From David Callu, "osgManipulator Object have not META_Object macro call in class definition.

> I add META_OSGMANIPULATOR_Object macro which define className, libraryName,
> isSameKindAs methods.
> Clone method is not appropriate for osgManipulator Object."
This commit is contained in:
Robert Osfield 2009-03-11 11:29:00 +00:00
parent c58ff9b656
commit 31608b2559
15 changed files with 71 additions and 32 deletions

View File

@ -48,13 +48,13 @@ class OSGMANIPULATOR_EXPORT PointerInfo
{
_hitList.clear();
_hitIter = _hitList.begin();
setCamera(0);
setCamera(0);
}
bool completed() const { return _hitIter==_hitList.end(); }
void next()
void next()
{
if (!completed()) ++_hitIter;
}
@ -66,15 +66,15 @@ class OSGMANIPULATOR_EXPORT PointerInfo
osg::Vec3d getLocalIntersectPoint() const { return _hitIter->second; }
void setNearFarPoints (osg::Vec3d nearPoint, osg::Vec3d farPoint) {
_nearPoint = nearPoint;
_farPoint=farPoint;
_eyeDir = farPoint - nearPoint;
}
const osg::Vec3d& getEyeDir() const {return _eyeDir;}
void getNearFarPoints( osg::Vec3d& nearPoint, osg::Vec3d& farPoint) const {
nearPoint = _nearPoint;
farPoint = _farPoint;
@ -84,7 +84,7 @@ class OSGMANIPULATOR_EXPORT PointerInfo
void setCamera(osg::Camera* camera)
{
if (camera)
{
_MVPW = camera->getViewMatrix() * camera->getProjectionMatrix();
@ -112,7 +112,7 @@ class OSGMANIPULATOR_EXPORT PointerInfo
}
void setMousePosition(float pixel_x, float pixel_y)
{
{
projectWindowXYIntoObject(osg::Vec2d(pixel_x, pixel_y), _nearPoint, _farPoint);
}
protected:
@ -123,7 +123,7 @@ class OSGMANIPULATOR_EXPORT PointerInfo
IntersectionList::const_iterator _hitIter;
protected:
osg::Vec3d _nearPoint,_farPoint;
osg::Vec3d _eyeDir;
@ -134,8 +134,8 @@ class OSGMANIPULATOR_EXPORT PointerInfo
/**
* Base class for draggers. Concrete draggers implement the pick event handler
* and generate motion commands (translate, rotate, ...) and sends these
* command to the CommandManager. The CommandManager dispatches the commands
* and generate motion commands (translate, rotate, ...) and sends these
* command to the CommandManager. The CommandManager dispatches the commands
* to all the Selections that are connected to the Dragger that generates the
* commands.
*/
@ -143,6 +143,8 @@ class OSGMANIPULATOR_EXPORT Dragger : public Selection
{
public:
META_OSGMANIPULATOR_Object(osgManipulator,Dragger)
/** Set/Get the CommandManager. Draggers use CommandManager to dispatch commands. */
virtual void setCommandManager(CommandManager* cm) { _commandManager = cm; }
CommandManager* getCommandManager() { return _commandManager; }
@ -170,24 +172,26 @@ class OSGMANIPULATOR_EXPORT Dragger : public Selection
Dragger();
virtual ~Dragger();
CommandManager* _commandManager;
Dragger* _parentDragger;
};
/**
* CompositeDragger allows to create complex draggers that are composed of a
* CompositeDragger allows to create complex draggers that are composed of a
* hierarchy of Draggers.
*/
class OSGMANIPULATOR_EXPORT CompositeDragger : public Dragger
{
public:
META_OSGMANIPULATOR_Object(osgManipulator,CompositeDragger)
typedef std::vector< osg::ref_ptr<Dragger> > DraggerList;
virtual const CompositeDragger* getComposite() const { return this; }
virtual CompositeDragger* getComposite() { return this; }
@ -210,14 +214,14 @@ class OSGMANIPULATOR_EXPORT CompositeDragger : public Dragger
CompositeDragger() {}
virtual ~CompositeDragger() {}
DraggerList _draggerList;
};
/**
* Culls the drawable all the time. Used by draggers to have invisible geometry
* around lines and points so that they can be picked. For example, a dragger
* could have a line with an invisible cylinder around it to enable picking on
* could have a line with an invisible cylinder around it to enable picking on
* that line.
*/
void OSGMANIPULATOR_EXPORT setDrawableToAlwaysCull(osg::Drawable& drawable);

View File

@ -29,6 +29,8 @@ class OSGMANIPULATOR_EXPORT RotateCylinderDragger : public Dragger
RotateCylinderDragger();
META_OSGMANIPULATOR_Object(osgManipulator,RotateCylinderDragger)
/**
* Handle pick events on dragger and generate TranslateInLine commands.
*/
@ -49,7 +51,7 @@ class OSGMANIPULATOR_EXPORT RotateCylinderDragger : public Dragger
inline void setPickColor(const osg::Vec4& color) { _pickColor = color; }
inline const osg::Vec4 getPickColor() const { return _pickColor; }
protected:
virtual ~RotateCylinderDragger();

View File

@ -29,6 +29,8 @@ class OSGMANIPULATOR_EXPORT RotateSphereDragger : public Dragger
RotateSphereDragger();
META_OSGMANIPULATOR_Object(osgManipulator,RotateSphereDragger)
/**
* Handle pick events on dragger and generate TranslateInLine commands.
*/
@ -42,7 +44,7 @@ class OSGMANIPULATOR_EXPORT RotateSphereDragger : public Dragger
inline const osg::Vec4 getColor() const { return _color; }
/**
* Set/Get pick color for dragger. Pick color is color of the dragger
* Set/Get pick color for dragger. Pick color is color of the dragger
* when picked. It gives a visual feedback to show that the dragger has
* been picked.
*/

View File

@ -32,9 +32,11 @@ class OSGMANIPULATOR_EXPORT Scale1DDragger : public Dragger
SCALE_WITH_ORIGIN_AS_PIVOT = 0,
SCALE_WITH_OPPOSITE_HANDLE_AS_PIVOT
};
Scale1DDragger(ScaleMode scaleMode=SCALE_WITH_ORIGIN_AS_PIVOT);
META_OSGMANIPULATOR_Object(osgManipulator,Scale1DDragger)
/**
* Handle pick events on dragger and generate TranslateInLine commands.
*/
@ -53,8 +55,8 @@ class OSGMANIPULATOR_EXPORT Scale1DDragger : public Dragger
/**
* Set/Get pick color for dragger. Pick color is color of the dragger
* when picked. It gives a visual feedback to show that the dragger has
* been picked.
* when picked. It gives a visual feedback to show that the dragger has
* been picked.
*/
inline void setPickColor(const osg::Vec4& color) { _pickColor = color; }
inline const osg::Vec4 getPickColor() const { return _pickColor; }
@ -70,7 +72,7 @@ class OSGMANIPULATOR_EXPORT Scale1DDragger : public Dragger
inline double getLeftHandlePosition() const { return _projector->getLineStart()[0]; }
inline void setRightHandlePosition(double pos) { _projector->getLineEnd() = osg::Vec3d(pos,0.0,0.0); }
inline double getRightHandlePosition() { return _projector->getLineEnd()[0]; }
protected:
virtual ~Scale1DDragger();

View File

@ -32,9 +32,11 @@ class OSGMANIPULATOR_EXPORT Scale2DDragger : public Dragger
SCALE_WITH_ORIGIN_AS_PIVOT = 0,
SCALE_WITH_OPPOSITE_HANDLE_AS_PIVOT
};
Scale2DDragger(ScaleMode scaleMode=SCALE_WITH_ORIGIN_AS_PIVOT);
META_OSGMANIPULATOR_Object(osgManipulator,Scale2DDragger)
/**
* Handle pick events on dragger and generate TranslateInLine commands.
*/
@ -51,7 +53,7 @@ class OSGMANIPULATOR_EXPORT Scale2DDragger : public Dragger
inline void setColor(const osg::Vec4& color) { _color = color; setMaterialColor(_color,*this); }
inline const osg::Vec4 getColor() const { return _color; }
/**
/**
* Set/Get pick color for dragger. Pick color is color of the dragger
* when picked. It gives a visual feedback to show that the dragger has
* been picked.
@ -68,7 +70,7 @@ class OSGMANIPULATOR_EXPORT Scale2DDragger : public Dragger
inline osg::Node* getTopRightHandleNode() { return _topRightHandleNode.get(); }
inline void setBottomRightHandleNode(osg::Node& node) { _bottomRightHandleNode = &node; }
inline osg::Node* getBottomRightHandleNode() { return _bottomRightHandleNode.get(); }
/** Set/Get the handle nodes postion for dragger. */
inline void setTopLeftHandlePosition(const osg::Vec2d& pos) { _topLeftHandlePosition = pos; }
const osg::Vec2d& getTopLeftHandlePosition() { return _topLeftHandlePosition; }

View File

@ -28,6 +28,8 @@ class OSGMANIPULATOR_EXPORT ScaleAxisDragger : public CompositeDragger
ScaleAxisDragger();
META_OSGMANIPULATOR_Object(osgManipulator,ScaleAxisDragger)
/** Setup default geometry for dragger. */
void setupDefaultGeometry();

View File

@ -31,6 +31,13 @@ class Rotate3DCommand;
/** Computes the nodepath from the given node all the way upto the root. */
extern OSGMANIPULATOR_EXPORT void computeNodePathToRoot(osg::Node& node, osg::NodePath& np);
#define META_OSGMANIPULATOR_Object(library,name) \
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const name *>(obj)!=NULL; } \
virtual const char* libraryName() const { return #library; }\
virtual const char* className() const { return #name; }
/**
* Selection listens to motion commands generated by draggers.
*/
@ -39,9 +46,11 @@ class OSGMANIPULATOR_EXPORT Selection : public osg::MatrixTransform
public:
Selection();
META_OSGMANIPULATOR_Object(osgManipulator,Selection)
/**
* Receive motion commands and set the MatrixTransform accordingly to
* Receive motion commands and set the MatrixTransform accordingly to
* transform selections. Returns true on success.
*/
virtual bool receive(const MotionCommand&);

View File

@ -20,7 +20,7 @@
namespace osgManipulator {
/**
* TabBoxDragger consists of 6 TabPlaneDraggers to form a box dragger that
* TabBoxDragger consists of 6 TabPlaneDraggers to form a box dragger that
* performs translation and scaling.
*/
class OSGMANIPULATOR_EXPORT TabBoxDragger : public CompositeDragger
@ -29,6 +29,8 @@ class OSGMANIPULATOR_EXPORT TabBoxDragger : public CompositeDragger
TabBoxDragger();
META_OSGMANIPULATOR_Object(osgManipulator,TabBoxDragger)
/** Setup default geometry for dragger. */
void setupDefaultGeometry();

View File

@ -22,7 +22,7 @@
namespace osgManipulator {
/**
* Tab plane dragger consists of a plane with tabs on it's corners and edges
* Tab plane dragger consists of a plane with tabs on it's corners and edges
* for scaling. And the plane is used as a 2D translate dragger.
*/
class OSGMANIPULATOR_EXPORT TabPlaneDragger : public CompositeDragger
@ -31,6 +31,8 @@ class OSGMANIPULATOR_EXPORT TabPlaneDragger : public CompositeDragger
TabPlaneDragger();
META_OSGMANIPULATOR_Object(osgManipulator,TabPlaneDragger)
virtual bool handle(const PointerInfo& pi, const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us);
/** Setup default geometry for dragger. */

View File

@ -29,6 +29,8 @@ class OSGMANIPULATOR_EXPORT TabPlaneTrackballDragger : public CompositeDragger
TabPlaneTrackballDragger();
META_OSGMANIPULATOR_Object(osgManipulator,TabPlaneTrackballDragger)
/** Setup default geometry for dragger. */
void setupDefaultGeometry();

View File

@ -29,6 +29,8 @@ class OSGMANIPULATOR_EXPORT TrackballDragger : public CompositeDragger
TrackballDragger(bool useAutoTransform=false);
META_OSGMANIPULATOR_Object(osgManipulator,TrackballDragger)
/** Setup default geometry for dragger. */
void setupDefaultGeometry();

View File

@ -30,6 +30,8 @@ class OSGMANIPULATOR_EXPORT Translate1DDragger : public Dragger
Translate1DDragger();
META_OSGMANIPULATOR_Object(osgManipulator,Translate1DDragger)
Translate1DDragger(const osg::Vec3d& s, const osg::Vec3d& e);
/** Handle pick events on dragger and generate TranslateInLine commands. */
@ -42,7 +44,7 @@ class OSGMANIPULATOR_EXPORT Translate1DDragger : public Dragger
inline void setColor(const osg::Vec4& color) { _color = color; setMaterialColor(_color,*this); }
inline const osg::Vec4 getColor() const { return _color; }
/** Set/Get pick color for dragger. Pick color is color of the dragger when picked.
/** Set/Get pick color for dragger. Pick color is color of the dragger when picked.
It gives a visual feedback to show that the dragger has been picked. */
inline void setPickColor(const osg::Vec4& color) { _pickColor = color; }
inline const osg::Vec4 getPickColor() const { return _pickColor; }

View File

@ -33,6 +33,8 @@ class OSGMANIPULATOR_EXPORT Translate2DDragger : public Dragger
Translate2DDragger(const osg::Plane& plane);
META_OSGMANIPULATOR_Object(osgManipulator,Translate2DDragger)
/** Handle pick events on dragger and generate TranslateInLine commands. */
virtual bool handle(const PointerInfo& pi, const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us);
@ -43,7 +45,7 @@ class OSGMANIPULATOR_EXPORT Translate2DDragger : public Dragger
inline void setColor(const osg::Vec4& color) { _color = color; setMaterialColor(_color,*this); }
inline const osg::Vec4 getColor() const { return _color; }
/** Set/Get pick color for dragger. Pick color is color of the dragger when picked.
/** Set/Get pick color for dragger. Pick color is color of the dragger when picked.
It gives a visual feedback to show that the dragger has been picked. */
inline void setPickColor(const osg::Vec4& color) { _pickColor = color; }
inline const osg::Vec4 getPickColor() const { return _pickColor; }

View File

@ -28,6 +28,8 @@ class OSGMANIPULATOR_EXPORT TranslateAxisDragger : public CompositeDragger
TranslateAxisDragger();
META_OSGMANIPULATOR_Object(osgManipulator,TranslateAxisDragger)
/** Setup default geometry for dragger. */
void setupDefaultGeometry();

View File

@ -21,7 +21,7 @@
namespace osgManipulator {
/**
* Tab plane dragger consists of a plane with tabs on it's corners and edges
* Tab plane dragger consists of a plane with tabs on it's corners and edges
* for scaling. And the plane is used as a 2D translate dragger.
*/
class OSGMANIPULATOR_EXPORT TranslatePlaneDragger : public CompositeDragger
@ -30,6 +30,8 @@ class OSGMANIPULATOR_EXPORT TranslatePlaneDragger : public CompositeDragger
TranslatePlaneDragger();
META_OSGMANIPULATOR_Object(osgManipulator,TranslatePlaneDragger)
virtual bool handle(const PointerInfo& pi, const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us);
/** Setup default geometry for dragger. */