ContextMenuInterface.hh 6.73 KB
Newer Older
1 2 3
/*===========================================================================*\
 *                                                                           *
 *                              OpenFlipper                                  *
Jan Möbius's avatar
Jan Möbius committed
4
 *      Copyright (C) 2001-2010 by Computer Graphics Group, RWTH Aachen      *
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
 *                           www.openflipper.org                             *
 *                                                                           *
 *---------------------------------------------------------------------------*
 *  This file is part of OpenFlipper.                                        *
 *                                                                           *
 *  OpenFlipper is free software: you can redistribute it and/or modify      *
 *  it under the terms of the GNU Lesser General Public License as           *
 *  published by the Free Software Foundation, either version 3 of           *
 *  the License, or (at your option) any later version with the              *
 *  following exceptions:                                                    *
 *                                                                           *
 *  If other files instantiate templates or use macros                       *
 *  or inline functions from this file, or you compile this file and         *
 *  link it with other files to produce an executable, this file does        *
 *  not by itself cause the resulting executable to be covered by the        *
 *  GNU Lesser General Public License. This exception does not however       *
 *  invalidate any other reasons why the executable file might be            *
 *  covered by the GNU Lesser General Public License.                        *
 *                                                                           *
 *  OpenFlipper is distributed in the hope that it will be useful,           *
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
 *  GNU Lesser General Public License for more details.                      *
 *                                                                           *
 *  You should have received a copy of the GNU LesserGeneral Public          *
 *  License along with OpenFlipper. If not,                                  *
 *  see <http://www.gnu.org/licenses/>.                                      *
 *                                                                           *
\*===========================================================================*/

/*===========================================================================*\
 *                                                                           *
 *   $Revision$                                                         *
 *   $Author$                                                      *
 *   $Date$                   *
 *                                                                           *
\*===========================================================================*/
Jan Möbius's avatar
 
Jan Möbius committed
42 43 44 45 46 47 48




//
// C++ Interface: BasePlugin
//
Jan Möbius's avatar
 
Jan Möbius committed
49
// Description:
Jan Möbius's avatar
 
Jan Möbius committed
50 51 52 53 54
//
//
// Author: Jan Moebius <jan_moebius@web.de>, (C) 2007
//

Jan Möbius's avatar
 
Jan Möbius committed
55 56
#ifndef CONTEXTMENUINTERFACE_HH
#define CONTEXTMENUINTERFACE_HH
Jan Möbius's avatar
 
Jan Möbius committed
57 58 59 60

#include <QtGui>
#include <QMenuBar>
#include <OpenFlipper/common/Types.hh>
Jan Möbius's avatar
 
Jan Möbius committed
61

Jan Möbius's avatar
 
Jan Möbius committed
62
enum ContextMenuType {
63 64 65 66 67 68 69

    /// 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
Jan Möbius's avatar
 
Jan Möbius committed
70
};
Jan Möbius's avatar
 
Jan Möbius committed
71

Jan Möbius's avatar
 
Jan Möbius committed
72
 /** \brief Interface class for creating custom context menus
Jan Möbius's avatar
 
Jan Möbius committed
73
  *
Jan Möbius's avatar
 
Jan Möbius committed
74
  * Using this interface you can create custom context menus for your plugin. You
Jan Möbius's avatar
 
Jan Möbius committed
75 76 77 78
  * can choose between context menus for objects nodes or the background.\n
  * Before a menu of the requested type is shown, an update function for the specific type
  * will be invoked by the core.
  * You have to create a QAction. The signals and slots of your actions have to be connected
Jan Möbius's avatar
 
Jan Möbius committed
79
  * to your plugin. Just connect them as usual. Only visibility of the menu is handled
Jan Möbius's avatar
 
Jan Möbius committed
80 81
  * by the core. You can also add submenus to the context menus. Just add the action for
  * the menu ( menu->menuAction() )
Jan Möbius's avatar
 
Jan Möbius committed
82 83
 */
class ContextMenuInterface {
Jan Möbius's avatar
 
Jan Möbius committed
84 85 86

public :

Jan Möbius's avatar
 
Jan Möbius committed
87 88
  /// Destructor
  virtual ~ContextMenuInterface() {};
Jan Möbius's avatar
 
Jan Möbius committed
89

Jan Möbius's avatar
 
Jan Möbius committed
90
signals:
Jan Möbius's avatar
 
Jan Möbius committed
91

92
  /**  \brief Add an entry for a context Menu
Jan Möbius's avatar
 
Jan Möbius committed
93
    *
Jan Möbius's avatar
 
Jan Möbius committed
94
    * Create an Action (Can also be the action of a Menu) and register this menu as a context menu to the core.
Jan Möbius's avatar
 
Jan Möbius committed
95 96 97
    * This Action will be visible  when you rightclick in the viewer widget on an item
    * of the given context menu type. You can add a whole menu here by adding the action:
    * menu->menuAction() of your own menu.
Jan Möbius's avatar
 
Jan Möbius committed
98
    * @param _menu Pointer to the new Action
Jan Möbius's avatar
 
Jan Möbius committed
99
  */
Jan Möbius's avatar
 
Jan Möbius committed
100
  virtual void addContextMenuItem(QAction* /*_action*/ , ContextMenuType /*_type*/) {};
Jan Möbius's avatar
 
Jan Möbius committed
101

Jan Möbius's avatar
 
Jan Möbius committed
102
  /**  \brief Add an entry for a  context Menu
Jan Möbius's avatar
 
Jan Möbius committed
103
    *
Jan Möbius's avatar
 
Jan Möbius committed
104 105
    * Create an action (Can also be the action of a Menu) and register this action as a context menu entry to the core.
    * This Action will only be visible if the picked object is of the given datatype.
Jan Möbius's avatar
 
Jan Möbius committed
106
    * To support multiple object types with your menu, you can emit this signal multiple
Jan Möbius's avatar
 
Jan Möbius committed
107 108
    * times with the same action but different DataTypes. You can add a whole Menu here by adding the action:
    * menu->menuAction()
Jan Möbius's avatar
 
Jan Möbius committed
109
    *
Jan Möbius's avatar
 
Jan Möbius committed
110
    * @param _action Pointer to the new action
Jan Möbius's avatar
 
Jan Möbius committed
111 112 113
    * @param _objectType Type of the picked object
   *  @param _type Type of the context Menu ( See ContextMenuType )
  */
Jan Möbius's avatar
 
Jan Möbius committed
114
  virtual void addContextMenuItem(QAction* /*_action*/ ,DataType /*_objectType*/ , ContextMenuType /*_type*/ ) {};
Jan Möbius's avatar
 
Jan Möbius committed
115

Jan Möbius's avatar
 
Jan Möbius committed
116
private slots:
Jan Möbius's avatar
 
Jan Möbius committed
117

Jan Möbius's avatar
 
Jan Möbius committed
118 119
  /** 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
120 121
   * depending on the given object.
   * @param _objectId id of the object
Jan Möbius's avatar
 
Jan Möbius committed
122
   */
Dirk Wilden's avatar
Dirk Wilden committed
123
  virtual void slotUpdateContextMenu( int /*_objectId*/ ) {};
Jan Möbius's avatar
 
Jan Möbius committed
124

125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
  /** 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( ) {};

Jan Möbius's avatar
 
Jan Möbius committed
140 141
};

Jan Möbius's avatar
 
Jan Möbius committed
142
Q_DECLARE_INTERFACE(ContextMenuInterface,"OpenFlipper.ContextMenuInterface/1.0")
Jan Möbius's avatar
 
Jan Möbius committed
143

Jan Möbius's avatar
 
Jan Möbius committed
144
#endif // CONTEXTMENUINTERFACE_HH