QCAD
Open Source 2D CAD
RGraphicsScene.h
Go to the documentation of this file.
1 
20 #ifndef RGRAPHICSSCENE_H
21 #define RGRAPHICSSCENE_H
22 
23 #include "core_global.h"
24 
25 #include <QCursor>
26 #include <QDebug>
27 
28 #include "RDebug.h"
29 #include "REntity.h"
30 #include "RExporter.h"
31 #include "RGraphicsView.h"
32 #include "RGraphicsSceneDrawable.h"
33 #include "RMouseEvent.h"
34 #include "RSpatialIndex.h"
35 #include "RTabletEvent.h"
36 //#include "RTextLabel.h"
37 #include "RWheelEvent.h"
38 
39 class RDocumentInterface;
40 
41 
42 
62 public:
63  RGraphicsScene(RDocumentInterface& documentInterface);
64  virtual ~RGraphicsScene();
65 
67  QList<RGraphicsView*> getGraphicsViews() const;
68 
69  virtual void clear();
70 
75  virtual bool exportDocumentSettings() { return true; }
76 
77  virtual void regenerate(bool undone = false);
78  virtual void regenerate(QSet<REntity::Id>& affectedEntities, bool updateViews);
79  virtual void updateSelectionStatus(QSet<REntity::Id>& affectedEntities, bool updateViews);
80  virtual void regenerateViews(bool force=false);
81  virtual void regenerateViews(QSet<RObject::Id>& affectedEntities);
82  virtual void repaintViews();
83  virtual void setCursor(const QCursor& cursor);
84 
85  void handleTerminateEvent(RTerminateEvent& event);
86 
87  void handleKeyPressEvent(QKeyEvent& event);
88  void handleKeyReleaseEvent(QKeyEvent& event);
89  void handleMouseMoveEvent(RMouseEvent& event);
90  void handleMousePressEvent(RMouseEvent& event);
91  void handleMouseReleaseEvent(RMouseEvent& event);
92  void handleMouseDoubleClickEvent(RMouseEvent& event);
93  void handleWheelEvent(RWheelEvent& event);
94  void handleTabletEvent(RTabletEvent& event);
95  void handleSwipeGestureEvent(QSwipeGesture& gesture);
96  void handlePanGestureEvent(QPanGesture& gesture);
97  void handlePinchGestureEvent(QPinchGesture& gesture);
98 
99  virtual void registerView(RGraphicsView* view, bool regen=true);
100  virtual void unregisterView(RGraphicsView* view);
101 
102  virtual void beginPreview();
103  virtual void endPreview();
104  virtual void clearPreview();
105  virtual bool isPreviewEmpty();
106 
107  virtual void addToPreview(REntity::Id entityId, const QList<RGraphicsSceneDrawable>& drawables) {
108  Q_UNUSED(entityId)
109  Q_UNUSED(drawables)
110  }
111  virtual void addToPreview(REntity::Id entityId, const RGraphicsSceneDrawable& drawable) {
112  Q_UNUSED(entityId)
113  Q_UNUSED(drawable)
114  }
115 
116  RRefPoint getHighlightedReferencePoint();
117 
122  virtual void highlightEntity(REntity& entity) = 0;
123 
128  virtual void highlightReferencePoint(const RRefPoint& position);
129 
130  virtual void exportCurrentEntity(bool preview = false, bool forceSelected = false);
131  virtual void unexportEntity(REntity::Id entityId);
132 
133  QMultiMap<REntity::Id, RRefPoint>& getReferencePoints() {
134  return referencePoints;
135  }
136 
137 // virtual bool isVisualExporter() const {
138 // return true;
139 // }
140 
141  virtual void dump() {
142  qDebug() << *this;
143  }
144 
148  friend QDebug operator<<(QDebug dbg, RGraphicsScene& gs);
149 
150 protected:
151  virtual void exportReferencePoints();
152 
153 protected:
155  QList<RGraphicsView*> views;
159 
165  QMultiMap<REntity::Id, RRefPoint> referencePoints;
166 
167 private:
168  bool deleting;
169 };
170 
171 Q_DECLARE_METATYPE(QList<RGraphicsScene*>)
173 
174 #endif
virtual bool exportDocumentSettings()
Override for performance reasons, we don't need settings to be exported for graphics scenes...
Definition: RGraphicsScene.h:75
A tablet event for a graphics scene.
Definition: RTabletEvent.h:43
virtual void addToPreview(REntity::Id entityId, const QList< RGraphicsSceneDrawable > &drawables)
Definition: RGraphicsScene.h:107
virtual void addToPreview(REntity::Id entityId, const RGraphicsSceneDrawable &drawable)
Definition: RGraphicsScene.h:111
Copyright (c) 2011-2017 by Andrew Mustun.
Definition: RGraphicsSceneDrawable.h:33
Represents a reference point of an entity.
Definition: RRefPoint.h:18
Abstract base class for all graphics scenes.
Definition: RGraphicsScene.h:61
bool exportToPreview
Definition: RGraphicsScene.h:156
#define QCADCORE_EXPORT
Definition: core_global.h:10
int Id
Definition: RObject.h:57
bool deleting
Definition: RGraphicsScene.h:168
RDocumentInterface & documentInterface
Definition: RGraphicsScene.h:154
QDebug operator<<(QDebug dbg, const RBox &b)
Stream operator for QDebug.
Definition: RBox.cpp:447
virtual void exportCurrentEntity(bool preview=false, bool forceSelected=false)
The default implementation calls the REntity::exportEntity() function of the entity.
Definition: RExporter.cpp:796
virtual void dump()
Definition: RGraphicsScene.h:141
Base class for all entity classes.
Definition: REntity.h:64
Q_DECLARE_METATYPE(RMath *)
A mouse event for a graphics scene.
Definition: RMouseEvent.h:42
virtual void unexportEntity(REntity::Id entityId)
This is called for entities for which an export was requested but which cannot be instantiated becaus...
Definition: RExporter.cpp:828
QMultiMap< REntity::Id, RRefPoint > referencePoints
Internal map of reference points for every selected entity in the scene.
Definition: RGraphicsScene.h:165
QMultiMap< REntity::Id, RRefPoint > & getReferencePoints()
Definition: RGraphicsScene.h:133
QList< RGraphicsView * > views
Definition: RGraphicsScene.h:155
Abstract base class for exporters.
Definition: RExporter.h:71
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 previewIsEmpty
Definition: RGraphicsScene.h:157
RRefPoint highlightedReferencePoint
Definition: RGraphicsScene.h:158
Copyright (c) 2011-2017 by Andrew Mustun.
Definition: RTerminateEvent.h:34
A mouse wheel event for a graphics scene.
Definition: RWheelEvent.h:41
Graphics view.
Definition: RGraphicsView.h:58