From: vsv Date: Wed, 4 May 2016 08:30:05 +0000 (+0300) Subject: Issue #1412: Make possible to switch on/off sub-shapes modes selection in AND condition. X-Git-Tag: V_2.3.0~46 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a51c7773d72fd8ac158f7d5356a8200347ccb3b4;p=modules%2Fshaper.git Issue #1412: Make possible to switch on/off sub-shapes modes selection in AND condition. --- diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index 295875c6f..65fe3d596 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -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"); +} diff --git a/src/XGUI/XGUI_ContextMenuMgr.h b/src/XGUI/XGUI_ContextMenuMgr.h index 52c1e6381..321c9641e 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.h +++ b/src/XGUI/XGUI_ContextMenuMgr.h @@ -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 myObjBrowserMenus; QMap myViewerMenu; - QActionGroup* mySelectActions; + //QActionGroup* mySelectActions; QAction* mySeparator; }; diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index afdbae4e4..9da518760 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -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); } diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index 4c894fc81..d28b37867 100755 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -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; };