Validate dimensions while reading multisize measurements.
This commit is contained in:
parent
3f2806a695
commit
2334a04fbd
|
@ -204,10 +204,12 @@ auto VAbstartMeasurementDimension::ValidBases(qreal min, qreal max, qreal step,
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VAbstartMeasurementDimension::IsRangeValid() -> bool
|
||||
auto VAbstartMeasurementDimension::IsRangeValid() const -> bool
|
||||
{
|
||||
bool valid = m_minValue > 0 && m_maxValue > 0 && m_minValue >= RangeMin() && m_minValue <= RangeMax()
|
||||
&& m_minValue <= m_maxValue;
|
||||
bool valid = m_minValue > 0 && m_maxValue > 0 &&
|
||||
(m_minValue > RangeMin() || VFuzzyComparePossibleNulls(m_minValue, RangeMin())) &&
|
||||
(m_maxValue < RangeMax() || VFuzzyComparePossibleNulls(m_maxValue, RangeMax())) &&
|
||||
(m_minValue < m_maxValue || VFuzzyComparePossibleNulls(m_minValue, m_maxValue));
|
||||
|
||||
if (not valid)
|
||||
{
|
||||
|
@ -218,7 +220,7 @@ auto VAbstartMeasurementDimension::IsRangeValid() -> bool
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VAbstartMeasurementDimension::IsStepValid() -> bool
|
||||
auto VAbstartMeasurementDimension::IsStepValid() const -> bool
|
||||
{
|
||||
bool valid = ValidSteps().indexOf(m_step) != -1;
|
||||
if (not valid)
|
||||
|
@ -230,7 +232,7 @@ auto VAbstartMeasurementDimension::IsStepValid() -> bool
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VAbstartMeasurementDimension::IsBaseValid() -> bool
|
||||
auto VAbstartMeasurementDimension::IsBaseValid() const -> bool
|
||||
{
|
||||
bool valid = ValidBases().indexOf(m_baseValue) != -1;
|
||||
if (not valid)
|
||||
|
@ -244,7 +246,14 @@ auto VAbstartMeasurementDimension::IsBaseValid() -> bool
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VAbstartMeasurementDimension::IsUnitsValid() const -> bool
|
||||
{
|
||||
return m_units == Unit::Cm || m_units == Unit::Mm || m_units == Unit::Inch;
|
||||
bool valid = (m_units == Unit::Cm || m_units == Unit::Mm || m_units == Unit::Inch);
|
||||
|
||||
if (not valid)
|
||||
{
|
||||
m_error = QCoreApplication::translate("VAbstartMeasurementDimension", "Units are invalid");
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -107,9 +107,9 @@ public:
|
|||
void SetCustomName(const QString &newCustomName);
|
||||
|
||||
protected:
|
||||
auto IsRangeValid() -> bool;
|
||||
auto IsStepValid() -> bool;
|
||||
auto IsBaseValid() -> bool;
|
||||
auto IsRangeValid() const -> bool;
|
||||
auto IsStepValid() const -> bool;
|
||||
auto IsBaseValid() const -> bool;
|
||||
auto IsUnitsValid() const -> bool;
|
||||
|
||||
private:
|
||||
|
@ -120,7 +120,7 @@ private:
|
|||
qreal m_maxValue{0};
|
||||
qreal m_step{-1};
|
||||
qreal m_baseValue{0};
|
||||
QString m_error{};
|
||||
mutable QString m_error{};
|
||||
DimesionLabels m_labels{};
|
||||
bool m_measurement{true};
|
||||
QString m_customName{};
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include <QGlobalStatic>
|
||||
|
||||
#include "../ifc/exception/vexceptionemptyparameter.h"
|
||||
#include "../ifc/exception/vexceptionobjecterror.h"
|
||||
#include "../ifc/xml/vvitconverter.h"
|
||||
#include "../ifc/xml/vvstconverter.h"
|
||||
#include "../ifc/ifcdef.h"
|
||||
|
@ -153,7 +154,12 @@ void VMeasurements::setXMLContent(const QString &fileName)
|
|||
VDomDocument::setXMLContent(fileName);
|
||||
type = ReadType();
|
||||
m_units = ReadUnits();
|
||||
|
||||
if (type == MeasurementsType::Multisize &&
|
||||
VVSTConverter::MeasurementMaxVer == GetFormatVersion(GetFormatVersionStr()))
|
||||
{
|
||||
m_dimensions = ReadDimensions();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -1427,6 +1433,14 @@ auto VMeasurements::ReadDimensions() const -> VDimensions
|
|||
dimension->SetBodyMeasurement(GetParametrBool(dom, AttrMeasurement, trueStr));
|
||||
dimension->SetCustomName(GetParametrEmptyString(dom, AttrCustomName));
|
||||
dimension->SetLabels(ReadDimensionLabels(dom));
|
||||
|
||||
if (not dimension->IsValid())
|
||||
{
|
||||
VExceptionObjectError excep(tr("Dimension is not valid"), dom);
|
||||
excep.AddMoreInformation(dimension->Error());
|
||||
throw excep;
|
||||
}
|
||||
|
||||
dimensions.insert(type, dimension);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user