X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_ContextMenuMgr.cpp;h=1a986b377ff86155065408fccb672b9f0b999a34;hb=6f213b9cc0ff018596fee19029d88ff8f8346025;hp=5ec4d3f083bcd5985f350c142a5247a17828c917;hpb=8a9ce2c0e7000a95da283f96bbb64d30cedb7c8c;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index 5ec4d3f08..1a986b377 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -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 +// #include "XGUI_ContextMenuMgr.h" #include "XGUI_Workshop.h" @@ -45,7 +63,6 @@ #include #include - XGUI_ContextMenuMgr::XGUI_ContextMenuMgr(XGUI_Workshop* theParent) : QObject(theParent), myWorkshop(theParent), @@ -90,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); @@ -152,6 +175,11 @@ void XGUI_ContextMenuMgr::createActions() tr("Select parent feature"), aDesktop); addAction("SHOW_FEATURE_CMD", aAction); +#ifdef TINSPECTOR + aAction = ModuleBase_Tools::createAction(QIcon(), tr("TInspector"), aDesktop); + addAction("TINSPECTOR_VIEW", aAction); +#endif + buildObjBrowserMenu(); buildViewerMenu(); } @@ -234,8 +262,9 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu() bool hasFeature = false; bool hasParameter = false; bool hasCompositeOwner = false; + bool hasResultInHistory = false; ModuleBase_Tools::checkObjects(aObjects, hasResult, hasFeature, hasParameter, - hasCompositeOwner); + hasCompositeOwner, hasResultInHistory); //Process Feature if (aSelected == 1) { ObjectPtr aObject = aObjects.first(); @@ -302,7 +331,7 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu() action("CLEAN_HISTORY_CMD")->setEnabled(true); action("SHOW_RESULTS_CMD")->setEnabled(hasFeature); - action("SHOW_FEATURE_CMD")->setEnabled(hasResult); + action("SHOW_FEATURE_CMD")->setEnabled(hasResult && hasResultInHistory); } // Show/Hide command has to be disabled for objects from non active document @@ -323,11 +352,17 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu() action("SHOW_ONLY_CMD")->setEnabled(false); } - if (myWorkshop->canChangeColor()) - action("COLOR_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); + #endif + #endif - if (myWorkshop->canChangeDeflection()) - action("DEFLECTION_CMD")->setEnabled(true); ModuleBase_IModule* aModule = myWorkshop->module(); if (aModule) @@ -375,8 +410,13 @@ void XGUI_ContextMenuMgr::updateViewerMenu() } else action("SHOW_CMD")->setEnabled(true); } + //issue #2159 Hide all incomplete behavior +#ifdef HAVE_SALOME + action("HIDEALL_CMD")->setEnabled(true); +#else if (myWorkshop->displayer()->objectsCount() > 0) action("HIDEALL_CMD")->setEnabled(true); +#endif // Update selection menu QIntList aModes = aDisplayer->activeSelectionModes(); @@ -414,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); } @@ -451,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; @@ -468,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 @@ -504,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; @@ -518,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; @@ -554,10 +611,19 @@ 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")); } +#ifdef _DEBUG + if (aSelected == 0) { + #ifdef TINSPECTOR + aActions.append(action("TINSPECTOR_VIEW")); + #endif + } +#endif theMenu->addActions(aActions); addFeatures(theMenu); @@ -603,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 aMenuActions; @@ -682,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()))