# Visualization
TKV2d
Graphic2d

# Graphic2d_Text Class Reference

The primitive Text
.

`#include <Graphic2d_Text.hxx>`

Inheritance diagram for Graphic2d_Text:

[legend]

## Public Member Functions

Standard_EXPORT | Graphic2d_Text (const Handle(Graphic2d_GraphicObject)&aGraphicObject, const TCollection_ExtendedString &aText, const Standard_Real X, const Standard_Real Y, const Quantity_PlaneAngle anAngle=0.0, const Aspect_TypeOfText aType=Aspect_TOT_SOLID, const Quantity_Factor aScale=1.0)

Creates a text in a graphic object <agraphicobject>
The text is <atext>.
The reference point is <x>, <y>.
The orientation angle is <anangle>.
The type of text is <atype> and must be one of :
Aspect_TOT_SOLID,
Aspect_TOT_OUTLINE,
The scale factor apply to the original font size,
Angles are measured counterclockwise with 0 radian
at 3 o'clock.
Warning: a text can be orientable,slantable,zoomable or outlinable
only when this options are enable regardless of the graphic driver.
i.e: Xw driver does not,but Xdps or PS driver does.
.

Standard_EXPORT void | SetFontIndex (const Standard_Integer anIndex=0)
| Sets the font index for the text <me>. Warning: Note that the index 0 can be undefined as a FontMapEntry, in this case the default system text font is taken. .
Standard_EXPORT void | SetSlant (const Quantity_PlaneAngle aSlant=0.0)
| Sets the slant angle of the text <me>. .
Standard_EXPORT void | SetZoomable (const Standard_Boolean aFlag=Standard_True)
| The text <me> follows the scale factor of the view if the flag is Standard_True. .
Standard_EXPORT void | SetOffset (const Standard_Real aDx=0.0, const Standard_Real aDy=0.0)
| Sets the Device space offset of the text <me>. .
Standard_EXPORT void | SetUnderline (const Standard_Boolean isUnderlined=Standard_False)
| Enable/Disable text underline. .
Standard_EXPORT void | SetAlignment (const Graphic2d_TypeOfAlignment anAlignment=Graphic2d_TOA_LEFT)
| Sets the text alignment. .
virtual Standard_EXPORT Standard_Boolean | Fit (const Quantity_Length aWidth, const Quantity_Length aHeight, const Standard_Boolean Adjust=Standard_True, const Standard_Boolean Expand=Standard_True)
| Compute text size depending of a required bounding box, Adjust the text position depending of the text origine and base line if "Adjust" is TRUE, Expand the text when the Width is smaller that the Fit Width if "Expand" is TRUE. and returns Standard_True if the current Driver used is enable to fit the text size. Warning: The fit computation is apply only if the corresponding dimension is > 0. .
virtual Standard_EXPORT Standard_Boolean | Trunc (const Quantity_Length aWidth)
| Trunc the text when the Width of the text is greater that the defined Width Max, and returns Standard_True if the current Driver used is enable to trunc the text size. .
Standard_EXPORT Standard_Boolean | IsZoomable () const
| Returns Standard_True if the Text <me> follows the scale factor of the view. .
Standard_EXPORT Standard_Boolean | IsUnderlined () const
| Returns Standard_True if the Text <me> is underlined. .
Standard_EXPORT Standard_Boolean | TextSize (Quantity_Length &aWidth, Quantity_Length &aHeight) const
| Returns Standard_True if the current Driver used is enabled to get the right size in the world size parameter <awidth>,<aheight> depending of the attributes of the text and the current scale of the view. .
virtual Standard_EXPORT Standard_Boolean | TextSize (Quantity_Length &aWidth, Quantity_Length &aHeight, Quantity_Length &anXoffset, Quantity_Length &anYoffset) const
| Returns Standard_True if the current Driver used is enabled to get the right size and text offsets in the world size parameter <awidth>,<aheight>,<anxoffset>,<anyoffset> depending of the attributes of the text and the current scale of the view. NOTE that the text offsets defines the relative position of the of the text string origin from the lower left corner of the text boundary limits. .
Standard_EXPORT void | Position (Quantity_Length &X, Quantity_Length &Y) const
| Returns the text position. .
Standard_EXPORT void | Offset (Standard_Real &X, Standard_Real &Y) const
| Returns the text Offset. .
Standard_EXPORT Quantity_PlaneAngle | Slant () const
| Returns the text slant. .
Standard_EXPORT Quantity_PlaneAngle | Angle () const
| Returns the text orientation. .
Standard_EXPORT Standard_Integer | FontIndex () const
| Returns the text font index. .
Standard_EXPORT Quantity_Factor | Scale () const
| Returns the text scale. .
Standard_EXPORT Graphic2d_TypeOfAlignment | Alignment () const
| Returns the text alignment. .
Standard_EXPORT TCollection_ExtendedString | GetText () const
| Returns the text string .
Standard_EXPORT Aspect_TypeOfText | GetType () const
| Returns the type text .
virtual Standard_EXPORT void | Save (Aspect_FStream &aFStream) const
Standard_EXPORT const | Handle (Standard_Type)&DynamicType() const

## Protected Member Functions

virtual Standard_EXPORT void | Draw (const Handle(Graphic2d_Drawer)&aDrawer)
| Draws the text <me>. .
virtual Standard_EXPORT Standard_Boolean | Pick (const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal aPrecision, const Handle(Graphic2d_Drawer)&aDrawer)
| Returns Standard_True if the text <me> is picked, Standard_False if not. .
virtual Standard_EXPORT Standard_Boolean | ComputeMinMax ()
| Computes the MinMax of the text if possible. .

## Protected Attributes

Standard_Integer | myFontIndex
Standard_ShortReal | myX
Standard_ShortReal | myDx
Standard_ShortReal | myY
Standard_ShortReal | myDy
Standard_ShortReal | myAngle
Aspect_TypeOfText | myType
TCollection_ExtendedString | myText
Standard_Boolean | myAdjustFlag
Standard_ShortReal | myDeltax
Standard_ShortReal | myDeltay
Standard_ShortReal | mySlant
Standard_Boolean | myIsZoomable
Standard_Boolean | myIsUnderlined
Quantity_Factor | myHScale
Quantity_Factor | myWScale
Graphic2d_TypeOfAlignment | myAlignment

## Constructor & Destructor Documentation

Standard_EXPORT Graphic2d_Text::Graphic2d_Text | ( | const Handle(Graphic2d_GraphicObject)& | aGraphicObject,
|  | const TCollection_ExtendedString & | aText,
|  | const Standard_Real | X,
|  | const Standard_Real | Y,
|  | const Quantity_PlaneAngle | anAngle = `0.0`,
|  | const Aspect_TypeOfText | aType = `Aspect_TOT_SOLID`,
|  | const Quantity_Factor | aScale = `1.0`
| ) |

## Member Function Documentation

Standard_EXPORT Graphic2d_TypeOfAlignment Graphic2d_Text::Alignment | ( |  | ) | const

Standard_EXPORT Quantity_PlaneAngle Graphic2d_Text::Angle | ( |  | ) | const

virtual Standard_EXPORT Standard_Boolean Graphic2d_Text::ComputeMinMax | ( |  | ) | `[protected, virtual]`

| Reimplemented from Graphic2d_Primitive. Reimplemented in Graphic2d_FramedText, and Graphic2d_HidingText.

virtual Standard_EXPORT void Graphic2d_Text::Draw | ( | const Handle(Graphic2d_Drawer)& | aDrawer | ) | `[protected, virtual]`

| Implements Graphic2d_Primitive. Reimplemented in Graphic2d_FramedText, and Graphic2d_HidingText.

virtual Standard_EXPORT Standard_Boolean Graphic2d_Text::Fit | ( | const Quantity_Length | aWidth,
|  | const Quantity_Length | aHeight,
|  | const Standard_Boolean | Adjust = `Standard_True`,
|  | const Standard_Boolean | Expand = `Standard_True`
| ) | `[virtual]`

| Reimplemented in Graphic2d_FramedText, and Graphic2d_HidingText.

Standard_EXPORT Standard_Integer Graphic2d_Text::FontIndex | ( |  | ) | const

Standard_EXPORT TCollection_ExtendedString Graphic2d_Text::GetText | ( |  | ) | const

Standard_EXPORT Aspect_TypeOfText Graphic2d_Text::GetType | ( |  | ) | const

Standard_EXPORT const Graphic2d_Text::Handle | ( | Standard_Type |  | ) | const

| Reimplemented from Graphic2d_Primitive. Reimplemented in Graphic2d_FramedText, and Graphic2d_HidingText.

Standard_EXPORT Standard_Boolean Graphic2d_Text::IsUnderlined | ( |  | ) | const

Standard_EXPORT Standard_Boolean Graphic2d_Text::IsZoomable | ( |  | ) | const

Standard_EXPORT void Graphic2d_Text::Offset | ( | Standard_Real & | X,
|  | Standard_Real & | Y
| ) | const

virtual Standard_EXPORT Standard_Boolean Graphic2d_Text::Pick | ( | const Standard_ShortReal | X,
|  | const Standard_ShortReal | Y,
|  | const Standard_ShortReal | aPrecision,
|  | const Handle(Graphic2d_Drawer)& | aDrawer
| ) | `[protected, virtual]`

| Implements Graphic2d_Primitive. Reimplemented in Graphic2d_FramedText, and Graphic2d_HidingText.

Standard_EXPORT void Graphic2d_Text::Position | ( | Quantity_Length & | X,
|  | Quantity_Length & | Y
| ) | const

virtual Standard_EXPORT void Graphic2d_Text::Save | ( | Aspect_FStream & | aFStream | ) | const`[virtual]`

| Implements Graphic2d_Primitive. Reimplemented in Graphic2d_FramedText, and Graphic2d_HidingText.

Standard_EXPORT Quantity_Factor Graphic2d_Text::Scale | ( |  | ) | const

Standard_EXPORT void Graphic2d_Text::SetAlignment | ( | const Graphic2d_TypeOfAlignment | anAlignment = `Graphic2d_TOA_LEFT` | ) |

Standard_EXPORT void Graphic2d_Text::SetFontIndex | ( | const Standard_Integer | anIndex = `0` | ) |

Standard_EXPORT void Graphic2d_Text::SetOffset | ( | const Standard_Real | aDx = `0.0`,
|  | const Standard_Real | aDy = `0.0`
| ) |

Standard_EXPORT void Graphic2d_Text::SetSlant | ( | const Quantity_PlaneAngle | aSlant = `0.0` | ) |

Standard_EXPORT void Graphic2d_Text::SetUnderline | ( | const Standard_Boolean | isUnderlined = `Standard_False` | ) |

Standard_EXPORT void Graphic2d_Text::SetZoomable | ( | const Standard_Boolean | aFlag = `Standard_True` | ) |

Standard_EXPORT Quantity_PlaneAngle Graphic2d_Text::Slant | ( |  | ) | const

virtual Standard_EXPORT Standard_Boolean Graphic2d_Text::TextSize | ( | Quantity_Length & | aWidth,
|  | Quantity_Length & | aHeight,
|  | Quantity_Length & | anXoffset,
|  | Quantity_Length & | anYoffset
| ) | const`[virtual]`

| Reimplemented in Graphic2d_FramedText, and Graphic2d_HidingText.

Standard_EXPORT Standard_Boolean Graphic2d_Text::TextSize | ( | Quantity_Length & | aWidth,
|  | Quantity_Length & | aHeight
| ) | const

virtual Standard_EXPORT Standard_Boolean Graphic2d_Text::Trunc | ( | const Quantity_Length | aWidth | ) | `[virtual]`

| Reimplemented in Graphic2d_FramedText, and Graphic2d_HidingText.

## Field Documentation

Standard_Boolean Graphic2d_Text::myAdjustFlag `[protected]`

Graphic2d_TypeOfAlignment Graphic2d_Text::myAlignment `[protected]`

Standard_ShortReal Graphic2d_Text::myAngle `[protected]`

Standard_ShortReal Graphic2d_Text::myDeltax `[protected]`

Standard_ShortReal Graphic2d_Text::myDeltay `[protected]`

Standard_ShortReal Graphic2d_Text::myDx `[protected]`

Standard_ShortReal Graphic2d_Text::myDy `[protected]`

Standard_Integer Graphic2d_Text::myFontIndex `[protected]`

Quantity_Factor Graphic2d_Text::myHScale `[protected]`

Standard_Boolean Graphic2d_Text::myIsUnderlined `[protected]`

Standard_Boolean Graphic2d_Text::myIsZoomable `[protected]`

Standard_ShortReal Graphic2d_Text::mySlant `[protected]`

TCollection_ExtendedString Graphic2d_Text::myText `[protected]`

Aspect_TypeOfText Graphic2d_Text::myType `[protected]`

Quantity_Factor Graphic2d_Text::myWScale `[protected]`

Standard_ShortReal Graphic2d_Text::myX `[protected]`

Standard_ShortReal Graphic2d_Text::myY `[protected]`

The documentation for this class was generated from the following file:

- Graphic2d_Text.hxx