Skip to content

Commit 5cceb32

Browse files
committed
Fix compilation issues on VS2003. (Thanks Martin Spacek)
svn path=/trunk/matplotlib/; revision=5070
1 parent 4b36ac0 commit 5cceb32

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2008-04-24 Fix compilation issues on VS2003 (Thanks Martin Spacek for
2+
all the help) - MGD
3+
14
2008-04-24 Fix sub/superscripts when the size of the font has been
25
changed - MGD
36

src/_backend_agg.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,8 @@ RendererAgg::set_clipbox(const Py::Object& cliprect, R rasterizer) {
270270

271271
double l, b, r, t;
272272
if (py_convert_bbox(cliprect.ptr(), l, b, r, t)) {
273-
rasterizer->clip_box(int(round(l)) + 1, height - int(round(b)),
274-
int(round(r)), height - int(round(t)));
273+
rasterizer->clip_box(int(mpl_round(l)) + 1, height - int(mpl_round(b)),
274+
int(mpl_round(r)), height - int(mpl_round(t)));
275275
}
276276

277277
_VERBOSE("RendererAgg::set_clipbox done");
@@ -807,7 +807,7 @@ void RendererAgg::_draw_path(path_t& path, bool has_clippath,
807807
if (gc.linewidth != 0.0) {
808808
double linewidth = gc.linewidth;
809809
if (!gc.isaa) {
810-
linewidth = (linewidth < 0.5) ? 0.5 : round(linewidth);
810+
linewidth = (linewidth < 0.5) ? 0.5 : mpl_round(linewidth);
811811
}
812812
if (gc.dashes.size() == 0) {
813813
stroke_t stroke(path);
@@ -1576,7 +1576,7 @@ RendererAgg::tostring_rgba_minimized(const Py::Tuple& args) {
15761576
int newwidth = 0;
15771577
int newheight = 0;
15781578
Py::String data;
1579-
if (xmin < xmax and ymin < ymax) {
1579+
if (xmin < xmax && ymin < ymax) {
15801580
// Expand the bounds by 1 pixel on all sides
15811581
xmin = std::max(0, xmin - 1);
15821582
ymin = std::max(0, ymin - 1);

src/agg_py_path_iterator.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,9 @@
66
#include "numpy/arrayobject.h"
77
#include "agg_path_storage.h"
88
#include "MPL_isnan.h"
9+
#include "mplutils.h"
910
#include <queue>
1011

11-
static inline double my_round(double v) {
12-
return (double)(int)(v + ((v >= 0.0) ? 0.5 : -0.5));
13-
}
14-
1512
class PathIterator
1613
{
1714
PyArrayObject* m_vertices;
@@ -161,8 +158,8 @@ class SimplifyPath
161158
cmd = m_source->vertex(x, y);
162159
if (m_quantize && agg::is_vertex(cmd))
163160
{
164-
*x = my_round(*x) + 0.5;
165-
*y = my_round(*y) + 0.5;
161+
*x = mpl_round(*x) + 0.5;
162+
*y = mpl_round(*y) + 0.5;
166163
}
167164
return cmd;
168165
}
@@ -218,8 +215,8 @@ class SimplifyPath
218215
// Do any quantization if requested
219216
if (m_quantize && agg::is_vertex(cmd))
220217
{
221-
*x = my_round(*x) + 0.5;
222-
*y = my_round(*y) + 0.5;
218+
*x = mpl_round(*x) + 0.5;
219+
*y = mpl_round(*y) + 0.5;
223220
}
224221

225222
//if we are starting a new path segment, move to the first point

src/mplutils.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* mplutils.h --
1+
/* mplutils.h --
22
*
33
* $Header$
44
* $Log$
@@ -26,6 +26,10 @@ void _VERBOSE(const std::string&);
2626
#undef MAX
2727
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
2828

29+
inline double mpl_round(double v) {
30+
return (double)(int)(v + ((v >= 0.0) ? 0.5 : -0.5));
31+
}
32+
2933
class Printf
3034
{
3135
private :

0 commit comments

Comments
 (0)