From cdd83520cc877ca3f8ef6dc3df0cbdff68b104cb Mon Sep 17 00:00:00 2001 From: cs Date: Wed, 21 Mar 2007 11:35:42 +0000 Subject: [PATCH] *** empty log message *** --- README | 10 ++- adm_local/unix/make_commence.in | 7 +- bin/myrunSalome.py | 14 ++-- build_configure | 24 ++++++ idl/MULTIPR.idl | 8 +- src/MULTIPR/MULTIPR_Mesh.cxx | 3 + src/MULTIPR/MULTIPR_MeshDis.cxx | 36 ++++++++- src/MULTIPR/MULTIPR_MeshDis.hxx | 2 +- src/MULTIPR/MULTIPR_Obj.cxx | 23 ++++-- src/MULTIPR/MULTIPR_Obj.hxx | 9 ++- src/MULTIPR/MULTIPR_Utils.cxx | 63 ++++++++++++++++ src/MULTIPR/MULTIPR_Utils.hxx | 26 +++++++ src/MULTIPR/MULTIPR_i.cxx | 14 +++- src/MULTIPR/MULTIPR_i.hxx | 10 ++- src/MULTIPR/Makefile.in | 4 +- src/MULTIPRGUI/MULTIPR_GUI.cxx | 117 ++++++++++++++++++++++------- src/MULTIPRGUI/MULTIPR_GUI.h | 4 +- src/MULTIPRGUI/MULTIPR_GUI_Dlg.cxx | 15 ++-- src/MULTIPRGUI/MULTIPR_msg_en.po | 2 - src/MULTIPRGUI/Makefile.in | 6 +- 20 files changed, 330 insertions(+), 67 deletions(-) diff --git a/README b/README index 2e4ce3c..1a54da8 100755 --- a/README +++ b/README @@ -27,7 +27,7 @@ A. Information generales ------------------------ MULTIPR a besoin des prerequis suivants: 1. Salome V3.2 - 2. MESPLITTER (branche CVS WP1_2_3_17-01-2007_Data_format_at_entry_of_visualization_pipeline) + 2. MESPLITTER (branche MED sur CVS : WP1_2_3_17-01-2007_Data_format_at_entry_of_visualization_pipeline) 3. MED fichier v2.3 4. METIS v4.0.1 (version NON modifiee par EDF) 5. SCOTCH v4 @@ -108,7 +108,7 @@ B. Installation/compilation Renommer la fonction log2 en log2_ dans metis\lib\proto.h (sinon, un conflit se produit) -Depuis le repertoire contenant WP1_2_3_17-01-2007_Data_format_at_entry_of_visualization_pipeline : +Depuis le repertoire MED contenant WP1_2_3_17-01-2007_Data_format_at_entry_of_visualization_pipeline : 9. Creer un repertoire Build et un repertoire MED au cote de MED_SRC 10. Dans le repertoire MED_SRC, faire ./build_configure 11. Depuis le repertoire Build, faire (en remplacant les <...> par les bons répertoires) @@ -142,6 +142,12 @@ Depuis le repertoire contenant WP1_2_3_17-01-2007_Data_format_at_entry_of_visual ../MULTIPR_SRC/configure --prefix=/MULTIPR --enable-production=yes --disable-debug 21. Puis : make 22. Puis : make install + + +Information supplementaire : +Pour compiler MULTIPR, les 8 variables d'environnement suivantes doivent etre definies : +KERNEL_ROOT_DIR, GUI_ROOT_DIR, MED_ROOT_DIR, MED2HOME, HDF5HOME, OMNIORBDIR, CASROOT, QTDIR +L'existence de ces variables est teste par le script build_configure. ******************************************************************************* diff --git a/adm_local/unix/make_commence.in b/adm_local/unix/make_commence.in index 4d769e4..cd6bf52 100644 --- a/adm_local/unix/make_commence.in +++ b/adm_local/unix/make_commence.in @@ -202,6 +202,10 @@ GUI_ROOT_DIR=@GUI_ROOT_DIR@ GUI_LDFLAGS=@GUI_LDFLAGS@ GUI_CXXFLAGS=@GUI_CXXFLAGS@ +MED_ROOT_DIR=@MED_ROOT_DIR@ +MED_LDFLAGS=@MED_LDFLAGS@ +MED_CXXFLAGS=@MED_CXXFLAGS@ + ## Installation points prefix=@prefix@ exec_prefix=@exec_prefix@ @@ -275,4 +279,5 @@ check_GUI.m4 check_corba_in_GUI.m4 $(top_srcdir)/aclocal.m4: $(ACLOCAL_KERNEL:%=@KERNEL_ROOT_DIR@/salome_adm/unix/config_files/%) \ $(ACLOCAL_GUI:%=@GUI_ROOT_DIR@/adm_local/unix/config_files/%) cd $(top_srcdir) ; aclocal -I adm_local/unix/config_files -I @KERNEL_ROOT_DIR@/salome_adm/unix/config_files \ - -I @GUI_ROOT_DIR@/adm_local/unix/config_files + -I @GUI_ROOT_DIR@/adm_local/unix/config_files \ + -I @MED_ROOT_DIR@/adm_local/unix/config_files diff --git a/bin/myrunSalome.py b/bin/myrunSalome.py index e9d52c4..798acc6 100755 --- a/bin/myrunSalome.py +++ b/bin/myrunSalome.py @@ -44,12 +44,12 @@ def multipr_test1(clt,path): m.setMesh(liste_maillages[0]) m.partitionneDomaine() m.getParts() - m.save() + m.save('') m.decimePartition('MAIL_99', 'SIG_____SIEF_ELGA_______________', 12, 'Filtre_GradientMoyen', 10, 25, 0.3) liste_grains = m.getParts() - m.save() + m.save('') m.partitionneGrain('MAIL_98', 3, 0) - m.save() + m.save('') m.getParts() m.getMeshes() m.getFields() @@ -68,7 +68,7 @@ def multipr_test2(clt,path): liste_champs = m.getFields() m.getTimeStamps(liste_champs[3]) m.decimePartition('MAIL_99', 'SIG_____SIEF_ELGA_______________', 12, 'Filtre_GradientMoyen', 10, 25, 0.3) - m.save() + m.save('') m.getMeshes() m.getParts() m.getFields() @@ -92,7 +92,7 @@ def multipr_test3(clt,path): m.getMeshes() m.getParts() m.getFields() - m.save() + m.save('') def multipr_test4(clt,path): @@ -120,7 +120,7 @@ def multipr_test5(clt,path): for grain in liste_grains[0:4]: m.decimePartition(grain, liste_champs[1], 12, 'Filtre_GradientMoyen', 10, 25, 0.3) m.getParts() - m.save() + m.save('') def multipr_test6(clt,path): @@ -138,7 +138,7 @@ def multipr_test6(clt,path): for grain in liste_pgrain[0:11]: m.decimePartition(grain, liste_champs[1], 12, 'Filtre_GradientMoyen', 10, 25, 0.5) m.getParts() - m.save() + m.save('') n = engine.getObject(path+'/agregat100grains_12pas_grains_maitre.med') n.getParts() diff --git a/build_configure b/build_configure index 9aa3637..be501f0 100755 --- a/build_configure +++ b/build_configure @@ -52,6 +52,30 @@ if test ! -d "${HDF5HOME}"; then exit fi +######################################################################## +# Test if the CASROOT is set correctly + +if test ! -d "${CASROOT}"; then + echo "failed : CASROOT variable is not correct !" + exit +fi + +######################################################################## +# Test if the QTDIR is set correctly + +if test ! -d "${QTDIR}"; then + echo "failed : QTDIR variable is not correct !" + exit +fi + +######################################################################## +# Test if the OMNIORBDIR is set correctly + +if test ! -d "${OMNIORBDIR}"; then + echo "failed : OMNIORBDIR variable is not correct !" + exit +fi + ######################################################################## # find_in - utility function # diff --git a/idl/MULTIPR.idl b/idl/MULTIPR.idl index 9b0e860..063f037 100644 --- a/idl/MULTIPR.idl +++ b/idl/MULTIPR.idl @@ -52,6 +52,12 @@ interface MULTIPR_Obj */ boolean isValidDistributedMEDFile(); + /*! + * Return the name of the associated MED file. + */ + string getFilename() + raises (SALOME::SALOME_Exception); + /*! * Set the mesh to be partitionned/decimated. * Assume sequential MED file. @@ -171,7 +177,7 @@ interface MULTIPR_Obj /*! * Save the current distributed MED file to disk. */ - void save() + void save(in string path) raises (SALOME::SALOME_Exception); }; // interface MULTIPR_Obj diff --git a/src/MULTIPR/MULTIPR_Mesh.cxx b/src/MULTIPR/MULTIPR_Mesh.cxx index 461b54c..f0c1979 100644 --- a/src/MULTIPR/MULTIPR_Mesh.cxx +++ b/src/MULTIPR/MULTIPR_Mesh.cxx @@ -716,6 +716,9 @@ char CELL_NAMES[MED_NBR_GEOMETRIE_MAILLE][MED_TAILLE_NOM + 1] = void Mesh::readSequentialMED(const char* pMEDfilename, const char* pMeshName) { + //cout << "File: |" << multipr::getFilenameWithoutPath(pMEDfilename) << "|" << endl; + //cout << "Path: |" << multipr::getPath(pMEDfilename) << "|" << endl; + reset(); //--------------------------------------------------------------------- diff --git a/src/MULTIPR/MULTIPR_MeshDis.cxx b/src/MULTIPR/MULTIPR_MeshDis.cxx index 361de63..3c0571e 100644 --- a/src/MULTIPR/MULTIPR_MeshDis.cxx +++ b/src/MULTIPR/MULTIPR_MeshDis.cxx @@ -439,10 +439,12 @@ string MeshDis::getPartInfo(const char* pPartName) void MeshDis::splitPart(const char* pPartName, int pNbParts, int pPartitionner) { + cout << "MULTIPR: MeshDis::splitPart()" << endl; if (pPartName == NULL) throw NullArgumentException("", __FILE__, __LINE__); if (pNbParts < 2) throw IllegalArgumentException("", __FILE__, __LINE__); if ((pPartitionner != MULTIPR_METIS) && (pPartitionner != MULTIPR_SCOTCH)) throw IllegalArgumentException("should be 0=METIS or 1=SCOTCH", __FILE__, __LINE__); + cout << "MULTIPR: MeshDis::splitPart(): args OK" << endl; //--------------------------------------------------------------------- // Find the MED file corresponding to the given part //--------------------------------------------------------------------- @@ -452,6 +454,8 @@ void MeshDis::splitPart(const char* pPartName, int pNbParts, int pPartitionner) { throw IllegalArgumentException("part not found in this distributed MED file", __FILE__, __LINE__); } + + cout << "MULTIPR: MeshDis::splitPart(): find part OK" << endl; //--------------------------------------------------------------------- // Load the sequential MED file @@ -459,6 +463,7 @@ void MeshDis::splitPart(const char* pPartName, int pNbParts, int pPartitionner) MEDSPLITTER::MESHCollection* collection; collection = new MEDSPLITTER::MESHCollection(part->getMEDFileName(), part->getMeshName()); + cout << "MULTIPR: MeshDis::splitPart(): MEDSPLITTER collection OK" << endl; //--------------------------------------------------------------------- // Partition the group //--------------------------------------------------------------------- @@ -478,7 +483,9 @@ void MeshDis::splitPart(const char* pPartName, int pNbParts, int pPartitionner) { try { + cout << "MULTIPR: try to create partition using SCOTCH: #parts=" << pNbParts << endl; topology = collection->createPartition(pNbParts, MEDSPLITTER::Graph::SCOTCH); + cout << "MULTIPR: assigned SCOTCH" << endl; } catch (...) { @@ -501,6 +508,7 @@ void MeshDis::splitPart(const char* pPartName, int pNbParts, int pPartitionner) } catch (...) { + cout << "MEDSPLITTER error: new MESHCollection()" << endl; throw RuntimeException("MEDSPLITTER error: new MESHCollection()", __FILE__, __LINE__); } } @@ -816,7 +824,7 @@ void MeshDis::readDistributedMED(const char* pMEDfilename) /** * Retrieves the output of MEDSPLITTER and convert it for MULTIPR. */ -int convertMedsplitterToMultipr(ofstream& pFileMaster, const char* pTmpFilename, int pId, MeshDisPart* pPart) +int convertMedsplitterToMultipr(ofstream& pFileMaster, const char* pTmpFilename, int pId, MeshDisPart* pPart, string pDestPath) { MULTIPR_LOG("convert" << endl); @@ -869,6 +877,13 @@ int convertMedsplitterToMultipr(ofstream& pFileMaster, const char* pTmpFilename, //cout << lMeshName << " " << (pId + i) << " " << pPart->getPartName() << "_" << (i + 1) << " " << lPath << " " << lMEDFileName << endl; + string strDestFilename = pDestPath + multipr::getFilenameWithoutPath(lMEDFileName); + if (strcmp(lMEDFileName, strDestFilename.c_str()) != 0) + { + multipr::copyFile(lMEDFileName, pDestPath.c_str()); + strcpy(lMEDFileName, strDestFilename.c_str()); + } + pFileMaster << lMeshName << " " << (pId + i) << " " << pPart->getPartName() << "_" << (i + 1) << " " << lPath << " " << lMEDFileName << endl; } @@ -903,6 +918,8 @@ void MeshDis::writeDistributedMED(const char* pMEDfilenamePrefix) strMasterFilename = strPrefix + strExtension; } + string strDestPath = multipr::getPath(strMasterFilename.c_str()); + MULTIPR_LOG("Create master: " << strMasterFilename << endl); strcpy(mMEDfilename, strMasterFilename.c_str()); @@ -939,6 +956,17 @@ void MeshDis::writeDistributedMED(const char* pMEDfilenamePrefix) { mParts[itPart]->mId = id; id++; + + // copy file in another directory? + string strSrcPath = multipr::getPath(mParts[itPart]->getMEDFileName()); + if (strSrcPath != strDestPath) + { + cout << "Write: KEEP_AS_IT: copy file" << endl; + string strDestFilename = strDestPath + multipr::getFilenameWithoutPath(mParts[itPart]->getMEDFileName()); + multipr::copyFile(mParts[itPart]->getMEDFileName(), strDestPath.c_str()); + strcpy(mParts[itPart]->mMEDFileName, strDestFilename.c_str()); + } + fileMaster << (*mParts[itPart]) << endl; cout << (*mParts[itPart]) << endl; break; @@ -948,6 +976,10 @@ void MeshDis::writeDistributedMED(const char* pMEDfilenamePrefix) { if (strlen(mParts[itPart]->getMEDFileName()) == 0) throw IOException("MED filename is empty", __FILE__, __LINE__); if (mParts[itPart]->mMesh == NULL) throw IllegalStateException("invalid mesh (shoult not be NULL)", __FILE__, __LINE__); + + string strDestFilename = strDestPath + multipr::getFilenameWithoutPath(mParts[itPart]->getMEDFileName()); + strcpy(mParts[itPart]->mMEDFileName, strDestFilename.c_str()); + mParts[itPart]->mMesh->writeMED(mParts[itPart]->getMEDFileName()); mParts[itPart]->mId = id; id++; @@ -965,7 +997,7 @@ void MeshDis::writeDistributedMED(const char* pMEDfilenamePrefix) sprintf(tmpFilename, "%s_part", strPrefix.c_str()); mParts[itPart]->mCollection->write(tmpFilename); mParts[itPart]->mCollection->castAllFields(*(mParts[itPart]->mOldCollection)); - int ret = convertMedsplitterToMultipr(fileMaster, tmpFilename, id, mParts[itPart]); + int ret = convertMedsplitterToMultipr(fileMaster, tmpFilename, id, mParts[itPart], strDestPath); id += ret; remove(mParts[itPart]->getMEDFileName()); break; diff --git a/src/MULTIPR/MULTIPR_MeshDis.hxx b/src/MULTIPR/MULTIPR_MeshDis.hxx index 603bff6..da4abf4 100644 --- a/src/MULTIPR/MULTIPR_MeshDis.hxx +++ b/src/MULTIPR/MULTIPR_MeshDis.hxx @@ -95,7 +95,7 @@ public: * \param pId * \param pPartName * \param pPath - * \param pMEDFileName + * \param pMEDFileName file name excluding the path. * \param pMesh can be NULL. */ void create( diff --git a/src/MULTIPR/MULTIPR_Obj.cxx b/src/MULTIPR/MULTIPR_Obj.cxx index 82cecfb..30fd595 100644 --- a/src/MULTIPR/MULTIPR_Obj.cxx +++ b/src/MULTIPR/MULTIPR_Obj.cxx @@ -424,16 +424,29 @@ vector Obj::getListParts() const } -void Obj::save() +void Obj::save(const char* pPath) { - // only save file if it is a distributed MED file currently in memory - if (mState == MULTIPR_OBJ_STATE_DIS_MEM) + static string prevPath = ""; + + // only save file if it is a distributed MED file currently in memory or path has changed + if ((mState == MULTIPR_OBJ_STATE_DIS_MEM) || (strcmp(pPath, prevPath.c_str()) != 0)) { + prevPath = pPath; + //------------------------------------------------------------- // Write new distributed mesh //------------------------------------------------------------- - string strPrefix = multipr::removeExtension(mMEDfilename.c_str(), ".med"); - mMeshDis->writeDistributedMED(strPrefix.c_str()); + string filename; + if (strlen(pPath) == 0) + { + filename = multipr::removeExtension(mMEDfilename.c_str(), ".med"); + } + else + { + filename = string(pPath) + string("/") + multipr::getFilenameWithoutPath(mMEDfilename.c_str()); + } + string strPrefix = multipr::removeExtension(filename.c_str(), ".med"); + mMeshDis->writeDistributedMED(strPrefix.c_str()); mMEDfilename = mMeshDis->getFilename(); cout << "Write MED master file: " << mMEDfilename << ": OK" << endl; diff --git a/src/MULTIPR/MULTIPR_Obj.hxx b/src/MULTIPR/MULTIPR_Obj.hxx index 14800a6..7d981e6 100644 --- a/src/MULTIPR/MULTIPR_Obj.hxx +++ b/src/MULTIPR/MULTIPR_Obj.hxx @@ -91,6 +91,12 @@ public: */ bool isValidDistributedMEDFile() const { return (mState == MULTIPR_OBJ_STATE_DIS) || (mState == MULTIPR_OBJ_STATE_DIS_MEM); } + /** + * Returns the name of the associated MED file. + * \return the name of the associated MED file. + */ + std::string getMEDFilename() const { return mMEDfilename; } + /** * Defines the mesh to be processed. * \param pMeshName name of the mesh to be partitionned. @@ -224,9 +230,10 @@ public: /** * Saves the associated MED file if necessary. + * \param pPath path where to save the file. * \throw IOException if any i/o error occurs. */ - void save(); + void save(const char* pPath); /** * Dumps any Obj to the given output stream. diff --git a/src/MULTIPR/MULTIPR_Utils.cxx b/src/MULTIPR/MULTIPR_Utils.cxx index 6ce5e8c..a5f9f0c 100644 --- a/src/MULTIPR/MULTIPR_Utils.cxx +++ b/src/MULTIPR/MULTIPR_Utils.cxx @@ -62,6 +62,69 @@ string multipr::removeExtension(const char* pFilename, const char* pExtension) } +string multipr::getFilenameWithoutPath(const char* pFilename) +{ + char* res = strrchr(pFilename, '/'); + if (res == NULL) + { + return pFilename; + } + else + { + char* name = res + 1; + return name; + } +} + + +string multipr::getPath(const char* pFilename) +{ + char* res = strrchr(pFilename, '/'); + if (res == NULL) + { + return ""; + } + else + { + int size = res - pFilename + 1; + char path[256]; + memcpy(path, pFilename, size); + path[size] = '\0'; + return path; + } +} + + +void multipr::copyFile(const char* pFilename, const char* pDestDir) +{ + const char* srcDir = multipr::getPath(pFilename).c_str(); + if (strcmp(srcDir, pDestDir) == 0) return; + + const char* filenameWithoutPath = multipr::getFilenameWithoutPath(pFilename).c_str(); + char pDstFilename[256]; + sprintf(pDstFilename, "%s%s", pDestDir, filenameWithoutPath); + + FILE* src = fopen(pFilename, "rb"); + if (src == NULL) return; + FILE* dst = fopen(pDstFilename, "wb"); + if (dst == NULL) return; + + const int size = 65536; + char* buf = new char[size]; + int ret; + ret = fread(buf, 1, size, src); + while (ret != 0) + { + fwrite(buf, 1, ret, dst); + ret = fread(buf, 1, size, src); + } + + delete[] buf; + fclose(src); + fclose(dst); +} + + void multipr::printArray2D( const med_float* pData, const int pNumElt, diff --git a/src/MULTIPR/MULTIPR_Utils.hxx b/src/MULTIPR/MULTIPR_Utils.hxx index 8c92ea8..d6b0640 100644 --- a/src/MULTIPR/MULTIPR_Utils.hxx +++ b/src/MULTIPR/MULTIPR_Utils.hxx @@ -55,6 +55,32 @@ bool startsWith(const char* pStr, const char* pStrPrefix); std::string removeExtension(const char* pFilename, const char* pExtension); +/** + * Returns the name of the file, excluding the path. + * Example: getFilenameWithoutPath("/home/data/agregat100grains_12pas.med") -> "agregat100grains_12pas.med" + * \param pPilename any valid C string ending with the char '\0'. + * \return the name of the file, excluding the path. + */ +std::string getFilenameWithoutPath(const char* pFilename); + + +/** + * Returns the path of the filename (which may be relative or absolute). + * Example: getPath("/home/data/agregat100grains_12pas.med") -> "/home/data/" + * \param pPilename any valid C string ending with the char '\0'. + * \return the path of the filename (which may be relative or absolute). + */ +std::string getPath(const char* pFilename); + + +/** + * Copies the given file into a directory. + * \param pFilename file to be copied. + * \param pDestDir destination directory. + */ +void copyFile(const char* pFilename, const char* pDestDir); + + /** * Prints all the elements of a 2D array. * \param pData all the data (should contain pNumberOfElements * pDimOfElements values) diff --git a/src/MULTIPR/MULTIPR_i.cxx b/src/MULTIPR/MULTIPR_i.cxx index 03df31d..a8eff22 100644 --- a/src/MULTIPR/MULTIPR_i.cxx +++ b/src/MULTIPR/MULTIPR_i.cxx @@ -186,6 +186,7 @@ MULTIPR_Obj_i::~MULTIPR_Obj_i() { if (mObj != NULL) { + cout << "MULTIPR: Destructor: remove mObj" << endl; delete mObj; mObj = NULL; } @@ -210,6 +211,15 @@ CORBA::Boolean MULTIPR_Obj_i::isValidDistributedMEDFile() } +char* MULTIPR_Obj_i::getFilename() + throw (SALOME::SALOME_Exception) +{ + if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR); + + return CORBA::string_dup(mObj->getMEDFilename().c_str()); +} + + void MULTIPR_Obj_i::setMesh(const char* meshName) throw (SALOME::SALOME_Exception) { @@ -489,14 +499,14 @@ void MULTIPR_Obj_i::removeParts(const char* pPrefixPartName) } -void MULTIPR_Obj_i::save() +void MULTIPR_Obj_i::save(const char* pPath) throw (SALOME::SALOME_Exception) { if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR); try { - mObj->save(); + mObj->save(pPath); } catch (multipr::RuntimeException& e) diff --git a/src/MULTIPR/MULTIPR_i.hxx b/src/MULTIPR/MULTIPR_i.hxx index 9876321..961b44d 100644 --- a/src/MULTIPR/MULTIPR_i.hxx +++ b/src/MULTIPR/MULTIPR_i.hxx @@ -70,6 +70,13 @@ public: CORBA::Boolean isValidDistributedMEDFile() throw (SALOME::SALOME_Exception); + /** + * Returns the name of the associated MED file. + * \return the name of the associated MED file. + */ + char* getFilename() + throw (SALOME::SALOME_Exception); + /** * Defines the mesh to be processed. * \param pMeshName name of the mesh to be partitionned. @@ -215,8 +222,9 @@ public: /** * Saves the associated MED file if necessary. + * \param pPath path where to save the file. */ - void save() + void save(const char* pPath) throw (SALOME::SALOME_Exception); private: diff --git a/src/MULTIPR/Makefile.in b/src/MULTIPR/Makefile.in index 5599f79..584c9ed 100644 --- a/src/MULTIPR/Makefile.in +++ b/src/MULTIPR/Makefile.in @@ -42,11 +42,11 @@ BIN_SRC = # additionnal information to compile and link file -CPPFLAGS += $(KERNEL_CXXFLAGS) -Wno-deprecated -Wparentheses -Wreturn-type -pthread $(MED2_INCLUDES) $(HDF5_INCLUDES) -I$(MED_ROOT_DIR)/include/salome +CPPFLAGS += $(KERNEL_CXXFLAGS) $(MED_CXXFLAGS) $(MED2_INCLUDES) -Wno-deprecated -Wparentheses -Wreturn-type -pthread CPPFLAGSFORBIN=$(CPPFLAGS) -LDFLAGS += $(KERNEL_LDFLAGS) -lSalomeContainer -lOpUtil -lm -lmed -lmedsplitter -lmedmem -lhdf5 -lmed_V2_1 -lSALOMELocalTrace $(MED2_LIBS) $(HDF5_LIBS) -L$(MED_ROOT_DIR)/lib/salome +LDFLAGS += $(KERNEL_LDFLAGS) $(MED_LDFLAGS) $(MED2_LIBS) -lSalomeContainer -lOpUtil -lm -lmed -lmedsplitter -lmedmem -lmed_V2_1 -lSALOMELocalTrace LDFLAGSFORBIN=$(LDFLAGS) diff --git a/src/MULTIPRGUI/MULTIPR_GUI.cxx b/src/MULTIPRGUI/MULTIPR_GUI.cxx index a9d83b0..d54fa0c 100644 --- a/src/MULTIPRGUI/MULTIPR_GUI.cxx +++ b/src/MULTIPRGUI/MULTIPR_GUI.cxx @@ -18,6 +18,7 @@ // MULTIPR Includes #include "MULTIPR_GUI.h" #include "MULTIPR_GUI_Dlg.h" +#include "MULTIPR_Utils.hxx" // Salome Includes #include @@ -56,8 +57,11 @@ #include #include #include +#include +#include + using namespace std; @@ -72,6 +76,33 @@ namespace multipr } +//***************************************************************************** +// Global function +//***************************************************************************** + +// singleton +MULTIPR_ORB::MULTIPR_Gen_ptr GetMultiprGen(const CAM_Module* theModule) +{ + static MULTIPR_ORB::MULTIPR_Gen_ptr aGen = NULL; + + if (!aGen) + { + SALOME_LifeCycleCORBA aLCC(SalomeApp_Application::namingService()); + Engines::Component_var aComponent = aLCC.FindOrLoad_Component("FactoryServer", "MULTIPR"); + aGen = MULTIPR_ORB::MULTIPR_Gen::_narrow(aComponent); + if (!CORBA::is_nil(aGen)) + { + //aGen->SetCurrentStudy(GetDSStudy(GetCStudy(GetAppStudy(theModule)))); + } + } + + if (CORBA::is_nil(aGen)) + throw std::runtime_error("Can't find MULTIPR component"); + + return aGen; +} + + //***************************************************************************** // Class MULTIPR_GUI implementation //***************************************************************************** @@ -83,24 +114,24 @@ MULTIPR_GUI::MULTIPR_GUI() : SalomeApp_Module("MULTIPR") } -MULTIPR_ORB::MULTIPR_Obj_ptr MULTIPR_GUI::getMULTIPRObj() +MULTIPR_GUI::~MULTIPR_GUI() { - return mMULTIPRObj; + if (mMULTIPRObj != NULL) + { + CORBA::release(mMULTIPRObj); + } } -SalomeApp_Application* MULTIPR_GUI::getAppli() const +MULTIPR_ORB::MULTIPR_Obj_ptr MULTIPR_GUI::getMULTIPRObj() { - return getApp(); + return mMULTIPRObj; } -MULTIPR_ORB::MULTIPR_Gen_ptr MULTIPR_GUI::InitMULTIPRGen(SalomeApp_Application* app) +SalomeApp_Application* MULTIPR_GUI::getAppli() const { - Engines::Component_var comp = app->lcc()->FindOrLoad_Component("FactoryServer", "MULTIPR"); - MULTIPR_ORB::MULTIPR_Gen_ptr clr = MULTIPR_ORB::MULTIPR_Gen::_narrow(comp); - ASSERT(!CORBA::is_nil(clr)); - return clr; + return getApp(); } @@ -108,7 +139,7 @@ void MULTIPR_GUI::initialize(CAM_Application* app) { SalomeApp_Module::initialize(app); - InitMULTIPRGen(dynamic_cast(app)); + GetMultiprGen(this); QWidget* aParent = app->desktop(); SUIT_ResourceMgr* aResourceMgr = app->resourceMgr(); @@ -234,7 +265,7 @@ CAM_DataModel* MULTIPR_GUI::createDataModel() QString MULTIPR_GUI::engineIOR() const { - CORBA::String_var anIOR = getApp()->orb()->object_to_string(InitMULTIPRGen(getApp())); + CORBA::String_var anIOR = getApp()->orb()->object_to_string(GetMultiprGen(this)); return QString(anIOR.in()); } @@ -246,6 +277,8 @@ bool MULTIPR_GUI::activateModule(SUIT_Study* theStudy) setMenuShown(true); setToolShown(true); + action(ACTION_IMPORT_MED)->setAccel(QKeySequence(CTRL + Key_I)); + return bOk; } @@ -255,10 +288,13 @@ bool MULTIPR_GUI::deactivateModule(SUIT_Study* theStudy) setMenuShown(false); setToolShown(false); + // Unset actions accelerator keys + action(ACTION_IMPORT_MED)->setAccel(QKeySequence()); + return SalomeApp_Module::deactivateModule(theStudy); } - + void MULTIPR_GUI::windows(QMap& theMap) const { theMap.clear(); @@ -301,11 +337,16 @@ void MULTIPR_GUI::OnImportFromMEDFile() SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg( this->application()->desktop(), true, - tr("MULTIPR_USE_BUILD_PROGRESS") ); + tr("") ); fd->setCaption(tr("MULTIPR_MEN_IMPORT_FROM_MED_FILE")); fd->setFilters(aFilter); - fd->exec(); + if (fd->exec() == QDialog::Rejected) + { + delete fd; + return; + } + QFileInfo aFileInfo(fd->selectedFile()); delete fd; @@ -319,7 +360,7 @@ void MULTIPR_GUI::OnImportFromMEDFile() try { - MULTIPR_ORB::MULTIPR_Gen_ptr multiprgen = MULTIPR_GUI::InitMULTIPRGen(getApp()); + MULTIPR_ORB::MULTIPR_Gen_ptr multiprgen = GetMultiprGen(this); mMULTIPRObj = multiprgen->getObject(mMEDFileName.latin1()); } catch(...) @@ -328,7 +369,7 @@ void MULTIPR_GUI::OnImportFromMEDFile() getApp()->desktop(), "Import MED file error", "Invalid MED file (not recognized by MULTIPR)", - tr("MULTIPR_OK") ); + tr("MULTIPR_BUT_OK") ); } QApplication::restoreOverrideCursor(); @@ -380,7 +421,7 @@ void MULTIPR_GUI::OnPartition2() getApp()->desktop(), "Split warning", "No parts selected", - tr("MULTIPR_OK") ); + tr("MULTIPR_BUT_OK") ); return; } @@ -412,7 +453,7 @@ void MULTIPR_GUI::OnDecimate() getApp()->desktop(), "Decimation warning", "No parts selected", - tr("MULTIPR_OK") ); + tr("MULTIPR_BUT_OK") ); return; } @@ -444,7 +485,7 @@ void MULTIPR_GUI::OnRemove() getApp()->desktop(), "Remove warning", "No parts selected", - tr("MULTIPR_OK") ); + tr("MULTIPR_BUT_OK") ); return; } @@ -476,7 +517,7 @@ void MULTIPR_GUI::OnRemove() getApp()->desktop(), "Remove error", "Error while removing selected part(s)", - tr("MULTIPR_OK") ); + tr("MULTIPR_BUT_OK") ); } QApplication::restoreOverrideCursor(); @@ -492,12 +533,31 @@ void MULTIPR_GUI::OnSave() { return; } - + + SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg( + this->application()->desktop(), + true, + tr("") ); + + fd->setCaption(tr("Save distributed MED file - Destination directory")); + fd->setMode(QFileDialog::DirectoryOnly); + + if (fd->exec() == QDialog::Rejected) + { + delete fd; + return; + } + + QFileInfo aFileInfo(fd->selectedFile()); + delete fd; + + QString path = aFileInfo.filePath(); + QApplication::setOverrideCursor(Qt::waitCursor); try { - mMULTIPRObj->save(); + mMULTIPRObj->save(path); getApp()->updateObjectBrowser(); } catch(...) @@ -506,7 +566,7 @@ void MULTIPR_GUI::OnSave() getApp()->desktop(), "Save distributed MED file error", "Error while writing distributed MED file", - tr("MULTIPR_OK") ); + tr("MULTIPR_BUT_OK") ); } QApplication::restoreOverrideCursor(); @@ -608,7 +668,7 @@ bool MULTIPR_GUI::removeLowerResolution() getApp()->desktop(), "Remove error", "Error while removing previous results", - tr("OK") ); + tr("MULTIPR_BUT_OK") ); } QApplication::restoreOverrideCursor(); @@ -898,7 +958,12 @@ void MULTIPR_GUI_DataModel::build() lPath, lMEDFileName); - if (ret != 5) return; + if (ret != 5) + { + cout << "MULTIPR: build() tree; error while parsing part info" << endl; + std::runtime_error("MULTIPR: build() tree; error while parsing part info"); + return; + } MULTIPR_GUI_DataObject_Mesh* dataObjectMesh = new MULTIPR_GUI_DataObject_Mesh(modelRoot, lMeshName); @@ -919,10 +984,8 @@ void MULTIPR_GUI_DataModel::build() if (ret != 5) return; - //cout << "Part : " << lPartName << endl; if ((strstr(lPartName,"_MED") != NULL) || (strstr(lPartName,"_LOW") != NULL)) { - //cout << "Found MED/LOW" << endl; new MULTIPR_GUI_DataObject_Resolution(dataObjectPart_prev, strItem, strPartInfo); } else diff --git a/src/MULTIPRGUI/MULTIPR_GUI.h b/src/MULTIPRGUI/MULTIPR_GUI.h index 9d059fc..91fd6cc 100644 --- a/src/MULTIPRGUI/MULTIPR_GUI.h +++ b/src/MULTIPRGUI/MULTIPR_GUI.h @@ -61,6 +61,8 @@ public: MULTIPR_GUI(); + virtual ~MULTIPR_GUI(); + void initialize(CAM_Application*); QString engineIOR() const; @@ -73,8 +75,6 @@ public: void selected(QStringList&, const bool); - static MULTIPR_ORB::MULTIPR_Gen_ptr InitMULTIPRGen(SalomeApp_Application*); - const QStringList& getSelectedParts() const { return mSelectedParts; } public slots: diff --git a/src/MULTIPRGUI/MULTIPR_GUI_Dlg.cxx b/src/MULTIPRGUI/MULTIPR_GUI_Dlg.cxx index 594cc51..d17ccac 100644 --- a/src/MULTIPRGUI/MULTIPR_GUI_Dlg.cxx +++ b/src/MULTIPRGUI/MULTIPR_GUI_Dlg.cxx @@ -62,12 +62,12 @@ MULTIPR_GUI_Partition1Dlg::MULTIPR_GUI_Partition1Dlg(MULTIPR_GUI* theModule) : buttonGroupProcess = new QButtonGroup( this, "buttonGroupProcess" ); buttonGroupProcess->setGeometry( QRect( 10, 110, 450, 60 ) ); + pushButtonOK = new QPushButton( buttonGroupProcess, "pushButtonOK" ); + pushButtonOK->setGeometry( QRect( 10, 10, 110, 41 ) ); + pushButtonCancel = new QPushButton( buttonGroupProcess, "pushButtonCancel" ); pushButtonCancel->setGeometry( QRect( 321, 10, 110, 41 ) ); - pushButtonOK = new QPushButton( buttonGroupProcess, "pushButtonOK" ); - pushButtonOK->setGeometry( QRect( 10, 10, 110, 41 ) ); - buttonGroupSelectMesh = new QButtonGroup( this, "buttonGroupSelectMesh" ); buttonGroupSelectMesh->setGeometry( QRect( 10, 10, 450, 91 ) ); @@ -226,7 +226,7 @@ void MULTIPR_GUI_Partition2Dlg::accept() for (QStringList::const_iterator it = partsList.begin(), last = partsList.end(); it != last; it++) { const QString& partName = (*it); - cout << "Split " << partName.latin1() << " #parts=" << nbParts << " splitter=" << strSplitter << endl; + //cout << "Split " << partName.latin1() << " #parts=" << nbParts << " splitter=" << strSplitter << endl; mModule->getMULTIPRObj()->partitionneGrain(partName.latin1(), nbParts, partitionner); } @@ -342,13 +342,12 @@ MULTIPR_GUI_DecimateDlg::MULTIPR_GUI_DecimateDlg(MULTIPR_GUI* theModule) : buttonGroupProcess = new QButtonGroup( this, "buttonGroupProcess" ); buttonGroupProcess->setGeometry( QRect( 10, 480, 450, 60 ) ); + pushButtonOK = new QPushButton( buttonGroupProcess, "pushButtonOK" ); + pushButtonOK->setGeometry( QRect( 10, 10, 110, 41 ) ); + pushButtonCancel = new QPushButton( buttonGroupProcess, "pushButtonCancel" ); pushButtonCancel->setGeometry( QRect( 321, 10, 110, 41 ) ); pushButtonCancel->setAccel( QKeySequence( tr( "Esc" ) ) ); - - pushButtonOK = new QPushButton( buttonGroupProcess, "pushButtonOK" ); - pushButtonOK->setGeometry( QRect( 10, 10, 110, 41 ) ); - pushButtonOK->setAccel( QKeySequence( tr( "Return" ) ) ); setCaption( tr( "Decimation" ) ); buttonGroupSelectField->setTitle( tr( "Select field" ) ); diff --git a/src/MULTIPRGUI/MULTIPR_msg_en.po b/src/MULTIPRGUI/MULTIPR_msg_en.po index a95d516..3ac720d 100644 --- a/src/MULTIPRGUI/MULTIPR_msg_en.po +++ b/src/MULTIPRGUI/MULTIPR_msg_en.po @@ -97,5 +97,3 @@ msgstr "All Files (*.*)" msgid "MULTIPR_FLT_MED_FILES" msgstr "MED Files (*.med)" -msgid "MULTIPR_USE_BUILD_PROGRESS" -msgstr "Use build progress" diff --git a/src/MULTIPRGUI/Makefile.in b/src/MULTIPRGUI/Makefile.in index 9818b33..6a2f322 100644 --- a/src/MULTIPRGUI/Makefile.in +++ b/src/MULTIPRGUI/Makefile.in @@ -42,10 +42,10 @@ LIB_SERVER_IDL = # additionnal information to compil and link file -CPPFLAGS += $(QT_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) $(BOOST_CPPFLAGS) $(KERNEL_CXXFLAGS) $(GUI_CXXFLAGS) $(MED2_INCLUDES) $(HDF5_INCLUDES) -I$(MED_ROOT_DIR)/include/salome -CXXFLAGS += $(KERNEL_CXXFLAGS) $(GUI_CXXFLAGS) -LDFLAGS += -lSalomeApp -lMULTIPREngine $(KERNEL_LDFLAGS) $(GUI_LDFLAGS) -lmed -lmedsplitter -lmedmem -lhdf5 -lmed_V2_1 -lSALOMELocalTrace $(MED2_LIBS) $(HDF5_LIBS) -L$(MED_ROOT_DIR)/lib/salome +CPPFLAGS += $(QT_INCLUDES) $(OCC_INCLUDES) $(KERNEL_CXXFLAGS) $(MED_CXXFLAGS) $(GUI_CXXFLAGS) $(MED2_INCLUDES) +CXXFLAGS += $(KERNEL_CXXFLAGS) $(GUI_CXXFLAGS) +LDFLAGS += $(KERNEL_LDFLAGS) $(GUI_LDFLAGS) $(MED_LDFLAGS) $(MED2_LIBS) -lSalomeApp -lmed -lmedsplitter -lmedmem -lmed_V2_1 -lSALOMELocalTrace -lMULTIPREngine @CONCLUDE@ -- 2.39.2