Read/write piece path include type.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-11-28 14:52:31 +02:00
parent 51df681fbc
commit 5156e0cf25
8 changed files with 91 additions and 11 deletions

View file

@ -846,6 +846,9 @@ void VPattern::ParseDetailCSARecords(const QDomElement &domElement, VPiece &deta
record.path = GetParametrUInt(element, VToolSeamAllowance::AttrPath, NULL_ID_STR);
record.endPoint = GetParametrUInt(element, VToolSeamAllowance::AttrEnd, NULL_ID_STR);
record.reverse = GetParametrBool(element, VAbstractPattern::AttrNodeReverse, falseStr);
record.includeType = static_cast<PiecePathIncludeType>(GetParametrUInt(element,
VToolSeamAllowance::AttrIncludeAs,
"1"));
records.append(record);
}
}

View file

@ -414,7 +414,7 @@
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="length" type="xs:string"></xs:attribute>
<xs:attribute name="rotation" type="xs:string"></xs:attribute>
<xs:attribute name="arrows" type="arrowType"></xs:attribute>
<xs:attribute name="arrows" type="arrowType"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="nodes" minOccurs="1" maxOccurs="1">
@ -442,6 +442,7 @@
<xs:attribute name="path" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="end" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="reverse" type="xs:boolean"></xs:attribute>
<xs:attribute name="includeAs" type="piecePathIncludeType"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
@ -693,4 +694,10 @@
<xs:enumeration value="2"/><!--internal path-->
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="piecePathIncludeType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="0"/><!--as main path-->
<xs:enumeration value="1"/><!--as custom seam allowance-->
</xs:restriction>
</xs:simpleType>
</xs:schema>

View file

@ -74,6 +74,12 @@ enum class PieceNodeAngle : unsigned char
BySecondEdgeRightAngle
};
enum class PiecePathIncludeType : unsigned char
{
AsMainPath = 0,
AsCustomSA
};
enum class PiecePathType : unsigned char {PiecePath = 0, CustomSeamAllowance = 1, InternalPath = 2, Unknown = 3};
typedef unsigned char ToolVisHolderType;
@ -686,13 +692,15 @@ struct CustomSARecord
: startPoint(0),
path(0),
endPoint(0),
reverse(false)
reverse(false),
includeType(PiecePathIncludeType::AsCustomSA)
{}
quint32 startPoint;
quint32 path;
quint32 endPoint;
bool reverse;
PiecePathIncludeType includeType;
};
Q_DECLARE_METATYPE(CustomSARecord)

View file

@ -103,6 +103,8 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 &
&DialogSeamAllowance::CSAStartPointChanged);
connect(ui->comboBoxEndPoint, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogSeamAllowance::CSAEndPointChanged);
connect(ui->comboBoxIncludeType, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogSeamAllowance::CSAIncludeTypeChanged);
if (not applyAllowed)
{
@ -352,6 +354,10 @@ void DialogSeamAllowance::ShowCustomSAContextMenu(const QPoint &pos)
auto *dialog = new DialogPiecePath(data, record.path, this);
dialog->SetPiecePath(data->GetPiecePath(record.path));
dialog->SetPieceId(toolId);
if (record.includeType == PiecePathIncludeType::AsMainPath)
{
dialog->SetSAWidth(ui->doubleSpinBoxSeams->value());
}
dialog->EnbleShowMode(true);
m_dialog = dialog;
m_dialog->setModal(true);
@ -502,6 +508,29 @@ void DialogSeamAllowance::CSAEndPointChanged(int index)
rowItem->setData(Qt::UserRole, QVariant::fromValue(record));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::CSAIncludeTypeChanged(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 PiecePathIncludeType type = static_cast<PiecePathIncludeType>(ui->comboBoxEndPoint->itemData(index).toUInt());
#else
Q_UNUSED(index);
const PiecePathIncludeType type = static_cast<PiecePathIncludeType>(ui->comboBoxEndPoint->currentData().toUInt());
#endif
QListWidgetItem *rowItem = ui->listWidgetCustomSA->item(row);
SCASSERT(rowItem != nullptr);
CustomSARecord record = qvariant_cast<CustomSARecord>(rowItem->data(Qt::UserRole));
record.includeType = type;
rowItem->setData(Qt::UserRole, QVariant::fromValue(record));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::NodeAngleChanged(int index)
{
@ -564,16 +593,12 @@ void DialogSeamAllowance::CustomSAChanged(int row)
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));
ui->comboBoxStartPoint->blockSignals(true);
InitCSAPoint(ui->comboBoxStartPoint);
{
const int index = ui->comboBoxStartPoint->findData(record.startPoint);
if (index != -1)
@ -581,7 +606,10 @@ void DialogSeamAllowance::CustomSAChanged(int row)
ui->comboBoxStartPoint->setCurrentIndex(index);
}
}
ui->comboBoxStartPoint->blockSignals(false);
ui->comboBoxEndPoint->blockSignals(true);
InitCSAPoint(ui->comboBoxEndPoint);
{
const int index = ui->comboBoxEndPoint->findData(record.endPoint);
if (index != -1)
@ -589,9 +617,18 @@ void DialogSeamAllowance::CustomSAChanged(int row)
ui->comboBoxEndPoint->setCurrentIndex(index);
}
}
ui->comboBoxStartPoint->blockSignals(false);
ui->comboBoxEndPoint->blockSignals(false);
ui->comboBoxIncludeType->blockSignals(true);
InitSAIncludeType();
{
const int index = ui->comboBoxIncludeType->findData(static_cast<unsigned char>(record.includeType));
if (index != -1)
{
ui->comboBoxIncludeType->setCurrentIndex(index);
}
}
ui->comboBoxIncludeType->blockSignals(false);
}
//---------------------------------------------------------------------------------------------------------------------
@ -853,3 +890,13 @@ void DialogSeamAllowance::InitCSAPoint(QComboBox *box)
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::InitSAIncludeType()
{
ui->comboBoxIncludeType->clear();
ui->comboBoxIncludeType->addItem(tr("main path"), static_cast<unsigned char>(PiecePathIncludeType::AsMainPath));
ui->comboBoxIncludeType->addItem(tr("custom seam allowance"),
static_cast<unsigned char>(PiecePathIncludeType::AsCustomSA));
}

View file

@ -67,6 +67,7 @@ private slots:
void NodeChanged(int index);
void CSAStartPointChanged(int index);
void CSAEndPointChanged(int index);
void CSAIncludeTypeChanged(int index);
void NodeAngleChanged(int index);
void ReturnDefBefore();
void ReturnDefAfter();
@ -95,6 +96,7 @@ private:
bool MainPathIsClockwise() const;
void InitNodesList();
void InitCSAPoint(QComboBox *box);
void InitSAIncludeType();
QListWidgetItem *GetItemById(quint32 id);

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">
@ -326,6 +326,16 @@
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxEndPoint"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelIncludeType">
<property name="text">
<string>Include as:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBoxIncludeType"/>
</item>
</layout>
</widget>
<widget class="QListWidget" name="listWidgetCustomSA"/>

View file

@ -68,6 +68,7 @@ const QString VToolSeamAllowance::AttrUnited = QStringLiteral("united");
const QString VToolSeamAllowance::AttrStart = QStringLiteral("start");
const QString VToolSeamAllowance::AttrPath = QStringLiteral("path");
const QString VToolSeamAllowance::AttrEnd = QStringLiteral("end");
const QString VToolSeamAllowance::AttrIncludeAs = QStringLiteral("includeAs");
//---------------------------------------------------------------------------------------------------------------------
VToolSeamAllowance::~VToolSeamAllowance()
@ -242,6 +243,7 @@ void VToolSeamAllowance::AddCSARecord(VAbstractPattern *doc, QDomElement &domEle
doc->SetAttribute(recordNode, AttrPath, record.path);
doc->SetAttribute(recordNode, AttrEnd, record.endPoint);
doc->SetAttribute(recordNode, VAbstractPattern::AttrNodeReverse, record.reverse);
doc->SetAttribute(recordNode, AttrIncludeAs, static_cast<unsigned int>(record.includeType));
domElement.appendChild(recordNode);
}

View file

@ -65,6 +65,7 @@ public:
static const QString AttrStart;
static const QString AttrPath;
static const QString AttrEnd;
static const QString AttrIncludeAs;
void Remove(bool ask);