New measurement type separator.
This commit is contained in:
parent
427a70b541
commit
038fbb3540
|
@ -33,6 +33,7 @@
|
|||
- Added scroll area to layout settings dialog.
|
||||
- Allow size to have values from 1 to 100 if not a circumference.
|
||||
- Fix tool True darts notes.
|
||||
- New measurement type separator.
|
||||
|
||||
# Valentina 0.7.49 July 1, 2021
|
||||
- Fix crash.
|
||||
|
|
|
@ -9,5 +9,7 @@
|
|||
<file>tapeicon/24x24/padlock_locked.png</file>
|
||||
<file>tapeicon/24x24/padlock_opened.png</file>
|
||||
<file>tapeicon/24x24/mannequin.png</file>
|
||||
<file>tapeicon/24x24/separator@2x.png</file>
|
||||
<file>tapeicon/24x24/separator.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
BIN
src/app/tape/share/resources/tapeicon/24x24/separator.png
Normal file
BIN
src/app/tape/share/resources/tapeicon/24x24/separator.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 846 B |
BIN
src/app/tape/share/resources/tapeicon/24x24/separator@2x.png
Normal file
BIN
src/app/tape/share/resources/tapeicon/24x24/separator@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.0 KiB |
|
@ -1447,6 +1447,36 @@ void TMainWindow::AddKnown()
|
|||
ui->tableWidget->repaint(); // Force repain to fix paint artifacts on Mac OS X
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void TMainWindow::AddSeparator()
|
||||
{
|
||||
const QString name = GetCustomName();
|
||||
qint32 currentRow = -1;
|
||||
|
||||
if (ui->tableWidget->currentRow() == -1)
|
||||
{
|
||||
currentRow = ui->tableWidget->rowCount();
|
||||
m->AddSeparator(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
currentRow = ui->tableWidget->currentRow()+1;
|
||||
const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName);
|
||||
m->AddSeparatorAfter(nameField->data(Qt::UserRole).toString(), name);
|
||||
}
|
||||
|
||||
m_search->AddRow(currentRow);
|
||||
RefreshData();
|
||||
m_search->RefreshList(ui->lineEditFind->text());
|
||||
|
||||
ui->tableWidget->selectRow(currentRow);
|
||||
|
||||
ui->actionExportToCSV->setEnabled(true);
|
||||
|
||||
MeasurementsWereSaved(false);
|
||||
ui->tableWidget->repaint(); // Force repain to fix paint artifacts on Mac OS X
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void TMainWindow::ImportFromPattern()
|
||||
{
|
||||
|
@ -1613,6 +1643,9 @@ void TMainWindow::ShowNewMData(bool fresh)
|
|||
|
||||
ShowMDiagram(meash->GetName());
|
||||
|
||||
ui->labelFullName->setVisible(meash->GetType() == VarType::Measurement);
|
||||
ui->lineEditFullName->setVisible(meash->GetType() == VarType::Measurement);
|
||||
|
||||
// Don't block all signal for QLineEdit. Need for correct handle with clear button.
|
||||
disconnect(ui->lineEditName, &QLineEdit::textEdited, this, &TMainWindow::SaveMName);
|
||||
ui->plainTextEditDescription->blockSignals(true);
|
||||
|
@ -1633,6 +1666,9 @@ void TMainWindow::ShowNewMData(bool fresh)
|
|||
connect(ui->lineEditName, &QLineEdit::textEdited, this, &TMainWindow::SaveMName);
|
||||
ui->plainTextEditDescription->blockSignals(false);
|
||||
|
||||
ui->labelMUnits->setVisible(meash->GetType() == VarType::Measurement);
|
||||
ui->comboBoxMUnits->setVisible(meash->GetType() == VarType::Measurement);
|
||||
|
||||
ui->comboBoxMUnits->blockSignals(true);
|
||||
ui->comboBoxMUnits->setCurrentIndex(
|
||||
ui->comboBoxMUnits->findData(static_cast<int>(meash->IsSpecialUnits() ? MUnits::Degrees : MUnits::Table)));
|
||||
|
@ -1640,6 +1676,32 @@ void TMainWindow::ShowNewMData(bool fresh)
|
|||
|
||||
if (mType == MeasurementsType::Multisize)
|
||||
{
|
||||
ui->labelCalculated->setVisible(meash->GetType() == VarType::Measurement);
|
||||
ui->labelCalculatedValue->setVisible(meash->GetType() == VarType::Measurement);
|
||||
|
||||
ui->labelBaseValue->setVisible(meash->GetType() == VarType::Measurement);
|
||||
ui->doubleSpinBoxBaseValue->setVisible(meash->GetType() == VarType::Measurement);
|
||||
|
||||
ui->labelCorrection->setVisible(meash->GetType() == VarType::Measurement);
|
||||
ui->doubleSpinBoxCorrection->setVisible(meash->GetType() == VarType::Measurement);
|
||||
|
||||
ui->labelShiftA->setVisible(meash->GetType() == VarType::Measurement);
|
||||
ui->doubleSpinBoxShiftA->setVisible(meash->GetType() == VarType::Measurement);
|
||||
|
||||
const QList<MeasurementDimension_p> dimensions = m->Dimensions().values();
|
||||
|
||||
if (dimensions.size() > 1)
|
||||
{
|
||||
ui->labelShiftB->setVisible(meash->GetType() == VarType::Measurement);
|
||||
ui->doubleSpinBoxShiftB->setVisible(meash->GetType() == VarType::Measurement);
|
||||
}
|
||||
|
||||
if (dimensions.size() > 2)
|
||||
{
|
||||
ui->labelShiftC->setVisible(meash->GetType() == VarType::Measurement);
|
||||
ui->doubleSpinBoxShiftC->setVisible(meash->GetType() == VarType::Measurement);
|
||||
}
|
||||
|
||||
ui->labelCalculatedValue->blockSignals(true);
|
||||
ui->doubleSpinBoxBaseValue->blockSignals(true);
|
||||
ui->doubleSpinBoxCorrection->blockSignals(true);
|
||||
|
@ -1683,6 +1745,17 @@ void TMainWindow::ShowNewMData(bool fresh)
|
|||
}
|
||||
else
|
||||
{
|
||||
ui->labelCalculated->setVisible(meash->GetType() == VarType::Measurement);
|
||||
ui->labelCalculatedValue->setVisible(meash->GetType() == VarType::Measurement);
|
||||
|
||||
ui->labelFormula->setVisible(meash->GetType() == VarType::Measurement);
|
||||
ui->plainTextEditFormula->setVisible(meash->GetType() == VarType::Measurement);
|
||||
ui->pushButtonGrow->setVisible(meash->GetType() == VarType::Measurement);
|
||||
ui->toolButtonExpr->setVisible(meash->GetType() == VarType::Measurement);
|
||||
|
||||
ui->labelDimension->setVisible(meash->GetType() == VarType::Measurement);
|
||||
ui->comboBoxDimension->setVisible(meash->GetType() == VarType::Measurement);
|
||||
|
||||
EvalFormula(meash->GetFormula(), false, meash->GetData(), ui->labelCalculatedValue,
|
||||
meash->IsSpecialUnits());
|
||||
|
||||
|
@ -2408,6 +2481,7 @@ void TMainWindow::SetupMenu()
|
|||
// Measurements
|
||||
connect(ui->actionAddCustom, &QAction::triggered, this, &TMainWindow::AddCustom);
|
||||
connect(ui->actionAddKnown, &QAction::triggered, this, &TMainWindow::AddKnown);
|
||||
connect(ui->actionAddSeparator, &QAction::triggered, this, &TMainWindow::AddSeparator);
|
||||
connect(ui->actionDatabase, &QAction::triggered, MApplication::VApp(), &MApplication::ShowDataBase);
|
||||
connect(ui->actionImportFromPattern, &QAction::triggered, this, &TMainWindow::ImportFromPattern);
|
||||
|
||||
|
@ -2564,6 +2638,7 @@ void TMainWindow::InitWindow()
|
|||
|
||||
ui->actionAddCustom->setEnabled(true);
|
||||
ui->actionAddKnown->setEnabled(true);
|
||||
ui->actionAddSeparator->setEnabled(true);
|
||||
ui->actionImportFromPattern->setEnabled(true);
|
||||
ui->actionSaveAs->setEnabled(true);
|
||||
|
||||
|
@ -3026,13 +3101,25 @@ QTableWidgetItem *TMainWindow::AddCell(const QString &text, int row, int column,
|
|||
return item;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QTableWidgetItem *TMainWindow::AddSeparatorCell(const QString &text, int row, int column, int aligment, bool ok)
|
||||
{
|
||||
QTableWidgetItem *item = AddCell(text, row, column, aligment, ok);
|
||||
|
||||
QFont itemFont = item->font();
|
||||
itemFont.setBold(true);
|
||||
itemFont.setItalic(true);
|
||||
item->setFont(itemFont);
|
||||
return item;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void TMainWindow::RefreshData(bool freshCall)
|
||||
{
|
||||
QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
|
||||
data->ClearUniqueNames();
|
||||
data->ClearVariables(VarType::Measurement);
|
||||
data->ClearVariables({VarType::Measurement, VarType::MeasurementSeparator});
|
||||
m->ReadMeasurements(currentDimensionA, currentDimensionB, currentDimensionC);
|
||||
|
||||
RefreshTable(freshCall);
|
||||
|
@ -3057,87 +3144,107 @@ void TMainWindow::RefreshTable(bool freshCall)
|
|||
const QSharedPointer<VMeasurement> &meash = iMap.value();
|
||||
currentRow++;
|
||||
|
||||
if (mType == MeasurementsType::Individual)
|
||||
if (meash->GetType() == VarType::Measurement)
|
||||
{
|
||||
if (mType == MeasurementsType::Individual)
|
||||
{
|
||||
QTableWidgetItem *item = AddCell(VAbstractApplication::VApp()->TrVars()->MToUser(meash->GetName()),
|
||||
currentRow, ColumnName, Qt::AlignVCenter); // name
|
||||
item->setData(Qt::UserRole, meash->GetName());
|
||||
|
||||
if (meash->IsCustom())
|
||||
{
|
||||
AddCell(meash->GetGuiText(), currentRow, ColumnFullName, Qt::AlignVCenter);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddCell(VAbstractApplication::VApp()->TrVars()->GuiText(meash->GetName()), currentRow,
|
||||
ColumnFullName, Qt::AlignVCenter);
|
||||
}
|
||||
|
||||
QString calculatedValue;
|
||||
if (meash->IsSpecialUnits())
|
||||
{
|
||||
calculatedValue = locale().toString(*meash->GetValue()) + degreeSymbol;
|
||||
}
|
||||
else
|
||||
{
|
||||
calculatedValue = locale().toString(UnitConvertor(*meash->GetValue(), mUnit, pUnit));
|
||||
}
|
||||
|
||||
AddCell(calculatedValue, currentRow, ColumnCalcValue, Qt::AlignHCenter | Qt::AlignVCenter,
|
||||
meash->IsFormulaOk()); // calculated value
|
||||
|
||||
QString formula =
|
||||
VTranslateVars::TryFormulaToUser(meash->GetFormula(),
|
||||
VAbstractApplication::VApp()->Settings()->GetOsSeparator());
|
||||
|
||||
AddCell(formula, currentRow, ColumnFormula, Qt::AlignVCenter); // formula
|
||||
}
|
||||
else
|
||||
{
|
||||
QTableWidgetItem *item = AddCell(VAbstractApplication::VApp()->TrVars()->MToUser(meash->GetName()),
|
||||
currentRow, 0, Qt::AlignVCenter); // name
|
||||
item->setData(Qt::UserRole, meash->GetName());
|
||||
|
||||
if (meash->IsCustom())
|
||||
{
|
||||
AddCell(meash->GetGuiText(), currentRow, ColumnFullName, Qt::AlignVCenter);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddCell(VAbstractApplication::VApp()->TrVars()->GuiText(meash->GetName()), currentRow,
|
||||
ColumnFullName, Qt::AlignVCenter);
|
||||
}
|
||||
|
||||
QString calculatedValue;
|
||||
if (meash->IsSpecialUnits())
|
||||
{
|
||||
const qreal value = *data->DataVariables()->value(meash->GetName())->GetValue();
|
||||
calculatedValue = locale().toString(value) + degreeSymbol;
|
||||
}
|
||||
else
|
||||
{
|
||||
const qreal value = UnitConvertor(*data->DataVariables()->value(meash->GetName())->GetValue(),
|
||||
mUnit, pUnit);
|
||||
calculatedValue = locale().toString(value);
|
||||
}
|
||||
|
||||
AddCell(calculatedValue, currentRow, ColumnCalcValue,
|
||||
Qt::AlignHCenter | Qt::AlignVCenter, meash->IsFormulaOk()); // calculated value
|
||||
|
||||
AddCell(locale().toString(meash->GetBase()), currentRow, ColumnBaseValue,
|
||||
Qt::AlignHCenter | Qt::AlignVCenter); // base value
|
||||
|
||||
AddCell(locale().toString(meash->GetShiftA()), currentRow, ColumnShiftA,
|
||||
Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
else if (meash->GetType() == VarType::MeasurementSeparator)
|
||||
{
|
||||
QTableWidgetItem *item = AddCell(VAbstractApplication::VApp()->TrVars()->MToUser(meash->GetName()),
|
||||
currentRow, ColumnName, Qt::AlignVCenter); // name
|
||||
item->setData(Qt::UserRole, meash->GetName());
|
||||
AddSeparatorCell(meash->GetDescription(), currentRow, ColumnFullName, Qt::AlignVCenter); // description
|
||||
|
||||
if (meash->IsCustom())
|
||||
if (mType == MeasurementsType::Individual)
|
||||
{
|
||||
AddCell(meash->GetGuiText(), currentRow, ColumnFullName, Qt::AlignVCenter);
|
||||
ui->tableWidget->setSpan(currentRow, 1, 1, 3);
|
||||
}
|
||||
else
|
||||
else if (mType == MeasurementsType::Multisize)
|
||||
{
|
||||
AddCell(VAbstractApplication::VApp()->TrVars()->GuiText(meash->GetName()), currentRow, ColumnFullName,
|
||||
Qt::AlignVCenter);
|
||||
ui->tableWidget->setSpan(currentRow, 1, 1, 8);
|
||||
}
|
||||
|
||||
QString calculatedValue;
|
||||
if (meash->IsSpecialUnits())
|
||||
{
|
||||
calculatedValue = locale().toString(*meash->GetValue()) + degreeSymbol;
|
||||
}
|
||||
else
|
||||
{
|
||||
calculatedValue = locale().toString(UnitConvertor(*meash->GetValue(), mUnit, pUnit));
|
||||
}
|
||||
|
||||
AddCell(calculatedValue, currentRow, ColumnCalcValue, Qt::AlignHCenter | Qt::AlignVCenter,
|
||||
meash->IsFormulaOk()); // calculated value
|
||||
|
||||
QString formula =
|
||||
VTranslateVars::TryFormulaToUser(meash->GetFormula(),
|
||||
VAbstractApplication::VApp()->Settings()->GetOsSeparator());
|
||||
|
||||
AddCell(formula, currentRow, ColumnFormula, Qt::AlignVCenter); // formula
|
||||
}
|
||||
else
|
||||
{
|
||||
QTableWidgetItem *item = AddCell(VAbstractApplication::VApp()->TrVars()->MToUser(meash->GetName()),
|
||||
currentRow, 0, Qt::AlignVCenter); // name
|
||||
item->setData(Qt::UserRole, meash->GetName());
|
||||
|
||||
if (meash->IsCustom())
|
||||
{
|
||||
AddCell(meash->GetGuiText(), currentRow, ColumnFullName, Qt::AlignVCenter);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddCell(VAbstractApplication::VApp()->TrVars()->GuiText(meash->GetName()), currentRow, ColumnFullName,
|
||||
Qt::AlignVCenter);
|
||||
}
|
||||
|
||||
QString calculatedValue;
|
||||
if (meash->IsSpecialUnits())
|
||||
{
|
||||
const qreal value = *data->DataVariables()->value(meash->GetName())->GetValue();
|
||||
calculatedValue = locale().toString(value) + degreeSymbol;
|
||||
}
|
||||
else
|
||||
{
|
||||
const qreal value = UnitConvertor(*data->DataVariables()->value(meash->GetName())->GetValue(), mUnit,
|
||||
pUnit);
|
||||
calculatedValue = locale().toString(value);
|
||||
}
|
||||
|
||||
AddCell(calculatedValue, currentRow, ColumnCalcValue,
|
||||
Qt::AlignHCenter | Qt::AlignVCenter, meash->IsFormulaOk()); // calculated value
|
||||
|
||||
AddCell(locale().toString(meash->GetBase()), currentRow, ColumnBaseValue,
|
||||
Qt::AlignHCenter | Qt::AlignVCenter); // base value
|
||||
|
||||
AddCell(locale().toString(meash->GetShiftA()), currentRow, ColumnShiftA,
|
||||
Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4172,7 +4279,7 @@ QVector<qreal> TMainWindow::DimensionRestrictedValues(int index, const Measureme
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QMap<int, QSharedPointer<VMeasurement> > TMainWindow::OrderedMeasurments() const
|
||||
{
|
||||
const QMap<QString, QSharedPointer<VMeasurement> > table = data->DataMeasurements();
|
||||
const QMap<QString, QSharedPointer<VMeasurement> > table = data->DataMeasurementsWithSeparators();
|
||||
QMap<int, QSharedPointer<VMeasurement> > orderedTable;
|
||||
QMap<QString, QSharedPointer<VMeasurement> >::const_iterator iterMap;
|
||||
for (iterMap = table.constBegin(); iterMap != table.constEnd(); ++iterMap)
|
||||
|
|
|
@ -111,6 +111,7 @@ private slots:
|
|||
|
||||
void AddCustom();
|
||||
void AddKnown();
|
||||
void AddSeparator();
|
||||
void ImportFromPattern();
|
||||
|
||||
void DimensionABaseChanged();
|
||||
|
@ -210,6 +211,7 @@ private:
|
|||
bool MaybeSave();
|
||||
|
||||
QTableWidgetItem *AddCell(const QString &text, int row, int column, int aligment, bool ok = true);
|
||||
QTableWidgetItem* AddSeparatorCell(const QString &text, int row, int column, int aligment, bool ok = true);
|
||||
|
||||
void RefreshData(bool freshCall = false);
|
||||
void RefreshTable(bool freshCall = false);
|
||||
|
|
|
@ -128,7 +128,6 @@
|
|||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
<weight>75</weight>
|
||||
<italic>false</italic>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
|
@ -161,7 +160,6 @@
|
|||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
|
@ -196,7 +194,6 @@
|
|||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
|
@ -228,7 +225,6 @@
|
|||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
|
@ -1223,6 +1219,7 @@
|
|||
<addaction name="actionSave"/>
|
||||
<addaction name="actionAddKnown"/>
|
||||
<addaction name="actionAddCustom"/>
|
||||
<addaction name="actionAddSeparator"/>
|
||||
<addaction name="actionMeasurementDiagram"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
|
@ -1618,6 +1615,18 @@
|
|||
<enum>QAction::ApplicationSpecificRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAddSeparator">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="share/resources/tapeicon.qrc">
|
||||
<normaloff>:/tapeicon/24x24/separator.png</normaloff>:/tapeicon/24x24/separator.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add separator</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
|
|
|
@ -565,7 +565,7 @@ bool MainWindow::LoadMeasurements(const QString &path)
|
|||
}
|
||||
ToolBarOption();
|
||||
SetDimensionBases();
|
||||
pattern->ClearVariables(VarType::Measurement);
|
||||
pattern->ClearVariables({VarType::Measurement, VarType::MeasurementSeparator});
|
||||
m->StoreNames(false);
|
||||
m->ReadMeasurements(m_currentDimensionA, m_currentDimensionB, m_currentDimensionC);
|
||||
}
|
||||
|
@ -607,7 +607,7 @@ bool MainWindow::UpdateMeasurements(const QString &path, qreal baseA, qreal base
|
|||
|
||||
try
|
||||
{
|
||||
pattern->ClearVariables(VarType::Measurement);
|
||||
pattern->ClearVariables({VarType::Measurement, VarType::MeasurementSeparator});
|
||||
|
||||
if (not m->Dimensions().isEmpty())
|
||||
{
|
||||
|
|
|
@ -478,7 +478,7 @@ void VPattern::LiteParseIncrements()
|
|||
|
||||
data->ClearUniqueIncrementNames();
|
||||
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(VarType::Unknown) == 9, "Check that you used all types");
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(VarType::Unknown) == 10, "Check that you used all types");
|
||||
data->ClearVariables(VarType::Increment);
|
||||
data->ClearVariables(VarType::IncrementSeparator);
|
||||
|
||||
|
@ -4370,7 +4370,7 @@ void VPattern::PrepareForParse(const Document &parse)
|
|||
}
|
||||
else if (parse == Document::LiteParse || parse == Document::FullLiteParse)
|
||||
{
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(VarType::Unknown) == 9, "Check that you used all types");
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(VarType::Unknown) == 10, "Check that you used all types");
|
||||
QVector<VarType> types({VarType::LineAngle,
|
||||
VarType::LineLength,
|
||||
VarType::CurveLength,
|
||||
|
|
|
@ -74,6 +74,7 @@
|
|||
<file>schema/multisize_measurements/v0.4.4.xsd</file>
|
||||
<file>schema/multisize_measurements/v0.5.0.xsd</file>
|
||||
<file>schema/multisize_measurements/v0.5.1.xsd</file>
|
||||
<file>schema/multisize_measurements/v0.5.2.xsd</file>
|
||||
<file>schema/individual_measurements/v0.2.0.xsd</file>
|
||||
<file>schema/individual_measurements/v0.3.0.xsd</file>
|
||||
<file>schema/individual_measurements/v0.3.1.xsd</file>
|
||||
|
@ -82,7 +83,7 @@
|
|||
<file>schema/individual_measurements/v0.4.0.xsd</file>
|
||||
<file>schema/individual_measurements/v0.5.0.xsd</file>
|
||||
<file>schema/individual_measurements/v0.5.1.xsd</file>
|
||||
<file>schema/multisize_measurements/v0.5.2.xsd</file>
|
||||
<file>schema/individual_measurements/v0.5.2.xsd</file>
|
||||
<file>schema/label_template/v1.0.0.xsd</file>
|
||||
<file>schema/watermark/v1.0.0.xsd</file>
|
||||
<file>schema/watermark/v1.1.0.xsd</file>
|
||||
|
|
90
src/libs/ifc/schema/individual_measurements/v0.5.2.xsd
Normal file
90
src/libs/ifc/schema/individual_measurements/v0.5.2.xsd
Normal file
|
@ -0,0 +1,90 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
|
||||
<xs:element name="vit">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="version" type="formatVersion"/>
|
||||
<xs:element name="read-only" type="xs:boolean"/>
|
||||
<xs:element name="notes" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
||||
<xs:element name="unit" type="units"/>
|
||||
<xs:element name="pm_system" type="psCode"/>
|
||||
<xs:element name="personal">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="customer" type="xs:string"/>
|
||||
<xs:element name="birth-date" type="xs:date"/>
|
||||
<xs:element name="gender" type="gender"/>
|
||||
<xs:element name="email" type="xs:string"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="body-measurements">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="m" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="name" type="shortName" use="required"/>
|
||||
<xs:attribute name="value" type="xs:string"/>
|
||||
<xs:attribute name="full_name" type="xs:string"/>
|
||||
<xs:attribute name="description" type="xs:string"/>
|
||||
<xs:attribute name="specialUnits" type="xs:boolean"/>
|
||||
<xs:attribute name="dimension" type="dimensionType"/>
|
||||
<xs:attribute name="type" type="measurementType"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="template" type="xs:string"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:unique name="measurementName">
|
||||
<xs:selector xpath="body-measurements/m"/>
|
||||
<xs:field xpath="@name"/>
|
||||
</xs:unique>
|
||||
</xs:element>
|
||||
<xs:simpleType name="shortName">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="([^\p{Nd}\p{Zs}*/&|!<>^ \()\-−+.,٫, ٬.’=?:;'\"]){1,1}([^\p{Zs}*/&|!<>^ \()\-−+.,٫, ٬.’=?:;\"]){0,}"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="formatVersion">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,}"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="units">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="mm"/>
|
||||
<xs:enumeration value="cm"/>
|
||||
<xs:enumeration value="inch"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="gender">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="unknown"/>
|
||||
<xs:enumeration value="male"/>
|
||||
<xs:enumeration value="female"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="psCode">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="(([0-9]|[1-4][0-9]|5[0-4])|998)"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="dimensionType">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="n"/>
|
||||
<xs:enumeration value="x"/>
|
||||
<xs:enumeration value="y"/>
|
||||
<xs:enumeration value="w"/>
|
||||
<xs:enumeration value="z"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="measurementType">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="measurement"/>
|
||||
<xs:enumeration value="separator"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:schema>
|
|
@ -73,13 +73,14 @@
|
|||
</xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="name" type="shortName" use="required"/>
|
||||
<xs:attribute name="base" type="xs:double" use="required"/>
|
||||
<xs:attribute name="base" type="xs:double"/>
|
||||
<xs:attribute name="shiftA" type="xs:double"/>
|
||||
<xs:attribute name="shiftB" type="xs:double"/>
|
||||
<xs:attribute name="shiftC" type="xs:double"/>
|
||||
<xs:attribute name="full_name" type="xs:string"/>
|
||||
<xs:attribute name="description" type="xs:string"/>
|
||||
<xs:attribute name="specialUnits" type="xs:boolean"/>
|
||||
<xs:attribute name="type" type="measurementType"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
|
@ -134,4 +135,10 @@
|
|||
<xs:maxInclusive value="80"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="measurementType">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="measurement"/>
|
||||
<xs:enumeration value="separator"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:schema>
|
||||
|
|
|
@ -54,8 +54,8 @@
|
|||
*/
|
||||
|
||||
const QString VVITConverter::MeasurementMinVerStr = QStringLiteral("0.2.0");
|
||||
const QString VVITConverter::MeasurementMaxVerStr = QStringLiteral("0.5.1");
|
||||
const QString VVITConverter::CurrentSchema = QStringLiteral("://schema/individual_measurements/v0.5.1.xsd");
|
||||
const QString VVITConverter::MeasurementMaxVerStr = QStringLiteral("0.5.2");
|
||||
const QString VVITConverter::CurrentSchema = QStringLiteral("://schema/individual_measurements/v0.5.2.xsd");
|
||||
|
||||
//VVITConverter::MeasurementMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||
//VVITConverter::MeasurementMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||
|
@ -90,7 +90,8 @@ QString VVITConverter::XSDSchema(unsigned ver) const
|
|||
std::make_pair(FormatVersion(0, 3, 3), QStringLiteral("://schema/individual_measurements/v0.3.3.xsd")),
|
||||
std::make_pair(FormatVersion(0, 4, 0), QStringLiteral("://schema/individual_measurements/v0.4.0.xsd")),
|
||||
std::make_pair(FormatVersion(0, 5, 0), QStringLiteral("://schema/individual_measurements/v0.5.0.xsd")),
|
||||
std::make_pair(FormatVersion(0, 5, 1), CurrentSchema),
|
||||
std::make_pair(FormatVersion(0, 5, 1), QStringLiteral("://schema/individual_measurements/v0.5.1.xsd")),
|
||||
std::make_pair(FormatVersion(0, 5, 2), CurrentSchema),
|
||||
};
|
||||
|
||||
if (schemas.contains(ver))
|
||||
|
@ -137,6 +138,10 @@ void VVITConverter::ApplyPatches()
|
|||
ValidateXML(XSDSchema(FormatVersion(0, 5, 1)));
|
||||
Q_FALLTHROUGH();
|
||||
case (FormatVersion(0, 5, 1)):
|
||||
ToV0_5_2();
|
||||
ValidateXML(XSDSchema(FormatVersion(0, 5, 2)));
|
||||
Q_FALLTHROUGH();
|
||||
case (FormatVersion(0, 5, 2)):
|
||||
break;
|
||||
default:
|
||||
InvalidVersion(m_ver);
|
||||
|
@ -155,7 +160,7 @@ void VVITConverter::DowngradeToCurrentMaxVersion()
|
|||
bool VVITConverter::IsReadOnly() const
|
||||
{
|
||||
// Check if attribute read-only was not changed in file format
|
||||
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMaxVer == FormatVersion(0, 5, 1),
|
||||
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMaxVer == FormatVersion(0, 5, 2),
|
||||
"Check attribute read-only.");
|
||||
|
||||
// Possibly in future attribute read-only will change position etc.
|
||||
|
@ -444,3 +449,14 @@ void VVITConverter::ToV0_5_1()
|
|||
SetVersion(QStringLiteral("0.5.1"));
|
||||
Save();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VVITConverter::ToV0_5_2()
|
||||
{
|
||||
// TODO. Delete if minimal supported version is 0.5.2
|
||||
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FormatVersion(0, 5, 2),
|
||||
"Time to refactor the code.");
|
||||
|
||||
SetVersion(QStringLiteral("0.5.2"));
|
||||
Save();
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
static const QString MeasurementMaxVerStr;
|
||||
static const QString CurrentSchema;
|
||||
static Q_DECL_CONSTEXPR const unsigned MeasurementMinVer = FormatVersion(0, 2, 0);
|
||||
static Q_DECL_CONSTEXPR const unsigned MeasurementMaxVer = FormatVersion(0, 5, 1);
|
||||
static Q_DECL_CONSTEXPR const unsigned MeasurementMaxVer = FormatVersion(0, 5, 2);
|
||||
|
||||
protected:
|
||||
virtual unsigned MinVer() const override;
|
||||
|
@ -83,6 +83,7 @@ private:
|
|||
void ToV0_4_0();
|
||||
void ToV0_5_0();
|
||||
void ToV0_5_1();
|
||||
void ToV0_5_2();
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#include "../vpatterndb/measurements.h"
|
||||
#include "../vpatterndb/pmsystems.h"
|
||||
#include "../vmisc/projectversion.h"
|
||||
#include "def.h"
|
||||
|
||||
const QString VMeasurements::TagVST = QStringLiteral("vst");
|
||||
const QString VMeasurements::TagVIT = QStringLiteral("vit");
|
||||
|
@ -174,7 +175,7 @@ bool VMeasurements::SaveDocument(const QString &fileName, QString &error)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VMeasurements::AddEmpty(const QString &name, const QString &formula)
|
||||
{
|
||||
const QDomElement element = MakeEmpty(name, formula);
|
||||
const QDomElement element = MakeEmpty(name, formula, MeasurementType::Measurement);
|
||||
|
||||
const QDomNodeList list = elementsByTagName(TagBodyMeasurements);
|
||||
list.at(0).appendChild(element);
|
||||
|
@ -183,7 +184,34 @@ void VMeasurements::AddEmpty(const QString &name, const QString &formula)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VMeasurements::AddEmptyAfter(const QString &after, const QString &name, const QString &formula)
|
||||
{
|
||||
const QDomElement element = MakeEmpty(name, formula);
|
||||
const QDomElement element = MakeEmpty(name, formula, MeasurementType::Measurement);
|
||||
const QDomElement sibling = FindM(after);
|
||||
|
||||
const QDomNodeList list = elementsByTagName(TagBodyMeasurements);
|
||||
|
||||
if (sibling.isNull())
|
||||
{
|
||||
list.at(0).appendChild(element);
|
||||
}
|
||||
else
|
||||
{
|
||||
list.at(0).insertAfter(element, sibling);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VMeasurements::AddSeparator(const QString &name)
|
||||
{
|
||||
const QDomElement element = MakeEmpty(name, QString(), MeasurementType::Separator);
|
||||
|
||||
const QDomNodeList list = elementsByTagName(TagBodyMeasurements);
|
||||
list.at(0).appendChild(element);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VMeasurements::AddSeparatorAfter(const QString &after, const QString &name)
|
||||
{
|
||||
const QDomElement element = MakeEmpty(name, QString(), MeasurementType::Separator);
|
||||
const QDomElement sibling = FindM(after);
|
||||
|
||||
const QDomNodeList list = elementsByTagName(TagBodyMeasurements);
|
||||
|
@ -307,94 +335,105 @@ void VMeasurements::ReadMeasurements(qreal baseA, qreal baseB, qreal baseC) cons
|
|||
|
||||
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);
|
||||
const MeasurementType varType = StringToMeasurementType(GetParametrString(dom, AttrType, strTypeMeasurement));
|
||||
|
||||
QSharedPointer<VMeasurement> meash;
|
||||
QSharedPointer<VMeasurement> tempMeash;
|
||||
if (type == MeasurementsType::Multisize)
|
||||
|
||||
if (varType != MeasurementType::Separator)
|
||||
{
|
||||
qreal base = GetParametrDouble(dom, AttrBase, 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);
|
||||
const QString fullName = GetParametrEmptyString(dom, AttrFullName);
|
||||
const bool specialUnits = GetParametrBool(dom, AttrSpecialUnits, falseStr);
|
||||
|
||||
qreal convertedBaseA = DimensionABase();
|
||||
qreal convertedBaseB = DimensionBBase();
|
||||
qreal convertedBaseC = DimensionCBase();
|
||||
qreal convertedStepA = DimensionAStep();
|
||||
qreal convertedStepB = DimensionBStep();
|
||||
qreal convertedStepC = DimensionCStep();
|
||||
|
||||
if (not specialUnits)
|
||||
if (type == MeasurementsType::Multisize)
|
||||
{
|
||||
base = UnitConvertor(base, Units(), *data->GetPatternUnit());
|
||||
shiftA = UnitConvertor(shiftA, Units(), *data->GetPatternUnit());
|
||||
shiftB = UnitConvertor(shiftB, Units(), *data->GetPatternUnit());
|
||||
shiftC = UnitConvertor(shiftC, Units(), *data->GetPatternUnit());
|
||||
qreal base = GetParametrDouble(dom, AttrBase, 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);
|
||||
|
||||
QMutableMapIterator<QString, qreal> iterator(corrections);
|
||||
while (iterator.hasNext())
|
||||
qreal convertedBaseA = DimensionABase();
|
||||
qreal convertedBaseB = DimensionBBase();
|
||||
qreal convertedBaseC = DimensionCBase();
|
||||
qreal convertedStepA = DimensionAStep();
|
||||
qreal convertedStepB = DimensionBStep();
|
||||
qreal convertedStepC = DimensionCStep();
|
||||
|
||||
if (not specialUnits)
|
||||
{
|
||||
iterator.next();
|
||||
iterator.setValue(UnitConvertor(iterator.value(), Units(), *data->GetPatternUnit()));
|
||||
base = UnitConvertor(base, Units(), *data->GetPatternUnit());
|
||||
shiftA = UnitConvertor(shiftA, Units(), *data->GetPatternUnit());
|
||||
shiftB = UnitConvertor(shiftB, Units(), *data->GetPatternUnit());
|
||||
shiftC = UnitConvertor(shiftC, Units(), *data->GetPatternUnit());
|
||||
|
||||
QMutableMapIterator<QString, qreal> iterator(corrections);
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
iterator.next();
|
||||
iterator.setValue(UnitConvertor(iterator.value(), Units(), *data->GetPatternUnit()));
|
||||
}
|
||||
|
||||
convertedBaseA = UnitConvertor(convertedBaseA, Units(), *data->GetPatternUnit());
|
||||
convertedBaseB = UnitConvertor(convertedBaseB, Units(), *data->GetPatternUnit());
|
||||
convertedBaseC = UnitConvertor(convertedBaseC, Units(), *data->GetPatternUnit());
|
||||
|
||||
convertedStepA = UnitConvertor(convertedStepA, Units(), *data->GetPatternUnit());
|
||||
convertedStepB = UnitConvertor(convertedStepB, Units(), *data->GetPatternUnit());
|
||||
convertedStepC = UnitConvertor(convertedStepC, Units(), *data->GetPatternUnit());
|
||||
}
|
||||
|
||||
convertedBaseA = UnitConvertor(convertedBaseA, Units(), *data->GetPatternUnit());
|
||||
convertedBaseB = UnitConvertor(convertedBaseB, Units(), *data->GetPatternUnit());
|
||||
convertedBaseC = UnitConvertor(convertedBaseC, Units(), *data->GetPatternUnit());
|
||||
meash = QSharedPointer<VMeasurement>::create(static_cast<quint32>(i), name,
|
||||
convertedBaseA, convertedBaseB, convertedBaseC, base);
|
||||
meash->SetBaseA(baseA);
|
||||
meash->SetBaseB(baseB);
|
||||
meash->SetBaseC(baseC);
|
||||
|
||||
convertedStepA = UnitConvertor(convertedStepA, Units(), *data->GetPatternUnit());
|
||||
convertedStepB = UnitConvertor(convertedStepB, Units(), *data->GetPatternUnit());
|
||||
convertedStepC = UnitConvertor(convertedStepC, Units(), *data->GetPatternUnit());
|
||||
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
|
||||
{
|
||||
const IMD dimension =
|
||||
VMeasurements::StrToIMD(GetParametrString(dom, AttrDimension, VMeasurements::IMDToStr(IMD::N)));
|
||||
const QString formula = GetParametrString(dom, AttrValue, QChar('0'));
|
||||
bool ok = false;
|
||||
qreal value = EvalFormula(tempData.data(), formula, &ok);
|
||||
|
||||
meash = QSharedPointer<VMeasurement>::create(static_cast<quint32>(i), name,
|
||||
convertedBaseA, convertedBaseB, convertedBaseC, base);
|
||||
meash->SetBaseA(baseA);
|
||||
meash->SetBaseB(baseB);
|
||||
meash->SetBaseC(baseC);
|
||||
tempMeash = QSharedPointer<VMeasurement>::create(tempData.data(), static_cast<quint32>(i), name, value,
|
||||
formula, ok);
|
||||
|
||||
meash->SetShiftA(shiftA);
|
||||
meash->SetShiftB(shiftB);
|
||||
meash->SetShiftC(shiftC);
|
||||
if (not specialUnits)
|
||||
{
|
||||
value = UnitConvertor(value, Units(), *data->GetPatternUnit());
|
||||
}
|
||||
|
||||
meash->SetStepA(convertedStepA);
|
||||
meash->SetStepB(convertedStepB);
|
||||
meash->SetStepC(convertedStepC);
|
||||
|
||||
meash->SetSpecialUnits(specialUnits);
|
||||
meash->SetCorrections(corrections);
|
||||
meash->SetGuiText(fullName);
|
||||
meash->SetDescription(description);
|
||||
meash = QSharedPointer<VMeasurement>::create(data, static_cast<quint32>(i), name, value, formula, ok);
|
||||
meash->SetGuiText(fullName);
|
||||
meash->SetDescription(description);
|
||||
meash->SetSpecialUnits(specialUnits);
|
||||
meash->SetDimension(dimension);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const IMD dimension =
|
||||
VMeasurements::StrToIMD(GetParametrString(dom, AttrDimension, VMeasurements::IMDToStr(IMD::N)));
|
||||
const QString formula = GetParametrString(dom, AttrValue, QChar('0'));
|
||||
bool ok = false;
|
||||
qreal value = EvalFormula(tempData.data(), formula, &ok);
|
||||
|
||||
tempMeash = QSharedPointer<VMeasurement>::create(tempData.data(), static_cast<quint32>(i), name, value,
|
||||
formula, ok);
|
||||
|
||||
if (not specialUnits)
|
||||
{
|
||||
value = UnitConvertor(value, Units(), *data->GetPatternUnit());
|
||||
}
|
||||
|
||||
meash = QSharedPointer<VMeasurement>::create(data, static_cast<quint32>(i), name, value, formula, ok);
|
||||
meash->SetGuiText(fullName);
|
||||
meash = QSharedPointer<VMeasurement>::create(static_cast<quint32>(i), name);
|
||||
meash->SetDescription(description);
|
||||
meash->SetSpecialUnits(specialUnits);
|
||||
meash->SetDimension(dimension);
|
||||
}
|
||||
|
||||
if (m_keepNames)
|
||||
{
|
||||
if (not tempData.isNull())
|
||||
if (not tempData.isNull() && not tempMeash.isNull())
|
||||
{
|
||||
tempData->AddUniqueVariable(tempMeash);
|
||||
}
|
||||
|
@ -402,7 +441,7 @@ void VMeasurements::ReadMeasurements(qreal baseA, qreal baseB, qreal baseC) cons
|
|||
}
|
||||
else
|
||||
{
|
||||
if (not tempData.isNull())
|
||||
if (not tempData.isNull() && not tempMeash.isNull())
|
||||
{
|
||||
tempData->AddVariable(tempMeash);
|
||||
}
|
||||
|
@ -1231,19 +1270,26 @@ qreal VMeasurements::UniqueTagAttr(const QString &tag, const QString &attr, qrea
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QDomElement VMeasurements::MakeEmpty(const QString &name, const QString &formula)
|
||||
QDomElement VMeasurements::MakeEmpty(const QString &name, const QString &formula, MeasurementType varType)
|
||||
{
|
||||
QDomElement element = createElement(TagMeasurement);
|
||||
|
||||
SetAttribute(element, AttrName, name);
|
||||
|
||||
if (type == MeasurementsType::Multisize)
|
||||
if (varType == MeasurementType::Measurement)
|
||||
{
|
||||
SetAttribute(element, AttrBase, QChar('0'));
|
||||
if (type == MeasurementsType::Multisize)
|
||||
{
|
||||
SetAttribute(element, AttrBase, QChar('0'));
|
||||
}
|
||||
else
|
||||
{
|
||||
SetAttribute(element, AttrValue, formula.isEmpty() ? QChar('0') : formula);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SetAttribute(element, AttrValue, formula.isEmpty() ? QChar('0') : formula);
|
||||
SetAttribute(element, AttrType, MeasurementTypeToString(varType));
|
||||
}
|
||||
|
||||
return element;
|
||||
|
|
|
@ -61,6 +61,8 @@ public:
|
|||
|
||||
void AddEmpty(const QString &name, const QString &formula = QString());
|
||||
void AddEmptyAfter(const QString &after, const QString &name, const QString &formula = QString());
|
||||
void AddSeparator(const QString &name);
|
||||
void AddSeparatorAfter(const QString &after, const QString &name);
|
||||
void Remove(const QString &name);
|
||||
void MoveTop(const QString &name);
|
||||
void MoveUp(const QString &name);
|
||||
|
@ -219,7 +221,7 @@ private:
|
|||
|
||||
qreal UniqueTagAttr(const QString &tag, const QString &attr, qreal defValue) const;
|
||||
|
||||
QDomElement MakeEmpty(const QString &name, const QString &formula);
|
||||
QDomElement MakeEmpty(const QString &name, const QString &formula, MeasurementType varType);
|
||||
QDomElement FindM(const QString &name) const;
|
||||
MeasurementsType ReadType() const;
|
||||
auto ReadUnits() const -> Unit;
|
||||
|
|
|
@ -87,7 +87,7 @@ VPatternRecipe::VPatternRecipe(VAbstractPattern *pattern, QObject *parent)
|
|||
|
||||
QDomElement recipeElement = createElement(QStringLiteral("recipe"));
|
||||
recipeElement.appendChild(createComment(FileComment()));
|
||||
SetAttribute(recipeElement, QStringLiteral("version"), QStringLiteral("1.3.0"));
|
||||
SetAttribute(recipeElement, QStringLiteral("version"), QStringLiteral("1.3.1"));
|
||||
|
||||
recipeElement.appendChild(Prerequisite());
|
||||
recipeElement.appendChild(Content());
|
||||
|
@ -135,7 +135,7 @@ QDomElement VPatternRecipe::Measurements()
|
|||
QDomElement measurements = createElement(QStringLiteral("measurements"));
|
||||
|
||||
VContainer data = m_pattern->GetCompleteData();
|
||||
QList<QSharedPointer<VMeasurement>> patternMeasurements = data.DataMeasurements().values();
|
||||
QList<QSharedPointer<VMeasurement>> patternMeasurements = data.DataMeasurementsWithSeparators().values();
|
||||
|
||||
// Resore order
|
||||
std::sort(patternMeasurements.begin(), patternMeasurements.end(),
|
||||
|
@ -160,20 +160,28 @@ QDomElement VPatternRecipe::Measurement(const QSharedPointer<VMeasurement> &m)
|
|||
*/
|
||||
QDomElement measurement = createElement(QStringLiteral("measurement"));
|
||||
|
||||
SetAttribute(measurement, QStringLiteral("description"), m->GetDescription());
|
||||
SetAttribute(measurement, QStringLiteral("fullName"), m->GetGuiText());
|
||||
SetAttribute(measurement, QStringLiteral("name"), m->GetName());
|
||||
SetAttribute(measurement, QStringLiteral("description"), m->GetDescription());
|
||||
|
||||
QString formula = m->GetFormula();
|
||||
if (not formula.isEmpty())
|
||||
if (m->GetType() != VarType::MeasurementSeparator)
|
||||
{
|
||||
SetAttribute(measurement, QStringLiteral("formula"), m->GetFormula());
|
||||
SetAttribute(measurement, QStringLiteral("fullName"), m->GetGuiText());
|
||||
|
||||
QString formula = m->GetFormula();
|
||||
if (not formula.isEmpty())
|
||||
{
|
||||
SetAttribute(measurement, QStringLiteral("formula"), m->GetFormula());
|
||||
}
|
||||
else
|
||||
{
|
||||
SetAttribute(measurement, QStringLiteral("formula"), *m->GetValue());
|
||||
}
|
||||
SetAttribute(measurement, QStringLiteral("value"), *m->GetValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
SetAttribute(measurement, QStringLiteral("formula"), *m->GetValue());
|
||||
SetAttribute(measurement, QStringLiteral("separator"), true);
|
||||
}
|
||||
SetAttribute(measurement, QStringLiteral("value"), *m->GetValue());
|
||||
|
||||
return measurement;
|
||||
}
|
||||
|
|
|
@ -473,6 +473,7 @@ const QString strIntersection2OnlyLeft = QStringLiteral("intersection2Left");
|
|||
const QString strIntersection2OnlyRight = QStringLiteral("intersection2Right");
|
||||
const QString strTypeIncrement = QStringLiteral("increment");
|
||||
const QString strTypeSeparator = QStringLiteral("separator");
|
||||
const QString strTypeMeasurement = QStringLiteral("measurement");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString PassmarkAngleTypeToString(PassmarkAngleType type)
|
||||
|
@ -744,6 +745,39 @@ IncrementType StringToIncrementType(const QString &value)
|
|||
return IncrementType::Increment;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString MeasurementTypeToString(MeasurementType type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case MeasurementType::Measurement:
|
||||
return strTypeMeasurement;
|
||||
case MeasurementType::Separator:
|
||||
return strTypeSeparator;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return strTypeIncrement;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
MeasurementType StringToMeasurementType(const QString &value)
|
||||
{
|
||||
const QStringList values { strTypeMeasurement, strTypeSeparator };
|
||||
|
||||
switch(values.indexOf(value))
|
||||
{
|
||||
case 0:
|
||||
return MeasurementType::Measurement;
|
||||
case 1:
|
||||
return MeasurementType::Separator;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return MeasurementType::Measurement;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QStringList SplitFilePaths(const QString &path)
|
||||
{
|
||||
|
|
|
@ -271,13 +271,18 @@ enum class Vis : ToolVisHolderType
|
|||
LAST_ONE_DO_NOT_USE //add new stuffs above this, this constant must be last and never used
|
||||
};
|
||||
|
||||
enum class VarType : qint8 { Measurement, Increment, IncrementSeparator, LineLength, CurveLength, CurveCLength,
|
||||
LineAngle, CurveAngle, ArcRadius, Unknown };
|
||||
enum class VarType : qint8 { Measurement, MeasurementSeparator, Increment, IncrementSeparator, LineLength, CurveLength,
|
||||
CurveCLength, LineAngle, CurveAngle, ArcRadius, Unknown };
|
||||
|
||||
enum class IncrementType : qint8 { Increment, Separator };
|
||||
|
||||
QString IncrementTypeToString(IncrementType type);
|
||||
IncrementType StringToIncrementType(const QString &value);
|
||||
auto IncrementTypeToString(IncrementType type) -> QString;
|
||||
auto StringToIncrementType(const QString &value) -> IncrementType;
|
||||
|
||||
enum class MeasurementType : qint8 { Measurement, Separator };
|
||||
|
||||
auto MeasurementTypeToString(MeasurementType type) -> QString;
|
||||
auto StringToMeasurementType(const QString &value) -> MeasurementType;
|
||||
|
||||
enum class IMD: qint8 // Individual measurement dimension
|
||||
{
|
||||
|
@ -465,6 +470,7 @@ extern const QString strIntersection2OnlyLeft;
|
|||
extern const QString strIntersection2OnlyRight;
|
||||
extern const QString strTypeIncrement;
|
||||
extern const QString strTypeSeparator;
|
||||
extern const QString strTypeMeasurement;
|
||||
|
||||
extern const QString unitMM;
|
||||
extern const QString unitCM;
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
{
|
||||
// When we create an increment in the dialog it will get neccesary data. Such data must be removed because will
|
||||
// confuse a user. Increment should not know nothing about internal variables.
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(VarType::Unknown) == 9, "Check that you used all types");
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(VarType::Unknown) == 10, "Check that you used all types");
|
||||
this->data->ClearVariables(QVector<VarType>({VarType::LineAngle,
|
||||
VarType::LineLength,
|
||||
VarType::CurveLength,
|
||||
|
|
|
@ -36,6 +36,15 @@
|
|||
#include "vvariable.h"
|
||||
#include "vmeasurement_p.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VMeasurement::VMeasurement(quint32 index, const QString &name)
|
||||
:VVariable(name),
|
||||
d(new VMeasurementData(index, MeasurementType::Separator))
|
||||
{
|
||||
SetType(VarType::MeasurementSeparator);
|
||||
VInternalVariable::SetValue(0);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VMeasurement create measurement for multisize table
|
||||
|
@ -185,6 +194,12 @@ bool VMeasurement::IsFormulaOk() const
|
|||
return d->formulaOk;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
MeasurementType VMeasurement::GetMeasurementType() const
|
||||
{
|
||||
return d->varType;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VMeasurement::IsNotUsed() const
|
||||
{
|
||||
|
|
|
@ -50,6 +50,7 @@ class VMeasurementData;
|
|||
class VMeasurement final :public VVariable
|
||||
{
|
||||
public:
|
||||
VMeasurement(quint32 index, const QString &name);
|
||||
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);
|
||||
|
@ -73,6 +74,8 @@ public:
|
|||
int Index() const;
|
||||
bool IsFormulaOk() const;
|
||||
|
||||
MeasurementType GetMeasurementType() const;
|
||||
|
||||
virtual bool IsNotUsed() const override;
|
||||
|
||||
virtual qreal GetValue() const override;
|
||||
|
|
|
@ -42,6 +42,11 @@ class VMeasurementData final : public QSharedData
|
|||
{
|
||||
public:
|
||||
|
||||
explicit VMeasurementData(quint32 index, MeasurementType varType)
|
||||
: index(index),
|
||||
varType(varType)
|
||||
{}
|
||||
|
||||
VMeasurementData(quint32 index, qreal baseA, qreal baseB, qreal baseC, qreal base)
|
||||
: index(index),
|
||||
shiftBase(base),
|
||||
|
@ -80,7 +85,8 @@ public:
|
|||
baseC(m.baseC),
|
||||
corrections(m.corrections),
|
||||
specialUnits(m.specialUnits),
|
||||
dimension(m.dimension)
|
||||
dimension(m.dimension),
|
||||
varType(m.varType)
|
||||
{}
|
||||
|
||||
virtual ~VMeasurementData();
|
||||
|
@ -115,6 +121,8 @@ public:
|
|||
|
||||
IMD dimension{IMD::N};
|
||||
|
||||
MeasurementType varType{MeasurementType::Measurement};
|
||||
|
||||
private:
|
||||
Q_DISABLE_ASSIGN(VMeasurementData)
|
||||
};
|
||||
|
|
|
@ -393,7 +393,7 @@ void VContainer::ClearForFullParse()
|
|||
|
||||
d->pieces->clear();
|
||||
d->piecePaths->clear();
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(VarType::Unknown) == 9, "Check that you used all types");
|
||||
Q_STATIC_ASSERT_X(static_cast<int>(VarType::Unknown) == 10, "Check that you used all types");
|
||||
ClearVariables(QVector<VarType>({VarType::Increment,
|
||||
VarType::IncrementSeparator,
|
||||
VarType::LineAngle,
|
||||
|
@ -578,6 +578,22 @@ const QMap<QString, QSharedPointer<VMeasurement> > VContainer::DataMeasurements(
|
|||
return DataVar<VMeasurement>(VarType::Measurement);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
const QMap<QString, QSharedPointer<VMeasurement> > VContainer::DataMeasurementsWithSeparators() const
|
||||
{
|
||||
QMap<QString, QSharedPointer<VMeasurement> > measurements = DataVar<VMeasurement>(VarType::Measurement);
|
||||
QMap<QString, QSharedPointer<VMeasurement> > separators = DataVar<VMeasurement>(VarType::MeasurementSeparator);
|
||||
|
||||
QMap<QString, QSharedPointer<VMeasurement>>::const_iterator i = separators.constBegin();
|
||||
while (i != separators.constEnd())
|
||||
{
|
||||
measurements.insert(i.key(), i.value());
|
||||
++i;
|
||||
}
|
||||
|
||||
return measurements;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
const QMap<QString, QSharedPointer<VIncrement> > VContainer::DataIncrements() const
|
||||
{
|
||||
|
|
|
@ -200,6 +200,7 @@ public:
|
|||
const QHash<QString, QSharedPointer<VInternalVariable>> *DataVariables() const;
|
||||
|
||||
const QMap<QString, QSharedPointer<VMeasurement> > DataMeasurements() const;
|
||||
const QMap<QString, QSharedPointer<VMeasurement> > DataMeasurementsWithSeparators() const;
|
||||
const QMap<QString, QSharedPointer<VIncrement> > DataIncrements() const;
|
||||
const QMap<QString, QSharedPointer<VIncrement> > DataIncrementsWithSeparators() const;
|
||||
const QMap<QString, QSharedPointer<VLengthLine> > DataLengthLines() const;
|
||||
|
|
Loading…
Reference in New Issue
Block a user