]> OCCT Git - occt-copy.git/commitdiff
Corrected segment value computation with text alignment
authoraba <aba@opencascade.com>
Mon, 10 Aug 2015 14:43:20 +0000 (17:43 +0300)
committeraba <aba@opencascade.com>
Mon, 10 Aug 2015 14:43:20 +0000 (17:43 +0300)
Set text aligned in lengths with centered text label

src/AIS/AIS_Dimension.cxx
src/ViewerTest/ViewerTest_RelationCommands.cxx
tests/bugs/vis/bug26507_2
tests/bugs/vis/bug26507_4

index e7cc88c63a0b58b960cdd576e0ea7719828c3d10..dce54af8404bd81cb47aab0277a59bd8c134e99a 100755 (executable)
@@ -128,9 +128,6 @@ Standard_Real AIS_Dimension::GetValue() const
       return ComputeValue();
     case TOL_Value:
       {
-        /*Standard_PCharacter aCString;
-        myLabel.ToUTF8CString (aCString);
-        return atof (aCString);*/
         return myCustomValue;
       }
     case TOL_Text:
@@ -211,7 +208,7 @@ const gp_Pln& AIS_Dimension::GetPlane() const
 //function : GetGeometryType
 //purpose  : 
 //=======================================================================
-const Standard_Integer AIS_Dimension::GetGeometryType () const
+const Standard_Integer AIS_Dimension::GetGeometryType() const
 {
   return myGeometryType;
 }
@@ -816,24 +813,16 @@ void AIS_Dimension::DrawExtension (const Handle(Prs3d_Presentation)& thePresenta
     if (hasLabel && myLeaderSegmentLength > 0 && myIsTextAligned)
     {
       gp_Lin aSegmentLine (anExtEnd, aTextDir);
-      Standard_Real aSegmentLength = isShortLine ? myLeaderSegmentLength : theLabelWidth + myLeaderSegmentLength;
+      Standard_Real aSegmentLength = (theLabelPosition & LabelPosition_VCenter) ? myLeaderSegmentLength : theLabelWidth + myLeaderSegmentLength;
       aSegmentPoint  = ElCLib::Value (aSegmentLength, aSegmentLine);
-      DrawText (thePresentation,
-                aSegmentPoint,
-                aTextDir,
-                theLabelString,
-                theLabelPosition);
+      aTextPos = (theLabelPosition & LabelPosition_VCenter) ? aSegmentPoint : ElCLib::Value (myLeaderSegmentLength, aSegmentLine);
     }
-    else
-    {
-      DrawText (thePresentation,
-                aTextPos,
-                aTextDir,
-                theLabelString,
-                theLabelPosition);
-    }
-
 
+    DrawText (thePresentation,
+              aTextPos,
+              aTextDir,
+              theLabelString,
+              theLabelPosition);
   }
 
   if (theMode != ComputeMode_All && theMode != ComputeMode_Line)
@@ -988,7 +977,9 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr
                                               : (aCenterLineBegin.XYZ() + aCenterLineEnd.XYZ()) * 0.5;
 
       // Choose a text direction
-      gp_Dir aTextDir = aDimensionLine.Direction();
+      gp_Dir aTextDir = myIsTextAligned
+        ? myTextDir
+        : aDimensionLine.Direction();
 
       // add text primitives
       if (theMode == ComputeMode_All || theMode == ComputeMode_Text)
@@ -1144,7 +1135,7 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr
         Prs3d_Root::NewGroup (thePresentation);
 
         DrawArrow (thePresentation, aFirstArrowBegin, aFirstArrowDir);
-        if (!theIsOneSide && theToDrawDimensionLine)
+        if (!theIsOneSide && (theToDrawDimensionLine || (!isArrowsExternal && !theToDrawDimensionLine) ))
         {
           DrawArrow (thePresentation, aSecondArrowBegin, aSecondArrowDir);
         }
@@ -1210,7 +1201,7 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr
         Prs3d_Root::NewGroup (thePresentation);
 
         DrawArrow (thePresentation, aSecondArrowBegin, aSecondArrowDir);
-        if (!theIsOneSide && theToDrawDimensionLine)
+        if (!theIsOneSide && (theToDrawDimensionLine || (!theToDrawDimensionLine && !isArrowsExternal) ))
         {
           DrawArrow (thePresentation, aFirstArrowBegin, aFirstArrowDir);
         }
index 37094bd17046692f9ff107e3f4218c1fcd30a9b0..61cf07deca02a187e16d7182b55fb874859a341c 100644 (file)
@@ -2886,7 +2886,7 @@ void ViewerTest::RelationCommands(Draw_Interpretor& theCommands)
   theCommands.Add("vdimension",
       "vdimension name {-angle|-length|-radius|-diameter} -shapes shape1 [shape2 [shape3]]\n"
       "[-text 3d|2d wf|sh|wireframe|shading IntegerSize]\n"
-      "[-label left|right|hcenter|hfit top|bottom|vcenter|vfit]\n"
+      "[-label left|right|hcenter|hfit above|below|vcenter|vfit]\n"
       "[-arrow external|internal|fit]\n"
       "[{-arrowlength|-arlen} RealArrowLength]\n"
       "[{-arrowangle|-arangle} ArrowAngle(degrees)]\n"
index fade5990a9177e829645ad801f0ead8e0ed9a5cd..cd28be0ebab5d3f0aa8a0d1f0b4f28e8dce2b752 100644 (file)
@@ -14,16 +14,21 @@ vbottom
 vpoint lengthP1 0 0 0
 vpoint lengthP2 50 100 0
 vpoint lengthP3 -50 100 0
+vpoint lengthP4 0 200 0
 # Text in center - custom aligment does not taken into account
 vdimension dim1 -length -plane xoy -shapes lengthP1 lengthP2 -text 3d -aligntext 1.0 0.0 0.0 -flyout -10
 
 # Text on the right side - it is aligned
-vdimension dim2 -length -plane xoy -shapes lengthP1 lengthP3 -text 3d -aligntext 1.0 0.0 0.0 -segment 15 -label right
+vdimension dim2 -length -plane xoy -shapes lengthP1 lengthP3 -text 3d -aligntext 1.0 0.0 0.0 -segment 0 -label right
 
 # Text on the left side - it is aligned
-vdimension dim3 -length -plane xoy -shapes lengthP2 lengthP3 -text 3d -flyout -10 -aligntext 1.0 0.0 0.0 -segment 10 -label left
+vdimension dim3 -length -plane xoy -shapes lengthP2 lengthP3 -text 3d -flyout -10 -aligntext 1.0 0.0 0.0 -segment 5 -label left
 
+# Text on the left side - it is aligned
+vdimension dim4 -length -plane xoy -shapes lengthP2 lengthP4 -text 3d -flyout -10 -aligntext 1.0 0.0 0.0 -segment 25 -label left
 
+# Text on the left side - it is aligned
+vdimension dim5 -length -plane xoy -shapes lengthP4 lengthP3 -text 3d -flyout -10 -aligntext 1.0 0.0 0.0 -label left above -segment 10 
 vfit
 #finalize and dump
 set only_screen 1
\ No newline at end of file
index 7277924d6f5a66339ecbf2e03f4ba4a0ff53354c..d3df0614a05a06f88996751822490f8e8551caa8 100644 (file)
@@ -17,7 +17,7 @@ vcircle aCircle aCircleP1 aCircleP2 aCircleP3 0
 
 #Check all text and arrow positions
 vdimension aDim1 -radius -shapes aCircle -circleparam 10 -text 3d -label right -arrow external -hidedimline -valuetext "+2.0\n-3.0\nThickness" -aligntext 1.0 0.0 0.0 -segment 15 -label left firstline
-vdimension aDim2 -diameter -shapes aCircle -circleparam 5 -text 3d -label right -arrow external -hidedimline -valuetext "+4.0\n -6.0" -aligntext 1.0 0.0 0.0 -segment 15 -label left firstline
+vdimension aDim2 -diameter -shapes aCircle -circleparam 5 -text 3d -label left -arrow external -hidedimline -valuetext "+4.0\n -6.0" -aligntext 1.0 0.0 0.0 -segment 15 -label left firstline
 vdimension aDim3 -radius -shapes aCircle -circleparam 20 -text 3d -plane zox -label right -arrow external -hidedimline
 vdimension aDim4 -radius -shapes aCircle -circleparam 40 -text 3d -plane zox -label vcenter -arrow internal -hidedimline
 vdimparam aDim3 -text 6