]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1412: Make possible to switch on/off sub-shapes modes selection in AND condition.
authorvsv <vitaly.smetannikov@opencascade.com>
Wed, 4 May 2016 08:30:05 +0000 (11:30 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Wed, 4 May 2016 08:30:20 +0000 (11:30 +0300)
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_ContextMenuMgr.h
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index 295875c6fc92a0779e92501e1c11f6cab4c617e8..65fe3d596f5b85f35aeab8c556cd63009972cdf6 100644 (file)
@@ -104,28 +104,32 @@ void XGUI_ContextMenuMgr::createActions()
   mySeparator = new QAction(this);
   mySeparator->setSeparator(true);
 
-  mySelectActions = new QActionGroup(this);
-  mySelectActions->setExclusive(true);
+  //mySelectActions = new QActionGroup(this);
+  //mySelectActions->setExclusive(true);
 
   aAction = new QAction(QIcon(":pictures/vertex.png"), tr("Vertices"), this);
   aAction->setCheckable(true);
   addAction("SELECT_VERTEX_CMD", aAction);
-  mySelectActions->addAction(aAction);
+  connect(aAction, SIGNAL(triggered(bool)), SLOT(onShapeSelection(bool)));
+  //mySelectActions->addAction(aAction);
 
   aAction = new QAction(QIcon(":pictures/edge.png"), tr("Edges"), this);
   aAction->setCheckable(true);
   addAction("SELECT_EDGE_CMD", aAction);
-  mySelectActions->addAction(aAction);
+  connect(aAction, SIGNAL(triggered(bool)), SLOT(onShapeSelection(bool)));
+  //mySelectActions->addAction(aAction);
 
   aAction = new QAction(QIcon(":pictures/face.png"), tr("Faces"), this);
   aAction->setCheckable(true);
   addAction("SELECT_FACE_CMD", aAction);
-  mySelectActions->addAction(aAction);
+  connect(aAction, SIGNAL(triggered(bool)), SLOT(onShapeSelection(bool)));
+  //mySelectActions->addAction(aAction);
 
   aAction = new QAction(QIcon(":pictures/result.png"), tr("Result"), this);
   aAction->setCheckable(true);
   addAction("SELECT_RESULT_CMD", aAction);
-  mySelectActions->addAction(aAction);
+  connect(aAction, SIGNAL(triggered(bool)), SLOT(onResultSelection(bool)));
+  //mySelectActions->addAction(aAction);
 
   aAction->setChecked(true);
 
@@ -358,13 +362,21 @@ void XGUI_ContextMenuMgr::updateViewerMenu()
 
   // Update selection menu
   QIntList aModes = aDisplayer->activeSelectionModes();
-  if (aModes.count() <= 1) {
-    action("SELECT_VERTEX_CMD")->setEnabled(true);
-    action("SELECT_EDGE_CMD")->setEnabled(true);
-    action("SELECT_FACE_CMD")->setEnabled(true);
-    action("SELECT_RESULT_CMD")->setEnabled(true);
-    if (aModes.count() == 1) {
-      switch (aModes.first()) {
+  action("SELECT_VERTEX_CMD")->setEnabled(true);
+  action("SELECT_EDGE_CMD")->setEnabled(true);
+  action("SELECT_FACE_CMD")->setEnabled(true);
+  action("SELECT_RESULT_CMD")->setEnabled(true);
+
+  action("SELECT_RESULT_CMD")->setChecked(false);
+  action("SELECT_VERTEX_CMD")->setChecked(false);
+  action("SELECT_EDGE_CMD")->setChecked(false);
+  action("SELECT_FACE_CMD")->setChecked(false);
+  action("SELECT_RESULT_CMD")->setChecked(false);
+  if (aModes.count() == 0) {
+    action("SELECT_RESULT_CMD")->setChecked(true);
+  } else {
+    foreach(int aMode, aModes) {
+      switch (aMode) {
       case TopAbs_VERTEX: 
         action("SELECT_VERTEX_CMD")->setChecked(true);
         break;
@@ -377,9 +389,8 @@ void XGUI_ContextMenuMgr::updateViewerMenu()
       default:
         action("SELECT_RESULT_CMD")->setChecked(true);
       }
-    } else 
-      action("SELECT_RESULT_CMD")->setChecked(true);
-  }
+    }
+  } 
 
   ModuleBase_IModule* aModule = myWorkshop->module();
   if (aModule)
@@ -542,6 +553,7 @@ void XGUI_ContextMenuMgr::addViewerMenu(QMenu* theMenu) const
     aSelMenu->addAction(action("SELECT_VERTEX_CMD"));
     aSelMenu->addAction(action("SELECT_EDGE_CMD"));
     aSelMenu->addAction(action("SELECT_FACE_CMD"));
+    aSelMenu->addSeparator();
     aSelMenu->addAction(action("SELECT_RESULT_CMD"));
     theMenu->addMenu(aSelMenu);
     theMenu->addSeparator();
@@ -667,3 +679,23 @@ void XGUI_ContextMenuMgr::addFeatures(QMenu* theMenu) const
     }
   }
 }
+
+#define UNCHECK_ACTION(NAME) \
+{ QAction* aAction = action(NAME); \
+bool isBlock = aAction->signalsBlocked(); \
+aAction->blockSignals(true); \
+aAction->setChecked(false); \
+  aAction->blockSignals(isBlock); }
+
+
+void XGUI_ContextMenuMgr::onResultSelection(bool theChecked)
+{
+  UNCHECK_ACTION("SELECT_VERTEX_CMD");
+  UNCHECK_ACTION("SELECT_EDGE_CMD");
+  UNCHECK_ACTION("SELECT_FACE_CMD");
+}
+
+void XGUI_ContextMenuMgr::onShapeSelection(bool theChecked)
+{
+  UNCHECK_ACTION("SHOW_RESULTS_CMD");
+}
index 52c1e6381cf762e622f871b4cbde407bd06cb941..321c9641e4d84e8d369a75a7001078984280b8c6 100644 (file)
@@ -87,6 +87,12 @@ signals:
 
   void onRename();
 
+  /// Slot called on Result selection menu press
+  void onResultSelection(bool theChecked);
+
+  /// Slot called on any shape selection menu press
+  void onShapeSelection(bool theChecked);
+
  private:
   /** 
    * Add action
@@ -116,7 +122,7 @@ signals:
   QMap<std::string, QActionsList> myObjBrowserMenus;
   QMap<std::string, QActionsList> myViewerMenu;
 
-  QActionGroup* mySelectActions;
+  //QActionGroup* mySelectActions;
 
   QAction* mySeparator;
 };
index afdbae4e4ee99a8be75f202144d88c646d59d725..9da518760816e3a10c6610188e63963b066a69a8 100755 (executable)
@@ -122,8 +122,8 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
       mySalomeConnector(theConnector),
       myPropertyPanel(0),
       myObjectBrowser(0),
-      myDisplayer(0),
-      myViewerSelMode(TopAbs_FACE)
+      myDisplayer(0)
+      //myViewerSelMode(TopAbs_FACE)
 {
 #ifndef HAVE_SALOME
   myMainWindow = new AppElements_MainWindow();
@@ -136,6 +136,8 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
     QLocale::setDefault( QLocale::system() );
 #endif
 
+  myViewerSelMode << TopAbs_FACE << TopAbs_EDGE << TopAbs_VERTEX;
+
   myDataModelXMLReader = new Config_DataModelReader();
   myDataModelXMLReader->readAll();
 
@@ -196,8 +198,8 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
   Config_PropManager::registerProp("Visualization", "result_part_color", "Part color",
                                    Config_Prop::Color, ModelAPI_ResultPart::DEFAULT_COLOR());
   
-  myViewerSelMode = 
-    ModuleBase_Preferences::resourceMgr()->integerValue("Viewer", "selection", TopAbs_FACE);
+  //myViewerSelMode = 
+  //  ModuleBase_Preferences::resourceMgr()->integerValue("Viewer", "selection", TopAbs_FACE);
 }
 
 //******************************************************
@@ -1241,7 +1243,14 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
 //**************************************************************
 void XGUI_Workshop::setViewerSelectionMode(int theMode)
 {
-  myViewerSelMode = theMode;
+  if (theMode == -1)
+    myViewerSelMode.clear();
+  else {
+    if (myViewerSelMode.contains(theMode))
+      myViewerSelMode.removeAll(theMode);
+    else
+      myViewerSelMode.append(theMode);
+  }
   activateObjectsSelection(myDisplayer->displayedObjects());
 }
 
@@ -1250,7 +1259,7 @@ void XGUI_Workshop::activateObjectsSelection(const QObjectPtrList& theList)
 {
   QIntList aModes;
   module()->activeSelectionModes(aModes);
-  if (aModes.isEmpty() && (myViewerSelMode != -1))
+  if (aModes.isEmpty() && (myViewerSelMode.length() > 0))
     aModes.append(myViewerSelMode);
   myDisplayer->activateObjects(aModes, theList);
 }
index 4c894fc81c088b11826d94df4aaf22e643fbd1d1..d28b37867fc307bf83d3f4f9bda66bab6824e97f 100755 (executable)
@@ -282,7 +282,7 @@ Q_OBJECT
   void connectToPropertyPanel(const bool isToConnect);
 
   /// Returns defailt selection mode in 3d viewer
-  int viewerSelectionMode() const { return myViewerSelMode; }
+  QIntList viewerSelectionModes() const { return myViewerSelMode; }
 
   /// Highlights result objects in Object Browser according to
   /// features found in the given list
@@ -522,7 +522,7 @@ private:
 
   QString myCurrentDir;
 
-  int myViewerSelMode;
+  QIntList myViewerSelMode;
 
   Config_DataModelReader* myDataModelXMLReader;
 };