Salome HOME
Update copyrights 2014.
[plugins/hexoticplugin.git] / src / GUI / HexoticPluginGUI_HypothesisCreator.cxx
1 // Copyright (C) 2007-2014  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, or (at your option) any later version.
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_MessageBox.h>
39 #include <SUIT_FileDlg.h>
40 #include <SalomeApp_Tools.h>
41 #include <QtxIntSpinBox.h>
42
43 #include <QFrame>
44 #include <QGroupBox>
45 #include <QVBoxLayout>
46 #include <QGridLayout>
47 #include <QLineEdit>
48 #include <QLabel>
49 #include <QCheckBox>
50 #include <QPushButton>
51
52 #include "SMESH_Gen_i.hxx"
53
54 // OCC includes
55 #include <TColStd_MapOfInteger.hxx>
56 #include <TopAbs.hxx>
57
58 // Main widget tabs identification
59 enum {
60   STD_TAB = 0,
61   SMP_TAB
62 };
63
64 // Size maps tab, table columns order
65 enum {
66   ENTRY_COL = 0,
67   NAME_COL,
68   SIZE_COL
69 };
70
71 //
72 // Size map table widget delegate
73 //
74
75 SizeMapsTableWidgetDelegate::SizeMapsTableWidgetDelegate(QObject *parent)
76      : QItemDelegate(parent)
77 {
78 }
79
80 QWidget* SizeMapsTableWidgetDelegate::createEditor(QWidget *parent,
81                                                    const QStyleOptionViewItem &/* option */,
82                                                    const QModelIndex &/* index */) const
83 {
84   SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent);
85   editor->RangeStepAndValidator(0.0, COORD_MAX, 10.0, "length_precision");
86   return editor;
87 }
88
89 void SizeMapsTableWidgetDelegate::setEditorData(QWidget *editor,
90                                                 const QModelIndex &index) const
91 {
92   double value = index.model()->data(index, Qt::EditRole).toDouble();
93   SMESHGUI_SpinBox *spinBox = static_cast<SMESHGUI_SpinBox*>(editor);
94   spinBox->setValue(value);
95 }
96
97 void SizeMapsTableWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
98                                                const QModelIndex &index) const
99 {
100   SMESHGUI_SpinBox *spinBox = static_cast<SMESHGUI_SpinBox*>(editor);
101   spinBox->interpretText();
102   double value = spinBox->value();
103   if ( value == 0 ) 
104     SUIT_MessageBox::critical( spinBox, tr( "SMESH_ERROR" ), tr( "Hexotic_NULL_LOCAL_SIZE" ) ); 
105   else
106     model->setData(index, value, Qt::EditRole);
107 }
108
109 void SizeMapsTableWidgetDelegate::updateEditorGeometry(QWidget *editor,
110                                                        const QStyleOptionViewItem &option, 
111                                                        const QModelIndex &/* index */) const
112 {
113   editor->setGeometry(option.rect);
114 }
115
116 // END Delegate
117
118
119
120 HexoticPluginGUI_HypothesisCreator::HexoticPluginGUI_HypothesisCreator( const QString& theHypType )
121 : SMESHGUI_GenericHypothesisCreator( theHypType ),
122   myIs3D( true ),
123   mySizeMapsToRemove()
124 {
125 }
126
127 HexoticPluginGUI_HypothesisCreator::~HexoticPluginGUI_HypothesisCreator()
128 {
129 }
130
131 bool HexoticPluginGUI_HypothesisCreator::checkParams(QString& msg) const
132 {
133   msg.clear();
134
135   HexoticHypothesisData data_old, data_new;
136   readParamsFromHypo( data_old );
137   
138   bool res = readParamsFromWidgets( data_new );
139   if ( !res ){
140     return res;
141   }
142
143   res = storeParamsToHypo( data_new );
144   if ( !res ) {
145     storeParamsToHypo( data_old );
146     return res;
147   }
148
149   res = data_new.myMinSize <= data_new.myMaxSize;
150   if ( !res ) {
151     msg = tr(QString("Min size (%1) is higher than max size (%2)").arg(data_new.myMinSize).arg(data_new.myMaxSize).toStdString().c_str());
152     return res;
153   }
154
155   res = data_new.myHexesMinLevel == 0  || \
156       ( data_new.myHexesMinLevel != 0  && (data_new.myHexesMinLevel < data_new.myHexesMaxLevel) );
157   if ( !res ) {
158     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());
159     return res;
160   }
161
162   return true;
163 }
164
165 QFrame* HexoticPluginGUI_HypothesisCreator::buildFrame()
166 {
167   QFrame* fr = new QFrame( 0 );
168   QVBoxLayout* lay = new QVBoxLayout( fr );
169   lay->setMargin( 0 );
170   lay->setSpacing( 6 );
171   
172   // main TabWidget of the dialog
173   QTabWidget* aTabWidget = new QTabWidget( fr );
174   aTabWidget->setTabShape( QTabWidget::Rounded );
175   aTabWidget->setTabPosition( QTabWidget::North );
176   lay->addWidget( aTabWidget );
177
178   // Standard arguments tab
179   QWidget* aStdGroup = new QWidget();
180   QGridLayout* l = new QGridLayout( aStdGroup );
181   l->setSpacing( 6 );
182   l->setMargin( 11 );
183  
184   int row = 0;
185   myName = 0;
186   if( isCreation() ) {
187     l->addWidget( new QLabel( tr( "SMESH_NAME" ), aStdGroup ), row, 0, 1, 1 );
188     myName = new QLineEdit( aStdGroup );
189     l->addWidget( myName, row++, 1, 1, 2 );
190     myName->setMinimumWidth( 150 );
191   }
192
193   HexoticPlugin::HexoticPlugin_Hypothesis_var h =
194   HexoticPlugin::HexoticPlugin_Hypothesis::_narrow( initParamsHypothesis() );
195   
196   myStdWidget = new HexoticPluginGUI_StdWidget(aStdGroup);
197   l->addWidget( myStdWidget, row++, 0, 1, 3 );
198   myStdWidget->onSdModeSelected(SD_MODE_4);
199
200   
201   // SIZE MAPS TAB
202   QWidget* aSmpGroup = new QWidget();
203   lay->addWidget( aSmpGroup );
204   
205   // Size map widget creation and initialisation
206   mySmpWidget = new HexoticPluginGUI_SizeMapsWidget(aSmpGroup);
207   mySmpWidget->doubleSpinBox->RangeStepAndValidator(0.0, COORD_MAX, 1.0, "length_precision");
208   mySmpWidget->doubleSpinBox->setValue(0.0);
209   
210   // Filters of selection
211   TColStd_MapOfInteger SM_ShapeTypes; 
212   SM_ShapeTypes.Add( TopAbs_VERTEX );
213   SM_ShapeTypes.Add( TopAbs_EDGE );
214   SM_ShapeTypes.Add( TopAbs_WIRE );
215   SM_ShapeTypes.Add( TopAbs_FACE );
216   SM_ShapeTypes.Add( TopAbs_SOLID );
217   SM_ShapeTypes.Add( TopAbs_COMPOUND );  
218   SMESH_NumberFilter* aFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, SM_ShapeTypes);
219   
220   // Selection widget
221   myGeomSelWdg = new StdMeshersGUI_ObjectReferenceParamWdg( aFilter, mySmpWidget, /*multiSel=*/false,/*stretch=*/false);
222   myGeomSelWdg->SetDefaultText(tr("Hexotic_SEL_SHAPE"), "QLineEdit { color: grey }");
223   mySmpWidget->gridLayout->addWidget(myGeomSelWdg, 0, 1);
224   
225   // Configuration of the table widget
226   QStringList headerLabels;
227   headerLabels << tr("Hexotic_ENTRY")<< tr("Hexotic_NAME")<< tr("Hexotic_SIZE");
228   mySmpWidget->tableWidget->setHorizontalHeaderLabels(headerLabels);
229   mySmpWidget->tableWidget->resizeColumnsToContents();
230   mySmpWidget->tableWidget->hideColumn( 0 );
231   mySmpWidget->label->setText(tr("LOCAL_SIZE"));
232   mySmpWidget->pushButton_1->setText(tr("Hexotic_ADD"));
233   mySmpWidget->pushButton_2->setText(tr("Hexotic_REMOVE"));
234   
235   // Setting a custom delegate for the size column
236   SizeMapsTableWidgetDelegate* delegate = new SizeMapsTableWidgetDelegate();
237   mySmpWidget->tableWidget->setItemDelegateForColumn(SIZE_COL, delegate);
238   
239   // Add the size maps widget to a layout
240   QHBoxLayout* aSmpLayout = new QHBoxLayout( aSmpGroup );
241   aSmpLayout->setMargin( 0 );
242   aSmpLayout->addWidget( mySmpWidget);
243   
244  
245 //  resizeEvent();
246   
247   aTabWidget->insertTab( STD_TAB, aStdGroup, tr( "SMESH_ARGUMENTS" ) );
248   aTabWidget->insertTab( SMP_TAB, aSmpGroup, tr( "LOCAL_SIZE" ) );
249   
250   myIs3D = true;
251   
252   // Size Maps
253   mySizeMapsToRemove.clear();
254   connect( mySmpWidget->pushButton_1,  SIGNAL( clicked() ),                              this,  SLOT( onAddLocalSize() ) );
255   connect( mySmpWidget->pushButton_2,  SIGNAL( clicked() ),                              this,  SLOT( onRemoveLocalSize() ) );
256   
257   return fr;
258 }
259
260 void HexoticPluginGUI_HypothesisCreator::onAddLocalSize()
261 {
262   int rowCount = mySmpWidget->tableWidget->rowCount();
263   int columnCount = mySmpWidget->tableWidget->columnCount();
264   
265   // Get the selected object properties
266   GEOM::GEOM_Object_var sizeMapObject = myGeomSelWdg->GetObject< GEOM::GEOM_Object >(0);
267   if (sizeMapObject->_is_nil())
268     return;
269   
270   std::string entry, shapeName;
271   entry = (std::string) sizeMapObject->GetStudyEntry();
272   shapeName = sizeMapObject->GetName();
273   
274   // Check if the object is already in the widget
275   QList<QTableWidgetItem *> listFound = mySmpWidget->tableWidget
276                                         ->findItems( QString(entry.c_str()), Qt::MatchExactly );
277   if ( !listFound.isEmpty() )
278     return;
279   
280   // Get the size value
281   double size = mySmpWidget->doubleSpinBox->value();
282   if (size == 0)
283   {
284     SUIT_MessageBox::critical( mySmpWidget, tr( "SMESH_ERROR" ), tr( "Hexotic_NULL_LOCAL_SIZE" ) );
285     return;
286   }
287   
288   // Set items for the inserted row
289   insertLocalSizeInWidget( entry, shapeName, size, rowCount );
290 }
291
292 void HexoticPluginGUI_HypothesisCreator::insertLocalSizeInWidget( std::string entry, 
293                                                                   std::string shapeName, 
294                                                                   double size, 
295                                                                   int row ) const
296 {
297   MESSAGE("HexoticPluginGUI_HypothesisCreator:insertLocalSizeInWidget")
298   int columnCount = mySmpWidget->tableWidget->columnCount();
299   
300   // Add a row at the end of the table
301   mySmpWidget->tableWidget->insertRow(row);
302   
303   QVariant value;
304   for (int col = 0; col<columnCount; col++)
305   {
306     QTableWidgetItem* item = new QTableWidgetItem();
307     switch ( col )
308     {
309       case ENTRY_COL:
310         item->setFlags( 0 );
311         value = QVariant( entry.c_str() );
312         item->setData(Qt::DisplayRole, value );
313         break;  
314       case NAME_COL:
315         item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
316         value = QVariant( shapeName.c_str() );
317         item->setData(Qt::DisplayRole, value );
318         break;
319       case SIZE_COL:
320         item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
321         value = QVariant( size );
322         item->setData(Qt::EditRole, value );
323         break;
324     }       
325     mySmpWidget->tableWidget->setItem(row,col,item);
326   }
327 }
328
329 void HexoticPluginGUI_HypothesisCreator::onRemoveLocalSize()
330 {
331   // Remove the selected rows in the table
332   QList<QTableWidgetSelectionRange> ranges = mySmpWidget->tableWidget->selectedRanges();
333   if ( ranges.isEmpty() ) // If none is selected remove the last one
334   {
335     int lastRow = mySmpWidget->tableWidget->rowCount() - 1;
336     std::string entry = mySmpWidget->tableWidget->item( lastRow, ENTRY_COL )->text().toStdString();
337     mySizeMapsToRemove.push_back(entry);
338     mySmpWidget->tableWidget->removeRow( lastRow ); 
339   }
340   else
341   {
342     QList<QTableWidgetSelectionRange>::iterator it;
343     for ( it = ranges.begin(); it != ranges.end(); ++it )
344     {
345       for ( int row = it->topRow(); row <= it->bottomRow(); row++ )
346       {
347         std::string entry = mySmpWidget->tableWidget->item( row, ENTRY_COL )->text().toStdString();
348         mySizeMapsToRemove.push_back(entry);
349         MESSAGE("ADDING entry : "<<entry<<"to the Size Maps to remove")
350       }
351       mySmpWidget->tableWidget->model()->removeRows(it->topRow(), it->rowCount());
352     }
353   }
354 }
355
356 //=================================================================================
357 // function : resizeEvent [REDEFINED]
358 // purpose  :
359 //=================================================================================
360 void HexoticPluginGUI_HypothesisCreator::resizeEvent(QResizeEvent */*event*/) {
361     QSize scaledSize = myStdWidget->imageSdMode.size();
362     scaledSize.scale(myStdWidget->sdModeLabel->size(), Qt::KeepAspectRatioByExpanding);
363     if (!myStdWidget->sdModeLabel->pixmap() || scaledSize != myStdWidget->sdModeLabel->pixmap()->size())
364       myStdWidget->sdModeLabel->setPixmap(myStdWidget->imageSdMode.scaled(myStdWidget->sdModeLabel->size(),
365       Qt::KeepAspectRatio,
366       Qt::SmoothTransformation));
367 }
368
369 void HexoticPluginGUI_HypothesisCreator::retrieveParams() const
370 {
371   HexoticHypothesisData data;
372   readParamsFromHypo( data );
373   printData(data);
374
375   if( myName )
376     myName->setText( data.myName );
377
378   myStdWidget->myMinSize->setCleared(data.myMinSize == 0);
379   if (data.myMinSize == 0)
380     myStdWidget->myMinSize->setText("");
381   else
382     myStdWidget->myMinSize->setValue( data.myMinSize );
383
384   myStdWidget->myMaxSize->setCleared(data.myMaxSize == 0);
385   if (data.myMaxSize == 0)
386     myStdWidget->myMaxSize->setText("");
387   else
388     myStdWidget->myMaxSize->setValue( data.myMaxSize );
389
390   myStdWidget->myHexesMinLevel->setCleared(data.myHexesMinLevel == 0);
391   if (data.myHexesMinLevel == 0)
392     myStdWidget->myHexesMinLevel->setText("");
393   else
394     myStdWidget->myHexesMinLevel->setValue( data.myHexesMinLevel );
395
396   myStdWidget->myHexesMaxLevel->setCleared(data.myHexesMaxLevel == 0);
397   if (data.myHexesMaxLevel == 0)
398     myStdWidget->myHexesMaxLevel->setText("");
399   else
400     myStdWidget->myHexesMaxLevel->setValue( data.myHexesMaxLevel );
401
402   myStdWidget->myHexoticIgnoreRidges->setChecked( data.myHexoticIgnoreRidges );
403   myStdWidget->myHexoticInvalidElements->setChecked( data.myHexoticInvalidElements );
404   
405   myStdWidget->myHexoticSharpAngleThreshold->setCleared(data.myHexoticSharpAngleThreshold == 0);
406   if (data.myHexoticSharpAngleThreshold == 0)
407     myStdWidget->myHexoticSharpAngleThreshold->setText("");
408   else
409     myStdWidget->myHexoticSharpAngleThreshold->setValue( data.myHexoticSharpAngleThreshold );
410
411   myStdWidget->myHexoticNbProc->setValue( data.myHexoticNbProc );
412   myStdWidget->myHexoticWorkingDir->setText( data.myHexoticWorkingDir );
413
414   myStdWidget->myHexoticVerbosity->setValue( data.myHexoticVerbosity );
415
416   myStdWidget->myHexoticMaxMemory->setValue( data.myHexoticMaxMemory );
417
418   myStdWidget->myHexoticSdMode->setCurrentIndex(data.myHexoticSdMode);
419   
420   HexoticPlugin_Hypothesis::THexoticSizeMaps::const_iterator it = data.mySizeMaps.begin();
421   for ( int row = 0; it != data.mySizeMaps.end(); it++, row++ )
422   {
423     std::string entry = it->first;
424     double size = it->second;
425     GEOM::GEOM_Object_var anObject = entryToObject( entry );
426     std::string shapeName = anObject->GetName();
427
428     MESSAGE(" Insert local size, entry : "<<entry<<", size : "<<size<<", at row : "<<row) 
429     insertLocalSizeInWidget( entry, shapeName, size , row );
430   }
431
432   std::cout << "myStdWidget->myMinSize->value(): " << myStdWidget->myMinSize->value() << std::endl;
433   std::cout << "myStdWidget->myMaxSize->value(): " << myStdWidget->myMaxSize->value() << std::endl;
434   std::cout << "myStdWidget->myHexesMinLevel->value(): " << myStdWidget->myHexesMinLevel->value() << std::endl;
435   std::cout << "myStdWidget->myHexesMaxLevel->value(): " << myStdWidget->myHexesMaxLevel->value() << std::endl;
436   std::cout << "myStdWidget->myHexoticSharpAngleThreshold->value(): " << myStdWidget->myHexoticSharpAngleThreshold->value() << std::endl;
437
438 }
439
440 void HexoticPluginGUI_HypothesisCreator::printData( HexoticHypothesisData& data) const
441 {
442   QString valStr;
443   valStr += tr("Hexotic_MIN_SIZE") + " = " + QString::number( data.myMinSize )   + "; ";
444   valStr += tr("Hexotic_MAX_SIZE") + " = " + QString::number( data.myMaxSize ) + "; ";
445   valStr += tr("Hexotic_HEXES_MIN_LEVEL") + " = " + QString::number( data.myHexesMinLevel )   + "; ";
446   valStr += tr("Hexotic_HEXES_MAX_LEVEL") + " = " + QString::number( data.myHexesMaxLevel ) + "; ";
447   valStr += tr("Hexotic_IGNORE_RIDGES")  + " = " + QString::number( data.myHexoticIgnoreRidges ) + "; ";
448   valStr += tr("Hexotic_INVALID_ELEMENTS")  + " = " + QString::number( data.myHexoticInvalidElements ) + "; ";
449   valStr += tr("Hexotic_SHARP_ANGLE_THRESHOLD") + " = " + QString::number( data.myHexoticSharpAngleThreshold ) + "; ";
450   valStr += tr("Hexotic_NB_PROC") + " = " + QString::number( data.myHexoticNbProc ) + "; ";
451   valStr += tr("Hexotic_WORKING_DIR") + " = " + data.myHexoticWorkingDir + "; ";
452   valStr += tr("Hexotic_VERBOSITY") + " = " + QString::number( data.myHexoticVerbosity ) + "; ";
453   valStr += tr("Hexotic_MAX_MEMORY") + " = " + QString::number( data.myHexoticMaxMemory ) + "; ";
454   valStr += tr("Hexotic_SD_MODE") + " = " + QString::number( data.myHexoticSdMode ) + "; ";
455
456   std::cout << "Data: " << valStr.toStdString() << std::endl;
457 }
458
459 QString HexoticPluginGUI_HypothesisCreator::storeParams() const
460 {
461   HexoticHypothesisData data;
462   readParamsFromWidgets( data );
463   storeParamsToHypo( data );
464
465   QString valStr;
466   valStr += tr("Hexotic_MIN_SIZE") + " = " + QString::number( data.myMinSize )   + "; ";
467   valStr += tr("Hexotic_MAX_SIZE") + " = " + QString::number( data.myMaxSize ) + "; ";
468   valStr += tr("Hexotic_HEXES_MIN_LEVEL") + " = " + QString::number( data.myHexesMinLevel )   + "; ";
469   valStr += tr("Hexotic_HEXES_MAX_LEVEL") + " = " + QString::number( data.myHexesMaxLevel ) + "; ";
470   valStr += tr("Hexotic_IGNORE_RIDGES")  + " = " + QString::number( data.myHexoticIgnoreRidges ) + "; ";
471   valStr += tr("Hexotic_INVALID_ELEMENTS")  + " = " + QString::number( data.myHexoticInvalidElements ) + "; ";
472   valStr += tr("Hexotic_SHARP_ANGLE_THRESHOLD") + " = " + QString::number( data.myHexoticSharpAngleThreshold ) + "; ";
473   valStr += tr("Hexotic_NB_PROC") + " = " + QString::number( data.myHexoticNbProc ) + "; ";
474   valStr += tr("Hexotic_WORKING_DIR") + " = " + data.myHexoticWorkingDir + "; ";
475   valStr += tr("Hexotic_VERBOSITY") + " = " + QString::number( data.myHexoticVerbosity) + "; ";
476   valStr += tr("Hexotic_MAX_MEMORY") + " = " + QString::number( data.myHexoticMaxMemory ) + "; ";
477   valStr += tr("Hexotic_SD_MODE") + " = " + QString::number( data.myHexoticSdMode) + "; ";
478
479 //  std::cout << "Data: " << valStr.toStdString() << std::endl;
480
481   return valStr;
482 }
483
484 bool HexoticPluginGUI_HypothesisCreator::readParamsFromHypo( HexoticHypothesisData& h_data ) const
485 {
486   HexoticPlugin::HexoticPlugin_Hypothesis_var h =
487     HexoticPlugin::HexoticPlugin_Hypothesis::_narrow( initParamsHypothesis() );
488
489   HypothesisData* data = SMESH::GetHypothesisData( hypType() );
490   h_data.myName = isCreation() && data ? data->Label : "";
491   h_data.myMinSize = h->GetMinSize();
492   h_data.myMaxSize = h->GetMaxSize();
493   h_data.myHexesMinLevel = h->GetHexesMinLevel();
494   h_data.myHexesMaxLevel = h->GetHexesMaxLevel();
495   h_data.myHexoticIgnoreRidges = h->GetHexoticIgnoreRidges();
496   h_data.myHexoticInvalidElements = h->GetHexoticInvalidElements();
497   h_data.myHexoticSharpAngleThreshold = h->GetHexoticSharpAngleThreshold();
498   h_data.myHexoticNbProc = h->GetHexoticNbProc();
499   h_data.myHexoticWorkingDir = h->GetHexoticWorkingDirectory();
500   h_data.myHexoticVerbosity = h->GetHexoticVerbosity();
501   h_data.myHexoticMaxMemory = h->GetHexoticMaxMemory();
502   h_data.myHexoticSdMode = h->GetHexoticSdMode()-1;
503   
504   // Size maps
505   HexoticPlugin::HexoticPluginSizeMapsList_var sizeMaps = h->GetSizeMaps();
506   for ( int i = 0 ; i < sizeMaps->length() ; i++) 
507   {
508     HexoticPlugin::HexoticPluginSizeMap aSizeMap = sizeMaps[i];
509     std::string entry = CORBA::string_dup(aSizeMap.entry.in());
510     double size = aSizeMap.size;
511     h_data.mySizeMaps[ entry ] = size;
512     MESSAGE("READING Size map : entry "<<entry<<" size : "<<size)
513   }
514   
515   return true;
516 }
517
518 bool HexoticPluginGUI_HypothesisCreator::storeParamsToHypo( const HexoticHypothesisData& h_data ) const
519 {
520   HexoticPlugin::HexoticPlugin_Hypothesis_var h =
521     HexoticPlugin::HexoticPlugin_Hypothesis::_narrow( hypothesis() );
522
523   bool ok = true;
524
525   try
526   {
527     if( isCreation() )
528       SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
529
530     h->SetMinSize( h_data.myMinSize );
531     h->SetMaxSize( h_data.myMaxSize );
532     h->SetHexesMinLevel( h_data.myHexesMinLevel );
533     h->SetHexesMaxLevel( h_data.myHexesMaxLevel );
534     h->SetHexoticIgnoreRidges( h_data.myHexoticIgnoreRidges );
535     h->SetHexoticInvalidElements( h_data.myHexoticInvalidElements );
536     h->SetHexoticSharpAngleThreshold( h_data.myHexoticSharpAngleThreshold );
537     h->SetHexoticNbProc( h_data.myHexoticNbProc );
538     h->SetHexoticWorkingDirectory( h_data.myHexoticWorkingDir.toLatin1().constData() );
539     h->SetHexoticVerbosity( h_data.myHexoticVerbosity );
540     h->SetHexoticMaxMemory( h_data.myHexoticMaxMemory );
541     h->SetHexoticSdMode( h_data.myHexoticSdMode+1 );
542     
543     HexoticPlugin_Hypothesis::THexoticSizeMaps::const_iterator it;
544     
545     for ( it =  h_data.mySizeMaps.begin(); it !=  h_data.mySizeMaps.end(); it++ )
546     {
547       h->SetSizeMapEntry( it->first.c_str(), it->second );
548       MESSAGE("STORING Size map : entry "<<it->first.c_str()<<" size : "<<it->second)
549     }
550     std::vector< std::string >::const_iterator entry_it;
551     for ( entry_it = mySizeMapsToRemove.begin(); entry_it!= mySizeMapsToRemove.end(); entry_it++ )
552     {
553       h->UnsetSizeMapEntry(entry_it->c_str());
554     }
555   }
556   catch(const SALOME::SALOME_Exception& ex)
557   {
558     SalomeApp_Tools::QtCatchCorbaException(ex);
559     ok = false;
560   }
561   return ok;
562 }
563
564 bool HexoticPluginGUI_HypothesisCreator::readParamsFromWidgets( HexoticHypothesisData& h_data ) const
565 {
566   h_data.myName    = myName ? myName->text() : "";
567
568   h_data.myHexoticIgnoreRidges = myStdWidget->myHexoticIgnoreRidges->isChecked();
569   h_data.myHexoticInvalidElements = myStdWidget->myHexoticInvalidElements->isChecked();
570
571   h_data.myHexoticNbProc = myStdWidget->myHexoticNbProc->value();
572   h_data.myHexoticWorkingDir = myStdWidget->myHexoticWorkingDir->text();
573   h_data.myHexoticVerbosity = myStdWidget->myHexoticVerbosity->value();
574   h_data.myHexoticMaxMemory = myStdWidget->myHexoticMaxMemory->value();
575   h_data.myHexoticSdMode = myStdWidget->myHexoticSdMode->currentIndex();
576
577   h_data.myMinSize = myStdWidget->myMinSize->text().isEmpty() ? 0.0 : myStdWidget->myMinSize->value();
578   h_data.myMaxSize = myStdWidget->myMaxSize->text().isEmpty() ? 0.0 : myStdWidget->myMaxSize->value();
579   h_data.myHexesMinLevel = myStdWidget->myHexesMinLevel->text().isEmpty() ? 0 : myStdWidget->myHexesMinLevel->value();
580   h_data.myHexesMaxLevel = myStdWidget->myHexesMaxLevel->text().isEmpty() ? 0 : myStdWidget->myHexesMaxLevel->value();
581   h_data.myHexoticSharpAngleThreshold = myStdWidget->myHexoticSharpAngleThreshold->text().isEmpty() ? 0 : myStdWidget->myHexoticSharpAngleThreshold->value();
582
583   // Size maps reading
584   bool ok = readSizeMapsFromWidgets( h_data );
585   if ( !ok )
586     return false;
587   
588   printData(h_data);
589
590   return true;
591 }
592
593 bool HexoticPluginGUI_HypothesisCreator::readSizeMapsFromWidgets( HexoticHypothesisData& h_data ) const
594 {
595   int rowCount = mySmpWidget->tableWidget->rowCount();
596   for ( int row = 0; row <  rowCount; row++ )
597   {
598     std::string entry     = mySmpWidget->tableWidget->item( row, ENTRY_COL )->text().toStdString();
599     QVariant size_variant = mySmpWidget->tableWidget->item( row, SIZE_COL )->data(Qt::DisplayRole);
600     
601     // Convert the size to double
602     bool ok = false;
603     double size = size_variant.toDouble(&ok);
604     if (!ok)
605       return false;
606     
607     // Set the size maps
608     h_data.mySizeMaps[ entry ] = size;
609     MESSAGE("READING Size map from WIDGET: entry "<<entry<<" size : "<<size)
610   }
611   return true;
612 }
613
614 GEOM::GEOM_Object_var HexoticPluginGUI_HypothesisCreator::entryToObject( std::string entry) const
615 {
616   SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
617   SALOMEDS::Study_var myStudy = smeshGen_i->GetCurrentStudy();
618   GEOM::GEOM_Object_var aGeomObj;
619   SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.c_str() );
620   if (!aSObj->_is_nil()) {
621     CORBA::Object_var obj = aSObj->GetObject();
622     aGeomObj = GEOM::GEOM_Object::_narrow(obj);
623     aSObj->UnRegister();
624   }
625   return aGeomObj;
626 }
627
628 QString HexoticPluginGUI_HypothesisCreator::caption() const
629 {
630   return myIs3D ? tr( "Hexotic_3D_TITLE" ) : tr( "Hexotic_3D_TITLE" ); // ??? 3D/2D ???
631 }
632
633 QPixmap HexoticPluginGUI_HypothesisCreator::icon() const
634 {
635   QString hypIconName = myIs3D ? tr( "ICON_DLG_Hexotic_PARAMETERS" ) : tr( "ICON_DLG_Hexotic_PARAMETERS" );
636   return SUIT_Session::session()->resourceMgr()->loadPixmap( "HexoticPLUGIN", hypIconName );
637 }
638
639 QString HexoticPluginGUI_HypothesisCreator::type() const
640 {
641   return myIs3D ? tr( "Hexotic_3D_HYPOTHESIS" ) : tr( "Hexotic_3D_HYPOTHESIS" ); // ??? 3D/2D ???
642 }
643
644 QString HexoticPluginGUI_HypothesisCreator::helpPage() const
645 {
646   return "hexotic_hypo_page.html";
647 }