+ action("HIDEALL_CMD")->setEnabled(true);
+ if (myWorkshop->canChangeColor())
+ action("COLOR_CMD")->setEnabled(true);
+
+ action("DELETE_CMD")->setEnabled(true);
+
+ ModuleBase_IModule* aModule = myWorkshop->module();
+ if (aModule)
+ aModule->updateViewerMenu(myActions);
+}
+
+void XGUI_ContextMenuMgr::connectObjectBrowser()
+{
+ connect(myWorkshop->objectBrowser(), SIGNAL(contextMenuRequested(QContextMenuEvent*)), this,
+ SLOT(onContextMenuRequest(QContextMenuEvent*)));
+}
+
+void XGUI_ContextMenuMgr::connectViewer()
+{
+ connect(myWorkshop->viewer(), SIGNAL(contextMenuRequested(QContextMenuEvent*)), this,
+ SLOT(onContextMenuRequest(QContextMenuEvent*)));
+}
+
+
+void XGUI_ContextMenuMgr::buildObjBrowserMenu()
+{
+ QAction* aSeparator = new QAction(this);
+ aSeparator->setSeparator(true);
+
+ QActionsList aList;
+
+ // Result construction menu
+ aList.append(action("SHOW_CMD"));
+ aList.append(action("HIDE_CMD"));
+ aList.append(action("SHOW_ONLY_CMD"));
+ aList.append(action("COLOR_CMD"));
+ aList.append(mySeparator);
+ aList.append(action("RENAME_CMD"));
+ myObjBrowserMenus[ModelAPI_ResultConstruction::group()] = aList;
+ //-------------------------------------
+ // Result body menu
+ aList.clear();
+ aList.append(action("WIREFRAME_CMD"));
+ aList.append(action("SHADING_CMD"));
+ aList.append(action("COLOR_CMD"));
+ aList.append(mySeparator);
+ aList.append(action("SHOW_CMD"));
+ aList.append(action("HIDE_CMD"));
+ aList.append(action("SHOW_ONLY_CMD"));
+ aList.append(mySeparator);
+ aList.append(action("RENAME_CMD"));
+ myObjBrowserMenus[ModelAPI_ResultBody::group()] = aList;
+ // Group menu
+ myObjBrowserMenus[ModelAPI_ResultGroup::group()] = aList;
+ // Result part menu
+ myObjBrowserMenus[ModelAPI_ResultPart::group()] = aList;
+ //-------------------------------------
+ // Feature menu
+ aList.clear();
+ aList.append(action("DELETE_CMD"));
+ aList.append(action("MOVE_CMD"));
+ aList.append(mySeparator);
+ aList.append(action("RENAME_CMD"));
+ myObjBrowserMenus[ModelAPI_Feature::group()] = aList;
+
+ aList.clear();
+ aList.append(action("DELETE_CMD"));
+ aList.append(mySeparator);
+ aList.append(action("RENAME_CMD"));
+ myObjBrowserMenus[ModelAPI_ResultParameter::group()] = aList;
+ //-------------------------------------
+}
+
+void XGUI_ContextMenuMgr::buildViewerMenu()
+{
+ QActionsList aList;
+ // Result construction menu
+ aList.append(action("HIDE_CMD"));
+ aList.append(action("SHOW_ONLY_CMD"));
+ aList.append(action("HIDEALL_CMD"));
+ aList.append(action("COLOR_CMD"));
+ myViewerMenu[ModelAPI_ResultConstruction::group()] = aList;
+ // Result part menu
+ myViewerMenu[ModelAPI_ResultPart::group()] = aList;
+ //-------------------------------------
+ // Result body menu
+ aList.clear();
+ aList.append(action("WIREFRAME_CMD"));
+ aList.append(action("SHADING_CMD"));
+ aList.append(action("COLOR_CMD"));
+ aList.append(mySeparator);
+ aList.append(action("HIDE_CMD"));
+ aList.append(action("SHOW_ONLY_CMD"));
+ aList.append(action("HIDEALL_CMD"));
+ myViewerMenu[ModelAPI_ResultBody::group()] = aList;
+ // Group menu
+ myViewerMenu[ModelAPI_ResultGroup::group()] = aList;
+ //-------------------------------------
+
+}
+
+
+void XGUI_ContextMenuMgr::addObjBrowserMenu(QMenu* theMenu) const
+{
+ XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
+ QObjectPtrList aObjects = aSelMgr->selection()->selectedObjects();
+ int aSelected = aObjects.size();
+ QActionsList aActions;
+ if (aSelected == 1) {
+ ObjectPtr aObject = aObjects.first();
+ std::string aName = aObject->groupName();
+ if (myObjBrowserMenus.contains(aName))
+ aActions = myObjBrowserMenus[aName];
+ } else if (aSelected > 1) {
+ aActions.append(action("SHADING_CMD"));
+ aActions.append(action("WIREFRAME_CMD"));
+ aActions.append(mySeparator);
+ aActions.append(action("SHOW_CMD"));
+ aActions.append(action("HIDE_CMD"));
+ aActions.append(action("SHOW_ONLY_CMD"));
+ aActions.append(mySeparator);
+ aActions.append(action("DELETE_CMD"));
+ //aActions.append(action("MOVE_CMD"));
+ }
+ theMenu->addActions(aActions);
+
+ ModuleBase_IModule* aModule = myWorkshop->module();
+ if (aModule) {
+ theMenu->addSeparator();
+ aModule->addObjectBrowserMenu(theMenu);
+ }
+ theMenu->addSeparator();
+ theMenu->addActions(myWorkshop->objectBrowser()->actions());
+}
+
+void XGUI_ContextMenuMgr::addViewerMenu(QMenu* theMenu) const
+{
+ ModuleBase_IModule* aModule = myWorkshop->module();
+ if (aModule) {
+ if (aModule->addViewerMenu(theMenu, myActions))
+ theMenu->addSeparator();
+ }
+ XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
+ QList<ModuleBase_ViewerPrs> aPrsList = aSelMgr->selection()->getSelected(ModuleBase_ISelection::Viewer);
+ int aSelected = aPrsList.size();
+ QActionsList aActions;
+ if (aSelected == 1) {
+ ObjectPtr aObject = aPrsList.first().object();
+ std::string aName = aObject->groupName();
+ if (myViewerMenu.contains(aName))
+ aActions = myViewerMenu[aName];
+ } else if (aSelected > 1) {
+ aActions.append(action("HIDE_CMD"));
+ }
+ theMenu->addActions(aActions);
+