osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarthUtil/Annotation

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_ANNOTATION
00021 #define OSGEARTHUTIL_ANNOTATION
00022 
00023 #include <osgEarth/MapNode>
00024 #include <osgEarth/GeoMath>
00025 #include <osgEarth/DrapeableNode>
00026 #include <osgEarthFeatures/Feature>
00027 #include <osgEarthFeatures/FeatureNode>
00028 #include <osgEarthSymbology/Geometry>
00029 #include <osgEarthSymbology/Style>
00030 #include <osgEarthUtil/Common>
00031 #include <osgEarthUtil/Controls>
00032 #include <osgEarthUtil/Viewpoint>
00033 #include <osg/MatrixTransform>
00034 
00035 namespace osgEarth { namespace Util { namespace Annotation
00036 {       
00037     using namespace osgEarth;
00038     using namespace osgEarth::Features;
00039     using namespace osgEarth::Symbology;
00040     using namespace osgEarth::Util::Controls;
00041 
00046     class AnnotationData : public osg::Referenced
00047     {
00048     public:
00049         AnnotationData()
00050             : _viewpoint( 0L ) { }
00051 
00052     public:
00056         void setName( const std::string& value ) { _name = value; }
00057         const std::string& getName() const { return _name; }
00058 
00062         void setDescription( const std::string& value ) { _description = value; }
00063         const std::string& getDescription() const { return _description; }
00064 
00068         void setViewpoint( const Viewpoint& vp ) {
00069             if ( _viewpoint )
00070                 delete _viewpoint;
00071             _viewpoint = new Viewpoint(vp);
00072         }
00073 
00074         const Viewpoint* getViewpoint() const {
00075             return _viewpoint;
00076         }
00077 
00078     public:
00079         virtual ~AnnotationData() {
00080             if ( _viewpoint )
00081                 delete _viewpoint;
00082         }
00083 
00084     protected:
00085         std::string _name;
00086         std::string _description;
00087         Viewpoint*  _viewpoint;
00088     };
00089 
00094     class OSGEARTHUTIL_EXPORT PlacemarkNode : public osg::MatrixTransform
00095     {
00096     public:
00100         PlacemarkNode(
00101             MapNode*           mapNode,
00102             const osg::Vec3d&  position,
00103             osg::Image*        iconImage,
00104             const std::string& labelText,
00105             const Style&       style =Style() );
00106 
00111         void setPosition( const osg::Vec3d& mapPosition );
00112 
00116         void setIconImage( osg::Image* image );
00117         osg::Image* getIconImage() const { return _image.get(); }
00118 
00122         void setText( const std::string& text );
00123         const std::string& getText() const { return _text; }
00124 
00128         void setStyle( const Style& style );
00129         const Style& getStyle() const { return _style; }
00130 
00131     private:
00132         osg::ref_ptr<osg::Image>   _image;
00133         std::string                _text;
00134         Style                      _style;
00135 
00136         osg::ref_ptr<Container>    _container;
00137         osg::ref_ptr<ImageControl> _icon;
00138         osg::ref_ptr<LabelControl> _label;
00139 
00140         osg::observer_ptr<MapNode> _mapNode;
00141 
00142         void init();
00143     };
00144 
00151     class OSGEARTHUTIL_EXPORT GeometryNode : public DrapeableNode
00152     {
00153     public:
00154         GeometryNode( Geometry* geom, const Style& style );
00155 
00156         GeometryNode( MapNode* mapNode, Geometry* geom, const Style& style, bool draped =true );
00157 
00162         template<typename T>
00163         T* getOrCreateParent()
00164         {
00165             if ( _parent.valid() )
00166             {
00167                 return static_cast<T*>( _parent.get() );
00168             }
00169             else
00170             {
00171                 T* p = new T();
00172                 _parent = p;
00173                 if ( getNode() )
00174                 {
00175                     p->addChild( getNode() );
00176                     setNode( _parent.get() );
00177                 }
00178                 return p;
00179             }
00180         }
00181 
00182     protected:
00183         void init();
00184 
00185         osg::ref_ptr<Geometry>   _geom;
00186         Style                    _style;
00187         osg::ref_ptr<osg::Group> _parent;
00188     };
00189 
00193     class OSGEARTHUTIL_EXPORT CircleNode : public FeatureNode 
00194     {
00195     public:
00196         CircleNode( 
00197             MapNode*                mapNode,
00198             const osg::Vec3d&       center,
00199             const Linear&           radius,
00200             const Style&            style,
00201             bool                    draped      =true,
00202             unsigned                numSegments =0 );
00203     };
00204 
00208     class OSGEARTHUTIL_EXPORT EllipseNode : public FeatureNode
00209     {
00210     public:
00211         EllipseNode( 
00212             MapNode*                mapNode,
00213             const osg::Vec3d&       center,
00214             const Linear&           radiusMajor,
00215             const Linear&           radiusMinor,
00216             const Angular&          rotationAngle,
00217             const Style&            style,
00218             bool                    draped      =true,
00219             unsigned                numSegments =0 );
00220     };
00221 
00222 } } } // namespace osgEarth::Util::Annotation
00223 
00224 #endif //OSGEARTHUTIL_ANNOTATION
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines