Inline.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 __INLINE_H__
00030 #define __INLINE_H__
00031 
00032 #include "X3DChildNode.h"
00033 #include "X3DUrlObject.h"
00034 #include "X3DBoundedObject.h"
00035 #include "H3DDisplayListObject.h"
00036 #include "Group.h"
00037 #include "DEFNodes.h"
00038 
00039 namespace H3D {
00040 
00096   class H3DAPI_API Inline : 
00097     public X3DChildNode,
00098     public X3DBoundedObject,
00099     public X3DUrlObject,
00100     public H3DDisplayListObject {
00101   public:
00102 
00109     class LoadedScene: 
00110       public TypedField< DependentMFNode< Group,
00111                              FieldRef< H3DDisplayListObject,
00112                                        H3DDisplayListObject::DisplayList,
00113                                        &H3DDisplayListObject::displayList >,
00114                              true >,
00115                         Types< SFBool, MFString > > {
00116     public:
00120       ~LoadedScene() {
00121         clear( ownerId() );
00122       }
00123 
00124     protected:
00125       typedef TypedField< DependentMFNode< Group,
00126                              FieldRef< H3DDisplayListObject,
00127                                        H3DDisplayListObject::DisplayList,
00128                                        &H3DDisplayListObject::displayList >,
00129                              true >,
00130                         Types< SFBool, MFString > > LoadedSceneBase;
00132       virtual void update();
00133 
00135       virtual void onAdd( Node *n );
00136 
00138       virtual void onRemove( Node *n );
00139       
00140     };
00141 
00151     class H3DAPI_API SFBound: 
00152       public TypedField< X3DBoundedObject::SFBound,
00153                          void,
00154                          AnyNumber< X3DBoundedObject::SFBound > > {
00157       virtual void update();
00158     };
00159 
00161     Inline( Inst< SFNode      >  _metadata   = 0,
00162             Inst< DisplayList > _displayList = 0,
00163             Inst< MFString    >  _url        = 0,
00164             Inst< SFBound     > _bound       = 0,
00165             Inst< SFVec3f     >  _bboxCenter = 0,
00166             Inst< SFVec3f     >  _bboxSize   = 0,
00167             Inst< SFBool      >  _load       = 0,
00168             Inst< LoadedScene > _loadedScene = 0 );
00169 
00170     virtual ~Inline() {
00171       exported_nodes.clear();
00172     }
00173 
00179     virtual void initialize() {
00180       const Vec3f &size = bboxSize->getValue();
00181       if( size.x == -1 && size.y == -1 && size.z == -1 ) {
00182         NodeVector children_nodes = loadedScene->getValue();
00183         use_union_bound = true;
00184         // set the values againg in order to run onNodeAdd again
00185         // with use_union_bound set to true to set the routes.
00186         loadedScene->setValue( children_nodes, id );
00187       } else {
00188         use_union_bound = false;
00189         BoxBound *bb = new BoxBound();
00190         bb->center->setValue( bboxCenter->getValue() );
00191         bb->size->setValue( bboxSize->getValue() );
00192         bound->setValue( bb );
00193       }
00194       X3DChildNode::initialize();
00195     }
00196 
00198     virtual void render();
00199 
00200 #ifdef USE_HAPTICS
00201 
00202     virtual void traverseSG( TraverseInfo &ti );
00203 #endif
00204 
00208     auto_ptr< SFBool >  load;
00209     
00211     auto_ptr< LoadedScene > loadedScene;
00212 
00213     // if true a route will be set up between the bound field of the
00214     // loadedScene field and the bound field of the inline node. 
00215     bool use_union_bound;
00216 
00218     static H3DNodeDatabase database;
00219 
00222     X3D::DEFNodes exported_nodes;
00223   };
00224 }
00225 
00226 #endif

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