//=======================================================================
void AIS_AngleDimension::Init()
{
+ SetAngleReversed (Standard_False);
+ SetArrowVisible (Standard_True, Standard_True);
SetSpecialSymbol (THE_DEGREE_SYMBOL);
SetDisplaySpecialSymbol (AIS_DSS_After);
SetFlyout (15.0);
}
gp_Pln aPlane = aConstructPlane.Value();
+ if (myUseReverse) {
+ gp_Ax1 anAxis = aPlane.Axis();
+ gp_Dir aDir = anAxis.Direction();
+ aDir.Reverse();
+ aPlane.SetAxis(gp_Ax1(anAxis.Location(), aDir));
+ }
Standard_Real aRadius = theFirstAttach.Distance (theCenter);
}
gp_Pln aPlane = aConstructPlane.Value();
-
+ if (myUseReverse) {
+ gp_Ax1 anAxis = aPlane.Axis();
+ gp_Dir aDir = anAxis.Direction();
+ aDir.Reverse();
+ aPlane.SetAxis(gp_Ax1(anAxis.Location(), aDir));
+ }
+
// construct circle forming the arc
gce_MakeCirc aConstructCircle (theCenter, aPlane, theRadius);
if (!aConstructCircle.IsDone())
gp_Circ aCircle = aConstructCircle.Value();
// construct the arc
- GC_MakeArcOfCircle aConstructArc (aCircle, theFirstAttach, theSecondAttach, Standard_True);
+ GC_MakeArcOfCircle aConstructArc(aCircle, theFirstAttach, theSecondAttach, Standard_True);
if (!aConstructArc.IsDone())
{
return;
// compute number of discretization elements in old-fanshioned way
gp_Vec aCenterToFirstVec (theCenter, theFirstAttach);
gp_Vec aCenterToSecondVec (theCenter, theSecondAttach);
- const Standard_Real anAngle = aCenterToFirstVec.Angle (aCenterToSecondVec);
+
+ gp_Ax1 anAxis = aPlane.Axis();
+ gp_Dir aDir = anAxis.Direction();
+ gp_Vec aRefVec(aDir);
+ Standard_Real anAngle = aCenterToFirstVec.AngleWithRef (aCenterToSecondVec, aRefVec);
+ if (anAngle < 0)
+ anAngle = 2.0 * M_PI + anAngle;
const Standard_Integer aNbPoints = Max (4, Standard_Integer (50.0 * anAngle / M_PI));
GCPnts_UniformAbscissa aMakePnts (anArcAdaptor, aNbPoints);
if (theMode == ComputeMode_All || theMode == ComputeMode_Line)
{
DrawArc (thePresentation,
- isArrowsExternal ? aFirstAttach : aFirstArrowEnd,
- isArrowsExternal ? aSecondAttach : aSecondArrowEnd,
+ (isArrowsExternal || !myFirstArrowVisible) ? aFirstAttach : aFirstArrowEnd,
+ (isArrowsExternal || !mySecondArrowVisible) ? aSecondAttach : aSecondArrowEnd,
myCenterPoint,
Abs (GetFlyout()),
theMode);
{
DrawExtension (thePresentation,
anExtensionSize,
- isArrowsExternal ? aFirstArrowEnd : aFirstAttach,
+ (isArrowsExternal && myFirstArrowVisible) ? aFirstArrowEnd : aFirstAttach,
aFirstExtensionDir,
aLabelString,
aLabelWidth,
{
DrawExtension (thePresentation,
anExtensionSize,
- isArrowsExternal ? aSecondArrowEnd : aSecondAttach,
+ (isArrowsExternal && mySecondArrowVisible) ? aSecondArrowEnd : aSecondAttach,
aSecondExtensionDir,
aLabelString,
aLabelWidth,
Prs3d_Root::NewGroup (thePresentation);
DrawArc (thePresentation,
- isArrowsExternal ? aFirstAttach : aFirstArrowEnd,
- isArrowsExternal ? aSecondAttach : aSecondArrowEnd,
+ (isArrowsExternal || !myFirstArrowVisible) ? aFirstAttach : aFirstArrowEnd,
+ (isArrowsExternal || !mySecondArrowVisible) ? aSecondAttach : aSecondArrowEnd,
myCenterPoint,
Abs(GetFlyout ()),
theMode);
{
Prs3d_Root::NewGroup (thePresentation);
- DrawArrow (thePresentation, aFirstArrowBegin, gp_Dir (aFirstArrowVec));
- DrawArrow (thePresentation, aSecondArrowBegin, gp_Dir (aSecondArrowVec));
+ if (myFirstArrowVisible)
+ DrawArrow (thePresentation, aFirstArrowBegin, gp_Dir (aFirstArrowVec));
+ if (mySecondArrowVisible)
+ DrawArrow (thePresentation, aSecondArrowBegin, gp_Dir (aSecondArrowVec));
}
if ((theMode == ComputeMode_All || theMode == ComputeMode_Line) && isArrowsExternal)
{
Prs3d_Root::NewGroup (thePresentation);
- if (aHPosition != LabelPosition_Left)
+ if (aHPosition != LabelPosition_Left && myFirstArrowVisible)
{
DrawExtension (thePresentation,
aDimensionAspect->ArrowTailSize(),
LabelPosition_None);
}
- if (aHPosition != LabelPosition_Right)
+ if (aHPosition != LabelPosition_Right && mySecondArrowVisible)
{
DrawExtension (thePresentation,
aDimensionAspect->ArrowTailSize(),
// |
// | <- dimension should be here
// *----
- myFirstPoint = myCenterPoint.Distance (aFirstPoint1) > myCenterPoint.Distance (aLastPoint1)
- ? aFirstPoint1
- : aLastPoint1;
-
- mySecondPoint = myCenterPoint.Distance (aFirstPoint2) > myCenterPoint.Distance (aLastPoint2)
- ? aFirstPoint2
- : aLastPoint2;
+ myFirstPoint = !myCenterPoint.IsEqual(aFirstPoint1, Precision::Confusion())
+ ? aFirstPoint1
+ : aLastPoint1;
+ mySecondPoint = !myCenterPoint.IsEqual(aFirstPoint2, Precision::Confusion())
+ ? aFirstPoint2
+ : aLastPoint2;
}
return IsValidPoints (myFirstPoint, myCenterPoint, mySecondPoint);
myFixedTextPosition = theTextPos;
}
+//=======================================================================
+//function : SetAngleReversed
+//purpose :
+//=======================================================================
+void AIS_AngleDimension::SetAngleReversed(const Standard_Boolean& theUseReverse)
+{
+ myUseReverse = theUseReverse;
+}
+
+//=======================================================================
+//function : SetArrowVisible
+//purpose :
+//=======================================================================
+void AIS_AngleDimension::SetArrowVisible(const Standard_Boolean& theFirstArrowVisible,
+ const Standard_Boolean& theSecondArrowVisible)
+{
+ myFirstArrowVisible = theFirstArrowVisible;
+ mySecondArrowVisible = theSecondArrowVisible;
+}
+
//=======================================================================
//function : AdjustParameters
//purpose :
: AIS_InteractiveObject (),
mySelToleranceForText2d(0.0),
myCustomValue (0.0),
+ myCustomStringValue (""),
myIsValueCustom (Standard_False),
+ myIsStringValueCustom (Standard_False),
myIsTextPositionFixed (Standard_False),
mySpecialSymbol (' '),
myDisplaySpecialSymbol (AIS_DSS_No),
SetToUpdate();
}
+//=======================================================================
+//function : SetCustomValue
+//purpose :
+//=======================================================================
+void AIS_Dimension::SetCustomValue (const TCollection_ExtendedString& theValue)
+{
+ if (myIsStringValueCustom && myCustomStringValue == theValue)
+ {
+ return;
+ }
+
+ myIsStringValueCustom = Standard_True;
+
+ myCustomStringValue = theValue;
+
+ SetToUpdate();
+}
+
//=======================================================================
//function : GetPlane
//purpose :
//=======================================================================
TCollection_ExtendedString AIS_Dimension::GetValueString (Standard_Real& theWidth) const
{
- // format value string using "sprintf"
- TCollection_AsciiString aFormatStr = myDrawer->DimensionAspect()->ValueStringFormat();
+ TCollection_ExtendedString aValueStr;
+ if (myIsStringValueCustom) {
+ aValueStr = myCustomStringValue;
+ }
+ else {
+ // format value string using "sprintf"
+ TCollection_AsciiString aFormatStr = myDrawer->DimensionAspect()->ValueStringFormat();
- char aFmtBuffer[256];
- sprintf (aFmtBuffer, aFormatStr.ToCString(), ValueToDisplayUnits());
- TCollection_ExtendedString aValueStr = TCollection_ExtendedString (aFmtBuffer);
+ char aFmtBuffer[256];
+ sprintf (aFmtBuffer, aFormatStr.ToCString(), ValueToDisplayUnits());
+ aValueStr = TCollection_ExtendedString (aFmtBuffer);
+ }
// add units to values string
if (myDrawer->DimensionAspect()->IsUnitsDisplayed())
//! @param theType [in] the type of dimension.
Standard_EXPORT AIS_Dimension (const AIS_KindOfDimension theType);
- //! Gets dimension measurement value. If the value to display is not
- //! specified by user, then the dimension object is responsible to
- //! compute it on its own in model space coordinates.
- //! @return the dimension value (in model units) which is used
- //! during display of the presentation.
- Standard_Real GetValue() const
- {
- return myIsValueCustom ? myCustomValue : ComputeValue();
- }
-
//! Sets user-defined dimension value.
//! The user-defined dimension value is specified in model space,
//! and affect by unit conversion during the display.
//! @param theValue [in] the user-defined value to display.
Standard_EXPORT void SetCustomValue (const Standard_Real theValue);
+ //! Sets user-defined dimension value.
+ //! Unit conversion during the display is not applyed.
+ //! @param theValue [in] the user-defined value to display.
+ Standard_EXPORT void SetCustomValue (const TCollection_ExtendedString& theValue);
+
//! Get the dimension plane in which the 2D dimension presentation is computed.
//! By default, if plane is not defined by user, it is computed automatically
//! after dimension geometry is computed.
Standard_EXPORT Standard_Real ValueToDisplayUnits() const;
+ //! Gets dimension measurement value. If the value to display is not
+ //! specified by user, then the dimension object is responsible to
+ //! compute it on its own in model space coordinates.
+ //! @return the dimension value (in model units) which is used
+ //! during display of the presentation.
+ Standard_Real GetValue() const
+ {
+ return myIsValueCustom ? myCustomValue : ComputeValue();
+ }
+
//! Get formatted value string and its model space width.
//! @param theWidth [out] the model space with of the string.
//! @return formatted dimension value string.
Standard_Real myCustomValue; //!< Value of the dimension (computed or user-defined).
Standard_Boolean myIsValueCustom; //!< Is user-defined value.
+ TCollection_ExtendedString myCustomStringValue; //!< Value of the dimension (computed or user-defined).
+ Standard_Boolean myIsStringValueCustom; //!< Is user-defined value.
+
protected: //! @name Fixed text position properties
gp_Pnt myFixedTextPosition; //!< Stores text position fixed by user.
Standard_Boolean myIsTextPositionFixed; //!< Is the text label position fixed by user.
protected: //! @name Units properties
-
Standard_ExtCharacter mySpecialSymbol; //!< Special symbol.
AIS_DisplaySpecialSymbol myDisplaySpecialSymbol; //!< Special symbol display options.