osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarthDrivers/model_feature_stencil/FeatureStencilModelOptions

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 OSGEARTH_DRIVER_FEATURE_STENCIL_MODEL_OPTIONS
00020 #define OSGEARTH_DRIVER_FEATURE_STENCIL_MODEL_OPTIONS 1
00021 
00022 #include <osgEarth/Common>
00023 #include <osgEarthFeatures/FeatureModelSource>
00024 
00025 namespace osgEarth { namespace Drivers
00026 {
00027     using namespace osgEarth;
00028     using namespace osgEarth::Features;
00029 
00030     class FeatureStencilModelOptions : public FeatureModelSourceOptions // NO EXPORT; header only
00031     {
00032     public: // properties
00033 
00034         optional<double>& extrusionDistance() { return _extrusionDistance; }
00035         const optional<double>& extrusionDistance() const { return _extrusionDistance; }
00036 
00037         optional<double>& densificationThreshold() { return _densificationThreshold; }
00038         const optional<double>& densificationThreshold() const { return _densificationThreshold; }
00039 
00040         optional<bool>& inverted() { return _inverted; }
00041         const optional<bool>& inverted() const { return _inverted; }
00042 
00043         optional<bool>& mask() { return _mask; }
00044         const optional<bool>& mask() const { return _mask; }
00045 
00046         optional<bool>& showVolumes() { return _showVolumes; }
00047         const optional<bool>& showVolumes() const { return _showVolumes; }
00048 
00049     public:
00050         FeatureStencilModelOptions( const ConfigOptions& options =ConfigOptions() ) : FeatureModelSourceOptions( options ),
00051             _extrusionDistance( 300000 ),
00052             _densificationThreshold( 1000000 ),
00053             _inverted( false ),
00054             _mask( false ),
00055             _showVolumes( false )
00056         {
00057             setDriver( "feature_stencil" );
00058             fromConfig( _conf );
00059         }
00060 
00061     public:
00062         Config getConfig() const {
00063             Config conf = FeatureModelSourceOptions::getConfig();
00064             conf.updateIfSet( "extrusion_distance", _extrusionDistance );
00065             conf.updateIfSet( "densification_threshold", _densificationThreshold );
00066             conf.updateIfSet( "inverted", _inverted );
00067             conf.updateIfSet( "mask", _mask );               
00068             conf.updateIfSet( "showVolumes", _showVolumes );
00069             return conf;
00070         }
00071 
00072     protected:
00073         void mergeConfig( const Config& conf ) {
00074             FeatureModelSourceOptions::mergeConfig( conf );
00075             fromConfig( conf );
00076         }
00077 
00078     private:
00079         void fromConfig( const Config& conf ) {
00080             conf.getIfSet( "extrusion_distance", _extrusionDistance );
00081             conf.getIfSet( "densification_threshold", _densificationThreshold );
00082             conf.getIfSet( "inverted", _inverted );
00083             conf.getIfSet( "mask", _mask );
00084             conf.getIfSet( "show_volumes", _showVolumes );
00085 
00086             //special: you can also set mask=true by naming the config:
00087             if ( !_mask.isSet() && conf.key() == "mask_model" )
00088                 _mask = true;
00089         }
00090 
00091         optional<double> _extrusionDistance, _densificationThreshold;
00092         optional<bool> _inverted, _mask, _showVolumes;
00093     };
00094 
00095 } } // namespace osgEarth::Drivers
00096 
00097 #endif // OSGEARTH_DRIVER_FEATURE_STENCIL_MODEL_OPTIONS
00098 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines