osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarth/MapNode

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 OSGEARTH_MAPNODE_H
00021 #define OSGEARTH_MAPNODE_H 1
00022 
00023 #include <osgEarth/Common>
00024 #include <osgEarth/Map>
00025 #include <osgEarth/MapNodeOptions>
00026 #include <osgEarth/OverlayDecorator>
00027 #include <osgEarth/TerrainEngineNode>
00028 #include <osg/CoordinateSystemNode>
00029 #include <osgSim/OverlayNode>
00030 
00031 namespace osgEarth
00032 {
00037     class OSGEARTH_EXPORT MapNode : public osg::Group
00038     {
00039     public:
00040 
00041         class TileRangeData : public osg::Referenced
00042         {
00043         public:
00044             TileRangeData(double minRange, double maxRange):
00045               _minRange( minRange ),
00046               _maxRange( maxRange )
00047             {
00048             }
00049 
00050             double _minRange;
00051             double _maxRange;
00052         };
00053 
00057         MapNode();
00058 
00065         MapNode( const MapNodeOptions& options );
00066 
00073         MapNode( Map* map );
00074 
00083         MapNode( Map* map, const MapNodeOptions& options );
00084 
00088         static MapNode* load( class osg::ArgumentParser& arguments );
00089 
00090     public:
00091 
00092         virtual const char* libraryName() const { return "osgEarth"; }
00093         virtual const char* className() const { return "MapNode"; }
00094 
00098         Map* getMap();
00099 
00107         static MapNode* findMapNode( osg::Node* graph );   
00108 
00113         bool isGeocentric() const;
00114 
00118         osg::Group* getModelLayerGroup() const;
00119 
00123         void addTerrainDecorator( osg::Group* decorator );
00124 
00128         void removeTerrainDecorator( osg::Group* decorator );
00129 
00134         osg::Group* getOverlayGroup() { return _overlayModels.get(); }
00135         
00140         void updateOverlayGraph();
00141 
00146         const MapNodeOptions& getMapNodeOptions() const;
00147 
00151         TerrainEngineNode* getTerrainEngine() const;
00152 
00158         Config& externalConfig() { return _externalConf; }
00159         const Config& externalConfig() const { return _externalConf; }
00160 
00161     public: //override osg::Node
00162 
00163         virtual osg::BoundingSphere computeBound() const;
00164 
00165         virtual void traverse( class osg::NodeVisitor& nv );
00166 
00167     protected:    
00168 
00169         virtual ~MapNode();
00170 
00171     private:
00172 
00173         unsigned int _id;
00174         osg::ref_ptr<Map> _map;
00175         osg::ref_ptr< osg::Group > _models;
00176         osg::ref_ptr< osg::Group > _overlayModels;
00177         osg::ref_ptr< OverlayDecorator > _overlayDecorator;
00178         MapNodeOptions _mapNodeOptions;
00179         Config _externalConf;
00180 
00181         // keep track of nodes created by model layers
00182         typedef std::map<ModelLayer*,osg::Node*> ModelLayerNodeMap;
00183         ModelLayerNodeMap _modelLayerNodes;
00184         osg::Group* _maskLayerNode;
00185 
00186         osg::ref_ptr< osgSim::OverlayNode > _pendingOverlayNode;
00187         bool _pendingOverlayAutoSetTextureUnit;
00188 
00189         unsigned _lastNumBlacklistedFilenames;
00190 
00191         osg::ref_ptr<TerrainEngineNode> _terrainEngine;
00192         bool _terrainEngineInitialized;
00193 
00194         osg::ref_ptr<osg::Group> _terrainEngineContainer;
00195 
00196     public: // MapCallback proxy
00197 
00198         void onModelLayerAdded( ModelLayer*, unsigned int );
00199         void onModelLayerRemoved( ModelLayer* );
00200                 void onModelLayerMoved( ModelLayer* layer, unsigned int oldIndex, unsigned int newIndex );
00201 #if 0
00202         void onMaskLayerAdded( MaskLayer* );
00203         void onMaskLayerRemoved( MaskLayer* );
00204 #endif
00205 
00206     public:
00207         void onModelLayerOverlayChanged( ModelLayer* layer );
00208 
00209     private:
00210 
00211         osg::ref_ptr< ModelLayerCallback > _modelLayerCallback;
00212         osg::ref_ptr< MapCallback > _mapCallback;
00213     
00214         void init();
00215         void adjustEventTraversalCount( int delta );
00216     };
00217 
00218 } // namespace osgEarth
00219 
00220 #endif // OSGEARTH_MAPNODE_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines