Skip to content

Commit 0473bb1

Browse files
committed
added transformations tut, did some reorg
svn path=/branches/v0_99_maint/; revision=7490
1 parent ff12479 commit 0473bb1

File tree

7 files changed

+81
-46
lines changed

7 files changed

+81
-46
lines changed

CXX/IndirectPythonInterface.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,6 @@ void _XINCREF( PyObject *op );
193193
void _XDECREF( PyObject *op );
194194

195195
char *__Py_PackageContext();
196-
};
196+
}
197197

198198
#endif // __CXX_INDIRECT_PYTHON_INTERFACE__HXX__

agg24/include/agg_basics.h

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Anti-Grain Geometry - Version 2.4
33
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
44
//
5-
// Permission to copy, use, modify, sell and distribute this software
6-
// is granted provided this copyright notice appears in all copies.
5+
// Permission to copy, use, modify, sell and distribute this software
6+
// is granted provided this copyright notice appears in all copies.
77
// This software is provided "as is" without express or implied
88
// warranty, and with no claim as to its suitability for any purpose.
99
//
@@ -25,12 +25,12 @@
2525
#else
2626
namespace agg
2727
{
28-
// The policy of all AGG containers and memory allocation strategy
28+
// The policy of all AGG containers and memory allocation strategy
2929
// in general is that no allocated data requires explicit construction.
3030
// It means that the allocator can be really simple; you can even
31-
// replace new/delete to malloc/free. The constructors and destructors
32-
// won't be called in this case, however everything will remain working.
33-
// The second argument of deallocate() is the size of the allocated
31+
// replace new/delete to malloc/free. The constructors and destructors
32+
// won't be called in this case, however everything will remain working.
33+
// The second argument of deallocate() is the size of the allocated
3434
// block. You can use this information if you wish.
3535
//------------------------------------------------------------pod_allocator
3636
template<class T> struct pod_allocator
@@ -40,8 +40,8 @@ namespace agg
4040
};
4141

4242
// Single object allocator. It's also can be replaced with your custom
43-
// allocator. The difference is that it can only allocate a single
44-
// object and the constructor and destructor must be called.
43+
// allocator. The difference is that it can only allocate a single
44+
// object and the constructor and destructor must be called.
4545
// In AGG there is no need to allocate an array of objects with
4646
// calling their constructors (only single ones). So that, if you
4747
// replace these new/delete to malloc/free make sure that the in-place
@@ -213,23 +213,23 @@ namespace agg
213213
enum cover_scale_e
214214
{
215215
cover_shift = 8, //----cover_shift
216-
cover_size = 1 << cover_shift, //----cover_size
217-
cover_mask = cover_size - 1, //----cover_mask
218-
cover_none = 0, //----cover_none
219-
cover_full = cover_mask //----cover_full
216+
cover_size = 1 << cover_shift, //----cover_size
217+
cover_mask = cover_size - 1, //----cover_mask
218+
cover_none = 0, //----cover_none
219+
cover_full = cover_mask //----cover_full
220220
};
221221

222222
//----------------------------------------------------poly_subpixel_scale_e
223-
// These constants determine the subpixel accuracy, to be more precise,
224-
// the number of bits of the fractional part of the coordinates.
223+
// These constants determine the subpixel accuracy, to be more precise,
224+
// the number of bits of the fractional part of the coordinates.
225225
// The possible coordinate capacity in bits can be calculated by formula:
226226
// sizeof(int) * 8 - poly_subpixel_shift, i.e, for 32-bit integers and
227227
// 8-bits fractional part the capacity is 24 bits.
228228
enum poly_subpixel_scale_e
229229
{
230230
poly_subpixel_shift = 8, //----poly_subpixel_shift
231-
poly_subpixel_scale = 1<<poly_subpixel_shift, //----poly_subpixel_scale
232-
poly_subpixel_mask = poly_subpixel_scale-1, //----poly_subpixel_mask
231+
poly_subpixel_scale = 1<<poly_subpixel_shift, //----poly_subpixel_scale
232+
poly_subpixel_mask = poly_subpixel_scale-1 //----poly_subpixel_mask
233233
};
234234

235235
//----------------------------------------------------------filling_rule_e
@@ -253,7 +253,7 @@ namespace agg
253253
{
254254
return rad * 180.0 / pi;
255255
}
256-
256+
257257
//----------------------------------------------------------------rect_base
258258
template<class T> struct rect_base
259259
{
@@ -265,9 +265,9 @@ namespace agg
265265
rect_base(T x1_, T y1_, T x2_, T y2_) :
266266
x1(x1_), y1(y1_), x2(x2_), y2(y2_) {}
267267

268-
void init(T x1_, T y1_, T x2_, T y2_)
268+
void init(T x1_, T y1_, T x2_, T y2_)
269269
{
270-
x1 = x1_; y1 = y1_; x2 = x2_; y2 = y2_;
270+
x1 = x1_; y1 = y1_; x2 = x2_; y2 = y2_;
271271
}
272272

273273
const self_type& normalize()
@@ -299,17 +299,17 @@ namespace agg
299299
};
300300

301301
//-----------------------------------------------------intersect_rectangles
302-
template<class Rect>
302+
template<class Rect>
303303
inline Rect intersect_rectangles(const Rect& r1, const Rect& r2)
304304
{
305305
Rect r = r1;
306306

307-
// First process x2,y2 because the other order
308-
// results in Internal Compiler Error under
309-
// Microsoft Visual C++ .NET 2003 69462-335-0000007-18038 in
307+
// First process x2,y2 because the other order
308+
// results in Internal Compiler Error under
309+
// Microsoft Visual C++ .NET 2003 69462-335-0000007-18038 in
310310
// case of "Maximize Speed" optimization option.
311311
//-----------------
312-
if(r.x2 > r2.x2) r.x2 = r2.x2;
312+
if(r.x2 > r2.x2) r.x2 = r2.x2;
313313
if(r.y2 > r2.y2) r.y2 = r2.y2;
314314
if(r.x1 < r2.x1) r.x1 = r2.x1;
315315
if(r.y1 < r2.y1) r.y1 = r2.y1;
@@ -318,7 +318,7 @@ namespace agg
318318

319319

320320
//---------------------------------------------------------unite_rectangles
321-
template<class Rect>
321+
template<class Rect>
322322
inline Rect unite_rectangles(const Rect& r1, const Rect& r2)
323323
{
324324
Rect r = r1;
@@ -336,26 +336,26 @@ namespace agg
336336
//---------------------------------------------------------path_commands_e
337337
enum path_commands_e
338338
{
339-
path_cmd_stop = 0, //----path_cmd_stop
340-
path_cmd_move_to = 1, //----path_cmd_move_to
341-
path_cmd_line_to = 2, //----path_cmd_line_to
342-
path_cmd_curve3 = 3, //----path_cmd_curve3
343-
path_cmd_curve4 = 4, //----path_cmd_curve4
339+
path_cmd_stop = 0, //----path_cmd_stop
340+
path_cmd_move_to = 1, //----path_cmd_move_to
341+
path_cmd_line_to = 2, //----path_cmd_line_to
342+
path_cmd_curve3 = 3, //----path_cmd_curve3
343+
path_cmd_curve4 = 4, //----path_cmd_curve4
344344
path_cmd_curveN = 5, //----path_cmd_curveN
345345
path_cmd_catrom = 6, //----path_cmd_catrom
346346
path_cmd_ubspline = 7, //----path_cmd_ubspline
347347
path_cmd_end_poly = 0x0F, //----path_cmd_end_poly
348-
path_cmd_mask = 0x0F //----path_cmd_mask
348+
path_cmd_mask = 0x0F //----path_cmd_mask
349349
};
350350

351351
//------------------------------------------------------------path_flags_e
352352
enum path_flags_e
353353
{
354-
path_flags_none = 0, //----path_flags_none
355-
path_flags_ccw = 0x10, //----path_flags_ccw
356-
path_flags_cw = 0x20, //----path_flags_cw
354+
path_flags_none = 0, //----path_flags_none
355+
path_flags_ccw = 0x10, //----path_flags_ccw
356+
path_flags_cw = 0x20, //----path_flags_cw
357357
path_flags_close = 0x40, //----path_flags_close
358-
path_flags_mask = 0xF0 //----path_flags_mask
358+
path_flags_mask = 0xF0 //----path_flags_mask
359359
};
360360

361361
//---------------------------------------------------------------is_vertex
@@ -372,7 +372,7 @@ namespace agg
372372

373373
//-----------------------------------------------------------------is_stop
374374
inline bool is_stop(unsigned c)
375-
{
375+
{
376376
return c == path_cmd_stop;
377377
}
378378

@@ -416,7 +416,7 @@ namespace agg
416416
inline bool is_close(unsigned c)
417417
{
418418
return (c & ~(path_flags_cw | path_flags_ccw)) ==
419-
(path_cmd_end_poly | path_flags_close);
419+
(path_cmd_end_poly | path_flags_close);
420420
}
421421

422422
//------------------------------------------------------------is_next_poly
@@ -440,19 +440,19 @@ namespace agg
440440
//-------------------------------------------------------------is_oriented
441441
inline bool is_oriented(unsigned c)
442442
{
443-
return (c & (path_flags_cw | path_flags_ccw)) != 0;
443+
return (c & (path_flags_cw | path_flags_ccw)) != 0;
444444
}
445445

446446
//---------------------------------------------------------------is_closed
447447
inline bool is_closed(unsigned c)
448448
{
449-
return (c & path_flags_close) != 0;
449+
return (c & path_flags_close) != 0;
450450
}
451451

452452
//----------------------------------------------------------get_close_flag
453453
inline unsigned get_close_flag(unsigned c)
454454
{
455-
return c & path_flags_close;
455+
return c & path_flags_close;
456456
}
457457

458458
//-------------------------------------------------------clear_orientation
@@ -513,7 +513,7 @@ namespace agg
513513
int x1, x2;
514514
const T* ptr;
515515
const_row_info() {}
516-
const_row_info(int x1_, int x2_, const T* ptr_) :
516+
const_row_info(int x1_, int x2_, const T* ptr_) :
517517
x1(x1_), x2(x2_), ptr(ptr_) {}
518518
};
519519

doc/pyplots/annotate_transform.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import numpy as np
2+
import matplotlib.pyplot as plt
3+
4+
x = np.arange(0, 10, 0.005)
5+
y = np.exp(-x/2.) * np.sin(2*np.pi*x)
6+
7+
fig = plt.figure()
8+
ax = fig.add_subplot(111)
9+
ax.plot(x, y)
10+
ax.set_xlim(0, 10)
11+
ax.set_ylim(-1, 1)
12+
13+
xdata, ydata = 5, 0
14+
xdisplay, ydisplay = ax.transData.transform((xdata, ydata))
15+
16+
bbox = dict(boxstyle="round", fc="0.8")
17+
arrowprops = dict(
18+
arrowstyle = "->",
19+
connectionstyle = "angle,angleA=0,angleB=90,rad=10")
20+
21+
offset = 72
22+
ax.annotate('data = (%.1f, %.1f)'%(xdata, ydata),
23+
(xdata, ydata), xytext=(-2*offset, offset), textcoords='offset points',
24+
bbox=bbox, arrowprops=arrowprops)
25+
26+
27+
disp = ax.annotate('display = (%.1f, %.1f)'%(xdisplay, ydisplay),
28+
(xdisplay, ydisplay), xytext=(0.5*offset, -offset),
29+
xycoords='figure pixels',
30+
textcoords='offset points',
31+
bbox=bbox, arrowprops=arrowprops)
32+
33+
34+
plt.show()
File renamed without changes.

doc/users/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ User's Guide
2222
artists.rst
2323
legend_guide.rst
2424
event_handling.rst
25-
annotation_guide.rst
25+
annotations_guide.rst
2626
legend.rst
2727
transforms_tutorial.rst
2828
toolkits.rst
File renamed without changes.

doc/users/transforms_tutorial.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ In 95% of your plotting, you won't need to think about this, as it
1212
happens under the hood, but as you push the limits of custom figure
1313
generation, it helps to have an understanding of these objects so you
1414
can reuse the existing transformations matplotlib makes available to
15-
you, or create your own. The table below summarizes the existing
15+
you, or create your own (see :mod:`matplotlib.transforms`. The table below summarizes the existing
1616
coordinate systems, the transformation object you should use to work
1717
in that coordinate system, and the description of that system. In the
1818
`Transformation Object` column, ``ax`` is a :class:`~matplotlib.axes.Axes` instance,
@@ -276,7 +276,8 @@ object identical to the first just to the right of it, and just below
276276
it, adjusting the zorder to make sure the shadow is drawn first and
277277
then the object it is shadowing above it. The transforms module has a
278278
helper transformation
279-
:class:~matplotlib.tranasforms.ScaledTranslation`. It is instantiated with::
279+
:class:`~matplotlib.transforms.ScaledTranslation`. It is
280+
instantiated with::
280281

281282
trans = ScaledTranslation(xt, yt, scale_trans)
282283

@@ -287,7 +288,7 @@ before applying the offsets. A typical use case is to use the figure
287288
to first scale `xty and `yt` specified in points to `display` space
288289
before doing the final offset. The dpi and inches offset is a
289290
common-enough use case that we have a special helper function to
290-
create it in :func:`~matplotlib.transforms.offset_copy`, which returns
291+
create it in :func:`matplotlib.transforms.offset_copy`, which returns
291292
a new transform with an added offset. But in the example below, we'll
292293
create the offset trransform ourselves. Note the use of the plus
293294
operator in::

0 commit comments

Comments
 (0)