H3D::Text Class Reference
[X3D node classes.]

The Text node specifies a two-sided, flat text string object positioned in the Z=0 plane of the local coordinate system based on values defined in the fontStyle field (see FontStyle). More...

#include <H3D/Text.h>

Inheritance diagram for H3D::Text:

Inheritance graph

List of all members.

Classes

class  DisplayList
 We extend the DisplayList to build the fonts of the X3DFontStyleNode in the fontStyle field of the Text node this DisplayList resides in. More...
class  SFBound
 The SFBound field is specialized to update itself from the values in the fields of the Text node. More...

Public Member Functions

 Text (Inst< SFNode > _metadata=0, Inst< SFBound > _bound=0, Inst< DisplayList > _displayList=0, Inst< SFFontStyleNode > _fontStyle=0, Inst< MFFloat > _length=0, Inst< SFFloat > _maxExtent=0, Inst< MFString > _string=0, Inst< SFBool > _solid=0)
 Constructor.
virtual void render ()
 Render the text with OpenGL.
virtual void traverseSG (TraverseInfo &ti)
 Traverse the scenegraph.
virtual int nrTriangles ()
 The number of triangles renderered in this geometry, we don't know so return -1.
virtual bool lineIntersect (const Vec3f &from, const Vec3f &to, LineIntersectResult &result)
 Detect intersection between a line segment and the texts bounding box.

Public Attributes

auto_ptr< SFFontStyleNodefontStyle
 The style the text should be rendered with.
auto_ptr< MFFloatlength
 The length field contains an MFFloat value that specifies the length of each text string in the local coordinate system.
auto_ptr< SFFloatmaxExtent
 The maxExtent field limits and compresses all of the text strings if the length of the maximum string is longer than the maximum extent, as measured in the local coordinate system.
auto_ptr< MFStringstringF
 The strings to render.
auto_ptr< SFBoolsolid
 The solid field determines whether one or both sides of each polygon shall be displayed.

Static Public Attributes

static H3DNodeDatabase database
 The H3DNodeDatabase for this node.

Protected Member Functions

virtual void scaleToMaxExtent (const vector< string > &text, X3DFontStyleNode *font)
 Scales the scene so that the text given would be contained within the value of the maxExtent field.
virtual void justifyMinor (const vector< string > &text, X3DFontStyleNode *font)
 Justify the text in the minor alignment by translating it in the way described in the FontStyle node.
virtual void moveToNewLine (const string &text, X3DFontStyleNode *font)
 Move to the position of the next line.
virtual void renderTextLine (const string &text, X3DFontStyleNode *font)
 Render a line of text in the style of the X3DFontStyleNode given.
virtual void justifyLine (const string &text, X3DFontStyleNode *font)
 Justify the line of text in the major alignment by translating it in the way described in the FontStyle node.


Detailed Description

The Text node specifies a two-sided, flat text string object positioned in the Z=0 plane of the local coordinate system based on values defined in the fontStyle field (see FontStyle).

Text nodes may contain multiple text strings specified using the UTF-8 encoding. The text strings are stored in the order in which the text mode characters are to be produced as defined by the parameters in the FontStyle node.

The text strings are contained in the string field. The fontStyle field contains one FontStyle node that specifies the font size, font family and style, direction of the text strings, and any specific language rendering techniques used for the text.

The maxExtent field limits and compresses all of the text strings if the length of the maximum string is longer than the maximum extent, as measured in the local coordinate system. If the text string with the maximum length is shorter than the maxExtent, then there is no compressing. The maximum extent is measured horizontally for horizontal text (FontStyle node: horizontal=TRUE) and vertically for vertical text (FontStyle node: horizontal=FALSE). The maxExtent field shall be greater than or equal to zero.

The length field contains an MFFloat value that specifies the length of each text string in the local coordinate system. If the string is too short, it is stretched (either by scaling the text or by adding space between the characters). If the string is too long, it is compressed (either by scaling the text or by subtracting space between the characters). If a length value is missing (for example, if there are four strings but only three length values), the missing values are considered to be 0. The length field shall be greater than or equal to zero.

Specifying a value of 0 for both the maxExtent and length fields indicates that the string may be any length.

The solid field determines whether one or both sides of each polygon shall be displayed. If solid is FALSE, each polygon is visible regardless of the viewing direction and if it is TRUE back face culling is performed to only show the front face of the polygons.

Internal routes:
Text.dot

Member Function Documentation

void Text::justifyLine ( const string &  text,
X3DFontStyleNode font 
) [protected, virtual]

void Text::justifyMinor ( const vector< string > &  text,
X3DFontStyleNode font 
) [protected, virtual]

bool Text::lineIntersect ( const Vec3f &  from,
const Vec3f &  to,
LineIntersectResult &  result 
) [virtual]

Detect intersection between a line segment and the texts bounding box.

Parameters:
from The start of the line segment.
to The end of the line segment.
result Contains info about the closest intersection for every object that intersects the line.
Returns:
true if intersected, false otherwise.

Reimplemented from H3D::X3DGeometryNode.

References H3D::H3DBoundedObject::bound, H3D::Bound::lineSegmentIntersect(), IntersectionInfo::normal, and IntersectionInfo::point.

void Text::moveToNewLine ( const string &  text,
X3DFontStyleNode font 
) [protected, virtual]

Move to the position of the next line.

What the next line is depends on the values in the FontStyle node, i.e. if the text is horizontal, if it is top to bottom or the other way around, spacing etc.

References H3D::X3DFontStyleNode::getAlignment(), H3D::X3DFontStyleNode::getSpacing(), H3D::X3DFontStyleNode::isLeftToRight(), H3D::X3DFontStyleNode::isTopToBottom(), and H3D::X3DFontStyleNode::stringDimensions().

Referenced by render().

void Text::renderTextLine ( const string &  text,
X3DFontStyleNode font 
) [protected, virtual]

Render a line of text in the style of the X3DFontStyleNode given.

The OpenGL transform matrices will not be changed by the call.

References H3D::X3DFontStyleNode::charDimensions(), H3D::X3DFontStyleNode::getAlignment(), H3D::X3DFontStyleNode::isLeftToRight(), H3D::X3DFontStyleNode::isTopToBottom(), and H3D::X3DFontStyleNode::renderChar().

Referenced by render().

void Text::scaleToMaxExtent ( const vector< string > &  text,
X3DFontStyleNode font 
) [protected, virtual]

Scales the scene so that the text given would be contained within the value of the maxExtent field.

The length field is inspected as well as the dimensions of the text to determine what the scale should be.

References H3D::X3DFontStyleNode::getAlignment(), length, maxExtent, and H3D::X3DFontStyleNode::stringDimensions().

Referenced by render().

void Text::traverseSG ( TraverseInfo ti  )  [virtual]

Traverse the scenegraph.

A HAPIHapticShape is added for haptic rendering if haptics is enabled.

Parameters:
ti The TraverseInfo object containing information about the traversal.

Reimplemented from H3D::X3DGeometryNode.

References solid, and H3D::X3DGeometryNode::useBackFaceCulling().


Member Data Documentation

The style the text should be rendered with.

See X3DFontStyleNode.

Access type: inputOutput

Text_fontStyle.dot

Referenced by render(), and Text().

The length field contains an MFFloat value that specifies the length of each text string in the local coordinate system.

If the string is too short, it is stretched (either by scaling the text or by adding space between the characters). If the string is too long, it is compressed (either by scaling the text or by subtracting space between the characters). If a length value is missing (for example, if there are four strings but only three length values), the missing values are considered to be 0. The length field shall be greater than or equal to zero.

Access type: inputOutput
Default value: []
Valid range: >=0

Text_length.dot

Referenced by render(), scaleToMaxExtent(), Text(), and H3D::Text::SFBound::update().

The maxExtent field limits and compresses all of the text strings if the length of the maximum string is longer than the maximum extent, as measured in the local coordinate system.

If the text string with the maximum length is shorter than the maxExtent, then there is no compressing. The maximum extent is measured horizontally for horizontal text (FontStyle node: horizontal=TRUE) and vertically for vertical text (FontStyle node: horizontal=FALSE). The maxExtent field shall be greater than or equal to zero.

Access type: inputOutput
Default value: 0
Valid range: >=0

Text_maxExtent.dot

Referenced by scaleToMaxExtent(), and Text().

auto_ptr< SFBool > H3D::Text::solid

The solid field determines whether one or both sides of each polygon shall be displayed.

If solid is FALSE, each polygon is visible regardless of the viewing direction and if it is TRUE back face culling is performed to only show the front face of the polygons.

Access type: inputOutput
Default value: FALSE

Text_solid.dot

Referenced by Text(), and traverseSG().

The strings to render.

Each string will be on its own line.

Access type: inputOutput

Text_string.dot

Referenced by render(), and Text().


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

Generated on Fri Nov 7 10:31:09 2008 for H3D API by  doxygen 1.5.7