1 # Copyright (C) 2010-2015 CEA/DEN, EDF R&D
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # This case corresponds to: /visu/dump_study/A2 case
22 from paravistest import datadir, delete_with_inputs
23 from presentations import *
24 from pvsimple import *
26 settings = {"Offset": [0.0001, 0.0002, 0], "ScalarMode": ("Component", 2), "Position": [0.1, 0.2], "Size": [0.15, 0.25], "Discretize": 1, "NbColors": 44, "NbLabels": 22, "Title": "My presentation", "UseLogScale": 1, "Orientation": 'Horizontal', "Orientation_BasePlane": [Orientation.ZX, 22, 33], "Orientation_CuttingPlanes": [Orientation.YZ, 44, 55], "Displacement": 0.1, "Displacement2": 0.2, "BasePlane_Position": 0.1, "NbLines": 3}
28 # 1. TimeStamps.med import
29 file_path = datadir + "TimeStamps.med"
30 OpenDataFile(file_path)
31 med_reader = GetActiveSource()
32 if med_reader is None :
33 raise RuntimeError, "TimeStamps.med wasn't imported..."
35 # 2. CutLines creation
38 nb_lines = settings["NbLines"]
39 orient1 = settings["Orientation_BasePlane"][0]
40 base_ang1 = settings["Orientation_BasePlane"][1]
41 base_ang2 = settings["Orientation_BasePlane"][2]
42 orient2 = settings["Orientation_CuttingPlanes"][0]
43 cut_ang1 = settings["Orientation_CuttingPlanes"][1]
44 cut_ang2 = settings["Orientation_CuttingPlanes"][2]
45 d1 = settings["Displacement"]
46 d2 = settings["Displacement2"]
48 cutlines = CutLinesOnField(med_reader, EntityType.NODE, med_field, 1, nb_lines, orient1, base_ang1, base_ang2, orient2, cut_ang1, cut_ang2, d1, d2)
51 cutlines.Position = settings["Offset"]
52 cutlines.LookupTable.VectorMode = settings["ScalarMode"][0]
53 cutlines.LookupTable.VectorComponent = settings["ScalarMode"][1]
54 cutlines.LookupTable.Discretize = settings["Discretize"]
55 cutlines.LookupTable.NumberOfTableValues = settings["NbColors"]
56 cutlines.LookupTable.UseLogScale = settings["UseLogScale"]
58 cutlines.Input.Input.SliceOffsetValues[0] = settings["BasePlane_Position"]
60 normal1 = list(cutlines.Input.Input.SliceType.Normal)
61 pos1 = list(cutlines.Input.Input.SliceOffsetValues)
62 normal2 = list(cutlines.Input.SliceType.Normal)
63 pos2 = list(cutlines.Input.SliceOffsetValues)
66 bar.Position = settings["Position"]
67 bar.Position2 = settings["Size"]
68 bar.NumberOfLabels = settings["NbLabels"]
69 bar.Title = settings["Title"]
70 bar.Orientation = settings["Orientation"]
73 path_to_save = os.path.join(os.getenv("HOME"), "CutLines.py")
74 SaveTrace( path_to_save )
76 # 4. Delete the created objects, recreate the view
77 delete_with_inputs(cutlines)
78 Delete(GetActiveView())
79 view = CreateRenderView()
81 # 5. Execution of the created script
82 execfile(path_to_save)
84 # 6. Checking of the settings done before dump
85 recreated_bar = view.Representations[0]
86 recreated_cutlines = view.Representations[1]
92 offset = recreated_cutlines.Position
93 for i in range(len(settings["Offset"])):
94 if abs(offset[i] - settings["Offset"][i]) > tolerance:
95 print "ERROR!!! Offset value with ", i, " index is incorrect: ", offset[i], " instead of ", settings["Offset"][i]
99 vector_mode = recreated_cutlines.LookupTable.VectorMode
100 vector_component = recreated_cutlines.LookupTable.VectorComponent
102 if vector_mode != settings["ScalarMode"][0]:
103 print "ERROR!!! Vector mode value is incorrect: ", vector_mode, " instead of ", settings["ScalarMode"][0]
105 if vector_component != settings["ScalarMode"][1]:
106 print "ERROR!!! Vector component value is incorrect: ", vector_component, " instead of ", settings["ScalarMode"][1]
109 # Position of scalar bar
110 pos_x = recreated_bar.Position[0]
111 pos_y = recreated_bar.Position[1]
113 if abs(pos_x - settings["Position"][0]) > tolerance:
114 print "ERROR!!! X coordinate of position of scalar bar is incorrect: ", pos_x, " instead of ", settings["Position"][0]
116 if abs(pos_y - settings["Position"][1]) > tolerance:
117 print "ERROR!!! Y coordinate of position of scalar bar is incorrect: ", pos_y, " instead of ", settings["Position"][1]
121 width = recreated_bar.Position2[0]
122 height = recreated_bar.Position2[1]
124 if abs(width - settings["Size"][0]) > tolerance:
125 print "ERROR!!! Width of scalar bar is incorrect: ", width, " instead of ", settings["Size"][0]
127 if abs(height - settings["Size"][1]) > tolerance:
128 print "ERROR!!! Height of scalar bar is incorrect: ", height, " instead of ", settings["Size"][1]
132 discretize = recreated_cutlines.LookupTable.Discretize
133 if discretize != settings["Discretize"]:
134 print "ERROR!!! Discretize property is incorrect: ", discretize, " instead of ", settings["Discretize"]
138 nb_colors = recreated_cutlines.LookupTable.NumberOfTableValues
139 if nb_colors != settings["NbColors"]:
140 print "ERROR!!! Number of colors of scalar bar is incorrect: ", nb_colors, " instead of ", settings["NbColors"]
144 nb_labels = recreated_bar.NumberOfLabels
145 if nb_labels != settings["NbLabels"]:
146 print "ERROR!!! Number of labels of scalar bar is incorrect: ", nb_labels, " instead of ", settings["NbLabels"]
150 title = recreated_bar.Title
151 if title != settings["Title"]:
152 print "ERROR!!! Title of presentation is incorrect: ", title, " instead of ", settings["Title"]
156 use_log_scale = recreated_cutlines.LookupTable.UseLogScale
157 if use_log_scale != settings["UseLogScale"]:
158 print "ERROR!!! Scaling of presentation is incorrect: ", use_log_scale, " instead of ", settings["UseLogScale"]
162 orientation = recreated_bar.Orientation
163 if orientation != settings["Orientation"]:
164 print "ERROR!!! Orientation of scalar bar is incorrect: ", orientation, " instead of ", settings["Orientation"]
168 cur_normal = list(recreated_cutlines.Input.Input.SliceType.Normal)
169 if cur_normal != normal1:
170 print "ERROR!!! Normal of base plane is incorrect: ", cur_normal, " instead of ", normal1
173 # Base Plane Position
174 cur_pos = list(recreated_cutlines.Input.Input.SliceOffsetValues)
176 print "ERROR!!! Position of base plane is incorrect: ", cur_pos, " instead of ", pos1
180 cur_normal = list(recreated_cutlines.Input.SliceType.Normal)
181 if cur_normal != normal2:
182 print "ERROR!!! Normal of cutting planes is incorrect: ", cur_normal, " instead of ", normal2
185 # Cutting Planes Position
186 cur_pos = list(recreated_cutlines.Input.SliceOffsetValues)
188 print "ERROR!!! Positions of cutting planes are incorrect: ", cur_pos, " instead of ", pos2
192 raise RuntimeError, "There is(are) some error(s) was(were) found... For more info see ERRORs above..."