1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
4 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 # Import a table from file and show it in Plot2d viewer
30 from visu_gui import *
32 # >>> Getting study builder ==================================================
33 myStudy = salome.myStudy
34 myBuilder = myStudy.NewBuilder()
36 # >>> Getting (loading) VISU component =======================================
37 myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU")
38 myComponent = myStudy.FindComponent("VISU")
39 myVisu.SetCurrentStudy(myStudy)
41 myComponent = myBuilder.NewComponent("VISU")
42 aName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName")
43 #aName.SetValue("Visu")
44 aName.SetValue( salome.sg.getComponentUserName("VISU") )
46 A2 = myBuilder.FindOrCreateAttribute(myComponent, "AttributePixMap");
47 aPixmap = A2._narrow(SALOMEDS.AttributePixMap);
48 aPixmap.SetPixMap( "ICON_OBJBROWSER_Visu" );
50 myBuilder.DefineComponentInstance(myComponent,myVisu)
52 # >>> Import a tables from a file ============================================
53 aFileName = os.getenv("DATA_DIR") + "/Tables/tables_test.xls"
54 sobj = myVisu.ImportTables(aFileName, False)
56 # >>> Create container and insert curves =====================================
57 myContainer = myVisu.CreateContainer()
59 chiter = myStudy.NewChildIterator(sobj)
61 sobj_table = chiter.Value()
63 # >>> Create Visu table ====================================================
64 myVisuTableReal = myVisu.CreateTable(sobj_table.GetID())
66 nbRows = myVisuTableReal.GetNbRows()
68 # >>> Create curves ========================================================
69 for i in range(1, nbRows):
70 myCurve = myVisu.CreateCurve(myVisuTableReal, 1, i+1)
71 myContainer.AddCurve(myCurve)
75 # >>> Updating Object Browser ================================================
76 salome.sg.updateObjBrowser(1)
78 # >>> Display curves in Plot2d viewer ========================================
79 myViewManager = myVisu.GetViewManager();
80 myView = myViewManager.CreateXYPlot();
81 myView.SetTitle("The viewer for Curves from the Table")
82 myView.Display(myContainer)
84 # ============================================================================