From f068d32e96cb18822463b88e91dbc4dbb08fc09e Mon Sep 17 00:00:00 2001 From: jfa Date: Tue, 8 May 2007 07:44:06 +0000 Subject: [PATCH] Conditional VISU compilation, depending on MULTIPR in MED --- configure.ac | 2 + src/VISUGUI/Makefile.am | 10 +- src/VISUGUI/VisuGUI.cxx | 9 + src/VISU_I/Makefile.am | 15 +- src/VISU_I/VISU_GaussPoints_i.cc | 4 + src/VISU_I/VISU_Result_i.cc | 915 ++++++++++++++++--------------- src/VISU_I/VISU_Result_i.hh | 10 + 7 files changed, 511 insertions(+), 454 deletions(-) diff --git a/configure.ac b/configure.ac index 971d0d61..cb5d6e32 100644 --- a/configure.ac +++ b/configure.ac @@ -304,6 +304,8 @@ echo CHECK_MED +AM_CONDITIONAL(MED_ENABLE_MULTIPR, [test "$ENABLE_MULTIPR" = yes]) + echo echo --------------------------------------------- echo Summary diff --git a/src/VISUGUI/Makefile.am b/src/VISUGUI/Makefile.am index 8e193f5a..f5ad51ad 100644 --- a/src/VISUGUI/Makefile.am +++ b/src/VISUGUI/Makefile.am @@ -115,8 +115,14 @@ libVISU_la_CPPFLAGS= \ $(GUI_CXXFLAGS) \ $(CORBA_CXXFLAGS) $(CORBA_INCLUDES) \ -I$(srcdir)/../VVTK -I$(srcdir)/../OBJECT -I$(srcdir)/../VISU_I -I$(srcdir)/../GUITOOLS \ - -I$(top_builddir)/idl -I$(srcdir)/../CONVERTOR -I$(srcdir)/../PIPELINE -I$(top_builddir)/salome_adm/unix + -I$(top_builddir)/idl -I$(srcdir)/../CONVERTOR -I$(srcdir)/../PIPELINE \ + -I$(top_builddir)/salome_adm/unix libVISU_la_LDFLAGS= $(QWT_LIBS) -lSalomeNS $(KERNEL_LDFLAGS) $(GUI_LDFLAGS) -lSVTK -lSPlot2d \ - ../VVTK/libVVTK.la ../OBJECT/libVisuObject.la ../VISU_I/libVISUEngineImpl.la ../GUITOOLS/libVISUGUITOOLS.la \ + ../VVTK/libVVTK.la ../OBJECT/libVisuObject.la ../VISU_I/libVISUEngineImpl.la \ + ../GUITOOLS/libVISUGUITOOLS.la \ ../../idl/libSalomeIDLVISU.la + +if MED_ENABLE_MULTIPR + libVISU_la_CPPFLAGS+= $(MULTIPR_CPPFLAGS) +endif diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index ef4dddbd..181412c7 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -2291,6 +2291,7 @@ VisuGUI tr("MEN_CACHE_PROPERTIES"), "", 0, aParent, false, this, SLOT(OnCacheProperties())); +#ifdef MED_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), @@ -2311,6 +2312,7 @@ 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 @@ -2488,11 +2490,13 @@ VisuGUI mgr->insert( action( VISU_SELECTION_INFO ), -1, -1, -1 ); // Selection info +#ifdef MED_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 @@ -2670,12 +2674,14 @@ VisuGUI //aRule = "client='ObjectBrowser' and type='MEDFIELD'"; //mgr->setRule( action( VISU_IMPORT_MED ), aRule, true ); +#ifdef MED_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 } //*************************************************************************** @@ -3494,6 +3500,7 @@ void VisuGUI::OnCacheProperties() aDlg->exec(); } +#ifdef MED_ENABLE_MULTIPR // MULTIPR void VisuGUI::OnMultiprViewFullRes() @@ -3584,3 +3591,5 @@ void VisuGUI::OnMultiprChangeRes(char resolution) UpdateObjBrowser(this, false); } + +#endif // MED_ENABLE_MULTIPR diff --git a/src/VISU_I/Makefile.am b/src/VISU_I/Makefile.am index a4a35123..7fb08ec6 100644 --- a/src/VISU_I/Makefile.am +++ b/src/VISU_I/Makefile.am @@ -126,13 +126,17 @@ libVISUEngineImpl_la_LIBADD= -lboost_signals@BOOST_LIBSUFFIX@ -lboost_thread@BOO -lVTKViewer \ -lSVTK \ -lSPlot2d \ - -lMULTIPR_API \ ../CONVERTOR/libVisuConvertor.la \ ../PIPELINE/libVisuPipeLine.la \ ../OBJECT/libVisuObject.la \ ../VVTK/libVVTK.la \ ../GUITOOLS/libVISUGUITOOLS.la +if MED_ENABLE_MULTIPR + libVISUEngineImpl_la_CPPFLAGS+= $(MULTIPR_CPPFLAGS) + libVISUEngineImpl_la_LIBADD+= $(MULTIPR_LIBS) +endif + # Executables targets bin_PROGRAMS = VISU_I dist_VISU_I_SOURCES=VISU_I.cxx @@ -170,6 +174,9 @@ VISU_I_LDADD=$(libVISUEngineImpl_la_LIBADD) $(libVISUEngineImpl_la_LDFLAGS) \ -lMEDWrapper_V2_2 \ -lMEDWrapper_V2_1 \ -lmed_V2_1 \ - -lmedmem \ - -lmedsplitter \ - -lMULTIPR_API + -lmedmem + +if MED_ENABLE_MULTIPR + VISU_I_CPPFLAGS+= $(MULTIPR_CPPFLAGS) + VISU_I_LDADD+= $(MULTIPR_LIBS) -lmedsplitter +endif diff --git a/src/VISU_I/VISU_GaussPoints_i.cc b/src/VISU_I/VISU_GaussPoints_i.cc index 43212b91..b58064b3 100644 --- a/src/VISU_I/VISU_GaussPoints_i.cc +++ b/src/VISU_I/VISU_GaussPoints_i.cc @@ -47,7 +47,9 @@ #include #include +#ifdef ENABLE_MULTIPR #include "MULTIPR_API.hxx" +#endif #ifdef _DEBUG_ static int MYDEBUG = 0; @@ -607,6 +609,7 @@ VISU::GaussPoints_i // MULTIPR VISU::Result_i::TInput* anInput = NULL; +#ifdef ENABLE_MULTIPR if (GetCResult()->IsDistributedMEDMultipr()) { vector aListMEDFiles = GetCResult()->GetCurrentRepresentationMultipr(); @@ -640,6 +643,7 @@ VISU::GaussPoints_i } } else +#endif { anInput = GetCResult()->GetInput(); } diff --git a/src/VISU_I/VISU_Result_i.cc b/src/VISU_I/VISU_Result_i.cc index 4adc042f..27071743 100644 --- a/src/VISU_I/VISU_Result_i.cc +++ b/src/VISU_I/VISU_Result_i.cc @@ -61,8 +61,10 @@ // OCCT Includes #include +#ifdef ENABLE_MULTIPR // MULTIPR #include "MULTIPR_Obj.hxx" +#endif using namespace VISU; using namespace std; @@ -270,13 +272,12 @@ namespace VISU _PTR(AttributeString) aCmnt (anAttr); aCmnt->SetValue(theComment); } - // MULTIPR - if (theIcon != "") { - anAttr = aStudyBuilder->FindOrCreateAttribute(aNewObj, "AttributePixMap"); + // MULTIPR + if (theIcon != "") { + anAttr = aStudyBuilder->FindOrCreateAttribute(aNewObj, "AttributePixMap"); _PTR(AttributePixMap) aPixmap (anAttr); aPixmap->SetPixMap(theIcon.c_str()); - - } + } return aNewObj->GetID(); } @@ -478,16 +479,18 @@ namespace VISU "", true); } - - // MULTIPR - aMesh->myPartsEntry = - 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++){ @@ -636,282 +639,282 @@ namespace VISU //--------------------------------------------------------------- -void BuildFields( + void BuildFields( Result_i* theResult, VISU_Convertor* theInput, CORBA::Boolean* theIsDone, CORBA::Boolean theIsBuild, CORBA::Boolean theIsAtOnce, _PTR(Study) theStudy) -{ - if(!theIsBuild || *theIsDone) - return; + { + if(!theIsBuild || *theIsDone) + return; - TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildFields"); - TResultManager aResultManager(theResult); - TTransactionManager aTransactionManager(theStudy); + TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildFields"); + TResultManager aResultManager(theResult); + TTransactionManager aTransactionManager(theStudy); - { - TTimerLog aTimerLog(MYTIMEDEBUG,"theInput->BuildFields"); - theInput->BuildFields(); - } + { + TTimerLog aTimerLog(MYTIMEDEBUG,"theInput->BuildFields"); + theInput->BuildFields(); + } - QString aComment,aTmp; - const TMeshMap& aMeshMap = theInput->GetMeshMap(); - TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); + 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(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++) + for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++) { - 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 = ""; - aComment.sprintf("myComment=FIELD;myType=%d;",TFIELD); - aComment.append("myMeshName=");aComment.append(aMeshName);aComment.append(";"); - aComment.append(aTmp.sprintf("myEntityId=%d;",anEntity)); - aComment.append("myName=");aComment.append(aFieldName);aComment.append(";"); - aComment.append(aTmp.sprintf("myNbTimeStamps=%d;",aValField.size())); - aComment.append(aTmp.sprintf("myNumComponent=%d",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 = ""; - aComment.sprintf("myComment=TIMESTAMP;myType=%d;",TTIMESTAMP); - aComment.append("myMeshName=");aComment.append(aMeshName);aComment.append(";"); - aComment.append(aTmp.sprintf("myEntityId=%d;",anEntity)); - aComment.append("myFieldName=");aComment.append(aFieldName);aComment.append(";"); - aComment.append(aTmp.sprintf("myTimeStampId=%d;myNumComponent=%d",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); + 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 = ""; + aComment.sprintf("myComment=FIELD;myType=%d;",TFIELD); + aComment.append("myMeshName=");aComment.append(aMeshName);aComment.append(";"); + aComment.append(aTmp.sprintf("myEntityId=%d;",anEntity)); + aComment.append("myName=");aComment.append(aFieldName);aComment.append(";"); + aComment.append(aTmp.sprintf("myNbTimeStamps=%d;",aValField.size())); + aComment.append(aTmp.sprintf("myNumComponent=%d",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 = ""; + aComment.sprintf("myComment=TIMESTAMP;myType=%d;",TTIMESTAMP); + aComment.append("myMeshName=");aComment.append(aMeshName);aComment.append(";"); + aComment.append(aTmp.sprintf("myEntityId=%d;",anEntity)); + aComment.append("myFieldName=");aComment.append(aFieldName);aComment.append(";"); + aComment.append(aTmp.sprintf("myTimeStampId=%d;myNumComponent=%d",aTimeStamp,aField->myNbComp)); + + string aTimeStampId = VISU_Convertor::GenerateName(aValForTime->myTime); + + aValForTime->myEntry = CreateAttributes( + theStudy, + aField->myEntry, + "", + aTimeStampId, + aComment.latin1(), + true); + } } + } - ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone)); -} + 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 + cout<GetFileInfoMultipr().filePath()<GetFileInfoMultipr().filePath().latin1()) == 0) + return; + + QApplication::setOverrideCursor(Qt::waitCursor); -// 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 - cout<GetFileInfoMultipr().filePath()<GetFileInfoMultipr().filePath().latin1()) == 0) - return; - - QApplication::setOverrideCursor(Qt::waitCursor); - 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 string& aMeshName = aMeshMapIter->first; - const PMesh& aMesh = aMeshMapIter->second; - - vector listParts = multiprObj.getParts(); - - QString aComment = "Sub-parts: #"; - aComment += QString::number(listParts.size()); - - UpdateAttributes( + 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 string& aMeshName = aMeshMapIter->first; + 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 - int ret = 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; - } + + 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 + int ret = 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"); + throw std::runtime_error("error while reading distributed MED file"); } - - QApplication::restoreOverrideCursor(); - ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone)); -} + QApplication::restoreOverrideCursor(); + + ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone)); + } +#endif //--------------------------------------------------------------- @@ -960,7 +963,7 @@ void BuildParts( theIsBuildMinMax, theUpdateMinMaxSignal); } - + //--------------------------------------------------------------- struct TBuildArgs @@ -976,9 +979,11 @@ void BuildParts( Result_i::TUpdateMinMaxSignal* myUpdateMinMaxSignal; CORBA::Boolean* myIsGroupsDone; CORBA::Boolean myIsBuildGroups; +#ifdef ENABLE_MULTIPR CORBA::Boolean* myIsPartsDone; CORBA::Boolean myIsBuildParts; - _PTR(Study) myStudy; +#endif + _PTR(Study) myStudy; TBuildArgs(Result_i* theResult, VISU_Convertor* theInput, @@ -991,9 +996,11 @@ void BuildParts( Result_i::TUpdateMinMaxSignal* theUpdateMinMaxSignal, CORBA::Boolean* theIsGroupsDone, CORBA::Boolean theIsBuildGroups, +#ifdef ENABLE_MULTIPR CORBA::Boolean* theIsPartsDone, CORBA::Boolean theIsBuildParts, - _PTR(Study) theStudy): +#endif + _PTR(Study) theStudy): myResult(theResult), myInput(theInput), myIsEntitiesDone(theIsEntitiesDone), @@ -1005,18 +1012,18 @@ void BuildParts( myUpdateMinMaxSignal(theUpdateMinMaxSignal), myIsGroupsDone(theIsGroupsDone), myIsBuildGroups(theIsBuildGroups), +#ifdef ENABLE_MULTIPR myIsPartsDone(theIsPartsDone), myIsBuildParts(theIsBuildParts), - myStudy(theStudy) +#endif + myStudy(theStudy) {} - }; //--------------------------------------------------------------- void BuildDataTree(TBuildArgs theBuildArgs) { - BuildEntities(theBuildArgs.myResult, theBuildArgs.myInput, theBuildArgs.myIsEntitiesDone, @@ -1025,8 +1032,8 @@ void BuildParts( theBuildArgs.myIsBuildGroups, theBuildArgs.myIsBuildFields, theBuildArgs.myStudy); - - { + + { boost::thread aThread(boost::bind(&BuildGroups, theBuildArgs.myResult, theBuildArgs.myInput, @@ -1046,19 +1053,17 @@ void BuildParts( theBuildArgs.myUpdateMinMaxSignal, theBuildArgs.myStudy)); } - - /* - // MULTIPR - BuildParts( - theBuildArgs.myResult, - theBuildArgs.myInput, - theBuildArgs.myIsPartsDone, - theBuildArgs.myIsBuildParts, - false, - theBuildArgs.myStudy); - */ + + /* + // MULTIPR + BuildParts(theBuildArgs.myResult, + theBuildArgs.myInput, + theBuildArgs.myIsPartsDone, + theBuildArgs.myIsBuildParts, + false, + theBuildArgs.myStudy); + */ } - } @@ -1103,17 +1108,23 @@ 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) { myStudy = ProcessEvent(new TGetStudy(myStudyDocument->StudyId())); +#ifdef ENABLE_MULTIPR myIsDistributedMEDMultipr = false; +#endif } @@ -1351,76 +1362,83 @@ VISU::Result_i &myIsMinMaxDone, myIsBuildMinMax, &myUpdateMinMaxSignal); - - // MULTIPR - BuildParts(this, - myInput, - &myIsPartsDone, - myIsBuildParts, - theIsAtOnce, - myStudy); - - }else{ - - if (strlen(GetFileInfoMultipr().filePath().latin1()) == 0) - { - // sequential MED file - TBuildArgs aBuildArgs(this, - myInput, - &myIsEntitiesDone, - aResultEntry, - &myIsFieldsDone, - myIsBuildFields, - &myIsMinMaxDone, - myIsBuildMinMax, - &myUpdateMinMaxSignal, - &myIsGroupsDone, - myIsBuildGroups, - &myIsPartsDone, - myIsBuildParts, - myStudy); - boost::thread aThread(boost::bind(&BuildDataTree, aBuildArgs)); - } - 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); - } + +#ifdef ENABLE_MULTIPR + // MULTIPR + BuildParts(this, + myInput, + &myIsPartsDone, + myIsBuildParts, + theIsAtOnce, + myStudy); +#endif + } + 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 } return this; @@ -1453,45 +1471,46 @@ VISU::Storable* VISU::Result_i:: Create(const char* theFileName) { - - try{ + try { myFileInfo.setFile(theFileName); - - // 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 + +#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)) { - myFileInfoMultipr.setFile(""); + 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(); if(mySourceId == eRestoredFile){ @@ -1508,9 +1527,9 @@ Create(const char* theFileName) if(MYDEBUG) MESSAGE("Result_i::Create - aCommand = "<::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; - } + map::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; + 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; + myIsDistributedMEDMultipr = theIsDistributedMED; } // MULTIPR bool VISU::Result_i::IsDistributedMEDMultipr() const { - return myIsDistributedMEDMultipr; + 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; -} + // 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 1e200702..20e0b2c7 100644 --- a/src/VISU_I/VISU_Result_i.hh +++ b/src/VISU_I/VISU_Result_i.hh @@ -120,11 +120,13 @@ namespace VISU std::string myName, myInitFileName; QFileInfo myFileInfo; +#ifdef ENABLE_MULTIPR // MULTIPR QFileInfo myFileInfoMultipr; std::map myMapPartNameToMEDFilename; std::map mySelectedResolutionMultipr; bool myIsDistributedMEDMultipr; +#endif protected: virtual Storable* Build(SALOMEDS::SObject_ptr theSObject, @@ -138,13 +140,17 @@ namespace VISU CORBA::Boolean myIsFieldsDone; CORBA::Boolean myIsGroupsDone; CORBA::Boolean myIsMinMaxDone; +#ifdef ENABLE_MULTIPR CORBA::Boolean myIsPartsDone; // MULTIPR +#endif CORBA::Boolean myIsBuildFields; CORBA::Boolean myIsBuildGroups; CORBA::Boolean myIsBuildMinMax; +#ifdef ENABLE_MULTIPR CORBA::Boolean myIsBuildParts; // MULTIPR +#endif TUpdateMinMaxSignal myUpdateMinMaxSignal; CORBA::Boolean myIsAllDone; @@ -171,10 +177,13 @@ namespace VISU 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 @@ -182,6 +191,7 @@ namespace VISU std::vector GetCurrentRepresentationMultipr(); void SetIsDistributedMEDMultipr(bool theIsDistributedMED); bool IsDistributedMEDMultipr() const; +#endif private: SALOMEDS::SObject_var mySObject; -- 2.39.2