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