1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
13//osgManipulator - Copyright (C) 2007 Fugro-Jason B.V.
15#ifndef OSGMANIPULATOR_COMMANDMANAGER
16#define OSGMANIPULATOR_COMMANDMANAGER 1
18#include <osgManipulator/Dragger>
19#include <osgManipulator/Selection>
20#include <osgManipulator/Constraint>
22namespace osgManipulator {
26 * CommandManager class is now no longer required as Dragger now matains all references to Constraints and Selections (now just generic MatrixTransforms).
27 * To replace CommandManager usage simple replace cmdMgr->connect(*dragger, *selection) with dragger->addTransformUpdating(selection) and
28 * cmdMgr->connect(*dragger, *selection) with dragger->addConstaint(constraint).
30class CommandManager : public osg::Referenced
35 bool connect(Dragger& dragger, Selection& selection)
37 dragger.addTransformUpdating(&selection);
42 bool connect(Dragger& dragger, Constraint& constraint)
44 dragger.addConstraint(&constraint);
49 bool disconnect(Dragger& dragger)
51 dragger.getConstraints().clear();
52 dragger.getDraggerCallbacks().clear();
57 typedef std::list< osg::ref_ptr<Selection> > Selections;
59 Selections getConnectedSelections(Dragger& dragger)
61 Selections selections;
63 for(Dragger::DraggerCallbacks::iterator itr = dragger.getDraggerCallbacks().begin();
64 itr != dragger.getDraggerCallbacks().end();
67 DraggerCallback* dc = itr->get();
68 DraggerTransformCallback* dtc = dynamic_cast<DraggerTransformCallback*>(dc);
69 if (dtc && dtc->getTransform()) selections.push_back(dtc->getTransform());
77 virtual ~CommandManager() {}