QCAD
Open Source 2D CAD
RExporter.h
Go to the documentation of this file.
1 
20 #ifndef REXPORTER_H
21 #define REXPORTER_H
22 
23 #include "core_global.h"
24 
25 #include <QBrush>
26 #include <QColor>
27 #include <QPen>
28 #include <QStack>
29 #include <QTextLayout>
30 
31 #include "REntity.h"
32 #include "RImageData.h"
33 #include "RMatrix.h"
34 #include "RPainterPath.h"
35 #include "RView.h"
36 
37 class RArc;
38 class RCircle;
39 class RDocument;
40 class REllipse;
41 class RLine;
42 class RLinetype;
43 class RLinetypePattern;
44 class RMessageHandler;
45 class RPainterPathSource;
46 class RPoint;
47 class RPolyline;
48 class RProgressHandler;
49 class RRay;
50 class RSpline;
51 class RTriangle;
52 class RVector;
53 class RXLine;
54 
64 
65 public:
66  RExporter();
67  RExporter(RDocument& document, RMessageHandler* messageHandler = NULL, RProgressHandler* progressHandler = NULL);
68  virtual ~RExporter();
69 
70  QString getErrorMessage() const;
71 
72  void setLayerSource(RDocument* ls);
73  void setBlockSource(RDocument* bs);
74 
78  RDocument& getDocument() const;
79 
80  void setProjectionRenderingHint(RS::ProjectionRenderingHint p);
81  RS::ProjectionRenderingHint getProjectionRenderingHint();
82  virtual void setPen(const QPen& pen);
83  virtual QPen getPen(const RPainterPath& path);
84  virtual QPen getPen();
85  virtual void setBrush(const QBrush& brush);
86  virtual QBrush getBrush(const RPainterPath& path);
87  virtual QBrush getBrush();
88 
89  virtual void setEntityAttributes(bool forceSelected=false);
90 
91  virtual void setStyle(Qt::PenStyle penStyle);
92  virtual void setBrushStyle(Qt::BrushStyle brushStyle);
93  virtual void setDashPattern(const QVector<qreal>& dashes);
94 
95  virtual void setColor(float r, float g, float b, float a = 1.0f);
96  virtual void setColor(const RColor& color);
97 
98  virtual void setLineweight(RLineweight::Lineweight weight);
99 
100  virtual void setLinetypeId(RLinetype::Id ltId);
101  virtual void setLinetypePattern(const RLinetypePattern& ltPattern);
102  virtual RLinetypePattern getLinetypePattern();
103 
104  virtual REntity* getBlockRefOrEntity();
105  virtual REntity* getEntity();
106 
110  virtual const REntity* getEntity() const;
111 
112  virtual bool isEntitySelected();
113 
114  virtual void startExport();
115  virtual void endExport();
116 
117  virtual bool exportDocument();
118  virtual bool exportDocumentSettings();
119  virtual void exportDocumentSetting(
120  const QString& /*key*/, const QVariant& /*value*/) {}
121 
122  virtual void exportLayers();
123  virtual void exportBlocks();
124  virtual void exportViews();
125  virtual void exportLinetypes();
126 
127  virtual void exportLayer(RLayer& /*layer*/) {}
128  virtual void exportLayer(RLayer::Id layerId);
129  virtual void exportBlock(RBlock& /*block*/) {}
130  virtual void exportBlock(RBlock::Id blockId);
131  virtual void exportView(RView& /*view*/) {}
132  virtual void exportView(RView::Id viewId);
133  virtual void exportLinetype(RLinetype& /*linetype*/) {}
134 
135  virtual void exportEntities(bool allBlocks = true, bool undone = false);
136  virtual void exportEntities(const RBox& box);
137  virtual void exportEntities(QSet<REntity::Id>& entityIds, bool allBlocks = true);
138  virtual void exportEntity(REntity& e, bool preview = false, bool allBlocks = true, bool forceSelected = false);
139  virtual void exportEntity(REntity::Id entityId, bool allBlocks = true, bool forceSelected = false);
140  virtual void startEntity(bool /*topLevelEntity*/) {}
141  virtual void endEntity() {}
142  virtual void exportCurrentEntity(bool preview = false, bool forceSelected = false);
143  virtual void unexportEntity(REntity::Id entityId);
144 
145  virtual void exportShapes(const QList<QSharedPointer<RShape> >& shapes);
146  virtual void exportShape(QSharedPointer<RShape> shape);
147  virtual void exportShapeSegment(QSharedPointer<RShape> shape);
148 
152  virtual double exportLine(const RLine& line, double offset = RNANDOUBLE);
153 
157  virtual bool exportLinetypeShape(QList<RPainterPath>& pps, const RLine& line, double total, double length, double angle, const RVector& cursor);
158 
164  virtual void exportLineSegment(const RLine& line, double angle = RNANDOUBLE) = 0;
165 
169  virtual void exportXLine(const RXLine& xLine) = 0;
170 
174  virtual void exportRay(const RRay& ray) = 0;
175 
179  virtual void exportPoint(const RPoint& point) = 0;
180 
181  virtual void exportCircle(const RCircle& circle);
182 
183  virtual void exportArc(const RArc& arc, double offset = RNANDOUBLE);
184 
185  virtual void exportArcSegment(const RArc& arc, bool allowForZeroLength = false);
186 
187  virtual void exportEllipse(const REllipse& ellipse, double offset = RNANDOUBLE);
188 
189  virtual void exportPolyline(const RPolyline& polyline, bool polylineGen = true, double offset = RNANDOUBLE);
190 
191  virtual void exportSpline(const RSpline& spline, double offset = RNANDOUBLE);
192 
193  virtual void exportSplineSegment(const RSpline& spline);
194 
198  virtual void exportExplodable(const RExplodable& explodable, double offset = RNANDOUBLE);
199 
203  virtual void exportPainterPathSource(const RPainterPathSource& pathSource);
204 
205  virtual void exportPainterPaths(const QList<RPainterPath>& paths);
206  virtual void exportPainterPaths(const QList<RPainterPath>& paths, double angle, const RVector& pos);
207 
208  virtual void exportBoundingBoxPaths(const QList<RPainterPath>& paths);
209 
210  virtual void exportImage(const RImageData& image);
211 
212  virtual void exportQuad(
213  const RVector& p1,
214  const RVector& p2,
215  const RVector& p3,
216  const RVector& p4
217  );
218 
219  virtual void exportVerticalQuad(
220  const RVector& p1,
221  const RVector& p2,
222  double height
223  );
224 
225  virtual void exportBox(const RBox& box);
226 
230  virtual void exportTriangle(const RTriangle& triangle) = 0;
231 
232  virtual void exportRectangle(const RVector& p1, const RVector& p2);
233 
234  virtual double getLineTypePatternScale(const RLinetypePattern& p) const;
235 
236  QStack<REntity*> getEntityStack();
237 
238  void setDraftMode(bool on);
239 
241  setDraftMode(!draftMode);
242  }
243 
244  bool getDraftMode() const {
245  return draftMode;
246  }
247 
248  void setTwoColorSelectedMode(bool on) {
249  twoColorSelectedMode = on;
250  }
251 
252  bool getTwoColorSelectedMode() const {
253  return twoColorSelectedMode;
254  }
255 
256  void setScreenBasedLinetypes(bool on);
257 
259  setScreenBasedLinetypes(!screenBasedLinetypes);
260  }
261 
262  bool getScreenBasedLinetypes() const {
263  return screenBasedLinetypes;
264  }
265 
270  bool isVisualExporter() const {
271  return visualExporter;
272  }
273 
274  void setVisualExporter(bool on) {
275  visualExporter = on;
276  }
277 
278  double getPixelSizeHint() const {
279  return pixelSizeHint;
280  }
281 
282  void setPixelSizeHint(double v) {
283  pixelSizeHint = v;
284  }
285 
286 protected:
290  QBrush currentBrush;
291  QStack<REntity*> entityStack;
293  QStack<REntity*> blockRefStack;
296  bool draftMode;
300  QString errorMessage;
302 
303 private:
305 };
306 
308 
309 #endif
RDocument * layerSource
Definition: RExporter.h:294
bool getDraftMode() const
Definition: RExporter.h:244
Represents a box e.g.
Definition: RBox.h:43
bool isVisualExporter() const
Definition: RExporter.h:270
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RMessageHandler.h:33
void setPixelSizeHint(double v)
Definition: RExporter.h:282
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
Low-level mathematical representation of a spline.
Definition: RSpline.h:54
double getPixelSizeHint() const
Definition: RExporter.h:278
RLinetypePattern currentLinetypePattern
Definition: RExporter.h:289
RLayer * currentLayer
Definition: RExporter.h:292
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RImageData.h:41
Low-level mathematical representation of a triangle.
Definition: RTriangle.h:46
virtual void startEntity(bool)
Definition: RExporter.h:140
bool twoColorSelectedMode
Definition: RExporter.h:297
Low-level mathematical representation of an arc.
Definition: RArc.h:41
Represents a block definition in a drawing.
Definition: RBlock.h:43
bool getScreenBasedLinetypes() const
Definition: RExporter.h:262
RDocument * document
Definition: RExporter.h:287
#define QCADCORE_EXPORT
Definition: core_global.h:10
RDocument * blockSource
Definition: RExporter.h:295
RS::ProjectionRenderingHint projectionRenderingHint
Definition: RExporter.h:304
int Id
Definition: RObject.h:53
void getDocument()
Definition: simple.js:19
virtual void endEntity()
Definition: RExporter.h:141
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RLinetypePattern.h:45
QStack< REntity * > blockRefStack
Definition: RExporter.h:293
QPen currentPen
Definition: RExporter.h:288
#define RNANDOUBLE
Definition: RMath.h:55
QString errorMessage
Definition: RExporter.h:300
ProjectionRenderingHint
Sets the current rendering hint for exports.
Definition: RS.h:118
Lineweight
Definition: RLineweight.h:42
Color.
Definition: RColor.h:42
void toggleDraftMode()
Definition: RExporter.h:240
virtual void exportView(RView &)
Definition: RExporter.h:131
bool draftMode
Definition: RExporter.h:296
double pixelSizeHint
Definition: RExporter.h:301
Base class for all entity classes.
Definition: REntity.h:64
A graphics document contains and owns entities, layers, user coordinate systems, variables, block definitions, etc.
Definition: RDocument.h:63
Q_DECLARE_METATYPE(RMath *)
Low-level mathematical representation of an ellipse or ellipse arc.
Definition: REllipse.h:41
Extended painter path with a z-level and a pen.
Definition: RPainterPath.h:45
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RPainterPathSource.h:36
virtual void exportDocumentSetting(const QString &, const QVariant &)
Definition: RExporter.h:119
Low-level mathematical representation of an infinite line.
Definition: RXLine.h:42
virtual void exportBlock(RBlock &)
Definition: RExporter.h:129
Low-level mathematical representation of a line.
Definition: RLine.h:42
Interface for explodable shape classes.
Definition: RExplodable.h:40
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RPoint.h:38
Represents a linetype in a drawing.
Definition: RLinetype.h:50
void setVisualExporter(bool on)
Definition: RExporter.h:274
Abstract base class for exporters.
Definition: RExporter.h:63
Low-level mathematical representation of a circle.
Definition: RCircle.h:39
QStack< REntity * > entityStack
Definition: RExporter.h:291
QBrush currentBrush
Definition: RExporter.h:290
virtual void exportLayer(RLayer &)
Definition: RExporter.h:127
Low-level mathematical representation of an open polyline or closed polyline (= polygon).
Definition: RPolyline.h:49
Represents a layer in a drawing.
Definition: RLayer.h:47
Represents a view in a drawing.
Definition: RView.h:42
bool visualExporter
Definition: RExporter.h:299
bool getTwoColorSelectedMode() const
Definition: RExporter.h:252
Low-level mathematical representation of a ray.
Definition: RRay.h:42
bool screenBasedLinetypes
Definition: RExporter.h:298
virtual void exportLinetype(RLinetype &)
Definition: RExporter.h:133
void toggleScreenBasedLinetypes()
Definition: RExporter.h:258
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RProgressHandler.h:33
void setTwoColorSelectedMode(bool on)
Definition: RExporter.h:248