QCAD
Open Source 2D CAD
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 <QPen>
26 #include <QList>
27 #include <QMultiMap>
28 
29 #include "RArc.h"
30 #include "RCircle.h"
31 #include "RDocumentInterface.h"
32 #include "REllipse.h"
33 #include "RGraphicsScene.h"
34 #include "RGraphicsSceneDrawable.h"
35 #include "RImageData.h"
36 #include "RLine.h"
37 #include "RPainterPath.h"
38 #include "RPainterPathSource.h"
39 #include "RPoint.h"
40 #include "RPolyline.h"
41 #include "RRay.h"
42 #include "RSpline.h"
43 #include "RXLine.h"
44 
45 class RGraphicsViewImage;
46 
47 #ifndef RDEFAULT_MIN1
48 #define RDEFAULT_MIN1 -1
49 #endif
50 
63 public:
64  RGraphicsSceneQt(RDocumentInterface& documentInterface);
65  virtual ~RGraphicsSceneQt();
66 
68 
69  virtual void clear();
70 
71  virtual void updateSelectionStatus(QSet<REntity::Id>& affectedEntities, bool updateViews);
72 
73  virtual void clearPreview();
74 
75  bool beginPath();
76  void endPath();
77 
78  virtual void unexportEntity(REntity::Id entityId);
79 
80  virtual void exportPoint(const RPoint& point);
81  virtual double exportLine(const RLine& line, double offset = RNANDOUBLE);
82  virtual void exportArc(const RArc& arc, double offset = RNANDOUBLE);
83  virtual void exportThickPolyline(const RPolyline& polyline);
84  virtual void exportPolyline(const RPolyline& polyline, bool polylineGen = true, double offset = RNANDOUBLE);
85  void exportPolylineFill(const RPolyline& polyline);
86  virtual void exportSpline(const RSpline& spline, double offset = RNANDOUBLE);
87 
88  virtual void exportArcSegment(const RArc& arc, bool allowForZeroLength = false);
89  virtual void exportLineSegment(const RLine& line, double angle = RNANDOUBLE);
90  virtual void exportXLine(const RXLine& xLine);
91  virtual void exportRay(const RRay& ray);
92  virtual void exportTriangle(const RTriangle& triangle);
93  virtual void exportRectangle(const RVector& p1, const RVector& p2);
94 
95  virtual void exportPainterPaths(const QList<RPainterPath>& paths);
96  virtual void exportImage(const RImageData& image, bool forceSelected = false);
97  virtual QList<RPainterPath> exportText(const RTextBasedData& text, bool forceSelected = false);
98  virtual void exportClipRectangle(const RBox& clipRectangles, bool forceSelected = false);
99 
100  virtual double getLineTypePatternScale(const RLinetypePattern& p) const;
101 
102  virtual void highlightEntity(REntity& entity);
103 
104  void deleteDrawables();
105  QList<RGraphicsSceneDrawable> getDrawables(REntity::Id entityId);
106 
107  bool hasPreview() const;
108  QList<REntity::Id> getPreviewEntityIds();
109  QList<RGraphicsSceneDrawable> getPreviewDrawables(REntity::Id entityId);
110  virtual void addToPreview(REntity::Id entityId, const QList<RGraphicsSceneDrawable>& drawables);
111  virtual void addToPreview(REntity::Id entityId, const RGraphicsSceneDrawable& drawable);
112  void addTextToPreview(const RTextBasedData& text);
113 
114  bool hasClipRectangleFor(REntity::Id entityId);
115  RBox getClipRectangle(REntity::Id entityId);
116 
117  void addPath(REntity::Id entityId, const RGraphicsSceneDrawable& path, bool draft);
118 
119  virtual void startEntity(bool topLevelEntity);
120 
121  virtual void dump() {
122  qDebug() << *this;
123  }
124 
128  friend QDebug operator<<(QDebug dbg, RGraphicsSceneQt& gs);
129 
130 private:
132 
133  QMap<REntity::Id, QList<RGraphicsSceneDrawable> > drawables;
134  QMap<REntity::Id, RBox> clipRectangles;
135 
136  QMap<REntity::Id, QList<RGraphicsSceneDrawable> > previewDrawables;
137  QMap<REntity::Id, RBox> previewClipRectangles;
138 
140 };
141 
143 
144 #endif
virtual void exportArc(const RArc &arc, double offset=RNANDOUBLE)
Definition: RExporter.cpp:1067
virtual void exportPainterPaths(const QList< RPainterPath > &paths)
Definition: RExporter.cpp:1533
Represents a box e.g.
Definition: RBox.h:43
virtual void exportArcSegment(const RArc &arc, bool allowForZeroLength=false)
Definition: RExporter.cpp:1205
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
virtual void addToPreview(REntity::Id entityId, const QList< RGraphicsSceneDrawable > &drawables)
Definition: RGraphicsScene.h:107
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RSpline.h:56
virtual void exportImage(const RImageData &image, bool forceSelected=false)
Definition: RExporter.cpp:1549
virtual QList< RPainterPath > exportText(const RTextBasedData &text, bool forceSelected=false)
Definition: RExporter.cpp:1554
virtual void exportSpline(const RSpline &spline, double offset=RNANDOUBLE)
Definition: RExporter.cpp:1411
virtual void exportXLine(const RXLine &xLine)=0
Exports an infinite line.
#define QCADGUI_EXPORT
Definition: gui_global.h:10
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RGraphicsSceneDrawable.h:33
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RImageData.h:41
virtual void exportLineSegment(const RLine &line, double angle=RNANDOUBLE)=0
Exports a line segment (a line without pattern).
Low-level mathematical representation of a triangle.
Definition: RTriangle.h:46
Abstract base class for all graphics scenes.
Definition: RGraphicsScene.h:61
virtual void startEntity(bool)
Definition: RExporter.h:159
Low-level mathematical representation of an arc.
Definition: RArc.h:41
virtual void clear()
Clears (resets) the scene contents.
Definition: RGraphicsScene.cpp:87
int Id
Definition: RObject.h:53
Qt based 2d graphics scene.
Definition: RGraphicsSceneQt.h:62
virtual void exportTriangle(const RTriangle &triangle)=0
Exports a triangle with the current attributes.
virtual void exportClipRectangle(const RBox &clipRectangle, bool forceSelected=false)
Definition: RExporter.cpp:1562
virtual void unexportEntity(REntity::Id entityId)
This is called for entities for which an export was requested but which cannot be instantiated becaus...
Definition: RGraphicsScene.cpp:333
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RLinetypePattern.h:45
virtual void exportPoint(const RPoint &point)=0
Exports a point with the current attributes.
virtual void updateSelectionStatus(QSet< REntity::Id > &affectedEntities, bool updateViews)
Updates the selection status of the given entities.
Definition: RGraphicsScene.cpp:170
#define RNANDOUBLE
Definition: RMath.h:71
Stores and manages all data that defines the geometry and appearance of a text based entity (text...
Definition: RTextBasedData.h:43
virtual void exportThickPolyline(const RPolyline &polyline)
Definition: RExporter.h:233
Base class for all entity classes.
Definition: REntity.h:64
Q_DECLARE_METATYPE(RMath *)
virtual double getLineTypePatternScale(const RLinetypePattern &p) const
Definition: RExporter.cpp:1567
virtual void exportPolyline(const RPolyline &polyline, bool polylineGen=true, double offset=RNANDOUBLE)
Definition: RExporter.cpp:1360
Extended painter path with a z-level and a pen.
Definition: RPainterPath.h:46
friend QDebug operator<<(QDebug dbg, RGraphicsScene &gs)
Stream operator for QDebug.
Definition: RGraphicsScene.cpp:349
QMap< REntity::Id, RBox > previewClipRectangles
Definition: RGraphicsSceneQt.h:137
bool decorating
Definition: RGraphicsSceneQt.h:139
Low-level mathematical representation of an infinite line.
Definition: RXLine.h:42
virtual void exportRay(const RRay &ray)=0
Exports an infinite ray.
Low-level mathematical representation of a line.
Definition: RLine.h:42
virtual double exportLine(const RLine &line, double offset=RNANDOUBLE)
Exports a line with the current attributes.
Definition: RExporter.cpp:881
RPainterPath currentPainterPath
Definition: RGraphicsSceneQt.h:131
QMap< REntity::Id, RBox > clipRectangles
Definition: RGraphicsSceneQt.h:134
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RPoint.h:38
QMap< REntity::Id, QList< RGraphicsSceneDrawable > > previewDrawables
Definition: RGraphicsSceneQt.h:136
virtual void dump()
Definition: RGraphicsSceneQt.h:121
virtual void clearPreview()
Clears the preview.
Definition: RGraphicsScene.cpp:130
Interface for interaction between a graphics document and a user.
Definition: RDocumentInterface.h:82
QMap< REntity::Id, QList< RGraphicsSceneDrawable > > drawables
Definition: RGraphicsSceneQt.h:133
Low-level mathematical representation of an open polyline or closed polyline (= polygon).
Definition: RPolyline.h:50
void getGraphicsView()
Definition: simple.js:25
Low-level mathematical representation of a ray.
Definition: RRay.h:42
virtual void exportRectangle(const RVector &p1, const RVector &p2)
Exports a rectangle with the current attributes.
Definition: RExporter.cpp:846
QImage based 2d graphics view.
Definition: RGraphicsViewImage.h:51
virtual void highlightEntity(REntity &entity)=0
Highlights the given entity.