X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FVISU_SWIG%2Fbatchmode_visu.py;h=f74b353644a70129d538d1c03df670acb1be435f;hb=d90eeb25287fa1f390fe7a336547e74161708e44;hp=06dd539c5dcf361e8250669b302ea4ae346afcf8;hpb=59a951f6d25e45e0587e4e97be93743b2e7bf646;p=modules%2Fvisu.git diff --git a/src/VISU_SWIG/batchmode_visu.py b/src/VISU_SWIG/batchmode_visu.py index 06dd539c..f74b3536 100644 --- a/src/VISU_SWIG/batchmode_visu.py +++ b/src/VISU_SWIG/batchmode_visu.py @@ -1,70 +1,92 @@ -import os -import SALOME_MED -import batchmode_salome -from omniORB import CORBA -import SALOMEDS +# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +# VISU VISU_SWIG : binding of C++ implementation and Python +# File : batchmode_visu.py +# Module : VISU +# +from batchmode_salome import * +import visu -mySession = batchmode_salome.naming_service.Resolve("/Kernel/Session") -mySession.GetInterface() -myVisu = batchmode_salome.lcc.FindOrLoadComponent("FactoryServer", "VISU") +myVisu = visu.Initialize(orb,naming_service,lcc,myStudyManager,myStudy,10) +if myVisu is None: + raise RuntimeError, "myVisu is none, VISU component is not loaded or found" -def getMedObjectFromStudy(): - mySO = batchmode_salome.myStudy.FindObject("Objet MED") - anAttr = mySO.FindAttribute("AttributeIOR")[1] - obj = batchmode_salome.orb.string_to_object(anAttr.Value()) - myObj = obj._narrow(SALOME_MED.MED) - return myObj +def try_mesh_parameters(theMeshPattern): + aResult = [] + if theMeshPattern is None : return aResult ; + theMeshPattern = theMeshPattern._narrow(VISU.Mesh) + if theMeshPattern is None : return aResult ; -def getFieldObjectFromStudy(number,subnumber): - mySO = batchmode_salome.myStudy.FindObject("MEDFIELD") - if mySO is None: - raise Runtime, "getFieldObjectFromStudy mySO is None" - mysub = mySO.FindSubObject(number)[1] - if mysub: - mysubsub = mysub.FindSubObject(subnumber)[1] - if mysubsub: - Builder = batchmode_salome.myStudy.NewBuilder() - anAttr = Builder.FindOrCreateAttribute(mysubsub, "AttributeIOR") - obj = batchmode_salome.orb.string_to_object(anAttr.Value()) - myObj = obj._narrow(SALOME_MED.FIELDINT) - if (myObj == None): - myObj = obj._narrow(SALOME_MED.FIELDDOUBLE) - return myObj - else: - print "ERROR: No Field Object stored in this Study" - return None + aTYPES = [VISU.POINT, VISU.WIREFRAME, VISU.SHADED, VISU.INSIDEFRAME, VISU.SHRINK] + import copy; import os; + for ind in aTYPES: + aNewMesh = copy.deepcopy(theMeshPattern); + aNewMesh.SetPresentationType(ind) + aResult.append(aNewMesh) + return aResult + +def try_scalarmap_parameters(thePattern, theNum): + aList = [] + if thePattern is None : return aList + thePattern = thePattern._narrow(VISU.ScalarMap) + if thePattern is None : return aList + SCALING = [VISU.LINEAR, VISU.LOGARITHMIC] + import copy + import random + for ind in range(0,theNum): + anObj = copy.deepcopy(thePattern); + if ind%2 : + #try incorrect value deliberately (but allowed by idl description) + #try SetScalarMode(long) + mode = random.randint(-100000,100000); #incorrect value deliberately + else: + #correct value of ScalarMode + mode = random.randint(0, 3) + print "\tSetScalarMode(" + str(mode) +")" + anObj.SetScalarMode(mode) -def SObjectToObject(theSObject) : - if theSObject is None : - print "SObjectToObject : argument is None" - anObj = None - res,Attr = theSObject.FindAttribute("AttributeIOR") - if (res != 0) and (Attr is not None) : - anIOR = Attr._narrow(SALOMEDS.AttributeIOR); - aValue = anIOR.Value(); - if(len(aValue) != 0) : - anObj = orb.string_to_object(aValue); - else: - print "SObjectToObject - IOR = ''" - return anObj; - -med_comp = batchmode_salome.lcc.FindOrLoadComponent("FactoryServer", "Med") - - -#med_obj = getMedObjectFromStudy() - -#myBuilder = batchmode_salome.myStudy.NewBuilder() -#father = batchmode_salome.myStudy.FindComponent("VISU") -#myVisu.SetCurrentStudy(batchmode_salome.myStudy) -#father = batchmode_salome.myStudy.FindComponent("VISU") -#if father is None: -# father = myBuilder.NewComponent("VISU") -# A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName"); -# FName = A1._narrow(SALOMEDS.AttributeName) -# FName.SetValue("Visu") -# A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap"); -# aPixmap = A2._narrow(SALOMEDS.AttributePixMap); -# aPixmap.SetPixMap( "ICON_OBJBROWSER_Visu" ); -# myBuilder.DefineComponentInstance(father,myVisu) + # --- SCALING --- + scal = random.randint(0,1) + print "\tSetScaling(" + str(SCALING[scal]) +")" + anObj.SetScaling(SCALING[scal]) + + # --- BOUNDARIES --- + if ind%2 : + alfa = random.random()*random.randint(-100000,100000) + betta = random.random()*random.randint(-100000,100000) + aMin = alfa; aMax = betta + else: + #more correct set + aPMin = thePattern.GetMin() + aPMax = thePattern.GetMax() + aLen = aPMax - aPMin + alfa = random.random()%0.5 + betta = random.random()%0.5 + aMin = alfa*aLen*random.randint(-1,1) + aPMin + aMax = betta*aLen*random.randint(-1,1) + aPMax + print "\tSetRange(" + str(aMin) + ", " + str(aMax) + ")" + anObj.SetRange(aMin, aMax) + aList.append(anObj) + + return aList