osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarthDrivers/engine_seamless/SeamlessEngineNode.cpp

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 #include "SeamlessEngineNode"
00021 #include "Geographic"
00022 #include "Projected"
00023 
00024 namespace seamless
00025 {
00026 using namespace osgEarth;
00027 
00028 // adapter that lets SeamlessEngineNode listen to Map events
00029 // This should be a template or something.
00030 struct SeamlessMapProxy : public MapCallback
00031 {
00032     SeamlessMapProxy(SeamlessEngineNode* node) : _node(node) { }
00033     osg::observer_ptr<SeamlessEngineNode> _node;
00034 
00035     void onMapProfileEstablished( const Profile* profile ) {
00036         _node->onMapProfileEstablished(profile);
00037     }
00038     void onImageLayerAdded( ImageLayer* layer, unsigned int index ) {
00039         _node->onImageLayerAdded(layer, index);
00040     }
00041     void onImageLayerRemoved( ImageLayer* layer, unsigned int index ) {
00042         _node->onImageLayerRemoved(layer, index);
00043     }
00044     void onImageLayerMoved( ImageLayer* layer, unsigned int oldIndex, unsigned int newIndex ) {
00045         _node->onImageLayerMoved(layer,oldIndex,newIndex);
00046     }
00047     void onElevationLayerAdded( ElevationLayer* layer, unsigned int index ) {
00048         _node->onElevationLayerAdded(layer, index);
00049     }
00050     void onElevationLayerRemoved( ElevationLayer* layer, unsigned int index ) {
00051         _node->onElevationLayerRemoved(layer, index);
00052     }
00053     void onElevationLayerMoved( ElevationLayer* layer, unsigned int oldIndex, unsigned int newIndex ) {
00054         _node->onElevationLayerMoved(layer,oldIndex,newIndex);
00055     }
00056 };
00057 
00058 SeamlessEngineNode::SeamlessEngineNode()
00059     : _mapf(0)
00060 {
00061 }
00062 
00063 SeamlessEngineNode::SeamlessEngineNode(const SeamlessEngineNode& rhs,
00064                        const osg::CopyOp& op)
00065     : TerrainEngineNode(rhs, op),
00066       _terrainOptions(rhs._terrainOptions), _mapf(0)
00067 {
00068     _patchSet = static_cast<PatchSet*>(op(rhs._patchSet.get()));
00069     
00070 }
00071 
00072 SeamlessEngineNode::~SeamlessEngineNode()
00073 {
00074     delete _mapf;
00075 }
00076 
00077 void SeamlessEngineNode::preInitialize(const Map* map, const TerrainOptions& options)
00078 {
00079     TerrainEngineNode::preInitialize(map, options);
00080     _mapf = new MapFrame(map, Map::TERRAIN_LAYERS, "seamless");
00081     _terrainOptions.merge(options);
00082     if (map->getProfile())
00083         onMapProfileEstablished(map->getProfile());
00084     map->addMapCallback(new SeamlessMapProxy(this));
00085 }
00086 
00087 void SeamlessEngineNode::validateTerrainOptions(TerrainOptions& options)
00088 {
00089 }
00090 
00091 void SeamlessEngineNode::onMapProfileEstablished(const Profile* mapProfile)
00092 {
00093     const Map* map = getMap();
00094     int resolution = _terrainOptions.resolution().value();
00095     if (map->getMapOptions().coordSysType() == MapOptions::CSTYPE_GEOCENTRIC)
00096         _patchSet = new Geographic(map, _terrainOptions);
00097     else if (map->getMapOptions().coordSysType()
00098              == MapOptions::CSTYPE_PROJECTED)
00099         _patchSet = new Projected(map, _terrainOptions);
00100     else
00101     {
00102         OE_WARN << "map is not projected\n";
00103         return;
00104     }
00105     addChild(_patchSet
00106              ->createPatchSetGraph("bar.osgearth_engine_seamless_patch"));
00107 }
00108 
00109 void SeamlessEngineNode::onImageLayerAdded(ImageLayer*, unsigned int index)
00110 {
00111 }
00112 
00113 void SeamlessEngineNode::onImageLayerRemoved(ImageLayer* layer,
00114                                              unsigned int index)
00115 {
00116 }
00117 
00118 void SeamlessEngineNode::onImageLayerMoved(ImageLayer* layer,
00119                                            unsigned int oldIndex,
00120                                            unsigned int newIndex)
00121 {
00122 }
00123 
00124 void SeamlessEngineNode::onElevationLayerAdded(ElevationLayer* layer,
00125                                                unsigned int index)
00126 {
00127 }
00128 
00129 void SeamlessEngineNode::onElevationLayerRemoved(ElevationLayer* layer,
00130                                                  unsigned int index)
00131 {
00132 }
00133 
00134 void SeamlessEngineNode::onElevationLayerMoved(ElevationLayer* layer,
00135                                                unsigned int oldIndex,
00136                                                unsigned int newIndex)
00137 {
00138 }
00139 
00140 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines