X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FVISU_I%2FVISU_DumpPython.cc;h=38b1318d8878861529af5be5a4018321eb5235c7;hb=e7e2c50aba46c639191ce54d4b42ae4587abb652;hp=02ae8b78ef138d5e226390c3c5407d4cac6c0638;hpb=87059649a597f596ea89148304b136593475167b;p=modules%2Fvisu.git diff --git a/src/VISU_I/VISU_DumpPython.cc b/src/VISU_I/VISU_DumpPython.cc index 02ae8b78..38b1318d 100644 --- a/src/VISU_I/VISU_DumpPython.cc +++ b/src/VISU_I/VISU_DumpPython.cc @@ -1,6 +1,6 @@ -// VISU OBJECT : interactive object for VISU entities implementation +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// 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 @@ -17,13 +17,14 @@ // 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 -// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + +// VISU OBJECT : interactive object for VISU entities implementation // File : VISU_DumpPython.cc // Author : Alexey PETROV // Module : VISU - +// #include "VISU_Gen_i.hh" #include "VISU_Result_i.hh" #include "VISU_PrsObject_i.hh" @@ -35,30 +36,40 @@ #include "VISU_DeformedShape_i.hh" #include "VISU_CutPlanes_i.hh" #include "VISU_CutLines_i.hh" +#include "VISU_CutSegment_i.hh" #include "VISU_Vectors_i.hh" #include "VISU_StreamLines_i.hh" #include "VISU_Plot3D_i.hh" #include "VISU_Table_i.hh" +#include "VISU_PointMap3d_i.hh" +#include "VISU_GaussPoints_i.hh" +#include "VISU_DeformedShapeAndScalarMap_i.hh" +#include "VISU_ColoredPrs3dCache_i.hh" +#include "VISU_ColoredPrs3dHolder_i.hh" #include "utilities.h" #include -#include +#include #include -#include -#include +#include +#include //#define COUT using namespace std; -namespace VISU{ +namespace VISU +{ + //--------------------------------------------------------------------------- static std::string PREFIX(" "); typedef std::map TName2EntryMap; typedef std::map TEntry2NameMap; + + //--------------------------------------------------------------------------- inline std::string GenerateName(std::string theName, @@ -79,20 +90,25 @@ namespace VISU{ return theName; } - struct TReplacePredicate{ + + //--------------------------------------------------------------------------- + struct TReplacePredicate + { bool operator()(char theChar) const { return !(isdigit(theChar) || isalpha(theChar) || theChar == '_'); } }; + + //--------------------------------------------------------------------------- inline std::string GetName(SALOMEDS::SObject_ptr theSObject) { CORBA::String_var aString = theSObject->GetName(); - std::string aName = QString(aString.in()).simplifyWhiteSpace().latin1(); + std::string aName = QString(aString.in()).simplified().toLatin1().data(); //replace_if(aName.begin(),aName.end(),not1(ptr_fun(isxdigit)),'_'); replace_if(aName.begin(),aName.end(),TReplacePredicate(),'_'); @@ -103,6 +119,8 @@ namespace VISU{ return aName; } + + //--------------------------------------------------------------------------- inline std::string GenerateName(SALOMEDS::SObject_ptr theSObject, @@ -111,11 +129,34 @@ namespace VISU{ { std::string aName = GetName(theSObject); - return GenerateName(aName,theSObject,theName2EntryMap,theEntry2NameMap,'X'); + return GenerateName(aName, theSObject, theName2EntryMap, theEntry2NameMap, 'X'); + } + + + //--------------------------------------------------------------------------- + inline + std::string + GetBoolean(bool theArgument) + { + if(theArgument) + return "True"; + + return "False"; + } + + + //--------------------------------------------------------------------------- + inline + std::string + GetColor(const SALOMEDS::Color& theColor) + { + std::ostringstream aStream; + aStream<<"SALOMEDS.Color("<GetClippingPlaneMgr(); + int aId; + for (int i = 0; i < thePrs->GetNumberOfClippingPlanes(); i++) { + aPlane = dynamic_cast(thePrs->GetClippingPlane(i)); + if (aPlane) { + if (!aPlane->isAuto()) { + aId = aMgr.GetPlaneId(aPlane); + if (aId > -1) { + theStr<GetOffset(x,y,z); + theStr<GetMarkerType(); + if( aMarkerType != VISU::MT_NONE ) { + if( aMarkerType != VISU::MT_USER ) { + VISU::MarkerScale aMarkerScale = theServant->GetMarkerScale(); + std::string aParam1, aParam2; + switch( aMarkerType ) { + case MT_POINT: aParam1 = "MT_POINT"; break; + case MT_PLUS: aParam1 = "MT_PLUS"; break; + case MT_STAR: aParam1 = "MT_STAR"; break; + case MT_O: aParam1 = "MT_O"; break; + case MT_X: aParam1 = "MT_X"; break; + case MT_O_POINT: aParam1 = "MT_O_POINT"; break; + case MT_O_PLUS: aParam1 = "MT_O_PLUS"; break; + case MT_O_STAR: aParam1 = "MT_O_STAR"; break; + case MT_O_X: aParam1 = "MT_O_X"; break; + case MT_POINT_SPRITE: aParam1 = "MT_POINT_SPRITE"; break; + default: aParam1 = "MT_NONE"; break; + } + switch( aMarkerScale ) { + case MS_10: aParam2 = "MS_10"; break; + case MS_15: aParam2 = "MS_15"; break; + case MS_20: aParam2 = "MS_20"; break; + case MS_25: aParam2 = "MS_25"; break; + case MS_30: aParam2 = "MS_30"; break; + case MS_35: aParam2 = "MS_35"; break; + case MS_40: aParam2 = "MS_40"; break; + case MS_45: aParam2 = "MS_45"; break; + case MS_50: aParam2 = "MS_50"; break; + case MS_55: aParam2 = "MS_55"; break; + case MS_60: aParam2 = "MS_60"; break; + case MS_65: aParam2 = "MS_65"; break; + case MS_70: aParam2 = "MS_70"; break; + default: aParam2 = "MS_NONE"; break; + } + if( aMarkerType == MT_POINT_SPRITE ) + aParam2 = "MS_NONE"; + theStr<GetMarkerTexture(); + if( aMarkerTexture >= 0 ) + theStr<GetEntity()){ + case NODE: + aParam = "VISU.NODE"; + break; + case EDGE: + aParam = "VISU.EDGE"; + break; + case FACE: + aParam = "VISU.FACE"; + break; + case CELL: + aParam = "VISU.CELL"; + break; + } + + theStr<GetCMeshName()<<"'"<< + ", "<GetCFieldName()<<"'"<< + ", "<GetTimeStampNumber()<< + ")"<Object map + theStr<GetName(); + theStr<GetPosX()<<", "<GetPosY()<<")"<GetWidth()<<", "<GetHeight()<<")"<GetNbColors()<<")"<GetLabels()<<")"<GetTitle()<<"')"<GetBarOrientation()){ + case ColoredPrs3dBase::HORIZONTAL: + aParam = "VISU.ColoredPrs3d.HORIZONTAL"; + break; + case ColoredPrs3dBase::VERTICAL: + aParam = "VISU.ColoredPrs3d.VERTICAL"; + break; + } + theStr<GetScalarMode()<<")"<IsRangeFixed()) + theStr<GetMin()<<", "<GetMax()<<")"<GetGroupNames(); + VISU::ColoredPrs3d_i::TGroupNames::const_iterator anIter = aGroupNames.begin(); + for(; anIter != aGroupNames.end(); anIter++){ + const std::string& aGroupName = *anIter; + theStr<GetIsActiveLocalScalarBar(); + theStr<GetIsDispGlobalScalarBar(); + theStr<GetSpacing()<<")"<GetBiColor(); + theStr<GetIsDeformed(); + theStr<GetScaleFactor()<<")"<GetPrimitiveType()){ + case VISU::GaussPoints::SPRITE : + aParam = "VISU.GaussPoints.SPRITE"; + break; + case VISU::GaussPoints::POINT : + aParam = "VISU.GaussPoints.POINT"; + break; + case VISU::GaussPoints::SPHERE : + aParam = "VISU.GaussPoints.SPHERE"; + break; + } + theStr<GetClamp()<<")"<GetQMainTexture(); + QString anAlphaTexture = theServant->GetQAlphaTexture(); + theStr<GetAlphaThreshold()<<")"<GetResolution()<<")"<GetFaceLimit()<<")"<GetIsColored(); + theStr<GetMinSize()<<")"<GetMaxSize()<<")"<GetColor())<<")"<GetGeomSize()<<")"<GetMagnification()<<")"<GetMagnificationIncrement()<<")"<IsBarVisible()? "True" : "False"; + theStr<GetScaling()){ + case LINEAR: + aParam = "VISU.LINEAR"; + break; + case LOGARITHMIC: + aParam = "VISU.LOGARITHMIC"; + break; + } + std::string aVisible = theServant->IsBarVisible()? "True" : "False"; + theStr<GetGaussMetric()){ + case AVERAGE: + aParam = "VISU.AVERAGE"; + break; + case MINIMUM: + aParam = "VISU.MINIMUM"; + break; + case MAXIMUM: + aParam = "VISU.MAXIMUM"; + break; + } + theStr<GetLinkColor(); + theStr<IsRangeFixed()) + theStr<GetMin()<<", "<GetMax()<<")"<IsColored())<<")"<GetColor())<<")"<GetScale()<<")"<IsColored())<<")"<GetColor())<<")"<GetDirection()){ + case StreamLines::FORWARD: + aParam = "VISU.StreamLines.FORWARD"; + break; + case StreamLines::BACKWARD: + aParam = "VISU.StreamLines.BACKWARD"; + break; + case StreamLines::BOTH: + aParam = "VISU.StreamLines.BOTH"; + break; + } + + theStr<GetSource(); + if(!CORBA::is_nil(aPrs3d)){ + if(Prs3d_i* aServant3d = dynamic_cast(GetServant(aPrs3d).in())){ + SALOMEDS::SObject_var aSObject = aServant3d->GetSObject(); + CORBA::String_var anID = aSObject->GetID(); + std::string anArg = theEntry2NameMap[anID.in()]; + theStr<GetIntegrationStep()<<", "<< + theServant->GetPropagationTime()<<", "<< + theServant->GetStepLength()<<", "<< + "aPrs3d"<<", "<< + theServant->GetUsedPoints()<<", "<< + aParam<< + ")"<GetMin()<<", "<GetMax()<<")"<GetScale()<<")"<GetEntity()){ + VISU::Entity anEntity = theServant->GetScalarEntity(); + switch(anEntity){ case NODE: aParam = "VISU.NODE"; break; @@ -164,73 +634,266 @@ namespace VISU{ aParam = "VISU.CELL"; break; } - - theStr<GetMeshName()<<"'"<< - ","<GetFieldName()<<"'"<< - ","<GetIteration()<< + + CORBA::String_var aFieldName = theServant->GetScalarFieldName(); + CORBA::Long aTimeStampNumber = theServant->GetScalarTimeStampNumber(); + + theStr<GetScalarMode()<<")"<GetScaling()){ - case LINEAR: - aParam = "VISU.LINEAR"; + theStr<GetLineWidth()<<")"<GetGlyphType()){ + case Vectors::ARROW: + aParam = "VISU.Vectors.ARROW"; break; - case LOGARITHMIC: - aParam = "VISU.LOGARITHMIC"; + case Vectors::CONE2: + aParam = "VISU.Vectors.CONE2"; + break; + case Vectors::CONE6: + aParam = "VISU.Vectors.CONE6"; + break; + case Vectors::NONE: + aParam = "VISU.Vectors.NONE"; break; } - theStr<GetMin()<<","<GetMax()<<")"<GetGlyphPos()){ + case Vectors::CENTER: + aParam = "VISU.Vectors.CENTER"; + break; + case Vectors::TAIL: + aParam = "VISU.Vectors.TAIL"; + break; + case Vectors::HEAD: + aParam = "VISU.Vectors.HEAD"; + break; + } + theStr<GetBarOrientation()){ - case ScalarMap::HORIZONTAL: - aParam = "VISU.ScalarMap.HORIZONTAL"; + + //--------------------------------------------------------------------------- + std::string + IsoSurfacesToPython(SALOMEDS::SObject_ptr theSObject, + VISU::IsoSurfaces_i* theServant, + std::ostream& theStr, + const std::string& theName, + TColoredPrs3dFactory& thePrsFactory, + std::string thePrefix) + { + thePrefix = ScalarMapToPython(theSObject, theServant, theStr, theName, thePrsFactory, thePrefix); + theStr<GetNbSurfaces()<<")"<IsLabeled()<<","<GetNbLabels()<<")"<GetOrientationType()){ + case CutPlanes::XY: + aParam = "VISU.CutPlanes.XY"; break; - case ScalarMap::VERTICAL: - aParam = "VISU.ScalarMap.VERTICAL"; + case CutPlanes::YZ: + aParam = "VISU.CutPlanes.YZ"; + break; + case CutPlanes::ZX: + aParam = "VISU.CutPlanes.ZX"; break; } - theStr<GetRotateX()<<", "<GetRotateY()<<")"<GetDisplacement()<<")"<GetNbPlanes(); + theStr<IsDefault(anId)) + theStr<GetPlanePosition(anId)<<")"<GetPosX()<<","<GetPosY()<<")"<GetWidth()<<","<GetHeight()<<")"<GetNbColors()<<")"<GetLabels()<<")"<GetTitle()<<"')"<IsDeformed())<<")"<IsDeformed()){ + theStr<< thePrefix << theName << ".SetScale(" << theServant->GetScale()<<")"<GetVectorialFieldEntity(); + switch(anEntity){ + case NODE: + aStringEntity = "VISU.NODE"; + break; + case EDGE: + aStringEntity = "VISU.EDGE"; + break; + case FACE: + aStringEntity = "VISU.FACE"; + break; + case CELL: + aStringEntity = "VISU.CELL"; + break; + } + theStr<< thePrefix << theName << ".SetVectorialField("<GetVectorialFieldName() <<"')"<GetOrientationType()){ + case CutPlanes::XY: + aParam = "VISU.CutPlanes.XY"; + break; + case CutPlanes::YZ: + aParam = "VISU.CutPlanes.YZ"; + break; + case CutPlanes::ZX: + aParam = "VISU.CutPlanes.ZX"; + break; + } + theStr<GetRotateX()<<", "<GetRotateY()<<")"<GetOrientationType2()){ + case CutPlanes::XY: + aParam = "VISU.CutPlanes.XY"; + break; + case CutPlanes::YZ: + aParam = "VISU.CutPlanes.YZ"; + break; + case CutPlanes::ZX: + aParam = "VISU.CutPlanes.ZX"; + break; + } + theStr<GetRotateX2()<<", "<GetRotateY2()<<")"<GetDisplacement()<<")"<GetDisplacement2()<<")"<IsDefault()) + theStr<GetBasePlanePosition()<<")"<IsUseAbsoluteLength(); + theStr<GetNbLines(); + theStr<IsDefaultPosition(anId)) + theStr<GetLinePosition(anId)<<")"<GetPoint1(x1, y1, z1); + theServant->GetPoint2(x2, y2, z2); + theStr<IsUseAbsoluteLength(); + theStr<GetScale()<<")"<IsColored()<<")"<GetColor(); - theStr<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<GetRotateX()<<", "<GetRotateY()<<")"<GetPlanePosition()<<", "<IsPositionRelative()<<")"<GetScaleFactor()<<")"<GetIsContourPrs()<<")"<GetNbOfContours()<<")"< void TableAttrToPython(SALOMEDS::Study_ptr theStudy, @@ -259,29 +922,32 @@ namespace VISU{ { SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::SObject_var aFatherSObject = theSObject->GetFather(); - if(aFatherSObject->FindAttribute(anAttr,"AttributeComment")){ - SALOMEDS::AttributeComment_var aComment = - SALOMEDS::AttributeComment::_narrow(anAttr); + if(aFatherSObject->FindAttribute(anAttr,"AttributeString")){ + SALOMEDS::AttributeString_var aComment = + SALOMEDS::AttributeString::_narrow(anAttr); CORBA::String_var aValue = aComment->Value(); Storable::TRestoringMap aMap; - Storable::StrToMap(aValue.in(),aMap); + Storable::StringToMap(aValue.in(),aMap); bool anIsExist; QString aMethodName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist); if(anIsExist){ - if(strcmp(aMethodName.latin1(),"ImportTables") == 0){ + if(strcmp(aMethodName.toLatin1().data(),"ImportTables") == 0){ return; } } } std::string aSObjectName = GetName(theSObject); - theStr<GetName()<<"\")"<GetNbRows(); // push values and their indices into streams - strstream values, rows, columns; + stringstream values, rows, columns; string comma = ""; for(CORBA::Long i = 1; i <= aNbColumns; i++){ for(CORBA::Long j = aNbRows; j > 0; j--){ @@ -310,7 +976,7 @@ namespace VISU{ } } // push titles and units into streams - strstream rowUnits, rowTitles, colTitles; + stringstream rowUnits, rowTitles, colTitles; SALOMEDS::StringSeq_var aRowUnits = theTableAttr->GetRowUnits(); SALOMEDS::StringSeq_var aRowTitles = theTableAttr->GetRowTitles(); comma = ""; @@ -350,7 +1016,7 @@ namespace VISU{ << aName << "_cTitles )" << endl; if(theSObject->FindAttribute(anAttr,"AttributeIOR")){ - theStr<GetName(); + theStr<GetID(); + CORBA::String_var aNameInStudy = theSObject->GetName(); + CORBA::Object_var anObj = SObjectToObject(theSObject); - if(!CORBA::is_nil(anObj)){ + if (!CORBA::is_nil(anObj)) { VISU::Base_var aBase = VISU::Base::_narrow(anObj); if(!CORBA::is_nil(aBase)){ - std::string aName = GenerateName(theSObject,theName2EntryMap,theEntry2NameMap); - CORBA::String_var anID = theSObject->GetID(); + std::string aName = GenerateName(theSObject, theName2EntryMap, theEntry2NameMap); VISU::VISUType aType = aBase->GetType(); switch(aType){ case VISU::TRESULT: if(Result_i* aServant = dynamic_cast(GetServant(anObj).in())){ - std::string aFileName = aServant->GetFileName(); + std::string aFileName = aServant->GetInitFileName(); Result_i::ECreationId anId = aServant->GetCreationId(); if(anId == Result_i::eImportFile || anId == Result_i::eCopyAndImportFile){ switch(anId){ case Result_i::eImportFile: - theStr<IsGroupsDone())<<")"<< + endl; + + theStr<IsFieldsDone())<<", "<< + GetBoolean(aServant->IsMinMaxDone())<<")"<< + endl; + + theStr<GetMeshNames(); + if (aMeshNames->length() > 0) { + for(size_t aMeshId = 0; aMeshId < aMeshNames->length(); aMeshId++){ + CORBA::String_var aMeshName = aMeshNames[aMeshId]; + VISU::Result::EntityNames_var aParts = aServant->GetPartNames(aMeshName); + if (aParts->length() > 0) { + for(size_t aPartId = 0; aPartId < aParts->length(); aPartId++){ + CORBA::String_var aPart = aParts[aPartId]; + VISU::Result::Resolution aResolution = aServant->GetResolution(aMeshName, aPart); + std::string aParam; + switch(aResolution){ + case VISU::Result::FULL: + aParam = "VISU.Result.FULL"; + break; + case VISU::Result::MEDIUM: + aParam = "VISU.Result.MEDIUM"; + break; + case VISU::Result::LOW: + aParam = "VISU.Result.LOW"; + break; + case VISU::Result::HIDDEN: + aParam = "VISU.Result.HIDDEN"; + break; + } + theStr<(GetServant(anObj).in())){ + if(Mesh_i* aServant = dynamic_cast(GetServant(anObj).in())){ VISU::Entity anEntity = aServant->GetEntity(); const std::string& aSubMeshName = aServant->GetSubMeshName(); if(anEntity >= 0){ @@ -576,38 +1294,46 @@ namespace VISU{ if(aSubMeshName == "") theStr<GetMeshName()<<"'"<< - ","<GetCMeshName()<<"'"<< + ", "<GetMeshName()<<"'"<< - ","<GetCMeshName()<<"'"<< + ", "<GetMeshName()<<"'"<< - ",'"<GetCMeshName()<<"'"<< + ", '"<Object map theStr<GetCellColor(); theStr<GetNodeColor(); theStr<GetLinkColor(); theStr<GetPresentationType()){ @@ -631,8 +1357,21 @@ namespace VISU{ break; } theStr<IsShrank()? "True" : "False")<<")"<GetQuadratic2DPresentationType()){ + case LINES: + aQuad2DPresent = "VISU.LINES"; + break; + case ARCS: + aQuad2DPresent = "VISU.ARCS"; + break; + } + theStr<(GetServant(anObj).in())){ - thePrefix = ScalarMapToPython(theSObject,aServant,theStr,aName,"ScalarMapOnField",theArgumentName,thePrefix); + TCreateFromResult aPrsFactory(theSObject, aServant, aName, "ScalarMapOnField", theArgumentName); + thePrefix = ScalarMapToPython(theSObject, aServant, theStr,aName, aPrsFactory, thePrefix); theStr<(GetServant(anObj).in())){ - thePrefix = DeformedShapeToPython(theSObject,aServant,theStr,aName,"DeformedShapeOnField",theArgumentName,thePrefix); + TCreateFromResult aPrsFactory(theSObject, aServant, aName, "DeformedShapeOnField", theArgumentName); + thePrefix = DeformedShapeToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix); theStr<(GetServant(anObj).in())){ - thePrefix = DeformedShapeToPython(theSObject,aServant,theStr,aName,"StreamLinesOnField",theArgumentName,thePrefix); - - std::string aParam; - switch(aServant->GetDirection()){ - case StreamLines::FORWARD: - aParam = "VISU.StreamLines.FORWARD"; - break; - case StreamLines::BACKWARD: - aParam = "VISU.StreamLines.BACKWARD"; - break; - case StreamLines::BOTH: - aParam = "VISU.StreamLines.BOTH"; - break; - } - - theStr<GetSource(); - if(!CORBA::is_nil(aPrs3d)){ - if(Prs3d_i* aServant3d = dynamic_cast(GetServant(aPrs3d).in())){ - SALOMEDS::SObject_var aSObject = aServant3d->GetSObject(); - CORBA::String_var anID = aSObject->GetID(); - std::string anArg = theEntry2NameMap[anID.in()]; - theStr<GetIntegrationStep()<<","<< - aServant->GetPropagationTime()<<","<< - aServant->GetStepLength()<<","<< - "aPrs3d"<<","<< - aServant->GetUsedPoints()<<","<< - aParam<< - ")"<(GetServant(anObj).in())){ + TCreateFromResult aPrsFactory(theSObject, aServant, aName, "DeformedShapeAndScalarMapOnField", theArgumentName); + thePrefix = DeformedShapeAndScalarMapToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix); theStr<(GetServant(anObj).in())){ - thePrefix = DeformedShapeToPython(theSObject,aServant,theStr,aName,"VectorsOnField",theArgumentName,thePrefix); - - theStr<GetLineWidth()<<")"<GetGlyphType()){ - case Vectors::ARROW: - aParam = "VISU.Vectors.ARROW"; - break; - case Vectors::CONE2: - aParam = "VISU.Vectors.CONE2"; - break; - case Vectors::CONE6: - aParam = "VISU.Vectors.CONE6"; - break; - case Vectors::NONE: - aParam = "VISU.Vectors.NONE"; - break; - } - theStr<GetGlyphPos()){ - case Vectors::CENTER: - aParam = "VISU.Vectors.CENTER"; - break; - case Vectors::TAIL: - aParam = "VISU.Vectors.TAIL"; - break; - case Vectors::HEAD: - aParam = "VISU.Vectors.HEAD"; - break; - } - theStr<(GetServant(anObj).in())){ - thePrefix = ScalarMapToPython(theSObject,aServant,theStr,aName,"IsoSurfacesOnField",theArgumentName,thePrefix); - theStr<GetNbSurfaces()<<")"<(GetServant(anObj).in())){ - thePrefix = ScalarMapToPython(theSObject,aServant,theStr,aName,"CutPlanesOnField",theArgumentName,thePrefix); + TCreateFromResult aPrsFactory(theSObject, aServant, aName, "CutPlanesOnField", theArgumentName); + thePrefix = CutPlanesToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix); + theStr<(GetServant(anObj).in())){ + TCreateFromResult aPrsFactory(theSObject, aServant, aName, "CutLinesOnField", theArgumentName); + thePrefix = CutLinesToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix); - std::string aParam; - switch(aServant->GetOrientationType()){ - case CutPlanes::XY: - aParam = "VISU.CutPlanes.XY"; - break; - case CutPlanes::YZ: - aParam = "VISU.CutPlanes.YZ"; - break; - case CutPlanes::ZX: - aParam = "VISU.CutPlanes.ZX"; - break; - } - theStr<GetRotateX()<<","<GetRotateY()<<")"<GetDisplacement()<<")"<GetNbPlanes(); - theStr<(GetServant(anObj).in())){ + TCreateFromResult aPrsFactory(theSObject, aServant, aName, "CutSegmentOnField", theArgumentName); + thePrefix = CutSegmentToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix); - for(CORBA::Long anId = 0; anId < aNbPlanes; anId++){ - if(!aServant->IsDefault(anId)) - theStr<GetPlanePosition(anId)<<")"<(GetServant(anObj).in())){ - thePrefix = ScalarMapToPython(theSObject,aServant,theStr,aName,"CutLinesOnField",theArgumentName,thePrefix); + case VISU::TPLOT3D: + if (Plot3D_i* aServant = dynamic_cast(GetServant(anObj).in())) { + TCreateFromResult aPrsFactory(theSObject, aServant, aName, "Plot3DOnField", theArgumentName); + thePrefix = Plot3DToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix); + theStr<(GetServant(anObj).in())) { + CORBA::Short aTag = theSObject->Tag(); + theStr<GetScaleFactor()<<")"<GetIsContourPrs()<<")"<GetNbOfContours()<<")"<GetOrientationType()){ - case CutPlanes::XY: - aParam = "VISU.CutPlanes.XY"; - break; - case CutPlanes::YZ: - aParam = "VISU.CutPlanes.YZ"; + switch(aServant->GetScaling()){ + case LINEAR: + aParam = "VISU.LINEAR"; break; - case CutPlanes::ZX: - aParam = "VISU.CutPlanes.ZX"; + case LOGARITHMIC: + aParam = "VISU.LOGARITHMIC"; break; } - theStr<GetRotateX()<<","<GetRotateY()<<")"<GetOrientationType2()){ - case CutPlanes::XY: - aParam = "VISU.CutPlanes.XY"; - break; - case CutPlanes::YZ: - aParam = "VISU.CutPlanes.YZ"; + theStr<GetNbColors()<<")"<GetLabels()<<")"<GetBarOrientation()){ + case ColoredPrs3dBase::HORIZONTAL: + aParam = "VISU.ColoredPrs3d.HORIZONTAL"; break; - case CutPlanes::ZX: - aParam = "VISU.CutPlanes.ZX"; + case ColoredPrs3dBase::VERTICAL: + aParam = "VISU.ColoredPrs3d.VERTICAL"; break; } - theStr<GetRotateX2()<<","<GetRotateY2()<<")"<GetDisplacement()<<")"<GetDisplacement2()<<")"<IsRangeFixed()) + theStr<GetMin()<<", "<GetMax()<<")"<IsDefault()) - theStr<GetBasePlanePosition()<<")"<GetPosX()<<", "<GetPosY()<<")"<GetWidth()<<", "<GetHeight()<<")"<GetNbLines(); - theStr<IsDefaultPosition(anId)) - theStr<GetLinePosition(anId)<<")"<GetOffset(dx, dy, dz); + theStr<(GetServant(anObj).in())) { - // jfa: TODO - /*thePrefix = ScalarMapToPython(theSObject, aServant, theStr, aName, - "Plot3DOnField", theArgumentName, thePrefix); - - std::string aParam; - switch(aServant->GetOrientationType()){ - case CutPlanes::XY: - aParam = "VISU.CutPlanes.XY"; - break; - case CutPlanes::YZ: - aParam = "VISU.CutPlanes.YZ"; - break; - case CutPlanes::ZX: - aParam = "VISU.CutPlanes.ZX"; - break; - } - theStr<GetRotateX()<<","<GetRotateY()<<")"<GetDisplacement()<<")"<GetNbPlanes(); - theStr<IsDefault(anId)) - theStr<GetPlanePosition(anId)<<")"<(GetServant(anObj).in())){ + TCreateFromResult aPrsFactory(theSObject, aServant, aName, "GaussPointsOnField", theArgumentName); + thePrefix = GaussPointsToPython(theSObject, aServant, theStr, aName, aPrsFactory, thePrefix); + theStr<(GetServant(anObj).in())) { - theStr << thePrefix << "aName2ObjectMap['" << aName << "'] = visu.CreateCurve(" << + bool withZ = aServant->GetZRow()>0; + bool isV2 = aServant->GetIsV2(); + + theStr << thePrefix << "aName2ObjectMap['" << aName << "'] = visu.CreateCurve"; + if( isV2 ) + theStr << "WithZExt"; + else if( withZ ) + theStr << "WithZ"; + theStr << "(" << theArgumentName<< // table - ","<GetHRow()<< // H row - ","<GetVRow()<< // V row - ",'"<GetTitle()<<"'"; // title + ", "<GetHRow()<< // H row + ", "<GetVRow(); // V row + if( withZ || isV2 ) + theStr << ", " << aServant->GetZRow(); // Z row + if( isV2 ) + theStr << ", " << aServant->GetIsV2(); // right axis + + theStr << ", '"<GetTitle()<<"'"; // title SALOMEDS::Color aColor = aServant->GetColor(); theStr << ",SALOMEDS.Color("<< - aColor.R<<","<GetMarker()){ @@ -894,7 +1598,7 @@ namespace VISU{ case Curve::CROSS: aParam = "VISU.Curve.CROSS"; break; case Curve::XCROSS: aParam = "VISU.Curve.XCROSS"; break; } - theStr<<","<GetLine()){ case Curve::VOIDLINE: aParam = "VISU.Curve.VOIDLINE"; break; @@ -904,23 +1608,22 @@ namespace VISU{ case Curve::DASHDOTLINE: aParam = "VISU.Curve.DASHDOTLINE"; break; case Curve::DASHDOTDOTLINE: aParam = "VISU.Curve.DASHDOTDOTLINE"; break; } - theStr<<","<GetLineWidth()<<")"<GetLineWidth()<<")"<(GetServant(anObj).in())){ - SALOMEDS::SObject_var aSObject = aServant->GetSObject(); + if(dynamic_cast(GetServant(anObj).in())){ SALOMEDS::GenericAttribute_var anAttr; - if(theSObject->FindAttribute(anAttr,"AttributeComment")){ + if(theSObject->FindAttribute(anAttr,"AttributeString")){ using namespace SALOMEDS; - AttributeComment_var aComment = AttributeComment::_narrow(anAttr); + AttributeString_var aComment = AttributeString::_narrow(anAttr); CORBA::String_var aValue = aComment->Value(); Storable::TRestoringMap aMap; - Storable::StrToMap(aValue.in(),aMap); + Storable::StringToMap(aValue.in(),aMap); bool anIsExist; QString aSourceId = VISU::Storable::FindValue(aMap,"mySourceId",&anIsExist); if(anIsExist){ - if(strcmp(aSourceId.latin1(),"CutLines") == 0){ + if( aSourceId == "CutLines" ){ theStr<Tag(); theStr<FindAttribute(anAttr,"AttributeComment")){ - SALOMEDS::AttributeComment_var aComment = - SALOMEDS::AttributeComment::_narrow(anAttr); + if (theSObject->FindAttribute(anAttr,"AttributeString")) { + SALOMEDS::AttributeString_var aComment = + SALOMEDS::AttributeString::_narrow(anAttr); CORBA::String_var aValue = aComment->Value(); Storable::TRestoringMap aMap; - Storable::StrToMap(aValue.in(),aMap); + Storable::StringToMap(aValue.in(),aMap); bool anIsExist; QString aTypeName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist); - if(anIsExist){ - if(strcmp(aTypeName.latin1(),"ImportTables") == 0){ + if (anIsExist) { + if (aTypeName == "ImportTables") { QString aFileName = VISU::Storable::FindValue(aMap,"myFileName",&anIsExist); if(anIsExist){ - std::string aName = GenerateName(theSObject,theName2EntryMap,theEntry2NameMap); - theStr<GetType() == VISU::TCONTAINER){ - theStr<GetName(); + theStr<NewChildIterator(aSObject); for(aCurveIter->InitEx(false); aCurveIter->More(); aCurveIter->Next()){ SALOMEDS::SObject_var aRefSObj = aCurveIter->Value(); @@ -1141,13 +1896,412 @@ namespace VISU{ } - //=========================================================================== + //--------------------------------------------------------------------------- + void + DumpPrs3dCacheToPython(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) + { + + SALOMEDS::ChildIterator_var anIter = theStudy->NewChildIterator(theSObject); + for(anIter->InitEx(false); anIter->More(); anIter->Next()){ + SALOMEDS::SObject_var aSObject = anIter->Value(); + CORBA::Object_var anObj = SObjectToObject(aSObject); + if(CORBA::is_nil(anObj)) + continue; + + VISU::Base_var aBase = VISU::Base::_narrow(anObj); + if(CORBA::is_nil(aBase)) + continue; + + if(aBase->GetType() == VISU::TCOLOREDPRS3DCACHE){ + ColoredPrs3dCache_i* aCache = dynamic_cast(GetServant(aBase).in()); + theStr<GetMemoryMode(); + switch(aMode){ + case VISU::ColoredPrs3dCache::MINIMAL : anArgument = "VISU.ColoredPrs3dCache.MINIMAL"; break; + case VISU::ColoredPrs3dCache::LIMITED : anArgument = "VISU.ColoredPrs3dCache.LIMITED"; break; + } + theStr<GetLimitedMemory()<<") # (Mb)"<NewChildIterator(aSObject); + for(aChildIter->InitEx(false); aChildIter->More(); aChildIter->Next()){ + SALOMEDS::SObject_var aSObject = aChildIter->Value(); + CORBA::Object_var anObject = SObjectToObject(aSObject); + if (CORBA::is_nil(anObject)) + continue; + + ColoredPrs3dHolder_i* aServant = dynamic_cast(GetServant(anObject).in()); + if(!aServant) + continue; + + ColoredPrs3d_i* aDevice = aServant->GetPrs3dDevice(); + if(!aDevice) + continue; + + Result_i* aResult = aDevice->GetCResult(); + std::string aResultEntry = aResult->GetEntry(); + std::string aResultName = theEntry2NameMap[aResultEntry]; + + ColoredPrs3dHolder::BasicInput_var anInput = aServant->GetBasicInput(); + std::string anEntity; + switch(anInput->myEntity){ + case VISU::NODE : anEntity = "VISU.NODE"; break; + case VISU::EDGE : anEntity = "VISU.EDGE"; break; + case VISU::FACE : anEntity = "VISU.FACE"; break; + case VISU::CELL : anEntity = "VISU.CELL"; break; + } + + + theStr<myMeshName<<"', "<< + anEntity<<", '"<< + anInput->myFieldName<<"', "<< + anInput->myTimeStampNumber<<")"<< + endl; + + std::string aComment = aDevice->GetComment(); + theStr<GetName(); + theStr<GetType()){ + case VISU::TSCALARMAP: + if(ScalarMap_i* aServant = dynamic_cast(aDevice)){ + ScalarMapToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3); + break; + } + case VISU::TDEFORMEDSHAPE: + if(DeformedShape_i* aServant = dynamic_cast(aDevice)){ + DeformedShapeToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3); + break; + } + case VISU::TSTREAMLINES: + if(StreamLines_i* aServant = dynamic_cast(aDevice)){ + StreamLinesToPython(aSObject, aServant, theStr, theEntry2NameMap, "aDevice", aPrsFactory, aPrefix3); + break; + } + case VISU::TSCALARMAPONDEFORMEDSHAPE: + case VISU::TDEFORMEDSHAPEANDSCALARMAP: + if(DeformedShapeAndScalarMap_i* aServant = dynamic_cast(aDevice)){ + DeformedShapeAndScalarMapToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3); + break; + } + case VISU::TVECTORS: + if(Vectors_i* aServant = dynamic_cast(aDevice)){ + VectorsToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3); + break; + } + case VISU::TISOSURFACES: + if(IsoSurfaces_i* aServant = dynamic_cast(aDevice)){ + IsoSurfacesToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3); + break; + } + case VISU::TCUTPLANES: + if(CutPlanes_i* aServant = dynamic_cast(aDevice)){ + CutPlanesToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3); + break; + } + case VISU::TCUTLINES: + if(CutLines_i* aServant = dynamic_cast(aDevice)){ + CutLinesToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3); + break; + } + case VISU::TCUTSEGMENT: + if(CutSegment_i* aServant = dynamic_cast(aDevice)){ + CutSegmentToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3); + break; + } + case VISU::TPLOT3D: + if(Plot3D_i* aServant = dynamic_cast(aDevice)){ + Plot3DToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3); + break; + } + case VISU::TGAUSSPOINTS: + if(GaussPoints_i* aServant = dynamic_cast(aDevice)){ + GaussPointsToPython(aSObject, aServant, theStr, "aDevice", aPrsFactory, aPrefix3); + break; + } + } + theStr<NewChildIterator(theSObject); + for(aChildItet->InitEx(false); aChildItet->More(); aChildItet->Next()){ + SALOMEDS::SObject_var aSObject = aChildItet->Value(); + + SALOMEDS::GenericAttribute_var anAttr; + if (!aSObject->FindAttribute(anAttr, "AttributeString")) continue; + + SALOMEDS::AttributeString_var aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr); + QString value (aStringAttr->Value()); + if(value.isEmpty()) continue; + + VISU::Storable::TRestoringMap aMap; + VISU::Storable::StringToMap(value, aMap); + bool isExist; + + QString aTypeName = VISU::Storable::FindValue(aMap,"myComment",&isExist); + if(!isExist || aTypeName != "EVOLUTION") continue; + + //EVOLUTION + theStr<GetName(); + theStr<NewChildIterator(aSObject); + for (anIter->Init(); anIter->More(); anIter->Next()) { + SALOMEDS::SObject_var anObj = anIter->Value(); + + //FIELD + theStr<FindAttribute(anAttr, "AttributeString")) { + aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr); + theStr<Value()<<"')"<< endl; + } + + SALOMEDS::SObject_var refObj; + if(anObj->ReferencedObject(refObj)) { + SALOMEDS::SObject_var father = refObj->GetFather(); + value = refObj->GetName(); + QString path(theStudy->GetObjectPath(father)); + //The following code requierd as a field name can contain '/' character + theStr<GetName(); + if(!value.isEmpty()) theStr<NewChildIterator(anObj); + for(aChildItet->InitEx(false); aChildItet->More(); aChildItet->Next()){ + SALOMEDS::SObject_var aSObject = aChildItet->Value(); + + std::string anArgumentName = "fieldSO"; + DumpTableAttrToPython(theStudy, + theIsPublished, + theIsValidScript, + aSObject, + theStr, + theName2EntryMap, + theEntry2NameMap, + anArgumentName, + thePrefix); + } + } + + } + + theStr<NewChildIterator(theSObject); + for(aChildItet->InitEx(false); aChildItet->More(); aChildItet->Next()){ + SALOMEDS::SObject_var aSObject = aChildItet->Value(); + + SALOMEDS::GenericAttribute_var anAttr; + if (!aSObject->FindAttribute(anAttr, "AttributeString")) continue; + + SALOMEDS::AttributeString_var aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr); + QString value (aStringAttr->Value()); + if(value.isEmpty()) continue; + + VISU::Storable::TRestoringMap aMap; + VISU::Storable::StringToMap(value, aMap); + bool isExist; + + QString aTypeName = VISU::Storable::FindValue(aMap,"myComment",&isExist); + if(!isExist || aTypeName != "ANIMATION") continue; + + //ANIMATION + theStr<GetName(); + theStr<NewChildIterator(aSObject); + for (anIter->Init(); anIter->More(); anIter->Next()) { + SALOMEDS::SObject_var anObj = anIter->Value(); + + //FIELD + theStr<FindAttribute(anAttr, "AttributeString")) { + aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr); + theStr<Value()<<"')"<< endl; + } + + SALOMEDS::SObject_var refObj; + if(anObj->ReferencedObject(refObj)) { + SALOMEDS::SObject_var father = refObj->GetFather(); + value = refObj->GetName(); + QString path(theStudy->GetObjectPath(father)); + //The following code requierd as a field name can contain '/' character + theStr<GetName(); + if(!value.isEmpty()) theStr<NewChildIterator(anObj); + for (aSubIter->Init(); aSubIter->More(); aSubIter->Next()) { + SALOMEDS::SObject_var aSubObj = aSubIter->Value(); + + theStr<GetName(); + if(!value.isEmpty()) theStr<FindAttribute(anAttr, "AttributeString")) { + aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr); + theStr<Value()<<"')"<< endl; + } + } + + } + + } + + theStr<GetOrigin(aOrigin); + aPlane->GetNormal(aDir); + + theStr<isAuto()<<",\""<getName()<<"\")"<StudyId()); + if(anIter == theMarkerMap.end()) + return; + + theStr<second; + VTK::MarkerMap::const_iterator aMarkerIter = aMarkerMap.begin(); + for(; aMarkerIter != aMarkerMap.end(); aMarkerIter++) { + int aMarkerId = aMarkerIter->first; + std::string aMarkerTexture = aMarkerIter->second.first; + theStr<GetDefaultScript("Post-Pro", aPrefix.c_str()); + if(script && strlen(script) > 0) { + aStr << script; + CORBA::string_free(script); + } + } + + if( theIsMultiFile ) + aStr<