Skip to content

Commit

Permalink
From David Callu, "osgManipulator Object have not META_Object macro c…
Browse files Browse the repository at this point in the history
…all in class definition.

> I add META_OSGMANIPULATOR_Object macro which define className, libraryName,
> isSameKindAs methods.
> Clone method is not appropriate for osgManipulator Object."
  • Loading branch information
robertosfield committed Mar 11, 2009
1 parent c58ff9b commit 31608b2
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 32 deletions.
36 changes: 20 additions & 16 deletions include/osgManipulator/Dragger
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand All @@ -84,7 +84,7 @@ class OSGMANIPULATOR_EXPORT PointerInfo

void setCamera(osg::Camera* camera)
{

if (camera)
{
_MVPW = camera->getViewMatrix() * camera->getProjectionMatrix();
Expand Down Expand Up @@ -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:
Expand All @@ -123,7 +123,7 @@ class OSGMANIPULATOR_EXPORT PointerInfo
IntersectionList::const_iterator _hitIter;

protected:

osg::Vec3d _nearPoint,_farPoint;
osg::Vec3d _eyeDir;

Expand All @@ -134,15 +134,17 @@ 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.
*/
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; }
Expand Down Expand Up @@ -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; }

Expand All @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion include/osgManipulator/RotateCylinderDragger
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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();
Expand Down
4 changes: 3 additions & 1 deletion include/osgManipulator/RotateSphereDragger
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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.
*/
Expand Down
10 changes: 6 additions & 4 deletions include/osgManipulator/Scale1DDragger
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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; }
Expand All @@ -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();
Expand Down
8 changes: 5 additions & 3 deletions include/osgManipulator/Scale2DDragger
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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.
Expand All @@ -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; }
Expand Down
2 changes: 2 additions & 0 deletions include/osgManipulator/ScaleAxisDragger
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class OSGMANIPULATOR_EXPORT ScaleAxisDragger : public CompositeDragger

ScaleAxisDragger();

META_OSGMANIPULATOR_Object(osgManipulator,ScaleAxisDragger)

/** Setup default geometry for dragger. */
void setupDefaultGeometry();

Expand Down
13 changes: 11 additions & 2 deletions include/osgManipulator/Selection
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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&);
Expand Down
4 changes: 3 additions & 1 deletion include/osgManipulator/TabBoxDragger
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,6 +29,8 @@ class OSGMANIPULATOR_EXPORT TabBoxDragger : public CompositeDragger

TabBoxDragger();

META_OSGMANIPULATOR_Object(osgManipulator,TabBoxDragger)

/** Setup default geometry for dragger. */
void setupDefaultGeometry();

Expand Down
4 changes: 3 additions & 1 deletion include/osgManipulator/TabPlaneDragger
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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. */
Expand Down
2 changes: 2 additions & 0 deletions include/osgManipulator/TabPlaneTrackballDragger
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class OSGMANIPULATOR_EXPORT TabPlaneTrackballDragger : public CompositeDragger

TabPlaneTrackballDragger();

META_OSGMANIPULATOR_Object(osgManipulator,TabPlaneTrackballDragger)

/** Setup default geometry for dragger. */
void setupDefaultGeometry();

Expand Down
2 changes: 2 additions & 0 deletions include/osgManipulator/TrackballDragger
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
4 changes: 3 additions & 1 deletion include/osgManipulator/Translate1DDragger
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand All @@ -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; }
Expand Down
4 changes: 3 additions & 1 deletion include/osgManipulator/Translate2DDragger
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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; }
Expand Down
2 changes: 2 additions & 0 deletions include/osgManipulator/TranslateAxisDragger
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class OSGMANIPULATOR_EXPORT TranslateAxisDragger : public CompositeDragger

TranslateAxisDragger();

META_OSGMANIPULATOR_Object(osgManipulator,TranslateAxisDragger)

/** Setup default geometry for dragger. */
void setupDefaultGeometry();

Expand Down
4 changes: 3 additions & 1 deletion include/osgManipulator/TranslatePlaneDragger
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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. */
Expand Down

0 comments on commit 31608b2

Please sign in to comment.