1 # Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA 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
19 # File : test_table.py
20 # Author : Vadim SANDLER
28 # >>> Getting study builder ==================================================
29 myStudy = salome.myStudy
30 myBuilder = myStudy.NewBuilder()
32 # >>> Creating virtual component =============================================
33 myComponent = myStudy.FindComponent("VirtualComponent")
35 myComponent = myBuilder.NewComponent("VirtualComponent")
36 aName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName")
37 aName.SetValue("VirtualComponent")
39 # >>> Creating object with Table of integer ==================================
40 myTIntObject = myBuilder.NewObject(myComponent)
41 AName = myBuilder.FindOrCreateAttribute(myTIntObject, "AttributeName")
42 AName.SetValue("Table Of Integer")
43 AIntTable = myBuilder.FindOrCreateAttribute(myTIntObject, "AttributeTableOfInteger")
45 a=[1,2,3,4,5,6,7,8,9,10]
47 a=[110,120,130,140,150,160,170,180,190,200]
49 a=[-1,272,0,0,-642,10000,13,578,-578,99]
51 AIntTable.SetTitle("TEST table of integer")
52 AIntTable.SetRowTitle(1,"FR")
53 AIntTable.SetRowUnit(1,"m/h")
54 AIntTable.SetRowTitle(2,"SR")
55 AIntTable.SetRowUnit(2,"s")
56 AIntTable.SetRowTitle(3,"TR")
57 AIntTable.SetRowUnit(3,"$")
58 c=["C1","C2","C3","C4","C5","C6","C7","C8","C9","C10"]
59 AIntTable.SetColumnTitles(c)
61 # >>> Creating object with Table of real =====================================
62 myTRealObject = myBuilder.NewObject(myComponent)
63 AName = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeName")
64 AName.SetValue("Table Of Real")
65 ARealTable = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeTableOfReal")
72 ARealTable.AddRow(k.values())
73 ARealTable.SetRowTitle(1, "Row 0")
74 ARealTable.SetRowUnit(1, "Hz")
75 ARealTable.SetColumnTitles(l.values())
79 k[j] = math.log10(j*30*math.pi/180) * 20 + i * 15 + j*5
81 k[j] = math.sin(j*30*math.pi/180) * 20 + i * 15 + j*5
82 ARealTable.AddRow(k.values())
83 ARealTable.SetRowTitle(i+1, "Row " + str(i))
84 ARealTable.SetRowUnit(i+1, "Wt")
85 ARealTable.SetTitle("TEST table of real")
87 # >>> Creating object with integer attribute =================================
88 myIntObject = myBuilder.NewObject(myComponent)
89 AName = myBuilder.FindOrCreateAttribute(myIntObject, "AttributeName")
90 AName.SetValue("Integer")
91 AInt = myBuilder.FindOrCreateAttribute(myIntObject, "AttributeInteger")
94 # >>> Creating object with real attribute ====================================
95 myRealObject = myBuilder.NewObject(myComponent)
96 AName = myBuilder.FindOrCreateAttribute(myRealObject, "AttributeName")
97 AName.SetValue("Real")
98 AReal = myBuilder.FindOrCreateAttribute(myRealObject, "AttributeReal")
99 AReal.SetValue(-56.9634)
101 # >>> Creating object with comment attribute =================================
102 myCmtObject = myBuilder.NewObject(myComponent)
103 AName = myBuilder.FindOrCreateAttribute(myCmtObject, "AttributeName")
104 AName.SetValue("Comment")
105 ACmt = myBuilder.FindOrCreateAttribute(myCmtObject, "AttributeComment")
106 ACmt.SetValue("Just a comment")
108 # >>> Updating Object Browser ================================================
109 salome.sg.updateObjBrowser(1)
111 # ============================================================================