当前位置: 首页> 科技> 名企 > C# OCCT Winform 选中模型改变状态

C# OCCT Winform 选中模型改变状态

时间:2025/8/8 14:17:31来源:https://blog.csdn.net/Mrfor516/article/details/139780449 浏览次数:0次

选中状态设置

  _context  = new AIS_InteractiveContext(_viewer);var selectionDrawer = new Prs3d_Drawer();selectionDrawer.SetColor(Colors.Selection);selectionDrawer.SetDisplayMode(1);selectionDrawer.SetTransparency(0.1f);_context.SetSelectionStyle(selectionDrawer);_context.SetHighlightStyle(Prs3d_TypeOfHighlight.Selected, selectionDrawer);_context.SetHighlightStyle(Prs3d_TypeOfHighlight.LocalSelected, selectionDrawer);_context.SetHighlightStyle(Prs3d_TypeOfHighlight.SubIntensity, selectionDrawer);var hilightLocalDrawer = new Prs3d_Drawer();hilightLocalDrawer.SetColor(Colors.Highlight);hilightLocalDrawer.SetDisplayMode(1);_context.SetHighlightStyle(Prs3d_TypeOfHighlight.LocalDynamic, hilightLocalDrawer);

其中,selectionDrawer 是设置鼠标点击选中颜色和样式,hilightLocalDrawer 是设置鼠标移动选中的颜色样式。

选择选中类型

在添加模型后使用 _context 的 Activate()函数才有作用

向场景添加 一个立方体 和 球 模型,在Display后进行选择模式设置,这样对立方体进行Face 选择,对球进行Wire 选择。还可以在所有模型添加完后整体设置

   _context.Activate(AIS_Shape.SelectionMode(TopAbs_ShapeEnum.WIRE));

这样在之前添加的模型都会设置为选中Wire。

 // 立方体var box = new BRepPrimAPI_MakeBox(100.0, 100.0, 100.0).Shape();var aisShape = new AIS_Shape(box);//_context.Display(aisShape, true); // 线框_context.Display(aisShape, 1, 2, true,true, PrsMgr_DisplayStatus.AIS_DS_Displayed); // 实体_context.Activate(aisShape, AIS_Shape.SelectionMode(TopAbs_ShapeEnum.FACE));// 球var sphere = new BRepPrimAPI_MakeSphere(new Pnt(100,100,150),30).Shape();var aissphere = new AIS_Shape(sphere);//_context.Display(aissphere, true); // 线框_context.Display(aissphere,1, 3, true, true, PrsMgr_DisplayStatus.AIS_DS_Displayed); // 实体                                                                 _context.Activate(aissphere, AIS_Shape.SelectionMode(TopAbs_ShapeEnum.WIRE));// 调整视图_view.FitAll();_view.MustBeResized();_view.Redraw();

1.Shape

  _context.Activate(AIS_Shape.SelectionMode(TopAbs_ShapeEnum.SHAPE));

2.Face

   _context.Activate(AIS_Shape.SelectionMode(TopAbs_ShapeEnum.FACE));

3.Wire

    _context.Activate(AIS_Shape.SelectionMode(TopAbs_ShapeEnum.WIRE));

4.Edge

  _context.Activate(AIS_Shape.SelectionMode(TopAbs_ShapeEnum.EDGE));

5.Vertex

  _context.Activate(AIS_Shape.SelectionMode(TopAbs_ShapeEnum.VERTEX));

关键字:C# OCCT Winform 选中模型改变状态

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: