Fixed a bug in calculation graduation value. Values base size and heights from
file was ignored. --HG-- branch : feature
This commit is contained in:
parent
5fb426c248
commit
34859e5913
|
@ -550,7 +550,7 @@ void TMainWindow::AddCustom()
|
|||
VMeasurement *meash;
|
||||
if (mType == MeasurementsType::Standard)
|
||||
{
|
||||
meash = new VMeasurement(currentRow, name, 0, 0, 0);
|
||||
meash = new VMeasurement(currentRow, name, m->BaseSize(), m->BaseHeight(), 0, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -592,15 +592,43 @@ void TMainWindow::AddKnown()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void TMainWindow::ChangedSize(const QString &text)
|
||||
{
|
||||
const int row = ui->tableWidget->currentRow();
|
||||
|
||||
if (row == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
data->SetSize(text.toInt());
|
||||
RefreshData();
|
||||
|
||||
ui->tableWidget->blockSignals(true);
|
||||
ui->tableWidget->selectRow(row);
|
||||
ui->tableWidget->resizeColumnsToContents();
|
||||
ui->tableWidget->resizeRowsToContents();
|
||||
ui->tableWidget->horizontalHeader()->setStretchLastSection(true);
|
||||
ui->tableWidget->blockSignals(false);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void TMainWindow::ChangedHeight(const QString &text)
|
||||
{
|
||||
const int row = ui->tableWidget->currentRow();
|
||||
|
||||
if (row == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
data->SetHeight(text.toInt());
|
||||
RefreshData();
|
||||
|
||||
ui->tableWidget->blockSignals(true);
|
||||
ui->tableWidget->selectRow(row);
|
||||
ui->tableWidget->resizeColumnsToContents();
|
||||
ui->tableWidget->resizeRowsToContents();
|
||||
ui->tableWidget->horizontalHeader()->setStretchLastSection(true);
|
||||
ui->tableWidget->blockSignals(false);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -836,10 +864,12 @@ void TMainWindow::SaveMBaseValue(int value)
|
|||
|
||||
RefreshData();
|
||||
|
||||
ui->tableWidget->blockSignals(true);
|
||||
ui->tableWidget->selectRow(row);
|
||||
ui->tableWidget->resizeColumnsToContents();
|
||||
ui->tableWidget->resizeRowsToContents();
|
||||
ui->tableWidget->horizontalHeader()->setStretchLastSection(true);
|
||||
ui->tableWidget->blockSignals(false);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -859,10 +889,12 @@ void TMainWindow::SaveMSizeIncrease(int value)
|
|||
|
||||
RefreshData();
|
||||
|
||||
ui->tableWidget->blockSignals(true);
|
||||
ui->tableWidget->selectRow(row);
|
||||
ui->tableWidget->resizeColumnsToContents();
|
||||
ui->tableWidget->resizeRowsToContents();
|
||||
ui->tableWidget->horizontalHeader()->setStretchLastSection(true);
|
||||
ui->tableWidget->blockSignals(false);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -1003,7 +1035,7 @@ void TMainWindow::InitWindow()
|
|||
|
||||
connect(ui->spinBoxBaseValue, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
|
||||
&TMainWindow::SaveMBaseValue);
|
||||
connect(ui->spinBoxInHeights, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
|
||||
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);
|
||||
|
|
|
@ -721,7 +721,7 @@ void DialogIncrements::clickedToolButtonAdd()
|
|||
|
||||
const quint32 id = data->getNextId();
|
||||
const QString description(tr("Description"));
|
||||
VIncrement *incr = new VIncrement(name, id, 0, 0, 0, description);
|
||||
VIncrement *incr = new VIncrement(name, id, 0, description);
|
||||
data->AddVariable(name, incr);
|
||||
|
||||
AddIncrementToFile(id, name, 0, 0, 0, description);
|
||||
|
|
|
@ -2164,7 +2164,7 @@ void VPattern::ParseIncrementsElement(const QDomNode &node)
|
|||
const qreal kgrowth = GetParametrDouble(domElement, IncrementKgrowth, "0");
|
||||
const QString desc = GetParametrString(domElement, IncrementDescription, "Description");
|
||||
data->UpdateId(id);
|
||||
data->AddVariable(name, new VIncrement(name, id, base, ksize, kgrowth, desc));
|
||||
data->AddVariable(name, new VIncrement(name, id, base, desc));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ void VStandardMeasurements::ReadMeasurement(const QDomElement &domElement, const
|
|||
qWarning()<<"Standard table can't use inch unit.";
|
||||
}
|
||||
|
||||
data->AddVariable(tag, new VMeasurement(0, tag, value, size_increase, height_increase,
|
||||
data->AddVariable(tag, new VMeasurement(0, tag, Size(), Height(), value, size_increase, height_increase,
|
||||
qApp->TrVars()->GuiText(tag), qApp->TrVars()->Description(tag), tag));
|
||||
}
|
||||
|
||||
|
|
|
@ -186,7 +186,7 @@ void VMeasurements::ReadMeasurements() const
|
|||
const quint32 ksize = GetParametrUInt(dom, AttrSizeIncrease, "0");
|
||||
const quint32 kheight = GetParametrUInt(dom, AttrHeightIncrease, "0");
|
||||
|
||||
meash = new VMeasurement(i, name, base, ksize, kheight, "", description);
|
||||
meash = new VMeasurement(i, name, BaseSize(), BaseHeight(), base, ksize, kheight, "", description);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -381,7 +381,7 @@ void VMeasurements::SetMBaseValue(const QString &name, int value)
|
|||
QDomElement node = FindM(name);
|
||||
if (not node.isNull())
|
||||
{
|
||||
SetAttribute(node, AttrValue, value);
|
||||
SetAttribute(node, AttrBase, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,13 +44,11 @@ VIncrement::VIncrement()
|
|||
* @brief VIncrementTableRow create increment
|
||||
* @param name increment's name
|
||||
* @param id id
|
||||
* @param base value in base size and height
|
||||
* @param ksize increment in sizes
|
||||
* @param kheight increment in heights
|
||||
* @param base value
|
||||
* @param description description of increment
|
||||
*/
|
||||
VIncrement::VIncrement(const QString &name, quint32 id, qreal base, qreal ksize, qreal kheight, QString description)
|
||||
:VVariable(name, base, ksize, kheight, description), d(new VIncrementData(id))
|
||||
VIncrement::VIncrement(const QString &name, quint32 id, qreal base, QString description)
|
||||
:VVariable(name, base, description), d(new VIncrementData(id))
|
||||
{
|
||||
SetType(VarType::Increment);
|
||||
}
|
||||
|
|
|
@ -40,8 +40,7 @@ class VIncrement :public VVariable
|
|||
{
|
||||
public:
|
||||
VIncrement();
|
||||
VIncrement(const QString &name, quint32 id, qreal base, qreal ksize, qreal kheight,
|
||||
QString description = QString());
|
||||
VIncrement(const QString &name, quint32 id, qreal base, QString description = QString());
|
||||
VIncrement(const VIncrement &incr);
|
||||
VIncrement &operator=(const VIncrement &incr);
|
||||
virtual ~VIncrement() Q_DECL_OVERRIDE;
|
||||
|
|
|
@ -40,10 +40,11 @@
|
|||
* @param description measurement full description
|
||||
* @param tagName measurement's tag name in file
|
||||
*/
|
||||
VMeasurement::VMeasurement(quint32 index, const QString &name, const qreal &base, const qreal &ksize,
|
||||
const qreal &kheight,
|
||||
const QString &gui_text, const QString &description, const QString &tagName)
|
||||
:VVariable(name, base, ksize, kheight, description), d(new VMeasurementData(index, gui_text, tagName))
|
||||
VMeasurement::VMeasurement(quint32 index, const QString &name, qreal baseSize, qreal baseHeight, const qreal &base,
|
||||
const qreal &ksize, const qreal &kheight, const QString &gui_text,
|
||||
const QString &description, const QString &tagName)
|
||||
:VVariable(name, baseSize, baseHeight, base, ksize, kheight, description),
|
||||
d(new VMeasurementData(index, gui_text, tagName))
|
||||
{
|
||||
SetType(VarType::Measurement);
|
||||
}
|
||||
|
|
|
@ -43,9 +43,9 @@ class VContainer;
|
|||
class VMeasurement :public VVariable
|
||||
{
|
||||
public:
|
||||
VMeasurement(quint32 index, const QString &name, const qreal &base, const qreal &ksize,
|
||||
const qreal &kheight, const QString &gui_text = QString(), const QString &description = QString(),
|
||||
const QString &TagName = QString());
|
||||
VMeasurement(quint32 index, const QString &name, qreal baseSize, qreal baseHeight, const qreal &base,
|
||||
const qreal &ksize, const qreal &kheight, const QString &gui_text = QString(),
|
||||
const QString &description = QString(), const QString &TagName = QString());
|
||||
VMeasurement(VContainer *data, quint32 index, const QString &name, const qreal &base, const QString &formula,
|
||||
bool ok, const QString &gui_text = QString(), const QString &description = QString(),
|
||||
const QString &TagName = QString());
|
||||
|
|
|
@ -37,9 +37,9 @@ VVariable::VVariable()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VVariable::VVariable(const QString &name, const qreal &base, const qreal &ksize, const qreal &kheight,
|
||||
const QString &description)
|
||||
:VInternalVariable(), d(new VVariableData(base, ksize, kheight, description))
|
||||
VVariable::VVariable(const QString &name, qreal baseSize, qreal baseHeight, const qreal &base, const qreal &ksize,
|
||||
const qreal &kheight, const QString &description)
|
||||
:VInternalVariable(), d(new VVariableData(baseSize, baseHeight, base, ksize, kheight, description))
|
||||
{
|
||||
VInternalVariable::SetValue(d->base);
|
||||
SetName(name);
|
||||
|
@ -82,14 +82,12 @@ void VVariable::SetValue(const qreal &size, const qreal &height, Unit patternUni
|
|||
qWarning("Gradation doesn't support inches");
|
||||
return;
|
||||
}
|
||||
const qreal baseSize = UnitConvertor(50.0, Unit::Cm, patternUnit);
|
||||
const qreal baseHeight = UnitConvertor(176.0, Unit::Cm, patternUnit);
|
||||
const qreal sizeIncrement = UnitConvertor(2.0, Unit::Cm, patternUnit);
|
||||
const qreal heightIncrement = UnitConvertor(6.0, Unit::Cm, patternUnit);
|
||||
|
||||
// Formula for calculation gradation
|
||||
const qreal k_size = ( size - baseSize ) / sizeIncrement;
|
||||
const qreal k_height = ( height - baseHeight ) / heightIncrement;
|
||||
const qreal k_size = ( size - d->baseSize ) / sizeIncrement;
|
||||
const qreal k_height = ( height - d->baseHeight ) / heightIncrement;
|
||||
VInternalVariable::SetValue(d->base + k_size * d->ksize + k_height * d->kheight);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,8 +38,8 @@ class VVariable :public VInternalVariable
|
|||
{
|
||||
public:
|
||||
VVariable();
|
||||
VVariable(const QString &name, const qreal &base, const qreal &ksize = 0, const qreal &kheight = 0,
|
||||
const QString &description = QString());
|
||||
VVariable(const QString &name, qreal baseSize, qreal baseHeight, const qreal &base, const qreal &ksize = 0,
|
||||
const qreal &kheight = 0, const QString &description = QString());
|
||||
VVariable(const QString &name, const qreal &base, const QString &description = QString());
|
||||
VVariable(const VVariable &var);
|
||||
VVariable &operator=(const VVariable &var);
|
||||
|
|
|
@ -41,19 +41,22 @@ class VVariableData : public QSharedData
|
|||
public:
|
||||
|
||||
VVariableData()
|
||||
:base(0), ksize(0), kheight(0), description(QString())
|
||||
:base(0), ksize(0), kheight(0), description(QString()), baseSize(0), baseHeight(0)
|
||||
{}
|
||||
|
||||
VVariableData(const qreal &base, const qreal &ksize, const qreal &kheight, const QString &description)
|
||||
:base(base), ksize(ksize), kheight(kheight), description(description)
|
||||
VVariableData(qreal baseSize, qreal baseHeight, const qreal &base, const qreal &ksize, const qreal &kheight,
|
||||
const QString &description)
|
||||
:base(base), ksize(ksize), kheight(kheight), description(description), baseSize(baseSize),
|
||||
baseHeight(baseHeight)
|
||||
{}
|
||||
|
||||
VVariableData(const qreal &base, const QString &description)
|
||||
:base(base), ksize(0), kheight(0), description(description)
|
||||
:base(base), ksize(0), kheight(0), description(description), baseSize(0), baseHeight(0)
|
||||
{}
|
||||
|
||||
VVariableData(const VVariableData &var)
|
||||
:QSharedData(var), base(var.base), ksize(var.ksize), kheight(var.kheight), description(var.description)
|
||||
:QSharedData(var), base(var.base), ksize(var.ksize), kheight(var.kheight), description(var.description),
|
||||
baseSize(var.baseSize), baseHeight(var.baseHeight)
|
||||
{}
|
||||
|
||||
virtual ~VVariableData();
|
||||
|
@ -69,6 +72,9 @@ public:
|
|||
|
||||
/** @brief description description of increment */
|
||||
QString description;
|
||||
|
||||
qreal baseSize;
|
||||
qreal baseHeight;
|
||||
};
|
||||
|
||||
VVariableData::~VVariableData()
|
||||
|
|
Loading…
Reference in New Issue
Block a user