]> SALOME platform Git repositories - plugins/hybridplugin.git/blob - src/GUI/HYBRIDPluginGUI_HypothesisCreator.cxx
Salome HOME
Fix french translation for tetrahedra.
[plugins/hybridplugin.git] / src / GUI / HYBRIDPluginGUI_HypothesisCreator.cxx
1 // Copyright (C) 2007-2016  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   : HYBRIDPluginGUI_HypothesisCreator.cxx
22 // Author : Christian VAN WAMBEKE (CEA)
23 // ---
24 //
25 #include "HYBRIDPluginGUI_HypothesisCreator.h"
26 #include "HYBRIDPluginGUI_Enums.h"
27 #include "HYBRIDPluginGUI_Dlg.h"
28
29 #include <GeometryGUI.h>
30
31 #include <SMESHGUI_HypothesesUtils.h>
32 #include <SMESHGUI_SpinBox.h>
33 #include <SMESHGUI_Utils.h>
34 #include <SMESH_NumberFilter.hxx>
35 #include <SMESH_TypeFilter.hxx>
36 #include <StdMeshersGUI_ObjectReferenceParamWdg.h>
37 #include <StdMeshersGUI_SubShapeSelectorWdg.h>
38
39 #include <LightApp_SelectionMgr.h>
40 #include <SUIT_Session.h>
41 #include <SUIT_MessageBox.h>
42 #include <SUIT_ResourceMgr.h>
43 #include <SUIT_FileDlg.h>
44 #include <SalomeApp_Tools.h>
45 #include <SalomeApp_TypeFilter.h>
46
47 #include <TopoDS_Iterator.hxx>
48
49 #include <QComboBox>
50 #include <QPalette>
51 #include <QLabel>
52 #include <QFrame>
53 #include <QVBoxLayout>
54 #include <QGridLayout>
55 #include <QLineEdit>
56 #include <QCheckBox>
57 #include <QTabWidget>
58 #include <QSpinBox>
59 #include <QPushButton>
60 #include <QFileInfo>
61 #include <QGroupBox>
62
63 #include <QTableWidget>
64 #include <QTableWidgetItem>
65 #include <QHeaderView>
66
67 #include <stdexcept>
68 #include <utilities.h>
69
70 #include <boost/algorithm/string.hpp>
71
72 // namespace {
73
74 // #ifdef WIN32
75 // #include <windows.h>
76 // #else
77 // #include <sys/sysinfo.h>
78 // #endif
79
80 //   int maxAvailableMemory()
81 //   {
82 // #ifdef WIN32
83 //     // See http://msdn.microsoft.com/en-us/library/aa366589.aspx
84 //     MEMORYSTATUSEX statex;
85 //     statex.dwLength = sizeof (statex);
86 //     int err = GlobalMemoryStatusEx (&statex);
87 //     if (err != 0) {
88 //       int totMB = 
89 //         statex.ullTotalPhys / 1024 / 1024 +
90 //         statex.ullTotalPageFile / 1024 / 1024 +
91 //         statex.ullTotalVirtual / 1024 / 1024;
92 //       return (int) ( 0.7 * totMB );
93 //     }
94 // #else
95 //     struct sysinfo si;
96 //     int err = sysinfo( &si );
97 //     if ( err == 0 ) {
98 //       int totMB =
99 //         si.totalram * si.mem_unit / 1024 / 1024 +
100 //         si.totalswap * si.mem_unit / 1024 / 1024 ;
101 //       return (int) ( 0.7 * totMB );
102 //     }
103 // #endif
104 //     return 0;
105 //   }
106 // }
107
108 //
109 // BEGIN EnforcedVertexTableWidgetDelegate
110 //
111
112 EnforcedVertexTableWidgetDelegate::EnforcedVertexTableWidgetDelegate(QObject *parent)
113     : QItemDelegate(parent)
114 {
115 }
116
117 QWidget *EnforcedVertexTableWidgetDelegate::createEditor(QWidget *parent,
118                                                   const QStyleOptionViewItem & option ,
119                                                   const QModelIndex & index ) const
120 {
121   QModelIndex father = index.parent();
122   QString entry = father.child(index.row(), ENF_VER_ENTRY_COLUMN).data().toString();
123   
124   if (index.column() == ENF_VER_X_COLUMN ||
125       index.column() == ENF_VER_Y_COLUMN ||
126       index.column() == ENF_VER_Z_COLUMN ||
127       index.column() == ENF_VER_SIZE_COLUMN) {
128     SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent);
129     if (index.column() == ENF_VER_SIZE_COLUMN)
130       editor->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
131     else
132       editor->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
133     editor->setReadOnly(!entry.isEmpty());
134     editor->setDisabled(!entry.isEmpty());
135     return editor;
136   }
137 //   else if (index.column() == ENF_VER_COMPOUND_COLUMN) {
138 //     QCheckBox *editor = new QCheckBox(parent);
139 //     editor->setDisabled(!entry.isEmpty());
140 //     return editor;
141 //   }
142   else if (index.column() == ENF_VER_GROUP_COLUMN ||
143            index.column() == ENF_VER_NAME_COLUMN) {
144 //   else {
145     QLineEdit *editor = new QLineEdit(parent);
146     if (index.column() != ENF_VER_GROUP_COLUMN) {
147       editor->setReadOnly(!entry.isEmpty());
148       editor->setDisabled(!entry.isEmpty());
149     }
150     return editor;
151   }
152   return QItemDelegate::createEditor(parent, option, index);
153 }
154
155 void EnforcedVertexTableWidgetDelegate::setEditorData(QWidget *editor,
156                                                const QModelIndex &index) const
157 {
158   if (index.column() == ENF_VER_X_COLUMN ||
159       index.column() == ENF_VER_Y_COLUMN ||
160       index.column() == ENF_VER_Z_COLUMN ||
161       index.column() == ENF_VER_SIZE_COLUMN)
162   {
163     SMESHGUI_SpinBox *lineEdit = qobject_cast<SMESHGUI_SpinBox*>(editor);
164     lineEdit->SetValue(index.data().toDouble());
165   } 
166   else if (index.column() == ENF_VER_COMPOUND_COLUMN) {
167     QCheckBox *checkBox = qobject_cast<QCheckBox*>(editor);
168     checkBox->setChecked(index.data().toBool());
169   }
170   else {
171     QItemDelegate::setEditorData(editor, index);
172   }
173 }
174
175 void EnforcedVertexTableWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
176                                               const QModelIndex &index) const
177 {
178   QModelIndex parent = index.parent();
179   
180   QString entry = parent.child(index.row(), ENF_VER_ENTRY_COLUMN).data().toString();
181   bool isCompound = parent.child(index.row(), ENF_VER_COMPOUND_COLUMN).data(Qt::CheckStateRole).toBool();
182   
183   if (index.column() == ENF_VER_X_COLUMN || 
184       index.column() == ENF_VER_Y_COLUMN || 
185       index.column() == ENF_VER_Z_COLUMN) {
186     SMESHGUI_SpinBox *lineEdit = qobject_cast<SMESHGUI_SpinBox*>(editor);
187     if (!isCompound && !vertexExists(model, index, lineEdit->GetString()))
188       model->setData(index, lineEdit->GetValue(), Qt::EditRole);
189   } 
190   else if (index.column() == ENF_VER_SIZE_COLUMN)
191   {
192     SMESHGUI_SpinBox *lineEdit = qobject_cast<SMESHGUI_SpinBox*>(editor);
193     const double newsize =  lineEdit->GetValue();
194     if (newsize > 0)
195       model->setData(index, newsize, Qt::EditRole);
196   } 
197   else if (index.column() == ENF_VER_NAME_COLUMN) {
198     QLineEdit *lineEdit = qobject_cast<QLineEdit*>(editor);
199     QString value = lineEdit->text();
200     if (entry.isEmpty() && !vertexExists(model, index, value))
201       model->setData(index, value, Qt::EditRole);
202   } 
203   else if (index.column() == ENF_VER_ENTRY_COLUMN) {
204     QLineEdit *lineEdit = qobject_cast<QLineEdit*>(editor);
205     QString value = lineEdit->text();
206     if (! vertexExists(model, index, value))
207       model->setData(index, value, Qt::EditRole);
208   }
209   else if (index.column() == ENF_VER_COMPOUND_COLUMN) {
210     QCheckBox *checkBox = qobject_cast<QCheckBox*>(editor);
211     model->setData(index, checkBox->isChecked(), Qt::CheckStateRole);
212   }
213   else {
214     QItemDelegate::setModelData(editor, model, index);
215   }
216 }
217
218 void EnforcedVertexTableWidgetDelegate::updateEditorGeometry(QWidget *editor,
219     const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
220 {
221     editor->setGeometry(option.rect);
222 }
223
224 bool EnforcedVertexTableWidgetDelegate::vertexExists(QAbstractItemModel *model,
225                                               const QModelIndex &index, 
226                                               QString value) const
227 {
228   bool exists = false;
229   QModelIndex parent = index.parent();
230   int row = index.row();
231   int col = index.column();
232
233   if (parent.isValid() && !value.isEmpty()) {
234     if (col == ENF_VER_X_COLUMN || col == ENF_VER_Y_COLUMN || col == ENF_VER_Z_COLUMN) {
235       double x, y, z;
236       if (col == ENF_VER_X_COLUMN) {
237         x = value.toDouble();
238         y = parent.child(row, ENF_VER_Y_COLUMN).data().toDouble();
239         z = parent.child(row, ENF_VER_Z_COLUMN).data().toDouble();
240       }
241       if (col == ENF_VER_Y_COLUMN) {
242         y = value.toDouble();
243         x = parent.child(row, ENF_VER_X_COLUMN).data().toDouble();
244         z = parent.child(row, ENF_VER_Z_COLUMN).data().toDouble();
245       }
246       if (col == ENF_VER_Z_COLUMN) {
247         z = value.toDouble();
248         x = parent.child(row, ENF_VER_X_COLUMN).data().toDouble();
249         y = parent.child(row, ENF_VER_Y_COLUMN).data().toDouble();
250       }
251       int nbChildren = model->rowCount(parent);
252       for (int i = 0 ; i < nbChildren ; i++) {
253         if (i != row) {
254           double childX = parent.child(i, ENF_VER_X_COLUMN).data().toDouble();
255           double childY = parent.child(i, ENF_VER_Y_COLUMN).data().toDouble();
256           double childZ = parent.child(i, ENF_VER_Z_COLUMN).data().toDouble();
257           if ((childX == x) && (childY == y) && (childZ == z)) {
258             exists = true;
259             break;
260           }
261         }
262       }
263     }
264     else if (col == ENF_VER_NAME_COLUMN) {
265       QString name = parent.child(row, ENF_VER_NAME_COLUMN).data().toString();
266       if (name == value)
267         exists = true;
268     }
269   }
270
271   return exists;
272 }
273
274 //
275 // END EnforcedVertexTableWidgetDelegate
276 //
277
278 //
279 // BEGIN EnforcedMeshTableWidgetDelegate
280 //
281
282 EnforcedMeshTableWidgetDelegate::EnforcedMeshTableWidgetDelegate(QObject *parent)
283     : QItemDelegate(parent)
284 {
285 }
286
287 QWidget *EnforcedMeshTableWidgetDelegate::createEditor(QWidget *parent,
288                                                   const QStyleOptionViewItem & option ,
289                                                   const QModelIndex & index ) const
290 {
291   return QItemDelegate::createEditor(parent, option, index);
292 }
293
294 void EnforcedMeshTableWidgetDelegate::setEditorData(QWidget *editor,
295                                                const QModelIndex &index) const
296 {
297         QItemDelegate::setEditorData(editor, index);
298 }
299
300 void EnforcedMeshTableWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
301                                               const QModelIndex &index) const
302 {  
303   QItemDelegate::setModelData(editor, model, index);
304
305 }
306
307 void EnforcedMeshTableWidgetDelegate::updateEditorGeometry(QWidget *editor,
308     const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
309 {
310     editor->setGeometry(option.rect);
311 }
312
313 // bool EnforcedMeshTableWidgetDelegate::enfMeshExists(QAbstractItemModel *model,
314 //                                               const QModelIndex &index, 
315 //                                               QString value) const
316 // {
317 //   bool exists = false;
318 //   QModelIndex parent = index.parent();
319 //   int row = index.row();
320 //   int col = index.column();
321 //   return exists;
322 // }
323
324 //
325 // END EnforcedMeshTableWidgetDelegate
326 //
327
328
329 HYBRIDPluginGUI_HypothesisCreator::HYBRIDPluginGUI_HypothesisCreator( const QString& theHypType )
330 : SMESHGUI_GenericHypothesisCreator( theHypType )
331 {
332   GeomToolSelected = NULL;
333   GeomToolSelected = getGeomSelectionTool();
334   
335   iconVertex  = QPixmap(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_OBJBROWSER_VERTEX")));
336   iconCompound  = QPixmap(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_OBJBROWSER_COMPOUND")));
337 //   mySelectionMgr = SMESH::GetSelectionMgr(SMESHGUI::GetSMESHGUI());
338   myEnfMeshConstraintLabels << tr( "HYBRID_ENF_MESH_CONSTRAINT_NODE" ) << tr( "HYBRID_ENF_MESH_CONSTRAINT_EDGE" ) << tr("HYBRID_ENF_MESH_CONSTRAINT_FACE");
339 }
340
341 HYBRIDPluginGUI_HypothesisCreator::~HYBRIDPluginGUI_HypothesisCreator()
342 {
343   HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
344   that->getGeomSelectionTool()->selectionMgr()->clearFilters();
345   myEnfMeshWdg->deactivateSelection();
346 }
347
348 /**
349  * \brief {Get or create the geom selection tool for active study}
350  * */
351 GeomSelectionTools* HYBRIDPluginGUI_HypothesisCreator::getGeomSelectionTool()
352 {
353   HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
354   _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
355   if (that->GeomToolSelected == NULL || that->GeomToolSelected->getMyStudy() != aStudy) {
356     that->GeomToolSelected = new GeomSelectionTools(aStudy);
357   }
358   return that->GeomToolSelected;
359 }
360
361 GEOM::GEOM_Gen_var HYBRIDPluginGUI_HypothesisCreator::getGeomEngine()
362 {
363   return GeometryGUI::GetGeomGen();
364 }
365
366 QFrame* HYBRIDPluginGUI_HypothesisCreator::buildFrame()
367 {
368   QFrame* fr = new QFrame( 0 );
369   QVBoxLayout* lay = new QVBoxLayout( fr );
370   lay->setMargin( 5 );
371   lay->setSpacing( 0 );
372
373   // tab
374   QTabWidget* tab = new QTabWidget( fr );
375   tab->setTabShape( QTabWidget::Rounded );
376   tab->setTabPosition( QTabWidget::North );
377   lay->addWidget( tab );
378
379   // basic parameters
380   myStdGroup = new QWidget();
381   QGridLayout* aStdLayout = new QGridLayout( myStdGroup );
382   aStdLayout->setSpacing( 6 );
383   aStdLayout->setMargin( 11 );
384
385   int row = 0;
386   myName = 0;
387   if( isCreation() )
388   {
389     aStdLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), myStdGroup ), row, 0, 1, 1 );
390     myName = new QLineEdit( myStdGroup );
391     aStdLayout->addWidget( myName, row++, 1, 1, 1 );
392   }
393
394   myToMeshHolesCheck = new QCheckBox( tr( "HYBRID_TO_MESH_HOLES" ), myStdGroup );
395   //aStdLayout->addWidget( myToMeshHolesCheck, row, 0, 1, 1 ); #stay, not view, may be used tomorrow...
396   myToMeshHolesCheck->hide();
397   myToMakeGroupsOfDomains = new QCheckBox( tr( "HYBRID_TO_MAKE_DOMAIN_GROUPS" ), myStdGroup );
398   //aStdLayout->addWidget( myToMakeGroupsOfDomains, row++, 1, 1, 1 ); #stay, not view, may be used tomorrow...
399   myToMakeGroupsOfDomains->hide();
400   //aStdLayout->addWidget( new QLabel( tr( "HYBRID_OPTIMIZATIOL_LEVEL" ), myStdGroup ), row, 0, 1, 1 );
401   myOptimizationLevelCombo = new QComboBox( myStdGroup );
402   //aStdLayout->addWidget( myOptimizationLevelCombo, row++, 1, 1, 1 ); #stay, not view, may be used tomorrow...
403   myOptimizationLevelCombo->hide();
404
405   QStringList types;
406   types << tr( "LEVEL_NONE" ) << tr( "LEVEL_LIGHT" ) << tr( "LEVEL_MEDIUM" ) << tr( "LEVEL_STANDARDPLUS" ) << tr( "LEVEL_STRONG" );
407   myOptimizationLevelCombo->addItems( types );
408
409   QLabel* aLabel = new QLabel( tr( "HYBRID_BOUNDARY_LAYERS_GROWTH" ), myStdGroup );
410   aLabel->setToolTip(tr( "HYBRID_BOUNDARY_LAYERS_HELP" ));
411   aStdLayout->addWidget( aLabel, row, 0, 1, 1 );
412   myBoundaryLayersGrowthCombo = new QComboBox( myStdGroup );
413   myBoundaryLayersGrowthCombo->setToolTip(tr( "HYBRID_BOUNDARY_LAYERS_HELP" ));
414   
415   aStdLayout->addWidget( myBoundaryLayersGrowthCombo, row++, 1, 1, 1 );
416   
417   QStringList typesBoundaryLayersGrowth;
418   typesBoundaryLayersGrowth << tr( "HYBRID_LAYER_GROWTH_DOWNWARD" ) << tr( "HYBRID_LAYER_GROWTH_UPWARD" );
419   myBoundaryLayersGrowthCombo->addItems( typesBoundaryLayersGrowth );
420   
421   aStdLayout->addWidget( new QLabel( tr( "HYBRID_HeightFirstLayer" ), myStdGroup ), row, 0, 1, 1 );
422   myHeightFirstLayerSpin = new SMESHGUI_SpinBox( myStdGroup );
423   myHeightFirstLayerSpin->RangeStepAndValidator(0., 100., .1, "HeightFirstLayer");
424   aStdLayout->addWidget( myHeightFirstLayerSpin, row++, 1, 1, 1 );
425
426   aStdLayout->addWidget( new QLabel( tr( "HYBRID_NbOfBoundaryLayers" ), myStdGroup ), row, 0, 1, 1 );
427   myNbOfBoundaryLayersSpin = new QSpinBox( myStdGroup );
428   aStdLayout->addWidget( myNbOfBoundaryLayersSpin, row++, 1, 1, 1 );
429
430   aStdLayout->addWidget( new QLabel( tr( "HYBRID_BoundaryLayersProgression" ), myStdGroup ), row, 0, 1, 1 );
431   myBoundaryLayersProgressionSpin = new SMESHGUI_SpinBox( myStdGroup );
432   myBoundaryLayersProgressionSpin->RangeStepAndValidator(0., 10., .1, "BoundaryLayersProgression");
433   aStdLayout->addWidget( myBoundaryLayersProgressionSpin, row++, 1, 1, 1 );
434
435   aStdLayout->addWidget( new QLabel( tr( "COLLISION_MODE" ), myStdGroup ), row, 0, 1, 1 );
436   myCollisionModeCombo = new QComboBox( myStdGroup );
437   aStdLayout->addWidget( myCollisionModeCombo, row++, 1, 1, 1 );
438   
439   QStringList typescoll;
440   typescoll << tr( "COLLISION_DECREASE" ) << tr( "COLLISION_STOP" );
441   myCollisionModeCombo->addItems( typescoll );
442
443   aStdLayout->addWidget( new QLabel( tr( "HYBRID_GENERATION_ELEMENT" ), myStdGroup ), row, 0, 1, 1 );
444   myElementGenerationCombo = new QComboBox( myStdGroup );
445   aStdLayout->addWidget( myElementGenerationCombo, row++, 1, 1, 1 );
446   
447   QStringList typesElementGeneration;
448   typesElementGeneration << tr( "HYBRID_GENERATION_TETRA_DOMINANT" ) << tr( "HYBRID_GENERATION_HEXA_DOMINANT" );
449   myElementGenerationCombo->addItems( typesElementGeneration );
450   
451   myAddMultinormalsCheck = new QCheckBox( tr( "HYBRID_ADD_MULTINORMALS" ), myStdGroup );
452   aStdLayout->addWidget( myAddMultinormalsCheck, row++, 0, 1, 1 );
453   
454   aStdLayout->addWidget( new QLabel( tr( "HYBRID_MULTINORMAL_ANGLE" ), myStdGroup ), row, 0, 1, 1 );
455   myMultinormalsAngleSpin = new SMESHGUI_SpinBox( myStdGroup );
456   myMultinormalsAngleSpin->RangeStepAndValidator(0., 90., 2., "threshold");
457   aStdLayout->addWidget( myMultinormalsAngleSpin, row++, 1, 1, 1 );
458
459   mySmoothNormalsCheck = new QCheckBox( tr( "HYBRID_SMOOTH_NORMALS" ), myStdGroup );
460   aStdLayout->addWidget( mySmoothNormalsCheck, row++, 0, 1, 1 );
461   aStdLayout->setRowStretch( row, 10 );
462
463   // advanced parameters
464   myAdvGroup = new QWidget();
465   QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup );
466   anAdvLayout->setSpacing( 6 );
467   anAdvLayout->setMargin( 11 );
468   myAdvWidget = new HYBRIDPluginGUI_AdvWidget(myAdvGroup);
469   anAdvLayout->addWidget( myAdvWidget);
470
471   myAdvWidget->maxMemoryCheck->setText(tr( "MAX_MEMORY_SIZE" ));
472   myAdvWidget->initialMemoryCheck->setText(tr( "INIT_MEMORY_SIZE" ));
473
474   myAdvWidget->maxMemorySpin->RangeStepAndValidator(20.0, 1e6, 10.0);
475   myAdvWidget->maxMemorySpin->setValue( 128.0 );
476
477   myAdvWidget->initialMemorySpin->RangeStepAndValidator(0.0, 1e6, 10.0);
478   myAdvWidget->initialMemorySpin->setValue( 100.0 );
479
480   myAdvWidget->initialMemoryLabel            ->setText (tr( "MEGABYTE" ));
481   myAdvWidget->maxMemoryLabel                ->setText (tr( "MEGABYTE" ));
482     
483   myAdvWidget->workingDirectoryPushButton    ->setText (tr( "SELECT_DIR" ));
484   myAdvWidget->keepWorkingFilesCheck         ->setText (tr( "KEEP_WORKING_FILES" ));
485   myAdvWidget->verboseLevelLabel             ->setText (tr( "VERBOSE_LEVEL" ));
486   myAdvWidget->removeLogOnSuccessCheck       ->setText (tr( "REMOVE_LOG_ON_SUCCESS" ));
487   myAdvWidget->logInFileCheck                ->setText (tr( "LOG_IN_FILE" ));
488   
489   myAdvWidget->memoryGroupBox                ->setTitle(tr( "MEMORY_GROUP_TITLE" ));
490   myAdvWidget->logGroupBox                   ->setTitle(tr( "LOG_GROUP_TITLE" ));
491   myAdvWidget->advancedMeshingGroupBox       ->setTitle(tr( "ADVANCED_MESHING_GROUP_TITLE" ));
492   
493   myAdvWidget->memoryGroupBox->hide();
494
495   myAdvWidget->createNewNodesCheck->hide();
496   //myAdvWidget->createNewNodesLabel->hide();
497   myAdvWidget->removeInitialCentralPointCheck->hide();
498   myAdvWidget->boundaryRecoveryCheck->hide();
499   myAdvWidget->FEMCorrectionCheck->hide();
500   myAdvWidget->gradationLabel->hide();
501   myAdvWidget->gradationSpinBox->hide();
502
503   myAdvWidget->createNewNodesCheck           ->setText (tr( "TO_ADD_NODES" ));
504   myAdvWidget->removeInitialCentralPointCheck->setText (tr( "NO_INITIAL_CENTRAL_POINT" ));
505   myAdvWidget->boundaryRecoveryCheck         ->setText (tr( "RECOVERY_VERSION" ));
506   myAdvWidget->FEMCorrectionCheck            ->setText (tr( "FEM_CORRECTION" ));
507   myAdvWidget->gradationLabel                ->setText (tr( "HYBRID_GRADATION" ));
508   myAdvWidget->gradationSpinBox->RangeStepAndValidator(1.05, 5.0, 0.05, "length_precision");
509
510   // Enforced vertices parameters
511   myEnfGroup = new QWidget();
512   QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup);
513   myEnforcedTableWidget = new QTableWidget(myEnfGroup);
514   myEnforcedTableWidget ->setMinimumWidth(300);
515   myEnforcedTableWidget->setRowCount( 0 );
516   myEnforcedTableWidget->setColumnCount( ENF_VER_NB_COLUMNS );
517   myEnforcedTableWidget->setSortingEnabled(true);
518   QStringList enforcedHeaders;
519   enforcedHeaders << tr( "HYBRID_ENF_NAME_COLUMN" )
520                   << tr( "HYBRID_ENF_VER_X_COLUMN" )<< tr( "HYBRID_ENF_VER_Y_COLUMN" ) << tr( "HYBRID_ENF_VER_Z_COLUMN" )
521                   << tr( "HYBRID_ENF_SIZE_COLUMN" ) << tr("HYBRID_ENF_ENTRY_COLUMN") << tr("HYBRID_ENF_VER_COMPOUND_COLUMN") << tr( "HYBRID_ENF_GROUP_COLUMN" );
522
523   myEnforcedTableWidget->setHorizontalHeaderLabels(enforcedHeaders);
524   myEnforcedTableWidget->verticalHeader()->hide();
525   myEnforcedTableWidget->horizontalHeader()->setStretchLastSection(true);
526   myEnforcedTableWidget->setAlternatingRowColors(true);
527   myEnforcedTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
528   myEnforcedTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
529 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
530   myEnforcedTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
531 #else
532   myEnforcedTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
533 #endif
534   myEnforcedTableWidget->resizeColumnsToContents();
535   myEnforcedTableWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
536   myEnforcedTableWidget->hideColumn(ENF_VER_COMPOUND_COLUMN);
537   
538   myEnforcedTableWidget->setItemDelegate(new EnforcedVertexTableWidgetDelegate());
539   
540 // VERTEX SELECTION
541   TColStd_MapOfInteger shapeTypes;
542   shapeTypes.Add( TopAbs_VERTEX );
543   shapeTypes.Add( TopAbs_COMPOUND );
544
545   SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes);
546   myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true);
547   myEnfVertexWdg->SetDefaultText(tr("HYBRID_ENF_SELECT_VERTEX"), "QLineEdit { color: grey }");
548   
549   QLabel* myXCoordLabel = new QLabel( tr( "HYBRID_ENF_VER_X_LABEL" ), myEnfGroup );
550   myXCoord = new SMESHGUI_SpinBox(myEnfGroup);
551   myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
552   QLabel* myYCoordLabel = new QLabel( tr( "HYBRID_ENF_VER_Y_LABEL" ), myEnfGroup );
553   myYCoord = new SMESHGUI_SpinBox(myEnfGroup);
554   myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
555   QLabel* myZCoordLabel = new QLabel( tr( "HYBRID_ENF_VER_Z_LABEL" ), myEnfGroup );
556   myZCoord = new SMESHGUI_SpinBox(myEnfGroup);
557   myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
558   QLabel* mySizeLabel = new QLabel( tr( "HYBRID_ENF_SIZE_LABEL" ), myEnfGroup );
559   mySizeValue = new SMESHGUI_SpinBox(myEnfGroup);
560   mySizeValue->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
561
562   QLabel* myGroupNameLabel = new QLabel( tr( "HYBRID_ENF_GROUP_LABEL" ), myEnfGroup );
563   myGroupName = new QLineEdit(myEnfGroup);
564
565   addVertexButton = new QPushButton(tr("HYBRID_ENF_ADD"),myEnfGroup);
566   addVertexButton->setEnabled(false);
567   removeVertexButton = new QPushButton(tr("HYBRID_ENF_REMOVE"),myEnfGroup);
568 //   myGlobalGroupName = new QCheckBox(tr("HYBRID_ENF_VER_GROUPS"), myEnfGroup);
569 //   myGlobalGroupName->setChecked(false);
570   
571   // QGroupBox* GroupBox = new QGroupBox( myEnfGroup );
572   // QLabel* info = new QLabel( GroupBox );
573   // info->setText( tr( "HYBRID_ENF_VER_INFO" ) );
574   // info->setWordWrap( true );
575   // QVBoxLayout* GroupBoxVLayout = new QVBoxLayout( GroupBox );
576   // GroupBoxVLayout->setSpacing( 6 );
577   // GroupBoxVLayout->setMargin( 11 );
578   // GroupBoxVLayout->addWidget( info );
579   
580
581   //anEnfLayout->addWidget(GroupBox,                  ENF_VER_WARNING, 0, 1, 2 );
582   anEnfLayout->addWidget(myEnforcedTableWidget,     ENF_VER_VERTEX, 0, ENF_VER_NB_LINES, 1);
583   
584   QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup);
585   anEnfLayout2->addWidget(myEnfVertexWdg,           ENF_VER_VERTEX, 0, 1, 2);
586   anEnfLayout2->addWidget(myXCoordLabel,            ENF_VER_X_COORD, 0, 1, 1);
587   anEnfLayout2->addWidget(myXCoord,                 ENF_VER_X_COORD, 1, 1, 1);
588   anEnfLayout2->addWidget(myYCoordLabel,            ENF_VER_Y_COORD, 0, 1, 1);
589   anEnfLayout2->addWidget(myYCoord,                 ENF_VER_Y_COORD, 1, 1, 1);
590   anEnfLayout2->addWidget(myZCoordLabel,            ENF_VER_Z_COORD, 0, 1, 1);
591   anEnfLayout2->addWidget(myZCoord,                 ENF_VER_Z_COORD, 1, 1, 1);
592   anEnfLayout2->addWidget(mySizeLabel,              ENF_VER_SIZE, 0, 1, 1);
593   anEnfLayout2->addWidget(mySizeValue,              ENF_VER_SIZE, 1, 1, 1);
594   anEnfLayout2->addWidget(myGroupNameLabel,         ENF_VER_GROUP, 0, 1, 1);
595   anEnfLayout2->addWidget(myGroupName,              ENF_VER_GROUP, 1, 1, 1);
596   anEnfLayout2->addWidget(addVertexButton,          ENF_VER_BTN, 0, 1, 1);
597   anEnfLayout2->addWidget(removeVertexButton,       ENF_VER_BTN, 1, 1, 1);
598   anEnfLayout2->setRowStretch(ENF_VER_NB_LINES, 1);
599   
600   anEnfLayout->addLayout(anEnfLayout2,              ENF_VER_VERTEX, 1,ENF_VER_NB_LINES, 1);
601   anEnfLayout->setRowStretch(ENF_VER_VERTEX, 10);
602
603   // Enforced meshes parameters
604   myEnfMeshGroup = new QWidget();
605   myLayersOnAllWrapCheck = new QCheckBox( tr( "HYBRID_LAYERS_ON_ALL_WRAP" ), myEnfMeshGroup );
606   QGridLayout* anEnfMeshLayout = new QGridLayout(myEnfMeshGroup);
607   
608   myEnforcedMeshTableWidget = new QTableWidget(myEnfGroup);
609   myEnforcedMeshTableWidget->setRowCount( 0 );
610   myEnforcedMeshTableWidget->setColumnCount( ENF_MESH_NB_COLUMNS );
611   myEnforcedMeshTableWidget->setSortingEnabled(true);
612   myEnforcedMeshTableWidget->verticalHeader()->hide();
613   QStringList enforcedMeshHeaders;
614   enforcedMeshHeaders << tr( "HYBRID_ENF_NAME_COLUMN" ) 
615                       << tr( "HYBRID_ENF_ENTRY_COLUMN" ) 
616                       << tr( "HYBRID_ENF_MESH_CONSTRAINT_COLUMN" ) 
617                       << tr( "HYBRID_ENF_GROUP_COLUMN" );
618   myEnforcedMeshTableWidget->setHorizontalHeaderLabels(enforcedMeshHeaders);
619   myEnforcedMeshTableWidget->horizontalHeader()->setStretchLastSection(true);
620 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
621   myEnforcedMeshTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
622 #else
623   myEnforcedMeshTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
624 #endif
625   myEnforcedMeshTableWidget->setAlternatingRowColors(true);
626   myEnforcedMeshTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
627   myEnforcedMeshTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
628   myEnforcedMeshTableWidget->resizeColumnsToContents();
629   myEnforcedMeshTableWidget->hideColumn(ENF_MESH_ENTRY_COLUMN);
630   
631   myEnforcedMeshTableWidget->setItemDelegate(new EnforcedMeshTableWidgetDelegate());
632   
633 //   myEnfMesh = SMESH::SMESH_Mesh::_nil();
634 //   myEnfMeshArray = new SMESH::mesh_array();
635
636   myEnfMeshWdg = new StdMeshersGUI_ObjectReferenceParamWdg( SMESH::IDSOURCE, myEnfMeshGroup, /*multiSel=*/true);
637   myEnfMeshWdg->SetDefaultText(tr("HYBRID_ENF_SELECT_MESH"), "QLineEdit { color: grey }");
638   
639   myEnfMeshWdg->AvoidSimultaneousSelection(myEnfVertexWdg);
640   ////myEnfMeshWdg->hide(); //may be used later
641   
642   QLabel* myMeshConstraintLabel = new QLabel( tr( "HYBRID_ENF_MESH_CONSTRAINT_LABEL" ), myEnfMeshGroup );
643   myEnfMeshConstraint = new QComboBox(myEnfMeshGroup);
644   myEnfMeshConstraint->insertItems(0,myEnfMeshConstraintLabels);
645   myEnfMeshConstraint->setEditable(false);
646   myEnfMeshConstraint->setCurrentIndex(2); //EZ: use mesh group of faces for a layer
647   myMeshConstraintLabel->hide(); //may be used later
648   myEnfMeshConstraint->hide(); //may be used later
649
650   QLabel* myMeshGroupNameLabel = new QLabel( tr( "HYBRID_ENF_GROUP_LABEL" ), myEnfMeshGroup );
651   myMeshGroupName = new QLineEdit(myEnfMeshGroup);
652   myMeshGroupNameLabel->hide(); //may be used later
653   myMeshGroupName->hide(); //may be used later
654
655   addEnfMeshButton = new QPushButton(tr("HYBRID_ENF_ADD"),myEnfMeshGroup);
656   // addEnfMeshButton->setEnabled(false);
657   removeEnfMeshButton = new QPushButton(tr("HYBRID_ENF_REMOVE"),myEnfMeshGroup);
658     
659   // QGroupBox* GroupBox2 = new QGroupBox( myEnfMeshGroup );
660   // QLabel* info2 = new QLabel( GroupBox2 );
661   // info2->setText( tr( "HYBRID_ENF_MESH_INFO" ) );
662   // info2->setWordWrap( true );
663   // QVBoxLayout* GroupBox2VLayout = new QVBoxLayout( GroupBox2 );
664   // GroupBox2VLayout->setSpacing( 6 );
665   // GroupBox2VLayout->setMargin( 11 );
666   // GroupBox2VLayout->addWidget( info2 );
667   
668   // anEnfMeshLayout->addWidget( GroupBox2,                ENF_MESH_WARNING, 0, 1, 2 );
669   anEnfMeshLayout->addWidget(myLayersOnAllWrapCheck, ENF_MESH_MESH, 0, 1 , 1);
670   anEnfMeshLayout->addWidget(myEnforcedMeshTableWidget, ENF_MESH_MESH+1, 0, ENF_MESH_NB_LINES , 1);
671   
672   QGridLayout* anEnfMeshLayout2 = new QGridLayout(myEnfMeshGroup);
673   anEnfMeshLayout2->addWidget(myEnfMeshWdg,             ENF_MESH_MESH, 0, 1, 2);
674   //TODO remove or not be lateful to select layers...
675   //anEnfMeshLayout2->addWidget(myMeshConstraintLabel,    ENF_MESH_CONSTRAINT, 0, 1, 1);
676   //anEnfMeshLayout2->addWidget(myEnfMeshConstraint,      ENF_MESH_CONSTRAINT, 1, 1, 1);
677   //anEnfMeshLayout2->addWidget(myMeshGroupNameLabel,     ENF_MESH_GROUP, 0, 1, 1);
678   //anEnfMeshLayout2->addWidget(myMeshGroupName,          ENF_MESH_GROUP, 1, 1, 1);
679   anEnfMeshLayout2->addWidget(addEnfMeshButton,         ENF_MESH_BTN, 0, 1, 1);
680   anEnfMeshLayout2->addWidget(removeEnfMeshButton,      ENF_MESH_BTN, 1, 1, 1);
681   anEnfMeshLayout2->setRowStretch(ENF_MESH_NB_LINES, 1);
682   
683   anEnfMeshLayout->addLayout(anEnfMeshLayout2,          ENF_MESH_MESH+1, 1, ENF_MESH_NB_LINES, 1);
684   anEnfMeshLayout->setRowStretch(ENF_MESH_MESH, 10);
685
686
687   // selection of faces
688
689   QWidget* faceSelGroup = new QWidget( dlg() );
690   QGridLayout* faceSelLayout = new QGridLayout( faceSelGroup );
691
692   QLabel* facesLbl = new QLabel( tr("HYBRID_FACE_IDS"), faceSelGroup );
693   faceSelLayout->addWidget( facesLbl, 0, 0 );
694
695   myFaceSelector = new StdMeshersGUI_SubShapeSelectorWdg( faceSelGroup, TopAbs_FACE, true, true );
696   QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
697   QString aSubEntry  = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
698   myFaceSelector->SetGeomShapeEntry( aSubEntry, aMainEntry );
699   faceSelLayout->addWidget( myFaceSelector, 1, 0, 2, 2 );
700   faceSelLayout->setRowStretch( 1, 10);
701
702
703   // add tabs
704   tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
705   tab->insertTab( ADV_TAB, myAdvGroup, tr( "HYBRID_ADV_ARGS" ) );
706   tab->insertTab( ENF_MESH_TAB, myEnfMeshGroup, tr( "HYBRID_ENFORCED_MESHES" ) );
707   if ( aMainEntry.isEmpty() && aSubEntry.isEmpty() ) // mesh not based of geometry
708     faceSelGroup->hide();
709   else
710     tab->insertTab( FACE_SEL_TAB, faceSelGroup, tr( "HYBRID_FACES_TAB" ));
711   tab->setCurrentIndex( STD_TAB );
712
713   // connections
714   connect( tab,              SIGNAL( currentChanged ( int )),       this,         SLOT( onTabChanged( int ) ) );
715   //connect( myLayersOnAllWrapCheck,      SIGNAL( toggled( bool ) ), this, SLOT( onLayersOnAllWrap(bool)));
716   connect( myLayersOnAllWrapCheck,      SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
717   //connect( myToMeshHolesCheck,      SIGNAL( toggled( bool ) ), this, SLOT( onToMeshHoles(bool)));
718   //connect( myAdvWidget->maxMemoryCheck,             SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
719   //connect( myAdvWidget->initialMemoryCheck,         SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
720   //connect( myAdvWidget->boundaryRecoveryCheck,      SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
721
722   //connect( myBoundaryLayersGrowthCombo,  SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
723   //connect( myElementGenerationCombo,     SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
724   connect( myAddMultinormalsCheck,       SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
725   connect( mySmoothNormalsCheck,         SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
726   
727   connect( myAdvWidget->logInFileCheck,             SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
728   connect( myAdvWidget->keepWorkingFilesCheck,      SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
729   connect( myAdvWidget->workingDirectoryPushButton, SIGNAL( clicked() ),       this, SLOT( onDirBtnClicked() ) );
730   
731   connect( myEnforcedTableWidget,   SIGNAL( itemClicked(QTableWidgetItem *)), this, SLOT( synchronizeCoords() ) );
732   connect( myEnforcedTableWidget,   SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
733   connect( myEnforcedTableWidget,   SIGNAL( itemSelectionChanged() ),         this, SLOT( synchronizeCoords() ) );
734   connect( addVertexButton,         SIGNAL( clicked()),                       this, SLOT( onAddEnforcedVertex() ) );
735   connect( removeVertexButton,      SIGNAL( clicked()),                       this, SLOT( onRemoveEnforcedVertex() ) );
736   connect( myEnfVertexWdg,          SIGNAL( contentModified()),               this, SLOT( onSelectEnforcedVertex() ) );
737   connect( myEnfVertexWdg,          SIGNAL( contentModified()),              this,  SLOT( checkVertexIsDefined() ) );
738   connect( myXCoord,                SIGNAL( textChanged(const QString&) ),   this,  SLOT( clearEnfVertexSelection() ) );
739   connect( myYCoord,                SIGNAL( textChanged(const QString&) ),   this,  SLOT( clearEnfVertexSelection() ) );
740   connect( myZCoord,                SIGNAL( textChanged(const QString&) ),   this,  SLOT( clearEnfVertexSelection() ) );
741   connect( mySizeValue,             SIGNAL( textChanged(const QString&) ),   this,  SLOT( checkVertexIsDefined() ) );
742   connect( myXCoord,                SIGNAL( valueChanged(const QString&) ),   this,  SLOT( clearEnfVertexSelection() ) );
743   connect( myYCoord,                SIGNAL( valueChanged(const QString&) ),   this,  SLOT( clearEnfVertexSelection() ) );
744   connect( myZCoord,                SIGNAL( valueChanged(const QString&) ),   this,  SLOT( clearEnfVertexSelection() ) );
745   connect( mySizeValue,             SIGNAL( valueChanged(const QString&) ),   this,  SLOT( checkVertexIsDefined() ) );
746   connect( this,                    SIGNAL( vertexDefined(bool) ), addVertexButton, SLOT( setEnabled(bool) ) );
747   
748   connect( addEnfMeshButton,        SIGNAL( clicked()),                       this, SLOT( onAddEnforcedMesh() ) );
749   connect( removeEnfMeshButton,     SIGNAL( clicked()),                       this, SLOT( onRemoveEnforcedMesh() ) );
750 //   connect( myEnfMeshWdg,            SIGNAL( contentModified()),              this,  SLOT( checkEnfMeshIsDefined() ) );
751 //   connect( myEnfMeshConstraint,     SIGNAL( currentIndexChanged(int) ),      this,  SLOT( checkEnfMeshIsDefined() ) );
752 //   connect( this,                    SIGNAL( enfMeshDefined(bool) ), addEnfMeshButton, SLOT( setEnabled(bool) ) );
753   
754   return fr;
755 }
756
757 /** 
758  * This method checks if an enforced vertex is defined;
759 **/
760 void HYBRIDPluginGUI_HypothesisCreator::clearEnfVertexSelection()
761 {
762   if (myEnfVertexWdg->NbObjects() != 0) {
763     disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
764     disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
765     myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
766     connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
767     connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
768   }
769   HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
770   that->checkVertexIsDefined();
771 }
772
773 /** 
774  * This method checks if an enforced vertex is defined;
775 **/
776 void HYBRIDPluginGUI_HypothesisCreator::checkVertexIsDefined()
777 {
778   bool enfVertexIsDefined = false;
779   enfVertexIsDefined = (!mySizeValue->GetString().isEmpty() &&
780                        (!myEnfVertexWdg->NbObjects() == 0 ||
781                        (myEnfVertexWdg->NbObjects() == 0 && !myXCoord->GetString().isEmpty()
782                                                          && !myYCoord->GetString().isEmpty()
783                                                          && !myZCoord->GetString().isEmpty())));
784   emit vertexDefined(enfVertexIsDefined);
785 }
786
787 /** 
788  * This method checks if an enforced mesh is defined;
789 **/
790 void HYBRIDPluginGUI_HypothesisCreator::checkEnfMeshIsDefined()
791 {
792   emit enfMeshDefined( myEnfVertexWdg->NbObjects() != 0);
793 }
794
795 /** 
796  * This method resets the content of the X, Y, Z, size and GroupName widgets;
797 **/
798 void HYBRIDPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
799 {
800   myXCoord->setCleared(true);
801   myYCoord->setCleared(true);
802   myZCoord->setCleared(true);
803 //   mySizeValue->setCleared(true);
804   myXCoord->setText("");
805   myYCoord->setText("");
806   myZCoord->setText("");
807 //   mySizeValue->setText("");
808 //   myGroupName->setText("");
809   addVertexButton->setEnabled(false);
810 }
811
812 /** HYBRIDPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item)
813 This method updates the tooltip of a modified item. The QLineEdit widgets content
814 is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
815 */
816 void HYBRIDPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTableWidgetItem* item) {
817   int row = myEnforcedTableWidget->row(item);
818       
819   QVariant vertexName = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole);
820   QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole);
821   QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole);
822   QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole);
823   QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole);
824   QVariant entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
825   QString groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole).toString();
826   
827   clearEnforcedVertexWidgets();
828   
829   if ( !x.isNull() || !entry.isNull()) {
830     QString toolTip = vertexName.toString();
831     toolTip += QString("(");
832     if (entry.isNull() || (!entry.isNull() && entry.toString() == "")) {
833       toolTip += x.toString();
834       toolTip += QString(", ") + y.toString();
835       toolTip += QString(", ") + z.toString();
836     }
837     else
838       toolTip += entry.toString();
839     toolTip += QString(")");
840     
841     if (!size.isNull())
842       toolTip += QString("=") + size.toString();
843     
844     if (!groupName.isEmpty())
845       toolTip += QString(" [") + groupName + QString("]");
846
847     for (int col=0;col<ENF_VER_NB_COLUMNS;col++)
848       myEnforcedTableWidget->item(row,col)->setToolTip(toolTip);
849
850     if (!x.isNull()) {
851       disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
852       disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
853       disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
854       myXCoord->SetValue(x.toDouble());
855       myYCoord->SetValue(y.toDouble());
856       myZCoord->SetValue(z.toDouble());
857       connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
858       connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
859       connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
860     }
861     if (!size.isNull())
862       mySizeValue->SetValue(size.toDouble());
863     
864     if (!groupName.isEmpty())
865       myGroupName->setText(groupName);
866   }
867 }
868
869 void HYBRIDPluginGUI_HypothesisCreator::onSelectEnforcedVertex() {
870   int nbSelEnfVertex = myEnfVertexWdg->NbObjects();
871   clearEnforcedVertexWidgets();
872   if (nbSelEnfVertex == 1)
873   {
874     if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() )
875     return ;
876
877     myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
878     if (myEnfVertex == GEOM::GEOM_Object::_nil())
879       return;
880     if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
881       HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
882       GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
883       if (CORBA::is_nil(measureOp))
884         return;
885       
886       CORBA::Double x,y,z;
887       measureOp->PointCoordinates (myEnfVertex, x, y, z);
888       if ( measureOp->IsDone() )
889       {
890         disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
891         disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
892         disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
893         myXCoord->SetValue(x);
894         myYCoord->SetValue(y);
895         myZCoord->SetValue(z);
896         connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
897         connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
898         connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
899       }
900     }
901   }
902 }
903
904 /** HYBRIDPluginGUI_HypothesisCreator::synchronizeCoords()
905 This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
906 of the enforced vertex clicked in the tree widget.
907 */
908 void HYBRIDPluginGUI_HypothesisCreator::synchronizeCoords() {
909   clearEnforcedVertexWidgets();
910   QList<QTableWidgetItem *> items = myEnforcedTableWidget->selectedItems();
911 //   myEnfVertexWdg->disconnect(SIGNAL(contentModified()));
912   disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
913   if (! items.isEmpty()) {
914     QTableWidgetItem *item;
915     int row;
916     QVariant entry;
917     if (items.size() == 1) {
918       item = items[0];
919       row = myEnforcedTableWidget->row(item);
920       QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole);
921       QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole);
922       QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole);
923       QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole);
924       entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
925       if (!entry.isNull()) {
926         SMESH::string_array_var objIds = new SMESH::string_array;
927         objIds->length(1);
928         objIds[0] = entry.toString().toStdString().c_str();
929         myEnfVertexWdg->SetObjects(objIds);
930       }
931       else {
932         myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
933       }
934       QVariant group = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole);
935       if (!x.isNull()/* && entry.isNull()*/) {
936 //         disconnect( myXCoord, SIGNAL( textChanged(const QString &)), this, SLOT( onSelectEnforcedVertex() ) );
937         disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
938         disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
939         disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
940         myXCoord->SetValue(x.toDouble());
941         myYCoord->SetValue(y.toDouble());
942         myZCoord->SetValue(z.toDouble());
943         connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
944         connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
945         connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
946       }
947       if (!size.isNull())
948         mySizeValue->SetValue(size.toDouble());
949       
950       if (!group.isNull() && (!x.isNull() || !entry.isNull()))
951         myGroupName->setText(group.toString());
952     }
953     else {
954       QList<QString> entryList;
955       for (int i = 0; i < items.size(); ++i) {
956         item = items[i];
957         row = myEnforcedTableWidget->row(item);
958         entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
959         if (!entry.isNull())
960           entryList << entry.toString();
961       }
962       if (entryList.size() > 0) {
963         SMESH::string_array_var objIds = new SMESH::string_array;
964         objIds->length(entryList.size());
965         for (int i = 0; i < entryList.size() ; i++)
966           objIds[i] = entryList.at(i).toStdString().c_str();
967         myEnfVertexWdg->SetObjects(objIds);
968       }
969       else {
970         myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
971       }
972     }
973   }
974   else {
975     myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
976   }
977   connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
978   HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
979   that->checkVertexIsDefined();
980 }
981
982 /** HYBRIDPluginGUI_HypothesisCreator::addEnforcedMesh( meshName, geomEntry, elemType, size, groupName)
983 This method adds in the tree widget an enforced mesh from mesh, submesh or group with optionally size and and groupName.
984 */
985 void HYBRIDPluginGUI_HypothesisCreator::addEnforcedMesh(std::string name, std::string entry, int elementType, std::string groupName)
986 {
987   bool okToCreate = true;
988   QString itemEntry = "";
989   int itemElementType = 0;
990   int rowCount = myEnforcedMeshTableWidget->rowCount();
991   bool allColumns = true;
992   for (int row = 0;row<rowCount;row++) {
993     for (int col = 0 ; col < ENF_MESH_NB_COLUMNS ; col++) {
994       if (col == ENF_MESH_CONSTRAINT_COLUMN){
995         if (qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row, col)) == 0) {
996           allColumns = false;
997           break;
998         }
999       }
1000       else if (myEnforcedMeshTableWidget->item(row, col) == 0) {
1001         allColumns = false;
1002         break;
1003       }
1004       if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1005         QComboBox* itemComboBox = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row, col));
1006         itemElementType = itemComboBox->currentIndex();
1007       }
1008       else if (col == ENF_MESH_ENTRY_COLUMN)
1009         itemEntry = myEnforcedMeshTableWidget->item(row, col)->data(Qt::EditRole).toString();
1010     }
1011     
1012     if (!allColumns)
1013       break;
1014   
1015     if (itemEntry == QString(entry.c_str()) && itemElementType == elementType) { 
1016 //       // update group name
1017 //       if (itemGroupName.toStdString() != groupName) {
1018 //         myEnforcedMeshTableWidget->item(row, ENF_MESH_GROUP_COLUMN)->setData( Qt::EditRole, QVariant(groupName.c_str()));
1019 //       }
1020       okToCreate = false;
1021       break;
1022     } // if
1023   } // for
1024
1025     
1026   if (!okToCreate)
1027     return;
1028   
1029
1030   myEnforcedMeshTableWidget->setRowCount(rowCount+1);
1031   myEnforcedMeshTableWidget->setSortingEnabled(false);
1032   
1033   for (int col=0;col<ENF_MESH_NB_COLUMNS;col++) {
1034     if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1035       QComboBox* comboBox = new QComboBox();
1036       QPalette pal = comboBox->palette();
1037       pal.setColor(QPalette::Button, Qt::white);
1038       comboBox->setPalette(pal);
1039       comboBox->insertItems(0,myEnfMeshConstraintLabels);
1040       comboBox->setEditable(false);
1041       comboBox->setCurrentIndex(elementType);
1042       myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox);
1043     }
1044     else {
1045       QTableWidgetItem* item = new QTableWidgetItem();
1046       item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1047       switch (col) {
1048         case ENF_MESH_NAME_COLUMN:
1049           item->setData( 0, name.c_str() );
1050           item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1051           myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1052           break;
1053         case ENF_MESH_ENTRY_COLUMN:
1054           item->setData( 0, entry.c_str() );
1055           item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1056           myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1057           break;
1058         case ENF_MESH_GROUP_COLUMN:
1059           item->setData( 0, groupName.c_str() );
1060           myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1061           break;
1062         default:
1063           break;
1064       }
1065     }
1066   }
1067
1068 //   connect( myEnforcedMeshTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this,  SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1069   
1070   myEnforcedMeshTableWidget->setSortingEnabled(true);
1071 //   myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1072 //   updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1073     
1074 }
1075
1076 /** HYBRIDPluginGUI_HypothesisCreator::addEnforcedVertex( x, y, z, size, vertexName, geomEntry, groupName)
1077 This method adds in the tree widget an enforced vertex with given size and coords (x,y,z) or GEOM vertex or compound and with optionally groupName.
1078 */
1079 void HYBRIDPluginGUI_HypothesisCreator::addEnforcedVertex(double x, double y, double z, double size, std::string vertexName, std::string geomEntry, std::string groupName, bool isCompound)
1080 {
1081   myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1082   bool okToCreate = true;
1083   double itemX,itemY,itemZ,itemSize = 0;
1084   QString itemEntry, itemGroupName = QString("");
1085 //   bool itemIsCompound;
1086   int rowCount = myEnforcedTableWidget->rowCount();
1087   QVariant data;
1088   bool allColumns;
1089   for (int row = 0;row<rowCount;row++) {
1090     allColumns = true;
1091     for (int col = 0 ; col < ENF_VER_NB_COLUMNS ; col++) {
1092       if (myEnforcedTableWidget->item(row, col) == 0) {
1093         allColumns = false;
1094         break;
1095       }
1096       
1097       data = myEnforcedTableWidget->item(row, col)->data(Qt::EditRole);
1098       if (!data.isNull()) {
1099         switch (col) {
1100           case ENF_VER_GROUP_COLUMN:
1101             itemGroupName = data.toString();
1102             break;
1103           case ENF_VER_ENTRY_COLUMN:
1104             itemEntry = data.toString();
1105             break;
1106 //           case ENF_VER_COMPOUND_COLUMN:
1107 //             itemIsCompound = data.toBool();
1108 //             break;
1109           case ENF_VER_X_COLUMN:
1110             itemX = data.toDouble();
1111             break;
1112           case ENF_VER_Y_COLUMN:
1113             itemY = data.toDouble();
1114             break;
1115           case ENF_VER_Z_COLUMN:
1116             itemZ = data.toDouble();
1117             break;
1118           case ENF_VER_SIZE_COLUMN:
1119             itemSize = data.toDouble();
1120             break;
1121           default:
1122             break;
1123         }
1124       }
1125     }
1126     
1127     if (!allColumns)
1128       break;
1129
1130
1131     if (( !isCompound && ((itemX == x) && (itemY == y) && (itemZ == z))) || /*( (itemEntry.toStdString() != "") && */ (itemEntry.toStdString() == geomEntry)/*)*/) {
1132       // update size
1133       if (itemSize != size) {
1134         myEnforcedTableWidget->item(row, ENF_VER_SIZE_COLUMN)->setData( Qt::EditRole, QVariant(size));
1135       }
1136       // update group name
1137       if (itemGroupName.toStdString() != groupName) {
1138         myEnforcedTableWidget->item(row, ENF_VER_GROUP_COLUMN)->setData( Qt::EditRole, QVariant(groupName.c_str()));
1139       }
1140       okToCreate = false;
1141       break;
1142     } // if
1143   } // for
1144   if (!okToCreate) {
1145     if (geomEntry.empty()) {
1146     }
1147     else {
1148     }
1149     return;
1150   }
1151     
1152   if (geomEntry.empty()) {
1153   }
1154   else {
1155   }
1156
1157   int vertexIndex=0;
1158   int indexRef = -1;
1159   QString myVertexName;
1160   while(indexRef != vertexIndex) {
1161     indexRef = vertexIndex;
1162     if (vertexName.empty())
1163       myVertexName = QString("Vertex #%1").arg(vertexIndex);
1164     else
1165       myVertexName = QString(vertexName.c_str());
1166
1167     for (int row = 0;row<rowCount;row++) {
1168       QString name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString();
1169       if (myVertexName == name) {
1170         vertexIndex++;
1171         break;
1172       }
1173     }
1174   }
1175   
1176   myEnforcedTableWidget->setRowCount(rowCount+1);
1177   myEnforcedTableWidget->setSortingEnabled(false);
1178   for (int col=0;col<ENF_VER_NB_COLUMNS;col++) {
1179     QTableWidgetItem* item = new QTableWidgetItem();
1180     item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1181     switch (col) {
1182       case ENF_VER_NAME_COLUMN:
1183         item->setData( Qt::EditRole, myVertexName );
1184         if (!geomEntry.empty()) {
1185           if (isCompound)
1186             item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1187           else
1188             item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1189         }
1190         break;
1191       case ENF_VER_X_COLUMN:
1192         if (!isCompound)
1193           item->setData( 0, QVariant(x) );
1194         break;
1195       case ENF_VER_Y_COLUMN:
1196         if (!isCompound)
1197           item->setData( 0, QVariant(y) );
1198         break;
1199       case ENF_VER_Z_COLUMN:
1200         if (!isCompound)
1201           item->setData( 0, QVariant(z) );
1202         break;
1203       case ENF_VER_SIZE_COLUMN:
1204         item->setData( 0, QVariant(size) );
1205         break;
1206       case ENF_VER_ENTRY_COLUMN:
1207         if (!geomEntry.empty())
1208           item->setData( 0, QString(geomEntry.c_str()) );
1209         break;
1210       case ENF_VER_COMPOUND_COLUMN:
1211         item->setData( Qt::CheckStateRole, isCompound );
1212         item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
1213         break;
1214       case ENF_VER_GROUP_COLUMN:
1215         if (!groupName.empty())
1216           item->setData( 0, QString(groupName.c_str()) );
1217         break;
1218       default:
1219         break;
1220     }
1221     
1222     myEnforcedTableWidget->setItem(rowCount,col,item);
1223   }
1224
1225   connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this,  SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1226   
1227   myEnforcedTableWidget->setSortingEnabled(true);
1228 //   myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1229   updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1230 }
1231
1232 /** HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedMesh()
1233 This method is called when a item is added into the enforced meshes tree widget
1234 */
1235 void HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedMesh()
1236 {
1237
1238   HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1239   
1240   that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1241   myEnfMeshWdg->deactivateSelection();
1242
1243   for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column)
1244     myEnforcedMeshTableWidget->resizeColumnToContents(column);
1245
1246   // Vertex selection
1247   int selEnfMeshes = myEnfMeshWdg->NbObjects();
1248   if (selEnfMeshes == 0)
1249     return;
1250
1251   std::string groupName = myMeshGroupName->text().toStdString();
1252 //   if (myGlobalGroupName->isChecked())
1253 //     groupName = myGlobalGroupName->text().toStdString();
1254
1255   if (boost::trim_copy(groupName).empty())
1256     groupName = "LayersGroup"; //have to be not empty until non used
1257
1258   int elementType = myEnfMeshConstraint->currentIndex();
1259   
1260   
1261   _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1262   _PTR(SObject) aSObj; //SMESH::SMESH_IDSource::_nil;
1263   QString meshEntry = myEnfMeshWdg->GetValue();
1264   
1265   if (selEnfMeshes == 1)
1266   {
1267 //     myEnfMesh = myEnfMeshWdg->GetObject< SMESH::SMESH_IDSource >();
1268 //     std::string entry = myEnfMeshWdg->GetValue();
1269     aSObj = aStudy->FindObjectID(meshEntry.toStdString().c_str());
1270     CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy);
1271     if (!CORBA::is_nil(anObj)) {
1272 //       SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1273       addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
1274     }
1275   }
1276   else
1277   {
1278     QStringList meshEntries = meshEntry.split(" ", QString::SkipEmptyParts);
1279     QStringListIterator meshEntriesIt (meshEntries);
1280     while (meshEntriesIt.hasNext()) {
1281       aSObj = aStudy->FindObjectID(meshEntriesIt.next().toStdString().c_str());
1282       CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy);
1283       if (!CORBA::is_nil(anObj)) {
1284 //         SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1285         addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
1286       }
1287     }
1288   }
1289
1290   myEnfVertexWdg->SetObject(SMESH::SMESH_IDSource::_nil());
1291   
1292   for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column)
1293     myEnforcedMeshTableWidget->resizeColumnToContents(column);  
1294 }
1295
1296
1297 /** HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedVertex()
1298 This method is called when a item is added into the enforced vertices tree widget
1299 */
1300 void HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedVertex()
1301 {
1302
1303   HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1304   
1305   that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1306   myEnfVertexWdg->deactivateSelection();
1307
1308   for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1309     myEnforcedTableWidget->resizeColumnToContents(column);
1310
1311   // Vertex selection
1312   int selEnfVertex = myEnfVertexWdg->NbObjects();
1313   bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty());
1314   if ((selEnfVertex == 0) && coordsEmpty)
1315     return;
1316
1317   std::string groupName = myGroupName->text().toStdString();
1318 //   if (myGlobalGroupName->isChecked())
1319 //     groupName = myGlobalGroupName->text().toStdString();
1320
1321   if (boost::trim_copy(groupName).empty())
1322     groupName = "";
1323
1324   double size = mySizeValue->GetValue();
1325   
1326   if (selEnfVertex <= 1)
1327   {
1328     double x = 0, y = 0, z=0;
1329     if (myXCoord->GetString() != "") {
1330       x = myXCoord->GetValue();
1331       y = myYCoord->GetValue();
1332       z = myZCoord->GetValue();
1333     }
1334     if (selEnfVertex == 1) {
1335       myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >();
1336       std::string entry = "";
1337       if (myEnfVertex != GEOM::GEOM_Object::_nil())
1338         entry = myEnfVertex->GetStudyEntry();
1339       addEnforcedVertex(x, y, z, size, myEnfVertex->GetName(),entry, groupName, myEnfVertex->GetShapeType() == GEOM::COMPOUND);
1340     }
1341     else {
1342       addEnforcedVertex(x, y, z, size, "", "", groupName);
1343     }
1344   }
1345   else
1346   {
1347     if ( CORBA::is_nil(getGeomEngine()))
1348       return;
1349
1350     GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
1351     if (CORBA::is_nil(measureOp))
1352       return;
1353
1354     CORBA::Double x = 0, y = 0,z = 0;
1355     for (int j = 0 ; j < selEnfVertex ; j++)
1356     {
1357       myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j);
1358       if (myEnfVertex == GEOM::GEOM_Object::_nil())
1359         continue;
1360       if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1361         measureOp->PointCoordinates (myEnfVertex, x, y, z);
1362         if ( measureOp->IsDone() )
1363           addEnforcedVertex(x, y, z, size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1364       } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) {
1365           addEnforcedVertex(0., 0., 0., size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName, true);
1366       }
1367     }
1368   }
1369
1370   myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1371   
1372   for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1373     myEnforcedTableWidget->resizeColumnToContents(column);  
1374 }
1375
1376 /** HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedMesh()
1377 This method is called when a item is removed from the enforced meshes tree widget
1378 */
1379 void HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedMesh()
1380 {
1381   QList<int> selectedRows;
1382   QList<QTableWidgetItem *> selectedItems = myEnforcedMeshTableWidget->selectedItems();
1383   QTableWidgetItem* item;
1384   int row;
1385   foreach( item, selectedItems ) {
1386     row = item->row();
1387     if (!selectedRows.contains( row ) )
1388       selectedRows.append(row);
1389   }
1390   
1391   qSort( selectedRows );
1392   QListIterator<int> it( selectedRows );
1393   it.toBack();
1394   while ( it.hasPrevious() ) {
1395       row = it.previous();
1396       myEnforcedMeshTableWidget->removeRow(row );
1397   }
1398
1399   myEnforcedMeshTableWidget->selectionModel()->clearSelection();
1400 }
1401
1402 /** HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1403 This method is called when a item is removed from the enforced vertices tree widget
1404 */
1405 void HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1406 {
1407   QList<int> selectedRows;
1408   QList<QTableWidgetItem *> selectedItems = myEnforcedTableWidget->selectedItems();
1409   QTableWidgetItem* item;
1410   int row;
1411   foreach( item, selectedItems ) {
1412     row = item->row();
1413     if (!selectedRows.contains( row ) )
1414       selectedRows.append(row);
1415   }
1416   
1417   qSort( selectedRows );
1418   QListIterator<int> it( selectedRows );
1419   it.toBack();
1420   while ( it.hasPrevious() ) {
1421       row = it.previous();
1422       myEnforcedTableWidget->removeRow(row );
1423   }
1424
1425   myEnforcedTableWidget->selectionModel()->clearSelection();
1426 }
1427
1428 void HYBRIDPluginGUI_HypothesisCreator::onLayersOnAllWrap(bool isOn)
1429 {
1430    // myToMakeGroupsOfDomains->setEnabled( isOn );
1431    // if ( !isOn )
1432    //   myToMakeGroupsOfDomains->setChecked( false );
1433 }
1434
1435 void HYBRIDPluginGUI_HypothesisCreator::onToMeshHoles(bool isOn)
1436 {
1437   // myToMakeGroupsOfDomains->setEnabled( isOn );
1438   // if ( !isOn )
1439   //   myToMakeGroupsOfDomains->setChecked( false );
1440 }
1441
1442 void HYBRIDPluginGUI_HypothesisCreator::onDirBtnClicked()
1443 {
1444   QString dir = SUIT_FileDlg::getExistingDirectory( dlg(), myAdvWidget->workingDirectoryLineEdit->text(), QString() );
1445   if ( !dir.isEmpty() )
1446     myAdvWidget->workingDirectoryLineEdit->setText( dir );
1447 }
1448
1449 void HYBRIDPluginGUI_HypothesisCreator::onTabChanged( int )
1450 {
1451   myEnfVertexWdg->deactivateSelection();
1452   myEnfMeshWdg->deactivateSelection();
1453   myFaceSelector->ActivateSelection( false );
1454   myFaceSelector->ShowPreview( false );
1455 }
1456
1457 void HYBRIDPluginGUI_HypothesisCreator::updateWidgets()
1458 {
1459   //customs automatic set
1460   //myToMakeGroupsOfDomains->setEnabled( myToMeshHolesCheck->isChecked() );
1461   //myAdvWidget->maxMemorySpin->setEnabled( myAdvWidget->maxMemoryCheck->isChecked() );
1462   //myAdvWidget->initialMemoryCheck->setEnabled( !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1463   //myAdvWidget->initialMemorySpin->setEnabled( myAdvWidget->initialMemoryCheck->isChecked() && !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1464   //myOptimizationLevelCombo->setEnabled( !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1465   myMultinormalsAngleSpin->setEnabled( myAddMultinormalsCheck->isChecked() );
1466   if ( sender() == myAdvWidget->logInFileCheck ||
1467        sender() == myAdvWidget->keepWorkingFilesCheck )
1468   {
1469     bool logFileRemovable = myAdvWidget->logInFileCheck->isChecked() &&
1470                             !myAdvWidget->keepWorkingFilesCheck->isChecked();
1471
1472     myAdvWidget->removeLogOnSuccessCheck->setEnabled( logFileRemovable );
1473   }
1474   bool enabled = !myLayersOnAllWrapCheck->isChecked();
1475   myEnforcedMeshTableWidget->setEnabled(enabled);
1476   addEnfMeshButton->setEnabled(enabled);
1477   removeEnfMeshButton->setEnabled(enabled);
1478   myEnfMeshWdg->setEnabled(enabled);
1479   if ( QTabWidget* tab = qobject_cast<QTabWidget*>( myStdGroup->parentWidget()->parentWidget() ))
1480     tab->setTabEnabled( FACE_SEL_TAB, enabled );
1481 }
1482
1483 bool HYBRIDPluginGUI_HypothesisCreator::checkParams(QString& msg) const
1484 {
1485
1486   if ( !QFileInfo( myAdvWidget->workingDirectoryLineEdit->text().trimmed() ).isWritable() ) {
1487     SUIT_MessageBox::warning( dlg(),
1488                               tr( "SMESH_WRN_WARNING" ),
1489                               tr( "HYBRID_PERMISSION_DENIED" ) );
1490     return false;
1491   }
1492
1493   return true;
1494 }
1495
1496 void HYBRIDPluginGUI_HypothesisCreator::retrieveParams() const
1497 {
1498   HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1499   HYBRIDHypothesisData data;
1500   readParamsFromHypo( data );
1501
1502   if ( myName )
1503     myName->setText( data.myName );
1504   myLayersOnAllWrapCheck                      ->setChecked    ( data.myLayersOnAllWrap );
1505   myToMeshHolesCheck                          ->setChecked    ( data.myToMeshHoles );
1506   myToMakeGroupsOfDomains                     ->setChecked    ( data.myToMakeGroupsOfDomains );
1507   myOptimizationLevelCombo                    ->setCurrentIndex( data.myOptimizationLevel );
1508   myAdvWidget->maxMemoryCheck                 ->setChecked    ( data.myMaximumMemory > 0 );
1509   myAdvWidget->maxMemorySpin                  ->setValue      ( qMax( data.myMaximumMemory,
1510                                                                       myAdvWidget->maxMemorySpin->minimum() ));
1511   myAdvWidget->initialMemoryCheck             ->setChecked    ( data.myInitialMemory > 0 );
1512   myAdvWidget->initialMemorySpin              ->setValue      ( qMax( data.myInitialMemory,
1513                                                                       myAdvWidget->initialMemorySpin->minimum() ));
1514
1515   myCollisionModeCombo            ->setCurrentIndex( data.myCollisionMode );
1516   myBoundaryLayersGrowthCombo     ->setCurrentIndex( data.myBoundaryLayersGrowth );
1517   myElementGenerationCombo        ->setCurrentIndex( data.myElementGeneration );
1518   myAddMultinormalsCheck          -> setChecked ( data.myAddMultinormals );
1519   mySmoothNormalsCheck            -> setChecked ( data.mySmoothNormals );
1520   myHeightFirstLayerSpin          -> setValue( data.myHeightFirstLayer );
1521   myNbOfBoundaryLayersSpin        -> setValue( data.myNbOfBoundaryLayers );
1522   myBoundaryLayersProgressionSpin -> setValue( data.myBoundaryLayersProgression );
1523   myMultinormalsAngleSpin         -> setValue( data.myMultinormalsAngle );
1524   myFaceSelector                  ->SetListOfIDs( data.myFaceWLIds );
1525
1526   myAdvWidget->workingDirectoryLineEdit       ->setText   ( data.myWorkingDir );
1527   myAdvWidget->keepWorkingFilesCheck          ->setChecked( data.myKeepFiles );
1528   myAdvWidget->verboseLevelSpin               ->setValue  ( data.myVerboseLevel );
1529   myAdvWidget->createNewNodesCheck            ->setChecked( data.myToCreateNewNodes );
1530   myAdvWidget->removeInitialCentralPointCheck ->setChecked( data.myRemoveInitialCentralPoint );
1531   myAdvWidget->boundaryRecoveryCheck          ->setChecked( data.myBoundaryRecovery );
1532   myAdvWidget->FEMCorrectionCheck             ->setChecked( data.myFEMCorrection );
1533   myAdvWidget->gradationSpinBox               ->setValue  ( data.myGradation );
1534   myAdvWidget->myAdvOptionsTable              ->SetCustomOptions( data.myTextOption );
1535   myAdvWidget->logInFileCheck                 ->setChecked( !data.myLogInStandardOutput );
1536   myAdvWidget->removeLogOnSuccessCheck        ->setChecked( data.myRemoveLogOnSuccess );
1537
1538   TEnfVertexList::const_iterator it;
1539   int rowCount = 0;
1540   myEnforcedTableWidget->clearContents();
1541   myEnforcedTableWidget->setSortingEnabled(false);
1542   myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1543   for(it = data.myEnforcedVertices.begin() ; it != data.myEnforcedVertices.end(); it++ )
1544   {
1545     TEnfVertex* enfVertex = (*it);
1546     myEnforcedTableWidget->setRowCount(rowCount+1);
1547
1548     for (int col=0;col<ENF_VER_NB_COLUMNS;col++) {
1549       QTableWidgetItem* item = new QTableWidgetItem();
1550       item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1551       switch (col) {
1552         case ENF_VER_NAME_COLUMN:
1553           item->setData( 0, enfVertex->name.c_str() );
1554           if (!enfVertex->geomEntry.empty()) {
1555             if (enfVertex->isCompound)
1556               item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1557             else
1558               item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1559             
1560           }
1561           break;
1562         case ENF_VER_X_COLUMN:
1563           if (!enfVertex->isCompound) {
1564             item->setData( 0, enfVertex->coords.at(0) );
1565           }
1566           break;
1567         case ENF_VER_Y_COLUMN:
1568           if (!enfVertex->isCompound) {
1569             item->setData( 0, enfVertex->coords.at(1) );
1570           }
1571           break;
1572         case ENF_VER_Z_COLUMN:
1573           if (!enfVertex->isCompound) {
1574             item->setData( 0, enfVertex->coords.at(2) );
1575           }
1576           break;
1577         case ENF_VER_SIZE_COLUMN:
1578           item->setData( 0, enfVertex->size );
1579           break;
1580         case ENF_VER_ENTRY_COLUMN:
1581           item->setData( 0, enfVertex->geomEntry.c_str() );
1582           break;
1583         case ENF_VER_COMPOUND_COLUMN:
1584           item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
1585           item->setData( Qt::CheckStateRole, enfVertex->isCompound );
1586           break;
1587         case ENF_VER_GROUP_COLUMN:
1588           item->setData( 0, enfVertex->groupName.c_str() );
1589           break;
1590         default:
1591           break;
1592       }
1593       
1594       myEnforcedTableWidget->setItem(rowCount,col,item);
1595     }
1596     that->updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1597     rowCount++;
1598   }
1599
1600   connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this,  SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1601   myEnforcedTableWidget->setSortingEnabled(true);
1602   
1603   for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1604     myEnforcedTableWidget->resizeColumnToContents(column);
1605
1606   // Update Enforced meshes QTableWidget
1607   TEnfMeshList::const_iterator itMesh;
1608   rowCount = 0;
1609   myEnforcedMeshTableWidget->clearContents();
1610   myEnforcedMeshTableWidget->setSortingEnabled(false);
1611 //   myEnforcedMeshTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1612   for(itMesh = data.myEnforcedMeshes.begin() ; itMesh != data.myEnforcedMeshes.end(); itMesh++ )
1613   {
1614     TEnfMesh* enfMesh = (*itMesh);
1615     myEnforcedMeshTableWidget->setRowCount(rowCount+1);
1616
1617     for (int col=0;col<ENF_MESH_NB_COLUMNS;col++) {
1618       if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1619         QComboBox* comboBox = new QComboBox();
1620         QPalette pal = comboBox->palette();
1621         pal.setColor(QPalette::Button, Qt::white);
1622         comboBox->setPalette(pal);
1623         comboBox->insertItems(0,myEnfMeshConstraintLabels);
1624         comboBox->setEditable(false);
1625         comboBox->setCurrentIndex(enfMesh->elementType);
1626         myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox);
1627       }
1628       else {
1629         QTableWidgetItem* item = new QTableWidgetItem();
1630         item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1631         switch (col) {
1632           case ENF_MESH_NAME_COLUMN:
1633             item->setData( 0, enfMesh->name.c_str() );
1634             item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1635             myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1636             break;
1637           case ENF_MESH_ENTRY_COLUMN:
1638             item->setData( 0, enfMesh->entry.c_str() );
1639             item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1640             myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1641             break;
1642           case ENF_MESH_GROUP_COLUMN:
1643             item->setData( 0, enfMesh->groupName.c_str() );
1644             myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1645             break;
1646           default:
1647             break;
1648         }
1649       }
1650       
1651 //       myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1652     }
1653 //     that->updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1654     rowCount++;
1655   }
1656
1657 //   connect( myEnforcedMeshTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this,  SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1658   myEnforcedMeshTableWidget->setSortingEnabled(true);
1659   
1660   for (int col=0;col<ENF_MESH_NB_COLUMNS;col++)
1661     myEnforcedMeshTableWidget->resizeColumnToContents(col);
1662   
1663   that->updateWidgets();
1664   that->checkVertexIsDefined();
1665 }
1666
1667 QString HYBRIDPluginGUI_HypothesisCreator::storeParams() const
1668 {
1669   HYBRIDHypothesisData data;
1670   readParamsFromWidgets( data );
1671   storeParamsToHypo( data );
1672
1673   QString valStr = "";
1674
1675   if ( !data.myBoundaryRecovery )
1676     valStr = "-c " + QString::number( !data.myToMeshHoles );
1677
1678   if ( data.myOptimizationLevel >= 0 && data.myOptimizationLevel < 5 && !data.myBoundaryRecovery) {
1679     const char* level[] = { "none" , "light" , "standard" , "standard+" , "strong" };
1680     valStr += " -o ";
1681     valStr += level[ data.myOptimizationLevel ];
1682   }
1683   if ( data.myMaximumMemory > 0 ) {
1684     valStr += " -m ";
1685     valStr += QString::number( data.myMaximumMemory );
1686   }
1687   if ( data.myInitialMemory > 0 && !data.myBoundaryRecovery ) {
1688     valStr += " -M ";
1689     valStr += QString::number( data.myInitialMemory );
1690   }
1691   valStr += " -v ";
1692   valStr += QString::number( data.myVerboseLevel );
1693
1694   if ( !data.myToCreateNewNodes )
1695     valStr += " -p0";
1696
1697   if ( data.myRemoveInitialCentralPoint )
1698     valStr += " -no_initial_central_point";
1699
1700   if ( data.myBoundaryRecovery )
1701     valStr += " -C";
1702
1703   if ( data.myFEMCorrection )
1704     valStr += " -FEM";
1705
1706   if ( data.myGradation != 1.05 ) {
1707     valStr += " -Dcpropa=";
1708     valStr += QString::number( data.myGradation );
1709   }
1710
1711   valStr += " ";
1712   valStr += data.myTextOption;
1713
1714   //     valStr += " #BEGIN ENFORCED VERTICES#";
1715   //     // Add size map parameters storage
1716   //     for (int i=0 ; i<mySmpModel->rowCount() ; i++) {
1717   //         valStr += " (";
1718   //         double x = mySmpModel->data(mySmpModel->index(i,ENF_VER_X_COLUMN)).toDouble();
1719   //         double y = mySmpModel->data(mySmpModel->index(i,ENF_VER_Y_COLUMN)).toDouble();
1720   //         double z = mySmpModel->data(mySmpModel->index(i,ENF_VER_Z_COLUMN)).toDouble();
1721   //         double size = mySmpModel->data(mySmpModel->index(i,ENF_VER_SIZE_COLUMN)).toDouble();
1722   //         valStr += QString::number( x );
1723   //         valStr += ",";
1724   //         valStr += QString::number( y );
1725   //         valStr += ",";
1726   //         valStr += QString::number( z );
1727   //         valStr += ")=";
1728   //         valStr += QString::number( size );
1729   //         if (i!=mySmpModel->rowCount()-1)
1730   //             valStr += ";";
1731   //     }
1732   //     valStr += " #END ENFORCED VERTICES#";
1733   return valStr;
1734 }
1735
1736 bool HYBRIDPluginGUI_HypothesisCreator::readParamsFromHypo( HYBRIDHypothesisData& h_data ) const
1737 {
1738   HYBRIDPlugin::HYBRIDPlugin_Hypothesis_var h =
1739     HYBRIDPlugin::HYBRIDPlugin_Hypothesis::_narrow( initParamsHypothesis() );
1740
1741   HypothesisData* data = SMESH::GetHypothesisData( hypType() );
1742   h_data.myName = isCreation() && data ? hypName() : "";
1743
1744   h_data.myCollisionMode              = h->GetCollisionMode();
1745   h_data.myBoundaryLayersGrowth       = h->GetBoundaryLayersGrowth();
1746   h_data.myElementGeneration          = h->GetElementGeneration();
1747   h_data.myAddMultinormals            = h->GetAddMultinormals();
1748   h_data.mySmoothNormals              = h->GetSmoothNormals();
1749   h_data.myHeightFirstLayer           = h->GetHeightFirstLayer();
1750   h_data.myBoundaryLayersProgression  = h->GetBoundaryLayersProgression();
1751   h_data.myMultinormalsAngle          = h->GetMultinormalsAngle();
1752   h_data.myNbOfBoundaryLayers         = h->GetNbOfBoundaryLayers();
1753   h_data.myFaceWLIds                  = h->GetFacesWithLayers();
1754
1755   h_data.myLayersOnAllWrap            = h->GetLayersOnAllWrap();
1756   h_data.myToMeshHoles                = h->GetToMeshHoles();
1757   h_data.myToMakeGroupsOfDomains      = /*h->GetToMeshHoles() &&*/ h->GetToMakeGroupsOfDomains();
1758   h_data.myMaximumMemory              = h->GetMaximumMemory();
1759   h_data.myInitialMemory              = h->GetInitialMemory();
1760   h_data.myInitialMemory              = h->GetInitialMemory();
1761   h_data.myOptimizationLevel          = h->GetOptimizationLevel();
1762   
1763   h_data.myKeepFiles                  = h->GetKeepFiles();
1764   h_data.myWorkingDir                 = h->GetWorkingDirectory();
1765   h_data.myVerboseLevel               = h->GetVerboseLevel();
1766   h_data.myToCreateNewNodes           = h->GetToCreateNewNodes();
1767   h_data.myRemoveInitialCentralPoint  = h->GetToRemoveCentralPoint();
1768   h_data.myBoundaryRecovery           = h->GetToUseBoundaryRecoveryVersion();
1769   h_data.myFEMCorrection              = h->GetFEMCorrection();
1770   h_data.myGradation                  = h->GetGradation();
1771   h_data.myTextOption                 = h->GetAdvancedOption();
1772   h_data.myLogInStandardOutput        = h->GetStandardOutputLog();
1773   h_data.myRemoveLogOnSuccess         = h->GetRemoveLogOnSuccess();
1774   
1775   HYBRIDPlugin::HYBRIDEnforcedVertexList_var vertices = h->GetEnforcedVertices();
1776   h_data.myEnforcedVertices.clear();
1777   for (CORBA::ULong i=0 ; i<vertices->length() ; i++) {
1778     TEnfVertex* myVertex = new TEnfVertex();
1779     myVertex->name = CORBA::string_dup(vertices[i].name.in());
1780     myVertex->geomEntry = CORBA::string_dup(vertices[i].geomEntry.in());
1781     myVertex->groupName = CORBA::string_dup(vertices[i].groupName.in());
1782     myVertex->size = vertices[i].size;
1783     myVertex->isCompound = vertices[i].isCompound;
1784     if (vertices[i].coords.length()) {
1785       for (CORBA::ULong c = 0; c < vertices[i].coords.length() ; c++)
1786         myVertex->coords.push_back(vertices[i].coords[c]);
1787     }
1788     h_data.myEnforcedVertices.insert(myVertex);
1789   }
1790   
1791   HYBRIDPlugin::HYBRIDEnforcedMeshList_var enfMeshes = h->GetEnforcedMeshes();
1792   h_data.myEnforcedMeshes.clear();
1793   for (CORBA::ULong i=0 ; i<enfMeshes->length() ; i++) {
1794     TEnfMesh* myEnfMesh = new TEnfMesh();
1795     myEnfMesh->name = CORBA::string_dup(enfMeshes[i].name.in());
1796     myEnfMesh->entry = CORBA::string_dup(enfMeshes[i].entry.in());
1797     myEnfMesh->groupName = CORBA::string_dup(enfMeshes[i].groupName.in());
1798     switch (enfMeshes[i].elementType) {
1799       case SMESH::NODE:
1800         myEnfMesh->elementType = 0;
1801         break;
1802       case SMESH::EDGE:
1803         myEnfMesh->elementType = 1;
1804         break;
1805       case SMESH::FACE:
1806         myEnfMesh->elementType = 2;
1807         break;
1808       default:
1809         break;
1810     }
1811 //     myEnfMesh->elementType = enfMeshes[i].elementType;
1812     h_data.myEnforcedMeshes.insert(myEnfMesh);
1813   }
1814   return true;
1815 }
1816
1817 bool HYBRIDPluginGUI_HypothesisCreator::storeParamsToHypo( const HYBRIDHypothesisData& h_data ) const
1818 {
1819   HYBRIDPlugin::HYBRIDPlugin_Hypothesis_var h =
1820     HYBRIDPlugin::HYBRIDPlugin_Hypothesis::_narrow( hypothesis() );
1821
1822   bool ok = true;
1823   try
1824   {
1825     if( isCreation() )
1826       SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
1827
1828     if ( h->GetLayersOnAllWrap() != h_data.myLayersOnAllWrap ) // avoid duplication of DumpPython commands
1829       h->SetLayersOnAllWrap ( h_data.myLayersOnAllWrap );
1830     if ( h->GetToMeshHoles() != h_data.myToMeshHoles ) // avoid duplication of DumpPython commands
1831       h->SetToMeshHoles      ( h_data.myToMeshHoles );
1832     if ( h->GetToMakeGroupsOfDomains() != h_data.myToMakeGroupsOfDomains )
1833       h->SetToMakeGroupsOfDomains( h_data.myToMakeGroupsOfDomains );
1834     if ( h->GetMaximumMemory() != h_data.myMaximumMemory )
1835       h->SetMaximumMemory    ( h_data.myMaximumMemory );
1836     if ( h->GetInitialMemory() != h_data.myInitialMemory )
1837       h->SetInitialMemory    ( h_data.myInitialMemory );
1838     if ( h->GetInitialMemory() != h_data.myInitialMemory )
1839       h->SetInitialMemory    ( h_data.myInitialMemory );
1840     if ( h->GetOptimizationLevel() != h_data.myOptimizationLevel )
1841       h->SetOptimizationLevel( h_data.myOptimizationLevel );
1842
1843     if ( h->GetCollisionMode() != h_data.myCollisionMode )
1844       h->SetCollisionMode(        h_data.myCollisionMode );
1845     if ( h->GetBoundaryLayersGrowth() != h_data.myBoundaryLayersGrowth )
1846       h->SetBoundaryLayersGrowth(        h_data.myBoundaryLayersGrowth );
1847     if ( h->GetElementGeneration() != h_data.myElementGeneration )
1848       h->SetElementGeneration(        h_data.myElementGeneration );
1849
1850     if ( h->GetAddMultinormals() != h_data.myAddMultinormals )
1851       h->SetAddMultinormals       ( h_data.myAddMultinormals );
1852     if ( h->GetSmoothNormals() != h_data.mySmoothNormals )
1853       h->SetSmoothNormals       ( h_data.mySmoothNormals );
1854     if ( h->GetHeightFirstLayer() != h_data.myHeightFirstLayer )
1855       h->SetHeightFirstLayer       ( h_data.myHeightFirstLayer );
1856     if ( h->GetBoundaryLayersProgression() != h_data.myBoundaryLayersProgression )
1857       h->SetBoundaryLayersProgression       ( h_data.myBoundaryLayersProgression );
1858     if ( h->GetMultinormalsAngle() != h_data.myMultinormalsAngle )
1859       h->SetMultinormalsAngle       ( h_data.myMultinormalsAngle );
1860     if ( h->GetNbOfBoundaryLayers() != h_data.myNbOfBoundaryLayers )
1861       h->SetNbOfBoundaryLayers       ( h_data.myNbOfBoundaryLayers );
1862     h->SetFacesWithLayers( h_data.myFaceWLIds );
1863
1864     if ( h->GetKeepFiles() != h_data.myKeepFiles)
1865       h->SetKeepFiles       ( h_data.myKeepFiles);
1866     if ( h->GetWorkingDirectory() != h_data.myWorkingDir )
1867       h->SetWorkingDirectory       ( h_data.myWorkingDir.toLatin1().constData() );
1868     if ( h->GetVerboseLevel() != h_data.myVerboseLevel )
1869       h->SetVerboseLevel       ( h_data.myVerboseLevel );
1870     if ( h->GetToCreateNewNodes() != h_data.myToCreateNewNodes )
1871       h->SetToCreateNewNodes       ( h_data.myToCreateNewNodes );
1872     if ( h->GetToRemoveCentralPoint() != h_data.myRemoveInitialCentralPoint )
1873       h->SetToRemoveCentralPoint       ( h_data.myRemoveInitialCentralPoint );
1874     if ( h->GetToUseBoundaryRecoveryVersion() != h_data.myBoundaryRecovery )
1875       h->SetToUseBoundaryRecoveryVersion       ( h_data.myBoundaryRecovery );
1876     if ( h->GetFEMCorrection() != h_data.myFEMCorrection )
1877       h->SetFEMCorrection       ( h_data.myFEMCorrection );
1878     if ( h->GetGradation() != h_data.myGradation )
1879       h->SetGradation       ( h_data.myGradation );
1880     if ( h->GetTextOption() != h_data.myTextOption )
1881       h->SetAdvancedOption    ( h_data.myTextOption.toLatin1().constData() );
1882     if ( h->GetStandardOutputLog() != h_data.myLogInStandardOutput )
1883       h->SetStandardOutputLog       ( h_data.myLogInStandardOutput );
1884     if ( h->GetRemoveLogOnSuccess() != h_data.myRemoveLogOnSuccess )
1885       h->SetRemoveLogOnSuccess        ( h_data.myRemoveLogOnSuccess );
1886     
1887     // Enforced vertices
1888     //int nbVertex = (int) h_data.myEnforcedVertices.size();
1889     HYBRIDPlugin::HYBRIDEnforcedVertexList_var vertexHyp = h->GetEnforcedVertices();
1890     int nbVertexHyp = vertexHyp->length();
1891     
1892     
1893     // 1. Clear all enforced vertices in hypothesis
1894     // 2. Add new enforced vertex according to h_data
1895     if ( nbVertexHyp > 0)
1896       h->ClearEnforcedVertices();
1897     
1898     TEnfVertexList::const_iterator it;
1899     double x = 0, y = 0, z = 0;
1900     for(it = h_data.myEnforcedVertices.begin() ; it != h_data.myEnforcedVertices.end(); it++ ) {
1901       TEnfVertex* enfVertex = (*it);
1902       x =y =z = 0;
1903       if (enfVertex->coords.size()) {
1904         x = enfVertex->coords.at(0);
1905         y = enfVertex->coords.at(1);
1906         z = enfVertex->coords.at(2);
1907       }
1908       ok = h->p_SetEnforcedVertex( enfVertex->size, x, y, z, enfVertex->name.c_str(), enfVertex->geomEntry.c_str(), enfVertex->groupName.c_str(), enfVertex->isCompound);
1909     } // for
1910     
1911     // Enforced Meshes
1912     //int nbEnfMeshes = (int) h_data.myEnforcedMeshes.size();
1913     HYBRIDPlugin::HYBRIDEnforcedMeshList_var enfMeshListHyp = h->GetEnforcedMeshes();
1914     int nbEnfMeshListHyp = enfMeshListHyp->length();
1915     
1916     
1917     // 1. Clear all enforced vertices in hypothesis
1918     // 2. Add new enforced vertex according to h_data
1919     if ( nbEnfMeshListHyp > 0)
1920       h->ClearEnforcedMeshes();
1921     
1922     TEnfMeshList::const_iterator itEnfMesh;
1923
1924     _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1925
1926     for(itEnfMesh = h_data.myEnforcedMeshes.begin() ; itEnfMesh != h_data.myEnforcedMeshes.end(); itEnfMesh++ ) {
1927       TEnfMesh* enfMesh = (*itEnfMesh);
1928
1929       _PTR(SObject) aSObj = aStudy->FindObjectID(enfMesh->entry.c_str());
1930       SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1931
1932       SMESH::ElementType elementType;
1933       switch(enfMesh->elementType) {
1934         case 0:
1935           elementType = SMESH::NODE;
1936           break;
1937         case 1:
1938           elementType = SMESH::EDGE;
1939           break;
1940         case 2:
1941           elementType = SMESH::FACE;
1942           break;
1943         default:
1944           break;
1945       }
1946     
1947       std::cout << "h->p_SetEnforcedMesh(theSource, "<< elementType <<", \""<< enfMesh->name << "\", \"" << enfMesh->groupName.c_str() <<"\")"<<std::endl;
1948       ok = h->p_SetEnforcedMesh(theSource, elementType, enfMesh->name.c_str(), enfMesh->groupName.c_str());
1949     } // for
1950   } // try
1951 //   catch(const std::exception& ex) {
1952 //     std::cout << "Exception: " << ex.what() << std::endl;
1953 //     throw ex;
1954 //   }
1955   catch ( const SALOME::SALOME_Exception& ex )
1956   {
1957     SalomeApp_Tools::QtCatchCorbaException( ex );
1958     ok = false;
1959   }
1960   return ok;
1961 }
1962
1963 bool HYBRIDPluginGUI_HypothesisCreator::readParamsFromWidgets( HYBRIDHypothesisData& h_data ) const
1964 {
1965   h_data.myName                       = myName ? myName->text() : "";
1966   h_data.myLayersOnAllWrap            = myLayersOnAllWrapCheck->isChecked();
1967   h_data.myToMeshHoles                = myToMeshHolesCheck->isChecked();
1968   h_data.myToMakeGroupsOfDomains      = myToMakeGroupsOfDomains->isChecked();
1969   h_data.myMaximumMemory              = myAdvWidget->maxMemoryCheck->isChecked() ? myAdvWidget->maxMemorySpin->value() : -1;
1970   h_data.myInitialMemory              = myAdvWidget->initialMemoryCheck->isChecked() ? myAdvWidget->initialMemorySpin->value() : -1;
1971   h_data.myOptimizationLevel          = myOptimizationLevelCombo->currentIndex();
1972
1973   h_data.myCollisionMode              = myCollisionModeCombo->currentIndex();
1974   h_data.myBoundaryLayersGrowth       = myBoundaryLayersGrowthCombo->currentIndex();
1975   h_data.myElementGeneration          = myElementGenerationCombo->currentIndex();
1976   h_data.myAddMultinormals            = myAddMultinormalsCheck->isChecked();
1977   h_data.mySmoothNormals              = mySmoothNormalsCheck->isChecked();
1978
1979   h_data.myHeightFirstLayer           = myHeightFirstLayerSpin -> value();
1980   h_data.myNbOfBoundaryLayers         = myNbOfBoundaryLayersSpin -> value();
1981   h_data.myBoundaryLayersProgression  = myBoundaryLayersProgressionSpin -> value();
1982   h_data.myMultinormalsAngle          = myMultinormalsAngleSpin -> value();
1983   h_data.myFaceWLIds                  = myFaceSelector->GetListOfIDs();
1984
1985   h_data.myKeepFiles                  = myAdvWidget->keepWorkingFilesCheck->isChecked();
1986   h_data.myWorkingDir                 = myAdvWidget->workingDirectoryLineEdit->text().trimmed();
1987   h_data.myVerboseLevel               = myAdvWidget->verboseLevelSpin->value();
1988   h_data.myToCreateNewNodes           = myAdvWidget->createNewNodesCheck->isChecked();
1989   h_data.myRemoveInitialCentralPoint  = myAdvWidget->removeInitialCentralPointCheck->isChecked();
1990   h_data.myBoundaryRecovery           = myAdvWidget->boundaryRecoveryCheck->isChecked();
1991   h_data.myFEMCorrection              = myAdvWidget->FEMCorrectionCheck->isChecked();
1992   h_data.myGradation                  = myAdvWidget->gradationSpinBox->value();
1993   h_data.myTextOption                 = myAdvWidget->myAdvOptionsTable->GetCustomOptions();
1994   h_data.myLogInStandardOutput        = !myAdvWidget->logInFileCheck->isChecked();
1995   h_data.myRemoveLogOnSuccess         = myAdvWidget->removeLogOnSuccessCheck->isChecked();
1996
1997   // Enforced vertices
1998   h_data.myEnforcedVertices.clear();
1999   QVariant valueX, valueY, valueZ;
2000   for (int row=0 ; row<myEnforcedTableWidget->rowCount() ; row++) {
2001     
2002     TEnfVertex *myVertex = new TEnfVertex();
2003     myVertex->name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString();
2004     myVertex->geomEntry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString();
2005     if (myVertex->geomEntry.size())
2006     myVertex->groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
2007     if (myVertex->groupName.size())
2008     valueX = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data(Qt::EditRole);
2009     valueY = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data(Qt::EditRole);
2010     valueZ = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data(Qt::EditRole);
2011     if (!valueX.isNull() && !valueY.isNull() && !valueZ.isNull()) {
2012       myVertex->coords.push_back(valueX.toDouble());
2013       myVertex->coords.push_back(valueY.toDouble());
2014       myVertex->coords.push_back(valueZ.toDouble());
2015     }
2016     myVertex->size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data(Qt::EditRole).toDouble();
2017     myVertex->isCompound = myEnforcedTableWidget->item(row,ENF_VER_COMPOUND_COLUMN)->data(Qt::CheckStateRole).toBool();
2018     h_data.myEnforcedVertices.insert(myVertex);
2019   }
2020   
2021   // Enforced meshes
2022   h_data.myEnforcedMeshes.clear();
2023
2024   for (int row=0 ; row<myEnforcedMeshTableWidget->rowCount() ; row++) {
2025     
2026     TEnfMesh *myEnfMesh = new TEnfMesh();
2027     myEnfMesh->name = myEnforcedMeshTableWidget->item(row,ENF_MESH_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString();
2028     myEnfMesh->entry = myEnforcedMeshTableWidget->item(row,ENF_MESH_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString();
2029     myEnfMesh->groupName = myEnforcedMeshTableWidget->item(row,ENF_MESH_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
2030     QComboBox* combo = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row,ENF_MESH_CONSTRAINT_COLUMN));
2031     myEnfMesh->elementType = combo->currentIndex();
2032     h_data.myEnforcedMeshes.insert(myEnfMesh);
2033     std::cout << "h_data.myEnforcedMeshes.size(): " << h_data.myEnforcedMeshes.size() << std::endl;
2034   }
2035
2036   return true;
2037 }
2038
2039 QString HYBRIDPluginGUI_HypothesisCreator::caption() const
2040 {
2041   return tr( "HYBRID_TITLE" );
2042 }
2043
2044 QPixmap HYBRIDPluginGUI_HypothesisCreator::icon() const
2045 {
2046   return SUIT_Session::session()->resourceMgr()->loadPixmap( "HYBRIDPlugin", tr( "ICON_DLG_HYBRID_PARAMETERS" ) );
2047 }
2048
2049 QString HYBRIDPluginGUI_HypothesisCreator::type() const
2050 {
2051   return tr( "HYBRID_HYPOTHESIS" );
2052 }
2053
2054 QString HYBRIDPluginGUI_HypothesisCreator::helpPage() const
2055 {
2056   return "hybrid_hypo_page.html";
2057 }