]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/XGUI/XGUI_ContextMenuMgr.cpp
Salome HOME
Draft of transparency
[modules/shaper.git] / src / XGUI / XGUI_ContextMenuMgr.cpp
index 89e8d9c8ed2213602f114865fb8c377c707e9ee6..1a986b377ff86155065408fccb672b9f0b999a34 100644 (file)
@@ -1,4 +1,22 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
 
 #include "XGUI_ContextMenuMgr.h"
 #include "XGUI_Workshop.h"
@@ -89,6 +107,12 @@ void XGUI_ContextMenuMgr::createActions()
   aAction = ModuleBase_Tools::createAction(QIcon(""), tr("Deflection..."), aDesktop);
   addAction("DEFLECTION_CMD", aAction);
 
+#ifdef USE_TRANSPARENCY
+  aAction = ModuleBase_Tools::createAction(QIcon(":pictures/transparency.png"),
+                                           tr("Transparency..."), aDesktop);
+  addAction("TRANSPARENCY_CMD", aAction);
+#endif
+
   aAction = ModuleBase_Tools::createAction(QIcon(":pictures/eye_pencil.png"), tr("Show"), aDesktop);
   addAction("SHOW_CMD", aAction);
 
@@ -328,12 +352,11 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu()
     action("SHOW_ONLY_CMD")->setEnabled(false);
   }
 
-  if (myWorkshop->canChangeColor())
-    action("COLOR_CMD")->setEnabled(true);
-
-  if (myWorkshop->canChangeDeflection())
-    action("DEFLECTION_CMD")->setEnabled(true);
-
+  action("COLOR_CMD")->setEnabled(myWorkshop->canChangeProperty("COLOR_CMD"));
+  action("DEFLECTION_CMD")->setEnabled(myWorkshop->canChangeProperty("DEFLECTION_CMD"));
+#ifdef USE_TRANSPARENCY
+  action("TRANSPARENCY_CMD")->setEnabled(myWorkshop->canChangeProperty("TRANSPARENCY_CMD"));
+#endif
   #ifdef _DEBUG
     #ifdef TINSPECTOR
       action("TINSPECTOR_VIEW")->setEnabled(true);
@@ -431,12 +454,17 @@ void XGUI_ContextMenuMgr::updateViewerMenu()
   if (aModule)
     aModule->updateViewerMenu(myActions);
 
-  if (myWorkshop->canChangeColor())
+  if (myWorkshop->canChangeProperty("COLOR_CMD"))
     action("COLOR_CMD")->setEnabled(true);
 
-  if (myWorkshop->canChangeDeflection())
+  if (myWorkshop->canChangeProperty("DEFLECTION_CMD"))
     action("DEFLECTION_CMD")->setEnabled(true);
 
+#ifdef USE_TRANSPARENCY
+  if (myWorkshop->canChangeProperty("TRANSPARENCY_CMD"))
+    action("TRANSPARENCY_CMD")->setEnabled(true);
+#endif
+
   action("DELETE_CMD")->setEnabled(true);
 }
 
@@ -468,6 +496,9 @@ void XGUI_ContextMenuMgr::buildObjBrowserMenu()
   aList.append(action("RENAME_CMD"));
   aList.append(action("COLOR_CMD"));
   aList.append(action("DEFLECTION_CMD"));
+#ifdef USE_TRANSPARENCY
+  aList.append(action("TRANSPARENCY_CMD"));
+#endif
   aList.append(action("SHOW_FEATURE_CMD"));
   myObjBrowserMenus[ModelAPI_ResultConstruction::group()] = aList;
 
@@ -485,6 +516,9 @@ void XGUI_ContextMenuMgr::buildObjBrowserMenu()
   aList.append(action("RENAME_CMD"));
   aList.append(action("COLOR_CMD"));
   aList.append(action("DEFLECTION_CMD"));
+#ifdef USE_TRANSPARENCY
+  aList.append(action("TRANSPARENCY_CMD"));
+#endif
   aList.append(action("SHOW_FEATURE_CMD"));
   myObjBrowserMenus[ModelAPI_ResultBody::group()] = aList;
   // Group menu
@@ -521,6 +555,9 @@ void XGUI_ContextMenuMgr::buildViewerMenu()
   aList.append(mySeparator);
   aList.append(action("COLOR_CMD"));
   aList.append(action("DEFLECTION_CMD"));
+#ifdef USE_TRANSPARENCY
+  aList.append(action("TRANSPARENCY_CMD"));
+#endif
   myViewerMenu[ModelAPI_ResultConstruction::group()] = aList;
   // Result part menu
   myViewerMenu[ModelAPI_ResultPart::group()] = aList;
@@ -535,6 +572,9 @@ void XGUI_ContextMenuMgr::buildViewerMenu()
   aList.append(mySeparator);
   aList.append(action("COLOR_CMD"));
   aList.append(action("DEFLECTION_CMD"));
+#ifdef USE_TRANSPARENCY
+  aList.append(action("TRANSPARENCY_CMD"));
+#endif
   myViewerMenu[ModelAPI_ResultBody::group()] = aList;
   // Group menu
   myViewerMenu[ModelAPI_ResultGroup::group()] = aList;
@@ -571,7 +611,9 @@ void XGUI_ContextMenuMgr::addObjBrowserMenu(QMenu* theMenu) const
       //aActions.append(action("MOVE_CMD"));
       aActions.append(action("COLOR_CMD"));
       aActions.append(action("DEFLECTION_CMD"));
-
+#ifdef USE_TRANSPARENCY
+      aActions.append(action("TRANSPARENCY_CMD"));
+#endif
       aActions.append(action("CLEAN_HISTORY_CMD"));
       aActions.append(action("DELETE_CMD"));
   }
@@ -627,7 +669,9 @@ void XGUI_ContextMenuMgr::addViewerMenu(QMenu* theMenu) const
   aActions.append(action("HIDEALL_CMD"));
   aActions.append(action("COLOR_CMD"));
   aActions.append(action("DEFLECTION_CMD"));
-
+#ifdef USE_TRANSPARENCY
+  aActions.append(action("TRANSPARENCY_CMD"));
+#endif
   theMenu->addActions(aActions);
 
   QMap<int, QAction*> aMenuActions;
@@ -706,7 +750,7 @@ void XGUI_ContextMenuMgr::addFeatures(QMenu* theMenu) const
   bool aIsRoot = false;
   foreach(QModelIndex aIdx, aSelectedIndexes) {
     // Process only first column
-    if (aIdx.column() == 0) {
+    if (aIdx.column() == 1) {
       aIsRoot = !aIdx.parent().isValid();
       // Exit if the selected index belongs to non active document
       if (aIsRoot && (aActiveDoc != aMgr->moduleDocument()))