Check unique label name in dialog. Fixed catch broken expression.
--HG-- branch : feature
This commit is contained in:
parent
afbc8d8c30
commit
6c784fcdca
|
@ -139,15 +139,12 @@ qreal Calculator::EvalFormula(const QString &formula)
|
|||
}
|
||||
|
||||
// Add variables
|
||||
InitVariables(data, tokens);
|
||||
|
||||
result = Eval();
|
||||
|
||||
return result;
|
||||
InitVariables(data, tokens, formula);
|
||||
return Eval();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void Calculator::InitVariables(const VContainer *data, const QMap<int, QString> &tokens)
|
||||
void Calculator::InitVariables(const VContainer *data, const QMap<int, QString> &tokens, const QString &formula)
|
||||
{
|
||||
if (qApp->patternType() == MeasurementsType::Standard)
|
||||
{
|
||||
|
@ -156,9 +153,11 @@ void Calculator::InitVariables(const VContainer *data, const QMap<int, QString>
|
|||
|
||||
const QHash<QString, QSharedPointer<VInternalVariable> > *vars = data->DataVariables();
|
||||
|
||||
bool found = false;
|
||||
QMap<int, QString>::const_iterator i = tokens.constBegin();
|
||||
while (i != tokens.constEnd())
|
||||
{
|
||||
found = false;
|
||||
if (vars->contains(i.value()))
|
||||
{
|
||||
QSharedPointer<VInternalVariable> var = vars->value(i.value());
|
||||
|
@ -169,6 +168,7 @@ void Calculator::InitVariables(const VContainer *data, const QMap<int, QString>
|
|||
m->SetValue(data->size(), data->height());
|
||||
}
|
||||
DefineVar(i.value(), var->GetValue());
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (qApp->patternType() == MeasurementsType::Standard)
|
||||
|
@ -177,14 +177,21 @@ void Calculator::InitVariables(const VContainer *data, const QMap<int, QString>
|
|||
{
|
||||
vVarVal[0] = data->size();
|
||||
DefineVar(data->SizeName(), &vVarVal[0]);
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (i.value() == data->HeightName())
|
||||
{
|
||||
vVarVal[1] = data->height();
|
||||
DefineVar(data->HeightName(), &vVarVal[1]);
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (found == false)
|
||||
{
|
||||
throw qmu::QmuParserError (ecUNASSIGNABLE_TOKEN , i.value(), formula, i.key());
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ private:
|
|||
qreal *vVarVal;
|
||||
static int iVal;
|
||||
const VContainer *data;
|
||||
void InitVariables(const VContainer *data, const QMap<int, QString> &tokens);
|
||||
void InitVariables(const VContainer *data, const QMap<int, QString> &tokens, const QString &formula);
|
||||
void InitCharacterSets();
|
||||
static qreal* AddVariable(const QString &a_szName, void *a_pUserData);
|
||||
};
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
* @param parent parent widget
|
||||
*/
|
||||
DialogAlongLine::DialogAlongLine(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogAlongLine), number(0), pointName(QString()),
|
||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogAlongLine), number(0),
|
||||
typeLine(QString()), formula(QString()), firstPointId(NULL_ID), secondPointId(NULL_ID), formulaBaseHeight(0),
|
||||
line(nullptr)
|
||||
{
|
||||
|
|
|
@ -87,9 +87,6 @@ private:
|
|||
/** @brief number number of handled objects */
|
||||
qint32 number;
|
||||
|
||||
/** @brief pointName name of point */
|
||||
QString pointName;
|
||||
|
||||
/** @brief typeLine type of line */
|
||||
QString typeLine;
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
* @param parent parent widget
|
||||
*/
|
||||
DialogBisector::DialogBisector(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogBisector), number(0), pointName(QString()), typeLine(QString()),
|
||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogBisector), number(0), typeLine(QString()),
|
||||
formula(QString()), firstPointId(NULL_ID), secondPointId(NULL_ID), thirdPointId(NULL_ID), formulaBaseHeight(0),
|
||||
line(nullptr), prepare(false)
|
||||
{
|
||||
|
|
|
@ -92,9 +92,6 @@ private:
|
|||
/** @brief number number of handled objects */
|
||||
qint32 number;
|
||||
|
||||
/** @brief pointName name of point */
|
||||
QString pointName;
|
||||
|
||||
/** @brief typeLine type of line */
|
||||
QString typeLine;
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
* @param parent parent widget
|
||||
*/
|
||||
DialogCutArc::DialogCutArc(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
||||
: DialogTool(data, toolId, parent), ui(new Ui::DialogCutArc), pointName(QString()), formula(QString()),
|
||||
: DialogTool(data, toolId, parent), ui(new Ui::DialogCutArc), formula(QString()),
|
||||
arcId(NULL_ID), formulaBaseHeight(0), path(nullptr)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
|
|
@ -78,9 +78,6 @@ private:
|
|||
/** @brief ui keeps information about user interface */
|
||||
Ui::DialogCutArc *ui;
|
||||
|
||||
/** @brief pointName name of created point */
|
||||
QString pointName;
|
||||
|
||||
/** @brief formula string with formula */
|
||||
QString formula;
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
* @param parent parent widget
|
||||
*/
|
||||
DialogCutSpline::DialogCutSpline(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogCutSpline), pointName(QString()), formula(QString()),
|
||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogCutSpline), formula(QString()),
|
||||
splineId(NULL_ID), formulaBaseHeight(0)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
|
|
@ -71,9 +71,6 @@ private:
|
|||
/** @brief ui keeps information about user interface */
|
||||
Ui::DialogCutSpline *ui;
|
||||
|
||||
/** @brief pointName name of created point */
|
||||
QString pointName;
|
||||
|
||||
/** @brief formula string with formula */
|
||||
QString formula;
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
* @param parent parent widget
|
||||
*/
|
||||
DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogCutSplinePath), pointName(QString()), formula(QString()),
|
||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogCutSplinePath), formula(QString()),
|
||||
splinePathId(NULL_ID), formulaBaseHeight(0)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
|
|
@ -71,9 +71,6 @@ private:
|
|||
/** @brief ui keeps information about user interface */
|
||||
Ui::DialogCutSplinePath *ui;
|
||||
|
||||
/** @brief pointName name of created point */
|
||||
QString pointName;
|
||||
|
||||
/** @brief formula string with formula */
|
||||
QString formula;
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
* @param parent parent widget
|
||||
*/
|
||||
DialogEndLine::DialogEndLine(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogEndLine), pointName(QString()), typeLine(QString()),
|
||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogEndLine), typeLine(QString()),
|
||||
formulaLength(QString()), formulaAngle(QString()), basePointId(NULL_ID), formulaBaseHeight(0),
|
||||
formulaBaseHeightAngle(0), line(nullptr)
|
||||
{
|
||||
|
|
|
@ -89,9 +89,6 @@ private:
|
|||
/** @brief ui keeps information about user interface */
|
||||
Ui::DialogEndLine *ui;
|
||||
|
||||
/** @brief pointName name of point */
|
||||
QString pointName;
|
||||
|
||||
/** @brief typeLine type of line */
|
||||
QString typeLine;
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
* @param parent parent widget
|
||||
*/
|
||||
DialogHeight::DialogHeight(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogHeight), number(0), pointName(QString()),
|
||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogHeight), number(0),
|
||||
typeLine(QString()), basePointId(NULL_ID), p1LineId(NULL_ID), p2LineId(NULL_ID), line(nullptr)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
|
|
@ -81,9 +81,6 @@ private:
|
|||
/** @brief number number of handled objects */
|
||||
qint32 number;
|
||||
|
||||
/** @brief pointName name of point */
|
||||
QString pointName;
|
||||
|
||||
/** @brief typeLine type of line */
|
||||
QString typeLine;
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
* @param parent parent widget
|
||||
*/
|
||||
DialogLineIntersect::DialogLineIntersect(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogLineIntersect), number(0), pointName(QString()),
|
||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogLineIntersect), number(0),
|
||||
p1Line1(NULL_ID), p2Line1(NULL_ID), p1Line2(NULL_ID), p2Line2(NULL_ID), flagPoint(true), line(nullptr)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
|
|
@ -85,9 +85,6 @@ private:
|
|||
/** @brief number number of handled objects */
|
||||
qint32 number;
|
||||
|
||||
/** @brief pointName name of point */
|
||||
QString pointName;
|
||||
|
||||
/** @brief p1Line1 id first point of first line */
|
||||
quint32 p1Line1;
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
* @param parent parent widget
|
||||
*/
|
||||
DialogNormal::DialogNormal(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogNormal), number(0), pointName(QString()), typeLine(QString()),
|
||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogNormal), number(0), typeLine(QString()),
|
||||
formula(QString()), angle(0), firstPointId(NULL_ID), secondPointId(NULL_ID), formulaBaseHeight(0), line(nullptr)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
|
|
@ -91,9 +91,6 @@ private:
|
|||
/** @brief number number of handled objects */
|
||||
qint32 number;
|
||||
|
||||
/** @brief pointName name of point */
|
||||
QString pointName;
|
||||
|
||||
/** @brief typeLine type of line */
|
||||
QString typeLine;
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
* @param parent parent widget
|
||||
*/
|
||||
DialogPointOfContact::DialogPointOfContact(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfContact), number(0), pointName(QString()),
|
||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfContact), number(0),
|
||||
radius(QString()), center(NULL_ID), firstPoint(NULL_ID), secondPoint(NULL_ID), formulaBaseHeight(0), line(nullptr)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
|
|
@ -89,9 +89,6 @@ private:
|
|||
/** @brief number number of handled objects */
|
||||
qint32 number;
|
||||
|
||||
/** @brief pointName name of point */
|
||||
QString pointName;
|
||||
|
||||
/** @brief radius radius of arc */
|
||||
QString radius;
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
* @param parent parent widget
|
||||
*/
|
||||
DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfIntersection), number(0), pointName(QString()),
|
||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfIntersection), number(0),
|
||||
firstPointId(NULL_ID), secondPointId(NULL_ID), line(nullptr)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
|
|
@ -75,9 +75,6 @@ private:
|
|||
/** @brief number number of handled objects */
|
||||
qint32 number;
|
||||
|
||||
/** @brief pointName name of point */
|
||||
QString pointName;
|
||||
|
||||
/** @brief firstPointId id first point of line */
|
||||
quint32 firstPointId;
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
* @param parent parent widget
|
||||
*/
|
||||
DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogShoulderPoint), number(0), pointName(QString()),
|
||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogShoulderPoint), number(0),
|
||||
typeLine(QString()), formula(QString()), p1Line(NULL_ID), p2Line(NULL_ID), pShoulder(NULL_ID), formulaBaseHeight(0),
|
||||
line (nullptr)
|
||||
{
|
||||
|
|
|
@ -91,9 +91,6 @@ private:
|
|||
/** @brief number number of handled objects */
|
||||
qint32 number;
|
||||
|
||||
/** @brief pointName name of point */
|
||||
QString pointName;
|
||||
|
||||
/** @brief typeLine type of line */
|
||||
QString typeLine;
|
||||
|
||||
|
|
|
@ -63,7 +63,8 @@ DialogTool::DialogTool(const VContainer *data, const quint32 &toolId, QWidget *p
|
|||
labelEditFormula(nullptr), radioButtonSizeGrowth(nullptr), radioButtonStandardTable(nullptr),
|
||||
radioButtonIncrements(nullptr), radioButtonLengthLine(nullptr), radioButtonLengthArc(nullptr),
|
||||
radioButtonLengthCurve(nullptr), radioButtonAngleLine(nullptr), lineStyles(VAbstractTool::Styles()),
|
||||
okColor(QColor(76, 76, 76)), errorColor(Qt::red), associatedTool(nullptr), toolId(toolId), prepare(false)
|
||||
okColor(QColor(76, 76, 76)), errorColor(Qt::red), associatedTool(nullptr), toolId(toolId), prepare(false),
|
||||
pointName(QString())
|
||||
{
|
||||
SCASSERT(data != nullptr);
|
||||
timerFormula = new QTimer(this);
|
||||
|
@ -659,7 +660,8 @@ void DialogTool::NamePointChanged()
|
|||
if (edit)
|
||||
{
|
||||
QString name = edit->text();
|
||||
if (name.isEmpty() || name.contains(" "))
|
||||
name.replace(" ", "");
|
||||
if (name.isEmpty() || (pointName != name && data->IsUnique(name) == false))
|
||||
{
|
||||
flagName = false;
|
||||
ChangeColor(labelEditNamePoint, Qt::red);
|
||||
|
|
|
@ -200,6 +200,9 @@ protected:
|
|||
/** @brief prepare show if we prepare. Show dialog after finish working with visual part of tool*/
|
||||
bool prepare;
|
||||
|
||||
/** @brief pointName name of point */
|
||||
QString pointName;
|
||||
|
||||
virtual void closeEvent ( QCloseEvent * event );
|
||||
virtual void showEvent( QShowEvent *event );
|
||||
void FillComboBoxPoints(QComboBox *box)const;
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
* @param parent parent widget
|
||||
*/
|
||||
DialogTriangle::DialogTriangle(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogTriangle), number(0), pointName(QString()), axisP1Id(NULL_ID),
|
||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogTriangle), number(0), axisP1Id(NULL_ID),
|
||||
axisP2Id(NULL_ID), firstPointId(NULL_ID), secondPointId(NULL_ID), line (nullptr)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
|
|
@ -80,9 +80,6 @@ private:
|
|||
/** @brief number number of handled objects */
|
||||
qint32 number;
|
||||
|
||||
/** @brief pointName name of point */
|
||||
QString pointName;
|
||||
|
||||
/** @brief axisP1Id id first point of axis */
|
||||
quint32 axisP1Id;
|
||||
|
||||
|
|
|
@ -1139,7 +1139,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
|
|||
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
||||
if (f != formula || angleFix != angle)
|
||||
{
|
||||
SetAttribute(domElement, VAbstractTool::AttrRadius, f);
|
||||
SetAttribute(domElement, VAbstractTool::AttrLength, f);
|
||||
SetAttribute(domElement, VAbstractTool::AttrAngle, angleFix);
|
||||
haveLiteChange();
|
||||
}
|
||||
|
@ -2452,6 +2452,7 @@ void VPattern::PrepareForParse(const Document &parse)
|
|||
else if (parse == Document::LiteParse)
|
||||
{
|
||||
data->ClearUniqueNames();
|
||||
data->ClearVariables();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user