Improve multisize measurements format. Allow decimal step 0.5.

This commit is contained in:
Roman Telezhynskyi 2021-01-18 20:43:53 +02:00
parent d60653fcd3
commit 2b7769c80e
19 changed files with 560 additions and 493 deletions

View File

@ -6,6 +6,7 @@
- New warning. Warn about empty measurements dimension value when preparing placeholders. - New warning. Warn about empty measurements dimension value when preparing placeholders.
- New option "Don't use the native file dialog". - New option "Don't use the native file dialog".
- Improve the layout option "Auto crop unused width". - Improve the layout option "Auto crop unused width".
- Improve multisize measurements format. Allow decimal step 0.5.
# Version 0.7.41 Dec 4, 2020 # Version 0.7.41 Dec 4, 2020
- Bug fixes. - Bug fixes.

View File

@ -96,11 +96,11 @@ void DialogDimensionLabels::DimensionChanged()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogDimensionLabels::LabelChanged(QTableWidgetItem *item) void DialogDimensionLabels::LabelChanged(QTableWidgetItem *item)
{ {
if (item) if (item != nullptr)
{ {
MeasurementDimension type = MeasurementDimension type =
static_cast<MeasurementDimension>(ui->comboBoxDimensionLabels->currentData().toInt()); static_cast<MeasurementDimension>(ui->comboBoxDimensionLabels->currentData().toInt());
int value = item->data(Qt::UserRole).toInt(); qreal value = item->data(Qt::UserRole).toDouble();
DimesionLabels labels = m_labels.value(type); DimesionLabels labels = m_labels.value(type);
labels.insert(value, item->text()); labels.insert(value, item->text());
@ -116,7 +116,7 @@ void DialogDimensionLabels::InitLabels()
const QList<MeasurementDimension_p> dimensions = m_dimensions.values(); const QList<MeasurementDimension_p> dimensions = m_dimensions.values();
for(auto &dimension : dimensions) for(const auto &dimension : dimensions)
{ {
m_labels.insert(dimension->Type(), dimension->Labels()); m_labels.insert(dimension->Type(), dimension->Labels());
} }
@ -158,7 +158,7 @@ void DialogDimensionLabels::InitTable()
return; return;
} }
const QVector<int> bases = dimension->ValidBases(); const QVector<qreal> bases = dimension->ValidBases();
ui->tableWidget->setRowCount(bases.size()); ui->tableWidget->setRowCount(bases.size());
@ -166,7 +166,7 @@ void DialogDimensionLabels::InitTable()
for(int row = 0; row < bases.size(); ++row) for(int row = 0; row < bases.size(); ++row)
{ {
const int base = bases.at(row); const qreal base = bases.at(row);
{ {
auto *itemValue = new QTableWidgetItem(DimensionValue(dimension, base)); auto *itemValue = new QTableWidgetItem(DimensionValue(dimension, base));
@ -195,7 +195,7 @@ void DialogDimensionLabels::InitTable()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString DialogDimensionLabels::DimensionValue(const MeasurementDimension_p &dimension, int value) auto DialogDimensionLabels::DimensionValue(const MeasurementDimension_p &dimension, qreal value) const -> QString
{ {
QStringList labels; QStringList labels;
@ -203,18 +203,19 @@ QString DialogDimensionLabels::DimensionValue(const MeasurementDimension_p &dime
{ {
return QString::number(value); return QString::number(value);
} }
else if (dimension->Type() == MeasurementDimension::Y)
if (dimension->Type() == MeasurementDimension::Y)
{ {
if (dimension->IsCircumference()) if (dimension->IsCircumference())
{ {
return QString::number(m_fullCircumference ? value*2 : value); return QString::number(m_fullCircumference ? value*2 : value);
} }
else
{
return QString::number(value); return QString::number(value);
} }
}
else if (dimension->Type() == MeasurementDimension::W || dimension->Type() == MeasurementDimension::Z) if (dimension->Type() == MeasurementDimension::W || dimension->Type() == MeasurementDimension::Z)
{ {
return QString::number(m_fullCircumference ? value*2 : value); return QString::number(m_fullCircumference ? value*2 : value);
} }

View File

@ -49,7 +49,7 @@ public:
bool fullCircumference, QWidget *parent = nullptr); bool fullCircumference, QWidget *parent = nullptr);
virtual ~DialogDimensionLabels(); virtual ~DialogDimensionLabels();
QMap<MeasurementDimension, DimesionLabels> Labels() const; auto Labels() const -> QMap<MeasurementDimension, DimesionLabels>;
protected: protected:
virtual void changeEvent(QEvent* event) override; virtual void changeEvent(QEvent* event) override;
@ -70,11 +70,11 @@ private:
void InitDimensions(); void InitDimensions();
void InitTable(); void InitTable();
QString DimensionValue(const MeasurementDimension_p &dimension, int value); auto DimensionValue(const MeasurementDimension_p &dimension, qreal value) const -> QString;
}; };
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline QMap<MeasurementDimension, DimesionLabels> DialogDimensionLabels::Labels() const inline auto DialogDimensionLabels::Labels() const -> QMap<MeasurementDimension, DimesionLabels>
{ {
return m_labels; return m_labels;
} }

View File

@ -37,16 +37,16 @@
namespace namespace
{ {
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<int> FilterByMinimum(const QVector<int> &base, int restriction) auto FilterByMinimum(const QVector<qreal> &base, qreal restriction) -> QVector<qreal>
{ {
if (restriction <= 0) if (restriction <= 0)
{ {
return base; return base;
} }
QVector<int> filtered; QVector<qreal> filtered;
filtered.reserve(base.size()); filtered.reserve(base.size());
for(auto &b : base) for(const auto &b : base)
{ {
if (b >= restriction) if (b >= restriction)
{ {
@ -57,16 +57,16 @@ QVector<int> FilterByMinimum(const QVector<int> &base, int restriction)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<int> FilterByMaximum(const QVector<int> &base, int restriction) auto FilterByMaximum(const QVector<qreal> &base, qreal restriction) -> QVector<qreal>
{ {
if (restriction <= 0) if (restriction <= 0)
{ {
return base; return base;
} }
QVector<int> filtered; QVector<qreal> filtered;
filtered.reserve(base.size()); filtered.reserve(base.size());
for(auto &b : base) for(const auto &b : base)
{ {
if (b <= restriction) if (b <= restriction)
{ {
@ -75,11 +75,11 @@ QVector<int> FilterByMaximum(const QVector<int> &base, int restriction)
} }
return filtered; return filtered;
} }
} } // namespace
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
DialogRestrictDimension::DialogRestrictDimension(const QList<MeasurementDimension_p> &dimensions, DialogRestrictDimension::DialogRestrictDimension(const QList<MeasurementDimension_p> &dimensions,
const QMap<QString, QPair<int, int>> &restrictions, const QMap<QString, QPair<qreal, qreal>> &restrictions,
bool oneDimesionRestriction, bool fullCircumference, bool oneDimesionRestriction, bool fullCircumference,
QWidget *parent) : QWidget *parent) :
QDialog(parent), QDialog(parent),
@ -157,15 +157,15 @@ void DialogRestrictDimension::RowSelected()
QTableWidgetItem *item = ui->tableWidget->currentItem(); QTableWidgetItem *item = ui->tableWidget->currentItem();
if (item) if (item != nullptr)
{ {
int base1 = 0; qreal base1 = 0;
int base2 = 0; qreal base2 = 0;
MeasurementDimension_p dimension; MeasurementDimension_p dimension;
if (m_oneDimesionRestriction) if (m_oneDimesionRestriction)
{ {
base1 = item->data(Qt::UserRole).toInt(); base1 = item->data(Qt::UserRole).toDouble();
if (m_dimensions.size() > 1) if (m_dimensions.size() > 1)
{ {
@ -174,8 +174,8 @@ void DialogRestrictDimension::RowSelected()
} }
else else
{ {
base1 = ui->comboBoxDimensionA->currentData().toInt(); base1 = ui->comboBoxDimensionA->currentData().toDouble();
base2 = item->data(Qt::UserRole).toInt(); base2 = item->data(Qt::UserRole).toDouble();
if (m_dimensions.size() > 2) if (m_dimensions.size() > 2)
{ {
@ -183,19 +183,19 @@ void DialogRestrictDimension::RowSelected()
} }
} }
QPair<int, int> restriction = m_restrictions.value(VMeasurement::CorrectionHash(base1, base2), QPair<qreal, qreal> restriction = m_restrictions.value(VMeasurement::CorrectionHash(base1, base2),
QPair<int, int>(0, 0)); QPair<qreal, qreal>(0, 0));
if (dimension.isNull()) if (dimension.isNull())
{ {
return; return;
} }
const QVector<int> bases = dimension->ValidBases(); const QVector<qreal> bases = dimension->ValidBases();
ui->comboBoxMin->blockSignals(true); ui->comboBoxMin->blockSignals(true);
ui->comboBoxMin->clear(); ui->comboBoxMin->clear();
QVector<int> filtered = FilterByMaximum(bases, restriction.second); QVector<qreal> filtered = FilterByMaximum(bases, restriction.second);
FillBases(filtered, dimension, ui->comboBoxMin); FillBases(filtered, dimension, ui->comboBoxMin);
int index = ui->comboBoxMin->findData(restriction.first); int index = ui->comboBoxMin->findData(restriction.first);
ui->comboBoxMin->setCurrentIndex(index != -1 ? index : 0); ui->comboBoxMin->setCurrentIndex(index != -1 ? index : 0);
@ -224,25 +224,25 @@ void DialogRestrictDimension::MinRestrictionChanged()
{ {
QTableWidgetItem *item = ui->tableWidget->currentItem(); QTableWidgetItem *item = ui->tableWidget->currentItem();
if (item) if (item != nullptr)
{ {
int base1 = 0; qreal base1 = 0;
int base2 = 0; qreal base2 = 0;
if (m_oneDimesionRestriction) if (m_oneDimesionRestriction)
{ {
base1 = item->data(Qt::UserRole).toInt(); base1 = item->data(Qt::UserRole).toDouble();
} }
else else
{ {
base1 = ui->comboBoxDimensionA->currentData().toInt(); base1 = ui->comboBoxDimensionA->currentData().toDouble();
base2 = item->data(Qt::UserRole).toInt(); base2 = item->data(Qt::UserRole).toDouble();
} }
const QString coordinates = VMeasurement::CorrectionHash(base1, base2); const QString coordinates = VMeasurement::CorrectionHash(base1, base2);
QPair<int, int> restriction = m_restrictions.value(coordinates, QPair<int, int>(0, 0)); QPair<qreal, qreal> restriction = m_restrictions.value(coordinates, QPair<qreal, qreal>(0, 0));
restriction.first = ui->comboBoxMin->currentData().toInt(); restriction.first = ui->comboBoxMin->currentData().toDouble();
m_restrictions.insert(coordinates, restriction); m_restrictions.insert(coordinates, restriction);
const int currentRow = ui->tableWidget->currentRow(); const int currentRow = ui->tableWidget->currentRow();
@ -261,25 +261,25 @@ void DialogRestrictDimension::MaxRestrictionChanged()
{ {
QTableWidgetItem *item = ui->tableWidget->currentItem(); QTableWidgetItem *item = ui->tableWidget->currentItem();
if (item) if (item != nullptr)
{ {
int base1 = 0; qreal base1 = 0;
int base2 = 0; qreal base2 = 0;
if (m_oneDimesionRestriction) if (m_oneDimesionRestriction)
{ {
base1 = item->data(Qt::UserRole).toInt(); base1 = item->data(Qt::UserRole).toDouble();
} }
else else
{ {
base1 = ui->comboBoxDimensionA->currentData().toInt(); base1 = ui->comboBoxDimensionA->currentData().toDouble();
base2 = item->data(Qt::UserRole).toInt(); base2 = item->data(Qt::UserRole).toDouble();
} }
const QString coordinates = VMeasurement::CorrectionHash(base1, base2); const QString coordinates = VMeasurement::CorrectionHash(base1, base2);
QPair<int, int> restriction = m_restrictions.value(coordinates, QPair<int, int>(0, 0)); QPair<qreal, qreal> restriction = m_restrictions.value(coordinates, QPair<qreal, qreal>(0, 0));
restriction.second = ui->comboBoxMax->currentData().toInt(); restriction.second = ui->comboBoxMax->currentData().toDouble();
m_restrictions.insert(coordinates, restriction); m_restrictions.insert(coordinates, restriction);
const int currentRow = ui->tableWidget->currentRow(); const int currentRow = ui->tableWidget->currentRow();
@ -304,7 +304,6 @@ void DialogRestrictDimension::InitDimensionsBaseValues()
if (m_dimensions.size() > index) if (m_dimensions.size() > index)
{ {
MeasurementDimension_p dimension = m_dimensions.at(index); MeasurementDimension_p dimension = m_dimensions.at(index);
const QString unit = UnitsToStr(dimension->Units(), true);
name->setText(VAbstartMeasurementDimension::DimensionName(dimension->Type())+QChar(':')); name->setText(VAbstartMeasurementDimension::DimensionName(dimension->Type())+QChar(':'));
name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension->Type(), name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension->Type(),
dimension->IsCircumference(), dimension->IsCircumference(),
@ -316,7 +315,7 @@ void DialogRestrictDimension::InitDimensionsBaseValues()
if (not m_oneDimesionRestriction) if (not m_oneDimesionRestriction)
{ {
if (m_dimensions.size() > 0) if (not m_dimensions.empty())
{ {
DimensionsBaseValue(0, ui->labelDimensionA, ui->comboBoxDimensionA); DimensionsBaseValue(0, ui->labelDimensionA, ui->comboBoxDimensionA);
} }
@ -338,10 +337,10 @@ void DialogRestrictDimension::InitDimensionGradation(const MeasurementDimension_
{ {
SCASSERT(control != nullptr) SCASSERT(control != nullptr)
int current = -1; qreal current = -1;
if (control->currentIndex() != -1) if (control->currentIndex() != -1)
{ {
current = control->currentData().toInt(); current = control->currentData().toDouble();
} }
control->blockSignals(true); control->blockSignals(true);
@ -373,12 +372,12 @@ void DialogRestrictDimension::InitTable()
if (m_dimensions.size() > index) if (m_dimensions.size() > index)
{ {
MeasurementDimension_p dimensionA = m_dimensions.at(index-1); MeasurementDimension_p dimensionA = m_dimensions.at(index-1);
const QVector<int> basesA = dimensionA->ValidBases(); const QVector<qreal> basesA = dimensionA->ValidBases();
ui->tableWidget->setRowCount(basesA.size()); ui->tableWidget->setRowCount(basesA.size());
ui->tableWidget->setVerticalHeaderLabels(DimensionLabels(basesA, dimensionA)); ui->tableWidget->setVerticalHeaderLabels(DimensionLabels(basesA, dimensionA));
MeasurementDimension_p dimensionB = m_dimensions.at(index); MeasurementDimension_p dimensionB = m_dimensions.at(index);
const QVector<int> basesB = dimensionB->ValidBases(); const QVector<qreal> basesB = dimensionB->ValidBases();
ui->tableWidget->setColumnCount(basesB.size()); ui->tableWidget->setColumnCount(basesB.size());
ui->tableWidget->setHorizontalHeaderLabels(DimensionLabels(basesB, dimensionB)); ui->tableWidget->setHorizontalHeaderLabels(DimensionLabels(basesB, dimensionB));
} }
@ -394,8 +393,8 @@ void DialogRestrictDimension::InitTable()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogRestrictDimension::RefreshTable() void DialogRestrictDimension::RefreshTable()
{ {
QVector<int> basesRow; QVector<qreal> basesRow;
QVector<int> basesColumn; QVector<qreal> basesColumn;
if (m_oneDimesionRestriction) if (m_oneDimesionRestriction)
{ {
@ -446,15 +445,15 @@ void DialogRestrictDimension::RefreshTable()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogRestrictDimension::AddCell(int row, int column, int rowValue, int columnValue) void DialogRestrictDimension::AddCell(int row, int column, qreal rowValue, qreal columnValue)
{ {
auto *item = new QTableWidgetItem(); auto *item = new QTableWidgetItem();
item->setData(Qt::UserRole, rowValue); item->setData(Qt::UserRole, rowValue);
int base1 = 0; qreal base1 = 0;
int base2 = 0; qreal base2 = 0;
MeasurementDimension_p dimension; MeasurementDimension_p dimension;
QVector<int> bases; QVector<qreal> bases;
if (m_oneDimesionRestriction) if (m_oneDimesionRestriction)
{ {
@ -468,7 +467,7 @@ void DialogRestrictDimension::AddCell(int row, int column, int rowValue, int col
} }
else else
{ {
base1 = ui->comboBoxDimensionA->currentData().toInt(); base1 = ui->comboBoxDimensionA->currentData().toDouble();
base2 = rowValue; base2 = rowValue;
if (m_dimensions.size() >= 3) if (m_dimensions.size() >= 3)
@ -478,10 +477,10 @@ void DialogRestrictDimension::AddCell(int row, int column, int rowValue, int col
} }
} }
QPair<int, int> restriction = m_restrictions.value(VMeasurement::CorrectionHash(base1, base2), QPair<qreal, qreal> restriction = m_restrictions.value(VMeasurement::CorrectionHash(base1, base2),
QPair<int, int>(0, 0)); QPair<qreal, qreal>(0, 0));
int min = INT32_MIN; qreal min = INT32_MIN;
int max = INT32_MAX; qreal max = INT32_MAX;
if (not dimension.isNull()) if (not dimension.isNull())
{ {
@ -500,11 +499,11 @@ void DialogRestrictDimension::AddCell(int row, int column, int rowValue, int col
if (leftRestriction && rightRestriction) if (leftRestriction && rightRestriction)
{ {
item->setIcon(QIcon("://icon/24x24/star.png")); item->setIcon(QIcon(QStringLiteral("://icon/24x24/star.png")));
} }
else else
{ {
item->setIcon(QIcon("://icon/24x24/close.png")); item->setIcon(QIcon(QStringLiteral("://icon/24x24/close.png")));
} }
// set the item non-editable (view only), and non-selectable // set the item non-editable (view only), and non-selectable
@ -533,8 +532,8 @@ void DialogRestrictDimension::EnableRestrictionControls(bool enable)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogRestrictDimension::FillBases(const QVector<int> &bases, const MeasurementDimension_p &dimension, void DialogRestrictDimension::FillBases(const QVector<qreal> &bases, const MeasurementDimension_p &dimension,
QComboBox *control) QComboBox *control) const
{ {
SCASSERT(control != nullptr) SCASSERT(control != nullptr)
@ -551,7 +550,7 @@ void DialogRestrictDimension::FillBases(const QVector<int> &bases, const Measure
} }
else else
{ {
control->addItem(QString("%1 %2").arg(base).arg(units), base); control->addItem(QStringLiteral("%1 %2").arg(base).arg(units), base);
} }
} }
} }
@ -567,7 +566,7 @@ void DialogRestrictDimension::FillBases(const QVector<int> &bases, const Measure
{ {
if (dimension->IsCircumference()) if (dimension->IsCircumference())
{ {
control->addItem(QString("%1 %2").arg(m_fullCircumference ? base*2 : base).arg(units), base); control->addItem(QStringLiteral("%1 %2").arg(m_fullCircumference ? base*2 : base).arg(units), base);
} }
else else
{ {
@ -586,14 +585,15 @@ void DialogRestrictDimension::FillBases(const QVector<int> &bases, const Measure
} }
else else
{ {
control->addItem(QString("%1 %2").arg(m_fullCircumference ? base*2 : base).arg(units), base); control->addItem(QStringLiteral("%1 %2").arg(m_fullCircumference ? base*2 : base).arg(units), base);
} }
} }
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QStringList DialogRestrictDimension::DimensionLabels(const QVector<int> &bases, const MeasurementDimension_p &dimension) auto DialogRestrictDimension::DimensionLabels(const QVector<qreal> &bases,
const MeasurementDimension_p &dimension) const -> QStringList
{ {
const bool showUnits = dimension->IsCircumference() || dimension->Type() == MeasurementDimension::X; const bool showUnits = dimension->IsCircumference() || dimension->Type() == MeasurementDimension::X;
const QString units = showUnits ? UnitsToStr(dimension->Units(), true) : QString(); const QString units = showUnits ? UnitsToStr(dimension->Units(), true) : QString();
@ -611,7 +611,7 @@ QStringList DialogRestrictDimension::DimensionLabels(const QVector<int> &bases,
} }
else else
{ {
labels.append(QString("%1 %2").arg(base).arg(units)); labels.append(QStringLiteral("%1 %2").arg(base).arg(units));
} }
} }
} }
@ -627,7 +627,7 @@ QStringList DialogRestrictDimension::DimensionLabels(const QVector<int> &bases,
{ {
if (dimension->IsCircumference()) if (dimension->IsCircumference())
{ {
labels.append(QString("%1 %2").arg(m_fullCircumference ? base*2 : base).arg(units)); labels.append(QStringLiteral("%1 %2").arg(m_fullCircumference ? base*2 : base).arg(units));
} }
else else
{ {
@ -646,7 +646,7 @@ QStringList DialogRestrictDimension::DimensionLabels(const QVector<int> &bases,
} }
else else
{ {
labels.append(QString("%1 %2").arg(m_fullCircumference ? base*2 : base).arg(units)); labels.append(QStringLiteral("%1 %2").arg(m_fullCircumference ? base*2 : base).arg(units));
} }
} }
} }

View File

@ -47,11 +47,11 @@ class DialogRestrictDimension : public QDialog
public: public:
DialogRestrictDimension(const QList<MeasurementDimension_p> &dimensions, DialogRestrictDimension(const QList<MeasurementDimension_p> &dimensions,
const QMap<QString, QPair<int, int>> &restrictions, bool oneDimesionRestriction, const QMap<QString, QPair<qreal, qreal>> &restrictions, bool oneDimesionRestriction,
bool fullCircumference, QWidget *parent = nullptr); bool fullCircumference, QWidget *parent = nullptr);
virtual ~DialogRestrictDimension(); virtual ~DialogRestrictDimension();
QMap<QString, QPair<int, int> > Restrictions() const; auto Restrictions() const -> QMap<QString, QPair<qreal, qreal> >;
protected: protected:
virtual void changeEvent(QEvent* event) override; virtual void changeEvent(QEvent* event) override;
@ -69,7 +69,7 @@ private:
bool m_oneDimesionRestriction; bool m_oneDimesionRestriction;
bool m_fullCircumference; bool m_fullCircumference;
QList<MeasurementDimension_p> m_dimensions; QList<MeasurementDimension_p> m_dimensions;
QMap<QString, QPair<int, int>> m_restrictions; QMap<QString, QPair<qreal, qreal>> m_restrictions;
void InitDimensionsBaseValues(); void InitDimensionsBaseValues();
void InitDimensionGradation(const MeasurementDimension_p &dimension, QComboBox *control); void InitDimensionGradation(const MeasurementDimension_p &dimension, QComboBox *control);
@ -77,17 +77,17 @@ private:
void RefreshTable(); void RefreshTable();
void AddCell(int row, int column, int rowValue, int columnValue); void AddCell(int row, int column, qreal rowValue, qreal columnValue);
void EnableRestrictionControls(bool enable); void EnableRestrictionControls(bool enable);
void FillBases(const QVector<int> &bases, const MeasurementDimension_p &dimension, QComboBox *control); void FillBases(const QVector<qreal> &bases, const MeasurementDimension_p &dimension, QComboBox *control) const;
QStringList DimensionLabels(const QVector<int> &bases, const MeasurementDimension_p &dimension); auto DimensionLabels(const QVector<qreal> &bases, const MeasurementDimension_p &dimension) const -> QStringList;
}; };
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline QMap<QString, QPair<int, int> > DialogRestrictDimension::Restrictions() const inline auto DialogRestrictDimension::Restrictions() const -> QMap<QString, QPair<qreal, qreal> >
{ {
return m_restrictions; return m_restrictions;
} }

View File

@ -54,16 +54,16 @@ DialogSetupMultisize::DialogSetupMultisize(Unit unit, QWidget *parent) :
InitZDimension(); InitZDimension();
// height // height
connect(ui->spinBoxXDimensionMinValue, QOverload<int>::of(&QSpinBox::valueChanged), connect(ui->doubleSpinBoxXDimensionMinValue, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
this, [this](int value) this, [this](qreal value)
{ {
DimensionMinValueChanged(value, ui->spinBoxXDimensionMaxValue, ui->comboBoxXDimensionStep, DimensionMinValueChanged(value, ui->doubleSpinBoxXDimensionMaxValue, ui->comboBoxXDimensionStep,
ui->comboBoxXDimensionBase, m_xDimension); ui->comboBoxXDimensionBase, m_xDimension);
}); });
connect(ui->spinBoxXDimensionMaxValue, QOverload<int>::of(&QSpinBox::valueChanged), connect(ui->doubleSpinBoxXDimensionMaxValue, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
this, [this](int value) this, [this](qreal value)
{ {
DimensionMaxValueChanged(value, ui->spinBoxXDimensionMinValue, ui->comboBoxXDimensionStep, DimensionMaxValueChanged(value, ui->doubleSpinBoxXDimensionMinValue, ui->comboBoxXDimensionStep,
ui->comboBoxXDimensionBase, m_xDimension); ui->comboBoxXDimensionBase, m_xDimension);
}); });
connect(ui->comboBoxXDimensionStep, QOverload<int>::of(&QComboBox::currentIndexChanged), connect(ui->comboBoxXDimensionStep, QOverload<int>::of(&QComboBox::currentIndexChanged),
@ -78,16 +78,16 @@ DialogSetupMultisize::DialogSetupMultisize(Unit unit, QWidget *parent) :
}); });
// size // size
connect(ui->spinBoxYDimensionMinValue, QOverload<int>::of(&QSpinBox::valueChanged), connect(ui->doubleSpinBoxYDimensionMinValue, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
this, [this](int value) this, [this](qreal value)
{ {
DimensionMinValueChanged(value, ui->spinBoxYDimensionMaxValue, ui->comboBoxYDimensionStep, DimensionMinValueChanged(value, ui->doubleSpinBoxYDimensionMaxValue, ui->comboBoxYDimensionStep,
ui->comboBoxYDimensionBase, m_yDimension); ui->comboBoxYDimensionBase, m_yDimension);
}); });
connect(ui->spinBoxYDimensionMaxValue, QOverload<int>::of(&QSpinBox::valueChanged), connect(ui->doubleSpinBoxYDimensionMaxValue, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
this, [this](int value) this, [this](qreal value)
{ {
DimensionMaxValueChanged(value, ui->spinBoxYDimensionMinValue, ui->comboBoxYDimensionStep, DimensionMaxValueChanged(value, ui->doubleSpinBoxYDimensionMinValue, ui->comboBoxYDimensionStep,
ui->comboBoxYDimensionBase, m_yDimension); ui->comboBoxYDimensionBase, m_yDimension);
}); });
connect(ui->comboBoxYDimensionStep, QOverload<int>::of(&QComboBox::currentIndexChanged), connect(ui->comboBoxYDimensionStep, QOverload<int>::of(&QComboBox::currentIndexChanged),
@ -102,16 +102,16 @@ DialogSetupMultisize::DialogSetupMultisize(Unit unit, QWidget *parent) :
}); });
// hip // hip
connect(ui->spinBoxWDimensionMinValue, QOverload<int>::of(&QSpinBox::valueChanged), connect(ui->doubleSpinBoxWDimensionMinValue, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
this, [this](int value) this, [this](qreal value)
{ {
DimensionMinValueChanged(value, ui->spinBoxWDimensionMaxValue, ui->comboBoxWDimensionStep, DimensionMinValueChanged(value, ui->doubleSpinBoxWDimensionMaxValue, ui->comboBoxWDimensionStep,
ui->comboBoxWDimensionBase, m_wDimension); ui->comboBoxWDimensionBase, m_wDimension);
}); });
connect(ui->spinBoxWDimensionMaxValue, QOverload<int>::of(&QSpinBox::valueChanged), connect(ui->doubleSpinBoxWDimensionMaxValue, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
this, [this](int value) this, [this](qreal value)
{ {
DimensionMaxValueChanged(value, ui->spinBoxWDimensionMinValue, ui->comboBoxWDimensionStep, DimensionMaxValueChanged(value, ui->doubleSpinBoxWDimensionMinValue, ui->comboBoxWDimensionStep,
ui->comboBoxWDimensionBase, m_wDimension); ui->comboBoxWDimensionBase, m_wDimension);
}); });
connect(ui->comboBoxWDimensionStep, QOverload<int>::of(&QComboBox::currentIndexChanged), connect(ui->comboBoxWDimensionStep, QOverload<int>::of(&QComboBox::currentIndexChanged),
@ -126,16 +126,16 @@ DialogSetupMultisize::DialogSetupMultisize(Unit unit, QWidget *parent) :
}); });
// waist // waist
connect(ui->spinBoxZDimensionMinValue, QOverload<int>::of(&QSpinBox::valueChanged), connect(ui->doubleSpinBoxZDimensionMinValue, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
this, [this](int value) this, [this](qreal value)
{ {
DimensionMinValueChanged(value, ui->spinBoxZDimensionMaxValue, ui->comboBoxZDimensionStep, DimensionMinValueChanged(value, ui->doubleSpinBoxZDimensionMaxValue, ui->comboBoxZDimensionStep,
ui->comboBoxZDimensionBase, m_zDimension); ui->comboBoxZDimensionBase, m_zDimension);
}); });
connect(ui->spinBoxZDimensionMaxValue, QOverload<int>::of(&QSpinBox::valueChanged), connect(ui->doubleSpinBoxZDimensionMaxValue, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
this, [this](int value) this, [this](qreal value)
{ {
DimensionMaxValueChanged(value, ui->spinBoxZDimensionMinValue, ui->comboBoxZDimensionStep, DimensionMaxValueChanged(value, ui->doubleSpinBoxZDimensionMinValue, ui->comboBoxZDimensionStep,
ui->comboBoxZDimensionBase, m_zDimension); ui->comboBoxZDimensionBase, m_zDimension);
}); });
connect(ui->comboBoxZDimensionStep, QOverload<int>::of(&QComboBox::currentIndexChanged), connect(ui->comboBoxZDimensionStep, QOverload<int>::of(&QComboBox::currentIndexChanged),
@ -170,7 +170,7 @@ DialogSetupMultisize::~DialogSetupMultisize()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<MeasurementDimension_p> DialogSetupMultisize::Dimensions() const auto DialogSetupMultisize::Dimensions() const -> QVector<MeasurementDimension_p>
{ {
QVector<MeasurementDimension_p> dimensions; QVector<MeasurementDimension_p> dimensions;
@ -198,7 +198,7 @@ QVector<MeasurementDimension_p> DialogSetupMultisize::Dimensions() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool DialogSetupMultisize::FullCircumference() const auto DialogSetupMultisize::FullCircumference() const -> bool
{ {
return ui->checkBoxFullCircumference->isChecked(); return ui->checkBoxFullCircumference->isChecked();
} }
@ -240,16 +240,16 @@ void DialogSetupMultisize::showEvent(QShowEvent *event)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSetupMultisize::ShowFullCircumference() void DialogSetupMultisize::ShowFullCircumference()
{ {
auto ShowDimensionFullCircumference = [this](QSpinBox *spinboxMinValue, QSpinBox *spinboxMaxValue, auto ShowDimensionFullCircumference = [this](QDoubleSpinBox *doubleSpinBoxMinValue,
QComboBox *comboBoxStep, QComboBox *comboBoxBase, QDoubleSpinBox *doubleSpinBoxMaxValue, QComboBox *comboBoxStep, QComboBox *comboBoxBase,
const MeasurementDimension_p &dimension) const MeasurementDimension_p &dimension)
{ {
SCASSERT(spinboxMinValue != nullptr) SCASSERT(doubleSpinBoxMinValue != nullptr)
SCASSERT(spinboxMaxValue != nullptr) SCASSERT(doubleSpinBoxMaxValue != nullptr)
SCASSERT(comboBoxStep != nullptr) SCASSERT(comboBoxStep != nullptr)
SCASSERT(comboBoxBase != nullptr) SCASSERT(comboBoxBase != nullptr)
InitDimension(spinboxMinValue, spinboxMaxValue, comboBoxStep, dimension); InitDimension(doubleSpinBoxMinValue, doubleSpinBoxMaxValue, comboBoxStep, dimension);
UpdateBase(comboBoxBase, dimension); UpdateBase(comboBoxBase, dimension);
comboBoxBase->blockSignals(true); comboBoxBase->blockSignals(true);
@ -257,11 +257,11 @@ void DialogSetupMultisize::ShowFullCircumference()
comboBoxBase->blockSignals(false); comboBoxBase->blockSignals(false);
}; };
ShowDimensionFullCircumference(ui->spinBoxYDimensionMinValue, ui->spinBoxYDimensionMaxValue, ShowDimensionFullCircumference(ui->doubleSpinBoxYDimensionMinValue, ui->doubleSpinBoxYDimensionMaxValue,
ui->comboBoxYDimensionStep, ui->comboBoxYDimensionBase, m_yDimension); ui->comboBoxYDimensionStep, ui->comboBoxYDimensionBase, m_yDimension);
ShowDimensionFullCircumference(ui->spinBoxWDimensionMinValue, ui->spinBoxWDimensionMaxValue, ShowDimensionFullCircumference(ui->doubleSpinBoxWDimensionMinValue, ui->doubleSpinBoxWDimensionMaxValue,
ui->comboBoxWDimensionStep, ui->comboBoxWDimensionBase, m_wDimension); ui->comboBoxWDimensionStep, ui->comboBoxWDimensionBase, m_wDimension);
ShowDimensionFullCircumference(ui->spinBoxZDimensionMinValue, ui->spinBoxZDimensionMaxValue, ShowDimensionFullCircumference(ui->doubleSpinBoxZDimensionMinValue, ui->doubleSpinBoxZDimensionMaxValue,
ui->comboBoxZDimensionStep, ui->comboBoxZDimensionBase, m_zDimension); ui->comboBoxZDimensionStep, ui->comboBoxZDimensionBase, m_zDimension);
CheckState(); CheckState();
@ -276,10 +276,10 @@ void DialogSetupMultisize::YDimensionCircumferenceChanged()
const bool c = m_yDimension->IsCircumference(); const bool c = m_yDimension->IsCircumference();
const QString unitStr = c ? " " + UnitsToStr(m_yDimension->Units()) : QString(); const QString unitStr = c ? " " + UnitsToStr(m_yDimension->Units()) : QString();
ui->spinBoxYDimensionMinValue->setSuffix(unitStr); ui->doubleSpinBoxYDimensionMinValue->setSuffix(unitStr);
ui->spinBoxYDimensionMaxValue->setSuffix(unitStr); ui->doubleSpinBoxYDimensionMaxValue->setSuffix(unitStr);
InitDimension(ui->spinBoxYDimensionMinValue, ui->spinBoxYDimensionMaxValue, ui->comboBoxYDimensionStep, InitDimension(ui->doubleSpinBoxYDimensionMinValue, ui->doubleSpinBoxYDimensionMaxValue, ui->comboBoxYDimensionStep,
m_yDimension); m_yDimension);
UpdateBase(ui->comboBoxYDimensionBase, m_yDimension); UpdateBase(ui->comboBoxYDimensionBase, m_yDimension);
@ -289,7 +289,7 @@ void DialogSetupMultisize::YDimensionCircumferenceChanged()
ui->comboBoxYDimensionBase->blockSignals(false); ui->comboBoxYDimensionBase->blockSignals(false);
bool ok = false; bool ok = false;
const int base = ui->comboBoxYDimensionBase->currentData().toInt(&ok); const qreal base = ui->comboBoxYDimensionBase->currentData().toDouble(&ok);
m_yDimension->SetBaseValue(ok ? base : -1); m_yDimension->SetBaseValue(ok ? base : -1);
CheckState(); CheckState();
@ -351,11 +351,12 @@ void DialogSetupMultisize::CheckState()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSetupMultisize::InitDimensionMinMax(QSpinBox *spinboxMinValue, QSpinBox *spinboxMaxValue, void DialogSetupMultisize::InitDimensionMinMax(QDoubleSpinBox *doubleSpinBoxMinValue,
QDoubleSpinBox *doubleSpinBoxMaxValue,
const MeasurementDimension_p &dimension) const MeasurementDimension_p &dimension)
{ {
SCASSERT(spinboxMinValue != nullptr) SCASSERT(doubleSpinBoxMinValue != nullptr)
SCASSERT(spinboxMaxValue != nullptr) SCASSERT(doubleSpinBoxMaxValue != nullptr)
dimension->SetMinValue(dimension->RangeMin()); dimension->SetMinValue(dimension->RangeMin());
dimension->SetMaxValue(dimension->RangeMax()); dimension->SetMaxValue(dimension->RangeMax());
@ -363,28 +364,31 @@ void DialogSetupMultisize::InitDimensionMinMax(QSpinBox *spinboxMinValue, QSpinB
const bool fc = ui->checkBoxFullCircumference->isChecked(); const bool fc = ui->checkBoxFullCircumference->isChecked();
const bool c = dimension->IsCircumference(); const bool c = dimension->IsCircumference();
spinboxMinValue->blockSignals(true); doubleSpinBoxMinValue->blockSignals(true);
const QString unitStr = " " + UnitsToStr(dimension->Units()); const QString unitStr = " " + UnitsToStr(dimension->Units());
if (c || dimension->Type() == MeasurementDimension::X) if (c || dimension->Type() == MeasurementDimension::X)
{ {
spinboxMinValue->setSuffix(unitStr); doubleSpinBoxMinValue->setSuffix(unitStr);
} }
spinboxMinValue->setMinimum(c && fc ? dimension->RangeMin()*2 : dimension->RangeMin()); doubleSpinBoxMinValue->setDecimals(dimension->Units() == Unit::Mm ? 0 : 1);
spinboxMinValue->setMaximum(c && fc ? dimension->MaxValue()*2 : dimension->MaxValue()); doubleSpinBoxMinValue->setMinimum(c && fc ? dimension->RangeMin()*2 : dimension->RangeMin());
spinboxMinValue->setValue(c && fc ? dimension->MinValue()*2 : dimension->MinValue()); doubleSpinBoxMinValue->setMaximum(c && fc ? dimension->MaxValue()*2 : dimension->MaxValue());
spinboxMinValue->blockSignals(false); doubleSpinBoxMinValue->setValue(c && fc ? dimension->MinValue()*2 : dimension->MinValue());
doubleSpinBoxMinValue->blockSignals(false);
spinboxMaxValue->blockSignals(true); doubleSpinBoxMaxValue->blockSignals(true);
if (c || dimension->Type() == MeasurementDimension::X) if (c || dimension->Type() == MeasurementDimension::X)
{ {
spinboxMaxValue->setSuffix(unitStr); doubleSpinBoxMaxValue->setSuffix(unitStr);
} }
spinboxMaxValue->setMinimum(c && fc ? dimension->MinValue()*2 : dimension->MinValue());
spinboxMaxValue->setMaximum(c && fc ? dimension->RangeMax()*2 : dimension->RangeMax()); doubleSpinBoxMaxValue->setDecimals(dimension->Units() == Unit::Mm ? 0 : 1);
spinboxMaxValue->setValue(c && fc ? dimension->RangeMax()*2 : dimension->RangeMax()); doubleSpinBoxMaxValue->setMinimum(c && fc ? dimension->MinValue()*2 : dimension->MinValue());
spinboxMaxValue->setValue(c && fc ? dimension->MaxValue()*2 : dimension->MaxValue()); doubleSpinBoxMaxValue->setMaximum(c && fc ? dimension->RangeMax()*2 : dimension->RangeMax());
spinboxMaxValue->blockSignals(false); doubleSpinBoxMaxValue->setValue(c && fc ? dimension->RangeMax()*2 : dimension->RangeMax());
doubleSpinBoxMaxValue->setValue(c && fc ? dimension->MaxValue()*2 : dimension->MaxValue());
doubleSpinBoxMaxValue->blockSignals(false);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -400,11 +404,11 @@ void DialogSetupMultisize::InitDimensionStep(QComboBox *comboBoxStep,
dimension->SetStep(-1); dimension->SetStep(-1);
comboBoxStep->blockSignals(true); comboBoxStep->blockSignals(true);
const QVector<int> steps = dimension->ValidSteps(); const QVector<qreal> steps = dimension->ValidSteps();
comboBoxStep->clear(); comboBoxStep->clear();
for(auto step : steps) for(auto step : steps)
{ {
comboBoxStep->addItem(QString("%1%2").arg(c && fc ? step*2 : step) comboBoxStep->addItem(QStringLiteral("%1%2").arg(c && fc ? step*2 : step)
.arg(c || dimension->Type() == MeasurementDimension::X ? unitStr : QString()), step); .arg(c || dimension->Type() == MeasurementDimension::X ? unitStr : QString()), step);
} }
@ -412,52 +416,52 @@ void DialogSetupMultisize::InitDimensionStep(QComboBox *comboBoxStep,
comboBoxStep->blockSignals(false); comboBoxStep->blockSignals(false);
bool ok = false; bool ok = false;
const int step = comboBoxStep->currentData().toInt(&ok); const qreal step = comboBoxStep->currentData().toDouble(&ok);
dimension->SetStep(ok ? step : -1); dimension->SetStep(ok ? step : -1);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSetupMultisize::InitDimension(QSpinBox *spinboxMinValue, QSpinBox *spinboxMaxValue, QComboBox *comboBoxStep, void DialogSetupMultisize::InitDimension(QDoubleSpinBox *doubleSpinBoxMinValue, QDoubleSpinBox *doubleSpinBoxMaxValue,
const MeasurementDimension_p &dimension) QComboBox *comboBoxStep, const MeasurementDimension_p &dimension)
{ {
InitDimensionMinMax(spinboxMinValue, spinboxMaxValue, dimension); InitDimensionMinMax(doubleSpinBoxMinValue, doubleSpinBoxMaxValue, dimension);
InitDimensionStep(comboBoxStep, dimension); InitDimensionStep(comboBoxStep, dimension);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSetupMultisize::InitXDimension() void DialogSetupMultisize::InitXDimension()
{ {
InitDimension(ui->spinBoxXDimensionMinValue, ui->spinBoxXDimensionMaxValue, ui->comboBoxXDimensionStep, InitDimension(ui->doubleSpinBoxXDimensionMinValue, ui->doubleSpinBoxXDimensionMaxValue, ui->comboBoxXDimensionStep,
m_xDimension); m_xDimension);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSetupMultisize::InitYDimension() void DialogSetupMultisize::InitYDimension()
{ {
InitDimension(ui->spinBoxYDimensionMinValue, ui->spinBoxYDimensionMaxValue, ui->comboBoxYDimensionStep, InitDimension(ui->doubleSpinBoxYDimensionMinValue, ui->doubleSpinBoxYDimensionMaxValue, ui->comboBoxYDimensionStep,
m_yDimension); m_yDimension);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSetupMultisize::InitWDimension() void DialogSetupMultisize::InitWDimension()
{ {
InitDimension(ui->spinBoxWDimensionMinValue, ui->spinBoxWDimensionMaxValue, ui->comboBoxWDimensionStep, InitDimension(ui->doubleSpinBoxWDimensionMinValue, ui->doubleSpinBoxWDimensionMaxValue, ui->comboBoxWDimensionStep,
m_wDimension); m_wDimension);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSetupMultisize::InitZDimension() void DialogSetupMultisize::InitZDimension()
{ {
InitDimension(ui->spinBoxZDimensionMinValue, ui->spinBoxZDimensionMaxValue, ui->comboBoxZDimensionStep, InitDimension(ui->doubleSpinBoxZDimensionMinValue, ui->doubleSpinBoxZDimensionMaxValue, ui->comboBoxZDimensionStep,
m_zDimension); m_zDimension);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSetupMultisize::DimensionMinValueChanged(int value, QSpinBox *spinboxMaxValue, QComboBox *comboBoxStep, void DialogSetupMultisize::DimensionMinValueChanged(qreal value, QDoubleSpinBox *doubleSpinBoxMaxValue,
QComboBox *comboBoxBase, QComboBox *comboBoxStep, QComboBox *comboBoxBase,
const MeasurementDimension_p &dimension) const MeasurementDimension_p &dimension)
{ {
SCASSERT(spinboxMaxValue != nullptr) SCASSERT(doubleSpinBoxMaxValue != nullptr)
SCASSERT(comboBoxStep != nullptr) SCASSERT(comboBoxStep != nullptr)
SCASSERT(comboBoxBase != nullptr) SCASSERT(comboBoxBase != nullptr)
@ -466,11 +470,11 @@ void DialogSetupMultisize::DimensionMinValueChanged(int value, QSpinBox *spinbox
dimension->SetMinValue(c && fc ? value / 2 : value); dimension->SetMinValue(c && fc ? value / 2 : value);
spinboxMaxValue->blockSignals(true); doubleSpinBoxMaxValue->blockSignals(true);
spinboxMaxValue->setMinimum(value); doubleSpinBoxMaxValue->setMinimum(value);
spinboxMaxValue->blockSignals(false); doubleSpinBoxMaxValue->blockSignals(false);
dimension->SetMaxValue(c && fc ? spinboxMaxValue->value() / 2 : spinboxMaxValue->value()); dimension->SetMaxValue(c && fc ? doubleSpinBoxMaxValue->value() / 2 : doubleSpinBoxMaxValue->value());
UpdateSteps(comboBoxStep, dimension); UpdateSteps(comboBoxStep, dimension);
UpdateBase(comboBoxBase, dimension); UpdateBase(comboBoxBase, dimension);
@ -479,11 +483,11 @@ void DialogSetupMultisize::DimensionMinValueChanged(int value, QSpinBox *spinbox
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSetupMultisize::DimensionMaxValueChanged(int value, QSpinBox *spinboxMinValue, QComboBox *comboBoxStep, void DialogSetupMultisize::DimensionMaxValueChanged(qreal value, QDoubleSpinBox *doubleSpinBoxMinValue,
QComboBox *comboBoxBase, QComboBox *comboBoxStep, QComboBox *comboBoxBase,
const MeasurementDimension_p &dimension) const MeasurementDimension_p &dimension)
{ {
SCASSERT(spinboxMinValue != nullptr) SCASSERT(doubleSpinBoxMinValue != nullptr)
SCASSERT(comboBoxStep != nullptr) SCASSERT(comboBoxStep != nullptr)
SCASSERT(comboBoxBase != nullptr) SCASSERT(comboBoxBase != nullptr)
@ -492,11 +496,11 @@ void DialogSetupMultisize::DimensionMaxValueChanged(int value, QSpinBox *spinbox
dimension->SetMaxValue(c && fc ? value / 2 : value); dimension->SetMaxValue(c && fc ? value / 2 : value);
spinboxMinValue->blockSignals(true); doubleSpinBoxMinValue->blockSignals(true);
spinboxMinValue->setMaximum(value); doubleSpinBoxMinValue->setMaximum(value);
spinboxMinValue->blockSignals(false); doubleSpinBoxMinValue->blockSignals(false);
dimension->SetMinValue(c && fc ? spinboxMinValue->value() / 2 : spinboxMinValue->value()); dimension->SetMinValue(c && fc ? doubleSpinBoxMinValue->value() / 2 : doubleSpinBoxMinValue->value());
UpdateSteps(comboBoxStep, dimension); UpdateSteps(comboBoxStep, dimension);
UpdateBase(comboBoxBase, dimension); UpdateBase(comboBoxBase, dimension);
@ -512,7 +516,7 @@ void DialogSetupMultisize::DimensionStepChanged(int index, QComboBox *comboBoxSt
SCASSERT(comboBoxBase != nullptr) SCASSERT(comboBoxBase != nullptr)
bool ok = false; bool ok = false;
const int step = comboBoxStep->itemData(index).toInt(&ok); const qreal step = comboBoxStep->itemData(index).toDouble(&ok);
dimension->SetStep(ok ? step : -1); dimension->SetStep(ok ? step : -1);
UpdateBase(comboBoxBase, dimension); UpdateBase(comboBoxBase, dimension);
@ -527,7 +531,7 @@ void DialogSetupMultisize::DimensionBaseChanged(int index, QComboBox *comboBoxBa
SCASSERT(comboBoxBase != nullptr) SCASSERT(comboBoxBase != nullptr)
bool ok = false; bool ok = false;
const int base = comboBoxBase->itemData(index).toInt(&ok); const qreal base = comboBoxBase->itemData(index).toDouble(&ok);
dimension->SetBaseValue(ok ? base : -1); dimension->SetBaseValue(ok ? base : -1);
CheckState(); CheckState();
@ -539,16 +543,16 @@ void DialogSetupMultisize::UpdateSteps(QComboBox *comboBoxStep,
{ {
SCASSERT(comboBoxStep != nullptr) SCASSERT(comboBoxStep != nullptr)
int oldStep = -1; qreal oldStep = -1;
if (comboBoxStep->currentIndex() != -1) if (comboBoxStep->currentIndex() != -1)
{ {
oldStep = comboBoxStep->currentData().toInt(); oldStep = comboBoxStep->currentData().toDouble();
} }
comboBoxStep->blockSignals(true); comboBoxStep->blockSignals(true);
const QString unitStr = " " + UnitsToStr(dimension->Units()); const QString unitStr = " " + UnitsToStr(dimension->Units());
const QVector<int> steps = dimension->ValidSteps(); const QVector<qreal> steps = dimension->ValidSteps();
comboBoxStep->clear(); comboBoxStep->clear();
const bool fc = ui->checkBoxFullCircumference->isChecked(); const bool fc = ui->checkBoxFullCircumference->isChecked();
@ -556,7 +560,7 @@ void DialogSetupMultisize::UpdateSteps(QComboBox *comboBoxStep,
for(auto step : steps) for(auto step : steps)
{ {
comboBoxStep->addItem(QString("%1%2").arg(c && fc ? step * 2 : step) comboBoxStep->addItem(QStringLiteral("%1%2").arg(c && fc ? step * 2 : step)
.arg(c ? unitStr : QString()), step); .arg(c ? unitStr : QString()), step);
} }
@ -564,7 +568,7 @@ void DialogSetupMultisize::UpdateSteps(QComboBox *comboBoxStep,
comboBoxStep->blockSignals(false); comboBoxStep->blockSignals(false);
bool ok = false; bool ok = false;
const int step = comboBoxStep->currentData().toInt(&ok); const qreal step = comboBoxStep->currentData().toDouble(&ok);
dimension->SetStep(ok ? step : -1); dimension->SetStep(ok ? step : -1);
} }
@ -574,23 +578,23 @@ void DialogSetupMultisize::UpdateBase(QComboBox *comboBoxBase,
{ {
SCASSERT(comboBoxBase != nullptr) SCASSERT(comboBoxBase != nullptr)
int oldBase = -1; qreal oldBase = -1;
if (comboBoxBase->currentIndex() != -1) if (comboBoxBase->currentIndex() != -1)
{ {
oldBase = comboBoxBase->currentData().toInt(); oldBase = comboBoxBase->currentData().toDouble();
} }
comboBoxBase->blockSignals(true); comboBoxBase->blockSignals(true);
const QString unitStr = " " + UnitsToStr(dimension->Units()); const QString unitStr = " " + UnitsToStr(dimension->Units());
const QVector<int> bases = dimension->ValidBases(); const QVector<qreal> bases = dimension->ValidBases();
comboBoxBase->clear(); comboBoxBase->clear();
const bool fc = ui->checkBoxFullCircumference->isChecked(); const bool fc = ui->checkBoxFullCircumference->isChecked();
const bool c = dimension->IsCircumference(); const bool c = dimension->IsCircumference();
for(auto base : bases) for(auto base : bases)
{ {
comboBoxBase->addItem(QString("%1%2").arg(c && fc ? base * 2 : base) comboBoxBase->addItem(QStringLiteral("%1%2").arg(c && fc ? base * 2 : base)
.arg(c || dimension->Type() == MeasurementDimension::X ? unitStr : QString()), base); .arg(c || dimension->Type() == MeasurementDimension::X ? unitStr : QString()), base);
} }
@ -598,7 +602,7 @@ void DialogSetupMultisize::UpdateBase(QComboBox *comboBoxBase,
comboBoxBase->blockSignals(false); comboBoxBase->blockSignals(false);
bool ok = false; bool ok = false;
const int base = comboBoxBase->currentData().toInt(&ok); const qreal base = comboBoxBase->currentData().toDouble(&ok);
dimension->SetBaseValue(ok ? base : -1); dimension->SetBaseValue(ok ? base : -1);
} }

View File

@ -33,7 +33,7 @@
#include "../vformat/vdimensions.h" #include "../vformat/vdimensions.h"
#include "../vmisc/def.h" #include "../vmisc/def.h"
class QSpinBox; class QDoubleSpinBox;
namespace Ui namespace Ui
{ {
@ -48,9 +48,9 @@ public:
explicit DialogSetupMultisize(Unit unit, QWidget *parent = nullptr); explicit DialogSetupMultisize(Unit unit, QWidget *parent = nullptr);
~DialogSetupMultisize(); ~DialogSetupMultisize();
QVector<MeasurementDimension_p> Dimensions() const; auto Dimensions() const -> QVector<MeasurementDimension_p>;
bool FullCircumference() const; auto FullCircumference() const -> bool;
protected: protected:
virtual void changeEvent(QEvent* event) override; virtual void changeEvent(QEvent* event) override;
@ -71,23 +71,21 @@ private:
void CheckState(); void CheckState();
void InitDimensionMinMax(QSpinBox *spinboxMinValue, QSpinBox *spinboxMaxValue, void InitDimensionMinMax(QDoubleSpinBox *doubleSpinBoxMinValue, QDoubleSpinBox *doubleSpinBoxMaxValue,
const MeasurementDimension_p &dimension); const MeasurementDimension_p &dimension);
void InitDimensionStep(QComboBox *comboBoxStep,const MeasurementDimension_p &dimension); void InitDimensionStep(QComboBox *comboBoxStep,const MeasurementDimension_p &dimension);
void InitDimension(QSpinBox *spinboxMinValue, QSpinBox *spinboxMaxValue, QComboBox *comboBoxStep, void InitDimension(QDoubleSpinBox *doubleSpinBoxMinValue, QDoubleSpinBox *doubleSpinBoxMaxValue,
const MeasurementDimension_p &dimension); QComboBox *comboBoxStep, const MeasurementDimension_p &dimension);
void InitXDimension(); void InitXDimension();
void InitYDimension(); void InitYDimension();
void InitWDimension(); void InitWDimension();
void InitZDimension(); void InitZDimension();
void DimensionMinValueChanged(int value, QSpinBox *spinboxMaxValue, QComboBox *comboBoxStep, void DimensionMinValueChanged(qreal value, QDoubleSpinBox *doubleSpinBoxMaxValue, QComboBox *comboBoxStep,
QComboBox *comboBoxBase, QComboBox *comboBoxBase, const MeasurementDimension_p &dimension);
const MeasurementDimension_p &dimension); void DimensionMaxValueChanged(qreal value, QDoubleSpinBox *doubleSpinBoxMinValue, QComboBox *comboBoxStep,
void DimensionMaxValueChanged(int value, QSpinBox *spinboxMinValue, QComboBox *comboBoxStep, QComboBox *comboBoxBase, const MeasurementDimension_p &dimension);
QComboBox *comboBoxBase,
const MeasurementDimension_p &dimension);
void DimensionStepChanged(int index, QComboBox *comboBoxStep, QComboBox *comboBoxBase, void DimensionStepChanged(int index, QComboBox *comboBoxStep, QComboBox *comboBoxBase,
const MeasurementDimension_p &dimension); const MeasurementDimension_p &dimension);

View File

@ -48,16 +48,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1">
<widget class="QSpinBox" name="spinBoxXDimensionMinValue">
<property name="toolTip">
<string>Minimal value described in the column</string>
</property>
<property name="suffix">
<string/>
</property>
</widget>
</item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
@ -65,13 +55,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<widget class="QSpinBox" name="spinBoxXDimensionMaxValue">
<property name="toolTip">
<string>Maximal value described in the column</string>
</property>
</widget>
</item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="text"> <property name="text">
@ -112,6 +95,26 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxXDimensionMinValue">
<property name="toolTip">
<string>Minimal value described in the column</string>
</property>
<property name="decimals">
<number>1</number>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxXDimensionMaxValue">
<property name="toolTip">
<string>Maximal value described in the column</string>
</property>
<property name="decimals">
<number>1</number>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>
@ -141,13 +144,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1">
<widget class="QSpinBox" name="spinBoxYDimensionMinValue">
<property name="toolTip">
<string>Minimal value described in the column</string>
</property>
</widget>
</item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_6"> <widget class="QLabel" name="label_6">
<property name="text"> <property name="text">
@ -155,13 +151,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<widget class="QSpinBox" name="spinBoxYDimensionMaxValue">
<property name="toolTip">
<string>Maximal value described in the column</string>
</property>
</widget>
</item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="label_7"> <widget class="QLabel" name="label_7">
<property name="text"> <property name="text">
@ -202,6 +191,26 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxYDimensionMinValue">
<property name="toolTip">
<string>Minimal value described in the column</string>
</property>
<property name="decimals">
<number>1</number>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxYDimensionMaxValue">
<property name="toolTip">
<string>Maximal value described in the column</string>
</property>
<property name="decimals">
<number>1</number>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>
@ -241,13 +250,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1">
<widget class="QSpinBox" name="spinBoxWDimensionMinValue">
<property name="toolTip">
<string>Minimal value described in the column</string>
</property>
</widget>
</item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_14"> <widget class="QLabel" name="label_14">
<property name="text"> <property name="text">
@ -255,13 +257,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<widget class="QSpinBox" name="spinBoxWDimensionMaxValue">
<property name="toolTip">
<string>Maximal value described in the column</string>
</property>
</widget>
</item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="label_15"> <widget class="QLabel" name="label_15">
<property name="text"> <property name="text">
@ -302,6 +297,26 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxWDimensionMinValue">
<property name="toolTip">
<string>Minimal value described in the column</string>
</property>
<property name="decimals">
<number>1</number>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxWDimensionMaxValue">
<property name="toolTip">
<string>Maximal value described in the column</string>
</property>
<property name="decimals">
<number>1</number>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>
@ -331,13 +346,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1">
<widget class="QSpinBox" name="spinBoxZDimensionMinValue">
<property name="toolTip">
<string>Minimal value described in the column</string>
</property>
</widget>
</item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_10"> <widget class="QLabel" name="label_10">
<property name="text"> <property name="text">
@ -345,13 +353,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<widget class="QSpinBox" name="spinBoxZDimensionMaxValue">
<property name="toolTip">
<string>Maximal value described in the column</string>
</property>
</widget>
</item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="label_11"> <widget class="QLabel" name="label_11">
<property name="text"> <property name="text">
@ -392,6 +393,26 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxZDimensionMinValue">
<property name="toolTip">
<string>Minimal value described in the column</string>
</property>
<property name="decimals">
<number>1</number>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxZDimensionMaxValue">
<property name="toolTip">
<string>Maximal value described in the column</string>
</property>
<property name="decimals">
<number>1</number>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>
@ -420,23 +441,23 @@
</widget> </widget>
<tabstops> <tabstops>
<tabstop>groupBoxXDimension</tabstop> <tabstop>groupBoxXDimension</tabstop>
<tabstop>spinBoxXDimensionMinValue</tabstop> <tabstop>doubleSpinBoxXDimensionMinValue</tabstop>
<tabstop>spinBoxXDimensionMaxValue</tabstop> <tabstop>doubleSpinBoxXDimensionMaxValue</tabstop>
<tabstop>comboBoxXDimensionStep</tabstop> <tabstop>comboBoxXDimensionStep</tabstop>
<tabstop>comboBoxXDimensionBase</tabstop> <tabstop>comboBoxXDimensionBase</tabstop>
<tabstop>groupBoxYDimension</tabstop> <tabstop>groupBoxYDimension</tabstop>
<tabstop>spinBoxYDimensionMinValue</tabstop> <tabstop>doubleSpinBoxYDimensionMinValue</tabstop>
<tabstop>spinBoxYDimensionMaxValue</tabstop> <tabstop>doubleSpinBoxYDimensionMaxValue</tabstop>
<tabstop>comboBoxYDimensionStep</tabstop> <tabstop>comboBoxYDimensionStep</tabstop>
<tabstop>comboBoxYDimensionBase</tabstop> <tabstop>comboBoxYDimensionBase</tabstop>
<tabstop>groupBoxWDimension</tabstop> <tabstop>groupBoxWDimension</tabstop>
<tabstop>spinBoxWDimensionMinValue</tabstop> <tabstop>doubleSpinBoxWDimensionMinValue</tabstop>
<tabstop>spinBoxWDimensionMaxValue</tabstop> <tabstop>doubleSpinBoxWDimensionMaxValue</tabstop>
<tabstop>comboBoxWDimensionStep</tabstop> <tabstop>comboBoxWDimensionStep</tabstop>
<tabstop>comboBoxWDimensionBase</tabstop> <tabstop>comboBoxWDimensionBase</tabstop>
<tabstop>groupBoxZDimension</tabstop> <tabstop>groupBoxZDimension</tabstop>
<tabstop>spinBoxZDimensionMinValue</tabstop> <tabstop>doubleSpinBoxZDimensionMinValue</tabstop>
<tabstop>spinBoxZDimensionMaxValue</tabstop> <tabstop>doubleSpinBoxZDimensionMaxValue</tabstop>
<tabstop>comboBoxZDimensionStep</tabstop> <tabstop>comboBoxZDimensionStep</tabstop>
<tabstop>comboBoxZDimensionBase</tabstop> <tabstop>comboBoxZDimensionBase</tabstop>
</tabstops> </tabstops>

View File

@ -194,7 +194,7 @@ bool TMainWindow::SetDimensionABase(int base)
gradationDimensionA->setCurrentIndex(i); gradationDimensionA->setCurrentIndex(i);
} }
if (base != currentDimensionA) if (not VFuzzyComparePossibleNulls(base, currentDimensionA))
{ {
qCCritical(tMainWindow, "%s\n", qPrintable(tr("Invalid base value for dimension A"))); qCCritical(tMainWindow, "%s\n", qPrintable(tr("Invalid base value for dimension A")));
return false; return false;
@ -219,7 +219,7 @@ bool TMainWindow::SetDimensionBBase(int base)
gradationDimensionB->setCurrentIndex(i); gradationDimensionB->setCurrentIndex(i);
} }
if (base != currentDimensionB) if (not VFuzzyComparePossibleNulls(base, currentDimensionB))
{ {
qCCritical(tMainWindow, "%s\n", qPrintable(tr("Invalid base value for dimension B"))); qCCritical(tMainWindow, "%s\n", qPrintable(tr("Invalid base value for dimension B")));
return false; return false;
@ -245,7 +245,7 @@ bool TMainWindow::SetDimensionCBase(int base)
gradationDimensionC->setCurrentIndex(i); gradationDimensionC->setCurrentIndex(i);
} }
if (base != currentDimensionC) if (not VFuzzyComparePossibleNulls(base, currentDimensionC))
{ {
qCCritical(tMainWindow, "%s\n", qPrintable(tr("Invalid base value for dimension C"))); qCCritical(tMainWindow, "%s\n", qPrintable(tr("Invalid base value for dimension C")));
return false; return false;
@ -1535,7 +1535,7 @@ void TMainWindow::ImportFromPattern()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TMainWindow::DimensionABaseChanged() void TMainWindow::DimensionABaseChanged()
{ {
currentDimensionA = gradationDimensionA->currentData().toInt(); currentDimensionA = gradationDimensionA->currentData().toDouble();
const QList<MeasurementDimension_p> dimensions = m->Dimensions().values(); const QList<MeasurementDimension_p> dimensions = m->Dimensions().values();
if (dimensions.size() > 1) if (dimensions.size() > 1)
@ -1556,7 +1556,7 @@ void TMainWindow::DimensionABaseChanged()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TMainWindow::DimensionBBaseChanged() void TMainWindow::DimensionBBaseChanged()
{ {
currentDimensionB = gradationDimensionB->currentData().toInt(); currentDimensionB = gradationDimensionB->currentData().toDouble();
const QList<MeasurementDimension_p> dimensions = m->Dimensions().values(); const QList<MeasurementDimension_p> dimensions = m->Dimensions().values();
@ -1572,7 +1572,7 @@ void TMainWindow::DimensionBBaseChanged()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TMainWindow::DimensionCBaseChanged() void TMainWindow::DimensionCBaseChanged()
{ {
currentDimensionC = gradationDimensionC->currentData().toInt(); currentDimensionC = gradationDimensionC->currentData().toDouble();
gradation->start(); gradation->start();
} }
@ -2249,7 +2249,7 @@ void TMainWindow::ExportToIndividual()
void TMainWindow::RestrictSecondDimesion() void TMainWindow::RestrictSecondDimesion()
{ {
const QList<MeasurementDimension_p> dimensions = m->Dimensions().values(); const QList<MeasurementDimension_p> dimensions = m->Dimensions().values();
const QMap<QString, QPair<int, int>> restrictions = m->GetRestrictions(); const QMap<QString, QPair<qreal, qreal>> restrictions = m->GetRestrictions();
bool oneDimesionRestriction = true; bool oneDimesionRestriction = true;
bool fullCircumference = m->IsFullCircumference(); bool fullCircumference = m->IsFullCircumference();
@ -2269,7 +2269,7 @@ void TMainWindow::RestrictSecondDimesion()
void TMainWindow::RestrictThirdDimesion() void TMainWindow::RestrictThirdDimesion()
{ {
const QList<MeasurementDimension_p> dimensions = m->Dimensions().values(); const QList<MeasurementDimension_p> dimensions = m->Dimensions().values();
const QMap<QString, QPair<int, int>> restrictions = m->GetRestrictions(); const QMap<QString, QPair<qreal, qreal>> restrictions = m->GetRestrictions();
bool oneDimesionRestriction = false; bool oneDimesionRestriction = false;
bool fullCircumference = m->IsFullCircumference(); bool fullCircumference = m->IsFullCircumference();
@ -2677,16 +2677,16 @@ void TMainWindow::InitDimensionGradation(int index, const MeasurementDimension_p
const bool fc = m->IsFullCircumference(); const bool fc = m->IsFullCircumference();
const QString unit = UnitsToStr(m->MUnit(), true); const QString unit = UnitsToStr(m->MUnit(), true);
int current = -1; qreal current = -1;
if (control->currentIndex() != -1) if (control->currentIndex() != -1)
{ {
current = control->currentData().toInt(); current = control->currentData().toDouble();
} }
control->blockSignals(true); control->blockSignals(true);
control->clear(); control->clear();
const QVector<int> bases = DimensionRestrictedValues(index, dimension); const QVector<qreal> bases = DimensionRestrictedValues(index, dimension);
const DimesionLabels labels = dimension->Labels(); const DimesionLabels labels = dimension->Labels();
if (dimension->Type() == MeasurementDimension::X) if (dimension->Type() == MeasurementDimension::X)
@ -4125,7 +4125,7 @@ void TMainWindow::SetDimensionBases()
currentDimensionC = dimension->BaseValue(); currentDimensionC = dimension->BaseValue();
} }
auto SetBase = [dimensions](int index, QComboBox *control, int &value) auto SetBase = [dimensions](int index, QComboBox *control, qreal &value)
{ {
if (dimensions.size() > index) if (dimensions.size() > index)
{ {
@ -4140,7 +4140,7 @@ void TMainWindow::SetDimensionBases()
} }
else else
{ {
value = control->currentData().toInt(); value = control->currentData().toDouble();
} }
} }
}; };
@ -4155,7 +4155,7 @@ void TMainWindow::SetCurrentDimensionValues()
{ {
const QList<MeasurementDimension_p> dimensions = m->Dimensions().values(); const QList<MeasurementDimension_p> dimensions = m->Dimensions().values();
auto SetDimensionValue = [dimensions](int index, int &value) auto SetDimensionValue = [dimensions](int index, qreal &value)
{ {
if (dimensions.size() > index) if (dimensions.size() > index)
{ {
@ -4170,27 +4170,20 @@ void TMainWindow::SetCurrentDimensionValues()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<int> TMainWindow::DimensionRestrictedValues(int index, const MeasurementDimension_p &dimension) QVector<qreal> TMainWindow::DimensionRestrictedValues(int index, const MeasurementDimension_p &dimension)
{ {
QPair<int, int> restriction;
if (index == 0) if (index == 0)
{ {
return dimension->ValidBases(); return dimension->ValidBases();
} }
else if (index == 1)
{
restriction = m->Restriction(currentDimensionA);
}
else
{
restriction = m->Restriction(currentDimensionA, currentDimensionB);
}
const QVector<int> bases = dimension->ValidBases(); QPair<qreal, qreal> restriction = index == 1 ? m->Restriction(currentDimensionA)
: m->Restriction(currentDimensionA, currentDimensionB);
int min = bases.indexOf(restriction.first) != -1 ? restriction.first : dimension->MinValue(); const QVector<qreal> bases = dimension->ValidBases();
int max = bases.indexOf(restriction.second) != -1 ? restriction.second : dimension->MaxValue();
qreal min = bases.indexOf(restriction.first) != -1 ? restriction.first : dimension->MinValue();
qreal max = bases.indexOf(restriction.second) != -1 ? restriction.second : dimension->MaxValue();
if (min > max) if (min > max)
{ {
@ -4222,22 +4215,6 @@ void TMainWindow::SetDecimals()
switch (mUnit) switch (mUnit)
{ {
case Unit::Cm: case Unit::Cm:
ui->doubleSpinBoxBaseValue->setDecimals(2);
ui->doubleSpinBoxBaseValue->setSingleStep(0.01);
ui->doubleSpinBoxCorrection->setDecimals(2);
ui->doubleSpinBoxCorrection->setSingleStep(0.01);
ui->doubleSpinBoxShiftA->setDecimals(2);
ui->doubleSpinBoxShiftA->setSingleStep(0.01);
ui->doubleSpinBoxShiftB->setDecimals(2);
ui->doubleSpinBoxShiftB->setSingleStep(0.01);
ui->doubleSpinBoxShiftC->setDecimals(2);
ui->doubleSpinBoxShiftC->setSingleStep(0.01);
break;
case Unit::Mm:
ui->doubleSpinBoxBaseValue->setDecimals(1); ui->doubleSpinBoxBaseValue->setDecimals(1);
ui->doubleSpinBoxBaseValue->setSingleStep(0.1); ui->doubleSpinBoxBaseValue->setSingleStep(0.1);
@ -4253,6 +4230,22 @@ void TMainWindow::SetDecimals()
ui->doubleSpinBoxShiftC->setDecimals(1); ui->doubleSpinBoxShiftC->setDecimals(1);
ui->doubleSpinBoxShiftC->setSingleStep(0.1); ui->doubleSpinBoxShiftC->setSingleStep(0.1);
break; break;
case Unit::Mm:
ui->doubleSpinBoxBaseValue->setDecimals(0);
ui->doubleSpinBoxBaseValue->setSingleStep(1);
ui->doubleSpinBoxCorrection->setDecimals(0);
ui->doubleSpinBoxCorrection->setSingleStep(1);
ui->doubleSpinBoxShiftA->setDecimals(0);
ui->doubleSpinBoxShiftA->setSingleStep(1);
ui->doubleSpinBoxShiftB->setDecimals(0);
ui->doubleSpinBoxShiftB->setSingleStep(1);
ui->doubleSpinBoxShiftC->setDecimals(0);
ui->doubleSpinBoxShiftC->setSingleStep(1);
break;
case Unit::Inch: case Unit::Inch:
ui->doubleSpinBoxBaseValue->setDecimals(5); ui->doubleSpinBoxBaseValue->setDecimals(5);
ui->doubleSpinBoxBaseValue->setSingleStep(0.00001); ui->doubleSpinBoxBaseValue->setSingleStep(0.00001);

View File

@ -153,9 +153,9 @@ private:
Unit mUnit{Unit::Cm}; Unit mUnit{Unit::Cm};
Unit pUnit{Unit::Cm}; Unit pUnit{Unit::Cm};
MeasurementsType mType{MeasurementsType::Individual}; MeasurementsType mType{MeasurementsType::Individual};
int currentDimensionA{0}; qreal currentDimensionA{0};
int currentDimensionB{0}; qreal currentDimensionB{0};
int currentDimensionC{0}; qreal currentDimensionC{0};
QString curFile{}; QString curFile{};
QComboBox *gradationDimensionA{nullptr}; QComboBox *gradationDimensionA{nullptr};
QComboBox *gradationDimensionB{nullptr}; QComboBox *gradationDimensionB{nullptr};
@ -248,7 +248,7 @@ private:
void SetDimensionBases(); void SetDimensionBases();
void SetCurrentDimensionValues(); void SetCurrentDimensionValues();
QVector<int> DimensionRestrictedValues(int index, const MeasurementDimension_p &dimension); QVector<double> DimensionRestrictedValues(int index, const MeasurementDimension_p &dimension);
QMap<int, QSharedPointer<VMeasurement> > OrderedMeasurments() const; QMap<int, QSharedPointer<VMeasurement> > OrderedMeasurments() const;
}; };

View File

@ -571,7 +571,7 @@ bool MainWindow::LoadMeasurements(const QString &path)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool MainWindow::UpdateMeasurements(const QString &path, int baseA, int baseB, int baseC) bool MainWindow::UpdateMeasurements(const QString &path, qreal baseA, qreal baseB, qreal baseC)
{ {
m = OpenMeasurementFile(path); m = OpenMeasurementFile(path);
@ -2072,7 +2072,7 @@ void MainWindow::StoreMultisizeMDimensions()
QList<MeasurementDimension_p> dimensions = m->Dimensions().values(); QList<MeasurementDimension_p> dimensions = m->Dimensions().values();
auto StoreDimension = [this, dimensions](int index, int currentBase) auto StoreDimension = [this, dimensions](int index, qreal currentBase)
{ {
if (dimensions.size() > index) if (dimensions.size() > index)
{ {
@ -2146,9 +2146,9 @@ void MainWindow::StoreIndividualMDimensions()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<int> MainWindow::DimensionRestrictedValues(int index, const MeasurementDimension_p &dimension) QVector<qreal> MainWindow::DimensionRestrictedValues(int index, const MeasurementDimension_p &dimension)
{ {
QPair<int, int> restriction; QPair<qreal, qreal> restriction;
if (index == 0) if (index == 0)
{ {
@ -2163,10 +2163,10 @@ QVector<int> MainWindow::DimensionRestrictedValues(int index, const MeasurementD
restriction = m->Restriction(m_currentDimensionA, m_currentDimensionB); restriction = m->Restriction(m_currentDimensionA, m_currentDimensionB);
} }
const QVector<int> bases = dimension->ValidBases(); const QVector<qreal> bases = dimension->ValidBases();
int min = bases.indexOf(restriction.first) != -1 ? restriction.first : dimension->MinValue(); qreal min = bases.indexOf(restriction.first) != -1 ? restriction.first : dimension->MinValue();
int max = bases.indexOf(restriction.second) != -1 ? restriction.second : dimension->MaxValue(); qreal max = bases.indexOf(restriction.second) != -1 ? restriction.second : dimension->MaxValue();
if (min > max) if (min > max)
{ {
@ -2182,7 +2182,7 @@ void MainWindow::SetDimensionBases()
{ {
const QList<MeasurementDimension_p> dimensions = m->Dimensions().values(); const QList<MeasurementDimension_p> dimensions = m->Dimensions().values();
auto SetBase = [dimensions](int index, QPointer<QComboBox> control, int &value) auto SetBase = [dimensions](int index, QPointer<QComboBox> control, double &value)
{ {
if (dimensions.size() > index) if (dimensions.size() > index)
{ {
@ -2199,7 +2199,7 @@ void MainWindow::SetDimensionBases()
} }
else else
{ {
value = control->currentData().toInt(); value = control->currentData().toDouble();
} }
control->blockSignals(false); control->blockSignals(false);
@ -3439,9 +3439,8 @@ void MainWindow::FullParseFile()
futureTestUniqueId.waitForFinished(); futureTestUniqueId.waitForFinished();
} }
} }
catch (const VExceptionUndo &e) catch (const VExceptionUndo &)
{ {
Q_UNUSED(e)
/* If user want undo last operation before undo we need finish broken redo operation. For those we post event /* If user want undo last operation before undo we need finish broken redo operation. For those we post event
* myself. Later in method customEvent call undo.*/ * myself. Later in method customEvent call undo.*/
if (qApp->getOpeningPattern()) if (qApp->getOpeningPattern())
@ -3823,7 +3822,7 @@ void MainWindow::PatternChangesWereSaved(bool saved)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::DimensionABaseChanged() void MainWindow::DimensionABaseChanged()
{ {
m_currentDimensionA = dimensionA->currentData().toInt(); m_currentDimensionA = dimensionA->currentData().toDouble();
const QList<MeasurementDimension_p> dimensions = m->Dimensions().values(); const QList<MeasurementDimension_p> dimensions = m->Dimensions().values();
if (dimensions.size() > 1) if (dimensions.size() > 1)
@ -3844,7 +3843,7 @@ void MainWindow::DimensionABaseChanged()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::DimensionBBaseChanged() void MainWindow::DimensionBBaseChanged()
{ {
m_currentDimensionB = dimensionB->currentData().toInt(); m_currentDimensionB = dimensionB->currentData().toDouble();
const QList<MeasurementDimension_p> dimensions = m->Dimensions().values(); const QList<MeasurementDimension_p> dimensions = m->Dimensions().values();
@ -3860,7 +3859,7 @@ void MainWindow::DimensionBBaseChanged()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::DimensionCBaseChanged() void MainWindow::DimensionCBaseChanged()
{ {
m_currentDimensionC = dimensionC->currentData().toInt(); m_currentDimensionC = dimensionC->currentData().toDouble();
m_gradation->start(); m_gradation->start();
} }
@ -3996,23 +3995,24 @@ void MainWindow::InitDimensionControls()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::InitDimensionGradation(int index, const MeasurementDimension_p &dimension, QPointer<QComboBox> control) void MainWindow::InitDimensionGradation(int index, const MeasurementDimension_p &dimension,
const QPointer<QComboBox> &control)
{ {
SCASSERT(control != nullptr) SCASSERT(control != nullptr)
const bool fc = m->IsFullCircumference(); const bool fc = m->IsFullCircumference();
const QString unit = UnitsToStr(qApp->MeasurementsUnits(), true); const QString unit = UnitsToStr(qApp->MeasurementsUnits(), true);
int current = -1; qreal current = -1;
if (control->currentIndex() != -1) if (control->currentIndex() != -1)
{ {
current = control->currentData().toInt(); current = control->currentData().toDouble();
} }
control->blockSignals(true); control->blockSignals(true);
control->clear(); control->clear();
const QVector<int> bases = DimensionRestrictedValues(index, dimension); const QVector<qreal> bases = DimensionRestrictedValues(index, dimension);
const DimesionLabels labels = dimension->Labels(); const DimesionLabels labels = dimension->Labels();
if (dimension->Type() == MeasurementDimension::X) if (dimension->Type() == MeasurementDimension::X)

View File

@ -293,16 +293,16 @@ private:
QList<QPointer<WatermarkWindow>> m_watermarkEditors{}; QList<QPointer<WatermarkWindow>> m_watermarkEditors{};
int m_currentDimensionA{0}; qreal m_currentDimensionA{0};
int m_currentDimensionB{0}; qreal m_currentDimensionB{0};
int m_currentDimensionC{0}; qreal m_currentDimensionC{0};
QSharedPointer<VMeasurements> m{}; QSharedPointer<VMeasurements> m{};
QTimer *m_gradation; QTimer *m_gradation;
void InitDimensionControls(); void InitDimensionControls();
void InitDimensionGradation(int index, const MeasurementDimension_p &dimension, QPointer<QComboBox> control); void InitDimensionGradation(int index, const MeasurementDimension_p &dimension, const QPointer<QComboBox> &control);
void ToolBarOption(); void ToolBarOption();
void ToolBarStages(); void ToolBarStages();
@ -373,7 +373,7 @@ private:
void InitScenes(); void InitScenes();
bool LoadMeasurements(const QString &path); bool LoadMeasurements(const QString &path);
bool UpdateMeasurements(const QString &path, int baseA, int baseB, int baseC); bool UpdateMeasurements(const QString &path, qreal baseA, qreal baseB, qreal baseC);
void ReopenFilesAfterCrash(QStringList &args); void ReopenFilesAfterCrash(QStringList &args);
bool DoExport(const VCommandLinePtr& expParams); bool DoExport(const VCommandLinePtr& expParams);
@ -411,7 +411,7 @@ private:
void StoreMultisizeMDimensions(); void StoreMultisizeMDimensions();
void StoreIndividualMDimensions(); void StoreIndividualMDimensions();
QVector<int> DimensionRestrictedValues(int index, const MeasurementDimension_p &dimension); QVector<qreal> DimensionRestrictedValues(int index, const MeasurementDimension_p &dimension);
void SetDimensionBases(); void SetDimensionBases();
}; };

View File

@ -45,8 +45,8 @@
<xs:element name="restriction" minOccurs="0" maxOccurs="unbounded"> <xs:element name="restriction" minOccurs="0" maxOccurs="unbounded">
<xs:complexType> <xs:complexType>
<xs:attribute name="coordinates" type="xs:string" use="required"/> <xs:attribute name="coordinates" type="xs:string" use="required"/>
<xs:attribute name="min" type="dimesionValue" use="required"/> <xs:attribute name="min" type="dimesionValue"/>
<xs:attribute name="max" type="dimesionValue" use="required"/> <xs:attribute name="max" type="dimesionValue"/>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
</xs:sequence> </xs:sequence>
@ -122,13 +122,13 @@
</xs:restriction> </xs:restriction>
</xs:simpleType> </xs:simpleType>
<xs:simpleType name="dimesionValue"> <xs:simpleType name="dimesionValue">
<xs:restriction base="xs:unsignedInt"> <xs:restriction base="xs:double">
<xs:minInclusive value="6"/> <xs:minInclusive value="6"/>
<xs:maxInclusive value="2720"/> <xs:maxInclusive value="2720"/>
</xs:restriction> </xs:restriction>
</xs:simpleType> </xs:simpleType>
<xs:simpleType name="dimensionStep"> <xs:simpleType name="dimensionStep">
<xs:restriction base="xs:unsignedInt"> <xs:restriction base="xs:double">
<xs:minInclusive value="0"/> <xs:minInclusive value="0"/>
<xs:maxInclusive value="80"/> <xs:maxInclusive value="80"/>
</xs:restriction> </xs:restriction>

View File

@ -29,6 +29,7 @@
#include <QSet> #include <QSet>
#include <QVector> #include <QVector>
#include <cmath>
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstartMeasurementDimension::VAbstartMeasurementDimension(Unit units) VAbstartMeasurementDimension::VAbstartMeasurementDimension(Unit units)
@ -36,7 +37,7 @@ VAbstartMeasurementDimension::VAbstartMeasurementDimension(Unit units)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VAbstartMeasurementDimension::VAbstartMeasurementDimension(Unit units, int min, int max, int step) VAbstartMeasurementDimension::VAbstartMeasurementDimension(Unit units, qreal min, qreal max, qreal step)
: m_units(units), : m_units(units),
m_minValue(min), m_minValue(min),
m_maxValue(max), m_maxValue(max),
@ -44,48 +45,57 @@ VAbstartMeasurementDimension::VAbstartMeasurementDimension(Unit units, int min,
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VAbstartMeasurementDimension::IsValid() auto VAbstartMeasurementDimension::IsValid() -> bool
{ {
m_error.clear(); m_error.clear();
return IsUnitsValid() && IsRangeValid() && IsStepValid() && IsBaseValid(); return IsUnitsValid() && IsRangeValid() && IsStepValid() && IsBaseValid();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<int> VAbstartMeasurementDimension::ValidSteps() const auto VAbstartMeasurementDimension::ValidSteps() const -> QVector<qreal>
{ {
QVector<int> steps; const qreal stepBarrier = 8.5;
const qreal s = 0.5;
const int diff = m_maxValue - m_minValue; QVector<qreal> steps;
if (diff == 0) steps.reserve(qRound((stepBarrier - s) * 2 - 1));
const qreal diff = m_maxValue - m_minValue;
if (qFuzzyIsNull(diff))
{ {
steps.append(0); // only one possible value steps.append(0); // only one possible value
} }
else if (diff > 0) else if (diff > 0)
{ {
for (int i=1; i < 9; ++i) qreal candidate = 1;
do
{ {
const int step = (m_units == Unit::Mm ? i * 10 : i); const qreal step = (m_units == Unit::Mm ? candidate * 10 : candidate);
if (diff % step == 0) qreal intpart;
if (qFuzzyIsNull(std::modf(diff / step, &intpart)))
{ {
steps.append(step); steps.append(step);
} }
candidate += s;
} }
while(candidate < stepBarrier);
} }
return steps; return steps;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<int> VAbstartMeasurementDimension::ValidBases() const auto VAbstartMeasurementDimension::ValidBases() const -> QVector<qreal>
{ {
return VAbstartMeasurementDimension::ValidBases(m_minValue, m_maxValue, m_step); return VAbstartMeasurementDimension::ValidBases(m_minValue, m_maxValue, m_step);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QStringList VAbstartMeasurementDimension::ValidBasesList() const auto VAbstartMeasurementDimension::ValidBasesList() const -> QStringList
{ {
QVector<int> bases = ValidBases(); QVector<qreal> bases = ValidBases();
QStringList list; QStringList list;
list.reserve(bases.size());
for(auto &base : bases) for(auto &base : bases)
{ {
list.append(QString::number(base)); list.append(QString::number(base));
@ -95,29 +105,35 @@ QStringList VAbstartMeasurementDimension::ValidBasesList() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<int> VAbstartMeasurementDimension::ValidBases(int min, int max, int step) auto VAbstartMeasurementDimension::ValidBases(qreal min, qreal max, qreal step) -> QVector<qreal>
{ {
QVector<int> validBases; QVector<qreal> validBases;
if (step < 0) if (step < 0 || min > max)
{ {
return validBases; return validBases;
} }
else if (step == 0)
if (qFuzzyIsNull(step))
{ {
step = 1; step = 1;
} }
for (int value = min; value <= max; value += step) validBases.reserve(qRound((max - min) / step));
qreal value = min;
do
{ {
validBases.append(value); validBases.append(value);
value += step;
} }
while(value < max + step);
return validBases; return validBases;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VAbstartMeasurementDimension::IsRangeValid() auto VAbstartMeasurementDimension::IsRangeValid() -> bool
{ {
bool valid = m_minValue > 0 && m_maxValue > 0 && m_minValue >= RangeMin() && m_minValue <= RangeMax() bool valid = m_minValue > 0 && m_maxValue > 0 && m_minValue >= RangeMin() && m_minValue <= RangeMax()
&& m_minValue <= m_maxValue; && m_minValue <= m_maxValue;
@ -131,7 +147,7 @@ bool VAbstartMeasurementDimension::IsRangeValid()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VAbstartMeasurementDimension::IsStepValid() auto VAbstartMeasurementDimension::IsStepValid() -> bool
{ {
bool valid = ValidSteps().indexOf(m_step) != -1; bool valid = ValidSteps().indexOf(m_step) != -1;
if (not valid) if (not valid)
@ -143,7 +159,7 @@ bool VAbstartMeasurementDimension::IsStepValid()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VAbstartMeasurementDimension::IsBaseValid() auto VAbstartMeasurementDimension::IsBaseValid() -> bool
{ {
bool valid = ValidBases().indexOf(m_baseValue) != -1; bool valid = ValidBases().indexOf(m_baseValue) != -1;
if (not valid) if (not valid)
@ -155,13 +171,13 @@ bool VAbstartMeasurementDimension::IsBaseValid()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VAbstartMeasurementDimension::IsUnitsValid() const auto VAbstartMeasurementDimension::IsUnitsValid() const -> bool
{ {
return m_units == Unit::Cm || m_units == Unit::Mm || m_units == Unit::Inch; return m_units == Unit::Cm || m_units == Unit::Mm || m_units == Unit::Inch;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VAbstartMeasurementDimension::DimensionName(MeasurementDimension type) auto VAbstartMeasurementDimension::DimensionName(MeasurementDimension type) -> QString
{ {
switch(type) switch(type)
{ {
@ -179,7 +195,7 @@ QString VAbstartMeasurementDimension::DimensionName(MeasurementDimension type)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VAbstartMeasurementDimension::DimensionToolTip(MeasurementDimension type, bool circumference, bool fc) auto VAbstartMeasurementDimension::DimensionToolTip(MeasurementDimension type, bool circumference, bool fc) -> QString
{ {
switch(type) switch(type)
{ {
@ -211,43 +227,51 @@ VXMeasurementDimension::VXMeasurementDimension(Unit units)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VXMeasurementDimension::VXMeasurementDimension(Unit units, int min, int max, int step) VXMeasurementDimension::VXMeasurementDimension(Unit units, qreal min, qreal max, qreal step)
: VAbstartMeasurementDimension(units, min, max, step) : VAbstartMeasurementDimension(units, min, max, step)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
MeasurementDimension VXMeasurementDimension::Type() const auto VXMeasurementDimension::Type() const -> MeasurementDimension
{ {
return MeasurementDimension::X; return MeasurementDimension::X;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VXMeasurementDimension::RangeMin() const auto VXMeasurementDimension::RangeMin() const -> int
{ {
const int rangeMinCm = 50;
const int rangeMinMm = 500;
const int rangeMinInch = 19;
switch(m_units) switch(m_units)
{ {
case Unit::Cm: case Unit::Cm:
return 50; return rangeMinCm;
case Unit::Mm: case Unit::Mm:
return 500; return rangeMinMm;
case Unit::Inch: case Unit::Inch:
return 19; return rangeMinInch;
default: default:
return 0; return 0;
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VXMeasurementDimension::RangeMax() const auto VXMeasurementDimension::RangeMax() const -> int
{ {
const int rangeMaxCm = 272;
const int rangeMaxMm = 2720;
const int rangeMaxInch = 107;
switch(m_units) switch(m_units)
{ {
case Unit::Cm: case Unit::Cm:
return 272; return rangeMaxCm;
case Unit::Mm: case Unit::Mm:
return 2720; return rangeMaxMm;
case Unit::Inch: case Unit::Inch:
return 107; return rangeMaxInch;
default: default:
return 0; return 0;
} }
@ -260,59 +284,69 @@ VYMeasurementDimension::VYMeasurementDimension(Unit units)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VYMeasurementDimension::VYMeasurementDimension(Unit units, int min, int max, int step) VYMeasurementDimension::VYMeasurementDimension(Unit units, qreal min, qreal max, qreal step)
: VAbstartMeasurementDimension(units, min, max, step) : VAbstartMeasurementDimension(units, min, max, step)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
MeasurementDimension VYMeasurementDimension::Type() const auto VYMeasurementDimension::Type() const -> MeasurementDimension
{ {
return MeasurementDimension::Y; return MeasurementDimension::Y;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VYMeasurementDimension::RangeMin() const auto VYMeasurementDimension::RangeMin() const -> int
{ {
if (m_circumference) if (m_circumference)
{ {
const int rangeMinCm = 22;
const int rangeMinMm = 220;
const int rangeMinInch = 8;
switch(m_units) switch(m_units)
{ {
case Unit::Cm: case Unit::Cm:
return 22; return rangeMinCm;
case Unit::Mm: case Unit::Mm:
return 220; return rangeMinMm;
case Unit::Inch: case Unit::Inch:
return 8; return rangeMinInch;
default: default:
return 0; return 0;
} }
} }
else else
{ {
return 6; const int rangeMinCir = 6;
return rangeMinCir;
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VYMeasurementDimension::RangeMax() const auto VYMeasurementDimension::RangeMax() const -> int
{ {
if (m_circumference) if (m_circumference)
{ {
const int rangeMaxCm = 72;
const int rangeMaxMm = 720;
const int rangeMaxInch = 29;
switch(m_units) switch(m_units)
{ {
case Unit::Cm: case Unit::Cm:
return 72; return rangeMaxCm;
case Unit::Mm: case Unit::Mm:
return 720; return rangeMaxMm;
case Unit::Inch: case Unit::Inch:
return 29; return rangeMaxInch;
default: default:
return 0; return 0;
} }
} }
else else
{ {
return 60; const int rangeMaxCir = 60;
return rangeMaxCir;
} }
} }
@ -323,43 +357,51 @@ VWMeasurementDimension::VWMeasurementDimension(Unit units)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VWMeasurementDimension::VWMeasurementDimension(Unit units, int min, int max, int step) VWMeasurementDimension::VWMeasurementDimension(Unit units, qreal min, qreal max, qreal step)
: VAbstartMeasurementDimension(units, min, max, step) : VAbstartMeasurementDimension(units, min, max, step)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
MeasurementDimension VWMeasurementDimension::Type() const auto VWMeasurementDimension::Type() const -> MeasurementDimension
{ {
return MeasurementDimension::W; return MeasurementDimension::W;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VWMeasurementDimension::RangeMin() const auto VWMeasurementDimension::RangeMin() const -> int
{ {
const int rangeMinCm = 20;
const int rangeMinMm = 200;
const int rangeMinInch = 8;
switch(m_units) switch(m_units)
{ {
case Unit::Cm: case Unit::Cm:
return 20; return rangeMinCm;
case Unit::Mm: case Unit::Mm:
return 200; return rangeMinMm;
case Unit::Inch: case Unit::Inch:
return 8; return rangeMinInch;
default: default:
return 0; return 0;
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VWMeasurementDimension::RangeMax() const auto VWMeasurementDimension::RangeMax() const -> int
{ {
const int rangeMaxCm = 65;
const int rangeMaxMm = 650;
const int rangeMaxInch = 26;
switch(m_units) switch(m_units)
{ {
case Unit::Cm: case Unit::Cm:
return 65; return rangeMaxCm;
case Unit::Mm: case Unit::Mm:
return 650; return rangeMaxMm;
case Unit::Inch: case Unit::Inch:
return 26; return rangeMaxInch;
default: default:
return 0; return 0;
} }
@ -372,43 +414,51 @@ VZMeasurementDimension::VZMeasurementDimension(Unit units)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VZMeasurementDimension::VZMeasurementDimension(Unit units, int min, int max, int step) VZMeasurementDimension::VZMeasurementDimension(Unit units, qreal min, qreal max, qreal step)
: VAbstartMeasurementDimension(units, min, max, step) : VAbstartMeasurementDimension(units, min, max, step)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
MeasurementDimension VZMeasurementDimension::Type() const auto VZMeasurementDimension::Type() const -> MeasurementDimension
{ {
return MeasurementDimension::Z; return MeasurementDimension::Z;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VZMeasurementDimension::RangeMin() const auto VZMeasurementDimension::RangeMin() const -> int
{ {
const int rangeMinCm = 20;
const int rangeMinMm = 200;
const int rangeMinInch = 8;
switch(m_units) switch(m_units)
{ {
case Unit::Cm: case Unit::Cm:
return 20; return rangeMinCm;
case Unit::Mm: case Unit::Mm:
return 200; return rangeMinMm;
case Unit::Inch: case Unit::Inch:
return 8; return rangeMinInch;
default: default:
return 0; return 0;
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VZMeasurementDimension::RangeMax() const auto VZMeasurementDimension::RangeMax() const -> int
{ {
const int rangeMaxCm = 75;
const int rangeMaxMm = 750;
const int rangeMaxInch = 30;
switch(m_units) switch(m_units)
{ {
case Unit::Cm: case Unit::Cm:
return 75; return rangeMaxCm;
case Unit::Mm: case Unit::Mm:
return 750; return rangeMaxMm;
case Unit::Inch: case Unit::Inch:
return 30; return rangeMaxInch;
default: default:
return 0; return 0;
} }

View File

@ -45,7 +45,7 @@ class VAbstartMeasurementDimension;
template <class T> class QSharedPointer; template <class T> class QSharedPointer;
using MeasurementDimension_p = QSharedPointer<VAbstartMeasurementDimension>; using MeasurementDimension_p = QSharedPointer<VAbstartMeasurementDimension>;
using DimesionLabels = QMap<int, QString>; using DimesionLabels = QMap<qreal, QString>;
class VAbstartMeasurementDimension class VAbstartMeasurementDimension
{ {
@ -53,128 +53,128 @@ class VAbstartMeasurementDimension
public: public:
VAbstartMeasurementDimension() =default; VAbstartMeasurementDimension() =default;
explicit VAbstartMeasurementDimension(Unit units); explicit VAbstartMeasurementDimension(Unit units);
VAbstartMeasurementDimension(Unit units, int min, int max, int step); VAbstartMeasurementDimension(Unit units, qreal min, qreal max, qreal step);
virtual ~VAbstartMeasurementDimension() =default; virtual ~VAbstartMeasurementDimension() =default;
virtual MeasurementDimension Type() const =0; virtual MeasurementDimension Type() const =0;
virtual bool IsValid(); virtual bool IsValid();
int MinValue() const; auto MinValue() const -> qreal;
void SetMinValue(int minValue); void SetMinValue(qreal minValue);
int MaxValue() const; auto MaxValue() const -> qreal;
void SetMaxValue(int maxValue); void SetMaxValue(qreal maxValue);
int Step() const; auto Step() const -> qreal;
void SetStep(int step); void SetStep(qreal step);
int BaseValue() const; auto BaseValue() const -> qreal;
void SetBaseValue(int baseValue); void SetBaseValue(qreal baseValue);
QString Error() const; auto Error() const -> QString;
Unit Units() const; auto Units() const -> Unit;
virtual bool IsCircumference() const; virtual auto IsCircumference() const -> bool;
virtual int RangeMin() const =0; virtual auto RangeMin() const -> int =0;
virtual int RangeMax() const =0; virtual auto RangeMax() const -> int =0;
QVector<int> ValidSteps() const; auto ValidSteps() const -> QVector<qreal>;
QVector<int> ValidBases() const; auto ValidBases() const -> QVector<qreal>;
QStringList ValidBasesList() const; auto ValidBasesList() const -> QStringList;
static QVector<int> ValidBases(int min, int max, int step); static auto ValidBases(qreal min, qreal max, qreal step) -> QVector<qreal>;
static QString DimensionName(MeasurementDimension type); static auto DimensionName(MeasurementDimension type) -> QString;
static QString DimensionToolTip(MeasurementDimension type, bool circumference, bool fc); static auto DimensionToolTip(MeasurementDimension type, bool circumference, bool fc) -> QString;
DimesionLabels Labels() const; auto Labels() const -> DimesionLabels;
void SetLabels(const DimesionLabels &labels); void SetLabels(const DimesionLabels &labels);
protected: protected:
Unit m_units{Unit::Cm}; Unit m_units{Unit::Cm};
int m_minValue{0}; qreal m_minValue{0};
int m_maxValue{0}; qreal m_maxValue{0};
int m_step{-1}; qreal m_step{-1};
int m_baseValue{0}; qreal m_baseValue{0};
QString m_error{}; QString m_error{};
DimesionLabels m_labels{}; DimesionLabels m_labels{};
bool IsRangeValid(); auto IsRangeValid() -> bool;
bool IsStepValid(); auto IsStepValid() -> bool;
bool IsBaseValid(); auto IsBaseValid() -> bool;
bool IsUnitsValid() const; auto IsUnitsValid() const -> bool;
}; };
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline int VAbstartMeasurementDimension::MinValue() const inline auto VAbstartMeasurementDimension::MinValue() const -> qreal
{ {
return m_minValue; return m_minValue;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline void VAbstartMeasurementDimension::SetMinValue(int minValue) inline void VAbstartMeasurementDimension::SetMinValue(qreal minValue)
{ {
m_minValue = minValue; m_minValue = minValue;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline int VAbstartMeasurementDimension::MaxValue() const inline auto VAbstartMeasurementDimension::MaxValue() const -> qreal
{ {
return m_maxValue; return m_maxValue;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline void VAbstartMeasurementDimension::SetMaxValue(int maxValue) inline void VAbstartMeasurementDimension::SetMaxValue(qreal maxValue)
{ {
m_maxValue = maxValue; m_maxValue = maxValue;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline int VAbstartMeasurementDimension::Step() const inline auto VAbstartMeasurementDimension::Step() const -> qreal
{ {
return m_step; return m_step;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline void VAbstartMeasurementDimension::SetStep(int step) inline void VAbstartMeasurementDimension::SetStep(qreal step)
{ {
m_step = step; m_step = step;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline int VAbstartMeasurementDimension::BaseValue() const inline auto VAbstartMeasurementDimension::BaseValue() const -> qreal
{ {
return m_baseValue; return m_baseValue;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline void VAbstartMeasurementDimension::SetBaseValue(int baseValue) inline void VAbstartMeasurementDimension::SetBaseValue(qreal baseValue)
{ {
m_baseValue = baseValue; m_baseValue = baseValue;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline QString VAbstartMeasurementDimension::Error() const inline auto VAbstartMeasurementDimension::Error() const -> QString
{ {
return m_error; return m_error;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline Unit VAbstartMeasurementDimension::Units() const inline auto VAbstartMeasurementDimension::Units() const -> Unit
{ {
return m_units; return m_units;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline bool VAbstartMeasurementDimension::IsCircumference() const inline auto VAbstartMeasurementDimension::IsCircumference() const -> bool
{ {
return true; return true;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline DimesionLabels VAbstartMeasurementDimension::Labels() const inline auto VAbstartMeasurementDimension::Labels() const -> DimesionLabels
{ {
return m_labels; return m_labels;
} }
@ -192,18 +192,18 @@ class VXMeasurementDimension : public VAbstartMeasurementDimension
public: public:
VXMeasurementDimension() =default; VXMeasurementDimension() =default;
explicit VXMeasurementDimension(Unit units); explicit VXMeasurementDimension(Unit units);
VXMeasurementDimension(Unit units, int min, int max, int step); VXMeasurementDimension(Unit units, qreal min, qreal max, qreal step);
virtual MeasurementDimension Type() const override; virtual auto Type() const -> MeasurementDimension override;
virtual int RangeMin() const override; virtual auto RangeMin() const -> int override;
virtual int RangeMax() const override; virtual auto RangeMax() const -> int override;
virtual bool IsCircumference() const override; virtual bool IsCircumference() const override;
}; };
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline bool VXMeasurementDimension::IsCircumference() const inline auto VXMeasurementDimension::IsCircumference() const -> bool
{ {
return false; return false;
} }
@ -215,14 +215,14 @@ class VYMeasurementDimension : public VAbstartMeasurementDimension
public: public:
VYMeasurementDimension() =default; VYMeasurementDimension() =default;
explicit VYMeasurementDimension(Unit units); explicit VYMeasurementDimension(Unit units);
VYMeasurementDimension(Unit units, int min, int max, int step); VYMeasurementDimension(Unit units, qreal min, qreal max, qreal step);
virtual MeasurementDimension Type() const override; virtual auto Type() const -> MeasurementDimension override;
virtual int RangeMin() const override; virtual auto RangeMin() const -> int override;
virtual int RangeMax() const override; virtual auto RangeMax() const -> int override;
virtual bool IsCircumference() const override; virtual auto IsCircumference() const -> bool override;
void SetCircumference(bool circumference); void SetCircumference(bool circumference);
private: private:
@ -248,12 +248,12 @@ class VWMeasurementDimension : public VAbstartMeasurementDimension
public: public:
VWMeasurementDimension() =default; VWMeasurementDimension() =default;
explicit VWMeasurementDimension(Unit units); explicit VWMeasurementDimension(Unit units);
VWMeasurementDimension(Unit units, int min, int max, int step); VWMeasurementDimension(Unit units, qreal min, qreal max, qreal step);
virtual MeasurementDimension Type() const override; virtual auto Type() const -> MeasurementDimension override;
virtual int RangeMin() const override; virtual auto RangeMin() const -> int override;
virtual int RangeMax() const override; virtual auto RangeMax() const -> int override;
}; };
// VZMeasurementDimension // VZMeasurementDimension
@ -263,12 +263,12 @@ class VZMeasurementDimension : public VAbstartMeasurementDimension
public: public:
VZMeasurementDimension() =default; VZMeasurementDimension() =default;
explicit VZMeasurementDimension(Unit units); explicit VZMeasurementDimension(Unit units);
VZMeasurementDimension(Unit units, int min, int max, int step); VZMeasurementDimension(Unit units, qreal min, qreal max, qreal step);
virtual MeasurementDimension Type() const override; virtual auto Type() const -> MeasurementDimension override;
virtual int RangeMin() const override; virtual auto RangeMin() const -> int override;
virtual int RangeMax() const override; virtual auto RangeMax() const -> int override;
}; };
#endif // VDIMENSIONS_H #endif // VDIMENSIONS_H

View File

@ -433,7 +433,7 @@ MeasurementsType VMeasurements::Type() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VMeasurements::DimensionABase() const qreal VMeasurements::DimensionABase() const
{ {
if (type == MeasurementsType::Multisize) if (type == MeasurementsType::Multisize)
{ {
@ -448,7 +448,7 @@ int VMeasurements::DimensionABase() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VMeasurements::DimensionBBase() const qreal VMeasurements::DimensionBBase() const
{ {
if (type == MeasurementsType::Multisize) if (type == MeasurementsType::Multisize)
{ {
@ -463,7 +463,7 @@ int VMeasurements::DimensionBBase() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VMeasurements::DimensionCBase() const qreal VMeasurements::DimensionCBase() const
{ {
if (type == MeasurementsType::Multisize) if (type == MeasurementsType::Multisize)
{ {
@ -478,7 +478,7 @@ int VMeasurements::DimensionCBase() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VMeasurements::DimensionAStep() const qreal VMeasurements::DimensionAStep() const
{ {
if (type == MeasurementsType::Multisize) if (type == MeasurementsType::Multisize)
{ {
@ -493,7 +493,7 @@ int VMeasurements::DimensionAStep() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VMeasurements::DimensionBStep() const qreal VMeasurements::DimensionBStep() const
{ {
if (type == MeasurementsType::Multisize) if (type == MeasurementsType::Multisize)
{ {
@ -508,7 +508,7 @@ int VMeasurements::DimensionBStep() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VMeasurements::DimensionCStep() const qreal VMeasurements::DimensionCStep() const
{ {
if (type == MeasurementsType::Multisize) if (type == MeasurementsType::Multisize)
{ {
@ -845,7 +845,7 @@ QString VMeasurements::MeasurementForDimension(IMD type) const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QMap<MeasurementDimension, MeasurementDimension_p > VMeasurements::Dimensions() const auto VMeasurements::Dimensions() const -> QMap<MeasurementDimension, MeasurementDimension_p >
{ {
if (type != MeasurementsType::Multisize) if (type != MeasurementsType::Multisize)
{ {
@ -860,10 +860,10 @@ QMap<MeasurementDimension, MeasurementDimension_p > VMeasurements::Dimensions()
{ {
const QDomElement dom = list.at(i).toElement(); const QDomElement dom = list.at(i).toElement();
const MeasurementDimension type = StrToDimensionType(GetParametrString(dom, AttrType)); const MeasurementDimension type = StrToDimensionType(GetParametrString(dom, AttrType));
const int min = GetParametrInt(dom, AttrMin, QChar('0')); const qreal min = GetParametrDouble(dom, AttrMin, QChar('0'));
const int max = GetParametrInt(dom, AttrMax, QChar('0')); const qreal max = GetParametrDouble(dom, AttrMax, QChar('0'));
const int step = GetParametrInt(dom, AttrStep, QString("-1")); const qreal step = GetParametrDouble(dom, AttrStep, QStringLiteral("-1"));
const int base = GetParametrInt(dom, AttrBase, QChar('0')); const qreal base = GetParametrDouble(dom, AttrBase, QChar('0'));
const DimesionLabels labels = ReadDimensionLabels(dom); const DimesionLabels labels = ReadDimensionLabels(dom);
@ -903,9 +903,9 @@ QMap<MeasurementDimension, MeasurementDimension_p > VMeasurements::Dimensions()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QMap<QString, QPair<int, int> > VMeasurements::GetRestrictions() const auto VMeasurements::GetRestrictions() const -> QMap<QString, QPair<qreal, qreal> >
{ {
QMap<QString, QPair<int, int> > restrictions; QMap<QString, QPair<qreal, qreal> > restrictions;
const QDomNodeList list = elementsByTagName(TagRestriction); const QDomNodeList list = elementsByTagName(TagRestriction);
for (int i=0; i < list.size(); ++i) for (int i=0; i < list.size(); ++i)
@ -913,8 +913,8 @@ QMap<QString, QPair<int, int> > VMeasurements::GetRestrictions() const
const QDomElement res = list.at(i).toElement(); const QDomElement res = list.at(i).toElement();
QString coordinates = GetParametrString(res, AttrCoordinates); QString coordinates = GetParametrString(res, AttrCoordinates);
const int min = GetParametrInt(res, AttrMin, QChar('0')); const qreal min = GetParametrDouble(res, AttrMin, QChar('0'));
const int max = GetParametrInt(res, AttrMax, QChar('0')); const qreal max = GetParametrDouble(res, AttrMax, QChar('0'));
restrictions.insert(coordinates, qMakePair(min, max)); restrictions.insert(coordinates, qMakePair(min, max));
} }
@ -923,7 +923,7 @@ QMap<QString, QPair<int, int> > VMeasurements::GetRestrictions() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VMeasurements::SetRestrictions(const QMap<QString, QPair<int, int> > &restrictions) void VMeasurements::SetRestrictions(const QMap<QString, QPair<qreal, qreal> > &restrictions)
{ {
QDomElement root = documentElement(); QDomElement root = documentElement();
QDomElement restrictionsTag = root.firstChildElement(TagRestrictions); QDomElement restrictionsTag = root.firstChildElement(TagRestrictions);
@ -935,14 +935,14 @@ void VMeasurements::SetRestrictions(const QMap<QString, QPair<int, int> > &restr
RemoveAllChildren(restrictionsTag); RemoveAllChildren(restrictionsTag);
QMap<QString, QPair<int, int> >::const_iterator i = restrictions.constBegin(); auto i = restrictions.constBegin();
while (i != restrictions.constEnd()) while (i != restrictions.constEnd())
{ {
QDomElement restrictionTag = createElement(TagRestriction); QDomElement restrictionTag = createElement(TagRestriction);
SetAttribute(restrictionTag, AttrCoordinates, i.key()); SetAttribute(restrictionTag, AttrCoordinates, i.key());
SetAttribute(restrictionTag, AttrMin, i.value().first); SetAttributeOrRemoveIf(restrictionTag, AttrMin, i.value().first, qFuzzyIsNull(i.value().first));
SetAttribute(restrictionTag, AttrMax, i.value().second); SetAttributeOrRemoveIf(restrictionTag, AttrMax, i.value().second, qFuzzyIsNull(i.value().second));
restrictionsTag.appendChild(restrictionTag); restrictionsTag.appendChild(restrictionTag);
++i; ++i;
@ -950,11 +950,11 @@ void VMeasurements::SetRestrictions(const QMap<QString, QPair<int, int> > &restr
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QPair<int, int> VMeasurements::Restriction(int base, int base2) const auto VMeasurements::Restriction(qreal base, qreal base2) const -> QPair<qreal, qreal>
{ {
const QMap<QString, QPair<int, int> > restrictions = GetRestrictions(); const QMap<QString, QPair<qreal, qreal> > restrictions = GetRestrictions();
const QString hash = VMeasurement::CorrectionHash(base, base2, 0); const QString hash = VMeasurement::CorrectionHash(base, base2, 0);
return restrictions.value(hash, QPair<int, int>(0, 0)); return restrictions.value(hash, QPair<qreal, qreal>(0, 0));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -1504,7 +1504,7 @@ DimesionLabels VMeasurements::ReadDimensionLabels(const QDomElement &dElement) c
if (labelTag.isElement()) if (labelTag.isElement())
{ {
const QDomElement l = labelTag.toElement(); const QDomElement l = labelTag.toElement();
const int value = GetParametrInt(l, AttrValue, QChar('0')); const qreal value = GetParametrDouble(l, AttrValue, QChar('0'));
const QString label = GetParametrEmptyString(l, AttrLabel); const QString label = GetParametrEmptyString(l, AttrLabel);
if (value > 0 && not label.isEmpty()) if (value > 0 && not label.isEmpty())

View File

@ -71,13 +71,13 @@ public:
void ClearForExport(); void ClearForExport();
MeasurementsType Type() const; MeasurementsType Type() const;
int DimensionABase() const; qreal DimensionABase() const;
int DimensionBBase() const; qreal DimensionBBase() const;
int DimensionCBase() const; qreal DimensionCBase() const;
int DimensionAStep() const; qreal DimensionAStep() const;
int DimensionBStep() const; qreal DimensionBStep() const;
int DimensionCStep() const; qreal DimensionCStep() const;
QString Notes() const; QString Notes() const;
void SetNotes(const QString &text); void SetNotes(const QString &text);
@ -117,12 +117,11 @@ public:
QString MeasurementForDimension(IMD type) const; QString MeasurementForDimension(IMD type) const;
QMap<MeasurementDimension, MeasurementDimension_p > Dimensions() const; auto Dimensions() const -> QMap<MeasurementDimension, MeasurementDimension_p >;
QMap<QString, QPair<int, int> > GetRestrictions() const; auto GetRestrictions() const -> QMap<QString, QPair<qreal, qreal> >;
void SetRestrictions(const QMap<QString, QPair<int, int> > &restrictions); void SetRestrictions(const QMap<QString, QPair<qreal, qreal> > &restrictions);
auto Restriction(qreal base, qreal base2=0) const -> QPair<double, double>;
QPair<int, int> Restriction(int base, int base2=0) const;
void SetDimensionLabels(const QMap<MeasurementDimension, DimesionLabels> &labels); void SetDimensionLabels(const QMap<MeasurementDimension, DimesionLabels> &labels);

View File

@ -351,7 +351,7 @@ void VMeasurement::SetDimension(IMD type)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VMeasurement::GetCorrection(int baseA, int baseB, int baseC) const qreal VMeasurement::GetCorrection(qreal baseA, qreal baseB, qreal baseC) const
{ {
return d->corrections.value(VMeasurement::CorrectionHash(baseA, baseB, baseC), 0); return d->corrections.value(VMeasurement::CorrectionHash(baseA, baseB, baseC), 0);
} }

View File

@ -111,7 +111,7 @@ public:
IMD GetDimension() const; IMD GetDimension() const;
void SetDimension(IMD type); void SetDimension(IMD type);
qreal GetCorrection(int baseA, int baseB, int baseC) const; qreal GetCorrection(qreal baseA, qreal baseB, qreal baseC) const;
QMap<QString, qreal> GetCorrections() const; QMap<QString, qreal> GetCorrections() const;
void SetCorrections(const QMap<QString, qreal> &corrections); void SetCorrections(const QMap<QString, qreal> &corrections);