QCAD
Open Source 2D CAD
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 RSpline;
50 class RTriangle;
51 class RVector;
52 
62 
63 public:
64  RExporter();
65  RExporter(RDocument& document, RMessageHandler* messageHandler = NULL, RProgressHandler* progressHandler = NULL);
66  virtual ~RExporter();
67 
68  QString getErrorMessage() const;
69 
70  void setLayerSource(RDocument* ls);
71  void setBlockSource(RDocument* bs);
72 
76  RDocument& getDocument() const;
77 
78  void setProjectionRenderingHint(RS::ProjectionRenderingHint p);
79  RS::ProjectionRenderingHint getProjectionRenderingHint();
80  virtual void setPen(const QPen& pen);
81  virtual QPen getPen(const RPainterPath& path);
82  virtual QPen getPen();
83  virtual void setBrush(const QBrush& brush);
84  virtual QBrush getBrush(const RPainterPath& path);
85  virtual QBrush getBrush();
86 
87  virtual void setEntityAttributes();
88 
89  virtual void setStyle(Qt::PenStyle penStyle);
90  virtual void setBrushStyle(Qt::BrushStyle brushStyle);
91  virtual void setDashPattern(const QVector<qreal>& dashes);
92 
93  virtual void setColor(float r, float g, float b, float a = 1.0f);
94  virtual void setColor(const RColor& color);
95 
96  virtual void setLineweight(RLineweight::Lineweight weight);
97 
98  virtual void setLinetypeId(RLinetype::Id ltId);
99  virtual void setLinetypePattern(const RLinetypePattern& ltPattern);
100  RLinetypePattern getLinetypePattern();
101 
102  virtual REntity* getBlockRefOrEntity();
103  virtual REntity* getEntity();
104 
108  virtual const REntity* getEntity() const;
109 
110  virtual bool isEntitySelected();
111 
112  virtual void startExport();
113  virtual void endExport();
114 
115  virtual bool exportDocument();
116  virtual bool exportDocumentSettings();
117  virtual void exportDocumentSetting(
118  const QString& /*key*/, const QVariant& /*value*/) {}
119 
120  virtual void exportLayers();
121  virtual void exportBlocks();
122  virtual void exportViews();
123  virtual void exportLinetypes();
124 
125  virtual void exportLayer(RLayer& /*layer*/) {}
126  virtual void exportLayer(RLayer::Id layerId);
127  virtual void exportBlock(RBlock& /*block*/) {}
128  virtual void exportBlock(RBlock::Id blockId);
129  virtual void exportView(RView& /*view*/) {}
130  virtual void exportView(RView::Id viewId);
131  virtual void exportLinetype(RLinetype& /*linetype*/) {}
132 
133  virtual void exportEntities(bool allBlocks = true, bool undone = false);
134  virtual void exportEntities(const RBox& box);
135  virtual void exportEntities(QSet<REntity::Id>& entityIds, bool allBlocks = true);
136  virtual void exportEntity(REntity& e, bool preview = false, bool allBlocks = true);
137  virtual void exportEntity(REntity::Id entityId, bool allBlocks = true);
138  virtual void startEntity(bool /*topLevelEntity*/) {}
139  virtual void endEntity() {}
140  virtual void exportCurrentEntity(bool preview = false);
141  virtual void unexportEntity(REntity::Id entityId);
142 
143  virtual void exportShapes(const QList<QSharedPointer<RShape> >& shapes);
144  virtual void exportShape(QSharedPointer<RShape> shape);
145 
149  virtual void exportLine(const RLine& line, double offset = RNANDOUBLE);
150 
156  virtual void exportLineSegment(const RLine& line) = 0;
157 
161  virtual void exportPoint(const RPoint& point) = 0;
162 
163  virtual void exportCircle(const RCircle& circle);
164 
165  virtual void exportArc(const RArc& arc, double offset = RNANDOUBLE);
166 
167  virtual void exportArcSegment(const RArc& arc);
168 
169  virtual void exportEllipse(const REllipse& ellipse, double offset = RNANDOUBLE);
170 
171  virtual void exportPolyline(const RPolyline& polyline, double offset = RNANDOUBLE);
172 
173  virtual void exportSpline(const RSpline& spline, double offset = RNANDOUBLE);
174 
178  virtual void exportExplodable(const RExplodable& explodable, double offset = RNANDOUBLE);
179 
183  virtual void exportPainterPathSource(const RPainterPathSource& pathSource);
184 
185  virtual void exportPainterPaths(const QList<RPainterPath>& paths);
186  virtual void exportBoundingBoxPaths(const QList<RPainterPath>& paths);
187 
188  virtual void exportImage(const RImageData& image);
189 
190  virtual void exportQuad(
191  const RVector& p1,
192  const RVector& p2,
193  const RVector& p3,
194  const RVector& p4
195  );
196 
197  virtual void exportVerticalQuad(
198  const RVector& p1,
199  const RVector& p2,
200  double height
201  );
202 
203  virtual void exportBox(const RBox& box);
204 
208  virtual void exportTriangle(const RTriangle& triangle) = 0;
209 
210  virtual void exportRectangle(const RVector& p1, const RVector& p2);
211 
212  virtual double getPatternFactor();
213 
214  QStack<REntity*> getEntityStack();
215 
216  double getPatternOffset(double length, const RLinetypePattern& pattern);
220  double getPatternOffset(double length, const RLinetypePattern& pattern,
221  int index, double* gap = NULL);
222 
223  void setDraftMode(bool on);
224 
226  setDraftMode(!draftMode);
227  }
228 
229  bool getDraftMode() const {
230  return draftMode;
231  }
232 
233  void setScreenBasedLinetypes(bool on);
234 
236  setScreenBasedLinetypes(!screenBasedLinetypes);
237  }
238 
239  bool getScreenBasedLinetypes() const {
240  return screenBasedLinetypes;
241  }
242 
247  bool isVisualExporter() const {
248  return visualExporter;
249  }
250 
251  void setVisualExporter(bool on) {
252  visualExporter = on;
253  }
254 
255  double getPixelSizeHint() const {
256  return pixelSizeHint;
257  }
258 
259  void setPixelSizeHint(double v) {
260  pixelSizeHint = v;
261  }
262 
263 protected:
267  QBrush currentBrush;
268  QStack<REntity*> entityStack;
270  QStack<RBlockReferenceEntity*> blockRefStack;
273  bool draftMode;
276  QString errorMessage;
278 
279 private:
281 };
282 
284 
285 #endif