Improve flipping control. Export from Details mode also should obey this rule.

ref #783.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2018-02-03 15:29:23 +02:00
parent 8b7494fb08
commit 14d5cf25ad
3 changed files with 35 additions and 6 deletions

View File

@ -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<VLayoutPiece> &li
QList<QGraphicsItem *> 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<VLayoutPiece> listDe
QList<QGraphicsItem *> 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)

View File

@ -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
{

View File

@ -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;