Commit 17af05cb authored by Jan Möbius's avatar Jan Möbius

Chenged and extended context Menu Interface to allow context for arbitrary Nodes

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5240 383ad7c9-94d9-4d36-a494-682f7c89f535
parent e81bc594
......@@ -49,10 +49,13 @@
#include <OpenFlipper/common/Types.hh>
enum ContextMenuType {
/// The Menu will be created directly inside the Menu.
CONTEXTTOPLEVELMENU,
/// The Menu will be added inside the Selection part of the Context Menu
CONTEXTSELECTIONMENU
/// The Menu will be shown when an object was picked
CONTEXTOBJECTMENU,
/// The Menu will be shown when a node was picked
CONTEXTNODEMENU,
/// The Menu will be shown when the background was picked
CONTEXTBACKGROUNDMENU
};
/** \brief Interface class for creating custom context menus
......@@ -75,10 +78,11 @@ public :
signals:
/** \brief Add an entry for a persistent context Menu
/** \brief Add an entry for a context Menu
*
* Create an QMenu and register this menu as a persistent context menu to the core.
* This Menu will be always visible when you rightclick in the viewer widget.
* Create an QMenu and register this menu as a context menu to the core.
* This Menu will be visible when you rightclick in the viewer widget on
* The given Context Menu Type.
* @param _menu Pointer to the new Menu
*/
virtual void addContextMenu(QMenu* /*_menu*/ , ContextMenuType /*_type*/) {};
......@@ -100,11 +104,26 @@ private slots:
/** When the main application requests a context menu, this slot is called before showing the window.
* If an object is picked the id will be given in this call so you can change the contents of your menu
* depending on the given object,
* @param _objectId id of the object or -1 if nothing picked
* depending on the given object.
* @param _objectId id of the object
*/
virtual void slotUpdateContextMenu( int /*_objectId*/ ) {};
/** When the main application requests a context menu, this slot is called before showing the window.
* This slot will be called indicating that a scenegraph node not belonging to an object
* has been picked.
* The id of the node is given as a parameter
* @param _node id of the picked node
*/
virtual void slotUpdateContextMenuNode( int /*_nodeId*/ ) {};
/** When the main application requests a context menu, this slot is called before showing the window.
* This slot will be called indicating thatthe background has been picked.
* The id of the node is given as a parameter
* @param _node id of the picked node
*/
virtual void slotUpdateContextMenuBackground( ) {};
};
Q_DECLARE_INTERFACE(ContextMenuInterface,"OpenFlipper.ContextMenuInterface/0.3")
......
......@@ -561,9 +561,9 @@ void Core::loadPlugin(QString filename, bool silent){
if ( contextMenuPlugin && OpenFlipper::Options::gui() ) {
supported = supported + "ContextMenu ";
if ( checkSignal(plugin,"addContextMenu(QMenu*)") )
connect(plugin , SIGNAL(addContextMenu(QMenu*)),
coreWidget_ , SLOT(slotAddContextMenu(QMenu*)),Qt::DirectConnection);
if ( checkSignal(plugin,"addContextMenu(QMenu*,ContextMenuType)") )
connect(plugin , SIGNAL(addContextMenu(QMenu*,ContextMenuType)),
coreWidget_ , SLOT(slotAddContextMenu(QMenu*,ContextMenuType)),Qt::DirectConnection);
if ( checkSignal(plugin,"addContextMenu(QMenu*,DataType,ContextMenuType)") )
connect(plugin , SIGNAL(addContextMenu(QMenu*,DataType,ContextMenuType)),
......@@ -573,6 +573,13 @@ void Core::loadPlugin(QString filename, bool silent){
connect(coreWidget_ , SIGNAL(updateContextMenu(int)),
plugin , SLOT(slotUpdateContextMenu(int)),Qt::DirectConnection);
if ( checkSlot(plugin,"slotUpdateContextMenuNode(int)") )
connect(coreWidget_ , SIGNAL(updateContextMenuNode(int)),
plugin , SLOT(slotUpdateContextMenuNode(int)),Qt::DirectConnection);
if ( checkSlot(plugin,"slotUpdateContextMenuBackground()") )
connect(coreWidget_ , SIGNAL(updateContextMenuBackground()),
plugin , SLOT(slotUpdateContextMenuBackground()),Qt::DirectConnection);
}
//Check if the plugin supports Toolbox-Interface
......
<?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE KDevPrjSession>
<KDevPrjSession>
<DocsAndViews NumberOfDocuments="8" >
<Doc0 NumberOfViews="1" URL="file:///home/jan/projects/OpenFlipper/OpenFlipper/Core/Core.cc" >
<View0 Encoding="" line="476" Type="Source" />
</Doc0>
<Doc1 NumberOfViews="1" URL="file:///home/jan/projects/OpenFlipper/OpenFlipper/widgets/coreWidget/ContextMenu.cc" >
<View0 Encoding="" line="104" Type="Source" />
</Doc1>
<Doc2 NumberOfViews="1" URL="file:///home/jan/projects/OpenFlipper/Plugin-ViewControl/ViewControlPlugin.cc" >
<View0 Encoding="" line="569" Type="Source" />
</Doc2>
<Doc3 NumberOfViews="1" URL="file:///home/jan/projects/OpenFlipper/OpenFlipper/widgets/coreWidget/MenuBar.cc" >
<View0 Encoding="" line="65" Type="Source" />
</Doc3>
<Doc4 NumberOfViews="1" URL="file:///home/jan/projects/OpenFlipper/OpenFlipper/widgets/coreWidget/CoreWidget.hh" >
<View0 Encoding="" line="515" Type="Source" />
</Doc4>
<Doc5 NumberOfViews="1" URL="file:///home/jan/projects/OpenFlipper/Plugin-ViewControl/ViewControlPlugin.hh" >
<View0 Encoding="" line="110" Type="Source" />
</Doc5>
<Doc6 NumberOfViews="1" URL="file:///home/jan/projects/OpenFlipper/OpenFlipper/widgets/coreWidget/CoreWidget.cc" >
<View0 Encoding="" line="90" Type="Source" />
</Doc6>
<Doc7 NumberOfViews="1" URL="file:///home/jan/projects/OpenFlipper/OpenFlipper/BasePlugin/PluginFunctions.cc" >
<View0 Encoding="" line="304" Type="Source" />
</Doc7>
</DocsAndViews>
<DocsAndViews NumberOfDocuments="0" />
<pluginList>
<kdevdebugger>
<breakpointList/>
......
......@@ -110,8 +110,8 @@ struct MenuInfo {
/// Type of objects for which the context Menu should be visible
DataType contextType;
/// Position of the context Menu inside the main widgets context Menu
ContextMenuType position;
/// Type of the context Menu ( Context for what type .. Background,Object,Node)
ContextMenuType type;
};
/** Core Widget of the Application
......@@ -270,14 +270,14 @@ public:
/// Setup the main menubar
void setupMenuBar();
/** @} */
//===========================================================================
/** @name Recent File Menu handling
* @{ */
//===========================================================================
/// Add a recent file and update menu
void addRecent(QString _filename, DataType _type);
......@@ -465,7 +465,7 @@ public:
/// View Menu
QMenu *viewMenu_;
/// Tools Menu
QMenu *toolsMenu_;
......@@ -495,51 +495,58 @@ public:
/** @name View Menu
* @{ */
//===========================================================================
public slots:
/// Setup and update the global draw menu
void slotUpdateGlobalDrawMenu();
private slots:
/// Called when the global drawMode is selected
void slotGlobalDrawMenu(QAction * _action);
/// Called before the view Menu is shown
void slotViewMenuAboutToShow();
private:
/// This variable holds the global draw menu
QMenu* globalDrawMenu_;
QActionGroup * drawGroup_;
QActionGroup * drawGroup_;
/// Group for all menu items
QActionGroup* viewGroup_;
QAction* perspectiveProjectionAction_;
QAction* orthogonalProjectionAction_;
int activeDrawModes_;
int availableGlobalDrawModes_;
/** @} */
//===========================================================================
/** @name Context Menu
* @{ */
//===========================================================================
signals :
// tells the plugins to update their context menu
void updateContextMenu(int) ;
/// tells the plugins to update their context menu when an object is picked
void updateContextMenu(int);
/// tells the plugins to update their context menu when a node is picked
void updateContextMenuNode(int);
/// tells the plugins to update their context menu when the background is picked
void updateContextMenuBackground();
private slots:
/// This slot is called by the examiner widgets gl area when a context menu is requested
void slotCustomContextMenu( const QPoint& _point );
/// called by plugins to add a new context menu
void slotAddContextMenu(QMenu* _menu);
void slotAddContextMenu(QMenu* _menu, ContextMenuType _type);
/// called by plugins to add a real context menu depending on DataType
void slotAddContextMenu( QMenu* _menu , DataType _dataType ,ContextMenuType type_);
......@@ -555,10 +562,10 @@ public:
/// Set the snapShot name for all examiners
void slotSnapshotName();
/// Called when a coordsys drawMode has been changed
void slotViewerDrawMenu( QAction * _action );
/// Creates a draw Menu for the currently active Viewer
void slotUpdateViewerDrawMenu();
......@@ -569,9 +576,12 @@ public:
*/
void updatePopupMenu(const QPoint& _point);
void updatePopupMenuCoordsysNode(QMenu* _menu , const int _part);
void updatePopupMenuObject(QMenu* _menu , const int _objectId );
void updatePopupMenuCoordsysNode(QMenu* _menu , const int _part);
void updatePopupMenuObject(QMenu* _menu , BaseObjectData* _object );
void updatePopupMenuBackground(QMenu* _menu , const QPoint& _point);
void updatePopupMenuNode(QMenu* _menu , ACG::SceneGraph::BaseNode* _node);
bool addContextMenus( QMenu* _menu , ContextMenuType _type, int _id = -1);
private :
/// context Menu for the gl area
......@@ -580,15 +590,12 @@ public:
/// Context Menu containing all selection elements
QMenu* contextSelectionMenu_;
/// All context menu entries which will always be available
std::vector< MenuInfo > persistentContextMenus_;
/// All real context menu entries
std::vector< MenuInfo > contextMenus_;
/// DrawGroup for per Viewer Draw Modes
QActionGroup* drawGroupViewer_;
/// Draw Menu for per Viewer Draw Modes
QMenu* viewerDrawMenu_;
......@@ -751,65 +758,65 @@ public:
/// Set Background Color for all viewers at once.
void slotSetGlobalBackgroundColor();
/// Set Background Color for one viewer.
void slotSetContextBackgroundColor();
/// Set the active viewer to home position
void slotContextHomeView();
/// Set the viewer to home position
void slotGlobalHomeView();
/// Set the active viewers home position
void slotContextSetHomeView();
/// Set the home position for all viewers
/// Set the home position for all viewers
void slotGlobalSetHomeView();
/// Change view on active viewer to view complete scene
void slotContextViewAll();
/// Change view on all viewers to view complete scene
void slotGlobalViewAll();
/// Toggle projection Mode of the active viewer.
void slotContextSwitchProjection();
/// Toggle projection Mode of all viewers to perspective projection
void slotGlobalPerspectiveProjection();
/// Toggle projection Mode of all viewers to orthographic projection
void slotGlobalOrthographicProjection();
/// Set the animation Mode for all viewers
void slotGlobalChangeAnimation(bool _animation);
/// Set the animation Mode for active viewer
void slotLocalChangeAnimation(bool _animation);
/// Set Backface culling for all viewers
void slotGlobalChangeBackFaceCulling(bool _backFaceCulling);
/// Set Backface culling for active viewer
void slotLocalChangeBackFaceCulling(bool _backFaceCulling);
/// Set two sided lighting for all viewers
void slotGlobalChangeTwoSidedLighting(bool _lighting);
/// Set two sided lighting for active viewer
void slotLocalChangeTwoSidedLighting(bool _lighting);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment