QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
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 <QtGlobal>
26
27#include "RExporter.h"
28#include "RRefPoint.h"
29
31class REntity;
33class RGraphicsView;
34class RMouseEvent;
35class RTabletEvent;
36class RTerminateEvent;
37class RWheelEvent;
38class QCursor;
39class QDebug;
40class QKeyEvent;
41class QPanGesture;
42class QPinchGesture;
43class QSwipeGesture;
44
45
65public:
66 RGraphicsScene(RDocumentInterface& documentInterface);
67 virtual ~RGraphicsScene();
68
70 QList<RGraphicsView*> getGraphicsViews() const;
71
72 virtual void clear();
73
78 virtual bool exportDocumentSettings() { return true; }
79
80 virtual void regenerate(bool undone = false, bool invisible = false);
81 virtual void regenerate(QSet<RObject::Id>& affectedEntities, bool updateViews);
82 virtual void updateSelectionStatus(QSet<RObject::Id>& affectedEntities, bool updateViews);
83 virtual void regenerateViews(bool force=false);
84 virtual void regenerateViews(QSet<RObject::Id>& affectedEntities);
85 virtual void repaintViews();
86 virtual void setCursor(const QCursor& cursor);
87
88 void handleTerminateEvent(RTerminateEvent& event);
89
90 void handleKeyPressEvent(QKeyEvent& event);
91 void handleKeyReleaseEvent(QKeyEvent& event);
92 void handleMouseMoveEvent(RMouseEvent& event);
93 void handleMousePressEvent(RMouseEvent& event);
94 void handleMouseReleaseEvent(RMouseEvent& event);
95 void handleMouseDoubleClickEvent(RMouseEvent& event);
96 void handleWheelEvent(RWheelEvent& event);
97 void handleTabletEvent(RTabletEvent& event);
98 void handleSwipeGestureEvent(QSwipeGesture& gesture);
99 void handlePanGestureEvent(QPanGesture& gesture);
100 void handlePinchGestureEvent(QPinchGesture& gesture);
101
102 virtual void registerView(RGraphicsView* view, bool regen=true);
103 virtual void unregisterView(RGraphicsView* view);
104
105 virtual void beginPreview();
106 virtual void endPreview();
107 virtual void clearPreview();
108 virtual bool isPreviewEmpty();
109
110 virtual void addToPreview(RObject::Id entityId, QList<RGraphicsSceneDrawable>& drawables) {
111 Q_UNUSED(entityId)
112 Q_UNUSED(drawables)
113 }
114 virtual void addToPreview(RObject::Id entityId, RGraphicsSceneDrawable& drawable) {
115 Q_UNUSED(entityId)
116 // MSVC:
117 //Q_UNUSED(drawable)
118 }
119 virtual void addPathToPreview(RObject::Id entityId, RPainterPath& pp) {
120 Q_UNUSED(entityId)
121 Q_UNUSED(pp)
122 }
123
125 colorMode = false;
126 }
128 colorMode = true;
129 }
130 bool getNoColorMode() const {
131 return !colorMode;
132 }
133
134 RRefPoint getHighlightedReferencePoint();
135
140 virtual void highlightEntity(REntity& entity) = 0;
141
142 virtual void highlightReferencePoint(const RRefPoint& position);
143
144 virtual void selectReferencePoints(const RBox& box, bool add);
145
146 virtual void exportCurrentEntity(bool preview = false, bool forceSelected = false);
147 virtual void unexportEntity(RObject::Id entityId);
148
149 int countReferencePoints() const;
150
155 return referencePoints;
156 }
157
158 bool hasSelectedReferencePoints() const;
159
160// virtual bool isVisualExporter() const {
161// return true;
162// }
163
164 virtual void dump() {
165 qDebug() << *this;
166 }
167
171 friend QDebug operator<<(QDebug dbg, RGraphicsScene& gs);
172
173protected:
174 virtual void exportReferencePoints();
175
176protected:
178 QList<RGraphicsView*> views;
180 // enable / disable color mode:
184
190
191private:
193};
194
195Q_DECLARE_METATYPE(QList<RGraphicsScene*>)
197
198#endif
QDebug operator<<(QDebug dbg, const RBox &b)
Stream operator for QDebug.
Definition RBox.cpp:640
Q_DECLARE_METATYPE(RMath *)
Definition RDebug.h:38
Represents a box e.g.
Definition RBox.h:46
Interface for interaction between a graphics document and a user.
Definition RDocumentInterface.h:97
Base class for all entity classes.
Definition REntity.h:63
Abstract base class for exporters.
Definition RExporter.h:78
virtual void unexportEntity(RObject::Id entityId)
This is called for entities for which an export was requested but which cannot be instantiated becaus...
Definition RExporter.cpp:916
virtual void exportCurrentEntity(bool preview=false, bool forceSelected=false)
The default implementation calls the REntity::exportEntity() function of the entity.
Definition RExporter.cpp:881
Definition RGraphicsSceneDrawable.h:37
Abstract base class for all graphics scenes.
Definition RGraphicsScene.h:64
QMap< RObject::Id, QList< RRefPoint > > referencePoints
Internal map of reference points for every selected entity in the scene.
Definition RGraphicsScene.h:189
RDocumentInterface & documentInterface
Definition RGraphicsScene.h:177
virtual void regenerateViews(QSet< RObject::Id > &affectedEntities)
virtual void addPathToPreview(RObject::Id entityId, RPainterPath &pp)
Definition RGraphicsScene.h:119
bool getNoColorMode() const
Definition RGraphicsScene.h:130
RRefPoint highlightedReferencePoint
Definition RGraphicsScene.h:183
virtual void addToPreview(RObject::Id entityId, QList< RGraphicsSceneDrawable > &drawables)
Definition RGraphicsScene.h:110
QMap< RObject::Id, QList< RRefPoint > > & getReferencePoints()
Definition RGraphicsScene.h:154
virtual void highlightEntity(REntity &entity)=0
Highlights the given entity.
bool colorMode
Definition RGraphicsScene.h:181
bool previewIsEmpty
Definition RGraphicsScene.h:182
void beginNoColorMode()
Definition RGraphicsScene.h:124
virtual bool exportDocumentSettings()
Override for performance reasons, we don't need settings to be exported for graphics scenes.
Definition RGraphicsScene.h:78
QList< RGraphicsView * > views
Definition RGraphicsScene.h:178
virtual void dump()
Definition RGraphicsScene.h:164
virtual void addToPreview(RObject::Id entityId, RGraphicsSceneDrawable &drawable)
Definition RGraphicsScene.h:114
virtual void regenerate(QSet< RObject::Id > &affectedEntities, bool updateViews)
void endNoColorMode()
Definition RGraphicsScene.h:127
bool deleting
Definition RGraphicsScene.h:192
bool exportToPreview
Definition RGraphicsScene.h:179
Graphics view.
Definition RGraphicsView.h:67
A mouse event for a graphics scene.
Definition RMouseEvent.h:42
int Id
Definition RObject.h:69
Extended painter path with a z-level and a pen.
Definition RPainterPath.h:48
Represents a reference point of an entity.
Definition RRefPoint.h:18
A tablet event for a graphics scene.
Definition RTabletEvent.h:43
Copyright (c) 2011-2018 by Andrew Mustun.
Definition RTerminateEvent.h:34
A mouse wheel event for a graphics scene.
Definition RWheelEvent.h:41
#define QCADCORE_EXPORT
Definition core_global.h:10
void getDocumentInterface()
Returns the current RDocumentInterface or undefined.
Definition simple.js:69