1 // VISU OBJECT : interactive object for VISU entities implementation
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : VISU_DumpPython.cc
24 // Author : Alexey PETROV
27 #include "VISU_Gen_i.hh"
28 #include "VISU_Result_i.hh"
29 #include "VISU_PrsObject_i.hh"
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_GaussPoints_i.hh"
43 #include "VISU_ScalarMapOnDeformedShape_i.hh"
44 #include "VISU_ColoredPrs3dCache_i.hh"
45 #include "VISU_ColoredPrs3dHolder_i.hh"
47 #include "utilities.h"
54 #include <qfileinfo.h>
62 //---------------------------------------------------------------------------
63 static std::string PREFIX(" ");
65 typedef std::map<std::string,std::string> TName2EntryMap;
66 typedef std::map<std::string,std::string> TEntry2NameMap;
69 //---------------------------------------------------------------------------
72 GenerateName(std::string theName,
73 SALOMEDS::SObject_ptr theSObject,
74 TName2EntryMap& theName2EntryMap,
75 TEntry2NameMap& theEntry2NameMap,
78 if(theName2EntryMap.find(theName) != theName2EntryMap.end()){
79 theName = GenerateName(theName + theSuffix, theSObject, theName2EntryMap, theEntry2NameMap, theSuffix);
81 CORBA::String_var anID = theSObject->GetID();
82 theName2EntryMap[theName] = anID.in();
83 theEntry2NameMap[anID.in()] = theName;
84 //cout<<"GenerateName - "<<theName<<" => "<<anID.in()<<endl;
91 //---------------------------------------------------------------------------
92 struct TReplacePredicate
94 bool operator()(char theChar) const
96 return !(isdigit(theChar) || isalpha(theChar) || theChar == '_');
101 //---------------------------------------------------------------------------
104 GetName(SALOMEDS::SObject_ptr theSObject)
106 CORBA::String_var aString = theSObject->GetName();
108 std::string aName = QString(aString.in()).simplifyWhiteSpace().latin1();
110 //replace_if(aName.begin(),aName.end(),not1(ptr_fun(isxdigit)),'_');
111 replace_if(aName.begin(),aName.end(),TReplacePredicate(),'_');
113 if ( isdigit( aName[0] ))
114 aName.insert( 0, 1, 'a' );
120 //---------------------------------------------------------------------------
123 GenerateName(SALOMEDS::SObject_ptr theSObject,
124 TName2EntryMap& theName2EntryMap,
125 TEntry2NameMap& theEntry2NameMap)
127 std::string aName = GetName(theSObject);
129 return GenerateName(aName, theSObject, theName2EntryMap, theEntry2NameMap, 'X');
133 //---------------------------------------------------------------------------
136 GetBoolean(bool theArgument)
145 //---------------------------------------------------------------------------
148 GetColor(const SALOMEDS::Color& theColor)
150 std::ostringstream aStream;
151 aStream<<"SALOMEDS.Color("<<theColor.R<<", "<<theColor.G<<", "<<theColor.B<<")";
152 return aStream.str();
156 //---------------------------------------------------------------------------
157 typedef void (*TDumpToPython)(SALOMEDS::Study_ptr theStudy,
158 CORBA::Boolean theIsPublished,
159 CORBA::Boolean& theIsValidScript,
160 SALOMEDS::SObject_ptr theSObject,
161 std::ostream& theStr,
162 TName2EntryMap& theName2EntryMap,
163 TEntry2NameMap& theEntry2NameMap,
164 std::string theArgumentName,
165 std::string thePrefix);
169 DumpToPython(SALOMEDS::Study_ptr theStudy,
170 CORBA::Boolean theIsPublished,
171 CORBA::Boolean& theIsValidScript,
172 SALOMEDS::SObject_ptr theSObject,
173 std::ostream& theStr,
174 TName2EntryMap& theName2EntryMap,
175 TEntry2NameMap& theEntry2NameMap,
176 std::string theArgumentName,
177 std::string thePrefix);
180 //---------------------------------------------------------------------------
182 Prs3dToPython(VISU::Prs3d_i* theServant,
183 std::ostream& theStr,
184 const std::string& theName,
185 std::string thePrefix)
188 theServant->GetOffset(x,y,z);
189 theStr<<thePrefix<<theName<<".SetOffset("<<x<<", "<<y<<", "<<z<<")"<<endl;
192 //---------------------------------------------------------------------------
193 struct TColoredPrs3dFactory
197 operator()(std::ostream& theStr,
198 std::string thePrefix)
206 struct TCreateFromResult: TColoredPrs3dFactory
208 VISU::ColoredPrs3d_i* myServant;
209 std::string myConstructorName;
210 std::string myArgumentName;
212 SALOMEDS::SObject_var mySObject;
215 TCreateFromResult(const SALOMEDS::SObject_var& theSObject,
216 VISU::ColoredPrs3d_i* theServant,
217 const std::string& theName,
218 const std::string& theConstructorName,
219 const std::string& theArgumentName):
220 myServant(theServant),
221 myConstructorName(theConstructorName),
222 myArgumentName(theArgumentName),
223 mySObject(theSObject),
229 operator()(std::ostream& theStr,
230 std::string thePrefix)
233 switch(myServant->GetEntity()){
235 aParam = "VISU.NODE";
238 aParam = "VISU.EDGE";
241 aParam = "VISU.FACE";
244 aParam = "VISU.CELL";
248 theStr<<thePrefix<<myName<<" = aVisu."<<myConstructorName<<"("<<myArgumentName<<
249 ", '"<<myServant->GetCMeshName()<<"'"<<
251 ", '"<<myServant->GetCFieldName()<<"'"<<
252 ", "<<myServant->GetTimeStampNumber()<<
255 theStr<<thePrefix<<"if "<<myName<<" != None:"<<endl;
258 // Add to Name->Object map
259 theStr<<thePrefix<<"aName2ObjectMap['"<<myName<<"'] = "<<myName<<endl;
261 // Set name (as this object could be renamed by user)
262 CORBA::String_var aNameInStudy = mySObject->GetName();
263 theStr<<thePrefix<<"visu.SetName("<<myName<<", '"<<aNameInStudy.in()<<"')"<<endl;
270 //---------------------------------------------------------------------------
272 ColoredPrs3dToPython(SALOMEDS::SObject_ptr theSObject,
273 VISU::ColoredPrs3d_i* theServant,
274 std::ostream& theStr,
275 const std::string& theName,
276 TColoredPrs3dFactory& thePrsFactory,
277 std::string thePrefix)
279 thePrefix = thePrsFactory(theStr, thePrefix);
281 // Set parameters common for all Prs3d objects (offset values)
282 Prs3dToPython(theServant, theStr, theName, thePrefix);
284 theStr<<thePrefix<<theName<<".SetPosition("<<theServant->GetPosX()<<", "<<theServant->GetPosY()<<")"<<endl;
285 theStr<<thePrefix<<theName<<".SetSize("<<theServant->GetWidth()<<", "<<theServant->GetHeight()<<")"<<endl;
286 theStr<<thePrefix<<theName<<".SetNbColors("<<theServant->GetNbColors()<<")"<<endl;
287 theStr<<thePrefix<<theName<<".SetLabels("<<theServant->GetLabels()<<")"<<endl;
288 theStr<<thePrefix<<theName<<".SetTitle('"<<theServant->GetTitle()<<"')"<<endl;
291 switch(theServant->GetBarOrientation()){
292 case ColoredPrs3d::HORIZONTAL:
293 aParam = "VISU.ColoredPrs3d.HORIZONTAL";
295 case ColoredPrs3d::VERTICAL:
296 aParam = "VISU.ColoredPrs3d.VERTICAL";
299 theStr<<thePrefix<<theName<<".SetBarOrientation("<<aParam<<")"<<endl;
301 theStr<<thePrefix<<theName<<".SetScalarMode("<<theServant->GetScalarMode()<<")"<<endl;
303 if(theServant->IsRangeFixed())
304 theStr<<thePrefix<<theName<<".SetRange("<<theServant->GetMin()<<", "<<theServant->GetMax()<<")"<<endl;
306 theStr<<thePrefix<<theName<<".SetSourceRange()"<<endl;
308 const VISU::ColoredPrs3d_i::TGroupNames aGroupNames = theServant->GetGroupNames();
309 VISU::ColoredPrs3d_i::TGroupNames::const_iterator anIter = aGroupNames.begin();
310 for(; anIter != aGroupNames.end(); anIter++){
311 const std::string& aGroupName = *anIter;
312 theStr<<thePrefix<<theName<<".AddMeshOnGroup('"<<aGroupName<<"')"<<endl;
319 //---------------------------------------------------------------------------
321 GaussPointsToPython(SALOMEDS::SObject_ptr theSObject,
322 VISU::GaussPoints_i* theServant,
323 std::ostream& theStr,
324 const std::string& theName,
325 TColoredPrs3dFactory& thePrsFactory,
326 std::string thePrefix)
328 thePrefix = ColoredPrs3dToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
329 theStr<<thePrefix<<endl;
331 bool aBoolean = theServant->GetIsActiveLocalScalarBar();
332 theStr<<thePrefix<<theName<<".SetIsActiveLocalScalarBar("<<GetBoolean(aBoolean)<<")"<<endl;
335 aBoolean = theServant->GetIsDispGlobalScalarBar();
336 theStr<<thePrefix<<theName<<".SetIsDispGlobalScalarBar("<<GetBoolean(aBoolean)<<")"<<endl;
339 theStr<<thePrefix<<theName<<".SetSpacing("<<theServant->GetSpacing()<<")"<<endl;
341 aBoolean = theServant->GetBiColor();
342 theStr<<thePrefix<<theName<<".SetBiColor("<<GetBoolean(aBoolean)<<")"<<endl;
344 aBoolean = theServant->GetIsDeformed();
345 theStr<<thePrefix<<theName<<".SetIsDeformed("<<GetBoolean(aBoolean)<<")"<<endl;
346 theStr<<thePrefix<<theName<<".SetScaleFactor("<<theServant->GetScaleFactor()<<")"<<endl;
349 switch(theServant->GetPrimitiveType()){
350 case VISU::GaussPoints::SPRITE :
351 aParam = "VISU.GaussPoints.SPRITE";
353 case VISU::GaussPoints::POINT :
354 aParam = "VISU.GaussPoints.POINT";
356 case VISU::GaussPoints::SPHERE :
357 aParam = "VISU.GaussPoints.SPHERE";
360 theStr<<thePrefix<<theName<<".SetPrimitiveType("<<aParam<<")"<<endl;
362 theStr<<thePrefix<<theName<<".SetClamp("<<theServant->GetClamp()<<")"<<endl;
364 QString aMainTexture = theServant->GetQMainTexture();
365 QString anAlphaTexture = theServant->GetQAlphaTexture();
366 theStr<<thePrefix<<theName<<".SetTextures('"<<aMainTexture.latin1()<<"', '"<<anAlphaTexture.latin1()<<"')"<<endl;
368 theStr<<thePrefix<<theName<<".SetAlphaThreshold("<<theServant->GetAlphaThreshold()<<")"<<endl;
370 theStr<<thePrefix<<theName<<".SetResolution("<<theServant->GetResolution()<<")"<<endl;
372 theStr<<thePrefix<<theName<<".SetFaceLimit("<<theServant->GetFaceLimit()<<")"<<endl;
374 aBoolean = theServant->GetIsColored();
375 theStr<<thePrefix<<theName<<".SetIsColored("<<GetBoolean(aBoolean)<<")"<<endl;
378 theStr<<thePrefix<<theName<<".SetMinSize("<<theServant->GetMinSize()<<")"<<endl;
379 theStr<<thePrefix<<theName<<".SetMaxSize("<<theServant->GetMaxSize()<<")"<<endl;
381 theStr<<thePrefix<<theName<<".SetColor("<<GetColor(theServant->GetColor())<<")"<<endl;
382 theStr<<thePrefix<<theName<<".SetGeomSize("<<theServant->GetGeomSize()<<")"<<endl;
385 theStr<<thePrefix<<theName<<".SetMagnification("<<theServant->GetMagnification()<<")"<<endl;
386 theStr<<thePrefix<<theName<<".SetMagnificationIncrement("<<theServant->GetMagnificationIncrement()<<")"<<endl;
392 //---------------------------------------------------------------------------
394 ScalarMapToPython(SALOMEDS::SObject_ptr theSObject,
395 VISU::ScalarMap_i* theServant,
396 std::ostream& theStr,
397 const std::string& theName,
398 TColoredPrs3dFactory& thePrsFactory,
399 std::string thePrefix)
401 thePrefix = ColoredPrs3dToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
402 theStr<<thePrefix<<endl;
405 switch(theServant->GetScaling()){
407 aParam = "VISU.LINEAR";
410 aParam = "VISU.LOGARITHMIC";
413 theStr<<thePrefix<<theName<<".SetScaling("<<aParam<<")"<<endl;
419 //---------------------------------------------------------------------------
421 DeformedShapeToPython(SALOMEDS::SObject_ptr theSObject,
422 VISU::DeformedShape_i* theServant,
423 std::ostream& theStr,
424 const std::string& theName,
425 TColoredPrs3dFactory& thePrsFactory,
426 std::string thePrefix)
428 thePrefix = ScalarMapToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
429 theStr<<thePrefix<<endl;
431 theStr<<thePrefix<<theName<<".SetScale("<<theServant->GetScale()<<")"<<endl;
432 theStr<<thePrefix<<theName<<".ShowColored("<<GetBoolean(theServant->IsColored())<<")"<<endl;
433 theStr<<thePrefix<<theName<<".SetColor("<<GetColor(theServant->GetColor())<<")"<<endl;
439 //---------------------------------------------------------------------------
441 StreamLinesToPython(SALOMEDS::SObject_ptr theSObject,
442 VISU::StreamLines_i* theServant,
443 std::ostream& theStr,
444 TEntry2NameMap& theEntry2NameMap,
445 const std::string& theName,
446 TColoredPrs3dFactory& thePrsFactory,
447 std::string thePrefix)
449 thePrefix = DeformedShapeToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
450 theStr<<thePrefix<<endl;
453 switch(theServant->GetDirection()){
454 case StreamLines::FORWARD:
455 aParam = "VISU.StreamLines.FORWARD";
457 case StreamLines::BACKWARD:
458 aParam = "VISU.StreamLines.BACKWARD";
460 case StreamLines::BOTH:
461 aParam = "VISU.StreamLines.BOTH";
465 theStr<<thePrefix<<"aPrs3d = None"<<endl;
466 VISU::Prs3d_var aPrs3d = theServant->GetSource();
467 if(!CORBA::is_nil(aPrs3d)){
468 if(Prs3d_i* aServant3d = dynamic_cast<Prs3d_i*>(GetServant(aPrs3d).in())){
469 SALOMEDS::SObject_var aSObject = aServant3d->GetSObject();
470 CORBA::String_var anID = aSObject->GetID();
471 std::string anArg = theEntry2NameMap[anID.in()];
472 theStr<<thePrefix<<"if aName2ObjectMap.has_key('"<<anArg<<"'):"<<endl;
474 theStr<<thePrefix<<"aPrs3d = aName2ObjectMap['"<<anArg<<"']"<<endl;
478 theStr<<thePrefix<<theName<<".SetParams("<<
479 theServant->GetIntegrationStep()<<", "<<
480 theServant->GetPropagationTime()<<", "<<
481 theServant->GetStepLength()<<", "<<
483 theServant->GetUsedPoints()<<", "<<
491 //---------------------------------------------------------------------------
493 ScalarMapOnDeformedShapeToPython(SALOMEDS::SObject_ptr theSObject,
494 VISU::ScalarMapOnDeformedShape_i* theServant,
495 std::ostream& theStr,
496 const std::string& theName,
497 TColoredPrs3dFactory& thePrsFactory,
498 std::string thePrefix)
500 thePrefix = ScalarMapToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
501 theStr<<thePrefix<<endl;
503 theStr<<thePrefix<<theName<<".SetRange("<<theServant->GetMin()<<", "<<theServant->GetMax()<<")"<<endl;
504 theStr<<thePrefix<<theName<<".SetScale("<<theServant->GetScale()<<")"<<endl;
507 VISU::Entity anEntity = theServant->GetScalarEntity();
510 aParam = "VISU.NODE";
513 aParam = "VISU.EDGE";
516 aParam = "VISU.FACE";
519 aParam = "VISU.CELL";
523 CORBA::String_var aFieldName = theServant->GetScalarFieldName();
524 CORBA::Long aTimeStampNumber = theServant->GetScalarTimeStampNumber();
526 theStr<<thePrefix<<theName<<".SetScalarField("<<
528 "'"<<aFieldName<<"', "<<
536 //---------------------------------------------------------------------------
538 VectorsToPython(SALOMEDS::SObject_ptr theSObject,
539 VISU::Vectors_i* theServant,
540 std::ostream& theStr,
541 const std::string& theName,
542 TColoredPrs3dFactory& thePrsFactory,
543 std::string thePrefix)
545 thePrefix = DeformedShapeToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
546 theStr<<thePrefix<<endl;
548 theStr<<thePrefix<<theName<<".SetLineWidth("<<theServant->GetLineWidth()<<")"<<endl;
551 switch(theServant->GetGlyphType()){
553 aParam = "VISU.Vectors.ARROW";
556 aParam = "VISU.Vectors.CONE2";
559 aParam = "VISU.Vectors.CONE6";
562 aParam = "VISU.Vectors.NONE";
565 theStr<<thePrefix<<theName<<".SetGlyphType("<<aParam<<")"<<endl;
567 switch(theServant->GetGlyphPos()){
568 case Vectors::CENTER:
569 aParam = "VISU.Vectors.CENTER";
572 aParam = "VISU.Vectors.TAIL";
575 aParam = "VISU.Vectors.HEAD";
578 theStr<<thePrefix<<theName<<".SetGlyphPos("<<aParam<<")"<<endl;
584 //---------------------------------------------------------------------------
586 IsoSurfacesToPython(SALOMEDS::SObject_ptr theSObject,
587 VISU::IsoSurfaces_i* theServant,
588 std::ostream& theStr,
589 const std::string& theName,
590 TColoredPrs3dFactory& thePrsFactory,
591 std::string thePrefix)
593 thePrefix = ScalarMapToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
594 theStr<<thePrefix<<endl;
596 theStr<<thePrefix<<theName<<".SetNbSurfaces("<<theServant->GetNbSurfaces()<<")"<<endl;
602 //---------------------------------------------------------------------------
604 CutPlanesToPython(SALOMEDS::SObject_ptr theSObject,
605 VISU::CutPlanes_i* theServant,
606 std::ostream& theStr,
607 const std::string& theName,
608 TColoredPrs3dFactory& thePrsFactory,
609 std::string thePrefix)
611 thePrefix = ScalarMapToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
612 theStr<<thePrefix<<endl;
615 switch(theServant->GetOrientationType()){
617 aParam = "VISU.CutPlanes.XY";
620 aParam = "VISU.CutPlanes.YZ";
623 aParam = "VISU.CutPlanes.ZX";
626 theStr<<thePrefix<<theName<<".SetOrientation("<<aParam<<", "<<theServant->GetRotateX()<<", "<<theServant->GetRotateY()<<")"<<endl;
628 theStr<<thePrefix<<theName<<".SetDisplacement("<<theServant->GetDisplacement()<<")"<<endl;
629 CORBA::Long aNbPlanes = theServant->GetNbPlanes();
630 theStr<<thePrefix<<theName<<".SetNbPlanes("<<aNbPlanes<<")"<<endl;
632 for(CORBA::Long anId = 0; anId < aNbPlanes; anId++){
633 if(!theServant->IsDefault(anId))
634 theStr<<thePrefix<<theName<<".SetPlanePosition("<<anId<<", "<<theServant->GetPlanePosition(anId)<<")"<<endl;
641 //---------------------------------------------------------------------------
643 CutLinesToPython(SALOMEDS::SObject_ptr theSObject,
644 VISU::CutLines_i* theServant,
645 std::ostream& theStr,
646 const std::string& theName,
647 TColoredPrs3dFactory& thePrsFactory,
648 std::string thePrefix)
650 thePrefix = ScalarMapToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
651 theStr<<thePrefix<<endl;
654 switch(theServant->GetOrientationType()){
656 aParam = "VISU.CutPlanes.XY";
659 aParam = "VISU.CutPlanes.YZ";
662 aParam = "VISU.CutPlanes.ZX";
665 theStr<<thePrefix<<theName<<".SetOrientation("<<aParam<<", "<<theServant->GetRotateX()<<", "<<theServant->GetRotateY()<<")"<<endl;
667 switch(theServant->GetOrientationType2()){
669 aParam = "VISU.CutPlanes.XY";
672 aParam = "VISU.CutPlanes.YZ";
675 aParam = "VISU.CutPlanes.ZX";
678 theStr<<thePrefix<<theName<<".SetOrientation2("<<aParam<<", "<<theServant->GetRotateX2()<<", "<<theServant->GetRotateY2()<<")"<<endl;
680 theStr<<thePrefix<<theName<<".SetDisplacement("<<theServant->GetDisplacement()<<")"<<endl;
681 theStr<<thePrefix<<theName<<".SetDisplacement2("<<theServant->GetDisplacement2()<<")"<<endl;
683 if(!theServant->IsDefault())
684 theStr<<thePrefix<<theName<<".SetBasePlanePosition("<<theServant->GetBasePlanePosition()<<")"<<endl;
686 CORBA::Boolean aUseAbsLength = theServant->IsUseAbsoluteLength();
687 theStr<<thePrefix<<theName<<".SetUseAbsoluteLength("<<aUseAbsLength<<")"<<endl;
689 CORBA::Long aNbLines = theServant->GetNbLines();
690 theStr<<thePrefix<<theName<<".SetNbLines("<<aNbLines<<")"<<endl;
691 for(CORBA::Long anId = 0; anId < aNbLines; anId++){
692 if(!theServant->IsDefaultPosition(anId))
693 theStr<<thePrefix<<theName<<".SetLinePosition("<<anId<<", "<<theServant->GetLinePosition(anId)<<")"<<endl;
700 //---------------------------------------------------------------------------
702 Plot3DToPython(SALOMEDS::SObject_ptr theSObject,
703 VISU::Plot3D_i* theServant,
704 std::ostream& theStr,
705 const std::string& theName,
706 TColoredPrs3dFactory& thePrsFactory,
707 std::string thePrefix)
709 thePrefix = ScalarMapToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix);
710 theStr<<thePrefix<<endl;
713 switch(theServant->GetOrientationType()){
715 aParam = "VISU.Plot3D.XY";
718 aParam = "VISU.Plot3D.YZ";
721 aParam = "VISU.Plot3D.ZX";
724 theStr<<thePrefix<<theName<<".SetOrientation("<<aParam<<", "<<theServant->GetRotateX()<<", "<<theServant->GetRotateY()<<")"<<endl;
726 theStr<<thePrefix<<theName<<".SetPlanePosition("<<theServant->GetPlanePosition()<<", "<<theServant->IsPositionRelative()<<")"<<endl;
727 theStr<<thePrefix<<theName<<".SetScaleFactor("<<theServant->GetScaleFactor()<<")"<<endl;
728 theStr<<thePrefix<<theName<<".SetContourPrs("<<theServant->GetIsContourPrs()<<")"<<endl;
729 theStr<<thePrefix<<theName<<".SetNbOfContours("<<theServant->GetNbOfContours()<<")"<<endl;
735 //---------------------------------------------------------------------------
737 void DumpChildrenToPython(SALOMEDS::Study_ptr theStudy,
738 CORBA::Boolean theIsPublished,
739 CORBA::Boolean& theIsValidScript,
740 SALOMEDS::SObject_ptr theSObject,
741 std::ostream& theStr,
742 TName2EntryMap& theName2EntryMap,
743 TEntry2NameMap& theEntry2NameMap,
744 std::string theArgumentName,
745 std::string thePrefix);
747 //---------------------------------------------------------------------------
748 template<class TTableAttr>
750 TableAttrToPython(SALOMEDS::Study_ptr theStudy,
751 CORBA::Boolean theIsPublished,
752 CORBA::Boolean& theIsValidScript,
753 SALOMEDS::SObject_ptr theSObject,
754 TTableAttr theTableAttr,
755 const std::string& theAttrName,
756 std::ostream& theStr,
757 TName2EntryMap& theName2EntryMap,
758 TEntry2NameMap& theEntry2NameMap,
759 std::string theArgumentName,
760 std::string thePrefix)
762 SALOMEDS::GenericAttribute_var anAttr;
763 SALOMEDS::SObject_var aFatherSObject = theSObject->GetFather();
764 if(aFatherSObject->FindAttribute(anAttr,"AttributeString")){
765 SALOMEDS::AttributeString_var aComment =
766 SALOMEDS::AttributeString::_narrow(anAttr);
767 CORBA::String_var aValue = aComment->Value();
768 Storable::TRestoringMap aMap;
769 Storable::StringToMap(aValue.in(),aMap);
771 QString aMethodName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist);
773 if(strcmp(aMethodName.latin1(),"ImportTables") == 0){
779 std::string aSObjectName = GetName(theSObject);
780 theStr<<thePrefix<<aSObjectName<<" = aBuilder.NewObject(aSComponent)"<<endl;
781 theStr<<thePrefix<<"if "<<aSObjectName<<":"<<endl;
784 theStr<<thePrefix<<"aBuilder.SetName("<<aSObjectName<<", \""<<theSObject->GetName()<<"\")"<<endl; // Fix for IPAL13165
785 std::string aName = "aTableAttr";
786 theStr<<thePrefix<<aName<<" = aBuilder.FindOrCreateAttribute("<<
787 aSObjectName<<", '"<<theAttrName<<"')"<<endl;
789 theStr<<thePrefix<<"if "<<aName<<":"<<endl;
790 std::string aPrefix = thePrefix;
793 CORBA::String_var aString = theTableAttr->GetTitle();
794 theStr<<thePrefix<<aName<<".SetTitle('"<<aString.in()<<"')"<<endl;
796 CORBA::Long aNbColumns = theTableAttr->GetNbColumns();
797 theStr<<thePrefix<<aName<<".SetNbColumns("<<aNbColumns<<")"<<endl;
799 CORBA::Long aNbRows = theTableAttr->GetNbRows();
801 // push values and their indices into streams
802 strstream values, rows, columns;
804 for(CORBA::Long i = 1; i <= aNbColumns; i++){
805 for(CORBA::Long j = aNbRows; j > 0; j--){
806 if(theTableAttr->HasValue(j,i)){
807 values << comma << theTableAttr->GetValue(j,i);
809 columns << comma << i;
815 // push titles and units into streams
816 strstream rowUnits, rowTitles, colTitles;
817 SALOMEDS::StringSeq_var aRowUnits = theTableAttr->GetRowUnits();
818 SALOMEDS::StringSeq_var aRowTitles = theTableAttr->GetRowTitles();
820 for(CORBA::Long j = 1; j <= aNbRows; j++){
821 rowUnits << comma << "'" << aRowUnits [ j - 1 ] << "'";
822 rowTitles << comma << "'" << aRowTitles[ j - 1 ] << "'";
826 SALOMEDS::StringSeq_var aColumnTitles = theTableAttr->GetColumnTitles();
828 for(CORBA::Long j = 1; j <= aNbColumns; j++){
829 colTitles << comma << "'" << aColumnTitles[ j - 1 ] << "'";
839 // write FillTable command
840 theStr<< thePrefix << aName << "_values = [" << values.str() << "]" << endl;
841 theStr<< thePrefix << aName << "_rows = [" << rows.str() << "]" << endl;
842 theStr<< thePrefix << aName << "_columns = [" << columns.str() << "]" << endl;
843 theStr<< thePrefix << aName << "_rUnits = [" << rowUnits.str() << "]" << endl;
844 theStr<< thePrefix << aName << "_rTitles = [" << rowTitles.str() << "]" << endl;
845 theStr<< thePrefix << aName << "_cTitles = [" << colTitles.str() << "]" << endl;
846 theStr<< thePrefix << "visu.FillTable( "
848 << aName << "_values, "
849 << aName << "_rows, "
850 << aName << "_columns, "
851 << aName << "_rTitles, "
852 << aName << "_rUnits, "
853 << aName << "_cTitles )" << endl;
855 if(theSObject->FindAttribute(anAttr,"AttributeIOR")){
856 theStr<<thePrefix<<endl;
857 std::string aName = "aTable";
858 theStr<<thePrefix<<"anID = "<<aSObjectName<<".GetID()"<<endl;
859 theStr<<thePrefix<<aName<<" = aVisu.CreateTable(anID)"<<endl;
860 theArgumentName = aName;
862 theStr<<thePrefix<<"if "<<aName<<":"<<endl;
863 std::string aPrefix2 = thePrefix + PREFIX;
865 // Set name (as this object could be renamed by user)
866 CORBA::String_var aNameInStudy = theSObject->GetName();
867 theStr<<aPrefix2<<aName<<".SetTitle('"<<aNameInStudy.in()<<"') # 1"<<endl;
869 DumpChildrenToPython(theStudy,
879 theStr<<aPrefix2<<"pass"<<endl<<endl;
882 theStr<<thePrefix<<"pass"<<endl<<endl;
883 theStr<<aPrefix<<"pass"<<endl<<endl;
887 //---------------------------------------------------------------------------
889 DumpChildrenToPython(SALOMEDS::Study_ptr theStudy,
890 CORBA::Boolean theIsPublished,
891 CORBA::Boolean& theIsValidScript,
892 SALOMEDS::SObject_ptr theSObject,
893 std::ostream& theStr,
894 TName2EntryMap& theName2EntryMap,
895 TEntry2NameMap& theEntry2NameMap,
896 std::string theArgumentName,
897 std::string thePrefix)
899 SALOMEDS::ChildIterator_var aChildItet = theStudy->NewChildIterator(theSObject);
900 for(aChildItet->InitEx(false); aChildItet->More(); aChildItet->Next()){
901 SALOMEDS::SObject_var aSObject = aChildItet->Value();
902 DumpToPython(theStudy,
915 //---------------------------------------------------------------------------
917 DumpTableAttrToPython(SALOMEDS::Study_ptr theStudy,
918 CORBA::Boolean theIsPublished,
919 CORBA::Boolean& theIsValidScript,
920 SALOMEDS::SObject_ptr theSObject,
921 std::ostream& theStr,
922 TName2EntryMap& theName2EntryMap,
923 TEntry2NameMap& theEntry2NameMap,
924 std::string theArgumentName,
925 std::string thePrefix)
927 SALOMEDS::GenericAttribute_var anAttr;
928 if(theSObject->FindAttribute(anAttr,"AttributeTableOfInteger")){
929 SALOMEDS::AttributeTableOfInteger_var aTableAttr =
930 SALOMEDS::AttributeTableOfInteger::_narrow(anAttr);
932 TableAttrToPython(theStudy,
937 "AttributeTableOfInteger",
944 }else if(theSObject->FindAttribute(anAttr,"AttributeTableOfReal")){
945 SALOMEDS::AttributeTableOfReal_var aTableAttr =
946 SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
948 TableAttrToPython(theStudy,
953 "AttributeTableOfReal",
964 //---------------------------------------------------------------------------
966 DumpToPython(SALOMEDS::Study_ptr theStudy,
967 CORBA::Boolean theIsPublished,
968 CORBA::Boolean& theIsValidScript,
969 SALOMEDS::SObject_ptr theSObject,
970 std::ostream& theStr,
971 TName2EntryMap& theName2EntryMap,
972 TEntry2NameMap& theEntry2NameMap,
973 std::string theArgumentName,
974 std::string thePrefix)
976 std::string aName = GetName(theSObject);
980 CORBA::String_var anID = theSObject->GetID();
981 CORBA::String_var aNameInStudy = theSObject->GetName();
983 CORBA::Object_var anObj = SObjectToObject(theSObject);
984 if (!CORBA::is_nil(anObj)) {
985 VISU::Base_var aBase = VISU::Base::_narrow(anObj);
986 if(!CORBA::is_nil(aBase)){
987 std::string aName = GenerateName(theSObject, theName2EntryMap, theEntry2NameMap);
989 VISU::VISUType aType = aBase->GetType();
992 if(Result_i* aServant = dynamic_cast<Result_i*>(GetServant(anObj).in())){
993 std::string aFileName = aServant->GetInitFileName();
994 Result_i::ECreationId anId = aServant->GetCreationId();
995 if(anId == Result_i::eImportFile || anId == Result_i::eCopyAndImportFile){
997 case Result_i::eImportFile:
998 theStr<<thePrefix<<aName<<" = aVisu.CreateResult('"<<aFileName<<"')"<<endl;
1000 theStr<<thePrefix<<aName<<".SetBuildGroups("<<
1001 GetBoolean(aServant->IsGroupsDone())<<")"<<
1004 theStr<<thePrefix<<aName<<".SetBuildFields("<<
1005 GetBoolean(aServant->IsFieldsDone())<<", "<<
1006 GetBoolean(aServant->IsMinMaxDone())<<")"<<
1009 theStr<<thePrefix<<aName<<".Build(False, True)"<<endl;
1011 theStr<<thePrefix<<"if "<<aName<<".IsDone() :"<<endl;
1013 case Result_i::eCopyAndImportFile:
1014 theStr<<thePrefix<<aName<<" = aVisu.CopyAndImportFile('"<<aFileName<<"')"<<endl;
1015 theStr<<thePrefix<<"if "<<aName<<":"<<endl;
1019 thePrefix += PREFIX;
1021 VISU::Result::EntityNames_var aMeshNames = aServant->GetMeshNames();
1022 if (aMeshNames->length() > 0) {
1023 for(size_t aMeshId = 0; aMeshId < aMeshNames->length(); aMeshId++){
1024 CORBA::String_var aMeshName = aMeshNames[aMeshId];
1025 VISU::Result::EntityNames_var aParts = aServant->GetPartNames(aMeshName);
1026 if (aParts->length() > 0) {
1027 for(size_t aPartId = 0; aPartId < aParts->length(); aPartId++){
1028 CORBA::String_var aPart = aParts[aPartId];
1029 VISU::Result::Resolution aResolution = aServant->GetResolution(aMeshName, aPart);
1031 switch(aResolution){
1032 case VISU::Result::FULL:
1033 aParam = "VISU.Result.FULL";
1035 case VISU::Result::MEDIUM:
1036 aParam = "VISU.Result.MEDIUM";
1038 case VISU::Result::LOW:
1039 aParam = "VISU.Result.LOW";
1041 case VISU::Result::HIDDEN:
1042 aParam = "VISU.Result.HIDDEN";
1045 theStr<<thePrefix<<aName<<".SetResolution('"<<aMeshName.in()<<"', '"<<aPart.in()<<"', "<<aParam<<")"<<endl;
1047 theStr<<thePrefix<<endl;
1053 theArgumentName = aName;
1054 DumpChildrenToPython(theStudy,
1064 theStr<<thePrefix<<"pass"<<endl<<endl;
1066 SALOMEDS::SObject_var aRefSObj;
1067 if(theSObject->FindSubObject(1,aRefSObj)){
1068 SALOMEDS::SObject_var aTargetRefSObj;
1069 if(aRefSObj->ReferencedObject(aTargetRefSObj)){
1070 CORBA::String_var aString = aTargetRefSObj->GetName();
1071 theStr<<thePrefix<<"aSObject = theStudy.FindObject('"<<aString.in()<<"')"<<endl;
1072 theStr<<thePrefix<<"if aSObject:"<<endl;
1073 thePrefix += PREFIX;
1074 theStr<<thePrefix<<"anObject = aSObject.GetObject()"<<endl;
1075 theStr<<thePrefix<<"if anObject:"<<endl;
1076 std::string aPrefix1 = thePrefix;
1077 thePrefix += PREFIX;
1080 case Result_i::eImportMed:
1081 theStr<<thePrefix<<aName<<" = aVisu.ImportMed(aSObject)"<<endl;
1083 case Result_i::eImportMedField:
1084 theStr<<thePrefix<<aName<<" = aVisu.ImportMedField(anObject)"<<endl;
1088 theStr<<thePrefix<<"if "<<aName<<":"<<endl;
1089 std::string aPrefix2 = thePrefix;
1090 thePrefix += PREFIX;
1092 theArgumentName = aName;
1093 DumpChildrenToPython(theStudy,
1103 theStr<<thePrefix<<"pass"<<endl<<endl;
1104 theStr<<aPrefix2<<"pass"<<endl<<endl;
1105 theStr<<aPrefix1<<"pass"<<endl<<endl;
1112 if(Mesh_i* aServant = dynamic_cast<Mesh_i*>(GetServant(anObj).in())){
1113 VISU::Entity anEntity = aServant->GetEntity();
1114 const std::string& aSubMeshName = aServant->GetSubMeshName();
1119 aParam = "VISU.NODE";
1122 aParam = "VISU.EDGE";
1125 aParam = "VISU.FACE";
1128 aParam = "VISU.CELL";
1132 if(aSubMeshName == "")
1133 theStr<<thePrefix<<aName<<" = aVisu.MeshOnEntity("<<theArgumentName<<
1134 ", '"<<aServant->GetCMeshName()<<"'"<<
1138 theStr<<thePrefix<<aName<<" = aVisu.FamilyMeshOnEntity("<<theArgumentName<<
1139 ", '"<<aServant->GetCMeshName()<<"'"<<
1141 ", '"<<aSubMeshName<<"'"<<
1144 theStr<<thePrefix<<aName<<" = aVisu.GroupMesh("<<theArgumentName<<
1145 ", '"<<aServant->GetCMeshName()<<"'"<<
1146 ", '"<<aSubMeshName<<"'"<<
1149 theStr<<thePrefix<<"if "<<aName<<":"<<endl;
1150 thePrefix += PREFIX;
1152 // Add to Name->Object map
1153 theStr<<thePrefix<<"aName2ObjectMap['"<<aName<<"'] = "<<aName<<endl;
1155 // Set name (as this object could be renamed by user)
1156 theStr<<thePrefix<<"visu.SetName("<<aName<<", '"<<aNameInStudy.in()<<"')"<<endl;
1158 // Set parameters common for all Prs3d objects (offset values)
1159 Prs3dToPython(aServant,theStr,aName,thePrefix);
1161 // Set presentation parameters
1162 SALOMEDS::Color aColor;
1163 aColor = aServant->GetCellColor();
1164 theStr<<thePrefix<<aName<<".SetCellColor(SALOMEDS.Color("<<
1165 aColor.R<<", "<<aColor.G<<", "<<aColor.B<<"))"<<endl;
1167 aColor = aServant->GetNodeColor();
1168 theStr<<thePrefix<<aName<<".SetNodeColor(SALOMEDS.Color("<<
1169 aColor.R<<", "<<aColor.G<<", "<<aColor.B<<"))"<<endl;
1171 aColor = aServant->GetLinkColor();
1172 theStr<<thePrefix<<aName<<".SetLinkColor(SALOMEDS.Color("<<
1173 aColor.R<<", "<<aColor.G<<", "<<aColor.B<<"))"<<endl;
1176 switch(aServant->GetPresentationType()){
1178 aParam = "VISU.POINT";
1181 aParam = "VISU.WIREFRAME";
1184 aParam = "VISU.SHADED";
1187 aParam = "VISU.INSIDEFRAME";
1190 aParam = "VISU.SURFACEFRAME";
1193 aParam = "VISU.SHRINK";
1196 theStr<<thePrefix<<aName<<".SetPresentationType("<<aParam<<")"<<endl;
1197 theStr<<thePrefix<<endl;
1199 DumpChildrenToPython(theStudy,
1209 theStr<<thePrefix<<"pass"<<endl<<endl;
1213 case VISU::TSCALARMAP:
1214 if(ScalarMap_i* aServant = dynamic_cast<ScalarMap_i*>(GetServant(anObj).in())){
1215 TCreateFromResult aPrsFactory(theSObject, aServant, aName, "ScalarMapOnField", theArgumentName);
1216 thePrefix = ScalarMapToPython(theSObject, aServant, theStr,aName, aPrsFactory, thePrefix);
1217 theStr<<thePrefix<<"pass"<<endl<<endl;
1220 case VISU::TDEFORMEDSHAPE:
1221 if(DeformedShape_i* aServant = dynamic_cast<DeformedShape_i*>(GetServant(anObj).in())){
1222 TCreateFromResult aPrsFactory(theSObject, aServant, aName, "DeformedShapeOnField", theArgumentName);
1223 thePrefix = DeformedShapeToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
1224 theStr<<thePrefix<<"pass"<<endl<<endl;
1227 case VISU::TSTREAMLINES:
1228 if(StreamLines_i* aServant = dynamic_cast<StreamLines_i*>(GetServant(anObj).in())){
1229 TCreateFromResult aPrsFactory(theSObject, aServant, aName, "StreamLinesOnField", theArgumentName);
1230 thePrefix = StreamLinesToPython(theSObject, aServant, theStr, theEntry2NameMap, aName, aPrsFactory, thePrefix);
1231 theStr<<thePrefix<<"pass"<<endl<<endl;
1234 case VISU::TSCALARMAPONDEFORMEDSHAPE:
1235 if(ScalarMapOnDeformedShape_i* aServant = dynamic_cast<ScalarMapOnDeformedShape_i*>(GetServant(anObj).in())){
1236 TCreateFromResult aPrsFactory(theSObject, aServant, aName, "ScalarMapOnDeformedShapeOnField", theArgumentName);
1237 thePrefix = ScalarMapOnDeformedShapeToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
1238 theStr<<thePrefix<<"pass"<<endl<<endl;
1241 case VISU::TVECTORS:
1242 if(Vectors_i* aServant = dynamic_cast<Vectors_i*>(GetServant(anObj).in())){
1243 TCreateFromResult aPrsFactory(theSObject, aServant, aName, "VectorsOnField", theArgumentName);
1244 thePrefix = VectorsToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
1245 theStr<<thePrefix<<"pass"<<endl<<endl;
1248 case VISU::TISOSURFACES:
1249 if(IsoSurfaces_i* aServant = dynamic_cast<IsoSurfaces_i*>(GetServant(anObj).in())){
1250 TCreateFromResult aPrsFactory(theSObject, aServant, aName, "IsoSurfacesOnField", theArgumentName);
1251 thePrefix = IsoSurfacesToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
1252 theStr<<thePrefix<<"pass"<<endl<<endl;
1255 case VISU::TCUTPLANES:
1256 if(CutPlanes_i* aServant = dynamic_cast<CutPlanes_i*>(GetServant(anObj).in())){
1257 TCreateFromResult aPrsFactory(theSObject, aServant, aName, "CutPlanesOnField", theArgumentName);
1258 thePrefix = CutPlanesToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
1259 theStr<<thePrefix<<"pass"<<endl<<endl;
1262 case VISU::TCUTLINES:
1263 if(CutLines_i* aServant = dynamic_cast<CutLines_i*>(GetServant(anObj).in())){
1264 TCreateFromResult aPrsFactory(theSObject, aServant, aName, "CutLinesOnField", theArgumentName);
1265 thePrefix = CutLinesToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
1267 theArgumentName = aName;
1268 DumpChildrenToPython(theStudy,
1278 theStr<<thePrefix<<"pass"<<endl<<endl;
1282 if (Plot3D_i* aServant = dynamic_cast<Plot3D_i*>(GetServant(anObj).in())) {
1283 TCreateFromResult aPrsFactory(theSObject, aServant, aName, "Plot3DOnField", theArgumentName);
1284 thePrefix = Plot3DToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
1285 theStr<<thePrefix<<"pass"<<endl<<endl;
1288 case VISU::TGAUSSPOINTS:
1289 if(GaussPoints_i* aServant = dynamic_cast<GaussPoints_i*>(GetServant(anObj).in())){
1290 TCreateFromResult aPrsFactory(theSObject, aServant, aName, "GaussPointsOnField", theArgumentName);
1291 thePrefix = GaussPointsToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix);
1292 theStr<<thePrefix<<"pass"<<endl<<endl;
1296 if(Curve_i* aServant = dynamic_cast<Curve_i*>(GetServant(anObj).in()))
1298 bool withZ = aServant->GetZRow()>0;
1300 theStr << thePrefix << "aName2ObjectMap['" << aName << "'] = visu.CreateCurve";
1304 theArgumentName<< // table
1305 ", "<<aServant->GetHRow()<< // H row
1306 ", "<<aServant->GetVRow(); // V row
1308 theStr << ", " << aServant->GetZRow(); // Z row
1310 theStr << ", '"<<aServant->GetTitle()<<"'"; // title
1311 SALOMEDS::Color aColor = aServant->GetColor();
1312 theStr << ",SALOMEDS.Color("<<
1313 aColor.R<<", "<<aColor.G<<", "<<aColor.B<<")"; // color
1316 switch(aServant->GetMarker()){
1317 case Curve::NONE: aParam = "VISU.Curve.NONE"; break;
1318 case Curve::CIRCLE: aParam = "VISU.Curve.CIRCLE"; break;
1319 case Curve::RECTANGLE: aParam = "VISU.Curve.RECTANGLE"; break;
1320 case Curve::DIAMOND: aParam = "VISU.Curve.DIAMOND"; break;
1321 case Curve::DTRIANGLE: aParam = "VISU.Curve.DTRIANGLE"; break;
1322 case Curve::UTRIANGLE: aParam = "VISU.Curve.UTRIANGLE"; break;
1323 case Curve::LTRIANGLE: aParam = "VISU.Curve.LTRIANGLE"; break;
1324 case Curve::RTRIANGLE: aParam = "VISU.Curve.RTRIANGLE"; break;
1325 case Curve::CROSS: aParam = "VISU.Curve.CROSS"; break;
1326 case Curve::XCROSS: aParam = "VISU.Curve.XCROSS"; break;
1328 theStr<<", "<<aParam; // marker
1330 switch(aServant->GetLine()){
1331 case Curve::VOIDLINE: aParam = "VISU.Curve.VOIDLINE"; break;
1332 case Curve::SOLIDLINE: aParam = "VISU.Curve.SOLIDLINE"; break;
1333 case Curve::DASHLINE: aParam = "VISU.Curve.DASHLINE"; break;
1334 case Curve::DOTLINE: aParam = "VISU.Curve.DOTLINE"; break;
1335 case Curve::DASHDOTLINE: aParam = "VISU.Curve.DASHDOTLINE"; break;
1336 case Curve::DASHDOTDOTLINE: aParam = "VISU.Curve.DASHDOTDOTLINE"; break;
1338 theStr<<", "<<aParam<<", "<<aServant->GetLineWidth()<<")"<<endl; // line type,width
1342 if(dynamic_cast<Table_i*>(GetServant(anObj).in())){
1343 SALOMEDS::GenericAttribute_var anAttr;
1344 if(theSObject->FindAttribute(anAttr,"AttributeString")){
1345 using namespace SALOMEDS;
1346 AttributeString_var aComment = AttributeString::_narrow(anAttr);
1347 CORBA::String_var aValue = aComment->Value();
1348 Storable::TRestoringMap aMap;
1349 Storable::StringToMap(aValue.in(),aMap);
1351 QString aSourceId = VISU::Storable::FindValue(aMap,"mySourceId",&anIsExist);
1353 if(strcmp(aSourceId.latin1(),"CutLines") == 0){
1354 theStr<<thePrefix<<"if aName2ObjectMap.has_key('"<<theArgumentName<<"'):"<<endl;
1355 thePrefix += PREFIX;
1357 theStr<<thePrefix<<"anObject = aName2ObjectMap['"<<theArgumentName<<"']"<<endl;
1358 theStr<<thePrefix<<"anIOR = anObject.GetID()"<<endl;
1359 theStr<<thePrefix<<"aSObject = theStudy.FindObjectIOR(anIOR)"<<endl;
1360 theStr<<thePrefix<<"if aSObject:"<<endl;
1361 std::string aPrefix = thePrefix;
1362 thePrefix += PREFIX;
1364 theStr<<thePrefix<<"anID = aSObject.GetID()"<<endl;
1365 theStr<<thePrefix<<aName<<" = aVisu.CreateTable(anID)"<<endl;
1367 // Set name (as this object could be renamed by user)
1368 theStr<<thePrefix<<aName<<".SetTitle('"<<aNameInStudy.in()<<"') # 2"<<endl;
1370 theStr<<thePrefix<<endl;
1372 theArgumentName = aName;
1373 DumpChildrenToPython(theStudy,
1383 theStr<<thePrefix<<"pass"<<endl<<endl;
1384 theStr<<aPrefix<<"pass"<<endl<<endl;
1385 }else if(strcmp(aSourceId.latin1(),"TableFile") == 0){
1386 CORBA::Short aTag = theSObject->Tag();
1387 theStr<<thePrefix<<"anIsFound, aSObject = "<<theArgumentName<<".FindSubObject("<<aTag<<")"<<endl;
1388 theStr<<thePrefix<<"if anIsFound:"<<endl;
1389 thePrefix += PREFIX;
1391 theStr<<thePrefix<<"anID = aSObject.GetID()"<<endl;
1392 theStr<<thePrefix<<aName<<" = aVisu.CreateTable(anID)"<<endl;
1394 // Set name (as this object could be renamed by user)
1395 theStr<<thePrefix<<aName<<".SetTitle('"<<aNameInStudy.in()<<"') # 3"<<endl;
1397 theStr<<thePrefix<<endl;
1399 theArgumentName = aName;
1400 DumpChildrenToPython(theStudy,
1410 theStr<<thePrefix<<"pass"<<endl<<endl;
1411 }else if(strcmp(aSourceId.latin1(),"TableAttr") == 0){
1412 theArgumentName = aName;
1413 DumpTableAttrToPython(theStudy,
1429 } else { /*if(!CORBA::is_nil(anObj))*/
1430 SALOMEDS::GenericAttribute_var anAttr;
1431 if (theSObject->FindAttribute(anAttr,"AttributeString")) {
1432 SALOMEDS::AttributeString_var aComment =
1433 SALOMEDS::AttributeString::_narrow(anAttr);
1434 CORBA::String_var aValue = aComment->Value();
1435 Storable::TRestoringMap aMap;
1436 Storable::StringToMap(aValue.in(),aMap);
1438 QString aTypeName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist);
1440 if (strcmp(aTypeName.latin1(),"ImportTables") == 0) {
1441 QString aFileName = VISU::Storable::FindValue(aMap,"myFileName",&anIsExist);
1443 std::string aName = GenerateName(theSObject,theName2EntryMap,theEntry2NameMap);
1444 theStr<<thePrefix<<aName<<" = aVisu.ImportTables('"<<aFileName.latin1()<<"')"<<endl;
1445 theStr<<thePrefix<<"if "<<aName<<":"<<endl;
1446 thePrefix += PREFIX;
1448 theArgumentName = aName;
1449 DumpChildrenToPython(theStudy,
1459 theStr<<thePrefix<<"pass"<<endl<<endl;
1462 } else if (strcmp(aTypeName.latin1(),"VIEW3D") == 0) {
1463 std::string aName = GetName(theSObject);
1464 theStr<<thePrefix<<aName<<" = aBuilder.NewObject(aSComponent)"<<endl;
1466 theStr<<thePrefix<<"if "<<aName<<":"<<endl;
1467 thePrefix += PREFIX;
1469 theStr<<thePrefix<<"anAttr = aBuilder.FindOrCreateAttribute("<<aName<<",'AttributeName')"<<endl;
1470 theStr<<thePrefix<<"anAttr.SetValue('"<<aName<<"')"<<endl;
1472 theStr<<thePrefix<<"anAttr = aBuilder.FindOrCreateAttribute("<<aName<<",'AttributeString')"<<endl;
1473 theStr<<thePrefix<<"anAttr.SetValue('"<<aValue.in()<<"')"<<endl;
1475 theStr<<thePrefix<<"pass"<<endl<<endl;
1477 } else if (aTypeName == "ENTITY" || aTypeName == "FAMILY" || aTypeName == "GROUP") {
1478 // Set name (as this object could be renamed by user)
1479 string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1();
1480 string aSubMeshName = VISU::Storable::FindValue(aMap,"myName").latin1();
1481 string anEntityTypeKey = "myEntityId";
1482 if (aTypeName == "ENTITY") anEntityTypeKey = "myId";
1483 int anEntity = VISU::Storable::FindValue(aMap,anEntityTypeKey,"0").toInt();
1484 std::string anEntityType;
1485 switch ((TEntity)anEntity) {
1486 case NODE_ENTITY: anEntityType = "VISU.NODE"; break;
1487 case EDGE_ENTITY: anEntityType = "VISU.EDGE"; break;
1488 case FACE_ENTITY: anEntityType = "VISU.FACE"; break;
1489 case CELL_ENTITY: anEntityType = "VISU.CELL"; break;
1492 if (aTypeName == "ENTITY" ) {
1493 theStr<<thePrefix<<"aVisu.RenameEntityInStudy("<<theArgumentName<<", '"<<aMeshName
1494 <<"', "<<anEntityType<<", '"<<aNameInStudy.in()<<"')"<<endl;
1496 else if (aTypeName == "FAMILY") {
1497 if (aSubMeshName != aNameInStudy.in()) {
1498 theStr<<thePrefix<<"aVisu.RenameFamilyInStudy("<<theArgumentName<<", '"<<aMeshName
1499 <<"', "<<anEntityType<<", '"<<aSubMeshName<<"', '"<<aNameInStudy.in()<<"')"<<endl;
1503 if (aSubMeshName != aNameInStudy.in()) {
1504 theStr<<thePrefix<<"aVisu.RenameGroupInStudy("<<theArgumentName<<", '"<<aMeshName
1505 <<"', '"<<aSubMeshName<<"', '"<<aNameInStudy.in()<<"')"<<endl;
1511 DumpTableAttrToPython(theStudy,
1523 DumpChildrenToPython(theStudy,
1535 //---------------------------------------------------------------------------
1537 DumpCurveToPython(SALOMEDS::Study_ptr theStudy,
1538 CORBA::Boolean theIsPublished,
1539 CORBA::Boolean& theIsValidScript,
1540 SALOMEDS::SObject_ptr theSObject,
1541 std::ostream& theStr,
1542 TName2EntryMap& theName2EntryMap,
1543 TEntry2NameMap& theEntry2NameMap,
1544 std::string theArgumentName,
1545 std::string thePrefix)
1547 SALOMEDS::SObject_var aTargetRefSObj;
1548 if(theSObject->ReferencedObject(aTargetRefSObj)){
1549 CORBA::Object_var anObj = SObjectToObject(aTargetRefSObj);
1550 if(CORBA::is_nil(anObj))
1553 VISU::Base_var aBase = VISU::Base::_narrow(anObj);
1554 if(CORBA::is_nil(aBase))
1557 if(aBase->GetType() == VISU::TCURVE){
1558 CORBA::String_var anID = aTargetRefSObj->GetID();
1559 std::string anArg = theEntry2NameMap[anID.in()];
1560 theStr<<thePrefix<<"if aName2ObjectMap.has_key('"<<anArg<<"'):"<<endl;
1561 thePrefix += PREFIX;
1562 theStr<<thePrefix<<"anObject = aName2ObjectMap['"<<anArg<<"']"<<endl;
1563 theStr<<thePrefix<<"if anObject: " <<theArgumentName<<".AddCurve(anObject)"<<endl;
1564 theStr<<thePrefix<<"pass"<<endl<<endl;
1570 //---------------------------------------------------------------------------
1572 DumpContainersToPython(SALOMEDS::Study_ptr theStudy,
1573 CORBA::Boolean theIsPublished,
1574 CORBA::Boolean& theIsValidScript,
1575 SALOMEDS::SObject_ptr theSObject,
1576 std::ostream& theStr,
1577 TName2EntryMap& theName2EntryMap,
1578 TEntry2NameMap& theEntry2NameMap,
1579 std::string theArgumentName,
1580 std::string thePrefix)
1582 SALOMEDS::ChildIterator_var aChildItet = theStudy->NewChildIterator(theSObject);
1583 for(aChildItet->InitEx(false); aChildItet->More(); aChildItet->Next()){
1584 SALOMEDS::SObject_var aSObject = aChildItet->Value();
1585 CORBA::Object_var anObj = SObjectToObject(aSObject);
1586 if(CORBA::is_nil(anObj))
1589 VISU::Base_var aBase = VISU::Base::_narrow(anObj);
1590 if(CORBA::is_nil(aBase))
1593 if(aBase->GetType() == VISU::TCONTAINER){
1594 theStr<<thePrefix<<endl;
1595 std::string aName = GenerateName(aSObject,theName2EntryMap,theEntry2NameMap);
1596 theStr<<thePrefix<<aName<<" = aVisu.CreateContainer()"<<endl;
1597 theStr<<thePrefix<<"if "<<aName<<":"<<endl;
1598 std::string aPrefix = thePrefix + PREFIX;
1599 theArgumentName = aName;
1601 // Set name (as this object could be renamed by user)
1602 CORBA::String_var aNameInStudy = aSObject->GetName();
1603 theStr<<aPrefix<<"visu.SetName("<<aName<<", '"<<aNameInStudy.in()<<"')"<<endl;
1605 SALOMEDS::ChildIterator_var aCurveIter = theStudy->NewChildIterator(aSObject);
1606 for(aCurveIter->InitEx(false); aCurveIter->More(); aCurveIter->Next()){
1607 SALOMEDS::SObject_var aRefSObj = aCurveIter->Value();
1608 DumpCurveToPython(theStudy,theIsPublished,theIsValidScript,aRefSObj,theStr,theName2EntryMap,theEntry2NameMap,theArgumentName,aPrefix);
1611 theStr<<aPrefix<<"pass"<<endl<<endl;
1617 //---------------------------------------------------------------------------
1619 DumpPrs3dCacheToPython(SALOMEDS::Study_ptr theStudy,
1620 CORBA::Boolean theIsPublished,
1621 CORBA::Boolean& theIsValidScript,
1622 SALOMEDS::SObject_ptr theSObject,
1623 std::ostream& theStr,
1624 TName2EntryMap& theName2EntryMap,
1625 TEntry2NameMap& theEntry2NameMap,
1626 std::string theArgumentName,
1627 std::string thePrefix)
1630 SALOMEDS::ChildIterator_var anIter = theStudy->NewChildIterator(theSObject);
1631 for(anIter->InitEx(false); anIter->More(); anIter->Next()){
1632 SALOMEDS::SObject_var aSObject = anIter->Value();
1633 CORBA::Object_var anObj = SObjectToObject(aSObject);
1634 if(CORBA::is_nil(anObj))
1637 VISU::Base_var aBase = VISU::Base::_narrow(anObj);
1638 if(CORBA::is_nil(aBase))
1641 if(aBase->GetType() == VISU::TCOLOREDPRS3DCACHE){
1642 ColoredPrs3dCache_i* aCache = dynamic_cast<ColoredPrs3dCache_i*>(GetServant(aBase).in());
1643 theStr<<thePrefix<<"aCache = aVisu.GetColoredPrs3dCache(aVisu.GetCurrentStudy())"<<endl;
1644 theStr<<thePrefix<<"if aCache != None:"<<endl;
1646 std::string aPrefix = thePrefix + PREFIX;
1647 std::string anArgument;
1648 VISU::ColoredPrs3dCache::MemoryMode aMode = aCache->GetMemoryMode();
1650 case VISU::ColoredPrs3dCache::MINIMAL : anArgument = "VISU.ColoredPrs3dCache.MINIMAL"; break;
1651 case VISU::ColoredPrs3dCache::LIMITED : anArgument = "VISU.ColoredPrs3dCache.LIMITED"; break;
1653 theStr<<aPrefix<<"aCache.SetMemoryMode("<<anArgument<<")"<<endl;
1655 if(aMode == VISU::ColoredPrs3dCache::LIMITED)
1656 theStr<<aPrefix<<"aCache.SetLimitedMemory("<<aCache->GetLimitedMemory()<<") # (Mb)"<<endl;
1658 SALOMEDS::ChildIterator_var aChildIter = theStudy->NewChildIterator(aSObject);
1659 for(aChildIter->InitEx(false); aChildIter->More(); aChildIter->Next()){
1660 SALOMEDS::SObject_var aSObject = aChildIter->Value();
1661 CORBA::Object_var anObject = SObjectToObject(aSObject);
1662 if (CORBA::is_nil(anObject))
1665 ColoredPrs3dHolder_i* aServant = dynamic_cast<ColoredPrs3dHolder_i*>(GetServant(anObject).in());
1669 ColoredPrs3d_i* aDevice = aServant->GetPrs3dDevice();
1673 Result_i* aResult = aDevice->GetCResult();
1674 std::string aResultEntry = aResult->GetEntry();
1675 std::string aResultName = theEntry2NameMap[aResultEntry];
1677 ColoredPrs3dHolder::BasicInput_var anInput = aServant->GetBasicInput();
1678 std::string anEntity;
1679 switch(anInput->myEntity){
1680 case VISU::NODE : anEntity = "VISU.NODE"; break;
1681 case VISU::EDGE : anEntity = "VISU.EDGE"; break;
1682 case VISU::FACE : anEntity = "VISU.FACE"; break;
1683 case VISU::CELL : anEntity = "VISU.CELL"; break;
1687 theStr<<aPrefix<<"anInput = VISU.ColoredPrs3dHolder.BasicInput("<<
1688 aResultName<<", '"<<
1689 anInput->myMeshName<<"', "<<
1691 anInput->myFieldName<<"', "<<
1692 anInput->myTimeStampNumber<<")"<<
1695 std::string aComment = aDevice->GetComment();
1696 theStr<<aPrefix<<"aHolder = aCache.CreateHolder(VISU.T"<<aComment<<", anInput)"<<endl;
1697 theStr<<aPrefix<<"if aHolder != None:"<<endl;
1699 std::string aPrefix2 = aPrefix + PREFIX;
1700 CORBA::String_var aNameInStudy = aSObject->GetName();
1701 theStr<<aPrefix2<<"visu.SetName(aHolder, '"<<aNameInStudy.in()<<"')"<<endl;
1702 theStr<<aPrefix2<<"aDevice = aHolder.GetDevice()"<<endl;
1703 theStr<<aPrefix2<<"if aDevice != None:"<<endl;
1705 std::string aPrefix3 = aPrefix2 + PREFIX;
1706 TColoredPrs3dFactory aPrsFactory;
1707 switch(aDevice->GetType()){
1708 case VISU::TSCALARMAP:
1709 if(ScalarMap_i* aServant = dynamic_cast<ScalarMap_i*>(aDevice)){
1710 ScalarMapToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
1713 case VISU::TDEFORMEDSHAPE:
1714 if(DeformedShape_i* aServant = dynamic_cast<DeformedShape_i*>(aDevice)){
1715 DeformedShapeToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
1718 case VISU::TSTREAMLINES:
1719 if(StreamLines_i* aServant = dynamic_cast<StreamLines_i*>(aDevice)){
1720 StreamLinesToPython(aSObject, aServant, theStr, theEntry2NameMap, "aDevice", aPrsFactory, aPrefix3);
1723 case VISU::TSCALARMAPONDEFORMEDSHAPE:
1724 if(ScalarMapOnDeformedShape_i* aServant = dynamic_cast<ScalarMapOnDeformedShape_i*>(aDevice)){
1725 ScalarMapOnDeformedShapeToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
1728 case VISU::TVECTORS:
1729 if(Vectors_i* aServant = dynamic_cast<Vectors_i*>(aDevice)){
1730 VectorsToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
1733 case VISU::TISOSURFACES:
1734 if(IsoSurfaces_i* aServant = dynamic_cast<IsoSurfaces_i*>(aDevice)){
1735 IsoSurfacesToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
1738 case VISU::TCUTPLANES:
1739 if(CutPlanes_i* aServant = dynamic_cast<CutPlanes_i*>(aDevice)){
1740 CutPlanesToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
1743 case VISU::TCUTLINES:
1744 if(CutLines_i* aServant = dynamic_cast<CutLines_i*>(aDevice)){
1745 CutLinesToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
1749 if(Plot3D_i* aServant = dynamic_cast<Plot3D_i*>(aDevice)){
1750 Plot3DToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
1753 case VISU::TGAUSSPOINTS:
1754 if(GaussPoints_i* aServant = dynamic_cast<GaussPoints_i*>(aDevice)){
1755 GaussPointsToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3);
1759 theStr<<aPrefix3<<"pass"<<endl;
1761 theStr<<aPrefix2<<"pass"<<endl<<endl;
1764 theStr<<aPrefix<<"pass"<<endl;
1771 //---------------------------------------------------------------------------
1773 DumpAnimationsToPython(SALOMEDS::Study_ptr theStudy,
1774 CORBA::Boolean theIsPublished,
1775 CORBA::Boolean& theIsValidScript,
1776 SALOMEDS::SObject_ptr theSObject,
1777 std::ostream& theStr,
1778 std::string thePrefix)
1781 if(!theIsPublished) return;
1783 SALOMEDS::ChildIterator_var aChildItet = theStudy->NewChildIterator(theSObject);
1784 for(aChildItet->InitEx(false); aChildItet->More(); aChildItet->Next()){
1785 SALOMEDS::SObject_var aSObject = aChildItet->Value();
1787 SALOMEDS::GenericAttribute_var anAttr;
1788 if (!aSObject->FindAttribute(anAttr, "AttributeString")) continue;
1790 SALOMEDS::AttributeString_var aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr);
1791 QString value (aStringAttr->Value());
1792 if(value.isEmpty()) continue;
1794 VISU::Storable::TRestoringMap aMap;
1795 VISU::Storable::StringToMap(value, aMap);
1798 QString aTypeName = VISU::Storable::FindValue(aMap,"myComment",&isExist);
1799 if(!isExist || aTypeName != "ANIMATION") continue;
1802 theStr<<thePrefix<<endl;
1803 QString animName = aSObject->GetName();
1804 theStr<<thePrefix<<"#Animation: "<<animName<<endl;
1805 theStr<<thePrefix<<endl;
1806 theStr<<thePrefix<<"animSO = aBuilder.NewObject(aSComponent)"<<endl;
1807 theStr<<thePrefix<<"aBuilder.SetName(animSO, '"<<animName<<"')"<< endl;
1808 theStr<<thePrefix<<"strAttr = aBuilder.FindOrCreateAttribute(animSO, 'AttributeString')"<< endl;
1809 theStr<<thePrefix<<"strAttr.SetValue('"<<value<<"')"<< endl;
1813 SALOMEDS::ChildIterator_var anIter = theStudy->NewChildIterator(aSObject);
1814 for (anIter->Init(); anIter->More(); anIter->Next()) {
1815 SALOMEDS::SObject_var anObj = anIter->Value();
1818 theStr<<thePrefix<<"fieldSO = aBuilder.NewObject(animSO)"<<endl;
1819 if (anObj->FindAttribute(anAttr, "AttributeString")) {
1820 aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr);
1821 theStr<<thePrefix<<"strAttr = aBuilder.FindOrCreateAttribute(fieldSO, 'AttributeString')"<< endl;
1822 theStr<<thePrefix<<"strAttr.SetValue('"<<aStringAttr->Value()<<"')"<< endl;
1825 SALOMEDS::SObject_var refObj;
1826 if(anObj->ReferencedObject(refObj)) {
1827 SALOMEDS::SObject_var father = refObj->GetFather();
1828 value = refObj->GetName();
1829 QString path(theStudy->GetObjectPath(father));
1830 //The following code requierd as a field name can contain '/' character
1831 theStr<<thePrefix<<"aBuilder.Addreference(fieldSO,getSObjectByFatherPathAndName(theStudy, '"<<path<<"', '"<<value<<"'))"<<endl;
1833 value = anObj->GetName();
1834 if(!value.isEmpty()) theStr<<thePrefix<<"aBuilder.SetName(fieldSO, '"<<value<<"')"<< endl;
1837 SALOMEDS::ChildIterator_var aSubIter = theStudy->NewChildIterator(anObj);
1838 for (aSubIter->Init(); aSubIter->More(); aSubIter->Next()) {
1839 SALOMEDS::SObject_var aSubObj = aSubIter->Value();
1841 theStr<<thePrefix<<"subSO = aBuilder.NewObject(fieldSO)"<<endl;
1842 value = aSubObj->GetName();
1843 if(!value.isEmpty()) theStr<<thePrefix<<"aBuilder.SetName(subSO, '"<<value<<"')"<< endl;
1844 if (aSubObj->FindAttribute(anAttr, "AttributeString")) {
1845 aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr);
1846 theStr<<thePrefix<<"strAttr = aBuilder.FindOrCreateAttribute(subSO, 'AttributeString')"<< endl;
1847 theStr<<thePrefix<<"strAttr.SetValue('"<<aStringAttr->Value()<<"')"<< endl;
1855 theStr<<thePrefix<<endl;
1858 //---------------------------------------------------------------------------
1861 DumpPython(CORBA::Object_ptr theStudy,
1862 CORBA::Boolean theIsPublished,
1863 CORBA::Boolean& theIsValidScript)
1865 theIsValidScript = false;
1867 SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy);
1868 if(CORBA::is_nil(aStudy))
1869 return new Engines::TMPFile(0);
1871 TName2EntryMap aName2EntryMap;
1872 TEntry2NameMap aEntry2NameMap;
1880 std::string aPrefix(PREFIX);
1881 aStr<<"### This file is generated by SALOME automatically by dump python functionality"
1882 " of VISU component"<<endl<<endl;
1883 aStr<<"def RebuildData(theStudy):"<<endl;
1884 aStr<<aPrefix<<"from batchmode_salome import orb, naming_service, lcc, myStudyManager"<<endl;
1885 aStr<<aPrefix<<"import SALOME_MED"<<endl;
1886 aStr<<aPrefix<<"import SALOMEDS"<<endl;
1887 aStr<<aPrefix<<"import VISU"<<endl;
1888 aStr<<aPrefix<<"import visu"<<endl;
1890 aStr<<aPrefix<<"aVisu = visu.Initialize(orb,naming_service,lcc,myStudyManager,theStudy,0)"<<endl;
1891 aStr<<aPrefix<<"aSComponent = visu.PublishComponent(theStudy)"<<endl;
1892 aStr<<aPrefix<<"aMed = lcc.FindOrLoadComponent('FactoryServer','MED')"<<endl;
1893 aStr<<aPrefix<<"aBuilder = theStudy.NewBuilder()"<<endl;
1894 aStr<<aPrefix<<"aName2ObjectMap = {}"<<endl;
1897 SALOMEDS::SComponent_var aComponent = FindOrCreateVisuComponent(aStudy);
1898 VISU::DumpChildrenToPython(aStudy,
1908 VISU::DumpContainersToPython(aStudy,
1918 VISU::DumpPrs3dCacheToPython(aStudy,
1928 VISU::DumpAnimationsToPython(aStudy,
1935 //Output the script that sets up the visul parameters.
1936 if(theIsPublished) {
1937 char* script = aStudy->GetDefaultScript("Post-Pro", aPrefix.c_str());
1938 if(script && strlen(script) > 0) {
1940 CORBA::string_free(script);
1944 aStr<<aPrefix<<"pass"<<endl;
1946 if(theIsPublished) { //SRN: define function for Animation
1948 //Define a function that find a SObject by its father's path and its name
1952 aStr<<"def getSObjectByFatherPathAndName(theStudy, thePath, theName):"<<endl;
1953 aStr<<aPrefix<<"father = theStudy.FindObjectByPath(thePath)"<<endl;
1954 aStr<<aPrefix<<"itr = theStudy.NewChildIterator(father)"<<endl;
1955 aStr<<aPrefix<<"while itr.More():"<<endl;
1956 aStr<<aPrefix<<aPrefix<<"so = itr.Value()"<<endl;
1957 aStr<<aPrefix<<aPrefix<<"if so.GetName()==theName: return so"<<endl;
1958 aStr<<aPrefix<<aPrefix<<"itr.Next()"<<endl;
1959 aStr<<aPrefix<<aPrefix<<"pass"<<endl;
1960 aStr<<aPrefix<<"return None"<<endl;
1965 // theIsValidScript currently is not used by internal dump methods (DumpChildrenToPython(), etc.)
1966 // If the situation changes, then the following line should be removed, and theIsValidScript
1967 // should be set properly by those internal methods
1968 theIsValidScript = true;
1971 std::string aResult = aStr.str();
1972 //ofstream anFStream("/tmp/dump.py");
1973 //anFStream<<aResult<<endl;
1975 CORBA::ULong aSize = aResult.size() + 1;
1976 char* aBuffer = new char[aSize];
1977 strcpy(aBuffer,&aResult[0]);
1978 return new Engines::TMPFile(aSize,aSize,(CORBA::Octet*)aBuffer,1);
1981 return new Engines::TMPFile(0);