]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'master' of newgeom:newgeom
authorvsv <vitaly.smetannikov@opencascade.com>
Mon, 2 Jun 2014 05:41:50 +0000 (09:41 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Mon, 2 Jun 2014 05:41:50 +0000 (09:41 +0400)
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h
src/XGUI/XGUI_pictures.qrc
src/XGUI/pictures/eye_pencil.png [new file with mode: 0644]
src/XGUI/pictures/eye_pencil_closed.png [new file with mode: 0644]

index 38e74834ba85a9a57f655e02172a0a6e0240d6bb..0abbb09ffe7bb8cbdd84e86c214622fb76dd8094 100644 (file)
@@ -3,6 +3,7 @@
 #include "XGUI_Workshop.h"
 #include "XGUI_ObjectsBrowser.h"
 #include "XGUI_SelectionMgr.h"
+#include "XGUI_Displayer.h"
 
 #include <ModelAPI_Data.h>
 #include <ModelAPI_AttributeDocRef.h>
@@ -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<QAction*> 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<ModelAPI_Object>(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;
 }
 
index f42b21c69a41f8fdcf26aea258a334b97feaafe2..980b8c8e0f28243771c285ceab2c4f9e74a423d9 100644 (file)
@@ -773,6 +773,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);
 }
 
 //**************************************************************
@@ -825,3 +829,10 @@ void XGUI_Workshop::deleteFeatures(QFeatureList theList)
     aMgr->rootDocument()->finishOperation();
   }
 }
+
+//**************************************************************
+void XGUI_Workshop::showFeatures(QFeatureList theList, bool isVisible)
+{
+//  foreach (FeaturePtr aFeature, theList) {
+//  }
+}
index 42d893f1d116e3de7486a1d05be0d93545902d40..d7ace358b60068eb67234ed7c51be05957cf4d79 100644 (file)
@@ -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&);
index 8ae03bf231bcb5beb4553a2de7d2d42247f50015..39c671f73b45eaff2982c50349bb3693f3c1fb2f 100644 (file)
@@ -56,5 +56,6 @@
      <file>pictures/activate.png</file>
      <file>pictures/delete.png</file>
      <file>pictures/rename_edit.png</file>
+     <file>pictures/eye_pencil.png</file>
  </qresource>
  </RCC>
diff --git a/src/XGUI/pictures/eye_pencil.png b/src/XGUI/pictures/eye_pencil.png
new file mode 100644 (file)
index 0000000..53562db
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 (file)
index 0000000..72931ef
Binary files /dev/null and b/src/XGUI/pictures/eye_pencil_closed.png differ