Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
SoMField Class Referenceabstract

Base class for all multiple-valued fields. More...

#include <Inventor/fields/SoMField.h>

+ Inheritance diagram for SoMField:

Public Member Functions

int getNum () const
 Returns the number of values currently in the field.
 
void setNum (int num)
 Forces this field to have exactly num values, inserting or deleting values as necessary.
 
virtual void deleteValues (int start, int num=-1)
 Deletes num values beginning at index start (index start through start + num -1 will be deleted, and any leftover values will be moved down to fill in the gap created).
 
virtual void insertSpace (int start, int num)
 Inserts space for num values at index start .
 
SoNONUNICODE SbBool set1 (int index, const char *valueString)
 This is equivalent to the set() method of SoField, but operates on only one value.
 
SbBool set1 (int index, const SbString &valueString)
 This is equivalent to the set() method of SoField, but operates on only one value.
 
void get1 (int index, SbString &valueString)
 This is equivalent to the get() method of SoField, but operates on only one value.
 
- Public Member Functions inherited from SoField
void setIgnored (SbBool ig)
 Sets the ignore flag for this field.
 
SbBool isIgnored () const
 Gets the ignore flag for this field.
 
SbBool isDefault () const
 Gets the state of default flag of the field.
 
void enableConnection (SbBool flag)
 Field connections may be enabled and disabled.
 
SbBool isConnectionEnabled () const
 Returns FALSE if connections to this field are disabled.
 
SbBool connectFrom (SoEngineOutput *engineOutput)
 Connects this field from an engine output.
 
SbBool connectFrom (SoField *field)
 Connects this field to another field.
 
SbBool connectFrom (SoVRMLInterpOutput *interpOutput)
 Connects this field from an interpOutput.
 
SbBool appendConnection (SoEngineOutput *engineOutput)
 Appends this field to the list of connections from another engineOutput.
 
SbBool appendConnection (SoField *field)
 Appends this field to the list of connections from another field.
 
SbBool appendConnection (SoVRMLInterpOutput *interpOutput)
 Appends this field to the list of connections from another interpOutput.
 
void disconnect (SoEngineOutput *engineOutput)
 Disconnect the field from the requested engineOutput.
 
void disconnect (SoField *field)
 Disconnect the field from the requested field.
 
void disconnect (SoVRMLInterpOutput *interpOutput)
 Disconnect the field from the requested interpOutput.
 
int getNumConnections () const
 Returns the number of connections to this field.
 
int getConnections (SoFieldList &list)
 Returns a list of the connections to this field.
 
void disconnect ()
 Disconnect the field from whatever it was connected to.
 
SbBool isConnected () const
 Returns TRUE if the field is connected to anything.
 
SbBool isConnectedFromVRMLInterp () const
 Returns TRUE if the field is connected to a VRML interpOutput.
 
SbBool isConnectedFromEngine () const
 Returns TRUE if the field is connected to an engine's output.
 
SbBool isConnectedFromField () const
 Returns TRUE if the field is connected to another field.
 
SbBool getConnectedEngine (SoEngineOutput *&engineOutput) const
 Returns TRUE if this field is being written into by an engine, and returns the engine output it is connected to in engineOutput.
 
SbBool getConnectedField (SoField *&writingField) const
 Returns TRUE if this field is being written into by another field, and returns the field it is connected to in writingField.
 
SbBool getConnectedVRMLInterp (SoVRMLInterpOutput *&interpOutput) const
 Returns the VRMLInterpolator output field is connected to.
 
int getForwardConnections (SoFieldList &list) const
 Adds references to all of the fields that this field is writing into (either fields in nodes, global fields or engine inputs) to the given field list, and returns the number of forward connections.
 
SoFieldContainergetContainer () const
 Returns the object that contains this field.
 
SoNONUNICODE SbBool set (const char *valueString)
 Sets the field to the given value, which is an ASCII string in the Open Inventor file format.
 
SbBool set (const SbString &valueString)
 Sets the field to the given value, which is an ASCII string in the Open Inventor file format.
 
void get (SbString &valueString)
 Returns the value of the field in the Open Inventor file format, even if the field has its default value.
 
virtual size_t getValueSize () const
 Gets the size of the value.
 
virtual void touch ()
 Simulates a change to the field, causing attached sensors to fire, connected fields and engines to be marked as needing evaluation, and so forth.
 
int operator== (const SoField &f) const
 Return TRUE if this field is of the same type and has the same value as f.
 
int operator!= (const SoField &f) const
 Return FALSE if this field is of the same type and has the same value as f.
 
- Public Member Functions inherited from SoTypedObject
virtual SoType getTypeId () const =0
 Returns the type identifier for a specific instance.
 
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 ()
 Return the type identifier for this field class.
 
- Static Public Member Functions inherited from SoField
static SoType getClassTypeId ()
 Return the type identifier for this field class.
 
- Static Public Member Functions inherited from SoTypedObject
static SoType getClassTypeId ()
 Returns the type identifier for this class.
 

Detailed Description

Base class for all multiple-valued fields.

Each class derived from SoMField begins with an SoMF prefix and contains a dynamic array of values of a particular type. Each has a setValues() method that is passed an array of values of the correct type; these values are copied into the array in the field, making extra room in the array if necessary. The start and num parameters to this method indicate the starting array index to copy into and the number of values to copy.

The getValues() method for a multiple-value field returns a read-only array of values in the field. In addition, the indexing operator "[ ]" is overloaded to return the i 'th value in the array; because it returns a const reference, it can be used only to get values, not to set them.

Methods are provided for getting the number of values in the field, inserting space for new values in the middle, and deleting values.

There are other methods that allow you to set only one value of several in the field and to set the field to contain one and only one value.

Two other methods can be used to make several changes to a multiple-value field without the overhead of copying values into and out of the fields. The startEditing() method returns the internal array of values in the field. It can be used to change (but not add or remove) any values in the array. The finishEditing() method indicates that the editing is done and notifies any sensors or engines that may be connected to the field.

SoMFields are written to file as a series of values separated by commas, all enclosed in square brackets. If the field has no values (getNum() returns zero), then only the square brackets ("[ ]") are written. The last value may optionally be followed by a comma. Each field subtype defines how the values are written; for example, a field whose values are integers might be written as:

   [ 1, 2, 3, 4 ]

or:

   [ 1, 2, 3, 4, ]

SEE ALSO

SoNode, SoEngine

Definition at line 134 of file SoMField.h.

Member Function Documentation

◆ deleteValues()

virtual void SoMField::deleteValues ( int  start,
int  num = -1 
)
virtual

Deletes num values beginning at index start (index start through start + num -1 will be deleted, and any leftover values will be moved down to fill in the gap created).

A num of -1 means delete all values from start to the last value in the field; getNum() will return start as the number of values in the field after this operation ( deleteValues(0, -1) empties the field ). However if num is greater than or equal to the number of values in the field, start is ignored and all values are deleted.

If the field's values are stored in an user data array and if the number of values to delete is not zero, a new array is allocated and the user data array is no longer used.

◆ get1()

void SoMField::get1 ( int  index,
SbString valueString 
)

This is equivalent to the get() method of SoField, but operates on only one value.

See the SoField methods for details.

◆ getClassTypeId()

static SoType SoMField::getClassTypeId ( )
static

Return the type identifier for this field class.

◆ getNum()

int SoMField::getNum ( ) const
inline

Returns the number of values currently in the field.

Definition at line 146 of file SoMField.h.

◆ insertSpace()

virtual void SoMField::insertSpace ( int  start,
int  num 
)
virtual

Inserts space for num values at index start .

Index start through start + num -1 will be moved up to make room. For example, to make room for 7 new values at the beginning of the field call insertSpace(0, 7) . If field's values are stored in an user data array and if the number of values to insert is not zero, a new array is allocated and the user's one is no more used.

◆ set1() [1/2]

SoNONUNICODE SbBool SoMField::set1 ( int  index,
const char *  valueString 
)

This is equivalent to the set() method of SoField, but operates on only one value.

See the SoField methods for details. If field's values are stored in an user data array and if specified index is greater than this array's length, a new array is allocated and the user's one is no more used.

Non Unicode: This function should not be used in a Unicode application.

◆ set1() [2/2]

SbBool SoMField::set1 ( int  index,
const SbString valueString 
)

This is equivalent to the set() method of SoField, but operates on only one value.

See the SoField methods for details. If field's values are stored in an user data array and if specified index is greater than this array's length, a new array is allocated and the user's one is no more used.

◆ setNum()

void SoMField::setNum ( int  num)

Forces this field to have exactly num values, inserting or deleting values as necessary.

If field's values are stored in an user data array and if specified number of values is different from this array's length, a new array is allocated and the user's one is no more used.


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