openscenegraph
ProxyNode
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
19namespace osg {
20
24{
25 public :
26
28
30 ProxyNode(const ProxyNode&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
31
33
36
37 virtual void traverse(NodeVisitor& nv);
38
40
41 virtual bool addChild(Node *child);
42
43 virtual bool addChild(Node *child, const std::string& filename);
44
45 template<class T> bool addChild( const ref_ptr<T>& child, const std::string& filename) { return addChild(child.get(), filename); }
46
47 virtual bool removeChildren(unsigned int pos,unsigned int numChildrenToRemove);
48
49
51 void setDatabaseOptions(osg::Referenced* options) { _databaseOptions = options; }
52
54 osg::Referenced* getDatabaseOptions() { return _databaseOptions.get(); }
55
57 const osg::Referenced* getDatabaseOptions() const { return _databaseOptions.get(); }
58
59
61 void setDatabasePath(const std::string& path);
63 inline const std::string& getDatabasePath() const { return _databasePath; }
64
65 void setFileName(unsigned int childNo, const std::string& filename) { expandFileNameListTo(childNo); _filenameList[childNo].first=filename; }
66 const std::string& getFileName(unsigned int childNo) const { return _filenameList[childNo].first; }
67 unsigned int getNumFileNames() const { return _filenameList.size(); }
68
73 osg::ref_ptr<osg::Referenced>& getDatabaseRequest(unsigned int childNo) { return _filenameList[childNo].second; }
74
76 const osg::ref_ptr<osg::Referenced>& getDatabaseRequest(unsigned int childNo) const { return _filenameList[childNo].second; }
77
78
81 {
84 UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED
85 };
86
88 void setCenterMode(CenterMode mode) { _centerMode=mode; }
89
91 CenterMode getCenterMode() const { return _centerMode; }
92
100
102 void setLoadingExternalReferenceMode(LoadingExternalReferenceMode mode) { _loadingExtReference=mode; }
103
105 LoadingExternalReferenceMode getLoadingExternalReferenceMode() const { return _loadingExtReference; }
106
109 inline void setCenter(const vec_type& center) { if (_centerMode!=UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED) { _centerMode=USER_DEFINED_CENTER; } _userDefinedCenter = center; }
110
112 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(); }
113
114
117 inline void setRadius(value_type radius) { _radius = radius; }
118
120 inline value_type getRadius() const { return _radius; }
121
123
124 protected :
125
126 virtual ~ProxyNode() {}
127
128 void expandFileNameListTo(unsigned int pos);
129
130 typedef std::pair< std::string, osg::ref_ptr<osg::Referenced> > FileNameDatabaseRequestPair;
131 typedef std::vector<FileNameDatabaseRequestPair> FileNameDatabaseRequestList;
132
135 std::string _databasePath;
136
138
142
143};
144
145}
146
147#endif
Definition BoundingSphere:35
VT vec_type
Definition BoundingSphere:37
VT::value_type value_type
Definition BoundingSphere:38
Definition CopyOp:41
Definition Group:29
virtual bool addChild(Node *child)
Definition NodeVisitor:82
Definition Node:72
Definition ProxyNode:24
bool addChild(const ref_ptr< T > &child, const std::string &filename)
Definition ProxyNode:45
const std::string & getFileName(unsigned int childNo) const
Definition ProxyNode:66
vec_type _userDefinedCenter
Definition ProxyNode:140
LoadingExternalReferenceMode
Definition ProxyNode:95
@ DEFER_LOADING_TO_DATABASE_PAGER
Definition ProxyNode:97
@ LOAD_IMMEDIATELY
Definition ProxyNode:96
virtual void traverse(NodeVisitor &nv)
void setLoadingExternalReferenceMode(LoadingExternalReferenceMode mode)
Definition ProxyNode:102
CenterMode _centerMode
Definition ProxyNode:139
const vec_type & getCenter() const
Definition ProxyNode:112
unsigned int getNumFileNames() const
Definition ProxyNode:67
ProxyNode(const ProxyNode &, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
void setCenter(const vec_type &center)
Definition ProxyNode:109
value_type _radius
Definition ProxyNode:141
virtual BoundingSphere computeBound() const
void setDatabaseOptions(osg::Referenced *options)
Definition ProxyNode:51
void expandFileNameListTo(unsigned int pos)
void setDatabasePath(const std::string &path)
osg::BoundingSphere::vec_type vec_type
Definition ProxyNode:34
CenterMode getCenterMode() const
Definition ProxyNode:91
const std::string & getDatabasePath() const
Definition ProxyNode:63
virtual ~ProxyNode()
Definition ProxyNode:126
virtual bool addChild(Node *child)
LoadingExternalReferenceMode getLoadingExternalReferenceMode() const
Definition ProxyNode:105
FileNameDatabaseRequestList _filenameList
Definition ProxyNode:133
ref_ptr< Referenced > _databaseOptions
Definition ProxyNode:134
osg::ref_ptr< osg::Referenced > & getDatabaseRequest(unsigned int childNo)
Definition ProxyNode:73
virtual bool removeChildren(unsigned int pos, unsigned int numChildrenToRemove)
virtual bool addChild(Node *child, const std::string &filename)
const osg::Referenced * getDatabaseOptions() const
Definition ProxyNode:57
std::pair< std::string, osg::ref_ptr< osg::Referenced > > FileNameDatabaseRequestPair
Definition ProxyNode:130
CenterMode
Definition ProxyNode:81
@ USE_BOUNDING_SPHERE_CENTER
Definition ProxyNode:82
@ USER_DEFINED_CENTER
Definition ProxyNode:83
LoadingExternalReferenceMode _loadingExtReference
Definition ProxyNode:137
osg::Referenced * getDatabaseOptions()
Definition ProxyNode:54
void setFileName(unsigned int childNo, const std::string &filename)
Definition ProxyNode:65
const osg::ref_ptr< osg::Referenced > & getDatabaseRequest(unsigned int childNo) const
Definition ProxyNode:76
META_Node(osg, ProxyNode)
void setCenterMode(CenterMode mode)
Definition ProxyNode:88
value_type getRadius() const
Definition ProxyNode:120
std::string _databasePath
Definition ProxyNode:135
void setRadius(value_type radius)
Definition ProxyNode:117
osg::BoundingSphere::value_type value_type
Definition ProxyNode:35
std::vector< FileNameDatabaseRequestPair > FileNameDatabaseRequestList
Definition ProxyNode:131
Definition Referenced:44
Definition ref_ptr:32
T * get() const
Definition ref_ptr:117
author: Julien Valentin 2017 (mp3butcher@hotmail.com)
Definition AlphaFunc:19
#define OSG_EXPORT
Definition osg/Export:39