Seamly2D
Code documentation
vdxfengine.h
Go to the documentation of this file.
1 /************************************************************************
2  **
3  ** @file vdxfengine.h
4  ** @author Valentina Zhuravska <zhuravska19(at)gmail.com>
5  ** @date 12 8, 2015
6  **
7  ** @brief
8  ** @copyright
9  ** This source code is part of the Valentine project, a pattern making
10  ** program, whose allow create and modeling patterns of clothing.
11  ** Copyright (C) 2013-2015 Seamly2D project
12  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
13  **
14  ** Seamly2D is free software: you can redistribute it and/or modify
15  ** it under the terms of the GNU General Public License as published by
16  ** the Free Software Foundation, either version 3 of the License, or
17  ** (at your option) any later version.
18  **
19  ** Seamly2D is distributed in the hope that it will be useful,
20  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
21  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  ** GNU General Public License for more details.
23  **
24  ** You should have received a copy of the GNU General Public License
25  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
26  **
27  *************************************************************************/
28 
29 #ifndef VDXFENGINE_H
30 #define VDXFENGINE_H
31 
32 #include <qcompilerdetection.h>
33 #include <QMatrix>
34 #include <QPaintEngine>
35 #include <QPointF>
36 #include <QRectF>
37 #include <QSize>
38 #include <QString>
39 #include <QtGlobal>
40 #include <string>
41 
42 #include "../vmisc/def.h"
43 #include "dxfdef.h"
44 #include "libdxfrw/drw_base.h"
45 
46 class QTextStream;
47 class dx_iface;
48 class DRW_Text;
49 class VLayoutPiece;
50 class DRW_Entity;
51 class dx_ifaceBlock;
52 
53 class VDxfEngine : public QPaintEngine
54 {
55  friend class VDxfPaintDevice;
56 public:
57  VDxfEngine();
58  virtual ~VDxfEngine();
59 
60  virtual bool begin(QPaintDevice *pdev) Q_DECL_OVERRIDE;
61  virtual bool end() Q_DECL_OVERRIDE;
62  virtual void updateState(const QPaintEngineState &state) Q_DECL_OVERRIDE;
63  virtual void drawPath(const QPainterPath &path) Q_DECL_OVERRIDE;
64  virtual void drawLines(const QLineF * lines, int lineCount) Q_DECL_OVERRIDE;
65  virtual void drawLines(const QLine * lines, int lineCount) Q_DECL_OVERRIDE;
66  virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) Q_DECL_OVERRIDE;
67  virtual void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode) Q_DECL_OVERRIDE;
68  virtual void drawEllipse(const QRectF & rect) Q_DECL_OVERRIDE;
69  virtual void drawEllipse(const QRect & rect) Q_DECL_OVERRIDE;
70  virtual void drawTextItem(const QPointF & p, const QTextItem & textItem) Q_DECL_OVERRIDE;
71  virtual Type type() const Q_DECL_OVERRIDE;
72  virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) Q_DECL_OVERRIDE;
73 
74  QSize getSize() const;
75  void setSize(const QSize &value);
76 
77  double getResolution() const;
78  void setResolution(double value);
79 
80  QString getFileName() const;
81  void setFileName(const QString &value);
82 
83  DRW::Version GetVersion() const;
84  void SetVersion(DRW::Version version);
85 
86  void SetBinaryFormat(bool binary);
87  bool IsBinaryFormat() const;
88 
89  std::string getPenStyle();
90  int getPenColor();
91 
92  void setMeasurement(const VarMeasurement &var);
93  void setInsunits(const VarInsunits &var);
94 
95 private:
96  Q_DISABLE_COPY(VDxfEngine)
97  QSize size;
98  double resolution;
99  QString fileName;
100  DRW::Version m_version;
101  bool m_binary;
102  QTransform transform;
106  DRW_Text *textBuffer;
107 
108  Q_REQUIRED_RESULT double FromPixel(double pix, const VarInsunits &unit) const;
109  Q_REQUIRED_RESULT double ToPixel(double val, const VarInsunits &unit) const;
110 
111  bool ExportToAAMA(const QVector<VLayoutPiece> &details);
112  void ExportAAMAOutline(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail);
113  void ExportAAMADraw(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail);
114  void ExportAAMAIntcut(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail);
115  void ExportAAMANotch(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail);
116  void ExportAAMAGrainline(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail);
117  void ExportAAMAText(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail);
118  void ExportAAMAGlobalText(const QSharedPointer<dx_iface> &input, const QVector<VLayoutPiece> &details);
119 
120  Q_REQUIRED_RESULT DRW_Entity *AAMAPolygon(const QVector<QPointF> &polygon, const QString &layer, bool forceClosed);
121  Q_REQUIRED_RESULT DRW_Entity *AAMALine(const QLineF &line, const QString &layer);
122  Q_REQUIRED_RESULT DRW_Entity *AAMAText(const QPointF &pos, const QString &text, const QString &layer);
123 
124  template<class P, class V>
125  Q_REQUIRED_RESULT P *CreateAAMAPolygon(const QVector<QPointF> &polygon, const QString &layer, bool forceClosed);
126 };
127 
128 #endif // VDXFENGINE_H
double resolution
Definition: vdxfengine.h:98
void setMeasurement(const VarMeasurement &var)
Definition: vdxfengine.cpp:558
virtual bool begin(QPaintDevice *pdev) Q_DECL_OVERRIDE
Definition: vdxfengine.cpp:96
QSharedPointer< dx_iface > input
Definition: vdxfengine.h:103
virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) Q_DECL_OVERRIDE
Definition: vdxfengine.cpp:396
virtual void drawLines(const QLineF *lines, int lineCount) Q_DECL_OVERRIDE
Definition: vdxfengine.cpp:203
double getResolution() const
Definition: vdxfengine.cpp:417
std::string getPenStyle()
Definition: vdxfengine.cpp:468
int getPenColor()
Definition: vdxfengine.cpp:487
QString getFileName() const
Definition: vdxfengine.cpp:430
QString fileName
Definition: vdxfengine.h:99
void ExportAAMAOutline(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail)
Definition: vdxfengine.cpp:660
bool m_binary
Definition: vdxfengine.h:101
virtual void drawTextItem(const QPointF &p, const QTextItem &textItem) Q_DECL_OVERRIDE
Definition: vdxfengine.cpp:344
Q_REQUIRED_RESULT DRW_Entity * AAMAText(const QPointF &pos, const QString &text, const QString &layer)
Definition: vdxfengine.cpp:811
virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) Q_DECL_OVERRIDE
Definition: vdxfengine.cpp:231
void ExportAAMAIntcut(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail)
Definition: vdxfengine.cpp:694
DRW::Version m_version
Definition: vdxfengine.h:100
virtual void drawEllipse(const QRectF &rect) Q_DECL_OVERRIDE
Definition: vdxfengine.cpp:297
void ExportAAMAGlobalText(const QSharedPointer< dx_iface > &input, const QVector< VLayoutPiece > &details)
Definition: vdxfengine.cpp:762
Q_REQUIRED_RESULT double FromPixel(double pix, const VarInsunits &unit) const
Definition: vdxfengine.cpp:575
bool ExportToAAMA(const QVector< VLayoutPiece > &details)
Definition: vdxfengine.cpp:607
bool IsBinaryFormat() const
Definition: vdxfengine.cpp:462
void SetBinaryFormat(bool binary)
Definition: vdxfengine.cpp:456
VarMeasurement varMeasurement
Definition: vdxfengine.h:104
void setSize(const QSize &value)
Definition: vdxfengine.cpp:410
QSize size
Definition: vdxfengine.h:97
virtual bool end() Q_DECL_OVERRIDE
Definition: vdxfengine.cpp:119
void ExportAAMAGrainline(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail)
Definition: vdxfengine.cpp:735
QSize getSize() const
Definition: vdxfengine.cpp:404
QTransform transform
Definition: vdxfengine.h:102
DRW_Text * textBuffer
Definition: vdxfengine.h:106
void ExportAAMANotch(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail)
Definition: vdxfengine.cpp:718
Q_REQUIRED_RESULT DRW_Entity * AAMAPolygon(const QVector< QPointF > &polygon, const QString &layer, bool forceClosed)
Definition: vdxfengine.cpp:780
virtual ~VDxfEngine()
Definition: vdxfengine.cpp:90
DRW::Version GetVersion() const
Definition: vdxfengine.cpp:443
void setResolution(double value)
Definition: vdxfengine.cpp:423
void ExportAAMADraw(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail)
Definition: vdxfengine.cpp:680
virtual void drawPath(const QPainterPath &path) Q_DECL_OVERRIDE
Definition: vdxfengine.cpp:142
Q_REQUIRED_RESULT double ToPixel(double val, const VarInsunits &unit) const
Definition: vdxfengine.cpp:590
Q_REQUIRED_RESULT P * CreateAAMAPolygon(const QVector< QPointF > &polygon, const QString &layer, bool forceClosed)
virtual void updateState(const QPaintEngineState &state) Q_DECL_OVERRIDE
Definition: vdxfengine.cpp:127
void ExportAAMAText(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail)
Definition: vdxfengine.cpp:749
void setInsunits(const VarInsunits &var)
Definition: vdxfengine.cpp:565
void SetVersion(DRW::Version version)
Definition: vdxfengine.cpp:449
void setFileName(const QString &value)
Definition: vdxfengine.cpp:436
virtual Type type() const Q_DECL_OVERRIDE
Definition: vdxfengine.cpp:389
VarInsunits varInsunits
Definition: vdxfengine.h:105
Q_REQUIRED_RESULT DRW_Entity * AAMALine(const QLineF &line, const QString &layer)
Definition: vdxfengine.cpp:798
VarMeasurement
Definition: dxfdef.h:61
VarInsunits
Definition: dxfdef.h:64