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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1199 - (show annotations)
Wed Jun 20 05:01:30 2007 UTC (12 years ago) by jongui
File MIME type: text/x-python
File size: 2728 byte(s)
- Updated the epydocs and guide.
Deleted redundant files and methods.
Tidied up the codes.
1 from esys.pyvisi import DataCollector, Scene, Contour, Legend, LocalPosition
2 from esys.pyvisi.constant import *
3 import unittest, os
4 from stat import ST_SIZE
5
6 try:
7 PYVISI_WORKDIR=os.environ['PYVISI_WORKDIR']
8 except KeyError:
9 PYVISI_WORKDIR='.'
10 try:
11 PYVISI_TEST_DATA_ROOT=os.environ['PYVISI_TEST_DATA_ROOT']
12 except KeyError:
13 PYVISI_TEST_DATA_ROOT='.'
14
15 PYVISI_TEST_MESHES_PATH = os.path.join(PYVISI_TEST_DATA_ROOT, "data_meshes")
16 PYVISI_TEST_LEGEND_IMAGES_PATH = os.path.join(PYVISI_WORKDIR, \
17 "data_sample_images", "legend")
18
19 MIN_IMAGE_SIZE = 100
20 FILE_2D = "interior_2D.xml"
21 X_SIZE = 400
22 Y_SIZE = 400
23 JPG_RENDERER = Renderer.OFFLINE_JPG
24
25 class TestLegendWithLazyEvaluation(unittest.TestCase):
26 def setUp(self):
27 self.scene = \
28 Scene(renderer = JPG_RENDERER, num_viewport = 1,
29 x_size = X_SIZE, y_size = Y_SIZE)
30
31 self.data_collector = DataCollector(source = Source.XML)
32
33 self.contour = Contour(scene = self.scene,
34 data_collector = self.data_collector,
35 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR,
36 cell_to_point = False, outline = True)
37
38
39 def tearDown(self):
40 del self.scene
41 del self.data_collector
42 del self.contour
43 del self.legend
44
45 def render(self, file):
46 self.scene.render(image_name = \
47 os.path.join(PYVISI_TEST_LEGEND_IMAGES_PATH, file))
48
49 self.failUnless(os.stat(os.path.join(PYVISI_TEST_LEGEND_IMAGES_PATH, \
50 file))[ST_SIZE] > MIN_IMAGE_SIZE)
51
52 def testScalarLegendLazy(self):
53 self.legend = Legend(scene = self.scene, \
54 data_collector = self.data_collector, \
55 viewport = Viewport.SOUTH_WEST,\
56 lut = Lut.COLOR, legend = LegendType.SCALAR)
57
58 self.legend.setOrientationToHorizontal()
59 self.legend.setTitle(title = "Scalar Bar")
60 self.legend.setPosition(LocalPosition(50, 5))
61
62 self.data_collector.setFileName(file_name = \
63 os.path.join(PYVISI_TEST_MESHES_PATH, FILE_2D))
64 self.render("TestLegend_testScalarLegendWithLazyEvaluation.jpg")
65
66 def testVectorLegendLazy(self):
67 self.legend = Legend(scene = self.scene, \
68 data_collector = self.data_collector, \
69 viewport = Viewport.SOUTH_WEST,\
70 lut = Lut.COLOR, legend = LegendType.VECTOR)
71
72 self.legend.setOrientationToVertical()
73 self.legend.setTitle(title = "Scalar Bar")
74 self.legend.setPosition(LocalPosition(5, 50))
75
76 self.data_collector.setFileName(file_name = \
77 os.path.join(PYVISI_TEST_MESHES_PATH, FILE_2D))
78 self.render("TestLegend_testVectorLegendWithLazyEvaluation.jpg")
79
80
81
82 ##############################################################################
83
84
85 if __name__ == '__main__':
86 suite = unittest.TestSuite()
87 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(\
88 TestLegendWithLazyEvaluation))
89 unittest.TextTestRunner(verbosity=2).run(suite)
90

  ViewVC Help
Powered by ViewVC 1.1.26