]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/SketchPlugin/SketchPlugin_Line.cpp
Salome HOME
Issue #1652 Add a real widget displaying the length of the line in the panel: correct...
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Line.cpp
index 3c4e19a1a369fe247dc140a81cc63c6815924cc3..2d2c6bc4a9880955de3c1f030c2b2d6cf231ed38 100644 (file)
@@ -27,14 +27,19 @@ SketchPlugin_Line::SketchPlugin_Line()
     : SketchPlugin_SketchEntity()
 {}
 
+void SketchPlugin_Line::initAttributes()
+{
+  SketchPlugin_SketchEntity::initAttributes();
+  /// new attributes should be added to end of the feature in order to provide
+  /// correct attribute values in previous saved studies
+  data()->addAttribute(LENGTH_ID(), ModelAPI_AttributeDouble::typeId());
+}
+
 void SketchPlugin_Line::initDerivedClassAttributes()
 {
   data()->addAttribute(START_ID(), GeomDataAPI_Point2D::typeId());
   data()->addAttribute(END_ID(), GeomDataAPI_Point2D::typeId());
   data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::typeId());
-#ifndef LINE_LENGHT_BLOCKED
-  data()->addAttribute(LENGTH_ID(), ModelAPI_AttributeDouble::typeId());
-#endif
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EXTERNAL_ID());
 }
 
@@ -137,7 +142,6 @@ void SketchPlugin_Line::attributeChanged(const std::string& theID) {
 
 void SketchPlugin_Line::updateLenghtValue()
 {
-#ifndef LINE_LENGHT_BLOCKED
   std::shared_ptr<GeomDataAPI_Point2D> aStartAttr = std::dynamic_pointer_cast<
       GeomDataAPI_Point2D>(data()->attribute(START_ID()));
   std::shared_ptr<GeomDataAPI_Point2D> anEndAttr = std::dynamic_pointer_cast<
@@ -146,5 +150,4 @@ void SketchPlugin_Line::updateLenghtValue()
     double aDistance = aStartAttr->pnt()->distance(anEndAttr->pnt());
     data()->real(LENGTH_ID())->setValue(aDistance);
   }
-#endif
 }