X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_ContextMenuMgr.cpp;h=efe3c9c127763939cb292274e67a4ae5d6b45ac6;hb=a21978de92f434702a3215df667f22e720cf107f;hp=0abbb09ffe7bb8cbdd84e86c214622fb76dd8094;hpb=a25996a80f13f4af8bd60a90edc3811bbbee3b2d;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index 0abbb09ff..efe3c9c12 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -4,6 +4,10 @@ #include "XGUI_ObjectsBrowser.h" #include "XGUI_SelectionMgr.h" #include "XGUI_Displayer.h" +#include "XGUI_MainWindow.h" +#include "XGUI_ViewerProxy.h" + +#include "PartSetPlugin_Part.h" #include #include @@ -12,6 +16,7 @@ #include #include #include +#include XGUI_ContextMenuMgr::XGUI_ContextMenuMgr(XGUI_Workshop* theParent) : QObject(theParent), myWorkshop(theParent) @@ -79,8 +84,11 @@ void XGUI_ContextMenuMgr::onContextMenuRequest(QContextMenuEvent* theEvent) QMenu* aMenu = 0; if (sender() == myWorkshop->objectBrowser()) aMenu = objectBrowserMenu(); - - if (aMenu) { + else if (sender() == myWorkshop->viewer()) { + aMenu = viewerMenu(); + } + + if (aMenu && (aMenu->actions().size() > 0)) { aMenu->exec(theEvent->globalPos()); delete aMenu; } @@ -96,7 +104,7 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const FeaturePtr aFeature = aFeatures.first(); //Process Feature if (aFeature) { - if (aFeature->getKind() == "Part") { + if (aFeature->getKind() == PARTSET_PART_KIND) { ObjectPtr aObject = boost::dynamic_pointer_cast(aFeature); DocumentPtr aFeaDoc = aObject->featureRef()->data()->docRef("PartDocument")->value(); if (aMgr->currentDocument() == aFeaDoc) @@ -107,7 +115,7 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const aMenu->addAction(action("EDIT_CMD")); XGUI_Displayer* aDisplayer = myWorkshop->displayer(); - if (aDisplayer->IsVisible(aFeature)) + if (aDisplayer->isVisible(aFeature)) aMenu->addAction(action("HIDE_CMD")); else aMenu->addAction(action("SHOW_CMD")); @@ -130,8 +138,55 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const return 0; } +QMenu* XGUI_ContextMenuMgr::viewerMenu() const +{ + QMenu* aMenu = new QMenu(); + addViewerItems(aMenu); + if (aMenu->actions().size() > 0) { + return aMenu; + } + delete aMenu; + return 0; +} + +void XGUI_ContextMenuMgr::addViewerItems(QMenu* theMenu) const +{ + XGUI_SelectionMgr* aSelMgr = myWorkshop->selector(); + QFeatureList aFeatures = aSelMgr->selectedFeatures(); + if (aFeatures.size() > 0) { + if (aFeatures.size() == 1) + theMenu->addAction(action("EDIT_CMD")); + bool isVisible = false; + foreach(FeaturePtr aFeature, aFeatures) { + if (myWorkshop->displayer()->isVisible(aFeature)) { + isVisible = true; + break; + } + } + if (isVisible) + theMenu->addAction(action("HIDE_CMD")); + else + theMenu->addAction(action("SHOW_CMD")); + theMenu->addAction(action("DELETE_CMD")); + } + if (!myWorkshop->isSalomeMode()) { + QMdiArea* aMDI = myWorkshop->mainWindow()->mdiArea(); + if (aMDI->actions().size() > 0) { + QMenu* aSubMenu = theMenu->addMenu(tr("Windows")); + aSubMenu->addActions(aMDI->actions()); + } + } +} + void XGUI_ContextMenuMgr::connectObjectBrowser() const { connect(myWorkshop->objectBrowser(), SIGNAL(contextMenuRequested(QContextMenuEvent*)), this, SLOT(onContextMenuRequest(QContextMenuEvent*))); -} \ No newline at end of file +} + +void XGUI_ContextMenuMgr::connectViewer() const +{ + connect(myWorkshop->viewer(), SIGNAL(contextMenuRequested(QContextMenuEvent*)), + this, SLOT(onContextMenuRequest(QContextMenuEvent*))); +} +