Changeset 3448


Ignore:
Timestamp:
Aug 3, 2006, 2:58:25 PM (19 years ago)
Author:
jack
Message:

Decoupled the VTK visualiser from the shallow water domain. Example available in netherlands.py

Location:
inundation/pyvolution
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • inundation/pyvolution/netherlands.py

    r2813 r3448  
    1212#rpdb.set_active()
    1313
    14 from shallow_water_vtk import Domain, Reflective_boundary, Dirichlet_boundary,\
     14from shallow_water import Domain, Reflective_boundary, Dirichlet_boundary,\
    1515     Transmissive_boundary, Constant_height, Constant_stage
    1616
    1717from mesh_factory import rectangular_cross
    1818from Numeric import array
    19 
     19from vtk_realtime_visualiser import Visualiser
    2020
    2121class Weir:
     
    121121    domain.filename, _ = os.path.splitext(base)
    122122else:
    123     domain.initialise_visualiser(rect=[0.0,0.0,1.0,1.0])
     123    #domain.initialise_visualiser(rect=[0.0,0.0,1.0,1.0])
    124124    #domain.initialise_visualiser()
    125125    #domain.visualiser.coloring['stage'] = False
     
    127127    domain.checkpoint = False
    128128    domain.store = False
    129 
     129    vis = Visualiser(domain)
     130    vis.setup['elevation'] = True
     131    vis.updating['stage'] = True
     132    vis.qcolor['stage'] = (0.0,0.0,0.8)
    130133
    131134
     
    174177    domain.write_time()
    175178    #domain.write_boundary()
    176 
     179    vis.update()
    177180    print domain.quantities['stage'].get_values(location='centroids',
    178181                                                indices=[0])
     
    188191
    189192print 'That took %.2f seconds' %(time.time()-t0)
     193vis.shutdown()
  • inundation/pyvolution/vtk_realtime_visualiser.py

    r2421 r3448  
    3636    """
    3737
    38     def __init__(self, domain, default_scale_z=1.0, rect=None, title='Test'):
     38    def __init__(self, domain, default_scale_z=1.0, title='Test'):
    3939        threading.Thread.__init__(self)
    4040        # Initialise data structures. setup and updating are maps
     
    5151        self.vertices = domain.vertex_coordinates
    5252       
    53 
    54 
    55 
    5653        self.idle = threading.Event()
    5754        self.redraw_ready = threading.Event()
     
    6663        self.mappers = {}
    6764
     65        self.running = True
     66
    6867        # Default options
    6968        for x in self.domain.quantities:
    7069            self.setup[x] = False
    7170            self.updating[x] = False
    72 
    73         # Bounding box.
    74         if rect is None:
    75             self.max_x = max(max(self.vertices[:,0]),max(self.vertices[:,2]),max(self.vertices[:,4]))
    76             self.min_x = min(min(self.vertices[:,0]),min(self.vertices[:,2]),min(self.vertices[:,4]))
    77             self.max_y = max(max(self.vertices[:,1]),max(self.vertices[:,3]),max(self.vertices[:,5]))
    78             self.min_y = min(min(self.vertices[:,1]),min(self.vertices[:,3]),min(self.vertices[:,5]))
    79         else:
    80             self.max_x = rect[2]
    81             self.min_x = rect[0]
    82             self.max_y = rect[3]
    83             self.min_y = rect[1]
    84 
    85         self.range_x = self.max_x - self.min_x
    86         self.range_y = self.max_y - self.min_y
    87         self.range_xy = max(self.range_x, self.range_y)
    88 
     71            self.coloring[x] = False
     72        self.start()
     73           
    8974    def run(self):
    9075        self.initialise_gui()
     
    129114
    130115    def add_axes(self):
    131         """Add axes to this Visualiser
     116        """Add axes to this Visualiser - TODO
    132117        """
    133118        pass
     
    239224
    240225            self.renderWindow.Render()
    241            
    242            
    243            
     226             
    244227            self.root.update_idletasks()
    245228            self.idle.set()
     
    247230   
    248231    def shutdown(self):
    249         self.domain.visualise = False
     232        """Shutdown the visualiser
     233        """
     234        self.running = False
    250235        self.idle.set()
    251236        self.unpaused.set()
    252237        self.root.withdraw()
    253238        self.root.quit()
     239
     240    def update(self):
     241        """Update the visualiser's display.
     242        Clients are expected to call this in their evolve() loop,
     243        to keep the visualiser in sync with the simulation.
     244        """
     245        if self.running:
     246            self.redraw_ready.set()
     247            self.idle.wait()
     248            self.idle.clear()
     249            self.unpaused.wait()
Note: See TracChangeset for help on using the changeset viewer.