eryar

PipeCAD - Plant Piping Design Software.
RvmTranslator - Translate AVEVA RVM to OBJ, glTF, etc.
posts - 603, comments - 590, trackbacks - 0, articles - 0

OpenCASCADE Customize Highlighting

Posted on 2020-02-29 15:01 eryar 阅读(8860) 评论(0)  编辑 收藏 引用 所属分类: 2.OpenCASCADE

OpenCASCADE Customize Highlighting

eryar@163.com

 

The traditional way of highlighting selected entity owners adopted by Open CASCADE Technology assumes that each entity owner highlights itself on its own. This approach has two drawbacks:

l  each entity owner has to maintain its own Prs3d_Presentation object, that results in a considerable memory overhead;

l  drawing selected owners one by one is not efficient from the visualization point of view.

OpenCASCADE内置的高亮算法是每个模型都有自己的高亮实体,高亮的一般是模型的TopoDS_Edge,对于B样条曲面还会显示出一条UIso和VIso线。这种高亮显示策略不一定符合所有人的需求,而且会占用额外大量的内存。

 

Therefore, to overcome these limitations, OCCT has an alternative way to implement the highlighting of a selected presentation. Using this approach, the interactive object itself will be responsible for the highlighting, not the entity owner.

因此,为了克服上面的缺点,OCCT提供一个自定义高亮的方式,由交互对象自己来实现高亮显示,满足更多个性化的需求。

 

On the basis of SelectMgr_EntityOwner::IsAutoHilight() return value, AIS_InteractiveContext object either uses the traditional way of highlighting (in case if IsAutoHilight() returns TRUE) or groups such owners according to their selectable objects and finally calls SelectMgr_SelectableObject::HilightSelected() or SelectMgr_SelectableObject::ClearSelected(), passing a group of owners as an argument.

Hence, an application can derive its own interactive object and redefine virtual methods HilightSelected(), ClearSelected() and HilightOwnerWithColor() from SelectMgr_SelectableObject. SelectMgr_SelectableObject::GetHilightPresentation and SelectMgr_SelectableObject::GetSelectPresentation methods can be used to optimize filling of selection and highlight presentations according to the user's needs. The AIS_InteractiveContext::HighlightSelected() method can be used for efficient redrawing of the selection presentation for a given interactive object from an application code.

当SelectMgr_SelectableObject的所有子类的IsAutoHilight()返回true时,则是由OCCT自动实现高亮选择效果。当IsAutoHilight()返回false时,则交互对象的高亮显示交给用户自己来实现。具体实现步骤为从类SelectMgr_SelectableObject派生出一个子类,重写三个虚函数:

l  HilightSelected():交互对象选中时的高亮显示效果;

l  ClearSelected():清除对象选中时的高亮效果;

l  HilightOwnerWithColor():鼠标移动到交互对象上时的高亮效果;

 

如上图所示为OCCT自动高亮显示效果,模型的每个Edge都高亮显示;

 

上图所示为自己实现模型的高亮效果,只高亮显示模型的外边框。这样高亮显示的数据少,占用内存就少,效率更高。


为了方便大家在移动端也能看到我的博文和讨论交流,现已注册微信公众号,欢迎大家扫描下方二维码关注。
Shing Liu(eryar@163.com)

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理