Back to index

salome-gui  6.5.0
test_big_table.py
Go to the documentation of this file.
00001 #  -*- coding: iso-8859-1 -*-
00002 # Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00003 #
00004 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00005 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00006 #
00007 # This library is free software; you can redistribute it and/or
00008 # modify it under the terms of the GNU Lesser General Public
00009 # License as published by the Free Software Foundation; either
00010 # version 2.1 of the License.
00011 #
00012 # This library is distributed in the hope that it will be useful,
00013 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 # Lesser General Public License for more details.
00016 #
00017 # You should have received a copy of the GNU Lesser General Public
00018 # License along with this library; if not, write to the Free Software
00019 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00020 #
00021 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00022 #
00023 
00024 # File   : test_big_table.py
00025 # Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
00026 #
00027 import salome
00028 import math
00029 import SALOMEDS
00030 
00031 # >>> Getting study builder ==================================================
00032 myStudy = salome.myStudy
00033 myBuilder = myStudy.NewBuilder()
00034 
00035 # >>> Creating virtual component =============================================
00036 myComponent = myStudy.FindComponent("VirtualComponent")
00037 if not myComponent:
00038    myComponent = myBuilder.NewComponent("VirtualComponent")
00039    aName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName")
00040    aName.SetValue("VirtualComponent")
00041 
00042 # >>> Creating object with Table of real[ 200 * 20 ] ========================
00043 myTRealObject = myBuilder.NewObject(myComponent)
00044 AName = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeName")
00045 AName.SetValue("Table Of Real")
00046 ARealTable = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeTableOfReal")
00047 myHorNb = 10
00048 myVerNb = 200
00049 
00050 k={}
00051 for j in range(0,myHorNb):
00052    k[j] = j*10+1
00053 ARealTable.AddRow(k.values())
00054 ARealTable.SetRowTitle(1, "Frequency")
00055 ARealTable.SetRowUnit(1, "Hz")
00056 
00057 for i in range(1,myVerNb+1):
00058    for j in range(0,myHorNb):
00059       if j % 2 == 1:
00060          k[j] = math.log10(j*30*math.pi/180) * 20 + i * 15 + j*5
00061       else:
00062          k[j] = math.sin(j*30*math.pi/180) * 20 + i * 15 + j*5 
00063    ARealTable.AddRow(k.values())
00064    ARealTable.SetRowTitle(i+1, "Power " + str(i))
00065    ARealTable.SetRowUnit(i+1, "Wt")
00066 ARealTable.SetTitle("Very useful data")
00067 
00068 # >>> Updating Object Browser ================================================
00069 salome.sg.updateObjBrowser(1)
00070 
00071 # ============================================================================