AECSoft

专注于AEC行业软件开发15年

导航

[原创]HOW TO: 在OCC中实现Show&Hide功能

作者:spas

Open Cascade没有提供明显的Show/Hide功能,偶逛遍国内外论坛,都没有人提到如何实现,可能是太简单不值一提吧。不过还是害我浪费了不少时间。

可利用AIS_InteractiveContext中的Erase功能实现Hide。其声明如下:

void Erase(const Handle(AIS_InteractiveObject)& aniobj,const Standard_Boolean updateviewer = Standard_True,const Standard_Boolean PutInCollector = Standard_True) ;

其中,PutInCollector参数是指是否将aniobj放到CollectorViewer中,如果为True,则可用AIS_InteractiveContext的DisplayFromCollector函数实现Show。其声明如下:

void DisplayFromCollector(const Handle(AIS_InteractiveObject)& anIObj,const Standard_Boolean updateviewer = Standard_True)

需要注意的是:在新建AIS_InteractiveContext对象时,一定要创建一个CollectViewer传进去,否则上述方法不起作用。如下代码:
Handle_V3d_Viewer myViewer;
Handle_V3d_Viewer myCollectorViewer;
Handle_AIS_InteractiveContext myAISContext;

Handle(Graphic3d_WNTGraphicDevice) theGraphicDevice =
((OCC_3dApp*)AfxGetApp())->GetGraphicDevice();

myViewer = new V3d_Viewer(theGraphicDevice,(short \*) "Visu3D");
myViewer->SetDefaultLights();
myViewer->SetLightOn();
myCollectorViewer = new V3d_Viewer(theGraphicDevice,(short \*) "Visu3DCollector");
myAISContext =new AIS_InteractiveContext(myViewer, myCollectorViewer);

 
阅读全文
类别:信息技术 查看评论

posted on 2009-04-06 18:09  zuoc  阅读(653)  评论(0编辑  收藏  举报