Changeset 2df0b74 in sasview for src/sas/plottools/BaseInteractor.py
- Timestamp:
- Mar 5, 2015 11:17:05 AM (10 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 3477478
- Parents:
- dca6188
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/plottools/BaseInteractor.py
r79492222 r2df0b74 9 9 10 10 11 class _BaseInteractor :11 class _BaseInteractor(object): 12 12 """ 13 13 Share some functions between the interface interactor and various layer 14 14 interactors. 15 15 16 16 Individual interactors need the following functions: 17 17 18 18 save(ev) - save the current state for later restore 19 19 restore() - restore the old state … … 21 21 moveend(ev) - end the drag event 22 22 update() - draw the interactors 23 23 24 24 The following are provided by the base class: 25 25 26 26 connect_markers(markers) - register callbacks for all markers 27 27 clear_markers() - remove all items in self.markers … … 32 32 onDrag(ev) - mouse move: calls move() or restore() 33 33 onKey(ev) - keyboard move: calls move() or restore() 34 34 35 35 Interactor attributes: 36 36 37 37 base - model we are operating on 38 38 axes - axes holding the interactor 39 39 color - color of the interactor in non-active state 40 40 markers - list of handles for the interactor 41 41 42 42 """ 43 43 def __init__(self, base, axes, color='black'): … … 48 48 self.color = color 49 49 self.markers = [] 50 50 51 51 def clear_markers(self): 52 52 ''' … … 63 63 """ 64 64 pass 65 65 66 66 def restore(self, ev): 67 67 """ 68 68 """ 69 69 pass 70 70 71 71 def move(self, x, y, ev): 72 72 """ 73 73 """ 74 74 pass 75 75 76 76 def moveend(self, ev): 77 77 """ … … 108 108 self.base.draw() 109 109 return True 110 110 111 111 def onClick(self, ev): 112 112 """ … … 137 137 self.base.update() 138 138 return True 139 139 140 140 def onKey(self, ev): 141 141 """ 142 142 Respond to keyboard events. Arrow keys move the widget. Escape 143 143 restores it to the position before the last click. 144 144 145 145 Calls move() to update the state. Calls restore() on escape. 146 146 """ … … 173 173 px, py = ax.transData.inverse_xy_tup((x, y)) 174 174 if nudge: 175 nx, ny = ax.transData.xy_tup((px +0.2, py+0.2))175 nx, ny = ax.transData.xy_tup((px + 0.2, py + 0.2)) 176 176 else: 177 nx, ny = ax.transData.xy_tup((px +1., py+1.))178 dx, dy = nx -x, ny-y177 nx, ny = ax.transData.xy_tup((px + 1., py + 1.)) 178 dx, dy = nx - x, ny - y 179 179 return dx, dy
Note: See TracChangeset
for help on using the changeset viewer.