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