User should be able to rename increments.
--HG-- branch : develop
This commit is contained in:
parent
6b29b8c528
commit
16ec3a3ea8
|
@ -61,7 +61,8 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
|
|||
doc(doc),
|
||||
formulaBaseHeight(0),
|
||||
search(),
|
||||
hasChanges(false)
|
||||
hasChanges(false),
|
||||
renameList()
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
|
@ -466,6 +467,64 @@ void DialogIncrements::LocalUpdateTree()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogIncrements::UpdateTree()
|
||||
{
|
||||
FillIncrements();
|
||||
|
||||
search->RefreshList(ui->lineEditFind->text());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool DialogIncrements::IncrementUsed(const QString &name) const
|
||||
{
|
||||
const QVector<VFormulaField> expressions = doc->ListExpressions();
|
||||
|
||||
for(int i = 0; i < expressions.size(); ++i)
|
||||
{
|
||||
if (expressions.at(i).expression.indexOf(name) != -1)
|
||||
{
|
||||
// Eval formula
|
||||
try
|
||||
{
|
||||
QScopedPointer<qmu::QmuTokenParser> cal(new qmu::QmuTokenParser(expressions.at(i).expression, false,
|
||||
false));
|
||||
|
||||
// Tokens (variables, measurements)
|
||||
if (cal->GetTokens().values().contains(name))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (const qmu::QmuParserError &)
|
||||
{
|
||||
// Do nothing. Because we not sure if used. A formula is broken.
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogIncrements::CacheRename(const QString &name, const QString &newName)
|
||||
{
|
||||
for (int i = 0; i < renameList.size(); ++i)
|
||||
{
|
||||
if (renameList.at(i).second == name)
|
||||
{
|
||||
renameList[i].second = newName;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
renameList.append(qMakePair(name, newName));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief FullUpdateFromFile update information in tables form file
|
||||
*/
|
||||
void DialogIncrements::FullUpdateFromFile()
|
||||
{
|
||||
hasChanges = false;
|
||||
|
||||
ui->tableWidgetLines->clearContents();
|
||||
ui->tableWidgetSplines->clearContents();
|
||||
ui->tableWidgetAnglesCurves->clearContents();
|
||||
|
@ -483,51 +542,18 @@ void DialogIncrements::UpdateTree()
|
|||
search->RefreshList(ui->lineEditFind->text());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool DialogIncrements::IncrementUsed(const QString &name) const
|
||||
{
|
||||
const QStringList expressions = doc->ListExpressions();
|
||||
|
||||
for(int i = 0; i < expressions.size(); ++i)
|
||||
{
|
||||
if (expressions.at(i).indexOf(name) != -1)
|
||||
{
|
||||
// Eval formula
|
||||
try
|
||||
{
|
||||
QScopedPointer<qmu::QmuTokenParser> cal(new qmu::QmuTokenParser(expressions.at(i), false, false));
|
||||
|
||||
// Tokens (variables, measurements)
|
||||
if (cal->GetTokens().values().contains(name))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (const qmu::QmuParserError &)
|
||||
{
|
||||
// Do nothing. Because we not sure if used. A formula is broken.
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief FullUpdateFromFile update information in tables form file
|
||||
*/
|
||||
void DialogIncrements::FullUpdateFromFile()
|
||||
{
|
||||
hasChanges = false;
|
||||
|
||||
UpdateTree();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogIncrements::RefreshPattern()
|
||||
{
|
||||
if (hasChanges)
|
||||
{
|
||||
QVector<VFormulaField> expressions = doc->ListExpressions();
|
||||
for (int i = 0; i < renameList.size(); ++i)
|
||||
{
|
||||
doc->ReplaceNameInFormula(expressions, renameList.at(i).first, renameList.at(i).second);
|
||||
}
|
||||
renameList.clear();
|
||||
|
||||
const int row = ui->tableWidgetIncrement->currentRow();
|
||||
|
||||
doc->LiteParseTree(Document::LiteParse);
|
||||
|
@ -663,6 +689,9 @@ void DialogIncrements::SaveIncrName(const QString &text)
|
|||
}
|
||||
|
||||
doc->SetIncrementName(nameField->text(), newName);
|
||||
QVector<VFormulaField> expressions = doc->ListIncrementExpressions();
|
||||
doc->ReplaceNameInFormula(expressions, nameField->text(), newName);
|
||||
CacheRename(nameField->text(), newName);
|
||||
|
||||
hasChanges = true;
|
||||
LocalUpdateTree();
|
||||
|
@ -832,6 +861,7 @@ void DialogIncrements::closeEvent(QCloseEvent *event)
|
|||
ui->lineEditName->blockSignals(true);
|
||||
ui->plainTextEditDescription->blockSignals(true);
|
||||
|
||||
emit UpdateProperties();
|
||||
emit DialogClosed(QDialog::Accepted);
|
||||
event->accept();
|
||||
}
|
||||
|
@ -942,7 +972,6 @@ void DialogIncrements::ShowIncrementDetails()
|
|||
ui->lineEditName->blockSignals(true);
|
||||
ui->lineEditName->setText(ClearIncrementName(incr->GetName()));
|
||||
ui->lineEditName->blockSignals(false);
|
||||
ui->lineEditName->setReadOnly(IncrementUsed(incr->GetName()));
|
||||
|
||||
ui->plainTextEditDescription->blockSignals(true);
|
||||
ui->plainTextEditDescription->setPlainText(incr->GetDescription());
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include "../xml/vpattern.h"
|
||||
#include "../vmisc/vtablesearch.h"
|
||||
|
||||
#include <QPair>
|
||||
|
||||
class VIndividualMeasurements;
|
||||
|
||||
namespace Ui
|
||||
|
@ -50,6 +52,9 @@ public:
|
|||
DialogIncrements(VContainer *data, VPattern *doc, QWidget *parent = nullptr);
|
||||
virtual ~DialogIncrements() Q_DECL_OVERRIDE;
|
||||
|
||||
signals:
|
||||
void UpdateProperties();
|
||||
|
||||
protected:
|
||||
virtual void closeEvent ( QCloseEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void changeEvent ( QEvent * event) Q_DECL_OVERRIDE;
|
||||
|
@ -88,6 +93,8 @@ private:
|
|||
|
||||
bool hasChanges;
|
||||
|
||||
QVector<QPair<QString, QString>> renameList;
|
||||
|
||||
template <typename T>
|
||||
void FillTable(const QMap<QString, T> &varTable, QTableWidget *table);
|
||||
|
||||
|
@ -115,6 +122,8 @@ private:
|
|||
void UpdateTree();
|
||||
|
||||
bool IncrementUsed(const QString &name) const;
|
||||
|
||||
void CacheRename(const QString &name, const QString &newName);
|
||||
};
|
||||
|
||||
#endif // DIALOGINCREMENTS_H
|
||||
|
|
|
@ -3919,6 +3919,8 @@ void MainWindow::CreateActions()
|
|||
if (checked)
|
||||
{
|
||||
dialogTable = new DialogIncrements(pattern, doc, this);
|
||||
connect(dialogTable.data(), &DialogIncrements::UpdateProperties, toolOptions,
|
||||
&VToolOptionsPropertyBrowser::RefreshOptions);
|
||||
connect(dialogTable.data(), &DialogIncrements::DialogClosed, this, [this]()
|
||||
{
|
||||
ui->actionTable->setChecked(false);
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "../vmisc/vmath.h"
|
||||
#include "../vmisc/projectversion.h"
|
||||
#include "../qmuparser/qmuparsererror.h"
|
||||
#include "../qmuparser/qmutokenparser.h"
|
||||
#include "../vgeometry/varc.h"
|
||||
#include "../vgeometry/vellipticalarc.h"
|
||||
#include "../vgeometry/vsplinepath.h"
|
||||
|
@ -3509,6 +3510,63 @@ void VPattern::SetIncrementDescription(const QString &name, const QString &text)
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPattern::ReplaceNameInFormula(QVector<VFormulaField> &expressions, const QString &name, const QString &newName)
|
||||
{
|
||||
const int bias = name.length() - newName.length();
|
||||
|
||||
for(int i = 0; i < expressions.size(); ++i)
|
||||
{
|
||||
if (expressions.at(i).expression.indexOf(name) != -1)
|
||||
{
|
||||
QMap<int, QString> tokens;
|
||||
|
||||
// Eval formula
|
||||
try
|
||||
{
|
||||
QScopedPointer<qmu::QmuTokenParser> cal(new qmu::QmuTokenParser(expressions.at(i).expression, false,
|
||||
false));
|
||||
tokens = cal->GetTokens();// Tokens (variables, measurements)
|
||||
|
||||
}
|
||||
catch (const qmu::QmuParserError &)
|
||||
{
|
||||
continue;// Because we not sure if used. A formula is broken.
|
||||
}
|
||||
|
||||
QList<QString> tValues = tokens.values();
|
||||
if (not tValues.contains(name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
QList<int> tKeys = tokens.keys();// Take all tokens positions
|
||||
QString newFormula = expressions.at(i).expression;
|
||||
|
||||
for (int i = 0; i < tKeys.size(); ++i)
|
||||
{
|
||||
if (tValues.at(i) != name)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
newFormula.replace(tKeys.at(i), name.length(), newName);
|
||||
|
||||
if (bias != 0)
|
||||
{// Translated token has different length than original. Position next tokens need to be corrected.
|
||||
VTranslateVars::BiasTokens(tKeys.at(i), bias, tokens);
|
||||
tKeys = tokens.keys();
|
||||
tValues = tokens.values();
|
||||
}
|
||||
}
|
||||
|
||||
expressions[i].expression = newFormula;
|
||||
expressions[i].element.setAttribute(expressions.at(i).attribute, newFormula);
|
||||
emit patternChanged(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief GenerateLabel create label for pattern piece of point.
|
||||
|
|
|
@ -79,6 +79,8 @@ public:
|
|||
void SetIncrementFormula(const QString &name, const QString &text);
|
||||
void SetIncrementDescription(const QString &name, const QString &text);
|
||||
|
||||
void ReplaceNameInFormula(QVector<VFormulaField> &expressions, const QString &name, const QString &newName);
|
||||
|
||||
virtual QString GenerateLabel(const LabelType &type, const QString &reservedName = QString())const Q_DECL_OVERRIDE;
|
||||
virtual QString GenerateSuffix() const Q_DECL_OVERRIDE;
|
||||
|
||||
|
|
|
@ -194,6 +194,28 @@ const QString VAbstractPattern::NodeSplinePath = QStringLiteral("NodeSplinePath"
|
|||
|
||||
QHash<quint32, VDataTool*> VAbstractPattern::tools = QHash<quint32, VDataTool*>();
|
||||
|
||||
namespace
|
||||
{
|
||||
void ReadExpressionAttribute(QVector<VFormulaField> &expressions, const QDomElement &element, const QString &attribute)
|
||||
{
|
||||
VFormulaField formula;
|
||||
try
|
||||
{
|
||||
formula.expression = VDomDocument::GetParametrString(element, attribute);
|
||||
}
|
||||
catch (VExceptionEmptyParameter &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
return;
|
||||
}
|
||||
|
||||
formula.element = element;
|
||||
formula.attribute = attribute;
|
||||
|
||||
expressions.append(formula);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VAbstractPattern::VAbstractPattern(QObject *parent)
|
||||
: QObject(parent),
|
||||
|
@ -218,17 +240,18 @@ QStringList VAbstractPattern::ListMeasurements() const
|
|||
others.insert(increments.at(i));
|
||||
}
|
||||
|
||||
const QStringList expressions = ListExpressions();
|
||||
const QVector<VFormulaField> expressions = ListExpressions();
|
||||
for (int i=0; i < expressions.size(); ++i)
|
||||
{
|
||||
QScopedPointer<qmu::QmuTokenParser> cal(new qmu::QmuTokenParser(expressions.at(i), false, false));// Eval formula
|
||||
// Eval formula
|
||||
QScopedPointer<qmu::QmuTokenParser> cal(new qmu::QmuTokenParser(expressions.at(i).expression, false, false));
|
||||
const QMap<int, QString> tokens = cal->GetTokens();// Tokens (variables, measurements)
|
||||
delete cal.take();
|
||||
|
||||
const QList<QString> tValues = tokens.values();
|
||||
for (int j = 0; j < tValues.size(); ++j)
|
||||
{
|
||||
if (tValues.at(j) == QLatin1String("-"))
|
||||
if (tValues.at(j) == QChar('-'))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -1613,9 +1636,9 @@ QStringList VAbstractPattern::ListIncrements() const
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QStringList VAbstractPattern::ListExpressions() const
|
||||
QVector<VFormulaField> VAbstractPattern::ListExpressions() const
|
||||
{
|
||||
QStringList list;
|
||||
QVector<VFormulaField> list;
|
||||
|
||||
// If new tool bring absolutely new type and has formula(s) create new method to cover it.
|
||||
// Note. Tool Union Details also contains formulas, but we don't use them for union and keep only to simplifying
|
||||
|
@ -1633,333 +1656,180 @@ QStringList VAbstractPattern::ListExpressions() const
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QStringList VAbstractPattern::ListPointExpressions() const
|
||||
QVector<VFormulaField> VAbstractPattern::ListPointExpressions() const
|
||||
{
|
||||
// Check if new tool doesn't bring new attribute with a formula.
|
||||
// If no just increment a number.
|
||||
// If new tool bring absolutely new type and has formula(s) create new method to cover it.
|
||||
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 53);
|
||||
|
||||
QStringList expressions;
|
||||
QVector<VFormulaField> expressions;
|
||||
const QDomNodeList list = elementsByTagName(TagPoint);
|
||||
for (int i=0; i < list.size(); ++i)
|
||||
{
|
||||
const QDomElement dom = list.at(i).toElement();
|
||||
|
||||
// Each tag can contains several attributes.
|
||||
try
|
||||
{
|
||||
expressions.append(GetParametrString(dom, AttrLength));
|
||||
}
|
||||
catch (VExceptionEmptyParameter &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
expressions.append(GetParametrString(dom, AttrAngle));
|
||||
}
|
||||
catch (VExceptionEmptyParameter &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
}
|
||||
try
|
||||
{
|
||||
expressions.append(GetParametrString(dom, AttrC1Radius));
|
||||
}
|
||||
catch (VExceptionEmptyParameter &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
expressions.append(GetParametrString(dom, AttrC2Radius));
|
||||
}
|
||||
catch (VExceptionEmptyParameter &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
expressions.append(GetParametrString(dom, AttrCRadius));
|
||||
}
|
||||
catch (VExceptionEmptyParameter &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
expressions.append(GetParametrString(dom, AttrRadius));
|
||||
}
|
||||
catch (VExceptionEmptyParameter &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
}
|
||||
ReadExpressionAttribute(expressions, dom, AttrLength);
|
||||
ReadExpressionAttribute(expressions, dom, AttrAngle);
|
||||
ReadExpressionAttribute(expressions, dom, AttrC1Radius);
|
||||
ReadExpressionAttribute(expressions, dom, AttrC2Radius);
|
||||
ReadExpressionAttribute(expressions, dom, AttrCRadius);
|
||||
ReadExpressionAttribute(expressions, dom, AttrRadius);
|
||||
}
|
||||
|
||||
return expressions;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QStringList VAbstractPattern::ListArcExpressions() const
|
||||
QVector<VFormulaField> VAbstractPattern::ListArcExpressions() const
|
||||
{
|
||||
// Check if new tool doesn't bring new attribute with a formula.
|
||||
// If no just increment number.
|
||||
// If new tool bring absolutely new type and has formula(s) create new method to cover it.
|
||||
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 53);
|
||||
|
||||
QStringList expressions;
|
||||
QVector<VFormulaField> expressions;
|
||||
const QDomNodeList list = elementsByTagName(TagArc);
|
||||
for (int i=0; i < list.size(); ++i)
|
||||
{
|
||||
const QDomElement dom = list.at(i).toElement();
|
||||
|
||||
try
|
||||
{
|
||||
expressions.append(GetParametrString(dom, AttrAngle1));
|
||||
}
|
||||
catch (VExceptionEmptyParameter &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
expressions.append(GetParametrString(dom, AttrAngle2));
|
||||
}
|
||||
catch (VExceptionEmptyParameter &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
expressions.append(GetParametrString(dom, AttrRadius));
|
||||
}
|
||||
catch (VExceptionEmptyParameter &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
expressions.append(GetParametrString(dom, AttrLength));
|
||||
}
|
||||
catch (VExceptionEmptyParameter &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
}
|
||||
// Each tag can contains several attributes.
|
||||
ReadExpressionAttribute(expressions, dom, AttrAngle1);
|
||||
ReadExpressionAttribute(expressions, dom, AttrAngle2);
|
||||
ReadExpressionAttribute(expressions, dom, AttrRadius);
|
||||
ReadExpressionAttribute(expressions, dom, AttrLength);
|
||||
}
|
||||
|
||||
return expressions;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QStringList VAbstractPattern::ListElArcExpressions() const
|
||||
QVector<VFormulaField> VAbstractPattern::ListElArcExpressions() const
|
||||
{
|
||||
// Check if new tool doesn't bring new attribute with a formula.
|
||||
// If no just increment number.
|
||||
// If new tool bring absolutely new type and has formula(s) create new method to cover it.
|
||||
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 53);
|
||||
|
||||
QStringList expressions;
|
||||
QVector<VFormulaField> expressions;
|
||||
const QDomNodeList list = elementsByTagName(TagElArc);
|
||||
for (int i=0; i < list.size(); ++i)
|
||||
{
|
||||
const QDomElement dom = list.at(i).toElement();
|
||||
|
||||
try
|
||||
{
|
||||
expressions.append(GetParametrString(dom, AttrRadius1));
|
||||
}
|
||||
catch (VExceptionEmptyParameter &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
expressions.append(GetParametrString(dom, AttrRadius2));
|
||||
}
|
||||
catch (VExceptionEmptyParameter &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
expressions.append(GetParametrString(dom, AttrAngle1));
|
||||
}
|
||||
catch (VExceptionEmptyParameter &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
expressions.append(GetParametrString(dom, AttrAngle2));
|
||||
}
|
||||
catch (VExceptionEmptyParameter &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
expressions.append(GetParametrString(dom, AttrRotationAngle));
|
||||
}
|
||||
catch (VExceptionEmptyParameter &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
}
|
||||
// Each tag can contains several attributes.
|
||||
ReadExpressionAttribute(expressions, dom, AttrRadius1);
|
||||
ReadExpressionAttribute(expressions, dom, AttrRadius2);
|
||||
ReadExpressionAttribute(expressions, dom, AttrAngle1);
|
||||
ReadExpressionAttribute(expressions, dom, AttrAngle2);
|
||||
ReadExpressionAttribute(expressions, dom, AttrRotationAngle);
|
||||
}
|
||||
|
||||
return expressions;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QStringList VAbstractPattern::ListSplineExpressions() const
|
||||
QVector<VFormulaField> VAbstractPattern::ListSplineExpressions() const
|
||||
{
|
||||
QStringList expressions;
|
||||
QVector<VFormulaField> expressions;
|
||||
expressions << ListPathPointExpressions();
|
||||
return expressions;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QStringList VAbstractPattern::ListPathPointExpressions() const
|
||||
QVector<VFormulaField> VAbstractPattern::ListPathPointExpressions() const
|
||||
{
|
||||
// Check if new tool doesn't bring new attribute with a formula.
|
||||
// If no just increment number.
|
||||
// If new tool bring absolutely new type and has formula(s) create new method to cover it.
|
||||
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 53);
|
||||
|
||||
QStringList expressions;
|
||||
QVector<VFormulaField> expressions;
|
||||
const QDomNodeList list = elementsByTagName(AttrPathPoint);
|
||||
for (int i=0; i < list.size(); ++i)
|
||||
{
|
||||
const QDomElement dom = list.at(i).toElement();
|
||||
|
||||
try
|
||||
{
|
||||
expressions.append(GetParametrString(dom, AttrKAsm1));
|
||||
}
|
||||
catch (VExceptionEmptyParameter &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
expressions.append(GetParametrString(dom, AttrKAsm2));
|
||||
}
|
||||
catch (VExceptionEmptyParameter &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
expressions.append(GetParametrString(dom, AttrAngle));
|
||||
}
|
||||
catch (VExceptionEmptyParameter &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
}
|
||||
// Each tag can contains several attributes.
|
||||
ReadExpressionAttribute(expressions, dom, AttrKAsm1);
|
||||
ReadExpressionAttribute(expressions, dom, AttrKAsm2);
|
||||
ReadExpressionAttribute(expressions, dom, AttrAngle);
|
||||
}
|
||||
|
||||
return expressions;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QStringList VAbstractPattern::ListIncrementExpressions() const
|
||||
QVector<VFormulaField> VAbstractPattern::ListIncrementExpressions() const
|
||||
{
|
||||
QStringList expressions;
|
||||
QVector<VFormulaField> expressions;
|
||||
const QDomNodeList list = elementsByTagName(TagIncrement);
|
||||
for (int i=0; i < list.size(); ++i)
|
||||
{
|
||||
const QDomElement dom = list.at(i).toElement();
|
||||
|
||||
try
|
||||
{
|
||||
expressions.append(GetParametrString(dom, IncrementFormula));
|
||||
}
|
||||
catch (VExceptionEmptyParameter &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
}
|
||||
ReadExpressionAttribute(expressions, dom, IncrementFormula);
|
||||
}
|
||||
|
||||
return expressions;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QStringList VAbstractPattern::ListOperationExpressions() const
|
||||
QVector<VFormulaField> VAbstractPattern::ListOperationExpressions() const
|
||||
{
|
||||
// Check if new tool doesn't bring new attribute with a formula.
|
||||
// If no just increment number.
|
||||
// If new tool bring absolutely new type and has formula(s) create new method to cover it.
|
||||
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 53);
|
||||
|
||||
QStringList expressions;
|
||||
QVector<VFormulaField> expressions;
|
||||
const QDomNodeList list = elementsByTagName(TagOperation);
|
||||
for (int i=0; i < list.size(); ++i)
|
||||
{
|
||||
const QDomElement dom = list.at(i).toElement();
|
||||
|
||||
// Each tag can contains several attributes.
|
||||
try
|
||||
{
|
||||
expressions.append(GetParametrString(dom, AttrAngle));
|
||||
}
|
||||
catch (VExceptionEmptyParameter &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
expressions.append(GetParametrString(dom, AttrLength));
|
||||
}
|
||||
catch (VExceptionEmptyParameter &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
}
|
||||
ReadExpressionAttribute(expressions, dom, AttrAngle);
|
||||
ReadExpressionAttribute(expressions, dom, AttrLength);
|
||||
}
|
||||
|
||||
return expressions;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QStringList VAbstractPattern::ListNodesExpressions(const QDomElement &nodes) const
|
||||
{
|
||||
QStringList expressions;
|
||||
VPiecePath path;
|
||||
if (not nodes.isNull())
|
||||
{
|
||||
path = ParsePathNodes(nodes);
|
||||
}
|
||||
|
||||
for(int i = 0; i < path.CountNodes(); ++i)
|
||||
{
|
||||
expressions.append(path.at(i).GetFormulaSABefore());
|
||||
expressions.append(path.at(i).GetFormulaSAAfter());
|
||||
}
|
||||
return expressions;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QStringList VAbstractPattern::ListPathExpressions() const
|
||||
QVector<VFormulaField> VAbstractPattern::ListNodesExpressions(const QDomElement &nodes) const
|
||||
{
|
||||
// Check if new tool doesn't bring new attribute with a formula.
|
||||
// If no just increment number.
|
||||
// If new tool bring absolutely new type and has formula(s) create new method to cover it.
|
||||
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 53);
|
||||
|
||||
QStringList expressions;
|
||||
QVector<VFormulaField> expressions;
|
||||
|
||||
const QDomNodeList nodeList = nodes.childNodes();
|
||||
for (qint32 i = 0; i < nodeList.size(); ++i)
|
||||
{
|
||||
const QDomElement element = nodeList.at(i).toElement();
|
||||
if (not element.isNull() && element.tagName() == VAbstractPattern::TagNode)
|
||||
{
|
||||
ReadExpressionAttribute(expressions, element, VAbstractPattern::AttrSABefore);
|
||||
ReadExpressionAttribute(expressions, element, VAbstractPattern::AttrSAAfter);
|
||||
}
|
||||
}
|
||||
return expressions;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<VFormulaField> VAbstractPattern::ListPathExpressions() const
|
||||
{
|
||||
// Check if new tool doesn't bring new attribute with a formula.
|
||||
// If no just increment number.
|
||||
// If new tool bring absolutely new type and has formula(s) create new method to cover it.
|
||||
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 53);
|
||||
|
||||
QVector<VFormulaField> expressions;
|
||||
const QDomNodeList list = elementsByTagName(TagPath);
|
||||
for (int i=0; i < list.size(); ++i)
|
||||
{
|
||||
|
@ -1976,43 +1846,28 @@ QStringList VAbstractPattern::ListPathExpressions() const
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QStringList VAbstractPattern::ListGrainlineExpressions(const QDomElement &element) const
|
||||
QVector<VFormulaField> VAbstractPattern::ListGrainlineExpressions(const QDomElement &element) const
|
||||
{
|
||||
QStringList expressions;
|
||||
QVector<VFormulaField> expressions;
|
||||
if (not element.isNull())
|
||||
{
|
||||
// Each tag can contains several attributes.
|
||||
try
|
||||
{
|
||||
expressions.append(GetParametrString(element, AttrRotation));
|
||||
}
|
||||
catch (VExceptionEmptyParameter &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
expressions.append(GetParametrString(element, AttrLength));
|
||||
}
|
||||
catch (VExceptionEmptyParameter &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
}
|
||||
ReadExpressionAttribute(expressions, element, AttrRotation);
|
||||
ReadExpressionAttribute(expressions, element, AttrLength);
|
||||
}
|
||||
|
||||
return expressions;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QStringList VAbstractPattern::ListPieceExpressions() const
|
||||
QVector<VFormulaField> VAbstractPattern::ListPieceExpressions() const
|
||||
{
|
||||
// Check if new tool doesn't bring new attribute with a formula.
|
||||
// If no just increment number.
|
||||
// If new tool bring absolutely new type and has formula(s) create new method to cover it.
|
||||
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 53);
|
||||
|
||||
QStringList expressions;
|
||||
QVector<VFormulaField> expressions;
|
||||
const QDomNodeList list = elementsByTagName(TagDetail);
|
||||
for (int i=0; i < list.size(); ++i)
|
||||
{
|
||||
|
@ -2023,14 +1878,7 @@ QStringList VAbstractPattern::ListPieceExpressions() const
|
|||
}
|
||||
|
||||
// Each tag can contains several attributes.
|
||||
try
|
||||
{
|
||||
expressions.append(GetParametrString(dom, AttrWidth));
|
||||
}
|
||||
catch (VExceptionEmptyParameter &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
}
|
||||
ReadExpressionAttribute(expressions, dom, AttrWidth);
|
||||
|
||||
expressions << ListNodesExpressions(dom.firstChildElement(TagNodes));
|
||||
expressions << ListGrainlineExpressions(dom.firstChildElement(TagGrainline));
|
||||
|
|
|
@ -60,6 +60,18 @@ enum class AxisType : char {VerticalAxis = 1, HorizontalAxis = 2};
|
|||
class VContainer;
|
||||
class VDataTool;
|
||||
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_GCC("-Weffc++")
|
||||
|
||||
struct VFormulaField
|
||||
{
|
||||
QString expression;
|
||||
QDomElement element;
|
||||
QString attribute;
|
||||
};
|
||||
|
||||
QT_WARNING_POP
|
||||
|
||||
class VAbstractPattern : public QObject, public VDomDocument
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -68,7 +80,8 @@ public:
|
|||
virtual ~VAbstractPattern() Q_DECL_EQ_DEFAULT;
|
||||
|
||||
QStringList ListMeasurements() const;
|
||||
QStringList ListExpressions() const;
|
||||
QVector<VFormulaField> ListExpressions() const;
|
||||
QVector<VFormulaField> ListIncrementExpressions() const;
|
||||
|
||||
virtual void CreateEmptyFile()=0;
|
||||
|
||||
|
@ -388,17 +401,16 @@ private:
|
|||
Q_DISABLE_COPY(VAbstractPattern)
|
||||
|
||||
QStringList ListIncrements() const;
|
||||
QStringList ListPointExpressions() const;
|
||||
QStringList ListArcExpressions() const;
|
||||
QStringList ListElArcExpressions() const;
|
||||
QStringList ListSplineExpressions() const;
|
||||
QStringList ListPathPointExpressions() const;
|
||||
QStringList ListIncrementExpressions() const;
|
||||
QStringList ListOperationExpressions() const;
|
||||
QStringList ListNodesExpressions(const QDomElement &nodes) const;
|
||||
QStringList ListPathExpressions() const;
|
||||
QStringList ListGrainlineExpressions(const QDomElement &element) const;
|
||||
QStringList ListPieceExpressions() const;
|
||||
QVector<VFormulaField> ListPointExpressions() const;
|
||||
QVector<VFormulaField> ListArcExpressions() const;
|
||||
QVector<VFormulaField> ListElArcExpressions() const;
|
||||
QVector<VFormulaField> ListSplineExpressions() const;
|
||||
QVector<VFormulaField> ListPathPointExpressions() const;
|
||||
QVector<VFormulaField> ListOperationExpressions() const;
|
||||
QVector<VFormulaField> ListNodesExpressions(const QDomElement &nodes) const;
|
||||
QVector<VFormulaField> ListPathExpressions() const;
|
||||
QVector<VFormulaField> ListGrainlineExpressions(const QDomElement &element) const;
|
||||
QVector<VFormulaField> ListPieceExpressions() const;
|
||||
|
||||
bool IsVariable(const QString& token) const;
|
||||
bool IsPostfixOperator(const QString& token) const;
|
||||
|
|
|
@ -65,6 +65,8 @@ public:
|
|||
|
||||
QMap<QString, qmu::QmuTranslation> GetFunctions() const;
|
||||
|
||||
static void BiasTokens(int position, int bias, QMap<int, QString> &tokens);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VTranslateVars)
|
||||
QMap<QString, qmu::QmuTranslation> PMSystemNames;
|
||||
|
@ -86,7 +88,7 @@ private:
|
|||
const qmu::QmuTranslation &book);
|
||||
|
||||
void CorrectionsPositions(int position, int bias, QMap<int, QString> &tokens, QMap<int, QString> &numbers) const;
|
||||
static void BiasTokens(int position, int bias, QMap<int, QString> &tokens);
|
||||
|
||||
};
|
||||
|
||||
#endif // VTRANSLATEVARS_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user