12 self.columnTitles = []
17 nb = len(self.rows[0].values)
22 col.values.append(r.values[i])
24 print self.columnTitles
25 if len(self.columnTitles)>i:
26 col.title = self.columnTitles[i]
29 if len(self.columnUnits)>i:
30 col.unit = self.columnUnits[i]
37 def AddTablesInStudyFromFile(ffile):
38 from exceptions import IOError
40 file = open(ffile, 'r')
42 msg="can't open file <%s>...\n"%ffile
45 is_table_first_line = 1
49 for line in file.readlines():
53 is_table_first_line = 1
55 if is_table_first_line:
56 is_table_first_line = 0
60 if line.find('#TITLE:')==0:
61 t.title = line.split('#TITLE:')[1].strip()
63 if line.find('#COLUMN_TITLES:')==0:
64 titles = line.split('#COLUMN_TITLES:')[1].split("|")
65 t.columnTitles = [ title.strip() for title in titles ]
67 if line.find('#COLUMN_UNITS:')==0:
68 units = line.split('#COLUMN_UNITS:')[1].split()
69 t.columnUnits = [ unit.strip() for unit in units ]
74 if line.find('#TITLE:')>0:
75 row.title = line.split('#TITLE:')[1].strip()
76 line = line.split('#TITLE:')[0]
84 message = "Syntax error at line " + str(num) + " ... \n"
85 message += "Found field : " + str(val) + '\n'
86 message += "instead of a floating point number"
88 qt.QMessageBox.warning(None,"Error",message)
90 floatingValues.append(val)
94 if len(t.rows[0].values) != len(floatingValues):
95 message = "Syntax error at line " + str(num) + " ... \n"
96 message += "All rows must have the same number of fields"
98 qt.QMessageBox.warning(None,"Error",message)
102 row.values = floatingValues
107 myStudy = salome.myStudy
108 myBuilder = myStudy.NewBuilder()
110 # >>> Getting (loading) VISU component =======================================
111 myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU")
112 myComponent = myStudy.FindComponent("VISU")
114 myComponent = myBuilder.NewComponent("VISU")
115 aName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName")
116 #aName.SetValue("Visu")
117 aName.SetValue( salome.sg.getComponentUserName("VISU") )
118 myBuilder.DefineComponentInstance(myComponent,myVisu)
121 # >>> Creating object with file name =====================================
122 myFileObject = myBuilder.NewObject(myComponent)
123 AName = myBuilder.FindOrCreateAttribute(myFileObject, "AttributeName")
125 AName.SetValue(os.path.basename(ffile))
129 # >>> Creating object with Table of real =====================================
130 myTRealObject = myBuilder.NewObject(myFileObject)
131 AName = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeName")
133 AName.SetValue(t.title)
135 AName.SetValue("Table "+str(num))
138 ARealTable = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeTableOfReal")
140 ARealTable.SetTitle(t.title)
142 cols = t.getColumns()
144 ARealTable.AddRow(col.values)
145 ARealTable.SetRowTitle(cols.index(col)+1, col.title)
146 ARealTable.SetRowUnit(cols.index(col)+1, col.unit)
147 # ARealTable.SetColumnTitles(l.values())
153 # >>> Updating Object Browser ================================================
154 salome.sg.updateObjBrowser(1)