0024326: Get rid of confusing extension line
authorapl <apl@opencascade.com>
Thu, 21 Nov 2013 13:27:33 +0000 (17:27 +0400)
committerbugmaster <bugmaster@opencascade.com>
Thu, 21 Nov 2013 13:28:17 +0000 (17:28 +0400)
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.

21 files changed:
src/AIS/AIS_AngleDimension.cxx
src/AIS/AIS_AngleDimension.hxx
src/AIS/AIS_DiameterDimension.cxx
src/AIS/AIS_DiameterDimension.hxx
src/AIS/AIS_Dimension.cxx
src/AIS/AIS_Dimension.hxx
src/AIS/AIS_LengthDimension.cxx
src/AIS/AIS_LengthDimension.hxx
src/AIS/AIS_RadiusDimension.cxx
src/AIS/AIS_RadiusDimension.hxx
src/Prs3d/Prs3d.cdl
src/Prs3d/Prs3d_DimensionAspect.cdl
src/Prs3d/Prs3d_DimensionAspect.cxx
src/QABugs/QABugs_16.cxx
tests/bugs/vis/bug24133_1
tests/bugs/vis/bug24133_2
tests/bugs/vis/bug24133_3
tests/bugs/vis/bug24133_4
tests/bugs/vis/bug24288_1
tests/bugs/vis/bug24288_2
tests/bugs/vis/bug24288_3

index 321014f..e9432be 100755 (executable)
 #include <AIS_AngleDimension.hxx>
 
 #include <AIS.hxx>
 #include <AIS_AngleDimension.hxx>
 
 #include <AIS.hxx>
-#include <AIS_Dimension.hxx>
-#include <AIS_DimensionOwner.hxx>
 #include <AIS_Drawer.hxx>
 #include <AIS_Drawer.hxx>
-#include <BRep_Tool.hxx>
 #include <BRepBuilderAPI_MakeFace.hxx>
 #include <BRepAdaptor_Curve.hxx>
 #include <BRepAdaptor_Surface.hxx>
 #include <BRepBuilderAPI_MakeFace.hxx>
 #include <BRepAdaptor_Curve.hxx>
 #include <BRepAdaptor_Surface.hxx>
-#include <BRepLib_MakeVertex.hxx>
-
-#include <DsgPrs.hxx>
-#include <DsgPrs_AnglePresentation.hxx>
-
 #include <ElCLib.hxx>
 #include <ElCLib.hxx>
-#include <ElSLib.hxx>
-
-#include <GC_MakeCircle.hxx>
-#include <GC_MakeConicalSurface.hxx>
-#include <gce_MakeLin.hxx>
 #include <gce_MakeLin2d.hxx>
 #include <gce_MakeLin2d.hxx>
-#include <gce_MakePln.hxx>
-#include <gce_MakeCirc.hxx>
 #include <gce_MakeCone.hxx>
 #include <gce_MakeCone.hxx>
-#include <Geom2d_Circle.hxx>
-#include <Geom2d_Curve.hxx>
-#include <Geom2d_Line.hxx>
-#include <Geom2dAPI_ExtremaCurveCurve.hxx>
-#include <GeomAPI.hxx>
 #include <Geom_Circle.hxx>
 #include <Geom_Circle.hxx>
-#include <Geom_Line.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_TrimmedCurve.hxx>
-#include <Geom_Surface.hxx>
-#include <Geom_CylindricalSurface.hxx>
 #include <Geom_ConicalSurface.hxx>
 #include <Geom_SurfaceOfRevolution.hxx>
 #include <Geom_ConicalSurface.hxx>
 #include <Geom_SurfaceOfRevolution.hxx>
-#include <Geom_SurfaceOfLinearExtrusion.hxx>
 #include <Geom_OffsetSurface.hxx>
 #include <Geom_OffsetSurface.hxx>
-#include <GeomAPI_ExtremaCurveCurve.hxx>
 #include <Graphic3d_ArrayOfSegments.hxx>
 #include <Graphic3d_ArrayOfSegments.hxx>
-#include <Graphic3d_AspectLine3d.hxx>
-#include <gp.hxx>
-#include <gp_Ax1.hxx>
-#include <gp_Lin.hxx>
-#include <gp_Cone.hxx>
-#include <gp_Pln.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Pnt2d.hxx>
-#include <gp_Vec.hxx> 
-#include <gp_XYZ.hxx>
 #include <Graphic3d_Group.hxx>
 #include <Graphic3d_Group.hxx>
-#include <Graphic3d_ArrayOfPrimitives.hxx>
 #include <Graphic3d_ArrayOfPolylines.hxx>
 #include <Graphic3d_ArrayOfPolylines.hxx>
-
 #include <IntAna2d_AnaIntersection.hxx>
 #include <IntAna2d_IntPoint.hxx>
 #include <IntAna2d_AnaIntersection.hxx>
 #include <IntAna2d_IntPoint.hxx>
-#include <IntAna_QuadQuadGeo.hxx>
 #include <IntAna_ResultType.hxx>
 #include <IntAna_ResultType.hxx>
-#include <Poly_Polygon3D.hxx>
-#include <Precision.hxx>
 #include <ProjLib.hxx>
 #include <ProjLib.hxx>
-#include <Prs3d_ArrowAspect.hxx>
-#include <Prs3d_DimensionAspect.hxx>
-#include <Prs3d_Drawer.hxx>
 #include <Prs3d_Root.hxx>
 #include <Prs3d_Root.hxx>
+#include <Prs3d_ShadingAspect.hxx>
 #include <PrsMgr_PresentationManager3d.hxx>
 #include <Select3D_SensitiveCurve.hxx>
 #include <Select3D_SensitiveGroup.hxx>
 #include <Select3D_SensitiveSegment.hxx>
 #include <SelectMgr_Selection.hxx>
 #include <PrsMgr_PresentationManager3d.hxx>
 #include <Select3D_SensitiveCurve.hxx>
 #include <Select3D_SensitiveGroup.hxx>
 #include <Select3D_SensitiveSegment.hxx>
 #include <SelectMgr_Selection.hxx>
-#include <Standard_NotImplemented.hxx>
-#include <Standard_Type.hxx>
-#include <Standard_Macro.hxx>
-#include <Standard_DefineHandle.hxx>
-
-#include <TColStd_Array1OfReal.hxx>
-#include <TopExp.hxx>
-#include <TopExp_Explorer.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Shape.hxx>
-#include <TopoDS_Vertex.hxx>
 #include <UnitsAPI.hxx>
 
 IMPLEMENT_STANDARD_HANDLE (AIS_AngleDimension, AIS_Dimension)
 IMPLEMENT_STANDARD_RTTIEXT (AIS_AngleDimension, AIS_Dimension)
 
 #include <UnitsAPI.hxx>
 
 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
 //=======================================================================
 //=======================================================================
 //function : init
 //purpose  : Private constructor for default initialization
 //=======================================================================
-
 void AIS_AngleDimension::init()
 {
 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");
   // 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);
   SetDisplaySpecialSymbol (AIS_DSS_After);
+  SetFlyout (15.0);
+  SetKindOfDimension (AIS_KOD_PLANEANGLE);
   MakeUnitsDisplayed (Standard_False);
 }
 
   MakeUnitsDisplayed (Standard_False);
 }
 
@@ -129,7 +79,6 @@ void AIS_AngleDimension::init()
 //function : Constructor
 //purpose  : Two edges dimension
 //=======================================================================
 //function : Constructor
 //purpose  : Two edges dimension
 //=======================================================================
-
 AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
                                         const TopoDS_Edge& theSecondEdge)
 : AIS_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;
 {
   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
 //           <thePlane> is used in case of Angle=PI
 //=======================================================================
 //purpose  : Two edges dimension
 //           <thePlane> is used in case of Angle=PI
 //=======================================================================
-
 AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
                                         const TopoDS_Edge& theSecondEdge,
                                         const gp_Pln& thePlane)
 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;
 {
   init();
   myShapesNumber = 2;
-  myFirstShape  = theFirstEdge;
-  mySecondShape = theSecondEdge;
-  SetWorkingPlane (thePlane);
-}
-
-//=======================================================================
-//function : Constructor
-//purpose  : Two edges dimension with aspect
-//           <thePlane> 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);
 }
 
   SetWorkingPlane (thePlane);
 }
 
@@ -184,7 +112,6 @@ AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
 //function : Constructor
 //purpose  : Three points dimension
 //=======================================================================
 //function : Constructor
 //purpose  : Three points dimension
 //=======================================================================
-
 AIS_AngleDimension::AIS_AngleDimension (const gp_Pnt& theFirstPoint,
                                         const gp_Pnt& theSecondPoint,
                                         const gp_Pnt& theThirdPoint)
 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;
 {
   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
 //=======================================================================
 }
 
 //=======================================================================
 //function : Constructor
 //purpose  : Cone dimension
 //=======================================================================
-
 AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Face& theCone)
 : AIS_Dimension(),
   myIsFlyoutLines (Standard_True)
 {
   init();
   myIsInitialized = Standard_False;
 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
 //=======================================================================
 }
 
 //=======================================================================
 //function : Constructor
 //purpose  : Two faces dimension
 //=======================================================================
-
 AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Face& theFirstFace,
                                         const TopoDS_Face& theSecondFace,
                                         const gp_Ax1& theAxis)
 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;
 {
   init();
   myIsInitialized = Standard_False;
-  myFirstShape   = theFirstFace;
-  mySecondShape  = theSecondFace;
-  myShapesNumber = 2;
+  myFirstShape    = theFirstFace;
+  mySecondShape   = theSecondFace;
+  myShapesNumber  = 2;
   gp_Pln aPlane;
   aPlane.SetAxis (theAxis);
   SetWorkingPlane (aPlane);
   gp_Pln aPlane;
   aPlane.SetAxis (theAxis);
   SetWorkingPlane (aPlane);
@@ -259,7 +164,6 @@ AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Face& theFirstFace,
 //function : SetFirstShape
 //purpose  : 
 //=======================================================================
 //function : SetFirstShape
 //purpose  : 
 //=======================================================================
-
 void AIS_AngleDimension::SetFirstShape (const TopoDS_Shape& theShape,
                                         const Standard_Boolean isSingleShape /*= Standard_False*/)
 {
 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,
 //                        <theCMax> centers;
 //                  -1 if <theC> center is below <theCMax> center.
 //=======================================================================
 //                        <theCMax> centers;
 //                  -1 if <theC> center is below <theCMax> center.
 //=======================================================================
-
 Standard_Integer AIS_AngleDimension::aboveInBelowCone (const gp_Circ &theCMax,
                                                        const gp_Circ &theCMin,
                                                        const gp_Circ &theC)
 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
 //=======================================================================
 //function : initConeAngle
 //purpose  : initialization of the cone angle
 //=======================================================================
-
 Standard_Boolean AIS_AngleDimension::initConeAngle (const TopoDS_Face& theCone)
 {
   if (theCone.IsNull ())
 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
 //=======================================================================
 //function : initTwoFacesAngle
 //purpose  : initialization of angle dimension between two faces
 //=======================================================================
-
 Standard_Boolean AIS_AngleDimension::initTwoFacesAngle ()
 {
   TopoDS_Face aFirstFace = TopoDS::Face (myFirstShape);
 Standard_Boolean AIS_AngleDimension::initTwoFacesAngle ()
 {
   TopoDS_Face aFirstFace = TopoDS::Face (myFirstShape);
@@ -458,7 +359,6 @@ Standard_Boolean AIS_AngleDimension::initTwoFacesAngle ()
 //function : countDefaultPlane
 //purpose  : 
 //=======================================================================
 //function : countDefaultPlane
 //purpose  : 
 //=======================================================================
-
 void AIS_AngleDimension::countDefaultPlane ()
 {
   if (!myIsInitialized)
 void AIS_AngleDimension::countDefaultPlane ()
 {
   if (!myIsInitialized)
@@ -475,7 +375,6 @@ void AIS_AngleDimension::countDefaultPlane ()
 //function : computeValue
 //purpose  : 
 //=======================================================================
 //function : computeValue
 //purpose  : 
 //=======================================================================
-
 void AIS_AngleDimension::computeValue ()
 {
   gp_Vec aVec1 (myCenter, myFirstPoint),
 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
 //           <myIsInitialized> is set to false
 //=======================================================================
 //           If intersection between two edges doesn't exist
 //           <myIsInitialized> is set to false
 //=======================================================================
-
 Standard_Boolean AIS_AngleDimension::initTwoEdgesAngle ()
 {
   // Data initialization
 Standard_Boolean AIS_AngleDimension::initTwoEdgesAngle ()
 {
   // Data initialization
@@ -636,21 +534,6 @@ Standard_Boolean AIS_AngleDimension::initTwoEdgesAngle ()
   return Standard_True;
 }
 
   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 :
 //=======================================================================
 //function: getCenterOnArc
 //purpose :
@@ -685,12 +568,12 @@ gp_Pnt AIS_AngleDimension::getCenterOnArc (const gp_Pnt& theFirstAttach,
 //function: drawArcWithText
 //purpose :
 //=======================================================================
 //function: drawArcWithText
 //purpose :
 //=======================================================================
-
 void AIS_AngleDimension::drawArcWithText (const Handle(Prs3d_Presentation)& thePresentation,
                                           const gp_Pnt& theFirstAttach,
                                           const gp_Pnt& theSecondAttach,
                                           const TCollection_ExtendedString& theText,
 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),
 {
   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,
   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) +
 
   // 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);
   }
     drawArc (thePresentation, theFirstAttach, aTextBeginOnArc, myCenter, aRadius, theMode);
     drawArc (thePresentation, aTextEndOnArc, theSecondAttach, myCenter, aRadius, theMode);
   }
-
 }
 
 //=======================================================================
 //function : drawArc
 //purpose  : draws the arc between two attach points
 //=======================================================================
 }
 
 //=======================================================================
 //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,
 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;
                                   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);
 
   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);
   }
   {
     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)
   {
   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
 //=======================================================================
 //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)
 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();
 
   // 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();
   Quantity_Length anArrowLength = aDimensionAspect->ArrowAspect()->Length();
+
   if (!myIsValueCustom)
   if (!myIsValueCustom)
-    computeValue ();
+  {
+    computeValue();
+  }
+
   TCollection_ExtendedString aValueString;
   Standard_Real aTextLength;
   getTextWidthAndString (aTextLength, aValueString);
   TCollection_ExtendedString aValueString;
   Standard_Real aTextLength;
   getTextWidthAndString (aTextLength, aValueString);
+
   if (!myIsWorkingPlaneCustom)
   if (!myIsWorkingPlaneCustom)
+  {
     countDefaultPlane();
     countDefaultPlane();
+  }
+
   gp_Pnt aFirstAttach = myCenter.Translated (gp_Vec(myCenter, myFirstPoint).Normalized() * GetFlyout());
   gp_Pnt aSecondAttach = myCenter.Translated (gp_Vec(myCenter, mySecondPoint).Normalized() * GetFlyout());
   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
 
   //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_Dir aFirstExtensionDir  = gp_Vec (myCenter, aFirstAttach) ^ aWPDir;
+  gp_Dir aSecondExtensionDir = gp_Vec (myCenter, aSecondAttach)^ aWPDir.Reversed();
 
 
-  gp_Pnt aFirstArrowBegin,
-         aFirstArrowEnd,
-         aSecondArrowBegin,
-         aSecondArrowEnd;
+  gp_Vec aFirstArrowVec  = gp_Vec (aFirstExtensionDir)  * anArrowLength;
+  gp_Vec aSecondArrowVec = gp_Vec (aSecondExtensionDir) * anArrowLength;
 
 
-  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)
   {
     aFirstArrowVec.Reverse();
     aSecondArrowVec.Reverse();
   {
     aFirstArrowVec.Reverse();
     aSecondArrowVec.Reverse();
+  }
+
+  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())
+  {
+    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:
+    {
+      gp_Vec anAttachVector (aFirstAttach, aSecondAttach);
+      Standard_Real aDimensionWidth = anAttachVector.Magnitude();
+      Standard_Real anArrowsWidth   = anArrowLength * 2.0;
+      Standard_Real aContentWidth   = isArrowsExternal ? aTextLength : aTextLength + anArrowsWidth;
 
 
-    aFirstArrowBegin = aFirstAttach.Translated (aFirstArrowVec);
-    aFirstArrowEnd = aFirstAttach;
-    aSecondArrowBegin = aSecondAttach;
-    aSecondArrowEnd = aSecondAttach.Translated (aSecondArrowVec);
+      aLabelPosition |= aDimensionWidth < aContentWidth ? LabelPosition_Left : LabelPosition_HCenter;
+      break;
+    }
   }
   }
-  else
+
+  switch (aDimensionAspect->TextVerticalPosition())
   {
   {
-    aFirstArrowBegin = aFirstAttach;
-    aFirstArrowEnd = aFirstAttach.Translated (aFirstArrowVec);
-    aSecondArrowBegin = aSecondAttach.Translated (aSecondArrowVec);
-    aSecondArrowEnd = aSecondAttach;
+    case Prs3d_DTVP_Above  : aLabelPosition |= LabelPosition_Above; break;
+    case Prs3d_DTVP_Below  : aLabelPosition |= LabelPosition_Below; break;
+    case Prs3d_DTVP_Center : aLabelPosition |= LabelPosition_VCenter; break;
   }
 
   }
 
-  // Fill presentation
-  Handle(Graphic3d_ArrayOfSegments) aPrimSegments;
-  Standard_Boolean isTextInCenter = aDimensionAspect->VerticalTextAlignment() == Prs3d_VTA_Center;
-  if (aDimensionAspect->HorizontalTextAlignment() == Prs3d_HTA_Center)
+  // 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)
   {
   {
-    // 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())
-    {
-      drawArcWithText (thePresentation, aFirstAttach, aSecondAttach, aValueString, (AIS_DimensionDisplayMode)theMode);
-    }
-    else
+    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);
       gp_Vec aTextDir (aFirstArrowEnd, aSecondArrowBegin);
       myGeom.myTextPosition = getCenterOnArc (aFirstArrowEnd, aSecondArrowBegin);
+
       drawText (thePresentation,
                 myIsTextReversed ? aTextDir.Reversed() : aTextDir,
       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);
     }
     }
-  }
-  else
-  {
-    // 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)
+    break;
+
+    case LabelPosition_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)));
-
-       // Long extension
-       drawExtensionWithText (thePresentation, aStartPoint, aLeftExtension, aValueString, (AIS_DimensionDisplayMode)theMode);
+      drawExtension (thePresentation,
+                     anExtensionSize,
+                     isArrowsExternal ? aFirstArrowEnd : aFirstAttach,
+                     aFirstExtensionDir,
+                     aValueString,
+                     (AIS_DimensionDisplayMode)theMode,
+                     aLabelPosition);
     }
     }
-    else // Prs3d_HTA_Right
+    break;
+
+    case LabelPosition_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)));
-
-       // Long extension
-       drawExtensionWithText (thePresentation, aStartPoint, aRightExtension, aValueString, (AIS_DimensionDisplayMode)theMode);
+      drawExtension (thePresentation,
+                     anExtensionSize,
+                     isArrowsExternal ? aSecondArrowEnd : aSecondAttach,
+                     aSecondExtensionDir,
+                     aValueString,
+                     (AIS_DimensionDisplayMode)theMode,
+                     aLabelPosition);
     }
     }
+    break;
+  }
+
+  // dimension arc without text
+  if (theMode != AIS_DDM_Text && aHPosition != LabelPosition_HCenter)
+  {
+    Prs3d_Root::NewGroup (thePresentation);
+
+    drawArc (thePresentation,
+             isArrowsExternal ? aFirstAttach  : aFirstArrowEnd,
+             isArrowsExternal ? aSecondAttach : aSecondArrowEnd,
+             myCenter,
+             Abs(GetFlyout ()),
+             (AIS_DimensionDisplayMode)theMode);
+  }
 
 
-    if (theMode != AIS_DDM_Text)
+  // 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 (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)
   {
   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);
     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);
     Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments);
-    drawArrow (thePresentation, aFirstAttach, gp_Dir (aFirstArrowVec));
-    drawArrow (thePresentation, aSecondAttach, gp_Dir (aSecondArrowVec));
   }
 
   setComputed (Standard_True);
   }
 
   setComputed (Standard_True);
@@ -999,12 +975,13 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*
 //function : computeFlyoutSelection
 //purpose  : computes selection for flyouts
 //=======================================================================
 //function : computeFlyoutSelection
 //purpose  : computes selection for flyouts
 //=======================================================================
-
 void AIS_AngleDimension::computeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
                                                 const Handle(AIS_DimensionOwner)& theOwner)
 {
  if (!myIsFlyoutLines)
 void AIS_AngleDimension::computeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
                                                 const Handle(AIS_DimensionOwner)& theOwner)
 {
  if (!myIsFlyoutLines)
+ {
    return;
    return;
+ }
 
  gp_Pnt aFirstAttach = myCenter.Translated (gp_Vec (myCenter, myFirstPoint).Normalized() * GetFlyout());
  gp_Pnt aSecondAttach = myCenter.Translated (gp_Vec (myCenter, mySecondPoint).Normalized() * GetFlyout());
 
  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);
  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
+}
index 9e1f893..805d651 100644 (file)
@@ -48,6 +48,7 @@ DEFINE_STANDARD_HANDLE (AIS_AngleDimension, AIS_Dimension)
 class AIS_AngleDimension : public AIS_Dimension
 {
 public:
 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
   //! 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);
   Standard_EXPORT  AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
                                        const TopoDS_Edge& theSecondEdge,
                                        const gp_Pln& thePlane);
-  
-  //!  Constructs the angle display object defined by the <br>
-  //! 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.
   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);
 
   //! 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);
 
   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:
 
 
 protected:
 
@@ -120,7 +107,8 @@ protected:
                                          const gp_Pnt& theFirstAttach,
                                          const gp_Pnt& theSecondAttach,
                                          const TCollection_ExtendedString& theText,
                                          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,
 
   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);
 
                                                      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 ();
   
   //! Fills default plane object if it is possible to count plane automatically.
   Standard_EXPORT virtual void countDefaultPlane ();
   
index 9431bc1..ef31b02 100755 (executable)
 // purpose or non-infringement. Please see the License for the specific terms
 // and conditions governing the rights and limitations under the License.
 
 // 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
-//              <ODL>, <SZY>
-
-
-#define BUC60915        //GG 05/06/01 Enable to compute the requested arrow size
-//                      if any in all dimensions.
 #include <AIS_DiameterDimension.hxx>
 #include <AIS_DiameterDimension.hxx>
-
-#include <Adaptor3d_HCurve.hxx>
 #include <AIS.hxx>
 #include <AIS_Drawer.hxx>
 #include <AIS.hxx>
 #include <AIS_Drawer.hxx>
-#include <AIS_DimensionOwner.hxx>
-#include <DsgPrs_DiameterPresentation.hxx>
-#include <DsgPrs_RadiusPresentation.hxx>
 #include <ElCLib.hxx>
 #include <ElCLib.hxx>
-#include <ElSLib.hxx>
-#include <GC_MakeCircle.hxx>
 #include <gce_MakeDir.hxx>
 #include <gce_MakeDir.hxx>
-#include <Geom_Plane.hxx>
-#include <gp_Pln.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Lin.hxx>
-#include <gp_Ax1.hxx>
-#include <gp_Dir.hxx>
-#include <gp_Vec.hxx>
 #include <Graphic3d_ArrayOfSegments.hxx>
 #include <Graphic3d_Group.hxx>
 #include <PrsMgr_PresentationManager3d.hxx>
 #include <Graphic3d_ArrayOfSegments.hxx>
 #include <Graphic3d_Group.hxx>
 #include <PrsMgr_PresentationManager3d.hxx>
-#include <Prs3d_DimensionAspect.hxx>
-#include <Prs3d_ArrowAspect.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_TextAspect.hxx>
-#include <Prs3d_Text.hxx>
 #include <Prs3d_Root.hxx>
 #include <Prs3d_Root.hxx>
-#include <Precision.hxx>
-#include <Select3D_SensitiveSegment.hxx>
-#include <Select3D_SensitiveBox.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <Standard_Macro.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Shape.hxx>
-#include <TCollection_ExtendedString.hxx>
 
 IMPLEMENT_STANDARD_HANDLE(AIS_DiameterDimension, AIS_Dimension)
 IMPLEMENT_STANDARD_RTTIEXT(AIS_DiameterDimension, AIS_Dimension)
 
 
 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  : 
 //=======================================================================
 //function : Constructor
 //purpose  : 
@@ -75,8 +47,9 @@ AIS_DiameterDimension::AIS_DiameterDimension(const gp_Circ& theCircle)
 {
   SetKindOfDimension(AIS_KOD_DIAMETER);
   myIsInitialized = Standard_True;
 {
   SetKindOfDimension(AIS_KOD_DIAMETER);
   myIsInitialized = Standard_True;
-  SetSpecialSymbol (0x00D8);
+  SetSpecialSymbol (THE_DIAMETER_SYMBOL);
   SetDisplaySpecialSymbol (AIS_DSS_Before);
   SetDisplaySpecialSymbol (AIS_DSS_Before);
+  SetFlyout (0.0);
   // Count attach points
   myFirstPoint = ElCLib::Value (0, myCircle);
   mySecondPoint = myFirstPoint.Translated (gp_Vec(myFirstPoint, theCircle.Location())*2);
   // 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)
 {
 : AIS_Dimension(),
   myCircle (theCircle)
 {
-  SetKindOfDimension(AIS_KOD_DIAMETER);
-  SetSpecialSymbol (0x00D8);
+  SetKindOfDimension (AIS_KOD_DIAMETER);
+  SetSpecialSymbol (THE_DIAMETER_SYMBOL);
   SetDisplaySpecialSymbol (AIS_DSS_Before);
   SetDisplaySpecialSymbol (AIS_DSS_Before);
+  SetFlyout (0.0);
   myFirstPoint = theAttachPoint;
   // Count the second point
   if (Abs(myFirstPoint.Distance (theCircle.Location()) - theCircle.Radius()) < Precision::Confusion())
   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;
 }
 
   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
 //=======================================================================
 //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 ()
 {
 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;
 }
   myFirstShape = theShape;
   myIsInitialized = Standard_False;
 }
@@ -163,38 +120,13 @@ void AIS_DiameterDimension::Compute (const Handle(PrsMgr_PresentationManager3d)&
     else
       myIsInitialized = Standard_True;
   }
     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)
+  if (!myIsWorkingPlaneCustom)
   {
   {
-    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);
 }
 
 //=======================================================================
 }
 
 //=======================================================================
index c6221a7..1842759 100644 (file)
@@ -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 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  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.
     //! Fills default plane object if it is possible to count plane automatically.
-  Standard_EXPORT  virtual void countDefaultPlane ();
+  Standard_EXPORT  virtual void countDefaultPlane();
 
 private: 
 
 
 private: 
 
@@ -68,6 +65,7 @@ private:
                          const Standard_Integer theMode = 0);
 
 // Fields
                          const Standard_Integer theMode = 0);
 
 // Fields
+private:
 
   gp_Circ myCircle;
 };
 
   gp_Circ myCircle;
 };
index 55a75bc..f073877 100644 (file)
@@ -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.
 
 // purpose or non-infringement. Please see the License for the specific terms
 // and conditions governing the rights and limitations under the License.
 
-#include <AIS.hxx>
 #include <AIS_Dimension.hxx>
 #include <AIS_Dimension.hxx>
+
+#include <AIS.hxx>
 #include <AIS_DimensionDisplayMode.hxx>
 #include <AIS_DimensionOwner.hxx>
 #include <AIS_Drawer.hxx>
 #include <AIS_DimensionDisplayMode.hxx>
 #include <AIS_DimensionOwner.hxx>
 #include <AIS_Drawer.hxx>
 IMPLEMENT_STANDARD_HANDLE(AIS_Dimension, AIS_InteractiveObject)
 IMPLEMENT_STANDARD_RTTIEXT(AIS_Dimension, AIS_InteractiveObject)
 
 IMPLEMENT_STANDARD_HANDLE(AIS_Dimension, AIS_InteractiveObject)
 IMPLEMENT_STANDARD_RTTIEXT(AIS_Dimension, AIS_InteractiveObject)
 
-//=======================================================================
-//function : Constructor
-//purpose  : 
-//=======================================================================
-
-AIS_Dimension::AIS_Dimension (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)
+namespace
 {
 {
-  ResetWorkingPlane();
-  // Units default settings
-  UnitsAPI::SetLocalSystem (UnitsAPI_SI);
-  myModelUnits = Units::DictionaryOfUnits()->ActiveUnit (myUnitsQuantity.ToCString());
-  myDisplayUnits = Units::DictionaryOfUnits()->ActiveUnit (myUnitsQuantity.ToCString());
-}
+  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  : 
 //=======================================================================
 
 //=======================================================================
 //function : Constructor
 //purpose  : 
 //=======================================================================
-
-AIS_Dimension::AIS_Dimension (const Handle(Prs3d_DimensionAspect)& theAspect,
-                              const Standard_Real theExtensionSize /*= 1.0*/)
+AIS_Dimension::AIS_Dimension()
 : AIS_InteractiveObject(),
   myDefaultPlane (gp_Pln (gp::XOY())),
   myIsWorkingPlaneCustom (Standard_False),
 : AIS_InteractiveObject(),
   myDefaultPlane (gp_Pln (gp::XOY())),
   myIsWorkingPlaneCustom (Standard_False),
@@ -121,25 +98,21 @@ AIS_Dimension::AIS_Dimension (const Handle(Prs3d_DimensionAspect)& theAspect,
   mySpecialSymbol (' '),
   myDisplaySpecialSymbol (AIS_DSS_No),
   myIsTextReversed (Standard_False),
   mySpecialSymbol (' '),
   myDisplaySpecialSymbol (AIS_DSS_No),
   myIsTextReversed (Standard_False),
-  myTextOffset (DimensionAspect()->ArrowAspect()->Length()),
   myIsInitialized (Standard_False),
   myFlyout (0.0),
   myIsInitialized (Standard_False),
   myFlyout (0.0),
-  myKindOfDimension (AIS_KOD_NONE),
-  myExtensionSize (theExtensionSize)
+  myKindOfDimension (AIS_KOD_NONE)
 {
   ResetWorkingPlane();
   // Units default settings
   UnitsAPI::SetLocalSystem (UnitsAPI_SI);
   myModelUnits = Units::DictionaryOfUnits()->ActiveUnit (myUnitsQuantity.ToCString());
   myDisplayUnits = Units::DictionaryOfUnits()->ActiveUnit (myUnitsQuantity.ToCString());
 {
   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 <theMode> is allowed to display object.
 //=======================================================================
 }
 
 //=======================================================================
 //function : AcceptDisplayMode
 //purpose  : Checks if display mode <theMode> is allowed to display object.
 //=======================================================================
-
 Standard_Boolean AIS_Dimension::AcceptDisplayMode (const Standard_Integer theMode) const
 {
   return theMode == 0 ? Standard_True : Standard_False;
 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.
 //=======================================================================
 //function : computeValue
 //purpose  : Computes dimension value in display units.
 //=======================================================================
-
 void AIS_Dimension::computeValue()
 {
   UnitsAPI::SetCurrentUnit (myUnitsQuantity.ToCString(), myModelUnits.ToCString());
 void AIS_Dimension::computeValue()
 {
   UnitsAPI::SetCurrentUnit (myUnitsQuantity.ToCString(), myModelUnits.ToCString());
@@ -161,7 +133,6 @@ void AIS_Dimension::computeValue()
 //function : countDefaultPlane
 //purpose  : 
 //=======================================================================
 //function : countDefaultPlane
 //purpose  : 
 //=======================================================================
-
 void AIS_Dimension::countDefaultPlane()
 {
 }
 void AIS_Dimension::countDefaultPlane()
 {
 }
@@ -170,7 +141,6 @@ void AIS_Dimension::countDefaultPlane()
 //function : GetWorkingPlane
 //purpose  : 
 //=======================================================================
 //function : GetWorkingPlane
 //purpose  : 
 //=======================================================================
-
 const gp_Pln& AIS_Dimension::GetWorkingPlane() const
 {
   return myWorkingPlane;
 const gp_Pln& AIS_Dimension::GetWorkingPlane() const
 {
   return myWorkingPlane;
@@ -180,7 +150,6 @@ const gp_Pln& AIS_Dimension::GetWorkingPlane() const
 //function : SetWorkingPlane
 //purpose  : 
 //=======================================================================
 //function : SetWorkingPlane
 //purpose  : 
 //=======================================================================
-
 void AIS_Dimension::SetWorkingPlane (const gp_Pln& thePlane)
 {
   myWorkingPlane = thePlane;
 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
 //=======================================================================
 //function : ResetWorkingPlane
 //purpose  : Set default value of working plane
 //=======================================================================
-
 void AIS_Dimension::ResetWorkingPlane()
 {
   myWorkingPlane = myDefaultPlane;
 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.
 //=======================================================================
 //purpose  : Set default value of working plane
 //           Only for internal use.
 //=======================================================================
-
 void AIS_Dimension::resetWorkingPlane (const gp_Pln& theNewDefaultPlane)
 {
   myDefaultPlane = theNewDefaultPlane;
 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  :
 //=======================================================================
 //function : valueInDisplayUnits
 //purpose  :
 //=======================================================================
-
 Standard_Real AIS_Dimension::valueToDisplayUnits()
 {
   return  UnitsAPI::AnyToAny (myValue,
 Standard_Real AIS_Dimension::valueToDisplayUnits()
 {
   return  UnitsAPI::AnyToAny (myValue,
@@ -226,7 +192,6 @@ Standard_Real AIS_Dimension::valueToDisplayUnits()
 //function : KindOfDimension
 //purpose  : 
 //=======================================================================
 //function : KindOfDimension
 //purpose  : 
 //=======================================================================
-
 AIS_KindOfDimension AIS_Dimension::KindOfDimension() const 
 {
   return myKindOfDimension;
 AIS_KindOfDimension AIS_Dimension::KindOfDimension() const 
 {
   return myKindOfDimension;
@@ -236,37 +201,15 @@ AIS_KindOfDimension AIS_Dimension::KindOfDimension() const
 //function : SetKindOfDimension
 //purpose  : 
 //=======================================================================
 //function : SetKindOfDimension
 //purpose  : 
 //=======================================================================
-
 void AIS_Dimension::SetKindOfDimension (const AIS_KindOfDimension theKindOfDimension)
 {
   myKindOfDimension = theKindOfDimension;
 }
 
 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  : 
 //=======================================================================
 //=======================================================================
 //function : GetValue
 //purpose  : 
 //=======================================================================
-
 Standard_Real AIS_Dimension::GetValue() const
  {
   return myValue;
 Standard_Real AIS_Dimension::GetValue() const
  {
   return myValue;
@@ -276,7 +219,6 @@ Standard_Real AIS_Dimension::GetValue() const
 //function : SetCustomValue
 //purpose  : 
 //=======================================================================
 //function : SetCustomValue
 //purpose  : 
 //=======================================================================
-
 void AIS_Dimension::SetCustomValue (const Standard_Real theValue)
 {
   myValue = theValue;
 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  : 
 //=======================================================================
 //function : SetFirstShape
 //purpose  : 
 //=======================================================================
-
 void AIS_Dimension::SetFirstShape (const TopoDS_Shape& theShape)
 {
   myFirstShape = theShape;
 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  : 
 //=======================================================================
 //function : SetSecondShape
 //purpose  : 
 //=======================================================================
-
 void AIS_Dimension::SetSecondShape (const TopoDS_Shape& theShape)
 {
   mySecondShape = theShape;
 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  : 
 //=======================================================================
 //function : getTextWidthAndString
 //purpose  : 
 //=======================================================================
-
 void AIS_Dimension::getTextWidthAndString (Quantity_Length& theWidth,
                                            TCollection_ExtendedString& theString) const
 {
 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);
   }
 
     theString += TCollection_ExtendedString (mySpecialSymbol);
   }
 
-  // Get font length
-  // Get expansion ratio for getting a width of symbols
+  // Get text style parameters
   Quantity_Color aColor; 
   Quantity_Color aColor; 
-  Standard_CString aFont;
+  Standard_CString aFontName;
   Standard_Real aFactor;
   Standard_Real aSpace;
   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  : 
 //=======================================================================
 }
 
 //=======================================================================
 //function : drawArrow
 //purpose  : 
 //=======================================================================
-
 void AIS_Dimension::drawArrow (const Handle(Prs3d_Presentation)& thePresentation,
                                const gp_Pnt& theLocation,
                                const gp_Dir& theDirection)
 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,
   {
     Prs3d_Arrow::Draw (thePresentation,
                        theLocation,
-                       theDirection.Reversed(),
+                       theDirection,
                        myDrawer->DimensionAspect()->ArrowAspect()->Angle(),
                        anArrowLength);
   }
   else
   {
                        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);
     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);
 
     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);
     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  : 
 //=======================================================================
 //function : drawText
 //purpose  : 
 //=======================================================================
-
 Standard_Real AIS_Dimension::drawText (const Handle(Prs3d_Presentation)& thePresentation,
                                        const gp_Dir& theTextDir,
                                        const TCollection_ExtendedString theText,
 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)
 {
   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())
   {
 
   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;
     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
 
     // 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);
 
     // 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
     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);
     }
       // 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);
-
-    // 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.
+    Prs3d_Root::CurrentGroup (thePresentation)->SetFlippingOptions (Standard_False, gp_Ax2());
+
+    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  : 
 //=======================================================================
 //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());
-
-  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);
+  Standard_Real aTextWidth = 0.0;
 
 
-  // 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));
+
+  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));
 
 
-  // Extension line in the same group
-  if (theMode != AIS_DDM_Text)
+  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  : 
 //=======================================================================
 //function : SetDimensionAspect
 //purpose  : 
 //=======================================================================
-
 void AIS_Dimension::SetDimensionAspect (const Handle(Prs3d_DimensionAspect)& theDimensionAspect)
 {
   myDrawer->SetDimensionAspect (theDimensionAspect);
 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  : 
 //=======================================================================
 //function : DimensionAspect
 //purpose  : 
 //=======================================================================
-
 Handle(Prs3d_DimensionAspect) AIS_Dimension::DimensionAspect() const
 {
   return myDrawer->DimensionAspect();
 }
 
 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  : 
 //=======================================================================
 //=======================================================================
 //function : drawLinearDimension
 //purpose  : 
 //=======================================================================
-
 void AIS_Dimension::drawLinearDimension (const Handle(Prs3d_Presentation)& thePresentation,
 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*/)
 {
                                          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;
   }
     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();
 
   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();
   if (!myIsValueCustom)
   {
    computeValue();
@@ -665,206 +604,316 @@ void AIS_Dimension::drawLinearDimension (const Handle(Prs3d_Presentation)& thePr
   Standard_Real aTextLength;
   getTextWidthAndString (aTextLength, aValueString);
 
   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
 
   // 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();
+
+  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 (aDimensionAspect->GetArrowOrientation() == Prs3d_DAO_External)
+  if (isArrowsExternal)
   {
     aFirstArrowDir.Reverse();
     aSecondArrowDir.Reverse();
   {
     aFirstArrowDir.Reverse();
     aSecondArrowDir.Reverse();
-
-    aFirstArrowBegin  = aParam1 - anArrowLength;
-    aFirstArrowEnd    = aParam1;
-    aSecondArrowBegin = aParam2;
-    aSecondArrowEnd   = aParam2 + anArrowLength;
   }
   }
-  else
+
+  aFirstArrowBegin  = aLineBegPoint;
+  aSecondArrowBegin = aLineEndPoint;
+  aFirstArrowEnd    = aLineBegPoint.Translated (-gp_Vec (aFirstArrowDir).Scaled (anArrowLength));
+  aSecondArrowEnd   = aLineEndPoint.Translated (-gp_Vec (aSecondArrowDir).Scaled (anArrowLength));
+
+  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())
   {
   {
-    aFirstArrowBegin  = aParam1;
-    aFirstArrowEnd    = aParam1 + anArrowLength;
-    aSecondArrowBegin = aParam2 - anArrowLength;
-    aSecondArrowEnd   = aParam2;
+    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:
+    {
+      Standard_Real aDimensionWidth = aLineBegPoint.Distance (aLineEndPoint);
+      Standard_Real anArrowsWidth   = isOneSideDimension ? anArrowLength : 2.0 * anArrowLength;
+      Standard_Real aContentWidth   = isArrowsExternal ? aTextLength : aTextLength + anArrowsWidth;
+
+      aLabelPosition |= aDimensionWidth < aContentWidth ? LabelPosition_Left : LabelPosition_HCenter;
+      break;
+    }
   }
 
   }
 
-  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)
+  switch (aDimensionAspect->TextVerticalPosition())
   {
   {
-    aGap = 1.0;
+    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 (aDimensionAspect->HorizontalTextAlignment())
+  switch (aLabelPosition & LabelPosition_HMask)
   {
   {
-    // Default case - text is to be in the center of length dimension line
-    case Prs3d_HTA_Center:
+    // ------------------------------------------------------------------------ //
+    //                                CENTER                                    //
+    // -------------------------------------------------------------------------//
+
+    case LabelPosition_HCenter:
     {
     {
-      // Group1: arrows
-      if (theMode != AIS_DDM_Text)
-      {
-        drawArrow (thePresentation, aFirstArrowPosition, aFirstArrowDir);
-        if (!isOneSideDimension)
-        {
-          drawArrow (thePresentation, aSecondArrowPosition, aSecondArrowDir);
-        }
-      }
+      // add label on dimension or extension line to presentation
+      Prs3d_Root::NewGroup (thePresentation);
 
 
-      // Group 2: Text and dimension line
-      aPrimSegments = new Graphic3d_ArrayOfSegments (isGapInCenter ? 4 : 2);
-      myGeom.myTextPosition = ElCLib::Value ((aParam1 + aParam2) / 2.0, aDimensionLine);
+      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,
       Standard_Real aTextWidth = drawText (thePresentation,
-                                           myIsTextReversed ? aTextDir.Reversed() : aTextDir,
+                                           myIsTextReversed ? -aTextDir : aTextDir,
                                            aValueString,
                                            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);
+        break;
       }
       }
-      else if (aDimensionAspect->VerticalTextAlignment() == Prs3d_VTA_Top)
+
+      Standard_Real aLabelMargin = 
+        aDimensionAspect->IsText3d() ? aDimensionAspect->TextAspect()->Height() * THE_3D_TEXT_MARGIN : 0.0;
+
+      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)
       {
       {
-        aDimensionAspect->TextAspect()->SetVerticalJustification (Graphic3d_VTA_BOTTOM);
+        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 if (aDimensionAspect->VerticalTextAlignment() == Prs3d_VTA_Bottom)
+      else
       {
       {
-        aDimensionAspect->TextAspect()->SetVerticalJustification(Graphic3d_VTA_TOP);
-      }
+        aPrimSegments->AddVertex (aCenterLineBegin);
+        aPrimSegments->AddVertex (aCenterLineEnd);
 
 
-      aLastPoint = isOneSideDimension ? theSecondAttach : ElCLib::Value (aSecondArrowBegin, aDimensionLine);
+        myGeom.mySensitiveSegments.Append (
+          new Select3D_SensitiveSegment (anEmptyOwner, aCenterLineBegin, aCenterLineEnd));
+      }
 
 
-      aPrimSegments->AddVertex (aFirstPoint);
-      aPrimSegments->AddVertex (aLastPoint);
-      myGeom.mySensitiveSegments.Append (new Select3D_SensitiveSegment (anEmptyOwner, aFirstPoint, aLastPoint));
+      // 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
 
       // 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);
+      }
+
+      // 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);
       }
       }
-      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:
+    // ------------------------------------------------------------------------ //
+    //                                LEFT                                      //
+    // -------------------------------------------------------------------------//
+
+    case LabelPosition_Left:
     {
     {
-      aPrimSegments = new Graphic3d_ArrayOfSegments (4);
+      // add label on dimension or extension line to presentation
+      Prs3d_Root::NewGroup (thePresentation);
 
 
-      gp_Pnt aFirstArrowBeginPnt = ElCLib::Value (aFirstArrowBegin, aDimensionLine);
-      gp_Lin aLongExtLine (aDimensionLine.Location(), aDimensionLine.Direction().Reversed());
-      gp_Pnt aStartPoint = ElCLib::Value (aFirstArrowBegin, aDimensionLine);
       // Left extension with the text
       // Left extension with the text
-      drawExtensionWithText (thePresentation, aStartPoint, aLongExtLine, aValueString, theMode);
+      drawExtension (thePresentation, anExtensionSize,
+                     isArrowsExternal ? aFirstArrowEnd : aLineBegPoint,
+                     aFirstExtensionDir,
+                     aValueString,
+                     theMode,
+                     aLabelPosition);
+
+      if (theMode == AIS_DDM_Text)
+      {
+        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));
 
 
-      // 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));
+      // add arrows to presentation
+      Prs3d_Root::NewGroup (thePresentation);
 
 
-      // Right extension
+      drawArrow (thePresentation, aFirstArrowBegin, aFirstArrowDir);
       if (!isOneSideDimension)
       {
       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;
     }
       break;
     }
-    case Prs3d_HTA_Right:
+    // ------------------------------------------------------------------------ //
+    //                                RIGHT                                     //
+    // -------------------------------------------------------------------------//
+
+    case LabelPosition_Right:
     {
     {
-      aPrimSegments = new Graphic3d_ArrayOfSegments (4);
-      // Left extension
-      if (!isOneSideDimension)
+      // add label on dimension or extension line to presentation
+      Prs3d_Root::NewGroup (thePresentation);
+
+      // Right extension with text
+      drawExtension (thePresentation, anExtensionSize,
+                     isArrowsExternal ? aSecondArrowEnd : aSecondArrowBegin,
+                     aSecondExtensionDir,
+                     aValueString,
+                     theMode,
+                     aLabelPosition);
+
+      if (theMode == AIS_DDM_Text)
       {
       {
-        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));
+        break;
       }
 
       }
 
-      // 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));
+      // add central dimension line
+      Prs3d_Root::NewGroup (thePresentation);
 
 
-      // Right extension with text
-      aFirstPoint = ElCLib::Value (aSecondArrowEnd, aDimensionLine);
-      drawExtensionWithText (thePresentation, aFirstPoint, aDimensionLine, aValueString, theMode);
+      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);
 
 
-      if (theMode != AIS_DDM_Text)
+      myGeom.mySensitiveSegments.Append (
+        new Select3D_SensitiveSegment (anEmptyOwner, aCenterLineBegin, aCenterLineEnd));
+
+      // add arrows to presentation
+      Prs3d_Root::NewGroup (thePresentation);
+
+      drawArrow (thePresentation, aSecondArrowBegin, aSecondArrowDir);
+      if (!isOneSideDimension)
       {
       {
-        // 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, aFirstArrowBegin, aFirstArrowDir);
+      }
 
 
-        drawArrow (thePresentation, aSecondArrowPosition, aSecondArrowDir);
+      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;
     }
   }
 
       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);
 }
 
   setComputed (Standard_True);
 }
 
@@ -872,7 +921,6 @@ void AIS_Dimension::drawLinearDimension (const Handle(Prs3d_Presentation)& thePr
 //function : SetFirstPoint
 //purpose  : 
 //=======================================================================
 //function : SetFirstPoint
 //purpose  : 
 //=======================================================================
-
 void AIS_Dimension::SetFirstPoint (const gp_Pnt& thePoint)
 {
   myFirstPoint = thePoint;
 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  : 
 //=======================================================================
 //function : SetSecondPoint
 //purpose  : 
 //=======================================================================
-
 void AIS_Dimension::SetSecondPoint (const gp_Pnt& thePoint)
 {
   mySecondPoint = thePoint;
 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  :
 //=======================================================================
 //function : Type
 //purpose  :
 //=======================================================================
-
 AIS_KindOfInteractive AIS_Dimension::Type() const
 {
   return AIS_KOI_Relation;
 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
 //=======================================================================
 //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,
 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
 //=======================================================================
 //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,
 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
 //=======================================================================
 //function : SetDisplaySpecialSymbol
 //purpose  : specifies dimension special symbol display options
 //=======================================================================
-
 void AIS_Dimension::SetDisplaySpecialSymbol (const AIS_DisplaySpecialSymbol theDisplaySpecSymbol)
 {
   myDisplaySpecialSymbol = theDisplaySpecSymbol;
 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
 //=======================================================================
 //function : DisplaySpecialSymbol
 //purpose  : shows dimension special symbol display options
 //=======================================================================
-
 AIS_DisplaySpecialSymbol AIS_Dimension::DisplaySpecialSymbol() const
 {
   return myDisplaySpecialSymbol;
 AIS_DisplaySpecialSymbol AIS_Dimension::DisplaySpecialSymbol() const
 {
   return myDisplaySpecialSymbol;
@@ -1112,7 +1154,6 @@ AIS_DisplaySpecialSymbol AIS_Dimension::DisplaySpecialSymbol() const
 //function : SetSpecialSymbol
 //purpose  : specifies special symbol
 //=======================================================================
 //function : SetSpecialSymbol
 //purpose  : specifies special symbol
 //=======================================================================
-
 void AIS_Dimension::SetSpecialSymbol (const Standard_ExtCharacter theSpecialSymbol)
 {
   mySpecialSymbol = theSpecialSymbol;
 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
 //=======================================================================
 //function : SpecialSymbol
 //purpose  : returns special symbol
 //=======================================================================
-
 Standard_ExtCharacter AIS_Dimension::SpecialSymbol() const
 {
   return mySpecialSymbol;
 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
 //=======================================================================
 //function : IsUnitsDisplayed
 //purpose  : shows if Units are to be displayed along with dimension value
 //=======================================================================
-
 Standard_Boolean AIS_Dimension::IsUnitsDisplayed() const
 {
   return myToDisplayUnits;
 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
 //=======================================================================
 //function : MakeUnitsDisplayed
 //purpose  : sets to display units along with the dimension value or no
 //=======================================================================
-
 void AIS_Dimension::MakeUnitsDisplayed (const Standard_Boolean toDisplayUnits)
 {
   myToDisplayUnits = toDisplayUnits;
 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
 //=======================================================================
 //function : MakeUnitsDisplayed
 //purpose  : returns the current type of units
 //=======================================================================
-
 TCollection_AsciiString AIS_Dimension::UnitsQuantity() const
 {
   return myUnitsQuantity;
 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
 //=======================================================================
 //function : SetUnitsQuantity
 //purpose  : sets the current type of units
 //=======================================================================
-
 void AIS_Dimension::SetUnitsQuantity (const TCollection_AsciiString& theUnitsQuantity)
 {
   myUnitsQuantity = theUnitsQuantity;
 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
 //=======================================================================
 //function : ModelUnits
 //purpose  : returns the current model units
 //=======================================================================
-
 TCollection_AsciiString AIS_Dimension::ModelUnits() const
 {
   return myModelUnits;
 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
 //=======================================================================
 //function : SetModelUnits
 //purpose  : sets the current model units
 //=======================================================================
-
 void AIS_Dimension::SetModelUnits (const TCollection_AsciiString& theUnits)
 {
   myModelUnits = theUnits;
 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
 //=======================================================================
 //function : DisplayUnits
 //purpose  : returns the current display units
 //=======================================================================
-
 TCollection_AsciiString AIS_Dimension::DisplayUnits() const
 {
   return myDisplayUnits;
 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
 //=======================================================================
 //function : SetDisplayUnits
 //purpose  : sets the current display units
 //=======================================================================
-
 void AIS_Dimension::SetDisplayUnits (const TCollection_AsciiString& theUnits)
 {
   myDisplayUnits = theUnits;
 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  :
 //=======================================================================
 //function : isComputed
 //purpose  :
 //=======================================================================
-
 Standard_Boolean AIS_Dimension::isComputed() const
 {
   return myGeom.myIsComputed;
 Standard_Boolean AIS_Dimension::isComputed() const
 {
   return myGeom.myIsComputed;
@@ -1222,7 +1253,6 @@ Standard_Boolean AIS_Dimension::isComputed() const
 //function : setComputed
 //purpose  :
 //=======================================================================
 //function : setComputed
 //purpose  :
 //=======================================================================
-
 void AIS_Dimension::setComputed (Standard_Boolean isComputed)
 {
   myGeom.myIsComputed = isComputed;
 void AIS_Dimension::setComputed (Standard_Boolean isComputed)
 {
   myGeom.myIsComputed = isComputed;
@@ -1232,7 +1262,6 @@ void AIS_Dimension::setComputed (Standard_Boolean isComputed)
 //function : textPosition
 //purpose  :
 //=======================================================================
 //function : textPosition
 //purpose  :
 //=======================================================================
-
 gp_Pnt AIS_Dimension::textPosition() const
 {
   return myGeom.myTextPosition;
 gp_Pnt AIS_Dimension::textPosition() const
 {
   return myGeom.myTextPosition;
@@ -1242,7 +1271,6 @@ gp_Pnt AIS_Dimension::textPosition() const
 //function : setTextPosition
 //purpose  :
 //=======================================================================
 //function : setTextPosition
 //purpose  :
 //=======================================================================
-
 void AIS_Dimension::setTextPosition (const gp_Pnt thePosition)
 {
   myGeom.myTextPosition = thePosition;
 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  :
 //=======================================================================
 //function : resetGeom
 //purpose  :
 //=======================================================================
-
 void AIS_Dimension::resetGeom()
 {
   setComputed (Standard_False);
 void AIS_Dimension::resetGeom()
 {
   setComputed (Standard_False);
@@ -1262,7 +1289,6 @@ void AIS_Dimension::resetGeom()
 //function : IsTextReversed
 //purpose  :
 //=======================================================================
 //function : IsTextReversed
 //purpose  :
 //=======================================================================
-
 Standard_Boolean AIS_Dimension::IsTextReversed() const
 {
   return myIsTextReversed;
 Standard_Boolean AIS_Dimension::IsTextReversed() const
 {
   return myIsTextReversed;
@@ -1272,7 +1298,6 @@ Standard_Boolean AIS_Dimension::IsTextReversed() const
 //function : MakeTextReversed
 //purpose  :
 //=======================================================================
 //function : MakeTextReversed
 //purpose  :
 //=======================================================================
-
 void AIS_Dimension::MakeTextReversed (const Standard_Boolean isTextReversed)
 {
   myIsTextReversed = isTextReversed;
 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  :
 //=======================================================================
 //function : SetSelToleranceForText2d
 //purpose  :
 //=======================================================================
-
 void AIS_Dimension::SetSelToleranceForText2d (const Standard_Real theTol)
 {
   myGeom.mySelToleranceForText2d = theTol;
 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  :
 //=======================================================================
 //function : SelToleranceForText2d
 //purpose  :
 //=======================================================================
-
 Standard_Real AIS_Dimension::SelToleranceForText2d() const
 {
   return myGeom.mySelToleranceForText2d;
 Standard_Real AIS_Dimension::SelToleranceForText2d() const
 {
   return myGeom.mySelToleranceForText2d;
@@ -1300,56 +1323,52 @@ Standard_Real AIS_Dimension::SelToleranceForText2d() const
 
 //=======================================================================
 //function : SetFlyout
 
 //=======================================================================
 //function : SetFlyout
-//purpose  : 
+//purpose  :
 //=======================================================================
 //=======================================================================
-
 void AIS_Dimension::SetFlyout (const Standard_Real theFlyout)
 {
 void AIS_Dimension::SetFlyout (const Standard_Real theFlyout)
 {
- myFlyout = theFlyout;
-}
-
-//=======================================================================
-//function : GetFlyout
-//purpose  : 
-//=======================================================================
+  if (myFlyout == theFlyout)
+  {
+    return;
+  }
 
 
-Standard_Real AIS_Dimension::GetFlyout () const
-{
- return myFlyout;
+  myFlyout = theFlyout;
+  SetToUpdate();
 }
 
 //=======================================================================
 //function : computeFlyoutSelection
 //purpose  : computes selection for flyouts
 //=======================================================================
 }
 
 //=======================================================================
 //function : computeFlyoutSelection
 //purpose  : computes selection for flyouts
 //=======================================================================
-
 void AIS_Dimension::computeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
 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);
-
- // 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 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);
+
+  // 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  : 
 //=======================================================================
 }
 
 //=======================================================================
 //function : ComputeSelection
 //purpose  : 
 //=======================================================================
-
 void AIS_Dimension::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
                                       const Standard_Integer theMode)
 {
 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
     aSensitiveForText->Set (aTextOwner);
   }
   else
+  {
     computeFlyoutSelection (theSelection, anOwner);
     computeFlyoutSelection (theSelection, anOwner);
+  }
 
   theSelection->Add (aSensitiveForLine);
   theSelection->Add (aSensitiveForText);
 
   theSelection->Add (aSensitiveForLine);
   theSelection->Add (aSensitiveForText);
index f8d33ee..534794a 100644 (file)
@@ -34,7 +34,6 @@
 #include <Prs3d_LineAspect.hxx>
 #include <Prs3d_Presentation.hxx>
 #include <Prs3d_TextAspect.hxx>
 #include <Prs3d_LineAspect.hxx>
 #include <Prs3d_Presentation.hxx>
 #include <Prs3d_TextAspect.hxx>
-#include <Prs3d_VerticalTextAlignment.hxx>
 #include <Select3D_ListOfSensitive.hxx>
 #include <SelectMgr_EntityOwner.hxx>
 #include <Standard.hxx>
 #include <Select3D_ListOfSensitive.hxx>
 #include <SelectMgr_EntityOwner.hxx>
 #include <Standard.hxx>
@@ -47,14 +46,32 @@ DEFINE_STANDARD_HANDLE(AIS_Dimension, AIS_InteractiveObject)
 
 class AIS_Dimension : public 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:
 public:
+
   //! Constructor with default parameters values
   //! 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
   //! 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.
 
   //! 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 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);
   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
   //! 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);
   // 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();
   //! Reset working plane to default.
   Standard_EXPORT  void ResetWorkingPlane();
+
   //! specifies dimension special symbol display options
   Standard_EXPORT  void SetDisplaySpecialSymbol (const AIS_DisplaySpecialSymbol theDisplaySpecSymbol);
   //! 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;
   //! shows dimension special symbol display options
   Standard_EXPORT  AIS_DisplaySpecialSymbol DisplaySpecialSymbol() const;
+
   //! specifies special symbol
   Standard_EXPORT  void SetSpecialSymbol (const Standard_ExtCharacter theSpecialSymbol);
   //! specifies special symbol
   Standard_EXPORT  void SetSpecialSymbol (const Standard_ExtCharacter theSpecialSymbol);
+
   //! returns special symbol
   Standard_EXPORT  Standard_ExtCharacter SpecialSymbol() const;
   //! 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;
   //! 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);
   //! 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;
   //! 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);
   //! 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;
   //! returns the current model units
   Standard_EXPORT  TCollection_AsciiString ModelUnits() const;
+
   //! sets the current model units
   Standard_EXPORT  void SetModelUnits (const TCollection_AsciiString& theUnits);
   //! sets the current model units
   Standard_EXPORT  void SetModelUnits (const TCollection_AsciiString& theUnits);
+
   //! returns the current display units
   Standard_EXPORT  TCollection_AsciiString DisplayUnits() const;
   //! 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 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 </br>
   //! 3d text is oriented relative to the attachment points order </br>
   //! By default, text direction vector is oriented from the first attachment point </br>
   //! to the second one. This method checks if text direction is to be default or </br>
   //! should be reversed.
   Standard_EXPORT  Standard_Boolean IsTextReversed() const;
   //! Important! Only for 3d text </br>
   //! 3d text is oriented relative to the attachment points order </br>
   //! By default, text direction vector is oriented from the first attachment point </br>
   //! to the second one. This method checks if text direction is to be default or </br>
   //! should be reversed.
   Standard_EXPORT  Standard_Boolean IsTextReversed() const;
+
   //! Important! Only for 3d text
   //! 3d text is oriented relative to the attachment points order </br>
   //! By default, text direction vector is oriented from the first attachment point </br>
   //! to the second one. This method sets value that shows if text direction </br>
   //! should be reversed or not.
   Standard_EXPORT  void MakeTextReversed (const Standard_Boolean isTextReversed);
   //! Important! Only for 3d text
   //! 3d text is oriented relative to the attachment points order </br>
   //! By default, text direction vector is oriented from the first attachment point </br>
   //! to the second one. This method sets value that shows if text direction </br>
   //! 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);
   //! 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;
   //! 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);
   //! Sets flyout size for dimension.
   Standard_EXPORT void SetFlyout (const Standard_Real theFlyout);
+
   //! @return flyout size for dimension.
   //! @return flyout size for dimension.
-  Standard_EXPORT Standard_Real GetFlyout () const;
+  Standard_Real GetFlyout() const
+  {
+    return myFlyout;
+  }
+
+public:
 
   DEFINE_STANDARD_RTTI(AIS_Dimension)
 
 protected:
 
   DEFINE_STANDARD_RTTI(AIS_Dimension)
 
 protected:
+
   Standard_EXPORT void getTextWidthAndString (Quantity_Length& theWidth,
                                               TCollection_ExtendedString& theString) const;
 
   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,
   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
 
   //! 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,
 
   //! 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);
 
                                             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);
   //! 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;
 
   //! Dimension default plane
   gp_Pln myDefaultPlane;
+
   //! Shows if working plane is set custom
   Standard_Boolean myIsWorkingPlaneCustom;
 
   //! 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;
 
   //! 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;
 
   //! 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;
 
   //! The quantity of units for the value computation
   TCollection_AsciiString myUnitsQuantity;
+
   //! Units of the model
   TCollection_AsciiString myModelUnits;
   //! Units of the model
   TCollection_AsciiString myModelUnits;
+
   //! Units in which the displayed value will be converted
   TCollection_AsciiString myDisplayUnits;
   //! 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;
   //! 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 for some kind of dimensions (for diameter, radius and so on)
   Standard_ExtCharacter mySpecialSymbol;
+
   //! Special symbol display options
   AIS_DisplaySpecialSymbol myDisplaySpecialSymbol;
 
   //! 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 
 
   //! 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 position
     gp_Pnt myTextPosition;
+
     //! Text bounding box, stored for advanced selection
     Bnd_Box myTextBndBox;
     //! Text bounding box, stored for advanced selection
     Bnd_Box myTextBndBox;
+
     //! Sensitive point tolerance for 2d text selection
     Standard_Real mySelToleranceForText2d;
     //! Sensitive point tolerance for 2d text selection
     Standard_Real mySelToleranceForText2d;
+
     //! For advanced dimension line selection
     Select3D_ListOfSensitive mySensitiveSegments;
     //! For advanced dimension line selection
     Select3D_ListOfSensitive mySensitiveSegments;
+
     //! Shows if attachment points were computed
     Standard_Boolean myIsComputed;
     //! Shows if attachment points were computed
     Standard_Boolean myIsComputed;
+
   public: 
   public: 
-    DimensionGeom ()
-     : myIsComputed (Standard_False)
-    { }
+
+    DimensionGeom () : myIsComputed (Standard_False) {}
   };
 
   //! Shows if text is inverted
   Standard_Boolean myIsTextReversed;
   };
 
   //! 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;
   //! 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;
   //! 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;
   //! Shows if attach points are initialized correctly
   Standard_Boolean myIsInitialized;
+
   //! First shape (can be vertex, edge or face)
   TopoDS_Shape myFirstShape;
   //! First shape (can be vertex, edge or face)
   TopoDS_Shape myFirstShape;
+
   //! Second shape (can be vertex, edge or face)
   TopoDS_Shape mySecondShape;
   //! Second shape (can be vertex, edge or face)
   TopoDS_Shape mySecondShape;
+
   //! Number of shapes
   Standard_Integer myShapesNumber;
   //! 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;
   //! 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;
   //! 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:
 private:
+
   //! Type of dimension
   AIS_KindOfDimension myKindOfDimension;
   //! Type of dimension
   AIS_KindOfDimension myKindOfDimension;
+
   //! Dimension working plane, is equal to <myDefaultPlane> if it can be computed automatically.
   gp_Pln myWorkingPlane;
   //! Dimension working plane, is equal to <myDefaultPlane> 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
 };
 #endif
index 22280a0..f602bb0 100755 (executable)
 // purpose or non-infringement. Please see the License for the specific terms
 // and conditions governing the rights and limitations under the License.
 
 // 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 <AIS_LengthDimension.hxx>
 
 #include <AIS.hxx>
 #include <AIS_LengthDimension.hxx>
 
 #include <AIS.hxx>
-#include <AIS_DimensionOwner.hxx>
-#include <AIS_Drawer.hxx>
 #include <BRep_Tool.hxx>
 #include <BRepAdaptor_Curve.hxx>
 #include <BRep_Tool.hxx>
 #include <BRepAdaptor_Curve.hxx>
-#include <BRepAdaptor_Surface.hxx>
 #include <BRepGProp_Face.hxx>
 #include <BRepLib_MakeVertex.hxx>
 #include <BRepTopAdaptor_FClass2d.hxx>
 #include <BRepGProp_Face.hxx>
 #include <BRepLib_MakeVertex.hxx>
 #include <BRepTopAdaptor_FClass2d.hxx>
-#include <DsgPrs.hxx>
-#include <DsgPrs_LengthPresentation.hxx>
 #include <ElCLib.hxx>
 #include <ElSLib.hxx>
 #include <ElCLib.hxx>
 #include <ElSLib.hxx>
-#include <Geom_Circle.hxx>
-#include <Geom_Curve.hxx>
-#include <Geom_TrimmedCurve.hxx>
 #include <Geom_Line.hxx>
 #include <Geom_Line.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_OffsetSurface.hxx>
 #include <gce_MakeDir.hxx>
 #include <gce_MakeDir.hxx>
-#include <gce_MakeLin.hxx>
 #include <Graphic3d_Group.hxx>
 #include <Graphic3d_ArrayOfSegments.hxx>
 #include <Graphic3d_Group.hxx>
 #include <Graphic3d_ArrayOfSegments.hxx>
-#include <Graphic3d_AspectText3d.hxx>
-#include <Graphic3d_AspectLine3d.hxx>
-#include <gp_Ax1.hxx>
-#include <gp_Ax2.hxx>
-#include <gp_Dir.hxx>
-#include <gp_Lin.hxx>
-#include <gp_Pln.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Pnt2d.hxx>
-#include <Precision.hxx>
-#include <ProjLib.hxx>
-#include <Prs3d_Arrow.hxx>
-#include <Prs3d_ArrowAspect.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_LineAspect.hxx>
-#include <Prs3d_Text.hxx>
-#include <Prs3d_TextAspect.hxx>
-#include <Select3D_SensitiveBox.hxx>
-#include <Select3D_SensitiveSegment.hxx>
-#include <Select3D_SensitiveCurve.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-#include <Standard_DomainError.hxx>
-#include <Standard_NotImplemented.hxx>
-#include <StdPrs_WFDeflectionShape.hxx>
-#include <TCollection_ExtendedString.hxx>
+#include <PrsMgr_PresentationManager.hxx>
+#include <Prs3d_Root.hxx>
 #include <TopExp.hxx>
 #include <TopExp_Explorer.hxx>
 #include <TopExp.hxx>
 #include <TopExp_Explorer.hxx>
-#include <TopoDS.hxx>
 
 IMPLEMENT_STANDARD_HANDLE(AIS_LengthDimension, AIS_Dimension)
 IMPLEMENT_STANDARD_RTTIEXT(AIS_LengthDimension, AIS_Dimension)
 
 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
 //=======================================================================
 
 //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_LengthDimension::AIS_LengthDimension (const gp_Pnt& theFirstPoint,
                                           const gp_Pnt& theSecondPoint,
                                           const gp_Pln& theDimensionPlane)
-: AIS_Dimension ()
+: AIS_Dimension()
 {
   myIsInitialized = Standard_True;
   myFirstPoint = theFirstPoint;
 {
   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;
   myFirstShape = BRepLib_MakeVertex (myFirstPoint);
   mySecondShape = BRepLib_MakeVertex (mySecondPoint);
   myShapesNumber = 2;
-  SetFlyout (15.0);
   SetKindOfDimension (AIS_KOD_LENGTH);
   SetWorkingPlane (theDimensionPlane);
   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_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;
 {
   myIsInitialized = Standard_False;
   myFirstShape = theFirstShape;
   mySecondShape = theSecondShape;
   myShapesNumber = 2;
-  SetFlyout (15.0);
   SetKindOfDimension (AIS_KOD_LENGTH);
   SetWorkingPlane (theWorkingPlane);
   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_LengthDimension::AIS_LengthDimension (const TopoDS_Edge& theEdge,
                                           const gp_Pln& theWorkingPlane)
-: AIS_Dimension ()
+: AIS_Dimension()
 {
   myIsInitialized = Standard_False;
   myFirstShape = theEdge;
   myShapesNumber = 1;
 {
   myIsInitialized = Standard_False;
   myFirstShape = theEdge;
   myShapesNumber = 1;
-  SetFlyout (15.0);
   SetKindOfDimension (AIS_KOD_LENGTH);
   SetWorkingPlane (theWorkingPlane);
   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_LengthDimension::AIS_LengthDimension (const TopoDS_Face& theFirstFace,
                                           const TopoDS_Face& theSecondFace)
-: AIS_Dimension ()
+: AIS_Dimension()
 {
   myIsInitialized = Standard_False;
   myFirstShape = theFirstFace;
   mySecondShape = theSecondFace;
   myShapesNumber = 2;
 {
   myIsInitialized = Standard_False;
   myFirstShape = theFirstFace;
   mySecondShape = theSecondFace;
   myShapesNumber = 2;
+  SetKindOfDimension (AIS_KOD_LENGTH);
   SetFlyout (15.0);
   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_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;
   myIsInitialized = Standard_False;
   myFirstShape = theFace;
   mySecondShape = theEdge;
   myShapesNumber = 2;
+  SetKindOfDimension (AIS_KOD_LENGTH);
   SetFlyout (15.0);
 }
 
   SetFlyout (15.0);
 }
 
@@ -201,8 +137,8 @@ AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Face& theFace,
 //=======================================================================
 
 Standard_Boolean AIS_LengthDimension::initTwoEdgesLength (const TopoDS_Edge & theFirstEdge,
 //=======================================================================
 
 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);
 {
   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,
 //=======================================================================
 
 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;
 {
   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)
   if (!myIsInitialized)
   {
     if (myShapesNumber == 1)
-        myIsInitialized = initOneShapePoints(myFirstShape);
+    {
+      myIsInitialized = initOneShapePoints (myFirstShape);
+    }
     else if (myShapesNumber == 2)
     else if (myShapesNumber == 2)
-        myIsInitialized = initTwoShapesPoints(myFirstShape, mySecondShape);
+    {
+      myIsInitialized = initTwoShapesPoints (myFirstShape, mySecondShape);
+    }
     else
     else
+    {
       return;
       return;
+    }
   }
   }
-  
+
   // If initialization failed
   if (!myIsInitialized)
   // If initialization failed
   if (!myIsInitialized)
+  {
     return;
     return;
+  }
 
   thePresentation->Clear();
 
   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  : 
 //=======================================================================
 
 //purpose  : 
 //=======================================================================
 
-void AIS_LengthDimension::computeValue ()
+void AIS_LengthDimension::computeValue()
 {
   myValue = myFirstPoint.Distance (mySecondPoint);
   AIS_Dimension::computeValue ();
 {
   myValue = myFirstPoint.Distance (mySecondPoint);
   AIS_Dimension::computeValue ();
index 0d1207e..674566d 100644 (file)
@@ -67,15 +67,6 @@ class AIS_LengthDimension : public AIS_Dimension
 {
 public:
 
 {
 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);
   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);
 
   Standard_EXPORT AIS_LengthDimension (const TopoDS_Face& theFace,
                                        const TopoDS_Edge& theEdge);
 
+public:
+
   DEFINE_STANDARD_RTTI(AIS_LengthDimension)
   DEFINE_STANDARD_RTTI(AIS_LengthDimension)
+
 private:
 private:
+
   Standard_Boolean initTwoEdgesLength (const TopoDS_Edge & theFirstEdge,
   Standard_Boolean initTwoEdgesLength (const TopoDS_Edge & theFirstEdge,
-                           const TopoDS_Edge& theSecondEdge,
-                           gp_Dir& theDirAttach);
+                                       const TopoDS_Edge& theSecondEdge,
+                                       gp_Dir& theDirAttach);
+
   //! Auxiliary method for <InitTwoShapesPoints()>
   //! in case of the distance between edge and vertex
   Standard_Boolean initEdgeVertexLength (const TopoDS_Edge & theEdge,
   //! Auxiliary method for <InitTwoShapesPoints()>
   //! 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 <InitTwoShapesPoints()>
   //! in case of the distance between face and edge
   Standard_Boolean initEdgeFaceLength (const TopoDS_Edge& theEdge,
                                        const TopoDS_Face& theFace,
                                        gp_Dir& theDirAttach);
   //! Auxiliary method for <InitTwoShapesPoints()>
   //! 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,
   //! 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.
   //! 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) ;
 
   virtual  void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
                          const Handle(Prs3d_Presentation)& thePresentation,
                          const Standard_Integer theMode = 0) ;
-
 };
 
 #endif
 };
 
 #endif
index 9b42475..06c7e07 100755 (executable)
 // purpose or non-infringement. Please see the License for the specific terms
 // and conditions governing the rights and limitations under the License.
 
 // purpose or non-infringement. Please see the License for the specific terms
 // and conditions governing the rights and limitations under the License.
 
-#include <Standard_NotImplemented.hxx>
-
 #include <AIS_RadiusDimension.hxx>
 
 #include <AIS.hxx>
 #include <AIS_Drawer.hxx>
 #include <AIS_RadiusDimension.hxx>
 
 #include <AIS.hxx>
 #include <AIS_Drawer.hxx>
-#include <AIS_KindOfDimension.hxx>
-#include <Adaptor3d_HCurve.hxx>
-#include <BRep_Tool.hxx>
-#include <BRepAdaptor_Surface.hxx>
-#include <BRepAdaptor_Curve.hxx>
-#include <DsgPrs.hxx>
 #include <ElCLib.hxx>
 #include <ElCLib.hxx>
-#include <GC_MakeCircle.hxx>
-#include <gce_MakeCirc.hxx>
 #include <gce_MakeDir.hxx>
 #include <gce_MakeDir.hxx>
-#include <gce_MakeLin.hxx>
-#include <Geom_Surface.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_Circle.hxx>
-#include <Geom_Curve.hxx>
-#include <Geom_TrimmedCurve.hxx>
-#include <Geom_ToroidalSurface.hxx>
-#include <Geom_CylindricalSurface.hxx>
-#include <Geom_SurfaceOfLinearExtrusion.hxx>
-#include <gp_Circ.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Trsf.hxx>
 #include <Graphic3d_ArrayOfSegments.hxx>
 #include <Graphic3d_Group.hxx>
 #include <Graphic3d_ArrayOfSegments.hxx>
 #include <Graphic3d_Group.hxx>
-#include <Precision.hxx>
 #include <PrsMgr_PresentationManager3d.hxx>
 #include <PrsMgr_PresentationManager3d.hxx>
-#include <Prs3d_DimensionAspect.hxx>
-#include <Prs3d_ArrowAspect.hxx>
-#include <Prs3d_Drawer.hxx>
 #include <Prs3d_Root.hxx>
 #include <Prs3d_Root.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <TCollection_ExtendedString.hxx>
-#include <TopExp_Explorer.hxx>
-#include <TopAbs_ShapeEnum.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Face.hxx>
-#include <TopoDS_Wire.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <TopLoc_Location.hxx>
 
 IMPLEMENT_STANDARD_HANDLE(AIS_RadiusDimension, AIS_Dimension)
 IMPLEMENT_STANDARD_RTTIEXT(AIS_RadiusDimension, AIS_Dimension)
 
 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);
   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(),
 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);
   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);
   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;
     }
   }
       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)
+  if (!myIsWorkingPlaneCustom)
   {
   {
-    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);
 }
 
 //=======================================================================
 }
 
 //=======================================================================
index 88bbe8b..8d8cf67 100644 (file)
@@ -44,19 +44,12 @@ DEFINE_STANDARD_HANDLE(AIS_RadiusDimension,AIS_Dimension)
 class AIS_RadiusDimension : public AIS_Dimension
 {
 public:
 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);
+  Standard_EXPORT  AIS_RadiusDimension (const gp_Circ& theCircle);
 
   Standard_EXPORT  AIS_RadiusDimension (const gp_Circ& theCircle,
 
   Standard_EXPORT  AIS_RadiusDimension (const gp_Circ& theCircle,
-                                        const Handle(Prs3d_DimensionAspect)& theDimensionAspect,
-                                        const Standard_Real theExtensionSize = 1.0);
+                                        const gp_Pnt& theAttachPoint);
 
 
-  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 <br>
   //! shape aShape, the dimension aVal, and the text aText.
   Standard_EXPORT  AIS_RadiusDimension (const TopoDS_Shape& aShape);
   //! Constructs the radius display object defined by the <br>
   //! 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:
   DEFINE_STANDARD_RTTI(AIS_RadiusDimension)
 
 protected:
+
   //! Computes dimension value in display units
   Standard_EXPORT virtual void computeValue ();
   //! 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 ();
 
     //! 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
 
 // Fields
+private:
 
   gp_Circ myCircle;
 };
 
   gp_Circ myCircle;
 };
index 218f602..424a15a 100755 (executable)
@@ -75,18 +75,27 @@ is
   --          For more details see AIS_Drawer class, AIS_Shape::Compute() method and
   --          HLRAlgo package from TKHLR toolkit.
   
   --          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
 
   class Presentation;
   ---Purpose: defines the presentation object. This object can be
index 573bef8..778b2fc 100644 (file)
@@ -20,8 +20,8 @@ class DimensionAspect from Prs3d inherits BasicAspect from Prs3d
 
        ---Purpose: defines the attributes when drawing a Length Presentation.
 uses 
 
        ---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,
     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.   
 
       --- 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).
 
       --- 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.
 
       --- 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.
 
       --- 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.
 
       --- 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;
       --- 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.
 
     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.
 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;
     myTextAspect: TextAspect from Prs3d;
     myArrowAspect : ArrowAspect from Prs3d;
     myIsText3d : Boolean from Standard;
     myIsTextShaded : Boolean from Standard;
     myIsArrows3d: Boolean from Standard;
+
     myArrowOrientation : DimensionArrowOrientation from Prs3d;
     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 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;
 end DimensionAspect from Prs3d;
index b5c2abc..ab0b04f 100644 (file)
 
 #include <Prs3d_DimensionAspect.hxx>
 
 
 #include <Prs3d_DimensionAspect.hxx>
 
+#include <Prs3d_ArrowAspect.hxx>
+#include <Prs3d_TextAspect.hxx>
+#include <Prs3d_LineAspect.hxx>
+
 #include <Aspect_TypeOfLine.hxx>
 #include <Graphic3d_AspectText3d.hxx>
 #include <Aspect_TypeOfLine.hxx>
 #include <Graphic3d_AspectText3d.hxx>
-#include <Prs3d_LineAspect.hxx>
-#include <Prs3d_TextAspect.hxx>
-#include <Prs3d_ArrowAspect.hxx>
 #include <Quantity_Color.hxx>
 
 IMPLEMENT_STANDARD_HANDLE (Prs3d_DimensionAspect, Prs3d_BasicAspect)
 #include <Quantity_Color.hxx>
 
 IMPLEMENT_STANDARD_HANDLE (Prs3d_DimensionAspect, Prs3d_BasicAspect)
@@ -33,13 +34,12 @@ IMPLEMENT_STANDARD_RTTIEXT (Prs3d_DimensionAspect, Prs3d_BasicAspect)
 //purpose  : 
 //=======================================================================
 
 //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);
   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);
   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  : 
 //======================================================================= 
 
 //purpose  : 
 //======================================================================= 
 
-Prs3d_DimensionArrowOrientation Prs3d_DimensionAspect::GetArrowOrientation () const
+Prs3d_DimensionArrowOrientation Prs3d_DimensionAspect::ArrowOrientation() const
 {
   return myArrowOrientation;
 }
 
 //=======================================================================
 {
   return myArrowOrientation;
 }
 
 //=======================================================================
-//function : VerticalTextAlignment
-//purpose  : 
-//======================================================================= 
+//function : SetTextVerticalPosition
+//purpose  :
+//=======================================================================
 
 
-Prs3d_VerticalTextAlignment Prs3d_DimensionAspect::VerticalTextAlignment () const
+void Prs3d_DimensionAspect::SetTextVerticalPosition (const Prs3d_DimensionTextVerticalPosition thePosition)
 {
 {
-  return myVerTextAlignment;
+  myTextVPosition = thePosition;
 }
 }
-   
-//=======================================================================
-//function : SetVerticalTextAlignment
-//purpose  : 
+
 //=======================================================================
 //=======================================================================
+//function : TextVerticalPosition
+//purpose  :
+//======================================================================= 
 
 
-void Prs3d_DimensionAspect::SetVerticalTextAlignment (const Prs3d_VerticalTextAlignment theVertTextAlignment)
+Prs3d_DimensionTextVerticalPosition Prs3d_DimensionAspect::TextVerticalPosition() const
 {
 {
-  myVerTextAlignment = theVertTextAlignment;
+  return myTextVPosition;
 }
 
 //=======================================================================
 }
 
 //=======================================================================
-//function : HorizontalTextAlignment
+//function : SetTextHorizontalPosition
 //purpose  : 
 //purpose  : 
-//======================================================================= 
+//=======================================================================
 
 
-Prs3d_HorizontalTextAlignment Prs3d_DimensionAspect::HorizontalTextAlignment () const
+void Prs3d_DimensionAspect::SetTextHorizontalPosition (const Prs3d_DimensionTextHorizontalPosition thePosition)
 {
 {
-  return myHorTextAlignment;
+  myTextHPosition = thePosition;
 }
 }
-   
+
 //=======================================================================
 //=======================================================================
-//function : SetHorizontalTextAlignment
+//function : TextHorizontalPosition
 //purpose  : 
 //purpose  : 
-//=======================================================================
+//======================================================================= 
 
 
-void Prs3d_DimensionAspect::SetHorizontalTextAlignment (const Prs3d_HorizontalTextAlignment theHorTextAlignment)
+Prs3d_DimensionTextHorizontalPosition Prs3d_DimensionAspect::TextHorizontalPosition() const
 {
 {
-  myHorTextAlignment = theHorTextAlignment;
+  return myTextHPosition;
 }
 
 //=======================================================================
 }
 
 //=======================================================================
@@ -240,3 +241,23 @@ void Prs3d_DimensionAspect::SetArrowAspect (const Handle(Prs3d_ArrowAspect)& the
 {
   myArrowAspect = theAspect;
 }
 {
   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;
+}
index 4c4f8e3..9a84cf4 100755 (executable)
@@ -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);
   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
   anAspect->TextAspect ()->SetColor (Quantity_NOC_YELLOW);
   anAngleDimension->SetDimensionAspect (anAspect);
   // Another position of dimension
index 3c7509a..2f489d5 100644 (file)
@@ -14,10 +14,10 @@ vpoint lengthP2 50 50 50
 vdim -length -name=dim1 -plane=xoy lengthP1 lengthP2
 vdisplay dim1
 vfit
 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."
 checkcolor $x_coord $y_coord 0 1 1
 if { $stat != 1 } {
    puts "Error : Highlighting of length dimension is wrong."
index 3242426..bd179d5 100644 (file)
@@ -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."
 }
 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
 
 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
 
 
 checkcolor $x_coord $y_coord 0 1 1
 
index 2b9d57c..920433b 100644 (file)
@@ -14,13 +14,13 @@ vpoint radP2 50 50 0
 vpoint radP3 100 0 0
 vcircle circle radP1 radP2 radP3 0
 verase radP1 radP2 radP3
 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
 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
 
 
 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."
 }
 
    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
 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
 
 
 checkcolor $x_coord $y_coord 0 1 1
 
index edb7bd7..cf43682 100644 (file)
@@ -14,8 +14,8 @@ vpoint diamP2 50 50 0
 vpoint diamP3 100 0 0
 vcircle circle diamP1 diamP2 diamP3 0
 verase diamP1 diamP2 diamP3
 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
 
 vfit
 vmoveto 208 205
 
@@ -28,9 +28,10 @@ if { $stat != 1 } {
    puts "Error : Highlighting of diameter dimension with 2d text is wrong."
 }
 
    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
 
 vfit
 vmoveto 208 205
 
index 79c441d..c6c3bb8 100644 (file)
@@ -20,10 +20,10 @@ verase radP1 radP2 radP3
 vdim -radius -name=dim -text=3d circle
 vdisplay dim
 vfit
 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 } {
 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
 # 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 } {
 checkcolor $x_coord $y_coord 0 1 1
 
 if { $stat != 1 } {
index 242f6f4..fa506f9 100644 (file)
@@ -20,10 +20,10 @@ verase radP1 radP2 radP3
 vdim -radius -name=dim -text=3d circle
 vdisplay dim
 vfit
 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 } {
 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
 # 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 } {
 checkcolor $x_coord $y_coord 0 1 1
 
 if { $stat != 1 } {
index 091a901..00e7533 100644 (file)
@@ -20,10 +20,10 @@ verase radP1 radP2 radP3
 vdim -radius -name=dim -text=3d circle
 vdisplay dim
 vfit
 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 } {
 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
 # 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 } {
 checkcolor $x_coord $y_coord 0 1 1
 
 if { $stat != 1 } {