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