From: vsv Date: Fri, 30 May 2014 07:04:19 +0000 (+0400) Subject: Show/Hide menu items added X-Git-Tag: V_0.4.4~340 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=be5d3c5c86f60641e7728c6205eaa16e372c69db;p=modules%2Fshaper.git Show/Hide menu items added --- diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index 38e74834b..0abbb09ff 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -3,6 +3,7 @@ #include "XGUI_Workshop.h" #include "XGUI_ObjectsBrowser.h" #include "XGUI_SelectionMgr.h" +#include "XGUI_Displayer.h" #include #include @@ -15,7 +16,6 @@ XGUI_ContextMenuMgr::XGUI_ContextMenuMgr(XGUI_Workshop* theParent) : QObject(theParent), myWorkshop(theParent) { - } XGUI_ContextMenuMgr::~XGUI_ContextMenuMgr() @@ -35,6 +35,12 @@ void XGUI_ContextMenuMgr::createActions() aAction = new QAction(QIcon(":pictures/delete.png"), tr("Delete"), this); addAction("DELETE_CMD", aAction); + + aAction = new QAction(QIcon(":pictures/eye_pencil.png"), tr("Show"), this); + addAction("SHOW_CMD", aAction); + + aAction = new QAction(QIcon(":pictures/eye_pencil_closed.png"), tr("Hide"), this); + addAction("HIDE_CMD", aAction); } void XGUI_ContextMenuMgr::addAction(const QString& theId, QAction* theAction) @@ -82,7 +88,7 @@ void XGUI_ContextMenuMgr::onContextMenuRequest(QContextMenuEvent* theEvent) QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const { - QList aActions; + QMenu* aMenu = new QMenu(); XGUI_SelectionMgr* aSelMgr = myWorkshop->selector(); QFeatureList aFeatures = aSelMgr->selectedFeatures(); if (aFeatures.size() == 1) { @@ -94,27 +100,33 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const ObjectPtr aObject = boost::dynamic_pointer_cast(aFeature); DocumentPtr aFeaDoc = aObject->featureRef()->data()->docRef("PartDocument")->value(); if (aMgr->currentDocument() == aFeaDoc) - aActions.append(action("DEACTIVATE_PART_CMD")); + aMenu->addAction(action("DEACTIVATE_PART_CMD")); else - aActions.append(action("ACTIVATE_PART_CMD")); + aMenu->addAction(action("ACTIVATE_PART_CMD")); } else { - aActions.append(action("EDIT_CMD")); + aMenu->addAction(action("EDIT_CMD")); + + XGUI_Displayer* aDisplayer = myWorkshop->displayer(); + if (aDisplayer->IsVisible(aFeature)) + aMenu->addAction(action("HIDE_CMD")); + else + aMenu->addAction(action("SHOW_CMD")); } - aActions.append(action("DELETE_CMD")); + aMenu->addAction(action("DELETE_CMD")); + aMenu->addSeparator(); // Process Root object (document) } else { // If feature is 0 the it means that selected root object (document) if (aMgr->currentDocument() != aMgr->rootDocument()) { - aActions.append(action("ACTIVATE_PART_CMD")); + aMenu->addAction(action("ACTIVATE_PART_CMD")); } } } - aActions.append(myWorkshop->objectBrowser()->actions()); - if (aActions.size() > 0) { - QMenu* aMenu = new QMenu(); - aMenu->addActions(aActions); + aMenu->addActions(myWorkshop->objectBrowser()->actions()); + if (aMenu->actions().size() > 0) { return aMenu; } + delete aMenu; return 0; } diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 1a5d25095..a9c92ee70 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -776,6 +776,10 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked) activatePart(FeaturePtr()); else if (theId == "DELETE_CMD") deleteFeatures(aFeatures); + else if (theId == "SHOW_CMD") + showFeatures(aFeatures, true); + else if (theId == "HIDE_CMD") + showFeatures(aFeatures, false); } //************************************************************** @@ -828,3 +832,10 @@ void XGUI_Workshop::deleteFeatures(QFeatureList theList) aMgr->rootDocument()->finishOperation(); } } + +//************************************************************** +void XGUI_Workshop::showFeatures(QFeatureList theList, bool isVisible) +{ +// foreach (FeaturePtr aFeature, theList) { +// } +} diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index 42d893f1d..d7ace358b 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -102,8 +102,12 @@ public: //! If PartPtr is Null pointer then PartSet will be activated void activatePart(FeaturePtr theFeature); + //! Delete features void deleteFeatures(QFeatureList theList); + //! Show the given features in 3d Viewer + void showFeatures(QFeatureList theList, bool isVisible); + signals: void salomeViewerSelection(); void errorOccurred(const QString&); diff --git a/src/XGUI/XGUI_pictures.qrc b/src/XGUI/XGUI_pictures.qrc index 8ae03bf23..39c671f73 100644 --- a/src/XGUI/XGUI_pictures.qrc +++ b/src/XGUI/XGUI_pictures.qrc @@ -56,5 +56,6 @@ pictures/activate.png pictures/delete.png pictures/rename_edit.png + pictures/eye_pencil.png diff --git a/src/XGUI/pictures/eye_pencil.png b/src/XGUI/pictures/eye_pencil.png new file mode 100644 index 000000000..53562dba0 Binary files /dev/null and b/src/XGUI/pictures/eye_pencil.png differ diff --git a/src/XGUI/pictures/eye_pencil_closed.png b/src/XGUI/pictures/eye_pencil_closed.png new file mode 100644 index 000000000..72931efab Binary files /dev/null and b/src/XGUI/pictures/eye_pencil_closed.png differ