openscenegraph
CommandManager
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
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.
7 *
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.
12*/
13//osgManipulator - Copyright (C) 2007 Fugro-Jason B.V.
14
15#ifndef OSGMANIPULATOR_COMMANDMANAGER
16#define OSGMANIPULATOR_COMMANDMANAGER 1
17
21
22namespace osgManipulator {
23
31{
32 public:
34
35 bool connect(Dragger& dragger, Selection& selection)
36 {
37 dragger.addTransformUpdating(&selection);
38
39 return true;
40 }
41
42 bool connect(Dragger& dragger, Constraint& constraint)
43 {
44 dragger.addConstraint(&constraint);
45
46 return true;
47 }
48
49 bool disconnect(Dragger& dragger)
50 {
51 dragger.getConstraints().clear();
52 dragger.getDraggerCallbacks().clear();
53
54 return true;
55 }
56
57 typedef std::list< osg::ref_ptr<Selection> > Selections;
58
60 {
61 Selections selections;
62
63 for(Dragger::DraggerCallbacks::iterator itr = dragger.getDraggerCallbacks().begin();
64 itr != dragger.getDraggerCallbacks().end();
65 ++itr)
66 {
67 DraggerCallback* dc = itr->get();
68 DraggerTransformCallback* dtc = dynamic_cast<DraggerTransformCallback*>(dc);
69 if (dtc && dtc->getTransform()) selections.push_back(dtc->getTransform());
70 }
71
72 return selections;
73 }
74
75 protected:
76
77 virtual ~CommandManager() {}
78
79};
80
81}
82
83#endif
Definition CommandManager:31
bool connect(Dragger &dragger, Selection &selection)
Definition CommandManager:35
std::list< osg::ref_ptr< Selection > > Selections
Definition CommandManager:57
bool connect(Dragger &dragger, Constraint &constraint)
Definition CommandManager:42
virtual ~CommandManager()
Definition CommandManager:77
Selections getConnectedSelections(Dragger &dragger)
Definition CommandManager:59
bool disconnect(Dragger &dragger)
Definition CommandManager:49
CommandManager()
Definition CommandManager:33
Definition Constraint:60
Definition Constraint:36
osg::MatrixTransform * getTransform()
Definition Dragger:68
Definition Dragger:194
void addTransformUpdating(MatrixTransform *transform, int handleCommandMask=DraggerTransformCallback::HANDLE_ALL)
void addConstraint(Constraint *constraint)
DraggerCallbacks & getDraggerCallbacks()
Definition Dragger:256
Constraints & getConstraints()
Definition Dragger:244
Definition MatrixTransform:26
Definition Referenced:44
Definition AntiSquish:23