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