Values should be fractional.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2015-07-25 09:10:56 +03:00
parent 34859e5913
commit 0026b698bb
5 changed files with 88 additions and 56 deletions

View File

@ -397,19 +397,19 @@ void TMainWindow::Remove()
if (mType == MeasurementsType::Standard) if (mType == MeasurementsType::Standard)
{ {
ui->labelCalculatedValue->blockSignals(true); ui->labelCalculatedValue->blockSignals(true);
ui->spinBoxBaseValue->blockSignals(true); ui->doubleSpinBoxBaseValue->blockSignals(true);
ui->spinBoxInSizes->blockSignals(true); ui->doubleSpinBoxInSizes->blockSignals(true);
ui->spinBoxInHeights->blockSignals(true); ui->doubleSpinBoxInHeights->blockSignals(true);
ui->labelCalculatedValue->setText(""); ui->labelCalculatedValue->setText("");
ui->spinBoxBaseValue->setValue(0); ui->doubleSpinBoxBaseValue->setValue(0);
ui->spinBoxInSizes->setValue(0); ui->doubleSpinBoxInSizes->setValue(0);
ui->spinBoxInHeights->setValue(0); ui->doubleSpinBoxInHeights->setValue(0);
ui->labelCalculatedValue->blockSignals(false); ui->labelCalculatedValue->blockSignals(false);
ui->spinBoxBaseValue->blockSignals(false); ui->doubleSpinBoxBaseValue->blockSignals(false);
ui->spinBoxInSizes->blockSignals(false); ui->doubleSpinBoxInSizes->blockSignals(false);
ui->spinBoxInHeights->blockSignals(false); ui->doubleSpinBoxInHeights->blockSignals(false);
} }
else else
{ {
@ -662,19 +662,19 @@ void TMainWindow::ShowMData()
if (mType == MeasurementsType::Standard) if (mType == MeasurementsType::Standard)
{ {
ui->labelCalculatedValue->blockSignals(true); ui->labelCalculatedValue->blockSignals(true);
ui->spinBoxBaseValue->blockSignals(true); ui->doubleSpinBoxBaseValue->blockSignals(true);
ui->spinBoxInSizes->blockSignals(true); ui->doubleSpinBoxInSizes->blockSignals(true);
ui->spinBoxInHeights->blockSignals(true); ui->doubleSpinBoxInHeights->blockSignals(true);
ui->labelCalculatedValue->setText(QString().setNum(data->GetTableValue(nameField->text(), mType))); ui->labelCalculatedValue->setText(QString().setNum(data->GetTableValue(nameField->text(), mType)));
ui->spinBoxBaseValue->setValue(static_cast<int>(meash->GetBase())); ui->doubleSpinBoxBaseValue->setValue(static_cast<int>(meash->GetBase()));
ui->spinBoxInSizes->setValue(static_cast<int>(meash->GetKsize())); ui->doubleSpinBoxInSizes->setValue(static_cast<int>(meash->GetKsize()));
ui->spinBoxInHeights->setValue(static_cast<int>(meash->GetKheight())); ui->doubleSpinBoxInHeights->setValue(static_cast<int>(meash->GetKheight()));
ui->labelCalculatedValue->blockSignals(false); ui->labelCalculatedValue->blockSignals(false);
ui->spinBoxBaseValue->blockSignals(false); ui->doubleSpinBoxBaseValue->blockSignals(false);
ui->spinBoxInSizes->blockSignals(false); ui->doubleSpinBoxInSizes->blockSignals(false);
ui->spinBoxInHeights->blockSignals(false); ui->doubleSpinBoxInHeights->blockSignals(false);
} }
else else
{ {
@ -848,7 +848,7 @@ void TMainWindow::SaveMValue()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TMainWindow::SaveMBaseValue(int value) void TMainWindow::SaveMBaseValue(double value)
{ {
const int row = ui->tableWidget->currentRow(); 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(); 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(); const int row = ui->tableWidget->currentRow();
@ -1033,12 +1033,17 @@ void TMainWindow::InitWindow()
connect(gradationSizes, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged), connect(gradationSizes, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &TMainWindow::ChangedSize); this, &TMainWindow::ChangedSize);
connect(ui->spinBoxBaseValue, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, connect(ui->doubleSpinBoxBaseValue,
&TMainWindow::SaveMBaseValue); static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
connect(ui->spinBoxInSizes, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, this, &TMainWindow::SaveMBaseValue);
&TMainWindow::SaveMSizeIncrease); connect(ui->doubleSpinBoxInSizes,
connect(ui->spinBoxInHeights, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
&TMainWindow::SaveMHeightIncrease); this, &TMainWindow::SaveMSizeIncrease);
connect(ui->doubleSpinBoxInHeights,
static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
this, &TMainWindow::SaveMHeightIncrease);
SetDecimals();
} }
else else
{ {
@ -1052,11 +1057,11 @@ void TMainWindow::InitWindow()
// Tab Measurements // Tab Measurements
delete ui->labelBaseValue; delete ui->labelBaseValue;
delete ui->spinBoxBaseValue; delete ui->doubleSpinBoxBaseValue;
delete ui->labelInSizes; delete ui->labelInSizes;
delete ui->spinBoxInSizes; delete ui->doubleSpinBoxInSizes;
delete ui->labelInHeights; delete ui->labelInHeights;
delete ui->spinBoxInHeights; delete ui->doubleSpinBoxInHeights;
// Tab Information // Tab Information
delete ui->labelBaseSize; delete ui->labelBaseSize;
@ -1401,9 +1406,9 @@ void TMainWindow::MFields(bool enabled)
if (mType == MeasurementsType::Standard) if (mType == MeasurementsType::Standard)
{ {
ui->spinBoxBaseValue->setEnabled(enabled); ui->doubleSpinBoxBaseValue->setEnabled(enabled);
ui->spinBoxInSizes->setEnabled(enabled); ui->doubleSpinBoxInSizes->setEnabled(enabled);
ui->spinBoxInHeights->setEnabled(enabled); ui->doubleSpinBoxInHeights->setEnabled(enabled);
} }
else 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;
}
}

View File

@ -41,6 +41,7 @@ namespace Ui
class QComboBox; class QComboBox;
class QTableWidgetItem; class QTableWidgetItem;
class QLabel;
class TMainWindow : public QMainWindow class TMainWindow : public QMainWindow
{ {
@ -89,9 +90,9 @@ private slots:
void SaveMName(); void SaveMName();
void SaveMValue(); void SaveMValue();
void SaveMBaseValue(int value); void SaveMBaseValue(double value);
void SaveMSizeIncrease(int value); void SaveMSizeIncrease(double value);
void SaveMHeightIncrease(int value); void SaveMHeightIncrease(double value);
void SaveMDescription(); void SaveMDescription();
private: private:
@ -109,6 +110,7 @@ private:
void SetupMenu(); void SetupMenu();
void InitWindow(); void InitWindow();
void InitTable(); void InitTable();
void SetDecimals();
void ShowUnits(); void ShowUnits();
void ShowHeaderUnits(QTableWidget *table, int column, const QString &unit); void ShowHeaderUnits(QTableWidget *table, int column, const QString &unit);

View File

@ -326,42 +326,42 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="1"> <item row="6" column="1">
<widget class="QSpinBox" name="spinBoxInHeights"> <widget class="QDoubleSpinBox" name="doubleSpinBoxBaseValue">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="minimum"> <property name="minimum">
<number>-1000</number> <double>-10000.000000000000000</double>
</property> </property>
<property name="maximum"> <property name="maximum">
<number>1000</number> <double>10000.000000000000000</double>
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="1"> <item row="7" column="1">
<widget class="QSpinBox" name="spinBoxInSizes"> <widget class="QDoubleSpinBox" name="doubleSpinBoxInSizes">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="minimum"> <property name="minimum">
<number>-1000</number> <double>-10000.000000000000000</double>
</property> </property>
<property name="maximum"> <property name="maximum">
<number>1000</number> <double>10000.000000000000000</double>
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="1"> <item row="8" column="1">
<widget class="QSpinBox" name="spinBoxBaseValue"> <widget class="QDoubleSpinBox" name="doubleSpinBoxInHeights">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="minimum"> <property name="minimum">
<number>-1000</number> <double>-10000.000000000000000</double>
</property> </property>
<property name="maximum"> <property name="maximum">
<number>1000</number> <double>10000.000000000000000</double>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -182,9 +182,9 @@ void VMeasurements::ReadMeasurements() const
VMeasurement *meash; VMeasurement *meash;
if (type == MeasurementsType::Standard) if (type == MeasurementsType::Standard)
{ {
const quint32 base = GetParametrUInt(dom, AttrBase, "0"); const qreal base = GetParametrDouble(dom, AttrBase, "0");
const quint32 ksize = GetParametrUInt(dom, AttrSizeIncrease, "0"); const qreal ksize = GetParametrDouble(dom, AttrSizeIncrease, "0");
const quint32 kheight = GetParametrUInt(dom, AttrHeightIncrease, "0"); const qreal kheight = GetParametrDouble(dom, AttrHeightIncrease, "0");
meash = new VMeasurement(i, name, BaseSize(), BaseHeight(), base, ksize, kheight, "", description); 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); QDomElement node = FindM(name);
if (not node.isNull()) 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); QDomElement node = FindM(name);
if (not node.isNull()) 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); QDomElement node = FindM(name);
if (not node.isNull()) if (not node.isNull())

View File

@ -79,9 +79,9 @@ public:
void SetMName(const QString &name, const QString &text); void SetMName(const QString &name, const QString &text);
void SetMValue(const QString &name, const QString &text); void SetMValue(const QString &name, const QString &text);
void SetMBaseValue(const QString &name, int value); void SetMBaseValue(const QString &name, double value);
void SetMSizeIncrease(const QString &name, int value); void SetMSizeIncrease(const QString &name, double value);
void SetMHeightIncrease(const QString &name, int value); void SetMHeightIncrease(const QString &name, double value);
void SetMDescription(const QString &name, const QString &text); void SetMDescription(const QString &name, const QString &text);
static const QString TagVST; static const QString TagVST;