opencascade视立方和三维箭头的实现

1.设置一个小的三维箭头

myV3dView->TriedronDisplay(Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.10, V3d_ZBUFFER);

2.创建一个带三维坐标箭头的视立方

	////设置视方体
	Handle(AIS_ViewCube) H_AisViewCube = new AIS_ViewCube();
	//下面是自定义每个面的文本
	H_AisViewCube->SetFont("宋体");
	H_AisViewCube->SetBoxSideLabel(V3d_Xpos, "Right");
	H_AisViewCube->SetBoxSideLabel(V3d_Ypos, "Top");
	H_AisViewCube->SetBoxSideLabel(V3d_Zpos, "Front"); 
	H_AisViewCube->SetBoxSideLabel(V3d_Xneg, "Left");
	H_AisViewCube->SetBoxSideLabel(V3d_Yneg, "Bottoom");
	H_AisViewCube->SetBoxSideLabel(V3d_Zneg, "Back");
	H_AisViewCube->SetAxesLabels("X", "Y", "Z");	
	H_AisViewCube->SetBoxColor(Quantity_NOC_WHITE); //设置视方体为白色
	H_AisViewCube->SetTransparency(0.5);   //设置透明度
	H_AisViewCube->SetTextColor(Quantity_Color(Quantity_NOC_BLACK)); //设置视方体每个面的字体为黑色
	H_AisViewCube->SetFontHeight(50); //设置视方体每个面字体的高度
	//设置视方体每个面的边界线
	//首先创建一个Prs3d_Drawer 对象,一切属性的修改在myDraw 下进行
	const Handle(Prs3d_Drawer)& myDrawer = H_AisViewCube->Attributes();
	myDrawer->SetupOwnFaceBoundaryAspect();
	myDrawer->SetFaceBoundaryDraw(true);
	//设置边界线的颜色为蓝色
	myDrawer->FaceBoundaryAspect()->SetColor(Quantity_NameOfColor::Quantity_NOC_LIGHTSKYBLUE);
	myDrawer->FaceBoundaryAspect()->SetWidth(2.0);//设置边界线的宽度
	//H_AisViewCube->SetMaterial(Graphic3d_MaterialAspect(Graphic3d_NOM_DEFAULT));//设置材质
	//设置视方体基准线
	myDrawer->SetDatumAspect(new Prs3d_DatumAspect());
	const Handle_Prs3d_DatumAspect& datumAspect = H_AisViewCube->Attributes()->DatumAspect();
	//设置轴颜色
	datumAspect->ShadingAspect(Prs3d_DP_XAxis)->SetColor(Quantity_NOC_RED);
	datumAspect->ShadingAspect(Prs3d_DP_YAxis)->SetColor(Quantity_NOC_GREEN);
	datumAspect->ShadingAspect(Prs3d_DP_ZAxis)->SetColor(Quantity_NOC_BLUE);
	//设置X,Y,Z文本颜色
	datumAspect->TextAspect(Prs3d_DP_XAxis)->SetColor(Quantity_NOC_RED);
	datumAspect->TextAspect(Prs3d_DP_YAxis)->SetColor(Quantity_NOC_GREEN);
	datumAspect->TextAspect(Prs3d_DP_ZAxis)->SetColor(Quantity_NOC_BLUE);
	H_AisViewCube->SetTransformPersistence(
		new Graphic3d_TransformPers(
			Graphic3d_TMF_TriedronPers,
			Aspect_TOTP_LEFT_LOWER/*设置在右下角*/,
			Graphic3d_Vec2i(100, 100)));
	this->getContext()->Display(H_AisViewCube, Standard_True);

3.如果三维坐标和视立方不显示文字内容,参见我的另一篇文章

https://blog.youkuaiyun.com/kade123/article/details/132864025

QQ群:64181011 QQ:312559824

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值