From: mbs Date: Wed, 3 Apr 2024 18:05:55 +0000 (+0100) Subject: [bos #40617] Preserve colors with clippling plane X-Git-Tag: V9_13_0a1~12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b1885170db797c5af476c74cdc0aacf034331024;p=modules%2Fshaper.git [bos #40617] Preserve colors with clippling plane --- diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 4b99d0e15..477544490 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -51,7 +51,11 @@ #include #include +#include #include +#include +#include +#include #include #include @@ -64,6 +68,8 @@ #include #endif #include +#include +#include #include #include #include @@ -133,6 +139,23 @@ QString qIntListInfo(const QIntList& theValues, const QString& theSeparator = QS return anInfo.join(theSeparator); } +/// Apply the clipping planes to all objects in the "OCC3D" viewer. +void applyClippingPlanes() +{ + SUIT_Application *pApp = SUIT_Session::session()->activeApplication(); + QList viewMgrs; + pApp->viewManagers(QString("OCCViewer"), viewMgrs); + if (!viewMgrs.isEmpty()) { + SUIT_ViewManager *pViewMgr = viewMgrs.first(); + if (pViewMgr) { + SUIT_ViewModel *pViewMdl = pViewMgr->getViewModel(); + if (pViewMdl) { + pViewMdl->applyClippingPlanes(true); + } + } + } +} + //************************************************************** XGUI_Displayer::XGUI_Displayer(XGUI_Workshop* theWorkshop) : myWorkshop(theWorkshop), @@ -180,6 +203,11 @@ bool XGUI_Displayer::display(ObjectPtr theObject, bool theUpdateViewer) if (anAIS.get()) aDisplayed = display(theObject, anAIS, isShading, theUpdateViewer); } + + if (aDisplayed) { + applyClippingPlanes(); + } + return aDisplayed; } @@ -217,6 +245,27 @@ bool XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS, if (!anAISIO.IsNull()) { appendResultObject(theObject, theAIS); + // bos#40617: Apply clipping planes + // Retrieve the clipping plane from the OCCT Presentation Manager directly, + // as they are stored in the ViewModel of the OCCViewer in GUI, where we + // don't have access to. + Handle(ViewerData_AISShape) aShape = Handle(ViewerData_AISShape)::DownCast (anAISIO); + if (!aShape.IsNull() && aShape->IsClippable()) { + Graphic3d_MapOfStructure aSetOfStructures; + aContext->MainPrsMgr()->StructureManager()->DisplayedStructures( aSetOfStructures ); + Graphic3d_MapIteratorOfMapOfStructure aStructureIt( aSetOfStructures ); + for( ; aStructureIt.More(); aStructureIt.Next() ) { + const Handle(Graphic3d_Structure)& aStructure = aStructureIt.Key(); + if ( aStructure->IsEmpty() || !aStructure->IsVisible() || aStructure->CStructure()->IsForHighlight ) + continue; + const Handle(Graphic3d_SequenceOfHClipPlane) &planes = aStructure->ClipPlanes(); + if (!planes.IsNull() && !planes->IsEmpty()) { + aShape->SetClipPlanes(planes); + break; + } + } + } + //bool isCustomized = customizeObject(theObject); int aDispMode = isShading? Shading : Wireframe; @@ -269,6 +318,10 @@ bool XGUI_Displayer::erase(ObjectPtr theObject, const bool theUpdateViewer) } myResult2AISObjectMap.remove(theObject); + if (aErased) { + applyClippingPlanes(); + } + #ifdef DEBUG_DISPLAY std::ostringstream aPtrStr; aPtrStr << theObject.get();