From 63c85fd22977c18682232705b2fe5fd62692ce77 Mon Sep 17 00:00:00 2001 From: rnc Date: Mon, 26 Aug 2013 08:48:14 +0000 Subject: [PATCH] BUG: HexoticPLUGIN/Size maps: Fixed some dump issues --- idl/HexoticPlugin_Algorithm.idl | 5 +++- resources/HexoticPLUGIN.xml | 9 ++++++- .../HexoticPluginGUI_HypothesisCreator.cxx | 24 ++++++++++++------- src/GUI/HexoticPluginGUI_HypothesisCreator.h | 4 ++-- src/HexoticPlugin/HexoticPLUGINBuilder.py | 9 ++++--- .../HexoticPlugin_Hypothesis.cxx | 13 +++++++--- .../HexoticPlugin_Hypothesis.hxx | 2 +- .../HexoticPlugin_Hypothesis_i.cxx | 22 +++++++++++------ .../HexoticPlugin_Hypothesis_i.hxx | 4 +++- 9 files changed, 65 insertions(+), 27 deletions(-) diff --git a/idl/HexoticPlugin_Algorithm.idl b/idl/HexoticPlugin_Algorithm.idl index cd9851e..dae73d9 100644 --- a/idl/HexoticPlugin_Algorithm.idl +++ b/idl/HexoticPlugin_Algorithm.idl @@ -93,9 +93,12 @@ module HexoticPlugin void SetSizeMapEntry(in string entry, in double size); + void UnsetSizeMapEntry(in string entry); + void SetSizeMap(in GEOM::GEOM_Object GeomObj, in double size); - void ClearSizeMaps(); + void UnsetSizeMap(in GEOM::GEOM_Object GeomObj); + HexoticPluginSizeMapsList GetSizeMaps(); }; }; diff --git a/resources/HexoticPLUGIN.xml b/resources/HexoticPLUGIN.xml index 47c65e2..859391c 100644 --- a/resources/HexoticPLUGIN.xml +++ b/resources/HexoticPLUGIN.xml @@ -34,7 +34,14 @@ + dim="3"> + + + SetSizeMap + UnsetSizeMap + + + diff --git a/src/GUI/HexoticPluginGUI_HypothesisCreator.cxx b/src/GUI/HexoticPluginGUI_HypothesisCreator.cxx index ad1e57c..b9a8d9a 100644 --- a/src/GUI/HexoticPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/HexoticPluginGUI_HypothesisCreator.cxx @@ -70,7 +70,7 @@ enum { HexoticPluginGUI_HypothesisCreator::HexoticPluginGUI_HypothesisCreator( const QString& theHypType ) : SMESHGUI_GenericHypothesisCreator( theHypType ), myIs3D( true ), - mySizeMapRemoved ( false ) + mySizeMapsToRemove () { } @@ -186,6 +186,7 @@ QFrame* HexoticPluginGUI_HypothesisCreator::buildFrame() myIs3D = true; // Size Maps + mySizeMapsToRemove.clear(); connect( mySmpWidget->pushButton_1, SIGNAL( clicked() ), this, SLOT( onAddLocalSize() ) ); connect( mySmpWidget->pushButton_2, SIGNAL( clicked() ), this, SLOT( onRemoveLocalSize() ) ); @@ -255,14 +256,20 @@ void HexoticPluginGUI_HypothesisCreator::onRemoveLocalSize() if ( ranges.isEmpty() ) // If none is selected remove the last one { int lastRow = mySmpWidget->tableWidget->rowCount() - 1; + std::string entry = mySmpWidget->tableWidget->item( lastRow, ENTRY_COL )->text().toStdString(); + mySizeMapsToRemove.push_back(entry); mySmpWidget->tableWidget->removeRow( lastRow ); } else { QTableWidgetSelectionRange& range = ranges.first(); + for ( int row = range.topRow(); row < range.rowCount(); row++ ) + { + std::string entry = mySmpWidget->tableWidget->item( row, ENTRY_COL )->text().toStdString(); + mySizeMapsToRemove.push_back(entry); + } mySmpWidget->tableWidget->model()->removeRows(range.topRow(), range.rowCount()); } - mySizeMapRemoved = true; } //================================================================================= @@ -454,14 +461,15 @@ bool HexoticPluginGUI_HypothesisCreator::storeParamsToHypo( const HexoticHypothe HexoticPlugin_Hypothesis::THexoticSizeMaps::const_iterator it; - // Clear size maps in hypothesis if one of them as been removed by the user - if ( mySizeMapRemoved ) - h->ClearSizeMaps(); - for ( it = h_data.mySizeMaps.begin(); it != h_data.mySizeMaps.end(); it++ ) { - h->SetSizeMapEntry( it->first.c_str(), it->second ); - MESSAGE("STORING Size map : entry "<first.c_str()<<" size : "<second) + h->SetSizeMapEntry( it->first.c_str(), it->second ); + MESSAGE("STORING Size map : entry "<first.c_str()<<" size : "<second) + } + std::vector< std::string >::const_iterator entry_it; + for ( entry_it = mySizeMapsToRemove.begin(); entry_it!= mySizeMapsToRemove.end(); entry_it++ ) + { + h->UnsetSizeMapEntry(entry_it->c_str()); } } catch(const SALOME::SALOME_Exception& ex) diff --git a/src/GUI/HexoticPluginGUI_HypothesisCreator.h b/src/GUI/HexoticPluginGUI_HypothesisCreator.h index ba687d5..219c250 100644 --- a/src/GUI/HexoticPluginGUI_HypothesisCreator.h +++ b/src/GUI/HexoticPluginGUI_HypothesisCreator.h @@ -96,8 +96,8 @@ private: HexoticPluginGUI_SizeMapsWidget* mySmpWidget; StdMeshersGUI_ObjectReferenceParamWdg* myGeomSelWdg; - bool myIs3D; - bool mySizeMapRemoved; + bool myIs3D; + std::vector< std::string > mySizeMapsToRemove; protected slots: void onAddLocalSize(); diff --git a/src/HexoticPlugin/HexoticPLUGINBuilder.py b/src/HexoticPlugin/HexoticPLUGINBuilder.py index f2127b1..f0c1b77 100644 --- a/src/HexoticPlugin/HexoticPLUGINBuilder.py +++ b/src/HexoticPlugin/HexoticPLUGINBuilder.py @@ -96,9 +96,12 @@ class Hexotic_Algorithm(Mesh_Algorithm): self.Parameters().SetSizeMap(theObject, theSize) return self.Parameters() - ## Clears all size maps : this is meant to be used only by the dump - def ClearSizeMaps(self): - self.Parameters().ClearSizeMaps() + ## Unsets a size map : this is meant to be used only by the dump + # @param theObject geometrical object to unassign local size + # @return hypothesis object + def UnsetSizeMap(self, theObject, theSize): + AssureGeomPublished( self.mesh, theObject ) + self.Parameters().UnsetSizeMap(theObject) return self.Parameters() ## (OBSOLETE) Defines "MinMaxQuad" hypothesis to give three hexotic parameters diff --git a/src/HexoticPlugin/HexoticPlugin_Hypothesis.cxx b/src/HexoticPlugin/HexoticPlugin_Hypothesis.cxx index df82d2c..3548bc6 100644 --- a/src/HexoticPlugin/HexoticPlugin_Hypothesis.cxx +++ b/src/HexoticPlugin/HexoticPlugin_Hypothesis.cxx @@ -169,9 +169,16 @@ bool HexoticPlugin_Hypothesis::AddSizeMap(std::string theEntry, double theSize) } } -void HexoticPlugin_Hypothesis::ClearSizeMaps() -{ - _sizeMaps.clear(); +bool HexoticPlugin_Hypothesis::UnsetSizeMap(std::string theEntry) { + THexoticSizeMaps::iterator it; + it=_sizeMaps.find(theEntry); + if( it != _sizeMaps.end() ) + { + _sizeMaps.erase(it); + return true; + } + else + return false; } //============================================================================= diff --git a/src/HexoticPlugin/HexoticPlugin_Hypothesis.hxx b/src/HexoticPlugin/HexoticPlugin_Hypothesis.hxx index 6dd9941..dc5ba06 100644 --- a/src/HexoticPlugin/HexoticPlugin_Hypothesis.hxx +++ b/src/HexoticPlugin/HexoticPlugin_Hypothesis.hxx @@ -93,10 +93,10 @@ public: // For the GUI HexoticPluginGUI_HypothesisCreator::storeParamToHypo THexoticSizeMaps GetSizeMaps() const { return _sizeMaps; }; - void ClearSizeMaps(); // Add one size map to the collection of size maps (user interface) bool AddSizeMap(std::string theEntry, double theSize); + bool UnsetSizeMap(std::string theEntry); // the parameters default values static int GetDefaultHexesMinLevel(); diff --git a/src/HexoticPlugin/HexoticPlugin_Hypothesis_i.cxx b/src/HexoticPlugin/HexoticPlugin_Hypothesis_i.cxx index b2b5009..ae2f0bc 100644 --- a/src/HexoticPlugin/HexoticPlugin_Hypothesis_i.cxx +++ b/src/HexoticPlugin/HexoticPlugin_Hypothesis_i.cxx @@ -236,26 +236,34 @@ HexoticPlugin::HexoticPluginSizeMapsList* HexoticPlugin_Hypothesis_i::GetSizeMap void HexoticPlugin_Hypothesis_i::SetSizeMapEntry ( const char* theEntry, CORBA::Double theSize ) { - MESSAGE("HexoticPlugin_Hypothesis_i::SetSizeMapEntry"); - std::string anEntry = theEntry; +// MESSAGE("HexoticPlugin_Hypothesis_i::SetSizeMapEntry"); bool valueChanged = this->GetImpl()->AddSizeMap(theEntry, theSize); - MESSAGE("valueChanged = "<GetImpl()->UnsetSizeMap(theEntry); + if (entryRemoved) + SMESH::TPythonDump() << _this() << ".UnsetSizeMap( "<< theEntry << " )"; +} + void HexoticPlugin_Hypothesis_i::SetSizeMap (const GEOM::GEOM_Object_ptr theGeomObj, const double theSize) { - MESSAGE("HexoticPlugin_Hypothesis_i::SetSizeMap"); +// MESSAGE("HexoticPlugin_Hypothesis_i::SetSizeMap"); ASSERT(myBaseImpl); std::string entry = theGeomObj->GetStudyEntry(); SetSizeMapEntry( entry.c_str(), theSize); } -void HexoticPlugin_Hypothesis_i::ClearSizeMaps () +void HexoticPlugin_Hypothesis_i::UnsetSizeMap (const GEOM::GEOM_Object_ptr theGeomObj) { - this->GetImpl()->ClearSizeMaps(); - SMESH::TPythonDump() << _this() << ".ClearSizeMaps()"; +// MESSAGE("HexoticPlugin_Hypothesis_i::UnsetSizeMap"); + ASSERT(myBaseImpl); + std::string entry = theGeomObj->GetStudyEntry(); + UnsetSizeMapEntry( entry.c_str()); } //============================================================================= diff --git a/src/HexoticPlugin/HexoticPlugin_Hypothesis_i.hxx b/src/HexoticPlugin/HexoticPlugin_Hypothesis_i.hxx index d04d7cc..7fa9b4b 100644 --- a/src/HexoticPlugin/HexoticPlugin_Hypothesis_i.hxx +++ b/src/HexoticPlugin/HexoticPlugin_Hypothesis_i.hxx @@ -85,9 +85,11 @@ class HEXOTICPLUGIN_EXPORT HexoticPlugin_Hypothesis_i: CORBA::Long GetHexoticMaxMemory(); void SetSizeMapEntry(const char* theEntry, CORBA::Double theSize); + void UnsetSizeMapEntry(const char* theEntry); + void SetSizeMap(GEOM::GEOM_Object_ptr theGeomObj, double theSize); + void UnsetSizeMap(GEOM::GEOM_Object_ptr theGeomObj); HexoticPlugin::HexoticPluginSizeMapsList* GetSizeMaps (); - void ClearSizeMaps(); // Get implementation ::HexoticPlugin_Hypothesis* GetImpl(); -- 2.39.2