osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarthUtil/Graticule

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 #ifndef OSGEARTHUTIL_GRATICLE
00020 #define OSGEARTHUTIL_GRATICLE
00021 
00022 #include <osgEarthUtil/Common>
00023 #include <osgEarth/Map>
00024 #include <osgEarthSymbology/Style>
00025 #include <vector>
00026 
00027 namespace osgEarth { namespace Util
00028 {
00029     using namespace osgEarth;
00030     using namespace osgEarth::Symbology;
00031 
00038     class OSGEARTHUTIL_EXPORT Graticule : public osg::Group
00039     {
00040     public:
00041 
00050         Graticule( const Map* map );
00051 
00055         void setLineColor( const osg::Vec4f& value );
00056 
00060         void setTextColor( const osg::Vec4f& value ) { _textColor = value; }
00061 
00073         void addLevel( float maxRange, unsigned int cellsX, unsigned int cellsY, double lineWidth );
00074 
00075 
00076     private:
00077         struct Level {
00078             float _maxRange;
00079             unsigned int _cellsX, _cellsY;
00080             double _lineWidth;
00081         };
00082 
00083         unsigned int getID() const { return _id; }
00084 
00085         bool getLevel( unsigned int level, Graticule::Level& out_level ) const;
00086 
00087         unsigned int getNumLevels() const { return _levels.size(); }
00088 
00089         unsigned int _id;
00090         bool _autoLevels;
00091         osg::observer_ptr<const Map> _map;
00092         std::vector<Level> _levels;
00093         osg::Vec4f _textColor;
00094         Style _lineStyle;
00095 
00096         osg::Node* createGridLevel( unsigned int levelNum ) const;
00097         osg::Node* createTextLevel( unsigned int levelNum ) const;
00098 
00099         friend class GraticuleFactory;
00100     };
00101 
00102 } } // namespace osgEarth::Util
00103 
00104 #endif // OSGEARTHUTIL_GRATICLE
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines