OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CommandManager.h
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 
18 #include <osgManipulator/Dragger>
19 #include <osgManipulator/Selection>
20 #include <osgManipulator/Constraint>
21 
22 namespace 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 
59  Selections getConnectedSelections(Dragger& dragger)
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
std::list< osg::ref_ptr< Selection > > Selections
DraggerCallbacks & getDraggerCallbacks()
Definition: Dragger.h:250
bool connect(Dragger &dragger, Constraint &constraint)
Constraints & getConstraints()
Definition: Dragger.h:241
bool disconnect(Dragger &dragger)
void addTransformUpdating(MatrixTransform *transform, int handleCommandMask=DraggerTransformCallback::HANDLE_ALL)
osg::MatrixTransform * getTransform()
Definition: Dragger.h:69
void addConstraint(Constraint *constraint)
Selections getConnectedSelections(Dragger &dragger)
bool connect(Dragger &dragger, Selection &selection)