[Yt-svn] commit/yt: MatthewTurk: Ctrl-click on an image in the plot window widget now re-centers. There may be

Bitbucket commits-noreply at bitbucket.org
Thu Apr 21 03:15:17 PDT 2011


1 new changeset in yt:

http://bitbucket.org/yt_analysis/yt/changeset/28326e73a7cc/
changeset:   r4177:28326e73a7cc
branch:      yt
user:        MatthewTurk
date:        2011-04-21 12:15:06
summary:     Ctrl-click on an image in the plot window widget now re-centers.  There may be
glitchiness with this, but it has worked for me.
affected #:  2 files (1.1 KB)

--- a/yt/gui/reason/html/js/widget_plotwindow.js	Thu Apr 21 05:06:03 2011 -0400
+++ b/yt/gui/reason/html/js/widget_plotwindow.js	Thu Apr 21 06:15:06 2011 -0400
@@ -79,6 +79,21 @@
                     y: 10,
                     width: 400,
                     height: 400,
+                    listeners: {
+                        afterrender: function(c){
+                            c.el.on('click', function(e){
+                                if (e.ctrlKey == false) return;
+                                xy = e.getXY();
+                                cc = python_varname + ".image_recenter(" 
+                                    + (xy[0] - c.el.dom.x) + ", "
+                                    + (xy[1] - c.el.dom.y) + ", "
+                                    + c.el.dom.width + ", "
+                                    + c.el.dom.height + ")";
+                                yt_rpc.ExtDirectREPL.execute(
+                                {code:cc, hide:false}, cell_finished); 
+                            });
+                        }
+                    }
                 }, {   xtype: 'multislider',
                     id: 'slider_' + python_varname,
                     minValue: 0,
@@ -310,7 +325,6 @@
     this.zoom_scroll = this.panel.get("slider_" + python_varname);
     var image_dom = this.image_panel.el.dom;
     var control_panel = this.panel;
-    examine = this.zoom_scroll;
     var metadata_string;
 
     this.accept_results = function(payload) {


--- a/yt/visualization/plot_window.py	Thu Apr 21 05:06:03 2011 -0400
+++ b/yt/visualization/plot_window.py	Thu Apr 21 06:15:06 2011 -0400
@@ -370,6 +370,14 @@
                 unit = unit, mi = mi, ma = ma)
         return md
 
+    def image_recenter(self, img_x, img_y, img_size_x, img_size_y):
+        dx = (self.xlim[1] - self.xlim[0]) / img_size_x
+        dy = (self.ylim[1] - self.ylim[0]) / img_size_y
+        new_x = img_x * dx + self.xlim[0]
+        new_y = img_y * dy + self.ylim[0]
+        print img_x, img_y, dx, dy, new_x, new_y
+        self.set_center((new_x, new_y))
+
     @invalidate_data
     def set_current_field(self, field):
         self._current_field = field

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list