H3D API  2.4.1
GlobalSettings.h
Go to the documentation of this file.
1 // Copyright 2004-2019, SenseGraphics AB
3 //
4 // This file is part of H3D API.
5 //
6 // H3D API is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // H3D API is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with H3D API; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // A commercial license is also available. Please contact us at
21 // www.sensegraphics.com for more information.
22 //
23 //
27 //
29 #ifndef __GLOBALSETTINGS_H__
30 #define __GLOBALSETTINGS_H__
31 
32 #include <H3D/X3DBindableNode.h>
33 #include <H3D/SFString.h>
34 #include <H3D/SFBool.h>
35 #include <H3D/SFFloat.h>
36 #include <H3D/H3DOptionNode.h>
37 #include <H3D/GraphicsOptions.h>
38 #include <H3D/MFNode.h>
39 #include <H3D/PeriodicUpdate.h>
40 
41 namespace H3D {
78  //class GraphicsOptions;
79  class H3DAPI_API GlobalSettings : public X3DBindableNode {
80  public:
82  class H3DAPI_API MFOptionNode : public TypedMFNode< H3DOptionNode > {
83  protected:
84  virtual void onAdd( Node *n );
85  virtual void onRemove( Node *n );
86  };
87 
88  //typedef TypedMFNode< H3DOptionNode > MFOptionNode;
89 
91  GlobalSettings( Inst< SFSetBind > _set_bind = 0,
92  Inst< SFNode > _metadata = 0,
93  Inst< SFTime > _bindTime = 0,
94  Inst< SFBool > _isBound = 0,
95  Inst< MFOptionNode > _options = 0,
96  Inst< SFBool > _x3dROUTESendsEvent = 0,
97  Inst< SFBool > _loadTexturesInThread = 0,
98  Inst< SFString > _renderMode = 0,
99  Inst< SFBool > _multiThreadedPython = 0);
100 
103  removeFromStack();
104  }
105 
107  static inline GlobalSettings *getActive() {
108  return static_cast<GlobalSettings *>
109  (X3DBindableNode::getActive( "GlobalSettings" ));
110  }
111 
115  template< class OptionNodeType >
116  void getOptionNode( OptionNodeType * &option ) {
117  for( MFOptionNode::const_iterator i = options->begin();
118  i != options->end(); ++i ) {
119  OptionNodeType *option_node = dynamic_cast<OptionNodeType *>(*i);
120  if( option_node ) {
121  option = option_node;
122  return;
123  }
124  }
125  option = NULL;
126  }
127 
132  H3DUniquePtr< MFOptionNode > options;
133 
143  H3DUniquePtr< SFBool > x3dROUTESendsEvent;
144 
155  H3DUniquePtr< SFBool > loadTexturesInThread;
156 
170  H3DUniquePtr< SFString > renderMode;
171 
190  H3DUniquePtr< SFBool > multiThreadedPython;
191 
194 
197 
200  return !updateOptions->isUpToDate();
201  }
202 
203  protected:
204 
205  H3DUniquePtr< UpdateOptions > updateOptions;
206 
207  };
208 }
209 
210 #endif
Header file for GraphicsOptions.
Header file for H3DOptionNode.
Contains the MFNode class.
Header file for PeriodicUpdate, template field modifier.
Contains the SFBool field class.
Contains the SFFloat field class.
Contains the SFString field class.
Header file for X3DBindableNode, X3D scene-graph node.
GlobalSettings is a X3DBindableNode that specifies default settings for use in H3D API,...
Definition: GlobalSettings.h:79
H3DUniquePtr< SFString > renderMode
Controls the render mode of all geometries in the scene.
Definition: GlobalSettings.h:170
bool optionNodesUpdated()
check whether option nodes has updated since last scene graph loop
Definition: GlobalSettings.h:199
~GlobalSettings()
Destructor.
Definition: GlobalSettings.h:102
static bool default_x3d_route_sends_event
The default value for the x3dROUTESendsEvent field.
Definition: GlobalSettings.h:196
H3DUniquePtr< MFOptionNode > options
Contains the H3DOptionNode to be use as default settings.
Definition: GlobalSettings.h:132
H3DUniquePtr< SFBool > multiThreadedPython
If true then the embedded Python interpreter is initialized to support multi-threaded use of the Pyth...
Definition: GlobalSettings.h:190
static GlobalSettings * getActive()
Convenience function to get the top of the DeviceInfo stack.
Definition: GlobalSettings.h:107
H3DUniquePtr< SFBool > loadTexturesInThread
Controls if the downloading/reading of texture image data from file should be done in a separate thre...
Definition: GlobalSettings.h:155
H3DUniquePtr< SFBool > x3dROUTESendsEvent
According to the X3D specification the ROUTE statement in an X3D file is not supposed to send an even...
Definition: GlobalSettings.h:143
void getOptionNode(OptionNodeType *&option)
Get the first option node of the type of the pointer given as argument.
Definition: GlobalSettings.h:116
static H3DNodeDatabase database
The H3DNodeDatabase for this node.
Definition: GlobalSettings.h:193
Node is the base class for all classes that can be part of the H3D scene-graph.
Definition: Node.h:46
Template to make sure that the Nodes that are added to a MFNode are of a specified Node type.
Definition: MFNode.h:221
X3DBindableNode is the abstract base type for all bindable children nodes, including Background,...
Definition: X3DBindableNode.h:108
static X3DBindableNode * getActive(const string &bindable_stack_name)
Returns the active bindable instance, i.e.
Definition: X3DBindableNode.h:149
H3D API namespace.
Definition: Anchor.h:38
The H3DNodeDatabase contains a mapping between a name of a Node and the constructor for the Node with...
Definition: H3DNodeDatabase.h:194