Open Source 2D CAD
Go to the documentation of this file.
23 #include "gui_global.h"
25 #include <QPen>
26 #include <QList>
27 #include <QMultiMap>
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"
45 class RGraphicsViewImage;
47 #ifndef RDEFAULT_MIN1
48 #define RDEFAULT_MIN1 -1
49 #endif
63 public:
64  RGraphicsSceneQt(RDocumentInterface& documentInterface);
65  virtual ~RGraphicsSceneQt();
69  virtual void clear();
71  virtual void updateSelectionStatus(QSet<REntity::Id>& affectedEntities, bool updateViews);
73  virtual void clearPreview();
75  bool beginPath();
76  void endPath();
78  virtual void unexportEntity(REntity::Id entityId);
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);
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);
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);
100  virtual double getLineTypePatternScale(const RLinetypePattern& p) const;
102  virtual void highlightEntity(REntity& entity);
104  void deleteDrawables();
105  QList<RGraphicsSceneDrawable> getDrawables(REntity::Id entityId);
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);
114  bool hasClipRectangleFor(REntity::Id entityId, bool preview = false);
115  RBox getClipRectangle(REntity::Id entityId, bool preview = false);
117  void addPath(REntity::Id entityId, const RGraphicsSceneDrawable& path, bool draft);
119  virtual void startEntity(bool topLevelEntity);
121  virtual bool getScreenBasedLinetypes() const {
122  if (screenBasedLinetypesOverride) {
123  return true;
124  }
126  }
128  virtual void dump() {
129  qDebug() << *this;
130  }
135  friend QDebug operator<<(QDebug dbg, RGraphicsSceneQt& gs);
137 private:
140  QMap<REntity::Id, QList<RGraphicsSceneDrawable> > drawables;
141  QMap<REntity::Id, RBox> clipRectangles;
143  QMap<REntity::Id, QList<RGraphicsSceneDrawable> > previewDrawables;
144  QMap<REntity::Id, RBox> previewClipRectangles;
148 };
152 #endif
virtual void exportArc(const RArc &arc, double offset=RNANDOUBLE)
Definition: RExporter.cpp:1067
virtual void exportPainterPaths(const QList< RPainterPath > &paths)
Definition: RExporter.cpp:1537
Represents a box e.g.
Definition: RBox.h:43
virtual void exportArcSegment(const RArc &arc, bool allowForZeroLength=false)
Definition: RExporter.cpp:1209
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:55
virtual void exportImage(const RImageData &image, bool forceSelected=false)
Definition: RExporter.cpp:1553
virtual QList< RPainterPath > exportText(const RTextBasedData &text, bool forceSelected=false)
Definition: RExporter.cpp:1558
virtual void exportSpline(const RSpline &spline, double offset=RNANDOUBLE)
Definition: RExporter.cpp:1415
virtual void exportXLine(const RXLine &xLine)=0
Exports an infinite line.
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:40
virtual void clear()
Clears (resets) the scene contents.
Definition: RGraphicsScene.cpp:87
int Id
Definition: RObject.h:57
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:1566
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
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
virtual double getLineTypePatternScale(const RLinetypePattern &p) const
Definition: RExporter.cpp:1571
virtual void exportPolyline(const RPolyline &polyline, bool polylineGen=true, double offset=RNANDOUBLE)
Definition: RExporter.cpp:1364
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:144
bool decorating
Definition: RGraphicsSceneQt.h:146
Low-level mathematical representation of an infinite line.
Definition: RXLine.h:42
virtual bool getScreenBasedLinetypes() const
Definition: RGraphicsSceneQt.h:121
virtual void exportRay(const RRay &ray)=0
Exports an infinite ray.
Low-level mathematical representation of a line.
Definition: RLine.h:41
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:138
QMap< REntity::Id, RBox > clipRectangles
Definition: RGraphicsSceneQt.h:141
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RPoint.h:38
QMap< REntity::Id, QList< RGraphicsSceneDrawable > > previewDrawables
Definition: RGraphicsSceneQt.h:143
virtual void dump()
Definition: RGraphicsSceneQt.h:128
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:140
Low-level mathematical representation of an open polyline or closed polyline (= polygon).
Definition: RPolyline.h:49
void getGraphicsView()
Definition: simple.js:54
bool screenBasedLinetypesOverride
Definition: RGraphicsSceneQt.h:147
Low-level mathematical representation of a ray.
Definition: RRay.h:42
virtual bool getScreenBasedLinetypes() const
Definition: RExporter.h:301
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.