Changeset 2118 for trunk/python
- Timestamp:
- 04/07/11 17:54:23 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/casatoolbar.py
r2053 r2118 8 8 class CustomToolbarCommon: 9 9 def __init__(self,parent): 10 self.plotter =parent10 self.plotter = parent 11 11 #self.figmgr=self.plotter._plotter.figmgr 12 12 … … 25 25 return 26 26 27 xclick =event.xdata28 yclick =event.ydata29 dist2 =1000.30 pickline =None27 xclick = event.xdata 28 yclick = event.ydata 29 dist2 = 1000. 30 pickline = None 31 31 # If the pannel has picable objects 32 pflag =False32 pflag = False 33 33 for lin in event.inaxes.lines: 34 34 if not lin.pickable(): 35 35 continue 36 pflag =True36 pflag = True 37 37 flag,pind = lin.contains(event) 38 38 if not flag: … … 52 52 # Pickable but too far from mouse position 53 53 elif pickline is None: 54 picked ='No line selected.'54 picked = 'No line selected.' 55 55 self.figmgr.toolbar.set_message(picked) 56 56 return … … 66 66 xdata = pickline.get_xdata() 67 67 ydata = pickline.get_ydata() 68 titl =pickline.get_label()69 titp =event.inaxes.title.get_text()70 panel0 =event.inaxes71 picked ="Selected: '"+titl+"' in panel '"+titp+"'."68 titl = pickline.get_label() 69 titp = event.inaxes.title.get_text() 70 panel0 = event.inaxes 71 picked = "Selected: '"+titl+"' in panel '"+titp+"'." 72 72 thetoolbar.set_message(picked) 73 73 # Generate a navigation window … … 77 77 def spec_data(event): 78 78 # Getting spectrum data of neiboring point 79 xclick =event.xdata79 xclick = event.xdata 80 80 if event.inaxes != panel0: 81 81 return 82 ipoint =len(xdata)-182 ipoint = len(xdata)-1 83 83 for i in range(len(xdata)-1): 84 xl =xclick-xdata[i]85 xr =xclick-xdata[i+1]84 xl = xclick - xdata[i] 85 xr = xclick - xdata[i+1] 86 86 if xl*xr <= 0.: 87 87 ipoint = i 88 88 break 89 89 # Output spectral value on the navigation window 90 posi ='[ %s, %s ]: x = %.2f value = %.2f'\91 %(titl,titp,xdata[ipoint],ydata[ipoint])90 posi = '[ %s, %s ]: x = %.2f value = %.2f'\ 91 %(titl,titp,xdata[ipoint],ydata[ipoint]) 92 92 #naviwin.posi.set(posi) 93 93 thetoolbar.set_message(posi) … … 98 98 theplot.register('motion_notify',None) 99 99 # Re-activate the default motion_notify_event 100 thetoolbar._idDrag =thecanvas.mpl_connect('motion_notify_event',101 thetoolbar.mouse_move)100 thetoolbar._idDrag = thecanvas.mpl_connect('motion_notify_event', 101 thetoolbar.mouse_move) 102 102 theplot.register('button_release',None) 103 103 return … … 117 117 if event.inaxes == None: 118 118 return 119 if event.button == 1:119 if event.button == 1: 120 120 baseinv=True 121 121 elif event.button == 3: … … 126 126 def _calc_stats(): 127 127 msk=mymask.get_mask() 128 mymask.scan.stats(stat='max',mask=msk) 129 mymask.scan.stats(stat='min',mask=msk) 130 mymask.scan.stats(stat='sum',mask=msk) 131 mymask.scan.stats(stat='mean',mask=msk) 132 mymask.scan.stats(stat='median',mask=msk) 133 mymask.scan.stats(stat='rms',mask=msk) 134 mymask.scan.stats(stat='stddev',mask=msk) 128 statstr = ['max', 'min', 'mean', 'median', 'sum', 'stddev', 'rms'] 129 for stat in statstr: 130 mymask.scan.stats(stat=stat,mask=msk) 135 131 136 132 # Interactive mask definition 137 133 from asap.interactivemask import interactivemask 138 mymask =interactivemask(plotter=self.plotter,scan=self.plotter._data)134 mymask = interactivemask(plotter=self.plotter,scan=self.plotter._data) 139 135 # Create initial mask 140 136 mymask.set_basemask(invert=baseinv) … … 150 146 if not self.figmgr.toolbar.mode == '': 151 147 return 152 if event.button == 1:148 if event.button == 1: 153 149 self.notewin.load_textwindow(event) 154 150 elif event.button == 3 and self._note_picked(event): … … 172 168 def prev_page(self): 173 169 self.figmgr.toolbar.set_message('plotting the previous page') 170 #self._pause_buttons(operation="start",msg='plotting the previous page') 174 171 self._new_page(goback=True) 172 #self._pause_buttons(operation="end") 175 173 176 174 ### go to the next page 177 175 def next_page(self): 178 176 self.figmgr.toolbar.set_message('plotting the next page') 177 #self._pause_buttons(operation="start",msg='plotting the next page') 179 178 self._new_page(goback=False) 179 #self._pause_buttons(operation="end") 180 180 181 181 ### actual plotting of the new page … … 240 240 # no user specification 241 241 prevpnum = maxpanel 242 242 243 243 start_ipanel = max(lastpanel-currpnum-prevpnum+1, 0) 244 244 # set the pannel ID of the last panel of prev-prev page … … 272 272 ppp = maxpanel 273 273 return int(idlastpanel/ppp)+1 274 275 # pause buttons for slow operations. implemented at a backend dependent class 276 def _pause_buttons(self,operation="end",msg=""): 277 pass 278 274 279 275 280 ##################################### … … 295 300 self.pagecount = None 296 301 CustomToolbarCommon.__init__(self,parent) 297 self.notewin =NotationWindowTkAgg(master=self.canvas)302 self.notewin = NotationWindowTkAgg(master=self.canvas) 298 303 self._add_custom_toolbar() 299 304 300 305 def _add_custom_toolbar(self): 301 306 Tk.Frame.__init__(self,master=self.figmgr.window) 302 #self.bSpec =self._NewButton(master=self,303 # text='spec value',304 # command=self.spec_show)305 self.bNote =self._NewButton(master=self,306 text='notation',307 command=self.modify_note)308 309 self.bStat =self._NewButton(master=self,310 text='statistics',311 command=self.stat_cal)312 self.bQuit =self._NewButton(master=self,313 text='Quit',314 command=self.quit,315 side=Tk.RIGHT)307 #self.bSpec = self._NewButton(master=self, 308 # text='spec value', 309 # command=self.spec_show) 310 self.bNote = self._NewButton(master=self, 311 text='notation', 312 command=self.modify_note) 313 314 self.bStat = self._NewButton(master=self, 315 text='statistics', 316 command=self.stat_cal) 317 self.bQuit = self._NewButton(master=self, 318 text='Quit', 319 command=self.quit, 320 side=Tk.RIGHT) 316 321 317 322 # page change oparations … … 326 331 self.lPagecount.pack(side=Tk.LEFT,padx=3) 327 332 328 self.bNext =self._NewButton(master=frPage,329 text=' + ',330 command=self.next_page)331 self.bPrev =self._NewButton(master=frPage,332 text=' - ',333 command=self.prev_page)333 self.bNext = self._NewButton(master=frPage, 334 text=' + ', 335 command=self.next_page) 336 self.bPrev = self._NewButton(master=frPage, 337 text=' - ', 338 command=self.prev_page) 334 339 335 340 if os.uname()[0] != 'Darwin': … … 362 367 #self.bSpec.config(relief='sunken') 363 368 #self.bNote.config(relief='raised') 364 self.mode ='spec'369 self.mode = 'spec' 365 370 self.notewin.close_widgets() 366 371 self.__disconnect_event() … … 378 383 self.bStat.config(relief='sunken') 379 384 self.bNote.config(relief='raised') 380 self.mode ='stat'385 self.mode = 'stat' 381 386 self.notewin.close_widgets() 382 387 self.__disconnect_event() … … 388 393 if self.mode == 'note': 389 394 self.bNote.config(relief='raised') 390 self.mode ='none'395 self.mode = 'none' 391 396 self.spec_show() 392 397 return … … 394 399 self.bStat.config(relief='raised') 395 400 self.bNote.config(relief='sunken') 396 self.mode ='note'401 self.mode = 'note' 397 402 self.__disconnect_event() 398 403 self._p.register('button_press',self._mod_note) … … 408 413 #self.bSpec.config(state=Tk.NORMAL) 409 414 self.bStat.config(state=Tk.NORMAL) 410 self.button =True415 self.button = True 411 416 self.spec_show() 412 417 … … 417 422 #self.bNext.config(state=Tk.DISABLED) 418 423 #self.bPrev.config(state=Tk.DISABLED) 419 self.button =False420 self.mode =''424 self.button = False 425 self.mode = '' 421 426 self.__disconnect_event() 422 427 … … 432 437 def disable_prev(self): 433 438 self.bPrev.config(state=Tk.DISABLED) 439 440 # pause buttons for slow operations 441 def _pause_buttons(self,operation="end",msg=""): 442 buttons = ["bStat","bNote","bQuit"] 443 if operation == "start": 444 state = Tk.DISABLED 445 else: 446 state = Tk.NORMAL 447 for btn in buttons: 448 getattr(self,btn).config(state=state) 449 self.figmgr.toolbar.set_message(msg) 434 450 435 451 def delete_bar(self):
Note:
See TracChangeset
for help on using the changeset viewer.