00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef TOOL_H
00026 #define TOOL_H
00027
00028 #include <avogadro/global.h>
00029 #include "plugin.h"
00030
00031 #include <QSettings>
00032 #include <QtPlugin>
00033 #include <QWheelEvent>
00034
00035 #define AVOGADRO_TOOL(i, t, d, s) \
00036 public: \
00037 static QString staticIdentifier() { return i; } \
00038 QString identifier() const { return i; } \
00039 static QString staticName() { return t; } \
00040 QString name() const { return t; } \
00041 static QString staticDescription() { return d; } \
00042 QString description() const { return d; } \
00043 QString settingsTitle() const { return s; }
00044
00045 #define AVOGADRO_TOOL_FACTORY(c) \
00046 public: \
00047 Plugin *createInstance(QObject *parent = 0) { return new c(parent); } \
00048 Plugin::Type type() const { return Plugin::ToolType; } \
00049 QString identifier() const { return c::staticIdentifier(); } \
00050 QString name() const { return c::staticName(); } \
00051 QString description() const { return c::staticDescription(); }
00052
00053 class QAction;
00054 class QUndoCommand;
00055 class QWidget;
00056
00057 namespace Avogadro {
00058
00059 class GLWidget;
00060 class Molecule;
00061
00071 class ToolPrivate;
00072 class A_EXPORT Tool : public Plugin
00073 {
00074 Q_OBJECT
00075
00076 public:
00080 Tool(QObject *parent = 0);
00081
00085 virtual ~Tool();
00086
00090 Plugin::Type type() const;
00091
00095 QString typeName() const;
00096
00100 virtual QAction* activateAction() const;
00101
00105 virtual QWidget* settingsWidget();
00106
00110 virtual QString settingsTitle() const = 0;
00111
00117 virtual QUndoCommand* mousePressEvent(GLWidget *widget, QMouseEvent *event) = 0;
00118
00124 virtual QUndoCommand* mouseReleaseEvent(GLWidget *widget, QMouseEvent *event) = 0;
00125
00131 virtual QUndoCommand* mouseMoveEvent(GLWidget *widget, QMouseEvent *event) = 0;
00132
00138 virtual QUndoCommand* wheelEvent(GLWidget *widget, QWheelEvent *event);
00139
00145 virtual QUndoCommand* keyPressEvent(GLWidget *widget, QKeyEvent *event);
00146
00152 virtual QUndoCommand* keyReleaseEvent(GLWidget *widget, QKeyEvent *event);
00153
00159 virtual bool paint(GLWidget *widget);
00160
00167 virtual int usefulness() const;
00168
00169 bool operator<(const Tool &other) const;
00170
00174 virtual void writeSettings(QSettings &settings) const;
00175
00179 virtual void readSettings(QSettings &settings);
00180
00181 Q_SIGNALS:
00186 void message(const QString &m);
00187
00188 public Q_SLOTS:
00193 virtual void setMolecule(Molecule *molecule);
00194
00195 protected:
00196 QAction *m_activateAction;
00197 ToolPrivate *const d;
00198 };
00199
00200 }
00201
00202 #endif