1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
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
21 # Displaying curves attached to different Y axes of Plot2d view
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
50 aTableObject = myBuilder.NewObject(myComponent)
51 aTableName = myBuilder.FindOrCreateAttribute(aTableObject, "AttributeName")
52 aTableName.SetValue("TestTable")
53 aTable = myBuilder.FindOrCreateAttribute(aTableObject, "AttributeTableOfReal")
55 aTable.AddRow([0,1,2,3,4,5,6,7,8,9,10])
56 aTable.AddRow([2000,1900,1800,1700,1600,1500,1400,1300,1200,1100,1000])
57 aTable.AddRow([1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0])
58 aTable.SetTitle("Test table")
59 aTable.SetRowTitle(1,"Time")
60 aTable.SetRowUnit(1,"s")
61 aTable.SetRowTitle(2,"Mass")
62 aTable.SetRowUnit(2,"kg")
63 aTable.SetRowTitle(3,"Temperature")
64 aTable.SetRowUnit(3,"K")
66 # >>> Create table of integer
67 aVisuTable = myVisu.CreateTable(aTableObject.GetID())
69 # >>> Create curve attached to the left axis
70 aCurve1 = myVisu.CreateCurveWithZExt(aVisuTable, 1, 2, 0, False)
72 # >>> Create curve attached to the right axis
73 aCurve2 = myVisu.CreateCurveWithZExt(aVisuTable, 1, 3, 1, True)
75 # >>> Create container and insert curves
76 aContainer = myVisu.CreateContainer()
77 aContainer.AddCurve(aCurve1)
78 aContainer.AddCurve(aCurve2)
80 # >>> Create XY plot and display container
81 myViewManager = myVisu.GetViewManager();
82 myView = myViewManager.CreateXYPlot();
83 myView.SetTitle("The viewer for curves")
84 myView.Display(aContainer)
86 # >>> Update Object Browser
87 salome.sg.updateObjBrowser(1)