Changeset 4325
- Timestamp:
- Mar 26, 2007, 1:50:21 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/visualiser/offline.py
r4322 r4325 1 1 from Numeric import array, Float, ravel, zeros 2 2 from Scientific.IO.NetCDF import NetCDFFile 3 from Tkinter import Button, E, Tk, W 3 from Tkinter import Button, E, Tk, W, Label, StringVar, Scale, HORIZONTAL 4 4 from visualiser import Visualiser 5 5 from vtk import vtkCellArray, vtkPoints, vtkPolyData … … 13 13 structures for any dynamic height based quantities to render. 14 14 """ 15 def __init__(self, source, frameDelay=100, f orwardStep=1):15 def __init__(self, source, frameDelay=100, frameStep=1): 16 16 """The source parameter is assumed to be a NetCDF sww file. 17 17 The frameDelay parameter is the number of milliseconds waited between frames. … … 23 23 self.maxFrameNumber = fin.variables['time'].shape[0] - 1 24 24 fin.close() 25 26 #self.frameNumberTkVariable = StringVar() 27 #self.frameNumberTkVariable.set('Frame - %05g'%self.framNumber) 25 28 26 29 self.frameDelay = frameDelay … … 33 36 self.zmax = None 34 37 35 self.f orwardStep= forwardStep38 self.frameStep= frameStep 36 39 37 40 self.vtk_heightQuantityCache = [] … … 55 58 polydata = self.vtk_polyData[quantityName] = vtkPolyData() 56 59 if dynamic is True: 57 print ' - Frame',self.frameNumber,'of',self.maxFrameNumber60 #print ' - Frame',self.frameNumber,'of',self.maxFrameNumber 58 61 if not self.vtk_heightQuantityCache[self.frameNumber].has_key(quantityName): 59 62 self.vtk_heightQuantityCache[self.frameNumber][quantityName]\ … … 128 131 def setup_gui(self): 129 132 Visualiser.setup_gui(self) 130 self.tk_quit.grid(row=0, column=0, columnspan=7, sticky=W+E) 131 self.tk_restart = Button(self.tk_controlFrame, text="<<<", command=self.restart) 133 self.tk_quit.grid(row=0, column=0, sticky=W+E) 134 self.tk_movie_toggle = Button(self.tk_controlFrame, text="Movie off", command=self.movie_toggle) 135 self.tk_movie_toggle.grid(row=0, column=6, sticky=W+E) 136 137 138 self.tk_restart = Button(self.tk_controlFrame, text="<<<", command=self.restart, width=5) 132 139 self.tk_restart.grid(row=1, column=0, sticky=W+E) 133 self.tk_back10 = Button(self.tk_controlFrame, text="<<", command=self.back10 )140 self.tk_back10 = Button(self.tk_controlFrame, text="<<", command=self.back10, width=5) 134 141 self.tk_back10.grid(row=1, column=1, sticky=W+E) 135 self.tk_back = Button(self.tk_controlFrame, text="<", command=self.back )142 self.tk_back = Button(self.tk_controlFrame, text="<", command=self.back, width=5) 136 143 self.tk_back.grid(row=1, column=2, sticky=W+E) 137 144 self.tk_pauseResume = Button(self.tk_controlFrame, text="Pause", command=self.pauseResume, width=15) 138 145 self.tk_pauseResume.grid(row=1, column=3, sticky=W+E) 139 self.tk_forward = Button(self.tk_controlFrame, text=">", command=self.forward )146 self.tk_forward = Button(self.tk_controlFrame, text=">", command=self.forward, width=5) 140 147 self.tk_forward.grid(row=1, column=4, sticky=W+E) 141 self.tk_forward10 = Button(self.tk_controlFrame, text=">>", command=self.forward10 )148 self.tk_forward10 = Button(self.tk_controlFrame, text=">>", command=self.forward10, width=5) 142 149 self.tk_forward10.grid(row=1, column=5, sticky=W+E) 143 self.tk_movie_toggle = Button(self.tk_controlFrame, text="Movie off", command=self.movie_toggle) 144 self.tk_movie_toggle.grid(row=1, column=6, sticky=W+E) 145 150 self.tk_forwardEnd = Button(self.tk_controlFrame, text=">>>", command=self.forwardEnd, width=5) 151 self.tk_forwardEnd.grid(row=1, column=6, sticky=W+E) 152 153 154 self.tk_frameNumber = Label(self.tk_controlFrame, text='Frame') 155 self.tk_frameNumber.grid(row=2, column=0, sticky=W+E) 156 self.tk_gotoFrame = Scale(self.tk_controlFrame, from_=0, to=self.maxFrameNumber, orient=HORIZONTAL) 157 self.tk_gotoFrame.grid(row=2, column=1, columnspan=2, sticky=W+E) 158 self.tk_stepLabel = Label(self.tk_controlFrame, text='Step') 159 self.tk_stepLabel.grid(row=2, column=4, sticky=W+E) 160 self.tk_frameStep = Scale(self.tk_controlFrame, from_=0, to=self.maxFrameNumber, orient=HORIZONTAL) 161 self.tk_frameStep.grid(row=2, column=5, columnspan=2, sticky=W+E) 162 146 163 # Make the buttons stretch to fill all available space 147 164 for i in range(7): … … 155 172 self.frameNumber = 0 156 173 self.redraw_quantities() 174 self.update_labels() 157 175 self.pause() 158 176 159 177 if self.movie: 160 178 self.save_image() 161 179 180 def forwardEnd(self): 181 self.frameNumber = self.maxFrameNumber 182 self.redraw_quantities() 183 self.update_labels() 184 self.pause() 185 162 186 def movie_toggle(self): 163 187 if self.movie == True: … … 208 232 self.frameNumber = 0 209 233 self.redraw_quantities() 234 self.update_labels() 210 235 self.pause() 211 236 … … 214 239 self.frameNumber -= 1 215 240 self.redraw_quantities() 241 self.update_labels() 216 242 self.pause() 217 243 … … 229 255 self.paused = False 230 256 self.tk_pauseResume.config(text="Pause") 257 self.frameNumber = self.tk_gotoFrame.get() 258 self.frameStep = self.tk_frameStep.get() 231 259 self.tk_root.after(self.frameDelay, self.animateForward) 232 260 … … 235 263 self.frameNumber += 1 236 264 self.redraw_quantities() 265 self.update_labels() 237 266 self.pause() 238 267 239 268 def forward_step(self): 240 if self.frameNumber + self.f orwardStep <= self.maxFrameNumber:241 self.frameNumber += self.f orwardStep269 if self.frameNumber + self.frameStep <= self.maxFrameNumber: 270 self.frameNumber += self.frameStep 242 271 self.redraw_quantities() 272 self.update_labels() 243 273 else: 244 274 self.frameNumber = self.maxFrameNumber 245 275 self.redraw_quantities() 276 self.update_labels() 246 277 self.pause() 247 278 … … 256 287 self.frameNumber = self.maxFrameNumber 257 288 self.redraw_quantities() 289 self.update_labels() 258 290 self.pause() 259 291 … … 262 294 self.forward_step() 263 295 self.tk_root.after(self.frameDelay, self.animateForward) 296 297 def update_labels(self): 298 #self.tk_frameNumber.config(text='%05g of %05g'%(self.frameNumber,self.maxFrameNumber)) 299 self.tk_gotoFrame.set(self.frameNumber) 300 self.tk_frameStep.set(self.frameStep) 301 302 def shutdown(self): 303 #self.pause() 304 self.tk_root.withdraw() 305 self.tk_root.destroy() 306 #Visualiser.shutdown(self)
Note: See TracChangeset
for help on using the changeset viewer.