]> Shamusworld >> Repos - architektonas/blob - src/base/actioninterface.h
In the middle of removing Snapper class/fixing snapper rendering...
[architektonas] / src / base / actioninterface.h
1 #ifndef __ACTIONINTERFACE_H__
2 #define __ACTIONINTERFACE_H__
3
4 #include <QtGui>
5 #include "enums.h"
6
7 class CommandEvent;
8 class Document;
9 class Drawing;
10 class Entity;
11 class EntityContainer;
12 class GraphicView;
13 class Vector;
14
15 /**
16  * This is the interface that must be implemented for all action classes.
17  * Action classes handle actions such as drawing lines, moving entities or
18  * zooming in.
19  *
20  * Inherited from QObject for Qt translation features.
21  *
22  * @author James Hammons
23  * @author Andrew Mustun
24  */
25 class ActionInterface: public QObject
26 {
27 //WHY derive from QObject??? for the TR macro???
28 //mebbe... Well, that's what he says above. Though it would be just as easy to
29 //prefix a QObject::tr in front of translated strings...
30         public:
31                 ActionInterface(const char * name, EntityContainer &,
32                         GraphicView &);
33                 virtual ~ActionInterface();
34
35                 virtual RS2::ActionType rtti();
36                 QString getName();
37                 virtual void init(int status = 0);
38                 virtual void mouseMoveEvent(QMouseEvent *);
39                 virtual void mousePressEvent(QMouseEvent *);
40                 virtual void mouseReleaseEvent(QMouseEvent *);
41                 virtual void keyPressEvent(QKeyEvent * e);
42                 virtual void keyReleaseEvent(QKeyEvent * e);
43                 virtual void coordinateEvent(Vector *);
44                 virtual void commandEvent(CommandEvent *);
45                 virtual QStringList getAvailableCommands();
46                 virtual void setStatus(int status);
47                 virtual int getStatus();
48                 virtual void trigger();
49                 virtual void updateMouseButtonHints();
50                 virtual void updateMouseCursor();
51                 virtual void updateToolBar();
52                 virtual bool isFinished();
53                 virtual void setFinished();
54                 virtual void finish();
55                 virtual void setPredecessor(ActionInterface *);
56                 virtual void suspend();
57                 virtual void resume();
58                 virtual void hideOptions();
59                 virtual void showOptions();
60                 bool checkCommand(const QString & cmd, const QString & str,
61                         RS2::ActionType action = RS2::ActionNone);
62                 QString command(const QString & cmd);
63                 QString msgAvailableCommands();
64                 //built-in for now, we'll see how it goes...
65                 Vector snapPoint(QMouseEvent *);
66                 Entity * catchEntity(QMouseEvent *, RS2::ResolveLevel level = RS2::ResolveNone);
67                 Entity * catchEntity(Vector, RS2::ResolveLevel level = RS2::ResolveNone);
68 #warning "!!! The following functions are DEPRECATED and only in place to help with porting.. !!!"
69                 void drawSnapper(void);
70                 void deleteSnapper(void);
71                 void drawPreview(void);
72                 void clearPreview(void);
73                 void deletePreview(void);
74
75         private:
76                 /**
77                  * Current status of the action. After an action has been created the
78                  * action status is set to 0. Actions that are terminated have a status
79                  * of -1. Other status numbers can be used to describe the stage this
80                  * action is in. E.g. a window zoom consists of selecting the first
81                  * corner (status 0), and selecting the second corner (status 1).
82                  */
83                 int status;
84                 bool snapperVisibility;
85                 bool previewVisibility;
86                 int suspendCount;
87
88         protected:
89                 /** Action name. Used internally for debugging */
90                 QString name;
91                 /**
92                  * This flag is set when the action has terminated and can be deleted.
93                  */
94                 bool finished;
95                 /**
96                  * Pointer to the graphic is this container is a graphic. NULL otherwise
97                  */
98                 Drawing * graphic;
99                 /**
100                  * Pointer to the document (graphic or block) or NULL.
101                  */
102                 Document * document;
103                 /**
104                  * Predecessor of this action or NULL.
105                  */
106                 ActionInterface * predecessor;
107                 // hm.
108                 GraphicView * graphicView;
109                 EntityContainer * container;
110 };
111
112 #endif  // __ACTIONINTERFACE_H__