1 #==============================================================================
4 # Author : Vadim SANDLER
6 # Copyright : Open CASCADE
8 #==============================================================================
10 # ============================================================================
11 # Check attributes creation : Integer, Real, Comment, Tables
12 # ============================================================================
17 # >>> Getting study builder ==================================================
18 myStudy = salome.myStudy
19 myBuilder = myStudy.NewBuilder()
21 # >>> Creating virtual component =============================================
22 myComponent = myStudy.FindComponent("VirtualComponent")
24 myComponent = myBuilder.NewComponent("VirtualComponent")
25 aName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName")
26 aName.SetValue("VirtualComponent")
28 # >>> Creating object with Table of integer ==================================
29 myTIntObject = myBuilder.NewObject(myComponent)
30 AName = myBuilder.FindOrCreateAttribute(myTIntObject, "AttributeName")
31 AName.SetValue("Table Of Integer")
32 AIntTable = myBuilder.FindOrCreateAttribute(myTIntObject, "AttributeTableOfInteger")
34 a=[1,2,3,4,5,6,7,8,9,10]
36 a=[110,120,130,140,150,160,170,180,190,200]
38 a=[-1,272,0,0,-642,10000,13,578,-578,99]
40 AIntTable.SetTitle("TEST table of integer")
41 AIntTable.SetRowTitle(1,"FR")
42 AIntTable.SetRowUnit(1,"m/h")
43 AIntTable.SetRowTitle(2,"SR")
44 AIntTable.SetRowUnit(2,"s")
45 AIntTable.SetRowTitle(3,"TR")
46 AIntTable.SetRowUnit(3,"$")
47 c=["C1","C2","C3","C4","C5","C6","C7","C8","C9","C10"]
48 AIntTable.SetColumnTitles(c)
50 # >>> Creating object with Table of real =====================================
51 myTRealObject = myBuilder.NewObject(myComponent)
52 AName = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeName")
53 AName.SetValue("Table Of Real")
54 ARealTable = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeTableOfReal")
61 ARealTable.AddRow(k.values())
62 ARealTable.SetRowTitle(1, "Row 0")
63 ARealTable.SetRowUnit(1, "Hz")
64 ARealTable.SetColumnTitles(l.values())
68 k[j] = math.log10(j*30*math.pi/180) * 20 + i * 15 + j*5
70 k[j] = math.sin(j*30*math.pi/180) * 20 + i * 15 + j*5
71 ARealTable.AddRow(k.values())
72 ARealTable.SetRowTitle(i+1, "Row " + str(i))
73 ARealTable.SetRowUnit(i+1, "Wt")
74 ARealTable.SetTitle("TEST table of real")
76 # >>> Creating object with integer attribute =================================
77 myIntObject = myBuilder.NewObject(myComponent)
78 AName = myBuilder.FindOrCreateAttribute(myIntObject, "AttributeName")
79 AName.SetValue("Integer")
80 AInt = myBuilder.FindOrCreateAttribute(myIntObject, "AttributeInteger")
83 # >>> Creating object with real attribute ====================================
84 myRealObject = myBuilder.NewObject(myComponent)
85 AName = myBuilder.FindOrCreateAttribute(myRealObject, "AttributeName")
86 AName.SetValue("Real")
87 AReal = myBuilder.FindOrCreateAttribute(myRealObject, "AttributeReal")
88 AReal.SetValue(-56.9634)
90 # >>> Creating object with comment attribute =================================
91 myCmtObject = myBuilder.NewObject(myComponent)
92 AName = myBuilder.FindOrCreateAttribute(myCmtObject, "AttributeName")
93 AName.SetValue("Comment")
94 ACmt = myBuilder.FindOrCreateAttribute(myCmtObject, "AttributeComment")
95 ACmt.SetValue("Just a comment")
97 # >>> Updating Object Browser ================================================
98 salome.sg.updateObjBrowser(1)
100 # ============================================================================