Back to index

salome-paravis  6.5.0
C7.py
Go to the documentation of this file.
00001 # Copyright (C) 2010-2012  CEA/DEN, EDF R&D
00002 #
00003 # This library is free software; you can redistribute it and/or
00004 # modify it under the terms of the GNU Lesser General Public
00005 # License as published by the Free Software Foundation; either
00006 # version 2.1 of the License.
00007 #
00008 # This library is distributed in the hope that it will be useful,
00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 # Lesser General Public License for more details.
00012 #
00013 # You should have received a copy of the GNU Lesser General Public
00014 # License along with this library; if not, write to the Free Software
00015 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 #
00017 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 #
00019 
00020 # This case corresponds to: /visu/SWIG_scripts/C7 case
00021 # Import a table in Post-Pro specific format from file;
00022 # create 3D representation of the table and show it in 3D viewer
00023 
00024 import sys
00025 
00026 from paravistest import tablesdir, get_picture_dir, pictureext
00027 from presentations import *
00028 import paravis
00029 import pvsimple
00030 
00031 
00032 # Import table from file
00033 print 'Import file with tables....',
00034 file_path = tablesdir + "table_test.xls"
00035 table_reader = pvsimple.TableReader(FileName=file_path)
00036 if table_reader is None:
00037     print "FAILED"
00038 else:
00039     print "OK"
00040 
00041 # Get default settings of the reader
00042 available_tables = table_reader.GetPropertyValue("AvailableTables")
00043 is_detect_num = table_reader.DetectNumericColumns
00044 first_str_as_title = table_reader.FirstStringAsTitles
00045 delimiter = table_reader.ValueDelimiter
00046 table_nb = table_reader.TableNumber
00047 
00048 print "Default reader settings:"
00049 print "Available tables: ", available_tables
00050 print "Detect Numeric Columns: ", is_detect_num
00051 print "Interpret First String As Column Titles: ", first_str_as_title
00052 print "Value Delimiter: '%s'" % delimiter
00053 print "Table Number: ", table_nb
00054 
00055 
00056 # Create 3D representation of the table with the
00057 # help of "Table To 3D" filter,
00058 # in Post-Pro this representation is known as "Pointmap3d"
00059 table_to_3d = pvsimple.TableTo3D(table_reader)
00060 
00061 print 'Create "Table To 3D" filter....',
00062 if table_to_3d is None:
00063     print "FAILED"
00064 else:
00065     print "OK"
00066 
00067 print "Default 'Table To 3D' filter settings:"
00068 print "Scale Factor: ", table_to_3d.ScaleFactor
00069 print "Use Optimus Scale: ", table_to_3d.UseOptimusScale
00070 print "Presentation Type: ", table_to_3d.PresentationType
00071 print "Number Of Contours: ", table_to_3d.NumberOfContours
00072 
00073 
00074 # Show table 3D representation
00075 
00076 # Get 3D view
00077 print 'Get 3D view...................',
00078 view = pvsimple.GetRenderView()
00079 if view is None:
00080     print "FAILED"
00081 else:
00082     reset_view(view)
00083     print "OK"
00084 
00085 pointmap3d = pvsimple.GetRepresentation(table_to_3d)
00086 
00087 table_name = available_tables
00088 if type(available_tables) == list:
00089   table_name = available_tables[table_nb]
00090 
00091 vector_mode = 'Magnitude'
00092 nb_components = 1
00093 entity = EntityType.NODE
00094 
00095 # Get lookup table
00096 lookup_table = get_lookup_table(table_name, nb_components, vector_mode)
00097 lookup_table.LockScalarRange = 0
00098 
00099 # Set properties
00100 pointmap3d.ColorAttributeType = EntityType.get_pvtype(entity)
00101 pointmap3d.ColorArrayName = table_name
00102 pointmap3d.LookupTable = lookup_table
00103 
00104 # Add scalar bar
00105 add_scalar_bar(table_name, nb_components, vector_mode,
00106                lookup_table, "")
00107 
00108 # Reset view
00109 reset_view(view=view)
00110 
00111 
00112 # Write image
00113 
00114 # Directory for saving snapshots
00115 picturedir = get_picture_dir(sys.argv[1], "SWIG_scripts/C7")
00116 if not picturedir.endswith(os.sep):
00117     picturedir += os.sep
00118 
00119 file_name = picturedir + "pointmap3d." + pictureext
00120 pvsimple.WriteImage(file_name, view=view, Magnification=1)