1 // Copyright (C) 2004-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
20 // GHS3DPlugin GUI: GUI for plugged-in mesher GHS3DPlugin
21 // File : GHS3DPluginGUI_HypothesisCreator.cxx
22 // Author : Michael Zorin
23 // Module : GHS3DPlugin
25 #include "GHS3DPluginGUI_HypothesisCreator.h"
26 #include "GHS3DPluginGUI_Enums.h"
27 #include "GHS3DPluginGUI_Dlg.h"
28 #include "GHS3DPlugin_OptimizerHypothesis.hxx"
30 #include <GeometryGUI.h>
32 #include <SMESHGUI_Utils.h>
33 #include <SMESHGUI_SpinBox.h>
34 #include <SMESHGUI_HypothesesUtils.h>
35 #include <SMESH_NumberFilter.hxx>
36 #include <SMESH_TypeFilter.hxx>
37 #include <StdMeshersGUI_ObjectReferenceParamWdg.h>
39 #include <LightApp_SelectionMgr.h>
40 #include <SUIT_FileDlg.h>
41 #include <SUIT_MessageBox.h>
42 #include <SUIT_ResourceMgr.h>
43 #include <SUIT_Session.h>
44 #include <SalomeApp_IntSpinBox.h>
45 #include <SalomeApp_Tools.h>
46 #include <SalomeApp_TypeFilter.h>
52 #include <QGridLayout>
54 #include <QHeaderView>
58 #include <QPushButton>
61 #include <QTableWidget>
62 #include <QTableWidgetItem>
63 #include <QVBoxLayout>
66 #include <utilities.h>
70 QComboBox* getModeCombo( QWidget* parent, bool isPThreadCombo )
72 QComboBox* combo = new QComboBox( parent );
75 combo->insertItem((int) GHS3DPlugin_OptimizerHypothesis::SAFE, QObject::tr("MODE_SAFE"));
76 combo->insertItem((int) GHS3DPlugin_OptimizerHypothesis::AGGRESSIVE, QObject::tr("MODE_AGGRESSIVE"));
77 combo->insertItem((int) GHS3DPlugin_OptimizerHypothesis::NONE, QObject::tr("MODE_NONE"));
81 combo->insertItem((int) GHS3DPlugin_OptimizerHypothesis::NO, QObject::tr("MODE_NO"));
82 combo->insertItem((int) GHS3DPlugin_OptimizerHypothesis::YES, QObject::tr("MODE_YES"));
83 combo->insertItem((int) GHS3DPlugin_OptimizerHypothesis::ONLY, QObject::tr("MODE_ONLY"));
90 // BEGIN EnforcedVertexTableWidgetDelegate
93 EnforcedVertexTableWidgetDelegate::EnforcedVertexTableWidgetDelegate(QObject *parent)
94 : QItemDelegate(parent)
98 QWidget *EnforcedVertexTableWidgetDelegate::createEditor(QWidget *parent,
99 const QStyleOptionViewItem & option ,
100 const QModelIndex & index ) const
102 QModelIndex father = index.parent();
103 QString entry = father.child(index.row(), ENF_VER_ENTRY_COLUMN).data().toString();
105 if (index.column() == ENF_VER_X_COLUMN ||
106 index.column() == ENF_VER_Y_COLUMN ||
107 index.column() == ENF_VER_Z_COLUMN ||
108 index.column() == ENF_VER_SIZE_COLUMN) {
109 SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent);
110 if (index.column() == ENF_VER_SIZE_COLUMN)
111 editor->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
113 editor->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
114 editor->setReadOnly(!entry.isEmpty());
115 editor->setDisabled(!entry.isEmpty());
118 else if (index.column() == ENF_VER_GROUP_COLUMN ||
119 index.column() == ENF_VER_NAME_COLUMN) {
121 QLineEdit *editor = new QLineEdit(parent);
122 if (index.column() != ENF_VER_GROUP_COLUMN) {
123 editor->setReadOnly(!entry.isEmpty());
124 editor->setDisabled(!entry.isEmpty());
128 return QItemDelegate::createEditor(parent, option, index);
131 void EnforcedVertexTableWidgetDelegate::setEditorData(QWidget *editor,
132 const QModelIndex &index) const
134 if (index.column() == ENF_VER_X_COLUMN ||
135 index.column() == ENF_VER_Y_COLUMN ||
136 index.column() == ENF_VER_Z_COLUMN ||
137 index.column() == ENF_VER_SIZE_COLUMN)
139 SMESHGUI_SpinBox *lineEdit = qobject_cast<SMESHGUI_SpinBox*>(editor);
140 lineEdit->SetValue(index.data().toDouble());
142 else if (index.column() == ENF_VER_COMPOUND_COLUMN) {
143 QCheckBox *checkBox = qobject_cast<QCheckBox*>(editor);
144 checkBox->setChecked(index.data().toBool());
147 QItemDelegate::setEditorData(editor, index);
151 void EnforcedVertexTableWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
152 const QModelIndex &index) const
154 QModelIndex parent = index.parent();
156 QString entry = parent.child(index.row(), ENF_VER_ENTRY_COLUMN).data().toString();
157 bool isCompound = parent.child(index.row(), ENF_VER_COMPOUND_COLUMN).data(Qt::CheckStateRole).toBool();
159 if (index.column() == ENF_VER_X_COLUMN ||
160 index.column() == ENF_VER_Y_COLUMN ||
161 index.column() == ENF_VER_Z_COLUMN) {
162 SMESHGUI_SpinBox *lineEdit = qobject_cast<SMESHGUI_SpinBox*>(editor);
163 if (!isCompound && !vertexExists(model, index, lineEdit->GetString()))
164 model->setData(index, lineEdit->GetValue(), Qt::EditRole);
166 else if (index.column() == ENF_VER_SIZE_COLUMN)
168 SMESHGUI_SpinBox *lineEdit = qobject_cast<SMESHGUI_SpinBox*>(editor);
169 const double newsize = lineEdit->GetValue();
171 model->setData(index, newsize, Qt::EditRole);
173 else if (index.column() == ENF_VER_NAME_COLUMN) {
174 QLineEdit *lineEdit = qobject_cast<QLineEdit*>(editor);
175 QString value = lineEdit->text();
176 if (entry.isEmpty() && !vertexExists(model, index, value))
177 model->setData(index, value, Qt::EditRole);
179 else if (index.column() == ENF_VER_ENTRY_COLUMN) {
180 QLineEdit *lineEdit = qobject_cast<QLineEdit*>(editor);
181 QString value = lineEdit->text();
182 if (! vertexExists(model, index, value))
183 model->setData(index, value, Qt::EditRole);
185 else if (index.column() == ENF_VER_COMPOUND_COLUMN) {
186 QCheckBox *checkBox = qobject_cast<QCheckBox*>(editor);
187 model->setData(index, checkBox->isChecked(), Qt::CheckStateRole);
190 QItemDelegate::setModelData(editor, model, index);
194 void EnforcedVertexTableWidgetDelegate::updateEditorGeometry(QWidget *editor,
195 const QStyleOptionViewItem &option,
196 const QModelIndex &/* index */) const
198 editor->setGeometry(option.rect);
201 bool EnforcedVertexTableWidgetDelegate::vertexExists(QAbstractItemModel *model,
202 const QModelIndex &index,
206 QModelIndex parent = index.parent();
207 int row = index.row();
208 int col = index.column();
210 if (parent.isValid() && !value.isEmpty()) {
211 if (col == ENF_VER_X_COLUMN || col == ENF_VER_Y_COLUMN || col == ENF_VER_Z_COLUMN) {
213 if (col == ENF_VER_X_COLUMN) {
214 x = value.toDouble();
215 y = parent.child(row, ENF_VER_Y_COLUMN).data().toDouble();
216 z = parent.child(row, ENF_VER_Z_COLUMN).data().toDouble();
218 if (col == ENF_VER_Y_COLUMN) {
219 y = value.toDouble();
220 x = parent.child(row, ENF_VER_X_COLUMN).data().toDouble();
221 z = parent.child(row, ENF_VER_Z_COLUMN).data().toDouble();
223 if (col == ENF_VER_Z_COLUMN) {
224 z = value.toDouble();
225 x = parent.child(row, ENF_VER_X_COLUMN).data().toDouble();
226 y = parent.child(row, ENF_VER_Y_COLUMN).data().toDouble();
228 int nbChildren = model->rowCount(parent);
229 for (int i = 0 ; i < nbChildren ; i++) {
231 double childX = parent.child(i, ENF_VER_X_COLUMN).data().toDouble();
232 double childY = parent.child(i, ENF_VER_Y_COLUMN).data().toDouble();
233 double childZ = parent.child(i, ENF_VER_Z_COLUMN).data().toDouble();
234 if ((childX == x) && (childY == y) && (childZ == z)) {
241 else if (col == ENF_VER_NAME_COLUMN) {
242 QString name = parent.child(row, ENF_VER_NAME_COLUMN).data().toString();
252 // END EnforcedVertexTableWidgetDelegate
256 // BEGIN EnforcedMeshTableWidgetDelegate
259 EnforcedMeshTableWidgetDelegate::EnforcedMeshTableWidgetDelegate(QObject *parent)
260 : QItemDelegate(parent)
264 QWidget *EnforcedMeshTableWidgetDelegate::createEditor(QWidget *parent,
265 const QStyleOptionViewItem & option ,
266 const QModelIndex & index ) const
268 return QItemDelegate::createEditor(parent, option, index);
271 void EnforcedMeshTableWidgetDelegate::setEditorData(QWidget *editor,
272 const QModelIndex &index) const
274 QItemDelegate::setEditorData(editor, index);
277 void EnforcedMeshTableWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
278 const QModelIndex &index) const
280 QItemDelegate::setModelData(editor, model, index);
284 void EnforcedMeshTableWidgetDelegate::updateEditorGeometry(QWidget *editor,
285 const QStyleOptionViewItem &option,
286 const QModelIndex &/* index */) const
288 editor->setGeometry(option.rect);
292 // END EnforcedMeshTableWidgetDelegate
296 GHS3DPluginGUI_HypothesisCreator::GHS3DPluginGUI_HypothesisCreator( const QString& theHypType )
297 : SMESHGUI_GenericHypothesisCreator( theHypType )
299 GeomToolSelected = NULL;
300 GeomToolSelected = getGeomSelectionTool();
302 iconVertex = QPixmap(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_OBJBROWSER_VERTEX")));
303 iconCompound = QPixmap(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_OBJBROWSER_COMPOUND")));
304 // mySelectionMgr = SMESH::GetSelectionMgr(SMESHGUI::GetSMESHGUI());
305 myEnfMeshConstraintLabels << tr( "GHS3D_ENF_MESH_CONSTRAINT_NODE" ) << tr( "GHS3D_ENF_MESH_CONSTRAINT_EDGE" ) << tr("GHS3D_ENF_MESH_CONSTRAINT_FACE");
308 GHS3DPluginGUI_HypothesisCreator::~GHS3DPluginGUI_HypothesisCreator()
310 GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
311 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
312 myEnfMeshWdg->deactivateSelection();
316 * \brief {Get or create the geom selection tool for study}
318 GeomSelectionTools* GHS3DPluginGUI_HypothesisCreator::getGeomSelectionTool()
320 GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
321 if (that->GeomToolSelected == NULL) {
322 that->GeomToolSelected = new GeomSelectionTools();
324 return that->GeomToolSelected;
327 GEOM::GEOM_Gen_var GHS3DPluginGUI_HypothesisCreator::getGeomEngine()
329 return GeometryGUI::GetGeomGen();
332 bool GHS3DPluginGUI_HypothesisCreator::isOptimization() const
334 return ( hypType() == GHS3DPlugin_OptimizerHypothesis::GetHypType() );
337 QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame()
339 QFrame* fr = new QFrame( 0 );
340 QVBoxLayout* lay = new QVBoxLayout( fr );
342 lay->setSpacing( 0 );
345 QTabWidget* tab = new QTabWidget( fr );
346 tab->setTabShape( QTabWidget::Rounded );
347 tab->setTabPosition( QTabWidget::North );
348 lay->addWidget( tab );
351 myStdGroup = new QWidget();
352 QGridLayout* aStdLayout = new QGridLayout( myStdGroup );
353 aStdLayout->setSpacing( 6 );
354 aStdLayout->setMargin( 11 );
360 aStdLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), myStdGroup ), row, 0, 1, 1 );
361 myName = new QLineEdit( myStdGroup );
362 aStdLayout->addWidget( myName, row++, 1, 1, 1 );
365 myToMeshHolesCheck = new QCheckBox( tr( "GHS3D_TO_MESH_HOLES" ), myStdGroup );
366 aStdLayout->addWidget( myToMeshHolesCheck, row, 0, 1, 1 );
367 myToMakeGroupsOfDomains = new QCheckBox( tr( "GHS3D_TO_MAKE_DOMAIN_GROUPS" ), myStdGroup );
368 aStdLayout->addWidget( myToMakeGroupsOfDomains, row++, 1, 1, 1 );
370 QLabel* optimizationLbl = new QLabel( tr( "GHS3D_OPTIMIZATION" ), myStdGroup );
371 aStdLayout->addWidget( optimizationLbl, row, 0, 1, 1 );
372 myOptimizationCombo = getModeCombo( myStdGroup, false );
373 aStdLayout->addWidget( myOptimizationCombo, row++, 1, 1, 1 );
375 QLabel* optimizatiolLevelLbl = new QLabel( tr( "GHS3D_OPTIMIZATIOL_LEVEL" ), myStdGroup );
376 aStdLayout->addWidget( optimizatiolLevelLbl, row, 0, 1, 1 );
377 myOptimizationLevelCombo = new QComboBox( myStdGroup );
378 aStdLayout->addWidget( myOptimizationLevelCombo, row++, 1, 1, 1 );
380 QLabel* splitOverconstrainedLbl = new QLabel( tr("GHS3D_SPLIT_OVERCONSTRAINED"), myStdGroup );
381 aStdLayout->addWidget( splitOverconstrainedLbl, row, 0, 1, 1 );
382 mySplitOverConstrainedCombo = getModeCombo( myStdGroup, false );
383 aStdLayout->addWidget( mySplitOverConstrainedCombo, row++, 1, 1, 1 );
385 QLabel* pthreadsModeLbl = new QLabel( tr( "GHS3D_PTHREADS_MODE" ), myStdGroup);
386 aStdLayout->addWidget( pthreadsModeLbl, row, 0, 1, 1 );
387 myPThreadsModeCombo = getModeCombo( myStdGroup, true );
388 aStdLayout->addWidget( myPThreadsModeCombo, row++, 1, 1, 1 );
390 QLabel* nbThreadsLbl = new QLabel( tr( "GHS3D_NB_THREADS" ), myStdGroup);
391 aStdLayout->addWidget( nbThreadsLbl, row, 0, 1, 1 );
392 myNumberOfThreadsSpin = new SalomeApp_IntSpinBox( 0, 1000, 1, myStdGroup );
393 aStdLayout->addWidget( myNumberOfThreadsSpin, row++, 1, 1, 1 );
395 mySmoothOffSliversCheck = new QCheckBox( tr( "GHS3D_SMOOTH_OFF_SLIVERS" ), myStdGroup );
396 aStdLayout->addWidget( mySmoothOffSliversCheck, row, 0, 1, 1 );
397 myCreateNewNodesCheck = new QCheckBox( tr( "TO_ADD_NODES" ), myStdGroup );
398 aStdLayout->addWidget( myCreateNewNodesCheck, row++, 1, 1, 1 );
400 myOptimizationLevelCombo->addItems( QStringList()
401 << tr( "LEVEL_NONE" ) << tr( "LEVEL_LIGHT" )
402 << tr( "LEVEL_MEDIUM" ) << tr( "LEVEL_STANDARDPLUS" )
403 << tr( "LEVEL_STRONG" ));
404 aStdLayout->setRowStretch( row, 10 );
406 if ( isOptimization() )
408 myToMeshHolesCheck->hide();
409 myToMakeGroupsOfDomains->hide();
413 optimizationLbl->hide();
414 myOptimizationCombo->hide();
415 splitOverconstrainedLbl->hide();
416 mySplitOverConstrainedCombo->hide();
417 pthreadsModeLbl->hide();
418 myPThreadsModeCombo->hide();
419 nbThreadsLbl->hide();
420 myNumberOfThreadsSpin->hide();
421 mySmoothOffSliversCheck->hide();
422 myCreateNewNodesCheck->hide();
425 // advanced parameters
426 myAdvGroup = new QWidget();
427 QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup );
428 anAdvLayout->setSpacing( 6 );
429 anAdvLayout->setMargin( 11 );
430 myAdvWidget = new GHS3DPluginGUI_AdvWidget(myAdvGroup);
431 anAdvLayout->addWidget( myAdvWidget);
433 myAdvWidget->maxMemoryCheck->setText(tr( "MAX_MEMORY_SIZE" ));
434 myAdvWidget->initialMemoryCheck->setText(tr( "INIT_MEMORY_SIZE" ));
436 myAdvWidget->maxMemorySpin->stepBy(10);
437 myAdvWidget->maxMemorySpin->setValue( 128 );
439 myAdvWidget->initialMemorySpin->stepBy(10);
440 myAdvWidget->initialMemorySpin->setValue( 100 );
442 myAdvWidget->initialMemoryLabel ->setText (tr( "MEGABYTE" ));
443 myAdvWidget->maxMemoryLabel ->setText (tr( "MEGABYTE" ));
445 myAdvWidget->workingDirectoryLabel ->setText (tr( "WORKING_DIR" ));
446 myAdvWidget->workingDirectoryPushButton ->setText (tr( "SELECT_DIR" ));
447 myAdvWidget->keepWorkingFilesCheck ->setText (tr( "KEEP_WORKING_FILES" ));
448 myAdvWidget->verboseLevelLabel ->setText (tr( "VERBOSE_LEVEL" ));
449 myAdvWidget->removeLogOnSuccessCheck ->setText (tr( "REMOVE_LOG_ON_SUCCESS" ));
450 myAdvWidget->logInFileCheck ->setText (tr( "LOG_IN_FILE" ));
452 myAdvWidget->memoryGroupBox ->setTitle(tr( "MEMORY_GROUP_TITLE" ));
453 myAdvWidget->logGroupBox ->setTitle(tr( "LOG_GROUP_TITLE" ));
454 myAdvWidget->advancedMeshingGroupBox ->setTitle(tr( "ADVANCED_MESHING_GROUP_TITLE" ));
456 myAdvWidget->createNewNodesCheck ->setText (tr( "TO_ADD_NODES" ));
457 myAdvWidget->removeInitialCentralPointCheck->setText (tr( "NO_INITIAL_CENTRAL_POINT" ));
458 myAdvWidget->boundaryRecoveryCheck ->setText (tr( "RECOVERY_VERSION" ));
459 myAdvWidget->FEMCorrectionCheck ->setText (tr( "FEM_CORRECTION" ));
460 myAdvWidget->gradationLabel ->setText (tr( "GHS3D_GRADATION" ));
461 myAdvWidget->gradationSpinBox->RangeStepAndValidator(0.0, 5.0, 0.05, "length_precision");
463 if ( isOptimization() )
465 myAdvWidget->createNewNodesCheck->hide();
466 myAdvWidget->removeInitialCentralPointCheck->hide();
467 myAdvWidget->boundaryRecoveryCheck->hide();
468 myAdvWidget->FEMCorrectionCheck->hide();
469 myAdvWidget->gradationLabel->hide();
470 myAdvWidget->gradationSpinBox->hide();
473 // Enforced vertices parameters
474 myEnfGroup = new QWidget();
475 QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup);
477 myEnforcedTableWidget = new QTableWidget(myEnfGroup);
478 myEnforcedTableWidget ->setMinimumWidth(300);
479 myEnforcedTableWidget->setRowCount( 0 );
480 myEnforcedTableWidget->setColumnCount( ENF_VER_NB_COLUMNS );
481 myEnforcedTableWidget->setSortingEnabled(true);
482 myEnforcedTableWidget->setHorizontalHeaderLabels
484 << tr( "GHS3D_ENF_NAME_COLUMN" ) << tr( "GHS3D_ENF_VER_X_COLUMN" )
485 << tr( "GHS3D_ENF_VER_Y_COLUMN" ) << tr( "GHS3D_ENF_VER_Z_COLUMN" )
486 << tr( "GHS3D_ENF_SIZE_COLUMN" ) << tr("GHS3D_ENF_ENTRY_COLUMN")
487 << tr("GHS3D_ENF_VER_COMPOUND_COLUMN") << tr( "GHS3D_ENF_GROUP_COLUMN" ));
488 myEnforcedTableWidget->verticalHeader()->hide();
489 myEnforcedTableWidget->horizontalHeader()->setStretchLastSection(true);
490 myEnforcedTableWidget->setAlternatingRowColors(true);
491 myEnforcedTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
492 myEnforcedTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
493 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
494 myEnforcedTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
496 myEnforcedTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
498 myEnforcedTableWidget->resizeColumnsToContents();
499 myEnforcedTableWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
500 myEnforcedTableWidget->hideColumn(ENF_VER_COMPOUND_COLUMN);
502 myEnforcedTableWidget->setItemDelegate(new EnforcedVertexTableWidgetDelegate());
505 TColStd_MapOfInteger shapeTypes;
506 shapeTypes.Add( TopAbs_VERTEX );
507 shapeTypes.Add( TopAbs_COMPOUND );
509 SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes);
510 myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true);
511 myEnfVertexWdg->SetDefaultText(tr("GHS3D_ENF_SELECT_VERTEX"), "QLineEdit { color: grey }");
513 QLabel* myXCoordLabel = new QLabel( tr( "GHS3D_ENF_VER_X_LABEL" ), myEnfGroup );
514 myXCoord = new SMESHGUI_SpinBox(myEnfGroup);
515 myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
516 QLabel* myYCoordLabel = new QLabel( tr( "GHS3D_ENF_VER_Y_LABEL" ), myEnfGroup );
517 myYCoord = new SMESHGUI_SpinBox(myEnfGroup);
518 myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
519 QLabel* myZCoordLabel = new QLabel( tr( "GHS3D_ENF_VER_Z_LABEL" ), myEnfGroup );
520 myZCoord = new SMESHGUI_SpinBox(myEnfGroup);
521 myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
522 QLabel* mySizeLabel = new QLabel( tr( "GHS3D_ENF_SIZE_LABEL" ), myEnfGroup );
523 mySizeValue = new SMESHGUI_SpinBox(myEnfGroup);
524 mySizeValue->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
526 QLabel* myGroupNameLabel = new QLabel( tr( "GHS3D_ENF_GROUP_LABEL" ), myEnfGroup );
527 myGroupName = new QLineEdit(myEnfGroup);
529 addVertexButton = new QPushButton(tr("GHS3D_ENF_ADD"),myEnfGroup);
530 addVertexButton->setEnabled(false);
531 removeVertexButton = new QPushButton(tr("GHS3D_ENF_REMOVE"),myEnfGroup);
533 anEnfLayout->addWidget(myEnforcedTableWidget, ENF_VER_VERTEX, 0, ENF_VER_NB_LINES, 1);
535 QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup);
536 anEnfLayout2->addWidget(myEnfVertexWdg, ENF_VER_VERTEX, 0, 1, 2);
537 anEnfLayout2->addWidget(myXCoordLabel, ENF_VER_X_COORD, 0, 1, 1);
538 anEnfLayout2->addWidget(myXCoord, ENF_VER_X_COORD, 1, 1, 1);
539 anEnfLayout2->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 0, 1, 1);
540 anEnfLayout2->addWidget(myYCoord, ENF_VER_Y_COORD, 1, 1, 1);
541 anEnfLayout2->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 0, 1, 1);
542 anEnfLayout2->addWidget(myZCoord, ENF_VER_Z_COORD, 1, 1, 1);
543 anEnfLayout2->addWidget(mySizeLabel, ENF_VER_SIZE, 0, 1, 1);
544 anEnfLayout2->addWidget(mySizeValue, ENF_VER_SIZE, 1, 1, 1);
545 anEnfLayout2->addWidget(myGroupNameLabel, ENF_VER_GROUP, 0, 1, 1);
546 anEnfLayout2->addWidget(myGroupName, ENF_VER_GROUP, 1, 1, 1);
547 anEnfLayout2->addWidget(addVertexButton, ENF_VER_BTN, 0, 1, 1);
548 anEnfLayout2->addWidget(removeVertexButton, ENF_VER_BTN, 1, 1, 1);
549 anEnfLayout2->setRowStretch(ENF_VER_NB_LINES, 1);
551 anEnfLayout->addLayout(anEnfLayout2, ENF_VER_VERTEX, 1,ENF_VER_NB_LINES, 1);
552 anEnfLayout->setRowStretch(ENF_VER_VERTEX, 10);
555 // Enforced meshes parameters
556 myEnfMeshGroup = new QWidget();
557 QGridLayout* anEnfMeshLayout = new QGridLayout(myEnfMeshGroup);
559 myEnforcedMeshTableWidget = new QTableWidget(myEnfGroup);
560 myEnforcedMeshTableWidget->setRowCount( 0 );
561 myEnforcedMeshTableWidget->setColumnCount( ENF_MESH_NB_COLUMNS );
562 myEnforcedMeshTableWidget->setSortingEnabled(true);
563 myEnforcedMeshTableWidget->verticalHeader()->hide();
564 QStringList enforcedMeshHeaders;
565 enforcedMeshHeaders << tr( "GHS3D_ENF_NAME_COLUMN" )
566 << tr( "GHS3D_ENF_ENTRY_COLUMN" )
567 << tr( "GHS3D_ENF_MESH_CONSTRAINT_COLUMN" )
568 << tr( "GHS3D_ENF_GROUP_COLUMN" );
569 myEnforcedMeshTableWidget->setHorizontalHeaderLabels(enforcedMeshHeaders);
570 myEnforcedMeshTableWidget->horizontalHeader()->setStretchLastSection(true);
571 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
572 myEnforcedMeshTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
574 myEnforcedMeshTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
576 myEnforcedMeshTableWidget->setAlternatingRowColors(true);
577 myEnforcedMeshTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
578 myEnforcedMeshTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
579 myEnforcedMeshTableWidget->resizeColumnsToContents();
580 myEnforcedMeshTableWidget->hideColumn(ENF_MESH_ENTRY_COLUMN);
582 myEnforcedMeshTableWidget->setItemDelegate(new EnforcedMeshTableWidgetDelegate());
584 myEnfMeshWdg = new StdMeshersGUI_ObjectReferenceParamWdg( SMESH::IDSOURCE, myEnfMeshGroup, /*multiSel=*/true);
585 myEnfMeshWdg->SetDefaultText(tr("GHS3D_ENF_SELECT_MESH"), "QLineEdit { color: grey }");
587 myEnfMeshWdg->AvoidSimultaneousSelection(myEnfVertexWdg);
589 QLabel* myMeshConstraintLabel = new QLabel( tr( "GHS3D_ENF_MESH_CONSTRAINT_LABEL" ), myEnfMeshGroup );
590 myEnfMeshConstraint = new QComboBox(myEnfMeshGroup);
591 myEnfMeshConstraint->insertItems(0,myEnfMeshConstraintLabels);
592 myEnfMeshConstraint->setEditable(false);
593 myEnfMeshConstraint->setCurrentIndex(0);
595 QLabel* myMeshGroupNameLabel = new QLabel( tr( "GHS3D_ENF_GROUP_LABEL" ), myEnfMeshGroup );
596 myMeshGroupName = new QLineEdit(myEnfMeshGroup);
598 addEnfMeshButton = new QPushButton(tr("GHS3D_ENF_ADD"),myEnfMeshGroup);
599 removeEnfMeshButton = new QPushButton(tr("GHS3D_ENF_REMOVE"),myEnfMeshGroup);
601 anEnfMeshLayout->addWidget(myEnforcedMeshTableWidget, ENF_MESH_MESH, 0, ENF_MESH_NB_LINES , 1);
603 QGridLayout* anEnfMeshLayout2 = new QGridLayout(myEnfMeshGroup);
604 anEnfMeshLayout2->addWidget(myEnfMeshWdg, ENF_MESH_MESH, 0, 1, 2);
605 anEnfMeshLayout2->addWidget(myMeshConstraintLabel, ENF_MESH_CONSTRAINT, 0, 1, 1);
606 anEnfMeshLayout2->addWidget(myEnfMeshConstraint, ENF_MESH_CONSTRAINT, 1, 1, 1);
607 anEnfMeshLayout2->addWidget(myMeshGroupNameLabel, ENF_MESH_GROUP, 0, 1, 1);
608 anEnfMeshLayout2->addWidget(myMeshGroupName, ENF_MESH_GROUP, 1, 1, 1);
609 anEnfMeshLayout2->addWidget(addEnfMeshButton, ENF_MESH_BTN, 0, 1, 1);
610 anEnfMeshLayout2->addWidget(removeEnfMeshButton, ENF_MESH_BTN, 1, 1, 1);
611 anEnfMeshLayout2->setRowStretch(ENF_MESH_NB_LINES, 1);
613 anEnfMeshLayout->addLayout(anEnfMeshLayout2, ENF_MESH_MESH, 1, ENF_MESH_NB_LINES, 1);
614 anEnfMeshLayout->setRowStretch(ENF_MESH_MESH, 10);
617 tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
618 tab->insertTab( ADV_TAB, myAdvGroup, tr( "GHS3D_ADV_ARGS" ) );
619 if ( !isOptimization() )
621 tab->insertTab( ENF_VER_TAB, myEnfGroup, tr( "GHS3D_ENFORCED_VERTICES" ) );
622 tab->insertTab( ENF_MESH_TAB, myEnfMeshGroup, tr( "GHS3D_ENFORCED_MESHES" ) );
624 tab->setCurrentIndex( STD_TAB );
626 connect( myAdvWidget->maxMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
627 connect( myAdvWidget->initialMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
628 connect( myAdvWidget->boundaryRecoveryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
629 connect( myAdvWidget->logInFileCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
630 connect( myAdvWidget->keepWorkingFilesCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
631 connect( myAdvWidget->workingDirectoryPushButton, SIGNAL( clicked() ), this, SLOT( onDirBtnClicked() ) );
633 connect( myEnforcedTableWidget, SIGNAL( itemClicked(QTableWidgetItem *)), this, SLOT( synchronizeCoords() ) );
634 connect( myEnforcedTableWidget, SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
635 connect( myEnforcedTableWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
636 connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertex() ) );
637 connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
638 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
639 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
640 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
641 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
642 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
643 connect( mySizeValue, SIGNAL( textChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) );
644 connect( myXCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
645 connect( myYCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
646 connect( myZCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
647 connect( mySizeValue, SIGNAL( valueChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) );
648 connect( this, SIGNAL( vertexDefined(bool) ), addVertexButton, SLOT( setEnabled(bool) ) );
650 connect( addEnfMeshButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedMesh() ) );
651 connect( removeEnfMeshButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedMesh() ) );
657 * This method checks if an enforced vertex is defined;
659 void GHS3DPluginGUI_HypothesisCreator::clearEnfVertexSelection()
661 if (myEnfVertexWdg->NbObjects() != 0) {
662 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
663 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
664 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
665 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
666 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
668 GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
669 that->checkVertexIsDefined();
673 * This method checks if an enforced vertex is defined;
675 void GHS3DPluginGUI_HypothesisCreator::checkVertexIsDefined()
677 bool enfVertexIsDefined = false;
678 enfVertexIsDefined = (!mySizeValue->GetString().isEmpty() &&
679 (!myEnfVertexWdg->NbObjects() == 0 ||
680 (myEnfVertexWdg->NbObjects() == 0 && !myXCoord->GetString().isEmpty()
681 && !myYCoord->GetString().isEmpty()
682 && !myZCoord->GetString().isEmpty())));
683 emit vertexDefined(enfVertexIsDefined);
687 * This method checks if an enforced mesh is defined;
689 void GHS3DPluginGUI_HypothesisCreator::checkEnfMeshIsDefined()
691 emit enfMeshDefined( myEnfVertexWdg->NbObjects() != 0);
695 * This method resets the content of the X, Y, Z, size and GroupName widgets;
697 void GHS3DPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
699 myXCoord->setCleared(true);
700 myYCoord->setCleared(true);
701 myZCoord->setCleared(true);
702 myXCoord->setText("");
703 myYCoord->setText("");
704 myZCoord->setText("");
705 addVertexButton->setEnabled(false);
708 /** GHS3DPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item)
709 This method updates the tooltip of a modified item. The QLineEdit widgets content
710 is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
712 void GHS3DPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTableWidgetItem* item)
714 int row = myEnforcedTableWidget->row(item);
716 QVariant vertexName = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole);
717 QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole);
718 QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole);
719 QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole);
720 QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole);
721 QVariant entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
722 QString groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole).toString();
724 clearEnforcedVertexWidgets();
726 if ( !x.isNull() || !entry.isNull()) {
727 QString toolTip = vertexName.toString();
728 toolTip += QString("(");
729 if (entry.isNull() || (!entry.isNull() && entry.toString() == "")) {
730 toolTip += x.toString();
731 toolTip += QString(", ") + y.toString();
732 toolTip += QString(", ") + z.toString();
735 toolTip += entry.toString();
736 toolTip += QString(")");
739 toolTip += QString("=") + size.toString();
741 if (!groupName.isEmpty())
742 toolTip += QString(" [") + groupName + QString("]");
744 for (int col=0;col<ENF_VER_NB_COLUMNS;col++)
745 myEnforcedTableWidget->item(row,col)->setToolTip(toolTip);
748 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
749 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
750 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
751 myXCoord->SetValue(x.toDouble());
752 myYCoord->SetValue(y.toDouble());
753 myZCoord->SetValue(z.toDouble());
754 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
755 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
756 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
759 mySizeValue->SetValue(size.toDouble());
761 if (!groupName.isEmpty())
762 myGroupName->setText(groupName);
766 void GHS3DPluginGUI_HypothesisCreator::onSelectEnforcedVertex()
768 int nbSelEnfVertex = myEnfVertexWdg->NbObjects();
769 clearEnforcedVertexWidgets();
770 if (nbSelEnfVertex == 1)
772 if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() )
775 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
776 if (myEnfVertex == GEOM::GEOM_Object::_nil())
778 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
779 GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
780 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( );
781 if (CORBA::is_nil(measureOp))
785 measureOp->PointCoordinates (myEnfVertex, x, y, z);
786 if ( measureOp->IsDone() )
788 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
789 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
790 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
791 myXCoord->SetValue(x);
792 myYCoord->SetValue(y);
793 myZCoord->SetValue(z);
794 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
795 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
796 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
802 /** GHS3DPluginGUI_HypothesisCreator::synchronizeCoords()
803 This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
804 of the enforced vertex clicked in the tree widget.
806 void GHS3DPluginGUI_HypothesisCreator::synchronizeCoords()
808 clearEnforcedVertexWidgets();
809 QList<QTableWidgetItem *> items = myEnforcedTableWidget->selectedItems();
810 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
811 if (! items.isEmpty()) {
812 QTableWidgetItem *item;
815 if (items.size() == 1) {
817 row = myEnforcedTableWidget->row(item);
818 QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole);
819 QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole);
820 QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole);
821 QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole);
822 entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
823 if (!entry.isNull()) {
824 SMESH::string_array_var objIds = new SMESH::string_array;
826 objIds[0] = entry.toString().toStdString().c_str();
827 myEnfVertexWdg->SetObjects(objIds);
830 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
832 QVariant group = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole);
833 if (!x.isNull()/* && entry.isNull()*/) {
834 // disconnect( myXCoord, SIGNAL( textChanged(const QString &)), this, SLOT( onSelectEnforcedVertex() ) );
835 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
836 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
837 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
838 myXCoord->SetValue(x.toDouble());
839 myYCoord->SetValue(y.toDouble());
840 myZCoord->SetValue(z.toDouble());
841 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
842 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
843 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
846 mySizeValue->SetValue(size.toDouble());
848 if (!group.isNull() && (!x.isNull() || !entry.isNull()))
849 myGroupName->setText(group.toString());
852 QList<QString> entryList;
853 for (int i = 0; i < items.size(); ++i) {
855 row = myEnforcedTableWidget->row(item);
856 entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
858 entryList << entry.toString();
860 if (entryList.size() > 0) {
861 SMESH::string_array_var objIds = new SMESH::string_array;
862 objIds->length(entryList.size());
863 for (int i = 0; i < entryList.size() ; i++)
864 objIds[i] = entryList.at(i).toStdString().c_str();
865 myEnfVertexWdg->SetObjects(objIds);
868 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
873 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
875 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
876 GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
877 that->checkVertexIsDefined();
880 /** GHS3DPluginGUI_HypothesisCreator::addEnforcedMesh( meshName, geomEntry, elemType, size, groupName)
881 This method adds in the tree widget an enforced mesh from mesh, submesh or group with optionally size and and groupName.
883 void GHS3DPluginGUI_HypothesisCreator::addEnforcedMesh(std::string name,
886 std::string groupName)
888 bool okToCreate = true;
889 QString itemEntry = "";
890 int itemElementType = 0;
891 int rowCount = myEnforcedMeshTableWidget->rowCount();
892 bool allColumns = true;
893 for (int row = 0;row<rowCount;row++) {
894 for (int col = 0 ; col < ENF_MESH_NB_COLUMNS ; col++) {
895 if (col == ENF_MESH_CONSTRAINT_COLUMN){
896 if (qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row, col)) == 0) {
901 else if (myEnforcedMeshTableWidget->item(row, col) == 0) {
905 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
906 QComboBox* itemComboBox = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row, col));
907 itemElementType = itemComboBox->currentIndex();
909 else if (col == ENF_MESH_ENTRY_COLUMN)
910 itemEntry = myEnforcedMeshTableWidget->item(row, col)->data(Qt::EditRole).toString();
916 if (itemEntry == QString(entry.c_str()) && itemElementType == elementType) {
926 myEnforcedMeshTableWidget->setRowCount(rowCount+1);
927 myEnforcedMeshTableWidget->setSortingEnabled(false);
929 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++) {
930 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
931 QComboBox* comboBox = new QComboBox();
932 QPalette pal = comboBox->palette();
933 pal.setColor(QPalette::Button, Qt::white);
934 comboBox->setPalette(pal);
935 comboBox->insertItems(0,myEnfMeshConstraintLabels);
936 comboBox->setEditable(false);
937 comboBox->setCurrentIndex(elementType);
938 myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox);
941 QTableWidgetItem* item = new QTableWidgetItem();
942 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
944 case ENF_MESH_NAME_COLUMN:
945 item->setData( 0, name.c_str() );
946 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
947 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
949 case ENF_MESH_ENTRY_COLUMN:
950 item->setData( 0, entry.c_str() );
951 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
952 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
954 case ENF_MESH_GROUP_COLUMN:
955 item->setData( 0, groupName.c_str() );
956 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
963 myEnforcedMeshTableWidget->setSortingEnabled(true);
966 /** GHS3DPluginGUI_HypothesisCreator::addEnforcedVertex( x, y, z, size, vertexName, geomEntry, groupName)
967 This method adds in the tree widget an enforced vertex with given size and coords (x,y,z) or GEOM vertex or compound and with optionally groupName.
969 void GHS3DPluginGUI_HypothesisCreator::addEnforcedVertex(double x, double y, double z, double size, std::string vertexName, std::string geomEntry, std::string groupName, bool isCompound)
971 myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
972 bool okToCreate = true;
973 double itemX,itemY,itemZ,itemSize = 0;
974 QString itemEntry, itemGroupName = QString("");
975 // bool itemIsCompound;
976 int rowCount = myEnforcedTableWidget->rowCount();
979 for (int row = 0;row<rowCount;row++) {
981 for (int col = 0 ; col < ENF_VER_NB_COLUMNS ; col++) {
982 if (myEnforcedTableWidget->item(row, col) == 0) {
987 data = myEnforcedTableWidget->item(row, col)->data(Qt::EditRole);
988 if (!data.isNull()) {
990 case ENF_VER_GROUP_COLUMN:
991 itemGroupName = data.toString();
993 case ENF_VER_ENTRY_COLUMN:
994 itemEntry = data.toString();
996 case ENF_VER_X_COLUMN:
997 itemX = data.toDouble();
999 case ENF_VER_Y_COLUMN:
1000 itemY = data.toDouble();
1002 case ENF_VER_Z_COLUMN:
1003 itemZ = data.toDouble();
1005 case ENF_VER_SIZE_COLUMN:
1006 itemSize = data.toDouble();
1018 if (( !isCompound && ((itemX == x) && (itemY == y) && (itemZ == z))) ||
1019 ( !itemEntry.isEmpty() && ( itemEntry == geomEntry.c_str() )))
1022 if (itemSize != size) {
1023 myEnforcedTableWidget->item(row, ENF_VER_SIZE_COLUMN)->setData( Qt::EditRole, QVariant(size));
1025 // update group name
1026 if (itemGroupName.toStdString() != groupName) {
1027 myEnforcedTableWidget->item(row, ENF_VER_GROUP_COLUMN)->setData( Qt::EditRole, QVariant(groupName.c_str()));
1034 if (geomEntry.empty()) {
1043 QString myVertexName;
1044 while(indexRef != vertexIndex) {
1045 indexRef = vertexIndex;
1046 if (vertexName.empty())
1047 myVertexName = QString("Vertex #%1").arg(vertexIndex);
1049 myVertexName = QString(vertexName.c_str());
1051 for (int row = 0;row<rowCount;row++) {
1052 QString name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString();
1053 if (myVertexName == name) {
1060 myEnforcedTableWidget->setRowCount(rowCount+1);
1061 myEnforcedTableWidget->setSortingEnabled(false);
1062 for (int col=0;col<ENF_VER_NB_COLUMNS;col++) {
1063 QTableWidgetItem* item = new QTableWidgetItem();
1064 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1066 case ENF_VER_NAME_COLUMN:
1067 item->setData( Qt::EditRole, myVertexName );
1068 if (!geomEntry.empty()) {
1070 item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1072 item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1075 case ENF_VER_X_COLUMN:
1077 item->setData( 0, QVariant(x) );
1079 case ENF_VER_Y_COLUMN:
1081 item->setData( 0, QVariant(y) );
1083 case ENF_VER_Z_COLUMN:
1085 item->setData( 0, QVariant(z) );
1087 case ENF_VER_SIZE_COLUMN:
1088 item->setData( 0, QVariant(size) );
1090 case ENF_VER_ENTRY_COLUMN:
1091 if (!geomEntry.empty())
1092 item->setData( 0, QString(geomEntry.c_str()) );
1094 case ENF_VER_COMPOUND_COLUMN:
1095 item->setData( Qt::CheckStateRole, isCompound );
1096 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
1098 case ENF_VER_GROUP_COLUMN:
1099 if (!groupName.empty())
1100 item->setData( 0, QString(groupName.c_str()) );
1106 myEnforcedTableWidget->setItem(rowCount,col,item);
1109 connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1111 myEnforcedTableWidget->setSortingEnabled(true);
1112 // myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1113 updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1116 /** GHS3DPluginGUI_HypothesisCreator::onAddEnforcedMesh()
1117 This method is called when a item is added into the enforced meshes tree widget
1119 void GHS3DPluginGUI_HypothesisCreator::onAddEnforcedMesh()
1121 GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
1123 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1124 myEnfMeshWdg->deactivateSelection();
1126 for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column)
1127 myEnforcedMeshTableWidget->resizeColumnToContents(column);
1130 int selEnfMeshes = myEnfMeshWdg->NbObjects();
1131 if (selEnfMeshes == 0)
1134 std::string groupName = myMeshGroupName->text().simplified().toStdString();
1136 int elementType = myEnfMeshConstraint->currentIndex();
1139 _PTR(Study) aStudy = SMESH::getStudy();
1140 _PTR(SObject) aSObj;
1141 QString meshEntry = myEnfMeshWdg->GetValue();
1143 if (selEnfMeshes == 1)
1145 aSObj = aStudy->FindObjectID(meshEntry.toStdString().c_str());
1146 CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj);
1147 if (!CORBA::is_nil(anObj)) {
1148 addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
1153 QStringList meshEntries = meshEntry.split(" ", QString::SkipEmptyParts);
1154 QStringListIterator meshEntriesIt (meshEntries);
1155 while (meshEntriesIt.hasNext()) {
1156 aSObj = aStudy->FindObjectID(meshEntriesIt.next().toStdString().c_str());
1157 CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj);
1158 if (!CORBA::is_nil(anObj)) {
1159 addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
1164 myEnfVertexWdg->SetObject(SMESH::SMESH_IDSource::_nil());
1166 for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column)
1167 myEnforcedMeshTableWidget->resizeColumnToContents(column);
1171 /** GHS3DPluginGUI_HypothesisCreator::onAddEnforcedVertex()
1172 This method is called when a item is added into the enforced vertices tree widget
1174 void GHS3DPluginGUI_HypothesisCreator::onAddEnforcedVertex()
1176 GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
1178 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1179 myEnfVertexWdg->deactivateSelection();
1181 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1182 myEnforcedTableWidget->resizeColumnToContents(column);
1185 int selEnfVertex = myEnfVertexWdg->NbObjects();
1186 bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty());
1187 if ((selEnfVertex == 0) && coordsEmpty)
1190 std::string groupName = myGroupName->text().simplified().toStdString();
1192 double size = mySizeValue->GetValue();
1194 if (selEnfVertex <= 1)
1196 double x = 0, y = 0, z=0;
1197 if (myXCoord->GetString() != "") {
1198 x = myXCoord->GetValue();
1199 y = myYCoord->GetValue();
1200 z = myZCoord->GetValue();
1202 if (selEnfVertex == 1) {
1203 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >();
1204 std::string entry = "", name = "";
1205 bool isCompound = false;
1206 if ( !myEnfVertex->_is_nil() ) {
1207 entry = SMESH::toStdStr( myEnfVertex->GetStudyEntry() );
1208 name = SMESH::toStdStr( myEnfVertex->GetName() );
1209 isCompound = ( myEnfVertex->GetShapeType() == GEOM::COMPOUND );
1211 addEnforcedVertex(x, y, z, size, name, entry, groupName, isCompound);
1214 addEnforcedVertex(x, y, z, size, "", "", groupName);
1219 if ( CORBA::is_nil(getGeomEngine()))
1222 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( );
1223 if (CORBA::is_nil(measureOp))
1226 CORBA::Double x = 0, y = 0,z = 0;
1227 for (int j = 0 ; j < selEnfVertex ; j++)
1229 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j);
1230 if (myEnfVertex == GEOM::GEOM_Object::_nil())
1232 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1233 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1234 if ( measureOp->IsDone() )
1235 addEnforcedVertex(x, y, z, size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1236 } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) {
1237 addEnforcedVertex(0., 0., 0., size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName, true);
1242 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1244 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1245 myEnforcedTableWidget->resizeColumnToContents(column);
1248 /** GHS3DPluginGUI_HypothesisCreator::onRemoveEnforcedMesh()
1249 This method is called when a item is removed from the enforced meshes tree widget
1251 void GHS3DPluginGUI_HypothesisCreator::onRemoveEnforcedMesh()
1253 QList<int> selectedRows;
1254 QList<QTableWidgetItem *> selectedItems = myEnforcedMeshTableWidget->selectedItems();
1255 QTableWidgetItem* item;
1257 foreach( item, selectedItems ) {
1259 if (!selectedRows.contains( row ) )
1260 selectedRows.append(row);
1263 qSort( selectedRows );
1264 QListIterator<int> it( selectedRows );
1266 while ( it.hasPrevious() ) {
1267 row = it.previous();
1268 myEnforcedMeshTableWidget->removeRow(row );
1271 myEnforcedMeshTableWidget->selectionModel()->clearSelection();
1274 /** GHS3DPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1275 This method is called when a item is removed from the enforced vertices tree widget
1277 void GHS3DPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1279 QList<int> selectedRows;
1280 QList<QTableWidgetItem *> selectedItems = myEnforcedTableWidget->selectedItems();
1281 QTableWidgetItem* item;
1283 foreach( item, selectedItems ) {
1285 if (!selectedRows.contains( row ) )
1286 selectedRows.append(row);
1289 qSort( selectedRows );
1290 QListIterator<int> it( selectedRows );
1292 while ( it.hasPrevious() ) {
1293 row = it.previous();
1294 myEnforcedTableWidget->removeRow(row );
1297 myEnforcedTableWidget->selectionModel()->clearSelection();
1300 void GHS3DPluginGUI_HypothesisCreator::onToMeshHoles(bool isOn)
1302 // myToMakeGroupsOfDomains->setEnabled( isOn );
1304 // myToMakeGroupsOfDomains->setChecked( false );
1307 void GHS3DPluginGUI_HypothesisCreator::onDirBtnClicked()
1309 QString dir = SUIT_FileDlg::getExistingDirectory( dlg(), myAdvWidget->workingDirectoryLineEdit->text(), QString() );
1310 if ( !dir.isEmpty() )
1311 myAdvWidget->workingDirectoryLineEdit->setText( dir );
1314 void GHS3DPluginGUI_HypothesisCreator::updateWidgets()
1316 //myToMakeGroupsOfDomains->setEnabled( myToMeshHolesCheck->isChecked() );
1317 myAdvWidget->maxMemorySpin->setEnabled( myAdvWidget->maxMemoryCheck->isChecked() );
1318 myAdvWidget->initialMemoryCheck->setEnabled( !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1319 myAdvWidget->initialMemorySpin->setEnabled( myAdvWidget->initialMemoryCheck->isChecked() && !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1320 myOptimizationLevelCombo->setEnabled( !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1321 if ( sender() == myAdvWidget->logInFileCheck ||
1322 sender() == myAdvWidget->keepWorkingFilesCheck )
1324 bool logFileRemovable = myAdvWidget->logInFileCheck->isChecked() &&
1325 !myAdvWidget->keepWorkingFilesCheck->isChecked();
1327 myAdvWidget->removeLogOnSuccessCheck->setEnabled( logFileRemovable );
1331 bool GHS3DPluginGUI_HypothesisCreator::checkParams(QString& msg) const
1333 if ( !QFileInfo( myAdvWidget->workingDirectoryLineEdit->text().trimmed() ).isWritable() ) {
1334 SUIT_MessageBox::warning( dlg(),
1335 tr( "SMESH_WRN_WARNING" ),
1336 tr( "GHS3D_PERMISSION_DENIED" ) );
1343 void GHS3DPluginGUI_HypothesisCreator::retrieveParams() const
1345 GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
1346 GHS3DHypothesisData data;
1347 readParamsFromHypo( data );
1351 myName->setText( data.myName );
1353 int width = QFontMetrics( myName->font() ).width( data.myName );
1354 QGridLayout* aStdLayout = (QGridLayout*) myStdGroup->layout();
1355 aStdLayout->setColumnMinimumWidth( 1, width + 10 );
1357 myToMeshHolesCheck ->setChecked ( data.myToMeshHoles );
1358 myToMakeGroupsOfDomains ->setChecked ( data.myToMakeGroupsOfDomains );
1359 myOptimizationLevelCombo ->setCurrentIndex( data.myOptimizationLevel );
1360 myOptimizationCombo ->setCurrentIndex( data.myOptimization );
1361 mySplitOverConstrainedCombo ->setCurrentIndex( data.mySplitOverConstrained );
1362 myPThreadsModeCombo ->setCurrentIndex( data.myPThreadsMode );
1363 myNumberOfThreadsSpin ->setValue ( data.myNumberOfThreads );
1364 mySmoothOffSliversCheck ->setChecked ( data.mySmoothOffSlivers );
1365 myCreateNewNodesCheck ->setChecked ( data.myToCreateNewNodes );
1367 myAdvWidget->maxMemoryCheck ->setChecked ( data.myMaximumMemory > 0 );
1368 myAdvWidget->maxMemorySpin ->setValue ( qMax( data.myMaximumMemory,
1369 (float)myAdvWidget->maxMemorySpin->minimum() ));
1370 myAdvWidget->initialMemoryCheck ->setChecked ( data.myInitialMemory > 0 );
1371 myAdvWidget->initialMemorySpin ->setValue ( qMax( data.myInitialMemory,
1372 (float)myAdvWidget->initialMemorySpin->minimum() ));
1373 myAdvWidget->workingDirectoryLineEdit ->setText ( data.myWorkingDir );
1374 myAdvWidget->keepWorkingFilesCheck ->setChecked ( data.myKeepFiles );
1375 myAdvWidget->verboseLevelSpin ->setValue ( data.myVerboseLevel );
1376 myAdvWidget->createNewNodesCheck ->setChecked ( data.myToCreateNewNodes );
1377 myAdvWidget->removeInitialCentralPointCheck ->setChecked ( data.myRemoveInitialCentralPoint );
1378 myAdvWidget->boundaryRecoveryCheck ->setChecked ( data.myBoundaryRecovery );
1379 myAdvWidget->FEMCorrectionCheck ->setChecked ( data.myFEMCorrection );
1380 myAdvWidget->gradationSpinBox ->setValue ( data.myGradation );
1381 myAdvWidget->advOptionTable ->SetCustomOptions( data.myTextOption );
1382 myAdvWidget->logInFileCheck ->setChecked ( !data.myLogInStandardOutput );
1383 myAdvWidget->removeLogOnSuccessCheck ->setChecked ( data.myRemoveLogOnSuccess );
1385 TEnfVertexList::const_iterator it;
1387 myEnforcedTableWidget->clearContents();
1388 myEnforcedTableWidget->setSortingEnabled(false);
1389 myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1390 for(it = data.myEnforcedVertices.begin() ; it != data.myEnforcedVertices.end(); it++ )
1392 TEnfVertex* enfVertex = (*it);
1393 myEnforcedTableWidget->setRowCount(rowCount+1);
1395 for (int col=0;col<ENF_VER_NB_COLUMNS;col++) {
1396 QTableWidgetItem* item = new QTableWidgetItem();
1397 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1399 case ENF_VER_NAME_COLUMN:
1400 item->setData( 0, enfVertex->name.c_str() );
1401 if (!enfVertex->geomEntry.empty()) {
1402 if (enfVertex->isCompound)
1403 item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1405 item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1409 case ENF_VER_X_COLUMN:
1410 if (!enfVertex->isCompound) {
1411 item->setData( 0, enfVertex->coords.at(0) );
1414 case ENF_VER_Y_COLUMN:
1415 if (!enfVertex->isCompound) {
1416 item->setData( 0, enfVertex->coords.at(1) );
1419 case ENF_VER_Z_COLUMN:
1420 if (!enfVertex->isCompound) {
1421 item->setData( 0, enfVertex->coords.at(2) );
1424 case ENF_VER_SIZE_COLUMN:
1425 item->setData( 0, enfVertex->size );
1427 case ENF_VER_ENTRY_COLUMN:
1428 item->setData( 0, enfVertex->geomEntry.c_str() );
1430 case ENF_VER_COMPOUND_COLUMN:
1431 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
1432 item->setData( Qt::CheckStateRole, enfVertex->isCompound );
1434 case ENF_VER_GROUP_COLUMN:
1435 item->setData( 0, enfVertex->groupName.c_str() );
1441 myEnforcedTableWidget->setItem(rowCount,col,item);
1443 that->updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1447 connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1448 myEnforcedTableWidget->setSortingEnabled(true);
1450 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1451 myEnforcedTableWidget->resizeColumnToContents(column);
1453 // Update Enforced meshes QTableWidget
1454 TEnfMeshList::const_iterator itMesh;
1456 myEnforcedMeshTableWidget->clearContents();
1457 myEnforcedMeshTableWidget->setSortingEnabled(false);
1458 // myEnforcedMeshTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1459 for(itMesh = data.myEnforcedMeshes.begin() ; itMesh != data.myEnforcedMeshes.end(); itMesh++ )
1461 TEnfMesh* enfMesh = (*itMesh);
1462 myEnforcedMeshTableWidget->setRowCount(rowCount+1);
1464 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++) {
1465 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1466 QComboBox* comboBox = new QComboBox();
1467 QPalette pal = comboBox->palette();
1468 pal.setColor(QPalette::Button, Qt::white);
1469 comboBox->setPalette(pal);
1470 comboBox->insertItems(0,myEnfMeshConstraintLabels);
1471 comboBox->setEditable(false);
1472 comboBox->setCurrentIndex(enfMesh->elementType);
1473 myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox);
1476 QTableWidgetItem* item = new QTableWidgetItem();
1477 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1479 case ENF_MESH_NAME_COLUMN:
1480 item->setData( 0, enfMesh->name.c_str() );
1481 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1482 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1484 case ENF_MESH_ENTRY_COLUMN:
1485 item->setData( 0, enfMesh->entry.c_str() );
1486 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1487 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1489 case ENF_MESH_GROUP_COLUMN:
1490 item->setData( 0, enfMesh->groupName.c_str() );
1491 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1502 myEnforcedMeshTableWidget->setSortingEnabled(true);
1504 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++)
1505 myEnforcedMeshTableWidget->resizeColumnToContents(col);
1507 that->updateWidgets();
1508 that->checkVertexIsDefined();
1511 QString GHS3DPluginGUI_HypothesisCreator::storeParams() const
1513 GHS3DHypothesisData data;
1514 readParamsFromWidgets( data );
1515 storeParamsToHypo( data );
1517 QString valStr = "";
1519 if ( !data.myBoundaryRecovery )
1520 valStr = " --components " + data.myToMeshHoles ? "all" : "outside_components" ;
1522 if ( data.myOptimizationLevel >= 0 && data.myOptimizationLevel < 5 && !data.myBoundaryRecovery) {
1523 const char* level[] = { "none" , "light" , "standard" , "standard+" , "strong" };
1524 valStr += " --optimisation_level ";
1525 valStr += level[ data.myOptimizationLevel ];
1527 if ( data.myMaximumMemory > 0 ) {
1528 valStr += " --max_memory ";
1529 valStr += QString::number( data.myMaximumMemory );
1531 if ( data.myInitialMemory > 0 && !data.myBoundaryRecovery ) {
1532 valStr += " --automatic_memory ";
1533 valStr += QString::number( data.myInitialMemory );
1535 valStr += " --verbose ";
1536 valStr += QString::number( data.myVerboseLevel );
1538 if ( !data.myToCreateNewNodes )
1539 valStr += " --no_internal_points";
1541 if ( data.myRemoveInitialCentralPoint )
1542 valStr += " --no_initial_central_point";
1544 if ( data.myBoundaryRecovery )
1547 if ( data.myFEMCorrection )
1550 if ( data.myGradation != 1.05 ) {
1551 valStr += " -Dcpropa=";
1552 valStr += QString::number( data.myGradation );
1556 valStr += data.myTextOption;
1561 bool GHS3DPluginGUI_HypothesisCreator::readParamsFromHypo( GHS3DHypothesisData& h_data ) const
1563 GHS3DPlugin::GHS3DPlugin_Hypothesis_var h =
1564 GHS3DPlugin::GHS3DPlugin_Hypothesis::_narrow( initParamsHypothesis() );
1565 GHS3DPlugin::GHS3DPlugin_OptimizerHypothesis_var opt =
1566 GHS3DPlugin::GHS3DPlugin_OptimizerHypothesis::_narrow( initParamsHypothesis() );
1568 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
1569 h_data.myName = isCreation() && data ? hypName() : "";
1571 if ( !opt->_is_nil() )
1573 h_data.myOptimization = opt->GetOptimization();
1574 h_data.mySplitOverConstrained = opt->GetSplitOverConstrained();
1575 h_data.myPThreadsMode = opt->GetPThreadsMode();
1576 h_data.myNumberOfThreads = opt->GetMaximalNumberOfThreads();
1577 h_data.mySmoothOffSlivers = opt->GetSmoothOffSlivers();
1579 else // avoid "Conditional jump or move depends on uninitialised value" error
1581 h_data.myOptimization = 1;
1582 h_data.mySplitOverConstrained = 1;
1583 h_data.myPThreadsMode = 1;
1584 h_data.myNumberOfThreads = 1;
1585 h_data.mySmoothOffSlivers = 1;
1587 h_data.myToMeshHoles = h->GetToMeshHoles();
1588 h_data.myToMakeGroupsOfDomains = h->GetToMakeGroupsOfDomains();
1589 h_data.myMaximumMemory = h->GetMaximumMemory();
1590 h_data.myInitialMemory = h->GetInitialMemory();
1591 h_data.myInitialMemory = h->GetInitialMemory();
1592 h_data.myOptimizationLevel = h->GetOptimizationLevel();
1593 h_data.myKeepFiles = h->GetKeepFiles();
1594 h_data.myWorkingDir = h->GetWorkingDirectory();
1595 h_data.myVerboseLevel = h->GetVerboseLevel();
1596 h_data.myToCreateNewNodes = h->GetToCreateNewNodes();
1597 h_data.myRemoveInitialCentralPoint = h->GetToRemoveCentralPoint();
1598 h_data.myBoundaryRecovery = h->GetToUseBoundaryRecoveryVersion();
1599 h_data.myFEMCorrection = h->GetFEMCorrection();
1600 h_data.myGradation = h->GetGradation();
1601 h_data.myTextOption = h->GetAdvancedOption();
1602 h_data.myLogInStandardOutput = h->GetStandardOutputLog();
1603 h_data.myRemoveLogOnSuccess = h->GetRemoveLogOnSuccess();
1605 GHS3DPlugin::GHS3DEnforcedVertexList_var vertices = h->GetEnforcedVertices();
1606 h_data.myEnforcedVertices.clear();
1607 for (CORBA::ULong i=0 ; i<vertices->length() ; i++) {
1608 TEnfVertex* myVertex = new TEnfVertex();
1609 myVertex->name = CORBA::string_dup(vertices[i].name.in());
1610 myVertex->geomEntry = CORBA::string_dup(vertices[i].geomEntry.in());
1611 myVertex->groupName = CORBA::string_dup(vertices[i].groupName.in());
1612 myVertex->size = vertices[i].size;
1613 myVertex->isCompound = vertices[i].isCompound;
1614 if (vertices[i].coords.length()) {
1615 for (CORBA::ULong c = 0; c < vertices[i].coords.length() ; c++)
1616 myVertex->coords.push_back(vertices[i].coords[c]);
1618 h_data.myEnforcedVertices.insert(myVertex);
1621 GHS3DPlugin::GHS3DEnforcedMeshList_var enfMeshes = h->GetEnforcedMeshes();
1622 h_data.myEnforcedMeshes.clear();
1623 for (CORBA::ULong i=0 ; i<enfMeshes->length() ; i++) {
1624 TEnfMesh* myEnfMesh = new TEnfMesh();
1625 myEnfMesh->name = CORBA::string_dup(enfMeshes[i].name.in());
1626 myEnfMesh->entry = CORBA::string_dup(enfMeshes[i].entry.in());
1627 myEnfMesh->groupName = CORBA::string_dup(enfMeshes[i].groupName.in());
1628 switch (enfMeshes[i].elementType) {
1630 myEnfMesh->elementType = 0;
1633 myEnfMesh->elementType = 1;
1636 myEnfMesh->elementType = 2;
1641 // myEnfMesh->elementType = enfMeshes[i].elementType;
1642 h_data.myEnforcedMeshes.insert(myEnfMesh);
1647 bool GHS3DPluginGUI_HypothesisCreator::storeParamsToHypo( const GHS3DHypothesisData& h_data ) const
1649 GHS3DPlugin::GHS3DPlugin_Hypothesis_var h =
1650 GHS3DPlugin::GHS3DPlugin_Hypothesis::_narrow( hypothesis() );
1651 GHS3DPlugin::GHS3DPlugin_OptimizerHypothesis_var opt =
1652 GHS3DPlugin::GHS3DPlugin_OptimizerHypothesis::_narrow( initParamsHypothesis() );
1658 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
1660 if ( h->GetToMeshHoles() != h_data.myToMeshHoles ) // avoid duplication of DumpPython commands
1661 h->SetToMeshHoles ( h_data.myToMeshHoles );
1662 if ( h->GetToMakeGroupsOfDomains() != h_data.myToMakeGroupsOfDomains )
1663 h->SetToMakeGroupsOfDomains( h_data.myToMakeGroupsOfDomains );
1664 if ( h->GetMaximumMemory() != h_data.myMaximumMemory )
1665 h->SetMaximumMemory ( h_data.myMaximumMemory );
1666 if ( h->GetInitialMemory() != h_data.myInitialMemory )
1667 h->SetInitialMemory ( h_data.myInitialMemory );
1668 if ( h->GetInitialMemory() != h_data.myInitialMemory )
1669 h->SetInitialMemory ( h_data.myInitialMemory );
1670 if ( h->GetOptimizationLevel() != h_data.myOptimizationLevel )
1671 h->SetOptimizationLevel( h_data.myOptimizationLevel );
1672 if ( h->GetKeepFiles() != h_data.myKeepFiles )
1673 h->SetKeepFiles ( h_data.myKeepFiles );
1674 if ( h->GetWorkingDirectory() != h_data.myWorkingDir )
1675 h->SetWorkingDirectory ( h_data.myWorkingDir.toLatin1().constData() );
1676 if ( h->GetVerboseLevel() != h_data.myVerboseLevel )
1677 h->SetVerboseLevel ( h_data.myVerboseLevel );
1678 if ( h->GetToCreateNewNodes() != h_data.myToCreateNewNodes )
1679 h->SetToCreateNewNodes( h_data.myToCreateNewNodes );
1680 if ( h->GetToRemoveCentralPoint() != h_data.myRemoveInitialCentralPoint )
1681 h->SetToRemoveCentralPoint( h_data.myRemoveInitialCentralPoint );
1682 if ( h->GetToUseBoundaryRecoveryVersion() != h_data.myBoundaryRecovery )
1683 h->SetToUseBoundaryRecoveryVersion( h_data.myBoundaryRecovery );
1684 if ( h->GetFEMCorrection() != h_data.myFEMCorrection )
1685 h->SetFEMCorrection ( h_data.myFEMCorrection );
1686 if ( h->GetGradation() != h_data.myGradation )
1687 h->SetGradation ( h_data.myGradation );
1688 if ( h->GetAdvancedOption() != h_data.myTextOption )
1689 h->SetAdvancedOption ( h_data.myTextOption.toLatin1().constData() );
1690 if ( h->GetStandardOutputLog() != h_data.myLogInStandardOutput )
1691 h->SetStandardOutputLog( h_data.myLogInStandardOutput );
1692 if ( h->GetRemoveLogOnSuccess() != h_data.myRemoveLogOnSuccess )
1693 h->SetRemoveLogOnSuccess( h_data.myRemoveLogOnSuccess );
1695 if ( !opt->_is_nil() )
1697 opt->SetOptimization ( (GHS3DPlugin::Mode) h_data.myOptimization );
1698 opt->SetSplitOverConstrained ( (GHS3DPlugin::Mode) h_data.mySplitOverConstrained );
1699 opt->SetPThreadsMode ( (GHS3DPlugin::PThreadsMode) h_data.myPThreadsMode );
1700 opt->SetSmoothOffSlivers ( h_data.mySmoothOffSlivers );
1701 opt->SetMaximalNumberOfThreads( h_data.myNumberOfThreads );
1704 // Enforced vertices
1705 GHS3DPlugin::GHS3DEnforcedVertexList_var vertexHyp = h->GetEnforcedVertices();
1706 int nbVertexHyp = vertexHyp->length();
1708 // 1. Clear all enforced vertices in hypothesis
1709 // 2. Add new enforced vertex according to h_data
1710 if ( nbVertexHyp > 0)
1711 h->ClearEnforcedVertices();
1713 TEnfVertexList::const_iterator it;
1714 double x = 0, y = 0, z = 0;
1715 for(it = h_data.myEnforcedVertices.begin() ; it != h_data.myEnforcedVertices.end(); it++ ) {
1716 TEnfVertex* enfVertex = (*it);
1718 if (enfVertex->coords.size()) {
1719 x = enfVertex->coords.at(0);
1720 y = enfVertex->coords.at(1);
1721 z = enfVertex->coords.at(2);
1723 ok = h->p_SetEnforcedVertex( enfVertex->size, x, y, z, enfVertex->name.c_str(), enfVertex->geomEntry.c_str(), enfVertex->groupName.c_str(), enfVertex->isCompound);
1727 GHS3DPlugin::GHS3DEnforcedMeshList_var enfMeshListHyp = h->GetEnforcedMeshes();
1728 int nbEnfMeshListHyp = enfMeshListHyp->length();
1730 // 1. Clear all enforced vertices in hypothesis
1731 // 2. Add new enforced vertex according to h_data
1732 if ( nbEnfMeshListHyp > 0)
1733 h->ClearEnforcedMeshes();
1735 TEnfMeshList::const_iterator itEnfMesh;
1737 _PTR(Study) aStudy = SMESH::getStudy();
1739 for(itEnfMesh = h_data.myEnforcedMeshes.begin() ; itEnfMesh != h_data.myEnforcedMeshes.end(); itEnfMesh++ ) {
1740 TEnfMesh* enfMesh = (*itEnfMesh);
1742 _PTR(SObject) aSObj = aStudy->FindObjectID(enfMesh->entry.c_str());
1743 SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1745 SMESH::ElementType elementType;
1746 switch(enfMesh->elementType) {
1748 elementType = SMESH::NODE;
1751 elementType = SMESH::EDGE;
1754 elementType = SMESH::FACE;
1760 ok = h->p_SetEnforcedMesh(theSource, elementType, enfMesh->name.c_str(), enfMesh->groupName.c_str());
1763 catch ( const SALOME::SALOME_Exception& ex )
1765 SalomeApp_Tools::QtCatchCorbaException( ex );
1771 bool GHS3DPluginGUI_HypothesisCreator::readParamsFromWidgets( GHS3DHypothesisData& h_data ) const
1773 h_data.myName = myName ? myName->text() : "";
1774 h_data.myToMeshHoles = myToMeshHolesCheck->isChecked();
1775 h_data.myToMakeGroupsOfDomains = myToMakeGroupsOfDomains->isChecked();
1776 h_data.myOptimization = myOptimizationCombo->currentIndex();
1777 h_data.myOptimizationLevel = myOptimizationLevelCombo->currentIndex();
1778 h_data.mySplitOverConstrained = mySplitOverConstrainedCombo->currentIndex();
1779 h_data.myPThreadsMode = myPThreadsModeCombo->currentIndex();
1780 h_data.myNumberOfThreads = myNumberOfThreadsSpin->value();
1781 h_data.mySmoothOffSlivers = mySmoothOffSliversCheck->isChecked();
1782 h_data.myMaximumMemory = myAdvWidget->maxMemoryCheck->isChecked() ? myAdvWidget->maxMemorySpin->value() : -1;
1783 h_data.myInitialMemory = myAdvWidget->initialMemoryCheck->isChecked() ? myAdvWidget->initialMemorySpin->value() : -1;
1784 h_data.myKeepFiles = myAdvWidget->keepWorkingFilesCheck->isChecked();
1785 h_data.myWorkingDir = myAdvWidget->workingDirectoryLineEdit->text().trimmed();
1786 h_data.myVerboseLevel = myAdvWidget->verboseLevelSpin->value();
1787 h_data.myRemoveInitialCentralPoint = myAdvWidget->removeInitialCentralPointCheck->isChecked();
1788 h_data.myBoundaryRecovery = myAdvWidget->boundaryRecoveryCheck->isChecked();
1789 h_data.myFEMCorrection = myAdvWidget->FEMCorrectionCheck->isChecked();
1790 h_data.myGradation = myAdvWidget->gradationSpinBox->value();
1791 h_data.myTextOption = myAdvWidget->advOptionTable->GetCustomOptions();
1792 h_data.myLogInStandardOutput = !myAdvWidget->logInFileCheck->isChecked();
1793 h_data.myRemoveLogOnSuccess = myAdvWidget->removeLogOnSuccessCheck->isChecked();
1794 if ( isOptimization() )
1795 h_data.myToCreateNewNodes = myCreateNewNodesCheck->isChecked();
1797 h_data.myToCreateNewNodes = myAdvWidget->createNewNodesCheck->isChecked();
1799 // Enforced vertices
1800 h_data.myEnforcedVertices.clear();
1801 QVariant valueX, valueY, valueZ;
1802 for (int row=0 ; row<myEnforcedTableWidget->rowCount() ; row++)
1804 TEnfVertex *myVertex = new TEnfVertex();
1805 myVertex->name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString();
1806 myVertex->geomEntry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString();
1807 myVertex->groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
1808 valueX = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data(Qt::EditRole);
1809 valueY = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data(Qt::EditRole);
1810 valueZ = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data(Qt::EditRole);
1811 if (!valueX.isNull() && !valueY.isNull() && !valueZ.isNull()) {
1812 myVertex->coords.push_back(valueX.toDouble());
1813 myVertex->coords.push_back(valueY.toDouble());
1814 myVertex->coords.push_back(valueZ.toDouble());
1816 myVertex->size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data(Qt::EditRole).toDouble();
1817 myVertex->isCompound = myEnforcedTableWidget->item(row,ENF_VER_COMPOUND_COLUMN)->data(Qt::CheckStateRole).toBool();
1818 h_data.myEnforcedVertices.insert(myVertex);
1822 h_data.myEnforcedMeshes.clear();
1824 for (int row=0 ; row<myEnforcedMeshTableWidget->rowCount() ; row++)
1826 TEnfMesh *myEnfMesh = new TEnfMesh();
1827 myEnfMesh->name = myEnforcedMeshTableWidget->item(row,ENF_MESH_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString();
1828 myEnfMesh->entry = myEnforcedMeshTableWidget->item(row,ENF_MESH_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString();
1829 myEnfMesh->groupName = myEnforcedMeshTableWidget->item(row,ENF_MESH_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
1830 QComboBox* combo = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row,ENF_MESH_CONSTRAINT_COLUMN));
1831 myEnfMesh->elementType = combo->currentIndex();
1832 h_data.myEnforcedMeshes.insert(myEnfMesh);
1838 QString GHS3DPluginGUI_HypothesisCreator::caption() const
1840 return tr( "GHS3D_TITLE" );
1843 QPixmap GHS3DPluginGUI_HypothesisCreator::icon() const
1845 return SUIT_Session::session()->resourceMgr()->loadPixmap( "GHS3DPlugin", tr( "ICON_DLG_GHS3D_PARAMETERS" ) );
1848 QString GHS3DPluginGUI_HypothesisCreator::type() const
1850 return tr( isOptimization() ? "GHS3D_OPTIMIZATIOL_HYPOTHESIS" : "GHS3D_HYPOTHESIS" );
1853 QString GHS3DPluginGUI_HypothesisCreator::helpPage() const
1855 return isOptimization() ? "optimization_page.html" : "ghs3d_hypo_page.html";