Salome HOME
#858 'Tangency' constraint doesn't work
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Point.cpp
index 97c74f4760dbfc4f52e4e3bab14563effcd24c5f..d831982c1465bbcf4b20c395e617c07b566f39e2 100644 (file)
 using namespace std;
 
 SketchPlugin_Point::SketchPlugin_Point()
+    : SketchPlugin_SketchEntity()
 {
 }
 
 void SketchPlugin_Point::initAttributes()
 {
-  data()->addAttribute(SketchPlugin_Point::COORD_ID(), GeomDataAPI_Point2D::type());
-  data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::type());
+  SketchPlugin_SketchEntity::initAttributes();
+
+  data()->addAttribute(SketchPlugin_Point::COORD_ID(), GeomDataAPI_Point2D::typeId());
+  data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::typeId());
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EXTERNAL_ID());
 }
 
@@ -70,11 +73,12 @@ double SketchPlugin_Point::distanceToPoint(const std::shared_ptr<GeomAPI_Pnt2d>&
 }
 
 bool SketchPlugin_Point::isFixed() {
-  return data()->selection(EXTERNAL_ID())->context();
+  return data()->selection(EXTERNAL_ID())->context().get() != NULL;
 }
 
 void SketchPlugin_Point::attributeChanged(const std::string& theID) {
-  if (theID == EXTERNAL_ID()) {
+  // the second condition for unability to move external point anywhere
+  if (theID == EXTERNAL_ID() || isFixed()) {
     std::shared_ptr<GeomAPI_Shape> aSelection = data()->selection(EXTERNAL_ID())->value();
      // update arguments due to the selection value
     if (aSelection && !aSelection->isNull() && aSelection->isVertex()) {