mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
Corrected segment value computation with text alignment
Set text aligned in lengths with centered text label
This commit is contained in:
@@ -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);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawText (thePresentation,
|
||||
aTextPos,
|
||||
aTextDir,
|
||||
theLabelString,
|
||||
theLabelPosition);
|
||||
aTextPos = (theLabelPosition & LabelPosition_VCenter) ? aSegmentPoint : ElCLib::Value (myLeaderSegmentLength, aSegmentLine);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
@@ -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"
|
||||
|
@@ -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
|
@@ -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
|
||||
|
Reference in New Issue
Block a user