Fixed issue #885. Regression. Broken support for multi size measurements.

(grafted from 1a0becf32c00518f126cd0e7325c0eb2bbdcc18e)

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2018-10-12 13:06:03 +03:00
parent 409f34d205
commit db478562ee
8 changed files with 41 additions and 16 deletions

View File

@ -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.

View File

@ -2429,7 +2429,7 @@ void TMainWindow::RefreshData(bool freshCall)
{
data->ClearUniqueNames();
data->ClearVariables(VarType::Measurement);
m->ReadMeasurements();
m->ReadMeasurements(currentHeight, currentSize);
RefreshTable(freshCall);
}

View File

@ -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());

View File

@ -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<VMeasurement>(new VMeasurement(static_cast<quint32>(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<VMeasurement>(new VMeasurement(static_cast<quint32>(i), name, baseSize, baseHeight,
base, ksize, kheight, fullName, description));
meash->SetSize(size);
meash->SetHeight(height);
meash->SetUnit(data->GetPatternUnit());
}
else

View File

@ -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;

View File

@ -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)
{

View File

@ -87,6 +87,9 @@ public:
VContainer *GetData();
void SetSize(qreal size);
void SetHeight(qreal height);
void SetUnit(const Unit *unit);
qreal GetBase() const;

View File

@ -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 */