Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_ConstraintLength.cpp
index ea50c3850d38a66e61b00f7a074a6b3416ea1b20..da91dc5835cbead17fa834bec2c063fc18536912 100644 (file)
@@ -50,6 +50,14 @@ void SketchPlugin_ConstraintLength::execute()
     //if(!aValueAttr->isInitialized()) {
     //  aValueAttr->setValue(aLenght);
     //}
+
+    // the value should to be computed here, not in the getAISObject in order to change the model value
+    // inside the object transaction. This is important for creating a constraint by preselection.
+    // The display of the presentation in this case happens after the transaction commit
+    AttributePtr aFlyOutAttribute = data()->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT());
+    if (!aFlyOutAttribute->isInitialized()) {
+      compute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT());
+    }
   }
 }
 
@@ -109,8 +117,7 @@ AISObjectPtr SketchPlugin_ConstraintLength::getAISObject(AISObjectPtr thePreviou
 
   AttributePtr aFlyOutAttribute = data()->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT());
   if (!aFlyOutAttribute->isInitialized()) {
-    if (!compute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()))
-      return thePrevious; // not possible to show length because points are not defined
+    return thePrevious; // not possible to show length because points are not defined
   }
   std::shared_ptr<GeomDataAPI_Point2D> aFlyOutAttr = std::dynamic_pointer_cast<
                                                           GeomDataAPI_Point2D>(aFlyOutAttribute);
@@ -134,8 +141,8 @@ AISObjectPtr SketchPlugin_ConstraintLength::getAISObject(AISObjectPtr thePreviou
   anAIS->createDistance(aPoint1, aPoint2, aFlyoutPnt, aPlane, aValue);
 
   // Set color from preferences
-  std::vector<int> aRGB = 
-    Config_PropManager::color("Visualization", "length_color", LENGTH_COLOR);
+  std::vector<int> aRGB = Config_PropManager::color("Visualization", "sketch_dimension_color",
+                                                    SKETCH_DIMENSION_COLOR);
   anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
   return anAIS;
 }