| 1 |
NAME SoMField SoMField "" { base class for all multiple-valued fields } |
| 2 |
|
| 3 |
INCLUDE fields/SoField.h |
| 4 |
|
| 5 |
DESC { |
| 6 |
Each class derived from \cSoMField\. begins with an \cSoMF\. prefix |
| 7 |
and contains a dynamic array of values of a particular type. Each has a |
| 8 |
\m\+setValues()\.\-SetN()\.\. method |
| 9 |
that is passed a pointer to a const array of values of the correct |
| 10 |
type; these values are copied into the array in the field, making |
| 11 |
extra room in the array if necessary. The start and num parameters to |
| 12 |
this method indicate the starting array index to copy into and the |
| 13 |
number of values to copy. |
| 14 |
\p |
| 15 |
The \m\+getValues()\.\-GetN()\.\. method |
| 16 |
for a multiple-value field returns a const pointer to the array of |
| 17 |
values in the field. (Because this pointer is const, it cannot be used |
| 18 |
to change values in this array.) |
| 19 |
\+ |
| 20 |
\p |
| 21 |
In addition, the indexing operator "[]" is overloaded to return the |
| 22 |
\ai\.'th value in the array; because it returns a const reference, it can |
| 23 |
be used only to get values, not to set them. |
| 24 |
\. |
| 25 |
\p |
| 26 |
Methods are provided for getting the number of values in the field, |
| 27 |
inserting space for new values in the middle, and deleting values. |
| 28 |
\p |
| 29 |
There are other methods that allow you to set only one value of |
| 30 |
several in the field and to set the field to contain one and only one |
| 31 |
value. |
| 32 |
\p |
| 33 |
Two other methods can be used to make several changes to a |
| 34 |
multiple-value field without the overhead of copying values into and |
| 35 |
out of the fields. The \m\+startEditing()\.\-StartEdit()\.\. method |
| 36 |
returns a non-const pointer to the array of values in the field; this |
| 37 |
pointer can then be used to change (but not add or remove) any values |
| 38 |
in the array. The \m\+finishEditing()\.\-FinishEdit()\.\. method |
| 39 |
indicates that the editing is done and notifies any sensors or engines |
| 40 |
that may be connected to the field. |
| 41 |
\- |
| 42 |
\p |
| 43 |
This class is rarely needed by C programmers. |
| 44 |
\. |
| 45 |
\p |
| 46 |
\cSoMFields\. are written to file as a series of values separated by |
| 47 |
commas, all enclosed in square brackets. If the field has no values |
| 48 |
(\mgetNum()\. returns zero), then only the square brackets ("[]") are |
| 49 |
written. The last value may optionally be followed by a comma. Each |
| 50 |
field subtype defines how the values are written; for example, a field |
| 51 |
whose values are integers might be written as: |
| 52 |
\b |
| 53 |
[ 1, 2, 3, 4 ] |
| 54 |
or: |
| 55 |
[ 1, 2, 3, 4, ] |
| 56 |
\. |
| 57 |
} |
| 58 |
|
| 59 |
METHOD "" int getNum() const { |
| 60 |
Returns the number of values currently in the field. |
| 61 |
} |
| 62 |
|
| 63 |
METHOD "" void setNum(int num) { |
| 64 |
Forces this field to have exactly num values, inserting or deleting |
| 65 |
values as necessary. |
| 66 |
} |
| 67 |
|
| 68 |
METHOD del virtual void deleteValues(int start, int num = -1) { |
| 69 |
Deletes \anum\. values beginning at index \astart\. (index \astart\. through |
| 70 |
\astart\.+\anum\.-1 will be deleted, and any leftover values will be moved |
| 71 |
down to fill in the gap created). A \anum\. of -1 means delete all values |
| 72 |
from \astart\. to the last value in the field; \mgetNum()\. will return |
| 73 |
\astart\. as the number of values in the field after this operation |
| 74 |
(\m\+deleteValues(0, -1)\-Del(0, -1)\.\. empties the field). |
| 75 |
} |
| 76 |
|
| 77 |
METHOD "" virtual void insertSpace(int start, int num) { |
| 78 |
Inserts space for \anum\. values at index \astart\.. Index \astart\. through |
| 79 |
\astart\.+\anum\.-1 will be moved up to make room. For example, to make room |
| 80 |
for 7 new values at the beginning of the field call |
| 81 |
\m\+insertSpace(0, 10)\.\-InsertSpace(0, 10)\.\.. |
| 82 |
} |
| 83 |
|
| 84 |
METHOD "" SbBool set1(int index, const char *valueString) {} |
| 85 |
METHOD "" void get1(int index, SbString &valueString) { |
| 86 |
These are equivalent to the \m\+set()\.\-Set()\.\. and |
| 87 |
\m\+get()\.\-Get()\.\. methods of \cSoField\., but they operate on |
| 88 |
only one value. See the \cSoField\. methods for details. |
| 89 |
} |
| 90 |
|
| 91 |
METHOD "" static SoType getClassTypeId() { |
| 92 |
Return the type identifier for this field class. |
| 93 |
} |
| 94 |
|
| 95 |
ALSO { SoNode, SoEngine } |