Unit type for increments.
This commit is contained in:
parent
f005b78ecc
commit
74da6b8e1e
|
@ -14,6 +14,7 @@
|
|||
- Fix updating dimension labels in Valentina app.
|
||||
- Fix menu on Mac OS X.
|
||||
- Add function's argument template with name in the Formula Wizard.
|
||||
- Unit type for increments.
|
||||
|
||||
# Valentina 0.7.51 April 18, 2022
|
||||
- Z value change for a layout piece.
|
||||
|
|
|
@ -4400,7 +4400,7 @@ void TMainWindow::InitMeasurementUnits()
|
|||
units = tr("Centimeters");
|
||||
break;
|
||||
default:
|
||||
units = "<Invalid>";
|
||||
units = QStringLiteral("<Invalid>");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,11 @@
|
|||
|
||||
#define DIALOG_MAX_FORMULA_HEIGHT 64
|
||||
|
||||
namespace
|
||||
{
|
||||
enum class IncrUnits : qint8 {Pattern, Degrees};
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief DialogIncrements create dialog
|
||||
|
@ -89,6 +94,20 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
|
|||
qCDebug(vDialog, "Showing variables.");
|
||||
ShowUnits();
|
||||
|
||||
InitIncrementUnits(ui->comboBoxIncrementUnits);
|
||||
InitIncrementUnits(ui->comboBoxPreviewCalculationUnits);
|
||||
|
||||
ui->comboBoxIncrementUnits->blockSignals(true);
|
||||
ui->comboBoxIncrementUnits->setCurrentIndex(-1);
|
||||
ui->comboBoxIncrementUnits->blockSignals(true);
|
||||
|
||||
ui->comboBoxPreviewCalculationUnits->blockSignals(true);
|
||||
ui->comboBoxPreviewCalculationUnits->setCurrentIndex(-1);
|
||||
ui->comboBoxPreviewCalculationUnits->blockSignals(true);
|
||||
|
||||
connect(ui->comboBoxIncrementUnits, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
||||
&DialogIncrements::SaveIncrUnits);
|
||||
|
||||
FillIncrements();
|
||||
FillPreviewCalculations();
|
||||
FillLengthsLines();
|
||||
|
@ -101,7 +120,7 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
|
|||
connect(this->doc, &VPattern::FullUpdateFromFile, this, &DialogIncrements::FullUpdateFromFile);
|
||||
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
auto validator = new QRegularExpressionValidator(QRegularExpression(QStringLiteral("^$|")+NameRegExp()), this);
|
||||
auto *validator = new QRegularExpressionValidator(QRegularExpression(QStringLiteral("^$|")+NameRegExp()), this);
|
||||
ui->lineEditName->setValidator(validator);
|
||||
ui->lineEditNamePC->setValidator(validator);
|
||||
|
||||
|
@ -330,51 +349,57 @@ QString DialogIncrements::ClearIncrementName(const QString &name) const
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool DialogIncrements::EvalIncrementFormula(const QString &formula, bool fromUser, VContainer *data, QLabel *label)
|
||||
auto DialogIncrements::EvalIncrementFormula(const QString &formula, bool fromUser, VContainer *data, QLabel *label,
|
||||
bool special) -> bool
|
||||
{
|
||||
const QString postfix =
|
||||
UnitsToStr(VAbstractValApplication::VApp()->patternUnits());//Show unit in dialog lable (cm, mm or inch)
|
||||
QString postfix;
|
||||
if (special)
|
||||
{
|
||||
postfix = degreeSymbol;
|
||||
}
|
||||
else
|
||||
{
|
||||
postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits());//Show unit in dialog lable (cm, mm or inch)
|
||||
}
|
||||
if (formula.isEmpty())
|
||||
{
|
||||
label->setText(tr("Error") + " (" + postfix + "). " + tr("Empty field."));
|
||||
label->setToolTip(tr("Empty field"));
|
||||
return false;
|
||||
}
|
||||
else
|
||||
|
||||
try
|
||||
{
|
||||
try
|
||||
QString f;
|
||||
// Replace line return character with spaces for calc if exist
|
||||
if (fromUser)
|
||||
{
|
||||
QString f;
|
||||
// Replace line return character with spaces for calc if exist
|
||||
if (fromUser)
|
||||
{
|
||||
f = VAbstractApplication::VApp()->TrVars()
|
||||
->FormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
|
||||
}
|
||||
else
|
||||
{
|
||||
f = formula;
|
||||
}
|
||||
QScopedPointer<Calculator> cal(new Calculator());
|
||||
const qreal result = cal->EvalFormula(data->DataVariables(), f);
|
||||
|
||||
if (qIsInf(result) || qIsNaN(result))
|
||||
{
|
||||
label->setText(tr("Error") + " (" + postfix + ").");
|
||||
label->setToolTip(tr("Invalid result. Value is infinite or NaN. Please, check your calculations."));
|
||||
return false;
|
||||
}
|
||||
|
||||
label->setText(VAbstractApplication::VApp()->LocaleToString(result) + QChar(QChar::Space) + postfix);
|
||||
label->setToolTip(tr("Value"));
|
||||
return true;
|
||||
f = VAbstractApplication::VApp()->TrVars()
|
||||
->FormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
|
||||
}
|
||||
catch (qmu::QmuParserError &e)
|
||||
else
|
||||
{
|
||||
label->setText(tr("Error") + " (" + postfix + "). " + tr("Parser error: %1").arg(e.GetMsg()));
|
||||
label->setToolTip(tr("Parser error: %1").arg(e.GetMsg()));
|
||||
f = formula;
|
||||
}
|
||||
QScopedPointer<Calculator> cal(new Calculator());
|
||||
const qreal result = cal->EvalFormula(data->DataVariables(), f);
|
||||
|
||||
if (qIsInf(result) || qIsNaN(result))
|
||||
{
|
||||
label->setText(tr("Error") + " (" + postfix + ").");
|
||||
label->setToolTip(tr("Invalid result. Value is infinite or NaN. Please, check your calculations."));
|
||||
return false;
|
||||
}
|
||||
|
||||
label->setText(VAbstractApplication::VApp()->LocaleToString(result) + QChar(QChar::Space) + postfix);
|
||||
label->setToolTip(tr("Value"));
|
||||
return true;
|
||||
}
|
||||
catch (qmu::QmuParserError &e)
|
||||
{
|
||||
label->setText(tr("Error") + " (" + postfix + "). " + tr("Parser error: %1").arg(e.GetMsg()));
|
||||
label->setToolTip(tr("Parser error: %1").arg(e.GetMsg()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -499,6 +524,10 @@ void DialogIncrements::EnableDetails(QTableWidget *table, bool enabled)
|
|||
ui->lineEditName->clear();
|
||||
ui->lineEditName->blockSignals(false);
|
||||
|
||||
ui->comboBoxIncrementUnits->blockSignals(true);
|
||||
ui->comboBoxIncrementUnits->setCurrentIndex(-1);
|
||||
ui->comboBoxIncrementUnits->blockSignals(false);
|
||||
|
||||
ui->plainTextEditDescription->blockSignals(true);
|
||||
ui->plainTextEditDescription->clear();
|
||||
ui->plainTextEditDescription->blockSignals(false);
|
||||
|
@ -517,6 +546,10 @@ void DialogIncrements::EnableDetails(QTableWidget *table, bool enabled)
|
|||
ui->lineEditNamePC->clear();
|
||||
ui->lineEditNamePC->blockSignals(false);
|
||||
|
||||
ui->comboBoxPreviewCalculationUnits->blockSignals(true);
|
||||
ui->comboBoxPreviewCalculationUnits->setCurrentIndex(-1);
|
||||
ui->comboBoxPreviewCalculationUnits->blockSignals(false);
|
||||
|
||||
ui->plainTextEditDescriptionPC->blockSignals(true);
|
||||
ui->plainTextEditDescriptionPC->clear();
|
||||
ui->plainTextEditDescriptionPC->blockSignals(false);
|
||||
|
@ -536,6 +569,7 @@ void DialogIncrements::EnableDetails(QTableWidget *table, bool enabled)
|
|||
ui->pushButtonGrow->setEnabled(enabled);
|
||||
ui->toolButtonExpr->setEnabled(enabled);
|
||||
ui->lineEditName->setEnabled(enabled);
|
||||
ui->comboBoxIncrementUnits->setEnabled(enabled);
|
||||
ui->plainTextEditDescription->setEnabled(enabled);
|
||||
ui->plainTextEditFormula->setEnabled(enabled);
|
||||
}
|
||||
|
@ -544,6 +578,7 @@ void DialogIncrements::EnableDetails(QTableWidget *table, bool enabled)
|
|||
ui->pushButtonGrowPC->setEnabled(enabled);
|
||||
ui->toolButtonExprPC->setEnabled(enabled);
|
||||
ui->lineEditNamePC->setEnabled(enabled);
|
||||
ui->comboBoxPreviewCalculationUnits->setEnabled(enabled);
|
||||
ui->plainTextEditDescriptionPC->setEnabled(enabled);
|
||||
ui->plainTextEditFormulaPC->setEnabled(enabled);
|
||||
}
|
||||
|
@ -563,6 +598,8 @@ void DialogIncrements::EnableDetails(QTableWidget *table, bool enabled)
|
|||
ui->plainTextEditFormula->setVisible(not isSeparator);
|
||||
ui->pushButtonGrow->setVisible(not isSeparator);
|
||||
ui->toolButtonExpr->setVisible(not isSeparator);
|
||||
ui->labelIncrementUnits->setVisible(not isSeparator);
|
||||
ui->comboBoxIncrementUnits->setVisible(not isSeparator);
|
||||
}
|
||||
else if (table == ui->tableWidgetPC)
|
||||
{
|
||||
|
@ -572,6 +609,8 @@ void DialogIncrements::EnableDetails(QTableWidget *table, bool enabled)
|
|||
ui->plainTextEditFormulaPC->setVisible(not isSeparator);
|
||||
ui->pushButtonGrowPC->setVisible(not isSeparator);
|
||||
ui->toolButtonExprPC->setVisible(not isSeparator);
|
||||
ui->labelPreviewCalculationUnits->setVisible(not isSeparator);
|
||||
ui->comboBoxPreviewCalculationUnits->setVisible(not isSeparator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -652,6 +691,7 @@ void DialogIncrements::ShowTableIncrementDetails(QTableWidget *table)
|
|||
QPlainTextEdit *plainTextEditDescription = nullptr;
|
||||
QPlainTextEdit *plainTextEditFormula = nullptr;
|
||||
QLabel *labelCalculatedValue = nullptr;
|
||||
QComboBox *comboboxUnits = nullptr;
|
||||
|
||||
if (table == ui->tableWidgetIncrement)
|
||||
{
|
||||
|
@ -659,6 +699,7 @@ void DialogIncrements::ShowTableIncrementDetails(QTableWidget *table)
|
|||
plainTextEditDescription = ui->plainTextEditDescription;
|
||||
plainTextEditFormula = ui->plainTextEditFormula;
|
||||
labelCalculatedValue = ui->labelCalculatedValue;
|
||||
comboboxUnits = ui->comboBoxIncrementUnits;
|
||||
}
|
||||
else if (table == ui->tableWidgetPC)
|
||||
{
|
||||
|
@ -666,6 +707,7 @@ void DialogIncrements::ShowTableIncrementDetails(QTableWidget *table)
|
|||
plainTextEditDescription = ui->plainTextEditDescriptionPC;
|
||||
plainTextEditFormula = ui->plainTextEditFormulaPC;
|
||||
labelCalculatedValue = ui->labelCalculatedValuePC;
|
||||
comboboxUnits = ui->comboBoxPreviewCalculationUnits;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -695,11 +737,16 @@ void DialogIncrements::ShowTableIncrementDetails(QTableWidget *table)
|
|||
lineEditName->setText(ClearIncrementName(incr->GetName()));
|
||||
lineEditName->blockSignals(false);
|
||||
|
||||
comboboxUnits->blockSignals(true);
|
||||
comboboxUnits->setCurrentIndex(comboboxUnits->findData(
|
||||
static_cast<int>(incr->IsSpecialUnits() ? IncrUnits::Degrees : IncrUnits::Pattern)));
|
||||
comboboxUnits->blockSignals(false);
|
||||
|
||||
plainTextEditDescription->blockSignals(true);
|
||||
plainTextEditDescription->setPlainText(incr->GetDescription());
|
||||
plainTextEditDescription->blockSignals(false);
|
||||
|
||||
EvalIncrementFormula(incr->GetFormula(), false, incr->GetData(), labelCalculatedValue);
|
||||
EvalIncrementFormula(incr->GetFormula(), false, incr->GetData(), labelCalculatedValue, incr->IsSpecialUnits());
|
||||
plainTextEditFormula->blockSignals(true);
|
||||
|
||||
QString formula =
|
||||
|
@ -1124,6 +1171,49 @@ void DialogIncrements::UpdateSearchControlsTooltips()
|
|||
UpdateToolTip(ui->toolButtonFindNextPC);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogIncrements::InitIncrementUnits(QComboBox *combo)
|
||||
{
|
||||
SCASSERT(combo != nullptr)
|
||||
|
||||
combo->blockSignals(true);
|
||||
|
||||
int current = -1;
|
||||
if (combo->currentIndex() != -1)
|
||||
{
|
||||
current = combo->currentData().toInt();
|
||||
}
|
||||
|
||||
QString units;
|
||||
switch (VAbstractValApplication::VApp()->patternUnits())
|
||||
{
|
||||
case Unit::Mm:
|
||||
units = tr("Millimeters");
|
||||
break;
|
||||
case Unit::Inch:
|
||||
units = tr("Inches");
|
||||
break;
|
||||
case Unit::Cm:
|
||||
units = tr("Centimeters");
|
||||
break;
|
||||
default:
|
||||
units = QStringLiteral("<Invalid>");
|
||||
break;
|
||||
}
|
||||
|
||||
combo->clear();
|
||||
combo->addItem(units, QVariant(static_cast<int>(IncrUnits::Pattern)));
|
||||
combo->addItem(tr("Degrees"), QVariant(static_cast<int>(IncrUnits::Degrees)));
|
||||
|
||||
int i = combo->findData(current);
|
||||
if (i != -1)
|
||||
{
|
||||
combo->setCurrentIndex(i);
|
||||
}
|
||||
|
||||
combo->blockSignals(false);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief FullUpdateFromFile update information in tables form file
|
||||
|
@ -1222,9 +1312,13 @@ void DialogIncrements::FillIncrementsTable(QTableWidget *table,
|
|||
if (incr->GetType() == VarType::Increment)
|
||||
{
|
||||
AddCell(table, incr->GetName(), currentRow, 0, Qt::AlignVCenter); // name
|
||||
AddCell(table, VAbstractApplication::VApp()->
|
||||
LocaleToString(*incr->GetValue()), currentRow, 1, Qt::AlignCenter,
|
||||
incr->IsFormulaOk()); // calculated value
|
||||
|
||||
QString calculatedValue = VAbstractApplication::VApp()->LocaleToString(*incr->GetValue());
|
||||
if (incr->IsSpecialUnits())
|
||||
{
|
||||
calculatedValue = calculatedValue + degreeSymbol;
|
||||
}
|
||||
AddCell(table, calculatedValue, currentRow, 1, Qt::AlignCenter, incr->IsFormulaOk()); // calculated value
|
||||
|
||||
QString formula =
|
||||
VTranslateVars::TryFormulaToUser(incr->GetFormula(),
|
||||
|
@ -1270,7 +1364,7 @@ void DialogIncrements::AddSeparator()
|
|||
*/
|
||||
void DialogIncrements::RemoveIncrement()
|
||||
{
|
||||
QToolButton *button = qobject_cast<QToolButton *>(sender());
|
||||
auto *button = qobject_cast<QToolButton *>(sender());
|
||||
|
||||
QTableWidget *table = nullptr;
|
||||
|
||||
|
@ -1469,10 +1563,50 @@ void DialogIncrements::SaveIncrName(const QString &text)
|
|||
table->blockSignals(false);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogIncrements::SaveIncrUnits()
|
||||
{
|
||||
auto *combo = qobject_cast<QComboBox *>(sender());
|
||||
|
||||
QTableWidget *table = nullptr;
|
||||
|
||||
if (combo == ui->comboBoxIncrementUnits)
|
||||
{
|
||||
table = ui->tableWidgetIncrement;
|
||||
}
|
||||
else if (combo == ui->comboBoxPreviewCalculationUnits)
|
||||
{
|
||||
table = ui->tableWidgetPC;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const int row = table->currentRow();
|
||||
|
||||
if (row == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const QTableWidgetItem *nameField = table->item(row, 0);
|
||||
|
||||
const IncrUnits units = static_cast<IncrUnits>(combo->currentData().toInt());
|
||||
doc->SetIncrementSpecialUnits(nameField->text(), units == IncrUnits::Degrees);
|
||||
LocalUpdateTree();
|
||||
|
||||
table->blockSignals(true);
|
||||
table->selectRow(row);
|
||||
table->blockSignals(false);
|
||||
|
||||
ShowTableIncrementDetails(table);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogIncrements::SaveIncrDescription()
|
||||
{
|
||||
QPlainTextEdit *textEdit = qobject_cast<QPlainTextEdit *>(sender());
|
||||
auto *textEdit = qobject_cast<QPlainTextEdit *>(sender());
|
||||
|
||||
QTableWidget *table = nullptr;
|
||||
|
||||
|
@ -1541,32 +1675,46 @@ void DialogIncrements::SaveIncrFormula()
|
|||
const QTableWidgetItem *nameField = table->item(row, 0);
|
||||
|
||||
QString text = textEdit->toPlainText();
|
||||
QSharedPointer<VIncrement> incr = data->GetVariable<VIncrement>(nameField->text());
|
||||
|
||||
QTableWidgetItem *formulaField = table->item(row, 2);
|
||||
if (formulaField->text() == text)
|
||||
{
|
||||
QTableWidgetItem *result = table->item(row, 1);
|
||||
//Show unit in dialog lable (cm, mm or inch)
|
||||
const QString postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits());
|
||||
labelCalculatedValue->setText(result->text() + QChar(QChar::Space) +postfix);
|
||||
if (incr->IsSpecialUnits())
|
||||
{
|
||||
labelCalculatedValue->setText(result->text() + QChar(QChar::Space) + degreeSymbol);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Show unit in dialog lable (cm, mm or inch)
|
||||
const QString postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits());
|
||||
labelCalculatedValue->setText(result->text() + QChar(QChar::Space) +postfix);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (text.isEmpty())
|
||||
{
|
||||
//Show unit in dialog lable (cm, mm or inch)
|
||||
const QString postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits());
|
||||
labelCalculatedValue->setText(tr("Error") + " (" + postfix + "). " + tr("Empty field."));
|
||||
if (incr->IsSpecialUnits())
|
||||
{
|
||||
labelCalculatedValue->setText(tr("Error") + " (" + degreeSymbol + "). " + tr("Empty field."));
|
||||
}
|
||||
else
|
||||
{
|
||||
//Show unit in dialog lable (cm, mm or inch)
|
||||
const QString postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits());
|
||||
labelCalculatedValue->setText(tr("Error") + " (" + postfix + "). " + tr("Empty field."));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
QSharedPointer<VIncrement> incr = data->GetVariable<VIncrement>(nameField->text());
|
||||
if (incr->GetIncrementType() == IncrementType::Separator)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (not EvalIncrementFormula(text, true, incr->GetData(), labelCalculatedValue))
|
||||
if (not EvalIncrementFormula(text, true, incr->GetData(), labelCalculatedValue, incr->IsSpecialUnits()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -75,6 +75,7 @@ private slots:
|
|||
void MoveUp();
|
||||
void MoveDown();
|
||||
void SaveIncrName(const QString &text);
|
||||
void SaveIncrUnits();
|
||||
void SaveIncrDescription();
|
||||
void SaveIncrFormula();
|
||||
void DeployFormula();
|
||||
|
@ -136,7 +137,7 @@ private:
|
|||
QString GetCustomName() const;
|
||||
QString ClearIncrementName(const QString &name) const;
|
||||
|
||||
bool EvalIncrementFormula(const QString &formula, bool fromUser, VContainer *data, QLabel *label);
|
||||
bool EvalIncrementFormula(const QString &formula, bool fromUser, VContainer *data, QLabel *label, bool special);
|
||||
void Controls(QTableWidget *table);
|
||||
void EnableDetails(QTableWidget *table, bool enabled);
|
||||
|
||||
|
@ -158,6 +159,7 @@ private:
|
|||
void SaveIncrementsSearchRequest();
|
||||
void SavePreviewCalculationsSearchRequest();
|
||||
void UpdateSearchControlsTooltips();
|
||||
void InitIncrementUnits(QComboBox *combo);
|
||||
};
|
||||
|
||||
#endif // DIALOGINCREMENTS_H
|
||||
|
|
|
@ -119,7 +119,6 @@
|
|||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
<weight>75</weight>
|
||||
<italic>false</italic>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
|
@ -152,7 +151,6 @@
|
|||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
|
@ -187,7 +185,6 @@
|
|||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
|
@ -219,7 +216,6 @@
|
|||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
|
@ -508,27 +504,34 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="labelIncrementUnits">
|
||||
<property name="text">
|
||||
<string>Units:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="labelCalculated">
|
||||
<property name="text">
|
||||
<string>Calculated value:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<item row="7" column="1">
|
||||
<widget class="QLabel" name="labelCalculatedValue">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="labelFormula">
|
||||
<property name="text">
|
||||
<string>Formula:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<item row="8" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayoutValue">
|
||||
<item>
|
||||
<widget class="VPlainTextEdit" name="plainTextEditFormula">
|
||||
|
@ -624,14 +627,14 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Description:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<item row="10" column="1">
|
||||
<widget class="VPlainTextEdit" name="plainTextEditDescription">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
|
@ -650,7 +653,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<item row="13" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
|
@ -677,6 +680,16 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="comboBoxIncrementUnits">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
|
@ -761,7 +774,6 @@
|
|||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
<weight>75</weight>
|
||||
<italic>false</italic>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
|
@ -794,7 +806,6 @@
|
|||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
|
@ -829,7 +840,6 @@
|
|||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
|
@ -861,7 +871,6 @@
|
|||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
|
@ -1149,28 +1158,28 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="labelCalculatedPC">
|
||||
<property name="text">
|
||||
<string>Calculated value:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<item row="5" column="1">
|
||||
<widget class="QLabel" name="labelCalculatedValuePC">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="labelFormulaPC">
|
||||
<property name="text">
|
||||
<string>Formula:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<item row="7" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayoutValue_2">
|
||||
<item>
|
||||
<widget class="VPlainTextEdit" name="plainTextEditFormulaPC">
|
||||
|
@ -1266,14 +1275,14 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Description:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<item row="9" column="1">
|
||||
<widget class="VPlainTextEdit" name="plainTextEditDescriptionPC">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
|
@ -1292,7 +1301,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<item row="12" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_6">
|
||||
|
@ -1319,6 +1328,20 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="labelPreviewCalculationUnits">
|
||||
<property name="text">
|
||||
<string>Units:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="comboBoxPreviewCalculationUnits">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
|
@ -1585,7 +1608,7 @@
|
|||
<customwidget>
|
||||
<class>VPlainTextEdit</class>
|
||||
<extends>QPlainTextEdit</extends>
|
||||
<header location="global">vplaintextedit.h</header>
|
||||
<header>vplaintextedit.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
|
|
|
@ -4038,14 +4038,16 @@ void VPattern::ParseIncrementsElement(const QDomNode &node, const Document &pars
|
|||
strTypeIncrement));
|
||||
const QString formula = (type == IncrementType::Separator) ?
|
||||
QChar('0') : GetParametrString(domElement, AttrFormula, QChar('0'));
|
||||
const bool specialUnits = GetParametrBool(domElement, AttrSpecialUnits, falseStr);
|
||||
|
||||
bool ok = false;
|
||||
const qreal value = EvalFormula(data, formula, &ok);
|
||||
|
||||
VIncrement *increment = new VIncrement(data, name, type);
|
||||
auto *increment = new VIncrement(data, name, type);
|
||||
increment->SetIndex(static_cast<quint32>(index++));
|
||||
increment->SetFormula(value, formula, ok);
|
||||
increment->SetDescription(desc);
|
||||
increment->SetSpecialUnits(specialUnits);
|
||||
increment->SetPreviewCalculation(node.toElement().tagName() == TagPreviewCalculations);
|
||||
data->AddUniqueVariable(increment);
|
||||
}
|
||||
|
@ -4150,6 +4152,21 @@ void VPattern::SetIncrementDescription(const QString &name, const QString &text)
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPattern::SetIncrementSpecialUnits(const QString &name, bool special)
|
||||
{
|
||||
QDomElement node = FindIncrement(name);
|
||||
if (not node.isNull())
|
||||
{
|
||||
SetAttributeOrRemoveIf<bool>(node, AttrSpecialUnits, special, [](bool special) noexcept {return not special;});
|
||||
emit patternChanged(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning() << tr("Can't find increment '%1'").arg(name);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPattern::ReplaceNameInFormula(QVector<VFormulaField> &expressions, const QString &name, const QString &newName)
|
||||
{
|
||||
|
|
|
@ -93,6 +93,7 @@ public:
|
|||
void SetIncrementName(const QString &name, const QString &text);
|
||||
void SetIncrementFormula(const QString &name, const QString &text);
|
||||
void SetIncrementDescription(const QString &name, const QString &text);
|
||||
void SetIncrementSpecialUnits(const QString &name, bool special);
|
||||
|
||||
void ReplaceNameInFormula(QVector<VFormulaField> &expressions, const QString &name, const QString &newName);
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@
|
|||
<file>schema/pattern/v0.8.12.xsd</file>
|
||||
<file>schema/pattern/v0.8.13.xsd</file>
|
||||
<file>schema/pattern/v0.9.0.xsd</file>
|
||||
<file>schema/pattern/v0.9.1.xsd</file>
|
||||
<file>schema/multisize_measurements/v0.3.0.xsd</file>
|
||||
<file>schema/multisize_measurements/v0.4.0.xsd</file>
|
||||
<file>schema/multisize_measurements/v0.4.1.xsd</file>
|
||||
|
|
1166
src/libs/ifc/schema/pattern/v0.9.1.xsd
Normal file
1166
src/libs/ifc/schema/pattern/v0.9.1.xsd
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -150,8 +150,9 @@ const QString VAbstractPattern::AttrImageId = QStringLiteral("imageId"
|
|||
|
||||
const QString VAbstractPattern::AttrContentType = QStringLiteral("contentType");
|
||||
|
||||
const QString VAbstractPattern::AttrFormula = QStringLiteral("formula");
|
||||
const QString VAbstractPattern::AttrDescription = QStringLiteral("description");
|
||||
const QString VAbstractPattern::AttrFormula = QStringLiteral("formula");
|
||||
const QString VAbstractPattern::AttrDescription = QStringLiteral("description");
|
||||
const QString VAbstractPattern::AttrSpecialUnits = QStringLiteral("specialUnits");
|
||||
|
||||
const QString VAbstractPattern::NodeArc = QStringLiteral("NodeArc");
|
||||
const QString VAbstractPattern::NodeElArc = QStringLiteral("NodeElArc");
|
||||
|
|
|
@ -337,6 +337,7 @@ public:
|
|||
|
||||
static const QString AttrFormula;
|
||||
static const QString AttrDescription;
|
||||
static const QString AttrSpecialUnits;
|
||||
|
||||
static const QString NodeArc;
|
||||
static const QString NodeElArc;
|
||||
|
|
|
@ -60,8 +60,8 @@ class QDomElement;
|
|||
*/
|
||||
|
||||
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.4");
|
||||
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.9.0");
|
||||
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.9.0.xsd");
|
||||
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.9.1");
|
||||
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.9.1.xsd");
|
||||
|
||||
//VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||
//VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||
|
@ -265,7 +265,8 @@ auto VPatternConverter::XSDSchema(unsigned ver) const -> QString
|
|||
std::make_pair(FormatVersion(0, 8, 11), QStringLiteral("://schema/pattern/v0.8.11.xsd")),
|
||||
std::make_pair(FormatVersion(0, 8, 12), QStringLiteral("://schema/pattern/v0.8.12.xsd")),
|
||||
std::make_pair(FormatVersion(0, 8, 13), QStringLiteral("://schema/pattern/v0.8.13.xsd")),
|
||||
std::make_pair(FormatVersion(0, 9, 0), CurrentSchema)
|
||||
std::make_pair(FormatVersion(0, 9, 0), QStringLiteral("://schema/pattern/v0.9.0.xsd")),
|
||||
std::make_pair(FormatVersion(0, 9, 1), CurrentSchema)
|
||||
};
|
||||
|
||||
if (schemas.contains(ver))
|
||||
|
@ -367,9 +368,12 @@ void VPatternConverter::ApplyPatches()
|
|||
case (FormatVersion(0, 8, 12)):
|
||||
case (FormatVersion(0, 8, 13)):
|
||||
ToV0_9_0();
|
||||
ValidateXML(CurrentSchema);
|
||||
Q_FALLTHROUGH();
|
||||
case (FormatVersion(0, 9, 0)):
|
||||
ToV0_9_1();
|
||||
ValidateXML(CurrentSchema);
|
||||
Q_FALLTHROUGH();
|
||||
case (FormatVersion(0, 9, 1)):
|
||||
break;
|
||||
default:
|
||||
InvalidVersion(m_ver);
|
||||
|
@ -387,7 +391,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion()
|
|||
bool VPatternConverter::IsReadOnly() const
|
||||
{
|
||||
// Check if attribute readOnly was not changed in file format
|
||||
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FormatVersion(0, 9, 0),
|
||||
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FormatVersion(0, 9, 1),
|
||||
"Check attribute readOnly.");
|
||||
|
||||
// Possibly in future attribute readOnly will change position etc.
|
||||
|
@ -546,6 +550,17 @@ void VPatternConverter::ToV0_9_0()
|
|||
Save();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPatternConverter::ToV0_9_1()
|
||||
{
|
||||
// TODO. Delete if minimal supported version is 0.9.1
|
||||
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 9, 1),
|
||||
"Time to refactor the code.");
|
||||
|
||||
SetVersion(QStringLiteral("0.9.1"));
|
||||
Save();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPatternConverter::TagUnitToV0_2_0()
|
||||
{
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
static const QString PatternMaxVerStr;
|
||||
static const QString CurrentSchema;
|
||||
static Q_DECL_CONSTEXPR const unsigned PatternMinVer = FormatVersion(0, 1, 4);
|
||||
static Q_DECL_CONSTEXPR const unsigned PatternMaxVer = FormatVersion(0, 9, 0);
|
||||
static Q_DECL_CONSTEXPR const unsigned PatternMaxVer = FormatVersion(0, 9, 1);
|
||||
|
||||
protected:
|
||||
void Save() override;
|
||||
|
@ -85,6 +85,7 @@ private:
|
|||
void ToV0_6_2();
|
||||
void ToV0_8_8();
|
||||
void ToV0_9_0();
|
||||
void ToV0_9_1();
|
||||
|
||||
void TagUnitToV0_2_0();
|
||||
void TagIncrementToV0_2_0();
|
||||
|
|
|
@ -149,3 +149,15 @@ void VIncrement::SetPreviewCalculation(bool value)
|
|||
{
|
||||
d->previewCalculation = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VIncrement::IsSpecialUnits() const
|
||||
{
|
||||
return d->specialUnits;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VIncrement::SetSpecialUnits(bool special)
|
||||
{
|
||||
d->specialUnits = special;
|
||||
}
|
||||
|
|
|
@ -71,6 +71,9 @@ public:
|
|||
bool IsPreviewCalculation() const;
|
||||
void SetPreviewCalculation(bool value);
|
||||
|
||||
bool IsSpecialUnits() const;
|
||||
void SetSpecialUnits(bool special);
|
||||
|
||||
private:
|
||||
QSharedDataPointer<VIncrementData> d;
|
||||
};
|
||||
|
|
|
@ -70,7 +70,8 @@ public:
|
|||
formulaOk(incr.formulaOk),
|
||||
previewCalculation(incr.previewCalculation),
|
||||
data(incr.data),
|
||||
incrType(incr.incrType)
|
||||
incrType(incr.incrType),
|
||||
specialUnits(incr.specialUnits)
|
||||
{}
|
||||
|
||||
virtual ~VIncrementData();
|
||||
|
@ -82,6 +83,7 @@ public:
|
|||
bool previewCalculation{false};
|
||||
QSharedPointer<VContainer> data;
|
||||
IncrementType incrType{IncrementType::Increment};
|
||||
bool specialUnits{false};
|
||||
|
||||
private:
|
||||
Q_DISABLE_ASSIGN(VIncrementData)
|
||||
|
|
|
@ -197,17 +197,10 @@ void DialogEditWrongFormula::ValChanged(int row)
|
|||
const QSharedPointer<VMeasurement> stable = m_data->GetVariable<VMeasurement>(name);
|
||||
SetDescription(item->text(), *stable->GetValue(), stable->IsSpecialUnits(), stable->GetGuiText());
|
||||
}
|
||||
else if (ui->radioButtonIncrements->isChecked())
|
||||
else if (ui->radioButtonIncrements->isChecked() || ui->radioButtonPC->isChecked())
|
||||
{
|
||||
const QSharedPointer<VIncrement> incr = m_data->GetVariable<VIncrement>(name);
|
||||
const bool specialUnits = false;
|
||||
SetDescription(item->text(), *incr->GetValue(), specialUnits, incr->GetDescription());
|
||||
}
|
||||
else if (ui->radioButtonPC->isChecked())
|
||||
{
|
||||
const QSharedPointer<VIncrement> incr = m_data->GetVariable<VIncrement>(name);
|
||||
const bool specialUnits = false;
|
||||
SetDescription(item->text(), *incr->GetValue(), specialUnits, incr->GetDescription());
|
||||
SetDescription(item->text(), *incr->GetValue(), incr->IsSpecialUnits(), incr->GetDescription());
|
||||
}
|
||||
else if (ui->radioButtonLengthLine->isChecked())
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user