Salome HOME
BUG: HexoticPLUGIN/Size maps: Fixed some dump issues
[plugins/hexoticplugin.git] / src / GUI / HexoticPluginGUI_HypothesisCreator.cxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // ---
21 // File   : HexoticPluginGUI_HypothesisCreator.cxx
22 // Author : Lioka RAZAFINDRAZAKA (CEA)
23 // ---
24 //
25 #include "HexoticPluginGUI_HypothesisCreator.h"
26 #include "HexoticPluginGUI_Dlg.h"
27
28 #include <SMESHGUI_Utils.h>
29 #include <SMESHGUI_HypothesesUtils.h>
30 #include "SMESH_NumberFilter.hxx"
31
32 #include "utilities.h"
33
34 #include CORBA_SERVER_HEADER(HexoticPlugin_Algorithm)
35
36 #include <SUIT_Session.h>
37 #include <SUIT_ResourceMgr.h>
38 #include <SUIT_FileDlg.h>
39 #include <SalomeApp_Tools.h>
40 #include <QtxIntSpinBox.h>
41
42 #include <QFrame>
43 #include <QGroupBox>
44 #include <QVBoxLayout>
45 #include <QGridLayout>
46 #include <QLineEdit>
47 #include <QLabel>
48 #include <QCheckBox>
49 #include <QPushButton>
50
51 #include "SMESH_Gen_i.hxx"
52
53 // OCC includes
54 #include <TColStd_MapOfInteger.hxx>
55 #include <TopAbs.hxx>
56
57 // Main widget tabs identification
58 enum {
59   STD_TAB = 0,
60   SMP_TAB
61 };
62
63 // Size maps tab, table columns order
64 enum {
65   ENTRY_COL = 0,
66   NAME_COL,
67   SIZE_COL
68 };
69
70 HexoticPluginGUI_HypothesisCreator::HexoticPluginGUI_HypothesisCreator( const QString& theHypType )
71 : SMESHGUI_GenericHypothesisCreator( theHypType ),
72   myIs3D( true ),
73   mySizeMapsToRemove ()
74 {
75 }
76
77 HexoticPluginGUI_HypothesisCreator::~HexoticPluginGUI_HypothesisCreator()
78 {
79 }
80
81 bool HexoticPluginGUI_HypothesisCreator::checkParams(QString& msg) const
82 {
83   msg.clear();
84   HexoticHypothesisData data_old, data_new;
85   readParamsFromHypo( data_old );
86   readParamsFromWidgets( data_new );
87
88   bool res = storeParamsToHypo( data_new );
89   if ( !res ) {
90     storeParamsToHypo( data_old );
91     return res;
92   }
93
94   res = data_new.myMinSize <= data_new.myMaxSize;
95   if ( !res ) {
96     msg = tr(QString("Min size (%1) is higher than max size (%2)").arg(data_new.myMinSize).arg(data_new.myMaxSize).toStdString().c_str());
97     return res;
98   }
99
100   res = data_new.myHexesMinLevel == 0  || \
101       ( data_new.myHexesMinLevel != 0  && (data_new.myHexesMinLevel < data_new.myHexesMaxLevel) );
102   if ( !res ) {
103     msg = tr(QString("Min hexes level (%1) is higher than max hexes level (%2)").arg(data_new.myHexesMinLevel).arg(data_new.myHexesMaxLevel).toStdString().c_str());
104     return res;
105   }
106
107   return true;
108 }
109
110 QFrame* HexoticPluginGUI_HypothesisCreator::buildFrame()
111 {
112   QFrame* fr = new QFrame( 0 );
113   QVBoxLayout* lay = new QVBoxLayout( fr );
114   lay->setMargin( 0 );
115   lay->setSpacing( 6 );
116   
117   // main TabWidget of the dialog
118   QTabWidget* aTabWidget = new QTabWidget( fr );
119   aTabWidget->setTabShape( QTabWidget::Rounded );
120   aTabWidget->setTabPosition( QTabWidget::North );
121   lay->addWidget( aTabWidget );
122
123   // Standard arguments tab
124   QWidget* aStdGroup = new QWidget();
125   QGridLayout* l = new QGridLayout( aStdGroup );
126   l->setSpacing( 6 );
127   l->setMargin( 11 );
128  
129   int row = 0;
130   myName = 0;
131   if( isCreation() ) {
132     l->addWidget( new QLabel( tr( "SMESH_NAME" ), aStdGroup ), row, 0, 1, 1 );
133     myName = new QLineEdit( aStdGroup );
134     l->addWidget( myName, row++, 1, 1, 2 );
135     myName->setMinimumWidth( 150 );
136   }
137
138   HexoticPlugin::HexoticPlugin_Hypothesis_var h =
139   HexoticPlugin::HexoticPlugin_Hypothesis::_narrow( initParamsHypothesis() );
140   
141   myStdWidget = new HexoticPluginGUI_StdWidget(aStdGroup);
142   l->addWidget( myStdWidget, row++, 0, 1, 3 );
143   myStdWidget->onSdModeSelected(SD_MODE_4);
144
145   // SIZE MAPS TAB
146   QWidget* aSmpGroup = new QWidget();
147   lay->addWidget( aSmpGroup );
148   
149   // Size map widget creation and initialisation
150   mySmpWidget = new HexoticPluginGUI_SizeMapsWidget(aSmpGroup);
151   mySmpWidget->doubleSpinBox->setValue(0.0);
152   
153   // Filters of selection
154   TColStd_MapOfInteger SM_ShapeTypes; 
155   SM_ShapeTypes.Add( TopAbs_VERTEX );
156   SM_ShapeTypes.Add( TopAbs_EDGE );
157   SM_ShapeTypes.Add( TopAbs_WIRE );
158   SM_ShapeTypes.Add( TopAbs_FACE );
159   SM_ShapeTypes.Add( TopAbs_SOLID );
160   SM_ShapeTypes.Add( TopAbs_COMPOUND );  
161   SMESH_NumberFilter* aFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, SM_ShapeTypes);
162   
163   myGeomSelWdg = new StdMeshersGUI_ObjectReferenceParamWdg( aFilter, mySmpWidget, /*multiSel=*/false,/*stretch=*/false);
164   myGeomSelWdg->SetDefaultText(tr("Hexotic_SEL_SHAPE"), "QLineEdit { color: grey }");
165   mySmpWidget->gridLayout->addWidget(myGeomSelWdg, 0, 1);
166   
167   QHBoxLayout* aSmpLayout = new QHBoxLayout( aSmpGroup );
168   aSmpLayout->setMargin( 0 );
169   aSmpLayout->addWidget( mySmpWidget);
170   
171   QStringList headerLabels;
172   headerLabels << tr("Hexotic_ENTRY")<< tr("Hexotic_NAME")<< tr("Hexotic_SIZE");
173   mySmpWidget->tableWidget->setHorizontalHeaderLabels(headerLabels);
174   mySmpWidget->tableWidget->resizeColumnsToContents();
175   mySmpWidget->tableWidget->hideColumn( 0 );
176   mySmpWidget->label->setText(tr("LOCAL_SIZE"));
177   mySmpWidget->pushButton_1->setText(tr("Hexotic_ADD"));
178   mySmpWidget->pushButton_2->setText(tr("Hexotic_REMOVE"));
179   
180  
181 //  resizeEvent();
182   
183   aTabWidget->insertTab( STD_TAB, aStdGroup, tr( "SMESH_ARGUMENTS" ) );
184   aTabWidget->insertTab( SMP_TAB, aSmpGroup, tr( "LOCAL_SIZE" ) );
185   
186   myIs3D = true;
187   
188   // Size Maps
189   mySizeMapsToRemove.clear();
190   connect( mySmpWidget->pushButton_1,  SIGNAL( clicked() ),  this,  SLOT( onAddLocalSize() ) );
191   connect( mySmpWidget->pushButton_2,  SIGNAL( clicked() ),  this,  SLOT( onRemoveLocalSize() ) );
192   
193   return fr;
194 }
195
196 void HexoticPluginGUI_HypothesisCreator::onAddLocalSize()
197 {
198   int rowCount = mySmpWidget->tableWidget->rowCount();
199   int columnCount = mySmpWidget->tableWidget->columnCount();
200   
201   // Get the selected object properties
202   GEOM::GEOM_Object_var sizeMapObject = myGeomSelWdg->GetObject< GEOM::GEOM_Object >(0);
203   std::string entry, shapeName;
204   entry = (std::string) sizeMapObject->GetStudyEntry();
205   shapeName = sizeMapObject->GetName();
206   
207   // Check if the object is already in the widget
208   QList<QTableWidgetItem *> listFound = mySmpWidget->tableWidget
209                                         ->findItems( QString(entry.c_str()), Qt::MatchExactly );
210   if ( !listFound.isEmpty() )
211     return;
212   
213   // Get the size value
214   double size = mySmpWidget->doubleSpinBox->value();
215   
216   // Set items for the inserted row
217   insertLocalSizeInWidget( entry, shapeName, size, rowCount );
218 }
219
220 void HexoticPluginGUI_HypothesisCreator::insertLocalSizeInWidget( std::string entry, 
221                                                                   std::string shapeName, 
222                                                                   double size, 
223                                                                   int row ) const
224 {
225   MESSAGE("HexoticPluginGUI_HypothesisCreator:insertLocalSizeInWidget")
226   int columnCount = mySmpWidget->tableWidget->columnCount();
227   
228   // Add a row at the end of the table
229   mySmpWidget->tableWidget->insertRow(row);
230   
231   QVariant value;
232   for (int col = 0; col<columnCount; col++)
233   {
234     QTableWidgetItem* item = new QTableWidgetItem();
235     switch ( col )
236     {
237       case ENTRY_COL:
238         value = QVariant( entry.c_str() );
239         break;  
240       case NAME_COL:
241         value = QVariant( shapeName.c_str() );
242         break;
243       case SIZE_COL:
244         value = QVariant( size );
245         break;
246     }       
247     item->setData(Qt::DisplayRole, value );
248     mySmpWidget->tableWidget->setItem(row,col,item);
249   }
250 }
251
252 void HexoticPluginGUI_HypothesisCreator::onRemoveLocalSize()
253 {
254   // Remove the selected rows in the table
255   QList<QTableWidgetSelectionRange> ranges = mySmpWidget->tableWidget->selectedRanges();
256   if ( ranges.isEmpty() ) // If none is selected remove the last one
257   {
258     int lastRow = mySmpWidget->tableWidget->rowCount() - 1;
259     std::string entry = mySmpWidget->tableWidget->item( lastRow, ENTRY_COL )->text().toStdString();
260     mySizeMapsToRemove.push_back(entry);
261     mySmpWidget->tableWidget->removeRow( lastRow ); 
262   }
263   else
264   {
265     QTableWidgetSelectionRange& range = ranges.first();
266     for ( int row = range.topRow(); row < range.rowCount(); row++ )
267     {
268       std::string entry = mySmpWidget->tableWidget->item( row, ENTRY_COL )->text().toStdString();
269       mySizeMapsToRemove.push_back(entry);
270     }
271     mySmpWidget->tableWidget->model()->removeRows(range.topRow(), range.rowCount());
272   }
273 }
274
275 //=================================================================================
276 // function : resizeEvent [REDEFINED]
277 // purpose  :
278 //=================================================================================
279 void HexoticPluginGUI_HypothesisCreator::resizeEvent(QResizeEvent */*event*/) {
280     QSize scaledSize = myStdWidget->imageSdMode.size();
281     scaledSize.scale(myStdWidget->sdModeLabel->size(), Qt::KeepAspectRatioByExpanding);
282     if (!myStdWidget->sdModeLabel->pixmap() || scaledSize != myStdWidget->sdModeLabel->pixmap()->size())
283         myStdWidget->sdModeLabel->setPixmap(myStdWidget->imageSdMode.scaled(myStdWidget->sdModeLabel->size(),
284                         Qt::KeepAspectRatio,
285                         Qt::SmoothTransformation));
286 }
287
288 void HexoticPluginGUI_HypothesisCreator::retrieveParams() const
289 {
290   HexoticHypothesisData data;
291   readParamsFromHypo( data );
292   printData(data);
293
294   if( myName )
295     myName->setText( data.myName );
296
297   myStdWidget->myMinSize->setCleared(data.myMinSize == 0);
298   if (data.myMinSize == 0)
299     myStdWidget->myMinSize->setText("");
300   else
301     myStdWidget->myMinSize->setValue( data.myMinSize );
302
303   myStdWidget->myMaxSize->setCleared(data.myMaxSize == 0);
304   if (data.myMaxSize == 0)
305     myStdWidget->myMaxSize->setText("");
306   else
307     myStdWidget->myMaxSize->setValue( data.myMaxSize );
308
309   myStdWidget->myHexesMinLevel->setCleared(data.myHexesMinLevel == 0);
310   if (data.myHexesMinLevel == 0)
311     myStdWidget->myHexesMinLevel->setText("");
312   else
313     myStdWidget->myHexesMinLevel->setValue( data.myHexesMinLevel );
314
315   myStdWidget->myHexesMaxLevel->setCleared(data.myHexesMaxLevel == 0);
316   if (data.myHexesMaxLevel == 0)
317     myStdWidget->myHexesMaxLevel->setText("");
318   else
319     myStdWidget->myHexesMaxLevel->setValue( data.myHexesMaxLevel );
320
321   myStdWidget->myHexoticIgnoreRidges->setChecked( data.myHexoticIgnoreRidges );
322   myStdWidget->myHexoticInvalidElements->setChecked( data.myHexoticInvalidElements );
323   
324   myStdWidget->myHexoticSharpAngleThreshold->setCleared(data.myHexoticSharpAngleThreshold == 0);
325   if (data.myHexoticSharpAngleThreshold == 0)
326     myStdWidget->myHexoticSharpAngleThreshold->setText("");
327   else
328     myStdWidget->myHexoticSharpAngleThreshold->setValue( data.myHexoticSharpAngleThreshold );
329
330   myStdWidget->myHexoticNbProc->setValue( data.myHexoticNbProc );
331   myStdWidget->myHexoticWorkingDir->setText( data.myHexoticWorkingDir );
332
333   myStdWidget->myHexoticVerbosity->setValue( data.myHexoticVerbosity );
334
335   myStdWidget->myHexoticMaxMemory->setValue( data.myHexoticMaxMemory );
336
337   myStdWidget->myHexoticSdMode->setCurrentIndex(data.myHexoticSdMode);
338   
339   HexoticPlugin_Hypothesis::THexoticSizeMaps::const_iterator it = data.mySizeMaps.begin();
340   for ( int row = 0; it != data.mySizeMaps.end(); it++, row++ )
341   {
342     std::string entry = it->first;
343     double size = it->second;
344     GEOM::GEOM_Object_var anObject = entryToObject( entry );
345     std::string shapeName = anObject->GetName();
346
347     MESSAGE(" Insert local size, entry : "<<entry<<", size : "<<size<<", at row : "<<row) 
348     insertLocalSizeInWidget( entry, shapeName, size , row );
349   }
350
351   std::cout << "myStdWidget->myMinSize->value(): " << myStdWidget->myMinSize->value() << std::endl;
352   std::cout << "myStdWidget->myMaxSize->value(): " << myStdWidget->myMaxSize->value() << std::endl;
353   std::cout << "myStdWidget->myHexesMinLevel->value(): " << myStdWidget->myHexesMinLevel->value() << std::endl;
354   std::cout << "myStdWidget->myHexesMaxLevel->value(): " << myStdWidget->myHexesMaxLevel->value() << std::endl;
355   std::cout << "myStdWidget->myHexoticSharpAngleThreshold->value(): " << myStdWidget->myHexoticSharpAngleThreshold->value() << std::endl;
356
357 }
358
359 void HexoticPluginGUI_HypothesisCreator::printData( HexoticHypothesisData& data) const
360 {
361   QString valStr;
362   valStr += tr("Hexotic_MIN_SIZE") + " = " + QString::number( data.myMinSize )   + "; ";
363   valStr += tr("Hexotic_MAX_SIZE") + " = " + QString::number( data.myMaxSize ) + "; ";
364   valStr += tr("Hexotic_HEXES_MIN_LEVEL") + " = " + QString::number( data.myHexesMinLevel )   + "; ";
365   valStr += tr("Hexotic_HEXES_MAX_LEVEL") + " = " + QString::number( data.myHexesMaxLevel ) + "; ";
366   valStr += tr("Hexotic_IGNORE_RIDGES")  + " = " + QString::number( data.myHexoticIgnoreRidges ) + "; ";
367   valStr += tr("Hexotic_INVALID_ELEMENTS")  + " = " + QString::number( data.myHexoticInvalidElements ) + "; ";
368   valStr += tr("Hexotic_SHARP_ANGLE_THRESHOLD") + " = " + QString::number( data.myHexoticSharpAngleThreshold ) + "; ";
369   valStr += tr("Hexotic_NB_PROC") + " = " + QString::number( data.myHexoticNbProc ) + "; ";
370   valStr += tr("Hexotic_WORKING_DIR") + " = " + data.myHexoticWorkingDir + "; ";
371   valStr += tr("Hexotic_VERBOSITY") + " = " + QString::number( data.myHexoticVerbosity ) + "; ";
372   valStr += tr("Hexotic_MAX_MEMORY") + " = " + QString::number( data.myHexoticMaxMemory ) + "; ";
373   valStr += tr("Hexotic_SD_MODE") + " = " + QString::number( data.myHexoticSdMode ) + "; ";
374
375   std::cout << "Data: " << valStr.toStdString() << std::endl;
376 }
377
378 QString HexoticPluginGUI_HypothesisCreator::storeParams() const
379 {
380   HexoticHypothesisData data;
381   readParamsFromWidgets( data );
382   storeParamsToHypo( data );
383
384   QString valStr;
385   valStr += tr("Hexotic_MIN_SIZE") + " = " + QString::number( data.myMinSize )   + "; ";
386   valStr += tr("Hexotic_MAX_SIZE") + " = " + QString::number( data.myMaxSize ) + "; ";
387   valStr += tr("Hexotic_HEXES_MIN_LEVEL") + " = " + QString::number( data.myHexesMinLevel )   + "; ";
388   valStr += tr("Hexotic_HEXES_MAX_LEVEL") + " = " + QString::number( data.myHexesMaxLevel ) + "; ";
389   valStr += tr("Hexotic_IGNORE_RIDGES")  + " = " + QString::number( data.myHexoticIgnoreRidges ) + "; ";
390   valStr += tr("Hexotic_INVALID_ELEMENTS")  + " = " + QString::number( data.myHexoticInvalidElements ) + "; ";
391   valStr += tr("Hexotic_SHARP_ANGLE_THRESHOLD") + " = " + QString::number( data.myHexoticSharpAngleThreshold ) + "; ";
392   valStr += tr("Hexotic_NB_PROC") + " = " + QString::number( data.myHexoticNbProc ) + "; ";
393   valStr += tr("Hexotic_WORKING_DIR") + " = " + data.myHexoticWorkingDir + "; ";
394   valStr += tr("Hexotic_VERBOSITY") + " = " + QString::number( data.myHexoticVerbosity) + "; ";
395   valStr += tr("Hexotic_MAX_MEMORY") + " = " + QString::number( data.myHexoticMaxMemory ) + "; ";
396   valStr += tr("Hexotic_SD_MODE") + " = " + QString::number( data.myHexoticSdMode) + "; ";
397
398 //  std::cout << "Data: " << valStr.toStdString() << std::endl;
399
400   return valStr;
401 }
402
403 bool HexoticPluginGUI_HypothesisCreator::readParamsFromHypo( HexoticHypothesisData& h_data ) const
404 {
405   HexoticPlugin::HexoticPlugin_Hypothesis_var h =
406     HexoticPlugin::HexoticPlugin_Hypothesis::_narrow( initParamsHypothesis() );
407
408   HypothesisData* data = SMESH::GetHypothesisData( hypType() );
409   h_data.myName = isCreation() && data ? data->Label : "";
410   h_data.myMinSize = h->GetMinSize();
411   h_data.myMaxSize = h->GetMaxSize();
412   h_data.myHexesMinLevel = h->GetHexesMinLevel();
413   h_data.myHexesMaxLevel = h->GetHexesMaxLevel();
414   h_data.myHexoticIgnoreRidges = h->GetHexoticIgnoreRidges();
415   h_data.myHexoticInvalidElements = h->GetHexoticInvalidElements();
416   h_data.myHexoticSharpAngleThreshold = h->GetHexoticSharpAngleThreshold();
417   h_data.myHexoticNbProc = h->GetHexoticNbProc();
418   h_data.myHexoticWorkingDir = h->GetHexoticWorkingDirectory();
419   h_data.myHexoticVerbosity = h->GetHexoticVerbosity();
420   h_data.myHexoticMaxMemory = h->GetHexoticMaxMemory();
421   h_data.myHexoticSdMode = h->GetHexoticSdMode()-1;
422   
423   // Size maps
424   HexoticPlugin::HexoticPluginSizeMapsList_var sizeMaps = h->GetSizeMaps();
425   for ( int i = 0 ; i < sizeMaps->length() ; i++) 
426   {
427     HexoticPlugin::HexoticPluginSizeMap aSizeMap = sizeMaps[i];
428     std::string entry = CORBA::string_dup(aSizeMap.entry.in());
429     double size = aSizeMap.size;
430     h_data.mySizeMaps[ entry ] = size;
431     MESSAGE("READING Size map : entry "<<entry<<" size : "<<size)
432   }
433   
434   return true;
435 }
436
437 bool HexoticPluginGUI_HypothesisCreator::storeParamsToHypo( const HexoticHypothesisData& h_data ) const
438 {
439   HexoticPlugin::HexoticPlugin_Hypothesis_var h =
440     HexoticPlugin::HexoticPlugin_Hypothesis::_narrow( hypothesis() );
441
442   bool ok = true;
443
444   try
445   {
446     if( isCreation() )
447       SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
448
449     h->SetMinSize( h_data.myMinSize );
450     h->SetMaxSize( h_data.myMaxSize );
451     h->SetHexesMinLevel( h_data.myHexesMinLevel );
452     h->SetHexesMaxLevel( h_data.myHexesMaxLevel );
453     h->SetHexoticIgnoreRidges( h_data.myHexoticIgnoreRidges );
454     h->SetHexoticInvalidElements( h_data.myHexoticInvalidElements );
455     h->SetHexoticSharpAngleThreshold( h_data.myHexoticSharpAngleThreshold );
456     h->SetHexoticNbProc( h_data.myHexoticNbProc );
457     h->SetHexoticWorkingDirectory( h_data.myHexoticWorkingDir.toLatin1().constData() );
458     h->SetHexoticVerbosity( h_data.myHexoticVerbosity );
459     h->SetHexoticMaxMemory( h_data.myHexoticMaxMemory );
460     h->SetHexoticSdMode( h_data.myHexoticSdMode+1 );
461     
462     HexoticPlugin_Hypothesis::THexoticSizeMaps::const_iterator it;
463     
464     for ( it =  h_data.mySizeMaps.begin(); it !=  h_data.mySizeMaps.end(); it++ )
465     {
466       h->SetSizeMapEntry( it->first.c_str(), it->second );
467       MESSAGE("STORING Size map : entry "<<it->first.c_str()<<" size : "<<it->second)
468     }
469     std::vector< std::string >::const_iterator entry_it;
470     for ( entry_it = mySizeMapsToRemove.begin(); entry_it!= mySizeMapsToRemove.end(); entry_it++ )
471     {
472       h->UnsetSizeMapEntry(entry_it->c_str());
473     }
474   }
475   catch(const SALOME::SALOME_Exception& ex)
476   {
477     SalomeApp_Tools::QtCatchCorbaException(ex);
478     ok = false;
479   }
480   return ok;
481 }
482
483 bool HexoticPluginGUI_HypothesisCreator::readParamsFromWidgets( HexoticHypothesisData& h_data ) const
484 {
485   h_data.myName    = myName ? myName->text() : "";
486
487   h_data.myHexoticIgnoreRidges = myStdWidget->myHexoticIgnoreRidges->isChecked();
488   h_data.myHexoticInvalidElements = myStdWidget->myHexoticInvalidElements->isChecked();
489
490   h_data.myHexoticNbProc = myStdWidget->myHexoticNbProc->value();
491   h_data.myHexoticWorkingDir = myStdWidget->myHexoticWorkingDir->text();
492   h_data.myHexoticVerbosity = myStdWidget->myHexoticVerbosity->value();
493   h_data.myHexoticMaxMemory = myStdWidget->myHexoticMaxMemory->value();
494   h_data.myHexoticSdMode = myStdWidget->myHexoticSdMode->currentIndex();
495
496   h_data.myMinSize = myStdWidget->myMinSize->text().isEmpty() ? 0.0 : myStdWidget->myMinSize->value();
497   h_data.myMaxSize = myStdWidget->myMaxSize->text().isEmpty() ? 0.0 : myStdWidget->myMaxSize->value();
498   h_data.myHexesMinLevel = myStdWidget->myHexesMinLevel->text().isEmpty() ? 0 : myStdWidget->myHexesMinLevel->value();
499   h_data.myHexesMaxLevel = myStdWidget->myHexesMaxLevel->text().isEmpty() ? 0 : myStdWidget->myHexesMaxLevel->value();
500   h_data.myHexoticSharpAngleThreshold = myStdWidget->myHexoticSharpAngleThreshold->text().isEmpty() ? 0 : myStdWidget->myHexoticSharpAngleThreshold->value();
501
502   // Size maps reading
503   bool ok = readSizeMapsFromWidgets( h_data );
504   if ( !ok )
505     return false;
506   
507   printData(h_data);
508
509   return true;
510 }
511
512 bool HexoticPluginGUI_HypothesisCreator::readSizeMapsFromWidgets( HexoticHypothesisData& h_data ) const
513 {
514   int rowCount = mySmpWidget->tableWidget->rowCount();
515   for ( int row = 0; row <  rowCount; row++ )
516   {
517     std::string entry     = mySmpWidget->tableWidget->item( row, ENTRY_COL )->text().toStdString();
518     QVariant size_variant = mySmpWidget->tableWidget->item( row, SIZE_COL )->data(Qt::DisplayRole);
519     
520     // Convert the size to double
521     bool ok = false;
522     double size = size_variant.toDouble(&ok);
523     if (!ok)
524       return false;
525     
526     // Set the size maps
527     h_data.mySizeMaps[ entry ] = size;
528     MESSAGE("READING Size map from WIDGET: entry "<<entry<<" size : "<<size)
529   } 
530 }
531
532 GEOM::GEOM_Object_var HexoticPluginGUI_HypothesisCreator::entryToObject( std::string entry) const
533 {
534   SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
535   SALOMEDS::Study_var myStudy = smeshGen_i->GetCurrentStudy();
536   GEOM::GEOM_Object_var aGeomObj;
537   SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.c_str() );
538   if (!aSObj->_is_nil()) {
539     CORBA::Object_var obj = aSObj->GetObject();
540     aGeomObj = GEOM::GEOM_Object::_narrow(obj);
541     aSObj->UnRegister();
542   }
543   return aGeomObj;
544 }
545
546 QString HexoticPluginGUI_HypothesisCreator::caption() const
547 {
548   return myIs3D ? tr( "Hexotic_3D_TITLE" ) : tr( "Hexotic_3D_TITLE" ); // ??? 3D/2D ???
549 }
550
551 QPixmap HexoticPluginGUI_HypothesisCreator::icon() const
552 {
553   QString hypIconName = myIs3D ? tr( "ICON_DLG_Hexotic_PARAMETERS" ) : tr( "ICON_DLG_Hexotic_PARAMETERS" );
554   return SUIT_Session::session()->resourceMgr()->loadPixmap( "HexoticPLUGIN", hypIconName );
555 }
556
557 QString HexoticPluginGUI_HypothesisCreator::type() const
558 {
559   return myIs3D ? tr( "Hexotic_3D_HYPOTHESIS" ) : tr( "Hexotic_3D_HYPOTHESIS" ); // ??? 3D/2D ???
560 }
561
562 QString HexoticPluginGUI_HypothesisCreator::helpPage() const
563 {
564   return "hexotic_hypo_page.html";
565 }