diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index aebac0ed6..54dbaded1 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -4399,7 +4399,7 @@ void MainWindow::ExportLayoutAs() return; } - ExportLayout(dialog, scenes, papers, shadows, ignorePrinterFields, margins); + ExportLayout(dialog, scenes, papers, shadows, details, ignorePrinterFields, margins); } catch (const VException &e) { diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index 54b0b3027..a6acb36f5 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -203,7 +203,7 @@ void MainWindowsNoGUI::ExportData(const QVector &listDetails, cons { if (dialog.Mode() == Draw::Layout) { - ExportLayout(dialog, scenes, papers, shadows, ignorePrinterFields, margins); + ExportLayout(dialog, scenes, papers, shadows, details, ignorePrinterFields, margins); } else { @@ -212,7 +212,9 @@ void MainWindowsNoGUI::ExportData(const QVector &listDetails, cons QList list; for (int i=0; i < listDetails.count(); ++i) { - list.append(listDetails.at(i).GetItem(dialog.IsTextAsPaths())); + QGraphicsItem *item = listDetails.at(i).GetItem(dialog.IsTextAsPaths()); + item->setPos(listDetails.at(i).GetMx(), listDetails.at(i).GetMy()); + list.append(item); } for (int i=0; i < list.size(); ++i) @@ -221,7 +223,25 @@ void MainWindowsNoGUI::ExportData(const QVector &listDetails, cons } QList papers;// Blank sheets - papers.append(new QGraphicsRectItem(scene->itemsBoundingRect().toRect())); + QRect rect = scene->itemsBoundingRect().toRect(); + + const int mx = rect.x(); + const int my = rect.y(); + + QTransform matrix; + matrix = matrix.translate(-mx, -my); + + for (int i=0; i < list.size(); ++i) + { + list.at(i)->setTransform(matrix); + } + + rect = scene->itemsBoundingRect().toRect(); + + QGraphicsRectItem *paper = new QGraphicsRectItem(rect); + paper->setPen(QPen(Qt::black, 1)); + paper->setBrush(QBrush(Qt::white)); + papers.append(paper); QList > details;// All details details.append(list); @@ -230,8 +250,9 @@ void MainWindowsNoGUI::ExportData(const QVector &listDetails, cons QList scenes = CreateScenes(papers, shadows, details); const bool ignorePrinterFields = false; - const qreal margin = ToPixel(2, Unit::Mm); - ExportLayout(dialog, scenes, papers, shadows, ignorePrinterFields, QMarginsF(margin, margin, margin, margin)); + const qreal margin = ToPixel(1, Unit::Cm); + ExportLayout(dialog, scenes, papers, shadows, details, ignorePrinterFields, + QMarginsF(margin, margin, margin, margin)); qDeleteAll(scenes);//Scene will clear all other items } @@ -240,7 +261,8 @@ void MainWindowsNoGUI::ExportData(const QVector &listDetails, cons //--------------------------------------------------------------------------------------------------------------------- void MainWindowsNoGUI::ExportLayout(const DialogSaveLayout &dialog, const QList &scenes, const QList &papers, const QList &shadows, - bool ignorePrinterFields, const QMarginsF &margins) + const QList > &details, bool ignorePrinterFields, + const QMarginsF &margins) { const QString path = dialog.Path(); bool usedNotExistedDir = false; @@ -328,47 +350,47 @@ void MainWindowsNoGUI::ExportLayout(const DialogSaveLayout &dialog, const QList< break; case LayoutExportFormats::DXF_AC1006_Flat: paper->setVisible(false); - DxfFile(name, DRW::AC1006, dialog.IsBinaryDXFFormat(), paper, scene); + DxfFile(name, DRW::AC1006, dialog.IsBinaryDXFFormat(), paper, scene, details); paper->setVisible(true); break; case LayoutExportFormats::DXF_AC1009_Flat: paper->setVisible(false); - DxfFile(name, DRW::AC1009, dialog.IsBinaryDXFFormat(), paper, scene); + DxfFile(name, DRW::AC1009, dialog.IsBinaryDXFFormat(), paper, scene, details); paper->setVisible(true); break; case LayoutExportFormats::DXF_AC1012_Flat: paper->setVisible(false); - DxfFile(name, DRW::AC1012, dialog.IsBinaryDXFFormat(), paper, scene); + DxfFile(name, DRW::AC1012, dialog.IsBinaryDXFFormat(), paper, scene, details); paper->setVisible(true); break; case LayoutExportFormats::DXF_AC1014_Flat: paper->setVisible(false); - DxfFile(name, DRW::AC1014, dialog.IsBinaryDXFFormat(), paper, scene); + DxfFile(name, DRW::AC1014, dialog.IsBinaryDXFFormat(), paper, scene, details); paper->setVisible(true); break; case LayoutExportFormats::DXF_AC1015_Flat: paper->setVisible(false); - DxfFile(name, DRW::AC1015, dialog.IsBinaryDXFFormat(), paper, scene); + DxfFile(name, DRW::AC1015, dialog.IsBinaryDXFFormat(), paper, scene, details); paper->setVisible(true); break; case LayoutExportFormats::DXF_AC1018_Flat: paper->setVisible(false); - DxfFile(name, DRW::AC1018, dialog.IsBinaryDXFFormat(), paper, scene); + DxfFile(name, DRW::AC1018, dialog.IsBinaryDXFFormat(), paper, scene, details); paper->setVisible(true); break; case LayoutExportFormats::DXF_AC1021_Flat: paper->setVisible(false); - DxfFile(name, DRW::AC1021, dialog.IsBinaryDXFFormat(), paper, scene); + DxfFile(name, DRW::AC1021, dialog.IsBinaryDXFFormat(), paper, scene, details); paper->setVisible(true); break; case LayoutExportFormats::DXF_AC1024_Flat: paper->setVisible(false); - DxfFile(name, DRW::AC1024, dialog.IsBinaryDXFFormat(), paper, scene); + DxfFile(name, DRW::AC1024, dialog.IsBinaryDXFFormat(), paper, scene, details); paper->setVisible(true); break; case LayoutExportFormats::DXF_AC1027_Flat: paper->setVisible(false); - DxfFile(name, DRW::AC1027, dialog.IsBinaryDXFFormat(), paper, scene); + DxfFile(name, DRW::AC1027, dialog.IsBinaryDXFFormat(), paper, scene, details); paper->setVisible(true); break; default: @@ -773,19 +795,26 @@ void MainWindowsNoGUI::PdfFile(const QString &name, QGraphicsRectItem *paper, QG printer.setDocName(FileName()); const QRectF r = paper->rect(); printer.setResolution(static_cast(PrintDPI)); - // Set orientation - if (paper->rect().height()>= paper->rect().width()) - { - printer.setOrientation(QPrinter::Portrait); - } - else - { - printer.setOrientation(QPrinter::Landscape); - } + printer.setOrientation(QPrinter::Portrait); printer.setFullPage(ignorePrinterFields); printer.setPaperSize ( QSizeF(FromPixel(r.width() + margins.left() + margins.right(), Unit::Mm), FromPixel(r.height() + margins.top() + margins.bottom(), Unit::Mm)), QPrinter::Millimeter ); + + const qreal left = FromPixel(margins.left(), Unit::Mm); + const qreal top = FromPixel(margins.top(), Unit::Mm); + const qreal right = FromPixel(margins.right(), Unit::Mm); + const qreal bottom = FromPixel(margins.bottom(), Unit::Mm); +#if QT_VERSION >= QT_VERSION_CHECK(5, 3, 0) + const bool success = printer.setPageMargins(QMarginsF(left, top, right, bottom), QPageLayout::Millimeter); + if (not success) + { + qWarning() << tr("Cannot set printer margins"); + } +#else + printer.setPageMargins(left, top, right, bottom, QPrinter::Millimeter); +#endif //QT_VERSION >= QT_VERSION_CHECK(5, 3, 0) + QPainter painter; if (painter.begin( &printer ) == false) { // failed to open file @@ -915,9 +944,9 @@ QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wswitch-default") void MainWindowsNoGUI::DxfFile(const QString &name, int version, bool binary, QGraphicsRectItem *paper, - QGraphicsScene *scene) const + QGraphicsScene *scene, const QList > &details) const { - PrepareTextForDXF(endStringPlaceholder); + PrepareTextForDXF(endStringPlaceholder, details); VDxfPaintDevice generator; generator.setFileName(name); generator.setSize(paper->rect().size().toSize()); @@ -948,7 +977,7 @@ void MainWindowsNoGUI::DxfFile(const QString &name, int version, bool binary, QG scene->render(&painter, paper->rect(), paper->rect(), Qt::IgnoreAspectRatio); painter.end(); } - RestoreTextAfterDXF(endStringPlaceholder); + RestoreTextAfterDXF(endStringPlaceholder, details); } QT_WARNING_POP @@ -990,14 +1019,15 @@ void MainWindowsNoGUI::RestorePaper(int index) const * * @param placeholder placeholder that will be appended to each QGraphicsSimpleTextItem item's text string. */ -void MainWindowsNoGUI::PrepareTextForDXF(const QString &placeholder) const +void MainWindowsNoGUI::PrepareTextForDXF(const QString &placeholder, + const QList > &details) const { for (int i = 0; i < details.size(); ++i) { const QList &paperItems = details.at(i); for (int j = 0; j < paperItems.size(); ++j) { - QList pieceChildren = paperItems.at(i)->childItems(); + QList pieceChildren = paperItems.at(j)->childItems(); for (int k = 0; k < pieceChildren.size(); ++k) { QGraphicsItem *item = pieceChildren.at(k); @@ -1022,7 +1052,8 @@ void MainWindowsNoGUI::PrepareTextForDXF(const QString &placeholder) const * * @param placeholder placeholder that will be removed from each QGraphicsSimpleTextItem item's text string. */ -void MainWindowsNoGUI::RestoreTextAfterDXF(const QString &placeholder) const +void MainWindowsNoGUI::RestoreTextAfterDXF(const QString &placeholder, + const QList > &details) const { for (int i = 0; i < details.size(); ++i) { @@ -1119,16 +1150,7 @@ void MainWindowsNoGUI::SetPrinterSettings(QPrinter *printer, const PrintType &pr { SCASSERT(printer != nullptr) printer->setCreator(QGuiApplication::applicationDisplayName()+" "+QCoreApplication::applicationVersion()); - - // Set orientation - if (paperSize.height() >= paperSize.width()) - { - printer->setOrientation(QPrinter::Portrait); - } - else - { - printer->setOrientation(QPrinter::Landscape); - } + printer->setOrientation(QPrinter::Portrait); if (not isTiled) { diff --git a/src/app/valentina/mainwindowsnogui.h b/src/app/valentina/mainwindowsnogui.h index 9cd8cc594..d2e162a64 100644 --- a/src/app/valentina/mainwindowsnogui.h +++ b/src/app/valentina/mainwindowsnogui.h @@ -96,6 +96,7 @@ protected: const QList &scenes, const QList &papers, const QList &shadows, + const QList > &details, bool ignorePrinterFields, const QMarginsF &margins); void InitTempLayoutScene(); @@ -133,13 +134,14 @@ private: const QMarginsF &margins)const; void PdfToPs(const QStringList ¶ms)const; void ObjFile(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene)const; - void DxfFile(const QString &name, int version, bool binary, QGraphicsRectItem *paper, QGraphicsScene *scene)const; + void DxfFile(const QString &name, int version, bool binary, QGraphicsRectItem *paper, QGraphicsScene *scene, + const QList > &details)const; void PreparePaper(int index) const; void RestorePaper(int index) const; - void PrepareTextForDXF(const QString &placeholder) const; - void RestoreTextAfterDXF(const QString &placeholder) const; + void PrepareTextForDXF(const QString &placeholder, const QList > &details) const; + void RestoreTextAfterDXF(const QString &placeholder, const QList > &details) const; void PrintPreview(); void LayoutPrint(); diff --git a/src/libs/vdxf/dxiface.cpp b/src/libs/vdxf/dxiface.cpp index d4f44aefa..61e8e2ea6 100644 --- a/src/libs/vdxf/dxiface.cpp +++ b/src/libs/vdxf/dxiface.cpp @@ -242,7 +242,7 @@ void dx_iface::InitLayers() DRW_Layer defLayer; defLayer.name = "0"; defLayer.color = DRW::black; // default color - defLayer.lWeight = DRW_LW_Conv::width17; // default width + defLayer.lWeight = DRW_LW_Conv::width03; // default width defLayer.lineType = "CONTINUOUS"; // default line style cData.layers.push_back(defLayer); diff --git a/src/libs/vlayout/vabstractpiece.cpp b/src/libs/vlayout/vabstractpiece.cpp index b90804175..dea8832d8 100644 --- a/src/libs/vlayout/vabstractpiece.cpp +++ b/src/libs/vlayout/vabstractpiece.cpp @@ -980,6 +980,30 @@ bool VAbstractPiece::IsEkvPointOnLine(const VSAPoint &iPoint, const VSAPoint &pr && qAbs(prevPoint.GetSAAfter(tmpWidth) - nextPoint.GetSABefore(tmpWidth)) < VGObject::accuracyPointOnLine); } +//--------------------------------------------------------------------------------------------------------------------- +qreal VAbstractPiece::GetMx() const +{ + return d->m_mx; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractPiece::SetMx(qreal value) +{ + d->m_mx = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal VAbstractPiece::GetMy() const +{ + return d->m_my; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractPiece::SetMy(qreal value) +{ + d->m_my = value; +} + //--------------------------------------------------------------------------------------------------------------------- qreal VSAPoint::GetSABefore(qreal width) const { diff --git a/src/libs/vlayout/vabstractpiece.h b/src/libs/vlayout/vabstractpiece.h index 1fcfd666d..5e82d3234 100644 --- a/src/libs/vlayout/vabstractpiece.h +++ b/src/libs/vlayout/vabstractpiece.h @@ -171,6 +171,12 @@ public: qreal GetSAWidth() const; void SetSAWidth(qreal value); + qreal GetMx() const; + void SetMx(qreal value); + + qreal GetMy() const; + void SetMy(qreal value); + static QVector Equidistant(const QVector &points, qreal width); static qreal SumTrapezoids(const QVector &points); static QVector CheckLoops(const QVector &points); diff --git a/src/libs/vlayout/vabstractpiece_p.h b/src/libs/vlayout/vabstractpiece_p.h index fa96dcdfb..adc280a6d 100644 --- a/src/libs/vlayout/vabstractpiece_p.h +++ b/src/libs/vlayout/vabstractpiece_p.h @@ -49,7 +49,9 @@ public: m_seamAllowance(false), m_seamAllowanceBuiltIn(false), m_hideMainPath(false), - m_width(0) + m_width(0), + m_mx(0), + m_my(0) {} VAbstractPieceData(const VAbstractPieceData &piece) @@ -59,7 +61,9 @@ public: m_seamAllowance(piece.m_seamAllowance), m_seamAllowanceBuiltIn(piece.m_seamAllowanceBuiltIn), m_hideMainPath(piece.m_hideMainPath), - m_width(piece.m_width) + m_width(piece.m_width), + m_mx(piece.m_mx), + m_my(piece.m_my) {} ~VAbstractPieceData() Q_DECL_EQ_DEFAULT; @@ -71,6 +75,8 @@ public: bool m_seamAllowanceBuiltIn; bool m_hideMainPath; qreal m_width; + qreal m_mx; + qreal m_my; private: VAbstractPieceData &operator=(const VAbstractPieceData &) Q_DECL_EQ_DELETE; diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index 6f6c704c7..da5721deb 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -368,6 +368,10 @@ VLayoutPiece::~VLayoutPiece() VLayoutPiece VLayoutPiece::Create(const VPiece &piece, const VContainer *pattern) { VLayoutPiece det; + + det.SetMx(piece.GetMx()); + det.SetMy(piece.GetMy()); + det.SetCountourPoints(piece.MainPathPoints(pattern), piece.IsHideMainPath()); det.SetSeamAllowancePoints(piece.SeamAllowancePoints(pattern), piece.IsSeamAllowance(), piece.IsSeamAllowanceBuiltIn()); diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index c5bdec7b3..ffefc4cf2 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -505,30 +505,6 @@ QPainterPath VPiece::PassmarksPath(const VContainer *data) const return path; } -//--------------------------------------------------------------------------------------------------------------------- -qreal VPiece::GetMx() const -{ - return d->m_mx; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPiece::SetMx(qreal value) -{ - d->m_mx = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -qreal VPiece::GetMy() const -{ - return d->m_my; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPiece::SetMy(qreal value) -{ - d->m_my = value; -} - //--------------------------------------------------------------------------------------------------------------------- bool VPiece::IsInLayout() const { diff --git a/src/libs/vpatterndb/vpiece.h b/src/libs/vpatterndb/vpiece.h index d2b1e7c55..830275322 100644 --- a/src/libs/vpatterndb/vpiece.h +++ b/src/libs/vpatterndb/vpiece.h @@ -75,12 +75,6 @@ public: QPainterPath SeamAllowancePath(const VContainer *data) const; QPainterPath PassmarksPath(const VContainer *data) const; - qreal GetMx() const; - void SetMx(qreal value); - - qreal GetMy() const; - void SetMy(qreal value); - bool IsInLayout() const; void SetInLayout(bool inLayout); diff --git a/src/libs/vpatterndb/vpiece_p.h b/src/libs/vpatterndb/vpiece_p.h index 0c4f8d918..e0ecf3814 100644 --- a/src/libs/vpatterndb/vpiece_p.h +++ b/src/libs/vpatterndb/vpiece_p.h @@ -49,8 +49,6 @@ class VPieceData : public QSharedData public: explicit VPieceData(PiecePathType type) : m_path(type), - m_mx(0), - m_my(0), m_inLayout(true), m_united(false), m_customSARecords(), @@ -65,8 +63,6 @@ public: VPieceData(const VPieceData &detail) : QSharedData(detail), m_path(detail.m_path), - m_mx(detail.m_mx), - m_my(detail.m_my), m_inLayout(detail.m_inLayout), m_united(detail.m_united), m_customSARecords(detail.m_customSARecords), @@ -83,9 +79,6 @@ public: /** @brief nodes list detail nodes. */ VPiecePath m_path; - qreal m_mx; - qreal m_my; - bool m_inLayout; bool m_united;