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 "RImageData.h"
35 #include "RLine.h"
36 #include "RPainterPath.h"
37 #include "RPainterPathSource.h"
38 #include "RPoint.h"
39 #include "RPolyline.h"
40 #include "RRay.h"
41 #include "RXLine.h"
42 
43 class RGraphicsViewImage;
44 
57 public:
58  RGraphicsSceneQt(RDocumentInterface& documentInterface);
59  virtual ~RGraphicsSceneQt();
60 
61  RGraphicsViewImage* getGraphicsView() const;
62  //RGraphicsViewImage* const getGraphicsView() const;
63 
64  virtual void clear();
65 
66  virtual void updateSelectionStatus(QSet<REntity::Id>& affectedEntities, bool updateViews);
67 
68  virtual void clearPreview();
69 
70  bool beginPath();
71  void endPath();
72 
73  virtual void unexportEntity(REntity::Id entityId);
74 
75  virtual void exportPoint(const RPoint& point);
76  virtual double exportLine(const RLine& line, double offset = RNANDOUBLE);
77  virtual void exportArc(const RArc& arc, double offset = RNANDOUBLE);
78  virtual void exportEllipse(const REllipse& ellipse, double offset = RNANDOUBLE);
79  virtual void exportPolyline(const RPolyline& polyline, bool polylineGen = true, double offset = RNANDOUBLE);
80  void exportPolylineFill(const RPolyline& polyline);
81  virtual void exportSpline(const RSpline& spline, double offset = RNANDOUBLE);
82 
83  virtual void exportArcSegment(const RArc& arc, bool allowForZeroLength = false);
84  virtual void exportLineSegment(const RLine& line, double angle = RNANDOUBLE);
85  virtual void exportXLine(const RXLine& xLine);
86  virtual void exportRay(const RRay& ray);
87  virtual void exportTriangle(const RTriangle& triangle);
88  virtual void exportRectangle(const RVector& p1, const RVector& p2);
89 
90  //virtual void exportPainterPathSource(const RPainterPathSource& pathSource);
91  virtual void exportPainterPaths(const QList<RPainterPath>& paths);
92  virtual void exportImage(const RImageData& image);
93 
94  virtual double getLineTypePatternScale(const RLinetypePattern& p) const;
95 
96  virtual void highlightEntity(REntity& entity);
97 
98  void deletePainterPaths();
99  QList<RPainterPath> getPainterPaths(REntity::Id entityId);
100  QList<RPainterPath> getPreviewPainterPaths();
101  bool hasImageFor(REntity::Id entityId);
102  RImageData getImage(REntity::Id entityId);
103 
104  void addPath(REntity::Id entityId, const RPainterPath& path, bool draft);
105 
106  void addToPreview(const QList<RPainterPath>& painterPaths);
107  void addToPreview(const RPainterPath& painterPath);
108 
109  virtual void startEntity(bool topLevelEntity);
110 
111  virtual void dump() {
112  qDebug() << *this;
113  }
114 
118  friend QDebug operator<<(QDebug dbg, RGraphicsSceneQt& gs);
119 
120 private:
122  QMap<REntity::Id, QList<RPainterPath> > painterPaths;
123 
124  QMap<REntity::Id, RImageData> images;
125 
126  QList<RPainterPath> previewPainterPaths;
127 };
128 
130 
131 #endif
virtual void exportArc(const RArc &arc, double offset=RNANDOUBLE)
Definition: RExporter.cpp:940
virtual void exportPainterPaths(const QList< RPainterPath > &paths)
Definition: RExporter.cpp:1392
virtual void exportArcSegment(const RArc &arc, bool allowForZeroLength=false)
Definition: RExporter.cpp:1078
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
Low-level mathematical representation of a spline.
Definition: RSpline.h:54
virtual void exportSpline(const RSpline &spline, double offset=RNANDOUBLE)
Definition: RExporter.cpp:1270
virtual void exportXLine(const RXLine &xLine)=0
Exports an infinite line.
#define QCADGUI_EXPORT
Definition: gui_global.h:10
Copyright (c) 2011-2015 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
QMap< REntity::Id, RImageData > images
Definition: RGraphicsSceneQt.h:124
Abstract base class for all graphics scenes.
Definition: RGraphicsScene.h:60
virtual void startEntity(bool)
Definition: RExporter.h:140
Low-level mathematical representation of an arc.
Definition: RArc.h:41
virtual void clear()
Clears (resets) the scene contents.
Definition: RGraphicsScene.cpp:79
int Id
Definition: RObject.h:53
Qt based 2d graphics scene.
Definition: RGraphicsSceneQt.h:56
virtual void exportTriangle(const RTriangle &triangle)=0
Exports a triangle with the current attributes.
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:308
Copyright (c) 2011-2015 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:162
#define RNANDOUBLE
Definition: RMath.h:55
Base class for all entity classes.
Definition: REntity.h:64
Q_DECLARE_METATYPE(RMath *)
virtual void exportImage(const RImageData &image)
Definition: RExporter.cpp:1408
Low-level mathematical representation of an ellipse or ellipse arc.
Definition: REllipse.h:41
virtual double getLineTypePatternScale(const RLinetypePattern &p) const
Definition: RExporter.cpp:1412
virtual void exportPolyline(const RPolyline &polyline, bool polylineGen=true, double offset=RNANDOUBLE)
Definition: RExporter.cpp:1225
Extended painter path with a z-level and a pen.
Definition: RPainterPath.h:45
friend QDebug operator<<(QDebug dbg, RGraphicsScene &gs)
Stream operator for QDebug.
Definition: RGraphicsScene.cpp:324
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:758
RPainterPath currentPainterPath
Definition: RGraphicsSceneQt.h:121
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RPoint.h:38
virtual void exportEllipse(const REllipse &ellipse, double offset=RNANDOUBLE)
Exports an ellipse with the current attributes.
Definition: RExporter.cpp:1165
QList< RPainterPath > previewPainterPaths
Definition: RGraphicsSceneQt.h:126
virtual void dump()
Definition: RGraphicsSceneQt.h:111
virtual void clearPreview()
Clears the preview.
Definition: RGraphicsScene.cpp:122
Interface for interaction between a graphics document and a user.
Definition: RDocumentInterface.h:82
Low-level mathematical representation of an open polyline or closed polyline (= polygon).
Definition: RPolyline.h:49
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:723
QImage based 2d graphics view.
Definition: RGraphicsViewImage.h:51
virtual void highlightEntity(REntity &entity)=0
Highlights the given entity.
QMap< REntity::Id, QList< RPainterPath > > painterPaths
Definition: RGraphicsSceneQt.h:122