/[escript]/trunk/pyvisi/test/python/run_image.py
ViewVC logotype

Contents of /trunk/pyvisi/test/python/run_image.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1110 - (show annotations)
Thu Apr 19 05:24:28 2007 UTC (12 years ago) by jongui
File MIME type: text/x-python
File size: 1936 byte(s)
Some test for the logo.
1 from esys.pyvisi import DataCollector, Scene, Map, Image, Image, ImageReader
2 from esys.pyvisi import GlobalPosition
3 from esys.pyvisi.constant import *
4 import unittest, os
5 from stat import ST_SIZE
6
7 PYVISI_TEST_MESHES_PATH = "data_meshes/"
8 PYVISI_TEST_IMAGE_IMAGES_PATH = "data_sample_images/image/"
9 MIN_IMAGE_SIZE = 100
10 FILE_3D = "interior_3D.xml"
11 IMAGE = "flinders.jpg"
12
13 X_SIZE = 400
14 Y_SIZE = 400
15
16 JPG_RENDERER = Renderer.OFFLINE_JPG
17
18 class TestImage:
19 def tearDown(self):
20 self.scene
21 self.data_collector
22 self.map
23 self.image
24 self.image_reader
25
26 def render(self, file):
27 self.scene.render(image_name = \
28 PYVISI_TEST_IMAGE_IMAGES_PATH + file)
29
30 self.failUnless(os.stat(PYVISI_TEST_IMAGE_IMAGES_PATH + \
31 file)[ST_SIZE] > MIN_IMAGE_SIZE)
32
33 class TestImageOnAMap(unittest.TestCase, TestImage):
34 def setUp(self):
35 self.scene = \
36 Scene(renderer = JPG_RENDERER, num_viewport = 1,
37 x_size = X_SIZE, y_size = Y_SIZE)
38
39 self.data_collector = DataCollector(source = Source.XML)
40 self.data_collector.setFileName(file_name = \
41 PYVISI_TEST_MESHES_PATH + FILE_3D)
42
43 self.map = Map(scene = self.scene,
44 data_collector = self.data_collector,
45 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR,
46 cell_to_point = False, outline = True)
47
48 self.image_reader = ImageReader(ImageFormat.JPG)
49 self.image_reader.setImageName(PYVISI_TEST_MESHES_PATH + IMAGE)
50
51 self.image = Image(scene = self.scene, image_reader = self.image_reader)
52
53 def testImage(self):
54 self.image.translate(0, 0, -1)
55 self.image.setPoint1(GlobalPosition(2, 0, 0))
56 self.image.setPoint2(GlobalPosition(0, 2, 0))
57 self.image.setOpacity(0.6)
58 self.render("TestImage.jpg")
59
60
61 ###############################################################################
62
63
64 if __name__ == '__main__':
65 suite = unittest.TestSuite()
66 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestImageOnAMap))
67 unittest.TextTestRunner(verbosity=2).run(suite)
68

  ViewVC Help
Powered by ViewVC 1.1.26