1、显示全局坐标系、视图导航器、更改背景颜色和设置默认显示模式
1.1 在COCCDemoDoc::COCCDemoDoc()添加代码:
m_Viewer->SetDefaultLights();
m_Viewer->SetLightOn();
COCCDemoDoc::COCCDemoDoc()
{
Handle(Graphic3d_GraphicDriver) theGraphicDriver = ((COCCDemoApp*)AfxGetApp())->GetGraphicDriver();
m_Viewer = new V3d_Viewer(theGraphicDriver);
m_Viewer->SetDefaultLights();
m_Viewer->SetLightOn();
m_AISContext = new AIS_InteractiveContext(m_Viewer);
m_AISContext->SetDisplayMode(AIS_Shaded,true);
}
1.2 在void COCCDemoView::OnInitialUpdate()添加代码:
//显示坐标
m_View->TriedronDisplay(Aspect_TOTP_LEFT_LOWER, Quantity_NOC_GOLD, 0.1, V3d_ZBUFFER);
//通过提供颜色和填充方法(默认为水平)来定义视图的渐变背景色
m_View->SetBgGradientColors(Quantity_NOC_GRAY, Quantity_NOC_WHITE, Aspect_GFM_VER);
//视图导航器
Handle(AIS_ViewCube) aViewCube = new AIS_ViewCube();
aViewCube->SetTransformPersistence(
new Graphic3d_TransformPers(
Graphic3d_TMF_TriedronPers,
Aspect_TOTP_RIGHT_UPPER,
Graphic3d_Vec2i(100, 100)));
GetDocument()->GetAISContext()->Display(aViewCube, Standard_True);
void COCCDemoView::OnInitialUpdate()
{
CView::OnInitialUpdate();
m_View = GetDocument()->GetViewer()->CreateView();
Handle(WNT_Window) aWNTWindow = new WNT_Window(GetSafeHwnd());
m_View->SetWindow(aWNTWindow);
if (!aWNTWindow->IsMapped())
aWNTWindow->Map();
m_View->TriedronDisplay(Aspect_TOTP_LEFT_LOWER, Quantity_NOC_GOLD, 0.1, V3d_ZBUFFER);
m_View->SetBgGradientColors(Quantity_NOC_GRAY, Quantity_NOC_WHITE, Aspect_GFM_VER);
Handle(AIS_ViewCube) aViewCube = new AIS_ViewCube();
aViewCube->SetTransformPersistence(
new Graphic3d_TransformPers(
Graphic3d_TMF_TriedronPers,
Aspect_TOTP_RIGHT_UPPER,
Graphic3d_Vec2i(100, 100)));
GetDocument()->GetAISContext()->Display(aViewCube, Standard_True);
}
1.3 运行如图:
