Scene Class Reference

#include <Scene.h>

Inheritance diagram for Scene:

SceneBase List of all members.

Public Member Functions

 Scene ()
virtual ~Scene ()
void def (const char *nodeName, Node *value)
Nodeuse (const char *nodeName)
NodegetNodeByName (const char *nodeName)
void undef (const char *nodeName)
int addSymbol (std::string s)
const std::string & getSymbol (int id) const
void setRoot (Node *root)
NodegetRoot () const
void setNodes (NodeList *nodes)
virtual const char * parseVRML (FILE *f)
NodecreateNode (const char *nodeType)
bool writeVRML (FILE *f)
void addProto (std::string name, Proto *value)
ProtogetProto (std::string name)
void addRoute (Node *src, int eventOut, Node *dest, int eventIn)
void deleteRoute (Node *src, int eventOut, Node *dest, int eventIn)
int getFieldType (std::string name)
void errorf (const char *fmt,...)
void invalidNode (const char *nodeName)
void invalidField (const char *node, const char *field)
void setField (Node *node, int field, FieldValue *value)
void addNode (Node *node)
void removeNode (Node *node)
std::string generateUniqueNodeName (Node *node)
const NodeListgetNodes () const
bool isTempSave () const
void ref ()
void unref ()

Static Public Member Functions

static bool validRoute (Node *src, int eventOut, Node *dst, int eventIn)
static const char * getFieldTypeName (int type)
static void checkInLicense ()
static void checkOutLicense ()

Private Attributes

int _refs
NodeMap _nodeMap
Node_root
StringMap _symbols
std::vector< std::string > _symbolList
ProtoMap _protos
StringMap _fieldTypeMap
NodeList_nodes
int _numSymbols
NodeViewpoint_defaultViewpoint
NodeViewpoint_currentViewpoint
std::string _compileErrors
bool _tempSave

Detailed Description

This is the main manager class that controls all the scene and node aspects, registrations. It is also used as a handle to the current VRML scene. Important data types:

std::map<std::string,Node *> NodeMap, std::map<std::string,int> StringMap, std::map<std::string,Proto *> ProtoMap. Important variables are:

It also assigns Node _root of the Scene to be a "Group" node and creates a default viewpoint


Constructor & Destructor Documentation

Scene::Scene (  ) 

Scene class constructor. Initialises the private "StringMap _fieldTypeMap" to contain pairs of "std::string-Int" as "MFVec3f - MFVEC3F" (the int ID MFVEC3F is returned from the scanner). Also initialises the private "ProtoMap _protos" to contain pairs of "std::string-Proto" as "Anchor - ProtoAnchor". In addition it assigns "Node _root" of the Scene to be a "Group" Node. Also it creates a default viewpoint.

TM

TM

Scene::~Scene (  )  [virtual]


Member Function Documentation

void Scene::def ( const char *  nodeName,
Node value 
)

In case of a VRML DEF keyword. Assigns the std::string "nodename" to the Node.

Node * Scene::use ( const char *  nodeName  ) 

In case of a VRML "USE" statement.

Parameters:
nodeName the name of the node.
Returns:
the Node that has that DEF nodename in the "std::string-Node" _nodeMap.

Node * Scene::getNodeByName ( const char *  nodeName  ) 

Returns the Node that has the specified DEF name.

Parameters:
nodeName the name of the node.
Returns:
the Node that has that DEF nodename in the "std::string-Node" _nodeMap.

void Scene::undef ( const char *  nodeName  ) 

Deassociate the Node with name 'nodeName' from that nodeName (in the NodeMap HastTable).

int Scene::addSymbol ( std::string  s  ) 

Primary used by the lexer. Adds the tokenised std::string input yytext to the Symbol HashTable and then in the Vector(Array) that contains all the parsed tokens.

Parameters:
s std::string read by the lexr
Returns:
the int id position of the input std::string in the Scene's Array of input lexer Strings

const string & Scene::getSymbol ( int  id  )  const

Returns a std::string scanned by the lexer.

Parameters:
id the id(position) of the lexer input std::string
Returns:
the std::string that is contained in the specified id in the Array<std::string>

void Scene::setRoot ( Node root  )  [inline]

Sets the first primary Node as a root to the scene.

Node* Scene::getRoot (  )  const [inline]

Gets the first primary Node root of the scene.

void Scene::setNodes ( NodeList nodes  ) 

Sets all the root Nodes in the scenegraph. They are set as children of the _root "Group" node. (set in the Scene constructor).

const char * Scene::parseVRML ( FILE *  f  )  [virtual]

Calls the yyparse() method of the parser. Then begins the parsing process.

Implements SceneBase.

Node * Scene::createNode ( const char *  nodeType  ) 

Creates a new Node. That Node is taken from the ProtoMap pair std::string-Proto e,g, "Anchor"-ProtoAnchor initialised in Scene's contructor.

bool Scene::writeVRML ( FILE *  f  ) 

Outputs to a file all the scene contents(all nodes).

void Scene::addProto ( std::string  name,
Proto value 
)

Adds a named Proto to the Proto HashTable. The Proto is added to the ProtoMap _protos as a pair of key std::string-Proto values.

Proto* Scene::getProto ( std::string  name  ) 

Returns a Proto from the Proto HashTable. From the ProtoMap <std::string,Proto *>.

bool Scene::validRoute ( Node src,
int  eventOut,
Node dst,
int  eventIn 
) [static]

Checks if the Route is valid (from eventOut to eventIn).

void Scene::addRoute ( Node src,
int  eventOut,
Node dest,
int  eventIn 
)

In case of a VRML Route statement. Adds an event route from the src Node to dst Node.

void Scene::deleteRoute ( Node src,
int  eventOut,
Node dest,
int  eventIn 
)

int Scene::getFieldType ( std::string  name  ) 

Returns an int from a StringMap HashTable for FieldTypes. That is the int id from the StringMap _fieldTypeMap e.g. key "MFVec3f"-MFVEC3F value

const char * Scene::getFieldTypeName ( int  type  )  [static]

Returns a std::string from a StringMap HashTable for FieldTypes. From the pairs std::string-Id returns the opposite of getFieldType i.e. the std::string name

void Scene::errorf ( const char *  fmt,
  ... 
)

Outputs error messages to a buffer

void Scene::invalidNode ( const char *  nodeName  ) 

Outputs error message. In case of an invalid DEF name.

void Scene::invalidField ( const char *  node,
const char *  field 
)

Outputs error message. In case of an invalid Field.

void Scene::setField ( Node node,
int  field,
FieldValue value 
)

Sets the field of the current node to the fieldValue

void Scene::addNode ( Node node  ) 

Appends a new node to the Scene. Actually the new Node is added in the Scene's NodeList(Array<Node*>)

void Scene::removeNode ( Node node  ) 

Removes the Node from the Scene. Actually from Scene._nodes ( a NodeList i.e. an Array<Node*>)

string Scene::generateUniqueNodeName ( Node node  ) 

In case of Node::write() and that Node doesn't have a nodeName, generate a new nodeName.

const NodeList* Scene::getNodes (  )  const [inline]

Returns a reference to all the root Nodes in the Scene contained in it's NodeList.

bool Scene::isTempSave (  )  const [inline]

void Scene::ref (  )  [inline]

void Scene::unref (  )  [inline]

void Scene::checkInLicense (  )  [static]

FLEX_LM Check_in license

void Scene::checkOutLicense (  )  [static]

FLEX_LM Check_out license


Member Data Documentation

int Scene::_refs [private]

NodeMap Scene::_nodeMap [private]

Node* Scene::_root [private]

StringMap Scene::_symbols [private]

std::vector<std::string> Scene::_symbolList [private]

ProtoMap Scene::_protos [private]

StringMap Scene::_fieldTypeMap [private]

NodeList* Scene::_nodes [private]

int Scene::_numSymbols [private]

NodeViewpoint* Scene::_defaultViewpoint [private]

NodeViewpoint* Scene::_currentViewpoint [private]

std::string Scene::_compileErrors [private]

bool Scene::_tempSave [private]


Generated on Thu Jan 18 10:06:22 2007 for vhdPLUS by  doxygen 1.5.1-p1