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