]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_I/VISU_DumpPython.cc
Salome HOME
IPAL21489 Filter by Scalars... does not show visible elements for some presentations.
[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     theStr<<thePrefix<<aSObjectName<<" = aBuilder.NewObject("<<theArgumentName<<")"<<endl;
896     theStr<<thePrefix<<"if "<<aSObjectName<<":"<<endl;
897     thePrefix += PREFIX;
898
899     theStr<<thePrefix<<"aBuilder.SetName("<<aSObjectName<<", \""<<theSObject->GetName()<<"\")"<<endl; // Fix for IPAL13165
900     std::string aName = "aTableAttr";
901     theStr<<thePrefix<<aName<<" = aBuilder.FindOrCreateAttribute("<<
902       aSObjectName<<", '"<<theAttrName<<"')"<<endl;
903
904     theStr<<thePrefix<<"if "<<aName<<":"<<endl;
905     std::string aPrefix = thePrefix;
906     thePrefix += PREFIX;
907
908     CORBA::String_var aString = theTableAttr->GetTitle();
909     theStr<<thePrefix<<aName<<".SetTitle('"<<aString.in()<<"')"<<endl;
910
911     CORBA::Long aNbColumns = theTableAttr->GetNbColumns();
912     theStr<<thePrefix<<aName<<".SetNbColumns("<<aNbColumns<<")"<<endl;
913
914     CORBA::Long aNbRows = theTableAttr->GetNbRows();
915
916     // push values and their indices into streams
917     strstream values, rows, columns;
918     string comma = "";
919     for(CORBA::Long i = 1; i <= aNbColumns; i++){
920       for(CORBA::Long j = aNbRows; j > 0; j--){
921         if(theTableAttr->HasValue(j,i)){
922           values  << comma << theTableAttr->GetValue(j,i);
923           rows    << comma << j;
924           columns << comma << i;
925           if ( comma.empty() )
926             comma = ",";
927         }
928       }
929     }
930     // push titles and units into streams
931     strstream rowUnits, rowTitles, colTitles;
932     SALOMEDS::StringSeq_var aRowUnits = theTableAttr->GetRowUnits();
933     SALOMEDS::StringSeq_var aRowTitles = theTableAttr->GetRowTitles();
934     comma = "";
935     for(CORBA::Long j = 1; j <= aNbRows; j++){
936       rowUnits  << comma << "'" << aRowUnits [ j - 1 ] << "'";
937       rowTitles << comma << "'" << aRowTitles[ j - 1 ] << "'";
938       if ( comma.empty() )
939         comma = ",";
940     }
941     SALOMEDS::StringSeq_var aColumnTitles = theTableAttr->GetColumnTitles();
942     comma = "";
943     for(CORBA::Long j = 1; j <= aNbColumns; j++){
944       colTitles << comma << "'" << aColumnTitles[ j - 1 ] << "'";
945       if ( comma.empty() )
946         comma = ",";
947     }
948     values    << '\0';
949     rows      << '\0';
950     columns   << '\0';
951     rowUnits  << '\0';
952     rowTitles << '\0';
953     colTitles << '\0';
954     // write FillTable command
955     theStr<< thePrefix << aName << "_values  = [" << values.str()  << "]" << endl;
956     theStr<< thePrefix << aName << "_rows    = [" << rows.str()    << "]" << endl;
957     theStr<< thePrefix << aName << "_columns = [" << columns.str() << "]" << endl;
958     theStr<< thePrefix << aName << "_rUnits  = [" << rowUnits.str()  << "]" << endl;
959     theStr<< thePrefix << aName << "_rTitles = [" << rowTitles.str() << "]" << endl;
960     theStr<< thePrefix << aName << "_cTitles = [" << colTitles.str() << "]" << endl;
961     theStr<< thePrefix << "visu.FillTable( "
962       << aName << ", "
963         << aName << "_values, "
964           << aName << "_rows, "
965             << aName << "_columns, "
966               << aName << "_rTitles, "
967                 << aName << "_rUnits, "
968                   << aName << "_cTitles )" << endl;
969
970     if(theSObject->FindAttribute(anAttr,"AttributeIOR")){
971       theStr<<thePrefix<<endl;
972       std::string aName = "aTable";
973       theStr<<thePrefix<<"anID = "<<aSObjectName<<".GetID()"<<endl;
974       theStr<<thePrefix<<aName<<" = aVisu.CreateTable(anID)"<<endl;
975       theArgumentName = aName;
976
977       theStr<<thePrefix<<"if "<<aName<<":"<<endl;
978       std::string aPrefix2 = thePrefix + PREFIX;
979
980       // Set name (as this object could be renamed by user)
981       CORBA::String_var aNameInStudy = theSObject->GetName();
982       theStr<<aPrefix2<<aName<<".SetTitle('"<<aNameInStudy.in()<<"') # 1"<<endl;
983
984       DumpChildrenToPython(theStudy,
985                            theIsPublished,
986                            theIsValidScript,
987                            theSObject,
988                            theStr,
989                            theName2EntryMap,
990                            theEntry2NameMap,
991                            theArgumentName,
992                            aPrefix2);
993
994       theStr<<aPrefix2<<"pass"<<endl<<endl;
995     }
996
997     theStr<<thePrefix<<"pass"<<endl<<endl;
998     theStr<<aPrefix<<"pass"<<endl<<endl;
999   }
1000
1001
1002   //---------------------------------------------------------------------------
1003   void
1004   DumpChildrenToPython(SALOMEDS::Study_ptr theStudy,
1005                        CORBA::Boolean theIsPublished,
1006                        CORBA::Boolean& theIsValidScript,
1007                        SALOMEDS::SObject_ptr theSObject,
1008                        std::ostream& theStr,
1009                        TName2EntryMap& theName2EntryMap,
1010                        TEntry2NameMap& theEntry2NameMap,
1011                        std::string theArgumentName,
1012                        std::string thePrefix)
1013   {
1014     SALOMEDS::ChildIterator_var aChildItet = theStudy->NewChildIterator(theSObject);
1015     for(aChildItet->InitEx(false); aChildItet->More(); aChildItet->Next()){
1016       SALOMEDS::SObject_var aSObject = aChildItet->Value();
1017       DumpToPython(theStudy,
1018                    theIsPublished,
1019                    theIsValidScript,
1020                    aSObject,
1021                    theStr,
1022                    theName2EntryMap,
1023                    theEntry2NameMap,
1024                    theArgumentName,
1025                    thePrefix);
1026     }
1027   }
1028
1029
1030   //---------------------------------------------------------------------------
1031   void
1032   DumpTableAttrToPython(SALOMEDS::Study_ptr theStudy,
1033                         CORBA::Boolean theIsPublished,
1034                         CORBA::Boolean& theIsValidScript,
1035                         SALOMEDS::SObject_ptr theSObject,
1036                         std::ostream& theStr,
1037                         TName2EntryMap& theName2EntryMap,
1038                         TEntry2NameMap& theEntry2NameMap,
1039                         std::string theArgumentName,
1040                         std::string thePrefix)
1041   {
1042     SALOMEDS::GenericAttribute_var anAttr;
1043     if(theSObject->FindAttribute(anAttr,"AttributeTableOfInteger")){
1044       SALOMEDS::AttributeTableOfInteger_var aTableAttr =
1045         SALOMEDS::AttributeTableOfInteger::_narrow(anAttr);
1046
1047       TableAttrToPython(theStudy,
1048                         theIsPublished,
1049                         theIsValidScript,
1050                         theSObject,
1051                         aTableAttr,
1052                         "AttributeTableOfInteger",
1053                         theStr,
1054                         theName2EntryMap,
1055                         theEntry2NameMap,
1056                         theArgumentName,
1057                         thePrefix);
1058
1059     }else if(theSObject->FindAttribute(anAttr,"AttributeTableOfReal")){
1060       SALOMEDS::AttributeTableOfReal_var aTableAttr =
1061         SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
1062
1063       TableAttrToPython(theStudy,
1064                         theIsPublished,
1065                         theIsValidScript,
1066                         theSObject,
1067                         aTableAttr,
1068                         "AttributeTableOfReal",
1069                         theStr,
1070                         theName2EntryMap,
1071                         theEntry2NameMap,
1072                         theArgumentName,
1073                         thePrefix);
1074     }
1075   }
1076
1077
1078
1079   //---------------------------------------------------------------------------
1080   void
1081   DumpToPython(SALOMEDS::Study_ptr theStudy,
1082                CORBA::Boolean theIsPublished,
1083                CORBA::Boolean& theIsValidScript,
1084                SALOMEDS::SObject_ptr theSObject,
1085                std::ostream& theStr,
1086                TName2EntryMap& theName2EntryMap,
1087                TEntry2NameMap& theEntry2NameMap,
1088                std::string theArgumentName,
1089                std::string thePrefix)
1090   {
1091     std::string aName = GetName(theSObject);
1092     if (aName == "")
1093       return;
1094
1095     CORBA::String_var anID = theSObject->GetID();
1096     CORBA::String_var aNameInStudy = theSObject->GetName();
1097
1098     CORBA::Object_var anObj = SObjectToObject(theSObject);
1099     if (!CORBA::is_nil(anObj)) {
1100       VISU::Base_var aBase = VISU::Base::_narrow(anObj);
1101       if(!CORBA::is_nil(aBase)){
1102         std::string aName = GenerateName(theSObject, theName2EntryMap, theEntry2NameMap);
1103
1104         VISU::VISUType aType = aBase->GetType();
1105         switch(aType){
1106         case VISU::TRESULT:
1107           if(Result_i* aServant = dynamic_cast<Result_i*>(GetServant(anObj).in())){
1108             std::string aFileName = aServant->GetInitFileName();
1109             Result_i::ECreationId anId = aServant->GetCreationId();
1110             if(anId == Result_i::eImportFile || anId == Result_i::eCopyAndImportFile){
1111               switch(anId){
1112               case Result_i::eImportFile:
1113                 theStr<<thePrefix<<aName<<" = aVisu.CreateResult('"<<aFileName<<"')"<<endl;
1114
1115                 theStr<<thePrefix<<aName<<".SetBuildGroups("<<
1116                   GetBoolean(aServant->IsGroupsDone())<<")"<<
1117                   endl;
1118
1119                 theStr<<thePrefix<<aName<<".SetBuildFields("<<
1120                   GetBoolean(aServant->IsFieldsDone())<<", "<<
1121                   GetBoolean(aServant->IsMinMaxDone())<<")"<<
1122                   endl;
1123
1124                 theStr<<thePrefix<<aName<<".Build(False, True)"<<endl;
1125
1126                 theStr<<thePrefix<<"if "<<aName<<".IsDone() :"<<endl;
1127                 break;
1128               case Result_i::eCopyAndImportFile:
1129                 theStr<<thePrefix<<aName<<" = aVisu.CopyAndImportFile('"<<aFileName<<"')"<<endl;
1130                 theStr<<thePrefix<<"if "<<aName<<":"<<endl;
1131                 break;
1132               }
1133
1134               thePrefix += PREFIX;
1135               {
1136                 VISU::Result::EntityNames_var aMeshNames = aServant->GetMeshNames();
1137                 if (aMeshNames->length() > 0) {
1138                   for(size_t aMeshId = 0; aMeshId < aMeshNames->length(); aMeshId++){
1139                     CORBA::String_var aMeshName = aMeshNames[aMeshId];
1140                     VISU::Result::EntityNames_var aParts = aServant->GetPartNames(aMeshName);
1141                     if (aParts->length() > 0) {
1142                       for(size_t aPartId = 0; aPartId < aParts->length(); aPartId++){
1143                         CORBA::String_var aPart = aParts[aPartId];
1144                         VISU::Result::Resolution aResolution = aServant->GetResolution(aMeshName, aPart);
1145                         std::string aParam;
1146                         switch(aResolution){
1147                         case VISU::Result::FULL:
1148                           aParam = "VISU.Result.FULL";
1149                           break;
1150                         case VISU::Result::MEDIUM:
1151                           aParam = "VISU.Result.MEDIUM";
1152                           break;
1153                         case VISU::Result::LOW:
1154                           aParam = "VISU.Result.LOW";
1155                           break;
1156                         case VISU::Result::HIDDEN:
1157                           aParam = "VISU.Result.HIDDEN";
1158                           break;
1159                         }
1160                         theStr<<thePrefix<<aName<<".SetResolution('"<<aMeshName.in()<<"', '"<<aPart.in()<<"', "<<aParam<<")"<<endl;
1161                       }
1162                       theStr<<thePrefix<<endl;
1163                     }
1164                   }
1165                 }
1166               }
1167
1168               theArgumentName = aName;
1169               DumpChildrenToPython(theStudy,
1170                                    theIsPublished,
1171                                    theIsValidScript,
1172                                    theSObject,
1173                                    theStr,
1174                                    theName2EntryMap,
1175                                    theEntry2NameMap,
1176                                    theArgumentName,
1177                                    thePrefix);
1178
1179               theStr<<thePrefix<<"pass"<<endl<<endl;
1180             }else{
1181               SALOMEDS::SObject_var aRefSObj;
1182               if(theSObject->FindSubObject(1,aRefSObj)){
1183                 SALOMEDS::SObject_var aTargetRefSObj;
1184                 if(aRefSObj->ReferencedObject(aTargetRefSObj)){
1185                   CORBA::String_var aString = aTargetRefSObj->GetName();
1186                   theStr<<thePrefix<<"aSObject = theStudy.FindObject('"<<aString.in()<<"')"<<endl;
1187                   theStr<<thePrefix<<"if aSObject:"<<endl;
1188                   thePrefix += PREFIX;
1189                   theStr<<thePrefix<<"anObject = aSObject.GetObject()"<<endl;
1190                   theStr<<thePrefix<<"if anObject:"<<endl;
1191                   std::string aPrefix1 = thePrefix;
1192                   thePrefix += PREFIX;
1193
1194                   switch(anId){
1195                   case Result_i::eImportMed:
1196                     theStr<<thePrefix<<aName<<" = aVisu.ImportMed(aSObject)"<<endl;
1197                     break;
1198                   case Result_i::eImportMedField:
1199                     theStr<<thePrefix<<aName<<" = aVisu.ImportMedField(anObject)"<<endl;
1200                     break;
1201                   }
1202
1203                   theStr<<thePrefix<<"if "<<aName<<":"<<endl;
1204                   std::string aPrefix2 = thePrefix;
1205                   thePrefix += PREFIX;
1206
1207                   theArgumentName = aName;
1208                   DumpChildrenToPython(theStudy,
1209                                        theIsPublished,
1210                                        theIsValidScript,
1211                                        theSObject,
1212                                        theStr,
1213                                        theName2EntryMap,
1214                                        theEntry2NameMap,
1215                                        theArgumentName,
1216                                        thePrefix);
1217
1218                   theStr<<thePrefix<<"pass"<<endl<<endl;
1219                   theStr<<aPrefix2<<"pass"<<endl<<endl;
1220                   theStr<<aPrefix1<<"pass"<<endl<<endl;
1221                 }
1222               }
1223             }
1224           }
1225           return;
1226         case VISU::TMESH:
1227           if(Mesh_i* aServant = dynamic_cast<Mesh_i*>(GetServant(anObj).in())){     
1228             VISU::Entity anEntity = aServant->GetEntity();
1229             const std::string& aSubMeshName = aServant->GetSubMeshName();
1230             if(anEntity >= 0){
1231               std::string aParam;
1232               switch(anEntity){
1233               case NODE:
1234                 aParam = "VISU.NODE";
1235                 break;
1236               case EDGE:
1237                 aParam = "VISU.EDGE";
1238                 break;
1239               case FACE:
1240                 aParam = "VISU.FACE";
1241                 break;
1242               case CELL:
1243                 aParam = "VISU.CELL";
1244                 break;
1245               }
1246
1247               if(aSubMeshName == "")
1248                 theStr<<thePrefix<<aName<<" = aVisu.MeshOnEntity("<<theArgumentName<<
1249                   ", '"<<aServant->GetCMeshName()<<"'"<<
1250                   ", "<<aParam<<
1251                   ")"<<endl;
1252               else
1253                 theStr<<thePrefix<<aName<<" = aVisu.FamilyMeshOnEntity("<<theArgumentName<<
1254                   ", '"<<aServant->GetCMeshName()<<"'"<<
1255                   ", "<<aParam<<
1256                   ", '"<<aSubMeshName<<"'"<<
1257                   ")"<<endl;
1258             }else
1259               theStr<<thePrefix<<aName<<" = aVisu.GroupMesh("<<theArgumentName<<
1260                 ", '"<<aServant->GetCMeshName()<<"'"<<
1261                 ", '"<<aSubMeshName<<"'"<<
1262                 ")"<<endl;
1263
1264             theStr<<thePrefix<<"if "<<aName<<":"<<endl;
1265             thePrefix += PREFIX;
1266
1267             // Add to Name->Object map
1268             theStr<<thePrefix<<"aName2ObjectMap['"<<aName<<"'] = "<<aName<<endl;
1269
1270             // Set name (as this object could be renamed by user)
1271             theStr<<thePrefix<<"visu.SetName("<<aName<<", '"<<aNameInStudy.in()<<"')"<<endl;
1272
1273             // Set parameters common for all Prs3d objects (offset values)
1274             Prs3dToPython(aServant,theStr,aName,thePrefix);
1275
1276             // Set presentation parameters
1277             SALOMEDS::Color aColor;
1278             aColor = aServant->GetCellColor();
1279             theStr<<thePrefix<<aName<<".SetCellColor(SALOMEDS.Color("<<
1280               aColor.R<<", "<<aColor.G<<", "<<aColor.B<<"))"<<endl;
1281
1282             aColor = aServant->GetNodeColor();
1283             theStr<<thePrefix<<aName<<".SetNodeColor(SALOMEDS.Color("<<
1284               aColor.R<<", "<<aColor.G<<", "<<aColor.B<<"))"<<endl;
1285
1286             aColor = aServant->GetLinkColor();
1287             theStr<<thePrefix<<aName<<".SetLinkColor(SALOMEDS.Color("<<
1288               aColor.R<<", "<<aColor.G<<", "<<aColor.B<<"))"<<endl;
1289
1290             std::string aParam;
1291             switch(aServant->GetPresentationType()){
1292             case POINT:
1293               aParam = "VISU.POINT";
1294               break;
1295             case WIREFRAME:
1296               aParam = "VISU.WIREFRAME";
1297               break;
1298             case SHADED:
1299               aParam = "VISU.SHADED";
1300               break;
1301             case INSIDEFRAME:
1302               aParam = "VISU.INSIDEFRAME";
1303               break;
1304             case SURFACEFRAME:
1305               aParam = "VISU.SURFACEFRAME";
1306               break;
1307             case SHRINK:
1308               aParam = "VISU.SHRINK";
1309               break;
1310             }
1311             theStr<<thePrefix<<aName<<".SetPresentationType("<<aParam<<")"<<endl;
1312             theStr<<thePrefix<<aName<<".SetShrink("<<(aServant->IsShrank()? "True" : "False")<<")"<<endl;
1313             theStr<<thePrefix<<endl;
1314
1315             std::string aQuad2DPresent;
1316             switch(aServant->GetQuadratic2DPresentationType()){
1317             case LINES:
1318               aQuad2DPresent = "VISU.LINES";
1319               break;
1320             case ARCS:
1321               aQuad2DPresent = "VISU.ARCS";
1322               break;
1323             }
1324
1325             theStr<<thePrefix<<aName<<".SetQuadratic2DPresentationType("<<aQuad2DPresent<<")"<<endl;
1326             
1327             DumpChildrenToPython(theStudy,
1328                                  theIsPublished,
1329                                  theIsValidScript,
1330                                  theSObject,
1331                                  theStr,
1332                                  theName2EntryMap,
1333                                  theEntry2NameMap,
1334                                  theArgumentName,
1335                                  thePrefix);
1336
1337             theStr<<thePrefix<<"pass"<<endl<<endl;
1338             return;
1339           }
1340           break;
1341         case VISU::TSCALARMAP:
1342           if(ScalarMap_i* aServant = dynamic_cast<ScalarMap_i*>(GetServant(anObj).in())){
1343             TCreateFromResult aPrsFactory(theSObject, aServant, aName, "ScalarMapOnField", theArgumentName);
1344             thePrefix = ScalarMapToPython(theSObject, aServant, theStr,aName, aPrsFactory, thePrefix);
1345             theStr<<thePrefix<<"pass"<<endl<<endl;
1346           }
1347           return;
1348         case VISU::TDEFORMEDSHAPE:
1349           if(DeformedShape_i* aServant = dynamic_cast<DeformedShape_i*>(GetServant(anObj).in())){
1350             TCreateFromResult aPrsFactory(theSObject, aServant, aName, "DeformedShapeOnField", theArgumentName);
1351             thePrefix = DeformedShapeToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
1352             theStr<<thePrefix<<"pass"<<endl<<endl;
1353           }
1354           return;
1355         case VISU::TSTREAMLINES:
1356           if(StreamLines_i* aServant = dynamic_cast<StreamLines_i*>(GetServant(anObj).in())){
1357             TCreateFromResult aPrsFactory(theSObject, aServant, aName, "StreamLinesOnField", theArgumentName);
1358             thePrefix = StreamLinesToPython(theSObject, aServant, theStr, theEntry2NameMap, aName, aPrsFactory, thePrefix);
1359             theStr<<thePrefix<<"pass"<<endl<<endl;
1360           }
1361           return;
1362         case VISU::TSCALARMAPONDEFORMEDSHAPE:
1363         case VISU::TDEFORMEDSHAPEANDSCALARMAP:
1364           if(DeformedShapeAndScalarMap_i* aServant = dynamic_cast<DeformedShapeAndScalarMap_i*>(GetServant(anObj).in())){
1365             TCreateFromResult aPrsFactory(theSObject, aServant, aName, "DeformedShapeAndScalarMapOnField", theArgumentName);
1366             thePrefix = DeformedShapeAndScalarMapToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
1367             theStr<<thePrefix<<"pass"<<endl<<endl;
1368           }
1369           return;
1370         case VISU::TVECTORS:
1371           if(Vectors_i* aServant = dynamic_cast<Vectors_i*>(GetServant(anObj).in())){
1372             TCreateFromResult aPrsFactory(theSObject, aServant, aName, "VectorsOnField", theArgumentName);
1373             thePrefix = VectorsToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
1374             theStr<<thePrefix<<"pass"<<endl<<endl;
1375           }
1376           return;
1377         case VISU::TISOSURFACES:
1378           if(IsoSurfaces_i* aServant = dynamic_cast<IsoSurfaces_i*>(GetServant(anObj).in())){
1379             TCreateFromResult aPrsFactory(theSObject, aServant, aName, "IsoSurfacesOnField", theArgumentName);
1380             thePrefix = IsoSurfacesToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
1381             theStr<<thePrefix<<"pass"<<endl<<endl;
1382           }
1383           return;
1384         case VISU::TCUTPLANES:
1385           if(CutPlanes_i* aServant = dynamic_cast<CutPlanes_i*>(GetServant(anObj).in())){
1386             TCreateFromResult aPrsFactory(theSObject, aServant, aName, "CutPlanesOnField", theArgumentName);
1387             thePrefix = CutPlanesToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
1388             theStr<<thePrefix<<"pass"<<endl<<endl;
1389           }
1390           return;
1391         case VISU::TCUTLINES:
1392           if(CutLines_i* aServant = dynamic_cast<CutLines_i*>(GetServant(anObj).in())){
1393             TCreateFromResult aPrsFactory(theSObject, aServant, aName, "CutLinesOnField", theArgumentName);
1394             thePrefix = CutLinesToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
1395
1396             theArgumentName = aName;
1397             DumpChildrenToPython(theStudy,
1398                                  theIsPublished,
1399                                  theIsValidScript,
1400                                  theSObject,
1401                                  theStr,
1402                                  theName2EntryMap,
1403                                  theEntry2NameMap,
1404                                  theArgumentName,
1405                                  thePrefix);
1406
1407             theStr<<thePrefix<<"pass"<<endl<<endl;
1408           }
1409           return;
1410         case VISU::TCUTSEGMENT:
1411           if(CutSegment_i* aServant = dynamic_cast<CutSegment_i*>(GetServant(anObj).in())){
1412             TCreateFromResult aPrsFactory(theSObject, aServant, aName, "CutSegmentOnField", theArgumentName);
1413             thePrefix = CutSegmentToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
1414
1415             theArgumentName = aName;
1416             DumpChildrenToPython(theStudy,
1417                                  theIsPublished,
1418                                  theIsValidScript,
1419                                  theSObject,
1420                                  theStr,
1421                                  theName2EntryMap,
1422                                  theEntry2NameMap,
1423                                  theArgumentName,
1424                                  thePrefix);
1425
1426             theStr<<thePrefix<<"pass"<<endl<<endl;
1427           }
1428           return;
1429         case VISU::TPLOT3D:
1430           if (Plot3D_i* aServant = dynamic_cast<Plot3D_i*>(GetServant(anObj).in())) {
1431             TCreateFromResult aPrsFactory(theSObject, aServant, aName, "Plot3DOnField", theArgumentName);
1432             thePrefix = Plot3DToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
1433             theStr<<thePrefix<<"pass"<<endl<<endl;
1434           }
1435           return;
1436         case VISU::TPOINTMAP3D:
1437           if (PointMap3d_i* aServant = dynamic_cast<PointMap3d_i*>(GetServant(anObj).in())) {
1438             CORBA::Short aTag = theSObject->Tag();
1439             theStr<<thePrefix<<"anIsFound, aSObject = "<<theArgumentName<<".FindSubObject("<<aTag<<")"<<endl;
1440             theStr<<thePrefix<<"if anIsFound:"<<endl;
1441             thePrefix += PREFIX;
1442             
1443             theStr<<thePrefix<<"anID = aSObject.GetID()"<<endl;
1444             theStr<<thePrefix<<aName<<" = aVisu.CreateTable(anID)"<<endl;
1445             
1446             // Set name (as this object could be renamed by user)
1447             theStr<<thePrefix<<aName<<".SetTitle('"<<aNameInStudy.in()<<"') # 3"<<endl;
1448
1449             // Set PointMap3D Properties
1450
1451             theStr<<thePrefix<<aName<<".SetScaleFactor("<<aServant->GetScaleFactor()<<")"<<endl;
1452             theStr<<thePrefix<<aName<<".SetContourPrs("<<aServant->GetIsContourPrs()<<")"<<endl;
1453             theStr<<thePrefix<<aName<<".SetNbOfContours("<<aServant->GetNbOfContours()<<")"<<endl;
1454
1455             std::string aParam;
1456             switch(aServant->GetScaling()){
1457             case LINEAR:
1458               aParam = "VISU.LINEAR";
1459               break;
1460             case LOGARITHMIC:
1461               aParam = "VISU.LOGARITHMIC";
1462               break;
1463             }
1464             theStr<<thePrefix<<aName<<".SetScaling("<<aParam<<")"<<endl;
1465
1466             theStr<<thePrefix<<aName<<".SetNbColors("<<aServant->GetNbColors()<<")"<<endl;
1467             theStr<<thePrefix<<aName<<".SetLabels("<<aServant->GetLabels()<<")"<<endl;
1468
1469             switch(aServant->GetBarOrientation()){
1470             case ColoredPrs3dBase::HORIZONTAL:
1471               aParam = "VISU.ColoredPrs3d.HORIZONTAL";
1472               break;
1473             case ColoredPrs3dBase::VERTICAL:
1474               aParam = "VISU.ColoredPrs3d.VERTICAL";
1475               break;
1476             }
1477             theStr<<thePrefix<<aName<<".SetBarOrientation("<<aParam<<")"<<endl;
1478
1479             if(aServant->IsRangeFixed())
1480               theStr<<thePrefix<<aName<<".SetRange("<<aServant->GetMin()<<", "<<aServant->GetMax()<<")"<<endl;
1481             else
1482               theStr<<thePrefix<<aName<<".SetSourceRange()"<<endl;
1483
1484             theStr<<thePrefix<<aName<<".SetPosition("<<aServant->GetPosX()<<", "<<aServant->GetPosY()<<")"<<endl;
1485             theStr<<thePrefix<<aName<<".SetSize("<<aServant->GetWidth()<<", "<<aServant->GetHeight()<<")"<<endl;
1486
1487             float dx, dy, dz;
1488             aServant->GetOffset(dx, dy, dz);
1489             theStr<<thePrefix<<aName<<".SetOffset("<<dx<<", "<<dy<<", "<<dz<<")"<<endl;
1490
1491             
1492             theStr<<thePrefix<<endl;
1493             
1494             theArgumentName = aName;
1495             DumpChildrenToPython(theStudy,
1496                                  theIsPublished,
1497                                  theIsValidScript,
1498                                  theSObject,
1499                                  theStr,
1500                                  theName2EntryMap,
1501                                  theEntry2NameMap,
1502                                  theArgumentName,
1503                                  thePrefix);
1504
1505             theStr<<thePrefix<<"pass"<<endl<<endl;
1506           }
1507           return;
1508         case VISU::TGAUSSPOINTS:
1509           if(GaussPoints_i* aServant = dynamic_cast<GaussPoints_i*>(GetServant(anObj).in())){
1510             TCreateFromResult aPrsFactory(theSObject, aServant, aName, "GaussPointsOnField", theArgumentName);
1511             thePrefix = GaussPointsToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
1512             theStr<<thePrefix<<"pass"<<endl<<endl;
1513           }
1514           return;
1515         case VISU::TCURVE:
1516           if(Curve_i* aServant = dynamic_cast<Curve_i*>(GetServant(anObj).in()))
1517           {
1518             bool withZ = aServant->GetZRow()>0;
1519               
1520             theStr << thePrefix << "aName2ObjectMap['" << aName << "'] = visu.CreateCurve";
1521             if( withZ )
1522               theStr << "WithZ";
1523             theStr << "(" <<
1524               theArgumentName<< // table
1525                 ", "<<aServant->GetHRow()<< // H row
1526                   ", "<<aServant->GetVRow(); // V row
1527             if( withZ )
1528               theStr << ", " << aServant->GetZRow(); // Z row
1529
1530             theStr << ", '"<<aServant->GetTitle()<<"'"; // title
1531             SALOMEDS::Color aColor = aServant->GetColor();
1532             theStr << ",SALOMEDS.Color("<<
1533               aColor.R<<", "<<aColor.G<<", "<<aColor.B<<")"; // color
1534
1535             std::string aParam;
1536             switch(aServant->GetMarker()){
1537             case Curve::NONE:      aParam = "VISU.Curve.NONE";      break;
1538             case Curve::CIRCLE:    aParam = "VISU.Curve.CIRCLE";    break;
1539             case Curve::RECTANGLE: aParam = "VISU.Curve.RECTANGLE"; break;
1540             case Curve::DIAMOND:   aParam = "VISU.Curve.DIAMOND";   break;
1541             case Curve::DTRIANGLE: aParam = "VISU.Curve.DTRIANGLE"; break;
1542             case Curve::UTRIANGLE: aParam = "VISU.Curve.UTRIANGLE"; break;
1543             case Curve::LTRIANGLE: aParam = "VISU.Curve.LTRIANGLE"; break;
1544             case Curve::RTRIANGLE: aParam = "VISU.Curve.RTRIANGLE"; break;
1545             case Curve::CROSS:     aParam = "VISU.Curve.CROSS";     break;
1546             case Curve::XCROSS:    aParam = "VISU.Curve.XCROSS";    break;
1547             }
1548             theStr<<", "<<aParam; // marker
1549
1550             switch(aServant->GetLine()){
1551             case Curve::VOIDLINE:       aParam = "VISU.Curve.VOIDLINE";       break;
1552             case Curve::SOLIDLINE:      aParam = "VISU.Curve.SOLIDLINE";      break;
1553             case Curve::DASHLINE:       aParam = "VISU.Curve.DASHLINE";       break;
1554             case Curve::DOTLINE:        aParam = "VISU.Curve.DOTLINE";        break;
1555             case Curve::DASHDOTLINE:    aParam = "VISU.Curve.DASHDOTLINE";    break;
1556             case Curve::DASHDOTDOTLINE: aParam = "VISU.Curve.DASHDOTDOTLINE"; break;
1557             }
1558             theStr<<", "<<aParam<<", "<<aServant->GetLineWidth()<<")"<<endl; // line type,width
1559           }
1560           return;
1561         case VISU::TTABLE:
1562           if(dynamic_cast<Table_i*>(GetServant(anObj).in())){
1563             SALOMEDS::GenericAttribute_var anAttr;
1564             if(theSObject->FindAttribute(anAttr,"AttributeString")){
1565               using namespace SALOMEDS;
1566               AttributeString_var aComment = AttributeString::_narrow(anAttr);
1567               CORBA::String_var aValue = aComment->Value();
1568               Storable::TRestoringMap aMap;
1569               Storable::StringToMap(aValue.in(),aMap);
1570               bool anIsExist;
1571               QString aSourceId = VISU::Storable::FindValue(aMap,"mySourceId",&anIsExist);
1572               if(anIsExist){
1573                 if( aSourceId == "CutLines" ){
1574                   theStr<<thePrefix<<"if aName2ObjectMap.has_key('"<<theArgumentName<<"'):"<<endl;
1575                   thePrefix += PREFIX;
1576
1577                   theStr<<thePrefix<<"anObject = aName2ObjectMap['"<<theArgumentName<<"']"<<endl;
1578                   theStr<<thePrefix<<"anIOR = anObject.GetID()"<<endl;
1579                   theStr<<thePrefix<<"aSObject = theStudy.FindObjectIOR(anIOR)"<<endl;
1580                   theStr<<thePrefix<<"if aSObject:"<<endl;
1581                   std::string aPrefix = thePrefix;
1582                   thePrefix += PREFIX;
1583
1584                   theStr<<thePrefix<<"anID = aSObject.GetID()"<<endl;
1585                   theStr<<thePrefix<<aName<<" = aVisu.CreateTable(anID)"<<endl;
1586
1587                   // Set name (as this object could be renamed by user)
1588                   theStr<<thePrefix<<aName<<".SetTitle('"<<aNameInStudy.in()<<"') # 2"<<endl;
1589
1590                   theStr<<thePrefix<<endl;
1591
1592                   theArgumentName = aName;
1593                   DumpChildrenToPython(theStudy,
1594                                        theIsPublished,
1595                                        theIsValidScript,
1596                                        theSObject,
1597                                        theStr,
1598                                        theName2EntryMap,
1599                                        theEntry2NameMap,
1600                                        theArgumentName,
1601                                        thePrefix);
1602
1603                   theStr<<thePrefix<<"pass"<<endl<<endl;
1604                   theStr<<aPrefix<<"pass"<<endl<<endl;
1605                 }else if( aSourceId == "TableFile" ){
1606                   CORBA::Short aTag = theSObject->Tag();
1607                   theStr<<thePrefix<<"anIsFound, aSObject = "<<theArgumentName<<".FindSubObject("<<aTag<<")"<<endl;
1608                   theStr<<thePrefix<<"if anIsFound:"<<endl;
1609                   thePrefix += PREFIX;
1610
1611                   theStr<<thePrefix<<"anID = aSObject.GetID()"<<endl;
1612                   theStr<<thePrefix<<aName<<" = aVisu.CreateTable(anID)"<<endl;
1613
1614                   // Set name (as this object could be renamed by user)
1615                   theStr<<thePrefix<<aName<<".SetTitle('"<<aNameInStudy.in()<<"') # 3"<<endl;
1616
1617                   theStr<<thePrefix<<endl;
1618
1619                   theArgumentName = aName;
1620                   DumpChildrenToPython(theStudy,
1621                                        theIsPublished,
1622                                        theIsValidScript,
1623                                        theSObject,
1624                                        theStr,
1625                                        theName2EntryMap,
1626                                        theEntry2NameMap,
1627                                        theArgumentName,
1628                                        thePrefix);
1629
1630                   theStr<<thePrefix<<"pass"<<endl<<endl;
1631                 }else if( aSourceId == "TableAttr" ){
1632                   theArgumentName = aName;
1633                   DumpTableAttrToPython(theStudy,
1634                                         theIsPublished,
1635                                         theIsValidScript,
1636                                         theSObject,
1637                                         theStr,
1638                                         theName2EntryMap,
1639                                         theEntry2NameMap,
1640                                         theArgumentName,
1641                                         thePrefix);
1642                 }
1643               }
1644             }
1645           }
1646           return;
1647         }
1648       }
1649     } else { /*if(!CORBA::is_nil(anObj))*/
1650       SALOMEDS::GenericAttribute_var anAttr;
1651       if (theSObject->FindAttribute(anAttr,"AttributeString")) {
1652         SALOMEDS::AttributeString_var aComment =
1653           SALOMEDS::AttributeString::_narrow(anAttr);
1654         CORBA::String_var aValue = aComment->Value();
1655         Storable::TRestoringMap aMap;
1656         Storable::StringToMap(aValue.in(),aMap);
1657         bool anIsExist;
1658         QString aTypeName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist);
1659         if (anIsExist) {
1660           if (aTypeName == "ImportTables") {
1661             QString aFileName = VISU::Storable::FindValue(aMap,"myFileName",&anIsExist);
1662             if(anIsExist){
1663               std::string aName = GenerateName(theSObject,theName2EntryMap,theEntry2NameMap);
1664               theStr<<thePrefix<<aName<<" = aVisu.ImportTables('"<<aFileName.toLatin1().data()<<"')"<<endl;
1665               theStr<<thePrefix<<"if "<<aName<<":"<<endl;
1666               thePrefix += PREFIX;
1667
1668               theArgumentName = aName;
1669               DumpChildrenToPython(theStudy,
1670                                    theIsPublished,
1671                                    theIsValidScript,
1672                                    theSObject,
1673                                    theStr,
1674                                    theName2EntryMap,
1675                                    theEntry2NameMap,
1676                                    theArgumentName,
1677                                    thePrefix);
1678
1679               theStr<<thePrefix<<"pass"<<endl<<endl;
1680               return;
1681             }
1682           } else if (aTypeName == "VIEW3D") {
1683             std::string aName = GetName(theSObject);
1684             theStr<<thePrefix<<aName<<" = aBuilder.NewObject(aSComponent)"<<endl;
1685
1686             theStr<<thePrefix<<"if "<<aName<<":"<<endl;
1687             thePrefix += PREFIX;
1688
1689             theStr<<thePrefix<<"anAttr = aBuilder.FindOrCreateAttribute("<<aName<<",'AttributeName')"<<endl;
1690             theStr<<thePrefix<<"anAttr.SetValue('"<<aName<<"')"<<endl;
1691
1692             theStr<<thePrefix<<"anAttr = aBuilder.FindOrCreateAttribute("<<aName<<",'AttributeString')"<<endl;
1693             theStr<<thePrefix<<"anAttr.SetValue('"<<aValue.in()<<"')"<<endl;
1694
1695             theStr<<thePrefix<<"pass"<<endl<<endl;
1696             return;
1697           } else if (aTypeName == "ENTITY" || aTypeName == "FAMILY" || aTypeName == "GROUP") {
1698             // Set name (as this object could be renamed by user)
1699             string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").toLatin1().data();
1700             string aSubMeshName = VISU::Storable::FindValue(aMap,"myName").toLatin1().data();
1701             string anEntityTypeKey = "myEntityId";
1702             if (aTypeName == "ENTITY") anEntityTypeKey = "myId";
1703             int anEntity = VISU::Storable::FindValue(aMap,anEntityTypeKey,"0").toInt();
1704             std::string anEntityType;
1705             switch ((TEntity)anEntity) {
1706             case NODE_ENTITY: anEntityType = "VISU.NODE"; break;
1707             case EDGE_ENTITY: anEntityType = "VISU.EDGE"; break;
1708             case FACE_ENTITY: anEntityType = "VISU.FACE"; break;
1709             case CELL_ENTITY: anEntityType = "VISU.CELL"; break;
1710             }
1711
1712             if (aTypeName == "ENTITY" ) {
1713               theStr<<thePrefix<<"aVisu.RenameEntityInStudy("<<theArgumentName<<", '"<<aMeshName
1714                     <<"', "<<anEntityType<<", '"<<aNameInStudy.in()<<"')"<<endl;
1715             }
1716             else if (aTypeName == "FAMILY") {
1717               if (aSubMeshName != aNameInStudy.in()) {
1718                 theStr<<thePrefix<<"aVisu.RenameFamilyInStudy("<<theArgumentName<<", '"<<aMeshName
1719                       <<"', "<<anEntityType<<", '"<<aSubMeshName<<"', '"<<aNameInStudy.in()<<"')"<<endl;
1720               }
1721             }
1722             else { // "GROUP"
1723               if (aSubMeshName != aNameInStudy.in()) {
1724                 theStr<<thePrefix<<"aVisu.RenameGroupInStudy("<<theArgumentName<<", '"<<aMeshName
1725                       <<"', '"<<aSubMeshName<<"', '"<<aNameInStudy.in()<<"')"<<endl;
1726               }
1727             }
1728           }
1729         }
1730       } else {
1731         DumpTableAttrToPython(theStudy,
1732                               theIsPublished,
1733                               theIsValidScript,
1734                               theSObject,
1735                               theStr,
1736                               theName2EntryMap,
1737                               theEntry2NameMap,
1738                               theArgumentName,
1739                               thePrefix);
1740       }
1741     }
1742
1743     DumpChildrenToPython(theStudy,
1744                          theIsPublished,
1745                          theIsValidScript,
1746                          theSObject,
1747                          theStr,
1748                          theName2EntryMap,
1749                          theEntry2NameMap,
1750                          theArgumentName,
1751                          thePrefix);
1752   }
1753
1754
1755   //---------------------------------------------------------------------------
1756   void
1757   DumpCurveToPython(SALOMEDS::Study_ptr theStudy,
1758                     CORBA::Boolean theIsPublished,
1759                     CORBA::Boolean& theIsValidScript,
1760                     SALOMEDS::SObject_ptr theSObject,
1761                     std::ostream& theStr,
1762                     TName2EntryMap& theName2EntryMap,
1763                     TEntry2NameMap& theEntry2NameMap,
1764                     std::string theArgumentName,
1765                     std::string thePrefix)
1766   {
1767     SALOMEDS::SObject_var aTargetRefSObj;
1768     if(theSObject->ReferencedObject(aTargetRefSObj)){
1769       CORBA::Object_var anObj = SObjectToObject(aTargetRefSObj);
1770       if(CORBA::is_nil(anObj))
1771         return;
1772
1773       VISU::Base_var aBase = VISU::Base::_narrow(anObj);
1774       if(CORBA::is_nil(aBase))
1775         return;
1776
1777       if(aBase->GetType() == VISU::TCURVE){
1778         CORBA::String_var anID = aTargetRefSObj->GetID();
1779         std::string anArg = theEntry2NameMap[anID.in()];
1780         theStr<<thePrefix<<"if aName2ObjectMap.has_key('"<<anArg<<"'):"<<endl;
1781         thePrefix += PREFIX;
1782         theStr<<thePrefix<<"anObject = aName2ObjectMap['"<<anArg<<"']"<<endl;
1783         theStr<<thePrefix<<"if anObject: " <<theArgumentName<<".AddCurve(anObject)"<<endl;
1784         theStr<<thePrefix<<"pass"<<endl<<endl;
1785       }
1786     }
1787   }
1788
1789
1790   //---------------------------------------------------------------------------
1791   void
1792   DumpContainersToPython(SALOMEDS::Study_ptr theStudy,
1793                          CORBA::Boolean theIsPublished,
1794                          CORBA::Boolean& theIsValidScript,
1795                          SALOMEDS::SObject_ptr theSObject,
1796                          std::ostream& theStr,
1797                          TName2EntryMap& theName2EntryMap,
1798                          TEntry2NameMap& theEntry2NameMap,
1799                          std::string theArgumentName,
1800                          std::string thePrefix)
1801   {
1802     SALOMEDS::ChildIterator_var aChildItet = theStudy->NewChildIterator(theSObject);
1803     for(aChildItet->InitEx(false); aChildItet->More(); aChildItet->Next()){
1804       SALOMEDS::SObject_var aSObject = aChildItet->Value();
1805       CORBA::Object_var anObj = SObjectToObject(aSObject);
1806       if(CORBA::is_nil(anObj))
1807         continue;
1808
1809       VISU::Base_var aBase = VISU::Base::_narrow(anObj);
1810       if(CORBA::is_nil(aBase))
1811         continue;
1812
1813       if(aBase->GetType() == VISU::TCONTAINER){
1814         theStr<<thePrefix<<endl;
1815         std::string aName = GenerateName(aSObject,theName2EntryMap,theEntry2NameMap);
1816         theStr<<thePrefix<<aName<<" = aVisu.CreateContainer()"<<endl;
1817         theStr<<thePrefix<<"if "<<aName<<":"<<endl;
1818         std::string aPrefix = thePrefix + PREFIX;
1819         theArgumentName = aName;
1820
1821         // Set name (as this object could be renamed by user)
1822         CORBA::String_var aNameInStudy = aSObject->GetName();
1823         theStr<<aPrefix<<"visu.SetName("<<aName<<", '"<<aNameInStudy.in()<<"')"<<endl;
1824
1825         SALOMEDS::ChildIterator_var aCurveIter = theStudy->NewChildIterator(aSObject);
1826         for(aCurveIter->InitEx(false); aCurveIter->More(); aCurveIter->Next()){
1827           SALOMEDS::SObject_var aRefSObj = aCurveIter->Value();
1828           DumpCurveToPython(theStudy,theIsPublished,theIsValidScript,aRefSObj,theStr,theName2EntryMap,theEntry2NameMap,theArgumentName,aPrefix);
1829         }
1830
1831         theStr<<aPrefix<<"pass"<<endl<<endl;
1832       }
1833     }
1834   }
1835
1836
1837   //---------------------------------------------------------------------------
1838   void
1839   DumpPrs3dCacheToPython(SALOMEDS::Study_ptr theStudy,
1840                          CORBA::Boolean theIsPublished,
1841                          CORBA::Boolean& theIsValidScript,
1842                          SALOMEDS::SObject_ptr theSObject,
1843                          std::ostream& theStr,
1844                          TName2EntryMap& theName2EntryMap,
1845                          TEntry2NameMap& theEntry2NameMap,
1846                          std::string theArgumentName,
1847                          std::string thePrefix)
1848   {
1849
1850     SALOMEDS::ChildIterator_var anIter = theStudy->NewChildIterator(theSObject);
1851     for(anIter->InitEx(false); anIter->More(); anIter->Next()){
1852       SALOMEDS::SObject_var aSObject = anIter->Value();
1853       CORBA::Object_var anObj = SObjectToObject(aSObject);
1854       if(CORBA::is_nil(anObj))
1855         continue;
1856
1857       VISU::Base_var aBase = VISU::Base::_narrow(anObj);
1858       if(CORBA::is_nil(aBase))
1859         continue;
1860
1861       if(aBase->GetType() == VISU::TCOLOREDPRS3DCACHE){
1862         ColoredPrs3dCache_i* aCache = dynamic_cast<ColoredPrs3dCache_i*>(GetServant(aBase).in());
1863         theStr<<thePrefix<<"aCache = aVisu.GetColoredPrs3dCache(aVisu.GetCurrentStudy())"<<endl;
1864         theStr<<thePrefix<<"if aCache != None:"<<endl;
1865         {
1866           std::string aPrefix = thePrefix + PREFIX;
1867           std::string anArgument;
1868           VISU::ColoredPrs3dCache::MemoryMode aMode = aCache->GetMemoryMode();
1869           switch(aMode){
1870           case VISU::ColoredPrs3dCache::MINIMAL : anArgument = "VISU.ColoredPrs3dCache.MINIMAL"; break;
1871           case VISU::ColoredPrs3dCache::LIMITED : anArgument = "VISU.ColoredPrs3dCache.LIMITED"; break;
1872           }
1873           theStr<<aPrefix<<"aCache.SetMemoryMode("<<anArgument<<")"<<endl;
1874
1875           if(aMode == VISU::ColoredPrs3dCache::LIMITED)
1876             theStr<<aPrefix<<"aCache.SetLimitedMemory("<<aCache->GetLimitedMemory()<<") # (Mb)"<<endl;
1877
1878           SALOMEDS::ChildIterator_var aChildIter = theStudy->NewChildIterator(aSObject);
1879           for(aChildIter->InitEx(false); aChildIter->More(); aChildIter->Next()){
1880             SALOMEDS::SObject_var aSObject = aChildIter->Value();
1881             CORBA::Object_var anObject = SObjectToObject(aSObject);
1882             if (CORBA::is_nil(anObject))
1883               continue;
1884             
1885             ColoredPrs3dHolder_i* aServant = dynamic_cast<ColoredPrs3dHolder_i*>(GetServant(anObject).in());
1886             if(!aServant)
1887               continue;
1888           
1889             ColoredPrs3d_i* aDevice = aServant->GetPrs3dDevice();
1890             if(!aDevice)
1891               continue;
1892             
1893             Result_i* aResult = aDevice->GetCResult();
1894             std::string aResultEntry = aResult->GetEntry();
1895             std::string aResultName = theEntry2NameMap[aResultEntry];
1896             
1897             ColoredPrs3dHolder::BasicInput_var anInput = aServant->GetBasicInput();
1898             std::string anEntity;
1899             switch(anInput->myEntity){
1900             case VISU::NODE : anEntity = "VISU.NODE"; break;
1901             case VISU::EDGE : anEntity = "VISU.EDGE"; break;
1902             case VISU::FACE : anEntity = "VISU.FACE"; break;
1903             case VISU::CELL : anEntity = "VISU.CELL"; break;
1904             }
1905             
1906             
1907             theStr<<aPrefix<<"anInput = VISU.ColoredPrs3dHolder.BasicInput("<<
1908               aResultName<<", '"<<
1909               anInput->myMeshName<<"', "<<
1910               anEntity<<", '"<<
1911               anInput->myFieldName<<"', "<<
1912               anInput->myTimeStampNumber<<")"<<
1913               endl;
1914           
1915             std::string aComment = aDevice->GetComment();
1916             theStr<<aPrefix<<"aHolder = aCache.CreateHolder(VISU.T"<<aComment<<", anInput)"<<endl;
1917             theStr<<aPrefix<<"if aHolder != None:"<<endl;
1918             {
1919               std::string aPrefix2 = aPrefix + PREFIX;
1920               CORBA::String_var aNameInStudy = aSObject->GetName();
1921               theStr<<aPrefix2<<"visu.SetName(aHolder, '"<<aNameInStudy.in()<<"')"<<endl;
1922               theStr<<aPrefix2<<"aDevice = aHolder.GetDevice()"<<endl;
1923               theStr<<aPrefix2<<"if aDevice != None:"<<endl;
1924               {
1925                 std::string aPrefix3 = aPrefix2 + PREFIX;
1926                 TColoredPrs3dFactory aPrsFactory;
1927                 switch(aDevice->GetType()){
1928                 case VISU::TSCALARMAP:
1929                   if(ScalarMap_i* aServant = dynamic_cast<ScalarMap_i*>(aDevice)){
1930                     ScalarMapToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
1931                     break;
1932                   }
1933                 case VISU::TDEFORMEDSHAPE:
1934                   if(DeformedShape_i* aServant = dynamic_cast<DeformedShape_i*>(aDevice)){
1935                     DeformedShapeToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
1936                     break;
1937                   }
1938                 case VISU::TSTREAMLINES:
1939                   if(StreamLines_i* aServant = dynamic_cast<StreamLines_i*>(aDevice)){
1940                     StreamLinesToPython(aSObject, aServant, theStr, theEntry2NameMap, "aDevice", aPrsFactory, aPrefix3);
1941                     break;
1942                   }
1943                 case VISU::TSCALARMAPONDEFORMEDSHAPE:
1944                 case VISU::TDEFORMEDSHAPEANDSCALARMAP:
1945                   if(DeformedShapeAndScalarMap_i* aServant = dynamic_cast<DeformedShapeAndScalarMap_i*>(aDevice)){
1946                     DeformedShapeAndScalarMapToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
1947                     break;
1948                   }
1949                 case VISU::TVECTORS:
1950                   if(Vectors_i* aServant = dynamic_cast<Vectors_i*>(aDevice)){
1951                     VectorsToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
1952                     break;
1953                   }
1954                 case VISU::TISOSURFACES:
1955                   if(IsoSurfaces_i* aServant = dynamic_cast<IsoSurfaces_i*>(aDevice)){
1956                     IsoSurfacesToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
1957                     break;
1958                   }
1959                 case VISU::TCUTPLANES:
1960                   if(CutPlanes_i* aServant = dynamic_cast<CutPlanes_i*>(aDevice)){
1961                     CutPlanesToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
1962                     break;
1963                   }
1964                 case VISU::TCUTLINES:
1965                   if(CutLines_i* aServant = dynamic_cast<CutLines_i*>(aDevice)){
1966                     CutLinesToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
1967                     break;
1968                   }
1969                 case VISU::TCUTSEGMENT:
1970                   if(CutSegment_i* aServant = dynamic_cast<CutSegment_i*>(aDevice)){
1971                     CutSegmentToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
1972                     break;
1973                   }
1974                 case VISU::TPLOT3D:
1975                   if(Plot3D_i* aServant = dynamic_cast<Plot3D_i*>(aDevice)){
1976                     Plot3DToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
1977                     break;
1978                   }
1979                 case VISU::TGAUSSPOINTS:
1980                   if(GaussPoints_i* aServant = dynamic_cast<GaussPoints_i*>(aDevice)){
1981                     GaussPointsToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
1982                     break;
1983                   }
1984                 }
1985                 theStr<<aPrefix3<<"pass"<<endl;
1986               }
1987               theStr<<aPrefix2<<"pass"<<endl<<endl;
1988             }
1989           }
1990           theStr<<aPrefix<<"pass"<<endl;
1991         }
1992       }
1993     }
1994   }
1995
1996     
1997   //---------------------------------------------------------------------------
1998   void
1999   DumpEvolutionsToPython(SALOMEDS::Study_ptr theStudy,
2000                          CORBA::Boolean theIsPublished,
2001                          CORBA::Boolean& theIsValidScript,
2002                          SALOMEDS::SObject_ptr theSObject,
2003                          std::ostream& theStr,
2004                          TName2EntryMap& theName2EntryMap,
2005                          TEntry2NameMap& theEntry2NameMap,
2006                          std::string thePrefix)
2007   {
2008     if(!theIsPublished) return;
2009
2010     SALOMEDS::ChildIterator_var aChildItet = theStudy->NewChildIterator(theSObject);
2011     for(aChildItet->InitEx(false); aChildItet->More(); aChildItet->Next()){
2012       SALOMEDS::SObject_var aSObject = aChildItet->Value();
2013           
2014       SALOMEDS::GenericAttribute_var anAttr;
2015       if (!aSObject->FindAttribute(anAttr, "AttributeString")) continue;
2016       
2017       SALOMEDS::AttributeString_var aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr);
2018       QString value (aStringAttr->Value());
2019       if(value.isEmpty()) continue;
2020
2021       VISU::Storable::TRestoringMap aMap;
2022       VISU::Storable::StringToMap(value, aMap);
2023       bool isExist;
2024       
2025       QString aTypeName = VISU::Storable::FindValue(aMap,"myComment",&isExist);
2026       if(!isExist || aTypeName != "EVOLUTION") continue;
2027
2028       //EVOLUTION
2029       theStr<<thePrefix<<endl;
2030       QString evolutionName = aSObject->GetName();
2031       theStr<<thePrefix<<"#Evolution: "<<evolutionName.toLatin1().data()<<endl;
2032       theStr<<thePrefix<<endl;
2033       theStr<<thePrefix<<"evolutionSO = aBuilder.NewObject(aSComponent)"<<endl;
2034       theStr<<thePrefix<<"aBuilder.SetName(evolutionSO, '"<<evolutionName.toLatin1().data()<<"')"<< endl;
2035       theStr<<thePrefix<<"strAttr = aBuilder.FindOrCreateAttribute(evolutionSO, 'AttributeString')"<< endl;
2036       theStr<<thePrefix<<"strAttr.SetValue('"<<value.toLatin1().data()<<"')"<< endl;
2037
2038       SALOMEDS::ChildIterator_var anIter = theStudy->NewChildIterator(aSObject);
2039       for (anIter->Init(); anIter->More(); anIter->Next()) {
2040         SALOMEDS::SObject_var anObj = anIter->Value();
2041
2042         //FIELD
2043         theStr<<thePrefix<<"fieldSO = aBuilder.NewObject(evolutionSO)"<<endl;
2044         if (anObj->FindAttribute(anAttr, "AttributeString")) {
2045           aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr);
2046           theStr<<thePrefix<<"strAttr = aBuilder.FindOrCreateAttribute(fieldSO, 'AttributeString')"<< endl;
2047           theStr<<thePrefix<<"strAttr.SetValue('"<<aStringAttr->Value()<<"')"<< endl;
2048         }
2049         
2050         SALOMEDS::SObject_var refObj;
2051         if(anObj->ReferencedObject(refObj)) {
2052           SALOMEDS::SObject_var father = refObj->GetFather();
2053           value = refObj->GetName();
2054           QString path(theStudy->GetObjectPath(father));
2055           //The following code requierd as a field name can contain '/' character
2056           theStr<<thePrefix<<"aBuilder.Addreference(fieldSO,getSObjectByFatherPathAndName(theStudy, '"<<path.toLatin1().data()<<"', '"<<value.toLatin1().data()<<"'))"<<endl;
2057         }
2058         value = anObj->GetName();
2059         if(!value.isEmpty()) theStr<<thePrefix<<"aBuilder.SetName(fieldSO, '"<<value.toLatin1().data()<<"')"<< endl;
2060
2061         //TABLE
2062         SALOMEDS::ChildIterator_var aChildItet = theStudy->NewChildIterator(anObj);
2063         for(aChildItet->InitEx(false); aChildItet->More(); aChildItet->Next()){
2064           SALOMEDS::SObject_var aSObject = aChildItet->Value();
2065
2066           std::string anArgumentName = "fieldSO";
2067           DumpTableAttrToPython(theStudy,
2068                                 theIsPublished,
2069                                 theIsValidScript,
2070                                 aSObject,
2071                                 theStr,
2072                                 theName2EntryMap,
2073                                 theEntry2NameMap,
2074                                 anArgumentName,
2075                                 thePrefix);
2076         }
2077       }
2078       
2079     }
2080
2081     theStr<<thePrefix<<endl;
2082   }
2083
2084
2085   //---------------------------------------------------------------------------
2086   void
2087   DumpAnimationsToPython(SALOMEDS::Study_ptr theStudy,
2088                          CORBA::Boolean theIsPublished,
2089                          CORBA::Boolean& theIsValidScript,
2090                          SALOMEDS::SObject_ptr theSObject,
2091                          std::ostream& theStr,
2092                          std::string thePrefix)
2093   {
2094
2095     if(!theIsPublished) return;
2096
2097     SALOMEDS::ChildIterator_var aChildItet = theStudy->NewChildIterator(theSObject);
2098     for(aChildItet->InitEx(false); aChildItet->More(); aChildItet->Next()){
2099       SALOMEDS::SObject_var aSObject = aChildItet->Value();
2100           
2101       SALOMEDS::GenericAttribute_var anAttr;
2102       if (!aSObject->FindAttribute(anAttr, "AttributeString")) continue;
2103       
2104       SALOMEDS::AttributeString_var aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr);
2105       QString value (aStringAttr->Value());
2106       if(value.isEmpty()) continue;
2107
2108       VISU::Storable::TRestoringMap aMap;
2109       VISU::Storable::StringToMap(value, aMap);
2110       bool isExist;
2111       
2112       QString aTypeName = VISU::Storable::FindValue(aMap,"myComment",&isExist);
2113       if(!isExist || aTypeName != "ANIMATION") continue;
2114
2115       //ANIMATION
2116       theStr<<thePrefix<<endl;
2117       QString animName = aSObject->GetName();
2118       theStr<<thePrefix<<"#Animation: "<<animName.toLatin1().data()<<endl;
2119       theStr<<thePrefix<<endl;
2120       theStr<<thePrefix<<"animSO = aBuilder.NewObject(aSComponent)"<<endl;
2121       theStr<<thePrefix<<"aBuilder.SetName(animSO, '"<<animName.toLatin1().data()<<"')"<< endl;
2122       theStr<<thePrefix<<"strAttr = aBuilder.FindOrCreateAttribute(animSO, 'AttributeString')"<< endl;
2123       theStr<<thePrefix<<"strAttr.SetValue('"<<value.toLatin1().data()<<"')"<< endl;
2124
2125
2126     
2127       SALOMEDS::ChildIterator_var anIter = theStudy->NewChildIterator(aSObject);
2128       for (anIter->Init(); anIter->More(); anIter->Next()) {
2129         SALOMEDS::SObject_var anObj = anIter->Value();
2130
2131         //FIELD
2132         theStr<<thePrefix<<"fieldSO = aBuilder.NewObject(animSO)"<<endl;
2133         if (anObj->FindAttribute(anAttr, "AttributeString")) {
2134           aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr);
2135           theStr<<thePrefix<<"strAttr = aBuilder.FindOrCreateAttribute(fieldSO, 'AttributeString')"<< endl;
2136           theStr<<thePrefix<<"strAttr.SetValue('"<<aStringAttr->Value()<<"')"<< endl;
2137         }
2138         
2139         SALOMEDS::SObject_var refObj;
2140         if(anObj->ReferencedObject(refObj)) {
2141           SALOMEDS::SObject_var father = refObj->GetFather();
2142           value = refObj->GetName();
2143           QString path(theStudy->GetObjectPath(father));
2144           //The following code requierd as a field name can contain '/' character
2145           theStr<<thePrefix<<"aBuilder.Addreference(fieldSO,getSObjectByFatherPathAndName(theStudy, '"<<path.toLatin1().data()<<"', '"<<value.toLatin1().data()<<"'))"<<endl;
2146         }
2147         value = anObj->GetName();
2148         if(!value.isEmpty()) theStr<<thePrefix<<"aBuilder.SetName(fieldSO, '"<<value.toLatin1().data()<<"')"<< endl;
2149
2150         //SCALARMAP,...
2151         SALOMEDS::ChildIterator_var aSubIter = theStudy->NewChildIterator(anObj);
2152         for (aSubIter->Init(); aSubIter->More(); aSubIter->Next()) {
2153           SALOMEDS::SObject_var aSubObj = aSubIter->Value();
2154           
2155           theStr<<thePrefix<<"subSO = aBuilder.NewObject(fieldSO)"<<endl;
2156           value = aSubObj->GetName();
2157           if(!value.isEmpty()) theStr<<thePrefix<<"aBuilder.SetName(subSO, '"<<value.toLatin1().data()<<"')"<< endl;
2158           if (aSubObj->FindAttribute(anAttr, "AttributeString")) {
2159             aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr);
2160             theStr<<thePrefix<<"strAttr = aBuilder.FindOrCreateAttribute(subSO, 'AttributeString')"<< endl;
2161             theStr<<thePrefix<<"strAttr.SetValue('"<<aStringAttr->Value()<<"')"<< endl;
2162           }
2163         }
2164
2165       }
2166       
2167     }
2168
2169     theStr<<thePrefix<<endl;
2170   }
2171
2172
2173   void
2174   DumpClippingPlanesToPython(SALOMEDS::Study_ptr theStudy,
2175                              CORBA::Boolean theIsPublished,
2176                              CORBA::Boolean& theIsValidScript,
2177                              SALOMEDS::SObject_ptr theSObject,
2178                              std::ostream& theStr,
2179                              std::string thePrefix,
2180                              VISU_ClippingPlaneMgr& thePlaneMgr)
2181   {
2182
2183     if(!theIsPublished) return;
2184
2185     VISU_CutPlaneFunction* aPlane;
2186     double aOrigin[3], aDir[3];
2187     for (int i = 0; i < thePlaneMgr.GetClippingPlanesNb(); i++) {
2188       aPlane = thePlaneMgr.GetClippingPlane(i);
2189       aPlane->GetOrigin(aOrigin);
2190       aPlane->GetNormal(aDir);
2191
2192       theStr<<thePrefix<<"aVisu.CreateClippingPlane("<<
2193         aOrigin[0]<<","<<aOrigin[1]<<","<<aOrigin[2]<<","<<
2194         aDir[0]<<","<<aDir[1]<<","<<aDir[2]<<","<<
2195         aPlane->isAuto()<<",\""<<aPlane->getName()<<"\")"<<endl;      
2196     }
2197     theStr<<endl;
2198   }  
2199
2200
2201   //---------------------------------------------------------------------------
2202   Engines::TMPFile*
2203   VISU_Gen_i::
2204   DumpPython(CORBA::Object_ptr theStudy,
2205              CORBA::Boolean theIsPublished,
2206              CORBA::Boolean& theIsValidScript)
2207   {
2208     theIsValidScript = false;
2209
2210     SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy);
2211     if(CORBA::is_nil(aStudy))
2212       return new Engines::TMPFile(0);
2213
2214     TName2EntryMap aName2EntryMap;
2215     TEntry2NameMap aEntry2NameMap;
2216
2217 #ifndef COUT
2218     ostringstream aStr;
2219 #else
2220 #define aStr cout
2221 #endif
2222
2223     std::string aPrefix(PREFIX);
2224     aStr<< "# -*- coding: iso-8859-1 -*-" << endl;
2225     aStr<<"### This file is generated by SALOME automatically by dump python functionality"
2226       " of VISU component"<<endl<<endl;
2227     aStr<<"def RebuildData(theStudy):"<<endl;
2228     aStr<<aPrefix<<"from batchmode_salome import orb, naming_service, lcc, myStudyManager"<<endl;
2229     aStr<<aPrefix<<"import SALOME_MED"<<endl;
2230     aStr<<aPrefix<<"import SALOMEDS"<<endl;
2231     aStr<<aPrefix<<"import VISU"<<endl;
2232     aStr<<aPrefix<<"import visu"<<endl;
2233     aStr<<endl;
2234     aStr<<aPrefix<<"aVisu = visu.Initialize(orb,naming_service,lcc,myStudyManager,theStudy,0)"<<endl;
2235     aStr<<aPrefix<<"aSComponent = visu.PublishComponent(theStudy)"<<endl;
2236     aStr<<aPrefix<<"aMed = lcc.FindOrLoadComponent('FactoryServer','MED')"<<endl;
2237     aStr<<aPrefix<<"aBuilder = theStudy.NewBuilder()"<<endl;
2238     aStr<<aPrefix<<"aName2ObjectMap = {}"<<endl;
2239     aStr<<endl;
2240
2241     SALOMEDS::SComponent_var aComponent = FindOrCreateVisuComponent(aStudy);
2242
2243     VISU::DumpClippingPlanesToPython(aStudy,
2244                                      theIsPublished,
2245                                      theIsValidScript,
2246                                      aComponent.in(),
2247                                      aStr,
2248                                      aPrefix, 
2249                                      myClippingPlaneMgr);
2250
2251
2252     VISU::DumpChildrenToPython(aStudy,
2253                                theIsPublished,
2254                                theIsValidScript,
2255                                aComponent.in(),
2256                                aStr,
2257                                aName2EntryMap,
2258                                aEntry2NameMap,
2259                                "",
2260                                aPrefix);
2261
2262     VISU::DumpEvolutionsToPython(aStudy,
2263                                  theIsPublished,
2264                                  theIsValidScript,
2265                                  aComponent.in(),
2266                                  aStr,
2267                                  aName2EntryMap,
2268                                  aEntry2NameMap,
2269                                  aPrefix);
2270
2271     VISU::DumpContainersToPython(aStudy,
2272                                  theIsPublished,
2273                                  theIsValidScript,
2274                                  aComponent.in(),
2275                                  aStr,
2276                                  aName2EntryMap,
2277                                  aEntry2NameMap,
2278                                  "",
2279                                  aPrefix);
2280
2281     VISU::DumpPrs3dCacheToPython(aStudy,
2282                                  theIsPublished,
2283                                  theIsValidScript,
2284                                  aComponent.in(),
2285                                  aStr,
2286                                  aName2EntryMap,
2287                                  aEntry2NameMap,
2288                                  "",
2289                                  aPrefix);
2290
2291     VISU::DumpAnimationsToPython(aStudy,
2292                                  theIsPublished,
2293                                  theIsValidScript,
2294                                  aComponent.in(),
2295                                  aStr,
2296                                  aPrefix);
2297
2298
2299     //Output the script that sets up the visul parameters.
2300     if(theIsPublished) {
2301       char* script = aStudy->GetDefaultScript("Post-Pro", aPrefix.c_str());
2302       if(script && strlen(script) > 0) {
2303         aStr << script;
2304         CORBA::string_free(script);
2305       }
2306     }
2307
2308     aStr<<aPrefix<<"pass"<<endl;
2309
2310     if(theIsPublished) { //SRN: define function for Animation
2311
2312       //Define a function that find a SObject by its father's path and its name
2313       aStr<<endl;
2314       aStr<<endl;
2315
2316       aStr<<"def getSObjectByFatherPathAndName(theStudy, thePath, theName):"<<endl;
2317       aStr<<aPrefix<<"father = theStudy.FindObjectByPath(thePath)"<<endl;
2318       aStr<<aPrefix<<"itr = theStudy.NewChildIterator(father)"<<endl;
2319       aStr<<aPrefix<<"while itr.More():"<<endl;
2320       aStr<<aPrefix<<aPrefix<<"so = itr.Value()"<<endl;
2321       aStr<<aPrefix<<aPrefix<<"if so.GetName()==theName: return so"<<endl;
2322       aStr<<aPrefix<<aPrefix<<"itr.Next()"<<endl;
2323       aStr<<aPrefix<<aPrefix<<"pass"<<endl;
2324       aStr<<aPrefix<<"return None"<<endl;
2325
2326       aStr<<endl;
2327     }
2328
2329     // theIsValidScript currently is not used by internal dump methods (DumpChildrenToPython(), etc.)
2330     // If the situation changes, then the following line should be removed, and theIsValidScript
2331     // should be set properly by those internal methods
2332     theIsValidScript = true;
2333
2334 #ifndef COUT
2335     std::string aResult = aStr.str();
2336     //ofstream anFStream("/tmp/dump.py");
2337     //anFStream<<aResult<<endl;
2338
2339     CORBA::ULong aSize = aResult.size() + 1;
2340     char* aBuffer = new char[aSize];
2341     strcpy(aBuffer,&aResult[0]);
2342     return new Engines::TMPFile(aSize,aSize,(CORBA::Octet*)aBuffer,1);
2343 #else
2344 #undef aStr
2345     return new Engines::TMPFile(0);
2346 #endif
2347   }
2348 }