Class SoMField
- java.lang.Object
-
- com.openinventor.inventor.Inventor
-
- com.openinventor.inventor.fields.SoField
-
- com.openinventor.inventor.fields.SoMField
-
- Direct Known Subclasses:
SoMFBool
,SoMFBufferObject
,SoMFColor
,SoMFColorRGBA
,SoMFDataMeasure
,SoMFDouble
,SoMFEngine
,SoMFEnum
,SoMFFieldContainer
,SoMFFloat
,SoMFInstanceParameter
,SoMFInt32
,SoMFInt64
,SoMFKernel2i32
,SoMFKernel3i32
,SoMFMatrix
,SoMFName
,SoMFNode
,SoMFPath
,SoMFPlane
,SoMFRotation
,SoMFShort
,SoMFString
,SoMFTime
,SoMFUByte
,SoMFUInt32
,SoMFUniformShaderParameter
,SoMFUShort
,SoMFVec2d
,SoMFVec2f
,SoMFVec2i32
,SoMFVec2s
,SoMFVec2String
,SoMFVec3d
,SoMFVec3f
,SoMFVec3i32
,SoMFVec3s
,SoMFVec4b
,SoMFVec4f
,SoMFVec4i32
,SoMFVec4s
,SoMFVec4ub
,SoMFVec4ui32
,SoMFVec4us
public abstract class SoMField extends SoField
Base class for all multiple-valued fields. Each class derived fromSoMField
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 parameter to this method indicates the starting array index to copy into.The getValues() method for a multiple-value field returns a read-only array of values in the field. In addition, getValueAt(i) returns the i 'th value in the array.
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:
or:[ 1, 2, 3, 4 ] [ 1, 2, 3, 4, ]
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.openinventor.inventor.fields.SoField
SoField.FieldTypes
-
Nested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand
-
-
Field Summary
-
Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deleteValues(int start)
Calls deleteValues(start, (int)-1).void
deleteValues(int start, int num)
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).java.lang.String
get1(int index)
int
getNum()
Returns the number of values currently in the field.void
insertSpace(int start, int num)
Inserts space for num values at index start .boolean
set1(int index, java.lang.String valueString)
void
setNum(int num)
Forces this field to have exactly num values, inserting or deleting values as necessary.-
Methods inherited from class com.openinventor.inventor.fields.SoField
appendConnection, appendConnection, connectFrom, connectFrom, disconnect, disconnect, disconnect, enableConnection, equals, get, getConnectedEngine, getConnectedField, getContainer, getNumConnections, getValueSize, isConnected, isConnectedFromEngine, isConnectedFromField, isConnectedFromVRMLInterp, isConnectionEnabled, isDefault, isIgnored, set, setIgnored, touch
-
Methods inherited from class com.openinventor.inventor.Inventor
dispose, getNativeResourceHandle
-
-
-
-
Method Detail
-
deleteValues
public void deleteValues(int start)
Calls deleteValues(start, (int)-1).
-
setNum
public void 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.
-
getNum
public int getNum()
Returns the number of values currently in the field.
-
get1
public java.lang.String get1(int index)
-
deleteValues
public void deleteValues(int start, int num)
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.
-
set1
public boolean set1(int index, java.lang.String valueString)
-
insertSpace
public void insertSpace(int start, int num)
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.
-
-