X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FSketchPlugin_ConstraintCoincidence.cpp;h=3cc02a863e73f99b635880abcd94b982366ebcc6;hb=21a0c85b52bb93f94680e2342370764e6510e387;hp=8d2ab687e1ba5b2804787b0b610777e158369c55;hpb=bb5bba6e567f9cae87f9fbaf584d2d0502ec372e;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp b/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp index 8d2ab687e..3cc02a863 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp @@ -11,11 +11,14 @@ #include #include +#include #include #include #include +#include + SketchPlugin_ConstraintCoincidence::SketchPlugin_ConstraintCoincidence() { } @@ -96,3 +99,29 @@ AttributePoint2DPtr SketchPlugin_ConstraintCoincidence::getPoint(const FeaturePt SketchPlugin_Point::ID(), SketchPlugin_Point::COORD_ID()); return aPoint; } + +void SketchPlugin_ConstraintCoincidence::createCoincidenceFeature(SketchPlugin_Sketch* theSketch, + const std::shared_ptr& thePoint1, + const std::shared_ptr& thePoint2) +{ + FeaturePtr aFeature; + if (theSketch) { + aFeature = theSketch->addFeature(SketchPlugin_ConstraintCoincidence::ID()); + } else { + std::shared_ptr aDoc = theSketch->document(); + aFeature = aDoc->addFeature(SketchPlugin_ConstraintCoincidence::ID()); + } + + std::shared_ptr aData = aFeature->data(); + + std::shared_ptr aRef1 = std::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A())); + aRef1->setAttr(thePoint1); + + std::shared_ptr aRef2 = std::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_B())); + aRef2->setAttr(thePoint2); + + // we need to flush created signal in order to coincidence is processed by solver + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED)); +}