From 14d5cf25adddaf893b8b3a88fee15f1107b83492 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 3 Feb 2018 15:29:23 +0200 Subject: [PATCH] Improve flipping control. Export from Details mode also should obey this rule. ref #783. --HG-- branch : develop --- src/app/valentina/mainwindowsnogui.cpp | 31 +++++++++++++++++++++----- src/libs/vlayout/vlayoutpiece.cpp | 9 ++++++++ src/libs/vlayout/vlayoutpiece.h | 1 + 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index 35ac34fbe..3b8b704b2 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -66,6 +66,7 @@ namespace { +//--------------------------------------------------------------------------------------------------------------------- bool CreateLayoutPath(const QString &path) { bool usedNotExistedDir = true; @@ -78,6 +79,7 @@ bool CreateLayoutPath(const QString &path) return usedNotExistedDir; } +//--------------------------------------------------------------------------------------------------------------------- void RemoveLayoutPath(const QString &path, bool usedNotExistedDir) { if (usedNotExistedDir) @@ -86,6 +88,27 @@ void RemoveLayoutPath(const QString &path, bool usedNotExistedDir) dir.rmpath("."); } } + +//--------------------------------------------------------------------------------------------------------------------- +Q_REQUIRED_RESULT QGraphicsItem *ExportOriginalDetail(VLayoutPiece piece, bool textAsPaths) +{ + if (piece.IsForceFlipping()) + { + piece.Mirror(); + } + + QGraphicsItem *item = piece.GetItem(textAsPaths); + + if (piece.IsForceFlipping()) + { + item->setPos(piece.GetMx()-item->boundingRect().width(), piece.GetMy()); + } + else + { + item->setPos(piece.GetMx(), piece.GetMy()); + } + return item; +} } //--------------------------------------------------------------------------------------------------------------------- @@ -344,9 +367,7 @@ void MainWindowsNoGUI::ExportDetailsAsFlatLayout(const QVector &li QList list; for (int i=0; i < listDetails.count(); ++i) { - QGraphicsItem *item = listDetails.at(i).GetItem(m_dialogSaveLayout->IsTextAsPaths()); - item->setPos(listDetails.at(i).GetMx(), listDetails.at(i).GetMy()); - list.append(item); + list.append(ExportOriginalDetail(listDetails.at(i), m_dialogSaveLayout->IsTextAsPaths())); } for (int i=0; i < list.size(); ++i) @@ -464,9 +485,7 @@ void MainWindowsNoGUI::ExportDetailsAsApparelLayout(QVector listDe QList list; for (int i=0; i < listDetails.count(); ++i) { - QGraphicsItem *item = listDetails.at(i).GetItem(m_dialogSaveLayout->IsTextAsPaths()); - item->setPos(listDetails.at(i).GetMx(), listDetails.at(i).GetMy()); - list.append(item); + list.append(ExportOriginalDetail(listDetails.at(i), m_dialogSaveLayout->IsTextAsPaths())); } for (int i=0; i < list.size(); ++i) diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index 000fd2151..4489d7568 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -777,6 +777,15 @@ void VLayoutPiece::Mirror(const QLineF &edge) d->mirror = !d->mirror; } +//--------------------------------------------------------------------------------------------------------------------- +void VLayoutPiece::Mirror() +{ + QTransform m; + m.scale(-1, 1); + d->matrix *= m; + d->mirror = !d->mirror; +} + //--------------------------------------------------------------------------------------------------------------------- int VLayoutPiece::DetailEdgesCount() const { diff --git a/src/libs/vlayout/vlayoutpiece.h b/src/libs/vlayout/vlayoutpiece.h index 05a9f96b7..396b0b8ad 100644 --- a/src/libs/vlayout/vlayoutpiece.h +++ b/src/libs/vlayout/vlayoutpiece.h @@ -117,6 +117,7 @@ public: void Translate(qreal dx, qreal dy); void Rotate(const QPointF &originPoint, qreal degrees); void Mirror(const QLineF &edge); + void Mirror(); int DetailEdgesCount() const; int LayoutEdgesCount() const;