From c4a469ec1e1ac5dd7399f9de65e21eea775670ea Mon Sep 17 00:00:00 2001 From: vsv Date: Wed, 12 Sep 2018 16:29:29 +0300 Subject: [PATCH] Display highlight for all sub-objects of a Feature only for Construction Results. --- src/XGUI/XGUI_ViewerProxy.cpp | 55 +++++++++++++++++++++-------------- src/XGUI/XGUI_ViewerProxy.h | 3 +- 2 files changed, 35 insertions(+), 23 deletions(-) diff --git a/src/XGUI/XGUI_ViewerProxy.cpp b/src/XGUI/XGUI_ViewerProxy.cpp index 5aef6ec18..899ca492d 100644 --- a/src/XGUI/XGUI_ViewerProxy.cpp +++ b/src/XGUI/XGUI_ViewerProxy.cpp @@ -32,6 +32,7 @@ #include #include +#include #include @@ -289,14 +290,29 @@ void XGUI_ViewerProxy::onMouseDoubleClick(AppElements_ViewWindow* theWnd, QMouse 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); + + if (myResult->groupName() == ModelAPI_ResultConstruction::group()) { + FeaturePtr aFeature = ModelAPI_Feature::feature(myResult); + if (aFeature.get()) { + std::list aResults = aFeature->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_CYAN4); + aAis->SetZLayer(1); //Graphic3d_ZLayerId_Topmost + myHighlights.Append(aAis); + aContext->Display(aAis, false); + aContext->Deactivate(aAis); + } + } + } + else { + TopoDS_Shape aTShape = myResult->shape()->impl(); + Handle(AIS_Shape) aAis = new AIS_Shape(aTShape); aAis->SetColor(Quantity_NOC_CYAN4); aAis->SetZLayer(1); //Graphic3d_ZLayerId_Topmost myHighlights.Append(aAis); @@ -323,30 +339,25 @@ void XGUI_ViewerProxy::onMouseMove(AppElements_ViewWindow* theWnd, QMouseEvent* if (!aContext.IsNull()) { Handle(SelectMgr_EntityOwner) aOwner; Handle(AIS_InteractiveObject) anIO; - ObjectPtr aObj; bool isDisplayed = false; + ResultPtr aRes; 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; - } + aRes = std::dynamic_pointer_cast(aDisplayer->getObject(anIO)); + if (aRes.get() && (aRes != myResult)) { + eraseHighlight(); + myResult = aRes; + displayHighlight(); + aContext->UpdateCurrentViewer(); } + isDisplayed = aRes.get(); } if (!isDisplayed) { eraseHighlight(); aContext->UpdateCurrentViewer(); - myFeature = FeaturePtr(); + myResult = ResultPtr(); } } emit mouseMove(theWnd, theEvent); diff --git a/src/XGUI/XGUI_ViewerProxy.h b/src/XGUI/XGUI_ViewerProxy.h index 9c4755f82..0e3396fb8 100644 --- a/src/XGUI/XGUI_ViewerProxy.h +++ b/src/XGUI/XGUI_ViewerProxy.h @@ -24,6 +24,7 @@ #include "XGUI.h" #include #include +#include #include #include @@ -158,7 +159,7 @@ private slots: void eraseHighlight(); XGUI_Workshop* myWorkshop; - FeaturePtr myFeature; + ResultPtr myResult; AIS_ListOfInteractive myHighlights; }; -- 2.39.2