You can subscribe to this list here.
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(115) |
Aug
(120) |
Sep
(137) |
Oct
(170) |
Nov
(461) |
Dec
(263) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2008 |
Jan
(120) |
Feb
(74) |
Mar
(35) |
Apr
(74) |
May
(245) |
Jun
(356) |
Jul
(240) |
Aug
(115) |
Sep
(78) |
Oct
(225) |
Nov
(98) |
Dec
(271) |
| 2009 |
Jan
(132) |
Feb
(84) |
Mar
(74) |
Apr
(56) |
May
(90) |
Jun
(79) |
Jul
(83) |
Aug
(296) |
Sep
(214) |
Oct
(76) |
Nov
(82) |
Dec
(66) |
| 2010 |
Jan
(46) |
Feb
(58) |
Mar
(51) |
Apr
(77) |
May
(58) |
Jun
(126) |
Jul
(128) |
Aug
(64) |
Sep
(50) |
Oct
(44) |
Nov
(48) |
Dec
(54) |
| 2011 |
Jan
(68) |
Feb
(52) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <js...@us...> - 2008-01-23 13:20:31
|
Revision: 4886
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4886&view=rev
Author: jswhit
Date: 2008-01-23 05:20:03 -0800 (Wed, 23 Jan 2008)
Log Message:
-----------
make a copy of projparams dict, so original is not modified.
Modified Paths:
--------------
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/basemap.py
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/basemap.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/basemap.py 2008-01-22 19:43:18 UTC (rev 4885)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/basemap.py 2008-01-23 13:20:03 UTC (rev 4886)
@@ -930,7 +930,7 @@
boundaryxy = _geos.Polygon(b)
# compute proj instance for full disk, if necessary.
if not self._fulldisk:
- projparms = self.projparams
+ projparms = self.projparams.copy()
del projparms['x_0']
del projparms['y_0']
if self.projection == 'ortho':
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-01-22 19:43:27
|
Revision: 4885
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4885&view=rev
Author: mdboom
Date: 2008-01-22 11:43:18 -0800 (Tue, 22 Jan 2008)
Log Message:
-----------
Speed improvements for path simplification algorithm.
Modified Paths:
--------------
trunk/matplotlib/src/_backend_agg.cpp
trunk/matplotlib/src/agg_py_path_iterator.h
Modified: trunk/matplotlib/src/_backend_agg.cpp
===================================================================
--- trunk/matplotlib/src/_backend_agg.cpp 2008-01-22 13:08:27 UTC (rev 4884)
+++ trunk/matplotlib/src/_backend_agg.cpp 2008-01-22 19:43:18 UTC (rev 4885)
@@ -370,7 +370,7 @@
template<class Path>
bool should_simplify(Path& path) {
- return !path.has_curves() && path.total_vertices() > 5;
+ return !path.has_curves() && path.total_vertices() >= 128;
}
Py::Object
@@ -803,10 +803,7 @@
if (gc.linewidth != 0.0) {
double linewidth = gc.linewidth;
if (!gc.isaa) {
- if (linewidth < 0.5)
- linewidth = 0.5;
- else
- linewidth = round(linewidth);
+ linewidth = (linewidth < 0.5) ? 0.5 : round(linewidth);
}
if (gc.dashes.size() == 0) {
stroke_t stroke(path);
Modified: trunk/matplotlib/src/agg_py_path_iterator.h
===================================================================
--- trunk/matplotlib/src/agg_py_path_iterator.h 2008-01-22 13:08:27 UTC (rev 4884)
+++ trunk/matplotlib/src/agg_py_path_iterator.h 2008-01-22 19:43:18 UTC (rev 4885)
@@ -24,7 +24,9 @@
m_vertices = (PyArrayObject*)PyArray_FromObject
(vertices_obj.ptr(), PyArray_DOUBLE, 2, 2);
- if (!m_vertices || PyArray_NDIM(m_vertices) != 2 || PyArray_DIM(m_vertices, 1) != 2)
+ if (!m_vertices ||
+ PyArray_NDIM(m_vertices) != 2 ||
+ PyArray_DIM(m_vertices, 1) != 2)
throw Py::ValueError("Invalid vertices array.");
if (codes_obj.ptr() != Py_None)
@@ -116,7 +118,7 @@
SimplifyPath(VertexSource& source, bool quantize, bool simplify,
double width = 0.0, double height = 0.0) :
m_source(&source), m_quantize(quantize), m_simplify(simplify),
- m_width(width), m_height(height),
+ m_width(width), m_height(height), m_queue_read(0), m_queue_write(0),
m_moveto(true), m_lastx(0.0), m_lasty(0.0), m_clipped(false),
m_do_clipping(width > 0.0 && height > 0.0),
m_origdx(0.0), m_origdy(0.0),
@@ -177,19 +179,21 @@
// will be popped from the queue in subsequent calls. The following
// block will empty the queue before proceeding to the main loop below.
// -- Michael Droettboom
- if (m_queue.size())
+ if (m_queue_read < m_queue_write)
{
- const item& front = m_queue.front();
+ const item& front = m_queue[m_queue_read++];
unsigned cmd = front.cmd;
*x = front.x;
*y = front.y;
- m_queue.pop();
#if DEBUG_SIMPLIFY
printf((cmd == agg::path_cmd_move_to) ? "|" : "-");
#endif
return cmd;
}
+ m_queue_read = 0;
+ m_queue_write = 0;
+
// If the queue is now empty, and the path was fully consumed
// in the last call to the main loop, return agg::path_cmd_stop to
// signal that there are no more points to emit.
@@ -200,8 +204,8 @@
return agg::path_cmd_stop;
}
- // The main simplification loop. The point is consume only as many
- // points as necessary until some have been added to the outbound
+ // The main simplification loop. The point is to consume only as many
+ // points as necessary until something has been added to the outbound
// queue, not to run through the entire path in one go. This
// eliminates the need to allocate and fill an entire additional path
// array on each draw.
@@ -241,10 +245,10 @@
//skip any lines that are outside the drawing area. Note: More lines
//could be clipped, but a more involved calculation would be needed
if (m_do_clipping &&
- ((*x < -1 && m_lastx < -1) ||
- (*x > m_width + 1 && m_lastx > m_width + 1) ||
- (*y < -1 && m_lasty < -1) ||
- (*y > m_height + 1 && m_lasty > m_height + 1)))
+ ((*x < -1.0 && m_lastx < -1.0) ||
+ (*x > m_width + 1.0 && m_lastx > m_width + 1.0) ||
+ (*y < -1.0 && m_lasty < -1.0) ||
+ (*y > m_height + 1.0 && m_lasty > m_height + 1.0)))
{
m_lastx = *x;
m_lasty = *y;
@@ -264,31 +268,24 @@
{
if (m_clipped)
{
- m_queue.push(item(agg::path_cmd_move_to, m_lastx, m_lasty));
+ m_queue[m_queue_write++].set(agg::path_cmd_move_to, m_lastx, m_lasty);
m_clipped = false;
}
m_origdx = *x - m_lastx;
m_origdy = *y - m_lasty;
- m_origdNorm2 = m_origdx*m_origdx + m_origdy+m_origdy;
+ m_origdNorm2 = m_origdx*m_origdx + m_origdy*m_origdy;
//set all the variables to reflect this new orig vecor
m_dnorm2Max = m_origdNorm2;
- m_dnorm2Min = 0;
+ m_dnorm2Min = 0.0;
m_haveMin = false;
m_lastMax = true;
- m_maxX = *x;
- m_maxY = *y;
- m_minX = m_lastx;
- m_minY = m_lasty;
-
- m_lastWrittenX = m_lastx;
- m_lastWrittenY = m_lasty;
-
- // set the last point seen
- m_lastx = *x;
- m_lasty = *y;
+ m_lastx = m_maxX = *x;
+ m_lasty = m_maxY = *y;
+ m_lastWrittenX = m_minX = m_lastx;
+ m_lastWrittenY = m_minY = m_lasty;
#if DEBUG_SIMPLIFY
m_skipped++;
#endif
@@ -313,7 +310,6 @@
// get the para vector ( = (o.v)o/(o.o))
double paradx = totdot*m_origdx/m_origdNorm2;
double parady = totdot*m_origdy/m_origdNorm2;
- double paradNorm2 = paradx*paradx + parady*parady;
// get the perp vector ( = v - para)
double perpdx = totdx - paradx;
@@ -330,6 +326,8 @@
//direction. If anti-p, test if it is the longest in the
//opposite direction (the min of our final line)
+ double paradNorm2 = paradx*paradx + parady*parady;
+
m_lastMax = false;
if (totdot >= 0)
{
@@ -368,25 +366,21 @@
//direction we are drawing in, move back to we start drawing from
//back there.
if (m_haveMin)
- m_queue.push(item(agg::path_cmd_line_to, m_minX, m_minY));
- m_queue.push(item(agg::path_cmd_line_to, m_maxX, m_maxY));
+ m_queue[m_queue_write++].set(agg::path_cmd_move_to, m_minX, m_minY);
+ m_queue[m_queue_write++].set(agg::path_cmd_line_to, m_maxX, m_maxY);
//if we clipped some segments between this line and the next line
//we are starting, we also need to move to the last point.
if (m_clipped)
- {
- m_queue.push(item(agg::path_cmd_move_to, m_lastx, m_lasty));
- }
+ m_queue[m_queue_write++].set(agg::path_cmd_move_to, m_lastx, m_lasty);
else if (!m_lastMax)
- {
//if the last line was not the longest line, then move back to
//the end point of the last line in the sequence. Only do this
//if not clipped, since in that case lastx,lasty is not part of
//the line just drawn.
//Would be move_to if not for the artifacts
- m_queue.push(item(agg::path_cmd_line_to, m_lastx, m_lasty));
- }
+ m_queue[m_queue_write++].set(agg::path_cmd_line_to, m_lastx, m_lasty);
//now reset all the variables to get ready for the next line
m_origdx = *x - m_lastx;
@@ -394,23 +388,17 @@
m_origdNorm2 = m_origdx*m_origdx + m_origdy*m_origdy;
m_dnorm2Max = m_origdNorm2;
- m_dnorm2Min = 0;
+ m_dnorm2Min = 0.0;
m_haveMin = false;
m_lastMax = true;
- m_maxX = *x;
- m_maxY = *y;
- m_minX = m_lastx;
- m_minY = m_lasty;
+ m_lastx = m_maxX = *x;
+ m_lasty = m_maxY = *y;
+ m_lastWrittenX = m_minX = m_lastx;
+ m_lastWrittenY = m_minY = m_lasty;
- m_lastWrittenX = m_lastx;
- m_lastWrittenY = m_lasty;
-
m_clipped = false;
-
- m_lastx = *x;
- m_lasty = *y;
#if DEBUG_SIMPLIFY
- m_pushed += m_queue.size();
+ m_pushed += m_queue_write - m_queue_read;
#endif
break;
}
@@ -423,21 +411,20 @@
if (m_origdNorm2 != 0)
{
if (m_haveMin)
- m_queue.push(item(agg::path_cmd_line_to, m_minX, m_minY));
- m_queue.push(item(agg::path_cmd_line_to, m_maxX, m_maxY));
+ m_queue[m_queue_write++].set(agg::path_cmd_line_to, m_minX, m_minY);
+ m_queue[m_queue_write++].set(agg::path_cmd_line_to, m_maxX, m_maxY);
}
m_done = true;
}
// Return the first item in the queue, if any, otherwise
// indicate that we're done.
- if (m_queue.size())
+ if (m_queue_read < m_queue_write)
{
- const item& front = m_queue.front();
+ const item& front = m_queue[m_queue_read++];
unsigned cmd = front.cmd;
*x = front.x;
*y = front.y;
- m_queue.pop();
#if DEBUG_SIMPLIFY
printf((cmd == agg::path_cmd_move_to) ? "|" : "-");
#endif
@@ -460,14 +447,20 @@
struct item
{
- item(unsigned cmd_, const double& x_, double& y_) :
- cmd(cmd_), x(x_), y(y_) {}
+ item() {}
+ inline void set(const unsigned cmd_, const double& x_, const double& y_) {
+ cmd = cmd_;
+ x = x_;
+ y = y_;
+ }
unsigned cmd;
double x;
double y;
};
- typedef std::queue<item> ItemQueue;
- ItemQueue m_queue;
+ int m_queue_read;
+ int m_queue_write;
+ item m_queue[6];
+
bool m_moveto;
double m_lastx, m_lasty;
bool m_clipped;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-01-22 13:09:31
|
Revision: 4884
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4884&view=rev
Author: mdboom
Date: 2008-01-22 05:08:27 -0800 (Tue, 22 Jan 2008)
Log Message:
-----------
Fix relim() to properly ignore existing data. (Thanks Darren Dale).
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/axes.py
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2008-01-21 19:08:35 UTC (rev 4883)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2008-01-22 13:08:27 UTC (rev 4884)
@@ -1201,9 +1201,11 @@
'recompute the datalimits based on current artists'
self.dataLim.ignore(True)
for line in self.lines:
+ self.ignore_existing_data_limits = True
self._update_line_limits(line)
for p in self.patches:
+ self.ignore_existing_data_limits = True
self._update_patch_limits(p)
def update_datalim(self, xys):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-01-21 19:10:45
|
Revision: 4883
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4883&view=rev
Author: mdboom
Date: 2008-01-21 11:08:35 -0800 (Mon, 21 Jan 2008)
Log Message:
-----------
Add more debugging output to the path simplification code.
Modified Paths:
--------------
trunk/matplotlib/src/agg_py_path_iterator.h
Modified: trunk/matplotlib/src/agg_py_path_iterator.h
===================================================================
--- trunk/matplotlib/src/agg_py_path_iterator.h 2008-01-21 19:03:48 UTC (rev 4882)
+++ trunk/matplotlib/src/agg_py_path_iterator.h 2008-01-21 19:08:35 UTC (rev 4883)
@@ -6,7 +6,7 @@
#include "numpy/arrayobject.h"
#include "agg_path_storage.h"
#include "MPL_isnan.h"
-#include <deque>
+#include <queue>
class PathIterator
{
@@ -134,7 +134,8 @@
#if DEBUG_SIMPLIFY
~SimplifyPath()
{
- printf("%d %d\n", m_pushed, m_skipped);
+ if (m_simplify)
+ printf("%d %d\n", m_pushed, m_skipped);
}
#endif
@@ -175,21 +176,29 @@
// multiple points can be emitted in a single call, and those points
// will be popped from the queue in subsequent calls. The following
// block will empty the queue before proceeding to the main loop below.
+ // -- Michael Droettboom
if (m_queue.size())
{
const item& front = m_queue.front();
unsigned cmd = front.cmd;
*x = front.x;
*y = front.y;
- m_queue.pop_front();
+ m_queue.pop();
+#if DEBUG_SIMPLIFY
+ printf((cmd == agg::path_cmd_move_to) ? "|" : "-");
+#endif
return cmd;
}
// If the queue is now empty, and the path was fully consumed
// in the last call to the main loop, return agg::path_cmd_stop to
// signal that there are no more points to emit.
- if (m_done)
+ if (m_done) {
+#if DEBUG_SIMPLIFY
+ printf(".\n");
+#endif
return agg::path_cmd_stop;
+ }
// The main simplification loop. The point is consume only as many
// points as necessary until some have been added to the outbound
@@ -209,15 +218,15 @@
// + init
if (m_moveto)
{
- m_queue.push_back(item(agg::path_cmd_move_to, *x, *y));
m_lastx = *x;
m_lasty = *y;
m_moveto = false;
m_origdNorm2 = 0.0;
#if DEBUG_SIMPLIFY
m_pushed++;
+ printf("|");
#endif
- break;
+ return agg::path_cmd_move_to;
}
// Don't render line segments less than one pixel long
@@ -240,6 +249,9 @@
m_lastx = *x;
m_lasty = *y;
m_clipped = true;
+#if DEBUG_SIMPLIFY
+ m_skipped++;
+#endif
continue;
}
@@ -252,7 +264,7 @@
{
if (m_clipped)
{
- m_queue.push_back(item(agg::path_cmd_move_to, m_lastx, m_lasty));
+ m_queue.push(item(agg::path_cmd_move_to, m_lastx, m_lasty));
m_clipped = false;
}
@@ -277,6 +289,9 @@
// set the last point seen
m_lastx = *x;
m_lasty = *y;
+#if DEBUG_SIMPLIFY
+ m_skipped++;
+#endif
continue;
}
@@ -339,6 +354,9 @@
m_lastx = *x;
m_lasty = *y;
+#if DEBUG_SIMPLIFY
+ m_skipped++;
+#endif
continue;
}
@@ -350,14 +368,14 @@
//direction we are drawing in, move back to we start drawing from
//back there.
if (m_haveMin)
- m_queue.push_back(item(agg::path_cmd_line_to, m_minX, m_minY));
- m_queue.push_back(item(agg::path_cmd_line_to, m_maxX, m_maxY));
+ m_queue.push(item(agg::path_cmd_line_to, m_minX, m_minY));
+ m_queue.push(item(agg::path_cmd_line_to, m_maxX, m_maxY));
//if we clipped some segments between this line and the next line
//we are starting, we also need to move to the last point.
if (m_clipped)
{
- m_queue.push_back(item(agg::path_cmd_move_to, m_lastx, m_lasty));
+ m_queue.push(item(agg::path_cmd_move_to, m_lastx, m_lasty));
}
else if (!m_lastMax)
{
@@ -367,11 +385,10 @@
//the line just drawn.
//Would be move_to if not for the artifacts
- m_queue.push_back(item(agg::path_cmd_line_to, m_lastx, m_lasty));
+ m_queue.push(item(agg::path_cmd_line_to, m_lastx, m_lasty));
}
//now reset all the variables to get ready for the next line
-
m_origdx = *x - m_lastx;
m_origdy = *y - m_lasty;
m_origdNorm2 = m_origdx*m_origdx + m_origdy*m_origdy;
@@ -393,7 +410,7 @@
m_lastx = *x;
m_lasty = *y;
#if DEBUG_SIMPLIFY
- m_pushed++;
+ m_pushed += m_queue.size();
#endif
break;
}
@@ -406,8 +423,8 @@
if (m_origdNorm2 != 0)
{
if (m_haveMin)
- m_queue.push_back(item(agg::path_cmd_line_to, m_minX, m_minY));
- m_queue.push_back(item(agg::path_cmd_line_to, m_maxX, m_maxY));
+ m_queue.push(item(agg::path_cmd_line_to, m_minX, m_minY));
+ m_queue.push(item(agg::path_cmd_line_to, m_maxX, m_maxY));
}
m_done = true;
}
@@ -420,11 +437,17 @@
unsigned cmd = front.cmd;
*x = front.x;
*y = front.y;
- m_queue.pop_front();
+ m_queue.pop();
+#if DEBUG_SIMPLIFY
+ printf((cmd == agg::path_cmd_move_to) ? "|" : "-");
+#endif
return cmd;
}
else
{
+#if DEBUG_SIMPLIFY
+ printf(".\n");
+#endif
return agg::path_cmd_stop;
}
}
@@ -443,7 +466,7 @@
double x;
double y;
};
- typedef std::deque<item> ItemQueue;
+ typedef std::queue<item> ItemQueue;
ItemQueue m_queue;
bool m_moveto;
double m_lastx, m_lasty;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-01-21 19:06:02
|
Revision: 4882
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4882&view=rev
Author: mdboom
Date: 2008-01-21 11:03:48 -0800 (Mon, 21 Jan 2008)
Log Message:
-----------
Fix bug with pie chart slices less than 2.5 degrees.
Modified Paths:
--------------
branches/v0_91_maint/lib/matplotlib/patches.py
Modified: branches/v0_91_maint/lib/matplotlib/patches.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/patches.py 2008-01-21 18:32:57 UTC (rev 4881)
+++ branches/v0_91_maint/lib/matplotlib/patches.py 2008-01-21 19:03:48 UTC (rev 4882)
@@ -526,7 +526,9 @@
theta1 = float(theta1)
theta2 = float(theta2)
dtheta = float(dtheta)
- num_points = abs(theta2 - theta1) / dtheta
+ num_points = (abs(theta2 - theta1) / dtheta)
+ if num_points < 2.0:
+ num_points = 2.0
rads = (npy.pi/180.) * npy.linspace(theta1, theta2, num_points, endpoint=True)
xs = r*npy.cos(rads)+xc
ys = r*npy.sin(rads)+yc
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-01-21 18:33:59
|
Revision: 4881
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4881&view=rev
Author: mdboom
Date: 2008-01-21 10:32:57 -0800 (Mon, 21 Jan 2008)
Log Message:
-----------
Fix memory leak in pcolor and pcolormesh. (Thanks Rob Hetland)
Modified Paths:
--------------
trunk/matplotlib/src/_backend_agg.cpp
trunk/matplotlib/src/_path.cpp
Modified: trunk/matplotlib/src/_backend_agg.cpp
===================================================================
--- trunk/matplotlib/src/_backend_agg.cpp 2008-01-18 18:21:14 UTC (rev 4880)
+++ trunk/matplotlib/src/_backend_agg.cpp 2008-01-21 18:32:57 UTC (rev 4881)
@@ -1001,6 +1001,7 @@
for (i = 0; i < N; ++i) {
typename PathGenerator::path_iterator path = path_generator(i);
+
if (Ntransforms) {
trans = transforms[i % Ntransforms];
} else {
@@ -1070,15 +1071,18 @@
}
}
}
+
+ Py_XDECREF(offsets);
+ Py_XDECREF(facecolors);
+ Py_XDECREF(edgecolors);
+ return Py::Object();
} catch (...) {
+ printf("Exception!\n");
Py_XDECREF(offsets);
Py_XDECREF(facecolors);
Py_XDECREF(edgecolors);
throw;
}
-
- Py_XDECREF(offsets);
- return Py::Object();
}
@@ -1186,9 +1190,9 @@
public:
typedef QuadMeshPathIterator path_iterator;
- inline QuadMeshGenerator(size_t meshWidth, size_t meshHeight, const Py::Object& coordinates) :
+ inline QuadMeshGenerator(size_t meshWidth, size_t meshHeight, PyObject* coordinates) :
m_meshWidth(meshWidth), m_meshHeight(meshHeight), m_coordinates(NULL) {
- PyArrayObject* coordinates_array = (PyArrayObject*)PyArray_FromObject(coordinates.ptr(), PyArray_DOUBLE, 3, 3);
+ PyArrayObject* coordinates_array = (PyArrayObject*)PyArray_FromObject(coordinates, PyArray_DOUBLE, 3, 3);
if (!coordinates_array) {
throw Py::ValueError("Invalid coordinates array.");
}
@@ -1214,6 +1218,7 @@
_VERBOSE("RendererAgg::draw_quad_mesh");
args.verify_length(12);
+
//segments, trans, clipbox, colors, linewidths, antialiaseds
agg::trans_affine master_transform = py_to_agg_transformation_matrix(args[0]);
Py::Object cliprect = args[1];
@@ -1221,12 +1226,13 @@
agg::trans_affine clippath_trans = py_to_agg_transformation_matrix(args[3], false);
size_t mesh_width = Py::Int(args[4]);
size_t mesh_height = Py::Int(args[5]);
- Py::Object coordinates = args[6];
+ PyObject* coordinates = args[6].ptr();
Py::Object offsets_obj = args[7];
agg::trans_affine offset_trans = py_to_agg_transformation_matrix(args[8]);
Py::Object facecolors_obj = args[9];
bool antialiased = (bool)Py::Int(args[10]);
bool showedges = (bool)Py::Int(args[11]);
+ bool free_edgecolors = false;
QuadMeshGenerator path_generator(mesh_width, mesh_height, coordinates);
@@ -1242,12 +1248,14 @@
npy_intp dims[] = { 1, 4, 0 };
double data[] = { 0, 0, 0, 1 };
edgecolors_obj = PyArray_SimpleNewFromData(2, dims, PyArray_DOUBLE, (char*)data);
+ free_edgecolors = true;
} else {
if (antialiased) {
edgecolors_obj = facecolors_obj;
} else {
npy_intp dims[] = { 0, 0 };
edgecolors_obj = PyArray_SimpleNew(1, dims, PyArray_DOUBLE);
+ free_edgecolors = true;
}
}
@@ -1266,6 +1274,9 @@
linestyles_obj,
antialiaseds);
+ if (free_edgecolors)
+ Py_XDECREF(edgecolors_obj.ptr());
+
return Py::Object();
}
Modified: trunk/matplotlib/src/_path.cpp
===================================================================
--- trunk/matplotlib/src/_path.cpp 2008-01-18 18:21:14 UTC (rev 4880)
+++ trunk/matplotlib/src/_path.cpp 2008-01-21 18:32:57 UTC (rev 4881)
@@ -294,11 +294,17 @@
agg::trans_affine trans = py_to_agg_transformation_matrix(args[1], false);
npy_intp extent_dims[] = { 2, 2, 0 };
- double* extents_data = new double[4];
+ double* extents_data = NULL;
double xm, ym;
PyArrayObject* extents = NULL;
try
{
+ extents = (PyArrayObject*)PyArray_SimpleNew
+ (2, extent_dims, PyArray_DOUBLE);
+ if (extents == NULL)
+ throw Py::MemoryError("Could not allocate result array");
+ extents_data = (double*)PyArray_DATA(extents);
+
extents_data[0] = std::numeric_limits<double>::infinity();
extents_data[1] = std::numeric_limits<double>::infinity();
extents_data[2] = -std::numeric_limits<double>::infinity();
@@ -307,16 +313,10 @@
::get_path_extents(path, trans,
&extents_data[0], &extents_data[1], &extents_data[2], &extents_data[3],
&xm, &ym);
-
- extents = (PyArrayObject*)PyArray_SimpleNewFromData
- (2, extent_dims, PyArray_DOUBLE, extents_data);
}
catch (...)
{
- if (extents)
- Py_XDECREF(extents);
- else
- delete[] extents_data;
+ Py_XDECREF(extents);
throw;
}
@@ -357,15 +357,27 @@
Py_XDECREF(input_minpos);
npy_intp extent_dims[] = { 2, 2, 0 };
- double* extents_data = new double[4];
+ double* extents_data = NULL;
npy_intp minpos_dims[] = { 2, 0 };
- double* minpos_data = new double[2];
+ double* minpos_data = NULL;
PyArrayObject* extents = NULL;
PyArrayObject* minpos = NULL;
bool changed = false;
try
{
+ extents = (PyArrayObject*)PyArray_SimpleNew
+ (2, extent_dims, PyArray_DOUBLE);
+ if (extents == NULL)
+ throw Py::MemoryError("Could not allocate result array");
+ minpos = (PyArrayObject*)PyArray_SimpleNew
+ (1, minpos_dims, PyArray_DOUBLE);
+ if (minpos == NULL)
+ throw Py::MemoryError("Could not allocate result array");
+
+ extents_data = (double*)PyArray_DATA(extents);
+ minpos_data = (double*)PyArray_DATA(minpos);
+
if (ignore)
{
extents_data[0] = std::numeric_limits<double>::infinity();
@@ -396,21 +408,11 @@
minpos_data[0] != xm ||
minpos_data[1] != ym);
- extents = (PyArrayObject*)PyArray_SimpleNewFromData
- (2, extent_dims, PyArray_DOUBLE, extents_data);
- minpos = (PyArrayObject*)PyArray_SimpleNewFromData
- (1, minpos_dims, PyArray_DOUBLE, minpos_data);
}
catch (...)
{
- if (extents)
- Py_XDECREF(extents);
- else
- delete[] extents_data;
- if (minpos)
- Py_XDECREF(minpos);
- else
- delete[] minpos_data;
+ Py_XDECREF(extents);
+ Py_XDECREF(minpos);
throw;
}
@@ -419,6 +421,9 @@
result[1] = Py::Object((PyObject*) minpos);
result[2] = Py::Int(changed ? 1 : 0);
+ Py_XDECREF(extents);
+ Py_XDECREF(minpos);
+
return result;
}
@@ -964,7 +969,7 @@
{
args.verify_length(2);
- Py::Object bbox = args[0];
+ Py::Object bbox = args[0];
Py::SeqBase<Py::Object> bboxes = args[1];
double ax0, ay0, ax1, ay1;
@@ -1086,16 +1091,15 @@
if (polygon.size() == 0)
return;
npy_intp polygon_dims[] = { polygon.size() / 2, 2, 0 };
- double* polygon_data = new double[polygon.size()];
- memcpy(polygon_data, &polygon[0], polygon.size() * sizeof(double));
PyArrayObject* polygon_array = NULL;
- polygon_array = (PyArrayObject*)PyArray_SimpleNewFromData
- (2, polygon_dims, PyArray_DOUBLE, polygon_data);
+ polygon_array = (PyArrayObject*)PyArray_SimpleNew
+ (2, polygon_dims, PyArray_DOUBLE);
if (!polygon_array)
{
- delete[] polygon_data;
- throw Py::RuntimeError("Error creating polygon array");
+ throw Py::MemoryError("Error creating polygon array");
}
+ double* polygon_data = (double*)PyArray_DATA(polygon_array);
+ memcpy(polygon_data, &polygon[0], polygon.size() * sizeof(double));
polygons.append(Py::Object((PyObject*)polygon_array));
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sa...@us...> - 2008-01-18 18:25:30
|
Revision: 4880
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4880&view=rev
Author: sameerd
Date: 2008-01-18 10:21:14 -0800 (Fri, 18 Jan 2008)
Log Message:
-----------
rec_join now returns an array that has its rows in the same order as the first record array passed to it.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/mlab.py
Modified: trunk/matplotlib/lib/matplotlib/mlab.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mlab.py 2008-01-18 17:59:51 UTC (rev 4879)
+++ trunk/matplotlib/lib/matplotlib/mlab.py 2008-01-18 18:21:14 UTC (rev 4880)
@@ -1990,11 +1990,6 @@
def makekey(row):
return tuple([row[name] for name in key])
-
- names = list(r1.dtype.names) + [name for name in r2.dtype.names if name not in set(r1.dtype.names)]
-
-
-
r1d = dict([(makekey(row),i) for i,row in enumerate(r1)])
r2d = dict([(makekey(row),i) for i,row in enumerate(r2)])
@@ -2003,12 +1998,14 @@
keys = r1keys & r2keys
- r1ind = [r1d[k] for k in keys]
- r2ind = [r2d[k] for k in keys]
+ r1ind = npy.array([r1d[k] for k in keys])
+ r2ind = npy.array([r2d[k] for k in keys])
+ # Make sure that the output rows have the same relative order as r1
+ sortind = r1ind.argsort()
- r1 = r1[r1ind]
- r2 = r2[r2ind]
+ r1 = r1[r1ind[sortind]]
+ r2 = r2[r2ind[sortind]]
r2 = rec_drop_fields(r2, r1.dtype.names)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-01-18 18:01:42
|
Revision: 4879
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4879&view=rev
Author: mdboom
Date: 2008-01-18 09:59:51 -0800 (Fri, 18 Jan 2008)
Log Message:
-----------
Fix poly_editor.py
Modified Paths:
--------------
branches/v0_91_maint/examples/poly_editor.py
Modified: branches/v0_91_maint/examples/poly_editor.py
===================================================================
--- branches/v0_91_maint/examples/poly_editor.py 2008-01-18 17:57:23 UTC (rev 4878)
+++ branches/v0_91_maint/examples/poly_editor.py 2008-01-18 17:59:51 UTC (rev 4879)
@@ -37,6 +37,7 @@
x, y = zip(*self.poly.xy)
self.line = Line2D(x,y,marker='o', markerfacecolor='r', animated=True)
+ self.ax.add_line(self.line)
#self._update_line(poly)
cid = self.poly.add_callback(self.poly_changed)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-01-18 17:58:54
|
Revision: 4878
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4878&view=rev
Author: mdboom
Date: 2008-01-18 09:57:23 -0800 (Fri, 18 Jan 2008)
Log Message:
-----------
Fix poly_editor.py
Modified Paths:
--------------
trunk/matplotlib/examples/poly_editor.py
Modified: trunk/matplotlib/examples/poly_editor.py
===================================================================
--- trunk/matplotlib/examples/poly_editor.py 2008-01-18 17:27:35 UTC (rev 4877)
+++ trunk/matplotlib/examples/poly_editor.py 2008-01-18 17:57:23 UTC (rev 4878)
@@ -37,6 +37,7 @@
x, y = zip(*self.poly.xy)
self.line = Line2D(x,y,marker='o', markerfacecolor='r', animated=True)
+ self.ax.add_line(self.line)
#self._update_line(poly)
cid = self.poly.add_callback(self.poly_changed)
@@ -106,14 +107,17 @@
self.poly.xy = [tup for i,tup in enumerate(self.poly.xy) if i!=ind]
self.line.set_data(zip(*self.poly.xy))
elif event.key=='i':
- xys = self.poly.get_transform().seq_xy_tups(self.poly.xy)
+ xys = self.poly.get_transform().transform(self.poly.xy)
p = event.x, event.y # display coords
for i in range(len(xys)-1):
s0 = xys[i]
s1 = xys[i+1]
d = dist_point_to_segment(p, s0, s1)
if d<=self.epsilon:
- self.poly.xy.insert(i+1, (event.xdata, event.ydata))
+ self.poly.xy = npy.array(
+ list(self.poly.xy[:i]) +
+ [(event.xdata, event.ydata)] +
+ list(self.poly.xy[i:]))
self.line.set_data(zip(*self.poly.xy))
break
@@ -130,7 +134,7 @@
self.poly.xy[self._ind] = x,y
self.line.set_data(zip(*self.poly.xy))
-
+
self.canvas.restore_region(self.background)
self.ax.draw_artist(self.poly)
self.ax.draw_artist(self.line)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-01-18 17:30:57
|
Revision: 4877
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4877&view=rev
Author: mdboom
Date: 2008-01-18 09:27:35 -0800 (Fri, 18 Jan 2008)
Log Message:
-----------
Fix lasso_demo.py
Modified Paths:
--------------
trunk/matplotlib/examples/lasso_demo.py
trunk/matplotlib/lib/matplotlib/collections.py
Modified: trunk/matplotlib/examples/lasso_demo.py
===================================================================
--- trunk/matplotlib/examples/lasso_demo.py 2008-01-18 15:04:52 UTC (rev 4876)
+++ trunk/matplotlib/examples/lasso_demo.py 2008-01-18 17:27:35 UTC (rev 4877)
@@ -35,12 +35,12 @@
self.Nxy = len(data)
- self.facecolors = [d.color for d in data]
+ facecolors = [d.color for d in data]
self.xys = [(d.x, d.y) for d in data]
self.collection = RegularPolyCollection(
fig.dpi, 6, sizes=(100,),
- facecolors=self.facecolors,
+ facecolors=facecolors,
offsets = self.xys,
transOffset = ax.transData)
@@ -49,12 +49,13 @@
self.cid = self.canvas.mpl_connect('button_press_event', self.onpress)
def callback(self, verts):
+ facecolors = self.collection.get_facecolors()
ind = nonzero(points_inside_poly(self.xys, verts))[0]
for i in range(self.Nxy):
if i in ind:
- self.facecolors[i] = Datum.colorin
+ facecolors[i] = Datum.colorin
else:
- self.facecolors[i] = Datum.colorout
+ facecolors[i] = Datum.colorout
self.canvas.draw_idle()
self.canvas.widgetlock.release(self.lasso)
Modified: trunk/matplotlib/lib/matplotlib/collections.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/collections.py 2008-01-18 15:04:52 UTC (rev 4876)
+++ trunk/matplotlib/lib/matplotlib/collections.py 2008-01-18 17:27:35 UTC (rev 4877)
@@ -275,6 +275,10 @@
set_facecolors = set_facecolor
+ def get_facecolor(self):
+ return self._facecolors
+ get_facecolors = get_facecolor
+
def set_edgecolor(self, c):
"""
Set the edgecolor(s) of the collection. c can be a matplotlib color
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-01-18 15:05:45
|
Revision: 4876
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4876&view=rev
Author: mdboom
Date: 2008-01-18 07:04:52 -0800 (Fri, 18 Jan 2008)
Log Message:
-----------
Bugfig for last commit. Don't do simplifications on filled paths
ever. (Until we can work out the difficulties).
Modified Paths:
--------------
trunk/matplotlib/src/_backend_agg.cpp
Modified: trunk/matplotlib/src/_backend_agg.cpp
===================================================================
--- trunk/matplotlib/src/_backend_agg.cpp 2008-01-18 14:44:10 UTC (rev 4875)
+++ trunk/matplotlib/src/_backend_agg.cpp 2008-01-18 15:04:52 UTC (rev 4876)
@@ -887,7 +887,7 @@
trans *= agg::trans_affine_scaling(1.0, -1.0);
trans *= agg::trans_affine_translation(0.0, (double)height);
bool snap = should_snap(path, trans);
- bool simplify = should_simplify(path);
+ bool simplify = should_simplify(path) && !face.first;
transformed_path_t tpath(path, trans);
simplify_t simplified(tpath, snap, simplify, width, height);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-01-18 14:44:44
|
Revision: 4875
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4875&view=rev
Author: mdboom
Date: 2008-01-18 06:44:10 -0800 (Fri, 18 Jan 2008)
Log Message:
-----------
Add line simplification, to cut down on the number of line segments
that need to be stroked. Affects *Agg and Gdk backends.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/backends/backend_gdk.py
trunk/matplotlib/lib/matplotlib/path.py
trunk/matplotlib/src/_backend_agg.cpp
trunk/matplotlib/src/_path.cpp
trunk/matplotlib/src/agg_py_path_iterator.h
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gdk.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_gdk.py 2008-01-17 04:13:27 UTC (rev 4874)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gdk.py 2008-01-18 14:44:10 UTC (rev 4875)
@@ -84,7 +84,7 @@
def draw_path(self, gc, path, transform, rgbFace=None):
transform = transform + Affine2D(). \
scale(1.0, -1.0).translate(0, self.height)
- polygons = path.to_polygons(transform)
+ polygons = path.to_polygons(transform, self.width, self.height)
for polygon in polygons:
# draw_polygon won't take an arbitrary sequence -- it must be a list
# of tuples
Modified: trunk/matplotlib/lib/matplotlib/path.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/path.py 2008-01-17 04:13:27 UTC (rev 4874)
+++ trunk/matplotlib/lib/matplotlib/path.py 2008-01-18 14:44:10 UTC (rev 4875)
@@ -283,7 +283,7 @@
new_codes = None
return Path(vertices, new_codes)
- def to_polygons(self, transform=None):
+ def to_polygons(self, transform=None, width=0, height=0):
"""
Convert this path to a list of polygons. Each polygon is an
Nx2 array of vertices. In other words, each polygon has no
@@ -292,13 +292,13 @@
if transform is not None:
transform = transform.frozen()
# Deal with the common and simple case
- if self.codes is None:
+ if self.codes is None and len(self.vertices) < 100:
if len(self.vertices):
return [transform.transform(self.vertices)]
return []
# Deal with the case where there are curves and/or multiple
# subpaths (using extension code)
- return convert_path_to_polygons(self, transform)
+ return convert_path_to_polygons(self, transform, width, height)
_unit_rectangle = None
#@classmethod
Modified: trunk/matplotlib/src/_backend_agg.cpp
===================================================================
--- trunk/matplotlib/src/_backend_agg.cpp 2008-01-17 04:13:27 UTC (rev 4874)
+++ trunk/matplotlib/src/_backend_agg.cpp 2008-01-18 14:44:10 UTC (rev 4875)
@@ -20,6 +20,7 @@
#include "agg_span_image_filter_gray.h"
#include "agg_span_image_filter_rgba.h"
#include "agg_span_interpolator_linear.h"
+#include "agg_conv_shorten_path.h"
#include "util/agg_color_conv_rgb8.h"
#include "ft2font.h"
@@ -84,31 +85,6 @@
return Py::String(PyString_FromStringAndSize((const char*)data, height*stride), true);
}
-template<class VertexSource> class conv_quantize
-{
-public:
- conv_quantize(VertexSource& source, bool quantize) :
- m_source(&source), m_quantize(quantize) {}
-
- void rewind(unsigned path_id) {
- m_source->rewind(path_id);
- }
-
- unsigned vertex(double* x, double* y) {
- unsigned cmd = m_source->vertex(x, y);
- if (m_quantize && agg::is_vertex(cmd)) {
- *x = round(*x) + 0.5;
- *y = round(*y) + 0.5;
- }
- return cmd;
- }
-
-private:
- VertexSource* m_source;
- bool m_quantize;
-};
-
-
GCAgg::GCAgg(const Py::Object &gc, double dpi) :
dpi(dpi), isaa(true), linewidth(1.0), alpha(1.0),
dashOffset(0.0)
@@ -358,8 +334,8 @@
template<class Path>
bool should_snap(Path& path, const agg::trans_affine& trans) {
- // If this contains only straight horizontal or vertical lines, quantize to nearest
- // pixels
+ // If this contains only straight horizontal or vertical lines, it should be
+ // quantized to the nearest pixels
double x0, y0, x1, y1;
unsigned code;
@@ -392,6 +368,11 @@
return true;
}
+template<class Path>
+bool should_simplify(Path& path) {
+ return !path.has_curves() && path.total_vertices() > 5;
+}
+
Py::Object
RendererAgg::copy_from_bbox(const Py::Tuple& args) {
//copy region in bbox to buffer and return swig/agg buffer object
@@ -479,7 +460,7 @@
Py::Object
RendererAgg::draw_markers(const Py::Tuple& args) {
typedef agg::conv_transform<PathIterator> transformed_path_t;
- typedef conv_quantize<transformed_path_t> quantize_t;
+ typedef SimplifyPath<transformed_path_t> simplify_t;
typedef agg::conv_curve<transformed_path_t> curve_t;
typedef agg::conv_stroke<curve_t> stroke_t;
typedef agg::pixfmt_amask_adaptor<pixfmt, alpha_mask_type> pixfmt_amask_type;
@@ -510,8 +491,8 @@
bool snap = should_snap(path, trans);
transformed_path_t path_transformed(path, trans);
GCAgg gc = GCAgg(gc_obj, dpi);
- quantize_t path_quantized(path_transformed, snap);
- path_quantized.rewind(0);
+ simplify_t path_simplified(path_transformed, snap, false, width, height);
+ path_simplified.rewind(0);
facepair_t face = _get_rgba_face(face_obj, gc.alpha);
@@ -564,7 +545,7 @@
agg::serialized_scanlines_adaptor_aa8::embedded_scanline sl;
if (has_clippath) {
- while (path_quantized.vertex(&x, &y) != agg::path_cmd_stop) {
+ while (path_simplified.vertex(&x, &y) != agg::path_cmd_stop) {
pixfmt_amask_type pfa(*pixFmt, *alphaMask);
amask_ren_type r(pfa);
amask_aa_renderer_type ren(r);
@@ -579,7 +560,7 @@
agg::render_scanlines(sa, sl, ren);
}
} else {
- while (path_quantized.vertex(&x, &y) != agg::path_cmd_stop) {
+ while (path_simplified.vertex(&x, &y) != agg::path_cmd_stop) {
if (face.first) {
rendererAA->color(face.second);
sa.init(fillCache, fillSize, x, y);
@@ -881,8 +862,8 @@
Py::Object
RendererAgg::draw_path(const Py::Tuple& args) {
typedef agg::conv_transform<PathIterator> transformed_path_t;
- typedef conv_quantize<transformed_path_t> quantize_t;
- typedef agg::conv_curve<quantize_t> curve_t;
+ typedef SimplifyPath<transformed_path_t> simplify_t;
+ typedef agg::conv_curve<simplify_t> curve_t;
_VERBOSE("RendererAgg::draw_path");
args.verify_length(3, 4);
@@ -906,9 +887,11 @@
trans *= agg::trans_affine_scaling(1.0, -1.0);
trans *= agg::trans_affine_translation(0.0, (double)height);
bool snap = should_snap(path, trans);
+ bool simplify = should_simplify(path);
+
transformed_path_t tpath(path, trans);
- quantize_t quantized(tpath, snap);
- curve_t curve(quantized);
+ simplify_t simplified(tpath, snap, simplify, width, height);
+ curve_t curve(simplified);
if (snap)
gc.isaa = false;
@@ -934,8 +917,8 @@
const Py::SeqBase<Py::Object>& linestyles_obj,
const Py::SeqBase<Py::Int>& antialiaseds) {
typedef agg::conv_transform<typename PathGenerator::path_iterator> transformed_path_t;
- typedef conv_quantize<transformed_path_t> quantize_t;
- typedef agg::conv_curve<quantize_t> quantized_curve_t;
+ typedef SimplifyPath<transformed_path_t> simplify_t;
+ typedef agg::conv_curve<simplify_t> simplified_curve_t;
typedef agg::conv_curve<transformed_path_t> curve_t;
GCAgg gc(dpi);
@@ -1068,12 +1051,12 @@
gc.isaa = bool(Py::Int(antialiaseds[i % Naa]));
transformed_path_t tpath(path, trans);
- quantize_t quantized(tpath, snap);
+ simplify_t simplified(tpath, snap, false, width, height);
if (has_curves) {
- quantized_curve_t curve(quantized);
+ simplified_curve_t curve(simplified);
_draw_path(curve, has_clippath, face, gc);
} else {
- _draw_path(quantized, has_clippath, face, gc);
+ _draw_path(simplified, has_clippath, face, gc);
}
} else {
gc.isaa = bool(Py::Int(antialiaseds[i % Naa]));
Modified: trunk/matplotlib/src/_path.cpp
===================================================================
--- trunk/matplotlib/src/_path.cpp 2008-01-17 04:13:27 UTC (rev 4874)
+++ trunk/matplotlib/src/_path.cpp 2008-01-18 14:44:10 UTC (rev 4875)
@@ -1102,17 +1102,23 @@
Py::Object _path_module::convert_path_to_polygons(const Py::Tuple& args)
{
typedef agg::conv_transform<PathIterator> transformed_path_t;
- typedef agg::conv_curve<transformed_path_t> curve_t;
+ typedef SimplifyPath<transformed_path_t> simplify_t;
+ typedef agg::conv_curve<simplify_t> curve_t;
typedef std::vector<double> vertices_t;
- args.verify_length(2);
+ args.verify_length(4);
PathIterator path(args[0]);
agg::trans_affine trans = py_to_agg_transformation_matrix(args[1], false);
+ double width = Py::Float(args[2]);
+ double height = Py::Float(args[3]);
+ bool simplify = !path.has_curves();
+
transformed_path_t tpath(path, trans);
- curve_t curve(tpath);
+ simplify_t simplified(tpath, false, simplify, width, height);
+ curve_t curve(simplified);
Py::List polygons;
vertices_t polygon;
Modified: trunk/matplotlib/src/agg_py_path_iterator.h
===================================================================
--- trunk/matplotlib/src/agg_py_path_iterator.h 2008-01-17 04:13:27 UTC (rev 4874)
+++ trunk/matplotlib/src/agg_py_path_iterator.h 2008-01-18 14:44:10 UTC (rev 4875)
@@ -6,6 +6,7 @@
#include "numpy/arrayobject.h"
#include "agg_path_storage.h"
#include "MPL_isnan.h"
+#include <deque>
class PathIterator
{
@@ -46,11 +47,16 @@
static const unsigned code_map[];
private:
- inline unsigned vertex(unsigned idx, double* x, double* y)
+ inline void vertex(const unsigned idx, double* x, double* y)
{
char* pair = (char*)PyArray_GETPTR2(m_vertices, idx, 0);
*x = *(double*)pair;
*y = *(double*)(pair + PyArray_STRIDE(m_vertices, 1));
+ }
+
+ inline unsigned vertex_with_code(const unsigned idx, double* x, double* y)
+ {
+ vertex(idx, x, y);
if (m_codes)
{
return code_map[(int)*(char *)PyArray_GETPTR1(m_codes, idx)];
@@ -65,11 +71,12 @@
inline unsigned vertex(double* x, double* y)
{
if (m_iterator >= m_total_vertices) return agg::path_cmd_stop;
- unsigned code = vertex(m_iterator++, x, y);
+ unsigned code = vertex_with_code(m_iterator++, x, y);
while ((MPL_isnan64(*x) || MPL_isnan64(*y)) &&
- m_iterator < m_total_vertices) {
- vertex(m_iterator++, x, y);
- code = agg::path_cmd_move_to;
+ m_iterator < m_total_vertices)
+ {
+ vertex(m_iterator++, x, y);
+ code = agg::path_cmd_move_to;
}
return code;
}
@@ -100,4 +107,368 @@
agg::path_cmd_end_poly | agg::path_flags_close
};
+#define DEBUG_SIMPLIFY 0
+
+template<class VertexSource>
+class SimplifyPath
+{
+public:
+ SimplifyPath(VertexSource& source, bool quantize, bool simplify,
+ double width = 0.0, double height = 0.0) :
+ m_source(&source), m_quantize(quantize), m_simplify(simplify),
+ m_width(width), m_height(height),
+ m_moveto(true), m_lastx(0.0), m_lasty(0.0), m_clipped(false),
+ m_do_clipping(width > 0.0 && height > 0.0),
+ m_origdx(0.0), m_origdy(0.0),
+ m_origdNorm2(0.0), m_dnorm2Max(0.0), m_dnorm2Min(0.0),
+ m_haveMin(false), m_lastMax(false), m_maxX(0.0), m_maxY(0.0),
+ m_minX(0.0), m_minY(0.0), m_lastWrittenX(0.0), m_lastWrittenY(0.0),
+ m_done(false)
+#if DEBUG_SIMPLIFY
+ , m_pushed(0), m_skipped(0)
+#endif
+ {
+ // empty
+ }
+
+#if DEBUG_SIMPLIFY
+ ~SimplifyPath()
+ {
+ printf("%d %d\n", m_pushed, m_skipped);
+ }
+#endif
+
+ void rewind(unsigned path_id)
+ {
+ m_source->rewind(path_id);
+ }
+
+ unsigned vertex(double* x, double* y)
+ {
+ unsigned cmd;
+
+ // The simplification algorithm doesn't support curves or compound paths
+ // so we just don't do it at all in that case...
+ if (!m_simplify)
+ {
+ cmd = m_source->vertex(x, y);
+ if (m_quantize && agg::is_vertex(cmd))
+ {
+ *x = round(*x) + 0.5;
+ *y = round(*y) + 0.5;
+ }
+ return cmd;
+ }
+
+ //idea: we can skip drawing many lines: lines < 1 pixel in length, lines
+ //outside of the drawing area, and we can combine sequential parallel lines
+ //into a single line instead of redrawing lines over the same points.
+ //The loop below works a bit like a state machine, where what it does depends
+ //on what it did in the last looping. To test whether sequential lines
+ //are close to parallel, I calculate the distance moved perpendicular to the
+ //last line. Once it gets too big, the lines cannot be combined.
+
+ // This code was originally written by someone else (John Hunter?) and I
+ // have modified to work in-place -- meaning not creating an entirely
+ // new path list each time. In order to do that without too much
+ // additional code complexity, it keeps a small queue around so that
+ // multiple points can be emitted in a single call, and those points
+ // will be popped from the queue in subsequent calls. The following
+ // block will empty the queue before proceeding to the main loop below.
+ if (m_queue.size())
+ {
+ const item& front = m_queue.front();
+ unsigned cmd = front.cmd;
+ *x = front.x;
+ *y = front.y;
+ m_queue.pop_front();
+ return cmd;
+ }
+
+ // If the queue is now empty, and the path was fully consumed
+ // in the last call to the main loop, return agg::path_cmd_stop to
+ // signal that there are no more points to emit.
+ if (m_done)
+ return agg::path_cmd_stop;
+
+ // The main simplification loop. The point is consume only as many
+ // points as necessary until some have been added to the outbound
+ // queue, not to run through the entire path in one go. This
+ // eliminates the need to allocate and fill an entire additional path
+ // array on each draw.
+ while ((cmd = m_source->vertex(x, y)) != agg::path_cmd_stop)
+ {
+ // Do any quantization if requested
+ if (m_quantize && agg::is_vertex(cmd))
+ {
+ *x = round(*x) + 0.5;
+ *y = round(*y) + 0.5;
+ }
+
+ //if we are starting a new path segment, move to the first point
+ // + init
+ if (m_moveto)
+ {
+ m_queue.push_back(item(agg::path_cmd_move_to, *x, *y));
+ m_lastx = *x;
+ m_lasty = *y;
+ m_moveto = false;
+ m_origdNorm2 = 0.0;
+#if DEBUG_SIMPLIFY
+ m_pushed++;
+#endif
+ break;
+ }
+
+ // Don't render line segments less than one pixel long
+ if (fabs(*x - m_lastx) < 1.0 && fabs(*y - m_lasty) < 1.0)
+ {
+#if DEBUG_SIMPLIFY
+ m_skipped++;
+#endif
+ continue;
+ }
+
+ //skip any lines that are outside the drawing area. Note: More lines
+ //could be clipped, but a more involved calculation would be needed
+ if (m_do_clipping &&
+ ((*x < -1 && m_lastx < -1) ||
+ (*x > m_width + 1 && m_lastx > m_width + 1) ||
+ (*y < -1 && m_lasty < -1) ||
+ (*y > m_height + 1 && m_lasty > m_height + 1)))
+ {
+ m_lastx = *x;
+ m_lasty = *y;
+ m_clipped = true;
+ continue;
+ }
+
+ // if we have no orig vector, set it to this vector and
+ // continue.
+ // this orig vector is the reference vector we will build
+ // up the line to
+
+ if (m_origdNorm2 == 0)
+ {
+ if (m_clipped)
+ {
+ m_queue.push_back(item(agg::path_cmd_move_to, m_lastx, m_lasty));
+ m_clipped = false;
+ }
+
+ m_origdx = *x - m_lastx;
+ m_origdy = *y - m_lasty;
+ m_origdNorm2 = m_origdx*m_origdx + m_origdy+m_origdy;
+
+ //set all the variables to reflect this new orig vecor
+ m_dnorm2Max = m_origdNorm2;
+ m_dnorm2Min = 0;
+ m_haveMin = false;
+ m_lastMax = true;
+
+ m_maxX = *x;
+ m_maxY = *y;
+ m_minX = m_lastx;
+ m_minY = m_lasty;
+
+ m_lastWrittenX = m_lastx;
+ m_lastWrittenY = m_lasty;
+
+ // set the last point seen
+ m_lastx = *x;
+ m_lasty = *y;
+ continue;
+ }
+
+ //if got to here, then we have an orig vector and we just got
+ //a vector in the sequence.
+
+ //check that the perpendicular distance we have moved from the
+ //last written point compared to the line we are building is not too
+ //much. If o is the orig vector (we are building on), and v is the
+ //vector from the last written point to the current point, then the
+ //perpendicular vector is p = v - (o.v)o, and we normalize o (by
+ //dividing the second term by o.o).
+
+ // get the v vector
+ double totdx = *x - m_lastWrittenX;
+ double totdy = *y - m_lastWrittenY;
+ double totdot = m_origdx*totdx + m_origdy*totdy;
+
+ // get the para vector ( = (o.v)o/(o.o))
+ double paradx = totdot*m_origdx/m_origdNorm2;
+ double parady = totdot*m_origdy/m_origdNorm2;
+ double paradNorm2 = paradx*paradx + parady*parady;
+
+ // get the perp vector ( = v - para)
+ double perpdx = totdx - paradx;
+ double perpdy = totdy - parady;
+ double perpdNorm2 = perpdx*perpdx + perpdy*perpdy;
+
+ //if the perp vector is less than some number of (squared)
+ //pixels in size, then merge the current vector
+ if (perpdNorm2 < 0.25)
+ {
+ //check if the current vector is parallel or
+ //anti-parallel to the orig vector. If it is parallel, test
+ //if it is the longest of the vectors we are merging in that
+ //direction. If anti-p, test if it is the longest in the
+ //opposite direction (the min of our final line)
+
+ m_lastMax = false;
+ if (totdot >= 0)
+ {
+ if (paradNorm2 > m_dnorm2Max)
+ {
+ m_lastMax = true;
+ m_dnorm2Max = paradNorm2;
+ m_maxX = m_lastWrittenX + paradx;
+ m_maxY = m_lastWrittenY + parady;
+ }
+ }
+ else
+ {
+ m_haveMin = true;
+ if (paradNorm2 > m_dnorm2Min)
+ {
+ m_dnorm2Min = paradNorm2;
+ m_minX = m_lastWrittenX + paradx;
+ m_minY = m_lastWrittenY + parady;
+ }
+ }
+
+ m_lastx = *x;
+ m_lasty = *y;
+ continue;
+ }
+
+ //if we get here, then this vector was not similar enough to the
+ //line we are building, so we need to draw that line and start the
+ //next one.
+
+ //if the line needs to extend in the opposite direction from the
+ //direction we are drawing in, move back to we start drawing from
+ //back there.
+ if (m_haveMin)
+ m_queue.push_back(item(agg::path_cmd_line_to, m_minX, m_minY));
+ m_queue.push_back(item(agg::path_cmd_line_to, m_maxX, m_maxY));
+
+ //if we clipped some segments between this line and the next line
+ //we are starting, we also need to move to the last point.
+ if (m_clipped)
+ {
+ m_queue.push_back(item(agg::path_cmd_move_to, m_lastx, m_lasty));
+ }
+ else if (!m_lastMax)
+ {
+ //if the last line was not the longest line, then move back to
+ //the end point of the last line in the sequence. Only do this
+ //if not clipped, since in that case lastx,lasty is not part of
+ //the line just drawn.
+
+ //Would be move_to if not for the artifacts
+ m_queue.push_back(item(agg::path_cmd_line_to, m_lastx, m_lasty));
+ }
+
+ //now reset all the variables to get ready for the next line
+
+ m_origdx = *x - m_lastx;
+ m_origdy = *y - m_lasty;
+ m_origdNorm2 = m_origdx*m_origdx + m_origdy*m_origdy;
+
+ m_dnorm2Max = m_origdNorm2;
+ m_dnorm2Min = 0;
+ m_haveMin = false;
+ m_lastMax = true;
+ m_maxX = *x;
+ m_maxY = *y;
+ m_minX = m_lastx;
+ m_minY = m_lasty;
+
+ m_lastWrittenX = m_lastx;
+ m_lastWrittenY = m_lasty;
+
+ m_clipped = false;
+
+ m_lastx = *x;
+ m_lasty = *y;
+#if DEBUG_SIMPLIFY
+ m_pushed++;
+#endif
+ break;
+ }
+
+ // Fill the queue with the remaining vertices if we've finished the
+ // path in the above loop. Mark the path as done, so we don't call
+ // m_source->vertex again and segfault.
+ if (cmd == agg::path_cmd_stop)
+ {
+ if (m_origdNorm2 != 0)
+ {
+ if (m_haveMin)
+ m_queue.push_back(item(agg::path_cmd_line_to, m_minX, m_minY));
+ m_queue.push_back(item(agg::path_cmd_line_to, m_maxX, m_maxY));
+ }
+ m_done = true;
+ }
+
+ // Return the first item in the queue, if any, otherwise
+ // indicate that we're done.
+ if (m_queue.size())
+ {
+ const item& front = m_queue.front();
+ unsigned cmd = front.cmd;
+ *x = front.x;
+ *y = front.y;
+ m_queue.pop_front();
+ return cmd;
+ }
+ else
+ {
+ return agg::path_cmd_stop;
+ }
+ }
+
+private:
+ VertexSource* m_source;
+ bool m_quantize;
+ bool m_simplify;
+ double m_width, m_height;
+
+ struct item
+ {
+ item(unsigned cmd_, const double& x_, double& y_) :
+ cmd(cmd_), x(x_), y(y_) {}
+ unsigned cmd;
+ double x;
+ double y;
+ };
+ typedef std::deque<item> ItemQueue;
+ ItemQueue m_queue;
+ bool m_moveto;
+ double m_lastx, m_lasty;
+ bool m_clipped;
+ bool m_do_clipping;
+
+ double m_origdx;
+ double m_origdy;
+ double m_origdNorm2;
+ double m_dnorm2Max;
+ double m_dnorm2Min;
+ bool m_haveMin;
+ bool m_lastMax;
+ double m_maxX;
+ double m_maxY;
+ double m_minX;
+ double m_minY;
+ double m_lastWrittenX;
+ double m_lastWrittenY;
+ bool m_done;
+
+#if DEBUG_SIMPLIFY
+ unsigned m_pushed;
+ unsigned m_skipped;
+#endif
+};
+
#endif // __AGG_PY_PATH_ITERATOR_H__
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-01-17 04:13:31
|
Revision: 4874
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4874&view=rev
Author: jdh2358
Date: 2008-01-16 20:13:27 -0800 (Wed, 16 Jan 2008)
Log Message:
-----------
forced nonunicode fname for save in agg
Modified Paths:
--------------
branches/v0_91_maint/lib/matplotlib/backends/backend_agg.py
Modified: branches/v0_91_maint/lib/matplotlib/backends/backend_agg.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/backends/backend_agg.py 2008-01-17 04:12:58 UTC (rev 4873)
+++ branches/v0_91_maint/lib/matplotlib/backends/backend_agg.py 2008-01-17 04:13:27 UTC (rev 4874)
@@ -394,5 +394,6 @@
def print_png(self, filename, *args, **kwargs):
self.draw()
+ filename = str(filename) # until we figure out unicode handling
self.get_renderer()._renderer.write_png(filename, self.figure.dpi.get())
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-01-17 04:13:00
|
Revision: 4873
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4873&view=rev
Author: jdh2358
Date: 2008-01-16 20:12:58 -0800 (Wed, 16 Jan 2008)
Log Message:
-----------
forced nonunicode fname for save in agg
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/backends/backend_agg.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_agg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2008-01-16 13:04:50 UTC (rev 4872)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2008-01-17 04:12:58 UTC (rev 4873)
@@ -299,5 +299,6 @@
renderer = self.get_renderer()
original_dpi = renderer.dpi
renderer.dpi = self.figure.dpi
+ filename = str(filename) # until we figure out unicode handling
renderer._renderer.write_png(filename, self.figure.dpi)
renderer.dpi = original_dpi
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-01-16 13:04:56
|
Revision: 4872
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4872&view=rev
Author: mdboom
Date: 2008-01-16 05:04:50 -0800 (Wed, 16 Jan 2008)
Log Message:
-----------
Fix exception when plotting legend for LineCollection (Thanks to Paul Novak).
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/legend.py
Modified: trunk/matplotlib/lib/matplotlib/legend.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/legend.py 2008-01-15 20:52:27 UTC (rev 4871)
+++ trunk/matplotlib/lib/matplotlib/legend.py 2008-01-16 13:04:50 UTC (rev 4872)
@@ -272,7 +272,7 @@
legline.set_clip_box(None)
legline.set_clip_path(None)
lw = handle.get_linewidth()[0]
- dashes = handle.get_dashes()
+ dashes = handle.get_dashes()[0]
color = handle.get_colors()[0]
legline.set_color(color)
legline.set_linewidth(lw)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-01-15 20:52:31
|
Revision: 4871
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4871&view=rev
Author: mdboom
Date: 2008-01-15 12:52:27 -0800 (Tue, 15 Jan 2008)
Log Message:
-----------
Make numpoints=1 work for legend handles. (Patch submitted by Paul Novak).
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/legend.py
Modified: trunk/matplotlib/lib/matplotlib/legend.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/legend.py 2008-01-15 20:00:50 UTC (rev 4870)
+++ trunk/matplotlib/lib/matplotlib/legend.py 2008-01-15 20:52:27 UTC (rev 4871)
@@ -175,10 +175,6 @@
# make a trial box in the middle of the axes. relocate it
# based on it's bbox
left, top = 0.5, 0.5
- if self.numpoints == 1:
- self._xdata = npy.array([left + self.handlelen*0.5])
- else:
- self._xdata = npy.linspace(left, left + self.handlelen, self.numpoints)
textleft = left+ self.handlelen+self.handletextsep
self.texts = self._get_texts(labels, textleft, top)
self.legendHandles = self._get_handles(handles, self.texts)
@@ -236,15 +232,23 @@
def _get_handles(self, handles, texts):
HEIGHT = self._approx_text_height()
+ left = 0.5
ret = [] # the returned legend lines
for handle, label in zip(handles, texts):
+ if self.numpoints > 1:
+ xdata = npy.linspace(left, left + self.handlelen, self.numpoints)
+ elif self.numpoints == 1:
+ xdata = npy.linspace(left, left + self.handlelen, 2)
+
x, y = label.get_position()
x -= self.handlelen + self.handletextsep
if isinstance(handle, Line2D):
- ydata = (y-HEIGHT/2)*npy.ones(self._xdata.shape, float)
- legline = Line2D(self._xdata, ydata)
+ if self.numpoints == 1 and handle._marker != 'None':
+ xdata = npy.array([left + self.handlelen*0.5])
+ ydata = (y-HEIGHT/2)*npy.ones(xdata.shape, float)
+ legline = Line2D(xdata, ydata)
legline.update_from(handle)
self._set_artist_props(legline) # after update
legline.set_clip_box(None)
@@ -253,8 +257,7 @@
ret.append(legline)
elif isinstance(handle, Patch):
-
- p = Rectangle(xy=(min(self._xdata), y-3/4*HEIGHT),
+ p = Rectangle(xy=(min(xdata), y-3/4*HEIGHT),
width = self.handlelen, height=HEIGHT/2,
)
p.update_from(handle)
@@ -263,8 +266,8 @@
p.set_clip_path(None)
ret.append(p)
elif isinstance(handle, LineCollection):
- ydata = (y-HEIGHT/2)*npy.ones(self._xdata.shape, float)
- legline = Line2D(self._xdata, ydata)
+ ydata = (y-HEIGHT/2)*npy.ones(xdata.shape, float)
+ legline = Line2D(xdata, ydata)
self._set_artist_props(legline)
legline.set_clip_box(None)
legline.set_clip_path(None)
@@ -277,7 +280,9 @@
ret.append(legline)
elif isinstance(handle, RegularPolyCollection):
- p = Rectangle(xy=(min(self._xdata), y-3/4*HEIGHT),
+ if self.numpoints == 1:
+ xdata = npy.array([left])
+ p = Rectangle(xy=(min(xdata), y-3/4*HEIGHT),
width = self.handlelen, height=HEIGHT/2,
)
p.set_facecolor(handle._facecolors[0])
@@ -487,7 +492,7 @@
for handle, tup in zip(self.legendHandles, hpos):
y,h = tup
if isinstance(handle, Line2D):
- ydata = y*npy.ones(self._xdata.shape, float)
+ ydata = y*npy.ones(handle.get_xdata().shape, float)
handle.set_ydata(ydata+h/2)
elif isinstance(handle, Rectangle):
handle.set_y(y+1/4*h)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-01-15 20:00:53
|
Revision: 4870
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4870&view=rev
Author: mdboom
Date: 2008-01-15 12:00:50 -0800 (Tue, 15 Jan 2008)
Log Message:
-----------
Fix problem with color changing in Ps backend. (Ticks were same color
as line). Thanks Paul Novak.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-01-15 19:32:47 UTC (rev 4869)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-01-15 20:00:50 UTC (rev 4870)
@@ -759,16 +759,6 @@
fill = (fill and rgbFace is not None and
(len(rgbFace) <= 3 or rgbFace[3] != 0.0))
- if stroke:
- self.set_linewidth(gc.get_linewidth())
- jint = gc.get_joinstyle()
- self.set_linejoin(jint)
- cint = gc.get_capstyle()
- self.set_linecap(cint)
- self.set_linedash(*gc.get_dashes())
- if self.linewidth > 0 and stroke:
- self.set_color(*gc.get_rgb()[:3])
-
cliprect = gc.get_clip_rectangle()
if cliprect:
x,y,w,h=cliprect.bounds
@@ -782,17 +772,23 @@
write(ps.strip())
write("\n")
+ hatch = gc.get_hatch()
+ if hatch:
+ self.set_hatch(hatch)
+
if fill:
#print 'rgbface', rgbFace
write("gsave\n")
self.set_color(store=0, *rgbFace[:3])
write("fill\ngrestore\n")
- hatch = gc.get_hatch()
- if (hatch):
- self.set_hatch(hatch)
-
- if self.linewidth > 0 and stroke:
+ if stroke and gc.get_linewidth() > 0.0:
+ self.set_linewidth(gc.get_linewidth())
+ jint = gc.get_joinstyle()
+ self.set_linejoin(jint)
+ cint = gc.get_capstyle()
+ self.set_linecap(cint)
+ self.set_linedash(*gc.get_dashes())
self.set_color(*gc.get_rgb()[:3])
write("stroke\n")
else:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-01-15 19:32:52
|
Revision: 4869
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4869&view=rev
Author: mdboom
Date: 2008-01-15 11:32:47 -0800 (Tue, 15 Jan 2008)
Log Message:
-----------
Fix bug with alpha colors in Ps backend. Thanks Paul Novak.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-01-14 13:21:23 UTC (rev 4868)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-01-15 19:32:47 UTC (rev 4869)
@@ -541,7 +541,7 @@
corr = 0#w/2*(fontsize-10)/10
pos = _nums_to_str(x-corr, y)
thetext = 'psmarker%d' % self.textcnt
- color = '%1.3f,%1.3f,%1.3f'% gc.get_rgb()
+ color = '%1.3f,%1.3f,%1.3f'% gc.get_rgb()[:3]
fontcmd = {'sans-serif' : r'{\sffamily %s}',
'monospace' : r'{\ttfamily %s}'}.get(
rcParams['font.family'], r'{\rmfamily %s}')
@@ -597,7 +597,7 @@
fontname = font.get_fontname()
fontsize = prop.get_size_in_points()
rotate = '%1.1f rotate' % angle
- setcolor = '%1.3f %1.3f %1.3f setrgbcolor' % gc.get_rgb()
+ setcolor = '%1.3f %1.3f %1.3f setrgbcolor' % gc.get_rgb()[:3]
#h = 0
ps = """\
gsave
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ds...@us...> - 2008-01-14 13:21:30
|
Revision: 4868
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4868&view=rev
Author: dsdale
Date: 2008-01-14 05:21:23 -0800 (Mon, 14 Jan 2008)
Log Message:
-----------
minor bugfix in default rcParams
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/__init__.py
Modified: trunk/matplotlib/lib/matplotlib/__init__.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/__init__.py 2008-01-14 13:15:17 UTC (rev 4867)
+++ trunk/matplotlib/lib/matplotlib/__init__.py 2008-01-14 13:21:23 UTC (rev 4868)
@@ -561,8 +561,10 @@
fname = matplotlib_fname()
if not os.path.exists(fname):
+ # this should never happen, default in mpl-data should always be found
message = 'could not find rc file; returning defaults'
- ret = dict([ (key, tup[0]) for key, tup in defaultParams.items()])
+ ret = RcParams([ (key, default) for key, (default, converter) in \
+ defaultParams.iteritems() ])
warnings.warn(message)
return ret
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-01-14 13:15:21
|
Revision: 4867
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4867&view=rev
Author: mdboom
Date: 2008-01-14 05:15:17 -0800 (Mon, 14 Jan 2008)
Log Message:
-----------
Merged revisions 4856-4866 via svnmerge from
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint
........
r4866 | mdboom | 2008-01-14 08:11:16 -0500 (Mon, 14 Jan 2008) | 3 lines
Fix SVG glyphs for use with Qt (which doesn't look forward for the
glyph definitions).
........
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/backends/backend_svg.py
Property Changed:
----------------
trunk/matplotlib/
Property changes on: trunk/matplotlib
___________________________________________________________________
Name: svnmerge-integrated
- /branches/v0_91_maint:1-4855
+ /branches/v0_91_maint:1-4866
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2008-01-14 13:11:16 UTC (rev 4866)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2008-01-14 13:15:17 UTC (rev 4867)
@@ -294,8 +294,20 @@
fontsize = prop.get_size_in_points()
color = rgb2hex(gc.get_rgb()[:3])
+ write = self._svgwriter.write
if rcParams['svg.embed_char_paths']:
+ new_chars = []
+ for c in s:
+ path = self._add_char_def(prop, c)
+ if path is not None:
+ new_chars.append(path)
+ if len(new_chars):
+ write('<defs>\n')
+ for path in new_chars:
+ write(path)
+ write('</defs>\n')
+
svg = ['<g style="fill: %s; opacity: %s" transform="' % (color, gc.get_alpha())]
if angle != 0:
svg.append('translate(%s,%s)rotate(%1.1f)' % (x,y,-angle))
@@ -307,7 +319,7 @@
lastgind = None
currx = 0
for c in s:
- charid = self._add_char_def(prop, c)
+ charnum = self._get_char_def_id(prop, c)
ccode = ord(c)
gind = cmap.get(ccode)
if gind is None:
@@ -322,7 +334,7 @@
lastgind = gind
currx += kern/64.0
- svg.append('<use xlink:href="#%s"' % charid)
+ svg.append('<use xlink:href="#%s"' % charnum)
if currx != 0:
svg.append(' x="%s"' %
(currx * (self.FONT_SCALE / fontsize)))
@@ -346,7 +358,7 @@
svg = """\
<text style="%(style)s" x="%(x)s" y="%(y)s" %(transform)s>%(thetext)s</text>
""" % locals()
- self._svgwriter.write (svg)
+ write(svg)
def _add_char_def(self, prop, char):
if isinstance(prop, FontProperties):
@@ -357,9 +369,9 @@
font.set_size(self.FONT_SCALE, 72)
ps_name = font.get_sfnt()[(1,0,0,6)]
char_id = urllib.quote('%s-%d' % (ps_name, ord(char)))
- char_num, path = self._char_defs.get(char_id, (None, None))
+ char_num = self._char_defs.get(char_id, None)
if char_num is not None:
- return char_num
+ return None
path_data = []
glyph = font.load_char(ord(char), flags=LOAD_NO_HINTING)
@@ -388,9 +400,20 @@
currx, curry = step[-2], -step[-1]
char_num = 'c%x' % len(self._char_defs)
path_element = '<path id="%s" d="%s"/>\n' % (char_num, ''.join(path_data))
- self._char_defs[char_id] = (char_num, path_element)
- return char_num
+ self._char_defs[char_id] = char_num
+ return path_element
+ def _get_char_def_id(self, prop, char):
+ if isinstance(prop, FontProperties):
+ newprop = prop.copy()
+ font = self._get_font(newprop)
+ else:
+ font = prop
+ font.set_size(self.FONT_SCALE, 72)
+ ps_name = font.get_sfnt()[(1,0,0,6)]
+ char_id = urllib.quote('%s-%d' % (ps_name, ord(char)))
+ return self._char_defs[char_id]
+
def _draw_mathtext(self, gc, x, y, s, prop, angle):
"""
Draw math text using matplotlib.mathtext
@@ -400,12 +423,22 @@
svg_glyphs = svg_elements.svg_glyphs
svg_rects = svg_elements.svg_rects
color = rgb2hex(gc.get_rgb()[:3])
+ write = self._svgwriter.write
- self.open_group("mathtext")
-
style = "fill: %s" % color
if rcParams['svg.embed_char_paths']:
+ new_chars = []
+ for font, fontsize, thetext, new_x, new_y_mtc, metrics in svg_glyphs:
+ path = self._add_char_def(font, thetext)
+ if path is not None:
+ new_chars.append(path)
+ if len(new_chars):
+ write('<defs>\n')
+ for path in new_chars:
+ write(path)
+ write('</defs>\n')
+
svg = ['<g style="%s" transform="' % style]
if angle != 0:
svg.append('translate(%s,%s)rotate(%1.1f)'
@@ -415,7 +448,7 @@
svg.append('">\n')
for font, fontsize, thetext, new_x, new_y_mtc, metrics in svg_glyphs:
- charid = self._add_char_def(font, thetext)
+ charid = self._get_char_def_id(font, thetext)
svg.append('<use xlink:href="#%s" transform="translate(%s,%s)scale(%s)"/>\n' %
(charid, new_x, -new_y_mtc, fontsize / self.FONT_SCALE))
@@ -469,16 +502,12 @@
svg.append('<rect x="%s" y="%s" width="%s" height="%s" fill="black" stroke="none" />' % (x, -y + height, width, height))
svg.append("</g>")
- self._svgwriter.write (''.join(svg))
+ self.open_group("mathtext")
+ write (''.join(svg))
self.close_group("mathtext")
def finalize(self):
write = self._svgwriter.write
- if len(self._char_defs):
- write('<defs id="fontpaths">\n')
- for char_num, path in self._char_defs.values():
- write(path)
- write('</defs>\n')
write('</svg>\n')
def flipy(self):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-01-14 13:11:34
|
Revision: 4866
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4866&view=rev
Author: mdboom
Date: 2008-01-14 05:11:16 -0800 (Mon, 14 Jan 2008)
Log Message:
-----------
Fix SVG glyphs for use with Qt (which doesn't look forward for the
glyph definitions).
Modified Paths:
--------------
branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py
Modified: branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py 2008-01-12 13:36:24 UTC (rev 4865)
+++ branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py 2008-01-14 13:11:16 UTC (rev 4866)
@@ -284,8 +284,20 @@
fontsize = prop.get_size_in_points()
color = rgb2hex(gc.get_rgb())
+ write = self._svgwriter.write
if rcParams['svg.embed_char_paths']:
+ new_chars = []
+ for c in s:
+ path = self._add_char_def(prop, c)
+ if path is not None:
+ new_chars.append(path)
+ if len(new_chars):
+ write('<defs>\n')
+ for path in new_chars:
+ write(path)
+ write('</defs>\n')
+
svg = ['<g style="fill: %s; opacity: %s" transform="' % (color, gc.get_alpha())]
if angle != 0:
svg.append('translate(%s,%s)rotate(%1.1f)' % (x,y,-angle))
@@ -297,7 +309,7 @@
lastgind = None
currx = 0
for c in s:
- charid = self._add_char_def(prop, c)
+ charnum = self._get_char_def_id(prop, c)
ccode = ord(c)
gind = cmap.get(ccode)
if gind is None:
@@ -312,7 +324,7 @@
lastgind = gind
currx += kern/64.0
- svg.append('<use xlink:href="#%s"' % charid)
+ svg.append('<use xlink:href="#%s"' % charnum)
if currx != 0:
svg.append(' transform="translate(%s)"' %
(currx * (self.FONT_SCALE / fontsize)))
@@ -336,7 +348,7 @@
svg = """\
<text style="%(style)s" x="%(x)s" y="%(y)s" %(transform)s>%(thetext)s</text>
""" % locals()
- self._svgwriter.write (svg)
+ write(svg)
def _add_char_def(self, prop, char):
if isinstance(prop, FontProperties):
@@ -347,9 +359,9 @@
font.set_size(self.FONT_SCALE, 72)
ps_name = font.get_sfnt()[(1,0,0,6)]
char_id = urllib.quote('%s-%d' % (ps_name, ord(char)))
- char_num, path = self._char_defs.get(char_id, (None, None))
+ char_num = self._char_defs.get(char_id, None)
if char_num is not None:
- return char_num
+ return None
path_data = []
glyph = font.load_char(ord(char), flags=LOAD_NO_HINTING)
@@ -378,9 +390,20 @@
currx, curry = step[-2], -step[-1]
char_num = 'c_%x' % len(self._char_defs)
path_element = '<path id="%s" d="%s"/>\n' % (char_num, ''.join(path_data))
- self._char_defs[char_id] = (char_num, path_element)
- return char_num
+ self._char_defs[char_id] = char_num
+ return path_element
+ def _get_char_def_id(self, prop, char):
+ if isinstance(prop, FontProperties):
+ newprop = prop.copy()
+ font = self._get_font(newprop)
+ else:
+ font = prop
+ font.set_size(self.FONT_SCALE, 72)
+ ps_name = font.get_sfnt()[(1,0,0,6)]
+ char_id = urllib.quote('%s-%d' % (ps_name, ord(char)))
+ return self._char_defs[char_id]
+
def _draw_mathtext(self, gc, x, y, s, prop, angle):
"""
Draw math text using matplotlib.mathtext
@@ -390,12 +413,22 @@
svg_glyphs = svg_elements.svg_glyphs
svg_rects = svg_elements.svg_rects
color = rgb2hex(gc.get_rgb())
+ write = self._svgwriter.write
- self.open_group("mathtext")
-
style = "fill: %s" % color
if rcParams['svg.embed_char_paths']:
+ new_chars = []
+ for font, fontsize, thetext, new_x, new_y_mtc, metrics in svg_glyphs:
+ path = self._add_char_def(font, thetext)
+ if path is not None:
+ new_chars.append(path)
+ if len(new_chars):
+ write('<defs>\n')
+ for path in new_chars:
+ write(path)
+ write('</defs>\n')
+
svg = ['<g style="%s" transform="' % style]
if angle != 0:
svg.append('translate(%s,%s)rotate(%1.1f)'
@@ -405,7 +438,7 @@
svg.append('">\n')
for font, fontsize, thetext, new_x, new_y_mtc, metrics in svg_glyphs:
- charid = self._add_char_def(font, thetext)
+ charid = self._get_char_def_id(font, thetext)
svg.append('<use xlink:href="#%s" transform="translate(%s,%s)scale(%s)"/>\n' %
(charid, new_x, -new_y_mtc, fontsize / self.FONT_SCALE))
@@ -459,16 +492,12 @@
svg.append('<rect x="%s" y="%s" width="%s" height="%s" fill="black" stroke="none" />' % (x, -y + height, width, height))
svg.append("</g>")
- self._svgwriter.write (''.join(svg))
+ self.open_group("mathtext")
+ write (''.join(svg))
self.close_group("mathtext")
def finish(self):
write = self._svgwriter.write
- if len(self._char_defs):
- write('<defs id="fontpaths">\n')
- for char_num, path in self._char_defs.values():
- write(path)
- write('</defs>\n')
write('</svg>\n')
def flipy(self):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-01-12 13:36:28
|
Revision: 4865
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4865&view=rev
Author: jswhit
Date: 2008-01-12 05:36:24 -0800 (Sat, 12 Jan 2008)
Log Message:
-----------
update download instructions
Modified Paths:
--------------
trunk/toolkits/basemap/README
Modified: trunk/toolkits/basemap/README
===================================================================
--- trunk/toolkits/basemap/README 2008-01-12 13:32:31 UTC (rev 4864)
+++ trunk/toolkits/basemap/README 2008-01-12 13:36:24 UTC (rev 4865)
@@ -68,8 +68,11 @@
0) Install pre-requisite python modules numpy and matplotlib.
-1) Then download basemap-X.Y.Z.tar.gz from
+1) Then download basemap-X.Y.Z.tar.gz (approx 32 mb) from
the sourceforge download site, unpack and cd to basemap-X.Y.Z.
+If you want the full-resolution coastline dataset (useful if you
+will be making maps of very small regions), get
+basemap-fullresdata-X.Y.Z.tar.gz (approx. 100 mb).
2) Install the GEOS library. If you already have it on your
system, just set the environment variable GEOS_DIR to point to the location
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-01-12 13:32:39
|
Revision: 4864
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4864&view=rev
Author: jswhit
Date: 2008-01-12 05:32:31 -0800 (Sat, 12 Jan 2008)
Log Message:
-----------
obsolete
Removed Paths:
-------------
trunk/toolkits/basemap/MANIFEST-data
Deleted: trunk/toolkits/basemap/MANIFEST-data
===================================================================
--- trunk/toolkits/basemap/MANIFEST-data 2008-01-12 00:12:10 UTC (rev 4863)
+++ trunk/toolkits/basemap/MANIFEST-data 2008-01-12 13:32:31 UTC (rev 4864)
@@ -1,13 +0,0 @@
-MANIFEST-data
-LICENSE_data
-README
-setup-data.py
-lib/matplotlib/toolkits/basemap/data/__init__.py
-lib/matplotlib/toolkits/basemap/data/countries_f.dat
-lib/matplotlib/toolkits/basemap/data/countriesmeta_f.dat
-lib/matplotlib/toolkits/basemap/data/gshhs_f.dat
-lib/matplotlib/toolkits/basemap/data/gshhsmeta_f.dat
-lib/matplotlib/toolkits/basemap/data/rivers_f.dat
-lib/matplotlib/toolkits/basemap/data/riversmeta_f.dat
-lib/matplotlib/toolkits/basemap/data/states_f.dat
-lib/matplotlib/toolkits/basemap/data/statesmeta_f.dat
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-01-12 00:27:08
|
Revision: 4863
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4863&view=rev
Author: jswhit
Date: 2008-01-11 16:12:10 -0800 (Fri, 11 Jan 2008)
Log Message:
-----------
not needed
Removed Paths:
-------------
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/data/__init__.py
Deleted: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/data/__init__.py
===================================================================
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-01-12 00:00:30
|
Revision: 4862
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4862&view=rev
Author: jswhit
Date: 2008-01-11 16:00:22 -0800 (Fri, 11 Jan 2008)
Log Message:
-----------
update install instructions.
Modified Paths:
--------------
trunk/toolkits/basemap/README
Modified: trunk/toolkits/basemap/README
===================================================================
--- trunk/toolkits/basemap/README 2008-01-11 23:59:04 UTC (rev 4861)
+++ trunk/toolkits/basemap/README 2008-01-12 00:00:22 UTC (rev 4862)
@@ -89,19 +89,9 @@
run the usual 'python setup.py install'.
4) To test, cd to the examples directory and run 'python simpletest.py'.
-On linux, if you get an import error (with a message about not
-finding libgeos.so) you may need to set the LD_LIBRARY_PATH environment
-to include $GEOS_DIR/lib. To run all the examples (except those that
-have extra dependenices or require an internet connection), execute
-'python run_all.py'.
+To run all the examples (except those that have extra dependencies
+or require an internet connection), execute 'python run_all.py'.
-5) if you want the full-resolution coastlines, download
-basemap-data-fullres-X.Y.Z.tar.gz (about 70 mb), untar
-it, cd into basemap-data-fullres-X.Y.Z and
-run 'python setup-data.py install'. The fullres dataset does not
-change with every basemap release, so you may need to look back
-a couple of releases on the download page to find it.
-
**Contact**
Jeff Whitaker <jef...@no...>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|