2015-09-07 21:47:02 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vdxfpaintdevice.cpp
|
|
|
|
** @author Valentina Zhuravska <zhuravska19(at)gmail.com>
|
|
|
|
** @date 12 812, 2015
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
|
|
|
** This source code is part of the Valentine project, a pattern making
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
|
|
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
|
|
|
**
|
|
|
|
** 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/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#include "vdxfpaintdevice.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
|
|
|
|
#include <QMessageLogger>
|
|
|
|
#include <QtDebug>
|
|
|
|
|
2015-09-07 21:47:02 +02:00
|
|
|
#include "vdxfengine.h"
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VDxfPaintDevice::VDxfPaintDevice()
|
|
|
|
:QPaintDevice(), engine(new VDxfEngine()), fileName()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VDxfPaintDevice::~VDxfPaintDevice()
|
|
|
|
{
|
|
|
|
delete engine;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
// cppcheck-suppress unusedFunction
|
|
|
|
QPaintEngine *VDxfPaintDevice::paintEngine() const
|
|
|
|
{
|
|
|
|
return engine;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
// cppcheck-suppress unusedFunction
|
|
|
|
QString VDxfPaintDevice::getFileName() const
|
|
|
|
{
|
|
|
|
return fileName;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VDxfPaintDevice::setFileName(const QString &value)
|
|
|
|
{
|
|
|
|
if (engine->isActive())
|
|
|
|
{
|
|
|
|
qWarning("VDxfPaintDevice::setFileName(), cannot set file name while Dxf is being generated");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fileName = value;
|
|
|
|
engine->setFileName(fileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
QSize VDxfPaintDevice::getSize()
|
|
|
|
{
|
|
|
|
return engine->getSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VDxfPaintDevice::setSize(const QSize &size)
|
|
|
|
{
|
|
|
|
if (engine->isActive())
|
|
|
|
{
|
|
|
|
qWarning("VDxfPaintDevice::setSize(), cannot set size while Dxf is being generated");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
engine->setSize(size);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-03-27 18:00:08 +02:00
|
|
|
double VDxfPaintDevice::getResolution() const
|
2015-09-07 21:47:02 +02:00
|
|
|
{
|
|
|
|
return engine->getResolution();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-03-27 18:00:08 +02:00
|
|
|
void VDxfPaintDevice::setResolution(double dpi)
|
2015-09-07 21:47:02 +02:00
|
|
|
{
|
2017-06-26 16:28:41 +02:00
|
|
|
if (engine->isActive())
|
|
|
|
{
|
|
|
|
qWarning("VDxfPaintDevice::setResolution(), cannot set dpi while Dxf is being generated");
|
|
|
|
return;
|
|
|
|
}
|
2015-09-07 21:47:02 +02:00
|
|
|
engine->setResolution(dpi);
|
|
|
|
}
|
|
|
|
|
2017-06-26 16:28:41 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
DRW::Version VDxfPaintDevice::GetVersion() const
|
|
|
|
{
|
|
|
|
return engine->GetVersion();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VDxfPaintDevice::SetVersion(DRW::Version version)
|
|
|
|
{
|
|
|
|
if (engine->isActive())
|
|
|
|
{
|
|
|
|
qWarning("VDxfPaintDevice::SetVersion(), cannot set version while Dxf is being generated");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
engine->SetVersion(version);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VDxfPaintDevice::SetBinaryFormat(bool binary)
|
|
|
|
{
|
|
|
|
if (engine->isActive())
|
|
|
|
{
|
|
|
|
qWarning("VDxfPaintDevice::SetBinaryFormat(), cannot set binary format while Dxf is being generated");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
engine->SetBinaryFormat(binary);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VDxfPaintDevice::IsBinaryFromat() const
|
|
|
|
{
|
|
|
|
return engine->IsBinaryFormat();
|
|
|
|
}
|
|
|
|
|
2015-09-07 21:47:02 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VDxfPaintDevice::setMeasurement(const VarMeasurement &var)
|
|
|
|
{
|
2017-06-26 16:28:41 +02:00
|
|
|
if (engine->isActive())
|
|
|
|
{
|
|
|
|
qWarning("VDxfPaintDevice::setMeasurement(), cannot set measurements while Dxf is being generated");
|
|
|
|
return;
|
|
|
|
}
|
2015-09-07 21:47:02 +02:00
|
|
|
engine->setMeasurement(var);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VDxfPaintDevice::setInsunits(const VarInsunits &var)
|
|
|
|
{
|
2017-06-26 16:28:41 +02:00
|
|
|
if (engine->isActive())
|
|
|
|
{
|
|
|
|
qWarning("VDxfPaintDevice::setInsunits(), cannot set units while Dxf is being generated");
|
|
|
|
return;
|
|
|
|
}
|
2015-09-07 21:47:02 +02:00
|
|
|
engine->setInsunits(var);
|
|
|
|
}
|
|
|
|
|
2017-07-16 20:10:48 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool VDxfPaintDevice::ExportToAAMA(const QVector<VLayoutPiece> &details) const
|
|
|
|
{
|
|
|
|
engine->setActive(true);
|
|
|
|
const bool res = engine->ExportToAAMA(details);
|
|
|
|
engine->setActive(false);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2015-09-07 21:47:02 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
int VDxfPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const
|
|
|
|
{
|
|
|
|
switch (metric)
|
|
|
|
{
|
|
|
|
case QPaintDevice::PdmDepth:
|
|
|
|
return 32;
|
|
|
|
case QPaintDevice::PdmWidth:
|
|
|
|
return engine->getSize().width();
|
|
|
|
case QPaintDevice::PdmHeight:
|
|
|
|
return engine->getSize().height();
|
|
|
|
case QPaintDevice::PdmHeightMM:
|
|
|
|
return qRound(engine->getSize().height() * 25.4 / engine->getResolution());
|
|
|
|
case QPaintDevice::PdmWidthMM:
|
|
|
|
return qRound(engine->getSize().width() * 25.4 / engine->getResolution());
|
|
|
|
case QPaintDevice::PdmNumColors:
|
|
|
|
return static_cast<int>(0xffffffff);
|
|
|
|
case QPaintDevice::PdmPhysicalDpiX:
|
|
|
|
case QPaintDevice::PdmPhysicalDpiY:
|
2016-12-21 20:35:07 +01:00
|
|
|
case QPaintDevice::PdmDpiX:
|
|
|
|
case QPaintDevice::PdmDpiY:
|
2016-03-27 18:00:08 +02:00
|
|
|
return static_cast<int>(engine->getResolution());
|
2015-09-07 21:47:02 +02:00
|
|
|
case QPaintDevice::PdmDevicePixelRatio:
|
2016-11-19 09:07:02 +01:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
|
|
|
|
case QPaintDevice::PdmDevicePixelRatioScaled:
|
|
|
|
#endif
|
2015-09-07 21:47:02 +02:00
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
qWarning("VDxfPaintDevice::metric(), unhandled metric %d\n", metric);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|