1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 #include "XGUI_ContextMenuMgr.h"
4 #include "XGUI_Workshop.h"
5 #include "XGUI_ObjectsBrowser.h"
6 #include "XGUI_SelectionMgr.h"
7 #include "XGUI_Displayer.h"
8 #include "XGUI_ViewerProxy.h"
9 #include "XGUI_Selection.h"
10 #include "XGUI_SalomeConnector.h"
11 #include "XGUI_DataModel.h"
12 #include "XGUI_OperationMgr.h"
13 #include "XGUI_Tools.h"
14 #include "XGUI_ActionsMgr.h"
17 #include <AppElements_MainWindow.h>
20 //#include "PartSetPlugin_Part.h"
22 #include <ModelAPI_Data.h>
23 #include <ModelAPI_AttributeDocRef.h>
24 #include <ModelAPI_Object.h>
25 #include <ModelAPI_Session.h>
26 #include <ModelAPI_ResultGroup.h>
27 #include <ModelAPI_ResultParameter.h>
28 #include <ModelAPI_ResultConstruction.h>
29 #include <ModelAPI_ResultBody.h>
30 #include <ModelAPI_Tools.h>
32 #include <Config_DataModelReader.h>
34 #include <ModuleBase_IModule.h>
35 #include <ModuleBase_Tools.h>
36 #include <ModuleBase_OperationAction.h>
37 #include <ModuleBase_ViewerPrs.h>
40 #include <QActionGroup>
41 #include <QContextMenuEvent>
44 #include <QMainWindow>
45 #include <QModelIndex>
48 XGUI_ContextMenuMgr::XGUI_ContextMenuMgr(XGUI_Workshop* theParent)
50 myWorkshop(theParent),
55 XGUI_ContextMenuMgr::~XGUI_ContextMenuMgr()
59 void XGUI_ContextMenuMgr::createActions()
62 QMainWindow* aDesktop = myWorkshop->salomeConnector()->desktop();
64 QMainWindow* aDesktop = myWorkshop->mainWindow();
67 QAction* aAction = new QAction(QIcon(":pictures/delete.png"), tr("Delete"), this);
68 aDesktop->addAction(aAction);
70 addAction("DELETE_CMD", aAction);
71 aAction->setShortcutContext(Qt::ApplicationShortcut);
73 aAction = new QAction(QIcon(":pictures/rename_edit.png"), tr("Rename"), this);
74 addAction("RENAME_CMD", aAction);
75 connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onRename()));
77 aAction = new QAction(QIcon(":pictures/move.png"), XGUI_Workshop::MOVE_TO_END_COMMAND, this);
78 addAction("MOVE_CMD", aAction);
80 aAction = new QAction(QIcon(":pictures/clean_history.png"), tr("Clean history"), this);
81 addAction("CLEAN_HISTORY_CMD", aAction);
83 aAction = new QAction(QIcon(":pictures/color.png"), tr("Color..."), this);
84 addAction("COLOR_CMD", aAction);
86 aAction = new QAction(QIcon(":pictures/eye_pencil.png"), tr("Show"), this);
87 addAction("SHOW_CMD", aAction);
89 aAction = new QAction(QIcon(":pictures/eye_pencil.png"), tr("Show only"), this);
90 addAction("SHOW_ONLY_CMD", aAction);
92 aAction = new QAction(QIcon(":pictures/eye_pencil_closed.png"), tr("Hide"), this);
93 addAction("HIDE_CMD", aAction);
95 aAction = new QAction(QIcon(":pictures/eye_pencil_closed.png"), tr("Hide all"), this);
96 addAction("HIDEALL_CMD", aAction);
98 aAction = new QAction(QIcon(":pictures/shading.png"), tr("Shading"), this);
99 addAction("SHADING_CMD", aAction);
101 aAction = new QAction(QIcon(":pictures/wireframe.png"), tr("Wireframe"), this);
102 addAction("WIREFRAME_CMD", aAction);
104 mySeparator = new QAction(this);
105 mySeparator->setSeparator(true);
107 //mySelectActions = new QActionGroup(this);
108 //mySelectActions->setExclusive(true);
110 aAction = new QAction(QIcon(":pictures/vertex.png"), tr("Vertices"), this);
111 aAction->setCheckable(true);
112 addAction("SELECT_VERTEX_CMD", aAction);
113 connect(aAction, SIGNAL(triggered(bool)), SLOT(onShapeSelection(bool)));
114 //mySelectActions->addAction(aAction);
116 aAction = new QAction(QIcon(":pictures/edge.png"), tr("Edges"), this);
117 aAction->setCheckable(true);
118 addAction("SELECT_EDGE_CMD", aAction);
119 connect(aAction, SIGNAL(triggered(bool)), SLOT(onShapeSelection(bool)));
120 //mySelectActions->addAction(aAction);
122 aAction = new QAction(QIcon(":pictures/face.png"), tr("Faces"), this);
123 aAction->setCheckable(true);
124 addAction("SELECT_FACE_CMD", aAction);
125 connect(aAction, SIGNAL(triggered(bool)), SLOT(onShapeSelection(bool)));
126 //mySelectActions->addAction(aAction);
128 aAction = new QAction(QIcon(":pictures/result.png"), tr("Result"), this);
129 aAction->setCheckable(true);
130 addAction("SELECT_RESULT_CMD", aAction);
131 connect(aAction, SIGNAL(triggered(bool)), SLOT(onResultSelection(bool)));
132 //mySelectActions->addAction(aAction);
134 aAction->setChecked(true);
136 aAction = new QAction(QIcon(":pictures/find_result.png"), tr("Select results"), this);
137 addAction("SHOW_RESULTS_CMD", aAction);
139 aAction = new QAction(QIcon(":pictures/find_result.png"), tr("Select parent feature"), this);
140 addAction("SHOW_FEATURE_CMD", aAction);
142 buildObjBrowserMenu();
146 void XGUI_ContextMenuMgr::addAction(const QString& theId, QAction* theAction)
148 if (myActions.contains(theId))
149 qCritical("A command with Id = '%s' already defined!", qPrintable(theId));
150 theAction->setData(theId);
151 connect(theAction, SIGNAL(triggered(bool)), this, SLOT(onAction(bool)));
152 myActions[theId] = theAction;
155 QAction* XGUI_ContextMenuMgr::action(const QString& theId) const
157 if (myActions.contains(theId))
158 return myActions[theId];
162 QAction* XGUI_ContextMenuMgr::actionByName(const QString& theName) const
164 foreach(QAction* eachAction, myActions) {
165 if (eachAction->text() == theName) {
172 QStringList XGUI_ContextMenuMgr::actionIds() const
174 return myActions.keys();
177 void XGUI_ContextMenuMgr::onAction(bool isChecked)
179 QAction* aAction = static_cast<QAction*>(sender());
180 emit actionTriggered(aAction->data().toString(), isChecked);
183 void XGUI_ContextMenuMgr::updateCommandsStatus()
187 void XGUI_ContextMenuMgr::onContextMenuRequest(QContextMenuEvent* theEvent)
189 QMenu* aMenu = new QMenu();
190 if (sender() == myWorkshop->objectBrowser()) {
191 updateObjectBrowserMenu();
192 addObjBrowserMenu(aMenu);
193 } else if (sender() == myWorkshop->viewer()) {
195 addViewerMenu(aMenu);
198 if (aMenu && (aMenu->actions().size() > 0)) {
199 // it is possible that some objects should do something before and after the popup menu exec
200 // e.g. a sketch manager changes an internal flag on this signals in order to do not hide
202 emit beforeContextMenu();
203 aMenu->exec(theEvent->globalPos());
204 emit afterContextMenu();
209 void XGUI_ContextMenuMgr::updateObjectBrowserMenu()
211 foreach(QAction* aAction, myActions)
212 aAction->setEnabled(false);
214 XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
215 QObjectPtrList aObjects = aSelMgr->selection()->selectedObjects();
216 int aSelected = aObjects.size();
218 SessionPtr aMgr = ModelAPI_Session::get();
219 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
220 bool hasResult = false;
221 bool hasFeature = false;
222 bool hasParameter = false;
223 bool hasCompositeOwner = false;
224 ModuleBase_Tools::checkObjects(aObjects, hasResult, hasFeature, hasParameter,
227 if (aSelected == 1) {
228 ObjectPtr aObject = aObjects.first();
230 if (hasResult && myWorkshop->canBeShaded(aObject)) {
231 XGUI_Displayer::DisplayMode aMode = aDisplayer->displayMode(aObject);
232 if (aMode != XGUI_Displayer::NoMode) {
233 action("WIREFRAME_CMD")->setEnabled(aMode == XGUI_Displayer::Shading);
234 action("SHADING_CMD")->setEnabled(aMode == XGUI_Displayer::Wireframe);
236 action("WIREFRAME_CMD")->setEnabled(true);
237 action("SHADING_CMD")->setEnabled(true);
241 bool aHasSubResults = ModelAPI_Tools::hasSubResults(
242 std::dynamic_pointer_cast<ModelAPI_Result>(aObject));
243 if (aHasSubResults) {
244 action("HIDE_CMD")->setEnabled(true);
245 action("SHOW_CMD")->setEnabled(true);
248 if (aObject->isDisplayed()) {
249 action("HIDE_CMD")->setEnabled(true);
250 } else if (hasResult && (!hasParameter)) {
251 action("SHOW_CMD")->setEnabled(true);
254 if (!(hasParameter || hasFeature))
255 action("SHOW_ONLY_CMD")->setEnabled(true);
257 else if (hasFeature && myWorkshop->canMoveFeature())
258 action("MOVE_CMD")->setEnabled(true);
260 if( aMgr->activeDocument() == aObject->document() )
262 action("RENAME_CMD")->setEnabled(true);
263 action("DELETE_CMD")->setEnabled(!hasCompositeOwner);
264 action("CLEAN_HISTORY_CMD")->setEnabled(!hasCompositeOwner &&
265 (hasFeature || hasParameter));
269 // parameter is commented because the actions are not in the list of result parameter actions
270 if (hasResult /*&& (!hasParameter)*/) {
271 action("SHOW_CMD")->setEnabled(true);
272 action("HIDE_CMD")->setEnabled(true);
273 action("SHOW_ONLY_CMD")->setEnabled(true);
274 action("SHADING_CMD")->setEnabled(true);
275 action("WIREFRAME_CMD")->setEnabled(true);
278 bool allActive = true;
279 foreach( ObjectPtr aObject, aObjects )
280 if( aMgr->activeDocument() != aObject->document() ) {
284 if (!hasCompositeOwner && allActive ) {
285 if (hasFeature || hasParameter)
286 action("DELETE_CMD")->setEnabled(true);
288 if (!hasCompositeOwner && allActive && (hasFeature|| hasParameter))
289 action("CLEAN_HISTORY_CMD")->setEnabled(true);
291 action("SHOW_RESULTS_CMD")->setEnabled(hasFeature);
292 action("SHOW_FEATURE_CMD")->setEnabled(hasResult);
295 // Show/Hide command has to be disabled for objects from non active document
296 bool aDeactivate = false;
297 foreach (ObjectPtr aObj, aObjects) {
298 if (!aObj->document()->isActive()) {
299 if ((aObj->document() != ModelAPI_Session::get()->moduleDocument()) ||
300 aObj->groupName() == ModelAPI_ResultPart::group()) {
307 // If at leas a one objec can not be edited then Show/Hide has to be disabled
308 action("SHOW_CMD")->setEnabled(false);
309 action("HIDE_CMD")->setEnabled(false);
310 action("SHOW_ONLY_CMD")->setEnabled(false);
313 if (myWorkshop->canChangeColor())
314 action("COLOR_CMD")->setEnabled(true);
316 ModuleBase_IModule* aModule = myWorkshop->module();
318 aModule->updateObjectBrowserMenu(myActions);
321 void XGUI_ContextMenuMgr::updateViewerMenu()
323 foreach(QAction* aAction, myActions)
324 aAction->setEnabled(false);
326 XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
327 XGUI_Displayer* aDisplayer = myWorkshop->displayer();
328 QList<ModuleBase_ViewerPrsPtr> aPrsList = aSelMgr->selection()->getSelected(ModuleBase_ISelection::Viewer);
329 if (aPrsList.size() > 0) {
330 bool isVisible = false;
331 bool isShading = false;
332 bool canBeShaded = false;
334 foreach(ModuleBase_ViewerPrsPtr aPrs, aPrsList) {
335 aObject = aPrs->object();
336 ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObject);
337 if (aRes && aRes->isDisplayed()) {
339 canBeShaded = myWorkshop->displayer()->canBeShaded(aObject);
340 isShading = (myWorkshop->displayer()->displayMode(aObject) == XGUI_Displayer::Shading);
346 XGUI_Displayer::DisplayMode aMode = aDisplayer->displayMode(aObject);
347 if (aMode != XGUI_Displayer::NoMode) {
348 action("WIREFRAME_CMD")->setEnabled(aMode == XGUI_Displayer::Shading);
349 action("SHADING_CMD")->setEnabled(aMode == XGUI_Displayer::Wireframe);
351 action("WIREFRAME_CMD")->setEnabled(true);
352 action("SHADING_CMD")->setEnabled(true);
355 action("SHOW_ONLY_CMD")->setEnabled(true);
356 action("HIDE_CMD")->setEnabled(true);
358 action("SHOW_CMD")->setEnabled(true);
360 if (myWorkshop->displayer()->objectsCount() > 0)
361 action("HIDEALL_CMD")->setEnabled(true);
363 // Update selection menu
364 QIntList aModes = aDisplayer->activeSelectionModes();
365 action("SELECT_VERTEX_CMD")->setEnabled(true);
366 action("SELECT_EDGE_CMD")->setEnabled(true);
367 action("SELECT_FACE_CMD")->setEnabled(true);
368 action("SELECT_RESULT_CMD")->setEnabled(true);
370 action("SELECT_RESULT_CMD")->setChecked(false);
371 action("SELECT_VERTEX_CMD")->setChecked(false);
372 action("SELECT_EDGE_CMD")->setChecked(false);
373 action("SELECT_FACE_CMD")->setChecked(false);
374 action("SELECT_RESULT_CMD")->setChecked(false);
375 if (aModes.count() == 0) {
376 action("SELECT_RESULT_CMD")->setChecked(true);
378 foreach(int aMode, aModes) {
381 action("SELECT_VERTEX_CMD")->setChecked(true);
384 action("SELECT_EDGE_CMD")->setChecked(true);
387 action("SELECT_FACE_CMD")->setChecked(true);
390 action("SELECT_RESULT_CMD")->setChecked(true);
395 ModuleBase_IModule* aModule = myWorkshop->module();
397 aModule->updateViewerMenu(myActions);
399 if (myWorkshop->canChangeColor())
400 action("COLOR_CMD")->setEnabled(true);
402 action("DELETE_CMD")->setEnabled(true);
405 void XGUI_ContextMenuMgr::connectObjectBrowser()
407 connect(myWorkshop->objectBrowser(), SIGNAL(contextMenuRequested(QContextMenuEvent*)), this,
408 SLOT(onContextMenuRequest(QContextMenuEvent*)));
411 void XGUI_ContextMenuMgr::connectViewer()
413 connect(myWorkshop->viewer(), SIGNAL(contextMenuRequested(QContextMenuEvent*)), this,
414 SLOT(onContextMenuRequest(QContextMenuEvent*)));
418 void XGUI_ContextMenuMgr::buildObjBrowserMenu()
420 QAction* aSeparator = new QAction(this);
421 aSeparator->setSeparator(true);
425 // Result construction menu
426 aList.append(action("SHOW_CMD"));
427 aList.append(action("HIDE_CMD"));
428 aList.append(action("SHOW_ONLY_CMD"));
429 aList.append(mySeparator);
430 aList.append(action("RENAME_CMD"));
431 aList.append(action("COLOR_CMD"));
432 aList.append(action("SHOW_FEATURE_CMD"));
433 myObjBrowserMenus[ModelAPI_ResultConstruction::group()] = aList;
435 //-------------------------------------
438 aList.append(action("WIREFRAME_CMD"));
439 aList.append(action("SHADING_CMD"));
440 aList.append(mySeparator); // this separator is not shown as this action is added after show only
441 // qt list container contains only one instance of the same action
442 aList.append(action("SHOW_CMD"));
443 aList.append(action("HIDE_CMD"));
444 aList.append(action("SHOW_ONLY_CMD"));
445 aList.append(mySeparator);
446 aList.append(action("RENAME_CMD"));
447 aList.append(action("COLOR_CMD"));
448 aList.append(action("SHOW_FEATURE_CMD"));
449 myObjBrowserMenus[ModelAPI_ResultBody::group()] = aList;
451 myObjBrowserMenus[ModelAPI_ResultGroup::group()] = aList;
453 myObjBrowserMenus[ModelAPI_ResultPart::group()] = aList;
454 //-------------------------------------
457 aList.append(action("RENAME_CMD"));
458 aList.append(action("SHOW_RESULTS_CMD"));
459 aList.append(action("MOVE_CMD"));
460 aList.append(mySeparator);
461 aList.append(action("CLEAN_HISTORY_CMD"));
462 aList.append(action("DELETE_CMD"));
463 myObjBrowserMenus[ModelAPI_Feature::group()] = aList;
466 aList.append(action("RENAME_CMD"));
467 aList.append(mySeparator);
468 aList.append(action("CLEAN_HISTORY_CMD"));
469 aList.append(action("DELETE_CMD"));
470 myObjBrowserMenus[ModelAPI_ResultParameter::group()] = aList;
471 //-------------------------------------
474 void XGUI_ContextMenuMgr::buildViewerMenu()
477 // Result construction menu
478 aList.append(action("HIDE_CMD"));
479 aList.append(action("SHOW_ONLY_CMD"));
480 aList.append(mySeparator);
481 aList.append(action("COLOR_CMD"));
482 myViewerMenu[ModelAPI_ResultConstruction::group()] = aList;
484 myViewerMenu[ModelAPI_ResultPart::group()] = aList;
485 //-------------------------------------
488 aList.append(action("WIREFRAME_CMD"));
489 aList.append(action("SHADING_CMD"));
490 aList.append(mySeparator);
491 aList.append(action("HIDE_CMD"));
492 aList.append(action("SHOW_ONLY_CMD"));
493 aList.append(mySeparator);
494 aList.append(action("COLOR_CMD"));
495 myViewerMenu[ModelAPI_ResultBody::group()] = aList;
497 myViewerMenu[ModelAPI_ResultGroup::group()] = aList;
498 //-------------------------------------
502 void XGUI_ContextMenuMgr::addObjBrowserMenu(QMenu* theMenu) const
504 ModuleBase_IModule* aModule = myWorkshop->module();
506 theMenu->addSeparator();
507 aModule->addObjectBrowserMenu(theMenu);
510 XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
511 QObjectPtrList aObjects = aSelMgr->selection()->selectedObjects();
512 int aSelected = aObjects.size();
513 QActionsList aActions;
514 if (aSelected == 1) {
515 ObjectPtr aObject = aObjects.first();
516 std::string aName = aObject->groupName();
517 if (myObjBrowserMenus.contains(aName))
518 aActions = myObjBrowserMenus[aName];
519 } else if (aSelected > 1) {
520 aActions.append(action("WIREFRAME_CMD"));
521 aActions.append(action("SHADING_CMD"));
522 aActions.append(mySeparator);
523 aActions.append(action("SHOW_CMD"));
524 aActions.append(action("HIDE_CMD"));
525 aActions.append(action("SHOW_ONLY_CMD"));
526 aActions.append(mySeparator);
527 //aActions.append(action("MOVE_CMD"));
528 aActions.append(action("COLOR_CMD"));
529 aActions.append(action("CLEAN_HISTORY_CMD"));
530 aActions.append(action("DELETE_CMD"));
532 theMenu->addActions(aActions);
533 addFeatures(theMenu);
535 // It is commented out because Object Browser does not have actions
536 //theMenu->addSeparator();
537 //theMenu->addActions(myWorkshop->objectBrowser()->actions());
540 void XGUI_ContextMenuMgr::addViewerMenu(QMenu* theMenu) const
542 XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
543 QList<ModuleBase_ViewerPrsPtr> aPrsList = aSelMgr->selection()->getSelected(ModuleBase_ISelection::Viewer);
544 int aSelected = aPrsList.size();
545 QActionsList aActions;
547 // Create selection menu
548 XGUI_OperationMgr* aOpMgr = myWorkshop->operationMgr();
550 myWorkshop->module()->activeSelectionModes(aModes);
551 if ((!aOpMgr->hasOperation()) && aModes.isEmpty()) {
552 QMenu* aSelMenu = new QMenu(tr("Selection mode"), theMenu);
553 aSelMenu->addAction(action("SELECT_VERTEX_CMD"));
554 aSelMenu->addAction(action("SELECT_EDGE_CMD"));
555 aSelMenu->addAction(action("SELECT_FACE_CMD"));
556 aSelMenu->addSeparator();
557 aSelMenu->addAction(action("SELECT_RESULT_CMD"));
558 theMenu->addMenu(aSelMenu);
559 theMenu->addSeparator();
561 if (aSelected == 1) {
562 ObjectPtr aObject = aPrsList.first()->object();
563 if (aObject.get() != NULL) {
564 std::string aName = aObject->groupName();
565 if (myViewerMenu.contains(aName))
566 aActions = myViewerMenu[aName];
568 } else if (aSelected > 1) {
569 aActions.append(action("HIDE_CMD"));
571 // hide all is shown always even if selection in the viewer is empty
572 aActions.append(action("HIDEALL_CMD"));
573 aActions.append(action("COLOR_CMD"));
575 theMenu->addActions(aActions);
577 QMap<int, QAction*> aMenuActions;
578 ModuleBase_IModule* aModule = myWorkshop->module();
580 if (aModule->addViewerMenu(myActions, theMenu, aMenuActions))
581 theMenu->addSeparator();
584 // insert the module menu items on specific positions in the popup menu: some actions should be
585 // in the begin of the list, Delete action should be the last by #1343 issue
586 QList<QAction*> anActions = theMenu->actions();
587 int anActionsSize = anActions.size();
588 QAction* aFirstAction = anActions[0];
589 QMap<int, QAction*>::const_iterator anIt = aMenuActions.begin(), aLast = aMenuActions.end();
590 for (; anIt != aLast; anIt++) {
591 if (anIt.key() > anActionsSize)
592 theMenu->addAction(anIt.value());
594 theMenu->insertAction(aFirstAction, *anIt);
598 theMenu->addSeparator();
599 QMdiArea* aMDI = myWorkshop->mainWindow()->mdiArea();
600 if (aMDI->actions().size() > 0) {
601 QMenu* aSubMenu = theMenu->addMenu(tr("Windows"));
602 aSubMenu->addActions(aMDI->actions());
607 QStringList XGUI_ContextMenuMgr::actionObjectGroups(const QString& theName)
611 QMap<std::string, QActionsList>::const_iterator anIt = myObjBrowserMenus.begin(),
612 aLast = myObjBrowserMenus.end();
613 for (; anIt != aLast; anIt++) {
614 QString aGroupName(anIt.key().c_str());
615 if (aGroups.contains(aGroupName))
617 QActionsList anActions = anIt.value();
618 QActionsList::const_iterator anAIt = anActions.begin(), anALast = anActions.end();
620 for (; anAIt != anALast && !aFound; anAIt++)
621 aFound = (*anAIt)->data().toString() == theName;
623 aGroups.append(aGroupName);
628 void XGUI_ContextMenuMgr::onRename()
630 QObjectPtrList anObjects = myWorkshop->selector()->selection()->selectedObjects();
631 if (!myWorkshop->abortAllOperations())
633 // restore selection in case if dialog box was shown
634 myWorkshop->objectBrowser()->setObjectsSelected(anObjects);
635 myWorkshop->objectBrowser()->onEditItem();
638 void XGUI_ContextMenuMgr::addFeatures(QMenu* theMenu) const
640 SessionPtr aMgr = ModelAPI_Session::get();
641 DocumentPtr aActiveDoc = aMgr->activeDocument();
643 XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
644 XGUI_ActionsMgr* aActionMgr = myWorkshop->actionsMgr();
645 const Config_DataModelReader* aDataModelXML = myWorkshop->dataModelXMLReader();
646 QModelIndexList aSelectedIndexes = aSelMgr->selection()->selectedIndexes();
650 bool aIsRoot = false;
651 foreach(QModelIndex aIdx, aSelectedIndexes) {
652 // Process only first column
653 if (aIdx.column() == 0) {
654 aIsRoot = !aIdx.parent().isValid();
655 // Exit if the selected index belongs to non active document
656 if (aIsRoot && (aActiveDoc != aMgr->moduleDocument()))
658 if ((!aIsRoot) && (aIdx.internalPointer() != aActiveDoc.get()))
661 // Get name of the selected index
662 aName = aIdx.data().toString();
663 aLen = aName.indexOf('(');
665 aName = aName.left(--aLen);
667 std::string aFeaturesStr = aIsRoot?
668 aDataModelXML->rootFolderFeatures(aName.toStdString()) :
669 aDataModelXML->subFolderFeatures(aName.toStdString());
670 if (aFeaturesStr.length() > 0) {
671 QStringList aFeturesList =
672 QString(aFeaturesStr.c_str()).split(",", QString::SkipEmptyParts);
673 foreach(QString aFea, aFeturesList) {
674 QAction* aAction = aActionMgr->action(aFea);
676 theMenu->addAction(aAction);
683 #define UNCHECK_ACTION(NAME) \
684 { QAction* aAction = action(NAME); \
685 bool isBlock = aAction->signalsBlocked(); \
686 aAction->blockSignals(true); \
687 aAction->setChecked(false); \
688 aAction->blockSignals(isBlock); }
691 void XGUI_ContextMenuMgr::onResultSelection(bool theChecked)
693 UNCHECK_ACTION("SELECT_VERTEX_CMD");
694 UNCHECK_ACTION("SELECT_EDGE_CMD");
695 UNCHECK_ACTION("SELECT_FACE_CMD");
698 void XGUI_ContextMenuMgr::onShapeSelection(bool theChecked)
700 UNCHECK_ACTION("SHOW_RESULTS_CMD");