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)
{
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<int>(meash->GetBase()));
ui->spinBoxInSizes->setValue(static_cast<int>(meash->GetKsize()));
ui->spinBoxInHeights->setValue(static_cast<int>(meash->GetKheight()));
ui->doubleSpinBoxBaseValue->setValue(static_cast<int>(meash->GetBase()));
ui->doubleSpinBoxInSizes->setValue(static_cast<int>(meash->GetKsize()));
ui->doubleSpinBoxInHeights->setValue(static_cast<int>(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<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &TMainWindow::ChangedSize);
connect(ui->spinBoxBaseValue, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
&TMainWindow::SaveMBaseValue);
connect(ui->spinBoxInSizes, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
&TMainWindow::SaveMSizeIncrease);
connect(ui->spinBoxInHeights, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
&TMainWindow::SaveMHeightIncrease);
connect(ui->doubleSpinBoxBaseValue,
static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
this, &TMainWindow::SaveMBaseValue);
connect(ui->doubleSpinBoxInSizes,
static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
this, &TMainWindow::SaveMSizeIncrease);
connect(ui->doubleSpinBoxInHeights,
static_cast<void (QDoubleSpinBox::*)(double)>(&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;
}
}

View File

@ -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);

View File

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

View File

@ -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())

View File

@ -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;