]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_SWIG/visu_table.py
Salome HOME
This commit was generated by cvs2git to track changes on a CVS vendor
[modules/visu.git] / src / VISU_SWIG / visu_table.py
1 #==============================================================================
2 #  File      : visu_table.py
3 #  Created   : 20/01/03
4 #  Author    : Vadim SANDLER
5 #  Project   : SALOME
6 #  Copyright : Open CASCADE
7 #  $Header$
8 #==============================================================================
9
10 # ============================================================================
11 # Check attributes creation : Integer, Real, Comment, Tables
12 # ============================================================================
13 import salome
14 import math
15 import SALOMEDS
16 import VISU
17
18 # >>> Getting study builder ==================================================
19 myStudy = salome.myStudy
20 myBuilder = myStudy.NewBuilder()
21
22 # >>> Getting (loading) VISU component =======================================
23 myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU")
24 myComponent = myStudy.FindComponent("VISU")
25 myVisu.SetCurrentStudy(myStudy)
26 if not myComponent:
27    myComponent = myBuilder.NewComponent("VISU")
28    aName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName")
29    aName.SetValue( salome.sg.getComponentUserName("VISU") )
30    myBuilder.DefineComponentInstance(myComponent,myVisu)
31
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")
37
38 a=[1,2,3,4,5,6,7,8,9,10]
39 AIntTable.AddRow(a)
40 a=[110,120,130,140,150,160,170,180,190,200]
41 AIntTable.AddRow(a)
42 a=[-1,272,0,0,-642,10000,13,578,-578,99]
43 AIntTable.AddRow(a)
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)
53
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")
59
60 k={}
61 l={}
62 for j in range(0,20):
63    k[j] = j*10+1
64    l[j] = "C"+str(j+1)
65 ARealTable.AddRow(k.values())
66 ARealTable.SetRowTitle(1, "Row 0")
67 ARealTable.SetRowUnit(1, "Hz")
68 ARealTable.SetColumnTitles(l.values())
69 for i in range(1,11):
70    for j in range(1,21):
71       if j % 2 == 1:
72          k[j] = math.log10(j*30*math.pi/180) * 20 + i * 15 + j*5
73       else:
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")
79
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")
85 AInt.SetValue(123)
86
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)
93
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")
100
101 # >>> Create VISU presentable objects ========================================
102 # >>> Create table of real
103 myVisuTableReal = myVisu.CreateTable( myTRealObject.GetID() )
104
105 # >>> Create curves
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 )
112
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) )
120
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)
129
130 # >>> Create container and insert curves
131 myContainer2 = myVisu.CreateContainer()
132 myContainer2.AddCurve(myCurve4)
133
134 # >>> Create table of integer
135 myVisuTableInt = myVisu.CreateTable( myTIntObject.GetID() )
136
137 # >>> Create curves
138 myCurve101 = myVisu.CreateCurve( myVisuTableInt, 1, 1 )
139 myCurve102 = myVisu.CreateCurve( myVisuTableInt, 1, 3 )
140
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" )
146
147 # >>> Create container and insert curves
148 myContainer3 = myVisu.CreateContainer()
149 myContainer3.AddCurve(myCurve101)
150 myContainer3.AddCurve(myCurve102)
151
152 # >>> Updating Object Browser ================================================
153 salome.sg.updateObjBrowser(1)
154
155 # ============================================================================
156
157
158