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