Fix bug with calculator and tools visualization.
--HG-- branch : develop
This commit is contained in:
parent
936244948c
commit
7673deade8
|
@ -42,7 +42,6 @@ defineTest(copyToDestdir) {
|
||||||
|
|
||||||
|
|
||||||
GCC_CXXFLAGS += \
|
GCC_CXXFLAGS += \
|
||||||
-O0 \
|
|
||||||
-Wall \
|
-Wall \
|
||||||
-Wextra \
|
-Wextra \
|
||||||
-pedantic \
|
-pedantic \
|
||||||
|
@ -84,7 +83,6 @@ GCC_CXXFLAGS += \
|
||||||
-ftrapv
|
-ftrapv
|
||||||
|
|
||||||
CLANG_CXXFLAGS += \
|
CLANG_CXXFLAGS += \
|
||||||
-O0 \
|
|
||||||
-fparse-all-comments \
|
-fparse-all-comments \
|
||||||
-Wabi \
|
-Wabi \
|
||||||
-Wabstract-final-class \
|
-Wabstract-final-class \
|
||||||
|
|
|
@ -55,8 +55,7 @@ Calculator::Calculator(const VContainer *data)
|
||||||
InitCharacterSets();
|
InitCharacterSets();
|
||||||
setAllowSubexpressions(false);//Only one expression per time
|
setAllowSubexpressions(false);//Only one expression per time
|
||||||
|
|
||||||
SetArgSep(',');
|
SetSepForEval();
|
||||||
SetDecSep('.');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -82,30 +81,7 @@ Calculator::Calculator(const QString &formula, bool fromUser)
|
||||||
setAllowSubexpressions(false);//Only one expression per time
|
setAllowSubexpressions(false);//Only one expression per time
|
||||||
SetVarFactory(AddVariable, this);
|
SetVarFactory(AddVariable, this);
|
||||||
|
|
||||||
// Add unary operators
|
SetSepForTr(fromUser);
|
||||||
if (fromUser)
|
|
||||||
{
|
|
||||||
bool osSeparatorValue = qApp->getSettings()->value("configuration/osSeparator", 1).toBool();
|
|
||||||
|
|
||||||
if (osSeparatorValue)
|
|
||||||
{
|
|
||||||
QLocale loc = QLocale::system();
|
|
||||||
SetDecSep(loc.decimalPoint().toLatin1());
|
|
||||||
SetThousandsSep(loc.groupSeparator().toLatin1());
|
|
||||||
SetArgSep(';');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SetArgSep(',');
|
|
||||||
SetDecSep('.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
SetArgSep(',');
|
|
||||||
SetDecSep('.');
|
|
||||||
}
|
|
||||||
|
|
||||||
SetExpr(formula);
|
SetExpr(formula);
|
||||||
//Need run for making tokens. Don't catch exception here, because we want know if formula has error.
|
//Need run for making tokens. Don't catch exception here, because we want know if formula has error.
|
||||||
|
@ -126,6 +102,7 @@ Calculator::~Calculator()
|
||||||
qreal Calculator::EvalFormula(const QString &formula)
|
qreal Calculator::EvalFormula(const QString &formula)
|
||||||
{
|
{
|
||||||
SetVarFactory(AddVariable, this);
|
SetVarFactory(AddVariable, this);
|
||||||
|
SetSepForEval();//Reset separators options
|
||||||
|
|
||||||
SetExpr(formula);
|
SetExpr(formula);
|
||||||
|
|
||||||
|
@ -214,7 +191,7 @@ void Calculator::InitCharacterSets()
|
||||||
DefineOprtChars(symbols + QStringLiteral("+-*^/?<>=#!$%&|~'_"));
|
DefineOprtChars(symbols + QStringLiteral("+-*^/?<>=#!$%&|~'_"));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
// Factory function for creating new parser variables
|
// Factory function for creating new parser variables
|
||||||
// This could as well be a function performing database queries.
|
// This could as well be a function performing database queries.
|
||||||
qreal* Calculator::AddVariable(const QString &a_szName, void *a_pUserData)
|
qreal* Calculator::AddVariable(const QString &a_szName, void *a_pUserData)
|
||||||
|
@ -225,3 +202,38 @@ qreal* Calculator::AddVariable(const QString &a_szName, void *a_pUserData)
|
||||||
static qreal value = 0;
|
static qreal value = 0;
|
||||||
return &value;
|
return &value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void Calculator::SetSepForEval()
|
||||||
|
{
|
||||||
|
SetArgSep(',');
|
||||||
|
SetDecSep('.');
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void Calculator::SetSepForTr(bool fromUser)
|
||||||
|
{
|
||||||
|
if (fromUser)
|
||||||
|
{
|
||||||
|
bool osSeparatorValue = qApp->getSettings()->value("configuration/osSeparator", 1).toBool();
|
||||||
|
|
||||||
|
if (osSeparatorValue)
|
||||||
|
{
|
||||||
|
QLocale loc = QLocale::system();
|
||||||
|
SetDecSep(loc.decimalPoint().toLatin1());
|
||||||
|
SetThousandsSep(loc.groupSeparator().toLatin1());
|
||||||
|
SetArgSep(';');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetArgSep(',');
|
||||||
|
SetDecSep('.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
SetArgSep(',');
|
||||||
|
SetDecSep('.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -66,6 +66,8 @@ private:
|
||||||
void InitVariables(const VContainer *data, const QMap<int, QString> &tokens, const QString &formula);
|
void InitVariables(const VContainer *data, const QMap<int, QString> &tokens, const QString &formula);
|
||||||
void InitCharacterSets();
|
void InitCharacterSets();
|
||||||
static qreal* AddVariable(const QString &a_szName, void *a_pUserData);
|
static qreal* AddVariable(const QString &a_szName, void *a_pUserData);
|
||||||
|
void SetSepForEval();
|
||||||
|
void SetSepForTr(bool fromUser);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CALCULATOR_H
|
#endif // CALCULATOR_H
|
||||||
|
|
|
@ -86,7 +86,7 @@ void VToolAlongLine::FullUpdateFromFile()
|
||||||
VisToolAlongLine * visual = qobject_cast<VisToolAlongLine *>(vis);
|
VisToolAlongLine * visual = qobject_cast<VisToolAlongLine *>(vis);
|
||||||
visual->setPoint1Id(basePointId);
|
visual->setPoint1Id(basePointId);
|
||||||
visual->setPoint2Id(secondPointId);
|
visual->setPoint2Id(secondPointId);
|
||||||
visual->setLength(formulaLength);
|
visual->setLength(qApp->FormulaToUser(formulaLength));
|
||||||
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
|
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
|
||||||
visual->RefreshGeometry();
|
visual->RefreshGeometry();
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ void VToolAlongLine::ShowVisualization(bool show)
|
||||||
|
|
||||||
visual->setPoint1Id(basePointId);
|
visual->setPoint1Id(basePointId);
|
||||||
visual->setPoint2Id(secondPointId);
|
visual->setPoint2Id(secondPointId);
|
||||||
visual->setLength(formulaLength);
|
visual->setLength(qApp->FormulaToUser(formulaLength));
|
||||||
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
|
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
|
||||||
visual->RefreshGeometry();
|
visual->RefreshGeometry();
|
||||||
vis = visual;
|
vis = visual;
|
||||||
|
|
|
@ -286,7 +286,7 @@ void VToolArc::ShowVisualization(bool show)
|
||||||
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
|
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
|
||||||
|
|
||||||
visual->setPoint1Id(arc->GetCenter().id());
|
visual->setPoint1Id(arc->GetCenter().id());
|
||||||
visual->setRadius(arc->GetFormulaRadius());
|
visual->setRadius(qApp->FormulaToUser(arc->GetFormulaRadius()));
|
||||||
visual->setF1(arc->GetFormulaF1());
|
visual->setF1(arc->GetFormulaF1());
|
||||||
visual->setF2(arc->GetFormulaF2());
|
visual->setF2(arc->GetFormulaF2());
|
||||||
visual->RefreshGeometry();
|
visual->RefreshGeometry();
|
||||||
|
@ -372,7 +372,7 @@ void VToolArc::RefreshGeometry()
|
||||||
VisToolArc *visual = qobject_cast<VisToolArc *>(vis);
|
VisToolArc *visual = qobject_cast<VisToolArc *>(vis);
|
||||||
|
|
||||||
visual->setPoint1Id(arc->GetCenter().id());
|
visual->setPoint1Id(arc->GetCenter().id());
|
||||||
visual->setRadius(arc->GetFormulaRadius());
|
visual->setRadius(qApp->FormulaToUser(arc->GetFormulaRadius()));
|
||||||
visual->setF1(arc->GetFormulaF1());
|
visual->setF1(arc->GetFormulaF1());
|
||||||
visual->setF2(arc->GetFormulaF2());
|
visual->setF2(arc->GetFormulaF2());
|
||||||
visual->RefreshGeometry();
|
visual->RefreshGeometry();
|
||||||
|
|
|
@ -238,7 +238,7 @@ void VToolBisector::FullUpdateFromFile()
|
||||||
visual->setPoint1Id(firstPointId);
|
visual->setPoint1Id(firstPointId);
|
||||||
visual->setPoint2Id(basePointId);
|
visual->setPoint2Id(basePointId);
|
||||||
visual->setPoint3Id(thirdPointId);
|
visual->setPoint3Id(thirdPointId);
|
||||||
visual->setLength(formulaLength);
|
visual->setLength(qApp->FormulaToUser(formulaLength));
|
||||||
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
|
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
|
||||||
visual->RefreshGeometry();
|
visual->RefreshGeometry();
|
||||||
}
|
}
|
||||||
|
@ -355,7 +355,7 @@ void VToolBisector::ShowVisualization(bool show)
|
||||||
visual->setPoint1Id(firstPointId);
|
visual->setPoint1Id(firstPointId);
|
||||||
visual->setPoint2Id(basePointId);
|
visual->setPoint2Id(basePointId);
|
||||||
visual->setPoint3Id(thirdPointId);
|
visual->setPoint3Id(thirdPointId);
|
||||||
visual->setLength(formulaLength);
|
visual->setLength(qApp->FormulaToUser(formulaLength));
|
||||||
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
|
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
|
||||||
visual->RefreshGeometry();
|
visual->RefreshGeometry();
|
||||||
vis = visual;
|
vis = visual;
|
||||||
|
|
|
@ -194,7 +194,7 @@ void VToolCutArc::ShowVisualization(bool show)
|
||||||
scene->addItem(visual);
|
scene->addItem(visual);
|
||||||
|
|
||||||
visual->setPoint1Id(curveCutId);
|
visual->setPoint1Id(curveCutId);
|
||||||
visual->setLength(formula);
|
visual->setLength(qApp->FormulaToUser(formula));
|
||||||
visual->RefreshGeometry();
|
visual->RefreshGeometry();
|
||||||
vis = visual;
|
vis = visual;
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,7 @@ void VToolCutArc::FullUpdateFromFile()
|
||||||
{
|
{
|
||||||
VisToolCutArc *visual = qobject_cast<VisToolCutArc *>(vis);
|
VisToolCutArc *visual = qobject_cast<VisToolCutArc *>(vis);
|
||||||
visual->setPoint1Id(curveCutId);
|
visual->setPoint1Id(curveCutId);
|
||||||
visual->setLength(formula);
|
visual->setLength(qApp->FormulaToUser(formula));
|
||||||
visual->RefreshGeometry();
|
visual->RefreshGeometry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,7 +202,7 @@ void VToolCutSpline::ShowVisualization(bool show)
|
||||||
scene->addItem(visual);
|
scene->addItem(visual);
|
||||||
|
|
||||||
visual->setPoint1Id(curveCutId);
|
visual->setPoint1Id(curveCutId);
|
||||||
visual->setLength(formula);
|
visual->setLength(qApp->FormulaToUser(formula));
|
||||||
visual->RefreshGeometry();
|
visual->RefreshGeometry();
|
||||||
vis = visual;
|
vis = visual;
|
||||||
}
|
}
|
||||||
|
@ -238,7 +238,7 @@ void VToolCutSpline::FullUpdateFromFile()
|
||||||
{
|
{
|
||||||
VisToolCutSpline *visual = qobject_cast<VisToolCutSpline *>(vis);
|
VisToolCutSpline *visual = qobject_cast<VisToolCutSpline *>(vis);
|
||||||
visual->setPoint1Id(curveCutId);
|
visual->setPoint1Id(curveCutId);
|
||||||
visual->setLength(formula);
|
visual->setLength(qApp->FormulaToUser(formula));
|
||||||
visual->RefreshGeometry();
|
visual->RefreshGeometry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,7 +257,7 @@ void VToolCutSplinePath::ShowVisualization(bool show)
|
||||||
scene->addItem(visual);
|
scene->addItem(visual);
|
||||||
|
|
||||||
visual->setPoint1Id(curveCutId);
|
visual->setPoint1Id(curveCutId);
|
||||||
visual->setLength(formula);
|
visual->setLength(qApp->FormulaToUser(formula));
|
||||||
visual->RefreshGeometry();
|
visual->RefreshGeometry();
|
||||||
vis = visual;
|
vis = visual;
|
||||||
}
|
}
|
||||||
|
@ -293,7 +293,7 @@ void VToolCutSplinePath::FullUpdateFromFile()
|
||||||
{
|
{
|
||||||
VisToolCutSplinePath *visual = qobject_cast<VisToolCutSplinePath *>(vis);
|
VisToolCutSplinePath *visual = qobject_cast<VisToolCutSplinePath *>(vis);
|
||||||
visual->setPoint1Id(curveCutId);
|
visual->setPoint1Id(curveCutId);
|
||||||
visual->setLength(formula);
|
visual->setLength(qApp->FormulaToUser(formula));
|
||||||
visual->RefreshGeometry();
|
visual->RefreshGeometry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,8 +191,8 @@ void VToolEndLine::FullUpdateFromFile()
|
||||||
{
|
{
|
||||||
VisToolEndLine *visual = qobject_cast<VisToolEndLine *>(vis);
|
VisToolEndLine *visual = qobject_cast<VisToolEndLine *>(vis);
|
||||||
visual->setPoint1Id(basePointId);
|
visual->setPoint1Id(basePointId);
|
||||||
visual->setLength(formulaLength);
|
visual->setLength(qApp->FormulaToUser(formulaLength));
|
||||||
visual->setAngle(formulaAngle);
|
visual->setAngle(qApp->FormulaToUser(formulaAngle));
|
||||||
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
|
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
|
||||||
visual->RefreshGeometry();
|
visual->RefreshGeometry();
|
||||||
}
|
}
|
||||||
|
@ -287,8 +287,8 @@ void VToolEndLine::ShowVisualization(bool show)
|
||||||
scene->addItem(visual);
|
scene->addItem(visual);
|
||||||
|
|
||||||
visual->setPoint1Id(basePointId);
|
visual->setPoint1Id(basePointId);
|
||||||
visual->setLength(formulaLength);
|
visual->setLength(qApp->FormulaToUser(formulaLength));
|
||||||
visual->setAngle(formulaAngle);
|
visual->setAngle(qApp->FormulaToUser(formulaAngle));
|
||||||
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
|
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
|
||||||
visual->RefreshGeometry();
|
visual->RefreshGeometry();
|
||||||
vis = visual;
|
vis = visual;
|
||||||
|
|
|
@ -216,7 +216,7 @@ void VToolNormal::FullUpdateFromFile()
|
||||||
VisToolNormal *visual = qobject_cast<VisToolNormal *>(vis);
|
VisToolNormal *visual = qobject_cast<VisToolNormal *>(vis);
|
||||||
visual->setPoint1Id(basePointId);
|
visual->setPoint1Id(basePointId);
|
||||||
visual->setPoint2Id(secondPointId);
|
visual->setPoint2Id(secondPointId);
|
||||||
visual->setLength(formulaLength);
|
visual->setLength(qApp->FormulaToUser(formulaLength));
|
||||||
visual->setAngle(angle);
|
visual->setAngle(angle);
|
||||||
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
|
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
|
||||||
visual->RefreshGeometry();
|
visual->RefreshGeometry();
|
||||||
|
@ -332,7 +332,7 @@ void VToolNormal::ShowVisualization(bool show)
|
||||||
|
|
||||||
visual->setPoint1Id(basePointId);
|
visual->setPoint1Id(basePointId);
|
||||||
visual->setPoint2Id(secondPointId);
|
visual->setPoint2Id(secondPointId);
|
||||||
visual->setLength(formulaLength);
|
visual->setLength(qApp->FormulaToUser(formulaLength));
|
||||||
visual->setAngle(angle);
|
visual->setAngle(angle);
|
||||||
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
|
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
|
||||||
visual->RefreshGeometry();
|
visual->RefreshGeometry();
|
||||||
|
|
|
@ -236,7 +236,7 @@ void VToolPointOfContact::FullUpdateFromFile()
|
||||||
visual->setPoint1Id(firstPointId);
|
visual->setPoint1Id(firstPointId);
|
||||||
visual->setLineP2Id(secondPointId);
|
visual->setLineP2Id(secondPointId);
|
||||||
visual->setRadiusId(center);
|
visual->setRadiusId(center);
|
||||||
visual->setRadius(arcRadius);
|
visual->setRadius(qApp->FormulaToUser(arcRadius));
|
||||||
visual->RefreshGeometry();
|
visual->RefreshGeometry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -344,7 +344,7 @@ void VToolPointOfContact::ShowVisualization(bool show)
|
||||||
visual->setPoint1Id(firstPointId);
|
visual->setPoint1Id(firstPointId);
|
||||||
visual->setLineP2Id(secondPointId);
|
visual->setLineP2Id(secondPointId);
|
||||||
visual->setRadiusId(center);
|
visual->setRadiusId(center);
|
||||||
visual->setRadius(arcRadius);
|
visual->setRadius(qApp->FormulaToUser(arcRadius));
|
||||||
visual->RefreshGeometry();
|
visual->RefreshGeometry();
|
||||||
vis = visual;
|
vis = visual;
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,7 +242,7 @@ void VToolShoulderPoint::FullUpdateFromFile()
|
||||||
visual->setPoint1Id(pShoulder);
|
visual->setPoint1Id(pShoulder);
|
||||||
visual->setLineP1Id(basePointId);
|
visual->setLineP1Id(basePointId);
|
||||||
visual->setLineP2Id(p2Line);
|
visual->setLineP2Id(p2Line);
|
||||||
visual->setLength(formulaLength);
|
visual->setLength(qApp->FormulaToUser(formulaLength));
|
||||||
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
|
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
|
||||||
visual->RefreshGeometry();
|
visual->RefreshGeometry();
|
||||||
}
|
}
|
||||||
|
@ -359,7 +359,7 @@ void VToolShoulderPoint::ShowVisualization(bool show)
|
||||||
visual->setPoint1Id(pShoulder);
|
visual->setPoint1Id(pShoulder);
|
||||||
visual->setLineP1Id(basePointId);
|
visual->setLineP1Id(basePointId);
|
||||||
visual->setLineP2Id(p2Line);
|
visual->setLineP2Id(p2Line);
|
||||||
visual->setLength(formulaLength);
|
visual->setLength(qApp->FormulaToUser(formulaLength));
|
||||||
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
|
visual->setLineStyle(VAbstractTool::LineStyle(typeLine));
|
||||||
visual->RefreshGeometry();
|
visual->RefreshGeometry();
|
||||||
vis = visual;
|
vis = visual;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user