mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-21 10:13:43 +03:00
AIS_Dimension is extended to use custom text value
AIS_AngleDimension is extended to visualize reversed angle and only one of arrows.
This commit is contained in:
parent
b3cbd47d26
commit
415fb570ce
@ -277,6 +277,8 @@ void AIS_AngleDimension::SetMeasuredGeometry (const TopoDS_Face& theFirstFace,
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
void AIS_AngleDimension::Init()
|
void AIS_AngleDimension::Init()
|
||||||
{
|
{
|
||||||
|
SetAngleReversed (Standard_False);
|
||||||
|
SetArrowVisible (Standard_True, Standard_True);
|
||||||
SetSpecialSymbol (THE_DEGREE_SYMBOL);
|
SetSpecialSymbol (THE_DEGREE_SYMBOL);
|
||||||
SetDisplaySpecialSymbol (AIS_DSS_After);
|
SetDisplaySpecialSymbol (AIS_DSS_After);
|
||||||
SetFlyout (15.0);
|
SetFlyout (15.0);
|
||||||
@ -298,6 +300,12 @@ gp_Pnt AIS_AngleDimension::GetCenterOnArc (const gp_Pnt& theFirstAttach,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gp_Pln aPlane = aConstructPlane.Value();
|
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);
|
Standard_Real aRadius = theFirstAttach.Distance (theCenter);
|
||||||
|
|
||||||
@ -337,6 +345,12 @@ void AIS_AngleDimension::DrawArc (const Handle(Prs3d_Presentation)& thePresentat
|
|||||||
}
|
}
|
||||||
|
|
||||||
gp_Pln aPlane = aConstructPlane.Value();
|
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
|
// construct circle forming the arc
|
||||||
gce_MakeCirc aConstructCircle (theCenter, aPlane, theRadius);
|
gce_MakeCirc aConstructCircle (theCenter, aPlane, theRadius);
|
||||||
@ -362,7 +376,13 @@ void AIS_AngleDimension::DrawArc (const Handle(Prs3d_Presentation)& thePresentat
|
|||||||
// compute number of discretization elements in old-fanshioned way
|
// compute number of discretization elements in old-fanshioned way
|
||||||
gp_Vec aCenterToFirstVec (theCenter, theFirstAttach);
|
gp_Vec aCenterToFirstVec (theCenter, theFirstAttach);
|
||||||
gp_Vec aCenterToSecondVec (theCenter, theSecondAttach);
|
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));
|
const Standard_Integer aNbPoints = Max (4, Standard_Integer (50.0 * anAngle / M_PI));
|
||||||
|
|
||||||
GCPnts_UniformAbscissa aMakePnts (anArcAdaptor, aNbPoints);
|
GCPnts_UniformAbscissa aMakePnts (anArcAdaptor, aNbPoints);
|
||||||
@ -694,8 +714,8 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*
|
|||||||
if (theMode == ComputeMode_All || theMode == ComputeMode_Line)
|
if (theMode == ComputeMode_All || theMode == ComputeMode_Line)
|
||||||
{
|
{
|
||||||
DrawArc (thePresentation,
|
DrawArc (thePresentation,
|
||||||
isArrowsExternal ? aFirstAttach : aFirstArrowEnd,
|
(isArrowsExternal || !myFirstArrowVisible) ? aFirstAttach : aFirstArrowEnd,
|
||||||
isArrowsExternal ? aSecondAttach : aSecondArrowEnd,
|
(isArrowsExternal || !mySecondArrowVisible) ? aSecondAttach : aSecondArrowEnd,
|
||||||
myCenterPoint,
|
myCenterPoint,
|
||||||
Abs (GetFlyout()),
|
Abs (GetFlyout()),
|
||||||
theMode);
|
theMode);
|
||||||
@ -707,7 +727,7 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*
|
|||||||
{
|
{
|
||||||
DrawExtension (thePresentation,
|
DrawExtension (thePresentation,
|
||||||
anExtensionSize,
|
anExtensionSize,
|
||||||
isArrowsExternal ? aFirstArrowEnd : aFirstAttach,
|
(isArrowsExternal && myFirstArrowVisible) ? aFirstArrowEnd : aFirstAttach,
|
||||||
aFirstExtensionDir,
|
aFirstExtensionDir,
|
||||||
aLabelString,
|
aLabelString,
|
||||||
aLabelWidth,
|
aLabelWidth,
|
||||||
@ -720,7 +740,7 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*
|
|||||||
{
|
{
|
||||||
DrawExtension (thePresentation,
|
DrawExtension (thePresentation,
|
||||||
anExtensionSize,
|
anExtensionSize,
|
||||||
isArrowsExternal ? aSecondArrowEnd : aSecondAttach,
|
(isArrowsExternal && mySecondArrowVisible) ? aSecondArrowEnd : aSecondAttach,
|
||||||
aSecondExtensionDir,
|
aSecondExtensionDir,
|
||||||
aLabelString,
|
aLabelString,
|
||||||
aLabelWidth,
|
aLabelWidth,
|
||||||
@ -736,8 +756,8 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*
|
|||||||
Prs3d_Root::NewGroup (thePresentation);
|
Prs3d_Root::NewGroup (thePresentation);
|
||||||
|
|
||||||
DrawArc (thePresentation,
|
DrawArc (thePresentation,
|
||||||
isArrowsExternal ? aFirstAttach : aFirstArrowEnd,
|
(isArrowsExternal || !myFirstArrowVisible) ? aFirstAttach : aFirstArrowEnd,
|
||||||
isArrowsExternal ? aSecondAttach : aSecondArrowEnd,
|
(isArrowsExternal || !mySecondArrowVisible) ? aSecondAttach : aSecondArrowEnd,
|
||||||
myCenterPoint,
|
myCenterPoint,
|
||||||
Abs(GetFlyout ()),
|
Abs(GetFlyout ()),
|
||||||
theMode);
|
theMode);
|
||||||
@ -748,7 +768,9 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*
|
|||||||
{
|
{
|
||||||
Prs3d_Root::NewGroup (thePresentation);
|
Prs3d_Root::NewGroup (thePresentation);
|
||||||
|
|
||||||
|
if (myFirstArrowVisible)
|
||||||
DrawArrow (thePresentation, aFirstArrowBegin, gp_Dir (aFirstArrowVec));
|
DrawArrow (thePresentation, aFirstArrowBegin, gp_Dir (aFirstArrowVec));
|
||||||
|
if (mySecondArrowVisible)
|
||||||
DrawArrow (thePresentation, aSecondArrowBegin, gp_Dir (aSecondArrowVec));
|
DrawArrow (thePresentation, aSecondArrowBegin, gp_Dir (aSecondArrowVec));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -756,7 +778,7 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*
|
|||||||
{
|
{
|
||||||
Prs3d_Root::NewGroup (thePresentation);
|
Prs3d_Root::NewGroup (thePresentation);
|
||||||
|
|
||||||
if (aHPosition != LabelPosition_Left)
|
if (aHPosition != LabelPosition_Left && myFirstArrowVisible)
|
||||||
{
|
{
|
||||||
DrawExtension (thePresentation,
|
DrawExtension (thePresentation,
|
||||||
aDimensionAspect->ArrowTailSize(),
|
aDimensionAspect->ArrowTailSize(),
|
||||||
@ -768,7 +790,7 @@ void AIS_AngleDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*
|
|||||||
LabelPosition_None);
|
LabelPosition_None);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aHPosition != LabelPosition_Right)
|
if (aHPosition != LabelPosition_Right && mySecondArrowVisible)
|
||||||
{
|
{
|
||||||
DrawExtension (thePresentation,
|
DrawExtension (thePresentation,
|
||||||
aDimensionAspect->ArrowTailSize(),
|
aDimensionAspect->ArrowTailSize(),
|
||||||
@ -902,11 +924,10 @@ Standard_Boolean AIS_AngleDimension::InitTwoEdgesAngle (gp_Pln& theComputedPlane
|
|||||||
// |
|
// |
|
||||||
// | <- dimension should be here
|
// | <- dimension should be here
|
||||||
// *----
|
// *----
|
||||||
myFirstPoint = myCenterPoint.Distance (aFirstPoint1) > myCenterPoint.Distance (aLastPoint1)
|
myFirstPoint = !myCenterPoint.IsEqual(aFirstPoint1, Precision::Confusion())
|
||||||
? aFirstPoint1
|
? aFirstPoint1
|
||||||
: aLastPoint1;
|
: aLastPoint1;
|
||||||
|
mySecondPoint = !myCenterPoint.IsEqual(aFirstPoint2, Precision::Confusion())
|
||||||
mySecondPoint = myCenterPoint.Distance (aFirstPoint2) > myCenterPoint.Distance (aLastPoint2)
|
|
||||||
? aFirstPoint2
|
? aFirstPoint2
|
||||||
: aLastPoint2;
|
: aLastPoint2;
|
||||||
}
|
}
|
||||||
@ -1229,6 +1250,26 @@ void AIS_AngleDimension::SetTextPosition (const gp_Pnt& theTextPos)
|
|||||||
myFixedTextPosition = theTextPos;
|
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
|
//function : AdjustParameters
|
||||||
//purpose :
|
//purpose :
|
||||||
|
@ -207,6 +207,17 @@ public:
|
|||||||
|
|
||||||
Standard_EXPORT virtual const gp_Pnt GetTextPosition () const;
|
Standard_EXPORT virtual const gp_Pnt GetTextPosition () const;
|
||||||
|
|
||||||
|
//! Sets state if the angle arc should be built reversing to the presentation plane.
|
||||||
|
//! Default state is not reversed
|
||||||
|
//! @param theUseReverse [in] the boolean state.
|
||||||
|
Standard_EXPORT void SetAngleReversed(const Standard_Boolean& theUseReverse);
|
||||||
|
|
||||||
|
//! Sets visible state of angle arrows. Default value is true for both
|
||||||
|
//! @param theFirstArrowVisible [in] the visibility of the first arrow.
|
||||||
|
//! @param theSecondArrowVisible [in] the visibility of the second arrow.
|
||||||
|
Standard_EXPORT void SetArrowVisible(const Standard_Boolean& theFirstArrowVisible,
|
||||||
|
const Standard_Boolean& theSecondArrowVisible);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DEFINE_STANDARD_RTTI (AIS_AngleDimension)
|
DEFINE_STANDARD_RTTI (AIS_AngleDimension)
|
||||||
@ -335,6 +346,10 @@ protected:
|
|||||||
const gp_Pnt& theSecondPoint) const;
|
const gp_Pnt& theSecondPoint) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Standard_Boolean myUseReverse;
|
||||||
|
|
||||||
|
Standard_Boolean myFirstArrowVisible;
|
||||||
|
Standard_Boolean mySecondArrowVisible;
|
||||||
|
|
||||||
gp_Pnt myFirstPoint;
|
gp_Pnt myFirstPoint;
|
||||||
gp_Pnt mySecondPoint;
|
gp_Pnt mySecondPoint;
|
||||||
|
@ -99,7 +99,9 @@ AIS_Dimension::AIS_Dimension (const AIS_KindOfDimension theType)
|
|||||||
: AIS_InteractiveObject (),
|
: AIS_InteractiveObject (),
|
||||||
mySelToleranceForText2d(0.0),
|
mySelToleranceForText2d(0.0),
|
||||||
myCustomValue (0.0),
|
myCustomValue (0.0),
|
||||||
|
myCustomStringValue (""),
|
||||||
myIsValueCustom (Standard_False),
|
myIsValueCustom (Standard_False),
|
||||||
|
myIsStringValueCustom (Standard_False),
|
||||||
myIsTextPositionFixed (Standard_False),
|
myIsTextPositionFixed (Standard_False),
|
||||||
mySpecialSymbol (' '),
|
mySpecialSymbol (' '),
|
||||||
myDisplaySpecialSymbol (AIS_DSS_No),
|
myDisplaySpecialSymbol (AIS_DSS_No),
|
||||||
@ -129,6 +131,24 @@ void AIS_Dimension::SetCustomValue (const Standard_Real theValue)
|
|||||||
SetToUpdate();
|
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
|
//function : GetPlane
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -279,12 +299,18 @@ Standard_Real AIS_Dimension::ValueToDisplayUnits() const
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
TCollection_ExtendedString AIS_Dimension::GetValueString (Standard_Real& theWidth) const
|
TCollection_ExtendedString AIS_Dimension::GetValueString (Standard_Real& theWidth) const
|
||||||
{
|
{
|
||||||
|
TCollection_ExtendedString aValueStr;
|
||||||
|
if (myIsStringValueCustom) {
|
||||||
|
aValueStr = myCustomStringValue;
|
||||||
|
}
|
||||||
|
else {
|
||||||
// format value string using "sprintf"
|
// format value string using "sprintf"
|
||||||
TCollection_AsciiString aFormatStr = myDrawer->DimensionAspect()->ValueStringFormat();
|
TCollection_AsciiString aFormatStr = myDrawer->DimensionAspect()->ValueStringFormat();
|
||||||
|
|
||||||
char aFmtBuffer[256];
|
char aFmtBuffer[256];
|
||||||
sprintf (aFmtBuffer, aFormatStr.ToCString(), ValueToDisplayUnits());
|
sprintf (aFmtBuffer, aFormatStr.ToCString(), ValueToDisplayUnits());
|
||||||
TCollection_ExtendedString aValueStr = TCollection_ExtendedString (aFmtBuffer);
|
aValueStr = TCollection_ExtendedString (aFmtBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
// add units to values string
|
// add units to values string
|
||||||
if (myDrawer->DimensionAspect()->IsUnitsDisplayed())
|
if (myDrawer->DimensionAspect()->IsUnitsDisplayed())
|
||||||
|
@ -219,22 +219,17 @@ public:
|
|||||||
//! @param theType [in] the type of dimension.
|
//! @param theType [in] the type of dimension.
|
||||||
Standard_EXPORT AIS_Dimension (const AIS_KindOfDimension theType);
|
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.
|
//! Sets user-defined dimension value.
|
||||||
//! The user-defined dimension value is specified in model space,
|
//! The user-defined dimension value is specified in model space,
|
||||||
//! and affect by unit conversion during the display.
|
//! and affect by unit conversion during the display.
|
||||||
//! @param theValue [in] the user-defined value to display.
|
//! @param theValue [in] the user-defined value to display.
|
||||||
Standard_EXPORT void SetCustomValue (const Standard_Real theValue);
|
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.
|
//! 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
|
//! By default, if plane is not defined by user, it is computed automatically
|
||||||
//! after dimension geometry is computed.
|
//! after dimension geometry is computed.
|
||||||
@ -383,6 +378,16 @@ protected:
|
|||||||
|
|
||||||
Standard_EXPORT Standard_Real ValueToDisplayUnits() const;
|
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.
|
//! Get formatted value string and its model space width.
|
||||||
//! @param theWidth [out] the model space with of the string.
|
//! @param theWidth [out] the model space with of the string.
|
||||||
//! @return formatted dimension value string.
|
//! @return formatted dimension value string.
|
||||||
@ -655,13 +660,15 @@ protected: //! @name Value properties
|
|||||||
Standard_Real myCustomValue; //!< Value of the dimension (computed or user-defined).
|
Standard_Real myCustomValue; //!< Value of the dimension (computed or user-defined).
|
||||||
Standard_Boolean myIsValueCustom; //!< Is user-defined value.
|
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
|
protected: //! @name Fixed text position properties
|
||||||
|
|
||||||
gp_Pnt myFixedTextPosition; //!< Stores text position fixed by user.
|
gp_Pnt myFixedTextPosition; //!< Stores text position fixed by user.
|
||||||
Standard_Boolean myIsTextPositionFixed; //!< Is the text label position fixed by user.
|
Standard_Boolean myIsTextPositionFixed; //!< Is the text label position fixed by user.
|
||||||
|
|
||||||
protected: //! @name Units properties
|
protected: //! @name Units properties
|
||||||
|
|
||||||
Standard_ExtCharacter mySpecialSymbol; //!< Special symbol.
|
Standard_ExtCharacter mySpecialSymbol; //!< Special symbol.
|
||||||
AIS_DisplaySpecialSymbol myDisplaySpecialSymbol; //!< Special symbol display options.
|
AIS_DisplaySpecialSymbol myDisplaySpecialSymbol; //!< Special symbol display options.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user