[Yt-svn] yt-commit r1797 - trunk/yt/extensions/image_panner

mturk at wrangler.dreamhost.com mturk at wrangler.dreamhost.com
Wed Jul 7 21:16:42 PDT 2010


Author: mturk
Date: Wed Jul  7 21:16:42 2010
New Revision: 1797
URL: http://yt.enzotools.org/changeset/1797

Log:
Backporting set_width on image panner to trunk



Modified:
   trunk/yt/extensions/image_panner/vm_panner.py

Modified: trunk/yt/extensions/image_panner/vm_panner.py
==============================================================================
--- trunk/yt/extensions/image_panner/vm_panner.py	(original)
+++ trunk/yt/extensions/image_panner/vm_panner.py	Wed Jul  7 21:16:42 2010
@@ -26,6 +26,7 @@
 from yt.raven import FixedResolutionBuffer, ObliqueFixedResolutionBuffer
 from yt.lagos import data_object_registry, AMRProjBase, AMRSliceBase, \
                      x_dict, y_dict
+from yt.funcs import *
 
 class VariableMeshPanner(object):
     _buffer = None
@@ -161,6 +162,20 @@
         self.ylim = (low[1], high[1])
         return na.log10(self.buffer)
 
+    def set_width(self, width):
+        """
+        This sets the width based on the current center.
+        """
+        if not iterable(width): width = (width, width)
+        Wx, Wy = self.width
+        centerx = self.xlim[0] + Wx*0.5
+        centery = self.ylim[0] + Wy*0.5
+        self.xlim = (centerx - width[0]/2.0,
+                     centerx + width[0]/2.0)
+        self.ylim = (centery - width[1]/2.0,
+                     centery + width[1]/2.0)
+        self._run_callbacks()
+
     def set_limits(self, xlim, ylim):
         """
         This accepts a new *xlim* and *ylim*.



More information about the yt-svn mailing list