Improve multisize measurements format. Allow decimal step 0.5.
This commit is contained in:
parent
d60653fcd3
commit
2b7769c80e
|
@ -6,6 +6,7 @@
|
|||
- New warning. Warn about empty measurements dimension value when preparing placeholders.
|
||||
- New option "Don't use the native file dialog".
|
||||
- Improve the layout option "Auto crop unused width".
|
||||
- Improve multisize measurements format. Allow decimal step 0.5.
|
||||
|
||||
# Version 0.7.41 Dec 4, 2020
|
||||
- Bug fixes.
|
||||
|
|
|
@ -96,11 +96,11 @@ void DialogDimensionLabels::DimensionChanged()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogDimensionLabels::LabelChanged(QTableWidgetItem *item)
|
||||
{
|
||||
if (item)
|
||||
if (item != nullptr)
|
||||
{
|
||||
MeasurementDimension type =
|
||||
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);
|
||||
labels.insert(value, item->text());
|
||||
|
@ -116,7 +116,7 @@ void DialogDimensionLabels::InitLabels()
|
|||
|
||||
const QList<MeasurementDimension_p> dimensions = m_dimensions.values();
|
||||
|
||||
for(auto &dimension : dimensions)
|
||||
for(const auto &dimension : dimensions)
|
||||
{
|
||||
m_labels.insert(dimension->Type(), dimension->Labels());
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ void DialogDimensionLabels::InitTable()
|
|||
return;
|
||||
}
|
||||
|
||||
const QVector<int> bases = dimension->ValidBases();
|
||||
const QVector<qreal> bases = dimension->ValidBases();
|
||||
|
||||
ui->tableWidget->setRowCount(bases.size());
|
||||
|
||||
|
@ -166,7 +166,7 @@ void DialogDimensionLabels::InitTable()
|
|||
|
||||
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));
|
||||
|
@ -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;
|
||||
|
||||
|
@ -203,18 +203,19 @@ QString DialogDimensionLabels::DimensionValue(const MeasurementDimension_p &dime
|
|||
{
|
||||
return QString::number(value);
|
||||
}
|
||||
else if (dimension->Type() == MeasurementDimension::Y)
|
||||
|
||||
if (dimension->Type() == MeasurementDimension::Y)
|
||||
{
|
||||
if (dimension->IsCircumference())
|
||||
{
|
||||
return QString::number(m_fullCircumference ? value*2 : value);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
bool fullCircumference, QWidget *parent = nullptr);
|
||||
virtual ~DialogDimensionLabels();
|
||||
|
||||
QMap<MeasurementDimension, DimesionLabels> Labels() const;
|
||||
auto Labels() const -> QMap<MeasurementDimension, DimesionLabels>;
|
||||
|
||||
protected:
|
||||
virtual void changeEvent(QEvent* event) override;
|
||||
|
@ -70,11 +70,11 @@ private:
|
|||
void InitDimensions();
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -37,16 +37,16 @@
|
|||
namespace
|
||||
{
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<int> FilterByMinimum(const QVector<int> &base, int restriction)
|
||||
auto FilterByMinimum(const QVector<qreal> &base, qreal restriction) -> QVector<qreal>
|
||||
{
|
||||
if (restriction <= 0)
|
||||
{
|
||||
return base;
|
||||
}
|
||||
|
||||
QVector<int> filtered;
|
||||
QVector<qreal> filtered;
|
||||
filtered.reserve(base.size());
|
||||
for(auto &b : base)
|
||||
for(const auto &b : base)
|
||||
{
|
||||
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)
|
||||
{
|
||||
return base;
|
||||
}
|
||||
|
||||
QVector<int> filtered;
|
||||
QVector<qreal> filtered;
|
||||
filtered.reserve(base.size());
|
||||
for(auto &b : base)
|
||||
for(const auto &b : base)
|
||||
{
|
||||
if (b <= restriction)
|
||||
{
|
||||
|
@ -75,11 +75,11 @@ QVector<int> FilterByMaximum(const QVector<int> &base, int restriction)
|
|||
}
|
||||
return filtered;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
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,
|
||||
QWidget *parent) :
|
||||
QDialog(parent),
|
||||
|
@ -157,15 +157,15 @@ void DialogRestrictDimension::RowSelected()
|
|||
|
||||
QTableWidgetItem *item = ui->tableWidget->currentItem();
|
||||
|
||||
if (item)
|
||||
if (item != nullptr)
|
||||
{
|
||||
int base1 = 0;
|
||||
int base2 = 0;
|
||||
qreal base1 = 0;
|
||||
qreal base2 = 0;
|
||||
MeasurementDimension_p dimension;
|
||||
|
||||
if (m_oneDimesionRestriction)
|
||||
{
|
||||
base1 = item->data(Qt::UserRole).toInt();
|
||||
base1 = item->data(Qt::UserRole).toDouble();
|
||||
|
||||
if (m_dimensions.size() > 1)
|
||||
{
|
||||
|
@ -174,8 +174,8 @@ void DialogRestrictDimension::RowSelected()
|
|||
}
|
||||
else
|
||||
{
|
||||
base1 = ui->comboBoxDimensionA->currentData().toInt();
|
||||
base2 = item->data(Qt::UserRole).toInt();
|
||||
base1 = ui->comboBoxDimensionA->currentData().toDouble();
|
||||
base2 = item->data(Qt::UserRole).toDouble();
|
||||
|
||||
if (m_dimensions.size() > 2)
|
||||
{
|
||||
|
@ -183,19 +183,19 @@ void DialogRestrictDimension::RowSelected()
|
|||
}
|
||||
}
|
||||
|
||||
QPair<int, int> restriction = m_restrictions.value(VMeasurement::CorrectionHash(base1, base2),
|
||||
QPair<int, int>(0, 0));
|
||||
QPair<qreal, qreal> restriction = m_restrictions.value(VMeasurement::CorrectionHash(base1, base2),
|
||||
QPair<qreal, qreal>(0, 0));
|
||||
|
||||
if (dimension.isNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const QVector<int> bases = dimension->ValidBases();
|
||||
const QVector<qreal> bases = dimension->ValidBases();
|
||||
|
||||
ui->comboBoxMin->blockSignals(true);
|
||||
ui->comboBoxMin->clear();
|
||||
QVector<int> filtered = FilterByMaximum(bases, restriction.second);
|
||||
QVector<qreal> filtered = FilterByMaximum(bases, restriction.second);
|
||||
FillBases(filtered, dimension, ui->comboBoxMin);
|
||||
int index = ui->comboBoxMin->findData(restriction.first);
|
||||
ui->comboBoxMin->setCurrentIndex(index != -1 ? index : 0);
|
||||
|
@ -224,25 +224,25 @@ void DialogRestrictDimension::MinRestrictionChanged()
|
|||
{
|
||||
QTableWidgetItem *item = ui->tableWidget->currentItem();
|
||||
|
||||
if (item)
|
||||
if (item != nullptr)
|
||||
{
|
||||
int base1 = 0;
|
||||
int base2 = 0;
|
||||
qreal base1 = 0;
|
||||
qreal base2 = 0;
|
||||
|
||||
if (m_oneDimesionRestriction)
|
||||
{
|
||||
base1 = item->data(Qt::UserRole).toInt();
|
||||
base1 = item->data(Qt::UserRole).toDouble();
|
||||
}
|
||||
else
|
||||
{
|
||||
base1 = ui->comboBoxDimensionA->currentData().toInt();
|
||||
base2 = item->data(Qt::UserRole).toInt();
|
||||
base1 = ui->comboBoxDimensionA->currentData().toDouble();
|
||||
base2 = item->data(Qt::UserRole).toDouble();
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
const int currentRow = ui->tableWidget->currentRow();
|
||||
|
@ -261,25 +261,25 @@ void DialogRestrictDimension::MaxRestrictionChanged()
|
|||
{
|
||||
QTableWidgetItem *item = ui->tableWidget->currentItem();
|
||||
|
||||
if (item)
|
||||
if (item != nullptr)
|
||||
{
|
||||
int base1 = 0;
|
||||
int base2 = 0;
|
||||
qreal base1 = 0;
|
||||
qreal base2 = 0;
|
||||
|
||||
if (m_oneDimesionRestriction)
|
||||
{
|
||||
base1 = item->data(Qt::UserRole).toInt();
|
||||
base1 = item->data(Qt::UserRole).toDouble();
|
||||
}
|
||||
else
|
||||
{
|
||||
base1 = ui->comboBoxDimensionA->currentData().toInt();
|
||||
base2 = item->data(Qt::UserRole).toInt();
|
||||
base1 = ui->comboBoxDimensionA->currentData().toDouble();
|
||||
base2 = item->data(Qt::UserRole).toDouble();
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
const int currentRow = ui->tableWidget->currentRow();
|
||||
|
@ -304,7 +304,6 @@ void DialogRestrictDimension::InitDimensionsBaseValues()
|
|||
if (m_dimensions.size() > index)
|
||||
{
|
||||
MeasurementDimension_p dimension = m_dimensions.at(index);
|
||||
const QString unit = UnitsToStr(dimension->Units(), true);
|
||||
name->setText(VAbstartMeasurementDimension::DimensionName(dimension->Type())+QChar(':'));
|
||||
name->setToolTip(VAbstartMeasurementDimension::DimensionToolTip(dimension->Type(),
|
||||
dimension->IsCircumference(),
|
||||
|
@ -316,7 +315,7 @@ void DialogRestrictDimension::InitDimensionsBaseValues()
|
|||
|
||||
if (not m_oneDimesionRestriction)
|
||||
{
|
||||
if (m_dimensions.size() > 0)
|
||||
if (not m_dimensions.empty())
|
||||
{
|
||||
DimensionsBaseValue(0, ui->labelDimensionA, ui->comboBoxDimensionA);
|
||||
}
|
||||
|
@ -338,10 +337,10 @@ void DialogRestrictDimension::InitDimensionGradation(const MeasurementDimension_
|
|||
{
|
||||
SCASSERT(control != nullptr)
|
||||
|
||||
int current = -1;
|
||||
qreal current = -1;
|
||||
if (control->currentIndex() != -1)
|
||||
{
|
||||
current = control->currentData().toInt();
|
||||
current = control->currentData().toDouble();
|
||||
}
|
||||
|
||||
control->blockSignals(true);
|
||||
|
@ -373,12 +372,12 @@ void DialogRestrictDimension::InitTable()
|
|||
if (m_dimensions.size() > index)
|
||||
{
|
||||
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->setVerticalHeaderLabels(DimensionLabels(basesA, dimensionA));
|
||||
|
||||
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->setHorizontalHeaderLabels(DimensionLabels(basesB, dimensionB));
|
||||
}
|
||||
|
@ -394,8 +393,8 @@ void DialogRestrictDimension::InitTable()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogRestrictDimension::RefreshTable()
|
||||
{
|
||||
QVector<int> basesRow;
|
||||
QVector<int> basesColumn;
|
||||
QVector<qreal> basesRow;
|
||||
QVector<qreal> basesColumn;
|
||||
|
||||
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();
|
||||
item->setData(Qt::UserRole, rowValue);
|
||||
|
||||
int base1 = 0;
|
||||
int base2 = 0;
|
||||
qreal base1 = 0;
|
||||
qreal base2 = 0;
|
||||
MeasurementDimension_p dimension;
|
||||
QVector<int> bases;
|
||||
QVector<qreal> bases;
|
||||
|
||||
if (m_oneDimesionRestriction)
|
||||
{
|
||||
|
@ -468,7 +467,7 @@ void DialogRestrictDimension::AddCell(int row, int column, int rowValue, int col
|
|||
}
|
||||
else
|
||||
{
|
||||
base1 = ui->comboBoxDimensionA->currentData().toInt();
|
||||
base1 = ui->comboBoxDimensionA->currentData().toDouble();
|
||||
base2 = rowValue;
|
||||
|
||||
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<int, int>(0, 0));
|
||||
int min = INT32_MIN;
|
||||
int max = INT32_MAX;
|
||||
QPair<qreal, qreal> restriction = m_restrictions.value(VMeasurement::CorrectionHash(base1, base2),
|
||||
QPair<qreal, qreal>(0, 0));
|
||||
qreal min = INT32_MIN;
|
||||
qreal max = INT32_MAX;
|
||||
|
||||
if (not dimension.isNull())
|
||||
{
|
||||
|
@ -500,11 +499,11 @@ void DialogRestrictDimension::AddCell(int row, int column, int rowValue, int col
|
|||
|
||||
if (leftRestriction && rightRestriction)
|
||||
{
|
||||
item->setIcon(QIcon("://icon/24x24/star.png"));
|
||||
item->setIcon(QIcon(QStringLiteral("://icon/24x24/star.png")));
|
||||
}
|
||||
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
|
||||
|
@ -533,8 +532,8 @@ void DialogRestrictDimension::EnableRestrictionControls(bool enable)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogRestrictDimension::FillBases(const QVector<int> &bases, const MeasurementDimension_p &dimension,
|
||||
QComboBox *control)
|
||||
void DialogRestrictDimension::FillBases(const QVector<qreal> &bases, const MeasurementDimension_p &dimension,
|
||||
QComboBox *control) const
|
||||
{
|
||||
SCASSERT(control != nullptr)
|
||||
|
||||
|
@ -551,7 +550,7 @@ void DialogRestrictDimension::FillBases(const QVector<int> &bases, const Measure
|
|||
}
|
||||
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())
|
||||
{
|
||||
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
|
||||
{
|
||||
|
@ -586,14 +585,15 @@ void DialogRestrictDimension::FillBases(const QVector<int> &bases, const Measure
|
|||
}
|
||||
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 QString units = showUnits ? UnitsToStr(dimension->Units(), true) : QString();
|
||||
|
@ -611,7 +611,7 @@ QStringList DialogRestrictDimension::DimensionLabels(const QVector<int> &bases,
|
|||
}
|
||||
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())
|
||||
{
|
||||
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
|
||||
{
|
||||
|
@ -646,7 +646,7 @@ QStringList DialogRestrictDimension::DimensionLabels(const QVector<int> &bases,
|
|||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,11 +47,11 @@ class DialogRestrictDimension : public QDialog
|
|||
|
||||
public:
|
||||
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);
|
||||
virtual ~DialogRestrictDimension();
|
||||
|
||||
QMap<QString, QPair<int, int> > Restrictions() const;
|
||||
auto Restrictions() const -> QMap<QString, QPair<qreal, qreal> >;
|
||||
|
||||
protected:
|
||||
virtual void changeEvent(QEvent* event) override;
|
||||
|
@ -69,7 +69,7 @@ private:
|
|||
bool m_oneDimesionRestriction;
|
||||
bool m_fullCircumference;
|
||||
QList<MeasurementDimension_p> m_dimensions;
|
||||
QMap<QString, QPair<int, int>> m_restrictions;
|
||||
QMap<QString, QPair<qreal, qreal>> m_restrictions;
|
||||
|
||||
void InitDimensionsBaseValues();
|
||||
void InitDimensionGradation(const MeasurementDimension_p &dimension, QComboBox *control);
|
||||
|
@ -77,17 +77,17 @@ private:
|
|||
|
||||
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 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;
|
||||
}
|
||||
|
|
|
@ -54,16 +54,16 @@ DialogSetupMultisize::DialogSetupMultisize(Unit unit, QWidget *parent) :
|
|||
InitZDimension();
|
||||
|
||||
// height
|
||||
connect(ui->spinBoxXDimensionMinValue, QOverload<int>::of(&QSpinBox::valueChanged),
|
||||
this, [this](int value)
|
||||
connect(ui->doubleSpinBoxXDimensionMinValue, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
|
||||
this, [this](qreal value)
|
||||
{
|
||||
DimensionMinValueChanged(value, ui->spinBoxXDimensionMaxValue, ui->comboBoxXDimensionStep,
|
||||
DimensionMinValueChanged(value, ui->doubleSpinBoxXDimensionMaxValue, ui->comboBoxXDimensionStep,
|
||||
ui->comboBoxXDimensionBase, m_xDimension);
|
||||
});
|
||||
connect(ui->spinBoxXDimensionMaxValue, QOverload<int>::of(&QSpinBox::valueChanged),
|
||||
this, [this](int value)
|
||||
connect(ui->doubleSpinBoxXDimensionMaxValue, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
|
||||
this, [this](qreal value)
|
||||
{
|
||||
DimensionMaxValueChanged(value, ui->spinBoxXDimensionMinValue, ui->comboBoxXDimensionStep,
|
||||
DimensionMaxValueChanged(value, ui->doubleSpinBoxXDimensionMinValue, ui->comboBoxXDimensionStep,
|
||||
ui->comboBoxXDimensionBase, m_xDimension);
|
||||
});
|
||||
connect(ui->comboBoxXDimensionStep, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
|
@ -78,16 +78,16 @@ DialogSetupMultisize::DialogSetupMultisize(Unit unit, QWidget *parent) :
|
|||
});
|
||||
|
||||
// size
|
||||
connect(ui->spinBoxYDimensionMinValue, QOverload<int>::of(&QSpinBox::valueChanged),
|
||||
this, [this](int value)
|
||||
connect(ui->doubleSpinBoxYDimensionMinValue, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
|
||||
this, [this](qreal value)
|
||||
{
|
||||
DimensionMinValueChanged(value, ui->spinBoxYDimensionMaxValue, ui->comboBoxYDimensionStep,
|
||||
DimensionMinValueChanged(value, ui->doubleSpinBoxYDimensionMaxValue, ui->comboBoxYDimensionStep,
|
||||
ui->comboBoxYDimensionBase, m_yDimension);
|
||||
});
|
||||
connect(ui->spinBoxYDimensionMaxValue, QOverload<int>::of(&QSpinBox::valueChanged),
|
||||
this, [this](int value)
|
||||
connect(ui->doubleSpinBoxYDimensionMaxValue, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
|
||||
this, [this](qreal value)
|
||||
{
|
||||
DimensionMaxValueChanged(value, ui->spinBoxYDimensionMinValue, ui->comboBoxYDimensionStep,
|
||||
DimensionMaxValueChanged(value, ui->doubleSpinBoxYDimensionMinValue, ui->comboBoxYDimensionStep,
|
||||
ui->comboBoxYDimensionBase, m_yDimension);
|
||||
});
|
||||
connect(ui->comboBoxYDimensionStep, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
|
@ -102,16 +102,16 @@ DialogSetupMultisize::DialogSetupMultisize(Unit unit, QWidget *parent) :
|
|||
});
|
||||
|
||||
// hip
|
||||
connect(ui->spinBoxWDimensionMinValue, QOverload<int>::of(&QSpinBox::valueChanged),
|
||||
this, [this](int value)
|
||||
connect(ui->doubleSpinBoxWDimensionMinValue, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
|
||||
this, [this](qreal value)
|
||||
{
|
||||
DimensionMinValueChanged(value, ui->spinBoxWDimensionMaxValue, ui->comboBoxWDimensionStep,
|
||||
DimensionMinValueChanged(value, ui->doubleSpinBoxWDimensionMaxValue, ui->comboBoxWDimensionStep,
|
||||
ui->comboBoxWDimensionBase, m_wDimension);
|
||||
});
|
||||
connect(ui->spinBoxWDimensionMaxValue, QOverload<int>::of(&QSpinBox::valueChanged),
|
||||
this, [this](int value)
|
||||
connect(ui->doubleSpinBoxWDimensionMaxValue, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
|
||||
this, [this](qreal value)
|
||||
{
|
||||
DimensionMaxValueChanged(value, ui->spinBoxWDimensionMinValue, ui->comboBoxWDimensionStep,
|
||||
DimensionMaxValueChanged(value, ui->doubleSpinBoxWDimensionMinValue, ui->comboBoxWDimensionStep,
|
||||
ui->comboBoxWDimensionBase, m_wDimension);
|
||||
});
|
||||
connect(ui->comboBoxWDimensionStep, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
|
@ -126,16 +126,16 @@ DialogSetupMultisize::DialogSetupMultisize(Unit unit, QWidget *parent) :
|
|||
});
|
||||
|
||||
// waist
|
||||
connect(ui->spinBoxZDimensionMinValue, QOverload<int>::of(&QSpinBox::valueChanged),
|
||||
this, [this](int value)
|
||||
connect(ui->doubleSpinBoxZDimensionMinValue, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
|
||||
this, [this](qreal value)
|
||||
{
|
||||
DimensionMinValueChanged(value, ui->spinBoxZDimensionMaxValue, ui->comboBoxZDimensionStep,
|
||||
DimensionMinValueChanged(value, ui->doubleSpinBoxZDimensionMaxValue, ui->comboBoxZDimensionStep,
|
||||
ui->comboBoxZDimensionBase, m_zDimension);
|
||||
});
|
||||
connect(ui->spinBoxZDimensionMaxValue, QOverload<int>::of(&QSpinBox::valueChanged),
|
||||
this, [this](int value)
|
||||
connect(ui->doubleSpinBoxZDimensionMaxValue, QOverload<qreal>::of(&QDoubleSpinBox::valueChanged),
|
||||
this, [this](qreal value)
|
||||
{
|
||||
DimensionMaxValueChanged(value, ui->spinBoxZDimensionMinValue, ui->comboBoxZDimensionStep,
|
||||
DimensionMaxValueChanged(value, ui->doubleSpinBoxZDimensionMinValue, ui->comboBoxZDimensionStep,
|
||||
ui->comboBoxZDimensionBase, m_zDimension);
|
||||
});
|
||||
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;
|
||||
|
||||
|
@ -198,7 +198,7 @@ QVector<MeasurementDimension_p> DialogSetupMultisize::Dimensions() const
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool DialogSetupMultisize::FullCircumference() const
|
||||
auto DialogSetupMultisize::FullCircumference() const -> bool
|
||||
{
|
||||
return ui->checkBoxFullCircumference->isChecked();
|
||||
}
|
||||
|
@ -240,16 +240,16 @@ void DialogSetupMultisize::showEvent(QShowEvent *event)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSetupMultisize::ShowFullCircumference()
|
||||
{
|
||||
auto ShowDimensionFullCircumference = [this](QSpinBox *spinboxMinValue, QSpinBox *spinboxMaxValue,
|
||||
QComboBox *comboBoxStep, QComboBox *comboBoxBase,
|
||||
auto ShowDimensionFullCircumference = [this](QDoubleSpinBox *doubleSpinBoxMinValue,
|
||||
QDoubleSpinBox *doubleSpinBoxMaxValue, QComboBox *comboBoxStep, QComboBox *comboBoxBase,
|
||||
const MeasurementDimension_p &dimension)
|
||||
{
|
||||
SCASSERT(spinboxMinValue != nullptr)
|
||||
SCASSERT(spinboxMaxValue != nullptr)
|
||||
SCASSERT(doubleSpinBoxMinValue != nullptr)
|
||||
SCASSERT(doubleSpinBoxMaxValue != nullptr)
|
||||
SCASSERT(comboBoxStep != nullptr)
|
||||
SCASSERT(comboBoxBase != nullptr)
|
||||
|
||||
InitDimension(spinboxMinValue, spinboxMaxValue, comboBoxStep, dimension);
|
||||
InitDimension(doubleSpinBoxMinValue, doubleSpinBoxMaxValue, comboBoxStep, dimension);
|
||||
UpdateBase(comboBoxBase, dimension);
|
||||
|
||||
comboBoxBase->blockSignals(true);
|
||||
|
@ -257,11 +257,11 @@ void DialogSetupMultisize::ShowFullCircumference()
|
|||
comboBoxBase->blockSignals(false);
|
||||
};
|
||||
|
||||
ShowDimensionFullCircumference(ui->spinBoxYDimensionMinValue, ui->spinBoxYDimensionMaxValue,
|
||||
ShowDimensionFullCircumference(ui->doubleSpinBoxYDimensionMinValue, ui->doubleSpinBoxYDimensionMaxValue,
|
||||
ui->comboBoxYDimensionStep, ui->comboBoxYDimensionBase, m_yDimension);
|
||||
ShowDimensionFullCircumference(ui->spinBoxWDimensionMinValue, ui->spinBoxWDimensionMaxValue,
|
||||
ShowDimensionFullCircumference(ui->doubleSpinBoxWDimensionMinValue, ui->doubleSpinBoxWDimensionMaxValue,
|
||||
ui->comboBoxWDimensionStep, ui->comboBoxWDimensionBase, m_wDimension);
|
||||
ShowDimensionFullCircumference(ui->spinBoxZDimensionMinValue, ui->spinBoxZDimensionMaxValue,
|
||||
ShowDimensionFullCircumference(ui->doubleSpinBoxZDimensionMinValue, ui->doubleSpinBoxZDimensionMaxValue,
|
||||
ui->comboBoxZDimensionStep, ui->comboBoxZDimensionBase, m_zDimension);
|
||||
|
||||
CheckState();
|
||||
|
@ -276,10 +276,10 @@ void DialogSetupMultisize::YDimensionCircumferenceChanged()
|
|||
const bool c = m_yDimension->IsCircumference();
|
||||
const QString unitStr = c ? " " + UnitsToStr(m_yDimension->Units()) : QString();
|
||||
|
||||
ui->spinBoxYDimensionMinValue->setSuffix(unitStr);
|
||||
ui->spinBoxYDimensionMaxValue->setSuffix(unitStr);
|
||||
ui->doubleSpinBoxYDimensionMinValue->setSuffix(unitStr);
|
||||
ui->doubleSpinBoxYDimensionMaxValue->setSuffix(unitStr);
|
||||
|
||||
InitDimension(ui->spinBoxYDimensionMinValue, ui->spinBoxYDimensionMaxValue, ui->comboBoxYDimensionStep,
|
||||
InitDimension(ui->doubleSpinBoxYDimensionMinValue, ui->doubleSpinBoxYDimensionMaxValue, ui->comboBoxYDimensionStep,
|
||||
m_yDimension);
|
||||
|
||||
UpdateBase(ui->comboBoxYDimensionBase, m_yDimension);
|
||||
|
@ -289,7 +289,7 @@ void DialogSetupMultisize::YDimensionCircumferenceChanged()
|
|||
ui->comboBoxYDimensionBase->blockSignals(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);
|
||||
|
||||
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)
|
||||
{
|
||||
SCASSERT(spinboxMinValue != nullptr)
|
||||
SCASSERT(spinboxMaxValue != nullptr)
|
||||
SCASSERT(doubleSpinBoxMinValue != nullptr)
|
||||
SCASSERT(doubleSpinBoxMaxValue != nullptr)
|
||||
|
||||
dimension->SetMinValue(dimension->RangeMin());
|
||||
dimension->SetMaxValue(dimension->RangeMax());
|
||||
|
@ -363,28 +364,31 @@ void DialogSetupMultisize::InitDimensionMinMax(QSpinBox *spinboxMinValue, QSpinB
|
|||
const bool fc = ui->checkBoxFullCircumference->isChecked();
|
||||
const bool c = dimension->IsCircumference();
|
||||
|
||||
spinboxMinValue->blockSignals(true);
|
||||
doubleSpinBoxMinValue->blockSignals(true);
|
||||
const QString unitStr = " " + UnitsToStr(dimension->Units());
|
||||
if (c || dimension->Type() == MeasurementDimension::X)
|
||||
{
|
||||
spinboxMinValue->setSuffix(unitStr);
|
||||
doubleSpinBoxMinValue->setSuffix(unitStr);
|
||||
}
|
||||
|
||||
spinboxMinValue->setMinimum(c && fc ? dimension->RangeMin()*2 : dimension->RangeMin());
|
||||
spinboxMinValue->setMaximum(c && fc ? dimension->MaxValue()*2 : dimension->MaxValue());
|
||||
spinboxMinValue->setValue(c && fc ? dimension->MinValue()*2 : dimension->MinValue());
|
||||
spinboxMinValue->blockSignals(false);
|
||||
doubleSpinBoxMinValue->setDecimals(dimension->Units() == Unit::Mm ? 0 : 1);
|
||||
doubleSpinBoxMinValue->setMinimum(c && fc ? dimension->RangeMin()*2 : dimension->RangeMin());
|
||||
doubleSpinBoxMinValue->setMaximum(c && fc ? dimension->MaxValue()*2 : dimension->MaxValue());
|
||||
doubleSpinBoxMinValue->setValue(c && fc ? dimension->MinValue()*2 : dimension->MinValue());
|
||||
doubleSpinBoxMinValue->blockSignals(false);
|
||||
|
||||
spinboxMaxValue->blockSignals(true);
|
||||
doubleSpinBoxMaxValue->blockSignals(true);
|
||||
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());
|
||||
spinboxMaxValue->setValue(c && fc ? dimension->RangeMax()*2 : dimension->RangeMax());
|
||||
spinboxMaxValue->setValue(c && fc ? dimension->MaxValue()*2 : dimension->MaxValue());
|
||||
spinboxMaxValue->blockSignals(false);
|
||||
|
||||
doubleSpinBoxMaxValue->setDecimals(dimension->Units() == Unit::Mm ? 0 : 1);
|
||||
doubleSpinBoxMaxValue->setMinimum(c && fc ? dimension->MinValue()*2 : dimension->MinValue());
|
||||
doubleSpinBoxMaxValue->setMaximum(c && fc ? dimension->RangeMax()*2 : dimension->RangeMax());
|
||||
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);
|
||||
|
||||
comboBoxStep->blockSignals(true);
|
||||
const QVector<int> steps = dimension->ValidSteps();
|
||||
const QVector<qreal> steps = dimension->ValidSteps();
|
||||
comboBoxStep->clear();
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -412,52 +416,52 @@ void DialogSetupMultisize::InitDimensionStep(QComboBox *comboBoxStep,
|
|||
comboBoxStep->blockSignals(false);
|
||||
|
||||
bool ok = false;
|
||||
const int step = comboBoxStep->currentData().toInt(&ok);
|
||||
const qreal step = comboBoxStep->currentData().toDouble(&ok);
|
||||
dimension->SetStep(ok ? step : -1);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSetupMultisize::InitDimension(QSpinBox *spinboxMinValue, QSpinBox *spinboxMaxValue, QComboBox *comboBoxStep,
|
||||
const MeasurementDimension_p &dimension)
|
||||
void DialogSetupMultisize::InitDimension(QDoubleSpinBox *doubleSpinBoxMinValue, QDoubleSpinBox *doubleSpinBoxMaxValue,
|
||||
QComboBox *comboBoxStep, const MeasurementDimension_p &dimension)
|
||||
{
|
||||
InitDimensionMinMax(spinboxMinValue, spinboxMaxValue, dimension);
|
||||
InitDimensionMinMax(doubleSpinBoxMinValue, doubleSpinBoxMaxValue, dimension);
|
||||
InitDimensionStep(comboBoxStep, dimension);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSetupMultisize::InitXDimension()
|
||||
{
|
||||
InitDimension(ui->spinBoxXDimensionMinValue, ui->spinBoxXDimensionMaxValue, ui->comboBoxXDimensionStep,
|
||||
InitDimension(ui->doubleSpinBoxXDimensionMinValue, ui->doubleSpinBoxXDimensionMaxValue, ui->comboBoxXDimensionStep,
|
||||
m_xDimension);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSetupMultisize::InitYDimension()
|
||||
{
|
||||
InitDimension(ui->spinBoxYDimensionMinValue, ui->spinBoxYDimensionMaxValue, ui->comboBoxYDimensionStep,
|
||||
InitDimension(ui->doubleSpinBoxYDimensionMinValue, ui->doubleSpinBoxYDimensionMaxValue, ui->comboBoxYDimensionStep,
|
||||
m_yDimension);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSetupMultisize::InitWDimension()
|
||||
{
|
||||
InitDimension(ui->spinBoxWDimensionMinValue, ui->spinBoxWDimensionMaxValue, ui->comboBoxWDimensionStep,
|
||||
InitDimension(ui->doubleSpinBoxWDimensionMinValue, ui->doubleSpinBoxWDimensionMaxValue, ui->comboBoxWDimensionStep,
|
||||
m_wDimension);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSetupMultisize::InitZDimension()
|
||||
{
|
||||
InitDimension(ui->spinBoxZDimensionMinValue, ui->spinBoxZDimensionMaxValue, ui->comboBoxZDimensionStep,
|
||||
InitDimension(ui->doubleSpinBoxZDimensionMinValue, ui->doubleSpinBoxZDimensionMaxValue, ui->comboBoxZDimensionStep,
|
||||
m_zDimension);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSetupMultisize::DimensionMinValueChanged(int value, QSpinBox *spinboxMaxValue, QComboBox *comboBoxStep,
|
||||
QComboBox *comboBoxBase,
|
||||
void DialogSetupMultisize::DimensionMinValueChanged(qreal value, QDoubleSpinBox *doubleSpinBoxMaxValue,
|
||||
QComboBox *comboBoxStep, QComboBox *comboBoxBase,
|
||||
const MeasurementDimension_p &dimension)
|
||||
{
|
||||
SCASSERT(spinboxMaxValue != nullptr)
|
||||
SCASSERT(doubleSpinBoxMaxValue != nullptr)
|
||||
SCASSERT(comboBoxStep != nullptr)
|
||||
SCASSERT(comboBoxBase != nullptr)
|
||||
|
||||
|
@ -466,11 +470,11 @@ void DialogSetupMultisize::DimensionMinValueChanged(int value, QSpinBox *spinbox
|
|||
|
||||
dimension->SetMinValue(c && fc ? value / 2 : value);
|
||||
|
||||
spinboxMaxValue->blockSignals(true);
|
||||
spinboxMaxValue->setMinimum(value);
|
||||
spinboxMaxValue->blockSignals(false);
|
||||
doubleSpinBoxMaxValue->blockSignals(true);
|
||||
doubleSpinBoxMaxValue->setMinimum(value);
|
||||
doubleSpinBoxMaxValue->blockSignals(false);
|
||||
|
||||
dimension->SetMaxValue(c && fc ? spinboxMaxValue->value() / 2 : spinboxMaxValue->value());
|
||||
dimension->SetMaxValue(c && fc ? doubleSpinBoxMaxValue->value() / 2 : doubleSpinBoxMaxValue->value());
|
||||
|
||||
UpdateSteps(comboBoxStep, dimension);
|
||||
UpdateBase(comboBoxBase, dimension);
|
||||
|
@ -479,11 +483,11 @@ void DialogSetupMultisize::DimensionMinValueChanged(int value, QSpinBox *spinbox
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSetupMultisize::DimensionMaxValueChanged(int value, QSpinBox *spinboxMinValue, QComboBox *comboBoxStep,
|
||||
QComboBox *comboBoxBase,
|
||||
void DialogSetupMultisize::DimensionMaxValueChanged(qreal value, QDoubleSpinBox *doubleSpinBoxMinValue,
|
||||
QComboBox *comboBoxStep, QComboBox *comboBoxBase,
|
||||
const MeasurementDimension_p &dimension)
|
||||
{
|
||||
SCASSERT(spinboxMinValue != nullptr)
|
||||
SCASSERT(doubleSpinBoxMinValue != nullptr)
|
||||
SCASSERT(comboBoxStep != nullptr)
|
||||
SCASSERT(comboBoxBase != nullptr)
|
||||
|
||||
|
@ -492,11 +496,11 @@ void DialogSetupMultisize::DimensionMaxValueChanged(int value, QSpinBox *spinbox
|
|||
|
||||
dimension->SetMaxValue(c && fc ? value / 2 : value);
|
||||
|
||||
spinboxMinValue->blockSignals(true);
|
||||
spinboxMinValue->setMaximum(value);
|
||||
spinboxMinValue->blockSignals(false);
|
||||
doubleSpinBoxMinValue->blockSignals(true);
|
||||
doubleSpinBoxMinValue->setMaximum(value);
|
||||
doubleSpinBoxMinValue->blockSignals(false);
|
||||
|
||||
dimension->SetMinValue(c && fc ? spinboxMinValue->value() / 2 : spinboxMinValue->value());
|
||||
dimension->SetMinValue(c && fc ? doubleSpinBoxMinValue->value() / 2 : doubleSpinBoxMinValue->value());
|
||||
|
||||
UpdateSteps(comboBoxStep, dimension);
|
||||
UpdateBase(comboBoxBase, dimension);
|
||||
|
@ -512,7 +516,7 @@ void DialogSetupMultisize::DimensionStepChanged(int index, QComboBox *comboBoxSt
|
|||
SCASSERT(comboBoxBase != nullptr)
|
||||
|
||||
bool ok = false;
|
||||
const int step = comboBoxStep->itemData(index).toInt(&ok);
|
||||
const qreal step = comboBoxStep->itemData(index).toDouble(&ok);
|
||||
dimension->SetStep(ok ? step : -1);
|
||||
|
||||
UpdateBase(comboBoxBase, dimension);
|
||||
|
@ -527,7 +531,7 @@ void DialogSetupMultisize::DimensionBaseChanged(int index, QComboBox *comboBoxBa
|
|||
SCASSERT(comboBoxBase != nullptr)
|
||||
|
||||
bool ok = false;
|
||||
const int base = comboBoxBase->itemData(index).toInt(&ok);
|
||||
const qreal base = comboBoxBase->itemData(index).toDouble(&ok);
|
||||
dimension->SetBaseValue(ok ? base : -1);
|
||||
|
||||
CheckState();
|
||||
|
@ -539,16 +543,16 @@ void DialogSetupMultisize::UpdateSteps(QComboBox *comboBoxStep,
|
|||
{
|
||||
SCASSERT(comboBoxStep != nullptr)
|
||||
|
||||
int oldStep = -1;
|
||||
qreal oldStep = -1;
|
||||
if (comboBoxStep->currentIndex() != -1)
|
||||
{
|
||||
oldStep = comboBoxStep->currentData().toInt();
|
||||
oldStep = comboBoxStep->currentData().toDouble();
|
||||
}
|
||||
|
||||
comboBoxStep->blockSignals(true);
|
||||
|
||||
const QString unitStr = " " + UnitsToStr(dimension->Units());
|
||||
const QVector<int> steps = dimension->ValidSteps();
|
||||
const QVector<qreal> steps = dimension->ValidSteps();
|
||||
comboBoxStep->clear();
|
||||
|
||||
const bool fc = ui->checkBoxFullCircumference->isChecked();
|
||||
|
@ -556,7 +560,7 @@ void DialogSetupMultisize::UpdateSteps(QComboBox *comboBoxStep,
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -564,7 +568,7 @@ void DialogSetupMultisize::UpdateSteps(QComboBox *comboBoxStep,
|
|||
comboBoxStep->blockSignals(false);
|
||||
|
||||
bool ok = false;
|
||||
const int step = comboBoxStep->currentData().toInt(&ok);
|
||||
const qreal step = comboBoxStep->currentData().toDouble(&ok);
|
||||
dimension->SetStep(ok ? step : -1);
|
||||
}
|
||||
|
||||
|
@ -574,23 +578,23 @@ void DialogSetupMultisize::UpdateBase(QComboBox *comboBoxBase,
|
|||
{
|
||||
SCASSERT(comboBoxBase != nullptr)
|
||||
|
||||
int oldBase = -1;
|
||||
qreal oldBase = -1;
|
||||
if (comboBoxBase->currentIndex() != -1)
|
||||
{
|
||||
oldBase = comboBoxBase->currentData().toInt();
|
||||
oldBase = comboBoxBase->currentData().toDouble();
|
||||
}
|
||||
|
||||
comboBoxBase->blockSignals(true);
|
||||
|
||||
const QString unitStr = " " + UnitsToStr(dimension->Units());
|
||||
const QVector<int> bases = dimension->ValidBases();
|
||||
const QVector<qreal> bases = dimension->ValidBases();
|
||||
comboBoxBase->clear();
|
||||
const bool fc = ui->checkBoxFullCircumference->isChecked();
|
||||
const bool c = dimension->IsCircumference();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -598,7 +602,7 @@ void DialogSetupMultisize::UpdateBase(QComboBox *comboBoxBase,
|
|||
comboBoxBase->blockSignals(false);
|
||||
|
||||
bool ok = false;
|
||||
const int base = comboBoxBase->currentData().toInt(&ok);
|
||||
const qreal base = comboBoxBase->currentData().toDouble(&ok);
|
||||
dimension->SetBaseValue(ok ? base : -1);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include "../vformat/vdimensions.h"
|
||||
#include "../vmisc/def.h"
|
||||
|
||||
class QSpinBox;
|
||||
class QDoubleSpinBox;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
|
@ -48,9 +48,9 @@ public:
|
|||
explicit DialogSetupMultisize(Unit unit, QWidget *parent = nullptr);
|
||||
~DialogSetupMultisize();
|
||||
|
||||
QVector<MeasurementDimension_p> Dimensions() const;
|
||||
auto Dimensions() const -> QVector<MeasurementDimension_p>;
|
||||
|
||||
bool FullCircumference() const;
|
||||
auto FullCircumference() const -> bool;
|
||||
|
||||
protected:
|
||||
virtual void changeEvent(QEvent* event) override;
|
||||
|
@ -71,23 +71,21 @@ private:
|
|||
|
||||
void CheckState();
|
||||
|
||||
void InitDimensionMinMax(QSpinBox *spinboxMinValue, QSpinBox *spinboxMaxValue,
|
||||
void InitDimensionMinMax(QDoubleSpinBox *doubleSpinBoxMinValue, QDoubleSpinBox *doubleSpinBoxMaxValue,
|
||||
const MeasurementDimension_p &dimension);
|
||||
void InitDimensionStep(QComboBox *comboBoxStep,const MeasurementDimension_p &dimension);
|
||||
|
||||
void InitDimension(QSpinBox *spinboxMinValue, QSpinBox *spinboxMaxValue, QComboBox *comboBoxStep,
|
||||
const MeasurementDimension_p &dimension);
|
||||
void InitDimension(QDoubleSpinBox *doubleSpinBoxMinValue, QDoubleSpinBox *doubleSpinBoxMaxValue,
|
||||
QComboBox *comboBoxStep, const MeasurementDimension_p &dimension);
|
||||
void InitXDimension();
|
||||
void InitYDimension();
|
||||
void InitWDimension();
|
||||
void InitZDimension();
|
||||
|
||||
void DimensionMinValueChanged(int value, QSpinBox *spinboxMaxValue, QComboBox *comboBoxStep,
|
||||
QComboBox *comboBoxBase,
|
||||
const MeasurementDimension_p &dimension);
|
||||
void DimensionMaxValueChanged(int value, QSpinBox *spinboxMinValue, QComboBox *comboBoxStep,
|
||||
QComboBox *comboBoxBase,
|
||||
const MeasurementDimension_p &dimension);
|
||||
void DimensionMinValueChanged(qreal value, QDoubleSpinBox *doubleSpinBoxMaxValue, QComboBox *comboBoxStep,
|
||||
QComboBox *comboBoxBase, const MeasurementDimension_p &dimension);
|
||||
void DimensionMaxValueChanged(qreal value, QDoubleSpinBox *doubleSpinBoxMinValue, QComboBox *comboBoxStep,
|
||||
QComboBox *comboBoxBase, const MeasurementDimension_p &dimension);
|
||||
|
||||
void DimensionStepChanged(int index, QComboBox *comboBoxStep, QComboBox *comboBoxBase,
|
||||
const MeasurementDimension_p &dimension);
|
||||
|
|
|
@ -48,16 +48,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
|
@ -65,13 +55,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
|
@ -112,6 +95,26 @@
|
|||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -141,13 +144,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
|
@ -155,13 +151,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
|
@ -202,6 +191,26 @@
|
|||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -241,13 +250,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<widget class="QLabel" name="label_14">
|
||||
<property name="text">
|
||||
|
@ -255,13 +257,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="text">
|
||||
|
@ -302,6 +297,26 @@
|
|||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -331,13 +346,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
|
@ -345,13 +353,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
|
@ -392,6 +393,26 @@
|
|||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -420,23 +441,23 @@
|
|||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>groupBoxXDimension</tabstop>
|
||||
<tabstop>spinBoxXDimensionMinValue</tabstop>
|
||||
<tabstop>spinBoxXDimensionMaxValue</tabstop>
|
||||
<tabstop>doubleSpinBoxXDimensionMinValue</tabstop>
|
||||
<tabstop>doubleSpinBoxXDimensionMaxValue</tabstop>
|
||||
<tabstop>comboBoxXDimensionStep</tabstop>
|
||||
<tabstop>comboBoxXDimensionBase</tabstop>
|
||||
<tabstop>groupBoxYDimension</tabstop>
|
||||
<tabstop>spinBoxYDimensionMinValue</tabstop>
|
||||
<tabstop>spinBoxYDimensionMaxValue</tabstop>
|
||||
<tabstop>doubleSpinBoxYDimensionMinValue</tabstop>
|
||||
<tabstop>doubleSpinBoxYDimensionMaxValue</tabstop>
|
||||
<tabstop>comboBoxYDimensionStep</tabstop>
|
||||
<tabstop>comboBoxYDimensionBase</tabstop>
|
||||
<tabstop>groupBoxWDimension</tabstop>
|
||||
<tabstop>spinBoxWDimensionMinValue</tabstop>
|
||||
<tabstop>spinBoxWDimensionMaxValue</tabstop>
|
||||
<tabstop>doubleSpinBoxWDimensionMinValue</tabstop>
|
||||
<tabstop>doubleSpinBoxWDimensionMaxValue</tabstop>
|
||||
<tabstop>comboBoxWDimensionStep</tabstop>
|
||||
<tabstop>comboBoxWDimensionBase</tabstop>
|
||||
<tabstop>groupBoxZDimension</tabstop>
|
||||
<tabstop>spinBoxZDimensionMinValue</tabstop>
|
||||
<tabstop>spinBoxZDimensionMaxValue</tabstop>
|
||||
<tabstop>doubleSpinBoxZDimensionMinValue</tabstop>
|
||||
<tabstop>doubleSpinBoxZDimensionMaxValue</tabstop>
|
||||
<tabstop>comboBoxZDimensionStep</tabstop>
|
||||
<tabstop>comboBoxZDimensionBase</tabstop>
|
||||
</tabstops>
|
||||
|
|
|
@ -194,7 +194,7 @@ bool TMainWindow::SetDimensionABase(int base)
|
|||
gradationDimensionA->setCurrentIndex(i);
|
||||
}
|
||||
|
||||
if (base != currentDimensionA)
|
||||
if (not VFuzzyComparePossibleNulls(base, currentDimensionA))
|
||||
{
|
||||
qCCritical(tMainWindow, "%s\n", qPrintable(tr("Invalid base value for dimension A")));
|
||||
return false;
|
||||
|
@ -219,7 +219,7 @@ bool TMainWindow::SetDimensionBBase(int base)
|
|||
gradationDimensionB->setCurrentIndex(i);
|
||||
}
|
||||
|
||||
if (base != currentDimensionB)
|
||||
if (not VFuzzyComparePossibleNulls(base, currentDimensionB))
|
||||
{
|
||||
qCCritical(tMainWindow, "%s\n", qPrintable(tr("Invalid base value for dimension B")));
|
||||
return false;
|
||||
|
@ -245,7 +245,7 @@ bool TMainWindow::SetDimensionCBase(int base)
|
|||
gradationDimensionC->setCurrentIndex(i);
|
||||
}
|
||||
|
||||
if (base != currentDimensionC)
|
||||
if (not VFuzzyComparePossibleNulls(base, currentDimensionC))
|
||||
{
|
||||
qCCritical(tMainWindow, "%s\n", qPrintable(tr("Invalid base value for dimension C")));
|
||||
return false;
|
||||
|
@ -1535,7 +1535,7 @@ void TMainWindow::ImportFromPattern()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void TMainWindow::DimensionABaseChanged()
|
||||
{
|
||||
currentDimensionA = gradationDimensionA->currentData().toInt();
|
||||
currentDimensionA = gradationDimensionA->currentData().toDouble();
|
||||
|
||||
const QList<MeasurementDimension_p> dimensions = m->Dimensions().values();
|
||||
if (dimensions.size() > 1)
|
||||
|
@ -1556,7 +1556,7 @@ void TMainWindow::DimensionABaseChanged()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void TMainWindow::DimensionBBaseChanged()
|
||||
{
|
||||
currentDimensionB = gradationDimensionB->currentData().toInt();
|
||||
currentDimensionB = gradationDimensionB->currentData().toDouble();
|
||||
|
||||
const QList<MeasurementDimension_p> dimensions = m->Dimensions().values();
|
||||
|
||||
|
@ -1572,7 +1572,7 @@ void TMainWindow::DimensionBBaseChanged()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void TMainWindow::DimensionCBaseChanged()
|
||||
{
|
||||
currentDimensionC = gradationDimensionC->currentData().toInt();
|
||||
currentDimensionC = gradationDimensionC->currentData().toDouble();
|
||||
gradation->start();
|
||||
}
|
||||
|
||||
|
@ -2249,7 +2249,7 @@ void TMainWindow::ExportToIndividual()
|
|||
void TMainWindow::RestrictSecondDimesion()
|
||||
{
|
||||
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 fullCircumference = m->IsFullCircumference();
|
||||
|
@ -2269,7 +2269,7 @@ void TMainWindow::RestrictSecondDimesion()
|
|||
void TMainWindow::RestrictThirdDimesion()
|
||||
{
|
||||
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 fullCircumference = m->IsFullCircumference();
|
||||
|
@ -2677,16 +2677,16 @@ void TMainWindow::InitDimensionGradation(int index, const MeasurementDimension_p
|
|||
const bool fc = m->IsFullCircumference();
|
||||
const QString unit = UnitsToStr(m->MUnit(), true);
|
||||
|
||||
int current = -1;
|
||||
qreal current = -1;
|
||||
if (control->currentIndex() != -1)
|
||||
{
|
||||
current = control->currentData().toInt();
|
||||
current = control->currentData().toDouble();
|
||||
}
|
||||
|
||||
control->blockSignals(true);
|
||||
control->clear();
|
||||
|
||||
const QVector<int> bases = DimensionRestrictedValues(index, dimension);
|
||||
const QVector<qreal> bases = DimensionRestrictedValues(index, dimension);
|
||||
const DimesionLabels labels = dimension->Labels();
|
||||
|
||||
if (dimension->Type() == MeasurementDimension::X)
|
||||
|
@ -4125,7 +4125,7 @@ void TMainWindow::SetDimensionBases()
|
|||
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)
|
||||
{
|
||||
|
@ -4140,7 +4140,7 @@ void TMainWindow::SetDimensionBases()
|
|||
}
|
||||
else
|
||||
{
|
||||
value = control->currentData().toInt();
|
||||
value = control->currentData().toDouble();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -4155,7 +4155,7 @@ void TMainWindow::SetCurrentDimensionValues()
|
|||
{
|
||||
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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
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();
|
||||
int max = bases.indexOf(restriction.second) != -1 ? restriction.second : dimension->MaxValue();
|
||||
const QVector<qreal> bases = dimension->ValidBases();
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -4222,22 +4215,6 @@ void TMainWindow::SetDecimals()
|
|||
switch (mUnit)
|
||||
{
|
||||
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->setSingleStep(0.1);
|
||||
|
||||
|
@ -4253,6 +4230,22 @@ void TMainWindow::SetDecimals()
|
|||
ui->doubleSpinBoxShiftC->setDecimals(1);
|
||||
ui->doubleSpinBoxShiftC->setSingleStep(0.1);
|
||||
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:
|
||||
ui->doubleSpinBoxBaseValue->setDecimals(5);
|
||||
ui->doubleSpinBoxBaseValue->setSingleStep(0.00001);
|
||||
|
|
|
@ -153,9 +153,9 @@ private:
|
|||
Unit mUnit{Unit::Cm};
|
||||
Unit pUnit{Unit::Cm};
|
||||
MeasurementsType mType{MeasurementsType::Individual};
|
||||
int currentDimensionA{0};
|
||||
int currentDimensionB{0};
|
||||
int currentDimensionC{0};
|
||||
qreal currentDimensionA{0};
|
||||
qreal currentDimensionB{0};
|
||||
qreal currentDimensionC{0};
|
||||
QString curFile{};
|
||||
QComboBox *gradationDimensionA{nullptr};
|
||||
QComboBox *gradationDimensionB{nullptr};
|
||||
|
@ -248,7 +248,7 @@ private:
|
|||
void SetDimensionBases();
|
||||
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;
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
@ -2072,7 +2072,7 @@ void MainWindow::StoreMultisizeMDimensions()
|
|||
|
||||
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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -2163,10 +2163,10 @@ QVector<int> MainWindow::DimensionRestrictedValues(int index, const MeasurementD
|
|||
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();
|
||||
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)
|
||||
{
|
||||
|
@ -2182,7 +2182,7 @@ void MainWindow::SetDimensionBases()
|
|||
{
|
||||
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)
|
||||
{
|
||||
|
@ -2199,7 +2199,7 @@ void MainWindow::SetDimensionBases()
|
|||
}
|
||||
else
|
||||
{
|
||||
value = control->currentData().toInt();
|
||||
value = control->currentData().toDouble();
|
||||
}
|
||||
|
||||
control->blockSignals(false);
|
||||
|
@ -3439,9 +3439,8 @@ void MainWindow::FullParseFile()
|
|||
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
|
||||
* myself. Later in method customEvent call undo.*/
|
||||
if (qApp->getOpeningPattern())
|
||||
|
@ -3823,7 +3822,7 @@ void MainWindow::PatternChangesWereSaved(bool saved)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void MainWindow::DimensionABaseChanged()
|
||||
{
|
||||
m_currentDimensionA = dimensionA->currentData().toInt();
|
||||
m_currentDimensionA = dimensionA->currentData().toDouble();
|
||||
|
||||
const QList<MeasurementDimension_p> dimensions = m->Dimensions().values();
|
||||
if (dimensions.size() > 1)
|
||||
|
@ -3844,7 +3843,7 @@ void MainWindow::DimensionABaseChanged()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void MainWindow::DimensionBBaseChanged()
|
||||
{
|
||||
m_currentDimensionB = dimensionB->currentData().toInt();
|
||||
m_currentDimensionB = dimensionB->currentData().toDouble();
|
||||
|
||||
const QList<MeasurementDimension_p> dimensions = m->Dimensions().values();
|
||||
|
||||
|
@ -3860,7 +3859,7 @@ void MainWindow::DimensionBBaseChanged()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void MainWindow::DimensionCBaseChanged()
|
||||
{
|
||||
m_currentDimensionC = dimensionC->currentData().toInt();
|
||||
m_currentDimensionC = dimensionC->currentData().toDouble();
|
||||
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)
|
||||
|
||||
const bool fc = m->IsFullCircumference();
|
||||
const QString unit = UnitsToStr(qApp->MeasurementsUnits(), true);
|
||||
|
||||
int current = -1;
|
||||
qreal current = -1;
|
||||
if (control->currentIndex() != -1)
|
||||
{
|
||||
current = control->currentData().toInt();
|
||||
current = control->currentData().toDouble();
|
||||
}
|
||||
|
||||
control->blockSignals(true);
|
||||
control->clear();
|
||||
|
||||
const QVector<int> bases = DimensionRestrictedValues(index, dimension);
|
||||
const QVector<qreal> bases = DimensionRestrictedValues(index, dimension);
|
||||
const DimesionLabels labels = dimension->Labels();
|
||||
|
||||
if (dimension->Type() == MeasurementDimension::X)
|
||||
|
|
|
@ -293,16 +293,16 @@ private:
|
|||
|
||||
QList<QPointer<WatermarkWindow>> m_watermarkEditors{};
|
||||
|
||||
int m_currentDimensionA{0};
|
||||
int m_currentDimensionB{0};
|
||||
int m_currentDimensionC{0};
|
||||
qreal m_currentDimensionA{0};
|
||||
qreal m_currentDimensionB{0};
|
||||
qreal m_currentDimensionC{0};
|
||||
|
||||
QSharedPointer<VMeasurements> m{};
|
||||
|
||||
QTimer *m_gradation;
|
||||
|
||||
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 ToolBarStages();
|
||||
|
@ -373,7 +373,7 @@ private:
|
|||
void InitScenes();
|
||||
|
||||
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);
|
||||
bool DoExport(const VCommandLinePtr& expParams);
|
||||
|
@ -411,7 +411,7 @@ private:
|
|||
void StoreMultisizeMDimensions();
|
||||
void StoreIndividualMDimensions();
|
||||
|
||||
QVector<int> DimensionRestrictedValues(int index, const MeasurementDimension_p &dimension);
|
||||
QVector<qreal> DimensionRestrictedValues(int index, const MeasurementDimension_p &dimension);
|
||||
void SetDimensionBases();
|
||||
};
|
||||
|
||||
|
|
|
@ -45,8 +45,8 @@
|
|||
<xs:element name="restriction" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="coordinates" type="xs:string" use="required"/>
|
||||
<xs:attribute name="min" type="dimesionValue" use="required"/>
|
||||
<xs:attribute name="max" type="dimesionValue" use="required"/>
|
||||
<xs:attribute name="min" type="dimesionValue"/>
|
||||
<xs:attribute name="max" type="dimesionValue"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
|
@ -122,13 +122,13 @@
|
|||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="dimesionValue">
|
||||
<xs:restriction base="xs:unsignedInt">
|
||||
<xs:restriction base="xs:double">
|
||||
<xs:minInclusive value="6"/>
|
||||
<xs:maxInclusive value="2720"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="dimensionStep">
|
||||
<xs:restriction base="xs:unsignedInt">
|
||||
<xs:restriction base="xs:double">
|
||||
<xs:minInclusive value="0"/>
|
||||
<xs:maxInclusive value="80"/>
|
||||
</xs:restriction>
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include <QSet>
|
||||
#include <QVector>
|
||||
#include <cmath>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
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_minValue(min),
|
||||
m_maxValue(max),
|
||||
|
@ -44,48 +45,57 @@ VAbstartMeasurementDimension::VAbstartMeasurementDimension(Unit units, int min,
|
|||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VAbstartMeasurementDimension::IsValid()
|
||||
auto VAbstartMeasurementDimension::IsValid() -> bool
|
||||
{
|
||||
m_error.clear();
|
||||
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;
|
||||
if (diff == 0)
|
||||
QVector<qreal> steps;
|
||||
steps.reserve(qRound((stepBarrier - s) * 2 - 1));
|
||||
|
||||
const qreal diff = m_maxValue - m_minValue;
|
||||
if (qFuzzyIsNull(diff))
|
||||
{
|
||||
steps.append(0); // only one possible value
|
||||
}
|
||||
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);
|
||||
if (diff % step == 0)
|
||||
const qreal step = (m_units == Unit::Mm ? candidate * 10 : candidate);
|
||||
qreal intpart;
|
||||
if (qFuzzyIsNull(std::modf(diff / step, &intpart)))
|
||||
{
|
||||
steps.append(step);
|
||||
}
|
||||
candidate += s;
|
||||
}
|
||||
while(candidate < stepBarrier);
|
||||
}
|
||||
|
||||
return steps;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<int> VAbstartMeasurementDimension::ValidBases() const
|
||||
auto VAbstartMeasurementDimension::ValidBases() const -> QVector<qreal>
|
||||
{
|
||||
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;
|
||||
list.reserve(bases.size());
|
||||
for(auto &base : bases)
|
||||
{
|
||||
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;
|
||||
}
|
||||
else if (step == 0)
|
||||
|
||||
if (qFuzzyIsNull(step))
|
||||
{
|
||||
step = 1;
|
||||
}
|
||||
|
||||
for (int value = min; value <= max; value += step)
|
||||
validBases.reserve(qRound((max - min) / step));
|
||||
|
||||
qreal value = min;
|
||||
do
|
||||
{
|
||||
validBases.append(value);
|
||||
value += step;
|
||||
}
|
||||
while(value < max + step);
|
||||
|
||||
return validBases;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VAbstartMeasurementDimension::IsRangeValid()
|
||||
auto VAbstartMeasurementDimension::IsRangeValid() -> bool
|
||||
{
|
||||
bool valid = m_minValue > 0 && m_maxValue > 0 && m_minValue >= RangeMin() && m_minValue <= RangeMax()
|
||||
&& 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;
|
||||
if (not valid)
|
||||
|
@ -143,7 +159,7 @@ bool VAbstartMeasurementDimension::IsStepValid()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VAbstartMeasurementDimension::IsBaseValid()
|
||||
auto VAbstartMeasurementDimension::IsBaseValid() -> bool
|
||||
{
|
||||
bool valid = ValidBases().indexOf(m_baseValue) != -1;
|
||||
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;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VAbstartMeasurementDimension::DimensionName(MeasurementDimension type)
|
||||
auto VAbstartMeasurementDimension::DimensionName(MeasurementDimension type) -> QString
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
@ -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)
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
MeasurementDimension VXMeasurementDimension::Type() const
|
||||
auto VXMeasurementDimension::Type() const -> MeasurementDimension
|
||||
{
|
||||
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)
|
||||
{
|
||||
case Unit::Cm:
|
||||
return 50;
|
||||
return rangeMinCm;
|
||||
case Unit::Mm:
|
||||
return 500;
|
||||
return rangeMinMm;
|
||||
case Unit::Inch:
|
||||
return 19;
|
||||
return rangeMinInch;
|
||||
default:
|
||||
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)
|
||||
{
|
||||
case Unit::Cm:
|
||||
return 272;
|
||||
return rangeMaxCm;
|
||||
case Unit::Mm:
|
||||
return 2720;
|
||||
return rangeMaxMm;
|
||||
case Unit::Inch:
|
||||
return 107;
|
||||
return rangeMaxInch;
|
||||
default:
|
||||
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)
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
MeasurementDimension VYMeasurementDimension::Type() const
|
||||
auto VYMeasurementDimension::Type() const -> MeasurementDimension
|
||||
{
|
||||
return MeasurementDimension::Y;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VYMeasurementDimension::RangeMin() const
|
||||
auto VYMeasurementDimension::RangeMin() const -> int
|
||||
{
|
||||
if (m_circumference)
|
||||
{
|
||||
const int rangeMinCm = 22;
|
||||
const int rangeMinMm = 220;
|
||||
const int rangeMinInch = 8;
|
||||
|
||||
switch(m_units)
|
||||
{
|
||||
case Unit::Cm:
|
||||
return 22;
|
||||
return rangeMinCm;
|
||||
case Unit::Mm:
|
||||
return 220;
|
||||
return rangeMinMm;
|
||||
case Unit::Inch:
|
||||
return 8;
|
||||
return rangeMinInch;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 6;
|
||||
const int rangeMinCir = 6;
|
||||
return rangeMinCir;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VYMeasurementDimension::RangeMax() const
|
||||
auto VYMeasurementDimension::RangeMax() const -> int
|
||||
{
|
||||
if (m_circumference)
|
||||
{
|
||||
const int rangeMaxCm = 72;
|
||||
const int rangeMaxMm = 720;
|
||||
const int rangeMaxInch = 29;
|
||||
|
||||
switch(m_units)
|
||||
{
|
||||
case Unit::Cm:
|
||||
return 72;
|
||||
return rangeMaxCm;
|
||||
case Unit::Mm:
|
||||
return 720;
|
||||
return rangeMaxMm;
|
||||
case Unit::Inch:
|
||||
return 29;
|
||||
return rangeMaxInch;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
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)
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
MeasurementDimension VWMeasurementDimension::Type() const
|
||||
auto VWMeasurementDimension::Type() const -> MeasurementDimension
|
||||
{
|
||||
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)
|
||||
{
|
||||
case Unit::Cm:
|
||||
return 20;
|
||||
return rangeMinCm;
|
||||
case Unit::Mm:
|
||||
return 200;
|
||||
return rangeMinMm;
|
||||
case Unit::Inch:
|
||||
return 8;
|
||||
return rangeMinInch;
|
||||
default:
|
||||
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)
|
||||
{
|
||||
case Unit::Cm:
|
||||
return 65;
|
||||
return rangeMaxCm;
|
||||
case Unit::Mm:
|
||||
return 650;
|
||||
return rangeMaxMm;
|
||||
case Unit::Inch:
|
||||
return 26;
|
||||
return rangeMaxInch;
|
||||
default:
|
||||
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)
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
MeasurementDimension VZMeasurementDimension::Type() const
|
||||
auto VZMeasurementDimension::Type() const -> MeasurementDimension
|
||||
{
|
||||
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)
|
||||
{
|
||||
case Unit::Cm:
|
||||
return 20;
|
||||
return rangeMinCm;
|
||||
case Unit::Mm:
|
||||
return 200;
|
||||
return rangeMinMm;
|
||||
case Unit::Inch:
|
||||
return 8;
|
||||
return rangeMinInch;
|
||||
default:
|
||||
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)
|
||||
{
|
||||
case Unit::Cm:
|
||||
return 75;
|
||||
return rangeMaxCm;
|
||||
case Unit::Mm:
|
||||
return 750;
|
||||
return rangeMaxMm;
|
||||
case Unit::Inch:
|
||||
return 30;
|
||||
return rangeMaxInch;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ class VAbstartMeasurementDimension;
|
|||
template <class T> class QSharedPointer;
|
||||
|
||||
using MeasurementDimension_p = QSharedPointer<VAbstartMeasurementDimension>;
|
||||
using DimesionLabels = QMap<int, QString>;
|
||||
using DimesionLabels = QMap<qreal, QString>;
|
||||
|
||||
class VAbstartMeasurementDimension
|
||||
{
|
||||
|
@ -53,128 +53,128 @@ class VAbstartMeasurementDimension
|
|||
public:
|
||||
VAbstartMeasurementDimension() =default;
|
||||
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 MeasurementDimension Type() const =0;
|
||||
|
||||
virtual bool IsValid();
|
||||
|
||||
int MinValue() const;
|
||||
void SetMinValue(int minValue);
|
||||
auto MinValue() const -> qreal;
|
||||
void SetMinValue(qreal minValue);
|
||||
|
||||
int MaxValue() const;
|
||||
void SetMaxValue(int maxValue);
|
||||
auto MaxValue() const -> qreal;
|
||||
void SetMaxValue(qreal maxValue);
|
||||
|
||||
int Step() const;
|
||||
void SetStep(int step);
|
||||
auto Step() const -> qreal;
|
||||
void SetStep(qreal step);
|
||||
|
||||
int BaseValue() const;
|
||||
void SetBaseValue(int baseValue);
|
||||
auto BaseValue() const -> qreal;
|
||||
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 int RangeMax() const =0;
|
||||
virtual auto RangeMin() const -> int =0;
|
||||
virtual auto RangeMax() const -> int =0;
|
||||
|
||||
QVector<int> ValidSteps() const;
|
||||
QVector<int> ValidBases() const;
|
||||
QStringList ValidBasesList() const;
|
||||
auto ValidSteps() const -> QVector<qreal>;
|
||||
auto ValidBases() const -> QVector<qreal>;
|
||||
auto ValidBasesList() const -> QStringList;
|
||||
|
||||
static QVector<int> ValidBases(int min, int max, int step);
|
||||
static QString DimensionName(MeasurementDimension type);
|
||||
static QString DimensionToolTip(MeasurementDimension type, bool circumference, bool fc);
|
||||
static auto ValidBases(qreal min, qreal max, qreal step) -> QVector<qreal>;
|
||||
static auto DimensionName(MeasurementDimension type) -> QString;
|
||||
static auto DimensionToolTip(MeasurementDimension type, bool circumference, bool fc) -> QString;
|
||||
|
||||
DimesionLabels Labels() const;
|
||||
auto Labels() const -> DimesionLabels;
|
||||
void SetLabels(const DimesionLabels &labels);
|
||||
|
||||
protected:
|
||||
Unit m_units{Unit::Cm};
|
||||
int m_minValue{0};
|
||||
int m_maxValue{0};
|
||||
int m_step{-1};
|
||||
int m_baseValue{0};
|
||||
qreal m_minValue{0};
|
||||
qreal m_maxValue{0};
|
||||
qreal m_step{-1};
|
||||
qreal m_baseValue{0};
|
||||
QString m_error{};
|
||||
DimesionLabels m_labels{};
|
||||
|
||||
bool IsRangeValid();
|
||||
bool IsStepValid();
|
||||
bool IsBaseValid();
|
||||
bool IsUnitsValid() const;
|
||||
auto IsRangeValid() -> bool;
|
||||
auto IsStepValid() -> bool;
|
||||
auto IsBaseValid() -> bool;
|
||||
auto IsUnitsValid() const -> bool;
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline int VAbstartMeasurementDimension::MinValue() const
|
||||
inline auto VAbstartMeasurementDimension::MinValue() const -> qreal
|
||||
{
|
||||
return m_minValue;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline void VAbstartMeasurementDimension::SetMinValue(int minValue)
|
||||
inline void VAbstartMeasurementDimension::SetMinValue(qreal minValue)
|
||||
{
|
||||
m_minValue = minValue;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline int VAbstartMeasurementDimension::MaxValue() const
|
||||
inline auto VAbstartMeasurementDimension::MaxValue() const -> qreal
|
||||
{
|
||||
return m_maxValue;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline void VAbstartMeasurementDimension::SetMaxValue(int maxValue)
|
||||
inline void VAbstartMeasurementDimension::SetMaxValue(qreal maxValue)
|
||||
{
|
||||
m_maxValue = maxValue;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline int VAbstartMeasurementDimension::Step() const
|
||||
inline auto VAbstartMeasurementDimension::Step() const -> qreal
|
||||
{
|
||||
return m_step;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline void VAbstartMeasurementDimension::SetStep(int step)
|
||||
inline void VAbstartMeasurementDimension::SetStep(qreal step)
|
||||
{
|
||||
m_step = step;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline int VAbstartMeasurementDimension::BaseValue() const
|
||||
inline auto VAbstartMeasurementDimension::BaseValue() const -> qreal
|
||||
{
|
||||
return m_baseValue;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline void VAbstartMeasurementDimension::SetBaseValue(int baseValue)
|
||||
inline void VAbstartMeasurementDimension::SetBaseValue(qreal baseValue)
|
||||
{
|
||||
m_baseValue = baseValue;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline QString VAbstartMeasurementDimension::Error() const
|
||||
inline auto VAbstartMeasurementDimension::Error() const -> QString
|
||||
{
|
||||
return m_error;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline Unit VAbstartMeasurementDimension::Units() const
|
||||
inline auto VAbstartMeasurementDimension::Units() const -> Unit
|
||||
{
|
||||
return m_units;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline bool VAbstartMeasurementDimension::IsCircumference() const
|
||||
inline auto VAbstartMeasurementDimension::IsCircumference() const -> bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline DimesionLabels VAbstartMeasurementDimension::Labels() const
|
||||
inline auto VAbstartMeasurementDimension::Labels() const -> DimesionLabels
|
||||
{
|
||||
return m_labels;
|
||||
}
|
||||
|
@ -192,18 +192,18 @@ class VXMeasurementDimension : public VAbstartMeasurementDimension
|
|||
public:
|
||||
VXMeasurementDimension() =default;
|
||||
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 int RangeMax() const override;
|
||||
virtual auto RangeMin() const -> int override;
|
||||
virtual auto RangeMax() const -> int override;
|
||||
|
||||
virtual bool IsCircumference() const override;
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline bool VXMeasurementDimension::IsCircumference() const
|
||||
inline auto VXMeasurementDimension::IsCircumference() const -> bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -215,14 +215,14 @@ class VYMeasurementDimension : public VAbstartMeasurementDimension
|
|||
public:
|
||||
VYMeasurementDimension() =default;
|
||||
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 int RangeMax() const override;
|
||||
virtual auto RangeMin() const -> int override;
|
||||
virtual auto RangeMax() const -> int override;
|
||||
|
||||
virtual bool IsCircumference() const override;
|
||||
virtual auto IsCircumference() const -> bool override;
|
||||
void SetCircumference(bool circumference);
|
||||
|
||||
private:
|
||||
|
@ -248,12 +248,12 @@ class VWMeasurementDimension : public VAbstartMeasurementDimension
|
|||
public:
|
||||
VWMeasurementDimension() =default;
|
||||
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 int RangeMax() const override;
|
||||
virtual auto RangeMin() const -> int override;
|
||||
virtual auto RangeMax() const -> int override;
|
||||
};
|
||||
|
||||
// VZMeasurementDimension
|
||||
|
@ -263,12 +263,12 @@ class VZMeasurementDimension : public VAbstartMeasurementDimension
|
|||
public:
|
||||
VZMeasurementDimension() =default;
|
||||
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 int RangeMax() const override;
|
||||
virtual auto RangeMin() const -> int override;
|
||||
virtual auto RangeMax() const -> int override;
|
||||
};
|
||||
|
||||
#endif // VDIMENSIONS_H
|
||||
|
|
|
@ -433,7 +433,7 @@ MeasurementsType VMeasurements::Type() const
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VMeasurements::DimensionABase() const
|
||||
qreal VMeasurements::DimensionABase() const
|
||||
{
|
||||
if (type == MeasurementsType::Multisize)
|
||||
{
|
||||
|
@ -448,7 +448,7 @@ int VMeasurements::DimensionABase() const
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VMeasurements::DimensionBBase() const
|
||||
qreal VMeasurements::DimensionBBase() const
|
||||
{
|
||||
if (type == MeasurementsType::Multisize)
|
||||
{
|
||||
|
@ -463,7 +463,7 @@ int VMeasurements::DimensionBBase() const
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VMeasurements::DimensionCBase() const
|
||||
qreal VMeasurements::DimensionCBase() const
|
||||
{
|
||||
if (type == MeasurementsType::Multisize)
|
||||
{
|
||||
|
@ -478,7 +478,7 @@ int VMeasurements::DimensionCBase() const
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VMeasurements::DimensionAStep() const
|
||||
qreal VMeasurements::DimensionAStep() const
|
||||
{
|
||||
if (type == MeasurementsType::Multisize)
|
||||
{
|
||||
|
@ -493,7 +493,7 @@ int VMeasurements::DimensionAStep() const
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VMeasurements::DimensionBStep() const
|
||||
qreal VMeasurements::DimensionBStep() const
|
||||
{
|
||||
if (type == MeasurementsType::Multisize)
|
||||
{
|
||||
|
@ -508,7 +508,7 @@ int VMeasurements::DimensionBStep() const
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VMeasurements::DimensionCStep() const
|
||||
qreal VMeasurements::DimensionCStep() const
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
@ -860,10 +860,10 @@ QMap<MeasurementDimension, MeasurementDimension_p > VMeasurements::Dimensions()
|
|||
{
|
||||
const QDomElement dom = list.at(i).toElement();
|
||||
const MeasurementDimension type = StrToDimensionType(GetParametrString(dom, AttrType));
|
||||
const int min = GetParametrInt(dom, AttrMin, QChar('0'));
|
||||
const int max = GetParametrInt(dom, AttrMax, QChar('0'));
|
||||
const int step = GetParametrInt(dom, AttrStep, QString("-1"));
|
||||
const int base = GetParametrInt(dom, AttrBase, QChar('0'));
|
||||
const qreal min = GetParametrDouble(dom, AttrMin, QChar('0'));
|
||||
const qreal max = GetParametrDouble(dom, AttrMax, QChar('0'));
|
||||
const qreal step = GetParametrDouble(dom, AttrStep, QStringLiteral("-1"));
|
||||
const qreal base = GetParametrDouble(dom, AttrBase, QChar('0'));
|
||||
|
||||
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);
|
||||
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();
|
||||
|
||||
QString coordinates = GetParametrString(res, AttrCoordinates);
|
||||
const int min = GetParametrInt(res, AttrMin, QChar('0'));
|
||||
const int max = GetParametrInt(res, AttrMax, QChar('0'));
|
||||
const qreal min = GetParametrDouble(res, AttrMin, QChar('0'));
|
||||
const qreal max = GetParametrDouble(res, AttrMax, QChar('0'));
|
||||
|
||||
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 restrictionsTag = root.firstChildElement(TagRestrictions);
|
||||
|
@ -935,14 +935,14 @@ void VMeasurements::SetRestrictions(const QMap<QString, QPair<int, int> > &restr
|
|||
|
||||
RemoveAllChildren(restrictionsTag);
|
||||
|
||||
QMap<QString, QPair<int, int> >::const_iterator i = restrictions.constBegin();
|
||||
auto i = restrictions.constBegin();
|
||||
while (i != restrictions.constEnd())
|
||||
{
|
||||
QDomElement restrictionTag = createElement(TagRestriction);
|
||||
|
||||
SetAttribute(restrictionTag, AttrCoordinates, i.key());
|
||||
SetAttribute(restrictionTag, AttrMin, i.value().first);
|
||||
SetAttribute(restrictionTag, AttrMax, i.value().second);
|
||||
SetAttributeOrRemoveIf(restrictionTag, AttrMin, i.value().first, qFuzzyIsNull(i.value().first));
|
||||
SetAttributeOrRemoveIf(restrictionTag, AttrMax, i.value().second, qFuzzyIsNull(i.value().second));
|
||||
|
||||
restrictionsTag.appendChild(restrictionTag);
|
||||
++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);
|
||||
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())
|
||||
{
|
||||
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);
|
||||
|
||||
if (value > 0 && not label.isEmpty())
|
||||
|
|
|
@ -71,13 +71,13 @@ public:
|
|||
void ClearForExport();
|
||||
|
||||
MeasurementsType Type() const;
|
||||
int DimensionABase() const;
|
||||
int DimensionBBase() const;
|
||||
int DimensionCBase() const;
|
||||
qreal DimensionABase() const;
|
||||
qreal DimensionBBase() const;
|
||||
qreal DimensionCBase() const;
|
||||
|
||||
int DimensionAStep() const;
|
||||
int DimensionBStep() const;
|
||||
int DimensionCStep() const;
|
||||
qreal DimensionAStep() const;
|
||||
qreal DimensionBStep() const;
|
||||
qreal DimensionCStep() const;
|
||||
|
||||
QString Notes() const;
|
||||
void SetNotes(const QString &text);
|
||||
|
@ -117,12 +117,11 @@ public:
|
|||
|
||||
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;
|
||||
void SetRestrictions(const QMap<QString, QPair<int, int> > &restrictions);
|
||||
|
||||
QPair<int, int> Restriction(int base, int base2=0) const;
|
||||
auto GetRestrictions() const -> QMap<QString, QPair<qreal, qreal> >;
|
||||
void SetRestrictions(const QMap<QString, QPair<qreal, qreal> > &restrictions);
|
||||
auto Restriction(qreal base, qreal base2=0) const -> QPair<double, double>;
|
||||
|
||||
void SetDimensionLabels(const QMap<MeasurementDimension, DimesionLabels> &labels);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ public:
|
|||
IMD GetDimension() const;
|
||||
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;
|
||||
void SetCorrections(const QMap<QString, qreal> &corrections);
|
||||
|
|
Loading…
Reference in New Issue
Block a user