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 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();
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  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);
139  virtual void exportEntity(REntity::Id entityId, bool allBlocks = true);
140  virtual void startEntity(bool /*topLevelEntity*/) {}
141  virtual void endEntity() {}
142  virtual void exportCurrentEntity(bool preview = 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 
151  virtual void exportLine(const RLine& line, double offset = RNANDOUBLE);
152 
158  virtual void exportLineSegment(const RLine& line) = 0;
159 
163  virtual void exportXLine(const RXLine& xLine) = 0;
164 
168  virtual void exportRay(const RRay& ray) = 0;
169 
173  virtual void exportPoint(const RPoint& point) = 0;
174 
175  virtual void exportCircle(const RCircle& circle);
176 
177  virtual void exportArc(const RArc& arc, double offset = RNANDOUBLE);
178 
179  virtual void exportArcSegment(const RArc& arc);
180 
181  virtual void exportEllipse(const REllipse& ellipse, double offset = RNANDOUBLE);
182 
183  virtual void exportPolyline(const RPolyline& polyline, double offset = RNANDOUBLE);
184 
185  virtual void exportSpline(const RSpline& spline, double offset = RNANDOUBLE);
186 
190  virtual void exportExplodable(const RExplodable& explodable, double offset = RNANDOUBLE);
191 
195  virtual void exportPainterPathSource(const RPainterPathSource& pathSource);
196 
197  virtual void exportPainterPaths(const QList<RPainterPath>& paths);
198  virtual void exportBoundingBoxPaths(const QList<RPainterPath>& paths);
199 
200  virtual void exportImage(const RImageData& image);
201 
202  virtual void exportQuad(
203  const RVector& p1,
204  const RVector& p2,
205  const RVector& p3,
206  const RVector& p4
207  );
208 
209  virtual void exportVerticalQuad(
210  const RVector& p1,
211  const RVector& p2,
212  double height
213  );
214 
215  virtual void exportBox(const RBox& box);
216 
220  virtual void exportTriangle(const RTriangle& triangle) = 0;
221 
222  virtual void exportRectangle(const RVector& p1, const RVector& p2);
223 
224  virtual double getPatternFactor();
225 
226  QStack<REntity*> getEntityStack();
227 
228  double getPatternOffset(double length, const RLinetypePattern& pattern);
232  double getPatternOffset(double length, const RLinetypePattern& pattern,
233  int index, double* gap = NULL);
234 
235  void setDraftMode(bool on);
236 
238  setDraftMode(!draftMode);
239  }
240 
241  bool getDraftMode() const {
242  return draftMode;
243  }
244 
245  void setScreenBasedLinetypes(bool on);
246 
248  setScreenBasedLinetypes(!screenBasedLinetypes);
249  }
250 
251  bool getScreenBasedLinetypes() const {
252  return screenBasedLinetypes;
253  }
254 
259  bool isVisualExporter() const {
260  return visualExporter;
261  }
262 
263  void setVisualExporter(bool on) {
264  visualExporter = on;
265  }
266 
267  double getPixelSizeHint() const {
268  return pixelSizeHint;
269  }
270 
271  void setPixelSizeHint(double v) {
272  pixelSizeHint = v;
273  }
274 
275 protected:
279  QBrush currentBrush;
280  QStack<REntity*> entityStack;
282  QStack<RBlockReferenceEntity*> blockRefStack;
285  bool draftMode;
288  QString errorMessage;
290 
291 private:
293 };
294 
296 
297 #endif