Allow user to set default size and height for a pattern.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-12-11 16:19:11 +02:00
parent af8bd356ac
commit 93a52bd889
15 changed files with 836 additions and 38 deletions

View file

@ -30,16 +30,18 @@
#include "ui_dialogpatternproperties.h"
#include <QPushButton>
#include "../xml/vpattern.h"
#include "../vpatterndb/vcontainer.h"
#include "../core/vapplication.h"
#define MAX_HEIGHTS 18
#define MAX_SIZES 18
//---------------------------------------------------------------------------------------------------------------------
DialogPatternProperties::DialogPatternProperties(VPattern *doc, QWidget *parent) :
QDialog(parent), ui(new Ui::DialogPatternProperties), doc(doc), heightsChecked(MAX_HEIGHTS),
DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pattern, QWidget *parent) :
QDialog(parent), ui(new Ui::DialogPatternProperties), doc(doc), pattern(pattern), heightsChecked(MAX_HEIGHTS),
sizesChecked(MAX_SIZES), heights (QMap<GHeights, bool>()), sizes(QMap<GSizes, bool>()),
data(QMap<QCheckBox *, int>()), descriptionChanged(false), gradationChanged(false), isInitialized(false)
data(QMap<QCheckBox *, int>()), descriptionChanged(false), gradationChanged(false), defaultChanged(false),
isInitialized(false)
{
ui->setupUi(this);
@ -69,7 +71,7 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, QWidget *parent)
connect(bCansel, &QPushButton::clicked, this, &DialogPatternProperties::close);
ui->tabWidget->setCurrentIndex(0);
if (qApp->patternType() == MeasurementsType::Individual)
if (qApp->patternType() != MeasurementsType::Standard)
{
ui->tabWidget->setTabEnabled(1, false);
}
@ -83,7 +85,30 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, QWidget *parent)
SetOptions(heights);
SetOptions(sizes);
gradationChanged = false;//Set to default value after initialization
InitComboBox(ui->comboBoxHeight, heights);
InitComboBox(ui->comboBoxSize, sizes);
const QString height = QString().setNum(static_cast<int>(UnitConvertor(doc->GetDefCustomHeight(),
*pattern->GetPatternUnit(), Unit::Cm)));
SetDefaultHeight(height);
const QString size = QString().setNum(static_cast<int>(UnitConvertor(doc->GetDefCustomSize(),
*pattern->GetPatternUnit(), Unit::Cm)));
SetDefaultSize(size);
connect(ui->radioButtonDefFromP, &QRadioButton::toggled, this, &DialogPatternProperties::ToggleComboBox);
connect(ui->radioButtonDefFromP, &QRadioButton::toggled, this, &DialogPatternProperties::DefValueChanged);
ui->radioButtonDefFromP->setChecked(doc->IsDefCustom());
connect(ui->comboBoxHeight, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogPatternProperties::DefValueChanged);
connect(ui->comboBoxSize, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogPatternProperties::DefValueChanged);
//Initialization change value. Set to default value after initialization
gradationChanged = false;
defaultChanged = false;
}
//---------------------------------------------------------------------------------------------------------------------
@ -100,10 +125,14 @@ void DialogPatternProperties::Apply()
case 0:
SaveDescription();
descriptionChanged = false;
emit doc->patternChanged(false);
break;
case 1:
SaveGradation();
gradationChanged = false;
SaveDefValues();
defaultChanged = false;
emit doc->patternChanged(false);
break;
default:
break;
@ -113,6 +142,11 @@ void DialogPatternProperties::Apply()
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::Ok()
{
if (descriptionChanged || gradationChanged || defaultChanged)
{
emit doc->patternChanged(false);
}
if (descriptionChanged)
{
SaveDescription();
@ -125,6 +159,12 @@ void DialogPatternProperties::Ok()
gradationChanged = false;
}
if (defaultChanged)
{
SaveDefValues();
defaultChanged = false;
}
close();
}
@ -204,6 +244,8 @@ void DialogPatternProperties::CheckStateHeight(int state)
heights.insert(static_cast<GHeights>(data.value(box)), box->isChecked());
}
UpdateDefHeight();
CheckApplyOk();
gradationChanged = true;
}
@ -244,6 +286,8 @@ void DialogPatternProperties::CheckStateSize(int state)
sizes.insert(static_cast<GSizes>(data.value(box)), box->isChecked());
}
UpdateDefSize();
CheckApplyOk();
gradationChanged = true;
}
@ -276,6 +320,19 @@ void DialogPatternProperties::showEvent(QShowEvent *event)
isInitialized = true;//first show windows are held
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::ToggleComboBox()
{
ui->comboBoxHeight->setEnabled(ui->radioButtonDefFromP->isChecked());
ui->comboBoxSize->setEnabled(ui->radioButtonDefFromP->isChecked());
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::DefValueChanged()
{
defaultChanged = true;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::SetHeightsChecked(bool enabled)
{
@ -396,6 +453,86 @@ void DialogPatternProperties::SaveGradation()
emit UpdateGradation();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::SaveDefValues()
{
if (ui->radioButtonDefFromM->isChecked())
{
doc->SetDefCustom(false);
doc->SetDefCustomHeight(0);
doc->SetDefCustomSize(0);
}
else
{
doc->SetDefCustom(true);
const int height = static_cast<int>(UnitConvertor(ui->comboBoxHeight->currentText().toInt(),
Unit::Cm, *pattern->GetPatternUnit()));
doc->SetDefCustomHeight(height);
const int size = static_cast<int>(UnitConvertor(ui->comboBoxSize->currentText().toInt(),
Unit::Cm, *pattern->GetPatternUnit()));
doc->SetDefCustomSize(size);
}
defaultChanged = false;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::SetDefaultHeight(const QString &def)
{
int index = ui->comboBoxHeight->findText(def);
if (index != -1)
{
ui->comboBoxHeight->setCurrentIndex(index);
defaultChanged = true;
}
else
{
const int height = static_cast<int>(UnitConvertor(pattern->height(), *pattern->GetPatternUnit(), Unit::Cm));
index = ui->comboBoxHeight->findText(QString().setNum(height));
if (index != -1)
{
ui->comboBoxHeight->setCurrentIndex(index);
defaultChanged = true;
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::SetDefaultSize(const QString &def)
{
int index = ui->comboBoxSize->findText(def);
if (index != -1)
{
ui->comboBoxSize->setCurrentIndex(index);
defaultChanged = true;
}
else
{
const int size = static_cast<int>(UnitConvertor(pattern->size(), *pattern->GetPatternUnit(), Unit::Cm));
index = ui->comboBoxSize->findText(QString().setNum(size));
if (index != -1)
{
ui->comboBoxSize->setCurrentIndex(index);
defaultChanged = true;
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::UpdateDefHeight()
{
const QString def = ui->comboBoxHeight->currentText();
InitComboBox(ui->comboBoxHeight, heights);
SetDefaultHeight(def);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::UpdateDefSize()
{
const QString def = ui->comboBoxSize->currentText();
InitComboBox(ui->comboBoxSize, sizes);
SetDefaultSize(def);
}
//---------------------------------------------------------------------------------------------------------------------
template<typename Func>
void DialogPatternProperties::Init(QCheckBox *check, int val, Func slot)
@ -425,3 +562,22 @@ void DialogPatternProperties::SetOptions(const QMap<GVal, bool> &option)
}
}
}
//---------------------------------------------------------------------------------------------------------------------
template<typename GVal>
void DialogPatternProperties::InitComboBox(QComboBox *box, const QMap<GVal, bool> &option)
{
SCASSERT(box != nullptr);
box->clear();
QMapIterator<GVal, bool> i(option);
while (i.hasNext())
{
i.next();
if (i.value() && i.key() != GVal::ALL)
{
box->addItem(QString().setNum(static_cast<int>(i.key())));
}
}
}

View file

@ -34,6 +34,7 @@
#include <QMap>
class VPattern;
class VContainer;
class QCheckBox;
namespace Ui
@ -45,7 +46,7 @@ class DialogPatternProperties : public QDialog
{
Q_OBJECT
public:
explicit DialogPatternProperties(VPattern *doc, QWidget *parent = nullptr);
explicit DialogPatternProperties(VPattern *doc, VContainer *pattern, QWidget *parent = nullptr);
virtual ~DialogPatternProperties() Q_DECL_OVERRIDE;
signals:
void UpdateGradation();
@ -58,10 +59,14 @@ public slots:
void DescEdited();
protected:
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
private slots:
void ToggleComboBox();
void DefValueChanged();
private:
Q_DISABLE_COPY(DialogPatternProperties)
Ui::DialogPatternProperties *ui;
VPattern *doc;
VContainer *pattern;
char heightsChecked;
char sizesChecked;
QMap<GHeights, bool> heights;
@ -69,6 +74,7 @@ private:
QMap<QCheckBox *, int> data;
bool descriptionChanged;
bool gradationChanged;
bool defaultChanged;
bool isInitialized;
void SetHeightsChecked(bool enabled);
@ -79,9 +85,18 @@ private:
void Init(QCheckBox *check, int val, Func slot);
template<typename GVal>
void SetOptions(const QMap<GVal, bool> &option);
template<typename GVal>
void InitComboBox(QComboBox *box, const QMap<GVal, bool> &option);
void CheckApplyOk();
void SaveDescription();
void SaveGradation();
void SaveDefValues();
void SetDefaultHeight(const QString &def);
void SetDefaultSize(const QString &def);
void UpdateDefHeight();
void UpdateDefSize();
};
#endif // DIALOGPATTERNPROPERTIES_H

View file

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>657</width>
<height>562</height>
<height>532</height>
</rect>
</property>
<property name="windowTitle">
@ -21,7 +21,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@ -38,8 +38,7 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditAuthor">
</widget>
<widget class="QLineEdit" name="lineEditAuthor"/>
</item>
</layout>
</item>
@ -82,6 +81,85 @@
<string>Heights and Sizes</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Default height and size</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<widget class="QRadioButton" name="radioButtonDefFromM">
<property name="text">
<string>From standard measurements</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QRadioButton" name="radioButtonDefFromP">
<property name="text">
<string>Custom</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Height:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxHeight">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Size:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxSize">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
@ -884,4 +962,7 @@
</hints>
</connection>
</connections>
<buttongroups>
<buttongroup name="buttonGroup"/>
</buttongroups>
</ui>

View file

@ -1054,7 +1054,7 @@ void MainWindow::OpenRecentFile()
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::PatternProperties()
{
DialogPatternProperties proper(doc, this);
DialogPatternProperties proper(doc, pattern, this);
connect(&proper, &DialogPatternProperties::UpdateGradation, this, &MainWindow::UpdateGradation);
proper.exec();
}
@ -1387,17 +1387,7 @@ void MainWindow::ToolBarOption()
gradationHeights = SetGradationList(gradationHeightsLabel, listHeights);
// set default height
{
const qint32 index = gradationHeights->findText(QString("%1").arg(static_cast<int>(pattern->height())));
if (index != -1)
{
gradationHeights->setCurrentIndex(index);
}
else
{
pattern->SetHeight(gradationHeights->currentText().toInt());
}
}
SetDefaultHeight();
connect(gradationHeights.data(),
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
@ -1407,17 +1397,7 @@ void MainWindow::ToolBarOption()
gradationSizes = SetGradationList(gradationSizesLabel, listSizes);
// set default size
{
const qint32 index = gradationSizes->findText(QString("%1").arg(static_cast<int>(pattern->size())));
if (index != -1)
{
gradationSizes->setCurrentIndex(index);
}
else
{
pattern->SetSize(gradationSizes->currentText().toInt());
}
}
SetDefaultSize();
connect(gradationSizes.data(),
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
@ -2653,6 +2633,56 @@ void MainWindow::ChangedHeight(const QString &text)
}
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::SetDefaultHeight()
{
const QString defHeight = QString().setNum(static_cast<int>(UnitConvertor(doc->GetDefCustomHeight(),
*pattern->GetPatternUnit(), Unit::Cm)));
int index = gradationHeights->findText(defHeight);
if (index != -1)
{
gradationHeights->setCurrentIndex(index);
}
else
{
const int height = static_cast<int>(UnitConvertor(pattern->height(), *pattern->GetPatternUnit(), Unit::Cm));
index = gradationHeights->findText(QString().setNum(height));
if (index != -1)
{
gradationHeights->setCurrentIndex(index);
}
else
{
pattern->SetHeight(gradationHeights->currentText().toInt());
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::SetDefaultSize()
{
const QString defSize = QString().setNum(static_cast<int>(UnitConvertor(doc->GetDefCustomSize(),
*pattern->GetPatternUnit(), Unit::Cm)));
int index = gradationSizes->findText(defSize);
if (index != -1)
{
gradationSizes->setCurrentIndex(index);
}
else
{
const int size = static_cast<int>(UnitConvertor(pattern->size(), *pattern->GetPatternUnit(), Unit::Cm));
index = gradationSizes->findText(QString().setNum(size));
if (index != -1)
{
gradationSizes->setCurrentIndex(index);
}
else
{
pattern->SetSize(gradationSizes->currentText().toInt());
}
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ActionTable show table with variables.

View file

@ -240,6 +240,9 @@ private:
VToolOptionsPropertyBrowser *toolOptions;
std::shared_ptr<VLockGuard<char>> lock;
void SetDefaultHeight();
void SetDefaultSize();
void ToolBarOption();
void ToolBarStages();
void ToolBarDraws();

View file

@ -2444,6 +2444,152 @@ QString VPattern::GenerateLabel(const LabelType &type, const QString &reservedNa
return QString();
}
//---------------------------------------------------------------------------------------------------------------------
bool VPattern::IsDefCustom() const
{
QDomNodeList tags = elementsByTagName(TagGradation);
if (tags.size() == 0)
{
return false;
}
const QDomNode domNode = tags.at(0);
const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
return GetParametrBool(domElement, AttrCustom, QStringLiteral("false"));
}
else
{
return false;
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::SetDefCustom(bool value)
{
CheckTagExists(TagGradation);
QDomNodeList tags = elementsByTagName(TagGradation);
if (tags.size() == 0)
{
qDebug()<<"Can't save attribute "<<AttrCustom<<Q_FUNC_INFO;
return;
}
QDomNode domNode = tags.at(0);
QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
SetAttribute(domElement, AttrCustom, value);
}
else
{
qDebug()<<"Can't save attribute "<<AttrCustom<<Q_FUNC_INFO;
}
}
//---------------------------------------------------------------------------------------------------------------------
int VPattern::GetDefCustomHeight() const
{
QDomNodeList tags = elementsByTagName(TagGradation);
if (tags.size() == 0)
{
return 0;
}
const QDomNode domNode = tags.at(0);
const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
return static_cast<int>(GetParametrUInt(domElement, AttrDefHeight, QStringLiteral("0")));
}
else
{
return 0;
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::SetDefCustomHeight(int value)
{
CheckTagExists(TagGradation);
QDomNodeList tags = elementsByTagName(TagGradation);
if (tags.size() == 0)
{
qDebug()<<"Can't save attribute "<<AttrDefHeight<<Q_FUNC_INFO;
return;
}
QDomNode domNode = tags.at(0);
QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
if (value == 0)
{
domElement.removeAttribute(AttrDefHeight);
}
else
{
SetAttribute(domElement, AttrDefHeight, value);
}
}
else
{
qDebug()<<"Can't save attribute "<<AttrDefHeight<<Q_FUNC_INFO;
}
}
//---------------------------------------------------------------------------------------------------------------------
int VPattern::GetDefCustomSize() const
{
QDomNodeList tags = elementsByTagName(TagGradation);
if (tags.size() == 0)
{
return 0;
}
const QDomNode domNode = tags.at(0);
const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
return static_cast<int>(GetParametrUInt(domElement, AttrDefSize, QStringLiteral("0")));
}
else
{
return 0;
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::SetDefCustomSize(int value)
{
CheckTagExists(TagGradation);
QDomNodeList tags = elementsByTagName(TagGradation);
if (tags.size() == 0)
{
qDebug()<<"Can't save attribute "<<AttrDefSize<<Q_FUNC_INFO;
return;
}
QDomNode domNode = tags.at(0);
QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
if (value == 0)
{
domElement.removeAttribute(AttrDefSize);
}
else
{
SetAttribute(domElement, AttrDefSize, value);
}
}
else
{
qDebug()<<"Can't save attribute "<<AttrDefSize<<Q_FUNC_INFO;
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::PrepareForParse(const Document &parse)
{

View file

@ -77,6 +77,15 @@ public:
virtual QString GenerateLabel(const LabelType &type, const QString &reservedName = QString())const Q_DECL_OVERRIDE;
bool IsDefCustom() const;
void SetDefCustom(bool value);
int GetDefCustomHeight() const;
void SetDefCustomHeight(int value);
int GetDefCustomSize() const;
void SetDefCustomSize(int value);
public slots:
void LiteParseTree(const Document &parse);

View file

@ -7,6 +7,7 @@
<file>schema/pattern/v0.1.4.xsd</file>
<file>schema/pattern/v0.2.0.xsd</file>
<file>schema/pattern/v0.2.1.xsd</file>
<file>schema/pattern/v0.2.2.xsd</file>
<file>schema/standard_measurements/v0.3.0.xsd</file>
<file>schema/standard_measurements/v0.4.0.xsd</file>
<file>schema/standard_measurements/v0.4.1.xsd</file>

View file

@ -0,0 +1,332 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<!-- XML Schema Generated from XML Document-->
<xs:element name="pattern">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="unbounded">
<xs:element name="version" type="formatVersion"></xs:element>
<xs:element name="unit" type="units"></xs:element>
<xs:element name="author" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="description" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="notes" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="gradation" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="heights">
<xs:complexType>
<xs:attribute name="all" type="xs:boolean" use="required"></xs:attribute>
<xs:attribute name="h92" type="xs:boolean"></xs:attribute>
<xs:attribute name="h98" type="xs:boolean"></xs:attribute>
<xs:attribute name="h104" type="xs:boolean"></xs:attribute>
<xs:attribute name="h110" type="xs:boolean"></xs:attribute>
<xs:attribute name="h116" type="xs:boolean"></xs:attribute>
<xs:attribute name="h122" type="xs:boolean"></xs:attribute>
<xs:attribute name="h128" type="xs:boolean"></xs:attribute>
<xs:attribute name="h134" type="xs:boolean"></xs:attribute>
<xs:attribute name="h140" type="xs:boolean"></xs:attribute>
<xs:attribute name="h146" type="xs:boolean"></xs:attribute>
<xs:attribute name="h152" type="xs:boolean"></xs:attribute>
<xs:attribute name="h158" type="xs:boolean"></xs:attribute>
<xs:attribute name="h164" type="xs:boolean"></xs:attribute>
<xs:attribute name="h170" type="xs:boolean"></xs:attribute>
<xs:attribute name="h176" type="xs:boolean"></xs:attribute>
<xs:attribute name="h182" type="xs:boolean"></xs:attribute>
<xs:attribute name="h188" type="xs:boolean"></xs:attribute>
<xs:attribute name="h194" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="sizes">
<xs:complexType>
<xs:attribute name="all" type="xs:boolean" use="required"></xs:attribute>
<xs:attribute name="s22" type="xs:boolean"></xs:attribute>
<xs:attribute name="s24" type="xs:boolean"></xs:attribute>
<xs:attribute name="s26" type="xs:boolean"></xs:attribute>
<xs:attribute name="s28" type="xs:boolean"></xs:attribute>
<xs:attribute name="s30" type="xs:boolean"></xs:attribute>
<xs:attribute name="s32" type="xs:boolean"></xs:attribute>
<xs:attribute name="s34" type="xs:boolean"></xs:attribute>
<xs:attribute name="s36" type="xs:boolean"></xs:attribute>
<xs:attribute name="s38" type="xs:boolean"></xs:attribute>
<xs:attribute name="s40" type="xs:boolean"></xs:attribute>
<xs:attribute name="s42" type="xs:boolean"></xs:attribute>
<xs:attribute name="s44" type="xs:boolean"></xs:attribute>
<xs:attribute name="s46" type="xs:boolean"></xs:attribute>
<xs:attribute name="s48" type="xs:boolean"></xs:attribute>
<xs:attribute name="s50" type="xs:boolean"></xs:attribute>
<xs:attribute name="s52" type="xs:boolean"></xs:attribute>
<xs:attribute name="s54" type="xs:boolean"></xs:attribute>
<xs:attribute name="s56" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="custom" type="xs:boolean"></xs:attribute>
<xs:attribute name="defHeight" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="defSize" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="measurements" type="xs:string"></xs:element>
<xs:element name="increments" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="increment" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="description" type="xs:string" use="required"></xs:attribute>
<xs:attribute name="name" type="shortName" use="required"></xs:attribute>
<xs:attribute name="formula" type="xs:string" use="required"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:unique name="incrementName">
<xs:selector xpath="increment"/>
<xs:field xpath="@name"/>
</xs:unique>
</xs:element>
<xs:element name="draw" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="calculation" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="point" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="x" type="xs:double"></xs:attribute>
<xs:attribute name="y" type="xs:double"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="name" type="shortName"></xs:attribute>
<xs:attribute name="firstPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="secondPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="thirdPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="basePoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="pShoulder" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p1Line" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p2Line" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="length" type="xs:string"></xs:attribute>
<xs:attribute name="angle" type="xs:string"></xs:attribute>
<xs:attribute name="typeLine" type="xs:string"></xs:attribute>
<xs:attribute name="splinePath" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="spline" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p1Line1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p1Line2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p2Line1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p2Line2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="center" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="radius" type="xs:string"></xs:attribute>
<xs:attribute name="axisP1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="axisP2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="arc" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="curve" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="lineColor" type="colors"></xs:attribute>
<xs:attribute name="color" type="colors"></xs:attribute>
<xs:attribute name="firstArc" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="secondArc" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="crossPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="c1Center" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="c2Center" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="c1Radius" type="xs:string"></xs:attribute>
<xs:attribute name="c2Radius" type="xs:string"></xs:attribute>
<xs:attribute name="cRadius" type="xs:string"></xs:attribute>
<xs:attribute name="tangent" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="cCenter" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="name1" type="shortName"></xs:attribute>
<xs:attribute name="mx1" type="xs:double"></xs:attribute>
<xs:attribute name="my1" type="xs:double"></xs:attribute>
<xs:attribute name="name2" type="shortName"></xs:attribute>
<xs:attribute name="mx2" type="xs:double"></xs:attribute>
<xs:attribute name="my2" type="xs:double"></xs:attribute>
<xs:attribute name="point1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="point2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="dartP1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="dartP2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="dartP3" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="baseLineP1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="baseLineP2" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="firstPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="secondPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="typeLine" type="xs:string"></xs:attribute>
<xs:attribute name="lineColor" type="colors"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="arc" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="angle1" type="xs:string"></xs:attribute>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="angle2" type="xs:string"></xs:attribute>
<xs:attribute name="radius" type="xs:string"></xs:attribute>
<xs:attribute name="center" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="color" type="colors"></xs:attribute>
<xs:attribute name="length" type="xs:string"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="spline" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="pathPoint" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="kAsm2" type="xs:string"></xs:attribute>
<xs:attribute name="pSpline" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="angle" type="xs:string"></xs:attribute>
<xs:attribute name="kAsm1" type="xs:string"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="kCurve" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="kAsm1" type="xs:double"></xs:attribute>
<xs:attribute name="kAsm2" type="xs:double"></xs:attribute>
<xs:attribute name="angle1" type="xs:double"></xs:attribute>
<xs:attribute name="angle2" type="xs:double"></xs:attribute>
<xs:attribute name="point1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="point4" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="color" type="colors"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="modeling" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="point" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="typeObject" type="xs:string"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="idTool" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="arc" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="typeObject" type="xs:string"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="idTool" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="spline" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="typeObject" type="xs:string"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="idTool" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="tools" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="det" minOccurs="2" maxOccurs="2">
<xs:complexType>
<xs:sequence>
<xs:element name="node" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="nodeType" type="xs:string"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="reverse" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="indexD1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="indexD2" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="details" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="detail" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="node" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="nodeType" type="xs:string"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="reverse" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="supplement" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="width" type="xs:double"></xs:attribute>
<xs:attribute name="name" type="xs:string"></xs:attribute>
<xs:attribute name="closed" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name" type="xs:string"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="shortName">
<xs:restriction base="xs:string">
<xs:pattern value="^([^0-9*/^+\-=\s()?%:;!.,`'\&quot;]){1,1}([^*/^+\-=\s()?%:;!.,`'\&quot;]){0,}$"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="units">
<xs:restriction base="xs:string">
<xs:enumeration value="mm"/>
<xs:enumeration value="cm"/>
<xs:enumeration value="inch"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="measurementsTypes">
<xs:restriction base="xs:string">
<xs:enumeration value="standard"/>
<xs:enumeration value="individual"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="formatVersion">
<xs:restriction base="xs:string">
<xs:pattern value="^(0|([1-9][0-9]*))\.(0|([1-9][0-9]*))\.(0|([1-9][0-9]*))$"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="colors">
<xs:restriction base="xs:string">
<xs:enumeration value="black"/>
<xs:enumeration value="green"/>
<xs:enumeration value="blue"/>
<xs:enumeration value="darkRed"/>
<xs:enumeration value="darkGreen"/>
<xs:enumeration value="darkBlue"/>
<xs:enumeration value="yellow"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

View file

@ -96,6 +96,10 @@ const QString VAbstractPattern::AttrS52 = QStringLiteral("s52");
const QString VAbstractPattern::AttrS54 = QStringLiteral("s54");
const QString VAbstractPattern::AttrS56 = QStringLiteral("s56");
const QString VAbstractPattern::AttrCustom = QStringLiteral("custom");
const QString VAbstractPattern::AttrDefHeight = QStringLiteral("defHeight");
const QString VAbstractPattern::AttrDefSize = QStringLiteral("defSize");
const QString VAbstractPattern::IncrementName = QStringLiteral("name");
const QString VAbstractPattern::IncrementFormula = QStringLiteral("formula");
const QString VAbstractPattern::IncrementDescription = QStringLiteral("description");

View file

@ -167,6 +167,10 @@ public:
static const QString AttrS54;
static const QString AttrS56;
static const QString AttrCustom;
static const QString AttrDefHeight;
static const QString AttrDefSize;
static const QString IncrementName;
static const QString IncrementFormula;
static const QString IncrementDescription;

View file

@ -455,7 +455,7 @@ void VDomDocument::ValidateXML(const QString &schema, const QString &fileName)
{
pattern.close();
fileSchema.close();
const QString errorMsg(tr("Could not load schema file.").arg(fileSchema.fileName()));
const QString errorMsg(tr("Could not load schema file '%1'.").arg(fileSchema.fileName()));
throw VException(errorMsg);
}
qCDebug(vXML, "Schema loaded.");

View file

@ -43,8 +43,8 @@
*/
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.2.1");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.2.1.xsd");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.2.2");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.2.2.xsd");
//---------------------------------------------------------------------------------------------------------------------
VPatternConverter::VPatternConverter(const QString &fileName)
@ -102,6 +102,8 @@ QString VPatternConverter::XSDSchema(int ver) const
case (0x000200):
return QStringLiteral("://schema/pattern/v0.2.0.xsd");
case (0x000201):
return QStringLiteral("://schema/pattern/v0.2.1.xsd");
case (0x000202):
return CurrentSchema;
default:
{
@ -161,6 +163,13 @@ void VPatternConverter::ApplyPatches()
V_FALLTHROUGH
}
case (0x000201):
{
ToV0_2_2();
const QString schema = XSDSchema(0x000202);
ValidateXML(schema, fileName);
V_FALLTHROUGH
}
case (0x000202):
break;
default:
break;
@ -232,6 +241,13 @@ void VPatternConverter::ToV0_2_1()
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::ToV0_2_2()
{
SetVersion(QStringLiteral("0.2.2"));
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::TagUnitToV0_2_0()
{

View file

@ -61,6 +61,7 @@ private:
void ToV0_1_4();
void ToV0_2_0();
void ToV0_2_1();
void ToV0_2_2();
void TagUnitToV0_2_0();
void TagIncrementToV0_2_0();

View file

@ -1,12 +1,12 @@
<?xml version='1.0' encoding='UTF-8'?>
<pattern>
<!--Pattern created with Valentina (http://www.valentina-project.org/).-->
<version>0.2.1</version>
<version>0.2.2</version>
<unit>cm</unit>
<author/>
<description/>
<notes/>
<gradation>
<gradation custom="false">
<heights h116="true" h176="true" h104="true" h164="false" h152="true" h92="true" h140="true" h98="true" h158="true" h146="true" h134="true" h194="true" all="false" h122="true" h182="true" h110="true" h170="true" h128="true" h188="true"/>
<sizes s34="true" s36="true" s22="true" s38="true" s24="true" s26="true" s28="true" s50="true" s52="true" s54="true" s40="true" s56="true" all="false" s42="true" s44="true" s30="true" s46="false" s48="true" s32="true"/>
</gradation>