diff --git a/include/osgManipulator/Dragger b/include/osgManipulator/Dragger index de20de420..696db3c74 100644 --- a/include/osgManipulator/Dragger +++ b/include/osgManipulator/Dragger @@ -45,15 +45,34 @@ class OSGMANIPULATOR_EXPORT DraggerTransformCallback : public DraggerCallback { public: - DraggerTransformCallback(osg::MatrixTransform* transform); + enum HandleCommandMask + { + HANDLE_TRANSLATE_IN_LINE = 1<<0, + HANDLE_TRANSLATE_IN_PLANE = 1<<1, + HANDLE_SCALED_1D = 1<<2, + HANDLE_SCALED_2D = 1<<3, + HANDLE_SCALED_UNIFORM = 1<<4, + HANDLE_ROTATE_3D = 1<<5, + HANDLE_ALL = 0x8ffffff + }; + + DraggerTransformCallback(osg::MatrixTransform* transform, int handleCommandMask = HANDLE_ALL); virtual bool receive(const MotionCommand&); + virtual bool receive(const TranslateInLineCommand& command); + virtual bool receive(const TranslateInPlaneCommand& command); + virtual bool receive(const Scale1DCommand& command); + virtual bool receive(const Scale2DCommand& command); + virtual bool receive(const ScaleUniformCommand& command); + virtual bool receive(const Rotate3DCommand& command); osg::MatrixTransform* getTransform() { return _transform.get(); } const osg::MatrixTransform* getTransform() const { return _transform.get(); } protected: + unsigned int _handleCommandMask; + osg::observer_ptr _transform; osg::Matrix _startMotionMatrix; @@ -228,7 +247,7 @@ class OSGMANIPULATOR_EXPORT Dragger : public osg::MatrixTransform DraggerCallbacks& getDraggerCallbacks() { return _draggerCallbacks; } const DraggerCallbacks& getDraggerCallbacks() const { return _draggerCallbacks; } - void addTransformUpdating(MatrixTransform* transform); + void addTransformUpdating(MatrixTransform* transform, int handleCommandMask = DraggerTransformCallback::HANDLE_ALL); void removeTransformUpdating(MatrixTransform* transform); /** Setup default geometry for dragger. */ diff --git a/src/osgManipulator/Dragger.cpp b/src/osgManipulator/Dragger.cpp index bb374f1e9..ae3385843 100644 --- a/src/osgManipulator/Dragger.cpp +++ b/src/osgManipulator/Dragger.cpp @@ -45,7 +45,8 @@ void osgManipulator::computeNodePathToRoot(osg::Node& node, osg::NodePath& np) // // DraggerTransformCallback // -DraggerTransformCallback::DraggerTransformCallback(osg::MatrixTransform* transform): +DraggerTransformCallback::DraggerTransformCallback(osg::MatrixTransform* transform,int handleCommandMask): + _handleCommandMask(handleCommandMask), _transform(transform) { } @@ -93,6 +94,42 @@ bool DraggerTransformCallback::receive(const MotionCommand& command) } } +bool DraggerTransformCallback::receive(const TranslateInLineCommand& command) +{ + if ((_handleCommandMask&HANDLE_TRANSLATE_IN_LINE)!=0) return receive(static_cast(command)); + return false; +} + +bool DraggerTransformCallback::receive(const TranslateInPlaneCommand& command) +{ + if ((_handleCommandMask&HANDLE_TRANSLATE_IN_PLANE)!=0) return receive(static_cast(command)); + return false; +} + +bool DraggerTransformCallback::receive(const Scale1DCommand& command) +{ + if ((_handleCommandMask&HANDLE_SCALED_1D)!=0) return receive(static_cast(command)); + return false; +} + +bool DraggerTransformCallback::receive(const Scale2DCommand& command) +{ + if ((_handleCommandMask&HANDLE_SCALED_2D)!=0) return receive(static_cast(command)); + return false; +} + +bool DraggerTransformCallback::receive(const ScaleUniformCommand& command) +{ + if ((_handleCommandMask&HANDLE_SCALED_UNIFORM)!=0) return receive(static_cast(command)); + return false; +} + +bool DraggerTransformCallback::receive(const Rotate3DCommand& command) +{ + if ((_handleCommandMask&HANDLE_ROTATE_3D)!=0) return receive(static_cast(command)); + return false; +} + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // @@ -199,9 +236,9 @@ void Dragger::removeConstraint(Constraint* constraint) } } -void Dragger::addTransformUpdating(osg::MatrixTransform* transform) +void Dragger::addTransformUpdating(osg::MatrixTransform* transform, int handleCommandMask) { - addDraggerCallback(new DraggerTransformCallback(transform)); + addDraggerCallback(new DraggerTransformCallback(transform, handleCommandMask)); } void Dragger::removeTransformUpdating(osg::MatrixTransform* transform)