From d7bffd44eacc919e14267de0e5db68deab50365d Mon Sep 17 00:00:00 2001 From: apl Date: Thu, 21 Nov 2013 17:27:33 +0400 Subject: [PATCH] 0024326: Get rid of confusing extension line 1) Removed confusing part of labeled extension for 3d text. 2) Removed unused "TextOffset" property of AIS_Dimension class, revised function of "ExtensionSize" property. 3) Added options to specify automatic or user-defined arrow orientation and value label positioning to dimension aspect enumerations. 4) Use proper naming: Prs3d_DimensionTextVerticalPosition, Prs3d_DimensionTextHorizontalPosition instead of Prs3d_HorizontalTextAlignment, Prs3d_VerticalTextAlignment. Correction of label length computing method. --- src/AIS/AIS_AngleDimension.cxx | 447 +++++++------- src/AIS/AIS_AngleDimension.hxx | 30 +- src/AIS/AIS_DiameterDimension.cxx | 102 +--- src/AIS/AIS_DiameterDimension.hxx | 10 +- src/AIS/AIS_Dimension.cxx | 893 ++++++++++++++-------------- src/AIS/AIS_Dimension.hxx | 139 +++-- src/AIS/AIS_LengthDimension.cxx | 146 +---- src/AIS/AIS_LengthDimension.hxx | 32 +- src/AIS/AIS_RadiusDimension.cxx | 115 +--- src/AIS/AIS_RadiusDimension.hxx | 23 +- src/Prs3d/Prs3d.cdl | 29 +- src/Prs3d/Prs3d_DimensionAspect.cdl | 44 +- src/Prs3d/Prs3d_DimensionAspect.cxx | 109 ++-- src/QABugs/QABugs_16.cxx | 2 +- tests/bugs/vis/bug24133_1 | 6 +- tests/bugs/vis/bug24133_2 | 7 +- tests/bugs/vis/bug24133_3 | 23 +- tests/bugs/vis/bug24133_4 | 11 +- tests/bugs/vis/bug24288_1 | 12 +- tests/bugs/vis/bug24288_2 | 12 +- tests/bugs/vis/bug24288_3 | 12 +- 21 files changed, 1016 insertions(+), 1188 deletions(-) diff --git a/src/AIS/AIS_AngleDimension.cxx b/src/AIS/AIS_AngleDimension.cxx index 321014fca2..e9432be35f 100755 --- a/src/AIS/AIS_AngleDimension.cxx +++ b/src/AIS/AIS_AngleDimension.cxx @@ -21,107 +21,57 @@ #include #include -#include -#include #include -#include #include #include #include -#include - -#include -#include - #include -#include - -#include -#include -#include #include -#include -#include #include -#include -#include -#include -#include -#include #include -#include -#include -#include -#include -#include #include #include -#include #include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include #include - #include #include -#include #include -#include -#include #include -#include -#include -#include #include +#include #include #include #include #include #include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include #include IMPLEMENT_STANDARD_HANDLE (AIS_AngleDimension, AIS_Dimension) IMPLEMENT_STANDARD_RTTIEXT (AIS_AngleDimension, AIS_Dimension) +namespace +{ + static const TCollection_ExtendedString THE_EMPTY_LABEL; + static const Standard_ExtCharacter THE_DEGREE_SYMBOL (0x00B0); +}; + //======================================================================= //function : init //purpose : Private constructor for default initialization //======================================================================= - void AIS_AngleDimension::init() { - SetKindOfDimension (AIS_KOD_PLANEANGLE); - SetFlyout (15.0); // Default values of units UnitsAPI::SetLocalSystem (UnitsAPI_SI); SetUnitsQuantity ("PLANE ANGLE"); SetModelUnits ("rad"); SetDisplayUnits ("deg"); - SetSpecialSymbol (0x00B0); + SetSpecialSymbol (THE_DEGREE_SYMBOL); SetDisplaySpecialSymbol (AIS_DSS_After); + SetFlyout (15.0); + SetKindOfDimension (AIS_KOD_PLANEANGLE); MakeUnitsDisplayed (Standard_False); } @@ -129,7 +79,6 @@ void AIS_AngleDimension::init() //function : Constructor //purpose : Two edges dimension //======================================================================= - AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Edge& theFirstEdge, const TopoDS_Edge& theSecondEdge) : AIS_Dimension(), @@ -137,8 +86,8 @@ AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Edge& theFirstEdge, { init(); myShapesNumber = 2; - myFirstShape = theFirstEdge; - mySecondShape = theSecondEdge; + myFirstShape = theFirstEdge; + mySecondShape = theSecondEdge; } //======================================================================= @@ -146,7 +95,6 @@ AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Edge& theFirstEdge, //purpose : Two edges dimension // is used in case of Angle=PI //======================================================================= - AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Edge& theFirstEdge, const TopoDS_Edge& theSecondEdge, const gp_Pln& thePlane) @@ -155,28 +103,8 @@ AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Edge& theFirstEdge, { init(); myShapesNumber = 2; - myFirstShape = theFirstEdge; - mySecondShape = theSecondEdge; - SetWorkingPlane (thePlane); -} - -//======================================================================= -//function : Constructor -//purpose : Two edges dimension with aspect -// is used in case of Angle=PI -//======================================================================= - -AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Edge& theFirstEdge, - const TopoDS_Edge& theSecondEdge, - const gp_Pln& thePlane, - const Handle(Prs3d_DimensionAspect)& theDimensionAspect, - const Standard_Real theExtensionSize) -: AIS_Dimension (theDimensionAspect,theExtensionSize), - myIsFlyoutLines (Standard_True) -{ - myShapesNumber = 2; - myFirstShape = theFirstEdge; - mySecondShape = theSecondEdge; + myFirstShape = theFirstEdge; + mySecondShape = theSecondEdge; SetWorkingPlane (thePlane); } @@ -184,7 +112,6 @@ AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Edge& theFirstEdge, //function : Constructor //purpose : Three points dimension //======================================================================= - AIS_AngleDimension::AIS_AngleDimension (const gp_Pnt& theFirstPoint, const gp_Pnt& theSecondPoint, const gp_Pnt& theThirdPoint) @@ -193,52 +120,30 @@ AIS_AngleDimension::AIS_AngleDimension (const gp_Pnt& theFirstPoint, { init(); myIsInitialized = Standard_True; - myFirstPoint = theFirstPoint; - myCenter = theSecondPoint; - mySecondPoint = theThirdPoint; - myShapesNumber = 3; -} - -//======================================================================= -//function : Constructor -//purpose : Three points dimension -//======================================================================= - -AIS_AngleDimension::AIS_AngleDimension (const gp_Pnt& theFirstPoint, - const gp_Pnt& theSecondPoint, - const gp_Pnt& theThirdPoint, - const Handle(Prs3d_DimensionAspect)& theDimensionAspect, - const Standard_Real theExtensionSize) -: AIS_Dimension (theDimensionAspect,theExtensionSize), - myIsFlyoutLines (Standard_True) -{ - myIsInitialized = Standard_True; - myFirstPoint = theFirstPoint; - myCenter = theSecondPoint; - mySecondPoint = theThirdPoint; - myShapesNumber =3; + myFirstPoint = theFirstPoint; + myCenter = theSecondPoint; + mySecondPoint = theThirdPoint; + myShapesNumber = 3; } //======================================================================= //function : Constructor //purpose : Cone dimension //======================================================================= - AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Face& theCone) : AIS_Dimension(), myIsFlyoutLines (Standard_True) { init(); myIsInitialized = Standard_False; - myFirstShape = theCone; - myShapesNumber = 1; + myFirstShape = theCone; + myShapesNumber = 1; } //======================================================================= //function : Constructor //purpose : Two faces dimension //======================================================================= - AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Face& theFirstFace, const TopoDS_Face& theSecondFace, const gp_Ax1& theAxis) @@ -247,9 +152,9 @@ AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Face& theFirstFace, { init(); myIsInitialized = Standard_False; - myFirstShape = theFirstFace; - mySecondShape = theSecondFace; - myShapesNumber = 2; + myFirstShape = theFirstFace; + mySecondShape = theSecondFace; + myShapesNumber = 2; gp_Pln aPlane; aPlane.SetAxis (theAxis); SetWorkingPlane (aPlane); @@ -259,7 +164,6 @@ AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Face& theFirstFace, //function : SetFirstShape //purpose : //======================================================================= - void AIS_AngleDimension::SetFirstShape (const TopoDS_Shape& theShape, const Standard_Boolean isSingleShape /*= Standard_False*/) { @@ -275,7 +179,6 @@ void AIS_AngleDimension::SetFirstShape (const TopoDS_Shape& theShape, // centers; // -1 if center is below center. //======================================================================= - Standard_Integer AIS_AngleDimension::aboveInBelowCone (const gp_Circ &theCMax, const gp_Circ &theCMin, const gp_Circ &theC) @@ -294,7 +197,6 @@ Standard_Integer AIS_AngleDimension::aboveInBelowCone (const gp_Circ &theCMax, //function : initConeAngle //purpose : initialization of the cone angle //======================================================================= - Standard_Boolean AIS_AngleDimension::initConeAngle (const TopoDS_Face& theCone) { if (theCone.IsNull ()) @@ -397,7 +299,6 @@ Standard_Boolean AIS_AngleDimension::initConeAngle (const TopoDS_Face& theCone) //function : initTwoFacesAngle //purpose : initialization of angle dimension between two faces //======================================================================= - Standard_Boolean AIS_AngleDimension::initTwoFacesAngle () { TopoDS_Face aFirstFace = TopoDS::Face (myFirstShape); @@ -458,7 +359,6 @@ Standard_Boolean AIS_AngleDimension::initTwoFacesAngle () //function : countDefaultPlane //purpose : //======================================================================= - void AIS_AngleDimension::countDefaultPlane () { if (!myIsInitialized) @@ -475,7 +375,6 @@ void AIS_AngleDimension::countDefaultPlane () //function : computeValue //purpose : //======================================================================= - void AIS_AngleDimension::computeValue () { gp_Vec aVec1 (myCenter, myFirstPoint), @@ -491,7 +390,6 @@ void AIS_AngleDimension::computeValue () // If intersection between two edges doesn't exist // is set to false //======================================================================= - Standard_Boolean AIS_AngleDimension::initTwoEdgesAngle () { // Data initialization @@ -636,21 +534,6 @@ Standard_Boolean AIS_AngleDimension::initTwoEdgesAngle () return Standard_True; } -//======================================================================= -//function : canTextBeInCenter -//purpose : Auxiliary method to arrange text and arrows -//======================================================================= - -Standard_Boolean AIS_AngleDimension::canTextBeInCenter (const gp_Pnt& theFirstAttach, - const gp_Pnt& theSecondAttach, - const Quantity_Length& theTextLength, - const Quantity_Length& theArrowLength) -{ - gp_Vec anAttachVector (theFirstAttach, theSecondAttach); - Standard_Real aValue = anAttachVector.Magnitude(); - return (aValue < theTextLength + 2.*theArrowLength) ? Standard_False : Standard_True; -} - //======================================================================= //function: getCenterOnArc //purpose : @@ -685,12 +568,12 @@ gp_Pnt AIS_AngleDimension::getCenterOnArc (const gp_Pnt& theFirstAttach, //function: drawArcWithText //purpose : //======================================================================= - void AIS_AngleDimension::drawArcWithText (const Handle(Prs3d_Presentation)& thePresentation, const gp_Pnt& theFirstAttach, const gp_Pnt& theSecondAttach, const TCollection_ExtendedString& theText, - const AIS_DimensionDisplayMode theMode) + const AIS_DimensionDisplayMode theMode, + const Standard_Integer theLabelPosition) { gp_Pnt2d aCenter2d = ProjLib::Project (GetWorkingPlane(), myCenter), aFirstAttach2d = ProjLib::Project (GetWorkingPlane(), theFirstAttach), @@ -717,7 +600,8 @@ void AIS_AngleDimension::drawArcWithText (const Handle(Prs3d_Presentation)& theP gp_Vec aVec (theFirstAttach, theSecondAttach); Standard_Real aTextWidth = drawText (thePresentation, myIsTextReversed ? aVec.Reversed() : aVec, - theText,theMode); + theText, theMode, + theLabelPosition); // Getting text begin and end points gp_Pnt2d aTextBeginPnt = ElCLib::Value ((ElCLib::Parameter (anAttachLine2d, aFirstAttach2d) + @@ -750,14 +634,12 @@ void AIS_AngleDimension::drawArcWithText (const Handle(Prs3d_Presentation)& theP drawArc (thePresentation, theFirstAttach, aTextBeginOnArc, myCenter, aRadius, theMode); drawArc (thePresentation, aTextEndOnArc, theSecondAttach, myCenter, aRadius, theMode); } - } //======================================================================= //function : drawArc //purpose : draws the arc between two attach points //======================================================================= - void AIS_AngleDimension::drawArc (const Handle(Prs3d_Presentation)& thePresentation, const gp_Pnt& theFirstAttach, const gp_Pnt& theSecondAttach, @@ -766,8 +648,6 @@ void AIS_AngleDimension::drawArc (const Handle(Prs3d_Presentation)& thePresentat const AIS_DimensionDisplayMode theMode) { Handle(SelectMgr_EntityOwner) anEmptyOwner; - Prs3d_Root::CurrentGroup (thePresentation)-> - SetPrimitivesAspect(myDrawer->DimensionAspect()->LineAspect()->Aspect()); gp_Vec aCenterToFirstVec (theCenter,theFirstAttach); gp_Vec aCenterToSecondVec (theCenter,theSecondAttach); @@ -803,6 +683,8 @@ void AIS_AngleDimension::drawArc (const Handle(Prs3d_Presentation)& thePresentat { Prs3d_Root::CurrentGroup (thePresentation)->SetStencilTestOptions (Standard_True); } + Handle(Graphic3d_AspectLine3d) aDimensionLineStyle = myDrawer->DimensionAspect()->LineAspect()->Aspect(); + Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionLineStyle); Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments); if (!myDrawer->DimensionAspect()->IsText3d() && theMode == AIS_DDM_All) { @@ -814,7 +696,6 @@ void AIS_AngleDimension::drawArc (const Handle(Prs3d_Presentation)& thePresentat //function : Compute //purpose : Having three gp_Pnt points compute presentation //======================================================================= - void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePM*/, const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode) @@ -857,139 +738,234 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /* // Parameters for presentation Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect(); - Prs3d_Root::CurrentGroup(thePresentation)-> - SetPrimitivesAspect(aDimensionAspect->LineAspect()->Aspect()); + + Prs3d_Root::CurrentGroup(thePresentation)->SetPrimitivesAspect(aDimensionAspect->LineAspect()->Aspect()); + Quantity_Length anArrowLength = aDimensionAspect->ArrowAspect()->Length(); + if (!myIsValueCustom) - computeValue (); + { + computeValue(); + } + TCollection_ExtendedString aValueString; Standard_Real aTextLength; getTextWidthAndString (aTextLength, aValueString); + if (!myIsWorkingPlaneCustom) + { countDefaultPlane(); + } + gp_Pnt aFirstAttach = myCenter.Translated (gp_Vec(myCenter, myFirstPoint).Normalized() * GetFlyout()); gp_Pnt aSecondAttach = myCenter.Translated (gp_Vec(myCenter, mySecondPoint).Normalized() * GetFlyout()); - // Attach points and radius - if (aDimensionAspect->HorizontalTextAlignment () == Prs3d_HTA_Center) - { - aDimensionAspect->SetArrowOrientation (Prs3d_DAO_Internal); - if (!canTextBeInCenter (aFirstAttach, aSecondAttach, aTextLength, anArrowLength)) + // Handle user-defined and automatic arrow placement + bool isArrowsExternal = false; + switch (aDimensionAspect->ArrowOrientation()) + { + case Prs3d_DAO_External: isArrowsExternal = true; break; + case Prs3d_DAO_Internal: isArrowsExternal = false; break; + case Prs3d_DAO_Fit: { - aDimensionAspect->SetArrowOrientation (Prs3d_DAO_External); - aDimensionAspect->SetHorizontalTextAlignment (Prs3d_HTA_Left); + gp_Vec anAttachVector (aFirstAttach, aSecondAttach); + Standard_Real aDimensionWidth = anAttachVector.Magnitude(); + Standard_Real anArrowsWidth = anArrowLength * 2.0; + + isArrowsExternal = aDimensionWidth < aTextLength + anArrowsWidth; + break; } } - else - aDimensionAspect->SetArrowOrientation (Prs3d_DAO_External); //Arrows positions and directions - gp_Vec aFirstArrowVec = (gp_Vec(myCenter, aFirstAttach)^gp_Vec(GetWorkingPlane().Axis().Direction())).Normalized().Reversed()*anArrowLength; - gp_Vec aSecondArrowVec = (gp_Vec(myCenter, aSecondAttach)^gp_Vec(GetWorkingPlane().Axis().Direction())).Normalized()*anArrowLength; + gp_Vec aWPDir = gp_Vec (GetWorkingPlane().Axis().Direction()); - gp_Pnt aFirstArrowBegin, - aFirstArrowEnd, - aSecondArrowBegin, - aSecondArrowEnd; + gp_Dir aFirstExtensionDir = gp_Vec (myCenter, aFirstAttach) ^ aWPDir; + gp_Dir aSecondExtensionDir = gp_Vec (myCenter, aSecondAttach)^ aWPDir.Reversed(); - if (aDimensionAspect->GetArrowOrientation() == Prs3d_DAO_External) + gp_Vec aFirstArrowVec = gp_Vec (aFirstExtensionDir) * anArrowLength; + gp_Vec aSecondArrowVec = gp_Vec (aSecondExtensionDir) * anArrowLength; + + gp_Pnt aFirstArrowBegin (0.0, 0.0, 0.0); + gp_Pnt aFirstArrowEnd (0.0, 0.0, 0.0); + gp_Pnt aSecondArrowBegin (0.0, 0.0, 0.0); + gp_Pnt aSecondArrowEnd (0.0, 0.0, 0.0); + + if (isArrowsExternal) { aFirstArrowVec.Reverse(); aSecondArrowVec.Reverse(); - - aFirstArrowBegin = aFirstAttach.Translated (aFirstArrowVec); - aFirstArrowEnd = aFirstAttach; - aSecondArrowBegin = aSecondAttach; - aSecondArrowEnd = aSecondAttach.Translated (aSecondArrowVec); - } - else - { - aFirstArrowBegin = aFirstAttach; - aFirstArrowEnd = aFirstAttach.Translated (aFirstArrowVec); - aSecondArrowBegin = aSecondAttach.Translated (aSecondArrowVec); - aSecondArrowEnd = aSecondAttach; } - // Fill presentation - Handle(Graphic3d_ArrayOfSegments) aPrimSegments; - Standard_Boolean isTextInCenter = aDimensionAspect->VerticalTextAlignment() == Prs3d_VTA_Center; - if (aDimensionAspect->HorizontalTextAlignment() == Prs3d_HTA_Center) + aFirstArrowBegin = aFirstAttach; + aSecondArrowBegin = aSecondAttach; + aFirstArrowEnd = aFirstAttach.Translated (-aFirstArrowVec); + aSecondArrowEnd = aSecondAttach.Translated (-aSecondArrowVec); + + Standard_Integer aLabelPosition = LabelPosition_None; + + // Handle user-defined and automatic text placement + switch (aDimensionAspect->TextHorizontalPosition()) { - // Important! Current implementation doesn't draw the extensions here - aPrimSegments = new Graphic3d_ArrayOfSegments (4); - // Get text begin and end positions (text is positioned in the center between two attach points) - gp_Pnt aTextBeginOnArc, aTextEndOnArc, anArcCenter; - if (isTextInCenter && aDimensionAspect->IsText3d()) + case Prs3d_DTHP_Left : aLabelPosition |= LabelPosition_Left; break; + case Prs3d_DTHP_Right : aLabelPosition |= LabelPosition_Right; break; + case Prs3d_DTHP_Center: aLabelPosition |= LabelPosition_HCenter; break; + case Prs3d_DTHP_Fit: { - drawArcWithText (thePresentation, aFirstAttach, aSecondAttach, aValueString, (AIS_DimensionDisplayMode)theMode); + gp_Vec anAttachVector (aFirstAttach, aSecondAttach); + Standard_Real aDimensionWidth = anAttachVector.Magnitude(); + Standard_Real anArrowsWidth = anArrowLength * 2.0; + Standard_Real aContentWidth = isArrowsExternal ? aTextLength : aTextLength + anArrowsWidth; + + aLabelPosition |= aDimensionWidth < aContentWidth ? LabelPosition_Left : LabelPosition_HCenter; + break; } - else + } + + switch (aDimensionAspect->TextVerticalPosition()) + { + case Prs3d_DTVP_Above : aLabelPosition |= LabelPosition_Above; break; + case Prs3d_DTVP_Below : aLabelPosition |= LabelPosition_Below; break; + case Prs3d_DTVP_Center : aLabelPosition |= LabelPosition_VCenter; break; + } + + // Group1: stenciling text and the angle dimension arc + Prs3d_Root::NewGroup (thePresentation); + + Standard_Real anExtensionSize = aDimensionAspect->ExtensionSize(); + + Standard_Integer aHPosition = aLabelPosition & LabelPosition_HMask; + + // draw text label + switch (aHPosition) + { + case LabelPosition_HCenter : { + Standard_Boolean isLineBreak = aDimensionAspect->TextVerticalPosition() == Prs3d_DTVP_Center + && aDimensionAspect->IsText3d(); + + if (isLineBreak) + { + drawArcWithText (thePresentation, + aFirstAttach, + aSecondAttach, + aValueString, + (AIS_DimensionDisplayMode)theMode, + aLabelPosition); + break; + } + gp_Vec aTextDir (aFirstArrowEnd, aSecondArrowBegin); myGeom.myTextPosition = getCenterOnArc (aFirstArrowEnd, aSecondArrowBegin); + drawText (thePresentation, myIsTextReversed ? aTextDir.Reversed() : aTextDir, - aValueString, (AIS_DimensionDisplayMode)theMode); - if (theMode != AIS_DDM_Text) - drawArc (thePresentation, aFirstArrowEnd, aSecondArrowBegin, myCenter, Abs (GetFlyout()), (AIS_DimensionDisplayMode)theMode); + aValueString, + (AIS_DimensionDisplayMode)theMode, + aLabelPosition); + + if (theMode == AIS_DDM_Text) + { + break; + } + + drawArc (thePresentation, + isArrowsExternal ? aFirstAttach : aFirstArrowEnd, + isArrowsExternal ? aSecondAttach : aSecondArrowEnd, + myCenter, + Abs (GetFlyout()), + (AIS_DimensionDisplayMode)theMode); } + break; + + case LabelPosition_Left : + { + drawExtension (thePresentation, + anExtensionSize, + isArrowsExternal ? aFirstArrowEnd : aFirstAttach, + aFirstExtensionDir, + aValueString, + (AIS_DimensionDisplayMode)theMode, + aLabelPosition); + } + break; + + case LabelPosition_Right : + { + drawExtension (thePresentation, + anExtensionSize, + isArrowsExternal ? aSecondArrowEnd : aSecondAttach, + aSecondExtensionDir, + aValueString, + (AIS_DimensionDisplayMode)theMode, + aLabelPosition); + } + break; } - else + + // dimension arc without text + if (theMode != AIS_DDM_Text && aHPosition != LabelPosition_HCenter) { - // Lines for extensions - gp_Lin aLeftExtension (aFirstAttach,gp_Dir(aFirstArrowVec)); - gp_Lin aRightExtension (aSecondAttach, gp_Dir(aSecondArrowVec)); - aPrimSegments = new Graphic3d_ArrayOfSegments (6); - gp_Pnt aStartPoint; - if (aDimensionAspect->HorizontalTextAlignment() == Prs3d_HTA_Left) - { - aStartPoint = aFirstArrowBegin; - // Short extension - aPrimSegments->AddVertex (aSecondArrowEnd); - aPrimSegments->AddVertex (aSecondArrowEnd.Translated(gp_Vec(aRightExtension.Direction())*anArrowLength)); - myGeom.mySensitiveSegments.Append (new Select3D_SensitiveSegment(anEmptyOwner, - aSecondArrowEnd, - aSecondArrowEnd.Translated(gp_Vec(aRightExtension.Direction())*anArrowLength))); + Prs3d_Root::NewGroup (thePresentation); - // Long extension - drawExtensionWithText (thePresentation, aStartPoint, aLeftExtension, aValueString, (AIS_DimensionDisplayMode)theMode); - } - else // Prs3d_HTA_Right - { - aStartPoint = aSecondArrowEnd; - // Short extension - aPrimSegments->AddVertex (aFirstArrowBegin); - aPrimSegments->AddVertex (aFirstArrowBegin.Translated (gp_Vec (aLeftExtension.Direction()) * anArrowLength)); - myGeom.mySensitiveSegments.Append (new Select3D_SensitiveSegment(anEmptyOwner, - aFirstArrowBegin, - aFirstArrowBegin.Translated (gp_Vec (aLeftExtension.Direction()) * anArrowLength))); + drawArc (thePresentation, + isArrowsExternal ? aFirstAttach : aFirstArrowEnd, + isArrowsExternal ? aSecondAttach : aSecondArrowEnd, + myCenter, + Abs(GetFlyout ()), + (AIS_DimensionDisplayMode)theMode); + } - // Long extension - drawExtensionWithText (thePresentation, aStartPoint, aRightExtension, aValueString, (AIS_DimensionDisplayMode)theMode); + // arrows and arrow extensions + if (theMode != AIS_DDM_Text) + { + Prs3d_Root::NewGroup (thePresentation); + + drawArrow (thePresentation, aFirstArrowBegin, gp_Dir (aFirstArrowVec)); + drawArrow (thePresentation, aSecondArrowBegin, gp_Dir (aSecondArrowVec)); + } + + if (theMode != AIS_DDM_Text && isArrowsExternal) + { + Prs3d_Root::NewGroup (thePresentation); + + if (aHPosition != LabelPosition_Left) + { + drawExtension (thePresentation, + anExtensionSize, + aFirstArrowEnd, + aFirstExtensionDir, + THE_EMPTY_LABEL, + (AIS_DimensionDisplayMode)theMode, + LabelPosition_None); } - if (theMode != AIS_DDM_Text) + if (aHPosition != LabelPosition_Right) { - // Draw main arc - drawArc (thePresentation, aFirstArrowEnd, aSecondArrowBegin, myCenter, Abs(GetFlyout ()), (AIS_DimensionDisplayMode)theMode); + drawExtension (thePresentation, + anExtensionSize, + aSecondArrowEnd, + aSecondExtensionDir, + THE_EMPTY_LABEL, + (AIS_DimensionDisplayMode)theMode, + LabelPosition_None); } } - // Draw flyout lines and arrows in new group. - Prs3d_Root::NewGroup (thePresentation) - ->SetPrimitivesAspect (myDrawer->DimensionAspect()->LineAspect()->Aspect()); + // flyouts if (theMode == AIS_DDM_All && myIsFlyoutLines) { + Prs3d_Root::NewGroup (thePresentation); + + Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (4); aPrimSegments->AddVertex (myCenter); aPrimSegments->AddVertex (aFirstAttach); aPrimSegments->AddVertex (myCenter); aPrimSegments->AddVertex (aSecondAttach); - } - if (theMode != AIS_DDM_Text) - { + + Handle(Graphic3d_AspectLine3d) aFlyoutStyle = myDrawer->DimensionAspect()->LineAspect()->Aspect(); + Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aFlyoutStyle); Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments); - drawArrow (thePresentation, aFirstAttach, gp_Dir (aFirstArrowVec)); - drawArrow (thePresentation, aSecondAttach, gp_Dir (aSecondArrowVec)); } setComputed (Standard_True); @@ -999,12 +975,13 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /* //function : computeFlyoutSelection //purpose : computes selection for flyouts //======================================================================= - void AIS_AngleDimension::computeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection, const Handle(AIS_DimensionOwner)& theOwner) { if (!myIsFlyoutLines) + { return; + } gp_Pnt aFirstAttach = myCenter.Translated (gp_Vec (myCenter, myFirstPoint).Normalized() * GetFlyout()); gp_Pnt aSecondAttach = myCenter.Translated (gp_Vec (myCenter, mySecondPoint).Normalized() * GetFlyout()); @@ -1012,4 +989,4 @@ void AIS_AngleDimension::computeFlyoutSelection (const Handle(SelectMgr_Selectio aSensitiveEntity->Add (new Select3D_SensitiveSegment (theOwner, myCenter, aFirstAttach)); aSensitiveEntity->Add (new Select3D_SensitiveSegment (theOwner, myCenter, aSecondAttach)); theSelection->Add (aSensitiveEntity); -} \ No newline at end of file +} diff --git a/src/AIS/AIS_AngleDimension.hxx b/src/AIS/AIS_AngleDimension.hxx index 9e1f893f6f..805d651119 100644 --- a/src/AIS/AIS_AngleDimension.hxx +++ b/src/AIS/AIS_AngleDimension.hxx @@ -48,6 +48,7 @@ DEFINE_STANDARD_HANDLE (AIS_AngleDimension, AIS_Dimension) class AIS_AngleDimension : public AIS_Dimension { public: + //! Constructs angle dimension between two edges //! with automatic working plane computing //! if it is possible. In case of PI angle please @@ -63,28 +64,12 @@ public: Standard_EXPORT AIS_AngleDimension (const TopoDS_Edge& theFirstEdge, const TopoDS_Edge& theSecondEdge, const gp_Pln& thePlane); - - //! Constructs the angle display object defined by the
- //! two edges and custom working plane and dimension aspect. - Standard_EXPORT AIS_AngleDimension (const TopoDS_Edge& theFirstEdge, - const TopoDS_Edge& theSecondEdge, - const gp_Pln& thePlane, - const Handle(Prs3d_DimensionAspect)& theDimensionAspect, - const Standard_Real theExtensionSize = 1.0); //! Constructs the angle display object defined by three points. Standard_EXPORT AIS_AngleDimension (const gp_Pnt& theFirstPoint, const gp_Pnt& theSecondPoint, const gp_Pnt& theThirdPoint); - //! Constructs the angle display object defined by three points - //! and dimension aspect that defines line, arrow and text aspect. - Standard_EXPORT AIS_AngleDimension (const gp_Pnt& theFirstPoint, - const gp_Pnt& theSecondPoint, - const gp_Pnt& theThirdPoint, - const Handle(Prs3d_DimensionAspect)& theDimensionAspect, - const Standard_Real theExtensionSize = 1.0); - //! Angle of cone Standard_EXPORT AIS_AngleDimension (const TopoDS_Face& theCone); @@ -97,7 +82,9 @@ public: Standard_EXPORT void SetFirstShape (const TopoDS_Shape& theShape, const Standard_Boolean isSingleShape = Standard_False); - DEFINE_STANDARD_RTTI(AIS_AngleDimension) +public: + + DEFINE_STANDARD_RTTI (AIS_AngleDimension) protected: @@ -120,7 +107,8 @@ protected: const gp_Pnt& theFirstAttach, const gp_Pnt& theSecondAttach, const TCollection_ExtendedString& theText, - const AIS_DimensionDisplayMode theMode); + const AIS_DimensionDisplayMode theMode, + const Standard_Integer theLabelPosition); Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePM, const Handle(Prs3d_Presentation)& thePresentation, @@ -141,12 +129,6 @@ protected: const gp_Circ &theCMin, const gp_Circ &theC); - //! Auxiliary method to arrange text and arrows - Standard_EXPORT Standard_Boolean canTextBeInCenter (const gp_Pnt& theFirstAttach, - const gp_Pnt& theSecondAttach, - const Quantity_Length& theTextLength, - const Quantity_Length& theArrowLength); - //! Fills default plane object if it is possible to count plane automatically. Standard_EXPORT virtual void countDefaultPlane (); diff --git a/src/AIS/AIS_DiameterDimension.cxx b/src/AIS/AIS_DiameterDimension.cxx index 9431bc13a9..ef31b023a3 100755 --- a/src/AIS/AIS_DiameterDimension.cxx +++ b/src/AIS/AIS_DiameterDimension.cxx @@ -18,52 +18,24 @@ // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. -// Modified Mon 12-january-98 -// , - - -#define BUC60915 //GG 05/06/01 Enable to compute the requested arrow size -// if any in all dimensions. #include - -#include #include #include -#include -#include -#include #include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include #include #include #include -#include -#include -#include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include IMPLEMENT_STANDARD_HANDLE(AIS_DiameterDimension, AIS_Dimension) IMPLEMENT_STANDARD_RTTIEXT(AIS_DiameterDimension, AIS_Dimension) +namespace +{ + static const Standard_ExtCharacter THE_DIAMETER_SYMBOL (0x00D8); +}; + //======================================================================= //function : Constructor //purpose : @@ -75,8 +47,9 @@ AIS_DiameterDimension::AIS_DiameterDimension(const gp_Circ& theCircle) { SetKindOfDimension(AIS_KOD_DIAMETER); myIsInitialized = Standard_True; - SetSpecialSymbol (0x00D8); + SetSpecialSymbol (THE_DIAMETER_SYMBOL); SetDisplaySpecialSymbol (AIS_DSS_Before); + SetFlyout (0.0); // Count attach points myFirstPoint = ElCLib::Value (0, myCircle); mySecondPoint = myFirstPoint.Translated (gp_Vec(myFirstPoint, theCircle.Location())*2); @@ -91,9 +64,10 @@ AIS_DiameterDimension::AIS_DiameterDimension(const gp_Circ& theCircle, const gp_ : AIS_Dimension(), myCircle (theCircle) { - SetKindOfDimension(AIS_KOD_DIAMETER); - SetSpecialSymbol (0x00D8); + SetKindOfDimension (AIS_KOD_DIAMETER); + SetSpecialSymbol (THE_DIAMETER_SYMBOL); SetDisplaySpecialSymbol (AIS_DSS_Before); + SetFlyout (0.0); myFirstPoint = theAttachPoint; // Count the second point if (Abs(myFirstPoint.Distance (theCircle.Location()) - theCircle.Radius()) < Precision::Confusion()) @@ -108,24 +82,6 @@ AIS_DiameterDimension::AIS_DiameterDimension(const gp_Circ& theCircle, const gp_ myIsInitialized = Standard_True; } -//======================================================================= -//function : Constructor -//purpose : -//======================================================================= - -AIS_DiameterDimension::AIS_DiameterDimension (const gp_Circ& theCircle, - const Handle(Prs3d_DimensionAspect)& theDimensionStyle, - const Standard_Real theExtensionSize /*= 1.0*/) -: AIS_Dimension (theExtensionSize), - myCircle (theCircle) -{ - SetKindOfDimension(AIS_KOD_DIAMETER); - SetSpecialSymbol (0x00D8); - SetDisplaySpecialSymbol(AIS_DSS_Before); - myDrawer->SetDimensionAspect(theDimensionStyle); - myIsInitialized = Standard_True; -} - //======================================================================= //function : Constructor //purpose : Universal constructor for diameter dimension of shape @@ -134,9 +90,10 @@ AIS_DiameterDimension::AIS_DiameterDimension (const gp_Circ& theCircle, AIS_DiameterDimension::AIS_DiameterDimension (const TopoDS_Shape& theShape) : AIS_Dimension () { - SetKindOfDimension(AIS_KOD_DIAMETER); - SetSpecialSymbol (0x00D8); - SetDisplaySpecialSymbol(AIS_DSS_Before); + SetKindOfDimension (AIS_KOD_DIAMETER); + SetSpecialSymbol (THE_DIAMETER_SYMBOL); + SetDisplaySpecialSymbol (AIS_DSS_Before); + SetFlyout (0.0); myFirstShape = theShape; myIsInitialized = Standard_False; } @@ -163,38 +120,13 @@ void AIS_DiameterDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& else myIsInitialized = Standard_True; } + if (!myIsWorkingPlaneCustom) - countDefaultPlane(); - - //Count flyout direction - gp_Ax1 aWorkingPlaneNormal = GetWorkingPlane().Axis(); - gp_Dir aTargetPointsVector = gce_MakeDir (myFirstPoint, mySecondPoint); - // Count a flyout direction vector. - gp_Dir aFlyoutVector = aWorkingPlaneNormal.Direction()^aTargetPointsVector; - - // Create lines for layouts - gp_Lin aLine1 (myFirstPoint, aFlyoutVector); - gp_Lin aLine2 (mySecondPoint, aFlyoutVector); - - // Get flyout end points - gp_Pnt aFlyoutEnd1 = ElCLib::Value (ElCLib::Parameter (aLine1, myFirstPoint) + GetFlyout(), aLine1); - gp_Pnt aFlyoutEnd2 = ElCLib::Value (ElCLib::Parameter (aLine2, mySecondPoint) + GetFlyout(), aLine2); - - // Add layout lines to graphic group - // Common to all type of dimension placement. - if (theMode == 0) { - Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments(4); - aPrimSegments->AddVertex (myFirstPoint); - aPrimSegments->AddVertex (aFlyoutEnd1); - - aPrimSegments->AddVertex (mySecondPoint); - aPrimSegments->AddVertex (aFlyoutEnd2); - - Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments); + countDefaultPlane(); } - drawLinearDimension (thePresentation, aFlyoutEnd1, aFlyoutEnd2, (AIS_DimensionDisplayMode)theMode); + drawLinearDimension (thePresentation, (AIS_DimensionDisplayMode)theMode); } //======================================================================= diff --git a/src/AIS/AIS_DiameterDimension.hxx b/src/AIS/AIS_DiameterDimension.hxx index c6221a702b..18427593a7 100644 --- a/src/AIS/AIS_DiameterDimension.hxx +++ b/src/AIS/AIS_DiameterDimension.hxx @@ -47,19 +47,16 @@ public: Standard_EXPORT AIS_DiameterDimension (const gp_Circ& theCircle, const gp_Pnt& theAttachPoint); - Standard_EXPORT AIS_DiameterDimension (const gp_Circ& theCircle, - const Handle(Prs3d_DimensionAspect)& theDimensionStyle, - const Standard_Real theExtensionSize = 1.0); - Standard_EXPORT AIS_DiameterDimension (const TopoDS_Shape& theShape); DEFINE_STANDARD_RTTI(AIS_DiameterDimension) protected: - Standard_EXPORT virtual void computeValue (); + Standard_EXPORT virtual void computeValue(); + //! Fills default plane object if it is possible to count plane automatically. - Standard_EXPORT virtual void countDefaultPlane (); + Standard_EXPORT virtual void countDefaultPlane(); private: @@ -68,6 +65,7 @@ private: const Standard_Integer theMode = 0); // Fields +private: gp_Circ myCircle; }; diff --git a/src/AIS/AIS_Dimension.cxx b/src/AIS/AIS_Dimension.cxx index 55a75bc652..f07387778d 100644 --- a/src/AIS/AIS_Dimension.cxx +++ b/src/AIS/AIS_Dimension.cxx @@ -15,8 +15,9 @@ // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. -#include #include + +#include #include #include #include @@ -75,12 +76,18 @@ IMPLEMENT_STANDARD_HANDLE(AIS_Dimension, AIS_InteractiveObject) IMPLEMENT_STANDARD_RTTIEXT(AIS_Dimension, AIS_InteractiveObject) +namespace +{ + static const Standard_Utf32Char THE_FILL_CHARACTER ('0'); + static const TCollection_ExtendedString THE_EMPTY_LABEL; + static const Standard_Real THE_3D_TEXT_MARGIN = 0.1; +}; + //======================================================================= //function : Constructor //purpose : //======================================================================= - -AIS_Dimension::AIS_Dimension (const Standard_Real theExtensionSize /*= 1.0*/) +AIS_Dimension::AIS_Dimension() : AIS_InteractiveObject(), myDefaultPlane (gp_Pln (gp::XOY())), myIsWorkingPlaneCustom (Standard_False), @@ -91,11 +98,9 @@ AIS_Dimension::AIS_Dimension (const Standard_Real theExtensionSize /*= 1.0*/) mySpecialSymbol (' '), myDisplaySpecialSymbol (AIS_DSS_No), myIsTextReversed (Standard_False), - myTextOffset (DimensionAspect()->ArrowAspect()->Length()), myIsInitialized (Standard_False), myFlyout (0.0), - myKindOfDimension (AIS_KOD_NONE), - myExtensionSize (theExtensionSize) + myKindOfDimension (AIS_KOD_NONE) { ResetWorkingPlane(); // Units default settings @@ -104,42 +109,10 @@ AIS_Dimension::AIS_Dimension (const Standard_Real theExtensionSize /*= 1.0*/) myDisplayUnits = Units::DictionaryOfUnits()->ActiveUnit (myUnitsQuantity.ToCString()); } -//======================================================================= -//function : Constructor -//purpose : -//======================================================================= - -AIS_Dimension::AIS_Dimension (const Handle(Prs3d_DimensionAspect)& theAspect, - const Standard_Real theExtensionSize /*= 1.0*/) -: AIS_InteractiveObject(), - myDefaultPlane (gp_Pln (gp::XOY())), - myIsWorkingPlaneCustom (Standard_False), - myValue (0.0), - myIsValueCustom (Standard_False), - myUnitsQuantity (TCollection_AsciiString("LENGTH")), - myToDisplayUnits (Standard_False), - mySpecialSymbol (' '), - myDisplaySpecialSymbol (AIS_DSS_No), - myIsTextReversed (Standard_False), - myTextOffset (DimensionAspect()->ArrowAspect()->Length()), - myIsInitialized (Standard_False), - myFlyout (0.0), - myKindOfDimension (AIS_KOD_NONE), - myExtensionSize (theExtensionSize) -{ - ResetWorkingPlane(); - // Units default settings - UnitsAPI::SetLocalSystem (UnitsAPI_SI); - myModelUnits = Units::DictionaryOfUnits()->ActiveUnit (myUnitsQuantity.ToCString()); - myDisplayUnits = Units::DictionaryOfUnits()->ActiveUnit (myUnitsQuantity.ToCString()); - SetDimensionAspect (theAspect); -} - //======================================================================= //function : AcceptDisplayMode //purpose : Checks if display mode is allowed to display object. //======================================================================= - Standard_Boolean AIS_Dimension::AcceptDisplayMode (const Standard_Integer theMode) const { return theMode == 0 ? Standard_True : Standard_False; @@ -149,7 +122,6 @@ Standard_Boolean AIS_Dimension::AcceptDisplayMode (const Standard_Integer theMod //function : computeValue //purpose : Computes dimension value in display units. //======================================================================= - void AIS_Dimension::computeValue() { UnitsAPI::SetCurrentUnit (myUnitsQuantity.ToCString(), myModelUnits.ToCString()); @@ -161,7 +133,6 @@ void AIS_Dimension::computeValue() //function : countDefaultPlane //purpose : //======================================================================= - void AIS_Dimension::countDefaultPlane() { } @@ -170,7 +141,6 @@ void AIS_Dimension::countDefaultPlane() //function : GetWorkingPlane //purpose : //======================================================================= - const gp_Pln& AIS_Dimension::GetWorkingPlane() const { return myWorkingPlane; @@ -180,7 +150,6 @@ const gp_Pln& AIS_Dimension::GetWorkingPlane() const //function : SetWorkingPlane //purpose : //======================================================================= - void AIS_Dimension::SetWorkingPlane (const gp_Pln& thePlane) { myWorkingPlane = thePlane; @@ -191,7 +160,6 @@ void AIS_Dimension::SetWorkingPlane (const gp_Pln& thePlane) //function : ResetWorkingPlane //purpose : Set default value of working plane //======================================================================= - void AIS_Dimension::ResetWorkingPlane() { myWorkingPlane = myDefaultPlane; @@ -203,7 +171,6 @@ void AIS_Dimension::ResetWorkingPlane() //purpose : Set default value of working plane // Only for internal use. //======================================================================= - void AIS_Dimension::resetWorkingPlane (const gp_Pln& theNewDefaultPlane) { myDefaultPlane = theNewDefaultPlane; @@ -214,7 +181,6 @@ void AIS_Dimension::resetWorkingPlane (const gp_Pln& theNewDefaultPlane) //function : valueInDisplayUnits //purpose : //======================================================================= - Standard_Real AIS_Dimension::valueToDisplayUnits() { return UnitsAPI::AnyToAny (myValue, @@ -226,7 +192,6 @@ Standard_Real AIS_Dimension::valueToDisplayUnits() //function : KindOfDimension //purpose : //======================================================================= - AIS_KindOfDimension AIS_Dimension::KindOfDimension() const { return myKindOfDimension; @@ -236,37 +201,15 @@ AIS_KindOfDimension AIS_Dimension::KindOfDimension() const //function : SetKindOfDimension //purpose : //======================================================================= - void AIS_Dimension::SetKindOfDimension (const AIS_KindOfDimension theKindOfDimension) { myKindOfDimension = theKindOfDimension; } -//======================================================================= -//function : SetExtensionSize -//purpose : -//======================================================================= - -void AIS_Dimension::SetExtensionSize (const Standard_Real theExtensionSize) -{ - myExtensionSize = theExtensionSize; -} - -//======================================================================= -//function : GetExtensionSize -//purpose : -//======================================================================= - -Standard_Real AIS_Dimension::GetExtensionSize() const -{ - return myExtensionSize; -} - //======================================================================= //function : GetValue //purpose : //======================================================================= - Standard_Real AIS_Dimension::GetValue() const { return myValue; @@ -276,7 +219,6 @@ Standard_Real AIS_Dimension::GetValue() const //function : SetCustomValue //purpose : //======================================================================= - void AIS_Dimension::SetCustomValue (const Standard_Real theValue) { myValue = theValue; @@ -287,7 +229,6 @@ void AIS_Dimension::SetCustomValue (const Standard_Real theValue) //function : SetFirstShape //purpose : //======================================================================= - void AIS_Dimension::SetFirstShape (const TopoDS_Shape& theShape) { myFirstShape = theShape; @@ -299,7 +240,6 @@ void AIS_Dimension::SetFirstShape (const TopoDS_Shape& theShape) //function : SetSecondShape //purpose : //======================================================================= - void AIS_Dimension::SetSecondShape (const TopoDS_Shape& theShape) { mySecondShape = theShape; @@ -311,7 +251,6 @@ void AIS_Dimension::SetSecondShape (const TopoDS_Shape& theShape) //function : getTextWidthAndString //purpose : //======================================================================= - void AIS_Dimension::getTextWidthAndString (Quantity_Length& theWidth, TCollection_ExtendedString& theString) const { @@ -334,21 +273,34 @@ void AIS_Dimension::getTextWidthAndString (Quantity_Length& theWidth, theString += TCollection_ExtendedString (mySpecialSymbol); } - // Get font length - // Get expansion ratio for getting a width of symbols + // Get text style parameters Quantity_Color aColor; - Standard_CString aFont; + Standard_CString aFontName; Standard_Real aFactor; Standard_Real aSpace; - myDrawer->DimensionAspect()->TextAspect()->Aspect()->Values (aColor, aFont, aFactor, aSpace); - theWidth = (myDrawer->DimensionAspect()->TextAspect()->Height() / aFactor) * theString.Length(); + myDrawer->DimensionAspect()->TextAspect()->Aspect()->Values (aColor, aFontName, aFactor, aSpace); + // Init font instance + Handle(Font_FTFont) aFont = new Font_FTFont (); + aFont->Init (aFontName, + myDrawer->DimensionAspect()->TextAspect()->Aspect()->GetTextFontAspect(), + (Standard_Integer) myDrawer->DimensionAspect()->TextAspect()->Height(), 72); + + TCollection_ExtendedString aString (theString); + aString += "."; + Standard_PCharacter aUtf8String = new Standard_Character[aString.Length()]; + Standard_Integer aStrLength = aString.ToUTF8CString(aUtf8String); + theWidth = 0.0; + for (Standard_Integer anIt = 0; anIt < aStrLength - 1; ++anIt) + { + Standard_Real anAdvance = aFont->AdvanceX (aUtf8String[anIt], aUtf8String[anIt + 1]); + theWidth += anAdvance; + } } //======================================================================= //function : drawArrow //purpose : //======================================================================= - void AIS_Dimension::drawArrow (const Handle(Prs3d_Presentation)& thePresentation, const gp_Pnt& theLocation, const gp_Dir& theDirection) @@ -360,17 +312,17 @@ void AIS_Dimension::drawArrow (const Handle(Prs3d_Presentation)& thePresentation { Prs3d_Arrow::Draw (thePresentation, theLocation, - theDirection.Reversed(), + theDirection, myDrawer->DimensionAspect()->ArrowAspect()->Angle(), anArrowLength); } else { - gp_Vec anArrowDir (theDirection); + gp_Vec aBackDir (theDirection.Reversed()); Quantity_Length theCathetusLength = anArrowLength / Cos (M_PI / 9.0); Handle(Graphic3d_ArrayOfTriangles) anArrow = new Graphic3d_ArrayOfTriangles(3); - gp_Pnt aLeftPoint (theLocation.Translated (anArrowDir.Rotated (myWorkingPlane.Axis(), M_PI / 9.0) * theCathetusLength)); - gp_Pnt aRightPoint (theLocation.Translated (anArrowDir.Rotated (myWorkingPlane.Axis(), M_PI * 17.0 / 9.0) * theCathetusLength)); + gp_Pnt aLeftPoint (theLocation.Translated (aBackDir.Rotated (myWorkingPlane.Axis(), M_PI / 9.0) * theCathetusLength)); + gp_Pnt aRightPoint (theLocation.Translated (aBackDir.Rotated (myWorkingPlane.Axis(), M_PI * 17.0 / 9.0) * theCathetusLength)); anArrow->AddVertex (aLeftPoint); anArrow->AddVertex (theLocation); @@ -385,11 +337,13 @@ void AIS_Dimension::drawArrow (const Handle(Prs3d_Presentation)& thePresentation aShadeMat.SetReflectionModeOff (Graphic3d_TOR_AMBIENT); aShadeMat.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE); aShadeMat.SetReflectionModeOff (Graphic3d_TOR_SPECULAR); - myDrawer->ShadingAspect()->Aspect()->SetInteriorColor (aColor); - myDrawer->ShadingAspect()->Aspect()->SetBackInteriorColor (aColor); - myDrawer->ShadingAspect()->SetMaterial (aShadeMat); - Prs3d_Root::CurrentGroup(thePresentation)->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect()); - Prs3d_Root::CurrentGroup(thePresentation)->AddPrimitiveArray (anArrow); + + Handle(Prs3d_ShadingAspect) aShadingStyle = new Prs3d_ShadingAspect(); + aShadingStyle->SetColor (aColor); + aShadingStyle->SetMaterial (aShadeMat); + + Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aShadingStyle->Aspect()); + Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (anArrow); } } @@ -397,17 +351,17 @@ void AIS_Dimension::drawArrow (const Handle(Prs3d_Presentation)& thePresentation //function : drawText //purpose : //======================================================================= - Standard_Real AIS_Dimension::drawText (const Handle(Prs3d_Presentation)& thePresentation, const gp_Dir& theTextDir, const TCollection_ExtendedString theText, - const AIS_DimensionDisplayMode theMode) + const AIS_DimensionDisplayMode theMode, + const Standard_Integer theLabelPosition) { Standard_Real aTextWidth (0.0), aTextHeight (0.0); if (theMode == AIS_DDM_Line) - return aTextWidth; - // Creating new group for text - Prs3d_Root::NewGroup (thePresentation); + { + return 0.0; + } if (myDrawer->DimensionAspect()->IsText3d()) { @@ -432,47 +386,59 @@ Standard_Real AIS_Dimension::drawText (const Handle(Prs3d_Presentation)& thePres aTextBndBox.Get (aXMin, anYMin, aZMin, aXMax, anYMax, aZMax); aTextWidth = aXMax - aXMin; aTextHeight = anYMax - anYMin; - gp_Dir aTextDir (theTextDir); - Standard_Real aHorizontalOffset (0.0), aVerticalOffset (0.0); - switch (myDrawer->DimensionAspect()->HorizontalTextAlignment()) + + Standard_Integer aHLabelPos = theLabelPosition & LabelPosition_HMask; + Standard_Integer aVLabelPos = theLabelPosition & LabelPosition_VMask; + + gp_Dir aTextDir (aHLabelPos == LabelPosition_Left ? -theTextDir : theTextDir); + + // compute label offsets + Standard_Real aMarginSize = aHeight * THE_3D_TEXT_MARGIN; + Standard_Real aCenterHOffset = 0.0; + Standard_Real aCenterVOffset = 0.0; + switch (aHLabelPos) { - case Prs3d_HTA_Left: - aTextDir.Reverse(); - aHorizontalOffset = -aTextWidth; - break; - case Prs3d_HTA_Center: - aHorizontalOffset = -(aTextWidth / 2.0); - break; - case Prs3d_HTA_Right: - aHorizontalOffset = 0.0; - break; + case LabelPosition_HCenter : aCenterHOffset = 0.0; break; + case LabelPosition_Right : aCenterHOffset = aTextWidth / 2.0 + aMarginSize; break; + case LabelPosition_Left : aCenterHOffset = -aTextWidth / 2.0 - aMarginSize; break; } - switch (myDrawer->DimensionAspect()->VerticalTextAlignment()) + switch (aVLabelPos) { - case Prs3d_VTA_Top: - aVerticalOffset = 0.0; - break; - case Prs3d_VTA_Center: - aVerticalOffset = -(aTextHeight / 2.0); - break; - case Prs3d_VTA_Bottom: - aVerticalOffset = -aTextHeight; - break; + case LabelPosition_VCenter : aCenterVOffset = 0.0; break; + case LabelPosition_Above : aCenterVOffset = aTextHeight / 2.0 + aMarginSize; break; + case LabelPosition_Below : aCenterVOffset = -aTextHeight / 2.0 - aMarginSize; break; } - gp_Trsf aTrsf; - aTrsf.SetTranslation (gp_Pnt (), gp_Pnt (aHorizontalOffset, aVerticalOffset, 0.0)); - aTextShape.Move (aTrsf); + + // compute shape offset transformation + Standard_Real aShapeHOffset = aCenterHOffset - aTextWidth / 2.0; + Standard_Real aShapeVOffset = aCenterVOffset - aTextHeight / 2.0; + + gp_Trsf anOffsetTrsf; + anOffsetTrsf.SetTranslation (gp::Origin(), gp_Pnt (aShapeHOffset, aShapeVOffset, 0.0)); + aTextShape.Move (anOffsetTrsf); // Transform text to myWorkingPlane coordinate system - gp_Ax3 aPenAx3 (myGeom.myTextPosition, myWorkingPlane.Axis().Direction(), aTextDir); - aTrsf.SetTransformation (aPenAx3, gp_Ax3 (gp::XOY())); - aTextShape.Move (aTrsf); + gp_Ax3 aTextCoordSystem (myGeom.myTextPosition, myWorkingPlane.Axis().Direction(), aTextDir); + gp_Trsf aTextPlaneTrsf; + aTextPlaneTrsf.SetTransformation (aTextCoordSystem, gp_Ax3 (gp::XOY())); + aTextShape.Move (aTextPlaneTrsf); // Set display parameters for advanced selection BRepBndLib::AddClose (aTextShape, myGeom.myTextBndBox); - // Drawing text - gp_Pnt aTextCenter = myGeom.myTextPosition.Translated (gp_Vec (theTextDir) * aTextWidth * 0.5); - Prs3d_Root::CurrentGroup (thePresentation)->SetFlippingOptions (Standard_True, gp_Ax2 (aTextCenter, myWorkingPlane.Axis().Direction(), aTextDir)); + + // Set text flipping anchors + gp_Trsf aCenterOffsetTrsf; + gp_Pnt aCenterOffset (aCenterHOffset, aCenterVOffset, 0.0); + aCenterOffsetTrsf.SetTranslation (gp::Origin(), aCenterOffset); + + gp_Pnt aCenterOfFlip (gp::Origin()); + aCenterOfFlip.Transform (aCenterOffsetTrsf); + aCenterOfFlip.Transform (aTextPlaneTrsf); + + gp_Ax2 aFlippingAxes (aCenterOfFlip, myWorkingPlane.Axis().Direction(), aTextDir); + Prs3d_Root::CurrentGroup (thePresentation)->SetFlippingOptions (Standard_True, aFlippingAxes); + + // Draw text if (myDrawer->DimensionAspect()->IsTextShaded()) { // Setting text shading and color parameters @@ -494,92 +460,80 @@ Standard_Real AIS_Dimension::drawText (const Handle(Prs3d_Presentation)& thePres // Drawing text StdPrs_WFShape::Add (thePresentation, aTextShape, myDrawer); } - // Creating new group for lines - Prs3d_Root::CurrentGroup (thePresentation)->SetFlippingOptions (Standard_False, aPenAx3.Ax2()); - Prs3d_Root::NewGroup (thePresentation); - } - else - { - myDrawer->DimensionAspect()->TextAspect()->Aspect()->SetDisplayType (Aspect_TODT_DIMENSION); - Prs3d_Text::Draw (thePresentation, - myDrawer->DimensionAspect()->TextAspect(), - theText, - myGeom.myTextPosition); + Prs3d_Root::CurrentGroup (thePresentation)->SetFlippingOptions (Standard_False, gp_Ax2()); - // For 2d text we don not create new group for lines and draw them in the same group with text - // for the proper handling of stencil test buffer. + return aTextWidth + aMarginSize * 2.0; } - return aTextWidth; + myDrawer->DimensionAspect()->TextAspect()->Aspect()->SetDisplayType (Aspect_TODT_DIMENSION); + + Prs3d_Text::Draw (thePresentation, + myDrawer->DimensionAspect()->TextAspect(), + theText, + myGeom.myTextPosition); + + // For 2d text we don not create new group for lines and draw them in the same group with text + // for the proper handling of stencil test buffer. + return 0.0; } - //======================================================================= -//function : drawExtensionWithText +//======================================================================= +//function : drawExtension //purpose : //======================================================================= - -void AIS_Dimension::drawExtensionWithText (const Handle(Prs3d_Presentation)& thePresentation, - const gp_Pnt& theStartPoint, - const gp_Lin& theDimensionLine, - const TCollection_ExtendedString& theValueString, - const AIS_DimensionDisplayMode theMode) +void AIS_Dimension::drawExtension (const Handle(Prs3d_Presentation)& thePresentation, + const Standard_Real theExtensionSize, + const gp_Pnt& theExtensionStart, + const gp_Dir& theExtensionDir, + const TCollection_ExtendedString& theValueString, + const AIS_DimensionDisplayMode theMode, + const Standard_Integer theLabelPosition) { - Handle(SelectMgr_EntityOwner) anEmptyOwner; - Standard_Boolean isGapInCenter = (myDrawer->DimensionAspect()->VerticalTextAlignment() == Prs3d_VTA_Center - && myDrawer->DimensionAspect()->IsText3d()); + Standard_Real aTextWidth = 0.0; - Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (isGapInCenter ? 4 : 2); - - gp_Dir anAttachPointsVector = myWorkingPlane.Axis().Direction() ^ gce_MakeDir (myFirstPoint, mySecondPoint); - Standard_Real aGap = 1.; - Standard_Real aStartParam = ElCLib::Parameter (theDimensionLine, theStartPoint); - - // Text - Standard_Real aTextParam = isGapInCenter ? aStartParam + myTextOffset + aGap : aStartParam + myTextOffset; - myGeom.myTextPosition = ElCLib::Value (aTextParam, theDimensionLine); - Standard_Real aTextWidth = drawText (thePresentation, - myIsTextReversed ? theDimensionLine.Direction().Reversed() - : theDimensionLine.Direction(), - theValueString, - theMode); - gp_Pnt aFirstPoint, aLastPoint; - aFirstPoint = theStartPoint; - Standard_Real aParam = isGapInCenter ? aTextParam + aTextWidth + aGap : aTextParam + aTextWidth; - - // If text separates dimension line into two parts (4 points) - if (isGapInCenter) + Standard_Boolean isLabel = theValueString.Length() > 0; + if (isLabel) { - aLastPoint = ElCLib::Value (aStartParam + myTextOffset, theDimensionLine); - aPrimSegments->AddVertex (aFirstPoint); - aPrimSegments->AddVertex (aLastPoint); - myGeom.mySensitiveSegments.Append (new Select3D_SensitiveSegment (anEmptyOwner, aFirstPoint, aLastPoint)); - aFirstPoint = ElCLib::Value (aParam, theDimensionLine); + // compute text primitives; get its model width + myGeom.myTextPosition = theExtensionStart.Translated ( + gp_Vec (theExtensionDir).Scaled (theExtensionSize)); + + aTextWidth = drawText (thePresentation, + myIsTextReversed ? -theExtensionDir : theExtensionDir, + theValueString, + theMode, + theLabelPosition); } - // Draw additional line segment only after 3D text - if (myDrawer->DimensionAspect()->IsText3d()) + if (theMode == AIS_DDM_Text) { - aParam += myTextOffset; + return; } - aLastPoint = ElCLib::Value (aParam, theDimensionLine); - aPrimSegments->AddVertex (aFirstPoint); - aPrimSegments->AddVertex (aLastPoint); - myGeom.mySensitiveSegments.Append (new Select3D_SensitiveSegment (anEmptyOwner, aFirstPoint, aLastPoint)); + // compute graphical primitives and sensitives for extension line + gp_Pnt anExtStart = theExtensionStart; + gp_Pnt anExtEnd = !isLabel || (theLabelPosition & LabelPosition_VCenter) != 0 + ? theExtensionStart.Translated (gp_Vec (theExtensionDir) * theExtensionSize) + : theExtensionStart.Translated (gp_Vec (theExtensionDir) * (theExtensionSize + aTextWidth)); - // Extension line in the same group - if (theMode != AIS_DDM_Text) + Handle(Graphic3d_ArrayOfSegments) anExtPrimitive = new Graphic3d_ArrayOfSegments (2); + anExtPrimitive->AddVertex (anExtStart); + anExtPrimitive->AddVertex (anExtEnd); + + Handle(SelectMgr_EntityOwner) aDummyOwner; + + myGeom.mySensitiveSegments.Append (new Select3D_SensitiveSegment (aDummyOwner, anExtStart, anExtEnd)); + + if (!myDrawer->DimensionAspect()->IsText3d() && theMode == AIS_DDM_All) { - if (!myDrawer->DimensionAspect()->IsText3d() && theMode == AIS_DDM_All) - { - Prs3d_Root::CurrentGroup (thePresentation)->SetStencilTestOptions (Standard_True); - } - Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (myDrawer->DimensionAspect()->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments); - if (!myDrawer->DimensionAspect()->IsText3d() && theMode == AIS_DDM_All) - { - Prs3d_Root::CurrentGroup (thePresentation)->SetStencilTestOptions (Standard_False); - } + Prs3d_Root::CurrentGroup (thePresentation)->SetStencilTestOptions (Standard_True); + } + Handle(Graphic3d_AspectLine3d) aDimensionLineStyle = myDrawer->DimensionAspect()->LineAspect()->Aspect(); + Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionLineStyle); + Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (anExtPrimitive); + if (!myDrawer->DimensionAspect()->IsText3d() && theMode == AIS_DDM_All) + { + Prs3d_Root::CurrentGroup (thePresentation)->SetStencilTestOptions (Standard_False); } } @@ -587,7 +541,6 @@ void AIS_Dimension::drawExtensionWithText (const Handle(Prs3d_Presentation)& the //function : SetDimensionAspect //purpose : //======================================================================= - void AIS_Dimension::SetDimensionAspect (const Handle(Prs3d_DimensionAspect)& theDimensionAspect) { myDrawer->SetDimensionAspect (theDimensionAspect); @@ -597,40 +550,16 @@ void AIS_Dimension::SetDimensionAspect (const Handle(Prs3d_DimensionAspect)& the //function : DimensionAspect //purpose : //======================================================================= - Handle(Prs3d_DimensionAspect) AIS_Dimension::DimensionAspect() const { return myDrawer->DimensionAspect(); } -//======================================================================= -//function : SetTextOffset -//purpose : -//======================================================================= - -void AIS_Dimension::SetTextOffset (const Standard_Real theOffset) -{ - myTextOffset = theOffset; -} - -//======================================================================= -//function : TextOffset -//purpose : -//======================================================================= - -Standard_Real AIS_Dimension::TextOffset() const -{ - return myTextOffset; -} - //======================================================================= //function : drawLinearDimension //purpose : //======================================================================= - void AIS_Dimension::drawLinearDimension (const Handle(Prs3d_Presentation)& thePresentation, - const gp_Pnt& theFirstAttach, - const gp_Pnt& theSecondAttach, const AIS_DimensionDisplayMode theMode, const Standard_Boolean isOneSideDimension/* = Standard_False*/) { @@ -640,22 +569,32 @@ void AIS_Dimension::drawLinearDimension (const Handle(Prs3d_Presentation)& thePr setComputed (Standard_False); return; } + + // compute dimension line points + gp_Ax1 aWorkingPlaneNormal = GetWorkingPlane().Axis(); + gp_Dir aTargetPointsVector = gce_MakeDir (myFirstPoint, mySecondPoint); + + // compute flyout direction vector + gp_Dir aFlyoutVector = aWorkingPlaneNormal.Direction() ^ aTargetPointsVector; + + // create lines for layouts + gp_Lin aLine1 (myFirstPoint, aFlyoutVector); + gp_Lin aLine2 (mySecondPoint, aFlyoutVector); + + // Get flyout end points + gp_Pnt aLineBegPoint = ElCLib::Value (ElCLib::Parameter (aLine1, myFirstPoint) + GetFlyout(), aLine1); + gp_Pnt aLineEndPoint = ElCLib::Value (ElCLib::Parameter (aLine2, mySecondPoint) + GetFlyout(), aLine2); + Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect(); Handle(SelectMgr_EntityOwner) anEmptyOwner; myGeom.mySensitiveSegments.Clear(); - gp_Dir aAttachPointsVector = GetWorkingPlane().Axis().Direction()^gce_MakeDir (myFirstPoint, mySecondPoint); - // Get line of the dimension - gp_Lin aDimensionLine = gce_MakeLin (theFirstAttach, theSecondAttach); + gp_Lin aDimensionLine = gce_MakeLin (aLineBegPoint, aLineEndPoint); - // Get parameters on dimension line of two layout points - Standard_Real aParam1 = ElCLib::Parameter (aDimensionLine, theFirstAttach); - Standard_Real aParam2 = ElCLib::Parameter (aDimensionLine, theSecondAttach); + // For extensions we need to know arrow size, text size and extension size: get it from aspect + Quantity_Length anArrowLength = aDimensionAspect->ArrowAspect()->Length(); + Standard_Real anExtensionSize = aDimensionAspect->ExtensionSize(); - // For extensions we need to know arrow size and text size, get it from aspect - Quantity_Length anArrowLength = aDimensionAspect->ArrowAspect()->Length(); - // Set line parameters - Standard_Real aGap = 0.; // gap between line and text if AIS_VTA_Center if (!myIsValueCustom) { computeValue(); @@ -665,206 +604,316 @@ void AIS_Dimension::drawLinearDimension (const Handle(Prs3d_Presentation)& thePr Standard_Real aTextLength; getTextWidthAndString (aTextLength, aValueString); - // Automatical text and arrow placement - Standard_Real aValue = myFirstPoint.Distance (mySecondPoint); - if (aDimensionAspect->HorizontalTextAlignment() == Prs3d_HTA_Center) + // Handle user-defined and automatic arrow placement + bool isArrowsExternal = false; + switch (aDimensionAspect->ArrowOrientation()) { - aDimensionAspect->SetArrowOrientation (Prs3d_DAO_Internal); - if (aValue < aTextLength + (isOneSideDimension ? anArrowLength : 2.0 * anArrowLength)) + case Prs3d_DAO_External: isArrowsExternal = true; break; + case Prs3d_DAO_Internal: isArrowsExternal = false; break; + case Prs3d_DAO_Fit: { - aDimensionAspect->SetArrowOrientation (Prs3d_DAO_External); - aDimensionAspect->SetHorizontalTextAlignment (Prs3d_HTA_Left); + Standard_Real aDimensionWidth = aLineBegPoint.Distance (aLineEndPoint); + Standard_Real anArrowsWidth = isOneSideDimension ? anArrowLength : 2.0 * anArrowLength; + isArrowsExternal = aDimensionWidth < aTextLength + anArrowsWidth; + break; } } - else - { - aDimensionAspect->SetArrowOrientation (Prs3d_DAO_External); - } // Arrows positions and directions - gp_Pnt aFirstArrowPosition = ElCLib::Value (aParam1, aDimensionLine); - gp_Pnt aSecondArrowPosition = ElCLib::Value (aParam2, aDimensionLine); - gp_Dir aFirstArrowDir = aDimensionLine.Direction(); - gp_Dir aSecondArrowDir = aDimensionLine.Direction().Reversed(); - Standard_Real aFirstArrowBegin, aFirstArrowEnd, aSecondArrowBegin, aSecondArrowEnd; + gp_Dir aFirstArrowDir = aDimensionLine.Direction().Reversed(); + gp_Dir aSecondArrowDir = aDimensionLine.Direction(); + gp_Dir aFirstExtensionDir = aDimensionLine.Direction().Reversed(); + gp_Dir aSecondExtensionDir = aDimensionLine.Direction(); - if (aDimensionAspect->GetArrowOrientation() == Prs3d_DAO_External) + gp_Pnt aFirstArrowBegin (0.0, 0.0, 0.0); + gp_Pnt aFirstArrowEnd (0.0, 0.0, 0.0); + gp_Pnt aSecondArrowBegin (0.0, 0.0, 0.0); + gp_Pnt aSecondArrowEnd (0.0, 0.0, 0.0); + + if (isArrowsExternal) { aFirstArrowDir.Reverse(); aSecondArrowDir.Reverse(); - - aFirstArrowBegin = aParam1 - anArrowLength; - aFirstArrowEnd = aParam1; - aSecondArrowBegin = aParam2; - aSecondArrowEnd = aParam2 + anArrowLength; - } - else - { - aFirstArrowBegin = aParam1; - aFirstArrowEnd = aParam1 + anArrowLength; - aSecondArrowBegin = aParam2 - anArrowLength; - aSecondArrowEnd = aParam2; } - Handle(Graphic3d_ArrayOfSegments) aPrimSegments; - gp_Pnt aFirstPoint, aLastPoint; - // Take into account vertical text alignment: - // only for 3D text! subtract the text length if it is in the center. - Standard_Boolean isGapInCenter = (aDimensionAspect->VerticalTextAlignment() == Prs3d_VTA_Center - && aDimensionAspect->IsText3d()); - if (isGapInCenter) - { - aGap = 1.0; - } + aFirstArrowBegin = aLineBegPoint; + aSecondArrowBegin = aLineEndPoint; + aFirstArrowEnd = aLineBegPoint.Translated (-gp_Vec (aFirstArrowDir).Scaled (anArrowLength)); + aSecondArrowEnd = aLineEndPoint.Translated (-gp_Vec (aSecondArrowDir).Scaled (anArrowLength)); - switch (aDimensionAspect->HorizontalTextAlignment()) + gp_Pnt aCenterLineBegin = isArrowsExternal + ? aLineBegPoint : aFirstArrowEnd; + + gp_Pnt aCenterLineEnd = isArrowsExternal || isOneSideDimension + ? aLineEndPoint : aSecondArrowEnd; + + Standard_Integer aLabelPosition = LabelPosition_None; + + // Handle user-defined and automatic text placement + switch (aDimensionAspect->TextHorizontalPosition()) { - // Default case - text is to be in the center of length dimension line - case Prs3d_HTA_Center: + case Prs3d_DTHP_Left : aLabelPosition |= LabelPosition_Left; break; + case Prs3d_DTHP_Right : aLabelPosition |= LabelPosition_Right; break; + case Prs3d_DTHP_Center: aLabelPosition |= LabelPosition_HCenter; break; + case Prs3d_DTHP_Fit: { - // Group1: arrows - if (theMode != AIS_DDM_Text) - { - drawArrow (thePresentation, aFirstArrowPosition, aFirstArrowDir); - if (!isOneSideDimension) - { - drawArrow (thePresentation, aSecondArrowPosition, aSecondArrowDir); - } - } + Standard_Real aDimensionWidth = aLineBegPoint.Distance (aLineEndPoint); + Standard_Real anArrowsWidth = isOneSideDimension ? anArrowLength : 2.0 * anArrowLength; + Standard_Real aContentWidth = isArrowsExternal ? aTextLength : aTextLength + anArrowsWidth; - // Group 2: Text and dimension line - aPrimSegments = new Graphic3d_ArrayOfSegments (isGapInCenter ? 4 : 2); - myGeom.myTextPosition = ElCLib::Value ((aParam1 + aParam2) / 2.0, aDimensionLine); + aLabelPosition |= aDimensionWidth < aContentWidth ? LabelPosition_Left : LabelPosition_HCenter; + break; + } + } + + switch (aDimensionAspect->TextVerticalPosition()) + { + case Prs3d_DTVP_Above : aLabelPosition |= LabelPosition_Above; break; + case Prs3d_DTVP_Below : aLabelPosition |= LabelPosition_Below; break; + case Prs3d_DTVP_Center : aLabelPosition |= LabelPosition_VCenter; break; + } + + switch (aLabelPosition & LabelPosition_HMask) + { + // ------------------------------------------------------------------------ // + // CENTER // + // -------------------------------------------------------------------------// + + case LabelPosition_HCenter: + { + // add label on dimension or extension line to presentation + Prs3d_Root::NewGroup (thePresentation); + + gp_Vec aTextDir (aLineBegPoint, aLineEndPoint); + + myGeom.myTextPosition = gp_XYZ (aLineBegPoint.XYZ() + aLineEndPoint.XYZ()) * 0.5; - gp_Vec aTextDir (myFirstPoint, mySecondPoint); Standard_Real aTextWidth = drawText (thePresentation, - myIsTextReversed ? aTextDir.Reversed() : aTextDir, + myIsTextReversed ? -aTextDir : aTextDir, aValueString, - theMode); + theMode, + aLabelPosition); - aFirstPoint = ElCLib::Value (aFirstArrowEnd, aDimensionLine); - if (isGapInCenter) + if (theMode == AIS_DDM_Text) { - aLastPoint = ElCLib::Value (ElCLib::Parameter (aDimensionLine,myGeom.myTextPosition) - aGap - (aTextWidth / 2.0), aDimensionLine); - aPrimSegments->AddVertex (aFirstPoint); - aPrimSegments->AddVertex (aLastPoint); - myGeom.mySensitiveSegments.Append (new Select3D_SensitiveSegment (anEmptyOwner,aFirstPoint,aLastPoint)); - aFirstPoint = ElCLib::Value (ElCLib::Parameter(aDimensionLine,myGeom.myTextPosition) + (aTextWidth / 2.0) + aGap, aDimensionLine); - } - else if (aDimensionAspect->VerticalTextAlignment() == Prs3d_VTA_Top) - { - aDimensionAspect->TextAspect()->SetVerticalJustification (Graphic3d_VTA_BOTTOM); - } - else if (aDimensionAspect->VerticalTextAlignment() == Prs3d_VTA_Bottom) - { - aDimensionAspect->TextAspect()->SetVerticalJustification(Graphic3d_VTA_TOP); + break; } - aLastPoint = isOneSideDimension ? theSecondAttach : ElCLib::Value (aSecondArrowBegin, aDimensionLine); + Standard_Real aLabelMargin = + aDimensionAspect->IsText3d() ? aDimensionAspect->TextAspect()->Height() * THE_3D_TEXT_MARGIN : 0.0; - aPrimSegments->AddVertex (aFirstPoint); - aPrimSegments->AddVertex (aLastPoint); - myGeom.mySensitiveSegments.Append (new Select3D_SensitiveSegment (anEmptyOwner, aFirstPoint, aLastPoint)); + Standard_Boolean isLineBreak = aDimensionAspect->TextVerticalPosition() == Prs3d_DTVP_Center + && aDimensionAspect->IsText3d(); + + Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (isLineBreak ? 4 : 2); + + // compute dimension continuous or sectioned dimension line + if (isLineBreak) + { + Standard_Real aPTextPosition = ElCLib::Parameter (aDimensionLine, myGeom.myTextPosition); + gp_Pnt aSection1Beg = aCenterLineBegin; + gp_Pnt aSection1End = ElCLib::Value (aPTextPosition - aLabelMargin - (aTextWidth * 0.5), aDimensionLine); + gp_Pnt aSection2Beg = ElCLib::Value (aPTextPosition + aLabelMargin + (aTextWidth * 0.5), aDimensionLine); + gp_Pnt aSection2End = aCenterLineEnd; + + aPrimSegments->AddVertex (aSection1Beg); + aPrimSegments->AddVertex (aSection1End); + aPrimSegments->AddVertex (aSection2Beg); + aPrimSegments->AddVertex (aSection2End); + + myGeom.mySensitiveSegments.Append (new Select3D_SensitiveSegment (anEmptyOwner, aSection1Beg, aSection1End)); + myGeom.mySensitiveSegments.Append (new Select3D_SensitiveSegment (anEmptyOwner, aSection2Beg, aSection2End)); + } + else + { + aPrimSegments->AddVertex (aCenterLineBegin); + aPrimSegments->AddVertex (aCenterLineEnd); + + myGeom.mySensitiveSegments.Append ( + new Select3D_SensitiveSegment (anEmptyOwner, aCenterLineBegin, aCenterLineEnd)); + } + + // set text label justification + Graphic3d_VerticalTextAlignment aTextJustificaton = Graphic3d_VTA_BOTTOM; + switch (aLabelPosition & LabelPosition_VMask) + { + case LabelPosition_Above : + case LabelPosition_VCenter : aTextJustificaton = Graphic3d_VTA_BOTTOM; break; + case LabelPosition_Below : aTextJustificaton = Graphic3d_VTA_TOP; break; + } + aDimensionAspect->TextAspect()->SetVerticalJustification (aTextJustificaton); // Main dimension line, short extension - if (theMode != AIS_DDM_Text) + if (!aDimensionAspect->IsText3d() && theMode == AIS_DDM_All) { - if (!aDimensionAspect->IsText3d() && theMode == AIS_DDM_All) - { - Prs3d_Root::CurrentGroup (thePresentation)->SetStencilTestOptions (Standard_True); - } - Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments); - if (!aDimensionAspect->IsText3d() && theMode == AIS_DDM_All) - { - Prs3d_Root::CurrentGroup (thePresentation)->SetStencilTestOptions (Standard_False); - } + Prs3d_Root::CurrentGroup (thePresentation)->SetStencilTestOptions (Standard_True); + } + Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect()); + Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments); + if (!aDimensionAspect->IsText3d() && theMode == AIS_DDM_All) + { + Prs3d_Root::CurrentGroup (thePresentation)->SetStencilTestOptions (Standard_False); } - break; - } - // Text is disposed from the left side of length dimension (after the left flyout line) - // Needs to create extensions: left for text and right for proper view of dimensions. - case Prs3d_HTA_Left: - { - aPrimSegments = new Graphic3d_ArrayOfSegments (4); - gp_Pnt aFirstArrowBeginPnt = ElCLib::Value (aFirstArrowBegin, aDimensionLine); - gp_Lin aLongExtLine (aDimensionLine.Location(), aDimensionLine.Direction().Reversed()); - gp_Pnt aStartPoint = ElCLib::Value (aFirstArrowBegin, aDimensionLine); + // add arrows to presentation + Prs3d_Root::NewGroup (thePresentation); + + drawArrow (thePresentation, aFirstArrowBegin, aFirstArrowDir); + if (!isOneSideDimension) + { + drawArrow (thePresentation, aSecondArrowBegin, aSecondArrowDir); + } + + if (!isArrowsExternal) + { + break; + } + + // add arrow extension lines to presentation + Prs3d_Root::NewGroup (thePresentation); + + drawExtension (thePresentation, anExtensionSize, + aFirstArrowEnd, aFirstExtensionDir, + THE_EMPTY_LABEL, theMode, LabelPosition_None); + if (!isOneSideDimension) + { + drawExtension (thePresentation, anExtensionSize, + aSecondArrowEnd, aSecondExtensionDir, + THE_EMPTY_LABEL, theMode, LabelPosition_None); + } + } + // ------------------------------------------------------------------------ // + // LEFT // + // -------------------------------------------------------------------------// + + case LabelPosition_Left: + { + // add label on dimension or extension line to presentation + Prs3d_Root::NewGroup (thePresentation); + // Left extension with the text - drawExtensionWithText (thePresentation, aStartPoint, aLongExtLine, aValueString, theMode); + drawExtension (thePresentation, anExtensionSize, + isArrowsExternal ? aFirstArrowEnd : aLineBegPoint, + aFirstExtensionDir, + aValueString, + theMode, + aLabelPosition); - // Central(main) dimension line - aFirstPoint = ElCLib::Value (aFirstArrowEnd, aDimensionLine); - aLastPoint = isOneSideDimension ? theSecondAttach : ElCLib::Value (aSecondArrowBegin, aDimensionLine); - aPrimSegments->AddVertex (aFirstPoint); - aPrimSegments->AddVertex (aLastPoint); - myGeom.mySensitiveSegments.Append (new Select3D_SensitiveSegment (anEmptyOwner, aFirstPoint, aLastPoint)); + if (theMode == AIS_DDM_Text) + { + break; + } - // Right extension + // add central dimension line + Prs3d_Root::NewGroup (thePresentation); + + Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (2); + aPrimSegments->AddVertex (aCenterLineBegin); + aPrimSegments->AddVertex (aCenterLineEnd); + Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect()); + Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments); + + myGeom.mySensitiveSegments.Append ( + new Select3D_SensitiveSegment (anEmptyOwner, aCenterLineBegin, aCenterLineEnd)); + + // add arrows to presentation + Prs3d_Root::NewGroup (thePresentation); + + drawArrow (thePresentation, aFirstArrowBegin, aFirstArrowDir); if (!isOneSideDimension) { - aFirstPoint = ElCLib::Value (aSecondArrowEnd, aDimensionLine); - aLastPoint = ElCLib::Value (aSecondArrowEnd + anArrowLength, aDimensionLine); - aPrimSegments->AddVertex (aFirstPoint); - aPrimSegments->AddVertex (aLastPoint); - myGeom.mySensitiveSegments.Append(new Select3D_SensitiveSegment (anEmptyOwner, aFirstPoint, aLastPoint)); + drawArrow (thePresentation, aSecondArrowBegin, aSecondArrowDir); } - if (theMode != AIS_DDM_Text) + + if (!isArrowsExternal || isOneSideDimension) { - // Main dimension line, short extension - Prs3d_Root::NewGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments); - // Group1: Add arrows to a group - drawArrow (thePresentation, aFirstArrowPosition, aFirstArrowDir); - if (!isOneSideDimension) - { - drawArrow (thePresentation, aSecondArrowPosition, aSecondArrowDir); - } + break; } + + // add extension lines for external arrows + Prs3d_Root::NewGroup (thePresentation); + + drawExtension (thePresentation, anExtensionSize, + aSecondArrowEnd, aSecondExtensionDir, + THE_EMPTY_LABEL, theMode, LabelPosition_None); + break; } - case Prs3d_HTA_Right: - { - aPrimSegments = new Graphic3d_ArrayOfSegments (4); - // Left extension - if (!isOneSideDimension) - { - aFirstPoint = ElCLib::Value (aFirstArrowBegin - anArrowLength, aDimensionLine); - aLastPoint = ElCLib::Value (aFirstArrowEnd, aDimensionLine); - aPrimSegments->AddVertex (aFirstPoint); - aPrimSegments->AddVertex (aLastPoint); - myGeom.mySensitiveSegments.Append (new Select3D_SensitiveSegment (anEmptyOwner, aFirstPoint, aLastPoint)); - } + // ------------------------------------------------------------------------ // + // RIGHT // + // -------------------------------------------------------------------------// - // Central(main) dimension line - aFirstPoint = isOneSideDimension ? theFirstAttach : ElCLib::Value (aFirstArrowEnd, aDimensionLine); - aLastPoint = ElCLib::Value (aSecondArrowBegin, aDimensionLine); - aPrimSegments->AddVertex (aFirstPoint); - aPrimSegments->AddVertex (aLastPoint); - myGeom.mySensitiveSegments.Append (new Select3D_SensitiveSegment (anEmptyOwner, aFirstPoint, aLastPoint)); + case LabelPosition_Right: + { + // add label on dimension or extension line to presentation + Prs3d_Root::NewGroup (thePresentation); // Right extension with text - aFirstPoint = ElCLib::Value (aSecondArrowEnd, aDimensionLine); - drawExtensionWithText (thePresentation, aFirstPoint, aDimensionLine, aValueString, theMode); + drawExtension (thePresentation, anExtensionSize, + isArrowsExternal ? aSecondArrowEnd : aSecondArrowBegin, + aSecondExtensionDir, + aValueString, + theMode, + aLabelPosition); - if (theMode != AIS_DDM_Text) + if (theMode == AIS_DDM_Text) { - // Main dimension line, short extension - Prs3d_Root::NewGroup(thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup(thePresentation)->AddPrimitiveArray (aPrimSegments); - // Group1, 2: Add arrows to a group - if (!isOneSideDimension) - { - drawArrow (thePresentation, aFirstArrowPosition, aFirstArrowDir); - } - - drawArrow (thePresentation, aSecondArrowPosition, aSecondArrowDir); + break; } + + // add central dimension line + Prs3d_Root::NewGroup (thePresentation); + + Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (2); + aPrimSegments->AddVertex (aCenterLineBegin); + aPrimSegments->AddVertex (aCenterLineEnd); + Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect()); + Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments); + + myGeom.mySensitiveSegments.Append ( + new Select3D_SensitiveSegment (anEmptyOwner, aCenterLineBegin, aCenterLineEnd)); + + // add arrows to presentation + Prs3d_Root::NewGroup (thePresentation); + + drawArrow (thePresentation, aSecondArrowBegin, aSecondArrowDir); + if (!isOneSideDimension) + { + drawArrow (thePresentation, aFirstArrowBegin, aFirstArrowDir); + } + + if (!isArrowsExternal || isOneSideDimension) + { + break; + } + + // add extension lines for external arrows + Prs3d_Root::NewGroup (thePresentation); + + drawExtension (thePresentation, anExtensionSize, + aFirstArrowEnd, aFirstExtensionDir, + THE_EMPTY_LABEL, theMode, LabelPosition_None); break; } } + // add flyout lines to presentation + if (theMode == AIS_DDM_All) + { + Prs3d_Root::NewGroup (thePresentation); + + Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments(4); + aPrimSegments->AddVertex (myFirstPoint); + aPrimSegments->AddVertex (aLineBegPoint); + + aPrimSegments->AddVertex (mySecondPoint); + aPrimSegments->AddVertex (aLineEndPoint); + + Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect(); + Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect()); + Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments); + } + setComputed (Standard_True); } @@ -872,7 +921,6 @@ void AIS_Dimension::drawLinearDimension (const Handle(Prs3d_Presentation)& thePr //function : SetFirstPoint //purpose : //======================================================================= - void AIS_Dimension::SetFirstPoint (const gp_Pnt& thePoint) { myFirstPoint = thePoint; @@ -882,7 +930,6 @@ void AIS_Dimension::SetFirstPoint (const gp_Pnt& thePoint) //function : SetSecondPoint //purpose : //======================================================================= - void AIS_Dimension::SetSecondPoint (const gp_Pnt& thePoint) { mySecondPoint = thePoint; @@ -892,7 +939,6 @@ void AIS_Dimension::SetSecondPoint (const gp_Pnt& thePoint) //function : Type //purpose : //======================================================================= - AIS_KindOfInteractive AIS_Dimension::Type() const { return AIS_KOI_Relation; @@ -902,7 +948,6 @@ AIS_KindOfInteractive AIS_Dimension::Type() const //function : circleFromPlanarFace //purpose : if possible computes circle from planar face //======================================================================= - Standard_Boolean AIS_Dimension::circleFromPlanarFace (const TopoDS_Face& theFace, Handle(Geom_Curve)& theCurve, gp_Pnt & theFirstPoint, @@ -927,7 +972,6 @@ Standard_Boolean AIS_Dimension::circleFromPlanarFace (const TopoDS_Face& theFace //function : initCircularDimension //purpose : if it's possible computes circle from planar face //======================================================================= - Standard_Boolean AIS_Dimension::initCircularDimension (const TopoDS_Shape& theShape, gp_Circ& theCircle, gp_Pnt& theMiddleArcPoint, @@ -1092,7 +1136,6 @@ Standard_Boolean AIS_Dimension::initCircularDimension (const TopoDS_Shape& theSh //function : SetDisplaySpecialSymbol //purpose : specifies dimension special symbol display options //======================================================================= - void AIS_Dimension::SetDisplaySpecialSymbol (const AIS_DisplaySpecialSymbol theDisplaySpecSymbol) { myDisplaySpecialSymbol = theDisplaySpecSymbol; @@ -1102,7 +1145,6 @@ void AIS_Dimension::SetDisplaySpecialSymbol (const AIS_DisplaySpecialSymbol theD //function : DisplaySpecialSymbol //purpose : shows dimension special symbol display options //======================================================================= - AIS_DisplaySpecialSymbol AIS_Dimension::DisplaySpecialSymbol() const { return myDisplaySpecialSymbol; @@ -1112,7 +1154,6 @@ AIS_DisplaySpecialSymbol AIS_Dimension::DisplaySpecialSymbol() const //function : SetSpecialSymbol //purpose : specifies special symbol //======================================================================= - void AIS_Dimension::SetSpecialSymbol (const Standard_ExtCharacter theSpecialSymbol) { mySpecialSymbol = theSpecialSymbol; @@ -1122,7 +1163,6 @@ void AIS_Dimension::SetSpecialSymbol (const Standard_ExtCharacter theSpecialSymb //function : SpecialSymbol //purpose : returns special symbol //======================================================================= - Standard_ExtCharacter AIS_Dimension::SpecialSymbol() const { return mySpecialSymbol; @@ -1132,7 +1172,6 @@ Standard_ExtCharacter AIS_Dimension::SpecialSymbol() const //function : IsUnitsDisplayed //purpose : shows if Units are to be displayed along with dimension value //======================================================================= - Standard_Boolean AIS_Dimension::IsUnitsDisplayed() const { return myToDisplayUnits; @@ -1142,7 +1181,6 @@ Standard_Boolean AIS_Dimension::IsUnitsDisplayed() const //function : MakeUnitsDisplayed //purpose : sets to display units along with the dimension value or no //======================================================================= - void AIS_Dimension::MakeUnitsDisplayed (const Standard_Boolean toDisplayUnits) { myToDisplayUnits = toDisplayUnits; @@ -1152,7 +1190,6 @@ void AIS_Dimension::MakeUnitsDisplayed (const Standard_Boolean toDisplayUnits) //function : MakeUnitsDisplayed //purpose : returns the current type of units //======================================================================= - TCollection_AsciiString AIS_Dimension::UnitsQuantity() const { return myUnitsQuantity; @@ -1162,7 +1199,6 @@ TCollection_AsciiString AIS_Dimension::UnitsQuantity() const //function : SetUnitsQuantity //purpose : sets the current type of units //======================================================================= - void AIS_Dimension::SetUnitsQuantity (const TCollection_AsciiString& theUnitsQuantity) { myUnitsQuantity = theUnitsQuantity; @@ -1172,7 +1208,6 @@ void AIS_Dimension::SetUnitsQuantity (const TCollection_AsciiString& theUnitsQua //function : ModelUnits //purpose : returns the current model units //======================================================================= - TCollection_AsciiString AIS_Dimension::ModelUnits() const { return myModelUnits; @@ -1182,7 +1217,6 @@ TCollection_AsciiString AIS_Dimension::ModelUnits() const //function : SetModelUnits //purpose : sets the current model units //======================================================================= - void AIS_Dimension::SetModelUnits (const TCollection_AsciiString& theUnits) { myModelUnits = theUnits; @@ -1192,7 +1226,6 @@ void AIS_Dimension::SetModelUnits (const TCollection_AsciiString& theUnits) //function : DisplayUnits //purpose : returns the current display units //======================================================================= - TCollection_AsciiString AIS_Dimension::DisplayUnits() const { return myDisplayUnits; @@ -1202,7 +1235,6 @@ TCollection_AsciiString AIS_Dimension::DisplayUnits() const //function : SetDisplayUnits //purpose : sets the current display units //======================================================================= - void AIS_Dimension::SetDisplayUnits (const TCollection_AsciiString& theUnits) { myDisplayUnits = theUnits; @@ -1212,7 +1244,6 @@ void AIS_Dimension::SetDisplayUnits (const TCollection_AsciiString& theUnits) //function : isComputed //purpose : //======================================================================= - Standard_Boolean AIS_Dimension::isComputed() const { return myGeom.myIsComputed; @@ -1222,7 +1253,6 @@ Standard_Boolean AIS_Dimension::isComputed() const //function : setComputed //purpose : //======================================================================= - void AIS_Dimension::setComputed (Standard_Boolean isComputed) { myGeom.myIsComputed = isComputed; @@ -1232,7 +1262,6 @@ void AIS_Dimension::setComputed (Standard_Boolean isComputed) //function : textPosition //purpose : //======================================================================= - gp_Pnt AIS_Dimension::textPosition() const { return myGeom.myTextPosition; @@ -1242,7 +1271,6 @@ gp_Pnt AIS_Dimension::textPosition() const //function : setTextPosition //purpose : //======================================================================= - void AIS_Dimension::setTextPosition (const gp_Pnt thePosition) { myGeom.myTextPosition = thePosition; @@ -1252,7 +1280,6 @@ void AIS_Dimension::setTextPosition (const gp_Pnt thePosition) //function : resetGeom //purpose : //======================================================================= - void AIS_Dimension::resetGeom() { setComputed (Standard_False); @@ -1262,7 +1289,6 @@ void AIS_Dimension::resetGeom() //function : IsTextReversed //purpose : //======================================================================= - Standard_Boolean AIS_Dimension::IsTextReversed() const { return myIsTextReversed; @@ -1272,7 +1298,6 @@ Standard_Boolean AIS_Dimension::IsTextReversed() const //function : MakeTextReversed //purpose : //======================================================================= - void AIS_Dimension::MakeTextReversed (const Standard_Boolean isTextReversed) { myIsTextReversed = isTextReversed; @@ -1282,7 +1307,6 @@ void AIS_Dimension::MakeTextReversed (const Standard_Boolean isTextReversed) //function : SetSelToleranceForText2d //purpose : //======================================================================= - void AIS_Dimension::SetSelToleranceForText2d (const Standard_Real theTol) { myGeom.mySelToleranceForText2d = theTol; @@ -1292,7 +1316,6 @@ void AIS_Dimension::SetSelToleranceForText2d (const Standard_Real theTol) //function : SelToleranceForText2d //purpose : //======================================================================= - Standard_Real AIS_Dimension::SelToleranceForText2d() const { return myGeom.mySelToleranceForText2d; @@ -1300,56 +1323,52 @@ Standard_Real AIS_Dimension::SelToleranceForText2d() const //======================================================================= //function : SetFlyout -//purpose : +//purpose : //======================================================================= - void AIS_Dimension::SetFlyout (const Standard_Real theFlyout) { - myFlyout = theFlyout; -} + if (myFlyout == theFlyout) + { + return; + } -//======================================================================= -//function : GetFlyout -//purpose : -//======================================================================= - -Standard_Real AIS_Dimension::GetFlyout () const -{ - return myFlyout; + myFlyout = theFlyout; + SetToUpdate(); } //======================================================================= //function : computeFlyoutSelection //purpose : computes selection for flyouts //======================================================================= - void AIS_Dimension::computeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection, - const Handle(AIS_DimensionOwner)& theOwner) + const Handle(AIS_DimensionOwner)& theOwner) { - //Count flyout direction - gp_Ax1 aWorkingPlaneNormal = GetWorkingPlane().Axis(); - gp_Dir aTargetPointsVector = gce_MakeDir (myFirstPoint, mySecondPoint); - // Count a flyout direction vector. - gp_Dir aFlyoutVector = aWorkingPlaneNormal.Direction()^aTargetPointsVector; - // Create lines for layouts - gp_Lin aLine1 (myFirstPoint, aFlyoutVector); - gp_Lin aLine2 (mySecondPoint, aFlyoutVector); - // Get flyout end points - gp_Pnt aFlyoutEnd1 = ElCLib::Value (ElCLib::Parameter (aLine1, myFirstPoint) + GetFlyout(), aLine1); - gp_Pnt aFlyoutEnd2 = ElCLib::Value (ElCLib::Parameter (aLine2, mySecondPoint) + GetFlyout(), aLine2); + //Count flyout direction + gp_Ax1 aWorkingPlaneNormal = GetWorkingPlane().Axis(); + gp_Dir aTargetPointsVector = gce_MakeDir (myFirstPoint, mySecondPoint); - // Fill sensitive entity for flyouts - Handle(Select3D_SensitiveGroup) aSensitiveEntity = new Select3D_SensitiveGroup (theOwner); - aSensitiveEntity->Add (new Select3D_SensitiveSegment (theOwner, myFirstPoint, aFlyoutEnd1)); - aSensitiveEntity->Add (new Select3D_SensitiveSegment (theOwner, mySecondPoint, aFlyoutEnd2)); - theSelection->Add (aSensitiveEntity); + // Count a flyout direction vector. + gp_Dir aFlyoutVector = aWorkingPlaneNormal.Direction()^aTargetPointsVector; + + // Create lines for layouts + gp_Lin aLine1 (myFirstPoint, aFlyoutVector); + gp_Lin aLine2 (mySecondPoint, aFlyoutVector); + + // Get flyout end points + gp_Pnt aFlyoutEnd1 = ElCLib::Value (ElCLib::Parameter (aLine1, myFirstPoint) + GetFlyout(), aLine1); + gp_Pnt aFlyoutEnd2 = ElCLib::Value (ElCLib::Parameter (aLine2, mySecondPoint) + GetFlyout(), aLine2); + + // Fill sensitive entity for flyouts + Handle(Select3D_SensitiveGroup) aSensitiveEntity = new Select3D_SensitiveGroup (theOwner); + aSensitiveEntity->Add (new Select3D_SensitiveSegment (theOwner, myFirstPoint, aFlyoutEnd1)); + aSensitiveEntity->Add (new Select3D_SensitiveSegment (theOwner, mySecondPoint, aFlyoutEnd2)); + theSelection->Add (aSensitiveEntity); } //======================================================================= //function : ComputeSelection //purpose : //======================================================================= - void AIS_Dimension::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer theMode) { @@ -1391,7 +1410,9 @@ void AIS_Dimension::ComputeSelection (const Handle(SelectMgr_Selection)& theSele aSensitiveForText->Set (aTextOwner); } else + { computeFlyoutSelection (theSelection, anOwner); + } theSelection->Add (aSensitiveForLine); theSelection->Add (aSensitiveForText); diff --git a/src/AIS/AIS_Dimension.hxx b/src/AIS/AIS_Dimension.hxx index f8d33ee024..534794a7fd 100644 --- a/src/AIS/AIS_Dimension.hxx +++ b/src/AIS/AIS_Dimension.hxx @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -47,14 +46,32 @@ DEFINE_STANDARD_HANDLE(AIS_Dimension, AIS_InteractiveObject) class AIS_Dimension : public AIS_InteractiveObject { +protected: + + // Specifies supported at base level horizontal and vertical + // label positions for drawing extension lines and centered text. + enum LabelPosition + { + LabelPosition_None = 0x00, + + LabelPosition_Left = 0x01, + LabelPosition_Right = 0x02, + LabelPosition_HCenter = 0x04, + LabelPosition_HMask = LabelPosition_Left | LabelPosition_Right | LabelPosition_HCenter, + + LabelPosition_Above = 0x10, + LabelPosition_Below = 0x20, + LabelPosition_VCenter = 0x40, + LabelPosition_VMask = LabelPosition_Above | LabelPosition_Below | LabelPosition_VCenter + }; + public: + //! Constructor with default parameters values - Standard_EXPORT AIS_Dimension (const Standard_Real theExtensionSize = 1.0); - //! Constructor to set aspect of dimension - Standard_EXPORT AIS_Dimension (const Handle(Prs3d_DimensionAspect)& theAspect, - const Standard_Real theExtensionSize = 1.0); + Standard_EXPORT AIS_Dimension(); + //! Gets dimension value - Standard_EXPORT Standard_Real GetValue () const; + Standard_EXPORT Standard_Real GetValue() const; //! Sets dimension value //! Attention! This method is used ONLY to set custom value. @@ -67,12 +84,6 @@ public: //! Sets working plane. Standard_EXPORT void SetWorkingPlane (const gp_Pln& thePlane); - //! Sets extension size. - Standard_EXPORT void SetExtensionSize (const Standard_Real theExtensionSize); - - //! Gets extension size. - Standard_EXPORT Standard_Real GetExtensionSize() const; - Standard_EXPORT void SetFirstPoint (const gp_Pnt& thePoint); Standard_EXPORT void SetSecondPoint (const gp_Pnt& thePoint); @@ -101,71 +112,91 @@ public: //! The interactive context can have a default mode of //! representation for the set of Interactive Objects. This //! mode may not be accepted by object - Standard_EXPORT virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const; + Standard_EXPORT virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const; + // Selection computing if it is needed here Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer theMode); + //! Reset working plane to default. Standard_EXPORT void ResetWorkingPlane(); + //! specifies dimension special symbol display options Standard_EXPORT void SetDisplaySpecialSymbol (const AIS_DisplaySpecialSymbol theDisplaySpecSymbol); + //! shows dimension special symbol display options Standard_EXPORT AIS_DisplaySpecialSymbol DisplaySpecialSymbol() const; + //! specifies special symbol Standard_EXPORT void SetSpecialSymbol (const Standard_ExtCharacter theSpecialSymbol); + //! returns special symbol Standard_EXPORT Standard_ExtCharacter SpecialSymbol() const; + //! shows if Units are to be displayed along with dimension value Standard_EXPORT Standard_Boolean IsUnitsDisplayed() const; + //! sets to display units along with the dimansion value or no Standard_EXPORT void MakeUnitsDisplayed (const Standard_Boolean toDisplayUnits); + //! returns the current type of units Standard_EXPORT TCollection_AsciiString UnitsQuantity() const; + //! sets the current type of units Standard_EXPORT void SetUnitsQuantity (const TCollection_AsciiString& theUnitsQuantity); + //! returns the current model units Standard_EXPORT TCollection_AsciiString ModelUnits() const; + //! sets the current model units Standard_EXPORT void SetModelUnits (const TCollection_AsciiString& theUnits); + //! returns the current display units Standard_EXPORT TCollection_AsciiString DisplayUnits() const; + //! sets the current display units Standard_EXPORT void SetDisplayUnits (const TCollection_AsciiString& theUnits); - //! sets the text offset: distance from attach point to the text on the extension - //! in case if text isn't in center of the dimension line - Standard_EXPORT void SetTextOffset (const Standard_Real theOffset); - //! returns the text offset: distance from attach point to the text on the extension - //! in case if text isn't in center of the dimension line - Standard_EXPORT Standard_Real TextOffset() const; + //! Important! Only for 3d text
//! 3d text is oriented relative to the attachment points order
//! By default, text direction vector is oriented from the first attachment point
//! to the second one. This method checks if text direction is to be default or
//! should be reversed. Standard_EXPORT Standard_Boolean IsTextReversed() const; + //! Important! Only for 3d text //! 3d text is oriented relative to the attachment points order
//! By default, text direction vector is oriented from the first attachment point
//! to the second one. This method sets value that shows if text direction
//! should be reversed or not. Standard_EXPORT void MakeTextReversed (const Standard_Boolean isTextReversed); + //! Sets selection tolerance for text2d: //! For 2d text selection detection sensitive point with tolerance is used //! to change this tolerance use this method //! Important! Only for 2d text Standard_EXPORT void SetSelToleranceForText2d (const Standard_Real theTol); + //! Returns selection tolerance for text2d: //! For 2d text selection detection sensitive point with tolerance is used //! Important! Only for 2d text Standard_EXPORT Standard_Real SelToleranceForText2d() const; + //! Sets flyout size for dimension. Standard_EXPORT void SetFlyout (const Standard_Real theFlyout); + //! @return flyout size for dimension. - Standard_EXPORT Standard_Real GetFlyout () const; + Standard_Real GetFlyout() const + { + return myFlyout; + } + +public: DEFINE_STANDARD_RTTI(AIS_Dimension) protected: + Standard_EXPORT void getTextWidthAndString (Quantity_Length& theWidth, TCollection_ExtendedString& theString) const; @@ -190,19 +221,27 @@ protected: Standard_EXPORT Standard_Real drawText (const Handle(Prs3d_Presentation)& thePresentation, const gp_Dir& theTextDir, const TCollection_ExtendedString theText, - const AIS_DimensionDisplayMode theMode); + const AIS_DimensionDisplayMode theMode, + const Standard_Integer theLabelPosition); //! Performs computing of dimension linear extension with text - Standard_EXPORT virtual void drawExtensionWithText (const Handle(Prs3d_Presentation)& thePresentation, - const gp_Pnt& theStartPoint, - const gp_Lin& theDimensionLine, - const TCollection_ExtendedString& theValueString, - const AIS_DimensionDisplayMode theMode); + //! @param thePresentation [in] the presentation to fill with graphical primitives. + //! @param theExtensionSize [in] the size of extension line. + //! @param theExtensionStart [in] the point where extension line connects to dimension. + //! @param theExtensionDir [in] the direction of extension line. + //! @param theValueString [in] the string with value. + //! @param theMode [in] the display mode. + //! @param theLabelPosition [in] position flags for the text label. + Standard_EXPORT void drawExtension (const Handle(Prs3d_Presentation)& thePresentation, + const Standard_Real theExtensionSize, + const gp_Pnt& theExtensionStart, + const gp_Dir& theExtensionDir, + const TCollection_ExtendedString& theValueString, + const AIS_DimensionDisplayMode theMode, + const Standard_Integer theLabelPosition); //! Performs computing of linear dimension (for length, diameter, radius and so on) Standard_EXPORT void drawLinearDimension (const Handle(Prs3d_Presentation)& thePresentation, - const gp_Pnt& theFirstAttach, - const gp_Pnt& theSecondAttach, const AIS_DimensionDisplayMode theMode, const Standard_Boolean isOneSideDimension = Standard_False); @@ -231,39 +270,44 @@ protected: //! Fills sensitive entity for flyouts and adds it to the selection. Standard_EXPORT virtual void computeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection, const Handle(AIS_DimensionOwner)& theOwner); - // Fields -protected: - /// WORKING PLANE PROPERTIES +protected: //! @name Working plane properties //! Dimension default plane gp_Pln myDefaultPlane; + //! Shows if working plane is set custom Standard_Boolean myIsWorkingPlaneCustom; - /// VALUE PROPERTIES +protected: //! @name Value properties //! Dimension value which is displayed with dimension lines Standard_Real myValue; + //! Shows if the value is set by user and is no need to count it automatically Standard_Boolean myIsValueCustom; - /// UNITS PROPERTIES +protected: // !@name Units properties //! The quantity of units for the value computation TCollection_AsciiString myUnitsQuantity; + //! Units of the model TCollection_AsciiString myModelUnits; + //! Units in which the displayed value will be converted TCollection_AsciiString myDisplayUnits; + //! Determines if units is to be displayed along with the value Standard_Boolean myToDisplayUnits; + //! Special symbol for some kind of dimensions (for diameter, radius and so on) Standard_ExtCharacter mySpecialSymbol; + //! Special symbol display options AIS_DisplaySpecialSymbol myDisplaySpecialSymbol; - /// GEOMETRY PROPERTIES +protected: //! @name Geometry properties //! Geometry of dimensions, needs for advanced selection //! Geometry is computed in Compute() method and is used @@ -274,57 +318,66 @@ protected: { //! Text position gp_Pnt myTextPosition; + //! Text bounding box, stored for advanced selection Bnd_Box myTextBndBox; + //! Sensitive point tolerance for 2d text selection Standard_Real mySelToleranceForText2d; + //! For advanced dimension line selection Select3D_ListOfSensitive mySensitiveSegments; + //! Shows if attachment points were computed Standard_Boolean myIsComputed; + public: - DimensionGeom () - : myIsComputed (Standard_False) - { } + + DimensionGeom () : myIsComputed (Standard_False) {} }; //! Shows if text is inverted Standard_Boolean myIsTextReversed; - //! Determines distance from attach point to the text on the extension - //! in case if text isn't in center of the dimension line - Standard_Real myTextOffset; + //! Points that are base for dimension. //! My first point of dimension attach (belongs to shape for which dimension is computed) gp_Pnt myFirstPoint; + //! My second point of dimension attach (belongs to shape for which dimension is computed) gp_Pnt mySecondPoint; + //! Shows if attach points are initialized correctly Standard_Boolean myIsInitialized; + //! First shape (can be vertex, edge or face) TopoDS_Shape myFirstShape; + //! Second shape (can be vertex, edge or face) TopoDS_Shape mySecondShape; + //! Number of shapes Standard_Integer myShapesNumber; + //! Defines flyout lines and direction //! Flyout direction in the working plane. //! Can be negative, or positive and is defined by the sign of myFlyout value. //! The direction vector is counting using the working plane. //! myFlyout value defined the size of flyout. Standard_Real myFlyout; + //! Geometry of dimensions, needs for advanced selection //! Geometry is computed in Compute() method and is used //! in ComputeSelection() method. //! If it is computed successfully, myIsComputed = Standard_True. //! to check computing result use IsComputed() method DimensionGeom myGeom; + private: + //! Type of dimension AIS_KindOfDimension myKindOfDimension; + //! Dimension working plane, is equal to if it can be computed automatically. gp_Pln myWorkingPlane; - //! Extension size in model measure units. - //! No inclined or curved extension line is now supported. - Standard_Real myExtensionSize; }; #endif diff --git a/src/AIS/AIS_LengthDimension.cxx b/src/AIS/AIS_LengthDimension.cxx index 22280a014e..f602bb047e 100755 --- a/src/AIS/AIS_LengthDimension.cxx +++ b/src/AIS/AIS_LengthDimension.cxx @@ -18,65 +18,24 @@ // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. - -#define BUC60915 //GG 05/06/01 Enable to compute the requested arrow size -// if any in all dimensions. - - - #include #include -#include -#include #include #include -#include #include #include #include -#include -#include #include #include -#include -#include -#include #include -#include -#include #include -#include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include #include #include -#include IMPLEMENT_STANDARD_HANDLE(AIS_LengthDimension, AIS_Dimension) IMPLEMENT_STANDARD_RTTIEXT(AIS_LengthDimension, AIS_Dimension) @@ -86,33 +45,10 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_LengthDimension, AIS_Dimension) //purpose : Dimension between two points //======================================================================= -AIS_LengthDimension::AIS_LengthDimension (const gp_Pnt& theFirstPoint, - const gp_Pnt& theSecondPoint, - const gp_Pln& theDimensionPlane, - const Handle(Prs3d_DimensionAspect)& theDimensionAspect, - const Standard_Real theExtensionSize /*= 1.0*/) - :AIS_Dimension (theDimensionAspect,theExtensionSize) -{ - myIsInitialized = Standard_True; - myFirstPoint = theFirstPoint; - mySecondPoint = theSecondPoint; - myShapesNumber = 2; - myFirstShape = BRepLib_MakeVertex (myFirstPoint); - mySecondShape = BRepLib_MakeVertex (mySecondPoint); - SetFlyout (15.0); - SetKindOfDimension(AIS_KOD_LENGTH); - SetWorkingPlane (theDimensionPlane); -} - -//======================================================================= -//function : Constructor -//purpose : Dimension between two points -//======================================================================= - AIS_LengthDimension::AIS_LengthDimension (const gp_Pnt& theFirstPoint, const gp_Pnt& theSecondPoint, const gp_Pln& theDimensionPlane) -: AIS_Dimension () +: AIS_Dimension() { myIsInitialized = Standard_True; myFirstPoint = theFirstPoint; @@ -120,9 +56,9 @@ AIS_LengthDimension::AIS_LengthDimension (const gp_Pnt& theFirstPoint, myFirstShape = BRepLib_MakeVertex (myFirstPoint); mySecondShape = BRepLib_MakeVertex (mySecondPoint); myShapesNumber = 2; - SetFlyout (15.0); SetKindOfDimension (AIS_KOD_LENGTH); SetWorkingPlane (theDimensionPlane); + SetFlyout (15.0); } //======================================================================= @@ -133,15 +69,15 @@ AIS_LengthDimension::AIS_LengthDimension (const gp_Pnt& theFirstPoint, AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Shape& theFirstShape, const TopoDS_Shape& theSecondShape, const gp_Pln& theWorkingPlane) -: AIS_Dimension () +: AIS_Dimension() { myIsInitialized = Standard_False; myFirstShape = theFirstShape; mySecondShape = theSecondShape; myShapesNumber = 2; - SetFlyout (15.0); SetKindOfDimension (AIS_KOD_LENGTH); SetWorkingPlane (theWorkingPlane); + SetFlyout (15.0); } //======================================================================= @@ -151,14 +87,14 @@ AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Shape& theFirstShape, AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Edge& theEdge, const gp_Pln& theWorkingPlane) -: AIS_Dimension () +: AIS_Dimension() { myIsInitialized = Standard_False; myFirstShape = theEdge; myShapesNumber = 1; - SetFlyout (15.0); SetKindOfDimension (AIS_KOD_LENGTH); SetWorkingPlane (theWorkingPlane); + SetFlyout (15.0); } //======================================================================= @@ -168,14 +104,14 @@ AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Edge& theEdge, AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Face& theFirstFace, const TopoDS_Face& theSecondFace) -: AIS_Dimension () +: AIS_Dimension() { myIsInitialized = Standard_False; myFirstShape = theFirstFace; mySecondShape = theSecondFace; myShapesNumber = 2; + SetKindOfDimension (AIS_KOD_LENGTH); SetFlyout (15.0); - SetKindOfDimension(AIS_KOD_LENGTH); } //======================================================================= @@ -185,13 +121,13 @@ AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Face& theFirstFace, AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Face& theFace, const TopoDS_Edge& theEdge) - : AIS_Dimension () +: AIS_Dimension() { - SetKindOfDimension(AIS_KOD_LENGTH); myIsInitialized = Standard_False; myFirstShape = theFace; mySecondShape = theEdge; myShapesNumber = 2; + SetKindOfDimension (AIS_KOD_LENGTH); SetFlyout (15.0); } @@ -201,8 +137,8 @@ AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Face& theFace, //======================================================================= Standard_Boolean AIS_LengthDimension::initTwoEdgesLength (const TopoDS_Edge & theFirstEdge, - const TopoDS_Edge& theSecondEdge, - gp_Dir& theDirAttach) + const TopoDS_Edge& theSecondEdge, + gp_Dir& theDirAttach) { Standard_Integer anExtShapeIndex = 0; BRepAdaptor_Curve aFirstCurveAdapt (theFirstEdge); @@ -280,9 +216,9 @@ Standard_Boolean AIS_LengthDimension::initTwoEdgesLength (const TopoDS_Edge & th //======================================================================= Standard_Boolean AIS_LengthDimension::initEdgeVertexLength (const TopoDS_Edge & theEdge, - const TopoDS_Vertex & theVertex, - gp_Dir & theDirAttach, - Standard_Boolean isInfinite) + const TopoDS_Vertex & theVertex, + gp_Dir & theDirAttach, + Standard_Boolean isInfinite) { gp_Pnt anEdgePoint1,anEdgePoint2; Handle(Geom_Curve) aCurve; @@ -561,50 +497,28 @@ void AIS_LengthDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& / if (!myIsInitialized) { if (myShapesNumber == 1) - myIsInitialized = initOneShapePoints(myFirstShape); + { + myIsInitialized = initOneShapePoints (myFirstShape); + } else if (myShapesNumber == 2) - myIsInitialized = initTwoShapesPoints(myFirstShape, mySecondShape); + { + myIsInitialized = initTwoShapesPoints (myFirstShape, mySecondShape); + } else + { return; + } } - + // If initialization failed if (!myIsInitialized) + { return; + } thePresentation->Clear(); - // Get length dimension aspect from AIS object drawer - Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect(); - Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect()); - //Count flyout direction - gp_Ax1 aWorkingPlaneNormal = GetWorkingPlane().Axis(); - gp_Dir aTargetPointsVector = gce_MakeDir (myFirstPoint, mySecondPoint); - // Count a flyout direction vector. - gp_Dir aFlyoutVector = aWorkingPlaneNormal.Direction()^aTargetPointsVector; - - // Create lines for layouts - gp_Lin aLine1 (myFirstPoint, aFlyoutVector); - gp_Lin aLine2 (mySecondPoint, aFlyoutVector); - - // Get flyout end points - gp_Pnt aFlyoutEnd1 = ElCLib::Value (ElCLib::Parameter (aLine1, myFirstPoint) + GetFlyout(), aLine1); - gp_Pnt aFlyoutEnd2 = ElCLib::Value (ElCLib::Parameter (aLine2, mySecondPoint) + GetFlyout(), aLine2); - - // Add layout lines to graphic group - // Common to all type of dimension placement. - if (theMode == 0) - { - Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments(4); - aPrimSegments->AddVertex (myFirstPoint); - aPrimSegments->AddVertex (aFlyoutEnd1); - - aPrimSegments->AddVertex (mySecondPoint); - aPrimSegments->AddVertex (aFlyoutEnd2); - - Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments); - } - drawLinearDimension (thePresentation, aFlyoutEnd1, aFlyoutEnd2, (AIS_DimensionDisplayMode)theMode); + drawLinearDimension (thePresentation, (AIS_DimensionDisplayMode)theMode); } //======================================================================= @@ -612,7 +526,7 @@ void AIS_LengthDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& / //purpose : //======================================================================= -void AIS_LengthDimension::computeValue () +void AIS_LengthDimension::computeValue() { myValue = myFirstPoint.Distance (mySecondPoint); AIS_Dimension::computeValue (); diff --git a/src/AIS/AIS_LengthDimension.hxx b/src/AIS/AIS_LengthDimension.hxx index 0d1207ea66..674566d1a4 100644 --- a/src/AIS/AIS_LengthDimension.hxx +++ b/src/AIS/AIS_LengthDimension.hxx @@ -67,15 +67,6 @@ class AIS_LengthDimension : public AIS_Dimension { public: - //! Constructor with full parameter list. - //! Construct dimension between two vertices. - //! Style of line, arrow and text can be set by default. - Standard_EXPORT AIS_LengthDimension (const gp_Pnt& theFirstPoint, - const gp_Pnt& theSecondPoint, - const gp_Pln& theDimensionPlane, - const Handle(Prs3d_DimensionAspect)& theDimensionAspect, - const Standard_Real theExtensionSize = 1.0); - Standard_EXPORT AIS_LengthDimension (const gp_Pnt& theFirstPoint, const gp_Pnt& theSecondPoint, const gp_Pln& theDimensionPlane); @@ -94,35 +85,42 @@ public: Standard_EXPORT AIS_LengthDimension (const TopoDS_Face& theFace, const TopoDS_Edge& theEdge); +public: + DEFINE_STANDARD_RTTI(AIS_LengthDimension) + private: + Standard_Boolean initTwoEdgesLength (const TopoDS_Edge & theFirstEdge, - const TopoDS_Edge& theSecondEdge, - gp_Dir& theDirAttach); + const TopoDS_Edge& theSecondEdge, + gp_Dir& theDirAttach); + //! Auxiliary method for //! in case of the distance between edge and vertex Standard_Boolean initEdgeVertexLength (const TopoDS_Edge & theEdge, - const TopoDS_Vertex & theVertex, - gp_Dir & theDirAttach, - Standard_Boolean isInfinite); + const TopoDS_Vertex & theVertex, + gp_Dir & theDirAttach, + Standard_Boolean isInfinite); + //! Auxiliary method for //! in case of the distance between face and edge Standard_Boolean initEdgeFaceLength (const TopoDS_Edge& theEdge, const TopoDS_Face& theFace, gp_Dir& theDirAttach); + //! Initialization of two attach points in case of two owner shapes Standard_Boolean initTwoShapesPoints (const TopoDS_Shape& theFirstShape, - const TopoDS_Shape& theSecondShape); + const TopoDS_Shape& theSecondShape); + //! Initialization of two attach points in case of one owner shape Standard_Boolean initOneShapePoints (const TopoDS_Shape& theShape); //! Compute length in display units. - virtual void computeValue (); + virtual void computeValue(); virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0) ; - }; #endif diff --git a/src/AIS/AIS_RadiusDimension.cxx b/src/AIS/AIS_RadiusDimension.cxx index 9b424752e0..06c7e071f2 100755 --- a/src/AIS/AIS_RadiusDimension.cxx +++ b/src/AIS/AIS_RadiusDimension.cxx @@ -18,52 +18,16 @@ // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. -#include - #include #include #include -#include -#include -#include -#include -#include -#include #include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include -#include #include -#include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include IMPLEMENT_STANDARD_HANDLE(AIS_RadiusDimension, AIS_Dimension) IMPLEMENT_STANDARD_RTTIEXT(AIS_RadiusDimension, AIS_Dimension) @@ -82,9 +46,15 @@ AIS_RadiusDimension::AIS_RadiusDimension (const gp_Circ& theCircle) myIsInitialized = Standard_True; SetSpecialSymbol ('R'); SetDisplaySpecialSymbol (AIS_DSS_Before); - SetKindOfDimension(AIS_KOD_RADIUS); + SetKindOfDimension (AIS_KOD_RADIUS); + SetFlyout (0.0); } +//======================================================================= +//function : Constructor +//purpose : +//======================================================================= + AIS_RadiusDimension::AIS_RadiusDimension (const gp_Circ& theCircle, const gp_Pnt& theAttachPoint) : AIS_Dimension(), @@ -96,6 +66,7 @@ AIS_RadiusDimension::AIS_RadiusDimension (const gp_Circ& theCircle, SetSpecialSymbol ('R'); SetDisplaySpecialSymbol (AIS_DSS_Before); SetKindOfDimension (AIS_KOD_RADIUS); + SetFlyout (0.0); } //======================================================================= @@ -111,44 +82,7 @@ AIS_RadiusDimension::AIS_RadiusDimension (const TopoDS_Shape& theShape) SetSpecialSymbol ('R'); SetDisplaySpecialSymbol (AIS_DSS_Before); SetKindOfDimension (AIS_KOD_RADIUS); -} - -//======================================================================= -//function : Constructor -//purpose : -//======================================================================= - -AIS_RadiusDimension::AIS_RadiusDimension (const gp_Circ& theCircle, - const Handle(Prs3d_DimensionAspect)& theDimensionAspect, - const Standard_Real theExtensionSize/* = 1.0*/) - -: AIS_Dimension (theDimensionAspect,theExtensionSize), - myCircle (theCircle) -{ - myFirstPoint = ElCLib::Value(0, myCircle); - mySecondPoint = theCircle.Location(); - SetSpecialSymbol ('R'); - SetDisplaySpecialSymbol (AIS_DSS_Before); - SetKindOfDimension (AIS_KOD_RADIUS); -} - -//======================================================================= -//function : Constructor -//purpose : -//======================================================================= - -AIS_RadiusDimension::AIS_RadiusDimension (const gp_Circ& theCircle, - const gp_Pnt& theAttachPoint, - const Handle(Prs3d_DimensionAspect)& theDimensionAspect, - const Standard_Real theExtensionSize/* = 1.0*/) -: AIS_Dimension (theDimensionAspect,theExtensionSize), - myCircle (theCircle) -{ - myFirstPoint = theAttachPoint; - mySecondPoint = theCircle.Location(); - SetSpecialSymbol ('R'); - SetDisplaySpecialSymbol (AIS_DSS_Before); - SetKindOfDimension (AIS_KOD_RADIUS); + SetFlyout (0.0); } //======================================================================= @@ -177,38 +111,13 @@ void AIS_RadiusDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& / myIsInitialized = Standard_True; } } + if (!myIsWorkingPlaneCustom) - countDefaultPlane(); - - //Count flyout direction - gp_Ax1 aWorkingPlaneNormal = GetWorkingPlane().Axis(); - gp_Dir aTargetPointsVector = gce_MakeDir (myFirstPoint, mySecondPoint); - // Count a flyout direction vector. - gp_Dir aFlyoutVector = aWorkingPlaneNormal.Direction()^aTargetPointsVector; - - // Create lines for layouts - gp_Lin aLine1 (myFirstPoint, aFlyoutVector); - gp_Lin aLine2 (mySecondPoint, aFlyoutVector); - - // Get flyout end points - gp_Pnt aFlyoutEnd1 = ElCLib::Value (ElCLib::Parameter (aLine1, myFirstPoint) + GetFlyout(), aLine1); - gp_Pnt aFlyoutEnd2 = ElCLib::Value (ElCLib::Parameter (aLine2, mySecondPoint) + GetFlyout(), aLine2); - - // Add layout lines to graphic group - // Common to all type of dimension placement. - if (theMode == 0) { - Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments(4); - aPrimSegments->AddVertex (myFirstPoint); - aPrimSegments->AddVertex (aFlyoutEnd1); - - aPrimSegments->AddVertex (mySecondPoint); - aPrimSegments->AddVertex (aFlyoutEnd2); - - Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments); + countDefaultPlane(); } - drawLinearDimension (thePresentation, aFlyoutEnd1, aFlyoutEnd2, (AIS_DimensionDisplayMode)theMode, Standard_True); + drawLinearDimension (thePresentation, (AIS_DimensionDisplayMode)theMode, Standard_True); } //======================================================================= diff --git a/src/AIS/AIS_RadiusDimension.hxx b/src/AIS/AIS_RadiusDimension.hxx index 88bbe8b4f4..8d8cf67038 100644 --- a/src/AIS/AIS_RadiusDimension.hxx +++ b/src/AIS/AIS_RadiusDimension.hxx @@ -44,19 +44,12 @@ DEFINE_STANDARD_HANDLE(AIS_RadiusDimension,AIS_Dimension) class AIS_RadiusDimension : public AIS_Dimension { public: + Standard_EXPORT AIS_RadiusDimension (const gp_Circ& theCircle); Standard_EXPORT AIS_RadiusDimension (const gp_Circ& theCircle, - const gp_Pnt& theAttachPoint); + const gp_Pnt& theAttachPoint); - Standard_EXPORT AIS_RadiusDimension (const gp_Circ& theCircle, - const Handle(Prs3d_DimensionAspect)& theDimensionAspect, - const Standard_Real theExtensionSize = 1.0); - - Standard_EXPORT AIS_RadiusDimension (const gp_Circ& theCircle, - const gp_Pnt& theAttachPoint, - const Handle(Prs3d_DimensionAspect)& theDimensionAspect, - const Standard_Real theExtensionSize = 1.0); //! Constructs the radius display object defined by the
//! shape aShape, the dimension aVal, and the text aText. Standard_EXPORT AIS_RadiusDimension (const TopoDS_Shape& aShape); @@ -64,17 +57,21 @@ public: DEFINE_STANDARD_RTTI(AIS_RadiusDimension) protected: + //! Computes dimension value in display units Standard_EXPORT virtual void computeValue (); + //! Fills default plane object if it is possible to count plane automatically. Standard_EXPORT virtual void countDefaultPlane (); -private: - virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, - const Handle(Prs3d_Presentation)& thePresentation, - const Standard_Integer theMode = 0); +private: + + virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, + const Handle(Prs3d_Presentation)& thePresentation, + const Standard_Integer theMode = 0); // Fields +private: gp_Circ myCircle; }; diff --git a/src/Prs3d/Prs3d.cdl b/src/Prs3d/Prs3d.cdl index 218f6026e3..424a15ab99 100755 --- a/src/Prs3d/Prs3d.cdl +++ b/src/Prs3d/Prs3d.cdl @@ -75,18 +75,27 @@ is -- For more details see AIS_Drawer class, AIS_Shape::Compute() method and -- HLRAlgo package from TKHLR toolkit. - enumeration HorizontalTextAlignment is HTA_Left, HTA_Right, HTA_Center; - ---Purpose: To declare horisontal alignment for dimension text. - - enumeration VerticalTextAlignment is VTA_Top, VTA_Bottom, VTA_Center; - ---Purpose: To declare vertical alignment for dimension text label. - - enumeration DimensionArrowOrientation is DAO_Internal, DAO_External; - ---Purpose: To declare arrow orientation for dimenation. - -- External orientation means that dimension has extension parts outside the measured area. - --Internal orientation means the dimension arrows are in the measured area, and no extension parts are needed. + enumeration DimensionTextHorizontalPosition is DTHP_Left, DTHP_Right, DTHP_Center, DTHP_Fit; + ---Purpose: Specifies options for positioning dimension value label in horizontal direction. + -- DTHP_Left - value label located at left side on dimension extension. + -- DTHP_Right - value label located at right side on dimension extension. + -- DTHP_Center - value label located at center of dimension line. + -- DTHP_Fit - value label located automatically at left side if does not fits + -- the dimension space, otherwise the value label is placed at center. + enumeration DimensionTextVerticalPosition is DTVP_Above, DTVP_Below, DTVP_Center; + ---Purpose: Specifies options for positioning dimension value label in vertical direction + -- with respect to dimension (extension) line. + -- DTVP_Above - text label is located above the dimension or extension line. + -- DTVP_Below - text label is located below the dimension or extension line. + -- DTVP_Center - the text label middle-point is in line with dimension or extension line. + enumeration DimensionArrowOrientation is DAO_Internal, DAO_External, DAO_Fit; + ---Purpose: Specifies dimension arrow location and orientation. + -- DAO_Internal - arrows "inside", pointing outwards. + -- DAO_External - arrows "outside", pointing inwards. + -- DAO_Fit - arrows oriented inside if value label with arrowtips fit the dimension line, + -- otherwise - externally class Presentation; ---Purpose: defines the presentation object. This object can be diff --git a/src/Prs3d/Prs3d_DimensionAspect.cdl b/src/Prs3d/Prs3d_DimensionAspect.cdl index 573bef8543..778b2fc14c 100644 --- a/src/Prs3d/Prs3d_DimensionAspect.cdl +++ b/src/Prs3d/Prs3d_DimensionAspect.cdl @@ -20,8 +20,8 @@ class DimensionAspect from Prs3d inherits BasicAspect from Prs3d ---Purpose: defines the attributes when drawing a Length Presentation. uses - HorizontalTextAlignment from Prs3d, - VerticalTextAlignment from Prs3d, + DimensionTextHorizontalPosition from Prs3d, + DimensionTextVerticalPosition from Prs3d, DimensionArrowOrientation from Prs3d, AspectLine3d from Graphic3d, ArrowAspect from Prs3d, @@ -71,19 +71,19 @@ is --- Purpose: Sets orientation of arrows (external or internal). -- By default orientation is chosen automatically according to situation and text label size. - GetArrowOrientation (me) returns DimensionArrowOrientation from Prs3d; + ArrowOrientation (me) returns DimensionArrowOrientation from Prs3d; --- Purpose: Gets orientation of arrows (external or internal). - SetVerticalTextAlignment(me: mutable; theVertTextAlignment: VerticalTextAlignment from Prs3d); + SetTextVerticalPosition (me: mutable; thePosition : DimensionTextVerticalPosition from Prs3d); --- Purpose: Sets vertical text alignment for text label. - VerticalTextAlignment (me) returns VerticalTextAlignment from Prs3d; + TextVerticalPosition (me) returns DimensionTextVerticalPosition from Prs3d; --- Purpose: Gets vertical text alignment for text label. - SetHorizontalTextAlignment (me: mutable; theHorTextAlignment: HorizontalTextAlignment from Prs3d); + SetTextHorizontalPosition (me: mutable; thePosition: DimensionTextHorizontalPosition from Prs3d); --- Purpose: Sets horizontal text alignment for text label. - HorizontalTextAlignment (me) returns HorizontalTextAlignment from Prs3d; + TextHorizontalPosition (me) returns DimensionTextHorizontalPosition from Prs3d; --- Purpose: Gets horizontal text alignment for text label. ArrowAspect(me) returns mutable ArrowAspect from Prs3d is static; @@ -95,24 +95,38 @@ is SetCommonColor(me:mutable; theColor: Color from Quantity) is static; ---Purpose: Sets the same color for all parts of dimension: lines, arrows and text. + SetExtensionSize (me : mutable; theSize : Real from Standard) is static; + ---Purpose: Sets extension size. + + ExtensionSize (me) returns Real from Standard; + ---Purpose: Returns extension size. + fields myLineAspect: LineAspect from Prs3d; ---Purpose: Text style. The size for 3d (or 2d) text is also inside here. + myTextAspect: TextAspect from Prs3d; myArrowAspect : ArrowAspect from Prs3d; myIsText3d : Boolean from Standard; myIsTextShaded : Boolean from Standard; myIsArrows3d: Boolean from Standard; + myArrowOrientation : DimensionArrowOrientation from Prs3d; - ---Purpose: Dimension arrow orientation + ---Purpose: Dimension arrow orientation. -- By default, it is computed automatically. Its value depends on the text -- bouning rectangle size and distance between two flyouts. - -- By default, it is internal one. - myHorTextAlignment: HorizontalTextAlignment from Prs3d; - ---Purpose:Horizontal text alignment (Prs3d_HTA_Left/Prs3d_HTA_Right/Prs3d_HTA_Center). - -- Defines horizontal position of text value label, by default it is center. - myVerTextAlignment: VerticalTextAlignment from Prs3d; - ---Purpose: Vertical text alignment (Prs3d_VTA_Top, Prs3d_VTA_Bottom/Prs3d_VTA_Center) - -- Defines vertical position of text value lable, by default it is center. + -- By default, it is "fit" one. + + myTextHPosition : DimensionTextHorizontalPosition from Prs3d; + ---Purpose: Defines horizontal position of text value label, by default it is + -- "fit" - selected automatically depending on label-to-dimension size relation. + + myTextVPosition : DimensionTextVerticalPosition from Prs3d; + ---Purpose: Defines vertical position of text value label, by default it is center. + + myExtensionSize : Real from Standard; + ---Purpose: Size of arrow extensions. + -- The length of arrow tails if arrows are located outside dimension line. + end DimensionAspect from Prs3d; diff --git a/src/Prs3d/Prs3d_DimensionAspect.cxx b/src/Prs3d/Prs3d_DimensionAspect.cxx index b5c2abc617..ab0b04f02a 100644 --- a/src/Prs3d/Prs3d_DimensionAspect.cxx +++ b/src/Prs3d/Prs3d_DimensionAspect.cxx @@ -18,11 +18,12 @@ #include +#include +#include +#include + #include #include -#include -#include -#include #include IMPLEMENT_STANDARD_HANDLE (Prs3d_DimensionAspect, Prs3d_BasicAspect) @@ -33,13 +34,12 @@ IMPLEMENT_STANDARD_RTTIEXT (Prs3d_DimensionAspect, Prs3d_BasicAspect) //purpose : //======================================================================= -Prs3d_DimensionAspect::Prs3d_DimensionAspect () +Prs3d_DimensionAspect::Prs3d_DimensionAspect() { - // Text alignment - myHorTextAlignment = Prs3d_HTA_Center; - myVerTextAlignment = Prs3d_VTA_Center; - // Arrow orientation, will be computed on further steps, by default it is internal. - myArrowOrientation = Prs3d_DAO_Internal; + myTextHPosition = Prs3d_DTHP_Fit; + myTextVPosition = Prs3d_DTVP_Center; + myArrowOrientation = Prs3d_DAO_Fit; + myLineAspect = new Prs3d_LineAspect (Quantity_NOC_LAWNGREEN,Aspect_TOL_SOLID,1.); myTextAspect = new Prs3d_TextAspect; myTextAspect->Aspect()->SetTextZoomable (Standard_False); @@ -48,7 +48,8 @@ Prs3d_DimensionAspect::Prs3d_DimensionAspect () myTextAspect->SetVerticalJustification (Graphic3d_VTA_CENTER); myArrowAspect = new Prs3d_ArrowAspect; myArrowAspect->SetColor (Quantity_NOC_LAWNGREEN); - myArrowAspect->SetLength (6.); + myArrowAspect->SetLength (6.0); + myExtensionSize = 6.0; } //======================================================================= @@ -176,49 +177,49 @@ void Prs3d_DimensionAspect::SetArrowOrientation (const Prs3d_DimensionArrowOrien //purpose : //======================================================================= -Prs3d_DimensionArrowOrientation Prs3d_DimensionAspect::GetArrowOrientation () const +Prs3d_DimensionArrowOrientation Prs3d_DimensionAspect::ArrowOrientation() const { return myArrowOrientation; } //======================================================================= -//function : VerticalTextAlignment +//function : SetTextVerticalPosition +//purpose : +//======================================================================= + +void Prs3d_DimensionAspect::SetTextVerticalPosition (const Prs3d_DimensionTextVerticalPosition thePosition) +{ + myTextVPosition = thePosition; +} + +//======================================================================= +//function : TextVerticalPosition +//purpose : +//======================================================================= + +Prs3d_DimensionTextVerticalPosition Prs3d_DimensionAspect::TextVerticalPosition() const +{ + return myTextVPosition; +} + +//======================================================================= +//function : SetTextHorizontalPosition +//purpose : +//======================================================================= + +void Prs3d_DimensionAspect::SetTextHorizontalPosition (const Prs3d_DimensionTextHorizontalPosition thePosition) +{ + myTextHPosition = thePosition; +} + +//======================================================================= +//function : TextHorizontalPosition //purpose : //======================================================================= -Prs3d_VerticalTextAlignment Prs3d_DimensionAspect::VerticalTextAlignment () const +Prs3d_DimensionTextHorizontalPosition Prs3d_DimensionAspect::TextHorizontalPosition() const { - return myVerTextAlignment; -} - -//======================================================================= -//function : SetVerticalTextAlignment -//purpose : -//======================================================================= - -void Prs3d_DimensionAspect::SetVerticalTextAlignment (const Prs3d_VerticalTextAlignment theVertTextAlignment) -{ - myVerTextAlignment = theVertTextAlignment; -} - -//======================================================================= -//function : HorizontalTextAlignment -//purpose : -//======================================================================= - -Prs3d_HorizontalTextAlignment Prs3d_DimensionAspect::HorizontalTextAlignment () const -{ - return myHorTextAlignment; -} - -//======================================================================= -//function : SetHorizontalTextAlignment -//purpose : -//======================================================================= - -void Prs3d_DimensionAspect::SetHorizontalTextAlignment (const Prs3d_HorizontalTextAlignment theHorTextAlignment) -{ - myHorTextAlignment = theHorTextAlignment; + return myTextHPosition; } //======================================================================= @@ -240,3 +241,23 @@ void Prs3d_DimensionAspect::SetArrowAspect (const Handle(Prs3d_ArrowAspect)& the { myArrowAspect = theAspect; } + +//======================================================================= +//function : SetExtensioSize +//purpose : +//======================================================================= + +void Prs3d_DimensionAspect::SetExtensionSize (const Standard_Real theSize) +{ + myExtensionSize = theSize; +} + +//======================================================================= +//function : ExtensionSize +//purpose : +//======================================================================= + +Standard_Real Prs3d_DimensionAspect::ExtensionSize() const +{ + return myExtensionSize; +} diff --git a/src/QABugs/QABugs_16.cxx b/src/QABugs/QABugs_16.cxx index 4c4f8e37a6..9a84cf4be7 100755 --- a/src/QABugs/QABugs_16.cxx +++ b/src/QABugs/QABugs_16.cxx @@ -710,7 +710,7 @@ static Standard_Integer OCC301 (Draw_Interpretor& di, Standard_Integer argc, con Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect; anAspect->MakeArrows3d (Standard_True); anAspect->ArrowAspect()->SetLength (anArrowSize); - anAspect->SetHorizontalTextAlignment (Prs3d_HTA_Right); + anAspect->SetTextHorizontalPosition (Prs3d_DTHP_Right); anAspect->TextAspect ()->SetColor (Quantity_NOC_YELLOW); anAngleDimension->SetDimensionAspect (anAspect); // Another position of dimension diff --git a/tests/bugs/vis/bug24133_1 b/tests/bugs/vis/bug24133_1 index 3c7509aa61..2f489d5a6e 100644 --- a/tests/bugs/vis/bug24133_1 +++ b/tests/bugs/vis/bug24133_1 @@ -14,10 +14,10 @@ vpoint lengthP2 50 50 50 vdim -length -name=dim1 -plane=xoy lengthP1 lengthP2 vdisplay dim1 vfit -vmoveto 82 268 +vmoveto 82 254 -set x_coord 337 -set y_coord 130 +set x_coord 362 +set y_coord 102 checkcolor $x_coord $y_coord 0 1 1 if { $stat != 1 } { puts "Error : Highlighting of length dimension is wrong." diff --git a/tests/bugs/vis/bug24133_2 b/tests/bugs/vis/bug24133_2 index 3242426bbd..bd179d51f2 100644 --- a/tests/bugs/vis/bug24133_2 +++ b/tests/bugs/vis/bug24133_2 @@ -25,14 +25,15 @@ checkcolor $x_coord $y_coord 0 1 1 if { $stat != 1 } { puts "Error : Highlighting of angle dimension with 2d text is wrong." } -verase dim1 +vinit Viewer2/View2 +vdisplay angleP1 angleP2 angleP3 vdim -angle -name=dim2 -text=3d angleP1 angleP2 angleP3 vdisplay dim2 vfit vmoveto 263 251 -set x_coord 332 -set y_coord 326 +set x_coord 335 +set y_coord 319 checkcolor $x_coord $y_coord 0 1 1 diff --git a/tests/bugs/vis/bug24133_3 b/tests/bugs/vis/bug24133_3 index 2b9d57cf13..920433bc32 100644 --- a/tests/bugs/vis/bug24133_3 +++ b/tests/bugs/vis/bug24133_3 @@ -14,13 +14,13 @@ vpoint radP2 50 50 0 vpoint radP3 100 0 0 vcircle circle radP1 radP2 radP3 0 verase radP1 radP2 radP3 -vdim -radius -name=dim3 circle -vdisplay dim3 +vdim -radius -name=dim1 circle +vdisplay dim1 vfit -vmoveto 102 144 +vmoveto 123 158 -set x_coord 172 -set y_coord 186 +set x_coord 112 +set y_coord 151 checkcolor $x_coord $y_coord 0 1 1 @@ -28,14 +28,15 @@ if { $stat != 1 } { puts "Error : Highlighting of radius dimension with 2d text is wrong." } -verase dim3 -vdim -radius -name=dim3 -text=3d circle -vdisplay dim3 +vinit Viewer2/View2 +vdisplay circle +vdim -radius -name=dim2 -text=3d circle +vdisplay dim2 vfit -vmoveto 102 144 +vmoveto 191 196 -set x_coord 172 -set y_coord 186 +set x_coord 129 +set y_coord 172 checkcolor $x_coord $y_coord 0 1 1 diff --git a/tests/bugs/vis/bug24133_4 b/tests/bugs/vis/bug24133_4 index edb7bd7918..cf43682a8c 100644 --- a/tests/bugs/vis/bug24133_4 +++ b/tests/bugs/vis/bug24133_4 @@ -14,8 +14,8 @@ vpoint diamP2 50 50 0 vpoint diamP3 100 0 0 vcircle circle diamP1 diamP2 diamP3 0 verase diamP1 diamP2 diamP3 -vdim -diam -name=dim4 circle -vdisplay dim4 +vdim -diam -name=dim1 circle +vdisplay dim1 vfit vmoveto 208 205 @@ -28,9 +28,10 @@ if { $stat != 1 } { puts "Error : Highlighting of diameter dimension with 2d text is wrong." } -verase dim4 -vdim -diam -name=dim4 -text=3d circle -vdisplay dim4 +vinit Viewer2/View2 +vdisplay circle +vdim -diam -name=dim2 -text=3d circle +vdisplay dim2 vfit vmoveto 208 205 diff --git a/tests/bugs/vis/bug24288_1 b/tests/bugs/vis/bug24288_1 index 79c441db06..c6c3bb8229 100644 --- a/tests/bugs/vis/bug24288_1 +++ b/tests/bugs/vis/bug24288_1 @@ -20,10 +20,10 @@ verase radP1 radP2 radP3 vdim -radius -name=dim -text=3d circle vdisplay dim vfit -vmoveto 102 144 +vmoveto 110 111 -set x_coord 153 -set y_coord 153 +set x_coord 196 +set y_coord 196 checkcolor $x_coord $y_coord 0 1 1 if { $stat != 1 } { @@ -33,10 +33,10 @@ if { $stat != 1 } { # X axis rotation vrotate $m_pi 0 0 vfit -vmoveto 201 206 +vmoveto 208 200 -set x_coord 269 -set y_coord 123 +set x_coord 295 +set y_coord 113 checkcolor $x_coord $y_coord 0 1 1 if { $stat != 1 } { diff --git a/tests/bugs/vis/bug24288_2 b/tests/bugs/vis/bug24288_2 index 242f6f412a..fa506f94ea 100644 --- a/tests/bugs/vis/bug24288_2 +++ b/tests/bugs/vis/bug24288_2 @@ -20,10 +20,10 @@ verase radP1 radP2 radP3 vdim -radius -name=dim -text=3d circle vdisplay dim vfit -vmoveto 102 144 +vmoveto 110 111 -set x_coord 153 -set y_coord 153 +set x_coord 196 +set y_coord 196 checkcolor $x_coord $y_coord 0 1 1 if { $stat != 1 } { @@ -33,10 +33,10 @@ if { $stat != 1 } { # Y axis rotation vrotate 0 $m_pi 0 vfit -vmoveto 205 205 +vmoveto 185 246 -set x_coord 96 -set y_coord 296 +set x_coord 113 +set y_coord 294 checkcolor $x_coord $y_coord 0 1 1 if { $stat != 1 } { diff --git a/tests/bugs/vis/bug24288_3 b/tests/bugs/vis/bug24288_3 index 091a901f2e..00e75334cb 100644 --- a/tests/bugs/vis/bug24288_3 +++ b/tests/bugs/vis/bug24288_3 @@ -20,10 +20,10 @@ verase radP1 radP2 radP3 vdim -radius -name=dim -text=3d circle vdisplay dim vfit -vmoveto 102 144 +vmoveto 110 111 -set x_coord 153 -set y_coord 153 +set x_coord 196 +set y_coord 196 checkcolor $x_coord $y_coord 0 1 1 if { $stat != 1 } { @@ -33,10 +33,10 @@ if { $stat != 1 } { # Z axis rotation vrotate 0 0 $m_pi vfit -vmoveto 176 184 +vmoveto 221 217 -set x_coord 294 -set y_coord 257 +set x_coord 209 +set y_coord 208 checkcolor $x_coord $y_coord 0 1 1 if { $stat != 1 } {