Salome HOME
Fix for the issue #2753 : error when dump/load script
[modules/shaper.git] / src / SketcherPrs / SketcherPrs_LengthDimension.cpp
index 7472d956b1a723cc55d3ee5563be78d8ada2cfd3..34c7401d2d23bb865c528357a6c0d9cd633390d6 100644 (file)
@@ -94,7 +94,7 @@ void updateArrows(Handle(Prs3d_DimensionAspect) theDimAspect,
     theDimAspect->SetExtensionSize(
         (theTextSize / aViewerScale + SketcherPrs_Tools::getArrowSize()) / 2.0);
   }
-  theDimAspect->TextAspect()->SetFont(Config_PropManager::string(SKETCH_TAB_NAME,
+  theDimAspect->TextAspect()->SetFont(Config_PropManager::string("Visualization",
                                       "dimension_font").c_str());
 
   theDimAspect->SetArrowTailSize(theDimAspect->ArrowAspect()->Length());
@@ -158,7 +158,12 @@ void SketcherPrs_LengthDimension::Compute(
     myPlane = gp_Pln(mySketcherPlane->impl<gp_Ax3>());
 
     DataPtr aData = myConstraint->data();
-    AttributeDoublePtr anAttributeValue = aData->real(SketchPlugin_Constraint::VALUE());
+    AttributeDoublePtr anAttributeValue;
+    if (myConstraint->getKind() == SketchPlugin_ConstraintDistanceHorizontal::ID() ||
+        myConstraint->getKind() == SketchPlugin_ConstraintDistanceVertical::ID())
+      anAttributeValue = aData->real(SketchPlugin_ConstraintDistanceAlongDir::DISTANCE_VALUE_ID());
+    else
+      anAttributeValue = aData->real(SketchPlugin_Constraint::VALUE());
     myValue.init(anAttributeValue);
   }
 
@@ -261,6 +266,15 @@ bool SketcherPrs_LengthDimension::readyToDisplay(ModelAPI_Feature* theConstraint
     if (!aPnt_A || !aPnt_B) // Objects not found
       return false;
 
+    if (theConstraint->getKind() == SketchPlugin_ConstraintDistanceHorizontal::ID()) {
+      if (fabs(aPnt_A->x() - aPnt_B->x()) < Precision::Confusion())
+        return false;
+    }
+    else if (theConstraint->getKind() == SketchPlugin_ConstraintDistanceVertical::ID()) {
+      if (fabs(aPnt_A->y() - aPnt_B->y()) < Precision::Confusion())
+        return false;
+    }
+
     // Get points from these object
     std::shared_ptr<GeomAPI_Pnt> aPoint1 = thePlane->to3D(aPnt_A->x(), aPnt_A->y());
     std::shared_ptr<GeomAPI_Pnt> aPoint2 = thePlane->to3D(aPnt_B->x(), aPnt_B->y());
@@ -297,6 +311,6 @@ void SketcherPrs_LengthDimension::ComputeSelection(const Handle(SelectMgr_Select
     return;
   }
   }
-  SetSelToleranceForText2d(SketcherPrs_Tools::getTextHeight());
+  SetSelToleranceForText2d(SketcherPrs_Tools::getArrowSize()/5.);
   AIS_LengthDimension::ComputeSelection(aSelection, aMode);
 }