Open Inventor Reference
|
Base class for all multiple-valued fields. More...
#include <Inventor/fields/SoField.h>
Public Member Functions | |
virtual | ~SoMField () |
Destructor. | |
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+ 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 . | |
SbBool | set1 (int index, const char *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. | |
Static Public Member Functions | |
static SoType | getClassTypeId () |
Return the type identifier for this field class. | |
static void | initClass () |
static void * | createInstance () |
Protected Member Functions | |
SoMField () | |
Constructor. | |
virtual void | makeRoom (int newNum) |
Make sure there is room for newNum vals. | |
Protected Attributes | |
int | num |
Number of values. | |
int | maxNum |
Number of values allocated. |
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 a pointer to a const 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 const pointer to the array of values in the field. (Because this pointer is const, it cannot be used to change values in this array.)
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 a non-const pointer to the array of values in the field; this pointer can then 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, ]
virtual SoMField::~SoMField | ( | ) | [virtual] |
SoMField::SoMField | ( | ) | [protected] |
static void* SoMField::createInstance | ( | ) | [static] |
virtual void SoMField::deleteValues | ( | int | start, |
int | num = -1 |
||
) | [virtual] |
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).
static SoType SoMField::getClassTypeId | ( | ) | [inline, static] |
int SoMField::getNum | ( | ) | const [inline] |
Definition at line 635 of file SoField.h.
References SoField::evaluate().
static void SoMField::initClass | ( | ) | [static] |
Reimplemented from SoField.
Reimplemented in SoMFBitMask, SoMFBool, SoMFColor, SoMFDouble, SoMFEngine, SoMFEnum, SoMFFloat, SoMFInt32, SoMFMatrix, SoMFName, SoMFNode, SoMFPath, SoMFPlane, SoMFRotation, SoMFShort, SoMFString, SoMFTime, SoMFUInt32, SoMFUShort, SoMFVec2f, SoMFVec3f, and SoMFVec4f.
virtual void SoMField::insertSpace | ( | int | start, |
int | num | ||
) | [virtual] |
Index start
through start+
be moved up to make room. For example, to make room for 7 new values at the beginning of the field call insertSpace(0, 10). num-1
will
virtual void SoMField::makeRoom | ( | int | newNum | ) | [protected, virtual] |
void SoMField::setNum | ( | int | num | ) |
int SoMField::maxNum [protected] |
int SoMField::num [protected] |