Changeset 824e488 in sasview for src/sas/guiframe/local_perspectives/plotting/BaseInteractor.py
- Timestamp:
- Mar 5, 2015 2:18:47 PM (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:
- b5de88e
- Parents:
- b9dbd6b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/guiframe/local_perspectives/plotting/BaseInteractor.py
r79492222 r824e488 8 8 profile_colors = [rho_color, mu_color, P_color, theta_color] 9 9 10 class _BaseInteractor :10 class _BaseInteractor(object): 11 11 """ 12 12 Share some functions between the interface interactor and various layer 13 13 interactors. 14 14 15 15 Individual interactors need the following functions: 16 16 17 17 save(ev) - save the current state for later restore 18 18 restore() - restore the old state … … 20 20 moveend(ev) - end the drag event 21 21 update() - draw the interactors 22 22 23 23 The following are provided by the base class: 24 24 25 25 connect_markers(markers) - register callbacks for all markers 26 26 clear_markers() - remove all items in self.markers … … 31 31 onDrag(ev) - mouse move: calls move() or restore() 32 32 onKey(ev) - keyboard move: calls move() or restore() 33 33 34 34 Interactor attributes: 35 35 36 36 base - model we are operating on 37 37 axes - axes holding the interactor 38 38 color - color of the interactor in non-active state 39 39 markers - list of handles for the interactor 40 40 41 41 """ 42 42 def __init__(self, base, axes, color='black'): … … 49 49 self.clicky = None 50 50 self.markers = [] 51 51 52 52 def clear_markers(self): 53 53 """ … … 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 """ … … 83 83 Connect markers to callbacks 84 84 """ 85 85 86 86 for h in markers: 87 87 connect = self.base.connect … … 109 109 self.base.draw() 110 110 return True 111 111 112 112 def onClick(self, ev): 113 113 """ … … 138 138 self.base.update() 139 139 return True 140 140 141 141 def onKey(self, ev): 142 142 """ 143 143 Respond to keyboard events. Arrow keys move the widget. Escape 144 144 restores it to the position before the last click. 145 145 146 146 Calls move() to update the state. Calls restore() on escape. 147 147 """ … … 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.0, py+1.0))178 dx, dy = nx -x, ny-y177 nx, ny = ax.transData.xy_tup((px + 1.0, py + 1.0)) 178 dx, dy = nx - x, ny - y 179 179 return dx, dy 180 180
Note: See TracChangeset
for help on using the changeset viewer.