Translate2DDragger 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #ifndef OSGMANIPULATOR_TRANSLATE2DDRAGGER
  15. #define OSGMANIPULATOR_TRANSLATE2DDRAGGER 1
  16. #include <osgManipulator/Dragger>
  17. #include <osgManipulator/Projector>
  18. #include <osg/PolygonOffset>
  19. namespace osgManipulator {
  20. /**
  21. * Dragger for performing 2D translation.
  22. */
  23. class OSGMANIPULATOR_EXPORT Translate2DDragger : public Dragger
  24. {
  25. public:
  26. Translate2DDragger();
  27. Translate2DDragger(const osg::Plane& plane);
  28. META_OSGMANIPULATOR_Object(osgManipulator,Translate2DDragger)
  29. /** Handle pick events on dragger and generate TranslateInLine commands. */
  30. virtual bool handle(const PointerInfo& pi, const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us);
  31. /** Setup default geometry for dragger. */
  32. void setupDefaultGeometry();
  33. /** Set/Get color for dragger. */
  34. inline void setColor(const osg::Vec4& color) { _color = color; setMaterialColor(_color,*this); }
  35. inline const osg::Vec4& getColor() const { return _color; }
  36. /** Set/Get pick color for dragger. Pick color is color of the dragger when picked.
  37. It gives a visual feedback to show that the dragger has been picked. */
  38. inline void setPickColor(const osg::Vec4& color) { _pickColor = color; }
  39. inline const osg::Vec4& getPickColor() const { return _pickColor; }
  40. protected:
  41. virtual ~Translate2DDragger();
  42. osg::ref_ptr< PlaneProjector > _projector;
  43. osg::Vec3d _startProjectedPoint;
  44. osg::Vec4 _color;
  45. osg::Vec4 _pickColor;
  46. osg::ref_ptr<osg::PolygonOffset> _polygonOffset;
  47. };
  48. }
  49. #endif