]> SALOME platform Git repositories - plugins/hexoticplugin.git/blob - src/GUI/HexoticPluginGUI_HypothesisCreator.cxx
Salome HOME
Merge from BR_size_maps
[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   mySizeMapRemoved ( false )
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   connect( mySmpWidget->pushButton_1,  SIGNAL( clicked() ),  this,  SLOT( onAddLocalSize() ) );
190   connect( mySmpWidget->pushButton_2,  SIGNAL( clicked() ),  this,  SLOT( onRemoveLocalSize() ) );
191   
192   return fr;
193 }
194
195 void HexoticPluginGUI_HypothesisCreator::onAddLocalSize()
196 {
197   int rowCount = mySmpWidget->tableWidget->rowCount();
198   int columnCount = mySmpWidget->tableWidget->columnCount();
199   
200   // Get the selected object properties
201   GEOM::GEOM_Object_var sizeMapObject = myGeomSelWdg->GetObject< GEOM::GEOM_Object >(0);
202   std::string entry, shapeName;
203   entry = (std::string) sizeMapObject->GetStudyEntry();
204   shapeName = sizeMapObject->GetName();
205   
206   // Check if the object is already in the widget
207   QList<QTableWidgetItem *> listFound = mySmpWidget->tableWidget
208                                         ->findItems( QString(entry.c_str()), Qt::MatchExactly );
209   if ( !listFound.isEmpty() )
210     return;
211   
212   // Get the size value
213   double size = mySmpWidget->doubleSpinBox->value();
214   
215   // Set items for the inserted row
216   insertLocalSizeInWidget( entry, shapeName, size, rowCount );
217 }
218
219 void HexoticPluginGUI_HypothesisCreator::insertLocalSizeInWidget( std::string entry, 
220                                                                   std::string shapeName, 
221                                                                   double size, 
222                                                                   int row ) const
223 {
224   MESSAGE("HexoticPluginGUI_HypothesisCreator:insertLocalSizeInWidget")
225   int columnCount = mySmpWidget->tableWidget->columnCount();
226   
227   // Add a row at the end of the table
228   mySmpWidget->tableWidget->insertRow(row);
229   
230   QVariant value;
231   for (int col = 0; col<columnCount; col++)
232   {
233     QTableWidgetItem* item = new QTableWidgetItem();
234     switch ( col )
235     {
236       case ENTRY_COL:
237         value = QVariant( entry.c_str() );
238         break;  
239       case NAME_COL:
240         value = QVariant( shapeName.c_str() );
241         break;
242       case SIZE_COL:
243         value = QVariant( size );
244         break;
245     }       
246     item->setData(Qt::DisplayRole, value );
247     mySmpWidget->tableWidget->setItem(row,col,item);
248   }
249 }
250
251 void HexoticPluginGUI_HypothesisCreator::onRemoveLocalSize()
252 {
253   // Remove the selected rows in the table
254   QList<QTableWidgetSelectionRange> ranges = mySmpWidget->tableWidget->selectedRanges();
255   if ( ranges.isEmpty() ) // If none is selected remove the last one
256   {
257     int lastRow = mySmpWidget->tableWidget->rowCount() - 1;
258     mySmpWidget->tableWidget->removeRow( lastRow ); 
259   }
260   else
261   {
262     QTableWidgetSelectionRange& range = ranges.first();
263     mySmpWidget->tableWidget->model()->removeRows(range.topRow(), range.rowCount());
264   }
265   mySizeMapRemoved = true;
266 }
267
268 //=================================================================================
269 // function : resizeEvent [REDEFINED]
270 // purpose  :
271 //=================================================================================
272 void HexoticPluginGUI_HypothesisCreator::resizeEvent(QResizeEvent */*event*/) {
273     QSize scaledSize = myStdWidget->imageSdMode.size();
274     scaledSize.scale(myStdWidget->sdModeLabel->size(), Qt::KeepAspectRatioByExpanding);
275     if (!myStdWidget->sdModeLabel->pixmap() || scaledSize != myStdWidget->sdModeLabel->pixmap()->size())
276         myStdWidget->sdModeLabel->setPixmap(myStdWidget->imageSdMode.scaled(myStdWidget->sdModeLabel->size(),
277                         Qt::KeepAspectRatio,
278                         Qt::SmoothTransformation));
279 }
280
281 void HexoticPluginGUI_HypothesisCreator::retrieveParams() const
282 {
283   HexoticHypothesisData data;
284   readParamsFromHypo( data );
285   printData(data);
286
287   if( myName )
288     myName->setText( data.myName );
289
290   myStdWidget->myMinSize->setCleared(data.myMinSize == 0);
291   if (data.myMinSize == 0)
292     myStdWidget->myMinSize->setText("");
293   else
294     myStdWidget->myMinSize->setValue( data.myMinSize );
295
296   myStdWidget->myMaxSize->setCleared(data.myMaxSize == 0);
297   if (data.myMaxSize == 0)
298     myStdWidget->myMaxSize->setText("");
299   else
300     myStdWidget->myMaxSize->setValue( data.myMaxSize );
301
302   myStdWidget->myHexesMinLevel->setCleared(data.myHexesMinLevel == 0);
303   if (data.myHexesMinLevel == 0)
304     myStdWidget->myHexesMinLevel->setText("");
305   else
306     myStdWidget->myHexesMinLevel->setValue( data.myHexesMinLevel );
307
308   myStdWidget->myHexesMaxLevel->setCleared(data.myHexesMaxLevel == 0);
309   if (data.myHexesMaxLevel == 0)
310     myStdWidget->myHexesMaxLevel->setText("");
311   else
312     myStdWidget->myHexesMaxLevel->setValue( data.myHexesMaxLevel );
313
314   myStdWidget->myHexoticIgnoreRidges->setChecked( data.myHexoticIgnoreRidges );
315   myStdWidget->myHexoticInvalidElements->setChecked( data.myHexoticInvalidElements );
316   
317   myStdWidget->myHexoticSharpAngleThreshold->setCleared(data.myHexoticSharpAngleThreshold == 0);
318   if (data.myHexoticSharpAngleThreshold == 0)
319     myStdWidget->myHexoticSharpAngleThreshold->setText("");
320   else
321     myStdWidget->myHexoticSharpAngleThreshold->setValue( data.myHexoticSharpAngleThreshold );
322
323   myStdWidget->myHexoticNbProc->setValue( data.myHexoticNbProc );
324   myStdWidget->myHexoticWorkingDir->setText( data.myHexoticWorkingDir );
325
326   myStdWidget->myHexoticVerbosity->setValue( data.myHexoticVerbosity );
327
328   myStdWidget->myHexoticMaxMemory->setValue( data.myHexoticMaxMemory );
329
330   myStdWidget->myHexoticSdMode->setCurrentIndex(data.myHexoticSdMode);
331   
332   HexoticPlugin_Hypothesis::THexoticSizeMaps::const_iterator it = data.mySizeMaps.begin();
333   for ( int row = 0; it != data.mySizeMaps.end(); it++, row++ )
334   {
335     std::string entry = it->first;
336     double size = it->second;
337     GEOM::GEOM_Object_var anObject = entryToObject( entry );
338     std::string shapeName = anObject->GetName();
339
340     MESSAGE(" Insert local size, entry : "<<entry<<", size : "<<size<<", at row : "<<row) 
341     insertLocalSizeInWidget( entry, shapeName, size , row );
342   }
343
344   std::cout << "myStdWidget->myMinSize->value(): " << myStdWidget->myMinSize->value() << std::endl;
345   std::cout << "myStdWidget->myMaxSize->value(): " << myStdWidget->myMaxSize->value() << std::endl;
346   std::cout << "myStdWidget->myHexesMinLevel->value(): " << myStdWidget->myHexesMinLevel->value() << std::endl;
347   std::cout << "myStdWidget->myHexesMaxLevel->value(): " << myStdWidget->myHexesMaxLevel->value() << std::endl;
348   std::cout << "myStdWidget->myHexoticSharpAngleThreshold->value(): " << myStdWidget->myHexoticSharpAngleThreshold->value() << std::endl;
349
350 }
351
352 void HexoticPluginGUI_HypothesisCreator::printData( HexoticHypothesisData& data) const
353 {
354   QString valStr;
355   valStr += tr("Hexotic_MIN_SIZE") + " = " + QString::number( data.myMinSize )   + "; ";
356   valStr += tr("Hexotic_MAX_SIZE") + " = " + QString::number( data.myMaxSize ) + "; ";
357   valStr += tr("Hexotic_HEXES_MIN_LEVEL") + " = " + QString::number( data.myHexesMinLevel )   + "; ";
358   valStr += tr("Hexotic_HEXES_MAX_LEVEL") + " = " + QString::number( data.myHexesMaxLevel ) + "; ";
359   valStr += tr("Hexotic_IGNORE_RIDGES")  + " = " + QString::number( data.myHexoticIgnoreRidges ) + "; ";
360   valStr += tr("Hexotic_INVALID_ELEMENTS")  + " = " + QString::number( data.myHexoticInvalidElements ) + "; ";
361   valStr += tr("Hexotic_SHARP_ANGLE_THRESHOLD") + " = " + QString::number( data.myHexoticSharpAngleThreshold ) + "; ";
362   valStr += tr("Hexotic_NB_PROC") + " = " + QString::number( data.myHexoticNbProc ) + "; ";
363   valStr += tr("Hexotic_WORKING_DIR") + " = " + data.myHexoticWorkingDir + "; ";
364   valStr += tr("Hexotic_VERBOSITY") + " = " + QString::number( data.myHexoticVerbosity ) + "; ";
365   valStr += tr("Hexotic_MAX_MEMORY") + " = " + QString::number( data.myHexoticMaxMemory ) + "; ";
366   valStr += tr("Hexotic_SD_MODE") + " = " + QString::number( data.myHexoticSdMode ) + "; ";
367
368   std::cout << "Data: " << valStr.toStdString() << std::endl;
369 }
370
371 QString HexoticPluginGUI_HypothesisCreator::storeParams() const
372 {
373   HexoticHypothesisData data;
374   readParamsFromWidgets( data );
375   storeParamsToHypo( data );
376
377   QString valStr;
378   valStr += tr("Hexotic_MIN_SIZE") + " = " + QString::number( data.myMinSize )   + "; ";
379   valStr += tr("Hexotic_MAX_SIZE") + " = " + QString::number( data.myMaxSize ) + "; ";
380   valStr += tr("Hexotic_HEXES_MIN_LEVEL") + " = " + QString::number( data.myHexesMinLevel )   + "; ";
381   valStr += tr("Hexotic_HEXES_MAX_LEVEL") + " = " + QString::number( data.myHexesMaxLevel ) + "; ";
382   valStr += tr("Hexotic_IGNORE_RIDGES")  + " = " + QString::number( data.myHexoticIgnoreRidges ) + "; ";
383   valStr += tr("Hexotic_INVALID_ELEMENTS")  + " = " + QString::number( data.myHexoticInvalidElements ) + "; ";
384   valStr += tr("Hexotic_SHARP_ANGLE_THRESHOLD") + " = " + QString::number( data.myHexoticSharpAngleThreshold ) + "; ";
385   valStr += tr("Hexotic_NB_PROC") + " = " + QString::number( data.myHexoticNbProc ) + "; ";
386   valStr += tr("Hexotic_WORKING_DIR") + " = " + data.myHexoticWorkingDir + "; ";
387   valStr += tr("Hexotic_VERBOSITY") + " = " + QString::number( data.myHexoticVerbosity) + "; ";
388   valStr += tr("Hexotic_MAX_MEMORY") + " = " + QString::number( data.myHexoticMaxMemory ) + "; ";
389   valStr += tr("Hexotic_SD_MODE") + " = " + QString::number( data.myHexoticSdMode) + "; ";
390
391 //  std::cout << "Data: " << valStr.toStdString() << std::endl;
392
393   return valStr;
394 }
395
396 bool HexoticPluginGUI_HypothesisCreator::readParamsFromHypo( HexoticHypothesisData& h_data ) const
397 {
398   HexoticPlugin::HexoticPlugin_Hypothesis_var h =
399     HexoticPlugin::HexoticPlugin_Hypothesis::_narrow( initParamsHypothesis() );
400
401   HypothesisData* data = SMESH::GetHypothesisData( hypType() );
402   h_data.myName = isCreation() && data ? data->Label : "";
403   h_data.myMinSize = h->GetMinSize();
404   h_data.myMaxSize = h->GetMaxSize();
405   h_data.myHexesMinLevel = h->GetHexesMinLevel();
406   h_data.myHexesMaxLevel = h->GetHexesMaxLevel();
407   h_data.myHexoticIgnoreRidges = h->GetHexoticIgnoreRidges();
408   h_data.myHexoticInvalidElements = h->GetHexoticInvalidElements();
409   h_data.myHexoticSharpAngleThreshold = h->GetHexoticSharpAngleThreshold();
410   h_data.myHexoticNbProc = h->GetHexoticNbProc();
411   h_data.myHexoticWorkingDir = h->GetHexoticWorkingDirectory();
412   h_data.myHexoticVerbosity = h->GetHexoticVerbosity();
413   h_data.myHexoticMaxMemory = h->GetHexoticMaxMemory();
414   h_data.myHexoticSdMode = h->GetHexoticSdMode()-1;
415   
416   // Size maps
417   HexoticPlugin::HexoticPluginSizeMapsList_var sizeMaps = h->GetSizeMaps();
418   for ( int i = 0 ; i < sizeMaps->length() ; i++) 
419   {
420     HexoticPlugin::HexoticPluginSizeMap aSizeMap = sizeMaps[i];
421     std::string entry = CORBA::string_dup(aSizeMap.entry.in());
422     double size = aSizeMap.size;
423     h_data.mySizeMaps[ entry ] = size;
424     MESSAGE("READING Size map : entry "<<entry<<" size : "<<size)
425   }
426   
427   return true;
428 }
429
430 bool HexoticPluginGUI_HypothesisCreator::storeParamsToHypo( const HexoticHypothesisData& h_data ) const
431 {
432   HexoticPlugin::HexoticPlugin_Hypothesis_var h =
433     HexoticPlugin::HexoticPlugin_Hypothesis::_narrow( hypothesis() );
434
435   bool ok = true;
436
437   try
438   {
439     if( isCreation() )
440       SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
441
442     h->SetMinSize( h_data.myMinSize );
443     h->SetMaxSize( h_data.myMaxSize );
444     h->SetHexesMinLevel( h_data.myHexesMinLevel );
445     h->SetHexesMaxLevel( h_data.myHexesMaxLevel );
446     h->SetHexoticIgnoreRidges( h_data.myHexoticIgnoreRidges );
447     h->SetHexoticInvalidElements( h_data.myHexoticInvalidElements );
448     h->SetHexoticSharpAngleThreshold( h_data.myHexoticSharpAngleThreshold );
449     h->SetHexoticNbProc( h_data.myHexoticNbProc );
450     h->SetHexoticWorkingDirectory( h_data.myHexoticWorkingDir.toLatin1().constData() );
451     h->SetHexoticVerbosity( h_data.myHexoticVerbosity );
452     h->SetHexoticMaxMemory( h_data.myHexoticMaxMemory );
453     h->SetHexoticSdMode( h_data.myHexoticSdMode+1 );
454     
455     HexoticPlugin_Hypothesis::THexoticSizeMaps::const_iterator it;
456     
457     // Clear size maps in hypothesis if one of them as been removed by the user
458     if ( mySizeMapRemoved )
459       h->ClearSizeMaps();
460     
461     for ( it =  h_data.mySizeMaps.begin(); it !=  h_data.mySizeMaps.end(); it++ )
462     {
463        h->SetSizeMapEntry( it->first.c_str(), it->second );
464        MESSAGE("STORING Size map : entry "<<it->first.c_str()<<" size : "<<it->second)
465     }
466   }
467   catch(const SALOME::SALOME_Exception& ex)
468   {
469     SalomeApp_Tools::QtCatchCorbaException(ex);
470     ok = false;
471   }
472   return ok;
473 }
474
475 bool HexoticPluginGUI_HypothesisCreator::readParamsFromWidgets( HexoticHypothesisData& h_data ) const
476 {
477   h_data.myName    = myName ? myName->text() : "";
478
479   h_data.myHexoticIgnoreRidges = myStdWidget->myHexoticIgnoreRidges->isChecked();
480   h_data.myHexoticInvalidElements = myStdWidget->myHexoticInvalidElements->isChecked();
481
482   h_data.myHexoticNbProc = myStdWidget->myHexoticNbProc->value();
483   h_data.myHexoticWorkingDir = myStdWidget->myHexoticWorkingDir->text();
484   h_data.myHexoticVerbosity = myStdWidget->myHexoticVerbosity->value();
485   h_data.myHexoticMaxMemory = myStdWidget->myHexoticMaxMemory->value();
486   h_data.myHexoticSdMode = myStdWidget->myHexoticSdMode->currentIndex();
487
488   h_data.myMinSize = myStdWidget->myMinSize->text().isEmpty() ? 0.0 : myStdWidget->myMinSize->value();
489   h_data.myMaxSize = myStdWidget->myMaxSize->text().isEmpty() ? 0.0 : myStdWidget->myMaxSize->value();
490   h_data.myHexesMinLevel = myStdWidget->myHexesMinLevel->text().isEmpty() ? 0 : myStdWidget->myHexesMinLevel->value();
491   h_data.myHexesMaxLevel = myStdWidget->myHexesMaxLevel->text().isEmpty() ? 0 : myStdWidget->myHexesMaxLevel->value();
492   h_data.myHexoticSharpAngleThreshold = myStdWidget->myHexoticSharpAngleThreshold->text().isEmpty() ? 0 : myStdWidget->myHexoticSharpAngleThreshold->value();
493
494   // Size maps reading
495   bool ok = readSizeMapsFromWidgets( h_data );
496   if ( !ok )
497     return false;
498   
499   printData(h_data);
500
501   return true;
502 }
503
504 bool HexoticPluginGUI_HypothesisCreator::readSizeMapsFromWidgets( HexoticHypothesisData& h_data ) const
505 {
506   int rowCount = mySmpWidget->tableWidget->rowCount();
507   for ( int row = 0; row <  rowCount; row++ )
508   {
509     std::string entry     = mySmpWidget->tableWidget->item( row, ENTRY_COL )->text().toStdString();
510     QVariant size_variant = mySmpWidget->tableWidget->item( row, SIZE_COL )->data(Qt::DisplayRole);
511     
512     // Convert the size to double
513     bool ok = false;
514     double size = size_variant.toDouble(&ok);
515     if (!ok)
516       return false;
517     
518     // Set the size maps
519     h_data.mySizeMaps[ entry ] = size;
520     MESSAGE("READING Size map from WIDGET: entry "<<entry<<" size : "<<size)
521   } 
522 }
523
524 GEOM::GEOM_Object_var HexoticPluginGUI_HypothesisCreator::entryToObject( std::string entry) const
525 {
526   SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
527   SALOMEDS::Study_var myStudy = smeshGen_i->GetCurrentStudy();
528   GEOM::GEOM_Object_var aGeomObj;
529   SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.c_str() );
530   if (!aSObj->_is_nil()) {
531     CORBA::Object_var obj = aSObj->GetObject();
532     aGeomObj = GEOM::GEOM_Object::_narrow(obj);
533     aSObj->UnRegister();
534   }
535   return aGeomObj;
536 }
537
538 QString HexoticPluginGUI_HypothesisCreator::caption() const
539 {
540   return myIs3D ? tr( "Hexotic_3D_TITLE" ) : tr( "Hexotic_3D_TITLE" ); // ??? 3D/2D ???
541 }
542
543 QPixmap HexoticPluginGUI_HypothesisCreator::icon() const
544 {
545   QString hypIconName = myIs3D ? tr( "ICON_DLG_Hexotic_PARAMETERS" ) : tr( "ICON_DLG_Hexotic_PARAMETERS" );
546   return SUIT_Session::session()->resourceMgr()->loadPixmap( "HexoticPLUGIN", hypIconName );
547 }
548
549 QString HexoticPluginGUI_HypothesisCreator::type() const
550 {
551   return myIs3D ? tr( "Hexotic_3D_HYPOTHESIS" ) : tr( "Hexotic_3D_HYPOTHESIS" ); // ??? 3D/2D ???
552 }
553
554 QString HexoticPluginGUI_HypothesisCreator::helpPage() const
555 {
556   return "hexotic_hypo_page.html";
557 }