From: aba Date: Mon, 10 Aug 2015 14:43:20 +0000 (+0300) Subject: Corrected segment value computation with text alignment X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=60e9342e8e11e0f68773e43e45f1a69c5c5fa50f;p=occt-copy.git Corrected segment value computation with text alignment Set text aligned in lengths with centered text label --- diff --git a/src/AIS/AIS_Dimension.cxx b/src/AIS/AIS_Dimension.cxx index e7cc88c63a..dce54af840 100755 --- a/src/AIS/AIS_Dimension.cxx +++ b/src/AIS/AIS_Dimension.cxx @@ -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); } diff --git a/src/ViewerTest/ViewerTest_RelationCommands.cxx b/src/ViewerTest/ViewerTest_RelationCommands.cxx index 37094bd170..61cf07deca 100644 --- a/src/ViewerTest/ViewerTest_RelationCommands.cxx +++ b/src/ViewerTest/ViewerTest_RelationCommands.cxx @@ -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" diff --git a/tests/bugs/vis/bug26507_2 b/tests/bugs/vis/bug26507_2 index fade5990a9..cd28be0eba 100644 --- a/tests/bugs/vis/bug26507_2 +++ b/tests/bugs/vis/bug26507_2 @@ -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 diff --git a/tests/bugs/vis/bug26507_4 b/tests/bugs/vis/bug26507_4 index 7277924d6f..d3df0614a0 100644 --- a/tests/bugs/vis/bug26507_4 +++ b/tests/bugs/vis/bug26507_4 @@ -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