Salome HOME
BUG: HexoticPLUGIN/Size maps: Fixed some dump issues
authorrnc <rnc@opencascade.com>
Mon, 26 Aug 2013 08:48:14 +0000 (08:48 +0000)
committerrnc <rnc@opencascade.com>
Mon, 26 Aug 2013 08:48:14 +0000 (08:48 +0000)
idl/HexoticPlugin_Algorithm.idl
resources/HexoticPLUGIN.xml
src/GUI/HexoticPluginGUI_HypothesisCreator.cxx
src/GUI/HexoticPluginGUI_HypothesisCreator.h
src/HexoticPlugin/HexoticPLUGINBuilder.py
src/HexoticPlugin/HexoticPlugin_Hypothesis.cxx
src/HexoticPlugin/HexoticPlugin_Hypothesis.hxx
src/HexoticPlugin/HexoticPlugin_Hypothesis_i.cxx
src/HexoticPlugin/HexoticPlugin_Hypothesis_i.hxx

index cd9851e86275859ee6af8f9bcea0f95ac71a96e4..dae73d9a78c46057e62a0e4343303f02621d60ad 100644 (file)
@@ -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();
   };
 };
index 47c65e2a542b96f0e056ef7c998454f183d37a4e..859391c21394d1bfb5ad190e183ecd5c48acdd0e 100644 (file)
     <hypothesis type="Hexotic_Parameters"
     label-id="Hexotic Parameters"
     icon-id="mesh_hypo_Hexotic.png"
-    dim="3"/>
+    dim="3">
+      <python-wrap>
+        <accumulative-methods>
+          SetSizeMap
+          UnsetSizeMap
+        </accumulative-methods>
+      </python-wrap>
+    </hypothesis>
   </hypotheses>
   <algorithms>
 
index ad1e57c22d177541569f7c7c29c379288f2b9056..b9a8d9af19f58790897159581bbac8ad6251ca31 100644 (file)
@@ -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 "<<it->first.c_str()<<" size : "<<it->second)
+      h->SetSizeMapEntry( it->first.c_str(), it->second );
+      MESSAGE("STORING Size map : entry "<<it->first.c_str()<<" size : "<<it->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)
index ba687d50c4a53b9506f7fb8ab6eeac0d45478b24..219c25081a5cff2cd080ff8f81c6fe47725d21f9 100644 (file)
@@ -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();
index f2127b1e26180fdeabb1ec05604024d878db4652..f0c1b777610ed3a9e647492cbea70865f0369ea1 100644 (file)
@@ -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
index df82d2c32fac9a1b7f9de054bf89c3340d5ac568..3548bc6df6b94ba548ae94ce6cfd4f8d7e2711b7 100644 (file)
@@ -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;
 }
 
 //=============================================================================
index 6dd9941540ee861c97216b4c8bff72a73013bc48..dc5ba064300c581088295a476d91915023491c5d 100644 (file)
@@ -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();
index b2b500997882510d39311f4b911b8bf87fffda98..ae2f0bc5b75871d3ec8145223613b4214792890d 100644 (file)
@@ -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 = "<<valueChanged);
   if (valueChanged)
     SMESH::TPythonDump() << _this() << ".SetSizeMap( "<< theEntry << ", " << theSize << " )";
 }
 
+void HexoticPlugin_Hypothesis_i::UnsetSizeMapEntry ( const char* theEntry )
+{
+//   MESSAGE("HexoticPlugin_Hypothesis_i::UnsetSizeMapEntry");
+  bool entryRemoved = this->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());
 }
 
 //=============================================================================
index d04d7cc51b0e51f5c00a33fe65ed651a750aced8..7fa9b4b5ad5ea919eb7076833baed10454cf5cdc 100644 (file)
@@ -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();