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 # Import a table from file and show it in Plot2d viewer
26 from visu_gui import *
28 # >>> Getting study builder ==================================================
29 myStudy = salome.myStudy
30 myBuilder = myStudy.NewBuilder()
32 # >>> Getting (loading) VISU component =======================================
33 myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU")
34 myComponent = myStudy.FindComponent("VISU")
35 myVisu.SetCurrentStudy(myStudy)
37 myComponent = myBuilder.NewComponent("VISU")
38 aName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName")
39 #aName.SetValue("Visu")
40 aName.SetValue( salome.sg.getComponentUserName("VISU") )
42 A2 = myBuilder.FindOrCreateAttribute(myComponent, "AttributePixMap");
43 aPixmap = A2._narrow(SALOMEDS.AttributePixMap);
44 aPixmap.SetPixMap( "ICON_OBJBROWSER_Visu" );
46 myBuilder.DefineComponentInstance(myComponent,myVisu)
48 # >>> Import a tables from a file ============================================
49 aFileName = os.getenv("DATA_DIR") + "/Tables/tables_test.xls"
50 sobj = myVisu.ImportTables(aFileName)
52 # >>> Create container and insert curves =====================================
53 myContainer = myVisu.CreateContainer()
55 chiter = myStudy.NewChildIterator(sobj)
57 sobj_table = chiter.Value()
59 # >>> Create Visu table ====================================================
60 myVisuTableReal = myVisu.CreateTable(sobj_table.GetID())
62 nbRows = myVisuTableReal.GetNbRows()
64 # >>> Create curves ========================================================
65 for i in range(1, nbRows):
66 myCurve = myVisu.CreateCurve(myVisuTableReal, 1, i+1)
67 myContainer.AddCurve(myCurve)
71 # >>> Updating Object Browser ================================================
72 salome.sg.updateObjBrowser(1)
74 # >>> Display curves in Plot2d viewer ========================================
75 myViewManager = myVisu.GetViewManager();
76 myView = myViewManager.CreateXYPlot();
77 myView.SetTitle("The viewer for Curves from the Table")
78 myView.Display(myContainer)
80 # ============================================================================