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