From: vsv Date: Thu, 9 Aug 2018 15:43:28 +0000 (+0300) Subject: Task 2.2.5: Highlight all results if a shape of a one result is preselected X-Git-Tag: SHAPER_V9_1_0RC1~84 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d14f608e765948eb2f0a37fedb8a1ef44abf2610;p=modules%2Fshaper.git Task 2.2.5: Highlight all results if a shape of a one result is preselected --- diff --git a/src/XGUI/XGUI_Selection.cpp b/src/XGUI/XGUI_Selection.cpp index ed54a60a2..04db48853 100644 --- a/src/XGUI/XGUI_Selection.cpp +++ b/src/XGUI/XGUI_Selection.cpp @@ -143,7 +143,6 @@ void XGUI_Selection::fillPresentation(ModuleBase_ViewerPrsPtr& thePrs, const Handle(SelectMgr_EntityOwner)& theOwner) const { thePrs->setOwner(theOwner); - Handle(SelectMgr_SelectableObject) aSelectable = theOwner->Selectable(); Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable()); thePrs->setInteractive(anIO); diff --git a/src/XGUI/XGUI_ViewerProxy.cpp b/src/XGUI/XGUI_ViewerProxy.cpp index 788a0d906..d763573e3 100644 --- a/src/XGUI/XGUI_ViewerProxy.cpp +++ b/src/XGUI/XGUI_ViewerProxy.cpp @@ -31,6 +31,9 @@ #endif #include +#include + +#include #include @@ -283,8 +286,69 @@ void XGUI_ViewerProxy::onMouseDoubleClick(AppElements_ViewWindow* theWnd, QMouse emit mouseDoubleClick(theWnd, theEvent); } +void XGUI_ViewerProxy::displayHighlight() +{ + Handle(AIS_InteractiveContext) aContext = AISContext(); + std::list aResults = myFeature->results(); + std::list::const_iterator aIt; + ResultPtr aRes; + Handle(AIS_Shape) aAis; + for (aIt = aResults.cbegin(); aIt != aResults.cend(); aIt++) { + aRes = (*aIt); + TopoDS_Shape aTShape = aRes->shape()->impl(); + aAis = new AIS_Shape(aTShape); + aAis->SetColor(Quantity_NOC_CYAN3); + aAis->SetZLayer(Graphic3d_ZLayerId_Topmost); + myHighlights.Append(aAis); + aContext->Display(aAis, false); + aContext->Deactivate(aAis); + } +} + +void XGUI_ViewerProxy::eraseHighlight() +{ + Handle(AIS_InteractiveContext) aContext = AISContext(); + Handle(AIS_InteractiveObject) anAISIO; + AIS_ListIteratorOfListOfInteractive aLIt; + for (aLIt.Initialize(myHighlights); aLIt.More(); aLIt.Next()) { + anAISIO = aLIt.Value(); + aContext->Remove(anAISIO, false); + } + myHighlights.Clear(); +} + void XGUI_ViewerProxy::onMouseMove(AppElements_ViewWindow* theWnd, QMouseEvent* theEvent) { + Handle(AIS_InteractiveContext) aContext = AISContext(); + if (!aContext.IsNull()) { + Handle(SelectMgr_EntityOwner) aOwner; + Handle(AIS_InteractiveObject) anIO; + ObjectPtr aObj; + bool isDisplayed = false; + XGUI_Displayer* aDisplayer = myWorkshop->displayer(); + for (aContext->InitDetected(); aContext->MoreDetected(); aContext->NextDetected()) { + aOwner = aContext->DetectedOwner(); + anIO = Handle(AIS_InteractiveObject)::DownCast(aOwner->Selectable()); + aObj = aDisplayer->getObject(anIO); + if (aObj.get()) { + FeaturePtr aFeature = ModelAPI_Feature::feature(aObj); + if (aFeature.get()) { + if (aFeature != myFeature) { + eraseHighlight(); + myFeature = aFeature; + displayHighlight(); + aContext->UpdateCurrentViewer(); + } + isDisplayed = true; + } + } + } + if (!isDisplayed) { + eraseHighlight(); + aContext->UpdateCurrentViewer(); + myFeature = FeaturePtr(); + } + } emit mouseMove(theWnd, theEvent); } diff --git a/src/XGUI/XGUI_ViewerProxy.h b/src/XGUI/XGUI_ViewerProxy.h index 93e76332b..9c4755f82 100644 --- a/src/XGUI/XGUI_ViewerProxy.h +++ b/src/XGUI/XGUI_ViewerProxy.h @@ -23,8 +23,10 @@ #include "XGUI.h" #include +#include #include +#include #ifndef HAVE_SALOME #include @@ -152,7 +154,12 @@ private slots: #endif private: + void displayHighlight(); + void eraseHighlight(); + XGUI_Workshop* myWorkshop; + FeaturePtr myFeature; + AIS_ListOfInteractive myHighlights; }; #endif