]> SALOME platform Git repositories - modules/gui.git/blob - src/SALOME_SWIG/test_table.py
Salome HOME
e3cd71d65270bbecd5284e926ad9118c228d6c0b
[modules/gui.git] / src / SALOME_SWIG / test_table.py
1 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 #
6 #  This library is free software; you can redistribute it and/or
7 #  modify it under the terms of the GNU Lesser General Public
8 #  License as published by the Free Software Foundation; either
9 #  version 2.1 of the License.
10 #
11 #  This library is distributed in the hope that it will be useful,
12 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 #  Lesser General Public License for more details.
15 #
16 #  You should have received a copy of the GNU Lesser General Public
17 #  License along with this library; if not, write to the Free Software
18 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 #
20 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #
22 # File   : test_table.py
23 # Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
24 #
25 import salome
26 import math
27 import SALOMEDS
28
29 # >>> Getting study builder ==================================================
30 myStudy = salome.myStudy
31 myBuilder = myStudy.NewBuilder()
32
33 # >>> Creating virtual component =============================================
34 myComponent = myStudy.FindComponent("VirtualComponent")
35 if not myComponent:
36    myComponent = myBuilder.NewComponent("VirtualComponent")
37    aName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName")
38    aName.SetValue("VirtualComponent")
39
40 # >>> Creating object with Table of integer ==================================
41 myTIntObject = myBuilder.NewObject(myComponent)
42 AName = myBuilder.FindOrCreateAttribute(myTIntObject, "AttributeName")
43 AName.SetValue("Table Of Integer")
44 AIntTable = myBuilder.FindOrCreateAttribute(myTIntObject, "AttributeTableOfInteger")
45
46 a=[1,2,3,4,5,6,7,8,9,10]
47 AIntTable.AddRow(a)
48 a=[110,120,130,140,150,160,170,180,190,200]
49 AIntTable.AddRow(a)
50 a=[-1,272,0,0,-642,10000,13,578,-578,99]
51 AIntTable.AddRow(a)
52 AIntTable.SetTitle("TEST table of integer")
53 AIntTable.SetRowTitle(1,"FR")
54 AIntTable.SetRowUnit(1,"m/h")
55 AIntTable.SetRowTitle(2,"SR")
56 AIntTable.SetRowUnit(2,"s")
57 AIntTable.SetRowTitle(3,"TR")
58 AIntTable.SetRowUnit(3,"$")
59 c=["C1","C2","C3","C4","C5","C6","C7","C8","C9","C10"]
60 AIntTable.SetColumnTitles(c)
61
62 # >>> Creating object with Table of real =====================================
63 myTRealObject = myBuilder.NewObject(myComponent)
64 AName = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeName")
65 AName.SetValue("Table Of Real")
66 ARealTable = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeTableOfReal")
67
68 k={}
69 l={}
70 for j in range(0,20):
71    k[j] = j*10+1
72    l[j] = "C"+str(j+1)
73 ARealTable.AddRow(k.values())
74 ARealTable.SetRowTitle(1, "Row 0")
75 ARealTable.SetRowUnit(1, "Hz")
76 ARealTable.SetColumnTitles(l.values())
77 for i in range(1,11):
78    for j in range(1,21):
79       if j % 2 == 1:
80          k[j] = math.log10(j*30*math.pi/180) * 20 + i * 15 + j*5
81       else:
82          k[j] = math.sin(j*30*math.pi/180) * 20 + i * 15 + j*5 
83    ARealTable.AddRow(k.values())
84    ARealTable.SetRowTitle(i+1, "Row " + str(i))
85    ARealTable.SetRowUnit(i+1, "Wt")
86 ARealTable.SetTitle("TEST table of real")
87
88 # >>> Creating object with integer attribute =================================
89 myIntObject = myBuilder.NewObject(myComponent)
90 AName = myBuilder.FindOrCreateAttribute(myIntObject, "AttributeName")
91 AName.SetValue("Integer")
92 AInt = myBuilder.FindOrCreateAttribute(myIntObject, "AttributeInteger")
93 AInt.SetValue(123)
94
95 # >>> Creating object with real attribute ====================================
96 myRealObject = myBuilder.NewObject(myComponent)
97 AName = myBuilder.FindOrCreateAttribute(myRealObject, "AttributeName")
98 AName.SetValue("Real")
99 AReal = myBuilder.FindOrCreateAttribute(myRealObject, "AttributeReal")
100 AReal.SetValue(-56.9634)
101
102 # >>> Creating object with comment attribute =================================
103 myCmtObject = myBuilder.NewObject(myComponent)
104 AName = myBuilder.FindOrCreateAttribute(myCmtObject, "AttributeName")
105 AName.SetValue("Comment")
106 ACmt = myBuilder.FindOrCreateAttribute(myCmtObject, "AttributeComment")
107 ACmt.SetValue("Just a comment")
108
109 # >>> Updating Object Browser ================================================
110 salome.sg.updateObjBrowser(1)
111
112 # ============================================================================
113
114
115