]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Update pop-up menu of group object.
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 31 Oct 2014 13:53:07 +0000 (16:53 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 31 Oct 2014 13:53:07 +0000 (16:53 +0300)
src/XGUI/XGUI_ContextMenuMgr.cpp

index a9618988920f1a3df15eb3303d335e16bed1a827..f951d7a279fc590625f6225a739585838f92caf9 100644 (file)
@@ -14,6 +14,7 @@
 #include <ModelAPI_Object.h>
 #include <ModelAPI_ResultPart.h>
 #include <ModelAPI_Session.h>
+#include <ModelAPI_ResultGroup.h>
 
 #include <QAction>
 #include <QContextMenuEvent>
@@ -120,58 +121,64 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const
     XGUI_Displayer* aDisplayer = myWorkshop->displayer();
     bool hasResult = false;
     bool hasFeature = false;
+    bool hasGroup = false;
     foreach(ObjectPtr aObj, aObjects)
     {
       FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
       ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(aObj);
+      ResultGroupPtr aGroupRes = boost::dynamic_pointer_cast<ModelAPI_ResultGroup>(aObj);
       if (aResult)
         hasResult = true;
       if (aFeature)
         hasFeature = true;
-      if (hasFeature && hasResult)
+      if (aGroupRes)
+        hasGroup = true;
+      if (hasFeature && hasResult && hasGroup)
         break;
     }
     //Process Feature
-    if (aSelected == 1) {
-      ObjectPtr aObject = aObjects.first();
-      if (aObject) {
-        ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aObject);
-        if (aPart) {
-          if (aMgr->activeDocument() == aPart->partDoc())
-            aMenu->addAction(action("DEACTIVATE_PART_CMD"));
-          else
-            aMenu->addAction(action("ACTIVATE_PART_CMD"));
-        } else if (hasFeature) {
-          aMenu->addAction(action("EDIT_CMD"));
-        } else {
-          if (aDisplayer->isVisible(aObject)) {
-            if (aDisplayer->displayMode(aObject) == XGUI_Displayer::Shading)
-              aMenu->addAction(action("WIREFRAME_CMD"));
+    if (!hasGroup) {
+      if (aSelected == 1) {
+        ObjectPtr aObject = aObjects.first();
+        if (aObject) {
+          ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aObject);
+          if (aPart) {
+            if (aMgr->activeDocument() == aPart->partDoc())
+              aMenu->addAction(action("DEACTIVATE_PART_CMD"));
             else
-              aMenu->addAction(action("SHADING_CMD"));
-            aMenu->addSeparator();
-            aMenu->addAction(action("HIDE_CMD"));
+              aMenu->addAction(action("ACTIVATE_PART_CMD"));
+          } else if (hasFeature) {
+            aMenu->addAction(action("EDIT_CMD"));
           } else {
-            aMenu->addAction(action("SHOW_CMD"));
+            if (aDisplayer->isVisible(aObject)) {
+              if (aDisplayer->displayMode(aObject) == XGUI_Displayer::Shading)
+                aMenu->addAction(action("WIREFRAME_CMD"));
+              else
+                aMenu->addAction(action("SHADING_CMD"));
+              aMenu->addSeparator();
+              aMenu->addAction(action("HIDE_CMD"));
+            } else {
+              aMenu->addAction(action("SHOW_CMD"));
+            }
+            aMenu->addAction(action("SHOW_ONLY_CMD"));
           }
+        } else {  // If feature is 0 the it means that selected root object (document)
+          if (aMgr->activeDocument() != aMgr->moduleDocument())
+            aMenu->addAction(action("ACTIVATE_PART_CMD"));
+        }
+      } else {
+        if (hasResult) {
+          aMenu->addAction(action("SHOW_CMD"));
+          aMenu->addAction(action("HIDE_CMD"));
           aMenu->addAction(action("SHOW_ONLY_CMD"));
+          aMenu->addSeparator();
+          aMenu->addAction(action("SHADING_CMD"));
+          aMenu->addAction(action("WIREFRAME_CMD"));
         }
-      } else {  // If feature is 0 the it means that selected root object (document)
-        if (aMgr->activeDocument() != aMgr->moduleDocument())
-          aMenu->addAction(action("ACTIVATE_PART_CMD"));
-      }
-    } else {
-      if (hasResult) {
-        aMenu->addAction(action("SHOW_CMD"));
-        aMenu->addAction(action("HIDE_CMD"));
-        aMenu->addAction(action("SHOW_ONLY_CMD"));
-        aMenu->addSeparator();
-        aMenu->addAction(action("SHADING_CMD"));
-        aMenu->addAction(action("WIREFRAME_CMD"));
       }
+      if (hasFeature)
+        aMenu->addAction(action("DELETE_CMD"));
     }
-    if (hasFeature)
-      aMenu->addAction(action("DELETE_CMD"));
   }
   aMenu->addSeparator();
   aMenu->addActions(myWorkshop->objectBrowser()->actions());