OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ProxyNode.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2  *
3  * This library is open source and may be redistributed and/or modified under
4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5  * (at your option) any later version. The full license is in LICENSE file
6  * included with this distribution, and on the openscenegraph.org website.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * OpenSceneGraph Public License for more details.
12 */
13 
14 #ifndef OSG_ProxyNode
15 #define OSG_ProxyNode 1
16 
17 #include <osg/Group>
18 
19 namespace osg {
20 
23 class OSG_EXPORT ProxyNode : public Group
24 {
25  public :
26 
27  ProxyNode();
28 
30  ProxyNode(const ProxyNode&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
31 
33 
36 
37  virtual void traverse(NodeVisitor& nv);
38 
39  virtual bool addChild(Node *child);
40  virtual bool addChild(Node *child, const std::string& filename);
41 
42  virtual bool removeChildren(unsigned int pos,unsigned int numChildrenToRemove);
43 
44 
46  void setDatabaseOptions(osg::Referenced* options) { _databaseOptions = options; }
47 
49  osg::Referenced* getDatabaseOptions() { return _databaseOptions.get(); }
50 
52  const osg::Referenced* getDatabaseOptions() const { return _databaseOptions.get(); }
53 
54 
56  void setDatabasePath(const std::string& path);
58  inline const std::string& getDatabasePath() const { return _databasePath; }
59 
60  void setFileName(unsigned int childNo, const std::string& filename) { expandFileNameListTo(childNo); _filenameList[childNo].first=filename; }
61  const std::string& getFileName(unsigned int childNo) const { return _filenameList[childNo].first; }
62  unsigned int getNumFileNames() const { return _filenameList.size(); }
63 
68  osg::ref_ptr<osg::Referenced>& getDatabaseRequest(unsigned int childNo) { return _filenameList[childNo].second; }
69 
71  const osg::ref_ptr<osg::Referenced>& getDatabaseRequest(unsigned int childNo) const { return _filenameList[childNo].second; }
72 
73 
76  {
79  UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED
80  };
81 
83  void setCenterMode(CenterMode mode) { _centerMode=mode; }
84 
86  CenterMode getCenterMode() const { return _centerMode; }
87 
90  {
93  NO_AUTOMATIC_LOADING
94  };
95 
97  void setLoadingExternalReferenceMode(LoadingExternalReferenceMode mode) { _loadingExtReference=mode; }
98 
100  LoadingExternalReferenceMode getLoadingExternalReferenceMode() const { return _loadingExtReference; }
101 
104  inline void setCenter(const vec_type& center) { if (_centerMode!=UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED) { _centerMode=USER_DEFINED_CENTER; } _userDefinedCenter = center; }
105 
107  inline const vec_type& getCenter() const { if ((_centerMode==USER_DEFINED_CENTER)||(_centerMode==UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED)) return _userDefinedCenter; else return getBound().center(); }
108 
109 
112  inline void setRadius(value_type radius) { _radius = radius; }
113 
115  inline value_type getRadius() const { return _radius; }
116 
117  virtual BoundingSphere computeBound() const;
118 
119  protected :
120 
121  virtual ~ProxyNode() {}
122 
123  void expandFileNameListTo(unsigned int pos);
124 
125  typedef std::pair< std::string, osg::ref_ptr<osg::Referenced> > FileNameDatabaseRequestPair;
126  typedef std::vector<FileNameDatabaseRequestPair> FileNameDatabaseRequestList;
127 
128  FileNameDatabaseRequestList _filenameList;
130  std::string _databasePath;
131 
133 
136  value_type _radius;
137 
138 };
139 
140 }
141 
142 #endif
#define OSG_EXPORT
Definition: Export.h:43
vec_type _userDefinedCenter
Definition: ProxyNode.h:135
std::string _databasePath
Definition: ProxyNode.h:130
value_type getRadius() const
Definition: ProxyNode.h:115
void setCenter(const vec_type &center)
Definition: ProxyNode.h:104
osg::Referenced * getDatabaseOptions()
Definition: ProxyNode.h:49
const std::string & getFileName(unsigned int childNo) const
Definition: ProxyNode.h:61
CenterMode _centerMode
Definition: ProxyNode.h:134
unsigned int getNumFileNames() const
Definition: ProxyNode.h:62
void setCenterMode(CenterMode mode)
Definition: ProxyNode.h:83
void setFileName(unsigned int childNo, const std::string &filename)
Definition: ProxyNode.h:60
#define META_Node(library, name)
Definition: Node.h:59
LoadingExternalReferenceMode
Definition: ProxyNode.h:89
void setRadius(value_type radius)
Definition: ProxyNode.h:112
CenterMode getCenterMode() const
Definition: ProxyNode.h:86
virtual ~ProxyNode()
Definition: ProxyNode.h:121
LoadingExternalReferenceMode getLoadingExternalReferenceMode() const
Definition: ProxyNode.h:100
const osg::Referenced * getDatabaseOptions() const
Definition: ProxyNode.h:52
std::pair< std::string, osg::ref_ptr< osg::Referenced > > FileNameDatabaseRequestPair
Definition: ProxyNode.h:125
value_type _radius
Definition: ProxyNode.h:136
VT::value_type value_type
const vec_type & getCenter() const
Definition: ProxyNode.h:107
osg::BoundingSphere::vec_type vec_type
Definition: ProxyNode.h:34
LoadingExternalReferenceMode _loadingExtReference
Definition: ProxyNode.h:132
void setLoadingExternalReferenceMode(LoadingExternalReferenceMode mode)
Definition: ProxyNode.h:97
Definition: Node.h:71
Definition: AlphaFunc.h:19
FileNameDatabaseRequestList _filenameList
Definition: ProxyNode.h:128
const std::string & getDatabasePath() const
Definition: ProxyNode.h:58
osg::BoundingSphere::value_type value_type
Definition: ProxyNode.h:35
const osg::ref_ptr< osg::Referenced > & getDatabaseRequest(unsigned int childNo) const
Definition: ProxyNode.h:71
void setDatabaseOptions(osg::Referenced *options)
Definition: ProxyNode.h:46
std::vector< FileNameDatabaseRequestPair > FileNameDatabaseRequestList
Definition: ProxyNode.h:126
ref_ptr< Referenced > _databaseOptions
Definition: ProxyNode.h:129
osg::ref_ptr< osg::Referenced > & getDatabaseRequest(unsigned int childNo)
Definition: ProxyNode.h:68