QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
RExporter.h
Go to the documentation of this file.
1
20#ifndef REXPORTER_H
21#define REXPORTER_H
22
23#include <stdint.h>
24
25#include "core_global.h"
26
27#include <QBrush>
28#include <QPen>
29#include <QStack>
30#include <QTransform>
31
32#include "RLinetypePattern.h"
33#include "RLineweight.h"
34#include "RMath.h"
35#include "RObject.h"
36
37class RArc;
38class RBlock;
39class RCircle;
40class RColor;
41class RDocument;
42class REllipse;
43class REntity;
44class RExplodable;
45class RImageData;
46class RLayer;
47class RLayerState;
48class RLine;
49class RLinetype;
50class RMessageHandler;
51class RPainterPath;
53class RPoint;
54class RPolyline;
56class RRay;
57class RSpline;
58class RTextBasedData;
59class RTransform;
60class RTriangle;
61class RVector;
62class RView;
63class RViewportEntity;
64class RXLine;
65
66#ifndef RDEFAULT_MIN1
67#define RDEFAULT_MIN1 -1
68#endif
69
79
80public:
81 RExporter();
82 RExporter(RDocument& document, RMessageHandler* messageHandler = NULL, RProgressHandler* progressHandler = NULL);
83 virtual ~RExporter();
84
85private:
86 void init();
87
88public:
89
90 QString getErrorMessage() const;
91
92 void setLayerSource(RDocument* ls);
93 void setBlockSource(RDocument* bs);
94
98 virtual RDocument& getDocument() const;
99
100 void setProjectionRenderingHint(RS::ProjectionRenderingHint p);
101 RS::ProjectionRenderingHint getProjectionRenderingHint();
102
103 //virtual RBox getClipRectangle() const;
104 virtual void setClipping(bool on);
105 bool getClipping() const;
106
107 virtual void setWipeout(bool on);
108 bool getWipeout() const;
109
110 virtual void setFrameless(bool on);
111 bool getFrameless() const;
112
113 virtual void setPen(const QPen& pen);
114 virtual QPen getPen(const RPainterPath& path);
115 virtual QPen getPen();
116 virtual void setBrush(const QBrush& brush);
117 virtual QBrush getBrush(const RPainterPath& path);
118 virtual QBrush getBrush();
119
120 virtual RColor getColor(const RColor& unresolvedColor);
121 virtual RColor getColor(bool resolve);
122
123 virtual void setEntityAttributes(bool forceSelected=false);
124
125 virtual void setStyle(Qt::PenStyle penStyle);
126 virtual void setBrushStyle(Qt::BrushStyle brushStyle);
127 virtual void setDashPattern(const QVector<qreal>& dashes);
128
129 virtual void setColor(float r, float g, float b, float a = 1.0f);
130 virtual void setColor(const RColor& color);
131
132 virtual void setLineweight(RLineweight::Lineweight weight);
133
134 virtual void setLinetypeId(RObject::Id ltId);
135 virtual void setLinetypePattern(const RLinetypePattern& ltPattern);
136 virtual RLinetypePattern getLinetypePattern();
137
138 virtual QSharedPointer<REntity> getBlockRefOrEntity();
139 virtual RObject::Id getBlockRefOrEntityId();
140 virtual QSharedPointer<REntity> getEntity();
141 virtual QSharedPointer<REntity> getCurrentBlockRef() const;
142 virtual QSharedPointer<RViewportEntity> getCurrentViewport() const;
143 virtual QStack<QSharedPointer<REntity> > getBlockRefViewportStack() const;
144
148 virtual QSharedPointer<REntity> getEntity() const;
149
150 virtual bool isEntitySelected();
151 virtual bool isPatternContinuous(const RLinetypePattern& p);
152
153 virtual void startExport();
154 virtual void endExport();
155
156 virtual bool exportDocument();
157 virtual bool exportDocumentSettings();
158 virtual void exportDocumentSetting(const QString& key, const QVariant& value, const QString& dictionaryName = "QCAD_OBJECTS");
159
160 virtual void exportIntListWithName(const QString& dictionaryName, const QString& name, const QString& listName, QList<int64_t>& values);
161
162 virtual void exportLayers();
163 virtual void exportLayerStates();
164 virtual void exportBlocks();
165 virtual void exportViews();
166 virtual void exportLinetypes();
167
168 virtual void exportLayer(QSharedPointer<RLayer> /*layer*/) {}
169 virtual void exportLayer(RObject::Id layerId);
170 virtual void exportLayerState(QSharedPointer<RLayerState> /*layerState*/) {}
171 virtual void exportBlock(QSharedPointer<RBlock> /*block*/) {}
172 virtual void exportBlock(RObject::Id blockId);
173 virtual void exportView(QSharedPointer<RView> /*view*/) {}
174 virtual void exportView(RObject::Id viewId);
175 virtual void exportLinetype(QSharedPointer<RLinetype> /*linetype*/) {}
176
177 virtual void exportEntities(bool allBlocks = true, bool undone = false, bool invisible = false);
178 virtual void exportEntities(const RBox& box);
179 virtual void exportEntities(QSet<RObject::Id>& entityIds, bool allBlocks = true);
180 virtual void exportEntity(QSharedPointer<REntity> entity, bool preview = false, bool allBlocks = true, bool forceSelected = false, bool invisible = false);
181 virtual void exportEntity(RObject::Id entityId, bool allBlocks = true, bool forceSelected = false);
182 virtual QSharedPointer<RLayer> getEntityLayer(QSharedPointer<REntity> entity);
183 virtual bool isVisible(QSharedPointer<REntity> entity);
184 virtual void startEntity(bool /*topLevelEntity*/) {}
185 virtual void endEntity(bool /*topLevelEntity*/) {}
186 virtual void exportCurrentEntity(bool preview = false, bool forceSelected = false);
187 virtual void unexportEntity(RObject::Id entityId);
188
189 virtual void exportShapes(const QList<QSharedPointer<RShape> >& shapes);
190 virtual void exportShape(QSharedPointer<RShape> shape);
191 virtual void exportShapeSegment(QSharedPointer<RShape> shape, double angle);
192
196 virtual double exportLine(const RLine& line, double offset = RNANDOUBLE);
197
201 virtual bool exportLinetypeShape(QList<RPainterPath>& pps, const RLine& line, double total, double length, double angle, const RVector& cursor);
202
208 virtual void exportLineSegment(const RLine& line, double angle = RNANDOUBLE) = 0;
209
213 virtual void exportXLine(const RXLine& xLine) = 0;
214
218 virtual void exportRay(const RRay& ray) = 0;
219
223 virtual void exportPoint(const RPoint& point) = 0;
224
225 virtual void exportCircle(const RCircle& circle);
226
227 virtual void exportArc(const RArc& arc, double offset = RNANDOUBLE);
228
229 virtual void exportArcSegment(const RArc& arc, bool allowForZeroLength = false);
230
231 virtual void exportEllipse(const REllipse& ellipse, double offset = RNANDOUBLE);
232
233 virtual void exportPolyline(const RPolyline& polyline, bool polylineGen = true, double offset = RNANDOUBLE);
234
235 virtual void exportSpline(const RSpline& spline, double offset = RNANDOUBLE);
236
237 virtual void exportSplineSegment(const RSpline& spline);
238
242 virtual void exportExplodable(const RExplodable& explodable, double offset = RNANDOUBLE);
243
247 virtual void exportPainterPathSource(const RPainterPathSource& pathSource, double z = 0.0);
248
249 virtual void exportPainterPaths(const QList<RPainterPath>& paths, double z = 0.0);
250 virtual void exportPainterPaths(const QList<RPainterPath>& paths, double angle, const RVector& pos);
251
252 virtual void exportBoundingBoxPaths(const QList<RPainterPath>& paths);
253
254 virtual void exportImage(const RImageData& image, bool forceSelected = false);
255 virtual QList<RPainterPath> exportText(const RTextBasedData& text, bool forceSelected = false);
256 virtual void exportClipRectangle(const RBox& clipRectangle, bool forceSelected = false);
257 virtual void clearClipRectangles();
258 virtual void exportTransform(const RTransform& t);
259 virtual void exportEndTransform();
260
261 virtual void exportThickPolyline(const RPolyline& polyline);
262
263// virtual void exportThickLine(const RLine& line, double w1, double w2) {
264// Q_UNUSED(w1)
265// Q_UNUSED(w2)
266// exportLineSegment(line);
267// }
268
269// virtual void exportThickArc(const RArc& arc, double w1, double w2) {
270// Q_UNUSED(w1)
271// Q_UNUSED(w2)
272// exportArcSegment(arc);
273// }
274
275 virtual void exportQuad(
276 const RVector& p1,
277 const RVector& p2,
278 const RVector& p3,
279 const RVector& p4
280 );
281
282 virtual void exportVerticalQuad(
283 const RVector& p1,
284 const RVector& p2,
285 double height
286 );
287
288 virtual void exportBox(const RBox& box);
289
293 virtual void exportTriangle(const RTriangle& triangle) = 0;
294
295 virtual void exportRectangle(const RVector& p1, const RVector& p2);
296
297 virtual double getLineTypePatternScale(const RLinetypePattern& p) const;
298
302 virtual bool isTextRenderedAsText() const;
303
304 QStack<QSharedPointer<REntity> > getEntityStack();
305
306 void pushEntity(QSharedPointer<REntity> e);
307 void popEntity();
308
309 void setDraftMode(bool on);
310
312 setDraftMode(!draftMode);
313 }
314
315 bool getDraftMode() const {
316 return draftMode;
317 }
318
320 twoColorSelectedMode = on;
321 }
322
324 return twoColorSelectedMode;
325 }
326
327 void setScreenBasedLinetypes(bool on);
328
330 setScreenBasedLinetypes(!screenBasedLinetypes);
331 }
332
333 virtual bool getScreenBasedLinetypes() const {
334 return screenBasedLinetypes;
335 }
336
341 bool isVisualExporter() const {
342 return visualExporter;
343 }
344
345 void setVisualExporter(bool on) {
346 visualExporter = on;
347 }
348
349 bool getExportInvisible() const {
350 return exportInvisible;
351 }
352
353 void setExportInvisible(bool on) {
354 exportInvisible = on;
355 }
356
357 double getPixelSizeHint() const {
358 return pixelSizeHint;
359 }
360
361 virtual double getCurrentPixelSizeHint() const;
362
363 void setPixelSizeHint(double v) {
364 pixelSizeHint = v;
365 }
366
367 bool getPixelUnit() const {
368 return pixelUnit;
369 }
370
371 void setPixelUnit(bool on) {
372 pixelUnit = on;
373 }
374
375 bool getPixelWidth() const {
376 return pixelWidth;
377 }
378
379 void setPixelWidth(bool on) {
380 pixelWidth = on;
381 }
382
383 void setEnablePatterns(bool on) {
384 enablePatterns = on;
385 }
386
387// bool getCombineTransforms() const {
388// return combineTransforms;
389// }
390
391// void setCombineTransforms(bool on) {
392// combineTransforms = on;
393// }
394
395protected:
397 QTransform transform;
401 QStack<QSharedPointer<REntity> > entityStack;
403 QStack<QSharedPointer<REntity> > blockRefViewportStack;
418 Qt::PenCapStyle penCapStyle;
420 //bool combineTransforms;
421
422private:
424};
425
427
428#endif
void init(void basePath)
Definition AddBlockInit.js:2
#define RNANDOUBLE
Definition RMath.h:74
Q_DECLARE_METATYPE(RMath *)
Low-level mathematical representation of an arc.
Definition RArc.h:42
Represents a block definition in a drawing.
Definition RBlock.h:42
Represents a box e.g.
Definition RBox.h:46
Low-level mathematical representation of a circle.
Definition RCircle.h:41
Color.
Definition RColor.h:43
A graphics document contains and owns entities, layers, user coordinate systems, variables,...
Definition RDocument.h:78
Low-level mathematical representation of an ellipse or ellipse arc.
Definition REllipse.h:43
Base class for all entity classes.
Definition REntity.h:63
Interface for explodable shape classes.
Definition RExplodable.h:40
Abstract base class for exporters.
Definition RExporter.h:78
bool getPixelWidth() const
Definition RExporter.h:375
virtual void exportRay(const RRay &ray)=0
Exports an infinite ray.
bool draftMode
Definition RExporter.h:406
RLayer * currentLayer
Definition RExporter.h:402
QPen currentPen
Definition RExporter.h:398
virtual void exportLayerState(QSharedPointer< RLayerState >)
Definition RExporter.h:170
virtual void exportTriangle(const RTriangle &triangle)=0
Exports a triangle with the current attributes.
bool pixelUnit
Definition RExporter.h:413
Qt::PenCapStyle penCapStyle
Definition RExporter.h:418
bool wipeout
Definition RExporter.h:415
RDocument * layerSource
Definition RExporter.h:404
virtual void exportPoint(const RPoint &point)=0
Exports a point with the current attributes.
double pixelSizeHint
Definition RExporter.h:412
QTransform transform
Definition RExporter.h:397
bool enablePatterns
Definition RExporter.h:419
RLinetypePattern currentLinetypePattern
Definition RExporter.h:399
RDocument * document
Definition RExporter.h:396
bool pixelWidth
Definition RExporter.h:417
virtual void exportBlock(QSharedPointer< RBlock >)
Definition RExporter.h:171
bool visualExporter
Definition RExporter.h:409
void toggleScreenBasedLinetypes()
Definition RExporter.h:329
void toggleDraftMode()
Definition RExporter.h:311
virtual void exportXLine(const RXLine &xLine)=0
Exports an infinite line.
RDocument * blockSource
Definition RExporter.h:405
virtual void exportLinetype(QSharedPointer< RLinetype >)
Definition RExporter.h:175
QString errorMessage
Definition RExporter.h:411
QBrush currentBrush
Definition RExporter.h:400
double getPixelSizeHint() const
Definition RExporter.h:357
QStack< QSharedPointer< REntity > > blockRefViewportStack
Definition RExporter.h:403
void setEnablePatterns(bool on)
Definition RExporter.h:383
bool exportInvisible
Definition RExporter.h:410
bool frameless
Definition RExporter.h:416
bool getDraftMode() const
Definition RExporter.h:315
virtual void exportEntities(QSet< RObject::Id > &entityIds, bool allBlocks=true)
bool clipping
Definition RExporter.h:414
QStack< QSharedPointer< REntity > > entityStack
Definition RExporter.h:401
void setPixelWidth(bool on)
Definition RExporter.h:379
void setVisualExporter(bool on)
Definition RExporter.h:345
void setPixelSizeHint(double v)
Definition RExporter.h:363
bool isVisualExporter() const
Definition RExporter.h:341
virtual void exportView(QSharedPointer< RView >)
Definition RExporter.h:173
virtual void startEntity(bool)
Definition RExporter.h:184
virtual void exportLineSegment(const RLine &line, double angle=RNANDOUBLE)=0
Exports a line segment (a line without pattern).
virtual void exportLayer(QSharedPointer< RLayer >)
Definition RExporter.h:168
bool twoColorSelectedMode
Definition RExporter.h:407
bool getExportInvisible() const
Definition RExporter.h:349
virtual void endEntity(bool)
Definition RExporter.h:185
bool screenBasedLinetypes
Definition RExporter.h:408
void setTwoColorSelectedMode(bool on)
Definition RExporter.h:319
void setExportInvisible(bool on)
Definition RExporter.h:353
RS::ProjectionRenderingHint projectionRenderingHint
Definition RExporter.h:423
bool getTwoColorSelectedMode() const
Definition RExporter.h:323
bool getPixelUnit() const
Definition RExporter.h:367
virtual bool getScreenBasedLinetypes() const
Definition RExporter.h:333
void setPixelUnit(bool on)
Definition RExporter.h:371
Stores and manages all data that defines the geometry and appearance of a raster image entity.
Definition RImageData.h:41
Represents a layer in a drawing.
Definition RLayer.h:45
Represents a layer state (state of list of layers) in a drawing.
Definition RLayerState.h:37
Low-level mathematical representation of a line.
Definition RLine.h:41
Represents a linetype in a drawing.
Definition RLinetype.h:45
Copyright (c) 2011-2018 by Andrew Mustun.
Definition RLinetypePattern.h:42
Lineweight
Definition RLineweight.h:44
Copyright (c) 2011-2018 by Andrew Mustun.
Definition RMessageHandler.h:33
int Id
Definition RObject.h:69
Extended painter path with a z-level and a pen.
Definition RPainterPath.h:48
Interface for entity data classes that can deliver painter paths.
Definition RPainterPathSource.h:40
Low-level mathematical representation of a point.
Definition RPoint.h:40
Low-level mathematical representation of an open polyline or closed polyline (= polygon).
Definition RPolyline.h:50
Copyright (c) 2011-2018 by Andrew Mustun.
Definition RProgressHandler.h:33
Low-level mathematical representation of a ray.
Definition RRay.h:41
ProjectionRenderingHint
Sets the current rendering hint for exports.
Definition RS.h:293
Low-level mathematical representation of a spline.
Definition RSpline.h:59
Stores and manages all data that defines the geometry and appearance of a text based entity (text,...
Definition RTextBasedData.h:68
Copyright (c) 2011-2020 by Andrew Mustun.
Definition RTransform.h:37
Low-level mathematical representation of a triangle.
Definition RTriangle.h:49
Represents a 3d vector (x/y/z).
Definition RVector.h:47
Represents a view in a drawing.
Definition RView.h:41
Viewport entity.
Definition RViewportEntity.h:38
Low-level mathematical representation of an infinite line.
Definition RXLine.h:42
#define QCADCORE_EXPORT
Definition core_global.h:10
void getDocument()
Returns the current RDocument or undefined.
Definition simple.js:63
#define NULL
Definition opennurbs_system.h:256