From e82f65fc6a83ccd64adcff1623e7c787ac183e1e Mon Sep 17 00:00:00 2001 From: BojanKverh Date: Sun, 23 Oct 2016 20:59:38 +0200 Subject: [PATCH 1/6] Fixed the grainline tab icon in details dialog --HG-- branch : feature --- src/app/valentina/xml/vpattern.cpp | 16 ++++++++++++---- src/libs/vtools/dialogs/tools/dialogdetail.cpp | 12 ++++++++++-- src/libs/vtools/dialogs/tools/dialogdetail.h | 1 + src/libs/vtools/tools/vtooldetail.cpp | 3 +++ .../vtools/undocommands/savedetailoptions.cpp | 7 +++++-- 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index c6186ca16..02840d407 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -726,10 +726,18 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document ptPos.setX(GetParametrDouble(element, AttrMx, "0")); ptPos.setY(GetParametrDouble(element, AttrMy, "0")); detail.GetGrainlineGeometry().SetPos(ptPos); - QString qsLength = GetParametrString(element, AttrLength, "0"); - detail.GetGrainlineGeometry().SetLength(qsLength); - QString qsRot = GetParametrString(element, VToolDetail::AttrRotation, "0"); - detail.GetGrainlineGeometry().SetRotation(qsRot); + if (detail.GetGrainlineGeometry().IsVisible() == true) + { + QString qsLength = GetParametrString(element, AttrLength); + detail.GetGrainlineGeometry().SetLength(qsLength); + QString qsRot = GetParametrString(element, VToolDetail::AttrRotation); + detail.GetGrainlineGeometry().SetRotation(qsRot); + } + else + { + detail.GetGrainlineGeometry().SetLength(""); + detail.GetGrainlineGeometry().SetRotation(""); + } } } } diff --git a/src/libs/vtools/dialogs/tools/dialogdetail.cpp b/src/libs/vtools/dialogs/tools/dialogdetail.cpp index e82f2e704..1049cc744 100644 --- a/src/libs/vtools/dialogs/tools/dialogdetail.cpp +++ b/src/libs/vtools/dialogs/tools/dialogdetail.cpp @@ -903,8 +903,7 @@ void DialogDetail::UpdateValues() } else { - QIcon icon; - ui.tabWidget->setTabIcon(2, icon); + ResetWarning(); } } @@ -974,6 +973,7 @@ void DialogDetail::EnableGrainlineRotation() ChangeColor(ui.labelEditLen, okColor); ChangeColor(ui.labelEditRot, okColor); bOk->setEnabled(true); + ResetWarning(); } } @@ -1024,3 +1024,11 @@ void DialogDetail::DeployLength() } //--------------------------------------------------------------------------------------------------------------------- +void DialogDetail::ResetWarning() +{ + QIcon icon; + ui.tabWidget->setTabIcon(2, icon); +} + +//--------------------------------------------------------------------------------------------------------------------- + diff --git a/src/libs/vtools/dialogs/tools/dialogdetail.h b/src/libs/vtools/dialogs/tools/dialogdetail.h index c40cb37a6..cecc051d7 100644 --- a/src/libs/vtools/dialogs/tools/dialogdetail.h +++ b/src/libs/vtools/dialogs/tools/dialogdetail.h @@ -135,6 +135,7 @@ private slots: void EditFormula(); void DeployRotation(); void DeployLength(); + void ResetWarning(); }; //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/vtooldetail.cpp b/src/libs/vtools/tools/vtooldetail.cpp index 7694f92cf..81a2be130 100644 --- a/src/libs/vtools/tools/vtooldetail.cpp +++ b/src/libs/vtools/tools/vtooldetail.cpp @@ -502,6 +502,7 @@ void VToolDetail::AddToFile() doc->SetAttribute(domData, AttrMy, glGeom.GetPos().y()); doc->SetAttribute(domData, AttrLength, glGeom.GetLength()); doc->SetAttribute(domData, AttrRotation, glGeom.GetRotation()); + qDebug() << "XML ROTATION" << glGeom.GetRotation(); // nodes for (int i = 0; i < detail.CountNode(); ++i) @@ -580,6 +581,7 @@ void VToolDetail::RefreshDataInFile() doc->SetAttribute(domData, AttrMy, glGeom.GetPos().y()); doc->SetAttribute(domData, AttrLength, glGeom.GetLength()); doc->SetAttribute(domData, AttrRotation, glGeom.GetRotation()); + qDebug() << "XML ROTATION2" << glGeom.GetRotation(); // nodes for (int i = 0; i < det.CountNode(); ++i) @@ -926,6 +928,7 @@ void VToolDetail::UpdateGrainline() QString qsFormula; qsFormula = geom.GetRotation().replace("\n", " "); qsFormula = qApp->TrVars()->FormulaFromUser(qsFormula, qApp->Settings()->GetOsSeparator()); + Calculator cal1; dRotation = cal1.EvalFormula(VDataTool::data.PlainVariables(), qsFormula); diff --git a/src/libs/vtools/undocommands/savedetailoptions.cpp b/src/libs/vtools/undocommands/savedetailoptions.cpp index 5cc0c525d..5cdf5d57a 100644 --- a/src/libs/vtools/undocommands/savedetailoptions.cpp +++ b/src/libs/vtools/undocommands/savedetailoptions.cpp @@ -208,8 +208,11 @@ void SaveDetailOptions::SaveGrainline(QDomElement &domElement, const VDetail &de doc->SetAttribute(domData, VAbstractPattern::AttrVisible, glGeom.IsVisible() == true? trueStr : falseStr); doc->SetAttribute(domData, AttrMx, glGeom.GetPos().x()); doc->SetAttribute(domData, AttrMy, glGeom.GetPos().y()); - doc->SetAttribute(domData, AttrLength, glGeom.GetLength()); - doc->SetAttribute(domData, VToolDetail::AttrRotation, glGeom.GetRotation()); + if (glGeom.IsVisible() == true) + { + doc->SetAttribute(domData, AttrLength, glGeom.GetLength()); + doc->SetAttribute(domData, VToolDetail::AttrRotation, glGeom.GetRotation()); + } domElement.appendChild(domData); } From 5862264a1ddf313560cdf23cf60e40309832fb87 Mon Sep 17 00:00:00 2001 From: BojanKverh Date: Sun, 23 Oct 2016 21:24:16 +0200 Subject: [PATCH 2/6] Fixed saving grainline formulas when grainline is set to not visible --HG-- branch : feature --- src/app/valentina/xml/vpattern.cpp | 13 ++++++++++--- src/libs/vtools/undocommands/savedetailoptions.cpp | 7 ++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 02840d407..4a681cee7 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -726,16 +726,23 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document ptPos.setX(GetParametrDouble(element, AttrMx, "0")); ptPos.setY(GetParametrDouble(element, AttrMy, "0")); detail.GetGrainlineGeometry().SetPos(ptPos); - if (detail.GetGrainlineGeometry().IsVisible() == true) + try { QString qsLength = GetParametrString(element, AttrLength); detail.GetGrainlineGeometry().SetLength(qsLength); + } + catch (...) + { + detail.GetGrainlineGeometry().SetLength(""); + } + + try + { QString qsRot = GetParametrString(element, VToolDetail::AttrRotation); detail.GetGrainlineGeometry().SetRotation(qsRot); } - else + catch(...) { - detail.GetGrainlineGeometry().SetLength(""); detail.GetGrainlineGeometry().SetRotation(""); } } diff --git a/src/libs/vtools/undocommands/savedetailoptions.cpp b/src/libs/vtools/undocommands/savedetailoptions.cpp index 5cdf5d57a..5cc0c525d 100644 --- a/src/libs/vtools/undocommands/savedetailoptions.cpp +++ b/src/libs/vtools/undocommands/savedetailoptions.cpp @@ -208,11 +208,8 @@ void SaveDetailOptions::SaveGrainline(QDomElement &domElement, const VDetail &de doc->SetAttribute(domData, VAbstractPattern::AttrVisible, glGeom.IsVisible() == true? trueStr : falseStr); doc->SetAttribute(domData, AttrMx, glGeom.GetPos().x()); doc->SetAttribute(domData, AttrMy, glGeom.GetPos().y()); - if (glGeom.IsVisible() == true) - { - doc->SetAttribute(domData, AttrLength, glGeom.GetLength()); - doc->SetAttribute(domData, VToolDetail::AttrRotation, glGeom.GetRotation()); - } + doc->SetAttribute(domData, AttrLength, glGeom.GetLength()); + doc->SetAttribute(domData, VToolDetail::AttrRotation, glGeom.GetRotation()); domElement.appendChild(domData); } From 1f67e327c4f97c4a8a23515dc320a45f28475e51 Mon Sep 17 00:00:00 2001 From: BojanKverh Date: Sun, 23 Oct 2016 21:45:11 +0200 Subject: [PATCH 3/6] Fixed exception catching when reading grainline formulas --HG-- branch : feature --- src/app/valentina/xml/vpattern.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 4a681cee7..f3d662117 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -731,8 +731,9 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document QString qsLength = GetParametrString(element, AttrLength); detail.GetGrainlineGeometry().SetLength(qsLength); } - catch (...) + catch (VExceptionEmptyParameter eep) { + Q_UNUSED(eep); detail.GetGrainlineGeometry().SetLength(""); } @@ -741,8 +742,9 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document QString qsRot = GetParametrString(element, VToolDetail::AttrRotation); detail.GetGrainlineGeometry().SetRotation(qsRot); } - catch(...) + catch(VExceptionEmptyParameter eep) { + Q_UNUSED(eep); detail.GetGrainlineGeometry().SetRotation(""); } } From ddb040901b6ef63b4aa1bfec6e80f8bcb0aeb4ea Mon Sep 17 00:00:00 2001 From: BojanKverh Date: Sun, 23 Oct 2016 21:51:22 +0200 Subject: [PATCH 4/6] Fixed default values for grainline formulas --HG-- branch : feature --- src/app/valentina/xml/vpattern.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index f3d662117..682114bd6 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -734,7 +734,7 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document catch (VExceptionEmptyParameter eep) { Q_UNUSED(eep); - detail.GetGrainlineGeometry().SetLength(""); + detail.GetGrainlineGeometry().SetLength("0"); } try @@ -745,7 +745,7 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document catch(VExceptionEmptyParameter eep) { Q_UNUSED(eep); - detail.GetGrainlineGeometry().SetRotation(""); + detail.GetGrainlineGeometry().SetRotation("90"); } } } From 22d2f2275e368da8b038b15d1ecb08e60f3ac0d7 Mon Sep 17 00:00:00 2001 From: BojanKverh Date: Sun, 23 Oct 2016 21:57:55 +0200 Subject: [PATCH 5/6] Fixed exception catching when reading grainline formulas --HG-- branch : feature --- src/app/valentina/xml/vpattern.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 682114bd6..8530de059 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -731,7 +731,7 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document QString qsLength = GetParametrString(element, AttrLength); detail.GetGrainlineGeometry().SetLength(qsLength); } - catch (VExceptionEmptyParameter eep) + catch (const VExceptionEmptyParameter& eep) { Q_UNUSED(eep); detail.GetGrainlineGeometry().SetLength("0"); @@ -742,7 +742,7 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document QString qsRot = GetParametrString(element, VToolDetail::AttrRotation); detail.GetGrainlineGeometry().SetRotation(qsRot); } - catch(VExceptionEmptyParameter eep) + catch(const VExceptionEmptyParameter& eep) { Q_UNUSED(eep); detail.GetGrainlineGeometry().SetRotation("90"); From 568ecc01a6c7ba0645510f7b337675bb98eca674 Mon Sep 17 00:00:00 2001 From: BojanKverh Date: Sun, 23 Oct 2016 22:04:14 +0200 Subject: [PATCH 6/6] Fixed exception catching when reading grainline formulas --HG-- branch : feature --- src/app/valentina/xml/vpattern.cpp | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 8530de059..8dc43e38e 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -726,27 +726,10 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document ptPos.setX(GetParametrDouble(element, AttrMx, "0")); ptPos.setY(GetParametrDouble(element, AttrMy, "0")); detail.GetGrainlineGeometry().SetPos(ptPos); - try - { - QString qsLength = GetParametrString(element, AttrLength); - detail.GetGrainlineGeometry().SetLength(qsLength); - } - catch (const VExceptionEmptyParameter& eep) - { - Q_UNUSED(eep); - detail.GetGrainlineGeometry().SetLength("0"); - } - - try - { - QString qsRot = GetParametrString(element, VToolDetail::AttrRotation); - detail.GetGrainlineGeometry().SetRotation(qsRot); - } - catch(const VExceptionEmptyParameter& eep) - { - Q_UNUSED(eep); - detail.GetGrainlineGeometry().SetRotation("90"); - } + QString qsLength = GetParametrString(element, AttrLength, "0"); + detail.GetGrainlineGeometry().SetLength(qsLength); + QString qsRot = GetParametrString(element, VToolDetail::AttrRotation, "90"); + detail.GetGrainlineGeometry().SetRotation(qsRot); } } }