treenode.h

Go to the documentation of this file.
00001 
00002 //**************************************************************************/
00003 // Copyright (c) 2008 Autodesk, Inc.
00004 // All rights reserved.
00005 //
00006 // Use of this software is subject to the terms of the Autodesk license
00007 // agreement provided at the time of installation or download, or which
00008 // otherwise accompanies this software in either electronic or hard copy form.
00009 //
00010 //**************************************************************************/
00011 // DESCRIPTION:
00012 // CREATED: October 2008
00013 //**************************************************************************/
00014 
00015 namespace mudbox {
00016 
00018 class MBDLL_DECL TreeNode : virtual public Node
00019 {
00020 public:
00021     DECLARE_CLASS;
00022 
00023     TreeNode( void );
00024     ~TreeNode( void );
00025     virtual void Serialize( Stream &s );
00026 
00028     virtual void AddChild( TreeNode *pChild, bool bFirst = false ) const;
00030     virtual void RemoveChild( TreeNode *pChild ) const;
00032     virtual TreeNode *FirstChild( void ) const;
00034     virtual TreeNode *Parent( void ) const;
00036     virtual TreeNode *NextSibling( void ) const;
00038     virtual TreeNode *PrevSibling( void ) const;
00040     virtual void MoveChild( TreeNode *pChild, TreeNode *pAfter );
00041 
00043     virtual TreeNode *ChildByClass( const ClassDesc *pClass, bool bAutoCreate = true ) const;
00045     template < typename type >
00046     inline type *ChildByClass( bool bAutoCreate = true ) const { return dynamic_cast<type *>( ChildByClass( type::StaticClass(), bAutoCreate ) ); };
00048     virtual TreeNode *ChildByClass( const ClassDesc *pClass, unsigned int iIndex = 0 ) const;
00050     template < typename type >
00051     inline type *ChildByClass( unsigned int iIndex = 0 ) const { return dynamic_cast<type *>( ChildByClass( type::StaticClass(), iIndex ) ); };
00053     virtual void DeleteChildByClass( const ClassDesc *pClass );
00054 
00056     virtual QString Info( void ) const;
00058     virtual bool Visible( void ) const;
00060     virtual void SetVisible( bool b );
00062     virtual bool Locked( void ) const;
00064     virtual void SetLocked( bool b );
00065 
00067     virtual void OnLinked( const TreeNode *pOldParent );
00068 
00070     virtual void CheckValidity( Node::DiagnosticLevel iLevel  = dgnLevel2 ) const;
00071 
00073     QString UniqueChildName( 
00074         const TreeNode* pChild,         
00075         const QString& sPrefix = ""     
00076         ) const;
00077 
00079     virtual void SetName( const QString &sName );
00080 
00081     virtual void CopyTo( Node *pNode ) const;
00082 
00083 private:
00084     mutable aptr<TreeNode> m_pNext;
00085     mutable aptr<TreeNode> m_pPrev;
00086     mutable aptr<TreeNode> m_pParent;
00087     mutable aptr<TreeNode> m_pChildren;
00088     abool m_bVisible, m_bLocked;
00089 };
00090 
00091 }; // end of namespace mudbox