1. Matthew Turk
  2. fisheye

Commits

Matthew Turk  committed 2a26766

"c" and click now re-centers

  • Participants
  • Parent commits aef8ed0
  • Branches default

Comments (0)

Files changed (1)

File simple_pan_scan.py

View file
         self.axes.set_ylabel("")
         self.axes.set_xlabel("")
         self.colorbar = self.figure.colorbar(self.image)
+        self.figure.canvas.mpl_connect("button_press_event", self.pick_event)
         
         self.canvas.draw()
         self.full_domain()
 
+    def pick_event(self, event):
+        if event.inaxes is self.axes and event.key == "c":
+            # Now we re-center
+            xbounds = self.pan_n_scan.xlim
+            ybounds = self.pan_n_scan.ylim
+            width = self.pan_n_scan.width
+            size = self.pan_n_scan.size
+            dx, dy = (width[0] / size[0], width[1] / size[1])
+            px, py = event.xdata, event.ydata
+            # Our new center ...
+            ax = self.pan_n_scan.source.axis
+            self.center[x_dict[ax]] = px * dx + xbounds[0]
+            self.center[y_dict[ax]] = py * dy + ybounds[0]
+            print "Re-centering at %s" % (self.center)
+            self.recenter()
+
+    def recenter(self):
+        self.pan_n_scan.set_center(self.center)
+        self._update_from_pns()
+
     @property
     def current_limits(self):
         buf = self.pan_n_scan.buffer
 app = SimpleWindow(root)
 Tk.mainloop()
 
+"""
+def key(event):
+    if event.char == event.keysym:
+        msg = 'Normal Key %r' % event.char
+    elif len(event.char) == 1:
+        msg = 'Punctuation Key %r (%r)' % (event.keysym, event.char)
+    else:
+        msg = 'Special Key %r' % event.keysym
+    label1.config(text=msg)
+
+root.bind_all('<Key>', key)
+# from http://www.daniweb.com/code/snippet216830.html
+"""