HI Mikhail, So the problem is the the Rotate3DCommnd is being upcast to the base class MotionCommand and then never the Constraint and DraggerCallbacks only have their constrain(MotionCommand&)/recive(MotionCommand&) methods called rather than the original subclass method i,e, constain(Rotate3DCommand&) and recive(Rotate3DCommand&)?
If so then the problem looks to be one that would need tackling via a double dispatch vistor pattern solution like used in osg::Node::accept(NodeVisitor&)/osg::NodeVisitor::apply(Node&). I am on the right track? Robert. On Wed, May 25, 2011 at 10:09 AM, Mikhail I. Izmestev <[email protected]> wrote: > 25.05.2011 12:29, Robert Osfield wrote: >> >> Hi Mikhail, >> >> On Wed, May 25, 2011 at 9:10 AM, Mikhail I. Izmestev >> <[email protected]> wrote: >>> >>> For example you can take a look to RotateCylinderDragger, it create >>> Rotate3DCommand and pass it to dispatch method. >> >> I'm afraid this doesn't explain what the problem is. Could you please >> explain the mechanics of the problem rather than just throw out >> various class names as I can't second guess what problems you have >> identified. >> >> Robert. > > Ok, Constraint class have methods > > virtual bool constrain(MotionCommand&) const > virtual bool constrain(TranslateInLineCommand& command) const > virtual bool constrain(TranslateInPlaneCommand& command) const > virtual bool constrain(Scale1DCommand& command) const > virtual bool constrain(Scale2DCommand& command) const > virtual bool constrain(ScaleUniformCommand& command) const > > > And DraggerCallback class have methods > > 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) > > piece of code of RotateCylinderDragger::handle > <code> > ... > osg::ref_ptr<Rotate3DCommand> cmd = new Rotate3DCommand(); > cmd->setStage(MotionCommand::MOVE); > cmd->setLocalToWorldAndWorldToLocal(_startLocalToWorld,_startWorldToLocal); > cmd->setRotation(rotation); > > // Dispatch command. > dispatch(*cmd); > ... > </code> > > As you can see there is used Rotate3DCommand, what we would expect from > DraggerCallback attached to this Dragger, call of > bool receive(const Rotate3DCommand& command) > or > bool receive(const MotionCommand&) > ? > > Now see dispatch method > void Dragger::dispatch(MotionCommand& command) > { > // apply any constraints > for(Constraints::iterator itr = _constraints.begin(); > itr != _constraints.end(); > ++itr) > { > (*itr)->constrain(command); > } > > // move self > getParentDragger()->receive(command); > > > for(DraggerCallbacks::iterator itr = > getParentDragger()->getDraggerCallbacks().begin(); > itr != getParentDragger()->getDraggerCallbacks().end(); > ++itr) > { > (*itr)->receive(command); > } > } > > and we see what would be called > bool receive(const MotionCommand&) > > Mikhail. > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

