From db478562eed7723fa1d0d8d5c52d85fb8167dba0 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 12 Oct 2018 13:06:03 +0300 Subject: [PATCH] Fixed issue #885. Regression. Broken support for multi size measurements. (grafted from 1a0becf32c00518f126cd0e7325c0eb2bbdcc18e) --HG-- branch : develop --- ChangeLog.txt | 3 +++ src/app/tape/tmainwindow.cpp | 2 +- src/app/valentina/mainwindow.cpp | 11 +++++++---- src/libs/vformat/vmeasurements.cpp | 6 +++++- src/libs/vformat/vmeasurements.h | 2 +- src/libs/vpatterndb/variables/vmeasurement.cpp | 18 +++++++++++++++--- src/libs/vpatterndb/variables/vmeasurement.h | 3 +++ src/libs/vpatterndb/variables/vmeasurement_p.h | 12 ++++++------ 8 files changed, 41 insertions(+), 16 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 118382f80..b37637f8c 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,6 @@ +# Version 0.6.1 (unreleased) +- [#885] Regression. Broken support for multi size measurements. + # Version 0.6.0 October 1, 2018 - [#682] New feature. Export increments to Excel .csv. - [#681] Enhance feature: Dashed line options for curves, arcs, etc. diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index e414c3ae3..8112ed09a 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -2429,7 +2429,7 @@ void TMainWindow::RefreshData(bool freshCall) { data->ClearUniqueNames(); data->ClearVariables(VarType::Measurement); - m->ReadMeasurements(); + m->ReadMeasurements(currentHeight, currentSize); RefreshTable(freshCall); } diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 06fcc2c5b..98de6b540 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -420,6 +420,9 @@ bool MainWindow::LoadMeasurements(const QString &path) return false; } + const qreal size = UnitConvertor(m->BaseSize(), m->MUnit(), *m->GetData()->GetPatternUnit()); + const qreal height = UnitConvertor(m->BaseHeight(), m->MUnit(), *m->GetData()->GetPatternUnit()); + try { qApp->setPatternType(m->Type()); @@ -429,7 +432,7 @@ bool MainWindow::LoadMeasurements(const QString &path) } ToolBarOption(); pattern->ClearVariables(VarType::Measurement); - m->ReadMeasurements(); + m->ReadMeasurements(height, size); } catch (VExceptionEmptyParameter &e) { @@ -444,8 +447,8 @@ bool MainWindow::LoadMeasurements(const QString &path) if (m->Type() == MeasurementsType::Multisize) { - pattern->SetSize(UnitConvertor(m->BaseSize(), m->MUnit(), *m->GetData()->GetPatternUnit())); - pattern->SetHeight(UnitConvertor(m->BaseHeight(), m->MUnit(), *m->GetData()->GetPatternUnit())); + pattern->SetSize(size); + pattern->SetHeight(height); doc->SetPatternWasChanged(true); emit doc->UpdatePatternLabel(); @@ -481,7 +484,7 @@ bool MainWindow::UpdateMeasurements(const QString &path, int size, int height) try { pattern->ClearVariables(VarType::Measurement); - m->ReadMeasurements(); + m->ReadMeasurements(height, size); if (m->Type() == MeasurementsType::Individual) { qApp->SetCustomerName(m->Customer()); diff --git a/src/libs/vformat/vmeasurements.cpp b/src/libs/vformat/vmeasurements.cpp index 38f8f576c..9cc6bd792 100644 --- a/src/libs/vformat/vmeasurements.cpp +++ b/src/libs/vformat/vmeasurements.cpp @@ -250,7 +250,7 @@ void VMeasurements::MoveBottom(const QString &name) } //--------------------------------------------------------------------------------------------------------------------- -void VMeasurements::ReadMeasurements() const +void VMeasurements::ReadMeasurements(qreal height, qreal size) const { // For conversion values we must first calculate all data in measurement file's unit. // That's why we need two containers: one for converted values, second for real data. @@ -278,6 +278,8 @@ void VMeasurements::ReadMeasurements() const tempMeash = QSharedPointer(new VMeasurement(static_cast(i), name, BaseSize(), BaseHeight(), base, ksize, kheight)); + tempMeash->SetSize(size); + tempMeash->SetHeight(height); tempMeash->SetUnit(data->GetPatternUnit()); base = UnitConvertor(base, MUnit(), *data->GetPatternUnit()); @@ -289,6 +291,8 @@ void VMeasurements::ReadMeasurements() const meash = QSharedPointer(new VMeasurement(static_cast(i), name, baseSize, baseHeight, base, ksize, kheight, fullName, description)); + meash->SetSize(size); + meash->SetHeight(height); meash->SetUnit(data->GetPatternUnit()); } else diff --git a/src/libs/vformat/vmeasurements.h b/src/libs/vformat/vmeasurements.h index 9ba19442d..dadaec42c 100644 --- a/src/libs/vformat/vmeasurements.h +++ b/src/libs/vformat/vmeasurements.h @@ -62,7 +62,7 @@ public: void MoveDown(const QString &name); void MoveBottom(const QString &name); - void ReadMeasurements() const; + void ReadMeasurements(qreal height, qreal size) const; void ClearForExport(); MeasurementsType Type() const; diff --git a/src/libs/vpatterndb/variables/vmeasurement.cpp b/src/libs/vpatterndb/variables/vmeasurement.cpp index 1f1d877e1..ce5934784 100644 --- a/src/libs/vpatterndb/variables/vmeasurement.cpp +++ b/src/libs/vpatterndb/variables/vmeasurement.cpp @@ -219,7 +219,7 @@ bool VMeasurement::IsGradationHeightValid(const QString &height) //--------------------------------------------------------------------------------------------------------------------- qreal VMeasurement::CalcValue() const { - if (d->currentUnit == nullptr || d->currentSize == nullptr || d->currentHeight == nullptr) + if (d->currentUnit == nullptr || qFuzzyIsNull(d->currentSize) || qFuzzyIsNull(d->currentHeight)) { return VInternalVariable::GetValue(); } @@ -234,8 +234,8 @@ qreal VMeasurement::CalcValue() const const qreal heightIncrement = UnitConvertor(6.0, Unit::Cm, *d->currentUnit); // Formula for calculation gradation - const qreal k_size = ( *d->currentSize - d->baseSize ) / sizeIncrement; - const qreal k_height = ( *d->currentHeight - d->baseHeight ) / heightIncrement; + const qreal k_size = ( d->currentSize - d->baseSize ) / sizeIncrement; + const qreal k_height = ( d->currentHeight - d->baseHeight ) / heightIncrement; return d->base + k_size * d->ksize + k_height * d->kheight; } @@ -310,6 +310,18 @@ VContainer *VMeasurement::GetData() return d->data.data(); } +//--------------------------------------------------------------------------------------------------------------------- +void VMeasurement::SetSize(qreal size) +{ + d->currentSize = size; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VMeasurement::SetHeight(qreal height) +{ + d->currentHeight = height; +} + //--------------------------------------------------------------------------------------------------------------------- void VMeasurement::SetUnit(const Unit *unit) { diff --git a/src/libs/vpatterndb/variables/vmeasurement.h b/src/libs/vpatterndb/variables/vmeasurement.h index a4b3af4b5..d9281225b 100644 --- a/src/libs/vpatterndb/variables/vmeasurement.h +++ b/src/libs/vpatterndb/variables/vmeasurement.h @@ -87,6 +87,9 @@ public: VContainer *GetData(); + void SetSize(qreal size); + void SetHeight(qreal height); + void SetUnit(const Unit *unit); qreal GetBase() const; diff --git a/src/libs/vpatterndb/variables/vmeasurement_p.h b/src/libs/vpatterndb/variables/vmeasurement_p.h index 1b77eb703..0ea69b667 100644 --- a/src/libs/vpatterndb/variables/vmeasurement_p.h +++ b/src/libs/vpatterndb/variables/vmeasurement_p.h @@ -50,8 +50,8 @@ public: gui_text(gui_text), _tagName(tagName), formulaOk(true), - currentSize(nullptr), - currentHeight(nullptr), + currentSize(0), + currentHeight(0), currentUnit(nullptr), base(base), ksize(ksize), @@ -68,8 +68,8 @@ public: gui_text(gui_text), _tagName(tagName), formulaOk(ok), - currentSize(nullptr), - currentHeight(nullptr), + currentSize(0), + currentHeight(0), currentUnit(nullptr), base(base), ksize(0), @@ -105,8 +105,8 @@ public: QString _tagName; bool formulaOk; - qreal *currentSize; - qreal *currentHeight; + qreal currentSize; + qreal currentHeight; const Unit *currentUnit; /** @brief base value in base size and height */