]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Compsolid - Color/Wireframe/Shading operation apply to sub-objects.
authornds <nds@opencascade.com>
Fri, 21 Aug 2015 08:37:09 +0000 (11:37 +0300)
committernds <nds@opencascade.com>
Fri, 21 Aug 2015 08:37:48 +0000 (11:37 +0300)
src/ModuleBase/ModuleBase_Tools.cpp
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index 2c9114380671d1afaae6b284b6c06b2437cb9f11..cf6f70d9b66a044db4055c6a806889884acdbc1b 100755 (executable)
@@ -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<ModelAPI_ResultCompSolid>(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<ModelAPI_Result>(aObj);
     ResultParameterPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultParameter>(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) 
index 8557a43f972489ffbb5c490282131b11e69f11b6..f3625a1f88a70aefc22b951dbe1fe757294c3c1b 100644 (file)
@@ -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);
index 84b91bcf9e3d1d4b3f83dc87d3a0f8f141b3526c..bdfd1b2d50c3a8e7c032d24d2c36d38ccac7b3ca 100644 (file)
@@ -44,6 +44,7 @@
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
 #include <ModelAPI_ResultCompSolid.h>
+#include <ModelAPI_Tools.h>
 
 //#include <PartSetPlugin_Part.h>
 
@@ -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<ModelAPI_ResultCompSolid>(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<ModelAPI_ResultCompSolid>(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<ModelAPI_ResultCompSolid>(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();
index aa7dfaa767f57d920f379fc750e61220ea033661..cc51d7880ff09b2e902faa7df679591783d117c4 100644 (file)
@@ -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;