1 #include <SketchSolver_ConstraintMiddle.h>
3 SketchSolver_ConstraintMiddle::SketchSolver_ConstraintMiddle(ConstraintPtr theConstraint)
4 : SketchSolver_Constraint(theConstraint)
8 void SketchSolver_ConstraintMiddle::notifyCoincidenceChanged(
9 EntityWrapperPtr theCoincAttr1,
10 EntityWrapperPtr theCoincAttr2)
12 // Check the coincidence between point and line has been changed
15 EntityWrapperPtr anEntities[2] = {theCoincAttr1, theCoincAttr2};
16 for (int i = 0; i < 2; ++i) {
17 if (anEntities[i]->type() == ENTITY_POINT)
18 aPoint = anEntities[i]->baseAttribute();
19 else if (anEntities[i]->type() == ENTITY_LINE)
20 aLine = anEntities[i]->baseFeature();
22 if (!aPoint || !aLine)
25 // Check the attributes of middle-point constraint are the same point and line
26 bool isSameAttr = true;
27 for (int i = 0; i < 2 && isSameAttr; ++i) {
28 AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
29 myBaseConstraint->attribute(SketchPlugin_Constraint::ATTRIBUTE(i)));
30 if (aRefAttr->isObject()) {
31 FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->object());
32 isSameAttr = (aFeature == aLine);
34 isSameAttr = (aRefAttr->attr() == aPoint);