source: anuga_core/source/anuga/visualiser_new/sww_visualiser.py @ 4605

Last change on this file since 4605 was 4365, checked in by jack, 18 years ago

More work on the traited visualiser. Not working yet.

File size: 1.7 KB
Line 
1from enthought.traits.api import Int, String
2from Scientific.IO.NetCDF import NetCDFFile
3from Tkinter import Label, Scale, W, E, HORIZONTAL
4from visualiser import Visualiser
5
6class SWWVisualiser(Visualiser):
7    '''A Visualiser that views SWW files. The source for this
8    visualiser is a string containing the sww file name.
9    '''
10    source = String
11    frameDelay = Int(100)
12    frameStep = Int(1)
13
14    def __init__(self, *args, **kwargs):
15        Visualiser.__init__(self, *args, **kwargs)
16
17        fin = NetCDFFile(self.source, 'r')
18        self.frame = 0
19        self.maxFrame = fin.variables['time'].shape[0] - 1
20        self.paused = False
21        self.heightFeatureCache = []
22        for i in range(self.maxFrame + 1): # Zero indexed
23            self.heightFeatureCache.append({})
24
25    def setup_grid(self):
26        fin = NetCDFFile(self.source, 'r')
27        N_tri = fin.variables['volumes'].shape[0]
28        for v in range(N_tri):
29            self.vtk_cells.InsertNextCell(3)
30            for i in range(3):
31                self.vtk_cells.InsertCellPoint(fin.variables['volumes'][v][i])
32        fin.close()
33       
34    def setup_gui(self):
35        Visualiser.setup_gui(self)
36
37        Label(self.tk_customControlFrame, text='Frame').grid(row=0, column=0, sticky=W+E)
38        self.tk_frame = Scale(self.tk_customControlFrame, from_=0, to=self.maxFrame, orient=HORIZONTAL)
39        self.tk_frame.grid(row=0, column=1, sticky=W+E)
40        Label(self.tk_customControlFrame, text='Step').grid(row=0, column=2, sticky=W+E)
41        self.tk_frameStep = Scale(self.tk_customControlFrame, from_=0, to=self.maxFrame, orient=HORIZONTAL)
42        self.tk_frameStep.grid(row=0, column=3, sticky=W+E)
43       
Note: See TracBrowser for help on using the repository browser.