New measurement type separator.

This commit is contained in:
Roman Telezhynskyi 2022-02-05 15:00:22 +02:00
parent 427a70b541
commit 038fbb3540
25 changed files with 553 additions and 178 deletions

View File

@ -33,6 +33,7 @@
- Added scroll area to layout settings dialog. - Added scroll area to layout settings dialog.
- Allow size to have values from 1 to 100 if not a circumference. - Allow size to have values from 1 to 100 if not a circumference.
- Fix tool True darts notes. - Fix tool True darts notes.
- New measurement type separator.
# Valentina 0.7.49 July 1, 2021 # Valentina 0.7.49 July 1, 2021
- Fix crash. - Fix crash.

View File

@ -9,5 +9,7 @@
<file>tapeicon/24x24/padlock_locked.png</file> <file>tapeicon/24x24/padlock_locked.png</file>
<file>tapeicon/24x24/padlock_opened.png</file> <file>tapeicon/24x24/padlock_opened.png</file>
<file>tapeicon/24x24/mannequin.png</file> <file>tapeicon/24x24/mannequin.png</file>
<file>tapeicon/24x24/separator@2x.png</file>
<file>tapeicon/24x24/separator.png</file>
</qresource> </qresource>
</RCC> </RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 846 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

@ -1447,6 +1447,36 @@ void TMainWindow::AddKnown()
ui->tableWidget->repaint(); // Force repain to fix paint artifacts on Mac OS X 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() void TMainWindow::ImportFromPattern()
{ {
@ -1613,6 +1643,9 @@ void TMainWindow::ShowNewMData(bool fresh)
ShowMDiagram(meash->GetName()); 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. // Don't block all signal for QLineEdit. Need for correct handle with clear button.
disconnect(ui->lineEditName, &QLineEdit::textEdited, this, &TMainWindow::SaveMName); disconnect(ui->lineEditName, &QLineEdit::textEdited, this, &TMainWindow::SaveMName);
ui->plainTextEditDescription->blockSignals(true); ui->plainTextEditDescription->blockSignals(true);
@ -1633,6 +1666,9 @@ void TMainWindow::ShowNewMData(bool fresh)
connect(ui->lineEditName, &QLineEdit::textEdited, this, &TMainWindow::SaveMName); connect(ui->lineEditName, &QLineEdit::textEdited, this, &TMainWindow::SaveMName);
ui->plainTextEditDescription->blockSignals(false); ui->plainTextEditDescription->blockSignals(false);
ui->labelMUnits->setVisible(meash->GetType() == VarType::Measurement);
ui->comboBoxMUnits->setVisible(meash->GetType() == VarType::Measurement);
ui->comboBoxMUnits->blockSignals(true); ui->comboBoxMUnits->blockSignals(true);
ui->comboBoxMUnits->setCurrentIndex( ui->comboBoxMUnits->setCurrentIndex(
ui->comboBoxMUnits->findData(static_cast<int>(meash->IsSpecialUnits() ? MUnits::Degrees : MUnits::Table))); 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) 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->labelCalculatedValue->blockSignals(true);
ui->doubleSpinBoxBaseValue->blockSignals(true); ui->doubleSpinBoxBaseValue->blockSignals(true);
ui->doubleSpinBoxCorrection->blockSignals(true); ui->doubleSpinBoxCorrection->blockSignals(true);
@ -1683,6 +1745,17 @@ void TMainWindow::ShowNewMData(bool fresh)
} }
else 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, EvalFormula(meash->GetFormula(), false, meash->GetData(), ui->labelCalculatedValue,
meash->IsSpecialUnits()); meash->IsSpecialUnits());
@ -2408,6 +2481,7 @@ void TMainWindow::SetupMenu()
// Measurements // Measurements
connect(ui->actionAddCustom, &QAction::triggered, this, &TMainWindow::AddCustom); connect(ui->actionAddCustom, &QAction::triggered, this, &TMainWindow::AddCustom);
connect(ui->actionAddKnown, &QAction::triggered, this, &TMainWindow::AddKnown); 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->actionDatabase, &QAction::triggered, MApplication::VApp(), &MApplication::ShowDataBase);
connect(ui->actionImportFromPattern, &QAction::triggered, this, &TMainWindow::ImportFromPattern); connect(ui->actionImportFromPattern, &QAction::triggered, this, &TMainWindow::ImportFromPattern);
@ -2564,6 +2638,7 @@ void TMainWindow::InitWindow()
ui->actionAddCustom->setEnabled(true); ui->actionAddCustom->setEnabled(true);
ui->actionAddKnown->setEnabled(true); ui->actionAddKnown->setEnabled(true);
ui->actionAddSeparator->setEnabled(true);
ui->actionImportFromPattern->setEnabled(true); ui->actionImportFromPattern->setEnabled(true);
ui->actionSaveAs->setEnabled(true); ui->actionSaveAs->setEnabled(true);
@ -3026,13 +3101,25 @@ QTableWidgetItem *TMainWindow::AddCell(const QString &text, int row, int column,
return item; 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) void TMainWindow::RefreshData(bool freshCall)
{ {
QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
data->ClearUniqueNames(); data->ClearUniqueNames();
data->ClearVariables(VarType::Measurement); data->ClearVariables({VarType::Measurement, VarType::MeasurementSeparator});
m->ReadMeasurements(currentDimensionA, currentDimensionB, currentDimensionC); m->ReadMeasurements(currentDimensionA, currentDimensionB, currentDimensionC);
RefreshTable(freshCall); RefreshTable(freshCall);
@ -3057,6 +3144,8 @@ void TMainWindow::RefreshTable(bool freshCall)
const QSharedPointer<VMeasurement> &meash = iMap.value(); const QSharedPointer<VMeasurement> &meash = iMap.value();
currentRow++; currentRow++;
if (meash->GetType() == VarType::Measurement)
{
if (mType == MeasurementsType::Individual) if (mType == MeasurementsType::Individual)
{ {
QTableWidgetItem *item = AddCell(VAbstractApplication::VApp()->TrVars()->MToUser(meash->GetName()), QTableWidgetItem *item = AddCell(VAbstractApplication::VApp()->TrVars()->MToUser(meash->GetName()),
@ -3069,8 +3158,8 @@ void TMainWindow::RefreshTable(bool freshCall)
} }
else else
{ {
AddCell(VAbstractApplication::VApp()->TrVars()->GuiText(meash->GetName()), currentRow, ColumnFullName, AddCell(VAbstractApplication::VApp()->TrVars()->GuiText(meash->GetName()), currentRow,
Qt::AlignVCenter); ColumnFullName, Qt::AlignVCenter);
} }
QString calculatedValue; QString calculatedValue;
@ -3104,8 +3193,8 @@ void TMainWindow::RefreshTable(bool freshCall)
} }
else else
{ {
AddCell(VAbstractApplication::VApp()->TrVars()->GuiText(meash->GetName()), currentRow, ColumnFullName, AddCell(VAbstractApplication::VApp()->TrVars()->GuiText(meash->GetName()), currentRow,
Qt::AlignVCenter); ColumnFullName, Qt::AlignVCenter);
} }
QString calculatedValue; QString calculatedValue;
@ -3116,8 +3205,8 @@ void TMainWindow::RefreshTable(bool freshCall)
} }
else else
{ {
const qreal value = UnitConvertor(*data->DataVariables()->value(meash->GetName())->GetValue(), mUnit, const qreal value = UnitConvertor(*data->DataVariables()->value(meash->GetName())->GetValue(),
pUnit); mUnit, pUnit);
calculatedValue = locale().toString(value); calculatedValue = locale().toString(value);
} }
@ -3136,10 +3225,28 @@ void TMainWindow::RefreshTable(bool freshCall)
AddCell(locale().toString(meash->GetShiftC()), currentRow, ColumnShiftC, AddCell(locale().toString(meash->GetShiftC()), currentRow, ColumnShiftC,
Qt::AlignHCenter | Qt::AlignVCenter); Qt::AlignHCenter | Qt::AlignVCenter);
AddCell(locale().toString(meash->GetCorrection(currentDimensionA, currentDimensionB, currentDimensionC)), AddCell(locale()
.toString(meash->GetCorrection(currentDimensionA, currentDimensionB, currentDimensionC)),
currentRow, ColumnCorrection, Qt::AlignHCenter | Qt::AlignVCenter); 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 (mType == MeasurementsType::Individual)
{
ui->tableWidget->setSpan(currentRow, 1, 1, 3);
}
else if (mType == MeasurementsType::Multisize)
{
ui->tableWidget->setSpan(currentRow, 1, 1, 8);
}
}
}
if (freshCall) if (freshCall)
{ {
@ -4172,7 +4279,7 @@ QVector<qreal> TMainWindow::DimensionRestrictedValues(int index, const Measureme
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QMap<int, QSharedPointer<VMeasurement> > TMainWindow::OrderedMeasurments() const 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<int, QSharedPointer<VMeasurement> > orderedTable;
QMap<QString, QSharedPointer<VMeasurement> >::const_iterator iterMap; QMap<QString, QSharedPointer<VMeasurement> >::const_iterator iterMap;
for (iterMap = table.constBegin(); iterMap != table.constEnd(); ++iterMap) for (iterMap = table.constBegin(); iterMap != table.constEnd(); ++iterMap)

View File

@ -111,6 +111,7 @@ private slots:
void AddCustom(); void AddCustom();
void AddKnown(); void AddKnown();
void AddSeparator();
void ImportFromPattern(); void ImportFromPattern();
void DimensionABaseChanged(); void DimensionABaseChanged();
@ -210,6 +211,7 @@ private:
bool MaybeSave(); bool MaybeSave();
QTableWidgetItem *AddCell(const QString &text, int row, int column, int aligment, bool ok = true); 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 RefreshData(bool freshCall = false);
void RefreshTable(bool freshCall = false); void RefreshTable(bool freshCall = false);

View File

@ -128,7 +128,6 @@
<property name="font"> <property name="font">
<font> <font>
<pointsize>14</pointsize> <pointsize>14</pointsize>
<weight>75</weight>
<italic>false</italic> <italic>false</italic>
<bold>true</bold> <bold>true</bold>
</font> </font>
@ -161,7 +160,6 @@
<property name="font"> <property name="font">
<font> <font>
<pointsize>14</pointsize> <pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold> <bold>true</bold>
</font> </font>
</property> </property>
@ -196,7 +194,6 @@
<property name="font"> <property name="font">
<font> <font>
<pointsize>14</pointsize> <pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold> <bold>true</bold>
</font> </font>
</property> </property>
@ -228,7 +225,6 @@
<property name="font"> <property name="font">
<font> <font>
<pointsize>14</pointsize> <pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold> <bold>true</bold>
</font> </font>
</property> </property>
@ -1223,6 +1219,7 @@
<addaction name="actionSave"/> <addaction name="actionSave"/>
<addaction name="actionAddKnown"/> <addaction name="actionAddKnown"/>
<addaction name="actionAddCustom"/> <addaction name="actionAddCustom"/>
<addaction name="actionAddSeparator"/>
<addaction name="actionMeasurementDiagram"/> <addaction name="actionMeasurementDiagram"/>
</widget> </widget>
<widget class="QStatusBar" name="statusBar"/> <widget class="QStatusBar" name="statusBar"/>
@ -1618,6 +1615,18 @@
<enum>QAction::ApplicationSpecificRole</enum> <enum>QAction::ApplicationSpecificRole</enum>
</property> </property>
</action> </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> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>
<customwidgets> <customwidgets>

View File

@ -565,7 +565,7 @@ bool MainWindow::LoadMeasurements(const QString &path)
} }
ToolBarOption(); ToolBarOption();
SetDimensionBases(); SetDimensionBases();
pattern->ClearVariables(VarType::Measurement); pattern->ClearVariables({VarType::Measurement, VarType::MeasurementSeparator});
m->StoreNames(false); m->StoreNames(false);
m->ReadMeasurements(m_currentDimensionA, m_currentDimensionB, m_currentDimensionC); m->ReadMeasurements(m_currentDimensionA, m_currentDimensionB, m_currentDimensionC);
} }
@ -607,7 +607,7 @@ bool MainWindow::UpdateMeasurements(const QString &path, qreal baseA, qreal base
try try
{ {
pattern->ClearVariables(VarType::Measurement); pattern->ClearVariables({VarType::Measurement, VarType::MeasurementSeparator});
if (not m->Dimensions().isEmpty()) if (not m->Dimensions().isEmpty())
{ {

View File

@ -478,7 +478,7 @@ void VPattern::LiteParseIncrements()
data->ClearUniqueIncrementNames(); 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::Increment);
data->ClearVariables(VarType::IncrementSeparator); data->ClearVariables(VarType::IncrementSeparator);
@ -4370,7 +4370,7 @@ void VPattern::PrepareForParse(const Document &parse)
} }
else if (parse == Document::LiteParse || parse == Document::FullLiteParse) 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, QVector<VarType> types({VarType::LineAngle,
VarType::LineLength, VarType::LineLength,
VarType::CurveLength, VarType::CurveLength,

View File

@ -74,6 +74,7 @@
<file>schema/multisize_measurements/v0.4.4.xsd</file> <file>schema/multisize_measurements/v0.4.4.xsd</file>
<file>schema/multisize_measurements/v0.5.0.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.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.2.0.xsd</file>
<file>schema/individual_measurements/v0.3.0.xsd</file> <file>schema/individual_measurements/v0.3.0.xsd</file>
<file>schema/individual_measurements/v0.3.1.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.4.0.xsd</file>
<file>schema/individual_measurements/v0.5.0.xsd</file> <file>schema/individual_measurements/v0.5.0.xsd</file>
<file>schema/individual_measurements/v0.5.1.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/label_template/v1.0.0.xsd</file>
<file>schema/watermark/v1.0.0.xsd</file> <file>schema/watermark/v1.0.0.xsd</file>
<file>schema/watermark/v1.1.0.xsd</file> <file>schema/watermark/v1.1.0.xsd</file>

View 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}*/&amp;|!&lt;&gt;^&#10;\()\-+.,٫, ٬.=?:;'\&quot;]){1,1}([^\p{Zs}*/&amp;|!&lt;&gt;^&#10;\()\-+.,٫, ٬.=?:;\&quot;]){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>

View File

@ -73,13 +73,14 @@
</xs:element> </xs:element>
</xs:sequence> </xs:sequence>
<xs:attribute name="name" type="shortName" use="required"/> <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="shiftA" type="xs:double"/>
<xs:attribute name="shiftB" type="xs:double"/> <xs:attribute name="shiftB" type="xs:double"/>
<xs:attribute name="shiftC" type="xs:double"/> <xs:attribute name="shiftC" type="xs:double"/>
<xs:attribute name="full_name" type="xs:string"/> <xs:attribute name="full_name" type="xs:string"/>
<xs:attribute name="description" type="xs:string"/> <xs:attribute name="description" type="xs:string"/>
<xs:attribute name="specialUnits" type="xs:boolean"/> <xs:attribute name="specialUnits" type="xs:boolean"/>
<xs:attribute name="type" type="measurementType"/>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
</xs:sequence> </xs:sequence>
@ -134,4 +135,10 @@
<xs:maxInclusive value="80"/> <xs:maxInclusive value="80"/>
</xs:restriction> </xs:restriction>
</xs:simpleType> </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> </xs:schema>

View File

@ -54,8 +54,8 @@
*/ */
const QString VVITConverter::MeasurementMinVerStr = QStringLiteral("0.2.0"); const QString VVITConverter::MeasurementMinVerStr = QStringLiteral("0.2.0");
const QString VVITConverter::MeasurementMaxVerStr = QStringLiteral("0.5.1"); const QString VVITConverter::MeasurementMaxVerStr = QStringLiteral("0.5.2");
const QString VVITConverter::CurrentSchema = QStringLiteral("://schema/individual_measurements/v0.5.1.xsd"); const QString VVITConverter::CurrentSchema = QStringLiteral("://schema/individual_measurements/v0.5.2.xsd");
//VVITConverter::MeasurementMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! //VVITConverter::MeasurementMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
//VVITConverter::MeasurementMaxVer; // <== 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, 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, 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, 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)) if (schemas.contains(ver))
@ -137,6 +138,10 @@ void VVITConverter::ApplyPatches()
ValidateXML(XSDSchema(FormatVersion(0, 5, 1))); ValidateXML(XSDSchema(FormatVersion(0, 5, 1)));
Q_FALLTHROUGH(); Q_FALLTHROUGH();
case (FormatVersion(0, 5, 1)): case (FormatVersion(0, 5, 1)):
ToV0_5_2();
ValidateXML(XSDSchema(FormatVersion(0, 5, 2)));
Q_FALLTHROUGH();
case (FormatVersion(0, 5, 2)):
break; break;
default: default:
InvalidVersion(m_ver); InvalidVersion(m_ver);
@ -155,7 +160,7 @@ void VVITConverter::DowngradeToCurrentMaxVersion()
bool VVITConverter::IsReadOnly() const bool VVITConverter::IsReadOnly() const
{ {
// Check if attribute read-only was not changed in file format // 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."); "Check attribute read-only.");
// Possibly in future attribute read-only will change position etc. // Possibly in future attribute read-only will change position etc.
@ -444,3 +449,14 @@ void VVITConverter::ToV0_5_1()
SetVersion(QStringLiteral("0.5.1")); SetVersion(QStringLiteral("0.5.1"));
Save(); 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();
}

View File

@ -49,7 +49,7 @@ public:
static const QString MeasurementMaxVerStr; static const QString MeasurementMaxVerStr;
static const QString CurrentSchema; static const QString CurrentSchema;
static Q_DECL_CONSTEXPR const unsigned MeasurementMinVer = FormatVersion(0, 2, 0); 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: protected:
virtual unsigned MinVer() const override; virtual unsigned MinVer() const override;
@ -83,6 +83,7 @@ private:
void ToV0_4_0(); void ToV0_4_0();
void ToV0_5_0(); void ToV0_5_0();
void ToV0_5_1(); void ToV0_5_1();
void ToV0_5_2();
}; };
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -55,6 +55,7 @@
#include "../vpatterndb/measurements.h" #include "../vpatterndb/measurements.h"
#include "../vpatterndb/pmsystems.h" #include "../vpatterndb/pmsystems.h"
#include "../vmisc/projectversion.h" #include "../vmisc/projectversion.h"
#include "def.h"
const QString VMeasurements::TagVST = QStringLiteral("vst"); const QString VMeasurements::TagVST = QStringLiteral("vst");
const QString VMeasurements::TagVIT = QStringLiteral("vit"); 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) 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); const QDomNodeList list = elementsByTagName(TagBodyMeasurements);
list.at(0).appendChild(element); 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) 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 QDomElement sibling = FindM(after);
const QDomNodeList list = elementsByTagName(TagBodyMeasurements); const QDomNodeList list = elementsByTagName(TagBodyMeasurements);
@ -307,11 +335,16 @@ void VMeasurements::ReadMeasurements(qreal baseA, qreal baseB, qreal baseC) cons
const QString name = GetParametrString(dom, AttrName).simplified(); const QString name = GetParametrString(dom, AttrName).simplified();
const QString description = GetParametrEmptyString(dom, AttrDescription); const QString description = GetParametrEmptyString(dom, AttrDescription);
const QString fullName = GetParametrEmptyString(dom, AttrFullName); const MeasurementType varType = StringToMeasurementType(GetParametrString(dom, AttrType, strTypeMeasurement));
const bool specialUnits = GetParametrBool(dom, AttrSpecialUnits, falseStr);
QSharedPointer<VMeasurement> meash; QSharedPointer<VMeasurement> meash;
QSharedPointer<VMeasurement> tempMeash; QSharedPointer<VMeasurement> tempMeash;
if (varType != MeasurementType::Separator)
{
const QString fullName = GetParametrEmptyString(dom, AttrFullName);
const bool specialUnits = GetParametrBool(dom, AttrSpecialUnits, falseStr);
if (type == MeasurementsType::Multisize) if (type == MeasurementsType::Multisize)
{ {
qreal base = GetParametrDouble(dom, AttrBase, QChar('0')); qreal base = GetParametrDouble(dom, AttrBase, QChar('0'));
@ -391,10 +424,16 @@ void VMeasurements::ReadMeasurements(qreal baseA, qreal baseB, qreal baseC) cons
meash->SetSpecialUnits(specialUnits); meash->SetSpecialUnits(specialUnits);
meash->SetDimension(dimension); meash->SetDimension(dimension);
} }
}
else
{
meash = QSharedPointer<VMeasurement>::create(static_cast<quint32>(i), name);
meash->SetDescription(description);
}
if (m_keepNames) if (m_keepNames)
{ {
if (not tempData.isNull()) if (not tempData.isNull() && not tempMeash.isNull())
{ {
tempData->AddUniqueVariable(tempMeash); tempData->AddUniqueVariable(tempMeash);
} }
@ -402,7 +441,7 @@ void VMeasurements::ReadMeasurements(qreal baseA, qreal baseB, qreal baseC) cons
} }
else else
{ {
if (not tempData.isNull()) if (not tempData.isNull() && not tempMeash.isNull())
{ {
tempData->AddVariable(tempMeash); tempData->AddVariable(tempMeash);
} }
@ -1231,12 +1270,14 @@ 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); QDomElement element = createElement(TagMeasurement);
SetAttribute(element, AttrName, name); SetAttribute(element, AttrName, name);
if (varType == MeasurementType::Measurement)
{
if (type == MeasurementsType::Multisize) if (type == MeasurementsType::Multisize)
{ {
SetAttribute(element, AttrBase, QChar('0')); SetAttribute(element, AttrBase, QChar('0'));
@ -1245,6 +1286,11 @@ QDomElement VMeasurements::MakeEmpty(const QString &name, const QString &formula
{ {
SetAttribute(element, AttrValue, formula.isEmpty() ? QChar('0') : formula); SetAttribute(element, AttrValue, formula.isEmpty() ? QChar('0') : formula);
} }
}
else
{
SetAttribute(element, AttrType, MeasurementTypeToString(varType));
}
return element; return element;
} }

View File

@ -61,6 +61,8 @@ public:
void AddEmpty(const QString &name, const QString &formula = QString()); void AddEmpty(const QString &name, const QString &formula = QString());
void AddEmptyAfter(const QString &after, 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 Remove(const QString &name);
void MoveTop(const QString &name); void MoveTop(const QString &name);
void MoveUp(const QString &name); void MoveUp(const QString &name);
@ -219,7 +221,7 @@ private:
qreal UniqueTagAttr(const QString &tag, const QString &attr, qreal defValue) const; 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; QDomElement FindM(const QString &name) const;
MeasurementsType ReadType() const; MeasurementsType ReadType() const;
auto ReadUnits() const -> Unit; auto ReadUnits() const -> Unit;

View File

@ -87,7 +87,7 @@ VPatternRecipe::VPatternRecipe(VAbstractPattern *pattern, QObject *parent)
QDomElement recipeElement = createElement(QStringLiteral("recipe")); QDomElement recipeElement = createElement(QStringLiteral("recipe"));
recipeElement.appendChild(createComment(FileComment())); 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(Prerequisite());
recipeElement.appendChild(Content()); recipeElement.appendChild(Content());
@ -135,7 +135,7 @@ QDomElement VPatternRecipe::Measurements()
QDomElement measurements = createElement(QStringLiteral("measurements")); QDomElement measurements = createElement(QStringLiteral("measurements"));
VContainer data = m_pattern->GetCompleteData(); VContainer data = m_pattern->GetCompleteData();
QList<QSharedPointer<VMeasurement>> patternMeasurements = data.DataMeasurements().values(); QList<QSharedPointer<VMeasurement>> patternMeasurements = data.DataMeasurementsWithSeparators().values();
// Resore order // Resore order
std::sort(patternMeasurements.begin(), patternMeasurements.end(), std::sort(patternMeasurements.begin(), patternMeasurements.end(),
@ -160,9 +160,12 @@ QDomElement VPatternRecipe::Measurement(const QSharedPointer<VMeasurement> &m)
*/ */
QDomElement measurement = createElement(QStringLiteral("measurement")); 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("name"), m->GetName());
SetAttribute(measurement, QStringLiteral("description"), m->GetDescription());
if (m->GetType() != VarType::MeasurementSeparator)
{
SetAttribute(measurement, QStringLiteral("fullName"), m->GetGuiText());
QString formula = m->GetFormula(); QString formula = m->GetFormula();
if (not formula.isEmpty()) if (not formula.isEmpty())
@ -174,6 +177,11 @@ QDomElement VPatternRecipe::Measurement(const QSharedPointer<VMeasurement> &m)
SetAttribute(measurement, QStringLiteral("formula"), *m->GetValue()); SetAttribute(measurement, QStringLiteral("formula"), *m->GetValue());
} }
SetAttribute(measurement, QStringLiteral("value"), *m->GetValue()); SetAttribute(measurement, QStringLiteral("value"), *m->GetValue());
}
else
{
SetAttribute(measurement, QStringLiteral("separator"), true);
}
return measurement; return measurement;
} }

View File

@ -473,6 +473,7 @@ const QString strIntersection2OnlyLeft = QStringLiteral("intersection2Left");
const QString strIntersection2OnlyRight = QStringLiteral("intersection2Right"); const QString strIntersection2OnlyRight = QStringLiteral("intersection2Right");
const QString strTypeIncrement = QStringLiteral("increment"); const QString strTypeIncrement = QStringLiteral("increment");
const QString strTypeSeparator = QStringLiteral("separator"); const QString strTypeSeparator = QStringLiteral("separator");
const QString strTypeMeasurement = QStringLiteral("measurement");
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString PassmarkAngleTypeToString(PassmarkAngleType type) QString PassmarkAngleTypeToString(PassmarkAngleType type)
@ -744,6 +745,39 @@ IncrementType StringToIncrementType(const QString &value)
return IncrementType::Increment; 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) QStringList SplitFilePaths(const QString &path)
{ {

View File

@ -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 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, enum class VarType : qint8 { Measurement, MeasurementSeparator, Increment, IncrementSeparator, LineLength, CurveLength,
LineAngle, CurveAngle, ArcRadius, Unknown }; CurveCLength, LineAngle, CurveAngle, ArcRadius, Unknown };
enum class IncrementType : qint8 { Increment, Separator }; enum class IncrementType : qint8 { Increment, Separator };
QString IncrementTypeToString(IncrementType type); auto IncrementTypeToString(IncrementType type) -> QString;
IncrementType StringToIncrementType(const QString &value); 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 enum class IMD: qint8 // Individual measurement dimension
{ {
@ -465,6 +470,7 @@ extern const QString strIntersection2OnlyLeft;
extern const QString strIntersection2OnlyRight; extern const QString strIntersection2OnlyRight;
extern const QString strTypeIncrement; extern const QString strTypeIncrement;
extern const QString strTypeSeparator; extern const QString strTypeSeparator;
extern const QString strTypeMeasurement;
extern const QString unitMM; extern const QString unitMM;
extern const QString unitCM; extern const QString unitCM;

View File

@ -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 // 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. // 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, this->data->ClearVariables(QVector<VarType>({VarType::LineAngle,
VarType::LineLength, VarType::LineLength,
VarType::CurveLength, VarType::CurveLength,

View File

@ -36,6 +36,15 @@
#include "vvariable.h" #include "vvariable.h"
#include "vmeasurement_p.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 * @brief VMeasurement create measurement for multisize table
@ -185,6 +194,12 @@ bool VMeasurement::IsFormulaOk() const
return d->formulaOk; return d->formulaOk;
} }
//---------------------------------------------------------------------------------------------------------------------
MeasurementType VMeasurement::GetMeasurementType() const
{
return d->varType;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VMeasurement::IsNotUsed() const bool VMeasurement::IsNotUsed() const
{ {

View File

@ -50,6 +50,7 @@ class VMeasurementData;
class VMeasurement final :public VVariable class VMeasurement final :public VVariable
{ {
public: public:
VMeasurement(quint32 index, const QString &name);
VMeasurement(quint32 index, const QString &name, qreal baseA, qreal baseB, qreal baseC, qreal base); 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, VMeasurement(VContainer *data, quint32 index, const QString &name, const qreal &base, const QString &formula,
bool ok); bool ok);
@ -73,6 +74,8 @@ public:
int Index() const; int Index() const;
bool IsFormulaOk() const; bool IsFormulaOk() const;
MeasurementType GetMeasurementType() const;
virtual bool IsNotUsed() const override; virtual bool IsNotUsed() const override;
virtual qreal GetValue() const override; virtual qreal GetValue() const override;

View File

@ -42,6 +42,11 @@ class VMeasurementData final : public QSharedData
{ {
public: public:
explicit VMeasurementData(quint32 index, MeasurementType varType)
: index(index),
varType(varType)
{}
VMeasurementData(quint32 index, qreal baseA, qreal baseB, qreal baseC, qreal base) VMeasurementData(quint32 index, qreal baseA, qreal baseB, qreal baseC, qreal base)
: index(index), : index(index),
shiftBase(base), shiftBase(base),
@ -80,7 +85,8 @@ public:
baseC(m.baseC), baseC(m.baseC),
corrections(m.corrections), corrections(m.corrections),
specialUnits(m.specialUnits), specialUnits(m.specialUnits),
dimension(m.dimension) dimension(m.dimension),
varType(m.varType)
{} {}
virtual ~VMeasurementData(); virtual ~VMeasurementData();
@ -115,6 +121,8 @@ public:
IMD dimension{IMD::N}; IMD dimension{IMD::N};
MeasurementType varType{MeasurementType::Measurement};
private: private:
Q_DISABLE_ASSIGN(VMeasurementData) Q_DISABLE_ASSIGN(VMeasurementData)
}; };

View File

@ -393,7 +393,7 @@ void VContainer::ClearForFullParse()
d->pieces->clear(); d->pieces->clear();
d->piecePaths->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, ClearVariables(QVector<VarType>({VarType::Increment,
VarType::IncrementSeparator, VarType::IncrementSeparator,
VarType::LineAngle, VarType::LineAngle,
@ -578,6 +578,22 @@ const QMap<QString, QSharedPointer<VMeasurement> > VContainer::DataMeasurements(
return DataVar<VMeasurement>(VarType::Measurement); 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 const QMap<QString, QSharedPointer<VIncrement> > VContainer::DataIncrements() const
{ {

View File

@ -200,6 +200,7 @@ public:
const QHash<QString, QSharedPointer<VInternalVariable>> *DataVariables() const; const QHash<QString, QSharedPointer<VInternalVariable>> *DataVariables() const;
const QMap<QString, QSharedPointer<VMeasurement> > DataMeasurements() 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> > DataIncrements() const;
const QMap<QString, QSharedPointer<VIncrement> > DataIncrementsWithSeparators() const; const QMap<QString, QSharedPointer<VIncrement> > DataIncrementsWithSeparators() const;
const QMap<QString, QSharedPointer<VLengthLine> > DataLengthLines() const; const QMap<QString, QSharedPointer<VLengthLine> > DataLengthLines() const;