mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
patch of 0028850: Visualization - Length dimension along Horizontal/Vertical axes
This commit is contained in:
parent
1780d6cc29
commit
0c129fdf43
@ -691,21 +691,9 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr
|
|||||||
FitTextAlignmentForLinear (theFirstPoint, theSecondPoint, theIsOneSide, aHorisontalTextPos,
|
FitTextAlignmentForLinear (theFirstPoint, theSecondPoint, theIsOneSide, aHorisontalTextPos,
|
||||||
aLabelPosition, isArrowsExternal);
|
aLabelPosition, isArrowsExternal);
|
||||||
|
|
||||||
// compute dimension line points
|
// compute dimension line points
|
||||||
gp_Ax1 aPlaneNormal = GetPlane().Axis();
|
gp_Pnt aLineBegPoint, aLineEndPoint;
|
||||||
gp_Dir aTargetPointsVector = gce_MakeDir (theFirstPoint, theSecondPoint);
|
ComputeFlyoutLinePoints (theFirstPoint, theSecondPoint, aLineBegPoint, aLineEndPoint);
|
||||||
|
|
||||||
// compute flyout direction vector
|
|
||||||
gp_Dir aFlyoutVector = aPlaneNormal.Direction() ^ aTargetPointsVector;
|
|
||||||
|
|
||||||
// create lines for layouts
|
|
||||||
gp_Lin aLine1 (theFirstPoint, aFlyoutVector);
|
|
||||||
gp_Lin aLine2 (theSecondPoint, aFlyoutVector);
|
|
||||||
|
|
||||||
// Get flyout end points
|
|
||||||
gp_Pnt aLineBegPoint = ElCLib::Value (ElCLib::Parameter (aLine1, theFirstPoint) + GetFlyout(), aLine1);
|
|
||||||
gp_Pnt aLineEndPoint = ElCLib::Value (ElCLib::Parameter (aLine2, theSecondPoint) + GetFlyout(), aLine2);
|
|
||||||
|
|
||||||
gp_Lin aDimensionLine = gce_MakeLin (aLineBegPoint, aLineEndPoint);
|
gp_Lin aDimensionLine = gce_MakeLin (aLineBegPoint, aLineEndPoint);
|
||||||
|
|
||||||
// compute arrows positions and directions
|
// compute arrows positions and directions
|
||||||
@ -996,6 +984,27 @@ void AIS_Dimension::DrawLinearDimension (const Handle(Prs3d_Presentation)& thePr
|
|||||||
mySelectionGeom.IsComputed = Standard_True;
|
mySelectionGeom.IsComputed = Standard_True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : ComputeFlyoutLinePoints
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_Dimension::ComputeFlyoutLinePoints (const gp_Pnt& theFirstPoint, const gp_Pnt& theSecondPoint,
|
||||||
|
gp_Pnt& theLineBegPoint, gp_Pnt& theLineEndPoint)
|
||||||
|
{
|
||||||
|
// compute dimension line points
|
||||||
|
gp_Ax1 aPlaneNormal = GetPlane().Axis();
|
||||||
|
// compute flyout direction vector
|
||||||
|
gp_Dir aTargetPointsVector = gce_MakeDir (theFirstPoint, theSecondPoint);
|
||||||
|
gp_Dir aFlyoutVector = aPlaneNormal.Direction() ^ aTargetPointsVector;
|
||||||
|
// create lines for layouts
|
||||||
|
gp_Lin aLine1 (theFirstPoint, aFlyoutVector);
|
||||||
|
gp_Lin aLine2 (theSecondPoint, aFlyoutVector);
|
||||||
|
|
||||||
|
// Get flyout end points
|
||||||
|
theLineBegPoint = ElCLib::Value (ElCLib::Parameter (aLine1, theFirstPoint) + GetFlyout(), aLine1);
|
||||||
|
theLineEndPoint = ElCLib::Value (ElCLib::Parameter (aLine2, theSecondPoint) + GetFlyout(), aLine2);
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : ComputeLinearFlyouts
|
//function : ComputeLinearFlyouts
|
||||||
//purpose :
|
//purpose :
|
||||||
|
@ -463,6 +463,14 @@ protected:
|
|||||||
const gp_Pnt& theSecondPoint,
|
const gp_Pnt& theSecondPoint,
|
||||||
const Standard_Boolean theIsOneSide = Standard_False);
|
const Standard_Boolean theIsOneSide = Standard_False);
|
||||||
|
|
||||||
|
//! Computes points bounded the flyout line for linear dimension.
|
||||||
|
//! @param theFirstPoint [in] the first attach point of linear dimension.
|
||||||
|
//! @param theSecondPoint [in] the second attach point of linear dimension.
|
||||||
|
//! @param theLineBegPoint [out] the first attach point of linear dimension.
|
||||||
|
//! @param theLineEndPoint [out] the second attach point of linear dimension.
|
||||||
|
Standard_EXPORT virtual void ComputeFlyoutLinePoints (const gp_Pnt& theFirstPoint, const gp_Pnt& theSecondPoint,
|
||||||
|
gp_Pnt& theLineBegPoint, gp_Pnt& theLineEndPoint);
|
||||||
|
|
||||||
//! Compute selection sensitives for linear dimension flyout lines (length, diameter, radius).
|
//! Compute selection sensitives for linear dimension flyout lines (length, diameter, radius).
|
||||||
//! Please note that this method uses base dimension properties: working plane and flyout length.
|
//! Please note that this method uses base dimension properties: working plane and flyout length.
|
||||||
//! @param theSelection [in] the selection structure to fill with selection primitives.
|
//! @param theSelection [in] the selection structure to fill with selection primitives.
|
||||||
|
@ -44,7 +44,8 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_LengthDimension,AIS_Dimension)
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Face& theFirstFace,
|
AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Face& theFirstFace,
|
||||||
const TopoDS_Face& theSecondFace)
|
const TopoDS_Face& theSecondFace)
|
||||||
: AIS_Dimension (AIS_KOD_LENGTH)
|
: AIS_Dimension (AIS_KOD_LENGTH),
|
||||||
|
myHasCustomDirection (Standard_False)
|
||||||
{
|
{
|
||||||
SetMeasuredGeometry (theFirstFace, theSecondFace);
|
SetMeasuredGeometry (theFirstFace, theSecondFace);
|
||||||
SetFlyout (15.0);
|
SetFlyout (15.0);
|
||||||
@ -56,7 +57,8 @@ AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Face& theFirstFace,
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Face& theFace,
|
AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Face& theFace,
|
||||||
const TopoDS_Edge& theEdge)
|
const TopoDS_Edge& theEdge)
|
||||||
: AIS_Dimension (AIS_KOD_LENGTH)
|
: AIS_Dimension (AIS_KOD_LENGTH),
|
||||||
|
myHasCustomDirection (Standard_False)
|
||||||
{
|
{
|
||||||
SetMeasuredGeometry (theFace, theEdge);
|
SetMeasuredGeometry (theFace, theEdge);
|
||||||
SetFlyout (15.0);
|
SetFlyout (15.0);
|
||||||
@ -69,7 +71,8 @@ AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Face& theFace,
|
|||||||
AIS_LengthDimension::AIS_LengthDimension (const gp_Pnt& theFirstPoint,
|
AIS_LengthDimension::AIS_LengthDimension (const gp_Pnt& theFirstPoint,
|
||||||
const gp_Pnt& theSecondPoint,
|
const gp_Pnt& theSecondPoint,
|
||||||
const gp_Pln& thePlane)
|
const gp_Pln& thePlane)
|
||||||
: AIS_Dimension (AIS_KOD_LENGTH)
|
: AIS_Dimension (AIS_KOD_LENGTH),
|
||||||
|
myHasCustomDirection (Standard_False)
|
||||||
{
|
{
|
||||||
SetMeasuredGeometry (theFirstPoint, theSecondPoint, thePlane);
|
SetMeasuredGeometry (theFirstPoint, theSecondPoint, thePlane);
|
||||||
SetFlyout (15.0);
|
SetFlyout (15.0);
|
||||||
@ -82,7 +85,8 @@ AIS_LengthDimension::AIS_LengthDimension (const gp_Pnt& theFirstPoint,
|
|||||||
AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Shape& theFirstShape,
|
AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Shape& theFirstShape,
|
||||||
const TopoDS_Shape& theSecondShape,
|
const TopoDS_Shape& theSecondShape,
|
||||||
const gp_Pln& thePlane)
|
const gp_Pln& thePlane)
|
||||||
: AIS_Dimension (AIS_KOD_LENGTH)
|
: AIS_Dimension (AIS_KOD_LENGTH),
|
||||||
|
myHasCustomDirection (Standard_False)
|
||||||
{
|
{
|
||||||
SetCustomPlane (thePlane);
|
SetCustomPlane (thePlane);
|
||||||
SetMeasuredShapes (theFirstShape, theSecondShape);
|
SetMeasuredShapes (theFirstShape, theSecondShape);
|
||||||
@ -95,7 +99,8 @@ AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Shape& theFirstShape,
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Edge& theEdge,
|
AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Edge& theEdge,
|
||||||
const gp_Pln& thePlane)
|
const gp_Pln& thePlane)
|
||||||
: AIS_Dimension (AIS_KOD_LENGTH)
|
: AIS_Dimension (AIS_KOD_LENGTH),
|
||||||
|
myHasCustomDirection (Standard_False)
|
||||||
{
|
{
|
||||||
SetMeasuredGeometry (theEdge, thePlane);
|
SetMeasuredGeometry (theEdge, thePlane);
|
||||||
SetFlyout (15.0);
|
SetFlyout (15.0);
|
||||||
@ -261,7 +266,13 @@ void AIS_LengthDimension::SetDisplayUnits (const TCollection_AsciiString& theUni
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
Standard_Real AIS_LengthDimension::ComputeValue() const
|
Standard_Real AIS_LengthDimension::ComputeValue() const
|
||||||
{
|
{
|
||||||
return IsValid() ? myFirstPoint.Distance (mySecondPoint) : 0.0;
|
if (!IsValid())
|
||||||
|
return 0.0;
|
||||||
|
|
||||||
|
if (!myHasCustomDirection)
|
||||||
|
return myFirstPoint.Distance (mySecondPoint);
|
||||||
|
|
||||||
|
return fabs (gp_Vec(myFirstPoint, mySecondPoint).Dot (myDirection));
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -282,6 +293,35 @@ void AIS_LengthDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /
|
|||||||
DrawLinearDimension (thePresentation, theMode, myFirstPoint, mySecondPoint);
|
DrawLinearDimension (thePresentation, theMode, myFirstPoint, mySecondPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : ComputeFlyoutLinePoints
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_LengthDimension::ComputeFlyoutLinePoints (const gp_Pnt& theFirstPoint, const gp_Pnt& theSecondPoint,
|
||||||
|
gp_Pnt& theLineBegPoint, gp_Pnt& theLineEndPoint)
|
||||||
|
{
|
||||||
|
if (!myHasCustomDirection)
|
||||||
|
{
|
||||||
|
AIS_Dimension::ComputeFlyoutLinePoints (theFirstPoint, theSecondPoint, theLineBegPoint, theLineEndPoint);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// find scalar of projection target vector (from start to second point) to flyout vector
|
||||||
|
gp_Ax1 aPlaneNormal = GetPlane().Axis();
|
||||||
|
gp_Vec aFlyoutNormalizedDir(aPlaneNormal.Direction() ^ myDirection);
|
||||||
|
aFlyoutNormalizedDir.Normalize();
|
||||||
|
Standard_Real aTargetProjectedToFlyout = gp_Vec(theFirstPoint, theSecondPoint).Dot (aFlyoutNormalizedDir);
|
||||||
|
|
||||||
|
gp_Dir aFlyoutVector = aFlyoutNormalizedDir;
|
||||||
|
// create lines for layouts
|
||||||
|
gp_Lin aLine1 (theFirstPoint, aFlyoutVector);
|
||||||
|
gp_Lin aLine2 (theSecondPoint, aFlyoutVector);
|
||||||
|
|
||||||
|
// Get flyout end points
|
||||||
|
theLineBegPoint = ElCLib::Value (ElCLib::Parameter (aLine1, theFirstPoint) + GetFlyout() + aTargetProjectedToFlyout, aLine1);
|
||||||
|
theLineEndPoint = ElCLib::Value (ElCLib::Parameter (aLine2, theSecondPoint) + GetFlyout(), aLine2);
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : ComputeFlyoutSelection
|
//function : ComputeFlyoutSelection
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -773,3 +813,14 @@ void AIS_LengthDimension::SetTextPosition (const gp_Pnt& theTextPos)
|
|||||||
|
|
||||||
SetToUpdate();
|
SetToUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetDirection
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_LengthDimension::SetDirection (const gp_Dir& theDirection, const Standard_Boolean theUseDirection)
|
||||||
|
{
|
||||||
|
myHasCustomDirection = theUseDirection;
|
||||||
|
if (myHasCustomDirection)
|
||||||
|
myDirection = theDirection;
|
||||||
|
}
|
||||||
|
@ -194,6 +194,13 @@ public:
|
|||||||
|
|
||||||
Standard_EXPORT virtual const gp_Pnt GetTextPosition() const Standard_OVERRIDE;
|
Standard_EXPORT virtual const gp_Pnt GetTextPosition() const Standard_OVERRIDE;
|
||||||
|
|
||||||
|
//! Set custom direction for dimension. If it is not set, the direction is obtained
|
||||||
|
//! from the measured geometry (e.g. line between points of dimension)
|
||||||
|
//! The direction does not change flyout direction of dimension.
|
||||||
|
//! @param theDirection [in] the dimension direction.
|
||||||
|
//! @param theUseDirection [in] boolean value if custom direction should be used.
|
||||||
|
Standard_EXPORT void SetDirection (const gp_Dir& theDirection, const Standard_Boolean theUseDirection = Standard_True);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DEFINE_STANDARD_RTTIEXT(AIS_LengthDimension,AIS_Dimension)
|
DEFINE_STANDARD_RTTIEXT(AIS_LengthDimension,AIS_Dimension)
|
||||||
@ -205,12 +212,25 @@ protected:
|
|||||||
|
|
||||||
Standard_EXPORT virtual gp_Pln ComputePlane(const gp_Dir& theAttachDir) const;
|
Standard_EXPORT virtual gp_Pln ComputePlane(const gp_Dir& theAttachDir) const;
|
||||||
|
|
||||||
|
//! Computes distance between dimension points. If custom direction is defined, the distance
|
||||||
|
//! is a projection value of the distance between points to this direction
|
||||||
|
//! @return dimension value
|
||||||
Standard_EXPORT Standard_Real ComputeValue() const Standard_OVERRIDE;
|
Standard_EXPORT Standard_Real ComputeValue() const Standard_OVERRIDE;
|
||||||
|
|
||||||
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
|
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
|
||||||
const Handle(Prs3d_Presentation)& thePresentation,
|
const Handle(Prs3d_Presentation)& thePresentation,
|
||||||
const Standard_Integer theMode = 0) Standard_OVERRIDE;
|
const Standard_Integer theMode = 0) Standard_OVERRIDE;
|
||||||
|
|
||||||
|
//! Computes points bounded the flyout line for linear dimension.
|
||||||
|
//! Direction of flyout line equal to the custom direction of dimension if defined or
|
||||||
|
//! parallel to the main direction line
|
||||||
|
//! @param theFirstPoint [in] the first attach point of linear dimension.
|
||||||
|
//! @param theSecondPoint [in] the second attach point of linear dimension.
|
||||||
|
//! @param theLineBegPoint [out] the first attach point of linear dimension.
|
||||||
|
//! @param theLineEndPoint [out] the second attach point of linear dimension.
|
||||||
|
Standard_EXPORT virtual void ComputeFlyoutLinePoints (const gp_Pnt& theFirstPoint, const gp_Pnt& theSecondPoint,
|
||||||
|
gp_Pnt& theLineBegPoint, gp_Pnt& theLineEndPoint) Standard_OVERRIDE;
|
||||||
|
|
||||||
Standard_EXPORT virtual void ComputeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
|
Standard_EXPORT virtual void ComputeFlyoutSelection (const Handle(SelectMgr_Selection)& theSelection,
|
||||||
const Handle(SelectMgr_EntityOwner)& theEntityOwner) Standard_OVERRIDE;
|
const Handle(SelectMgr_EntityOwner)& theEntityOwner) Standard_OVERRIDE;
|
||||||
|
|
||||||
@ -263,6 +283,8 @@ private:
|
|||||||
gp_Pnt mySecondPoint;
|
gp_Pnt mySecondPoint;
|
||||||
TopoDS_Shape myFirstShape;
|
TopoDS_Shape myFirstShape;
|
||||||
TopoDS_Shape mySecondShape;
|
TopoDS_Shape mySecondShape;
|
||||||
|
gp_Dir myDirection;
|
||||||
|
Standard_Boolean myHasCustomDirection;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _AIS_LengthDimension_HeaderFile
|
#endif // _AIS_LengthDimension_HeaderFile
|
||||||
|
Loading…
x
Reference in New Issue
Block a user