Skip to content

Commit

Permalink
Fix compilation issues on VS2003. (Thanks Martin Spacek)
Browse files Browse the repository at this point in the history
svn path=/trunk/matplotlib/; revision=5070
  • Loading branch information
mdboom committed Apr 24, 2008
1 parent 4b36ac0 commit 5cceb32
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2008-04-24 Fix compilation issues on VS2003 (Thanks Martin Spacek for
all the help) - MGD

2008-04-24 Fix sub/superscripts when the size of the font has been
changed - MGD

Expand Down
8 changes: 4 additions & 4 deletions src/_backend_agg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ RendererAgg::set_clipbox(const Py::Object& cliprect, R rasterizer) {

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

_VERBOSE("RendererAgg::set_clipbox done");
Expand Down Expand Up @@ -807,7 +807,7 @@ void RendererAgg::_draw_path(path_t& path, bool has_clippath,
if (gc.linewidth != 0.0) {
double linewidth = gc.linewidth;
if (!gc.isaa) {
linewidth = (linewidth < 0.5) ? 0.5 : round(linewidth);
linewidth = (linewidth < 0.5) ? 0.5 : mpl_round(linewidth);
}
if (gc.dashes.size() == 0) {
stroke_t stroke(path);
Expand Down Expand Up @@ -1576,7 +1576,7 @@ RendererAgg::tostring_rgba_minimized(const Py::Tuple& args) {
int newwidth = 0;
int newheight = 0;
Py::String data;
if (xmin < xmax and ymin < ymax) {
if (xmin < xmax && ymin < ymax) {
// Expand the bounds by 1 pixel on all sides
xmin = std::max(0, xmin - 1);
ymin = std::max(0, ymin - 1);
Expand Down
13 changes: 5 additions & 8 deletions src/agg_py_path_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@
#include "numpy/arrayobject.h"
#include "agg_path_storage.h"
#include "MPL_isnan.h"
#include "mplutils.h"
#include <queue>

static inline double my_round(double v) {
return (double)(int)(v + ((v >= 0.0) ? 0.5 : -0.5));
}

class PathIterator
{
PyArrayObject* m_vertices;
Expand Down Expand Up @@ -161,8 +158,8 @@ class SimplifyPath
cmd = m_source->vertex(x, y);
if (m_quantize && agg::is_vertex(cmd))
{
*x = my_round(*x) + 0.5;
*y = my_round(*y) + 0.5;
*x = mpl_round(*x) + 0.5;
*y = mpl_round(*y) + 0.5;
}
return cmd;
}
Expand Down Expand Up @@ -218,8 +215,8 @@ class SimplifyPath
// Do any quantization if requested
if (m_quantize && agg::is_vertex(cmd))
{
*x = my_round(*x) + 0.5;
*y = my_round(*y) + 0.5;
*x = mpl_round(*x) + 0.5;
*y = mpl_round(*y) + 0.5;
}

//if we are starting a new path segment, move to the first point
Expand Down
6 changes: 5 additions & 1 deletion src/mplutils.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* mplutils.h --
/* mplutils.h --
*
* $Header$
* $Log$
Expand Down Expand Up @@ -26,6 +26,10 @@ void _VERBOSE(const std::string&);
#undef MAX
#define MAX(a, b) (((a) > (b)) ? (a) : (b))

inline double mpl_round(double v) {
return (double)(int)(v + ((v >= 0.0) ? 0.5 : -0.5));
}

class Printf
{
private :
Expand Down

0 comments on commit 5cceb32

Please sign in to comment.