]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_SWIG/visu.py
Salome HOME
50a3aea739d6af62e8c3be54ce245eb3da19b658
[modules/visu.git] / src / VISU_SWIG / visu.py
1 #  -*- coding: iso-8859-1 -*-
2 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
3 #
4 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 #
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.
11 #
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.
16 #
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
20 #
21 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #
23 #  VISU VISU_SWIG : binding of C++ implementation and Python
24 #  File   : visu.py
25 #  Module : VISU
26 #
27 import os
28 import re
29 from time import sleep
30
31 import VISU
32 import SALOME
33 import SALOME_Session_idl
34 import SALOMEDS
35 import SALOME_MED
36 import SALOME_ModuleCatalog
37 from omniORB import CORBA
38 from string import *
39 from time import sleep
40
41 myORB = None
42 myNamingService = None
43 myLifeCycleCORBA = None
44 myNamingService = None
45 myLocalStudyManager = None
46 myLocalStudy = None
47 myLocalVisu = None
48 myDelay = None
49 mySession = None
50  
51 def Initialize(theORB, theNamingService, theLifeCycleCORBA, theStudyManager, theStudy, theDelay) :
52     global myORB, myNamingService, myLifeCycleCORBA, myLocalStudyManager, myLocalStudy
53     global mySession, myLocalVisu, myDelay
54     myDelay = theDelay
55     myORB = theORB
56     myNamingService = theNamingService
57     myLifeCycleCORBA = theLifeCycleCORBA
58     myLocalStudyManager = theStudyManager
59     while mySession == None:
60         mySession = myNamingService.Resolve("/Kernel/Session")
61     mySession = mySession._narrow(SALOME.Session)
62     mySession.GetInterface()
63     myDelay = theDelay
64     sleep(myDelay)
65     myLocalVisu = myLifeCycleCORBA.FindOrLoadComponent("FactoryServer", "VISU")
66     myLocalStudy = theStudy
67     myLocalVisu.SetCurrentStudy(myLocalStudy)
68     return myLocalVisu
69
70 def PublishComponent(theStudyDocument):
71     aComponentDataType = myLocalVisu.ComponentDataType()
72     aSComponent = theStudyDocument.FindComponent(aComponentDataType)
73     if aSComponent == None:
74         aStudyBuilder = theStudyDocument.NewBuilder()
75         aStudyBuilder.NewCommand()
76         aLocked = theStudyDocument.GetProperties().IsLocked()
77         if aLocked:
78             theStudyDocument.GetProperties().SetLocked(0)
79             pass
80
81         aSComponent = aStudyBuilder.NewComponent(aComponentDataType);
82         aName = aStudyBuilder.FindOrCreateAttribute(aSComponent,"AttributeName")
83         aModuleCatalogObj = myNamingService.Resolve("/Kernel/ModulCatalog");
84         aModuleCatalog = aModuleCatalogObj._narrow(SALOME_ModuleCatalog.ModuleCatalog)
85         aComponent = aModuleCatalog.GetComponent(aComponentDataType);
86         if aComponent != None:
87             aComponentUserName = aComponent._get_componentusername()
88             aName.SetValue(aComponentUserName)
89             pass
90         
91         aPixMap = aStudyBuilder.FindOrCreateAttribute(aSComponent,"AttributePixMap")
92         aPixMap.SetPixMap("ICON_OBJBROWSER_Visu")
93         
94         aStudyBuilder.DefineComponentInstance(aSComponent,myLocalVisu);
95         if aLocked:
96             theStudyDocument.GetProperties().SetLocked(1);
97             pass
98         
99         aStudyBuilder.CommitCommand();
100         pass
101     
102     return aSComponent;
103
104 def SetName(theObj, theName):
105     anIOR  = myORB.object_to_string(theObj)
106     aSObj  = myLocalStudy.FindObjectIOR(anIOR)
107     anAttr = aSObj.FindAttribute("AttributeName")[1]
108     anAttr.SetValue(theName)
109         
110 def StrToMap(theString) :
111     aPairList = split(theString,";")
112     aMap = {}
113     iEnd = len(aPairList)
114     for i in range(iEnd) :
115         aPair = split(aPairList[i],"=")
116         aMap[aPair[0]] = aPair[1]
117     return aMap
118
119 def IntToEntity(theInt) :
120     theInt = atoi(theInt)
121     if theInt == 0 :
122         return VISU.NODE;
123     elif theInt == 1 :
124         return VISU.EDGE;
125     elif theInt == 2 :
126         return VISU.FACE;
127     else :
128         return VISU.CELL;
129         
130 def HasValue(theList, theValue) :
131     try :
132         return theList.index(theValue) + 1
133     except StandardError, e :
134         return 0
135
136 def CreateStudyForMed(theVisu, theFileName) :
137     print "CreateStudyForMed ", theFileName,
138     if os.path.isfile(theFileName) :
139         if re.search("\.med$", theFileName) is not None :
140             print "OK"
141             aStudyName = os.path.basename(theFileName)
142             aStudyName = re.sub(r'\.med', "", aStudyName)
143             aStudyName = generateName(aStudyName)
144             print "myLocalStudyManager.NewStudy -", aStudyName, "...",
145             aStudy = myLocalStudyManager.NewStudy(aStudyName)
146             if aStudy is None : raise RuntimeError, "Error"
147             else : print "OK"
148             
149             print "CreateStudyForMed - Creating a 3D viewer...",
150             theVisu.SetCurrentStudy(aStudy)
151             myViewManager = theVisu.GetViewManager()
152             if myViewManager is None : raise RuntimeError, "Error - theVisu.GetViewManager"
153             myView = myViewManager.Create3DView()
154             if myView is None : raise RuntimeError, "Error - myViewManager.Create3DView"
155             myView.Maximize()
156             print "OK"
157
158             return [aStudy, myViewManager, myView]
159     raise RuntimeError, "Error: There is no such file."
160
161 def getMedSObject(theStudy = myLocalStudy ):
162     if theStudy is None:
163         theStudy = myLocalStudy
164     aSO = theStudy.FindObject("Med")
165     anIsPresetn, aSObject = aSO.FindSubObject(1)
166     return aSObject
167
168 def getMedObjectFromStudy(theStudy = myLocalStudy):
169     aSObject = getMedSObject(theStudy)
170     if aSObject:
171         anAttr = aSObject.FindAttribute("AttributeIOR")[1]
172         anObj = myORB.string_to_object(anAttr.Value())
173         return  anObj._narrow(SALOME_MED.MED)
174     return None
175
176 def getFieldObjectFromStudy(number, subnumber, theStudy = myLocalStudy):
177     if theStudy is None:
178         theStudy = myLocalStudy
179     mySO = theStudy.FindObject("MEDFIELD")
180     if mySO is None:
181         raise Runtime, "getFieldObjectFromStudy mySO is None"
182     mysub = mySO.FindSubObject(number)[1]
183     if mysub:
184         mysubsub = mysub.FindSubObject(subnumber)[1]
185         if mysubsub:
186             Builder = theStudy.NewBuilder()
187             anAttr = Builder.FindOrCreateAttribute(mysubsub, "AttributeIOR")
188             obj = myORB.string_to_object(anAttr.Value())
189             myObj = obj._narrow(SALOME_MED.FIELDINT)
190             if (myObj == None):
191                 myObj = obj._narrow(SALOME_MED.FIELDDOUBLE)
192             return myObj
193     else:
194         print "ERROR: No Field Object stored in this Study"
195         return None
196
197 def SObjectToObject(theSObject) :
198      #    global myORB
199     if theSObject is None :
200         print "SObjectToObject : argument is None"
201     anObj = None                         
202     res,Attr = theSObject.FindAttribute("AttributeIOR")
203     if (res != 0) and (Attr is not None)  : 
204       anIOR  = Attr._narrow(SALOMEDS.AttributeIOR);
205       aValue = anIOR.Value();
206       if(len(aValue) != 0) :
207         anObj = myORB.string_to_object(aValue);
208       else:
209         print "SObjectToObject - IOR = ''"
210     return anObj;
211  
212 def CreatePrsForMed(theVisu, theFileName, thePrsTypeList, thePictureDir, thePictureExt, theIsAutoDelete = 0) :
213 #    try:
214         global myLifeCycleCORBA
215         print "lcc.FindOrLoadComponent...",
216         aMedComp = myLifeCycleCORBA.FindOrLoadComponent("FactoryServer", "MED")
217         if aMedComp is None : print "Error"
218         else : print "OK"
219         
220         aVISUObjList = [myLocalStudy, myViewManager, myView] = CreateStudyForMed(theVisu, theFileName)
221
222         print "aMedComp.readStructFileWithFieldType...",
223         aMedComp.readStructFileWithFieldType(theFileName,myLocalStudy._get_Name())
224         aMedSObj = getMedSObject(myLocalStudy)
225         if aMedSObj is None : raise RuntimeError, "Error"
226         else : print "OK"
227         
228         print "theVisu.ImportMed...",
229         aResult = theVisu.ImportMed(aMedSObj)
230         if aResult is None : raise RuntimeError, "Error"
231         else : print "OK"
232
233         aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt, theIsAutoDelete))
234         if theIsAutoDelete :
235             aResult.RemoveFromStudy()
236         else :
237             aVISUObjList.append(aResult)
238         
239         aFolderIter = myLocalStudy.NewChildIterator(aMedSObj.GetFather());
240         while aFolderIter.More() :
241             aFolderSObj = aFolderIter.Value()
242             aFolderIter.Next()
243             anAttr = aFolderSObj.FindAttribute("AttributeName")[1]
244             anAttr = anAttr._narrow(SALOMEDS.AttributeName);
245             aFolderName = anAttr.Value()
246             print "  ", aFolderName
247             
248             if aFolderName == 'MEDMESH' :
249                 aMeshIter = myLocalStudy.NewChildIterator(aFolderSObj);
250                 while aMeshIter.More() :
251                     aMeshSObj = aMeshIter.Value()
252                     aMeshIter.Next()
253                     anAttr = aMeshSObj.FindAttribute("AttributeName")[1]
254                     anAttr = anAttr._narrow(SALOMEDS.AttributeName);
255                     aMeshName = anAttr.Value()
256                     print "    ", aMeshName
257                 
258                     aSupportIter = myLocalStudy.NewChildIterator(aMeshSObj);
259                     while aSupportIter.More() :
260                         aSupportSObj = aSupportIter.Value()
261                         aSupportIter.Next()
262                         anAttr = aSupportSObj.FindAttribute("AttributeName")[1]
263                         anAttr = anAttr._narrow(SALOMEDS.AttributeName);
264                         aSupportName = anAttr.Value()
265                         print "      ", aSupportName
266
267             if aFolderName == 'MEDFIELD' :
268                 aFieldIter = myLocalStudy.NewChildIterator(aFolderSObj);
269                 while aFieldIter.More() :
270                     aFieldSObj = aFieldIter.Value()
271                     aFieldIter.Next()
272                     anAttr = aFieldSObj.FindAttribute("AttributeName")[1]
273                     anAttr = anAttr._narrow(SALOMEDS.AttributeName);
274                     aFieldName = anAttr.Value()
275                     print "    ", aFieldName
276                 
277                     print "theVisu.ImportMed...",
278                     aResult = theVisu.ImportMed(aFieldSObj)
279                     if aResult is None : raise RuntimeError, "Error"
280                     else : print "OK"
281
282                     aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt, theIsAutoDelete))
283                     if theIsAutoDelete :
284                         aResult.RemoveFromStudy()
285                     else :
286                         aVISUObjList.append(aResult)
287
288                     aTimeStampIter = myLocalStudy.NewChildIterator(aFieldSObj);
289                     if aTimeStampIter.More() :
290                         aTimeStampIter.Next()
291                         while aTimeStampIter.More() :
292                             aTimeStampSObj = aTimeStampIter.Value()
293                             aTimeStampIter.Next()
294                             anAttr = aTimeStampSObj.FindAttribute("AttributeName")[1]
295                             anAttr = anAttr._narrow(SALOMEDS.AttributeName);
296                             aTimeStampName = anAttr.Value()
297                             print "        ", aTimeStampName
298
299                             print "theVisu.ImportMed...",
300                             aMedField = SObjectToObject(aTimeStampSObj)
301                             aResult = theVisu.ImportMedField(aMedField)
302                             if aResult is None : raise RuntimeError, "Error"
303                             else : print "OK"
304
305                             aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt, theIsAutoDelete))
306                             if theIsAutoDelete :
307                                 aResult.RemoveFromStudy()
308                             else :
309                                 aVISUObjList.append(aResult)
310                     
311         return aVISUObjList
312     
313 #    except Exception, e:
314 #        print str(e)
315         
316 def CreatePrsForFile(theVisu, theFileName, thePrsTypeList, thePictureDir, thePictureExt, theIsAutoDelete = 0) :
317  #   try:
318         aVISUObjList = [myLocalStudy, myViewManager, myView] = CreateStudyForMed(theVisu, theFileName)
319
320         print "theVisu.ImportMed...",
321         aResult = theVisu.ImportFile(theFileName)
322         if aResult is None : raise RuntimeError, "Error"
323         else : print "OK"
324         
325         aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt, theIsAutoDelete))
326
327         if theIsAutoDelete :
328             aResult.RemoveFromStudy()
329         else :
330             aVISUObjList.append(aResult)
331
332         return aVISUObjList
333     
334 #    except Exception, e:
335 #        print str(e)
336                 
337 def CreatePrsForResult(theVisu, theResult, theView, thePrsTypeList, thePictureDir, thePictureExt, theIsAutoDelete = 0) :
338     aVISUObjList = None
339     if theIsAutoDelete is not None :
340         aVISUObjList = []
341         pass
342         
343     print "CreatePrsForResult - myLocalStudy.FindObjectIOR...",
344     myLocalStudy = theVisu.GetCurrentStudy()
345
346     aSObj = myLocalStudy.FindObjectIOR(theResult.GetID())
347     if aSObj is None : raise RuntimeError, "Error"
348     else : print "OK"
349     aMeshIter = myLocalStudy.NewChildIterator(aSObj);
350     while aMeshIter.More() :
351         aMeshSObj = aMeshIter.Value()
352         aMeshIter.Next()
353         anAttr = aMeshSObj.FindAttribute("AttributeName")[1]
354         if anAttr is None :
355             aMeshSObj = aMeshIter.Value()
356             aMeshIter.Next()
357             anAttr = aMeshSObj.FindAttribute("AttributeName")[1]
358         anAttr = anAttr._narrow(SALOMEDS.AttributeName);
359         aMeshName = anAttr.Value()
360         aMeshNamePic = re.sub(".","_",aMeshName)
361         print "  ", aMeshName
362         
363         aFolderIter = myLocalStudy.NewChildIterator(aMeshSObj);
364         while aFolderIter.More() :
365             aFolderSObj = aFolderIter.Value()
366             aFolderIter.Next()
367             anIsFound, anAttr = aFolderSObj.FindAttribute("AttributeName")
368             if not anIsFound :
369                 continue
370             anAttr = anAttr._narrow(SALOMEDS.AttributeName);
371             aFolderName = anAttr.Value()
372             print "    ", aFolderName
373             
374             if aFolderName == 'Families' :
375                 anEntityIter = myLocalStudy.NewChildIterator(aFolderSObj);
376                 while anEntityIter.More() :
377                     anEntitySObj = anEntityIter.Value()
378                     anEntityIter.Next()
379                     anAttr = anEntitySObj.FindAttribute("AttributeName")[1]
380                     anAttr = anAttr._narrow(SALOMEDS.AttributeName);
381                     anEntityName = anAttr.Value()
382                     
383                     anEntityId = "3"
384                     if anEntityName == 'onNodes' :
385                         anEntity = VISU.NODE
386                         anEntityId = "0"
387                     if anEntityName == 'onEdges' :
388                         anEntity = VISU.EDGE
389                         anEntityId = "1"
390                     if anEntityName == 'onFaces' :
391                         anEntity = VISU.FACE
392                         anEntityId = "2"
393                     if anEntityName == 'onCells' :
394                         anEntity = VISU.CELL
395                         anEntityId = "3"
396
397                     if HasValue(thePrsTypeList,VISU.TMESH) :
398                         print "      ", anEntityName, aMeshName,
399                         aMesh = theVisu.MeshOnEntity(theResult,aMeshName,anEntity)
400                         if aMesh is None : print "Error"
401                         else :
402                             print ",OK"
403                             theView.DisplayOnly(aMesh)
404                             theView.FitAll()
405                             aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "." + thePictureExt
406                             aPictureName = re.sub("\s+","_", aPictureName);
407                             theView.SavePicture(aPictureName)
408                             if theIsAutoDelete :
409                                 aMesh.RemoveFromStudy()
410                             else :
411                                 aVISUObjList.append(aMesh)
412                         
413                         anFamilyIter = myLocalStudy.NewChildIterator(anEntitySObj);
414                         while anFamilyIter.More() :
415                             aFamilySObj = anFamilyIter.Value()
416                             anFamilyIter.Next()
417                             anAttr = aFamilySObj.FindAttribute("AttributeName")[1]
418                             anAttr = anAttr._narrow(SALOMEDS.AttributeName);
419                             anFamilyName = anAttr.Value()
420                             if HasValue(thePrsTypeList,VISU.TMESH) :
421                                 print "        ", anFamilyName,
422                                 aMesh = theVisu.FamilyMeshOnEntity(theResult,aMeshName,anEntity,anFamilyName)
423                                 if aMesh is None : print "Error"
424                                 else :
425                                     print ",OK"
426                                     theView.DisplayOnly(aMesh)
427                                     theView.FitAll()
428                                     aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + anFamilyName + "." + thePictureExt
429                                     aPictureName = re.sub("\s+","_", aPictureName);
430                                     theView.SavePicture(aPictureName)
431                                     if theIsAutoDelete :
432                                         aMesh.RemoveFromStudy()
433                                     else :
434                                         aVISUObjList.append(aMesh)
435                                 
436             if aFolderName == 'Groups' :
437                 aGroupIter = myLocalStudy.NewChildIterator(aFolderSObj);
438                 while aGroupIter.More() :
439                     aGroupSObj = aGroupIter.Value()
440                     aGroupIter.Next()
441                     anAttr = aGroupSObj.FindAttribute("AttributeName")[1]
442                     anAttr = anAttr._narrow(SALOMEDS.AttributeName);
443                     aGroupName = anAttr.Value()
444                     if HasValue(thePrsTypeList,VISU.TMESH) :
445                         print "      ", aGroupName,
446                         aMesh = theVisu.GroupMesh(theResult,aMeshName,aGroupName)
447                         if aMesh is None : print "Error"
448                         else :
449                             print ",OK"
450                             theView.DisplayOnly(aMesh)
451                             theView.FitAll()
452                             aPictureName = thePictureDir + aMeshNamePic + "_" + aGroupName + "." + thePictureExt
453                             aPictureName = re.sub("\s+","_", aPictureName);
454                             theView.SavePicture(aPictureName)
455                             if theIsAutoDelete :
456                                 aMesh.RemoveFromStudy()
457                             else :
458                                 aVISUObjList.append(aMesh)
459                         
460             if aFolderName == 'Fields' :
461                 aFieldIter = myLocalStudy.NewChildIterator(aFolderSObj);
462                 while aFieldIter.More() :
463                     aFieldSObj = aFieldIter.Value()
464                     aFieldIter.Next()
465                     anAttr = aFieldSObj.FindAttribute("AttributeName")[1]
466                     anAttr = anAttr._narrow(SALOMEDS.AttributeName);
467                     aFieldName = anAttr.Value()
468                     print "      ", aFieldName
469                     
470                     anAttr = aFieldSObj.FindAttribute("AttributeString")[1]
471                     anAttr = anAttr._narrow(SALOMEDS.AttributeString);
472                     aFieldComment = anAttr.Value()
473                     aMap = StrToMap(aFieldComment)
474                     
475                     aTimeStampIter = myLocalStudy.NewChildIterator(aFieldSObj);
476                     if aTimeStampIter.More() :
477                         aTimeStampIter.Next()
478                         while aTimeStampIter.More() :
479                             aTimeStampSObj = aTimeStampIter.Value()
480                             aTimeStampIter.Next()
481                             anAttr = aTimeStampSObj.FindAttribute("AttributeName")[1]
482                             anAttr = anAttr._narrow(SALOMEDS.AttributeName);
483                             aTimeStampName = anAttr.Value()
484                             print "        ", aTimeStampName
485                             
486                             anAttr = aTimeStampSObj.FindAttribute("AttributeString")[1]
487                             anAttr = anAttr._narrow(SALOMEDS.AttributeString);
488                             aTimeStampComment = anAttr.Value()
489                             aMap = StrToMap(aTimeStampComment)
490                             aMeshName = aMap["myMeshName"]
491                             aFieldName = aMap["myFieldName"]
492                             aTimeStampId = atoi(aMap["myTimeStampId"])
493                             anEntity = IntToEntity(aMap["myEntityId"])
494                             anEntityId = str(aMap["myEntityId"]);
495                             #print aMeshName, aFieldName, anEntity, aTimeStampId
496                             if HasValue(thePrsTypeList,VISU.TSCALARMAP) :
497                                 print "          Creating ScalarMapOnField",
498                                 aPrsObj = theVisu.ScalarMapOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
499                                 if aPrsObj is None : print "Error"
500                                 else :
501                                     print ",OK"
502                                     theView.DisplayOnly(aPrsObj)
503                                     theView.FitAll()
504                                     aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TSCALARMAP." + thePictureExt
505                                     aPictureName = re.sub("\s+","_", aPictureName);
506                                     theView.SavePicture(aPictureName)
507                                     if theIsAutoDelete :
508                                         aPrsObj.RemoveFromStudy()
509                                     else :
510                                         aVISUObjList.append(aPrsObj)
511
512                             if HasValue(thePrsTypeList,VISU.TISOSURFACES) :
513                                 print "          Creating IsoSurfacesOnField",
514                                 aPrsObj = theVisu.IsoSurfacesOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
515                                 if aPrsObj is None : print "Error"
516                                 else :
517                                     print ",OK"
518                                     theView.DisplayOnly(aPrsObj)
519                                     theView.FitAll()
520                                     aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TISOSURFACES." + thePictureExt
521                                     aPictureName = re.sub("\s+","_", aPictureName);
522                                     theView.SavePicture(aPictureName)
523                                     if theIsAutoDelete :
524                                         aPrsObj.RemoveFromStudy()
525                                     else :
526                                         aVISUObjList.append(aPrsObj)
527                                 
528                             if HasValue(thePrsTypeList,VISU.TCUTPLANES) :
529                                 print "          Creating CutPlanesOnField",
530                                 aPrsObj = theVisu.CutPlanesOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
531                                 if aPrsObj is None : print "Error"
532                                 else :
533                                     print ",OK"
534                                     aPrsObj.SetOrientation(VISU.CutPlanes.ZX,aPrsObj.GetRotateX(),aPrsObj.GetRotateY())
535                                     theView.DisplayOnly(aPrsObj)
536                                     theView.FitAll()
537                                     aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TCUTPLANES." + thePictureExt
538                                     aPictureName = re.sub("\s+","_", aPictureName)
539                                     theView.SavePicture(aPictureName)
540                                     if theIsAutoDelete :
541                                         aPrsObj.RemoveFromStudy()
542                                     else :
543                                         aVISUObjList.append(aPrsObj)
544                                 
545                             if HasValue(thePrsTypeList,VISU.TCUTLINES) :
546                                 print "          Creating CutLinesOnField",
547                                 aPrsObj = theVisu.CutLinesOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
548                                 if aPrsObj is None : print "Error"
549                                 else :
550                                     print ",OK"
551                                     aPrsObj.SetOrientation(VISU.CutPlanes.XY,aPrsObj.GetRotateX(),aPrsObj.GetRotateY())
552                                     aPrsObj.SetOrientation2(VISU.CutPlanes.ZX,aPrsObj.GetRotateX2(),aPrsObj.GetRotateY2())
553                                     theView.DisplayOnly(aPrsObj)
554                                     theView.FitAll()
555                                     aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TCUTLINES." + thePictureExt
556                                     aPictureName = re.sub("\s+","_", aPictureName)
557                                     theView.SavePicture(aPictureName)
558                                     if theIsAutoDelete :
559                                         aPrsObj.RemoveFromStudy()
560                                     else :
561                                         aVISUObjList.append(aPrsObj)
562                                 
563                             if HasValue(thePrsTypeList,VISU.TCUTSEGMENT) :
564                                 print "          Creating CutSegmentOnField",
565                                 aPrsObj = theVisu.CutSegmentOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
566                                 if aPrsObj is None : print "Error"
567                                 else :
568                                     print ",OK"
569                                     theView.DisplayOnly(aPrsObj)
570                                     theView.FitAll()
571                                     aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TCUTSEGMENT." + thePictureExt
572                                     aPictureName = re.sub("\s+","_", aPictureName)
573                                     theView.SavePicture(aPictureName)
574                                     if theIsAutoDelete :
575                                         aPrsObj.RemoveFromStudy()
576                                     else :
577                                         aVISUObjList.append(aPrsObj)
578                                 
579                             if HasValue(thePrsTypeList,VISU.TPLOT3D) :
580                                 print "          Creating Plot3DOnField",
581                                 aPrsObj = theVisu.Plot3DOnField(theResult,aMeshName,anEntity,
582                                                                 aFieldName,aTimeStampId)
583                                 if aPrsObj is None : print "Error"
584                                 else :
585                                     print ",OK"
586                                 #aPrsObj.SetOrientation(VISU.CutPlanes.ZX,
587                                 #                       aPrsObj.GetRotateX(),
588                                 #                       aPrsObj.GetRotateY())
589                                     theView.DisplayOnly(aPrsObj)
590                                     theView.FitAll()
591                                     aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TPLOT3D." + thePictureExt
592                                     aPictureName = re.sub("\s+","_", aPictureName)
593                                     theView.SavePicture(aPictureName)
594                                     if theIsAutoDelete :
595                                         aPrsObj.RemoveFromStudy()
596                                     else :
597                                         aVISUObjList.append(aPrsObj)
598                                 
599                             aNumComponent = atoi(aMap["myNumComponent"])
600                             if aNumComponent > 1 :
601                                 if HasValue(thePrsTypeList,VISU.TDEFORMEDSHAPE) :
602                                     print "          Creating DeformedShapeOnField",
603                                     aPrsObj = theVisu.DeformedShapeOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
604                                     if aPrsObj is None : print "Error"
605                                     else :
606                                         print ",OK"
607                                         theView.DisplayOnly(aPrsObj)
608                                         theView.FitAll()
609                                         aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TDEFORMEDSHAPE." + thePictureExt
610                                         aPictureName = re.sub("\s+","_", aPictureName)
611                                         theView.SavePicture(aPictureName)
612                                         if theIsAutoDelete :
613                                             aPrsObj.RemoveFromStudy()
614                                         else :
615                                             aVISUObjList.append(aPrsObj)
616
617                                 if HasValue(thePrsTypeList,VISU.TVECTORS) :
618                                     print "          Creating VectorsOnField",
619                                     aPrsObj = theVisu.VectorsOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
620                                     if aPrsObj is None : print "Error"
621                                     else :
622                                         print ",OK"
623                                         theView.DisplayOnly(aPrsObj)
624                                         theView.FitAll()
625                                         aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TVECTORS." + thePictureExt
626                                         aPictureName = re.sub("\s+","_", aPictureName)
627                                         theView.SavePicture(aPictureName)
628                                         if theIsAutoDelete :
629                                             aPrsObj.RemoveFromStudy()
630                                         else :
631                                             aVISUObjList.append(aPrsObj)
632                                     
633                                 if HasValue(thePrsTypeList,VISU.TSTREAMLINES) :
634                                     print "          Creating StreamLinesOnField",
635                                     aPrsObj = theVisu.StreamLinesOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
636                                     if aPrsObj is None : print "Error"
637                                     else :
638                                         print ",OK"
639                                         theView.DisplayOnly(aPrsObj)
640                                         theView.FitAll()
641                                         aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TSTREAMLINES." + thePictureExt
642                                         aPictureName = re.sub("\s+","_", aPictureName)
643                                         theView.SavePicture(aPictureName)
644                                         if theIsAutoDelete :
645                                             aPrsObj.RemoveFromStudy()
646                                         else :
647                                             aVISUObjList.append(aPrsObj)
648
649                                 if HasValue(thePrsTypeList,VISU.TSCALARMAPONDEFORMEDSHAPE) or HasValue(thePrsTypeList,VISU.TDEFORMEDSHAPEANDSCALARMAP) :
650                                     print "          Creating DeformedShapeAndScalarMapOnField",
651                                     aPrsObj = theVisu.DeformedShapeAndScalarMapOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
652                                     if aPrsObj is None : print "Error"
653                                     else :
654                                         print ",OK"
655                                         theView.DisplayOnly(aPrsObj)
656                                         theView.FitAll()
657                                         aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TDEFORMEDSHAPEANDSCALARMAP." + thePictureExt
658                                         aPictureName = re.sub("\s+","_", aPictureName)
659                                         theView.SavePicture(aPictureName)
660                                         if theIsAutoDelete :
661                                             aPrsObj.RemoveFromStudy()
662                                         else :
663                                             aVISUObjList.append(aPrsObj)
664
665                                 if HasValue(thePrsTypeList,VISU.TGAUSSPOINTS) :
666                                     print "          Creating GaussPointsOnField",
667                                     aPrsObj = theVisu.GaussPointsOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
668                                     if aPrsObj is None : print "Error"
669                                     else :
670                                         print ",OK"
671                                         theView.DisplayOnly(aPrsObj)
672                                         theView.FitAll()
673                                         aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TGAUSSPOINTS." + thePictureExt
674                                         aPictureName = re.sub("\s+","_", aPictureName)
675                                         theView.SavePicture(aPictureName)
676                                         if theIsAutoDelete :
677                                             aPrsObj.RemoveFromStudy()
678                                             pass
679                                         else :
680                                             aVISUObjList.append(aPrsObj)
681                                             pass
682                                         pass
683                                     pass
684                                 
685     return aVISUObjList
686
687
688 def generateName(prefix = None):
689     import random;
690     int = random.randint(1,1000);
691     if prefix is None:
692         return "Study" + str(int)
693     else :
694         return prefix + str(int)
695     
696
697
698 # ----------------------
699 # MESH
700 # ----------------------
701 def try_mesh_parameters(theMeshPattern):
702     aResult = []
703     if theMeshPattern is None : return aResult ;
704     theMeshPattern =  theMeshPattern._narrow(VISU.Mesh)
705     if theMeshPattern is None : return aResult ;
706
707     aTYPES = [VISU.POINT, VISU.WIREFRAME, VISU.SHADED, VISU.INSIDEFRAME, VISU.SHRINK]
708     import copy; import os;
709     for ind in aTYPES:
710         aNewMesh = copy.deepcopy(theMeshPattern);
711         aNewMesh.SetPresentationType(ind)
712         aResult.append(aNewMesh)
713
714     return aResult
715
716
717 # ----------------------------    
718 # SCALAR MAP 
719 # ----------------------------    
720 ind=1  #try safe way
721 def try_scalarmap_parameters(thePattern, dump = 0):
722
723     if thePattern  is None : return None 
724
725     SCALING = [VISU.LINEAR, VISU.LOGARITHMIC]
726     import copy
727     import random
728
729     anObj = thePattern#copy.deepcopy(thePattern);
730     #ind = random.randint(1,2)
731     if ind%2 :
732             #try incorrect value deliberately (but allowed by idl description)
733             #try SetScalarMode(long)
734             mode = random.randint(-100000,100000); #incorrect value deliberately
735     else:
736             #correct value of ScalarMode
737             mode = random.randint(0, 3)
738
739     if dump : print "\tSetScalarMode(" + str(mode) +")"
740     anObj.SetScalarMode(mode)
741
742     # --- SCALING ---
743     scal = random.randint(0,1)
744     if dump : print "\tSetScaling(" + str(SCALING[scal]) +")"
745     anObj.SetScaling(SCALING[scal])
746         
747     # --- BOUNDARIES ---
748     if ind%2 :
749             alfa =  random.random()*random.randint(-100000,100000)
750             betta = random.random()*random.randint(-100000,100000)
751             aMin = alfa; aMax = betta
752     else:
753             #more correct set
754             aPMin = thePattern.GetMin()
755             aPMax = thePattern.GetMax()
756             aLen = aPMax - aPMin
757             alfa =  random.random()%0.5
758             betta = random.random()%0.5
759             aMin = alfa*aLen*random.randint(-1,1) + aPMin
760             aMax = betta*aLen*random.randint(-1,1) + aPMax
761     if dump : print "\tSetRange(" + str(aMin) + ", " + str(aMax) + ")"
762     anObj.SetRange(aMin, aMax)
763
764         # --- POSITION ---
765     if ind%2:
766             X=random.random()*random.randint(-100000,100000)
767             Y=random.random()*random.randint(-100000,100000)
768     else :
769              X=random.random()
770              Y=random.random()
771     if dump : print "SetPosition("+ str(X) + ", " + str(Y) + " )"
772     anObj.SetPosition(X, Y)
773
774         # --- SCALAR BAR SIZE ---
775     if ind%2:
776             aWidth=random.random()*random.randint(-100000,100000)
777             aHeight=random.random()*random.randint(-100000,100000)
778     else :
779              aWidth=random.random()
780              aHeight=random.random()
781     if dump : print " SCALAR BAR Width = " + str(aWidth) + " Height = ", str(aHeight)
782     anObj.SetSize(aWidth, aHeight)
783     
784     return anObj
785
786
787 def dump_scalarmap_parameters(anObj):
788     
789     print "\tGetScalarMode() = " + str(anObj.GetScalarMode()) 
790     print "\tGetScaling() = " + str(anObj.GetScaling()) 
791     print "\tGetMin() = " + str(anObj.GetMin()) + "  GetMax() = " + str (anObj.GetMax())
792     print "\tGetOrientation() = " + str(anObj.GetOrientation())
793     print "\tGetPosX() = ", str(anObj.GetPosX()) + "  GetPosY() = ", str(anObj.GetPosY())
794     print "\tGetWidth() = ", str ( anObj.GetWidth()) + "  GetHeight() = " + str(anObj.GetHeight())
795
796 # ----------------------
797 # DEFORMED SHAPE
798 # ----------------------
799 def try_deformedshape_parameters(thePattern) :
800
801     if thePattern  is None : return None 
802     import copy
803     import random
804
805     anObj = try_scalarmap_parameters(thePattern)
806
807     # --- SCALING ---
808     if ind%2:
809         anObj.SetScale( random.random()*random.randint(-100000, 100000))
810     else :
811         anObj.SetScale( anObj.GetScale()*random.random())
812
813     return anObj
814
815
816 def dump_deformedshape_parameters(theObject):
817     dump_scalarmap_parameters(theObject)
818     print "GetScale() = ", theObject.GetScale()
819     
820 # ----------------------
821 # CUT PLANES
822 # ----------------------
823 def try_cutplanes_parameters(thePattern) :
824
825     if thePattern  is None : return None 
826     import copy
827     import random
828
829     ORIENT = [VISU.CutPlanes.XY, VISU.CutPlanes.YZ, VISU.CutPlanes.ZX]
830
831     ind = random.randint(1,2)
832     anObj = try_scalarmap_parameters(thePattern)
833         
834     if ind%2 :   anObj.SetNbPlanes(random.randint(-40,40))
835     else :       anObj.SetNbPlanes(random.randint(0,10)) #try behaivor if NbPlanes=0
836
837     # --- DISPLACEMENT ---
838     anObj.SetDisplacement(random.randint(-100000,100000))
839
840     # --- PLANE POSITION ---
841     if ind%2:
842         PlaneNb = random.randint(-100000,100000) #incorrect value is possible
843     else    : PlaneNb = random.randint(0, anObj.GetNbPlanes())
844         
845     anObj.SetPlanePosition(PlaneNb, random.random()*random.randint(-100000,100000))
846
847     # --- SET DEFAULT ---
848     anObj.SetDefault(PlaneNb)
849
850     # --- SET X,Y,Z ROTATION ---
851     if ind%2 :
852             angle1 = random.random()*random.randint(-100000,100000)
853             angle2 = random.random()*random.randint(-100000,100000)
854     else :
855             angle1 = random.random()*3.14
856             angle2 = random.random()*3.14
857         
858     # --- ORIENTATION ---
859     anObj.SetOrientation(ORIENT[random.randint(0,2)],angle1,angle2)
860
861     return anObj
862         
863 def dump_cutplanes_parameters(theObject):
864         dump_saclarmap_parameters(theObject)
865
866         print "GetOrientationType = " + str(theObject.GetOrientationType())
867         PlanesNb = theObject.GetNbPlanes()
868         print "GetNbPlanes() = ", str(PlanesNb)
869         for i in range(0,PlanesNb+1):
870             if theObject.IsDefault(i) :
871                 print "Default plane : "+str(i); break
872         print "GetPlanePosition(" + str(i) + ") = ", theObject.GetPlanePosition(i)
873         print "GetDisplacement() = ", str(theObject.GetDisplacement())
874         print "GetRotateX() = ", str(theObject.GetRotateX())
875         print "GetRotateY() = ", str(theObject.GetRotateY())
876         print "GetRotateZ() = ", str(theObject.GetRotateZ())
877
878 # ----------------------
879 # CUT LINES
880 # ----------------------
881 def try_cutlines_parameters(thePattern):
882
883     if thePattern  is None : return None 
884     import copy
885     import random
886
887     ORIENT = [VISU.CutPlanes.XY, VISU.CutPlanes.YZ, VISU.CutPlanes.ZX]
888     ind = random.randint(1,2)
889     anObj = try_scalarmap_parameters(thePattern)
890
891     # --- ORIENTATION ---
892     anObj.SetOrientation(ORIENT[random.randint(0,2)],
893                          random.randint(-100,100)*random.random(),
894                          random.randint(-100,100)*random.random())
895     anObj.SetOrientation2(ORIENT[random.randint(0,2)],
896                           random.randint(-100,100)*random.random(),
897                           random.randint(-100,100)*random.random())
898
899     # --- Base Plane Position ---
900     anObj.SetBasePlanePosition( random.random()*random.randint(-100000,100000))
901
902     # --- NUMBER OF LINES ---
903     if ind%2:
904             anObj.SetNbLines(random.randint(-5, 50))
905
906     return anObj
907
908 def dump_cutlines_parameters(theObject):
909     dump_scalarmap_parameters(theObject)
910
911     print "GetOrientationType() = " + str(theObject.GetOrientationType())
912     print "GetOrientationType2() = " + str(theObject.GetOrientationType2())
913     print "GetBasePlanePosition() = "+ str(theObject.GetBasePlanePosition())
914     print "GetNbLines() = " + str(theObject.GetNbLines())
915     print "GetRotateX() = ", str(theObject.GetRotateX())
916     print "GetRotateX2() = ", str(theObject.GetRotateX2())
917     print "GetRotateY() = ", str(theObject.GetRotateY())
918     print "GetRotateY2() = ", str(theObject.GetRotateY2())
919
920 # ----------------------
921 # CUT SEGMENT
922 # ----------------------
923 def try_cutsegment_parameters(thePattern):
924
925     if thePattern  is None : return None 
926     import copy
927     import random
928
929     anObj = try_scalarmap_parameters(thePattern)
930
931     anObj.SetPoint1(random.randint(-100,100)*random.random(),
932                     random.randint(-100,100)*random.random(),
933                     random.randint(-100,100)*random.random())
934     anObj.SetPoint2(random.randint(-100,100)*random.random(),
935                     random.randint(-100,100)*random.random(),
936                     random.randint(-100,100)*random.random())
937
938     return anObj
939
940 def dump_cutsegment_parameters(theObject):
941     dump_scalarmap_parameters(theObject)
942
943     x1 = y1 = z1 = 0
944     x2 = y2 = z2 = 0
945     theObject.GetPoint1(x1, y1, z1)
946     theObject.GetPoint1(x2, y2, z2)
947     print "GetPoint1() = " + str(x1) + ", " + str(y1) + ", " + str(z1)
948     print "GetPoint2() = " + str(x2) + ", " + str(y2) + ", " + str(z2)
949
950 # ----------------------
951 # STREAM LINES
952 # ----------------------
953 def try_streamlines_parameters(thePattern):
954
955     if thePattern  is None : return None 
956     import copy
957     import random
958
959     DIRECTION = [VISU.StreamLines.FORWARD, VISU.StreamLines.BACKWARD, VISU.StreamLines.BOTH]
960
961     ind = random.randint(1,2)
962     anObj = (try_deformedshape_parameters(thePattern))[0]
963
964     # --- DIREACTION ---
965     anObj.SetDirection(DIRECTION[random.randint(0,2)])
966
967     # --- STEP LENGTH ---
968     if ind%2 : anObj.SetStepLength(random.random()*random.randint(-1000,1000))
969     else :
970             aLen = anObj.GetMax() - anObj.GetMin()
971             anObj.SetStepLength(aLen/random.randint(1,100))
972             
973     # --- PROPAGATION TIME ---
974     anObj.SetPropagationTime(random.random()*random.randint(1,100))
975
976     # --- INTEGRATION STEP ---
977     if ind%2 :
978             anObj.SetIntegrationStep(random.random()*random.randint(-1000,1000))
979     else:
980             anObj.SetIntegrationStep(random.random())
981
982     # --- USED POINT ---
983     anObj.SetUsedPoints(random.random()*random.randint(-10000,10000))
984
985     return anObj
986         
987 def dump_streamlines_parameters(theObject):
988     
989     dump_deformedshape_parameters(theObject)
990     
991     print "GetDirection() = "      + str(theObject.GetDirection())
992     print "GetStepLength() = "     + str(theObject.GetStepLength())
993     print "GetPropagationTime() =" + str(theObject.GetPropagationTime())
994     print "GetIntegrationStep() =" + str(theObject.GetIntegrationStep())
995     print "GetUsedPoints()      =" + str(theObject.GetUsedPoints())
996     
997 # ----------------------
998 # VECTORS     
999 # ----------------------
1000 def try_vectors_parameters(thePattern, theNum):
1001
1002     if thePattern  is None : return None 
1003     import copy
1004     import random
1005     GLIPH_TYPE = [VISU.Vectors.ARROW, VISU.Vectors.CONE2, VISU.Vectors.CONE6, VISU.Vectors.NONE]
1006     GLIPH_POS = [VISU.Vectors.CENTER, VISU.Vectors.TAIL, VISU.Vectors.HEAD]
1007     ind = random.randint(1,2)
1008     anObj = (try_deformedshape_parameters(thePattern))[0]
1009
1010     # --- LINE WIDTH ---
1011     if ind%2 :
1012             anObj.SetLineWidth(random.random()*random.randint(-10000,10000))
1013     else :
1014             anObj.SetLineWidth(random.randint(1, 10))
1015
1016     # --- GLIPH TYPE ---
1017     anObj.SetGlyphType(GLIPH_TYPE[random.randint(0, len(GLIPH_TYPE)-1)])
1018         
1019     # --- GLIPH POS ---
1020     anObj.SetGlyphPos(GLIPH_POS[random.randint(0, len(GLIPH_POS)-1)])
1021     
1022     return anObj
1023
1024 def dump_vectors_parameters(theObject):
1025     
1026     dump_deformedshape_parameters(theObject)
1027     
1028     print "GetLineWidth() = " +str(theObject.GetLineWidth())
1029     print "GetGlyphType() = " +str(theObject.GetGlyphType())
1030     print "GetGlyphPos()  = " +str(theObject.GetGlyphPos())
1031
1032
1033 # ----------------------
1034 # ISO SURFACES     
1035 # ----------------------
1036
1037 def try_isosurfaces_parameters(thePattern) :
1038     if thePattern  is None : return None 
1039     import copy
1040     import random
1041     
1042     anObj = try_scalarmap_parameters(thePattern)
1043     ind = random.randint(1,2)   
1044     # --- SURFACES NUMBER ---
1045     if ind%2 :
1046             anObj.SetNbSurfaces(random.randint(-100000,100000))
1047     else:
1048             anObj.SetNbSurfaces(random.randint(1, 50))
1049             
1050     return anObj
1051
1052 def dump_isosurfaces_parameters(theObject):
1053     
1054     dump_scalarmap_parameters(theObject)
1055     print "GetNbSurfaces() = "+ str(theObject.GetNbSurfaces())
1056
1057 # ----------------------------
1058 # SCALAR MAP ON DEFORMED SHAPE
1059 # ----------------------------
1060 def dump_scalarmapondeformedshape_parameters(theObject):
1061     dump_scalarmap_parameters(theObject)
1062     print "GetScale()          =", theObject.GetScale()
1063     print "GetScalarCMeshName ()=|",theObject.GetScalarCMeshName(),"|"
1064     print "GetScalarCFieldName()=|",theObject.GetScalarCFieldName(),"|"
1065     print "GetScalarEEntity()   =",theObject.GetScalarEEntity()
1066     print "GetScalarLIteration()=",theObject.GetScalarLIteration()
1067     pass
1068
1069 def try_scalarmapondeformedshape_parameters(thePattern):
1070
1071     if thePattern  is None : return None 
1072     import copy
1073     import random
1074
1075     anObj = try_scalarmap_parameters(thePattern)
1076
1077     # --- SCALING ---
1078     print 
1079     anObj.SetScale( anObj.GetScale()/random.random()*random.randint(1,10))
1080
1081     # --- Scalar Field ---
1082     # not implemented yet.
1083     
1084     return anObj
1085 # ----------------------
1086 # PLOT 3D 
1087 # ----------------------
1088 def dump_plot3d_parameters(theObject):
1089     dump_scalarmap_parameters(theObject)
1090     print "GetOrientationType()=",str(theObject.GetOrientationType())
1091     print "GetRotateX()=",theObject.GetRotateX()
1092     print "GetRotateY()=",theObject.GetRotateY()
1093     print "GetPlanePosition()=",theObject.GetPlanePosition()
1094     print "IsPositionRelative()=",theObject.IsPositionRelative()
1095     print "GetScaleFactor()=",theObject.GetScaleFactor()
1096     print "GetIsContourPrs()=",theObject.GetIsContourPrs()
1097     print "GetNbOfContours()=",theObject.GetNbOfContours()
1098     pass
1099
1100 def try_plot3d_parameters(thePattern):
1101     if thePattern is None : return None
1102     import random
1103     
1104     anObj = try_scalarmap_parameters(thePattern)
1105
1106     ORIENT = [VISU.Plot3D.XY, VISU.Plot3D.YZ, VISU.Plot3D.ZX]
1107
1108     theXAngle = random.random()*random.randint(-180,180)
1109     theYAngle = random.random()*random.randint(-180,180)
1110
1111     # ORIENTATION and ANGLES
1112     anObj.SetOrientation(ORIENT[random.randint(0,2)],theXAngle,theYAngle)
1113
1114     # Plane position (revative)
1115     anObj.SetPlanePosition(random.random(),1)
1116
1117     # SCALE FACTOR
1118     anObj.SetScaleFactor(random.random()*random.randint(-10000,10000))
1119
1120     # CONTOUR PRS
1121     anObj.SetContourPrs(random.randint(0,1))
1122     if anObj.GetIsContourPrs():
1123         anObj.SetNbOfContours(random.randint(1,999))
1124         pass
1125     
1126     pass
1127
1128 # ----------------------
1129 # Gauss points
1130 # ----------------------
1131 def dump_gausspoints_parameters(theObject):
1132     
1133     print "\tGetScalarMode() = " + str(anObj.GetScalarMode())
1134     print "\tGetMin() = " + str(anObj.GetMin()) + "  GetMax() = " + str (anObj.GetMax())
1135     print "\tGetPosX() = ", str(anObj.GetPosX()) + "  GetPosY() = ", str(anObj.GetPosY())
1136     print "\tGetWidth() = ", str ( anObj.GetWidth()) + "  GetHeight() = " + str(anObj.GetHeight())
1137     print "\tGetNbColors() = " + str(anObj.GetNbColors())
1138     print "\tGetLabels() = " + str(anObj.GetLabels())
1139     print "\tGetTitle() = " + str(anObj.GetTitle())
1140     pass
1141
1142 def try_plot3d_parameters(thePattern):
1143     if thePattern is None : return None
1144     import random
1145     
1146     pass
1147
1148 # ----------------------
1149 # TABLES AND CURVES
1150 # ----------------------
1151
1152 def FillTable( theTable, theValues, theRows, theColumns, theRowTitles, theRowUnits, theColumnTitles ):
1153     if theTable is None: return
1154     if len(theRows) != len(theColumns): return
1155     if len(theRows) != len(theValues): return
1156     i = 0
1157     for value in theValues:
1158         theTable.PutValue( value, theRows[ i ], theColumns[ i ])
1159         i = i + 1
1160         pass
1161     i = 1
1162     for title in theRowTitles:
1163         theTable.SetRowTitle( i, title )
1164         theTable.SetRowUnit( i, theRowUnits[ i - 1 ])
1165         i = i + 1
1166         pass
1167     i = 1
1168     for title in theColumnTitles:
1169         theTable.SetColumnTitle( i, title )
1170         i = i + 1
1171         pass
1172     pass
1173
1174 def CreateCurve( theTable, theHRow, theVRow, theTitle, theColor, theMarker, theLineType, theLineWidth ):
1175     if theTitle is None: return
1176     curve = myLocalVisu.CreateCurve( theTable, theHRow, theVRow );
1177     if curve:
1178         curve.SetTitle( theTitle )
1179         curve.SetColor( theColor )
1180         curve.SetMarker( theMarker )
1181         curve.SetLine( theLineType, theLineWidth )
1182         pass
1183     return curve