From: nds Date: Fri, 21 Aug 2015 08:37:09 +0000 (+0300) Subject: Compsolid - Color/Wireframe/Shading operation apply to sub-objects. X-Git-Tag: V_1.4.0_beta4~296 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6eb2159e22cf1cf6d664e3847cc4b1a8d71af72d;p=modules%2Fshaper.git Compsolid - Color/Wireframe/Shading operation apply to sub-objects. --- diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index 2c9114380..cf6f70d9b 100755 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -222,14 +222,6 @@ TopAbs_ShapeEnum shapeType(const QString& theType) return TopAbs_SHAPE; } -bool isSubResult(ObjectPtr theObject) -{ - bool aSubResult = false; - - //ResultCompSolidPtr aCompsolidResult = std::dynamic_pointer_cast(aResult); - return aSubResult; -} - void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFeature, bool& hasParameter, bool& hasSubFeature) { hasResult = false; @@ -241,10 +233,7 @@ void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFe ResultPtr aResult = std::dynamic_pointer_cast(aObj); ResultParameterPtr aConstruction = std::dynamic_pointer_cast(aResult); - bool aSubResult = isSubResult(aResult); - - /// results of compsolids are not processed in SHOW/HIDE/WIREFRAME operations - hasResult = (aResult.get() != NULL && !aSubResult); + hasResult = (aResult.get() != NULL); hasFeature = (aFeature.get() != NULL); hasParameter = (aConstruction.get() != NULL); if (hasFeature) diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index 8557a43f9..f3625a1f8 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -174,12 +174,12 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu() if (aSelected == 1) { ObjectPtr aObject = aObjects.first(); if (aObject) { + if (hasResult && myWorkshop->canBeShaded(aObject)) { + action("WIREFRAME_CMD")->setEnabled(true); + action("SHADING_CMD")->setEnabled(true); + } if (!hasFeature) { if (aObject->isDisplayed()) { - if (aDisplayer->canBeShaded(aObject)) { - action("WIREFRAME_CMD")->setEnabled(true); - action("SHADING_CMD")->setEnabled(true); - } action("HIDE_CMD")->setEnabled(true); } else if (hasResult && (!hasParameter)) { action("SHOW_CMD")->setEnabled(true); @@ -198,7 +198,8 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu() } } } else { - if (hasResult && (!hasParameter)) { + // parameter is commented because the actions are not in the list of result parameter actions + if (hasResult /*&& (!hasParameter)*/) { action("SHOW_CMD")->setEnabled(true); action("HIDE_CMD")->setEnabled(true); action("SHOW_ONLY_CMD")->setEnabled(true); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 84b91bcf9..bdfd1b2d5 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -44,6 +44,7 @@ #include #include #include +#include //#include @@ -1315,6 +1316,21 @@ bool XGUI_Workshop::canMoveFeature() return aCanMove; } +//************************************************************** +bool XGUI_Workshop::canBeShaded(const ObjectPtr& theObject) const +{ + bool aCanBeShaded = myDisplayer->canBeShaded(theObject); + if (!aCanBeShaded) { + ResultCompSolidPtr aCompsolidResult = + std::dynamic_pointer_cast(theObject); + if (aCompsolidResult.get() != NULL) { // change colors for all sub-solids + for(int i = 0; i < aCompsolidResult->numberOfSubs() && !aCanBeShaded; i++) + aCanBeShaded = myDisplayer->canBeShaded(aCompsolidResult->subResult(i)); + } + } + return aCanBeShaded; +} + //************************************************************** bool XGUI_Workshop::canChangeColor() const { @@ -1399,11 +1415,8 @@ void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects) if (aResult.get() != NULL) { ResultCompSolidPtr aCompsolidResult = std::dynamic_pointer_cast(aResult); if (aCompsolidResult.get() != NULL) { // change colors for all sub-solids - for(int i = 0; i < aCompsolidResult->numberOfSubs(); i++) { - ResultPtr aSubResult = aCompsolidResult->subResult(i); - if (aSubResult.get()) - setColor(aSubResult, aColorResult); - } + for(int i = 0; i < aCompsolidResult->numberOfSubs(); i++) + setColor(aCompsolidResult->subResult(i), aColorResult); } setColor(aResult, aColorResult); } @@ -1507,6 +1520,14 @@ void XGUI_Workshop::setDisplayMode(const QObjectPtrList& theList, int theMode) { foreach(ObjectPtr aObj, theList) { myDisplayer->setDisplayMode(aObj, (XGUI_Displayer::DisplayMode)theMode, false); + + ResultCompSolidPtr aCompsolidResult = std::dynamic_pointer_cast(aObj); + if (aCompsolidResult.get() != NULL) { // change colors for all sub-solids + for(int i = 0; i < aCompsolidResult->numberOfSubs(); i++) { + myDisplayer->setDisplayMode(aCompsolidResult->subResult(i), + (XGUI_Displayer::DisplayMode)theMode, false); + } + } } if (theList.size() > 0) myDisplayer->updateViewer(); diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index aa7dfaa76..cc51d7880 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -164,6 +164,11 @@ Q_OBJECT //! Move selected features to be after the current feature void moveObjects(); + //! Returns true if the object can be shaded. If the object is a compsolid result, the method + //! checks subobjects of the result + //! \return boolean value + bool canBeShaded(const ObjectPtr& theObject) const; + //! Returns true if there is at least one selected body/construction/group result //! \return boolean value bool canChangeColor() const;