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(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