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 <osgEarthSymbology/Symbol> 00020 00021 using namespace osgEarth; 00022 using namespace osgEarth::Symbology; 00023 00024 //------------------------------------------------------------------------ 00025 00026 Symbol::Symbol( const Config& conf ) 00027 { 00028 _uriContext = conf.uriContext(); 00029 } 00030 00031 //------------------------------------------------------------------------ 00032 00033 Stroke::Stroke() : 00034 _color( 1, 1, 1, 1 ), 00035 _lineCap( LINECAP_DEFAULT ), 00036 _lineJoin( LINEJOIN_DEFAULT ), 00037 _width( 1.0f ) 00038 { 00039 //nop 00040 } 00041 00042 Stroke::Stroke( float r, float g, float b, float a ) : 00043 _color( r, g, b, a ), 00044 _lineCap( LINECAP_DEFAULT ), 00045 _lineJoin( LINEJOIN_DEFAULT ), 00046 _width( 1.0f ) 00047 { 00048 //nop 00049 } 00050 00051 Config 00052 Stroke::getConfig() const { 00053 Config conf("stroke"); 00054 conf.add( "color", vec4fToHtmlColor(_color) ); 00055 conf.addIfSet("linecap", "butt", _lineCap, LINECAP_BUTT); 00056 conf.addIfSet("linecap", "square", _lineCap, LINECAP_SQUARE); 00057 conf.addIfSet("linecap", "round", _lineCap, LINECAP_ROUND); 00058 conf.addIfSet("width", _width); 00059 conf.addIfSet("stipple", _stipple); 00060 return conf; 00061 } 00062 00063 void 00064 Stroke::mergeConfig( const Config& conf ) { 00065 _color = htmlColorToVec4f( conf.value("color") ); 00066 conf.getIfSet("linecap", "butt", _lineCap, LINECAP_BUTT); 00067 conf.getIfSet("linecap", "square", _lineCap, LINECAP_SQUARE); 00068 conf.getIfSet("linecap", "round", _lineCap, LINECAP_ROUND); 00069 conf.getIfSet("width", _width); 00070 conf.getIfSet("stipple", _stipple); 00071 } 00072 00073 //------------------------------------------------------------------------ 00074 00075 Fill::Fill( float r, float g, float b, float a ) : 00076 _color( r, g, b, a ) 00077 { 00078 //nop 00079 } 00080 00081 Fill::Fill() : 00082 _color( 1, 1, 1, 1 ) 00083 { 00084 //nop 00085 } 00086 00087 Config 00088 Fill::getConfig() const 00089 { 00090 Config conf("fill"); 00091 conf.add("color", vec4fToHtmlColor(_color)); 00092 return conf; 00093 } 00094 00095 void 00096 Fill::mergeConfig( const Config& conf ) 00097 { 00098 _color = htmlColorToVec4f(conf.value("color")); 00099 }