Open Inventor Reference
|
Base class for all fields. More...
#include <Inventor/fields/SoField.h>
Public Member Functions | |
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... | |
SoFieldContainer * | getContainer () 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 | initClasses () |
Initialize ALL Inventor node classes. More... | |
Protected Member Functions | |
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 | readValue (SoInput *in)=0 |
Reads value(s) of field. More... | |
virtual bool | readConnection (SoInput *in) |
Reads connection. More... | |
virtual void | writeValue (SoOutput *out) const =0 |
Writes value(s) of field. More... | |
virtual void | writeConnection (SoOutput *out) const |
Writes field connection. More... | |
Friends | |
class | SoEngineOutput |
SoField is the abstract base class for all fields. Fields are the data elements contained within nodes and are the input values for engines. Each node or engine class specifies a set of fields and associates a name with each. These names define the semantics of the field (e.g., the SoCube node contains three float fields named width, height, and depth). Field classes provide the access methods that indirectly allow editing and querying of data within nodes.
There are two abstract subclasses of SoField: SoSField is the base class for all single-valued field classes and SoMField is the base class for all multiple-valued fields, which contain dynamic arrays of values. Subclasses of SoSField have an SoSF prefix, and subclasses of SoMField have an SoMF prefix. See the reference pages for SoSField and SoMField for additional methods.
Fields are typically constructed only within node or engine instances; if you need a field that is not part of a node or engine, you can create a GlobalField; see the methods on SoDB for creating global fields.
Fields can be connected either directly to another field, or can be connected to the output of an engine. The value of a field with a connection will change when the thing it is connected to changes. For example, consider a field "A" that is connected from "B" (by A->connectFrom(B)). When B's value is changed, A's value will also change. Note that A and B may have different values, even if they are connected: if A's value is set after B's value, A's value will be different from B's until B's value is set.
A field can be connected to several other fields, but can be connected from only one source.
It is possible (and often useful) to create loops of field connections (for example, A connected from B and B connected from A). If there are loops, then the rule is that the last setValue() done overrides any connections in to that value. You can think of setting the value of a field as immediately propagating that value forward into all the fields it is connected to, with the propagation stopping at the place where the original setValue() occurred if there is a connection loop. (Actually, a more efficient mechanism than this is used, but the semantics are the same.)
If you try to connect two fields of differing types, Inventor will automatically try to insert a field converter engine between them to convert values from one type into the other. Inventor has most reasonable conversions built-in (multiple-valued field to single-valued and vice versa, anything to SoSFString, anything to SoSFTrigger, float/short/unsigned short/int32_t/uint32_t/etc numeric conversions, etc). You can add field converters using SoDB's extender method addConverter(); see the SoDB.h header file for details. You can also find out if a converter is available with the SoDB::getConverter() method.
Fields each define their own file format for reading and being written to files, but all fields follow the same conventions:
Fields in a node or engine are written as the name of the field followed by the field's value; fields are not written if they have not been modified since they were created (if they have their default value).
The ignored flag is written as a "~" character after the field's value (if the field's value is its default value, just the "~" is written).
Field connections are written as an "=" followed by the container of the field or engine output that the field is connected to, followed by a "." and the name of the field or engine output. For example:
Global fields are written as part of an internal SoFieldContainer class called GlobalField, which writes out an SoSFName field named type whose value is the type of the global field, followed by a field of that type whose name is the name of the global field. For example, a global uint32_t field called "FrameCounter" whose value is 494 would be written as:
|
virtual |
|
protected |
void SoField::addAuditor | ( | void * | auditor, |
SoNotRec::Type | type | ||
) |
bool SoField::connectFrom | ( | SoEngineOutput * | engineOutput | ) |
Returns FALSE if the connection could not be made.
bool SoField::connectFrom | ( | SoField * | field | ) |
|
virtual |
Passed the number of things being connected to the field; the number will be negative when things are disconnected. The default method does nothing.
void SoField::copyConnection | ( | const SoField * | fromField | ) |
Assumes fields are the same subclass and that this field is connected.
|
pure virtual |
|
virtual |
void SoField::disconnect | ( | ) |
This does nothing if the field was not connected.
void SoField::enableConnection | ( | bool | flag | ) |
Disabling a field's connection is almost exactly like disconnecting it; the only difference is that you can later re-enable the connection by calling enableConnection(TRUE). Note that disconnecting an engine output can cause the engine's reference count to be decremented and the engine to be deleted, but disabling the connection does not decrement its reference count.
Re-enabling a connection will cause the value of the field to be changed to the engine output or field to which it is connected.
A field's connection-enabled status is maintained even if the field is disconnected or reconnected. By default, connections are enabled.
bool SoField::enableContainerNotify | ( | bool | flag | ) |
The default is TRUE, so that a field will notify its container. If disabled, only the direct auditors (connected fields and field sensors) will be notified and the field container does not get a notification. This will prevent unwanted scene repaints (for pure "output fields" that are changed while scene traversal) but has the side effect that the owning field container does not get a new node id and thus one can not detect the field change from the container except by attaching a SoFieldSensor directly to the field. If notification is disabled via enableNotify(FALSE), this flag has no effect. (MeVis Only)
bool SoField::enableNotify | ( | bool | flag | ) |
Engines turn this off when writing results into fields, since notification has already propagated.
|
inline |
If there's no connection or we don't need to evaluate, this does nothing. This has to be const because it's used by getValue methods.
Definition at line 418 of file SoField.h.
Referenced by SoSFRotationd::getValue(), and SoSFRotation::getValue().
|
protectedvirtual |
This is const because it is called by evaluate().
|
virtual |
This is used by node, engine, and path fields to make sure instances are handled properly. The default implementation does nothing.
Reimplemented in SoSFPath, SoSFNode, SoSFEngine, SoMFPath, SoMFNode, and SoMFEngine.
void SoField::get | ( | SbString & | valueString | ) |
Referenced by SoEngineOutput::operator[]().
bool SoField::getConnectedEngine | ( | SoEngineOutput *& | engineOutput | ) | const |
Returns FALSE and does not modify engineOutput
if it is not connected to an engine.
bool SoField::getConnectedField | ( | SoField *& | field | ) | const |
Returns FALSE and does not modify writingField
if it is not connected to a field.
SoFieldContainer* SoField::getContainer | ( | ) | const |
int SoField::getForwardConnections | ( | SoFieldList & | list | ) | const |
|
pure virtual |
|
static |
|
static |
|
inline |
|
inline |
This flag will be TRUE for any field whose value is not modified after construction and will be FALSE for those that have changed (each node or engine determines what the default values for its fields are). Note: the state of this flag should not be set explicitly from within applications.
|
inline |
bool SoField::isOfType | ( | SoType | type | ) | const |
This is typically used with the getClassTypeId() method to determine the type of an SoField * at run-time:
|
pure virtual |
Subclasses must define this as well as an == operator.
|
virtual |
Reimplemented in SoSFTrigger, SoSFPath, and SoMFPath.
|
inline |
|
inline |
This does the work common to all fields, then calls other read methods to do the rest.
|
protectedvirtual |
|
protectedpure virtual |
|
virtual |
The default method just checks if the field is connected to such a node or engine. Subclasses may contain other tests, such as those that contain pointers to nodes or engines.
Reimplemented in SoSFPath, SoSFNode, SoSFEngine, SoMFPath, SoMFNode, and SoMFEngine.
void SoField::removeAuditor | ( | void * | auditor, |
SoNotRec::Type | type | ||
) |
bool SoField::set | ( | const char * | valueString | ) |
Each field subclass defines its own file format; see their reference pages for information on their file format. The string should contain only the field's value, not the field's name (e.g., "1.0", not "width 1.0"). This method returns TRUE if the string is valid, FALSE if it is not.
void SoField::setContainer | ( | SoFieldContainer * | cont | ) |
This also calls enableNotify(TRUE) and setDefault(TRUE).
void SoField::setIgnored | ( | bool | ig | ) |
When a field's ignore flag is set to TRUE, the field is not used during traversal for rendering and other actions. The default value for this flag is FALSE.
bool SoField::shouldWrite | ( | ) | const |
Fields with default values that aren't ignored and aren't connected to anything will return FALSE.
|
virtual |
Reimplemented in SoSFTrigger.
|
virtual |
Calling touch() on an instance of a derived field class is equivalent to calling setValue(getValue()) using the derived class's methods, except that the field's isDefault() status remains unchanged.
Reimplemented in SoSFTrigger.
Referenced by SoSFTrigger::setValue().
|
protected |
If resetDefault is TRUE, this turns off default flag. Initiates notification, if necessary.
|
protectedvirtual |
|
protectedpure virtual |
|
friend |
SoFieldContainer* SoField::container |