+ 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(action("CLEAN_HISTORY_CMD"));
+ aList.append(mySeparator);
+ aList.append(action("RENAME_CMD"));
+ myObjBrowserMenus[ModelAPI_Feature::group()] = aList;
+
+ aList.clear();
+ aList.append(action("DELETE_CMD"));
+ aList.append(action("CLEAN_HISTORY_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("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"));
+ 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"));
+ aActions.append(action("CLEAN_HISTORY_CMD"));
+ aActions.append(action("COLOR_CMD"));