1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-21 10:13:43 +03:00

0024326: Get rid of confusing extension line

1) Removed confusing part of labeled extension for 3d text.
2) Removed unused "TextOffset" property of AIS_Dimension class, revised function of "ExtensionSize" property.
3) Added options to specify automatic or user-defined arrow orientation and value label positioning to dimension aspect enumerations.
4) Use proper naming: Prs3d_DimensionTextVerticalPosition, Prs3d_DimensionTextHorizontalPosition instead of Prs3d_HorizontalTextAlignment, Prs3d_VerticalTextAlignment.
Correction of label length computing method.
This commit is contained in:
apl 2013-11-21 17:27:33 +04:00 committed by bugmaster
parent 938d454409
commit d7bffd44ea
21 changed files with 1016 additions and 1188 deletions

View File

@ -21,107 +21,57 @@
#include <AIS_AngleDimension.hxx> #include <AIS_AngleDimension.hxx>
#include <AIS.hxx> #include <AIS.hxx>
#include <AIS_Dimension.hxx>
#include <AIS_DimensionOwner.hxx>
#include <AIS_Drawer.hxx> #include <AIS_Drawer.hxx>
#include <BRep_Tool.hxx>
#include <BRepBuilderAPI_MakeFace.hxx> #include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepAdaptor_Curve.hxx> #include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Surface.hxx> #include <BRepAdaptor_Surface.hxx>
#include <BRepLib_MakeVertex.hxx>
#include <DsgPrs.hxx>
#include <DsgPrs_AnglePresentation.hxx>
#include <ElCLib.hxx> #include <ElCLib.hxx>
#include <ElSLib.hxx>
#include <GC_MakeCircle.hxx>
#include <GC_MakeConicalSurface.hxx>
#include <gce_MakeLin.hxx>
#include <gce_MakeLin2d.hxx> #include <gce_MakeLin2d.hxx>
#include <gce_MakePln.hxx>
#include <gce_MakeCirc.hxx>
#include <gce_MakeCone.hxx> #include <gce_MakeCone.hxx>
#include <Geom2d_Circle.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2d_Line.hxx>
#include <Geom2dAPI_ExtremaCurveCurve.hxx>
#include <GeomAPI.hxx>
#include <Geom_Circle.hxx> #include <Geom_Circle.hxx>
#include <Geom_Line.hxx>
#include <Geom_Plane.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom_Surface.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_ConicalSurface.hxx> #include <Geom_ConicalSurface.hxx>
#include <Geom_SurfaceOfRevolution.hxx> #include <Geom_SurfaceOfRevolution.hxx>
#include <Geom_SurfaceOfLinearExtrusion.hxx>
#include <Geom_OffsetSurface.hxx> #include <Geom_OffsetSurface.hxx>
#include <GeomAPI_ExtremaCurveCurve.hxx>
#include <Graphic3d_ArrayOfSegments.hxx> #include <Graphic3d_ArrayOfSegments.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <gp.hxx>
#include <gp_Ax1.hxx>
#include <gp_Lin.hxx>
#include <gp_Cone.hxx>
#include <gp_Pln.hxx>
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Vec.hxx>
#include <gp_XYZ.hxx>
#include <Graphic3d_Group.hxx> #include <Graphic3d_Group.hxx>
#include <Graphic3d_ArrayOfPrimitives.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx> #include <Graphic3d_ArrayOfPolylines.hxx>
#include <IntAna2d_AnaIntersection.hxx> #include <IntAna2d_AnaIntersection.hxx>
#include <IntAna2d_IntPoint.hxx> #include <IntAna2d_IntPoint.hxx>
#include <IntAna_QuadQuadGeo.hxx>
#include <IntAna_ResultType.hxx> #include <IntAna_ResultType.hxx>
#include <Poly_Polygon3D.hxx>
#include <Precision.hxx>
#include <ProjLib.hxx> #include <ProjLib.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_DimensionAspect.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_Root.hxx> #include <Prs3d_Root.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <PrsMgr_PresentationManager3d.hxx> #include <PrsMgr_PresentationManager3d.hxx>
#include <Select3D_SensitiveCurve.hxx> #include <Select3D_SensitiveCurve.hxx>
#include <Select3D_SensitiveGroup.hxx> #include <Select3D_SensitiveGroup.hxx>
#include <Select3D_SensitiveSegment.hxx> #include <Select3D_SensitiveSegment.hxx>
#include <SelectMgr_Selection.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> #include <UnitsAPI.hxx>
IMPLEMENT_STANDARD_HANDLE (AIS_AngleDimension, AIS_Dimension) IMPLEMENT_STANDARD_HANDLE (AIS_AngleDimension, AIS_Dimension)
IMPLEMENT_STANDARD_RTTIEXT (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 //function : init
//purpose : Private constructor for default initialization //purpose : Private constructor for default initialization
//======================================================================= //=======================================================================
void AIS_AngleDimension::init() void AIS_AngleDimension::init()
{ {
SetKindOfDimension (AIS_KOD_PLANEANGLE);
SetFlyout (15.0);
// Default values of units // Default values of units
UnitsAPI::SetLocalSystem (UnitsAPI_SI); UnitsAPI::SetLocalSystem (UnitsAPI_SI);
SetUnitsQuantity ("PLANE ANGLE"); SetUnitsQuantity ("PLANE ANGLE");
SetModelUnits ("rad"); SetModelUnits ("rad");
SetDisplayUnits ("deg"); SetDisplayUnits ("deg");
SetSpecialSymbol (0x00B0); SetSpecialSymbol (THE_DEGREE_SYMBOL);
SetDisplaySpecialSymbol (AIS_DSS_After); SetDisplaySpecialSymbol (AIS_DSS_After);
SetFlyout (15.0);
SetKindOfDimension (AIS_KOD_PLANEANGLE);
MakeUnitsDisplayed (Standard_False); MakeUnitsDisplayed (Standard_False);
} }
@ -129,7 +79,6 @@ void AIS_AngleDimension::init()
//function : Constructor //function : Constructor
//purpose : Two edges dimension //purpose : Two edges dimension
//======================================================================= //=======================================================================
AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Edge& theFirstEdge, AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
const TopoDS_Edge& theSecondEdge) const TopoDS_Edge& theSecondEdge)
: AIS_Dimension(), : AIS_Dimension(),
@ -146,7 +95,6 @@ AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
//purpose : Two edges dimension //purpose : Two edges dimension
// <thePlane> is used in case of Angle=PI // <thePlane> is used in case of Angle=PI
//======================================================================= //=======================================================================
AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Edge& theFirstEdge, AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
const TopoDS_Edge& theSecondEdge, const TopoDS_Edge& theSecondEdge,
const gp_Pln& thePlane) const gp_Pln& thePlane)
@ -160,31 +108,10 @@ AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
SetWorkingPlane (thePlane); 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;
SetWorkingPlane (thePlane);
}
//======================================================================= //=======================================================================
//function : Constructor //function : Constructor
//purpose : Three points dimension //purpose : Three points dimension
//======================================================================= //=======================================================================
AIS_AngleDimension::AIS_AngleDimension (const gp_Pnt& theFirstPoint, AIS_AngleDimension::AIS_AngleDimension (const gp_Pnt& theFirstPoint,
const gp_Pnt& theSecondPoint, const gp_Pnt& theSecondPoint,
const gp_Pnt& theThirdPoint) const gp_Pnt& theThirdPoint)
@ -199,31 +126,10 @@ AIS_AngleDimension::AIS_AngleDimension (const gp_Pnt& theFirstPoint,
myShapesNumber = 3; 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;
}
//======================================================================= //=======================================================================
//function : Constructor //function : Constructor
//purpose : Cone dimension //purpose : Cone dimension
//======================================================================= //=======================================================================
AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Face& theCone) AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Face& theCone)
: AIS_Dimension(), : AIS_Dimension(),
myIsFlyoutLines (Standard_True) myIsFlyoutLines (Standard_True)
@ -238,7 +144,6 @@ AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Face& theCone)
//function : Constructor //function : Constructor
//purpose : Two faces dimension //purpose : Two faces dimension
//======================================================================= //=======================================================================
AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Face& theFirstFace, AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Face& theFirstFace,
const TopoDS_Face& theSecondFace, const TopoDS_Face& theSecondFace,
const gp_Ax1& theAxis) const gp_Ax1& theAxis)
@ -259,7 +164,6 @@ AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Face& theFirstFace,
//function : SetFirstShape //function : SetFirstShape
//purpose : //purpose :
//======================================================================= //=======================================================================
void AIS_AngleDimension::SetFirstShape (const TopoDS_Shape& theShape, void AIS_AngleDimension::SetFirstShape (const TopoDS_Shape& theShape,
const Standard_Boolean isSingleShape /*= Standard_False*/) const Standard_Boolean isSingleShape /*= Standard_False*/)
{ {
@ -275,7 +179,6 @@ void AIS_AngleDimension::SetFirstShape (const TopoDS_Shape& theShape,
// <theCMax> centers; // <theCMax> centers;
// -1 if <theC> center is below <theCMax> center. // -1 if <theC> center is below <theCMax> center.
//======================================================================= //=======================================================================
Standard_Integer AIS_AngleDimension::aboveInBelowCone (const gp_Circ &theCMax, Standard_Integer AIS_AngleDimension::aboveInBelowCone (const gp_Circ &theCMax,
const gp_Circ &theCMin, const gp_Circ &theCMin,
const gp_Circ &theC) const gp_Circ &theC)
@ -294,7 +197,6 @@ Standard_Integer AIS_AngleDimension::aboveInBelowCone (const gp_Circ &theCMax,
//function : initConeAngle //function : initConeAngle
//purpose : initialization of the cone angle //purpose : initialization of the cone angle
//======================================================================= //=======================================================================
Standard_Boolean AIS_AngleDimension::initConeAngle (const TopoDS_Face& theCone) Standard_Boolean AIS_AngleDimension::initConeAngle (const TopoDS_Face& theCone)
{ {
if (theCone.IsNull ()) if (theCone.IsNull ())
@ -397,7 +299,6 @@ Standard_Boolean AIS_AngleDimension::initConeAngle (const TopoDS_Face& theCone)
//function : initTwoFacesAngle //function : initTwoFacesAngle
//purpose : initialization of angle dimension between two faces //purpose : initialization of angle dimension between two faces
//======================================================================= //=======================================================================
Standard_Boolean AIS_AngleDimension::initTwoFacesAngle () Standard_Boolean AIS_AngleDimension::initTwoFacesAngle ()
{ {
TopoDS_Face aFirstFace = TopoDS::Face (myFirstShape); TopoDS_Face aFirstFace = TopoDS::Face (myFirstShape);
@ -458,7 +359,6 @@ Standard_Boolean AIS_AngleDimension::initTwoFacesAngle ()
//function : countDefaultPlane //function : countDefaultPlane
//purpose : //purpose :
//======================================================================= //=======================================================================
void AIS_AngleDimension::countDefaultPlane () void AIS_AngleDimension::countDefaultPlane ()
{ {
if (!myIsInitialized) if (!myIsInitialized)
@ -475,7 +375,6 @@ void AIS_AngleDimension::countDefaultPlane ()
//function : computeValue //function : computeValue
//purpose : //purpose :
//======================================================================= //=======================================================================
void AIS_AngleDimension::computeValue () void AIS_AngleDimension::computeValue ()
{ {
gp_Vec aVec1 (myCenter, myFirstPoint), gp_Vec aVec1 (myCenter, myFirstPoint),
@ -491,7 +390,6 @@ void AIS_AngleDimension::computeValue ()
// If intersection between two edges doesn't exist // If intersection between two edges doesn't exist
// <myIsInitialized> is set to false // <myIsInitialized> is set to false
//======================================================================= //=======================================================================
Standard_Boolean AIS_AngleDimension::initTwoEdgesAngle () Standard_Boolean AIS_AngleDimension::initTwoEdgesAngle ()
{ {
// Data initialization // Data initialization
@ -636,21 +534,6 @@ Standard_Boolean AIS_AngleDimension::initTwoEdgesAngle ()
return Standard_True; return Standard_True;
} }
//=======================================================================
//function : canTextBeInCenter
//purpose : Auxiliary method to arrange text and arrows
//=======================================================================
Standard_Boolean AIS_AngleDimension::canTextBeInCenter (const gp_Pnt& theFirstAttach,
const gp_Pnt& theSecondAttach,
const Quantity_Length& theTextLength,
const Quantity_Length& theArrowLength)
{
gp_Vec anAttachVector (theFirstAttach, theSecondAttach);
Standard_Real aValue = anAttachVector.Magnitude();
return (aValue < theTextLength + 2.*theArrowLength) ? Standard_False : Standard_True;
}
//======================================================================= //=======================================================================
//function: getCenterOnArc //function: getCenterOnArc
//purpose : //purpose :
@ -685,12 +568,12 @@ gp_Pnt AIS_AngleDimension::getCenterOnArc (const gp_Pnt& theFirstAttach,
//function: drawArcWithText //function: drawArcWithText
//purpose : //purpose :
//======================================================================= //=======================================================================
void AIS_AngleDimension::drawArcWithText (const Handle(Prs3d_Presentation)& thePresentation, void AIS_AngleDimension::drawArcWithText (const Handle(Prs3d_Presentation)& thePresentation,
const gp_Pnt& theFirstAttach, const gp_Pnt& theFirstAttach,
const gp_Pnt& theSecondAttach, const gp_Pnt& theSecondAttach,
const TCollection_ExtendedString& theText, const TCollection_ExtendedString& theText,
const AIS_DimensionDisplayMode theMode) const AIS_DimensionDisplayMode theMode,
const Standard_Integer theLabelPosition)
{ {
gp_Pnt2d aCenter2d = ProjLib::Project (GetWorkingPlane(), myCenter), gp_Pnt2d aCenter2d = ProjLib::Project (GetWorkingPlane(), myCenter),
aFirstAttach2d = ProjLib::Project (GetWorkingPlane(), theFirstAttach), aFirstAttach2d = ProjLib::Project (GetWorkingPlane(), theFirstAttach),
@ -717,7 +600,8 @@ void AIS_AngleDimension::drawArcWithText (const Handle(Prs3d_Presentation)& theP
gp_Vec aVec (theFirstAttach, theSecondAttach); gp_Vec aVec (theFirstAttach, theSecondAttach);
Standard_Real aTextWidth = drawText (thePresentation, Standard_Real aTextWidth = drawText (thePresentation,
myIsTextReversed ? aVec.Reversed() : aVec, myIsTextReversed ? aVec.Reversed() : aVec,
theText,theMode); theText, theMode,
theLabelPosition);
// Getting text begin and end points // Getting text begin and end points
gp_Pnt2d aTextBeginPnt = ElCLib::Value ((ElCLib::Parameter (anAttachLine2d, aFirstAttach2d) + gp_Pnt2d aTextBeginPnt = ElCLib::Value ((ElCLib::Parameter (anAttachLine2d, aFirstAttach2d) +
@ -750,14 +634,12 @@ void AIS_AngleDimension::drawArcWithText (const Handle(Prs3d_Presentation)& theP
drawArc (thePresentation, theFirstAttach, aTextBeginOnArc, myCenter, aRadius, theMode); drawArc (thePresentation, theFirstAttach, aTextBeginOnArc, myCenter, aRadius, theMode);
drawArc (thePresentation, aTextEndOnArc, theSecondAttach, myCenter, aRadius, theMode); drawArc (thePresentation, aTextEndOnArc, theSecondAttach, myCenter, aRadius, theMode);
} }
} }
//======================================================================= //=======================================================================
//function : drawArc //function : drawArc
//purpose : draws the arc between two attach points //purpose : draws the arc between two attach points
//======================================================================= //=======================================================================
void AIS_AngleDimension::drawArc (const Handle(Prs3d_Presentation)& thePresentation, void AIS_AngleDimension::drawArc (const Handle(Prs3d_Presentation)& thePresentation,
const gp_Pnt& theFirstAttach, const gp_Pnt& theFirstAttach,
const gp_Pnt& theSecondAttach, const gp_Pnt& theSecondAttach,
@ -766,8 +648,6 @@ void AIS_AngleDimension::drawArc (const Handle(Prs3d_Presentation)& thePresentat
const AIS_DimensionDisplayMode theMode) const AIS_DimensionDisplayMode theMode)
{ {
Handle(SelectMgr_EntityOwner) anEmptyOwner; Handle(SelectMgr_EntityOwner) anEmptyOwner;
Prs3d_Root::CurrentGroup (thePresentation)->
SetPrimitivesAspect(myDrawer->DimensionAspect()->LineAspect()->Aspect());
gp_Vec aCenterToFirstVec (theCenter,theFirstAttach); gp_Vec aCenterToFirstVec (theCenter,theFirstAttach);
gp_Vec aCenterToSecondVec (theCenter,theSecondAttach); gp_Vec aCenterToSecondVec (theCenter,theSecondAttach);
@ -803,6 +683,8 @@ void AIS_AngleDimension::drawArc (const Handle(Prs3d_Presentation)& thePresentat
{ {
Prs3d_Root::CurrentGroup (thePresentation)->SetStencilTestOptions (Standard_True); Prs3d_Root::CurrentGroup (thePresentation)->SetStencilTestOptions (Standard_True);
} }
Handle(Graphic3d_AspectLine3d) aDimensionLineStyle = myDrawer->DimensionAspect()->LineAspect()->Aspect();
Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionLineStyle);
Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments); Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments);
if (!myDrawer->DimensionAspect()->IsText3d() && theMode == AIS_DDM_All) if (!myDrawer->DimensionAspect()->IsText3d() && theMode == AIS_DDM_All)
{ {
@ -814,7 +696,6 @@ void AIS_AngleDimension::drawArc (const Handle(Prs3d_Presentation)& thePresentat
//function : Compute //function : Compute
//purpose : Having three gp_Pnt points compute presentation //purpose : Having three gp_Pnt points compute presentation
//======================================================================= //=======================================================================
void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePM*/, void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePM*/,
const Handle(Prs3d_Presentation)& thePresentation, const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode) const Standard_Integer theMode)
@ -857,139 +738,234 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*
// Parameters for presentation // Parameters for presentation
Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect(); Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
Prs3d_Root::CurrentGroup(thePresentation)->
SetPrimitivesAspect(aDimensionAspect->LineAspect()->Aspect()); Prs3d_Root::CurrentGroup(thePresentation)->SetPrimitivesAspect(aDimensionAspect->LineAspect()->Aspect());
Quantity_Length anArrowLength = aDimensionAspect->ArrowAspect()->Length(); Quantity_Length anArrowLength = aDimensionAspect->ArrowAspect()->Length();
if (!myIsValueCustom) if (!myIsValueCustom)
computeValue (); {
computeValue();
}
TCollection_ExtendedString aValueString; TCollection_ExtendedString aValueString;
Standard_Real aTextLength; Standard_Real aTextLength;
getTextWidthAndString (aTextLength, aValueString); getTextWidthAndString (aTextLength, aValueString);
if (!myIsWorkingPlaneCustom) if (!myIsWorkingPlaneCustom)
{
countDefaultPlane(); countDefaultPlane();
}
gp_Pnt aFirstAttach = myCenter.Translated (gp_Vec(myCenter, myFirstPoint).Normalized() * GetFlyout()); gp_Pnt aFirstAttach = myCenter.Translated (gp_Vec(myCenter, myFirstPoint).Normalized() * GetFlyout());
gp_Pnt aSecondAttach = myCenter.Translated (gp_Vec(myCenter, mySecondPoint).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())
{ {
aDimensionAspect->SetArrowOrientation (Prs3d_DAO_External); case Prs3d_DAO_External: isArrowsExternal = true; break;
aDimensionAspect->SetHorizontalTextAlignment (Prs3d_HTA_Left); case Prs3d_DAO_Internal: isArrowsExternal = false; break;
case Prs3d_DAO_Fit:
{
gp_Vec anAttachVector (aFirstAttach, aSecondAttach);
Standard_Real aDimensionWidth = anAttachVector.Magnitude();
Standard_Real anArrowsWidth = anArrowLength * 2.0;
isArrowsExternal = aDimensionWidth < aTextLength + anArrowsWidth;
break;
} }
} }
else
aDimensionAspect->SetArrowOrientation (Prs3d_DAO_External);
//Arrows positions and directions //Arrows positions and directions
gp_Vec aFirstArrowVec = (gp_Vec(myCenter, aFirstAttach)^gp_Vec(GetWorkingPlane().Axis().Direction())).Normalized().Reversed()*anArrowLength; gp_Vec aWPDir = gp_Vec (GetWorkingPlane().Axis().Direction());
gp_Vec aSecondArrowVec = (gp_Vec(myCenter, aSecondAttach)^gp_Vec(GetWorkingPlane().Axis().Direction())).Normalized()*anArrowLength;
gp_Pnt aFirstArrowBegin, gp_Dir aFirstExtensionDir = gp_Vec (myCenter, aFirstAttach) ^ aWPDir;
aFirstArrowEnd, gp_Dir aSecondExtensionDir = gp_Vec (myCenter, aSecondAttach)^ aWPDir.Reversed();
aSecondArrowBegin,
aSecondArrowEnd;
if (aDimensionAspect->GetArrowOrientation() == Prs3d_DAO_External) gp_Vec aFirstArrowVec = gp_Vec (aFirstExtensionDir) * anArrowLength;
gp_Vec aSecondArrowVec = gp_Vec (aSecondExtensionDir) * anArrowLength;
gp_Pnt aFirstArrowBegin (0.0, 0.0, 0.0);
gp_Pnt aFirstArrowEnd (0.0, 0.0, 0.0);
gp_Pnt aSecondArrowBegin (0.0, 0.0, 0.0);
gp_Pnt aSecondArrowEnd (0.0, 0.0, 0.0);
if (isArrowsExternal)
{ {
aFirstArrowVec.Reverse(); aFirstArrowVec.Reverse();
aSecondArrowVec.Reverse(); aSecondArrowVec.Reverse();
aFirstArrowBegin = aFirstAttach.Translated (aFirstArrowVec);
aFirstArrowEnd = aFirstAttach;
aSecondArrowBegin = aSecondAttach;
aSecondArrowEnd = aSecondAttach.Translated (aSecondArrowVec);
} }
else
{
aFirstArrowBegin = aFirstAttach; aFirstArrowBegin = aFirstAttach;
aFirstArrowEnd = aFirstAttach.Translated (aFirstArrowVec); aSecondArrowBegin = aSecondAttach;
aSecondArrowBegin = aSecondAttach.Translated (aSecondArrowVec); aFirstArrowEnd = aFirstAttach.Translated (-aFirstArrowVec);
aSecondArrowEnd = aSecondAttach; 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;
aLabelPosition |= aDimensionWidth < aContentWidth ? LabelPosition_Left : LabelPosition_HCenter;
break;
}
} }
// Fill presentation switch (aDimensionAspect->TextVerticalPosition())
Handle(Graphic3d_ArrayOfSegments) aPrimSegments;
Standard_Boolean isTextInCenter = aDimensionAspect->VerticalTextAlignment() == Prs3d_VTA_Center;
if (aDimensionAspect->HorizontalTextAlignment() == Prs3d_HTA_Center)
{ {
// Important! Current implementation doesn't draw the extensions here case Prs3d_DTVP_Above : aLabelPosition |= LabelPosition_Above; break;
aPrimSegments = new Graphic3d_ArrayOfSegments (4); case Prs3d_DTVP_Below : aLabelPosition |= LabelPosition_Below; break;
// Get text begin and end positions (text is positioned in the center between two attach points) case Prs3d_DTVP_Center : aLabelPosition |= LabelPosition_VCenter; break;
gp_Pnt aTextBeginOnArc, aTextEndOnArc, anArcCenter;
if (isTextInCenter && aDimensionAspect->IsText3d())
{
drawArcWithText (thePresentation, aFirstAttach, aSecondAttach, aValueString, (AIS_DimensionDisplayMode)theMode);
} }
else
// Group1: stenciling text and the angle dimension arc
Prs3d_Root::NewGroup (thePresentation);
Standard_Real anExtensionSize = aDimensionAspect->ExtensionSize();
Standard_Integer aHPosition = aLabelPosition & LabelPosition_HMask;
// draw text label
switch (aHPosition)
{ {
case LabelPosition_HCenter :
{
Standard_Boolean isLineBreak = aDimensionAspect->TextVerticalPosition() == Prs3d_DTVP_Center
&& aDimensionAspect->IsText3d();
if (isLineBreak)
{
drawArcWithText (thePresentation,
aFirstAttach,
aSecondAttach,
aValueString,
(AIS_DimensionDisplayMode)theMode,
aLabelPosition);
break;
}
gp_Vec aTextDir (aFirstArrowEnd, aSecondArrowBegin); gp_Vec aTextDir (aFirstArrowEnd, aSecondArrowBegin);
myGeom.myTextPosition = getCenterOnArc (aFirstArrowEnd, aSecondArrowBegin); myGeom.myTextPosition = getCenterOnArc (aFirstArrowEnd, aSecondArrowBegin);
drawText (thePresentation, drawText (thePresentation,
myIsTextReversed ? aTextDir.Reversed() : aTextDir, myIsTextReversed ? aTextDir.Reversed() : aTextDir,
aValueString, (AIS_DimensionDisplayMode)theMode); aValueString,
(AIS_DimensionDisplayMode)theMode,
aLabelPosition);
if (theMode == AIS_DDM_Text)
{
break;
}
drawArc (thePresentation,
isArrowsExternal ? aFirstAttach : aFirstArrowEnd,
isArrowsExternal ? aSecondAttach : aSecondArrowEnd,
myCenter,
Abs (GetFlyout()),
(AIS_DimensionDisplayMode)theMode);
}
break;
case LabelPosition_Left :
{
drawExtension (thePresentation,
anExtensionSize,
isArrowsExternal ? aFirstArrowEnd : aFirstAttach,
aFirstExtensionDir,
aValueString,
(AIS_DimensionDisplayMode)theMode,
aLabelPosition);
}
break;
case LabelPosition_Right :
{
drawExtension (thePresentation,
anExtensionSize,
isArrowsExternal ? aSecondArrowEnd : aSecondAttach,
aSecondExtensionDir,
aValueString,
(AIS_DimensionDisplayMode)theMode,
aLabelPosition);
}
break;
}
// 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);
}
// arrows and arrow extensions
if (theMode != AIS_DDM_Text) if (theMode != AIS_DDM_Text)
drawArc (thePresentation, aFirstArrowEnd, aSecondArrowBegin, myCenter, Abs (GetFlyout()), (AIS_DimensionDisplayMode)theMode);
}
}
else
{ {
// Lines for extensions Prs3d_Root::NewGroup (thePresentation);
gp_Lin aLeftExtension (aFirstAttach,gp_Dir(aFirstArrowVec));
gp_Lin aRightExtension (aSecondAttach, gp_Dir(aSecondArrowVec)); drawArrow (thePresentation, aFirstArrowBegin, gp_Dir (aFirstArrowVec));
aPrimSegments = new Graphic3d_ArrayOfSegments (6); drawArrow (thePresentation, aSecondArrowBegin, gp_Dir (aSecondArrowVec));
gp_Pnt aStartPoint; }
if (aDimensionAspect->HorizontalTextAlignment() == Prs3d_HTA_Left)
if (theMode != AIS_DDM_Text && isArrowsExternal)
{ {
aStartPoint = aFirstArrowBegin; Prs3d_Root::NewGroup (thePresentation);
// Short extension
aPrimSegments->AddVertex (aSecondArrowEnd); if (aHPosition != LabelPosition_Left)
aPrimSegments->AddVertex (aSecondArrowEnd.Translated(gp_Vec(aRightExtension.Direction())*anArrowLength)); {
myGeom.mySensitiveSegments.Append (new Select3D_SensitiveSegment(anEmptyOwner, drawExtension (thePresentation,
anExtensionSize,
aFirstArrowEnd,
aFirstExtensionDir,
THE_EMPTY_LABEL,
(AIS_DimensionDisplayMode)theMode,
LabelPosition_None);
}
if (aHPosition != LabelPosition_Right)
{
drawExtension (thePresentation,
anExtensionSize,
aSecondArrowEnd, aSecondArrowEnd,
aSecondArrowEnd.Translated(gp_Vec(aRightExtension.Direction())*anArrowLength))); aSecondExtensionDir,
THE_EMPTY_LABEL,
// Long extension (AIS_DimensionDisplayMode)theMode,
drawExtensionWithText (thePresentation, aStartPoint, aLeftExtension, aValueString, (AIS_DimensionDisplayMode)theMode); LabelPosition_None);
}
else // Prs3d_HTA_Right
{
aStartPoint = aSecondArrowEnd;
// Short extension
aPrimSegments->AddVertex (aFirstArrowBegin);
aPrimSegments->AddVertex (aFirstArrowBegin.Translated (gp_Vec (aLeftExtension.Direction()) * anArrowLength));
myGeom.mySensitiveSegments.Append (new Select3D_SensitiveSegment(anEmptyOwner,
aFirstArrowBegin,
aFirstArrowBegin.Translated (gp_Vec (aLeftExtension.Direction()) * anArrowLength)));
// Long extension
drawExtensionWithText (thePresentation, aStartPoint, aRightExtension, aValueString, (AIS_DimensionDisplayMode)theMode);
}
if (theMode != AIS_DDM_Text)
{
// Draw main arc
drawArc (thePresentation, aFirstArrowEnd, aSecondArrowBegin, myCenter, Abs(GetFlyout ()), (AIS_DimensionDisplayMode)theMode);
} }
} }
// Draw flyout lines and arrows in new group. // flyouts
Prs3d_Root::NewGroup (thePresentation)
->SetPrimitivesAspect (myDrawer->DimensionAspect()->LineAspect()->Aspect());
if (theMode == AIS_DDM_All && myIsFlyoutLines) if (theMode == AIS_DDM_All && myIsFlyoutLines)
{ {
Prs3d_Root::NewGroup (thePresentation);
Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (4);
aPrimSegments->AddVertex (myCenter); aPrimSegments->AddVertex (myCenter);
aPrimSegments->AddVertex (aFirstAttach); aPrimSegments->AddVertex (aFirstAttach);
aPrimSegments->AddVertex (myCenter); aPrimSegments->AddVertex (myCenter);
aPrimSegments->AddVertex (aSecondAttach); aPrimSegments->AddVertex (aSecondAttach);
}
if (theMode != AIS_DDM_Text) Handle(Graphic3d_AspectLine3d) aFlyoutStyle = myDrawer->DimensionAspect()->LineAspect()->Aspect();
{ Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aFlyoutStyle);
Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments); Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments);
drawArrow (thePresentation, aFirstAttach, gp_Dir (aFirstArrowVec));
drawArrow (thePresentation, aSecondAttach, gp_Dir (aSecondArrowVec));
} }
setComputed (Standard_True); setComputed (Standard_True);
@ -999,12 +975,13 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*
//function : computeFlyoutSelection //function : computeFlyoutSelection
//purpose : computes selection for flyouts //purpose : computes selection for flyouts
//======================================================================= //=======================================================================
void AIS_AngleDimension::computeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection, void AIS_AngleDimension::computeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
const Handle(AIS_DimensionOwner)& theOwner) const Handle(AIS_DimensionOwner)& theOwner)
{ {
if (!myIsFlyoutLines) if (!myIsFlyoutLines)
{
return; return;
}
gp_Pnt aFirstAttach = myCenter.Translated (gp_Vec (myCenter, myFirstPoint).Normalized() * GetFlyout()); gp_Pnt aFirstAttach = myCenter.Translated (gp_Vec (myCenter, myFirstPoint).Normalized() * GetFlyout());
gp_Pnt aSecondAttach = myCenter.Translated (gp_Vec (myCenter, mySecondPoint).Normalized() * GetFlyout()); gp_Pnt aSecondAttach = myCenter.Translated (gp_Vec (myCenter, mySecondPoint).Normalized() * GetFlyout());

View File

@ -48,6 +48,7 @@ DEFINE_STANDARD_HANDLE (AIS_AngleDimension, AIS_Dimension)
class AIS_AngleDimension : public AIS_Dimension class AIS_AngleDimension : public AIS_Dimension
{ {
public: public:
//! Constructs angle dimension between two edges //! Constructs angle dimension between two edges
//! with automatic working plane computing //! with automatic working plane computing
//! if it is possible. In case of PI angle please //! if it is possible. In case of PI angle please
@ -64,27 +65,11 @@ public:
const TopoDS_Edge& theSecondEdge, const TopoDS_Edge& theSecondEdge,
const gp_Pln& thePlane); 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. //! Constructs the angle display object defined by three points.
Standard_EXPORT AIS_AngleDimension (const gp_Pnt& theFirstPoint, Standard_EXPORT AIS_AngleDimension (const gp_Pnt& theFirstPoint,
const gp_Pnt& theSecondPoint, const gp_Pnt& theSecondPoint,
const gp_Pnt& theThirdPoint); 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 //! Angle of cone
Standard_EXPORT AIS_AngleDimension (const TopoDS_Face& theCone); Standard_EXPORT AIS_AngleDimension (const TopoDS_Face& theCone);
@ -97,7 +82,9 @@ public:
Standard_EXPORT void SetFirstShape (const TopoDS_Shape& theShape, Standard_EXPORT void SetFirstShape (const TopoDS_Shape& theShape,
const Standard_Boolean isSingleShape = Standard_False); const Standard_Boolean isSingleShape = Standard_False);
DEFINE_STANDARD_RTTI(AIS_AngleDimension) public:
DEFINE_STANDARD_RTTI (AIS_AngleDimension)
protected: protected:
@ -120,7 +107,8 @@ protected:
const gp_Pnt& theFirstAttach, const gp_Pnt& theFirstAttach,
const gp_Pnt& theSecondAttach, const gp_Pnt& theSecondAttach,
const TCollection_ExtendedString& theText, 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, Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePM,
const Handle(Prs3d_Presentation)& thePresentation, const Handle(Prs3d_Presentation)& thePresentation,
@ -141,12 +129,6 @@ protected:
const gp_Circ &theCMin, const gp_Circ &theCMin,
const gp_Circ &theC); 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. //! Fills default plane object if it is possible to count plane automatically.
Standard_EXPORT virtual void countDefaultPlane (); Standard_EXPORT virtual void countDefaultPlane ();

View File

@ -18,52 +18,24 @@
// purpose or non-infringement. Please see the License for the specific terms // purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License. // and conditions governing the rights and limitations under the License.
// Modified Mon 12-january-98
// <ODL>, <SZY>
#define BUC60915 //GG 05/06/01 Enable to compute the requested arrow size
// if any in all dimensions.
#include <AIS_DiameterDimension.hxx> #include <AIS_DiameterDimension.hxx>
#include <Adaptor3d_HCurve.hxx>
#include <AIS.hxx> #include <AIS.hxx>
#include <AIS_Drawer.hxx> #include <AIS_Drawer.hxx>
#include <AIS_DimensionOwner.hxx>
#include <DsgPrs_DiameterPresentation.hxx>
#include <DsgPrs_RadiusPresentation.hxx>
#include <ElCLib.hxx> #include <ElCLib.hxx>
#include <ElSLib.hxx>
#include <GC_MakeCircle.hxx>
#include <gce_MakeDir.hxx> #include <gce_MakeDir.hxx>
#include <Geom_Plane.hxx>
#include <gp_Pln.hxx>
#include <gp_Pnt.hxx>
#include <gp_Lin.hxx>
#include <gp_Ax1.hxx>
#include <gp_Dir.hxx>
#include <gp_Vec.hxx>
#include <Graphic3d_ArrayOfSegments.hxx> #include <Graphic3d_ArrayOfSegments.hxx>
#include <Graphic3d_Group.hxx> #include <Graphic3d_Group.hxx>
#include <PrsMgr_PresentationManager3d.hxx> #include <PrsMgr_PresentationManager3d.hxx>
#include <Prs3d_DimensionAspect.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_TextAspect.hxx>
#include <Prs3d_Text.hxx>
#include <Prs3d_Root.hxx> #include <Prs3d_Root.hxx>
#include <Precision.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <Select3D_SensitiveBox.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <Standard_Macro.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TCollection_ExtendedString.hxx>
IMPLEMENT_STANDARD_HANDLE(AIS_DiameterDimension, AIS_Dimension) IMPLEMENT_STANDARD_HANDLE(AIS_DiameterDimension, AIS_Dimension)
IMPLEMENT_STANDARD_RTTIEXT(AIS_DiameterDimension, AIS_Dimension) IMPLEMENT_STANDARD_RTTIEXT(AIS_DiameterDimension, AIS_Dimension)
namespace
{
static const Standard_ExtCharacter THE_DIAMETER_SYMBOL (0x00D8);
};
//======================================================================= //=======================================================================
//function : Constructor //function : Constructor
//purpose : //purpose :
@ -75,8 +47,9 @@ AIS_DiameterDimension::AIS_DiameterDimension(const gp_Circ& theCircle)
{ {
SetKindOfDimension(AIS_KOD_DIAMETER); SetKindOfDimension(AIS_KOD_DIAMETER);
myIsInitialized = Standard_True; myIsInitialized = Standard_True;
SetSpecialSymbol (0x00D8); SetSpecialSymbol (THE_DIAMETER_SYMBOL);
SetDisplaySpecialSymbol (AIS_DSS_Before); SetDisplaySpecialSymbol (AIS_DSS_Before);
SetFlyout (0.0);
// Count attach points // Count attach points
myFirstPoint = ElCLib::Value (0, myCircle); myFirstPoint = ElCLib::Value (0, myCircle);
mySecondPoint = myFirstPoint.Translated (gp_Vec(myFirstPoint, theCircle.Location())*2); mySecondPoint = myFirstPoint.Translated (gp_Vec(myFirstPoint, theCircle.Location())*2);
@ -91,9 +64,10 @@ AIS_DiameterDimension::AIS_DiameterDimension(const gp_Circ& theCircle, const gp_
: AIS_Dimension(), : AIS_Dimension(),
myCircle (theCircle) myCircle (theCircle)
{ {
SetKindOfDimension(AIS_KOD_DIAMETER); SetKindOfDimension (AIS_KOD_DIAMETER);
SetSpecialSymbol (0x00D8); SetSpecialSymbol (THE_DIAMETER_SYMBOL);
SetDisplaySpecialSymbol (AIS_DSS_Before); SetDisplaySpecialSymbol (AIS_DSS_Before);
SetFlyout (0.0);
myFirstPoint = theAttachPoint; myFirstPoint = theAttachPoint;
// Count the second point // Count the second point
if (Abs(myFirstPoint.Distance (theCircle.Location()) - theCircle.Radius()) < Precision::Confusion()) if (Abs(myFirstPoint.Distance (theCircle.Location()) - theCircle.Radius()) < Precision::Confusion())
@ -108,24 +82,6 @@ AIS_DiameterDimension::AIS_DiameterDimension(const gp_Circ& theCircle, const gp_
myIsInitialized = Standard_True; myIsInitialized = Standard_True;
} }
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
AIS_DiameterDimension::AIS_DiameterDimension (const gp_Circ& theCircle,
const Handle(Prs3d_DimensionAspect)& theDimensionStyle,
const Standard_Real theExtensionSize /*= 1.0*/)
: AIS_Dimension (theExtensionSize),
myCircle (theCircle)
{
SetKindOfDimension(AIS_KOD_DIAMETER);
SetSpecialSymbol (0x00D8);
SetDisplaySpecialSymbol(AIS_DSS_Before);
myDrawer->SetDimensionAspect(theDimensionStyle);
myIsInitialized = Standard_True;
}
//======================================================================= //=======================================================================
//function : Constructor //function : Constructor
//purpose : Universal constructor for diameter dimension of shape //purpose : Universal constructor for diameter dimension of shape
@ -134,9 +90,10 @@ AIS_DiameterDimension::AIS_DiameterDimension (const gp_Circ& theCircle,
AIS_DiameterDimension::AIS_DiameterDimension (const TopoDS_Shape& theShape) AIS_DiameterDimension::AIS_DiameterDimension (const TopoDS_Shape& theShape)
: AIS_Dimension () : AIS_Dimension ()
{ {
SetKindOfDimension(AIS_KOD_DIAMETER); SetKindOfDimension (AIS_KOD_DIAMETER);
SetSpecialSymbol (0x00D8); SetSpecialSymbol (THE_DIAMETER_SYMBOL);
SetDisplaySpecialSymbol(AIS_DSS_Before); SetDisplaySpecialSymbol (AIS_DSS_Before);
SetFlyout (0.0);
myFirstShape = theShape; myFirstShape = theShape;
myIsInitialized = Standard_False; myIsInitialized = Standard_False;
} }
@ -163,38 +120,13 @@ void AIS_DiameterDimension::Compute (const Handle(PrsMgr_PresentationManager3d)&
else else
myIsInitialized = Standard_True; myIsInitialized = Standard_True;
} }
if (!myIsWorkingPlaneCustom) if (!myIsWorkingPlaneCustom)
countDefaultPlane();
//Count flyout direction
gp_Ax1 aWorkingPlaneNormal = GetWorkingPlane().Axis();
gp_Dir aTargetPointsVector = gce_MakeDir (myFirstPoint, mySecondPoint);
// Count a flyout direction vector.
gp_Dir aFlyoutVector = aWorkingPlaneNormal.Direction()^aTargetPointsVector;
// Create lines for layouts
gp_Lin aLine1 (myFirstPoint, aFlyoutVector);
gp_Lin aLine2 (mySecondPoint, aFlyoutVector);
// Get flyout end points
gp_Pnt aFlyoutEnd1 = ElCLib::Value (ElCLib::Parameter (aLine1, myFirstPoint) + GetFlyout(), aLine1);
gp_Pnt aFlyoutEnd2 = ElCLib::Value (ElCLib::Parameter (aLine2, mySecondPoint) + GetFlyout(), aLine2);
// Add layout lines to graphic group
// Common to all type of dimension placement.
if (theMode == 0)
{ {
Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments(4); countDefaultPlane();
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);
} }
//======================================================================= //=======================================================================

View File

@ -47,19 +47,16 @@ public:
Standard_EXPORT AIS_DiameterDimension (const gp_Circ& theCircle, Standard_EXPORT AIS_DiameterDimension (const gp_Circ& theCircle,
const gp_Pnt& theAttachPoint); 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); Standard_EXPORT AIS_DiameterDimension (const TopoDS_Shape& theShape);
DEFINE_STANDARD_RTTI(AIS_DiameterDimension) DEFINE_STANDARD_RTTI(AIS_DiameterDimension)
protected: protected:
Standard_EXPORT virtual void computeValue (); Standard_EXPORT virtual void computeValue();
//! Fills default plane object if it is possible to count plane automatically. //! Fills default plane object if it is possible to count plane automatically.
Standard_EXPORT virtual void countDefaultPlane (); Standard_EXPORT virtual void countDefaultPlane();
private: private:
@ -68,6 +65,7 @@ private:
const Standard_Integer theMode = 0); const Standard_Integer theMode = 0);
// Fields // Fields
private:
gp_Circ myCircle; gp_Circ myCircle;
}; };

File diff suppressed because it is too large Load Diff

View File

@ -34,7 +34,6 @@
#include <Prs3d_LineAspect.hxx> #include <Prs3d_LineAspect.hxx>
#include <Prs3d_Presentation.hxx> #include <Prs3d_Presentation.hxx>
#include <Prs3d_TextAspect.hxx> #include <Prs3d_TextAspect.hxx>
#include <Prs3d_VerticalTextAlignment.hxx>
#include <Select3D_ListOfSensitive.hxx> #include <Select3D_ListOfSensitive.hxx>
#include <SelectMgr_EntityOwner.hxx> #include <SelectMgr_EntityOwner.hxx>
#include <Standard.hxx> #include <Standard.hxx>
@ -47,14 +46,32 @@ DEFINE_STANDARD_HANDLE(AIS_Dimension, AIS_InteractiveObject)
class AIS_Dimension : public AIS_InteractiveObject class AIS_Dimension : public AIS_InteractiveObject
{ {
protected:
// Specifies supported at base level horizontal and vertical
// label positions for drawing extension lines and centered text.
enum LabelPosition
{
LabelPosition_None = 0x00,
LabelPosition_Left = 0x01,
LabelPosition_Right = 0x02,
LabelPosition_HCenter = 0x04,
LabelPosition_HMask = LabelPosition_Left | LabelPosition_Right | LabelPosition_HCenter,
LabelPosition_Above = 0x10,
LabelPosition_Below = 0x20,
LabelPosition_VCenter = 0x40,
LabelPosition_VMask = LabelPosition_Above | LabelPosition_Below | LabelPosition_VCenter
};
public: public:
//! Constructor with default parameters values //! Constructor with default parameters values
Standard_EXPORT AIS_Dimension (const Standard_Real theExtensionSize = 1.0); Standard_EXPORT AIS_Dimension();
//! Constructor to set aspect of dimension
Standard_EXPORT AIS_Dimension (const Handle(Prs3d_DimensionAspect)& theAspect,
const Standard_Real theExtensionSize = 1.0);
//! Gets dimension value //! Gets dimension value
Standard_EXPORT Standard_Real GetValue () const; Standard_EXPORT Standard_Real GetValue() const;
//! Sets dimension value //! Sets dimension value
//! Attention! This method is used ONLY to set custom value. //! Attention! This method is used ONLY to set custom value.
@ -67,12 +84,6 @@ public:
//! Sets working plane. //! Sets working plane.
Standard_EXPORT void SetWorkingPlane (const gp_Pln& thePlane); 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 SetFirstPoint (const gp_Pnt& thePoint);
Standard_EXPORT void SetSecondPoint (const gp_Pnt& thePoint); Standard_EXPORT void SetSecondPoint (const gp_Pnt& thePoint);
@ -101,71 +112,91 @@ public:
//! The interactive context can have a default mode of //! The interactive context can have a default mode of
//! representation for the set of Interactive Objects. This //! representation for the set of Interactive Objects. This
//! mode may not be accepted by object //! 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 // Selection computing if it is needed here
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode); const Standard_Integer theMode);
//! Reset working plane to default. //! Reset working plane to default.
Standard_EXPORT void ResetWorkingPlane(); Standard_EXPORT void ResetWorkingPlane();
//! specifies dimension special symbol display options //! specifies dimension special symbol display options
Standard_EXPORT void SetDisplaySpecialSymbol (const AIS_DisplaySpecialSymbol theDisplaySpecSymbol); Standard_EXPORT void SetDisplaySpecialSymbol (const AIS_DisplaySpecialSymbol theDisplaySpecSymbol);
//! shows dimension special symbol display options //! shows dimension special symbol display options
Standard_EXPORT AIS_DisplaySpecialSymbol DisplaySpecialSymbol() const; Standard_EXPORT AIS_DisplaySpecialSymbol DisplaySpecialSymbol() const;
//! specifies special symbol //! specifies special symbol
Standard_EXPORT void SetSpecialSymbol (const Standard_ExtCharacter theSpecialSymbol); Standard_EXPORT void SetSpecialSymbol (const Standard_ExtCharacter theSpecialSymbol);
//! returns special symbol //! returns special symbol
Standard_EXPORT Standard_ExtCharacter SpecialSymbol() const; Standard_EXPORT Standard_ExtCharacter SpecialSymbol() const;
//! shows if Units are to be displayed along with dimension value //! shows if Units are to be displayed along with dimension value
Standard_EXPORT Standard_Boolean IsUnitsDisplayed() const; Standard_EXPORT Standard_Boolean IsUnitsDisplayed() const;
//! sets to display units along with the dimansion value or no //! sets to display units along with the dimansion value or no
Standard_EXPORT void MakeUnitsDisplayed (const Standard_Boolean toDisplayUnits); Standard_EXPORT void MakeUnitsDisplayed (const Standard_Boolean toDisplayUnits);
//! returns the current type of units //! returns the current type of units
Standard_EXPORT TCollection_AsciiString UnitsQuantity() const; Standard_EXPORT TCollection_AsciiString UnitsQuantity() const;
//! sets the current type of units //! sets the current type of units
Standard_EXPORT void SetUnitsQuantity (const TCollection_AsciiString& theUnitsQuantity); Standard_EXPORT void SetUnitsQuantity (const TCollection_AsciiString& theUnitsQuantity);
//! returns the current model units //! returns the current model units
Standard_EXPORT TCollection_AsciiString ModelUnits() const; Standard_EXPORT TCollection_AsciiString ModelUnits() const;
//! sets the current model units //! sets the current model units
Standard_EXPORT void SetModelUnits (const TCollection_AsciiString& theUnits); Standard_EXPORT void SetModelUnits (const TCollection_AsciiString& theUnits);
//! returns the current display units //! returns the current display units
Standard_EXPORT TCollection_AsciiString DisplayUnits() const; Standard_EXPORT TCollection_AsciiString DisplayUnits() const;
//! sets the current display units //! sets the current display units
Standard_EXPORT void SetDisplayUnits (const TCollection_AsciiString& theUnits); 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> //! Important! Only for 3d text </br>
//! 3d text is oriented relative to the attachment points order </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> //! 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> //! to the second one. This method checks if text direction is to be default or </br>
//! should be reversed. //! should be reversed.
Standard_EXPORT Standard_Boolean IsTextReversed() const; Standard_EXPORT Standard_Boolean IsTextReversed() const;
//! Important! Only for 3d text //! Important! Only for 3d text
//! 3d text is oriented relative to the attachment points order </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> //! 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> //! to the second one. This method sets value that shows if text direction </br>
//! should be reversed or not. //! should be reversed or not.
Standard_EXPORT void MakeTextReversed (const Standard_Boolean isTextReversed); Standard_EXPORT void MakeTextReversed (const Standard_Boolean isTextReversed);
//! Sets selection tolerance for text2d: //! Sets selection tolerance for text2d:
//! For 2d text selection detection sensitive point with tolerance is used //! For 2d text selection detection sensitive point with tolerance is used
//! to change this tolerance use this method //! to change this tolerance use this method
//! Important! Only for 2d text //! Important! Only for 2d text
Standard_EXPORT void SetSelToleranceForText2d (const Standard_Real theTol); Standard_EXPORT void SetSelToleranceForText2d (const Standard_Real theTol);
//! Returns selection tolerance for text2d: //! Returns selection tolerance for text2d:
//! For 2d text selection detection sensitive point with tolerance is used //! For 2d text selection detection sensitive point with tolerance is used
//! Important! Only for 2d text //! Important! Only for 2d text
Standard_EXPORT Standard_Real SelToleranceForText2d() const; Standard_EXPORT Standard_Real SelToleranceForText2d() const;
//! Sets flyout size for dimension. //! Sets flyout size for dimension.
Standard_EXPORT void SetFlyout (const Standard_Real theFlyout); Standard_EXPORT void SetFlyout (const Standard_Real theFlyout);
//! @return flyout size for dimension. //! @return flyout size for dimension.
Standard_EXPORT Standard_Real GetFlyout () const; Standard_Real GetFlyout() const
{
return myFlyout;
}
public:
DEFINE_STANDARD_RTTI(AIS_Dimension) DEFINE_STANDARD_RTTI(AIS_Dimension)
protected: protected:
Standard_EXPORT void getTextWidthAndString (Quantity_Length& theWidth, Standard_EXPORT void getTextWidthAndString (Quantity_Length& theWidth,
TCollection_ExtendedString& theString) const; TCollection_ExtendedString& theString) const;
@ -190,19 +221,27 @@ protected:
Standard_EXPORT Standard_Real drawText (const Handle(Prs3d_Presentation)& thePresentation, Standard_EXPORT Standard_Real drawText (const Handle(Prs3d_Presentation)& thePresentation,
const gp_Dir& theTextDir, const gp_Dir& theTextDir,
const TCollection_ExtendedString theText, const TCollection_ExtendedString theText,
const AIS_DimensionDisplayMode theMode); const AIS_DimensionDisplayMode theMode,
const Standard_Integer theLabelPosition);
//! Performs computing of dimension linear extension with text //! Performs computing of dimension linear extension with text
Standard_EXPORT virtual void drawExtensionWithText (const Handle(Prs3d_Presentation)& thePresentation, //! @param thePresentation [in] the presentation to fill with graphical primitives.
const gp_Pnt& theStartPoint, //! @param theExtensionSize [in] the size of extension line.
const gp_Lin& theDimensionLine, //! @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 TCollection_ExtendedString& theValueString,
const AIS_DimensionDisplayMode theMode); const AIS_DimensionDisplayMode theMode,
const Standard_Integer theLabelPosition);
//! Performs computing of linear dimension (for length, diameter, radius and so on) //! Performs computing of linear dimension (for length, diameter, radius and so on)
Standard_EXPORT void drawLinearDimension (const Handle(Prs3d_Presentation)& thePresentation, Standard_EXPORT void drawLinearDimension (const Handle(Prs3d_Presentation)& thePresentation,
const gp_Pnt& theFirstAttach,
const gp_Pnt& theSecondAttach,
const AIS_DimensionDisplayMode theMode, const AIS_DimensionDisplayMode theMode,
const Standard_Boolean isOneSideDimension = Standard_False); const Standard_Boolean isOneSideDimension = Standard_False);
@ -231,39 +270,44 @@ protected:
//! Fills sensitive entity for flyouts and adds it to the selection. //! Fills sensitive entity for flyouts and adds it to the selection.
Standard_EXPORT virtual void computeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection, Standard_EXPORT virtual void computeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
const Handle(AIS_DimensionOwner)& theOwner); const Handle(AIS_DimensionOwner)& theOwner);
// Fields
protected:
/// WORKING PLANE PROPERTIES protected: //! @name Working plane properties
//! Dimension default plane //! Dimension default plane
gp_Pln myDefaultPlane; gp_Pln myDefaultPlane;
//! Shows if working plane is set custom //! Shows if working plane is set custom
Standard_Boolean myIsWorkingPlaneCustom; Standard_Boolean myIsWorkingPlaneCustom;
/// VALUE PROPERTIES protected: //! @name Value properties
//! Dimension value which is displayed with dimension lines //! Dimension value which is displayed with dimension lines
Standard_Real myValue; Standard_Real myValue;
//! Shows if the value is set by user and is no need to count it automatically //! Shows if the value is set by user and is no need to count it automatically
Standard_Boolean myIsValueCustom; Standard_Boolean myIsValueCustom;
/// UNITS PROPERTIES protected: // !@name Units properties
//! The quantity of units for the value computation //! The quantity of units for the value computation
TCollection_AsciiString myUnitsQuantity; TCollection_AsciiString myUnitsQuantity;
//! Units of the model //! Units of the model
TCollection_AsciiString myModelUnits; TCollection_AsciiString myModelUnits;
//! Units in which the displayed value will be converted //! Units in which the displayed value will be converted
TCollection_AsciiString myDisplayUnits; TCollection_AsciiString myDisplayUnits;
//! Determines if units is to be displayed along with the value //! Determines if units is to be displayed along with the value
Standard_Boolean myToDisplayUnits; Standard_Boolean myToDisplayUnits;
//! Special symbol for some kind of dimensions (for diameter, radius and so on) //! Special symbol for some kind of dimensions (for diameter, radius and so on)
Standard_ExtCharacter mySpecialSymbol; Standard_ExtCharacter mySpecialSymbol;
//! Special symbol display options //! Special symbol display options
AIS_DisplaySpecialSymbol myDisplaySpecialSymbol; AIS_DisplaySpecialSymbol myDisplaySpecialSymbol;
/// GEOMETRY PROPERTIES protected: //! @name Geometry properties
//! Geometry of dimensions, needs for advanced selection //! Geometry of dimensions, needs for advanced selection
//! Geometry is computed in Compute() method and is used //! Geometry is computed in Compute() method and is used
@ -274,57 +318,66 @@ protected:
{ {
//! Text position //! Text position
gp_Pnt myTextPosition; gp_Pnt myTextPosition;
//! Text bounding box, stored for advanced selection //! Text bounding box, stored for advanced selection
Bnd_Box myTextBndBox; Bnd_Box myTextBndBox;
//! Sensitive point tolerance for 2d text selection //! Sensitive point tolerance for 2d text selection
Standard_Real mySelToleranceForText2d; Standard_Real mySelToleranceForText2d;
//! For advanced dimension line selection //! For advanced dimension line selection
Select3D_ListOfSensitive mySensitiveSegments; Select3D_ListOfSensitive mySensitiveSegments;
//! Shows if attachment points were computed //! Shows if attachment points were computed
Standard_Boolean myIsComputed; Standard_Boolean myIsComputed;
public: public:
DimensionGeom ()
: myIsComputed (Standard_False) DimensionGeom () : myIsComputed (Standard_False) {}
{ }
}; };
//! Shows if text is inverted //! Shows if text is inverted
Standard_Boolean myIsTextReversed; 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. //! Points that are base for dimension.
//! My first point of dimension attach (belongs to shape for which dimension is computed) //! My first point of dimension attach (belongs to shape for which dimension is computed)
gp_Pnt myFirstPoint; gp_Pnt myFirstPoint;
//! My second point of dimension attach (belongs to shape for which dimension is computed) //! My second point of dimension attach (belongs to shape for which dimension is computed)
gp_Pnt mySecondPoint; gp_Pnt mySecondPoint;
//! Shows if attach points are initialized correctly //! Shows if attach points are initialized correctly
Standard_Boolean myIsInitialized; Standard_Boolean myIsInitialized;
//! First shape (can be vertex, edge or face) //! First shape (can be vertex, edge or face)
TopoDS_Shape myFirstShape; TopoDS_Shape myFirstShape;
//! Second shape (can be vertex, edge or face) //! Second shape (can be vertex, edge or face)
TopoDS_Shape mySecondShape; TopoDS_Shape mySecondShape;
//! Number of shapes //! Number of shapes
Standard_Integer myShapesNumber; Standard_Integer myShapesNumber;
//! Defines flyout lines and direction //! Defines flyout lines and direction
//! Flyout direction in the working plane. //! Flyout direction in the working plane.
//! Can be negative, or positive and is defined by the sign of myFlyout value. //! Can be negative, or positive and is defined by the sign of myFlyout value.
//! The direction vector is counting using the working plane. //! The direction vector is counting using the working plane.
//! myFlyout value defined the size of flyout. //! myFlyout value defined the size of flyout.
Standard_Real myFlyout; Standard_Real myFlyout;
//! Geometry of dimensions, needs for advanced selection //! Geometry of dimensions, needs for advanced selection
//! Geometry is computed in Compute() method and is used //! Geometry is computed in Compute() method and is used
//! in ComputeSelection() method. //! in ComputeSelection() method.
//! If it is computed successfully, myIsComputed = Standard_True. //! If it is computed successfully, myIsComputed = Standard_True.
//! to check computing result use IsComputed() method //! to check computing result use IsComputed() method
DimensionGeom myGeom; DimensionGeom myGeom;
private: private:
//! Type of dimension //! Type of dimension
AIS_KindOfDimension myKindOfDimension; AIS_KindOfDimension myKindOfDimension;
//! Dimension working plane, is equal to <myDefaultPlane> if it can be computed automatically. //! Dimension working plane, is equal to <myDefaultPlane> if it can be computed automatically.
gp_Pln myWorkingPlane; gp_Pln myWorkingPlane;
//! Extension size in model measure units.
//! No inclined or curved extension line is now supported.
Standard_Real myExtensionSize;
}; };
#endif #endif

View File

@ -18,65 +18,24 @@
// purpose or non-infringement. Please see the License for the specific terms // purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License. // 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_LengthDimension.hxx>
#include <AIS.hxx> #include <AIS.hxx>
#include <AIS_DimensionOwner.hxx>
#include <AIS_Drawer.hxx>
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
#include <BRepAdaptor_Curve.hxx> #include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepGProp_Face.hxx> #include <BRepGProp_Face.hxx>
#include <BRepLib_MakeVertex.hxx> #include <BRepLib_MakeVertex.hxx>
#include <BRepTopAdaptor_FClass2d.hxx> #include <BRepTopAdaptor_FClass2d.hxx>
#include <DsgPrs.hxx>
#include <DsgPrs_LengthPresentation.hxx>
#include <ElCLib.hxx> #include <ElCLib.hxx>
#include <ElSLib.hxx> #include <ElSLib.hxx>
#include <Geom_Circle.hxx>
#include <Geom_Curve.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom_Line.hxx> #include <Geom_Line.hxx>
#include <Geom_Plane.hxx>
#include <Geom_OffsetSurface.hxx>
#include <gce_MakeDir.hxx> #include <gce_MakeDir.hxx>
#include <gce_MakeLin.hxx>
#include <Graphic3d_Group.hxx> #include <Graphic3d_Group.hxx>
#include <Graphic3d_ArrayOfSegments.hxx> #include <Graphic3d_ArrayOfSegments.hxx>
#include <Graphic3d_AspectText3d.hxx> #include <PrsMgr_PresentationManager.hxx>
#include <Graphic3d_AspectLine3d.hxx> #include <Prs3d_Root.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 <TopExp.hxx> #include <TopExp.hxx>
#include <TopExp_Explorer.hxx> #include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
IMPLEMENT_STANDARD_HANDLE(AIS_LengthDimension, AIS_Dimension) IMPLEMENT_STANDARD_HANDLE(AIS_LengthDimension, AIS_Dimension)
IMPLEMENT_STANDARD_RTTIEXT(AIS_LengthDimension, AIS_Dimension) IMPLEMENT_STANDARD_RTTIEXT(AIS_LengthDimension, AIS_Dimension)
@ -86,33 +45,10 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_LengthDimension, AIS_Dimension)
//purpose : Dimension between two points //purpose : Dimension between two points
//======================================================================= //=======================================================================
AIS_LengthDimension::AIS_LengthDimension (const gp_Pnt& theFirstPoint,
const gp_Pnt& theSecondPoint,
const gp_Pln& theDimensionPlane,
const Handle(Prs3d_DimensionAspect)& theDimensionAspect,
const Standard_Real theExtensionSize /*= 1.0*/)
:AIS_Dimension (theDimensionAspect,theExtensionSize)
{
myIsInitialized = Standard_True;
myFirstPoint = theFirstPoint;
mySecondPoint = theSecondPoint;
myShapesNumber = 2;
myFirstShape = BRepLib_MakeVertex (myFirstPoint);
mySecondShape = BRepLib_MakeVertex (mySecondPoint);
SetFlyout (15.0);
SetKindOfDimension(AIS_KOD_LENGTH);
SetWorkingPlane (theDimensionPlane);
}
//=======================================================================
//function : Constructor
//purpose : Dimension between two points
//=======================================================================
AIS_LengthDimension::AIS_LengthDimension (const gp_Pnt& theFirstPoint, AIS_LengthDimension::AIS_LengthDimension (const gp_Pnt& theFirstPoint,
const gp_Pnt& theSecondPoint, const gp_Pnt& theSecondPoint,
const gp_Pln& theDimensionPlane) const gp_Pln& theDimensionPlane)
: AIS_Dimension () : AIS_Dimension()
{ {
myIsInitialized = Standard_True; myIsInitialized = Standard_True;
myFirstPoint = theFirstPoint; myFirstPoint = theFirstPoint;
@ -120,9 +56,9 @@ AIS_LengthDimension::AIS_LengthDimension (const gp_Pnt& theFirstPoint,
myFirstShape = BRepLib_MakeVertex (myFirstPoint); myFirstShape = BRepLib_MakeVertex (myFirstPoint);
mySecondShape = BRepLib_MakeVertex (mySecondPoint); mySecondShape = BRepLib_MakeVertex (mySecondPoint);
myShapesNumber = 2; myShapesNumber = 2;
SetFlyout (15.0);
SetKindOfDimension (AIS_KOD_LENGTH); SetKindOfDimension (AIS_KOD_LENGTH);
SetWorkingPlane (theDimensionPlane); SetWorkingPlane (theDimensionPlane);
SetFlyout (15.0);
} }
//======================================================================= //=======================================================================
@ -133,15 +69,15 @@ AIS_LengthDimension::AIS_LengthDimension (const gp_Pnt& theFirstPoint,
AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Shape& theFirstShape, AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Shape& theFirstShape,
const TopoDS_Shape& theSecondShape, const TopoDS_Shape& theSecondShape,
const gp_Pln& theWorkingPlane) const gp_Pln& theWorkingPlane)
: AIS_Dimension () : AIS_Dimension()
{ {
myIsInitialized = Standard_False; myIsInitialized = Standard_False;
myFirstShape = theFirstShape; myFirstShape = theFirstShape;
mySecondShape = theSecondShape; mySecondShape = theSecondShape;
myShapesNumber = 2; myShapesNumber = 2;
SetFlyout (15.0);
SetKindOfDimension (AIS_KOD_LENGTH); SetKindOfDimension (AIS_KOD_LENGTH);
SetWorkingPlane (theWorkingPlane); SetWorkingPlane (theWorkingPlane);
SetFlyout (15.0);
} }
//======================================================================= //=======================================================================
@ -151,14 +87,14 @@ AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Shape& theFirstShape,
AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Edge& theEdge, AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Edge& theEdge,
const gp_Pln& theWorkingPlane) const gp_Pln& theWorkingPlane)
: AIS_Dimension () : AIS_Dimension()
{ {
myIsInitialized = Standard_False; myIsInitialized = Standard_False;
myFirstShape = theEdge; myFirstShape = theEdge;
myShapesNumber = 1; myShapesNumber = 1;
SetFlyout (15.0);
SetKindOfDimension (AIS_KOD_LENGTH); SetKindOfDimension (AIS_KOD_LENGTH);
SetWorkingPlane (theWorkingPlane); SetWorkingPlane (theWorkingPlane);
SetFlyout (15.0);
} }
//======================================================================= //=======================================================================
@ -168,14 +104,14 @@ AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Edge& theEdge,
AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Face& theFirstFace, AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Face& theFirstFace,
const TopoDS_Face& theSecondFace) const TopoDS_Face& theSecondFace)
: AIS_Dimension () : AIS_Dimension()
{ {
myIsInitialized = Standard_False; myIsInitialized = Standard_False;
myFirstShape = theFirstFace; myFirstShape = theFirstFace;
mySecondShape = theSecondFace; mySecondShape = theSecondFace;
myShapesNumber = 2; myShapesNumber = 2;
SetKindOfDimension (AIS_KOD_LENGTH);
SetFlyout (15.0); SetFlyout (15.0);
SetKindOfDimension(AIS_KOD_LENGTH);
} }
//======================================================================= //=======================================================================
@ -185,13 +121,13 @@ AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Face& theFirstFace,
AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Face& theFace, AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Face& theFace,
const TopoDS_Edge& theEdge) const TopoDS_Edge& theEdge)
: AIS_Dimension () : AIS_Dimension()
{ {
SetKindOfDimension(AIS_KOD_LENGTH);
myIsInitialized = Standard_False; myIsInitialized = Standard_False;
myFirstShape = theFace; myFirstShape = theFace;
mySecondShape = theEdge; mySecondShape = theEdge;
myShapesNumber = 2; myShapesNumber = 2;
SetKindOfDimension (AIS_KOD_LENGTH);
SetFlyout (15.0); SetFlyout (15.0);
} }
@ -561,50 +497,28 @@ void AIS_LengthDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /
if (!myIsInitialized) if (!myIsInitialized)
{ {
if (myShapesNumber == 1) if (myShapesNumber == 1)
myIsInitialized = initOneShapePoints(myFirstShape); {
myIsInitialized = initOneShapePoints (myFirstShape);
}
else if (myShapesNumber == 2) else if (myShapesNumber == 2)
myIsInitialized = initTwoShapesPoints(myFirstShape, mySecondShape); {
myIsInitialized = initTwoShapesPoints (myFirstShape, mySecondShape);
}
else else
{
return; return;
} }
}
// If initialization failed // If initialization failed
if (!myIsInitialized) if (!myIsInitialized)
{
return; return;
}
thePresentation->Clear(); thePresentation->Clear();
// Get length dimension aspect from AIS object drawer
Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
//Count flyout direction drawLinearDimension (thePresentation, (AIS_DimensionDisplayMode)theMode);
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);
} }
//======================================================================= //=======================================================================
@ -612,7 +526,7 @@ void AIS_LengthDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /
//purpose : //purpose :
//======================================================================= //=======================================================================
void AIS_LengthDimension::computeValue () void AIS_LengthDimension::computeValue()
{ {
myValue = myFirstPoint.Distance (mySecondPoint); myValue = myFirstPoint.Distance (mySecondPoint);
AIS_Dimension::computeValue (); AIS_Dimension::computeValue ();

View File

@ -67,15 +67,6 @@ class AIS_LengthDimension : public AIS_Dimension
{ {
public: public:
//! Constructor with full parameter list.
//! Construct dimension between two vertices.
//! Style of line, arrow and text can be set by default.
Standard_EXPORT AIS_LengthDimension (const gp_Pnt& theFirstPoint,
const gp_Pnt& theSecondPoint,
const gp_Pln& theDimensionPlane,
const Handle(Prs3d_DimensionAspect)& theDimensionAspect,
const Standard_Real theExtensionSize = 1.0);
Standard_EXPORT AIS_LengthDimension (const gp_Pnt& theFirstPoint, Standard_EXPORT AIS_LengthDimension (const gp_Pnt& theFirstPoint,
const gp_Pnt& theSecondPoint, const gp_Pnt& theSecondPoint,
const gp_Pln& theDimensionPlane); const gp_Pln& theDimensionPlane);
@ -94,35 +85,42 @@ public:
Standard_EXPORT AIS_LengthDimension (const TopoDS_Face& theFace, Standard_EXPORT AIS_LengthDimension (const TopoDS_Face& theFace,
const TopoDS_Edge& theEdge); const TopoDS_Edge& theEdge);
public:
DEFINE_STANDARD_RTTI(AIS_LengthDimension) DEFINE_STANDARD_RTTI(AIS_LengthDimension)
private: private:
Standard_Boolean initTwoEdgesLength (const TopoDS_Edge & theFirstEdge, Standard_Boolean initTwoEdgesLength (const TopoDS_Edge & theFirstEdge,
const TopoDS_Edge& theSecondEdge, const TopoDS_Edge& theSecondEdge,
gp_Dir& theDirAttach); gp_Dir& theDirAttach);
//! Auxiliary method for <InitTwoShapesPoints()> //! Auxiliary method for <InitTwoShapesPoints()>
//! in case of the distance between edge and vertex //! in case of the distance between edge and vertex
Standard_Boolean initEdgeVertexLength (const TopoDS_Edge & theEdge, Standard_Boolean initEdgeVertexLength (const TopoDS_Edge & theEdge,
const TopoDS_Vertex & theVertex, const TopoDS_Vertex & theVertex,
gp_Dir & theDirAttach, gp_Dir & theDirAttach,
Standard_Boolean isInfinite); Standard_Boolean isInfinite);
//! Auxiliary method for <InitTwoShapesPoints()> //! Auxiliary method for <InitTwoShapesPoints()>
//! in case of the distance between face and edge //! in case of the distance between face and edge
Standard_Boolean initEdgeFaceLength (const TopoDS_Edge& theEdge, Standard_Boolean initEdgeFaceLength (const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace, const TopoDS_Face& theFace,
gp_Dir& theDirAttach); gp_Dir& theDirAttach);
//! Initialization of two attach points in case of two owner shapes //! Initialization of two attach points in case of two owner shapes
Standard_Boolean initTwoShapesPoints (const TopoDS_Shape& theFirstShape, 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 //! Initialization of two attach points in case of one owner shape
Standard_Boolean initOneShapePoints (const TopoDS_Shape& theShape); Standard_Boolean initOneShapePoints (const TopoDS_Shape& theShape);
//! Compute length in display units. //! Compute length in display units.
virtual void computeValue (); virtual void computeValue();
virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
const Handle(Prs3d_Presentation)& thePresentation, const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode = 0) ; const Standard_Integer theMode = 0) ;
}; };
#endif #endif

View File

@ -18,52 +18,16 @@
// purpose or non-infringement. Please see the License for the specific terms // purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License. // and conditions governing the rights and limitations under the License.
#include <Standard_NotImplemented.hxx>
#include <AIS_RadiusDimension.hxx> #include <AIS_RadiusDimension.hxx>
#include <AIS.hxx> #include <AIS.hxx>
#include <AIS_Drawer.hxx> #include <AIS_Drawer.hxx>
#include <AIS_KindOfDimension.hxx>
#include <Adaptor3d_HCurve.hxx>
#include <BRep_Tool.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <DsgPrs.hxx>
#include <ElCLib.hxx> #include <ElCLib.hxx>
#include <GC_MakeCircle.hxx>
#include <gce_MakeCirc.hxx>
#include <gce_MakeDir.hxx> #include <gce_MakeDir.hxx>
#include <gce_MakeLin.hxx>
#include <Geom_Surface.hxx>
#include <Geom_Plane.hxx>
#include <Geom_Circle.hxx>
#include <Geom_Curve.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom_ToroidalSurface.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_SurfaceOfLinearExtrusion.hxx>
#include <gp_Circ.hxx>
#include <gp_Pnt.hxx>
#include <gp_Trsf.hxx>
#include <Graphic3d_ArrayOfSegments.hxx> #include <Graphic3d_ArrayOfSegments.hxx>
#include <Graphic3d_Group.hxx> #include <Graphic3d_Group.hxx>
#include <Precision.hxx>
#include <PrsMgr_PresentationManager3d.hxx> #include <PrsMgr_PresentationManager3d.hxx>
#include <Prs3d_DimensionAspect.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_Root.hxx> #include <Prs3d_Root.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <TopExp_Explorer.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopLoc_Location.hxx>
IMPLEMENT_STANDARD_HANDLE(AIS_RadiusDimension, AIS_Dimension) IMPLEMENT_STANDARD_HANDLE(AIS_RadiusDimension, AIS_Dimension)
IMPLEMENT_STANDARD_RTTIEXT(AIS_RadiusDimension, AIS_Dimension) IMPLEMENT_STANDARD_RTTIEXT(AIS_RadiusDimension, AIS_Dimension)
@ -82,9 +46,15 @@ AIS_RadiusDimension::AIS_RadiusDimension (const gp_Circ& theCircle)
myIsInitialized = Standard_True; myIsInitialized = Standard_True;
SetSpecialSymbol ('R'); SetSpecialSymbol ('R');
SetDisplaySpecialSymbol (AIS_DSS_Before); 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, AIS_RadiusDimension::AIS_RadiusDimension (const gp_Circ& theCircle,
const gp_Pnt& theAttachPoint) const gp_Pnt& theAttachPoint)
: AIS_Dimension(), : AIS_Dimension(),
@ -96,6 +66,7 @@ AIS_RadiusDimension::AIS_RadiusDimension (const gp_Circ& theCircle,
SetSpecialSymbol ('R'); SetSpecialSymbol ('R');
SetDisplaySpecialSymbol (AIS_DSS_Before); SetDisplaySpecialSymbol (AIS_DSS_Before);
SetKindOfDimension (AIS_KOD_RADIUS); SetKindOfDimension (AIS_KOD_RADIUS);
SetFlyout (0.0);
} }
//======================================================================= //=======================================================================
@ -111,44 +82,7 @@ AIS_RadiusDimension::AIS_RadiusDimension (const TopoDS_Shape& theShape)
SetSpecialSymbol ('R'); SetSpecialSymbol ('R');
SetDisplaySpecialSymbol (AIS_DSS_Before); 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 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);
} }
//======================================================================= //=======================================================================
@ -177,38 +111,13 @@ void AIS_RadiusDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /
myIsInitialized = Standard_True; myIsInitialized = Standard_True;
} }
} }
if (!myIsWorkingPlaneCustom) if (!myIsWorkingPlaneCustom)
countDefaultPlane();
//Count flyout direction
gp_Ax1 aWorkingPlaneNormal = GetWorkingPlane().Axis();
gp_Dir aTargetPointsVector = gce_MakeDir (myFirstPoint, mySecondPoint);
// Count a flyout direction vector.
gp_Dir aFlyoutVector = aWorkingPlaneNormal.Direction()^aTargetPointsVector;
// Create lines for layouts
gp_Lin aLine1 (myFirstPoint, aFlyoutVector);
gp_Lin aLine2 (mySecondPoint, aFlyoutVector);
// Get flyout end points
gp_Pnt aFlyoutEnd1 = ElCLib::Value (ElCLib::Parameter (aLine1, myFirstPoint) + GetFlyout(), aLine1);
gp_Pnt aFlyoutEnd2 = ElCLib::Value (ElCLib::Parameter (aLine2, mySecondPoint) + GetFlyout(), aLine2);
// Add layout lines to graphic group
// Common to all type of dimension placement.
if (theMode == 0)
{ {
Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments(4); countDefaultPlane();
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, Standard_True); drawLinearDimension (thePresentation, (AIS_DimensionDisplayMode)theMode, Standard_True);
} }
//======================================================================= //=======================================================================

View File

@ -44,19 +44,12 @@ DEFINE_STANDARD_HANDLE(AIS_RadiusDimension,AIS_Dimension)
class AIS_RadiusDimension : public AIS_Dimension class AIS_RadiusDimension : public AIS_Dimension
{ {
public: public:
Standard_EXPORT AIS_RadiusDimension (const gp_Circ& theCircle); Standard_EXPORT AIS_RadiusDimension (const gp_Circ& theCircle);
Standard_EXPORT AIS_RadiusDimension (const gp_Circ& theCircle, Standard_EXPORT AIS_RadiusDimension (const gp_Circ& theCircle,
const gp_Pnt& theAttachPoint); const gp_Pnt& theAttachPoint);
Standard_EXPORT AIS_RadiusDimension (const gp_Circ& theCircle,
const Handle(Prs3d_DimensionAspect)& theDimensionAspect,
const Standard_Real theExtensionSize = 1.0);
Standard_EXPORT AIS_RadiusDimension (const gp_Circ& theCircle,
const gp_Pnt& theAttachPoint,
const Handle(Prs3d_DimensionAspect)& theDimensionAspect,
const Standard_Real theExtensionSize = 1.0);
//! Constructs the radius display object defined by the <br> //! Constructs the radius display object defined by the <br>
//! shape aShape, the dimension aVal, and the text aText. //! shape aShape, the dimension aVal, and the text aText.
Standard_EXPORT AIS_RadiusDimension (const TopoDS_Shape& aShape); Standard_EXPORT AIS_RadiusDimension (const TopoDS_Shape& aShape);
@ -64,17 +57,21 @@ public:
DEFINE_STANDARD_RTTI(AIS_RadiusDimension) DEFINE_STANDARD_RTTI(AIS_RadiusDimension)
protected: protected:
//! Computes dimension value in display units //! Computes dimension value in display units
Standard_EXPORT virtual void computeValue (); Standard_EXPORT virtual void computeValue ();
//! Fills default plane object if it is possible to count plane automatically. //! Fills default plane object if it is possible to count plane automatically.
Standard_EXPORT virtual void countDefaultPlane (); Standard_EXPORT virtual void countDefaultPlane ();
private: private:
virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
const Handle(Prs3d_Presentation)& thePresentation, const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode = 0); const Standard_Integer theMode = 0);
// Fields // Fields
private:
gp_Circ myCircle; gp_Circ myCircle;
}; };

View File

@ -75,18 +75,27 @@ is
-- For more details see AIS_Drawer class, AIS_Shape::Compute() method and -- For more details see AIS_Drawer class, AIS_Shape::Compute() method and
-- HLRAlgo package from TKHLR toolkit. -- HLRAlgo package from TKHLR toolkit.
enumeration HorizontalTextAlignment is HTA_Left, HTA_Right, HTA_Center; enumeration DimensionTextHorizontalPosition is DTHP_Left, DTHP_Right, DTHP_Center, DTHP_Fit;
---Purpose: To declare horisontal alignment for dimension text. ---Purpose: Specifies options for positioning dimension value label in horizontal direction.
-- DTHP_Left - value label located at left side on dimension extension.
enumeration VerticalTextAlignment is VTA_Top, VTA_Bottom, VTA_Center; -- DTHP_Right - value label located at right side on dimension extension.
---Purpose: To declare vertical alignment for dimension text label. -- DTHP_Center - value label located at center of dimension line.
-- DTHP_Fit - value label located automatically at left side if does not fits
enumeration DimensionArrowOrientation is DAO_Internal, DAO_External; -- the dimension space, otherwise the value label is placed at center.
---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 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; class Presentation;
---Purpose: defines the presentation object. This object can be ---Purpose: defines the presentation object. This object can be

View File

@ -20,8 +20,8 @@ class DimensionAspect from Prs3d inherits BasicAspect from Prs3d
---Purpose: defines the attributes when drawing a Length Presentation. ---Purpose: defines the attributes when drawing a Length Presentation.
uses uses
HorizontalTextAlignment from Prs3d, DimensionTextHorizontalPosition from Prs3d,
VerticalTextAlignment from Prs3d, DimensionTextVerticalPosition from Prs3d,
DimensionArrowOrientation from Prs3d, DimensionArrowOrientation from Prs3d,
AspectLine3d from Graphic3d, AspectLine3d from Graphic3d,
ArrowAspect from Prs3d, ArrowAspect from Prs3d,
@ -71,19 +71,19 @@ is
--- Purpose: Sets orientation of arrows (external or internal). --- Purpose: Sets orientation of arrows (external or internal).
-- By default orientation is chosen automatically according to situation and text label size. -- By default orientation is chosen automatically according to situation and text label size.
GetArrowOrientation (me) returns DimensionArrowOrientation from Prs3d; ArrowOrientation (me) returns DimensionArrowOrientation from Prs3d;
--- Purpose: Gets orientation of arrows (external or internal). --- Purpose: Gets orientation of arrows (external or internal).
SetVerticalTextAlignment(me: mutable; theVertTextAlignment: VerticalTextAlignment from Prs3d); SetTextVerticalPosition (me: mutable; thePosition : DimensionTextVerticalPosition from Prs3d);
--- Purpose: Sets vertical text alignment for text label. --- Purpose: Sets vertical text alignment for text label.
VerticalTextAlignment (me) returns VerticalTextAlignment from Prs3d; TextVerticalPosition (me) returns DimensionTextVerticalPosition from Prs3d;
--- Purpose: Gets vertical text alignment for text label. --- Purpose: Gets vertical text alignment for text label.
SetHorizontalTextAlignment (me: mutable; theHorTextAlignment: HorizontalTextAlignment from Prs3d); SetTextHorizontalPosition (me: mutable; thePosition: DimensionTextHorizontalPosition from Prs3d);
--- Purpose: Sets horizontal text alignment for text label. --- Purpose: Sets horizontal text alignment for text label.
HorizontalTextAlignment (me) returns HorizontalTextAlignment from Prs3d; TextHorizontalPosition (me) returns DimensionTextHorizontalPosition from Prs3d;
--- Purpose: Gets horizontal text alignment for text label. --- Purpose: Gets horizontal text alignment for text label.
ArrowAspect(me) returns mutable ArrowAspect from Prs3d is static; ArrowAspect(me) returns mutable ArrowAspect from Prs3d is static;
@ -95,24 +95,38 @@ is
SetCommonColor(me:mutable; theColor: Color from Quantity) 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. ---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 fields
myLineAspect: LineAspect from Prs3d; myLineAspect: LineAspect from Prs3d;
---Purpose: Text style. The size for 3d (or 2d) text is also inside here. ---Purpose: Text style. The size for 3d (or 2d) text is also inside here.
myTextAspect: TextAspect from Prs3d; myTextAspect: TextAspect from Prs3d;
myArrowAspect : ArrowAspect from Prs3d; myArrowAspect : ArrowAspect from Prs3d;
myIsText3d : Boolean from Standard; myIsText3d : Boolean from Standard;
myIsTextShaded : Boolean from Standard; myIsTextShaded : Boolean from Standard;
myIsArrows3d: Boolean from Standard; myIsArrows3d: Boolean from Standard;
myArrowOrientation : DimensionArrowOrientation from Prs3d; myArrowOrientation : DimensionArrowOrientation from Prs3d;
---Purpose: Dimension arrow orientation ---Purpose: Dimension arrow orientation.
-- By default, it is computed automatically. Its value depends on the text -- By default, it is computed automatically. Its value depends on the text
-- bouning rectangle size and distance between two flyouts. -- bouning rectangle size and distance between two flyouts.
-- By default, it is internal one. -- By default, it is "fit" one.
myHorTextAlignment: HorizontalTextAlignment from Prs3d;
---Purpose:Horizontal text alignment (Prs3d_HTA_Left/Prs3d_HTA_Right/Prs3d_HTA_Center). myTextHPosition : DimensionTextHorizontalPosition from Prs3d;
-- Defines horizontal position of text value label, by default it is center. ---Purpose: Defines horizontal position of text value label, by default it is
myVerTextAlignment: VerticalTextAlignment from Prs3d; -- "fit" - selected automatically depending on label-to-dimension size relation.
---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. myTextVPosition : DimensionTextVerticalPosition from Prs3d;
---Purpose: Defines vertical position of text value label, by default it is center.
myExtensionSize : Real from Standard;
---Purpose: Size of arrow extensions.
-- The length of arrow tails if arrows are located outside dimension line.
end DimensionAspect from Prs3d; end DimensionAspect from Prs3d;

View File

@ -18,11 +18,12 @@
#include <Prs3d_DimensionAspect.hxx> #include <Prs3d_DimensionAspect.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_TextAspect.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Aspect_TypeOfLine.hxx> #include <Aspect_TypeOfLine.hxx>
#include <Graphic3d_AspectText3d.hxx> #include <Graphic3d_AspectText3d.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_TextAspect.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Quantity_Color.hxx> #include <Quantity_Color.hxx>
IMPLEMENT_STANDARD_HANDLE (Prs3d_DimensionAspect, Prs3d_BasicAspect) IMPLEMENT_STANDARD_HANDLE (Prs3d_DimensionAspect, Prs3d_BasicAspect)
@ -33,13 +34,12 @@ IMPLEMENT_STANDARD_RTTIEXT (Prs3d_DimensionAspect, Prs3d_BasicAspect)
//purpose : //purpose :
//======================================================================= //=======================================================================
Prs3d_DimensionAspect::Prs3d_DimensionAspect () Prs3d_DimensionAspect::Prs3d_DimensionAspect()
{ {
// Text alignment myTextHPosition = Prs3d_DTHP_Fit;
myHorTextAlignment = Prs3d_HTA_Center; myTextVPosition = Prs3d_DTVP_Center;
myVerTextAlignment = Prs3d_VTA_Center; myArrowOrientation = Prs3d_DAO_Fit;
// Arrow orientation, will be computed on further steps, by default it is internal.
myArrowOrientation = Prs3d_DAO_Internal;
myLineAspect = new Prs3d_LineAspect (Quantity_NOC_LAWNGREEN,Aspect_TOL_SOLID,1.); myLineAspect = new Prs3d_LineAspect (Quantity_NOC_LAWNGREEN,Aspect_TOL_SOLID,1.);
myTextAspect = new Prs3d_TextAspect; myTextAspect = new Prs3d_TextAspect;
myTextAspect->Aspect()->SetTextZoomable (Standard_False); myTextAspect->Aspect()->SetTextZoomable (Standard_False);
@ -48,7 +48,8 @@ Prs3d_DimensionAspect::Prs3d_DimensionAspect ()
myTextAspect->SetVerticalJustification (Graphic3d_VTA_CENTER); myTextAspect->SetVerticalJustification (Graphic3d_VTA_CENTER);
myArrowAspect = new Prs3d_ArrowAspect; myArrowAspect = new Prs3d_ArrowAspect;
myArrowAspect->SetColor (Quantity_NOC_LAWNGREEN); myArrowAspect->SetColor (Quantity_NOC_LAWNGREEN);
myArrowAspect->SetLength (6.); myArrowAspect->SetLength (6.0);
myExtensionSize = 6.0;
} }
//======================================================================= //=======================================================================
@ -176,49 +177,49 @@ void Prs3d_DimensionAspect::SetArrowOrientation (const Prs3d_DimensionArrowOrien
//purpose : //purpose :
//======================================================================= //=======================================================================
Prs3d_DimensionArrowOrientation Prs3d_DimensionAspect::GetArrowOrientation () const Prs3d_DimensionArrowOrientation Prs3d_DimensionAspect::ArrowOrientation() const
{ {
return myArrowOrientation; return myArrowOrientation;
} }
//======================================================================= //=======================================================================
//function : VerticalTextAlignment //function : SetTextVerticalPosition
//purpose : //purpose :
//======================================================================= //=======================================================================
Prs3d_VerticalTextAlignment Prs3d_DimensionAspect::VerticalTextAlignment () const void Prs3d_DimensionAspect::SetTextVerticalPosition (const Prs3d_DimensionTextVerticalPosition thePosition)
{ {
return myVerTextAlignment; myTextVPosition = thePosition;
} }
//======================================================================= //=======================================================================
//function : SetVerticalTextAlignment //function : TextVerticalPosition
//purpose : //purpose :
//======================================================================= //=======================================================================
void Prs3d_DimensionAspect::SetVerticalTextAlignment (const Prs3d_VerticalTextAlignment theVertTextAlignment) Prs3d_DimensionTextVerticalPosition Prs3d_DimensionAspect::TextVerticalPosition() const
{ {
myVerTextAlignment = theVertTextAlignment; return myTextVPosition;
} }
//======================================================================= //=======================================================================
//function : HorizontalTextAlignment //function : SetTextHorizontalPosition
//purpose : //purpose :
//======================================================================= //=======================================================================
Prs3d_HorizontalTextAlignment Prs3d_DimensionAspect::HorizontalTextAlignment () const void Prs3d_DimensionAspect::SetTextHorizontalPosition (const Prs3d_DimensionTextHorizontalPosition thePosition)
{ {
return myHorTextAlignment; myTextHPosition = thePosition;
} }
//======================================================================= //=======================================================================
//function : SetHorizontalTextAlignment //function : TextHorizontalPosition
//purpose : //purpose :
//======================================================================= //=======================================================================
void Prs3d_DimensionAspect::SetHorizontalTextAlignment (const Prs3d_HorizontalTextAlignment theHorTextAlignment) Prs3d_DimensionTextHorizontalPosition Prs3d_DimensionAspect::TextHorizontalPosition() const
{ {
myHorTextAlignment = theHorTextAlignment; return myTextHPosition;
} }
//======================================================================= //=======================================================================
@ -240,3 +241,23 @@ void Prs3d_DimensionAspect::SetArrowAspect (const Handle(Prs3d_ArrowAspect)& the
{ {
myArrowAspect = theAspect; myArrowAspect = theAspect;
} }
//=======================================================================
//function : SetExtensioSize
//purpose :
//=======================================================================
void Prs3d_DimensionAspect::SetExtensionSize (const Standard_Real theSize)
{
myExtensionSize = theSize;
}
//=======================================================================
//function : ExtensionSize
//purpose :
//=======================================================================
Standard_Real Prs3d_DimensionAspect::ExtensionSize() const
{
return myExtensionSize;
}

View File

@ -710,7 +710,7 @@ static Standard_Integer OCC301 (Draw_Interpretor& di, Standard_Integer argc, con
Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect; Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect;
anAspect->MakeArrows3d (Standard_True); anAspect->MakeArrows3d (Standard_True);
anAspect->ArrowAspect()->SetLength (anArrowSize); anAspect->ArrowAspect()->SetLength (anArrowSize);
anAspect->SetHorizontalTextAlignment (Prs3d_HTA_Right); anAspect->SetTextHorizontalPosition (Prs3d_DTHP_Right);
anAspect->TextAspect ()->SetColor (Quantity_NOC_YELLOW); anAspect->TextAspect ()->SetColor (Quantity_NOC_YELLOW);
anAngleDimension->SetDimensionAspect (anAspect); anAngleDimension->SetDimensionAspect (anAspect);
// Another position of dimension // Another position of dimension

View File

@ -14,10 +14,10 @@ vpoint lengthP2 50 50 50
vdim -length -name=dim1 -plane=xoy lengthP1 lengthP2 vdim -length -name=dim1 -plane=xoy lengthP1 lengthP2
vdisplay dim1 vdisplay dim1
vfit vfit
vmoveto 82 268 vmoveto 82 254
set x_coord 337 set x_coord 362
set y_coord 130 set y_coord 102
checkcolor $x_coord $y_coord 0 1 1 checkcolor $x_coord $y_coord 0 1 1
if { $stat != 1 } { if { $stat != 1 } {
puts "Error : Highlighting of length dimension is wrong." puts "Error : Highlighting of length dimension is wrong."

View File

@ -25,14 +25,15 @@ checkcolor $x_coord $y_coord 0 1 1
if { $stat != 1 } { if { $stat != 1 } {
puts "Error : Highlighting of angle dimension with 2d text is wrong." 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 vdim -angle -name=dim2 -text=3d angleP1 angleP2 angleP3
vdisplay dim2 vdisplay dim2
vfit vfit
vmoveto 263 251 vmoveto 263 251
set x_coord 332 set x_coord 335
set y_coord 326 set y_coord 319
checkcolor $x_coord $y_coord 0 1 1 checkcolor $x_coord $y_coord 0 1 1

View File

@ -14,13 +14,13 @@ vpoint radP2 50 50 0
vpoint radP3 100 0 0 vpoint radP3 100 0 0
vcircle circle radP1 radP2 radP3 0 vcircle circle radP1 radP2 radP3 0
verase radP1 radP2 radP3 verase radP1 radP2 radP3
vdim -radius -name=dim3 circle vdim -radius -name=dim1 circle
vdisplay dim3 vdisplay dim1
vfit vfit
vmoveto 102 144 vmoveto 123 158
set x_coord 172 set x_coord 112
set y_coord 186 set y_coord 151
checkcolor $x_coord $y_coord 0 1 1 checkcolor $x_coord $y_coord 0 1 1
@ -28,14 +28,15 @@ if { $stat != 1 } {
puts "Error : Highlighting of radius dimension with 2d text is wrong." puts "Error : Highlighting of radius dimension with 2d text is wrong."
} }
verase dim3 vinit Viewer2/View2
vdim -radius -name=dim3 -text=3d circle vdisplay circle
vdisplay dim3 vdim -radius -name=dim2 -text=3d circle
vdisplay dim2
vfit vfit
vmoveto 102 144 vmoveto 191 196
set x_coord 172 set x_coord 129
set y_coord 186 set y_coord 172
checkcolor $x_coord $y_coord 0 1 1 checkcolor $x_coord $y_coord 0 1 1

View File

@ -14,8 +14,8 @@ vpoint diamP2 50 50 0
vpoint diamP3 100 0 0 vpoint diamP3 100 0 0
vcircle circle diamP1 diamP2 diamP3 0 vcircle circle diamP1 diamP2 diamP3 0
verase diamP1 diamP2 diamP3 verase diamP1 diamP2 diamP3
vdim -diam -name=dim4 circle vdim -diam -name=dim1 circle
vdisplay dim4 vdisplay dim1
vfit vfit
vmoveto 208 205 vmoveto 208 205
@ -28,9 +28,10 @@ if { $stat != 1 } {
puts "Error : Highlighting of diameter dimension with 2d text is wrong." puts "Error : Highlighting of diameter dimension with 2d text is wrong."
} }
verase dim4 vinit Viewer2/View2
vdim -diam -name=dim4 -text=3d circle vdisplay circle
vdisplay dim4 vdim -diam -name=dim2 -text=3d circle
vdisplay dim2
vfit vfit
vmoveto 208 205 vmoveto 208 205

View File

@ -20,10 +20,10 @@ verase radP1 radP2 radP3
vdim -radius -name=dim -text=3d circle vdim -radius -name=dim -text=3d circle
vdisplay dim vdisplay dim
vfit vfit
vmoveto 102 144 vmoveto 110 111
set x_coord 153 set x_coord 196
set y_coord 153 set y_coord 196
checkcolor $x_coord $y_coord 0 1 1 checkcolor $x_coord $y_coord 0 1 1
if { $stat != 1 } { if { $stat != 1 } {
@ -33,10 +33,10 @@ if { $stat != 1 } {
# X axis rotation # X axis rotation
vrotate $m_pi 0 0 vrotate $m_pi 0 0
vfit vfit
vmoveto 201 206 vmoveto 208 200
set x_coord 269 set x_coord 295
set y_coord 123 set y_coord 113
checkcolor $x_coord $y_coord 0 1 1 checkcolor $x_coord $y_coord 0 1 1
if { $stat != 1 } { if { $stat != 1 } {

View File

@ -20,10 +20,10 @@ verase radP1 radP2 radP3
vdim -radius -name=dim -text=3d circle vdim -radius -name=dim -text=3d circle
vdisplay dim vdisplay dim
vfit vfit
vmoveto 102 144 vmoveto 110 111
set x_coord 153 set x_coord 196
set y_coord 153 set y_coord 196
checkcolor $x_coord $y_coord 0 1 1 checkcolor $x_coord $y_coord 0 1 1
if { $stat != 1 } { if { $stat != 1 } {
@ -33,10 +33,10 @@ if { $stat != 1 } {
# Y axis rotation # Y axis rotation
vrotate 0 $m_pi 0 vrotate 0 $m_pi 0
vfit vfit
vmoveto 205 205 vmoveto 185 246
set x_coord 96 set x_coord 113
set y_coord 296 set y_coord 294
checkcolor $x_coord $y_coord 0 1 1 checkcolor $x_coord $y_coord 0 1 1
if { $stat != 1 } { if { $stat != 1 } {

View File

@ -20,10 +20,10 @@ verase radP1 radP2 radP3
vdim -radius -name=dim -text=3d circle vdim -radius -name=dim -text=3d circle
vdisplay dim vdisplay dim
vfit vfit
vmoveto 102 144 vmoveto 110 111
set x_coord 153 set x_coord 196
set y_coord 153 set y_coord 196
checkcolor $x_coord $y_coord 0 1 1 checkcolor $x_coord $y_coord 0 1 1
if { $stat != 1 } { if { $stat != 1 } {
@ -33,10 +33,10 @@ if { $stat != 1 } {
# Z axis rotation # Z axis rotation
vrotate 0 0 $m_pi vrotate 0 0 $m_pi
vfit vfit
vmoveto 176 184 vmoveto 221 217
set x_coord 294 set x_coord 209
set y_coord 257 set y_coord 208
checkcolor $x_coord $y_coord 0 1 1 checkcolor $x_coord $y_coord 0 1 1
if { $stat != 1 } { if { $stat != 1 } {