Revision: 7968
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7968&view=rev
Author:   mdehoon
Date:     2009-11-15 14:07:11 +0000 (Sun, 15 Nov 2009)

Log Message:
-----------
Fixing the order of transformations; see bug #2896668 on sourceforge.
The master transformation was moved to backend_macosx.py.

Modified Paths:
--------------
    trunk/matplotlib/lib/matplotlib/backends/backend_macosx.py
    trunk/matplotlib/src/_macosx.m

Modified: trunk/matplotlib/lib/matplotlib/backends/backend_macosx.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_macosx.py  2009-11-15 
03:31:26 UTC (rev 7967)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_macosx.py  2009-11-15 
14:07:11 UTC (rev 7968)
@@ -63,12 +63,15 @@
                              linewidths, linestyles, antialiaseds, urls):
         cliprect = gc.get_clip_rectangle()
         clippath, clippath_transform = gc.get_clip_path()
-        gc.draw_path_collection(master_transform,
-                                cliprect,
+        if all_transforms:
+            transforms = [numpy.dot(master_transform, t) for t in 
all_transforms]
+        else:
+            transforms = [master_transform]
+        gc.draw_path_collection(cliprect,
                                 clippath,
                                 clippath_transform,
                                 paths,
-                                all_transforms,
+                                transforms,
                                 offsets,
                                 offsetTrans,
                                 facecolors,

Modified: trunk/matplotlib/src/_macosx.m
===================================================================
--- trunk/matplotlib/src/_macosx.m      2009-11-15 03:31:26 UTC (rev 7967)
+++ trunk/matplotlib/src/_macosx.m      2009-11-15 14:07:11 UTC (rev 7968)
@@ -1165,7 +1165,6 @@
 static PyObject*
 GraphicsContext_draw_path_collection (GraphicsContext* self, PyObject* args)
 {
-    PyObject* master_transform;
     PyObject* cliprect;
     PyObject* clippath;
     PyObject* clippath_transform;
@@ -1187,19 +1186,18 @@
         return NULL;
     }
 
-    if(!PyArg_ParseTuple(args, "OOOOOOOOOOOOO", &master_transform,
-                                                &cliprect,
-                                                &clippath,
-                                                &clippath_transform,
-                                                &paths,
-                                                &transforms,
-                                                &offsets,
-                                                &offset_transform,
-                                                &facecolors,
-                                                &edgecolors,
-                                                &linewidths,
-                                                &linestyles,
-                                                &antialiaseds))
+    if(!PyArg_ParseTuple(args, "OOOOOOOOOOOO", &cliprect,
+                                               &clippath,
+                                               &clippath_transform,
+                                               &paths,
+                                               &transforms,
+                                               &offsets,
+                                               &offset_transform,
+                                               &facecolors,
+                                               &edgecolors,
+                                               &linewidths,
+                                               &linestyles,
+                                               &antialiaseds))
         return NULL;
 
     int ok = 1;
@@ -1235,43 +1233,22 @@
         PyErr_SetString(PyExc_ValueError, "transforms must be a sequence 
object");
         return NULL;
     }
-    Py_ssize_t Ntransforms = PySequence_Size(transforms);
-
-    CGContextSaveGState(cr);
-    /* ------------------- Set master transform --------------------------- */
-
-    if (Ntransforms)
+    const Py_ssize_t Ntransforms = PySequence_Size(transforms);
+    if (Ntransforms==0)
     {
-        CGAffineTransform master;
-        double a, b, c, d, tx, ty;
-        PyObject* values = PyObject_CallMethod(master_transform, "to_values", 
"");
-        if (!values)
-        {
-            ok = 0;
-            goto exit;
-        }
-        if (!PyTuple_Check(values))
-        {
-            Py_DECREF(values);
-            ok = 0;
-            goto exit;
-        }
-        /* CGAffineTransform contains CGFloat; cannot use master directly */
-        ok = PyArg_ParseTuple(values, "dddddd", &a, &b, &c, &d, &tx, &ty);
-        Py_DECREF(values);
-        master.a = a;
-        master.b = b;
-        master.c = c;
-        master.d = d;
-        master.tx = tx;
-       master.ty = ty;
-        if (!ok) goto exit;
-        CGContextConcatCTM(cr, master);
+        PyErr_SetString(PyExc_ValueError, "transforms should contain at least 
one item");
+        return NULL;
     }
 
-    /* ------------------- Check offsets array ---------------------------- */
+    /* ------------------- Read drawing arrays ---------------------------- */
 
+    CGContextSaveGState(cr);
     offsets = PyArray_FromObject(offsets, NPY_DOUBLE, 0, 2);
+    facecolors = PyArray_FromObject(facecolors, NPY_DOUBLE, 1, 2);
+    edgecolors = PyArray_FromObject(edgecolors, NPY_DOUBLE, 1, 2);
+
+    /* ------------------- Check offsets array ---------------------------- */
+
     if (!offsets ||
         (PyArray_NDIM(offsets)==2 && PyArray_DIM(offsets, 1)!=2) ||
         (PyArray_NDIM(offsets)==1 && PyArray_DIM(offsets, 0)!=0))
@@ -1282,11 +1259,36 @@
     }
     const Py_ssize_t Noffsets = PyArray_DIM(offsets, 0);
 
+    /* ------------------- Check facecolors array ------------------------- */
+
+    if (!facecolors ||
+        (PyArray_NDIM(facecolors)==1 && PyArray_DIM(facecolors, 0)!=0) ||
+        (PyArray_NDIM(facecolors)==2 && PyArray_DIM(facecolors, 1)!=4))
+    {
+        PyErr_SetString(PyExc_ValueError, "Facecolors must by a Nx4 numpy 
array or empty");
+        ok = 0;
+        goto exit;
+    }
+
+    /* ------------------- Check edgecolors array ------------------------- */
+
+    if (!edgecolors ||
+        (PyArray_NDIM(edgecolors)==1 && PyArray_DIM(edgecolors, 0)!=0) ||
+        (PyArray_NDIM(edgecolors)==2 && PyArray_DIM(edgecolors, 1)!=4))
+    {
+        PyErr_SetString(PyExc_ValueError, "Edgecolors must by a Nx4 numpy 
array or empty");
+        ok = 0;
+        goto exit;
+    }
+
     /* -------------------------------------------------------------------- */
 
+    if (Npaths==0) goto exit; /* Nothing to do */
+
+    /* -------------------------------------------------------------------- */
+
     Np = Npaths > Ntransforms ? Npaths : Ntransforms;
     N = Np > Noffsets ? Np : Noffsets;
-    if (N < Ntransforms) Ntransforms = N;
 
     p = malloc(Np*sizeof(CGMutablePathRef));
     if (!p)
@@ -1305,35 +1307,22 @@
             ok = 0;
             goto exit;
         }
-        if (Ntransforms)
+        transform = PySequence_ITEM(transforms, i % Ntransforms);
+        if (!transform)
         {
-            transform = PySequence_ITEM(transforms, i % Ntransforms);
-            if (!transform)
-            {
-                PyErr_SetString(PyExc_RuntimeError,
-                                "failed to obtain transform");
-                ok = 0;
-                goto exit;
-            }
-            iterator = get_path_iterator(path,
-                                         transform,
-                                         1,
-                                         0,
-                                         rect,
-                                         mode,
-                                         0);
-            Py_DECREF(transform);
+            PyErr_SetString(PyExc_RuntimeError, "failed to obtain transform");
+            Py_DECREF(path);
+            ok = 0;
+            goto exit;
         }
-        else
-        {
-            iterator = get_path_iterator(path,
-                                         master_transform,
-                                         1,
-                                         0,
-                                         rect,
-                                         mode,
-                                         0);
-        }
+        iterator = get_path_iterator(path,
+                                     transform,
+                                     1,
+                                     0,
+                                     rect,
+                                     mode,
+                                     0);
+        Py_DECREF(transform);
         Py_DECREF(path);
         if (!iterator)
         {
@@ -1381,30 +1370,6 @@
         if (n > 0) CGContextClip(cr);
     }
 
-    /* ------------------- Check facecolors array ------------------------- */
-
-    facecolors = PyArray_FromObject(facecolors, NPY_DOUBLE, 1, 2);
-    if (!facecolors ||
-        (PyArray_NDIM(facecolors)==1 && PyArray_DIM(facecolors, 0)!=0) ||
-        (PyArray_NDIM(facecolors)==2 && PyArray_DIM(facecolors, 1)!=4))
-    {
-        PyErr_SetString(PyExc_ValueError, "Facecolors must by a Nx4 numpy 
array or empty");
-        ok = 0;
-        goto exit;
-    }
-
-    /* ------------------- Check edgecolors array ------------------------- */
-
-    edgecolors = PyArray_FromObject(edgecolors, NPY_DOUBLE, 1, 2);
-    if (!edgecolors ||
-        (PyArray_NDIM(edgecolors)==1 && PyArray_DIM(edgecolors, 0)!=0) ||
-        (PyArray_NDIM(edgecolors)==2 && PyArray_DIM(edgecolors, 1)!=4))
-    {
-        PyErr_SetString(PyExc_ValueError, "Edgecolors must by a Nx4 numpy 
array or empty");
-        ok = 0;
-        goto exit;
-    }
-
     /* ------------------- Check the other arguments ---------------------- */
 
     if (!PySequence_Check(linewidths))
@@ -1610,7 +1575,6 @@
         free(p);
     }
     if (!ok) return NULL;
-
     Py_INCREF(Py_None);
     return Py_None;
 }
@@ -2390,7 +2354,6 @@
         PyErr_SetString(PyExc_RuntimeError, "ATSUDrawText failed");
         return NULL;
     }
-
     Py_INCREF(Py_None);
     return Py_None;
 }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-checkins mailing list
Matplotlib-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to