Returned storing and reading base seam allowance values: width and

enable/disable.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-11-10 12:53:02 +02:00
parent de6015de4d
commit a5fc19d7ec
11 changed files with 180 additions and 10 deletions

View File

@ -618,10 +618,9 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document
detail.SetName(GetParametrString(domElement, AttrName, tr("Detail")));
detail.SetMx(qApp->toPixel(GetParametrDouble(domElement, AttrMx, "0.0")));
detail.SetMy(qApp->toPixel(GetParametrDouble(domElement, AttrMy, "0.0")));
// detail.setSeamAllowance(GetParametrUInt(domElement, VToolDetail::AttrSupplement, "1"));
// detail.setWidth(GetParametrDouble(domElement, VToolDetail::AttrWidth, "10.0"));
// detail.setClosed(GetParametrUInt(domElement, VToolDetail::AttrClosed, "1"));
detail.SetForbidFlipping(GetParametrUInt(domElement, VToolSeamAllowance::AttrForbidFlipping,
detail.SetSeamAllowance(GetParametrBool(domElement, VToolSeamAllowance::AttrSeamAllowance, falseStr));
detail.SetSAWidth(GetParametrDouble(domElement, VToolSeamAllowance::AttrWidth, "0.0"));
detail.SetForbidFlipping(GetParametrBool(domElement, VToolSeamAllowance::AttrForbidFlipping,
QString().setNum(qApp->ValentinaSettings()->GetForbidWorkpieceFlipping())));
detail.SetInLayout(GetParametrBool(domElement, AttrInLayout, trueStr));

View File

@ -414,7 +414,9 @@
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="name" type="xs:string"></xs:attribute>
<xs:attribute name="inLayout" type="xs:boolean"></xs:attribute>
<xs:attribute name="forbidFlipping" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="forbidFlipping" type="xs:boolean"></xs:attribute>
<xs:attribute name="width" type="xs:double"></xs:attribute>
<xs:attribute name="seamAllowance" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>

View File

@ -129,6 +129,7 @@ const QString strMx = QStringLiteral("mx");
const QString strMy = QStringLiteral("my");
const QString strForbidFlipping = QStringLiteral("forbidFlipping");
const QString strInLayout = QStringLiteral("inLayout");
const QString strSeamAllowance = QStringLiteral("seamAllowance");
//---------------------------------------------------------------------------------------------------------------------
VPatternConverter::VPatternConverter(const QString &fileName)
@ -1694,9 +1695,10 @@ void VPatternConverter::TagDetailToV0_4_0()
if (not dom.isNull())
{
dom.setAttribute(strSeamAllowance, dom.attribute(strSupplement, "0"));
dom.removeAttribute(strSupplement);
dom.removeAttribute(strClosed);
dom.removeAttribute(strWidth);
dom.setAttribute(strVersion, "1");

View File

@ -85,6 +85,30 @@ void VAbstractPiece::SetForbidFlipping(bool value)
d->m_forbidFlipping = value;
}
//---------------------------------------------------------------------------------------------------------------------
bool VAbstractPiece::IsSeamAllowance() const
{
return d->m_seamAllowance;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPiece::SetSeamAllowance(bool value)
{
d->m_seamAllowance = value;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VAbstractPiece::GetSAWidth() const
{
return d->m_width;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPiece::SetSAWidth(qreal value)
{
value >= 0 ? d->m_width = value : d->m_width = 0;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VAbstractPiece::SumTrapezoids(const QVector<QPointF> &points)
{

View File

@ -50,6 +50,12 @@ public:
bool IsForbidFlipping() const;
void SetForbidFlipping(bool value);
bool IsSeamAllowance() const;
void SetSeamAllowance(bool value);
qreal GetSAWidth() const;
void SetSAWidth(qreal value);
static qreal SumTrapezoids(const QVector<QPointF> &points);
static QVector<QPointF> CheckLoops(const QVector<QPointF> &points);
static QVector<QPointF> CorrectEquidistantPoints(const QVector<QPointF> &points, bool removeFirstAndLast = true);

View File

@ -42,13 +42,17 @@ class VAbstractPieceData : public QSharedData
public:
VAbstractPieceData()
: m_name(),
m_forbidFlipping(false)
m_forbidFlipping(false),
m_seamAllowance(false),
m_width(0)
{}
VAbstractPieceData(const VAbstractPieceData &piece)
: QSharedData(piece),
m_name(piece.m_name),
m_forbidFlipping(piece.m_forbidFlipping)
m_forbidFlipping(piece.m_forbidFlipping),
m_seamAllowance(piece.m_seamAllowance),
m_width(piece.m_width)
{}
~VAbstractPieceData();
@ -56,6 +60,8 @@ public:
QString m_name;
/** @brief forbidFlipping forbid piece be mirrored in a layout. */
bool m_forbidFlipping;
bool m_seamAllowance;
qreal m_width;
private:
VAbstractPieceData &operator=(const VAbstractPieceData &) Q_DECL_EQ_DELETE;

View File

@ -51,10 +51,19 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 &
CheckState();
ui->checkBoxForbidFlipping->setChecked(qApp->Settings()->GetForbidWorkpieceFlipping());
ui->labelUnit->setText(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
if(qApp->patternUnit() == Unit::Inch)
{
ui->doubleSpinBoxSeams->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()));
ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->listWidget, &QListWidget::customContextMenuRequested, this, &DialogSeamAllowance::ShowContextMenu);
connect(ui->listWidget->model(), &QAbstractItemModel::rowsMoved, this, &DialogSeamAllowance::ListChanged);
connect(ui->checkBoxSeams, &QCheckBox::clicked, this, &DialogSeamAllowance::EnableSeamAllowance);
if (not applyAllowed)
{
@ -94,6 +103,9 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece)
}
ui->checkBoxForbidFlipping->setChecked(m_piece.IsForbidFlipping());
ui->doubleSpinBoxSeams->setValue(m_piece.GetSAWidth());
EnableSeamAllowance(m_piece.IsSeamAllowance());
ValidObjects(MainPathIsValid());
}
@ -254,6 +266,12 @@ void DialogSeamAllowance::ListChanged()
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::EnableSeamAllowance(bool enable)
{
ui->groupBoxAutomatic->setEnabled(enable);
}
//---------------------------------------------------------------------------------------------------------------------
VPiece DialogSeamAllowance::CreatePiece() const
{
@ -265,6 +283,7 @@ VPiece DialogSeamAllowance::CreatePiece() const
}
piece.SetForbidFlipping(ui->checkBoxForbidFlipping->isChecked());
piece.SetSAWidth(ui->doubleSpinBoxSeams->value());
return piece;
}

View File

@ -62,6 +62,7 @@ protected:
private slots:
void ShowContextMenu(const QPoint &pos);
void ListChanged();
void EnableSeamAllowance(bool enable);
private:
Q_DISABLE_COPY(DialogSeamAllowance)

View File

@ -21,7 +21,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tabMainPath">
<attribute name="title">
@ -94,6 +94,111 @@
<attribute name="title">
<string>Seam allowance</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QCheckBox" name="checkBoxSeams">
<property name="text">
<string>Seam allowance</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxAutomatic">
<property name="enabled">
<bool>false</bool>
</property>
<property name="title">
<string>Automatic</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="labelEditWidth">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string>Width:</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBoxSeams">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<double>900.990000000000009</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelUnit">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>cm</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>219</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>

View File

@ -62,6 +62,8 @@ const QString VToolSeamAllowance::TagNode = QStringLiteral("node");
const QString VToolSeamAllowance::AttrVersion = QStringLiteral("version");
const QString VToolSeamAllowance::AttrNodeReverse = QStringLiteral("reverse");
const QString VToolSeamAllowance::AttrForbidFlipping = QStringLiteral("forbidFlipping");
const QString VToolSeamAllowance::AttrSeamAllowance = QStringLiteral("seamAllowance");
const QString VToolSeamAllowance::AttrWidth = QStringLiteral("width");
const QString VToolSeamAllowance::NodeArc = QStringLiteral("NodeArc");
const QString VToolSeamAllowance::NodePoint = QStringLiteral("NodePoint");
@ -253,7 +255,9 @@ void VToolSeamAllowance::AddAttributes(VAbstractPattern *doc, QDomElement &domEl
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(piece.GetMx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(piece.GetMy()));
doc->SetAttribute(domElement, AttrInLayout, piece.IsInLayout());
doc->SetAttribute(domElement, AttrForbidFlipping, static_cast<quint8>(piece.IsForbidFlipping()));
doc->SetAttribute(domElement, AttrForbidFlipping, piece.IsForbidFlipping());
doc->SetAttribute(domElement, AttrSeamAllowance, piece.IsSeamAllowance());
doc->SetAttribute(domElement, AttrWidth, piece.GetSAWidth());
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -60,6 +60,8 @@ public:
static const QString AttrVersion;
static const QString AttrNodeReverse;
static const QString AttrForbidFlipping;
static const QString AttrSeamAllowance;
static const QString AttrWidth;
static const QString NodeArc;
static const QString NodePoint;