1 # Copyright (C) 2010-2016 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/SWIG_scripts/C7 case
21 # Import a table in Post-Pro specific format from file;
22 # create 3D representation of the table and show it in 3D viewer
26 from paravistest import tablesdir, get_picture_dir, pictureext
27 from presentations import *
30 # Import table from file
31 print('Import file with tables....', end=' ')
32 file_path = tablesdir + "table_test.xls"
33 table_reader = pvsimple.TableReader(FileName=file_path)
34 if table_reader is None:
39 # Get default settings of the reader
40 available_tables = table_reader.GetPropertyValue("AvailableTables")
41 is_detect_num = table_reader.DetectNumericColumns
42 first_str_as_title = table_reader.FirstStringAsTitles
43 delimiter = table_reader.ValueDelimiter
44 table_nb = table_reader.TableNumber
46 print("Default reader settings:")
47 print("Available tables: ", available_tables)
48 print("Detect Numeric Columns: ", is_detect_num)
49 print("Interpret First String As Column Titles: ", first_str_as_title)
50 print("Value Delimiter: '%s'" % delimiter)
51 print("Table Number: ", table_nb)
54 # Create 3D representation of the table with the
55 # help of "Table To 3D" filter,
56 # in Post-Pro this representation is known as "Pointmap3d"
57 table_to_3d = pvsimple.TableTo3D(table_reader)
59 print('Create "Table To 3D" filter....', end=' ')
60 if table_to_3d is None:
65 print("Default 'Table To 3D' filter settings:")
66 print("Scale Factor: ", table_to_3d.ScaleFactor)
67 print("Use Optimus Scale: ", table_to_3d.UseOptimusScale)
68 print("Presentation Type: ", table_to_3d.PresentationType)
69 print("Number Of Contours: ", table_to_3d.NumberOfContours)
72 # Show table 3D representation
75 print('Get 3D view...................', end=' ')
76 view = pvsimple.GetRenderView()
83 pointmap3d = pvsimple.GetRepresentation(table_to_3d)
85 table_name = available_tables
86 if isinstance(available_tables, list):
87 table_name = available_tables[table_nb]
89 vector_mode = 'Magnitude'
91 entity = EntityType.NODE
94 lookup_table = get_lookup_table(table_name, nb_components, vector_mode)
95 if hasattr(lookup_table,"LockDataRange"):
96 lookup_table.LockDataRange = 0
97 elif hasattr(lookup_table,"LockScalarRange"):
98 lookup_table.LockScalarRange = 0
100 raise RuntimeError("Object %s has no 'LockDataRange' or 'LockScalarRange' attribute!"%(lookup_table))
103 pointmap3d.ColorArrayName = (EntityType.get_pvtype(entity), table_name)
104 pointmap3d.LookupTable = lookup_table
107 add_scalar_bar(table_name, nb_components, vector_mode,
111 reset_view(view=view)
115 # Directory for saving snapshots
116 picturedir = get_picture_dir("SWIG_scripts/C7")
117 if not picturedir.endswith(os.sep):
120 file_name = picturedir + "pointmap3d." + pictureext
121 pvsimple.WriteImage(file_name, view=view, Magnification=1)