osgEarth 2.1.1
|
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 #include <osgEarthFeatures/LabelSource> 00020 00021 using namespace osgEarth; 00022 using namespace osgEarth::Features; 00023 using namespace osgEarth::Symbology; 00024 00025 #define LC "[LabelSource] " 00026 00027 00028 //------------------------------------------------------------------------ 00029 00030 void 00031 LabelSourceOptions::fromConfig( const Config& conf ) 00032 { 00033 //nop 00034 } 00035 00036 void 00037 LabelSourceOptions::mergeConfig( const Config& conf ) 00038 { 00039 DriverConfigOptions::mergeConfig( conf ); 00040 fromConfig( conf ); 00041 } 00042 00043 Config 00044 LabelSourceOptions::getConfig() const 00045 { 00046 Config conf = DriverConfigOptions::getConfig(); 00047 return conf; 00048 } 00049 00050 //------------------------------------------------------------------------ 00051 00052 #undef LC 00053 #define LC "[LabeSourceFactory] " 00054 #define LABEL_SOURCE_OPTIONS_TAG "__osgEarth::Features::LabelSourceOptions" 00055 00056 LabelSource* 00057 LabelSourceFactory::create( const LabelSourceOptions& options ) 00058 { 00059 LabelSource* labelSource = 0L; 00060 00061 if ( !options.getDriver().empty() ) 00062 { 00063 std::string driverExt = std::string(".osgearth_label_") + options.getDriver(); 00064 00065 osg::ref_ptr<osgDB::ReaderWriter::Options> rwopts = new osgDB::ReaderWriter::Options(); 00066 rwopts->setPluginData( LABEL_SOURCE_OPTIONS_TAG, (void*)&options ); 00067 00068 labelSource = dynamic_cast<LabelSource*>( osgDB::readObjectFile( driverExt, rwopts.get() ) ); 00069 if ( labelSource ) 00070 { 00071 //modelSource->setName( options.getName() ); 00072 OE_INFO << "Loaded LabelSource driver \"" << options.getDriver() << "\" OK" << std::endl; 00073 } 00074 else 00075 { 00076 OE_WARN << "FAIL, unable to load label source driver for \"" << options.getDriver() << "\"" << std::endl; 00077 } 00078 } 00079 else 00080 { 00081 OE_WARN << LC << "FAIL, illegal null driver specification" << std::endl; 00082 } 00083 00084 return labelSource; 00085 } 00086 00087 //------------------------------------------------------------------------ 00088 00089 const LabelSourceOptions& 00090 LabelSourceDriver::getLabelSourceOptions( const osgDB::ReaderWriter::Options* options ) const 00091 { 00092 return *static_cast<const LabelSourceOptions*>( options->getPluginData( LABEL_SOURCE_OPTIONS_TAG ) ); 00093 }