Changeset df25521 in sasview
- Timestamp:
- Jun 9, 2008 1:50:54 PM (16 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:
- 06290c8
- Parents:
- 105614c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
guitools/PlotPanel.py
r105614c rdf25521 13 13 from pylab import gca, gcf 14 14 from plottables import Theory1D 15 16 #from matplotlib.backend_bases import MouseEvent 15 17 #from plottables import Data1D 16 18 #TODO: make the plottables interactive 17 19 18 20 DEBUG = False 21 print "hello" 19 22 20 23 from plottables import Graph … … 49 52 #print"this is unit",unit 50 53 return unit 51 52 54 def _rescale(lo,hi,step,pt=None,bal=None,scale='linear'): 53 55 """ … … 133 135 #self.Bind(EVT_FUNC_FIT, self.onFitRange) 134 136 self.Bind(wx.EVT_CONTEXT_MENU, self.onContextMenu) 137 135 138 #self.Bind(EVT_PROPERTY, self._onEVT_FUNC_PROPERTY) 136 139 # Define some constants … … 145 148 self.prevYtrans ="y" 146 149 self.canvas.mpl_connect('scroll_event',self.onWheel) 150 #taking care of dragging 151 self.canvas.mpl_connect('motion_notify_event',self.onMouseMotion) 152 self.canvas.mpl_connect('button_press_event',self.onLeftDown) 153 self.canvas.mpl_connect('button_release_event',self.onLeftUp) 154 #self.canvas.mpl_connect('key_press_event',self.onKeyPress) 155 156 self.leftdown=False 157 self.leftup=False 158 self.mousemotion=False 159 160 #self.canvas.Bind(wx.EVT_MOUSE_EVENTS,self.onTest) 147 161 self.axes = [self.subplot] 148 162 # new data for the fit … … 160 174 self.ErrBvalue=None 161 175 self.Chivalue=None 162 176 self.begDrag=False 177 #self.begDragI=False 178 self.xInit=None 179 self.yInit=None 180 self.xFinal=None 181 self.yFinal=None 182 183 def onLeftDown(self,event): 184 """ left button down and ready to drag""" 185 self.leftdown=True 186 ax = event.inaxes 187 if ax !=None: 188 x,y = event.x,event.y 189 self.xInit,self.yInit=ax.transAxes.inverse_xy_tup((x,y)) 190 191 def onLeftUp(self,event): 192 """ Dragging is done """ 193 194 self.leftup=True 195 196 if self.mousemotion==True: 197 ax = event.inaxes 198 if ax !=None: 199 x,y = event.x,event.y 200 self.xFinal,self.yFinal=ax.transAxes.inverse_xy_tup((x,y)) 201 202 #print "this is xFinal %f this is yFinal %f"%(self.xFinal, self.yFinal) 203 #print "this is xInit %f this is yInit %f"%(self.xInit, self.yInit) 204 #print "this is xdelta %f and ydelta %f"%(xdelta,ydelta) 205 xdelta = self.xFinal -self.xInit 206 ydelta = self.yFinal -self.yInit 207 208 self.dragHelper(xdelta,ydelta) 209 210 def onMouseMotion(self,event): 211 if self.leftdown==True: 212 self.mousemotion=True 213 214 def dragHelper(self,xdelta,ydelta): 215 """ dragging occurs here""" 216 217 # Event occurred inside a plotting area 218 for ax in self.axes: 219 lo,hi= ax.get_xlim() 220 #print "x lo %f and x hi %f"%(lo,hi) 221 newlo,newhi= lo- xdelta, hi- xdelta 222 if self.xscale=='log': 223 if newlo > 0: 224 newlo= math.log10(newlo) 225 if newhi > 0: 226 newhi= math.log10(newhi) 227 if self.xscale=='log': 228 ax.set_xlim(math.pow(10,newlo),math.pow(10,newhi)) 229 else: 230 ax.set_xlim(newlo,newhi) 231 print "new lo %f and new hi %f"%(newlo,newhi) 232 233 lo,hi= ax.get_ylim() 234 print "y lo %f and y hi %f"%(lo,hi) 235 newlo,newhi= lo- ydelta, hi- ydelta 236 if self.yscale=='log': 237 if newlo > 0: 238 newlo= math.log10(newlo) 239 if newhi > 0: 240 newhi= math.log10(newhi) 241 if self.yscale=='log': 242 ax.set_ylim(math.pow(10,newlo),math.pow(10,newhi)) 243 else: 244 ax.set_ylim(newlo,newhi) 245 self.canvas.draw_idle() 246 247 248 163 249 def resetFitView(self): 164 250 """ … … 174 260 self.ErrBvalue=None 175 261 self.Chivalue=None 176 262 177 263 def onWheel(self, event): 178 264 """ … … 350 436 self.figure.canvas.draw_idle() 351 437 352 353 354 355 438 356 439 def onSaveImage(self, evt):
Note: See TracChangeset
for help on using the changeset viewer.