]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Bug #1279: Bad display of distance constraint in the sktech
authordbv <dbv@opencascade.com>
Fri, 12 Feb 2016 11:21:34 +0000 (14:21 +0300)
committerdbv <dbv@opencascade.com>
Tue, 16 Feb 2016 14:04:44 +0000 (17:04 +0300)
src/PartSet/PartSet_Module.cpp
src/SketcherPrs/SketcherPrs_LengthDimension.cpp
src/SketcherPrs/SketcherPrs_Radius.cpp
src/SketcherPrs/SketcherPrs_Tools.cpp
src/SketcherPrs/SketcherPrs_Tools.h

index aef61e704814ce2dae5edff3c17fe834c57688bf..df2a560b700cbbc1de02f67ac229bc5c22947447 100755 (executable)
@@ -776,7 +776,7 @@ void PartSet_Module::onViewTransformed(int theTrsfType)
   }
   if (aView.IsNull())
     return;
-  double aLen = aView->Convert(20);
+  double aLen = aView->Convert(SketcherPrs_Tools::getDefaultArrowSize());
 
   double aPrevLen = SketcherPrs_Tools::getArrowSize();
   SketcherPrs_Tools::setArrowSize(aLen);
index f70de41f5098242d8fea4d54bd67437daa92efd4..34cae3a54cde252acae1a195cf3517f3ae1420be 100644 (file)
@@ -37,12 +37,13 @@ static const Standard_ExtCharacter MySummSymbol(0x03A3);
 IMPLEMENT_STANDARD_HANDLE(SketcherPrs_LengthDimension, AIS_LengthDimension);
 IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_LengthDimension, AIS_LengthDimension);
 
-SketcherPrs_LengthDimension::SketcherPrs_LengthDimension(ModelAPI_Feature* theConstraint, 
-                        const std::shared_ptr<GeomAPI_Ax3>& thePlane)
-: AIS_LengthDimension(MyDefStart, MyDefEnd, MyDefPln), 
-myConstraint(theConstraint), myPlane(thePlane)
+SketcherPrs_LengthDimension::SketcherPrs_LengthDimension(ModelAPI_Feature* theConstraint,
+                                                         const std::shared_ptr<GeomAPI_Ax3>& thePlane)
+: AIS_LengthDimension(MyDefStart, MyDefEnd, MyDefPln),
+  myConstraint(theConstraint),
+  myPlane(thePlane),
+  myAspect(new Prs3d_DimensionAspect())
 {
-  myAspect = new Prs3d_DimensionAspect();
   myAspect->MakeArrows3d(false);
   myAspect->MakeText3d(false);
   myAspect->MakeTextShaded(false);
@@ -54,7 +55,6 @@ myConstraint(theConstraint), myPlane(thePlane)
   SetDimensionAspect(myAspect);
 }
 
-
 void SketcherPrs_LengthDimension::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
                                  const Handle(Prs3d_Presentation)& thePresentation, 
                                  const Standard_Integer theMode)
@@ -64,13 +64,27 @@ void SketcherPrs_LengthDimension::Compute(const Handle(PrsMgr_PresentationManage
     return;
 
   // compute flyout distance
-  double aD = SketcherPrs_Tools::getFlyoutDistance(myConstraint);
   SetFlyout(SketcherPrs_Tools::getFlyoutDistance(myConstraint));
   SetMeasuredGeometry(aPnt1, aPnt2, myPlane->impl<gp_Ax3>());
 
   // Update variable aspect parameters (depending on viewer scale)
-  myAspect->SetExtensionSize(myAspect->ArrowAspect()->Length());
+  double anArrowLength = myAspect->ArrowAspect()->Length();
+   // This is not realy correct way to get viewer scale.
+  double aViewerScale = (double) SketcherPrs_Tools::getDefaultArrowSize() / anArrowLength;
+  double aDimensionValue = GetValue();
+  double aTextSize = 0.0;
+  GetValueString(aTextSize);
+
+  if(aTextSize > ((aDimensionValue - 3 * SketcherPrs_Tools::getArrowSize()) * aViewerScale)) {
+    myAspect->SetTextHorizontalPosition(Prs3d_DTHP_Left);
+    myAspect->SetArrowOrientation(Prs3d_DAO_External);
+    myAspect->SetExtensionSize(aTextSize / aViewerScale - SketcherPrs_Tools::getArrowSize() / 2.0);
+  } else {
+    myAspect->SetTextHorizontalPosition(Prs3d_DTHP_Center);
+    myAspect->SetArrowOrientation(Prs3d_DAO_Internal);
+  }
   myAspect->SetArrowTailSize(myAspect->ArrowAspect()->Length());
+
   // The value of vertical aligment is sometimes changed
   myAspect->TextAspect()->SetVerticalJustification(Graphic3d_VTA_CENTER);
 
index 458bf517b8fb06c9d64cbf088bc78637a1c85492..56f9d7f0e252e12b4cef13725cff88cf535a0eb2 100644 (file)
@@ -102,8 +102,24 @@ void SketcherPrs_Radius::Compute(const Handle(PrsMgr_PresentationManager3d)& the
   SetMeasuredGeometry(aCirc, anAncorPnt);
   SetCustomValue(aRadius);
 
-  myAspect->SetExtensionSize(myAspect->ArrowAspect()->Length());
+  // Update variable aspect parameters (depending on viewer scale)
+  double anArrowLength = myAspect->ArrowAspect()->Length();
+   // This is not realy correct way to get viewer scale.
+  double aViewerScale = (double) SketcherPrs_Tools::getDefaultArrowSize() / anArrowLength;
+  double aDimensionValue = GetValue();
+  double aTextSize = 0.0;
+  GetValueString(aTextSize);
+
+  if(aTextSize > ((aDimensionValue - 2 * SketcherPrs_Tools::getArrowSize()) * aViewerScale)) {
+    myAspect->SetTextHorizontalPosition(Prs3d_DTHP_Left);
+    myAspect->SetArrowOrientation(Prs3d_DAO_External);
+    myAspect->SetExtensionSize(aTextSize / aViewerScale - SketcherPrs_Tools::getArrowSize() / 2.0);
+  } else {
+    myAspect->SetTextHorizontalPosition(Prs3d_DTHP_Center);
+    myAspect->SetArrowOrientation(Prs3d_DAO_Internal);
+  }
   myAspect->SetArrowTailSize(myAspect->ArrowAspect()->Length());
+
   // The value of vertical aligment is sometimes changed
   myAspect->TextAspect()->SetVerticalJustification(Graphic3d_VTA_CENTER);
 
index 847509a1b046b265feaa1c3607e671cc67d0b7dc..be093bc6907cb17a08113abc0e1609814fda819a 100644 (file)
@@ -194,7 +194,7 @@ std::shared_ptr<GeomAPI_Pnt2d> getProjectionPoint(const FeaturePtr theLine,
 }
 
 
-static double MyArrowSize = 24.;
+static double MyArrowSize = 20;
 double getArrowSize()
 {
   return MyArrowSize;
@@ -205,6 +205,11 @@ void setArrowSize(double theSize)
   MyArrowSize = theSize;
 }
 
+int getDefaultArrowSize()
+{
+  return 20;
+}
+
 static double MyTextHeight = 16;
 double getTextHeight()
 {
index a7c0925b53b194bb321b2da75b90055de369d3d4..0daf047238c24e53990af7e73df539d5d5d00094 100644 (file)
@@ -82,6 +82,9 @@ namespace SketcherPrs_Tools {
   /// \param theSize a size value
   SKETCHERPRS_EXPORT void setArrowSize(double theSize);
 
+  /// Returns default value of dimension arrows size
+  SKETCHERPRS_EXPORT int getDefaultArrowSize();
+
   /// Set value of dimension text height
   /// \param theHeight a height value
   SKETCHERPRS_EXPORT void setTextHeight(double theHeight);