osgEarth 2.1.1
|
00001 /* -*-c++-*- */ 00002 /* osgEarth - Dynamic map generation toolkit for OpenSceneGraph 00003 * Copyright 2008-2010 Pelican Mapping 00004 * http://osgearth.org 00005 * 00006 * osgEarth is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU Lesser General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public License 00017 * along with this program. If not, see <http://www.gnu.org/licenses/> 00018 */ 00019 #ifndef OSGEARTHUTIL_DRAGGERS 00020 #define OSGEARTHUTIL_DRAGGERS 00021 00022 #include <osg/ShapeDrawable> 00023 #include <osgEarthUtil/Common> 00024 00025 00026 #include <osgManipulator/Dragger> 00027 #include <osgManipulator/Command> 00028 00029 namespace osgEarth { namespace Util { 00030 00031 00032 class OSGEARTHUTIL_EXPORT TranslateCommand : public osgManipulator::MotionCommand 00033 { 00034 public: 00035 TranslateCommand(); 00036 inline const osg::Vec3d& getTranslation() const { return _translation;} 00037 inline void setTranslation( const osg::Vec3d &translation ) { _translation = translation;} 00038 virtual osgManipulator::MotionCommand* createCommandInverse(); 00039 00040 virtual osg::Matrix getMotionMatrix() const; 00041 00042 protected: 00043 virtual ~TranslateCommand(); 00044 osg::Vec3d _translation; 00045 }; 00046 00047 class OSGEARTHUTIL_EXPORT IntersectingDragger : public osgManipulator::Dragger 00048 { 00049 public: 00050 IntersectingDragger(); 00051 00052 virtual void setupDefaultGeometry(); 00053 00055 virtual bool handle(const osgManipulator::PointerInfo& pi, const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us); 00056 00057 void setNode(osg::Node* node) { _node = node;} 00058 osg::Node* getNode() const { return _node.get(); } 00059 00061 inline void setColor(const osg::Vec4& color) { _color = color; } 00062 00063 inline const osg::Vec4& getColor() const { return _color; } 00064 00067 inline void setPickColor(const osg::Vec4& color) { _pickColor = color; } 00068 inline const osg::Vec4& getPickColor() const { return _pickColor; } 00069 00073 inline float getSize() const { return _size;} 00074 00078 inline void setSize( float size ) { _size = size; } 00079 00080 virtual bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa); 00081 00082 protected: 00083 00084 bool getHit(const osg::Vec3d &start, const osg::Vec3d &end, osg::Vec3d &intersection); 00085 void setDrawableColor(const osg::Vec4f& color); 00086 00087 virtual ~IntersectingDragger(); 00088 00089 osg::Vec4 _color; 00090 osg::Vec4 _pickColor; 00091 osg::Vec3d _startPoint; 00092 float _size; 00093 osg::Matrixd _localToWorld; 00094 osg::Matrixd _worldToLocal; 00095 00096 osg::ref_ptr< osg::ShapeDrawable > _shapeDrawable; 00097 00098 osg::ref_ptr< osg::Node > _node; 00099 }; 00100 00101 00102 } } 00103 00104 00105 #endif