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 aName.SetValue( salome.sg.getComponentUserName("VISU") )
31 A2 = myBuilder.FindOrCreateAttribute(myComponent, "AttributePixMap");
32 aPixmap = A2._narrow(SALOMEDS.AttributePixMap);
33 aPixmap.SetPixMap( "ICON_OBJBROWSER_Visu" );
35 myBuilder.DefineComponentInstance(myComponent,myVisu)
37 # >>> Creating object with Table of integer ==================================
38 myTIntObject = myBuilder.NewObject(myComponent)
39 AName = myBuilder.FindOrCreateAttribute(myTIntObject, "AttributeName")
40 AName.SetValue("Table Of Integer")
41 AIntTable = myBuilder.FindOrCreateAttribute(myTIntObject, "AttributeTableOfInteger")
43 a=[1,2,3,4,5,6,7,8,9,10]
45 a=[110,120,130,140,150,160,170,180,190,200]
47 a=[-1,272,0,0,-642,10000,13,578,-578,99]
49 AIntTable.SetTitle("TEST table of integer")
50 AIntTable.SetRowTitle(1,"FR")
51 AIntTable.SetRowUnit(1,"m/h")
52 AIntTable.SetRowTitle(2,"SR")
53 AIntTable.SetRowUnit(2,"s")
54 AIntTable.SetRowTitle(3,"TR")
55 AIntTable.SetRowUnit(3,"$")
56 c=["C1","C2","C3","C4","C5","C6","C7","C8","C9","C10"]
57 AIntTable.SetColumnTitles(c)
59 # >>> Creating object with Table of real =====================================
60 myTRealObject = myBuilder.NewObject(myComponent)
61 AName = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeName")
62 AName.SetValue("Table Of Real")
63 ARealTable = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeTableOfReal")
70 ARealTable.AddRow(k.values())
71 ARealTable.SetRowTitle(1, "Row 0")
72 ARealTable.SetRowUnit(1, "Hz")
73 ARealTable.SetColumnTitles(l.values())
77 k[j] = math.log10(j*30*math.pi/180) * 20 + i * 15 + j*5
79 k[j] = math.sin(j*30*math.pi/180) * 20 + i * 15 + j*5
80 ARealTable.AddRow(k.values())
81 ARealTable.SetRowTitle(i+1, "Row " + str(i))
82 ARealTable.SetRowUnit(i+1, "Wt")
83 ARealTable.SetTitle("TEST table of real")
85 # >>> Creating object with integer attribute =================================
86 myIntObject = myBuilder.NewObject(myComponent)
87 AName = myBuilder.FindOrCreateAttribute(myIntObject, "AttributeName")
88 AName.SetValue("Integer")
89 AInt = myBuilder.FindOrCreateAttribute(myIntObject, "AttributeInteger")
92 # >>> Creating object with real attribute ====================================
93 myRealObject = myBuilder.NewObject(myComponent)
94 AName = myBuilder.FindOrCreateAttribute(myRealObject, "AttributeName")
95 AName.SetValue("Real")
96 AReal = myBuilder.FindOrCreateAttribute(myRealObject, "AttributeReal")
97 AReal.SetValue(-56.9634)
99 # >>> Creating object with comment attribute =================================
100 myCmtObject = myBuilder.NewObject(myComponent)
101 AName = myBuilder.FindOrCreateAttribute(myCmtObject, "AttributeName")
102 AName.SetValue("Comment")
103 ACmt = myBuilder.FindOrCreateAttribute(myCmtObject, "AttributeComment")
104 ACmt.SetValue("Just a comment")
106 # >>> Create VISU presentable objects ========================================
107 # >>> Create table of real
108 myVisuTableReal = myVisu.CreateTable( myTRealObject.GetID() )
111 myCurve1 = myVisu.CreateCurve( myVisuTableReal, 1, 2 )
112 myCurve2 = myVisu.CreateCurve( myVisuTableReal, 1, 3 )
113 myCurve3 = myVisu.CreateCurve( myVisuTableReal, 1, 4 )
114 myCurve4 = myVisu.CreateCurve( myVisuTableReal, 1, 6 )
115 myCurve5 = myVisu.CreateCurve( myVisuTableReal, 1, 8 )
116 myCurve6 = myVisu.CreateCurve( myVisuTableReal, 1, 11 )
118 # >>> Set curve parameters
119 myCurve4.SetMarker( VISU.Curve.RECTANGLE )
120 myCurve4.SetLine( VISU.Curve.DASHLINE, 3 )
121 myCurve4.SetColor( SALOMEDS.Color(0, 0.7, 0.3) )
122 myCurve6.SetMarker( VISU.Curve.LTRIANGLE )
123 myCurve6.SetLine( VISU.Curve.DOTLINE, 2 )
124 myCurve6.SetColor( SALOMEDS.Color(0.2, 0.2, 0.9) )
126 # >>> Create container and insert curves
127 myContainer1 = myVisu.CreateContainer()
128 myContainer1.AddCurve(myCurve1)
129 myContainer1.AddCurve(myCurve2)
130 myContainer1.AddCurve(myCurve3)
131 myContainer1.AddCurve(myCurve4)
132 myContainer1.AddCurve(myCurve5)
133 myContainer1.AddCurve(myCurve6)
135 # >>> Create container and insert curves
136 myContainer2 = myVisu.CreateContainer()
137 myContainer2.AddCurve(myCurve4)
139 # >>> Create table of integer
140 myVisuTableInt = myVisu.CreateTable( myTIntObject.GetID() )
143 myCurve101 = myVisu.CreateCurve( myVisuTableInt, 1, 1 )
144 myCurve102 = myVisu.CreateCurve( myVisuTableInt, 1, 3 )
146 # >>> Set curve parameters
147 myCurve101.SetMarker( VISU.Curve.RECTANGLE )
148 myCurve101.SetLine( VISU.Curve.DASHLINE, 3 )
149 myCurve101.SetColor( SALOMEDS.Color(0, 0.7, 0.3) )
150 myCurve101.SetTitle( "Very useful data" )
152 # >>> Create container and insert curves
153 myContainer3 = myVisu.CreateContainer()
154 myContainer3.AddCurve(myCurve101)
155 myContainer3.AddCurve(myCurve102)
157 # >>> Updating Object Browser ================================================
158 salome.sg.updateObjBrowser(1)
160 # ============================================================================