1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : HYBRIDPluginGUI_HypothesisCreator.cxx
22 // Author : Christian VAN WAMBEKE (CEA)
25 #include "HYBRIDPluginGUI_HypothesisCreator.h"
26 #include "HYBRIDPluginGUI_Enums.h"
27 #include "HYBRIDPluginGUI_Dlg.h"
29 #include <GeometryGUI.h>
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>
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>
47 #include <TopoDS_Iterator.hxx>
53 #include <QVBoxLayout>
54 #include <QGridLayout>
59 #include <QPushButton>
63 #include <QTableWidget>
64 #include <QTableWidgetItem>
65 #include <QHeaderView>
68 #include <utilities.h>
70 #include <boost/algorithm/string.hpp>
75 // #include <windows.h>
77 // #include <sys/sysinfo.h>
80 // int maxAvailableMemory()
83 // // See http://msdn.microsoft.com/en-us/library/aa366589.aspx
84 // MEMORYSTATUSEX statex;
85 // statex.dwLength = sizeof (statex);
86 // int err = GlobalMemoryStatusEx (&statex);
89 // statex.ullTotalPhys / 1024 / 1024 +
90 // statex.ullTotalPageFile / 1024 / 1024 +
91 // statex.ullTotalVirtual / 1024 / 1024;
92 // return (int) ( 0.7 * totMB );
96 // int err = sysinfo( &si );
99 // si.totalram * si.mem_unit / 1024 / 1024 +
100 // si.totalswap * si.mem_unit / 1024 / 1024 ;
101 // return (int) ( 0.7 * totMB );
109 // BEGIN EnforcedVertexTableWidgetDelegate
112 EnforcedVertexTableWidgetDelegate::EnforcedVertexTableWidgetDelegate(QObject *parent)
113 : QItemDelegate(parent)
117 QWidget *EnforcedVertexTableWidgetDelegate::createEditor(QWidget *parent,
118 const QStyleOptionViewItem & option ,
119 const QModelIndex & index ) const
121 QModelIndex father = index.parent();
122 QString entry = father.child(index.row(), ENF_VER_ENTRY_COLUMN).data().toString();
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");
132 editor->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
133 editor->setReadOnly(!entry.isEmpty());
134 editor->setDisabled(!entry.isEmpty());
137 // else if (index.column() == ENF_VER_COMPOUND_COLUMN) {
138 // QCheckBox *editor = new QCheckBox(parent);
139 // editor->setDisabled(!entry.isEmpty());
142 else if (index.column() == ENF_VER_GROUP_COLUMN ||
143 index.column() == ENF_VER_NAME_COLUMN) {
145 QLineEdit *editor = new QLineEdit(parent);
146 if (index.column() != ENF_VER_GROUP_COLUMN) {
147 editor->setReadOnly(!entry.isEmpty());
148 editor->setDisabled(!entry.isEmpty());
152 return QItemDelegate::createEditor(parent, option, index);
155 void EnforcedVertexTableWidgetDelegate::setEditorData(QWidget *editor,
156 const QModelIndex &index) const
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)
163 SMESHGUI_SpinBox *lineEdit = qobject_cast<SMESHGUI_SpinBox*>(editor);
164 lineEdit->SetValue(index.data().toDouble());
166 else if (index.column() == ENF_VER_COMPOUND_COLUMN) {
167 QCheckBox *checkBox = qobject_cast<QCheckBox*>(editor);
168 checkBox->setChecked(index.data().toBool());
171 QItemDelegate::setEditorData(editor, index);
175 void EnforcedVertexTableWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
176 const QModelIndex &index) const
178 QModelIndex parent = index.parent();
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();
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);
190 else if (index.column() == ENF_VER_SIZE_COLUMN)
192 SMESHGUI_SpinBox *lineEdit = qobject_cast<SMESHGUI_SpinBox*>(editor);
193 const double newsize = lineEdit->GetValue();
195 model->setData(index, newsize, Qt::EditRole);
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);
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);
209 else if (index.column() == ENF_VER_COMPOUND_COLUMN) {
210 QCheckBox *checkBox = qobject_cast<QCheckBox*>(editor);
211 model->setData(index, checkBox->isChecked(), Qt::CheckStateRole);
214 QItemDelegate::setModelData(editor, model, index);
218 void EnforcedVertexTableWidgetDelegate::updateEditorGeometry(QWidget *editor,
219 const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
221 editor->setGeometry(option.rect);
224 bool EnforcedVertexTableWidgetDelegate::vertexExists(QAbstractItemModel *model,
225 const QModelIndex &index,
229 QModelIndex parent = index.parent();
230 int row = index.row();
231 int col = index.column();
233 if (parent.isValid() && !value.isEmpty()) {
234 if (col == ENF_VER_X_COLUMN || col == ENF_VER_Y_COLUMN || col == ENF_VER_Z_COLUMN) {
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();
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();
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();
251 int nbChildren = model->rowCount(parent);
252 for (int i = 0 ; i < nbChildren ; i++) {
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)) {
264 else if (col == ENF_VER_NAME_COLUMN) {
265 QString name = parent.child(row, ENF_VER_NAME_COLUMN).data().toString();
275 // END EnforcedVertexTableWidgetDelegate
279 // BEGIN EnforcedMeshTableWidgetDelegate
282 EnforcedMeshTableWidgetDelegate::EnforcedMeshTableWidgetDelegate(QObject *parent)
283 : QItemDelegate(parent)
287 QWidget *EnforcedMeshTableWidgetDelegate::createEditor(QWidget *parent,
288 const QStyleOptionViewItem & option ,
289 const QModelIndex & index ) const
291 return QItemDelegate::createEditor(parent, option, index);
294 void EnforcedMeshTableWidgetDelegate::setEditorData(QWidget *editor,
295 const QModelIndex &index) const
297 QItemDelegate::setEditorData(editor, index);
300 void EnforcedMeshTableWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
301 const QModelIndex &index) const
303 QItemDelegate::setModelData(editor, model, index);
307 void EnforcedMeshTableWidgetDelegate::updateEditorGeometry(QWidget *editor,
308 const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
310 editor->setGeometry(option.rect);
313 // bool EnforcedMeshTableWidgetDelegate::enfMeshExists(QAbstractItemModel *model,
314 // const QModelIndex &index,
315 // QString value) const
317 // bool exists = false;
318 // QModelIndex parent = index.parent();
319 // int row = index.row();
320 // int col = index.column();
325 // END EnforcedMeshTableWidgetDelegate
329 HYBRIDPluginGUI_HypothesisCreator::HYBRIDPluginGUI_HypothesisCreator( const QString& theHypType )
330 : SMESHGUI_GenericHypothesisCreator( theHypType )
332 GeomToolSelected = NULL;
333 GeomToolSelected = getGeomSelectionTool();
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");
341 HYBRIDPluginGUI_HypothesisCreator::~HYBRIDPluginGUI_HypothesisCreator()
343 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
344 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
345 myEnfMeshWdg->deactivateSelection();
349 * \brief {Get or create the geom selection tool for active study}
351 GeomSelectionTools* HYBRIDPluginGUI_HypothesisCreator::getGeomSelectionTool()
353 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
354 if (that->GeomToolSelected == NULL) {
355 that->GeomToolSelected = new GeomSelectionTools();
357 return that->GeomToolSelected;
360 GEOM::GEOM_Gen_var HYBRIDPluginGUI_HypothesisCreator::getGeomEngine()
362 return GeometryGUI::GetGeomGen();
365 QFrame* HYBRIDPluginGUI_HypothesisCreator::buildFrame()
367 QFrame* fr = new QFrame( 0 );
368 QVBoxLayout* lay = new QVBoxLayout( fr );
370 lay->setSpacing( 0 );
373 QTabWidget* tab = new QTabWidget( fr );
374 tab->setTabShape( QTabWidget::Rounded );
375 tab->setTabPosition( QTabWidget::North );
376 lay->addWidget( tab );
379 myStdGroup = new QWidget();
380 QGridLayout* aStdLayout = new QGridLayout( myStdGroup );
381 aStdLayout->setSpacing( 6 );
382 aStdLayout->setMargin( 11 );
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 );
393 myToMeshHolesCheck = new QCheckBox( tr( "HYBRID_TO_MESH_HOLES" ), myStdGroup );
394 //aStdLayout->addWidget( myToMeshHolesCheck, row, 0, 1, 1 ); #stay, not view, may be used tomorrow...
395 myToMeshHolesCheck->hide();
396 myToMakeGroupsOfDomains = new QCheckBox( tr( "HYBRID_TO_MAKE_DOMAIN_GROUPS" ), myStdGroup );
397 //aStdLayout->addWidget( myToMakeGroupsOfDomains, row++, 1, 1, 1 ); #stay, not view, may be used tomorrow...
398 myToMakeGroupsOfDomains->hide();
399 //aStdLayout->addWidget( new QLabel( tr( "HYBRID_OPTIMIZATIOL_LEVEL" ), myStdGroup ), row, 0, 1, 1 );
400 myOptimizationLevelCombo = new QComboBox( myStdGroup );
401 //aStdLayout->addWidget( myOptimizationLevelCombo, row++, 1, 1, 1 ); #stay, not view, may be used tomorrow...
402 myOptimizationLevelCombo->hide();
405 types << tr( "LEVEL_NONE" ) << tr( "LEVEL_LIGHT" ) << tr( "LEVEL_MEDIUM" ) << tr( "LEVEL_STANDARDPLUS" ) << tr( "LEVEL_STRONG" );
406 myOptimizationLevelCombo->addItems( types );
408 QLabel* aLabel = new QLabel( tr( "HYBRID_BOUNDARY_LAYERS_GROWTH" ), myStdGroup );
409 aLabel->setToolTip(tr( "HYBRID_BOUNDARY_LAYERS_HELP" ));
410 aStdLayout->addWidget( aLabel, row, 0, 1, 1 );
411 myBoundaryLayersGrowthCombo = new QComboBox( myStdGroup );
412 myBoundaryLayersGrowthCombo->setToolTip(tr( "HYBRID_BOUNDARY_LAYERS_HELP" ));
414 aStdLayout->addWidget( myBoundaryLayersGrowthCombo, row++, 1, 1, 1 );
416 QStringList typesBoundaryLayersGrowth;
417 typesBoundaryLayersGrowth << tr( "HYBRID_LAYER_GROWTH_DOWNWARD" ) << tr( "HYBRID_LAYER_GROWTH_UPWARD" );
418 myBoundaryLayersGrowthCombo->addItems( typesBoundaryLayersGrowth );
420 aStdLayout->addWidget( new QLabel( tr( "HYBRID_HeightFirstLayer" ), myStdGroup ), row, 0, 1, 1 );
421 myHeightFirstLayerSpin = new SMESHGUI_SpinBox( myStdGroup );
422 myHeightFirstLayerSpin->RangeStepAndValidator(0., 100., .1, "HeightFirstLayer");
423 aStdLayout->addWidget( myHeightFirstLayerSpin, row++, 1, 1, 1 );
425 aStdLayout->addWidget( new QLabel( tr( "HYBRID_NbOfBoundaryLayers" ), myStdGroup ), row, 0, 1, 1 );
426 myNbOfBoundaryLayersSpin = new QSpinBox( myStdGroup );
427 aStdLayout->addWidget( myNbOfBoundaryLayersSpin, row++, 1, 1, 1 );
429 aStdLayout->addWidget( new QLabel( tr( "HYBRID_BoundaryLayersProgression" ), myStdGroup ), row, 0, 1, 1 );
430 myBoundaryLayersProgressionSpin = new SMESHGUI_SpinBox( myStdGroup );
431 myBoundaryLayersProgressionSpin->RangeStepAndValidator(0., 10., .1, "BoundaryLayersProgression");
432 aStdLayout->addWidget( myBoundaryLayersProgressionSpin, row++, 1, 1, 1 );
434 aStdLayout->addWidget( new QLabel( tr( "COLLISION_MODE" ), myStdGroup ), row, 0, 1, 1 );
435 myCollisionModeCombo = new QComboBox( myStdGroup );
436 aStdLayout->addWidget( myCollisionModeCombo, row++, 1, 1, 1 );
438 QStringList typescoll;
439 typescoll << tr( "COLLISION_DECREASE" ) << tr( "COLLISION_STOP" );
440 myCollisionModeCombo->addItems( typescoll );
442 aStdLayout->addWidget( new QLabel( tr( "HYBRID_GENERATION_ELEMENT" ), myStdGroup ), row, 0, 1, 1 );
443 myElementGenerationCombo = new QComboBox( myStdGroup );
444 aStdLayout->addWidget( myElementGenerationCombo, row++, 1, 1, 1 );
446 QStringList typesElementGeneration;
447 typesElementGeneration << tr( "HYBRID_GENERATION_TETRA_DOMINANT" ) << tr( "HYBRID_GENERATION_HEXA_DOMINANT" ) << tr( "HYBRID_GENERATION_CARTESIAN_CORE" );
448 myElementGenerationCombo->addItems( typesElementGeneration );
450 aStdLayout->addWidget( new QLabel( tr( "HYBRID_CORE_SIZE" ), myStdGroup ), row, 0, 1, 1 );
451 myCoreSizeSpin = new SMESHGUI_SpinBox( myStdGroup );
452 myCoreSizeSpin->RangeStepAndValidator(0., COORD_MAX, 10., "length_precision");
453 aStdLayout->addWidget( myCoreSizeSpin, row++, 1, 1, 1 );
455 myAddMultinormalsCheck = new QCheckBox( tr( "HYBRID_ADD_MULTINORMALS" ), myStdGroup );
456 aStdLayout->addWidget( myAddMultinormalsCheck, row++, 0, 1, 1 );
458 aStdLayout->addWidget( new QLabel( tr( "HYBRID_MULTINORMAL_ANGLE" ), myStdGroup ), row, 0, 1, 1 );
459 myMultinormalsAngleSpin = new SMESHGUI_SpinBox( myStdGroup );
460 myMultinormalsAngleSpin->RangeStepAndValidator(0., 90., 2., "threshold");
461 aStdLayout->addWidget( myMultinormalsAngleSpin, row++, 1, 1, 1 );
463 mySmoothNormalsCheck = new QCheckBox( tr( "HYBRID_SMOOTH_NORMALS" ), myStdGroup );
464 aStdLayout->addWidget( mySmoothNormalsCheck, row++, 0, 1, 1 );
465 aStdLayout->setRowStretch( row, 10 );
467 // advanced parameters
468 myAdvGroup = new QWidget();
469 QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup );
470 anAdvLayout->setSpacing( 6 );
471 anAdvLayout->setMargin( 11 );
472 myAdvWidget = new HYBRIDPluginGUI_AdvWidget(myAdvGroup);
473 anAdvLayout->addWidget( myAdvWidget);
475 myAdvWidget->maxMemoryCheck->setText(tr( "MAX_MEMORY_SIZE" ));
476 myAdvWidget->initialMemoryCheck->setText(tr( "INIT_MEMORY_SIZE" ));
478 myAdvWidget->maxMemorySpin->RangeStepAndValidator(20.0, 1e6, 10.0);
479 myAdvWidget->maxMemorySpin->setValue( 128.0 );
481 myAdvWidget->initialMemorySpin->RangeStepAndValidator(0.0, 1e6, 10.0);
482 myAdvWidget->initialMemorySpin->setValue( 100.0 );
484 myAdvWidget->initialMemoryLabel ->setText (tr( "MEGABYTE" ));
485 myAdvWidget->maxMemoryLabel ->setText (tr( "MEGABYTE" ));
487 myAdvWidget->workingDirectoryPushButton ->setText (tr( "SELECT_DIR" ));
488 myAdvWidget->keepWorkingFilesCheck ->setText (tr( "KEEP_WORKING_FILES" ));
489 myAdvWidget->verboseLevelLabel ->setText (tr( "VERBOSE_LEVEL" ));
490 myAdvWidget->removeLogOnSuccessCheck ->setText (tr( "REMOVE_LOG_ON_SUCCESS" ));
491 myAdvWidget->logInFileCheck ->setText (tr( "LOG_IN_FILE" ));
493 myAdvWidget->memoryGroupBox ->setTitle(tr( "MEMORY_GROUP_TITLE" ));
494 myAdvWidget->logGroupBox ->setTitle(tr( "LOG_GROUP_TITLE" ));
495 myAdvWidget->advancedMeshingGroupBox ->setTitle(tr( "ADVANCED_MESHING_GROUP_TITLE" ));
497 myAdvWidget->memoryGroupBox->hide();
499 myAdvWidget->createNewNodesCheck->hide();
500 //myAdvWidget->createNewNodesLabel->hide();
501 myAdvWidget->removeInitialCentralPointCheck->hide();
502 myAdvWidget->boundaryRecoveryCheck->hide();
503 myAdvWidget->FEMCorrectionCheck->hide();
504 myAdvWidget->gradationLabel->hide();
505 myAdvWidget->gradationSpinBox->hide();
507 myAdvWidget->createNewNodesCheck ->setText (tr( "TO_ADD_NODES" ));
508 myAdvWidget->removeInitialCentralPointCheck->setText (tr( "NO_INITIAL_CENTRAL_POINT" ));
509 myAdvWidget->boundaryRecoveryCheck ->setText (tr( "RECOVERY_VERSION" ));
510 myAdvWidget->FEMCorrectionCheck ->setText (tr( "FEM_CORRECTION" ));
511 myAdvWidget->gradationLabel ->setText (tr( "HYBRID_GRADATION" ));
512 myAdvWidget->gradationSpinBox->RangeStepAndValidator(1.05, 5.0, 0.05, "length_precision");
514 // Enforced vertices parameters
515 myEnfGroup = new QWidget();
516 QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup);
517 myEnforcedTableWidget = new QTableWidget(myEnfGroup);
518 myEnforcedTableWidget ->setMinimumWidth(300);
519 myEnforcedTableWidget->setRowCount( 0 );
520 myEnforcedTableWidget->setColumnCount( ENF_VER_NB_COLUMNS );
521 myEnforcedTableWidget->setSortingEnabled(true);
522 QStringList enforcedHeaders;
523 enforcedHeaders << tr( "HYBRID_ENF_NAME_COLUMN" )
524 << tr( "HYBRID_ENF_VER_X_COLUMN" )<< tr( "HYBRID_ENF_VER_Y_COLUMN" ) << tr( "HYBRID_ENF_VER_Z_COLUMN" )
525 << tr( "HYBRID_ENF_SIZE_COLUMN" ) << tr("HYBRID_ENF_ENTRY_COLUMN") << tr("HYBRID_ENF_VER_COMPOUND_COLUMN") << tr( "HYBRID_ENF_GROUP_COLUMN" );
527 myEnforcedTableWidget->setHorizontalHeaderLabels(enforcedHeaders);
528 myEnforcedTableWidget->verticalHeader()->hide();
529 myEnforcedTableWidget->horizontalHeader()->setStretchLastSection(true);
530 myEnforcedTableWidget->setAlternatingRowColors(true);
531 myEnforcedTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
532 myEnforcedTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
533 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
534 myEnforcedTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
536 myEnforcedTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
538 myEnforcedTableWidget->resizeColumnsToContents();
539 myEnforcedTableWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
540 myEnforcedTableWidget->hideColumn(ENF_VER_COMPOUND_COLUMN);
542 myEnforcedTableWidget->setItemDelegate(new EnforcedVertexTableWidgetDelegate());
545 TColStd_MapOfInteger shapeTypes;
546 shapeTypes.Add( TopAbs_VERTEX );
547 shapeTypes.Add( TopAbs_COMPOUND );
549 SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes);
550 myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true);
551 myEnfVertexWdg->SetDefaultText(tr("HYBRID_ENF_SELECT_VERTEX"), "QLineEdit { color: grey }");
553 QLabel* myXCoordLabel = new QLabel( tr( "HYBRID_ENF_VER_X_LABEL" ), myEnfGroup );
554 myXCoord = new SMESHGUI_SpinBox(myEnfGroup);
555 myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
556 QLabel* myYCoordLabel = new QLabel( tr( "HYBRID_ENF_VER_Y_LABEL" ), myEnfGroup );
557 myYCoord = new SMESHGUI_SpinBox(myEnfGroup);
558 myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
559 QLabel* myZCoordLabel = new QLabel( tr( "HYBRID_ENF_VER_Z_LABEL" ), myEnfGroup );
560 myZCoord = new SMESHGUI_SpinBox(myEnfGroup);
561 myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
562 QLabel* mySizeLabel = new QLabel( tr( "HYBRID_ENF_SIZE_LABEL" ), myEnfGroup );
563 mySizeValue = new SMESHGUI_SpinBox(myEnfGroup);
564 mySizeValue->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
566 QLabel* myGroupNameLabel = new QLabel( tr( "HYBRID_ENF_GROUP_LABEL" ), myEnfGroup );
567 myGroupName = new QLineEdit(myEnfGroup);
569 addVertexButton = new QPushButton(tr("HYBRID_ENF_ADD"),myEnfGroup);
570 addVertexButton->setEnabled(false);
571 removeVertexButton = new QPushButton(tr("HYBRID_ENF_REMOVE"),myEnfGroup);
572 // myGlobalGroupName = new QCheckBox(tr("HYBRID_ENF_VER_GROUPS"), myEnfGroup);
573 // myGlobalGroupName->setChecked(false);
575 // QGroupBox* GroupBox = new QGroupBox( myEnfGroup );
576 // QLabel* info = new QLabel( GroupBox );
577 // info->setText( tr( "HYBRID_ENF_VER_INFO" ) );
578 // info->setWordWrap( true );
579 // QVBoxLayout* GroupBoxVLayout = new QVBoxLayout( GroupBox );
580 // GroupBoxVLayout->setSpacing( 6 );
581 // GroupBoxVLayout->setMargin( 11 );
582 // GroupBoxVLayout->addWidget( info );
585 //anEnfLayout->addWidget(GroupBox, ENF_VER_WARNING, 0, 1, 2 );
586 anEnfLayout->addWidget(myEnforcedTableWidget, ENF_VER_VERTEX, 0, ENF_VER_NB_LINES, 1);
588 QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup);
589 anEnfLayout2->addWidget(myEnfVertexWdg, ENF_VER_VERTEX, 0, 1, 2);
590 anEnfLayout2->addWidget(myXCoordLabel, ENF_VER_X_COORD, 0, 1, 1);
591 anEnfLayout2->addWidget(myXCoord, ENF_VER_X_COORD, 1, 1, 1);
592 anEnfLayout2->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 0, 1, 1);
593 anEnfLayout2->addWidget(myYCoord, ENF_VER_Y_COORD, 1, 1, 1);
594 anEnfLayout2->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 0, 1, 1);
595 anEnfLayout2->addWidget(myZCoord, ENF_VER_Z_COORD, 1, 1, 1);
596 anEnfLayout2->addWidget(mySizeLabel, ENF_VER_SIZE, 0, 1, 1);
597 anEnfLayout2->addWidget(mySizeValue, ENF_VER_SIZE, 1, 1, 1);
598 anEnfLayout2->addWidget(myGroupNameLabel, ENF_VER_GROUP, 0, 1, 1);
599 anEnfLayout2->addWidget(myGroupName, ENF_VER_GROUP, 1, 1, 1);
600 anEnfLayout2->addWidget(addVertexButton, ENF_VER_BTN, 0, 1, 1);
601 anEnfLayout2->addWidget(removeVertexButton, ENF_VER_BTN, 1, 1, 1);
602 anEnfLayout2->setRowStretch(ENF_VER_NB_LINES, 1);
604 anEnfLayout->addLayout(anEnfLayout2, ENF_VER_VERTEX, 1,ENF_VER_NB_LINES, 1);
605 anEnfLayout->setRowStretch(ENF_VER_VERTEX, 10);
607 // Enforced meshes parameters
608 myEnfMeshGroup = new QWidget();
609 QGridLayout* anEnfMeshLayout = new QGridLayout(myEnfMeshGroup);
611 myEnforcedMeshTableWidget = new QTableWidget(myEnfGroup);
612 myEnforcedMeshTableWidget->setRowCount( 0 );
613 myEnforcedMeshTableWidget->setColumnCount( ENF_MESH_NB_COLUMNS );
614 myEnforcedMeshTableWidget->setSortingEnabled(true);
615 myEnforcedMeshTableWidget->verticalHeader()->hide();
616 QStringList enforcedMeshHeaders;
617 enforcedMeshHeaders << tr( "HYBRID_ENF_NAME_COLUMN" )
618 << tr( "HYBRID_ENF_ENTRY_COLUMN" )
619 << tr( "HYBRID_ENF_MESH_CONSTRAINT_COLUMN" )
620 << tr( "HYBRID_ENF_GROUP_COLUMN" );
621 myEnforcedMeshTableWidget->setHorizontalHeaderLabels(enforcedMeshHeaders);
622 myEnforcedMeshTableWidget->horizontalHeader()->setStretchLastSection(true);
623 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
624 myEnforcedMeshTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
626 myEnforcedMeshTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
628 myEnforcedMeshTableWidget->setAlternatingRowColors(true);
629 myEnforcedMeshTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
630 myEnforcedMeshTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
631 myEnforcedMeshTableWidget->resizeColumnsToContents();
632 myEnforcedMeshTableWidget->hideColumn(ENF_MESH_ENTRY_COLUMN);
634 myEnforcedMeshTableWidget->setItemDelegate(new EnforcedMeshTableWidgetDelegate());
636 // myEnfMesh = SMESH::SMESH_Mesh::_nil();
637 // myEnfMeshArray = new SMESH::mesh_array();
639 myEnfMeshWdg = new StdMeshersGUI_ObjectReferenceParamWdg( SMESH::IDSOURCE, myEnfMeshGroup, /*multiSel=*/true);
640 myEnfMeshWdg->SetDefaultText(tr("HYBRID_ENF_SELECT_MESH"), "QLineEdit { color: grey }");
642 myEnfMeshWdg->AvoidSimultaneousSelection(myEnfVertexWdg);
643 ////myEnfMeshWdg->hide(); //may be used later
645 QLabel* myMeshConstraintLabel = new QLabel( tr( "HYBRID_ENF_MESH_CONSTRAINT_LABEL" ), myEnfMeshGroup );
646 myEnfMeshConstraint = new QComboBox(myEnfMeshGroup);
647 myEnfMeshConstraint->insertItems(0,myEnfMeshConstraintLabels);
648 myEnfMeshConstraint->setEditable(false);
649 myEnfMeshConstraint->setCurrentIndex(2); //EZ: use mesh group of faces for a layer
650 myMeshConstraintLabel->hide(); //may be used later
651 myEnfMeshConstraint->hide(); //may be used later
653 QLabel* myMeshGroupNameLabel = new QLabel( tr( "HYBRID_ENF_GROUP_LABEL" ), myEnfMeshGroup );
654 myMeshGroupName = new QLineEdit(myEnfMeshGroup);
655 myMeshGroupNameLabel->hide(); //may be used later
656 myMeshGroupName->hide(); //may be used later
658 addEnfMeshButton = new QPushButton(tr("HYBRID_ENF_ADD"),myEnfMeshGroup);
659 // addEnfMeshButton->setEnabled(false);
660 removeEnfMeshButton = new QPushButton(tr("HYBRID_ENF_REMOVE"),myEnfMeshGroup);
662 // QGroupBox* GroupBox2 = new QGroupBox( myEnfMeshGroup );
663 // QLabel* info2 = new QLabel( GroupBox2 );
664 // info2->setText( tr( "HYBRID_ENF_MESH_INFO" ) );
665 // info2->setWordWrap( true );
666 // QVBoxLayout* GroupBox2VLayout = new QVBoxLayout( GroupBox2 );
667 // GroupBox2VLayout->setSpacing( 6 );
668 // GroupBox2VLayout->setMargin( 11 );
669 // GroupBox2VLayout->addWidget( info2 );
671 // anEnfMeshLayout->addWidget( GroupBox2, ENF_MESH_WARNING, 0, 1, 2 );
672 //anEnfMeshLayout->addWidget(myLayersOnAllWrapCheck, ENF_MESH_MESH, 0, 1 , 1);
673 anEnfMeshLayout->addWidget(myEnforcedMeshTableWidget, ENF_MESH_MESH, 0, ENF_MESH_NB_LINES , 1);
675 QGridLayout* anEnfMeshLayout2 = new QGridLayout(myEnfMeshGroup);
676 anEnfMeshLayout2->addWidget(myEnfMeshWdg, ENF_MESH_MESH, 0, 1, 2);
677 //TODO remove or not be lateful to select layers...
678 //anEnfMeshLayout2->addWidget(myMeshConstraintLabel, ENF_MESH_CONSTRAINT, 0, 1, 1);
679 //anEnfMeshLayout2->addWidget(myEnfMeshConstraint, ENF_MESH_CONSTRAINT, 1, 1, 1);
680 //anEnfMeshLayout2->addWidget(myMeshGroupNameLabel, ENF_MESH_GROUP, 0, 1, 1);
681 //anEnfMeshLayout2->addWidget(myMeshGroupName, ENF_MESH_GROUP, 1, 1, 1);
682 anEnfMeshLayout2->addWidget(addEnfMeshButton, ENF_MESH_BTN, 0, 1, 1);
683 anEnfMeshLayout2->addWidget(removeEnfMeshButton, ENF_MESH_BTN, 1, 1, 1);
684 anEnfMeshLayout2->setRowStretch(ENF_MESH_NB_LINES, 1);
686 anEnfMeshLayout->addLayout(anEnfMeshLayout2, ENF_MESH_MESH, 1, ENF_MESH_NB_LINES, 1);
687 anEnfMeshLayout->setRowStretch(ENF_MESH_MESH, 10);
690 // selection of faces for layers
692 QWidget* faceSelLayersGroup = new QWidget( dlg() );
693 myLayersOnAllWrapCheck = new QCheckBox( tr( "HYBRID_LAYERS_ON_ALL_WRAP" ), faceSelLayersGroup );
694 QGridLayout* faceSelLayersLayout = new QGridLayout( faceSelLayersGroup );
695 faceSelLayersLayout->addWidget(myLayersOnAllWrapCheck, 0, 0 );
697 myFacesLbl = new QLabel( tr("HYBRID_FACE_IDS"), faceSelLayersGroup );
698 faceSelLayersLayout->addWidget( myFacesLbl, 1, 0 );
700 myFaceSelectorLayers = new StdMeshersGUI_SubShapeSelectorWdg( faceSelLayersGroup, TopAbs_FACE, true, true );
701 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
702 QString aSubEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
703 myFaceSelectorLayers->SetGeomShapeEntry( aSubEntry, aMainEntry );
704 faceSelLayersLayout->addWidget( myFaceSelectorLayers, 2, 0);
705 faceSelLayersLayout->setRowStretch( 2, 10);
707 // selection of faces for imprinting
709 QWidget* faceSelImprintingGroup = new QWidget( dlg() );
710 QGridLayout* faceSelImprintingLayout = new QGridLayout( faceSelImprintingGroup );
712 QLabel* facesLblImprinting = new QLabel( tr("HYBRID_FACE_IDS"), faceSelImprintingGroup );
713 faceSelImprintingLayout->addWidget( facesLblImprinting, 0, 0 );
715 myFaceSelectorImprinting = new StdMeshersGUI_SubShapeSelectorWdg( faceSelImprintingGroup, TopAbs_FACE, true, true );
716 myFaceSelectorImprinting->SetGeomShapeEntry( aSubEntry, aMainEntry );
717 faceSelImprintingLayout->addWidget( myFaceSelectorImprinting, 1, 0, 2, 2 );
718 faceSelImprintingLayout->setRowStretch( 1, 10);
721 tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
722 tab->insertTab( ADV_TAB, myAdvGroup, tr( "HYBRID_ADV_ARGS" ) );
723 if ( aMainEntry.isEmpty() && aSubEntry.isEmpty() ) // mesh not based of geometry
724 faceSelLayersGroup->hide();
726 tab->insertTab( FACE_SEL_LAYERS_TAB, faceSelLayersGroup, tr( "HYBRID_FACES_LAYERS_TAB" ));
727 tab->insertTab( FACE_SEL_IMPRINTING_TAB, faceSelImprintingGroup, tr( "HYBRID_FACES_IMPRINTING_TAB" ));
729 tab->insertTab( ENF_MESH_TAB, myEnfMeshGroup, tr( "HYBRID_ENFORCED_MESHES" ) );
730 tab->setCurrentIndex( STD_TAB );
733 connect( tab, SIGNAL( currentChanged ( int )), this, SLOT( onTabChanged( int ) ) );
734 //connect( myLayersOnAllWrapCheck, SIGNAL( toggled( bool ) ), this, SLOT( onLayersOnAllWrap(bool)));
735 connect( myLayersOnAllWrapCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
736 //connect( myToMeshHolesCheck, SIGNAL( toggled( bool ) ), this, SLOT( onToMeshHoles(bool)));
737 //connect( myAdvWidget->maxMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
738 //connect( myAdvWidget->initialMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
739 //connect( myAdvWidget->boundaryRecoveryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
741 //connect( myBoundaryLayersGrowthCombo, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
742 //connect( myElementGenerationCombo, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
743 connect( myAddMultinormalsCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
744 connect( mySmoothNormalsCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
746 connect( myAdvWidget->logInFileCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
747 connect( myAdvWidget->keepWorkingFilesCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
748 connect( myAdvWidget->workingDirectoryPushButton, SIGNAL( clicked() ), this, SLOT( onDirBtnClicked() ) );
750 connect( myEnforcedTableWidget, SIGNAL( itemClicked(QTableWidgetItem *)), this, SLOT( synchronizeCoords() ) );
751 connect( myEnforcedTableWidget, SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
752 connect( myEnforcedTableWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
753 connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertex() ) );
754 connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
755 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
756 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
757 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
758 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
759 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
760 connect( mySizeValue, SIGNAL( textChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) );
761 connect( myXCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
762 connect( myYCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
763 connect( myZCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
764 connect( mySizeValue, SIGNAL( valueChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) );
765 connect( this, SIGNAL( vertexDefined(bool) ), addVertexButton, SLOT( setEnabled(bool) ) );
767 connect( addEnfMeshButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedMesh() ) );
768 connect( removeEnfMeshButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedMesh() ) );
769 // connect( myEnfMeshWdg, SIGNAL( contentModified()), this, SLOT( checkEnfMeshIsDefined() ) );
770 // connect( myEnfMeshConstraint, SIGNAL( currentIndexChanged(int) ), this, SLOT( checkEnfMeshIsDefined() ) );
771 // connect( this, SIGNAL( enfMeshDefined(bool) ), addEnfMeshButton, SLOT( setEnabled(bool) ) );
777 * This method checks if an enforced vertex is defined;
779 void HYBRIDPluginGUI_HypothesisCreator::clearEnfVertexSelection()
781 if (myEnfVertexWdg->NbObjects() != 0) {
782 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
783 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
784 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
785 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
786 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
788 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
789 that->checkVertexIsDefined();
793 * This method checks if an enforced vertex is defined;
795 void HYBRIDPluginGUI_HypothesisCreator::checkVertexIsDefined()
797 bool enfVertexIsDefined = false;
798 enfVertexIsDefined = (!mySizeValue->GetString().isEmpty() &&
799 (!myEnfVertexWdg->NbObjects() == 0 ||
800 (myEnfVertexWdg->NbObjects() == 0 && !myXCoord->GetString().isEmpty()
801 && !myYCoord->GetString().isEmpty()
802 && !myZCoord->GetString().isEmpty())));
803 emit vertexDefined(enfVertexIsDefined);
807 * This method checks if an enforced mesh is defined;
809 void HYBRIDPluginGUI_HypothesisCreator::checkEnfMeshIsDefined()
811 emit enfMeshDefined( myEnfVertexWdg->NbObjects() != 0);
815 * This method resets the content of the X, Y, Z, size and GroupName widgets;
817 void HYBRIDPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
819 myXCoord->setCleared(true);
820 myYCoord->setCleared(true);
821 myZCoord->setCleared(true);
822 // mySizeValue->setCleared(true);
823 myXCoord->setText("");
824 myYCoord->setText("");
825 myZCoord->setText("");
826 // mySizeValue->setText("");
827 // myGroupName->setText("");
828 addVertexButton->setEnabled(false);
831 /** HYBRIDPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item)
832 This method updates the tooltip of a modified item. The QLineEdit widgets content
833 is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
835 void HYBRIDPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTableWidgetItem* item) {
836 int row = myEnforcedTableWidget->row(item);
838 QVariant vertexName = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole);
839 QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole);
840 QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole);
841 QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole);
842 QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole);
843 QVariant entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
844 QString groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole).toString();
846 clearEnforcedVertexWidgets();
848 if ( !x.isNull() || !entry.isNull()) {
849 QString toolTip = vertexName.toString();
850 toolTip += QString("(");
851 if (entry.isNull() || (!entry.isNull() && entry.toString() == "")) {
852 toolTip += x.toString();
853 toolTip += QString(", ") + y.toString();
854 toolTip += QString(", ") + z.toString();
857 toolTip += entry.toString();
858 toolTip += QString(")");
861 toolTip += QString("=") + size.toString();
863 if (!groupName.isEmpty())
864 toolTip += QString(" [") + groupName + QString("]");
866 for (int col=0;col<ENF_VER_NB_COLUMNS;col++)
867 myEnforcedTableWidget->item(row,col)->setToolTip(toolTip);
870 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
871 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
872 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
873 myXCoord->SetValue(x.toDouble());
874 myYCoord->SetValue(y.toDouble());
875 myZCoord->SetValue(z.toDouble());
876 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
877 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
878 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
881 mySizeValue->SetValue(size.toDouble());
883 if (!groupName.isEmpty())
884 myGroupName->setText(groupName);
888 void HYBRIDPluginGUI_HypothesisCreator::onSelectEnforcedVertex() {
889 int nbSelEnfVertex = myEnfVertexWdg->NbObjects();
890 clearEnforcedVertexWidgets();
891 if (nbSelEnfVertex == 1)
893 if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() )
896 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
897 if (myEnfVertex == GEOM::GEOM_Object::_nil())
899 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
900 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
901 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations();
902 if (CORBA::is_nil(measureOp))
906 measureOp->PointCoordinates (myEnfVertex, x, y, z);
907 if ( measureOp->IsDone() )
909 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
910 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
911 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
912 myXCoord->SetValue(x);
913 myYCoord->SetValue(y);
914 myZCoord->SetValue(z);
915 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
916 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
917 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
923 /** HYBRIDPluginGUI_HypothesisCreator::synchronizeCoords()
924 This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
925 of the enforced vertex clicked in the tree widget.
927 void HYBRIDPluginGUI_HypothesisCreator::synchronizeCoords() {
928 clearEnforcedVertexWidgets();
929 QList<QTableWidgetItem *> items = myEnforcedTableWidget->selectedItems();
930 // myEnfVertexWdg->disconnect(SIGNAL(contentModified()));
931 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
932 if (! items.isEmpty()) {
933 QTableWidgetItem *item;
936 if (items.size() == 1) {
938 row = myEnforcedTableWidget->row(item);
939 QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole);
940 QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole);
941 QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole);
942 QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole);
943 entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
944 if (!entry.isNull()) {
945 SMESH::string_array_var objIds = new SMESH::string_array;
947 objIds[0] = entry.toString().toStdString().c_str();
948 myEnfVertexWdg->SetObjects(objIds);
951 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
953 QVariant group = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole);
954 if (!x.isNull()/* && entry.isNull()*/) {
955 // disconnect( myXCoord, SIGNAL( textChanged(const QString &)), this, SLOT( onSelectEnforcedVertex() ) );
956 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
957 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
958 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
959 myXCoord->SetValue(x.toDouble());
960 myYCoord->SetValue(y.toDouble());
961 myZCoord->SetValue(z.toDouble());
962 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
963 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
964 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
967 mySizeValue->SetValue(size.toDouble());
969 if (!group.isNull() && (!x.isNull() || !entry.isNull()))
970 myGroupName->setText(group.toString());
973 QList<QString> entryList;
974 for (int i = 0; i < items.size(); ++i) {
976 row = myEnforcedTableWidget->row(item);
977 entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
979 entryList << entry.toString();
981 if (entryList.size() > 0) {
982 SMESH::string_array_var objIds = new SMESH::string_array;
983 objIds->length(entryList.size());
984 for (int i = 0; i < entryList.size() ; i++)
985 objIds[i] = entryList.at(i).toStdString().c_str();
986 myEnfVertexWdg->SetObjects(objIds);
989 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
994 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
996 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
997 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
998 that->checkVertexIsDefined();
1001 /** HYBRIDPluginGUI_HypothesisCreator::addEnforcedMesh( meshName, geomEntry, elemType, size, groupName)
1002 This method adds in the tree widget an enforced mesh from mesh, submesh or group with optionally size and and groupName.
1004 void HYBRIDPluginGUI_HypothesisCreator::addEnforcedMesh(std::string name, std::string entry, int elementType, std::string groupName)
1006 bool okToCreate = true;
1007 QString itemEntry = "";
1008 int itemElementType = 0;
1009 int rowCount = myEnforcedMeshTableWidget->rowCount();
1010 bool allColumns = true;
1011 for (int row = 0;row<rowCount;row++) {
1012 for (int col = 0 ; col < ENF_MESH_NB_COLUMNS ; col++) {
1013 if (col == ENF_MESH_CONSTRAINT_COLUMN){
1014 if (qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row, col)) == 0) {
1019 else if (myEnforcedMeshTableWidget->item(row, col) == 0) {
1023 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1024 QComboBox* itemComboBox = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row, col));
1025 itemElementType = itemComboBox->currentIndex();
1027 else if (col == ENF_MESH_ENTRY_COLUMN)
1028 itemEntry = myEnforcedMeshTableWidget->item(row, col)->data(Qt::EditRole).toString();
1034 if (itemEntry == QString(entry.c_str()) && itemElementType == elementType) {
1035 // // update group name
1036 // if (itemGroupName.toStdString() != groupName) {
1037 // myEnforcedMeshTableWidget->item(row, ENF_MESH_GROUP_COLUMN)->setData( Qt::EditRole, QVariant(groupName.c_str()));
1049 myEnforcedMeshTableWidget->setRowCount(rowCount+1);
1050 myEnforcedMeshTableWidget->setSortingEnabled(false);
1052 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++) {
1053 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1054 QComboBox* comboBox = new QComboBox();
1055 QPalette pal = comboBox->palette();
1056 pal.setColor(QPalette::Button, Qt::white);
1057 comboBox->setPalette(pal);
1058 comboBox->insertItems(0,myEnfMeshConstraintLabels);
1059 comboBox->setEditable(false);
1060 comboBox->setCurrentIndex(elementType);
1061 myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox);
1064 QTableWidgetItem* item = new QTableWidgetItem();
1065 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1067 case ENF_MESH_NAME_COLUMN:
1068 item->setData( 0, name.c_str() );
1069 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1070 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1072 case ENF_MESH_ENTRY_COLUMN:
1073 item->setData( 0, entry.c_str() );
1074 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1075 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1077 case ENF_MESH_GROUP_COLUMN:
1078 item->setData( 0, groupName.c_str() );
1079 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1087 // connect( myEnforcedMeshTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1089 myEnforcedMeshTableWidget->setSortingEnabled(true);
1090 // myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1091 // updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1095 /** HYBRIDPluginGUI_HypothesisCreator::addEnforcedVertex( x, y, z, size, vertexName, geomEntry, groupName)
1096 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.
1098 void HYBRIDPluginGUI_HypothesisCreator::addEnforcedVertex(double x, double y, double z, double size, std::string vertexName, std::string geomEntry, std::string groupName, bool isCompound)
1100 myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1101 bool okToCreate = true;
1102 double itemX,itemY,itemZ,itemSize = 0;
1103 QString itemEntry, itemGroupName = QString("");
1104 // bool itemIsCompound;
1105 int rowCount = myEnforcedTableWidget->rowCount();
1108 for (int row = 0;row<rowCount;row++) {
1110 for (int col = 0 ; col < ENF_VER_NB_COLUMNS ; col++) {
1111 if (myEnforcedTableWidget->item(row, col) == 0) {
1116 data = myEnforcedTableWidget->item(row, col)->data(Qt::EditRole);
1117 if (!data.isNull()) {
1119 case ENF_VER_GROUP_COLUMN:
1120 itemGroupName = data.toString();
1122 case ENF_VER_ENTRY_COLUMN:
1123 itemEntry = data.toString();
1125 // case ENF_VER_COMPOUND_COLUMN:
1126 // itemIsCompound = data.toBool();
1128 case ENF_VER_X_COLUMN:
1129 itemX = data.toDouble();
1131 case ENF_VER_Y_COLUMN:
1132 itemY = data.toDouble();
1134 case ENF_VER_Z_COLUMN:
1135 itemZ = data.toDouble();
1137 case ENF_VER_SIZE_COLUMN:
1138 itemSize = data.toDouble();
1150 if (( !isCompound && ((itemX == x) && (itemY == y) && (itemZ == z))) || /*( (itemEntry.toStdString() != "") && */ (itemEntry.toStdString() == geomEntry)/*)*/) {
1152 if (itemSize != size) {
1153 myEnforcedTableWidget->item(row, ENF_VER_SIZE_COLUMN)->setData( Qt::EditRole, QVariant(size));
1155 // update group name
1156 if (itemGroupName.toStdString() != groupName) {
1157 myEnforcedTableWidget->item(row, ENF_VER_GROUP_COLUMN)->setData( Qt::EditRole, QVariant(groupName.c_str()));
1164 if (geomEntry.empty()) {
1171 if (geomEntry.empty()) {
1178 QString myVertexName;
1179 while(indexRef != vertexIndex) {
1180 indexRef = vertexIndex;
1181 if (vertexName.empty())
1182 myVertexName = QString("Vertex #%1").arg(vertexIndex);
1184 myVertexName = QString(vertexName.c_str());
1186 for (int row = 0;row<rowCount;row++) {
1187 QString name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString();
1188 if (myVertexName == name) {
1195 myEnforcedTableWidget->setRowCount(rowCount+1);
1196 myEnforcedTableWidget->setSortingEnabled(false);
1197 for (int col=0;col<ENF_VER_NB_COLUMNS;col++) {
1198 QTableWidgetItem* item = new QTableWidgetItem();
1199 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1201 case ENF_VER_NAME_COLUMN:
1202 item->setData( Qt::EditRole, myVertexName );
1203 if (!geomEntry.empty()) {
1205 item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1207 item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1210 case ENF_VER_X_COLUMN:
1212 item->setData( 0, QVariant(x) );
1214 case ENF_VER_Y_COLUMN:
1216 item->setData( 0, QVariant(y) );
1218 case ENF_VER_Z_COLUMN:
1220 item->setData( 0, QVariant(z) );
1222 case ENF_VER_SIZE_COLUMN:
1223 item->setData( 0, QVariant(size) );
1225 case ENF_VER_ENTRY_COLUMN:
1226 if (!geomEntry.empty())
1227 item->setData( 0, QString(geomEntry.c_str()) );
1229 case ENF_VER_COMPOUND_COLUMN:
1230 item->setData( Qt::CheckStateRole, isCompound );
1231 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
1233 case ENF_VER_GROUP_COLUMN:
1234 if (!groupName.empty())
1235 item->setData( 0, QString(groupName.c_str()) );
1241 myEnforcedTableWidget->setItem(rowCount,col,item);
1244 connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1246 myEnforcedTableWidget->setSortingEnabled(true);
1247 // myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1248 updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1251 /** HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedMesh()
1252 This method is called when a item is added into the enforced meshes tree widget
1254 void HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedMesh()
1257 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1259 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1260 myEnfMeshWdg->deactivateSelection();
1262 for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column)
1263 myEnforcedMeshTableWidget->resizeColumnToContents(column);
1266 int selEnfMeshes = myEnfMeshWdg->NbObjects();
1267 if (selEnfMeshes == 0)
1270 std::string groupName = myMeshGroupName->text().toStdString();
1271 // if (myGlobalGroupName->isChecked())
1272 // groupName = myGlobalGroupName->text().toStdString();
1274 if (boost::trim_copy(groupName).empty())
1275 groupName = "LayersGroup"; //have to be not empty until non used
1277 int elementType = myEnfMeshConstraint->currentIndex();
1280 _PTR(Study) aStudy = SMESH::getStudy();
1281 _PTR(SObject) aSObj; //SMESH::SMESH_IDSource::_nil;
1282 QString meshEntry = myEnfMeshWdg->GetValue();
1284 if (selEnfMeshes == 1)
1286 // myEnfMesh = myEnfMeshWdg->GetObject< SMESH::SMESH_IDSource >();
1287 // std::string entry = myEnfMeshWdg->GetValue();
1288 aSObj = aStudy->FindObjectID(meshEntry.toStdString().c_str());
1289 CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj);
1290 if (!CORBA::is_nil(anObj)) {
1291 // SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1292 addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
1297 QStringList meshEntries = meshEntry.split(" ", QString::SkipEmptyParts);
1298 QStringListIterator meshEntriesIt (meshEntries);
1299 while (meshEntriesIt.hasNext()) {
1300 aSObj = aStudy->FindObjectID(meshEntriesIt.next().toStdString().c_str());
1301 CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj);
1302 if (!CORBA::is_nil(anObj)) {
1303 // SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1304 addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
1309 myEnfVertexWdg->SetObject(SMESH::SMESH_IDSource::_nil());
1311 for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column)
1312 myEnforcedMeshTableWidget->resizeColumnToContents(column);
1316 /** HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedVertex()
1317 This method is called when a item is added into the enforced vertices tree widget
1319 void HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedVertex()
1322 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1324 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1325 myEnfVertexWdg->deactivateSelection();
1327 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1328 myEnforcedTableWidget->resizeColumnToContents(column);
1331 int selEnfVertex = myEnfVertexWdg->NbObjects();
1332 bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty());
1333 if ((selEnfVertex == 0) && coordsEmpty)
1336 std::string groupName = myGroupName->text().toStdString();
1337 // if (myGlobalGroupName->isChecked())
1338 // groupName = myGlobalGroupName->text().toStdString();
1340 if (boost::trim_copy(groupName).empty())
1343 double size = mySizeValue->GetValue();
1345 if (selEnfVertex <= 1)
1347 double x = 0, y = 0, z=0;
1348 if (myXCoord->GetString() != "") {
1349 x = myXCoord->GetValue();
1350 y = myYCoord->GetValue();
1351 z = myZCoord->GetValue();
1353 if (selEnfVertex == 1) {
1354 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >();
1355 std::string entry = "";
1356 if (myEnfVertex != GEOM::GEOM_Object::_nil())
1357 entry = myEnfVertex->GetStudyEntry();
1358 addEnforcedVertex(x, y, z, size, myEnfVertex->GetName(),entry, groupName, myEnfVertex->GetShapeType() == GEOM::COMPOUND);
1361 addEnforcedVertex(x, y, z, size, "", "", groupName);
1366 if ( CORBA::is_nil(getGeomEngine()))
1369 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations();
1370 if (CORBA::is_nil(measureOp))
1373 CORBA::Double x = 0, y = 0,z = 0;
1374 for (int j = 0 ; j < selEnfVertex ; j++)
1376 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j);
1377 if (myEnfVertex == GEOM::GEOM_Object::_nil())
1379 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1380 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1381 if ( measureOp->IsDone() )
1382 addEnforcedVertex(x, y, z, size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1383 } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) {
1384 addEnforcedVertex(0., 0., 0., size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName, true);
1389 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1391 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1392 myEnforcedTableWidget->resizeColumnToContents(column);
1395 /** HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedMesh()
1396 This method is called when a item is removed from the enforced meshes tree widget
1398 void HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedMesh()
1400 QList<int> selectedRows;
1401 QList<QTableWidgetItem *> selectedItems = myEnforcedMeshTableWidget->selectedItems();
1402 QTableWidgetItem* item;
1404 foreach( item, selectedItems ) {
1406 if (!selectedRows.contains( row ) )
1407 selectedRows.append(row);
1410 qSort( selectedRows );
1411 QListIterator<int> it( selectedRows );
1413 while ( it.hasPrevious() ) {
1414 row = it.previous();
1415 myEnforcedMeshTableWidget->removeRow(row );
1418 myEnforcedMeshTableWidget->selectionModel()->clearSelection();
1421 /** HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1422 This method is called when a item is removed from the enforced vertices tree widget
1424 void HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1426 QList<int> selectedRows;
1427 QList<QTableWidgetItem *> selectedItems = myEnforcedTableWidget->selectedItems();
1428 QTableWidgetItem* item;
1430 foreach( item, selectedItems ) {
1432 if (!selectedRows.contains( row ) )
1433 selectedRows.append(row);
1436 qSort( selectedRows );
1437 QListIterator<int> it( selectedRows );
1439 while ( it.hasPrevious() ) {
1440 row = it.previous();
1441 myEnforcedTableWidget->removeRow(row );
1444 myEnforcedTableWidget->selectionModel()->clearSelection();
1447 void HYBRIDPluginGUI_HypothesisCreator::onLayersOnAllWrap(bool isOn)
1449 // myToMakeGroupsOfDomains->setEnabled( isOn );
1451 // myToMakeGroupsOfDomains->setChecked( false );
1454 void HYBRIDPluginGUI_HypothesisCreator::onToMeshHoles(bool isOn)
1456 // myToMakeGroupsOfDomains->setEnabled( isOn );
1458 // myToMakeGroupsOfDomains->setChecked( false );
1461 void HYBRIDPluginGUI_HypothesisCreator::onDirBtnClicked()
1463 QString dir = SUIT_FileDlg::getExistingDirectory( dlg(), myAdvWidget->workingDirectoryLineEdit->text(), QString() );
1464 if ( !dir.isEmpty() )
1465 myAdvWidget->workingDirectoryLineEdit->setText( dir );
1468 void HYBRIDPluginGUI_HypothesisCreator::onTabChanged( int )
1470 myEnfVertexWdg->deactivateSelection();
1471 myEnfMeshWdg->deactivateSelection();
1472 myFaceSelectorLayers->ActivateSelection( false );
1473 myFaceSelectorLayers->ShowPreview( false );
1474 myFaceSelectorImprinting->ActivateSelection( false );
1475 myFaceSelectorImprinting->ShowPreview( false );
1478 void HYBRIDPluginGUI_HypothesisCreator::updateWidgets()
1480 //customs automatic set
1481 //myToMakeGroupsOfDomains->setEnabled( myToMeshHolesCheck->isChecked() );
1482 //myAdvWidget->maxMemorySpin->setEnabled( myAdvWidget->maxMemoryCheck->isChecked() );
1483 //myAdvWidget->initialMemoryCheck->setEnabled( !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1484 //myAdvWidget->initialMemorySpin->setEnabled( myAdvWidget->initialMemoryCheck->isChecked() && !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1485 //myOptimizationLevelCombo->setEnabled( !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1486 myMultinormalsAngleSpin->setEnabled( myAddMultinormalsCheck->isChecked() );
1487 if ( sender() == myAdvWidget->logInFileCheck ||
1488 sender() == myAdvWidget->keepWorkingFilesCheck )
1490 bool logFileRemovable = myAdvWidget->logInFileCheck->isChecked() &&
1491 !myAdvWidget->keepWorkingFilesCheck->isChecked();
1493 myAdvWidget->removeLogOnSuccessCheck->setEnabled( logFileRemovable );
1495 bool enabled = !myLayersOnAllWrapCheck->isChecked();
1496 myFacesLbl->setEnabled(enabled);
1497 myFaceSelectorLayers->setEnabled(enabled);
1498 if ( QTabWidget* tab = qobject_cast<QTabWidget*>( myStdGroup->parentWidget()->parentWidget() )) {
1499 tab->setTabEnabled( FACE_SEL_IMPRINTING_TAB, enabled );
1503 bool HYBRIDPluginGUI_HypothesisCreator::checkParams(QString& msg) const
1506 if ( !QFileInfo( myAdvWidget->workingDirectoryLineEdit->text().trimmed() ).isWritable() ) {
1507 SUIT_MessageBox::warning( dlg(),
1508 tr( "SMESH_WRN_WARNING" ),
1509 tr( "HYBRID_PERMISSION_DENIED" ) );
1516 void HYBRIDPluginGUI_HypothesisCreator::retrieveParams() const
1518 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1519 HYBRIDHypothesisData data;
1520 readParamsFromHypo( data );
1523 myName->setText( data.myName );
1524 myLayersOnAllWrapCheck ->setChecked ( data.myLayersOnAllWrap );
1525 myToMeshHolesCheck ->setChecked ( data.myToMeshHoles );
1526 myToMakeGroupsOfDomains ->setChecked ( data.myToMakeGroupsOfDomains );
1527 myOptimizationLevelCombo ->setCurrentIndex( data.myOptimizationLevel );
1528 myAdvWidget->maxMemoryCheck ->setChecked ( data.myMaximumMemory > 0 );
1529 myAdvWidget->maxMemorySpin ->setValue ( qMax( data.myMaximumMemory,
1530 myAdvWidget->maxMemorySpin->minimum() ));
1531 myAdvWidget->initialMemoryCheck ->setChecked ( data.myInitialMemory > 0 );
1532 myAdvWidget->initialMemorySpin ->setValue ( qMax( data.myInitialMemory,
1533 myAdvWidget->initialMemorySpin->minimum() ));
1535 myCollisionModeCombo ->setCurrentIndex( data.myCollisionMode );
1536 myBoundaryLayersGrowthCombo ->setCurrentIndex( data.myBoundaryLayersGrowth );
1537 myElementGenerationCombo ->setCurrentIndex( data.myElementGeneration );
1538 myAddMultinormalsCheck -> setChecked ( data.myAddMultinormals );
1539 mySmoothNormalsCheck -> setChecked ( data.mySmoothNormals );
1540 myHeightFirstLayerSpin -> setValue( data.myHeightFirstLayer );
1541 myNbOfBoundaryLayersSpin -> setValue( data.myNbOfBoundaryLayers );
1542 myBoundaryLayersProgressionSpin -> setValue( data.myBoundaryLayersProgression );
1543 if (data.myCoreSize <= 0)
1544 myCoreSizeSpin->setText("");
1546 myCoreSizeSpin -> setValue( data.myCoreSize );
1547 myMultinormalsAngleSpin -> setValue( data.myMultinormalsAngle );
1548 myFaceSelectorLayers ->SetListOfIDs( data.myFaceWLIds );
1549 myFaceSelectorImprinting ->SetListOfIDs( data.myFaceWIIds );
1551 myAdvWidget->workingDirectoryLineEdit ->setText ( data.myWorkingDir );
1552 myAdvWidget->keepWorkingFilesCheck ->setChecked( data.myKeepFiles );
1553 myAdvWidget->verboseLevelSpin ->setValue ( data.myVerboseLevel );
1554 myAdvWidget->createNewNodesCheck ->setChecked( data.myToCreateNewNodes );
1555 myAdvWidget->removeInitialCentralPointCheck ->setChecked( data.myRemoveInitialCentralPoint );
1556 myAdvWidget->boundaryRecoveryCheck ->setChecked( data.myBoundaryRecovery );
1557 myAdvWidget->FEMCorrectionCheck ->setChecked( data.myFEMCorrection );
1558 myAdvWidget->gradationSpinBox ->setValue ( data.myGradation );
1559 myAdvWidget->myAdvOptionsTable ->SetCustomOptions( data.myTextOption );
1560 myAdvWidget->logInFileCheck ->setChecked( !data.myLogInStandardOutput );
1561 myAdvWidget->removeLogOnSuccessCheck ->setChecked( data.myRemoveLogOnSuccess );
1563 TEnfVertexList::const_iterator it;
1565 myEnforcedTableWidget->clearContents();
1566 myEnforcedTableWidget->setSortingEnabled(false);
1567 myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1568 for(it = data.myEnforcedVertices.begin() ; it != data.myEnforcedVertices.end(); it++ )
1570 TEnfVertex* enfVertex = (*it);
1571 myEnforcedTableWidget->setRowCount(rowCount+1);
1573 for (int col=0;col<ENF_VER_NB_COLUMNS;col++) {
1574 QTableWidgetItem* item = new QTableWidgetItem();
1575 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1577 case ENF_VER_NAME_COLUMN:
1578 item->setData( 0, enfVertex->name.c_str() );
1579 if (!enfVertex->geomEntry.empty()) {
1580 if (enfVertex->isCompound)
1581 item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1583 item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1587 case ENF_VER_X_COLUMN:
1588 if (!enfVertex->isCompound) {
1589 item->setData( 0, enfVertex->coords.at(0) );
1592 case ENF_VER_Y_COLUMN:
1593 if (!enfVertex->isCompound) {
1594 item->setData( 0, enfVertex->coords.at(1) );
1597 case ENF_VER_Z_COLUMN:
1598 if (!enfVertex->isCompound) {
1599 item->setData( 0, enfVertex->coords.at(2) );
1602 case ENF_VER_SIZE_COLUMN:
1603 item->setData( 0, enfVertex->size );
1605 case ENF_VER_ENTRY_COLUMN:
1606 item->setData( 0, enfVertex->geomEntry.c_str() );
1608 case ENF_VER_COMPOUND_COLUMN:
1609 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
1610 item->setData( Qt::CheckStateRole, enfVertex->isCompound );
1612 case ENF_VER_GROUP_COLUMN:
1613 item->setData( 0, enfVertex->groupName.c_str() );
1619 myEnforcedTableWidget->setItem(rowCount,col,item);
1621 that->updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1625 connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1626 myEnforcedTableWidget->setSortingEnabled(true);
1628 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1629 myEnforcedTableWidget->resizeColumnToContents(column);
1631 // Update Enforced meshes QTableWidget
1632 TEnfMeshList::const_iterator itMesh;
1634 myEnforcedMeshTableWidget->clearContents();
1635 myEnforcedMeshTableWidget->setSortingEnabled(false);
1636 // myEnforcedMeshTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1637 for(itMesh = data.myEnforcedMeshes.begin() ; itMesh != data.myEnforcedMeshes.end(); itMesh++ )
1639 TEnfMesh* enfMesh = (*itMesh);
1640 myEnforcedMeshTableWidget->setRowCount(rowCount+1);
1642 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++) {
1643 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1644 QComboBox* comboBox = new QComboBox();
1645 QPalette pal = comboBox->palette();
1646 pal.setColor(QPalette::Button, Qt::white);
1647 comboBox->setPalette(pal);
1648 comboBox->insertItems(0,myEnfMeshConstraintLabels);
1649 comboBox->setEditable(false);
1650 comboBox->setCurrentIndex(enfMesh->elementType);
1651 myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox);
1654 QTableWidgetItem* item = new QTableWidgetItem();
1655 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1657 case ENF_MESH_NAME_COLUMN:
1658 item->setData( 0, enfMesh->name.c_str() );
1659 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1660 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1662 case ENF_MESH_ENTRY_COLUMN:
1663 item->setData( 0, enfMesh->entry.c_str() );
1664 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1665 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1667 case ENF_MESH_GROUP_COLUMN:
1668 item->setData( 0, enfMesh->groupName.c_str() );
1669 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1676 // myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1678 // that->updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1682 // connect( myEnforcedMeshTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1683 myEnforcedMeshTableWidget->setSortingEnabled(true);
1685 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++)
1686 myEnforcedMeshTableWidget->resizeColumnToContents(col);
1688 that->updateWidgets();
1689 that->checkVertexIsDefined();
1692 QString HYBRIDPluginGUI_HypothesisCreator::storeParams() const
1694 HYBRIDHypothesisData data;
1695 readParamsFromWidgets( data );
1696 storeParamsToHypo( data );
1698 QString valStr = "";
1700 if ( !data.myBoundaryRecovery )
1701 valStr = "-c " + QString::number( !data.myToMeshHoles );
1703 if ( data.myOptimizationLevel >= 0 && data.myOptimizationLevel < 5 && !data.myBoundaryRecovery) {
1704 const char* level[] = { "none" , "light" , "standard" , "standard+" , "strong" };
1706 valStr += level[ data.myOptimizationLevel ];
1708 if ( data.myMaximumMemory > 0 ) {
1710 valStr += QString::number( data.myMaximumMemory );
1712 if ( data.myInitialMemory > 0 && !data.myBoundaryRecovery ) {
1714 valStr += QString::number( data.myInitialMemory );
1717 valStr += QString::number( data.myVerboseLevel );
1719 if ( !data.myToCreateNewNodes )
1722 if ( data.myRemoveInitialCentralPoint )
1723 valStr += " -no_initial_central_point";
1725 if ( data.myBoundaryRecovery )
1728 if ( data.myFEMCorrection )
1731 if ( data.myGradation != 1.05 ) {
1732 valStr += " -Dcpropa=";
1733 valStr += QString::number( data.myGradation );
1737 valStr += data.myTextOption;
1739 // valStr += " #BEGIN ENFORCED VERTICES#";
1740 // // Add size map parameters storage
1741 // for (int i=0 ; i<mySmpModel->rowCount() ; i++) {
1743 // double x = mySmpModel->data(mySmpModel->index(i,ENF_VER_X_COLUMN)).toDouble();
1744 // double y = mySmpModel->data(mySmpModel->index(i,ENF_VER_Y_COLUMN)).toDouble();
1745 // double z = mySmpModel->data(mySmpModel->index(i,ENF_VER_Z_COLUMN)).toDouble();
1746 // double size = mySmpModel->data(mySmpModel->index(i,ENF_VER_SIZE_COLUMN)).toDouble();
1747 // valStr += QString::number( x );
1749 // valStr += QString::number( y );
1751 // valStr += QString::number( z );
1753 // valStr += QString::number( size );
1754 // if (i!=mySmpModel->rowCount()-1)
1757 // valStr += " #END ENFORCED VERTICES#";
1761 bool HYBRIDPluginGUI_HypothesisCreator::readParamsFromHypo( HYBRIDHypothesisData& h_data ) const
1763 HYBRIDPlugin::HYBRIDPlugin_Hypothesis_var h =
1764 HYBRIDPlugin::HYBRIDPlugin_Hypothesis::_narrow( initParamsHypothesis() );
1766 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
1767 h_data.myName = isCreation() && data ? hypName() : "";
1769 h_data.myCollisionMode = h->GetCollisionMode();
1770 h_data.myBoundaryLayersGrowth = h->GetBoundaryLayersGrowth();
1771 h_data.myElementGeneration = h->GetElementGeneration();
1772 h_data.myAddMultinormals = h->GetAddMultinormals();
1773 h_data.mySmoothNormals = h->GetSmoothNormals();
1774 h_data.myHeightFirstLayer = h->GetHeightFirstLayer();
1775 h_data.myBoundaryLayersProgression = h->GetBoundaryLayersProgression();
1776 h_data.myCoreSize = h->GetCoreSize();
1777 h_data.myMultinormalsAngle = h->GetMultinormalsAngle();
1778 h_data.myNbOfBoundaryLayers = h->GetNbOfBoundaryLayers();
1779 h_data.myFaceWLIds = h->GetFacesWithLayers();
1780 h_data.myFaceWIIds = h->GetFacesWithImprinting();
1782 h_data.myLayersOnAllWrap = h->GetLayersOnAllWrap();
1783 h_data.myToMeshHoles = h->GetToMeshHoles();
1784 h_data.myToMakeGroupsOfDomains = /*h->GetToMeshHoles() &&*/ h->GetToMakeGroupsOfDomains();
1785 h_data.myMaximumMemory = h->GetMaximumMemory();
1786 h_data.myInitialMemory = h->GetInitialMemory();
1787 h_data.myInitialMemory = h->GetInitialMemory();
1788 h_data.myOptimizationLevel = h->GetOptimizationLevel();
1790 h_data.myKeepFiles = h->GetKeepFiles();
1791 h_data.myWorkingDir = h->GetWorkingDirectory();
1792 h_data.myVerboseLevel = h->GetVerboseLevel();
1793 h_data.myToCreateNewNodes = h->GetToCreateNewNodes();
1794 h_data.myRemoveInitialCentralPoint = h->GetToRemoveCentralPoint();
1795 h_data.myBoundaryRecovery = h->GetToUseBoundaryRecoveryVersion();
1796 h_data.myFEMCorrection = h->GetFEMCorrection();
1797 h_data.myGradation = h->GetGradation();
1798 h_data.myTextOption = h->GetAdvancedOption();
1799 h_data.myLogInStandardOutput = h->GetStandardOutputLog();
1800 h_data.myRemoveLogOnSuccess = h->GetRemoveLogOnSuccess();
1802 HYBRIDPlugin::HYBRIDEnforcedVertexList_var vertices = h->GetEnforcedVertices();
1803 h_data.myEnforcedVertices.clear();
1804 for (CORBA::ULong i=0 ; i<vertices->length() ; i++) {
1805 TEnfVertex* myVertex = new TEnfVertex();
1806 myVertex->name = CORBA::string_dup(vertices[i].name.in());
1807 myVertex->geomEntry = CORBA::string_dup(vertices[i].geomEntry.in());
1808 myVertex->groupName = CORBA::string_dup(vertices[i].groupName.in());
1809 myVertex->size = vertices[i].size;
1810 myVertex->isCompound = vertices[i].isCompound;
1811 if (vertices[i].coords.length()) {
1812 for (CORBA::ULong c = 0; c < vertices[i].coords.length() ; c++)
1813 myVertex->coords.push_back(vertices[i].coords[c]);
1815 h_data.myEnforcedVertices.insert(myVertex);
1818 HYBRIDPlugin::HYBRIDEnforcedMeshList_var enfMeshes = h->GetEnforcedMeshes();
1819 h_data.myEnforcedMeshes.clear();
1820 for (CORBA::ULong i=0 ; i<enfMeshes->length() ; i++) {
1821 TEnfMesh* myEnfMesh = new TEnfMesh();
1822 myEnfMesh->name = CORBA::string_dup(enfMeshes[i].name.in());
1823 myEnfMesh->entry = CORBA::string_dup(enfMeshes[i].entry.in());
1824 myEnfMesh->groupName = CORBA::string_dup(enfMeshes[i].groupName.in());
1825 switch (enfMeshes[i].elementType) {
1827 myEnfMesh->elementType = 0;
1830 myEnfMesh->elementType = 1;
1833 myEnfMesh->elementType = 2;
1838 // myEnfMesh->elementType = enfMeshes[i].elementType;
1839 h_data.myEnforcedMeshes.insert(myEnfMesh);
1844 bool HYBRIDPluginGUI_HypothesisCreator::storeParamsToHypo( const HYBRIDHypothesisData& h_data ) const
1846 HYBRIDPlugin::HYBRIDPlugin_Hypothesis_var h =
1847 HYBRIDPlugin::HYBRIDPlugin_Hypothesis::_narrow( hypothesis() );
1853 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
1855 if ( h->GetLayersOnAllWrap() != h_data.myLayersOnAllWrap ) // avoid duplication of DumpPython commands
1856 h->SetLayersOnAllWrap ( h_data.myLayersOnAllWrap );
1857 if ( h->GetToMeshHoles() != h_data.myToMeshHoles ) // avoid duplication of DumpPython commands
1858 h->SetToMeshHoles ( h_data.myToMeshHoles );
1859 if ( h->GetToMakeGroupsOfDomains() != h_data.myToMakeGroupsOfDomains )
1860 h->SetToMakeGroupsOfDomains( h_data.myToMakeGroupsOfDomains );
1861 if ( h->GetMaximumMemory() != h_data.myMaximumMemory )
1862 h->SetMaximumMemory ( h_data.myMaximumMemory );
1863 if ( h->GetInitialMemory() != h_data.myInitialMemory )
1864 h->SetInitialMemory ( h_data.myInitialMemory );
1865 if ( h->GetInitialMemory() != h_data.myInitialMemory )
1866 h->SetInitialMemory ( h_data.myInitialMemory );
1867 if ( h->GetOptimizationLevel() != h_data.myOptimizationLevel )
1868 h->SetOptimizationLevel( h_data.myOptimizationLevel );
1870 if ( h->GetCollisionMode() != h_data.myCollisionMode )
1871 h->SetCollisionMode( h_data.myCollisionMode );
1872 if ( h->GetBoundaryLayersGrowth() != h_data.myBoundaryLayersGrowth )
1873 h->SetBoundaryLayersGrowth( h_data.myBoundaryLayersGrowth );
1874 if ( h->GetElementGeneration() != h_data.myElementGeneration )
1875 h->SetElementGeneration( h_data.myElementGeneration );
1877 if ( h->GetAddMultinormals() != h_data.myAddMultinormals )
1878 h->SetAddMultinormals ( h_data.myAddMultinormals );
1879 if ( h->GetSmoothNormals() != h_data.mySmoothNormals )
1880 h->SetSmoothNormals ( h_data.mySmoothNormals );
1881 if ( h->GetHeightFirstLayer() != h_data.myHeightFirstLayer )
1882 h->SetHeightFirstLayer ( h_data.myHeightFirstLayer );
1883 if ( h->GetBoundaryLayersProgression() != h_data.myBoundaryLayersProgression )
1884 h->SetBoundaryLayersProgression ( h_data.myBoundaryLayersProgression );
1885 if ( h->GetCoreSize() != h_data.myCoreSize )
1886 h->SetCoreSize ( h_data.myCoreSize );
1887 if ( h->GetMultinormalsAngle() != h_data.myMultinormalsAngle )
1888 h->SetMultinormalsAngle ( h_data.myMultinormalsAngle );
1889 if ( h->GetNbOfBoundaryLayers() != h_data.myNbOfBoundaryLayers )
1890 h->SetNbOfBoundaryLayers ( h_data.myNbOfBoundaryLayers );
1891 h->SetFacesWithLayers( h_data.myFaceWLIds );
1892 h->SetFacesWithImprinting( h_data.myFaceWIIds );
1894 if ( h->GetKeepFiles() != h_data.myKeepFiles)
1895 h->SetKeepFiles ( h_data.myKeepFiles);
1896 if ( h->GetWorkingDirectory() != h_data.myWorkingDir )
1897 h->SetWorkingDirectory ( h_data.myWorkingDir.toLatin1().constData() );
1898 if ( h->GetVerboseLevel() != h_data.myVerboseLevel )
1899 h->SetVerboseLevel ( h_data.myVerboseLevel );
1900 if ( h->GetToCreateNewNodes() != h_data.myToCreateNewNodes )
1901 h->SetToCreateNewNodes ( h_data.myToCreateNewNodes );
1902 if ( h->GetToRemoveCentralPoint() != h_data.myRemoveInitialCentralPoint )
1903 h->SetToRemoveCentralPoint ( h_data.myRemoveInitialCentralPoint );
1904 if ( h->GetToUseBoundaryRecoveryVersion() != h_data.myBoundaryRecovery )
1905 h->SetToUseBoundaryRecoveryVersion ( h_data.myBoundaryRecovery );
1906 if ( h->GetFEMCorrection() != h_data.myFEMCorrection )
1907 h->SetFEMCorrection ( h_data.myFEMCorrection );
1908 if ( h->GetGradation() != h_data.myGradation )
1909 h->SetGradation ( h_data.myGradation );
1910 if ( h->GetTextOption() != h_data.myTextOption )
1911 h->SetAdvancedOption ( h_data.myTextOption.toLatin1().constData() );
1912 if ( h->GetStandardOutputLog() != h_data.myLogInStandardOutput )
1913 h->SetStandardOutputLog ( h_data.myLogInStandardOutput );
1914 if ( h->GetRemoveLogOnSuccess() != h_data.myRemoveLogOnSuccess )
1915 h->SetRemoveLogOnSuccess ( h_data.myRemoveLogOnSuccess );
1917 // Enforced vertices
1918 //int nbVertex = (int) h_data.myEnforcedVertices.size();
1919 HYBRIDPlugin::HYBRIDEnforcedVertexList_var vertexHyp = h->GetEnforcedVertices();
1920 int nbVertexHyp = vertexHyp->length();
1923 // 1. Clear all enforced vertices in hypothesis
1924 // 2. Add new enforced vertex according to h_data
1925 if ( nbVertexHyp > 0)
1926 h->ClearEnforcedVertices();
1928 TEnfVertexList::const_iterator it;
1929 double x = 0, y = 0, z = 0;
1930 for(it = h_data.myEnforcedVertices.begin() ; it != h_data.myEnforcedVertices.end(); it++ ) {
1931 TEnfVertex* enfVertex = (*it);
1933 if (enfVertex->coords.size()) {
1934 x = enfVertex->coords.at(0);
1935 y = enfVertex->coords.at(1);
1936 z = enfVertex->coords.at(2);
1938 ok = h->p_SetEnforcedVertex( enfVertex->size, x, y, z, enfVertex->name.c_str(), enfVertex->geomEntry.c_str(), enfVertex->groupName.c_str(), enfVertex->isCompound);
1942 //int nbEnfMeshes = (int) h_data.myEnforcedMeshes.size();
1943 HYBRIDPlugin::HYBRIDEnforcedMeshList_var enfMeshListHyp = h->GetEnforcedMeshes();
1944 int nbEnfMeshListHyp = enfMeshListHyp->length();
1947 // 1. Clear all enforced vertices in hypothesis
1948 // 2. Add new enforced vertex according to h_data
1949 if ( nbEnfMeshListHyp > 0)
1950 h->ClearEnforcedMeshes();
1952 TEnfMeshList::const_iterator itEnfMesh;
1954 _PTR(Study) aStudy = SMESH::getStudy();
1956 for(itEnfMesh = h_data.myEnforcedMeshes.begin() ; itEnfMesh != h_data.myEnforcedMeshes.end(); itEnfMesh++ ) {
1957 TEnfMesh* enfMesh = (*itEnfMesh);
1959 _PTR(SObject) aSObj = aStudy->FindObjectID(enfMesh->entry.c_str());
1960 SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1962 SMESH::ElementType elementType;
1963 switch(enfMesh->elementType) {
1965 elementType = SMESH::NODE;
1968 elementType = SMESH::EDGE;
1971 elementType = SMESH::FACE;
1977 std::cout << "h->p_SetEnforcedMesh(theSource, "<< elementType <<", \""<< enfMesh->name << "\", \"" << enfMesh->groupName.c_str() <<"\")"<<std::endl;
1978 ok = h->p_SetEnforcedMesh(theSource, elementType, enfMesh->name.c_str(), enfMesh->groupName.c_str());
1981 // catch(const std::exception& ex) {
1982 // std::cout << "Exception: " << ex.what() << std::endl;
1985 catch ( const SALOME::SALOME_Exception& ex )
1987 SalomeApp_Tools::QtCatchCorbaException( ex );
1993 bool HYBRIDPluginGUI_HypothesisCreator::readParamsFromWidgets( HYBRIDHypothesisData& h_data ) const
1995 h_data.myName = myName ? myName->text() : "";
1996 h_data.myLayersOnAllWrap = myLayersOnAllWrapCheck->isChecked();
1997 h_data.myToMeshHoles = myToMeshHolesCheck->isChecked();
1998 h_data.myToMakeGroupsOfDomains = myToMakeGroupsOfDomains->isChecked();
1999 h_data.myMaximumMemory = myAdvWidget->maxMemoryCheck->isChecked() ? myAdvWidget->maxMemorySpin->value() : -1;
2000 h_data.myInitialMemory = myAdvWidget->initialMemoryCheck->isChecked() ? myAdvWidget->initialMemorySpin->value() : -1;
2001 h_data.myOptimizationLevel = myOptimizationLevelCombo->currentIndex();
2003 h_data.myCollisionMode = myCollisionModeCombo->currentIndex();
2004 h_data.myBoundaryLayersGrowth = myBoundaryLayersGrowthCombo->currentIndex();
2005 h_data.myElementGeneration = myElementGenerationCombo->currentIndex();
2006 h_data.myAddMultinormals = myAddMultinormalsCheck->isChecked();
2007 h_data.mySmoothNormals = mySmoothNormalsCheck->isChecked();
2009 h_data.myHeightFirstLayer = myHeightFirstLayerSpin -> value();
2010 h_data.myNbOfBoundaryLayers = myNbOfBoundaryLayersSpin -> value();
2011 h_data.myBoundaryLayersProgression = myBoundaryLayersProgressionSpin -> value();
2012 h_data.myCoreSize = myCoreSizeSpin->text().isEmpty() ? 0.0 : myCoreSizeSpin -> value();
2013 h_data.myMultinormalsAngle = myMultinormalsAngleSpin -> value();
2014 h_data.myFaceWLIds = myFaceSelectorLayers->GetListOfIDs();
2015 h_data.myFaceWIIds = myFaceSelectorImprinting->GetListOfIDs();
2017 h_data.myKeepFiles = myAdvWidget->keepWorkingFilesCheck->isChecked();
2018 h_data.myWorkingDir = myAdvWidget->workingDirectoryLineEdit->text().trimmed();
2019 h_data.myVerboseLevel = myAdvWidget->verboseLevelSpin->value();
2020 h_data.myToCreateNewNodes = myAdvWidget->createNewNodesCheck->isChecked();
2021 h_data.myRemoveInitialCentralPoint = myAdvWidget->removeInitialCentralPointCheck->isChecked();
2022 h_data.myBoundaryRecovery = myAdvWidget->boundaryRecoveryCheck->isChecked();
2023 h_data.myFEMCorrection = myAdvWidget->FEMCorrectionCheck->isChecked();
2024 h_data.myGradation = myAdvWidget->gradationSpinBox->value();
2025 h_data.myTextOption = myAdvWidget->myAdvOptionsTable->GetCustomOptions();
2026 h_data.myLogInStandardOutput = !myAdvWidget->logInFileCheck->isChecked();
2027 h_data.myRemoveLogOnSuccess = myAdvWidget->removeLogOnSuccessCheck->isChecked();
2029 // Enforced vertices
2030 h_data.myEnforcedVertices.clear();
2031 QVariant valueX, valueY, valueZ;
2032 for (int row=0 ; row<myEnforcedTableWidget->rowCount() ; row++) {
2034 TEnfVertex *myVertex = new TEnfVertex();
2035 myVertex->name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString();
2036 myVertex->geomEntry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString();
2037 if (myVertex->geomEntry.size())
2038 myVertex->groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
2039 if (myVertex->groupName.size())
2040 valueX = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data(Qt::EditRole);
2041 valueY = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data(Qt::EditRole);
2042 valueZ = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data(Qt::EditRole);
2043 if (!valueX.isNull() && !valueY.isNull() && !valueZ.isNull()) {
2044 myVertex->coords.push_back(valueX.toDouble());
2045 myVertex->coords.push_back(valueY.toDouble());
2046 myVertex->coords.push_back(valueZ.toDouble());
2048 myVertex->size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data(Qt::EditRole).toDouble();
2049 myVertex->isCompound = myEnforcedTableWidget->item(row,ENF_VER_COMPOUND_COLUMN)->data(Qt::CheckStateRole).toBool();
2050 h_data.myEnforcedVertices.insert(myVertex);
2054 h_data.myEnforcedMeshes.clear();
2056 for (int row=0 ; row<myEnforcedMeshTableWidget->rowCount() ; row++) {
2058 TEnfMesh *myEnfMesh = new TEnfMesh();
2059 myEnfMesh->name = myEnforcedMeshTableWidget->item(row,ENF_MESH_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString();
2060 myEnfMesh->entry = myEnforcedMeshTableWidget->item(row,ENF_MESH_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString();
2061 myEnfMesh->groupName = myEnforcedMeshTableWidget->item(row,ENF_MESH_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
2062 QComboBox* combo = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row,ENF_MESH_CONSTRAINT_COLUMN));
2063 myEnfMesh->elementType = combo->currentIndex();
2064 h_data.myEnforcedMeshes.insert(myEnfMesh);
2065 std::cout << "h_data.myEnforcedMeshes.size(): " << h_data.myEnforcedMeshes.size() << std::endl;
2071 QString HYBRIDPluginGUI_HypothesisCreator::caption() const
2073 return tr( "HYBRID_TITLE" );
2076 QPixmap HYBRIDPluginGUI_HypothesisCreator::icon() const
2078 return SUIT_Session::session()->resourceMgr()->loadPixmap( "HYBRIDPlugin", tr( "ICON_DLG_HYBRID_PARAMETERS" ) );
2081 QString HYBRIDPluginGUI_HypothesisCreator::type() const
2083 return tr( "HYBRID_HYPOTHESIS" );
2086 QString HYBRIDPluginGUI_HypothesisCreator::helpPage() const
2088 return "hybrid_hypo_page.html";