Salome HOME
#2205 Ability to customize the arrows and texts of dimensions
authornds <nds@opencascade.com>
Tue, 3 Oct 2017 19:11:01 +0000 (22:11 +0300)
committernds <nds@opencascade.com>
Tue, 3 Oct 2017 19:11:01 +0000 (22:11 +0300)
16 files changed:
src/SketchAPI/SketchAPI_Sketch.cpp
src/SketchPlugin/SketchPlugin_ConstraintAngle.cpp
src/SketchPlugin/SketchPlugin_ConstraintAngle.h
src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistance.h
src/SketchPlugin/SketchPlugin_ConstraintDistanceHorizontal.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistanceHorizontal.h
src/SketchPlugin/SketchPlugin_ConstraintDistanceVertical.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistanceVertical.h
src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp
src/SketchPlugin/SketchPlugin_ConstraintRadius.h
src/SketchPlugin/SketchPlugin_Plugin.cpp
src/SketchPlugin/plugin-Sketch.xml
src/SketcherPrs/SketcherPrs_Angle.cpp
src/SketcherPrs/SketcherPrs_LengthDimension.cpp
src/SketcherPrs/SketcherPrs_Radius.cpp

index 5f36a0872b89739ee9b13bbe9dfe7da691049ed7..581990dcf061e3b64587c08e604f2e5b3a2a01e7 100644 (file)
@@ -564,6 +564,8 @@ std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setAngle(
       compositeFeature()->addFeature(SketchPlugin_ConstraintAngle::ID());
   fillAttribute(SketcherPrs_Tools::ANGLE_DIRECT,
       aFeature->integer(SketchPlugin_ConstraintAngle::TYPE_ID()));
+  fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC,
+    aFeature->integer(SketchPlugin_ConstraintAngle::LOCATION_TYPE_ID()));
   // fill the value before llines to avoid calculation of angle value by the Angle feature
   fillAttribute(theValue, aFeature->real(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID()));
   fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
@@ -581,6 +583,8 @@ std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setAngleComplementary(
       compositeFeature()->addFeature(SketchPlugin_ConstraintAngle::ID());
   fillAttribute(SketcherPrs_Tools::ANGLE_COMPLEMENTARY,
       aFeature->integer(SketchPlugin_ConstraintAngle::TYPE_ID()));
+  fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC,
+    aFeature->integer(SketchPlugin_ConstraintAngle::LOCATION_TYPE_ID()));
   fillAttribute(theValue, aFeature->real(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID()));
   fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
   fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
@@ -598,6 +602,8 @@ std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setAngleBackward(
       compositeFeature()->addFeature(SketchPlugin_ConstraintAngle::ID());
   fillAttribute(SketcherPrs_Tools::ANGLE_BACKWARD,
       aFeature->integer(SketchPlugin_ConstraintAngle::TYPE_ID()));
+  fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC,
+    aFeature->integer(SketchPlugin_ConstraintAngle::LOCATION_TYPE_ID()));
   fillAttribute(theValue, aFeature->real(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID()));
   fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
   fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
@@ -638,6 +644,8 @@ std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setDistance(
 {
   std::shared_ptr<ModelAPI_Feature> aFeature =
       compositeFeature()->addFeature(SketchPlugin_ConstraintDistance::ID());
+  fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC,
+    aFeature->integer(SketchPlugin_ConstraintDistance::LOCATION_TYPE_ID()));
   fillAttribute(thePoint, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
   fillAttribute(thePointOrLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
   fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
@@ -669,6 +677,8 @@ std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setHorizontalDistance(
 {
   std::shared_ptr<ModelAPI_Feature> aFeature =
       compositeFeature()->addFeature(SketchPlugin_ConstraintDistanceHorizontal::ID());
+  fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC,
+    aFeature->integer(SketchPlugin_ConstraintDistanceHorizontal::LOCATION_TYPE_ID()));
   fillAttribute(thePoint1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
   fillAttribute(thePoint2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
   fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
@@ -683,6 +693,8 @@ std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setVerticalDistance(
 {
   std::shared_ptr<ModelAPI_Feature> aFeature =
       compositeFeature()->addFeature(SketchPlugin_ConstraintDistanceVertical::ID());
+  fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC,
+    aFeature->integer(SketchPlugin_ConstraintDistanceVertical::LOCATION_TYPE_ID()));
   fillAttribute(thePoint1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
   fillAttribute(thePoint2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
   fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
@@ -756,6 +768,8 @@ std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setLength(
 {
   std::shared_ptr<ModelAPI_Feature> aFeature =
       compositeFeature()->addFeature(SketchPlugin_ConstraintLength::ID());
+  fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC,
+    aFeature->integer(SketchPlugin_ConstraintLength::LOCATION_TYPE_ID()));
   fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
   fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
   aFeature->execute();
@@ -804,6 +818,8 @@ std::shared_ptr<ModelHighAPI_Interface> SketchAPI_Sketch::setRadius(
 {
   std::shared_ptr<ModelAPI_Feature> aFeature =
       compositeFeature()->addFeature(SketchPlugin_ConstraintRadius::ID());
+  fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC,
+    aFeature->integer(SketchPlugin_ConstraintRadius::LOCATION_TYPE_ID()));
   fillAttribute(theCircleOrArc, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
   fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
   aFeature->execute();
index 14815ed666a854c70bbe50069b957b1d1dd37f5e..23bba812a64fff286e9fc83a028c1b1e4ab0e329 100644 (file)
@@ -65,6 +65,9 @@ void SketchPlugin_ConstraintAngle::initAttributes()
                        ModelAPI_AttributeBoolean::typeId());
   data()->addAttribute(SketchPlugin_ConstraintAngle::ANGLE_REVERSED_SECOND_LINE_ID(),
                        ModelAPI_AttributeBoolean::typeId());
+
+  data()->addAttribute(SketchPlugin_ConstraintAngle::LOCATION_TYPE_ID(),
+                       ModelAPI_AttributeInteger::typeId());
 }
 
 void SketchPlugin_ConstraintAngle::colorConfigInfo(std::string& theSection, std::string& theName,
index ba00fbc9d76449eb5753dd92b1f666efe9b67cbd..d0b21dafcada12869676045748b72f2e9f414910 100644 (file)
@@ -75,6 +75,14 @@ class SketchPlugin_ConstraintAngle : public SketchPlugin_ConstraintBase
     return MY_ANGLE_REVERSED_ID;
   }
 
+  /// attribute name of dimension location type
+  inline static const std::string& LOCATION_TYPE_ID()
+  {
+    static const std::string MY_LOCATION_TYPE_ID("LocationType");
+    return MY_LOCATION_TYPE_ID;
+  }
+
+
   /// \brief Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
 
index 9566988fd570640bb00298148e6a39e9d2756479..7532a3e0e1a666a9ebc8397dac76d8d0caf3371b 100644 (file)
@@ -33,6 +33,7 @@
 #include <GeomDataAPI_Point2D.h>
 
 #include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeInteger.h>
 #include <ModelAPI_Data.h>
 
 #include <Config_PropManager.h>
@@ -55,6 +56,9 @@ void SketchPlugin_ConstraintDistance::initAttributes()
   data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
   data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
   data()->addAttribute(SIGNED(), ModelAPI_AttributeBoolean::typeId());
+
+  data()->addAttribute(SketchPlugin_ConstraintDistance::LOCATION_TYPE_ID(),
+                       ModelAPI_AttributeInteger::typeId());
 }
 
 void SketchPlugin_ConstraintDistance::colorConfigInfo(std::string& theSection, std::string& theName,
index e9e4b1501329863f3161ddb006fe920b4b63dedb..c3f5118c4a24f1b755557c43d16aa0578e61536d 100644 (file)
@@ -65,6 +65,13 @@ class SketchPlugin_ConstraintDistance : public SketchPlugin_ConstraintBase
     return MY_SIGNED;
   }
 
+  /// attribute name of dimension location type
+  inline static const std::string& LOCATION_TYPE_ID()
+  {
+    static const std::string MY_LOCATION_TYPE_ID("LocationType");
+    return MY_LOCATION_TYPE_ID;
+  }
+
   /// \brief Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
 
index accd996af2b417ec04c1e7757857003f12276301..c75e83bf570af3d1e3bf955d9b160993a8bffebe 100644 (file)
@@ -32,6 +32,7 @@
 #include <GeomDataAPI_Point2D.h>
 
 #include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeInteger.h>
 
 const double tolerance = 1e-7;
 
@@ -48,6 +49,9 @@ void SketchPlugin_ConstraintDistanceHorizontal::initAttributes()
   data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
   data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
   data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
+
+  data()->addAttribute(SketchPlugin_ConstraintDistanceHorizontal::LOCATION_TYPE_ID(),
+                       ModelAPI_AttributeInteger::typeId());
 }
 
 //*************************************************************************************
index e8f6cb8ebc2d2bb123736442654fbc98c7757a04..c5ddc47fe42e7044cf825520d24e77d6ffd16315 100644 (file)
@@ -52,6 +52,14 @@ public:
     return MY_KIND;
   }
 
+  /// attribute name of dimension location type
+  inline static const std::string& LOCATION_TYPE_ID()
+  {
+    static const std::string MY_LOCATION_TYPE_ID("LocationType");
+    return MY_LOCATION_TYPE_ID;
+  }
+
+
   /// \brief Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
 
index e9f645a0256063bfc40381de14ec9ae4045a84a2..845b3b1cc2175d0245911de3bbc373ceb460dd95 100644 (file)
@@ -32,6 +32,7 @@
 #include <GeomDataAPI_Point2D.h>
 
 #include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeInteger.h>
 
 const double tolerance = 1e-7;
 
@@ -48,6 +49,9 @@ void SketchPlugin_ConstraintDistanceVertical::initAttributes()
   data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
   data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
   data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
+
+  data()->addAttribute(SketchPlugin_ConstraintDistanceVertical::LOCATION_TYPE_ID(),
+                       ModelAPI_AttributeInteger::typeId());
 }
 
 //*************************************************************************************
index 2cdb36d7d0960eef25eaff113e71409808f07773..1bfb6f144dfae47fb61b3be19ba6de6981597d7d 100644 (file)
@@ -52,6 +52,13 @@ public:
     return MY_KIND;
   }
 
+  /// attribute name of dimension location type
+  inline static const std::string& LOCATION_TYPE_ID()
+  {
+    static const std::string MY_LOCATION_TYPE_ID("LocationType");
+    return MY_LOCATION_TYPE_ID;
+  }
+
   /// \brief Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
 
index 16c7b60326aa4e775d6b084fbcec0d8b34aa1720..bd5b0bd7db52cb2faa9065844102b8a8b8365ce5 100644 (file)
@@ -27,6 +27,7 @@
 #include <SketcherPrs_Factory.h>
 
 #include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeInteger.h>
 #include <ModelAPI_Data.h>
 
 #include <GeomAPI_Pnt2d.h>
@@ -52,6 +53,9 @@ void SketchPlugin_ConstraintRadius::initAttributes()
   data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::typeId());
   data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
   data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
+
+  data()->addAttribute(SketchPlugin_ConstraintRadius::LOCATION_TYPE_ID(),
+                       ModelAPI_AttributeInteger::typeId());
 }
 
 void SketchPlugin_ConstraintRadius::colorConfigInfo(std::string& theSection, std::string& theName,
index cdb83eccd522b6ada6ea80c62450dd8bd249b3af..8b52f35939b90b0f71de69f16aa03655ce0aa3fa 100644 (file)
@@ -49,6 +49,13 @@ class SketchPlugin_ConstraintRadius : public SketchPlugin_ConstraintBase
     return MY_KIND;
   }
 
+  /// attribute name of dimension location type
+  inline static const std::string& LOCATION_TYPE_ID()
+  {
+    static const std::string MY_LOCATION_TYPE_ID("LocationType");
+    return MY_LOCATION_TYPE_ID;
+  }
+
   /// \brief Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
 
index 0a1c026780f159025a7b7ca0653c3a74ebde224a..6d3c562e9136803ad8c13b1bd4134808e600f8dc 100644 (file)
@@ -55,6 +55,8 @@
 #include <SketchPlugin_Ellipse.h>
 #include <SketchPlugin_MacroEllipse.h>
 
+#include <SketcherPrs_Tools.h>
+
 #include <Events_Loop.h>
 #include <GeomDataAPI_Dir.h>
 
@@ -66,6 +68,7 @@
 #include <Config_PropManager.h>
 
 #include <memory>
+#include <sstream>
 
 #ifdef _DEBUG
 #include <iostream>
@@ -168,6 +171,18 @@ SketchPlugin_Plugin::SketchPlugin_Plugin()
   Config_PropManager::registerProp("Visualization", "xy_plane_color", "XY plane color",
                                    Config_Prop::Color, XY_PLANE_COLOR);
 #endif
+
+  Config_PropManager::registerProp(SKETCH_TAB_NAME, "dimension_font", "Dimension font", Config_Prop::String,
+                                   "Arial");
+  std::ostringstream aStream;
+  aStream << SketcherPrs_Tools::getDefaultTextHeight();
+  Config_PropManager::registerProp(SKETCH_TAB_NAME, "dimension_value_size", "Dimension value size", Config_Prop::Integer,
+                                   aStream.str());
+  aStream.str("");
+  aStream.clear();
+  aStream << SketcherPrs_Tools::getDefaultArrowSize();
+  Config_PropManager::registerProp(SKETCH_TAB_NAME, "dimension_arrow_size", "Dimension arrow size", Config_Prop::Integer,
+                                   aStream.str());
 }
 
 FeaturePtr SketchPlugin_Plugin::createFeature(std::string theFeatureID)
index 30f03a352431e974b98c6984df3c243aa2f9a523..e03938bed0b1fd0b09205cc21fa9a75d402e9a9b 100644 (file)
@@ -656,6 +656,16 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
           <validator id="GeomValidators_Positive"/>
         </doublevalue_editor>
 
+        <module_choice id="LocationType"
+          widget_type="radiobuttons"
+          buttons_dir="horizontal"
+          label="Location type"
+          tooltip="Type of location"
+          string_list="Left Automatic Right"
+          icons_list="icons/Sketch/location_left.png icons/Sketch/location_automatic.png icons/Sketch/location_right.png"
+          default="1"
+          />
+
         <boolvalue id="SignedDistance" label="Keep orientation" default="true" tooltip="Keep distance orientation" obligatory="0"/>
         <validator id="PartSet_DistanceSelection"/>
       </feature>
@@ -689,6 +699,16 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
 
         <doublevalue_editor label="Value" tooltip="Distance" id="ConstraintValue" default="computed"/>
 
+        <module_choice id="LocationType"
+          widget_type="radiobuttons"
+          buttons_dir="horizontal"
+          label="Location type"
+          tooltip="Type of location"
+          string_list="Left Automatic Right"
+          icons_list="icons/Sketch/location_left.png icons/Sketch/location_automatic.png icons/Sketch/location_right.png"
+          default="1"
+          />
+
         <validator id="PartSet_DistanceSelection"/>
       </feature>
 
@@ -721,6 +741,16 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
 
         <doublevalue_editor label="Value" tooltip="Distance" id="ConstraintValue" default="computed"/>
 
+        <module_choice id="LocationType"
+          widget_type="radiobuttons"
+          buttons_dir="horizontal"
+          label="Location type"
+          tooltip="Type of location"
+          string_list="Left Automatic Right"
+          icons_list="icons/Sketch/location_left.png icons/Sketch/location_automatic.png icons/Sketch/location_right.png"
+          default="1"
+          />
+
         <validator id="PartSet_DistanceSelection"/>
       </feature>
 
@@ -770,6 +800,17 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
           icons_list="icons/Sketch/angle_direct.png icons/Sketch/angle_complementary.png icons/Sketch/angle_backward.png"
           default="0"
           />
+
+        <module_choice id="LocationType"
+          widget_type="radiobuttons"
+          buttons_dir="horizontal"
+          label="Location type"
+          tooltip="Type of location"
+          string_list="Left Automatic Right"
+          icons_list="icons/Sketch/location_left.png icons/Sketch/location_automatic.png icons/Sketch/location_right.png"
+          default="1"
+          />
+
       </feature>
 
       <!--  SketchConstraintRadius  -->
@@ -783,6 +824,17 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
         <doublevalue_editor label="Value" tooltip="Radius" id="ConstraintValue" default="computed">
           <validator id="GeomValidators_Positive"/>
         </doublevalue_editor>
+
+        <module_choice id="LocationType"
+          widget_type="radiobuttons"
+          buttons_dir="horizontal"
+          label="Location type"
+          tooltip="Type of location"
+          string_list="Left Automatic Right"
+          icons_list="icons/Sketch/location_left.png icons/Sketch/location_automatic.png icons/Sketch/location_right.png"
+          default="1"
+          />
+
         <validator id="PartSet_RadiusSelection"/>
       </feature>
 
index c7273954548de55d0a188beb3dcb891e2c22177d..400f0709994b360c20190fd6afd9d5c8671d78db 100644 (file)
 #include <TopExp.hxx>
 #include <BRep_Tool.hxx>
 
+/// Update variable aspect parameters (depending on viewer scale)
+/// \param theDimAspect an aspect to be changed
+/// \param theDimValue an arrow value
+/// \param theTextSize an arrow value
+extern void updateArrows(Handle_Prs3d_DimensionAspect theDimAspect,
+  double theDimValue, double theTextSize, SketcherPrs_Tools::LocationType theLocationType);
+
 #define PI 3.1415926535897932
 
 //#ifndef WNT
@@ -230,8 +237,12 @@ void SketcherPrs_Angle::Compute(const Handle(PrsMgr_PresentationManager3d)& theP
   // Update text visualization: parameter value or parameter text
   myStyleListener->updateDimensions(this, myValue);
 
-  myAspect->SetExtensionSize(myAspect->ArrowAspect()->Length());
-  myAspect->SetArrowTailSize(myAspect->ArrowAspect()->Length());
+  double aTextSize = 0.0;
+  GetValueString(aTextSize);
+  AttributeIntegerPtr aLocationTypeAttr = std::dynamic_pointer_cast<ModelAPI_AttributeInteger>
+    (myConstraint->data()->attribute(SketchPlugin_ConstraintAngle::LOCATION_TYPE_ID()));
+  updateArrows(myAspect, GetValue(), aTextSize,
+    (SketcherPrs_Tools::LocationType)(aLocationTypeAttr->value()));
 
   AIS_AngleDimension::Compute(thePresentationManager, thePresentation, theMode);
 
index 2b55584a000dd1a7123ab14290e5351692c56f2c..9de74eb320b35182c9dc3983a176a034ee6951bb 100644 (file)
@@ -43,7 +43,7 @@
 
 #include <AIS_DisplaySpecialSymbol.hxx>
 
-//#ifdef OCCT_28850_FIXED
+#define OCCT_28850_FIXED
 
 /// Creates an aspect to be shown in length/radius dimension presentations
 /// \return an instance of aspect
@@ -87,6 +87,12 @@ void updateArrows(Handle(Prs3d_DimensionAspect) theDimAspect,
     theDimAspect->SetTextHorizontalPosition(
       theLocationType == SketcherPrs_Tools::LOCATION_LEFT ? Prs3d_DTHP_Left : Prs3d_DTHP_Right);
     theDimAspect->SetArrowOrientation(Prs3d_DAO_External);
+
+    double anArrowLength = theDimAspect->ArrowAspect()->Length();
+    // This is not realy correct way to get viewer scale.
+    double aViewerScale = (double) SketcherPrs_Tools::getDefaultArrowSize() / anArrowLength;
+    theDimAspect->SetExtensionSize(
+        (theTextSize / aViewerScale + SketcherPrs_Tools::getArrowSize()) / 2.0);
   }
 
   theDimAspect->SetArrowTailSize(theDimAspect->ArrowAspect()->Length());
@@ -117,9 +123,9 @@ SketcherPrs_LengthDimension::SketcherPrs_LengthDimension(ModelAPI_Feature* theCo
 
 #ifdef OCCT_28850_FIXED
   if (theConstraint->getKind() == SketchPlugin_ConstraintDistanceHorizontal::ID())
-    SetDirection(true, mySketcherPlane->dirX()->impl<gp_Dir>());
+    SetDirection(mySketcherPlane->dirX()->impl<gp_Dir>(), true);
   else if (theConstraint->getKind() == SketchPlugin_ConstraintDistanceVertical::ID())
-    SetDirection(true, mySketcherPlane->dirY()->impl<gp_Dir>());
+    SetDirection(mySketcherPlane->dirY()->impl<gp_Dir>(), true);
 #endif
 }
 
@@ -162,17 +168,21 @@ void SketcherPrs_LengthDimension::Compute(
   double aTextSize = 0.0;
   GetValueString(aTextSize);
 
-  SketcherPrs_Tools::LocationType aLocationType = SketcherPrs_Tools::LOCATION_AUTOMATIC;
   std::string aLocationAttribute;
-  if (myConstraint->getKind() == SketchPlugin_ConstraintLength::ID())
+  std::string aConstraintKind = myConstraint->getKind();
+  if (aConstraintKind == SketchPlugin_ConstraintLength::ID())
     aLocationAttribute = SketchPlugin_ConstraintLength::LOCATION_TYPE_ID();
-  if (!aLocationAttribute.empty())
-  {
-    std::shared_ptr<ModelAPI_AttributeInteger> aTypeAttr = std::dynamic_pointer_cast<
-      ModelAPI_AttributeInteger>(myConstraint->data()->attribute(aLocationAttribute));
-    aLocationType = (SketcherPrs_Tools::LocationType)(aTypeAttr->value());
-  }
-  updateArrows(DimensionAspect(), GetValue(), aTextSize, aLocationType);
+  else if (aConstraintKind == SketchPlugin_ConstraintDistance::ID())
+    aLocationAttribute = SketchPlugin_ConstraintDistance::LOCATION_TYPE_ID();
+  else if (aConstraintKind == SketchPlugin_ConstraintDistanceHorizontal::ID())
+    aLocationAttribute = SketchPlugin_ConstraintDistanceHorizontal::LOCATION_TYPE_ID();
+  else if (aConstraintKind == SketchPlugin_ConstraintDistanceVertical::ID())
+    aLocationAttribute = SketchPlugin_ConstraintDistanceVertical::LOCATION_TYPE_ID();
+
+  std::shared_ptr<ModelAPI_AttributeInteger> aLocationTypeAttr = std::dynamic_pointer_cast<
+    ModelAPI_AttributeInteger>(myConstraint->data()->attribute(aLocationAttribute));
+  updateArrows(DimensionAspect(), GetValue(), aTextSize,
+    (SketcherPrs_Tools::LocationType)(aLocationTypeAttr->value()));
 
   // Update text visualization: parameter value or parameter text
   myStyleListener->updateDimensions(this, myValue);
index bc784cb38bae61cce5fe03bce358da9eab450438..8e557e32b9c62d10d0afb3fc1604c272dfaa9a9b 100644 (file)
@@ -32,6 +32,7 @@
 #include <GeomAPI_Circ.h>
 #include <GeomAPI_XYZ.h>
 #include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeInteger.h>
 
 #include <gp_Circ.hxx>
 
@@ -163,8 +164,10 @@ void SketcherPrs_Radius::Compute(
   // Update variable aspect parameters (depending on viewer scale)
   double aTextSize = 0.0;
   GetValueString(aTextSize);
-  updateArrows(DimensionAspect(), GetValue(), aTextSize, SketcherPrs_Tools::LOCATION_AUTOMATIC);
-
+  AttributeIntegerPtr aLocationTypeAttr = std::dynamic_pointer_cast<ModelAPI_AttributeInteger>
+    (myConstraint->data()->attribute(SketchPlugin_ConstraintRadius::LOCATION_TYPE_ID()));
+  updateArrows(DimensionAspect(), GetValue(), aTextSize,
+    (SketcherPrs_Tools::LocationType)(aLocationTypeAttr->value()));
 
   AIS_RadiusDimension::Compute(thePresentationManager, thePresentation, theMode);