Screen-aligned 2D text shape node. More...
#include <Inventor/nodes/SoText2.h>
Public Types | |
enum | Justification { LEFT = 0x01 , CENTER = 0x03 , RIGHT = 0x02 , INHERITED = 0x04 } |
Justification types. More... | |
Public Types inherited from SoShape | |
enum | ShapeType { POINTS , LINES , POLYGONS , TEXT } |
Basic type for antialiased rendering for this shape (Do not consider the SoDrawStyle property currently in the state). More... | |
Public Member Functions | |
virtual SoType | getTypeId () const |
Returns the type identifier for this specific instance. | |
SoText2 () | |
Creates a 2D text node with default settings. | |
Public Member Functions inherited from SoShape | |
virtual SbBool | affectsState () const |
Overrides default method on SoNode. | |
ShapeType | getShapeType () |
Gets the current shape Full Scene Antialiasing type. | |
Public Member Functions inherited from SoNode | |
virtual void | setOverride (const SbBool state) |
Turns the override flag on or off. | |
virtual SbBool | isOverride () const |
Returns the state of the override flag. | |
virtual SoNode * | copy (SbBool copyConnections=FALSE) const |
Creates and returns an exact copy of the node. | |
virtual void | touch () |
Marks an instance as modified, simulating a change to it. | |
Public Member Functions inherited from SoFieldContainer | |
void | setToDefaults () |
Sets all fields in this object to their default values. | |
SbBool | hasDefaultValues () const |
Returns TRUE if all of the object's fields have their default values. | |
SbBool | fieldsAreEqual (const SoFieldContainer *fc) const |
Returns TRUE if this object's fields are exactly equal to fc's fields. | |
void | copyFieldValues (const SoFieldContainer *fc, SbBool copyConnections=FALSE) |
Copies the contents of fc's fields into this object's fields. | |
SoNONUNICODE SbBool | set (const char *fieldDataString) |
Sets one or more fields in this object to the values specified in the given string, which should be a string in the Open Inventor file format. | |
SbBool | set (const SbString &fieldDataString) |
Sets one or more fields in this object to the values specified in the given string, which should be a string in the Open Inventor file format. | |
void | get (SbString &fieldDataString) |
Returns the values of the fields of this object in the Open Inventor ASCII file format in the given string. | |
virtual int | getFields (SoFieldList &list) const |
Appends references to all of this object's fields to resultList, and returns the number of fields appended. | |
virtual int | getAllFields (SoFieldList &list) const |
Returns a list of fields, including the eventIn's and eventOut's. | |
virtual SoField * | getField (const SbName &fieldName) const |
Returns a the field of this object whose name is fieldName. | |
virtual SoField * | getEventIn (const SbName &fieldName) const |
Returns a the eventIn with the given name. | |
virtual SoField * | getEventOut (const SbName &fieldName) const |
Returns the eventOut with the given name. | |
SbBool | getFieldName (const SoField *field, SbName &fieldName) const |
Returns the name of the given field in the fieldName argument. | |
SbBool | enableNotify (SbBool flag) |
Notification at this Field Container is enabled (if flag == TRUE) or disabled (if flag == FALSE). | |
SbBool | isNotifyEnabled () const |
Notification is the process of telling interested objects that this object has changed. | |
virtual void | setUserData (void *data) |
Sets application data. | |
void * | getUserData (void) const |
Gets user application data. | |
Public Member Functions inherited from SoBase | |
virtual SbName | getName () const |
Returns the name of an instance. | |
virtual void | setName (const SbName &name) |
Sets the name of an instance. | |
void | setSynchronizable (const bool b) |
Sets this to be a ScaleViz synchronizable object. | |
bool | isSynchronizable () const |
Gets the ScaleViz synchronizable state of this object. | |
Public Member Functions inherited from SoRefCounter | |
void | ref () const |
Adds a reference to an instance. | |
void | unref () const |
Removes a reference from an instance. | |
void | unrefNoDelete () const |
unrefNoDelete() should be called when it is desired to decrement the reference count, but not delete the instance if this brings the reference count to zero. | |
int | getRefCount () const |
Returns current reference count. | |
void | lock () const |
lock this instance. | |
void | unlock () const |
unlock this instance. | |
Public Member Functions inherited from SoTypedObject | |
SbBool | isOfType (const SoType &type) const |
Returns TRUE if this object is of the type specified in type or is derived from that type. | |
template<typename TypedObjectClass > | |
SbBool | isOfType () const |
Returns TRUE if this object is of the type of class TypedObjectClass or is derived from that class. | |
Static Public Member Functions | |
static SoType | getClassTypeId () |
Returns the type identifier for this class. | |
Static Public Member Functions inherited from SoShape | |
static SoType | getClassTypeId () |
Returns the type identifier for this class. | |
static SbBool | isPrimitiveRestartAvailable (SoState *state=NULL) |
Returns TRUE if the primitive restart feature is available. | |
Static Public Member Functions inherited from SoNode | |
static SoType | getClassTypeId () |
Returns the type identifier for this class. | |
static SoNode * | getByName (const SbName &name) |
A node's name can be set using SoBase::setName(). | |
static int | getByName (const SbName &name, SoNodeList &list) |
A node's name can be set using SoBase::setName(). | |
Static Public Member Functions inherited from SoFieldContainer | |
static SoType | getClassTypeId () |
Returns the type of this class. | |
Static Public Member Functions inherited from SoBase | |
static SoType | getClassTypeId () |
Returns type identifier for this class. | |
Static Public Member Functions inherited from SoTypedObject | |
static SoType | getClassTypeId () |
Returns the type identifier for this class. | |
Public Attributes | |
SoMFString | string |
The text string(s) to display. | |
SoSFFloat | spacing |
Defines the distance (in the negative y direction) between the base points of successive strings, measured with respect to the current font height. | |
SoSFEnum | justification |
Specifies horizontal alignment of strings. | |
Public Attributes inherited from SoShape | |
SoSFBool | boundingBoxIgnoring |
Whether to ignore this node during bounding box traversal. | |
Friends | |
class | SoAnnoText3 |
class | SoFontServer |
Screen-aligned 2D text shape node.
This node defines one or more strings of 2D text. The text is always horizontal, aligned with the screen and does not change size with distance from the camera. However the position of the text is specified in 3D units and is affected by viewing and modeling transformations. 2D text cannot be rotated, but because it always faces the user, it is often used for annotation, for example labels on axes.
The text position is always at the local origin (0,0,0). Rotations and scales have no effect on the orientation or size of 2D text, just the location.
Note: A transform node, e.g. SoTranslation, must be used to position the text in 3D space.
Text supports both single byte Latin1 (ISO8859-1) characters and multi-byte UNICODE characters. ISO8859-1 is an 8-bit character set which is a superset of the older 7-bit ASCII character set. See the SbString class for more information.
Rendering:
The typeface and size (default = 10) are specified using an SoFont node. Note that for SoText2 the size is interpreted as a value in pixels, not 3D units.
Setting the SoFont renderStyle field to TEXTURE is recommended for best appearance and performance. (antialiasing is applied).
Additional rendering styles can be applied using an SoTextProperty node, including underline, overline, strikethrough, background and background outline.
SoText2 is drawn using the diffuse color of the current material (SoMaterial). Lighting is not applied, regardless of the lighting model. Textures do not affect SoText2 (note this is independent of the fact that textures are used internally to render SoText2). Complexity (SoComplexity) does not affect SoText2. Drawing styles (SoDrawStyle) other than INVISIBLE do not affect SoText2.
Justification:
Horizontal alignment of the text can be specified using the justification field. Both horizontal and vertical alignment can be controlled using an SoTextProperty node, however the justification setting in the SoText2 node overrides the horizontal setting unless it is explicitly set to INHERITED.
Clipping:
If the transformed position (origin point) of the SoText2 is clipped, then the entire string is clipped, even if some part of the string should conceptually be visible. If the origin point is inside the view volume then the string is clipped similar to other geometry.
Bounding box:
Because 2D text is screen-aligned, it has some unusual characteristics. For example, the 3D bounding box surrounding a 2D text string depends on the current camera and the current viewport size, since changing the field of view or the mapping onto the window changes the relative size of the text with respect to the rest of the scene.
When computing the bounding box of a 2D text node (see SoGetBoundingBoxAction), be careful to:
Picking:
Text can be picked (SoRayPickAction) like any other geometry. If a text node has been picked then SoPickedPoint can return an SoTextDetail object. This object contains information about which string (in a multi-string text node) was picked and which character within the string was picked.
Render caching:
If your Open Inventor version is older than 9.2, then SoText2 nodes using CENTER or RIGHT justification cannot be render cached because the bounding box and justification offset depend on the camera. As a result, no SoSeparator above the SoText2 will be able to build a render cache or a bounding box cache and this can reduce performance. If possible put other geometry, that can be cached, under its own SoSeparator. SoText2 nodes using LEFT justification (the default) can be cached. Since Open Inventor 9.2, SoText2 nodes can be render cached in all cases.
Antialiasing:
Shape Antialiasing type is SoShape::TEXT.
Export limitations:
string | "" |
spacing | 1 |
justification | LEFT |
SoRayPickAction
Performs a pick on the text. Text will be picked if the picking ray intersects the bounding box of the strings. The string index and character position are available from the SoTextDetail.
SoGetBoundingBoxAction
Computes the bounding box that encloses the text.
SoFont, SoFullSceneAntialiasing, SoText3, SoTextDetail, SoTextProperty
Justification types.
Enumerator | |
---|---|
LEFT | Left edges of all strings are aligned. |
CENTER | Centers of all strings are aligned. |
RIGHT | Right edges of all strings are aligned. |
INHERITED | The text justification is inherited from the current SoTextProperty::alignmentH value. |
SoText2::SoText2 | ( | ) |
Creates a 2D text node with default settings.
|
static |
Returns the type identifier for this class.
|
virtual |
Returns the type identifier for this specific instance.
Reimplemented from SoShape.
|
friend |
SoSFEnum SoText2::justification |
Specifies horizontal alignment of strings.
With LEFT justification, the left edge of the first line is at the (transformed) origin, and all left edges are aligned. RIGHT justification is similar. CENTER justification places the center of the first string at the (transformed) origin, with the centers of all remaining strings aligned under it. Use enum Justification. Default is LEFT.
Both horizontal and vertical alignment can be specified using an SoTextProperty node. However the justification setting in this node overrides the horizontal setting in SoTextProperty unless this field is set to INHERITED.
SoSFFloat SoText2::spacing |
SoMFString SoText2::string |