From be5d3c5c86f60641e7728c6205eaa16e372c69db Mon Sep 17 00:00:00 2001 From: vsv Date: Fri, 30 May 2014 11:04:19 +0400 Subject: [PATCH] Show/Hide menu items added --- src/XGUI/XGUI_ContextMenuMgr.cpp | 34 ++++++++++++++++-------- src/XGUI/XGUI_Workshop.cpp | 11 ++++++++ src/XGUI/XGUI_Workshop.h | 4 +++ src/XGUI/XGUI_pictures.qrc | 1 + src/XGUI/pictures/eye_pencil.png | Bin 0 -> 720 bytes src/XGUI/pictures/eye_pencil_closed.png | Bin 0 -> 563 bytes 6 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 src/XGUI/pictures/eye_pencil.png create mode 100644 src/XGUI/pictures/eye_pencil_closed.png 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 0000000000000000000000000000000000000000..53562dba0a712f9c5b5ea487d2838f82dcb6707c GIT binary patch literal 720 zcmV;>0x$iEP)X87# zBM!t?sr!a}M54$%lGk*afesCNj7H-np6B-kgTW?25G+eeODs)t94C1^o>Dj*{u+%& zKa|VmNz^^0ed!TQ$Q8feKN5?@xS5$5w=BzzcDtP|l|-PRh^2cpM{8&;)u>v%UVj?9 zKF?;eWl(a~YU@mWcd)N_SGA?z%} z`1n0_?R2)m#zqpfJd;SUx7ODWijtVO)D=5fAb8`#W?M|qz ztp|&Rfj}StnM?-WE-d^!;dYyA=I2FfkV&OdN<1EyeLmkVtJPXZO$1>T91bs7tu{0h zpsTABb~j|<$=H;?+rp7Upj z@510n+tkF^VszO!y7<~ScPEzv!#@v8L|#>ZbDatd4v=GF35HMgUTd4aKQ@P#5K{%64Z6zDmk!1n?``G>Cm^6>laiQBE) zivKcDFiUy#0#tqn8GZM;^?|hk?lv?+Y`bZH2`~UxgCp^BtU(?C0000Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02*{fSaefwW^{L9 za%BKeVQFr3E>1;MAa*k@H7+qRNAp5A0004^Nkl)fdwTLD6~X0MM)IxH3WeW9MSN4 z|KTe=RFEEg$Gdm`_wnF>Qu;6I9=1Z=!&U%7h)QL(Ge#Kej6CC}0`Bn)zv0ZESJ_}8 zsMqVy0)fC&I2@)NNgAfIEPrLQ*$@1NGdPQmsDeZBZ?Oo@cRA!(|UpGn?xcJ zRW6lEG?z$x(|DZj6LOCMy-ueabGzLK+DLT>BQK9RnoK6kilWdSizUAUFn|GI0mA4u z8jbN#D0JK?l3wX}Q(ot&)oR@`o6YuZ{GXKor;XuYOfcpd%ZS${rc;Z;1IlX)J#8{kMx~vl5>