]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_I/VISU_DumpPython.cc
Salome HOME
d782714ea228e6c4f880baed244ad8bad13c0b83
[modules/visu.git] / src / VISU_I / VISU_DumpPython.cc
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 OBJECT : interactive object for VISU entities implementation
23 //  File   : VISU_DumpPython.cc
24 //  Author : Alexey PETROV
25 //  Module : VISU
26 //
27 #include "VISU_Gen_i.hh"
28 #include "VISU_Result_i.hh"
29 #include "VISU_PrsObject_i.hh"
30
31 #include "VISU_Prs3d_i.hh"
32 #include "VISU_Mesh_i.hh"
33 #include "VISU_ScalarMap_i.hh"
34 #include "VISU_IsoSurfaces_i.hh"
35 #include "VISU_DeformedShape_i.hh"
36 #include "VISU_CutPlanes_i.hh"
37 #include "VISU_CutLines_i.hh"
38 #include "VISU_Vectors_i.hh"
39 #include "VISU_StreamLines_i.hh"
40 #include "VISU_Plot3D_i.hh"
41 #include "VISU_Table_i.hh"
42 #include "VISU_PointMap3d_i.hh"
43 #include "VISU_GaussPoints_i.hh"
44 #include "VISU_DeformedShapeAndScalarMap_i.hh"
45 #include "VISU_ColoredPrs3dCache_i.hh"
46 #include "VISU_ColoredPrs3dHolder_i.hh"
47
48 #include "utilities.h"
49
50 #include <cctype>
51 #include <strstream>
52 #include <functional>
53
54 #include <QString>
55 #include <QFileInfo>
56
57 //#define COUT
58
59 using namespace std;
60
61 namespace VISU
62 {
63   //---------------------------------------------------------------------------
64   static std::string PREFIX("  ");
65
66   typedef std::map<std::string,std::string> TName2EntryMap;
67   typedef std::map<std::string,std::string> TEntry2NameMap;
68
69
70   //---------------------------------------------------------------------------
71   inline
72   std::string
73   GenerateName(std::string theName,
74                SALOMEDS::SObject_ptr theSObject,
75                TName2EntryMap& theName2EntryMap,
76                TEntry2NameMap& theEntry2NameMap,
77                char theSuffix)
78   {
79     if(theName2EntryMap.find(theName) != theName2EntryMap.end()){
80       theName = GenerateName(theName + theSuffix, theSObject, theName2EntryMap, theEntry2NameMap, theSuffix);
81     }else{
82       CORBA::String_var anID = theSObject->GetID();
83       theName2EntryMap[theName] = anID.in();
84       theEntry2NameMap[anID.in()] = theName;
85       //cout<<"GenerateName - "<<theName<<" => "<<anID.in()<<endl;
86     }
87
88     return theName;
89   }
90
91
92   //---------------------------------------------------------------------------
93   struct TReplacePredicate
94   {
95     bool operator()(char theChar) const
96     {
97       return !(isdigit(theChar) || isalpha(theChar) || theChar == '_');
98     }
99   };
100
101
102   //---------------------------------------------------------------------------
103   inline
104   std::string
105   GetName(SALOMEDS::SObject_ptr theSObject)
106   {
107     CORBA::String_var aString = theSObject->GetName();
108
109     std::string aName = QString(aString.in()).simplified().toLatin1().data();
110
111     //replace_if(aName.begin(),aName.end(),not1(ptr_fun(isxdigit)),'_');
112     replace_if(aName.begin(),aName.end(),TReplacePredicate(),'_');
113
114     if ( isdigit( aName[0] ))
115       aName.insert( 0, 1, 'a' );
116
117     return aName;
118   }
119
120
121   //---------------------------------------------------------------------------
122   inline
123   std::string
124   GenerateName(SALOMEDS::SObject_ptr theSObject,
125                TName2EntryMap& theName2EntryMap,
126                TEntry2NameMap& theEntry2NameMap)
127   {
128     std::string aName = GetName(theSObject);
129
130     return GenerateName(aName, theSObject, theName2EntryMap, theEntry2NameMap, 'X');
131   }
132
133
134   //---------------------------------------------------------------------------
135   inline
136   std::string
137   GetBoolean(bool theArgument)
138   {
139     if(theArgument)
140       return "True";
141
142     return "False";
143   }
144
145
146   //---------------------------------------------------------------------------
147   inline
148   std::string
149   GetColor(const SALOMEDS::Color& theColor)
150   {
151     std::ostringstream aStream;
152     aStream<<"SALOMEDS.Color("<<theColor.R<<", "<<theColor.G<<", "<<theColor.B<<")";
153     return aStream.str();
154   }
155
156
157   //---------------------------------------------------------------------------
158   typedef void (*TDumpToPython)(SALOMEDS::Study_ptr theStudy,
159                                 CORBA::Boolean theIsPublished,
160                                 CORBA::Boolean& theIsValidScript,
161                                 SALOMEDS::SObject_ptr theSObject,
162                                 std::ostream& theStr,
163                                 TName2EntryMap& theName2EntryMap,
164                                 TEntry2NameMap& theEntry2NameMap,
165                                 std::string theArgumentName,
166                                 std::string thePrefix);
167
168
169   void
170   DumpToPython(SALOMEDS::Study_ptr theStudy,
171                CORBA::Boolean theIsPublished,
172                CORBA::Boolean& theIsValidScript,
173                SALOMEDS::SObject_ptr theSObject,
174                std::ostream& theStr,
175                TName2EntryMap& theName2EntryMap,
176                TEntry2NameMap& theEntry2NameMap,
177                std::string theArgumentName,
178                std::string thePrefix);
179
180
181   //---------------------------------------------------------------------------
182   void SetClippingPlane(Prs3d_i* thePrs, string theName,
183                         std::ostream& theStr,
184                         std::string thePrefix) 
185   {
186     VISU_CutPlaneFunction* aPlane;
187     VISU_Gen_i* aGen = VISU_Gen_i::GetVisuGenImpl();
188     VISU_ClippingPlaneMgr& aMgr = aGen->GetClippingPlaneMgr();
189     int aId;
190     for (int i = 0; i < thePrs->GetNumberOfClippingPlanes(); i++) {
191       aPlane = dynamic_cast<VISU_CutPlaneFunction*>(thePrs->GetClippingPlane(i));
192       if (aPlane) {
193         if (!aPlane->isAuto()) {
194           aId = aMgr.GetPlaneId(aPlane);
195           if (aId > -1) {
196             theStr<<thePrefix<<"aVisu.ApplyClippingPlane("<<theName<<", "<<aId<<")"<<endl;
197           }
198         }
199       }
200     }
201   }
202   
203
204   void
205   Prs3dToPython(VISU::Prs3d_i* theServant,
206                 std::ostream& theStr,
207                 const std::string& theName,
208                 std::string thePrefix)
209   {
210     float x, y, z;
211     theServant->GetOffset(x,y,z);
212     theStr<<thePrefix<<theName<<".SetOffset("<<x<<", "<<y<<", "<<z<<")"<<endl;
213     SetClippingPlane(theServant, theName, theStr, thePrefix);
214   }
215
216   //---------------------------------------------------------------------------
217   struct TColoredPrs3dFactory
218   {
219     virtual
220     std::string
221     operator()(std::ostream& theStr,
222                std::string thePrefix)
223     {
224
225       return thePrefix;
226     }
227   };
228
229
230   struct TCreateFromResult: TColoredPrs3dFactory
231   {
232     VISU::ColoredPrs3d_i* myServant;
233     std::string myConstructorName;
234     std::string myArgumentName;
235
236     SALOMEDS::SObject_var mySObject;
237     std::string myName;
238
239     TCreateFromResult(const SALOMEDS::SObject_var& theSObject,
240                       VISU::ColoredPrs3d_i* theServant,
241                       const std::string& theName,
242                       const std::string& theConstructorName,
243                       const std::string& theArgumentName):
244       myServant(theServant),
245       myConstructorName(theConstructorName),
246       myArgumentName(theArgumentName),
247       mySObject(theSObject),
248       myName(theName)
249     {}
250
251     virtual
252     std::string
253     operator()(std::ostream& theStr,
254                std::string thePrefix)
255     {
256       std::string aParam;
257       switch(myServant->GetEntity()){
258       case NODE:
259         aParam = "VISU.NODE";
260         break;
261       case EDGE:
262         aParam = "VISU.EDGE";
263         break;
264       case FACE:
265         aParam = "VISU.FACE";
266         break;
267       case CELL:
268         aParam = "VISU.CELL";
269         break;
270       }
271
272       theStr<<thePrefix<<myName<<" = aVisu."<<myConstructorName<<"("<<myArgumentName<<
273         ", '"<<myServant->GetCMeshName()<<"'"<<
274         ", "<<aParam<<
275         ", '"<<myServant->GetCFieldName()<<"'"<<
276         ", "<<myServant->GetTimeStampNumber()<<
277         ")"<<endl;
278       
279       theStr<<thePrefix<<"if "<<myName<<" != None:"<<endl;
280       thePrefix += PREFIX;
281       
282       // Add to Name->Object map
283       theStr<<thePrefix<<"aName2ObjectMap['"<<myName<<"'] = "<<myName<<endl;
284
285       // Set name (as this object could be renamed by user)
286       CORBA::String_var aNameInStudy = mySObject->GetName();
287       theStr<<thePrefix<<"visu.SetName("<<myName<<", '"<<aNameInStudy.in()<<"')"<<endl;
288
289       return thePrefix;
290     }
291   };
292
293
294   //---------------------------------------------------------------------------
295   std::string
296   ColoredPrs3dToPython(SALOMEDS::SObject_ptr theSObject,
297                        VISU::ColoredPrs3d_i* theServant,
298                        std::ostream& theStr,
299                        const std::string& theName,
300                        TColoredPrs3dFactory& thePrsFactory,
301                        std::string thePrefix)
302   {
303     thePrefix = thePrsFactory(theStr, thePrefix);
304
305     // Set parameters common for all Prs3d objects (offset values)
306     Prs3dToPython(theServant, theStr, theName, thePrefix);
307
308     theStr<<thePrefix<<theName<<".SetPosition("<<theServant->GetPosX()<<", "<<theServant->GetPosY()<<")"<<endl;
309     theStr<<thePrefix<<theName<<".SetSize("<<theServant->GetWidth()<<", "<<theServant->GetHeight()<<")"<<endl;
310     theStr<<thePrefix<<theName<<".SetNbColors("<<theServant->GetNbColors()<<")"<<endl;
311     theStr<<thePrefix<<theName<<".SetLabels("<<theServant->GetLabels()<<")"<<endl;
312     theStr<<thePrefix<<theName<<".SetTitle('"<<theServant->GetTitle()<<"')"<<endl;
313
314     std::string aParam;
315     switch(theServant->GetBarOrientation()){
316     case ColoredPrs3dBase::HORIZONTAL:
317       aParam = "VISU.ColoredPrs3d.HORIZONTAL";
318       break;
319     case ColoredPrs3dBase::VERTICAL:
320       aParam = "VISU.ColoredPrs3d.VERTICAL";
321       break;
322     }
323     theStr<<thePrefix<<theName<<".SetBarOrientation("<<aParam<<")"<<endl;
324
325     theStr<<thePrefix<<theName<<".SetScalarMode("<<theServant->GetScalarMode()<<")"<<endl;
326
327     if(theServant->IsRangeFixed())
328       theStr<<thePrefix<<theName<<".SetRange("<<theServant->GetMin()<<", "<<theServant->GetMax()<<")"<<endl;
329     else
330       theStr<<thePrefix<<theName<<".SetSourceRange()"<<endl;
331
332     const VISU::ColoredPrs3d_i::TGroupNames aGroupNames = theServant->GetGroupNames();
333     VISU::ColoredPrs3d_i::TGroupNames::const_iterator anIter = aGroupNames.begin();
334     for(; anIter != aGroupNames.end(); anIter++){
335       const std::string& aGroupName = *anIter;
336       theStr<<thePrefix<<theName<<".AddMeshOnGroup('"<<aGroupName<<"')"<<endl;
337     }
338     
339     return thePrefix;
340   }
341
342
343   //---------------------------------------------------------------------------
344   std::string
345   GaussPointsToPython(SALOMEDS::SObject_ptr theSObject,
346                       VISU::GaussPoints_i* theServant,
347                       std::ostream& theStr,
348                       const std::string& theName,
349                       TColoredPrs3dFactory& thePrsFactory,
350                       std::string thePrefix)
351   {
352     thePrefix = ColoredPrs3dToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
353     theStr<<thePrefix<<endl;
354
355     bool aBoolean = theServant->GetIsActiveLocalScalarBar();
356     theStr<<thePrefix<<theName<<".SetIsActiveLocalScalarBar("<<GetBoolean(aBoolean)<<")"<<endl;
357
358     if(aBoolean){
359       aBoolean = theServant->GetIsDispGlobalScalarBar();
360       theStr<<thePrefix<<theName<<".SetIsDispGlobalScalarBar("<<GetBoolean(aBoolean)<<")"<<endl;
361     }
362
363     theStr<<thePrefix<<theName<<".SetSpacing("<<theServant->GetSpacing()<<")"<<endl;
364
365     aBoolean = theServant->GetBiColor();
366     theStr<<thePrefix<<theName<<".SetBiColor("<<GetBoolean(aBoolean)<<")"<<endl;
367
368     aBoolean = theServant->GetIsDeformed();
369     theStr<<thePrefix<<theName<<".SetIsDeformed("<<GetBoolean(aBoolean)<<")"<<endl;
370     theStr<<thePrefix<<theName<<".SetScaleFactor("<<theServant->GetScaleFactor()<<")"<<endl;
371
372     std::string aParam;
373     switch(theServant->GetPrimitiveType()){
374     case VISU::GaussPoints::SPRITE :
375       aParam = "VISU.GaussPoints.SPRITE";
376       break;
377     case VISU::GaussPoints::POINT :
378       aParam = "VISU.GaussPoints.POINT";
379       break;
380     case VISU::GaussPoints::SPHERE :
381       aParam = "VISU.GaussPoints.SPHERE";
382       break;
383     }
384     theStr<<thePrefix<<theName<<".SetPrimitiveType("<<aParam<<")"<<endl;
385
386     theStr<<thePrefix<<theName<<".SetClamp("<<theServant->GetClamp()<<")"<<endl;
387
388     QString aMainTexture = theServant->GetQMainTexture();
389     QString anAlphaTexture = theServant->GetQAlphaTexture();
390     theStr<<thePrefix<<theName<<".SetTextures('"<<aMainTexture.toLatin1().data()<<"', '"<<anAlphaTexture.toLatin1().data()<<"')"<<endl;
391
392     theStr<<thePrefix<<theName<<".SetAlphaThreshold("<<theServant->GetAlphaThreshold()<<")"<<endl;
393
394     theStr<<thePrefix<<theName<<".SetResolution("<<theServant->GetResolution()<<")"<<endl;
395
396     theStr<<thePrefix<<theName<<".SetFaceLimit("<<theServant->GetFaceLimit()<<")"<<endl;
397
398     aBoolean = theServant->GetIsColored();
399     theStr<<thePrefix<<theName<<".SetIsColored("<<GetBoolean(aBoolean)<<")"<<endl;
400
401     if(aBoolean){
402       theStr<<thePrefix<<theName<<".SetMinSize("<<theServant->GetMinSize()<<")"<<endl;
403       theStr<<thePrefix<<theName<<".SetMaxSize("<<theServant->GetMaxSize()<<")"<<endl;
404     }else{
405       theStr<<thePrefix<<theName<<".SetColor("<<GetColor(theServant->GetColor())<<")"<<endl;
406       theStr<<thePrefix<<theName<<".SetGeomSize("<<theServant->GetGeomSize()<<")"<<endl;
407     }
408
409     theStr<<thePrefix<<theName<<".SetMagnification("<<theServant->GetMagnification()<<")"<<endl;
410     theStr<<thePrefix<<theName<<".SetMagnificationIncrement("<<theServant->GetMagnificationIncrement()<<")"<<endl;
411     
412     std::string aVisible = theServant->IsBarVisible()? "True" : "False";
413     theStr<<thePrefix<<theName<<".SetBarVisible("<<aVisible<<")"<<endl;
414
415     return thePrefix;
416   }
417
418
419   //---------------------------------------------------------------------------
420   std::string
421   ScalarMapToPython(SALOMEDS::SObject_ptr theSObject,
422                     VISU::ScalarMap_i* theServant,
423                     std::ostream& theStr,
424                     const std::string& theName,
425                     TColoredPrs3dFactory& thePrsFactory,
426                     std::string thePrefix)
427   {
428     thePrefix = ColoredPrs3dToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
429     theStr<<thePrefix<<endl;
430
431     std::string aParam;
432     switch(theServant->GetScaling()){
433     case LINEAR:
434       aParam = "VISU.LINEAR";
435       break;
436     case LOGARITHMIC:
437       aParam = "VISU.LOGARITHMIC";
438       break;
439     }
440     std::string aVisible = theServant->IsBarVisible()? "True" : "False";
441     theStr<<thePrefix<<theName<<".SetScaling("<<aParam<<")"<<endl;
442     theStr<<thePrefix<<theName<<".SetBarVisible("<<aVisible<<")"<<endl;
443
444     return thePrefix;
445   }
446
447   //---------------------------------------------------------------------------
448   std::string
449   MonoColorPrsToPython(SALOMEDS::SObject_ptr theSObject,
450                        VISU::MonoColorPrs_i* theServant,
451                        std::ostream& theStr,
452                        const std::string& theName,
453                        TColoredPrs3dFactory& thePrsFactory,
454                        std::string thePrefix)
455   {
456     thePrefix = ScalarMapToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
457     theStr<<thePrefix<<endl;
458     theStr<<thePrefix<<theName<<".ShowColored("<<GetBoolean(theServant->IsColored())<<")"<<endl;
459     theStr<<thePrefix<<theName<<".SetColor("<<GetColor(theServant->GetColor())<<")"<<endl;
460     return thePrefix;
461   }
462
463   //---------------------------------------------------------------------------
464   std::string
465   DeformedShapeToPython(SALOMEDS::SObject_ptr theSObject,
466                         VISU::DeformedShape_i* theServant,
467                         std::ostream& theStr,
468                         const std::string& theName,
469                         TColoredPrs3dFactory& thePrsFactory,
470                         std::string thePrefix)
471   {
472     thePrefix = MonoColorPrsToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
473     theStr<<thePrefix<<endl;
474
475     theStr<<thePrefix<<theName<<".SetScale("<<theServant->GetScale()<<")"<<endl;
476 //     theStr<<thePrefix<<theName<<".ShowColored("<<GetBoolean(theServant->IsColored())<<")"<<endl;
477 //     theStr<<thePrefix<<theName<<".SetColor("<<GetColor(theServant->GetColor())<<")"<<endl;
478
479     return thePrefix;
480   }
481
482
483   //---------------------------------------------------------------------------
484   std::string
485   StreamLinesToPython(SALOMEDS::SObject_ptr theSObject,
486                       VISU::StreamLines_i* theServant,
487                       std::ostream& theStr,
488                       TEntry2NameMap& theEntry2NameMap,
489                       const std::string& theName,
490                       TColoredPrs3dFactory& thePrsFactory,
491                       std::string thePrefix)
492   {
493     thePrefix = MonoColorPrsToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
494     //    thePrefix = DeformedShapeToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
495     theStr<<thePrefix<<endl;
496     
497     std::string aParam;
498     switch(theServant->GetDirection()){
499     case StreamLines::FORWARD:
500       aParam = "VISU.StreamLines.FORWARD";
501       break;
502     case StreamLines::BACKWARD:
503       aParam = "VISU.StreamLines.BACKWARD";
504       break;
505     case StreamLines::BOTH:
506       aParam = "VISU.StreamLines.BOTH";
507       break;
508     }
509     
510     theStr<<thePrefix<<"aPrs3d = None"<<endl;
511     VISU::Prs3d_var aPrs3d = theServant->GetSource();
512     if(!CORBA::is_nil(aPrs3d)){
513       if(Prs3d_i* aServant3d = dynamic_cast<Prs3d_i*>(GetServant(aPrs3d).in())){
514         SALOMEDS::SObject_var aSObject = aServant3d->GetSObject();
515         CORBA::String_var anID = aSObject->GetID();
516         std::string anArg = theEntry2NameMap[anID.in()];
517         theStr<<thePrefix<<"if aName2ObjectMap.has_key('"<<anArg<<"'):"<<endl;
518         thePrefix += PREFIX;
519         theStr<<thePrefix<<"aPrs3d = aName2ObjectMap['"<<anArg<<"']"<<endl;
520       }
521     }
522     
523     theStr<<thePrefix<<theName<<".SetParams("<<
524       theServant->GetIntegrationStep()<<", "<<
525       theServant->GetPropagationTime()<<", "<<
526       theServant->GetStepLength()<<", "<<
527       "aPrs3d"<<", "<<
528       theServant->GetUsedPoints()<<", "<<
529       aParam<<
530       ")"<<endl;
531     
532     return thePrefix;
533   }
534
535
536   //---------------------------------------------------------------------------
537   std::string
538   DeformedShapeAndScalarMapToPython(SALOMEDS::SObject_ptr theSObject,
539                                     VISU::DeformedShapeAndScalarMap_i* theServant,
540                                     std::ostream& theStr,
541                                     const std::string& theName,
542                                     TColoredPrs3dFactory& thePrsFactory,
543                                     std::string thePrefix)
544   {
545     thePrefix = ScalarMapToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
546     theStr<<thePrefix<<endl;
547
548     theStr<<thePrefix<<theName<<".SetRange("<<theServant->GetMin()<<", "<<theServant->GetMax()<<")"<<endl;
549     theStr<<thePrefix<<theName<<".SetScale("<<theServant->GetScale()<<")"<<endl;
550
551     std::string aParam;
552     VISU::Entity anEntity = theServant->GetScalarEntity();
553     switch(anEntity){
554     case NODE:
555       aParam = "VISU.NODE";
556       break;
557     case EDGE:
558       aParam = "VISU.EDGE";
559       break;
560     case FACE:
561       aParam = "VISU.FACE";
562       break;
563     case CELL:
564       aParam = "VISU.CELL";
565       break;
566     }
567     
568     CORBA::String_var aFieldName = theServant->GetScalarFieldName();
569     CORBA::Long aTimeStampNumber = theServant->GetScalarTimeStampNumber();
570     
571     theStr<<thePrefix<<theName<<".SetScalarField("<<
572       aParam<<", "<<
573       "'"<<aFieldName<<"', "<<
574       aTimeStampNumber<<
575       ")"<<endl;
576
577     return thePrefix;
578   }
579
580
581   //---------------------------------------------------------------------------
582   std::string
583   VectorsToPython(SALOMEDS::SObject_ptr theSObject,
584                   VISU::Vectors_i* theServant,
585                   std::ostream& theStr,
586                   const std::string& theName,
587                   TColoredPrs3dFactory& thePrsFactory,
588                   std::string thePrefix)
589   {
590     thePrefix = DeformedShapeToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
591     theStr<<thePrefix<<endl;
592
593     theStr<<thePrefix<<theName<<".SetLineWidth("<<theServant->GetLineWidth()<<")"<<endl;
594
595     std::string aParam;
596     switch(theServant->GetGlyphType()){
597     case Vectors::ARROW:
598       aParam = "VISU.Vectors.ARROW";
599       break;
600     case Vectors::CONE2:
601       aParam = "VISU.Vectors.CONE2";
602       break;
603     case Vectors::CONE6:
604       aParam = "VISU.Vectors.CONE6";
605       break;
606     case Vectors::NONE:
607       aParam = "VISU.Vectors.NONE";
608       break;
609     }
610     theStr<<thePrefix<<theName<<".SetGlyphType("<<aParam<<")"<<endl;
611     
612     switch(theServant->GetGlyphPos()){
613     case Vectors::CENTER:
614       aParam = "VISU.Vectors.CENTER";
615       break;
616     case Vectors::TAIL:
617       aParam = "VISU.Vectors.TAIL";
618       break;
619     case Vectors::HEAD:
620       aParam = "VISU.Vectors.HEAD";
621       break;
622     }
623     theStr<<thePrefix<<theName<<".SetGlyphPos("<<aParam<<")"<<endl;
624     
625     return thePrefix;
626   }
627
628
629   //---------------------------------------------------------------------------
630   std::string
631   IsoSurfacesToPython(SALOMEDS::SObject_ptr theSObject,
632                       VISU::IsoSurfaces_i* theServant,
633                       std::ostream& theStr,
634                       const std::string& theName,
635                       TColoredPrs3dFactory& thePrsFactory,
636                       std::string thePrefix)
637   {
638     thePrefix = ScalarMapToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
639     theStr<<thePrefix<<endl;
640
641     theStr<<thePrefix<<theName<<".SetNbSurfaces("<<theServant->GetNbSurfaces()<<")"<<endl;
642     theStr<<thePrefix<<theName<<".ShowLabels("<<theServant->IsLabeled()<<","<<theServant->GetNbLabels()<<")"<<endl;
643
644     return thePrefix;
645   }
646
647
648   //---------------------------------------------------------------------------
649   std::string
650   CutPlanesToPython(SALOMEDS::SObject_ptr theSObject,
651                     VISU::CutPlanes_i* theServant,
652                     std::ostream& theStr,
653                     const std::string& theName,
654                     TColoredPrs3dFactory& thePrsFactory,
655                     std::string thePrefix)
656   {
657     thePrefix = ScalarMapToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
658     theStr<<thePrefix<<endl;
659
660     std::string aParam;
661     switch(theServant->GetOrientationType()){
662     case CutPlanes::XY:
663       aParam = "VISU.CutPlanes.XY";
664       break;
665     case CutPlanes::YZ:
666       aParam = "VISU.CutPlanes.YZ";
667       break;
668     case CutPlanes::ZX:
669       aParam = "VISU.CutPlanes.ZX";
670       break;
671     }
672     theStr<<thePrefix<<theName<<".SetOrientation("<<aParam<<", "<<theServant->GetRotateX()<<", "<<theServant->GetRotateY()<<")"<<endl;
673     
674     theStr<<thePrefix<<theName<<".SetDisplacement("<<theServant->GetDisplacement()<<")"<<endl;
675     CORBA::Long aNbPlanes = theServant->GetNbPlanes();
676     theStr<<thePrefix<<theName<<".SetNbPlanes("<<aNbPlanes<<")"<<endl;
677     
678     for(CORBA::Long anId = 0; anId < aNbPlanes; anId++){
679       if(!theServant->IsDefault(anId))
680         theStr<<thePrefix<<theName<<".SetPlanePosition("<<anId<<", "<<theServant->GetPlanePosition(anId)<<")"<<endl;
681     }
682
683     theStr<<thePrefix<<theName<<".UseDeformation("<<GetBoolean(theServant->IsDeformed())<<")"<<endl;
684     if(theServant->IsDeformed()){
685       theStr<< thePrefix << theName << ".SetScale(" << theServant->GetScale()<<")"<<endl;
686       std::string aStringEntity;
687       VISU::Entity anEntity = theServant->GetVectorialFieldEntity();
688       switch(anEntity){
689       case NODE:
690         aStringEntity = "VISU.NODE";
691         break;
692       case EDGE:
693         aStringEntity = "VISU.EDGE";
694         break;
695       case FACE:
696         aStringEntity = "VISU.FACE";
697         break;
698       case CELL:
699         aStringEntity = "VISU.CELL";
700         break;
701       }
702       theStr<< thePrefix << theName << ".SetVectorialField("<<aStringEntity<<", '" << theServant->GetVectorialFieldName() <<"')"<<endl;
703     }
704     return thePrefix;
705   }
706
707
708   //---------------------------------------------------------------------------
709   std::string
710   CutLinesToPython(SALOMEDS::SObject_ptr theSObject,
711                    VISU::CutLines_i* theServant,
712                    std::ostream& theStr,
713                    const std::string& theName,
714                    TColoredPrs3dFactory& thePrsFactory,
715                    std::string thePrefix)
716   {
717     thePrefix = ScalarMapToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
718     theStr<<thePrefix<<endl;
719
720     std::string aParam;
721     switch(theServant->GetOrientationType()){
722     case CutPlanes::XY:
723       aParam = "VISU.CutPlanes.XY";
724       break;
725     case CutPlanes::YZ:
726       aParam = "VISU.CutPlanes.YZ";
727       break;
728     case CutPlanes::ZX:
729       aParam = "VISU.CutPlanes.ZX";
730       break;
731     }
732     theStr<<thePrefix<<theName<<".SetOrientation("<<aParam<<", "<<theServant->GetRotateX()<<", "<<theServant->GetRotateY()<<")"<<endl;
733     
734     switch(theServant->GetOrientationType2()){
735     case CutPlanes::XY:
736       aParam = "VISU.CutPlanes.XY";
737       break;
738     case CutPlanes::YZ:
739       aParam = "VISU.CutPlanes.YZ";
740       break;
741     case CutPlanes::ZX:
742       aParam = "VISU.CutPlanes.ZX";
743       break;
744     }
745     theStr<<thePrefix<<theName<<".SetOrientation2("<<aParam<<", "<<theServant->GetRotateX2()<<", "<<theServant->GetRotateY2()<<")"<<endl;
746     
747     theStr<<thePrefix<<theName<<".SetDisplacement("<<theServant->GetDisplacement()<<")"<<endl;
748     theStr<<thePrefix<<theName<<".SetDisplacement2("<<theServant->GetDisplacement2()<<")"<<endl;
749     
750     if(!theServant->IsDefault())
751       theStr<<thePrefix<<theName<<".SetBasePlanePosition("<<theServant->GetBasePlanePosition()<<")"<<endl;
752     
753     CORBA::Boolean aUseAbsLength = theServant->IsUseAbsoluteLength();
754     theStr<<thePrefix<<theName<<".SetUseAbsoluteLength("<<aUseAbsLength<<")"<<endl;
755     
756     CORBA::Long aNbLines = theServant->GetNbLines();
757     theStr<<thePrefix<<theName<<".SetNbLines("<<aNbLines<<")"<<endl;
758     for(CORBA::Long anId = 0; anId < aNbLines; anId++){
759       if(!theServant->IsDefaultPosition(anId))
760         theStr<<thePrefix<<theName<<".SetLinePosition("<<anId<<", "<<theServant->GetLinePosition(anId)<<")"<<endl;
761     }
762     
763     return thePrefix;
764   }
765
766
767   //---------------------------------------------------------------------------
768   std::string
769   Plot3DToPython(SALOMEDS::SObject_ptr theSObject,
770                  VISU::Plot3D_i* theServant,
771                  std::ostream& theStr,
772                  const std::string& theName,
773                  TColoredPrs3dFactory& thePrsFactory,
774                  std::string thePrefix)
775   {
776     thePrefix = ScalarMapToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
777     theStr<<thePrefix<<endl;
778
779     std::string aParam;
780     switch(theServant->GetOrientationType()){
781     case CutPlanes::XY: 
782       aParam = "VISU.Plot3D.XY"; 
783       break;
784     case CutPlanes::YZ: 
785       aParam = "VISU.Plot3D.YZ"; 
786       break;
787     case CutPlanes::ZX: 
788       aParam = "VISU.Plot3D.ZX"; 
789       break;
790     }
791     theStr<<thePrefix<<theName<<".SetOrientation("<<aParam<<", "<<theServant->GetRotateX()<<", "<<theServant->GetRotateY()<<")"<<endl;
792
793     theStr<<thePrefix<<theName<<".SetPlanePosition("<<theServant->GetPlanePosition()<<", "<<theServant->IsPositionRelative()<<")"<<endl;
794     theStr<<thePrefix<<theName<<".SetScaleFactor("<<theServant->GetScaleFactor()<<")"<<endl;
795     theStr<<thePrefix<<theName<<".SetContourPrs("<<theServant->GetIsContourPrs()<<")"<<endl;
796     theStr<<thePrefix<<theName<<".SetNbOfContours("<<theServant->GetNbOfContours()<<")"<<endl;
797
798     return thePrefix;
799   }
800
801   //---------------------------------------------------------------------------
802   // declaration
803   void DumpChildrenToPython(SALOMEDS::Study_ptr theStudy,
804                             CORBA::Boolean theIsPublished,
805                             CORBA::Boolean& theIsValidScript,
806                             SALOMEDS::SObject_ptr theSObject,
807                             std::ostream& theStr,
808                             TName2EntryMap& theName2EntryMap,
809                             TEntry2NameMap& theEntry2NameMap,
810                             std::string theArgumentName,
811                             std::string thePrefix);
812
813   //---------------------------------------------------------------------------
814   template<class TTableAttr>
815   void
816   TableAttrToPython(SALOMEDS::Study_ptr theStudy,
817                     CORBA::Boolean theIsPublished,
818                     CORBA::Boolean& theIsValidScript,
819                     SALOMEDS::SObject_ptr theSObject,
820                     TTableAttr theTableAttr,
821                     const std::string& theAttrName,
822                     std::ostream& theStr,
823                     TName2EntryMap& theName2EntryMap,
824                     TEntry2NameMap& theEntry2NameMap,
825                     std::string theArgumentName,
826                     std::string thePrefix)
827   {
828     SALOMEDS::GenericAttribute_var anAttr;
829     SALOMEDS::SObject_var aFatherSObject = theSObject->GetFather();
830     if(aFatherSObject->FindAttribute(anAttr,"AttributeString")){
831       SALOMEDS::AttributeString_var aComment =
832         SALOMEDS::AttributeString::_narrow(anAttr);
833       CORBA::String_var aValue = aComment->Value();
834       Storable::TRestoringMap aMap;
835       Storable::StringToMap(aValue.in(),aMap);
836       bool anIsExist;
837       QString aMethodName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist);
838       if(anIsExist){
839         if(strcmp(aMethodName.toLatin1().data(),"ImportTables") == 0){
840           return;
841         }
842       }
843     }
844
845     std::string aSObjectName = GetName(theSObject);
846     theStr<<thePrefix<<aSObjectName<<" = aBuilder.NewObject(aSComponent)"<<endl;
847     theStr<<thePrefix<<"if "<<aSObjectName<<":"<<endl;
848     thePrefix += PREFIX;
849
850     theStr<<thePrefix<<"aBuilder.SetName("<<aSObjectName<<", \""<<theSObject->GetName()<<"\")"<<endl; // Fix for IPAL13165
851     std::string aName = "aTableAttr";
852     theStr<<thePrefix<<aName<<" = aBuilder.FindOrCreateAttribute("<<
853       aSObjectName<<", '"<<theAttrName<<"')"<<endl;
854
855     theStr<<thePrefix<<"if "<<aName<<":"<<endl;
856     std::string aPrefix = thePrefix;
857     thePrefix += PREFIX;
858
859     CORBA::String_var aString = theTableAttr->GetTitle();
860     theStr<<thePrefix<<aName<<".SetTitle('"<<aString.in()<<"')"<<endl;
861
862     CORBA::Long aNbColumns = theTableAttr->GetNbColumns();
863     theStr<<thePrefix<<aName<<".SetNbColumns("<<aNbColumns<<")"<<endl;
864
865     CORBA::Long aNbRows = theTableAttr->GetNbRows();
866
867     // push values and their indices into streams
868     strstream values, rows, columns;
869     string comma = "";
870     for(CORBA::Long i = 1; i <= aNbColumns; i++){
871       for(CORBA::Long j = aNbRows; j > 0; j--){
872         if(theTableAttr->HasValue(j,i)){
873           values  << comma << theTableAttr->GetValue(j,i);
874           rows    << comma << j;
875           columns << comma << i;
876           if ( comma.empty() )
877             comma = ",";
878         }
879       }
880     }
881     // push titles and units into streams
882     strstream rowUnits, rowTitles, colTitles;
883     SALOMEDS::StringSeq_var aRowUnits = theTableAttr->GetRowUnits();
884     SALOMEDS::StringSeq_var aRowTitles = theTableAttr->GetRowTitles();
885     comma = "";
886     for(CORBA::Long j = 1; j <= aNbRows; j++){
887       rowUnits  << comma << "'" << aRowUnits [ j - 1 ] << "'";
888       rowTitles << comma << "'" << aRowTitles[ j - 1 ] << "'";
889       if ( comma.empty() )
890         comma = ",";
891     }
892     SALOMEDS::StringSeq_var aColumnTitles = theTableAttr->GetColumnTitles();
893     comma = "";
894     for(CORBA::Long j = 1; j <= aNbColumns; j++){
895       colTitles << comma << "'" << aColumnTitles[ j - 1 ] << "'";
896       if ( comma.empty() )
897         comma = ",";
898     }
899     values    << '\0';
900     rows      << '\0';
901     columns   << '\0';
902     rowUnits  << '\0';
903     rowTitles << '\0';
904     colTitles << '\0';
905     // write FillTable command
906     theStr<< thePrefix << aName << "_values  = [" << values.str()  << "]" << endl;
907     theStr<< thePrefix << aName << "_rows    = [" << rows.str()    << "]" << endl;
908     theStr<< thePrefix << aName << "_columns = [" << columns.str() << "]" << endl;
909     theStr<< thePrefix << aName << "_rUnits  = [" << rowUnits.str()  << "]" << endl;
910     theStr<< thePrefix << aName << "_rTitles = [" << rowTitles.str() << "]" << endl;
911     theStr<< thePrefix << aName << "_cTitles = [" << colTitles.str() << "]" << endl;
912     theStr<< thePrefix << "visu.FillTable( "
913       << aName << ", "
914         << aName << "_values, "
915           << aName << "_rows, "
916             << aName << "_columns, "
917               << aName << "_rTitles, "
918                 << aName << "_rUnits, "
919                   << aName << "_cTitles )" << endl;
920
921     if(theSObject->FindAttribute(anAttr,"AttributeIOR")){
922       theStr<<thePrefix<<endl;
923       std::string aName = "aTable";
924       theStr<<thePrefix<<"anID = "<<aSObjectName<<".GetID()"<<endl;
925       theStr<<thePrefix<<aName<<" = aVisu.CreateTable(anID)"<<endl;
926       theArgumentName = aName;
927
928       theStr<<thePrefix<<"if "<<aName<<":"<<endl;
929       std::string aPrefix2 = thePrefix + PREFIX;
930
931       // Set name (as this object could be renamed by user)
932       CORBA::String_var aNameInStudy = theSObject->GetName();
933       theStr<<aPrefix2<<aName<<".SetTitle('"<<aNameInStudy.in()<<"') # 1"<<endl;
934
935       DumpChildrenToPython(theStudy,
936                            theIsPublished,
937                            theIsValidScript,
938                            theSObject,
939                            theStr,
940                            theName2EntryMap,
941                            theEntry2NameMap,
942                            theArgumentName,
943                            aPrefix2);
944
945       theStr<<aPrefix2<<"pass"<<endl<<endl;
946     }
947
948     theStr<<thePrefix<<"pass"<<endl<<endl;
949     theStr<<aPrefix<<"pass"<<endl<<endl;
950   }
951
952
953   //---------------------------------------------------------------------------
954   void
955   DumpChildrenToPython(SALOMEDS::Study_ptr theStudy,
956                        CORBA::Boolean theIsPublished,
957                        CORBA::Boolean& theIsValidScript,
958                        SALOMEDS::SObject_ptr theSObject,
959                        std::ostream& theStr,
960                        TName2EntryMap& theName2EntryMap,
961                        TEntry2NameMap& theEntry2NameMap,
962                        std::string theArgumentName,
963                        std::string thePrefix)
964   {
965     SALOMEDS::ChildIterator_var aChildItet = theStudy->NewChildIterator(theSObject);
966     for(aChildItet->InitEx(false); aChildItet->More(); aChildItet->Next()){
967       SALOMEDS::SObject_var aSObject = aChildItet->Value();
968       DumpToPython(theStudy,
969                    theIsPublished,
970                    theIsValidScript,
971                    aSObject,
972                    theStr,
973                    theName2EntryMap,
974                    theEntry2NameMap,
975                    theArgumentName,
976                    thePrefix);
977     }
978   }
979
980
981   //---------------------------------------------------------------------------
982   void
983   DumpTableAttrToPython(SALOMEDS::Study_ptr theStudy,
984                         CORBA::Boolean theIsPublished,
985                         CORBA::Boolean& theIsValidScript,
986                         SALOMEDS::SObject_ptr theSObject,
987                         std::ostream& theStr,
988                         TName2EntryMap& theName2EntryMap,
989                         TEntry2NameMap& theEntry2NameMap,
990                         std::string theArgumentName,
991                         std::string thePrefix)
992   {
993     SALOMEDS::GenericAttribute_var anAttr;
994     if(theSObject->FindAttribute(anAttr,"AttributeTableOfInteger")){
995       SALOMEDS::AttributeTableOfInteger_var aTableAttr =
996         SALOMEDS::AttributeTableOfInteger::_narrow(anAttr);
997
998       TableAttrToPython(theStudy,
999                         theIsPublished,
1000                         theIsValidScript,
1001                         theSObject,
1002                         aTableAttr,
1003                         "AttributeTableOfInteger",
1004                         theStr,
1005                         theName2EntryMap,
1006                         theEntry2NameMap,
1007                         theArgumentName,
1008                         thePrefix);
1009
1010     }else if(theSObject->FindAttribute(anAttr,"AttributeTableOfReal")){
1011       SALOMEDS::AttributeTableOfReal_var aTableAttr =
1012         SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
1013
1014       TableAttrToPython(theStudy,
1015                         theIsPublished,
1016                         theIsValidScript,
1017                         theSObject,
1018                         aTableAttr,
1019                         "AttributeTableOfReal",
1020                         theStr,
1021                         theName2EntryMap,
1022                         theEntry2NameMap,
1023                         theArgumentName,
1024                         thePrefix);
1025     }
1026   }
1027
1028
1029
1030   //---------------------------------------------------------------------------
1031   void
1032   DumpToPython(SALOMEDS::Study_ptr theStudy,
1033                CORBA::Boolean theIsPublished,
1034                CORBA::Boolean& theIsValidScript,
1035                SALOMEDS::SObject_ptr theSObject,
1036                std::ostream& theStr,
1037                TName2EntryMap& theName2EntryMap,
1038                TEntry2NameMap& theEntry2NameMap,
1039                std::string theArgumentName,
1040                std::string thePrefix)
1041   {
1042     std::string aName = GetName(theSObject);
1043     if (aName == "")
1044       return;
1045
1046     CORBA::String_var anID = theSObject->GetID();
1047     CORBA::String_var aNameInStudy = theSObject->GetName();
1048
1049     CORBA::Object_var anObj = SObjectToObject(theSObject);
1050     if (!CORBA::is_nil(anObj)) {
1051       VISU::Base_var aBase = VISU::Base::_narrow(anObj);
1052       if(!CORBA::is_nil(aBase)){
1053         std::string aName = GenerateName(theSObject, theName2EntryMap, theEntry2NameMap);
1054
1055         VISU::VISUType aType = aBase->GetType();
1056         switch(aType){
1057         case VISU::TRESULT:
1058           if(Result_i* aServant = dynamic_cast<Result_i*>(GetServant(anObj).in())){
1059             std::string aFileName = aServant->GetInitFileName();
1060             Result_i::ECreationId anId = aServant->GetCreationId();
1061             if(anId == Result_i::eImportFile || anId == Result_i::eCopyAndImportFile){
1062               switch(anId){
1063               case Result_i::eImportFile:
1064                 theStr<<thePrefix<<aName<<" = aVisu.CreateResult('"<<aFileName<<"')"<<endl;
1065
1066                 theStr<<thePrefix<<aName<<".SetBuildGroups("<<
1067                   GetBoolean(aServant->IsGroupsDone())<<")"<<
1068                   endl;
1069
1070                 theStr<<thePrefix<<aName<<".SetBuildFields("<<
1071                   GetBoolean(aServant->IsFieldsDone())<<", "<<
1072                   GetBoolean(aServant->IsMinMaxDone())<<")"<<
1073                   endl;
1074
1075                 theStr<<thePrefix<<aName<<".Build(False, True)"<<endl;
1076
1077                 theStr<<thePrefix<<"if "<<aName<<".IsDone() :"<<endl;
1078                 break;
1079               case Result_i::eCopyAndImportFile:
1080                 theStr<<thePrefix<<aName<<" = aVisu.CopyAndImportFile('"<<aFileName<<"')"<<endl;
1081                 theStr<<thePrefix<<"if "<<aName<<":"<<endl;
1082                 break;
1083               }
1084
1085               thePrefix += PREFIX;
1086               {
1087                 VISU::Result::EntityNames_var aMeshNames = aServant->GetMeshNames();
1088                 if (aMeshNames->length() > 0) {
1089                   for(size_t aMeshId = 0; aMeshId < aMeshNames->length(); aMeshId++){
1090                     CORBA::String_var aMeshName = aMeshNames[aMeshId];
1091                     VISU::Result::EntityNames_var aParts = aServant->GetPartNames(aMeshName);
1092                     if (aParts->length() > 0) {
1093                       for(size_t aPartId = 0; aPartId < aParts->length(); aPartId++){
1094                         CORBA::String_var aPart = aParts[aPartId];
1095                         VISU::Result::Resolution aResolution = aServant->GetResolution(aMeshName, aPart);
1096                         std::string aParam;
1097                         switch(aResolution){
1098                         case VISU::Result::FULL:
1099                           aParam = "VISU.Result.FULL";
1100                           break;
1101                         case VISU::Result::MEDIUM:
1102                           aParam = "VISU.Result.MEDIUM";
1103                           break;
1104                         case VISU::Result::LOW:
1105                           aParam = "VISU.Result.LOW";
1106                           break;
1107                         case VISU::Result::HIDDEN:
1108                           aParam = "VISU.Result.HIDDEN";
1109                           break;
1110                         }
1111                         theStr<<thePrefix<<aName<<".SetResolution('"<<aMeshName.in()<<"', '"<<aPart.in()<<"', "<<aParam<<")"<<endl;
1112                       }
1113                       theStr<<thePrefix<<endl;
1114                     }
1115                   }
1116                 }
1117               }
1118
1119               theArgumentName = aName;
1120               DumpChildrenToPython(theStudy,
1121                                    theIsPublished,
1122                                    theIsValidScript,
1123                                    theSObject,
1124                                    theStr,
1125                                    theName2EntryMap,
1126                                    theEntry2NameMap,
1127                                    theArgumentName,
1128                                    thePrefix);
1129
1130               theStr<<thePrefix<<"pass"<<endl<<endl;
1131             }else{
1132               SALOMEDS::SObject_var aRefSObj;
1133               if(theSObject->FindSubObject(1,aRefSObj)){
1134                 SALOMEDS::SObject_var aTargetRefSObj;
1135                 if(aRefSObj->ReferencedObject(aTargetRefSObj)){
1136                   CORBA::String_var aString = aTargetRefSObj->GetName();
1137                   theStr<<thePrefix<<"aSObject = theStudy.FindObject('"<<aString.in()<<"')"<<endl;
1138                   theStr<<thePrefix<<"if aSObject:"<<endl;
1139                   thePrefix += PREFIX;
1140                   theStr<<thePrefix<<"anObject = aSObject.GetObject()"<<endl;
1141                   theStr<<thePrefix<<"if anObject:"<<endl;
1142                   std::string aPrefix1 = thePrefix;
1143                   thePrefix += PREFIX;
1144
1145                   switch(anId){
1146                   case Result_i::eImportMed:
1147                     theStr<<thePrefix<<aName<<" = aVisu.ImportMed(aSObject)"<<endl;
1148                     break;
1149                   case Result_i::eImportMedField:
1150                     theStr<<thePrefix<<aName<<" = aVisu.ImportMedField(anObject)"<<endl;
1151                     break;
1152                   }
1153
1154                   theStr<<thePrefix<<"if "<<aName<<":"<<endl;
1155                   std::string aPrefix2 = thePrefix;
1156                   thePrefix += PREFIX;
1157
1158                   theArgumentName = aName;
1159                   DumpChildrenToPython(theStudy,
1160                                        theIsPublished,
1161                                        theIsValidScript,
1162                                        theSObject,
1163                                        theStr,
1164                                        theName2EntryMap,
1165                                        theEntry2NameMap,
1166                                        theArgumentName,
1167                                        thePrefix);
1168
1169                   theStr<<thePrefix<<"pass"<<endl<<endl;
1170                   theStr<<aPrefix2<<"pass"<<endl<<endl;
1171                   theStr<<aPrefix1<<"pass"<<endl<<endl;
1172                 }
1173               }
1174             }
1175           }
1176           return;
1177         case VISU::TMESH:
1178           if(Mesh_i* aServant = dynamic_cast<Mesh_i*>(GetServant(anObj).in())){     
1179             VISU::Entity anEntity = aServant->GetEntity();
1180             const std::string& aSubMeshName = aServant->GetSubMeshName();
1181             if(anEntity >= 0){
1182               std::string aParam;
1183               switch(anEntity){
1184               case NODE:
1185                 aParam = "VISU.NODE";
1186                 break;
1187               case EDGE:
1188                 aParam = "VISU.EDGE";
1189                 break;
1190               case FACE:
1191                 aParam = "VISU.FACE";
1192                 break;
1193               case CELL:
1194                 aParam = "VISU.CELL";
1195                 break;
1196               }
1197
1198               if(aSubMeshName == "")
1199                 theStr<<thePrefix<<aName<<" = aVisu.MeshOnEntity("<<theArgumentName<<
1200                   ", '"<<aServant->GetCMeshName()<<"'"<<
1201                   ", "<<aParam<<
1202                   ")"<<endl;
1203               else
1204                 theStr<<thePrefix<<aName<<" = aVisu.FamilyMeshOnEntity("<<theArgumentName<<
1205                   ", '"<<aServant->GetCMeshName()<<"'"<<
1206                   ", "<<aParam<<
1207                   ", '"<<aSubMeshName<<"'"<<
1208                   ")"<<endl;
1209             }else
1210               theStr<<thePrefix<<aName<<" = aVisu.GroupMesh("<<theArgumentName<<
1211                 ", '"<<aServant->GetCMeshName()<<"'"<<
1212                 ", '"<<aSubMeshName<<"'"<<
1213                 ")"<<endl;
1214
1215             theStr<<thePrefix<<"if "<<aName<<":"<<endl;
1216             thePrefix += PREFIX;
1217
1218             // Add to Name->Object map
1219             theStr<<thePrefix<<"aName2ObjectMap['"<<aName<<"'] = "<<aName<<endl;
1220
1221             // Set name (as this object could be renamed by user)
1222             theStr<<thePrefix<<"visu.SetName("<<aName<<", '"<<aNameInStudy.in()<<"')"<<endl;
1223
1224             // Set parameters common for all Prs3d objects (offset values)
1225             Prs3dToPython(aServant,theStr,aName,thePrefix);
1226
1227             // Set presentation parameters
1228             SALOMEDS::Color aColor;
1229             aColor = aServant->GetCellColor();
1230             theStr<<thePrefix<<aName<<".SetCellColor(SALOMEDS.Color("<<
1231               aColor.R<<", "<<aColor.G<<", "<<aColor.B<<"))"<<endl;
1232
1233             aColor = aServant->GetNodeColor();
1234             theStr<<thePrefix<<aName<<".SetNodeColor(SALOMEDS.Color("<<
1235               aColor.R<<", "<<aColor.G<<", "<<aColor.B<<"))"<<endl;
1236
1237             aColor = aServant->GetLinkColor();
1238             theStr<<thePrefix<<aName<<".SetLinkColor(SALOMEDS.Color("<<
1239               aColor.R<<", "<<aColor.G<<", "<<aColor.B<<"))"<<endl;
1240
1241             std::string aParam;
1242             switch(aServant->GetPresentationType()){
1243             case POINT:
1244               aParam = "VISU.POINT";
1245               break;
1246             case WIREFRAME:
1247               aParam = "VISU.WIREFRAME";
1248               break;
1249             case SHADED:
1250               aParam = "VISU.SHADED";
1251               break;
1252             case INSIDEFRAME:
1253               aParam = "VISU.INSIDEFRAME";
1254               break;
1255             case SURFACEFRAME:
1256               aParam = "VISU.SURFACEFRAME";
1257               break;
1258             case SHRINK:
1259               aParam = "VISU.SHRINK";
1260               break;
1261             }
1262             theStr<<thePrefix<<aName<<".SetPresentationType("<<aParam<<")"<<endl;
1263             theStr<<thePrefix<<aName<<".SetShrink("<<(aServant->IsShrank()? "True" : "False")<<")"<<endl;
1264             theStr<<thePrefix<<endl;
1265
1266             std::string aQuad2DPresent;
1267             switch(aServant->GetQuadratic2DPresentationType()){
1268             case LINES:
1269               aQuad2DPresent = "VISU.LINES";
1270               break;
1271             case ARCS:
1272               aQuad2DPresent = "VISU.ARCS";
1273               break;
1274             }
1275
1276             theStr<<thePrefix<<aName<<".SetQuadratic2DPresentationType("<<aQuad2DPresent<<")"<<endl;
1277             
1278             DumpChildrenToPython(theStudy,
1279                                  theIsPublished,
1280                                  theIsValidScript,
1281                                  theSObject,
1282                                  theStr,
1283                                  theName2EntryMap,
1284                                  theEntry2NameMap,
1285                                  theArgumentName,
1286                                  thePrefix);
1287
1288             theStr<<thePrefix<<"pass"<<endl<<endl;
1289             return;
1290           }
1291           break;
1292         case VISU::TSCALARMAP:
1293           if(ScalarMap_i* aServant = dynamic_cast<ScalarMap_i*>(GetServant(anObj).in())){
1294             TCreateFromResult aPrsFactory(theSObject, aServant, aName, "ScalarMapOnField", theArgumentName);
1295             thePrefix = ScalarMapToPython(theSObject, aServant, theStr,aName, aPrsFactory, thePrefix);
1296             theStr<<thePrefix<<"pass"<<endl<<endl;
1297           }
1298           return;
1299         case VISU::TDEFORMEDSHAPE:
1300           if(DeformedShape_i* aServant = dynamic_cast<DeformedShape_i*>(GetServant(anObj).in())){
1301             TCreateFromResult aPrsFactory(theSObject, aServant, aName, "DeformedShapeOnField", theArgumentName);
1302             thePrefix = DeformedShapeToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
1303             theStr<<thePrefix<<"pass"<<endl<<endl;
1304           }
1305           return;
1306         case VISU::TSTREAMLINES:
1307           if(StreamLines_i* aServant = dynamic_cast<StreamLines_i*>(GetServant(anObj).in())){
1308             TCreateFromResult aPrsFactory(theSObject, aServant, aName, "StreamLinesOnField", theArgumentName);
1309             thePrefix = StreamLinesToPython(theSObject, aServant, theStr, theEntry2NameMap, aName, aPrsFactory, thePrefix);
1310             theStr<<thePrefix<<"pass"<<endl<<endl;
1311           }
1312           return;
1313         case VISU::TSCALARMAPONDEFORMEDSHAPE:
1314         case VISU::TDEFORMEDSHAPEANDSCALARMAP:
1315           if(DeformedShapeAndScalarMap_i* aServant = dynamic_cast<DeformedShapeAndScalarMap_i*>(GetServant(anObj).in())){
1316             TCreateFromResult aPrsFactory(theSObject, aServant, aName, "DeformedShapeAndScalarMapOnField", theArgumentName);
1317             thePrefix = DeformedShapeAndScalarMapToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
1318             theStr<<thePrefix<<"pass"<<endl<<endl;
1319           }
1320           return;
1321         case VISU::TVECTORS:
1322           if(Vectors_i* aServant = dynamic_cast<Vectors_i*>(GetServant(anObj).in())){
1323             TCreateFromResult aPrsFactory(theSObject, aServant, aName, "VectorsOnField", theArgumentName);
1324             thePrefix = VectorsToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
1325             theStr<<thePrefix<<"pass"<<endl<<endl;
1326           }
1327           return;
1328         case VISU::TISOSURFACES:
1329           if(IsoSurfaces_i* aServant = dynamic_cast<IsoSurfaces_i*>(GetServant(anObj).in())){
1330             TCreateFromResult aPrsFactory(theSObject, aServant, aName, "IsoSurfacesOnField", theArgumentName);
1331             thePrefix = IsoSurfacesToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
1332             theStr<<thePrefix<<"pass"<<endl<<endl;
1333           }
1334           return;
1335         case VISU::TCUTPLANES:
1336           if(CutPlanes_i* aServant = dynamic_cast<CutPlanes_i*>(GetServant(anObj).in())){
1337             TCreateFromResult aPrsFactory(theSObject, aServant, aName, "CutPlanesOnField", theArgumentName);
1338             thePrefix = CutPlanesToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
1339             theStr<<thePrefix<<"pass"<<endl<<endl;
1340           }
1341           return;
1342         case VISU::TCUTLINES:
1343           if(CutLines_i* aServant = dynamic_cast<CutLines_i*>(GetServant(anObj).in())){
1344             TCreateFromResult aPrsFactory(theSObject, aServant, aName, "CutLinesOnField", theArgumentName);
1345             thePrefix = CutLinesToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
1346
1347             theArgumentName = aName;
1348             DumpChildrenToPython(theStudy,
1349                                  theIsPublished,
1350                                  theIsValidScript,
1351                                  theSObject,
1352                                  theStr,
1353                                  theName2EntryMap,
1354                                  theEntry2NameMap,
1355                                  theArgumentName,
1356                                  thePrefix);
1357
1358             theStr<<thePrefix<<"pass"<<endl<<endl;
1359           }
1360           return;
1361         case VISU::TPLOT3D:
1362           if (Plot3D_i* aServant = dynamic_cast<Plot3D_i*>(GetServant(anObj).in())) {
1363             TCreateFromResult aPrsFactory(theSObject, aServant, aName, "Plot3DOnField", theArgumentName);
1364             thePrefix = Plot3DToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
1365             theStr<<thePrefix<<"pass"<<endl<<endl;
1366           }
1367           return;
1368         case VISU::TPOINTMAP3D:
1369           if (PointMap3d_i* aServant = dynamic_cast<PointMap3d_i*>(GetServant(anObj).in())) {
1370             CORBA::Short aTag = theSObject->Tag();
1371             theStr<<thePrefix<<"anIsFound, aSObject = "<<theArgumentName<<".FindSubObject("<<aTag<<")"<<endl;
1372             theStr<<thePrefix<<"if anIsFound:"<<endl;
1373             thePrefix += PREFIX;
1374             
1375             theStr<<thePrefix<<"anID = aSObject.GetID()"<<endl;
1376             theStr<<thePrefix<<aName<<" = aVisu.CreateTable(anID)"<<endl;
1377             
1378             // Set name (as this object could be renamed by user)
1379             theStr<<thePrefix<<aName<<".SetTitle('"<<aNameInStudy.in()<<"') # 3"<<endl;
1380
1381             // Set PointMap3D Properties
1382
1383             theStr<<thePrefix<<aName<<".SetScaleFactor("<<aServant->GetScaleFactor()<<")"<<endl;
1384             theStr<<thePrefix<<aName<<".SetContourPrs("<<aServant->GetIsContourPrs()<<")"<<endl;
1385             theStr<<thePrefix<<aName<<".SetNbOfContours("<<aServant->GetNbOfContours()<<")"<<endl;
1386
1387             std::string aParam;
1388             switch(aServant->GetScaling()){
1389             case LINEAR:
1390               aParam = "VISU.LINEAR";
1391               break;
1392             case LOGARITHMIC:
1393               aParam = "VISU.LOGARITHMIC";
1394               break;
1395             }
1396             theStr<<thePrefix<<aName<<".SetScaling("<<aParam<<")"<<endl;
1397
1398             theStr<<thePrefix<<aName<<".SetNbColors("<<aServant->GetNbColors()<<")"<<endl;
1399             theStr<<thePrefix<<aName<<".SetLabels("<<aServant->GetLabels()<<")"<<endl;
1400
1401             switch(aServant->GetBarOrientation()){
1402             case ColoredPrs3dBase::HORIZONTAL:
1403               aParam = "VISU.ColoredPrs3d.HORIZONTAL";
1404               break;
1405             case ColoredPrs3dBase::VERTICAL:
1406               aParam = "VISU.ColoredPrs3d.VERTICAL";
1407               break;
1408             }
1409             theStr<<thePrefix<<aName<<".SetBarOrientation("<<aParam<<")"<<endl;
1410
1411             if(aServant->IsRangeFixed())
1412               theStr<<thePrefix<<aName<<".SetRange("<<aServant->GetMin()<<", "<<aServant->GetMax()<<")"<<endl;
1413             else
1414               theStr<<thePrefix<<aName<<".SetSourceRange()"<<endl;
1415
1416             theStr<<thePrefix<<aName<<".SetPosition("<<aServant->GetPosX()<<", "<<aServant->GetPosY()<<")"<<endl;
1417             theStr<<thePrefix<<aName<<".SetSize("<<aServant->GetWidth()<<", "<<aServant->GetHeight()<<")"<<endl;
1418
1419             float dx, dy, dz;
1420             aServant->GetOffset(dx, dy, dz);
1421             theStr<<thePrefix<<aName<<".SetOffset("<<dx<<", "<<dy<<", "<<dz<<")"<<endl;
1422
1423             
1424             theStr<<thePrefix<<endl;
1425             
1426             theArgumentName = aName;
1427             DumpChildrenToPython(theStudy,
1428                                  theIsPublished,
1429                                  theIsValidScript,
1430                                  theSObject,
1431                                  theStr,
1432                                  theName2EntryMap,
1433                                  theEntry2NameMap,
1434                                  theArgumentName,
1435                                  thePrefix);
1436
1437             theStr<<thePrefix<<"pass"<<endl<<endl;
1438           }
1439           return;
1440         case VISU::TGAUSSPOINTS:
1441           if(GaussPoints_i* aServant = dynamic_cast<GaussPoints_i*>(GetServant(anObj).in())){
1442             TCreateFromResult aPrsFactory(theSObject, aServant, aName, "GaussPointsOnField", theArgumentName);
1443             thePrefix = GaussPointsToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
1444             theStr<<thePrefix<<"pass"<<endl<<endl;
1445           }
1446           return;
1447         case VISU::TCURVE:
1448           if(Curve_i* aServant = dynamic_cast<Curve_i*>(GetServant(anObj).in()))
1449           {
1450             bool withZ = aServant->GetZRow()>0;
1451               
1452             theStr << thePrefix << "aName2ObjectMap['" << aName << "'] = visu.CreateCurve";
1453             if( withZ )
1454               theStr << "WithZ";
1455             theStr << "(" <<
1456               theArgumentName<< // table
1457                 ", "<<aServant->GetHRow()<< // H row
1458                   ", "<<aServant->GetVRow(); // V row
1459             if( withZ )
1460               theStr << ", " << aServant->GetZRow(); // Z row
1461
1462             theStr << ", '"<<aServant->GetTitle()<<"'"; // title
1463             SALOMEDS::Color aColor = aServant->GetColor();
1464             theStr << ",SALOMEDS.Color("<<
1465               aColor.R<<", "<<aColor.G<<", "<<aColor.B<<")"; // color
1466
1467             std::string aParam;
1468             switch(aServant->GetMarker()){
1469             case Curve::NONE:      aParam = "VISU.Curve.NONE";      break;
1470             case Curve::CIRCLE:    aParam = "VISU.Curve.CIRCLE";    break;
1471             case Curve::RECTANGLE: aParam = "VISU.Curve.RECTANGLE"; break;
1472             case Curve::DIAMOND:   aParam = "VISU.Curve.DIAMOND";   break;
1473             case Curve::DTRIANGLE: aParam = "VISU.Curve.DTRIANGLE"; break;
1474             case Curve::UTRIANGLE: aParam = "VISU.Curve.UTRIANGLE"; break;
1475             case Curve::LTRIANGLE: aParam = "VISU.Curve.LTRIANGLE"; break;
1476             case Curve::RTRIANGLE: aParam = "VISU.Curve.RTRIANGLE"; break;
1477             case Curve::CROSS:     aParam = "VISU.Curve.CROSS";     break;
1478             case Curve::XCROSS:    aParam = "VISU.Curve.XCROSS";    break;
1479             }
1480             theStr<<", "<<aParam; // marker
1481
1482             switch(aServant->GetLine()){
1483             case Curve::VOIDLINE:       aParam = "VISU.Curve.VOIDLINE";       break;
1484             case Curve::SOLIDLINE:      aParam = "VISU.Curve.SOLIDLINE";      break;
1485             case Curve::DASHLINE:       aParam = "VISU.Curve.DASHLINE";       break;
1486             case Curve::DOTLINE:        aParam = "VISU.Curve.DOTLINE";        break;
1487             case Curve::DASHDOTLINE:    aParam = "VISU.Curve.DASHDOTLINE";    break;
1488             case Curve::DASHDOTDOTLINE: aParam = "VISU.Curve.DASHDOTDOTLINE"; break;
1489             }
1490             theStr<<", "<<aParam<<", "<<aServant->GetLineWidth()<<")"<<endl; // line type,width
1491           }
1492           return;
1493         case VISU::TTABLE:
1494           if(dynamic_cast<Table_i*>(GetServant(anObj).in())){
1495             SALOMEDS::GenericAttribute_var anAttr;
1496             if(theSObject->FindAttribute(anAttr,"AttributeString")){
1497               using namespace SALOMEDS;
1498               AttributeString_var aComment = AttributeString::_narrow(anAttr);
1499               CORBA::String_var aValue = aComment->Value();
1500               Storable::TRestoringMap aMap;
1501               Storable::StringToMap(aValue.in(),aMap);
1502               bool anIsExist;
1503               QString aSourceId = VISU::Storable::FindValue(aMap,"mySourceId",&anIsExist);
1504               if(anIsExist){
1505                 if( aSourceId == "CutLines" ){
1506                   theStr<<thePrefix<<"if aName2ObjectMap.has_key('"<<theArgumentName<<"'):"<<endl;
1507                   thePrefix += PREFIX;
1508
1509                   theStr<<thePrefix<<"anObject = aName2ObjectMap['"<<theArgumentName<<"']"<<endl;
1510                   theStr<<thePrefix<<"anIOR = anObject.GetID()"<<endl;
1511                   theStr<<thePrefix<<"aSObject = theStudy.FindObjectIOR(anIOR)"<<endl;
1512                   theStr<<thePrefix<<"if aSObject:"<<endl;
1513                   std::string aPrefix = thePrefix;
1514                   thePrefix += PREFIX;
1515
1516                   theStr<<thePrefix<<"anID = aSObject.GetID()"<<endl;
1517                   theStr<<thePrefix<<aName<<" = aVisu.CreateTable(anID)"<<endl;
1518
1519                   // Set name (as this object could be renamed by user)
1520                   theStr<<thePrefix<<aName<<".SetTitle('"<<aNameInStudy.in()<<"') # 2"<<endl;
1521
1522                   theStr<<thePrefix<<endl;
1523
1524                   theArgumentName = aName;
1525                   DumpChildrenToPython(theStudy,
1526                                        theIsPublished,
1527                                        theIsValidScript,
1528                                        theSObject,
1529                                        theStr,
1530                                        theName2EntryMap,
1531                                        theEntry2NameMap,
1532                                        theArgumentName,
1533                                        thePrefix);
1534
1535                   theStr<<thePrefix<<"pass"<<endl<<endl;
1536                   theStr<<aPrefix<<"pass"<<endl<<endl;
1537                 }else if( aSourceId == "TableFile" ){
1538                   CORBA::Short aTag = theSObject->Tag();
1539                   theStr<<thePrefix<<"anIsFound, aSObject = "<<theArgumentName<<".FindSubObject("<<aTag<<")"<<endl;
1540                   theStr<<thePrefix<<"if anIsFound:"<<endl;
1541                   thePrefix += PREFIX;
1542
1543                   theStr<<thePrefix<<"anID = aSObject.GetID()"<<endl;
1544                   theStr<<thePrefix<<aName<<" = aVisu.CreateTable(anID)"<<endl;
1545
1546                   // Set name (as this object could be renamed by user)
1547                   theStr<<thePrefix<<aName<<".SetTitle('"<<aNameInStudy.in()<<"') # 3"<<endl;
1548
1549                   theStr<<thePrefix<<endl;
1550
1551                   theArgumentName = aName;
1552                   DumpChildrenToPython(theStudy,
1553                                        theIsPublished,
1554                                        theIsValidScript,
1555                                        theSObject,
1556                                        theStr,
1557                                        theName2EntryMap,
1558                                        theEntry2NameMap,
1559                                        theArgumentName,
1560                                        thePrefix);
1561
1562                   theStr<<thePrefix<<"pass"<<endl<<endl;
1563                 }else if( aSourceId == "TableAttr" ){
1564                   theArgumentName = aName;
1565                   DumpTableAttrToPython(theStudy,
1566                                         theIsPublished,
1567                                         theIsValidScript,
1568                                         theSObject,
1569                                         theStr,
1570                                         theName2EntryMap,
1571                                         theEntry2NameMap,
1572                                         theArgumentName,
1573                                         thePrefix);
1574                 }
1575               }
1576             }
1577           }
1578           return;
1579         }
1580       }
1581     } else { /*if(!CORBA::is_nil(anObj))*/
1582       SALOMEDS::GenericAttribute_var anAttr;
1583       if (theSObject->FindAttribute(anAttr,"AttributeString")) {
1584         SALOMEDS::AttributeString_var aComment =
1585           SALOMEDS::AttributeString::_narrow(anAttr);
1586         CORBA::String_var aValue = aComment->Value();
1587         Storable::TRestoringMap aMap;
1588         Storable::StringToMap(aValue.in(),aMap);
1589         bool anIsExist;
1590         QString aTypeName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist);
1591         if (anIsExist) {
1592           if (aTypeName == "ImportTables") {
1593             QString aFileName = VISU::Storable::FindValue(aMap,"myFileName",&anIsExist);
1594             if(anIsExist){
1595               std::string aName = GenerateName(theSObject,theName2EntryMap,theEntry2NameMap);
1596               theStr<<thePrefix<<aName<<" = aVisu.ImportTables('"<<aFileName.toLatin1().data()<<"')"<<endl;
1597               theStr<<thePrefix<<"if "<<aName<<":"<<endl;
1598               thePrefix += PREFIX;
1599
1600               theArgumentName = aName;
1601               DumpChildrenToPython(theStudy,
1602                                    theIsPublished,
1603                                    theIsValidScript,
1604                                    theSObject,
1605                                    theStr,
1606                                    theName2EntryMap,
1607                                    theEntry2NameMap,
1608                                    theArgumentName,
1609                                    thePrefix);
1610
1611               theStr<<thePrefix<<"pass"<<endl<<endl;
1612               return;
1613             }
1614           } else if (aTypeName == "VIEW3D") {
1615             std::string aName = GetName(theSObject);
1616             theStr<<thePrefix<<aName<<" = aBuilder.NewObject(aSComponent)"<<endl;
1617
1618             theStr<<thePrefix<<"if "<<aName<<":"<<endl;
1619             thePrefix += PREFIX;
1620
1621             theStr<<thePrefix<<"anAttr = aBuilder.FindOrCreateAttribute("<<aName<<",'AttributeName')"<<endl;
1622             theStr<<thePrefix<<"anAttr.SetValue('"<<aName<<"')"<<endl;
1623
1624             theStr<<thePrefix<<"anAttr = aBuilder.FindOrCreateAttribute("<<aName<<",'AttributeString')"<<endl;
1625             theStr<<thePrefix<<"anAttr.SetValue('"<<aValue.in()<<"')"<<endl;
1626
1627             theStr<<thePrefix<<"pass"<<endl<<endl;
1628             return;
1629           } else if (aTypeName == "ENTITY" || aTypeName == "FAMILY" || aTypeName == "GROUP") {
1630             // Set name (as this object could be renamed by user)
1631             string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").toLatin1().data();
1632             string aSubMeshName = VISU::Storable::FindValue(aMap,"myName").toLatin1().data();
1633             string anEntityTypeKey = "myEntityId";
1634             if (aTypeName == "ENTITY") anEntityTypeKey = "myId";
1635             int anEntity = VISU::Storable::FindValue(aMap,anEntityTypeKey,"0").toInt();
1636             std::string anEntityType;
1637             switch ((TEntity)anEntity) {
1638             case NODE_ENTITY: anEntityType = "VISU.NODE"; break;
1639             case EDGE_ENTITY: anEntityType = "VISU.EDGE"; break;
1640             case FACE_ENTITY: anEntityType = "VISU.FACE"; break;
1641             case CELL_ENTITY: anEntityType = "VISU.CELL"; break;
1642             }
1643
1644             if (aTypeName == "ENTITY" ) {
1645               theStr<<thePrefix<<"aVisu.RenameEntityInStudy("<<theArgumentName<<", '"<<aMeshName
1646                     <<"', "<<anEntityType<<", '"<<aNameInStudy.in()<<"')"<<endl;
1647             }
1648             else if (aTypeName == "FAMILY") {
1649               if (aSubMeshName != aNameInStudy.in()) {
1650                 theStr<<thePrefix<<"aVisu.RenameFamilyInStudy("<<theArgumentName<<", '"<<aMeshName
1651                       <<"', "<<anEntityType<<", '"<<aSubMeshName<<"', '"<<aNameInStudy.in()<<"')"<<endl;
1652               }
1653             }
1654             else { // "GROUP"
1655               if (aSubMeshName != aNameInStudy.in()) {
1656                 theStr<<thePrefix<<"aVisu.RenameGroupInStudy("<<theArgumentName<<", '"<<aMeshName
1657                       <<"', '"<<aSubMeshName<<"', '"<<aNameInStudy.in()<<"')"<<endl;
1658               }
1659             }
1660           }
1661         }
1662       } else {
1663         DumpTableAttrToPython(theStudy,
1664                               theIsPublished,
1665                               theIsValidScript,
1666                               theSObject,
1667                               theStr,
1668                               theName2EntryMap,
1669                               theEntry2NameMap,
1670                               theArgumentName,
1671                               thePrefix);
1672       }
1673     }
1674
1675     DumpChildrenToPython(theStudy,
1676                          theIsPublished,
1677                          theIsValidScript,
1678                          theSObject,
1679                          theStr,
1680                          theName2EntryMap,
1681                          theEntry2NameMap,
1682                          theArgumentName,
1683                          thePrefix);
1684   }
1685
1686
1687   //---------------------------------------------------------------------------
1688   void
1689   DumpCurveToPython(SALOMEDS::Study_ptr theStudy,
1690                     CORBA::Boolean theIsPublished,
1691                     CORBA::Boolean& theIsValidScript,
1692                     SALOMEDS::SObject_ptr theSObject,
1693                     std::ostream& theStr,
1694                     TName2EntryMap& theName2EntryMap,
1695                     TEntry2NameMap& theEntry2NameMap,
1696                     std::string theArgumentName,
1697                     std::string thePrefix)
1698   {
1699     SALOMEDS::SObject_var aTargetRefSObj;
1700     if(theSObject->ReferencedObject(aTargetRefSObj)){
1701       CORBA::Object_var anObj = SObjectToObject(aTargetRefSObj);
1702       if(CORBA::is_nil(anObj))
1703         return;
1704
1705       VISU::Base_var aBase = VISU::Base::_narrow(anObj);
1706       if(CORBA::is_nil(aBase))
1707         return;
1708
1709       if(aBase->GetType() == VISU::TCURVE){
1710         CORBA::String_var anID = aTargetRefSObj->GetID();
1711         std::string anArg = theEntry2NameMap[anID.in()];
1712         theStr<<thePrefix<<"if aName2ObjectMap.has_key('"<<anArg<<"'):"<<endl;
1713         thePrefix += PREFIX;
1714         theStr<<thePrefix<<"anObject = aName2ObjectMap['"<<anArg<<"']"<<endl;
1715         theStr<<thePrefix<<"if anObject: " <<theArgumentName<<".AddCurve(anObject)"<<endl;
1716         theStr<<thePrefix<<"pass"<<endl<<endl;
1717       }
1718     }
1719   }
1720
1721
1722   //---------------------------------------------------------------------------
1723   void
1724   DumpContainersToPython(SALOMEDS::Study_ptr theStudy,
1725                          CORBA::Boolean theIsPublished,
1726                          CORBA::Boolean& theIsValidScript,
1727                          SALOMEDS::SObject_ptr theSObject,
1728                          std::ostream& theStr,
1729                          TName2EntryMap& theName2EntryMap,
1730                          TEntry2NameMap& theEntry2NameMap,
1731                          std::string theArgumentName,
1732                          std::string thePrefix)
1733   {
1734     SALOMEDS::ChildIterator_var aChildItet = theStudy->NewChildIterator(theSObject);
1735     for(aChildItet->InitEx(false); aChildItet->More(); aChildItet->Next()){
1736       SALOMEDS::SObject_var aSObject = aChildItet->Value();
1737       CORBA::Object_var anObj = SObjectToObject(aSObject);
1738       if(CORBA::is_nil(anObj))
1739         continue;
1740
1741       VISU::Base_var aBase = VISU::Base::_narrow(anObj);
1742       if(CORBA::is_nil(aBase))
1743         continue;
1744
1745       if(aBase->GetType() == VISU::TCONTAINER){
1746         theStr<<thePrefix<<endl;
1747         std::string aName = GenerateName(aSObject,theName2EntryMap,theEntry2NameMap);
1748         theStr<<thePrefix<<aName<<" = aVisu.CreateContainer()"<<endl;
1749         theStr<<thePrefix<<"if "<<aName<<":"<<endl;
1750         std::string aPrefix = thePrefix + PREFIX;
1751         theArgumentName = aName;
1752
1753         // Set name (as this object could be renamed by user)
1754         CORBA::String_var aNameInStudy = aSObject->GetName();
1755         theStr<<aPrefix<<"visu.SetName("<<aName<<", '"<<aNameInStudy.in()<<"')"<<endl;
1756
1757         SALOMEDS::ChildIterator_var aCurveIter = theStudy->NewChildIterator(aSObject);
1758         for(aCurveIter->InitEx(false); aCurveIter->More(); aCurveIter->Next()){
1759           SALOMEDS::SObject_var aRefSObj = aCurveIter->Value();
1760           DumpCurveToPython(theStudy,theIsPublished,theIsValidScript,aRefSObj,theStr,theName2EntryMap,theEntry2NameMap,theArgumentName,aPrefix);
1761         }
1762
1763         theStr<<aPrefix<<"pass"<<endl<<endl;
1764       }
1765     }
1766   }
1767
1768
1769   //---------------------------------------------------------------------------
1770   void
1771   DumpPrs3dCacheToPython(SALOMEDS::Study_ptr theStudy,
1772                          CORBA::Boolean theIsPublished,
1773                          CORBA::Boolean& theIsValidScript,
1774                          SALOMEDS::SObject_ptr theSObject,
1775                          std::ostream& theStr,
1776                          TName2EntryMap& theName2EntryMap,
1777                          TEntry2NameMap& theEntry2NameMap,
1778                          std::string theArgumentName,
1779                          std::string thePrefix)
1780   {
1781
1782     SALOMEDS::ChildIterator_var anIter = theStudy->NewChildIterator(theSObject);
1783     for(anIter->InitEx(false); anIter->More(); anIter->Next()){
1784       SALOMEDS::SObject_var aSObject = anIter->Value();
1785       CORBA::Object_var anObj = SObjectToObject(aSObject);
1786       if(CORBA::is_nil(anObj))
1787         continue;
1788
1789       VISU::Base_var aBase = VISU::Base::_narrow(anObj);
1790       if(CORBA::is_nil(aBase))
1791         continue;
1792
1793       if(aBase->GetType() == VISU::TCOLOREDPRS3DCACHE){
1794         ColoredPrs3dCache_i* aCache = dynamic_cast<ColoredPrs3dCache_i*>(GetServant(aBase).in());
1795         theStr<<thePrefix<<"aCache = aVisu.GetColoredPrs3dCache(aVisu.GetCurrentStudy())"<<endl;
1796         theStr<<thePrefix<<"if aCache != None:"<<endl;
1797         {
1798           std::string aPrefix = thePrefix + PREFIX;
1799           std::string anArgument;
1800           VISU::ColoredPrs3dCache::MemoryMode aMode = aCache->GetMemoryMode();
1801           switch(aMode){
1802           case VISU::ColoredPrs3dCache::MINIMAL : anArgument = "VISU.ColoredPrs3dCache.MINIMAL"; break;
1803           case VISU::ColoredPrs3dCache::LIMITED : anArgument = "VISU.ColoredPrs3dCache.LIMITED"; break;
1804           }
1805           theStr<<aPrefix<<"aCache.SetMemoryMode("<<anArgument<<")"<<endl;
1806
1807           if(aMode == VISU::ColoredPrs3dCache::LIMITED)
1808             theStr<<aPrefix<<"aCache.SetLimitedMemory("<<aCache->GetLimitedMemory()<<") # (Mb)"<<endl;
1809
1810           SALOMEDS::ChildIterator_var aChildIter = theStudy->NewChildIterator(aSObject);
1811           for(aChildIter->InitEx(false); aChildIter->More(); aChildIter->Next()){
1812             SALOMEDS::SObject_var aSObject = aChildIter->Value();
1813             CORBA::Object_var anObject = SObjectToObject(aSObject);
1814             if (CORBA::is_nil(anObject))
1815               continue;
1816             
1817             ColoredPrs3dHolder_i* aServant = dynamic_cast<ColoredPrs3dHolder_i*>(GetServant(anObject).in());
1818             if(!aServant)
1819               continue;
1820           
1821             ColoredPrs3d_i* aDevice = aServant->GetPrs3dDevice();
1822             if(!aDevice)
1823               continue;
1824             
1825             Result_i* aResult = aDevice->GetCResult();
1826             std::string aResultEntry = aResult->GetEntry();
1827             std::string aResultName = theEntry2NameMap[aResultEntry];
1828             
1829             ColoredPrs3dHolder::BasicInput_var anInput = aServant->GetBasicInput();
1830             std::string anEntity;
1831             switch(anInput->myEntity){
1832             case VISU::NODE : anEntity = "VISU.NODE"; break;
1833             case VISU::EDGE : anEntity = "VISU.EDGE"; break;
1834             case VISU::FACE : anEntity = "VISU.FACE"; break;
1835             case VISU::CELL : anEntity = "VISU.CELL"; break;
1836             }
1837             
1838             
1839             theStr<<aPrefix<<"anInput = VISU.ColoredPrs3dHolder.BasicInput("<<
1840               aResultName<<", '"<<
1841               anInput->myMeshName<<"', "<<
1842               anEntity<<", '"<<
1843               anInput->myFieldName<<"', "<<
1844               anInput->myTimeStampNumber<<")"<<
1845               endl;
1846           
1847             std::string aComment = aDevice->GetComment();
1848             theStr<<aPrefix<<"aHolder = aCache.CreateHolder(VISU.T"<<aComment<<", anInput)"<<endl;
1849             theStr<<aPrefix<<"if aHolder != None:"<<endl;
1850             {
1851               std::string aPrefix2 = aPrefix + PREFIX;
1852               CORBA::String_var aNameInStudy = aSObject->GetName();
1853               theStr<<aPrefix2<<"visu.SetName(aHolder, '"<<aNameInStudy.in()<<"')"<<endl;
1854               theStr<<aPrefix2<<"aDevice = aHolder.GetDevice()"<<endl;
1855               theStr<<aPrefix2<<"if aDevice != None:"<<endl;
1856               {
1857                 std::string aPrefix3 = aPrefix2 + PREFIX;
1858                 TColoredPrs3dFactory aPrsFactory;
1859                 switch(aDevice->GetType()){
1860                 case VISU::TSCALARMAP:
1861                   if(ScalarMap_i* aServant = dynamic_cast<ScalarMap_i*>(aDevice)){
1862                     ScalarMapToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
1863                     break;
1864                   }
1865                 case VISU::TDEFORMEDSHAPE:
1866                   if(DeformedShape_i* aServant = dynamic_cast<DeformedShape_i*>(aDevice)){
1867                     DeformedShapeToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
1868                     break;
1869                   }
1870                 case VISU::TSTREAMLINES:
1871                   if(StreamLines_i* aServant = dynamic_cast<StreamLines_i*>(aDevice)){
1872                     StreamLinesToPython(aSObject, aServant, theStr, theEntry2NameMap, "aDevice", aPrsFactory, aPrefix3);
1873                     break;
1874                   }
1875                 case VISU::TSCALARMAPONDEFORMEDSHAPE:
1876                 case VISU::TDEFORMEDSHAPEANDSCALARMAP:
1877                   if(DeformedShapeAndScalarMap_i* aServant = dynamic_cast<DeformedShapeAndScalarMap_i*>(aDevice)){
1878                     DeformedShapeAndScalarMapToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
1879                     break;
1880                   }
1881                 case VISU::TVECTORS:
1882                   if(Vectors_i* aServant = dynamic_cast<Vectors_i*>(aDevice)){
1883                     VectorsToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
1884                     break;
1885                   }
1886                 case VISU::TISOSURFACES:
1887                   if(IsoSurfaces_i* aServant = dynamic_cast<IsoSurfaces_i*>(aDevice)){
1888                     IsoSurfacesToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
1889                     break;
1890                   }
1891                 case VISU::TCUTPLANES:
1892                   if(CutPlanes_i* aServant = dynamic_cast<CutPlanes_i*>(aDevice)){
1893                     CutPlanesToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
1894                     break;
1895                   }
1896                 case VISU::TCUTLINES:
1897                   if(CutLines_i* aServant = dynamic_cast<CutLines_i*>(aDevice)){
1898                     CutLinesToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
1899                     break;
1900                   }
1901                 case VISU::TPLOT3D:
1902                   if(Plot3D_i* aServant = dynamic_cast<Plot3D_i*>(aDevice)){
1903                     Plot3DToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
1904                     break;
1905                   }
1906                 case VISU::TGAUSSPOINTS:
1907                   if(GaussPoints_i* aServant = dynamic_cast<GaussPoints_i*>(aDevice)){
1908                     GaussPointsToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
1909                     break;
1910                   }
1911                 }
1912                 theStr<<aPrefix3<<"pass"<<endl;
1913               }
1914               theStr<<aPrefix2<<"pass"<<endl<<endl;
1915             }
1916           }
1917           theStr<<aPrefix<<"pass"<<endl;
1918         }
1919       }
1920     }
1921   }
1922
1923     
1924   //---------------------------------------------------------------------------
1925   void
1926   DumpAnimationsToPython(SALOMEDS::Study_ptr theStudy,
1927                          CORBA::Boolean theIsPublished,
1928                          CORBA::Boolean& theIsValidScript,
1929                          SALOMEDS::SObject_ptr theSObject,
1930                          std::ostream& theStr,
1931                          std::string thePrefix)
1932   {
1933
1934     if(!theIsPublished) return;
1935
1936     SALOMEDS::ChildIterator_var aChildItet = theStudy->NewChildIterator(theSObject);
1937     for(aChildItet->InitEx(false); aChildItet->More(); aChildItet->Next()){
1938       SALOMEDS::SObject_var aSObject = aChildItet->Value();
1939           
1940       SALOMEDS::GenericAttribute_var anAttr;
1941       if (!aSObject->FindAttribute(anAttr, "AttributeString")) continue;
1942       
1943       SALOMEDS::AttributeString_var aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr);
1944       QString value (aStringAttr->Value());
1945       if(value.isEmpty()) continue;
1946
1947       VISU::Storable::TRestoringMap aMap;
1948       VISU::Storable::StringToMap(value, aMap);
1949       bool isExist;
1950       
1951       QString aTypeName = VISU::Storable::FindValue(aMap,"myComment",&isExist);
1952       if(!isExist || aTypeName != "ANIMATION") continue;
1953
1954       //ANIMATION
1955       theStr<<thePrefix<<endl;
1956       QString animName = aSObject->GetName();
1957       theStr<<thePrefix<<"#Animation: "<<animName.toLatin1().data()<<endl;
1958       theStr<<thePrefix<<endl;
1959       theStr<<thePrefix<<"animSO = aBuilder.NewObject(aSComponent)"<<endl;
1960       theStr<<thePrefix<<"aBuilder.SetName(animSO, '"<<animName.toLatin1().data()<<"')"<< endl;
1961       theStr<<thePrefix<<"strAttr = aBuilder.FindOrCreateAttribute(animSO, 'AttributeString')"<< endl;
1962       theStr<<thePrefix<<"strAttr.SetValue('"<<value.toLatin1().data()<<"')"<< endl;
1963
1964
1965     
1966       SALOMEDS::ChildIterator_var anIter = theStudy->NewChildIterator(aSObject);
1967       for (anIter->Init(); anIter->More(); anIter->Next()) {
1968         SALOMEDS::SObject_var anObj = anIter->Value();
1969
1970         //FIELD
1971         theStr<<thePrefix<<"fieldSO = aBuilder.NewObject(animSO)"<<endl;
1972         if (anObj->FindAttribute(anAttr, "AttributeString")) {
1973           aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr);
1974           theStr<<thePrefix<<"strAttr = aBuilder.FindOrCreateAttribute(fieldSO, 'AttributeString')"<< endl;
1975           theStr<<thePrefix<<"strAttr.SetValue('"<<aStringAttr->Value()<<"')"<< endl;
1976         }
1977         
1978         SALOMEDS::SObject_var refObj;
1979         if(anObj->ReferencedObject(refObj)) {
1980           SALOMEDS::SObject_var father = refObj->GetFather();
1981           value = refObj->GetName();
1982           QString path(theStudy->GetObjectPath(father));
1983           //The following code requierd as a field name can contain '/' character
1984           theStr<<thePrefix<<"aBuilder.Addreference(fieldSO,getSObjectByFatherPathAndName(theStudy, '"<<path.toLatin1().data()<<"', '"<<value.toLatin1().data()<<"'))"<<endl;
1985         }
1986         value = anObj->GetName();
1987         if(!value.isEmpty()) theStr<<thePrefix<<"aBuilder.SetName(fieldSO, '"<<value.toLatin1().data()<<"')"<< endl;
1988
1989         //SCALARMAP,...
1990         SALOMEDS::ChildIterator_var aSubIter = theStudy->NewChildIterator(anObj);
1991         for (aSubIter->Init(); aSubIter->More(); aSubIter->Next()) {
1992           SALOMEDS::SObject_var aSubObj = aSubIter->Value();
1993           
1994           theStr<<thePrefix<<"subSO = aBuilder.NewObject(fieldSO)"<<endl;
1995           value = aSubObj->GetName();
1996           if(!value.isEmpty()) theStr<<thePrefix<<"aBuilder.SetName(subSO, '"<<value.toLatin1().data()<<"')"<< endl;
1997           if (aSubObj->FindAttribute(anAttr, "AttributeString")) {
1998             aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr);
1999             theStr<<thePrefix<<"strAttr = aBuilder.FindOrCreateAttribute(subSO, 'AttributeString')"<< endl;
2000             theStr<<thePrefix<<"strAttr.SetValue('"<<aStringAttr->Value()<<"')"<< endl;
2001           }
2002         }
2003
2004       }
2005       
2006     }
2007
2008     theStr<<thePrefix<<endl;
2009   }
2010
2011
2012   void
2013   DumpClippingPlanesToPython(SALOMEDS::Study_ptr theStudy,
2014                              CORBA::Boolean theIsPublished,
2015                              CORBA::Boolean& theIsValidScript,
2016                              SALOMEDS::SObject_ptr theSObject,
2017                              std::ostream& theStr,
2018                              std::string thePrefix,
2019                              VISU_ClippingPlaneMgr& thePlaneMgr)
2020   {
2021
2022     if(!theIsPublished) return;
2023
2024     VISU_CutPlaneFunction* aPlane;
2025     double aOrigin[3], aDir[3];
2026     for (int i = 0; i < thePlaneMgr.GetClippingPlanesNb(); i++) {
2027       aPlane = thePlaneMgr.GetClippingPlane(i);
2028       aPlane->GetOrigin(aOrigin);
2029       aPlane->GetNormal(aDir);
2030
2031       theStr<<thePrefix<<"aVisu.CreateClippingPlane("<<
2032         aOrigin[0]<<","<<aOrigin[1]<<","<<aOrigin[2]<<","<<
2033         aDir[0]<<","<<aDir[1]<<","<<aDir[2]<<","<<
2034         aPlane->isAuto()<<",\""<<aPlane->getName()<<"\")"<<endl;      
2035     }
2036     theStr<<endl;
2037   }  
2038
2039
2040   //---------------------------------------------------------------------------
2041   Engines::TMPFile*
2042   VISU_Gen_i::
2043   DumpPython(CORBA::Object_ptr theStudy,
2044              CORBA::Boolean theIsPublished,
2045              CORBA::Boolean& theIsValidScript)
2046   {
2047     theIsValidScript = false;
2048
2049     SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy);
2050     if(CORBA::is_nil(aStudy))
2051       return new Engines::TMPFile(0);
2052
2053     TName2EntryMap aName2EntryMap;
2054     TEntry2NameMap aEntry2NameMap;
2055
2056 #ifndef COUT
2057     ostringstream aStr;
2058 #else
2059 #define aStr cout
2060 #endif
2061
2062     std::string aPrefix(PREFIX);
2063     aStr<<"### This file is generated by SALOME automatically by dump python functionality"
2064       " of VISU component"<<endl<<endl;
2065     aStr<<"def RebuildData(theStudy):"<<endl;
2066     aStr<<aPrefix<<"from batchmode_salome import orb, naming_service, lcc, myStudyManager"<<endl;
2067     aStr<<aPrefix<<"import SALOME_MED"<<endl;
2068     aStr<<aPrefix<<"import SALOMEDS"<<endl;
2069     aStr<<aPrefix<<"import VISU"<<endl;
2070     aStr<<aPrefix<<"import visu"<<endl;
2071     aStr<<endl;
2072     aStr<<aPrefix<<"aVisu = visu.Initialize(orb,naming_service,lcc,myStudyManager,theStudy,0)"<<endl;
2073     aStr<<aPrefix<<"aSComponent = visu.PublishComponent(theStudy)"<<endl;
2074     aStr<<aPrefix<<"aMed = lcc.FindOrLoadComponent('FactoryServer','MED')"<<endl;
2075     aStr<<aPrefix<<"aBuilder = theStudy.NewBuilder()"<<endl;
2076     aStr<<aPrefix<<"aName2ObjectMap = {}"<<endl;
2077     aStr<<endl;
2078
2079     SALOMEDS::SComponent_var aComponent = FindOrCreateVisuComponent(aStudy);
2080
2081     VISU::DumpClippingPlanesToPython(aStudy,
2082                                      theIsPublished,
2083                                      theIsValidScript,
2084                                      aComponent.in(),
2085                                      aStr,
2086                                      aPrefix, 
2087                                      myClippingPlaneMgr);
2088
2089
2090     VISU::DumpChildrenToPython(aStudy,
2091                                theIsPublished,
2092                                theIsValidScript,
2093                                aComponent.in(),
2094                                aStr,
2095                                aName2EntryMap,
2096                                aEntry2NameMap,
2097                                "",
2098                                aPrefix);
2099
2100     VISU::DumpContainersToPython(aStudy,
2101                                  theIsPublished,
2102                                  theIsValidScript,
2103                                  aComponent.in(),
2104                                  aStr,
2105                                  aName2EntryMap,
2106                                  aEntry2NameMap,
2107                                  "",
2108                                  aPrefix);
2109
2110     VISU::DumpPrs3dCacheToPython(aStudy,
2111                                  theIsPublished,
2112                                  theIsValidScript,
2113                                  aComponent.in(),
2114                                  aStr,
2115                                  aName2EntryMap,
2116                                  aEntry2NameMap,
2117                                  "",
2118                                  aPrefix);
2119
2120     VISU::DumpAnimationsToPython(aStudy,
2121                                  theIsPublished,
2122                                  theIsValidScript,
2123                                  aComponent.in(),
2124                                  aStr,
2125                                  aPrefix);
2126
2127
2128     //Output the script that sets up the visul parameters.
2129     if(theIsPublished) {
2130       char* script = aStudy->GetDefaultScript("Post-Pro", aPrefix.c_str());
2131       if(script && strlen(script) > 0) {
2132         aStr << script;
2133         CORBA::string_free(script);
2134       }
2135     }
2136
2137     aStr<<aPrefix<<"pass"<<endl;
2138
2139     if(theIsPublished) { //SRN: define function for Animation
2140
2141       //Define a function that find a SObject by its father's path and its name
2142       aStr<<endl;
2143       aStr<<endl;
2144
2145       aStr<<"def getSObjectByFatherPathAndName(theStudy, thePath, theName):"<<endl;
2146       aStr<<aPrefix<<"father = theStudy.FindObjectByPath(thePath)"<<endl;
2147       aStr<<aPrefix<<"itr = theStudy.NewChildIterator(father)"<<endl;
2148       aStr<<aPrefix<<"while itr.More():"<<endl;
2149       aStr<<aPrefix<<aPrefix<<"so = itr.Value()"<<endl;
2150       aStr<<aPrefix<<aPrefix<<"if so.GetName()==theName: return so"<<endl;
2151       aStr<<aPrefix<<aPrefix<<"itr.Next()"<<endl;
2152       aStr<<aPrefix<<aPrefix<<"pass"<<endl;
2153       aStr<<aPrefix<<"return None"<<endl;
2154
2155       aStr<<endl;
2156     }
2157
2158     // theIsValidScript currently is not used by internal dump methods (DumpChildrenToPython(), etc.)
2159     // If the situation changes, then the following line should be removed, and theIsValidScript
2160     // should be set properly by those internal methods
2161     theIsValidScript = true;
2162
2163 #ifndef COUT
2164     std::string aResult = aStr.str();
2165     //ofstream anFStream("/tmp/dump.py");
2166     //anFStream<<aResult<<endl;
2167
2168     CORBA::ULong aSize = aResult.size() + 1;
2169     char* aBuffer = new char[aSize];
2170     strcpy(aBuffer,&aResult[0]);
2171     return new Engines::TMPFile(aSize,aSize,(CORBA::Octet*)aBuffer,1);
2172 #else
2173 #undef aStr
2174     return new Engines::TMPFile(0);
2175 #endif
2176   }
2177 }