37 wxLogTrace( MASK_3D_SG,
38 wxT(
"%s:%s:%d * [BUG] inappropriate parent to SGCOLORS (type %s)" ),
39 __FILE__, __FUNCTION__, __LINE__, aParent->GetNodeType() );
43 m_Parent->AddChildNode( this );
67 if(
nullptr == aParent )
86 if(
nullptr == aNodeName || 0 == aNodeName[0] )
89 if( !
m_Name.compare( aNodeName ) )
110 wxCHECK( aNode,
false );
118 wxCHECK( aNode,
false );
129 aColorList =
nullptr;
133 aListSize =
colors.size();
143 if( 0 == aListSize ||
nullptr == aColorList )
146 for(
size_t i = 0; i < aListSize; ++i )
147 colors.push_back( aColorList[i] );
155 colors.emplace_back( aRedValue, aGreenValue, aBlueValue );
162 colors.push_back( aColor );
186 aFile <<
"color DEF " <<
GetName() <<
" Color { color [\n ";
191 aFile <<
"color USE " <<
GetName() <<
"\n";
197 aFile <<
"color Color { color [\n ";
204 for(
size_t i = 0; i < n; )
208 colors[i].GetColor(r, g, b);
237 if(
nullptr == parentNode )
255 wxCHECK( parentNode ==
m_Parent,
false );
259 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [INFO] bad stream" ),
260 __FILE__, __FUNCTION__, __LINE__ );
265 aFile <<
"[" <<
GetName() <<
"]";
266 size_t ncolors =
colors.size();
267 aFile.write( (
char*)&ncolors,
sizeof(
size_t) );
269 for(
size_t i = 0; i < ncolors; ++i )
282 wxCHECK(
colors.empty(),
false );
285 aFile.read( (
char*) &ncolors,
sizeof(
size_t ) );
291 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.
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.
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.
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...