41 wxLogTrace( MASK_3D_SG,
42 wxT(
"%s:%s:%d * [BUG] inappropriate parent to SGCOLORS (type %s)" ),
43 __FILE__, __FUNCTION__, __LINE__, aParent->
GetNodeType() );
71 if(
nullptr == aParent )
90 if(
nullptr == aNodeName || 0 == aNodeName[0] )
93 if( !m_Name.compare( aNodeName ) )
114 wxCHECK( aNode,
false );
122 wxCHECK( aNode,
false );
133 aColorList =
nullptr;
137 aListSize =
colors.size();
147 if( 0 == aListSize ||
nullptr == aColorList )
150 for(
size_t i = 0; i < aListSize; ++i )
151 colors.push_back( aColorList[i] );
159 colors.emplace_back( aRedValue, aGreenValue, aBlueValue );
166 colors.push_back( aColor );
190 aFile <<
"color DEF " <<
GetName() <<
" Color { color [\n ";
195 aFile <<
"color USE " <<
GetName() <<
"\n";
201 aFile <<
"color Color { color [\n ";
208 for(
size_t i = 0; i < n; )
212 colors[i].GetColor(r, g, b);
241 if(
nullptr == parentNode )
259 wxCHECK( parentNode ==
m_Parent,
false );
263 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [INFO] bad stream" ),
264 __FILE__, __FUNCTION__, __LINE__ );
269 aFile <<
"[" <<
GetName() <<
"]";
270 size_t ncolors =
colors.size();
271 aFile.write( (
char*)&ncolors,
sizeof(
size_t) );
273 for(
size_t i = 0; i < ncolors; ++i )
286 wxCHECK(
colors.empty(),
false );
289 aFile.read( (
char*) &ncolors,
sizeof(
size_t ) );
295 for(
size_t i = 0; i < ncolors; ++i )
void unlinkChildNode(const SGNODE *aNode) noexcept override
Remove references to an owned child.
bool WriteCache(std::ostream &aFile, SGNODE *parentNode) override
Write this node's data to a binary cache file.
bool ReadCache(std::istream &aFile, SGNODE *parentNode) override
Reads binary format data from a cache file.
bool AddChildNode(SGNODE *aNode) noexcept override
bool AddRefNode(SGNODE *aNode) noexcept override
virtual bool SetParent(SGNODE *aParent, bool notify=true) override
Set the parent SGNODE of this object.
void unlinkRefNode(const SGNODE *aNode) noexcept override
Remove pointers to a referenced node.
bool WriteVRML(std::ostream &aFile, bool aReuseFlag) override
Writes this node's data to a VRML file.
SGNODE * FindNode(const char *aNodeName, const SGNODE *aCaller) noexcept override
Search the tree of linked nodes and return a reference to the first node found with the given name.
void AddColor(double aRedValue, double aGreenValue, double aBlueValue)
void SetColorList(size_t aListSize, const SGCOLOR *aColorList)
std::vector< SGCOLOR > colors
SGCOLORS(SGNODE *aParent)
bool GetColorList(size_t &aListSize, SGCOLOR *&aColorList)
void ReNameNodes(void) override
Rename a node and all its child nodes in preparation for write operations.
The base class of all Scene Graph nodes.
virtual bool WriteCache(std::ostream &aFile, SGNODE *parentNode)=0
Write this node's data to a binary cache file.
const char * GetName(void)
SGNODE * GetParent(void) const noexcept
Returns a pointer to the parent SGNODE of this object or NULL if the object has no parent (ie.
S3D::SGTYPES GetNodeType(void) const noexcept
Return the type of this node instance.
virtual bool AddChildNode(SGNODE *aNode)=0
SGNODE * m_Parent
Pointer to parent node; may be NULL for top level transform.
std::string m_Name
name to use for referencing the entity by name.
virtual void unlinkChildNode(const SGNODE *aNode)=0
Remove references to an owned child.
bool m_written
Set to true when the object has been written after a ReNameNodes().
S3D::SGTYPES m_SGtype
Type of Scene Graph node.
bool WriteColor(std::ostream &aFile, const SGCOLOR &aColor)
void FormatColor(std::string &result, const SGCOLOR &aColor)
bool ReadColor(std::istream &aFile, SGCOLOR &aColor)
Define a number of macros to aid in repetitious code which is probably best expressed as a preprocess...