Permalink
Browse files

+ refactor join/cap settings (agg_helper.hpp)

  • Loading branch information...
1 parent d855568 commit 3e4733c51a5a621686e386d0fa85fc8f7fc57828 @artemp artemp committed Mar 14, 2012
Showing with 37 additions and 41 deletions.
  1. +34 −0 include/mapnik/agg_helpers.hpp
  2. +3 −41 src/agg/process_line_symbolizer.cpp
@@ -24,6 +24,7 @@
#define MAPNIK_AGG_HELPERS_HPP
#include "agg_gamma_functions.h"
+#include "agg_math_stroke.h"
namespace mapnik {
@@ -52,6 +53,39 @@ void set_gamma_method(T0 const& obj, T1 & ras_ptr)
}
}
+template <typename Stroke,typename PathType>
+void set_join_caps(Stroke const& stroke_, PathType & stroke)
+{
+ line_join_e join=stroke_.get_line_join();
+ switch (join)
+ {
+ case MITER_JOIN:
+ stroke.generator().line_join(agg::miter_join);
+ break;
+ case MITER_REVERT_JOIN:
+ stroke.generator().line_join(agg::miter_join);
+ break;
+ case ROUND_JOIN:
+ stroke.generator().line_join(agg::round_join);
+ break;
+ default:
+ stroke.generator().line_join(agg::bevel_join);
+ }
+
+ line_cap_e cap=stroke_.get_line_cap();
+ switch (cap)
+ {
+ case BUTT_CAP:
+ stroke.generator().line_cap(agg::butt_cap);
+ break;
+ case SQUARE_CAP:
+ stroke.generator().line_cap(agg::square_cap);
+ break;
+ default:
+ stroke.generator().line_cap(agg::round_cap);
+ }
+}
+
}
#endif //MAPNIK_AGG_HELPERS_HPP
@@ -113,7 +113,6 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
geometry_type & geom = feature->get_geometry(i);
if (geom.num_points() > 1)
{
-
if (stroke_.has_dash())
{
clipped_geometry_type clipped(geom);
@@ -129,27 +128,8 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
dash.add_dash(itr->first * scale_factor_,
itr->second * scale_factor_);
}
-
agg::conv_stroke<agg::conv_dash<path_type > > stroke(dash);
-
- line_join_e join=stroke_.get_line_join();
- if ( join == MITER_JOIN)
- stroke.generator().line_join(agg::miter_join);
- else if( join == MITER_REVERT_JOIN)
- stroke.generator().line_join(agg::miter_join);
- else if( join == ROUND_JOIN)
- stroke.generator().line_join(agg::round_join);
- else
- stroke.generator().line_join(agg::bevel_join);
-
- line_cap_e cap=stroke_.get_line_cap();
- if (cap == BUTT_CAP)
- stroke.generator().line_cap(agg::butt_cap);
- else if (cap == SQUARE_CAP)
- stroke.generator().line_cap(agg::square_cap);
- else
- stroke.generator().line_cap(agg::round_cap);
-
+ set_join_caps(stroke_,stroke);
stroke.generator().miter_limit(4.0);
stroke.generator().width(stroke_.get_width() * scale_factor_);
ras_ptr->add_path(stroke);
@@ -160,26 +140,8 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
clipped_geometry_type clipped(geom);
clipped.clip_box(ext.minx(),ext.miny(),ext.maxx(),ext.maxy());
path_type path(t_,clipped,prj_trans);
-
- agg::conv_stroke<path_type> stroke(path);
- line_join_e join=stroke_.get_line_join();
- if ( join == MITER_JOIN)
- stroke.generator().line_join(agg::miter_join);
- else if( join == MITER_REVERT_JOIN)
- stroke.generator().line_join(agg::miter_join);
- else if( join == ROUND_JOIN)
- stroke.generator().line_join(agg::round_join);
- else
- stroke.generator().line_join(agg::bevel_join);
-
- line_cap_e cap=stroke_.get_line_cap();
- if (cap == BUTT_CAP)
- stroke.generator().line_cap(agg::butt_cap);
- else if (cap == SQUARE_CAP)
- stroke.generator().line_cap(agg::square_cap);
- else
- stroke.generator().line_cap(agg::round_cap);
-
+ agg::conv_stroke<path_type> stroke(path);
+ set_join_caps(stroke_,stroke);
stroke.generator().miter_limit(4.0);
stroke.generator().width(stroke_.get_width() * scale_factor_);
ras_ptr->add_path(stroke);

0 comments on commit 3e4733c

Please sign in to comment.