Developer Documentation
MouseAndKeyPlugin.hh
1 #ifndef MOUSEANDKEYPLUGIN_HH
2 #define MOUSEANDKEYPLUGIN_HH
3 
4 
13 
14 #include <QPushButton>
15 #include <QLabel>
16 #include <QGridLayout>
17 #include <QMenu>
18 
19 class MouseAndKeyPlugin: public QObject,
27  Q_OBJECT
28  Q_INTERFACES(BaseInterface)
29  Q_INTERFACES(MouseInterface)
30  Q_INTERFACES(PickingInterface)
31  Q_INTERFACES(KeyInterface)
32  Q_INTERFACES(ContextMenuInterface)
33  Q_INTERFACES(ToolboxInterface)
34  Q_INTERFACES(LoggingInterface)
35 
36  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.examples.MouseAndKeyPlugin")
37 
38  signals:
39 
40  //BaseInterface
41  void updateView();
42  void updatedObject(int _identifier, const UpdateType& _type);
43  //LoggingInterface
44  void log(Logtype _type, QString _message);
45  void log(QString _message);
46  //ContextMenuInterface
47  void addContextMenuItem(QAction* _action , ContextMenuType _type);
48  void addContextMenuItem(QAction* _action , DataType _objectType , ContextMenuType _type );
49  //PickingInterface
50  void addPickMode(const std::string& _mode);
51  void addHiddenPickMode(const std::string& _mode);
52  //KeyInterface
53  void registerKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description, bool _multiUse = false);
54 
55  // ToolboxInterface
56  void addToolbox(QString _name, QWidget* _widget);
57 
58  private slots:
59 
60  // BaseInterface
61  void initializePlugin();
62  void pluginsInitialized();
63  //MouseInterface
64  void slotMouseEvent( QMouseEvent* _event );
65  //KeyInterface
66  void slotKeyEvent( QKeyEvent* _event );
67  //PickingInterface
68  void slotPickModeChanged( const std::string& _mode);
69 
70  public:
71 
72  // BaseInterface
73  QString name() {return (QString("Mouse and Keyboard Plugin"));};
74  QString description() {return (QString("Shows some basic mouse and key embedding"));};
75 
77 
78  private:
79 
80  // Transform geometry with given Matrix
81  template <typename MeshT>
82  void transformMesh(ACG::Matrix4x4d _mat , MeshT& _mesh );
83 
84  // The context menu action
85  QMenu* contextMenuEntry_;
86 
87  // The toolbox widget and the button in it
88  QWidget* tool_;
89  QPushButton* pickButton_;
90 
91  // Last picked object
92  int activeObject_;
93 
94  // Rotation axes
95  ACG::Vec3d axis_x_;
96  ACG::Vec3d axis_y_;
97 
98  private slots:
99 
100  // Is called each time the button in the toolbox is clicked
101  void slotButtonClicked();
102 
103  // Is called if context menu item has been selected
104  void contextMenuItemSelected(QAction* _action);
105 
106  public slots:
107  QString version() { return QString("1.0"); };
108 };
109 
110 #endif //MOUSEANDKEYPLUGIN_HH
Interface class for receiving mouse events.
Plugins can add its own toolbox to the main widget&#39;s toolbox area by using this interface.
QString description()
Return a description of what the plugin is doing.
Logtype
Log types for Message Window.
Predefined datatypes.
Definition: DataTypes.hh:83
Interface for all Plugins which do logging to the logging window of the framework.
Update type class.
Definition: UpdateType.hh:59
Keyboard Event Interface.
Definition: KeyInterface.hh:59
QString name()
Return a name for the plugin.
Interface class for creating custom context menus.
Interface class from which all plugins have to be created.
Allow access to picking functions.