X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_ContextMenuMgr.cpp;h=84bf0d7beaea67bbcafb0bb59a3ae0ea4f75740a;hb=19bc85698899d6bee8704e7b0953ee045b0eb66f;hp=e699b4a2aca094101a7c11485f88c4a3b1f745a6;hpb=96ff1d1fb2acb842cee193f15492de81060a1d58;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index e699b4a2a..84bf0d7be 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -1,4 +1,3 @@ - #include "XGUI_ContextMenuMgr.h" #include "XGUI_Workshop.h" #include "XGUI_ObjectsBrowser.h" @@ -20,8 +19,9 @@ #include #include -XGUI_ContextMenuMgr::XGUI_ContextMenuMgr(XGUI_Workshop* theParent) : -QObject(theParent), myWorkshop(theParent) +XGUI_ContextMenuMgr::XGUI_ContextMenuMgr(XGUI_Workshop* theParent) + : QObject(theParent), + myWorkshop(theParent) { } @@ -46,8 +46,20 @@ void XGUI_ContextMenuMgr::createActions() aAction = new QAction(QIcon(":pictures/eye_pencil.png"), tr("Show"), this); addAction("SHOW_CMD", aAction); + aAction = new QAction(QIcon(":pictures/eye_pencil.png"), tr("Show only"), this); + addAction("SHOW_ONLY_CMD", aAction); + aAction = new QAction(QIcon(":pictures/eye_pencil_closed.png"), tr("Hide"), this); addAction("HIDE_CMD", aAction); + + aAction = new QAction(QIcon(":pictures/eye_pencil_closed.png"), tr("Hide all"), this); + addAction("HIDEALL_CMD", aAction); + + aAction = new QAction(QIcon(":pictures/shading.png"), tr("Shading"), this); + addAction("SHADING_CMD", aAction); + + aAction = new QAction(QIcon(":pictures/wireframe.png"), tr("Wireframe"), this); + addAction("WIREFRAME_CMD", aAction); } void XGUI_ContextMenuMgr::addAction(const QString& theId, QAction* theAction) @@ -89,7 +101,7 @@ void XGUI_ContextMenuMgr::onContextMenuRequest(QContextMenuEvent* theEvent) else if (sender() == myWorkshop->viewer()) { aMenu = viewerMenu(); } - + if (aMenu && (aMenu->actions().size() > 0)) { aMenu->exec(theEvent->globalPos()); delete aMenu; @@ -103,50 +115,64 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const QList aObjects = aSelMgr->selection()->selectedObjects(); int aSelected = aObjects.size(); if (aSelected > 0) { - PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + SessionPtr aMgr = ModelAPI_Session::get(); XGUI_Displayer* aDisplayer = myWorkshop->displayer(); + bool hasResult = false; + bool hasFeature = false; + foreach(ObjectPtr aObj, aObjects) + { + FeaturePtr aFeature = boost::dynamic_pointer_cast(aObj); + ResultPtr aResult = boost::dynamic_pointer_cast(aObj); + if (aResult) + hasResult = true; + if (aFeature) + hasFeature = true; + if (hasFeature && hasResult) + break; + } //Process Feature if (aSelected == 1) { ObjectPtr aObject = aObjects.first(); if (aObject) { ResultPartPtr aPart = boost::dynamic_pointer_cast(aObject); - FeaturePtr aFeature = boost::dynamic_pointer_cast(aObject); if (aPart) { - if (aMgr->currentDocument() == aPart->partDoc()) + if (aMgr->activeDocument() == aPart->partDoc()) aMenu->addAction(action("DEACTIVATE_PART_CMD")); - else + else aMenu->addAction(action("ACTIVATE_PART_CMD")); - } else if (aFeature) { + } else if (hasFeature) { aMenu->addAction(action("EDIT_CMD")); } else { - if (aDisplayer->isVisible(aObject)) + if (aDisplayer->isVisible(aObject)) { + if (aDisplayer->displayMode(aObject) == XGUI_Displayer::Shading) + aMenu->addAction(action("WIREFRAME_CMD")); + else + aMenu->addAction(action("SHADING_CMD")); + aMenu->addSeparator(); aMenu->addAction(action("HIDE_CMD")); - else + } else { aMenu->addAction(action("SHOW_CMD")); + } + aMenu->addAction(action("SHOW_ONLY_CMD")); } - } else { // If feature is 0 the it means that selected root object (document) - if (aMgr->currentDocument() != aMgr->rootDocument()) + } else { // If feature is 0 the it means that selected root object (document) + if (aMgr->activeDocument() != aMgr->moduleDocument()) aMenu->addAction(action("ACTIVATE_PART_CMD")); } - } else if (aSelected >= 1) { - bool hasResult = false; - bool hasFeature = false; - foreach(ObjectPtr aObj, aObjects) { - FeaturePtr aFeature = boost::dynamic_pointer_cast(aObj); - ResultPtr aResult = boost::dynamic_pointer_cast(aObj); - if (aResult) hasResult = true; - if (aFeature) hasFeature = true; - if (hasFeature && hasResult) - break; - } + } else { if (hasResult) { aMenu->addAction(action("SHOW_CMD")); aMenu->addAction(action("HIDE_CMD")); + aMenu->addAction(action("SHOW_ONLY_CMD")); + aMenu->addSeparator(); + aMenu->addAction(action("SHADING_CMD")); + aMenu->addAction(action("WIREFRAME_CMD")); } - if (hasFeature) - aMenu->addAction(action("DELETE_CMD")); } + if (hasFeature) + aMenu->addAction(action("DELETE_CMD")); } + aMenu->addSeparator(); aMenu->addActions(myWorkshop->objectBrowser()->actions()); if (aMenu->actions().size() > 0) { return aMenu; @@ -174,20 +200,32 @@ void XGUI_ContextMenuMgr::addViewerItems(QMenu* theMenu) const //if (aObjects.size() == 1) // theMenu->addAction(action("EDIT_CMD")); bool isVisible = false; - foreach(ObjectPtr aObject, aObjects) { + bool isShading = false; + foreach(ObjectPtr aObject, aObjects) + { ResultPtr aRes = boost::dynamic_pointer_cast(aObject); if (aRes && myWorkshop->displayer()->isVisible(aRes)) { isVisible = true; + isShading = (myWorkshop->displayer()->displayMode(aObject) == XGUI_Displayer::Shading); break; } } - if (isVisible) + if (isVisible) { + if (isShading) + theMenu->addAction(action("WIREFRAME_CMD")); + else + theMenu->addAction(action("SHADING_CMD")); + theMenu->addSeparator(); + theMenu->addAction(action("SHOW_ONLY_CMD")); theMenu->addAction(action("HIDE_CMD")); - else + } else theMenu->addAction(action("SHOW_CMD")); //theMenu->addAction(action("DELETE_CMD")); } + if (myWorkshop->displayer()->objectsCount() > 0) + theMenu->addAction(action("HIDEALL_CMD")); if (!myWorkshop->isSalomeMode()) { + theMenu->addSeparator(); QMdiArea* aMDI = myWorkshop->mainWindow()->mdiArea(); if (aMDI->actions().size() > 0) { QMenu* aSubMenu = theMenu->addMenu(tr("Windows")); @@ -198,13 +236,13 @@ void XGUI_ContextMenuMgr::addViewerItems(QMenu* theMenu) const void XGUI_ContextMenuMgr::connectObjectBrowser() const { - connect(myWorkshop->objectBrowser(), SIGNAL(contextMenuRequested(QContextMenuEvent*)), - this, SLOT(onContextMenuRequest(QContextMenuEvent*))); + connect(myWorkshop->objectBrowser(), SIGNAL(contextMenuRequested(QContextMenuEvent*)), this, + SLOT(onContextMenuRequest(QContextMenuEvent*))); } void XGUI_ContextMenuMgr::connectViewer() const { - connect(myWorkshop->viewer(), SIGNAL(contextMenuRequested(QContextMenuEvent*)), - this, SLOT(onContextMenuRequest(QContextMenuEvent*))); + connect(myWorkshop->viewer(), SIGNAL(contextMenuRequested(QContextMenuEvent*)), this, + SLOT(onContextMenuRequest(QContextMenuEvent*))); }