QCAD Application Framework
CAD Application Development and Automation.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RDocumentInterface.h
Go to the documentation of this file.
1 #ifndef RDOCUMENTINTERFACE_H
2 #define RDOCUMENTINTERFACE_H
3 
4 #include <QKeyEvent>
5 #include <QList>
6 #include <QMap>
7 #include <QMutex>
8 #include <QSharedPointer>
9 #include <QStack>
10 #include <QQueue>
11 #include <QSwipeGesture>
12 #include <QPanGesture>
13 #include <QPinchGesture>
14 
15 #include "RAction.h"
16 #include "RCoordinateEvent.h"
17 #include "RCommandEvent.h"
18 #include "RCoordinateListener.h"
19 #include "RDocument.h"
20 #include "RExporter.h"
21 #include "RStorage.h"
22 #include "RTerminateEvent.h"
23 #include "RTextLabel.h"
24 #include "RUcs.h"
25 
26 #define RDEFAULT_QLIST_QREAL QList<qreal>()
27 #ifndef RDEFAULT_MIN1
28 #define RDEFAULT_MIN1 -1
29 #endif
30 
31 class RGraphicsScene;
32 class RGraphicsView;
33 class RMouseEvent;
34 class ROperation;
35 class RPropertyEvent;
36 class RSnap;
37 class RSnapRestriction;
38 class RScriptHandler;
39 class RTransaction;
40 class RWheelEvent;
41 
42 
43 
62 public:
63  enum IoErrorCode {
80  };
81 
82 public:
85 
88  QList<RGraphicsScene*> getGraphicsScenes();
90 
93 
94  void clear();
95 
99  RScriptHandler* getScriptHandler(const QString& extension);
100  bool isScriptRunning();
101 
102  void setDefaultAction(RAction* action);
103  void setCurrentAction(RAction* action);
104  void queueAction(RAction* action);
105  void killAllActions();
106 
108  bool hasCurrentAction();
109 
110  void suspend();
111  void resume();
112 
115 
116  void terminateEvent(RTerminateEvent& event);
117 
118  void keyPressEvent(QKeyEvent& event);
119  void keyReleaseEvent(QKeyEvent& event);
120  void mouseMoveEvent(RMouseEvent& event);
121  void mousePressEvent(RMouseEvent& event);
122  void mouseReleaseEvent(RMouseEvent& event);
123  void mouseDoubleClickEvent(RMouseEvent& event);
124  void coordinateEvent(RCoordinateEvent& event);
126  void commandEvent(RCommandEvent& event);
127  void commandEventPreview(RCommandEvent& event);
128  void wheelEvent(RWheelEvent& event);
129  void tabletEvent(RTabletEvent& event);
130  void swipeGestureEvent(QSwipeGesture& gesture);
131  void panGestureEvent(QPanGesture& gesture);
132  void pinchGestureEvent(QPinchGesture& gesture);
133 
134  void propertyChangeEvent(RPropertyEvent& event);
135  void ucsSetEvent(const QString& ucsName);
136 
137  void enableUpdates();
138  void disableUpdates();
139 
140  void updateAllEntities();
141 
142  void regenerateScenes(bool undone = false);
143  void regenerateScenes(QSet<REntity::Id>& entityIds, bool updateViews);
144  void regenerateScenes(REntity::Id entityId, bool updateViews);
145 
146  void regenerateViews(bool force=false);
147  void repaintViews();
148 
149  void registerScene(RGraphicsScene& scene);
150  void unregisterScene(RGraphicsScene& scene);
151 
152  void setCursor(const QCursor& cursor, bool global = true);
153 
154  RDocumentInterface::IoErrorCode importUrl(const QUrl& url, bool notify = true);
156  const QString& fileName, const QString& nameFilter = "", bool notify = true);
157 
158  QString getCorrectedFileName(const QString& fileName, const QString& fileVersion);
159  bool exportFile(const QString& fileName, const QString& fileVersion = "", bool resetModified = true);
160 
161  void undo();
162  void redo();
163 
164  void setSnap(RSnap* snap);
165  RSnap* getSnap();
166 
167  void setSnapRestriction(RSnapRestriction* snapRestriction);
169 
170  RVector snap(RMouseEvent& event);
171 
173  REntity::Id getClosestEntity(const RVector& position, double range, bool includeLockedLayers = true);
174  //REntity::Id getClosestEntityInUcs(const RVector& position, double range);
175  void highlightEntity(REntity::Id entityId);
176  void highlightReferencePoint(const RVector& position);
177  void selectEntities(const QSet<REntity::Id>& entityIds, bool add = false);
178  void selectEntity(REntity::Id entityId, bool add = false);
179  void deselectEntities(const QSet<REntity::Id>& entityIds);
180  void deselectEntity(REntity::Id entityId);
181  //void selectClosestEntity(RMouseEvent& event, const RLine& line, bool add = false);
182  void selectBoxXY(const RBox& box, bool add = false);
183  //void selectBoxInUcs(const RBox& box, bool add = false);
184  void selectAll();
185  void deselectAll();
186  void clearSelection();
187  bool hasSelection();
188 
189  void addZoomBoxToPreview(const RBox& box);
190  //void addTextLabelToPreview(const RTextLabel& textLabel);
191  void addShapeToPreview(RShape& shape, const RColor& color,
192  const QBrush& brush, RLineweight::Lineweight lineweight,
193  Qt::PenStyle style, const QList<qreal>& dashValues = RDEFAULT_QLIST_QREAL);
194  void addAuxShapeToPreview(RShape& shape);
195  void addEntityToPreview(REntity& entity);
196  void beginPreview();
197  void endPreview();
198  void clearPreview();
199  bool isPreviewEmpty();
200  void keepPreview();
201 
202  void showPropertiesOf(REntity& entity);
203  void clearProperties();
204 
205  void zoomIn();
206  void zoomOut();
207  void autoZoom(int margin = RDEFAULT_MIN1);
208  bool zoomToSelection();
209  void zoomTo(const RBox& region, int margin = 0);
210  void zoomPrevious();
211 
212  void previewOperation(const ROperation* operation);
213  RTransaction applyOperation(const ROperation* operation);
214 
215  void objectChangeEvent(QList<RObject::Id>& objectIds);
216 
217  RVector getRelativeZero() const;
218  RVector getLastPosition() const;
219  void setRelativeZero(const RVector& p);
220 
221  void lockRelativeZero();
222  void unlockRelativeZero();
223  bool isRelativeZeroLocked() const;
224 
225  RVector getCursorPosition() const;
226  void setCursorPosition(const RVector& p);
227  void setCursorOverride(bool on);
228  bool getCursorOverride() const;
229 
231 
232  void setCurrentColor(const RColor& color);
234 
237 
238  void setCurrentLinetype(RLinetype lt);
240 
241  void setCurrentLayer(const RLayer& layer);
242  void setCurrentLayer(const QString& layerName);
243 
244  void setCurrentBlock(const RBlock& block);
245  void setCurrentBlock(const QString& blockName);
246 
247  void setCurrentView(const QString& viewName);
248 
249  void setCurrentUcs(const RUcs& ucs);
250  void setCurrentUcs(const QString& ucsName);
252  QString getCurrentUcsName();
253 
256 
258  bool isClipboard() {
259  return this==clipboard;
260  }
261  bool isSuspended() {
262  return suspended;
263  }
264  void setNotifyListeners(bool on) {
265  notifyListeners = on;
266  }
267 
268 private:
269  void handleClickEvent(RAction& action, RMouseEvent& event);
270  void previewClickEvent(RAction& action, RMouseEvent& event);
271 
272 private:
274  QList<RGraphicsScene*> scenes;
276  QMap<QString, RScriptHandler*> scriptHandlers;
277 
279  QStack<RAction*> currentActions;
280  QQueue<RAction*> queuedActions;
281 
282  QList<RCoordinateListener*> coordinateListeners;
283 
286 
292  QString currentUcsName;
293  bool suspended;
294 
296 
298 
300  bool deleting;
302 
304 
305  //QMutex mutex;
306 };
307 
310 
311 #endif