Merge branch 'master' into feature_impl
This commit is contained in:
commit
a6a540cb68
18 changed files with 302 additions and 37 deletions
|
@ -62,17 +62,17 @@ struct polygon_pattern_symbolizer_pickle_suite : boost::python::pickle_suite
|
|||
static boost::python::tuple
|
||||
getstate(const polygon_pattern_symbolizer& p)
|
||||
{
|
||||
return boost::python::make_tuple(p.get_alignment(),p.get_gamma());
|
||||
return boost::python::make_tuple(p.get_alignment(),p.get_gamma(),p.get_gamma_method());
|
||||
}
|
||||
|
||||
static void
|
||||
setstate (polygon_pattern_symbolizer& p, boost::python::tuple state)
|
||||
{
|
||||
using namespace boost::python;
|
||||
if (len(state) != 2)
|
||||
if (len(state) != 3)
|
||||
{
|
||||
PyErr_SetObject(PyExc_ValueError,
|
||||
("expected 2-item tuple in call to __setstate__; got %s"
|
||||
("expected 3-item tuple in call to __setstate__; got %s"
|
||||
% state).ptr()
|
||||
);
|
||||
throw_error_already_set();
|
||||
|
@ -80,6 +80,7 @@ struct polygon_pattern_symbolizer_pickle_suite : boost::python::pickle_suite
|
|||
|
||||
p.set_alignment(extract<pattern_alignment_e>(state[0]));
|
||||
p.set_gamma(extract<float>(state[1]));
|
||||
p.set_gamma_method(extract<polygon_pattern_gamma_method_e>(state[2]));
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -92,6 +93,13 @@ void export_polygon_pattern_symbolizer()
|
|||
.value("LOCAL",LOCAL_ALIGNMENT)
|
||||
.value("GLOBAL",GLOBAL_ALIGNMENT)
|
||||
;
|
||||
enumeration_<polygon_pattern_gamma_method_e>("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_<polygon_pattern_symbolizer>("PolygonPatternSymbolizer",
|
||||
init<path_expression_ptr>("<path_expression_ptr>"))
|
||||
|
@ -109,5 +117,9 @@ void export_polygon_pattern_symbolizer()
|
|||
.add_property("gamma",
|
||||
&polygon_pattern_symbolizer::get_gamma,
|
||||
&polygon_pattern_symbolizer::set_gamma)
|
||||
.add_property("gamma_method",
|
||||
&polygon_pattern_symbolizer::get_gamma_method,
|
||||
&polygon_pattern_symbolizer::set_gamma_method,
|
||||
"Set/get the gamma correction method of the polygon")
|
||||
;
|
||||
}
|
||||
|
|
|
@ -22,8 +22,10 @@
|
|||
//$Id$
|
||||
|
||||
#include <boost/python.hpp>
|
||||
#include "mapnik_enumeration.hpp"
|
||||
#include <mapnik/polygon_symbolizer.hpp>
|
||||
|
||||
using namespace mapnik;
|
||||
using mapnik::polygon_symbolizer;
|
||||
using mapnik::color;
|
||||
|
||||
|
@ -38,17 +40,17 @@ struct polygon_symbolizer_pickle_suite : boost::python::pickle_suite
|
|||
static boost::python::tuple
|
||||
getstate(const polygon_symbolizer& p)
|
||||
{
|
||||
return boost::python::make_tuple(p.get_opacity(),p.get_gamma());
|
||||
return boost::python::make_tuple(p.get_opacity(),p.get_gamma(),p.get_gamma_method());
|
||||
}
|
||||
|
||||
static void
|
||||
setstate (polygon_symbolizer& p, boost::python::tuple state)
|
||||
{
|
||||
using namespace boost::python;
|
||||
if (len(state) != 2)
|
||||
if (len(state) != 3)
|
||||
{
|
||||
PyErr_SetObject(PyExc_ValueError,
|
||||
("expected 2-item tuple in call to __setstate__; got %s"
|
||||
("expected 3-item tuple in call to __setstate__; got %s"
|
||||
% state).ptr()
|
||||
);
|
||||
throw_error_already_set();
|
||||
|
@ -56,6 +58,7 @@ struct polygon_symbolizer_pickle_suite : boost::python::pickle_suite
|
|||
|
||||
p.set_opacity(extract<float>(state[0]));
|
||||
p.set_gamma(extract<float>(state[1]));
|
||||
p.set_gamma_method(extract<polygon_gamma_method_e>(state[2]));
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -64,6 +67,14 @@ void export_polygon_symbolizer()
|
|||
{
|
||||
using namespace boost::python;
|
||||
|
||||
enumeration_<polygon_gamma_method_e>("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_<polygon_symbolizer>("PolygonSymbolizer",
|
||||
init<>("Default PolygonSymbolizer - solid fill grey"))
|
||||
.def(init<color const&>("TODO"))
|
||||
|
@ -78,6 +89,10 @@ void export_polygon_symbolizer()
|
|||
.add_property("gamma",
|
||||
&polygon_symbolizer::get_gamma,
|
||||
&polygon_symbolizer::set_gamma)
|
||||
.add_property("gamma_method",
|
||||
&polygon_symbolizer::get_gamma_method,
|
||||
&polygon_symbolizer::set_gamma_method,
|
||||
"Set/get the gamma correction method of the polygon")
|
||||
;
|
||||
|
||||
}
|
||||
|
|
|
@ -68,17 +68,18 @@ struct stroke_pickle_suite : boost::python::pickle_suite
|
|||
dashes,
|
||||
s.get_line_cap(),
|
||||
s.get_line_join(),
|
||||
s.get_gamma());
|
||||
s.get_gamma(),
|
||||
s.get_gamma_method());
|
||||
}
|
||||
|
||||
static void
|
||||
setstate (stroke& s, boost::python::tuple state)
|
||||
{
|
||||
using namespace boost::python;
|
||||
if (len(state) != 5)
|
||||
if (len(state) != 6)
|
||||
{
|
||||
PyErr_SetObject(PyExc_ValueError,
|
||||
("expected 5-item tuple in call to __setstate__; got %s"
|
||||
("expected 6-item tuple in call to __setstate__; got %s"
|
||||
% state).ptr()
|
||||
);
|
||||
throw_error_already_set();
|
||||
|
@ -99,6 +100,7 @@ struct stroke_pickle_suite : boost::python::pickle_suite
|
|||
s.set_line_cap(extract<line_cap_e>(state[2]));
|
||||
s.set_line_join(extract<line_join_e>(state[3]));
|
||||
s.set_gamma(extract<double>(state[4]));
|
||||
s.set_gamma_method(extract<gamma_method_e>(state[5]));
|
||||
|
||||
}
|
||||
|
||||
|
@ -124,6 +126,13 @@ void export_stroke ()
|
|||
.value("ROUND_JOIN",ROUND_JOIN)
|
||||
.value("BEVEL_JOIN",BEVEL_JOIN)
|
||||
;
|
||||
enumeration_<gamma_method_e>("gamma_method")
|
||||
.value("POWER", GAMMA_POWER)
|
||||
.value("LINEAR", GAMMA_LINEAR)
|
||||
.value("NONE", GAMMA_NONE)
|
||||
.value("THRESHOLD", GAMMA_THRESHOLD)
|
||||
.value("MULTIPLY", GAMMA_MULTIPLY)
|
||||
;
|
||||
|
||||
class_<stroke>("Stroke",init<>(
|
||||
"Creates a new default black stroke with the width of 1.\n"))
|
||||
|
@ -151,6 +160,10 @@ void export_stroke ()
|
|||
&stroke::set_gamma,
|
||||
"Gets or sets the gamma of this stroke.\n"
|
||||
"The value is a float between 0 and 1.\n")
|
||||
.add_property("gamma_method",
|
||||
&stroke::get_gamma_method,
|
||||
&stroke::set_gamma_method,
|
||||
"Set/get the gamma correction method of this stroke")
|
||||
.add_property("line_cap",
|
||||
&stroke::get_line_cap,
|
||||
&stroke::set_line_cap,
|
||||
|
|
|
@ -38,21 +38,33 @@ 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
|
||||
{
|
||||
|
||||
polygon_pattern_symbolizer(path_expression_ptr file);
|
||||
polygon_pattern_symbolizer(polygon_pattern_symbolizer const& rhs);
|
||||
pattern_alignment_e get_alignment() const;
|
||||
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;
|
||||
|
||||
private:
|
||||
pattern_alignment_e alignment_;
|
||||
double gamma_;
|
||||
|
||||
polygon_pattern_gamma_method_e gamma_method_;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -27,22 +27,40 @@
|
|||
#include <mapnik/color.hpp>
|
||||
#include <mapnik/symbolizer.hpp>
|
||||
#include <mapnik/filter_factory.hpp>
|
||||
#include <mapnik/enumeration.hpp>
|
||||
|
||||
// stl
|
||||
#include <string>
|
||||
|
||||
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()
|
||||
: symbolizer_base(),
|
||||
fill_(color(128,128,128)),
|
||||
opacity_(1.0),
|
||||
gamma_(1.0) {}
|
||||
gamma_(1.0),
|
||||
gamma_method_(POLYGON_GAMMA_POWER) {}
|
||||
|
||||
polygon_symbolizer(color const& fill)
|
||||
: symbolizer_base(),
|
||||
fill_(fill),
|
||||
opacity_(1.0),
|
||||
gamma_(1.0) {}
|
||||
gamma_(1.0),
|
||||
gamma_method_(POLYGON_GAMMA_POWER) {}
|
||||
|
||||
color const& get_fill() const
|
||||
{
|
||||
|
@ -68,11 +86,20 @@ struct MAPNIK_DECL polygon_symbolizer : public symbolizer_base
|
|||
{
|
||||
return gamma_;
|
||||
}
|
||||
void set_gamma_method(polygon_gamma_method_e gamma_method)
|
||||
{
|
||||
gamma_method_ = gamma_method;
|
||||
}
|
||||
polygon_gamma_method_e get_gamma_method() const
|
||||
{
|
||||
return gamma_method_;
|
||||
}
|
||||
|
||||
private:
|
||||
color fill_;
|
||||
double opacity_;
|
||||
double gamma_;
|
||||
polygon_gamma_method_e gamma_method_;
|
||||
};
|
||||
|
||||
struct MAPNIK_DECL building_symbolizer : public symbolizer_base
|
||||
|
|
|
@ -60,15 +60,27 @@ 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_;
|
||||
double width_;
|
||||
double opacity_; // 0.0 - 1.0
|
||||
line_cap_e line_cap_;
|
||||
line_join_e line_join_;
|
||||
double gamma_;
|
||||
gamma_method_e gamma_method_;
|
||||
dash_array dash_;
|
||||
double dash_offset_;
|
||||
public:
|
||||
|
@ -94,15 +106,18 @@ public:
|
|||
|
||||
void set_gamma(double gamma);
|
||||
double get_gamma() const;
|
||||
|
||||
|
||||
void set_gamma_method(gamma_method_e gamma_method);
|
||||
gamma_method_e get_gamma_method() const;
|
||||
|
||||
void add_dash(double dash,double gap);
|
||||
bool has_dash() const;
|
||||
|
||||
void set_dash_offset(double offset);
|
||||
double dash_offset() const;
|
||||
|
||||
|
||||
dash_array const& get_dash_array() const;
|
||||
|
||||
|
||||
private:
|
||||
void swap(const stroke& other) throw();
|
||||
};
|
||||
|
|
|
@ -234,7 +234,7 @@ void agg_renderer<T>::render_marker(const int x, const int y, marker &marker, co
|
|||
typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_solid;
|
||||
|
||||
ras_ptr->reset();
|
||||
ras_ptr->gamma(agg::gamma_linear());
|
||||
ras_ptr->gamma(agg::gamma_power());
|
||||
agg::scanline_u8 sl;
|
||||
agg::rendering_buffer buf(pixmap_.raw_data(), width_, height_, width_ * 4);
|
||||
pixfmt pixf(buf);
|
||||
|
|
|
@ -65,7 +65,7 @@ void agg_renderer<T>::process(building_symbolizer const& sym,
|
|||
agg::scanline_u8 sl;
|
||||
|
||||
ras_ptr->reset();
|
||||
ras_ptr->gamma(agg::gamma_linear());
|
||||
ras_ptr->gamma(agg::gamma_power());
|
||||
|
||||
double height = 0.0;
|
||||
expression_ptr height_expr = sym.height();
|
||||
|
|
|
@ -97,7 +97,26 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
|
|||
ren_base renb(pixf);
|
||||
renderer ren(renb);
|
||||
ras_ptr->reset();
|
||||
ras_ptr->gamma(agg::gamma_linear(0.0, stroke_.get_gamma()));
|
||||
switch (stroke_.get_gamma_method())
|
||||
{
|
||||
case GAMMA_POWER:
|
||||
ras_ptr->gamma(agg::gamma_power(stroke_.get_gamma()));
|
||||
break;
|
||||
case GAMMA_LINEAR:
|
||||
ras_ptr->gamma(agg::gamma_linear(0.0, stroke_.get_gamma()));
|
||||
break;
|
||||
case GAMMA_NONE:
|
||||
ras_ptr->gamma(agg::gamma_none());
|
||||
break;
|
||||
case GAMMA_THRESHOLD:
|
||||
ras_ptr->gamma(agg::gamma_threshold(stroke_.get_gamma()));
|
||||
break;
|
||||
case GAMMA_MULTIPLY:
|
||||
ras_ptr->gamma(agg::gamma_multiply(stroke_.get_gamma()));
|
||||
break;
|
||||
default:
|
||||
ras_ptr->gamma(agg::gamma_power(stroke_.get_gamma()));
|
||||
}
|
||||
|
||||
metawriter_with_properties writer = sym.get_metawriter();
|
||||
for (unsigned i=0;i<feature.num_geometries();++i)
|
||||
|
|
|
@ -55,7 +55,7 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
|
|||
typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_solid;
|
||||
|
||||
ras_ptr->reset();
|
||||
ras_ptr->gamma(agg::gamma_linear());
|
||||
ras_ptr->gamma(agg::gamma_power());
|
||||
agg::scanline_u8 sl;
|
||||
agg::scanline_p8 sl_line;
|
||||
agg::rendering_buffer buf(pixmap_.raw_data(), width_, height_, width_ * 4);
|
||||
|
|
|
@ -71,7 +71,26 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
|
|||
|
||||
agg::scanline_u8 sl;
|
||||
ras_ptr->reset();
|
||||
ras_ptr->gamma(agg::gamma_linear(0.0, sym.get_gamma()));
|
||||
switch (sym.get_gamma_method())
|
||||
{
|
||||
case GAMMA_POWER:
|
||||
ras_ptr->gamma(agg::gamma_power(sym.get_gamma()));
|
||||
break;
|
||||
case GAMMA_LINEAR:
|
||||
ras_ptr->gamma(agg::gamma_linear(0.0, sym.get_gamma()));
|
||||
break;
|
||||
case GAMMA_NONE:
|
||||
ras_ptr->gamma(agg::gamma_none());
|
||||
break;
|
||||
case GAMMA_THRESHOLD:
|
||||
ras_ptr->gamma(agg::gamma_threshold(sym.get_gamma()));
|
||||
break;
|
||||
case GAMMA_MULTIPLY:
|
||||
ras_ptr->gamma(agg::gamma_multiply(sym.get_gamma()));
|
||||
break;
|
||||
default:
|
||||
ras_ptr->gamma(agg::gamma_power(sym.get_gamma()));
|
||||
}
|
||||
|
||||
std::string filename = path_processor_type::evaluate( *sym.get_filename(), feature);
|
||||
boost::optional<mapnik::marker_ptr> marker;
|
||||
|
|
|
@ -62,7 +62,27 @@ void agg_renderer<T>::process(polygon_symbolizer const& sym,
|
|||
renderer ren(renb);
|
||||
|
||||
ras_ptr->reset();
|
||||
ras_ptr->gamma(agg::gamma_power(sym.get_gamma()));
|
||||
switch (sym.get_gamma_method())
|
||||
{
|
||||
case GAMMA_POWER:
|
||||
ras_ptr->gamma(agg::gamma_power(sym.get_gamma()));
|
||||
break;
|
||||
case GAMMA_LINEAR:
|
||||
ras_ptr->gamma(agg::gamma_linear(0.0, sym.get_gamma()));
|
||||
break;
|
||||
case GAMMA_NONE:
|
||||
ras_ptr->gamma(agg::gamma_none());
|
||||
break;
|
||||
case GAMMA_THRESHOLD:
|
||||
ras_ptr->gamma(agg::gamma_threshold(sym.get_gamma()));
|
||||
break;
|
||||
case GAMMA_MULTIPLY:
|
||||
ras_ptr->gamma(agg::gamma_multiply(sym.get_gamma()));
|
||||
break;
|
||||
default:
|
||||
ras_ptr->gamma(agg::gamma_power(sym.get_gamma()));
|
||||
}
|
||||
|
||||
metawriter_with_properties writer = sym.get_metawriter();
|
||||
for (unsigned i=0;i<feature.num_geometries();++i)
|
||||
{
|
||||
|
|
|
@ -130,6 +130,7 @@ source = Split(
|
|||
png_reader.cpp
|
||||
point_symbolizer.cpp
|
||||
polygon_pattern_symbolizer.cpp
|
||||
polygon_symbolizer.cpp
|
||||
save_map.cpp
|
||||
shield_symbolizer.cpp
|
||||
text_symbolizer.cpp
|
||||
|
|
|
@ -1216,6 +1216,10 @@ void map_parser::parse_polygon_pattern_symbolizer( rule & rule,
|
|||
optional<double> gamma = get_opt_attr<double>(sym, "gamma");
|
||||
if (gamma) symbol.set_gamma(*gamma);
|
||||
|
||||
// gamma method
|
||||
optional<polygon_pattern_gamma_method_e> gamma_method = get_opt_attr<polygon_pattern_gamma_method_e>(sym, "gamma-method");
|
||||
if (gamma_method) symbol.set_gamma_method(*gamma_method);
|
||||
|
||||
parse_metawriter_in_symbolizer(symbol, sym);
|
||||
rule.append(symbol);
|
||||
}
|
||||
|
@ -1794,6 +1798,10 @@ void map_parser::parse_stroke(stroke & strk, ptree const & sym)
|
|||
optional<double> gamma = get_opt_attr<double>(sym, "stroke-gamma");
|
||||
if (gamma) strk.set_gamma(*gamma);
|
||||
|
||||
// stroke-gamma-method
|
||||
optional<gamma_method_e> gamma_method = get_opt_attr<gamma_method_e>(sym, "stroke-gamma-method");
|
||||
if (gamma_method) strk.set_gamma_method(*gamma_method);
|
||||
|
||||
// stroke-dashoffset
|
||||
optional<double> dash_offset = get_opt_attr<double>(sym, "stroke-dashoffset");
|
||||
if (dash_offset) strk.set_dash_offset(*dash_offset);
|
||||
|
@ -1872,7 +1880,7 @@ void map_parser::parse_line_symbolizer( rule & rule, ptree const & sym )
|
|||
|
||||
void map_parser::parse_polygon_symbolizer( rule & rule, ptree const & sym )
|
||||
{
|
||||
ensure_attrs(sym, "PolygonSymbolizer", "fill,fill-opacity,gamma,meta-writer,meta-output");
|
||||
ensure_attrs(sym, "PolygonSymbolizer", "fill,fill-opacity,gamma,gamma-method,meta-writer,meta-output");
|
||||
try
|
||||
{
|
||||
polygon_symbolizer poly_sym;
|
||||
|
@ -1885,6 +1893,9 @@ void map_parser::parse_polygon_symbolizer( rule & rule, ptree const & sym )
|
|||
// gamma
|
||||
optional<double> gamma = get_opt_attr<double>(sym, "gamma");
|
||||
if (gamma) poly_sym.set_gamma(*gamma);
|
||||
// gamma method
|
||||
optional<polygon_gamma_method_e> gamma_method = get_opt_attr<polygon_gamma_method_e>(sym, "gamma-method");
|
||||
if (gamma_method) poly_sym.set_gamma_method(*gamma_method);
|
||||
|
||||
parse_metawriter_in_symbolizer(poly_sym, sym);
|
||||
rule.append(poly_sym);
|
||||
|
|
|
@ -34,16 +34,29 @@ static const char * pattern_alignment_strings[] = {
|
|||
};
|
||||
|
||||
IMPLEMENT_ENUM( pattern_alignment_e, pattern_alignment_strings )
|
||||
|
||||
polygon_pattern_symbolizer::polygon_pattern_symbolizer(path_expression_ptr file)
|
||||
|
||||
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_(1.0),
|
||||
gamma_method_(POLYGON_PATTERN_GAMMA_POWER) {}
|
||||
|
||||
polygon_pattern_symbolizer::polygon_pattern_symbolizer(polygon_pattern_symbolizer const& rhs)
|
||||
: symbolizer_with_image(rhs), symbolizer_base(rhs),
|
||||
alignment_(rhs.alignment_),
|
||||
gamma_(rhs.gamma_) {}
|
||||
gamma_(rhs.gamma_),
|
||||
gamma_method_(rhs.gamma_method_) {}
|
||||
|
||||
pattern_alignment_e polygon_pattern_symbolizer::get_alignment() const
|
||||
{
|
||||
|
@ -65,5 +78,15 @@ void polygon_pattern_symbolizer::set_gamma(double gamma)
|
|||
gamma_ = gamma;
|
||||
}
|
||||
|
||||
void polygon_pattern_symbolizer::set_gamma_method(polygon_pattern_gamma_method_e gamma_method)
|
||||
{
|
||||
gamma_method_ = gamma_method;
|
||||
}
|
||||
|
||||
polygon_pattern_gamma_method_e polygon_pattern_symbolizer::get_gamma_method() const
|
||||
{
|
||||
return gamma_method_;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
43
src/polygon_symbolizer.cpp
Normal file
43
src/polygon_symbolizer.cpp
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* 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 <mapnik/polygon_symbolizer.hpp>
|
||||
|
||||
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 )
|
||||
|
||||
}
|
||||
|
|
@ -118,6 +118,10 @@ public:
|
|||
{
|
||||
set_attr( sym_node, "gamma", sym.get_gamma() );
|
||||
}
|
||||
if ( sym.get_gamma_method() != dfl.get_gamma_method() || explicit_defaults_ )
|
||||
{
|
||||
set_attr( sym_node, "gamma-method", sym.get_gamma_method() );
|
||||
}
|
||||
add_metawriter_attributes(sym_node, sym);
|
||||
}
|
||||
|
||||
|
@ -132,12 +136,14 @@ public:
|
|||
{
|
||||
set_attr( sym_node, "alignment", sym.get_alignment() );
|
||||
}
|
||||
|
||||
if ( sym.get_gamma() != dfl.get_gamma() || explicit_defaults_ )
|
||||
{
|
||||
set_attr( sym_node, "gamma", sym.get_gamma() );
|
||||
}
|
||||
|
||||
if ( sym.get_gamma_method() != dfl.get_gamma_method() || explicit_defaults_ )
|
||||
{
|
||||
set_attr( sym_node, "gamma-method", sym.get_gamma_method() );
|
||||
}
|
||||
add_image_attributes( sym_node, sym );
|
||||
add_metawriter_attributes(sym_node, sym);
|
||||
}
|
||||
|
@ -606,6 +612,10 @@ private:
|
|||
{
|
||||
set_attr( node, "stroke-gamma", strk.get_gamma());
|
||||
}
|
||||
if ( strk.get_gamma_method() != dfl.get_gamma_method() || explicit_defaults_ )
|
||||
{
|
||||
set_attr( node, "stroke-gamma-method", strk.get_gamma_method() );
|
||||
}
|
||||
if ( strk.dash_offset() != dfl.dash_offset() || explicit_defaults_ )
|
||||
{
|
||||
set_attr( node, "stroke-dash-offset", strk.dash_offset());
|
||||
|
|
|
@ -46,6 +46,17 @@ 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),
|
||||
|
@ -54,6 +65,7 @@ stroke::stroke()
|
|||
line_cap_(BUTT_CAP),
|
||||
line_join_(MITER_JOIN),
|
||||
gamma_(1.0),
|
||||
gamma_method_(GAMMA_POWER),
|
||||
dash_(),
|
||||
dash_offset_(0) {}
|
||||
|
||||
|
@ -64,6 +76,7 @@ stroke::stroke(color const& c, double width)
|
|||
line_cap_(BUTT_CAP),
|
||||
line_join_(MITER_JOIN),
|
||||
gamma_(1.0),
|
||||
gamma_method_(GAMMA_POWER),
|
||||
dash_(),
|
||||
dash_offset_(0.0) {}
|
||||
|
||||
|
@ -74,6 +87,7 @@ stroke::stroke(stroke const& other)
|
|||
line_cap_(other.line_cap_),
|
||||
line_join_(other.line_join_),
|
||||
gamma_(other.gamma_),
|
||||
gamma_method_(other.gamma_method_),
|
||||
dash_(other.dash_),
|
||||
dash_offset_(other.dash_offset_) {}
|
||||
|
||||
|
@ -145,6 +159,16 @@ double stroke::get_gamma() const
|
|||
return gamma_;
|
||||
}
|
||||
|
||||
void stroke::set_gamma_method(gamma_method_e gamma_method)
|
||||
{
|
||||
gamma_method_ = gamma_method;
|
||||
}
|
||||
|
||||
gamma_method_e stroke::get_gamma_method() const
|
||||
{
|
||||
return gamma_method_;
|
||||
}
|
||||
|
||||
void stroke::add_dash(double dash, double gap)
|
||||
{
|
||||
dash_.push_back(std::make_pair(dash,gap));
|
||||
|
@ -172,12 +196,13 @@ dash_array const& stroke::get_dash_array() const
|
|||
|
||||
void stroke::swap(const stroke& other) throw()
|
||||
{
|
||||
c_=other.c_;
|
||||
width_=other.width_;
|
||||
opacity_=other.opacity_;
|
||||
line_cap_=other.line_cap_;
|
||||
line_join_=other.line_join_;
|
||||
gamma_=other.gamma_;
|
||||
c_ = other.c_;
|
||||
width_ = other.width_;
|
||||
opacity_ = other.opacity_;
|
||||
line_cap_ = other.line_cap_;
|
||||
line_join_ = other.line_join_;
|
||||
gamma_ = other.gamma_;
|
||||
gamma_method_ = other.gamma_method_;
|
||||
dash_ = other.dash_;
|
||||
dash_offset_ = other.dash_offset_;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue