Merge with feature

--HG--
branch : develop
This commit is contained in:
dismine 2014-08-09 10:42:28 +03:00
commit 9435c9fe22
13 changed files with 1982 additions and 140 deletions

View File

@ -97,7 +97,7 @@ VMeasurement::~VMeasurement()
{}
//---------------------------------------------------------------------------------------------------------------------
QStringList VMeasurement::ListHeights()
QStringList VMeasurement::ListHeights(QMap<GHeights, bool> heights)
{
QStringList list;
if (qApp->patternUnit() == Unit::Inch)
@ -106,16 +106,29 @@ QStringList VMeasurement::ListHeights()
return list;
}
// from 92 cm to 188 cm
for (int i = 92; i<= 188; i = i+6)
QMap<GHeights, bool>::const_iterator i = heights.constBegin();
while (i != heights.constEnd())
{
if (i.value() && i.key() != GHeights::ALL)
{
ListValue(list, static_cast<int>(i.key()));
}
++i;
}
if (list.isEmpty())
{
// from 92 cm to 194 cm
for (int i = 92; i<= 194; i = i+6)
{
ListValue(list, i);
}
}
return list;
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VMeasurement::ListSizes()
QStringList VMeasurement::ListSizes(QMap<GSizes, bool> sizes)
{
QStringList list;
if (qApp->patternUnit() == Unit::Inch)
@ -124,11 +137,24 @@ QStringList VMeasurement::ListSizes()
return list;
}
QMap<GSizes, bool>::const_iterator i = sizes.constBegin();
while (i != sizes.constEnd())
{
if (i.value() && i.key() != GSizes::ALL)
{
ListValue(list, static_cast<int>(i.key()));
}
++i;
}
if (list.isEmpty())
{
// from 22 cm to 56 cm
for (int i = 22; i<= 56; i = i+2)
{
ListValue(list, i);
}
}
return list;
}

View File

@ -30,6 +30,7 @@
#define VSTANDARDTABLEROW_H
#include "vvariable.h"
#include "../options.h"
#include <QStringList>
@ -52,8 +53,8 @@ public:
QString GetGuiText() const;
QString TagName() const;
void setTagName(const QString &TagName);
static QStringList ListHeights();
static QStringList ListSizes();
static QStringList ListHeights(QMap<GHeights, bool> heights);
static QStringList ListSizes(QMap<GSizes, bool> sizes);
private:
/** @brief description description measurement */
QString gui_text;

View File

@ -28,40 +28,56 @@
#include "dialogpatternproperties.h"
#include "ui_dialogpatternproperties.h"
#include <QSettings>
#include <QPushButton>
#include "../../xml/vpattern.h"
#include "../../widgets/vapplication.h"
#define MAX_HEIGHTS 18
#define MAX_SIZES 18
//---------------------------------------------------------------------------------------------------------------------
DialogPatternProperties::DialogPatternProperties(VPattern *doc, QWidget *parent) :
QDialog(parent), ui(new Ui::DialogPatternProperties), doc(doc)
QDialog(parent), ui(new Ui::DialogPatternProperties), doc(doc), heightsChecked(MAX_HEIGHTS),
sizesChecked(MAX_SIZES), heights (QMap<GHeights, bool>()), sizes(QMap<GSizes, bool>()),
data(QMap<QCheckBox *, int>()), descriptionChanged(false), gradationChanged(false)
{
ui->setupUi(this);
SCASSERT(doc != nullptr);
QSettings *settings = qApp->getSettings();
SCASSERT(settings != nullptr);
#ifdef Q_OS_WIN
QString user = settings->value("pattern/user", QString::fromLocal8Bit(qgetenv("USERNAME").constData())).toString();
#else
QString user = settings->value("pattern/user", QString::fromLocal8Bit(qgetenv("USER").constData())).toString();
#endif
ui->lineEditAuthor->setText(doc->GetAuthor());
connect(ui->lineEditAuthor, &QLineEdit::editingFinished, this, &DialogPatternProperties::DescEdited);
ui->lineEditAuthor->setText(this->doc->UniqueTagText("author", user));
ui->plainTextEditDescription->setPlainText(this->doc->UniqueTagText("description"));
ui->plainTextEditTechNotes->setPlainText(this->doc->UniqueTagText("notes"));
ui->plainTextEditDescription->setPlainText(doc->GetDescription());
connect(ui->plainTextEditDescription, &QPlainTextEdit::textChanged, this, &DialogPatternProperties::DescEdited);
QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
SCASSERT(bOk != nullptr);
connect(bOk, &QPushButton::clicked, this, &DialogPatternProperties::Apply);
ui->plainTextEditTechNotes->setPlainText(doc->GetNotes());
connect(ui->plainTextEditTechNotes, &QPlainTextEdit::textChanged, this, &DialogPatternProperties::DescEdited);
connect(ui->buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked, this, &DialogPatternProperties::Ok);
connect(ui->buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked, this,
&DialogPatternProperties::Apply);
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
SCASSERT(bCansel != nullptr);
connect(bCansel, &QPushButton::clicked, this, &DialogPatternProperties::close);
connect(this, &DialogPatternProperties::haveChange, this->doc, &VPattern::haveLiteChange);
ui->tabWidget->setCurrentIndex(0);
if (qApp->patternType() == MeasurementsType::Individual)
{
ui->tabWidget->setTabEnabled(1, false);
}
InitHeights();
InitSizes();
heights = doc->GetGradationHeights();
sizes = doc->GetGradationSizes();
SetOptions(heights);
SetOptions(sizes);
gradationChanged = false;//Set to default value after initialization
}
//---------------------------------------------------------------------------------------------------------------------
@ -73,49 +89,312 @@ DialogPatternProperties::~DialogPatternProperties()
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::Apply()
{
Write("notes", ui->plainTextEditTechNotes->document()->toPlainText());
Write("description", ui->plainTextEditDescription->document()->toPlainText());
Write("author", ui->lineEditAuthor->text());
emit haveChange();
switch (ui->tabWidget->currentIndex())
{
case 0:
SaveDescription();
descriptionChanged = false;
break;
case 1:
SaveGradation();
gradationChanged = false;
break;
default:
break;
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::Ok()
{
if (descriptionChanged)
{
SaveDescription();
descriptionChanged = false;
}
if (gradationChanged)
{
SaveGradation();
gradationChanged = false;
}
close();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::Write(const QString &tagName, const QString &text) const
void DialogPatternProperties::SelectAll(int state)
{
QDomNodeList nodeList = doc->elementsByTagName(tagName);
if (nodeList.isEmpty())
QCheckBox* box = qobject_cast<QCheckBox*>(sender());
if (box)
{
QDomElement pattern = doc->documentElement();
if (box == ui->checkBoxAllHeights)
{
if (state == Qt::Checked)
{
SetHeightsChecked(true);
}
else if (state == Qt::Unchecked)
{
SetHeightsChecked(false);
}
QDomElement tag = doc->createElement(tagName);
QDomText domText = doc->createTextNode(text);
tag.appendChild(domText);
//Old pattern file doesn't have comment. But here we try insert tag after first child (comment).
// <pattern>
// <!--Valentina pattern format.-->
// -->place for new tag<--
// </pattern>
if (pattern.firstChild().isComment())
if (data.contains(box))
{
pattern.insertAfter(tag, pattern.firstChild());
}
else
{
pattern.insertBefore(tag, pattern.firstChild());
heights.insert(static_cast<GHeights>(data.value(box)), box->isChecked());
}
}
else
{
QDomElement oldTag = nodeList.at(0).toElement();
if (oldTag.isElement())
{
QDomElement newTag = doc->createElement(tagName);
QDomText domText = doc->createTextNode(text);
newTag.appendChild(domText);
QDomElement pattern = doc->documentElement();
pattern.replaceChild(newTag, oldTag);
if (box == ui->checkBoxAllSizes)
{
if (state == Qt::Checked)
{
SetSizesChecked(true);
}
else if (state == Qt::Unchecked)
{
SetSizesChecked(false);
}
if (data.contains(box))
{
sizes.insert(static_cast<GSizes>(data.value(box)), box->isChecked());
}
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::CheckStateHeight(int state)
{
QCheckBox* box = qobject_cast<QCheckBox*>(sender());
if (box)
{
if (state == Qt::Checked)
{
++heightsChecked;
if (heightsChecked == MAX_HEIGHTS)
{
ui->checkBoxAllHeights->blockSignals(true);//don't touch anothers checkboxes
ui->checkBoxAllHeights->setCheckState(Qt::Checked);
heights.insert(GHeights::ALL, true);
ui->checkBoxAllHeights->blockSignals(false);
}
}
else if (state == Qt::Unchecked)
{
if (heightsChecked == MAX_HEIGHTS)
{
ui->checkBoxAllHeights->blockSignals(true);//don't touch anothers checkboxes
ui->checkBoxAllHeights->setCheckState(Qt::Unchecked);
heights.insert(GHeights::ALL, false);
ui->checkBoxAllHeights->blockSignals(false);
}
--heightsChecked;
}
if (data.contains(box))
{
heights.insert(static_cast<GHeights>(data.value(box)), box->isChecked());
}
CheckApplyOk();
gradationChanged = true;
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::CheckStateSize(int state)
{
QCheckBox* box = qobject_cast<QCheckBox*>(sender());
if (box)
{
if (state == Qt::Checked)
{
++sizesChecked;
if (sizesChecked == MAX_SIZES)
{
ui->checkBoxAllSizes->blockSignals(true);//don't touch anothers checkboxes
ui->checkBoxAllSizes->setCheckState(Qt::Checked);
sizes.insert(GSizes::ALL, true);
ui->checkBoxAllSizes->blockSignals(false);
}
}
else if (state == Qt::Unchecked)
{
if (sizesChecked == MAX_SIZES)
{
ui->checkBoxAllSizes->blockSignals(true);//don't touch anothers checkboxes
ui->checkBoxAllSizes->setCheckState(Qt::Unchecked);
sizes.insert(GSizes::ALL, false);
ui->checkBoxAllSizes->blockSignals(false);
}
--sizesChecked;
}
if (data.contains(box))
{
sizes.insert(static_cast<GSizes>(data.value(box)), box->isChecked());
}
CheckApplyOk();
gradationChanged = true;
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::DescEdited()
{
descriptionChanged = true;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::SetHeightsChecked(bool enabled)
{
ui->checkBoxH92->setChecked(enabled);
ui->checkBoxH98->setChecked(enabled);
ui->checkBoxH104->setChecked(enabled);
ui->checkBoxH110->setChecked(enabled);
ui->checkBoxH116->setChecked(enabled);
ui->checkBoxH122->setChecked(enabled);
ui->checkBoxH128->setChecked(enabled);
ui->checkBoxH134->setChecked(enabled);
ui->checkBoxH140->setChecked(enabled);
ui->checkBoxH146->setChecked(enabled);
ui->checkBoxH152->setChecked(enabled);
ui->checkBoxH158->setChecked(enabled);
ui->checkBoxH164->setChecked(enabled);
ui->checkBoxH170->setChecked(enabled);
ui->checkBoxH176->setChecked(enabled);
ui->checkBoxH182->setChecked(enabled);
ui->checkBoxH188->setChecked(enabled);
ui->checkBoxH194->setChecked(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::SetSizesChecked(bool enabled)
{
ui->checkBoxS22->setChecked(enabled);
ui->checkBoxS24->setChecked(enabled);
ui->checkBoxS26->setChecked(enabled);
ui->checkBoxS28->setChecked(enabled);
ui->checkBoxS30->setChecked(enabled);
ui->checkBoxS32->setChecked(enabled);
ui->checkBoxS34->setChecked(enabled);
ui->checkBoxS36->setChecked(enabled);
ui->checkBoxS38->setChecked(enabled);
ui->checkBoxS40->setChecked(enabled);
ui->checkBoxS42->setChecked(enabled);
ui->checkBoxS44->setChecked(enabled);
ui->checkBoxS46->setChecked(enabled);
ui->checkBoxS48->setChecked(enabled);
ui->checkBoxS50->setChecked(enabled);
ui->checkBoxS52->setChecked(enabled);
ui->checkBoxS54->setChecked(enabled);
ui->checkBoxS56->setChecked(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::InitHeights()
{
Init(ui->checkBoxAllHeights, static_cast<int>(GHeights::ALL), &DialogPatternProperties::SelectAll);
Init(ui->checkBoxH92, static_cast<int>(GHeights::H92), &DialogPatternProperties::CheckStateHeight);
Init(ui->checkBoxH98, static_cast<int>(GHeights::H98), &DialogPatternProperties::CheckStateHeight);
Init(ui->checkBoxH104, static_cast<int>(GHeights::H104), &DialogPatternProperties::CheckStateHeight);
Init(ui->checkBoxH110, static_cast<int>(GHeights::H110), &DialogPatternProperties::CheckStateHeight);
Init(ui->checkBoxH116, static_cast<int>(GHeights::H116), &DialogPatternProperties::CheckStateHeight);
Init(ui->checkBoxH122, static_cast<int>(GHeights::H122), &DialogPatternProperties::CheckStateHeight);
Init(ui->checkBoxH128, static_cast<int>(GHeights::H128), &DialogPatternProperties::CheckStateHeight);
Init(ui->checkBoxH134, static_cast<int>(GHeights::H134), &DialogPatternProperties::CheckStateHeight);
Init(ui->checkBoxH140, static_cast<int>(GHeights::H140), &DialogPatternProperties::CheckStateHeight);
Init(ui->checkBoxH146, static_cast<int>(GHeights::H146), &DialogPatternProperties::CheckStateHeight);
Init(ui->checkBoxH152, static_cast<int>(GHeights::H152), &DialogPatternProperties::CheckStateHeight);
Init(ui->checkBoxH158, static_cast<int>(GHeights::H158), &DialogPatternProperties::CheckStateHeight);
Init(ui->checkBoxH164, static_cast<int>(GHeights::H164), &DialogPatternProperties::CheckStateHeight);
Init(ui->checkBoxH170, static_cast<int>(GHeights::H170), &DialogPatternProperties::CheckStateHeight);
Init(ui->checkBoxH176, static_cast<int>(GHeights::H176), &DialogPatternProperties::CheckStateHeight);
Init(ui->checkBoxH182, static_cast<int>(GHeights::H182), &DialogPatternProperties::CheckStateHeight);
Init(ui->checkBoxH188, static_cast<int>(GHeights::H188), &DialogPatternProperties::CheckStateHeight);
Init(ui->checkBoxH194, static_cast<int>(GHeights::H194), &DialogPatternProperties::CheckStateHeight);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::InitSizes()
{
Init(ui->checkBoxAllSizes, static_cast<int>(GSizes::ALL), &DialogPatternProperties::SelectAll);
Init(ui->checkBoxS22, static_cast<int>(GSizes::S22), &DialogPatternProperties::CheckStateSize);
Init(ui->checkBoxS24, static_cast<int>(GSizes::S24), &DialogPatternProperties::CheckStateSize);
Init(ui->checkBoxS26, static_cast<int>(GSizes::S26), &DialogPatternProperties::CheckStateSize);
Init(ui->checkBoxS28, static_cast<int>(GSizes::S28), &DialogPatternProperties::CheckStateSize);
Init(ui->checkBoxS30, static_cast<int>(GSizes::S30), &DialogPatternProperties::CheckStateSize);
Init(ui->checkBoxS32, static_cast<int>(GSizes::S32), &DialogPatternProperties::CheckStateSize);
Init(ui->checkBoxS34, static_cast<int>(GSizes::S34), &DialogPatternProperties::CheckStateSize);
Init(ui->checkBoxS36, static_cast<int>(GSizes::S36), &DialogPatternProperties::CheckStateSize);
Init(ui->checkBoxS38, static_cast<int>(GSizes::S38), &DialogPatternProperties::CheckStateSize);
Init(ui->checkBoxS40, static_cast<int>(GSizes::S40), &DialogPatternProperties::CheckStateSize);
Init(ui->checkBoxS42, static_cast<int>(GSizes::S42), &DialogPatternProperties::CheckStateSize);
Init(ui->checkBoxS44, static_cast<int>(GSizes::S44), &DialogPatternProperties::CheckStateSize);
Init(ui->checkBoxS46, static_cast<int>(GSizes::S46), &DialogPatternProperties::CheckStateSize);
Init(ui->checkBoxS48, static_cast<int>(GSizes::S48), &DialogPatternProperties::CheckStateSize);
Init(ui->checkBoxS50, static_cast<int>(GSizes::S50), &DialogPatternProperties::CheckStateSize);
Init(ui->checkBoxS52, static_cast<int>(GSizes::S52), &DialogPatternProperties::CheckStateSize);
Init(ui->checkBoxS54, static_cast<int>(GSizes::S54), &DialogPatternProperties::CheckStateSize);
Init(ui->checkBoxS56, static_cast<int>(GSizes::S56), &DialogPatternProperties::CheckStateSize);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::CheckApplyOk()
{
bool enable = !(heightsChecked == 0 || sizesChecked == 0);
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(enable);
ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(enable);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::SaveDescription()
{
doc->SetNotes(ui->plainTextEditTechNotes->document()->toPlainText());
doc->SetDescription(ui->plainTextEditTechNotes->document()->toPlainText());
doc->SetAuthor(ui->lineEditAuthor->text());
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::SaveGradation()
{
doc->SetGradationHeights(heights);
doc->SetGradationSizes(sizes);
emit UpdateGradation();
}
//---------------------------------------------------------------------------------------------------------------------
template<typename Func>
void DialogPatternProperties::Init(QCheckBox *check, int val, Func slot)
{
connect(check, &QCheckBox::stateChanged, this, slot);
data.insert(check, val);
}
//---------------------------------------------------------------------------------------------------------------------
template<typename GVal>
void DialogPatternProperties::SetOptions(const QMap<GVal, bool> &option)
{
if (option.value(GVal::ALL) == false)
{
QMapIterator<GVal, bool> i(option);
while (i.hasNext())
{
i.next();
if (i.value() == false && i.key() != GVal::ALL)
{
QCheckBox *box = data.key(static_cast<int>(i.key()));
if (box != nullptr)
{
box->setCheckState(Qt::Unchecked);
}
}
}
}
}

View File

@ -30,8 +30,10 @@
#define DIALOGPATTERNPROPERTIES_H
#include <QDialog>
#include "../../options.h"
class VPattern;
class QCheckBox;
namespace Ui
{
@ -45,14 +47,37 @@ public:
DialogPatternProperties(VPattern *doc, QWidget *parent = nullptr);
virtual ~DialogPatternProperties();
signals:
void haveChange();
void UpdateGradation();
public slots:
void Apply();
void Ok();
void SelectAll(int state);
void CheckStateHeight(int state);
void CheckStateSize(int state);
void DescEdited();
private:
Q_DISABLE_COPY(DialogPatternProperties)
Ui::DialogPatternProperties *ui;
VPattern *doc;
void Write(const QString &tagName, const QString &text) const;
char heightsChecked;
char sizesChecked;
QMap<GHeights, bool> heights;
QMap<GSizes, bool> sizes;
QMap<QCheckBox *, int> data;
bool descriptionChanged;
bool gradationChanged;
void SetHeightsChecked(bool enabled);
void SetSizesChecked(bool enabled);
void InitHeights();
void InitSizes();
template<typename Func>
void Init(QCheckBox *check, int val, Func slot);
template<typename GVal>
void SetOptions(const QMap<GVal, bool> &option);
void CheckApplyOk();
void SaveDescription();
void SaveGradation();
};
#endif // DIALOGPATTERNPROPERTIES_H

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>646</width>
<height>605</height>
<width>657</width>
<height>562</height>
</rect>
</property>
<property name="windowTitle">
@ -17,6 +17,16 @@
<iconset resource="../../share/resources/icon.qrc">
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Description</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
@ -64,13 +74,773 @@
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Heights and Sizes</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QCheckBox" name="checkBoxAllHeights">
<property name="text">
<string>All heights (cm)</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
<item row="0" column="0">
<widget class="QCheckBox" name="checkBoxH92">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>92</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="checkBoxH146">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>146</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBoxH98">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>98</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="checkBoxH152">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>152</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="checkBoxH104">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>104</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="checkBoxH158">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>158</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="checkBoxH110">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>110</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="checkBoxH164">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>164</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="checkBoxH116">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>116</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="checkBoxH170">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>170</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="checkBoxH122">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>122</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="checkBoxH176">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>176</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="checkBoxH128">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>128</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="checkBoxH182">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>182</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="checkBoxH134">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>134</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QCheckBox" name="checkBoxH188">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>188</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="checkBoxH140">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>140</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QCheckBox" name="checkBoxH194">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>194</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QCheckBox" name="checkBoxAllSizes">
<property name="text">
<string>All sizes (cm)</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_2">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="checkBoxS22">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>22</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="checkBoxS40">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>40</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBoxS24">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>24</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="checkBoxS42">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>42</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="checkBoxS26">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>26</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="checkBoxS44">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>44</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="checkBoxS28">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>28</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="checkBoxS46">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>46</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="checkBoxS30">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>30</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="checkBoxS48">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>48</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="checkBoxS32">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>32</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="checkBoxS50">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>50</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="checkBoxS34">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>34</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="checkBoxS52">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>52</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="checkBoxS36">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>36</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QCheckBox" name="checkBoxS54">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>54</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="checkBoxS38">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>38</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QCheckBox" name="checkBoxS56">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>56</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>

View File

@ -65,7 +65,8 @@ MainWindow::MainWindow(QWidget *parent)
view(nullptr), isInitialized(false), dialogTable(0), dialogTool(nullptr), dialogHistory(nullptr),
comboBoxDraws(nullptr), curFile(QString()), mode(Draw::Calculation), currentDrawIndex(0),
currentToolBoxIndex(0), drawMode(true), recentFileActs{nullptr, nullptr, nullptr, nullptr, nullptr},
separatorAct(nullptr), autoSaveTimer(nullptr), guiEnabled(true)
separatorAct(nullptr), autoSaveTimer(nullptr), guiEnabled(true), gradationHeights(nullptr),
gradationSizes(nullptr)
{
CreateActions();
CreateMenus();
@ -690,6 +691,7 @@ void MainWindow::OpenRecentFile()
void MainWindow::PatternProperties()
{
DialogPatternProperties proper(doc, this);
connect(&proper, &DialogPatternProperties::UpdateGradation, this, &MainWindow::UpdateGradation);
proper.exec();
}
@ -761,11 +763,18 @@ void MainWindow::ToolBarOption()
{
if (qApp->patternType() == MeasurementsType::Standard)
{
const QStringList listHeights = VMeasurement::ListHeights();
const QStringList listSizes = VMeasurement::ListSizes();
const QStringList listHeights = VMeasurement::ListHeights(doc->GetGradationHeights());
const QStringList listSizes = VMeasurement::ListSizes(doc->GetGradationSizes());
SetGradationList(tr("Height: "), listHeights, &MainWindow::ChangedHeight);
SetGradationList(tr("Size: "), listSizes, &MainWindow::ChangedSize);
gradationHeights = SetGradationList(tr("Height: "), listHeights);
SetDefaultHeight(static_cast<int>(GHeights::H176));
connect(gradationHeights, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &MainWindow::ChangedHeight);
gradationSizes = SetGradationList(tr("Size: "), listSizes);
SetDefaultSize(static_cast<int>(GSizes::S50));
connect(gradationSizes, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &MainWindow::ChangedSize);
ui->toolBarOption->addSeparator();
}
@ -775,17 +784,49 @@ void MainWindow::ToolBarOption()
}
//---------------------------------------------------------------------------------------------------------------------
template <typename Func>
void MainWindow::SetGradationList(const QString &label, const QStringList &list, Func changeSlot)
QComboBox *MainWindow::SetGradationList(const QString &label, const QStringList &list)
{
ui->toolBarOption->addWidget(new QLabel(label));
QComboBox *comboBox = new QComboBox;
comboBox->addItems(list);
comboBox->setCurrentIndex(14);//176 cm
ui->toolBarOption->addWidget(comboBox);
connect(comboBox, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, changeSlot);
return comboBox;
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::SetDefaultHeight(int value)
{
qreal val = VAbstractMeasurements::UnitConvertor(value, Unit::Cm, qApp->patternUnit());
QString strVal = QString("%1").arg(val);
qint32 index = gradationHeights->findText(strVal);
if (index != -1)
{
gradationHeights->setCurrentIndex(index);
}
else
{
pattern->SetHeight(gradationHeights->currentText().toInt());
}
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::SetDefaultSize(int value)
{
qreal val = VAbstractMeasurements::UnitConvertor(value, Unit::Cm, qApp->patternUnit());
QString strVal = QString("%1").arg(val);
qint32 index = gradationSizes->findText(strVal);
if (index != -1)
{
gradationSizes->setCurrentIndex(index);
}
else
{
pattern->SetSize(gradationSizes->currentText().toInt());
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -1446,6 +1487,63 @@ void MainWindow::Layout()
}
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::UpdateGradation()
{
UpdateHeightsList(VMeasurement::ListHeights(doc->GetGradationHeights()));
UpdateSizesList(VMeasurement::ListSizes(doc->GetGradationSizes()));
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::UpdateHeightsList(const QStringList &list)
{
QString val;
if (gradationHeights->currentIndex() != -1)
{
val = gradationHeights->currentText();
}
gradationHeights->blockSignals(true);
gradationHeights->clear();
gradationHeights->addItems(list);
gradationHeights->blockSignals(false);
int index = gradationHeights->findText(val);
if (index != -1)
{
gradationHeights->setCurrentIndex(index);
}
else
{
ChangedHeight(list.at(0));
}
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::UpdateSizesList(const QStringList &list)
{
QString val;
if (gradationSizes->currentIndex() != -1)
{
val = gradationSizes->currentText();
}
gradationSizes->blockSignals(true);
gradationSizes->clear();
gradationSizes->addItems(list);
gradationSizes->blockSignals(false);
int index = gradationSizes->findText(val);
if (index != -1)
{
gradationSizes->setCurrentIndex(index);
}
else
{
ChangedSize(list.at(0));
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief NewPattern create new empty pattern.
@ -1480,8 +1578,7 @@ void MainWindow::PatternWasModified(bool saved)
*/
void MainWindow::ChangedSize(const QString & text)
{
qint32 size = text.toInt();
pattern->SetSize(size);
pattern->SetSize(text.toInt());
doc->LiteParseTree(Document::LiteParse);
}
@ -1492,8 +1589,7 @@ void MainWindow::ChangedSize(const QString & text)
*/
void MainWindow::ChangedHeight(const QString &text)
{
qint32 growth = text.toInt();
pattern->SetHeight(growth);
pattern->SetHeight(text.toInt());
doc->LiteParseTree(Document::LiteParse);
}
@ -1594,7 +1690,7 @@ void MainWindow::ActionLayout(bool checked)
QPainterPath path = VEquidistant().ContourPath(idetail.key(), pattern);
listDetails.append(new VItem(path, listDetails.size()));
}
QString description = doc->UniqueTagText("description");
QString description = doc->GetDescription();
emit ModelChosen(listDetails, curFile, description);
}
@ -1813,7 +1909,7 @@ void MainWindow::UpdateRecentFileActions()
for (int i = 0; i < numRecentFiles; ++i)
{
QString text = QString("&%1 %2").arg(i + 1).arg(strippedName(files.at(i)));
QString text = QString("&%1. %2").arg(i + 1).arg(strippedName(files.at(i)));
recentFileActs[i]->setText(text);
recentFileActs[i]->setData(files.at(i));
recentFileActs[i]->setVisible(true);

View File

@ -120,6 +120,7 @@ public slots:
void SetEnabledGUI(bool enabled);
void ClickEndVisualization();
void Layout();
void UpdateGradation();
signals:
/**
* @brief ModelChosen emit after calculation all details.
@ -194,6 +195,8 @@ private:
QAction *separatorAct;
QTimer *autoSaveTimer;
bool guiEnabled;
QComboBox *gradationHeights;
QComboBox *gradationSizes;
void ToolBarOption();
void ToolBarDraws();
void ToolBarTools();
@ -232,14 +235,17 @@ private:
QString PatternPieceName(const QString &text);
QString CheckPathToMeasurements(const QString &path, const MeasurementsType &patternType);
void OpenPattern(const QString &filePath);
template <typename Func>
void SetGradationList(const QString &label, const QStringList &list, Func changeSlot);
QComboBox *SetGradationList(const QString &label, const QStringList &list);
void ChangePP(int index , bool zoomBestFit = true);
/**
* @brief EndVisualization try show dialog after and working with tool visualization.
*/
void EndVisualization(bool click = false);
void ZoomFirstShow();
void UpdateHeightsList(const QStringList &list);
void UpdateSizesList(const QStringList &list);
void SetDefaultHeight(int value);
void SetDefaultSize(int value);
};
#endif // MAINWINDOW_H

View File

@ -75,6 +75,15 @@ enum class Draw : char { Calculation, Modeling };
enum class Unit : char { Mm, Cm, Inch };
enum class MeasurementsType : char { Standard, Individual };
enum class GHeights : unsigned char { ALL,
H92=92, H98=98, H104=104, H110=110, H116=116, H122=122, H128=128, H134=134,
H140=140, H146=146, H152=152, H158=158, H164=164, H170=170, H176=176, H182=182,
H188=188, H194=194};
enum class GSizes : unsigned char { ALL,
S22=22, S24=24, S26=26, S28=28, S30=30, S32=32, S34=34, S36=36, S38=38, S40=40,
S42=42, S44=44, S46=46, S48=48, S50=50, S52=52, S54=54, S56=56 };
// measurements
extern const QString headGirth_M;
extern const QString midNeckGirth_M;

View File

@ -8,6 +8,58 @@
<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:complexType>
</xs:element>
<xs:element name="measurements" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="type" type="measurementsTypes" use="required"></xs:attribute>

View File

@ -221,6 +221,45 @@ quint32 VDomDocument::GetParametrUInt(const QDomElement &domElement, const QStri
return id;
}
//---------------------------------------------------------------------------------------------------------------------
bool VDomDocument::GetParametrBool(const QDomElement &domElement, const QString &name, const QString &defValue) const
{
Q_ASSERT_X(name.isEmpty() == false, Q_FUNC_INFO, "name of parametr is empty");
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
bool ok = false;
QString parametr;
bool val = true;
QString message = tr("Can't convert toBool parameter");
try
{
parametr = GetParametrString(domElement, name, defValue);
QStringList bools {QLatin1String("true"), QLatin1String("false")};
switch (bools.indexOf(parametr))
{
case 0: // true
val = true;
break;
case 1: // false
val = false;
break;
default:// others
throw VExceptionConversionError(message, name);
break;
}
}
catch (const VExceptionEmptyParameter &e)
{
VExceptionConversionError excep(message, name);
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
return val;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Returns the string value of the given attribute. RENAME: see above

View File

@ -87,11 +87,6 @@ public:
* @param domElement element in xml tree.
* @param name name of attribute.
* @param value value of attribute.
* @param parse parsing mode
* @return list of tool pointers
* @return list of history record lists
* @return cursor
* @throw VExceptionUniqueId
*/
void SetAttribute(QDomElement &domElement, const QString &name, const T &value) const
{
@ -100,10 +95,11 @@ public:
domElement.setAttribute(name, val);
}
quint32 GetParametrUInt(const QDomElement& domElement, const QString &name, const QString &defValue) const;
bool GetParametrBool(const QDomElement& domElement, const QString &name, const QString &defValue) const;
QString GetParametrString(const QDomElement& domElement, const QString &name,
const QString &defValue = QString()) const;
qreal GetParametrDouble(const QDomElement& domElement, const QString &name, const QString &defValue) const;
QString UniqueTagText(const QString &tagName, const QString &defVal = QString()) const;
static void ValidateXML(const QString &schema, const QString &fileName);
void setContent(const QString &fileName);
static Unit StrToUnits(const QString &unit);
@ -118,6 +114,7 @@ protected:
VContainer *data;
void setTagText(const QString &tag, const QString &text);
QString UniqueTagText(const QString &tagName, const QString &defVal = QString()) const;
private:
Q_DISABLE_COPY(VDomDocument)
/** @brief Map used for finding element by id. */
@ -134,6 +131,22 @@ inline void VDomDocument::SetAttribute<QString>(QDomElement &domElement, const Q
domElement.setAttribute(name, value);
}
//---------------------------------------------------------------------------------------------------------------------
template <>
inline void VDomDocument::SetAttribute<bool>(QDomElement &domElement, const QString &name, const bool &value) const
{
QString string;
if (value)
{
string = "true";
}
else
{
string = "false";
}
domElement.setAttribute(name, string);
}
//---------------------------------------------------------------------------------------------------------------------
template <>
inline void VDomDocument::SetAttribute<MeasurementsType>(QDomElement &domElement, const QString &name,

View File

@ -42,6 +42,7 @@
#include "vindividualmeasurements.h"
#include "../../libs/qmuparser/qmuparsererror.h"
#include "../geometry/varc.h"
#include <QMessageBox>
#include <QUndoStack>
@ -61,11 +62,54 @@ const QString VPattern::TagLine = QStringLiteral("line");
const QString VPattern::TagSpline = QStringLiteral("spline");
const QString VPattern::TagArc = QStringLiteral("arc");
const QString VPattern::TagTools = QStringLiteral("tools");
const QString VPattern::TagGradation = QStringLiteral("gradation");
const QString VPattern::TagHeights = QStringLiteral("heights");
const QString VPattern::TagSizes = QStringLiteral("sizes");
const QString VPattern::AttrName = QStringLiteral("name");
const QString VPattern::AttrType = QStringLiteral("type");
const QString VPattern::AttrPath = QStringLiteral("path");
const QString VPattern::AttrAll = QStringLiteral("all");
const QString VPattern::AttrH92 = QStringLiteral("h92");
const QString VPattern::AttrH98 = QStringLiteral("h98");
const QString VPattern::AttrH104 = QStringLiteral("h104");
const QString VPattern::AttrH110 = QStringLiteral("h110");
const QString VPattern::AttrH116 = QStringLiteral("h116");
const QString VPattern::AttrH122 = QStringLiteral("h122");
const QString VPattern::AttrH128 = QStringLiteral("h128");
const QString VPattern::AttrH134 = QStringLiteral("h134");
const QString VPattern::AttrH140 = QStringLiteral("h140");
const QString VPattern::AttrH146 = QStringLiteral("h146");
const QString VPattern::AttrH152 = QStringLiteral("h152");
const QString VPattern::AttrH158 = QStringLiteral("h158");
const QString VPattern::AttrH164 = QStringLiteral("h164");
const QString VPattern::AttrH170 = QStringLiteral("h170");
const QString VPattern::AttrH176 = QStringLiteral("h176");
const QString VPattern::AttrH182 = QStringLiteral("h182");
const QString VPattern::AttrH188 = QStringLiteral("h188");
const QString VPattern::AttrH194 = QStringLiteral("h194");
const QString VPattern::AttrS22 = QStringLiteral("s22");
const QString VPattern::AttrS24 = QStringLiteral("s24");
const QString VPattern::AttrS26 = QStringLiteral("s26");
const QString VPattern::AttrS28 = QStringLiteral("s28");
const QString VPattern::AttrS30 = QStringLiteral("s30");
const QString VPattern::AttrS32 = QStringLiteral("s32");
const QString VPattern::AttrS34 = QStringLiteral("s34");
const QString VPattern::AttrS36 = QStringLiteral("s36");
const QString VPattern::AttrS38 = QStringLiteral("s38");
const QString VPattern::AttrS40 = QStringLiteral("s40");
const QString VPattern::AttrS42 = QStringLiteral("s42");
const QString VPattern::AttrS44 = QStringLiteral("s44");
const QString VPattern::AttrS46 = QStringLiteral("s46");
const QString VPattern::AttrS48 = QStringLiteral("s48");
const QString VPattern::AttrS50 = QStringLiteral("s50");
const QString VPattern::AttrS52 = QStringLiteral("s52");
const QString VPattern::AttrS54 = QStringLiteral("s54");
const QString VPattern::AttrS56 = QStringLiteral("s56");
const QString VPattern::IncrementName = QStringLiteral("name");
const QString VPattern::IncrementBase = QStringLiteral("base");
const QString VPattern::IncrementKsize = QStringLiteral("ksize");
@ -256,7 +300,8 @@ void VPattern::Parse(const Document &parse)
{
SCASSERT(sceneDraw != nullptr);
SCASSERT(sceneDetail != nullptr);
QStringList tags{TagDraw, TagIncrements, TagAuthor, TagDescription, TagNotes, TagMeasurements, TagVersion};
QStringList tags{TagDraw, TagIncrements, TagAuthor, TagDescription, TagNotes, TagMeasurements, TagVersion,
TagGradation};
PrepareForParse(parse);
QDomNode domNode = documentElement().firstChild();
while (domNode.isNull() == false)
@ -300,6 +345,8 @@ void VPattern::Parse(const Document &parse)
break;
case 6: // TagVersion
break;
case 7: // TagGradation
break;
default:
qDebug()<<"Wrong tag name"<<domElement.tagName()<<Q_FUNC_INFO;
break;
@ -1499,6 +1546,75 @@ void VPattern::ParseCurrentPP()
emit CheckLayout();
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::CheckTagExists(const QString &tag)
{
QDomNodeList list = elementsByTagName(tag);
if (list.size() == 0)
{
QStringList tags{TagVersion, TagAuthor, TagDescription, TagNotes, TagGradation};
QDomElement pattern = documentElement();
switch (tags.indexOf(tag))
{
case 0: //TagVersion
break;// Mandatory tag
case 1: //TagAuthor
pattern.insertAfter(createElement(TagAuthor), elementsByTagName(TagVersion).at(0));
SetVersion();
break;
case 2: //TagDescription
{
for (int i = tags.indexOf(tag)-1; i >= 0; --i)
{
QDomNodeList list = elementsByTagName(tags.at(i));
if (list.isEmpty())
{
continue;
}
pattern.insertAfter(createElement(TagDescription), list.at(0));
}
SetVersion();
break;
}
case 3: //TagNotes
{
for (int i = tags.indexOf(tag)-1; i >= 0; --i)
{
QDomNodeList list = elementsByTagName(tags.at(i));
if (list.isEmpty())
{
continue;
}
pattern.insertAfter(createElement(TagNotes), list.at(0));
}
SetVersion();
break;
}
case 4: //TagGradation
{
QDomElement gradation = createElement(TagGradation);
gradation.appendChild(createElement(TagHeights));
gradation.appendChild(createElement(TagSizes));
for (int i = tags.indexOf(tag)-1; i >= 0; --i)
{
QDomNodeList list = elementsByTagName(tags.at(i));
if (list.isEmpty())
{
continue;
}
pattern.insertAfter(gradation, list.at(0));
break;
}
SetVersion();
break;
}
default:
break;
}
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ParseSplineElement parse spline tag.
@ -1815,6 +1931,351 @@ quint32 VPattern::GetParametrId(const QDomElement &domElement) const
return id;
}
//---------------------------------------------------------------------------------------------------------------------
QMap<GHeights, bool> VPattern::GetGradationHeights() const
{
QMap<GHeights, bool> map;
map.insert(GHeights::ALL, true);
map.insert(GHeights::H92, true);
map.insert(GHeights::H98, true);
map.insert(GHeights::H104, true);
map.insert(GHeights::H110, true);
map.insert(GHeights::H116, true);
map.insert(GHeights::H122, true);
map.insert(GHeights::H128, true);
map.insert(GHeights::H134, true);
map.insert(GHeights::H140, true);
map.insert(GHeights::H146, true);
map.insert(GHeights::H152, true);
map.insert(GHeights::H158, true);
map.insert(GHeights::H164, true);
map.insert(GHeights::H170, true);
map.insert(GHeights::H176, true);
map.insert(GHeights::H182, true);
map.insert(GHeights::H188, true);
map.insert(GHeights::H194, true);
QDomNodeList tags = elementsByTagName(TagGradation);
if (tags.size() == 0)
{
return map;
}
QStringList gTags{TagHeights, TagSizes};
QDomNode domNode = tags.at(0).firstChild();
while (domNode.isNull() == false)
{
if (domNode.isElement())
{
const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
const QString defValue = QStringLiteral("true");
switch (gTags.indexOf(domElement.tagName()))
{
case 0: // TagHeights
if (GetParametrBool(domElement, AttrAll, defValue))
{
return map;
}
else
{
map.insert(GHeights::ALL, false);
}
map.insert(GHeights::H92, GetParametrBool(domElement, AttrH92, defValue));
map.insert(GHeights::H98, GetParametrBool(domElement, AttrH98, defValue));
map.insert(GHeights::H104, GetParametrBool(domElement, AttrH104, defValue));
map.insert(GHeights::H110, GetParametrBool(domElement, AttrH110, defValue));
map.insert(GHeights::H116, GetParametrBool(domElement, AttrH116, defValue));
map.insert(GHeights::H122, GetParametrBool(domElement, AttrH122, defValue));
map.insert(GHeights::H128, GetParametrBool(domElement, AttrH128, defValue));
map.insert(GHeights::H134, GetParametrBool(domElement, AttrH134, defValue));
map.insert(GHeights::H140, GetParametrBool(domElement, AttrH140, defValue));
map.insert(GHeights::H146, GetParametrBool(domElement, AttrH146, defValue));
map.insert(GHeights::H152, GetParametrBool(domElement, AttrH152, defValue));
map.insert(GHeights::H158, GetParametrBool(domElement, AttrH158, defValue));
map.insert(GHeights::H164, GetParametrBool(domElement, AttrH164, defValue));
map.insert(GHeights::H170, GetParametrBool(domElement, AttrH170, defValue));
map.insert(GHeights::H176, GetParametrBool(domElement, AttrH176, defValue));
map.insert(GHeights::H182, GetParametrBool(domElement, AttrH182, defValue));
map.insert(GHeights::H188, GetParametrBool(domElement, AttrH188, defValue));
map.insert(GHeights::H194, GetParametrBool(domElement, AttrH194, defValue));
return map;
break;
case 1: // TagSizes
break;
default:
break;
}
}
}
domNode = domNode.nextSibling();
}
return map;
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::SetGradationHeights(const QMap<GHeights, bool> &options)
{
CheckTagExists(TagGradation);
QDomNodeList tags = elementsByTagName(TagGradation);
if (tags.size() == 0)
{
qDebug()<<"Can't save tag "<<TagGradation<<Q_FUNC_INFO;
return;
}
QStringList gTags{TagHeights, TagSizes};
QDomNode domNode = tags.at(0).firstChild();
while (domNode.isNull() == false)
{
if (domNode.isElement())
{
QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
switch (gTags.indexOf(domElement.tagName()))
{
case 0: // TagHeights
SetAttribute(domElement, AttrAll, options.value(GHeights::ALL));
SetAttribute(domElement, AttrH92, options.value(GHeights::H92));
SetAttribute(domElement, AttrH98, options.value(GHeights::H98));
SetAttribute(domElement, AttrH104, options.value(GHeights::H104));
SetAttribute(domElement, AttrH110, options.value(GHeights::H110));
SetAttribute(domElement, AttrH116, options.value(GHeights::H116));
SetAttribute(domElement, AttrH122, options.value(GHeights::H122));
SetAttribute(domElement, AttrH128, options.value(GHeights::H128));
SetAttribute(domElement, AttrH134, options.value(GHeights::H134));
SetAttribute(domElement, AttrH140, options.value(GHeights::H140));
SetAttribute(domElement, AttrH146, options.value(GHeights::H146));
SetAttribute(domElement, AttrH152, options.value(GHeights::H152));
SetAttribute(domElement, AttrH158, options.value(GHeights::H158));
SetAttribute(domElement, AttrH164, options.value(GHeights::H164));
SetAttribute(domElement, AttrH170, options.value(GHeights::H170));
SetAttribute(domElement, AttrH176, options.value(GHeights::H176));
SetAttribute(domElement, AttrH182, options.value(GHeights::H182));
SetAttribute(domElement, AttrH188, options.value(GHeights::H188));
SetAttribute(domElement, AttrH194, options.value(GHeights::H194));
emit patternChanged(false);
return;
break;
case 1: // TagSizes
break;
default:
break;
}
}
}
domNode = domNode.nextSibling();
}
}
//---------------------------------------------------------------------------------------------------------------------
QMap<GSizes, bool> VPattern::GetGradationSizes() const
{
QMap<GSizes, bool> map;
map.insert(GSizes::ALL, true);
map.insert(GSizes::S22, true);
map.insert(GSizes::S24, true);
map.insert(GSizes::S26, true);
map.insert(GSizes::S28, true);
map.insert(GSizes::S30, true);
map.insert(GSizes::S32, true);
map.insert(GSizes::S34, true);
map.insert(GSizes::S36, true);
map.insert(GSizes::S38, true);
map.insert(GSizes::S40, true);
map.insert(GSizes::S42, true);
map.insert(GSizes::S44, true);
map.insert(GSizes::S46, true);
map.insert(GSizes::S48, true);
map.insert(GSizes::S50, true);
map.insert(GSizes::S52, true);
map.insert(GSizes::S54, true);
map.insert(GSizes::S56, true);
QDomNodeList tags = elementsByTagName(TagGradation);
if (tags.size() == 0)
{
return map;
}
QStringList gTags{TagHeights, TagSizes};
QDomNode domNode = tags.at(0).firstChild();
while (domNode.isNull() == false)
{
if (domNode.isElement())
{
const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
const QString defValue = QStringLiteral("true");
switch (gTags.indexOf(domElement.tagName()))
{
case 0: // TagHeights
break;
case 1: // TagSizes
if (GetParametrBool(domElement, AttrAll, defValue))
{
return map;
}
else
{
map.insert(GSizes::ALL, false);
}
map.insert(GSizes::S22, GetParametrBool(domElement, AttrS22, defValue));
map.insert(GSizes::S24, GetParametrBool(domElement, AttrS24, defValue));
map.insert(GSizes::S26, GetParametrBool(domElement, AttrS26, defValue));
map.insert(GSizes::S28, GetParametrBool(domElement, AttrS28, defValue));
map.insert(GSizes::S30, GetParametrBool(domElement, AttrS30, defValue));
map.insert(GSizes::S32, GetParametrBool(domElement, AttrS32, defValue));
map.insert(GSizes::S34, GetParametrBool(domElement, AttrS34, defValue));
map.insert(GSizes::S36, GetParametrBool(domElement, AttrS36, defValue));
map.insert(GSizes::S38, GetParametrBool(domElement, AttrS38, defValue));
map.insert(GSizes::S40, GetParametrBool(domElement, AttrS40, defValue));
map.insert(GSizes::S42, GetParametrBool(domElement, AttrS42, defValue));
map.insert(GSizes::S44, GetParametrBool(domElement, AttrS44, defValue));
map.insert(GSizes::S46, GetParametrBool(domElement, AttrS46, defValue));
map.insert(GSizes::S48, GetParametrBool(domElement, AttrS48, defValue));
map.insert(GSizes::S50, GetParametrBool(domElement, AttrS50, defValue));
map.insert(GSizes::S52, GetParametrBool(domElement, AttrS52, defValue));
map.insert(GSizes::S54, GetParametrBool(domElement, AttrS54, defValue));
map.insert(GSizes::S56, GetParametrBool(domElement, AttrS56, defValue));
return map;
break;
default:
break;
}
}
}
domNode = domNode.nextSibling();
}
return map;
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::SetGradationSizes(const QMap<GSizes, bool> &options)
{
CheckTagExists(TagGradation);
QDomNodeList tags = elementsByTagName(TagGradation);
if (tags.size() == 0)
{
qDebug()<<"Can't save tag "<<TagGradation<<Q_FUNC_INFO;
return;
}
QStringList gTags{TagHeights, TagSizes};
QDomNode domNode = tags.at(0).firstChild();
while (domNode.isNull() == false)
{
if (domNode.isElement())
{
QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
switch (gTags.indexOf(domElement.tagName()))
{
case 0: // TagHeights
break;
case 1: // TagSizes
SetAttribute(domElement, AttrAll, options.value(GSizes::ALL));
SetAttribute(domElement, AttrS22, options.value(GSizes::S22));
SetAttribute(domElement, AttrS24, options.value(GSizes::S24));
SetAttribute(domElement, AttrS26, options.value(GSizes::S26));
SetAttribute(domElement, AttrS28, options.value(GSizes::S28));
SetAttribute(domElement, AttrS30, options.value(GSizes::S30));
SetAttribute(domElement, AttrS32, options.value(GSizes::S32));
SetAttribute(domElement, AttrS34, options.value(GSizes::S34));
SetAttribute(domElement, AttrS36, options.value(GSizes::S36));
SetAttribute(domElement, AttrS38, options.value(GSizes::S38));
SetAttribute(domElement, AttrS40, options.value(GSizes::S40));
SetAttribute(domElement, AttrS42, options.value(GSizes::S42));
SetAttribute(domElement, AttrS44, options.value(GSizes::S44));
SetAttribute(domElement, AttrS46, options.value(GSizes::S46));
SetAttribute(domElement, AttrS48, options.value(GSizes::S48));
SetAttribute(domElement, AttrS50, options.value(GSizes::S50));
SetAttribute(domElement, AttrS52, options.value(GSizes::S52));
SetAttribute(domElement, AttrS54, options.value(GSizes::S54));
SetAttribute(domElement, AttrS56, options.value(GSizes::S56));
emit patternChanged(false);
return;
break;
default:
break;
}
}
}
domNode = domNode.nextSibling();
}
}
//---------------------------------------------------------------------------------------------------------------------
QString VPattern::GetAuthor() const
{
QSettings *settings = qApp->getSettings();
SCASSERT(settings != nullptr);
#ifdef Q_OS_WIN
QString user = settings->value("pattern/user", QString::fromLocal8Bit(qgetenv("USERNAME").constData())).toString();
#else
QString user = settings->value("pattern/user", QString::fromLocal8Bit(qgetenv("USER").constData())).toString();
#endif
return UniqueTagText(TagAuthor, user);
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::SetAuthor(const QString &text)
{
CheckTagExists(TagAuthor);
setTagText(TagAuthor, text);
emit patternChanged(false);
}
//---------------------------------------------------------------------------------------------------------------------
QString VPattern::GetDescription() const
{
return UniqueTagText(TagDescription);
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::SetDescription(const QString &text)
{
CheckTagExists(TagDescription);
setTagText(TagDescription, text);
emit patternChanged(false);
}
//---------------------------------------------------------------------------------------------------------------------
QString VPattern::GetNotes() const
{
return UniqueTagText(TagNotes);
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::SetNotes(const QString &text)
{
CheckTagExists(TagNotes);
setTagText(TagNotes, text);
emit patternChanged(false);
}
//---------------------------------------------------------------------------------------------------------------------
QString VPattern::GetVersion() const
{
return UniqueTagText(TagVersion, VAL_STR_VERSION);
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::SetVersion()
{
setTagText(TagVersion, VAL_STR_VERSION);
emit patternChanged(false);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief CollectId recursive function, try find id attribute in file. Throw exclusion if find not unique.

View File

@ -35,7 +35,7 @@
class VDataTool;
class VMainGraphicsScene;
enum class Document : char { LiteParse, LitePPParse, FullParse};
enum class Document : char { LiteParse, LitePPParse, FullParse };
/*
VAL_VERSION is (major << 16) + (minor << 8) + patch.
@ -43,9 +43,9 @@ enum class Document : char { LiteParse, LitePPParse, FullParse};
// version without patch part
#define VAL_MIN_VERSION 0x000100
// max support version of format
#define VAL_VERSION 0x000100
#define VAL_VERSION 0x000101
#define VAL_STR_VERSION "0.1.0"
#define VAL_STR_VERSION "0.1.1"
/**
* @brief The VPattern class working with pattern file.
@ -103,18 +103,82 @@ public:
static const QString TagSpline;
static const QString TagArc;
static const QString TagTools;
static const QString TagGradation;
static const QString TagHeights;
static const QString TagSizes;
static const QString AttrName;
static const QString AttrType;
static const QString AttrPath;
static const QString AttrAll;
static const QString AttrH92;
static const QString AttrH98;
static const QString AttrH104;
static const QString AttrH110;
static const QString AttrH116;
static const QString AttrH122;
static const QString AttrH128;
static const QString AttrH134;
static const QString AttrH140;
static const QString AttrH146;
static const QString AttrH152;
static const QString AttrH158;
static const QString AttrH164;
static const QString AttrH170;
static const QString AttrH176;
static const QString AttrH182;
static const QString AttrH188;
static const QString AttrH194;
static const QString AttrS22;
static const QString AttrS24;
static const QString AttrS26;
static const QString AttrS28;
static const QString AttrS30;
static const QString AttrS32;
static const QString AttrS34;
static const QString AttrS36;
static const QString AttrS38;
static const QString AttrS40;
static const QString AttrS42;
static const QString AttrS44;
static const QString AttrS46;
static const QString AttrS48;
static const QString AttrS50;
static const QString AttrS52;
static const QString AttrS54;
static const QString AttrS56;
static const QString IncrementName;
static const QString IncrementBase;
static const QString IncrementKsize;
static const QString IncrementKgrowth;
static const QString IncrementDescription;
virtual bool SaveDocument(const QString &fileName);
QStringList getPatternPieces() const;
QRectF ActiveDrawBoundingRect() const;
quint32 GetParametrId(const QDomElement& domElement) const;
QMap<GHeights, bool> GetGradationHeights() const;
void SetGradationHeights(const QMap<GHeights, bool> &options);
QMap<GSizes, bool> GetGradationSizes() const;
void SetGradationSizes(const QMap<GSizes, bool> &options);
QString GetAuthor() const;
void SetAuthor(const QString &text);
QString GetDescription() const;
void SetDescription(const QString &text);
QString GetNotes() const;
void SetNotes(const QString &text);
QString GetVersion() const;
void SetVersion();
signals:
/**
* @brief ChangedActivDraw change active pattern peace.
@ -215,6 +279,7 @@ private:
template <typename T>
QRectF ToolBoundingRect(const QRectF &rec, const quint32 &id) const;
void ParseCurrentPP();
void CheckTagExists(const QString &tag);
};
//---------------------------------------------------------------------------------------------------------------------