1 # Copyright (C) 2010-2013 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.
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 *
32 # Import table from file
33 print 'Import file with tables....',
34 file_path = tablesdir + "table_test.xls"
35 table_reader = pvsimple.TableReader(FileName=file_path)
36 if table_reader is None:
41 # Get default settings of the reader
42 available_tables = table_reader.GetPropertyValue("AvailableTables")
43 is_detect_num = table_reader.DetectNumericColumns
44 first_str_as_title = table_reader.FirstStringAsTitles
45 delimiter = table_reader.ValueDelimiter
46 table_nb = table_reader.TableNumber
48 print "Default reader settings:"
49 print "Available tables: ", available_tables
50 print "Detect Numeric Columns: ", is_detect_num
51 print "Interpret First String As Column Titles: ", first_str_as_title
52 print "Value Delimiter: '%s'" % delimiter
53 print "Table Number: ", table_nb
56 # Create 3D representation of the table with the
57 # help of "Table To 3D" filter,
58 # in Post-Pro this representation is known as "Pointmap3d"
59 table_to_3d = pvsimple.TableTo3D(table_reader)
61 print 'Create "Table To 3D" filter....',
62 if table_to_3d is None:
67 print "Default 'Table To 3D' filter settings:"
68 print "Scale Factor: ", table_to_3d.ScaleFactor
69 print "Use Optimus Scale: ", table_to_3d.UseOptimusScale
70 print "Presentation Type: ", table_to_3d.PresentationType
71 print "Number Of Contours: ", table_to_3d.NumberOfContours
74 # Show table 3D representation
77 print 'Get 3D view...................',
78 view = pvsimple.GetRenderView()
85 pointmap3d = pvsimple.GetRepresentation(table_to_3d)
87 table_name = available_tables
88 if type(available_tables) == list:
89 table_name = available_tables[table_nb]
91 vector_mode = 'Magnitude'
93 entity = EntityType.NODE
96 lookup_table = get_lookup_table(table_name, nb_components, vector_mode)
97 lookup_table.LockScalarRange = 0
100 pointmap3d.ColorAttributeType = EntityType.get_pvtype(entity)
101 pointmap3d.ColorArrayName = table_name
102 pointmap3d.LookupTable = lookup_table
105 add_scalar_bar(table_name, nb_components, vector_mode,
109 reset_view(view=view)
114 # Directory for saving snapshots
115 picturedir = get_picture_dir("SWIG_scripts/C7")
116 if not picturedir.endswith(os.sep):
119 file_name = picturedir + "pointmap3d." + pictureext
120 pvsimple.WriteImage(file_name, view=view, Magnification=1)