MouseAndKeyPlugin.hh 2.86 KB
Newer Older
Mike Kremer's avatar
Mike Kremer committed
1 2 3
#ifndef MOUSEANDKEYPLUGIN_HH
#define MOUSEANDKEYPLUGIN_HH

4

Mike Kremer's avatar
Mike Kremer committed
5 6 7 8 9 10 11 12 13
#include <OpenFlipper/BasePlugin/BaseInterface.hh>
#include <OpenFlipper/BasePlugin/MouseInterface.hh>
#include <OpenFlipper/BasePlugin/PickingInterface.hh>
#include <OpenFlipper/BasePlugin/KeyInterface.hh>
#include <OpenFlipper/BasePlugin/ContextMenuInterface.hh>
#include <OpenFlipper/BasePlugin/ToolboxInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>
#include <OpenFlipper/common/Types.hh>

14 15 16 17 18
#include <QPushButton>
#include <QLabel>
#include <QGridLayout>
#include <QMenu>

Mike Kremer's avatar
Mike Kremer committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
class MouseAndKeyPlugin: public QObject,
		BaseInterface,
		MouseInterface,
		PickingInterface,
		ContextMenuInterface,
		ToolboxInterface,
		KeyInterface,
		LoggingInterface {
	Q_OBJECT
	Q_INTERFACES(BaseInterface)
	Q_INTERFACES(MouseInterface)
	Q_INTERFACES(PickingInterface)
	Q_INTERFACES(KeyInterface)
	Q_INTERFACES(ContextMenuInterface)
	Q_INTERFACES(ToolboxInterface)
	Q_INTERFACES(LoggingInterface)

36 37
    Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.examples.MouseAndKeyPlugin")

Mike Kremer's avatar
Mike Kremer committed
38 39 40 41
	signals:

	//BaseInterface
	void updateView();
Jan Möbius's avatar
Jan Möbius committed
42
	void updatedObject(int _identifier, const UpdateType& _type);
Mike Kremer's avatar
Mike Kremer committed
43 44 45 46 47 48 49
	//LoggingInterface
	void log(Logtype _type, QString _message);
	void log(QString _message);
	//ContextMenuInterface
	void addContextMenuItem(QAction* _action , ContextMenuType _type);
	void addContextMenuItem(QAction* _action , DataType _objectType , ContextMenuType _type );
	//PickingInterface
Jan Möbius's avatar
Jan Möbius committed
50 51
	void addPickMode(const std::string& _mode);
	void addHiddenPickMode(const std::string& _mode);
Mike Kremer's avatar
Mike Kremer committed
52 53
	//KeyInterface
	void registerKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description, bool _multiUse = false);
Jan Möbius's avatar
Jan Möbius committed
54 55 56

  // ToolboxInterface
  void addToolbox(QString _name, QWidget* _widget);
Mike Kremer's avatar
Mike Kremer committed
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75

	private slots:

	// BaseInterface
	void initializePlugin();
	void pluginsInitialized();
	//MouseInterface
	void slotMouseEvent( QMouseEvent* _event );
	//KeyInterface
	void slotKeyEvent( QKeyEvent* _event );
	//PickingInterface
	void slotPickModeChanged( const std::string& _mode);

	public:

	// BaseInterface
	QString name() {return (QString("Mouse and Keyboard Plugin"));};
	QString description() {return (QString("Shows some basic mouse and key embedding"));};

Jan Möbius's avatar
Jan Möbius committed
76 77
	MouseAndKeyPlugin();

Mike Kremer's avatar
Mike Kremer committed
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
	private:

	// Transform geometry with given Matrix
	template <typename MeshT>
	void transformMesh(ACG::Matrix4x4d _mat , MeshT& _mesh );

	// The context menu action
	QMenu* contextMenuEntry_;

	// The toolbox widget and the button in it
	QWidget* tool_;
	QPushButton* pickButton_;

	// Last picked object
	int activeObject_;

	// Rotation axes
	ACG::Vec3d axis_x_;
	ACG::Vec3d axis_y_;

	private slots:

	// Is called each time the button in the toolbox is clicked
	void slotButtonClicked();

	// Is called if context menu item has been selected
	void contextMenuItemSelected(QAction* _action);

	public slots:
	QString version() { return QString("1.0"); };
};

#endif //MOUSEANDKEYPLUGIN_HH