Ignore:
Timestamp:
Oct 26, 2006, 1:02:41 PM (18 years ago)
Author:
jack
Message:

Fixed the visualiser to actually run properly in its own thread.

Added a simple example to use the realtime visualiser.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/visualiser/offline.py

    r3670 r3873  
    11from Numeric import array, Float, ravel, zeros
    22from Scientific.IO.NetCDF import NetCDFFile
    3 from Tkinter import Button, E, W
     3from Tkinter import Button, E, Tk, W
    44from visualiser import Visualiser
    55from vtk import vtkCellArray, vtkPoints, vtkPolyData
     
    1313    structures for any dynamic height based quantities to render.
    1414    """
    15     def __init__(self, source):
     15    def __init__(self, source, frameDelay=100):
    1616        """The source parameter is assumed to be a NetCDF sww file.
     17        The frameDelay parameter is the number of milliseconds waited between frames.
    1718        """
    1819        Visualiser.__init__(self, source)
     
    2223        self.maxFrameNumber = fin.variables['time'].shape[0] - 1
    2324        fin.close()
     25
     26        self.frameDelay = frameDelay
    2427
    2528        self.xmin = None
     
    140143
    141144    def run(self):
    142         self.tk_root.after(100, self.animateForward)
     145        self.alter_tkroot(Tk.after, (self.frameDelay, self.animateForward))
    143146        Visualiser.run(self)
    144147
    145148    def restart(self):
    146149        self.frameNumber = 0
    147         self.redraw_quantities(True)
     150        self.redraw_quantities()
    148151        self.pause()
    149152
     
    153156        else:
    154157            self.frameNumber = 0
    155         self.redraw_quantities(True)
     158        self.redraw_quantities()
    156159        self.pause()
    157160
     
    159162        if self.frameNumber > 0:
    160163            self.frameNumber -= 1
    161             self.redraw_quantities(True)
     164            self.redraw_quantities()
    162165            self.pause()
    163166
     
    175178        self.paused = False
    176179        self.tk_pauseResume.config(text="Pause")
    177         self.tk_root.after(100, self.animateForward)
     180        self.tk_root.after(self.frameDelay, self.animateForward)
    178181
    179182    def forward(self):
     
    184187        if self.frameNumber < self.maxFrameNumber:
    185188            self.frameNumber += 1
    186             self.redraw_quantities(True)
     189            self.redraw_quantities()
    187190        else:
    188191            self.pause()
     
    193196        else:
    194197            self.frameNumber = self.maxFrameNumber
    195         self.redraw_quantities(True)
     198        self.redraw_quantities()
    196199        self.pause()
    197200
     
    199202        if self.paused is not True:
    200203            self.forward_step()
    201             self.tk_root.after(100, self.animateForward)
     204            self.tk_root.after(self.frameDelay, self.animateForward)
Note: See TracChangeset for help on using the changeset viewer.