From: <md...@us...> - 2007-09-10 19:25:26
|
Revision: 3826 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3826&view=rev Author: mdboom Date: 2007-09-10 12:25:21 -0700 (Mon, 10 Sep 2007) Log Message: ----------- Running mathtext_demo.py without transforms.py/cpp. Totally broken, though. Not surprising... ;) Modified Paths: -------------- branches/transforms/lib/matplotlib/affine.py branches/transforms/lib/matplotlib/axes.py branches/transforms/lib/matplotlib/axis.py branches/transforms/lib/matplotlib/backend_bases.py branches/transforms/lib/matplotlib/backends/backend_agg.py branches/transforms/lib/matplotlib/bbox.py branches/transforms/lib/matplotlib/figure.py branches/transforms/lib/matplotlib/finance.py branches/transforms/lib/matplotlib/legend.py branches/transforms/lib/matplotlib/lines.py branches/transforms/lib/matplotlib/patches.py branches/transforms/lib/matplotlib/text.py branches/transforms/lib/matplotlib/ticker.py branches/transforms/src/_backend_agg.cpp Modified: branches/transforms/lib/matplotlib/affine.py =================================================================== --- branches/transforms/lib/matplotlib/affine.py 2007-09-10 18:45:32 UTC (rev 3825) +++ branches/transforms/lib/matplotlib/affine.py 2007-09-10 19:25:21 UTC (rev 3826) @@ -67,7 +67,10 @@ def from_values(a, b, c, d, e, f): return Affine2D(Affine2D.matrix_from_values(a, b, c, d, e, f)) from_values = staticmethod(from_values) - + + def to_values(self): + return tuple(self.mtx[:2].swapaxes(0, 1).flatten()) + #@staticmethod def matrix_from_values(a, b, c, d, e, f): affine = N.zeros((3,3), N.float_) @@ -92,11 +95,12 @@ # This is nicer for now, however, since we can just keep a # regular affine matrix around + # MGDTODO: Trap cases where this isn't an array and fix there + points = N.array(points, N.float_) new_points = points.swapaxes(0, 1) new_points = N.vstack((new_points, N.ones((1, points.shape[0])))) result = N.dot(self.mtx, new_points)[:2] - result.swapaxes(0, 1) - return result + return result.swapaxes(0, 1) #@staticmethod def _concat(a, b): @@ -198,10 +202,14 @@ print transform.inverted() from bbox import Bbox + print "BBOX" boxin = Bbox([[10, 10], [320, 240]]) boxout = Bbox([[25, 25], [640, 400]]) - trans = bbox_transform(boxin, boxout) + print boxin._points, boxin.xmin(), boxin.ymin(), boxin.xmax(), boxin.ymax() + print boxout._points, boxout.xmin(), boxout.ymin(), boxout.xmax(), boxout.ymax() + trans = get_bbox_transform(boxin, boxout) print trans print trans(N.array([[10, 10], [320, 240]])) + print trans([[10, 10]]) __all__ = ['Transform', 'Affine2D'] Modified: branches/transforms/lib/matplotlib/axes.py =================================================================== --- branches/transforms/lib/matplotlib/axes.py 2007-09-10 18:45:32 UTC (rev 3825) +++ branches/transforms/lib/matplotlib/axes.py 2007-09-10 19:25:21 UTC (rev 3826) @@ -618,10 +618,10 @@ martist.Artist.set_figure(self, fig) l, b, w, h = self._position - xmin = fig.bbox.ll().x() - xmax = fig.bbox.ur().x() - ymin = fig.bbox.ll().y() - ymax = fig.bbox.ur().y() + xmin = fig.bbox.xmin() + xmax = fig.bbox.xmax() + ymin = fig.bbox.ymin() + ymax = fig.bbox.ymax() figw = xmax-xmin figh = ymax-ymin self.left = l*figw @@ -695,9 +695,11 @@ ACCEPTS: len(4) sequence of floats """ if which in ('both', 'active'): - # Change values within self._position--don't replace it. - for num,val in zip(pos, self._position): - val.set(num) + # MGDTODO +# # Change values within self._position--don't replace it. +# for num,val in zip(pos, self._position): +# val.set(num) + self._position = pos if which in ('both', 'original'): self._originalPosition = pos @@ -714,7 +716,8 @@ self.xaxis.cla() self.yaxis.cla() - self.dataLim.ignore(1) + # MGDTODO + # self.dataLim.ignore(1) self.callbacks = cbook.CallbackRegistry(('xlim_changed', 'ylim_changed')) if self._sharex is not None: @@ -1176,7 +1179,9 @@ # Otherwise, it will compute the bounds of it's current data # and the data in xydata #print type(x), type(y) - self.dataLim.update_numerix(x, y, -1) + # MGDTODO + ## self.dataLim.update_numerix(x, y, -1) + pass def _get_verts_in_data_coords(self, trans, xys): if trans == self.transData: @@ -1273,8 +1278,9 @@ if not self.get_visible(): return renderer.open_group('axes') self.apply_aspect() - self.transData.freeze() # eval the lazy objects - self.transAxes.freeze() + # MGDTODO + # self.transData.freeze() # eval the lazy objects + # self.transAxes.freeze() if self.axison and self._frameon: self.axesPatch.draw(renderer) artists = [] @@ -1330,8 +1336,9 @@ for zorder, i, a in dsu: a.draw(renderer) - self.transData.thaw() # release the lazy objects - self.transAxes.thaw() # release the lazy objects + # MGDTODO + # self.transData.thaw() # release the lazy objects + # self.transAxes.thaw() # release the lazy objects renderer.close_group('axes') self._cachedRenderer = renderer Modified: branches/transforms/lib/matplotlib/axis.py =================================================================== --- branches/transforms/lib/matplotlib/axis.py 2007-09-10 18:45:32 UTC (rev 3825) +++ branches/transforms/lib/matplotlib/axis.py 2007-09-10 19:25:21 UTC (rev 3826) @@ -261,7 +261,7 @@ horizontalalignment='center', ) - trans = blend_xy_sep_transformation( + trans = blend_xy_sep_transform( self.axes.transData, self.axes.transAxes) # offset the text upward with a post transformation trans = trans + Affine2D().translated(0, self._padPixels) @@ -1037,7 +1037,8 @@ bbox = bbox_union(bboxes) bottom = bbox.ymin() - self.label.set_position( (x, bottom-self.LABELPAD*self.figure.dpi.get()/72.0)) + self.label.set_position( (x, bottom-self.LABELPAD*self.figure.dpi/72.0)) +# self.label.set_position( (x, bottom-self.LABELPAD*self.figure.dpi.get()/72.0)) MGDTODO else: if not len(bboxes2): @@ -1060,8 +1061,9 @@ else: bbox = bbox_union(bboxes) bottom = bbox.ymin() - self.offsetText.set_position((x, bottom-self.OFFSETTEXTPAD*self.figure.dpi.get()/72.0)) - + self.offsetText.set_position((x, bottom-self.OFFSETTEXTPAD*self.figure.dpi/72.0)) +# self.offsetText.set_position((x, bottom-self.OFFSETTEXTPAD*self.figure.dpi.get()/72.0)) MGDTODO + def set_ticks_position(self, position): """ Set the ticks position (top, bottom, both or default) @@ -1227,8 +1229,9 @@ bbox = bbox_union(bboxes) left = bbox.xmin() - self.label.set_position( (left-self.LABELPAD*self.figure.dpi.get()/72.0, y)) - + self.label.set_position( (left-self.LABELPAD*self.figure.dpi/72.0, y)) + # self.label.set_position( (left-self.LABELPAD*self.figure.dpi.get()/72.0, y)) MGDTODO + else: if not len(bboxes2): right = self.axes.bbox.xmax() @@ -1246,8 +1249,9 @@ """ x,y = self.offsetText.get_position() top = self.axes.bbox.ymax() - self.offsetText.set_position((x, top+self.OFFSETTEXTPAD*self.figure.dpi.get()/72.0)) - + self.offsetText.set_position((x, top+self.OFFSETTEXTPAD*self.figure.dpi/72.0)) +# self.offsetText.set_position((x, top+self.OFFSETTEXTPAD*self.figure.dpi.get()/72.0)) MGDTODO + def set_offset_position(self, position): assert position == 'left' or position == 'right' Modified: branches/transforms/lib/matplotlib/backend_bases.py =================================================================== --- branches/transforms/lib/matplotlib/backend_bases.py 2007-09-10 18:45:32 UTC (rev 3825) +++ branches/transforms/lib/matplotlib/backend_bases.py 2007-09-10 19:25:21 UTC (rev 3826) @@ -1178,11 +1178,13 @@ if dpi is None: dpi = rcParams['savefig.dpi'] - origDPI = self.figure.dpi.get() + origDPI = self.figure.dpi origfacecolor = self.figure.get_facecolor() origedgecolor = self.figure.get_edgecolor() - self.figure.dpi.set(dpi) + # MGDTODO + # self.figure.dpi.set(dpi) + self.figure.dpi = dpi self.figure.set_facecolor(facecolor) self.figure.set_edgecolor(edgecolor) @@ -1195,7 +1197,9 @@ orientation=orientation, **kwargs) finally: - self.figure.dpi.set(origDPI) + # MGDTODO + # self.figure.dpi.set(origDPI) + self.figure.dpi = origDPI self.figure.set_facecolor(origfacecolor) self.figure.set_edgecolor(origedgecolor) self.figure.set_canvas(self) Modified: branches/transforms/lib/matplotlib/backends/backend_agg.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_agg.py 2007-09-10 18:45:32 UTC (rev 3825) +++ branches/transforms/lib/matplotlib/backends/backend_agg.py 2007-09-10 19:25:21 UTC (rev 3826) @@ -106,14 +106,17 @@ self.height = height if __debug__: verbose.report('RendererAgg.__init__ width=%s, \ height=%s'%(width, height), 'debug-annoying') - self._renderer = _RendererAgg(int(width), int(height), dpi.get(), - debug=False) + # MGDTODO +# self._renderer = _RendererAgg(int(width), int(height), dpi.get(), +# debug=False) + self._renderer = _RendererAgg(int(width), int(height), dpi, + debug=False) if __debug__: verbose.report('RendererAgg.__init__ _RendererAgg done', 'debug-annoying') self.draw_polygon = self._renderer.draw_polygon self.draw_rectangle = self._renderer.draw_rectangle self.draw_path = self._renderer.draw_path - self.draw_lines = self._renderer.draw_lines + # self.draw_lines = self._renderer.draw_lines self.draw_markers = self._renderer.draw_markers self.draw_image = self._renderer.draw_image self.draw_line_collection = self._renderer.draw_line_collection @@ -156,6 +159,9 @@ y = npy.array([y1,y2], float) self._renderer.draw_lines(gc, x, y) + def draw_lines(self, gc, x, y, transform): + return self._renderer.draw_lines(gc, x, y, transform.to_values()) + def draw_point(self, gc, x, y): """ @@ -173,7 +179,9 @@ if __debug__: verbose.report('RendererAgg.draw_mathtext', 'debug-annoying') ox, oy, width, height, descent, font_image, used_characters = \ - self.mathtext_parser.parse(s, self.dpi.get(), prop) + self.mathtext_parser.parse(s, self.dpi, prop) +# ox, oy, width, height, descent, font_image, used_characters = \ +# self.mathtext_parser.parse(s, self.dpi.get(), prop) MGDTODO x = int(x) + ox y = int(y) - oy @@ -228,7 +236,9 @@ if ismath: ox, oy, width, height, descent, fonts, used_characters = \ - self.mathtext_parser.parse(s, self.dpi.get(), prop) + self.mathtext_parser.parse(s, self.dpi, prop) +# ox, oy, width, height, descent, fonts, used_characters = \ +# self.mathtext_parser.parse(s, self.dpi.get(), prop) MGDTODO return width, height, descent font = self._get_agg_font(prop) font.set_text(s, 0.0, flags=LOAD_DEFAULT) # the width and height of unrotated string @@ -302,7 +312,8 @@ font.clear() size = prop.get_size_in_points() - font.set_size(size, self.dpi.get()) + font.set_size(size, self.dpi) + # font.set_size(size, self.dpi.get()) MGDTODO return font @@ -380,7 +391,9 @@ def get_renderer(self): l,b,w,h = self.figure.bbox.get_bounds() - key = w, h, self.figure.dpi.get() + # MGDTODO + # key = w, h, self.figure.dpi.get() + key = w, h, self.figure.dpi try: self._lastKey, self.renderer except AttributeError: need_new_renderer = True else: need_new_renderer = (self._lastKey != key) Modified: branches/transforms/lib/matplotlib/bbox.py =================================================================== --- branches/transforms/lib/matplotlib/bbox.py 2007-09-10 18:45:32 UTC (rev 3825) +++ branches/transforms/lib/matplotlib/bbox.py 2007-09-10 19:25:21 UTC (rev 3826) @@ -6,9 +6,31 @@ import numpy as N +class Interval: + def __init__(self, bounds): + self._bounds = N.array(bounds, N.float_) + + def contains(self, value): + bounds = self._bounds + return value >= bounds[0] and value <= bounds[1] + + def contains_open(self, value): + bounds = self._bounds + return value > bounds[0] and value < bounds[1] + + def get_bounds(self): + return self._bounds + + def set_bounds(self, lower, upper): + self._bounds = lower, upper + + def span(self): + bounds = self._bounds + return bounds[1] - bounds[0] + class Bbox: def __init__(self, points): - self._points = N.array(points) + self._points = N.array(points, N.float_) #@staticmethod def unit(): @@ -23,7 +45,10 @@ #@staticmethod def from_lbrt(left, bottom, right, top): return Bbox([[left, bottom], [right, top]]) - from_lbwh = staticmethod(from_lbwh) + from_lbrt = staticmethod(from_lbrt) + + def copy(self): + return Bbox(self._points.copy()) # MGDTODO: Probably a more efficient ways to do this... def xmin(self): @@ -45,15 +70,29 @@ return self.ymax() - self.ymin() def transform(self, transform): - return Bbox(transform(points)) + return Bbox(transform(self._points)) def inverse_transform(self, transform): - return Bbox(transform.inverted()(points)) + return Bbox(transform.inverted()(self._points)) def get_bounds(self): return (self.xmin(), self.ymin(), self.xmax() - self.xmin(), self.ymax() - self.ymin()) - + + def intervalx(self): + return Interval(self._points[0]) + + def intervaly(self): + return Interval(self._points[1]) + + def scaled(self, sw, sh): + width = self.width() + height = self.height() + deltaw = (sw * width - width) / 2.0 + deltah = (sh * height - height) / 2.0 + a = N.array([[-deltaw, -deltah], [deltaw, deltah]]) + return Bbox(self._points + a) + def lbwh_to_bbox(left, bottom, width, height): return Bbox([[left, bottom], [left + width, bottom + height]]) @@ -67,18 +106,18 @@ return bboxes[0] bbox = bboxes[0] - xmin = bbox.xmin - ymin = bbox.ymin - xmax = bbox.xmax - ymax = bbox.ymax + xmin = bbox.xmin() + ymin = bbox.ymin() + xmax = bbox.xmax() + ymax = bbox.ymax() for bbox in bboxes[1:]: - xmin = min(xmin, bbox.xmin) - ymin = min(ymin, bbox.ymin) - xmax = max(xmax, bbox.xmax) - ymax = max(ymax, bbox.ymax) + xmin = min(xmin, bbox.xmin()) + ymin = min(ymin, bbox.ymin()) + xmax = max(xmax, bbox.xmax()) + ymax = max(ymax, bbox.ymax()) - return Bbox(xmin, ymin, xmax, ymax) + return Bbox.from_lbrt(xmin, ymin, xmax, ymax) # MGDTODO: There's probably a better place for this def nonsingular(vmin, vmax, expander=0.001, tiny=1e-15, increasing=True): Modified: branches/transforms/lib/matplotlib/figure.py =================================================================== --- branches/transforms/lib/matplotlib/figure.py 2007-09-10 18:45:32 UTC (rev 3825) +++ branches/transforms/lib/matplotlib/figure.py 2007-09-10 19:25:21 UTC (rev 3826) @@ -129,9 +129,10 @@ if edgecolor is None: edgecolor = rcParams['figure.edgecolor'] self.dpi = dpi + self.figsize = figsize self.bbox = Bbox.from_lbwh(0, 0, - self.figsize[0] * dpi, - self.figsize[1] * dpi) + figsize[0] * dpi, + figsize[1] * dpi) self.frameon = frameon @@ -581,7 +582,8 @@ #print 'figure draw' if not self.get_visible(): return renderer.open_group('figure') - self.transFigure.freeze() # eval the lazy objects + # MGDTODO + # self.transFigure.freeze() # eval the lazy objects if self.frameon: self.figurePatch.draw(renderer) @@ -615,7 +617,8 @@ for legend in self.legends: legend.draw(renderer) - self.transFigure.thaw() # release the lazy objects + # MGDTODO + # self.transFigure.thaw() # release the lazy objects renderer.close_group('figure') self._cachedRenderer = renderer Modified: branches/transforms/lib/matplotlib/finance.py =================================================================== --- branches/transforms/lib/matplotlib/finance.py 2007-09-10 18:45:32 UTC (rev 3825) +++ branches/transforms/lib/matplotlib/finance.py 2007-09-10 19:25:21 UTC (rev 3826) @@ -22,8 +22,7 @@ from matplotlib.colors import colorConverter from lines import Line2D, TICKLEFT, TICKRIGHT from patches import Rectangle -from matplotlib.transforms import scale_transform, Value, zero, one, \ - scale_sep_transform, blend_xy_sep_transform +from matplotlib.affine import Affine2D @@ -335,9 +334,9 @@ offsetsClose = [ (i, close) for i, close in zip(xrange(len(closes)), closes) if close != -1 ] - scale = ax.figure.dpi * Value(1/72.0) + scale = ax.figure.dpi * (1.0/72.0) - tickTransform = scale_transform( scale, zero()) + tickTransform = Affine2D().scaled(scale, 0.0) r,g,b = colorConverter.to_rgb(colorup) colorup = r,g,b,1 @@ -424,10 +423,10 @@ offsetsBars = [ (i, open) for i,open in zip(xrange(len(opens)), opens) if open != -1 ] - sx = ax.figure.dpi * Value(1/72.0) # scale for points + sx = ax.figure.dpi * (1.0/72.0) # scale for points sy = (ax.bbox.ur().y() - ax.bbox.ll().y()) / (ax.viewLim.ur().y() - ax.viewLim.ll().y()) - barTransform = scale_sep_transform(sx,sy) + barTransform = Affine2D().scaled(sx,sy) @@ -512,10 +511,10 @@ bars = [ ( (left, 0), (left, v), (right, v), (right, 0)) for v in volumes if v != -1 ] - sx = ax.figure.dpi * Value(1/72.0) # scale for points + sx = ax.figure.dpi * (1.0/72.0) # scale for points sy = (ax.bbox.ur().y() - ax.bbox.ll().y()) / (ax.viewLim.ur().y() - ax.viewLim.ll().y()) - barTransform = scale_sep_transform(sx,sy) + barTransform = Affine2D().scaled(sx,sy) offsetsBars = [ (i, 0) for i,v in enumerate(volumes) if v != -1 ] @@ -602,10 +601,10 @@ bars = [ ( (left, 0), (left, volume), (right, volume), (right, 0)) for d, open, close, high, low, volume in quotes] - sx = ax.figure.dpi * Value(1/72.0) # scale for points + sx = ax.figure.dpi * (1.0/72.0) # scale for points sy = (ax.bbox.ur().y() - ax.bbox.ll().y()) / (ax.viewLim.ur().y() - ax.viewLim.ll().y()) - barTransform = scale_sep_transform(sx,sy) + barTransform = Affine2D().scaled(sx,sy) dates = [d for d, open, close, high, low, volume in quotes] offsetsBars = [(d, 0) for d in dates] @@ -662,10 +661,10 @@ bars = [ ( (left, 0), (left, v), (right, v), (right, 0)) for v in vals if v != -1 ] - sx = ax.figure.dpi * Value(1/72.0) # scale for points + sx = ax.figure.dpi * (1.0/72.0) # scale for points sy = (ax.bbox.ur().y() - ax.bbox.ll().y()) / (ax.viewLim.ur().y() - ax.viewLim.ll().y()) - barTransform = scale_sep_transform(sx,sy) + barTransform = Affine2D().scaled(sx,sy) offsetsBars = [ (i, 0) for i,v in enumerate(vals) if v != -1 ] Modified: branches/transforms/lib/matplotlib/legend.py =================================================================== --- branches/transforms/lib/matplotlib/legend.py 2007-09-10 18:45:32 UTC (rev 3825) +++ branches/transforms/lib/matplotlib/legend.py 2007-09-10 19:25:21 UTC (rev 3826) @@ -224,7 +224,7 @@ a.set_transform(self.get_transform()) def _approx_text_height(self): - return self.fontsize/72.0*self.figure.dpi.get()/self.parent.bbox.height() + return self.fontsize/72.0*self.figure.dpi/self.parent.bbox.height() def draw(self, renderer): @@ -531,7 +531,7 @@ if not len(self.legendHandles) and not len(self.texts): return def get_tbounds(text): #get text bounds in axes coords bbox = text.get_window_extent(renderer) - bboxa = inverse_transform_bbox(self.get_transform(), bbox) + bboxa = bbox.inverse_transform(self.get_transform()) return bboxa.get_bounds() hpos = [] @@ -559,9 +559,11 @@ handle.set_height(h/2) # Set the data for the legend patch - bbox = self._get_handle_text_bbox(renderer).deepcopy() + # MGDTODO: This copy may no longer be needed now that Bboxes are + # essentially immutable + bbox = self._get_handle_text_bbox(renderer).copy() - bbox.scale(1 + self.pad, 1 + self.pad) + bbox = bbox.scaled(1 + self.pad, 1 + self.pad) l,b,w,h = bbox.get_bounds() self.legendPatch.set_bounds(l,b,w,h) Modified: branches/transforms/lib/matplotlib/lines.py =================================================================== --- branches/transforms/lib/matplotlib/lines.py 2007-09-10 18:45:32 UTC (rev 3825) +++ branches/transforms/lib/matplotlib/lines.py 2007-09-10 19:25:21 UTC (rev 3826) @@ -362,8 +362,13 @@ else: x, y = self._get_plottable() - - x, y = self.get_transform().numerix_x_y(x, y) + # MGDTODO: Put this in a single Nx2 array, rather than these + # separate ones + #### Conversion code + a = npy.vstack((x, y)).swapaxes(0, 1) + #### + x, y = self.get_transform()(a) + #x, y = self.get_transform().seq_x_y(x, y) left = min(x) @@ -373,7 +378,8 @@ # correct for marker size, if any if self._marker is not None: - ms = self._markersize/72.0*self.figure.dpi.get() + ms = self._markersize/72.0*self.figure.dpi + # ms = self._markersize/72.0*self.figure.dpi.get() MGDTODO left -= ms/2 bottom -= ms/2 width += ms Modified: branches/transforms/lib/matplotlib/patches.py =================================================================== --- branches/transforms/lib/matplotlib/patches.py 2007-09-10 18:45:32 UTC (rev 3825) +++ branches/transforms/lib/matplotlib/patches.py 2007-09-10 19:25:21 UTC (rev 3826) @@ -209,8 +209,13 @@ gc.set_hatch(self._hatch ) verts = self.get_verts() - tverts = self.get_transform().seq_xy_tups(verts) + tverts = self.get_transform()(verts) + # MGDTODO: This result is an Nx2 numpy array, which could be passed + # directly to renderer.draw_polygon. However, it currently expects + # a list of tuples so we're converting it to that now. + tverts = [tuple(x) for x in tverts] + renderer.draw_polygon(gc, rgbFace, tverts) Modified: branches/transforms/lib/matplotlib/text.py =================================================================== --- branches/transforms/lib/matplotlib/text.py 2007-09-10 18:45:32 UTC (rev 3825) +++ branches/transforms/lib/matplotlib/text.py 2007-09-10 19:25:21 UTC (rev 3826) @@ -151,7 +151,7 @@ def _get_xy_display(self): 'get the (possibly unit converted) transformed x,y in display coords' x, y = self.get_position() - return self.get_transform().xy_tup((x,y)) + return self.get_transform()([[x,y]])[0] def _get_multialignment(self): if self._multialignment is not None: return self._multialignment @@ -275,7 +275,8 @@ ty = [float(v[1][0])+offsety for v in xys] # now inverse transform back to data coords - xys = [self.get_transform().inverse_xy_tup( xy ) for xy in zip(tx, ty)] + inverse_transform = self.get_transform().inverted() + xys = inverse_transform(zip(tx, ty)) xs, ys = zip(*xys) @@ -328,7 +329,7 @@ return for line, wh, x, y in info: - x, y = trans.xy_tup((x, y)) + x, y = trans([[x, y]])[0] if renderer.flipy(): canvasw, canvash = renderer.get_canvas_width_height() @@ -405,7 +406,7 @@ return (x, y, self._text, self._color, self._verticalalignment, self._horizontalalignment, hash(self._fontproperties), self._rotation, - self.get_transform().as_vec6_val(), + self.get_transform().to_values(), ) def get_text(self): Modified: branches/transforms/lib/matplotlib/ticker.py =================================================================== --- branches/transforms/lib/matplotlib/ticker.py 2007-09-10 18:45:32 UTC (rev 3825) +++ branches/transforms/lib/matplotlib/ticker.py 2007-09-10 19:25:21 UTC (rev 3826) @@ -115,12 +115,11 @@ import matplotlib as mpl from matplotlib import verbose, rcParams from matplotlib import cbook -from matplotlib import transforms as mtrans +from matplotlib import bbox as mbbox - class TickHelper: viewInterval = None @@ -149,8 +148,8 @@ cases where the Intervals do not need to be updated automatically. ''' - self.dataInterval = mtrans.Interval(mtrans.Value(vmin), mtrans.Value(vmax)) - self.viewInterval = mtrans.Interval(mtrans.Value(vmin), mtrans.Value(vmax)) + self.dataInterval = mbbox.Interval([vmin, vmax]) + self.viewInterval = mbbox.Interval([vmin, vmax]) class Formatter(TickHelper): """ @@ -572,7 +571,7 @@ def autoscale(self): 'autoscale the view limits' self.verify_intervals() - return mtrans.nonsingular(*self.dataInterval.get_bounds()) + return mbbox.nonsingular(*self.dataInterval.get_bounds()) def pan(self, numsteps): 'Pan numticks (can be positive or negative)' @@ -714,7 +713,7 @@ vmin = math.floor(scale*vmin)/scale vmax = math.ceil(scale*vmax)/scale - return mtrans.nonsingular(vmin, vmax) + return mbbox.nonsingular(vmin, vmax) def closeto(x,y): @@ -798,7 +797,7 @@ vmin -=1 vmax +=1 - return mtrans.nonsingular(vmin, vmax) + return mbbox.nonsingular(vmin, vmax) def scale_range(vmin, vmax, n = 1, threshold=100): dv = abs(vmax - vmin) @@ -866,13 +865,13 @@ def __call__(self): self.verify_intervals() vmin, vmax = self.viewInterval.get_bounds() - vmin, vmax = mtrans.nonsingular(vmin, vmax, expander = 0.05) + vmin, vmax = mbbox.nonsingular(vmin, vmax, expander = 0.05) return self.bin_boundaries(vmin, vmax) def autoscale(self): self.verify_intervals() dmin, dmax = self.dataInterval.get_bounds() - dmin, dmax = mtrans.nonsingular(dmin, dmax, expander = 0.05) + dmin, dmax = mbbox.nonsingular(dmin, dmax, expander = 0.05) return npy.take(self.bin_boundaries(dmin, dmax), [0,-1]) @@ -973,7 +972,7 @@ if vmin==vmax: vmin = decade_down(vmin,self._base) vmax = decade_up(vmax,self._base) - return mtrans.nonsingular(vmin, vmax) + return mbbox.nonsingular(vmin, vmax) class AutoLocator(MaxNLocator): def __init__(self): Modified: branches/transforms/src/_backend_agg.cpp =================================================================== --- branches/transforms/src/_backend_agg.cpp 2007-09-10 18:45:32 UTC (rev 3825) +++ branches/transforms/src/_backend_agg.cpp 2007-09-10 19:25:21 UTC (rev 3826) @@ -44,6 +44,27 @@ #define M_PI_2 1.57079632679489661923 #endif +agg::trans_affine py_sequence_to_agg_transformation_matrix(const Py::Object& obj) { + Py::SeqBase<Py::Float> seq; + try { + seq = obj; + } catch(...) { + throw Py::ValueError("Transformation matrix must be given as a 6-element list."); + } + + if (seq.size() != 6) { + throw Py::ValueError("Transformation matrix must be given as a 6-element list."); + } + + agg::trans_affine xytrans = agg::trans_affine + (Py::Float(seq[0]), + Py::Float(seq[1]), + Py::Float(seq[2]), + Py::Float(seq[3]), + Py::Float(seq[4]), + Py::Float(seq[5])); +} + GCAgg::GCAgg(const Py::Object &gc, double dpi, bool snapto) : dpi(dpi), snapto(snapto), isaa(true), linewidth(1.0), alpha(1.0), cliprect(NULL), clippath(NULL), @@ -646,7 +667,8 @@ Py::SeqBase<Py::Object> linewidths = args[4]; Py::SeqBase<Py::Object> linestyle = args[5]; Py::SeqBase<Py::Object> antialiaseds = args[6]; - + + // MGDTODO: Verify we don't need this offset stuff anymore bool usingOffsets = args[7].ptr()!=Py_None; Py::SeqBase<Py::Object> offsets; Transformation* transOffset=NULL; @@ -1534,24 +1556,14 @@ //path_t transpath(path, xytrans); _process_alpha_mask(gc); - Transformation* mpltransform = static_cast<Transformation*>(args[3].ptr()); + agg::trans_affine xytrans = py_sequence_to_agg_transformation_matrix(args[3]); - double a, b, c, d, tx, ty; - try { - mpltransform->affine_params_api(&a, &b, &c, &d, &tx, &ty); - } - catch(...) { - throw Py::ValueError("Domain error on affine_params_api in RendererAgg::draw_lines"); - } - - agg::trans_affine xytrans = agg::trans_affine(a,b,c,d,tx,ty); - - agg::path_storage path; + // MGDTODO + bool needNonlinear = false; + // mpltransform->need_nonlinear_api(); - bool needNonlinear = mpltransform->need_nonlinear_api(); - double thisx(0.0), thisy(0.0); double origdx(0.0), origdy(0.0), origdNorm2(0); bool moveto = true; @@ -1584,7 +1596,8 @@ if (needNonlinear) try { - mpltransform->nonlinear_only_api(&thisx, &thisy); + // MGDTODO + // mpltransform->nonlinear_only_api(&thisx, &thisy); } catch (...) { moveto = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |