2020-09-28 15:38:32 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vdimensions.cpp
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 25 9, 2020
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
|
|
|
** This source code is part of the Valentina project, a pattern making
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2020 Valentina project
|
|
|
|
** <https://gitlab.com/smart-pattern/valentina> 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 <http://www.gnu.org/licenses/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
#include "vdimensions.h"
|
|
|
|
|
|
|
|
#include <QSet>
|
|
|
|
#include <QVector>
|
2021-01-18 19:43:53 +01:00
|
|
|
#include <cmath>
|
2020-09-28 15:38:32 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VAbstartMeasurementDimension::VAbstartMeasurementDimension(Unit units)
|
|
|
|
: m_units(units)
|
|
|
|
{}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
VAbstartMeasurementDimension::VAbstartMeasurementDimension(Unit units, qreal min, qreal max, qreal step)
|
2020-09-28 15:38:32 +02:00
|
|
|
: m_units(units),
|
|
|
|
m_minValue(min),
|
|
|
|
m_maxValue(max),
|
|
|
|
m_step(step)
|
|
|
|
{}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
auto VAbstartMeasurementDimension::IsValid() -> bool
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
|
|
|
m_error.clear();
|
|
|
|
return IsUnitsValid() && IsRangeValid() && IsStepValid() && IsBaseValid();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
auto VAbstartMeasurementDimension::ValidSteps() const -> QVector<qreal>
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
const qreal stepBarrier = 8.5;
|
|
|
|
const qreal s = 0.5;
|
2020-09-28 15:38:32 +02:00
|
|
|
|
2021-01-18 19:43:53 +01:00
|
|
|
QVector<qreal> steps;
|
|
|
|
steps.reserve(qRound((stepBarrier - s) * 2 - 1));
|
|
|
|
|
|
|
|
const qreal diff = m_maxValue - m_minValue;
|
|
|
|
if (qFuzzyIsNull(diff))
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
|
|
|
steps.append(0); // only one possible value
|
|
|
|
}
|
|
|
|
else if (diff > 0)
|
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
qreal candidate = 1;
|
|
|
|
do
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
const qreal step = (m_units == Unit::Mm ? candidate * 10 : candidate);
|
|
|
|
qreal intpart;
|
|
|
|
if (qFuzzyIsNull(std::modf(diff / step, &intpart)))
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
|
|
|
steps.append(step);
|
|
|
|
}
|
2021-01-18 19:43:53 +01:00
|
|
|
candidate += s;
|
2020-09-28 15:38:32 +02:00
|
|
|
}
|
2021-01-18 19:43:53 +01:00
|
|
|
while(candidate < stepBarrier);
|
2020-09-28 15:38:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return steps;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
auto VAbstartMeasurementDimension::ValidBases() const -> QVector<qreal>
|
2020-10-07 16:12:53 +02:00
|
|
|
{
|
2021-01-19 20:13:17 +01:00
|
|
|
return VAbstartMeasurementDimension::ValidBases(m_minValue, m_maxValue, m_step, QSet<qreal>());
|
2020-10-07 16:12:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
auto VAbstartMeasurementDimension::ValidBasesList() const -> QStringList
|
2020-10-07 16:12:53 +02:00
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
QVector<qreal> bases = ValidBases();
|
2020-10-07 16:12:53 +02:00
|
|
|
QStringList list;
|
2021-01-18 19:43:53 +01:00
|
|
|
list.reserve(bases.size());
|
2020-10-07 16:12:53 +02:00
|
|
|
for(auto &base : bases)
|
|
|
|
{
|
|
|
|
list.append(QString::number(base));
|
|
|
|
}
|
|
|
|
return list;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-19 20:13:17 +01:00
|
|
|
auto VAbstartMeasurementDimension::ValidBases(qreal min, qreal max, qreal step,
|
|
|
|
const QSet<qreal> &exclude) -> QVector<qreal>
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
QVector<qreal> validBases;
|
2020-09-28 15:38:32 +02:00
|
|
|
|
2021-01-18 19:43:53 +01:00
|
|
|
if (step < 0 || min > max)
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
|
|
|
return validBases;
|
|
|
|
}
|
2021-01-18 19:43:53 +01:00
|
|
|
|
|
|
|
if (qFuzzyIsNull(step))
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
|
|
|
step = 1;
|
|
|
|
}
|
|
|
|
|
2021-01-18 19:43:53 +01:00
|
|
|
validBases.reserve(qRound((max - min) / step));
|
|
|
|
|
|
|
|
qreal value = min;
|
|
|
|
do
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
2021-01-19 20:13:17 +01:00
|
|
|
if (not exclude.contains(value))
|
|
|
|
{
|
|
|
|
validBases.append(value);
|
|
|
|
}
|
2021-01-18 19:43:53 +01:00
|
|
|
value += step;
|
2020-09-28 15:38:32 +02:00
|
|
|
}
|
2021-01-18 19:43:53 +01:00
|
|
|
while(value < max + step);
|
2020-09-28 15:38:32 +02:00
|
|
|
|
2021-01-19 20:13:17 +01:00
|
|
|
if (validBases.isEmpty())
|
|
|
|
{
|
|
|
|
value = min;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
validBases.append(value);
|
|
|
|
value += step;
|
|
|
|
}
|
|
|
|
while(value < max + step);
|
|
|
|
}
|
|
|
|
|
2020-09-28 15:38:32 +02:00
|
|
|
return validBases;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
auto VAbstartMeasurementDimension::IsRangeValid() -> bool
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
|
|
|
bool valid = m_minValue > 0 && m_maxValue > 0 && m_minValue >= RangeMin() && m_minValue <= RangeMax()
|
|
|
|
&& m_minValue <= m_maxValue;
|
|
|
|
|
|
|
|
if (not valid)
|
|
|
|
{
|
|
|
|
m_error = tr("Invalid min/max range");
|
|
|
|
}
|
|
|
|
|
|
|
|
return valid;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
auto VAbstartMeasurementDimension::IsStepValid() -> bool
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
|
|
|
bool valid = ValidSteps().indexOf(m_step) != -1;
|
|
|
|
if (not valid)
|
|
|
|
{
|
|
|
|
m_error = tr("Invalid step");
|
|
|
|
}
|
|
|
|
|
|
|
|
return valid;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
auto VAbstartMeasurementDimension::IsBaseValid() -> bool
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
|
|
|
bool valid = ValidBases().indexOf(m_baseValue) != -1;
|
|
|
|
if (not valid)
|
|
|
|
{
|
|
|
|
m_error = tr("Base value invalid");
|
|
|
|
}
|
|
|
|
|
|
|
|
return valid;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
auto VAbstartMeasurementDimension::IsUnitsValid() const -> bool
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
|
|
|
return m_units == Unit::Cm || m_units == Unit::Mm || m_units == Unit::Inch;
|
|
|
|
}
|
|
|
|
|
2020-10-06 17:00:53 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
auto VAbstartMeasurementDimension::DimensionName(MeasurementDimension type) -> QString
|
2020-10-06 17:00:53 +02:00
|
|
|
{
|
|
|
|
switch(type)
|
|
|
|
{
|
2020-10-15 08:35:08 +02:00
|
|
|
case MeasurementDimension::X:
|
2020-10-20 15:29:11 +02:00
|
|
|
return tr("Height", "dimension");
|
2020-10-15 08:35:08 +02:00
|
|
|
case MeasurementDimension::Y:
|
2020-10-20 15:29:11 +02:00
|
|
|
return tr("Size", "dimension");
|
2020-10-15 08:35:08 +02:00
|
|
|
case MeasurementDimension::W:
|
2020-10-20 15:29:11 +02:00
|
|
|
return tr("Waist", "dimension");
|
2020-10-15 08:35:08 +02:00
|
|
|
case MeasurementDimension::Z:
|
2020-10-20 15:29:11 +02:00
|
|
|
return tr("Hip", "dimension");
|
2020-10-15 08:35:08 +02:00
|
|
|
default:
|
|
|
|
return QString();
|
2020-10-06 17:00:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
auto VAbstartMeasurementDimension::DimensionToolTip(MeasurementDimension type, bool circumference, bool fc) -> QString
|
2020-10-06 17:00:53 +02:00
|
|
|
{
|
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case MeasurementDimension::X:
|
2020-10-20 15:29:11 +02:00
|
|
|
return tr("Height", "dimension");
|
2020-10-06 17:00:53 +02:00
|
|
|
case MeasurementDimension::Y:
|
|
|
|
if (circumference)
|
|
|
|
{
|
2020-10-20 15:29:11 +02:00
|
|
|
return fc ? tr("Chest full circumference", "dimension") : tr("Chest half circumference", "dimension");
|
2020-10-06 17:00:53 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return tr("Size");
|
|
|
|
}
|
2020-10-20 15:29:11 +02:00
|
|
|
return circumference ? tr("Chest circumference", "dimension") : tr("Size", "dimension");
|
2020-10-06 17:00:53 +02:00
|
|
|
case MeasurementDimension::W:
|
2020-10-20 15:29:11 +02:00
|
|
|
return fc ? tr("Waist full circumference", "dimension") : tr("Waist half circumference", "dimension");
|
2020-10-06 17:00:53 +02:00
|
|
|
case MeasurementDimension::Z:
|
2020-10-20 15:29:11 +02:00
|
|
|
return fc ? tr("Hip full circumference", "dimension") : tr("Hip half circumference", "dimension");
|
2020-10-06 17:00:53 +02:00
|
|
|
default:
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-28 15:38:32 +02:00
|
|
|
// VXMeasurementDimension
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VXMeasurementDimension::VXMeasurementDimension(Unit units)
|
|
|
|
: VAbstartMeasurementDimension(units)
|
|
|
|
{}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
VXMeasurementDimension::VXMeasurementDimension(Unit units, qreal min, qreal max, qreal step)
|
2020-09-28 15:38:32 +02:00
|
|
|
: VAbstartMeasurementDimension(units, min, max, step)
|
|
|
|
{}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
auto VXMeasurementDimension::Type() const -> MeasurementDimension
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
|
|
|
return MeasurementDimension::X;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
auto VXMeasurementDimension::RangeMin() const -> int
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
const int rangeMinCm = 50;
|
|
|
|
const int rangeMinMm = 500;
|
|
|
|
const int rangeMinInch = 19;
|
|
|
|
|
2020-09-28 15:38:32 +02:00
|
|
|
switch(m_units)
|
|
|
|
{
|
|
|
|
case Unit::Cm:
|
2021-01-18 19:43:53 +01:00
|
|
|
return rangeMinCm;
|
2020-09-28 15:38:32 +02:00
|
|
|
case Unit::Mm:
|
2021-01-18 19:43:53 +01:00
|
|
|
return rangeMinMm;
|
2020-09-28 15:38:32 +02:00
|
|
|
case Unit::Inch:
|
2021-01-18 19:43:53 +01:00
|
|
|
return rangeMinInch;
|
2020-09-28 15:38:32 +02:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
auto VXMeasurementDimension::RangeMax() const -> int
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
const int rangeMaxCm = 272;
|
|
|
|
const int rangeMaxMm = 2720;
|
|
|
|
const int rangeMaxInch = 107;
|
|
|
|
|
2020-09-28 15:38:32 +02:00
|
|
|
switch(m_units)
|
|
|
|
{
|
|
|
|
case Unit::Cm:
|
2021-01-18 19:43:53 +01:00
|
|
|
return rangeMaxCm;
|
2020-09-28 15:38:32 +02:00
|
|
|
case Unit::Mm:
|
2021-01-18 19:43:53 +01:00
|
|
|
return rangeMaxMm;
|
2020-09-28 15:38:32 +02:00
|
|
|
case Unit::Inch:
|
2021-01-18 19:43:53 +01:00
|
|
|
return rangeMaxInch;
|
2020-09-28 15:38:32 +02:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// VYMeasurementDimension
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VYMeasurementDimension::VYMeasurementDimension(Unit units)
|
|
|
|
: VAbstartMeasurementDimension(units)
|
|
|
|
{}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
VYMeasurementDimension::VYMeasurementDimension(Unit units, qreal min, qreal max, qreal step)
|
2020-09-28 15:38:32 +02:00
|
|
|
: VAbstartMeasurementDimension(units, min, max, step)
|
|
|
|
{}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
auto VYMeasurementDimension::Type() const -> MeasurementDimension
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
|
|
|
return MeasurementDimension::Y;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
auto VYMeasurementDimension::RangeMin() const -> int
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
|
|
|
if (m_circumference)
|
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
const int rangeMinCm = 22;
|
|
|
|
const int rangeMinMm = 220;
|
|
|
|
const int rangeMinInch = 8;
|
|
|
|
|
2020-09-28 15:38:32 +02:00
|
|
|
switch(m_units)
|
|
|
|
{
|
|
|
|
case Unit::Cm:
|
2021-01-18 19:43:53 +01:00
|
|
|
return rangeMinCm;
|
2020-09-28 15:38:32 +02:00
|
|
|
case Unit::Mm:
|
2021-01-18 19:43:53 +01:00
|
|
|
return rangeMinMm;
|
2020-09-28 15:38:32 +02:00
|
|
|
case Unit::Inch:
|
2021-01-18 19:43:53 +01:00
|
|
|
return rangeMinInch;
|
2020-09-28 15:38:32 +02:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
const int rangeMinCir = 6;
|
|
|
|
return rangeMinCir;
|
2020-09-28 15:38:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
auto VYMeasurementDimension::RangeMax() const -> int
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
|
|
|
if (m_circumference)
|
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
const int rangeMaxCm = 72;
|
|
|
|
const int rangeMaxMm = 720;
|
|
|
|
const int rangeMaxInch = 29;
|
|
|
|
|
2020-09-28 15:38:32 +02:00
|
|
|
switch(m_units)
|
|
|
|
{
|
|
|
|
case Unit::Cm:
|
2021-01-18 19:43:53 +01:00
|
|
|
return rangeMaxCm;
|
2020-09-28 15:38:32 +02:00
|
|
|
case Unit::Mm:
|
2021-01-18 19:43:53 +01:00
|
|
|
return rangeMaxMm;
|
2020-09-28 15:38:32 +02:00
|
|
|
case Unit::Inch:
|
2021-01-18 19:43:53 +01:00
|
|
|
return rangeMaxInch;
|
2020-09-28 15:38:32 +02:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
const int rangeMaxCir = 60;
|
|
|
|
return rangeMaxCir;
|
2020-09-28 15:38:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// VWMeasurementDimension
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VWMeasurementDimension::VWMeasurementDimension(Unit units)
|
|
|
|
: VAbstartMeasurementDimension(units)
|
|
|
|
{}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
VWMeasurementDimension::VWMeasurementDimension(Unit units, qreal min, qreal max, qreal step)
|
2020-09-28 15:38:32 +02:00
|
|
|
: VAbstartMeasurementDimension(units, min, max, step)
|
|
|
|
{}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
auto VWMeasurementDimension::Type() const -> MeasurementDimension
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
|
|
|
return MeasurementDimension::W;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
auto VWMeasurementDimension::RangeMin() const -> int
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
const int rangeMinCm = 20;
|
|
|
|
const int rangeMinMm = 200;
|
|
|
|
const int rangeMinInch = 8;
|
|
|
|
|
2020-09-28 15:38:32 +02:00
|
|
|
switch(m_units)
|
|
|
|
{
|
|
|
|
case Unit::Cm:
|
2021-01-18 19:43:53 +01:00
|
|
|
return rangeMinCm;
|
2020-09-28 15:38:32 +02:00
|
|
|
case Unit::Mm:
|
2021-01-18 19:43:53 +01:00
|
|
|
return rangeMinMm;
|
2020-09-28 15:38:32 +02:00
|
|
|
case Unit::Inch:
|
2021-01-18 19:43:53 +01:00
|
|
|
return rangeMinInch;
|
2020-09-28 15:38:32 +02:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
auto VWMeasurementDimension::RangeMax() const -> int
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
const int rangeMaxCm = 65;
|
|
|
|
const int rangeMaxMm = 650;
|
|
|
|
const int rangeMaxInch = 26;
|
|
|
|
|
2020-09-28 15:38:32 +02:00
|
|
|
switch(m_units)
|
|
|
|
{
|
|
|
|
case Unit::Cm:
|
2021-01-18 19:43:53 +01:00
|
|
|
return rangeMaxCm;
|
2020-09-28 15:38:32 +02:00
|
|
|
case Unit::Mm:
|
2021-01-18 19:43:53 +01:00
|
|
|
return rangeMaxMm;
|
2020-09-28 15:38:32 +02:00
|
|
|
case Unit::Inch:
|
2021-01-18 19:43:53 +01:00
|
|
|
return rangeMaxInch;
|
2020-09-28 15:38:32 +02:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// VZMeasurementDimension
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VZMeasurementDimension::VZMeasurementDimension(Unit units)
|
|
|
|
: VAbstartMeasurementDimension(units)
|
|
|
|
{}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
VZMeasurementDimension::VZMeasurementDimension(Unit units, qreal min, qreal max, qreal step)
|
2020-09-28 15:38:32 +02:00
|
|
|
: VAbstartMeasurementDimension(units, min, max, step)
|
|
|
|
{}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
auto VZMeasurementDimension::Type() const -> MeasurementDimension
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
|
|
|
return MeasurementDimension::Z;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
auto VZMeasurementDimension::RangeMin() const -> int
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
const int rangeMinCm = 20;
|
|
|
|
const int rangeMinMm = 200;
|
|
|
|
const int rangeMinInch = 8;
|
|
|
|
|
2020-09-28 15:38:32 +02:00
|
|
|
switch(m_units)
|
|
|
|
{
|
|
|
|
case Unit::Cm:
|
2021-01-18 19:43:53 +01:00
|
|
|
return rangeMinCm;
|
2020-09-28 15:38:32 +02:00
|
|
|
case Unit::Mm:
|
2021-01-18 19:43:53 +01:00
|
|
|
return rangeMinMm;
|
2020-09-28 15:38:32 +02:00
|
|
|
case Unit::Inch:
|
2021-01-18 19:43:53 +01:00
|
|
|
return rangeMinInch;
|
2020-09-28 15:38:32 +02:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2021-01-18 19:43:53 +01:00
|
|
|
auto VZMeasurementDimension::RangeMax() const -> int
|
2020-09-28 15:38:32 +02:00
|
|
|
{
|
2021-01-18 19:43:53 +01:00
|
|
|
const int rangeMaxCm = 75;
|
|
|
|
const int rangeMaxMm = 750;
|
|
|
|
const int rangeMaxInch = 30;
|
|
|
|
|
2020-09-28 15:38:32 +02:00
|
|
|
switch(m_units)
|
|
|
|
{
|
|
|
|
case Unit::Cm:
|
2021-01-18 19:43:53 +01:00
|
|
|
return rangeMaxCm;
|
2020-09-28 15:38:32 +02:00
|
|
|
case Unit::Mm:
|
2021-01-18 19:43:53 +01:00
|
|
|
return rangeMaxMm;
|
2020-09-28 15:38:32 +02:00
|
|
|
case Unit::Inch:
|
2021-01-18 19:43:53 +01:00
|
|
|
return rangeMaxInch;
|
2020-09-28 15:38:32 +02:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2021-01-19 20:13:17 +01:00
|
|
|
|
|
|
|
// VDimensionRestriction
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VDimensionRestriction::SetExcludeString(const QString &exclude)
|
|
|
|
{
|
|
|
|
m_exclude.clear();
|
|
|
|
|
|
|
|
QStringList values = exclude.split(';');
|
|
|
|
for(auto &value : values)
|
|
|
|
{
|
|
|
|
bool ok = false;
|
|
|
|
qreal val = value.toDouble(&ok);
|
|
|
|
|
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
m_exclude.insert(val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
auto VDimensionRestriction::GetExcludeString() const -> QString
|
|
|
|
{
|
|
|
|
QList<qreal> list = m_exclude.values();
|
|
|
|
QStringList excludeList;
|
|
|
|
|
|
|
|
for(auto &value : list)
|
|
|
|
{
|
|
|
|
excludeList.append(QString::number(value));
|
|
|
|
}
|
|
|
|
|
|
|
|
return excludeList.join(';');
|
|
|
|
}
|