Changeset 3958
- Timestamp:
- Nov 9, 2006, 1:07:13 PM (18 years ago)
- Location:
- anuga_core/source
- Files:
-
- 5 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/examples/sww_file_visualiser_example.py
r3873 r3958 11 11 12 12 # The argument to OfflineVisualiser is the path to a sww file 13 o = OfflineVisualiser("../../ swollen_viewer/tests/cylinders.sww")13 o = OfflineVisualiser("../../anuga_viewer/tests/cylinders.sww") 14 14 #o = OfflineVisualiser("../../../../anuga_validation/analytical solutions/circular_second_order.sww") 15 15 -
anuga_core/source/anuga/examples/visualise_rectangle.py
r3918 r3958 33 33 return self.h0 + self.h*((x>self.x0)&(x<self.x1)&(y>self.y0)&(y<self.y1)) 34 34 35 M = 1035 M = 20 36 36 points, vertices, boundary = rectangular(M, M, len1 = 1.0, len2 = 1.0) 37 37 … … 79 79 R = Reflective_boundary(domain) 80 80 domain.set_boundary( {'left': R, 'right': R, 'bottom': R, 'top': R} ) 81 domain.set_quantity('stage', Set_Stage(0.2, 0.4, 0.25, 0.75, 1.0, 0.00))81 domain.set_quantity('stage', Set_Stage(0.2, 0.4, 0.25, 0.75, 2.0, 0.00)) 82 82 83 83 #----------------------------------------------------------------- -
anuga_core/source/anuga/visualiser/realtime.py
r3918 r3958 45 45 def setup_grid(self): 46 46 self.vtk_cells = vtkCellArray() 47 triangles = self.source.triangles 48 N_tri = self.source.number_of_triangles 49 verticies = self.source.get_vertex_coordinates() 50 N_vert = len(verticies) 47 51 # Also build vert_index - a list of the x & y values of each vertex 48 N_vert = len(self.source.vertex_coordinates)49 52 self.vert_index = zeros((N_vert,2), Float) 50 for n in range(N_ vert):53 for n in range(N_tri): 51 54 self.vtk_cells.InsertNextCell(3) 52 55 for v in range(3): 53 self.vert_index[ self.source.triangles[n][v]] = self.source.vertex_coordinates[n][v*2:v*2+2]54 self.vtk_cells.InsertCellPoint( self.source.triangles[n][v])56 self.vert_index[triangles[n][v]] = verticies[n * 3 + v] 57 self.vtk_cells.InsertCellPoint(triangles[n][v]) 55 58 56 59 def update_height_quantity(self, quantityName, dynamic=True): … … 118 121 119 122 def redraw(self): 120 print "Calling redraw"121 123 if self.running and self.sync_unpaused.isSet(): 122 124 self.sync_redrawReady.wait() -
anuga_core/source/anuga/visualiser/visualiser-tvtk.py
r3906 r3958 30 30 self.vtk_polyData = {} 31 31 32 # A function queue to ensure all the visualiser configuration is done in the visualiser thread. 33 # The queue will contain zero or more functions, with the arguments to that function immediately following 34 # as a tuple. 35 self.sync_configFuncs = Queue(-1) 32 # A list of operations to be performed on the cube axes. Type: [(func, (args))] 33 self.conf_axesAlterations = [] 34 # A list of all polygons to overlay. Type: [([coords], height, (colour)] 35 self.conf_overlaidPolygons = [] 36 # A list of alterations to be performed on the Tk root. Type: [(func, (args))] 37 self.conf_tkAlterations = [] 36 38 37 39 def run(self): … … 40 42 self.setup_grid() 41 43 42 # Normally, empty() is not reliable, however all configuration is done 43 # before the visualiser is started and nothing is added to the queue after that. 44 while not self.sync_configFuncs.empty(): 45 func = self.sync_configFuncs.get(True) 46 args = self.sync_configFuncs.get(True) 47 func(*args) 44 # Handle any deferred configuration 45 # Overlaid polygons 46 for args in self.conf_overlaidPolygons: 47 self.overlay_polygon_internal(*args) 48 # Draw (and maybe alter) the axes 49 if self.vtk_drawAxes: 50 self.vtk_axes = vtkCubeAxesActor2D() 51 # Perform all of the alterations required, by applying func to the vtk_axes instance (with the given args). 52 for func, args in self.conf_axesAlterations: 53 func(*((self.vtk_axes,) + args)) 54 # Alter the Tk root as necessary. 55 for func, args in self.conf_tkAlterations: 56 func(*((self.tk_root,) + args)) 57 # Finished with deferred configuration. 48 58 49 59 # Draw Height Quantities … … 51 61 self.update_height_quantity(q, self.height_dynamic[q]) 52 62 self.draw_height_quantity(q) 53 54 if self.vtk_drawAxes is True:55 self.tk_root.after(1, self.draw_axes)56 63 57 64 self.tk_root.mainloop() 58 65 59 def redraw_quantities(self , dynamic_only=False):66 def redraw_quantities(self): 60 67 """Redraw all dynamic quantities. 61 68 """ … … 73 80 """Intstruct the visualiser to render cube axes around the render. 74 81 """ 75 self.sync_configFuncs.put(self._render_axes, True)76 self.sync_configFuncs.put(())77 78 def _render_axes(self):79 """Add the axes to the visualiser.80 """81 82 self.vtk_drawAxes = True 82 self.vtk_axes = vtkCubeAxesActor2D()83 83 84 84 def draw_axes(self): … … 90 90 self.vtk_axes.SetCamera(self.vtk_renderer.GetActiveCamera()) 91 91 self.vtk_renderer.AddActor(self.vtk_axes) 92 self.vtk_renderer.ResetCamera(self.get_3d_bounds()) 92 93 93 94 def alter_axes(self, func, args): … … 100 101 alter_axes(vtkCubeAxesActor2D.SetNumberOfPoints, (5,)) 101 102 """ 102 self.sync_configFuncs.put(self._alter_axes, True) 103 self.sync_configFuncs.put((func,)+args, True) 104 105 def _alter_axes(self, func, *args): 106 """Apply func, with args *args to the axes actor. This function should be called from 107 within the visualiser thread after the axes have been initialised. 108 """ 109 func(*((self.vtk_axes,) + args)) 103 self.conf_axesAlterations.append((func, args)) 110 104 111 105 # --- Height Based Rendering --- # … … 218 212 colour is the colour of the polygon, as a 3-tuple representing 219 213 r, g, b values between 0 and 1.""" 220 self.sync_configFuncs.put(self._overlay_polygon, True) 221 self.sync_configFuncs.put((coords, height, colour), True) 222 223 def _overlay_polygon(self, coords, height, colour): 214 self.conf_overlaidPolygons.append((coords, height, colour)) 215 216 def overlay_polygon_internal(self, coords, height, colour): 224 217 """Add a polygon to the output of the visualiser. 225 218 … … 276 269 """Apply func, with arguments tuple args to the root tk window for this visualiser. 277 270 """ 278 self.sync_configFuncs.put(self._alter_tkroot, True) 279 self.sync_configFuncs.put((func,)+args, True) 280 281 def _alter_tkroot(self, func, *args): 282 """Apply func, with arguments tuple args to the root tk window for this visualiser. 283 This function should only be called from within the visualiser after the tk root window 284 has been created. 285 """ 286 func(*((self.tk_root,) + args)) 271 self.conf_tkAlterations.append((func, args)) 287 272 288 273 # --- GUI Events --- # -
anuga_core/source/anuga/visualiser/visualiser.py
r3873 r3958 30 30 self.vtk_polyData = {} 31 31 32 # A function queue to ensure all the visualiser configuration is done in the visualiser thread. 33 # The queue will contain zero or more functions, with the arguments to that function immediately following 34 # as a tuple. 35 self.sync_configFuncs = Queue(-1) 32 # A list of operations to be performed on the cube axes. Type: [(func, (args))] 33 self.conf_axesAlterations = [] 34 # A list of all polygons to overlay. Type: [([coords], height, (colour)] 35 self.conf_overlaidPolygons = [] 36 # A list of alterations to be performed on the Tk root. Type: [(func, (args))] 37 self.conf_tkAlterations = [] 36 38 37 39 def run(self): … … 40 42 self.setup_grid() 41 43 42 # Normally, empty() is not reliable, however all configuration is done 43 # before the visualiser is started and nothing is added to the queue after that. 44 while not self.sync_configFuncs.empty(): 45 func = self.sync_configFuncs.get(True) 46 args = self.sync_configFuncs.get(True) 47 func(*args) 44 # Handle any deferred configuration 45 # Overlaid polygons 46 for args in self.conf_overlaidPolygons: 47 self.overlay_polygon_internal(*args) 48 # Draw (and maybe alter) the axes 49 if self.vtk_drawAxes: 50 self.vtk_axes = vtkCubeAxesActor2D() 51 # Perform all of the alterations required, by applying func to the vtk_axes instance (with the given args). 52 for func, args in self.conf_axesAlterations: 53 func(*((self.vtk_axes,) + args)) 54 # Alter the Tk root as necessary. 55 for func, args in self.conf_tkAlterations: 56 func(*((self.tk_root,) + args)) 57 # Finished with deferred configuration. 48 58 49 59 # Draw Height Quantities … … 51 61 self.update_height_quantity(q, self.height_dynamic[q]) 52 62 self.draw_height_quantity(q) 53 54 if self.vtk_drawAxes is True:55 self.tk_root.after(1, self.draw_axes)56 63 57 64 self.tk_root.mainloop() 58 65 59 def redraw_quantities(self , dynamic_only=False):66 def redraw_quantities(self): 60 67 """Redraw all dynamic quantities. 61 68 """ … … 73 80 """Intstruct the visualiser to render cube axes around the render. 74 81 """ 75 self.sync_configFuncs.put(self._render_axes, True)76 self.sync_configFuncs.put(())77 78 def _render_axes(self):79 """Add the axes to the visualiser.80 """81 82 self.vtk_drawAxes = True 82 self.vtk_axes = vtkCubeAxesActor2D()83 83 84 84 def draw_axes(self): … … 90 90 self.vtk_axes.SetCamera(self.vtk_renderer.GetActiveCamera()) 91 91 self.vtk_renderer.AddActor(self.vtk_axes) 92 self.vtk_renderer.ResetCamera(self.get_3d_bounds()) 92 93 93 94 def alter_axes(self, func, args): … … 100 101 alter_axes(vtkCubeAxesActor2D.SetNumberOfPoints, (5,)) 101 102 """ 102 self.sync_configFuncs.put(self._alter_axes, True) 103 self.sync_configFuncs.put((func,)+args, True) 104 105 def _alter_axes(self, func, *args): 106 """Apply func, with args *args to the axes actor. This function should be called from 107 within the visualiser thread after the axes have been initialised. 108 """ 109 func(*((self.vtk_axes,) + args)) 103 self.conf_axesAlterations.append((func, args)) 110 104 111 105 # --- Height Based Rendering --- # … … 218 212 colour is the colour of the polygon, as a 3-tuple representing 219 213 r, g, b values between 0 and 1.""" 220 self.sync_configFuncs.put(self._overlay_polygon, True) 221 self.sync_configFuncs.put((coords, height, colour), True) 222 223 def _overlay_polygon(self, coords, height, colour): 214 self.conf_overlaidPolygons.append((coords, height, colour)) 215 216 def overlay_polygon_internal(self, coords, height, colour): 224 217 """Add a polygon to the output of the visualiser. 225 218 … … 276 269 """Apply func, with arguments tuple args to the root tk window for this visualiser. 277 270 """ 278 self.sync_configFuncs.put(self._alter_tkroot, True) 279 self.sync_configFuncs.put((func,)+args, True) 280 281 def _alter_tkroot(self, func, *args): 282 """Apply func, with arguments tuple args to the root tk window for this visualiser. 283 This function should only be called from within the visualiser after the tk root window 284 has been created. 285 """ 286 func(*((self.tk_root,) + args)) 271 self.conf_tkAlterations.append((func, args)) 287 272 288 273 # --- GUI Events --- #
Note: See TracChangeset
for help on using the changeset viewer.