FitTextAlignmentForLinear (theFirstPoint, theSecondPoint, theIsOneSide, aHorisontalTextPos,
aLabelPosition, isArrowsExternal);
- // compute dimension line points
- gp_Ax1 aPlaneNormal = GetPlane().Axis();
- gp_Dir aTargetPointsVector = gce_MakeDir (theFirstPoint, theSecondPoint);
-
- // 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);
-
+ // compute dimension line points
+ gp_Pnt aLineBegPoint, aLineEndPoint;
+ ComputeFlyoutLinePoints (theFirstPoint, theSecondPoint, aLineBegPoint, aLineEndPoint);
gp_Lin aDimensionLine = gce_MakeLin (aLineBegPoint, aLineEndPoint);
// compute arrows positions and directions
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
//purpose :
const gp_Pnt& theSecondPoint,
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).
//! 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.
//=======================================================================
AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Face& theFirstFace,
const TopoDS_Face& theSecondFace)
-: AIS_Dimension (AIS_KOD_LENGTH)
+: AIS_Dimension (AIS_KOD_LENGTH),
+ myHasCustomDirection (Standard_False)
{
SetMeasuredGeometry (theFirstFace, theSecondFace);
SetFlyout (15.0);
//=======================================================================
AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Face& theFace,
const TopoDS_Edge& theEdge)
-: AIS_Dimension (AIS_KOD_LENGTH)
+: AIS_Dimension (AIS_KOD_LENGTH),
+ myHasCustomDirection (Standard_False)
{
SetMeasuredGeometry (theFace, theEdge);
SetFlyout (15.0);
AIS_LengthDimension::AIS_LengthDimension (const gp_Pnt& theFirstPoint,
const gp_Pnt& theSecondPoint,
const gp_Pln& thePlane)
-: AIS_Dimension (AIS_KOD_LENGTH)
+: AIS_Dimension (AIS_KOD_LENGTH),
+ myHasCustomDirection (Standard_False)
{
SetMeasuredGeometry (theFirstPoint, theSecondPoint, thePlane);
SetFlyout (15.0);
AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Shape& theFirstShape,
const TopoDS_Shape& theSecondShape,
const gp_Pln& thePlane)
-: AIS_Dimension (AIS_KOD_LENGTH)
+: AIS_Dimension (AIS_KOD_LENGTH),
+ myHasCustomDirection (Standard_False)
{
SetCustomPlane (thePlane);
SetMeasuredShapes (theFirstShape, theSecondShape);
//=======================================================================
AIS_LengthDimension::AIS_LengthDimension (const TopoDS_Edge& theEdge,
const gp_Pln& thePlane)
-: AIS_Dimension (AIS_KOD_LENGTH)
+: AIS_Dimension (AIS_KOD_LENGTH),
+ myHasCustomDirection (Standard_False)
{
SetMeasuredGeometry (theEdge, thePlane);
SetFlyout (15.0);
//=======================================================================
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));
}
//=======================================================================
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
//purpose :
SetToUpdate();
}
+
+//=======================================================================
+//function : SetDirection
+//purpose :
+//=======================================================================
+void AIS_LengthDimension::SetDirection (const gp_Dir& theDirection, const Standard_Boolean theUseDirection)
+{
+ myHasCustomDirection = theUseDirection;
+ if (myHasCustomDirection)
+ myDirection = theDirection;
+}
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:
DEFINE_STANDARD_RTTIEXT(AIS_LengthDimension,AIS_Dimension)
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 virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
const Handle(Prs3d_Presentation)& thePresentation,
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,
const Handle(SelectMgr_EntityOwner)& theEntityOwner) Standard_OVERRIDE;
gp_Pnt mySecondPoint;
TopoDS_Shape myFirstShape;
TopoDS_Shape mySecondShape;
+ gp_Dir myDirection;
+ Standard_Boolean myHasCustomDirection;
};
#endif // _AIS_LengthDimension_HeaderFile