Introduce NodeVisitor::className and libraryName()

This commit is contained in:
Robert Osfield
2008-12-17 12:13:15 +00:00
parent a5c32da4ff
commit 8a6e04b84d
27 changed files with 90 additions and 52 deletions

View File

@@ -31,6 +31,8 @@ class OSG_EXPORT CollectOccludersVisitor : public osg::NodeVisitor, public osg::
CollectOccludersVisitor();
virtual ~CollectOccludersVisitor();
META_NodeVisitor("osg","CollectOccludersVisitor")
virtual CollectOccludersVisitor* cloneType() const { return new CollectOccludersVisitor(); }
virtual void reset();

View File

@@ -26,6 +26,8 @@ public:
ComputeBoundsVisitor(TraversalMode traversalMode = TRAVERSE_ALL_CHILDREN);
META_NodeVisitor("osg","ComputeBoundsVisitor")
virtual void reset();
osg::BoundingBox& getBoundingBox() { return _bb; }

View File

@@ -175,6 +175,8 @@ class OSG_EXPORT KdTreeBuilder : public osg::NodeVisitor
KdTreeBuilder(const KdTreeBuilder& rhs);
META_NodeVisitor("osg","KdTreeBuilder")
virtual KdTreeBuilder* clone() { return new KdTreeBuilder(*this); }
void apply(osg::Geode& geode);

View File

@@ -42,6 +42,10 @@ class Transform;
class Camera;
class CameraView;
#define META_NodeVisitor(library,name) \
virtual const char* libraryName() const { return #library; }\
virtual const char* className() const { return #name; }
/** Visitor for type safe operations on osg::Nodes.
Based on GOF's Visitor pattern. The NodeVisitor
is useful for developing type safe operations to nodes
@@ -82,6 +86,12 @@ class OSG_EXPORT NodeVisitor : public virtual Referenced
NodeVisitor(VisitorType type,TraversalMode tm=TRAVERSE_NONE);
virtual ~NodeVisitor();
/** return the library name/namespapce of the visitor's. Should be defined by derived classes.*/
virtual const char* libraryName() const { return "osg"; }
/** return the name of the visitor's class type. Should be defined by derived classes.*/
virtual const char* className() const { return "NodeVisitor"; }
/** Method to call to reset visitor. Useful if your visitor accumulates
state during a traversal, and you plan to reuse the visitor.

View File

@@ -56,6 +56,8 @@ namespace osgAnimation
BoneMap _map;
BoneMapVisitor(): osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {}
META_NodeVisitor("osgAnimation","BoneMapVisitor")
void apply(osg::Node& node) { return; }
void apply(osg::Transform& node)
{

View File

@@ -26,8 +26,12 @@ namespace osgAnimation
{
AnimationList _animations;
unsigned int _nbLinkedTarget;
LinkVisitor(Animation* animation) : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) { _animations.push_back(animation); _nbLinkedTarget = 0;}
LinkVisitor(const AnimationList& animations) : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) { _animations = animations; _nbLinkedTarget = 0;}
META_NodeVisitor("osgAnimation","LinkVisitor")
void apply(osg::Node& node)
{
osgAnimation::AnimationUpdateCallback* cb = dynamic_cast<osgAnimation::AnimationUpdateCallback*>(node.getUpdateCallback());

View File

@@ -77,6 +77,9 @@ namespace osgAnimation
{
osg::ref_ptr<Skeleton> _root;
BuildVertexTransformerVisitor(Skeleton* root): osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) { _root = root;}
META_NodeVisitor("osgAnimation","BuildVertexTransformerVisitor")
void apply(osg::Geode& node)
{
int num = node.getNumDrawables();

View File

@@ -48,6 +48,8 @@ namespace osgDB {
SharedStateManager(unsigned int mode = SHARE_ALL);
META_NodeVisitor("osgDB","SharedStateManager")
void setShareMode(unsigned int mode);
unsigned int getShareMode() { return _shareMode; }

View File

@@ -43,6 +43,7 @@ class OSGGA_EXPORT EventVisitor : public osg::NodeVisitor
EventVisitor();
virtual ~EventVisitor();
META_NodeVisitor("osgGA","EventVisitor")
void setActionAdapter(osgGA::GUIActionAdapter* actionAdapter) { _actionAdapter=actionAdapter; }

View File

@@ -29,6 +29,8 @@ class OSGSIM_EXPORT InsertImpostorsVisitor : public osg::NodeVisitor
/** Default to traversing all children. */
InsertImpostorsVisitor();
META_NodeVisitor("osgSim","InsertImpostorsVisitor")
void setImpostorThresholdRatio(float ratio) { _impostorThresholdRatio = ratio; }
float getImpostorThresholdRatio() const { return _impostorThresholdRatio; }

View File

@@ -57,6 +57,8 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac
/// Copy constructor that does a shallow copy.
CullVisitor(const CullVisitor&);
META_NodeVisitor("osgUtil","CullVisitor")
/** Create a shallow copy of the CullVisitor, used by CullVisitor::create() to clone the prototype. */
virtual CullVisitor* clone() const { return new CullVisitor(*this); }

View File

@@ -36,6 +36,7 @@ class OSGUTIL_EXPORT DisplayRequirementsVisitor : public osg::NodeVisitor
* alpha and stencil off.*/
DisplayRequirementsVisitor();
META_NodeVisitor("osgUtil","DisplayRequirementsVisitor")
/** Set the DisplaySettings. */
inline void setDisplaySettings(osg::DisplaySettings* ds) { _ds = ds; }

View File

@@ -32,6 +32,8 @@ class OSGUTIL_EXPORT DrawElementTypeSimplifierVisitor : public osg::NodeVisitor
{
public:
META_NodeVisitor("osgUtil","DrawElementTypeSimplifierVisitor")
void apply(osg::Geode& node);
};

View File

@@ -51,9 +51,10 @@ class OSGUTIL_EXPORT GLObjectsVisitor : public osg::NodeVisitor
* display list/texture objects etc. Default mode is to compile
* GL objects.
*/
GLObjectsVisitor(Mode mode=COMPILE_DISPLAY_LISTS|COMPILE_STATE_ATTRIBUTES|CHECK_BLACK_LISTED_MODES);
GLObjectsVisitor(Mode mode=COMPILE_DISPLAY_LISTS|COMPILE_STATE_ATTRIBUTES|CHECK_BLACK_LISTED_MODES);
META_NodeVisitor("osg","GLObjectsVisitor")
virtual void reset()
{
_drawablesAppliedSet.clear();

View File

@@ -102,6 +102,8 @@ class OSGUTIL_EXPORT IntersectVisitor : public osg::NodeVisitor
IntersectVisitor();
virtual ~IntersectVisitor();
META_NodeVisitor("osgUtil","IntersectVisitor")
void reset();
/** Add a line segment to use for intersection testing during scene traversal.

View File

@@ -137,6 +137,8 @@ class OSGUTIL_EXPORT IntersectionVisitor : public osg::NodeVisitor
IntersectionVisitor(Intersector* intersector=0, ReadCallback* readCallback=0);
META_NodeVisitor("osgUtil","IntersectionVisitor")
virtual void reset();

View File

@@ -30,6 +30,7 @@ class OSGUTIL_EXPORT Simplifier : public osg::NodeVisitor
Simplifier(double sampleRatio=1.0, double maximumError=FLT_MAX, double maximumLength=0.0);
META_NodeVisitor("osgUtil","Simplifier")
void setSampleRatio(float sampleRatio) { _sampleRatio = sampleRatio; }
float getSampleRatio() const { return _sampleRatio; }

View File

@@ -167,6 +167,8 @@ public:
StatsVisitor();
META_NodeVisitor("osgUtil","StatsVisitor")
void reset();
void apply(osg::Node& node);

View File

@@ -41,9 +41,11 @@ class OSGUTIL_EXPORT UpdateVisitor : public osg::NodeVisitor
UpdateVisitor();
virtual ~UpdateVisitor();
META_NodeVisitor("osgUtil","UpdateVisitor")
virtual void reset();
/** During traversal each type of node calls its callbacks and its children traversed. */
/** During traversal each type of node calls its callbacks and its children traversed. */
virtual void apply(osg::Node& node) { handle_callbacks_and_traverse(node); }
virtual void apply(osg::Geode& node) { handle_geode_callbacks(node); }