diff --git a/src/app/app.pro b/src/app/app.pro index 40ba0d1a0..02d64b309 100644 --- a/src/app/app.pro +++ b/src/app/app.pro @@ -142,7 +142,6 @@ CONFIG(debug, debug|release){ -Wlong-long \ -Wmissing-format-attribute \ -Wswitch-default \ - -Wswitch-enum \ -Wuninitialized \ -Wvariadic-macros \ -Wlogical-op \ diff --git a/src/app/container/vcontainer.cpp b/src/app/container/vcontainer.cpp index 4f8b81778..fbc2d10f7 100644 --- a/src/app/container/vcontainer.cpp +++ b/src/app/container/vcontainer.cpp @@ -188,7 +188,7 @@ val VContainer::GetVariable(const QHash &obj, key id) const */ const VMeasurement VContainer::GetMeasurement(const QString &name) const { - Q_ASSERT(name.isEmpty()==false); + SCASSERT(name.isEmpty()==false); return GetVariable(measurements, name); } @@ -200,7 +200,7 @@ const VMeasurement VContainer::GetMeasurement(const QString &name) const */ const VIncrement VContainer::GetIncrement(const QString& name) const { - Q_ASSERT(name.isEmpty()==false); + SCASSERT(name.isEmpty()==false); return GetVariable(increments, name); } @@ -212,7 +212,7 @@ const VIncrement VContainer::GetIncrement(const QString& name) const */ qreal VContainer::GetLine(const QString &name) const { - Q_ASSERT(name.isEmpty()==false); + SCASSERT(name.isEmpty()==false); return GetVariable(lengthLines, name); } @@ -224,7 +224,7 @@ qreal VContainer::GetLine(const QString &name) const */ qreal VContainer::GetLengthArc(const QString &name) const { - Q_ASSERT(name.isEmpty()==false); + SCASSERT(name.isEmpty()==false); return GetVariable(lengthArcs, name); } @@ -236,7 +236,7 @@ qreal VContainer::GetLengthArc(const QString &name) const */ qreal VContainer::GetLengthSpline(const QString &name) const { - Q_ASSERT(name.isEmpty()==false); + SCASSERT(name.isEmpty()==false); return GetVariable(lengthSplines, name); } @@ -248,7 +248,7 @@ qreal VContainer::GetLengthSpline(const QString &name) const */ qreal VContainer::GetLineAngle(const QString &name) const { - Q_ASSERT(name.isEmpty()==false); + SCASSERT(name.isEmpty()==false); return GetVariable(lineAngles, name); } @@ -352,7 +352,7 @@ void VContainer::UpdateObject(QHash &obj, const quint32 &id, val p */ void VContainer::AddLengthSpline(const QString &name, const qreal &value) { - Q_ASSERT(name.isEmpty() == false); + SCASSERT(name.isEmpty() == false); lengthSplines[name] = value; } @@ -375,7 +375,7 @@ void VContainer::AddLengthArc(const quint32 &id) */ void VContainer::AddLineAngle(const QString &name, const qreal &value) { - Q_ASSERT(name.isEmpty() == false); + SCASSERT(name.isEmpty() == false); lineAngles[name] = value; } @@ -560,6 +560,6 @@ void VContainer::UpdateDetail(quint32 id, const VDetail &detail) */ void VContainer::AddLengthLine(const QString &name, const qreal &value) { - Q_ASSERT(name.isEmpty() == false); + SCASSERT(name.isEmpty() == false); lengthLines[name] = value; } diff --git a/src/app/dialogs/app/dialogpatternxmledit.cpp b/src/app/dialogs/app/dialogpatternxmledit.cpp index 521ed0792..04f619278 100644 --- a/src/app/dialogs/app/dialogpatternxmledit.cpp +++ b/src/app/dialogs/app/dialogpatternxmledit.cpp @@ -127,7 +127,7 @@ bool DialogPatternXmlEdit::ApplyNodeChange(QDomNode domElement, QString name, QS bool DialogPatternXmlEdit::ApplyNodeAdd(QDomNode domElement, VXMLTreeElement* treeElement, QString name, QString value) { QDomElement newnode = domElement.ownerDocument().createElement(name); - //Q_ASSERT(newnode != nullptr); + //SCASSERT(newnode != nullptr); newnode.setNodeValue(value); domElement.appendChild(newnode); treeElement->SetDocNode(newnode); @@ -282,7 +282,7 @@ bool DialogPatternXmlEdit::DeleteNodeAndSons(VXMLTreeElement * currentNode, bool } if (index < 0) { - Q_ASSERT(index==0); + SCASSERT(index==0); return false; } parent->removeRow(index); @@ -318,7 +318,7 @@ DialogPatternXmlEdit::ChangesStackElement* DialogPatternXmlEdit::CreateStackElem //--------------------------------------------------------------------------------------------------------------------- bool DialogPatternXmlEdit::UndoChange(DialogPatternXmlEdit::ChangesStackElement* current) { - Q_ASSERT(current != nullptr); + SCASSERT(current != nullptr); VXMLTreeElement * currentNode = current->element; @@ -371,7 +371,7 @@ bool DialogPatternXmlEdit::UndoChange(DialogPatternXmlEdit::ChangesStackElement* } if (index < 0) { - Q_ASSERT(index==0); + SCASSERT(index==0); return false; } parent->removeRow(index); @@ -621,7 +621,7 @@ void DialogPatternXmlEdit::RemoveChangeStackElement(ChangesStackElement* elmt) } if (index->next == nullptr) { - Q_ASSERT(index->next != nullptr); + SCASSERT(index->next != nullptr); return; } if (index->next->newText != nullptr) @@ -834,7 +834,7 @@ void DialogPatternXmlEdit::ButtonSetClicked() { // If node was created or edited previously, rewrite if (this->currentNodeEditedStatus == DialogPatternXmlEdit::ChangeTypeDelete) { // You shouldn't be able to edit a deleted node... - Q_ASSERT(this->currentNodeEditedStatus != DialogPatternXmlEdit::ChangeTypeDelete); + SCASSERT(this->currentNodeEditedStatus != DialogPatternXmlEdit::ChangeTypeDelete); ClearEditData(); return; } @@ -958,7 +958,7 @@ void DialogPatternXmlEdit::BaseSelectionChanged(int value) ui->pushButton_Apply_Changes->setEnabled(false); index = ui->comboBox_Base_Selection->itemData(value).toInt(); //.convert(QVariant::Int); - Q_ASSERT(value < rootBasesNum); + SCASSERT(value < rootBasesNum); // QMessageBox::information(this, "test", QString("%1:%2").arg(value).arg(index)); // Clear all tree info and nodes @@ -1169,7 +1169,7 @@ void VXMLTreeView::appendchain(VXMLTreeElement* elmt) current = new TreeElementchain; if (current == nullptr) { - Q_ASSERT(current != nullptr); + SCASSERT(current != nullptr); // TODO : throw exception } current->elmt=elmt; @@ -1180,7 +1180,7 @@ void VXMLTreeView::appendchain(VXMLTreeElement* elmt) TreeElementchain* temp= new TreeElementchain; if (temp == nullptr) { - Q_ASSERT(temp != nullptr); + SCASSERT(temp != nullptr); // TODO : throw exception } temp->elmt=elmt; diff --git a/src/app/dialogs/tools/dialogalongline.cpp b/src/app/dialogs/tools/dialogalongline.cpp index cbb375364..b7dad8c54 100644 --- a/src/app/dialogs/tools/dialogalongline.cpp +++ b/src/app/dialogs/tools/dialogalongline.cpp @@ -42,33 +42,27 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, QWidget *parent) formula(QString()), firstPointId(0), secondPointId(0), formulaBaseHeight(0) { ui->setupUi(this); - labelResultCalculation = ui->labelResultCalculation; - plainTextEditFormula = ui->plainTextEditFormula; - labelEditFormula = ui->labelEditFormula; - - this->formulaBaseHeight=ui->plainTextEditFormula->height(); + InitVariables(ui); + InitFormulaUI(ui); + labelEditNamePoint = ui->labelEditNamePoint; + this->formulaBaseHeight = ui->plainTextEditFormula->height(); + InitOkCancelApply(ui); flagFormula = false; flagName = false; - InitOkCancelApply(ui); CheckState(); - FillComboBoxTypeLine(ui->comboBoxLineType); - ui->comboBoxLineType->setCurrentIndex(0); FillComboBoxPoints(ui->comboBoxFirstPoint); FillComboBoxPoints(ui->comboBoxSecondPoint); + FillComboBoxTypeLine(ui->comboBoxLineType); + ui->comboBoxLineType->setCurrentIndex(0); - labelEditNamePoint = ui->labelEditNamePoint; connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogAlongLine::PutHere); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogAlongLine::NamePointChanged); connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogAlongLine::EvalFormula); connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogAlongLine::FormulaTextChanged); connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogAlongLine::DeployFormulaTextEdit); - InitVariables(ui); connect(listWidget, &QListWidget::itemDoubleClicked, this, &DialogTool::PutVal); - - ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down", - QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png"))); } //--------------------------------------------------------------------------------------------------------------------- @@ -80,20 +74,7 @@ void DialogAlongLine::FormulaTextChanged() //--------------------------------------------------------------------------------------------------------------------- void DialogAlongLine::DeployFormulaTextEdit() { - if (ui->plainTextEditFormula->height() < DIALOGALONLINE_MAX_FORMULA_HEIGHT) - { - ui->plainTextEditFormula->setFixedHeight(DIALOGALONLINE_MAX_FORMULA_HEIGHT); - //Set icon from theme (internal for Windows system) - ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-next", - QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-next.png"))); - } - else - { - ui->plainTextEditFormula->setFixedHeight(this->formulaBaseHeight); - //Set icon from theme (internal for Windows system) - ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down", - QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png"))); - } + DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogalongline.h b/src/app/dialogs/tools/dialogalongline.h index 581d67269..478aef06b 100644 --- a/src/app/dialogs/tools/dialogalongline.h +++ b/src/app/dialogs/tools/dialogalongline.h @@ -31,7 +31,6 @@ #include "dialogtool.h" -#define DIALOGALONLINE_MAX_FORMULA_HEIGHT 64 namespace Ui { class DialogAlongLine; diff --git a/src/app/dialogs/tools/dialogalongline.ui b/src/app/dialogs/tools/dialogalongline.ui index 5bf4d8691..41f3e0fd4 100644 --- a/src/app/dialogs/tools/dialogalongline.ui +++ b/src/app/dialogs/tools/dialogalongline.ui @@ -160,6 +160,12 @@ + + + 0 + 0 + + 16777215 @@ -189,8 +195,7 @@ - - :/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png:/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png + @@ -468,7 +473,6 @@ - diff --git a/src/app/dialogs/tools/dialogarc.cpp b/src/app/dialogs/tools/dialogarc.cpp index 92cae1561..77cc8b597 100644 --- a/src/app/dialogs/tools/dialogarc.cpp +++ b/src/app/dialogs/tools/dialogarc.cpp @@ -44,10 +44,17 @@ DialogArc::DialogArc(const VContainer *data, QWidget *parent) :DialogTool(data, parent), ui(new Ui::DialogArc), flagRadius(false), flagF1(false), flagF2(false), timerRadius(nullptr), timerF1(nullptr), timerF2(nullptr), center(0), radius(QString()), f1(QString()), - f2(QString()), formulaBaseHeight(0) + f2(QString()), formulaBaseHeight(0), formulaBaseHeightF1(0), formulaBaseHeightF2(0) { ui->setupUi(this); + InitVariables(ui); + + plainTextEditFormula = ui->plainTextEditFormula; + this->formulaBaseHeight = ui->plainTextEditFormula->height(); + this->formulaBaseHeightF1 = ui->plainTextEditF1->height(); + this->formulaBaseHeightF2 = ui->plainTextEditF2->height(); + timerRadius = new QTimer(this); connect(timerRadius, &QTimer::timeout, this, &DialogArc::EvalRadius); @@ -59,14 +66,10 @@ DialogArc::DialogArc(const VContainer *data, QWidget *parent) InitOkCancelApply(ui); - this->formulaBaseHeight=ui->plainTextEditFormula->height(); - FillComboBoxPoints(ui->comboBoxBasePoint); CheckState(); - InitVariables(ui); - connect(ui->toolButtonPutHereRadius, &QPushButton::clicked, this, &DialogArc::PutRadius); connect(ui->toolButtonPutHereF1, &QPushButton::clicked, this, &DialogArc::PutF1); connect(ui->toolButtonPutHereF2, &QPushButton::clicked, this, &DialogArc::PutF2); @@ -76,31 +79,30 @@ DialogArc::DialogArc(const VContainer *data, QWidget *parent) connect(ui->toolButtonEqualF2, &QPushButton::clicked, this, &DialogArc::EvalF2); connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogArc::RadiusChanged); - connect(ui->lineEditF1, &QLineEdit::textChanged, this, &DialogArc::F1Changed); - connect(ui->lineEditF2, &QLineEdit::textChanged, this, &DialogArc::F2Changed); - connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogArc::DeployFormulaTextEdit); + connect(ui->plainTextEditF1, &QPlainTextEdit::textChanged, this, &DialogArc::F1Changed); + connect(ui->plainTextEditF2, &QPlainTextEdit::textChanged, this, &DialogArc::F2Changed); - ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down", - QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png"))); + connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogArc::DeployFormulaTextEdit); + connect(ui->pushButtonGrowLengthF1, &QPushButton::clicked, this, &DialogArc::DeployF1TextEdit); + connect(ui->pushButtonGrowLengthF2, &QPushButton::clicked, this, &DialogArc::DeployF2TextEdit); } //--------------------------------------------------------------------------------------------------------------------- void DialogArc::DeployFormulaTextEdit() { - if (ui->plainTextEditFormula->height() < DIALOGARC_MAX_FORMULA_HEIGHT) - { - ui->plainTextEditFormula->setFixedHeight(DIALOGARC_MAX_FORMULA_HEIGHT); - //Set icon from theme (internal for Windows system) - ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-next", - QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-next.png"))); - } - else - { - ui->plainTextEditFormula->setFixedHeight(this->formulaBaseHeight); - //Set icon from theme (internal for Windows system) - ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down", - QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png"))); - } + DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogArc::DeployF1TextEdit() +{ + DeployFormula(ui->plainTextEditF1, ui->pushButtonGrowLengthF1, formulaBaseHeightF1); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogArc::DeployF2TextEdit() +{ + DeployFormula(ui->plainTextEditF2, ui->pushButtonGrowLengthF2, formulaBaseHeightF2); } //--------------------------------------------------------------------------------------------------------------------- @@ -127,8 +129,13 @@ void DialogArc::SetCenter(const quint32 &value) */ void DialogArc::SetF2(const QString &value) { - f2 = value; - ui->lineEditF2->setText(f2); + f2 = qApp->FormulaToUser(value); + // increase height if needed. + if (f2.length() > 80) + { + this->DeployF2TextEdit(); + } + ui->plainTextEditF2->setPlainText(f2); } //--------------------------------------------------------------------------------------------------------------------- @@ -138,8 +145,13 @@ void DialogArc::SetF2(const QString &value) */ void DialogArc::SetF1(const QString &value) { - f1 = value; - ui->lineEditF1->setText(f1); + f1 = qApp->FormulaToUser(value); + // increase height if needed. + if (f1.length() > 80) + { + this->DeployF1TextEdit(); + } + ui->plainTextEditF1->setPlainText(f1); } //--------------------------------------------------------------------------------------------------------------------- @@ -197,8 +209,10 @@ void DialogArc::SaveData() { radius = ui->plainTextEditFormula->toPlainText(); radius.replace("\n", " "); - f1 = ui->lineEditF1->text(); - f2 = ui->lineEditF2->text(); + f1 = ui->plainTextEditF1->toPlainText(); + f1.replace("\n", " "); + f2 = ui->plainTextEditF2->toPlainText(); + f2.replace("\n", " "); center = getCurrentObjectId(ui->comboBoxBasePoint); } @@ -239,7 +253,7 @@ void DialogArc::PutRadius() */ void DialogArc::PutF1() { - PutValHere(ui->lineEditF1, ui->listWidget); + PutValHere(ui->plainTextEditF1, ui->listWidget); } //--------------------------------------------------------------------------------------------------------------------- @@ -248,7 +262,7 @@ void DialogArc::PutF1() */ void DialogArc::PutF2() { - PutValHere(ui->lineEditF2, ui->listWidget); + PutValHere(ui->plainTextEditF2, ui->listWidget); } //--------------------------------------------------------------------------------------------------------------------- @@ -278,7 +292,7 @@ void DialogArc::RadiusChanged() void DialogArc::F1Changed() { labelEditFormula = ui->labelEditF1; - ValFormulaChanged(flagF1, ui->lineEditF1, timerF1); + ValFormulaChanged(flagF1, ui->plainTextEditF1, timerF1); } //--------------------------------------------------------------------------------------------------------------------- @@ -288,7 +302,7 @@ void DialogArc::F1Changed() void DialogArc::F2Changed() { labelEditFormula = ui->labelEditF2; - ValFormulaChanged(flagF2, ui->lineEditF2, timerF2); + ValFormulaChanged(flagF2, ui->plainTextEditF2, timerF2); } //--------------------------------------------------------------------------------------------------------------------- @@ -310,7 +324,7 @@ void DialogArc::CheckState() void DialogArc::EvalRadius() { labelEditFormula = ui->labelEditRadius; - Eval(ui->plainTextEditFormula, flagRadius, timerRadius, ui->labelResultRadius); + Eval(ui->plainTextEditFormula->toPlainText(), flagRadius, timerRadius, ui->labelResultRadius); } //--------------------------------------------------------------------------------------------------------------------- @@ -320,7 +334,7 @@ void DialogArc::EvalRadius() void DialogArc::EvalF1() { labelEditFormula = ui->labelEditF1; - Eval(ui->lineEditF1, flagF1, timerF1, ui->labelResultF1); + Eval(ui->plainTextEditF1->toPlainText(), flagF1, timerF1, ui->labelResultF1); } //--------------------------------------------------------------------------------------------------------------------- @@ -330,7 +344,7 @@ void DialogArc::EvalF1() void DialogArc::EvalF2() { labelEditFormula = ui->labelEditF2; - Eval(ui->lineEditF2, flagF2, timerF2, ui->labelResultF2); + Eval(ui->plainTextEditF2->toPlainText(), flagF2, timerF2, ui->labelResultF2); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogarc.h b/src/app/dialogs/tools/dialogarc.h index 411e46f4a..74e1c9ee6 100644 --- a/src/app/dialogs/tools/dialogarc.h +++ b/src/app/dialogs/tools/dialogarc.h @@ -31,7 +31,6 @@ #include "dialogtool.h" -#define DIALOGARC_MAX_FORMULA_HEIGHT 64 namespace Ui { class DialogArc; @@ -69,6 +68,8 @@ public slots: * @brief DeployFormulaTextEdit grow or shrink formula input */ void DeployFormulaTextEdit(); + void DeployF1TextEdit(); + void DeployF2TextEdit(); virtual void ValChenged(int row); void PutRadius(); void PutF1(); @@ -118,6 +119,8 @@ private: /** @brief formulaBaseHeight base height defined by dialogui */ int formulaBaseHeight; + int formulaBaseHeightF1; + int formulaBaseHeightF2; void EvalRadius(); void EvalF1(); diff --git a/src/app/dialogs/tools/dialogarc.ui b/src/app/dialogs/tools/dialogarc.ui index 606cf83c4..42957ae81 100644 --- a/src/app/dialogs/tools/dialogarc.ui +++ b/src/app/dialogs/tools/dialogarc.ui @@ -23,9 +23,6 @@ - - QLayout::SetDefaultConstraint - @@ -77,50 +74,17 @@ - - + + + Qt::Horizontal + + - 16777215 - 24 + 40 + 20 - - - - - - - 18 - 18 - - - - - 0 - 0 - - - - <html><head/><body><p>Show full calculation in message box</p></body></html> - - - - - - - - - - - - 16 - 16 - - - - true - - + @@ -132,7 +96,7 @@ - :/icon/24x24/putHereLeft.png:/icon/24x24/putHereLeft.png + :/icon/24x24/putHere.png:/icon/24x24/putHere.png @@ -186,6 +150,62 @@ + + + + + + + 0 + 0 + + + + + 16777215 + 24 + + + + + + + + + 18 + 18 + + + + + 0 + 0 + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + + + + + + + + 16 + 16 + + + + true + + + + + @@ -239,17 +259,17 @@ - - - - 0 - 0 - + + + Qt::Horizontal - - First angle of arc counterclockwise + + + 40 + 20 + - + @@ -261,7 +281,7 @@ - :/icon/24x24/putHereLeft.png:/icon/24x24/putHereLeft.png + :/icon/24x24/putHere.png:/icon/24x24/putHere.png @@ -315,6 +335,62 @@ + + + + + + + 0 + 0 + + + + + 16777215 + 24 + + + + + + + + + 18 + 18 + + + + + 0 + 0 + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + + + + + + + + 16 + 16 + + + + true + + + + + @@ -368,17 +444,17 @@ - - - - 0 - 0 - + + + Qt::Horizontal - - Second angle of arc counterclockwise + + + 40 + 20 + - + @@ -390,7 +466,7 @@ - :/icon/24x24/putHereLeft.png:/icon/24x24/putHereLeft.png + :/icon/24x24/putHere.png:/icon/24x24/putHere.png @@ -444,6 +520,62 @@ + + + + + + + 0 + 0 + + + + + 16777215 + 24 + + + + + + + + + 18 + 18 + + + + + 0 + 0 + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + + + + + + + + 16 + 16 + + + + true + + + + + @@ -623,8 +755,6 @@ - lineEditF1 - lineEditF2 comboBoxBasePoint radioButtonSizeGrowth radioButtonStandardTable diff --git a/src/app/dialogs/tools/dialogbisector.cpp b/src/app/dialogs/tools/dialogbisector.cpp index 0eb457e48..3610409fd 100644 --- a/src/app/dialogs/tools/dialogbisector.cpp +++ b/src/app/dialogs/tools/dialogbisector.cpp @@ -40,16 +40,14 @@ */ DialogBisector::DialogBisector(const VContainer *data, QWidget *parent) :DialogTool(data, parent), ui(new Ui::DialogBisector), number(0), pointName(QString()), typeLine(QString()), - formula(QString()), firstPointId(0), secondPointId(0), thirdPointId(0), formulaBaseHeight(0) + formula(QString()), firstPointId(0), secondPointId(0), thirdPointId(0), + formulaBaseHeight(0) { ui->setupUi(this); InitVariables(ui); - labelResultCalculation = ui->labelResultCalculation; - plainTextEditFormula = ui->plainTextEditFormula; - labelEditFormula = ui->labelEditFormula; + InitFormulaUI(ui); labelEditNamePoint = ui->labelEditNamePoint; - - this->formulaBaseHeight=ui->plainTextEditFormula->height(); + this->formulaBaseHeight = ui->plainTextEditFormula->height(); InitOkCancelApply(ui); flagFormula = false; @@ -58,8 +56,8 @@ DialogBisector::DialogBisector(const VContainer *data, QWidget *parent) FillComboBoxPoints(ui->comboBoxFirstPoint); FillComboBoxPoints(ui->comboBoxSecondPoint); - FillComboBoxPoints(ui->comboBoxThirdPoint); FillComboBoxTypeLine(ui->comboBoxLineType); + FillComboBoxPoints(ui->comboBoxThirdPoint); connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogBisector::PutHere); connect(listWidget, &QListWidget::itemDoubleClicked, this, &DialogBisector::PutVal); @@ -68,9 +66,6 @@ DialogBisector::DialogBisector(const VContainer *data, QWidget *parent) connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogBisector::NamePointChanged); connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogBisector::FormulaTextChanged); connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogBisector::DeployFormulaTextEdit); - - ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down", - QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png"))); } //--------------------------------------------------------------------------------------------------------------------- @@ -82,20 +77,7 @@ void DialogBisector::FormulaTextChanged() //--------------------------------------------------------------------------------------------------------------------- void DialogBisector::DeployFormulaTextEdit() { - if (ui->plainTextEditFormula->height() < DIALOGBISECTOR_MAX_FORMULA_HEIGHT) - { - ui->plainTextEditFormula->setFixedHeight(DIALOGBISECTOR_MAX_FORMULA_HEIGHT); - //Set icon from theme (internal for Windows system) - ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-next", - QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-next.png"))); - } - else - { - ui->plainTextEditFormula->setFixedHeight(this->formulaBaseHeight); - //Set icon from theme (internal for Windows system) - ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down", - QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png"))); - } + DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogbisector.h b/src/app/dialogs/tools/dialogbisector.h index 700f48c18..8757d482f 100644 --- a/src/app/dialogs/tools/dialogbisector.h +++ b/src/app/dialogs/tools/dialogbisector.h @@ -31,7 +31,6 @@ #include "dialogtool.h" -#define DIALOGBISECTOR_MAX_FORMULA_HEIGHT 64 namespace Ui { class DialogBisector; diff --git a/src/app/dialogs/tools/dialogbisector.ui b/src/app/dialogs/tools/dialogbisector.ui index 5c634c8aa..14a44ddb3 100644 --- a/src/app/dialogs/tools/dialogbisector.ui +++ b/src/app/dialogs/tools/dialogbisector.ui @@ -151,6 +151,12 @@ + + + 0 + 0 + + 16777215 @@ -180,7 +186,7 @@ - + diff --git a/src/app/dialogs/tools/dialogcutarc.cpp b/src/app/dialogs/tools/dialogcutarc.cpp index e4791526c..b80da3206 100644 --- a/src/app/dialogs/tools/dialogcutarc.cpp +++ b/src/app/dialogs/tools/dialogcutarc.cpp @@ -44,16 +44,14 @@ DialogCutArc::DialogCutArc(const VContainer *data, QWidget *parent) { ui->setupUi(this); InitVariables(ui); - labelResultCalculation = ui->labelResultCalculation; - plainTextEditFormula = ui->plainTextEditFormula; - labelEditFormula = ui->labelEditFormula; + InitFormulaUI(ui); labelEditNamePoint = ui->labelEditNamePoint; + this->formulaBaseHeight = ui->plainTextEditFormula->height(); InitOkCancelApply(ui); flagFormula = false; flagName = false; CheckState(); - this->formulaBaseHeight=ui->plainTextEditFormula->height(); FillComboBoxArcs(ui->comboBoxArc); @@ -64,9 +62,6 @@ DialogCutArc::DialogCutArc(const VContainer *data, QWidget *parent) connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogCutArc::NamePointChanged); connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogCutArc::FormulaTextChanged); connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutArc::DeployFormulaTextEdit); - - ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down", - QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png"))); } //--------------------------------------------------------------------------------------------------------------------- @@ -78,20 +73,7 @@ void DialogCutArc::FormulaTextChanged() //--------------------------------------------------------------------------------------------------------------------- void DialogCutArc::DeployFormulaTextEdit() { - if (ui->plainTextEditFormula->height() < DIALOGCUTARC_MAX_FORMULA_HEIGHT) - { - ui->plainTextEditFormula->setFixedHeight(DIALOGCUTARC_MAX_FORMULA_HEIGHT); - //Set icon from theme (internal for Windows system) - ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-next", - QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-next.png"))); - } - else - { - ui->plainTextEditFormula->setFixedHeight(this->formulaBaseHeight); - //Set icon from theme (internal for Windows system) - ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down", - QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png"))); - } + DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogcutarc.h b/src/app/dialogs/tools/dialogcutarc.h index f4a6b6a13..02cb79b66 100644 --- a/src/app/dialogs/tools/dialogcutarc.h +++ b/src/app/dialogs/tools/dialogcutarc.h @@ -31,7 +31,6 @@ #include "dialogtool.h" -#define DIALOGCUTARC_MAX_FORMULA_HEIGHT 64 namespace Ui { class DialogCutArc; diff --git a/src/app/dialogs/tools/dialogcutarc.ui b/src/app/dialogs/tools/dialogcutarc.ui index c79294e69..3450b24fe 100644 --- a/src/app/dialogs/tools/dialogcutarc.ui +++ b/src/app/dialogs/tools/dialogcutarc.ui @@ -144,6 +144,12 @@ + + + 0 + 0 + + 16777215 @@ -173,9 +179,7 @@ - - - + diff --git a/src/app/dialogs/tools/dialogcutspline.cpp b/src/app/dialogs/tools/dialogcutspline.cpp index 979c3d34f..bfb5e1fb7 100644 --- a/src/app/dialogs/tools/dialogcutspline.cpp +++ b/src/app/dialogs/tools/dialogcutspline.cpp @@ -39,16 +39,16 @@ * @param parent parent widget */ DialogCutSpline::DialogCutSpline(const VContainer *data, QWidget *parent) - :DialogTool(data, parent), ui(new Ui::DialogCutSpline), pointName(QString()), formula(QString()), splineId(0) + :DialogTool(data, parent), ui(new Ui::DialogCutSpline), pointName(QString()), formula(QString()), splineId(0), + formulaBaseHeight(0) { ui->setupUi(this); InitVariables(ui); - labelResultCalculation = ui->labelResultCalculation; - lineEditFormula = ui->lineEditFormula; - labelEditFormula = ui->labelEditFormula; + InitFormulaUI(ui); labelEditNamePoint = ui->labelEditNamePoint; - InitOkCancel(ui); + this->formulaBaseHeight = ui->plainTextEditFormula->height(); + InitOkCancel(ui); flagFormula = false; flagName = false; CheckState(); @@ -59,7 +59,8 @@ DialogCutSpline::DialogCutSpline(const VContainer *data, QWidget *parent) connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogCutSpline::PutVal); connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogCutSpline::EvalFormula); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogCutSpline::NamePointChanged); - connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogCutSpline::FormulaChanged); + connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogCutSpline::FormulaChanged); + connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutSpline::DeployFormulaTextEdit); } //--------------------------------------------------------------------------------------------------------------------- @@ -87,7 +88,13 @@ void DialogCutSpline::setPointName(const QString &value) void DialogCutSpline::setFormula(const QString &value) { formula = qApp->FormulaToUser(value); - ui->lineEditFormula->setText(formula); + // increase height if needed. TODO : see if I can get the max number of caracters in one line + // of this PlainTextEdit to change 80 to this value + if (formula.length() > 80) + { + this->DeployFormulaTextEdit(); + } + ui->plainTextEditFormula->setPlainText(formula); } //--------------------------------------------------------------------------------------------------------------------- @@ -125,7 +132,14 @@ void DialogCutSpline::ChoosedObject(quint32 id, const SceneObject &type) void DialogCutSpline::DialogAccepted() { pointName = ui->lineEditNamePoint->text(); - formula = ui->lineEditFormula->text(); + formula = ui->plainTextEditFormula->toPlainText(); + formula.replace("\n", " "); splineId = getCurrentObjectId(ui->comboBoxSpline); emit DialogClosed(QDialog::Accepted); } + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCutSpline::DeployFormulaTextEdit() +{ + DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight); +} diff --git a/src/app/dialogs/tools/dialogcutspline.h b/src/app/dialogs/tools/dialogcutspline.h index 03be441cb..810658c39 100644 --- a/src/app/dialogs/tools/dialogcutspline.h +++ b/src/app/dialogs/tools/dialogcutspline.h @@ -61,6 +61,10 @@ public slots: * @brief DialogApply apply data and emit signal about applied dialog. */ virtual void DialogApply(){} + /** + * @brief DeployFormulaTextEdit grow or shrink formula input + */ + void DeployFormulaTextEdit(); private: Q_DISABLE_COPY(DialogCutSpline) @@ -75,6 +79,9 @@ private: /** @brief splineId keep id of spline */ quint32 splineId; + + /** @brief formulaBaseHeight base height defined by dialogui */ + int formulaBaseHeight; }; //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogcutspline.ui b/src/app/dialogs/tools/dialogcutspline.ui index 4fb194f59..7e564cda5 100644 --- a/src/app/dialogs/tools/dialogcutspline.ui +++ b/src/app/dialogs/tools/dialogcutspline.ui @@ -6,7 +6,7 @@ 0 0 - 520 + 665 546 @@ -67,17 +67,17 @@ - - - - 0 - 0 - + + + Qt::Horizontal - - Formula for the calculation of the spline + + + 40 + 20 + - + @@ -140,6 +140,60 @@ + + + + + + + 0 + 0 + + + + + 16777215 + 24 + + + + + + + + + 18 + 18 + + + + + 0 + 0 + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + + + + + + 16 + 16 + + + + true + + + + + diff --git a/src/app/dialogs/tools/dialogcutsplinepath.cpp b/src/app/dialogs/tools/dialogcutsplinepath.cpp index 725c1ef62..769fffe8b 100644 --- a/src/app/dialogs/tools/dialogcutsplinepath.cpp +++ b/src/app/dialogs/tools/dialogcutsplinepath.cpp @@ -40,14 +40,13 @@ */ DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, QWidget *parent) :DialogTool(data, parent), ui(new Ui::DialogCutSplinePath), pointName(QString()), formula(QString()), - splinePathId(0) + splinePathId(0), formulaBaseHeight(0) { ui->setupUi(this); InitVariables(ui); - labelResultCalculation = ui->labelResultCalculation; - lineEditFormula = ui->lineEditFormula; - labelEditFormula = ui->labelEditFormula; + InitFormulaUI(ui); labelEditNamePoint = ui->labelEditNamePoint; + this->formulaBaseHeight = ui->plainTextEditFormula->height(); InitOkCancel(ui); flagFormula = false; @@ -60,7 +59,8 @@ DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, QWidget *parent connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogCutSplinePath::PutVal); connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogCutSplinePath::EvalFormula); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogCutSplinePath::NamePointChanged); - connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogCutSplinePath::FormulaChanged); + connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogCutSplinePath::FormulaChanged); + connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutSplinePath::DeployFormulaTextEdit); } //--------------------------------------------------------------------------------------------------------------------- @@ -88,7 +88,13 @@ void DialogCutSplinePath::setPointName(const QString &value) void DialogCutSplinePath::setFormula(const QString &value) { formula = qApp->FormulaToUser(value); - ui->lineEditFormula->setText(formula); + // increase height if needed. TODO : see if I can get the max number of caracters in one line + // of this PlainTextEdit to change 80 to this value + if (formula.length() > 80) + { + this->DeployFormulaTextEdit(); + } + ui->plainTextEditFormula->setPlainText(formula); } //--------------------------------------------------------------------------------------------------------------------- @@ -126,7 +132,14 @@ void DialogCutSplinePath::ChoosedObject(quint32 id, const SceneObject &type) void DialogCutSplinePath::DialogAccepted() { pointName = ui->lineEditNamePoint->text(); - formula = ui->lineEditFormula->text(); + formula = ui->plainTextEditFormula->toPlainText(); + formula.replace("\n", " "); splinePathId = getCurrentObjectId(ui->comboBoxSplinePath); emit DialogClosed(QDialog::Accepted); } + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCutSplinePath::DeployFormulaTextEdit() +{ + DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight); +} diff --git a/src/app/dialogs/tools/dialogcutsplinepath.h b/src/app/dialogs/tools/dialogcutsplinepath.h index 0dd7d421f..8bd39f888 100644 --- a/src/app/dialogs/tools/dialogcutsplinepath.h +++ b/src/app/dialogs/tools/dialogcutsplinepath.h @@ -61,6 +61,10 @@ public slots: * @brief DialogApply apply data and emit signal about applied dialog. */ virtual void DialogApply(){} + /** + * @brief DeployFormulaTextEdit grow or shrink formula input + */ + void DeployFormulaTextEdit(); private: Q_DISABLE_COPY(DialogCutSplinePath) @@ -75,6 +79,9 @@ private: /** @brief splinePathId keep id of splinePath */ quint32 splinePathId; + + /** @brief formulaBaseHeight base height defined by dialogui */ + int formulaBaseHeight; }; //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogcutsplinepath.ui b/src/app/dialogs/tools/dialogcutsplinepath.ui index 26351262b..7a441a07c 100644 --- a/src/app/dialogs/tools/dialogcutsplinepath.ui +++ b/src/app/dialogs/tools/dialogcutsplinepath.ui @@ -6,7 +6,7 @@ 0 0 - 605 + 464 499 @@ -67,17 +67,17 @@ - - - - 0 - 0 - + + + Qt::Horizontal - - Formula for the calculation of the curve length + + + 40 + 20 + - + @@ -140,6 +140,60 @@ + + + + + + + 0 + 0 + + + + + 16777215 + 24 + + + + + + + + + 18 + 18 + + + + + 0 + 0 + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + + + + + + 16 + 16 + + + + true + + + + + diff --git a/src/app/dialogs/tools/dialogdetail.cpp b/src/app/dialogs/tools/dialogdetail.cpp index f4e210540..7d8f83e92 100644 --- a/src/app/dialogs/tools/dialogdetail.cpp +++ b/src/app/dialogs/tools/dialogdetail.cpp @@ -170,27 +170,6 @@ void DialogDetail::NewItem(quint32 id, const Tool &typeTool, const NodeDetail &t name = splPath->name(); break; } - case (Tool::ArrowTool): - case (Tool::SinglePointTool): - case (Tool::EndLineTool): - case (Tool::LineTool): - case (Tool::AlongLineTool): - case (Tool::ShoulderPointTool): - case (Tool::NormalTool): - case (Tool::BisectorTool): - case (Tool::LineIntersectTool): - case (Tool::SplineTool): - case (Tool::CutSplineTool): - case (Tool::CutArcTool): - case (Tool::ArcTool): - case (Tool::SplinePathTool): - case (Tool::CutSplinePathTool): - case (Tool::PointOfContact): - case (Tool::DetailTool): - case (Tool::Height): - case (Tool::Triangle): - case (Tool::PointOfIntersection): - case (Tool::UnionDetails): default: qDebug()<<"Got wrong tools. Ignore."; break; diff --git a/src/app/dialogs/tools/dialogeditwrongformula.cpp b/src/app/dialogs/tools/dialogeditwrongformula.cpp index c303e8895..28fe4afe6 100644 --- a/src/app/dialogs/tools/dialogeditwrongformula.cpp +++ b/src/app/dialogs/tools/dialogeditwrongformula.cpp @@ -31,24 +31,23 @@ //--------------------------------------------------------------------------------------------------------------------- DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, QWidget *parent) - :DialogTool(data, parent), ui(new Ui::DialogEditWrongFormula), formula(QString()) + :DialogTool(data, parent), ui(new Ui::DialogEditWrongFormula), formula(QString()), formulaBaseHeight(0) { ui->setupUi(this); InitVariables(ui); - labelResultCalculation = ui->labelResult; - lineEditFormula = ui->lineEditFormula; - labelEditFormula = ui->labelFormula; + InitFormulaUI(ui); + this->formulaBaseHeight = ui->plainTextEditFormula->height(); InitOkCancel(ui); flagFormula = false; CheckState(); - connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogEditWrongFormula::PutHere); connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogEditWrongFormula::PutVal); connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogEditWrongFormula::EvalFormula); - connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogEditWrongFormula::FormulaChanged); + connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogEditWrongFormula::FormulaChanged); + connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogEditWrongFormula::DeployFormulaTextEdit); //Disable Qt::WaitCursor #ifndef QT_NO_CURSOR @@ -68,7 +67,8 @@ DialogEditWrongFormula::~DialogEditWrongFormula() //--------------------------------------------------------------------------------------------------------------------- void DialogEditWrongFormula::DialogAccepted() { - formula = ui->lineEditFormula->text(); + formula = ui->plainTextEditFormula->toPlainText(); + formula.replace("\n", " "); emit DialogClosed(QDialog::Accepted); accepted(); } @@ -80,6 +80,12 @@ void DialogEditWrongFormula::DialogRejected() rejected(); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditWrongFormula::DeployFormulaTextEdit() +{ + DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight); +} + //--------------------------------------------------------------------------------------------------------------------- void DialogEditWrongFormula::CheckState() { @@ -91,7 +97,13 @@ void DialogEditWrongFormula::CheckState() void DialogEditWrongFormula::setFormula(const QString &value) { formula = qApp->FormulaToUser(value); - ui->lineEditFormula->setText(formula); + // increase height if needed. TODO : see if I can get the max number of caracters in one line + // of this PlainTextEdit to change 80 to this value + if (formula.length() > 80) + { + this->DeployFormulaTextEdit(); + } + ui->plainTextEditFormula->setPlainText(formula); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogeditwrongformula.h b/src/app/dialogs/tools/dialogeditwrongformula.h index d7e22f6de..f1459f69d 100644 --- a/src/app/dialogs/tools/dialogeditwrongformula.h +++ b/src/app/dialogs/tools/dialogeditwrongformula.h @@ -56,6 +56,10 @@ public: public slots: virtual void DialogAccepted(); virtual void DialogRejected(); + /** + * @brief DeployFormulaTextEdit grow or shrink formula input + */ + void DeployFormulaTextEdit(); protected: virtual void CheckState(); private: @@ -64,6 +68,9 @@ private: /** @brief formula string with formula */ QString formula; + + /** @brief formulaBaseHeight base height defined by dialogui */ + int formulaBaseHeight; }; diff --git a/src/app/dialogs/tools/dialogeditwrongformula.ui b/src/app/dialogs/tools/dialogeditwrongformula.ui index 15e900f08..64cc17aa9 100644 --- a/src/app/dialogs/tools/dialogeditwrongformula.ui +++ b/src/app/dialogs/tools/dialogeditwrongformula.ui @@ -6,305 +6,357 @@ 0 0 - 607 + 507 535 Edit wrong formula - + - + - - - - - - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 159 - 158 - 158 - - - - - - - - Formula - - - - - - - - 0 - 0 - - - - First angle of arc counterclockwise - - - - - - - Insert variable into formula - - - ... - - - - :/icon/24x24/putHereLeft.png:/icon/24x24/putHereLeft.png - - - - 24 - 24 - - - - - - - - Calculate value - - - ... - - - - :/icon/24x24/equal.png:/icon/24x24/equal.png - - - - 24 - 24 - - - - - - - - - 0 - 0 - - - - - 87 - 0 - - - - Value of first angle - - - _ - - - - - - - - - - - - - - - - 0 - 0 - - - - Input data - - - - - - - - 0 - 0 - - - - Size and height - - - true - - - - - - - - 0 - 0 - - - - Standard table - - - - - - - - 0 - 0 - - - - Increments - - - - - - - true - - - - 0 - 0 - - - - Length of lines - - - - - - - true - - - - 0 - 0 - - - - Length of arcs - - - - - - - true - - - - 0 - 0 - - - - Length of curves - - - - - - - true - - - - 0 - 0 - - - - Angle of lines - - - - - - - - - - - Variables - - - - - - - - - + + + + 0 + 0 + - - true + + + + + + + 255 + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 159 + 158 + 158 + + + + + + + + Formula - + Qt::Horizontal - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + 40 + 20 + + + + + + + + Insert variable into formula + + + ... + + + + :/icon/24x24/putHereLeft.png:/icon/24x24/putHereLeft.png + + + + 24 + 24 + + + + + + + + Calculate value + + + ... + + + + :/icon/24x24/equal.png:/icon/24x24/equal.png + + + + 24 + 24 + + + + + + + + + 0 + 0 + + + + + 87 + 0 + + + + Value of first angle + + + _ + + + + + + + 0 + 0 + + + + + 16777215 + 24 + + + + + + + + + 18 + 18 + + + + + 0 + 0 + + + + <html><head/><body><p>Show full calculation in message box</p></body></html> + + + + + + + + + + + + 16 + 16 + + + + true + + + + + + + + + + + + + + + + 0 + 0 + + + + Input data + + + + + + + + 0 + 0 + + + + Size and height + + + true + + + + + + + + 0 + 0 + + + + Standard table + + + + + + + + 0 + 0 + + + + Increments + + + + + + + true + + + + 0 + 0 + + + + Length of lines + + + + + + + true + + + + 0 + 0 + + + + Length of arcs + + + + + + + true + + + + 0 + 0 + + + + Length of curves + + + + + + + true + + + + 0 + 0 + + + + Angle of lines + + + + + + + + + + + Variables + + + + + + + + + + + + true + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + diff --git a/src/app/dialogs/tools/dialogendline.cpp b/src/app/dialogs/tools/dialogendline.cpp index aeca74c04..5b7770a1c 100644 --- a/src/app/dialogs/tools/dialogendline.cpp +++ b/src/app/dialogs/tools/dialogendline.cpp @@ -44,12 +44,9 @@ DialogEndLine::DialogEndLine(const VContainer *data, QWidget *parent) { ui->setupUi(this); InitVariables(ui); - labelResultCalculation = ui->labelResultCalculation; - plainTextEditFormula = ui->plainTextEditFormula; - labelEditFormula = ui->labelEditFormula; + InitFormulaUI(ui); labelEditNamePoint = ui->labelEditNamePoint; - - this->formulaBaseHeight=ui->plainTextEditFormula->height(); + this->formulaBaseHeight = ui->plainTextEditFormula->height(); InitOkCancelApply(ui); flagFormula = false; @@ -67,10 +64,6 @@ DialogEndLine::DialogEndLine(const VContainer *data, QWidget *parent) connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogEndLine::NamePointChanged); connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogEndLine::FormulaTextChanged); connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogEndLine::DeployFormulaTextEdit); - - ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down", - QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png"))); - } //--------------------------------------------------------------------------------------------------------------------- @@ -82,20 +75,7 @@ void DialogEndLine::FormulaTextChanged() //--------------------------------------------------------------------------------------------------------------------- void DialogEndLine::DeployFormulaTextEdit() { - if (ui->plainTextEditFormula->height() < DIALOGENDLINE_MAX_FORMULA_HEIGHT) - { - ui->plainTextEditFormula->setFixedHeight(DIALOGENDLINE_MAX_FORMULA_HEIGHT); - //Set icon from theme (internal for Windows system) - ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-next", - QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-next.png"))); - } - else - { - ui->plainTextEditFormula->setFixedHeight(this->formulaBaseHeight); - //Set icon from theme (internal for Windows system) - ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down", - QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png"))); - } + DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogendline.h b/src/app/dialogs/tools/dialogendline.h index 9f755b7d7..5e53bfe5c 100644 --- a/src/app/dialogs/tools/dialogendline.h +++ b/src/app/dialogs/tools/dialogendline.h @@ -31,8 +31,6 @@ #include "dialogtool.h" - -#define DIALOGENDLINE_MAX_FORMULA_HEIGHT 64 namespace Ui { class DialogEndLine; diff --git a/src/app/dialogs/tools/dialogendline.ui b/src/app/dialogs/tools/dialogendline.ui index 12be8bf7a..9db253c80 100644 --- a/src/app/dialogs/tools/dialogendline.ui +++ b/src/app/dialogs/tools/dialogendline.ui @@ -189,8 +189,9 @@ - - :/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png:/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png + + + @@ -331,7 +332,7 @@ - :/icon/24x24/arrowRightUp.png:/icon/24x24/arrowRightUp.png + :/icon/32x32/arrowRightUp.png:/icon/32x32/arrowRightUp.png @@ -348,7 +349,7 @@ - :/icon/24x24/arrowLeftUp.png:/icon/24x24/arrowLeftUp.png + :/icon/32x32/arrowLeftUp.png:/icon/32x32/arrowLeftUp.png @@ -365,7 +366,7 @@ - :/icon/24x24/arrowLeft.png:/icon/24x24/arrowLeft.png + :/icon/32x32/arrowLeft.png:/icon/32x32/arrowLeft.png @@ -382,7 +383,7 @@ - :/icon/24x24/arrowRight.png:/icon/24x24/arrowRight.png + :/icon/32x32/arrowRight.png:/icon/32x32/arrowRight.png @@ -405,7 +406,7 @@ - :/icon/24x24/arrowUp.png:/icon/24x24/arrowUp.png + :/icon/32x32/arrowUp.png:/icon/32x32/arrowUp.png @@ -422,7 +423,7 @@ - :/icon/24x24/arrowDown.png:/icon/24x24/arrowDown.png + :/icon/32x32/arrowDown.png:/icon/32x32/arrowDown.png @@ -439,7 +440,7 @@ - :/icon/24x24/arrowLeftDown.png:/icon/24x24/arrowLeftDown.png + :/icon/32x32/arrowLeftDown.png:/icon/32x32/arrowLeftDown.png @@ -456,7 +457,7 @@ - :/icon/24x24/arrowRightDown.png:/icon/24x24/arrowRightDown.png + :/icon/32x32/arrowRightDown.png:/icon/32x32/arrowRightDown.png @@ -677,7 +678,6 @@ - diff --git a/src/app/dialogs/tools/dialognormal.cpp b/src/app/dialogs/tools/dialognormal.cpp index 87cabe48f..b306c45a1 100644 --- a/src/app/dialogs/tools/dialognormal.cpp +++ b/src/app/dialogs/tools/dialognormal.cpp @@ -41,14 +41,11 @@ DialogNormal::DialogNormal(const VContainer *data, QWidget *parent) { ui->setupUi(this); InitVariables(ui); - labelResultCalculation = ui->labelResultCalculation; - plainTextEditFormula = ui->plainTextEditFormula; - labelEditFormula = ui->labelEditFormula; + InitFormulaUI(ui); labelEditNamePoint = ui->labelEditNamePoint; + this->formulaBaseHeight = ui->plainTextEditFormula->height(); + InitOkCancelApply(ui); - - this->formulaBaseHeight=ui->plainTextEditFormula->height(); - flagFormula = false; flagName = false; CheckState(); @@ -65,9 +62,6 @@ DialogNormal::DialogNormal(const VContainer *data, QWidget *parent) connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogNormal::NamePointChanged); connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogNormal::FormulaTextChanged); connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogNormal::DeployFormulaTextEdit); - - ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down", - QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png"))); } //--------------------------------------------------------------------------------------------------------------------- @@ -79,18 +73,7 @@ void DialogNormal::FormulaTextChanged() //--------------------------------------------------------------------------------------------------------------------- void DialogNormal::DeployFormulaTextEdit() { - if (ui->plainTextEditFormula->height() < DIALOGNORMAL_MAX_FORMULA_HEIGHT) - { - ui->plainTextEditFormula->setFixedHeight(DIALOGNORMAL_MAX_FORMULA_HEIGHT); - //Set icon from theme (internal for Windows system) - ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-next")); - } - else - { - ui->plainTextEditFormula->setFixedHeight(this->formulaBaseHeight); - //Set icon from theme (internal for Windows system) - ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down")); - } + DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialognormal.h b/src/app/dialogs/tools/dialognormal.h index 2fdcbb6cc..747067463 100644 --- a/src/app/dialogs/tools/dialognormal.h +++ b/src/app/dialogs/tools/dialognormal.h @@ -31,7 +31,6 @@ #include "dialogtool.h" -#define DIALOGNORMAL_MAX_FORMULA_HEIGHT 64 namespace Ui { class DialogNormal; diff --git a/src/app/dialogs/tools/dialognormal.ui b/src/app/dialogs/tools/dialognormal.ui index a135ba36a..b774de117 100644 --- a/src/app/dialogs/tools/dialognormal.ui +++ b/src/app/dialogs/tools/dialognormal.ui @@ -154,6 +154,12 @@ + + + 0 + 0 + + 16777215 @@ -183,7 +189,7 @@ - + @@ -345,7 +351,7 @@ - :/icon/24x24/arrowRightUp.png:/icon/24x24/arrowRightUp.png + :/icon/32x32/arrowRightUp.png:/icon/32x32/arrowRightUp.png @@ -362,7 +368,7 @@ - :/icon/24x24/arrowLeftUp.png:/icon/24x24/arrowLeftUp.png + :/icon/32x32/arrowLeftUp.png:/icon/32x32/arrowLeftUp.png @@ -379,7 +385,7 @@ - :/icon/24x24/arrowLeft.png:/icon/24x24/arrowLeft.png + :/icon/32x32/arrowLeft.png:/icon/32x32/arrowLeft.png @@ -396,7 +402,7 @@ - :/icon/24x24/arrowRight.png:/icon/24x24/arrowRight.png + :/icon/32x32/arrowRight.png:/icon/32x32/arrowRight.png @@ -419,7 +425,7 @@ - :/icon/24x24/arrowUp.png:/icon/24x24/arrowUp.png + :/icon/32x32/arrowUp.png:/icon/32x32/arrowUp.png @@ -436,7 +442,7 @@ - :/icon/24x24/arrowDown.png:/icon/24x24/arrowDown.png + :/icon/32x32/arrowDown.png:/icon/32x32/arrowDown.png @@ -453,7 +459,7 @@ - :/icon/24x24/arrowLeftDown.png:/icon/24x24/arrowLeftDown.png + :/icon/32x32/arrowLeftDown.png:/icon/32x32/arrowLeftDown.png @@ -470,7 +476,7 @@ - :/icon/24x24/arrowRightDown.png:/icon/24x24/arrowRightDown.png + :/icon/32x32/arrowRightDown.png:/icon/32x32/arrowRightDown.png diff --git a/src/app/dialogs/tools/dialogpointofcontact.cpp b/src/app/dialogs/tools/dialogpointofcontact.cpp index ee3310d4c..322471c8f 100644 --- a/src/app/dialogs/tools/dialogpointofcontact.cpp +++ b/src/app/dialogs/tools/dialogpointofcontact.cpp @@ -43,36 +43,18 @@ DialogPointOfContact::DialogPointOfContact(const VContainer *data, QWidget *pare { ui->setupUi(this); InitVariables(ui); - listWidget = ui->listWidget; - labelResultCalculation = ui->labelResultCalculation; - labelDescription = ui->labelDescription; - radioButtonSizeGrowth = ui->radioButtonSizeGrowth; - radioButtonStandardTable = ui->radioButtonStandardTable; - radioButtonIncrements = ui->radioButtonIncrements; - radioButtonLengthLine = ui->radioButtonLengthLine; - radioButtonLengthArc = ui->radioButtonLengthArc; - radioButtonLengthCurve = ui->radioButtonLengthSpline; - plainTextEditFormula = ui->plainTextEditFormula; - labelEditFormula = ui->labelEditFormula; + InitFormulaUI(ui); labelEditNamePoint = ui->labelEditNamePoint; + this->formulaBaseHeight = ui->plainTextEditFormula->height(); - this->formulaBaseHeight=ui->plainTextEditFormula->height(); InitOkCancelApply(ui); - - /* bOk = ui.buttonBox->button(QDialogButtonBox::Ok); - SCASSERT(bOk != nullptr); - connect(bOk, &QPushButton::clicked, this, &DialogTool::DialogAccepted); - QPushButton *bCansel = ui.buttonBox->button(QDialogButtonBox::Cancel); - SCASSERT(bCansel != nullptr); - connect(bCansel, &QPushButton::clicked, this, &DialogTool::DialogRejected); - */ flagFormula = false; flagName = false; CheckState(); - FillComboBoxPoints(ui->comboBoxCenter); FillComboBoxPoints(ui->comboBoxFirstPoint); FillComboBoxPoints(ui->comboBoxSecondPoint); + FillComboBoxPoints(ui->comboBoxCenter); connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogPointOfContact::PutHere); connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogPointOfContact::PutVal); @@ -97,9 +79,6 @@ DialogPointOfContact::DialogPointOfContact(const VContainer *data, QWidget *pare connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfContact::NamePointChanged); connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogPointOfContact::FormulaTextChanged); connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogPointOfContact::DeployFormulaTextEdit); - - ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down", - QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png"))); } //--------------------------------------------------------------------------------------------------------------------- @@ -111,20 +90,7 @@ void DialogPointOfContact::FormulaTextChanged() //--------------------------------------------------------------------------------------------------------------------- void DialogPointOfContact::DeployFormulaTextEdit() { - if (ui->plainTextEditFormula->height() < DIALOGPOINTOFCONTACT_MAX_FORMULA_HEIGHT) - { - ui->plainTextEditFormula->setFixedHeight(DIALOGPOINTOFCONTACT_MAX_FORMULA_HEIGHT); - //Set icon from theme (internal for Windows system) - ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-next", - QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-next.png"))); - } - else - { - ui->plainTextEditFormula->setFixedHeight(this->formulaBaseHeight); - //Set icon from theme (internal for Windows system) - ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down", - QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png"))); - } + DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogpointofcontact.h b/src/app/dialogs/tools/dialogpointofcontact.h index d0517dd2f..e4413785e 100644 --- a/src/app/dialogs/tools/dialogpointofcontact.h +++ b/src/app/dialogs/tools/dialogpointofcontact.h @@ -32,7 +32,6 @@ #include "ui_dialogpointofcontact.h" #include "dialogtool.h" -#define DIALOGPOINTOFCONTACT_MAX_FORMULA_HEIGHT 64 namespace Ui { class DialogPointOfContact; diff --git a/src/app/dialogs/tools/dialogpointofcontact.ui b/src/app/dialogs/tools/dialogpointofcontact.ui index 147765832..fd13a0448 100644 --- a/src/app/dialogs/tools/dialogpointofcontact.ui +++ b/src/app/dialogs/tools/dialogpointofcontact.ui @@ -154,6 +154,12 @@ + + + 0 + 0 + + 16777215 @@ -183,9 +189,7 @@ - - - + diff --git a/src/app/dialogs/tools/dialogpointofintersection.cpp b/src/app/dialogs/tools/dialogpointofintersection.cpp index 58b058cdb..9a998063c 100644 --- a/src/app/dialogs/tools/dialogpointofintersection.cpp +++ b/src/app/dialogs/tools/dialogpointofintersection.cpp @@ -44,6 +44,7 @@ DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, QWi { ui->setupUi(this); labelEditNamePoint = ui->labelEditNamePoint; + InitOkCancel(ui); flagName = false; CheckState(); diff --git a/src/app/dialogs/tools/dialogshoulderpoint.cpp b/src/app/dialogs/tools/dialogshoulderpoint.cpp index 0df400703..d88e15e1a 100644 --- a/src/app/dialogs/tools/dialogshoulderpoint.cpp +++ b/src/app/dialogs/tools/dialogshoulderpoint.cpp @@ -43,16 +43,12 @@ DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, QWidget *parent typeLine(QString()), formula(QString()), p1Line(0), p2Line(0), pShoulder(0), formulaBaseHeight(0) { ui->setupUi(this); - number = 0; InitVariables(ui); - labelResultCalculation = ui->labelResultCalculation; - plainTextEditFormula = ui->plainTextEditFormula; - labelEditFormula = ui->labelEditFormula; + InitFormulaUI(ui); labelEditNamePoint = ui->labelEditNamePoint; + this->formulaBaseHeight = ui->plainTextEditFormula->height(); + InitOkCancelApply(ui); - - this->formulaBaseHeight=ui->plainTextEditFormula->height(); - flagFormula = false; flagName = false; CheckState(); @@ -68,9 +64,6 @@ DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, QWidget *parent connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogShoulderPoint::NamePointChanged); connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogShoulderPoint::FormulaTextChanged); connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogShoulderPoint::DeployFormulaTextEdit); - - ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down", - QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png"))); } //--------------------------------------------------------------------------------------------------------------------- @@ -82,20 +75,7 @@ void DialogShoulderPoint::FormulaTextChanged() //--------------------------------------------------------------------------------------------------------------------- void DialogShoulderPoint::DeployFormulaTextEdit() { - if (ui->plainTextEditFormula->height() < DIALOGSHOULDERPOINT_MAX_FORMULA_HEIGHT) - { - ui->plainTextEditFormula->setFixedHeight(DIALOGSHOULDERPOINT_MAX_FORMULA_HEIGHT); - //Set icon from theme (internal for Windows system) - ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-next", - QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-next.png"))); - } - else - { - ui->plainTextEditFormula->setFixedHeight(this->formulaBaseHeight); - //Set icon from theme (internal for Windows system) - ui->pushButtonGrowLength->setIcon(QIcon::fromTheme("go-down", - QIcon(":/icons/win.icon.theme/icons/win.icon.theme/16x16/actions/go-down.png"))); - } + DeployFormula(ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogshoulderpoint.h b/src/app/dialogs/tools/dialogshoulderpoint.h index 3b7a389a8..17afae0ad 100644 --- a/src/app/dialogs/tools/dialogshoulderpoint.h +++ b/src/app/dialogs/tools/dialogshoulderpoint.h @@ -31,7 +31,6 @@ #include "dialogtool.h" -#define DIALOGSHOULDERPOINT_MAX_FORMULA_HEIGHT 64 namespace Ui { class DialogShoulderPoint; diff --git a/src/app/dialogs/tools/dialogshoulderpoint.ui b/src/app/dialogs/tools/dialogshoulderpoint.ui index a9ed3dc8b..583815972 100644 --- a/src/app/dialogs/tools/dialogshoulderpoint.ui +++ b/src/app/dialogs/tools/dialogshoulderpoint.ui @@ -154,6 +154,12 @@ + + + 0 + 0 + + 16777215 @@ -183,9 +189,7 @@ - - - + diff --git a/src/app/dialogs/tools/dialogsinglepoint.cpp b/src/app/dialogs/tools/dialogsinglepoint.cpp index e7caa1d34..596a8a17a 100644 --- a/src/app/dialogs/tools/dialogsinglepoint.cpp +++ b/src/app/dialogs/tools/dialogsinglepoint.cpp @@ -36,8 +36,7 @@ * @param parent parent widget */ DialogSinglePoint::DialogSinglePoint(const VContainer *data, QWidget *parent) - :DialogTool(data, parent), ui(new Ui::DialogSinglePoint), name(QString()), - point(QPointF()) + :DialogTool(data, parent), ui(new Ui::DialogSinglePoint), name(QString()), point(QPointF()) { ui->setupUi(this); ui->doubleSpinBoxX->setRange(0, qApp->fromPixel(SceneSize)); diff --git a/src/app/dialogs/tools/dialogspline.cpp b/src/app/dialogs/tools/dialogspline.cpp index bf5a8df41..4640380cb 100644 --- a/src/app/dialogs/tools/dialogspline.cpp +++ b/src/app/dialogs/tools/dialogspline.cpp @@ -39,8 +39,8 @@ * @param parent parent widget */ DialogSpline::DialogSpline(const VContainer *data, QWidget *parent) - :DialogTool(data, parent), ui(new Ui::DialogSpline), number(0), p1(0), p4(0), angle1(0), angle2(0), - kAsm1(1), kAsm2(1), kCurve(1) + :DialogTool(data, parent), ui(new Ui::DialogSpline), number(0), p1(0), p4(0), angle1(0), angle2(0), kAsm1(1), + kAsm2(1), kCurve(1) { ui->setupUi(this); InitOkCancel(ui); diff --git a/src/app/dialogs/tools/dialogtool.cpp b/src/app/dialogs/tools/dialogtool.cpp index 570d2ef8e..e6698ea66 100644 --- a/src/app/dialogs/tools/dialogtool.cpp +++ b/src/app/dialogs/tools/dialogtool.cpp @@ -41,7 +41,6 @@ #include #include #include -#include #include #include #include @@ -51,6 +50,8 @@ #include #include +#define DIALOGARC_MAX_FORMULA_HEIGHT 64 + //--------------------------------------------------------------------------------------------------------------------- /** * @brief DialogTool create dialog @@ -59,7 +60,7 @@ */ DialogTool::DialogTool(const VContainer *data, QWidget *parent) :QDialog(parent), data(data), isInitialized(false), flagName(true), flagFormula(true), timerFormula(nullptr), - bOk(nullptr), bApply(nullptr), spinBoxAngle(nullptr), lineEditFormula(nullptr), plainTextEditFormula(nullptr), + bOk(nullptr), bApply(nullptr), spinBoxAngle(nullptr), plainTextEditFormula(nullptr), listWidget(nullptr), labelResultCalculation(nullptr), labelDescription(nullptr), labelEditNamePoint(nullptr), labelEditFormula(nullptr), radioButtonSizeGrowth(nullptr), radioButtonStandardTable(nullptr), radioButtonIncrements(nullptr), radioButtonLengthLine(nullptr), radioButtonLengthArc(nullptr), @@ -385,12 +386,6 @@ void DialogTool::PutValHere(QPlainTextEdit *plainTextEdit, QListWidget *listWidg QTextCursor cursor = plainTextEdit->textCursor(); cursor.insertText(item->text()); plainTextEdit->setTextCursor(cursor); - /* - int pos = lineEdit->cursorPosition(); - lineEdit->setText(lineEdit->text().insert(lineEdit->cursorPosition(), item->text())); - lineEdit->setFocus(); - lineEdit->setCursorPosition(pos + item->text().size()); - */ } //--------------------------------------------------------------------------------------------------------------------- @@ -437,19 +432,18 @@ void DialogTool::ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer *tim //--------------------------------------------------------------------------------------------------------------------- /** * @brief Eval evaluate formula and show result - * @param edit lineEdit of formula + * @param text formula * @param flag flag state of formula * @param timer timer of formula * @param label label for signal error */ -void DialogTool::Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label) +void DialogTool::Eval(const QString &text, bool &flag, QTimer *timer, QLabel *label) { - SCASSERT(edit != nullptr); SCASSERT(timer != nullptr); SCASSERT(label != nullptr); SCASSERT(labelEditFormula != nullptr); QPalette palette = labelEditFormula->palette(); - if (edit->text().isEmpty()) + if (text.isEmpty()) { flag = false; palette.setColor(labelEditFormula->foregroundRole(), Qt::red); @@ -458,66 +452,8 @@ void DialogTool::Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label) { try { - const QString formula = qApp->FormulaFromUser(edit->text()); - Calculator *cal = new Calculator(data); - const qreal result = cal->EvalFormula(formula); - delete cal; - - QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), - QApplication::applicationName()); - bool osSeparatorValue = settings.value("configuration/osSeparator", 1).toBool(); - - if (osSeparatorValue) - { - QLocale loc = QLocale::system(); - label->setText(loc.toString(result) + VDomDocument::UnitsToStr(qApp->patternUnit(), true)); - } - else - { - QLocale loc = QLocale(QLocale::C); - label->setText(loc.toString(result) + VDomDocument::UnitsToStr(qApp->patternUnit(), true)); - } - flag = true; - palette.setColor(labelEditFormula->foregroundRole(), QColor(76, 76, 76)); - emit ToolTip(""); - } - catch (qmu::QmuParserError &e) - { - label->setText(tr("Error")); - flag = false; - palette.setColor(labelEditFormula->foregroundRole(), Qt::red); - emit ToolTip("Parser error: "+e.GetMsg()); - qDebug() << "\nMath parser error:\n" - << "--------------------------------------\n" - << "Message: " << e.GetMsg() << "\n" - << "Expression: " << e.GetExpr() << "\n" - << "--------------------------------------"; - } - } - CheckState(); - timer->stop(); - labelEditFormula->setPalette(palette); -} - -//--------------------------------------------------------------------------------------------------------------------- -void DialogTool::Eval(QPlainTextEdit *edit, bool &flag, QTimer *timer, QLabel *label) -{ - SCASSERT(edit != nullptr); - SCASSERT(timer != nullptr); - SCASSERT(label != nullptr); - SCASSERT(labelEditFormula != nullptr); - QPalette palette = labelEditFormula->palette(); - if (edit->toPlainText().isEmpty()) - { - flag = false; - palette.setColor(labelEditFormula->foregroundRole(), Qt::red); - } - else - { - try - { - // Replace line return with spaces for calc - QString formula = edit->toPlainText(); + // Replace line return with spaces for calc if exist + QString formula = text; formula.replace("\n", " "); formula = qApp->FormulaFromUser(formula); Calculator *cal = new Calculator(data); @@ -633,7 +569,7 @@ quint32 DialogTool::getCurrentObjectId(QComboBox *box) const { SCASSERT(box != nullptr); qint32 index = box->currentIndex(); - Q_ASSERT(index != -1); + SCASSERT(index != -1); if (index != -1) { return qvariant_cast(box->itemData(index)); @@ -660,6 +596,27 @@ bool DialogTool::ChoosedPoint(const quint32 &id, QComboBox *box, const QString & return false; } +//--------------------------------------------------------------------------------------------------------------------- +void DialogTool::DeployFormula(QPlainTextEdit *formula, QPushButton *buttonGrowLength, int formulaBaseHeight) +{ + SCASSERT(formula != nullptr); + SCASSERT(buttonGrowLength != nullptr) + if (formula->height() < DIALOGARC_MAX_FORMULA_HEIGHT) + { + formula->setFixedHeight(DIALOGARC_MAX_FORMULA_HEIGHT); + //Set icon from theme (internal for Windows system) + buttonGrowLength->setIcon(QIcon::fromTheme("go-next", + QIcon(":/icons/win.icon.theme/16x16/actions/go-next.png"))); + } + else + { + formula->setFixedHeight(formulaBaseHeight); + //Set icon from theme (internal for Windows system) + buttonGrowLength->setIcon(QIcon::fromTheme("go-down", + QIcon(":/icons/win.icon.theme/16x16/actions/go-down.png"))); + } +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief FillList fill combobox list @@ -759,7 +716,7 @@ void DialogTool::DialogRejected() */ void DialogTool::FormulaChanged() { - QLineEdit* edit = qobject_cast(sender()); + QPlainTextEdit* edit = qobject_cast(sender()); if (edit) { ValFormulaChanged(flagFormula, edit, timerFormula); @@ -863,7 +820,7 @@ void DialogTool::EvalFormula() { SCASSERT(plainTextEditFormula != nullptr); SCASSERT(labelResultCalculation != nullptr); - Eval(plainTextEditFormula, flagFormula, timerFormula, labelResultCalculation); + Eval(plainTextEditFormula->toPlainText(), flagFormula, timerFormula, labelResultCalculation); } //--------------------------------------------------------------------------------------------------------------------- @@ -956,12 +913,6 @@ void DialogTool::PutVal(QListWidgetItem *item) QTextCursor cursor = plainTextEditFormula->textCursor(); cursor.insertText(item->text()); plainTextEditFormula->setTextCursor(cursor); - /*int pos = plainTextEditFormula->cursorPosition(); - lineEditFormula->setText(lineEditFormula->text().insert(lineEditFormula->cursorPosition(), - item->text())); - lineEditFormula->setFocus(); - lineEditFormula->setCursorPosition(pos + item->text().size()); - */ } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogtool.h b/src/app/dialogs/tools/dialogtool.h index 0ddbabe69..bcf1dc425 100644 --- a/src/app/dialogs/tools/dialogtool.h +++ b/src/app/dialogs/tools/dialogtool.h @@ -39,7 +39,6 @@ class QLabel; class QRadioButton; class QComboBox; class QListWidgetItem; -class QLineEdit; class QListWidget; class VContainer; class QPlainTextEdit; @@ -134,8 +133,7 @@ protected: /** @brief spinBoxAngle spinbox for angle */ QDoubleSpinBox *spinBoxAngle; - /** @brief lineEditFormula linEdit for formula */ - QLineEdit *lineEditFormula; + /** @brief plainTextEditFormula formula */ QPlainTextEdit *plainTextEditFormula; /** @brief listWidget listWidget with variables */ QListWidget *listWidget; @@ -194,8 +192,7 @@ protected: void PutValHere(QPlainTextEdit *plainTextEdit, QListWidget *listWidget); void ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer * timer); void ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer * timer); - void Eval(QPlainTextEdit *edit, bool &flag, QTimer *timer, QLabel *label); - void Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label); + void Eval(const QString &text, bool &flag, QTimer *timer, QLabel *label); void setCurrentPointId(QComboBox *box, quint32 &pointId, const quint32 &value, const quint32 &id) const; void setCurrentSplineId(QComboBox *box, quint32 &splineId, const quint32 &value, const quint32 &id, ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline) const; @@ -206,6 +203,7 @@ protected: ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline) const; quint32 getCurrentObjectId(QComboBox *box) const; bool ChoosedPoint(const quint32 &id, QComboBox *box, const QString &toolTip); + void DeployFormula(QPlainTextEdit *formula, QPushButton *buttonGrowLength, int formulaBaseHeight); template void InitArrow(T *ui) { @@ -278,6 +276,17 @@ protected: SCASSERT(bCancel != nullptr); connect(bCancel, &QPushButton::clicked, this, &DialogTool::DialogRejected); } + template + /** + * @brief InitFormulaUI initialise ui object for formula fild + * @param ui Dialog container + */ + void InitFormulaUI(T *ui) + { + labelResultCalculation = ui->labelResultCalculation; + plainTextEditFormula = ui->plainTextEditFormula; + labelEditFormula = ui->labelEditFormula; + } /** * @brief associatedTool vdrawtool associated with opened dialog. */ diff --git a/src/app/dialogs/tools/dialogtriangle.cpp b/src/app/dialogs/tools/dialogtriangle.cpp index b421253fc..1db585d65 100644 --- a/src/app/dialogs/tools/dialogtriangle.cpp +++ b/src/app/dialogs/tools/dialogtriangle.cpp @@ -43,6 +43,7 @@ DialogTriangle::DialogTriangle(const VContainer *data, QWidget *parent) { ui->setupUi(this); labelEditNamePoint = ui->labelEditNamePoint; + InitOkCancel(ui); flagName = false; CheckState(); diff --git a/src/app/geometry/vequidistant.cpp b/src/app/geometry/vequidistant.cpp index cab6b2223..9ee6c10f0 100644 --- a/src/app/geometry/vequidistant.cpp +++ b/src/app/geometry/vequidistant.cpp @@ -132,27 +132,6 @@ QPainterPath VEquidistant::ContourPath(const quint32 &idDetail, const VContainer } } break; - case (Tool::ArrowTool): - case (Tool::SinglePointTool): - case (Tool::EndLineTool): - case (Tool::LineTool): - case (Tool::AlongLineTool): - case (Tool::ShoulderPointTool): - case (Tool::NormalTool): - case (Tool::BisectorTool): - case (Tool::LineIntersectTool): - case (Tool::SplineTool): - case (Tool::CutSplineTool): - case (Tool::CutArcTool): - case (Tool::ArcTool): - case (Tool::SplinePathTool): - case (Tool::CutSplinePathTool): - case (Tool::PointOfContact): - case (Tool::DetailTool): - case (Tool::Height): - case (Tool::Triangle): - case (Tool::PointOfIntersection): - case (Tool::UnionDetails): default: qDebug()<<"Get wrong tool type. Ignore."<< static_cast(detail.at(i).getTypeTool()); break; @@ -395,7 +374,7 @@ QVector VEquidistant::CheckLoops(const QVector &points) //--------------------------------------------------------------------------------------------------------------------- QVector VEquidistant::GetReversePoint(const QVector &points) { - Q_ASSERT(points.size() > 0); + SCASSERT(points.size() > 0); QVector reversePoints; for (qint32 i = points.size() - 1; i >= 0; --i) { @@ -407,7 +386,7 @@ QVector VEquidistant::GetReversePoint(const QVector &points) //--------------------------------------------------------------------------------------------------------------------- QVector VEquidistant::EkvPoint(const QLineF &line1, const QLineF &line2, const qreal &width) { - Q_ASSERT(width > 0); + SCASSERT(width > 0); QVector points; if (line1.p2() != line2.p2()) { @@ -457,7 +436,7 @@ QVector VEquidistant::EkvPoint(const QLineF &line1, const QLineF &line2 //--------------------------------------------------------------------------------------------------------------------- QLineF VEquidistant::ParallelLine(const QLineF &line, qreal width) { - Q_ASSERT(width > 0); + SCASSERT(width > 0); QLineF paralel = QLineF (SingleParallelPoint(line, 90, width), SingleParallelPoint(QLineF(line.p2(), line.p1()), -90, width)); return paralel; @@ -466,7 +445,7 @@ QLineF VEquidistant::ParallelLine(const QLineF &line, qreal width) //--------------------------------------------------------------------------------------------------------------------- QPointF VEquidistant::SingleParallelPoint(const QLineF &line, const qreal &angle, const qreal &width) { - Q_ASSERT(width > 0); + SCASSERT(width > 0); QLineF pLine = line; pLine.setAngle( pLine.angle() + angle ); pLine.setLength( width ); diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index 17c1915bc..02b2fafa2 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -96,6 +96,7 @@ MainWindow::MainWindow(QWidget *parent) doc = new VPattern(pattern, &mode, sceneDraw, sceneDetails); connect(doc, &VPattern::ClearMainWindow, this, &MainWindow::Clear); + connect(doc, &VPattern::patternChanged, this, &MainWindow::PatternWasModified); connect(doc, &VPattern::UndoCommand, this, &MainWindow::FullParseFile); connect(qApp->getUndoStack(), &QUndoStack::cleanChanged, this, &MainWindow::PatternWasModified); @@ -1565,14 +1566,8 @@ void MainWindow::FullParseFile() #ifndef QT_NO_CURSOR QApplication::restoreOverrideCursor(); #endif - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Error parsing file.")); - msgBox.setInformativeText("std::bad_alloc"); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setIcon(QMessageBox::Warning); - msgBox.exec(); + QMessageBox::critical(this, tr("Critical error!"), tr("Error parsing file (std::bad_alloc)."), QMessageBox::Ok, + QMessageBox::Ok); #ifndef QT_NO_CURSOR QApplication::setOverrideCursor(Qt::WaitCursor); #endif diff --git a/src/app/share/resources/icon.qrc b/src/app/share/resources/icon.qrc index d0a47eba8..e127d2f36 100644 --- a/src/app/share/resources/icon.qrc +++ b/src/app/share/resources/icon.qrc @@ -8,14 +8,6 @@ icon/32x32/option_draw.png icon/32x32/table.png icon/24x24/putHere.png - icon/24x24/arrowDown.png - icon/24x24/arrowUp.png - icon/24x24/arrowRightUp.png - icon/24x24/arrowRightDown.png - icon/24x24/arrowRight.png - icon/24x24/arrowLeftUp.png - icon/24x24/arrowLeftDown.png - icon/24x24/arrowLeft.png icon/24x24/equal.png icon/32x32/segment.png icon/32x32/line.png @@ -26,7 +18,6 @@ icon/32x32/intersect.png icon/32x32/spline.png icon/32x32/arc.png - icon/24x24/putHereLeft.png icon/32x32/splinePath.png icon/32x32/history.png icon/32x32/put_after.png @@ -55,5 +46,14 @@ icon/flags/nl.png icon/flags/it.png icon/community_config.png + icon/32x32/arrowLeft.png + icon/32x32/arrowRight.png + icon/32x32/arrowRightDown.png + icon/32x32/arrowDown.png + icon/32x32/arrowRightUp.png + icon/32x32/arrowLeftDown.png + icon/32x32/arrowUp.png + icon/32x32/arrowLeftUp.png + icon/32x32/putHereLeft.png diff --git a/src/app/share/resources/icon/24x24/arrowDown.png b/src/app/share/resources/icon/24x24/arrowDown.png deleted file mode 100644 index 817af191d..000000000 Binary files a/src/app/share/resources/icon/24x24/arrowDown.png and /dev/null differ diff --git a/src/app/share/resources/icon/24x24/arrowLeft.png b/src/app/share/resources/icon/24x24/arrowLeft.png deleted file mode 100644 index 9be8ca1bb..000000000 Binary files a/src/app/share/resources/icon/24x24/arrowLeft.png and /dev/null differ diff --git a/src/app/share/resources/icon/24x24/arrowLeftDown.png b/src/app/share/resources/icon/24x24/arrowLeftDown.png deleted file mode 100644 index f77bdf696..000000000 Binary files a/src/app/share/resources/icon/24x24/arrowLeftDown.png and /dev/null differ diff --git a/src/app/share/resources/icon/24x24/arrowLeftUp.png b/src/app/share/resources/icon/24x24/arrowLeftUp.png deleted file mode 100644 index 5f4024ad0..000000000 Binary files a/src/app/share/resources/icon/24x24/arrowLeftUp.png and /dev/null differ diff --git a/src/app/share/resources/icon/24x24/arrowRight.png b/src/app/share/resources/icon/24x24/arrowRight.png deleted file mode 100644 index 768ebaf7d..000000000 Binary files a/src/app/share/resources/icon/24x24/arrowRight.png and /dev/null differ diff --git a/src/app/share/resources/icon/24x24/arrowRightDown.png b/src/app/share/resources/icon/24x24/arrowRightDown.png deleted file mode 100644 index 7e5a1095b..000000000 Binary files a/src/app/share/resources/icon/24x24/arrowRightDown.png and /dev/null differ diff --git a/src/app/share/resources/icon/24x24/arrowRightUp.png b/src/app/share/resources/icon/24x24/arrowRightUp.png deleted file mode 100644 index 4a17aede6..000000000 Binary files a/src/app/share/resources/icon/24x24/arrowRightUp.png and /dev/null differ diff --git a/src/app/share/resources/icon/24x24/arrowUp.png b/src/app/share/resources/icon/24x24/arrowUp.png deleted file mode 100644 index bca77c6d1..000000000 Binary files a/src/app/share/resources/icon/24x24/arrowUp.png and /dev/null differ diff --git a/src/app/share/resources/icon/24x24/equal.png b/src/app/share/resources/icon/24x24/equal.png index ff7ca4845..89a704c56 100644 Binary files a/src/app/share/resources/icon/24x24/equal.png and b/src/app/share/resources/icon/24x24/equal.png differ diff --git a/src/app/share/resources/icon/24x24/putHere.png b/src/app/share/resources/icon/24x24/putHere.png index 00e4d8f1d..fadcb6032 100644 Binary files a/src/app/share/resources/icon/24x24/putHere.png and b/src/app/share/resources/icon/24x24/putHere.png differ diff --git a/src/app/share/resources/icon/24x24/putHereLeft.png b/src/app/share/resources/icon/24x24/putHereLeft.png deleted file mode 100644 index a69736efd..000000000 Binary files a/src/app/share/resources/icon/24x24/putHereLeft.png and /dev/null differ diff --git a/src/app/share/resources/icon/32x32/arrowDown.png b/src/app/share/resources/icon/32x32/arrowDown.png new file mode 100644 index 000000000..199edf66d Binary files /dev/null and b/src/app/share/resources/icon/32x32/arrowDown.png differ diff --git a/src/app/share/resources/icon/32x32/arrowLeft.png b/src/app/share/resources/icon/32x32/arrowLeft.png new file mode 100644 index 000000000..6fe84b8d9 Binary files /dev/null and b/src/app/share/resources/icon/32x32/arrowLeft.png differ diff --git a/src/app/share/resources/icon/32x32/arrowLeftDown.png b/src/app/share/resources/icon/32x32/arrowLeftDown.png new file mode 100644 index 000000000..85ffeadce Binary files /dev/null and b/src/app/share/resources/icon/32x32/arrowLeftDown.png differ diff --git a/src/app/share/resources/icon/32x32/arrowLeftUp.png b/src/app/share/resources/icon/32x32/arrowLeftUp.png new file mode 100644 index 000000000..99070f5a0 Binary files /dev/null and b/src/app/share/resources/icon/32x32/arrowLeftUp.png differ diff --git a/src/app/share/resources/icon/32x32/arrowRight.png b/src/app/share/resources/icon/32x32/arrowRight.png new file mode 100644 index 000000000..113acb379 Binary files /dev/null and b/src/app/share/resources/icon/32x32/arrowRight.png differ diff --git a/src/app/share/resources/icon/32x32/arrowRightDown.png b/src/app/share/resources/icon/32x32/arrowRightDown.png new file mode 100644 index 000000000..cb48bc3bc Binary files /dev/null and b/src/app/share/resources/icon/32x32/arrowRightDown.png differ diff --git a/src/app/share/resources/icon/32x32/arrowRightUp.png b/src/app/share/resources/icon/32x32/arrowRightUp.png new file mode 100644 index 000000000..877920aa7 Binary files /dev/null and b/src/app/share/resources/icon/32x32/arrowRightUp.png differ diff --git a/src/app/share/resources/icon/32x32/arrowUp.png b/src/app/share/resources/icon/32x32/arrowUp.png new file mode 100644 index 000000000..91cbc25ec Binary files /dev/null and b/src/app/share/resources/icon/32x32/arrowUp.png differ diff --git a/src/app/share/resources/icon/32x32/putHereLeft.png b/src/app/share/resources/icon/32x32/putHereLeft.png new file mode 100644 index 000000000..396a819b1 Binary files /dev/null and b/src/app/share/resources/icon/32x32/putHereLeft.png differ diff --git a/src/app/share/resources/theme.qrc b/src/app/share/resources/theme.qrc index cd91162f3..efa266e2b 100644 --- a/src/app/share/resources/theme.qrc +++ b/src/app/share/resources/theme.qrc @@ -40,5 +40,8 @@ icons/win.icon.theme/24x24/actions/edit-redo.png icons/win.icon.theme/32x32/actions/edit-redo.png icons/win.icon.theme/32x32/actions/edit-undo.png + icons/win.icon.theme/16x16/actions/go-down.png + icons/win.icon.theme/24x24/actions/go-down.png + icons/win.icon.theme/32x32/actions/go-down.png diff --git a/src/app/tools/drawTools/vtoolcutsplinepath.cpp b/src/app/tools/drawTools/vtoolcutsplinepath.cpp index 1c862bf64..6f5906669 100644 --- a/src/app/tools/drawTools/vtoolcutsplinepath.cpp +++ b/src/app/tools/drawTools/vtoolcutsplinepath.cpp @@ -164,41 +164,51 @@ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QSt VSplinePath *splPath1 = new VSplinePath(); VSplinePath *splPath2 = new VSplinePath(); + + for (qint32 i = 0; i < splPath->CountPoint(); i++) + { + if (i <= p1 && i < p2) + { + if (i == p1) + { + splPath1->append(VSplinePoint(splP1.P(), splP1.KAsm1(), spl1.GetAngle1()+180, spl1.GetKasm1(), + spl1.GetAngle1())); + VSplinePoint cutPoint; + if (typeCreation == Source::FromGui) + { + cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl1.GetAngle2(), spl1.GetAngle2()+180, + spl1.GetAngle2()); + } + else + { + cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl1.GetAngle2(), spl2.GetKasm1(), + spl1.GetAngle2()+180); + } + splPath1->append(cutPoint); + continue; + } + splPath1->append(splPath->at(i)); + } + else + { + if (i == p2) + { + const VSplinePoint cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl2.GetAngle1()+180, + spl2.GetKasm1(), spl2.GetAngle1()); + splPath2->append(cutPoint); + splPath2->append(VSplinePoint(splP2.P(), spl2.GetKasm2(), spl2.GetAngle2(), splP2.KAsm2(), + spl2.GetAngle2()+180)); + continue; + } + splPath2->append(splPath->at(i)); + } + } + + splPath1->setMaxCountPoints(splPath->CountPoint()); + splPath2->setMaxCountPoints(splPath->CountPoint()); + if (typeCreation == Source::FromGui) { - for (qint32 i = 0; i < splPath->CountPoint(); i++) - { - if (i <= p1 && i < p2) - { - if (i == p1) - { - splPath1->append(VSplinePoint(splP1.P(), splP1.KAsm1(), spl1.GetAngle1()+180, spl1.GetKasm1(), - spl1.GetAngle1())); - const VSplinePoint cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl1.GetAngle2(), - spl1.GetAngle2()+180, spl1.GetAngle2()); - splPath1->append(cutPoint); - continue; - } - splPath1->append(splPath->at(i)); - } - else - { - if (i == p2) - { - const VSplinePoint cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl2.GetAngle1()+180, - spl2.GetKasm1(), spl2.GetAngle1()); - splPath2->append(cutPoint); - splPath2->append(VSplinePoint(splP2.P(), spl2.GetKasm2(), spl2.GetAngle2(), splP2.KAsm2(), - spl2.GetAngle2()+180)); - continue; - } - splPath2->append(splPath->at(i)); - } - } - - splPath1->setMaxCountPoints(splPath->CountPoint()); - splPath2->setMaxCountPoints(splPath->CountPoint()); - splPath1id = data->AddGObject(splPath1); data->AddLengthSpline(splPath1->name(), qApp->fromPixel(splPath1->GetLength())); @@ -207,39 +217,6 @@ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QSt } else { - for (qint32 i = 0; i < splPath->CountPoint(); i++) - { - if (i <= p1 && i < p2) - { - if (i == p1) - { - splPath1->append(VSplinePoint(splP1.P(), splP1.KAsm1(), spl1.GetAngle1()+180, spl1.GetKasm1(), - spl1.GetAngle1())); - const VSplinePoint cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl1.GetAngle2(), - spl2.GetKasm1(), spl1.GetAngle2()+180); - splPath1->append(cutPoint); - continue; - } - splPath1->append(splPath->at(i)); - } - else - { - if (i == p2) - { - const VSplinePoint cutPoint = VSplinePoint(*p, spl1.GetKasm2(), spl2.GetAngle1()+180, - spl2.GetKasm1(), spl2.GetAngle1()); - splPath2->append(cutPoint); - splPath2->append(VSplinePoint(splP2.P(), spl2.GetKasm2(), spl2.GetAngle2(), splP2.KAsm2(), - spl2.GetAngle2()+180)); - continue; - } - splPath2->append(splPath->at(i)); - } - } - - splPath1->setMaxCountPoints(splPath->CountPoint()); - splPath2->setMaxCountPoints(splPath->CountPoint()); - data->UpdateGObject(splPath1id, splPath1); data->AddLengthSpline(splPath1->name(), qApp->fromPixel(splPath1->GetLength())); @@ -251,6 +228,7 @@ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QSt doc->UpdateToolData(id, data); } } + VDrawTool::AddRecord(id, Tool::CutSplinePathTool, doc); if (parse == Document::FullParse) { diff --git a/src/app/tools/vtooldetail.cpp b/src/app/tools/vtooldetail.cpp index 733db56e3..d5e61c90f 100644 --- a/src/app/tools/vtooldetail.cpp +++ b/src/app/tools/vtooldetail.cpp @@ -92,27 +92,6 @@ VToolDetail::VToolDetail(VPattern *doc, VContainer *data, const quint32 &id, con case (Tool::NodeSplinePath): InitTool(scene, detail.at(i)); break; - case (Tool::ArrowTool): - case (Tool::SinglePointTool): - case (Tool::EndLineTool): - case (Tool::LineTool): - case (Tool::AlongLineTool): - case (Tool::ShoulderPointTool): - case (Tool::NormalTool): - case (Tool::BisectorTool): - case (Tool::LineIntersectTool): - case (Tool::SplineTool): - case (Tool::CutSplineTool): - case (Tool::CutArcTool): - case (Tool::ArcTool): - case (Tool::SplinePathTool): - case (Tool::CutSplinePathTool): - case (Tool::PointOfContact): - case (Tool::DetailTool): - case (Tool::Height): - case (Tool::Triangle): - case (Tool::PointOfIntersection): - case (Tool::UnionDetails): default: qDebug()<<"Get wrong tool type. Ignore."; break; @@ -198,27 +177,6 @@ void VToolDetail::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern VNodeSplinePath::Create(doc, data, id, detail.at(i).getId(), Document::FullParse, Source::FromGui); } break; - case (Tool::ArrowTool): - case (Tool::SinglePointTool): - case (Tool::EndLineTool): - case (Tool::LineTool): - case (Tool::AlongLineTool): - case (Tool::ShoulderPointTool): - case (Tool::NormalTool): - case (Tool::BisectorTool): - case (Tool::LineIntersectTool): - case (Tool::SplineTool): - case (Tool::CutSplineTool): - case (Tool::CutArcTool): - case (Tool::ArcTool): - case (Tool::SplinePathTool): - case (Tool::CutSplinePathTool): - case (Tool::PointOfContact): - case (Tool::DetailTool): - case (Tool::Height): - case (Tool::Triangle): - case (Tool::PointOfIntersection): - case (Tool::UnionDetails): default: qDebug()<<"May be wrong tool type!!! Ignoring."<SetAttribute(nod, AttrType, NodeSplinePath); break; - case (Tool::ArrowTool): - case (Tool::SinglePointTool): - case (Tool::EndLineTool): - case (Tool::LineTool): - case (Tool::AlongLineTool): - case (Tool::ShoulderPointTool): - case (Tool::NormalTool): - case (Tool::BisectorTool): - case (Tool::LineIntersectTool): - case (Tool::SplineTool): - case (Tool::CutSplineTool): - case (Tool::CutArcTool): - case (Tool::ArcTool): - case (Tool::SplinePathTool): - case (Tool::CutSplinePathTool): - case (Tool::PointOfContact): - case (Tool::DetailTool): - case (Tool::Height): - case (Tool::Triangle): - case (Tool::PointOfIntersection): - case (Tool::UnionDetails): default: qDebug()<<"May be wrong tool type!!! Ignoring."<SetAttribute(nod, AttrType, QStringLiteral("NodeSplinePath")); break; - case (Tool::ArrowTool): - case (Tool::SinglePointTool): - case (Tool::EndLineTool): - case (Tool::LineTool): - case (Tool::AlongLineTool): - case (Tool::ShoulderPointTool): - case (Tool::NormalTool): - case (Tool::BisectorTool): - case (Tool::LineIntersectTool): - case (Tool::SplineTool): - case (Tool::CutSplineTool): - case (Tool::CutArcTool): - case (Tool::ArcTool): - case (Tool::SplinePathTool): - case (Tool::CutSplinePathTool): - case (Tool::PointOfContact): - case (Tool::DetailTool): - case (Tool::Height): - case (Tool::Triangle): - case (Tool::PointOfIntersection): - case (Tool::UnionDetails): default: qDebug()<<"May be wrong tool type!!! Ignoring."< + ** @date 18 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "vabstractmeasurements.h" + +const QString VAbstractMeasurements::TagUnit = QStringLiteral("unit"); +const QString VAbstractMeasurements::AttrValue = QStringLiteral("value"); + +//--------------------------------------------------------------------------------------------------------------------- +VAbstractMeasurements::VAbstractMeasurements(VContainer *data) + :VDomDocument(data) +{ + SCASSERT(data != nullptr) +} + +//--------------------------------------------------------------------------------------------------------------------- +VAbstractMeasurements::~VAbstractMeasurements() +{} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Measurements help read all measurements. + * + * Virtual method that keep all common measurements name. Measurements height and size create in different way in + * individual and standard measurements, see VIndividualMeasurements::Measurements(). + */ +void VAbstractMeasurements::Measurements() +{ + //head and neck + Measurement(headGirth_M); + Measurement(midNeckGirth_M); + Measurement(neckBaseGirth_M); + Measurement(headAndNeckLength_M); + //torso + Measurement(centerFrontWaistLength_M); + Measurement(centerBackWaistLength_M); + Measurement(shoulderLength_M); + Measurement(sideWaistLength_M); + Measurement(trunkLength_M); + Measurement(shoulderGirth_M); + Measurement(upperChestGirth_M); + Measurement(bustGirth_M); + Measurement(underBustGirth_M); + Measurement(waistGirth_M); + Measurement(highHipGirth_M); + Measurement(hipGirth_M); + Measurement(upperFrontChestWidth_M); + Measurement(frontChestWidth_M); + Measurement(acrossFrontShoulderWidth_M); + Measurement(acrossBackShoulderWidth_M); + Measurement(upperBackWidth_M); + Measurement(backWidth_M); + Measurement(bustpointToBustpoint_M); + Measurement(halterBustpointToBustpoint_M); + Measurement(neckToBustpoint_M); + Measurement(crotchLength_M); + Measurement(riseHeight_M); + Measurement(shoulderDrop_M); + Measurement(shoulderSlopeDegrees_M); + Measurement(frontShoulderSlopeLength_M); + Measurement(backShoulderSlopeLength_M); + Measurement(frontShoulderToWaistLength_M); + Measurement(backShoulderToWaistLength_M); + Measurement(frontNeckArc_M); + Measurement(backNeckArc_M); + Measurement(frontUpperChestArc_M); + Measurement(backUpperChestArc_M); + Measurement(frontWaistArc_M); + Measurement(backWaistArc_M); + Measurement(frontUpperHipArc_M); + Measurement(backUpperHipArc_M); + Measurement(frontHipArc_M); + Measurement(backHipArc_M); + Measurement(chestSlope_M); + Measurement(backSlope_M); + Measurement(frontWaistSlope_M); + Measurement(backWaistSlope_M); + Measurement(frontNeckToUpperChestHeight_M); + Measurement(frontNeckToBustHeight_M); + //arm + Measurement(armscyeGirth_M); + Measurement(elbowGirth_M); + Measurement(upperArmGirth_M); + Measurement(wristGirth_M); + Measurement(scyeDepth_M); + Measurement(shoulderAndArmLength_M); + Measurement(underarmLength_M); + Measurement(cervicaleToWristLength_M); + Measurement(shoulderToElbowLength_M); + Measurement(armLength_M); + //hand + Measurement(handWidth_M); + Measurement(handLength_M); + Measurement(handGirth_M); + //leg + Measurement(thighGirth_M); + Measurement(midThighGirth_M); + Measurement(kneeGirth_M); + Measurement(calfGirth_M); + Measurement(ankleGirth_M); + Measurement(kneeHeight_M); + Measurement(ankleHeight_M); + //foot + Measurement(footWidth_M); + Measurement(footLength_M); + //heights + Measurement(cervicaleHeight_M); + Measurement(cervicaleToKneeHeight_M); + Measurement(waistHeight_M); + Measurement(highHipHeight_M); + Measurement(hipHeight_M); + Measurement(waistToHipHeight_M); + Measurement(waistToKneeHeight_M); + Measurement(crotchHeight_M); + //extended + Measurement(heightFrontNeckBasePoint_M); + Measurement(heightBaseNeckSidePoint_M); + Measurement(heightShoulderPoint_M); + Measurement(heightNipplePoint_M); + Measurement(heightBackAngleAxilla_M); + Measurement(heightScapularPoint_M); + Measurement(heightUnderButtockFolds_M); + Measurement(hipsExcludingProtrudingAbdomen_M); + Measurement(girthFootInstep_M); + Measurement(sideWaistToFloor_M); + Measurement(frontWaistToFloor_M); + Measurement(arcThroughGroinArea_M); + Measurement(waistToPlaneSeat_M); + Measurement(neckToRadialPoint_M); + Measurement(neckToThirdFinger_M); + Measurement(neckToFirstLineChestCircumference_M); + Measurement(frontWaistLength_M); + Measurement(arcThroughShoulderJoint_M); + Measurement(neckToBackLineChestCircumference_M); + Measurement(waistToNeckSide_M); + Measurement(arcLengthUpperBody_M); + Measurement(chestWidth_M); + Measurement(anteroposteriorDiameterHands_M); + Measurement(heightClavicularPoint_M); + Measurement(heightArmholeSlash_M); + Measurement(slashShoulderHeight_M); + Measurement(halfGirthNeck_M); + Measurement(halfGirthNeckForShirts_M); + Measurement(halfGirthChestFirst_M); + Measurement(halfGirthChestSecond_M); + Measurement(halfGirthChestThird_M); + Measurement(halfGirthWaist_M); + Measurement(halfGirthHipsConsideringProtrudingAbdomen_M); + Measurement(halfGirthHipsExcludingProtrudingAbdomen_M); + Measurement(girthKneeFlexedFeet_M); + Measurement(neckTransverseDiameter_M); + Measurement(frontSlashShoulderHeight_M); + Measurement(neckToFrontWaistLine_M); + Measurement(handVerticalDiameter_M); + Measurement(neckToKneePoint_M); + Measurement(waistToKnee_M); + Measurement(shoulderHeight_M); + Measurement(headHeight_M); + Measurement(bodyPosition_M); + Measurement(arcBehindShoulderGirdle_M); + Measurement(neckToNeckBase_M); + Measurement(depthWaistFirst_M); + Measurement(depthWaistSecond_M); +} + +//--------------------------------------------------------------------------------------------------------------------- +Unit VAbstractMeasurements::MUnit() const +{ + const QString unit = UniqueTagText(TagUnit, UnitCM); + return VDomDocument::StrToUnits(unit); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractMeasurements::Measurement(const QString &tag) +{ + const QDomNodeList nodeList = this->elementsByTagName(tag); + if (nodeList.isEmpty()) + { + qDebug()<<"Measurement" << tag <<"doesn't exist"< + ** @date 18 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef VABSTRACTMEASUREMENTS_H +#define VABSTRACTMEASUREMENTS_H + +#include "vdomdocument.h" + +class VAbstractMeasurements : public VDomDocument +{ +public: + VAbstractMeasurements(VContainer *data); + virtual ~VAbstractMeasurements(); + virtual void Measurements(); + Unit MUnit() const; + static const QString TagUnit; + static const QString AttrValue; +protected: + void Measurement(const QString &tag); + virtual void ReadMeasurement(const QDomElement &domElement, const QString &tag) = 0; +private: + Q_DISABLE_COPY(VAbstractMeasurements) +}; + +#endif // VABSTRACTMEASUREMENTS_H diff --git a/src/app/xml/vindividualmeasurements.cpp b/src/app/xml/vindividualmeasurements.cpp index 0acefe104..bafbc4f88 100644 --- a/src/app/xml/vindividualmeasurements.cpp +++ b/src/app/xml/vindividualmeasurements.cpp @@ -30,31 +30,25 @@ #include "../widgets/vapplication.h" #include -const QString VIndividualMeasurements::AttrValue = QStringLiteral("value"); const QString VIndividualMeasurements::TagFamily_name = QStringLiteral("family-name"); const QString VIndividualMeasurements::TagGiven_name = QStringLiteral("given-name"); const QString VIndividualMeasurements::TagBirth_date = QStringLiteral("birth-date"); const QString VIndividualMeasurements::TagSex = QStringLiteral("sex"); -const QString VIndividualMeasurements::TagUnit = QStringLiteral("unit"); const QString VIndividualMeasurements::TagEmail = QStringLiteral("email"); const QString VIndividualMeasurements::SexMale = QStringLiteral("male"); const QString VIndividualMeasurements::SexFemale = QStringLiteral("female"); //--------------------------------------------------------------------------------------------------------------------- -VIndividualMeasurements::VIndividualMeasurements(VContainer *data):VDomDocument(data) -{} +VIndividualMeasurements::VIndividualMeasurements(VContainer *data) + :VAbstractMeasurements(data) +{ + SCASSERT(data != nullptr) +} //--------------------------------------------------------------------------------------------------------------------- VIndividualMeasurements::~VIndividualMeasurements() {} -//--------------------------------------------------------------------------------------------------------------------- -Unit VIndividualMeasurements::MUnit() const -{ - const QString unit = UniqueTagText(TagUnit, UnitCM); - return VDomDocument::StrToUnits(unit); -} - //--------------------------------------------------------------------------------------------------------------------- void VIndividualMeasurements::setUnit(const Unit &unit) { @@ -64,172 +58,23 @@ void VIndividualMeasurements::setUnit(const Unit &unit) //--------------------------------------------------------------------------------------------------------------------- void VIndividualMeasurements::Measurements() { - //head and neck - Measurement(headGirth_M); - Measurement(midNeckGirth_M); - Measurement(neckBaseGirth_M); - Measurement(headAndNeckLength_M); - //torso - Measurement(centerFrontWaistLength_M); - Measurement(centerBackWaistLength_M); - Measurement(shoulderLength_M); - Measurement(sideWaistLength_M); - Measurement(trunkLength_M); - Measurement(shoulderGirth_M); - Measurement(upperChestGirth_M); - Measurement(bustGirth_M); - Measurement(underBustGirth_M); - Measurement(waistGirth_M); - Measurement(highHipGirth_M); - Measurement(hipGirth_M); - Measurement(upperFrontChestWidth_M); - Measurement(frontChestWidth_M); - Measurement(acrossFrontShoulderWidth_M); - Measurement(acrossBackShoulderWidth_M); - Measurement(upperBackWidth_M); - Measurement(backWidth_M); - Measurement(bustpointToBustpoint_M); - Measurement(halterBustpointToBustpoint_M); - Measurement(neckToBustpoint_M); - Measurement(crotchLength_M); - Measurement(riseHeight_M); - Measurement(shoulderDrop_M); - Measurement(shoulderSlopeDegrees_M); - Measurement(frontShoulderSlopeLength_M); - Measurement(backShoulderSlopeLength_M); - Measurement(frontShoulderToWaistLength_M); - Measurement(backShoulderToWaistLength_M); - Measurement(frontNeckArc_M); - Measurement(backNeckArc_M); - Measurement(frontUpperChestArc_M); - Measurement(backUpperChestArc_M); - Measurement(frontWaistArc_M); - Measurement(backWaistArc_M); - Measurement(frontUpperHipArc_M); - Measurement(backUpperHipArc_M); - Measurement(frontHipArc_M); - Measurement(backHipArc_M); - Measurement(chestSlope_M); - Measurement(backSlope_M); - Measurement(frontWaistSlope_M); - Measurement(backWaistSlope_M); - Measurement(frontNeckToUpperChestHeight_M); - Measurement(frontNeckToBustHeight_M); - //arm - Measurement(armscyeGirth_M); - Measurement(elbowGirth_M); - Measurement(upperArmGirth_M); - Measurement(wristGirth_M); - Measurement(scyeDepth_M); - Measurement(shoulderAndArmLength_M); - Measurement(underarmLength_M); - Measurement(cervicaleToWristLength_M); - Measurement(shoulderToElbowLength_M); - Measurement(armLength_M); - //hand - Measurement(handWidth_M); - Measurement(handLength_M); - Measurement(handGirth_M); - //leg - Measurement(thighGirth_M); - Measurement(midThighGirth_M); - Measurement(kneeGirth_M); - Measurement(calfGirth_M); - Measurement(ankleGirth_M); - Measurement(kneeHeight_M); - Measurement(ankleHeight_M); - //foot - Measurement(footWidth_M); - Measurement(footLength_M); + VAbstractMeasurements::Measurements(); //heights Measurement(height_M); - Measurement(cervicaleHeight_M); - Measurement(cervicaleToKneeHeight_M); - Measurement(waistHeight_M); - Measurement(highHipHeight_M); - Measurement(hipHeight_M); - Measurement(waistToHipHeight_M); - Measurement(waistToKneeHeight_M); - Measurement(crotchHeight_M); //extended Measurement(size_M); - Measurement(heightFrontNeckBasePoint_M); - Measurement(heightBaseNeckSidePoint_M); - Measurement(heightShoulderPoint_M); - Measurement(heightNipplePoint_M); - Measurement(heightBackAngleAxilla_M); - Measurement(heightScapularPoint_M); - Measurement(heightUnderButtockFolds_M); - Measurement(hipsExcludingProtrudingAbdomen_M); - Measurement(girthFootInstep_M); - Measurement(sideWaistToFloor_M); - Measurement(frontWaistToFloor_M); - Measurement(arcThroughGroinArea_M); - Measurement(waistToPlaneSeat_M); - Measurement(neckToRadialPoint_M); - Measurement(neckToThirdFinger_M); - Measurement(neckToFirstLineChestCircumference_M); - Measurement(frontWaistLength_M); - Measurement(arcThroughShoulderJoint_M); - Measurement(neckToBackLineChestCircumference_M); - Measurement(waistToNeckSide_M); - Measurement(arcLengthUpperBody_M); - Measurement(chestWidth_M); - Measurement(anteroposteriorDiameterHands_M); - Measurement(heightClavicularPoint_M); - Measurement(heightArmholeSlash_M); - Measurement(slashShoulderHeight_M); - Measurement(halfGirthNeck_M); - Measurement(halfGirthNeckForShirts_M); - Measurement(halfGirthChestFirst_M); - Measurement(halfGirthChestSecond_M); - Measurement(halfGirthChestThird_M); - Measurement(halfGirthWaist_M); - Measurement(halfGirthHipsConsideringProtrudingAbdomen_M); - Measurement(halfGirthHipsExcludingProtrudingAbdomen_M); - Measurement(girthKneeFlexedFeet_M); - Measurement(neckTransverseDiameter_M); - Measurement(frontSlashShoulderHeight_M); - Measurement(neckToFrontWaistLine_M); - Measurement(handVerticalDiameter_M); - Measurement(neckToKneePoint_M); - Measurement(waistToKnee_M); - Measurement(shoulderHeight_M); - Measurement(headHeight_M); - Measurement(bodyPosition_M); - Measurement(arcBehindShoulderGirdle_M); - Measurement(neckToNeckBase_M); - Measurement(depthWaistFirst_M); - Measurement(depthWaistSecond_M); } //--------------------------------------------------------------------------------------------------------------------- -void VIndividualMeasurements::Measurement(const QString &tag) +void VIndividualMeasurements::ReadMeasurement(const QDomElement &domElement, const QString &tag) { - const QDomNodeList nodeList = this->elementsByTagName(tag); - if (nodeList.isEmpty()) - { - qDebug()<<"Measurement" << tag <<"doesn't exist"<AddMeasurement(tag, VMeasurement(value, qApp->GuiText(tag), qApp->Description(tag), tag)); - } - } + if (MUnit() == Unit::Mm)//Convert to Cm. + { + value = value / 10.0; } + data->AddMeasurement(tag, VMeasurement(value, qApp->GuiText(tag), qApp->Description(tag), tag)); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/xml/vindividualmeasurements.h b/src/app/xml/vindividualmeasurements.h index ced9a7b43..e117360ef 100644 --- a/src/app/xml/vindividualmeasurements.h +++ b/src/app/xml/vindividualmeasurements.h @@ -29,7 +29,7 @@ #ifndef VINDIVIDUALMEASUREMENTS_H #define VINDIVIDUALMEASUREMENTS_H -#include "vdomdocument.h" +#include "vabstractmeasurements.h" /* VIT_VERSION is (major << 16) + (minor << 8) + patch. @@ -41,39 +41,38 @@ enum class SexType : char { Male, Female }; -class VIndividualMeasurements:public VDomDocument +class VIndividualMeasurements:public VAbstractMeasurements { public: VIndividualMeasurements(VContainer *data); virtual ~VIndividualMeasurements(); - Unit MUnit() const; - void setUnit(const Unit &unit); - void Measurements(); - QString FamilyName() const; - void setFamilyName(const QString &text); - QString GivenName() const; - void setGivenName(const QString &text); - QDate BirthDate() const; - void setBirthDate(const QDate &date); - SexType Sex() const; - void setSex(const SexType &sex); - QString Mail() const; - void setMail(const QString &text); - static const QString AttrValue; + void setUnit(const Unit &unit); + virtual void Measurements(); + QString FamilyName() const; + void setFamilyName(const QString &text); + QString GivenName() const; + void setGivenName(const QString &text); + QDate BirthDate() const; + void setBirthDate(const QDate &date); + SexType Sex() const; + void setSex(const SexType &sex); + QString Mail() const; + void setMail(const QString &text); + static const QString TagFamily_name; static const QString TagGiven_name; static const QString TagBirth_date; static const QString TagSex; - static const QString TagUnit; static const QString TagEmail; static const QString SexMale; static const QString SexFemale; static QString GenderToStr(const SexType &sex); static SexType StrToGender(const QString &sex); +protected: + virtual void ReadMeasurement(const QDomElement &domElement, const QString &tag); private: Q_DISABLE_COPY(VIndividualMeasurements) - void Measurement(const QString &tag); }; #endif // VINDIVIDUALMEASUREMENTS_H diff --git a/src/app/xml/vpattern.cpp b/src/app/xml/vpattern.cpp index 353d09fda..fb697fbd2 100644 --- a/src/app/xml/vpattern.cpp +++ b/src/app/xml/vpattern.cpp @@ -214,7 +214,7 @@ bool VPattern::SetNameDraw(const QString &name) { nameActivDraw = name; element.setAttribute(AttrName, nameActivDraw); - emit patternChanged(); + emit patternChanged(false); emit ChangedNameDraw(oldName, nameActivDraw); return true; } @@ -558,7 +558,7 @@ void VPattern::SetPath(const QString &path) if (element.isElement()) { SetAttribute(element, AttrPath, path); - emit patternChanged(); + emit patternChanged(false); } else { @@ -687,14 +687,8 @@ void VPattern::LiteParseTree() #ifndef QT_NO_CURSOR QApplication::restoreOverrideCursor(); #endif - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Error parsing file.")); - msgBox.setInformativeText("std::bad_alloc"); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setIcon(QMessageBox::Warning); - msgBox.exec(); + QMessageBox::critical(nullptr, tr("Critical error!"), tr("Error parsing file (std::bad_alloc)."), QMessageBox::Ok, + QMessageBox::Ok); #ifndef QT_NO_CURSOR QApplication::setOverrideCursor(Qt::WaitCursor); #endif @@ -712,7 +706,7 @@ void VPattern::LiteParseTree() */ void VPattern::haveLiteChange() { - emit patternChanged(); + emit patternChanged(false); } //--------------------------------------------------------------------------------------------------------------------- @@ -942,6 +936,29 @@ void VPattern::ParseDetails(VMainGraphicsScene *sceneDetail, const QDomElement & } } +//--------------------------------------------------------------------------------------------------------------------- +void VPattern::PointsCommonAttributes(const QDomElement &domElement, quint32 &id, QString &name, qreal &mx, qreal &my, + QString &typeLine) +{ + PointsCommonAttributes(domElement, id, name, mx, my); + typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPattern::PointsCommonAttributes(const QDomElement &domElement, quint32 &id, QString &name, qreal &mx, qreal &my) +{ + PointsCommonAttributes(domElement, id, mx, my); + name = GetParametrString(domElement, VAbstractTool::AttrName, "A"); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPattern::PointsCommonAttributes(const QDomElement &domElement, quint32 &id, qreal &mx, qreal &my) +{ + ToolsCommonAttributes(domElement, id); + mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); + my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief ParsePointElement parse point tag. @@ -957,6 +974,11 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of point is empty"); + quint32 id = 0; + QString name; + qreal mx = 0; + qreal my = 0; + QString typeLine; QStringList points{VToolSinglePoint::ToolType, VToolEndLine::ToolType, VToolAlongLine::ToolType, VToolShoulderPoint::ToolType, VToolNormal::ToolType, VToolBisector::ToolType, @@ -970,12 +992,9 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem VToolSinglePoint *spoint = 0; try { - const quint32 id = GetParametrId(domElement); - const QString name = GetParametrString(domElement, VAbstractTool::AttrName, "A"); + PointsCommonAttributes(domElement, id, name, mx, my); const qreal x = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrX, "10.0")); const qreal y = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrY, "10.0")); - const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); - const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); data->UpdateGObject(id, new VPointF(x, y, name, mx, my)); VDrawTool::AddRecord(id, Tool::SinglePointTool, this); @@ -1005,12 +1024,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem case 1: //VToolEndLine::ToolType try { - const quint32 id = GetParametrId(domElement); - const QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); - const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); - const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); - const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, - VAbstractTool::TypeLineLine); + PointsCommonAttributes(domElement, id, name, mx, my, typeLine); const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0"); QString f = formula;//need for saving fixed formula; @@ -1035,21 +1049,14 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating point of end line"), domElement); - QString message("Message: " + e.GetMsg() + "\n"+ - "Expression: " + e.GetExpr()); - excep.AddMoreInformation(message); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); throw excep; } break; case 2: //VToolAlongLine::ToolType try { - const quint32 id = GetParametrId(domElement); - const QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); - const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); - const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); - const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, - VAbstractTool::TypeLineLine); + PointsCommonAttributes(domElement, id, name, mx, my, typeLine); const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0"); QString f = formula;//need for saving fixed formula; const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); @@ -1073,21 +1080,14 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating point along line"), domElement); - QString message("Message: " + e.GetMsg() + "\n"+ - "Expression: " + e.GetExpr()); - excep.AddMoreInformation(message); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); throw excep; } break; case 3: //VToolShoulderPoint::ToolType try { - const quint32 id = GetParametrId(domElement); - const QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); - const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); - const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); - const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, - VAbstractTool::TypeLineLine); + PointsCommonAttributes(domElement, id, name, mx, my, typeLine); const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0"); QString f = formula;//need for saving fixed formula; const quint32 p1Line = GetParametrUInt(domElement, VAbstractTool::AttrP1Line, "0"); @@ -1112,21 +1112,14 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating point of shoulder"), domElement); - QString message("Message: " + e.GetMsg() + "\n"+ - "Expression: " + e.GetExpr()); - excep.AddMoreInformation(message); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); throw excep; } break; case 4: //VToolNormal::ToolType try { - const quint32 id = GetParametrId(domElement); - const QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); - const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); - const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); - const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, - VAbstractTool::TypeLineLine); + PointsCommonAttributes(domElement, id, name, mx, my, typeLine); const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0"); QString f = formula;//need for saving fixed formula; const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); @@ -1151,21 +1144,14 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating point of normal"), domElement); - QString message("Message: " + e.GetMsg() + "\n"+ - "Expression: " + e.GetExpr()); - excep.AddMoreInformation(message); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); throw excep; } break; case 5: //VToolBisector::ToolType try { - const quint32 id = GetParametrId(domElement); - const QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); - const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); - const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); - const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, - VAbstractTool::TypeLineLine); + PointsCommonAttributes(domElement, id, name, mx, my, typeLine); const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0"); QString f = formula;//need for saving fixed formula; const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); @@ -1190,19 +1176,14 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating point of bisector"), domElement); - QString message("Message: " + e.GetMsg() + "\n"+ - "Expression: " + e.GetExpr()); - excep.AddMoreInformation(message); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); throw excep; } break; case 6: //VToolLineIntersect::ToolType try { - const quint32 id = GetParametrId(domElement); - const QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); - const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); - const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); + PointsCommonAttributes(domElement, id, name, mx, my); const quint32 p1Line1Id = GetParametrUInt(domElement, VAbstractTool::AttrP1Line1, "0"); const quint32 p2Line1Id = GetParametrUInt(domElement, VAbstractTool::AttrP2Line1, "0"); const quint32 p1Line2Id = GetParametrUInt(domElement, VAbstractTool::AttrP1Line2, "0"); @@ -1221,10 +1202,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem case 7: //VToolPointOfContact::ToolType try { - const quint32 id = GetParametrId(domElement); - const QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); - const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); - const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); + PointsCommonAttributes(domElement, id, name, mx, my); const QString radius = GetParametrString(domElement, VAbstractTool::AttrRadius, "0"); QString f = radius;//need for saving fixed formula; const quint32 center = GetParametrUInt(domElement, VAbstractTool::AttrCenter, "0"); @@ -1249,21 +1227,17 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating point of contact"), domElement); - QString message("Message: " + e.GetMsg() + "\n"+ - "Expression: " + e.GetExpr()); - excep.AddMoreInformation(message); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); throw excep; } break; case 8: //VNodePoint::ToolType try { - const quint32 id = GetParametrId(domElement); + PointsCommonAttributes(domElement, id, mx, my); const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, "0"); const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, "0"); const VPointF *point = data->GeometricObject(idObject ); - const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); - const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); data->UpdateGObject(id, new VPointF(point->x(), point->y(), point->name(), mx, my, idObject, Draw::Modeling)); VNodePoint::Create(this, data, id, idObject, parse, Source::FromFile, idTool); @@ -1278,12 +1252,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem case 9: //VToolHeight::ToolType try { - const quint32 id = GetParametrId(domElement); - const QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); - const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); - const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); - const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, - VAbstractTool::TypeLineLine); + PointsCommonAttributes(domElement, id, name, mx, my, typeLine); const quint32 basePointId = GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, "0"); const quint32 p1LineId = GetParametrUInt(domElement, VAbstractTool::AttrP1Line, "0"); const quint32 p2LineId = GetParametrUInt(domElement, VAbstractTool::AttrP2Line, "0"); @@ -1301,10 +1270,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem case 10: //VToolTriangle::ToolType try { - const quint32 id = GetParametrId(domElement); - const QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); - const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); - const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); + PointsCommonAttributes(domElement, id, name, mx, my); const quint32 axisP1Id = GetParametrUInt(domElement, VAbstractTool::AttrAxisP1, "0"); const quint32 axisP2Id = GetParametrUInt(domElement, VAbstractTool::AttrAxisP2, "0"); const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); @@ -1323,10 +1289,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem case 11: //VToolPointOfIntersection::ToolType try { - const quint32 id = GetParametrId(domElement); - const QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); - const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); - const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); + PointsCommonAttributes(domElement, id, name, mx, my); const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); @@ -1343,10 +1306,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem case 12: //VToolCutSpline::ToolType try { - const quint32 id = GetParametrId(domElement); - const QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); - const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); - const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); + PointsCommonAttributes(domElement, id, name, mx, my); const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0"); QString f = formula;//need for saving fixed formula; const quint32 splineId = GetParametrUInt(domElement, VToolCutSpline::AttrSpline, "0"); @@ -1368,19 +1328,14 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating cut spline point"), domElement); - QString message("Message: " + e.GetMsg() + "\n"+ - "Expression: " + e.GetExpr()); - excep.AddMoreInformation(message); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); throw excep; } break; case 13: //VToolCutSplinePath::ToolType try { - const quint32 id = GetParametrId(domElement); - const QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); - const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); - const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); + PointsCommonAttributes(domElement, id, name, mx, my); const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0"); QString f = formula;//need for saving fixed formula; const quint32 splinePathId = GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath, "0"); @@ -1403,19 +1358,14 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating cut spline path point"), domElement); - QString message("Message: " + e.GetMsg() + "\n"+ - "Expression: " + e.GetExpr()); - excep.AddMoreInformation(message); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); throw excep; } break; case 14: //VToolCutArc::ToolType try { - const quint32 id = GetParametrId(domElement); - const QString name = GetParametrString(domElement, VAbstractTool::AttrName, ""); - const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); - const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); + PointsCommonAttributes(domElement, id, name, mx, my); const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0"); QString f = formula;//need for saving fixed formula; const quint32 arcId = GetParametrUInt(domElement, VToolCutArc::AttrArc, "0"); @@ -1437,9 +1387,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating cut arc point"), domElement); - QString message("Message: " + e.GetMsg() + "\n"+ - "Expression: " + e.GetExpr()); - excep.AddMoreInformation(message); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); throw excep; } break; @@ -1461,9 +1409,10 @@ void VPattern::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &do { SCASSERT(scene != nullptr); Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); + quint32 id = 0; try { - const quint32 id = GetParametrId(domElement); + ToolsCommonAttributes(domElement, id); const quint32 firstPoint = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); const quint32 secondPoint = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, @@ -1479,6 +1428,14 @@ void VPattern::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &do } } +//--------------------------------------------------------------------------------------------------------------------- +void VPattern::SplinesCommonAttributes(const QDomElement &domElement, quint32 &id, quint32 &idObject, quint32 &idTool) +{ + ToolsCommonAttributes(domElement, id); + idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, "0"); + idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, "0"); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief ParseSplineElement parse spline tag. @@ -1494,6 +1451,10 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement & Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty"); + quint32 id = 0; + quint32 idObject = 0; + quint32 idTool = 0; + QStringList splines{VToolSpline::ToolType, VToolSplinePath::ToolType, VNodeSpline::ToolType, VNodeSplinePath::ToolType}; switch (splines.indexOf(type)) @@ -1501,7 +1462,7 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement & case 0: //VToolSpline::ToolType try { - const quint32 id = GetParametrId(domElement); + ToolsCommonAttributes(domElement, id); const quint32 point1 = GetParametrUInt(domElement, VAbstractTool::AttrPoint1, "0"); const quint32 point4 = GetParametrUInt(domElement, VAbstractTool::AttrPoint4, "0"); const qreal angle1 = GetParametrDouble(domElement, VAbstractTool::AttrAngle1, "270.0"); @@ -1523,7 +1484,7 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement & case 1: //VToolSplinePath::ToolType try { - const quint32 id = GetParametrId(domElement); + ToolsCommonAttributes(domElement, id); const qreal kCurve = GetParametrDouble(domElement, VAbstractTool::AttrKCurve, "1.0"); VSplinePath *path = new VSplinePath(kCurve); @@ -1567,9 +1528,7 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement & case 2: //VNodeSpline::ToolType try { - const quint32 id = GetParametrId(domElement); - const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, "0"); - const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, "0"); + SplinesCommonAttributes(domElement, id, idObject, idTool); VSpline *spl = new VSpline(*data->GeometricObject(idObject)); spl->setIdObject(idObject); spl->setMode(Draw::Modeling); @@ -1586,9 +1545,7 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement & case 3: //VNodeSplinePath::ToolType try { - const quint32 id = GetParametrId(domElement); - const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, "0"); - const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, "0"); + SplinesCommonAttributes(domElement, id, idObject, idTool); VSplinePath *path = new VSplinePath(*data->GeometricObject(idObject)); path->setIdObject(idObject); path->setMode(Draw::Modeling); @@ -1623,6 +1580,7 @@ void VPattern::ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElemen Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty"); + quint32 id = 0; QStringList arcs{VToolArc::ToolType, VNodeArc::ToolType}; switch (arcs.indexOf(type)) @@ -1630,7 +1588,7 @@ void VPattern::ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElemen case 0: //VToolArc::ToolType try { - const quint32 id = GetParametrId(domElement); + ToolsCommonAttributes(domElement, id); const quint32 center = GetParametrUInt(domElement, VAbstractTool::AttrCenter, "0"); const QString radius = GetParametrString(domElement, VAbstractTool::AttrRadius, "10"); QString r = radius;//need for saving fixed formula; @@ -1658,16 +1616,14 @@ void VPattern::ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElemen catch (qmu::QmuParserError &e) { VExceptionObjectError excep(tr("Error creating or updating simple arc"), domElement); - QString message("Message: " + e.GetMsg() + "\n"+ - "Expression: " + e.GetExpr()); - excep.AddMoreInformation(message); + excep.AddMoreInformation(QString("Message: " + e.GetMsg() + "\n"+ "Expression: " + e.GetExpr())); throw excep; } break; case 1: //VNodeArc::ToolType try { - const quint32 id = GetParametrId(domElement); + ToolsCommonAttributes(domElement, id); const quint32 idObject = GetParametrUInt(domElement, VAbstractNode::AttrIdObject, "0"); const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, "0"); VArc *arc = new VArc(*data->GeometricObject(idObject)); @@ -1704,6 +1660,7 @@ void VPattern::ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &d Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); Q_ASSERT_X(type.isEmpty() == false, Q_FUNC_INFO, "type of spline is empty"); + quint32 id = 0; QStringList tools{VToolUnionDetails::ToolType}; switch (tools.indexOf(type)) @@ -1711,7 +1668,7 @@ void VPattern::ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &d case 0: //VToolUnionDetails::ToolType try { - const quint32 id = GetParametrId(domElement); + ToolsCommonAttributes(domElement, id); const quint32 indexD1 = GetParametrUInt(domElement, VToolUnionDetails::AttrIndexD1, "-1"); const quint32 indexD2 = GetParametrUInt(domElement, VToolUnionDetails::AttrIndexD2, "-1"); @@ -1889,6 +1846,12 @@ void VPattern::GarbageCollector() } } +//--------------------------------------------------------------------------------------------------------------------- +void VPattern::ToolsCommonAttributes(const QDomElement &domElement, quint32 &id) +{ + id = GetParametrId(domElement); +} + //--------------------------------------------------------------------------------------------------------------------- QDomElement VPattern::GetPPElement(const QString &name) { diff --git a/src/app/xml/vpattern.h b/src/app/xml/vpattern.h index 5e8fda878..753c9cdb5 100644 --- a/src/app/xml/vpattern.h +++ b/src/app/xml/vpattern.h @@ -130,7 +130,7 @@ signals: /** * @brief patternChanged emit if we have unsaved change. */ - void patternChanged(); + void patternChanged(bool saved); /** * @brief ShowTool highlight tool. * @param id tool id. @@ -199,6 +199,14 @@ private: void PrepareForParse(const Document &parse); void UpdateMeasurements(); void GarbageCollector(); + void ToolsCommonAttributes(const QDomElement &domElement, quint32 &id); + void PointsCommonAttributes(const QDomElement &domElement, quint32 &id, QString &name, qreal &mx, + qreal &my, QString &typeLine); + void PointsCommonAttributes(const QDomElement &domElement, quint32 &id, QString &name, qreal &mx, + qreal &my); + void PointsCommonAttributes(const QDomElement &domElement, quint32 &id, qreal &mx, qreal &my); + void SplinesCommonAttributes(const QDomElement &domElement, quint32 &id, quint32 &idObject, + quint32 &idTool); }; //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/xml/vstandardmeasurements.cpp b/src/app/xml/vstandardmeasurements.cpp index 82f10b09e..1c99fc8a1 100644 --- a/src/app/xml/vstandardmeasurements.cpp +++ b/src/app/xml/vstandardmeasurements.cpp @@ -33,25 +33,20 @@ const QString VStandardMeasurements::TagDescription = QStringLiteral("description"); const QString VStandardMeasurements::TagSize = QStringLiteral("size"); const QString VStandardMeasurements::TagHeight = QStringLiteral("height"); -const QString VStandardMeasurements::AttrValue = QStringLiteral("value"); const QString VStandardMeasurements::AttrSize_increase = QStringLiteral("size_increase"); const QString VStandardMeasurements::AttrHeight_increase = QStringLiteral("height_increase"); //--------------------------------------------------------------------------------------------------------------------- -VStandardMeasurements::VStandardMeasurements(VContainer *data):VDomDocument(data) -{} +VStandardMeasurements::VStandardMeasurements(VContainer *data) + :VAbstractMeasurements(data) +{ + SCASSERT(data != nullptr) +} //--------------------------------------------------------------------------------------------------------------------- VStandardMeasurements::~VStandardMeasurements() {} -//--------------------------------------------------------------------------------------------------------------------- -Unit VStandardMeasurements::MUnit() -{ - const QString unit = UniqueTagText(AttrUnit, UnitCM); - return VDomDocument::StrToUnits(unit); -} - //--------------------------------------------------------------------------------------------------------------------- QString VStandardMeasurements::Description() { @@ -64,178 +59,21 @@ QString VStandardMeasurements::Description() } //--------------------------------------------------------------------------------------------------------------------- -void VStandardMeasurements::Measurements() +void VStandardMeasurements::ReadMeasurement(const QDomElement &domElement, const QString &tag) { - //head and neck - Measurement(headGirth_M); - Measurement(midNeckGirth_M); - Measurement(neckBaseGirth_M); - Measurement(headAndNeckLength_M); - //torso - Measurement(centerFrontWaistLength_M); - Measurement(centerBackWaistLength_M); - Measurement(shoulderLength_M); - Measurement(sideWaistLength_M); - Measurement(trunkLength_M); - Measurement(shoulderGirth_M); - Measurement(upperChestGirth_M); - Measurement(bustGirth_M); - Measurement(underBustGirth_M); - Measurement(waistGirth_M); - Measurement(highHipGirth_M); - Measurement(hipGirth_M); - Measurement(upperFrontChestWidth_M); - Measurement(frontChestWidth_M); - Measurement(acrossFrontShoulderWidth_M); - Measurement(acrossBackShoulderWidth_M); - Measurement(upperBackWidth_M); - Measurement(backWidth_M); - Measurement(bustpointToBustpoint_M); - Measurement(halterBustpointToBustpoint_M); - Measurement(neckToBustpoint_M); - Measurement(crotchLength_M); - Measurement(riseHeight_M); - Measurement(shoulderDrop_M); - Measurement(shoulderSlopeDegrees_M); - Measurement(frontShoulderSlopeLength_M); - Measurement(backShoulderSlopeLength_M); - Measurement(frontShoulderToWaistLength_M); - Measurement(backShoulderToWaistLength_M); - Measurement(frontNeckArc_M); - Measurement(backNeckArc_M); - Measurement(frontUpperChestArc_M); - Measurement(backUpperChestArc_M); - Measurement(frontWaistArc_M); - Measurement(backWaistArc_M); - Measurement(frontUpperHipArc_M); - Measurement(backUpperHipArc_M); - Measurement(frontHipArc_M); - Measurement(backHipArc_M); - Measurement(chestSlope_M); - Measurement(backSlope_M); - Measurement(frontWaistSlope_M); - Measurement(backWaistSlope_M); - Measurement(frontNeckToUpperChestHeight_M); - Measurement(frontNeckToBustHeight_M); - //arm - Measurement(armscyeGirth_M); - Measurement(elbowGirth_M); - Measurement(upperArmGirth_M); - Measurement(wristGirth_M); - Measurement(scyeDepth_M); - Measurement(shoulderAndArmLength_M); - Measurement(underarmLength_M); - Measurement(cervicaleToWristLength_M); - Measurement(shoulderToElbowLength_M); - Measurement(armLength_M); - //hand - Measurement(handWidth_M); - Measurement(handLength_M); - Measurement(handGirth_M); - //leg - Measurement(thighGirth_M); - Measurement(midThighGirth_M); - Measurement(kneeGirth_M); - Measurement(calfGirth_M); - Measurement(ankleGirth_M); - Measurement(kneeHeight_M); - Measurement(ankleHeight_M); - //foot - Measurement(footWidth_M); - Measurement(footLength_M); - //heights - Measurement(cervicaleHeight_M); - Measurement(cervicaleToKneeHeight_M); - Measurement(waistHeight_M); - Measurement(highHipHeight_M); - Measurement(hipHeight_M); - Measurement(waistToHipHeight_M); - Measurement(waistToKneeHeight_M); - Measurement(crotchHeight_M); - //extended - Measurement(heightFrontNeckBasePoint_M); - Measurement(heightBaseNeckSidePoint_M); - Measurement(heightShoulderPoint_M); - Measurement(heightNipplePoint_M); - Measurement(heightBackAngleAxilla_M); - Measurement(heightScapularPoint_M); - Measurement(heightUnderButtockFolds_M); - Measurement(hipsExcludingProtrudingAbdomen_M); - Measurement(girthFootInstep_M); - Measurement(sideWaistToFloor_M); - Measurement(frontWaistToFloor_M); - Measurement(arcThroughGroinArea_M); - Measurement(waistToPlaneSeat_M); - Measurement(neckToRadialPoint_M); - Measurement(neckToThirdFinger_M); - Measurement(neckToFirstLineChestCircumference_M); - Measurement(frontWaistLength_M); - Measurement(arcThroughShoulderJoint_M); - Measurement(neckToBackLineChestCircumference_M); - Measurement(waistToNeckSide_M); - Measurement(arcLengthUpperBody_M); - Measurement(chestWidth_M); - Measurement(anteroposteriorDiameterHands_M); - Measurement(heightClavicularPoint_M); - Measurement(heightArmholeSlash_M); - Measurement(slashShoulderHeight_M); - Measurement(halfGirthNeck_M); - Measurement(halfGirthNeckForShirts_M); - Measurement(halfGirthChestFirst_M); - Measurement(halfGirthChestSecond_M); - Measurement(halfGirthChestThird_M); - Measurement(halfGirthWaist_M); - Measurement(halfGirthHipsConsideringProtrudingAbdomen_M); - Measurement(halfGirthHipsExcludingProtrudingAbdomen_M); - Measurement(girthKneeFlexedFeet_M); - Measurement(neckTransverseDiameter_M); - Measurement(frontSlashShoulderHeight_M); - Measurement(neckToFrontWaistLine_M); - Measurement(handVerticalDiameter_M); - Measurement(neckToKneePoint_M); - Measurement(waistToKnee_M); - Measurement(shoulderHeight_M); - Measurement(headHeight_M); - Measurement(bodyPosition_M); - Measurement(arcBehindShoulderGirdle_M); - Measurement(neckToNeckBase_M); - Measurement(depthWaistFirst_M); - Measurement(depthWaistSecond_M); -} + const qreal value = GetParametrDouble(domElement, AttrValue, "0.0"); + const qreal size_increase = GetParametrDouble(domElement, AttrSize_increase, "0.0"); + const qreal height_increase = GetParametrDouble(domElement, AttrHeight_increase, "0.0"); -//--------------------------------------------------------------------------------------------------------------------- -void VStandardMeasurements::Measurement(const QString &tag) -{ - const QDomNodeList nodeList = this->elementsByTagName(tag); - if (nodeList.isEmpty()) + if (MUnit() == Unit::Mm)// Convert to Cm. { - qDebug()<<"Measurement" << tag <<"doesn't exist"<AddMeasurement(tag, VMeasurement(value/10.0, size_increase/10.0, height_increase/10.0, + qApp->GuiText(tag), qApp->Description(tag), tag)); } - else + else// Cm or inch. { - const QDomNode domNode = nodeList.at(0); - if (domNode.isNull() == false && domNode.isElement()) - { - const QDomElement domElement = domNode.toElement(); - if (domElement.isNull() == false) - { - const qreal value = GetParametrDouble(domElement, AttrValue, "0.0"); - const qreal size_increase = GetParametrDouble(domElement, AttrSize_increase, "0.0"); - const qreal height_increase = GetParametrDouble(domElement, AttrHeight_increase, "0.0"); - - if (MUnit() == Unit::Mm)// Convert to Cm. - { - data->AddMeasurement(tag, VMeasurement(value/10.0, size_increase/10.0, height_increase/10.0, - qApp->GuiText(tag), qApp->Description(tag), tag)); - } - else// Cm or inch. - { - data->AddMeasurement(tag, VMeasurement(value, size_increase, height_increase, qApp->GuiText(tag), - qApp->Description(tag), tag)); - } - } - } + data->AddMeasurement(tag, VMeasurement(value, size_increase, height_increase, qApp->GuiText(tag), + qApp->Description(tag), tag)); } } diff --git a/src/app/xml/vstandardmeasurements.h b/src/app/xml/vstandardmeasurements.h index 92b50a430..c9d0ee1de 100644 --- a/src/app/xml/vstandardmeasurements.h +++ b/src/app/xml/vstandardmeasurements.h @@ -29,7 +29,7 @@ #ifndef VSTANDARDMEASUREMENTS_H #define VSTANDARDMEASUREMENTS_H -#include "vdomdocument.h" +#include "vabstractmeasurements.h" /* VST_VERSION is (major << 16) + (minor << 8) + patch. @@ -39,26 +39,24 @@ // max support version of format #define VST_VERSION 0x000100 -class VStandardMeasurements:public VDomDocument +class VStandardMeasurements:public VAbstractMeasurements { public: VStandardMeasurements(VContainer *data); virtual ~VStandardMeasurements(); - Unit MUnit(); - QString Description(); - void Measurements(); - void SetSize(); - void SetHeight(); + QString Description(); + void SetSize(); + void SetHeight(); static const QString TagMeasurement; static const QString TagDescription; static const QString TagSize; static const QString TagHeight; - static const QString AttrValue; static const QString AttrSize_increase; static const QString AttrHeight_increase; +protected: + virtual void ReadMeasurement(const QDomElement &domElement, const QString &tag); private: Q_DISABLE_COPY(VStandardMeasurements) - void Measurement(const QString &tag); }; #endif // VSTANDARDMEASUREMENTS_H diff --git a/src/app/xml/xml.pri b/src/app/xml/xml.pri index d9b56eea9..90ca2739c 100644 --- a/src/app/xml/xml.pri +++ b/src/app/xml/xml.pri @@ -3,11 +3,13 @@ HEADERS += \ xml/vdomdocument.h \ xml/vpattern.h \ xml/vstandardmeasurements.h \ - xml/vindividualmeasurements.h + xml/vindividualmeasurements.h \ + xml/vabstractmeasurements.h SOURCES += \ xml/vtoolrecord.cpp \ xml/vdomdocument.cpp \ xml/vpattern.cpp \ xml/vstandardmeasurements.cpp \ - xml/vindividualmeasurements.cpp + xml/vindividualmeasurements.cpp \ + xml/vabstractmeasurements.cpp diff --git a/src/libs/qmuparser/qmuparser.pro b/src/libs/qmuparser/qmuparser.pro index 4a46c8b68..eab501172 100644 --- a/src/libs/qmuparser/qmuparser.pro +++ b/src/libs/qmuparser/qmuparser.pro @@ -80,7 +80,7 @@ CONFIG(debug, debug|release){ -Wformat=2 -Wimport \ -Winvalid-pch -Wunsafe-loop-optimizations -Wlong-long -Wmissing-format-attribute \ -Wmissing-include-dirs -Wpacked -Wredundant-decls -Winline \ - -Wswitch-default -Wswitch-enum -Wuninitialized -Wvariadic-macros \ + -Wswitch-default -Wuninitialized -Wvariadic-macros \ -Wlogical-op -Wnoexcept -Wmissing-noreturn -Wpointer-arith\ -Wstrict-null-sentinel -Wstrict-overflow=5 -Wundef -Wno-unused -gdwarf-3 \ -ftrapv diff --git a/src/libs/qmuparser/qmuparserbase.cpp b/src/libs/qmuparser/qmuparserbase.cpp index b6941a2b4..3bf001f68 100644 --- a/src/libs/qmuparser/qmuparserbase.cpp +++ b/src/libs/qmuparser/qmuparserbase.cpp @@ -335,40 +335,6 @@ void QmuParserBase::CheckOprt(const QString &a_sName, const QmuParserCallback &a case cmOPRT_INFIX: Error(ecINVALID_INFIX_IDENT, -1, a_sName); break; - case cmLE: - case cmGE: - case cmNEQ: - case cmEQ: - case cmLT: - case cmGT: - case cmADD: - case cmSUB: - case cmMUL: - case cmDIV: - case cmPOW: - case cmLAND: - case cmLOR: - case cmASSIGN: - case cmBO: - case cmBC: - case cmIF: - case cmELSE: - case cmENDIF: - case cmARG_SEP: - case cmVAR: - case cmVAL: - case cmVARPOW2: - case cmVARPOW3: - case cmVARPOW4: - case cmVARMUL: - case cmPOW2: - case cmFUNC: - case cmFUNC_STR: - case cmFUNC_BULK: - case cmSTRING: - case cmOPRT_BIN: - case cmEND: - case cmUNKNOWN: default: Error(ecINVALID_NAME, -1, a_sName); break; @@ -629,22 +595,6 @@ int QmuParserBase::GetOprtPrecedence(const token_type &a_Tok) const case cmOPRT_INFIX: case cmOPRT_BIN: return a_Tok.GetPri(); - case cmBO: - case cmBC: - case cmENDIF: - case cmVAR: - case cmVAL: - case cmVARPOW2: - case cmVARPOW3: - case cmVARPOW4: - case cmVARMUL: - case cmPOW2: - case cmFUNC: - case cmFUNC_STR: - case cmFUNC_BULK: - case cmSTRING: - case cmOPRT_POSTFIX: - case cmUNKNOWN: default: Error(ecINTERNAL_ERROR, 5); return 999; @@ -678,27 +628,6 @@ EOprtAssociativity QmuParserBase::GetOprtAssociativity(const token_type &a_Tok) return oaRIGHT; case cmOPRT_BIN: return a_Tok.GetAssociativity(); - case cmBO: - case cmBC: - case cmIF: - case cmELSE: - case cmENDIF: - case cmARG_SEP: - case cmVAR: - case cmVAL: - case cmVARPOW2: - case cmVARPOW3: - case cmVARPOW4: - case cmVARMUL: - case cmPOW2: - case cmFUNC: - case cmFUNC_STR: - case cmFUNC_BULK: - case cmSTRING: - case cmOPRT_POSTFIX: - case cmOPRT_INFIX: - case cmEND: - case cmUNKNOWN: default: return oaNONE; } @@ -875,96 +804,6 @@ void QmuParserBase::ApplyFunc( QStack &a_stOpt, QStack & m_vRPN.AddFun(funTok.GetFuncAddr(), (funTok.GetArgCount()==-1) ? -iArgNumerical : iArgNumerical); break; - case cmLE: - Q_UNREACHABLE(); - break; - case cmGE: - Q_UNREACHABLE(); - break; - case cmNEQ: - Q_UNREACHABLE(); - break; - case cmEQ: - Q_UNREACHABLE(); - break; - case cmLT: - Q_UNREACHABLE(); - break; - case cmGT: - Q_UNREACHABLE(); - break; - case cmADD: - Q_UNREACHABLE(); - break; - case cmSUB: - Q_UNREACHABLE(); - break; - case cmMUL: - Q_UNREACHABLE(); - break; - case cmDIV: - Q_UNREACHABLE(); - break; - case cmPOW: - Q_UNREACHABLE(); - break; - case cmLAND: - Q_UNREACHABLE(); - break; - case cmLOR: - Q_UNREACHABLE(); - break; - case cmASSIGN: - Q_UNREACHABLE(); - break; - case cmBO: - Q_UNREACHABLE(); - break; - case cmBC: - Q_UNREACHABLE(); - break; - case cmIF: - Q_UNREACHABLE(); - break; - case cmELSE: - Q_UNREACHABLE(); - break; - case cmENDIF: - Q_UNREACHABLE(); - break; - case cmARG_SEP: - Q_UNREACHABLE(); - break; - case cmVAR: - Q_UNREACHABLE(); - break; - case cmVAL: - Q_UNREACHABLE(); - break; - case cmVARPOW2: - Q_UNREACHABLE(); - break; - case cmVARPOW3: - Q_UNREACHABLE(); - break; - case cmVARPOW4: - Q_UNREACHABLE(); - break; - case cmVARMUL: - Q_UNREACHABLE(); - break; - case cmPOW2: - Q_UNREACHABLE(); - break; - case cmSTRING: - Q_UNREACHABLE(); - break; - case cmEND: - Q_UNREACHABLE(); - break; - case cmUNKNOWN: - Q_UNREACHABLE(); - break; default: break; } @@ -1056,58 +895,26 @@ void QmuParserBase::ApplyRemainingOprt(QStack &stOpt, QStack= cmLE && code <= cmASSIGN) || code == cmOPRT_INFIX || code == cmOPRT_BIN) { - case cmOPRT_INFIX: - case cmOPRT_BIN: - case cmLE: - case cmGE: - case cmNEQ: - case cmEQ: - case cmLT: - case cmGT: - case cmADD: - case cmSUB: - case cmMUL: - case cmDIV: - case cmPOW: - case cmLAND: - case cmLOR: - case cmASSIGN: - if (stOpt.top().GetCode()==cmOPRT_INFIX) - { - ApplyFunc(stOpt, stVal, 1); - } - else - { - ApplyBinOprt(stOpt, stVal); - } - break; - case cmELSE: - ApplyIfElse(stOpt, stVal); - break; - case cmBO: - case cmBC: - case cmIF: - case cmENDIF: - case cmARG_SEP: - case cmVAR: - case cmVAL: - case cmVARPOW2: - case cmVARPOW3: - case cmVARPOW4: - case cmVARMUL: - case cmPOW2: - case cmFUNC: - case cmFUNC_STR: - case cmFUNC_BULK: - case cmSTRING: - case cmOPRT_POSTFIX: - case cmEND: - case cmUNKNOWN: - default: - Error(ecINTERNAL_ERROR); - break; + if (stOpt.top().GetCode()==cmOPRT_INFIX) + { + ApplyFunc(stOpt, stVal, 1); + } + else + { + ApplyBinOprt(stOpt, stVal); + } + } + else if (code == cmELSE) + { + ApplyIfElse(stOpt, stVal); + } + else + { + Error(ecINTERNAL_ERROR); } } } @@ -1574,19 +1381,19 @@ void QmuParserBase::CreateRPN() const case cmIF: m_nIfElseCounter++; // fallthrough intentional (no break!) - case cmLAND: - case cmLOR: - case cmLT: - case cmGT: case cmLE: case cmGE: case cmNEQ: case cmEQ: + case cmLT: + case cmGT: case cmADD: case cmSUB: case cmMUL: case cmDIV: case cmPOW: + case cmLAND: + case cmLOR: case cmASSIGN: case cmOPRT_BIN: // A binary operator (user defined or built in) has been found. @@ -1982,28 +1789,6 @@ void QmuParserBase::StackDump(const QStack &a_stVal, const QStack= cmLE && i <= cmASSIGN) { - //case cmAND: - //case cmOR: - //case cmXOR: - case cmLAND: - case cmLOR: - case cmLT: - case cmGT: - case cmLE: - case cmGE: - case cmNEQ: - case cmEQ: - case cmADD: - case cmSUB: - case cmMUL: - case cmDIV: - case cmPOW: - case cmASSIGN: - //if (len!=sTok.length()) - // continue; + //if (len!=sTok.length()) + // continue; - // The assignement operator need special treatment - if ( i == cmASSIGN && m_iSynFlags & noASSIGN ) + // The assignement operator need special treatment + if ( i == cmASSIGN && m_iSynFlags & noASSIGN ) + { + Error ( ecUNEXPECTED_OPERATOR, m_iPos, pOprtDef.at ( i ) ); + } + + if ( m_pParser->HasBuiltInOprt() == false) + { + continue; + } + if ( m_iSynFlags & noOPT ) + { + // Maybe its an infix operator not an operator + // Both operator types can share characters in + // their identifiers + if ( IsInfixOpTok ( a_Tok ) ) { - Error ( ecUNEXPECTED_OPERATOR, m_iPos, pOprtDef.at ( i ) ); + return true; } - if ( m_pParser->HasBuiltInOprt() == false) - { - continue; - } - if ( m_iSynFlags & noOPT ) - { - // Maybe its an infix operator not an operator - // Both operator types can share characters in - // their identifiers - if ( IsInfixOpTok ( a_Tok ) ) - { - return true; - } + Error ( ecUNEXPECTED_OPERATOR, m_iPos, pOprtDef.at ( i ) ); + } - Error ( ecUNEXPECTED_OPERATOR, m_iPos, pOprtDef.at ( i ) ); - } + m_iSynFlags = noBC | noOPT | noARG_SEP | noPOSTOP | noASSIGN | noIF | noELSE; + m_iSynFlags |= ( ( i != cmEND ) && ( i != cmBC ) ) ? noEND : 0; + } + else if (i == cmBO) + { + if ( m_iSynFlags & noBO ) + { + Error ( ecUNEXPECTED_PARENS, m_iPos, pOprtDef.at ( i ) ); + } - m_iSynFlags = noBC | noOPT | noARG_SEP | noPOSTOP | noASSIGN | noIF | noELSE; - m_iSynFlags |= ( ( i != cmEND ) && ( i != cmBC ) ) ? noEND : 0; - break; + if ( m_lastTok.GetCode() == cmFUNC ) + { + m_iSynFlags = noOPT | noEND | noARG_SEP | noPOSTOP | noASSIGN | noIF | noELSE; + } + else + { + m_iSynFlags = noBC | noOPT | noEND | noARG_SEP | noPOSTOP | noASSIGN | noIF | noELSE; + } - case cmBO: - if ( m_iSynFlags & noBO ) - { - Error ( ecUNEXPECTED_PARENS, m_iPos, pOprtDef.at ( i ) ); - } + ++m_iBrackets; + } + else if (i == cmBC) + { + if ( m_iSynFlags & noBC ) + { + Error ( ecUNEXPECTED_PARENS, m_iPos, pOprtDef.at ( i ) ); + } - if ( m_lastTok.GetCode() == cmFUNC ) - { - m_iSynFlags = noOPT | noEND | noARG_SEP | noPOSTOP | noASSIGN | noIF | noELSE; - } - else - { - m_iSynFlags = noBC | noOPT | noEND | noARG_SEP | noPOSTOP | noASSIGN | noIF | noELSE; - } + m_iSynFlags = noBO | noVAR | noVAL | noFUN | noINFIXOP | noSTR | noASSIGN; - ++m_iBrackets; - break; + if ( --m_iBrackets < 0 ) + { + Error ( ecUNEXPECTED_PARENS, m_iPos, pOprtDef.at ( i ) ); + } + } + else if (i == cmELSE) + { + if ( m_iSynFlags & noELSE ) + { + Error ( ecUNEXPECTED_CONDITIONAL, m_iPos, pOprtDef.at ( i ) ); + } - case cmBC: - if ( m_iSynFlags & noBC ) - { - Error ( ecUNEXPECTED_PARENS, m_iPos, pOprtDef.at ( i ) ); - } + m_iSynFlags = noBC | noPOSTOP | noEND | noOPT | noIF | noELSE; + } + else if (i == cmIF) + { + if ( m_iSynFlags & noIF ) + { + Error ( ecUNEXPECTED_CONDITIONAL, m_iPos, pOprtDef.at ( i ) ); + } - m_iSynFlags = noBO | noVAR | noVAL | noFUN | noINFIXOP | noSTR | noASSIGN; - - if ( --m_iBrackets < 0 ) - { - Error ( ecUNEXPECTED_PARENS, m_iPos, pOprtDef.at ( i ) ); - } - break; - - case cmELSE: - if ( m_iSynFlags & noELSE ) - { - Error ( ecUNEXPECTED_CONDITIONAL, m_iPos, pOprtDef.at ( i ) ); - } - - m_iSynFlags = noBC | noPOSTOP | noEND | noOPT | noIF | noELSE; - break; - - case cmIF: - if ( m_iSynFlags & noIF ) - { - Error ( ecUNEXPECTED_CONDITIONAL, m_iPos, pOprtDef.at ( i ) ); - } - - m_iSynFlags = noBC | noPOSTOP | noEND | noOPT | noIF | noELSE; - break; - - default: // The operator is listed in c_DefaultOprt, but not here. This is a bad thing... - Error ( ecINTERNAL_ERROR ); - } // switch operator id + m_iSynFlags = noBC | noPOSTOP | noEND | noOPT | noIF | noELSE; + } + else // The operator is listed in c_DefaultOprt, but not here. This is a bad thing... + { + Error ( ecINTERNAL_ERROR ); + } m_iPos += len; a_Tok.Set ( static_cast(i), pOprtDef.at ( i ) );