1 # Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # Create a table and show it in Plot2d viewer
22 # This script is equivalent to script VISU_SWIG/visu_big_table.py
28 #from visu_gui import *
30 # >>> Getting study builder ==================================================
31 myStudy = salome.myStudy
32 myBuilder = myStudy.NewBuilder()
34 # >>> Getting (loading) VISU component =======================================
35 myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU")
36 myComponent = myStudy.FindComponent("VISU")
37 myVisu.SetCurrentStudy(myStudy)
39 myComponent = myBuilder.NewComponent("VISU")
40 aName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName")
41 aName.SetValue( salome.sg.getComponentUserName("VISU") )
43 A2 = myBuilder.FindOrCreateAttribute(myComponent, "AttributePixMap");
44 aPixmap = A2._narrow(SALOMEDS.AttributePixMap);
45 aPixmap.SetPixMap( "ICON_OBJBROWSER_Visu" );
47 myBuilder.DefineComponentInstance(myComponent,myVisu)
49 # >>> Creating object with Table of real[ 200 * 20 ] =========================
50 myTRealObject = myBuilder.NewObject(myComponent)
51 AName = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeName")
52 AName.SetValue("Table Of Real")
53 ARealTable = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeTableOfReal")
58 for j in range(0,myHorNb):
60 ARealTable.AddRow(k.values())
61 ARealTable.SetRowTitle(1, "Frequency")
62 ARealTable.SetRowUnit(1, "Hz")
64 for i in range(1,myVerNb+1):
65 for j in range(0,myHorNb):
67 k[j] = math.log10(j*30*math.pi/180) * 20 + i * 15 + j*5
69 k[j] = math.sin(j*30*math.pi/180) * 20 + i * 15 + j*5
70 ARealTable.AddRow(k.values())
71 ARealTable.SetRowTitle(i+1, "Power " + str(i))
72 ARealTable.SetRowUnit(i+1, "Wt")
74 ARealTable.SetTitle("Very useful data")
76 # >>> Create Visu table ======================================================
77 myVisuTableReal = myVisu.CreateTable( myTRealObject.GetID() )
79 # >>> Create container and insert curves
80 myContainer = myVisu.CreateContainer()
82 # >>> Create curves ==========================================================
83 for i in range(1,myVerNb+1):
84 myCurve = myVisu.CreateCurve( myVisuTableReal, 1, i+1 )
85 myContainer.AddCurve(myCurve)
87 # >>> Updating Object Browser ================================================
88 salome.sg.updateObjBrowser(1)
90 # >>> Display curves in Plot2d viewer ========================================
91 myViewManager = myVisu.GetViewManager();
92 myView = myViewManager.CreateXYPlot();
93 myView.SetTitle("The viewer for Curves from the Table")
94 myView.Display(myContainer)
96 # ============================================================================