Reading/Writing a measurement data.

This commit is contained in:
Roman Telezhynskyi 2020-10-03 18:52:31 +03:00
parent ecb62257c2
commit 16ce597a37
9 changed files with 1217 additions and 544 deletions

View File

@ -81,8 +81,23 @@ Q_LOGGING_CATEGORY(tMainWindow, "t.mainwindow")
QT_WARNING_POP
namespace
{
enum class MUnits : qint8 { Table, Degrees};
}
// We need this enum in case we will add or delete a column. And also make code more readable.
enum {ColumnName = 0, ColumnFullName, ColumnCalcValue, ColumnFormula, ColumnBaseValue, ColumnInSizes, ColumnInHeights};
enum {
ColumnName = 0,
ColumnFullName = 1,
ColumnCalcValue = 2,
ColumnFormula = 3,
ColumnBaseValue = 4,
ColumnShiftA = 5,
ColumnShiftB = 6,
ColumnShiftC = 7,
ColumnCorrection = 8
};
//---------------------------------------------------------------------------------------------------------------------
TMainWindow::TMainWindow(QWidget *parent)
@ -582,6 +597,8 @@ void TMainWindow::changeEvent(QEvent *event)
// retranslate designer form (single inheritance approach)
ui->retranslateUi(this);
InitMeasurementUnits();
if (mType == MeasurementsType::Multisize)
{
actionFullCircumference->setText(tr("Use full circumference"));
@ -590,6 +607,7 @@ void TMainWindow::changeEvent(QEvent *event)
InitDimensionsBaseValue();
InitDimensionControls();
InitDimesionShifts();
}
else
{
@ -1158,22 +1176,32 @@ void TMainWindow::Remove()
ui->lineEditFullName->setText(QString());
ui->lineEditFullName->blockSignals(false);
ui->comboBoxMUnits->blockSignals(true);
ui->comboBoxMUnits->setCurrentIndex(-1);
ui->comboBoxMUnits->blockSignals(false);
if (mType == MeasurementsType::Multisize)
{
ui->labelCalculatedValue->blockSignals(true);
ui->doubleSpinBoxBaseValue->blockSignals(true);
ui->doubleSpinBoxInSizes->blockSignals(true);
ui->doubleSpinBoxInHeights->blockSignals(true);
ui->doubleSpinBoxCorrection->blockSignals(true);
ui->doubleSpinBoxShiftA->blockSignals(true);
ui->doubleSpinBoxShiftB->blockSignals(true);
ui->doubleSpinBoxShiftC->blockSignals(true);
ui->labelCalculatedValue->setText(QString());
ui->doubleSpinBoxBaseValue->setValue(0);
ui->doubleSpinBoxInSizes->setValue(0);
ui->doubleSpinBoxInHeights->setValue(0);
ui->doubleSpinBoxCorrection->setValue(0);
ui->doubleSpinBoxShiftA->setValue(0);
ui->doubleSpinBoxShiftB->setValue(0);
ui->doubleSpinBoxShiftC->setValue(0);
ui->labelCalculatedValue->blockSignals(false);
ui->doubleSpinBoxBaseValue->blockSignals(false);
ui->doubleSpinBoxInSizes->blockSignals(false);
ui->doubleSpinBoxInHeights->blockSignals(false);
ui->doubleSpinBoxCorrection->blockSignals(false);
ui->doubleSpinBoxShiftA->blockSignals(false);
ui->doubleSpinBoxShiftB->blockSignals(false);
ui->doubleSpinBoxShiftC->blockSignals(false);
}
else
{
@ -1590,12 +1618,17 @@ void TMainWindow::ShowNewMData(bool fresh)
connect(ui->lineEditName, &QLineEdit::textEdited, this, &TMainWindow::SaveMName);
ui->plainTextEditDescription->blockSignals(false);
ui->comboBoxMUnits->setCurrentIndex(
ui->comboBoxMUnits->findData(static_cast<int>(meash->IsSpecialUnits() ? MUnits::Degrees : MUnits::Table)));
if (mType == MeasurementsType::Multisize)
{
ui->labelCalculatedValue->blockSignals(true);
ui->doubleSpinBoxBaseValue->blockSignals(true);
ui->doubleSpinBoxInSizes->blockSignals(true);
ui->doubleSpinBoxInHeights->blockSignals(true);
ui->doubleSpinBoxCorrection->blockSignals(true);
ui->doubleSpinBoxShiftA->blockSignals(true);
ui->doubleSpinBoxShiftB->blockSignals(true);
ui->doubleSpinBoxShiftC->blockSignals(true);
const QString postfix = UnitsToStr(pUnit);//Show unit in dialog lable (cm, mm or inch)
const qreal value = UnitConvertor(*data->DataVariables()->value(meash->GetName())->GetValue(), mUnit,
@ -1605,14 +1638,19 @@ void TMainWindow::ShowNewMData(bool fresh)
if (fresh)
{
ui->doubleSpinBoxBaseValue->setValue(meash->GetBase());
ui->doubleSpinBoxInSizes->setValue(meash->GetKsize());
ui->doubleSpinBoxInHeights->setValue(meash->GetKheight());
ui->doubleSpinBoxCorrection->setValue(
meash->GetCorrection(currentDimensionA, currentDimensionB, currentDimensionC));
ui->doubleSpinBoxShiftA->setValue(meash->GetShiftA());
ui->doubleSpinBoxShiftB->setValue(meash->GetShiftB());
ui->doubleSpinBoxShiftC->setValue(meash->GetShiftC());
}
ui->labelCalculatedValue->blockSignals(false);
ui->doubleSpinBoxBaseValue->blockSignals(false);
ui->doubleSpinBoxInSizes->blockSignals(false);
ui->doubleSpinBoxInHeights->blockSignals(false);
ui->doubleSpinBoxCorrection->blockSignals(false);
ui->doubleSpinBoxShiftA->blockSignals(false);
ui->doubleSpinBoxShiftB->blockSignals(false);
ui->doubleSpinBoxShiftC->blockSignals(false);
}
else
{
@ -1851,7 +1889,7 @@ void TMainWindow::SaveMBaseValue(double value)
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::SaveMSizeIncrease(double value)
void TMainWindow::SaveMShiftA(double value)
{
const int row = ui->tableWidget->currentRow();
@ -1861,7 +1899,7 @@ void TMainWindow::SaveMSizeIncrease(double value)
}
const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName);
m->SetMSizeIncrease(nameField->data(Qt::UserRole).toString(), value);
m->SetMShiftA(nameField->data(Qt::UserRole).toString(), value);
MeasurementsWereSaved(false);
@ -1876,7 +1914,7 @@ void TMainWindow::SaveMSizeIncrease(double value)
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::SaveMHeightIncrease(double value)
void TMainWindow::SaveMShiftB(double value)
{
const int row = ui->tableWidget->currentRow();
@ -1886,7 +1924,58 @@ void TMainWindow::SaveMHeightIncrease(double value)
}
const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName);
m->SetMHeightIncrease(nameField->data(Qt::UserRole).toString(), value);
m->SetMShiftB(nameField->data(Qt::UserRole).toString(), value);
MeasurementsWereSaved(false);
RefreshData();
search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->blockSignals(true);
ui->tableWidget->selectRow(row);
ui->tableWidget->blockSignals(false);
ShowNewMData(false);
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::SaveMShiftC(double value)
{
const int row = ui->tableWidget->currentRow();
if (row == -1)
{
return;
}
const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName);
m->SetMShiftC(nameField->data(Qt::UserRole).toString(), value);
MeasurementsWereSaved(false);
RefreshData();
search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->blockSignals(true);
ui->tableWidget->selectRow(row);
ui->tableWidget->blockSignals(false);
ShowNewMData(false);
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::SaveMCorrectionValue(double value)
{
const int row = ui->tableWidget->currentRow();
if (row == -1)
{
return;
}
const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName);
m->SetMCorrectionValue(nameField->data(Qt::UserRole).toString(),
currentDimensionA, currentDimensionB, currentDimensionC, value);
MeasurementsWereSaved(false);
@ -1972,6 +2061,32 @@ void TMainWindow::SaveMFullName()
}
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::SaveMUnits()
{
const int row = ui->tableWidget->currentRow();
if (row == -1)
{
return;
}
const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName);
const MUnits units = static_cast<MUnits>(ui->comboBoxMUnits->currentData().toInt());
m->SetMSpecialUnits(nameField->data(Qt::UserRole).toString(), units == MUnits::Degrees);
MeasurementsWereSaved(false);
RefreshData();
search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->blockSignals(true);
ui->tableWidget->selectRow(row);
ui->tableWidget->blockSignals(false);
ShowNewMData(false);
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::FullCircumferenceChanged(bool checked)
{
@ -2117,12 +2232,20 @@ void TMainWindow::InitWindow()
ShowDimensionControls();
SetDimensionBases();
InitDimesionShifts();
HackDimensionShifts();
connect(ui->doubleSpinBoxBaseValue, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, &TMainWindow::SaveMBaseValue);
connect(ui->doubleSpinBoxInSizes, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, &TMainWindow::SaveMSizeIncrease);
connect(ui->doubleSpinBoxInHeights, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, &TMainWindow::SaveMHeightIncrease);
connect(ui->doubleSpinBoxCorrection, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, &TMainWindow::SaveMCorrectionValue);
connect(ui->doubleSpinBoxShiftA, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, &TMainWindow::SaveMShiftA);
connect(ui->doubleSpinBoxShiftB, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, &TMainWindow::SaveMShiftB);
connect(ui->doubleSpinBoxShiftC, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, &TMainWindow::SaveMShiftC);
SetDecimals();
}
@ -2137,11 +2260,10 @@ void TMainWindow::InitWindow()
// Tab Measurements
HackWidget(&ui->doubleSpinBoxBaseValue);
HackWidget(&ui->doubleSpinBoxInSizes);
HackWidget(&ui->doubleSpinBoxInHeights);
HackWidget(&ui->doubleSpinBoxCorrection);
HackWidget(&ui->labelBaseValue);
HackWidget(&ui->labelInSizes);
HackWidget(&ui->labelInHeights);
HackWidget(&ui->labelCorrection);
HackDimensionShifts();
// Tab Information
HackDimensionBaseValue();
@ -2226,7 +2348,14 @@ void TMainWindow::InitWindow()
ShowInGraphicalShell(curFile);
});
InitUnits();
InitPatternUnits();
InitMeasurementUnits();
ui->comboBoxMUnits->blockSignals(true);
ui->comboBoxMUnits->setCurrentIndex(-1);
ui->comboBoxMUnits->blockSignals(false);
connect(ui->comboBoxMUnits, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &TMainWindow::SaveMUnits);
InitTable();
}
@ -2388,18 +2517,72 @@ void TMainWindow::InitDimensionControls()
InitControl(2, labelGradationDimensionC, gradationDimensionC);
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::InitDimesionShifts()
{
const QList<MeasurementDimension_p> dimensions = m->Dimensions().values();
auto InitShift = [this, dimensions](int index, QLabel *name)
{
if (dimensions.size() > index)
{
MeasurementDimension_p dimension = dimensions.at(index);
name->setText(tr("Shift (%1):").arg(DimensionName(dimension->Type())));
name->setToolTip(DimensionToolTip(dimension->Type(), dimension->IsCircumference()));
}
};
InitShift(0, ui->labelShiftA);
InitShift(1, ui->labelShiftB);
InitShift(2, ui->labelShiftC);
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::InitTable()
{
if (mType == MeasurementsType::Multisize)
{
ui->tableWidget->setColumnHidden( ColumnFormula, true );// formula
const QList< MeasurementDimension_p > dimensions = m->Dimensions().values();
if (dimensions.size() > 0)
{
MeasurementDimension_p dimension = dimensions.at(0);
ui->tableWidget->horizontalHeaderItem(ColumnShiftA)->setText(
tr("%1 shift").arg(DimensionName(dimension->Type())));
}
if (dimensions.size() < 2)
{
ui->tableWidget->setColumnHidden( ColumnShiftB, true );
}
else
{
MeasurementDimension_p dimension = dimensions.at(1);
ui->tableWidget->horizontalHeaderItem(ColumnShiftB)->setText(
tr("%1 shift").arg(DimensionName(dimension->Type())));
}
if (dimensions.size() < 3)
{
ui->tableWidget->setColumnHidden( ColumnShiftC, true );
}
else
{
MeasurementDimension_p dimension = dimensions.at(2);
ui->tableWidget->horizontalHeaderItem(ColumnShiftC)->setText(
tr("%1 shift").arg(DimensionName(dimension->Type())));
}
}
else
{
ui->tableWidget->setColumnHidden( ColumnBaseValue, true );// base value
ui->tableWidget->setColumnHidden( ColumnInSizes, true );// in sizes
ui->tableWidget->setColumnHidden( ColumnInHeights, true );// in heights
ui->tableWidget->setColumnHidden( ColumnShiftA, true );
ui->tableWidget->setColumnHidden( ColumnShiftB, true );
ui->tableWidget->setColumnHidden( ColumnShiftC, true );
ui->tableWidget->setColumnHidden( ColumnCorrection, true );
}
connect(ui->tableWidget, &QTableWidget::itemSelectionChanged, this, &TMainWindow::ShowMData);
@ -2419,8 +2602,10 @@ void TMainWindow::ShowUnits()
ShowHeaderUnits(ui->tableWidget, ColumnCalcValue, UnitsToStr(pUnit));// calculated value
ShowHeaderUnits(ui->tableWidget, ColumnFormula, unit);// formula
ShowHeaderUnits(ui->tableWidget, ColumnBaseValue, unit);// base value
ShowHeaderUnits(ui->tableWidget, ColumnInSizes, unit);// in sizes
ShowHeaderUnits(ui->tableWidget, ColumnInHeights, unit);// in heights
ShowHeaderUnits(ui->tableWidget, ColumnShiftA, unit);
ShowHeaderUnits(ui->tableWidget, ColumnShiftB, unit);
ShowHeaderUnits(ui->tableWidget, ColumnShiftC, unit);
ShowHeaderUnits(ui->tableWidget, ColumnCorrection, unit);
}
//---------------------------------------------------------------------------------------------------------------------
@ -2641,11 +2826,17 @@ void TMainWindow::RefreshTable(bool freshCall)
AddCell(locale().toString(meash->GetBase()), currentRow, ColumnBaseValue,
Qt::AlignHCenter | Qt::AlignVCenter); // base value
AddCell(locale().toString(meash->GetKsize()), currentRow, ColumnInSizes,
Qt::AlignHCenter | Qt::AlignVCenter); // in sizes
AddCell(locale().toString(meash->GetShiftA()), currentRow, ColumnShiftA,
Qt::AlignHCenter | Qt::AlignVCenter);
AddCell(locale().toString(meash->GetKheight()), currentRow, ColumnInHeights,
Qt::AlignHCenter | Qt::AlignVCenter); // in heights
AddCell(locale().toString(meash->GetShiftB()), currentRow, ColumnShiftB,
Qt::AlignHCenter | Qt::AlignVCenter);
AddCell(locale().toString(meash->GetShiftC()), currentRow, ColumnShiftC,
Qt::AlignHCenter | Qt::AlignVCenter);
AddCell(locale().toString(meash->GetCorrection(currentDimensionA, currentDimensionB, currentDimensionC)),
currentRow, ColumnCorrection, Qt::AlignHCenter | Qt::AlignVCenter);
}
}
@ -2725,12 +2916,15 @@ void TMainWindow::MFields(bool enabled)
ui->lineEditName->setEnabled(enabled);
ui->plainTextEditDescription->setEnabled(enabled);
ui->lineEditFullName->setEnabled(enabled);
ui->comboBoxMUnits->setEnabled(enabled);
if (mType == MeasurementsType::Multisize)
{
ui->doubleSpinBoxBaseValue->setEnabled(enabled);
ui->doubleSpinBoxInSizes->setEnabled(enabled);
ui->doubleSpinBoxInHeights->setEnabled(enabled);
ui->doubleSpinBoxShiftA->setEnabled(enabled);
ui->doubleSpinBoxShiftB->setEnabled(enabled);
ui->doubleSpinBoxShiftC->setEnabled(enabled);
ui->doubleSpinBoxCorrection->setEnabled(enabled);
}
else
{
@ -3221,6 +3415,28 @@ void TMainWindow::HackDimensionBaseValue()
DimensionsBaseValue(2, ui->labelDimensionC, ui->labelDimensionCBase);
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::HackDimensionShifts()
{
const QList<MeasurementDimension_p> dimensions = m->Dimensions().values();
auto HackShift = [this, dimensions](int index, QLabel *name, QDoubleSpinBox *shift)
{
SCASSERT(name != nullptr)
SCASSERT(shift != nullptr)
if (dimensions.size() <= index)
{
HackWidget(&name);
HackWidget(&shift);
}
};
HackShift(0, ui->labelShiftA, ui->doubleSpinBoxShiftA);
HackShift(0, ui->labelShiftB, ui->doubleSpinBoxShiftB);
HackShift(0, ui->labelShiftC, ui->doubleSpinBoxShiftC);
}
//---------------------------------------------------------------------------------------------------------------------
QString TMainWindow::CheckMName(const QString &name, const QSet<QString> &importedNames) const
{
@ -3465,8 +3681,8 @@ void TMainWindow::ImportMultisizeMeasurements(const QxtCsvModel &csv)
{
m->AddEmpty(mm.name);
m->SetMBaseValue(mm.name, mm.base);
m->SetMSizeIncrease(mm.name, mm.sizeIncrease);
m->SetMHeightIncrease(mm.name, mm.heightIncrease);
m->SetMShiftB(mm.name, mm.sizeIncrease);
m->SetMShiftA(mm.name, mm.heightIncrease);
if (not mm.fullName.isEmpty())
{
@ -3716,31 +3932,49 @@ void TMainWindow::SetDecimals()
ui->doubleSpinBoxBaseValue->setDecimals(2);
ui->doubleSpinBoxBaseValue->setSingleStep(0.01);
ui->doubleSpinBoxInSizes->setDecimals(2);
ui->doubleSpinBoxInSizes->setSingleStep(0.01);
ui->doubleSpinBoxCorrection->setDecimals(2);
ui->doubleSpinBoxCorrection->setSingleStep(0.01);
ui->doubleSpinBoxInHeights->setDecimals(2);
ui->doubleSpinBoxInHeights->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);
ui->doubleSpinBoxInSizes->setDecimals(1);
ui->doubleSpinBoxInSizes->setSingleStep(0.1);
ui->doubleSpinBoxCorrection->setDecimals(1);
ui->doubleSpinBoxCorrection->setSingleStep(0.1);
ui->doubleSpinBoxInHeights->setDecimals(1);
ui->doubleSpinBoxInHeights->setSingleStep(0.1);
ui->doubleSpinBoxShiftA->setDecimals(1);
ui->doubleSpinBoxShiftA->setSingleStep(0.1);
ui->doubleSpinBoxShiftB->setDecimals(1);
ui->doubleSpinBoxShiftB->setSingleStep(0.1);
ui->doubleSpinBoxShiftC->setDecimals(1);
ui->doubleSpinBoxShiftC->setSingleStep(0.1);
break;
case Unit::Inch:
ui->doubleSpinBoxBaseValue->setDecimals(5);
ui->doubleSpinBoxBaseValue->setSingleStep(0.00001);
ui->doubleSpinBoxInSizes->setDecimals(5);
ui->doubleSpinBoxInSizes->setSingleStep(0.00001);
ui->doubleSpinBoxCorrection->setDecimals(5);
ui->doubleSpinBoxCorrection->setSingleStep(0.00001);
ui->doubleSpinBoxInHeights->setDecimals(5);
ui->doubleSpinBoxInHeights->setSingleStep(0.00001);
ui->doubleSpinBoxShiftA->setDecimals(5);
ui->doubleSpinBoxShiftA->setSingleStep(0.00001);
ui->doubleSpinBoxShiftB->setDecimals(5);
ui->doubleSpinBoxShiftB->setSingleStep(0.00001);
ui->doubleSpinBoxShiftC->setDecimals(5);
ui->doubleSpinBoxShiftC->setSingleStep(0.00001);
break;
default:
break;
@ -3748,7 +3982,7 @@ void TMainWindow::SetDecimals()
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::InitUnits()
void TMainWindow::InitPatternUnits()
{
labelPatternUnit = new QLabel(tr("Pattern unit:"));
ui->toolBarGradation->addWidget(labelPatternUnit);
@ -3776,6 +4010,47 @@ void TMainWindow::InitComboBoxUnits()
comboBoxUnits->addItem(UnitsToStr(Unit::Inch, true), QVariant(static_cast<int>(Unit::Inch)));
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::InitMeasurementUnits()
{
ui->comboBoxMUnits->blockSignals(true);
int current = -1;
if (ui->comboBoxMUnits->currentIndex() != -1)
{
current = ui->comboBoxMUnits->currentData().toInt();
}
QString units;
switch (m->MUnit())
{
case Unit::Mm:
units = tr("Millimeters");
break;
case Unit::Inch:
units = tr("Inches");
break;
case Unit::Cm:
units = tr("Centimeters");
break;
default:
units = "<Invalid>";
break;
}
ui->comboBoxMUnits->clear();
ui->comboBoxMUnits->addItem(units, QVariant(static_cast<int>(MUnits::Table)));
ui->comboBoxMUnits->addItem(tr("Degrees"), QVariant(static_cast<int>(MUnits::Degrees)));
int i = ui->comboBoxMUnits->findData(current);
if (i != -1)
{
ui->comboBoxMUnits->setCurrentIndex(i);
}
ui->comboBoxMUnits->blockSignals(false);
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::InitGender(QComboBox *gender)
{

View File

@ -126,10 +126,13 @@ private slots:
void SaveMName(const QString &text);
void SaveMValue();
void SaveMBaseValue(double value);
void SaveMSizeIncrease(double value);
void SaveMHeightIncrease(double value);
void SaveMShiftA(double value);
void SaveMShiftB(double value);
void SaveMShiftC(double value);
void SaveMCorrectionValue(double value);
void SaveMDescription();
void SaveMFullName();
void SaveMUnits();
void FullCircumferenceChanged(bool checked);
@ -169,10 +172,12 @@ private:
void InitDimensionsBaseValue();
void InitDimensionGradation(int index, const MeasurementDimension_p &dimension, QComboBox *control);
void InitDimensionControls();
void InitDimesionShifts();
void InitTable();
void SetDecimals();
void InitUnits();
void InitPatternUnits();
void InitComboBoxUnits();
void InitMeasurementUnits();
void InitGender(QComboBox *gender);
void ShowNewMData(bool fresh);
@ -219,6 +224,7 @@ private:
template <class T>
void HackWidget(T **widget);
void HackDimensionBaseValue();
void HackDimensionShifts();
QString CheckMName(const QString &name, const QSet<QString> &importedNames) const;
void ShowError(const QString &text);

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1034</width>
<height>896</height>
<width>1188</width>
<height>836</height>
</rect>
</property>
<property name="windowTitle">
@ -24,7 +24,7 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QLabel" name="labelToolTip">
<property name="sizePolicy">
@ -173,12 +173,22 @@
</column>
<column>
<property name="text">
<string>In sizes</string>
<string notr="true">Shift A</string>
</property>
</column>
<column>
<property name="text">
<string>In heights</string>
<string notr="true">Shift B</string>
</property>
</column>
<column>
<property name="text">
<string notr="true">Shift C</string>
</property>
</column>
<column>
<property name="text">
<string>Correction</string>
</property>
</column>
</widget>
@ -198,173 +208,12 @@
<property name="title">
<string>Details</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEditName">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Measurement's name in a formula</string>
</property>
<property name="placeholderText">
<string>Measurement's name in a formula.</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="labelFormula">
<property name="text">
<string>Formula:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayoutValue">
<item>
<widget class="VPlainTextEdit" name="plainTextEditFormula">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>28</height>
</size>
</property>
<property name="tabChangesFocus">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonGrow">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Show full calculation in message box&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff>../../libs/vtools/dialogs/support</normaloff>../../libs/vtools/dialogs/support</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonExpr">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Function Wizard</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="share/resources/tapeicon.qrc">
<normaloff>:/tapeicon/24x24/fx.png</normaloff>:/tapeicon/24x24/fx.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="0">
<widget class="QLabel" name="labelBaseValue">
<property name="text">
<string>Base value:</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="labelInSizes">
<property name="text">
<string>In sizes:</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="labelInHeights">
<property name="text">
<string>In heights:</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Description:</string>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="VPlainTextEdit" name="plainTextEditDescription">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Ignored">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>28</height>
</size>
</property>
</widget>
</item>
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>9</number>
</property>
<item alignment="Qt::AlignLeft">
<widget class="QToolButton" name="toolButtonTop">
<property name="enabled">
@ -433,23 +282,6 @@
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>5000</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
@ -457,13 +289,13 @@
</property>
<property name="sizeHint" stdset="0">
<size>
<width>5000</width>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item alignment="Qt::AlignRight">
<item>
<widget class="QToolButton" name="toolButtonRemove">
<property name="enabled">
<bool>false</bool>
@ -482,81 +314,309 @@
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QLabel" name="labelCalculated">
<property name="text">
<string>Calculated value:</string>
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="labelCalculatedValue">
<property name="toolTip">
<string>Calculated value</string>
</property>
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxBaseValue">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<double>-10000.000000000000000</double>
</property>
<property name="maximum">
<double>10000.000000000000000</double>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxInSizes">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<double>-10000.000000000000000</double>
</property>
<property name="maximum">
<double>10000.000000000000000</double>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxInHeights">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<double>-10000.000000000000000</double>
</property>
<property name="maximum">
<double>10000.000000000000000</double>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="labelFullName">
<property name="text">
<string>Full name:</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QLineEdit" name="lineEditFullName">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string/>
</property>
<property name="placeholderText">
<string>Measurement's human-readable name.</string>
</property>
</widget>
<item row="0" column="0">
<widget class="QLabel" name="labelMUnits">
<property name="text">
<string>Units:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxMUnits">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEditName">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Measurement's name in a formula</string>
</property>
<property name="placeholderText">
<string>Measurement's name in a formula.</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelCalculated">
<property name="text">
<string>Calculated value:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="labelCalculatedValue">
<property name="toolTip">
<string>Calculated value</string>
</property>
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labelFormula">
<property name="text">
<string>Formula:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayoutValue">
<item>
<widget class="VPlainTextEdit" name="plainTextEditFormula">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>28</height>
</size>
</property>
<property name="tabChangesFocus">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonGrow">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Show full calculation in message box&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff>../../libs/vtools/dialogs/support</normaloff>../../libs/vtools/dialogs/support</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonExpr">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Function Wizard</string>
</property>
<property name="text">
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="share/resources/tapeicon.qrc">
<normaloff>:/tapeicon/24x24/fx.png</normaloff>:/tapeicon/24x24/fx.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QLabel" name="labelBaseValue">
<property name="text">
<string>Base value:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxBaseValue">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<double>-10000.000000000000000</double>
</property>
<property name="maximum">
<double>10000.000000000000000</double>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="labelShiftA">
<property name="text">
<string notr="true">Shift A</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxShiftA">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<double>-10000.000000000000000</double>
</property>
<property name="maximum">
<double>10000.000000000000000</double>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="labelShiftB">
<property name="text">
<string>Shift B</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxShiftB">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<double>-10000.000000000000000</double>
</property>
<property name="maximum">
<double>10000.000000000000000</double>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="labelShiftC">
<property name="text">
<string>Shift C</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxShiftC">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<double>-10000.000000000000000</double>
</property>
<property name="maximum">
<double>10000.000000000000000</double>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="labelCorrection">
<property name="text">
<string>Correction:</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxCorrection">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<double>-10000.000000000000000</double>
</property>
<property name="maximum">
<double>10000.000000000000000</double>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="labelFullName">
<property name="text">
<string>Full name:</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QLineEdit" name="lineEditFullName">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string/>
</property>
<property name="placeholderText">
<string>Measurement's human-readable name.</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Description:</string>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="VPlainTextEdit" name="plainTextEditDescription">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Ignored">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>28</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
@ -884,7 +944,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1034</width>
<width>1188</width>
<height>21</height>
</rect>
</property>

View File

@ -71,18 +71,24 @@ const QString VMeasurements::TagMeasurement = QStringLiteral("m");
const QString VMeasurements::TagDimensions = QStringLiteral("dimensions");
const QString VMeasurements::TagDimension = QStringLiteral("dimension");
const QString VMeasurements::TagRestrictions = QStringLiteral("restrictions");
const QString VMeasurements::TagCorrections = QStringLiteral("corrections");
const QString VMeasurements::TagCorrection = QStringLiteral("correction");
const QString VMeasurements::AttrBase = QStringLiteral("base");
const QString VMeasurements::AttrValue = QStringLiteral("value");
const QString VMeasurements::AttrSizeIncrease = QStringLiteral("size_increase");
const QString VMeasurements::AttrHeightIncrease = QStringLiteral("height_increase");
const QString VMeasurements::AttrDescription = QStringLiteral("description");
const QString VMeasurements::AttrName = QStringLiteral("name");
const QString VMeasurements::AttrFullName = QStringLiteral("full_name");
const QString VMeasurements::AttrMin = QStringLiteral("min");
const QString VMeasurements::AttrMax = QStringLiteral("max");
const QString VMeasurements::AttrStep = QStringLiteral("step");
const QString VMeasurements::AttrCircumference = QStringLiteral("circumference");
const QString VMeasurements::AttrBase = QStringLiteral("base");
const QString VMeasurements::AttrValue = QStringLiteral("value");
const QString VMeasurements::AttrShiftA = QStringLiteral("shiftA");
const QString VMeasurements::AttrShiftB = QStringLiteral("shiftB");
const QString VMeasurements::AttrShiftC = QStringLiteral("shiftC");
const QString VMeasurements::AttrCorrection = QStringLiteral("correction");
const QString VMeasurements::AttrCoordinates = QStringLiteral("coordinates");
const QString VMeasurements::AttrSpecialUnits = QStringLiteral("specialUnits");
const QString VMeasurements::AttrDescription = QStringLiteral("description");
const QString VMeasurements::AttrName = QStringLiteral("name");
const QString VMeasurements::AttrFullName = QStringLiteral("full_name");
const QString VMeasurements::AttrMin = QStringLiteral("min");
const QString VMeasurements::AttrMax = QStringLiteral("max");
const QString VMeasurements::AttrStep = QStringLiteral("step");
const QString VMeasurements::AttrCircumference = QStringLiteral("circumference");
const QString VMeasurements::AttrFullCircumference = QStringLiteral("fullCircumference");
const QString VMeasurements::GenderMale = QStringLiteral("male");
@ -96,7 +102,10 @@ const QString VMeasurements::DimensionZ = QStringLiteral("z");
namespace
{
using VDimensions = QMap<MeasurementDimension, MeasurementDimension_p>;
Q_GLOBAL_STATIC_WITH_ARGS(const QString, defBirthDate, (QLatin1String("1800-01-01")))
Q_GLOBAL_STATIC(VDimensions, dimensionsCached)
//---------------------------------------------------------------------------------------------------------------------
QString FileComment()
@ -268,14 +277,19 @@ void VMeasurements::StoreNames(bool store)
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurements::ReadMeasurements(qreal height, qreal size) const
void VMeasurements::ReadMeasurements(qreal baseA, qreal baseB, qreal baseC) const
{
// For conversion values we must first calculate all data in measurement file's unit.
// That's why we need two containers: one for converted values, second for real data.
// Container for values in measurement file's unit
QScopedPointer<VContainer> tempData(new VContainer(data->GetTrVars(), data->GetPatternUnit(),
VContainer::UniqueNamespace()));
QSharedPointer<VContainer> tempData;
if (type == MeasurementsType::Individual)
{
tempData = QSharedPointer<VContainer>::create(data->GetTrVars(), data->GetPatternUnit(),
VContainer::UniqueNamespace());
}
const QDomNodeList list = elementsByTagName(TagMeasurement);
for (int i=0; i < list.size(); ++i)
@ -285,33 +299,66 @@ void VMeasurements::ReadMeasurements(qreal height, qreal size) const
const QString name = GetParametrString(dom, AttrName).simplified();
const QString description = GetParametrEmptyString(dom, AttrDescription);
const QString fullName = GetParametrEmptyString(dom, AttrFullName);
const bool specialUnits = GetParametrBool(dom, AttrSpecialUnits, falseStr);
QSharedPointer<VMeasurement> meash;
QSharedPointer<VMeasurement> tempMeash;
if (type == MeasurementsType::Multisize)
{
qreal base = GetParametrDouble(dom, AttrBase, QChar('0'));
qreal ksize = GetParametrDouble(dom, AttrSizeIncrease, QChar('0'));
qreal kheight = GetParametrDouble(dom, AttrHeightIncrease, QChar('0'));
qreal shiftA = GetParametrDouble(dom, AttrShiftA, QChar('0'));
qreal shiftB = GetParametrDouble(dom, AttrShiftB, QChar('0'));
qreal shiftC = GetParametrDouble(dom, AttrShiftC, QChar('0'));
QMap<QString, qreal> corrections = ReadCorrections(dom);
tempMeash = QSharedPointer<VMeasurement>(new VMeasurement(static_cast<quint32>(i), name, DimensionABase(),
DimensionBBase(), base, ksize, kheight));
tempMeash->SetSize(size);
tempMeash->SetHeight(height);
tempMeash->SetUnit(data->GetPatternUnit());
qreal convertedBaseA = DimensionABase();
qreal convertedBaseB = DimensionBBase();
qreal convertedBaseC = DimensionCBase();
qreal convertedStepA = DimensionAStep();
qreal convertedStepB = DimensionBStep();
qreal convertedStepC = DimensionCStep();
base = UnitConvertor(base, MUnit(), *data->GetPatternUnit());
ksize = UnitConvertor(ksize, MUnit(), *data->GetPatternUnit());
kheight = UnitConvertor(kheight, MUnit(), *data->GetPatternUnit());
if (not specialUnits)
{
base = UnitConvertor(base, MUnit(), *data->GetPatternUnit());
shiftA = UnitConvertor(shiftA, MUnit(), *data->GetPatternUnit());
shiftB = UnitConvertor(shiftB, MUnit(), *data->GetPatternUnit());
shiftC = UnitConvertor(shiftC, MUnit(), *data->GetPatternUnit());
const qreal baseSize = UnitConvertor(DimensionABase(), MUnit(), *data->GetPatternUnit());
const qreal baseHeight = UnitConvertor(DimensionBBase(), MUnit(), *data->GetPatternUnit());
QMutableMapIterator<QString, qreal> iterator(corrections);
while (iterator.hasNext())
{
iterator.next();
iterator.setValue(UnitConvertor(iterator.value(), MUnit(), *data->GetPatternUnit()));
}
meash = QSharedPointer<VMeasurement>(new VMeasurement(static_cast<quint32>(i), name, baseSize, baseHeight,
base, ksize, kheight, fullName, description));
meash->SetSize(size);
meash->SetHeight(height);
meash->SetUnit(data->GetPatternUnit());
convertedBaseA = UnitConvertor(convertedBaseA, MUnit(), *data->GetPatternUnit());
convertedBaseB = UnitConvertor(convertedBaseB, MUnit(), *data->GetPatternUnit());
convertedBaseC = UnitConvertor(convertedBaseC, MUnit(), *data->GetPatternUnit());
convertedStepA = UnitConvertor(convertedStepA, MUnit(), *data->GetPatternUnit());
convertedStepB = UnitConvertor(convertedStepB, MUnit(), *data->GetPatternUnit());
convertedStepC = UnitConvertor(convertedStepC, MUnit(), *data->GetPatternUnit());
}
meash = QSharedPointer<VMeasurement>::create(static_cast<quint32>(i), name,
convertedBaseA, convertedBaseB, convertedBaseC, base);
meash->SetBaseA(baseA);
meash->SetBaseB(baseB);
meash->SetBaseC(baseC);
meash->SetShiftA(shiftA);
meash->SetShiftB(shiftB);
meash->SetShiftC(shiftC);
meash->SetStepA(convertedStepA);
meash->SetStepB(convertedStepB);
meash->SetStepC(convertedStepC);
meash->SetSpecialUnits(specialUnits);
meash->SetCorrections(corrections);
meash->SetGuiText(fullName);
meash->SetDescription(description);
}
else
{
@ -319,21 +366,34 @@ void VMeasurements::ReadMeasurements(qreal height, qreal size) const
bool ok = false;
qreal value = EvalFormula(tempData.data(), formula, &ok);
tempMeash = QSharedPointer<VMeasurement>(new VMeasurement(tempData.data(), static_cast<quint32>(i), name,
value, formula, ok));
tempMeash = QSharedPointer<VMeasurement>::create(tempData.data(), static_cast<quint32>(i), name, value,
formula, ok);
value = UnitConvertor(value, MUnit(), *data->GetPatternUnit());
meash = QSharedPointer<VMeasurement>(new VMeasurement(data, static_cast<quint32>(i), name, value, formula,
ok, fullName, description));
if (not specialUnits)
{
value = UnitConvertor(value, MUnit(), *data->GetPatternUnit());
}
meash = QSharedPointer<VMeasurement>::create(data, static_cast<quint32>(i), name, value, formula, ok);
meash->SetGuiText(fullName);
meash->SetDescription(description);
meash->SetSpecialUnits(specialUnits);
}
if (m_keepNames)
{
tempData->AddUniqueVariable(tempMeash);
if (not tempData.isNull())
{
tempData->AddUniqueVariable(tempMeash);
}
data->AddUniqueVariable(meash);
}
else
{
tempData->AddVariable(tempMeash);
if (not tempData.isNull())
{
tempData->AddVariable(tempMeash);
}
data->AddVariable(meash);
}
}
@ -399,7 +459,7 @@ int VMeasurements::DimensionCBase() const
if (type == MeasurementsType::Multisize)
{
const auto dimensions = Dimensions();
if (not dimensions.isEmpty() && dimensions.size() >= 3)
if (not dimensions.isEmpty() && dimensions.size() == 3)
{
return dimensions.last()->BaseValue();
}
@ -408,6 +468,51 @@ int VMeasurements::DimensionCBase() const
return 0;
}
//---------------------------------------------------------------------------------------------------------------------
int VMeasurements::DimensionAStep() const
{
if (type == MeasurementsType::Multisize)
{
const auto dimensions = Dimensions();
if (not dimensions.isEmpty())
{
return dimensions.first()->Step();
}
}
return 0;
}
//---------------------------------------------------------------------------------------------------------------------
int VMeasurements::DimensionBStep() const
{
if (type == MeasurementsType::Multisize)
{
const auto dimensions = Dimensions();
if (not dimensions.isEmpty() && dimensions.size() >= 2)
{
return dimensions.values().at(1)->Step();
}
}
return 0;
}
//---------------------------------------------------------------------------------------------------------------------
int VMeasurements::DimensionCStep() const
{
if (type == MeasurementsType::Multisize)
{
const auto dimensions = Dimensions();
if (not dimensions.isEmpty() && dimensions.size() == 3)
{
return dimensions.last()->Step();
}
}
return 0;
}
//---------------------------------------------------------------------------------------------------------------------
QString VMeasurements::Notes() const
{
@ -583,12 +688,12 @@ void VMeasurements::SetMBaseValue(const QString &name, double value)
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurements::SetMSizeIncrease(const QString &name, double value)
void VMeasurements::SetMShiftA(const QString &name, double value)
{
QDomElement node = FindM(name);
if (not node.isNull())
{
SetAttribute(node, AttrSizeIncrease, value);
SetAttribute(node, AttrShiftA, value);
}
else
{
@ -597,12 +702,69 @@ void VMeasurements::SetMSizeIncrease(const QString &name, double value)
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurements::SetMHeightIncrease(const QString &name, double value)
void VMeasurements::SetMShiftB(const QString &name, double value)
{
QDomElement node = FindM(name);
if (not node.isNull())
{
SetAttribute(node, AttrHeightIncrease, value);
SetAttribute(node, AttrShiftB, value);
}
else
{
qWarning() << tr("Can't find measurement '%1'").arg(name);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurements::SetMShiftC(const QString &name, double value)
{
QDomElement node = FindM(name);
if (not node.isNull())
{
SetAttribute(node, AttrShiftC, value);
}
else
{
qWarning() << tr("Can't find measurement '%1'").arg(name);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurements::SetMSpecialUnits(const QString &name, bool special)
{
QDomElement node = FindM(name);
if (not node.isNull())
{
SetAttributeOrRemoveIf(node, AttrSpecialUnits, special, not special);
}
else
{
qWarning() << tr("Can't find measurement '%1'").arg(name);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurements::SetMCorrectionValue(const QString &name, qreal baseA, qreal baseB, qreal baseC, double value)
{
QDomElement mElement = FindM(name);
if (not mElement.isNull())
{
QMap<QString, qreal> corrections = ReadCorrections(mElement);
const QString hash = VMeasurement::CorrectionHash(baseA, baseB, baseC);
if (not qFuzzyIsNull(value))
{
corrections.insert(hash, value);
}
else
{
if (corrections.contains(hash))
{
corrections.remove(hash);
}
}
WriteCorrections(mElement, corrections);
}
else
{
@ -641,47 +803,53 @@ void VMeasurements::SetMFullName(const QString &name, const QString &text)
//---------------------------------------------------------------------------------------------------------------------
QMap<MeasurementDimension, MeasurementDimension_p > VMeasurements::Dimensions() const
{
QMap<MeasurementDimension, MeasurementDimension_p > dimesions;
const Unit units = MUnit();
const QDomNodeList list = elementsByTagName(TagDimension);
for (int i=0; i < list.size(); ++i)
if (type != MeasurementsType::Multisize)
{
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'));
return QMap<MeasurementDimension, MeasurementDimension_p>();
}
if (type == MeasurementDimension::X)
if (dimensionsCached->isEmpty())
{
const Unit units = MUnit();
const QDomNodeList list = elementsByTagName(TagDimension);
for (int i=0; i < list.size(); ++i)
{
auto dimension = QSharedPointer<VXMeasurementDimension>::create(units, min, max, step);
dimension->SetBaseValue(base);
dimesions.insert(type, dimension);
}
else if (type == MeasurementDimension::Y)
{
auto dimension = QSharedPointer<VYMeasurementDimension>::create(units, min, max, step);
dimension->SetBaseValue(base);
dimension->SetCircumference(GetParametrBool(dom, AttrCircumference, trueStr));
dimesions.insert(type, dimension);
}
else if (type == MeasurementDimension::W)
{
auto dimension = QSharedPointer<VWMeasurementDimension>::create(units, min, max, step);
dimension->SetBaseValue(base);
dimesions.insert(type, dimension);
}
else if (type == MeasurementDimension::Z)
{
auto dimension = QSharedPointer<VZMeasurementDimension>::create(units, min, max, step);
dimension->SetBaseValue(base);
dimesions.insert(type, dimension);
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'));
if (type == MeasurementDimension::X)
{
auto dimension = QSharedPointer<VXMeasurementDimension>::create(units, min, max, step);
dimension->SetBaseValue(base);
dimensionsCached->insert(type, dimension);
}
else if (type == MeasurementDimension::Y)
{
auto dimension = QSharedPointer<VYMeasurementDimension>::create(units, min, max, step);
dimension->SetBaseValue(base);
dimension->SetCircumference(GetParametrBool(dom, AttrCircumference, trueStr));
dimensionsCached->insert(type, dimension);
}
else if (type == MeasurementDimension::W)
{
auto dimension = QSharedPointer<VWMeasurementDimension>::create(units, min, max, step);
dimension->SetBaseValue(base);
dimensionsCached->insert(type, dimension);
}
else if (type == MeasurementDimension::Z)
{
auto dimension = QSharedPointer<VZMeasurementDimension>::create(units, min, max, step);
dimension->SetBaseValue(base);
dimensionsCached->insert(type, dimension);
}
}
}
return dimesions;
return *dimensionsCached;
}
//---------------------------------------------------------------------------------------------------------------------
@ -936,8 +1104,7 @@ QDomElement VMeasurements::MakeEmpty(const QString &name, const QString &formula
if (type == MeasurementsType::Multisize)
{
SetAttribute(element, AttrBase, QChar('0'));
SetAttribute(element, AttrSizeIncrease, QChar('0'));
SetAttribute(element, AttrHeightIncrease, QChar('0'));
SetAttribute(element, AttrShiftA, QChar('0'));
}
else
{
@ -1030,3 +1197,73 @@ QString VMeasurements::ClearPMCode(const QString &code) const
}
return clear;
}
//---------------------------------------------------------------------------------------------------------------------
QMap<QString, qreal> VMeasurements::ReadCorrections(const QDomElement &mElement) const
{
if (mElement.isNull())
{
return QMap<QString, qreal>();
}
QDomElement correctionsTag = mElement.firstChildElement(TagCorrections);
if (correctionsTag.isNull())
{
return QMap<QString, qreal>();
}
QMap<QString, qreal> corrections;
QDomNode correctionTag = correctionsTag.firstChild();
while (not correctionTag.isNull())
{
if (correctionTag.isElement())
{
const QDomElement c = correctionTag.toElement();
const QString hash = GetParametrString(c, AttrCoordinates);
const qreal correction = GetParametrDouble(c, AttrCorrection, QChar('0'));
corrections.insert(hash, correction);
}
correctionTag = correctionTag.nextSibling();
}
return corrections;
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurements::WriteCorrections(QDomElement &mElement, const QMap<QString, qreal> &corrections)
{
QDomElement correctionsTag = mElement.firstChildElement(TagCorrections);
if (not corrections.isEmpty())
{
if (not correctionsTag.isNull())
{
RemoveAllChildren(correctionsTag);
}
else
{
correctionsTag = createElement(TagCorrections);
mElement.appendChild(correctionsTag);
}
QMap<QString, qreal>::const_iterator i = corrections.constBegin();
while (i != corrections.constEnd())
{
QDomElement correctionTag = createElement(TagCorrection);
SetAttribute(correctionTag, AttrCorrection, i.value());
SetAttribute(correctionTag, AttrCoordinates, i.key());
correctionsTag.appendChild(correctionTag);
++i;
}
}
else
{
if (not correctionsTag.isNull())
{
mElement.removeChild(correctionsTag);
}
}
}

View File

@ -67,7 +67,7 @@ public:
void StoreNames(bool store);
void ReadMeasurements(qreal height, qreal size) const;
void ReadMeasurements(qreal baseA, qreal baseB=0, qreal baseC=0) const;
void ClearForExport();
MeasurementsType Type() const;
@ -75,6 +75,10 @@ public:
int DimensionBBase() const;
int DimensionCBase() const;
int DimensionAStep() const;
int DimensionBStep() const;
int DimensionCStep() const;
QString Notes() const;
void SetNotes(const QString &text);
@ -102,8 +106,11 @@ public:
void SetMName(const QString &name, const QString &text);
void SetMValue(const QString &name, const QString &text);
void SetMBaseValue(const QString &name, double value);
void SetMSizeIncrease(const QString &name, double value);
void SetMHeightIncrease(const QString &name, double value);
void SetMShiftA(const QString &name, double value);
void SetMShiftB(const QString &name, double value);
void SetMShiftC(const QString &name, double value);
void SetMSpecialUnits(const QString &name, bool special);
void SetMCorrectionValue(const QString &name, qreal baseA, qreal baseB, qreal baseC, double value);
void SetMDescription(const QString &name, const QString &text);
void SetMFullName(const QString &name, const QString &text);
@ -127,11 +134,17 @@ public:
static const QString TagDimensions;
static const QString TagDimension;
static const QString TagRestrictions;
static const QString TagCorrections;
static const QString TagCorrection;
static const QString AttrBase;
static const QString AttrValue;
static const QString AttrSizeIncrease;
static const QString AttrHeightIncrease;
static const QString AttrShiftA;
static const QString AttrShiftB;
static const QString AttrShiftC;
static const QString AttrCorrection;
static const QString AttrCoordinates;
static const QString AttrSpecialUnits;
static const QString AttrDescription;
static const QString AttrName;
static const QString AttrFullName;
@ -187,6 +200,9 @@ private:
qreal EvalFormula(VContainer *data, const QString &formula, bool *ok) const;
QString ClearPMCode(const QString &code) const;
QMap<QString, qreal> ReadCorrections(const QDomElement &mElement) const;
void WriteCorrections(QDomElement &mElement, const QMap<QString, qreal> &corrections);
};
#endif // VMEASUREMENTS_H

View File

@ -40,36 +40,25 @@
/**
* @brief VMeasurement create measurement for multisize table
* @param name measurement's name
* @param base value in base size and height
* @param ksize increment in sizes
* @param kheight increment in heights
* @param gui_text shor tooltip for user
* @param description measurement full description
* @param tagName measurement's tag name in file
* @param base measurement's base value
*/
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, description),
d(new VMeasurementData(index, gui_text, tagName, baseSize, baseHeight, base, ksize, kheight))
VMeasurement::VMeasurement(quint32 index, const QString &name, qreal baseA, qreal baseB, qreal baseC, qreal base)
:VVariable(name),
d(new VMeasurementData(index, baseA, baseB, baseC, base))
{
SetType(VarType::Measurement);
VInternalVariable::SetValue(d->base);
VInternalVariable::SetValue(d->shiftBase);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VMeasurement create measurement for individual table
* @param name measurement's name
* @param name measurement's base value
* @param base value in base size and height
* @param gui_text shor tooltip for user
* @param description measurement full description
* @param tagName measurement's tag name in file
*/
VMeasurement::VMeasurement(VContainer *data, quint32 index, const QString &name, const qreal &base,
const QString &formula, bool ok, const QString &gui_text, const QString &description,
const QString &tagName)
:VVariable(name, description), d(new VMeasurementData(data, index, formula, ok, gui_text, tagName, base))
const QString &formula, bool ok)
:VVariable(name), d(new VMeasurementData(data, index, formula, ok, base))
{
SetType(VarType::Measurement);
VInternalVariable::SetValue(base);
@ -231,27 +220,38 @@ bool VMeasurement::IsGradationHeightValid(const QString &height)
}
}
//---------------------------------------------------------------------------------------------------------------------
QString VMeasurement::CorrectionHash(qreal baseA, qreal baseB, qreal baseC)
{
return QStringList({QString::number(baseA), QString::number(baseB), QString::number(baseC)}).join(';');
}
//---------------------------------------------------------------------------------------------------------------------
qreal VMeasurement::CalcValue() const
{
if (d->currentUnit == nullptr || qFuzzyIsNull(d->currentSize) || qFuzzyIsNull(d->currentHeight))
if (qFuzzyIsNull(d->currentBaseA))
{
return VInternalVariable::GetValue();
}
if (*d->currentUnit == Unit::Inch)
// Formula for calculation gradation
const qreal kA = d->stepA > 0 ? (d->currentBaseA - d->baseA) / d->stepA : 0;
const qreal kB = d->stepB > 0 ? (d->currentBaseB - d->baseB) / d->stepB : 0;
const qreal kC = d->stepC > 0 ? (d->currentBaseC - d->baseC) / d->stepC : 0;
return d->shiftBase + kA * d->shiftA + kB * d->shiftB + kC * d->shiftC + Correction();
}
//---------------------------------------------------------------------------------------------------------------------
qreal VMeasurement::Correction() const
{
const QString hash = CorrectionHash(d->currentBaseA, d->currentBaseB, d->currentBaseC);
if (d->corrections.contains(hash))
{
qWarning("Gradation doesn't support inches");
return 0;
return d->corrections.value(hash);
}
const qreal sizeIncrement = UnitConvertor(2.0, Unit::Cm, *d->currentUnit);
const qreal heightIncrement = UnitConvertor(6.0, Unit::Cm, *d->currentUnit);
// Formula for calculation gradation
const qreal k_size = ( d->currentSize - d->baseSize ) / sizeIncrement;
const qreal k_height = ( d->currentHeight - d->baseHeight ) / heightIncrement;
return d->base + k_size * d->ksize + k_height * d->kheight;
return 0;
}
//---------------------------------------------------------------------------------------------------------------------
@ -265,15 +265,9 @@ QString VMeasurement::GetGuiText() const
}
//---------------------------------------------------------------------------------------------------------------------
QString VMeasurement::TagName() const
void VMeasurement::SetGuiText(const QString &guiText)
{
return d->_tagName;
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurement::setTagName(const QString &tagName)
{
d->_tagName = tagName;
d->gui_text = guiText;
}
//---------------------------------------------------------------------------------------------------------------------
@ -303,7 +297,7 @@ bool VMeasurement::IsFormulaOk() const
//---------------------------------------------------------------------------------------------------------------------
bool VMeasurement::IsNotUsed() const
{
return qFuzzyIsNull(d->base) && qFuzzyIsNull(d->ksize) && qFuzzyIsNull(d->kheight);
return qFuzzyIsNull(d->shiftBase) && qFuzzyIsNull(d->shiftB) && qFuzzyIsNull(d->shiftA);
}
//---------------------------------------------------------------------------------------------------------------------
@ -326,21 +320,21 @@ VContainer *VMeasurement::GetData()
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurement::SetSize(qreal size)
void VMeasurement::SetBaseA(qreal base)
{
d->currentSize = size;
d->currentBaseA = base;
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurement::SetHeight(qreal height)
void VMeasurement::SetBaseB(qreal base)
{
d->currentHeight = height;
d->currentBaseB = base;
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurement::SetUnit(const Unit *unit)
void VMeasurement::SetBaseC(qreal base)
{
d->currentUnit = unit;
d->currentBaseC = base;
}
//---------------------------------------------------------------------------------------------------------------------
@ -350,30 +344,13 @@ void VMeasurement::SetUnit(const Unit *unit)
*/
qreal VMeasurement::GetBase() const
{
return d->base;
return d->shiftBase;
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurement::SetBase(const qreal &value)
void VMeasurement::SetBase(qreal value)
{
d->base = value;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetKsize return increment in sizes
* @return increment
*/
qreal VMeasurement::GetKsize() const
{
return d->ksize;
}
//---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress unusedFunction
void VMeasurement::SetKsize(const qreal &value)
{
d->ksize = value;
d->shiftBase = value;
}
//---------------------------------------------------------------------------------------------------------------------
@ -381,14 +358,109 @@ void VMeasurement::SetKsize(const qreal &value)
* @brief GetKheight return increment in heights
* @return increment
*/
qreal VMeasurement::GetKheight() const
qreal VMeasurement::GetShiftA() const
{
return d->kheight;
return d->shiftA;
}
//---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress unusedFunction
void VMeasurement::SetKheight(const qreal &value)
void VMeasurement::SetShiftA(qreal value)
{
d->kheight = value;
d->shiftA = value;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetKsize return increment in sizes
* @return increment
*/
qreal VMeasurement::GetShiftB() const
{
return d->shiftB;
}
//---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress unusedFunction
void VMeasurement::SetShiftB(qreal value)
{
d->shiftB = value;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VMeasurement::GetShiftC() const
{
return d->shiftC;
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurement::SetShiftC(qreal value)
{
d->shiftC = value;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VMeasurement::GetStepA() const
{
return d->shiftA;
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurement::SetStepA(qreal value)
{
d->stepA = value;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VMeasurement::GetStepB() const
{
return d->stepB;
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurement::SetStepB(qreal value)
{
d->stepB = value;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VMeasurement::GetStepC() const
{
return d->stepC;
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurement::SetStepC(qreal value)
{
d->stepC = value;
}
//---------------------------------------------------------------------------------------------------------------------
bool VMeasurement::IsSpecialUnits() const
{
return d->specialUnits;
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurement::SetSpecialUnits(bool special)
{
d->specialUnits = special;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VMeasurement::GetCorrection(int baseA, int baseB, int baseC) const
{
return d->corrections.value(VMeasurement::CorrectionHash(baseA, baseB, baseC), 0);
}
//---------------------------------------------------------------------------------------------------------------------
QMap<QString, qreal> VMeasurement::GetCorrections() const
{
return d->corrections;
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurement::SetCorrections(const QMap<QString, qreal> &corrections)
{
d->corrections = corrections;
}

View File

@ -50,12 +50,9 @@ class VMeasurementData;
class VMeasurement :public VVariable
{
public:
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(quint32 index, const QString &name, qreal baseA, qreal baseB, qreal baseC, qreal base);
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());
bool ok);
VMeasurement(const VMeasurement &m);
virtual ~VMeasurement() override;
@ -67,9 +64,7 @@ public:
#endif
QString GetGuiText() const;
QString TagName() const;
void setTagName(const QString &tagName);
void SetGuiText(const QString &guiText);
QString GetFormula() const;
@ -85,19 +80,38 @@ public:
VContainer *GetData();
void SetSize(qreal size);
void SetHeight(qreal height);
void SetBaseA(qreal base);
void SetBaseB(qreal base);
void SetBaseC(qreal base);
void SetUnit(const Unit *unit);
qreal GetBase() const;
void SetBase(qreal value);
qreal GetBase() const;
void SetBase(const qreal &value);
qreal GetShiftA() const;
void SetShiftA(qreal value);
qreal GetKsize() const;
void SetKsize(const qreal &value);
qreal GetShiftB() const;
void SetShiftB(qreal value);
qreal GetKheight() const;
void SetKheight(const qreal &value);
qreal GetShiftC() const;
void SetShiftC(qreal value);
qreal GetStepA() const;
void SetStepA(qreal value);
qreal GetStepB() const;
void SetStepB(qreal value);
qreal GetStepC() const;
void SetStepC(qreal value);
bool IsSpecialUnits() const;
void SetSpecialUnits(bool special);
qreal GetCorrection(int baseA, int baseB, int baseC) const;
QMap<QString, qreal> GetCorrections() const;
void SetCorrections(const QMap<QString, qreal> &corrections);
static QStringList ListHeights(const QMap<GHeights, bool> &heights, Unit patternUnit);
static QStringList ListSizes(const QMap<GSizes, bool> &sizes, Unit patternUnit);
@ -105,10 +119,12 @@ public:
static QStringList WholeListSizes(Unit patternUnit);
static bool IsGradationSizeValid(const QString &size);
static bool IsGradationHeightValid(const QString &height);
static QString CorrectionHash(qreal baseA, qreal baseB, qreal baseC);
private:
QSharedDataPointer<VMeasurementData> d;
qreal CalcValue() const;
qreal Correction() const;
};
Q_DECLARE_TYPEINFO(VMeasurement, Q_MOVABLE_TYPE);

View File

@ -42,40 +42,20 @@ class VMeasurementData : public QSharedData
{
public:
VMeasurementData(quint32 index, const QString &gui_text, const QString &tagName, qreal baseSize, qreal baseHeight,
qreal base, qreal ksize, qreal kheight )
: data(),
index(index),
formula(),
gui_text(gui_text),
_tagName(tagName),
formulaOk(true),
currentSize(0),
currentHeight(0),
currentUnit(nullptr),
base(base),
ksize(ksize),
kheight(kheight),
baseSize(baseSize),
baseHeight(baseHeight)
VMeasurementData(quint32 index, qreal baseA, qreal baseB, qreal baseC, qreal base)
: index(index),
shiftBase(base),
baseA(baseA),
baseB(baseB),
baseC(baseC)
{}
VMeasurementData(VContainer *data, quint32 index, const QString &formula, bool ok, const QString &gui_text,
const QString &tagName, qreal base)
VMeasurementData(VContainer *data, quint32 index, const QString &formula, bool ok, qreal base)
: data(QSharedPointer<VContainer>(new VContainer(*data))),
index(index),
formula(formula),
gui_text(gui_text),
_tagName(tagName),
formulaOk(ok),
currentSize(0),
currentHeight(0),
currentUnit(nullptr),
base(base),
ksize(0),
kheight(0),
baseSize(0),
baseHeight(0)
shiftBase(base)
{}
VMeasurementData(const VMeasurementData &m)
@ -84,42 +64,53 @@ public:
index(m.index),
formula(m.formula),
gui_text(m.gui_text),
_tagName(m._tagName),
formulaOk(m.formulaOk),
currentSize(m.currentSize),
currentHeight(m.currentHeight),
currentUnit(m.currentUnit),
base(m.base),
ksize(m.ksize),
kheight(m.kheight),
baseSize(m.baseSize),
baseHeight(m.baseHeight)
currentBaseA(m.currentBaseA),
currentBaseB(m.currentBaseB),
currentBaseC(m.currentBaseC),
shiftBase(m.shiftBase),
shiftA(m.shiftA),
shiftB(m.shiftB),
shiftC(m.shiftC),
stepA(m.stepA),
stepB(m.stepB),
stepC(m.stepC),
baseA(m.baseA),
baseB(m.baseB),
baseC(m.baseC),
corrections(m.corrections),
specialUnits(m.specialUnits)
{}
virtual ~VMeasurementData();
QSharedPointer<VContainer> data;
QSharedPointer<VContainer> data{};
quint32 index;
QString formula;
QString gui_text;
QString _tagName;
bool formulaOk;
QString formula{};
QString gui_text{};
bool formulaOk{true};
qreal currentSize;
qreal currentHeight;
const Unit *currentUnit;
qreal currentBaseA{0};
qreal currentBaseB{0};
qreal currentBaseC{0};
/** @brief base value in base size and height */
qreal base;
qreal shiftBase{0};
/** @brief ksize increment in sizes */
qreal ksize;
qreal shiftA{0};
qreal shiftB{0};
qreal shiftC{0};
/** @brief kgrowth increment in heights */
qreal kheight;
qreal stepA{0};
qreal stepB{0};
qreal stepC{0};
qreal baseSize;
qreal baseHeight;
qreal baseA{0};
qreal baseB{0};
qreal baseC{0};
QMap<QString, qreal> corrections{};
bool specialUnits{false};
private:
Q_DISABLE_ASSIGN(VMeasurementData)

View File

@ -45,7 +45,7 @@ class VVariable :public VInternalVariable
{
public:
VVariable();
VVariable(const QString &name, const QString &description = QString());
explicit VVariable(const QString &name, const QString &description = QString());
VVariable(const VVariable &var);
virtual ~VVariable() override;