Open Inventor Reference
SoMField Class Referenceabstract

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

#include <Inventor/fields/SoField.h>

Inheritance diagram for SoMField:
SoField SoMFBool SoMFColor SoMFDouble SoMFEngine SoMFEnum SoMFFloat SoMFInt32 SoMFMatrix SoMFMatrixd SoMFName SoMFNode SoMFPath SoMFPlane SoMFPlaned SoMFRotation SoMFRotationd SoMFShort SoMFString SoMFTime SoMFUInt32 SoMFUShort SoMFVec2d SoMFVec2f SoMFVec3d SoMFVec3f SoMFVec4d SoMFVec4f

Public Member Functions

virtual ~SoMField ()
 Destructor. More...
 
int getNum () const
 Returns the number of values currently in the field. More...
 
void setNum (int num)
 Forces this field to have exactly num values, inserting or deleting values as necessary. More...
 
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). More...
 
virtual void insertSpace (int start, int num)
 Inserts space for num values at index start. More...
 
bool set1 (int index, const char *valueString)
 This is equivalent to the set() method of SoField, but operates on only one value. More...
 
void get1 (int index, SbString &valueString)
 This is equivalent to the get() method of SoField, but operates on only one value. More...
 
- Public Member Functions inherited from SoField
virtual ~SoField ()
 Destructor. More...
 
void setIgnored (bool ig)
 Sets the ignore flag for this field. More...
 
bool isIgnored () const
 Gets the ignore flag for this field. More...
 
bool isDefault () const
 Gets the state of default flag of the field. More...
 
virtual SoType getTypeId () const =0
 Return the type identifier for this field instance (SoField *). More...
 
bool isOfType (SoType type) const
 Returns TRUE if this field is the given type or derived from that type. More...
 
void enableConnection (bool flag)
 Field connections may be enabled and disabled. More...
 
bool isConnectionEnabled () const
 Returns FALSE if connections to this field are disabled. More...
 
bool connectFrom (SoEngineOutput *engineOutput)
 Connects the field to the given output of an engine or to another field. More...
 
bool connectFrom (SoField *field)
 
void disconnect ()
 Disconnect the field from whatever it was connected to. More...
 
bool isConnected () const
 Returns TRUE if the field is connected to anything. More...
 
bool isConnectedFromEngine () const
 Returns TRUE if the field is connected to an engine's output. More...
 
bool isConnectedFromField () const
 Returns TRUE if the field is connected to another field. More...
 
bool 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. More...
 
bool getConnectedField (SoField *&field) const
 Returns TRUE if this field is being written into by another field, and returns the field it is connected to in writingField. More...
 
int getForwardConnections (SoFieldList &list) const
 Adds pointers 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. More...
 
SoFieldContainergetContainer () const
 Returns the containing node or engine. More...
 
bool set (const char *valueString)
 Sets the field to the given value, which is an ASCII string in the Inventor file format. More...
 
void get (SbString &valueString)
 Returns the value of the field in the Inventor file format, even if the field has its default value. More...
 
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. More...
 
bool operator== (const SoField &f) const
 Return TRUE (FALSE) if this field is of the same type and has the same value as f. More...
 
bool operator!= (const SoField &f) const
 Return TRUE (FALSE) if this field is of the same type and has the same value as f. More...
 
void setDefault (bool def)
 Sets default flag. More...
 
virtual void startNotify ()
 Initiates or propagates notification through container. More...
 
virtual void notify (SoNotList *list)
 
void setContainer (SoFieldContainer *cont)
 Sets the containing node. More...
 
bool shouldWrite () const
 Returns TRUE if the field really needs to be written out. More...
 
void addAuditor (void *auditor, SoNotRec::Type type)
 Adds/removes an auditor to/from list. More...
 
void removeAuditor (void *auditor, SoNotRec::Type type)
 
bool enableNotify (bool flag)
 Indicates whether notification will propagate as the result of setting the field value. More...
 
bool isNotifyEnabled () const
 
bool enableContainerNotify (bool flag)
 Indicates whether notification will propagate to the SoFieldContainer that owns the field. More...
 
bool isContainerNotifyEnabled () const
 
virtual void connectionStatusChanged (int numConnections)
 Indicates to a field that a change has been made involving a connection from it (as source) to another field. More...
 
bool isReadOnly () const
 If this returns TRUE, it means we're in the middle of doing a setValue()+valueChanged() and values from an upstream connection shouldn't write into this field. More...
 
virtual bool isSame (const SoField &f) const =0
 Returns TRUE if the given field is of the same type and has the same value(s) as this. More...
 
virtual void copyFrom (const SoField &f)=0
 Copies the value from one field to another, assuming same subclass. More...
 
virtual void fixCopy (bool copyConnections)
 After a field value has been copied using copyFrom(), this is called to allow fields to update the copy. More...
 
virtual bool referencesCopy () const
 This returns TRUE if this field contains a reference to a node or engine that is copied during a copy operation (i.e., it is "inside"). More...
 
void copyConnection (const SoField *fromField)
 Copies connection from one field to another. More...
 
virtual bool read (SoInput *in, const SbName &name)
 Reads value of field (with given name) from file as defined by SoInput. More...
 
virtual void write (SoOutput *out, const SbName &name) const
 Writes field (with given name) to file as defined by SoOutput. More...
 
virtual void countWriteRefs (SoOutput *out) const
 Counts write-references on field to prepare for writing. More...
 
void evaluate () const
 Evaluates the field from whatever it's connected to. More...
 

Static Public Member Functions

static SoType getClassTypeId ()
 Return the type identifier for this field class. More...
 
static void initClass ()
 
static void * createInstance ()
 
- Static Public Member Functions inherited from SoField
static SoType getClassTypeId ()
 Return the type identifier for this field class. More...
 
static void initClass ()
 
static void initClasses ()
 Initialize ALL Inventor node classes. More...
 

Protected Member Functions

 SoMField ()
 Constructor. More...
 
virtual void makeRoom (int newNum)
 Make sure there is room for newNum vals. More...
 
- Protected Member Functions inherited from SoField
 SoField ()
 Constuctor: More...
 
void valueChanged (bool resetDefault=TRUE)
 Called by an instance to indicate that a value has changed. More...
 
virtual void evaluateConnection () const
 Evaluates the field or engine the field is connected to, storing the result in the field. More...
 
virtual bool readConnection (SoInput *in)
 Reads connection. More...
 
virtual void writeConnection (SoOutput *out) const
 Writes field connection. More...
 

Protected Attributes

int num
 Number of values. More...
 
int maxNum
 Number of values allocated. More...
 

Detailed Description

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, ]
See Also
SoNode, SoEngine

Definition at line 628 of file SoField.h.

Constructor & Destructor Documentation

◆ ~SoMField()

virtual SoMField::~SoMField ( )
virtual

◆ SoMField()

SoMField::SoMField ( )
protected

Member Function Documentation

◆ createInstance()

static void* SoMField::createInstance ( )
static

◆ deleteValues()

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).

◆ get1()

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

See the SoField methods for details.

◆ getClassTypeId()

static SoType SoMField::getClassTypeId ( )
inlinestatic

Definition at line 665 of file SoField.h.

◆ getNum()

int SoMField::getNum ( ) const
inline

Definition at line 635 of file SoField.h.

◆ initClass()

static void SoMField::initClass ( )
static

◆ insertSpace()

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

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, 10).

◆ makeRoom()

virtual void SoMField::makeRoom ( int  newNum)
protectedvirtual

◆ set1()

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

See the SoField methods for details.

◆ setNum()

void SoMField::setNum ( int  num)

Member Data Documentation

◆ maxNum

int SoMField::maxNum
protected

Definition at line 674 of file SoField.h.

◆ num

int SoMField::num
protected

Definition at line 673 of file SoField.h.


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