Opencascade基础教程(3):优化视图显示(显示全局坐标系、视图导航器、更改背景颜色和设置默认显示模式)

1、显示全局坐标系、视图导航器、更改背景颜色和设置默认显示模式

1.1 在COCCDemoDoc::COCCDemoDoc()添加代码:

	m_Viewer->SetDefaultLights();
	m_Viewer->SetLightOn();
// COCCDemoDoc 构造/析构
COCCDemoDoc::COCCDemoDoc()
{
	// TODO:  在此添加一次性构造代码
	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 运行如图:

在这里插入图片描述

链接: 源代码下载地址

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值