diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index 7c686a4d5..f0d076908 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -397,19 +397,19 @@ void TMainWindow::Remove() if (mType == MeasurementsType::Standard) { ui->labelCalculatedValue->blockSignals(true); - ui->spinBoxBaseValue->blockSignals(true); - ui->spinBoxInSizes->blockSignals(true); - ui->spinBoxInHeights->blockSignals(true); + ui->doubleSpinBoxBaseValue->blockSignals(true); + ui->doubleSpinBoxInSizes->blockSignals(true); + ui->doubleSpinBoxInHeights->blockSignals(true); ui->labelCalculatedValue->setText(""); - ui->spinBoxBaseValue->setValue(0); - ui->spinBoxInSizes->setValue(0); - ui->spinBoxInHeights->setValue(0); + ui->doubleSpinBoxBaseValue->setValue(0); + ui->doubleSpinBoxInSizes->setValue(0); + ui->doubleSpinBoxInHeights->setValue(0); ui->labelCalculatedValue->blockSignals(false); - ui->spinBoxBaseValue->blockSignals(false); - ui->spinBoxInSizes->blockSignals(false); - ui->spinBoxInHeights->blockSignals(false); + ui->doubleSpinBoxBaseValue->blockSignals(false); + ui->doubleSpinBoxInSizes->blockSignals(false); + ui->doubleSpinBoxInHeights->blockSignals(false); } else { @@ -662,19 +662,19 @@ void TMainWindow::ShowMData() if (mType == MeasurementsType::Standard) { ui->labelCalculatedValue->blockSignals(true); - ui->spinBoxBaseValue->blockSignals(true); - ui->spinBoxInSizes->blockSignals(true); - ui->spinBoxInHeights->blockSignals(true); + ui->doubleSpinBoxBaseValue->blockSignals(true); + ui->doubleSpinBoxInSizes->blockSignals(true); + ui->doubleSpinBoxInHeights->blockSignals(true); ui->labelCalculatedValue->setText(QString().setNum(data->GetTableValue(nameField->text(), mType))); - ui->spinBoxBaseValue->setValue(static_cast(meash->GetBase())); - ui->spinBoxInSizes->setValue(static_cast(meash->GetKsize())); - ui->spinBoxInHeights->setValue(static_cast(meash->GetKheight())); + ui->doubleSpinBoxBaseValue->setValue(static_cast(meash->GetBase())); + ui->doubleSpinBoxInSizes->setValue(static_cast(meash->GetKsize())); + ui->doubleSpinBoxInHeights->setValue(static_cast(meash->GetKheight())); ui->labelCalculatedValue->blockSignals(false); - ui->spinBoxBaseValue->blockSignals(false); - ui->spinBoxInSizes->blockSignals(false); - ui->spinBoxInHeights->blockSignals(false); + ui->doubleSpinBoxBaseValue->blockSignals(false); + ui->doubleSpinBoxInSizes->blockSignals(false); + ui->doubleSpinBoxInHeights->blockSignals(false); } else { @@ -848,7 +848,7 @@ void TMainWindow::SaveMValue() } //--------------------------------------------------------------------------------------------------------------------- -void TMainWindow::SaveMBaseValue(int value) +void TMainWindow::SaveMBaseValue(double value) { const int row = ui->tableWidget->currentRow(); @@ -873,7 +873,7 @@ void TMainWindow::SaveMBaseValue(int value) } //--------------------------------------------------------------------------------------------------------------------- -void TMainWindow::SaveMSizeIncrease(int value) +void TMainWindow::SaveMSizeIncrease(double value) { const int row = ui->tableWidget->currentRow(); @@ -898,7 +898,7 @@ void TMainWindow::SaveMSizeIncrease(int value) } //--------------------------------------------------------------------------------------------------------------------- -void TMainWindow::SaveMHeightIncrease(int value) +void TMainWindow::SaveMHeightIncrease(double value) { const int row = ui->tableWidget->currentRow(); @@ -1033,12 +1033,17 @@ void TMainWindow::InitWindow() connect(gradationSizes, static_cast(&QComboBox::currentIndexChanged), this, &TMainWindow::ChangedSize); - connect(ui->spinBoxBaseValue, static_cast(&QSpinBox::valueChanged), this, - &TMainWindow::SaveMBaseValue); - connect(ui->spinBoxInSizes, static_cast(&QSpinBox::valueChanged), this, - &TMainWindow::SaveMSizeIncrease); - connect(ui->spinBoxInHeights, static_cast(&QSpinBox::valueChanged), this, - &TMainWindow::SaveMHeightIncrease); + connect(ui->doubleSpinBoxBaseValue, + static_cast(&QDoubleSpinBox::valueChanged), + this, &TMainWindow::SaveMBaseValue); + connect(ui->doubleSpinBoxInSizes, + static_cast(&QDoubleSpinBox::valueChanged), + this, &TMainWindow::SaveMSizeIncrease); + connect(ui->doubleSpinBoxInHeights, + static_cast(&QDoubleSpinBox::valueChanged), + this, &TMainWindow::SaveMHeightIncrease); + + SetDecimals(); } else { @@ -1052,11 +1057,11 @@ void TMainWindow::InitWindow() // Tab Measurements delete ui->labelBaseValue; - delete ui->spinBoxBaseValue; + delete ui->doubleSpinBoxBaseValue; delete ui->labelInSizes; - delete ui->spinBoxInSizes; + delete ui->doubleSpinBoxInSizes; delete ui->labelInHeights; - delete ui->spinBoxInHeights; + delete ui->doubleSpinBoxInHeights; // Tab Information delete ui->labelBaseSize; @@ -1401,9 +1406,9 @@ void TMainWindow::MFields(bool enabled) if (mType == MeasurementsType::Standard) { - ui->spinBoxBaseValue->setEnabled(enabled); - ui->spinBoxInSizes->setEnabled(enabled); - ui->spinBoxInHeights->setEnabled(enabled); + ui->doubleSpinBoxBaseValue->setEnabled(enabled); + ui->doubleSpinBoxInSizes->setEnabled(enabled); + ui->doubleSpinBoxInHeights->setEnabled(enabled); } else { @@ -1455,3 +1460,28 @@ void TMainWindow::EvalFormula(const QString &formula, VContainer *data, QLabel * } } } + +//--------------------------------------------------------------------------------------------------------------------- +void TMainWindow::SetDecimals() +{ + switch (mUnit) + { + case Unit::Cm: + ui->doubleSpinBoxBaseValue->setDecimals(1); + ui->doubleSpinBoxInSizes->setDecimals(1); + ui->doubleSpinBoxInHeights->setDecimals(1); + break; + case Unit::Mm: + ui->doubleSpinBoxBaseValue->setDecimals(0); + ui->doubleSpinBoxInSizes->setDecimals(0); + ui->doubleSpinBoxInHeights->setDecimals(0); + break; + case Unit::Inch: + ui->doubleSpinBoxBaseValue->setDecimals(5); + ui->doubleSpinBoxInSizes->setDecimals(5); + ui->doubleSpinBoxInHeights->setDecimals(5); + break; + default: + break; + } +} diff --git a/src/app/tape/tmainwindow.h b/src/app/tape/tmainwindow.h index df680357c..0fe3d3b1a 100644 --- a/src/app/tape/tmainwindow.h +++ b/src/app/tape/tmainwindow.h @@ -41,6 +41,7 @@ namespace Ui class QComboBox; class QTableWidgetItem; +class QLabel; class TMainWindow : public QMainWindow { @@ -89,9 +90,9 @@ private slots: void SaveMName(); void SaveMValue(); - void SaveMBaseValue(int value); - void SaveMSizeIncrease(int value); - void SaveMHeightIncrease(int value); + void SaveMBaseValue(double value); + void SaveMSizeIncrease(double value); + void SaveMHeightIncrease(double value); void SaveMDescription(); private: @@ -109,6 +110,7 @@ private: void SetupMenu(); void InitWindow(); void InitTable(); + void SetDecimals(); void ShowUnits(); void ShowHeaderUnits(QTableWidget *table, int column, const QString &unit); diff --git a/src/app/tape/tmainwindow.ui b/src/app/tape/tmainwindow.ui index d32e6b4b5..7cef16408 100644 --- a/src/app/tape/tmainwindow.ui +++ b/src/app/tape/tmainwindow.ui @@ -326,42 +326,42 @@ - - + + false - -1000 + -10000.000000000000000 - 1000 + 10000.000000000000000 - + false - -1000 + -10000.000000000000000 - 1000 + 10000.000000000000000 - - + + false - -1000 + -10000.000000000000000 - 1000 + 10000.000000000000000 diff --git a/src/libs/vformat/vmeasurements.cpp b/src/libs/vformat/vmeasurements.cpp index 2c2f7ae37..b5ee456e3 100644 --- a/src/libs/vformat/vmeasurements.cpp +++ b/src/libs/vformat/vmeasurements.cpp @@ -182,9 +182,9 @@ void VMeasurements::ReadMeasurements() const VMeasurement *meash; if (type == MeasurementsType::Standard) { - const quint32 base = GetParametrUInt(dom, AttrBase, "0"); - const quint32 ksize = GetParametrUInt(dom, AttrSizeIncrease, "0"); - const quint32 kheight = GetParametrUInt(dom, AttrHeightIncrease, "0"); + const qreal base = GetParametrDouble(dom, AttrBase, "0"); + const qreal ksize = GetParametrDouble(dom, AttrSizeIncrease, "0"); + const qreal kheight = GetParametrDouble(dom, AttrHeightIncrease, "0"); meash = new VMeasurement(i, name, BaseSize(), BaseHeight(), base, ksize, kheight, "", description); } @@ -376,7 +376,7 @@ void VMeasurements::SetMValue(const QString &name, const QString &text) } //--------------------------------------------------------------------------------------------------------------------- -void VMeasurements::SetMBaseValue(const QString &name, int value) +void VMeasurements::SetMBaseValue(const QString &name, double value) { QDomElement node = FindM(name); if (not node.isNull()) @@ -386,7 +386,7 @@ void VMeasurements::SetMBaseValue(const QString &name, int value) } //--------------------------------------------------------------------------------------------------------------------- -void VMeasurements::SetMSizeIncrease(const QString &name, int value) +void VMeasurements::SetMSizeIncrease(const QString &name, double value) { QDomElement node = FindM(name); if (not node.isNull()) @@ -396,7 +396,7 @@ void VMeasurements::SetMSizeIncrease(const QString &name, int value) } //--------------------------------------------------------------------------------------------------------------------- -void VMeasurements::SetMHeightIncrease(const QString &name, int value) +void VMeasurements::SetMHeightIncrease(const QString &name, double value) { QDomElement node = FindM(name); if (not node.isNull()) diff --git a/src/libs/vformat/vmeasurements.h b/src/libs/vformat/vmeasurements.h index b185f2761..88c2f8724 100644 --- a/src/libs/vformat/vmeasurements.h +++ b/src/libs/vformat/vmeasurements.h @@ -79,9 +79,9 @@ public: void SetMName(const QString &name, const QString &text); void SetMValue(const QString &name, const QString &text); - void SetMBaseValue(const QString &name, int value); - void SetMSizeIncrease(const QString &name, int value); - void SetMHeightIncrease(const QString &name, int value); + void SetMBaseValue(const QString &name, double value); + void SetMSizeIncrease(const QString &name, double value); + void SetMHeightIncrease(const QString &name, double value); void SetMDescription(const QString &name, const QString &text); static const QString TagVST;