Open Inventor Reference
SoDB Class Reference

Scene graph database class. More...

#include <Inventor/SoDB.h>

Static Public Member Functions

static void init ()
 Initializes the database.
 
static const char * getVersion ()
 Returns a character string identifying the version of the Inventor library in use.
 
static bool read (SoInput *in, SoNode *&rootNode)
 
static bool read (SoInput *in, SoPath *&path)
 Reads a graph from the file specified by the given SoInput, returning a pointer to the resulting root node in rootNode, or a pointer to the resulting path in path.
 
static SoSeparatorreadAll (SoInput *in)
 Reads all graphs and paths from the file specified by the given SoInput.
 
static bool registerHeader (const SbString &headerString, bool isBinary, float ivVersion, SoDBHeaderCB *preCB, SoDBHeaderCB *postCB, void *userData=NULL)
 Registers the given string as a valid header for input files.
 
static bool getHeaderData (const SbString &string, bool &isBinary, float &ivVersion, SoDBHeaderCB *&preCB, SoDBHeaderCB *&postCB, void *&userData, bool substringOK=FALSE)
 Passes back the data registered with the given header string, including the flag specifying whether the string is for a binary file, pointers to the callback functions invoked before and after reading the file, and a pointer to the user data passed to the callback functions.
 
static int getNumHeaders ()
 Returns the number of valid headers, including standard Inventor headers, and user-registered headers.
 
static SbString getHeaderString (int i)
 Returns the i'th header.
 
static bool isValidHeader (const char *testString)
 This returns TRUE if the given character string is one of the valid Inventor file headers, (e.g.
 
static SoFieldcreateGlobalField (const SbName &name, SoType type)
 The database maintains a namespace for global fields, making sure that there is at most one instance of a global field with any given name in the database.
 
static SoFieldgetGlobalField (const SbName &name)
 Returns the global field with the given name, or NULL if there is none.
 
static void renameGlobalField (const SbName &oldName, const SbName &newName)
 Renames the global field named oldName.
 
static void setRealTimeInterval (const SbTime &deltaT)
 The database automatically creates one global field when SoDB::init() is called.
 
static const SbTimegetRealTimeInterval ()
 Returns how often the database is updating realTime .
 
static void setDelaySensorTimeout (const SbTime &t)
 This sets the timeout value for sensors that are delay queue sensors (one-shot sensors, data sensors).
 
static const SbTimegetDelaySensorTimeout ()
 Returns the current delay queue timeout value.
 
static int doSelect (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *userTimeOut)
 In order to keep timer and idle sensors running as expected, it is necessary that an Inventor application not block waiting for input.
 
static void addConverter (SoType fromField, SoType toField, SoType converterEngine)
 Registers a field conversion engine that can be used to convert from one type of field to another.
 
static SoType getConverter (SoType fromField, SoType toField)
 Returns the field conversion engine registered for the two given field types.
 
static SoSensorManagergetSensorManager ()
 Accesses sensor manager.
 
static bool isInitialized ()
 Returns TRUE if database is initialized (for error checking)
 
static void startNotify ()
 This is called when some instance begins or ends a notification process.
 
static bool isNotifying ()
 
static void endNotify ()
 
static void enableRealTimeSensor (bool enable)
 Enables/disables realTime sensor processing.
 
static bool read (SoInput *in, SoBase *&base)
 Reads a base of any type, returning a pointer to it.
 

Detailed Description

The SoDB class holds all scene graphs, each representing a 3D scene used by an application. A scene graph is a collection of SoNode objects which come in several varieties (see SoNode). Application programs must initialize the database by calling SoDB::init() before calling any other database routines and before constructing any nodes, paths, functions, or actions. Note that SoDB::init() is called by SoInteraction::init(), and SoNodeKit::init(), so if you are calling any of these methods, you do not need to call SoDB::init() directly. All methods on this class are static.

Typical program database initialization and scene reading is as follows:

#include <Inventor/SoDB.h>
SoSeparator *rootSep;
rootSep = SoDB::readAll(&in);
if (rootSep == NULL)
printf("Error on read...\n");
...\
static SoSeparator * readAll(SoInput *in)
Reads all graphs and paths from the file specified by the given SoInput.
static void init()
Initializes the database.
Used to read Inventor data files.
Definition SoInput.h:128
Group node that saves and restores traversal state.

See Also
SoBase, SoNode, SoEngine, SoField, SoInput, SoFile, SoPath, SoOneShotSensor, SoDataSensor

Definition at line 115 of file SoDB.h.

Member Function Documentation

◆ addConverter()

static void SoDB::addConverter ( SoType  fromField,
SoType  toField,
SoType  converterEngine 
)
static

The type id's of the two fields are passed in, as is the type id of the field converter engine (derived from SoFieldConverter).

◆ createGlobalField()

static SoField * SoDB::createGlobalField ( const SbName name,
SoType  type 
)
static

This routine is used to create new global fields. If there is no global field with the given name, it will create a new global field with the given name and type. If there is already a global field with the given name and type, it will return it. If there is already a global field with the given name but a different type, this returns NULL.

All global fields must be derived from SoField; typically the result of this routine is cast into the appropriate type; for example:

SoSFInt32 *longField =
static SoField * createGlobalField(const SbName &name, SoType type)
The database maintains a namespace for global fields, making sure that there is at most one instance ...
static SoType getClassTypeId()
Return the type identifier for this field class.
Definition SoField.h:206
Field containing a int32_t integer.
Definition SoSFInt32.h:79

◆ doSelect()

static int SoDB::doSelect ( int  nfds,
fd_set *  readfds,
fd_set *  writefds,
fd_set *  exceptfds,
struct timeval *  userTimeOut 
)
static

If the Inventor application uses the Xt utility library, this can be handled automatically. However, if the application is using its own event loop, this function is provided as a wrapper around select(2) that will handle Inventor tasks if necessary instead of blocking.

◆ enableRealTimeSensor()

static void SoDB::enableRealTimeSensor ( bool  enable)
static

◆ endNotify()

static void SoDB::endNotify ( )
inlinestatic

Definition at line 319 of file SoDB.h.

◆ getConverter()

static SoType SoDB::getConverter ( SoType  fromField,
SoType  toField 
)
static

If no such engine exists, SoType::badType() is returned.

◆ getDelaySensorTimeout()

static const SbTime & SoDB::getDelaySensorTimeout ( )
static

◆ getGlobalField()

static SoField * SoDB::getGlobalField ( const SbName name)
static

The type of the field may be checked using the SoField::isOfType(), SoField::getClassTypeId(), and SoField::getTypeId() methods.

◆ getHeaderData()

static bool SoDB::getHeaderData ( const SbString string,
bool &  isBinary,
float &  ivVersion,
SoDBHeaderCB *&  preCB,
SoDBHeaderCB *&  postCB,
void *&  userData,
bool  substringOK = FALSE 
)
static

If the given header string does not match any of the registered headers, and the substringOK flag is TRUE, then the method will search for a registered header that is a substring of the given string. The method returns TRUE if a matching registered header, or subheader, was found.

◆ getHeaderString()

static SbString SoDB::getHeaderString ( int  i)
static

◆ getNumHeaders()

static int SoDB::getNumHeaders ( )
static

◆ getRealTimeInterval()

static const SbTime & SoDB::getRealTimeInterval ( )
static

◆ getSensorManager()

static SoSensorManager * SoDB::getSensorManager ( )
static

◆ getVersion()

static const char * SoDB::getVersion ( )
static

◆ init()

static void SoDB::init ( )
static

This must be called before calling any other database routines, including the construction of any nodes, paths, engines, or actions.

◆ isInitialized()

static bool SoDB::isInitialized ( )
inlinestatic

Definition at line 309 of file SoDB.h.

◆ isNotifying()

static bool SoDB::isNotifying ( )
inlinestatic

Definition at line 318 of file SoDB.h.

◆ isValidHeader()

static bool SoDB::isValidHeader ( const char *  testString)
static

"#Inventor V2.0 binary"), or if the string has been registered as a valid header through the registerHeader method.

◆ read() [1/3]

static bool SoDB::read ( SoInput in,
SoBase *&  base 
)
static

Returns FALSE on error.

◆ read() [2/3]

static bool SoDB::read ( SoInput in,
SoNode *&  rootNode 
)
static

◆ read() [3/3]

static bool SoDB::read ( SoInput in,
SoPath *&  path 
)
static

The programmer is responsible for determining which routine to use, based on the contents of the input. These routines return FALSE if any error occurred during reading.

If the passed SoInput was used to open a file and the name of the file contains a directory, SoDB automatically adds the directory to the end of the current directory search path in the SoInput. This means that nested files named in SoFile nodes may be found relative to that directory. The directory is removed from the search path when reading is complete.

◆ readAll()

static SoSeparator * SoDB::readAll ( SoInput in)
static

If there is only one graph in the file and its root is an SoSeparator, a pointer to the root is returned. In all other cases, this creates an SoSeparator, adds the root nodes of all graphs read as children of it, and returns a pointer to it. This returns NULL on error. This processes directory paths in the same way as the other reading routines.

◆ registerHeader()

static bool SoDB::registerHeader ( const SbString headerString,
bool  isBinary,
float  ivVersion,
SoDBHeaderCB preCB,
SoDBHeaderCB postCB,
void *  userData = NULL 
)
static

The string must be 80 characters or less, and start with the comment character '#'. If the passed isBinary flag is true, any file with this header will be read as a binary file. Usually, a user-defined header represents a file format that is a superset of the Inventor file format. The ivVersion number indicates which Inventor file version this header corresponds to. The user-defined callback functions preCB and postCB are called before and after a file with this header is read. The userData is passed to both callback functions. The method returns TRUE if the header is successfully registered. Note, nothing prevents you from registering the same string multiple times.

◆ renameGlobalField()

static void SoDB::renameGlobalField ( const SbName oldName,
const SbName newName 
)
static

Renaming a global field to an empty name ("") deletes it. If there is already a global field with the new name, that field will be deleted (the getGlobalField method can be used to guard against this).

◆ setDelaySensorTimeout()

static void SoDB::setDelaySensorTimeout ( const SbTime t)
static

Delay queue sensors are triggered whenever there is idle time. If a long period of time elapses without any idle time (as when there are continuous events to process), these sensors may not be triggered. Setting this timeout value ensures that if the specified length of time elapses without any idle time, the delay queue sensors will be processed anyway.

◆ setRealTimeInterval()

static void SoDB::setRealTimeInterval ( const SbTime deltaT)
static

The realTime global field, which is of type SoSFTime, can be connected to engines and nodes for real-time animation. The database will automatically update the realTime global field 12 times per second, using a timer sensor. Typically, there will be a node sensor on the root of the scene graph which schedules a redraw whenever the scene graph changes; by updating the realTime global field periodically, scene graphs that are connected to realTime (and are therefore animating) will be redrawn. The rate at which the database updates realTime can be controlled with this routine. Passing in a zero time will disable automatic update of realTime . If there are no enabled connections from the realTime field to any other field, the sensor is automatically disabled. .p Note that the SoSceneManager class automatically updates realTime immediately after redrawing, which will result in as high a frame rate as possible if the scene is continuously animating. The SoDB::setRealTimeInterval method ensures that engines that do not continuously animate (such as SoTimeCounter) will eventually be scheduled.

◆ startNotify()

static void SoDB::startNotify ( )
inlinestatic

It increments or decrements a counter of notifications in progress. When the counter reaches 0, all priority 0 (immediate) delay queue sensors are triggered. By doing this, all notification has a chance to finish before any evaluation (due to data sensors, primarily) takes place.

Definition at line 317 of file SoDB.h.


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