From be011307672cd4765e73905fbef34f3e467aaa83 Mon Sep 17 00:00:00 2001 From: jfa Date: Thu, 13 Apr 2006 08:09:28 +0000 Subject: [PATCH] Fix bug 10040: 'Dump Study' doesn't restore the name of presentation in Post-Pro. --- idl/VISU_Gen.idl | 22 ++++++++++ src/ENGINE/VISU_Engine_i.cc | 22 +++++++++- src/ENGINE/VISU_Engine_i.hh | 64 +++++++++++++++++----------- src/VISU_I/VISU_DumpPython.cc | 54 ++++++++++++++++++------ src/VISU_I/VISU_Gen_i.cc | 79 +++++++++++++++++++++++++++++++++++ src/VISU_I/VISU_Gen_i.hh | 29 +++++++++++++ 6 files changed, 232 insertions(+), 38 deletions(-) diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index af87ae1c..a769fa05 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -1398,6 +1398,28 @@ module VISU { */ Result ImportMedField(in SALOME_MED::FIELD theField); + /*! + * Rename a study object, representing a mesh, specified by given values. + * \param theResult Data generated in other sources (MED object or file). + * \param theMeshName One of the meshes presented in MED file. + * \param theEntity Type of entity where the field is defined. + * \param theSubMeshName Name of sub-mesh (group or family). + * \param theNewName Name to be given to the study object. + */ + void RenameEntityInStudy(in Result theResult, + in string theMeshName, + in Entity theEntity, + in string theNewName); + void RenameFamilyInStudy(in Result theResult, + in string theMeshName, + in Entity theEntity, + in string theSubMeshName, + in string theNewName); + void RenameGroupInStudy(in Result theResult, + in string theMeshName, + in string theSubMeshName, + in string theNewName); + /*! * Creates a mesh on the basis of the data generated in other sources (MED object or file). * \param theResult Data generated in other sources. (MED object or file) diff --git a/src/ENGINE/VISU_Engine_i.cc b/src/ENGINE/VISU_Engine_i.cc index b1a29e01..c6c73c1d 100644 --- a/src/ENGINE/VISU_Engine_i.cc +++ b/src/ENGINE/VISU_Engine_i.cc @@ -189,7 +189,6 @@ namespace VISU{ return myVisuGen->MeshOnEntity(theResult,theMeshName,theEntity); } - Mesh_ptr VISU_Gen_i::FamilyMeshOnEntity(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, @@ -198,7 +197,6 @@ namespace VISU{ return myVisuGen->FamilyMeshOnEntity(theResult,theMeshName,theEntity,theFamilyName); } - Mesh_ptr VISU_Gen_i::GroupMesh(Result_ptr theResult, const char* theMeshName, const char* theGroupName) @@ -207,6 +205,26 @@ namespace VISU{ } + void VISU_Gen_i::RenameEntityInStudy(Result_ptr theResult, const char* theMeshName, + VISU::Entity theEntity, const char* theNewName) + { + myVisuGen->RenameEntityInStudy(theResult,theMeshName,theEntity,theNewName); + } + + void VISU_Gen_i::RenameFamilyInStudy(Result_ptr theResult, const char* theMeshName, + VISU::Entity theEntity, const char* theFamilyName, + const char* theNewName) + { + myVisuGen->RenameFamilyInStudy(theResult,theMeshName,theEntity,theFamilyName,theNewName); + } + + void VISU_Gen_i::RenameGroupInStudy(Result_ptr theResult, const char* theMeshName, + const char* theGroupName, const char* theNewName) + { + myVisuGen->RenameGroupInStudy(theResult,theMeshName,theGroupName,theNewName); + } + + ScalarMap_ptr VISU_Gen_i::ScalarMapOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, diff --git a/src/ENGINE/VISU_Engine_i.hh b/src/ENGINE/VISU_Engine_i.hh index b56e216c..21892f5e 100644 --- a/src/ENGINE/VISU_Engine_i.hh +++ b/src/ENGINE/VISU_Engine_i.hh @@ -53,7 +53,7 @@ namespace VISU{ virtual ViewManager_ptr GetViewManager(); virtual SALOMEDS::SObject_ptr ImportTables(const char* theFileName); - virtual CORBA::Boolean ExportTableToFile(SALOMEDS::SObject_ptr theTable, const char* theFileName ); + virtual CORBA::Boolean ExportTableToFile(SALOMEDS::SObject_ptr theTable, const char* theFileName); //Create Result virtual Result_ptr ImportFile(const char* theFileName); @@ -64,30 +64,47 @@ namespace VISU{ //Create Presentation Of Submeshes virtual Mesh_ptr MeshOnEntity(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity); - virtual Mesh_ptr FamilyMeshOnEntity(Result_ptr theResult, const char* theMeshName, + virtual Mesh_ptr FamilyMeshOnEntity(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, const char* theFamilyName); virtual Mesh_ptr GroupMesh(Result_ptr theResult, const char* theMeshName, const char* theGroupName); - virtual ScalarMap_ptr ScalarMapOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, CORBA::Double theIteration); - virtual GaussPoints_ptr GaussPointsOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, CORBA::Double theIteration); - virtual DeformedShape_ptr DeformedShapeOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, CORBA::Double theIteration); - virtual Vectors_ptr VectorsOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, + //Rename Presentation Of Submeshes + virtual void RenameEntityInStudy(Result_ptr theResult, const char* theMeshName, + VISU::Entity theEntity, const char* theNewName); + virtual void RenameFamilyInStudy(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, + const char* theFamilyName, const char* theNewName); + virtual void RenameGroupInStudy (Result_ptr theResult, const char* theMeshName, + const char* theGroupName, const char* theNewName); + + //Create Presentation Of Results + virtual ScalarMap_ptr ScalarMapOnField + (Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, CORBA::Double theIteration); + virtual GaussPoints_ptr GaussPointsOnField + (Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, CORBA::Double theIteration); + virtual DeformedShape_ptr DeformedShapeOnField + (Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, CORBA::Double theIteration); + virtual Vectors_ptr VectorsOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, CORBA::Double theIteration); + virtual IsoSurfaces_ptr IsoSurfacesOnField + (Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, CORBA::Double theIteration); + virtual CutPlanes_ptr CutPlanesOnField + (Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, CORBA::Double theIteration); + virtual CutLines_ptr CutLinesOnField + (Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, CORBA::Double theIteration); + virtual StreamLines_ptr StreamLinesOnField + (Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, CORBA::Double theIteration); + virtual Plot3D_ptr Plot3DOnField (Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, CORBA::Double theIteration); + virtual ScalarMapOnDeformedShape_ptr ScalarMapOnDeformedShapeOnField + (Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, const char* theFieldName, CORBA::Double theIteration); - virtual IsoSurfaces_ptr IsoSurfacesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, CORBA::Double theIteration); - virtual CutPlanes_ptr CutPlanesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, CORBA::Double theIteration); - virtual CutLines_ptr CutLinesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, CORBA::Double theIteration); - virtual StreamLines_ptr StreamLinesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, CORBA::Double theIteration); - virtual Plot3D_ptr Plot3DOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, CORBA::Double theIteration); - virtual ScalarMapOnDeformedShape_ptr ScalarMapOnDeformedShapeOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, CORBA::Double theIteration); //Create Digital Presentation virtual Table_ptr CreateTable(const char* theTableEntry); virtual Curve_ptr CreateCurve(Table_ptr theTable, CORBA::Long theHRow, CORBA::Long theVRow); @@ -125,7 +142,7 @@ namespace VISU{ const char* aLocalPersistentID, CORBA::Boolean isMultiFile, CORBA::Boolean isASCII); - + virtual bool CanPublishInStudy(CORBA::Object_ptr theIOR); virtual SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy, SALOMEDS::SObject_ptr theSObject, @@ -143,9 +160,8 @@ namespace VISU{ virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy, CORBA::Boolean theIsPublished, CORBA::Boolean& theIsValidScript); - }; }; -#endif +#endif diff --git a/src/VISU_I/VISU_DumpPython.cc b/src/VISU_I/VISU_DumpPython.cc index a012ca37..d85247b9 100644 --- a/src/VISU_I/VISU_DumpPython.cc +++ b/src/VISU_I/VISU_DumpPython.cc @@ -509,15 +509,17 @@ namespace VISU{ std::string thePrefix) { std::string aName = GetName(theSObject); - if(aName == "") + if (aName == "") return; + CORBA::String_var anID = theSObject->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(); VISU::VISUType aType = aBase->GetType(); switch(aType){ @@ -641,7 +643,6 @@ namespace VISU{ theStr<GetName(); theStr<GetName(); theStr<GetName(); theStr<FindAttribute(anAttr,"AttributeComment")){ + if (theSObject->FindAttribute(anAttr,"AttributeComment")) { SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr); CORBA::String_var aValue = aComment->Value(); @@ -1086,8 +1085,8 @@ namespace VISU{ Storable::StrToMap(aValue.in(),aMap); bool anIsExist; QString aTypeName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist); - if(anIsExist){ - if(strcmp(aTypeName.latin1(),"ImportTables") == 0){ + if (anIsExist) { + if (strcmp(aTypeName.latin1(),"ImportTables") == 0) { QString aFileName = VISU::Storable::FindValue(aMap,"myFileName",&anIsExist); if(anIsExist){ std::string aName = GenerateName(theSObject,theName2EntryMap,theEntry2NameMap); @@ -1109,7 +1108,7 @@ namespace VISU{ theStr<GetProperties()->IsLocked()) return; + Mutex mt(myMutex); + + Result_i* pResult = dynamic_cast(GetServant(theResult).in()); + if (!pResult) return; + + QString aComment; + VISU::VISUType aType; + if (theEntity >= 0) + if (theSubMeshName == "") + aType = VISU::TENTITY; + else + aType = VISU::TFAMILY; + else + aType = VISU::TGROUP; + + switch (aType) { + case VISU::TENTITY: + aComment.sprintf("myComment=ENTITY;myType=%d;myMeshName=%s;myId=%d", + VISU::TENTITY, theMeshName.c_str(), theEntity); + break; + case VISU::TFAMILY: + aComment.sprintf("myComment=FAMILY;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s", + VISU::TFAMILY, theMeshName.c_str(), theEntity, theSubMeshName.c_str()); + break; + case VISU::TGROUP: + aComment.sprintf("myComment=GROUP;myType=%d;myMeshName=%s;myName=%s", + VISU::TGROUP, theMeshName.c_str(), theSubMeshName.c_str()); + break; + } + + string aResultEntry = pResult->GetEntry(); + string anEntry = pResult->GetEntry(aComment.latin1()); + if (anEntry == "") return; + + SALOMEDS::SObject_ptr aSObject = myStudyDocument->FindObjectID(anEntry.c_str()); + + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder(); + aStudyBuilder->NewCommand(); // There is a transaction + + SALOMEDS::GenericAttribute_var anAttr = + aStudyBuilder->FindOrCreateAttribute(aSObject,"AttributeName"); + SALOMEDS::AttributeName_var aNameAttr = SALOMEDS::AttributeName::_narrow(anAttr); + aNameAttr->SetValue(theNewName.c_str()); + + aStudyBuilder->CommitCommand(); + } + + void VISU_Gen_i::RenameEntityInStudy(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity, + const char* theNewName) + { + RenameMeshInStudy(theResult, theMeshName, (int)theEntity, "", theNewName); + } + + void VISU_Gen_i::RenameFamilyInStudy(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity, + const char* theFamilyName, + const char* theNewName) + { + RenameMeshInStudy(theResult, theMeshName, (int)theEntity, theFamilyName, theNewName); + } + + void VISU_Gen_i::RenameGroupInStudy(Result_ptr theResult, + const char* theMeshName, + const char* theGroupName, + const char* theNewName) + { + RenameMeshInStudy(theResult, theMeshName, -1, theGroupName, theNewName); + } + Mesh_ptr VISU_Gen_i::MeshOnEntity(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity) diff --git a/src/VISU_I/VISU_Gen_i.hh b/src/VISU_I/VISU_Gen_i.hh index 1f4f9212..5590e898 100644 --- a/src/VISU_I/VISU_Gen_i.hh +++ b/src/VISU_I/VISU_Gen_i.hh @@ -15,6 +15,8 @@ #include "SALOME_Component_i.hxx" #include "SALOME_NamingService.hxx" +#include + namespace VISU { class Result_i; @@ -92,6 +94,33 @@ namespace VISU ImportMedField(SALOME_MED::FIELD_ptr theField); + //Rename Presentation Of Submeshes + void + RenameMeshInStudy(Result_ptr theResult, + std::string theMeshName, + int theEntity, // -1 for group indication + std::string theSubMeshName, // Family or Group name + std::string theNewName); + virtual + void + RenameEntityInStudy(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity, + const char* theNewName); + virtual + void + RenameFamilyInStudy(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity, + const char* theFamilyName, + const char* theNewName); + virtual + void + RenameGroupInStudy(Result_ptr theResult, + const char* theMeshName, + const char* theGroupName, + const char* theNewName); + //Create Presentation Of Submeshes virtual Mesh_ptr -- 2.39.2