Changeset 1981 for trunk/python/casatoolbar.py
- Timestamp:
- 01/28/11 17:34:32 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/casatoolbar.py
r1979 r1981 1 1 import os 2 import matplotlib 2 import matplotlib, numpy 3 from asap.logging import asaplog, asaplog_post_dec 3 4 4 5 ###################################### … … 168 169 169 170 def _new_page(self,next=True): 171 if self.plotter._startrow <= 0: 172 msg = "The page counter is reset due to chages of plot settings. " 173 msg += "Plotting from the first page." 174 asaplog.push(msg) 175 asaplog.post('WARN') 176 next = True 177 170 178 self.plotter._plotter.hold() 179 if not next: 180 self._set_prevpage_counter() 171 181 #self.plotter._plotter.clear() 182 self.set_pagenum(self._get_pagenum()) 172 183 self.plotter._plot(self.plotter._data) 173 184 self.plotter._plotter.release() … … 175 186 self.plotter._plotter.show(hardrefresh=False) 176 187 188 def _set_prevpage_counter(self): 189 # set row and panel counters to those of the 1st panel of previous page 190 maxpanel = 16 191 # the ID of the last panel in current plot 192 lastpanel = self.plotter._ipanel 193 # the number of current subplots 194 currpnum = len(self.plotter._plotter.subplots) 195 # the nuber of previous subplots 196 prevpnum = None 197 if self.plotter._rows and self.plotter._cols: 198 # when user set layout 199 prevpnum = self.plotter._rows*self.plotter._cols 200 else: 201 # no user specification 202 prevpnum = maxpanel 203 204 start_ipanel = max(lastpanel-currpnum-prevpnum+1, 0) 205 # set the pannel ID of the last panel of prev-prev page 206 self.plotter._ipanel = start_ipanel-1 207 if self.plotter._panelling == 'r': 208 self.plotter._startrow = start_ipanel 209 else: 210 # the start row number of the next panel 211 self.plotter._startrow = self.plotter._panelrows[start_ipanel] 212 del lastpanel,currpnum,prevpnum,start_ipanel 213 214 def _get_pagenum(self): 215 maxpanel = 16 216 nextp = self.plotter._ipanel+1 217 if self.plotter._rows and self.plotter._cols: 218 ppp = self.plotter._rows*self.plotter._cols 219 else: 220 ppp = maxpanel 221 return int(nextp/ppp)+1 177 222 178 223 ##################################### … … 191 236 if not parent._plotter: 192 237 return False 193 self._p=parent._plotter 194 self.figmgr=self._p.figmgr 195 self.canvas=self.figmgr.canvas 196 self.mode='' 197 self.button=True 238 self._p = parent._plotter 239 self.figmgr = self._p.figmgr 240 self.canvas = self.figmgr.canvas 241 self.mode = '' 242 self.button = True 243 self.pagenum = None 198 244 self._add_custom_toolbar() 199 245 self.notewin=NotationWindowTkAgg(master=self.canvas) … … 205 251 # text='spec value', 206 252 # command=self.spec_show) 253 self.bNote=self._NewButton(master=self, 254 text='notation', 255 command=self.modify_note) 256 207 257 self.bStat=self._NewButton(master=self, 208 258 text='statistics', 209 259 command=self.stat_cal) 210 self.bNote=self._NewButton(master=self, 211 text='notation', 212 command=self.modify_note) 213 #self.bPrev=self._NewButton(master=self, 214 # text='- page', 215 # command=self.prev_page) 260 # page change oparations 261 self.lPagetitle = Tk.Label(master=self,text=' Page:',padx=5) 262 self.lPagetitle.pack(side=Tk.LEFT) 263 self.pagenum = Tk.StringVar(master=self) 264 self.lPage = Tk.Label(master=self,textvariable=self.pagenum, 265 padx=5,bg='white') 266 self.lPage.pack(side=Tk.LEFT,padx=3) 267 216 268 self.bNext=self._NewButton(master=self, 217 text=' + page',269 text=' + ', 218 270 command=self.next_page) 271 self.bPrev=self._NewButton(master=self, 272 text=' - ', 273 command=self.prev_page) 274 219 275 if os.uname()[0] != 'Darwin': 220 #self.bPrev.config(padx=5)276 self.bPrev.config(padx=5) 221 277 self.bNext.config(padx=5) 222 278 self.bQuit=self._NewButton(master=self, … … 225 281 side=Tk.RIGHT) 226 282 self.pack(side=Tk.BOTTOM,fill=Tk.BOTH) 283 self.pagenum.set(' ') 227 284 228 285 self.disable_button() … … 289 346 self._new_page(next=True) 290 347 348 def set_pagenum(self,page): 349 nwidth = int(numpy.ceil(numpy.log10(max(page,1))))+1 350 nwidth = max(nwidth,4) 351 formatstr = '%'+str(nwidth)+'d' 352 self.pagenum.set(formatstr % (page)) 353 291 354 def quit(self): 292 355 self.__disconnect_event() … … 304 367 def disable_button(self): 305 368 if not self.button: return 369 #self.bSpec.config(relief='raised', state=Tk.DISABLED) 306 370 self.bStat.config(relief='raised', state=Tk.DISABLED) 307 #self.b Spec.config(relief='raised',state=Tk.DISABLED)371 #self.bNext.config(state=Tk.DISABLED) 308 372 #self.bPrev.config(state=Tk.DISABLED) 309 #self.bNext.config(state=Tk.DISABLED)310 373 self.button=False 311 374 self.mode='' … … 319 382 320 383 def enable_prev(self): 321 #self.bPrev.config(state=Tk.NORMAL) 322 pass 384 self.bPrev.config(state=Tk.NORMAL) 323 385 324 386 def disable_prev(self): 325 #self.bPrev.config(state=Tk.DISABLED) 326 pass 387 self.bPrev.config(state=Tk.DISABLED) 327 388 328 389 def delete_bar(self): … … 331 392 332 393 def __disconnect_event(self): 333 #idP=self.figmgr.toolbar._idPress334 #idR=self.figmgr.toolbar._idRelease335 #if idP is not None:336 # self.canvas.mpl_disconnect(idP)337 # self.figmgr.toolbar._idPress=None338 #if idR is not None:339 # self.canvas.mpl_disconnect(idR)340 # self.figmgr.toolbar._idRelease=None341 394 self._p.register('button_press',None) 342 395 self._p.register('button_release',None)
Note: See TracChangeset
for help on using the changeset viewer.