2015-09-07 21:47:02 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vdxfengine.h
|
|
|
|
** @author Valentina Zhuravska <zhuravska19(at)gmail.com>
|
|
|
|
** @date 12 8, 2015
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2015-09-07 21:47:02 +02:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
2020-01-31 07:00:05 +01:00
|
|
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
2015-09-07 21:47:02 +02:00
|
|
|
**
|
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation, either version 3 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#ifndef VDXFENGINE_H
|
|
|
|
#define VDXFENGINE_H
|
|
|
|
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <qcompilerdetection.h>
|
|
|
|
#include <QMatrix>
|
2015-09-07 21:47:02 +02:00
|
|
|
#include <QPaintEngine>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QPointF>
|
|
|
|
#include <QRectF>
|
|
|
|
#include <QSize>
|
|
|
|
#include <QString>
|
|
|
|
#include <QtGlobal>
|
|
|
|
#include <string>
|
|
|
|
|
2015-09-07 21:47:02 +02:00
|
|
|
#include "../vmisc/def.h"
|
|
|
|
#include "dxfdef.h"
|
2017-06-21 11:34:20 +02:00
|
|
|
#include "libdxfrw/drw_base.h"
|
2015-09-07 21:47:02 +02:00
|
|
|
|
|
|
|
class QTextStream;
|
2017-06-21 11:34:20 +02:00
|
|
|
class dx_iface;
|
2017-06-29 17:56:52 +02:00
|
|
|
class DRW_Text;
|
2017-07-16 20:10:48 +02:00
|
|
|
class VLayoutPiece;
|
|
|
|
class DRW_Entity;
|
|
|
|
class dx_ifaceBlock;
|
2015-09-07 21:47:02 +02:00
|
|
|
|
2021-09-25 10:43:05 +02:00
|
|
|
class VDxfEngine final : public QPaintEngine
|
2015-09-07 21:47:02 +02:00
|
|
|
{
|
2017-07-16 20:10:48 +02:00
|
|
|
friend class VDxfPaintDevice;
|
2015-09-07 21:47:02 +02:00
|
|
|
public:
|
|
|
|
VDxfEngine();
|
2017-06-29 17:56:52 +02:00
|
|
|
virtual ~VDxfEngine();
|
2015-09-07 21:47:02 +02:00
|
|
|
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual bool begin(QPaintDevice *pdev) override;
|
|
|
|
virtual bool end() override;
|
|
|
|
virtual void updateState(const QPaintEngineState &state) override;
|
|
|
|
virtual void drawPath(const QPainterPath &path) override;
|
|
|
|
virtual void drawLines(const QLineF * lines, int lineCount) override;
|
|
|
|
virtual void drawLines(const QLine * lines, int lineCount) override;
|
|
|
|
virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) override;
|
|
|
|
virtual void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode) override;
|
|
|
|
virtual void drawEllipse(const QRectF & rect) override;
|
|
|
|
virtual void drawEllipse(const QRect & rect) override;
|
|
|
|
virtual void drawTextItem(const QPointF & p, const QTextItem & textItem) override;
|
|
|
|
virtual Type type() const override;
|
|
|
|
virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) override;
|
2015-09-07 21:47:02 +02:00
|
|
|
|
|
|
|
QSize getSize() const;
|
|
|
|
void setSize(const QSize &value);
|
|
|
|
|
2016-03-27 18:00:08 +02:00
|
|
|
double getResolution() const;
|
|
|
|
void setResolution(double value);
|
2015-09-07 21:47:02 +02:00
|
|
|
|
|
|
|
QString getFileName() const;
|
|
|
|
void setFileName(const QString &value);
|
|
|
|
|
2017-06-21 11:34:20 +02:00
|
|
|
DRW::Version GetVersion() const;
|
|
|
|
void SetVersion(DRW::Version version);
|
|
|
|
|
2017-06-26 16:28:41 +02:00
|
|
|
void SetBinaryFormat(bool binary);
|
|
|
|
bool IsBinaryFormat() const;
|
|
|
|
|
2015-09-07 21:47:02 +02:00
|
|
|
std::string getPenStyle();
|
|
|
|
int getPenColor();
|
|
|
|
|
|
|
|
void setMeasurement(const VarMeasurement &var);
|
|
|
|
void setInsunits(const VarInsunits &var);
|
|
|
|
|
2020-03-21 17:15:29 +01:00
|
|
|
qreal GetXScale() const;
|
|
|
|
void SetXScale(const qreal &xscale);
|
|
|
|
|
|
|
|
qreal GetYScale() const;
|
|
|
|
void SetYScale(const qreal &yscale);
|
|
|
|
|
2021-04-28 19:06:24 +02:00
|
|
|
QString ErrorString() const;
|
|
|
|
|
2015-09-07 21:47:02 +02:00
|
|
|
private:
|
2022-08-12 17:50:13 +02:00
|
|
|
Q_DISABLE_COPY_MOVE(VDxfEngine) // NOLINT
|
2015-09-07 21:47:02 +02:00
|
|
|
QSize size;
|
2016-03-27 18:00:08 +02:00
|
|
|
double resolution;
|
2015-09-07 21:47:02 +02:00
|
|
|
QString fileName;
|
2017-06-21 11:34:20 +02:00
|
|
|
DRW::Version m_version;
|
2017-06-26 16:28:41 +02:00
|
|
|
bool m_binary;
|
2020-07-07 09:51:00 +02:00
|
|
|
QTransform matrix;
|
2017-06-21 11:34:20 +02:00
|
|
|
QSharedPointer<dx_iface> input;
|
2015-09-07 21:47:02 +02:00
|
|
|
VarMeasurement varMeasurement;
|
|
|
|
VarInsunits varInsunits;
|
2017-06-29 17:56:52 +02:00
|
|
|
DRW_Text *textBuffer;
|
2020-03-21 17:15:29 +01:00
|
|
|
qreal m_xscale{1};
|
|
|
|
qreal m_yscale{1};
|
2015-09-07 21:47:02 +02:00
|
|
|
|
2017-07-01 20:38:26 +02:00
|
|
|
Q_REQUIRED_RESULT double FromPixel(double pix, const VarInsunits &unit) const;
|
2017-07-16 20:10:48 +02:00
|
|
|
Q_REQUIRED_RESULT double ToPixel(double val, const VarInsunits &unit) const;
|
|
|
|
|
|
|
|
bool ExportToAAMA(const QVector<VLayoutPiece> &details);
|
|
|
|
void ExportAAMAOutline(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail);
|
|
|
|
void ExportAAMADraw(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail);
|
|
|
|
void ExportAAMAIntcut(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail);
|
|
|
|
void ExportAAMANotch(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail);
|
|
|
|
void ExportAAMAGrainline(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail);
|
2020-03-15 12:35:31 +01:00
|
|
|
void ExportPieceText(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail);
|
|
|
|
void ExportStyleSystemText(const QSharedPointer<dx_iface> &input, const QVector<VLayoutPiece> &details);
|
2017-10-15 11:25:20 +02:00
|
|
|
void ExportAAMADrill(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail);
|
2017-07-16 20:10:48 +02:00
|
|
|
|
2020-03-15 12:35:31 +01:00
|
|
|
bool ExportToASTM(const QVector<VLayoutPiece> &details);
|
|
|
|
void ExportASTMPieceBoundary(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail);
|
|
|
|
void ExportASTMSewLine(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail);
|
|
|
|
void ExportASTMInternalLine(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail);
|
|
|
|
void ExportASTMInternalCutout(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail);
|
|
|
|
void ExportASTMAnnotationText(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail);
|
|
|
|
void ExportASTMDrill(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail);
|
|
|
|
void ExportASTMNotch(dx_ifaceBlock *detailBlock, const VLayoutPiece &detail);
|
|
|
|
|
2017-07-16 20:10:48 +02:00
|
|
|
Q_REQUIRED_RESULT DRW_Entity *AAMAPolygon(const QVector<QPointF> &polygon, const QString &layer, bool forceClosed);
|
|
|
|
Q_REQUIRED_RESULT DRW_Entity *AAMALine(const QLineF &line, const QString &layer);
|
|
|
|
Q_REQUIRED_RESULT DRW_Entity *AAMAText(const QPointF &pos, const QString &text, const QString &layer);
|
|
|
|
|
|
|
|
template<class P, class V>
|
|
|
|
Q_REQUIRED_RESULT P *CreateAAMAPolygon(const QVector<QPointF> &polygon, const QString &layer, bool forceClosed);
|
2018-07-16 19:00:42 +02:00
|
|
|
|
|
|
|
static std::string FromUnicodeToCodec(const QString &str, QTextCodec *codec);
|
|
|
|
std::string getFileNameForLocale() const;
|
2015-09-07 21:47:02 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VDXFENGINE_H
|