From 679904888efb0093383a4985eb1384ad2d75b657 Mon Sep 17 00:00:00 2001 From: jfa Date: Mon, 23 Jul 2007 12:05:32 +0000 Subject: [PATCH] Do not use callbacks for dialogs to avoid 'async reply' errors. --- idl/MULTIPR.idl | 15 ++++ src/MULTIPR/MULTIPR_i.cxx | 138 ++++++++++++++++++++--------- src/MULTIPR/MULTIPR_i.hxx | 67 ++++++++------ src/MULTIPRGUI/MULTIPR_GUI_Dlg.cxx | 42 ++++++--- 4 files changed, 178 insertions(+), 84 deletions(-) diff --git a/idl/MULTIPR.idl b/idl/MULTIPR.idl index ba9828d..5a15b0d 100644 --- a/idl/MULTIPR.idl +++ b/idl/MULTIPR.idl @@ -158,6 +158,21 @@ interface MULTIPR_Obj : SALOME::GenericObj in double radius) raises (SALOME::SALOME_Exception); + /*! + * Works exactly like the above method, but returns not a list + * of all parts, but a list of empty obtained resolutions. + * \return the list of empty resolutions. + */ + string_array decimatePart( + in string partName, + in string fieldName, + in long fieldIt, + in string filterName, + in double tmed, + in double tlow, + in double radius) + raises (SALOME::SALOME_Exception); + /*! * Return useful information to configure decimation parameters. * Depends on part, field and filter: generic operation. diff --git a/src/MULTIPR/MULTIPR_i.cxx b/src/MULTIPR/MULTIPR_i.cxx index 442fb71..e4663c2 100644 --- a/src/MULTIPR/MULTIPR_i.cxx +++ b/src/MULTIPR/MULTIPR_i.cxx @@ -7,15 +7,15 @@ * \brief see MULTIPR_i.hxx * * \author Olivier LE ROUX - CS, Virtual Reality Dpt - * + * * \date 01/2007 */ - + //***************************************************************************** // Includes section //***************************************************************************** - + using namespace std; #include "MULTIPR_i.hxx" @@ -187,8 +187,8 @@ namespace MULTIPR MULTIPR_Gen_i::MULTIPR_Gen_i (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, - PortableServer::ObjectId* contId, - const char* instanceName, + PortableServer::ObjectId* contId, + const char* instanceName, const char* interfaceName) : Engines_Component_i(orb, poa, contId, instanceName, interfaceName) { @@ -215,7 +215,7 @@ char* MULTIPR_Gen_i::getVersion() void MULTIPR_Gen_i::partitionneDomaine( - const char* medFilename, + const char* medFilename, const char* meshName) throw (SALOME::SALOME_Exception) { @@ -232,9 +232,9 @@ void MULTIPR_Gen_i::partitionneDomaine( void MULTIPR_Gen_i::partitionneGrain( - const char* medFilename, - const char* partName, - CORBA::Long nbParts, + const char* medFilename, + const char* partName, + CORBA::Long nbParts, CORBA::Long partitionner) throw (SALOME::SALOME_Exception) { @@ -255,8 +255,8 @@ void MULTIPR_Gen_i::partitionneGrain( void MULTIPR_Gen_i::decimePartition( - const char* medFilename, - const char* partName, + const char* medFilename, + const char* partName, const char* fieldName, CORBA::Long fieldIt, const char* filterName, @@ -279,12 +279,12 @@ void MULTIPR_Gen_i::decimePartition( cout << "Box : " << boxing << endl; cout << endl; */ - + try { multipr::decimePartition( - medFilename, - partName, + medFilename, + partName, fieldName, fieldIt, filterName, @@ -378,7 +378,7 @@ CORBA::Boolean MULTIPR_Obj_i::isValidSequentialMEDFile() throw (SALOME::SALOME_Exception) { if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR); - + return mObj->isValidSequentialMEDFile(); } @@ -387,7 +387,7 @@ CORBA::Boolean MULTIPR_Obj_i::isValidDistributedMEDFile() throw (SALOME::SALOME_Exception) { if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR); - + return mObj->isValidDistributedMEDFile(); } @@ -396,7 +396,7 @@ 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()); } @@ -405,7 +405,7 @@ char* MULTIPR_Obj_i::getSeqFilename() throw (SALOME::SALOME_Exception) { if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR); - + return CORBA::string_dup(mObj->getSequentialMEDFilename().c_str()); } @@ -455,18 +455,18 @@ void MULTIPR_Obj_i::setBoxing (CORBA::Long pBoxing) } -MULTIPR_ORB::string_array* MULTIPR_Obj_i::getMeshes() +MULTIPR_ORB::string_array* MULTIPR_Obj_i::getMeshes() throw (SALOME::SALOME_Exception) { if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR); - + MULTIPR_ORB::string_array_var mySeq = new MULTIPR_ORB::string_array(); - + try { std::vector listMeshes = mObj->getMeshes(); mySeq->length(listMeshes.size()); - + for (size_t i = 0 ; i < listMeshes.size() ; i++) { mySeq[i] = CORBA::string_dup(listMeshes[i].c_str()); @@ -477,23 +477,23 @@ MULTIPR_ORB::string_array* MULTIPR_Obj_i::getMeshes() e.dump(cout); THROW_SALOME_CORBA_EXCEPTION("Unable to get meshes", SALOME::INTERNAL_ERROR); } - + return mySeq._retn(); } -MULTIPR_ORB::string_array* MULTIPR_Obj_i::getFields() +MULTIPR_ORB::string_array* MULTIPR_Obj_i::getFields() throw (SALOME::SALOME_Exception) { if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR); - + MULTIPR_ORB::string_array_var mySeq = new MULTIPR_ORB::string_array(); - + try { std::vector listFields = mObj->getFields(); mySeq->length(listFields.size()); - + for (size_t i = 0 ; i < listFields.size() ; i++) { mySeq[i] = CORBA::string_dup(listFields[i].c_str()); @@ -504,7 +504,7 @@ MULTIPR_ORB::string_array* MULTIPR_Obj_i::getFields() e.dump(cout); THROW_SALOME_CORBA_EXCEPTION("Unable to get fields", SALOME::INTERNAL_ERROR); } - + return mySeq._retn(); } @@ -513,7 +513,7 @@ CORBA::Long MULTIPR_Obj_i::getTimeStamps(const char* fieldName) throw (SALOME::SALOME_Exception) { if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR); - + try { return mObj->getTimeStamps(fieldName); @@ -530,14 +530,14 @@ MULTIPR_ORB::string_array* MULTIPR_Obj_i::getParts() throw (SALOME::SALOME_Exception) { if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR); - + MULTIPR_ORB::string_array_var mySeq = new MULTIPR_ORB::string_array(); - + try { std::vector listParts = mObj->getParts(); mySeq->length(listParts.size()); - + for (size_t i = 0 ; i < listParts.size() ; i++) { mySeq[i] = CORBA::string_dup(listParts[i].c_str()); @@ -548,7 +548,7 @@ MULTIPR_ORB::string_array* MULTIPR_Obj_i::getParts() e.dump(cout); THROW_SALOME_CORBA_EXCEPTION("Unable to get parts", SALOME::INTERNAL_ERROR); } - + return mySeq._retn(); } @@ -557,7 +557,7 @@ char* MULTIPR_Obj_i::getPartInfo(const char* pPartName) throw (SALOME::SALOME_Exception) { if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR); - + return CORBA::string_dup(mObj->getPartInfo(pPartName).c_str()); } @@ -593,8 +593,8 @@ MULTIPR_ORB::string_array* MULTIPR_Obj_i::partitionneDomaine() MULTIPR_ORB::string_array* MULTIPR_Obj_i::partitionneGrain( - const char* pPartName, - CORBA::Long pNbParts, + const char* pPartName, + CORBA::Long pNbParts, CORBA::Long pPartitionner) throw (SALOME::SALOME_Exception) { @@ -683,10 +683,60 @@ MULTIPR_ORB::string_array* MULTIPR_Obj_i::decimePartition( } +MULTIPR_ORB::string_array* MULTIPR_Obj_i::decimatePart( + const char* pPartName, + const char* pFieldName, + CORBA::Long pFieldIt, + const char* pFilterName, + CORBA::Double pTmed, + CORBA::Double pTlow, + CORBA::Double pRadius) + throw (SALOME::SALOME_Exception) +{ + if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR); + + MULTIPR_ORB::string_array_var mySeq = new MULTIPR_ORB::string_array(); + + try + { + std::list emptyParts; + mObj->decimePartition(pPartName, + pFieldName, + pFieldIt, + pFilterName, + pTmed, + pTlow, + pRadius, + mBoxing, + emptyParts); + + mySeq->length(emptyParts.size()); + std::list::const_iterator it = emptyParts.begin(), end = emptyParts.end(); + for (size_t i = 0; it != end; it++, i++) + { + mySeq[i] = CORBA::string_dup((*it).c_str()); + } + + // Dump Python + MULTIPR::TPythonDump(_engine) << "empty_parts = " << this << ".decimatePart(\"" + << pPartName << "\", \"" << pFieldName << "\", " + << pFieldIt << ", \"" << pFilterName << "\", " + << pTmed << ", " << pTlow << ", " << pRadius << ")"; + } + catch (multipr::RuntimeException& e) + { + e.dump(cout); + THROW_SALOME_CORBA_EXCEPTION("Unable to decimate", SALOME::INTERNAL_ERROR); + } + + return mySeq._retn(); +} + + char* MULTIPR_Obj_i::evalDecimationParams( - const char* pPartName, - const char* pFieldName, - CORBA::Long pFieldIt, + const char* pPartName, + const char* pFieldName, + CORBA::Long pFieldIt, const char* pFilterName, const char* pFilterParams) throw (SALOME::SALOME_Exception) @@ -979,7 +1029,7 @@ SALOMEDS::TMPFile* MULTIPR_Gen_i::Save (SALOMEDS::SComponent_ptr theComponent, int lId; char lPartName[256]; char lPath[256]; - char lMEDFileName[256]; + char lMEDFileName[256]; for (unsigned int i = 0; i < nbParts; i++) // each part MED files { @@ -1327,13 +1377,13 @@ Engines::TMPFile* MULTIPR_Gen_i::DumpPython (CORBA::Object_ptr theStudy, //bool hasNotPublishedObjects = aScript.Location( NotPublishedObjectName(), 1, aLen); //isValidScript = isValidScript && !hasNotPublishedObjects; - return aStreamFile._retn(); + return aStreamFile._retn(); } /*! DumpPython_impl */ -std::string MULTIPR_Gen_i::DumpPython_impl (int theStudyID, - bool isPublished, +std::string MULTIPR_Gen_i::DumpPython_impl (int theStudyID, + bool isPublished, bool& aValidScript, std::string theSavedTrace) { @@ -1576,7 +1626,7 @@ SALOMEDS::SComponent_ptr _Gen_i::PublishComponent(SALOMEDS::Study_ptr theStudy) if ( CORBA::is_nil( aComp ) ) return father._retn(); - SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder(); + SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder(); SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributePixMap_var aPixmap; diff --git a/src/MULTIPR/MULTIPR_i.hxx b/src/MULTIPR/MULTIPR_i.hxx index e0b7e3a..9996197 100644 --- a/src/MULTIPR/MULTIPR_i.hxx +++ b/src/MULTIPR/MULTIPR_i.hxx @@ -57,37 +57,37 @@ public: bool isPersistence = false, bool isMultifile = false) throw (SALOME::SALOME_Exception); - + /** * Destructor. */ virtual ~MULTIPR_Obj_i(); - + //--------------------------------------------------------------------- // Basic accessors/mutators //-------------------------------------------------------------------- - + /** * Returns true iff this obj represents a valid sequential MED file. * \return true iff this obj represents a valid sequential MED file. */ CORBA::Boolean isValidSequentialMEDFile() throw (SALOME::SALOME_Exception); - + /** * Returns true iff this obj represents a valid distributed MED file. * \return true iff this obj represents a valid distributed MED file. */ 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); - + /** * Returns the name of the associated sequential MED file (for a distributed MED file). * \return the name of the associated sequential MED file (for a distributed MED file). @@ -138,7 +138,7 @@ public: */ MULTIPR_ORB::string_array* getFields() throw (SALOME::SALOME_Exception); - + /** * Returns the number of timestamps for a given field. * Assumes this object encapsulates a sequential MED file. @@ -147,7 +147,7 @@ public: */ CORBA::Long getTimeStamps(const char* pFieldName) throw (SALOME::SALOME_Exception); - + /** * Returns the name of all partitions. * Assumes this object encapsulates a distributed MED file. @@ -164,11 +164,11 @@ public: */ char* getPartInfo(const char* pPartName) throw (SALOME::SALOME_Exception); - + //--------------------------------------------------------------------- // Algorithms //--------------------------------------------------------------------- - + /** * Creates a distributed MED file (v2.3) by extracting all the groups from the current mesh of the current MED sequential MED file. * Assumes: @@ -180,7 +180,7 @@ public: */ MULTIPR_ORB::string_array* partitionneDomaine() throw (SALOME::SALOME_Exception); - + /** * Creates a distributed MED file (V2.3) by splitting a group of a MED file previously created by partitionneDomaine. * Assumes: @@ -197,7 +197,7 @@ public: CORBA::Long pNbParts, CORBA::Long pPartitionner) throw (SALOME::SALOME_Exception); - + /** * Creates 3 resolutions of the given part of a distributed MED file (V2.3). * Assumes: @@ -221,7 +221,22 @@ public: CORBA::Double pTlow, CORBA::Double pRadius) throw (SALOME::SALOME_Exception); - + + /** + * Works exactly like the above method, but returns not a list + * of all parts, but a list of empty obtained resolutions. + * \return the list of empty resolutions. + */ + MULTIPR_ORB::string_array* decimatePart( + const char* pPartName, + const char* pFieldName, + CORBA::Long pFieldIt, + const char* pFilterName, + CORBA::Double pTmed, + CORBA::Double pTlow, + CORBA::Double pRadius) + throw (SALOME::SALOME_Exception); + /** * Returns useful information to configure decimation parameters. * Depends on part, field and filter: generic operation. @@ -238,7 +253,7 @@ public: const char* pFilterName, const char* pFilterParams) throw (SALOME::SALOME_Exception); - + /*! * Removes all the parts starting with "pPrefixPartName" from the distributed MED file. * Example: if pPrefixPartName="PART_4" => remove "PART_4" and all sub-parts "PART_4_*", but not "PART41". @@ -247,11 +262,11 @@ public: */ void removeParts(const char* pPrefixPartName) throw (SALOME::SALOME_Exception); - + //--------------------------------------------------------------------- // I/O //--------------------------------------------------------------------- - + /** * Saves the associated MED file if necessary. * \param pPath path where to save the file. @@ -294,14 +309,14 @@ private: * The associated MULTIPR object. */ multipr::Obj* mObj; - + /** * Boxing paremeter: number of cells along each axis. * E.g. if mBoxing=10 then total number of cells = 10*10*10 = 1000. * By default, mBoxing=100. */ int mBoxing; - + /** * Engine. */ @@ -331,24 +346,24 @@ public: PortableServer::ObjectId* contId, const char* instanceName, const char* interfaceName); - + virtual ~MULTIPR_Gen_i(); - + char* getVersion() throw (SALOME::SALOME_Exception); - + void partitionneDomaine( const char* medFilename, const char* meshName) throw (SALOME::SALOME_Exception); - + void partitionneGrain( const char* medFilename, const char* partName, CORBA::Long nbParts, CORBA::Long partitionner) throw (SALOME::SALOME_Exception); - + void decimePartition( const char* medFilename, const char* partName, @@ -360,7 +375,7 @@ public: CORBA::Double radius, CORBA::Long boxing) throw (SALOME::SALOME_Exception); - + MULTIPR_ORB::MULTIPR_Obj_ptr getObject(const char* medFilename) throw (SALOME::SALOME_Exception); @@ -449,8 +464,8 @@ public: void AddToPythonScript (int theStudyID, std::string theString); private: - std::string DumpPython_impl (int theStudyID, - bool isPublished, + std::string DumpPython_impl (int theStudyID, + bool isPublished, bool& aValidScript, std::string theSavedTrace); diff --git a/src/MULTIPRGUI/MULTIPR_GUI_Dlg.cxx b/src/MULTIPRGUI/MULTIPR_GUI_Dlg.cxx index 68921c1..865ae9c 100644 --- a/src/MULTIPRGUI/MULTIPR_GUI_Dlg.cxx +++ b/src/MULTIPRGUI/MULTIPR_GUI_Dlg.cxx @@ -461,22 +461,36 @@ void MULTIPR_GUI_DecimateDlg::accept() try { - const QStringList& partsList = mModule->getSelectedParts(); - for (QStringList::const_iterator it = partsList.begin(), last = partsList.end(); it != last; it++) + const QStringList& partsList = mModule->getSelectedParts(); + for (QStringList::const_iterator it = partsList.begin(), last = partsList.end(); it != last; it++) + { + const QString& partName = (*it); + + mModule->getMULTIPRObj()->setBoxing(spinBoxBoxing->value()); + + MULTIPR_ORB::string_array_var anEmptyPartsSeq = + mModule->getMULTIPRObj()->decimatePart(partName.latin1(), + strFieldName, + fieldIteration, + comboBoxSelectFilter->currentText().latin1(), + thresholdMed, + thresholdLow, + radius); + int nbEmpty = anEmptyPartsSeq->length(); + if (nbEmpty > 0) { - const QString& partName = (*it); - - mModule->getMULTIPRObj()->setBoxing(spinBoxBoxing->value()); - - mModule->getMULTIPRObj()->decimePartition( - partName.latin1(), - strFieldName, - fieldIteration, - comboBoxSelectFilter->currentText().latin1(), - thresholdMed, - thresholdLow, - radius); + QString listEmptyMeshes ("Empty mesh(es) detected: "); + for (int ii = 0; ii < nbEmpty; ii++) + { + if (ii > 0) listEmptyMeshes += ", "; + listEmptyMeshes += anEmptyPartsSeq[ii]; + } + SUIT_MessageBox::warn1(mModule->getAppli()->desktop(), + "Empty mesh(es) detected", + listEmptyMeshes, + tr("OK")); } + } } catch(...) { -- 2.39.2