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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1381 - (show annotations)
Wed Jan 9 07:59:15 2008 UTC (11 years, 11 months ago) by gross
File MIME type: text/x-python
File size: 2230 byte(s)
import sys missing
1 from esys.pyvisi import DataCollector, Scene, Map, Rectangle
2 from esys.pyvisi import GlobalPosition
3 from esys.pyvisi.constant import *
4 import unittest, os, sys
5 from stat import ST_SIZE
6
7 try:
8 PYVISI_WORKDIR=os.environ['PYVISI_WORKDIR']
9 except KeyError:
10 PYVISI_WORKDIR='.'
11 try:
12 PYVISI_TEST_DATA_ROOT=os.environ['PYVISI_TEST_DATA_ROOT']
13 except KeyError:
14 PYVISI_TEST_DATA_ROOT='.'
15
16 PYVISI_TEST_MESHES_PATH = os.path.join(PYVISI_TEST_DATA_ROOT, "data_meshes")
17 PYVISI_TEST_IMAGE_IMAGES_PATH = os.path.join(PYVISI_WORKDIR, \
18 "data_sample_images", "rectangle")
19
20 MIN_IMAGE_SIZE = 100
21 FILE_3D = "interior_3D.xml"
22 X_SIZE = 400
23 Y_SIZE = 400
24 JPG_RENDERER = Renderer.OFFLINE_JPG
25
26 class TestRectangle:
27 def render(self, file):
28 self.scene.render(image_name = \
29 os.path.join(PYVISI_TEST_IMAGE_IMAGES_PATH, file))
30
31 self.failUnless(os.stat(os.path.join(PYVISI_TEST_IMAGE_IMAGES_PATH, \
32 file))[ST_SIZE] > MIN_IMAGE_SIZE)
33
34 class TestRectangleOnAMap(unittest.TestCase, TestRectangle):
35 def setUp(self):
36 self.scene = \
37 Scene(renderer = JPG_RENDERER, num_viewport = 1,
38 x_size = X_SIZE, y_size = Y_SIZE)
39
40 self.data_collector = DataCollector(source = Source.XML)
41 self.data_collector.setFileName(file_name = \
42 os.path.join(PYVISI_TEST_MESHES_PATH, FILE_3D))
43
44 self.map = Map(scene = self.scene,
45 data_collector = self.data_collector,
46 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR,
47 cell_to_point = False, outline = True)
48 self.map.setOpacity(0.2)
49
50 self.rectangle = Rectangle(scene = self.scene, viewport = Viewport.SOUTH_WEST)
51
52 def tearDown(self):
53 del self.scene
54 del self.data_collector
55 del self.map
56 del self.rectangle
57
58 def testRectangle(self):
59 self.rectangle.setCenter(GlobalPosition(1.5,2,0.8))
60 self.rectangle.setXLength(2.5)
61 self.rectangle.setYLength(1)
62 self.rectangle.setZLength(0.3)
63 self.rectangle.setColor(Color.GREY)
64
65 self.render("TestRectangle.jpg")
66
67
68 ###############################################################################
69
70
71 if __name__ == '__main__':
72 suite = unittest.TestSuite()
73 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestRectangleOnAMap))
74 s=unittest.TextTestRunner(verbosity=2).run(suite)
75 if not s.wasSuccessful(): sys.exit(1)

  ViewVC Help
Powered by ViewVC 1.1.26