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