1 #==============================================================================
4 # Author : Vadim SANDLER
6 # Copyright : Open CASCADE
8 #==============================================================================
10 # ============================================================================
11 # Check attributes creation : Integer, Real, Comment, Tables
12 # ============================================================================
18 # >>> Getting study builder ==================================================
19 myStudy = salome.myStudy
20 myBuilder = myStudy.NewBuilder()
22 # >>> Getting (loading) VISU component =======================================
23 myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU")
24 myComponent = myStudy.FindComponent("VISU")
25 myVisu.SetCurrentStudy(myStudy)
27 myComponent = myBuilder.NewComponent("VISU")
28 aName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName")
29 aName.SetValue( salome.sg.getComponentUserName("VISU") )
30 myBuilder.DefineComponentInstance(myComponent,myVisu)
32 # >>> Creating object with Table of integer ==================================
33 myTIntObject = myBuilder.NewObject(myComponent)
34 AName = myBuilder.FindOrCreateAttribute(myTIntObject, "AttributeName")
35 AName.SetValue("Table Of Integer")
36 AIntTable = myBuilder.FindOrCreateAttribute(myTIntObject, "AttributeTableOfInteger")
38 a=[1,2,3,4,5,6,7,8,9,10]
40 a=[110,120,130,140,150,160,170,180,190,200]
42 a=[-1,272,0,0,-642,10000,13,578,-578,99]
44 AIntTable.SetTitle("TEST table of integer")
45 AIntTable.SetRowTitle(1,"FR")
46 AIntTable.SetRowUnit(1,"m/h")
47 AIntTable.SetRowTitle(2,"SR")
48 AIntTable.SetRowUnit(2,"s")
49 AIntTable.SetRowTitle(3,"TR")
50 AIntTable.SetRowUnit(3,"$")
51 c=["C1","C2","C3","C4","C5","C6","C7","C8","C9","C10"]
52 AIntTable.SetColumnTitles(c)
54 # >>> Creating object with Table of real =====================================
55 myTRealObject = myBuilder.NewObject(myComponent)
56 AName = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeName")
57 AName.SetValue("Table Of Real")
58 ARealTable = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeTableOfReal")
65 ARealTable.AddRow(k.values())
66 ARealTable.SetRowTitle(1, "Row 0")
67 ARealTable.SetRowUnit(1, "Hz")
68 ARealTable.SetColumnTitles(l.values())
72 k[j] = math.log10(j*30*math.pi/180) * 20 + i * 15 + j*5
74 k[j] = math.sin(j*30*math.pi/180) * 20 + i * 15 + j*5
75 ARealTable.AddRow(k.values())
76 ARealTable.SetRowTitle(i+1, "Row " + str(i))
77 ARealTable.SetRowUnit(i+1, "Wt")
78 ARealTable.SetTitle("TEST table of real")
80 # >>> Creating object with integer attribute =================================
81 myIntObject = myBuilder.NewObject(myComponent)
82 AName = myBuilder.FindOrCreateAttribute(myIntObject, "AttributeName")
83 AName.SetValue("Integer")
84 AInt = myBuilder.FindOrCreateAttribute(myIntObject, "AttributeInteger")
87 # >>> Creating object with real attribute ====================================
88 myRealObject = myBuilder.NewObject(myComponent)
89 AName = myBuilder.FindOrCreateAttribute(myRealObject, "AttributeName")
90 AName.SetValue("Real")
91 AReal = myBuilder.FindOrCreateAttribute(myRealObject, "AttributeReal")
92 AReal.SetValue(-56.9634)
94 # >>> Creating object with comment attribute =================================
95 myCmtObject = myBuilder.NewObject(myComponent)
96 AName = myBuilder.FindOrCreateAttribute(myCmtObject, "AttributeName")
97 AName.SetValue("Comment")
98 ACmt = myBuilder.FindOrCreateAttribute(myCmtObject, "AttributeComment")
99 ACmt.SetValue("Just a comment")
101 # >>> Create VISU presentable objects ========================================
102 # >>> Create table of real
103 myVisuTableReal = myVisu.CreateTable( myTRealObject.GetID() )
106 myCurve1 = myVisu.CreateCurve( myVisuTableReal, 1, 2 )
107 myCurve2 = myVisu.CreateCurve( myVisuTableReal, 1, 3 )
108 myCurve3 = myVisu.CreateCurve( myVisuTableReal, 1, 4 )
109 myCurve4 = myVisu.CreateCurve( myVisuTableReal, 1, 6 )
110 myCurve5 = myVisu.CreateCurve( myVisuTableReal, 1, 8 )
111 myCurve6 = myVisu.CreateCurve( myVisuTableReal, 1, 11 )
113 # >>> Set curve parameters
114 myCurve4.SetMarker( VISU.Curve.RECTANGLE )
115 myCurve4.SetLine( VISU.Curve.DASHLINE, 3 )
116 myCurve4.SetColor( SALOMEDS.Color(0, 0.7, 0.3) )
117 myCurve6.SetMarker( VISU.Curve.LTRIANGLE )
118 myCurve6.SetLine( VISU.Curve.DOTLINE, 2 )
119 myCurve6.SetColor( SALOMEDS.Color(0.2, 0.2, 0.9) )
121 # >>> Create container and insert curves
122 myContainer1 = myVisu.CreateContainer()
123 myContainer1.AddCurve(myCurve1)
124 myContainer1.AddCurve(myCurve2)
125 myContainer1.AddCurve(myCurve3)
126 myContainer1.AddCurve(myCurve4)
127 myContainer1.AddCurve(myCurve5)
128 myContainer1.AddCurve(myCurve6)
130 # >>> Create container and insert curves
131 myContainer2 = myVisu.CreateContainer()
132 myContainer2.AddCurve(myCurve4)
134 # >>> Create table of integer
135 myVisuTableInt = myVisu.CreateTable( myTIntObject.GetID() )
138 myCurve101 = myVisu.CreateCurve( myVisuTableInt, 1, 1 )
139 myCurve102 = myVisu.CreateCurve( myVisuTableInt, 1, 3 )
141 # >>> Set curve parameters
142 myCurve101.SetMarker( VISU.Curve.RECTANGLE )
143 myCurve101.SetLine( VISU.Curve.DASHLINE, 3 )
144 myCurve101.SetColor( SALOMEDS.Color(0, 0.7, 0.3) )
145 myCurve101.SetTitle( "Very useful data" )
147 # >>> Create container and insert curves
148 myContainer3 = myVisu.CreateContainer()
149 myContainer3.AddCurve(myCurve101)
150 myContainer3.AddCurve(myCurve102)
152 # >>> Updating Object Browser ================================================
153 salome.sg.updateObjBrowser(1)
155 # ============================================================================