QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
RGraphicsSceneQt.h
Go to the documentation of this file.
1
20#ifndef RGRAPHICSSCENEQT_H
21#define RGRAPHICSSCENEQT_H
22
23#include "gui_global.h"
24
25#include <QList>
26#include <QMultiMap>
27
28#include "RGraphicsScene.h"
30#include "RPainterPath.h"
31
32class RArc;
33class RBox;
35class REntity;
36class RGraphicsView;
39class RImageData;
40class RLine;
42class RObject;
43class RPoint;
44class RPolyline;
45class RRay;
46class RSpline;
47class RTextBasedData;
48class RTransform;
49class RTriangle;
50class RVector;
51class RXLine;
52
53#ifndef RDEFAULT_MIN1
54#define RDEFAULT_MIN1 -1
55#endif
56
69public:
70 RGraphicsSceneQt(RDocumentInterface& documentInterface);
71 virtual ~RGraphicsSceneQt();
72
74
75 virtual void clear();
76
77 virtual void updateSelectionStatus(QSet<RObject::Id>& affectedEntities, bool updateViews);
78
79 virtual void clearPreview();
80
81 virtual void exportEntities(bool allBlocks = true, bool undone = false, bool invisible = false);
82 void exportEntitiesThread(int threadId, QList<RObject::Id>& list, int start, int end);
83 void exportEntityThread(int threadId, RObject::Id id);
84
85 bool beginPath();
86 void endPath();
87
88 void transformAndApplyPatternPath(RPainterPath& path) const;
89
90 virtual void unexportEntity(RObject::Id entityId);
91
92 virtual void exportPoint(const RPoint& point);
93 virtual double exportLine(const RLine& line, double offset = RNANDOUBLE);
94 virtual void exportArc(const RArc& arc, double offset = RNANDOUBLE);
95 virtual void exportThickPolyline(const RPolyline& polyline);
96 virtual void exportPolyline(const RPolyline& polyline, bool polylineGen = true, double offset = RNANDOUBLE);
97 void exportPolylineFill(const RPolyline& polyline);
98 virtual void exportSpline(const RSpline& spline, double offset = RNANDOUBLE);
99
100 virtual void exportArcSegment(const RArc& arc, bool allowForZeroLength = false);
101 virtual void exportLineSegment(const RLine& line, double angle = RNANDOUBLE);
102 virtual void exportXLine(const RXLine& xLine);
103
104 virtual void exportRay(const RRay& ray);
105 virtual void exportTriangle(const RTriangle& triangle);
106 virtual void exportRectangle(const RVector& p1, const RVector& p2);
107
108 virtual void exportPainterPaths(const QList<RPainterPath>& paths, double z = 0.0);
109 virtual void exportImage(const RImageData& image, bool forceSelected = false);
110 virtual QList<RPainterPath> exportText(const RTextBasedData& text, bool forceSelected = false);
111 virtual void exportClipRectangle(const RBox& clipRectangles, bool forceSelected = false);
112 virtual void clearClipRectangles();
113 virtual void exportTransform(const RTransform& t);
114 virtual void exportEndTransform();
115
116 virtual double getLineTypePatternScale(const RLinetypePattern& p) const;
117
118 virtual void highlightEntity(REntity& entity);
119
120 void deleteDrawables();
121
125 QList<RGraphicsSceneDrawable>* getDrawables(RObject::Id entityId);
126
130 QList<RGraphicsSceneDrawable> getDrawablesList(RObject::Id entityId);
131
132 bool hasPreview() const;
133 QList<RObject::Id> getPreviewEntityIds();
134
138 QList<RGraphicsSceneDrawable>* getPreviewDrawables(RObject::Id entityId);
139
140 virtual void addToPreview(RObject::Id entityId, QList<RGraphicsSceneDrawable>& drawables);
141 virtual void addToPreview(RObject::Id entityId, RGraphicsSceneDrawable& drawable);
142
143 virtual void addPathToPreview(RObject::Id entityId, RPainterPath& pp) {
145 addToPreview(entityId, drw);
146 }
147
148 void addTextToPreview(const RTextBasedData& text);
149
150 bool hasClipRectangleFor(RObject::Id entityId, bool preview = false) const;
151 RBox getClipRectangle(RObject::Id entityId, bool preview = false) const;
152
153 void addDrawable(RObject::Id entityId, RGraphicsSceneDrawable& drawable, bool draft = false, bool preview = false);
154
155 virtual void startEntity(bool topLevelEntity);
156
157 virtual bool getScreenBasedLinetypes() const {
158 if (screenBasedLinetypesOverride) {
159 return true;
160 }
162 }
163
164 virtual void dump() {
165 qDebug() << *this;
166 }
167
171 friend QDebug operator<<(QDebug dbg, RGraphicsSceneQt& gs);
172
173private:
175
178
181
184
185 QStack<QTransform> transformStack;
186
187
188 QList<RGraphicsSceneQt*> threadScenes;
189};
190
192
193#endif
#define RNANDOUBLE
Definition RMath.h:74
Q_DECLARE_METATYPE(RMath *)
Definition RDebug.h:38
Low-level mathematical representation of an arc.
Definition RArc.h:42
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
virtual void exportClipRectangle(const RBox &clipRectangle, bool forceSelected=false)
Definition RExporter.cpp:1672
virtual void exportRay(const RRay &ray)=0
Exports an infinite ray.
virtual void exportPainterPaths(const QList< RPainterPath > &paths, double z=0.0)
Definition RExporter.cpp:1640
virtual void exportArc(const RArc &arc, double offset=RNANDOUBLE)
Definition RExporter.cpp:1177
virtual void exportRectangle(const RVector &p1, const RVector &p2)
Exports a rectangle with the current attributes.
Definition RExporter.cpp:950
virtual void exportImage(const RImageData &image, bool forceSelected=false)
Definition RExporter.cpp:1658
virtual void exportTriangle(const RTriangle &triangle)=0
Exports a triangle with the current attributes.
virtual void exportEntities(bool allBlocks=true, bool undone=false, bool invisible=false)
Definition RExporter.cpp:560
virtual void exportPolyline(const RPolyline &polyline, bool polylineGen=true, double offset=RNANDOUBLE)
Definition RExporter.cpp:1476
virtual void exportEndTransform()
Definition RExporter.cpp:1685
virtual void exportPoint(const RPoint &point)=0
Exports a point with the current attributes.
virtual void clearClipRectangles()
Definition RExporter.cpp:1677
virtual void exportXLine(const RXLine &xLine)=0
Exports an infinite line.
virtual QList< RPainterPath > exportText(const RTextBasedData &text, bool forceSelected=false)
Definition RExporter.cpp:1664
virtual void exportArcSegment(const RArc &arc, bool allowForZeroLength=false)
Definition RExporter.cpp:1319
virtual void exportSpline(const RSpline &spline, double offset=RNANDOUBLE)
Definition RExporter.cpp:1523
virtual void startEntity(bool)
Definition RExporter.h:184
virtual void exportLineSegment(const RLine &line, double angle=RNANDOUBLE)=0
Exports a line segment (a line without pattern).
virtual double exportLine(const RLine &line, double offset=RNANDOUBLE)
Exports a line with the current attributes.
Definition RExporter.cpp:988
virtual void exportThickPolyline(const RPolyline &polyline)
Definition RExporter.cpp:1688
virtual double getLineTypePatternScale(const RLinetypePattern &p) const
Definition RExporter.cpp:1694
virtual void exportTransform(const RTransform &t)
Definition RExporter.cpp:1680
virtual bool getScreenBasedLinetypes() const
Definition RExporter.h:333
Definition RGraphicsSceneDrawable.h:37
Abstract base class for all graphics scenes.
Definition RGraphicsScene.h:64
virtual void clear()
Clears (resets) the scene contents.
Definition RGraphicsScene.cpp:88
friend QDebug operator<<(QDebug dbg, RGraphicsScene &gs)
Stream operator for QDebug.
Definition RGraphicsScene.cpp:438
virtual void addToPreview(RObject::Id entityId, QList< RGraphicsSceneDrawable > &drawables)
Definition RGraphicsScene.h:110
virtual void clearPreview()
Clears the preview.
Definition RGraphicsScene.cpp:131
virtual void highlightEntity(REntity &entity)=0
Highlights the given entity.
virtual void updateSelectionStatus(QSet< RObject::Id > &affectedEntities, bool updateViews)
Updates the selection status of the given entities.
Definition RGraphicsScene.cpp:171
virtual void unexportEntity(RObject::Id entityId)
This is called for entities for which an export was requested but which cannot be instantiated becaus...
Definition RGraphicsScene.cpp:418
Qt based 2d graphics scene.
Definition RGraphicsSceneQt.h:68
QMap< RObject::Id, RBox > previewClipRectangles
Definition RGraphicsSceneQt.h:180
RPainterPath currentPainterPath
Definition RGraphicsSceneQt.h:174
QList< RGraphicsSceneQt * > threadScenes
Definition RGraphicsSceneQt.h:188
QMap< RObject::Id, QList< RGraphicsSceneDrawable > > previewDrawables
Definition RGraphicsSceneQt.h:179
QMap< RObject::Id, RBox > clipRectangles
Definition RGraphicsSceneQt.h:177
virtual void addPathToPreview(RObject::Id entityId, RPainterPath &pp)
Definition RGraphicsSceneQt.h:143
QStack< QTransform > transformStack
Definition RGraphicsSceneQt.h:185
bool screenBasedLinetypesOverride
Definition RGraphicsSceneQt.h:183
bool decorating
Definition RGraphicsSceneQt.h:182
virtual bool getScreenBasedLinetypes() const
Definition RGraphicsSceneQt.h:157
QMap< RObject::Id, QList< RGraphicsSceneDrawable > > drawables
Definition RGraphicsSceneQt.h:176
virtual void dump()
Definition RGraphicsSceneQt.h:164
Graphics view.
Definition RGraphicsView.h:67
QImage based 2d graphics view.
Definition RGraphicsViewImage.h:69
Stores and manages all data that defines the geometry and appearance of a raster image entity.
Definition RImageData.h:41
Low-level mathematical representation of a line.
Definition RLine.h:41
Copyright (c) 2011-2018 by Andrew Mustun.
Definition RLinetypePattern.h:42
Abstract base class for all objects.
Definition RObject.h:64
int Id
Definition RObject.h:69
Extended painter path with a z-level and a pen.
Definition RPainterPath.h:48
Low-level mathematical representation of a point.
Definition RPoint.h:40
Low-level mathematical representation of an open polyline or closed polyline (= polygon).
Definition RPolyline.h:50
Low-level mathematical representation of a ray.
Definition RRay.h:41
Low-level mathematical representation of a spline.
Definition RSpline.h:59
Stores and manages all data that defines the geometry and appearance of a text based entity (text,...
Definition RTextBasedData.h:68
Copyright (c) 2011-2020 by Andrew Mustun.
Definition RTransform.h:37
Low-level mathematical representation of a triangle.
Definition RTriangle.h:49
Represents a 3d vector (x/y/z).
Definition RVector.h:47
Low-level mathematical representation of an infinite line.
Definition RXLine.h:42
void getGraphicsView()
Returns the current or last active RGraphicsView.
Definition simple.js:32
#define QCADGUI_EXPORT
Definition gui_global.h:10