#include "XGUI_ObjectsBrowser.h"
#include "XGUI_SelectionMgr.h"
#include "XGUI_Displayer.h"
+#include "XGUI_MainWindow.h"
+#include "XGUI_Viewer.h"
#include "PartSetPlugin_Part.h"
#include <QAction>
#include <QContextMenuEvent>
#include <QMenu>
+#include <QMdiArea>
XGUI_ContextMenuMgr::XGUI_ContextMenuMgr(XGUI_Workshop* theParent) :
QObject(theParent), myWorkshop(theParent)
QMenu* aMenu = 0;
if (sender() == myWorkshop->objectBrowser())
aMenu = objectBrowserMenu();
-
- if (aMenu) {
+ else if (sender() == myWorkshop->mainWindow()->viewer()) {
+ aMenu = viewerMenu();
+ }
+
+ if (aMenu && (aMenu->actions().size() > 0)) {
aMenu->exec(theEvent->globalPos());
delete aMenu;
}
return 0;
}
+QMenu* XGUI_ContextMenuMgr::viewerMenu() const
+{
+ QMenu* aMenu = new QMenu();
+ XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
+ QFeatureList aFeatures = aSelMgr->selectedFeatures();
+ if (aFeatures.size() > 0) {
+ if (aFeatures.size() > 0)
+ aMenu->addAction(action("EDIT_CMD"));
+ aMenu->addAction(action("HIDE_CMD"));
+ aMenu->addAction(action("DELETE_CMD"));
+ }
+ QMdiArea* aMDI = myWorkshop->mainWindow()->mdiArea();
+ if (aMDI->actions().size() > 0) {
+ QMenu* aSubMenu = aMenu->addMenu(tr("Windows"));
+ aSubMenu->addActions(aMDI->actions());
+ }
+ if (aMenu->actions().size() > 0) {
+ return aMenu;
+ }
+ delete aMenu;
+ return 0;
+}
+
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
+{
+ // TODO: Adapt to SALOME mode
+ connect(myWorkshop->mainWindow()->viewer(), SIGNAL(contextMenuRequested(QContextMenuEvent*)),
+ this, SLOT(onContextMenuRequest(QContextMenuEvent*)));
+}
void connectObjectBrowser() const;
+ void connectViewer() const;
+
signals:
void actionTriggered(const QString& theId, bool isChecked);
private:
QMenu* objectBrowserMenu() const;
+ QMenu* viewerMenu() const;
QMap<QString, QAction*> myActions;
if (part() == theFeature)
return aIndex;
- std::string aGroup = theFeature->getGroup();
+ //std::string aGroup = theFeature->getGroup();
DocumentPtr aDoc = theFeature->document();
- int aNb = aDoc->size(aGroup);
+ int aNb = aDoc->size(FEATURES_GROUP);
int aRow = -1;
for (int i = 0; i < aNb; i++) {
- if (aDoc->feature(aGroup, i) == theFeature) {
+ if (aDoc->feature(FEATURES_GROUP, i) == theFeature) {
aRow = i;
break;
}
}
if (aRow != -1) {
- if (aGroup.compare(PARAMETERS_GROUP) == 0)
+ return createIndex(aRow + 3, 0, (qint32) HistoryObject);
+/* if (aGroup.compare(PARAMETERS_GROUP) == 0)
return createIndex(aRow, 0, (qint32) ParamObject);
if (aGroup.compare(CONSTRUCTIONS_GROUP) == 0)
- return createIndex(aRow, 0, (qint32) ConstructObject);
+ return createIndex(aRow, 0, (qint32) ConstructObject);*/
}
}
return aIndex;
connect(aWindow, SIGNAL(keyReleased(XGUI_ViewWindow*, QKeyEvent*)),
this, SIGNAL(keyRelease(XGUI_ViewWindow*, QKeyEvent*)));
- connect(aWindow, SIGNAL(contextMenuRequested( QContextMenuEvent* )),
- this, SLOT (onContextMenuRequested( QContextMenuEvent* )));
- //connect(aWindow, SIGNAL( contextMenuRequested(QContextMenuEvent*) ),
- // this, SIGNAL( contextMenuRequested(QContextMenuEvent*) ) );
+ //connect(aWindow, SIGNAL(contextMenuRequested( QContextMenuEvent* )),
+ // this, SLOT (onContextMenuRequested( QContextMenuEvent* )));
+ connect(aWindow, SIGNAL( contextMenuRequested(QContextMenuEvent*) ),
+ this, SIGNAL( contextMenuRequested(QContextMenuEvent*) ) );
connect(aWindow, SIGNAL(mouseMoving(XGUI_ViewWindow*, QMouseEvent*)),
this, SLOT(onMouseMove(XGUI_ViewWindow*, QMouseEvent*)));
}
//******************************************************
-void XGUI_Viewer::onContextMenuRequested(QContextMenuEvent* theEvent)
-{
- XGUI_ViewWindow* aWnd = dynamic_cast<XGUI_ViewWindow*>(sender());
- if (!aWnd) return;
-
- QMenu aMenu;
-
- // Include Viewer actions
- if (myActions.size() > 0) {
- aMenu.addActions(myActions);
- aMenu.addSeparator();
- }
- if (aWnd->actions().size() > 0) {
- aMenu.addActions(aWnd->actions());
- aMenu.addSeparator();
- }
-
- QMdiArea* aMDI = myMainWindow->mdiArea();
- if (aMenu.actions().size() > 0) {
- QMenu* aSubMenu = aMenu.addMenu(tr("Windows"));
- aSubMenu->addActions(aMDI->actions());
- } else {
- aMenu.addActions(aMDI->actions());
- }
- aMenu.exec(theEvent->globalPos());
-}
\ No newline at end of file
+//void XGUI_Viewer::onContextMenuRequested(QContextMenuEvent* theEvent)
+//{
+// XGUI_ViewWindow* aWnd = dynamic_cast<XGUI_ViewWindow*>(sender());
+// if (!aWnd) return;
+//
+// QMenu aMenu;
+//
+// // Include Viewer actions
+// if (myActions.size() > 0) {
+// aMenu.addActions(myActions);
+// aMenu.addSeparator();
+// }
+// if (aWnd->actions().size() > 0) {
+// aMenu.addActions(aWnd->actions());
+// aMenu.addSeparator();
+// }
+//
+// QMdiArea* aMDI = myMainWindow->mdiArea();
+// if (aMenu.actions().size() > 0) {
+// QMenu* aSubMenu = aMenu.addMenu(tr("Windows"));
+// aSubMenu->addActions(aMDI->actions());
+// } else {
+// aMenu.addActions(aMDI->actions());
+// }
+// aMenu.exec(theEvent->globalPos());
+//}
void activated(XGUI_ViewWindow* theWindow);
void selectionChanged();
+ void contextMenuRequested(QContextMenuEvent*);
+
public slots:
void onWindowMinimized(QMdiSubWindow*);
void onWindowActivated(QMdiSubWindow*);
void onMouseMove(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
void onMouseReleased(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
void onMousePressed(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
- void onContextMenuRequested(QContextMenuEvent* theEvent);
+ //void onContextMenuRequested(QContextMenuEvent* theEvent);
private:
void addView(QMdiSubWindow* theView);
if (!isSalomeMode()) {
myMainWindow->showPythonConsole();
QMdiSubWindow* aWnd = myMainWindow->viewer()->createView();
+ myContextMenuMgr->connectViewer();
aWnd->showMaximized();
updateCommandStatus();
}
aFeature = aObject->featureRef();
}
}
+ if (myDisplayer->isVisible(aFeature))
+ myDisplayer->erase(aFeature, false);
aFeature->document()->removeFeature(aFeature);
}
+ myDisplayer->updateViewer();
aMgr->rootDocument()->finishOperation();
}
}