osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarthSymbology/MarkerSymbol.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 #include <osgEarthSymbology/MarkerSymbol>
00020 
00021 using namespace osgEarth;
00022 using namespace osgEarth::Symbology;
00023 
00024 MarkerSymbol::MarkerSymbol( const Config& conf ) :
00025 Symbol     ( conf ),
00026 _placement ( PLACEMENT_CENTROID ),
00027 _density   ( 25.0f ),
00028 _randomSeed( 0 )
00029 {
00030     mergeConfig( conf );
00031 }
00032 
00033 Config 
00034 MarkerSymbol::getConfig() const
00035 {
00036     Config conf = Symbol::getConfig();
00037     conf.key() = "marker";
00038     conf.addObjIfSet( "url", _url );
00039     conf.addObjIfSet( "scale", _scale );
00040     conf.addIfSet( "placement", "vertex",   _placement, PLACEMENT_VERTEX );
00041     conf.addIfSet( "placement", "interval", _placement, PLACEMENT_INTERVAL );
00042     conf.addIfSet( "placement", "random",   _placement, PLACEMENT_RANDOM );
00043     conf.addIfSet( "density", _density );
00044     conf.addIfSet( "random_seed", _randomSeed );
00045     conf.addNonSerializable( "MarkerSymbol::image", _image.get() );
00046     conf.addNonSerializable( "MarkerSymbol::node", _node.get() );
00047     return conf;
00048 }
00049 
00050 void 
00051 MarkerSymbol::mergeConfig( const Config& conf )
00052 {
00053     conf.getObjIfSet( "url", _url );
00054     conf.getObjIfSet( "scale", _scale );
00055     conf.getIfSet( "placement", "vertex",   _placement, PLACEMENT_VERTEX );
00056     conf.getIfSet( "placement", "interval", _placement, PLACEMENT_INTERVAL );
00057     conf.getIfSet( "placement", "random",   _placement, PLACEMENT_RANDOM );
00058     conf.getIfSet( "density", _density );
00059     conf.getIfSet( "random_seed", _randomSeed );
00060     _image = conf.getNonSerializable<osg::Image>( "MarkerSymbol::image" );
00061     _node = conf.getNonSerializable<osg::Node>( "MarkerSymbol::node" );
00062 }
00063 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines