Control seam allowance before and after values in a dialog.
--HG-- branch : feature
This commit is contained in:
parent
7490e3f8d6
commit
c5536ab38a
|
@ -98,6 +98,36 @@ void VPieceNode::SetReverse(bool reverse)
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
qreal VPieceNode::GetSABefore() const
|
||||
{
|
||||
return d->m_saBefore;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPieceNode::SetSABefore(qreal value)
|
||||
{
|
||||
if (d->m_typeTool == Tool::NodePoint)
|
||||
{
|
||||
value < 0 ? d->m_saBefore = -1: d->m_saBefore = value;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
qreal VPieceNode::GetSAAfter() const
|
||||
{
|
||||
return d->m_saAfter;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPieceNode::SetSAAfter(qreal value)
|
||||
{
|
||||
if (d->m_typeTool == Tool::NodePoint)
|
||||
{
|
||||
value < 0 ? d->m_saAfter = -1: d->m_saAfter = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Friend functions
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QDataStream& operator<<(QDataStream& out, const VPieceNode& p)
|
||||
|
|
|
@ -57,6 +57,12 @@ public:
|
|||
|
||||
bool GetReverse() const;
|
||||
void SetReverse(bool reverse);
|
||||
|
||||
qreal GetSABefore() const;
|
||||
void SetSABefore(qreal value);
|
||||
|
||||
qreal GetSAAfter() const;
|
||||
void SetSAAfter(qreal value);
|
||||
private:
|
||||
QSharedDataPointer<VPieceNodeData> d;
|
||||
};
|
||||
|
|
|
@ -39,40 +39,49 @@ QT_WARNING_DISABLE_GCC("-Weffc++")
|
|||
class VPieceNodeData : public QSharedData
|
||||
{
|
||||
public:
|
||||
VPieceNodeData()
|
||||
: m_id(NULL_ID),
|
||||
m_typeTool(Tool::NodePoint),
|
||||
m_reverse(false)
|
||||
{}
|
||||
VPieceNodeData()
|
||||
: m_id(NULL_ID),
|
||||
m_typeTool(Tool::NodePoint),
|
||||
m_reverse(false),
|
||||
m_saBefore(-1),
|
||||
m_saAfter(-1)
|
||||
{}
|
||||
|
||||
VPieceNodeData(quint32 id, Tool typeTool, bool reverse)
|
||||
: m_id(id),
|
||||
m_typeTool(typeTool),
|
||||
m_reverse(reverse)
|
||||
{
|
||||
if (m_typeTool == Tool::NodePoint)
|
||||
{
|
||||
m_reverse = false;
|
||||
}
|
||||
}
|
||||
VPieceNodeData(quint32 id, Tool typeTool, bool reverse)
|
||||
: m_id(id),
|
||||
m_typeTool(typeTool),
|
||||
m_reverse(reverse),
|
||||
m_saBefore(-1),
|
||||
m_saAfter(-1)
|
||||
{
|
||||
if (m_typeTool == Tool::NodePoint)
|
||||
{
|
||||
m_reverse = false;
|
||||
}
|
||||
}
|
||||
|
||||
VPieceNodeData (const VPieceNodeData& node)
|
||||
: QSharedData(node),
|
||||
m_id(node.m_id),
|
||||
m_typeTool(node.m_typeTool),
|
||||
m_reverse(node.m_reverse)
|
||||
{}
|
||||
VPieceNodeData (const VPieceNodeData& node)
|
||||
: QSharedData(node),
|
||||
m_id(node.m_id),
|
||||
m_typeTool(node.m_typeTool),
|
||||
m_reverse(node.m_reverse),
|
||||
m_saBefore(node.m_saBefore),
|
||||
m_saAfter(node.m_saAfter)
|
||||
{}
|
||||
|
||||
~VPieceNodeData();
|
||||
~VPieceNodeData();
|
||||
|
||||
/** @brief id object id. */
|
||||
quint32 m_id;
|
||||
/** @brief id object id. */
|
||||
quint32 m_id;
|
||||
|
||||
/** @brief typeTool type of tool */
|
||||
Tool m_typeTool;
|
||||
/** @brief typeTool type of tool */
|
||||
Tool m_typeTool;
|
||||
|
||||
/** @brief reverse true if need reverse points list for node. */
|
||||
bool m_reverse;
|
||||
/** @brief reverse true if need reverse points list for node. */
|
||||
bool m_reverse;
|
||||
|
||||
qreal m_saBefore;
|
||||
qreal m_saAfter;
|
||||
|
||||
private:
|
||||
VPieceNodeData &operator=(const VPieceNodeData &) Q_DECL_EQ_DELETE;
|
||||
|
|
|
@ -52,14 +52,37 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 &
|
|||
|
||||
ui->checkBoxForbidFlipping->setChecked(qApp->Settings()->GetForbidWorkpieceFlipping());
|
||||
ui->labelUnit->setText(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
|
||||
ui->labelUnitBefore->setText(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
|
||||
ui->labelUnitAfter->setText(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
|
||||
|
||||
if(qApp->patternUnit() == Unit::Inch)
|
||||
{
|
||||
ui->doubleSpinBoxSeams->setDecimals(5);
|
||||
ui->doubleSpinBoxSABefore->setDecimals(5);
|
||||
ui->doubleSpinBoxSAAfter->setDecimals(5);
|
||||
}
|
||||
// Default value for seam allowence is 1 cm. But pattern have different units, so just set 1 in dialog not enough.
|
||||
ui->doubleSpinBoxSeams->setValue(UnitConvertor(1, Unit::Cm, qApp->patternUnit()));
|
||||
|
||||
InitNodesList();
|
||||
connect(ui->comboBoxNodes, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||
&DialogSeamAllowance::NodeChanged);
|
||||
if (ui->comboBoxNodes->count() > 0)
|
||||
{
|
||||
NodeChanged(0);
|
||||
}
|
||||
|
||||
connect(ui->pushButtonDefBefore, &QPushButton::clicked, this, &DialogSeamAllowance::ReturnDefBefore);
|
||||
connect(ui->pushButtonDefAfter, &QPushButton::clicked, this, &DialogSeamAllowance::ReturnDefAfter);
|
||||
|
||||
connect(ui->doubleSpinBoxSeams, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
||||
[this](){NodeChanged(ui->comboBoxNodes->currentIndex());});
|
||||
|
||||
connect(ui->doubleSpinBoxSABefore, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
||||
this, &DialogSeamAllowance::ChangedSABefore);
|
||||
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);
|
||||
|
@ -107,6 +130,8 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece)
|
|||
ui->checkBoxSeams->setChecked(m_piece.IsSeamAllowance());
|
||||
|
||||
ValidObjects(MainPathIsValid());
|
||||
|
||||
ListChanged();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -263,12 +288,102 @@ void DialogSeamAllowance::ListChanged()
|
|||
visPath->SetPiece(CreatePiece());
|
||||
visPath->RefreshGeometry();
|
||||
}
|
||||
InitNodesList();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSeamAllowance::EnableSeamAllowance(bool enable)
|
||||
{
|
||||
ui->groupBoxAutomatic->setEnabled(enable);
|
||||
|
||||
if (enable)
|
||||
{
|
||||
InitNodesList();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSeamAllowance::NodeChanged(int index)
|
||||
{
|
||||
ui->doubleSpinBoxSABefore->setDisabled(true);
|
||||
ui->doubleSpinBoxSAAfter->setDisabled(true);
|
||||
ui->pushButtonDefBefore->setDisabled(true);
|
||||
ui->pushButtonDefAfter->setDisabled(true);
|
||||
|
||||
ui->doubleSpinBoxSABefore->blockSignals(true);
|
||||
ui->doubleSpinBoxSAAfter->blockSignals(true);
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
||||
const quint32 id = ui->comboBoxNodes->itemData(index).toUInt();
|
||||
#else
|
||||
const quint32 id = ui->comboBoxNodes->currentData().toUInt();
|
||||
#endif
|
||||
const VPiece piece = CreatePiece();
|
||||
const int nodeIndex = piece.indexOfNode(id);
|
||||
if (nodeIndex != -1)
|
||||
{
|
||||
const VPieceNode node = piece.at(nodeIndex);
|
||||
|
||||
ui->doubleSpinBoxSABefore->setEnabled(true);
|
||||
ui->doubleSpinBoxSAAfter->setEnabled(true);
|
||||
|
||||
qreal w1 = node.GetSABefore();
|
||||
if (w1 < 0)
|
||||
{
|
||||
w1 = piece.GetSAWidth();
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->pushButtonDefBefore->setEnabled(true);
|
||||
}
|
||||
ui->doubleSpinBoxSABefore->setValue(w1);
|
||||
|
||||
qreal w2 = node.GetSAAfter();
|
||||
if (w2 < 0)
|
||||
{
|
||||
w2 = piece.GetSAWidth();
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->pushButtonDefAfter->setEnabled(true);
|
||||
}
|
||||
ui->doubleSpinBoxSAAfter->setValue(w2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->doubleSpinBoxSABefore->setValue(0);
|
||||
ui->doubleSpinBoxSAAfter->setValue(0);
|
||||
}
|
||||
|
||||
ui->doubleSpinBoxSABefore->blockSignals(false);
|
||||
ui->doubleSpinBoxSAAfter->blockSignals(false);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSeamAllowance::ReturnDefBefore()
|
||||
{
|
||||
SetCurrentSABefore(-1);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSeamAllowance::ReturnDefAfter()
|
||||
{
|
||||
SetCurrentSAAfter(-1);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSeamAllowance::ChangedSABefore(double d)
|
||||
{
|
||||
SetCurrentSABefore(d);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSeamAllowance::ChangedSAAfter(double d)
|
||||
{
|
||||
SetCurrentSAAfter(d);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -447,3 +562,108 @@ QString DialogSeamAllowance::GetNodeName(const VPieceNode &node) const
|
|||
|
||||
return name;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSeamAllowance::InitNodesList()
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
||||
const quint32 id = ui->comboBoxNodes->itemData(ui->comboBoxNodes->currentIndex()).toUInt();
|
||||
#else
|
||||
const quint32 id = ui->comboBoxNodes->currentData().toUInt();
|
||||
#endif
|
||||
|
||||
ui->comboBoxNodes->blockSignals(true);
|
||||
ui->comboBoxNodes->clear();
|
||||
|
||||
const VPiece piece = CreatePiece();
|
||||
|
||||
for (int i = 0; i < piece.CountNodes(); ++i)
|
||||
{
|
||||
const VPieceNode node = piece.at(i);
|
||||
if (node.GetTypeTool() == Tool::NodePoint)
|
||||
{
|
||||
const QString name = GetNodeName(node);
|
||||
|
||||
ui->comboBoxNodes->addItem(name, node.GetId());
|
||||
}
|
||||
}
|
||||
ui->comboBoxNodes->blockSignals(false);
|
||||
|
||||
const int index = ui->comboBoxNodes->findData(id);
|
||||
if (index != -1)
|
||||
{
|
||||
ui->comboBoxNodes->setCurrentIndex(index);
|
||||
NodeChanged(index);// Need in case combox index was not changed
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ui->comboBoxNodes->count() > 0)
|
||||
{
|
||||
NodeChanged(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QListWidgetItem *DialogSeamAllowance::GetItemById(quint32 id)
|
||||
{
|
||||
for (qint32 i = 0; i < ui->listWidget->count(); ++i)
|
||||
{
|
||||
QListWidgetItem *item = ui->listWidget->item(i);
|
||||
const VPieceNode node = qvariant_cast<VPieceNode>(item->data(Qt::UserRole));
|
||||
|
||||
if (node.GetId() == id)
|
||||
{
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSeamAllowance::SetCurrentSABefore(qreal value)
|
||||
{
|
||||
const int index = ui->comboBoxNodes->currentIndex();
|
||||
if (index != -1)
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
||||
const quint32 id = ui->comboBoxNodes->itemData(index).toUInt();
|
||||
#else
|
||||
const quint32 id = ui->comboBoxNodes->currentData().toUInt();
|
||||
#endif
|
||||
|
||||
QListWidgetItem *rowItem = GetItemById(id);
|
||||
if (rowItem)
|
||||
{
|
||||
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
|
||||
rowNode.SetSABefore(value);
|
||||
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
|
||||
|
||||
ListChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSeamAllowance::SetCurrentSAAfter(qreal value)
|
||||
{
|
||||
const int index = ui->comboBoxNodes->currentIndex();
|
||||
if (index != -1)
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
||||
const quint32 id = ui->comboBoxNodes->itemData(index).toUInt();
|
||||
#else
|
||||
const quint32 id = ui->comboBoxNodes->currentData().toUInt();
|
||||
#endif
|
||||
|
||||
QListWidgetItem *rowItem = GetItemById(id);
|
||||
if (rowItem)
|
||||
{
|
||||
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
|
||||
rowNode.SetSAAfter(value);
|
||||
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
|
||||
|
||||
ListChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,6 +63,11 @@ private slots:
|
|||
void ShowContextMenu(const QPoint &pos);
|
||||
void ListChanged();
|
||||
void EnableSeamAllowance(bool enable);
|
||||
void NodeChanged(int index);
|
||||
void ReturnDefBefore();
|
||||
void ReturnDefAfter();
|
||||
void ChangedSABefore(double d);
|
||||
void ChangedSAAfter(double d);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(DialogSeamAllowance)
|
||||
|
@ -80,6 +85,12 @@ private:
|
|||
bool FirstPointEqualLast() const;
|
||||
bool MainPathIsClockwise() const;
|
||||
QString GetNodeName(const VPieceNode &node) const;
|
||||
void InitNodesList();
|
||||
|
||||
QListWidgetItem *GetItemById(quint32 id);
|
||||
|
||||
void SetCurrentSABefore(qreal value);
|
||||
void SetCurrentSAAfter(qreal value);
|
||||
};
|
||||
|
||||
#endif // DIALOGSEAMALLOWANCE_H
|
||||
|
|
|
@ -182,6 +182,110 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Nodes</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelNode">
|
||||
<property name="text">
|
||||
<string>Node:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="comboBoxNodes"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelSABefore">
|
||||
<property name="toolTip">
|
||||
<string>Seam allowance before node</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Before:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBoxSABefore">
|
||||
<property name="maximum">
|
||||
<double>900.990000000000009</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.100000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelUnitBefore">
|
||||
<property name="text">
|
||||
<string>cm</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButtonDefBefore">
|
||||
<property name="toolTip">
|
||||
<string>Return to default width</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Default</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelSAAfter">
|
||||
<property name="toolTip">
|
||||
<string>Seam allowance after node</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>After:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBoxSAAfter">
|
||||
<property name="maximum">
|
||||
<double>900.990000000000009</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.100000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelUnitAfter">
|
||||
<property name="text">
|
||||
<string>cm</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButtonDefAfter">
|
||||
<property name="toolTip">
|
||||
<string>Return to default width</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Default</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
|
|
Loading…
Reference in New Issue
Block a user