// VISU OBJECT : interactive object for VISU entities implementation
//
// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
// File : VISU_DumpPython.cc
#include "VISU_CutLines_i.hh"
#include "VISU_Vectors_i.hh"
#include "VISU_StreamLines_i.hh"
+#include "VISU_Plot3D_i.hh"
#include "VISU_Table_i.hh"
#include "utilities.h"
-#include <cctype>
-#include <strstream>
-#include <functional>
+#include <cctype>
+#include <strstream>
+#include <functional>
#include <qstring.h>
#include <qfileinfo.h>
typedef std::map<std::string,std::string> TEntry2NameMap;
inline
- std::string
- GenerateName(std::string theName,
+ std::string
+ GenerateName(std::string theName,
SALOMEDS::SObject_ptr theSObject,
TName2EntryMap& theName2EntryMap,
TEntry2NameMap& theEntry2NameMap,
};
inline
- std::string
+ std::string
GetName(SALOMEDS::SObject_ptr theSObject)
{
CORBA::String_var aString = theSObject->GetName();
}
inline
- std::string
+ std::string
GenerateName(SALOMEDS::SObject_ptr theSObject,
TName2EntryMap& theName2EntryMap,
TEntry2NameMap& theEntry2NameMap)
//===========================================================================
std::string
ScalarMapToPython(SALOMEDS::SObject_ptr theSObject,
- VISU::ScalarMap_i* theServant,
+ VISU::ScalarMap_i* theServant,
std::ostream& theStr,
std::string& theName,
const std::string& theConstructorName,
theStr<<thePrefix<<"aName2ObjectMap['"<<theName<<"'] = "<<theName<<endl;
theStr<<thePrefix<<theName<<".SetScalarMode("<<theServant->GetScalarMode()<<")"<<endl;
-
+
switch(theServant->GetScaling()){
case LINEAR:
aParam = "VISU.LINEAR";
}
theStr<<thePrefix<<theName<<".SetScaling("<<aParam<<")"<<endl;
theStr<<thePrefix<<theName<<".SetRange("<<theServant->GetMin()<<","<<theServant->GetMax()<<")"<<endl;
-
+
switch(theServant->GetBarOrientation()){
case ScalarMap::HORIZONTAL:
aParam = "VISU.ScalarMap.HORIZONTAL";
break;
}
theStr<<thePrefix<<theName<<".SetBarOrientation("<<aParam<<")"<<endl;
-
+
theStr<<thePrefix<<theName<<".SetPosition("<<theServant->GetPosX()<<","<<theServant->GetPosY()<<")"<<endl;
theStr<<thePrefix<<theName<<".SetSize("<<theServant->GetWidth()<<","<<theServant->GetHeight()<<")"<<endl;
theStr<<thePrefix<<theName<<".SetNbColors("<<theServant->GetNbColors()<<")"<<endl;
//===========================================================================
std::string
DeformedShapeToPython(SALOMEDS::SObject_ptr theSObject,
- VISU::DeformedShape_i* theServant,
+ VISU::DeformedShape_i* theServant,
std::ostream& theStr,
std::string& theName,
const std::string& theConstructorName,
return thePrefix;
}
-
+ //===========================================================================
+ // declaration
+ void DumpChildrenToPython(SALOMEDS::Study_ptr theStudy,
+ CORBA::Boolean theIsPublished,
+ CORBA::Boolean& theIsValidScript,
+ SALOMEDS::SObject_ptr theSObject,
+ std::ostream& theStr,
+ TName2EntryMap& theName2EntryMap,
+ TEntry2NameMap& theEntry2NameMap,
+ std::string theArgumentName,
+ std::string thePrefix);
+
//===========================================================================
template<class TTableAttr>
void
std::string theArgumentName,
std::string thePrefix)
{
- SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::SObject_var aFatherSObject = theSObject->GetFather();
if(aFatherSObject->FindAttribute(anAttr,"AttributeComment")){
- SALOMEDS::AttributeComment_var aComment =
+ SALOMEDS::AttributeComment_var aComment =
SALOMEDS::AttributeComment::_narrow(anAttr);
CORBA::String_var aValue = aComment->Value();
- Storable::TRestoringMap aMap;
+ Storable::TRestoringMap aMap;
Storable::StrToMap(aValue.in(),aMap);
bool anIsExist;
QString aMethodName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist);
theStr<<thePrefix<<"anID = "<<aSObjectName<<".GetID()"<<endl;
theStr<<thePrefix<<aName<<" = aVisu.CreateTable(anID)"<<endl;
theArgumentName = aName;
-
+
theStr<<thePrefix<<"if "<<aName<<":"<<endl;
std::string aPrefix2 = thePrefix + PREFIX;
{
SALOMEDS::GenericAttribute_var anAttr;
if(theSObject->FindAttribute(anAttr,"AttributeTableOfInteger")){
- SALOMEDS::AttributeTableOfInteger_var aTableAttr =
+ SALOMEDS::AttributeTableOfInteger_var aTableAttr =
SALOMEDS::AttributeTableOfInteger::_narrow(anAttr);
-
+
TableAttrToPython(theStudy,
theIsPublished,
theIsValidScript,
theEntry2NameMap,
theArgumentName,
thePrefix);
-
+
}else if(theSObject->FindAttribute(anAttr,"AttributeTableOfReal")){
- SALOMEDS::AttributeTableOfReal_var aTableAttr =
+ SALOMEDS::AttributeTableOfReal_var aTableAttr =
SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
-
+
TableAttrToPython(theStudy,
theIsPublished,
theIsValidScript,
case Result_i::eImportFile:
theStr<<thePrefix<<aName<<" = aVisu.ImportFile('"<<aFileName<<"')"<<endl;
break;
- case Result_i::eCopyAndImportFile:
+ case Result_i::eCopyAndImportFile:
theStr<<thePrefix<<aName<<" = aVisu.CopyAndImportFile('"<<aFileName<<"')"<<endl;
break;
}
theStr<<thePrefix<<"if "<<aName<<":"<<endl;
thePrefix += PREFIX;
-
+
theArgumentName = aName;
DumpChildrenToPython(theStudy,
theIsPublished,
theEntry2NameMap,
theArgumentName,
thePrefix);
-
+
theStr<<thePrefix<<"pass"<<endl<<endl;
}else{
SALOMEDS::SObject_var aRefSObj;
thePrefix += PREFIX;
switch(anId){
- case Result_i::eImportMed:
+ case Result_i::eImportMed:
theStr<<thePrefix<<aName<<" = aVisu.ImportMed(aSObject)"<<endl;
break;
case Result_i::eImportMedField:
theStr<<thePrefix<<"if "<<aName<<":"<<endl;
std::string aPrefix2 = thePrefix;
thePrefix += PREFIX;
-
+
theArgumentName = aName;
DumpChildrenToPython(theStudy,
theIsPublished,
theEntry2NameMap,
theArgumentName,
thePrefix);
-
+
theStr<<thePrefix<<"pass"<<endl<<endl;
theStr<<aPrefix2<<"pass"<<endl<<endl;
theStr<<aPrefix1<<"pass"<<endl<<endl;
aParam = "VISU.CELL";
break;
}
-
+
if(aSubMeshName == "")
theStr<<thePrefix<<aName<<" = aVisu.MeshOnEntity("<<theArgumentName<<
",'"<<aServant->GetMeshName()<<"'"<<
",'"<<aServant->GetMeshName()<<"'"<<
",'"<<aSubMeshName<<"'"<<
")"<<endl;
-
+
theStr<<thePrefix<<"if "<<aName<<":"<<endl;
thePrefix += PREFIX;
aColor = aServant->GetCellColor();
theStr<<thePrefix<<aName<<".SetCellColor(SALOMEDS.Color("<<
aColor.R<<","<<aColor.G<<","<<aColor.B<<"))"<<endl;
-
+
aColor = aServant->GetNodeColor();
theStr<<thePrefix<<aName<<".SetNodeColor(SALOMEDS.Color("<<
aColor.R<<","<<aColor.G<<","<<aColor.B<<"))"<<endl;
-
+
aColor = aServant->GetLinkColor();
theStr<<thePrefix<<aName<<".SetLinkColor(SALOMEDS.Color("<<
aColor.R<<","<<aColor.G<<","<<aColor.B<<"))"<<endl;
-
+
std::string aParam;
switch(aServant->GetPresentationType()){
case POINT:
theEntry2NameMap,
theArgumentName,
thePrefix);
-
+
theStr<<thePrefix<<"pass"<<endl<<endl;
return;
}
case VISU::TSTREAMLINES:
if(StreamLines_i* aServant = dynamic_cast<StreamLines_i*>(GetServant(anObj).in())){
thePrefix = DeformedShapeToPython(theSObject,aServant,theStr,aName,"StreamLinesOnField",theArgumentName,thePrefix);
-
+
std::string aParam;
switch(aServant->GetDirection()){
case StreamLines::FORWARD:
theStr<<thePrefix<<"aPrs3d = aName2ObjectMap['"<<anArg<<"']"<<endl;
}
}
-
+
theStr<<thePrefix<<aName<<".SetParams("<<
aServant->GetIntegrationStep()<<","<<
aServant->GetPropagationTime()<<","<<
case VISU::TVECTORS:
if(Vectors_i* aServant = dynamic_cast<Vectors_i*>(GetServant(anObj).in())){
thePrefix = DeformedShapeToPython(theSObject,aServant,theStr,aName,"VectorsOnField",theArgumentName,thePrefix);
-
+
theStr<<thePrefix<<aName<<".SetLineWidth("<<aServant->GetLineWidth()<<")"<<endl;
-
+
std::string aParam;
switch(aServant->GetGlyphType()){
case Vectors::ARROW:
break;
}
theStr<<thePrefix<<aName<<".SetGlyphType("<<aParam<<")"<<endl;
-
+
switch(aServant->GetGlyphPos()){
case Vectors::CENTER:
aParam = "VISU.Vectors.CENTER";
case VISU::TCUTPLANES:
if(CutPlanes_i* aServant = dynamic_cast<CutPlanes_i*>(GetServant(anObj).in())){
thePrefix = ScalarMapToPython(theSObject,aServant,theStr,aName,"CutPlanesOnField",theArgumentName,thePrefix);
-
+
std::string aParam;
switch(aServant->GetOrientationType()){
case CutPlanes::XY:
break;
}
theStr<<thePrefix<<aName<<".SetOrientation("<<aParam<<","<<aServant->GetRotateX()<<","<<aServant->GetRotateY()<<")"<<endl;
-
+
theStr<<thePrefix<<aName<<".SetDisplacement("<<aServant->GetDisplacement()<<")"<<endl;
CORBA::Long aNbPlanes = aServant->GetNbPlanes();
theStr<<thePrefix<<aName<<".SetNbPlanes("<<aNbPlanes<<")"<<endl;
-
+
for(CORBA::Long anId = 0; anId < aNbPlanes; anId++){
if(!aServant->IsDefault(anId))
theStr<<thePrefix<<aName<<".SetPlanePosition("<<anId<<","<<aServant->GetPlanePosition(anId)<<")"<<endl;
case VISU::TCUTLINES:
if(CutLines_i* aServant = dynamic_cast<CutLines_i*>(GetServant(anObj).in())){
thePrefix = ScalarMapToPython(theSObject,aServant,theStr,aName,"CutLinesOnField",theArgumentName,thePrefix);
-
+
std::string aParam;
switch(aServant->GetOrientationType()){
case CutPlanes::XY:
break;
}
theStr<<thePrefix<<aName<<".SetOrientation("<<aParam<<","<<aServant->GetRotateX()<<","<<aServant->GetRotateY()<<")"<<endl;
-
+
switch(aServant->GetOrientationType2()){
case CutPlanes::XY:
aParam = "VISU.CutPlanes.XY";
break;
}
theStr<<thePrefix<<aName<<".SetOrientation2("<<aParam<<","<<aServant->GetRotateX2()<<","<<aServant->GetRotateY2()<<")"<<endl;
-
+
theStr<<thePrefix<<aName<<".SetDisplacement("<<aServant->GetDisplacement()<<")"<<endl;
theStr<<thePrefix<<aName<<".SetDisplacement2("<<aServant->GetDisplacement2()<<")"<<endl;
-
+
if(!aServant->IsDefault())
theStr<<thePrefix<<aName<<".SetBasePlanePosition("<<aServant->GetBasePlanePosition()<<")"<<endl;
-
+
CORBA::Long aNbLines = aServant->GetNbLines();
theStr<<thePrefix<<aName<<".SetNbLines("<<aNbLines<<")"<<endl;
for(CORBA::Long anId = 0; anId < aNbLines; anId++){
theStr<<thePrefix<<"pass"<<endl<<endl;
}
return;
+ case VISU::TPLOT3D:
+ if (Plot3D_i* aServant = dynamic_cast<Plot3D_i*>(GetServant(anObj).in())) {
+ thePrefix = ScalarMapToPython(theSObject, aServant, theStr, aName,
+ "Plot3DOnField", theArgumentName, thePrefix);
+
+ std::string aParam;
+ switch(aServant->GetOrientationType()){
+ case CutPlanes::XY: aParam = "VISU.Plot3D.XY"; break;
+ case CutPlanes::YZ: aParam = "VISU.Plot3D.YZ"; break;
+ case CutPlanes::ZX: aParam = "VISU.Plot3D.ZX"; break;
+ }
+ theStr<<thePrefix<<aName<<".SetOrientation("<<aParam<<","<<aServant->GetRotateX()<<","<<aServant->GetRotateY()<<")"<<endl;
+
+ theStr<<thePrefix<<aName<<".SetPlanePosition("<<aServant->GetPlanePosition()<<","<<aServant->IsPositionRelative()<<")"<<endl;
+ theStr<<thePrefix<<aName<<".SetScaleFactor("<<aServant->GetScaleFactor()<<")"<<endl;
+ theStr<<thePrefix<<aName<<".SetContourPrs("<<aServant->GetIsContourPrs()<<")"<<endl;
+ theStr<<thePrefix<<aName<<".SetNbOfContours("<<aServant->GetNbOfContours()<<")"<<endl;
+ theStr<<thePrefix<<"pass"<<endl<<endl;
+ }
+ return;
case VISU::TCURVE:
if(Curve_i* aServant = dynamic_cast<Curve_i*>(GetServant(anObj).in()))
{
SALOMEDS::Color aColor = aServant->GetColor();
theStr << ",SALOMEDS.Color("<<
aColor.R<<","<<aColor.G<<","<<aColor.B<<")"; // color
-
+
std::string aParam;
switch(aServant->GetMarker()){
case Curve::NONE: aParam = "VISU.Curve.NONE"; break;
using namespace SALOMEDS;
AttributeComment_var aComment = AttributeComment::_narrow(anAttr);
CORBA::String_var aValue = aComment->Value();
- Storable::TRestoringMap aMap;
+ Storable::TRestoringMap aMap;
Storable::StrToMap(aValue.in(),aMap);
bool anIsExist;
QString aSourceId = VISU::Storable::FindValue(aMap,"mySourceId",&anIsExist);
theStr<<thePrefix<<"anID = aSObject.GetID()"<<endl;
theStr<<thePrefix<<aName<<" = aVisu.CreateTable(anID)"<<endl;
theStr<<endl;
-
+
theArgumentName = aName;
DumpChildrenToPython(theStudy,
theIsPublished,
theEntry2NameMap,
theArgumentName,
thePrefix);
-
+
theStr<<thePrefix<<"pass"<<endl<<endl;
theStr<<aPrefix<<"pass"<<endl<<endl;
}else if(strcmp(aSourceId.latin1(),"TableFile") == 0){
theStr<<thePrefix<<"anIsFound, aSObject = "<<theArgumentName<<".FindSubObject("<<aTag<<")"<<endl;
theStr<<thePrefix<<"if anIsFound:"<<endl;
thePrefix += PREFIX;
-
+
theStr<<thePrefix<<"anID = aSObject.GetID()"<<endl;
theStr<<thePrefix<<aName<<" = aVisu.CreateTable(anID)"<<endl;
theStr<<endl;
theEntry2NameMap,
theArgumentName,
thePrefix);
-
+
theStr<<thePrefix<<"pass"<<endl<<endl;
}else if(strcmp(aSourceId.latin1(),"TableAttr") == 0){
theArgumentName = aName;
}else{
SALOMEDS::GenericAttribute_var anAttr;
if(theSObject->FindAttribute(anAttr,"AttributeComment")){
- SALOMEDS::AttributeComment_var aComment =
+ SALOMEDS::AttributeComment_var aComment =
SALOMEDS::AttributeComment::_narrow(anAttr);
CORBA::String_var aValue = aComment->Value();
- Storable::TRestoringMap aMap;
+ Storable::TRestoringMap aMap;
Storable::StrToMap(aValue.in(),aMap);
bool anIsExist;
QString aTypeName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist);
theEntry2NameMap,
theArgumentName,
thePrefix);
-
+
theStr<<thePrefix<<"pass"<<endl<<endl;
return;
}
SALOMEDS::SObject_var aTargetRefSObj;
if(theSObject->ReferencedObject(aTargetRefSObj)){
CORBA::Object_var anObj = SObjectToObject(aTargetRefSObj);
- if(CORBA::is_nil(anObj))
+ if(CORBA::is_nil(anObj))
return;
-
+
VISU::Base_var aBase = VISU::Base::_narrow(anObj);
- if(CORBA::is_nil(aBase))
+ if(CORBA::is_nil(aBase))
return;
-
+
if(aBase->GetType() == VISU::TCURVE){
CORBA::String_var anID = aTargetRefSObj->GetID();
std::string anArg = theEntry2NameMap[anID.in()];
for(aChildItet->InitEx(false); aChildItet->More(); aChildItet->Next()){
SALOMEDS::SObject_var aSObject = aChildItet->Value();
CORBA::Object_var anObj = SObjectToObject(aSObject);
- if(CORBA::is_nil(anObj))
+ if(CORBA::is_nil(anObj))
continue;
VISU::Base_var aBase = VISU::Base::_narrow(anObj);
- if(CORBA::is_nil(aBase))
+ if(CORBA::is_nil(aBase))
continue;
if(aBase->GetType() == VISU::TCONTAINER){
//===========================================================================
- Engines::TMPFile*
+ Engines::TMPFile*
VISU_Gen_i::
DumpPython(CORBA::Object_ptr theStudy,
CORBA::Boolean theIsPublished,
CORBA::Boolean& theIsValidScript)
{
SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy);
- if(CORBA::is_nil(aStudy))
+ if(CORBA::is_nil(aStudy))
return new Engines::TMPFile(0);
TName2EntryMap aName2EntryMap;
#ifndef COUT
ostringstream aStr;
#else
-#define aStr cout
+#define aStr cout
#endif
std::string aPrefix(PREFIX);
CORBA::ULong aSize = aResult.size() + 1;
char* aBuffer = new char[aSize];
strcpy(aBuffer,&aResult[0]);
- return new Engines::TMPFile(aSize,aSize,(CORBA::Octet*)aBuffer,1);
+ return new Engines::TMPFile(aSize,aSize,(CORBA::Octet*)aBuffer,1);
#else
#undef aStr
return new Engines::TMPFile(0);
#endif
}
-
}