QCAD
Open Source 2D CAD
RAction.h
Go to the documentation of this file.
1 
20 #ifndef RACTION_H
21 #define RACTION_H
22 
23 #include "core_global.h"
24 
25 #include <QKeyEvent>
26 #include <QList>
27 #include <QMap>
28 #include <QObject>
29 #include <QString>
30 #include <QSwipeGesture>
31 #include <QPanGesture>
32 #include <QPinchGesture>
33 
34 #include "RDebug.h"
35 #include "REntity.h"
36 #include "RVector.h"
37 
38 class RPropertyEvent;
39 class RGraphicsScene;
40 class RGraphicsView;
41 class RDocumentInterface;
42 class RCommandEvent;
43 class RCoordinateEvent;
44 class RDocument;
45 class REntityPickEvent;
46 class RMouseEvent;
47 class RWheelEvent;
48 class RGuiAction;
49 class RStorage;
50 class RTabletEvent;
51 class ROperation;
52 
63 public:
67  enum ClickMode {
82  PickingDisabled
83  };
84 
85 public:
86  RAction(RGuiAction* guiAction = NULL);
87  virtual ~RAction();
88 
89  void terminate();
90  bool isTerminated();
91 
92  void setOverride();
93  bool isOverride();
94 
95  void setNoState();
96  bool hasNoState();
97 
98  void setUniqueGroup(const QString& ug);
99  QString getUniqueGroup();
100 
101  void setOverrideBase(RAction* base);
102  RAction* getOverrideBase();
103 
104  virtual RGuiAction* getGuiAction();
105 
106  void setGuiAction(RGuiAction* guiAction);
107 
108  QList<RGraphicsScene*> getGraphicsScenes();
111  RStorage* getStorage();
112 
114  documentInterface = di;
115  }
116 
123  clickMode = m;
124  }
125 
131  return clickMode;
132  }
133 
137  virtual void beginEvent() = 0;
141  virtual void setGraphicsView(RGraphicsView* view) = 0;
145  virtual void finishEvent() = 0;
149  virtual void enterEvent() = 0;
154  virtual void suspendEvent() = 0;
159  virtual void resumeEvent() = 0;
165  virtual void escapeEvent() = 0;
166 
167  virtual void keyPressEvent(QKeyEvent& event) = 0;
168 
169  virtual void keyReleaseEvent(QKeyEvent& event) = 0;
170 
174  virtual void mousePressEvent(RMouseEvent& event) = 0;
175 
179  virtual void mouseMoveEvent(RMouseEvent& event) = 0;
180 
184  virtual void mouseReleaseEvent(RMouseEvent& event) = 0;
185 
189  virtual void mouseDoubleClickEvent(RMouseEvent& event) = 0;
190 
194  virtual void wheelEvent(RWheelEvent& event) = 0;
195 
199  virtual void tabletEvent(RTabletEvent& event) = 0;
200 
204  virtual void swipeGestureEvent(QSwipeGesture& gesture) = 0;
205 
209  virtual void panGestureEvent(QPanGesture& gesture) = 0;
210 
214  virtual void pinchGestureEvent(QPinchGesture& gesture) = 0;
215 
219  virtual void commandEvent(RCommandEvent& event) = 0;
220 
224  virtual void commandEventPreview(RCommandEvent& event) = 0;
225 
232  virtual void coordinateEvent(RCoordinateEvent& event) = 0;
233 
239  virtual void coordinateEventPreview(RCoordinateEvent& event) = 0;
240 
241  virtual void entityPickEvent(REntityPickEvent& event) = 0;
242 
243  virtual void entityPickEventPreview(REntityPickEvent& event) = 0;
244 
248  virtual void propertyChangeEvent(RPropertyEvent& event) = 0;
249 
253  virtual void zoomChangeEvent(RGraphicsView& view) = 0;
254 
255  //virtual void setMultiSnapPoints(const QList<RVector>& points) = 0;
256  //virtual void setMultiSnapAngles(const QList<double>& angles) = 0;
257 
258  virtual void updatePreview() = 0;
259  virtual void applyOperation() = 0;
260 
261  RVector snap(RMouseEvent& event);
262 
263 protected:
265  bool override;
266 
271  bool noState;
272 
273  QString uniqueGroup;
278 };
279 
281 Q_DECLARE_METATYPE(RAction::ClickMode)
282 
283 #endif
This abstract class is an interface for all operation implementations.
Definition: ROperation.h:44
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RCommandEvent.h:31
A tablet event for a graphics scene.
Definition: RTabletEvent.h:43
ClickMode
Current mouse click mode.
Definition: RAction.h:67
RAction::ClickMode clickMode
Definition: RAction.h:274
Abstract base class for all graphics scenes.
Definition: RGraphicsScene.h:61
#define QCADCORE_EXPORT
Definition: core_global.h:10
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RPropertyEvent.h:40
RAction * overrideBase
Definition: RAction.h:276
This is the abstract base class for all storage implementations.
Definition: RStorage.h:62
Entity pick event.
Definition: REntityPickEvent.h:38
void setClickMode(RAction::ClickMode m)
Sets the current click mode.
Definition: RAction.h:122
RGuiAction * guiAction
Definition: RAction.h:275
Definition: RAction.h:73
void setDocumentInterface(RDocumentInterface *di)
Definition: RAction.h:113
RAction::ClickMode getClickMode()
Definition: RAction.h:130
RDocumentInterface * documentInterface
Definition: RAction.h:277
Abstract base class for all action classes.
Definition: RAction.h:62
A graphics document contains and owns entities, layers, user coordinate systems, variables, block definitions, etc.
Definition: RDocument.h:67
Mouse click will pick a coordinate and trigger coordinateEvent.
Definition: RAction.h:72
Q_DECLARE_METATYPE(RMath *)
A mouse event for a graphics scene.
Definition: RMouseEvent.h:42
void getDocument()
Returns the current RDocument or undefined.
Definition: simple.js:69
Mouse click will pick an entity and trigger entityPickEvent.
Definition: RAction.h:77
bool terminated
Definition: RAction.h:264
Abstract base class for GUI action classes.
Definition: RGuiAction.h:60
void getDocumentInterface()
Returns the current RDocumentInterface or undefined.
Definition: simple.js:50
Interface for interaction between a graphics document and a user.
Definition: RDocumentInterface.h:82
bool noState
Indicates whether this action is stateless (i.e.
Definition: RAction.h:271
QString uniqueGroup
Definition: RAction.h:273
A mouse wheel event for a graphics scene.
Definition: RWheelEvent.h:41
Coordinate Event.
Definition: RCoordinateEvent.h:37
Graphics view.
Definition: RGraphicsView.h:58