openscenegraph
Translate1DDragger
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_TRANSLATE1DDRAGGER
16#define OSGMANIPULATOR_TRANSLATE1DDRAGGER 1
17
18#include <osgManipulator/Dragger>
19#include <osgManipulator/Projector>
20
21namespace osgManipulator {
22
23
24/**
25 * Dragger for performing 1D translation.
26 */
27class OSGMANIPULATOR_EXPORT Translate1DDragger : public Dragger
28{
29 public:
30
31 Translate1DDragger();
32
33 META_OSGMANIPULATOR_Object(osgManipulator,Translate1DDragger);
34
35 Translate1DDragger(const osg::Vec3d& s, const osg::Vec3d& e);
36
37 /** Handle pick events on dragger and generate TranslateInLine commands. */
38 virtual bool handle(const PointerInfo& pi, const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us);
39
40 /** Setup default geometry for dragger. */
41 void setupDefaultGeometry();
42
43 /** Set/Get color for dragger. */
44 inline void setColor(const osg::Vec4& color) { _color = color; setMaterialColor(_color,*this); }
45 inline const osg::Vec4& getColor() const { return _color; }
46
47 /** Set/Get pick color for dragger. Pick color is color of the dragger when picked.
48 It gives a visual feedback to show that the dragger has been picked. */
49 inline void setPickColor(const osg::Vec4& color) { _pickColor = color; }
50 inline const osg::Vec4& getPickColor() const { return _pickColor; }
51
52 inline void setCheckForNodeInNodePath(bool onOff) { _checkForNodeInNodePath = onOff; }
53
54 protected:
55
56 virtual ~Translate1DDragger();
57
58 osg::ref_ptr< LineProjector > _projector;
59 osg::Vec3d _startProjectedPoint;
60
61 osg::Vec4 _color;
62 osg::Vec4 _pickColor;
63
64 bool _checkForNodeInNodePath;
65};
66
67
68}
69
70#endif