Salome HOME
Merge Python 3 porting.
[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 study}
317  * */
318 GeomSelectionTools* GHS3DPluginGUI_HypothesisCreator::getGeomSelectionTool()
319 {
320   GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
321   if (that->GeomToolSelected == NULL) {
322     that->GeomToolSelected = new GeomSelectionTools();
323   }
324   return that->GeomToolSelected;
325 }
326
327 GEOM::GEOM_Gen_var GHS3DPluginGUI_HypothesisCreator::getGeomEngine()
328 {
329   return GeometryGUI::GetGeomGen();
330 }
331
332 bool GHS3DPluginGUI_HypothesisCreator::isOptimization() const
333 {
334   return ( hypType() == GHS3DPlugin_OptimizerHypothesis::GetHypType() );
335 }
336
337 QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame()
338 {
339   QFrame* fr = new QFrame( 0 );
340   QVBoxLayout* lay = new QVBoxLayout( fr );
341   lay->setMargin( 5 );
342   lay->setSpacing( 0 );
343
344   // tab
345   QTabWidget* tab = new QTabWidget( fr );
346   tab->setTabShape( QTabWidget::Rounded );
347   tab->setTabPosition( QTabWidget::North );
348   lay->addWidget( tab );
349
350   // basic parameters
351   myStdGroup = new QWidget();
352   QGridLayout* aStdLayout = new QGridLayout( myStdGroup );
353   aStdLayout->setSpacing( 6 );
354   aStdLayout->setMargin( 11 );
355
356   int row = 0;
357   myName = 0;
358   if ( isCreation() )
359   {
360     aStdLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), myStdGroup ), row, 0, 1, 1 );
361     myName = new QLineEdit( myStdGroup );
362     aStdLayout->addWidget( myName, row++, 1, 1, 1 );
363   }
364
365   myToMeshHolesCheck = new QCheckBox( tr( "GHS3D_TO_MESH_HOLES" ), myStdGroup );
366   aStdLayout->addWidget( myToMeshHolesCheck, row, 0, 1, 1 );
367   myToMakeGroupsOfDomains = new QCheckBox( tr( "GHS3D_TO_MAKE_DOMAIN_GROUPS" ), myStdGroup );
368   aStdLayout->addWidget( myToMakeGroupsOfDomains, row++, 1, 1, 1 );
369
370   QLabel* optimizationLbl = new QLabel( tr( "GHS3D_OPTIMIZATION" ), myStdGroup );
371   aStdLayout->addWidget( optimizationLbl, row, 0, 1, 1 );
372   myOptimizationCombo = getModeCombo( myStdGroup, false );
373   aStdLayout->addWidget( myOptimizationCombo, row++, 1, 1, 1 );
374
375   QLabel* optimizatiolLevelLbl = new QLabel( tr( "GHS3D_OPTIMIZATIOL_LEVEL" ), myStdGroup );
376   aStdLayout->addWidget( optimizatiolLevelLbl, row, 0, 1, 1 );
377   myOptimizationLevelCombo = new QComboBox( myStdGroup );
378   aStdLayout->addWidget( myOptimizationLevelCombo, row++, 1, 1, 1 );
379
380   QLabel* splitOverconstrainedLbl = new QLabel( tr("GHS3D_SPLIT_OVERCONSTRAINED"), myStdGroup );
381   aStdLayout->addWidget( splitOverconstrainedLbl, row, 0, 1, 1 );
382   mySplitOverConstrainedCombo = getModeCombo( myStdGroup, false );
383   aStdLayout->addWidget( mySplitOverConstrainedCombo, row++, 1, 1, 1 );
384
385   QLabel* pthreadsModeLbl = new QLabel( tr( "GHS3D_PTHREADS_MODE" ), myStdGroup);
386   aStdLayout->addWidget( pthreadsModeLbl, row, 0, 1, 1 );
387   myPThreadsModeCombo = getModeCombo( myStdGroup, true );
388   aStdLayout->addWidget( myPThreadsModeCombo, row++, 1, 1, 1 );
389
390   QLabel* nbThreadsLbl = new QLabel( tr( "GHS3D_NB_THREADS" ), myStdGroup);
391   aStdLayout->addWidget( nbThreadsLbl, row, 0, 1, 1 );
392   myNumberOfThreadsSpin = new SalomeApp_IntSpinBox( 0, 1000, 1, myStdGroup );
393   aStdLayout->addWidget( myNumberOfThreadsSpin, row++, 1, 1, 1 );
394
395   mySmoothOffSliversCheck = new QCheckBox( tr( "GHS3D_SMOOTH_OFF_SLIVERS" ), myStdGroup );
396   aStdLayout->addWidget( mySmoothOffSliversCheck, row, 0, 1, 1 );
397   myCreateNewNodesCheck = new QCheckBox( tr( "TO_ADD_NODES" ), myStdGroup );
398   aStdLayout->addWidget( myCreateNewNodesCheck, row++, 1, 1, 1 );
399
400   myOptimizationLevelCombo->addItems( QStringList()
401                                       << tr( "LEVEL_NONE" )   << tr( "LEVEL_LIGHT" )
402                                       << tr( "LEVEL_MEDIUM" ) << tr( "LEVEL_STANDARDPLUS" )
403                                       << tr( "LEVEL_STRONG" ));
404   aStdLayout->setRowStretch( row, 10 );
405
406   if ( isOptimization() )
407   {
408     myToMeshHolesCheck->hide();
409     myToMakeGroupsOfDomains->hide();
410   }
411   else
412   {
413     optimizationLbl->hide();
414     myOptimizationCombo->hide();
415     splitOverconstrainedLbl->hide();
416     mySplitOverConstrainedCombo->hide();
417     pthreadsModeLbl->hide();
418     myPThreadsModeCombo->hide();
419     nbThreadsLbl->hide();
420     myNumberOfThreadsSpin->hide();
421     mySmoothOffSliversCheck->hide();
422     myCreateNewNodesCheck->hide();
423   }
424
425   // advanced parameters
426   myAdvGroup = new QWidget();
427   QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup );
428   anAdvLayout->setSpacing( 6 );
429   anAdvLayout->setMargin( 11 );
430   myAdvWidget = new GHS3DPluginGUI_AdvWidget(myAdvGroup);
431   anAdvLayout->addWidget( myAdvWidget);
432
433   myAdvWidget->maxMemoryCheck->setText(tr( "MAX_MEMORY_SIZE" ));
434   myAdvWidget->initialMemoryCheck->setText(tr( "INIT_MEMORY_SIZE" ));
435
436   myAdvWidget->maxMemorySpin->stepBy(10);
437   myAdvWidget->maxMemorySpin->setValue( 128 );
438
439   myAdvWidget->initialMemorySpin->stepBy(10);
440   myAdvWidget->initialMemorySpin->setValue( 100 );
441
442   myAdvWidget->initialMemoryLabel            ->setText (tr( "MEGABYTE" ));
443   myAdvWidget->maxMemoryLabel                ->setText (tr( "MEGABYTE" ));
444
445   myAdvWidget->workingDirectoryLabel         ->setText (tr( "WORKING_DIR" ));
446   myAdvWidget->workingDirectoryPushButton    ->setText (tr( "SELECT_DIR" ));
447   myAdvWidget->keepWorkingFilesCheck         ->setText (tr( "KEEP_WORKING_FILES" ));
448   myAdvWidget->verboseLevelLabel             ->setText (tr( "VERBOSE_LEVEL" ));
449   myAdvWidget->removeLogOnSuccessCheck       ->setText (tr( "REMOVE_LOG_ON_SUCCESS" ));
450   myAdvWidget->logInFileCheck                ->setText (tr( "LOG_IN_FILE" ));
451   
452   myAdvWidget->memoryGroupBox                ->setTitle(tr( "MEMORY_GROUP_TITLE" ));
453   myAdvWidget->logGroupBox                   ->setTitle(tr( "LOG_GROUP_TITLE" ));
454   myAdvWidget->advancedMeshingGroupBox       ->setTitle(tr( "ADVANCED_MESHING_GROUP_TITLE" ));
455   
456   myAdvWidget->createNewNodesCheck           ->setText (tr( "TO_ADD_NODES" ));
457   myAdvWidget->removeInitialCentralPointCheck->setText (tr( "NO_INITIAL_CENTRAL_POINT" ));
458   myAdvWidget->boundaryRecoveryCheck         ->setText (tr( "RECOVERY_VERSION" ));
459   myAdvWidget->FEMCorrectionCheck            ->setText (tr( "FEM_CORRECTION" ));
460   myAdvWidget->gradationLabel                ->setText (tr( "GHS3D_GRADATION" ));
461   myAdvWidget->gradationSpinBox->RangeStepAndValidator(0.0, 5.0, 0.05, "length_precision");
462
463   if ( isOptimization() )
464   {
465     myAdvWidget->createNewNodesCheck->hide();
466     myAdvWidget->removeInitialCentralPointCheck->hide();
467     myAdvWidget->boundaryRecoveryCheck->hide();
468     myAdvWidget->FEMCorrectionCheck->hide();
469     myAdvWidget->gradationLabel->hide();
470     myAdvWidget->gradationSpinBox->hide();
471   }
472
473   // Enforced vertices parameters
474   myEnfGroup = new QWidget();
475   QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup);
476   
477   myEnforcedTableWidget = new QTableWidget(myEnfGroup);
478   myEnforcedTableWidget ->setMinimumWidth(300);
479   myEnforcedTableWidget->setRowCount( 0 );
480   myEnforcedTableWidget->setColumnCount( ENF_VER_NB_COLUMNS );
481   myEnforcedTableWidget->setSortingEnabled(true);
482   myEnforcedTableWidget->setHorizontalHeaderLabels
483     ( QStringList()
484       << tr( "GHS3D_ENF_NAME_COLUMN" ) << tr( "GHS3D_ENF_VER_X_COLUMN" )
485       << tr( "GHS3D_ENF_VER_Y_COLUMN" ) << tr( "GHS3D_ENF_VER_Z_COLUMN" )
486       << tr( "GHS3D_ENF_SIZE_COLUMN" ) << tr("GHS3D_ENF_ENTRY_COLUMN")
487       << tr("GHS3D_ENF_VER_COMPOUND_COLUMN") << tr( "GHS3D_ENF_GROUP_COLUMN" ));
488   myEnforcedTableWidget->verticalHeader()->hide();
489   myEnforcedTableWidget->horizontalHeader()->setStretchLastSection(true);
490   myEnforcedTableWidget->setAlternatingRowColors(true);
491   myEnforcedTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
492   myEnforcedTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
493 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
494   myEnforcedTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
495 #else
496   myEnforcedTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
497 #endif
498   myEnforcedTableWidget->resizeColumnsToContents();
499   myEnforcedTableWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
500   myEnforcedTableWidget->hideColumn(ENF_VER_COMPOUND_COLUMN);
501   
502   myEnforcedTableWidget->setItemDelegate(new EnforcedVertexTableWidgetDelegate());
503   
504   // VERTEX SELECTION
505   TColStd_MapOfInteger shapeTypes;
506   shapeTypes.Add( TopAbs_VERTEX );
507   shapeTypes.Add( TopAbs_COMPOUND );
508
509   SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes);
510   myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true);
511   myEnfVertexWdg->SetDefaultText(tr("GHS3D_ENF_SELECT_VERTEX"), "QLineEdit { color: grey }");
512   
513   QLabel* myXCoordLabel = new QLabel( tr( "GHS3D_ENF_VER_X_LABEL" ), myEnfGroup );
514   myXCoord = new SMESHGUI_SpinBox(myEnfGroup);
515   myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
516   QLabel* myYCoordLabel = new QLabel( tr( "GHS3D_ENF_VER_Y_LABEL" ), myEnfGroup );
517   myYCoord = new SMESHGUI_SpinBox(myEnfGroup);
518   myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
519   QLabel* myZCoordLabel = new QLabel( tr( "GHS3D_ENF_VER_Z_LABEL" ), myEnfGroup );
520   myZCoord = new SMESHGUI_SpinBox(myEnfGroup);
521   myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
522   QLabel* mySizeLabel = new QLabel( tr( "GHS3D_ENF_SIZE_LABEL" ), myEnfGroup );
523   mySizeValue = new SMESHGUI_SpinBox(myEnfGroup);
524   mySizeValue->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
525
526   QLabel* myGroupNameLabel = new QLabel( tr( "GHS3D_ENF_GROUP_LABEL" ), myEnfGroup );
527   myGroupName = new QLineEdit(myEnfGroup);
528
529   addVertexButton = new QPushButton(tr("GHS3D_ENF_ADD"),myEnfGroup);
530   addVertexButton->setEnabled(false);
531   removeVertexButton = new QPushButton(tr("GHS3D_ENF_REMOVE"),myEnfGroup);
532
533   anEnfLayout->addWidget(myEnforcedTableWidget,     ENF_VER_VERTEX, 0, ENF_VER_NB_LINES, 1);
534   
535   QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup);
536   anEnfLayout2->addWidget(myEnfVertexWdg,           ENF_VER_VERTEX, 0, 1, 2);
537   anEnfLayout2->addWidget(myXCoordLabel,            ENF_VER_X_COORD, 0, 1, 1);
538   anEnfLayout2->addWidget(myXCoord,                 ENF_VER_X_COORD, 1, 1, 1);
539   anEnfLayout2->addWidget(myYCoordLabel,            ENF_VER_Y_COORD, 0, 1, 1);
540   anEnfLayout2->addWidget(myYCoord,                 ENF_VER_Y_COORD, 1, 1, 1);
541   anEnfLayout2->addWidget(myZCoordLabel,            ENF_VER_Z_COORD, 0, 1, 1);
542   anEnfLayout2->addWidget(myZCoord,                 ENF_VER_Z_COORD, 1, 1, 1);
543   anEnfLayout2->addWidget(mySizeLabel,              ENF_VER_SIZE, 0, 1, 1);
544   anEnfLayout2->addWidget(mySizeValue,              ENF_VER_SIZE, 1, 1, 1);
545   anEnfLayout2->addWidget(myGroupNameLabel,         ENF_VER_GROUP, 0, 1, 1);
546   anEnfLayout2->addWidget(myGroupName,              ENF_VER_GROUP, 1, 1, 1);
547   anEnfLayout2->addWidget(addVertexButton,          ENF_VER_BTN, 0, 1, 1);
548   anEnfLayout2->addWidget(removeVertexButton,       ENF_VER_BTN, 1, 1, 1);
549   anEnfLayout2->setRowStretch(ENF_VER_NB_LINES, 1);
550   
551   anEnfLayout->addLayout(anEnfLayout2,              ENF_VER_VERTEX, 1,ENF_VER_NB_LINES, 1);
552   anEnfLayout->setRowStretch(ENF_VER_VERTEX, 10);
553   
554
555   // Enforced meshes parameters
556   myEnfMeshGroup = new QWidget();
557   QGridLayout* anEnfMeshLayout = new QGridLayout(myEnfMeshGroup);
558   
559   myEnforcedMeshTableWidget = new QTableWidget(myEnfGroup);
560   myEnforcedMeshTableWidget->setRowCount( 0 );
561   myEnforcedMeshTableWidget->setColumnCount( ENF_MESH_NB_COLUMNS );
562   myEnforcedMeshTableWidget->setSortingEnabled(true);
563   myEnforcedMeshTableWidget->verticalHeader()->hide();
564   QStringList enforcedMeshHeaders;
565   enforcedMeshHeaders << tr( "GHS3D_ENF_NAME_COLUMN" ) 
566                       << tr( "GHS3D_ENF_ENTRY_COLUMN" ) 
567                       << tr( "GHS3D_ENF_MESH_CONSTRAINT_COLUMN" ) 
568                       << tr( "GHS3D_ENF_GROUP_COLUMN" );
569   myEnforcedMeshTableWidget->setHorizontalHeaderLabels(enforcedMeshHeaders);
570   myEnforcedMeshTableWidget->horizontalHeader()->setStretchLastSection(true);
571 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
572   myEnforcedMeshTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
573 #else
574   myEnforcedMeshTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
575 #endif
576   myEnforcedMeshTableWidget->setAlternatingRowColors(true);
577   myEnforcedMeshTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
578   myEnforcedMeshTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
579   myEnforcedMeshTableWidget->resizeColumnsToContents();
580   myEnforcedMeshTableWidget->hideColumn(ENF_MESH_ENTRY_COLUMN);
581   
582   myEnforcedMeshTableWidget->setItemDelegate(new EnforcedMeshTableWidgetDelegate());
583   
584   myEnfMeshWdg = new StdMeshersGUI_ObjectReferenceParamWdg( SMESH::IDSOURCE, myEnfMeshGroup, /*multiSel=*/true);
585   myEnfMeshWdg->SetDefaultText(tr("GHS3D_ENF_SELECT_MESH"), "QLineEdit { color: grey }");
586   
587   myEnfMeshWdg->AvoidSimultaneousSelection(myEnfVertexWdg);
588   
589   QLabel* myMeshConstraintLabel = new QLabel( tr( "GHS3D_ENF_MESH_CONSTRAINT_LABEL" ), myEnfMeshGroup );
590   myEnfMeshConstraint = new QComboBox(myEnfMeshGroup);
591   myEnfMeshConstraint->insertItems(0,myEnfMeshConstraintLabels);
592   myEnfMeshConstraint->setEditable(false);
593   myEnfMeshConstraint->setCurrentIndex(0);
594
595   QLabel* myMeshGroupNameLabel = new QLabel( tr( "GHS3D_ENF_GROUP_LABEL" ), myEnfMeshGroup );
596   myMeshGroupName = new QLineEdit(myEnfMeshGroup);
597
598   addEnfMeshButton = new QPushButton(tr("GHS3D_ENF_ADD"),myEnfMeshGroup);
599   removeEnfMeshButton = new QPushButton(tr("GHS3D_ENF_REMOVE"),myEnfMeshGroup);
600   
601   anEnfMeshLayout->addWidget(myEnforcedMeshTableWidget, ENF_MESH_MESH, 0, ENF_MESH_NB_LINES , 1);
602   
603   QGridLayout* anEnfMeshLayout2 = new QGridLayout(myEnfMeshGroup);
604   anEnfMeshLayout2->addWidget(myEnfMeshWdg,             ENF_MESH_MESH, 0, 1, 2);
605   anEnfMeshLayout2->addWidget(myMeshConstraintLabel,    ENF_MESH_CONSTRAINT, 0, 1, 1);
606   anEnfMeshLayout2->addWidget(myEnfMeshConstraint,      ENF_MESH_CONSTRAINT, 1, 1, 1);
607   anEnfMeshLayout2->addWidget(myMeshGroupNameLabel,     ENF_MESH_GROUP, 0, 1, 1);
608   anEnfMeshLayout2->addWidget(myMeshGroupName,          ENF_MESH_GROUP, 1, 1, 1);
609   anEnfMeshLayout2->addWidget(addEnfMeshButton,         ENF_MESH_BTN, 0, 1, 1);
610   anEnfMeshLayout2->addWidget(removeEnfMeshButton,      ENF_MESH_BTN, 1, 1, 1);
611   anEnfMeshLayout2->setRowStretch(ENF_MESH_NB_LINES, 1);
612   
613   anEnfMeshLayout->addLayout(anEnfMeshLayout2,          ENF_MESH_MESH, 1, ENF_MESH_NB_LINES, 1);
614   anEnfMeshLayout->setRowStretch(ENF_MESH_MESH, 10);
615   
616   // add tabs
617   tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
618   tab->insertTab( ADV_TAB, myAdvGroup, tr( "GHS3D_ADV_ARGS" ) );
619   if ( !isOptimization() )
620   {
621     tab->insertTab( ENF_VER_TAB, myEnfGroup, tr( "GHS3D_ENFORCED_VERTICES" ) );
622     tab->insertTab( ENF_MESH_TAB, myEnfMeshGroup, tr( "GHS3D_ENFORCED_MESHES" ) );
623   }
624   tab->setCurrentIndex( STD_TAB );
625
626   connect( myAdvWidget->maxMemoryCheck,             SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
627   connect( myAdvWidget->initialMemoryCheck,         SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
628   connect( myAdvWidget->boundaryRecoveryCheck,      SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
629   connect( myAdvWidget->logInFileCheck,             SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
630   connect( myAdvWidget->keepWorkingFilesCheck,      SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
631   connect( myAdvWidget->workingDirectoryPushButton, SIGNAL( clicked() ),       this, SLOT( onDirBtnClicked() ) );
632   
633   connect( myEnforcedTableWidget,   SIGNAL( itemClicked(QTableWidgetItem *)), this, SLOT( synchronizeCoords() ) );
634   connect( myEnforcedTableWidget,   SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
635   connect( myEnforcedTableWidget,   SIGNAL( itemSelectionChanged() ),         this, SLOT( synchronizeCoords() ) );
636   connect( addVertexButton,         SIGNAL( clicked()),                       this, SLOT( onAddEnforcedVertex() ) );
637   connect( removeVertexButton,      SIGNAL( clicked()),                       this, SLOT( onRemoveEnforcedVertex() ) );
638   connect( myEnfVertexWdg,          SIGNAL( contentModified()),               this, SLOT( onSelectEnforcedVertex() ) );
639   connect( myEnfVertexWdg,          SIGNAL( contentModified()),              this,  SLOT( checkVertexIsDefined() ) );
640   connect( myXCoord,                SIGNAL( textChanged(const QString&) ),   this,  SLOT( clearEnfVertexSelection() ) );
641   connect( myYCoord,                SIGNAL( textChanged(const QString&) ),   this,  SLOT( clearEnfVertexSelection() ) );
642   connect( myZCoord,                SIGNAL( textChanged(const QString&) ),   this,  SLOT( clearEnfVertexSelection() ) );
643   connect( mySizeValue,             SIGNAL( textChanged(const QString&) ),   this,  SLOT( checkVertexIsDefined() ) );
644   connect( myXCoord,                SIGNAL( valueChanged(const QString&) ),   this,  SLOT( clearEnfVertexSelection() ) );
645   connect( myYCoord,                SIGNAL( valueChanged(const QString&) ),   this,  SLOT( clearEnfVertexSelection() ) );
646   connect( myZCoord,                SIGNAL( valueChanged(const QString&) ),   this,  SLOT( clearEnfVertexSelection() ) );
647   connect( mySizeValue,             SIGNAL( valueChanged(const QString&) ),   this,  SLOT( checkVertexIsDefined() ) );
648   connect( this,                    SIGNAL( vertexDefined(bool) ), addVertexButton, SLOT( setEnabled(bool) ) );
649   
650   connect( addEnfMeshButton,        SIGNAL( clicked()),                       this, SLOT( onAddEnforcedMesh() ) );
651   connect( removeEnfMeshButton,     SIGNAL( clicked()),                       this, SLOT( onRemoveEnforcedMesh() ) );
652   
653   return fr;
654 }
655
656 /** 
657  * This method checks if an enforced vertex is defined;
658  **/
659 void GHS3DPluginGUI_HypothesisCreator::clearEnfVertexSelection()
660 {
661   if (myEnfVertexWdg->NbObjects() != 0) {
662     disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
663     disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
664     myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
665     connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
666     connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
667   }
668   GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
669   that->checkVertexIsDefined();
670 }
671
672 /** 
673  * This method checks if an enforced vertex is defined;
674  **/
675 void GHS3DPluginGUI_HypothesisCreator::checkVertexIsDefined()
676 {
677   bool enfVertexIsDefined = false;
678   enfVertexIsDefined = (!mySizeValue->GetString().isEmpty() &&
679                         (!myEnfVertexWdg->NbObjects() == 0 ||
680                          (myEnfVertexWdg->NbObjects() == 0 && !myXCoord->GetString().isEmpty()
681                           && !myYCoord->GetString().isEmpty()
682                           && !myZCoord->GetString().isEmpty())));
683   emit vertexDefined(enfVertexIsDefined);
684 }
685
686 /** 
687  * This method checks if an enforced mesh is defined;
688  **/
689 void GHS3DPluginGUI_HypothesisCreator::checkEnfMeshIsDefined()
690 {
691   emit enfMeshDefined( myEnfVertexWdg->NbObjects() != 0);
692 }
693
694 /** 
695  * This method resets the content of the X, Y, Z, size and GroupName widgets;
696  **/
697 void GHS3DPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
698 {
699   myXCoord->setCleared(true);
700   myYCoord->setCleared(true);
701   myZCoord->setCleared(true);
702   myXCoord->setText("");
703   myYCoord->setText("");
704   myZCoord->setText("");
705   addVertexButton->setEnabled(false);
706 }
707
708 /** GHS3DPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item)
709     This method updates the tooltip of a modified item. The QLineEdit widgets content
710     is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
711 */
712 void GHS3DPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTableWidgetItem* item)
713 {
714   int row = myEnforcedTableWidget->row(item);
715       
716   QVariant vertexName = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole);
717   QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole);
718   QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole);
719   QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole);
720   QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole);
721   QVariant entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
722   QString groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole).toString();
723   
724   clearEnforcedVertexWidgets();
725   
726   if ( !x.isNull() || !entry.isNull()) {
727     QString toolTip = vertexName.toString();
728     toolTip += QString("(");
729     if (entry.isNull() || (!entry.isNull() && entry.toString() == "")) {
730       toolTip += x.toString();
731       toolTip += QString(", ") + y.toString();
732       toolTip += QString(", ") + z.toString();
733     }
734     else
735       toolTip += entry.toString();
736     toolTip += QString(")");
737     
738     if (!size.isNull())
739       toolTip += QString("=") + size.toString();
740     
741     if (!groupName.isEmpty())
742       toolTip += QString(" [") + groupName + QString("]");
743
744     for (int col=0;col<ENF_VER_NB_COLUMNS;col++)
745       myEnforcedTableWidget->item(row,col)->setToolTip(toolTip);
746
747     if (!x.isNull()) {
748       disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
749       disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
750       disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
751       myXCoord->SetValue(x.toDouble());
752       myYCoord->SetValue(y.toDouble());
753       myZCoord->SetValue(z.toDouble());
754       connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
755       connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
756       connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
757     }
758     if (!size.isNull())
759       mySizeValue->SetValue(size.toDouble());
760     
761     if (!groupName.isEmpty())
762       myGroupName->setText(groupName);
763   }
764 }
765
766 void GHS3DPluginGUI_HypothesisCreator::onSelectEnforcedVertex()
767 {
768   int nbSelEnfVertex = myEnfVertexWdg->NbObjects();
769   clearEnforcedVertexWidgets();
770   if (nbSelEnfVertex == 1)
771   {
772     if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() )
773       return ;
774
775     myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
776     if (myEnfVertex == GEOM::GEOM_Object::_nil())
777       return;
778     if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
779       GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
780       GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( );
781       if (CORBA::is_nil(measureOp))
782         return;
783       
784       CORBA::Double x,y,z;
785       measureOp->PointCoordinates (myEnfVertex, x, y, z);
786       if ( measureOp->IsDone() )
787       {
788         disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
789         disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
790         disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
791         myXCoord->SetValue(x);
792         myYCoord->SetValue(y);
793         myZCoord->SetValue(z);
794         connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
795         connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
796         connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
797       }
798     }
799   }
800 }
801
802 /** GHS3DPluginGUI_HypothesisCreator::synchronizeCoords()
803     This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
804     of the enforced vertex clicked in the tree widget.
805 */
806 void GHS3DPluginGUI_HypothesisCreator::synchronizeCoords()
807 {
808   clearEnforcedVertexWidgets();
809   QList<QTableWidgetItem *> items = myEnforcedTableWidget->selectedItems();
810   disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
811   if (! items.isEmpty()) {
812     QTableWidgetItem *item;
813     int row;
814     QVariant entry;
815     if (items.size() == 1) {
816       item = items[0];
817       row = myEnforcedTableWidget->row(item);
818       QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole);
819       QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole);
820       QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole);
821       QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole);
822       entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
823       if (!entry.isNull()) {
824         SMESH::string_array_var objIds = new SMESH::string_array;
825         objIds->length(1);
826         objIds[0] = entry.toString().toStdString().c_str();
827         myEnfVertexWdg->SetObjects(objIds);
828       }
829       else {
830         myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
831       }
832       QVariant group = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole);
833       if (!x.isNull()/* && entry.isNull()*/) {
834         //         disconnect( myXCoord, SIGNAL( textChanged(const QString &)), this, SLOT( onSelectEnforcedVertex() ) );
835         disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
836         disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
837         disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
838         myXCoord->SetValue(x.toDouble());
839         myYCoord->SetValue(y.toDouble());
840         myZCoord->SetValue(z.toDouble());
841         connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
842         connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
843         connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
844       }
845       if (!size.isNull())
846         mySizeValue->SetValue(size.toDouble());
847       
848       if (!group.isNull() && (!x.isNull() || !entry.isNull()))
849         myGroupName->setText(group.toString());
850     }
851     else {
852       QList<QString> entryList;
853       for (int i = 0; i < items.size(); ++i) {
854         item = items[i];
855         row = myEnforcedTableWidget->row(item);
856         entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
857         if (!entry.isNull())
858           entryList << entry.toString();
859       }
860       if (entryList.size() > 0) {
861         SMESH::string_array_var objIds = new SMESH::string_array;
862         objIds->length(entryList.size());
863         for (int i = 0; i < entryList.size() ; i++)
864           objIds[i] = entryList.at(i).toStdString().c_str();
865         myEnfVertexWdg->SetObjects(objIds);
866       }
867       else {
868         myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
869       }
870     }
871   }
872   else {
873     myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
874   }
875   connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
876   GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
877   that->checkVertexIsDefined();
878 }
879
880 /** GHS3DPluginGUI_HypothesisCreator::addEnforcedMesh( meshName, geomEntry, elemType, size, groupName)
881     This method adds in the tree widget an enforced mesh from mesh, submesh or group with optionally size and and groupName.
882 */
883 void GHS3DPluginGUI_HypothesisCreator::addEnforcedMesh(std::string name,
884                                                        std::string entry,
885                                                        int elementType,
886                                                        std::string groupName)
887 {
888   bool okToCreate = true;
889   QString itemEntry = "";
890   int itemElementType = 0;
891   int rowCount = myEnforcedMeshTableWidget->rowCount();
892   bool allColumns = true;
893   for (int row = 0;row<rowCount;row++) {
894     for (int col = 0 ; col < ENF_MESH_NB_COLUMNS ; col++) {
895       if (col == ENF_MESH_CONSTRAINT_COLUMN){
896         if (qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row, col)) == 0) {
897           allColumns = false;
898           break;
899         }
900       }
901       else if (myEnforcedMeshTableWidget->item(row, col) == 0) {
902         allColumns = false;
903         break;
904       }
905       if (col == ENF_MESH_CONSTRAINT_COLUMN) {
906         QComboBox* itemComboBox = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row, col));
907         itemElementType = itemComboBox->currentIndex();
908       }
909       else if (col == ENF_MESH_ENTRY_COLUMN)
910         itemEntry = myEnforcedMeshTableWidget->item(row, col)->data(Qt::EditRole).toString();
911     }
912     
913     if (!allColumns)
914       break;
915   
916     if (itemEntry == QString(entry.c_str()) && itemElementType == elementType) { 
917       okToCreate = false;
918       break;
919     } // if
920   } // for
921
922     
923   if (!okToCreate)
924     return;
925   
926   myEnforcedMeshTableWidget->setRowCount(rowCount+1);
927   myEnforcedMeshTableWidget->setSortingEnabled(false);
928   
929   for (int col=0;col<ENF_MESH_NB_COLUMNS;col++) {
930     if (col == ENF_MESH_CONSTRAINT_COLUMN) {
931       QComboBox* comboBox = new QComboBox();
932       QPalette pal = comboBox->palette();
933       pal.setColor(QPalette::Button, Qt::white);
934       comboBox->setPalette(pal);
935       comboBox->insertItems(0,myEnfMeshConstraintLabels);
936       comboBox->setEditable(false);
937       comboBox->setCurrentIndex(elementType);
938       myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox);
939     }
940     else {
941       QTableWidgetItem* item = new QTableWidgetItem();
942       item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
943       switch (col) {
944       case ENF_MESH_NAME_COLUMN:
945         item->setData( 0, name.c_str() );
946         item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
947         myEnforcedMeshTableWidget->setItem(rowCount,col,item);
948         break;
949       case ENF_MESH_ENTRY_COLUMN:
950         item->setData( 0, entry.c_str() );
951         item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
952         myEnforcedMeshTableWidget->setItem(rowCount,col,item);
953         break;
954       case ENF_MESH_GROUP_COLUMN:
955         item->setData( 0, groupName.c_str() );
956         myEnforcedMeshTableWidget->setItem(rowCount,col,item);
957         break;
958       default:
959         break;
960       }
961     }
962   }
963   myEnforcedMeshTableWidget->setSortingEnabled(true);
964 }
965
966 /** GHS3DPluginGUI_HypothesisCreator::addEnforcedVertex( x, y, z, size, vertexName, geomEntry, groupName)
967     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.
968 */
969 void GHS3DPluginGUI_HypothesisCreator::addEnforcedVertex(double x, double y, double z, double size, std::string vertexName, std::string geomEntry, std::string groupName, bool isCompound)
970 {
971   myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
972   bool okToCreate = true;
973   double itemX,itemY,itemZ,itemSize = 0;
974   QString itemEntry, itemGroupName = QString("");
975   //   bool itemIsCompound;
976   int rowCount = myEnforcedTableWidget->rowCount();
977   QVariant data;
978   bool allColumns;
979   for (int row = 0;row<rowCount;row++) {
980     allColumns = true;
981     for (int col = 0 ; col < ENF_VER_NB_COLUMNS ; col++) {
982       if (myEnforcedTableWidget->item(row, col) == 0) {
983         allColumns = false;
984         break;
985       }
986       
987       data = myEnforcedTableWidget->item(row, col)->data(Qt::EditRole);
988       if (!data.isNull()) {
989         switch (col) {
990         case ENF_VER_GROUP_COLUMN:
991           itemGroupName = data.toString();
992           break;
993         case ENF_VER_ENTRY_COLUMN:
994           itemEntry = data.toString();
995           break;
996         case ENF_VER_X_COLUMN:
997           itemX = data.toDouble();
998           break;
999         case ENF_VER_Y_COLUMN:
1000           itemY = data.toDouble();
1001           break;
1002         case ENF_VER_Z_COLUMN:
1003           itemZ = data.toDouble();
1004           break;
1005         case ENF_VER_SIZE_COLUMN:
1006           itemSize = data.toDouble();
1007           break;
1008         default:
1009           break;
1010         }
1011       }
1012     }
1013     
1014     if (!allColumns)
1015       break;
1016
1017
1018     if (( !isCompound && ((itemX == x) && (itemY == y) && (itemZ == z))) ||
1019         ( !itemEntry.isEmpty() && ( itemEntry == geomEntry.c_str() )))
1020     {
1021       // update size
1022       if (itemSize != size) {
1023         myEnforcedTableWidget->item(row, ENF_VER_SIZE_COLUMN)->setData( Qt::EditRole, QVariant(size));
1024       }
1025       // update group name
1026       if (itemGroupName.toStdString() != groupName) {
1027         myEnforcedTableWidget->item(row, ENF_VER_GROUP_COLUMN)->setData( Qt::EditRole, QVariant(groupName.c_str()));
1028       }
1029       okToCreate = false;
1030       break;
1031     } // if
1032   } // for
1033   if (!okToCreate) {
1034     if (geomEntry.empty()) {
1035     }
1036     else {
1037     }
1038     return;
1039   }
1040     
1041   int vertexIndex=0;
1042   int indexRef = -1;
1043   QString myVertexName;
1044   while(indexRef != vertexIndex) {
1045     indexRef = vertexIndex;
1046     if (vertexName.empty())
1047       myVertexName = QString("Vertex #%1").arg(vertexIndex);
1048     else
1049       myVertexName = QString(vertexName.c_str());
1050
1051     for (int row = 0;row<rowCount;row++) {
1052       QString name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString();
1053       if (myVertexName == name) {
1054         vertexIndex++;
1055         break;
1056       }
1057     }
1058   }
1059   
1060   myEnforcedTableWidget->setRowCount(rowCount+1);
1061   myEnforcedTableWidget->setSortingEnabled(false);
1062   for (int col=0;col<ENF_VER_NB_COLUMNS;col++) {
1063     QTableWidgetItem* item = new QTableWidgetItem();
1064     item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1065     switch (col) {
1066     case ENF_VER_NAME_COLUMN:
1067       item->setData( Qt::EditRole, myVertexName );
1068       if (!geomEntry.empty()) {
1069         if (isCompound)
1070           item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1071         else
1072           item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1073       }
1074       break;
1075     case ENF_VER_X_COLUMN:
1076       if (!isCompound)
1077         item->setData( 0, QVariant(x) );
1078       break;
1079     case ENF_VER_Y_COLUMN:
1080       if (!isCompound)
1081         item->setData( 0, QVariant(y) );
1082       break;
1083     case ENF_VER_Z_COLUMN:
1084       if (!isCompound)
1085         item->setData( 0, QVariant(z) );
1086       break;
1087     case ENF_VER_SIZE_COLUMN:
1088       item->setData( 0, QVariant(size) );
1089       break;
1090     case ENF_VER_ENTRY_COLUMN:
1091       if (!geomEntry.empty())
1092         item->setData( 0, QString(geomEntry.c_str()) );
1093       break;
1094     case ENF_VER_COMPOUND_COLUMN:
1095       item->setData( Qt::CheckStateRole, isCompound );
1096       item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
1097       break;
1098     case ENF_VER_GROUP_COLUMN:
1099       if (!groupName.empty())
1100         item->setData( 0, QString(groupName.c_str()) );
1101       break;
1102     default:
1103       break;
1104     }
1105     
1106     myEnforcedTableWidget->setItem(rowCount,col,item);
1107   }
1108
1109   connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this,  SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1110   
1111   myEnforcedTableWidget->setSortingEnabled(true);
1112   //   myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1113   updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1114 }
1115
1116 /** GHS3DPluginGUI_HypothesisCreator::onAddEnforcedMesh()
1117     This method is called when a item is added into the enforced meshes tree widget
1118 */
1119 void GHS3DPluginGUI_HypothesisCreator::onAddEnforcedMesh()
1120 {
1121   GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
1122   
1123   that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1124   myEnfMeshWdg->deactivateSelection();
1125
1126   for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column)
1127     myEnforcedMeshTableWidget->resizeColumnToContents(column);
1128
1129   // Vertex selection
1130   int selEnfMeshes = myEnfMeshWdg->NbObjects();
1131   if (selEnfMeshes == 0)
1132     return;
1133
1134   std::string groupName = myMeshGroupName->text().simplified().toStdString();
1135   
1136   int elementType = myEnfMeshConstraint->currentIndex();
1137   
1138   
1139   _PTR(Study) aStudy = SMESH::getStudy();
1140   _PTR(SObject) aSObj;
1141   QString meshEntry = myEnfMeshWdg->GetValue();
1142   
1143   if (selEnfMeshes == 1)
1144   {
1145     aSObj = aStudy->FindObjectID(meshEntry.toStdString().c_str());
1146     CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj);
1147     if (!CORBA::is_nil(anObj)) {
1148       addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
1149     }
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);
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( );
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( data.myMaximumMemory,
1369                                                                       (float)myAdvWidget->maxMemorySpin->minimum() ));
1370   myAdvWidget->initialMemoryCheck             ->setChecked    ( data.myInitialMemory > 0 );
1371   myAdvWidget->initialMemorySpin              ->setValue      ( qMax( data.myInitialMemory,
1372                                                                       (float)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   else // avoid "Conditional jump or move depends on uninitialised value" error
1580   {
1581     h_data.myOptimization         = 1;
1582     h_data.mySplitOverConstrained = 1;
1583     h_data.myPThreadsMode         = 1;
1584     h_data.myNumberOfThreads      = 1;
1585     h_data.mySmoothOffSlivers     = 1;
1586   }
1587   h_data.myToMeshHoles                = h->GetToMeshHoles();
1588   h_data.myToMakeGroupsOfDomains      = h->GetToMakeGroupsOfDomains();
1589   h_data.myMaximumMemory              = h->GetMaximumMemory();
1590   h_data.myInitialMemory              = h->GetInitialMemory();
1591   h_data.myInitialMemory              = h->GetInitialMemory();
1592   h_data.myOptimizationLevel          = h->GetOptimizationLevel();
1593   h_data.myKeepFiles                  = h->GetKeepFiles();
1594   h_data.myWorkingDir                 = h->GetWorkingDirectory();
1595   h_data.myVerboseLevel               = h->GetVerboseLevel();
1596   h_data.myToCreateNewNodes           = h->GetToCreateNewNodes();
1597   h_data.myRemoveInitialCentralPoint  = h->GetToRemoveCentralPoint();
1598   h_data.myBoundaryRecovery           = h->GetToUseBoundaryRecoveryVersion();
1599   h_data.myFEMCorrection              = h->GetFEMCorrection();
1600   h_data.myGradation                  = h->GetGradation();
1601   h_data.myTextOption                 = h->GetAdvancedOption();
1602   h_data.myLogInStandardOutput        = h->GetStandardOutputLog();
1603   h_data.myRemoveLogOnSuccess         = h->GetRemoveLogOnSuccess();
1604   
1605   GHS3DPlugin::GHS3DEnforcedVertexList_var vertices = h->GetEnforcedVertices();
1606   h_data.myEnforcedVertices.clear();
1607   for (CORBA::ULong i=0 ; i<vertices->length() ; i++) {
1608     TEnfVertex* myVertex = new TEnfVertex();
1609     myVertex->name = CORBA::string_dup(vertices[i].name.in());
1610     myVertex->geomEntry = CORBA::string_dup(vertices[i].geomEntry.in());
1611     myVertex->groupName = CORBA::string_dup(vertices[i].groupName.in());
1612     myVertex->size = vertices[i].size;
1613     myVertex->isCompound = vertices[i].isCompound;
1614     if (vertices[i].coords.length()) {
1615       for (CORBA::ULong c = 0; c < vertices[i].coords.length() ; c++)
1616         myVertex->coords.push_back(vertices[i].coords[c]);
1617     }
1618     h_data.myEnforcedVertices.insert(myVertex);
1619   }
1620   
1621   GHS3DPlugin::GHS3DEnforcedMeshList_var enfMeshes = h->GetEnforcedMeshes();
1622   h_data.myEnforcedMeshes.clear();
1623   for (CORBA::ULong i=0 ; i<enfMeshes->length() ; i++) {
1624     TEnfMesh* myEnfMesh = new TEnfMesh();
1625     myEnfMesh->name = CORBA::string_dup(enfMeshes[i].name.in());
1626     myEnfMesh->entry = CORBA::string_dup(enfMeshes[i].entry.in());
1627     myEnfMesh->groupName = CORBA::string_dup(enfMeshes[i].groupName.in());
1628     switch (enfMeshes[i].elementType) {
1629     case SMESH::NODE:
1630       myEnfMesh->elementType = 0;
1631       break;
1632     case SMESH::EDGE:
1633       myEnfMesh->elementType = 1;
1634       break;
1635     case SMESH::FACE:
1636       myEnfMesh->elementType = 2;
1637       break;
1638     default:
1639       break;
1640     }
1641     //     myEnfMesh->elementType = enfMeshes[i].elementType;
1642     h_data.myEnforcedMeshes.insert(myEnfMesh);
1643   }
1644   return true;
1645 }
1646
1647 bool GHS3DPluginGUI_HypothesisCreator::storeParamsToHypo( const GHS3DHypothesisData& h_data ) const
1648 {
1649   GHS3DPlugin::GHS3DPlugin_Hypothesis_var h =
1650     GHS3DPlugin::GHS3DPlugin_Hypothesis::_narrow( hypothesis() );
1651   GHS3DPlugin::GHS3DPlugin_OptimizerHypothesis_var opt =
1652     GHS3DPlugin::GHS3DPlugin_OptimizerHypothesis::_narrow( initParamsHypothesis() );
1653
1654   bool ok = true;
1655   try
1656   {
1657     if( isCreation() )
1658       SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
1659
1660     if ( h->GetToMeshHoles() != h_data.myToMeshHoles ) // avoid duplication of DumpPython commands
1661       h->SetToMeshHoles      ( h_data.myToMeshHoles       );
1662     if ( h->GetToMakeGroupsOfDomains() != h_data.myToMakeGroupsOfDomains )
1663       h->SetToMakeGroupsOfDomains( h_data.myToMakeGroupsOfDomains );
1664     if ( h->GetMaximumMemory() != h_data.myMaximumMemory )
1665       h->SetMaximumMemory    ( h_data.myMaximumMemory     );
1666     if ( h->GetInitialMemory() != h_data.myInitialMemory )
1667       h->SetInitialMemory    ( h_data.myInitialMemory     );
1668     if ( h->GetInitialMemory() != h_data.myInitialMemory )
1669       h->SetInitialMemory    ( h_data.myInitialMemory     );
1670     if ( h->GetOptimizationLevel() != h_data.myOptimizationLevel )
1671       h->SetOptimizationLevel( h_data.myOptimizationLevel );
1672     if ( h->GetKeepFiles() != h_data.myKeepFiles         )
1673       h->SetKeepFiles        ( h_data.myKeepFiles         );
1674     if ( h->GetWorkingDirectory() != h_data.myWorkingDir )
1675       h->SetWorkingDirectory ( h_data.myWorkingDir.toLatin1().constData() );
1676     if ( h->GetVerboseLevel() != h_data.myVerboseLevel   )
1677       h->SetVerboseLevel     ( h_data.myVerboseLevel      );
1678     if ( h->GetToCreateNewNodes() != h_data.myToCreateNewNodes )
1679       h->SetToCreateNewNodes( h_data.myToCreateNewNodes   );
1680     if ( h->GetToRemoveCentralPoint() != h_data.myRemoveInitialCentralPoint )
1681       h->SetToRemoveCentralPoint( h_data.myRemoveInitialCentralPoint );
1682     if ( h->GetToUseBoundaryRecoveryVersion() != h_data.myBoundaryRecovery )
1683       h->SetToUseBoundaryRecoveryVersion( h_data.myBoundaryRecovery );
1684     if ( h->GetFEMCorrection() != h_data.myFEMCorrection )
1685       h->SetFEMCorrection    ( h_data.myFEMCorrection     );
1686     if ( h->GetGradation() != h_data.myGradation         )
1687       h->SetGradation        ( h_data.myGradation         );
1688     if ( h->GetAdvancedOption() != h_data.myTextOption       )
1689       h->SetAdvancedOption       ( h_data.myTextOption.toLatin1().constData() );
1690     if ( h->GetStandardOutputLog() != h_data.myLogInStandardOutput   )
1691       h->SetStandardOutputLog( h_data.myLogInStandardOutput  );
1692     if ( h->GetRemoveLogOnSuccess() != h_data.myRemoveLogOnSuccess   )
1693       h->SetRemoveLogOnSuccess( h_data.myRemoveLogOnSuccess  );
1694
1695     if ( !opt->_is_nil() )
1696     {
1697       opt->SetOptimization          ( (GHS3DPlugin::Mode) h_data.myOptimization );
1698       opt->SetSplitOverConstrained  ( (GHS3DPlugin::Mode) h_data.mySplitOverConstrained );
1699       opt->SetPThreadsMode          ( (GHS3DPlugin::PThreadsMode) h_data.myPThreadsMode );
1700       opt->SetSmoothOffSlivers      ( h_data.mySmoothOffSlivers );
1701       opt->SetMaximalNumberOfThreads( h_data.myNumberOfThreads );
1702     }
1703
1704     // Enforced vertices
1705     GHS3DPlugin::GHS3DEnforcedVertexList_var vertexHyp = h->GetEnforcedVertices();
1706     int nbVertexHyp = vertexHyp->length();
1707
1708     // 1. Clear all enforced vertices in hypothesis
1709     // 2. Add new enforced vertex according to h_data
1710     if ( nbVertexHyp > 0)
1711       h->ClearEnforcedVertices();
1712
1713     TEnfVertexList::const_iterator it;
1714     double x = 0, y = 0, z = 0;
1715     for(it = h_data.myEnforcedVertices.begin() ; it != h_data.myEnforcedVertices.end(); it++ ) {
1716       TEnfVertex* enfVertex = (*it);
1717       x =y =z = 0;
1718       if (enfVertex->coords.size()) {
1719         x = enfVertex->coords.at(0);
1720         y = enfVertex->coords.at(1);
1721         z = enfVertex->coords.at(2);
1722       }
1723       ok = h->p_SetEnforcedVertex( enfVertex->size, x, y, z, enfVertex->name.c_str(), enfVertex->geomEntry.c_str(), enfVertex->groupName.c_str(), enfVertex->isCompound);
1724     } // for
1725
1726     // Enforced Meshes
1727     GHS3DPlugin::GHS3DEnforcedMeshList_var enfMeshListHyp = h->GetEnforcedMeshes();
1728     int nbEnfMeshListHyp = enfMeshListHyp->length();
1729
1730     // 1. Clear all enforced vertices in hypothesis
1731     // 2. Add new enforced vertex according to h_data
1732     if ( nbEnfMeshListHyp > 0)
1733       h->ClearEnforcedMeshes();
1734
1735     TEnfMeshList::const_iterator itEnfMesh;
1736
1737     _PTR(Study) aStudy = SMESH::getStudy();
1738
1739     for(itEnfMesh = h_data.myEnforcedMeshes.begin() ; itEnfMesh != h_data.myEnforcedMeshes.end(); itEnfMesh++ ) {
1740       TEnfMesh* enfMesh = (*itEnfMesh);
1741
1742       _PTR(SObject) aSObj = aStudy->FindObjectID(enfMesh->entry.c_str());
1743       SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1744
1745       SMESH::ElementType elementType;
1746       switch(enfMesh->elementType) {
1747       case 0:
1748         elementType = SMESH::NODE;
1749         break;
1750       case 1:
1751         elementType = SMESH::EDGE;
1752         break;
1753       case 2:
1754         elementType = SMESH::FACE;
1755         break;
1756       default:
1757         break;
1758       }
1759     
1760       ok = h->p_SetEnforcedMesh(theSource, elementType, enfMesh->name.c_str(), enfMesh->groupName.c_str());
1761     } // for
1762   } // try
1763   catch ( const SALOME::SALOME_Exception& ex )
1764   {
1765     SalomeApp_Tools::QtCatchCorbaException( ex );
1766     ok = false;
1767   }
1768   return ok;
1769 }
1770
1771 bool GHS3DPluginGUI_HypothesisCreator::readParamsFromWidgets( GHS3DHypothesisData& h_data ) const
1772 {
1773   h_data.myName                       = myName ? myName->text() : "";
1774   h_data.myToMeshHoles                = myToMeshHolesCheck->isChecked();
1775   h_data.myToMakeGroupsOfDomains      = myToMakeGroupsOfDomains->isChecked();
1776   h_data.myOptimization               = myOptimizationCombo->currentIndex();
1777   h_data.myOptimizationLevel          = myOptimizationLevelCombo->currentIndex();
1778   h_data.mySplitOverConstrained       = mySplitOverConstrainedCombo->currentIndex();
1779   h_data.myPThreadsMode               = myPThreadsModeCombo->currentIndex();
1780   h_data.myNumberOfThreads            = myNumberOfThreadsSpin->value();
1781   h_data.mySmoothOffSlivers           = mySmoothOffSliversCheck->isChecked();
1782   h_data.myMaximumMemory              = myAdvWidget->maxMemoryCheck->isChecked() ? myAdvWidget->maxMemorySpin->value() : -1;
1783   h_data.myInitialMemory              = myAdvWidget->initialMemoryCheck->isChecked() ? myAdvWidget->initialMemorySpin->value() : -1;
1784   h_data.myKeepFiles                  = myAdvWidget->keepWorkingFilesCheck->isChecked();
1785   h_data.myWorkingDir                 = myAdvWidget->workingDirectoryLineEdit->text().trimmed();
1786   h_data.myVerboseLevel               = myAdvWidget->verboseLevelSpin->value();
1787   h_data.myRemoveInitialCentralPoint  = myAdvWidget->removeInitialCentralPointCheck->isChecked();
1788   h_data.myBoundaryRecovery           = myAdvWidget->boundaryRecoveryCheck->isChecked();
1789   h_data.myFEMCorrection              = myAdvWidget->FEMCorrectionCheck->isChecked();
1790   h_data.myGradation                  = myAdvWidget->gradationSpinBox->value();
1791   h_data.myTextOption                 = myAdvWidget->advOptionTable->GetCustomOptions();
1792   h_data.myLogInStandardOutput        = !myAdvWidget->logInFileCheck->isChecked();
1793   h_data.myRemoveLogOnSuccess         = myAdvWidget->removeLogOnSuccessCheck->isChecked();
1794   if ( isOptimization() )
1795     h_data.myToCreateNewNodes         = myCreateNewNodesCheck->isChecked();
1796   else
1797     h_data.myToCreateNewNodes         = myAdvWidget->createNewNodesCheck->isChecked();
1798   
1799   // Enforced vertices
1800   h_data.myEnforcedVertices.clear();
1801   QVariant valueX, valueY, valueZ;
1802   for (int row=0 ; row<myEnforcedTableWidget->rowCount() ; row++)
1803   {
1804     TEnfVertex *myVertex = new TEnfVertex();
1805     myVertex->name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString();
1806     myVertex->geomEntry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString();
1807     myVertex->groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
1808     valueX = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data(Qt::EditRole);
1809     valueY = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data(Qt::EditRole);
1810     valueZ = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data(Qt::EditRole);
1811     if (!valueX.isNull() && !valueY.isNull() && !valueZ.isNull()) {
1812       myVertex->coords.push_back(valueX.toDouble());
1813       myVertex->coords.push_back(valueY.toDouble());
1814       myVertex->coords.push_back(valueZ.toDouble());
1815     }
1816     myVertex->size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data(Qt::EditRole).toDouble();
1817     myVertex->isCompound = myEnforcedTableWidget->item(row,ENF_VER_COMPOUND_COLUMN)->data(Qt::CheckStateRole).toBool();
1818     h_data.myEnforcedVertices.insert(myVertex);
1819   }
1820   
1821   // Enforced meshes
1822   h_data.myEnforcedMeshes.clear();
1823
1824   for (int row=0 ; row<myEnforcedMeshTableWidget->rowCount() ; row++)
1825   {
1826     TEnfMesh *myEnfMesh = new TEnfMesh();
1827     myEnfMesh->name = myEnforcedMeshTableWidget->item(row,ENF_MESH_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString();
1828     myEnfMesh->entry = myEnforcedMeshTableWidget->item(row,ENF_MESH_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString();
1829     myEnfMesh->groupName = myEnforcedMeshTableWidget->item(row,ENF_MESH_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
1830     QComboBox* combo = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row,ENF_MESH_CONSTRAINT_COLUMN));
1831     myEnfMesh->elementType = combo->currentIndex();
1832     h_data.myEnforcedMeshes.insert(myEnfMesh);
1833   }
1834
1835   return true;
1836 }
1837
1838 QString GHS3DPluginGUI_HypothesisCreator::caption() const
1839 {
1840   return tr( "GHS3D_TITLE" );
1841 }
1842
1843 QPixmap GHS3DPluginGUI_HypothesisCreator::icon() const
1844 {
1845   return SUIT_Session::session()->resourceMgr()->loadPixmap( "GHS3DPlugin", tr( "ICON_DLG_GHS3D_PARAMETERS" ) );
1846 }
1847
1848 QString GHS3DPluginGUI_HypothesisCreator::type() const
1849 {
1850   return tr( isOptimization() ? "GHS3D_OPTIMIZATIOL_HYPOTHESIS" : "GHS3D_HYPOTHESIS" );
1851 }
1852
1853 QString GHS3DPluginGUI_HypothesisCreator::helpPage() const
1854 {
1855   return isOptimization() ? "optimization_page.html" : "ghs3d_hypo_page.html";
1856 }