From 6a053b2b341e129f9b572c2a415ab72344658b90 Mon Sep 17 00:00:00 2001 From: apo Date: Wed, 27 Jun 2007 07:48:19 +0000 Subject: [PATCH] Implementation of the first task of the VISU/MULTIPR industrialization project - "Automatic refresh 3D viewer after changing level of details" --- idl/VISU_Gen.idl | 3 +- src/CONVERTOR/VISU_Convertor.cxx | 24 + src/CONVERTOR/VISU_Convertor.hxx | 12 +- src/CONVERTOR/VISU_Convertor_impl.cxx | 6 +- src/CONVERTOR/VISU_MedConvertor.cxx | 3 +- src/CONVERTOR/VISU_MedConvertor.hxx | 2 - src/VISUGUI/VisuGUI.cxx | 116 +- src/VISUGUI/VisuGUI_InputPane.cxx | 2 +- src/VISUGUI/VisuGUI_PopupTools.cxx | 31 + src/VISUGUI/VisuGUI_PopupTools.h | 1 + .../VisuGUI_ScalarMapOnDeformedShapeDlg.cxx | 2 +- src/VISU_I/Makefile.am | 7 +- src/VISU_I/SALOME_GenericObjPointer.hh | 8 + src/VISU_I/VISUConfig.cc | 107 +- src/VISU_I/VISUConfig.hh | 10 + src/VISU_I/VISU_ColoredPrs3d_i.cc | 20 + src/VISU_I/VISU_ColoredPrs3d_i.hh | 11 + src/VISU_I/VISU_DeformedShape_i.cc | 2 +- src/VISU_I/VISU_GaussPoints_i.cc | 77 +- src/VISU_I/VISU_GaussPoints_i.hh | 11 +- src/VISU_I/VISU_Gen_i.cc | 44 +- src/VISU_I/VISU_Mesh_i.cc | 2 +- src/VISU_I/VISU_MultiResult_i.cc | 628 ++++++++ src/VISU_I/VISU_MultiResult_i.hh | 125 ++ src/VISU_I/VISU_ResultUtils.cc | 605 +++++++ src/VISU_I/VISU_ResultUtils.hh | 110 ++ src/VISU_I/VISU_Result_i.cc | 1387 ++--------------- src/VISU_I/VISU_Result_i.hh | 270 ++-- src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc | 4 +- src/VISU_I/VISU_ScalarMap_i.cc | 6 +- src/VISU_I/VISU_StreamLines_i.cc | 2 +- src/VISU_I/VISU_Vectors_i.cc | 2 +- 32 files changed, 2112 insertions(+), 1528 deletions(-) create mode 100644 src/VISU_I/VISU_MultiResult_i.cc create mode 100644 src/VISU_I/VISU_MultiResult_i.hh create mode 100644 src/VISU_I/VISU_ResultUtils.cc create mode 100644 src/VISU_I/VISU_ResultUtils.hh diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index 560a870a..5bc063ed 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -60,7 +60,8 @@ module VISU { enum Entity{ NODE, /*!< Node corresponds to a geometrical point. */ EDGE, /*!< Edge corresponds to a geometrical line connecting two points. */ FACE, /*!< Face corresponds to a geometrical plane bounded by several lines. */ - CELL /*!< Cell is a volumic element of a mesh */ + CELL, /*!< Cell is a volumic element of a mesh */ + NONE /*!< Indicates undefined entity value */ }; /*! diff --git a/src/CONVERTOR/VISU_Convertor.cxx b/src/CONVERTOR/VISU_Convertor.cxx index 1c6fd8d8..2526962b 100644 --- a/src/CONVERTOR/VISU_Convertor.cxx +++ b/src/CONVERTOR/VISU_Convertor.cxx @@ -32,6 +32,30 @@ #include +//--------------------------------------------------------------- +VISU_Convertor +::VISU_Convertor(): + myIsDone(false) +{} + + +//--------------------------------------------------------------- +const std::string& +VISU_Convertor +::GetName() +{ + return myName; +} + + +//--------------------------------------------------------------- +int +VISU_Convertor +::IsDone() const +{ + return myIsDone; +} + //--------------------------------------------------------------- const VISU::TMeshMap& VISU_Convertor diff --git a/src/CONVERTOR/VISU_Convertor.hxx b/src/CONVERTOR/VISU_Convertor.hxx index 45edc030..c5819c08 100644 --- a/src/CONVERTOR/VISU_Convertor.hxx +++ b/src/CONVERTOR/VISU_Convertor.hxx @@ -52,19 +52,15 @@ class VISU_CONVERTOR_EXPORT VISU_Convertor { public: - virtual - ~VISU_Convertor() - {}; - //! Get brief name of the corresponding source MED file virtual const std::string& - GetName(){ return myName;} + GetName(); //! Let known whether the source MED file parsed or not virtual int - IsDone() const { return myIsDone; } + IsDone() const; //! This method perform first parsing of MED file to get known what MED entities are pressent in it virtual @@ -205,6 +201,8 @@ public: GenerateName(const std::string& theName, unsigned int theTimeId); protected: + VISU_Convertor(); + std::string myName; VISU::TMeshMap myMeshMap; int myIsDone; @@ -212,8 +210,8 @@ protected: extern "C" { -VISU_CONVERTOR_EXPORT //! Instatiate proper VISU_Convertor subclass + VISU_CONVERTOR_EXPORT VISU_Convertor* CreateConvertor(const std::string& theFileName); }; diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index c2cd8893..b71a5712 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -563,10 +563,8 @@ namespace //--------------------------------------------------------------- VISU_Convertor_impl -::VISU_Convertor_impl() -{ - myIsDone = false; -} +::VISU_Convertor_impl() +{} //--------------------------------------------------------------- diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index 31cf0d9d..5cb62105 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -1328,8 +1328,7 @@ VISU_MedConvertor myIsMinMaxDone(false), myMed(theMed) { - myFileInfo.setFile(QString(theFileName.c_str())); - myName = myFileInfo.baseName().latin1(); + myName = theFileName; } diff --git a/src/CONVERTOR/VISU_MedConvertor.hxx b/src/CONVERTOR/VISU_MedConvertor.hxx index e3834ab2..7b2c6b80 100644 --- a/src/CONVERTOR/VISU_MedConvertor.hxx +++ b/src/CONVERTOR/VISU_MedConvertor.hxx @@ -31,7 +31,6 @@ #include "MED_GaussUtils.hxx" #include -#include namespace VISU { @@ -357,7 +356,6 @@ public: BuildGroups(); protected: - QFileInfo myFileInfo; MED::PWrapper myMed; // mpv : bug 13568: one med per converter virtual diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 7955acb0..311657fe 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -215,7 +215,6 @@ VisuGUI application()->putInfo( anInfo ); QApplication::setOverrideCursor(Qt::waitCursor); - // MULTIPR: CreateResult VISU::Result_var aResult = GetVisuGen(this)->CreateResult( aFileInfo.filePath() ); if (CORBA::is_nil(aResult.in())) { @@ -2281,8 +2280,6 @@ VisuGUI tr("MEN_CACHE_PROPERTIES"), "", 0, aParent, false, this, SLOT(OnCacheProperties())); -#ifdef ENABLE_MULTIPR - // MULTIPR aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_MULTIPR_VIEW_FULL")); createAction( VISU_MULTIPR_FULL_RES, tr("MEN_MULTIPR_VIEW_FULL_RES"), QIconSet(aPixmap), tr("MEN_MULTIPR_VIEW_FULL_RES"), "", 0, aParent, false, @@ -2302,7 +2299,6 @@ VisuGUI createAction( VISU_MULTIPR_HIDE, tr("MEN_MULTIPR_VIEW_HIDE"), QIconSet(aPixmap), tr("MEN_MULTIPR_VIEW_HIDE"), "", 0, aParent, false, this, SLOT(OnMultiprViewHide())); -#endif } void @@ -2480,14 +2476,10 @@ VisuGUI mgr->insert( action( VISU_SELECTION_INFO ), -1, -1, -1 ); // Selection info -#ifdef ENABLE_MULTIPR - // MULTIPR mgr->insert( action( VISU_MULTIPR_FULL_RES ), -1, -1, -1 ); mgr->insert( action( VISU_MULTIPR_MED_RES ), -1, -1, -1 ); mgr->insert( action( VISU_MULTIPR_LOW_RES ), -1, -1, -1 ); mgr->insert( action( VISU_MULTIPR_HIDE ), -1, -1, -1 ); -#endif - // Rules @@ -2663,14 +2655,11 @@ VisuGUI //aRule = "client='ObjectBrowser' and type='MEDFIELD'"; //mgr->setRule( action( VISU_IMPORT_MED ), aRule, true ); -#ifdef ENABLE_MULTIPR - // MULTIPR - aRule = "client='ObjectBrowser' and $type in {'VISU::TPART'}"; - mgr->setRule( action( VISU_MULTIPR_FULL_RES ), aRule + " and selcount>=1", true ); - mgr->setRule( action( VISU_MULTIPR_MED_RES ), aRule + " and selcount>=1", true ); - mgr->setRule( action( VISU_MULTIPR_LOW_RES ), aRule + " and selcount>=1", true ); - mgr->setRule( action( VISU_MULTIPR_HIDE), aRule + " and selcount>=1", true ); -#endif + aRule = "client='ObjectBrowser' and $type in {'VISU::TPART'} and selcount>=1"; + mgr->setRule( action( VISU_MULTIPR_FULL_RES ), aRule, true ); + mgr->setRule( action( VISU_MULTIPR_MED_RES ), aRule, true ); + mgr->setRule( action( VISU_MULTIPR_LOW_RES ), aRule, true ); + mgr->setRule( action( VISU_MULTIPR_HIDE), aRule, true ); } //*************************************************************************** @@ -3458,42 +3447,38 @@ void VisuGUI::OnCacheProperties() aDlg->exec(); } -// MULTIPR + +//--------------------------------------------------------------- void VisuGUI::OnMultiprViewFullRes() { -#ifdef ENABLE_MULTIPR - OnMultiprChangeRes('F'); -#endif + OnMultiprChangeRes('F'); } -// MULTIPR + +//--------------------------------------------------------------- void VisuGUI::OnMultiprViewMediumRes() { -#ifdef ENABLE_MULTIPR - OnMultiprChangeRes('M'); -#endif + OnMultiprChangeRes('M'); } -// MULTIPR + +//--------------------------------------------------------------- void VisuGUI::OnMultiprViewLowRes() { -#ifdef ENABLE_MULTIPR - OnMultiprChangeRes('L'); -#endif + OnMultiprChangeRes('L'); } -// MULTIPR + +//--------------------------------------------------------------- void VisuGUI::OnMultiprViewHide() { -#ifdef ENABLE_MULTIPR - OnMultiprChangeRes('H'); -#endif + OnMultiprChangeRes('H'); } -// MULTIPR -void VisuGUI::OnMultiprChangeRes(char resolution) + +//--------------------------------------------------------------- +void VisuGUI::OnMultiprChangeRes(char theResolution) { -#ifdef ENABLE_MULTIPR _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this)); if (CheckLock(aCStudy,GetDesktop(this))) return; @@ -3502,10 +3487,11 @@ void VisuGUI::OnMultiprChangeRes(char resolution) if(aSelectionInfo.empty()) return; - //cout << "selection: #=" << aSelectionInfo.size() << endl; + typedef SALOME::GenericObjPtr TResultPtr; + typedef std::set TResultSet; + TResultSet aResultSet; - for (int i=0; i(VISU::GetServant(aResult).in()); + if(CORBA::is_nil(aResult.in())) + continue; + + VISU::Result_i* aCResult = dynamic_cast(VISU::GetServant(aResult).in()); + if(!aCResult) + continue; - _PTR(GenericAttribute) anAttr; - if (aSObject->FindAttribute(anAttr, "AttributePixMap")) - { - _PTR(AttributePixMap) aPixMap(anAttr); - if ( aPixMap->HasPixMap() ) - { - const char* oldIcon = aPixMap->GetPixMap().c_str(); - if ( (strcmp(oldIcon, "ICON_MULTIPR_VIEW_FULL") == 0) || - (strcmp(oldIcon, "ICON_MULTIPR_VIEW_MEDIUM") == 0) || - (strcmp(oldIcon, "ICON_MULTIPR_VIEW_LOW") == 0) || - (strcmp(oldIcon, "ICON_MULTIPR_VIEW_HIDE") == 0) ) - { - bool hasMediumOrLow = (strstr(aSObject->GetComment().c_str(), "res=FML") != NULL); - - if (resolution == 'F') - { - if (result != NULL) result->SetResolutionMultipr(aSObject->GetName().c_str(), 'F'); - aPixMap->SetPixMap("ICON_MULTIPR_VIEW_FULL"); - } - else if ((resolution == 'M') && hasMediumOrLow) - { - if (result != NULL) result->SetResolutionMultipr(aSObject->GetName().c_str(), 'M'); - aPixMap->SetPixMap("ICON_MULTIPR_VIEW_MEDIUM"); - } - else if ((resolution == 'L') && hasMediumOrLow) - { - if (result != NULL) result->SetResolutionMultipr(aSObject->GetName().c_str(), 'L'); - aPixMap->SetPixMap("ICON_MULTIPR_VIEW_LOW"); - } - else if (resolution == 'H') - { - if (result != NULL) result->SetResolutionMultipr(aSObject->GetName().c_str(), 'H'); - aPixMap->SetPixMap("ICON_MULTIPR_VIEW_HIDE"); - } - } - } - } + aResultSet.insert(TResultPtr(aCResult)); + aCResult->SetResolution(aSObject->GetName().c_str(), theResolution); + } + + // To update all result observers + TResultSet::const_iterator anIter = aResultSet.begin(); + for(; anIter != aResultSet.end(); anIter++){ + const TResultPtr& aResultPtr = *anIter; + aResultPtr->UpdateObservers(); } UpdateObjBrowser(this, false); -#endif } diff --git a/src/VISUGUI/VisuGUI_InputPane.cxx b/src/VISUGUI/VisuGUI_InputPane.cxx index 4f7379bb..82d03a41 100644 --- a/src/VISUGUI/VisuGUI_InputPane.cxx +++ b/src/VISUGUI/VisuGUI_InputPane.cxx @@ -485,7 +485,7 @@ void VisuGUI_InputPane::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs ) VISU::GetSelectionMgr( myModule )->installFilter( myFieldFilter ); // type of presentation and groups - VISU_Convertor* anInput = aResult->GetInput(); + VISU::Result_i::PInput anInput = aResult->GetInput(); const VISU::TMeshMap& aMeshMap = anInput->GetMeshMap(); std::string aMeshName = thePrs->GetCMeshName(); VISU::TMeshMap::const_iterator aMeshIter = aMeshMap.find(aMeshName); diff --git a/src/VISUGUI/VisuGUI_PopupTools.cxx b/src/VISUGUI/VisuGUI_PopupTools.cxx index 043db8bd..c46f165d 100644 --- a/src/VISUGUI/VisuGUI_PopupTools.cxx +++ b/src/VISUGUI/VisuGUI_PopupTools.cxx @@ -45,12 +45,15 @@ using namespace VISU; // Class: VisuGUI_Selection ////////////////////////////////////////////////// + +//--------------------------------------------------------------- QtxValue VisuGUI_Selection::param( const int ind, const QString& p ) const { QtxValue val( LightApp_Selection::param( ind, p ) ); if ( !val.isValid() ) { if ( p == "type" ) val = QtxValue( type( ind ) ); else if ( p == "nbComponents" ) val = QtxValue( nbComponents( ind ) ); + else if ( p == "resolution" ) val = QtxValue( resolution( ind ) ); else if ( p == "medEntity" ) val = QtxValue( medEntity( ind ) ); else if ( p == "medSource" ) val = QtxValue( medSource( ind ) ); else if ( p == "representation" ) val = QtxValue( representation( ind ) ); @@ -68,6 +71,8 @@ QtxValue VisuGUI_Selection::param( const int ind, const QString& p ) const return val; } + +//--------------------------------------------------------------- // Macro for converting VISU enumeration items into corresponding strings #define ENUM2STRING( x, y ) \ case y: \ @@ -134,6 +139,8 @@ QString VisuGUI_Selection::type( const int ind ) const return aResStr; } + +//--------------------------------------------------------------- QString VisuGUI_Selection::nbComponents( const int ind ) const { QString aResStr; @@ -151,6 +158,28 @@ QString VisuGUI_Selection::nbComponents( const int ind ) const return aResStr; } + +//--------------------------------------------------------------- +QString VisuGUI_Selection::resolution( const int ind ) const +{ + QString aResStr; + SalomeApp_Study* aStudy = GetStudy(); + if ( !aStudy ) + return aResStr; + + VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, entry( ind )); + VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(anObjectInfo.mySObject); + + bool isExist; + QString aVal = VISU::Storable::FindValue(aMap,"myState",&isExist); + if ( isExist ) + aResStr = aVal; + + return aResStr; +} + + +//--------------------------------------------------------------- QString VisuGUI_Selection::medEntity( const int ind ) const { SalomeApp_Study* aStudy = GetStudy(); @@ -451,6 +480,8 @@ struct TIsScalarMapActFunctor: TViewFunctor } }; + +//--------------------------------------------------------------- QString VisuGUI_Selection::isScalarMapAct( const int ind ) const { return TPopupDispatcher()(myModule, entry(ind)); diff --git a/src/VISUGUI/VisuGUI_PopupTools.h b/src/VISUGUI/VisuGUI_PopupTools.h index 536ef59a..aef18963 100644 --- a/src/VISUGUI/VisuGUI_PopupTools.h +++ b/src/VISUGUI/VisuGUI_PopupTools.h @@ -48,6 +48,7 @@ public: private: QString type( const int ) const; QString nbComponents( const int ) const; + QString resolution( const int ) const; QString medEntity( const int ) const; QString medSource( const int ) const; QString nbTimeStamps( const int ) const; diff --git a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx index 13c8046d..bf8d48e4 100644 --- a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx +++ b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx @@ -460,7 +460,7 @@ VisuGUI_ScalarMapOnDeformedShapeDlg QString aTime(""); VISU::TEntity anEntity = VISU::TEntity(theEntity); VISU::Result_i* theResult = myPrsCopy->GetCResult(); - VISU::Result_i::TInput* anInput = theResult->GetInput(); + VISU::Result_i::PInput anInput = theResult->GetInput(); VISU::PField aField = anInput->GetField(myPrsCopy->GetCMeshName(), anEntity, theFieldName); diff --git a/src/VISU_I/Makefile.am b/src/VISU_I/Makefile.am index f75be372..2887c6d6 100644 --- a/src/VISU_I/Makefile.am +++ b/src/VISU_I/Makefile.am @@ -31,6 +31,7 @@ salomeinclude_HEADERS = \ VISUConfig.hh \ VISU_Gen_i.hh \ VISU_Result_i.hh \ + VISU_MultiResult_i.hh \ VISU_PrsObject_i.hh \ VISU_Table_i.hh \ VISU_Prs3d_i.hh \ @@ -53,8 +54,11 @@ salomeinclude_HEADERS = \ SALOME_GenericObjPointer.hh libVISUEngineImpl_la_SOURCES = \ - VISU_Result_i.cc \ VISUConfig.cc \ + VISU_Result_i.cc \ + VISU_ResultUtils.cc \ + VISU_MultiResult_i.cc \ + VISU_CorbaMedConvertor.cxx \ VISU_PrsObject_i.cc \ VISU_Prs3d_i.cc \ VISU_ColoredPrs3d_i.cc \ @@ -77,7 +81,6 @@ libVISUEngineImpl_la_SOURCES = \ VISU_View_i.cc \ VISU_Table_i.cc \ VISU_Gen_i.cc \ - VISU_CorbaMedConvertor.cxx \ VISU_DumpPython.cc \ SALOME_GenericObjPointer.cc diff --git a/src/VISU_I/SALOME_GenericObjPointer.hh b/src/VISU_I/SALOME_GenericObjPointer.hh index e710a4f0..72849849 100644 --- a/src/VISU_I/SALOME_GenericObjPointer.hh +++ b/src/VISU_I/SALOME_GenericObjPointer.hh @@ -153,6 +153,14 @@ namespace SALOME }; } +template +inline +bool +operator<(SALOME::GenericObjPtr const & a, SALOME::GenericObjPtr const & b) +{ + return a.get() < b.get(); +} + template inline bool diff --git a/src/VISU_I/VISUConfig.cc b/src/VISU_I/VISUConfig.cc index 0b7bad1f..bcde9828 100644 --- a/src/VISU_I/VISUConfig.cc +++ b/src/VISU_I/VISUConfig.cc @@ -33,6 +33,10 @@ #include "SALOMEDSClient_AttributeIOR.hxx" #include "SalomeApp_Application.h" +#include "SalomeApp_Study.h" + +#include "SALOME_Event.hxx" + #include using namespace std; @@ -57,7 +61,7 @@ namespace VISU{ return GetSession()->resourceMgr(); } - //=========================================================================== + //--------------------------------------------------------------------------- QMutex* Base_i::myMutex = NULL; //apo - &VISUMutex; CORBA::ORB_var Base_i::myOrb; @@ -79,7 +83,7 @@ namespace VISU{ return CORBA::string_dup(myID.c_str()); } - //=========================================================================== + //--------------------------------------------------------------------------- static int mySCnt = 0; static QMutex aMutex(TRUE); @@ -98,7 +102,7 @@ namespace VISU{ } - //=========================================================================== + //--------------------------------------------------------------------------- static Storable::TCallbackMap VisuStoreMap; std::string @@ -361,6 +365,8 @@ namespace VISU{ theStr<FindOrCreateAttribute(aNewSObject, "AttributeIOR"); SALOMEDS::AttributeIOR_var aCustomAttr = SALOMEDS::AttributeIOR::_narrow(anAttr); aCustomAttr->SetValue(theIOR.c_str()); } - if(theName != ""){ + if(theName != NO_NAME){ anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributeName"); SALOMEDS::AttributeName_var aCustomAttr = SALOMEDS::AttributeName::_narrow(anAttr); aCustomAttr->SetValue(theName.c_str()); } - if(thePersistentRef != ""){ + if(thePersistentRef != NO_PERFSITENT_REF){ anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributePersistentRef"); SALOMEDS::AttributePersistentRef_var aCustomAttr = SALOMEDS::AttributePersistentRef::_narrow(anAttr); aCustomAttr->SetValue(thePersistentRef.c_str()); } - if(theComment != ""){ + if(theComment != NO_COMMENT){ anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributeString"); SALOMEDS::AttributeString_var aCustomAttr = SALOMEDS::AttributeString::_narrow(anAttr); aCustomAttr->SetValue(theComment.c_str()); } - if(theIconName != ""){ + if(theIconName != NO_ICON){ anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributePixMap"); SALOMEDS::AttributePixMap_var aCustomAttr = SALOMEDS::AttributePixMap::_narrow(anAttr); aCustomAttr->SetPixMap(theIconName.c_str()); @@ -580,27 +592,27 @@ namespace VISU{ aNewSObject = aFather; _PTR(GenericAttribute) anAttr; - if (theIOR != "") { + if (theIOR != NO_IOR) { anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributeIOR"); _PTR(AttributeIOR) aCustomAttr (anAttr); aCustomAttr->SetValue(theIOR); } - if (theName != "") { + if (theName != NO_NAME) { anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributeName"); _PTR(AttributeName) aCustomAttr (anAttr); aCustomAttr->SetValue(theName); } - if (thePersistentRef != "") { + if (thePersistentRef != NO_PERFSITENT_REF) { anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributePersistentRef"); _PTR(AttributePersistentRef) aCustomAttr (anAttr); aCustomAttr->SetValue(thePersistentRef); } - if (theComment != "") { + if (theComment != NO_COMMENT) { anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributeString"); _PTR(AttributeString) aCustomAttr (anAttr); aCustomAttr->SetValue(theComment); } - if (theIconName != "") { + if (theIconName != NO_ICON) { anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributePixMap"); _PTR(AttributePixMap) aCustomAttr (anAttr); aCustomAttr->SetPixMap(theIconName); @@ -612,6 +624,8 @@ namespace VISU{ return aRet; } + + //--------------------------------------------------------------- QString GenerateName(const string& theFmt, int theId) { @@ -624,6 +638,7 @@ namespace VISU{ } + //--------------------------------------------------------------- SALOMEDS::StudyManager_var GetStudyManager() { @@ -637,15 +652,60 @@ namespace VISU{ } + //--------------------------------------------------------------- SALOMEDS::Study_var GetDSStudy(_PTR(Study) theStudy) { - //std::string aStudyName = theStudy->Name(); - //return GetStudyManager()->GetStudyByName(aStudyName.c_str()); int aStudyID = theStudy->StudyId(); return GetStudyManager()->GetStudyByID(aStudyID); } + + //--------------------------------------------------------------- + struct TGetStudyEvent: public SALOME_Event + { + int myStudyId; + + typedef _PTR(Study) TResult; + TResult myResult; + + TGetStudyEvent(int theStudyId): + myStudyId(theStudyId) + {} + + virtual + void + Execute() + { + SUIT_Session* aSession = SUIT_Session::session(); + QPtrList anApplications = aSession->applications(); + QPtrListIterator anIter (anApplications); + while (SUIT_Application* anApp = anIter.current()) { + ++anIter; + if (SUIT_Study* aSStudy = anApp->activeStudy()) { + if (SalomeApp_Study* aStudy = dynamic_cast(aSStudy)) { + if (_PTR(Study) aCStudy = aStudy->studyDS()) { + if (myStudyId == aCStudy->StudyId()) { + myResult = aCStudy; + break; + } + } + } + } + } + } + }; + + + //--------------------------------------------------------------- + _PTR(Study) + GetStudy(SALOMEDS::Study_var theStudy) + { + return ProcessEvent(new TGetStudyEvent(theStudy->StudyId())); + } + + + //--------------------------------------------------------------- SALOMEDS::SObject_var GetSObject( _PTR(SObject) obj ) { @@ -655,15 +715,18 @@ namespace VISU{ return aSalomeDSStudy->FindObjectID( id.c_str() ); } + //--------------------------------------------------------------- _PTR(SObject) GetClientSObject( SALOMEDS::SObject_var obj, _PTR(Study) study ) { - return study->FindObjectID( obj->GetID() ); + CORBA::String_var anEntry = obj->GetID(); + return study->FindObjectID( anEntry.in() ); } + //--------------------------------------------------------------- void RemoveFromStudy (SALOMEDS::SObject_ptr theSObject, bool theIsAttrOnly, @@ -707,6 +770,8 @@ namespace VISU{ aStudyBuilder->RemoveObjectWithChildren(theSObject); } + + //--------------------------------------------------------------- void RemoveFromStudy (_PTR(SObject) theSObject, bool theIsAttrOnly, diff --git a/src/VISU_I/VISUConfig.hh b/src/VISU_I/VISUConfig.hh index ef3ff038..58206b2a 100644 --- a/src/VISU_I/VISUConfig.hh +++ b/src/VISU_I/VISUConfig.hh @@ -247,6 +247,12 @@ namespace VISU SALOMEDS::SComponent_var FindOrCreateVisuComponent(SALOMEDS::Study_ptr theStudyDocument); + const char* const NO_ICON = ""; + const char* const NO_IOR = ""; + const char* const NO_NAME = ""; + const char* const NO_PERFSITENT_REF = ""; + const char* const NO_COMMENT = ""; + VISU_I_EXPORT std::string CreateAttributes(SALOMEDS::Study_ptr theStudyDocument, @@ -281,6 +287,10 @@ namespace VISU SALOMEDS::Study_var GetDSStudy(_PTR(Study)); + VISU_I_EXPORT + _PTR(Study) + GetStudy(SALOMEDS::Study_var); + VISU_I_EXPORT void RemoveFromStudy(SALOMEDS::SObject_ptr theSObject, diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.cc b/src/VISU_I/VISU_ColoredPrs3d_i.cc index 13246cfc..58423840 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3d_i.cc @@ -114,6 +114,25 @@ VISU::ColoredPrs3d_i ProcessVoidEvent(new TRemoveFromStudy(this)); } + +//---------------------------------------------------------------------------- +void +VISU::ColoredPrs3d_i +::UpdateFromResult(Result_i* theResult) +{ + try{ + if(theResult == GetCResult()){ + DoSetInput(false, false); + UpdateActors(); + } + }catch(std::exception& exc){ + INFOS("Follow exception was occured :\n"<ConnectObserver(this, myResultConnection); }catch(std::exception& exc){ INFOS("Follow exception was occured :\n"<GetInput(); + VISU::Result_i::PInput anInput = theResult->GetInput(); VISU::PField aField = anInput->GetField(theMeshName, (VISU::TEntity)theEntity, theFieldName); diff --git a/src/VISU_I/VISU_GaussPoints_i.cc b/src/VISU_I/VISU_GaussPoints_i.cc index 679dd5d7..be1570a5 100644 --- a/src/VISU_I/VISU_GaussPoints_i.cc +++ b/src/VISU_I/VISU_GaussPoints_i.cc @@ -47,10 +47,6 @@ #include #include -#ifdef ENABLE_MULTIPR -#include "MULTIPR_API.hxx" -#endif - #ifdef _DEBUG_ static int MYDEBUG = 0; #else @@ -74,7 +70,10 @@ VISU::GaussPoints_i return aResult; try{ bool anIsEstimated = true; - VISU::Result_i::TInput* anInput = theResult->GetInput(); + VISU::Result_i::PInput anInput = theResult->GetInput(theMeshName, + theEntity, + theFieldName, + theTimeStampNumber); size_t aSize = anInput->GetTimeStampOnGaussPtsSize(theMeshName, (VISU::TEntity)theEntity, theFieldName, @@ -615,60 +614,24 @@ void VISU::GaussPoints_i ::DoSetInput(bool theIsInitilizePipe, bool theReInit) { - static string aStrPrev = ""; - static VISU::Result_i::TInput* anInputPrev = NULL; - - // MULTIPR - VISU::Result_i::TInput* anInput = NULL; -#ifdef ENABLE_MULTIPR - if (GetCResult()->IsDistributedMEDMultipr()) - { - vector aListMEDFiles = GetCResult()->GetCurrentRepresentationMultipr(); - - string aStrCurrent = ""; - for (unsigned i = 0 ; i < aListMEDFiles.size() ; i++) - { - aStrCurrent +=aListMEDFiles[i]; - } - aStrCurrent += GetCMeshName(); - aStrCurrent += GetCFieldName(); - if (aStrPrev != aStrCurrent) - { - if (anInputPrev != NULL) delete anInputPrev; - - char aTmpFilename[256]; - sprintf(aTmpFilename, "__tmp.med"); - - int res = multipr::merge(aListMEDFiles, GetCMeshName().c_str(), GetCFieldName().c_str(), aTmpFilename); - if (res == 0) throw std::runtime_error("empty mesh"); - - anInput = CreateConvertor(aTmpFilename); - anInput->Build(); - anInputPrev = anInput; - - aStrPrev = aStrCurrent; - } - else - { - anInput = anInputPrev; - } - } - else -#endif - { - anInput = GetCResult()->GetInput(); - } - + VISU::Result_i::PInput anInput = GetCResult()->GetInput(GetCMeshName(), + GetEntity(), + GetCFieldName(), + GetTimeStampNumber()); if(!anInput) throw std::runtime_error("Mesh_i::Build - myResult->GetInput() == NULL !!!"); - SetField(anInput->GetField(GetCMeshName(),GetTEntity(),GetCFieldName())); + SetField(anInput->GetField(GetCMeshName(), + GetTEntity(), + GetCFieldName())); if(!GetField()) throw std::runtime_error("There is no Field with the parameters !!!"); VISU::PGaussPtsIDMapper aGaussPtsIDMapper = - anInput->GetTimeStampOnGaussPts(GetCMeshName(),GetTEntity(),GetCFieldName(),GetTimeStampNumber()); - + anInput->GetTimeStampOnGaussPts(GetCMeshName(), + GetTEntity(), + GetCFieldName(), + GetTimeStampNumber()); if(!aGaussPtsIDMapper) throw std::runtime_error("There is no TimeStamp with the parameters !!!"); @@ -676,7 +639,6 @@ VISU::GaussPoints_i if(theIsInitilizePipe){ GetSpecificPL()->Init(); } - GetCResult()->MinMaxConnect(this); // To update scalar range according to the new input if(!IsTimeStampFixed() || theReInit) @@ -1044,12 +1006,3 @@ VISU::GaussPoints_i { return mySpacing; } - -//---------------------------------------------------------------------------- -void -VISU::GaussPoints_i -::UpdateMinMax() -{ - MinMaxCunsomer::UpdateMinMax(); - UpdateActors(); -} diff --git a/src/VISU_I/VISU_GaussPoints_i.hh b/src/VISU_I/VISU_GaussPoints_i.hh index b4b150ec..bfe90d1c 100644 --- a/src/VISU_I/VISU_GaussPoints_i.hh +++ b/src/VISU_I/VISU_GaussPoints_i.hh @@ -27,7 +27,6 @@ #ifndef VISU_GaussPoints_i_HeaderFile #define VISU_GaussPoints_i_HeaderFile -#include "VISU_Result_i.hh" #include "VISU_ColoredPrs3d_i.hh" #include "VISU_GaussPtsActorFactory.h" @@ -40,9 +39,8 @@ namespace VISU { //! Class of the Gauss Points presentation. class VISU_I_EXPORT GaussPoints_i : public virtual POA_VISU::GaussPoints, - public virtual VISU::TGaussPtsActorFactory, - public virtual MinMaxCunsomer, - public virtual ColoredPrs3d_i + public virtual TGaussPtsActorFactory, + public virtual ColoredPrs3d_i { static int myNbPresent; GaussPoints_i(const GaussPoints_i&); @@ -250,11 +248,6 @@ namespace VISU void SetSourceRange(); - //! To update the min / max automatically - virtual - void - UpdateMinMax(); - VISU_GaussPointsPL* GetSpecificPL() const { diff --git a/src/VISU_I/VISU_Gen_i.cc b/src/VISU_I/VISU_Gen_i.cc index dcd5ae50..cddc42c4 100644 --- a/src/VISU_I/VISU_Gen_i.cc +++ b/src/VISU_I/VISU_Gen_i.cc @@ -646,9 +646,9 @@ namespace VISU return Result::_nil(); Mutex mt(myMutex); aFileInfo.setFile(theFileName); - Result_i* pResult = new Result_i(myStudyDocument, - Result_i::eFile, - Result_i::eImportFile); + Result_i* pResult = Result_i::New(myStudyDocument, + Result_i::eFile, + Result_i::eImportFile); if(pResult->Create(theFileName) != NULL) return pResult->_this(); else{ @@ -667,10 +667,10 @@ namespace VISU return Result::_nil(); Mutex mt(myMutex); aFileInfo.setFile(theFileName); - Result_i* pResult = new Result_i(myStudyDocument, - Result_i::eFile, - Result_i::eImportFile, - false); + Result_i* pResult = Result_i::New(myStudyDocument, + Result_i::eFile, + Result_i::eImportFile, + false); if(pResult->Create(theFileName) != NULL) return pResult->_this(); else{ @@ -690,9 +690,9 @@ namespace VISU Mutex mt(myMutex); VISU::Result_var aResult; aFileInfo.setFile(theFileName); - Result_i* pResult = new Result_i(myStudyDocument, - Result_i::eRestoredFile, - Result_i::eCopyAndImportFile); + Result_i* pResult = Result_i::New(myStudyDocument, + Result_i::eRestoredFile, + Result_i::eCopyAndImportFile); if(pResult->Create(theFileName) != NULL) aResult = pResult->_this(); return aResult._retn(); @@ -707,9 +707,9 @@ namespace VISU if (myStudyDocument->GetProperties()->IsLocked()) return Result::_nil(); Mutex mt(myMutex); - Result_i* pResult = new Result_i(myStudyDocument, - Result_i::eComponent, - Result_i::eImportMed); + Result_i* pResult = Result_i::New(myStudyDocument, + Result_i::eComponent, + Result_i::eImportMed); if (pResult->Create(theMedSObject) != NULL) { return pResult->_this(); } else { @@ -727,9 +727,9 @@ namespace VISU if (myStudyDocument->GetProperties()->IsLocked()) return Result::_nil(); Mutex mt(myMutex); - Result_i* pResult = new Result_i(myStudyDocument, - Result_i::eComponent, - Result_i::eImportMedField); + Result_i* pResult = Result_i::New(myStudyDocument, + Result_i::eComponent, + Result_i::eImportMedField); if (pResult->Create(theField) != NULL) { return pResult->_this(); } else { @@ -1209,16 +1209,18 @@ namespace VISU return false; } - SALOMEDS::TMPFile* VISU_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) { + SALOMEDS::TMPFile* + VISU_Gen_i + ::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) + { Mutex mt(myMutex); theObjectID = 0; SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile; SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; - PortableServer::POA_ptr aPOA = GetPOA(); - SALOMEDS::GenericAttribute_var anAttr; - if (!theObject->FindAttribute(anAttr,"AttributeIOR")) return NULL; + if (!theObject->FindAttribute(anAttr,"AttributeIOR")) + return NULL; SALOMEDS::AttributeIOR_var anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr); CORBA::Object_var aCorbaObj; try { @@ -1245,7 +1247,7 @@ namespace VISU stmOut2<(aPOA->reference_to_servant(aCorbaObj))) { + if (Result_i* aResultObj = dynamic_cast(GetServant(aCorbaObj).in())) { string aFileName = string(SALOMEDS_Tool::GetNameFromPath(theObject->GetStudy()->URL())) + "_"; if(strlen(aFileName.c_str()) == 1) aFileName=""; const QFileInfo& aFileInfo = aResultObj->GetFileInfo(); diff --git a/src/VISU_I/VISU_Mesh_i.cc b/src/VISU_I/VISU_Mesh_i.cc index 46f3b151..5df41e26 100644 --- a/src/VISU_I/VISU_Mesh_i.cc +++ b/src/VISU_I/VISU_Mesh_i.cc @@ -214,7 +214,7 @@ VISU::Mesh_i aRestoringMap["myMeshName"] = GetCMeshName(); VISU::PUnstructuredGridIDMapper anIDMapper; - VISU::Result_i::TInput* anInput = GetCResult()->GetInput(); + VISU::Result_i::PInput anInput = GetCResult()->GetInput(); switch(myType){ case VISU::TENTITY : anIDMapper = anInput->GetMeshOnEntity(aMeshName, diff --git a/src/VISU_I/VISU_MultiResult_i.cc b/src/VISU_I/VISU_MultiResult_i.cc new file mode 100644 index 00000000..012c00b6 --- /dev/null +++ b/src/VISU_I/VISU_MultiResult_i.cc @@ -0,0 +1,628 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File : VISU_MultiResult_i.cc +// Author : Alexey PETROV +// Module : VISU + +#ifdef ENABLE_MULTIPR + +#include "VISU_MultiResult_i.hh" +#include "VISU_ResultUtils.hh" + +#include "VISU_Convertor.hxx" + +#include "MULTIPR_API.hxx" +#include "MULTIPR_Obj.hxx" + +#include "SALOMEDS_Tool.hxx" + +#include +#include + +#include + + +namespace VISU +{ + //--------------------------------------------------------------- + inline + std::string + ExtractMainPart(const std::string& thePartName) + { + size_t aPos = thePartName.rfind('_'); + if(aPos == std::string::npos) + return thePartName; + + std::string aSuffix = thePartName.substr(aPos); + if(aSuffix == "_MED" || aSuffix == "_LOW") + return thePartName.substr(0, aPos); + + return thePartName; + } + + + //--------------------------------------------------------------- + inline + bool + IsSubString(const std::string& theSource, + const std::string& theSubString) + { + return theSource.rfind(theSubString) != std::string::npos; + } + + + //--------------------------------------------------------------- + inline + bool + IsMediumResolution(const std::string& thePartName) + { + return IsSubString(thePartName, "_MED"); + } + + + //--------------------------------------------------------------- + inline + bool + IsLowResolution(const std::string& thePartName) + { + return IsSubString(thePartName, "_LOW"); + } + + + //--------------------------------------------------------------- + inline + bool + IsFullResolution(const std::string& thePartName) + { + return !IsMediumResolution(thePartName) && !IsLowResolution(thePartName); + } + + + //--------------------------------------------------------------- + typedef std::set TSubParts; + typedef std::map TMain2SubParts; + + inline + std::string + GetResolutions(const TMain2SubParts& theMain2SubParts, + const std::string& thePartName) + { + std::string aResolution = "F"; + + MultiResult_i::TPartName aMainPart = ExtractMainPart(thePartName); + TMain2SubParts::const_iterator anIter = theMain2SubParts.find(aMainPart); + if(anIter != theMain2SubParts.end()){ + const TSubParts& aSubParts = anIter->second; + + if(aSubParts.find(aMainPart + "_LOW") != aSubParts.end()) + aResolution += "L"; + + if(aSubParts.find(aMainPart + "_MED") != aSubParts.end()) + aResolution += "M"; + } + return aResolution; + } + + + //--------------------------------------------------------------- + inline + MultiResult_i::TResolutionID + GetResolutionID(const TMain2SubParts& theMain2SubParts, + const std::string& thePartName) + { + std::string aResolutions = GetResolutions(theMain2SubParts, + thePartName); + if(aResolutions.find('L') != std::string::npos) + return 'L'; + + if(aResolutions.find('M') != std::string::npos) + return 'M'; + + return 'F'; + } + + + //--------------------------------------------------------------- + inline + std::string + GetIconName(const TMain2SubParts& theMain2SubParts, + const std::string& thePartName) + { + MultiResult_i::TResolutionID aResolutionID = GetResolutionID(theMain2SubParts, + thePartName); + if(aResolutionID == 'L') + return "ICON_MULTIPR_VIEW_LOW"; + + if(aResolutionID == 'M') + return "ICON_MULTIPR_VIEW_MEDIUM"; + + return "ICON_MULTIPR_VIEW_FULL"; + } + + + //--------------------------------------------------------------- + void + BuildParts(Result_i* theResult, + Result_i::PInput theInput, + const QFileInfo& theMPFileInfo, + MultiResult_i::TPartName2FileName* thePartName2FileName, + MultiResult_i::TPartName2ResolutionID* thePartName2ResolutionID, + CORBA::Boolean* theIsDone, + CORBA::Boolean theIsBuild, + CORBA::Boolean theIsAtOnce, + _PTR(Study) theStudy) + { + if(!theIsBuild || *theIsDone) + return; + + // if MED file is not a distributed MED file (created with MULTIPR), + // then it is not necessary to build parts + if (theMPFileInfo.filePath().isEmpty()) + return; + + try { + multipr::Obj aMultiprObj; + aMultiprObj.create(theMPFileInfo.filePath().latin1()); + if (aMultiprObj.isValidDistributedMEDFile()) { + const VISU::TMeshMap& aMeshMap = theInput->GetMeshMap(); + VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); + const VISU::PMesh& aMesh = aMeshMapIter->second; + + typedef std::vector TParts; + TParts aParts = aMultiprObj.getParts(); + + QString aComment = "Sub-parts: #"; + aComment += QString::number(aParts.size()); + + CreateAttributes(theStudy, + aMesh->myPartsEntry, + NO_ICON, + NO_IOR, + "Parts", + NO_PERFSITENT_REF, + aComment.latin1(), + false); + + MultiResult_i::TPartName2FileName& aPartName2FileName = *thePartName2FileName; + MultiResult_i::TPartName2ResolutionID& aPartName2ResolutionID = *thePartName2ResolutionID; + + TMain2SubParts aMain2SubParts; + + for (size_t aPartID = 0 ; aPartID < aParts.size() ; aPartID++) { + const MultiResult_i::TPartName& aPartName = aParts[aPartID]; + MultiResult_i::TPartName aMainPart = ExtractMainPart(aPartName); + aMain2SubParts[aMainPart].insert(aPartName); + } + + std::string aLastEntry; + for (size_t aPartID = 0 ; aPartID < aParts.size() ; aPartID++) { + const MultiResult_i::TPartName& aPartName = aParts[aPartID]; + std::string aPartInfo = aMultiprObj.getPartInfo(aPartName.c_str()); + + std::istrstream anOutputStream(aPartInfo.c_str()); + std::string aMeshName; + anOutputStream>>aMeshName; + + int anID; + anOutputStream>>anID; + + std::string aName; + anOutputStream>>aName; + + std::string aPath; + anOutputStream>>aPath; + + std::string aFileName; + anOutputStream>>aFileName; + + aPartName2FileName[aName] = aFileName; + + QString aComment = ""; + std::string aResoltutions = GetResolutions(aMain2SubParts, aName); + if ( IsFullResolution(aName) ) { + std::string anIconName = GetIconName(aMain2SubParts, aName); + MultiResult_i::TResolutionID aResolutionID = GetResolutionID(aMain2SubParts, aName); + aComment.sprintf("myComment=PART;myFile=%s;myResolutions=%s;myState=%c", + aFileName.c_str(), aResoltutions.c_str(), aResolutionID); + aLastEntry = CreateAttributes(theStudy, + aMesh->myPartsEntry, + anIconName, + NO_IOR, + aName, + NO_PERFSITENT_REF, + aComment.latin1(), + true); + aPartName2ResolutionID[aName] = aResolutionID; + } else { + aComment.sprintf("myComment=PART;myFile=%s;myResolutions=%s", + aFileName.c_str(), aResoltutions.c_str()); + CreateAttributes(theStudy, + aLastEntry, + NO_ICON, + NO_IOR, + aName, + NO_PERFSITENT_REF, + aComment.latin1(), + true); + } + } + } else { + INFOS("invalid distributed MED file"); + } + *theIsDone = true; + }catch(std::exception& exc){ + INFOS("Follow exception was occured :\n"<StudyId(), theIsDone)); + } + + + //--------------------------------------------------------------- +} + + +//--------------------------------------------------------------- +VISU::MultiResult_i +::MultiResult_i (SALOMEDS::Study_ptr theStudy, + const ESourceId& theSourceId, + const ECreationId& theCreationId, + CORBA::Boolean theIsBuildImmediately, + CORBA::Boolean theIsBuildFields, + CORBA::Boolean theIsBuildMinMax, + CORBA::Boolean theIsBuildGroups): + Result_i(theStudy, + theSourceId, + theCreationId, + theIsBuildImmediately, + theIsBuildFields, + theIsBuildMinMax, + theIsBuildGroups) +{} + + +//--------------------------------------------------------------- +size_t +VISU::MultiResult_i +::IsPossible() +{ + return TSuperClass::IsPossible(); +} + + +//--------------------------------------------------------------- +VISU::Storable* +VISU::MultiResult_i +::Build(SALOMEDS::SObject_ptr theSObject, + CORBA::Boolean theIsAtOnce) +{ + if(!TSuperClass::Build(theSObject, theIsAtOnce)) + return NULL; + + if(IsDone()) + return this; + + if(theIsAtOnce){ + BuildParts(this, + GetInput(), + myMPFileInfo, + &myPartName2FileName, + &myPartName2ResolutionID, + &myIsPartsDone, + myIsBuildParts, + theIsAtOnce, + myStudy); + } + + return this; +} + + +//--------------------------------------------------------------- +void +VISU::MultiResult_i +::BuildDataTree(const std::string& theResultEntry) +{ + BuildEntities(this, + GetInput(), + &myIsEntitiesDone, + theResultEntry, + false, + myIsBuildGroups, + myIsBuildFields, + myIsBuildParts, + myStudy); + { + boost::thread aThread(boost::bind(&BuildParts, + this, + GetInput(), + myMPFileInfo, + &myPartName2FileName, + &myPartName2ResolutionID, + &myIsPartsDone, + myIsBuildParts, + false, + myStudy)); + } + { + boost::thread aThread(boost::bind(&BuildGroups, + this, + GetInput(), + &myIsGroupsDone, + myIsBuildGroups, + false, + myStudy)); + } + { + boost::thread aThread(boost::bind(&BuildFieldDataTree, + this, + GetInput(), + &myIsFieldsDone, + myIsBuildFields, + &myIsMinMaxDone, + myIsBuildMinMax, + myStudy)); + } +} + + +//--------------------------------------------------------------- +VISU::Storable* +VISU::MultiResult_i +::Create(const char* theFileName) +{ + QFileInfo aFileInfo(theFileName); + QString aTargetFileName = aFileInfo.filePath(); + if(aTargetFileName.endsWith("_grains_maitre.med")){ + // retrieve source MED file (sequential MED file) + FILE* aFile = fopen(theFileName, "rt"); + QString aSourceFileName(""); + char aBuf[1024]; + while (!feof(aFile)) { + fgets(aBuf, 1024, aFile); + char* strTag = NULL; + if ((aBuf[0] == '#') && ((strTag = strstr(aBuf, "[SOURCE]=")) != NULL)) { + char aFileName[256]; + int ret = sscanf(strTag, "[SOURCE]=%s", aFileName); + if (ret == 1) { + aSourceFileName = aFileName; + break; + } + } + } + fclose(aFile); + if (aSourceFileName.isEmpty()) + throw std::runtime_error("distributed MED file; bad format"); + + myMPFileInfo.setFile(theFileName); + aTargetFileName = aSourceFileName; + myIsBuildParts = true; + } + + return TSuperClass::Create(aTargetFileName); +} + + +//--------------------------------------------------------------- +VISU::Storable* +VISU::MultiResult_i +::Restore(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap, + const string& thePrefix) +{ + return TSuperClass::Restore(theSObject, + theMap, + thePrefix); +} + + +//--------------------------------------------------------------- +CORBA::Boolean +VISU::MultiResult_i +::IsDone() +{ + return TSuperClass::IsDone() && + (myIsBuildParts? myIsPartsDone: true); +} + + +//--------------------------------------------------------------- +void +VISU::MultiResult_i +::ToStream(std::ostringstream& theStr) +{ + TSuperClass::ToStream(theStr); +} + + +//--------------------------------------------------------------- +VISU::MultiResult_i +::~MultiResult_i() +{} + + +//--------------------------------------------------------------- +void +VISU::MultiResult_i +::SetResolution(const std::string& theName, + TResolutionID theNewResolution) +{ + TPartName2FileName::iterator anIter = myPartName2FileName.find(theName); + if(anIter == myPartName2FileName.end()) + return; + + TResolutionID& aNewResolution = myPartName2ResolutionID[theName]; + if(aNewResolution == theNewResolution) + return; + + aNewResolution = theNewResolution; + + VISU::Storable::TRestoringMap aRestoringMap; + const TFileName& aFileName = anIter->second; + aRestoringMap["myComment"] = "PART"; + aRestoringMap["myFile"] = aFileName; + std::string aFatherEntry = GetEntry(aRestoringMap); + + std::string anIconName = "ICON_MULTIPR_VIEW_HIDE"; + if(theNewResolution == 'F') + anIconName = "ICON_MULTIPR_VIEW_FULL"; + else if(theNewResolution == 'M') + anIconName = "ICON_MULTIPR_VIEW_MEDIUM"; + else if(theNewResolution == 'L') + anIconName = "ICON_MULTIPR_VIEW_LOW"; + + _PTR(Study) aStudy = GetStudy(); + _PTR(SObject) aSObject = aStudy->FindObjectID(aFatherEntry); + aRestoringMap = Storable::GetStorableMap(aSObject); + + std::ostrstream anOutputStream; + anOutputStream<<"myComment=PART;"; + anOutputStream<<"myFile="<first; + if(IsFullResolution(aPartName)){ + MultiResult_i::TPartName2ResolutionID::const_iterator anIter2 = thePartName2ResolutionID.find(aPartName); + if(anIter2 != thePartName2ResolutionID.end()){ + const MultiResult_i::TResolutionID& aResolutionID = anIter2->second; + if(aResolutionID == 'F') + continue; + } + aResult = false; + break; + } + } + return aResult; + } +} + + +//--------------------------------------------------------------- +VISU::Result_i::PInput +VISU::MultiResult_i +::GetInput(const std::string& theMeshName, + VISU::Entity theEntity, + const std::string& theFieldName, + CORBA::Long theTimeStampNumber) +{ + if(theEntity == NONE) // If client wants use initial behaviour + return TSuperClass::GetInput(); + + if(!myIsPartsDone) // If corresponding data is not ready yet + return TSuperClass::GetInput(); + + if(UseInitialInput(myPartName2FileName, myPartName2ResolutionID)) + return TSuperClass::GetInput(); + + MultiResult_i::TRepresentationKey aRepresentationKey = + GetRepresentation(myPartName2FileName, myPartName2ResolutionID); + + typedef std::vector TFileNames; + TFileNames aFileNames(aRepresentationKey.begin(), aRepresentationKey.end()); + + aRepresentationKey.insert( theMeshName ); + aRepresentationKey.insert( theFieldName ); + + TRepresentation2Input::iterator anIter = myRepresentation2Input.find(aRepresentationKey); + if(anIter == myRepresentation2Input.end()){ + std::string aFileName = SALOMEDS_Tool::GetTmpDir() + "tmp.med"; + //cout<<"MultiResult_i::GetInput - '"<Build(); + myRepresentation2Input[aRepresentationKey] = anInput; + return anInput; + } + + return anIter->second; +} + + +#endif // ENABLE_MULTIPR diff --git a/src/VISU_I/VISU_MultiResult_i.hh b/src/VISU_I/VISU_MultiResult_i.hh new file mode 100644 index 00000000..b05dd5fc --- /dev/null +++ b/src/VISU_I/VISU_MultiResult_i.hh @@ -0,0 +1,125 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File : VISU_MultiResult_i.hh +// Author : Alexey PETROV +// Module : VISU + +#ifndef __VISU_MULTI_RESULT_I_H__ +#define __VISU_MULTI_RESULT_I_H__ + +#ifndef ENABLE_MULTIPR +# define RESULT_CLASS_NAME Result_i +#else +# define RESULT_CLASS_NAME MultiResult_i + +#include "VISU_Result_i.hh" + +#include + +namespace VISU +{ + //---------------------------------------------------------------------------- + class MultiResult_i : public virtual Result_i + { + MultiResult_i(const MultiResult_i&); + + public: + typedef Result_i TSuperClass; + + MultiResult_i(SALOMEDS::Study_ptr theStudy, + const ESourceId& theSourceId, + const ECreationId& theCreationId, + CORBA::Boolean theIsBuildImmediately = true, + CORBA::Boolean theIsBuildFields = true, + CORBA::Boolean theIsBuildMinMax = true, + CORBA::Boolean theIsBuildGroups = true); + + virtual + ~MultiResult_i(); + + virtual + CORBA::Boolean + IsDone(); + + typedef std::string TPartName; + typedef std::string TFileName; + typedef std::map TPartName2FileName; + typedef std::map TPartName2ResolutionID; + + typedef std::set TRepresentationKey; + typedef std::map TRepresentation2Input; + + private: + QFileInfo myMPFileInfo; + TPartName2FileName myPartName2FileName; + TPartName2ResolutionID myPartName2ResolutionID; + + TRepresentation2Input myRepresentation2Input; + + protected: + virtual + Storable* + Build(SALOMEDS::SObject_ptr theSObject, + CORBA::Boolean theIsAtOnce = true) ; + + virtual + void + BuildDataTree(const std::string& theResultEntry); + + public: + virtual + size_t + IsPossible(); + + virtual + Storable* + Create(const char* theFileName); + + virtual + Storable* + Restore(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap, + const std::string& thePrefix); + + virtual + void + ToStream(std::ostringstream& theStr); + + virtual + PInput + GetInput(const std::string& theMeshName = "", + VISU::Entity theEntity = VISU::NONE, + const std::string& theFieldName = "", + CORBA::Long theTimeStampNumber = -1); + + virtual + void + SetResolution(const std::string& theName, + TResolutionID theNewResolution); // 'F'=FULL 'M'=MEDIUM 'L'=LOW 'H'=HIDE + }; + +} + +#endif // ENABLE_MULTIPR + +#endif // __VISU_MULTI_RESULT_I_H__ diff --git a/src/VISU_I/VISU_ResultUtils.cc b/src/VISU_I/VISU_ResultUtils.cc new file mode 100644 index 00000000..82bcfdc2 --- /dev/null +++ b/src/VISU_I/VISU_ResultUtils.cc @@ -0,0 +1,605 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File : VISU_ResultUtils.cc +// Author : Alexey PETROV +// Module : VISU + +#include "VISU_ResultUtils.hh" + +#include "SUIT_Session.h" +#include "SALOME_Event.hxx" +#include "SalomeApp_Study.h" +#include "SalomeApp_Application.h" + +#include "VISU_Convertor.hxx" +#include "VISU_ConvertorUtils.hxx" + +#include +#include +#include + +#ifdef _DEBUG_ +static int MYTIMEDEBUG = 0; +#else +static int MYTIMEDEBUG = 0; +#endif + +namespace VISU +{ + //---------------------------------------------------------------------------- + typedef boost::recursive_mutex TMutex; + typedef TMutex::scoped_lock TLock; + + static TMutex myMutex; + + + //---------------------------------------------------------------------------- + TUpdateObjBrowser + ::TUpdateObjBrowser(const int theStudyId, CORBA::Boolean* theIsDone): + myStudyId(theStudyId), + myIsDone(theIsDone) + {} + + + //---------------------------------------------------------------------------- + void + TUpdateObjBrowser + ::Execute() + { + TLock aLock(myMutex); + SUIT_Session* aSession = SUIT_Session::session(); + QPtrList anApplications = aSession->applications(); + QPtrListIterator anIter (anApplications); + while (SUIT_Application* aSApp = anIter.current()) { + if(SalomeApp_Application* anApp = dynamic_cast(aSApp)){ + if (SalomeApp_Study* aStudy = dynamic_cast(anApp->activeStudy())) { + if (_PTR(Study) aCStudy = aStudy->studyDS()) { + if (myStudyId == aCStudy->StudyId()) { + TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::updateObjectBrowser"); + anApp->updateObjectBrowser(); + *myIsDone = true; + break; + } + } + } + } + ++anIter; + } + } + + + //---------------------------------------------------------------------------- + struct TResultManager + { + Result_i* myResult; + + TResultManager(Result_i* theResult): + myResult(theResult) + { + myResult->Register(); + } + + ~TResultManager() + { + myResult->Destroy(); + } + }; + + + //---------------------------------------------------------------------------- + struct TTransactionManager + { + _PTR(StudyBuilder) myStudyBuilder; + + TTransactionManager(_PTR(Study) theStudyDocument): + myStudyBuilder(theStudyDocument->NewBuilder()) + { + TLock aLock(myMutex); + myStudyBuilder->NewCommand(); + } + + ~TTransactionManager() + { + TLock aLock(myMutex); + myStudyBuilder->CommitCommand(); + } + }; + + + //---------------------------------------------------------------------------- + QString + GenerateName(const std::string& theName) + { + TLock aLock(myMutex); + + typedef std::map TNameMap; + static TNameMap aMap; + + TNameMap::const_iterator anIter = aMap.find(theName); + QString aResult; + if (anIter == aMap.end()) { + aMap[theName] = 0; + aResult = theName; + } else { + aResult = GenerateName(theName,++aMap[theName]); + } + return aResult; + } + + + //---------------------------------------------------------------------------- + QString + GenerateFieldName (const string& theName, const string& theUnits) + { + QString aName; + const string tmp (theUnits.size(),' '); + if (theUnits == "" || theUnits == tmp) + aName.sprintf("%s, -",theName.c_str()); + else + aName.sprintf("%s, %s",theName.c_str(),theUnits.c_str()); + aName = aName.simplifyWhiteSpace(); + return aName.latin1(); + } + + + //---------------------------------------------------------------------------- + void + CreateReference(_PTR(Study) theStudyDocument, + const string& theFatherEntry, + const string& theRefEntry) + { + _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder(); + _PTR(SObject) aFather = theStudyDocument->FindObjectID(theFatherEntry); + _PTR(SObject) aNewObj = aStudyBuilder->NewObject(aFather); + _PTR(SObject) aRefSObj = theStudyDocument->FindObjectID(theRefEntry); + aStudyBuilder->Addreference(aNewObj,aRefSObj); + } + + + //---------------------------------------------------------------------------- + void + RemoveSObject(_PTR(Study) theStudyDocument, + const string& theEntry) + { + _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder(); + _PTR(SObject) aSObject = theStudyDocument->FindObjectID(theEntry); + aStudyBuilder->RemoveObject(aSObject); + } + + + //---------------------------------------------------------------------------- + void + BuildEntities(Result_i* theResult, + Result_i::PInput theInput, + CORBA::Boolean* theIsDone, + const std::string& theResultEntry, + CORBA::Boolean theIsAtOnce, + CORBA::Boolean theIsBuildGroups, + CORBA::Boolean theIsBuildFields, + CORBA::Boolean theIsBuildParts, + _PTR(Study) theStudy) + { + if(*theIsDone) + return; + + TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildEntities"); + TResultManager aResultManager(theResult); + TTransactionManager aTransactionManager(theStudy); + + { + TTimerLog aTimerLog(MYTIMEDEBUG,"theInput->BuildEntities"); + theInput->BuildEntities(); + } + + QString aComment,aTmp; + const TMeshMap& aMeshMap = theInput->GetMeshMap(); + TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); + for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ + const string& aMeshName = aMeshMapIter->first; + const PMesh& aMesh = aMeshMapIter->second; + const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; + if(aMeshOnEntityMap.empty()) + continue; + aComment.sprintf("myComment=MESH;myName=%s;myDim=%d", + aMeshName.c_str(), + aMesh->myDim); + aMesh->myEntry = + CreateAttributes(theStudy, + theResultEntry, + NO_ICON, + NO_IOR, + aMeshName, + NO_PERFSITENT_REF, + aComment.latin1(), + true); + + aComment.sprintf("myComment=FAMILIES;myMeshName=%s", + aMeshName.c_str()); + std::string aSubMeshesEntry = + CreateAttributes(theStudy, + aMesh->myEntry, + NO_ICON, + NO_IOR, + "Families", + NO_PERFSITENT_REF, + aComment.latin1(), + true); + + if(theIsBuildGroups){ + aMesh->myGroupsEntry = + CreateAttributes(theStudy, + aMesh->myEntry, + NO_ICON, + NO_IOR, + NO_NAME, + NO_PERFSITENT_REF, + NO_COMMENT, + true); + } + + if(theIsBuildFields){ + aMesh->myFieldsEntry = + CreateAttributes(theStudy, + aMesh->myEntry, + NO_ICON, + NO_IOR, + NO_NAME, + NO_PERFSITENT_REF, + NO_COMMENT, + true); + } + + if(theIsBuildParts){ + aMesh->myPartsEntry = + CreateAttributes(theStudy, + aMesh->myEntry, + NO_ICON, + NO_IOR, + NO_NAME, + NO_PERFSITENT_REF, + NO_COMMENT, + true); + } + + //Import entities + TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); + for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ + const TEntity& anEntity = aMeshOnEntityMapIter->first; + const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; + + string anEntityName; + switch(anEntity){ + case NODE_ENTITY: + anEntityName = "onNodes"; + break; + case EDGE_ENTITY: + anEntityName = "onEdges"; + break; + case FACE_ENTITY: + anEntityName = "onFaces"; + break; + case CELL_ENTITY: + anEntityName = "onCells"; + break; + default: + continue; + } + + aComment.sprintf("myComment=ENTITY;myMeshName=%s;myId=%d", + aMeshName.c_str(), + anEntity); + + aMeshOnEntity->myEntry = + CreateAttributes(theStudy, + aSubMeshesEntry, + NO_ICON, + NO_IOR, + anEntityName.c_str(), + NO_PERFSITENT_REF, + aComment.latin1(), + true); + } + } + + ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone)); + } + + + //---------------------------------------------------------------------------- + void + BuildGroups(Result_i* theResult, + Result_i::PInput theInput, + CORBA::Boolean* theIsDone, + CORBA::Boolean theIsBuild, + CORBA::Boolean theIsAtOnce, + _PTR(Study) theStudy) + { + if(!theIsBuild || *theIsDone) + return; + + TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildGroups"); + TResultManager aResultManager(theResult); + TTransactionManager aTransactionManager(theStudy); + + { + TTimerLog aTimerLog(MYTIMEDEBUG,"theInput->BuildGroups"); + theInput->BuildGroups(); + } + + QString aComment,aTmp; + const TMeshMap& aMeshMap = theInput->GetMeshMap(); + TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); + for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ + const string& aMeshName = aMeshMapIter->first; + const PMesh& aMesh = aMeshMapIter->second; + + const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; + if(aMeshOnEntityMap.empty()) + continue; + + TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); + for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ + const TEntity& anEntity = aMeshOnEntityMapIter->first; + const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; + + const TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; + TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); + for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){ + const string& aFamilyName = aFamilyMapIter->first; + const PFamily& aFamily = aFamilyMapIter->second; + aComment.sprintf("myComment=FAMILY;myMeshName=%s;myEntityId=%d;myName=%s", + aMeshName.c_str(), + anEntity, + aFamilyName.c_str()); + + aFamily->myEntry = + CreateAttributes(theStudy, + aMeshOnEntity->myEntry, + NO_ICON, + NO_IOR, + aFamilyName, + NO_PERFSITENT_REF, + aComment.latin1(), + true); + } + } + //Importing groups + const TGroupMap& aGroupMap = aMesh->myGroupMap; + if(!aGroupMap.empty()){ + aComment.sprintf("myComment=GROUPS;myMeshName=%s", + aMeshName.c_str()); + + CreateAttributes(theStudy, + aMesh->myGroupsEntry, + NO_ICON, + NO_IOR, + "Groups", + NO_PERFSITENT_REF, + aComment.latin1(), + false); + + TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin(); + for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){ + const string& aGroupName = aGroupMapIter->first; + const PGroup& aGroup = aGroupMapIter->second; + aComment.sprintf("myComment=GROUP;myMeshName=%s;myName=%s", + aMeshName.c_str(), + aGroupName.c_str()); + aGroup->myEntry = + CreateAttributes(theStudy, + aMesh->myGroupsEntry, + NO_ICON, + NO_IOR, + aGroupName, + NO_PERFSITENT_REF, + aComment.latin1(), + true); + const TFamilySet& aFamilySet = aGroup->myFamilySet; + TFamilySet::const_iterator aFamilyIter = aFamilySet.begin(); + for(; aFamilyIter != aFamilySet.end(); aFamilyIter++){ + const PFamily& aFamily = *aFamilyIter; + CreateReference(theStudy, + aGroup->myEntry, + aFamily->myEntry); + } + } + }else if(!theIsAtOnce) + RemoveSObject(theStudy, + aMesh->myGroupsEntry); + } + + ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone)); + } + + + //---------------------------------------------------------------------------- + void + BuildFields(Result_i* theResult, + Result_i::PInput theInput, + CORBA::Boolean* theIsDone, + CORBA::Boolean theIsBuild, + CORBA::Boolean theIsAtOnce, + _PTR(Study) theStudy) + { + if(!theIsBuild || *theIsDone) + return; + + TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildFields"); + TResultManager aResultManager(theResult); + TTransactionManager aTransactionManager(theStudy); + + { + TTimerLog aTimerLog(MYTIMEDEBUG,"theInput->BuildFields"); + theInput->BuildFields(); + } + + QString aComment,aTmp; + const TMeshMap& aMeshMap = theInput->GetMeshMap(); + TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); + + for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++) + { + const string& aMeshName = aMeshMapIter->first; + const PMesh& aMesh = aMeshMapIter->second; + + const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; + if(aMeshOnEntityMap.empty()) + continue; + + //Import fields + bool anIsFieldsEntryUpdated = false; + TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); + + for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++) + { + const TEntity& anEntity = aMeshOnEntityMapIter->first; + const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; + const TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; + TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin(); + + for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++) + { + if(!anIsFieldsEntryUpdated) + { + aComment = ""; + aComment.append("myComment=FIELDS;"); + aComment.append("myMeshName=");aComment.append(aMeshName); + + CreateAttributes(theStudy, + aMesh->myFieldsEntry, + NO_ICON, + NO_IOR, + "Fields", + NO_PERFSITENT_REF, + aComment.latin1(), + false); + + anIsFieldsEntryUpdated = true; + } + + const string& aFieldName = aFieldMapIter->first; + const PField& aField = aFieldMapIter->second; + const TValField& aValField = aField->myValField; + QString aFieldNameWithUnit = GenerateFieldName(aFieldName,aField->myUnitNames[0]); + aComment.sprintf("myComment=FIELD;myMeshName=%s;myEntityId=%d;myName=%s;myNbTimeStamps=%d;myNumComponent=%d", + aMeshName.c_str(), + anEntity, + aFieldName.c_str(), + aValField.size(), + aField->myNbComp); + + aField->myEntry = CreateAttributes(theStudy, + aMesh->myFieldsEntry, + NO_ICON, + NO_IOR, + aFieldNameWithUnit.latin1(), + NO_PERFSITENT_REF, + aComment.latin1(), + true); + + CreateReference(theStudy, + aField->myEntry, + aMeshOnEntity->myEntry); + + TValField::const_iterator aValFieldIter = aValField.begin(); + + for(; aValFieldIter != aValField.end(); aValFieldIter++) + { + int aTimeStamp = aValFieldIter->first; + const PValForTime& aValForTime = aValFieldIter->second; + aComment.sprintf("myComment=TIMESTAMP;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d", + aMeshName.c_str(), + anEntity, + aFieldName.c_str(), + aTimeStamp, + aField->myNbComp); + + string aTimeStampId = VISU_Convertor::GenerateName(aValForTime->myTime); + + aValForTime->myEntry = CreateAttributes(theStudy, + aField->myEntry, + NO_ICON, + NO_IOR, + aTimeStampId, + NO_PERFSITENT_REF, + aComment.latin1(), + true); + } + } + } + + if(!anIsFieldsEntryUpdated && !theIsAtOnce) + RemoveSObject(theStudy, aMesh->myFieldsEntry); + } + + ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone)); + } + + + //---------------------------------------------------------------------------- + void + BuildMinMax(Result_i* theResult, + Result_i::PInput theInput, + CORBA::Boolean* theIsDone, + CORBA::Boolean theIsBuild) + { + if(!theIsBuild || *theIsDone) + return; + + TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildMinMax"); + TResultManager aResultManager(theResult); + + theInput->BuildMinMax(); + + *theIsDone = true; + + theResult->UpdateObservers(); + } + + + //---------------------------------------------------------------------------- + void + BuildFieldDataTree(Result_i* theResult, + Result_i::PInput theInput, + CORBA::Boolean* theIsFieldsDone, + CORBA::Boolean theIsBuildFields, + CORBA::Boolean* theIsMinMaxDone, + CORBA::Boolean theIsBuildMinMax, + _PTR(Study) theStudy) + { + BuildFields(theResult, + theInput, + theIsFieldsDone, + theIsBuildFields, + false, + theStudy); + + BuildMinMax(theResult, + theInput, + theIsMinMaxDone, + theIsBuildMinMax); + } + + + //---------------------------------------------------------------------------- +} diff --git a/src/VISU_I/VISU_ResultUtils.hh b/src/VISU_I/VISU_ResultUtils.hh new file mode 100644 index 00000000..2c9b0aae --- /dev/null +++ b/src/VISU_I/VISU_ResultUtils.hh @@ -0,0 +1,110 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File : VISU_ResultUtils.hh +// Author : Alexey PETROV +// Module : VISU + +#ifndef __VISU_RESULT_UTILS_H__ +#define __VISU_RESULT_UTILS_H__ + +#include "VISU_Result_i.hh" +#include "SALOME_Event.hxx" + +#include + +namespace VISU +{ + //---------------------------------------------------------------------------- + struct TUpdateObjBrowser: public SALOME_Event + { + int myStudyId; + CORBA::Boolean* myIsDone; + TUpdateObjBrowser(const int theStudyId, CORBA::Boolean* theIsDone); + + virtual + void + Execute(); + }; + + + //---------------------------------------------------------------------------- + QString + GenerateName(const std::string& theName); + + + //---------------------------------------------------------------------------- + void + BuildEntities(Result_i* theResult, + Result_i::PInput theInput, + CORBA::Boolean* theIsDone, + const std::string& theResultEntry, + CORBA::Boolean theIsAtOnce, + CORBA::Boolean theIsBuildGroups, + CORBA::Boolean theIsBuildFields, + CORBA::Boolean theIsBuildParts, + _PTR(Study) theStudy); + + + //---------------------------------------------------------------------------- + void + BuildGroups(Result_i* theResult, + Result_i::PInput theInput, + CORBA::Boolean* theIsDone, + CORBA::Boolean theIsBuild, + CORBA::Boolean theIsAtOnce, + _PTR(Study) theStudy); + + + //---------------------------------------------------------------------------- + void + BuildFields(Result_i* theResult, + Result_i::PInput theInput, + CORBA::Boolean* theIsDone, + CORBA::Boolean theIsBuild, + CORBA::Boolean theIsAtOnce, + _PTR(Study) theStudy); + + + //---------------------------------------------------------------------------- + void + BuildMinMax(Result_i* theResult, + Result_i::PInput theInput, + CORBA::Boolean* theIsDone, + CORBA::Boolean theIsBuild); + + + //---------------------------------------------------------------------------- + void + BuildFieldDataTree(Result_i* theResult, + Result_i::PInput theInput, + CORBA::Boolean* theIsFieldsDone, + CORBA::Boolean theIsBuildFields, + CORBA::Boolean* theIsMinMaxDone, + CORBA::Boolean theIsBuildMinMax, + _PTR(Study) theStudy); + + //---------------------------------------------------------------------------- +} + + +#endif // __VISU_RESULT_UTILS_H__ diff --git a/src/VISU_I/VISU_Result_i.cc b/src/VISU_I/VISU_Result_i.cc index 162842b9..1b3bf77c 100644 --- a/src/VISU_I/VISU_Result_i.cc +++ b/src/VISU_I/VISU_Result_i.cc @@ -24,7 +24,8 @@ // Author : Alexey PETROV // Module : VISU -#include "VISU_Result_i.hh" +#include "VISU_MultiResult_i.hh" +#include "VISU_ResultUtils.hh" #include "VISU_Convertor_impl.hxx" #include "VISU_CorbaMedConvertor.hxx" @@ -41,10 +42,7 @@ #include "SalomeApp_Study.h" #include "SalomeApp_Application.h" -#include #include - -#include #include // QT Includes @@ -61,20 +59,11 @@ // OCCT Includes #include -#ifdef ENABLE_MULTIPR -// MULTIPR -#include "MULTIPR_Obj.hxx" -#endif - -using namespace VISU; -using namespace std; #ifdef _DEBUG_ static int MYDEBUG = 1; -static int MYTIMEDEBUG = 0; #else static int MYDEBUG = 0; -static int MYTIMEDEBUG = 0; #endif @@ -82,7 +71,7 @@ namespace VISU { //--------------------------------------------------------------- Result_var - FindResult (SALOMEDS::SObject_ptr theSObject) + FindResult(SALOMEDS::SObject_ptr theSObject) { SALOMEDS::SComponent_var aSComponent = theSObject->GetFatherComponent(); SALOMEDS::SObject_var aFather = theSObject->GetFather(); @@ -117,85 +106,7 @@ namespace VISU //--------------------------------------------------------------- - typedef boost::recursive_mutex TMutex; - typedef TMutex::scoped_lock TLock; - - static TMutex myMutex; - - //--------------------------------------------------------------- - struct TGetStudy: public SALOME_Event - { - typedef _PTR(Study) TResult; - TResult myResult; - int myStudyId; - - TGetStudy(const int theStudyId): - myStudyId(theStudyId) - {} - - virtual - void - Execute() - { - SUIT_Session* aSession = SUIT_Session::session(); - QPtrList anApplications = aSession->applications(); - QPtrListIterator anIter (anApplications); - while (SUIT_Application* aSApp = anIter.current()) { - if(SalomeApp_Application* anApp = dynamic_cast(aSApp)){ - if(SalomeApp_Study* aStudy = dynamic_cast(anApp->activeStudy())) { - if(_PTR(Study) aStudyDS = aStudy->studyDS()){ - if(aStudyDS->StudyId() == myStudyId){ - myResult = aStudy->studyDS(); - break; - } - } - } - } - ++anIter; - } - } - }; - - - //--------------------------------------------------------------- - QString - GenerateName (const std::string& theName) - { - TLock aLock(myMutex); - - typedef map TNameMap; - static TNameMap aMap; - - TNameMap::const_iterator i = aMap.find(theName); - QString tmp; - if (i == aMap.end()) { - aMap[theName] = 0; - tmp = theName; - } else { - tmp = GenerateName(theName,++aMap[theName]); - } - if(MYDEBUG) MESSAGE("GenerateName - "<GetFatherComponent(); @@ -218,858 +129,7 @@ namespace VISU } - //--------------------------------------------------------------- - void - CreateReference (_PTR(Study) theStudyDocument, - const string& theFatherEntry, - const string& theRefEntry) - { - TLock aLock(myMutex); - - _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder(); - _PTR(SObject) aFather = theStudyDocument->FindObjectID(theFatherEntry); - _PTR(SObject) aNewObj = aStudyBuilder->NewObject(aFather); - _PTR(SObject) aRefSObj = theStudyDocument->FindObjectID(theRefEntry); - aStudyBuilder->Addreference(aNewObj,aRefSObj); - } - - - //--------------------------------------------------------------- - inline - std::string - CreateAttributes(_PTR(Study) theStudyDocument, - const string& theFatherEntry, - const string& theIOR, - const string& theName, - const string& theComment, - CORBA::Boolean theCreateNew, - const string& theIcon = "") - { - TLock aLock(myMutex); - - _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder(); - _PTR(SObject) aFather = theStudyDocument->FindObjectID(theFatherEntry); - - _PTR(SObject) aNewObj; - if(theCreateNew) - aNewObj = aStudyBuilder->NewObject(aFather); - else - aNewObj = aFather; - - _PTR(GenericAttribute) anAttr; - if (theIOR != "") { - anAttr = aStudyBuilder->FindOrCreateAttribute(aNewObj, "AttributeIOR"); - _PTR(AttributeIOR) anIOR (anAttr); - anIOR->SetValue(theIOR); - } - if (theName != "") { - anAttr = aStudyBuilder->FindOrCreateAttribute(aNewObj, "AttributeName"); - _PTR(AttributeName) aName (anAttr); - aName->SetValue(theName); - } - if (theComment != "") { - anAttr = aStudyBuilder->FindOrCreateAttribute(aNewObj, "AttributeString"); - _PTR(AttributeString) aCmnt (anAttr); - aCmnt->SetValue(theComment); - } - // MULTIPR - if (theIcon != "") { - anAttr = aStudyBuilder->FindOrCreateAttribute(aNewObj, "AttributePixMap"); - _PTR(AttributePixMap) aPixmap (anAttr); - aPixmap->SetPixMap(theIcon.c_str()); - } - return aNewObj->GetID(); - } - - - //--------------------------------------------------------------- - inline - void - UpdateAttributes(_PTR(Study) theStudyDocument, - const string& theEntry, - const string& theIOR, - const string& theName, - const string& theComment) - { - TLock aLock(myMutex); - - _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder(); - _PTR(SObject) aSObject = theStudyDocument->FindObjectID(theEntry); - - _PTR(GenericAttribute) anAttr; - if (theIOR != "") { - anAttr = aStudyBuilder->FindOrCreateAttribute(aSObject, "AttributeIOR"); - _PTR(AttributeIOR) anIOR (anAttr); - anIOR->SetValue(theIOR); - } - if (theName != "") { - anAttr = aStudyBuilder->FindOrCreateAttribute(aSObject, "AttributeName"); - _PTR(AttributeName) aName (anAttr); - aName->SetValue(theName); - } - if (theComment != "") { - anAttr = aStudyBuilder->FindOrCreateAttribute(aSObject, "AttributeString"); - _PTR(AttributeString) aCmnt (anAttr); - aCmnt->SetValue(theComment); - } - } - - - //--------------------------------------------------------------- - inline - void - RemoveSObject(_PTR(Study) theStudyDocument, - const string& theEntry) - { - TLock aLock(myMutex); - - _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder(); - _PTR(SObject) aSObject = theStudyDocument->FindObjectID(theEntry); - aStudyBuilder->RemoveObject(aSObject); - } - - - //--------------------------------------------------------------- - struct TResultManager - { - Result_i* myResult; - - TResultManager(Result_i* theResult): - myResult(theResult) - { - myResult->Register(); - } - - ~TResultManager() - { - myResult->Destroy(); - } - }; - - - //--------------------------------------------------------------- - struct TTransactionManager - { - _PTR(StudyBuilder) myStudyBuilder; - - TTransactionManager(_PTR(Study) theStudyDocument): - myStudyBuilder(theStudyDocument->NewBuilder()) - { - TLock aLock(myMutex); - myStudyBuilder->NewCommand(); - } - - ~TTransactionManager() - { - TLock aLock(myMutex); - myStudyBuilder->CommitCommand(); - } - }; - - - //--------------------------------------------------------------- - struct TUpdateObjBrowser: public SALOME_Event - { - int myStudyId; - CORBA::Boolean* myIsDone; - TUpdateObjBrowser(const int theStudyId, - CORBA::Boolean* theIsDone): - myStudyId(theStudyId), - myIsDone(theIsDone) - {} - - virtual - void - Execute() - { - TLock aLock(myMutex); - SUIT_Session* aSession = SUIT_Session::session(); - QPtrList anApplications = aSession->applications(); - QPtrListIterator anIter (anApplications); - while (SUIT_Application* aSApp = anIter.current()) { - if(SalomeApp_Application* anApp = dynamic_cast(aSApp)){ - if (SalomeApp_Study* aStudy = dynamic_cast(anApp->activeStudy())) { - if (_PTR(Study) aCStudy = aStudy->studyDS()) { - if (myStudyId == aCStudy->StudyId()) { - TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::updateObjectBrowser"); - anApp->updateObjectBrowser(); - *myIsDone = true; - break; - } - } - } - } - ++anIter; - } - } - }; - - - //--------------------------------------------------------------- - void - BuildEntities(Result_i* theResult, - VISU_Convertor* theInput, - CORBA::Boolean* theIsDone, - std::string theResultEntry, - CORBA::Boolean theIsAtOnce, - CORBA::Boolean theIsBuildGroups, - CORBA::Boolean theIsBuildFields, - _PTR(Study) theStudy) - { - if(*theIsDone) - return; - - TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildEntities"); - TResultManager aResultManager(theResult); - TTransactionManager aTransactionManager(theStudy); - - { - TTimerLog aTimerLog(MYTIMEDEBUG,"theInput->BuildEntities"); - theInput->BuildEntities(); - } - - QString aComment,aTmp; - const TMeshMap& aMeshMap = theInput->GetMeshMap(); - TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); - for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ - const string& aMeshName = aMeshMapIter->first; - const PMesh& aMesh = aMeshMapIter->second; - const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; - if(aMeshOnEntityMap.empty()) - continue; - aComment.sprintf("myComment=MESH;myName=%s;myDim=%d", - aMeshName.c_str(), - aMesh->myDim); - aMesh->myEntry = - CreateAttributes(theStudy, - theResultEntry, - "", - aMeshName, - aComment.latin1(), - true); - - aComment.sprintf("myComment=FAMILIES;myMeshName=%s", - aMeshName.c_str()); - string aSubMeshesEntry = - CreateAttributes(theStudy, - aMesh->myEntry, - "", - "Families", - aComment.latin1(), - true); - - if(theIsBuildGroups){ - aMesh->myGroupsEntry = - CreateAttributes(theStudy, - aMesh->myEntry, - "", - "", - "", - true); - } - - if(theIsBuildFields){ - aMesh->myFieldsEntry = - CreateAttributes(theStudy, - aMesh->myEntry, - "", - "", - "", - true); - } - -#ifdef ENABLE_MULTIPR - // MULTIPR - aMesh->myPartsEntry = - CreateAttributes(theStudy, - aMesh->myEntry, - "", - "", - "", - true); -#endif - - //Import entities - TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); - for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ - const TEntity& anEntity = aMeshOnEntityMapIter->first; - const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; - - string anEntityName; - switch(anEntity){ - case NODE_ENTITY: - anEntityName = "onNodes"; - break; - case EDGE_ENTITY: - anEntityName = "onEdges"; - break; - case FACE_ENTITY: - anEntityName = "onFaces"; - break; - case CELL_ENTITY: - anEntityName = "onCells"; - break; - default: - continue; - } - - aComment.sprintf("myComment=ENTITY;myMeshName=%s;myId=%d", - aMeshName.c_str(), - anEntity); - - aMeshOnEntity->myEntry = - CreateAttributes(theStudy, - aSubMeshesEntry, - "", - anEntityName.c_str(), - aComment.latin1(), - true); - } - } - - ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone)); - } - - //--------------------------------------------------------------- - void - BuildGroups(Result_i* theResult, - VISU_Convertor* theInput, - CORBA::Boolean* theIsDone, - CORBA::Boolean theIsBuild, - CORBA::Boolean theIsAtOnce, - _PTR(Study) theStudy) - { - if(!theIsBuild || *theIsDone) - return; - - TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildGroups"); - TResultManager aResultManager(theResult); - TTransactionManager aTransactionManager(theStudy); - - { - TTimerLog aTimerLog(MYTIMEDEBUG,"theInput->BuildGroups"); - theInput->BuildGroups(); - } - - QString aComment,aTmp; - const TMeshMap& aMeshMap = theInput->GetMeshMap(); - TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); - for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ - const string& aMeshName = aMeshMapIter->first; - const PMesh& aMesh = aMeshMapIter->second; - - const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; - if(aMeshOnEntityMap.empty()) - continue; - - TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); - for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ - const TEntity& anEntity = aMeshOnEntityMapIter->first; - const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; - - const TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; - TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); - for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){ - const string& aFamilyName = aFamilyMapIter->first; - const PFamily& aFamily = aFamilyMapIter->second; - aComment.sprintf("myComment=FAMILY;myMeshName=%s;myEntityId=%d;myName=%s", - aMeshName.c_str(), - anEntity, - aFamilyName.c_str()); - - aFamily->myEntry = - CreateAttributes(theStudy, - aMeshOnEntity->myEntry, - "", - aFamilyName, - aComment.latin1(), - true); - } - } - //Importing groups - const TGroupMap& aGroupMap = aMesh->myGroupMap; - if(!aGroupMap.empty()){ - aComment.sprintf("myComment=GROUPS;myMeshName=%s", - aMeshName.c_str()); - - UpdateAttributes(theStudy, - aMesh->myGroupsEntry, - "", - "Groups", - aComment.latin1()); - - TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin(); - for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){ - const string& aGroupName = aGroupMapIter->first; - const PGroup& aGroup = aGroupMapIter->second; - aComment.sprintf("myComment=GROUP;myMeshName=%s;myName=%s", - aMeshName.c_str(), - aGroupName.c_str()); - aGroup->myEntry = - CreateAttributes(theStudy, - aMesh->myGroupsEntry, - "", - aGroupName, - aComment.latin1(), - true); - const TFamilySet& aFamilySet = aGroup->myFamilySet; - TFamilySet::const_iterator aFamilyIter = aFamilySet.begin(); - for(; aFamilyIter != aFamilySet.end(); aFamilyIter++){ - const PFamily& aFamily = *aFamilyIter; - CreateReference(theStudy, - aGroup->myEntry, - aFamily->myEntry); - } - } - }else if(!theIsAtOnce) - RemoveSObject(theStudy, - aMesh->myGroupsEntry); - } - - ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone)); - } - - - //--------------------------------------------------------------- - void BuildFields( - Result_i* theResult, - VISU_Convertor* theInput, - CORBA::Boolean* theIsDone, - CORBA::Boolean theIsBuild, - CORBA::Boolean theIsAtOnce, - _PTR(Study) theStudy) - { - if(!theIsBuild || *theIsDone) - return; - - TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildFields"); - TResultManager aResultManager(theResult); - TTransactionManager aTransactionManager(theStudy); - - { - TTimerLog aTimerLog(MYTIMEDEBUG,"theInput->BuildFields"); - theInput->BuildFields(); - } - - QString aComment,aTmp; - const TMeshMap& aMeshMap = theInput->GetMeshMap(); - TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); - - for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++) - { - const string& aMeshName = aMeshMapIter->first; - const PMesh& aMesh = aMeshMapIter->second; - - const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; - if(aMeshOnEntityMap.empty()) - continue; - - //Import fields - bool anIsFieldsEntryUpdated = false; - TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); - - for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++) - { - const TEntity& anEntity = aMeshOnEntityMapIter->first; - const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; - const TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; - TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin(); - - for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++) - { - if(!anIsFieldsEntryUpdated) - { - aComment = ""; - aComment.append("myComment=FIELDS;"); - aComment.append("myMeshName=");aComment.append(aMeshName); - - UpdateAttributes( - theStudy, - aMesh->myFieldsEntry, - "", - "Fields", - aComment.latin1()); - - anIsFieldsEntryUpdated = true; - } - - const string& aFieldName = aFieldMapIter->first; - const PField& aField = aFieldMapIter->second; - const TValField& aValField = aField->myValField; - QString aFieldNameWithUnit = GenerateFieldName(aFieldName,aField->myUnitNames[0]); - aComment.sprintf("myComment=FIELD;myMeshName=%s;myEntityId=%d;myName=%s;myNbTimeStamps=%d;myNumComponent=%d", - aMeshName.c_str(), - anEntity, - aFieldName.c_str(), - aValField.size(), - aField->myNbComp); - - aField->myEntry = CreateAttributes( - theStudy, - aMesh->myFieldsEntry, - "", - aFieldNameWithUnit.latin1(), - aComment.latin1(), - true); - - CreateReference( - theStudy, - aField->myEntry, - aMeshOnEntity->myEntry); - - TValField::const_iterator aValFieldIter = aValField.begin(); - - for(; aValFieldIter != aValField.end(); aValFieldIter++) - { - int aTimeStamp = aValFieldIter->first; - const PValForTime& aValForTime = aValFieldIter->second; - aComment.sprintf("myComment=TIMESTAMP;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d", - aMeshName.c_str(), - anEntity, - aFieldName.c_str(), - aTimeStamp, - aField->myNbComp); - - string aTimeStampId = VISU_Convertor::GenerateName(aValForTime->myTime); - - aValForTime->myEntry = CreateAttributes( - theStudy, - aField->myEntry, - "", - aTimeStampId, - aComment.latin1(), - true); - } - } - } - - if(!anIsFieldsEntryUpdated && !theIsAtOnce) - RemoveSObject(theStudy, aMesh->myFieldsEntry); - } - - ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone)); - } - - -#ifdef ENABLE_MULTIPR - // MULTIPR - void BuildParts (Result_i* theResult, - VISU_Convertor* theInput, - CORBA::Boolean* theIsDone, - CORBA::Boolean theIsBuild, - CORBA::Boolean theIsAtOnce, - _PTR(Study) theStudy) - { - if(!theIsBuild || *theIsDone) - return; - - // if MED file is not a distributed MED file (created with MULTIPR), - // then it is not necessary to build parts - if (theResult->GetFileInfoMultipr().filePath().isEmpty()) - return; - - try - { - multipr::Obj multiprObj; - multiprObj.create(theResult->GetFileInfoMultipr().filePath().latin1()); - if (multiprObj.isValidDistributedMEDFile()) - { - theResult->SetIsDistributedMEDMultipr(true); - - const TMeshMap& aMeshMap = theInput->GetMeshMap(); - TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); - const PMesh& aMesh = aMeshMapIter->second; - - vector listParts = multiprObj.getParts(); - - QString aComment = "Sub-parts: #"; - aComment += QString::number(listParts.size()); - - UpdateAttributes( - theStudy, - aMesh->myPartsEntry, - "", - "Parts", - aComment.latin1()); - - string lastEntry; - - for (unsigned i = 0 ; i < listParts.size() ; i++) - { - const char* strItem = listParts[i].c_str(); - const char* strPartInfo = multiprObj.getPartInfo(strItem).c_str(); - - char lMeshName[256]; - int lId; - char lPartName[256]; - char lPath[256]; - char lMEDFileName[256]; - - // parse infos - sscanf(strPartInfo, "%s %d %s %s %s", - lMeshName, - &lId, - lPartName, - lPath, - lMEDFileName); - - if ((strstr(lPartName,"_MED") != NULL) || (strstr(lPartName,"_LOW") != NULL)) - { - QString aComment = ""; - aComment.append("myComment=PART;"); - aComment.append("res=ML;"); - aComment.append("file="); - aComment.append(lMEDFileName); - - CreateAttributes( - theStudy, - lastEntry, // father - "", - lPartName, - aComment.latin1(), - true); - } - else - { - QString aComment = ""; - QString icon = ""; - - if (i != listParts.size()-1) - { - const char* strItemNext = listParts[i+1].c_str(); - const char* strPartInfoNext = multiprObj.getPartInfo(strItemNext).c_str(); - if ((strstr(strPartInfoNext,"_MED") != NULL) || (strstr(strPartInfoNext,"_LOW") != NULL)) - { - // next part is MED or LOW resolution - icon = "ICON_MULTIPR_VIEW_LOW"; - theResult->SetResolutionMultipr(lPartName, 'L'); - - aComment.append("myComment=PART;"); - aComment.append("res=FML;"); - aComment.append("file="); - aComment.append(lMEDFileName); - } - else - { - // no resolution associated with this part - icon = "ICON_MULTIPR_VIEW_FULL"; - theResult->SetResolutionMultipr(lPartName, 'F'); - - aComment.append("myComment=PART;"); - aComment.append("res=F;"); - aComment.append("file="); - aComment.append(lMEDFileName); - } - } - else - { - // last part - icon = "ICON_MULTIPR_VIEW_FULL"; - theResult->SetResolutionMultipr(lPartName, 'F'); - - aComment.append("myComment=PART;"); - aComment.append("res=FML;"); - aComment.append("file="); - aComment.append(lMEDFileName); - } - - lastEntry = CreateAttributes( - theStudy, - aMesh->myPartsEntry, // father - "", - lPartName, - aComment.latin1(), - true, - icon.latin1()); - } - - theResult->AddPartMultipr(lPartName, lMEDFileName); - } - } - else - { - // invalid distributed MED file - return; - } - } - catch (...) - { - throw std::runtime_error("error while reading distributed MED file"); - } - - ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone)); - } -#endif - - - //--------------------------------------------------------------- - void - BuildMinMax(Result_i* theResult, - VISU_Convertor* theInput, - CORBA::Boolean* theIsDone, - CORBA::Boolean theIsBuild, - Result_i::TUpdateMinMaxSignal* theUpdateMinMaxSignal) - { - if(!theIsBuild || *theIsDone) - return; - - TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildMinMax"); - TResultManager aResultManager(theResult); - - theInput->BuildMinMax(); - - *theIsDone = true; - - (*theUpdateMinMaxSignal)(); - } - - - //--------------------------------------------------------------- - void - BuildFieldDataTree(Result_i* theResult, - VISU_Convertor* theInput, - CORBA::Boolean* theIsFieldsDone, - CORBA::Boolean theIsBuildFields, - CORBA::Boolean* theIsMinMaxDone, - CORBA::Boolean theIsBuildMinMax, - Result_i::TUpdateMinMaxSignal* theUpdateMinMaxSignal, - _PTR(Study) theStudy) - { - BuildFields(theResult, - theInput, - theIsFieldsDone, - theIsBuildFields, - false, - theStudy); - - BuildMinMax(theResult, - theInput, - theIsMinMaxDone, - theIsBuildMinMax, - theUpdateMinMaxSignal); - } - - - //--------------------------------------------------------------- - struct TBuildArgs - { - Result_i* myResult; - VISU_Convertor* myInput; - CORBA::Boolean* myIsEntitiesDone; - std::string myResultEntry; - CORBA::Boolean* myIsFieldsDone; - CORBA::Boolean myIsBuildFields; - CORBA::Boolean* myIsMinMaxDone; - CORBA::Boolean myIsBuildMinMax; - Result_i::TUpdateMinMaxSignal* myUpdateMinMaxSignal; - CORBA::Boolean* myIsGroupsDone; - CORBA::Boolean myIsBuildGroups; -#ifdef ENABLE_MULTIPR - CORBA::Boolean* myIsPartsDone; - CORBA::Boolean myIsBuildParts; -#endif - _PTR(Study) myStudy; - - TBuildArgs(Result_i* theResult, - VISU_Convertor* theInput, - CORBA::Boolean* theIsEntitiesDone, - std::string theResultEntry, - CORBA::Boolean* theIsFieldsDone, - CORBA::Boolean theIsBuildFields, - CORBA::Boolean* theIsMinMaxDone, - CORBA::Boolean theIsBuildMinMax, - Result_i::TUpdateMinMaxSignal* theUpdateMinMaxSignal, - CORBA::Boolean* theIsGroupsDone, - CORBA::Boolean theIsBuildGroups, -#ifdef ENABLE_MULTIPR - CORBA::Boolean* theIsPartsDone, - CORBA::Boolean theIsBuildParts, -#endif - _PTR(Study) theStudy): - myResult(theResult), - myInput(theInput), - myIsEntitiesDone(theIsEntitiesDone), - myResultEntry(theResultEntry), - myIsFieldsDone(theIsFieldsDone), - myIsBuildFields(theIsBuildFields), - myIsMinMaxDone(theIsMinMaxDone), - myIsBuildMinMax(theIsBuildMinMax), - myUpdateMinMaxSignal(theUpdateMinMaxSignal), - myIsGroupsDone(theIsGroupsDone), - myIsBuildGroups(theIsBuildGroups), -#ifdef ENABLE_MULTIPR - myIsPartsDone(theIsPartsDone), - myIsBuildParts(theIsBuildParts), -#endif - myStudy(theStudy) - {} - }; - - //--------------------------------------------------------------- - void - BuildDataTree(TBuildArgs theBuildArgs) - { - BuildEntities(theBuildArgs.myResult, - theBuildArgs.myInput, - theBuildArgs.myIsEntitiesDone, - theBuildArgs.myResultEntry, - false, - theBuildArgs.myIsBuildGroups, - theBuildArgs.myIsBuildFields, - theBuildArgs.myStudy); - - { - boost::thread aThread(boost::bind(&BuildGroups, - theBuildArgs.myResult, - theBuildArgs.myInput, - theBuildArgs.myIsGroupsDone, - theBuildArgs.myIsBuildGroups, - false, - theBuildArgs.myStudy)); - } - { - boost::thread aThread(boost::bind(&BuildFieldDataTree, - theBuildArgs.myResult, - theBuildArgs.myInput, - theBuildArgs.myIsFieldsDone, - theBuildArgs.myIsBuildFields, - theBuildArgs.myIsMinMaxDone, - theBuildArgs.myIsBuildMinMax, - theBuildArgs.myUpdateMinMaxSignal, - theBuildArgs.myStudy)); - } - - /* - // MULTIPR - BuildParts(theBuildArgs.myResult, - theBuildArgs.myInput, - theBuildArgs.myIsPartsDone, - theBuildArgs.myIsBuildParts, - false, - theBuildArgs.myStudy); - */ - } -} - - //--------------------------------------------------------------- -VISU::MinMaxCunsomer -::MinMaxCunsomer(): - myMinMaxIsInitilized(false) -{} - -bool -VISU::MinMaxCunsomer -::IsMinMaxInitilized() -{ - return myMinMaxIsInitilized; -} - -void -VISU::MinMaxCunsomer -::UpdateMinMax() -{ - myMinMaxIsInitilized = true; } @@ -1093,23 +153,15 @@ VISU::Result_i myIsBuildFields(theIsBuildFields), myIsBuildMinMax(theIsBuildMinMax), myIsBuildGroups(theIsBuildGroups), -#ifdef ENABLE_MULTIPR - myIsBuildParts(true), -#endif myIsEntitiesDone(false), myIsFieldsDone(false), myIsGroupsDone(false), myIsMinMaxDone(false), -#ifdef ENABLE_MULTIPR - myIsPartsDone(false), -#endif myIsAllDone(false), - myInput(NULL) + myIsBuildParts(false), + myIsPartsDone(false) { - myStudy = ProcessEvent(new TGetStudy(myStudyDocument->StudyId())); -#ifdef ENABLE_MULTIPR - myIsDistributedMEDMultipr = false; -#endif + myStudy = VISU::GetStudy(myStudyDocument); } @@ -1142,9 +194,26 @@ VISU::Result_i //--------------------------------------------------------------- void VISU::Result_i -::MinMaxConnect(VISU::MinMaxCunsomer* theMinMaxCunsomer) +::ConnectObserver(TResultObserver* theObserver, + boost::signalslib::connection& theConnection) { - myUpdateMinMaxSignal.connect(boost::bind(&MinMaxCunsomer::UpdateMinMax,theMinMaxCunsomer)); + if(theConnection.connected()) + theConnection.disconnect(); + + theConnection = + myUpdateObserverSignal.connect(boost::bind(boost::bind(&TResultObserver::UpdateFromResult, + theObserver, + _1), + this)); +} + + +//--------------------------------------------------------------- +void +VISU::Result_i +::UpdateObservers() +{ + myUpdateObserverSignal(); } @@ -1263,7 +332,7 @@ VISU::Result_i if(theIsBuildAll) theIsAtOnce = true; - if(Build(SALOMEDS::SObject::_nil(),theIsAtOnce)){ + if(Build(SALOMEDS::SObject::_nil(), theIsAtOnce)){ // Set icon SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder(); @@ -1304,17 +373,19 @@ VISU::Result_i GetComment(), myFileInfo.filePath().latin1(), myInitFileName.c_str()); // Restoring of Python dump - string aResultEntry = + std::string aResultEntry = CreateAttributes(myStudy, aSComponentEntry.in(), + NO_ICON, anIOR.in(), myName, + NO_PERFSITENT_REF, aComment.latin1(), true); mySObject = myStudyDocument->FindObjectID(aResultEntry.c_str()); if(!CORBA::is_nil(theSObject)){ CORBA::String_var aString = theSObject->GetID(); - CreateReference(myStudyDocument,aResultEntry,aString.in()); + CreateReference(myStudyDocument, aResultEntry, aString.in()); } if(theIsAtOnce){ @@ -1325,6 +396,7 @@ VISU::Result_i theIsAtOnce, myIsBuildGroups, myIsBuildFields, + myIsBuildParts, myStudy); BuildGroups(this, @@ -1344,91 +416,53 @@ VISU::Result_i BuildMinMax(this, myInput, &myIsMinMaxDone, - myIsBuildMinMax, - &myUpdateMinMaxSignal); - -#ifdef ENABLE_MULTIPR - // MULTIPR - BuildParts(this, - myInput, - &myIsPartsDone, - myIsBuildParts, - theIsAtOnce, - myStudy); -#endif + myIsBuildMinMax); } else { -#ifdef ENABLE_MULTIPR - if (strlen(GetFileInfoMultipr().filePath().latin1()) == 0) -#endif - { - // sequential MED file - TBuildArgs aBuildArgs(this, - myInput, - &myIsEntitiesDone, - aResultEntry, - &myIsFieldsDone, - myIsBuildFields, - &myIsMinMaxDone, - myIsBuildMinMax, - &myUpdateMinMaxSignal, - &myIsGroupsDone, - myIsBuildGroups, -#ifdef ENABLE_MULTIPR - &myIsPartsDone, - myIsBuildParts, -#endif - myStudy); - boost::thread aThread(boost::bind(&BuildDataTree, aBuildArgs)); - } -#ifdef ENABLE_MULTIPR - else - { - // distributed MED file - BuildEntities(this, - myInput, - &myIsEntitiesDone, - aResultEntry, - theIsAtOnce, - myIsBuildGroups, - myIsBuildFields, - myStudy); - - BuildGroups(this, - myInput, - &myIsGroupsDone, - myIsBuildGroups, - theIsAtOnce, - myStudy); - - BuildFields(this, - myInput, - &myIsFieldsDone, - myIsBuildFields, - theIsAtOnce, - myStudy); - - BuildMinMax(this, - myInput, - &myIsMinMaxDone, - myIsBuildMinMax, - &myUpdateMinMaxSignal); - - // MULTIPR - BuildParts(this, - myInput, - &myIsPartsDone, - myIsBuildParts, - theIsAtOnce, - myStudy); - } -#endif + boost::thread aThread(boost::bind(boost::bind(&Result_i::BuildDataTree, this, _1), + aResultEntry)); } return this; } +//--------------------------------------------------------------- +void +VISU::Result_i +::BuildDataTree(const std::string& theResultEntry) +{ + BuildEntities(this, + myInput, + &myIsEntitiesDone, + theResultEntry, + false, + myIsBuildGroups, + myIsBuildFields, + myIsBuildParts, + myStudy); + + { + boost::thread aThread(boost::bind(&BuildGroups, + this, + myInput, + &myIsGroupsDone, + myIsBuildGroups, + false, + myStudy)); + } + { + boost::thread aThread(boost::bind(&BuildFieldDataTree, + this, + myInput, + &myIsFieldsDone, + myIsBuildFields, + &myIsMinMaxDone, + myIsBuildMinMax, + myStudy)); + } +} + //--------------------------------------------------------------- VISU::Storable* VISU::Result_i @@ -1457,46 +491,8 @@ Create(const char* theFileName) { try { myFileInfo.setFile(theFileName); - -#ifdef ENABLE_MULTIPR - // MULTIPR - if (myFileInfo.filePath().endsWith("_grains_maitre.med")) - { - // retrieve source MED file (sequential MED file) - QString originalMEDFileName = ""; - FILE* aFile = fopen(theFileName, "rt"); - char aBuf[1024]; - while (!feof(aFile)) - { - fgets(aBuf, 1024, aFile); - char* strTag = NULL; - if ((aBuf[0] == '#') && ((strTag = strstr(aBuf, "[SOURCE]=")) != NULL)) - { - char strSequentialMEDFilename[256]; - int ret = sscanf(strTag, "[SOURCE]=%s", strSequentialMEDFilename); - if (ret == 1) - { - originalMEDFileName = strSequentialMEDFilename; - break; - } - } - } - fclose(aFile); - if (originalMEDFileName == "") - throw std::runtime_error("distributed MED file; bad format"); - - //cout << "MULTIPR: original med file=" << originalMEDFileName << endl; - myFileInfoMultipr.setFile(myFileInfo.filePath()); - myFileInfo.setFile(originalMEDFileName); - } - else - { - myFileInfoMultipr.setFile(""); - } -#endif - myInitFileName = myFileInfo.filePath().latin1(); - myName = ::GenerateName(myFileInfo.fileName()).latin1(); + myName = VISU::GenerateName(myFileInfo.fileName()).latin1(); if(mySourceId == eRestoredFile){ std::string aTmpDir(SALOMEDS_Tool::GetTmpDir()); static QString aCommand; @@ -1512,7 +508,7 @@ Create(const char* theFileName) myFileInfo.setFile(QString(aTmpDir.c_str()) + myFileInfo.fileName()); } - myInput = CreateConvertor(myFileInfo.absFilePath().latin1()); + myInput.reset(CreateConvertor(myFileInfo.absFilePath().latin1())); if(myInput){ if(myIsBuildImmediately) @@ -1535,8 +531,8 @@ VISU::Result_i { if(MYDEBUG) MESSAGE("Result_i::Create MedObject from SALOMEDS::SObject_ptr"); try{ - myInput = CreateMEDConvertor(theMedSObject); - if(myInput == NULL) + myInput.reset(CreateMEDConvertor(theMedSObject)); + if(!myInput) return NULL; myInput->Build(); @@ -1545,7 +541,7 @@ VISU::Result_i myFileInfo.setFile(aCompDataType.c_str()); myInitFileName = aCompDataType; - myName = ::GenerateName("aResult").latin1(); + myName = VISU::GenerateName("aResult").latin1(); return Build(theMedSObject); }catch(std::exception& exc){ @@ -1564,8 +560,8 @@ VISU::Result_i { if(MYDEBUG) MESSAGE("Result_i::Create MedObject from SALOME_MED::FIELD_ptr"); try{ - myInput = CreateMEDFieldConvertor(theField); - if(myInput == NULL) + myInput.reset(CreateMEDFieldConvertor(theField)); + if(!myInput) return NULL; myInput->Build(); @@ -1574,7 +570,7 @@ VISU::Result_i myFileInfo.setFile(aCompDataType.c_str()); myInitFileName = aCompDataType; - myName = ::GenerateName("aResult").latin1(); + myName = VISU::GenerateName("aResult").latin1(); CORBA::String_var anIOR = myStudyDocument->ConvertObjectToIOR(theField); SALOMEDS::SObject_var aFieldSObject = myStudyDocument->FindObjectIOR(anIOR); @@ -1620,31 +616,17 @@ VISU::Result_i SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder(); SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aEngComp); aStudyBuilder->LoadWith(aCompRefSObj, aDriver); - /* - if (strcmp(aDataType, "MED") == 0){ - // create field or MED converter - CORBA::Object_var aMedObject = VISU::SObjectToObject(aTargetRefSObj); - SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(aMedObject); - if(!CORBA::is_nil(aField)) - myInput = CreateMEDFieldConvertor(aField); - else - myInput = CreateMEDConvertor(aTargetRefSObj); - myInput->Build(); - }else - throw std::runtime_error("GetInput - There is no convertor for the aDataType !!!"); - //*/ - // create field or MED converter CORBA::Object_var aMedObject = VISU::SObjectToObject(aTargetRefSObj); SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(aMedObject); if (!CORBA::is_nil(aField)) { // create field converter - myInput = CreateMEDFieldConvertor(aField); + myInput.reset(CreateMEDFieldConvertor(aField)); myInput->Build(); } else if (strcmp(aDataType, "MED") == 0) { // create MED converter - myInput = CreateMEDConvertor(aTargetRefSObj); + myInput.reset(CreateMEDConvertor(aTargetRefSObj)); myInput->Build(); } else { @@ -1708,7 +690,7 @@ VISU::Result_i mySourceId = eFile; } if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - mySourceId = " << mySourceId); - myInput = CreateConvertor(myFileInfo.filePath().latin1()); + myInput.reset(CreateConvertor(myFileInfo.filePath().latin1())); myInput->BuildEntities(); if(myIsBuildFields){ @@ -1747,14 +729,27 @@ VISU::Result_i return NULL; } + //--------------------------------------------------------------- -VISU::Result_i::TInput* +void VISU::Result_i -::GetInput() +::SetResolution(const std::string& theName, + TResolutionID theNewResolution) +{} + + +//--------------------------------------------------------------- +VISU::Result_i::PInput +VISU::Result_i +::GetInput(const std::string& theMeshName, + VISU::Entity theEntity, + const std::string& theFieldName, + CORBA::Long theTimeStampNumber) { return myInput; } + //--------------------------------------------------------------- CORBA::Boolean VISU::Result_i @@ -1815,17 +810,23 @@ VISU::Result_i } //--------------------------------------------------------------- -void +VISU::Result_i* VISU::Result_i -::ToStream(std::ostringstream& theStr) +::New(SALOMEDS::Study_ptr theStudy, + const ESourceId& theSourceId, + const ECreationId& theCreationId, + CORBA::Boolean theIsBuildImmediately, + CORBA::Boolean theIsBuildFields, + CORBA::Boolean theIsBuildMinMax, + CORBA::Boolean theIsBuildGroups) { - if(MYDEBUG) MESSAGE(GetComment()); - Storable::DataToStream(theStr,"myName",myName.c_str()); - Storable::DataToStream(theStr,"myInitFileName",myInitFileName.c_str()); - Storable::DataToStream(theStr,"myCreationId",myCreationId); - Storable::DataToStream(theStr,"myIsBuildFields",myIsFieldsDone); - Storable::DataToStream(theStr,"myIsBuildMinMax",myIsMinMaxDone); - Storable::DataToStream(theStr,"myIsBuildGroups",myIsGroupsDone); + return new RESULT_CLASS_NAME(theStudy, + theSourceId, + theCreationId, + theIsBuildImmediately, + theIsBuildFields, + theIsBuildMinMax, + theIsBuildGroups); } @@ -1847,27 +848,68 @@ VISU::Result_i CORBA::Boolean anIsBuildMinMax = Storable::FindValue(theMap,"myIsBuildMinMax","1").toInt(); CORBA::Boolean anIsBuildGroups = Storable::FindValue(theMap,"myIsBuildGroups","1").toInt(); - VISU::Result_i* aResult = new VISU::Result_i(aStudy, - aSourceId, - aCreationId, - anIsBuildFields, - anIsBuildMinMax, - anIsBuildGroups); + VISU::Result_i* aResult = new RESULT_CLASS_NAME(aStudy, + aSourceId, + aCreationId, + anIsBuildFields, + anIsBuildMinMax, + anIsBuildGroups); if (aResult == NULL) return NULL; - return aResult->Restore(theSObject,theMap,thePrefix); + return aResult->Restore(theSObject, theMap, thePrefix); } //--------------------------------------------------------------- -string +void +VISU::Result_i +::ToStream(std::ostringstream& theStr) +{ + if(MYDEBUG) MESSAGE(GetComment()); + Storable::DataToStream(theStr,"myName",myName.c_str()); + Storable::DataToStream(theStr,"myInitFileName",myInitFileName.c_str()); + Storable::DataToStream(theStr,"myCreationId",myCreationId); + Storable::DataToStream(theStr,"myIsBuildFields",myIsFieldsDone); + Storable::DataToStream(theStr,"myIsBuildMinMax",myIsMinMaxDone); + Storable::DataToStream(theStr,"myIsBuildGroups",myIsGroupsDone); +} + + +//--------------------------------------------------------------- +const std::string& +VISU::Result_i +::GetName() const +{ + return myName; +} + + +const QFileInfo& +VISU::Result_i +::GetFileInfo() const +{ + return myFileInfo; +} + + +const std::string& +VISU::Result_i +::GetFileName() const +{ + return myInitFileName; +} + + +const VISU::Result_i::ECreationId& VISU::Result_i -::GetRefFatherEntry() +::GetCreationId() const { - return ""; + return myCreationId; } + +//--------------------------------------------------------------- std::string VISU::Result_i ::GetEntry() @@ -1890,6 +932,13 @@ VISU::Result_i return myStudyDocument; } +_PTR(Study) +VISU::Result_i +::GetStudy() const +{ + return myStudy; +} + const SALOMEDS::SComponent_var& VISU::Result_i ::GetSComponent() const @@ -1931,15 +980,14 @@ VISU::Result_i res = system(aCommand); MESSAGE("Result_i::~Result_i - system("<::iterator anIterator = mySelectedResolutionMultipr.find(theName); - - if (anIterator == mySelectedResolutionMultipr.end()) - { - // current name does not exist: create - mySelectedResolutionMultipr.insert(make_pair(theName, theNewResolution)); - } - else - { - // modify - (*anIterator).second = theNewResolution; - } -} - -// MULTIPR -string VISU::Result_i::FindPartMultipr(const char* theName) -{ - map::iterator anIterator = myMapPartNameToMEDFilename.find(theName); - - if (anIterator == myMapPartNameToMEDFilename.end()) - { - return NULL; - } - return (*anIterator).second; -} - -// MULTIPR -void VISU::Result_i::SetIsDistributedMEDMultipr(bool theIsDistributedMED) -{ - myIsDistributedMEDMultipr = theIsDistributedMED; -} - -// MULTIPR -bool VISU::Result_i::IsDistributedMEDMultipr() const -{ - return myIsDistributedMEDMultipr; -} - -// MULTIPR -vector VISU::Result_i::GetCurrentRepresentationMultipr() -{ - // name of selected parts - vector res; - - // for each part of the mesh - for (map::iterator it = mySelectedResolutionMultipr.begin() ; - it != mySelectedResolutionMultipr.end() ; - it++) - { - const char* partName = ((*it).first).c_str(); - char resolution = (*it).second; - - //cout << "name=" << partName << " res=" << resolution << endl; - - if (resolution == 'F') - { - res.push_back( FindPartMultipr(partName) ); - } - else if (resolution == 'M') - { - char subPartName[256]; - sprintf(subPartName, "%s_MED", partName); - res.push_back( FindPartMultipr(subPartName) ); - } - else if (resolution == 'L') - { - char subPartName[256]; - sprintf(subPartName, "%s_LOW", partName); - res.push_back( FindPartMultipr(subPartName) ); - } - } - - return res; -} -#endif // ENABLE_MULTIPR diff --git a/src/VISU_I/VISU_Result_i.hh b/src/VISU_I/VISU_Result_i.hh index 4ef575d0..bd8ec41d 100644 --- a/src/VISU_I/VISU_Result_i.hh +++ b/src/VISU_I/VISU_Result_i.hh @@ -31,8 +31,10 @@ #include "VISU_BoostSignals.h" #include "SALOME_GenericObj_i.hh" +#include "SALOME_Event.hxx" #include "VTKViewer.h" +#include #include #include #include @@ -42,27 +44,22 @@ class VISU_Convertor; namespace VISU { //---------------------------------------------------------------------------- - class VISU_I_EXPORT MinMaxCunsomer: public virtual boost::signalslib::trackable - { - protected: - bool myMinMaxIsInitilized; - MinMaxCunsomer(); + class Result_i; - public: - virtual - bool - IsMinMaxInitilized(); + //---------------------------------------------------------------------------- + struct TResultObserver: public virtual boost::signalslib::trackable + { virtual void - UpdateMinMax(); + UpdateFromResult(Result_i* theResult) = 0; }; //---------------------------------------------------------------------------- class VISU_I_EXPORT Result_i : public virtual POA_VISU::Result, - public virtual RemovableObject_i, - public virtual SALOME::GenericObj_i + public virtual RemovableObject_i, + public virtual SALOME::GenericObj_i { Result_i(const Result_i &); @@ -70,136 +67,221 @@ namespace VISU enum ESourceId {eRestoredComponent = -2, eRestoredFile = -1, eFile = 1, eComponent = 2}; enum ECreationId {eImportFile, eCopyAndImportFile, eImportMed, eImportMedField}; - Result_i(SALOMEDS::Study_ptr theStudy, - const ESourceId& theSourceId, - const ECreationId& theCreationId, - CORBA::Boolean theIsBuildImmediately = true, - CORBA::Boolean theIsBuildFields = true, - CORBA::Boolean theIsBuildMinMax = true, - CORBA::Boolean theIsBuildGroups = true); + static + Result_i* + New(SALOMEDS::Study_ptr theStudy, + const ESourceId& theSourceId, + const ECreationId& theCreationId, + CORBA::Boolean theIsBuildImmediately = true, + CORBA::Boolean theIsBuildFields = true, + CORBA::Boolean theIsBuildMinMax = true, + CORBA::Boolean theIsBuildGroups = true); + + virtual + void + RemoveFromStudy(); - virtual ~Result_i(); - virtual void RemoveFromStudy(); + virtual + VISU::VISUType + GetType() + { + return VISU::TRESULT; + } - virtual VISU::VISUType GetType() { return VISU::TRESULT;} - virtual CORBA::Boolean BuildAll(); + virtual + CORBA::Boolean + BuildAll(); - virtual CORBA::Boolean Build(CORBA::Boolean theIsBuildAll, - CORBA::Boolean theIsAtOnce); - virtual CORBA::Boolean IsDone(); + virtual + CORBA::Boolean + Build(CORBA::Boolean theIsBuildAll, + CORBA::Boolean theIsAtOnce); - virtual CORBA::Boolean IsEntitiesDone(); + virtual + CORBA::Boolean + IsDone(); - virtual void SetBuildFields(CORBA::Boolean theIsBuildFields, - CORBA::Boolean theIsCalculateMinMax); - virtual CORBA::Boolean IsFieldsDone(); + virtual + CORBA::Boolean + IsEntitiesDone(); - virtual void SetBuildGroups(CORBA::Boolean theIsBuildGroups); - virtual CORBA::Boolean IsGroupsDone(); + virtual + void + SetBuildFields(CORBA::Boolean theIsBuildFields, + CORBA::Boolean theIsCalculateMinMax); - virtual CORBA::Boolean IsMinMaxDone(); + virtual + CORBA::Boolean + IsFieldsDone(); + + virtual + void + SetBuildGroups(CORBA::Boolean theIsBuildGroups); + + virtual + CORBA::Boolean + IsGroupsDone(); + + virtual + CORBA::Boolean + IsMinMaxDone(); virtual void - MinMaxConnect(MinMaxCunsomer* theMinMaxCunsomer); + UpdateObservers(); - typedef boost::signal0 TUpdateMinMaxSignal; + virtual + void + ConnectObserver(TResultObserver* theObserver, + boost::signalslib::connection& theConnection); + + typedef boost::signal0 TUpdateObserverSignal; typedef VISU_Convertor TInput; + typedef boost::shared_ptr PInput; private: ESourceId mySourceId; ECreationId myCreationId; - TInput *myInput; - std::string myName, myInitFileName; + PInput myInput; + std::string myName; QFileInfo myFileInfo; - -#ifdef ENABLE_MULTIPR - // MULTIPR - QFileInfo myFileInfoMultipr; - std::map myMapPartNameToMEDFilename; - std::map mySelectedResolutionMultipr; - bool myIsDistributedMEDMultipr; -#endif + std::string myInitFileName; protected: - virtual Storable* Build(SALOMEDS::SObject_ptr theSObject, - CORBA::Boolean theIsAtOnce = true) ; - virtual Storable* BuildAll(SALOMEDS::SObject_ptr theSObject) ; + Result_i(SALOMEDS::Study_ptr theStudy, + const ESourceId& theSourceId, + const ECreationId& theCreationId, + CORBA::Boolean theIsBuildImmediately = true, + CORBA::Boolean theIsBuildFields = true, + CORBA::Boolean theIsBuildMinMax = true, + CORBA::Boolean theIsBuildGroups = true); + + virtual + ~Result_i(); + + virtual + Storable* + Build(SALOMEDS::SObject_ptr theSObject, + CORBA::Boolean theIsAtOnce = true) ; + + virtual + void + BuildDataTree(const std::string& theResultEntry); + + virtual + Storable* + BuildAll(SALOMEDS::SObject_ptr theSObject) ; _PTR(Study) myStudy; CORBA::Boolean myIsBuildImmediately; CORBA::Boolean myIsEntitiesDone; - CORBA::Boolean myIsFieldsDone; - CORBA::Boolean myIsGroupsDone; - CORBA::Boolean myIsMinMaxDone; -#ifdef ENABLE_MULTIPR - CORBA::Boolean myIsPartsDone; // MULTIPR -#endif + CORBA::Boolean myIsFieldsDone; CORBA::Boolean myIsBuildFields; + + CORBA::Boolean myIsGroupsDone; CORBA::Boolean myIsBuildGroups; + CORBA::Boolean myIsPartsDone; + CORBA::Boolean myIsBuildParts; + + CORBA::Boolean myIsMinMaxDone; CORBA::Boolean myIsBuildMinMax; -#ifdef ENABLE_MULTIPR - CORBA::Boolean myIsBuildParts; // MULTIPR -#endif - TUpdateMinMaxSignal myUpdateMinMaxSignal; + TUpdateObserverSignal myUpdateObserverSignal; CORBA::Boolean myIsAllDone; public: - virtual size_t IsPossible(); + virtual + size_t + IsPossible(); + + virtual + Storable* + Create(const char* theFileName); + + virtual + Storable* + Create(SALOMEDS::SObject_ptr theMedSObject); + + virtual + Storable* + Create(SALOME_MED::FIELD_ptr theField); - virtual Storable* Create(const char* theFileName); - virtual Storable* Create(SALOMEDS::SObject_ptr theMedSObject); - virtual Storable* Create(SALOME_MED::FIELD_ptr theField); + virtual + Storable* + Restore(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap, + const std::string& thePrefix); + + static + Storable* + Restore(SALOMEDS::SObject_ptr theSObject, + const std::string& thePrefix, + const Storable::TRestoringMap& theMap); - virtual Storable* Restore(SALOMEDS::SObject_ptr theSObject, - const Storable::TRestoringMap& theMap, - const std::string& thePrefix); + virtual + void + ToStream(std::ostringstream& theStr); - static Storable* Restore(SALOMEDS::SObject_ptr theSObject, - const std::string& thePrefix, - const Storable::TRestoringMap& theMap); + virtual + const char* + GetComment() const; - virtual void ToStream(std::ostringstream& theStr); - virtual const char* GetComment() const; static const std::string myComment; - TInput* GetInput(); - const std::string& GetName() const { return myName;} - const QFileInfo& GetFileInfo() const { return myFileInfo;} -#ifdef ENABLE_MULTIPR - const QFileInfo& GetFileInfoMultipr() const { return myFileInfoMultipr;} -#endif - const std::string& GetFileName() const { return myInitFileName;} - const ECreationId& GetCreationId() const { return myCreationId;} - -#ifdef ENABLE_MULTIPR - // MULTIPR - void AddPartMultipr(const char* thePartName, const char* theMEDFilename); - void SetResolutionMultipr(const char* theName, char theNewResolution); // 'F'=FULL 'M'=MEDIUM 'L'=LOW 'H'=HIDE - std::string FindPartMultipr(const char* theName); - std::vector GetCurrentRepresentationMultipr(); - void SetIsDistributedMEDMultipr(bool theIsDistributedMED); - bool IsDistributedMEDMultipr() const; -#endif + typedef char TResolutionID; + + virtual + void + SetResolution(const std::string& theName, + TResolutionID theNewResolution); + virtual + PInput + GetInput(const std::string& theMeshName = "", + VISU::Entity theEntity = VISU::NONE, + const std::string& theFieldName = "", + CORBA::Long theTimeStampNumber = -1); + + const std::string& + GetName() const; + + const QFileInfo& + GetFileInfo() const; + + const std::string& + GetFileName() const; + + const ECreationId& + GetCreationId() const; + private: SALOMEDS::SObject_var mySObject; SALOMEDS::Study_var myStudyDocument; SALOMEDS::SComponent_var mySComponent; public: - std::string GetRefFatherEntry(); - std::string GetEntry(); - const SALOMEDS::SObject_var& GetSObject() const; - const SALOMEDS::Study_var& GetStudyDocument() const; - const SALOMEDS::SComponent_var& GetSComponent() const; - std::string GetEntry(const Storable::TRestoringMap& theRestoringMap); + std::string + GetEntry(); + + const SALOMEDS::SObject_var& + GetSObject() const; + + const SALOMEDS::Study_var& + GetStudyDocument() const; + + _PTR(Study) + GetStudy() const; + + const SALOMEDS::SComponent_var& + GetSComponent() const; + + std::string + GetEntry(const Storable::TRestoringMap& theRestoringMap); // Info on structured mesh contained in TInput public: diff --git a/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc b/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc index 2dacbee6..a6d4e340 100644 --- a/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc +++ b/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc @@ -65,7 +65,7 @@ VISU::ScalarMapOnDeformedShape_i theTimeStampNumber, false); if(theIsMemoryCheck && aResult){ - VISU::Result_i::TInput* anInput = theResult->GetInput(); + VISU::Result_i::PInput anInput = theResult->GetInput(); const VISU::PField aField = anInput->GetField(theMeshName, (VISU::TEntity)theEntity, theFieldName); @@ -328,7 +328,7 @@ VISU::ScalarMapOnDeformedShape_i return; VISU::TEntity aEntity = VISU::TEntity(theEntity); - VISU::Result_i::TInput* anInput = GetCResult()->GetInput(); + VISU::Result_i::PInput anInput = GetCResult()->GetInput(); myScalarField = anInput->GetField(GetCMeshName(), aEntity, theFieldName); VISU::PUnstructuredGridIDMapper anIDMapper = diff --git a/src/VISU_I/VISU_ScalarMap_i.cc b/src/VISU_I/VISU_ScalarMap_i.cc index 3a82f2be..746bd977 100644 --- a/src/VISU_I/VISU_ScalarMap_i.cc +++ b/src/VISU_I/VISU_ScalarMap_i.cc @@ -67,7 +67,7 @@ VISU::ScalarMap_i try{ if(theResult){ bool anIsEstimated = true; - VISU::Result_i::TInput* anInput = theResult->GetInput(); + VISU::Result_i::PInput anInput = theResult->GetInput(); size_t aSize = anInput->GetTimeStampOnMeshSize(theMeshName, (VISU::TEntity)theEntity, theFieldName, @@ -375,7 +375,7 @@ void VISU::ScalarMap_i ::AddMeshOnGroup(const char* theGroupName) { - VISU::Result_i::TInput* anInput = GetCResult()->GetInput(); + VISU::Result_i::PInput anInput = GetCResult()->GetInput(); VISU::PUnstructuredGridIDMapper anIDMapper = anInput->GetMeshOnGroup(GetCMeshName(), theGroupName); if(anIDMapper){ int aNbGroups = myGroupNames.size(); @@ -407,7 +407,7 @@ void VISU::ScalarMap_i ::DoSetInput(bool theIsInitilizePipe, bool theReInit) { - VISU::Result_i::TInput* anInput = GetCResult()->GetInput(); + VISU::Result_i::PInput anInput = GetCResult()->GetInput(); if(!anInput) throw std::runtime_error("Mesh_i::Build - GetCResult()->GetInput() == NULL !!!"); diff --git a/src/VISU_I/VISU_StreamLines_i.cc b/src/VISU_I/VISU_StreamLines_i.cc index 86f4cbe0..1a2149b3 100644 --- a/src/VISU_I/VISU_StreamLines_i.cc +++ b/src/VISU_I/VISU_StreamLines_i.cc @@ -59,7 +59,7 @@ VISU::StreamLines_i if(!TSuperClass::IsPossible(theResult, theMeshName, theEntity, theFieldName, theTimeStampNumber, false)) return 0; - VISU::Result_i::TInput* anInput = theResult->GetInput(); + VISU::Result_i::PInput anInput = theResult->GetInput(); VISU::PUnstructuredGridIDMapper anIDMapper = anInput->GetTimeStampOnMesh(theMeshName, VISU::TEntity(theEntity), diff --git a/src/VISU_I/VISU_Vectors_i.cc b/src/VISU_I/VISU_Vectors_i.cc index 8434c013..0d9fe407 100644 --- a/src/VISU_I/VISU_Vectors_i.cc +++ b/src/VISU_I/VISU_Vectors_i.cc @@ -65,7 +65,7 @@ VISU::Vectors_i false); if(theIsMemoryCheck && aResult){ bool anIsEstimated = true; - VISU::Result_i::TInput* anInput = theResult->GetInput(); + VISU::Result_i::PInput anInput = theResult->GetInput(); size_t aSize = anInput->GetTimeStampOnMeshSize(theMeshName, (VISU::TEntity)theEntity, theFieldName, -- 2.39.2