1 |
""" |
2 |
@author: John NGUI |
3 |
""" |
4 |
|
5 |
import vtk |
6 |
from mapper import DataSetMapper |
7 |
from actor import Actor3D |
8 |
from constant import Viewport |
9 |
from texture import Texture |
10 |
from plane import PlaneSource |
11 |
|
12 |
# NOTE: DataSetMapper, Actor3D, Texture and PlaneSource were inherited to |
13 |
# allow access to their public methods from the driver. |
14 |
class Image(DataSetMapper, Actor3D, Texture, PlaneSource): |
15 |
""" |
16 |
Class that displays an image with interaction capability. |
17 |
""" |
18 |
|
19 |
# The SOUTH_WEST default viewport is used when there is only one viewport. |
20 |
# This saves the user from specifying the viewport when there is only one. |
21 |
def __init__(self, scene, image_reader, viewport = Viewport.SOUTH_WEST): |
22 |
""" |
23 |
@type scene: L{Scene <scene.Scene>} object |
24 |
@param scene: Scene in which objects are to be rendered on |
25 |
@type image_reader: L{ImageReader <datacollector.ImageReader>} |
26 |
object |
27 |
@param image_reader: Deal with source of image for visualisation |
28 |
@type viewport: L{Viewport <constant.Viewport>} constant |
29 |
@param viewport: Viewport in which objects are to be rendered on |
30 |
""" |
31 |
|
32 |
# ----- Image ----- |
33 |
|
34 |
Texture.__init__(self, image_reader._getOutput()) |
35 |
PlaneSource.__init__(self) |
36 |
|
37 |
DataSetMapper.__init__(self, PlaneSource._getOutput(self)) |
38 |
|
39 |
Actor3D.__init__(self, DataSetMapper._getDataSetMapper(self)) |
40 |
Actor3D._setTexture(self, Texture._getTexture(self)) |
41 |
|
42 |
scene._addActor3D(viewport, Actor3D._getActor3D(self)) |
43 |
|