X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOM_I%2FGEOM_DumpPython.cc;h=82f5f5d4459c4a96b815d0dec3429b15990e93e6;hb=f1fb1215e8923dd5651dee9b9547bb24db7e28d9;hp=0b714de688318cf5c391f69c039bcfabbce40556;hpb=fedf580aaa1cdbe35e069626879b922dc7fbb2ff;p=modules%2Fgeom.git diff --git a/src/GEOM_I/GEOM_DumpPython.cc b/src/GEOM_I/GEOM_DumpPython.cc index 0b714de68..82f5f5d44 100644 --- a/src/GEOM_I/GEOM_DumpPython.cc +++ b/src/GEOM_I/GEOM_DumpPython.cc @@ -1,11 +1,40 @@ -using namespace std; +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifdef WNT +#pragma warning( disable:4786 ) +#endif + +#include #include "GEOM_Gen_i.hh" + #include #include #include #include +#include +#include + //======================================================================= //function : DumpPython //purpose : @@ -25,6 +54,8 @@ Engines::TMPFile* GEOM_Gen_i::DumpPython(CORBA::Object_ptr theStudy, Resource_DataMapOfAsciiStringAsciiString aMap; + TVariablesList aVariableMap; + SALOMEDS::ChildIterator_var Itr = aStudy->NewChildIterator(aSO); for(Itr->InitEx(true); Itr->More(); Itr->Next()) { SALOMEDS::SObject_var aValue = Itr->Value(); @@ -36,14 +67,47 @@ Engines::TMPFile* GEOM_Gen_i::DumpPython(CORBA::Object_ptr theStudy, CORBA::String_var aName = aValue->GetName(); CORBA::String_var anEntry = GO->GetEntry(); aMap.Bind( (char*)anEntry.in(), (char*)aName.in() ); + + //Find attribute with list of used notebook variables + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeString_var anAttrStr; + if(aValue->FindAttribute(anAttr,"AttributeString")){ + anAttrStr = SALOMEDS::AttributeString::_narrow(anAttr); + SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(anAttrStr->Value()); + ObjectStates* aStates = new ObjectStates(); + for(int i = 0; i < aSections->length(); i++) { + TState aState; + SALOMEDS::ListOfStrings aListOfVars = aSections[i]; + for(int j = 0; j < aListOfVars.length(); j++) { + bool isVar = aStudy->IsVariable(aListOfVars[j].in()); + TVariable aVar = TVariable( (char*)aListOfVars[j].in(), isVar ); + aState.push_back(aVar); + } + aStates->AddState(aState); + } + aVariableMap.insert(pair(TCollection_AsciiString(anEntry),aStates)); + } } } } - + TCollection_AsciiString aScript = - "### This file is generated by SALOME automatically by dump python funcitonality\n" + "### This file is generated by SALOME automatically by dump python functionality\n" "### of GEOM component\n\n"; - aScript += _impl->DumpPython(aStudy->StudyId(), aMap, isPublished, isValidScript); + aScript += _impl->DumpPython(aStudy->StudyId(), aMap, aVariableMap, isPublished, isValidScript); + + if (isPublished) + { + //Output the script that sets up the visual parameters. + char* script = aStudy->GetDefaultScript(ComponentDataType(), "\t"); + if (script && strlen(script) > 0) { + aScript += "\n\t### Store presentation parameters of displayed objects\n"; + aScript += script; + CORBA::string_free(script); + } + } + + aScript += "\n\tpass\n"; int aLen = aScript.Length(); unsigned char* aBuffer = new unsigned char[aLen+1];