/// Use plugin manager for features creation
PartSetPlugin_Part();
+
+ /// Returns true if this feature must be displayed in the history (top level of Part tree)
+ PARTSETPLUGIN_EXPORT virtual bool isInHistory() {return false;}
};
#endif
XGUI_ViewerProxy.h
XGUI_ViewerPrs.h
XGUI_PropertyPanel.h
+ XGUI_ContextMenuMgr.h
)
SET(PROJECT_AUTOMOC
XGUI_ViewerProxy.cpp
XGUI_ViewerPrs.cpp
XGUI_PropertyPanel.cpp
+ XGUI_ContextMenuMgr.cpp
)
SET(PROJECT_RESOURCES
--- /dev/null
+
+#include "XGUI_ContextMenuMgr.h"
+#include "XGUI_Workshop.h"
+#include "XGUI_ObjectsBrowser.h"
+#include "XGUI_SelectionMgr.h"
+
+#include <QAction>
+#include <QContextMenuEvent>
+#include <QMenu>
+
+XGUI_ContextMenuMgr::XGUI_ContextMenuMgr(XGUI_Workshop* theParent) :
+QObject(theParent), myWorkshop(theParent)
+{
+
+}
+
+XGUI_ContextMenuMgr::~XGUI_ContextMenuMgr()
+{
+}
+
+void XGUI_ContextMenuMgr::createActions()
+{
+ QAction* aAction = new QAction(QIcon(":pictures/edit.png"), tr("Edit..."), this);
+ addAction("EDIT_CMD", aAction);
+}
+
+void XGUI_ContextMenuMgr::addAction(const QString& theId, QAction* theAction)
+{
+ if (myActions.contains(theId))
+ qCritical("A command with Id = '%s' already defined!", qPrintable(theId));
+ theAction->setData(theId);
+ connect(theAction, SIGNAL(triggered(bool)), this, SLOT(onAction(bool)));
+ myActions[theId] = theAction;
+}
+
+QAction* XGUI_ContextMenuMgr::action(const QString& theId) const
+{
+ if (myActions.contains(theId))
+ return myActions[theId];
+ return 0;
+}
+
+QStringList XGUI_ContextMenuMgr::actionIds() const
+{
+ return myActions.keys();
+}
+
+void XGUI_ContextMenuMgr::onAction(bool isChecked)
+{
+ QAction* aAction = static_cast<QAction*>(sender());
+ emit actionTriggered(aAction->data().toString(), isChecked);
+}
+
+void XGUI_ContextMenuMgr::updateCommandsStatus()
+{
+}
+
+void XGUI_ContextMenuMgr::onContextMenuRequest(QContextMenuEvent* theEvent)
+{
+ QMenu* aMenu = 0;
+ if (sender() == myWorkshop->objectBrowser())
+ aMenu = objectBrowserMenu();
+
+ if (aMenu) {
+ aMenu->exec(theEvent->globalPos());
+ delete aMenu;
+ }
+}
+
+QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const
+{
+ XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
+ QFeatureList aFeatures = aSelMgr->selectedFeatures();
+ if (aFeatures.size() == 1) {
+ FeaturePtr aFeature = aFeatures.first();
+ if (aFeature->getKind() != "Part") {
+ QMenu* aMenu = new QMenu();
+ aMenu->addAction(action("EDIT_CMD"));
+ return aMenu;
+ }
+ }
+ return 0;
+}
+
+void XGUI_ContextMenuMgr::connectObjectBrowser() const
+{
+ connect(myWorkshop->objectBrowser(), SIGNAL(contextMenuRequested(QContextMenuEvent*)),
+ this, SLOT(onContextMenuRequest(QContextMenuEvent*)));
+}
\ No newline at end of file
--- /dev/null
+
+#ifndef XGUI_ContextMenuMgr_H
+#define XGUI_ContextMenuMgr_H
+
+#include "XGUI.h"
+
+#include <QObject>
+#include <QMap>
+
+class XGUI_Workshop;
+class QAction;
+class QContextMenuEvent;
+class QMenu;
+
+class XGUI_EXPORT XGUI_ContextMenuMgr: public QObject
+{
+Q_OBJECT
+public:
+ XGUI_ContextMenuMgr(XGUI_Workshop* theParent);
+ virtual ~XGUI_ContextMenuMgr();
+
+ void createActions();
+
+ void addAction(const QString& theId, QAction* theAction);
+
+ QAction* action(const QString& theId) const;
+
+ QStringList actionIds() const;
+
+ void updateCommandsStatus();
+
+ void connectObjectBrowser() const;
+
+signals:
+ void actionTriggered(const QString& theId, bool isChecked);
+
+private slots:
+ void onAction(bool isChecked);
+
+ void onContextMenuRequest(QContextMenuEvent* theEvent);
+
+private:
+ QMenu* objectBrowserMenu() const;
+
+ QMap<QString, QAction*> myActions;
+
+ XGUI_Workshop* myWorkshop;
+};
+
+#endif
\ No newline at end of file
setExpanded(aIndex, myDocModel->hasChildren(aIndex));
emit activePartChanged(myDocModel->activePart());
}
+}
+
+void XGUI_ObjectsBrowser::contextMenuEvent(QContextMenuEvent* theEvent)
+{
+ emit contextMenuRequested(theEvent);
}
\ No newline at end of file
//! Emited when selection is changed
void selectionChanged();
void activePartChanged(FeaturePtr thePart);
+
+ //! Emited on context menu request
+ void contextMenuRequested(QContextMenuEvent* theEvent);
protected:
virtual void mouseDoubleClickEvent(QMouseEvent* theEvent);
+ virtual void contextMenuEvent(QContextMenuEvent* theEvent);
private slots:
//! Called when selection in Data Tree is changed
void XGUI_ViewWindow::contextMenuEvent(QContextMenuEvent* theEvent)
{
if (theEvent->modifiers() == Qt::NoModifier) {
- QFrame::contextMenuEvent(theEvent);
+ // Temporary: has to be removed when viewer popup will be defined
+ //QFrame::contextMenuEvent(theEvent);
emit contextMenuRequested(theEvent);
}
}
#include <QMdiArea>
#include <QMdiSubWindow>
#include <QApplication>
+#include <QMouseEvent>
+#include <QMenu>
#include <V3d_View.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <AIS_Shape.hxx>
-#include <QMouseEvent>
#ifdef WIN32
#include <WNT_Window.hxx>
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, SLOT (onContextMenuRequested( QContextMenuEvent* )));
//connect(aWindow, SIGNAL( contextMenuRequested(QContextMenuEvent*) ),
// this, SIGNAL( contextMenuRequested(QContextMenuEvent*) ) );
aView->updateEnabledDrawMode();
}
}
+
+//******************************************************
+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
#include <QObject>
#include <QMap>
#include <QList>
+#include <QPoint>
+#include <QAction>
#include <V3d_Viewer.hxx>
#include <AIS_InteractiveContext.hxx>
#include <NCollection_List.hxx>
#include <TopoDS_Shape.hxx>
-#include <QPoint>
class XGUI_MainWindow;
class QMdiSubWindow;
//! Compute trihedron size dependent on 3d scene size
bool computeTrihedronSize(double& theNewSize, double& theSize);
+ //! Add action to the viewer
+ void addAction(QAction* theAction) { myActions.append(theAction); }
+
+
static void setHotButton(XGUI::InteractionStyle theInteractionStyle, XGUI::HotOperation theOper,
Qt::KeyboardModifiers theState, Qt::MouseButtons theButton);
static void getHotButton(XGUI::InteractionStyle theInteractionStyle, XGUI::HotOperation theOper,
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);
private:
void addView(QMdiSubWindow* theView);
/// Points used for selection management
QPoint myStartPnt, myEndPnt, myCurPnt;
- // A counter of created windows
+ /// A counter of created windows
int myWndIdCount;
+
+ /// List of Viewer actions
+ QList<QAction*> myActions;
};
#endif
#include "XGUI_ErrorDialog.h"
#include "XGUI_ViewerProxy.h"
#include "XGUI_PropertyPanel.h"
+#include "XGUI_ContextMenuMgr.h"
#include <Model_Events.h>
#include <ModelAPI_PluginManager.h>
myOperationMgr = new XGUI_OperationMgr(this);
myActionsMgr = new XGUI_ActionsMgr(this);
myErrorDlg = new XGUI_ErrorDialog(myMainWindow);
+ myContextMenuMgr = new XGUI_ContextMenuMgr(this);
myViewerProxy = new XGUI_ViewerProxy(this);
QIcon(":pictures/close.png"), QKeySequence::Close);
aCommand->connectTo(this, SLOT(onExit()));
+ myContextMenuMgr->createActions();
}
//******************************************************
if (aMgr->hasRootDocument()) {
XGUI_Command* aUndoCmd;
XGUI_Command* aRedoCmd;
- for (aIt = aCommands.constBegin(); aIt != aCommands.constEnd(); ++aIt) {
- if ((*aIt)->id() == "UNDO_CMD")
- aUndoCmd = (*aIt);
- else if ((*aIt)->id() == "REDO_CMD")
- aRedoCmd = (*aIt);
+ foreach(XGUI_Command* aCmd, aCommands) {
+ if (aCmd->id() == "UNDO_CMD")
+ aUndoCmd = aCmd;
+ else if (aCmd->id() == "REDO_CMD")
+ aRedoCmd = aCmd;
else // Enable all commands
- (*aIt)->enable();
+ aCmd->enable();
}
boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
aUndoCmd->setEnabled(aDoc->canUndo());
aRedoCmd->setEnabled(aDoc->canRedo());
} else {
- for (aIt = aCommands.constBegin(); aIt != aCommands.constEnd(); ++aIt) {
- if ((*aIt)->id() == "NEW_CMD")
- (*aIt)->enable();
- else if ((*aIt)->id() == "EXIT_CMD")
- (*aIt)->enable();
+ foreach(XGUI_Command* aCmd, aCommands) {
+ if (aCmd->id() == "NEW_CMD")
+ aCmd->enable();
+ else if (aCmd->id() == "EXIT_CMD")
+ aCmd->enable();
else
- (*aIt)->disable();
+ aCmd->disable();
}
}
}
myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock);
connect(myObjectBrowser, SIGNAL(activePartChanged(FeaturePtr)), this, SLOT(changeCurrentDocument(FeaturePtr)));
aObjDock->setWidget(myObjectBrowser);
+
+ myContextMenuMgr->connectObjectBrowser();
return aObjDock;
}
class XGUI_SalomeViewer;
class XGUI_ViewerProxy;
class XGUI_PropertyPanel;
+class XGUI_ContextMenuMgr;
class ModuleBase_Operation;
//! Returns property panel widget
XGUI_PropertyPanel* propertyPanel() const { return myPropertyPanel; }
+ //! Returns context menu manager object
+ XGUI_ContextMenuMgr* contextMenuMgr() const { return myContextMenuMgr; }
+
//! Creates and adds a new workbench (menu group) with the given name and returns it
XGUI_Workbench* addWorkbench(const QString& theName);
XGUI_SalomeConnector* mySalomeConnector;
XGUI_ErrorDialog* myErrorDlg;
XGUI_ViewerProxy* myViewerProxy;
+ XGUI_ContextMenuMgr* myContextMenuMgr;
static QMap<QString, QString> myIcons;
<file>pictures/redo.png</file>
<file>pictures/undo.png</file>
<file>pictures/rebuild.png</file>
- <!--For test purposes-->
<file>pictures/occ_view_back.png</file>
<file>pictures/occ_view_bottom.png</file>
<file>pictures/cascade_views.png</file>
<file>pictures/tile_views.png</file>
<file>pictures/new_view.png</file>
+ <file>pictures/edit.png</file>
</qresource>
</RCC>