From e8ad141f26976dcca9721bb579f10f2c98dd7e10 Mon Sep 17 00:00:00 2001 From: vsv Date: Wed, 21 Mar 2018 13:45:46 +0300 Subject: [PATCH] Make dynamic highlighting of nodes by ball pictures --- src/ModuleBase/ModuleBase_IViewer.cpp | 2 ++ src/ModuleBase/ModuleBase_IViewer.h | 3 +++ src/ModuleBase/ModuleBase_Tools.cpp | 20 ++++++++++++-------- src/XGUI/XGUI_Displayer.cpp | 2 ++ 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/ModuleBase/ModuleBase_IViewer.cpp b/src/ModuleBase/ModuleBase_IViewer.cpp index dc7b8a202..bb514d31f 100644 --- a/src/ModuleBase/ModuleBase_IViewer.cpp +++ b/src/ModuleBase/ModuleBase_IViewer.cpp @@ -20,6 +20,8 @@ #include "ModuleBase_IViewer.h" +Handle(Prs3d_Drawer) ModuleBase_IViewer::DefaultHighlightDrawer; + ModuleBase_IViewer::ModuleBase_IViewer(QObject* theParent) : QObject(theParent) { diff --git a/src/ModuleBase/ModuleBase_IViewer.h b/src/ModuleBase/ModuleBase_IViewer.h index 087488ad9..c58173af9 100644 --- a/src/ModuleBase/ModuleBase_IViewer.h +++ b/src/ModuleBase/ModuleBase_IViewer.h @@ -129,6 +129,8 @@ Q_OBJECT /// Fit all along Z (perpendicular to display) //virtual void Zfitall() = 0; + static Handle(Prs3d_Drawer) DefaultHighlightDrawer; + signals: /// Signal emited when last view window is closed void lastViewClosed(); @@ -179,6 +181,7 @@ signals: protected: /// A map for storing a scale factors dependent on view object QMap myWindowScale; + }; #endif diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index 402e40bd8..bd50ee687 100755 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -53,6 +54,9 @@ #include #include +#include +#include +#include #include #include @@ -1137,11 +1141,13 @@ void setPointBallHighlighting(AIS_Shape* theAIS) } Handle(Graphic3d_AspectMarker3d) anAspect; - Handle(Prs3d_Drawer) aDrawer = theAIS->HilightAttributes(); -#ifdef USE_OCCT_720 - // to do: implement ball highlighting, in 7.2.0 this drawer is NULL -#else -/* + Handle(Prs3d_Drawer) aDrawer = theAIS->DynamicHilightAttributes(); + if (aDrawer.IsNull()) { + aDrawer = new Prs3d_Drawer(*ModuleBase_IViewer::DefaultHighlightDrawer); + if (!aDrawer->HasOwnPointAspect()) { + aDrawer->SetPointAspect(new Prs3d_PointAspect(Aspect_TOM_BALL, Quantity_NOC_BLACK, 2.0)); + } + } if(aDrawer->HasOwnPointAspect()) { Handle(Prs3d_PointAspect) aPntAspect = aDrawer->PointAspect(); if(aPixMap->IsEmpty()) { @@ -1157,10 +1163,8 @@ void setPointBallHighlighting(AIS_Shape* theAIS) aPntAspect->SetAspect(anAspect); } aDrawer->SetPointAspect(aPntAspect); - theAIS->SetHilightAttributes(aDrawer); + theAIS->SetDynamicHilightAttributes(aDrawer); } - */ -#endif } } // namespace ModuleBase_Tools diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index b0dec5323..6c2f216e3 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -662,6 +663,7 @@ Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const selectionActivate()->deactivateTrihedron(true); aContext->DefaultDrawer()->VIsoAspect()->SetNumber(0); aContext->DefaultDrawer()->UIsoAspect()->SetNumber(0); + ModuleBase_IViewer::DefaultHighlightDrawer = aContext->HighlightStyle(); } return aContext; } -- 2.39.2