]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_SWIG/VISU_Example_06.py
Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[modules/visu.git] / src / VISU_SWIG / VISU_Example_06.py
1 #  Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 #
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.
8 #
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.
13 #
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
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20 # Import a table from file and show it in Plot2d viewer
21
22 import salome
23 import math
24 import SALOMEDS
25 import VISU
26 from visu_gui import *
27
28 # >>> Getting study builder ==================================================
29 myStudy = salome.myStudy
30 myBuilder = myStudy.NewBuilder()
31
32 # >>> Getting (loading) VISU component =======================================
33 myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU")
34 myComponent = myStudy.FindComponent("VISU")
35 myVisu.SetCurrentStudy(myStudy)
36 if not myComponent:
37    myComponent = myBuilder.NewComponent("VISU")
38    aName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName")
39    #aName.SetValue("Visu")
40    aName.SetValue( salome.sg.getComponentUserName("VISU") )
41    
42    A2 = myBuilder.FindOrCreateAttribute(myComponent, "AttributePixMap");
43    aPixmap = A2._narrow(SALOMEDS.AttributePixMap);
44    aPixmap.SetPixMap( "ICON_OBJBROWSER_Visu" );
45    
46    myBuilder.DefineComponentInstance(myComponent,myVisu)
47
48 # >>> Import a tables from a file ============================================
49 aFileName = os.getenv("DATA_DIR") + "/Tables/tables_test.xls"
50 sobj = myVisu.ImportTables(aFileName)
51
52 # >>> Create container and insert curves =====================================
53 myContainer = myVisu.CreateContainer()
54
55 chiter = myStudy.NewChildIterator(sobj)
56 while chiter.More():
57   sobj_table = chiter.Value()
58
59   # >>> Create Visu table ====================================================
60   myVisuTableReal = myVisu.CreateTable(sobj_table.GetID())
61
62   nbRows = myVisuTableReal.GetNbRows()
63
64   # >>> Create curves ========================================================
65   for i in range(1, nbRows):
66     myCurve = myVisu.CreateCurve(myVisuTableReal, 1, i+1)
67     myContainer.AddCurve(myCurve)
68
69   chiter.Next()
70
71 # >>> Updating Object Browser ================================================
72 salome.sg.updateObjBrowser(1)
73
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)
79
80 # ============================================================================