mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-03 17:56:21 +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:
parent
938d454409
commit
d7bffd44ea
@ -21,107 +21,57 @@
|
||||
#include <AIS_AngleDimension.hxx>
|
||||
|
||||
#include <AIS.hxx>
|
||||
#include <AIS_Dimension.hxx>
|
||||
#include <AIS_DimensionOwner.hxx>
|
||||
#include <AIS_Drawer.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
#include <BRepAdaptor_Surface.hxx>
|
||||
#include <BRepLib_MakeVertex.hxx>
|
||||
|
||||
#include <DsgPrs.hxx>
|
||||
#include <DsgPrs_AnglePresentation.hxx>
|
||||
|
||||
#include <ElCLib.hxx>
|
||||
#include <ElSLib.hxx>
|
||||
|
||||
#include <GC_MakeCircle.hxx>
|
||||
#include <GC_MakeConicalSurface.hxx>
|
||||
#include <gce_MakeLin.hxx>
|
||||
#include <gce_MakeLin2d.hxx>
|
||||
#include <gce_MakePln.hxx>
|
||||
#include <gce_MakeCirc.hxx>
|
||||
#include <gce_MakeCone.hxx>
|
||||
#include <Geom2d_Circle.hxx>
|
||||
#include <Geom2d_Curve.hxx>
|
||||
#include <Geom2d_Line.hxx>
|
||||
#include <Geom2dAPI_ExtremaCurveCurve.hxx>
|
||||
#include <GeomAPI.hxx>
|
||||
#include <Geom_Circle.hxx>
|
||||
#include <Geom_Line.hxx>
|
||||
#include <Geom_Plane.hxx>
|
||||
#include <Geom_TrimmedCurve.hxx>
|
||||
#include <Geom_Surface.hxx>
|
||||
#include <Geom_CylindricalSurface.hxx>
|
||||
#include <Geom_ConicalSurface.hxx>
|
||||
#include <Geom_SurfaceOfRevolution.hxx>
|
||||
#include <Geom_SurfaceOfLinearExtrusion.hxx>
|
||||
#include <Geom_OffsetSurface.hxx>
|
||||
#include <GeomAPI_ExtremaCurveCurve.hxx>
|
||||
#include <Graphic3d_ArrayOfSegments.hxx>
|
||||
#include <Graphic3d_AspectLine3d.hxx>
|
||||
#include <gp.hxx>
|
||||
#include <gp_Ax1.hxx>
|
||||
#include <gp_Lin.hxx>
|
||||
#include <gp_Cone.hxx>
|
||||
#include <gp_Pln.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <gp_XYZ.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_ArrayOfPrimitives.hxx>
|
||||
#include <Graphic3d_ArrayOfPolylines.hxx>
|
||||
|
||||
#include <IntAna2d_AnaIntersection.hxx>
|
||||
#include <IntAna2d_IntPoint.hxx>
|
||||
#include <IntAna_QuadQuadGeo.hxx>
|
||||
#include <IntAna_ResultType.hxx>
|
||||
#include <Poly_Polygon3D.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <ProjLib.hxx>
|
||||
#include <Prs3d_ArrowAspect.hxx>
|
||||
#include <Prs3d_DimensionAspect.hxx>
|
||||
#include <Prs3d_Drawer.hxx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <Prs3d_ShadingAspect.hxx>
|
||||
#include <PrsMgr_PresentationManager3d.hxx>
|
||||
#include <Select3D_SensitiveCurve.hxx>
|
||||
#include <Select3D_SensitiveGroup.hxx>
|
||||
#include <Select3D_SensitiveSegment.hxx>
|
||||
#include <SelectMgr_Selection.hxx>
|
||||
#include <Standard_NotImplemented.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
#include <Standard_Macro.hxx>
|
||||
#include <Standard_DefineHandle.hxx>
|
||||
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <UnitsAPI.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_HANDLE (AIS_AngleDimension, AIS_Dimension)
|
||||
IMPLEMENT_STANDARD_RTTIEXT (AIS_AngleDimension, AIS_Dimension)
|
||||
|
||||
namespace
|
||||
{
|
||||
static const TCollection_ExtendedString THE_EMPTY_LABEL;
|
||||
static const Standard_ExtCharacter THE_DEGREE_SYMBOL (0x00B0);
|
||||
};
|
||||
|
||||
//=======================================================================
|
||||
//function : init
|
||||
//purpose : Private constructor for default initialization
|
||||
//=======================================================================
|
||||
|
||||
void AIS_AngleDimension::init()
|
||||
{
|
||||
SetKindOfDimension (AIS_KOD_PLANEANGLE);
|
||||
SetFlyout (15.0);
|
||||
// Default values of units
|
||||
UnitsAPI::SetLocalSystem (UnitsAPI_SI);
|
||||
SetUnitsQuantity ("PLANE ANGLE");
|
||||
SetModelUnits ("rad");
|
||||
SetDisplayUnits ("deg");
|
||||
SetSpecialSymbol (0x00B0);
|
||||
SetSpecialSymbol (THE_DEGREE_SYMBOL);
|
||||
SetDisplaySpecialSymbol (AIS_DSS_After);
|
||||
SetFlyout (15.0);
|
||||
SetKindOfDimension (AIS_KOD_PLANEANGLE);
|
||||
MakeUnitsDisplayed (Standard_False);
|
||||
}
|
||||
|
||||
@ -129,7 +79,6 @@ void AIS_AngleDimension::init()
|
||||
//function : Constructor
|
||||
//purpose : Two edges dimension
|
||||
//=======================================================================
|
||||
|
||||
AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
|
||||
const TopoDS_Edge& theSecondEdge)
|
||||
: AIS_Dimension(),
|
||||
@ -137,8 +86,8 @@ AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
|
||||
{
|
||||
init();
|
||||
myShapesNumber = 2;
|
||||
myFirstShape = theFirstEdge;
|
||||
mySecondShape = theSecondEdge;
|
||||
myFirstShape = theFirstEdge;
|
||||
mySecondShape = theSecondEdge;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -146,7 +95,6 @@ AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
|
||||
//purpose : Two edges dimension
|
||||
// <thePlane> is used in case of Angle=PI
|
||||
//=======================================================================
|
||||
|
||||
AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
|
||||
const TopoDS_Edge& theSecondEdge,
|
||||
const gp_Pln& thePlane)
|
||||
@ -155,28 +103,8 @@ AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
|
||||
{
|
||||
init();
|
||||
myShapesNumber = 2;
|
||||
myFirstShape = theFirstEdge;
|
||||
mySecondShape = theSecondEdge;
|
||||
SetWorkingPlane (thePlane);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose : Two edges dimension with aspect
|
||||
// <thePlane> is used in case of Angle=PI
|
||||
//=======================================================================
|
||||
|
||||
AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
|
||||
const TopoDS_Edge& theSecondEdge,
|
||||
const gp_Pln& thePlane,
|
||||
const Handle(Prs3d_DimensionAspect)& theDimensionAspect,
|
||||
const Standard_Real theExtensionSize)
|
||||
: AIS_Dimension (theDimensionAspect,theExtensionSize),
|
||||
myIsFlyoutLines (Standard_True)
|
||||
{
|
||||
myShapesNumber = 2;
|
||||
myFirstShape = theFirstEdge;
|
||||
mySecondShape = theSecondEdge;
|
||||
myFirstShape = theFirstEdge;
|
||||
mySecondShape = theSecondEdge;
|
||||
SetWorkingPlane (thePlane);
|
||||
}
|
||||
|
||||
@ -184,7 +112,6 @@ AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
|
||||
//function : Constructor
|
||||
//purpose : Three points dimension
|
||||
//=======================================================================
|
||||
|
||||
AIS_AngleDimension::AIS_AngleDimension (const gp_Pnt& theFirstPoint,
|
||||
const gp_Pnt& theSecondPoint,
|
||||
const gp_Pnt& theThirdPoint)
|
||||
@ -193,52 +120,30 @@ AIS_AngleDimension::AIS_AngleDimension (const gp_Pnt& theFirstPoint,
|
||||
{
|
||||
init();
|
||||
myIsInitialized = Standard_True;
|
||||
myFirstPoint = theFirstPoint;
|
||||
myCenter = theSecondPoint;
|
||||
mySecondPoint = theThirdPoint;
|
||||
myShapesNumber = 3;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose : Three points dimension
|
||||
//=======================================================================
|
||||
|
||||
AIS_AngleDimension::AIS_AngleDimension (const gp_Pnt& theFirstPoint,
|
||||
const gp_Pnt& theSecondPoint,
|
||||
const gp_Pnt& theThirdPoint,
|
||||
const Handle(Prs3d_DimensionAspect)& theDimensionAspect,
|
||||
const Standard_Real theExtensionSize)
|
||||
: AIS_Dimension (theDimensionAspect,theExtensionSize),
|
||||
myIsFlyoutLines (Standard_True)
|
||||
{
|
||||
myIsInitialized = Standard_True;
|
||||
myFirstPoint = theFirstPoint;
|
||||
myCenter = theSecondPoint;
|
||||
mySecondPoint = theThirdPoint;
|
||||
myShapesNumber =3;
|
||||
myFirstPoint = theFirstPoint;
|
||||
myCenter = theSecondPoint;
|
||||
mySecondPoint = theThirdPoint;
|
||||
myShapesNumber = 3;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose : Cone dimension
|
||||
//=======================================================================
|
||||
|
||||
AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Face& theCone)
|
||||
: AIS_Dimension(),
|
||||
myIsFlyoutLines (Standard_True)
|
||||
{
|
||||
init();
|
||||
myIsInitialized = Standard_False;
|
||||
myFirstShape = theCone;
|
||||
myShapesNumber = 1;
|
||||
myFirstShape = theCone;
|
||||
myShapesNumber = 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose : Two faces dimension
|
||||
//=======================================================================
|
||||
|
||||
AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Face& theFirstFace,
|
||||
const TopoDS_Face& theSecondFace,
|
||||
const gp_Ax1& theAxis)
|
||||
@ -247,9 +152,9 @@ AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Face& theFirstFace,
|
||||
{
|
||||
init();
|
||||
myIsInitialized = Standard_False;
|
||||
myFirstShape = theFirstFace;
|
||||
mySecondShape = theSecondFace;
|
||||
myShapesNumber = 2;
|
||||
myFirstShape = theFirstFace;
|
||||
mySecondShape = theSecondFace;
|
||||
myShapesNumber = 2;
|
||||
gp_Pln aPlane;
|
||||
aPlane.SetAxis (theAxis);
|
||||
SetWorkingPlane (aPlane);
|
||||
@ -259,7 +164,6 @@ AIS_AngleDimension::AIS_AngleDimension (const TopoDS_Face& theFirstFace,
|
||||
//function : SetFirstShape
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void AIS_AngleDimension::SetFirstShape (const TopoDS_Shape& theShape,
|
||||
const Standard_Boolean isSingleShape /*= Standard_False*/)
|
||||
{
|
||||
@ -275,7 +179,6 @@ void AIS_AngleDimension::SetFirstShape (const TopoDS_Shape& theShape,
|
||||
// <theCMax> centers;
|
||||
// -1 if <theC> center is below <theCMax> center.
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer AIS_AngleDimension::aboveInBelowCone (const gp_Circ &theCMax,
|
||||
const gp_Circ &theCMin,
|
||||
const gp_Circ &theC)
|
||||
@ -294,7 +197,6 @@ Standard_Integer AIS_AngleDimension::aboveInBelowCone (const gp_Circ &theCMax,
|
||||
//function : initConeAngle
|
||||
//purpose : initialization of the cone angle
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean AIS_AngleDimension::initConeAngle (const TopoDS_Face& theCone)
|
||||
{
|
||||
if (theCone.IsNull ())
|
||||
@ -397,7 +299,6 @@ Standard_Boolean AIS_AngleDimension::initConeAngle (const TopoDS_Face& theCone)
|
||||
//function : initTwoFacesAngle
|
||||
//purpose : initialization of angle dimension between two faces
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean AIS_AngleDimension::initTwoFacesAngle ()
|
||||
{
|
||||
TopoDS_Face aFirstFace = TopoDS::Face (myFirstShape);
|
||||
@ -458,7 +359,6 @@ Standard_Boolean AIS_AngleDimension::initTwoFacesAngle ()
|
||||
//function : countDefaultPlane
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void AIS_AngleDimension::countDefaultPlane ()
|
||||
{
|
||||
if (!myIsInitialized)
|
||||
@ -475,7 +375,6 @@ void AIS_AngleDimension::countDefaultPlane ()
|
||||
//function : computeValue
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void AIS_AngleDimension::computeValue ()
|
||||
{
|
||||
gp_Vec aVec1 (myCenter, myFirstPoint),
|
||||
@ -491,7 +390,6 @@ void AIS_AngleDimension::computeValue ()
|
||||
// If intersection between two edges doesn't exist
|
||||
// <myIsInitialized> is set to false
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean AIS_AngleDimension::initTwoEdgesAngle ()
|
||||
{
|
||||
// Data initialization
|
||||
@ -636,21 +534,6 @@ Standard_Boolean AIS_AngleDimension::initTwoEdgesAngle ()
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : canTextBeInCenter
|
||||
//purpose : Auxiliary method to arrange text and arrows
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean AIS_AngleDimension::canTextBeInCenter (const gp_Pnt& theFirstAttach,
|
||||
const gp_Pnt& theSecondAttach,
|
||||
const Quantity_Length& theTextLength,
|
||||
const Quantity_Length& theArrowLength)
|
||||
{
|
||||
gp_Vec anAttachVector (theFirstAttach, theSecondAttach);
|
||||
Standard_Real aValue = anAttachVector.Magnitude();
|
||||
return (aValue < theTextLength + 2.*theArrowLength) ? Standard_False : Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function: getCenterOnArc
|
||||
//purpose :
|
||||
@ -685,12 +568,12 @@ gp_Pnt AIS_AngleDimension::getCenterOnArc (const gp_Pnt& theFirstAttach,
|
||||
//function: drawArcWithText
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void AIS_AngleDimension::drawArcWithText (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const gp_Pnt& theFirstAttach,
|
||||
const gp_Pnt& theSecondAttach,
|
||||
const TCollection_ExtendedString& theText,
|
||||
const AIS_DimensionDisplayMode theMode)
|
||||
const AIS_DimensionDisplayMode theMode,
|
||||
const Standard_Integer theLabelPosition)
|
||||
{
|
||||
gp_Pnt2d aCenter2d = ProjLib::Project (GetWorkingPlane(), myCenter),
|
||||
aFirstAttach2d = ProjLib::Project (GetWorkingPlane(), theFirstAttach),
|
||||
@ -717,7 +600,8 @@ void AIS_AngleDimension::drawArcWithText (const Handle(Prs3d_Presentation)& theP
|
||||
gp_Vec aVec (theFirstAttach, theSecondAttach);
|
||||
Standard_Real aTextWidth = drawText (thePresentation,
|
||||
myIsTextReversed ? aVec.Reversed() : aVec,
|
||||
theText,theMode);
|
||||
theText, theMode,
|
||||
theLabelPosition);
|
||||
|
||||
// Getting text begin and end points
|
||||
gp_Pnt2d aTextBeginPnt = ElCLib::Value ((ElCLib::Parameter (anAttachLine2d, aFirstAttach2d) +
|
||||
@ -750,14 +634,12 @@ void AIS_AngleDimension::drawArcWithText (const Handle(Prs3d_Presentation)& theP
|
||||
drawArc (thePresentation, theFirstAttach, aTextBeginOnArc, myCenter, aRadius, theMode);
|
||||
drawArc (thePresentation, aTextEndOnArc, theSecondAttach, myCenter, aRadius, theMode);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : drawArc
|
||||
//purpose : draws the arc between two attach points
|
||||
//=======================================================================
|
||||
|
||||
void AIS_AngleDimension::drawArc (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const gp_Pnt& theFirstAttach,
|
||||
const gp_Pnt& theSecondAttach,
|
||||
@ -766,8 +648,6 @@ void AIS_AngleDimension::drawArc (const Handle(Prs3d_Presentation)& thePresentat
|
||||
const AIS_DimensionDisplayMode theMode)
|
||||
{
|
||||
Handle(SelectMgr_EntityOwner) anEmptyOwner;
|
||||
Prs3d_Root::CurrentGroup (thePresentation)->
|
||||
SetPrimitivesAspect(myDrawer->DimensionAspect()->LineAspect()->Aspect());
|
||||
|
||||
gp_Vec aCenterToFirstVec (theCenter,theFirstAttach);
|
||||
gp_Vec aCenterToSecondVec (theCenter,theSecondAttach);
|
||||
@ -803,6 +683,8 @@ void AIS_AngleDimension::drawArc (const Handle(Prs3d_Presentation)& thePresentat
|
||||
{
|
||||
Prs3d_Root::CurrentGroup (thePresentation)->SetStencilTestOptions (Standard_True);
|
||||
}
|
||||
Handle(Graphic3d_AspectLine3d) aDimensionLineStyle = myDrawer->DimensionAspect()->LineAspect()->Aspect();
|
||||
Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionLineStyle);
|
||||
Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments);
|
||||
if (!myDrawer->DimensionAspect()->IsText3d() && theMode == AIS_DDM_All)
|
||||
{
|
||||
@ -814,7 +696,6 @@ void AIS_AngleDimension::drawArc (const Handle(Prs3d_Presentation)& thePresentat
|
||||
//function : Compute
|
||||
//purpose : Having three gp_Pnt points compute presentation
|
||||
//=======================================================================
|
||||
|
||||
void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePM*/,
|
||||
const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const Standard_Integer theMode)
|
||||
@ -857,139 +738,234 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*
|
||||
|
||||
// Parameters for presentation
|
||||
Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
|
||||
Prs3d_Root::CurrentGroup(thePresentation)->
|
||||
SetPrimitivesAspect(aDimensionAspect->LineAspect()->Aspect());
|
||||
|
||||
Prs3d_Root::CurrentGroup(thePresentation)->SetPrimitivesAspect(aDimensionAspect->LineAspect()->Aspect());
|
||||
|
||||
Quantity_Length anArrowLength = aDimensionAspect->ArrowAspect()->Length();
|
||||
|
||||
if (!myIsValueCustom)
|
||||
computeValue ();
|
||||
{
|
||||
computeValue();
|
||||
}
|
||||
|
||||
TCollection_ExtendedString aValueString;
|
||||
Standard_Real aTextLength;
|
||||
getTextWidthAndString (aTextLength, aValueString);
|
||||
|
||||
if (!myIsWorkingPlaneCustom)
|
||||
{
|
||||
countDefaultPlane();
|
||||
}
|
||||
|
||||
gp_Pnt aFirstAttach = myCenter.Translated (gp_Vec(myCenter, myFirstPoint).Normalized() * GetFlyout());
|
||||
gp_Pnt aSecondAttach = myCenter.Translated (gp_Vec(myCenter, mySecondPoint).Normalized() * GetFlyout());
|
||||
// Attach points and radius
|
||||
if (aDimensionAspect->HorizontalTextAlignment () == Prs3d_HTA_Center)
|
||||
{
|
||||
aDimensionAspect->SetArrowOrientation (Prs3d_DAO_Internal);
|
||||
|
||||
if (!canTextBeInCenter (aFirstAttach, aSecondAttach, aTextLength, anArrowLength))
|
||||
// Handle user-defined and automatic arrow placement
|
||||
bool isArrowsExternal = false;
|
||||
switch (aDimensionAspect->ArrowOrientation())
|
||||
{
|
||||
case Prs3d_DAO_External: isArrowsExternal = true; break;
|
||||
case Prs3d_DAO_Internal: isArrowsExternal = false; break;
|
||||
case Prs3d_DAO_Fit:
|
||||
{
|
||||
aDimensionAspect->SetArrowOrientation (Prs3d_DAO_External);
|
||||
aDimensionAspect->SetHorizontalTextAlignment (Prs3d_HTA_Left);
|
||||
gp_Vec anAttachVector (aFirstAttach, aSecondAttach);
|
||||
Standard_Real aDimensionWidth = anAttachVector.Magnitude();
|
||||
Standard_Real anArrowsWidth = anArrowLength * 2.0;
|
||||
|
||||
isArrowsExternal = aDimensionWidth < aTextLength + anArrowsWidth;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
aDimensionAspect->SetArrowOrientation (Prs3d_DAO_External);
|
||||
|
||||
//Arrows positions and directions
|
||||
gp_Vec aFirstArrowVec = (gp_Vec(myCenter, aFirstAttach)^gp_Vec(GetWorkingPlane().Axis().Direction())).Normalized().Reversed()*anArrowLength;
|
||||
gp_Vec aSecondArrowVec = (gp_Vec(myCenter, aSecondAttach)^gp_Vec(GetWorkingPlane().Axis().Direction())).Normalized()*anArrowLength;
|
||||
gp_Vec aWPDir = gp_Vec (GetWorkingPlane().Axis().Direction());
|
||||
|
||||
gp_Pnt aFirstArrowBegin,
|
||||
aFirstArrowEnd,
|
||||
aSecondArrowBegin,
|
||||
aSecondArrowEnd;
|
||||
gp_Dir aFirstExtensionDir = gp_Vec (myCenter, aFirstAttach) ^ aWPDir;
|
||||
gp_Dir aSecondExtensionDir = gp_Vec (myCenter, aSecondAttach)^ aWPDir.Reversed();
|
||||
|
||||
if (aDimensionAspect->GetArrowOrientation() == Prs3d_DAO_External)
|
||||
gp_Vec aFirstArrowVec = gp_Vec (aFirstExtensionDir) * anArrowLength;
|
||||
gp_Vec aSecondArrowVec = gp_Vec (aSecondExtensionDir) * anArrowLength;
|
||||
|
||||
gp_Pnt aFirstArrowBegin (0.0, 0.0, 0.0);
|
||||
gp_Pnt aFirstArrowEnd (0.0, 0.0, 0.0);
|
||||
gp_Pnt aSecondArrowBegin (0.0, 0.0, 0.0);
|
||||
gp_Pnt aSecondArrowEnd (0.0, 0.0, 0.0);
|
||||
|
||||
if (isArrowsExternal)
|
||||
{
|
||||
aFirstArrowVec.Reverse();
|
||||
aSecondArrowVec.Reverse();
|
||||
|
||||
aFirstArrowBegin = aFirstAttach.Translated (aFirstArrowVec);
|
||||
aFirstArrowEnd = aFirstAttach;
|
||||
aSecondArrowBegin = aSecondAttach;
|
||||
aSecondArrowEnd = aSecondAttach.Translated (aSecondArrowVec);
|
||||
}
|
||||
else
|
||||
{
|
||||
aFirstArrowBegin = aFirstAttach;
|
||||
aFirstArrowEnd = aFirstAttach.Translated (aFirstArrowVec);
|
||||
aSecondArrowBegin = aSecondAttach.Translated (aSecondArrowVec);
|
||||
aSecondArrowEnd = aSecondAttach;
|
||||
}
|
||||
|
||||
// Fill presentation
|
||||
Handle(Graphic3d_ArrayOfSegments) aPrimSegments;
|
||||
Standard_Boolean isTextInCenter = aDimensionAspect->VerticalTextAlignment() == Prs3d_VTA_Center;
|
||||
if (aDimensionAspect->HorizontalTextAlignment() == Prs3d_HTA_Center)
|
||||
aFirstArrowBegin = aFirstAttach;
|
||||
aSecondArrowBegin = aSecondAttach;
|
||||
aFirstArrowEnd = aFirstAttach.Translated (-aFirstArrowVec);
|
||||
aSecondArrowEnd = aSecondAttach.Translated (-aSecondArrowVec);
|
||||
|
||||
Standard_Integer aLabelPosition = LabelPosition_None;
|
||||
|
||||
// Handle user-defined and automatic text placement
|
||||
switch (aDimensionAspect->TextHorizontalPosition())
|
||||
{
|
||||
// Important! Current implementation doesn't draw the extensions here
|
||||
aPrimSegments = new Graphic3d_ArrayOfSegments (4);
|
||||
// Get text begin and end positions (text is positioned in the center between two attach points)
|
||||
gp_Pnt aTextBeginOnArc, aTextEndOnArc, anArcCenter;
|
||||
if (isTextInCenter && aDimensionAspect->IsText3d())
|
||||
case Prs3d_DTHP_Left : aLabelPosition |= LabelPosition_Left; break;
|
||||
case Prs3d_DTHP_Right : aLabelPosition |= LabelPosition_Right; break;
|
||||
case Prs3d_DTHP_Center: aLabelPosition |= LabelPosition_HCenter; break;
|
||||
case Prs3d_DTHP_Fit:
|
||||
{
|
||||
drawArcWithText (thePresentation, aFirstAttach, aSecondAttach, aValueString, (AIS_DimensionDisplayMode)theMode);
|
||||
gp_Vec anAttachVector (aFirstAttach, aSecondAttach);
|
||||
Standard_Real aDimensionWidth = anAttachVector.Magnitude();
|
||||
Standard_Real anArrowsWidth = anArrowLength * 2.0;
|
||||
Standard_Real aContentWidth = isArrowsExternal ? aTextLength : aTextLength + anArrowsWidth;
|
||||
|
||||
aLabelPosition |= aDimensionWidth < aContentWidth ? LabelPosition_Left : LabelPosition_HCenter;
|
||||
break;
|
||||
}
|
||||
else
|
||||
}
|
||||
|
||||
switch (aDimensionAspect->TextVerticalPosition())
|
||||
{
|
||||
case Prs3d_DTVP_Above : aLabelPosition |= LabelPosition_Above; break;
|
||||
case Prs3d_DTVP_Below : aLabelPosition |= LabelPosition_Below; break;
|
||||
case Prs3d_DTVP_Center : aLabelPosition |= LabelPosition_VCenter; break;
|
||||
}
|
||||
|
||||
// Group1: stenciling text and the angle dimension arc
|
||||
Prs3d_Root::NewGroup (thePresentation);
|
||||
|
||||
Standard_Real anExtensionSize = aDimensionAspect->ExtensionSize();
|
||||
|
||||
Standard_Integer aHPosition = aLabelPosition & LabelPosition_HMask;
|
||||
|
||||
// draw text label
|
||||
switch (aHPosition)
|
||||
{
|
||||
case LabelPosition_HCenter :
|
||||
{
|
||||
Standard_Boolean isLineBreak = aDimensionAspect->TextVerticalPosition() == Prs3d_DTVP_Center
|
||||
&& aDimensionAspect->IsText3d();
|
||||
|
||||
if (isLineBreak)
|
||||
{
|
||||
drawArcWithText (thePresentation,
|
||||
aFirstAttach,
|
||||
aSecondAttach,
|
||||
aValueString,
|
||||
(AIS_DimensionDisplayMode)theMode,
|
||||
aLabelPosition);
|
||||
break;
|
||||
}
|
||||
|
||||
gp_Vec aTextDir (aFirstArrowEnd, aSecondArrowBegin);
|
||||
myGeom.myTextPosition = getCenterOnArc (aFirstArrowEnd, aSecondArrowBegin);
|
||||
|
||||
drawText (thePresentation,
|
||||
myIsTextReversed ? aTextDir.Reversed() : aTextDir,
|
||||
aValueString, (AIS_DimensionDisplayMode)theMode);
|
||||
if (theMode != AIS_DDM_Text)
|
||||
drawArc (thePresentation, aFirstArrowEnd, aSecondArrowBegin, myCenter, Abs (GetFlyout()), (AIS_DimensionDisplayMode)theMode);
|
||||
aValueString,
|
||||
(AIS_DimensionDisplayMode)theMode,
|
||||
aLabelPosition);
|
||||
|
||||
if (theMode == AIS_DDM_Text)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
drawArc (thePresentation,
|
||||
isArrowsExternal ? aFirstAttach : aFirstArrowEnd,
|
||||
isArrowsExternal ? aSecondAttach : aSecondArrowEnd,
|
||||
myCenter,
|
||||
Abs (GetFlyout()),
|
||||
(AIS_DimensionDisplayMode)theMode);
|
||||
}
|
||||
break;
|
||||
|
||||
case LabelPosition_Left :
|
||||
{
|
||||
drawExtension (thePresentation,
|
||||
anExtensionSize,
|
||||
isArrowsExternal ? aFirstArrowEnd : aFirstAttach,
|
||||
aFirstExtensionDir,
|
||||
aValueString,
|
||||
(AIS_DimensionDisplayMode)theMode,
|
||||
aLabelPosition);
|
||||
}
|
||||
break;
|
||||
|
||||
case LabelPosition_Right :
|
||||
{
|
||||
drawExtension (thePresentation,
|
||||
anExtensionSize,
|
||||
isArrowsExternal ? aSecondArrowEnd : aSecondAttach,
|
||||
aSecondExtensionDir,
|
||||
aValueString,
|
||||
(AIS_DimensionDisplayMode)theMode,
|
||||
aLabelPosition);
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
||||
// dimension arc without text
|
||||
if (theMode != AIS_DDM_Text && aHPosition != LabelPosition_HCenter)
|
||||
{
|
||||
// Lines for extensions
|
||||
gp_Lin aLeftExtension (aFirstAttach,gp_Dir(aFirstArrowVec));
|
||||
gp_Lin aRightExtension (aSecondAttach, gp_Dir(aSecondArrowVec));
|
||||
aPrimSegments = new Graphic3d_ArrayOfSegments (6);
|
||||
gp_Pnt aStartPoint;
|
||||
if (aDimensionAspect->HorizontalTextAlignment() == Prs3d_HTA_Left)
|
||||
{
|
||||
aStartPoint = aFirstArrowBegin;
|
||||
// Short extension
|
||||
aPrimSegments->AddVertex (aSecondArrowEnd);
|
||||
aPrimSegments->AddVertex (aSecondArrowEnd.Translated(gp_Vec(aRightExtension.Direction())*anArrowLength));
|
||||
myGeom.mySensitiveSegments.Append (new Select3D_SensitiveSegment(anEmptyOwner,
|
||||
aSecondArrowEnd,
|
||||
aSecondArrowEnd.Translated(gp_Vec(aRightExtension.Direction())*anArrowLength)));
|
||||
Prs3d_Root::NewGroup (thePresentation);
|
||||
|
||||
// Long extension
|
||||
drawExtensionWithText (thePresentation, aStartPoint, aLeftExtension, aValueString, (AIS_DimensionDisplayMode)theMode);
|
||||
}
|
||||
else // Prs3d_HTA_Right
|
||||
{
|
||||
aStartPoint = aSecondArrowEnd;
|
||||
// Short extension
|
||||
aPrimSegments->AddVertex (aFirstArrowBegin);
|
||||
aPrimSegments->AddVertex (aFirstArrowBegin.Translated (gp_Vec (aLeftExtension.Direction()) * anArrowLength));
|
||||
myGeom.mySensitiveSegments.Append (new Select3D_SensitiveSegment(anEmptyOwner,
|
||||
aFirstArrowBegin,
|
||||
aFirstArrowBegin.Translated (gp_Vec (aLeftExtension.Direction()) * anArrowLength)));
|
||||
drawArc (thePresentation,
|
||||
isArrowsExternal ? aFirstAttach : aFirstArrowEnd,
|
||||
isArrowsExternal ? aSecondAttach : aSecondArrowEnd,
|
||||
myCenter,
|
||||
Abs(GetFlyout ()),
|
||||
(AIS_DimensionDisplayMode)theMode);
|
||||
}
|
||||
|
||||
// Long extension
|
||||
drawExtensionWithText (thePresentation, aStartPoint, aRightExtension, aValueString, (AIS_DimensionDisplayMode)theMode);
|
||||
// arrows and arrow extensions
|
||||
if (theMode != AIS_DDM_Text)
|
||||
{
|
||||
Prs3d_Root::NewGroup (thePresentation);
|
||||
|
||||
drawArrow (thePresentation, aFirstArrowBegin, gp_Dir (aFirstArrowVec));
|
||||
drawArrow (thePresentation, aSecondArrowBegin, gp_Dir (aSecondArrowVec));
|
||||
}
|
||||
|
||||
if (theMode != AIS_DDM_Text && isArrowsExternal)
|
||||
{
|
||||
Prs3d_Root::NewGroup (thePresentation);
|
||||
|
||||
if (aHPosition != LabelPosition_Left)
|
||||
{
|
||||
drawExtension (thePresentation,
|
||||
anExtensionSize,
|
||||
aFirstArrowEnd,
|
||||
aFirstExtensionDir,
|
||||
THE_EMPTY_LABEL,
|
||||
(AIS_DimensionDisplayMode)theMode,
|
||||
LabelPosition_None);
|
||||
}
|
||||
|
||||
if (theMode != AIS_DDM_Text)
|
||||
if (aHPosition != LabelPosition_Right)
|
||||
{
|
||||
// Draw main arc
|
||||
drawArc (thePresentation, aFirstArrowEnd, aSecondArrowBegin, myCenter, Abs(GetFlyout ()), (AIS_DimensionDisplayMode)theMode);
|
||||
drawExtension (thePresentation,
|
||||
anExtensionSize,
|
||||
aSecondArrowEnd,
|
||||
aSecondExtensionDir,
|
||||
THE_EMPTY_LABEL,
|
||||
(AIS_DimensionDisplayMode)theMode,
|
||||
LabelPosition_None);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw flyout lines and arrows in new group.
|
||||
Prs3d_Root::NewGroup (thePresentation)
|
||||
->SetPrimitivesAspect (myDrawer->DimensionAspect()->LineAspect()->Aspect());
|
||||
// flyouts
|
||||
if (theMode == AIS_DDM_All && myIsFlyoutLines)
|
||||
{
|
||||
Prs3d_Root::NewGroup (thePresentation);
|
||||
|
||||
Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (4);
|
||||
aPrimSegments->AddVertex (myCenter);
|
||||
aPrimSegments->AddVertex (aFirstAttach);
|
||||
aPrimSegments->AddVertex (myCenter);
|
||||
aPrimSegments->AddVertex (aSecondAttach);
|
||||
}
|
||||
if (theMode != AIS_DDM_Text)
|
||||
{
|
||||
|
||||
Handle(Graphic3d_AspectLine3d) aFlyoutStyle = myDrawer->DimensionAspect()->LineAspect()->Aspect();
|
||||
Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aFlyoutStyle);
|
||||
Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments);
|
||||
drawArrow (thePresentation, aFirstAttach, gp_Dir (aFirstArrowVec));
|
||||
drawArrow (thePresentation, aSecondAttach, gp_Dir (aSecondArrowVec));
|
||||
}
|
||||
|
||||
setComputed (Standard_True);
|
||||
@ -999,12 +975,13 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*
|
||||
//function : computeFlyoutSelection
|
||||
//purpose : computes selection for flyouts
|
||||
//=======================================================================
|
||||
|
||||
void AIS_AngleDimension::computeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
|
||||
const Handle(AIS_DimensionOwner)& theOwner)
|
||||
{
|
||||
if (!myIsFlyoutLines)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
gp_Pnt aFirstAttach = myCenter.Translated (gp_Vec (myCenter, myFirstPoint).Normalized() * GetFlyout());
|
||||
gp_Pnt aSecondAttach = myCenter.Translated (gp_Vec (myCenter, mySecondPoint).Normalized() * GetFlyout());
|
||||
@ -1012,4 +989,4 @@ void AIS_AngleDimension::computeFlyoutSelection (const Handle(SelectMgr_Selectio
|
||||
aSensitiveEntity->Add (new Select3D_SensitiveSegment (theOwner, myCenter, aFirstAttach));
|
||||
aSensitiveEntity->Add (new Select3D_SensitiveSegment (theOwner, myCenter, aSecondAttach));
|
||||
theSelection->Add (aSensitiveEntity);
|
||||
}
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ DEFINE_STANDARD_HANDLE (AIS_AngleDimension, AIS_Dimension)
|
||||
class AIS_AngleDimension : public AIS_Dimension
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructs angle dimension between two edges
|
||||
//! with automatic working plane computing
|
||||
//! if it is possible. In case of PI angle please
|
||||
@ -63,28 +64,12 @@ public:
|
||||
Standard_EXPORT AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
|
||||
const TopoDS_Edge& theSecondEdge,
|
||||
const gp_Pln& thePlane);
|
||||
|
||||
//! Constructs the angle display object defined by the <br>
|
||||
//! two edges and custom working plane and dimension aspect.
|
||||
Standard_EXPORT AIS_AngleDimension (const TopoDS_Edge& theFirstEdge,
|
||||
const TopoDS_Edge& theSecondEdge,
|
||||
const gp_Pln& thePlane,
|
||||
const Handle(Prs3d_DimensionAspect)& theDimensionAspect,
|
||||
const Standard_Real theExtensionSize = 1.0);
|
||||
|
||||
//! Constructs the angle display object defined by three points.
|
||||
Standard_EXPORT AIS_AngleDimension (const gp_Pnt& theFirstPoint,
|
||||
const gp_Pnt& theSecondPoint,
|
||||
const gp_Pnt& theThirdPoint);
|
||||
|
||||
//! Constructs the angle display object defined by three points
|
||||
//! and dimension aspect that defines line, arrow and text aspect.
|
||||
Standard_EXPORT AIS_AngleDimension (const gp_Pnt& theFirstPoint,
|
||||
const gp_Pnt& theSecondPoint,
|
||||
const gp_Pnt& theThirdPoint,
|
||||
const Handle(Prs3d_DimensionAspect)& theDimensionAspect,
|
||||
const Standard_Real theExtensionSize = 1.0);
|
||||
|
||||
//! Angle of cone
|
||||
Standard_EXPORT AIS_AngleDimension (const TopoDS_Face& theCone);
|
||||
|
||||
@ -97,7 +82,9 @@ public:
|
||||
Standard_EXPORT void SetFirstShape (const TopoDS_Shape& theShape,
|
||||
const Standard_Boolean isSingleShape = Standard_False);
|
||||
|
||||
DEFINE_STANDARD_RTTI(AIS_AngleDimension)
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_RTTI (AIS_AngleDimension)
|
||||
|
||||
protected:
|
||||
|
||||
@ -120,7 +107,8 @@ protected:
|
||||
const gp_Pnt& theFirstAttach,
|
||||
const gp_Pnt& theSecondAttach,
|
||||
const TCollection_ExtendedString& theText,
|
||||
const AIS_DimensionDisplayMode theMode);
|
||||
const AIS_DimensionDisplayMode theMode,
|
||||
const Standard_Integer theLabelPosition);
|
||||
|
||||
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePM,
|
||||
const Handle(Prs3d_Presentation)& thePresentation,
|
||||
@ -141,12 +129,6 @@ protected:
|
||||
const gp_Circ &theCMin,
|
||||
const gp_Circ &theC);
|
||||
|
||||
//! Auxiliary method to arrange text and arrows
|
||||
Standard_EXPORT Standard_Boolean canTextBeInCenter (const gp_Pnt& theFirstAttach,
|
||||
const gp_Pnt& theSecondAttach,
|
||||
const Quantity_Length& theTextLength,
|
||||
const Quantity_Length& theArrowLength);
|
||||
|
||||
//! Fills default plane object if it is possible to count plane automatically.
|
||||
Standard_EXPORT virtual void countDefaultPlane ();
|
||||
|
||||
|
@ -18,52 +18,24 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
// Modified Mon 12-january-98
|
||||
// <ODL>, <SZY>
|
||||
|
||||
|
||||
#define BUC60915 //GG 05/06/01 Enable to compute the requested arrow size
|
||||
// if any in all dimensions.
|
||||
#include <AIS_DiameterDimension.hxx>
|
||||
|
||||
#include <Adaptor3d_HCurve.hxx>
|
||||
#include <AIS.hxx>
|
||||
#include <AIS_Drawer.hxx>
|
||||
#include <AIS_DimensionOwner.hxx>
|
||||
#include <DsgPrs_DiameterPresentation.hxx>
|
||||
#include <DsgPrs_RadiusPresentation.hxx>
|
||||
#include <ElCLib.hxx>
|
||||
#include <ElSLib.hxx>
|
||||
#include <GC_MakeCircle.hxx>
|
||||
#include <gce_MakeDir.hxx>
|
||||
#include <Geom_Plane.hxx>
|
||||
#include <gp_Pln.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Lin.hxx>
|
||||
#include <gp_Ax1.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <Graphic3d_ArrayOfSegments.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <PrsMgr_PresentationManager3d.hxx>
|
||||
#include <Prs3d_DimensionAspect.hxx>
|
||||
#include <Prs3d_ArrowAspect.hxx>
|
||||
#include <Prs3d_Drawer.hxx>
|
||||
#include <Prs3d_TextAspect.hxx>
|
||||
#include <Prs3d_Text.hxx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <Select3D_SensitiveSegment.hxx>
|
||||
#include <Select3D_SensitiveBox.hxx>
|
||||
#include <SelectMgr_EntityOwner.hxx>
|
||||
#include <Standard_Macro.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_HANDLE(AIS_DiameterDimension, AIS_Dimension)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(AIS_DiameterDimension, AIS_Dimension)
|
||||
|
||||
namespace
|
||||
{
|
||||
static const Standard_ExtCharacter THE_DIAMETER_SYMBOL (0x00D8);
|
||||
};
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
@ -75,8 +47,9 @@ AIS_DiameterDimension::AIS_DiameterDimension(const gp_Circ& theCircle)
|
||||
{
|
||||
SetKindOfDimension(AIS_KOD_DIAMETER);
|
||||
myIsInitialized = Standard_True;
|
||||
SetSpecialSymbol (0x00D8);
|
||||
SetSpecialSymbol (THE_DIAMETER_SYMBOL);
|
||||
SetDisplaySpecialSymbol (AIS_DSS_Before);
|
||||
SetFlyout (0.0);
|
||||
// Count attach points
|
||||
myFirstPoint = ElCLib::Value (0, myCircle);
|
||||
mySecondPoint = myFirstPoint.Translated (gp_Vec(myFirstPoint, theCircle.Location())*2);
|
||||
@ -91,9 +64,10 @@ AIS_DiameterDimension::AIS_DiameterDimension(const gp_Circ& theCircle, const gp_
|
||||
: AIS_Dimension(),
|
||||
myCircle (theCircle)
|
||||
{
|
||||
SetKindOfDimension(AIS_KOD_DIAMETER);
|
||||
SetSpecialSymbol (0x00D8);
|
||||
SetKindOfDimension (AIS_KOD_DIAMETER);
|
||||
SetSpecialSymbol (THE_DIAMETER_SYMBOL);
|
||||
SetDisplaySpecialSymbol (AIS_DSS_Before);
|
||||
SetFlyout (0.0);
|
||||
myFirstPoint = theAttachPoint;
|
||||
// Count the second point
|
||||
if (Abs(myFirstPoint.Distance (theCircle.Location()) - theCircle.Radius()) < Precision::Confusion())
|
||||
@ -108,24 +82,6 @@ AIS_DiameterDimension::AIS_DiameterDimension(const gp_Circ& theCircle, const gp_
|
||||
myIsInitialized = Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
AIS_DiameterDimension::AIS_DiameterDimension (const gp_Circ& theCircle,
|
||||
const Handle(Prs3d_DimensionAspect)& theDimensionStyle,
|
||||
const Standard_Real theExtensionSize /*= 1.0*/)
|
||||
: AIS_Dimension (theExtensionSize),
|
||||
myCircle (theCircle)
|
||||
{
|
||||
SetKindOfDimension(AIS_KOD_DIAMETER);
|
||||
SetSpecialSymbol (0x00D8);
|
||||
SetDisplaySpecialSymbol(AIS_DSS_Before);
|
||||
myDrawer->SetDimensionAspect(theDimensionStyle);
|
||||
myIsInitialized = Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose : Universal constructor for diameter dimension of shape
|
||||
@ -134,9 +90,10 @@ AIS_DiameterDimension::AIS_DiameterDimension (const gp_Circ& theCircle,
|
||||
AIS_DiameterDimension::AIS_DiameterDimension (const TopoDS_Shape& theShape)
|
||||
: AIS_Dimension ()
|
||||
{
|
||||
SetKindOfDimension(AIS_KOD_DIAMETER);
|
||||
SetSpecialSymbol (0x00D8);
|
||||
SetDisplaySpecialSymbol(AIS_DSS_Before);
|
||||
SetKindOfDimension (AIS_KOD_DIAMETER);
|
||||
SetSpecialSymbol (THE_DIAMETER_SYMBOL);
|
||||
SetDisplaySpecialSymbol (AIS_DSS_Before);
|
||||
SetFlyout (0.0);
|
||||
myFirstShape = theShape;
|
||||
myIsInitialized = Standard_False;
|
||||
}
|
||||
@ -163,38 +120,13 @@ void AIS_DiameterDimension::Compute (const Handle(PrsMgr_PresentationManager3d)&
|
||||
else
|
||||
myIsInitialized = Standard_True;
|
||||
}
|
||||
|
||||
if (!myIsWorkingPlaneCustom)
|
||||
countDefaultPlane();
|
||||
|
||||
//Count flyout direction
|
||||
gp_Ax1 aWorkingPlaneNormal = GetWorkingPlane().Axis();
|
||||
gp_Dir aTargetPointsVector = gce_MakeDir (myFirstPoint, mySecondPoint);
|
||||
// Count a flyout direction vector.
|
||||
gp_Dir aFlyoutVector = aWorkingPlaneNormal.Direction()^aTargetPointsVector;
|
||||
|
||||
// Create lines for layouts
|
||||
gp_Lin aLine1 (myFirstPoint, aFlyoutVector);
|
||||
gp_Lin aLine2 (mySecondPoint, aFlyoutVector);
|
||||
|
||||
// Get flyout end points
|
||||
gp_Pnt aFlyoutEnd1 = ElCLib::Value (ElCLib::Parameter (aLine1, myFirstPoint) + GetFlyout(), aLine1);
|
||||
gp_Pnt aFlyoutEnd2 = ElCLib::Value (ElCLib::Parameter (aLine2, mySecondPoint) + GetFlyout(), aLine2);
|
||||
|
||||
// Add layout lines to graphic group
|
||||
// Common to all type of dimension placement.
|
||||
if (theMode == 0)
|
||||
{
|
||||
Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments(4);
|
||||
aPrimSegments->AddVertex (myFirstPoint);
|
||||
aPrimSegments->AddVertex (aFlyoutEnd1);
|
||||
|
||||
aPrimSegments->AddVertex (mySecondPoint);
|
||||
aPrimSegments->AddVertex (aFlyoutEnd2);
|
||||
|
||||
Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments);
|
||||
countDefaultPlane();
|
||||
}
|
||||
|
||||
drawLinearDimension (thePresentation, aFlyoutEnd1, aFlyoutEnd2, (AIS_DimensionDisplayMode)theMode);
|
||||
drawLinearDimension (thePresentation, (AIS_DimensionDisplayMode)theMode);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@ -47,19 +47,16 @@ public:
|
||||
Standard_EXPORT AIS_DiameterDimension (const gp_Circ& theCircle,
|
||||
const gp_Pnt& theAttachPoint);
|
||||
|
||||
Standard_EXPORT AIS_DiameterDimension (const gp_Circ& theCircle,
|
||||
const Handle(Prs3d_DimensionAspect)& theDimensionStyle,
|
||||
const Standard_Real theExtensionSize = 1.0);
|
||||
|
||||
Standard_EXPORT AIS_DiameterDimension (const TopoDS_Shape& theShape);
|
||||
|
||||
DEFINE_STANDARD_RTTI(AIS_DiameterDimension)
|
||||
|
||||
protected:
|
||||
|
||||
Standard_EXPORT virtual void computeValue ();
|
||||
Standard_EXPORT virtual void computeValue();
|
||||
|
||||
//! Fills default plane object if it is possible to count plane automatically.
|
||||
Standard_EXPORT virtual void countDefaultPlane ();
|
||||
Standard_EXPORT virtual void countDefaultPlane();
|
||||
|
||||
private:
|
||||
|
||||
@ -68,6 +65,7 @@ private:
|
||||
const Standard_Integer theMode = 0);
|
||||
|
||||
// Fields
|
||||
private:
|
||||
|
||||
gp_Circ myCircle;
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -34,7 +34,6 @@
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_Presentation.hxx>
|
||||
#include <Prs3d_TextAspect.hxx>
|
||||
#include <Prs3d_VerticalTextAlignment.hxx>
|
||||
#include <Select3D_ListOfSensitive.hxx>
|
||||
#include <SelectMgr_EntityOwner.hxx>
|
||||
#include <Standard.hxx>
|
||||
@ -47,14 +46,32 @@ DEFINE_STANDARD_HANDLE(AIS_Dimension, AIS_InteractiveObject)
|
||||
|
||||
class AIS_Dimension : public AIS_InteractiveObject
|
||||
{
|
||||
protected:
|
||||
|
||||
// Specifies supported at base level horizontal and vertical
|
||||
// label positions for drawing extension lines and centered text.
|
||||
enum LabelPosition
|
||||
{
|
||||
LabelPosition_None = 0x00,
|
||||
|
||||
LabelPosition_Left = 0x01,
|
||||
LabelPosition_Right = 0x02,
|
||||
LabelPosition_HCenter = 0x04,
|
||||
LabelPosition_HMask = LabelPosition_Left | LabelPosition_Right | LabelPosition_HCenter,
|
||||
|
||||
LabelPosition_Above = 0x10,
|
||||
LabelPosition_Below = 0x20,
|
||||
LabelPosition_VCenter = 0x40,
|
||||
LabelPosition_VMask = LabelPosition_Above | LabelPosition_Below | LabelPosition_VCenter
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
//! Constructor with default parameters values
|
||||
Standard_EXPORT AIS_Dimension (const Standard_Real theExtensionSize = 1.0);
|
||||
//! Constructor to set aspect of dimension
|
||||
Standard_EXPORT AIS_Dimension (const Handle(Prs3d_DimensionAspect)& theAspect,
|
||||
const Standard_Real theExtensionSize = 1.0);
|
||||
Standard_EXPORT AIS_Dimension();
|
||||
|
||||
//! Gets dimension value
|
||||
Standard_EXPORT Standard_Real GetValue () const;
|
||||
Standard_EXPORT Standard_Real GetValue() const;
|
||||
|
||||
//! Sets dimension value
|
||||
//! Attention! This method is used ONLY to set custom value.
|
||||
@ -67,12 +84,6 @@ public:
|
||||
//! Sets working plane.
|
||||
Standard_EXPORT void SetWorkingPlane (const gp_Pln& thePlane);
|
||||
|
||||
//! Sets extension size.
|
||||
Standard_EXPORT void SetExtensionSize (const Standard_Real theExtensionSize);
|
||||
|
||||
//! Gets extension size.
|
||||
Standard_EXPORT Standard_Real GetExtensionSize() const;
|
||||
|
||||
Standard_EXPORT void SetFirstPoint (const gp_Pnt& thePoint);
|
||||
|
||||
Standard_EXPORT void SetSecondPoint (const gp_Pnt& thePoint);
|
||||
@ -101,71 +112,91 @@ public:
|
||||
//! The interactive context can have a default mode of
|
||||
//! representation for the set of Interactive Objects. This
|
||||
//! mode may not be accepted by object
|
||||
Standard_EXPORT virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const;
|
||||
Standard_EXPORT virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const;
|
||||
|
||||
// Selection computing if it is needed here
|
||||
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
|
||||
const Standard_Integer theMode);
|
||||
|
||||
//! Reset working plane to default.
|
||||
Standard_EXPORT void ResetWorkingPlane();
|
||||
|
||||
//! specifies dimension special symbol display options
|
||||
Standard_EXPORT void SetDisplaySpecialSymbol (const AIS_DisplaySpecialSymbol theDisplaySpecSymbol);
|
||||
|
||||
//! shows dimension special symbol display options
|
||||
Standard_EXPORT AIS_DisplaySpecialSymbol DisplaySpecialSymbol() const;
|
||||
|
||||
//! specifies special symbol
|
||||
Standard_EXPORT void SetSpecialSymbol (const Standard_ExtCharacter theSpecialSymbol);
|
||||
|
||||
//! returns special symbol
|
||||
Standard_EXPORT Standard_ExtCharacter SpecialSymbol() const;
|
||||
|
||||
//! shows if Units are to be displayed along with dimension value
|
||||
Standard_EXPORT Standard_Boolean IsUnitsDisplayed() const;
|
||||
|
||||
//! sets to display units along with the dimansion value or no
|
||||
Standard_EXPORT void MakeUnitsDisplayed (const Standard_Boolean toDisplayUnits);
|
||||
|
||||
//! returns the current type of units
|
||||
Standard_EXPORT TCollection_AsciiString UnitsQuantity() const;
|
||||
|
||||
//! sets the current type of units
|
||||
Standard_EXPORT void SetUnitsQuantity (const TCollection_AsciiString& theUnitsQuantity);
|
||||
|
||||
//! returns the current model units
|
||||
Standard_EXPORT TCollection_AsciiString ModelUnits() const;
|
||||
|
||||
//! sets the current model units
|
||||
Standard_EXPORT void SetModelUnits (const TCollection_AsciiString& theUnits);
|
||||
|
||||
//! returns the current display units
|
||||
Standard_EXPORT TCollection_AsciiString DisplayUnits() const;
|
||||
|
||||
//! sets the current display units
|
||||
Standard_EXPORT void SetDisplayUnits (const TCollection_AsciiString& theUnits);
|
||||
//! sets the text offset: distance from attach point to the text on the extension
|
||||
//! in case if text isn't in center of the dimension line
|
||||
Standard_EXPORT void SetTextOffset (const Standard_Real theOffset);
|
||||
//! returns the text offset: distance from attach point to the text on the extension
|
||||
//! in case if text isn't in center of the dimension line
|
||||
Standard_EXPORT Standard_Real TextOffset() const;
|
||||
|
||||
//! Important! Only for 3d text </br>
|
||||
//! 3d text is oriented relative to the attachment points order </br>
|
||||
//! By default, text direction vector is oriented from the first attachment point </br>
|
||||
//! to the second one. This method checks if text direction is to be default or </br>
|
||||
//! should be reversed.
|
||||
Standard_EXPORT Standard_Boolean IsTextReversed() const;
|
||||
|
||||
//! Important! Only for 3d text
|
||||
//! 3d text is oriented relative to the attachment points order </br>
|
||||
//! By default, text direction vector is oriented from the first attachment point </br>
|
||||
//! to the second one. This method sets value that shows if text direction </br>
|
||||
//! should be reversed or not.
|
||||
Standard_EXPORT void MakeTextReversed (const Standard_Boolean isTextReversed);
|
||||
|
||||
//! Sets selection tolerance for text2d:
|
||||
//! For 2d text selection detection sensitive point with tolerance is used
|
||||
//! to change this tolerance use this method
|
||||
//! Important! Only for 2d text
|
||||
Standard_EXPORT void SetSelToleranceForText2d (const Standard_Real theTol);
|
||||
|
||||
//! Returns selection tolerance for text2d:
|
||||
//! For 2d text selection detection sensitive point with tolerance is used
|
||||
//! Important! Only for 2d text
|
||||
Standard_EXPORT Standard_Real SelToleranceForText2d() const;
|
||||
|
||||
//! Sets flyout size for dimension.
|
||||
Standard_EXPORT void SetFlyout (const Standard_Real theFlyout);
|
||||
|
||||
//! @return flyout size for dimension.
|
||||
Standard_EXPORT Standard_Real GetFlyout () const;
|
||||
Standard_Real GetFlyout() const
|
||||
{
|
||||
return myFlyout;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_RTTI(AIS_Dimension)
|
||||
|
||||
protected:
|
||||
|
||||
Standard_EXPORT void getTextWidthAndString (Quantity_Length& theWidth,
|
||||
TCollection_ExtendedString& theString) const;
|
||||
|
||||
@ -190,19 +221,27 @@ protected:
|
||||
Standard_EXPORT Standard_Real drawText (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const gp_Dir& theTextDir,
|
||||
const TCollection_ExtendedString theText,
|
||||
const AIS_DimensionDisplayMode theMode);
|
||||
const AIS_DimensionDisplayMode theMode,
|
||||
const Standard_Integer theLabelPosition);
|
||||
|
||||
//! Performs computing of dimension linear extension with text
|
||||
Standard_EXPORT virtual void drawExtensionWithText (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const gp_Pnt& theStartPoint,
|
||||
const gp_Lin& theDimensionLine,
|
||||
const TCollection_ExtendedString& theValueString,
|
||||
const AIS_DimensionDisplayMode theMode);
|
||||
//! @param thePresentation [in] the presentation to fill with graphical primitives.
|
||||
//! @param theExtensionSize [in] the size of extension line.
|
||||
//! @param theExtensionStart [in] the point where extension line connects to dimension.
|
||||
//! @param theExtensionDir [in] the direction of extension line.
|
||||
//! @param theValueString [in] the string with value.
|
||||
//! @param theMode [in] the display mode.
|
||||
//! @param theLabelPosition [in] position flags for the text label.
|
||||
Standard_EXPORT void drawExtension (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const Standard_Real theExtensionSize,
|
||||
const gp_Pnt& theExtensionStart,
|
||||
const gp_Dir& theExtensionDir,
|
||||
const TCollection_ExtendedString& theValueString,
|
||||
const AIS_DimensionDisplayMode theMode,
|
||||
const Standard_Integer theLabelPosition);
|
||||
|
||||
//! Performs computing of linear dimension (for length, diameter, radius and so on)
|
||||
Standard_EXPORT void drawLinearDimension (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const gp_Pnt& theFirstAttach,
|
||||
const gp_Pnt& theSecondAttach,
|
||||
const AIS_DimensionDisplayMode theMode,
|
||||
const Standard_Boolean isOneSideDimension = Standard_False);
|
||||
|
||||
@ -231,39 +270,44 @@ protected:
|
||||
//! Fills sensitive entity for flyouts and adds it to the selection.
|
||||
Standard_EXPORT virtual void computeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
|
||||
const Handle(AIS_DimensionOwner)& theOwner);
|
||||
// Fields
|
||||
protected:
|
||||
|
||||
/// WORKING PLANE PROPERTIES
|
||||
protected: //! @name Working plane properties
|
||||
|
||||
//! Dimension default plane
|
||||
gp_Pln myDefaultPlane;
|
||||
|
||||
//! Shows if working plane is set custom
|
||||
Standard_Boolean myIsWorkingPlaneCustom;
|
||||
|
||||
/// VALUE PROPERTIES
|
||||
protected: //! @name Value properties
|
||||
|
||||
//! Dimension value which is displayed with dimension lines
|
||||
Standard_Real myValue;
|
||||
|
||||
//! Shows if the value is set by user and is no need to count it automatically
|
||||
Standard_Boolean myIsValueCustom;
|
||||
|
||||
/// UNITS PROPERTIES
|
||||
protected: // !@name Units properties
|
||||
|
||||
//! The quantity of units for the value computation
|
||||
TCollection_AsciiString myUnitsQuantity;
|
||||
|
||||
//! Units of the model
|
||||
TCollection_AsciiString myModelUnits;
|
||||
|
||||
//! Units in which the displayed value will be converted
|
||||
TCollection_AsciiString myDisplayUnits;
|
||||
|
||||
//! Determines if units is to be displayed along with the value
|
||||
Standard_Boolean myToDisplayUnits;
|
||||
|
||||
//! Special symbol for some kind of dimensions (for diameter, radius and so on)
|
||||
Standard_ExtCharacter mySpecialSymbol;
|
||||
|
||||
//! Special symbol display options
|
||||
AIS_DisplaySpecialSymbol myDisplaySpecialSymbol;
|
||||
|
||||
/// GEOMETRY PROPERTIES
|
||||
protected: //! @name Geometry properties
|
||||
|
||||
//! Geometry of dimensions, needs for advanced selection
|
||||
//! Geometry is computed in Compute() method and is used
|
||||
@ -274,57 +318,66 @@ protected:
|
||||
{
|
||||
//! Text position
|
||||
gp_Pnt myTextPosition;
|
||||
|
||||
//! Text bounding box, stored for advanced selection
|
||||
Bnd_Box myTextBndBox;
|
||||
|
||||
//! Sensitive point tolerance for 2d text selection
|
||||
Standard_Real mySelToleranceForText2d;
|
||||
|
||||
//! For advanced dimension line selection
|
||||
Select3D_ListOfSensitive mySensitiveSegments;
|
||||
|
||||
//! Shows if attachment points were computed
|
||||
Standard_Boolean myIsComputed;
|
||||
|
||||
public:
|
||||
DimensionGeom ()
|
||||
: myIsComputed (Standard_False)
|
||||
{ }
|
||||
|
||||
DimensionGeom () : myIsComputed (Standard_False) {}
|
||||
};
|
||||
|
||||
//! Shows if text is inverted
|
||||
Standard_Boolean myIsTextReversed;
|
||||
//! Determines distance from attach point to the text on the extension
|
||||
//! in case if text isn't in center of the dimension line
|
||||
Standard_Real myTextOffset;
|
||||
|
||||
//! Points that are base for dimension.
|
||||
//! My first point of dimension attach (belongs to shape for which dimension is computed)
|
||||
gp_Pnt myFirstPoint;
|
||||
|
||||
//! My second point of dimension attach (belongs to shape for which dimension is computed)
|
||||
gp_Pnt mySecondPoint;
|
||||
|
||||
//! Shows if attach points are initialized correctly
|
||||
Standard_Boolean myIsInitialized;
|
||||
|
||||
//! First shape (can be vertex, edge or face)
|
||||
TopoDS_Shape myFirstShape;
|
||||
|
||||
//! Second shape (can be vertex, edge or face)
|
||||
TopoDS_Shape mySecondShape;
|
||||
|
||||
//! Number of shapes
|
||||
Standard_Integer myShapesNumber;
|
||||
|
||||
//! Defines flyout lines and direction
|
||||
//! Flyout direction in the working plane.
|
||||
//! Can be negative, or positive and is defined by the sign of myFlyout value.
|
||||
//! The direction vector is counting using the working plane.
|
||||
//! myFlyout value defined the size of flyout.
|
||||
Standard_Real myFlyout;
|
||||
|
||||
//! Geometry of dimensions, needs for advanced selection
|
||||
//! Geometry is computed in Compute() method and is used
|
||||
//! in ComputeSelection() method.
|
||||
//! If it is computed successfully, myIsComputed = Standard_True.
|
||||
//! to check computing result use IsComputed() method
|
||||
DimensionGeom myGeom;
|
||||
|
||||
private:
|
||||
|
||||
//! Type of dimension
|
||||
AIS_KindOfDimension myKindOfDimension;
|
||||
|
||||
//! Dimension working plane, is equal to <myDefaultPlane> if it can be computed automatically.
|
||||
gp_Pln myWorkingPlane;
|
||||
//! Extension size in model measure units.
|
||||
//! No inclined or curved extension line is now supported.
|
||||
Standard_Real myExtensionSize;
|
||||
};
|
||||
#endif
|
||||
|
@ -18,65 +18,24 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#define BUC60915 //GG 05/06/01 Enable to compute the requested arrow size
|
||||
// if any in all dimensions.
|
||||
|
||||
|
||||
|
||||
#include <AIS_LengthDimension.hxx>
|
||||
|
||||
#include <AIS.hxx>
|
||||
#include <AIS_DimensionOwner.hxx>
|
||||
#include <AIS_Drawer.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
#include <BRepAdaptor_Surface.hxx>
|
||||
#include <BRepGProp_Face.hxx>
|
||||
#include <BRepLib_MakeVertex.hxx>
|
||||
#include <BRepTopAdaptor_FClass2d.hxx>
|
||||
#include <DsgPrs.hxx>
|
||||
#include <DsgPrs_LengthPresentation.hxx>
|
||||
#include <ElCLib.hxx>
|
||||
#include <ElSLib.hxx>
|
||||
#include <Geom_Circle.hxx>
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <Geom_TrimmedCurve.hxx>
|
||||
#include <Geom_Line.hxx>
|
||||
#include <Geom_Plane.hxx>
|
||||
#include <Geom_OffsetSurface.hxx>
|
||||
#include <gce_MakeDir.hxx>
|
||||
#include <gce_MakeLin.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_ArrayOfSegments.hxx>
|
||||
#include <Graphic3d_AspectText3d.hxx>
|
||||
#include <Graphic3d_AspectLine3d.hxx>
|
||||
#include <gp_Ax1.hxx>
|
||||
#include <gp_Ax2.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Lin.hxx>
|
||||
#include <gp_Pln.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <ProjLib.hxx>
|
||||
#include <Prs3d_Arrow.hxx>
|
||||
#include <Prs3d_ArrowAspect.hxx>
|
||||
#include <Prs3d_Drawer.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_Text.hxx>
|
||||
#include <Prs3d_TextAspect.hxx>
|
||||
#include <Select3D_SensitiveBox.hxx>
|
||||
#include <Select3D_SensitiveSegment.hxx>
|
||||
#include <Select3D_SensitiveCurve.hxx>
|
||||
#include <SelectMgr_EntityOwner.hxx>
|
||||
#include <Standard_DomainError.hxx>
|
||||
#include <Standard_NotImplemented.hxx>
|
||||
#include <StdPrs_WFDeflectionShape.hxx>
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
#include <PrsMgr_PresentationManager.hxx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_HANDLE(AIS_LengthDimension, AIS_Dimension)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(AIS_LengthDimension, AIS_Dimension)
|
||||
@ -86,33 +45,10 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_LengthDimension, AIS_Dimension)
|
||||
//purpose : Dimension between two points
|
||||
//=======================================================================
|
||||
|
||||
AIS_LengthDimension::AIS_LengthDimension (const gp_Pnt& theFirstPoint,
|
||||
const gp_Pnt& theSecondPoint,
|
||||
const gp_Pln& theDimensionPlane,
|
||||
const Handle(Prs3d_DimensionAspect)& theDimensionAspect,
|
||||
const Standard_Real theExtensionSize /*= 1.0*/)
|
||||
:AIS_Dimension (theDimensionAspect,theExtensionSize)
|
||||
{
|
||||
myIsInitialized = Standard_True;
|
||||
myFirstPoint = theFirstPoint;
|
||||
mySecondPoint = theSecondPoint;
|
||||
myShapesNumber = 2;
|
||||
myFirstShape = BRepLib_MakeVertex (myFirstPoint);
|
||||
mySecondShape = BRepLib_MakeVertex (mySecondPoint);
|
||||
SetFlyout (15.0);
|
||||
SetKindOfDimension(AIS_KOD_LENGTH);
|
||||
SetWorkingPlane (theDimensionPlane);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose : Dimension between two points
|
||||
//=======================================================================
|
||||
|
||||
AIS_LengthDimension::AIS_LengthDimension (const gp_Pnt& theFirstPoint,
|
||||
const gp_Pnt& theSecondPoint,
|
||||
const gp_Pln& theDimensionPlane)
|
||||
: AIS_Dimension ()
|
||||
: AIS_Dimension()
|
||||
{
|
||||
myIsInitialized = Standard_True;
|
||||
myFirstPoint = theFirstPoint;
|
||||
@ -120,9 +56,9 @@ AIS_LengthDimension::AIS_LengthDimension (const gp_Pnt& theFirstPoint,
|
||||
myFirstShape = BRepLib_MakeVertex (myFirstPoint);
|
||||
mySecondShape = BRepLib_MakeVertex (mySecondPoint);
|
||||
myShapesNumber = 2;
|
||||
SetFlyout (15.0);
|
||||
SetKindOfDimension (AIS_KOD_LENGTH);
|
||||
SetWorkingPlane (theDimensionPlane);
|
||||
SetFlyout (15.0);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -133,15 +69,15 @@ AIS_LengthDimension::AIS_LengthDimension (const gp_Pnt& theFirstPoint,
|
||||
AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Shape& theFirstShape,
|
||||
const TopoDS_Shape& theSecondShape,
|
||||
const gp_Pln& theWorkingPlane)
|
||||
: AIS_Dimension ()
|
||||
: AIS_Dimension()
|
||||
{
|
||||
myIsInitialized = Standard_False;
|
||||
myFirstShape = theFirstShape;
|
||||
mySecondShape = theSecondShape;
|
||||
myShapesNumber = 2;
|
||||
SetFlyout (15.0);
|
||||
SetKindOfDimension (AIS_KOD_LENGTH);
|
||||
SetWorkingPlane (theWorkingPlane);
|
||||
SetFlyout (15.0);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -151,14 +87,14 @@ AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Shape& theFirstShape,
|
||||
|
||||
AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Edge& theEdge,
|
||||
const gp_Pln& theWorkingPlane)
|
||||
: AIS_Dimension ()
|
||||
: AIS_Dimension()
|
||||
{
|
||||
myIsInitialized = Standard_False;
|
||||
myFirstShape = theEdge;
|
||||
myShapesNumber = 1;
|
||||
SetFlyout (15.0);
|
||||
SetKindOfDimension (AIS_KOD_LENGTH);
|
||||
SetWorkingPlane (theWorkingPlane);
|
||||
SetFlyout (15.0);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -168,14 +104,14 @@ AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Edge& theEdge,
|
||||
|
||||
AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Face& theFirstFace,
|
||||
const TopoDS_Face& theSecondFace)
|
||||
: AIS_Dimension ()
|
||||
: AIS_Dimension()
|
||||
{
|
||||
myIsInitialized = Standard_False;
|
||||
myFirstShape = theFirstFace;
|
||||
mySecondShape = theSecondFace;
|
||||
myShapesNumber = 2;
|
||||
SetKindOfDimension (AIS_KOD_LENGTH);
|
||||
SetFlyout (15.0);
|
||||
SetKindOfDimension(AIS_KOD_LENGTH);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -185,13 +121,13 @@ AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Face& theFirstFace,
|
||||
|
||||
AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Face& theFace,
|
||||
const TopoDS_Edge& theEdge)
|
||||
: AIS_Dimension ()
|
||||
: AIS_Dimension()
|
||||
{
|
||||
SetKindOfDimension(AIS_KOD_LENGTH);
|
||||
myIsInitialized = Standard_False;
|
||||
myFirstShape = theFace;
|
||||
mySecondShape = theEdge;
|
||||
myShapesNumber = 2;
|
||||
SetKindOfDimension (AIS_KOD_LENGTH);
|
||||
SetFlyout (15.0);
|
||||
}
|
||||
|
||||
@ -201,8 +137,8 @@ AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Face& theFace,
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean AIS_LengthDimension::initTwoEdgesLength (const TopoDS_Edge & theFirstEdge,
|
||||
const TopoDS_Edge& theSecondEdge,
|
||||
gp_Dir& theDirAttach)
|
||||
const TopoDS_Edge& theSecondEdge,
|
||||
gp_Dir& theDirAttach)
|
||||
{
|
||||
Standard_Integer anExtShapeIndex = 0;
|
||||
BRepAdaptor_Curve aFirstCurveAdapt (theFirstEdge);
|
||||
@ -280,9 +216,9 @@ Standard_Boolean AIS_LengthDimension::initTwoEdgesLength (const TopoDS_Edge & th
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean AIS_LengthDimension::initEdgeVertexLength (const TopoDS_Edge & theEdge,
|
||||
const TopoDS_Vertex & theVertex,
|
||||
gp_Dir & theDirAttach,
|
||||
Standard_Boolean isInfinite)
|
||||
const TopoDS_Vertex & theVertex,
|
||||
gp_Dir & theDirAttach,
|
||||
Standard_Boolean isInfinite)
|
||||
{
|
||||
gp_Pnt anEdgePoint1,anEdgePoint2;
|
||||
Handle(Geom_Curve) aCurve;
|
||||
@ -561,50 +497,28 @@ void AIS_LengthDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /
|
||||
if (!myIsInitialized)
|
||||
{
|
||||
if (myShapesNumber == 1)
|
||||
myIsInitialized = initOneShapePoints(myFirstShape);
|
||||
{
|
||||
myIsInitialized = initOneShapePoints (myFirstShape);
|
||||
}
|
||||
else if (myShapesNumber == 2)
|
||||
myIsInitialized = initTwoShapesPoints(myFirstShape, mySecondShape);
|
||||
{
|
||||
myIsInitialized = initTwoShapesPoints (myFirstShape, mySecondShape);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If initialization failed
|
||||
if (!myIsInitialized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
thePresentation->Clear();
|
||||
// Get length dimension aspect from AIS object drawer
|
||||
Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
|
||||
Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
|
||||
|
||||
//Count flyout direction
|
||||
gp_Ax1 aWorkingPlaneNormal = GetWorkingPlane().Axis();
|
||||
gp_Dir aTargetPointsVector = gce_MakeDir (myFirstPoint, mySecondPoint);
|
||||
// Count a flyout direction vector.
|
||||
gp_Dir aFlyoutVector = aWorkingPlaneNormal.Direction()^aTargetPointsVector;
|
||||
|
||||
// Create lines for layouts
|
||||
gp_Lin aLine1 (myFirstPoint, aFlyoutVector);
|
||||
gp_Lin aLine2 (mySecondPoint, aFlyoutVector);
|
||||
|
||||
// Get flyout end points
|
||||
gp_Pnt aFlyoutEnd1 = ElCLib::Value (ElCLib::Parameter (aLine1, myFirstPoint) + GetFlyout(), aLine1);
|
||||
gp_Pnt aFlyoutEnd2 = ElCLib::Value (ElCLib::Parameter (aLine2, mySecondPoint) + GetFlyout(), aLine2);
|
||||
|
||||
// Add layout lines to graphic group
|
||||
// Common to all type of dimension placement.
|
||||
if (theMode == 0)
|
||||
{
|
||||
Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments(4);
|
||||
aPrimSegments->AddVertex (myFirstPoint);
|
||||
aPrimSegments->AddVertex (aFlyoutEnd1);
|
||||
|
||||
aPrimSegments->AddVertex (mySecondPoint);
|
||||
aPrimSegments->AddVertex (aFlyoutEnd2);
|
||||
|
||||
Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments);
|
||||
}
|
||||
drawLinearDimension (thePresentation, aFlyoutEnd1, aFlyoutEnd2, (AIS_DimensionDisplayMode)theMode);
|
||||
drawLinearDimension (thePresentation, (AIS_DimensionDisplayMode)theMode);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -612,7 +526,7 @@ void AIS_LengthDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void AIS_LengthDimension::computeValue ()
|
||||
void AIS_LengthDimension::computeValue()
|
||||
{
|
||||
myValue = myFirstPoint.Distance (mySecondPoint);
|
||||
AIS_Dimension::computeValue ();
|
||||
|
@ -67,15 +67,6 @@ class AIS_LengthDimension : public AIS_Dimension
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor with full parameter list.
|
||||
//! Construct dimension between two vertices.
|
||||
//! Style of line, arrow and text can be set by default.
|
||||
Standard_EXPORT AIS_LengthDimension (const gp_Pnt& theFirstPoint,
|
||||
const gp_Pnt& theSecondPoint,
|
||||
const gp_Pln& theDimensionPlane,
|
||||
const Handle(Prs3d_DimensionAspect)& theDimensionAspect,
|
||||
const Standard_Real theExtensionSize = 1.0);
|
||||
|
||||
Standard_EXPORT AIS_LengthDimension (const gp_Pnt& theFirstPoint,
|
||||
const gp_Pnt& theSecondPoint,
|
||||
const gp_Pln& theDimensionPlane);
|
||||
@ -94,35 +85,42 @@ public:
|
||||
Standard_EXPORT AIS_LengthDimension (const TopoDS_Face& theFace,
|
||||
const TopoDS_Edge& theEdge);
|
||||
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_RTTI(AIS_LengthDimension)
|
||||
|
||||
private:
|
||||
|
||||
Standard_Boolean initTwoEdgesLength (const TopoDS_Edge & theFirstEdge,
|
||||
const TopoDS_Edge& theSecondEdge,
|
||||
gp_Dir& theDirAttach);
|
||||
const TopoDS_Edge& theSecondEdge,
|
||||
gp_Dir& theDirAttach);
|
||||
|
||||
//! Auxiliary method for <InitTwoShapesPoints()>
|
||||
//! in case of the distance between edge and vertex
|
||||
Standard_Boolean initEdgeVertexLength (const TopoDS_Edge & theEdge,
|
||||
const TopoDS_Vertex & theVertex,
|
||||
gp_Dir & theDirAttach,
|
||||
Standard_Boolean isInfinite);
|
||||
const TopoDS_Vertex & theVertex,
|
||||
gp_Dir & theDirAttach,
|
||||
Standard_Boolean isInfinite);
|
||||
|
||||
//! Auxiliary method for <InitTwoShapesPoints()>
|
||||
//! in case of the distance between face and edge
|
||||
Standard_Boolean initEdgeFaceLength (const TopoDS_Edge& theEdge,
|
||||
const TopoDS_Face& theFace,
|
||||
gp_Dir& theDirAttach);
|
||||
|
||||
//! Initialization of two attach points in case of two owner shapes
|
||||
Standard_Boolean initTwoShapesPoints (const TopoDS_Shape& theFirstShape,
|
||||
const TopoDS_Shape& theSecondShape);
|
||||
const TopoDS_Shape& theSecondShape);
|
||||
|
||||
//! Initialization of two attach points in case of one owner shape
|
||||
Standard_Boolean initOneShapePoints (const TopoDS_Shape& theShape);
|
||||
|
||||
//! Compute length in display units.
|
||||
virtual void computeValue ();
|
||||
virtual void computeValue();
|
||||
|
||||
virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
|
||||
const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const Standard_Integer theMode = 0) ;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -18,52 +18,16 @@
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
#include <Standard_NotImplemented.hxx>
|
||||
|
||||
#include <AIS_RadiusDimension.hxx>
|
||||
|
||||
#include <AIS.hxx>
|
||||
#include <AIS_Drawer.hxx>
|
||||
#include <AIS_KindOfDimension.hxx>
|
||||
#include <Adaptor3d_HCurve.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepAdaptor_Surface.hxx>
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
#include <DsgPrs.hxx>
|
||||
#include <ElCLib.hxx>
|
||||
#include <GC_MakeCircle.hxx>
|
||||
#include <gce_MakeCirc.hxx>
|
||||
#include <gce_MakeDir.hxx>
|
||||
#include <gce_MakeLin.hxx>
|
||||
#include <Geom_Surface.hxx>
|
||||
#include <Geom_Plane.hxx>
|
||||
#include <Geom_Circle.hxx>
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <Geom_TrimmedCurve.hxx>
|
||||
#include <Geom_ToroidalSurface.hxx>
|
||||
#include <Geom_CylindricalSurface.hxx>
|
||||
#include <Geom_SurfaceOfLinearExtrusion.hxx>
|
||||
#include <gp_Circ.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Trsf.hxx>
|
||||
#include <Graphic3d_ArrayOfSegments.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <PrsMgr_PresentationManager3d.hxx>
|
||||
#include <Prs3d_DimensionAspect.hxx>
|
||||
#include <Prs3d_ArrowAspect.hxx>
|
||||
#include <Prs3d_Drawer.hxx>
|
||||
#include <Prs3d_Root.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopAbs_ShapeEnum.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS_Wire.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopLoc_Location.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_HANDLE(AIS_RadiusDimension, AIS_Dimension)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(AIS_RadiusDimension, AIS_Dimension)
|
||||
@ -82,9 +46,15 @@ AIS_RadiusDimension::AIS_RadiusDimension (const gp_Circ& theCircle)
|
||||
myIsInitialized = Standard_True;
|
||||
SetSpecialSymbol ('R');
|
||||
SetDisplaySpecialSymbol (AIS_DSS_Before);
|
||||
SetKindOfDimension(AIS_KOD_RADIUS);
|
||||
SetKindOfDimension (AIS_KOD_RADIUS);
|
||||
SetFlyout (0.0);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
AIS_RadiusDimension::AIS_RadiusDimension (const gp_Circ& theCircle,
|
||||
const gp_Pnt& theAttachPoint)
|
||||
: AIS_Dimension(),
|
||||
@ -96,6 +66,7 @@ AIS_RadiusDimension::AIS_RadiusDimension (const gp_Circ& theCircle,
|
||||
SetSpecialSymbol ('R');
|
||||
SetDisplaySpecialSymbol (AIS_DSS_Before);
|
||||
SetKindOfDimension (AIS_KOD_RADIUS);
|
||||
SetFlyout (0.0);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -111,44 +82,7 @@ AIS_RadiusDimension::AIS_RadiusDimension (const TopoDS_Shape& theShape)
|
||||
SetSpecialSymbol ('R');
|
||||
SetDisplaySpecialSymbol (AIS_DSS_Before);
|
||||
SetKindOfDimension (AIS_KOD_RADIUS);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
AIS_RadiusDimension::AIS_RadiusDimension (const gp_Circ& theCircle,
|
||||
const Handle(Prs3d_DimensionAspect)& theDimensionAspect,
|
||||
const Standard_Real theExtensionSize/* = 1.0*/)
|
||||
|
||||
: AIS_Dimension (theDimensionAspect,theExtensionSize),
|
||||
myCircle (theCircle)
|
||||
{
|
||||
myFirstPoint = ElCLib::Value(0, myCircle);
|
||||
mySecondPoint = theCircle.Location();
|
||||
SetSpecialSymbol ('R');
|
||||
SetDisplaySpecialSymbol (AIS_DSS_Before);
|
||||
SetKindOfDimension (AIS_KOD_RADIUS);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
AIS_RadiusDimension::AIS_RadiusDimension (const gp_Circ& theCircle,
|
||||
const gp_Pnt& theAttachPoint,
|
||||
const Handle(Prs3d_DimensionAspect)& theDimensionAspect,
|
||||
const Standard_Real theExtensionSize/* = 1.0*/)
|
||||
: AIS_Dimension (theDimensionAspect,theExtensionSize),
|
||||
myCircle (theCircle)
|
||||
{
|
||||
myFirstPoint = theAttachPoint;
|
||||
mySecondPoint = theCircle.Location();
|
||||
SetSpecialSymbol ('R');
|
||||
SetDisplaySpecialSymbol (AIS_DSS_Before);
|
||||
SetKindOfDimension (AIS_KOD_RADIUS);
|
||||
SetFlyout (0.0);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -177,38 +111,13 @@ void AIS_RadiusDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /
|
||||
myIsInitialized = Standard_True;
|
||||
}
|
||||
}
|
||||
|
||||
if (!myIsWorkingPlaneCustom)
|
||||
countDefaultPlane();
|
||||
|
||||
//Count flyout direction
|
||||
gp_Ax1 aWorkingPlaneNormal = GetWorkingPlane().Axis();
|
||||
gp_Dir aTargetPointsVector = gce_MakeDir (myFirstPoint, mySecondPoint);
|
||||
// Count a flyout direction vector.
|
||||
gp_Dir aFlyoutVector = aWorkingPlaneNormal.Direction()^aTargetPointsVector;
|
||||
|
||||
// Create lines for layouts
|
||||
gp_Lin aLine1 (myFirstPoint, aFlyoutVector);
|
||||
gp_Lin aLine2 (mySecondPoint, aFlyoutVector);
|
||||
|
||||
// Get flyout end points
|
||||
gp_Pnt aFlyoutEnd1 = ElCLib::Value (ElCLib::Parameter (aLine1, myFirstPoint) + GetFlyout(), aLine1);
|
||||
gp_Pnt aFlyoutEnd2 = ElCLib::Value (ElCLib::Parameter (aLine2, mySecondPoint) + GetFlyout(), aLine2);
|
||||
|
||||
// Add layout lines to graphic group
|
||||
// Common to all type of dimension placement.
|
||||
if (theMode == 0)
|
||||
{
|
||||
Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments(4);
|
||||
aPrimSegments->AddVertex (myFirstPoint);
|
||||
aPrimSegments->AddVertex (aFlyoutEnd1);
|
||||
|
||||
aPrimSegments->AddVertex (mySecondPoint);
|
||||
aPrimSegments->AddVertex (aFlyoutEnd2);
|
||||
|
||||
Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments);
|
||||
countDefaultPlane();
|
||||
}
|
||||
|
||||
drawLinearDimension (thePresentation, aFlyoutEnd1, aFlyoutEnd2, (AIS_DimensionDisplayMode)theMode, Standard_True);
|
||||
drawLinearDimension (thePresentation, (AIS_DimensionDisplayMode)theMode, Standard_True);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@ -44,19 +44,12 @@ DEFINE_STANDARD_HANDLE(AIS_RadiusDimension,AIS_Dimension)
|
||||
class AIS_RadiusDimension : public AIS_Dimension
|
||||
{
|
||||
public:
|
||||
|
||||
Standard_EXPORT AIS_RadiusDimension (const gp_Circ& theCircle);
|
||||
|
||||
Standard_EXPORT AIS_RadiusDimension (const gp_Circ& theCircle,
|
||||
const gp_Pnt& theAttachPoint);
|
||||
const gp_Pnt& theAttachPoint);
|
||||
|
||||
Standard_EXPORT AIS_RadiusDimension (const gp_Circ& theCircle,
|
||||
const Handle(Prs3d_DimensionAspect)& theDimensionAspect,
|
||||
const Standard_Real theExtensionSize = 1.0);
|
||||
|
||||
Standard_EXPORT AIS_RadiusDimension (const gp_Circ& theCircle,
|
||||
const gp_Pnt& theAttachPoint,
|
||||
const Handle(Prs3d_DimensionAspect)& theDimensionAspect,
|
||||
const Standard_Real theExtensionSize = 1.0);
|
||||
//! Constructs the radius display object defined by the <br>
|
||||
//! shape aShape, the dimension aVal, and the text aText.
|
||||
Standard_EXPORT AIS_RadiusDimension (const TopoDS_Shape& aShape);
|
||||
@ -64,17 +57,21 @@ public:
|
||||
DEFINE_STANDARD_RTTI(AIS_RadiusDimension)
|
||||
|
||||
protected:
|
||||
|
||||
//! Computes dimension value in display units
|
||||
Standard_EXPORT virtual void computeValue ();
|
||||
|
||||
//! Fills default plane object if it is possible to count plane automatically.
|
||||
Standard_EXPORT virtual void countDefaultPlane ();
|
||||
|
||||
private:
|
||||
virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
|
||||
const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const Standard_Integer theMode = 0);
|
||||
private:
|
||||
|
||||
virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
|
||||
const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const Standard_Integer theMode = 0);
|
||||
|
||||
// Fields
|
||||
private:
|
||||
|
||||
gp_Circ myCircle;
|
||||
};
|
||||
|
@ -75,18 +75,27 @@ is
|
||||
-- For more details see AIS_Drawer class, AIS_Shape::Compute() method and
|
||||
-- HLRAlgo package from TKHLR toolkit.
|
||||
|
||||
enumeration HorizontalTextAlignment is HTA_Left, HTA_Right, HTA_Center;
|
||||
---Purpose: To declare horisontal alignment for dimension text.
|
||||
|
||||
enumeration VerticalTextAlignment is VTA_Top, VTA_Bottom, VTA_Center;
|
||||
---Purpose: To declare vertical alignment for dimension text label.
|
||||
|
||||
enumeration DimensionArrowOrientation is DAO_Internal, DAO_External;
|
||||
---Purpose: To declare arrow orientation for dimenation.
|
||||
-- External orientation means that dimension has extension parts outside the measured area.
|
||||
--Internal orientation means the dimension arrows are in the measured area, and no extension parts are needed.
|
||||
enumeration DimensionTextHorizontalPosition is DTHP_Left, DTHP_Right, DTHP_Center, DTHP_Fit;
|
||||
---Purpose: Specifies options for positioning dimension value label in horizontal direction.
|
||||
-- DTHP_Left - value label located at left side on dimension extension.
|
||||
-- DTHP_Right - value label located at right side on dimension extension.
|
||||
-- DTHP_Center - value label located at center of dimension line.
|
||||
-- DTHP_Fit - value label located automatically at left side if does not fits
|
||||
-- the dimension space, otherwise the value label is placed at center.
|
||||
|
||||
enumeration DimensionTextVerticalPosition is DTVP_Above, DTVP_Below, DTVP_Center;
|
||||
---Purpose: Specifies options for positioning dimension value label in vertical direction
|
||||
-- with respect to dimension (extension) line.
|
||||
-- DTVP_Above - text label is located above the dimension or extension line.
|
||||
-- DTVP_Below - text label is located below the dimension or extension line.
|
||||
-- DTVP_Center - the text label middle-point is in line with dimension or extension line.
|
||||
|
||||
enumeration DimensionArrowOrientation is DAO_Internal, DAO_External, DAO_Fit;
|
||||
---Purpose: Specifies dimension arrow location and orientation.
|
||||
-- DAO_Internal - arrows "inside", pointing outwards.
|
||||
-- DAO_External - arrows "outside", pointing inwards.
|
||||
-- DAO_Fit - arrows oriented inside if value label with arrowtips fit the dimension line,
|
||||
-- otherwise - externally
|
||||
|
||||
class Presentation;
|
||||
---Purpose: defines the presentation object. This object can be
|
||||
|
@ -20,8 +20,8 @@ class DimensionAspect from Prs3d inherits BasicAspect from Prs3d
|
||||
|
||||
---Purpose: defines the attributes when drawing a Length Presentation.
|
||||
uses
|
||||
HorizontalTextAlignment from Prs3d,
|
||||
VerticalTextAlignment from Prs3d,
|
||||
DimensionTextHorizontalPosition from Prs3d,
|
||||
DimensionTextVerticalPosition from Prs3d,
|
||||
DimensionArrowOrientation from Prs3d,
|
||||
AspectLine3d from Graphic3d,
|
||||
ArrowAspect from Prs3d,
|
||||
@ -71,19 +71,19 @@ is
|
||||
--- Purpose: Sets orientation of arrows (external or internal).
|
||||
-- By default orientation is chosen automatically according to situation and text label size.
|
||||
|
||||
GetArrowOrientation (me) returns DimensionArrowOrientation from Prs3d;
|
||||
ArrowOrientation (me) returns DimensionArrowOrientation from Prs3d;
|
||||
--- Purpose: Gets orientation of arrows (external or internal).
|
||||
|
||||
SetVerticalTextAlignment(me: mutable; theVertTextAlignment: VerticalTextAlignment from Prs3d);
|
||||
SetTextVerticalPosition (me: mutable; thePosition : DimensionTextVerticalPosition from Prs3d);
|
||||
--- Purpose: Sets vertical text alignment for text label.
|
||||
|
||||
VerticalTextAlignment (me) returns VerticalTextAlignment from Prs3d;
|
||||
TextVerticalPosition (me) returns DimensionTextVerticalPosition from Prs3d;
|
||||
--- Purpose: Gets vertical text alignment for text label.
|
||||
|
||||
SetHorizontalTextAlignment (me: mutable; theHorTextAlignment: HorizontalTextAlignment from Prs3d);
|
||||
SetTextHorizontalPosition (me: mutable; thePosition: DimensionTextHorizontalPosition from Prs3d);
|
||||
--- Purpose: Sets horizontal text alignment for text label.
|
||||
|
||||
HorizontalTextAlignment (me) returns HorizontalTextAlignment from Prs3d;
|
||||
TextHorizontalPosition (me) returns DimensionTextHorizontalPosition from Prs3d;
|
||||
--- Purpose: Gets horizontal text alignment for text label.
|
||||
|
||||
ArrowAspect(me) returns mutable ArrowAspect from Prs3d is static;
|
||||
@ -95,24 +95,38 @@ is
|
||||
SetCommonColor(me:mutable; theColor: Color from Quantity) is static;
|
||||
---Purpose: Sets the same color for all parts of dimension: lines, arrows and text.
|
||||
|
||||
SetExtensionSize (me : mutable; theSize : Real from Standard) is static;
|
||||
---Purpose: Sets extension size.
|
||||
|
||||
ExtensionSize (me) returns Real from Standard;
|
||||
---Purpose: Returns extension size.
|
||||
|
||||
fields
|
||||
|
||||
myLineAspect: LineAspect from Prs3d;
|
||||
---Purpose: Text style. The size for 3d (or 2d) text is also inside here.
|
||||
|
||||
myTextAspect: TextAspect from Prs3d;
|
||||
myArrowAspect : ArrowAspect from Prs3d;
|
||||
myIsText3d : Boolean from Standard;
|
||||
myIsTextShaded : Boolean from Standard;
|
||||
myIsArrows3d: Boolean from Standard;
|
||||
|
||||
myArrowOrientation : DimensionArrowOrientation from Prs3d;
|
||||
---Purpose: Dimension arrow orientation
|
||||
---Purpose: Dimension arrow orientation.
|
||||
-- By default, it is computed automatically. Its value depends on the text
|
||||
-- bouning rectangle size and distance between two flyouts.
|
||||
-- By default, it is internal one.
|
||||
myHorTextAlignment: HorizontalTextAlignment from Prs3d;
|
||||
---Purpose:Horizontal text alignment (Prs3d_HTA_Left/Prs3d_HTA_Right/Prs3d_HTA_Center).
|
||||
-- Defines horizontal position of text value label, by default it is center.
|
||||
myVerTextAlignment: VerticalTextAlignment from Prs3d;
|
||||
---Purpose: Vertical text alignment (Prs3d_VTA_Top, Prs3d_VTA_Bottom/Prs3d_VTA_Center)
|
||||
-- Defines vertical position of text value lable, by default it is center.
|
||||
-- By default, it is "fit" one.
|
||||
|
||||
myTextHPosition : DimensionTextHorizontalPosition from Prs3d;
|
||||
---Purpose: Defines horizontal position of text value label, by default it is
|
||||
-- "fit" - selected automatically depending on label-to-dimension size relation.
|
||||
|
||||
myTextVPosition : DimensionTextVerticalPosition from Prs3d;
|
||||
---Purpose: Defines vertical position of text value label, by default it is center.
|
||||
|
||||
myExtensionSize : Real from Standard;
|
||||
---Purpose: Size of arrow extensions.
|
||||
-- The length of arrow tails if arrows are located outside dimension line.
|
||||
|
||||
end DimensionAspect from Prs3d;
|
||||
|
@ -18,11 +18,12 @@
|
||||
|
||||
#include <Prs3d_DimensionAspect.hxx>
|
||||
|
||||
#include <Prs3d_ArrowAspect.hxx>
|
||||
#include <Prs3d_TextAspect.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
|
||||
#include <Aspect_TypeOfLine.hxx>
|
||||
#include <Graphic3d_AspectText3d.hxx>
|
||||
#include <Prs3d_LineAspect.hxx>
|
||||
#include <Prs3d_TextAspect.hxx>
|
||||
#include <Prs3d_ArrowAspect.hxx>
|
||||
#include <Quantity_Color.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_HANDLE (Prs3d_DimensionAspect, Prs3d_BasicAspect)
|
||||
@ -33,13 +34,12 @@ IMPLEMENT_STANDARD_RTTIEXT (Prs3d_DimensionAspect, Prs3d_BasicAspect)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Prs3d_DimensionAspect::Prs3d_DimensionAspect ()
|
||||
Prs3d_DimensionAspect::Prs3d_DimensionAspect()
|
||||
{
|
||||
// Text alignment
|
||||
myHorTextAlignment = Prs3d_HTA_Center;
|
||||
myVerTextAlignment = Prs3d_VTA_Center;
|
||||
// Arrow orientation, will be computed on further steps, by default it is internal.
|
||||
myArrowOrientation = Prs3d_DAO_Internal;
|
||||
myTextHPosition = Prs3d_DTHP_Fit;
|
||||
myTextVPosition = Prs3d_DTVP_Center;
|
||||
myArrowOrientation = Prs3d_DAO_Fit;
|
||||
|
||||
myLineAspect = new Prs3d_LineAspect (Quantity_NOC_LAWNGREEN,Aspect_TOL_SOLID,1.);
|
||||
myTextAspect = new Prs3d_TextAspect;
|
||||
myTextAspect->Aspect()->SetTextZoomable (Standard_False);
|
||||
@ -48,7 +48,8 @@ Prs3d_DimensionAspect::Prs3d_DimensionAspect ()
|
||||
myTextAspect->SetVerticalJustification (Graphic3d_VTA_CENTER);
|
||||
myArrowAspect = new Prs3d_ArrowAspect;
|
||||
myArrowAspect->SetColor (Quantity_NOC_LAWNGREEN);
|
||||
myArrowAspect->SetLength (6.);
|
||||
myArrowAspect->SetLength (6.0);
|
||||
myExtensionSize = 6.0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -176,49 +177,49 @@ void Prs3d_DimensionAspect::SetArrowOrientation (const Prs3d_DimensionArrowOrien
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Prs3d_DimensionArrowOrientation Prs3d_DimensionAspect::GetArrowOrientation () const
|
||||
Prs3d_DimensionArrowOrientation Prs3d_DimensionAspect::ArrowOrientation() const
|
||||
{
|
||||
return myArrowOrientation;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VerticalTextAlignment
|
||||
//function : SetTextVerticalPosition
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Prs3d_DimensionAspect::SetTextVerticalPosition (const Prs3d_DimensionTextVerticalPosition thePosition)
|
||||
{
|
||||
myTextVPosition = thePosition;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TextVerticalPosition
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Prs3d_DimensionTextVerticalPosition Prs3d_DimensionAspect::TextVerticalPosition() const
|
||||
{
|
||||
return myTextVPosition;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetTextHorizontalPosition
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Prs3d_DimensionAspect::SetTextHorizontalPosition (const Prs3d_DimensionTextHorizontalPosition thePosition)
|
||||
{
|
||||
myTextHPosition = thePosition;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TextHorizontalPosition
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Prs3d_VerticalTextAlignment Prs3d_DimensionAspect::VerticalTextAlignment () const
|
||||
Prs3d_DimensionTextHorizontalPosition Prs3d_DimensionAspect::TextHorizontalPosition() const
|
||||
{
|
||||
return myVerTextAlignment;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetVerticalTextAlignment
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Prs3d_DimensionAspect::SetVerticalTextAlignment (const Prs3d_VerticalTextAlignment theVertTextAlignment)
|
||||
{
|
||||
myVerTextAlignment = theVertTextAlignment;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HorizontalTextAlignment
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Prs3d_HorizontalTextAlignment Prs3d_DimensionAspect::HorizontalTextAlignment () const
|
||||
{
|
||||
return myHorTextAlignment;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetHorizontalTextAlignment
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Prs3d_DimensionAspect::SetHorizontalTextAlignment (const Prs3d_HorizontalTextAlignment theHorTextAlignment)
|
||||
{
|
||||
myHorTextAlignment = theHorTextAlignment;
|
||||
return myTextHPosition;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -240,3 +241,23 @@ void Prs3d_DimensionAspect::SetArrowAspect (const Handle(Prs3d_ArrowAspect)& the
|
||||
{
|
||||
myArrowAspect = theAspect;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetExtensioSize
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Prs3d_DimensionAspect::SetExtensionSize (const Standard_Real theSize)
|
||||
{
|
||||
myExtensionSize = theSize;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ExtensionSize
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real Prs3d_DimensionAspect::ExtensionSize() const
|
||||
{
|
||||
return myExtensionSize;
|
||||
}
|
||||
|
@ -710,7 +710,7 @@ static Standard_Integer OCC301 (Draw_Interpretor& di, Standard_Integer argc, con
|
||||
Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect;
|
||||
anAspect->MakeArrows3d (Standard_True);
|
||||
anAspect->ArrowAspect()->SetLength (anArrowSize);
|
||||
anAspect->SetHorizontalTextAlignment (Prs3d_HTA_Right);
|
||||
anAspect->SetTextHorizontalPosition (Prs3d_DTHP_Right);
|
||||
anAspect->TextAspect ()->SetColor (Quantity_NOC_YELLOW);
|
||||
anAngleDimension->SetDimensionAspect (anAspect);
|
||||
// Another position of dimension
|
||||
|
@ -14,10 +14,10 @@ vpoint lengthP2 50 50 50
|
||||
vdim -length -name=dim1 -plane=xoy lengthP1 lengthP2
|
||||
vdisplay dim1
|
||||
vfit
|
||||
vmoveto 82 268
|
||||
vmoveto 82 254
|
||||
|
||||
set x_coord 337
|
||||
set y_coord 130
|
||||
set x_coord 362
|
||||
set y_coord 102
|
||||
checkcolor $x_coord $y_coord 0 1 1
|
||||
if { $stat != 1 } {
|
||||
puts "Error : Highlighting of length dimension is wrong."
|
||||
|
@ -25,14 +25,15 @@ checkcolor $x_coord $y_coord 0 1 1
|
||||
if { $stat != 1 } {
|
||||
puts "Error : Highlighting of angle dimension with 2d text is wrong."
|
||||
}
|
||||
verase dim1
|
||||
vinit Viewer2/View2
|
||||
vdisplay angleP1 angleP2 angleP3
|
||||
vdim -angle -name=dim2 -text=3d angleP1 angleP2 angleP3
|
||||
vdisplay dim2
|
||||
vfit
|
||||
vmoveto 263 251
|
||||
|
||||
set x_coord 332
|
||||
set y_coord 326
|
||||
set x_coord 335
|
||||
set y_coord 319
|
||||
|
||||
checkcolor $x_coord $y_coord 0 1 1
|
||||
|
||||
|
@ -14,13 +14,13 @@ vpoint radP2 50 50 0
|
||||
vpoint radP3 100 0 0
|
||||
vcircle circle radP1 radP2 radP3 0
|
||||
verase radP1 radP2 radP3
|
||||
vdim -radius -name=dim3 circle
|
||||
vdisplay dim3
|
||||
vdim -radius -name=dim1 circle
|
||||
vdisplay dim1
|
||||
vfit
|
||||
vmoveto 102 144
|
||||
vmoveto 123 158
|
||||
|
||||
set x_coord 172
|
||||
set y_coord 186
|
||||
set x_coord 112
|
||||
set y_coord 151
|
||||
|
||||
checkcolor $x_coord $y_coord 0 1 1
|
||||
|
||||
@ -28,14 +28,15 @@ if { $stat != 1 } {
|
||||
puts "Error : Highlighting of radius dimension with 2d text is wrong."
|
||||
}
|
||||
|
||||
verase dim3
|
||||
vdim -radius -name=dim3 -text=3d circle
|
||||
vdisplay dim3
|
||||
vinit Viewer2/View2
|
||||
vdisplay circle
|
||||
vdim -radius -name=dim2 -text=3d circle
|
||||
vdisplay dim2
|
||||
vfit
|
||||
vmoveto 102 144
|
||||
vmoveto 191 196
|
||||
|
||||
set x_coord 172
|
||||
set y_coord 186
|
||||
set x_coord 129
|
||||
set y_coord 172
|
||||
|
||||
checkcolor $x_coord $y_coord 0 1 1
|
||||
|
||||
|
@ -14,8 +14,8 @@ vpoint diamP2 50 50 0
|
||||
vpoint diamP3 100 0 0
|
||||
vcircle circle diamP1 diamP2 diamP3 0
|
||||
verase diamP1 diamP2 diamP3
|
||||
vdim -diam -name=dim4 circle
|
||||
vdisplay dim4
|
||||
vdim -diam -name=dim1 circle
|
||||
vdisplay dim1
|
||||
vfit
|
||||
vmoveto 208 205
|
||||
|
||||
@ -28,9 +28,10 @@ if { $stat != 1 } {
|
||||
puts "Error : Highlighting of diameter dimension with 2d text is wrong."
|
||||
}
|
||||
|
||||
verase dim4
|
||||
vdim -diam -name=dim4 -text=3d circle
|
||||
vdisplay dim4
|
||||
vinit Viewer2/View2
|
||||
vdisplay circle
|
||||
vdim -diam -name=dim2 -text=3d circle
|
||||
vdisplay dim2
|
||||
vfit
|
||||
vmoveto 208 205
|
||||
|
||||
|
@ -20,10 +20,10 @@ verase radP1 radP2 radP3
|
||||
vdim -radius -name=dim -text=3d circle
|
||||
vdisplay dim
|
||||
vfit
|
||||
vmoveto 102 144
|
||||
vmoveto 110 111
|
||||
|
||||
set x_coord 153
|
||||
set y_coord 153
|
||||
set x_coord 196
|
||||
set y_coord 196
|
||||
checkcolor $x_coord $y_coord 0 1 1
|
||||
|
||||
if { $stat != 1 } {
|
||||
@ -33,10 +33,10 @@ if { $stat != 1 } {
|
||||
# X axis rotation
|
||||
vrotate $m_pi 0 0
|
||||
vfit
|
||||
vmoveto 201 206
|
||||
vmoveto 208 200
|
||||
|
||||
set x_coord 269
|
||||
set y_coord 123
|
||||
set x_coord 295
|
||||
set y_coord 113
|
||||
checkcolor $x_coord $y_coord 0 1 1
|
||||
|
||||
if { $stat != 1 } {
|
||||
|
@ -20,10 +20,10 @@ verase radP1 radP2 radP3
|
||||
vdim -radius -name=dim -text=3d circle
|
||||
vdisplay dim
|
||||
vfit
|
||||
vmoveto 102 144
|
||||
vmoveto 110 111
|
||||
|
||||
set x_coord 153
|
||||
set y_coord 153
|
||||
set x_coord 196
|
||||
set y_coord 196
|
||||
checkcolor $x_coord $y_coord 0 1 1
|
||||
|
||||
if { $stat != 1 } {
|
||||
@ -33,10 +33,10 @@ if { $stat != 1 } {
|
||||
# Y axis rotation
|
||||
vrotate 0 $m_pi 0
|
||||
vfit
|
||||
vmoveto 205 205
|
||||
vmoveto 185 246
|
||||
|
||||
set x_coord 96
|
||||
set y_coord 296
|
||||
set x_coord 113
|
||||
set y_coord 294
|
||||
checkcolor $x_coord $y_coord 0 1 1
|
||||
|
||||
if { $stat != 1 } {
|
||||
|
@ -20,10 +20,10 @@ verase radP1 radP2 radP3
|
||||
vdim -radius -name=dim -text=3d circle
|
||||
vdisplay dim
|
||||
vfit
|
||||
vmoveto 102 144
|
||||
vmoveto 110 111
|
||||
|
||||
set x_coord 153
|
||||
set y_coord 153
|
||||
set x_coord 196
|
||||
set y_coord 196
|
||||
checkcolor $x_coord $y_coord 0 1 1
|
||||
|
||||
if { $stat != 1 } {
|
||||
@ -33,10 +33,10 @@ if { $stat != 1 } {
|
||||
# Z axis rotation
|
||||
vrotate 0 0 $m_pi
|
||||
vfit
|
||||
vmoveto 176 184
|
||||
vmoveto 221 217
|
||||
|
||||
set x_coord 294
|
||||
set y_coord 257
|
||||
set x_coord 209
|
||||
set y_coord 208
|
||||
checkcolor $x_coord $y_coord 0 1 1
|
||||
|
||||
if { $stat != 1 } {
|
||||
|
Loading…
x
Reference in New Issue
Block a user