PropertyExpressionEngine: convert to link type property
PropertyExpressionEngine is changed to derived from a new class PropertyExpressionContainer, which is in turn derives from PropertyXLinkContainer. This makes PropertyExpressionEngine a link type property that is capable of external linking. It now uses the unified link property APIs for dependency management and tracking of object life time, re-labeling, etc. ObjectIdentifier is modified to support sub-object reference, but is not exposed to end-user, because expression syntax is kept mostly unchanged, which will be submitted in future PR. There is, however, one small change in expression syntax (ExpressionParser.y) to introduce local property reference to avoid ambiguity mentioned in FreeCAD/FreeCAD#1619 Modified Expression/ExpressionModifier interface to support various link property API for link modification.
This commit is contained in:
@@ -6393,17 +6393,17 @@ std::string SketchObject::validateExpression(const App::ObjectIdentifier &path,
|
||||
return "Reference constraints cannot be set!";
|
||||
}
|
||||
|
||||
std::set<App::ObjectIdentifier> deps;
|
||||
expr->getDeps(deps);
|
||||
auto deps = expr->getDeps();
|
||||
auto it = deps.find(this);
|
||||
if(it!=deps.end()) {
|
||||
auto it2 = it->second.find("Constraints");
|
||||
if(it2 != it->second.end()) {
|
||||
for(auto &oid : it2->second) {
|
||||
const Constraint * constraint = Constraints.getConstraint(oid);
|
||||
|
||||
for (std::set<App::ObjectIdentifier>::const_iterator i = deps.begin(); i != deps.end(); ++i) {
|
||||
const App::Property * prop = (*i).getProperty();
|
||||
|
||||
if (prop == &Constraints) {
|
||||
const Constraint * constraint = Constraints.getConstraint(*i);
|
||||
|
||||
if (!constraint->isDriving)
|
||||
return "Reference constraint from this sketch cannot be used in this expression.";
|
||||
if (!constraint->isDriving)
|
||||
return "Reference constraint from this sketch cannot be used in this expression.";
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
@@ -6468,7 +6468,7 @@ void SketchObject::constraintsRemoved(const std::set<App::ObjectIdentifier> &rem
|
||||
std::set<App::ObjectIdentifier>::const_iterator i = removed.begin();
|
||||
|
||||
while (i != removed.end()) {
|
||||
ExpressionEngine.setValue(*i, boost::shared_ptr<App::Expression>(), 0);
|
||||
ExpressionEngine.setValue(*i, boost::shared_ptr<App::Expression>());
|
||||
++i;
|
||||
}
|
||||
}
|
||||
@@ -6860,9 +6860,9 @@ bool SketchObject::AutoLockTangencyAndPerpty(Constraint *cstr, bool bForce, bool
|
||||
return true;
|
||||
}
|
||||
|
||||
void SketchObject::setExpression(const App::ObjectIdentifier &path, boost::shared_ptr<App::Expression> expr, const char * comment)
|
||||
void SketchObject::setExpression(const App::ObjectIdentifier &path, boost::shared_ptr<App::Expression> expr)
|
||||
{
|
||||
DocumentObject::setExpression(path, expr, comment);
|
||||
DocumentObject::setExpression(path, expr);
|
||||
|
||||
if(noRecomputes) // if we do not have a recompute, the sketch must be solved to update the DoF of the solver, constraints and UI
|
||||
solve();
|
||||
|
||||
Reference in New Issue
Block a user