Sketch: fix a few minor issues:
* fix compiler warning about unused variable * fix const correctness * fix access type of setExpression() * removed duplicated method
This commit is contained in:
@@ -682,7 +682,7 @@ void SketchObject::reverseAngleConstraintToSupplementary(Constraint* constr, int
|
||||
}
|
||||
}
|
||||
|
||||
bool SketchObject::constraintHasExpression(int constNum)
|
||||
bool SketchObject::constraintHasExpression(int constNum) const
|
||||
{
|
||||
App::ObjectIdentifier path = Constraints.createPath(constNum);
|
||||
auto info = getExpression(path);
|
||||
@@ -692,7 +692,7 @@ bool SketchObject::constraintHasExpression(int constNum)
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string SketchObject::getConstraintExpression(int constNum)
|
||||
std::string SketchObject::getConstraintExpression(int constNum) const
|
||||
{
|
||||
App::ObjectIdentifier path = Constraints.createPath(constNum);
|
||||
auto info = getExpression(path);
|
||||
@@ -701,19 +701,17 @@ std::string SketchObject::getConstraintExpression(int constNum)
|
||||
return expression;
|
||||
}
|
||||
|
||||
return "";
|
||||
return {};
|
||||
}
|
||||
|
||||
void SketchObject::setConstraintExpression(int constNum, std::string& newExpression)
|
||||
void SketchObject::setConstraintExpression(int constNum, const std::string& newExpression)
|
||||
{
|
||||
App::ObjectIdentifier path = Constraints.createPath(constNum);
|
||||
auto info = getExpression(path);
|
||||
if (info.expression) {
|
||||
try {
|
||||
std::shared_ptr<App::Expression> expr(App::Expression::parse(this, newExpression));
|
||||
// there is a bug in the SketchObject API because setExpression() is protected but public in DocumentObject
|
||||
App::DocumentObject* base = this;
|
||||
base->setExpression(path, expr);
|
||||
setExpression(path, expr);
|
||||
}
|
||||
catch (const Base::Exception&) {
|
||||
Base::Console().Error("Failed to set constraint expression.");
|
||||
@@ -9160,16 +9158,6 @@ int SketchObject::changeConstraintsLocking(bool bLock)
|
||||
return cntSuccess;
|
||||
}
|
||||
|
||||
bool SketchObject::constraintHasExpression(int constrid) const
|
||||
{
|
||||
App::ObjectIdentifier spath = this->Constraints.createPath(constrid);
|
||||
|
||||
App::PropertyExpressionEngine::ExpressionInfo expr_info = this->getExpression(spath);
|
||||
|
||||
return (expr_info.expression != nullptr);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* \brief SketchObject::port_reversedExternalArcs finds constraints that link to endpoints of
|
||||
* external-geometry arcs, and swaps the endpoints in the constraints. This is needed after CCW
|
||||
|
||||
@@ -273,11 +273,13 @@ public:
|
||||
void reverseAngleConstraintToSupplementary(Constraint* constr, int constNum);
|
||||
|
||||
// Check if a constraint has an expression associated.
|
||||
bool constraintHasExpression(int constNum);
|
||||
bool constraintHasExpression(int constNum) const;
|
||||
// Get a constraint associated expression
|
||||
std::string getConstraintExpression(int constNum);
|
||||
std::string getConstraintExpression(int constNum) const;
|
||||
// Set a constraint associated expression
|
||||
void setConstraintExpression(int constNum, std::string& newExpression);
|
||||
void setConstraintExpression(int constNum, const std::string& newExpression);
|
||||
void setExpression(const App::ObjectIdentifier& path,
|
||||
std::shared_ptr<App::Expression> expr) override;
|
||||
|
||||
/// set the driving status of this constraint and solve
|
||||
int setVirtualSpace(int ConstrId, bool isinvirtualspace);
|
||||
@@ -471,8 +473,6 @@ public:
|
||||
bool isPointOnCurve(int geoIdCurve, double px, double py);
|
||||
double calculateConstraintError(int ConstrId);
|
||||
int changeConstraintsLocking(bool bLock);
|
||||
/// returns whether a given constraint has an associated expression or not
|
||||
bool constraintHasExpression(int constrid) const;
|
||||
|
||||
/// porting functions
|
||||
int port_reversedExternalArcs(bool justAnalyze);
|
||||
@@ -735,9 +735,6 @@ protected:
|
||||
|
||||
void buildShape();
|
||||
|
||||
void setExpression(const App::ObjectIdentifier& path,
|
||||
std::shared_ptr<App::Expression> expr) override;
|
||||
|
||||
std::string validateExpression(const App::ObjectIdentifier& path,
|
||||
std::shared_ptr<const App::Expression> expr);
|
||||
|
||||
|
||||
@@ -1795,6 +1795,8 @@ protected:
|
||||
void makeCts_1Circle(bool& selAllowed, Base::Vector2d onSketchPos)
|
||||
{
|
||||
const Part::Geometry* geom = Obj->getGeometry(selCircleArc[0].GeoId);
|
||||
Q_UNUSED(geom)
|
||||
|
||||
if (availableConstraint == AvailableConstraint::FIRST
|
||||
|| availableConstraint == AvailableConstraint::SECOND) {
|
||||
//Radius/diameter. Mode changes in createRadiusDiameterConstrain.
|
||||
|
||||
Reference in New Issue
Block a user