Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 19ae193

Browse files
committed
cleaned up agg wrapper
svn path=/trunk/matplotlib/; revision=1308
1 parent e959554 commit 19ae193

16 files changed

Lines changed: 11542 additions & 3974 deletions

lib/matplotlib/agg.py

Lines changed: 586 additions & 209 deletions
Large diffs are not rendered by default.

lib/matplotlib/axes.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ def __init__(self, fig, rect,
322322
# must be set before set_figure
323323
self._sharex = sharex
324324
self._sharey = sharey
325-
self.set_label(label)
325+
self.set_label1(label)
326+
self.set_label2(label)
326327
self.set_figure(fig)
327328

328329
# this call may differ for non-sep axes, eg polar
@@ -3670,12 +3671,9 @@ class PolarAxes(Axes):
36703671
RESOLUTION = 200
36713672

36723673
def __init__(self, *args, **kwarg):
3673-
self.thetagridlabels = []
3674-
self.thetagridlines = []
3675-
self.rgridlabels = []
3676-
self.rgridlines = []
36773674
Axes.__init__(self, *args, **kwarg)
3678-
3675+
self.cla()
3676+
36793677
def _init_axis(self):
36803678
"nuthin to do"
36813679
pass
@@ -3706,7 +3704,14 @@ def cla(self):
37063704
self._get_patches_for_fill = _process_plot_var_args('fill')
37073705

37083706
self._gridOn = rcParams['polaraxes.grid']
3707+
self.thetagridlabels = []
3708+
self.thetagridlines = []
3709+
self.rgridlabels = []
3710+
self.rgridlines = []
3711+
37093712
self.lines = []
3713+
self.images = []
3714+
self.patches = []
37103715
self.collections = []
37113716
self.texts = [] # text in axis coords
37123717

@@ -3759,6 +3764,20 @@ def grid(self, b):
37593764

37603765

37613766

3767+
def legend(self, *args, **kwargs):
3768+
"""
3769+
LEGEND(*args, **kwargs)
3770+
Not implemented for polar yet -- use figlegend
3771+
"""
3772+
raise NotImplementedError('legend not implemented for polar yet -- use figlegend')
3773+
3774+
def table(self, *args, **kwargs):
3775+
"""
3776+
TABLE(*args, **kwargs)
3777+
Not implemented for polar axes
3778+
"""
3779+
raise NotImplementedError('legend not implemented for polar axes')
3780+
37623781
def autoscale_view(self):
37633782

37643783
self.rintd.set_bounds(0, self.get_rmax())

setupext.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ def build_swigagg(ext_modules, packages):
491491
'agg_vcgen_dash.cpp',
492492
'agg_vcgen_stroke.cpp',
493493
'agg_rasterizer_scanline_aa.cpp',
494+
'agg_curves.cpp',
494495
)
495496
])
496497

src/agg.cxx

Lines changed: 10763 additions & 3574 deletions
Large diffs are not rendered by default.

src/ft2font.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,13 @@ inline double conv(int v)
6464
}
6565

6666

67+
//see http://freetype.sourceforge.net/freetype2/docs/glyphs/glyphs-6.html
6768
Py::Object
6869
Glyph::get_path( const FT_Face& face) {
6970
//get the glyph as a path, a list of (COMMAND, *args) as desribed in matplotlib.path
7071
// this code is from agg's decompose_ft_outline with minor modifications
7172

73+
7274
enum {MOVETO, LINETO, CURVE3, CURVE4, ENDPOLY};
7375
FT_Outline& outline = face->glyph->outline;
7476
Py::List path;

src/ft2font.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class Glyph : public Py::PythonExtension<Glyph> {
4343
Py::Object get_path( const FT_Face& face );
4444
private:
4545
Py::Dict __dict__;
46+
static char get_path__doc__[];
4647
};
4748

4849
class FT2Font : public Py::PythonExtension<FT2Font> {

swig/agg.i

Lines changed: 14 additions & 185 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include "agg_renderer_base.h"
1212
#include "agg_math_stroke.h"
1313
#include "agg_conv_stroke.h"
14+
#include "agg_conv_transform.h"
15+
#include "agg_conv_curve.h"
1416
#include "agg_vcgen_stroke.h"
1517
#include "agg_rasterizer_scanline_aa.h"
1618
#include "agg_renderer_scanline.h"
@@ -20,15 +22,11 @@
2022

2123
using namespace agg;
2224

23-
typedef agg::rgba8 color_type;
24-
typedef agg::pixfmt_rgba32 pixel_format;
25-
25+
#include "agg_typedefs.h"
2626
%}
2727

28-
typedef agg::rgba8 color_type;
29-
typedef agg::pixfmt_rgba32 pixel_format;
30-
//typedef pixel_formats_rgba<blender_rgba32, pixel32_type> pixel_format;
3128

29+
%include "agg_typedefs.h"
3230
%include "agg_basics.i"
3331

3432

@@ -59,25 +57,11 @@ typedef agg::pixfmt_rgba32 pixel_format;
5957
}
6058

6159
%include "agg_buffer.h"
62-
6360
%include "agg_color_rgba.h"
6461
%include "agg_trans_affine.i"
6562
%include "agg_path_storage.i"
6663
%include "agg_math_stroke.h"
67-
%include "agg_vcgen_stroke.h"
68-
#include "agg_conv_adaptor_vcgen.h"
6964

70-
//%template(conv_adaptor_vcgen) agg::conv_adaptor_vcgen<agg::path_storage,agg::vcgen_stroke,agg::null_markers>;
71-
72-
%rename(null_markers) agg::null_markers;
73-
struct agg::null_markers {};
74-
75-
%rename(conv_adaptor_vcgen) conv_adaptor_vcgen<agg::path_storage,agg::vcgen_stroke,agg::null_markers>;
76-
class conv_adaptor_vcgen<agg::path_storage,agg::vcgen_stroke,agg::null_markers>
77-
{
78-
public:
79-
conv_adaptor_vcgen<agg::path_storage,agg::vcgen_stroke,agg::null_markers>(agg::path_storage& source);
80-
};
8165

8266

8367
%include "agg_rendering_buffer.h"
@@ -89,168 +73,16 @@ public:
8973
}
9074

9175
%include "agg_pixfmt_rgba.h"
92-
%template(pixel_format) agg::pixel_formats_rgba<agg::blender_rgba32, agg::pixel32_type>;
93-
94-
95-
96-
#include "agg_renderer_base.h"
97-
%rename(renderer_base) renderer_base<pixel_format>;
98-
class renderer_base<pixel_format>
99-
{
100-
public:
101-
renderer_base<pixel_format>(pixel_format& ren);
102-
const pixel_format& ren();
103-
unsigned width() const;
104-
unsigned height() const;
105-
bool clip_box(int x1, int y1, int x2, int y2);
106-
void reset_clipping(bool visibility);
107-
void clip_box_naked(int x1, int y1, int x2, int y2);
108-
bool inbox(int x, int y) const;
109-
void first_clip_box();
110-
bool next_clip_box();
111-
const agg::rect& clip_box() const;
112-
int xmin() const;
113-
int ymin() const;
114-
int xmax() const;
115-
int ymax() const;
116-
117-
const agg::rect& bounding_clip_box() const;
118-
int bounding_xmin() const;
119-
int bounding_ymin() const;
120-
int bounding_xmax() const;
121-
int bounding_ymax() const;
122-
void clear(const color_type& c);
123-
void copy_pixel(int x, int y, const color_type& c);
124-
void blend_pixel(int x, int y, const color_type& c, agg::cover_type cover);
125-
color_type pixel(int x, int y) const;
126-
void copy_hline(int x1, int y, int x2, const color_type& c);
127-
void copy_vline(int x, int y1, int y2, const color_type& c);
128-
void blend_hline(int x1, int y, int x2,
129-
const color_type& c, agg::cover_type cover);
130-
void blend_vline(int x, int y1, int y2,
131-
const color_type& c, agg::cover_type cover);
132-
void copy_bar(int x1, int y1, int x2, int y2, const color_type& c);
133-
void blend_bar(int x1, int y1, int x2, int y2,
134-
const color_type& c, agg::cover_type cover);
135-
void blend_solid_hspan(int x, int y, int len,
136-
const color_type& c,
137-
const agg::cover_type* covers);
138-
void blend_solid_vspan(int x, int y, int len,
139-
const color_type& c,
140-
const agg::cover_type* covers);
141-
142-
void blend_color_hspan(int x, int y, int len,
143-
const color_type* colors,
144-
const agg::cover_type* covers,
145-
agg::cover_type cover = cover_full);
146-
void blend_color_vspan(int x, int y, int len,
147-
const color_type* colors,
148-
const agg::cover_type* covers,
149-
agg::cover_type cover = cover_full);
150-
void blend_color_hspan_no_clip(int x, int y, int len,
151-
const color_type* colors,
152-
const agg::cover_type* covers,
153-
agg::cover_type cover = cover_full);
154-
void blend_color_vspan_no_clip(int x, int y, int len,
155-
const color_type* colors,
156-
const agg::cover_type* covers,
157-
agg::cover_type cover = cover_full);
158-
rect clip_rect_area(agg::rect& dst, agg::rect& src, int wsrc, int hsrc) const;
159-
void copy_from(const agg::rendering_buffer& src,
160-
const agg::rect* rect_src_ptr = 0,
161-
int dx = 0,
162-
int dy = 0);
163-
/* todo fixme
164-
template<class SrcPixelFormatRenderer>
165-
void blend_from(const SrcPixelFormatRenderer& src,
166-
const rect* rect_src_ptr = 0,
167-
int dx = 0,
168-
int dy = 0);
169-
*/
170-
};
171-
172-
173-
#include "agg_conv_stroke.h"
174-
%rename(conv_stroke) conv_stroke<agg::path_storage>;
175-
struct conv_stroke<agg::path_storage> {
176-
conv_stroke<agg::path_storage>(agg::path_storage& vs);
177-
void line_cap(agg::line_cap_e lc);
178-
void line_join(agg::line_join_e lj);
179-
agg::line_cap_e line_cap();
180-
agg::line_join_e line_join();
181-
void width(double w);
182-
void miter_limit(double ml);
183-
void miter_limit_theta(double t);
184-
void approximation_scale(double as);
185-
double width() const;
186-
double miter_limit() const;
187-
double approximation_scale();
188-
void shorten(double s);
189-
double shorten() const;
190-
};
191-
76+
%template(pixel_format_rgba) agg::pixel_formats_rgba<agg::blender_rgba32, agg::pixel32_type>;
19277

193-
#include "agg_rasterizer_scanline_aa.h"
194-
%rename(rasterizer_scanline_aa) rasterizer_scanline_aa<>;
195-
class rasterizer_scanline_aa<>
196-
{
197-
public:
198-
rasterizer_scanline_aa<>();
199-
void reset();
200-
void filling_rule(agg::filling_rule_e filling_rule);
201-
void clip_box(double x1, double y1, double x2, double y2);
202-
void reset_clipping();
203-
//template<class GammaF> void gamma(const GammaF& gamma_function)
204-
unsigned apply_gamma(unsigned cover) const;
205-
void add_vertex(double x, double y, unsigned cmd);
206-
void move_to(int x, int y);
207-
void line_to(int x, int y);
208-
void close_polygon();
209-
void move_to_d(double x, double y);
210-
void line_to_d(double x, double y);
211-
int min_x() const;
212-
int min_y() const;
213-
int max_x() const;
214-
int max_y() const;
215-
216-
unsigned calculate_alpha(int area);
217-
void sort();
218-
bool rewind_scanlines();
219-
//template<class Scanline> bool sweep_scanline(Scanline& sl);
220-
bool hit_test(int tx, int ty);
221-
//fixme void add_xy(const double* x, const double* y, unsigned n);
222-
//template<class VertexSource>
223-
void add_path(agg::path_storage& vs, unsigned id=0);
224-
void add_path(agg::conv_stroke<agg::path_storage>& vs, unsigned id=0);
225-
226-
};
22778

79+
%include "agg_renderer_base.i"
80+
%include "agg_conv_curve.i"
81+
%include "agg_conv_transform.i"
82+
%include "agg_conv_stroke.i"
22883

229-
230-
231-
232-
233-
#include "agg_renderer_scanline.h"
234-
//todo fixme color type
235-
%rename(renderer_scanline_aa_solid) renderer_scanline_aa_solid<renderer_base<pixel_format> >;
236-
class renderer_scanline_aa_solid<renderer_base<pixel_format> >
237-
{
238-
public:
239-
renderer_scanline_aa_solid<renderer_base<pixel_format> >(renderer_base<pixel_format>& ren);
240-
void color(const color_type& c);
241-
const color_type& color() const;
242-
void prepare(unsigned);
243-
};
244-
245-
%rename(renderer_scanline_bin_solid) renderer_scanline_bin_solid<renderer_base<pixel_format> >;
246-
class renderer_scanline_bin_solid<renderer_base<pixel_format> >
247-
{
248-
public:
249-
renderer_scanline_bin_solid<renderer_base<pixel_format> >(renderer_base<pixel_format>& ren);
250-
void color(const color_type& c);
251-
const color_type& color() const;
252-
void prepare(unsigned);
253-
};
84+
%include "agg_rasterizer_scanline_aa.i"
85+
%include "agg_renderer_scanline.i"
25486

25587

25688
%include "agg_scanline_p.h"
@@ -259,10 +91,7 @@ public:
25991
%include "agg_scanline_bin.h"
26092

26193
%include "agg_render_scanlines.h"
262-
%template(render_scanlines) agg::render_scanlines<
263-
rasterizer_scanline_aa<>,
94+
%template(render_scanlines_rgba) agg::render_scanlines<
95+
agg::rasterizer_scanline_aa<>,
26496
agg::scanline_p<agg::int8u>,
265-
renderer_scanline_aa_solid<renderer_base<pixel_format> > >;
266-
267-
268-
97+
agg::renderer_scanline_aa_solid<renderer_base_rgba_t> >;

swig/agg_conv_curve.i

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include "agg_conv_curve.h"
2+
%include "agg_conv_curve.h"
3+
4+
%template(conv_curve_path) agg::conv_curve<path_t>;
5+
%template(conv_curve_trans) agg::conv_curve<transpath_t>;

swig/agg_conv_stroke.i

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include "agg_conv_stroke.h"
2+
%include "agg_conv_stroke.h"
3+
4+
#include "agg_vcgen_stroke.h"
5+
%include "agg_vcgen_stroke.h"
6+
7+
#include "agg_conv_adaptor_vcgen.h"
8+
%include "agg_conv_adaptor_vcgen.h"
9+
10+
11+
%template(conv_adaptor_vcgen_path) agg::conv_adaptor_vcgen<path_t, agg::vcgen_stroke,agg::null_markers>;
12+
%template(conv_adaptor_vcgen_transpath) agg::conv_adaptor_vcgen<transpath_t, agg::vcgen_stroke,agg::null_markers>;
13+
%template(conv_adaptor_vcgen_curve) agg::conv_adaptor_vcgen<curve_t, agg::vcgen_stroke,agg::null_markers>;
14+
%template(conv_adaptor_vcgen_transcurve) agg::conv_adaptor_vcgen<transcurve_t, agg::vcgen_stroke,agg::null_markers>;
15+
%template(conv_adaptor_vcgen_curvetrans) agg::conv_adaptor_vcgen<curvetrans_t, agg::vcgen_stroke,agg::null_markers>;
16+
17+
18+
%template(conv_stroke_path) agg::conv_stroke<path_t>;
19+
%template(conv_stroke_transpath) agg::conv_stroke<transpath_t>;
20+
%template(conv_stroke_curve) agg::conv_stroke<curve_t>;
21+
%template(conv_stroke_transcurve) agg::conv_stroke<transcurve_t>;
22+
%template(conv_stroke_curvetrans) agg::conv_stroke<curvetrans_t>;
23+

swig/agg_conv_transform.i

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include "agg_conv_transform.h"
2+
%include "agg_conv_transform.h"
3+
4+
%template(conv_transform_path) agg::conv_transform<path_t, agg::trans_affine>;
5+
%template(conv_transform_curve) agg::conv_transform<curve_t, agg::trans_affine>;

0 commit comments

Comments
 (0)