public abstract class SoField extends Inventor
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, Open Inventor will automatically try to insert a field converter engine between them to convert values from one type into the other. Open 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 internalDEF node1 Transform translation 1 1 1 DEF node2 Scale scaleFactor 1 1 1 = USE node1.translation
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:
GlobalField{ type SoSFUInt32 FrameCounter 494 }
See also:
Modifier and Type | Class and Description |
---|---|
static class |
SoField.FieldTypes |
Inventor.ConstructorCommand
VERBOSE_LEVEL, ZeroHandle
Modifier and Type | Method and Description |
---|---|
boolean |
appendConnection(SoEngineOutput engineOutput)
Appends this field to the list of connections from another engineOutput.
|
boolean |
appendConnection(SoField field)
Appends this field to the list of connections from another field.
|
boolean |
appendConnection(SoVRMLInterpOutput interpOutput)
Appends this field to the list of connections from another interpOutput.
|
boolean |
connectFrom(SoEngineOutput engineOutput)
Connects this field from an engine output.
|
boolean |
connectFrom(SoField field)
Connects this field to another field.
|
boolean |
connectFrom(SoVRMLInterpOutput interpOutput)
Connects this field from an interpOutput.
|
void |
disconnect()
Disconnect the field from whatever it was connected to.
|
void |
disconnect(SoEngineOutput engineOutput)
Disconnect the field from the requested engineOutput.
|
void |
disconnect(SoField field)
Disconnect the field from the requested field.
|
void |
disconnect(SoVRMLInterpOutput interpOutput)
Disconnect the field from the requested interpOutput.
|
void |
enableConnection(boolean flag)
Field connections may be enabled and disabled.
|
boolean |
equals(java.lang.Object obj) |
java.lang.String |
get()
Returns the value of the field in the Open Inventor file format, even if the field has its default value.
|
SoEngineOutput |
getConnectedEngine()
Returns true if this field is being written into by an engine, and returns the engine output it is connected to in engineOutput.
|
SoField |
getConnectedField()
Returns true if this field is being written into by another field, and returns the field it is connected to in writingField.
|
SoVRMLInterpOutput |
getConnectedVRMLInterp()
Returns the VRMLInterpolator output field is connected to.
|
SoFieldContainer |
getContainer()
Returns the object that contains this field.
|
int |
getNumConnections()
Returns the number of connections to this field.
|
boolean |
isConnected()
Returns true if the field is connected to anything.
|
boolean |
isConnectedFromEngine()
Returns true if the field is connected to an engine's output.
|
boolean |
isConnectedFromField()
Returns true if the field is connected to another field.
|
boolean |
isConnectedFromVRMLInterp()
Returns true if the field is connected to a VRML interpOutput.
|
boolean |
isConnectionEnabled()
Returns false if connections to this field are disabled.
|
boolean |
isDefault()
Gets the state of default flag of the field.
|
boolean |
isIgnored()
Gets the ignore flag for this field.
|
boolean |
set(java.lang.String valueString)
Sets the field to the given value, which is an ASCII string in the Open Inventor file format.
|
void |
setIgnored(boolean ig)
Sets the ignore flag for this field.
|
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.
|
dispose, getAddress, getNativeResourceHandle, startInternalThreads, stopInternalThreads
public boolean connectFrom(SoEngineOutput engineOutput)
enableConnection()
), the field's value will be set to the value of the thing it is connected to.public boolean isConnectionEnabled()
public SoFieldContainer getContainer()
public boolean set(java.lang.String valueString)
public boolean isConnectedFromVRMLInterp()
public boolean isConnectedFromEngine()
public SoVRMLInterpOutput getConnectedVRMLInterp()
public boolean isConnectedFromField()
public SoField getConnectedField()
public SoEngineOutput getConnectedEngine()
public boolean isDefault()
public void enableConnection(boolean flag)
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.
public void setIgnored(boolean ig)
Examples of fields that are not inherited are the fields of shape nodes, light-source nodes, some groups, and cameras, as well as the fields in the SoEnvironment
node. If you set the Ignore flag for a field whose values are not inherited, Open Inventor simply uses the field's default values.
The default value for this flag is false.
public boolean isIgnored()
public boolean appendConnection(SoVRMLInterpOutput interpOutput)
public void disconnect(SoEngineOutput engineOutput)
public void disconnect(SoField field)
public boolean appendConnection(SoField field)
public boolean connectFrom(SoField field)
enableConnection()
), the field's value will be set to the value of the thing it is connected to.public boolean connectFrom(SoVRMLInterpOutput interpOutput)
enableConnection()
), the field's value will be set to the value of the thing it is connected to.public boolean appendConnection(SoEngineOutput engineOutput)
public void disconnect(SoVRMLInterpOutput interpOutput)
public java.lang.String get()
public boolean isConnected()
public void disconnect()
public int getNumConnections()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public void touch()
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.Generated on January 23, 2025, Copyright © Thermo Fisher Scientific. All rights reserved. http://www.openinventor.com