+int getDefaultArrowSize()
+{
+ return 20;
+}
+
+int getConfigArrowSize()
+{
+ return Config_PropManager::integer("Visualization", "dimension_arrow_size");
+}
+
+static double MyTextHeight = 16;
+double getTextHeight()
+{
+ return MyTextHeight * MyPixelRatio;
+}
+
+void setTextHeight(double theHeight)
+{
+ MyTextHeight = theHeight;
+}
+
+double getDefaultTextHeight()
+{
+ return 16 * MyPixelRatio;
+}
+
+double getConfigTextHeight()
+{
+ return Config_PropManager::integer("Visualization", "dimension_value_size") * MyPixelRatio;
+}
+
+double getFlyoutDistance(const ModelAPI_Feature* theConstraint)
+{
+ std::shared_ptr<GeomDataAPI_Point2D> aFlyoutPoint =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ const_cast<ModelAPI_Feature*>(
+ theConstraint)->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
+ // for not initialized values return zero distance to avoid Presentation crash
+ if (!aFlyoutPoint->isInitialized())
+ return 0;
+ return aFlyoutPoint->y();
+}
+
+std::shared_ptr<GeomAPI_Pnt> getAnchorPoint(const ModelAPI_Feature* theConstraint,
+ const std::shared_ptr<GeomAPI_Ax3>& thePlane)
+{
+ ModelAPI_Feature* aConstraint = const_cast<ModelAPI_Feature*>(theConstraint);
+ AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
+ aConstraint->attribute(SketchPlugin_Constraint::ENTITY_A()));
+ if (!aRefAttr || !aRefAttr->isObject() || !aRefAttr->object())
+ return std::shared_ptr<GeomAPI_Pnt>();
+
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->object());
+ std::shared_ptr<GeomAPI_Pnt2d> aCenter;
+ if (aFeature->getKind() == SketchPlugin_Arc::ID()) { // arc
+ aCenter = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aFeature->attribute(SketchPlugin_Arc::CENTER_ID()))->pnt();
+ } else if (aFeature->getKind() == SketchPlugin_Circle::ID()) { // circle
+ aCenter = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aFeature->attribute(SketchPlugin_Circle::CENTER_ID()))->pnt();
+ } else
+ return std::shared_ptr<GeomAPI_Pnt>();
+
+ std::shared_ptr<GeomAPI_Pnt2d> anOrigin(new GeomAPI_Pnt2d(0.0, 0.0));
+ std::shared_ptr<GeomAPI_Pnt2d> aFlyoutPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aConstraint->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()))->pnt();
+ double aRadius = std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
+ aConstraint->attribute(SketchPlugin_Constraint::VALUE()))->value();
+ double aLen = aFlyoutPnt->distance(anOrigin);
+ aRadius *= 1.001; // a gap to make point much closer to the circle, but not lying on it
+ aFlyoutPnt->setX(aCenter->x() + aFlyoutPnt->x() * aRadius / aLen);
+ aFlyoutPnt->setY(aCenter->y() + aFlyoutPnt->y() * aRadius / aLen);
+ return thePlane->to3D(aFlyoutPnt->x(), aFlyoutPnt->y());
+}
+
+void sendEmptyPresentationError(ModelAPI_Feature* theFeature, const std::string theError)
+{
+ Events_InfoMessage("SketcherPrs_Tools",
+ "An empty AIS presentation: SketcherPrs_LengthDimension").send();
+ static const Events_ID anEvent = Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION);
+ std::shared_ptr<ModelAPI_Object> aConstraintPtr(theFeature);
+ ModelAPI_EventCreator::get()->sendUpdated(aConstraintPtr, anEvent);
+}