1 # VISU VISUGUI : GUI of VISU component
3 # Copyright (C) 2003 CEA/DEN, EDF R&D
21 self.columnTitles = []
26 nb = len(self.rows[0].values)
31 col.values.append(r.values[i])
33 print self.columnTitles
34 if len(self.columnTitles)>i:
35 col.title = self.columnTitles[i]
38 if len(self.columnUnits)>i:
39 col.unit = self.columnUnits[i]
46 def AddTablesInStudyFromFile(ffile):
47 from exceptions import IOError
49 file = open(ffile, 'r')
51 msg="can't open file <%s>...\n"%ffile
54 is_table_first_line = 1
58 for line in file.readlines():
62 is_table_first_line = 1
64 if is_table_first_line:
65 is_table_first_line = 0
69 if line.find('#TITLE:')==0:
70 t.title = line.split('#TITLE:')[1].strip()
72 if line.find('#COLUMN_TITLES:')==0:
73 titles = line.split('#COLUMN_TITLES:')[1].split("|")
74 t.columnTitles = [ title.strip() for title in titles ]
76 if line.find('#COLUMN_UNITS:')==0:
77 units = line.split('#COLUMN_UNITS:')[1].split()
78 t.columnUnits = [ unit.strip() for unit in units ]
83 if line.find('#TITLE:')>0:
84 row.title = line.split('#TITLE:')[1].strip()
85 line = line.split('#TITLE:')[0]
93 message = "Syntax error at line " + str(num) + " ... \n"
94 message += "Found field : " + str(val) + '\n'
95 message += "instead of a floating point number"
97 qt.QMessageBox.warning(None,"Error",message)
99 floatingValues.append(val)
103 if len(t.rows[0].values) != len(floatingValues):
104 message = "Syntax error at line " + str(num) + " ... \n"
105 message += "All rows must have the same number of fields"
107 qt.QMessageBox.warning(None,"Error",message)
111 row.values = floatingValues
116 myStudy = salome.myStudy
117 myBuilder = myStudy.NewBuilder()
119 # >>> Getting (loading) VISU component =======================================
120 myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU")
121 myComponent = myStudy.FindComponent("VISU")
123 myComponent = myBuilder.NewComponent("VISU")
124 aName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName")
125 #aName.SetValue("Visu")
126 aName.SetValue( salome.sg.getComponentUserName("VISU") )
127 myBuilder.DefineComponentInstance(myComponent,myVisu)
130 # >>> Creating object with file name =====================================
131 myFileObject = myBuilder.NewObject(myComponent)
132 AName = myBuilder.FindOrCreateAttribute(myFileObject, "AttributeName")
134 AName.SetValue(os.path.basename(ffile))
138 # >>> Creating object with Table of real =====================================
139 myTRealObject = myBuilder.NewObject(myFileObject)
140 AName = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeName")
142 AName.SetValue(t.title)
144 AName.SetValue("Table "+str(num))
147 ARealTable = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeTableOfReal")
149 ARealTable.SetTitle(t.title)
151 cols = t.getColumns()
153 ARealTable.AddRow(col.values)
154 ARealTable.SetRowTitle(cols.index(col)+1, col.title)
155 ARealTable.SetRowUnit(cols.index(col)+1, col.unit)
156 # ARealTable.SetColumnTitles(l.values())
162 # >>> Updating Object Browser ================================================
163 salome.sg.updateObjBrowser(1)