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.
#include <AIS_AngleDimension.hxx>
#include <AIS.hxx>
-#include <AIS_Dimension.hxx>
-#include <AIS_DimensionOwner.hxx>
#include <AIS_Drawer.hxx>
-#include <BRep_Tool.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 <ElSLib.hxx>
-
-#include <GC_MakeCircle.hxx>
-#include <GC_MakeConicalSurface.hxx>
-#include <gce_MakeLin.hxx>
#include <gce_MakeLin2d.hxx>
-#include <gce_MakePln.hxx>
-#include <gce_MakeCirc.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_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_SurfaceOfLinearExtrusion.hxx>
#include <Geom_OffsetSurface.hxx>
-#include <GeomAPI_ExtremaCurveCurve.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_ArrayOfPrimitives.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx>
-
#include <IntAna2d_AnaIntersection.hxx>
#include <IntAna2d_IntPoint.hxx>
-#include <IntAna_QuadQuadGeo.hxx>
#include <IntAna_ResultType.hxx>
-#include <Poly_Polygon3D.hxx>
-#include <Precision.hxx>
#include <ProjLib.hxx>
-#include <Prs3d_ArrowAspect.hxx>
-#include <Prs3d_DimensionAspect.hxx>
-#include <Prs3d_Drawer.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 <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)
+namespace
+{
+ static const TCollection_ExtendedString THE_EMPTY_LABEL;
+ static const Standard_ExtCharacter THE_DEGREE_SYMBOL (0x00B0);
+};
+
//=======================================================================
//function : init
//purpose : Private constructor for default initialization
//=======================================================================
-
void AIS_AngleDimension::init()
{
- SetKindOfDimension (AIS_KOD_PLANEANGLE);
- SetFlyout (15.0);
// Default values of units
UnitsAPI::SetLocalSystem (UnitsAPI_SI);
SetUnitsQuantity ("PLANE ANGLE");
SetModelUnits ("rad");
SetDisplayUnits ("deg");
- SetSpecialSymbol (0x00B0);
+ SetSpecialSymbol (THE_DEGREE_SYMBOL);
SetDisplaySpecialSymbol (AIS_DSS_After);
+ SetFlyout (15.0);
+ SetKindOfDimension (AIS_KOD_PLANEANGLE);
MakeUnitsDisplayed (Standard_False);
}
//function : Constructor
//purpose : Two edges dimension
//=======================================================================
-
AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
const TopoDS_Edge& theSecondEdge)
: AIS_Dimension(),
{
init();
myShapesNumber = 2;
- myFirstShape = theFirstEdge;
- mySecondShape = theSecondEdge;
+ myFirstShape = theFirstEdge;
+ mySecondShape = theSecondEdge;
}
//=======================================================================
//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)
{
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);
}
//function : Constructor
//purpose : Three points dimension
//=======================================================================
-
AIS_AngleDimension::AIS_AngleDimension (const gp_Pnt& theFirstPoint,
const gp_Pnt& theSecondPoint,
const gp_Pnt& theThirdPoint)
{
init();
myIsInitialized = Standard_True;
- myFirstPoint = theFirstPoint;
- myCenter = theSecondPoint;
- mySecondPoint = theThirdPoint;
- myShapesNumber = 3;
-}
-
-//=======================================================================
-//function : Constructor
-//purpose : Three points dimension
-//=======================================================================
-
-AIS_AngleDimension::AIS_AngleDimension (const gp_Pnt& theFirstPoint,
- const gp_Pnt& theSecondPoint,
- const gp_Pnt& theThirdPoint,
- const Handle(Prs3d_DimensionAspect)& theDimensionAspect,
- const Standard_Real theExtensionSize)
-: AIS_Dimension (theDimensionAspect,theExtensionSize),
- myIsFlyoutLines (Standard_True)
-{
- myIsInitialized = Standard_True;
- myFirstPoint = theFirstPoint;
- myCenter = theSecondPoint;
- mySecondPoint = theThirdPoint;
- myShapesNumber =3;
+ myFirstPoint = theFirstPoint;
+ myCenter = theSecondPoint;
+ mySecondPoint = theThirdPoint;
+ myShapesNumber = 3;
}
//=======================================================================
//function : Constructor
//purpose : Cone dimension
//=======================================================================
-
AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Face& theCone)
: AIS_Dimension(),
myIsFlyoutLines (Standard_True)
{
init();
myIsInitialized = Standard_False;
- myFirstShape = theCone;
- myShapesNumber = 1;
+ myFirstShape = theCone;
+ myShapesNumber = 1;
}
//=======================================================================
//function : Constructor
//purpose : Two faces dimension
//=======================================================================
-
AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Face& theFirstFace,
const TopoDS_Face& theSecondFace,
const gp_Ax1& theAxis)
{
init();
myIsInitialized = Standard_False;
- myFirstShape = theFirstFace;
- mySecondShape = theSecondFace;
- myShapesNumber = 2;
+ myFirstShape = theFirstFace;
+ mySecondShape = theSecondFace;
+ myShapesNumber = 2;
gp_Pln aPlane;
aPlane.SetAxis (theAxis);
SetWorkingPlane (aPlane);
//function : SetFirstShape
//purpose :
//=======================================================================
-
void AIS_AngleDimension::SetFirstShape (const TopoDS_Shape& theShape,
const Standard_Boolean isSingleShape /*= Standard_False*/)
{
// <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)
//function : initConeAngle
//purpose : initialization of the cone angle
//=======================================================================
-
Standard_Boolean AIS_AngleDimension::initConeAngle (const TopoDS_Face& theCone)
{
if (theCone.IsNull ())
//function : initTwoFacesAngle
//purpose : initialization of angle dimension between two faces
//=======================================================================
-
Standard_Boolean AIS_AngleDimension::initTwoFacesAngle ()
{
TopoDS_Face aFirstFace = TopoDS::Face (myFirstShape);
//function : countDefaultPlane
//purpose :
//=======================================================================
-
void AIS_AngleDimension::countDefaultPlane ()
{
if (!myIsInitialized)
//function : computeValue
//purpose :
//=======================================================================
-
void AIS_AngleDimension::computeValue ()
{
gp_Vec aVec1 (myCenter, myFirstPoint),
// If intersection between two edges doesn't exist
// <myIsInitialized> is set to false
//=======================================================================
-
Standard_Boolean AIS_AngleDimension::initTwoEdgesAngle ()
{
// Data initialization
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: drawArcWithText
//purpose :
//=======================================================================
-
void AIS_AngleDimension::drawArcWithText (const Handle(Prs3d_Presentation)& thePresentation,
const gp_Pnt& theFirstAttach,
const gp_Pnt& theSecondAttach,
const TCollection_ExtendedString& theText,
- const AIS_DimensionDisplayMode theMode)
+ const AIS_DimensionDisplayMode theMode,
+ const Standard_Integer theLabelPosition)
{
gp_Pnt2d aCenter2d = ProjLib::Project (GetWorkingPlane(), myCenter),
aFirstAttach2d = ProjLib::Project (GetWorkingPlane(), theFirstAttach),
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) +
drawArc (thePresentation, theFirstAttach, aTextBeginOnArc, myCenter, aRadius, theMode);
drawArc (thePresentation, aTextEndOnArc, theSecondAttach, myCenter, aRadius, theMode);
}
-
}
//=======================================================================
//function : drawArc
//purpose : draws the arc between two attach points
//=======================================================================
-
void AIS_AngleDimension::drawArc (const Handle(Prs3d_Presentation)& thePresentation,
const gp_Pnt& theFirstAttach,
const gp_Pnt& theSecondAttach,
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);
{
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)
{
//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)
// Parameters for presentation
Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
- Prs3d_Root::CurrentGroup(thePresentation)->
- SetPrimitivesAspect(aDimensionAspect->LineAspect()->Aspect());
+
+ Prs3d_Root::CurrentGroup(thePresentation)->SetPrimitivesAspect(aDimensionAspect->LineAspect()->Aspect());
+
Quantity_Length anArrowLength = aDimensionAspect->ArrowAspect()->Length();
+
if (!myIsValueCustom)
- computeValue ();
+ {
+ computeValue();
+ }
+
TCollection_ExtendedString aValueString;
Standard_Real aTextLength;
getTextWidthAndString (aTextLength, aValueString);
+
if (!myIsWorkingPlaneCustom)
+ {
countDefaultPlane();
+ }
+
gp_Pnt aFirstAttach = myCenter.Translated (gp_Vec(myCenter, myFirstPoint).Normalized() * GetFlyout());
gp_Pnt aSecondAttach = myCenter.Translated (gp_Vec(myCenter, mySecondPoint).Normalized() * GetFlyout());
- // Attach points and radius
- if (aDimensionAspect->HorizontalTextAlignment () == Prs3d_HTA_Center)
- {
- aDimensionAspect->SetArrowOrientation (Prs3d_DAO_Internal);
- if (!canTextBeInCenter (aFirstAttach, aSecondAttach, aTextLength, anArrowLength))
+ // Handle user-defined and automatic arrow placement
+ bool isArrowsExternal = false;
+ switch (aDimensionAspect->ArrowOrientation())
+ {
+ case Prs3d_DAO_External: isArrowsExternal = true; break;
+ case Prs3d_DAO_Internal: isArrowsExternal = false; break;
+ case Prs3d_DAO_Fit:
{
- aDimensionAspect->SetArrowOrientation (Prs3d_DAO_External);
- aDimensionAspect->SetHorizontalTextAlignment (Prs3d_HTA_Left);
+ gp_Vec anAttachVector (aFirstAttach, aSecondAttach);
+ Standard_Real aDimensionWidth = anAttachVector.Magnitude();
+ Standard_Real anArrowsWidth = anArrowLength * 2.0;
+
+ isArrowsExternal = aDimensionWidth < aTextLength + anArrowsWidth;
+ break;
}
}
- else
- aDimensionAspect->SetArrowOrientation (Prs3d_DAO_External);
//Arrows positions and directions
- gp_Vec aFirstArrowVec = (gp_Vec(myCenter, aFirstAttach)^gp_Vec(GetWorkingPlane().Axis().Direction())).Normalized().Reversed()*anArrowLength;
- gp_Vec aSecondArrowVec = (gp_Vec(myCenter, aSecondAttach)^gp_Vec(GetWorkingPlane().Axis().Direction())).Normalized()*anArrowLength;
+ gp_Vec aWPDir = gp_Vec (GetWorkingPlane().Axis().Direction());
+
+ gp_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();
+ }
+
+ 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);
+
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)
{
+ Prs3d_Root::NewGroup (thePresentation);
+
+ Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (4);
aPrimSegments->AddVertex (myCenter);
aPrimSegments->AddVertex (aFirstAttach);
aPrimSegments->AddVertex (myCenter);
aPrimSegments->AddVertex (aSecondAttach);
- }
- if (theMode != AIS_DDM_Text)
- {
+
+ Handle(Graphic3d_AspectLine3d) aFlyoutStyle = myDrawer->DimensionAspect()->LineAspect()->Aspect();
+ Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aFlyoutStyle);
Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments);
- drawArrow (thePresentation, aFirstAttach, gp_Dir (aFirstArrowVec));
- drawArrow (thePresentation, aSecondAttach, gp_Dir (aSecondArrowVec));
}
setComputed (Standard_True);
//function : computeFlyoutSelection
//purpose : computes selection for flyouts
//=======================================================================
-
void AIS_AngleDimension::computeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
const Handle(AIS_DimensionOwner)& theOwner)
{
if (!myIsFlyoutLines)
+ {
return;
+ }
gp_Pnt aFirstAttach = myCenter.Translated (gp_Vec (myCenter, myFirstPoint).Normalized() * GetFlyout());
gp_Pnt aSecondAttach = myCenter.Translated (gp_Vec (myCenter, mySecondPoint).Normalized() * GetFlyout());
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
+}
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
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
- //! 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);
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:
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,
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 ();
// 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 <Adaptor3d_HCurve.hxx>
#include <AIS.hxx>
#include <AIS_Drawer.hxx>
-#include <AIS_DimensionOwner.hxx>
-#include <DsgPrs_DiameterPresentation.hxx>
-#include <DsgPrs_RadiusPresentation.hxx>
#include <ElCLib.hxx>
-#include <ElSLib.hxx>
-#include <GC_MakeCircle.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 <Prs3d_DimensionAspect.hxx>
-#include <Prs3d_ArrowAspect.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_TextAspect.hxx>
-#include <Prs3d_Text.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)
+namespace
+{
+ static const Standard_ExtCharacter THE_DIAMETER_SYMBOL (0x00D8);
+};
+
//=======================================================================
//function : Constructor
//purpose :
{
SetKindOfDimension(AIS_KOD_DIAMETER);
myIsInitialized = Standard_True;
- SetSpecialSymbol (0x00D8);
+ SetSpecialSymbol (THE_DIAMETER_SYMBOL);
SetDisplaySpecialSymbol (AIS_DSS_Before);
+ SetFlyout (0.0);
// Count attach points
myFirstPoint = ElCLib::Value (0, myCircle);
mySecondPoint = myFirstPoint.Translated (gp_Vec(myFirstPoint, theCircle.Location())*2);
: AIS_Dimension(),
myCircle (theCircle)
{
- SetKindOfDimension(AIS_KOD_DIAMETER);
- SetSpecialSymbol (0x00D8);
+ SetKindOfDimension (AIS_KOD_DIAMETER);
+ SetSpecialSymbol (THE_DIAMETER_SYMBOL);
SetDisplaySpecialSymbol (AIS_DSS_Before);
+ SetFlyout (0.0);
myFirstPoint = theAttachPoint;
// Count the second point
if (Abs(myFirstPoint.Distance (theCircle.Location()) - theCircle.Radius()) < Precision::Confusion())
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
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;
}
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);
}
//=======================================================================
Standard_EXPORT AIS_DiameterDimension (const gp_Circ& theCircle,
const gp_Pnt& theAttachPoint);
- Standard_EXPORT AIS_DiameterDimension (const gp_Circ& theCircle,
- const Handle(Prs3d_DimensionAspect)& theDimensionStyle,
- const Standard_Real theExtensionSize = 1.0);
-
Standard_EXPORT AIS_DiameterDimension (const TopoDS_Shape& theShape);
DEFINE_STANDARD_RTTI(AIS_DiameterDimension)
protected:
- Standard_EXPORT virtual void computeValue ();
+ Standard_EXPORT virtual void computeValue();
+
//! Fills default plane object if it is possible to count plane automatically.
- Standard_EXPORT virtual void countDefaultPlane ();
+ Standard_EXPORT virtual void countDefaultPlane();
private:
const Standard_Integer theMode = 0);
// Fields
+private:
gp_Circ myCircle;
};
// 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.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)
-//=======================================================================
-//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 :
//=======================================================================
-
-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),
mySpecialSymbol (' '),
myDisplaySpecialSymbol (AIS_DSS_No),
myIsTextReversed (Standard_False),
- myTextOffset (DimensionAspect()->ArrowAspect()->Length()),
myIsInitialized (Standard_False),
myFlyout (0.0),
- myKindOfDimension (AIS_KOD_NONE),
- myExtensionSize (theExtensionSize)
+ myKindOfDimension (AIS_KOD_NONE)
{
ResetWorkingPlane();
// Units default settings
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.
//=======================================================================
-
Standard_Boolean AIS_Dimension::AcceptDisplayMode (const Standard_Integer theMode) const
{
return theMode == 0 ? Standard_True : Standard_False;
//function : computeValue
//purpose : Computes dimension value in display units.
//=======================================================================
-
void AIS_Dimension::computeValue()
{
UnitsAPI::SetCurrentUnit (myUnitsQuantity.ToCString(), myModelUnits.ToCString());
//function : countDefaultPlane
//purpose :
//=======================================================================
-
void AIS_Dimension::countDefaultPlane()
{
}
//function : GetWorkingPlane
//purpose :
//=======================================================================
-
const gp_Pln& AIS_Dimension::GetWorkingPlane() const
{
return myWorkingPlane;
//function : SetWorkingPlane
//purpose :
//=======================================================================
-
void AIS_Dimension::SetWorkingPlane (const gp_Pln& thePlane)
{
myWorkingPlane = thePlane;
//function : ResetWorkingPlane
//purpose : Set default value of working plane
//=======================================================================
-
void AIS_Dimension::ResetWorkingPlane()
{
myWorkingPlane = myDefaultPlane;
//purpose : Set default value of working plane
// Only for internal use.
//=======================================================================
-
void AIS_Dimension::resetWorkingPlane (const gp_Pln& theNewDefaultPlane)
{
myDefaultPlane = theNewDefaultPlane;
//function : valueInDisplayUnits
//purpose :
//=======================================================================
-
Standard_Real AIS_Dimension::valueToDisplayUnits()
{
return UnitsAPI::AnyToAny (myValue,
//function : KindOfDimension
//purpose :
//=======================================================================
-
AIS_KindOfDimension AIS_Dimension::KindOfDimension() const
{
return myKindOfDimension;
//function : SetKindOfDimension
//purpose :
//=======================================================================
-
void AIS_Dimension::SetKindOfDimension (const AIS_KindOfDimension theKindOfDimension)
{
myKindOfDimension = theKindOfDimension;
}
-//=======================================================================
-//function : SetExtensionSize
-//purpose :
-//=======================================================================
-
-void AIS_Dimension::SetExtensionSize (const Standard_Real theExtensionSize)
-{
- myExtensionSize = theExtensionSize;
-}
-
-//=======================================================================
-//function : GetExtensionSize
-//purpose :
-//=======================================================================
-
-Standard_Real AIS_Dimension::GetExtensionSize() const
-{
- return myExtensionSize;
-}
-
//=======================================================================
//function : GetValue
//purpose :
//=======================================================================
-
Standard_Real AIS_Dimension::GetValue() const
{
return myValue;
//function : SetCustomValue
//purpose :
//=======================================================================
-
void AIS_Dimension::SetCustomValue (const Standard_Real theValue)
{
myValue = theValue;
//function : SetFirstShape
//purpose :
//=======================================================================
-
void AIS_Dimension::SetFirstShape (const TopoDS_Shape& theShape)
{
myFirstShape = theShape;
//function : SetSecondShape
//purpose :
//=======================================================================
-
void AIS_Dimension::SetSecondShape (const TopoDS_Shape& theShape)
{
mySecondShape = theShape;
//function : getTextWidthAndString
//purpose :
//=======================================================================
-
void AIS_Dimension::getTextWidthAndString (Quantity_Length& theWidth,
TCollection_ExtendedString& theString) const
{
theString += TCollection_ExtendedString (mySpecialSymbol);
}
- // Get font length
- // Get expansion ratio for getting a width of symbols
+ // Get text style parameters
Quantity_Color aColor;
- Standard_CString aFont;
+ Standard_CString aFontName;
Standard_Real aFactor;
Standard_Real aSpace;
- myDrawer->DimensionAspect()->TextAspect()->Aspect()->Values (aColor, aFont, aFactor, aSpace);
- theWidth = (myDrawer->DimensionAspect()->TextAspect()->Height() / aFactor) * theString.Length();
+ myDrawer->DimensionAspect()->TextAspect()->Aspect()->Values (aColor, aFontName, aFactor, aSpace);
+ // Init font instance
+ Handle(Font_FTFont) aFont = new Font_FTFont ();
+ aFont->Init (aFontName,
+ myDrawer->DimensionAspect()->TextAspect()->Aspect()->GetTextFontAspect(),
+ (Standard_Integer) myDrawer->DimensionAspect()->TextAspect()->Height(), 72);
+
+ TCollection_ExtendedString aString (theString);
+ aString += ".";
+ Standard_PCharacter aUtf8String = new Standard_Character[aString.Length()];
+ Standard_Integer aStrLength = aString.ToUTF8CString(aUtf8String);
+ theWidth = 0.0;
+ for (Standard_Integer anIt = 0; anIt < aStrLength - 1; ++anIt)
+ {
+ Standard_Real anAdvance = aFont->AdvanceX (aUtf8String[anIt], aUtf8String[anIt + 1]);
+ theWidth += anAdvance;
+ }
}
//=======================================================================
//function : drawArrow
//purpose :
//=======================================================================
-
void AIS_Dimension::drawArrow (const Handle(Prs3d_Presentation)& thePresentation,
const gp_Pnt& theLocation,
const gp_Dir& theDirection)
{
Prs3d_Arrow::Draw (thePresentation,
theLocation,
- theDirection.Reversed(),
+ theDirection,
myDrawer->DimensionAspect()->ArrowAspect()->Angle(),
anArrowLength);
}
else
{
- gp_Vec anArrowDir (theDirection);
+ gp_Vec aBackDir (theDirection.Reversed());
Quantity_Length theCathetusLength = anArrowLength / Cos (M_PI / 9.0);
Handle(Graphic3d_ArrayOfTriangles) anArrow = new Graphic3d_ArrayOfTriangles(3);
- gp_Pnt aLeftPoint (theLocation.Translated (anArrowDir.Rotated (myWorkingPlane.Axis(), M_PI / 9.0) * theCathetusLength));
- gp_Pnt aRightPoint (theLocation.Translated (anArrowDir.Rotated (myWorkingPlane.Axis(), M_PI * 17.0 / 9.0) * theCathetusLength));
+ gp_Pnt aLeftPoint (theLocation.Translated (aBackDir.Rotated (myWorkingPlane.Axis(), M_PI / 9.0) * theCathetusLength));
+ gp_Pnt aRightPoint (theLocation.Translated (aBackDir.Rotated (myWorkingPlane.Axis(), M_PI * 17.0 / 9.0) * theCathetusLength));
anArrow->AddVertex (aLeftPoint);
anArrow->AddVertex (theLocation);
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);
}
}
//function : drawText
//purpose :
//=======================================================================
-
Standard_Real AIS_Dimension::drawText (const Handle(Prs3d_Presentation)& thePresentation,
const gp_Dir& theTextDir,
const TCollection_ExtendedString theText,
- const AIS_DimensionDisplayMode theMode)
+ const AIS_DimensionDisplayMode theMode,
+ const Standard_Integer theLabelPosition)
{
Standard_Real aTextWidth (0.0), aTextHeight (0.0);
if (theMode == AIS_DDM_Line)
- return aTextWidth;
- // Creating new group for text
- Prs3d_Root::NewGroup (thePresentation);
+ {
+ return 0.0;
+ }
if (myDrawer->DimensionAspect()->IsText3d())
{
aTextBndBox.Get (aXMin, anYMin, aZMin, aXMax, anYMax, aZMax);
aTextWidth = aXMax - aXMin;
aTextHeight = anYMax - anYMin;
- gp_Dir aTextDir (theTextDir);
- Standard_Real aHorizontalOffset (0.0), aVerticalOffset (0.0);
- switch (myDrawer->DimensionAspect()->HorizontalTextAlignment())
+
+ Standard_Integer aHLabelPos = theLabelPosition & LabelPosition_HMask;
+ Standard_Integer aVLabelPos = theLabelPosition & LabelPosition_VMask;
+
+ gp_Dir aTextDir (aHLabelPos == LabelPosition_Left ? -theTextDir : theTextDir);
+
+ // compute label offsets
+ Standard_Real aMarginSize = aHeight * THE_3D_TEXT_MARGIN;
+ Standard_Real aCenterHOffset = 0.0;
+ Standard_Real aCenterVOffset = 0.0;
+ switch (aHLabelPos)
{
- case Prs3d_HTA_Left:
- aTextDir.Reverse();
- aHorizontalOffset = -aTextWidth;
- break;
- case Prs3d_HTA_Center:
- aHorizontalOffset = -(aTextWidth / 2.0);
- break;
- case Prs3d_HTA_Right:
- aHorizontalOffset = 0.0;
- break;
+ case LabelPosition_HCenter : aCenterHOffset = 0.0; break;
+ case LabelPosition_Right : aCenterHOffset = aTextWidth / 2.0 + aMarginSize; break;
+ case LabelPosition_Left : aCenterHOffset = -aTextWidth / 2.0 - aMarginSize; break;
}
- switch (myDrawer->DimensionAspect()->VerticalTextAlignment())
+ switch (aVLabelPos)
{
- case Prs3d_VTA_Top:
- aVerticalOffset = 0.0;
- break;
- case Prs3d_VTA_Center:
- aVerticalOffset = -(aTextHeight / 2.0);
- break;
- case Prs3d_VTA_Bottom:
- aVerticalOffset = -aTextHeight;
- break;
+ case LabelPosition_VCenter : aCenterVOffset = 0.0; break;
+ case LabelPosition_Above : aCenterVOffset = aTextHeight / 2.0 + aMarginSize; break;
+ case LabelPosition_Below : aCenterVOffset = -aTextHeight / 2.0 - aMarginSize; break;
}
- gp_Trsf aTrsf;
- aTrsf.SetTranslation (gp_Pnt (), gp_Pnt (aHorizontalOffset, aVerticalOffset, 0.0));
- aTextShape.Move (aTrsf);
+
+ // compute shape offset transformation
+ Standard_Real aShapeHOffset = aCenterHOffset - aTextWidth / 2.0;
+ Standard_Real aShapeVOffset = aCenterVOffset - aTextHeight / 2.0;
+
+ gp_Trsf anOffsetTrsf;
+ anOffsetTrsf.SetTranslation (gp::Origin(), gp_Pnt (aShapeHOffset, aShapeVOffset, 0.0));
+ aTextShape.Move (anOffsetTrsf);
// Transform text to myWorkingPlane coordinate system
- gp_Ax3 aPenAx3 (myGeom.myTextPosition, myWorkingPlane.Axis().Direction(), aTextDir);
- aTrsf.SetTransformation (aPenAx3, gp_Ax3 (gp::XOY()));
- aTextShape.Move (aTrsf);
+ gp_Ax3 aTextCoordSystem (myGeom.myTextPosition, myWorkingPlane.Axis().Direction(), aTextDir);
+ gp_Trsf aTextPlaneTrsf;
+ aTextPlaneTrsf.SetTransformation (aTextCoordSystem, gp_Ax3 (gp::XOY()));
+ aTextShape.Move (aTextPlaneTrsf);
// Set display parameters for advanced selection
BRepBndLib::AddClose (aTextShape, myGeom.myTextBndBox);
- // Drawing text
- gp_Pnt aTextCenter = myGeom.myTextPosition.Translated (gp_Vec (theTextDir) * aTextWidth * 0.5);
- Prs3d_Root::CurrentGroup (thePresentation)->SetFlippingOptions (Standard_True, gp_Ax2 (aTextCenter, myWorkingPlane.Axis().Direction(), aTextDir));
+
+ // Set text flipping anchors
+ gp_Trsf aCenterOffsetTrsf;
+ gp_Pnt aCenterOffset (aCenterHOffset, aCenterVOffset, 0.0);
+ aCenterOffsetTrsf.SetTranslation (gp::Origin(), aCenterOffset);
+
+ gp_Pnt aCenterOfFlip (gp::Origin());
+ aCenterOfFlip.Transform (aCenterOffsetTrsf);
+ aCenterOfFlip.Transform (aTextPlaneTrsf);
+
+ gp_Ax2 aFlippingAxes (aCenterOfFlip, myWorkingPlane.Axis().Direction(), aTextDir);
+ Prs3d_Root::CurrentGroup (thePresentation)->SetFlippingOptions (Standard_True, aFlippingAxes);
+
+ // Draw text
if (myDrawer->DimensionAspect()->IsTextShaded())
{
// Setting text shading and color parameters
// 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 :
//=======================================================================
-
-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);
}
}
//function : SetDimensionAspect
//purpose :
//=======================================================================
-
void AIS_Dimension::SetDimensionAspect (const Handle(Prs3d_DimensionAspect)& theDimensionAspect)
{
myDrawer->SetDimensionAspect (theDimensionAspect);
//function : DimensionAspect
//purpose :
//=======================================================================
-
Handle(Prs3d_DimensionAspect) AIS_Dimension::DimensionAspect() const
{
return myDrawer->DimensionAspect();
}
-//=======================================================================
-//function : SetTextOffset
-//purpose :
-//=======================================================================
-
-void AIS_Dimension::SetTextOffset (const Standard_Real theOffset)
-{
- myTextOffset = theOffset;
-}
-
-//=======================================================================
-//function : TextOffset
-//purpose :
-//=======================================================================
-
-Standard_Real AIS_Dimension::TextOffset() const
-{
- return myTextOffset;
-}
-
//=======================================================================
//function : drawLinearDimension
//purpose :
//=======================================================================
-
void AIS_Dimension::drawLinearDimension (const Handle(Prs3d_Presentation)& thePresentation,
- const gp_Pnt& theFirstAttach,
- const gp_Pnt& theSecondAttach,
const AIS_DimensionDisplayMode theMode,
const Standard_Boolean isOneSideDimension/* = Standard_False*/)
{
setComputed (Standard_False);
return;
}
+
+ // compute dimension line points
+ gp_Ax1 aWorkingPlaneNormal = GetWorkingPlane().Axis();
+ gp_Dir aTargetPointsVector = gce_MakeDir (myFirstPoint, mySecondPoint);
+
+ // compute flyout direction vector
+ gp_Dir aFlyoutVector = aWorkingPlaneNormal.Direction() ^ aTargetPointsVector;
+
+ // create lines for layouts
+ gp_Lin aLine1 (myFirstPoint, aFlyoutVector);
+ gp_Lin aLine2 (mySecondPoint, aFlyoutVector);
+
+ // Get flyout end points
+ gp_Pnt aLineBegPoint = ElCLib::Value (ElCLib::Parameter (aLine1, myFirstPoint) + GetFlyout(), aLine1);
+ gp_Pnt aLineEndPoint = ElCLib::Value (ElCLib::Parameter (aLine2, mySecondPoint) + GetFlyout(), aLine2);
+
Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
Handle(SelectMgr_EntityOwner) anEmptyOwner;
myGeom.mySensitiveSegments.Clear();
- gp_Dir aAttachPointsVector = GetWorkingPlane().Axis().Direction()^gce_MakeDir (myFirstPoint, mySecondPoint);
- // Get line of the dimension
- gp_Lin aDimensionLine = gce_MakeLin (theFirstAttach, theSecondAttach);
+ gp_Lin aDimensionLine = gce_MakeLin (aLineBegPoint, aLineEndPoint);
- // Get parameters on dimension line of two layout points
- Standard_Real aParam1 = ElCLib::Parameter (aDimensionLine, theFirstAttach);
- Standard_Real aParam2 = ElCLib::Parameter (aDimensionLine, theSecondAttach);
+ // For extensions we need to know arrow size, text size and extension size: get it from aspect
+ Quantity_Length anArrowLength = aDimensionAspect->ArrowAspect()->Length();
+ Standard_Real anExtensionSize = aDimensionAspect->ExtensionSize();
- // For extensions we need to know arrow size and text size, get it from aspect
- Quantity_Length anArrowLength = aDimensionAspect->ArrowAspect()->Length();
- // Set line parameters
- Standard_Real aGap = 0.; // gap between line and text if AIS_VTA_Center
if (!myIsValueCustom)
{
computeValue();
Standard_Real aTextLength;
getTextWidthAndString (aTextLength, aValueString);
- // Automatical text and arrow placement
- Standard_Real aValue = myFirstPoint.Distance (mySecondPoint);
- if (aDimensionAspect->HorizontalTextAlignment() == Prs3d_HTA_Center)
+ // Handle user-defined and automatic arrow placement
+ bool isArrowsExternal = false;
+ switch (aDimensionAspect->ArrowOrientation())
{
- aDimensionAspect->SetArrowOrientation (Prs3d_DAO_Internal);
- if (aValue < aTextLength + (isOneSideDimension ? anArrowLength : 2.0 * anArrowLength))
+ case Prs3d_DAO_External: isArrowsExternal = true; break;
+ case Prs3d_DAO_Internal: isArrowsExternal = false; break;
+ case Prs3d_DAO_Fit:
{
- aDimensionAspect->SetArrowOrientation (Prs3d_DAO_External);
- aDimensionAspect->SetHorizontalTextAlignment (Prs3d_HTA_Left);
+ Standard_Real aDimensionWidth = aLineBegPoint.Distance (aLineEndPoint);
+ Standard_Real anArrowsWidth = isOneSideDimension ? anArrowLength : 2.0 * anArrowLength;
+ isArrowsExternal = aDimensionWidth < aTextLength + anArrowsWidth;
+ break;
}
}
- else
- {
- aDimensionAspect->SetArrowOrientation (Prs3d_DAO_External);
- }
// Arrows positions and directions
- gp_Pnt aFirstArrowPosition = ElCLib::Value (aParam1, aDimensionLine);
- gp_Pnt aSecondArrowPosition = ElCLib::Value (aParam2, aDimensionLine);
- gp_Dir aFirstArrowDir = aDimensionLine.Direction();
- gp_Dir aSecondArrowDir = aDimensionLine.Direction().Reversed();
- Standard_Real aFirstArrowBegin, aFirstArrowEnd, aSecondArrowBegin, aSecondArrowEnd;
+ gp_Dir aFirstArrowDir = aDimensionLine.Direction().Reversed();
+ gp_Dir aSecondArrowDir = aDimensionLine.Direction();
+ gp_Dir aFirstExtensionDir = aDimensionLine.Direction().Reversed();
+ gp_Dir aSecondExtensionDir = aDimensionLine.Direction();
+
+ 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();
-
- 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,
- myIsTextReversed ? aTextDir.Reversed() : aTextDir,
+ myIsTextReversed ? -aTextDir : aTextDir,
aValueString,
- theMode);
+ theMode,
+ aLabelPosition);
- aFirstPoint = ElCLib::Value (aFirstArrowEnd, aDimensionLine);
- if (isGapInCenter)
+ if (theMode == AIS_DDM_Text)
{
- aLastPoint = ElCLib::Value (ElCLib::Parameter (aDimensionLine,myGeom.myTextPosition) - aGap - (aTextWidth / 2.0), aDimensionLine);
- aPrimSegments->AddVertex (aFirstPoint);
- aPrimSegments->AddVertex (aLastPoint);
- myGeom.mySensitiveSegments.Append (new Select3D_SensitiveSegment (anEmptyOwner,aFirstPoint,aLastPoint));
- aFirstPoint = ElCLib::Value (ElCLib::Parameter(aDimensionLine,myGeom.myTextPosition) + (aTextWidth / 2.0) + aGap, aDimensionLine);
+ 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
- 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
- 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)
{
- aFirstPoint = ElCLib::Value (aSecondArrowEnd, aDimensionLine);
- aLastPoint = ElCLib::Value (aSecondArrowEnd + anArrowLength, aDimensionLine);
- aPrimSegments->AddVertex (aFirstPoint);
- aPrimSegments->AddVertex (aLastPoint);
- myGeom.mySensitiveSegments.Append(new Select3D_SensitiveSegment (anEmptyOwner, aFirstPoint, aLastPoint));
+ drawArrow (thePresentation, aSecondArrowBegin, aSecondArrowDir);
}
- if (theMode != AIS_DDM_Text)
+
+ if (!isArrowsExternal || isOneSideDimension)
{
- // Main dimension line, short extension
- Prs3d_Root::NewGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
- Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments);
- // Group1: Add arrows to a group
- drawArrow (thePresentation, aFirstArrowPosition, aFirstArrowDir);
- if (!isOneSideDimension)
- {
- drawArrow (thePresentation, aSecondArrowPosition, aSecondArrowDir);
- }
+ break;
}
+
+ // add extension lines for external arrows
+ Prs3d_Root::NewGroup (thePresentation);
+
+ drawExtension (thePresentation, anExtensionSize,
+ aSecondArrowEnd, aSecondExtensionDir,
+ THE_EMPTY_LABEL, theMode, LabelPosition_None);
+
break;
}
- case Prs3d_HTA_Right:
+ // ------------------------------------------------------------------------ //
+ // 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;
}
}
+ // 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);
}
//function : SetFirstPoint
//purpose :
//=======================================================================
-
void AIS_Dimension::SetFirstPoint (const gp_Pnt& thePoint)
{
myFirstPoint = thePoint;
//function : SetSecondPoint
//purpose :
//=======================================================================
-
void AIS_Dimension::SetSecondPoint (const gp_Pnt& thePoint)
{
mySecondPoint = thePoint;
//function : Type
//purpose :
//=======================================================================
-
AIS_KindOfInteractive AIS_Dimension::Type() const
{
return AIS_KOI_Relation;
//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,
//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,
//function : SetDisplaySpecialSymbol
//purpose : specifies dimension special symbol display options
//=======================================================================
-
void AIS_Dimension::SetDisplaySpecialSymbol (const AIS_DisplaySpecialSymbol theDisplaySpecSymbol)
{
myDisplaySpecialSymbol = theDisplaySpecSymbol;
//function : DisplaySpecialSymbol
//purpose : shows dimension special symbol display options
//=======================================================================
-
AIS_DisplaySpecialSymbol AIS_Dimension::DisplaySpecialSymbol() const
{
return myDisplaySpecialSymbol;
//function : SetSpecialSymbol
//purpose : specifies special symbol
//=======================================================================
-
void AIS_Dimension::SetSpecialSymbol (const Standard_ExtCharacter theSpecialSymbol)
{
mySpecialSymbol = theSpecialSymbol;
//function : SpecialSymbol
//purpose : returns special symbol
//=======================================================================
-
Standard_ExtCharacter AIS_Dimension::SpecialSymbol() const
{
return mySpecialSymbol;
//function : IsUnitsDisplayed
//purpose : shows if Units are to be displayed along with dimension value
//=======================================================================
-
Standard_Boolean AIS_Dimension::IsUnitsDisplayed() const
{
return myToDisplayUnits;
//function : MakeUnitsDisplayed
//purpose : sets to display units along with the dimension value or no
//=======================================================================
-
void AIS_Dimension::MakeUnitsDisplayed (const Standard_Boolean toDisplayUnits)
{
myToDisplayUnits = toDisplayUnits;
//function : MakeUnitsDisplayed
//purpose : returns the current type of units
//=======================================================================
-
TCollection_AsciiString AIS_Dimension::UnitsQuantity() const
{
return myUnitsQuantity;
//function : SetUnitsQuantity
//purpose : sets the current type of units
//=======================================================================
-
void AIS_Dimension::SetUnitsQuantity (const TCollection_AsciiString& theUnitsQuantity)
{
myUnitsQuantity = theUnitsQuantity;
//function : ModelUnits
//purpose : returns the current model units
//=======================================================================
-
TCollection_AsciiString AIS_Dimension::ModelUnits() const
{
return myModelUnits;
//function : SetModelUnits
//purpose : sets the current model units
//=======================================================================
-
void AIS_Dimension::SetModelUnits (const TCollection_AsciiString& theUnits)
{
myModelUnits = theUnits;
//function : DisplayUnits
//purpose : returns the current display units
//=======================================================================
-
TCollection_AsciiString AIS_Dimension::DisplayUnits() const
{
return myDisplayUnits;
//function : SetDisplayUnits
//purpose : sets the current display units
//=======================================================================
-
void AIS_Dimension::SetDisplayUnits (const TCollection_AsciiString& theUnits)
{
myDisplayUnits = theUnits;
//function : isComputed
//purpose :
//=======================================================================
-
Standard_Boolean AIS_Dimension::isComputed() const
{
return myGeom.myIsComputed;
//function : setComputed
//purpose :
//=======================================================================
-
void AIS_Dimension::setComputed (Standard_Boolean isComputed)
{
myGeom.myIsComputed = isComputed;
//function : textPosition
//purpose :
//=======================================================================
-
gp_Pnt AIS_Dimension::textPosition() const
{
return myGeom.myTextPosition;
//function : setTextPosition
//purpose :
//=======================================================================
-
void AIS_Dimension::setTextPosition (const gp_Pnt thePosition)
{
myGeom.myTextPosition = thePosition;
//function : resetGeom
//purpose :
//=======================================================================
-
void AIS_Dimension::resetGeom()
{
setComputed (Standard_False);
//function : IsTextReversed
//purpose :
//=======================================================================
-
Standard_Boolean AIS_Dimension::IsTextReversed() const
{
return myIsTextReversed;
//function : MakeTextReversed
//purpose :
//=======================================================================
-
void AIS_Dimension::MakeTextReversed (const Standard_Boolean isTextReversed)
{
myIsTextReversed = isTextReversed;
//function : SetSelToleranceForText2d
//purpose :
//=======================================================================
-
void AIS_Dimension::SetSelToleranceForText2d (const Standard_Real theTol)
{
myGeom.mySelToleranceForText2d = theTol;
//function : SelToleranceForText2d
//purpose :
//=======================================================================
-
Standard_Real AIS_Dimension::SelToleranceForText2d() const
{
return myGeom.mySelToleranceForText2d;
//=======================================================================
//function : SetFlyout
-//purpose :
+//purpose :
//=======================================================================
-
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
//=======================================================================
-
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 :
//=======================================================================
-
void AIS_Dimension::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode)
{
aSensitiveForText->Set (aTextOwner);
}
else
+ {
computeFlyoutSelection (theSelection, anOwner);
+ }
theSelection->Add (aSensitiveForLine);
theSelection->Add (aSensitiveForText);
#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>
class AIS_Dimension : public AIS_InteractiveObject
{
+protected:
+
+ // Specifies supported at base level horizontal and vertical
+ // label positions for drawing extension lines and centered text.
+ enum LabelPosition
+ {
+ LabelPosition_None = 0x00,
+
+ LabelPosition_Left = 0x01,
+ LabelPosition_Right = 0x02,
+ LabelPosition_HCenter = 0x04,
+ LabelPosition_HMask = LabelPosition_Left | LabelPosition_Right | LabelPosition_HCenter,
+
+ LabelPosition_Above = 0x10,
+ LabelPosition_Below = 0x20,
+ LabelPosition_VCenter = 0x40,
+ LabelPosition_VMask = LabelPosition_Above | LabelPosition_Below | LabelPosition_VCenter
+ };
+
public:
+
//! Constructor with default parameters values
- Standard_EXPORT AIS_Dimension (const Standard_Real theExtensionSize = 1.0);
- //! Constructor to set aspect of dimension
- Standard_EXPORT AIS_Dimension (const Handle(Prs3d_DimensionAspect)& theAspect,
- const Standard_Real theExtensionSize = 1.0);
+ Standard_EXPORT AIS_Dimension();
+
//! Gets dimension value
- Standard_EXPORT Standard_Real GetValue () const;
+ Standard_EXPORT Standard_Real GetValue() const;
//! Sets dimension value
//! Attention! This method is used ONLY to set custom value.
//! 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);
//! The interactive context can have a default mode of
//! representation for the set of Interactive Objects. This
//! mode may not be accepted by object
- Standard_EXPORT virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const;
+ Standard_EXPORT virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const;
+
// Selection computing if it is needed here
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode);
+
//! Reset working plane to default.
Standard_EXPORT void ResetWorkingPlane();
+
//! specifies dimension special symbol display options
Standard_EXPORT void SetDisplaySpecialSymbol (const AIS_DisplaySpecialSymbol theDisplaySpecSymbol);
+
//! shows dimension special symbol display options
Standard_EXPORT AIS_DisplaySpecialSymbol DisplaySpecialSymbol() const;
+
//! specifies special symbol
Standard_EXPORT void SetSpecialSymbol (const Standard_ExtCharacter theSpecialSymbol);
+
//! returns special symbol
Standard_EXPORT Standard_ExtCharacter SpecialSymbol() const;
+
//! shows if Units are to be displayed along with dimension value
Standard_EXPORT Standard_Boolean IsUnitsDisplayed() const;
+
//! sets to display units along with the dimansion value or no
Standard_EXPORT void MakeUnitsDisplayed (const Standard_Boolean toDisplayUnits);
+
//! returns the current type of units
Standard_EXPORT TCollection_AsciiString UnitsQuantity() const;
+
//! sets the current type of units
Standard_EXPORT void SetUnitsQuantity (const TCollection_AsciiString& theUnitsQuantity);
+
//! returns the current model units
Standard_EXPORT TCollection_AsciiString ModelUnits() const;
+
//! sets the current model units
Standard_EXPORT void SetModelUnits (const TCollection_AsciiString& theUnits);
+
//! returns the current display units
Standard_EXPORT TCollection_AsciiString DisplayUnits() const;
+
//! sets the current display units
Standard_EXPORT void SetDisplayUnits (const TCollection_AsciiString& theUnits);
- //! sets the text offset: distance from attach point to the text on the extension
- //! in case if text isn't in center of the dimension line
- Standard_EXPORT void SetTextOffset (const Standard_Real theOffset);
- //! returns the text offset: distance from attach point to the text on the extension
- //! in case if text isn't in center of the dimension line
- Standard_EXPORT Standard_Real TextOffset() const;
+
//! Important! Only for 3d text </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);
+
//! Sets selection tolerance for text2d:
//! For 2d text selection detection sensitive point with tolerance is used
//! to change this tolerance use this method
//! Important! Only for 2d text
Standard_EXPORT void SetSelToleranceForText2d (const Standard_Real theTol);
+
//! Returns selection tolerance for text2d:
//! For 2d text selection detection sensitive point with tolerance is used
//! Important! Only for 2d text
Standard_EXPORT Standard_Real SelToleranceForText2d() const;
+
//! Sets flyout size for dimension.
Standard_EXPORT void SetFlyout (const Standard_Real theFlyout);
+
//! @return flyout size for dimension.
- Standard_EXPORT Standard_Real GetFlyout () const;
+ Standard_Real GetFlyout() const
+ {
+ return myFlyout;
+ }
+
+public:
DEFINE_STANDARD_RTTI(AIS_Dimension)
protected:
+
Standard_EXPORT void getTextWidthAndString (Quantity_Length& theWidth,
TCollection_ExtendedString& theString) const;
Standard_EXPORT Standard_Real drawText (const Handle(Prs3d_Presentation)& thePresentation,
const gp_Dir& theTextDir,
const TCollection_ExtendedString theText,
- const AIS_DimensionDisplayMode theMode);
+ const AIS_DimensionDisplayMode theMode,
+ const Standard_Integer theLabelPosition);
//! Performs computing of dimension linear extension with text
- Standard_EXPORT virtual void drawExtensionWithText (const Handle(Prs3d_Presentation)& thePresentation,
- const gp_Pnt& theStartPoint,
- const gp_Lin& theDimensionLine,
- const TCollection_ExtendedString& theValueString,
- const AIS_DimensionDisplayMode theMode);
+ //! @param thePresentation [in] the presentation to fill with graphical primitives.
+ //! @param theExtensionSize [in] the size of extension line.
+ //! @param theExtensionStart [in] the point where extension line connects to dimension.
+ //! @param theExtensionDir [in] the direction of extension line.
+ //! @param theValueString [in] the string with value.
+ //! @param theMode [in] the display mode.
+ //! @param theLabelPosition [in] position flags for the text label.
+ Standard_EXPORT void drawExtension (const Handle(Prs3d_Presentation)& thePresentation,
+ const Standard_Real theExtensionSize,
+ const gp_Pnt& theExtensionStart,
+ const gp_Dir& theExtensionDir,
+ const TCollection_ExtendedString& theValueString,
+ const AIS_DimensionDisplayMode theMode,
+ const Standard_Integer theLabelPosition);
//! Performs computing of linear dimension (for length, diameter, radius and so on)
Standard_EXPORT void drawLinearDimension (const Handle(Prs3d_Presentation)& thePresentation,
- const gp_Pnt& theFirstAttach,
- const gp_Pnt& theSecondAttach,
const AIS_DimensionDisplayMode theMode,
const Standard_Boolean isOneSideDimension = Standard_False);
//! Fills sensitive entity for flyouts and adds it to the selection.
Standard_EXPORT virtual void computeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
const Handle(AIS_DimensionOwner)& theOwner);
- // Fields
-protected:
- /// WORKING PLANE PROPERTIES
+protected: //! @name Working plane properties
//! Dimension default plane
gp_Pln myDefaultPlane;
+
//! Shows if working plane is set custom
Standard_Boolean myIsWorkingPlaneCustom;
- /// VALUE PROPERTIES
+protected: //! @name Value properties
//! Dimension value which is displayed with dimension lines
Standard_Real myValue;
+
//! Shows if the value is set by user and is no need to count it automatically
Standard_Boolean myIsValueCustom;
- /// UNITS PROPERTIES
+protected: // !@name Units properties
//! The quantity of units for the value computation
TCollection_AsciiString myUnitsQuantity;
+
//! Units of the model
TCollection_AsciiString myModelUnits;
+
//! Units in which the displayed value will be converted
TCollection_AsciiString myDisplayUnits;
+
//! Determines if units is to be displayed along with the value
Standard_Boolean myToDisplayUnits;
+
//! Special symbol for some kind of dimensions (for diameter, radius and so on)
Standard_ExtCharacter mySpecialSymbol;
+
//! Special symbol display options
AIS_DisplaySpecialSymbol myDisplaySpecialSymbol;
- /// GEOMETRY PROPERTIES
+protected: //! @name Geometry properties
//! Geometry of dimensions, needs for advanced selection
//! Geometry is computed in Compute() method and is used
{
//! Text position
gp_Pnt myTextPosition;
+
//! Text bounding box, stored for advanced selection
Bnd_Box myTextBndBox;
+
//! Sensitive point tolerance for 2d text selection
Standard_Real mySelToleranceForText2d;
+
//! For advanced dimension line selection
Select3D_ListOfSensitive mySensitiveSegments;
+
//! Shows if attachment points were computed
Standard_Boolean myIsComputed;
+
public:
- DimensionGeom ()
- : myIsComputed (Standard_False)
- { }
+
+ DimensionGeom () : myIsComputed (Standard_False) {}
};
//! Shows if text is inverted
Standard_Boolean myIsTextReversed;
- //! Determines distance from attach point to the text on the extension
- //! in case if text isn't in center of the dimension line
- Standard_Real myTextOffset;
+
//! Points that are base for dimension.
//! My first point of dimension attach (belongs to shape for which dimension is computed)
gp_Pnt myFirstPoint;
+
//! My second point of dimension attach (belongs to shape for which dimension is computed)
gp_Pnt mySecondPoint;
+
//! Shows if attach points are initialized correctly
Standard_Boolean myIsInitialized;
+
//! First shape (can be vertex, edge or face)
TopoDS_Shape myFirstShape;
+
//! Second shape (can be vertex, edge or face)
TopoDS_Shape mySecondShape;
+
//! Number of shapes
Standard_Integer myShapesNumber;
+
//! Defines flyout lines and direction
//! Flyout direction in the working plane.
//! Can be negative, or positive and is defined by the sign of myFlyout value.
//! The direction vector is counting using the working plane.
//! myFlyout value defined the size of flyout.
Standard_Real myFlyout;
+
//! Geometry of dimensions, needs for advanced selection
//! Geometry is computed in Compute() method and is used
//! in ComputeSelection() method.
//! If it is computed successfully, myIsComputed = Standard_True.
//! to check computing result use IsComputed() method
DimensionGeom myGeom;
+
private:
+
//! Type of dimension
AIS_KindOfDimension myKindOfDimension;
+
//! Dimension working plane, is equal to <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
// 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_DimensionOwner.hxx>
-#include <AIS_Drawer.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 <DsgPrs.hxx>
-#include <DsgPrs_LengthPresentation.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_Plane.hxx>
-#include <Geom_OffsetSurface.hxx>
#include <gce_MakeDir.hxx>
-#include <gce_MakeLin.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 <TopoDS.hxx>
IMPLEMENT_STANDARD_HANDLE(AIS_LengthDimension, AIS_Dimension)
IMPLEMENT_STANDARD_RTTIEXT(AIS_LengthDimension, AIS_Dimension)
//purpose : Dimension between two points
//=======================================================================
-AIS_LengthDimension::AIS_LengthDimension (const gp_Pnt& theFirstPoint,
- const gp_Pnt& theSecondPoint,
- const gp_Pln& theDimensionPlane,
- const Handle(Prs3d_DimensionAspect)& theDimensionAspect,
- const Standard_Real theExtensionSize /*= 1.0*/)
- :AIS_Dimension (theDimensionAspect,theExtensionSize)
-{
- myIsInitialized = Standard_True;
- myFirstPoint = theFirstPoint;
- mySecondPoint = theSecondPoint;
- myShapesNumber = 2;
- myFirstShape = BRepLib_MakeVertex (myFirstPoint);
- mySecondShape = BRepLib_MakeVertex (mySecondPoint);
- SetFlyout (15.0);
- SetKindOfDimension(AIS_KOD_LENGTH);
- SetWorkingPlane (theDimensionPlane);
-}
-
-//=======================================================================
-//function : Constructor
-//purpose : Dimension between two points
-//=======================================================================
-
AIS_LengthDimension::AIS_LengthDimension (const gp_Pnt& theFirstPoint,
const gp_Pnt& theSecondPoint,
const gp_Pln& theDimensionPlane)
-: AIS_Dimension ()
+: AIS_Dimension()
{
myIsInitialized = Standard_True;
myFirstPoint = theFirstPoint;
myFirstShape = BRepLib_MakeVertex (myFirstPoint);
mySecondShape = BRepLib_MakeVertex (mySecondPoint);
myShapesNumber = 2;
- SetFlyout (15.0);
SetKindOfDimension (AIS_KOD_LENGTH);
SetWorkingPlane (theDimensionPlane);
+ SetFlyout (15.0);
}
//=======================================================================
AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Shape& theFirstShape,
const TopoDS_Shape& theSecondShape,
const gp_Pln& theWorkingPlane)
-: AIS_Dimension ()
+: AIS_Dimension()
{
myIsInitialized = Standard_False;
myFirstShape = theFirstShape;
mySecondShape = theSecondShape;
myShapesNumber = 2;
- SetFlyout (15.0);
SetKindOfDimension (AIS_KOD_LENGTH);
SetWorkingPlane (theWorkingPlane);
+ SetFlyout (15.0);
}
//=======================================================================
AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Edge& theEdge,
const gp_Pln& theWorkingPlane)
-: AIS_Dimension ()
+: AIS_Dimension()
{
myIsInitialized = Standard_False;
myFirstShape = theEdge;
myShapesNumber = 1;
- SetFlyout (15.0);
SetKindOfDimension (AIS_KOD_LENGTH);
SetWorkingPlane (theWorkingPlane);
+ SetFlyout (15.0);
}
//=======================================================================
AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Face& theFirstFace,
const TopoDS_Face& theSecondFace)
-: AIS_Dimension ()
+: AIS_Dimension()
{
myIsInitialized = Standard_False;
myFirstShape = theFirstFace;
mySecondShape = theSecondFace;
myShapesNumber = 2;
+ SetKindOfDimension (AIS_KOD_LENGTH);
SetFlyout (15.0);
- SetKindOfDimension(AIS_KOD_LENGTH);
}
//=======================================================================
AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Face& theFace,
const TopoDS_Edge& theEdge)
- : AIS_Dimension ()
+: AIS_Dimension()
{
- SetKindOfDimension(AIS_KOD_LENGTH);
myIsInitialized = Standard_False;
myFirstShape = theFace;
mySecondShape = theEdge;
myShapesNumber = 2;
+ SetKindOfDimension (AIS_KOD_LENGTH);
SetFlyout (15.0);
}
//=======================================================================
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_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;
if (!myIsInitialized)
{
if (myShapesNumber == 1)
- myIsInitialized = initOneShapePoints(myFirstShape);
+ {
+ myIsInitialized = initOneShapePoints (myFirstShape);
+ }
else if (myShapesNumber == 2)
- myIsInitialized = initTwoShapesPoints(myFirstShape, mySecondShape);
+ {
+ myIsInitialized = initTwoShapesPoints (myFirstShape, mySecondShape);
+ }
else
+ {
return;
+ }
}
-
+
// If initialization failed
if (!myIsInitialized)
+ {
return;
+ }
thePresentation->Clear();
- // Get length dimension aspect from AIS object drawer
- Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
- Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
-
- //Count flyout direction
- gp_Ax1 aWorkingPlaneNormal = GetWorkingPlane().Axis();
- gp_Dir aTargetPointsVector = gce_MakeDir (myFirstPoint, mySecondPoint);
- // Count a flyout direction vector.
- gp_Dir aFlyoutVector = aWorkingPlaneNormal.Direction()^aTargetPointsVector;
-
- // Create lines for layouts
- gp_Lin aLine1 (myFirstPoint, aFlyoutVector);
- gp_Lin aLine2 (mySecondPoint, aFlyoutVector);
-
- // Get flyout end points
- gp_Pnt aFlyoutEnd1 = ElCLib::Value (ElCLib::Parameter (aLine1, myFirstPoint) + GetFlyout(), aLine1);
- gp_Pnt aFlyoutEnd2 = ElCLib::Value (ElCLib::Parameter (aLine2, mySecondPoint) + GetFlyout(), aLine2);
-
- // Add layout lines to graphic group
- // Common to all type of dimension placement.
- if (theMode == 0)
- {
- Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments(4);
- aPrimSegments->AddVertex (myFirstPoint);
- aPrimSegments->AddVertex (aFlyoutEnd1);
- aPrimSegments->AddVertex (mySecondPoint);
- aPrimSegments->AddVertex (aFlyoutEnd2);
-
- Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments);
- }
- drawLinearDimension (thePresentation, aFlyoutEnd1, aFlyoutEnd2, (AIS_DimensionDisplayMode)theMode);
+ drawLinearDimension (thePresentation, (AIS_DimensionDisplayMode)theMode);
}
//=======================================================================
//purpose :
//=======================================================================
-void AIS_LengthDimension::computeValue ()
+void AIS_LengthDimension::computeValue()
{
myValue = myFirstPoint.Distance (mySecondPoint);
AIS_Dimension::computeValue ();
{
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 TopoDS_Face& theFace,
const TopoDS_Edge& theEdge);
+public:
+
DEFINE_STANDARD_RTTI(AIS_LengthDimension)
+
private:
+
Standard_Boolean initTwoEdgesLength (const TopoDS_Edge & theFirstEdge,
- const TopoDS_Edge& theSecondEdge,
- gp_Dir& theDirAttach);
+ const TopoDS_Edge& theSecondEdge,
+ gp_Dir& theDirAttach);
+
//! Auxiliary method for <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);
+
//! Initialization of two attach points in case of two owner shapes
Standard_Boolean initTwoShapesPoints (const TopoDS_Shape& theFirstShape,
- const TopoDS_Shape& theSecondShape);
+ const TopoDS_Shape& theSecondShape);
+
//! Initialization of two attach points in case of one owner shape
Standard_Boolean initOneShapePoints (const TopoDS_Shape& theShape);
//! Compute length in display units.
- virtual void computeValue ();
+ virtual void computeValue();
virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode = 0) ;
-
};
#endif
// 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_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 <GC_MakeCircle.hxx>
-#include <gce_MakeCirc.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 <Precision.hxx>
#include <PrsMgr_PresentationManager3d.hxx>
-#include <Prs3d_DimensionAspect.hxx>
-#include <Prs3d_ArrowAspect.hxx>
-#include <Prs3d_Drawer.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)
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(),
SetSpecialSymbol ('R');
SetDisplaySpecialSymbol (AIS_DSS_Before);
SetKindOfDimension (AIS_KOD_RADIUS);
+ SetFlyout (0.0);
}
//=======================================================================
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);
}
//=======================================================================
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);
}
//=======================================================================
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,
- 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);
DEFINE_STANDARD_RTTI(AIS_RadiusDimension)
protected:
+
//! Computes dimension value in display units
Standard_EXPORT virtual void computeValue ();
+
//! Fills default plane object if it is possible to count plane automatically.
Standard_EXPORT virtual void countDefaultPlane ();
-private:
- virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
- const Handle(Prs3d_Presentation)& thePresentation,
- const Standard_Integer theMode = 0);
+private:
+
+ virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+ const Handle(Prs3d_Presentation)& thePresentation,
+ const Standard_Integer theMode = 0);
// Fields
+private:
gp_Circ myCircle;
};
-- 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
---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,
--- Purpose: Sets orientation of arrows (external or internal).
-- By default orientation is chosen automatically according to situation and text label size.
- GetArrowOrientation (me) returns DimensionArrowOrientation from Prs3d;
+ ArrowOrientation (me) returns DimensionArrowOrientation from Prs3d;
--- Purpose: Gets orientation of arrows (external or internal).
- SetVerticalTextAlignment(me: mutable; theVertTextAlignment: VerticalTextAlignment from Prs3d);
+ SetTextVerticalPosition (me: mutable; thePosition : DimensionTextVerticalPosition from Prs3d);
--- Purpose: Sets vertical text alignment for text label.
- VerticalTextAlignment (me) returns VerticalTextAlignment from Prs3d;
+ TextVerticalPosition (me) returns DimensionTextVerticalPosition from Prs3d;
--- Purpose: Gets vertical text alignment for text label.
- SetHorizontalTextAlignment (me: mutable; theHorTextAlignment: HorizontalTextAlignment from Prs3d);
+ SetTextHorizontalPosition (me: mutable; thePosition: DimensionTextHorizontalPosition from Prs3d);
--- Purpose: Sets horizontal text alignment for text label.
- HorizontalTextAlignment (me) returns HorizontalTextAlignment from Prs3d;
+ TextHorizontalPosition (me) returns DimensionTextHorizontalPosition from Prs3d;
--- Purpose: Gets horizontal text alignment for text label.
ArrowAspect(me) returns mutable ArrowAspect from Prs3d is static;
SetCommonColor(me:mutable; theColor: Color from Quantity) is static;
---Purpose: Sets the same color for all parts of dimension: lines, arrows and text.
+ SetExtensionSize (me : mutable; theSize : Real from Standard) is static;
+ ---Purpose: Sets extension size.
+
+ ExtensionSize (me) returns Real from Standard;
+ ---Purpose: Returns extension size.
+
fields
myLineAspect: LineAspect from Prs3d;
---Purpose: Text style. The size for 3d (or 2d) text is also inside here.
+
myTextAspect: TextAspect from Prs3d;
myArrowAspect : ArrowAspect from Prs3d;
myIsText3d : Boolean from Standard;
myIsTextShaded : Boolean from Standard;
myIsArrows3d: Boolean from Standard;
+
myArrowOrientation : DimensionArrowOrientation from Prs3d;
- ---Purpose: Dimension arrow orientation
+ ---Purpose: Dimension arrow orientation.
-- By default, it is computed automatically. Its value depends on the text
-- bouning rectangle size and distance between two flyouts.
- -- By default, it is internal one.
- myHorTextAlignment: HorizontalTextAlignment from Prs3d;
- ---Purpose:Horizontal text alignment (Prs3d_HTA_Left/Prs3d_HTA_Right/Prs3d_HTA_Center).
- -- Defines horizontal position of text value label, by default it is center.
- myVerTextAlignment: VerticalTextAlignment from Prs3d;
- ---Purpose: Vertical text alignment (Prs3d_VTA_Top, Prs3d_VTA_Bottom/Prs3d_VTA_Center)
- -- Defines vertical position of text value lable, by default it is center.
+ -- By default, it is "fit" one.
+
+ myTextHPosition : DimensionTextHorizontalPosition from Prs3d;
+ ---Purpose: Defines horizontal position of text value label, by default it is
+ -- "fit" - selected automatically depending on label-to-dimension size relation.
+
+ myTextVPosition : DimensionTextVerticalPosition from Prs3d;
+ ---Purpose: Defines vertical position of text value label, by default it is center.
+
+ myExtensionSize : Real from Standard;
+ ---Purpose: Size of arrow extensions.
+ -- The length of arrow tails if arrows are located outside dimension line.
+
end DimensionAspect from Prs3d;
#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 <Prs3d_LineAspect.hxx>
-#include <Prs3d_TextAspect.hxx>
-#include <Prs3d_ArrowAspect.hxx>
#include <Quantity_Color.hxx>
IMPLEMENT_STANDARD_HANDLE (Prs3d_DimensionAspect, Prs3d_BasicAspect)
//purpose :
//=======================================================================
-Prs3d_DimensionAspect::Prs3d_DimensionAspect ()
+Prs3d_DimensionAspect::Prs3d_DimensionAspect()
{
- // Text alignment
- myHorTextAlignment = Prs3d_HTA_Center;
- myVerTextAlignment = Prs3d_VTA_Center;
- // Arrow orientation, will be computed on further steps, by default it is internal.
- myArrowOrientation = Prs3d_DAO_Internal;
+ myTextHPosition = Prs3d_DTHP_Fit;
+ myTextVPosition = Prs3d_DTVP_Center;
+ myArrowOrientation = Prs3d_DAO_Fit;
+
myLineAspect = new Prs3d_LineAspect (Quantity_NOC_LAWNGREEN,Aspect_TOL_SOLID,1.);
myTextAspect = new Prs3d_TextAspect;
myTextAspect->Aspect()->SetTextZoomable (Standard_False);
myTextAspect->SetVerticalJustification (Graphic3d_VTA_CENTER);
myArrowAspect = new Prs3d_ArrowAspect;
myArrowAspect->SetColor (Quantity_NOC_LAWNGREEN);
- myArrowAspect->SetLength (6.);
+ myArrowAspect->SetLength (6.0);
+ myExtensionSize = 6.0;
}
//=======================================================================
//purpose :
//=======================================================================
-Prs3d_DimensionArrowOrientation Prs3d_DimensionAspect::GetArrowOrientation () const
+Prs3d_DimensionArrowOrientation Prs3d_DimensionAspect::ArrowOrientation() const
{
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 :
-//=======================================================================
+//=======================================================================
-Prs3d_HorizontalTextAlignment Prs3d_DimensionAspect::HorizontalTextAlignment () const
+void Prs3d_DimensionAspect::SetTextHorizontalPosition (const Prs3d_DimensionTextHorizontalPosition thePosition)
{
- return myHorTextAlignment;
+ myTextHPosition = thePosition;
}
-
+
//=======================================================================
-//function : SetHorizontalTextAlignment
+//function : TextHorizontalPosition
//purpose :
-//=======================================================================
+//=======================================================================
-void Prs3d_DimensionAspect::SetHorizontalTextAlignment (const Prs3d_HorizontalTextAlignment theHorTextAlignment)
+Prs3d_DimensionTextHorizontalPosition Prs3d_DimensionAspect::TextHorizontalPosition() const
{
- myHorTextAlignment = theHorTextAlignment;
+ return myTextHPosition;
}
//=======================================================================
{
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;
+}
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
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."
if { $stat != 1 } {
puts "Error : Highlighting of angle dimension with 2d text is wrong."
}
-verase dim1
+vinit Viewer2/View2
+vdisplay angleP1 angleP2 angleP3
vdim -angle -name=dim2 -text=3d angleP1 angleP2 angleP3
vdisplay dim2
vfit
vmoveto 263 251
-set x_coord 332
-set y_coord 326
+set x_coord 335
+set y_coord 319
checkcolor $x_coord $y_coord 0 1 1
vpoint radP3 100 0 0
vcircle circle radP1 radP2 radP3 0
verase radP1 radP2 radP3
-vdim -radius -name=dim3 circle
-vdisplay dim3
+vdim -radius -name=dim1 circle
+vdisplay dim1
vfit
-vmoveto 102 144
+vmoveto 123 158
-set x_coord 172
-set y_coord 186
+set x_coord 112
+set y_coord 151
checkcolor $x_coord $y_coord 0 1 1
puts "Error : Highlighting of radius dimension with 2d text is wrong."
}
-verase dim3
-vdim -radius -name=dim3 -text=3d circle
-vdisplay dim3
+vinit Viewer2/View2
+vdisplay circle
+vdim -radius -name=dim2 -text=3d circle
+vdisplay dim2
vfit
-vmoveto 102 144
+vmoveto 191 196
-set x_coord 172
-set y_coord 186
+set x_coord 129
+set y_coord 172
checkcolor $x_coord $y_coord 0 1 1
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
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
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 } {
# 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 } {
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 } {
# 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 } {
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 } {
# 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 } {