From 2525bb5d06cc33dc1335d9c256acd796435cbfe0 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 1 Jul 2009 14:01:09 +0000 Subject: [PATCH] Completed refactor of osgManipulator, key changes are: Selection is now just a typedef of osg::MatrixTransform, and is deprecated CommandManager is shell class that just sets values directly on Dragger, and is deprecated Dragger now has list of DraggerCallback that takes over the roll of tracking changes to the Dragger, and allows users to track the dragger in any way they wish. Dragger now has a convinience method making MatrixTransforms track a dragger. Selection and CommandManager are no longer required for use of osgManipulator and are kept around for backwards compatibility. --- examples/osgmanipulator/osgmanipulator.cpp | 2 +- include/osgManipulator/Command | 3 +- include/osgManipulator/CommandManager | 52 +++- include/osgManipulator/Dragger | 85 +++++- include/osgManipulator/Export | 6 + include/osgManipulator/Selection | 65 +---- src/osgManipulator/CMakeLists.txt | 2 - src/osgManipulator/Command.cpp | 1 - src/osgManipulator/CommandManager.cpp | 62 ----- src/osgManipulator/Constraint.cpp | 1 + src/osgManipulator/Dragger.cpp | 150 +++++++++-- src/osgManipulator/Selection.cpp | 86 ------- src/osgWrappers/osgManipulator/Command.cpp | 14 +- .../osgManipulator/CommandManager.cpp | 16 +- src/osgWrappers/osgManipulator/Dragger.cpp | 243 ++++++++++++++++-- src/osgWrappers/osgManipulator/Selection.cpp | 102 +------- 16 files changed, 476 insertions(+), 414 deletions(-) delete mode 100644 src/osgManipulator/CommandManager.cpp delete mode 100644 src/osgManipulator/Selection.cpp diff --git a/examples/osgmanipulator/osgmanipulator.cpp b/examples/osgmanipulator/osgmanipulator.cpp index 86efb1ef8..f21c669ff 100644 --- a/examples/osgmanipulator/osgmanipulator.cpp +++ b/examples/osgmanipulator/osgmanipulator.cpp @@ -114,7 +114,7 @@ osg::Node* addDraggerToScene(osg::Node* scene, osgManipulator::CommandManager* c #ifdef USE_COMMAND_MANAGER cmdMgr->connect(*dragger, *selection); #else - dragger->addSelection(selection); + dragger->addTransformUpdating(selection); #endif return root; } diff --git a/include/osgManipulator/Command b/include/osgManipulator/Command index 143b76ccf..2ac6b2f48 100644 --- a/include/osgManipulator/Command +++ b/include/osgManipulator/Command @@ -16,7 +16,6 @@ #define OSGMANIPULATOR_COMMAND 1 #include -#include #include #include @@ -55,7 +54,7 @@ class OSGMANIPULATOR_EXPORT MotionCommand : public osg::Referenced virtual MotionCommand* createCommandInverse() = 0; /** - * Gets the matrix for transforming the Selection. This matrix is in the + * Gets the matrix for transforming the object being dragged. This matrix is in the * command's coordinate systems. */ virtual osg::Matrix getMotionMatrix() const = 0; diff --git a/include/osgManipulator/CommandManager b/include/osgManipulator/CommandManager index e194c1357..872fd3c8b 100644 --- a/include/osgManipulator/CommandManager +++ b/include/osgManipulator/CommandManager @@ -22,29 +22,55 @@ namespace osgManipulator { /** - * Deprecated. CommandManager class is now no longer required as Dragger now matains all references to Constraints and Selections. + * Deprecated. + * CommandManager class is now no longer required as Dragger now matains all references to Constraints and Selections (now just generic MatrixTransforms). + * To replace CommandManager usage simple replace cmdMgr->connect(*dragger, *selection) with dragger->addTransformUpdating(selection) and + * cmdMgr->connect(*dragger, *selection) with dragger->addConstaint(constraint). */ -class OSGMANIPULATOR_EXPORT CommandManager : public osg::Referenced +class CommandManager : public osg::Referenced { public: CommandManager(); - /** - * Connect a dragger to a selection. The selection will begin listening - * to commands generated by the dragger. This can be called multiple - * times to connect many selections to a dragger. - */ - virtual bool connect(Dragger& dragger, Selection& selection); + bool connect(Dragger& dragger, Selection& selection) + { + dragger.addTransformUpdating(&selection); - virtual bool connect(Dragger& dragger, Constraint& constrain); + return true; + } - /** Disconnect the selections from a dragger. */ - virtual bool disconnect(Dragger& dragger); + bool connect(Dragger& dragger, Constraint& constraint) + { + dragger.addConstraint(&constraint); + + return true; + } + + bool disconnect(Dragger& dragger) + { + dragger.getConstraints().clear(); + dragger.getDraggerCallbacks().clear(); + + return true; + } typedef std::list< osg::ref_ptr > Selections; - /** Returns the selections connected to the dragger */ - Selections getConnectedSelections(Dragger& dragger); + Selections getConnectedSelections(Dragger& dragger) + { + Selections selections; + + for(Dragger::DraggerCallbacks::iterator itr = dragger.getDraggerCallbacks().begin(); + itr != dragger.getDraggerCallbacks().end(); + ++itr) + { + DraggerCallback* dc = itr->get(); + DraggerTransformCallback* dtc = dynamic_cast(dc); + if (dtc && dtc->getTransform()) selections.push_back(dtc->getTransform()); + } + + return selections; + } protected: diff --git a/include/osgManipulator/Dragger b/include/osgManipulator/Dragger index e58716328..7e729d382 100644 --- a/include/osgManipulator/Dragger +++ b/include/osgManipulator/Dragger @@ -15,11 +15,11 @@ #ifndef OSGMANIPULATOR_DRAGGER #define OSGMANIPULATOR_DRAGGER 1 -#include #include #include #include +#include #include #include #include @@ -29,6 +29,57 @@ namespace osgManipulator { class CompositeDragger; +class MotionCommand; +class TranslateInLineCommand; +class TranslateInPlaneCommand; +class Scale1DCommand; +class Scale2DCommand; +class ScaleUniformCommand; +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); + +class DraggerCallback : virtual public osg::Object +{ + public: + DraggerCallback() {} + DraggerCallback(const DraggerCallback&, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY) {} + + META_Object(osgManipulator, DraggerCallback); + + /** + * Receive motion commands. Returns true on success. + */ + virtual bool receive(const MotionCommand&) { return false; } + virtual bool receive(const TranslateInLineCommand& command) { return receive((MotionCommand&)command); } + virtual bool receive(const TranslateInPlaneCommand& command) { return receive((MotionCommand&)command); } + virtual bool receive(const Scale1DCommand& command) { return receive((MotionCommand&)command); } + virtual bool receive(const Scale2DCommand& command) { return receive((MotionCommand&)command); } + virtual bool receive(const ScaleUniformCommand& command) { return receive((MotionCommand&)command); } + virtual bool receive(const Rotate3DCommand& command) { return receive((MotionCommand&)command); } +}; + +class OSGMANIPULATOR_EXPORT DraggerTransformCallback : public DraggerCallback +{ + public: + + DraggerTransformCallback(osg::MatrixTransform* transform); + + virtual bool receive(const MotionCommand&); + + osg::MatrixTransform* getTransform() { return _transform.get(); } + const osg::MatrixTransform* getTransform() const { return _transform.get(); } + + protected: + + osg::observer_ptr _transform; + osg::Matrix _startMotionMatrix; + + osg::Matrix _localToWorld; + osg::Matrix _worldToLocal; +}; + class OSGMANIPULATOR_EXPORT PointerInfo { @@ -137,14 +188,15 @@ 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 all the Selections that are connected to the Dragger that generates the + * command to all the DraggerCallbacks & Transforms that are connected to the Dragger that generates the * commands. */ -class OSGMANIPULATOR_EXPORT Dragger : public Selection, public osg::Observer +class OSGMANIPULATOR_EXPORT Dragger : public osg::MatrixTransform { public: - META_OSGMANIPULATOR_Object(osgManipulator,Dragger) + + META_Node(osgManipulator,Dragger) /** * Set/Get parent dragger. For simple draggers parent points to itself. @@ -184,20 +236,26 @@ class OSGMANIPULATOR_EXPORT Dragger : public Selection, public osg::Observer const Constraints& getConstraints() const { return _constraints; } - typedef std::vector< Selection* > Selections; - void addSelection(Selection* selection); - void removeSelection(Selection* selection); + typedef std::vector< osg::ref_ptr > DraggerCallbacks; - Selections& getSelections() { return _selections; } - const Selections& getSelections() const { return _selections; } + void addDraggerCallback(DraggerCallback* dc); + void removeDraggerCallback(DraggerCallback* dc); + + DraggerCallbacks& getDraggerCallbacks() { return _draggerCallbacks; } + const DraggerCallbacks& getDraggerCallbacks() const { return _draggerCallbacks; } + + void addTransformUpdating(MatrixTransform* transform); + void removeTransformUpdating(MatrixTransform* transform); protected: Dragger(); + Dragger(const Dragger& rhs, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY); + virtual ~Dragger(); + virtual bool receive(const MotionCommand& command); void dispatch(MotionCommand& command); - virtual void objectDeleted(void* object); bool _handleEvents; bool _draggerActive; @@ -205,8 +263,9 @@ class OSGMANIPULATOR_EXPORT Dragger : public Selection, public osg::Observer Dragger* _parentDragger; + osg::ref_ptr _selfUpdater; Constraints _constraints; - Selections _selections; + DraggerCallbacks _draggerCallbacks; }; @@ -219,7 +278,7 @@ class OSGMANIPULATOR_EXPORT CompositeDragger : public Dragger { public: - META_OSGMANIPULATOR_Object(osgManipulator,CompositeDragger) + META_Node(osgManipulator,CompositeDragger) typedef std::vector< osg::ref_ptr > DraggerList; @@ -242,6 +301,8 @@ class OSGMANIPULATOR_EXPORT CompositeDragger : public Dragger protected: CompositeDragger() {} + CompositeDragger(const CompositeDragger& rhs, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY); + virtual ~CompositeDragger() {} DraggerList _draggerList; diff --git a/include/osgManipulator/Export b/include/osgManipulator/Export index 0bf7a114c..84ff231c0 100644 --- a/include/osgManipulator/Export +++ b/include/osgManipulator/Export @@ -27,6 +27,12 @@ # define OSGMANIPULATOR_EXPORT #endif +#define META_OSGMANIPULATOR_Object(library,name) \ +virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast(obj)!=NULL; } \ +virtual const char* libraryName() const { return #library; }\ +virtual const char* className() const { return #name; } + + /** \namespace osgManipulator diff --git a/include/osgManipulator/Selection b/include/osgManipulator/Selection index 11ca2d6da..8a99bc26e 100644 --- a/include/osgManipulator/Selection +++ b/include/osgManipulator/Selection @@ -20,71 +20,8 @@ namespace osgManipulator { -class MotionCommand; -class TranslateInLineCommand; -class TranslateInPlaneCommand; -class Scale1DCommand; -class Scale2DCommand; -class ScaleUniformCommand; -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(obj)!=NULL; } \ -virtual const char* libraryName() const { return #library; }\ -virtual const char* className() const { return #name; } - - - -class CommandProcessor -{ - public: - virtual bool receive(const MotionCommand&) = 0; - virtual bool receive(const TranslateInLineCommand& command) = 0; - virtual bool receive(const TranslateInPlaneCommand& command) = 0; - virtual bool receive(const Scale1DCommand& command) = 0; - virtual bool receive(const Scale2DCommand& command) = 0; - virtual bool receive(const ScaleUniformCommand& command) = 0; - virtual bool receive(const Rotate3DCommand& command) = 0; -}; - - -/** - * Selection listens to motion commands generated by draggers. - */ -class OSGMANIPULATOR_EXPORT Selection : public osg::MatrixTransform -{ - public: - - Selection(); - - META_OSGMANIPULATOR_Object(osgManipulator,Selection) - - /** - * Receive motion commands and set the MatrixTransform accordingly to - * transform selections. Returns true on success. - */ - virtual bool receive(const MotionCommand&); - virtual bool receive(const TranslateInLineCommand& command) { return receive((MotionCommand&)command); } - virtual bool receive(const TranslateInPlaneCommand& command) { return receive((MotionCommand&)command); } - virtual bool receive(const Scale1DCommand& command) { return receive((MotionCommand&)command); } - virtual bool receive(const Scale2DCommand& command) { return receive((MotionCommand&)command); } - virtual bool receive(const ScaleUniformCommand& command) { return receive((MotionCommand&)command); } - virtual bool receive(const Rotate3DCommand& command) { return receive((MotionCommand&)command); } - - protected: - - virtual ~Selection(); - - osg::Matrix _startMotionMatrix; - - osg::Matrix _localToWorld; - osg::Matrix _worldToLocal; -}; +typedef osg::MatrixTransform Selection; } diff --git a/src/osgManipulator/CMakeLists.txt b/src/osgManipulator/CMakeLists.txt index 1a84d2bf0..cf783ce48 100644 --- a/src/osgManipulator/CMakeLists.txt +++ b/src/osgManipulator/CMakeLists.txt @@ -38,7 +38,6 @@ ADD_LIBRARY(${LIB_NAME} ${LIB_PUBLIC_HEADERS} AntiSquish.cpp Command.cpp - CommandManager.cpp Constraint.cpp Dragger.cpp Projector.cpp @@ -47,7 +46,6 @@ ADD_LIBRARY(${LIB_NAME} Scale1DDragger.cpp Scale2DDragger.cpp ScaleAxisDragger.cpp - Selection.cpp TabBoxDragger.cpp TabPlaneDragger.cpp TabPlaneTrackballDragger.cpp diff --git a/src/osgManipulator/Command.cpp b/src/osgManipulator/Command.cpp index 92bce4cfd..b003fc23a 100644 --- a/src/osgManipulator/Command.cpp +++ b/src/osgManipulator/Command.cpp @@ -13,7 +13,6 @@ //osgManipulator - Copyright (C) 2007 Fugro-Jason B.V. #include -#include #include #include diff --git a/src/osgManipulator/CommandManager.cpp b/src/osgManipulator/CommandManager.cpp deleted file mode 100644 index a4a419104..000000000 --- a/src/osgManipulator/CommandManager.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield - * - * This library is open source and may be redistributed and/or modified under - * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or - * (at your option) any later version. The full license is in LICENSE file - * included with this distribution, and on the openscenegraph.org website. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * OpenSceneGraph Public License for more details. -*/ -//osgManipulator - Copyright (C) 2007 Fugro-Jason B.V. - -#include -#include - -using namespace osgManipulator; - -CommandManager::CommandManager() -{ -} - -CommandManager::~CommandManager() -{ -} - -bool CommandManager::connect(Dragger& dragger, Selection& selection) -{ - dragger.addSelection(&selection); - - return true; -} - -bool CommandManager::connect(Dragger& dragger, Constraint& constraint) -{ - dragger.addConstraint(&constraint); - - return true; -} - -bool CommandManager::disconnect(Dragger& dragger) -{ - dragger.getConstraints().clear(); - dragger.getSelections().clear(); - - return true; -} - -CommandManager::Selections CommandManager::getConnectedSelections(Dragger& dragger) -{ - Selections selections; - - for(Dragger::Selections::iterator itr = dragger.getSelections().begin(); - itr != dragger.getSelections().end(); - ++itr) - { - selections.push_back(*itr); - } - - return selections; -} diff --git a/src/osgManipulator/Constraint.cpp b/src/osgManipulator/Constraint.cpp index d9c874baf..a09db3de9 100644 --- a/src/osgManipulator/Constraint.cpp +++ b/src/osgManipulator/Constraint.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include diff --git a/src/osgManipulator/Dragger.cpp b/src/osgManipulator/Dragger.cpp index 71c66ecf9..4cd0586eb 100644 --- a/src/osgManipulator/Dragger.cpp +++ b/src/osgManipulator/Dragger.cpp @@ -20,6 +20,78 @@ using namespace osgManipulator; +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// computeNodePathToRoot +// +void osgManipulator::computeNodePathToRoot(osg::Node& node, osg::NodePath& np) +{ + np.clear(); + + osg::NodePathList nodePaths = node.getParentalNodePaths(); + + if (!nodePaths.empty()) + { + np = nodePaths.front(); + if (nodePaths.size()>1) + { + osg::notify(osg::NOTICE)<<"osgManipulator::computeNodePathToRoot(,) taking first parent path, ignoring others."<getMatrix(); + + // Get the LocalToWorld and WorldToLocal matrix for this node. + osg::NodePath nodePathToRoot; + computeNodePathToRoot(*_transform,nodePathToRoot); + _localToWorld = osg::computeLocalToWorld(nodePathToRoot); + _worldToLocal = osg::Matrix::inverse(_localToWorld); + + return true; + } + case MotionCommand::MOVE: + { + // Transform the command's motion matrix into local motion matrix. + osg::Matrix localMotionMatrix = _localToWorld * command.getWorldToLocal() + * command.getMotionMatrix() + * command.getLocalToWorld() * _worldToLocal; + + // Transform by the localMotionMatrix + _transform->setMatrix(localMotionMatrix * _startMotionMatrix); + + return true; + } + case MotionCommand::FINISH: + { + return true; + } + case MotionCommand::NONE: + default: + return false; + } +} + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // PointerInfo @@ -57,6 +129,15 @@ Dragger::Dragger() : { _parentDragger = this; getOrCreateStateSet()->setDataVariance(osg::Object::DYNAMIC); + + _selfUpdater = new DraggerTransformCallback(this); + +} + +Dragger::Dragger(const Dragger& rhs, const osg::CopyOp& copyop): + osg::MatrixTransform(rhs, copyop) +{ + osg::notify(osg::NOTICE)<<"CompositeDragger::CompositeDragger(const CompositeDragger& rhs, const osg::CopyOp& copyop) not Implemented yet."<(object)); + addDraggerCallback(new DraggerTransformCallback(transform)); } -void Dragger::addSelection(Selection* selection) +void Dragger::removeTransformUpdating(osg::MatrixTransform* transform) { - // check to make sure constaint hasn't already been attached. - for(Selections::iterator itr = _selections.begin(); - itr != _selections.end(); + for(Dragger::DraggerCallbacks::iterator itr = _draggerCallbacks.begin(); + itr != _draggerCallbacks.end(); ++itr) { - if (*itr == selection) return; - } - - selection->addObserver(this); - _selections.push_back(selection); -} - -void Dragger::removeSelection(Selection* selection) -{ - for(Selections::iterator itr = _selections.begin(); - itr != _selections.end(); - ++itr) - { - if (*itr == selection) + DraggerCallback* dc = itr->get(); + DraggerTransformCallback* dtc = dynamic_cast(dc); + if (dtc && dtc->getTransform()==transform) { - selection->removeObserver(this); - _selections.erase(itr); - return; + _draggerCallbacks.erase(itr); } } + +} + +void Dragger::addDraggerCallback(DraggerCallback* dc) +{ + for(DraggerCallbacks::iterator itr = _draggerCallbacks.begin(); + itr != _draggerCallbacks.end(); + ++itr) + { + if (*itr == dc) return; + } + + _draggerCallbacks.push_back(dc); +} + +void Dragger::removeDraggerCallback(DraggerCallback* dc) +{ } @@ -155,7 +238,7 @@ void Dragger::traverse(osg::NodeVisitor& nv) return; } - Selection::traverse(nv); + MatrixTransform::traverse(nv); } bool Dragger::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa) @@ -231,6 +314,12 @@ bool Dragger::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& return handled; } +bool Dragger::receive(const MotionCommand& command) +{ + if (_selfUpdater.valid()) return _selfUpdater->receive(command); + else return false; +} + void Dragger::dispatch(MotionCommand& command) { // apply any constraints @@ -244,9 +333,9 @@ void Dragger::dispatch(MotionCommand& command) // move self getParentDragger()->receive(command); - // then run through any selections - for(Selections::iterator itr = getParentDragger()->getSelections().begin(); - itr != getParentDragger()->getSelections().end(); + + for(DraggerCallbacks::iterator itr = getParentDragger()->getDraggerCallbacks().begin(); + itr != getParentDragger()->getDraggerCallbacks().end(); ++itr) { (*itr)->receive(command); @@ -258,6 +347,11 @@ void Dragger::dispatch(MotionCommand& command) // // CompositeDragger // +CompositeDragger::CompositeDragger(const CompositeDragger& rhs, const osg::CopyOp& copyop): + Dragger(rhs, copyop) +{ + osg::notify(osg::NOTICE)<<"CompositeDragger::CompositeDragger(const CompositeDragger& rhs, const osg::CopyOp& copyop) not Implemented yet."< -#include - -#include - -#include - -using namespace osgManipulator; - -void osgManipulator::computeNodePathToRoot(osg::Node& node, osg::NodePath& np) -{ - np.clear(); - - osg::NodePathList nodePaths = node.getParentalNodePaths(); - - if (!nodePaths.empty()) - { - np = nodePaths.front(); - if (nodePaths.size()>1) - { - osg::notify(osg::NOTICE)<<"osgManipulator::computeNodePathToRoot(,) taking first parent path, ignoring others."< #include +#include +#include #include #include #include #include #include #include +#include #include #include -#include // Must undefine IN and OUT macros defined in Windows headers #ifdef IN @@ -34,20 +36,35 @@ TYPE_NAME_ALIAS(std::vector< osg::ref_ptr< osgManipulator::Dragger > >, osgManip BEGIN_OBJECT_REFLECTOR(osgManipulator::CompositeDragger) I_DeclaringFile("osgManipulator/Dragger"); I_BaseType(osgManipulator::Dragger); + I_Method0(osg::Object *, cloneType, + Properties::VIRTUAL, + __osg_Object_P1__cloneType, + "clone an object of the same type as the node. ", + ""); + I_Method1(osg::Object *, clone, IN, const osg::CopyOp &, copyop, + Properties::VIRTUAL, + __osg_Object_P1__clone__C5_osg_CopyOp_R1, + "return a clone of a node, with Object* return type. ", + ""); I_Method1(bool, isSameKindAs, IN, const osg::Object *, obj, Properties::VIRTUAL, __bool__isSameKindAs__C5_osg_Object_P1, "return true if this and obj are of the same kind of object. ", ""); + I_Method0(const char *, className, + Properties::VIRTUAL, + __C5_char_P1__className, + "return the name of the node's class type. ", + ""); I_Method0(const char *, libraryName, Properties::VIRTUAL, __C5_char_P1__libraryName, "return the name of the node's library. ", ""); - I_Method0(const char *, className, + I_Method1(void, accept, IN, osg::NodeVisitor &, nv, Properties::VIRTUAL, - __C5_char_P1__className, - "return the name of the node's class type. ", + __void__accept__osg_NodeVisitor_R1, + "Visitor Pattern : calls the apply method of a NodeVisitor with this node's type. ", ""); I_Method0(const osgManipulator::CompositeDragger *, getComposite, Properties::VIRTUAL, @@ -107,6 +124,10 @@ BEGIN_OBJECT_REFLECTOR(osgManipulator::CompositeDragger) I_ProtectedConstructor0(____CompositeDragger, "", ""); + I_ProtectedConstructorWithDefaults2(IN, const osgManipulator::CompositeDragger &, rhs, , IN, const osg::CopyOp &, copyop, osg::CopyOp::SHALLOW_COPY, + ____CompositeDragger__C5_CompositeDragger_R1__C5_osg_CopyOp_R1, + "", + ""); I_SimpleProperty(osgManipulator::CompositeDragger *, Composite, __CompositeDragger_P1__getComposite, 0); @@ -124,26 +145,40 @@ END_REFLECTOR TYPE_NAME_ALIAS(std::vector< osg::ref_ptr< osgManipulator::Constraint > >, osgManipulator::Dragger::Constraints) -TYPE_NAME_ALIAS(std::vector< osgManipulator::Selection * >, osgManipulator::Dragger::Selections) +TYPE_NAME_ALIAS(std::vector< osg::ref_ptr< osgManipulator::DraggerCallback > >, osgManipulator::Dragger::DraggerCallbacks) BEGIN_OBJECT_REFLECTOR(osgManipulator::Dragger) I_DeclaringFile("osgManipulator/Dragger"); - I_BaseType(osgManipulator::Selection); - I_BaseType(osg::Observer); + I_BaseType(osg::MatrixTransform); + I_Method0(osg::Object *, cloneType, + Properties::VIRTUAL, + __osg_Object_P1__cloneType, + "clone an object of the same type as the node. ", + ""); + I_Method1(osg::Object *, clone, IN, const osg::CopyOp &, copyop, + Properties::VIRTUAL, + __osg_Object_P1__clone__C5_osg_CopyOp_R1, + "return a clone of a node, with Object* return type. ", + ""); I_Method1(bool, isSameKindAs, IN, const osg::Object *, obj, Properties::VIRTUAL, __bool__isSameKindAs__C5_osg_Object_P1, "return true if this and obj are of the same kind of object. ", ""); + I_Method0(const char *, className, + Properties::VIRTUAL, + __C5_char_P1__className, + "return the name of the node's class type. ", + ""); I_Method0(const char *, libraryName, Properties::VIRTUAL, __C5_char_P1__libraryName, "return the name of the node's library. ", ""); - I_Method0(const char *, className, + I_Method1(void, accept, IN, osg::NodeVisitor &, nv, Properties::VIRTUAL, - __C5_char_P1__className, - "return the name of the node's class type. ", + __void__accept__osg_NodeVisitor_R1, + "Visitor Pattern : calls the apply method of a NodeVisitor with this node's type. ", ""); I_Method1(void, setParentDragger, IN, osgManipulator::Dragger *, parent, Properties::VIRTUAL, @@ -225,41 +260,55 @@ BEGIN_OBJECT_REFLECTOR(osgManipulator::Dragger) __C5_Constraints_R1__getConstraints, "", ""); - I_Method1(void, addSelection, IN, osgManipulator::Selection *, selection, + I_Method1(void, addDraggerCallback, IN, osgManipulator::DraggerCallback *, dc, Properties::NON_VIRTUAL, - __void__addSelection__Selection_P1, + __void__addDraggerCallback__DraggerCallback_P1, "", ""); - I_Method1(void, removeSelection, IN, osgManipulator::Selection *, selection, + I_Method1(void, removeDraggerCallback, IN, osgManipulator::DraggerCallback *, dc, Properties::NON_VIRTUAL, - __void__removeSelection__Selection_P1, + __void__removeDraggerCallback__DraggerCallback_P1, "", ""); - I_Method0(osgManipulator::Dragger::Selections &, getSelections, + I_Method0(osgManipulator::Dragger::DraggerCallbacks &, getDraggerCallbacks, Properties::NON_VIRTUAL, - __Selections_R1__getSelections, + __DraggerCallbacks_R1__getDraggerCallbacks, "", ""); - I_Method0(const osgManipulator::Dragger::Selections &, getSelections, + I_Method0(const osgManipulator::Dragger::DraggerCallbacks &, getDraggerCallbacks, Properties::NON_VIRTUAL, - __C5_Selections_R1__getSelections, + __C5_DraggerCallbacks_R1__getDraggerCallbacks, + "", + ""); + I_Method1(void, addTransformUpdating, IN, osg::MatrixTransform *, transform, + Properties::NON_VIRTUAL, + __void__addTransformUpdating__MatrixTransform_P1, + "", + ""); + I_Method1(void, removeTransformUpdating, IN, osg::MatrixTransform *, transform, + Properties::NON_VIRTUAL, + __void__removeTransformUpdating__MatrixTransform_P1, "", ""); I_ProtectedConstructor0(____Dragger, "", ""); + I_ProtectedConstructorWithDefaults2(IN, const osgManipulator::Dragger &, rhs, , IN, const osg::CopyOp &, copyop, osg::CopyOp::SHALLOW_COPY, + ____Dragger__C5_Dragger_R1__C5_osg_CopyOp_R1, + "", + ""); + I_ProtectedMethod1(bool, receive, IN, const osgManipulator::MotionCommand &, command, + Properties::VIRTUAL, + Properties::NON_CONST, + __bool__receive__C5_MotionCommand_R1, + "", + ""); I_ProtectedMethod1(void, dispatch, IN, osgManipulator::MotionCommand &, command, Properties::NON_VIRTUAL, Properties::NON_CONST, __void__dispatch__MotionCommand_R1, "", ""); - I_ProtectedMethod1(void, objectDeleted, IN, void *, object, - Properties::VIRTUAL, - Properties::NON_CONST, - __void__objectDeleted__void_P1, - "", - ""); I_SimpleProperty(osgManipulator::CompositeDragger *, Composite, __CompositeDragger_P1__getComposite, 0); @@ -269,14 +318,114 @@ BEGIN_OBJECT_REFLECTOR(osgManipulator::Dragger) I_SimpleProperty(bool, DraggerActive, __bool__getDraggerActive, __void__setDraggerActive__bool); + I_SimpleProperty(osgManipulator::Dragger::DraggerCallbacks &, DraggerCallbacks, + __DraggerCallbacks_R1__getDraggerCallbacks, + 0); I_SimpleProperty(bool, HandleEvents, __bool__getHandleEvents, __void__setHandleEvents__bool); I_SimpleProperty(osgManipulator::Dragger *, ParentDragger, __Dragger_P1__getParentDragger, __void__setParentDragger__Dragger_P1); - I_SimpleProperty(osgManipulator::Dragger::Selections &, Selections, - __Selections_R1__getSelections, +END_REFLECTOR + +BEGIN_OBJECT_REFLECTOR(osgManipulator::DraggerCallback) + I_DeclaringFile("osgManipulator/Dragger"); + I_VirtualBaseType(osg::Object); + I_Constructor0(____DraggerCallback, + "", + ""); + I_ConstructorWithDefaults2(IN, const osgManipulator::DraggerCallback &, x, , IN, const osg::CopyOp &, copyop, osg::CopyOp::SHALLOW_COPY, + ____DraggerCallback__C5_DraggerCallback_R1__C5_osg_CopyOp_R1, + "", + ""); + I_Method0(osg::Object *, cloneType, + Properties::VIRTUAL, + __osg_Object_P1__cloneType, + "Clone the type of an object, with Object* return type. ", + "Must be defined by derived classes. "); + I_Method1(osg::Object *, clone, IN, const osg::CopyOp &, x, + Properties::VIRTUAL, + __osg_Object_P1__clone__C5_osg_CopyOp_R1, + "Clone an object, with Object* return type. ", + "Must be defined by derived classes. "); + I_Method1(bool, isSameKindAs, IN, const osg::Object *, obj, + Properties::VIRTUAL, + __bool__isSameKindAs__C5_osg_Object_P1, + "", + ""); + I_Method0(const char *, libraryName, + Properties::VIRTUAL, + __C5_char_P1__libraryName, + "return the name of the object's library. ", + "Must be defined by derived classes. The OpenSceneGraph convention is that the namespace of a library is the same as the library name. "); + I_Method0(const char *, className, + Properties::VIRTUAL, + __C5_char_P1__className, + "return the name of the object's class type. ", + "Must be defined by derived classes. "); + I_Method1(bool, receive, IN, const osgManipulator::MotionCommand &, x, + Properties::VIRTUAL, + __bool__receive__C5_MotionCommand_R1, + "Receive motion commands. ", + "Returns true on success. "); + I_Method1(bool, receive, IN, const osgManipulator::TranslateInLineCommand &, command, + Properties::VIRTUAL, + __bool__receive__C5_TranslateInLineCommand_R1, + "", + ""); + I_Method1(bool, receive, IN, const osgManipulator::TranslateInPlaneCommand &, command, + Properties::VIRTUAL, + __bool__receive__C5_TranslateInPlaneCommand_R1, + "", + ""); + I_Method1(bool, receive, IN, const osgManipulator::Scale1DCommand &, command, + Properties::VIRTUAL, + __bool__receive__C5_Scale1DCommand_R1, + "", + ""); + I_Method1(bool, receive, IN, const osgManipulator::Scale2DCommand &, command, + Properties::VIRTUAL, + __bool__receive__C5_Scale2DCommand_R1, + "", + ""); + I_Method1(bool, receive, IN, const osgManipulator::ScaleUniformCommand &, command, + Properties::VIRTUAL, + __bool__receive__C5_ScaleUniformCommand_R1, + "", + ""); + I_Method1(bool, receive, IN, const osgManipulator::Rotate3DCommand &, command, + Properties::VIRTUAL, + __bool__receive__C5_Rotate3DCommand_R1, + "", + ""); +END_REFLECTOR + +BEGIN_OBJECT_REFLECTOR(osgManipulator::DraggerTransformCallback) + I_DeclaringFile("osgManipulator/Dragger"); + I_BaseType(osgManipulator::DraggerCallback); + I_Constructor1(IN, osg::MatrixTransform *, transform, + Properties::NON_EXPLICIT, + ____DraggerTransformCallback__osg_MatrixTransform_P1, + "", + ""); + I_Method1(bool, receive, IN, const osgManipulator::MotionCommand &, x, + Properties::VIRTUAL, + __bool__receive__C5_MotionCommand_R1, + "Receive motion commands. ", + "Returns true on success. "); + I_Method0(osg::MatrixTransform *, getTransform, + Properties::NON_VIRTUAL, + __osg_MatrixTransform_P1__getTransform, + "", + ""); + I_Method0(const osg::MatrixTransform *, getTransform, + Properties::NON_VIRTUAL, + __C5_osg_MatrixTransform_P1__getTransform, + "", + ""); + I_SimpleProperty(osg::MatrixTransform *, Transform, + __osg_MatrixTransform_P1__getTransform, 0); END_REFLECTOR @@ -447,6 +596,46 @@ BEGIN_VALUE_REFLECTOR(osg::ref_ptr< osgManipulator::Dragger >) 0); END_REFLECTOR +BEGIN_VALUE_REFLECTOR(osg::ref_ptr< osgManipulator::DraggerCallback >) + I_DeclaringFile("osg/ref_ptr"); + I_Constructor0(____ref_ptr, + "", + ""); + I_Constructor1(IN, osgManipulator::DraggerCallback *, ptr, + Properties::NON_EXPLICIT, + ____ref_ptr__T_P1, + "", + ""); + I_Constructor1(IN, const osg::ref_ptr< osgManipulator::DraggerCallback > &, rp, + Properties::NON_EXPLICIT, + ____ref_ptr__C5_ref_ptr_R1, + "", + ""); + I_Method0(osgManipulator::DraggerCallback *, get, + Properties::NON_VIRTUAL, + __T_P1__get, + "", + ""); + I_Method0(bool, valid, + Properties::NON_VIRTUAL, + __bool__valid, + "", + ""); + I_Method0(osgManipulator::DraggerCallback *, release, + Properties::NON_VIRTUAL, + __T_P1__release, + "", + ""); + I_Method1(void, swap, IN, osg::ref_ptr< osgManipulator::DraggerCallback > &, rp, + Properties::NON_VIRTUAL, + __void__swap__ref_ptr_R1, + "", + ""); + I_SimpleProperty(osgManipulator::DraggerCallback *, , + __T_P1__get, + 0); +END_REFLECTOR + STD_LIST_REFLECTOR(std::list< osgManipulator::PointerInfo::NodePathIntersectionPair >) STD_PAIR_REFLECTOR(std::pair< osg::NodePath COMMA osg::Vec3d >) @@ -455,5 +644,5 @@ STD_VECTOR_REFLECTOR(std::vector< osg::ref_ptr< osgManipulator::Constraint > >) STD_VECTOR_REFLECTOR(std::vector< osg::ref_ptr< osgManipulator::Dragger > >) -STD_VECTOR_REFLECTOR(std::vector< osgManipulator::Selection * >) +STD_VECTOR_REFLECTOR(std::vector< osg::ref_ptr< osgManipulator::DraggerCallback > >) diff --git a/src/osgWrappers/osgManipulator/Selection.cpp b/src/osgWrappers/osgManipulator/Selection.cpp index 376abe7f8..430c2c72a 100644 --- a/src/osgWrappers/osgManipulator/Selection.cpp +++ b/src/osgWrappers/osgManipulator/Selection.cpp @@ -10,8 +10,6 @@ #include #include -#include -#include #include // Must undefine IN and OUT macros defined in Windows headers @@ -22,103 +20,5 @@ #undef OUT #endif -BEGIN_ABSTRACT_OBJECT_REFLECTOR(osgManipulator::CommandProcessor) - I_DeclaringFile("osgManipulator/Selection"); - I_Constructor0(____CommandProcessor, - "", - ""); - I_Method1(bool, receive, IN, const osgManipulator::MotionCommand &, x, - Properties::PURE_VIRTUAL, - __bool__receive__C5_MotionCommand_R1, - "", - ""); - I_Method1(bool, receive, IN, const osgManipulator::TranslateInLineCommand &, command, - Properties::PURE_VIRTUAL, - __bool__receive__C5_TranslateInLineCommand_R1, - "", - ""); - I_Method1(bool, receive, IN, const osgManipulator::TranslateInPlaneCommand &, command, - Properties::PURE_VIRTUAL, - __bool__receive__C5_TranslateInPlaneCommand_R1, - "", - ""); - I_Method1(bool, receive, IN, const osgManipulator::Scale1DCommand &, command, - Properties::PURE_VIRTUAL, - __bool__receive__C5_Scale1DCommand_R1, - "", - ""); - I_Method1(bool, receive, IN, const osgManipulator::Scale2DCommand &, command, - Properties::PURE_VIRTUAL, - __bool__receive__C5_Scale2DCommand_R1, - "", - ""); - I_Method1(bool, receive, IN, const osgManipulator::ScaleUniformCommand &, command, - Properties::PURE_VIRTUAL, - __bool__receive__C5_ScaleUniformCommand_R1, - "", - ""); - I_Method1(bool, receive, IN, const osgManipulator::Rotate3DCommand &, command, - Properties::PURE_VIRTUAL, - __bool__receive__C5_Rotate3DCommand_R1, - "", - ""); -END_REFLECTOR - -BEGIN_OBJECT_REFLECTOR(osgManipulator::Selection) - I_DeclaringFile("osgManipulator/Selection"); - I_BaseType(osg::MatrixTransform); - I_Constructor0(____Selection, - "", - ""); - I_Method1(bool, isSameKindAs, IN, const osg::Object *, obj, - Properties::VIRTUAL, - __bool__isSameKindAs__C5_osg_Object_P1, - "return true if this and obj are of the same kind of object. ", - ""); - I_Method0(const char *, libraryName, - Properties::VIRTUAL, - __C5_char_P1__libraryName, - "return the name of the node's library. ", - ""); - I_Method0(const char *, className, - Properties::VIRTUAL, - __C5_char_P1__className, - "return the name of the node's class type. ", - ""); - I_Method1(bool, receive, IN, const osgManipulator::MotionCommand &, x, - Properties::VIRTUAL, - __bool__receive__C5_MotionCommand_R1, - "Receive motion commands and set the MatrixTransform accordingly to transform selections. ", - "Returns true on success. "); - I_Method1(bool, receive, IN, const osgManipulator::TranslateInLineCommand &, command, - Properties::VIRTUAL, - __bool__receive__C5_TranslateInLineCommand_R1, - "", - ""); - I_Method1(bool, receive, IN, const osgManipulator::TranslateInPlaneCommand &, command, - Properties::VIRTUAL, - __bool__receive__C5_TranslateInPlaneCommand_R1, - "", - ""); - I_Method1(bool, receive, IN, const osgManipulator::Scale1DCommand &, command, - Properties::VIRTUAL, - __bool__receive__C5_Scale1DCommand_R1, - "", - ""); - I_Method1(bool, receive, IN, const osgManipulator::Scale2DCommand &, command, - Properties::VIRTUAL, - __bool__receive__C5_Scale2DCommand_R1, - "", - ""); - I_Method1(bool, receive, IN, const osgManipulator::ScaleUniformCommand &, command, - Properties::VIRTUAL, - __bool__receive__C5_ScaleUniformCommand_R1, - "", - ""); - I_Method1(bool, receive, IN, const osgManipulator::Rotate3DCommand &, command, - Properties::VIRTUAL, - __bool__receive__C5_Rotate3DCommand_R1, - "", - ""); -END_REFLECTOR +TYPE_NAME_ALIAS(osg::MatrixTransform, osgManipulator::Selection)