44 std::map< std::string, WRL1NODE* >::iterator ir =
reg.find( aName );
49 reg.emplace( aName, aNode );
60 std::map< std::string, WRL1NODE* >::iterator ir =
reg.find( aName );
62 if( ir !=
reg.end() && ir->second == aNode )
77 std::map< std::string, WRL1NODE* >::iterator ir =
reg.find( aName );
86typedef std::pair< std::string, WRL1NODES >
NODEITEM;
87typedef std::map< std::string, WRL1NODES >
NODEMAP;
95 m_Type = WRL1NODES::WRL1_END;
105 nodenames.emplace(
NODEITEM(
"DirectionalLight", WRL1NODES::WRL1_DIRECTIONALLIGHT ) );
108 nodenames.emplace(
NODEITEM(
"IndexedFaceSet", WRL1NODES::WRL1_INDEXEDFACESET ) );
109 nodenames.emplace(
NODEITEM(
"IndexedLineSet", WRL1NODES::WRL1_INDEXEDLINESET ) );
113 nodenames.emplace(
NODEITEM(
"MaterialBinding", WRL1NODES::WRL1_MATERIALBINDING ) );
114 nodenames.emplace(
NODEITEM(
"MatrixTransform", WRL1NODES::WRL1_MATRIXTRANSFORM ) );
117 nodenames.emplace(
NODEITEM(
"OrthographicCamera", WRL1NODES::WRL1_ORTHOCAMERA ) );
118 nodenames.emplace(
NODEITEM(
"PerspectiveCamera", WRL1NODES::WRL1_PERSPECTIVECAMERA ) );
129 nodenames.emplace(
NODEITEM(
"Testure2Transform", WRL1NODES::WRL1_TEXTURE2TRANSFORM ) );
130 nodenames.emplace(
NODEITEM(
"TextureCoordinate2", WRL1NODES::WRL1_TEXTURECOORDINATE2 ) );
142 wxT(
" * [INFO] ^^ Destroying Type %d with %lu children, %lu references, and %lu "
159 wxLogTrace(
traceVrmlPlugin, wxT(
" * [INFO]%sType %d is unlinking ref #%d" ),
160 wxString(
' ', (
size_t) std::distance( sBP,
m_BackPointers.begin() ) * 2 ),
163 (*sBP)->unlinkRefNode(
this );
165 wxLogTrace(
traceVrmlPlugin, wxT(
" * [INFO]%sType %d has unlinked ref #%d" ),
166 wxString(
' ', (
size_t) std::distance( sBP,
m_BackPointers.begin() ) * 2 ),
174 std::list< WRL1NODE* >::iterator sC =
m_Children.begin();
175 std::list< WRL1NODE* >::iterator eC =
m_Children.end();
179 (*sC)->SetParent(
nullptr,
false );
181 wxLogTrace(
traceVrmlPlugin, wxT(
" * [INFO]%sType %d has unlinked child #%d" ),
182 wxString(
' ', (
size_t) std::distance( sC,
m_Children.begin() ) * 2 ),
187 wxLogTrace(
traceVrmlPlugin, wxT(
" * [INFO]%sType %d has deleted child #%d" ),
188 wxString(
' ', (
size_t) std::distance( sC,
m_Children.begin() ) * 2 ),
200 std::list< WRL1NODE* >::iterator sC =
m_Children.begin();
201 std::list< WRL1NODE* >::iterator eC =
m_Children.end();
239 std::list< WRL1NODE* >::iterator np = std::find(
m_BackPointers.begin(),
249 " * [BUG] delNodeRef() did not find its target." ),
250 __FILE__, __FUNCTION__, __LINE__ );
277 if( isdigit( aName[0] ) )
280 " * [INFO] invalid node name '%s' (begins with digit)" ),
281 __FILE__, __FUNCTION__, __LINE__, aName );
289 #define BAD_CHARS1 "\"\'#,.\\[]{}\x00\x01\x02\x03\x04\x05\x06\x09\x0A\x0B\x0C\x0D\x0E\x0F"
290 #define BAD_CHARS2 "\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"
292 if( std::string::npos != aName.find_first_of(
BAD_CHARS1 )
293 || std::string::npos != aName.find_first_of(
BAD_CHARS2 ) )
297 " * [INFO] invalid node name '%s' (contains invalid character)" ),
298 __FILE__, __FUNCTION__, __LINE__, aName );
314 if( aNodeType < WRL1NODES::WRL1_BASE || aNodeType >= WRL1NODES::WRL1_END )
315 return "*INVALID_TYPE*";
317 if( aNodeType == WRL1NODES::WRL1_BASE )
318 return "*VIRTUAL_BASE*";
320 NODEMAP::iterator it =
nodenames.begin();
321 advance( it, (
static_cast<int>( aNodeType ) -
static_cast<int>( WRL1NODES::WRL1_BEGIN ) ) );
323 return it->first.c_str();
329 NODEMAP::iterator it =
nodenames.find( aNodeName );
334 return WRL1NODES::WRL1_INVALID;
364 if(
nullptr !=
m_Parent && doUnlink )
378 wxCHECK_MSG( aNode,
false, wxT(
"Invalid node pointer." ) );
379 wxCHECK_MSG( aNode->
GetNodeType() != WRL1NODES::WRL1_BASE,
false,
380 wxT(
"Attempting to add a base node to another node." ) );
382 std::list< WRL1NODE* >::iterator sC =
m_Children.begin();
383 std::list< WRL1NODE* >::iterator eC =
m_Children.end();
405 wxCHECK_MSG( aNode,
false, wxT(
"Invalid node pointer." ) );
406 wxCHECK_MSG( aNode->
GetNodeType() != WRL1NODES::WRL1_BASE,
false,
407 wxT(
"Attempt to add a base node reference to another base node" ) );
412 m_Refs.push_back( aNode );
422 std::list< WRL1NODE* >::iterator sL =
m_Children.begin();
423 std::list< WRL1NODE* >::iterator eL =
m_Children.end();
441 std::list< WRL1NODE* >::iterator sL =
m_Refs.begin();
442 std::list< WRL1NODE* >::iterator eL =
m_Refs.end();
466 std::list< WRL1NODE* >::iterator sL =
m_Items.begin();
467 std::list< WRL1NODE* >::iterator eL =
m_Items.end();
bool AddName(const std::string &aName, WRL1NODE *aNode)
WRL1NODE * FindName(const std::string &aName)
bool DelName(const std::string &aName, WRL1NODE *aNode)
std::map< std::string, WRL1NODE * > reg
The base class of all VRML1 nodes.
WRL1NODE * GetParent(void) const
Return a pointer to the parent SGNODE of this object or NULL if the object has no parent (ie.
std::string GetError(void)
void delNodeRef(WRL1NODE *aNode)
Remove a pointer to a node which references, but does not own, this node.
WRL1NODE(NAMEREGISTER *aDictionary)
WRL1NODES getNodeTypeID(const std::string &aNodeName)
Return the ID based on the given aNodeName or WRL1_INVALID (WRL1_END) if no such node name exists.
std::list< WRL1NODE * > m_Items
NAMEREGISTER * m_dictionary
virtual WRL1NODE * FindNode(const std::string &aNodeName)
Search the tree of linked nodes and returns a reference to the current node with the given name.
void addNodeRef(WRL1NODE *aNode)
Add a pointer to a node which references, but does not own, this node.
virtual bool AddRefNode(WRL1NODE *aNode)
virtual bool AddChildNode(WRL1NODE *aNode)
virtual std::string GetName(void)
virtual bool SetParent(WRL1NODE *aParent, bool doUnlink=true)
Set the parent WRL1NODE of this object.
std::list< WRL1NODE * > m_BackPointers
virtual void unlinkChildNode(const WRL1NODE *aNode)
Remove references to an owned child; it is invoked by the child upon destruction to ensure that the p...
std::list< WRL1NODE * > m_Children
size_t GetNItems(void) const
virtual bool SetName(const std::string &aName)
void addItem(WRL1NODE *aNode)
const char * GetNodeTypeName(WRL1NODES aNodeType) const
std::list< WRL1NODE * > m_Refs
virtual void unlinkRefNode(const WRL1NODE *aNode)
Remove pointers to a referenced node; it is invoked by the referenced node upon destruction to ensure...
WRL1NODES GetNodeType(void) const
Return the type of this node instance.
void delItem(const WRL1NODE *aNode)
const wxChar *const traceVrmlPlugin
Flag to enable VRML plugin trace output.
std::map< std::string, std::vector< SGNODE * > > NODEMAP
std::pair< std::string, std::vector< SGNODE * > > NODEITEM
std::map< std::string, WRL1NODES > NODEMAP
std::pair< std::string, WRL1NODES > NODEITEM