Mouse focus on AIS_Shape or selected AIS_Shape, the shape display different color

kndpeng

CAD practitioner
I new myHilightDrawer and myDynHilight Drawer as selected Drawer and focus Drawer.
But after selected the shape, the normal Drawer is not hide. How to hide normal Drawer when selected status?

WireFrameDraw::WireFrameDraw(TopoDS_Shape const& shape)
: AIS_Shape(shape)
{
{
myHilightDrawer = new Prs3d_Drawer();
myHilightDrawer->SetColor(Quantity_NOC_GOLD);
myHilightDrawer->SetDisplayMode(DisplayMode::Selected);
myHilightDrawer->SetOwnLineAspects();

myHilightDrawer->WireAspect()->SetTypeOfLine(Aspect_TOL_DASH);
}

{
myDynHilightDrawer = new Prs3d_Drawer();
myDynHilightDrawer->SetColor(Quantity_NOC_CORAL);
myDynHilightDrawer->SetDisplayMode(DisplayMode::Highlight);
myDynHilightDrawer->SetOwnLineAspects();

myDynHilightDrawer->SetupOwnPointAspect();
{
auto& pointAspect = myDynHilightDrawer->PointAspect();
pointAspect->SetTypeOfMarker(Aspect_TOM_O_PLUS);
pointAspect->SetScale(4.0);
}
}

myDrawer->SetDisplayMode(DisplayMode::Normal);
}

void WireFrameDraw::Compute(Handle(PrsMgr_PresentationManager) const& thePresentationManager,
Handle(Prs3d_Presentation) const& prs,
Standard_Integer const mode)
{
if (myshape.IsNull()) {
return;
}

if (!AcceptDisplayMode(mode)) {
return;
}

switch (mode) {
case DisplayMode::Normal: {
prs->Clear();
thePresentationManager->SetDisplayPriority(this, DisplayMode::Normal, Graphic3d_DisplayPriority_Bottom);
StdPrs_WFShape::Add(prs, myshape, myDrawer);
} break;
case DisplayMode::Highlight: {
prs->Clear();
StdPrs_WFShape::Add(prs, myshape, myDynHilightDrawer);
thePresentationManager->SetDisplayPriority(this, DisplayMode::Highlight, Graphic3d_DisplayPriority_Normal);
} break;
case DisplayMode::Selected: {
prs->Clear();
thePresentationManager->SetDisplayPriority(this, DisplayMode::Selected, Graphic3d_DisplayPriority_Topmost);
//thePresentationManager->SetVisibility(this, DisplayMode::Normal, false);
//thePresentationManager->Clear(this, DisplayMode::Normal);
StdPrs_WFShape::Add(prs, myshape, myHilightDrawer);
} break;
}
}

The display effect as below:(normal, focus, selected)
1692765213524.png
1692765255998.png
1692765272975.png
 

natalia

Moderator
Staff member
Hello, kndpeng
Described situation looks like you want to hide the presentation itself when it's selected and have only its selection visible in the viewer. Is it right?

Regards, Natalia
 

kndpeng

CAD practitioner
when select the curve apply DisplayMode::Selected but DisplayMode::Normal alway display.
I want the effect below.
Hello, kndpeng
Described situation looks like you want to hide the presentation itself when it's selected and have only its selection visible in the viewer. Is it right?

Regards, Natalia


1692866539997.png
 

natalia

Moderator
Staff member
Hello, @kndpeng

You know, it’s not the usual way of working with OCCT visualization. Usually, the selection/highlight is shown above the presentation without influencing on the style of displayed presentation.

However, there is a way, how you may try to implement your case. It’s a creating own selection owner and when it’s shown/hidden, to change style of the source presentation. To find a way on how to embed such owner into presentation, have a look at similar owner, existing in OCCT for manipulator presentation (AIS_ManipulatorOwner). A place to change the style of the source presentation is ‘HilightWithColor’ and ‘Unhilight’. As you use line presentation, it might be change of type for the presentation. The code is similar to next:

Selectable()->Attributes()->LineAspect()->SetTypeOfLine(Aspect_TOL_EMPTY);

It may require some redraw of displayed presentation, please check.

Regards, Natalia
 
Top