X3DGroupingNode.h

Go to the documentation of this file.
00001 
00002 //    Copyright 2004, SenseGraphics AB
00003 //
00004 //    This file is part of H3D API.
00005 //
00006 //    H3D API is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    H3D API is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with H3D API; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 //
00020 //    A commercial license is also available. Please contact us at 
00021 //    www.sensegraphics.com for more information.
00022 //
00023 //
00027 //
00029 #ifndef __X3DGROUPINGNODE_H__
00030 #define __X3DGROUPINGNODE_H__
00031 
00032 #include "X3DChildNode.h"
00033 #include "X3DBoundedObject.h"
00034 #include "DependentNodeFields.h"
00035 #include "H3DDisplayListObject.h"
00036 
00037 namespace H3D {
00038 
00044   class H3DAPI_API X3DGroupingNode : 
00045     public X3DChildNode,
00046     public X3DBoundedObject,
00047     public H3DDisplayListObject{
00048   public:
00049     
00055     class H3DAPI_API MFChild :
00056       public DependentMFNode< X3DChildNode,
00057         FieldRef< H3DDisplayListObject,
00058                   H3DDisplayListObject::DisplayList,
00059                   &H3DDisplayListObject::displayList >,
00060                               true >  {
00061       public:
00063       typedef DependentMFNode< 
00064         X3DChildNode,
00065         FieldRef< H3DDisplayListObject,
00066                   H3DDisplayListObject::DisplayList,
00067                   &H3DDisplayListObject::displayList >,
00068         true >  MFChildBase;
00069 
00073       ~MFChild() {
00074         clear();
00075       }
00076 
00078       virtual void onAdd( Node *n );
00079 
00081       virtual void onRemove( Node *n );
00082 
00083     private:
00084       friend class X3DGroupingNode;
00085     };
00086     friend class MFChild;
00087     
00097     class H3DAPI_API SFBound: 
00098       public TypedField< X3DBoundedObject::SFBound,
00099                          void,
00100                          AnyNumber< X3DBoundedObject::SFBound > > {
00103       virtual void update();
00104     };
00105 
00107     X3DGroupingNode( 
00108                     Inst< MFChild  > _addChildren    = 0,
00109                     Inst< MFChild  > _removeChildren = 0,
00110                     Inst< MFChild > _children       = 0,
00111                     Inst< SFNode  > _metadata       = 0,
00112                     Inst< SFBound > _bound          = 0,
00113                     Inst< SFVec3f > _bboxCenter     = 0,
00114                     Inst< SFVec3f > _bboxSize       = 0 );
00115 
00121     virtual void initialize() {
00122       const Vec3f &size = bboxSize->getValue();
00123       if( size.x == -1 && size.y == -1 && size.z == -1 ) {
00124         NodeVector children_nodes = children->getValue();
00125         use_union_bound = true;
00126         // set the values againg in order to run onNodeAdd again
00127         // with use_union_bound set to true to set the routes.
00128         children->setValue( children_nodes );
00129       } else {
00130         use_union_bound = false;
00131         BoxBound *bb = new BoxBound();
00132         bb->center->setValue( bboxCenter->getValue() );
00133         bb->size->setValue( bboxSize->getValue() );
00134         bound->setValue( bb );
00135       }
00136       X3DChildNode::initialize();
00137     }
00138 
00140     virtual void render();
00141 
00142 #ifdef USE_HAPTICS
00143 
00144     virtual void traverseSG( TraverseInfo &ti );
00145 #endif
00146   
00149     bool use_union_bound;
00150     
00156     auto_ptr< MFChild  >  addChildren;
00157 
00163     auto_ptr< MFChild  >  removeChildren;
00164 
00168     auto_ptr< MFChild >  children;
00169     
00171     static H3DNodeDatabase database;
00172 
00173   };
00174 }
00175 
00176 #endif

Generated on Thu Aug 24 12:38:35 2006 for H3D API by  doxygen 1.4.5