Salome HOME
Fix for the issue #3195 : The groups built by "Group Addtion" are not in ShaperResults
[modules/shaper.git] / src / XGUI / XGUI_ContextMenuMgr.cpp
index 3c5146ffcfaffd7f49285e134e6a20363b00bbc8..fe220b6578c83044f9938a0b15e9f4329e7be525 100644 (file)
@@ -140,10 +140,14 @@ void XGUI_ContextMenuMgr::createActions()
                                            aDesktop);
   addAction("WIREFRAME_CMD", aAction);
 
-  aAction = ModuleBase_Tools::createAction(QIcon(":pictures/iso_lines.png"), tr("Iso-lines..."),
+  aAction = ModuleBase_Tools::createAction(QIcon(":pictures/iso_lines.png"), tr("Define Isos..."),
                                            aDesktop);
   addAction("ISOLINES_CMD", aAction);
 
+  aAction = ModuleBase_Tools::createAction(QIcon(), tr("Show Isos..."), aDesktop);
+  aAction->setCheckable(true);
+  addAction("SHOW_ISOLINES_CMD", aAction);
+
   mySeparator1 = ModuleBase_Tools::createAction(QIcon(), "", aDesktop);
   mySeparator1->setSeparator(true);
 
@@ -306,22 +310,25 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu()
     //Process Feature
     if (aSelected == 1) { // single selection
       ObjectPtr aObject = aObjects.first();
+      ResultPtr aResult;
+      if (hasResult)
+        aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aObject);
       if (aObject) {
         if (hasResult && myWorkshop->canBeShaded(aObject)) {
           XGUI_Displayer::DisplayMode aMode = aDisplayer->displayMode(aObject);
           if (aMode != XGUI_Displayer::NoMode) {
             action("WIREFRAME_CMD")->setEnabled(aMode == XGUI_Displayer::Shading);
             action("SHADING_CMD")->setEnabled(aMode == XGUI_Displayer::Wireframe);
-            action("ISOLINES_CMD")->setEnabled(true);
           } else {
             action("WIREFRAME_CMD")->setEnabled(true);
             action("SHADING_CMD")->setEnabled(true);
-            action("ISOLINES_CMD")->setEnabled(true);
           }
+          action("SHOW_ISOLINES_CMD")->setEnabled(true);
+          action("SHOW_ISOLINES_CMD")->setChecked(ModelAPI_Tools::isShownIsoLines(aResult));
+          action("ISOLINES_CMD")->setEnabled(true);
         }
         if (!hasFeature) {
-          bool aHasSubResults = ModelAPI_Tools::hasSubResults(
-                                            std::dynamic_pointer_cast<ModelAPI_Result>(aObject));
+          bool aHasSubResults = ModelAPI_Tools::hasSubResults(aResult);
           if (aHasSubResults) {
             action("HIDE_CMD")->setEnabled(true);
             action("SHOW_CMD")->setEnabled(true);
@@ -358,6 +365,7 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu()
         action("SHOW_ONLY_CMD")->setEnabled(true);
         action("SHADING_CMD")->setEnabled(true);
         action("WIREFRAME_CMD")->setEnabled(true);
+        action("SHOW_ISOLINES_CMD")->setEnabled(true);
         action("ISOLINES_CMD")->setEnabled(true);
       }
       if (hasFeature && myWorkshop->canMoveFeature()) {
@@ -544,11 +552,18 @@ void XGUI_ContextMenuMgr::updateViewerMenu()
         if (aMode != XGUI_Displayer::NoMode) {
           action("WIREFRAME_CMD")->setEnabled(aMode == XGUI_Displayer::Shading);
           action("SHADING_CMD")->setEnabled(aMode == XGUI_Displayer::Wireframe);
-          action("ISOLINES_CMD")->setEnabled(true);
         } else {
           action("WIREFRAME_CMD")->setEnabled(true);
           action("SHADING_CMD")->setEnabled(true);
-          action("ISOLINES_CMD")->setEnabled(true);
+        }
+        action("ISOLINES_CMD")->setEnabled(true);
+
+        if (aPrsList.size() == 1) {
+          ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aObject);
+          if (aResult.get()) {
+            action("SHOW_ISOLINES_CMD")->setEnabled(true);
+            action("SHOW_ISOLINES_CMD")->setChecked(ModelAPI_Tools::isShownIsoLines(aResult));
+          }
         }
       }
       action("SHOW_ONLY_CMD")->setEnabled(true);
@@ -664,6 +679,7 @@ void XGUI_ContextMenuMgr::buildObjBrowserMenu()
   aList.append(action("COLOR_CMD"));
   aList.append(action("DEFLECTION_CMD"));
   aList.append(action("TRANSPARENCY_CMD"));
+  aList.append(action("SHOW_ISOLINES_CMD"));
   aList.append(action("ISOLINES_CMD"));
   aList.append(action("SHOW_FEATURE_CMD"));
   aList.append(mySeparator3);
@@ -740,6 +756,7 @@ void XGUI_ContextMenuMgr::buildViewerMenu()
   aList.append(action("COLOR_CMD"));
   aList.append(action("DEFLECTION_CMD"));
   aList.append(action("TRANSPARENCY_CMD"));
+  aList.append(action("SHOW_ISOLINES_CMD"));
   aList.append(action("ISOLINES_CMD"));
   aList.append(mySeparator3);
   aList.append(action("SET_VIEW_NORMAL_CMD"));
@@ -794,6 +811,7 @@ void XGUI_ContextMenuMgr::addObjBrowserMenu(QMenu* theMenu) const
       aActions.append(action("COLOR_CMD"));
       aActions.append(action("DEFLECTION_CMD"));
       aActions.append(action("TRANSPARENCY_CMD"));
+      aActions.append(action("SHOW_ISOLINES_CMD"));
       aActions.append(action("ISOLINES_CMD"));
       aActions.append(action("CLEAN_HISTORY_CMD"));
       aActions.append(action("DELETE_CMD"));