diff --git a/bindings/python/mapnik_polygon_pattern_symbolizer.cpp b/bindings/python/mapnik_polygon_pattern_symbolizer.cpp index 3ae556c55..54f1feaf2 100644 --- a/bindings/python/mapnik_polygon_pattern_symbolizer.cpp +++ b/bindings/python/mapnik_polygon_pattern_symbolizer.cpp @@ -80,7 +80,7 @@ struct polygon_pattern_symbolizer_pickle_suite : boost::python::pickle_suite p.set_alignment(extract(state[0])); p.set_gamma(extract(state[1])); - p.set_gamma_method(extract(state[2])); + p.set_gamma_method(extract(state[2])); } }; @@ -93,14 +93,7 @@ void export_polygon_pattern_symbolizer() .value("LOCAL",LOCAL_ALIGNMENT) .value("GLOBAL",GLOBAL_ALIGNMENT) ; - enumeration_("gamma_method") - .value("POWER", POLYGON_PATTERN_GAMMA_POWER) - .value("LINEAR", POLYGON_PATTERN_GAMMA_LINEAR) - .value("NONE", POLYGON_PATTERN_GAMMA_NONE) - .value("THRESHOLD", POLYGON_PATTERN_GAMMA_THRESHOLD) - .value("MULTIPLY", POLYGON_PATTERN_GAMMA_MULTIPLY) - ; - + class_("PolygonPatternSymbolizer", init("")) .def_pickle(polygon_pattern_symbolizer_pickle_suite()) diff --git a/bindings/python/mapnik_polygon_symbolizer.cpp b/bindings/python/mapnik_polygon_symbolizer.cpp index 09c7591dc..040ad4707 100644 --- a/bindings/python/mapnik_polygon_symbolizer.cpp +++ b/bindings/python/mapnik_polygon_symbolizer.cpp @@ -58,7 +58,7 @@ struct polygon_symbolizer_pickle_suite : boost::python::pickle_suite p.set_opacity(extract(state[0])); p.set_gamma(extract(state[1])); - p.set_gamma_method(extract(state[2])); + p.set_gamma_method(extract(state[2])); } }; @@ -66,15 +66,7 @@ struct polygon_symbolizer_pickle_suite : boost::python::pickle_suite void export_polygon_symbolizer() { using namespace boost::python; - - enumeration_("gamma_method") - .value("POWER", POLYGON_GAMMA_POWER) - .value("LINEAR", POLYGON_GAMMA_LINEAR) - .value("NONE", POLYGON_GAMMA_NONE) - .value("THRESHOLD", POLYGON_GAMMA_THRESHOLD) - .value("MULTIPLY", POLYGON_GAMMA_MULTIPLY) - ; - + class_("PolygonSymbolizer", init<>("Default PolygonSymbolizer - solid fill grey")) .def(init("TODO")) diff --git a/bindings/python/mapnik_python.cpp b/bindings/python/mapnik_python.cpp index 37b1b926f..af4d0c836 100644 --- a/bindings/python/mapnik_python.cpp +++ b/bindings/python/mapnik_python.cpp @@ -37,6 +37,7 @@ void export_geometry(); void export_palette(); void export_image(); void export_image_view(); +void export_gamma_method(); void export_grid(); void export_grid_view(); void export_map(); @@ -407,6 +408,7 @@ BOOST_PYTHON_MODULE(_mapnik) export_palette(); export_image(); export_image_view(); + export_gamma_method(); export_grid(); export_grid_view(); export_expression(); diff --git a/bindings/python/mapnik_stroke.cpp b/bindings/python/mapnik_stroke.cpp index 09f2a7027..637c32b94 100644 --- a/bindings/python/mapnik_stroke.cpp +++ b/bindings/python/mapnik_stroke.cpp @@ -126,14 +126,7 @@ void export_stroke () .value("ROUND_JOIN",ROUND_JOIN) .value("BEVEL_JOIN",BEVEL_JOIN) ; - enumeration_("gamma_method") - .value("POWER", GAMMA_POWER) - .value("LINEAR", GAMMA_LINEAR) - .value("NONE", GAMMA_NONE) - .value("THRESHOLD", GAMMA_THRESHOLD) - .value("MULTIPLY", GAMMA_MULTIPLY) - ; - + class_("Stroke",init<>( "Creates a new default black stroke with the width of 1.\n")) .def(init( diff --git a/include/mapnik/polygon_pattern_symbolizer.hpp b/include/mapnik/polygon_pattern_symbolizer.hpp index cdc485596..f886cae1e 100644 --- a/include/mapnik/polygon_pattern_symbolizer.hpp +++ b/include/mapnik/polygon_pattern_symbolizer.hpp @@ -26,6 +26,7 @@ // mapnik #include #include +#include namespace mapnik { @@ -38,17 +39,6 @@ enum pattern_alignment_enum { DEFINE_ENUM( pattern_alignment_e, pattern_alignment_enum ); -enum polygon_pattern_gamma_method_enum { - POLYGON_PATTERN_GAMMA_POWER, //agg::gamma_power - POLYGON_PATTERN_GAMMA_LINEAR, //agg::gamma_linear - POLYGON_PATTERN_GAMMA_NONE, //agg::gamma_none - POLYGON_PATTERN_GAMMA_THRESHOLD, //agg::gamma_threshold - POLYGON_PATTERN_GAMMA_MULTIPLY, //agg::gamma_multiply - polygon_pattern_gamma_method_enum_MAX -}; - -DEFINE_ENUM( polygon_pattern_gamma_method_e, polygon_pattern_gamma_method_enum ); - struct MAPNIK_DECL polygon_pattern_symbolizer : public symbolizer_with_image, public symbolizer_base { @@ -58,13 +48,13 @@ struct MAPNIK_DECL polygon_pattern_symbolizer : void set_alignment(pattern_alignment_e align); void set_gamma(double gamma); double get_gamma() const; - void set_gamma_method(polygon_pattern_gamma_method_e gamma_method); - polygon_pattern_gamma_method_e get_gamma_method() const; + void set_gamma_method(gamma_method_e gamma_method); + gamma_method_e get_gamma_method() const; private: pattern_alignment_e alignment_; double gamma_; - polygon_pattern_gamma_method_e gamma_method_; + gamma_method_e gamma_method_; }; } diff --git a/include/mapnik/polygon_symbolizer.hpp b/include/mapnik/polygon_symbolizer.hpp index 7bee50d91..d9edf2eb0 100644 --- a/include/mapnik/polygon_symbolizer.hpp +++ b/include/mapnik/polygon_symbolizer.hpp @@ -28,44 +28,34 @@ #include #include #include - +#include // stl #include namespace mapnik { -enum polygon_gamma_method_enum { - POLYGON_GAMMA_POWER, //agg::gamma_power - POLYGON_GAMMA_LINEAR, //agg::gamma_linear - POLYGON_GAMMA_NONE, //agg::gamma_none - POLYGON_GAMMA_THRESHOLD, //agg::gamma_threshold - POLYGON_GAMMA_MULTIPLY, //agg::gamma_multiply - polygon_gamma_method_enum_MAX -}; - -DEFINE_ENUM( polygon_gamma_method_e, polygon_gamma_method_enum ); - struct MAPNIK_DECL polygon_symbolizer : public symbolizer_base { - explicit polygon_symbolizer() + polygon_symbolizer() : symbolizer_base(), fill_(color(128,128,128)), opacity_(1.0), gamma_(1.0), - gamma_method_(POLYGON_GAMMA_POWER) {} - + gamma_method_(GAMMA_POWER) {} + polygon_symbolizer(color const& fill) : symbolizer_base(), fill_(fill), opacity_(1.0), gamma_(1.0), - gamma_method_(POLYGON_GAMMA_POWER) {} - + gamma_method_(GAMMA_POWER) {} + color const& get_fill() const { return fill_; } + void set_fill(color const& fill) { fill_ = fill; @@ -86,11 +76,11 @@ struct MAPNIK_DECL polygon_symbolizer : public symbolizer_base { return gamma_; } - void set_gamma_method(polygon_gamma_method_e gamma_method) + void set_gamma_method(gamma_method_e gamma_method) { gamma_method_ = gamma_method; } - polygon_gamma_method_e get_gamma_method() const + gamma_method_e get_gamma_method() const { return gamma_method_; } @@ -99,7 +89,7 @@ private: color fill_; double opacity_; double gamma_; - polygon_gamma_method_e gamma_method_; + gamma_method_e gamma_method_; }; struct MAPNIK_DECL building_symbolizer : public symbolizer_base diff --git a/include/mapnik/stroke.hpp b/include/mapnik/stroke.hpp index 653fc4516..9d1b77492 100644 --- a/include/mapnik/stroke.hpp +++ b/include/mapnik/stroke.hpp @@ -25,6 +25,7 @@ // mapnik #include +#include #include // stl @@ -61,17 +62,6 @@ enum line_join_enum DEFINE_ENUM( line_join_e, line_join_enum ); -enum gamma_method_enum { - GAMMA_POWER, //agg::gamma_power - GAMMA_LINEAR, //agg::gamma_linear - GAMMA_NONE, //agg::gamma_none - GAMMA_THRESHOLD, //agg::gamma_threshold - GAMMA_MULTIPLY, //agg::gamma_multiply - gamma_method_enum_MAX -}; - -DEFINE_ENUM( gamma_method_e, gamma_method_enum ); - class MAPNIK_DECL stroke { color c_; diff --git a/src/build.py b/src/build.py index bc7992945..f16059935 100644 --- a/src/build.py +++ b/src/build.py @@ -113,6 +113,7 @@ source = Split( feature_type_style.cpp font_engine_freetype.cpp font_set.cpp + gamma_method.cpp gradient.cpp graphics.cpp image_reader.cpp diff --git a/src/gamma_method.cpp b/src/gamma_method.cpp new file mode 100644 index 000000000..c3e81b6bb --- /dev/null +++ b/src/gamma_method.cpp @@ -0,0 +1,42 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2011 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +//$Id$ + +// mapnik +#include + +namespace mapnik +{ + +static const char * gamma_method_strings[] = { + "power", //agg::gamma_power + "linear", //agg::gamma_linear + "none", //agg::gamma_none + "threshold", //agg::gamma_threshold + "multiply", //agg::gamma_multiply", + "" +}; + +IMPLEMENT_ENUM( gamma_method_e, gamma_method_strings ) + +} diff --git a/src/load_map.cpp b/src/load_map.cpp index 22b9e1f8b..41c07c1d4 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -1217,7 +1217,7 @@ void map_parser::parse_polygon_pattern_symbolizer( rule & rule, if (gamma) symbol.set_gamma(*gamma); // gamma method - optional gamma_method = get_opt_attr(sym, "gamma-method"); + optional gamma_method = get_opt_attr(sym, "gamma-method"); if (gamma_method) symbol.set_gamma_method(*gamma_method); parse_metawriter_in_symbolizer(symbol, sym); @@ -1894,7 +1894,7 @@ void map_parser::parse_polygon_symbolizer( rule & rule, ptree const & sym ) optional gamma = get_opt_attr(sym, "gamma"); if (gamma) poly_sym.set_gamma(*gamma); // gamma method - optional gamma_method = get_opt_attr(sym, "gamma-method"); + optional gamma_method = get_opt_attr(sym, "gamma-method"); if (gamma_method) poly_sym.set_gamma_method(*gamma_method); parse_metawriter_in_symbolizer(poly_sym, sym); diff --git a/src/polygon_pattern_symbolizer.cpp b/src/polygon_pattern_symbolizer.cpp index f3b279b9c..511354248 100644 --- a/src/polygon_pattern_symbolizer.cpp +++ b/src/polygon_pattern_symbolizer.cpp @@ -35,22 +35,11 @@ static const char * pattern_alignment_strings[] = { IMPLEMENT_ENUM( pattern_alignment_e, pattern_alignment_strings ) -static const char * polygon_pattern_gamma_method_strings[] = { - "power", //agg::gamma_power - "linear", //agg::gamma_linear - "none", //agg::gamma_none - "threshold", //agg::gamma_threshold - "multiply", //agg::gamma_multiply", - "" -}; - -IMPLEMENT_ENUM( polygon_pattern_gamma_method_e, polygon_pattern_gamma_method_strings ) - polygon_pattern_symbolizer::polygon_pattern_symbolizer(path_expression_ptr file) : symbolizer_with_image(file), symbolizer_base(), alignment_(LOCAL_ALIGNMENT), gamma_(1.0), - gamma_method_(POLYGON_PATTERN_GAMMA_POWER) {} + gamma_method_(GAMMA_POWER) {} polygon_pattern_symbolizer::polygon_pattern_symbolizer(polygon_pattern_symbolizer const& rhs) : symbolizer_with_image(rhs), symbolizer_base(rhs), @@ -78,12 +67,12 @@ void polygon_pattern_symbolizer::set_gamma(double gamma) gamma_ = gamma; } -void polygon_pattern_symbolizer::set_gamma_method(polygon_pattern_gamma_method_e gamma_method) +void polygon_pattern_symbolizer::set_gamma_method(gamma_method_e gamma_method) { gamma_method_ = gamma_method; } -polygon_pattern_gamma_method_e polygon_pattern_symbolizer::get_gamma_method() const +gamma_method_e polygon_pattern_symbolizer::get_gamma_method() const { return gamma_method_; } diff --git a/src/polygon_symbolizer.cpp b/src/polygon_symbolizer.cpp index d5e7fe572..380473d7b 100644 --- a/src/polygon_symbolizer.cpp +++ b/src/polygon_symbolizer.cpp @@ -27,17 +27,5 @@ namespace mapnik { -static const char * polygon_gamma_method_strings[] = { - "power", //agg::gamma_power - "linear", //agg::gamma_linear - "none", //agg::gamma_none - "threshold", //agg::gamma_threshold - "multiply", //agg::gamma_multiply", - "" -}; - - -IMPLEMENT_ENUM( polygon_gamma_method_e, polygon_gamma_method_strings ) - } diff --git a/src/stroke.cpp b/src/stroke.cpp index 7484b3e36..95cb632f2 100644 --- a/src/stroke.cpp +++ b/src/stroke.cpp @@ -46,18 +46,6 @@ static const char * line_join_strings[] = { IMPLEMENT_ENUM( line_join_e, line_join_strings ) -static const char * gamma_method_strings[] = { - "power", //agg::gamma_power - "linear", //agg::gamma_linear - "none", //agg::gamma_none - "threshold", //agg::gamma_threshold - "multiply", //agg::gamma_multiply", - "" -}; - -IMPLEMENT_ENUM( gamma_method_e, gamma_method_strings ) - - stroke::stroke() : c_(0,0,0), width_(1.0),