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 
117  void setClickMode(RAction::ClickMode m);
118 
124  return clickMode;
125  }
126 
130  virtual void beginEvent() = 0;
134  virtual void setGraphicsView(RGraphicsView* view) = 0;
138  virtual void finishEvent() = 0;
142  virtual void enterEvent() = 0;
147  virtual void suspendEvent() = 0;
152  virtual void resumeEvent() = 0;
158  virtual void escapeEvent() = 0;
159 
160  virtual void keyPressEvent(QKeyEvent& event) = 0;
161 
162  virtual void keyReleaseEvent(QKeyEvent& event) = 0;
163 
167  virtual void mousePressEvent(RMouseEvent& event) = 0;
168 
172  virtual void mouseMoveEvent(RMouseEvent& event) = 0;
173 
177  virtual void mouseReleaseEvent(RMouseEvent& event) = 0;
178 
182  virtual void mouseDoubleClickEvent(RMouseEvent& event) = 0;
183 
187  virtual void wheelEvent(RWheelEvent& event) = 0;
188 
192  virtual void tabletEvent(RTabletEvent& event) = 0;
193 
197  virtual void swipeGestureEvent(QSwipeGesture& gesture) = 0;
198 
202  virtual void panGestureEvent(QPanGesture& gesture) = 0;
203 
207  virtual void pinchGestureEvent(QPinchGesture& gesture) = 0;
208 
212  virtual void commandEvent(RCommandEvent& event) = 0;
213 
217  virtual void commandEventPreview(RCommandEvent& event) = 0;
218 
225  virtual void coordinateEvent(RCoordinateEvent& event) = 0;
226 
232  virtual void coordinateEventPreview(RCoordinateEvent& event) = 0;
233 
234  virtual void entityPickEvent(REntityPickEvent& event) = 0;
235 
236  virtual void entityPickEventPreview(REntityPickEvent& event) = 0;
237 
241  virtual void propertyChangeEvent(RPropertyEvent& event) = 0;
242 
246  virtual void zoomChangeEvent(RGraphicsView& view) = 0;
247 
248  //virtual void setMultiSnapPoints(const QList<RVector>& points) = 0;
249  //virtual void setMultiSnapAngles(const QList<double>& angles) = 0;
250 
251  virtual void updatePreview() = 0;
252  virtual void applyOperation() = 0;
253 
254  RVector snap(RMouseEvent& event);
255 
256 protected:
258  bool override;
259 
264  bool noState;
265 
266  QString uniqueGroup;
271 };
272 
274 Q_DECLARE_METATYPE(RAction::ClickMode)
275 
276 #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-2017 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:267
Abstract base class for all graphics scenes.
Definition: RGraphicsScene.h:61
#define QCADCORE_EXPORT
Definition: core_global.h:10
Copyright (c) 2011-2017 by Andrew Mustun.
Definition: RPropertyEvent.h:40
RAction * overrideBase
Definition: RAction.h:269
This is the abstract base class for all storage implementations.
Definition: RStorage.h:62
Entity pick event.
Definition: REntityPickEvent.h:38
RGuiAction * guiAction
Definition: RAction.h:268
Definition: RAction.h:73
void setDocumentInterface(RDocumentInterface *di)
Definition: RAction.h:113
RAction::ClickMode getClickMode()
Definition: RAction.h:123
RDocumentInterface * documentInterface
Definition: RAction.h:270
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:21
Mouse click will pick an entity and trigger entityPickEvent.
Definition: RAction.h:77
bool terminated
Definition: RAction.h:257
Abstract base class for GUI action classes.
Definition: RGuiAction.h:60
void getDocumentInterface()
Returns the current RDocumentInterface or undefined.
Definition: simple.js:67
Interface for interaction between a graphics document and a user.
Definition: RDocumentInterface.h:84
bool noState
Indicates whether this action is stateless (i.e.
Definition: RAction.h:264
QString uniqueGroup
Definition: RAction.h:266
A mouse wheel event for a graphics scene.
Definition: RWheelEvent.h:41
Coordinate Event.
Definition: RCoordinateEvent.h:37
Graphics view.
Definition: RGraphicsView.h:58