- AttributePtr aFlyOutAttribute = data()->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT());
- if (!aFlyOutAttribute->isInitialized()) {
- 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);
- std::shared_ptr<GeomAPI_Pnt> aFlyoutPnt = sketch()->to3D(aFlyOutAttr->x(), aFlyOutAttr->y());
- // value calculation
- // TODO: has to be calculated on definition of reference object
- double aDistance = aPoint1->distance(aPoint2);
- std::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = std::dynamic_pointer_cast<
- ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
- double aValue = aDistance;
- if (aValueAttr->isInitialized())
- aValue = aValueAttr->value();
- else
- aValueAttr->setValue(aValue);
- // End TODO
-
- AISObjectPtr anAIS = thePrevious;
- if (!anAIS)
- anAIS = AISObjectPtr(new GeomAPI_AISObject);
- std::shared_ptr<GeomAPI_Pln> aPlane = sketch()->plane();
- anAIS->createDistance(aPoint1, aPoint2, aFlyoutPnt, aPlane, aValue);
-
- // Set color from preferences
- std::vector<int> aRGB = Config_PropManager::color("Visualization", "sketch_dimension_color",
- SKETCH_DIMENSION_COLOR);
- anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
+ AISObjectPtr anAIS = SketcherPrs_Factory::lengthDimensionConstraint(this,
+ sketch(), thePrevious);
+ if (anAIS.get() && !thePrevious.get())
+ SketchPlugin_Tools::setDimensionColor(anAIS);