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