http://www.coin3d.org/ http://www.kongsberg.com/kogt/ |
The SoMField class is the base class for fields which can contain multiple values.All field types which may contain more than one member value inherits this class. SoMField is an abstract class. More...
#include <Inventor/fields/SoMField.h>
Public Member Functions | |
virtual | ~SoMField () |
int | getNum (void) const |
void | setNum (const int num) |
virtual void | deleteValues (int start, int num=-1) |
virtual void | insertSpace (int start, int num) |
SbBool | set1 (const int index, const char *const valuestring) |
void | get1 (const int index, SbString &valuestring) |
virtual void | enableDeleteValues (void) |
virtual SbBool | isDeleteValuesEnabled (void) const |
Public Member Functions inherited from SoField | |
virtual | ~SoField () |
void | setIgnored (SbBool ignore) |
SbBool | isIgnored (void) const |
void | setDefault (SbBool defaultVal) |
SbBool | isDefault (void) const |
virtual SoType | getTypeId (void) const =0 |
SbBool | isOfType (const SoType type) const |
void | enableConnection (SbBool flag) |
SbBool | isConnectionEnabled (void) const |
SbBool | connectFrom (SoEngineOutput *master, SbBool notnotify=FALSE, SbBool append=FALSE) |
SbBool | appendConnection (SoEngineOutput *master, SbBool notnotify=FALSE) |
void | disconnect (SoEngineOutput *engineoutput) |
SbBool | isConnectedFromEngine (void) const |
SbBool | getConnectedEngine (SoEngineOutput *&master) const |
SbBool | connectFrom (SoField *master, SbBool notnotify=FALSE, SbBool append=FALSE) |
SbBool | appendConnection (SoField *master, SbBool notnotify=FALSE) |
void | disconnect (SoField *field) |
SbBool | isConnectedFromField (void) const |
SbBool | getConnectedField (SoField *&master) const |
int | getNumConnections (void) const |
int | getForwardConnections (SoFieldList &slavelist) const |
int | getConnections (SoFieldList &masterlist) const |
void | disconnect (void) |
SbBool | isConnected (void) const |
void | setContainer (SoFieldContainer *cont) |
SoFieldContainer * | getContainer (void) const |
SbBool | set (const char *valuestring) |
void | get (SbString &valuestring) |
SbBool | shouldWrite (void) const |
virtual void | touch (void) |
virtual void | startNotify (void) |
virtual void | notify (SoNotList *nlist) |
SbBool | enableNotify (SbBool on) |
SbBool | isNotifyEnabled (void) const |
void | addAuditor (void *f, SoNotRec::Type type) |
void | removeAuditor (void *f, SoNotRec::Type type) |
int | operator== (const SoField &f) const |
int | operator!= (const SoField &f) const |
virtual void | connectionStatusChanged (int numconnections) |
SbBool | isReadOnly (void) const |
virtual SbBool | isSame (const SoField &f) const =0 |
virtual void | copyFrom (const SoField &f)=0 |
virtual void | fixCopy (SbBool copyconnections) |
virtual SbBool | referencesCopy (void) const |
void | copyConnection (const SoField *fromfield) |
virtual SbBool | read (SoInput *input, const SbName &name) |
virtual void | write (SoOutput *out, const SbName &name) const |
virtual void | countWriteRefs (SoOutput *out) const |
void | setFieldType (int type) |
int | getFieldType (void) const |
SbBool | getDirty (void) const |
void | setDirty (SbBool dirty) |
void | evaluate (void) const |
Static Public Member Functions | |
static SoType | getClassTypeId (void) |
static void | atexit_cleanup (void) |
static void | initClass (void) |
Static Public Member Functions inherited from SoField | |
static void | initClass (void) |
static void | initClasses (void) |
static void | cleanupClass (void) |
static SoType | getClassTypeId (void) |
Protected Member Functions | |
SoMField (void) | |
virtual void | makeRoom (int newnum) |
virtual SoNotRec | createNotRec (SoBase *container) |
void | setChangedIndex (const int chgidx) |
void | setChangedIndices (const int chgidx=-1, const int numchgind=0) |
Protected Member Functions inherited from SoField | |
SoField (void) | |
void | valueChanged (SbBool resetdefault=TRUE) |
virtual void | evaluateConnection (void) const |
virtual SbBool | readConnection (SoInput *in) |
virtual void | writeConnection (SoOutput *out) const |
SbBool | isDestructing (void) const |
Protected Attributes | |
int | num |
int | maxNum |
SbBool | userDataIsUsed |
Additional Inherited Members | |
Public Types inherited from SoField | |
enum | FieldType { NORMAL_FIELD = 0, EVENTIN_FIELD, EVENTOUT_FIELD, EXPOSED_FIELD } |
The SoMField class is the base class for fields which can contain multiple values.
All field types which may contain more than one member value inherits this class. SoMField is an abstract class.
Use setValue(), setValues() or set1Value() to set the values of fields inheriting SoMField, and use getValues() or the index operator [] to read values. Example code:
The reason it is more effective to wrap many modifications within startEditing() / finishEditing() is because we avoid the stream of notification messages which would otherwise be sent for each and every modification done. Instead there will just be a single notification about the changes, triggered by the finishEditing() call.
The correct manner in which to pre-allocate a specific number of field values in one chunk is to use the SoMField::setNum() method, for instance in advance of using the startEditing() and finishEditing() methods. The field values will be uninitialized after expanding the field with the setNum() call.
Be aware that your application code must be careful to not do silly things during a setValues()-triggered notification. If you have code that looks for instance like this:
As setValues() might leave some elements at the end of the array that typically can be invalid indices after the first statement is executed, something can go wrong during notification if you have application code monitoring changes, and the application code then for instance triggers an action or something that tries to use the coordIndex field before it's updated to it's correct size with the setNum() call.
(Notification can in this case, as always, be temporarily disabled to be on the safe side:
This will guarantee that the setValues() and setNum() pair will be executed as an atomic operation.)
When nodes, engines or other types of field containers are written to file, their multiple-value fields are written to file in this format:
..like this, for instance, a Coordinate3 node providing 6 vertex coordinates in the form of SbVec3f values in its "point" field for e.g. a faceset, lineset or pointset:
Some fields support application data sharing through a setValuesPointer() method. setValuesPointer() makes it possible to set the data pointer directly in the field. Normally (when using setValues()), Coin makes a copy of your data, so this method can be very useful if your application needs the data internally and you're just using Coin for the visualization. Example code:
Be aware that your field should be a read-only field when you set the data like this. If you write to the field, the values in your application array will be overwritten. If you append values to the field, a new array will be allocated, and the data will be copied into it before appending the new values. The array pointer will then be discarded.
Also note that whenever you change some value(s) in the array, you must manually notify Coin about this by calling SoField::touch(). For our example:
You can use SoMField::enableDeleteValues() to make Coin delete the array for you when the field is destructed or the array pointer is discarded because it isn't needed anymore (e.g. when the array size is changed). The array will be deleted using the C++ delete[] operator, so if you use it, your array must be allocated using the C++ new[] operator.
SoMField::enableDeleteValues() is supported only to be compatible with later versions of TGS Inventor and we don't recommend using it. It can have undefined results on the Microsoft Windows platform. Allocating memory in the application and destructing it in a DLL can be a bad thing, causing mysterious crashes, if you're not very careful about how your application and DLLs are linked to the underlying C library.
|
virtual |
Destructor in SoMField does nothing. Resource deallocation needs to be done from subclasses.
|
protected |
Constructor. Initializes number of values in field to zero.
|
inline |
Returns number of values in this field.
void SoMField::setNum | ( | const int | numarg | ) |
Set number of values to num.
If the current number of values is larger than num, the array of values will be truncated from the end. But if num is larger, the array will automatically be expanded (and random values will be set for the new array items).
|
virtual |
Remove value elements from index start up to and including index start + num - 1.
Elements with indices larger than the last deleted element will be moved downwards in the value array.
If num equals -1, delete from index start and to the end of the array.
Reimplemented in SoMFNode, SoMFPath, and SoMFEngine.
|
virtual |
Insert num "slots" for new value elements from start. The elements already present from start will be moved "upward" in the extended array.
Reimplemented in SoMFNode, SoMFPath, and SoMFEngine.
SbBool SoMField::set1 | ( | const int | index, |
const char *const | valuestring | ||
) |
Set the value at index to the value contained in valuestring. Returns TRUE
if a valid value for this field can be extracted from valuestring, otherwise FALSE
.
If index is larger than the current number of elements in the field, this method will automatically expand the field to accomodate the new value.
void SoMField::get1 | ( | const int | index, |
SbString & | valuestring | ||
) |
Return the value at index in the valuestring string.
|
virtual |
Can be used to make Coin delete the array pointer set through a setValuesPointer() call. See SoMField documentation for information about the setValuesPointer() function.
This method is a TGS extension (introduced in TGS OIV v3.0) and is supported only for compatibility. We suggest that you don't use it since it can lead to hard-to-find bugs.
|
virtual |
Returns whether SoMField::enableDeleteValues() has been called on a field. The result is only valid if setValuesPointer() has been called on the field first.
This method is a TGS extension (introduced in TGS OIV v3.0) and is supported only for compatibility. We suggest that you don't use it since it can lead to hard-to-find bugs.
|
protectedvirtual |
Make room in the field to store newnum values.
|
protected |
Number of available values.
|
protected |
Number of array "slots" allocated for this field.
|
protected |
Is TRUE
if data has been set through a setValuesPointer() call and set to FALSE
through a enableDeleteValues() call.
Copyright © by Kongsberg Oil & Gas Technologies. All rights reserved.
Generated for Coin by Doxygen