osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarthUtil/FeatureEditing

Go to the documentation of this file.
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 
00020 #ifndef OSGEARTHUTIL_FEATUREEDITING_H
00021 #define OSGEARTHUTIL_FEATUREEDITING_H 1
00022 
00023 #include <osgEarthUtil/Common>
00024 #include <osgEarth/MapNode>
00025 #include <osgEarthFeatures/FeatureListSource>
00026 #include <osgGA/GUIEventHandler>
00027 #include <osgViewer/View>
00028 
00029 namespace osgEarth { namespace Util {
00030 
00034     struct OSGEARTHUTIL_EXPORT AddPointHandler : public osgGA::GUIEventHandler 
00035     {
00036     public:
00046         AddPointHandler(osgEarth::Features::Feature* feature, osgEarth::Features::FeatureListSource* source, const osgEarth::SpatialReference* mapSRS);
00047 
00048         bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa );
00049 
00053         void setMouseButton( osgGA::GUIEventAdapter::MouseButtonMask mouseButton);
00054 
00058         osgGA::GUIEventAdapter::MouseButtonMask getMouseButton() const;
00059 
00060         void setIntersectionMask( osg::Node::NodeMask intersectionMask ) { _intersectionMask = intersectionMask; }
00061         osg::Node::NodeMask getIntersectionMask() const { return _intersectionMask;}
00062 
00063 
00064     private:
00065         bool addPoint( float x, float y, osgViewer::View* view );
00066 
00067         osgGA::GUIEventAdapter::MouseButtonMask _mouseButton;
00068         bool _mouseDown;
00069         bool _firstMove;
00070         osg::ref_ptr< osgEarth::Features::FeatureListSource > _source;
00071         osg::ref_ptr< osgEarth::Features::Feature > _feature;
00072         osg::ref_ptr<const SpatialReference> _mapSRS;
00073         osg::Node::NodeMask _intersectionMask;
00074     };
00075 
00076     
00080     class OSGEARTHUTIL_EXPORT FeatureEditor : public osg::Group
00081     {
00082     public:
00092         FeatureEditor( osgEarth::Features::Feature* feature, osgEarth::Features::FeatureSource* source, osgEarth::MapNode* mapNode );
00093 
00097         const osg::Vec4f& getPickColor() const;
00098 
00102         void setPickColor( const osg::Vec4f& pickColor );
00103 
00107         const osg::Vec4f& getColor() const;
00108 
00112         void setColor( const osg::Vec4f& color );
00113 
00114 
00118         float getSize() const;
00119 
00123         void setSize( float size );
00124 
00125 
00126     protected:
00127         void init();
00128 
00129         osg::Vec4f _pickColor;
00130         osg::Vec4f _color;
00131         float _size;
00132 
00133         osg::ref_ptr< osgEarth::Features::Feature > _feature;
00134         osg::ref_ptr< osgEarth::Features::FeatureSource > _source;
00135         osg::ref_ptr< osgEarth::MapNode > _mapNode;
00136     };
00137 
00138 }}
00139 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines