source: trunk/anuga_core/source/anuga/visualiser_new/feature.py @ 7854

Last change on this file since 7854 was 4621, checked in by jack, 17 years ago

New visualiser layout. Functionally equivalent to the old one, but much cleaner. Slightly different interface.

File size: 1.4 KB
Line 
1from types import FloatType
2from vtk import vtkActor
3class Feature:
4    def __init__(self, colour=(0.5, 0.5, 0.5), opacity=1.0, dynamic=False):
5        '''
6        Parameters:
7        colour: (float, float, float) - apply a single colour to the feature.
8        opacity: float - 1.0 is opaque, 0.0 is invisible
9        dynamic: boolean - this quantity changes with time
10        '''
11        self.actor = vtkActor()
12        self.colour = colour
13        self.drawn = False
14        self.dynamic = dynamic
15        self.opacity = opacity
16        self.inRenderer = False
17        self.visualiser = None
18       
19    def button(self, tk_component):
20        '''
21        Construct and return a Tkinter button that allows editing of
22        the feature's parameters.
23        '''
24        raise NotImplementedError('Subclasses must override Feature::button!')
25
26    def draw(self, renderer):
27        '''
28        Draw this object into the renderer, updating it if necessary.
29        '''
30        self.drawn = True
31        if not self.inRenderer:
32            self.inRenderer = True
33            if type(self.colour[0]) is FloatType:
34                self.actor.GetProperty().SetColor(self.colour)
35            renderer.AddActor(self.actor)
36        self.actor.GetProperty().SetOpacity(self.opacity)
37
38    def redraw(self, renderer):
39        '''
40        Force a redraw of this feature.
41        '''
42        self.drawn = False
43        self.draw(renderer)
Note: See TracBrowser for help on using the repository browser.