Ocean
Ocean::Rendering::Text Class Reference

This class is the base class for all texts. More...

Inheritance diagram for Ocean::Rendering::Text:

Public Types

enum  AlignmentMode { AM_LEFT , AM_CENTER , AM_RIGHT }
 Definition of individual alignment modes within the text block. More...
 
enum  HorizontalAnchor { HA_LEFT , HA_CENTER , HA_RIGHT }
 Definition of individual horizontal anchor points for the entire text block. More...
 
enum  VerticalAnchor { VA_TOP , VA_MIDDLE , VA_BOTTOM }
 Definition of individual vertical anchor points for the entire text block. More...
 
- Public Types inherited from Ocean::Rendering::Object
enum  ObjectType {
  TYPE_UNKNOWN , TYPE_ABSOLUTE_TRANSFORM , TYPE_ATTRIBUTE , TYPE_ATTRIBUTE_SET ,
  TYPE_BACKGROUND , TYPE_BILLBOARD , TYPE_BITMAP_FRAMEBUFFER , TYPE_BLEND_ATTRIBUTE ,
  TYPE_BOX , TYPE_CONE , TYPE_CYLINDER , TYPE_DEPTH_ATTRIBUTE ,
  TYPE_DIRECTIONAL_LIGHT , TYPE_FRAMEBUFFER , TYPE_FRAME_TEXTURE_2D , TYPE_GEOMETRY ,
  TYPE_GROUP , TYPE_INDEPENDENT_PRIMITIVE , TYPE_LIGHT_SOURCE , TYPE_LINES ,
  TYPE_LINE_STRIPS , TYPE_LOD , TYPE_MATERIAL , TYPE_NODE ,
  TYPE_OBJECT , TYPE_PARALLEL_VIEW , TYPE_PERSPECTIVE_VIEW , TYPE_PHANTOM_ATTRIBUTE ,
  TYPE_POINT_LIGHT , TYPE_POINTS , TYPE_PRIMITIVE , TYPE_PRIMITIVE_ATTRIBUTE ,
  TYPE_QUAD_STRIPS , TYPE_QUADS , TYPE_RENDERABLE , TYPE_SCENE ,
  TYPE_SHADER_PROGRAM , TYPE_SHAPE , TYPE_SKY_BACKGROUND , TYPE_SPHERE ,
  TYPE_SPOT_LIGHT , TYPE_STEREO_ATTRIBUTE , TYPE_STEREO_VIEW , TYPE_STRIP_PRIMITIVE ,
  TYPE_SWITCH , TYPE_TEXT , TYPE_TEXTURE , TYPE_TEXTURE_2D ,
  TYPE_MEDIA_TEXTURE_2D , TYPE_TEXTURE_FRAMEBUFFER , TYPE_TEXTURES , TYPE_TRANSFORM ,
  TYPE_TRIANGLE_FANS , TYPE_TRIANGLES , TYPE_TRIANGLE_STRIPS , TYPE_UNDISTORTED_BACKGROUND ,
  TYPE_VERTEX_SET , TYPE_VIEW , TYPE_WINDOW_FRAMEBUFFER
}
 Definition of different object type. More...
 
typedef std::unordered_map< ObjectId, unsigned int > ObjectIdMap
 Definition of a map holding object ids to reference counters. More...
 

Public Member Functions

virtual std::string text () const
 Returns the text to be rendered. More...
 
virtual Vector2 size () const
 Returns the actual width and height of the text. More...
 
virtual std::string fontFamily (std::string *styleName=nullptr) const
 Returns the font which is used to render the text. More...
 
virtual MaterialRef backgroundMaterial () const
 Returns the material which is used to render the background of the text. More...
 
virtual AlignmentMode alignmentMode () const
 Returns the alignment mode of the text. More...
 
virtual HorizontalAnchor horizontalAnchor () const
 Returns the horizontal anchor of the text. More...
 
virtual VerticalAnchor verticalAnchor () const
 Returns the vertical anchor of the text. More...
 
virtual void setText (const std::string &text)
 Sets the text to be rendred. More...
 
virtual bool setSize (const Scalar fixedWidth, const Scalar fixedHeight, const Scalar fixedLineHeight)
 Sets the size of the text. More...
 
virtual void setFont (const std::string &fontFamily, const std::string &styleName=std::string())
 Sets the font to be used when rendering the text. More...
 
virtual void setBackgroundMaterial (const MaterialRef &material)
 Returns the material which is used to render the background of the text. More...
 
virtual void setAlignmentMode (const AlignmentMode alignmentMode)
 Sets the alignment mode of the text. More...
 
virtual void setHorizontalAnchor (const HorizontalAnchor horizontalAnchor)
 Sets the horizontal anchor of the text. More...
 
virtual void setVerticalAnchor (const VerticalAnchor verticalAnchor)
 Sets the vertical anchor of the text. More...
 
virtual void setGeometryLookupTable (const LookupCorner2< Vector3 > &lookupTable)
 Sets an explicit lookup table which will be used to determine the text geometry (the vertices of the text). More...
 
virtual bool isFontAvailable (const std::string &familyName, const std::string &styleName=std::string()) const
 Returns whether a specific font is currently available. More...
 
virtual std::string availableDefaultFont (std::string *styleName=nullptr) const
 Returns the default front currently available. More...
 
virtual std::vector< std::string > availableFamilyNames () const
 Returns all available family names. More...
 
virtual std::vector< std::string > availableStyleNames (const std::string &familyName) const
 Returns the style names of all available fonts with specified family name. More...
 
ObjectType type () const override
 Returns the type of this object. More...
 
- Public Member Functions inherited from Ocean::Rendering::Object
ObjectId id () const
 Returns the unique object id of this object. More...
 
const std::string & name () const
 Returns the name of this object. More...
 
virtual void setName (const std::string &name)
 Sets or changes the name of this object. More...
 
virtual const std::string & engineName () const =0
 Returns the name of the owner engine. More...
 
ObjectRefs parentObjects () const
 Returns all parent objects. More...
 
ObjectRefSet parentNodes () const
 Returns all parent nodes. More...
 
virtual std::string descriptiveInformation () const
 Returns descriptive information about the object as string. More...
 

Protected Member Functions

 Text ()
 Creates a new text object. More...
 
 ~Text () override
 Destructs the text object. More...
 
- Protected Member Functions inherited from Ocean::Rendering::Shape
 Shape ()
 Creates a new shape node. More...
 
 ~Shape () override
 Destructs a shape node. More...
 
- Protected Member Functions inherited from Ocean::Rendering::Renderable
 Renderable ()
 Creates a new renderable object. More...
 
 ~Renderable () override
 Destructs a renderable object. More...
 
- Protected Member Functions inherited from Ocean::Rendering::Object
 Object ()
 Creates a new object. More...
 
 Object (const Object &object)=delete
 Disabled copy constructor. More...
 
virtual ~Object ()
 Destructs an object. More...
 
Engineengine () const
 Returns the render engine which is owner of this object. More...
 
void registerParent (const ObjectId parentId)
 Registers a parent node for this (child) node. More...
 
void unregisterParent (const ObjectId parentId)
 Unregisters a parent node for this (child) node. More...
 
void registerThisObjectAsParent (const ObjectRef &child)
 Registers this object at a child as parent object. More...
 
void unregisterThisObjectAsParent (const ObjectRef &child)
 Unregisters this object from a child as parent. More...
 
Objectoperator= (const Object &object)=delete
 Disabled copy operator. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Ocean::Rendering::Object
static std::string translateObjectType (const ObjectType objectType)
 Translates an object type to a readable string. More...
 
- Protected Attributes inherited from Ocean::Rendering::Object
Lock objectLock
 Lock for the object. More...
 

Detailed Description

This class is the base class for all texts.

Member Enumeration Documentation

◆ AlignmentMode

Definition of individual alignment modes within the text block.

Enumerator
AM_LEFT 

The text is aligned to the left of the text block.

The alignment mode is visualized below:

 ------------------------
| This is the first line |
| The second line        |
| ...                    |
| The last line          |
 ------------------------
AM_CENTER 

The text is aligned at the center of the text block.

The alignment mode is visualized below:

 ------------------------
| This is the first line |
|    The second line     |
|          ...           |
|      The last line     |
 ------------------------
AM_RIGHT 

The text is aligned to the left of the text block.

The alignment mode is visualized below:

 ------------------------
| This is the first line |
|        The second line |
|                    ... |
|          The last line |
 ------------------------

◆ HorizontalAnchor

Definition of individual horizontal anchor points for the entire text block.

Enumerator
HA_LEFT 

The text block is anchored at the left edge.

The anchor mode is visualized below:

(A)-------------------------          (A): HA_LEFT, VA_TOP
 |  This is the first line  |
(B) ...                     |         (B): HA_LEFT, VA_MIDDLE
 |  The last line           |
(C)-------------------------          (C): HA_LEFT, VA_BOTTOM
HA_CENTER 

The text block is anchored at the center of the text block.

The anchor mode is visualized below:

 ------------(A)------------          (A): HA_CENTER, VA_TOP
|  This is the first line   |
|  ...       (B)            |         (B): HA_CENTER, VA_MIDDLE
|  The last line            |
  -----------(C)------------          (C): HA_CENTER, VA_BOTTOM
HA_RIGHT 

The text block is anchored at the right edge.

The anchor mode is visualized below:

 -------------------------(A)          (A): HA_RIGHT, VA_TOP
|  This is the first line  |
|  ...                    (B)          (B): HA_RIGHT, VA_MIDDLE
|  The last line           |
 -------------------------(C)          (C): HA_RIGHT, VA_BOTTOM

◆ VerticalAnchor

Definition of individual vertical anchor points for the entire text block.

Enumerator
VA_TOP 

The text block is anchored at the top edge.

VA_MIDDLE 

The text block is anchored at middle oft he text block.

VA_BOTTOM 

The text block is anchored at the bottom edge.

Constructor & Destructor Documentation

◆ Text()

Ocean::Rendering::Text::Text ( )
protected

Creates a new text object.

◆ ~Text()

Ocean::Rendering::Text::~Text ( )
overrideprotected

Destructs the text object.

Member Function Documentation

◆ alignmentMode()

virtual AlignmentMode Ocean::Rendering::Text::alignmentMode ( ) const
virtual

Returns the alignment mode of the text.

Returns
The text's alignment mode

Reimplemented in Ocean::Rendering::GLESceneGraph::GLESText.

◆ availableDefaultFont()

virtual std::string Ocean::Rendering::Text::availableDefaultFont ( std::string *  styleName = nullptr) const
virtual

Returns the default front currently available.

Parameters
styleNameOptional resulting style name of the resulting font, nullptr if not of interest
Returns
The family name of the currently available font, empty if no default is available

Reimplemented in Ocean::Rendering::GLESceneGraph::GLESText.

◆ availableFamilyNames()

virtual std::vector<std::string> Ocean::Rendering::Text::availableFamilyNames ( ) const
virtual

Returns all available family names.

Returns
The family names which are available
See also
setFont(), availableStyleNames().

Reimplemented in Ocean::Rendering::GLESceneGraph::GLESText.

◆ availableStyleNames()

virtual std::vector<std::string> Ocean::Rendering::Text::availableStyleNames ( const std::string &  familyName) const
virtual

Returns the style names of all available fonts with specified family name.

Parameters
familyNameThe family name of the fonts for which all available style names will be returned
Returns
The style names of all available fonts

Reimplemented in Ocean::Rendering::GLESceneGraph::GLESText.

◆ backgroundMaterial()

virtual MaterialRef Ocean::Rendering::Text::backgroundMaterial ( ) const
virtual

Returns the material which is used to render the background of the text.

By default, the text will be rendered with a black opaque background.

Returns
The text's background material

Reimplemented in Ocean::Rendering::GLESceneGraph::GLESText.

◆ fontFamily()

virtual std::string Ocean::Rendering::Text::fontFamily ( std::string *  styleName = nullptr) const
virtual

Returns the font which is used to render the text.

Parameters
styleNameOptional resulting style name of the font
Returns
The text's font

Reimplemented in Ocean::Rendering::GLESceneGraph::GLESText.

◆ horizontalAnchor()

virtual HorizontalAnchor Ocean::Rendering::Text::horizontalAnchor ( ) const
virtual

Returns the horizontal anchor of the text.

Returns
The text's horizontal anchor

Reimplemented in Ocean::Rendering::GLESceneGraph::GLESText.

◆ isFontAvailable()

virtual bool Ocean::Rendering::Text::isFontAvailable ( const std::string &  familyName,
const std::string &  styleName = std::string() 
) const
virtual

Returns whether a specific font is currently available.

Parameters
familyNameThe name of the font family to check
styleNameOptional explicit font style to check
Returns
True, if so

Reimplemented in Ocean::Rendering::GLESceneGraph::GLESText.

◆ setAlignmentMode()

virtual void Ocean::Rendering::Text::setAlignmentMode ( const AlignmentMode  alignmentMode)
virtual

Sets the alignment mode of the text.

Parameters
alignmentModeThe alignment node to be set

Reimplemented in Ocean::Rendering::GLESceneGraph::GLESText.

◆ setBackgroundMaterial()

virtual void Ocean::Rendering::Text::setBackgroundMaterial ( const MaterialRef material)
virtual

Returns the material which is used to render the background of the text.

By default, the text will be rendered with a black opaque background.
The background can be fully customized by e.g., setting a different diffuse color or the transparency of the background.

To render the text without background, the material must be entirely transparent and a BlendAttribute must be attached to the corresponding AttributeSet:

blendAttribute->setSourceFunction(BlendAttribute::BlendingFunction::FUNCTION_ONE);
blendAttribute->setDestinationFunction(BlendAttribute::BlendingFunction::FUNCTION_ONE_MINUS_SOURCE_ALPHA); // fully transparent with pre-multiplied alpha
textAttributeSet->addAttribute(blendAttribute);
textBackgroundMaterial->setTransparency(1.0f);
virtual const Factory & factory() const =0
Returns the factory of this render engine.
virtual ObjectRef createBlendAttribute() const
Creates a new blend attribute object.
Engine & engine() const
Returns the render engine which is owner of this object.
SmartObjectRef< BlendAttribute > BlendAttributeRef
Definition of a smart object reference holding a blend attribute.
Definition: BlendAttribute.h:21

To render the text with partially transparent background, the material must be translucent and a BlendAttribute must be attached to the corresponding AttributeSet:

blendAttribute->setSourceFunction(BlendAttribute::BlendingFunction::FUNCTION_SOURCE_ALPHA);
blendAttribute->setDestinationFunction(BlendAttribute::BlendingFunction::FUNCTION_ONE_MINUS_SOURCE_ALPHA); // translucent with standard blending
textAttributeSet->addAttribute(blendAttribute);
textBackgroundMaterial->setTransparency(0.5f);

To render the text with opaque background, the material must be opaque:

textBackgroundMaterial->setTransparency(0.0f);
Parameters
materialThe background material to be set

Reimplemented in Ocean::Rendering::GLESceneGraph::GLESText.

◆ setFont()

virtual void Ocean::Rendering::Text::setFont ( const std::string &  fontFamily,
const std::string &  styleName = std::string() 
)
virtual

Sets the font to be used when rendering the text.

Parameters
fontFamilyThe family identifying the font, must be valid
styleNameThe optional style name of the font, empty to use the default style
See also
availableFamilyNames(), availableStyleNames().

Reimplemented in Ocean::Rendering::GLESceneGraph::GLESText.

◆ setGeometryLookupTable()

virtual void Ocean::Rendering::Text::setGeometryLookupTable ( const LookupCorner2< Vector3 > &  lookupTable)
virtual

Sets an explicit lookup table which will be used to determine the text geometry (the vertices of the text).

In case a lookup table is set, the horizontal and vertical anchor do not have any meaning anymore.
The width and height of the lookup table must be identical to the number of horizontal and vertical bins.

Parameters
lookupTableThe lookup table to be set, an invalid lookup table to remove a previously set table

Reimplemented in Ocean::Rendering::GLESceneGraph::GLESText.

◆ setHorizontalAnchor()

virtual void Ocean::Rendering::Text::setHorizontalAnchor ( const HorizontalAnchor  horizontalAnchor)
virtual

Sets the horizontal anchor of the text.

Parameters
horizontalAnchorThe horizontal anchor to be set

Reimplemented in Ocean::Rendering::GLESceneGraph::GLESText.

◆ setSize()

virtual bool Ocean::Rendering::Text::setSize ( const Scalar  fixedWidth,
const Scalar  fixedHeight,
const Scalar  fixedLineHeight 
)
virtual

Sets the size of the text.

Four different size modes are supported:
1) The text block has a fixed width and the height is automatically determined by preserving the aspect ratio.
2) The text block has a fixed height and the width is automatically determined by preserving the aspect ratio.
3) The text block has a fixed width and fixed height the text's aspect ratio is not preserved.
4) The width and height of the text block is automatically determined by ensuring that each text line has a specified height while the aspect ratio is preserved.

Parameters
fixedWidthThe fixed width of the text block, with range (0, infinity), 0 to define the width indirect via 'fixedHeight' or 'fixedLineHeight'
fixedHeightThe fixed height of the text block, with range (0, infinity), 0 to define the height indirect via 'fixedWidth' or 'fixedLineHeight'
fixedLineHeightThe height of each line in the text block, with range (0, infinity), 0 to define the size via 'fixedWidth' and/or 'fixedHeight'
Returns
True, if the provided combination of size parameter is valid

Reimplemented in Ocean::Rendering::GLESceneGraph::GLESText.

◆ setText()

virtual void Ocean::Rendering::Text::setText ( const std::string &  text)
virtual

Sets the text to be rendred.

Multiple lines can be rendered by adding a line feed character ('
') at the end of a line.

Parameters
textThe text to be rendered

Reimplemented in Ocean::Rendering::GLESceneGraph::GLESText.

◆ setVerticalAnchor()

virtual void Ocean::Rendering::Text::setVerticalAnchor ( const VerticalAnchor  verticalAnchor)
virtual

Sets the vertical anchor of the text.

Parameters
verticalAnchorThe vertical anchor to be set

Reimplemented in Ocean::Rendering::GLESceneGraph::GLESText.

◆ size()

virtual Vector2 Ocean::Rendering::Text::size ( ) const
virtual

Returns the actual width and height of the text.

Returns
The text's width and height

Reimplemented in Ocean::Rendering::GLESceneGraph::GLESText.

◆ text()

virtual std::string Ocean::Rendering::Text::text ( ) const
virtual

Returns the text to be rendered.

Returns
The text which will be rendered

Reimplemented in Ocean::Rendering::GLESceneGraph::GLESText.

◆ type()

ObjectType Ocean::Rendering::Text::type ( ) const
overridevirtual

Returns the type of this object.

See also
Object::type().

Reimplemented from Ocean::Rendering::Shape.

◆ verticalAnchor()

virtual VerticalAnchor Ocean::Rendering::Text::verticalAnchor ( ) const
virtual

Returns the vertical anchor of the text.

Returns
The text's vertical anchor

Reimplemented in Ocean::Rendering::GLESceneGraph::GLESText.


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