Speed optimization for class VFormula.
--HG-- branch : develop
This commit is contained in:
parent
e68510cc49
commit
99d6ea5152
|
@ -2286,24 +2286,28 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolSpline(QGraphicsItem *item)
|
|||
angle1.setCheckZero(false);
|
||||
angle1.setToolId(i->getId());
|
||||
angle1.setPostfix(degreeSymbol);
|
||||
angle1.Eval();
|
||||
AddPropertyFormula(tr("C1: angle:"), angle1, AttrAngle1);
|
||||
|
||||
VFormula length1(spl.GetC1LengthFormula(), i->getData());
|
||||
length1.setCheckZero(false);
|
||||
length1.setToolId(i->getId());
|
||||
length1.setPostfix(UnitsToStr(qApp->patternUnit()));
|
||||
length1.Eval();
|
||||
AddPropertyFormula(tr("C1: length:"), length1, AttrLength1);
|
||||
|
||||
VFormula angle2(spl.GetEndAngleFormula(), i->getData());
|
||||
angle2.setCheckZero(false);
|
||||
angle2.setToolId(i->getId());
|
||||
angle2.setPostfix(degreeSymbol);
|
||||
angle2.Eval();
|
||||
AddPropertyFormula(tr("C2: angle:"), angle2, AttrAngle2);
|
||||
|
||||
VFormula length2(spl.GetC2LengthFormula(), i->getData());
|
||||
length2.setCheckZero(false);
|
||||
length2.setToolId(i->getId());
|
||||
length2.setPostfix(UnitsToStr(qApp->patternUnit()));
|
||||
length2.Eval();
|
||||
AddPropertyFormula(tr("C2: length:"), length2, AttrLength2);
|
||||
|
||||
AddPropertyCurvePenStyle(i, tr("Pen style:"), CurvePenStylesPics());
|
||||
|
@ -3008,6 +3012,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline()
|
|||
angle1F.setCheckZero(false);
|
||||
angle1F.setToolId(i->getId());
|
||||
angle1F.setPostfix(degreeSymbol);
|
||||
angle1F.Eval();
|
||||
QVariant angle1;
|
||||
angle1.setValue(angle1F);
|
||||
idToProperty[AttrAngle1]->setValue(angle1);
|
||||
|
@ -3016,6 +3021,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline()
|
|||
length1F.setCheckZero(false);
|
||||
length1F.setToolId(i->getId());
|
||||
length1F.setPostfix(UnitsToStr(qApp->patternUnit()));
|
||||
length1F.Eval();
|
||||
QVariant length1;
|
||||
length1.setValue(length1F);
|
||||
idToProperty[AttrLength1]->setValue(length1);
|
||||
|
@ -3024,6 +3030,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline()
|
|||
angle2F.setCheckZero(false);
|
||||
angle2F.setToolId(i->getId());
|
||||
angle2F.setPostfix(degreeSymbol);
|
||||
angle2F.Eval();
|
||||
QVariant angle2;
|
||||
angle2.setValue(angle2F);
|
||||
idToProperty[AttrAngle2]->setValue(angle2);
|
||||
|
@ -3032,6 +3039,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline()
|
|||
length2F.setCheckZero(false);
|
||||
length2F.setToolId(i->getId());
|
||||
length2F.setPostfix(UnitsToStr(qApp->patternUnit()));
|
||||
length2F.Eval();
|
||||
QVariant length2;
|
||||
length2.setValue(length2F);
|
||||
idToProperty[AttrLength2]->setValue(length2);
|
||||
|
|
|
@ -45,8 +45,14 @@
|
|||
//VFormula
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VFormula::VFormula()
|
||||
:formula(QString()), value(tr("Error")), checkZero(true), data(nullptr), toolId(NULL_ID),
|
||||
postfix(QString()), _error(true), dValue(0)
|
||||
: formula(QString()),
|
||||
value(tr("Error")),
|
||||
checkZero(true),
|
||||
data(nullptr),
|
||||
toolId(NULL_ID),
|
||||
postfix(QString()),
|
||||
_error(true),
|
||||
dValue(0)
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -61,7 +67,6 @@ VFormula::VFormula(const QString &formula, const VContainer *container)
|
|||
dValue(0)
|
||||
{
|
||||
this->formula.replace("\n", " ");// Replace line return with spaces for calc if exist
|
||||
Eval();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -71,22 +76,27 @@ VFormula &VFormula::operator=(const VFormula &formula)
|
|||
{
|
||||
return *this;
|
||||
}
|
||||
this->formula = formula.GetFormula();
|
||||
this->value = formula.getStringValue();
|
||||
this->checkZero = formula.getCheckZero();
|
||||
this->data = formula.getData();
|
||||
this->toolId = formula.getToolId();
|
||||
this->postfix = formula.getPostfix();
|
||||
this->_error = formula.error();
|
||||
this->dValue = formula.getDoubleValue();
|
||||
this->formula = formula.formula;
|
||||
this->value = formula.value;
|
||||
this->checkZero = formula.checkZero;
|
||||
this->data = formula.data;
|
||||
this->toolId = formula.toolId;
|
||||
this->postfix = formula.postfix;
|
||||
this->_error = formula._error;
|
||||
this->dValue = formula.dValue;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VFormula::VFormula(const VFormula &formula)
|
||||
:formula(formula.GetFormula()), value(formula.getStringValue()), checkZero(formula.getCheckZero()),
|
||||
data(formula.getData()), toolId(formula.getToolId()), postfix(formula.getPostfix()), _error(formula.error()),
|
||||
dValue(formula.getDoubleValue())
|
||||
: formula(formula.formula),
|
||||
value(formula.value),
|
||||
checkZero(formula.data),
|
||||
data(formula.getData()),
|
||||
toolId(formula.toolId),
|
||||
postfix(formula.postfix),
|
||||
_error(formula._error),
|
||||
dValue(formula.dValue)
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -103,6 +113,7 @@ bool VFormula::operator==(const VFormula &formula) const
|
|||
return isEqual;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VFormula::operator!=(const VFormula &formula) const
|
||||
{
|
||||
return !VFormula::operator==(formula);
|
||||
|
@ -135,7 +146,6 @@ void VFormula::SetFormula(const QString &value, FormulaType type)
|
|||
formula = value;
|
||||
}
|
||||
formula.replace("\n", " ");// Replace line return with spaces for calc if exist
|
||||
Eval();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,7 +173,6 @@ void VFormula::setCheckZero(bool value)
|
|||
if (checkZero != value)
|
||||
{
|
||||
checkZero = value;
|
||||
Eval();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -179,7 +188,6 @@ void VFormula::setData(const VContainer *value)
|
|||
if (data != value && value != nullptr)
|
||||
{
|
||||
data = value;
|
||||
Eval();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -207,7 +215,6 @@ void VFormula::setPostfix(const QString &value)
|
|||
if (postfix != value)
|
||||
{
|
||||
postfix = value;
|
||||
Eval();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,6 +70,8 @@ public:
|
|||
bool error() const;
|
||||
|
||||
static int FormulaTypeId();
|
||||
|
||||
void Eval();
|
||||
private:
|
||||
QString formula;
|
||||
QString value;
|
||||
|
@ -79,8 +81,6 @@ private:
|
|||
QString postfix;
|
||||
bool _error;
|
||||
qreal dValue;
|
||||
|
||||
void Eval();
|
||||
};
|
||||
Q_DECLARE_METATYPE(VFormula)
|
||||
|
||||
|
|
|
@ -348,6 +348,7 @@ VFormula VToolMove::GetFormulaAngle() const
|
|||
fAngle.setCheckZero(false);
|
||||
fAngle.setToolId(m_id);
|
||||
fAngle.setPostfix(degreeSymbol);
|
||||
fAngle.Eval();
|
||||
return fAngle;
|
||||
}
|
||||
|
||||
|
@ -370,6 +371,7 @@ VFormula VToolMove::GetFormulaRotationAngle() const
|
|||
fAngle.setCheckZero(false);
|
||||
fAngle.setToolId(m_id);
|
||||
fAngle.setPostfix(degreeSymbol);
|
||||
fAngle.Eval();
|
||||
return fAngle;
|
||||
}
|
||||
|
||||
|
@ -392,6 +394,7 @@ VFormula VToolMove::GetFormulaLength() const
|
|||
fLength.setCheckZero(true);
|
||||
fLength.setToolId(m_id);
|
||||
fLength.setPostfix(UnitsToStr(qApp->patternUnit()));
|
||||
fLength.Eval();
|
||||
return fLength;
|
||||
}
|
||||
|
||||
|
|
|
@ -281,6 +281,7 @@ VFormula VToolRotation::GetFormulaAngle() const
|
|||
fAngle.setCheckZero(false);
|
||||
fAngle.setToolId(m_id);
|
||||
fAngle.setPostfix(degreeSymbol);
|
||||
fAngle.Eval();
|
||||
return fAngle;
|
||||
}
|
||||
|
||||
|
|
|
@ -193,6 +193,7 @@ VFormula VToolArc::GetFormulaRadius() const
|
|||
radius.setCheckZero(true);
|
||||
radius.setToolId(m_id);
|
||||
radius.setPostfix(UnitsToStr(qApp->patternUnit()));
|
||||
radius.Eval();
|
||||
return radius;
|
||||
}
|
||||
|
||||
|
@ -221,6 +222,7 @@ VFormula VToolArc::GetFormulaF1() const
|
|||
f1.setCheckZero(false);
|
||||
f1.setToolId(m_id);
|
||||
f1.setPostfix(degreeSymbol);
|
||||
f1.Eval();
|
||||
return f1;
|
||||
}
|
||||
|
||||
|
@ -247,6 +249,7 @@ VFormula VToolArc::GetFormulaF2() const
|
|||
f2.setCheckZero(false);
|
||||
f2.setToolId(m_id);
|
||||
f2.setPostfix(degreeSymbol);
|
||||
f2.Eval();
|
||||
return f2;
|
||||
}
|
||||
|
||||
|
|
|
@ -173,6 +173,7 @@ VFormula VToolArcWithLength::GetFormulaRadius() const
|
|||
radius.setCheckZero(true);
|
||||
radius.setToolId(m_id);
|
||||
radius.setPostfix(UnitsToStr(qApp->patternUnit()));
|
||||
radius.Eval();
|
||||
return radius;
|
||||
}
|
||||
|
||||
|
@ -201,6 +202,7 @@ VFormula VToolArcWithLength::GetFormulaF1() const
|
|||
f1.setCheckZero(false);
|
||||
f1.setToolId(m_id);
|
||||
f1.setPostfix(degreeSymbol);
|
||||
f1.Eval();
|
||||
return f1;
|
||||
}
|
||||
|
||||
|
@ -230,6 +232,7 @@ VFormula VToolArcWithLength::GetFormulaLength() const
|
|||
radius.setCheckZero(true);
|
||||
radius.setToolId(m_id);
|
||||
radius.setPostfix(UnitsToStr(qApp->patternUnit()));
|
||||
radius.Eval();
|
||||
return radius;
|
||||
}
|
||||
|
||||
|
|
|
@ -202,6 +202,7 @@ VFormula VToolEllipticalArc::GetFormulaRadius1() const
|
|||
radius1.setCheckZero(true);
|
||||
radius1.setToolId(m_id);
|
||||
radius1.setPostfix(UnitsToStr(qApp->patternUnit()));
|
||||
radius1.Eval();
|
||||
return radius1;
|
||||
}
|
||||
|
||||
|
@ -230,6 +231,7 @@ VFormula VToolEllipticalArc::GetFormulaRadius2() const
|
|||
radius2.setCheckZero(true);
|
||||
radius2.setToolId(m_id);
|
||||
radius2.setPostfix(UnitsToStr(qApp->patternUnit()));
|
||||
radius2.Eval();
|
||||
return radius2;
|
||||
}
|
||||
|
||||
|
@ -258,6 +260,7 @@ VFormula VToolEllipticalArc::GetFormulaF1() const
|
|||
f1.setCheckZero(false);
|
||||
f1.setToolId(m_id);
|
||||
f1.setPostfix(degreeSymbol);
|
||||
f1.Eval();
|
||||
return f1;
|
||||
}
|
||||
|
||||
|
@ -283,6 +286,7 @@ VFormula VToolEllipticalArc::GetFormulaF2() const
|
|||
f2.setCheckZero(false);
|
||||
f2.setToolId(m_id);
|
||||
f2.setPostfix(degreeSymbol);
|
||||
f2.Eval();
|
||||
return f2;
|
||||
}
|
||||
|
||||
|
@ -308,6 +312,7 @@ VFormula VToolEllipticalArc::GetFormulaRotationAngle() const
|
|||
rotationAngle.setCheckZero(false);
|
||||
rotationAngle.setToolId(m_id);
|
||||
rotationAngle.setPostfix(degreeSymbol);
|
||||
rotationAngle.Eval();
|
||||
return rotationAngle;
|
||||
}
|
||||
|
||||
|
|
|
@ -84,6 +84,7 @@ VFormula VToolCut::GetFormula() const
|
|||
val.setCheckZero(true);
|
||||
val.setToolId(m_id);
|
||||
val.setPostfix(UnitsToStr(qApp->patternUnit()));
|
||||
val.Eval();
|
||||
return val;
|
||||
}
|
||||
|
||||
|
|
|
@ -234,6 +234,7 @@ VFormula VToolCurveIntersectAxis::GetFormulaAngle() const
|
|||
fAngle.setCheckZero(false);
|
||||
fAngle.setToolId(m_id);
|
||||
fAngle.setPostfix(degreeSymbol);
|
||||
fAngle.Eval();
|
||||
return fAngle;
|
||||
}
|
||||
|
||||
|
|
|
@ -236,6 +236,7 @@ VFormula VToolEndLine::GetFormulaAngle() const
|
|||
fAngle.setCheckZero(false);
|
||||
fAngle.setToolId(m_id);
|
||||
fAngle.setPostfix(degreeSymbol);
|
||||
fAngle.Eval();
|
||||
return fAngle;
|
||||
}
|
||||
|
||||
|
|
|
@ -205,6 +205,7 @@ VFormula VToolLineIntersectAxis::GetFormulaAngle() const
|
|||
fAngle.setCheckZero(false);
|
||||
fAngle.setToolId(m_id);
|
||||
fAngle.setPostfix(degreeSymbol);
|
||||
fAngle.Eval();
|
||||
return fAngle;
|
||||
}
|
||||
|
||||
|
|
|
@ -220,6 +220,7 @@ VFormula VToolLinePoint::GetFormulaLength() const
|
|||
fLength.setCheckZero(true);
|
||||
fLength.setToolId(m_id);
|
||||
fLength.setPostfix(UnitsToStr(qApp->patternUnit()));
|
||||
fLength.Eval();
|
||||
|
||||
return fLength;
|
||||
}
|
||||
|
|
|
@ -197,6 +197,7 @@ VFormula VToolPointFromCircleAndTangent::GetCircleRadius() const
|
|||
radius.setCheckZero(true);
|
||||
radius.setToolId(m_id);
|
||||
radius.setPostfix(UnitsToStr(qApp->patternUnit()));
|
||||
radius.Eval();
|
||||
return radius;
|
||||
}
|
||||
|
||||
|
|
|
@ -392,6 +392,7 @@ VFormula VToolPointOfContact::getArcRadius() const
|
|||
radius.setCheckZero(true);
|
||||
radius.setToolId(m_id);
|
||||
radius.setPostfix(UnitsToStr(qApp->patternUnit()));
|
||||
radius.Eval();
|
||||
|
||||
return radius;
|
||||
}
|
||||
|
|
|
@ -203,6 +203,7 @@ VFormula VToolPointOfIntersectionCircles::GetFirstCircleRadius() const
|
|||
radius.setCheckZero(true);
|
||||
radius.setToolId(m_id);
|
||||
radius.setPostfix(UnitsToStr(qApp->patternUnit()));
|
||||
radius.Eval();
|
||||
return radius;
|
||||
}
|
||||
|
||||
|
@ -227,6 +228,7 @@ VFormula VToolPointOfIntersectionCircles::GetSecondCircleRadius() const
|
|||
radius.setCheckZero(true);
|
||||
radius.setToolId(m_id);
|
||||
radius.setPostfix(UnitsToStr(qApp->patternUnit()));
|
||||
radius.Eval();
|
||||
return radius;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user