1 |
""" |
""" |
2 |
class that shows a vector field by arrows |
@author: John Ngui |
3 |
|
@author: Lutz Gross |
|
@var __author__: name of author |
|
|
@var __license__: licence agreement |
|
|
@var __copyright__: copyrights |
|
|
@var __url__: url entry point on documentation |
|
|
@var __version__: version |
|
|
@var __date__: date of the version |
|
4 |
""" |
""" |
5 |
__copyright__=""" Copyright (c) 2006 by ACcESS MNRF |
|
6 |
http://www.access.edu.au |
import vtk |
7 |
Primary Business: Queensland, Australia""" |
from common import Common |
8 |
__license__="""Licensed under the Open Software License version 3.0 |
|
9 |
http://www.opensource.org/licenses/osl-3.0.php""" |
class Arrows(Common): |
10 |
__author__="Paul Cochrane, L. Gross" |
""" |
11 |
__url__="http://www.iservo.edu.au/esys" |
Class that shows a vector field by arrows. |
12 |
__version__="$Revision:$" |
""" |
13 |
__date__="$Date:$" |
|
14 |
|
def __init__(self, scene, data_collector, lut = None): |
15 |
from common import Component |
""" |
16 |
|
@type scene: L{Scene <scene.Scene>} object |
17 |
class Arrows(Component): |
@param scene: Scene in which components are to be added to |
18 |
""" |
@type data_collector: L{DataCollector <datacollector.DataCollector>} |
19 |
shows a vector field by arrows |
object |
20 |
""" |
@param data_collector: Source of data for visualization |
21 |
pass |
@type lut: L{BlueToRed <colormap.BlueToRed>} or |
22 |
|
L{RedToBlue <colormap.RedToBlue>} object |
23 |
class ArrowsOnPlane(Component): |
@param lut: Lookup table to be used by the mapper |
24 |
""" |
""" |
25 |
shows a vector field by arrows on a plane |
|
26 |
""" |
Common.__init__(self, scene, data_collector) |
27 |
pass |
self.vtk_glyph = vtk.vtkGlyph3D() |
28 |
|
self.setArrows() |
29 |
|
|
30 |
|
Common.setMapperInput(self, self.vtk_glyph.GetOutput(), lut) |
31 |
|
Common.setActorInput(self) |
32 |
|
Common.addActor(self) |
33 |
|
|
34 |
|
def setArrows(self): |
35 |
|
""" |
36 |
|
Set up the glyph and use arrows as the source. |
37 |
|
""" |
38 |
|
|
39 |
|
vtk_arrows = vtk.vtkArrowSource() |
40 |
|
|
41 |
|
self.vtk_glyph.SetInput(self.data_collector.getReader().GetOutput()) |
42 |
|
self.vtk_glyph.SetSource(vtk_arrows.GetOutput()) |
43 |
|
# Default vector mode is vector. |
44 |
|
self.setVectorMode("Vector") |
45 |
|
# Default scale mode is vector. |
46 |
|
self.setScaleMode("Vector") |
47 |
|
# Default color mode is scalar. |
48 |
|
self.setColorMode("Scalar") |
49 |
|
self.setScaleFactor(0.2) |
50 |
|
|
51 |
|
def setVectorMode(self, vector_mode): |
52 |
|
""" |
53 |
|
Set the arrows vector mode. |
54 |
|
@type vector_mode: String |
55 |
|
@param vector_mode: Arrows vector mode |
56 |
|
""" |
57 |
|
|
58 |
|
eval("self.vtk_glyph.SetVectorModeToUse%s" % vector_mode) |
59 |
|
|
60 |
|
def setScaleMode(self, scale_mode): |
61 |
|
""" |
62 |
|
Set the arrows scale mode. |
63 |
|
@type scale_mode: String |
64 |
|
@param scale_mode: Arrows scale mode |
65 |
|
""" |
66 |
|
|
67 |
|
eval("self.vtk_glyph.SetScaleModeToScaleBy%s" % scale_mode) |
68 |
|
|
69 |
|
def setScaleFactor(self, scale_factor): |
70 |
|
""" |
71 |
|
Set the arrows scale factor. |
72 |
|
@type scale_factor: Number |
73 |
|
@param scale_factor: Size of the arrows |
74 |
|
""" |
75 |
|
|
76 |
|
self.vtk_glyph.SetScaleFactor(scale_factor) |
77 |
|
|
78 |
|
def setColorMode(self, color_mode): |
79 |
|
""" |
80 |
|
Set the arrows color mode. |
81 |
|
@type color_mode: String |
82 |
|
@param color_mode: Arrows color mode |
83 |
|
""" |
84 |
|
|
85 |
|
eval("self.vtk_glyph.SetColorModeToColorBy%s()" % color_mode) |
86 |
|
|
87 |
|
|
88 |
|
from arrows import Arrows |
89 |
|
from plane import Plane |
90 |
|
|
91 |
|
class ArrowsOnPlane(Arrows, Plane): |
92 |
|
""" |
93 |
|
Class that shows a vector field by arrows on a given plane. |
94 |
|
""" |
95 |
|
|
96 |
|
def __init__(self, scene, data_collector, transform, lut = None): |
97 |
|
""" |
98 |
|
@type scene: L{Scene <scene.Scene>} object |
99 |
|
@param scene: Scene in which components are to be added to |
100 |
|
@type data_collector: L{DataCollector <datacollector.DataCollector>} |
101 |
|
object |
102 |
|
@param data_collector: Source of data for visualization |
103 |
|
@type transform: L{Transform <geo.Transform>} object |
104 |
|
@param transform: Orientation of the plane |
105 |
|
@type lut: L{BlueToRed <colormap.BlueToRed>} or |
106 |
|
L{RedToBlue <colormap.RedToBlue>} object |
107 |
|
@param lut: Lookup table to be used by the mapper |
108 |
|
""" |
109 |
|
|
110 |
|
# Declared because they are needed by the setArrows method. |
111 |
|
self.data_collector = data_collector |
112 |
|
self.vtk_glyph = vtk.vtkGlyph3D() |
113 |
|
|
114 |
|
Arrows.setArrows(self) |
115 |
|
# "Cut" is used to distinguish cutting from clipping. |
116 |
|
Plane.__init__(self, scene, data_collector, |
117 |
|
self.vtk_glyph.GetOutput(), transform, lut, "Cut") |
118 |
|
|
119 |
|
from arrows import Arrows |
120 |
|
from plane import Plane |
121 |
|
|
122 |
|
class ArrowsOnClip(Arrows, Plane): |
123 |
|
""" |
124 |
|
Class that shows a vector field by arrows on a clip. |
125 |
|
""" |
126 |
|
|
127 |
|
def __init__(self, scene, data_collector, transform, lut = None): |
128 |
|
""" |
129 |
|
@type scene: L{Scene <scene.Scene>} object |
130 |
|
@param scene: Scene in which components are to be added to |
131 |
|
@type data_collector: L{DataCollector <datacollector.DataCollector>} |
132 |
|
object |
133 |
|
@param data_collector: Source of data for visualization |
134 |
|
@type transform: L{Transform <geo.Transform>} object |
135 |
|
@param transform: Orientation of the plane |
136 |
|
@type lut: L{BlueToRed <colormap.BlueToRed>} or |
137 |
|
L{RedToBlue <colormap.RedToBlue>} object |
138 |
|
@param lut: Lookup table to be used by the mapper |
139 |
|
""" |
140 |
|
|
141 |
|
# Declared because they are needed by the setArrows method. |
142 |
|
self.data_collector = data_collector |
143 |
|
self.vtk_glyph = vtk.vtkGlyph3D() |
144 |
|
|
145 |
|
Arrows.setArrows(self) |
146 |
|
# "Clip" is used to distinguish clipping from cutting. |
147 |
|
Plane.__init__(self, scene, data_collector, |
148 |
|
self.vtk_glyph.GetOutput(), transform, lut, "Clip") |
149 |
|
|