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