New section "Custom seam allowance".

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-11-28 10:47:36 +02:00
parent 9c3a49e43f
commit fea2ec52fe
14 changed files with 623 additions and 114 deletions

View file

@ -695,6 +695,7 @@ struct CustomSARecord
bool reverse;
};
Q_DECLARE_METATYPE(CustomSARecord)
Q_DECLARE_TYPEINFO(CustomSARecord, Q_MOVABLE_TYPE);
/****************************************************************************

View file

@ -252,36 +252,7 @@ void VPiece::SetCustomSARecords(const QVector<CustomSARecord> &records)
*/
QVector<quint32> VPiece::MissingNodes(const VPiece &det) const
{
const QVector<VPieceNode> pNodes = d->m_path.GetNodes();
if (pNodes.size() == det.GetPath().CountNodes()) //-V807
{
return QVector<quint32>();
}
QSet<quint32> set1;
for (qint32 i = 0; i < pNodes.size(); ++i)
{
set1.insert(pNodes.at(i).GetId());
}
QSet<quint32> set2;
for (qint32 j = 0; j < det.GetPath().CountNodes(); ++j)
{
set2.insert(det.GetPath().at(j).GetId());
}
const QList<quint32> set3 = set1.subtract(set2).toList();
QVector<quint32> nodes;
for (qint32 i = 0; i < set3.size(); ++i)
{
const int index = indexOfNode(pNodes, set3.at(i));
if (index != -1)
{
nodes.append(pNodes.at(index).GetId());
}
}
return nodes;
return d->m_path.MissingNodes(det.GetPath());
}
//---------------------------------------------------------------------------------------------------------------------
@ -315,17 +286,6 @@ QVector<quint32> VPiece::MissingCSAPath(const VPiece &det) const
return r;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief indexOfNode return index in list node using id object.
* @param id object (arc, point, spline, splinePath) id.
* @return index in list or -1 id can't find.
*/
int VPiece::indexOfNode(const quint32 &id) const
{
return indexOfNode(d->m_path.GetNodes(), id);
}
//---------------------------------------------------------------------------------------------------------------------
void VPiece::CurveSeamAllowanceSegment(QVector<VSAPoint> &pointsEkv, const VContainer *data,
const QSharedPointer<VAbstractCurve> &curve, int i, bool reverse) const
@ -410,23 +370,3 @@ void VPiece::CurveSeamAllowanceSegment(QVector<VSAPoint> &pointsEkv, const VCont
}
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief indexOfNode return index in list node using id object.
* @param list list nodes detail.
* @param id object (arc, point, spline, splinePath) id.
* @return index in list or -1 id can't find.
*/
int VPiece::indexOfNode(const QVector<VPieceNode> &list, quint32 id)
{
for (int i = 0; i < list.size(); ++i)
{
if (list.at(i).GetId() == id)
{
return i;
}
}
qDebug()<<"Can't find node.";
return -1;
}

View file

@ -81,15 +81,11 @@ public:
QVector<quint32> MissingNodes(const VPiece &det) const;
QVector<quint32> MissingCSAPath(const VPiece &det) const;
int indexOfNode(const quint32 &id) const;
private:
QSharedDataPointer<VPieceData> d;
void CurveSeamAllowanceSegment(QVector<VSAPoint> &pointsEkv, const VContainer *data,
const QSharedPointer<VAbstractCurve> &curve, int i, bool reverse) const;
static int indexOfNode(const QVector<VPieceNode> &list, quint32 id);
};
Q_DECLARE_TYPEINFO(VPiece, Q_MOVABLE_TYPE);

View file

@ -314,3 +314,51 @@ VSAPoint VPiecePath::EndSegment(const VContainer *data, int i, bool reverse) con
}
return end;
}
//---------------------------------------------------------------------------------------------------------------------
QVector<quint32> VPiecePath::MissingNodes(const VPiecePath &path) const
{
if (d->m_nodes.size() == path.CountNodes()) //-V807
{
return QVector<quint32>();
}
QSet<quint32> set1;
for (qint32 i = 0; i < d->m_nodes.size(); ++i)
{
set1.insert(d->m_nodes.at(i).GetId());
}
QSet<quint32> set2;
for (qint32 j = 0; j < path.CountNodes(); ++j)
{
set2.insert(path.at(j).GetId());
}
const QList<quint32> set3 = set1.subtract(set2).toList();
QVector<quint32> nodes;
for (qint32 i = 0; i < set3.size(); ++i)
{
const int index = indexOfNode(set3.at(i));
if (index != -1)
{
nodes.append(d->m_nodes.at(index).GetId());
}
}
return nodes;
}
//---------------------------------------------------------------------------------------------------------------------
int VPiecePath::indexOfNode(quint32 id) const
{
for (int i = 0; i < d->m_nodes.size(); ++i)
{
if (d->m_nodes.at(i).GetId() == id)
{
return i;
}
}
qDebug()<<"Can't find node.";
return -1;
}

View file

@ -74,6 +74,10 @@ public:
VSAPoint StartSegment(const VContainer *data, int i, bool reverse) const;
VSAPoint EndSegment(const VContainer *data, int i, bool reverse) const;
QVector<quint32> MissingNodes(const VPiecePath &path) const;
int indexOfNode(quint32 id) const;
private:
QSharedDataPointer<VPiecePathData> d;
};

View file

@ -31,6 +31,8 @@
#include "../vpatterndb/vpiecenode.h"
#include "../vpatterndb/vpiecepath.h"
#include "visualization/path/vistoolpiece.h"
#include "dialogpiecepath.h"
#include "../../undocommands/savepiecepathoptions.h"
#include <QMenu>
@ -40,7 +42,8 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 &
ui(new Ui::DialogSeamAllowance),
applyAllowed(false),// By default disabled
m_mx(0),
m_my(0)
m_my(0),
m_dialog()
{
ui->setupUi(this);
@ -82,15 +85,25 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 &
connect(ui->doubleSpinBoxSAAfter, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
this, &DialogSeamAllowance::ChangedSAAfter);
ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->listWidget, &QListWidget::customContextMenuRequested, this, &DialogSeamAllowance::ShowContextMenu);
connect(ui->listWidget->model(), &QAbstractItemModel::rowsMoved, this, &DialogSeamAllowance::ListChanged);
ui->listWidgetMainPath->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->listWidgetMainPath, &QListWidget::customContextMenuRequested, this,
&DialogSeamAllowance::ShowMainPathContextMenu);
connect(ui->listWidgetMainPath->model(), &QAbstractItemModel::rowsMoved, this, &DialogSeamAllowance::ListChanged);
connect(ui->checkBoxSeams, &QCheckBox::toggled, this, &DialogSeamAllowance::EnableSeamAllowance);
InitNodeAngles();
connect(ui->comboBoxAngle, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogSeamAllowance::NodeAngleChanged);
ui->listWidgetCustomSA->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->listWidgetCustomSA, &QListWidget::customContextMenuRequested, this,
&DialogSeamAllowance::ShowCustomSAContextMenu);
connect(ui->listWidgetCustomSA, &QListWidget::currentRowChanged, this, &DialogSeamAllowance::CustomSAChanged);
connect(ui->comboBoxStartPoint, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogSeamAllowance::CSAStartPointChanged);
connect(ui->comboBoxEndPoint, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogSeamAllowance::CSAEndPointChanged);
if (not applyAllowed)
{
vis = new VisToolPiece(data);
@ -123,12 +136,31 @@ VPiece DialogSeamAllowance::GetPiece() const
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetPiece(const VPiece &piece)
{
ui->listWidget->clear();
ui->listWidgetMainPath->clear();
for (int i = 0; i < piece.GetPath().CountNodes(); ++i)
{
NewItem(piece.GetPath().at(i));
NewMainPathItem(piece.GetPath().at(i));
}
ui->listWidgetCustomSA->blockSignals(true);
ui->listWidgetCustomSA->clear();
const QVector<CustomSARecord> records = piece.GetCustomSARecords();
for (int i = 0; i < records.size(); ++i)
{
NewCustomSA(records.at(i));
}
ui->listWidgetCustomSA->blockSignals(false);
ui->comboBoxStartPoint->blockSignals(true);
ui->comboBoxStartPoint->clear();
ui->comboBoxStartPoint->blockSignals(false);
ui->comboBoxEndPoint->blockSignals(true);
ui->comboBoxEndPoint->clear();
ui->comboBoxEndPoint->blockSignals(false);
CustomSAChanged(0);
ui->checkBoxForbidFlipping->setChecked(piece.IsForbidFlipping());
ui->doubleSpinBoxSeams->setValue(piece.GetSAWidth());
ui->checkBoxSeams->setChecked(piece.IsSeamAllowance());
@ -159,16 +191,16 @@ void DialogSeamAllowance::ChosenObject(quint32 id, const SceneObject &type)
switch (type)
{
case SceneObject::Arc:
NewItem(VPieceNode(id, Tool::NodeArc, reverse));
NewMainPathItem(VPieceNode(id, Tool::NodeArc, reverse));
break;
case SceneObject::Point:
NewItem(VPieceNode(id, Tool::NodePoint));
NewMainPathItem(VPieceNode(id, Tool::NodePoint));
break;
case SceneObject::Spline:
NewItem(VPieceNode(id, Tool::NodeSpline, reverse));
NewMainPathItem(VPieceNode(id, Tool::NodeSpline, reverse));
break;
case SceneObject::SplinePath:
NewItem(VPieceNode(id, Tool::NodeSplinePath, reverse));
NewMainPathItem(VPieceNode(id, Tool::NodeSplinePath, reverse));
break;
case (SceneObject::Line):
case (SceneObject::Detail):
@ -241,10 +273,10 @@ void DialogSeamAllowance::CheckState()
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::ShowContextMenu(const QPoint &pos)
void DialogSeamAllowance::ShowMainPathContextMenu(const QPoint &pos)
{
const int row = ui->listWidget->currentRow();
if (ui->listWidget->count() == 0 || row == -1 || row >= ui->listWidget->count())
const int row = ui->listWidgetMainPath->currentRow();
if (ui->listWidgetMainPath->count() == 0 || row == -1 || row >= ui->listWidgetMainPath->count())
{
return;
}
@ -253,7 +285,7 @@ void DialogSeamAllowance::ShowContextMenu(const QPoint &pos)
QAction *actionDelete = menu->addAction(QIcon::fromTheme("edit-delete"), tr("Delete"));
actionDelete->setEnabled(applyAllowed);//Because we can't undo this operation when creating a piece.
QListWidgetItem *rowItem = ui->listWidget->item(row);
QListWidgetItem *rowItem = ui->listWidgetMainPath->item(row);
SCASSERT(rowItem != nullptr);
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
@ -265,10 +297,10 @@ void DialogSeamAllowance::ShowContextMenu(const QPoint &pos)
actionReverse->setChecked(rowNode.GetReverse());
}
QAction *selectedAction = menu->exec(ui->listWidget->viewport()->mapToGlobal(pos));
QAction *selectedAction = menu->exec(ui->listWidgetMainPath->viewport()->mapToGlobal(pos));
if (selectedAction == actionDelete)
{
delete ui->listWidget->item(row);
delete ui->listWidgetMainPath->item(row);
ValidObjects(MainPathIsValid());
}
else if (selectedAction == actionReverse)
@ -282,6 +314,52 @@ void DialogSeamAllowance::ShowContextMenu(const QPoint &pos)
ListChanged();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::ShowCustomSAContextMenu(const QPoint &pos)
{
const int row = ui->listWidgetCustomSA->currentRow();
if (ui->listWidgetCustomSA->count() == 0 || row == -1 || row >= ui->listWidgetCustomSA->count())
{
return;
}
QMenu *menu = new QMenu(this);
QAction *actionDelete = menu->addAction(QIcon::fromTheme("edit-delete"), tr("Delete"));
QListWidgetItem *rowItem = ui->listWidgetCustomSA->item(row);
SCASSERT(rowItem != nullptr);
CustomSARecord record = qvariant_cast<CustomSARecord>(rowItem->data(Qt::UserRole));
QAction *actionReverse = menu->addAction(tr("Reverse"));
actionReverse->setCheckable(true);
actionReverse->setChecked(record.reverse);
QAction *actionOption = menu->addAction(QIcon::fromTheme("preferences-other"), tr("Options"));
QAction *selectedAction = menu->exec(ui->listWidgetCustomSA->viewport()->mapToGlobal(pos));
if (selectedAction == actionDelete)
{
delete ui->listWidgetCustomSA->item(row);
}
else if (selectedAction == actionReverse)
{
record.reverse = not record.reverse;
rowItem->setData(Qt::UserRole, QVariant::fromValue(record));
rowItem->setText(GetCustomSARecordName(record));
}
else if (selectedAction == actionOption)
{
auto *dialog = new DialogPiecePath(data, record.path, this);
dialog->SetPiecePath(data->GetPiecePath(record.path));
dialog->SetPieceId(toolId);
dialog->EnbleShowMode(true);
m_dialog = dialog;
m_dialog->setModal(true);
connect(m_dialog.data(), &DialogTool::DialogClosed, this, &DialogSeamAllowance::PathDialogClosed);
m_dialog->show();
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::ListChanged()
{
@ -299,6 +377,7 @@ void DialogSeamAllowance::ListChanged()
void DialogSeamAllowance::EnableSeamAllowance(bool enable)
{
ui->groupBoxAutomatic->setEnabled(enable);
ui->groupBoxCustom->setEnabled(enable);
if (enable)
{
@ -327,7 +406,7 @@ void DialogSeamAllowance::NodeChanged(int index)
const quint32 id = ui->comboBoxNodes->currentData().toUInt();
#endif
const VPiece piece = CreatePiece();
const int nodeIndex = piece.indexOfNode(id);
const int nodeIndex = piece.GetPath().indexOfNode(id);
if (nodeIndex != -1)
{
const VPieceNode &node = piece.GetPath().at(nodeIndex);
@ -377,6 +456,52 @@ void DialogSeamAllowance::NodeChanged(int index)
ui->comboBoxAngle->blockSignals(false);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::CSAStartPointChanged(int index)
{
const int row = ui->listWidgetCustomSA->currentRow();
if (ui->listWidgetCustomSA->count() == 0 || row == -1 || row >= ui->listWidgetCustomSA->count())
{
return;
}
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
const quint32 startPoint = ui->comboBoxStartPoint->itemData(index).toUInt();
#else
Q_UNUSED(index);
const quint32 startPoint = ui->comboBoxStartPoint->currentData().toUInt();
#endif
QListWidgetItem *rowItem = ui->listWidgetCustomSA->item(row);
SCASSERT(rowItem != nullptr);
CustomSARecord record = qvariant_cast<CustomSARecord>(rowItem->data(Qt::UserRole));
record.startPoint = startPoint;
rowItem->setData(Qt::UserRole, QVariant::fromValue(record));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::CSAEndPointChanged(int index)
{
const int row = ui->listWidgetCustomSA->currentRow();
if (ui->listWidgetCustomSA->count() == 0 || row == -1 || row >= ui->listWidgetCustomSA->count())
{
return;
}
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
const quint32 endPoint = ui->comboBoxEndPoint->itemData(index).toUInt();
#else
Q_UNUSED(index);
const quint32 endPoint = ui->comboBoxEndPoint->currentData().toUInt();
#endif
QListWidgetItem *rowItem = ui->listWidgetCustomSA->item(row);
SCASSERT(rowItem != nullptr);
CustomSARecord record = qvariant_cast<CustomSARecord>(rowItem->data(Qt::UserRole));
record.endPoint = endPoint;
rowItem->setData(Qt::UserRole, QVariant::fromValue(record));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::NodeAngleChanged(int index)
{
@ -431,13 +556,69 @@ void DialogSeamAllowance::ChangedSAAfter(double d)
SetCurrentSAAfter(d);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::CustomSAChanged(int row)
{
if (ui->listWidgetCustomSA->count() == 0 || row == -1 || row >= ui->listWidgetCustomSA->count())
{
return;
}
ui->comboBoxStartPoint->blockSignals(true);
ui->comboBoxEndPoint->blockSignals(true);
InitCSAPoint(ui->comboBoxStartPoint);
InitCSAPoint(ui->comboBoxEndPoint);
const QListWidgetItem *item = ui->listWidgetCustomSA->item( row );
SCASSERT(item != nullptr);
const CustomSARecord record = qvariant_cast<CustomSARecord>(item->data(Qt::UserRole));
{
const int index = ui->comboBoxStartPoint->findData(record.startPoint);
if (index != -1)
{
ui->comboBoxStartPoint->setCurrentIndex(index);
}
}
{
const int index = ui->comboBoxEndPoint->findData(record.endPoint);
if (index != -1)
{
ui->comboBoxEndPoint->setCurrentIndex(index);
}
}
ui->comboBoxStartPoint->blockSignals(false);
ui->comboBoxEndPoint->blockSignals(false);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::PathDialogClosed(int result)
{
if (result == QDialog::Accepted)
{
SCASSERT(not m_dialog.isNull());
DialogPiecePath *dialogTool = qobject_cast<DialogPiecePath*>(m_dialog.data());
SCASSERT(dialogTool != nullptr);
const VPiecePath newPath = dialogTool->GetPiecePath();
const VPiecePath oldPath = data->GetPiecePath(dialogTool->GetPieceId());
SavePiecePathOptions *saveCommand = new SavePiecePathOptions(newPath, oldPath, qApp->getCurrentDocument(),
const_cast<VContainer *>(data), toolId);
qApp->getUndoStack()->push(saveCommand);
}
delete m_dialog;
}
//---------------------------------------------------------------------------------------------------------------------
VPiece DialogSeamAllowance::CreatePiece() const
{
VPiece piece;
for (qint32 i = 0; i < ui->listWidget->count(); ++i)
for (qint32 i = 0; i < ui->listWidgetMainPath->count(); ++i)
{
QListWidgetItem *item = ui->listWidget->item(i);
QListWidgetItem *item = ui->listWidgetMainPath->item(i);
piece.GetPath().Append(qvariant_cast<VPieceNode>(item->data(Qt::UserRole)));
}
@ -451,9 +632,43 @@ VPiece DialogSeamAllowance::CreatePiece() const
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::NewItem(const VPieceNode &node)
void DialogSeamAllowance::NewMainPathItem(const VPieceNode &node)
{
NewNodeItem(ui->listWidget, node);
NewNodeItem(ui->listWidgetMainPath, node);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::NewCustomSA(const CustomSARecord &record)
{
if (record.path > NULL_ID)
{
const QString name = GetCustomSARecordName(record);
QListWidgetItem *item = new QListWidgetItem(name);
item->setFont(QFont("Times", 12, QFont::Bold));
item->setData(Qt::UserRole, QVariant::fromValue(record));
ui->listWidgetCustomSA->addItem(item);
ui->listWidgetCustomSA->setCurrentRow(ui->listWidgetCustomSA->count()-1);
}
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogSeamAllowance::GetCustomSARecordName(const CustomSARecord &record) const
{
QString name;
if (record.path > NULL_ID)
{
const VPiecePath path = data->GetPiecePath(record.path);
name = path.GetName();
if (record.reverse)
{
name = QLatin1String("- ") + name;
}
}
return name;
}
//---------------------------------------------------------------------------------------------------------------------
@ -475,13 +690,13 @@ bool DialogSeamAllowance::MainPathIsValid() const
ui->helpLabel->setText(url);
return false;
}
if (FirstPointEqualLast(ui->listWidget))
if (FirstPointEqualLast(ui->listWidgetMainPath))
{
url += tr("First point cannot be equal to the last point!");
ui->helpLabel->setText(url);
return false;
}
else if (DoublePoints(ui->listWidget))
else if (DoublePoints(ui->listWidgetMainPath))
{
url += tr("You have double points!");
ui->helpLabel->setText(url);
@ -576,9 +791,9 @@ void DialogSeamAllowance::InitNodeAngles()
//---------------------------------------------------------------------------------------------------------------------
QListWidgetItem *DialogSeamAllowance::GetItemById(quint32 id)
{
for (qint32 i = 0; i < ui->listWidget->count(); ++i)
for (qint32 i = 0; i < ui->listWidgetMainPath->count(); ++i)
{
QListWidgetItem *item = ui->listWidget->item(i);
QListWidgetItem *item = ui->listWidgetMainPath->item(i);
const VPieceNode node = qvariant_cast<VPieceNode>(item->data(Qt::UserRole));
if (node.GetId() == id)
@ -636,3 +851,23 @@ void DialogSeamAllowance::SetCurrentSAAfter(qreal value)
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::InitCSAPoint(QComboBox *box)
{
SCASSERT(box != nullptr);
box->clear();
box->addItem(tr("Empty"), NULL_ID);
const VPiece piece = CreatePiece();
for (int i = 0; i < piece.GetPath().CountNodes(); ++i)
{
const VPieceNode &node = piece.GetPath().at(i);
if (node.GetTypeTool() == Tool::NodePoint)
{
const QString name = GetNodeName(node);
box->addItem(name, node.GetId());
}
}
}

View file

@ -60,15 +60,20 @@ protected:
virtual void CheckState() Q_DECL_OVERRIDE;
private slots:
void ShowContextMenu(const QPoint &pos);
void ShowMainPathContextMenu(const QPoint &pos);
void ShowCustomSAContextMenu(const QPoint &pos);
void ListChanged();
void EnableSeamAllowance(bool enable);
void NodeChanged(int index);
void CSAStartPointChanged(int index);
void CSAEndPointChanged(int index);
void NodeAngleChanged(int index);
void ReturnDefBefore();
void ReturnDefAfter();
void ChangedSABefore(double d);
void ChangedSAAfter(double d);
void CustomSAChanged(int row);
void PathDialogClosed(int result);
private:
Q_DISABLE_COPY(DialogSeamAllowance)
@ -78,14 +83,19 @@ private:
qreal m_mx;
qreal m_my;
QPointer<DialogTool> m_dialog;
VPiece CreatePiece() const;
void NewItem(const VPieceNode &node);
void NewMainPathItem(const VPieceNode &node);
void NewCustomSA(const CustomSARecord &record);
QString GetCustomSARecordName(const CustomSARecord &record) const;
bool MainPathIsValid() const;
void ValidObjects(bool value);
bool MainPathIsClockwise() const;
void InitNodesList();
void InitNodeAngles();
void InitCSAPoint(QComboBox *box);
QListWidgetItem *GetItemById(quint32 id);

View file

@ -7,21 +7,21 @@
<x>0</x>
<y>0</y>
<width>559</width>
<height>423</height>
<height>476</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="windowIcon">
<iconset>
<iconset resource="../../../vmisc/share/resources/icon.qrc">
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tabMainPath">
<attribute name="title">
@ -42,7 +42,7 @@
<string/>
</property>
<property name="pixmap">
<pixmap>:/icon/32x32/clockwise.png</pixmap>
<pixmap resource="../../../vmisc/share/resources/icon.qrc">:/icon/32x32/clockwise.png</pixmap>
</property>
</widget>
</item>
@ -69,7 +69,7 @@
</widget>
</item>
<item>
<widget class="QListWidget" name="listWidget">
<widget class="QListWidget" name="listWidgetMainPath">
<property name="dragDropMode">
<enum>QAbstractItemView::InternalMove</enum>
</property>
@ -94,7 +94,7 @@
<attribute name="title">
<string>Seam allowance</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QCheckBox" name="checkBoxSeams">
<property name="text">
@ -113,10 +113,19 @@
<property name="title">
<string>Automatic</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="topMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
@ -269,22 +278,75 @@
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxCustom">
<property name="enabled">
<bool>false</bool>
</property>
<property name="title">
<string>Custom</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer name="verticalSpacer">
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>219</height>
</size>
</property>
</spacer>
<widget class="QWidget" name="layoutWidget">
<layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="labelStartPoint">
<property name="text">
<string>Start point:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxStartPoint"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelEndPoint">
<property name="text">
<string>End point:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxEndPoint"/>
</item>
</layout>
</widget>
<widget class="QListWidget" name="listWidgetCustomSA"/>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
@ -301,7 +363,9 @@
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="../../../vmisc/share/resources/icon.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>

View file

@ -151,6 +151,14 @@ void VToolPiecePath::AddNodes(VAbstractPattern *doc, QDomElement &domElement, co
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPiecePath::AddAttributes(VAbstractPattern *doc, QDomElement &domElement, quint32 id, const VPiecePath &path)
{
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrName, path.GetName());
doc->SetAttribute(domElement, AttrType, static_cast<int>(path.GetType()));
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPiecePath::FullUpdateFromFile()
{
@ -175,11 +183,9 @@ void VToolPiecePath::AllowSelecting(bool enabled)
void VToolPiecePath::AddToFile()
{
QDomElement domElement = doc->createElement(getTagName());
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
const VPiecePath path = VAbstractTool::data.GetPiecePath(id);
doc->SetAttribute(domElement, AttrType, static_cast<int>(path.GetType()));
AddAttributes(doc, domElement, id, path);
if (idTool != NULL_ID)
{

View file

@ -52,6 +52,7 @@ public:
static void AddNode(VAbstractPattern *doc, QDomElement &domElement, const VPieceNode &node);
static void AddNodes(VAbstractPattern *doc, QDomElement &domElement, const VPiecePath &path);
static void AddAttributes(VAbstractPattern *doc, QDomElement &domElement, quint32 id, const VPiecePath &path);
public slots:
virtual void FullUpdateFromFile () Q_DECL_OVERRIDE;
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;

View file

@ -0,0 +1,139 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 26 11, 2016
**
** @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) 2016 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 "savepiecepathoptions.h"
#include <QDomElement>
#include <QUndoCommand>
#include <QDebug>
#include "../ifc/xml/vabstractpattern.h"
#include "../vmisc/logging.h"
#include "../tools/nodeDetails/vtoolpiecepath.h"
class QDomElement;
class QUndoCommand;
//---------------------------------------------------------------------------------------------------------------------
SavePiecePathOptions::SavePiecePathOptions(const VPiecePath &oldPath, const VPiecePath &newPath,
VAbstractPattern *doc, VContainer *data, quint32 id,
QUndoCommand *parent)
: VUndoCommand(QDomElement(), doc, parent),
m_oldPath(oldPath),
m_newPath(newPath),
m_data(data)
{
setText(tr("save path options"));
nodeId = id;
}
//---------------------------------------------------------------------------------------------------------------------
SavePiecePathOptions::~SavePiecePathOptions()
{}
//---------------------------------------------------------------------------------------------------------------------
void SavePiecePathOptions::undo()
{
qCDebug(vUndo, "Undo.");
QDomElement domElement = doc->elementById(nodeId);
if (domElement.isElement())
{
VToolPiecePath::AddAttributes(doc, domElement, nodeId, m_oldPath);
doc->RemoveAllChildren(domElement);//Very important to clear before rewrite
VToolPiecePath::AddNodes(doc, domElement, m_oldPath);
IncrementReferences(m_oldPath.MissingNodes(m_newPath));
SCASSERT(m_data);
m_data->UpdatePiecePath(nodeId, m_oldPath);
}
else
{
qCDebug(vUndo, "Can't find path with id = %u.", nodeId);
return;
}
}
//---------------------------------------------------------------------------------------------------------------------
void SavePiecePathOptions::redo()
{
qCDebug(vUndo, "Redo.");
QDomElement domElement = doc->elementById(nodeId);
if (domElement.isElement())
{
VToolPiecePath::AddAttributes(doc, domElement, nodeId, m_newPath);
doc->RemoveAllChildren(domElement);//Very important to clear before rewrite
VToolPiecePath::AddNodes(doc, domElement, m_newPath);
DecrementReferences(m_oldPath.MissingNodes(m_newPath));
SCASSERT(m_data);
m_data->UpdatePiecePath(nodeId, m_oldPath);
}
else
{
qCDebug(vUndo, "Can't find path with id = %u.", nodeId);
return;
}
}
//---------------------------------------------------------------------------------------------------------------------
bool SavePiecePathOptions::mergeWith(const QUndoCommand *command)
{
const SavePiecePathOptions *saveCommand = static_cast<const SavePiecePathOptions *>(command);
SCASSERT(saveCommand != nullptr);
const quint32 id = saveCommand->PathId();
if (id != nodeId)
{
return false;
}
m_newPath = saveCommand->NewPath();
return true;
}
//---------------------------------------------------------------------------------------------------------------------
int SavePiecePathOptions::id() const
{
return static_cast<int>(UndoCommand::SavePiecePathOptions);
}
//---------------------------------------------------------------------------------------------------------------------
quint32 SavePiecePathOptions::PathId() const
{
return nodeId;
}
//---------------------------------------------------------------------------------------------------------------------
VPiecePath SavePiecePathOptions::NewPath() const
{
return m_newPath;
}

View file

@ -0,0 +1,62 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 26 11, 2016
**
** @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) 2016 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/>.
**
*************************************************************************/
#ifndef SAVEPIECEPATHOPTIONS_H
#define SAVEPIECEPATHOPTIONS_H
#include <QtGlobal>
#include "../vpatterndb/vpiecepath.h"
#include "vundocommand.h"
class QUndoCommand;
class VAbstractPattern;
class SavePiecePathOptions : public VUndoCommand
{
public:
SavePiecePathOptions(const VPiecePath &oldPath, const VPiecePath &newPath, VAbstractPattern *doc,
VContainer *data, quint32 id, QUndoCommand *parent = nullptr);
virtual ~SavePiecePathOptions();
virtual void undo() Q_DECL_OVERRIDE;
virtual void redo() Q_DECL_OVERRIDE;
virtual bool mergeWith(const QUndoCommand *command) Q_DECL_OVERRIDE;
virtual int id() const Q_DECL_OVERRIDE;
quint32 PathId() const;
VPiecePath NewPath() const;
private:
Q_DISABLE_COPY(SavePiecePathOptions)
const VPiecePath m_oldPath;
VPiecePath m_newPath;
VContainer *m_data;
};
#endif // SAVEPIECEPATHOPTIONS_H

View file

@ -26,7 +26,8 @@ HEADERS += \
$$PWD/deletepiece.h \
$$PWD/movepiece.h \
$$PWD/savepieceoptions.h \
$$PWD/togglepieceinlayout.h
$$PWD/togglepieceinlayout.h \
$$PWD/savepiecepathoptions.h
SOURCES += \
$$PWD/addtocalc.cpp \
@ -53,4 +54,5 @@ SOURCES += \
$$PWD/deletepiece.cpp \
$$PWD/movepiece.cpp \
$$PWD/savepieceoptions.cpp \
$$PWD/togglepieceinlayout.cpp
$$PWD/togglepieceinlayout.cpp \
$$PWD/savepiecepathoptions.cpp

View file

@ -55,6 +55,7 @@ enum class UndoCommand: char { AddPatternPiece,
SaveToolOptions,
SaveDetailOptions,
SavePieceOptions,
SavePiecePathOptions,
MovePiece,
DeleteTool,
DeletePatternPiece,