1 #ifndef RS_ACTIONINTERFACE_H
2 #define RS_ACTIONINTERFACE_H
6 #include "rs_entitycontainer.h"
7 #include "rs_commandevent.h"
8 //#include "rs_event.h"
9 #include "rs_graphic.h"
10 #include "rs_graphicview.h"
11 #include "rs_snapper.h"
12 #include "rs_preview.h"
13 #include "rs_dialogfactory.h"
19 //template<class T> T* instantiate(RS_EntityContainer& container, RS_GraphicView& graphicView) {
20 // return new T(container, graphicView);
21 //void (*function)() = T::instantiate;
22 //return (*function)();
26 * This is the interface that must be implemented for all
27 * action classes. Action classes handle actions such
28 * as drawing lines, moving entities or zooming in.
30 * Inherited from QObject for Qt translation features.
32 * @author Andrew Mustun
34 class RS_ActionInterface: public QObject, public RS_Snapper
36 //huh? no slots/signals here... Q_OBJECT
39 RS_ActionInterface(const char * name, RS_EntityContainer & container,
40 RS_GraphicView & graphicView);
41 virtual ~RS_ActionInterface();
43 virtual RS2::ActionType rtti();
47 virtual void init(int status = 0);
48 virtual void mouseMoveEvent(QMouseEvent *);
49 virtual void mousePressEvent(QMouseEvent *);
51 virtual void mouseReleaseEvent(QMouseEvent *);
52 virtual void keyPressEvent(QKeyEvent * e);
53 virtual void keyReleaseEvent(QKeyEvent * e);
54 virtual void coordinateEvent(RS_CoordinateEvent *);
55 virtual void commandEvent(RS_CommandEvent *);
56 virtual QStringList getAvailableCommands();
57 virtual void setStatus(int status);
58 virtual int getStatus();
59 virtual void trigger();
60 virtual void updateMouseButtonHints();
61 virtual void updateMouseCursor();
62 virtual void updateToolBar();
63 virtual bool isFinished();
64 virtual void setFinished();
65 virtual void finish();
66 virtual void setPredecessor(RS_ActionInterface * pre);
67 virtual void suspend();
68 virtual void resume();
69 virtual void hideOptions();
70 virtual void showOptions();
71 bool checkCommand(const QString & cmd, const QString & str,
72 RS2::ActionType action = RS2::ActionNone);
73 QString command(const QString & cmd);
74 QString msgAvailableCommands();
78 * Current status of the action. After an action has
79 * been created the action status is set to 0. Actions
80 * that are terminated have a status of -1. Other status
81 * numbers can be used to describe the stage this action
82 * is in. E.g. a window zoom consists of selecting the
83 * first corner (status 0), and selecting the second
89 /** Action name. Used internally for debugging */
93 * This flag is set when the action has terminated and
99 * Pointer to the graphic is this container is a graphic.
102 RS_Graphic * graphic;
105 * Pointer to the document (graphic or block) or NULL.
107 RS_Document * document;
110 * Pointer to the default mouse cursor for this action or NULL.
112 //RS2::CursorType cursor;
115 * Predecessor of this action or NULL.
117 RS_ActionInterface * predecessor;
120 * String prepended to the help text for currently available commands.
122 //static QString msgAvailableCommands;
125 * Command used for showing help for every action.
127 //static QString cmdHelp;
130 * Command for answering yes to a question.
132 //static QString cmdYes;
133 //static QString cmdYes2;
136 * Command for answering no to a question.
138 //static QString cmdNo;
139 //static QString cmdNo2;