1 // Copyright (C) 2004-2023 CEA, EDF
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>
48 #include "GHS3DPlugin_Hypothesis.hxx"
52 #include <QButtonGroup>
55 #include <QGridLayout>
57 #include <QHeaderView>
61 #include <QPushButton>
62 #include <QRadioButton>
66 #include <QTableWidget>
67 #include <QTableWidgetItem>
68 #include <QVBoxLayout>
71 #include <utilities.h>
75 QComboBox* getModeCombo( QWidget* parent, bool isPThreadCombo )
77 QComboBox* combo = new QComboBox( parent );
80 combo->insertItem((int) GHS3DPlugin_OptimizerHypothesis::SAFE, QObject::tr("MODE_SAFE"));
81 combo->insertItem((int) GHS3DPlugin_OptimizerHypothesis::AGGRESSIVE, QObject::tr("MODE_AGGRESSIVE"));
82 combo->insertItem((int) GHS3DPlugin_OptimizerHypothesis::NONE, QObject::tr("MODE_NONE"));
86 combo->insertItem((int) GHS3DPlugin_OptimizerHypothesis::NO, QObject::tr("MODE_NO"));
87 combo->insertItem((int) GHS3DPlugin_OptimizerHypothesis::YES, QObject::tr("MODE_YES"));
88 combo->insertItem((int) GHS3DPlugin_OptimizerHypothesis::ONLY, QObject::tr("MODE_ONLY"));
95 // BEGIN EnforcedVertexTableWidgetDelegate
98 EnforcedVertexTableWidgetDelegate::EnforcedVertexTableWidgetDelegate(QObject *parent)
99 : QItemDelegate(parent)
103 QWidget *EnforcedVertexTableWidgetDelegate::createEditor(QWidget *parent,
104 const QStyleOptionViewItem & option ,
105 const QModelIndex & index ) const
107 QModelIndex father = index.parent();
108 QString entry = father.child(index.row(), ENF_VER_ENTRY_COLUMN).data().toString();
110 if (index.column() == ENF_VER_X_COLUMN ||
111 index.column() == ENF_VER_Y_COLUMN ||
112 index.column() == ENF_VER_Z_COLUMN ||
113 index.column() == ENF_VER_SIZE_COLUMN) {
114 SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent);
115 if (index.column() == ENF_VER_SIZE_COLUMN)
116 editor->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
118 editor->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
119 editor->setReadOnly(!entry.isEmpty());
120 editor->setDisabled(!entry.isEmpty());
123 else if (index.column() == ENF_VER_GROUP_COLUMN ||
124 index.column() == ENF_VER_NAME_COLUMN) {
126 QLineEdit *editor = new QLineEdit(parent);
127 if (index.column() != ENF_VER_GROUP_COLUMN) {
128 editor->setReadOnly(!entry.isEmpty());
129 editor->setDisabled(!entry.isEmpty());
133 return QItemDelegate::createEditor(parent, option, index);
136 void EnforcedVertexTableWidgetDelegate::setEditorData(QWidget *editor,
137 const QModelIndex &index) const
139 if (index.column() == ENF_VER_X_COLUMN ||
140 index.column() == ENF_VER_Y_COLUMN ||
141 index.column() == ENF_VER_Z_COLUMN ||
142 index.column() == ENF_VER_SIZE_COLUMN)
144 SMESHGUI_SpinBox *lineEdit = qobject_cast<SMESHGUI_SpinBox*>(editor);
145 lineEdit->SetValue(index.data().toDouble());
147 else if (index.column() == ENF_VER_COMPOUND_COLUMN) {
148 QCheckBox *checkBox = qobject_cast<QCheckBox*>(editor);
149 checkBox->setChecked(index.data().toBool());
152 QItemDelegate::setEditorData(editor, index);
156 void EnforcedVertexTableWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
157 const QModelIndex &index) const
159 QModelIndex parent = index.parent();
161 QString entry = parent.child(index.row(), ENF_VER_ENTRY_COLUMN).data().toString();
162 bool isCompound = parent.child(index.row(), ENF_VER_COMPOUND_COLUMN).data(Qt::CheckStateRole).toBool();
164 if (index.column() == ENF_VER_X_COLUMN ||
165 index.column() == ENF_VER_Y_COLUMN ||
166 index.column() == ENF_VER_Z_COLUMN) {
167 SMESHGUI_SpinBox *lineEdit = qobject_cast<SMESHGUI_SpinBox*>(editor);
168 if (!isCompound && !vertexExists(model, index, lineEdit->GetString()))
169 model->setData(index, lineEdit->GetValue(), Qt::EditRole);
171 else if (index.column() == ENF_VER_SIZE_COLUMN)
173 SMESHGUI_SpinBox *lineEdit = qobject_cast<SMESHGUI_SpinBox*>(editor);
174 const double newsize = lineEdit->GetValue();
176 model->setData(index, newsize, Qt::EditRole);
178 else if (index.column() == ENF_VER_NAME_COLUMN) {
179 QLineEdit *lineEdit = qobject_cast<QLineEdit*>(editor);
180 QString value = lineEdit->text();
181 if (entry.isEmpty() && !vertexExists(model, index, value))
182 model->setData(index, value, Qt::EditRole);
184 else if (index.column() == ENF_VER_ENTRY_COLUMN) {
185 QLineEdit *lineEdit = qobject_cast<QLineEdit*>(editor);
186 QString value = lineEdit->text();
187 if (! vertexExists(model, index, value))
188 model->setData(index, value, Qt::EditRole);
190 else if (index.column() == ENF_VER_COMPOUND_COLUMN) {
191 QCheckBox *checkBox = qobject_cast<QCheckBox*>(editor);
192 model->setData(index, checkBox->isChecked(), Qt::CheckStateRole);
195 QItemDelegate::setModelData(editor, model, index);
199 void EnforcedVertexTableWidgetDelegate::updateEditorGeometry(QWidget *editor,
200 const QStyleOptionViewItem &option,
201 const QModelIndex &/* index */) const
203 editor->setGeometry(option.rect);
206 bool EnforcedVertexTableWidgetDelegate::vertexExists(QAbstractItemModel *model,
207 const QModelIndex &index,
211 QModelIndex parent = index.parent();
212 int row = index.row();
213 int col = index.column();
215 if (parent.isValid() && !value.isEmpty()) {
216 if (col == ENF_VER_X_COLUMN || col == ENF_VER_Y_COLUMN || col == ENF_VER_Z_COLUMN) {
218 if (col == ENF_VER_X_COLUMN) {
219 x = value.toDouble();
220 y = parent.child(row, ENF_VER_Y_COLUMN).data().toDouble();
221 z = parent.child(row, ENF_VER_Z_COLUMN).data().toDouble();
223 if (col == ENF_VER_Y_COLUMN) {
224 y = value.toDouble();
225 x = parent.child(row, ENF_VER_X_COLUMN).data().toDouble();
226 z = parent.child(row, ENF_VER_Z_COLUMN).data().toDouble();
228 if (col == ENF_VER_Z_COLUMN) {
229 z = value.toDouble();
230 x = parent.child(row, ENF_VER_X_COLUMN).data().toDouble();
231 y = parent.child(row, ENF_VER_Y_COLUMN).data().toDouble();
233 int nbChildren = model->rowCount(parent);
234 for (int i = 0 ; i < nbChildren ; i++) {
236 double childX = parent.child(i, ENF_VER_X_COLUMN).data().toDouble();
237 double childY = parent.child(i, ENF_VER_Y_COLUMN).data().toDouble();
238 double childZ = parent.child(i, ENF_VER_Z_COLUMN).data().toDouble();
239 if ((childX == x) && (childY == y) && (childZ == z)) {
246 else if (col == ENF_VER_NAME_COLUMN) {
247 QString name = parent.child(row, ENF_VER_NAME_COLUMN).data().toString();
257 // END EnforcedVertexTableWidgetDelegate
261 // BEGIN EnforcedMeshTableWidgetDelegate
264 EnforcedMeshTableWidgetDelegate::EnforcedMeshTableWidgetDelegate(QObject *parent)
265 : QItemDelegate(parent)
269 QWidget *EnforcedMeshTableWidgetDelegate::createEditor(QWidget *parent,
270 const QStyleOptionViewItem & option ,
271 const QModelIndex & index ) const
273 return QItemDelegate::createEditor(parent, option, index);
276 void EnforcedMeshTableWidgetDelegate::setEditorData(QWidget *editor,
277 const QModelIndex &index) const
279 QItemDelegate::setEditorData(editor, index);
282 void EnforcedMeshTableWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
283 const QModelIndex &index) const
285 QItemDelegate::setModelData(editor, model, index);
289 void EnforcedMeshTableWidgetDelegate::updateEditorGeometry(QWidget *editor,
290 const QStyleOptionViewItem &option,
291 const QModelIndex &/* index */) const
293 editor->setGeometry(option.rect);
297 // END EnforcedMeshTableWidgetDelegate
301 GHS3DPluginGUI_HypothesisCreator::GHS3DPluginGUI_HypothesisCreator( const QString& theHypType )
302 : SMESHGUI_GenericHypothesisCreator( theHypType ),
304 myOptimizationLevelCombo(0),
309 myNumOfThreadsCheck(0),
310 myNumOfThreadsSpin(0),
313 myUseProximityGroup(0),
314 myNbProximityLayers(0),
315 myToMakeGroupsOfDomains(0),
316 myToMeshHolesCheck(0),
317 myOptimizationCombo(0),
318 mySplitOverConstrainedCombo(0),
319 myPThreadsModeCombo(0),
320 myNumberOfThreadsSpin(0),
321 mySmoothOffSliversCheck(0),
322 myCreateNewNodesCheck(0),
326 GeomToolSelected = NULL;
327 GeomToolSelected = getGeomSelectionTool();
329 iconVertex = QPixmap(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_OBJBROWSER_VERTEX")));
330 iconCompound = QPixmap(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_OBJBROWSER_COMPOUND")));
331 // mySelectionMgr = SMESH::GetSelectionMgr(SMESHGUI::GetSMESHGUI());
332 myEnfMeshConstraintLabels << tr( "GHS3D_ENF_MESH_CONSTRAINT_NODE" ) << tr( "GHS3D_ENF_MESH_CONSTRAINT_EDGE" ) << tr("GHS3D_ENF_MESH_CONSTRAINT_FACE");
335 GHS3DPluginGUI_HypothesisCreator::~GHS3DPluginGUI_HypothesisCreator()
337 GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
338 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
339 myEnfMeshWdg->deactivateSelection();
343 * \brief {Get or create the geom selection tool for study}
345 GeomSelectionTools* GHS3DPluginGUI_HypothesisCreator::getGeomSelectionTool()
347 GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
348 if (that->GeomToolSelected == NULL) {
349 that->GeomToolSelected = new GeomSelectionTools();
351 return that->GeomToolSelected;
354 GEOM::GEOM_Gen_var GHS3DPluginGUI_HypothesisCreator::getGeomEngine()
356 return GeometryGUI::GetGeomGen();
359 bool GHS3DPluginGUI_HypothesisCreator::isOptimization() const
361 return ( hypType() == GHS3DPlugin_OptimizerHypothesis::GetHypType() );
364 void GHS3DPluginGUI_HypothesisCreator::onRadioButtonSelect()
366 onNumOfThreadsCheck();
368 // Disable selection of standart+
369 QStandardItemModel * model = qobject_cast<QStandardItemModel*>(myOptimizationLevelCombo->model());
371 QStandardItem * item = model->item( GHS3DPlugin_Hypothesis::StandardPlus );
374 if ( myRadioBottomGroup->checkedId() == GHS3DPlugin_Hypothesis::MGTetra )
376 // Enable selection of stadart+
377 item->setEnabled(true);
378 // Set possibility to check memory options again.
379 myAdvWidget->maxMemoryCheck ->setEnabled( true );
380 myAdvWidget->initialMemoryCheck ->setEnabled( true );
382 myAdvWidget->EnableAdvancedOptions( true );
383 myEnfGroup->setEnabled( true );
384 myEnfMeshGroup->setEnabled( true );
386 else if ( myRadioBottomGroup->checkedId() == GHS3DPlugin_Hypothesis::MGTetraHPC )
388 // Disable selection of stadart+
389 item->setEnabled(false);
390 // Set to false memory checks and disable checkbox
391 myAdvWidget->maxMemoryCheck ->setChecked( false );
392 myAdvWidget->initialMemoryCheck ->setChecked( false );
393 myAdvWidget->maxMemoryCheck ->setEnabled( false );
394 myAdvWidget->initialMemoryCheck ->setEnabled( false );
395 myAdvWidget->EnableAdvancedOptions( false );
396 myEnfGroup->setEnabled( false );
397 myEnfMeshGroup->setEnabled( false );
402 void GHS3DPluginGUI_HypothesisCreator::onNumOfThreadsCheck()
404 if ( myRadioBottomGroup->checkedId() == GHS3DPlugin_Hypothesis::MGTetra )
406 if ( myNumOfThreadsCheck->isChecked() )
407 myPthreadMode->setEnabled( true );
409 myPthreadMode->setEnabled( false );
411 myParallelMode->setEnabled( false );
413 else if ( myRadioBottomGroup->checkedId() == GHS3DPlugin_Hypothesis::MGTetraHPC )
415 if ( myNumOfThreadsCheck->isChecked() )
416 myParallelMode->setEnabled( true );
418 myParallelMode->setEnabled( false );
420 myPthreadMode->setEnabled( false );
428 QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame()
430 QFrame* fr = new QFrame( 0 );
431 QVBoxLayout* lay = new QVBoxLayout( fr );
433 lay->setSpacing( 0 );
436 QTabWidget* tab = new QTabWidget( fr );
437 tab->setTabShape( QTabWidget::Rounded );
438 tab->setTabPosition( QTabWidget::North );
439 lay->addWidget( tab );
442 myStdGroup = new QWidget();
443 QGridLayout* aStdLayout = new QGridLayout( myStdGroup );
444 aStdLayout->setSpacing( 6 );
445 aStdLayout->setMargin( 11 );
450 aStdLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), myStdGroup ), row, 0, 1, 1 );
451 myName = new QLineEdit( myStdGroup );
452 aStdLayout->addWidget( myName, row++, 1, 1, 1 );
454 if ( isOptimization() )
456 myToMeshHolesCheck = new QCheckBox( tr( "GHS3D_TO_MESH_HOLES" ), myStdGroup );
457 aStdLayout->addWidget( myToMeshHolesCheck, row, 0, 1, 1 );
458 myToMakeGroupsOfDomains = new QCheckBox( tr( "GHS3D_TO_MAKE_DOMAIN_GROUPS" ), myStdGroup );
459 aStdLayout->addWidget( myToMakeGroupsOfDomains, row++, 1, 1, 1 );
461 QLabel* optimizationLbl = new QLabel( tr( "GHS3D_OPTIMIZATION" ), myStdGroup );
462 aStdLayout->addWidget( optimizationLbl, row, 0, 1, 1 );
463 myOptimizationCombo = getModeCombo( myStdGroup, false );
464 aStdLayout->addWidget( myOptimizationCombo, row++, 1, 1, 1 );
466 QLabel* optimizatiolLevelLbl = new QLabel( tr( "GHS3D_OPTIMIZATIOL_LEVEL" ), myStdGroup );
467 aStdLayout->addWidget( optimizatiolLevelLbl, row, 0, 1, 1 );
468 myOptimizationLevelCombo = new QComboBox( myStdGroup );
469 aStdLayout->addWidget( myOptimizationLevelCombo, row++, 1, 1, 1 );
471 QLabel* splitOverconstrainedLbl = new QLabel( tr("GHS3D_SPLIT_OVERCONSTRAINED"), myStdGroup );
472 aStdLayout->addWidget( splitOverconstrainedLbl, row, 0, 1, 1 );
473 mySplitOverConstrainedCombo = getModeCombo( myStdGroup, false );
474 aStdLayout->addWidget( mySplitOverConstrainedCombo, row++, 1, 1, 1 );
476 QLabel* pthreadsModeLbl = new QLabel( tr( "GHS3D_PTHREADS_MODE" ), myStdGroup);
477 aStdLayout->addWidget( pthreadsModeLbl, row, 0, 1, 1 );
478 myPThreadsModeCombo = getModeCombo( myStdGroup, true );
479 aStdLayout->addWidget( myPThreadsModeCombo, row++, 1, 1, 1 );
481 QLabel* nbThreadsLbl = new QLabel( tr( "GHS3D_NB_THREADS" ), myStdGroup);
482 aStdLayout->addWidget( nbThreadsLbl, row, 0, 1, 1 );
483 myNumberOfThreadsSpin = new SalomeApp_IntSpinBox( 0, 1000, 1, myStdGroup );
484 aStdLayout->addWidget( myNumberOfThreadsSpin, row++, 1, 1, 1 );
486 mySmoothOffSliversCheck = new QCheckBox( tr( "GHS3D_SMOOTH_OFF_SLIVERS" ), myStdGroup );
487 aStdLayout->addWidget( mySmoothOffSliversCheck, row, 0, 1, 1 );
488 myCreateNewNodesCheck = new QCheckBox( tr( "TO_ADD_NODES" ), myStdGroup );
489 aStdLayout->addWidget( myCreateNewNodesCheck, row++, 1, 1, 1 );
493 // Algorithm selection
494 QGroupBox* radioBottomGroup = new QGroupBox( tr("GHS3D_ALGO_SELECTION"), myStdGroup );
495 myRadioBottomGroup = new QButtonGroup( radioBottomGroup );
497 QRadioButton * GM_MSH = new QRadioButton(tr("GHS3D_ALGO_MGTETRA"), radioBottomGroup );
498 QRadioButton * GM_MSH_HPC = new QRadioButton(tr("GHS3D_ALGO_MGTETRAHPC"), radioBottomGroup );
500 myRadioBottomGroup->addButton( GM_MSH, 1 );
501 myRadioBottomGroup->addButton( GM_MSH_HPC, 0 );
502 GM_MSH->setChecked( true );
504 QGridLayout* radioBottomLayout = new QGridLayout( radioBottomGroup );
505 radioBottomLayout->setSpacing( 4 );
506 radioBottomLayout->setMargin( 11 );
507 radioBottomLayout->addWidget( GM_MSH, 0, 0, 1, 1 );
508 radioBottomLayout->addWidget( GM_MSH_HPC, 0, 1, 1, 1 );
511 QGroupBox* mainGroup = new QGroupBox( tr("GHS3D_MAIN_PARAMS"), myStdGroup );
512 QLabel* optimizatiolLevelLbl = new QLabel( tr( "GHS3D_OPTIMIZATIOL_LEVEL" ), mainGroup );
513 QLabel* pthreadModeLbl = new QLabel( tr( "GHS3D_PTHREAD_MODE" ), mainGroup );
514 QLabel* parallelStrat = new QLabel( tr( "GHS3D_PARALLE_STRAT" ), mainGroup );
516 myOptimizationLevelCombo = new QComboBox( mainGroup );
517 myMinSizeCheck = new QCheckBox( tr("GHS3D_MIN_SIZE"), mainGroup );
518 myMaxSizeCheck = new QCheckBox( tr("GHS3D_MAX_SIZE"), mainGroup );
519 myNumOfThreadsCheck = new QCheckBox( tr("GHS3D_THREADS_SIZE"), mainGroup );
520 myPthreadMode = new QComboBox( mainGroup );
521 myParallelMode = new QComboBox( mainGroup );
523 myMinSizeSpin = new SMESHGUI_SpinBox( mainGroup );
524 myMaxSizeSpin = new SMESHGUI_SpinBox( mainGroup );
525 myNumOfThreadsSpin = new SalomeApp_IntSpinBox( 1, 128, 1, mainGroup );
527 myMinSizeCheck->setChecked( false );
528 myMaxSizeCheck->setChecked( false );
529 myNumOfThreadsCheck->setChecked( false );
531 myMinSizeSpin->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
532 myMaxSizeSpin->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
533 myNumOfThreadsSpin->setValue( 4 );
535 myMinSizeSpin ->setEnabled( false );
536 myMaxSizeSpin ->setEnabled( false );
537 myNumOfThreadsSpin->setEnabled(false);
538 myPthreadMode ->setEnabled( false );
539 myParallelMode->setEnabled( false );
541 // ACTIONS ON BUTTOMS
542 connect( myMinSizeCheck, SIGNAL( toggled(bool)), myMinSizeSpin, SLOT( setEnabled(bool)));
543 connect( myMaxSizeCheck, SIGNAL( toggled(bool)), myMaxSizeSpin, SLOT( setEnabled(bool)));
544 connect( myNumOfThreadsCheck, SIGNAL( toggled(bool)), myNumOfThreadsSpin, SLOT( setEnabled(bool)));
545 connect( myNumOfThreadsCheck, SIGNAL( toggled(bool)), this, SLOT( onNumOfThreadsCheck() ));
546 connect( myNumOfThreadsCheck, SIGNAL( toggled(bool)), this, SLOT( onNumOfThreadsCheck() ));
547 connect( GM_MSH, SIGNAL( toggled( bool )),this, SLOT( onRadioButtonSelect() ));
549 QGridLayout* mainLayout = new QGridLayout( mainGroup );
550 mainLayout->setSpacing( 12 );
551 mainLayout->setMargin( 11 );
552 mainLayout->addWidget( optimizatiolLevelLbl, 0, 0, 1, 1 );
553 mainLayout->addWidget( myOptimizationLevelCombo, 0, 1, 1, 1 );
554 mainLayout->addWidget( myMinSizeCheck, 1, 0, 1, 1 );
555 mainLayout->addWidget( myMinSizeSpin, 1, 1, 1, 1 );
556 mainLayout->addWidget( myMaxSizeCheck, 2, 0, 1, 1 );
557 mainLayout->addWidget( myMaxSizeSpin, 2, 1, 1, 1 );
558 mainLayout->addWidget( myNumOfThreadsCheck, 3, 0, 1, 1 );
559 mainLayout->addWidget( myNumOfThreadsSpin, 3, 1, 1, 1 );
560 mainLayout->addWidget( pthreadModeLbl, 4, 0, 1, 1 );
561 mainLayout->addWidget( myPthreadMode, 4, 1, 1, 1 );
562 mainLayout->addWidget( parallelStrat, 5, 0, 1, 1 );
563 mainLayout->addWidget( myParallelMode, 5, 1, 1, 1 );
567 QGroupBox* proxyGroup = new QGroupBox( tr("GHS3D_VOLUME_PROXIMITY"), myStdGroup );
568 myGradationCheck = new QCheckBox( tr("GHS3D_GRADATION"), proxyGroup );
569 myGradationSpin = new SMESHGUI_SpinBox( proxyGroup );
570 myGradationSpin->RangeStepAndValidator(1, COORD_MAX, 0.1, "length_precision");
571 myGradationSpin->setEnabled( false );
572 connect( myGradationCheck, SIGNAL( toggled(bool)), myGradationSpin, SLOT( setEnabled(bool)));
573 myUseProximityGroup = new QGroupBox( tr("GHS3D_USE_VOLUME_PROXIMITY"), proxyGroup );
574 myUseProximityGroup->setCheckable( true );
575 //myUseProximityGroup->setChecked( false );
576 QLabel* nbProximityLayersLabel = new QLabel( tr("GHS3D_NB_LAYERS"));
577 myNbProximityLayers = new SalomeApp_IntSpinBox( 2, 1e6, 1, proxyGroup );
579 QHBoxLayout* useProxyLayout = new QHBoxLayout( myUseProximityGroup );
580 useProxyLayout->addWidget( nbProximityLayersLabel );
581 useProxyLayout->addWidget( myNbProximityLayers );
583 QGridLayout* proxyLayout = new QGridLayout( proxyGroup );
584 proxyLayout->setSpacing( 6 );
585 proxyLayout->setMargin( 11 );
586 proxyLayout->addWidget( myGradationCheck, 0, 0, 1, 1 );
587 proxyLayout->addWidget( myGradationSpin, 0, 1, 1, 1 );
588 proxyLayout->addWidget( myUseProximityGroup, 1, 0, 1, 2 );
592 QGroupBox* otherGroup = new QGroupBox( tr("GHS3D_OTHER_PARAMETERS"), myStdGroup );
593 myToMeshHolesCheck = new QCheckBox( tr( "GHS3D_TO_MESH_HOLES" ), otherGroup );
594 myToMakeGroupsOfDomains = new QCheckBox( tr( "GHS3D_TO_MAKE_DOMAIN_GROUPS" ), otherGroup );
596 QGridLayout* otherLayout = new QGridLayout( otherGroup );
597 otherLayout->setSpacing( 6 );
598 otherLayout->setMargin( 11 );
599 otherLayout->addWidget( myToMeshHolesCheck, 0, 0 );
600 otherLayout->addWidget( myToMakeGroupsOfDomains, 1, 0 );
602 aStdLayout->addWidget( radioBottomGroup,row++, 0, 1, 2 );
603 aStdLayout->addWidget( mainGroup, row++, 0, 1, 2 );
604 aStdLayout->addWidget( proxyGroup, row++, 0, 1, 2 );
605 aStdLayout->addWidget( otherGroup, row++, 0, 1, 2 );
607 myPthreadMode->addItems( QStringList() << tr( "MODE_NONE" ) << tr( "MODE_AGGRESSIVE" ) << tr( "MODE_SAFE" ) );
608 myParallelMode->addItems( QStringList() << tr( "MODE_NONE" ) << tr( "MODE_REPRODUCIBLE_GIVEN_MAX_THREADS" ) << tr( "MODE_REPRODUCIBLE" ) << tr( "MODE_AGGRESSIVE" ) );
610 aStdLayout->setRowStretch( row, 10 );
612 myOptimizationLevelCombo->addItems( QStringList()
613 << tr( "LEVEL_NONE" ) << tr( "LEVEL_LIGHT" )
614 << tr( "LEVEL_MEDIUM" ) << tr( "LEVEL_STANDARDPLUS" )
615 << tr( "LEVEL_STRONG" ));
617 // advanced parameters
618 myAdvGroup = new QWidget();
619 QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup );
620 anAdvLayout->setSpacing( 6 );
621 anAdvLayout->setMargin( 11 );
622 myAdvWidget = new GHS3DPluginGUI_AdvWidget(myAdvGroup);
623 anAdvLayout->addWidget( myAdvWidget);
625 myAdvWidget->maxMemoryCheck->setText(tr( "MAX_MEMORY_SIZE" ));
626 myAdvWidget->initialMemoryCheck->setText(tr( "INIT_MEMORY_SIZE" ));
628 myAdvWidget->maxMemorySpin->stepBy(10);
629 myAdvWidget->maxMemorySpin->setValue( 128 );
631 myAdvWidget->initialMemorySpin->stepBy(10);
632 myAdvWidget->initialMemorySpin->setValue( 100 );
634 myAdvWidget->initialMemoryLabel ->setText (tr( "MEGABYTE" ));
635 myAdvWidget->maxMemoryLabel ->setText (tr( "MEGABYTE" ));
637 myAdvWidget->workingDirectoryLabel ->setText (tr( "WORKING_DIR" ));
638 myAdvWidget->workingDirectoryPushButton ->setText (tr( "SELECT_DIR" ));
639 myAdvWidget->keepWorkingFilesCheck ->setText (tr( "KEEP_WORKING_FILES" ));
640 myAdvWidget->verboseLevelLabel ->setText (tr( "VERBOSE_LEVEL" ));
641 myAdvWidget->removeLogOnSuccessCheck ->setText (tr( "REMOVE_LOG_ON_SUCCESS" ));
642 myAdvWidget->logInFileCheck ->setText (tr( "LOG_IN_FILE" ));
644 myAdvWidget->memoryGroupBox ->setTitle(tr( "MEMORY_GROUP_TITLE" ));
645 myAdvWidget->logGroupBox ->setTitle(tr( "LOG_GROUP_TITLE" ));
646 //myAdvWidget->advancedMeshingGroupBox ->setTitle(tr( "ADVANCED_MESHING_GROUP_TITLE" ));
648 // myAdvWidget->createNewNodesCheck ->setText (tr( "TO_ADD_NODES" ));
649 // myAdvWidget->removeInitialCentralPointCheck->setText (tr( "NO_INITIAL_CENTRAL_POINT" ));
650 // myAdvWidget->boundaryRecoveryCheck ->setText (tr( "RECOVERY_VERSION" ));
651 // myAdvWidget->FEMCorrectionCheck ->setText (tr( "FEM_CORRECTION" ));
652 // myAdvWidget->gradationLabel ->setText (tr( "GHS3D_GRADATION" ));
653 // myAdvWidget->gradationSpinBox->RangeStepAndValidator(0.0, 5.0, 0.05, "length_precision");
655 // if ( isOptimization() )
657 // myAdvWidget->createNewNodesCheck->hide();
658 // myAdvWidget->removeInitialCentralPointCheck->hide();
659 // myAdvWidget->boundaryRecoveryCheck->hide();
660 // myAdvWidget->FEMCorrectionCheck->hide();
661 // myAdvWidget->gradationLabel->hide();
662 // myAdvWidget->gradationSpinBox->hide();
665 // Enforced vertices parameters
666 myEnfGroup = new QWidget();
667 QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup);
669 myEnforcedTableWidget = new QTableWidget(myEnfGroup);
670 myEnforcedTableWidget->setMinimumWidth(300);
671 myEnforcedTableWidget->setRowCount( 0 );
672 myEnforcedTableWidget->setColumnCount( ENF_VER_NB_COLUMNS );
673 myEnforcedTableWidget->setSortingEnabled(true);
674 myEnforcedTableWidget->setHorizontalHeaderLabels
676 << tr( "GHS3D_ENF_NAME_COLUMN" ) << tr( "GHS3D_ENF_VER_X_COLUMN" )
677 << tr( "GHS3D_ENF_VER_Y_COLUMN" ) << tr( "GHS3D_ENF_VER_Z_COLUMN" )
678 << tr( "GHS3D_ENF_SIZE_COLUMN" ) << tr("GHS3D_ENF_ENTRY_COLUMN")
679 << tr("GHS3D_ENF_VER_COMPOUND_COLUMN") << tr( "GHS3D_ENF_GROUP_COLUMN" ));
680 myEnforcedTableWidget->verticalHeader()->hide();
681 myEnforcedTableWidget->horizontalHeader()->setStretchLastSection(true);
682 myEnforcedTableWidget->setAlternatingRowColors(true);
683 myEnforcedTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
684 myEnforcedTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
685 myEnforcedTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
687 myEnforcedTableWidget->resizeColumnsToContents();
688 myEnforcedTableWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
689 myEnforcedTableWidget->hideColumn(ENF_VER_COMPOUND_COLUMN);
691 myEnforcedTableWidget->setItemDelegate(new EnforcedVertexTableWidgetDelegate());
694 TColStd_MapOfInteger shapeTypes;
695 shapeTypes.Add( TopAbs_VERTEX );
696 shapeTypes.Add( TopAbs_COMPOUND );
698 SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes);
699 myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true);
700 myEnfVertexWdg->SetDefaultText(tr("GHS3D_ENF_SELECT_VERTEX"), "QLineEdit { color: grey }");
702 QLabel* myXCoordLabel = new QLabel( tr( "GHS3D_ENF_VER_X_LABEL" ), myEnfGroup );
703 myXCoord = new SMESHGUI_SpinBox(myEnfGroup);
704 myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
705 QLabel* myYCoordLabel = new QLabel( tr( "GHS3D_ENF_VER_Y_LABEL" ), myEnfGroup );
706 myYCoord = new SMESHGUI_SpinBox(myEnfGroup);
707 myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
708 QLabel* myZCoordLabel = new QLabel( tr( "GHS3D_ENF_VER_Z_LABEL" ), myEnfGroup );
709 myZCoord = new SMESHGUI_SpinBox(myEnfGroup);
710 myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
711 QLabel* mySizeLabel = new QLabel( tr( "GHS3D_ENF_SIZE_LABEL" ), myEnfGroup );
712 mySizeValue = new SMESHGUI_SpinBox(myEnfGroup);
713 mySizeValue->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
715 QLabel* myGroupNameLabel = new QLabel( tr( "GHS3D_ENF_GROUP_LABEL" ), myEnfGroup );
716 myGroupName = new QLineEdit(myEnfGroup);
718 addVertexButton = new QPushButton(tr("GHS3D_ENF_ADD"),myEnfGroup);
719 addVertexButton->setEnabled(false);
720 removeVertexButton = new QPushButton(tr("GHS3D_ENF_REMOVE"),myEnfGroup);
722 anEnfLayout->addWidget(myEnforcedTableWidget, ENF_VER_VERTEX, 0, ENF_VER_NB_LINES, 1);
724 QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup);
725 anEnfLayout2->addWidget(myEnfVertexWdg, ENF_VER_VERTEX, 0, 1, 2);
726 anEnfLayout2->addWidget(myXCoordLabel, ENF_VER_X_COORD, 0, 1, 1);
727 anEnfLayout2->addWidget(myXCoord, ENF_VER_X_COORD, 1, 1, 1);
728 anEnfLayout2->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 0, 1, 1);
729 anEnfLayout2->addWidget(myYCoord, ENF_VER_Y_COORD, 1, 1, 1);
730 anEnfLayout2->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 0, 1, 1);
731 anEnfLayout2->addWidget(myZCoord, ENF_VER_Z_COORD, 1, 1, 1);
732 anEnfLayout2->addWidget(mySizeLabel, ENF_VER_SIZE, 0, 1, 1);
733 anEnfLayout2->addWidget(mySizeValue, ENF_VER_SIZE, 1, 1, 1);
734 anEnfLayout2->addWidget(myGroupNameLabel, ENF_VER_GROUP, 0, 1, 1);
735 anEnfLayout2->addWidget(myGroupName, ENF_VER_GROUP, 1, 1, 1);
736 anEnfLayout2->addWidget(addVertexButton, ENF_VER_BTN, 0, 1, 1);
737 anEnfLayout2->addWidget(removeVertexButton, ENF_VER_BTN, 1, 1, 1);
738 anEnfLayout2->setRowStretch(ENF_VER_NB_LINES, 1);
740 anEnfLayout->addLayout(anEnfLayout2, ENF_VER_VERTEX, 1,ENF_VER_NB_LINES, 1);
741 anEnfLayout->setRowStretch(ENF_VER_VERTEX, 10);
744 // Enforced meshes parameters
745 myEnfMeshGroup = new QWidget();
746 QGridLayout* anEnfMeshLayout = new QGridLayout(myEnfMeshGroup);
748 myEnforcedMeshTableWidget = new QTableWidget(myEnfGroup);
749 myEnforcedMeshTableWidget->setRowCount( 0 );
750 myEnforcedMeshTableWidget->setColumnCount( ENF_MESH_NB_COLUMNS );
751 myEnforcedMeshTableWidget->setSortingEnabled(true);
752 myEnforcedMeshTableWidget->verticalHeader()->hide();
753 QStringList enforcedMeshHeaders;
754 enforcedMeshHeaders << tr( "GHS3D_ENF_NAME_COLUMN" )
755 << tr( "GHS3D_ENF_ENTRY_COLUMN" )
756 << tr( "GHS3D_ENF_MESH_CONSTRAINT_COLUMN" )
757 << tr( "GHS3D_ENF_GROUP_COLUMN" );
758 myEnforcedMeshTableWidget->setHorizontalHeaderLabels(enforcedMeshHeaders);
759 myEnforcedMeshTableWidget->horizontalHeader()->setStretchLastSection(true);
760 myEnforcedMeshTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
762 myEnforcedMeshTableWidget->setAlternatingRowColors(true);
763 myEnforcedMeshTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
764 myEnforcedMeshTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
765 myEnforcedMeshTableWidget->resizeColumnsToContents();
766 myEnforcedMeshTableWidget->hideColumn(ENF_MESH_ENTRY_COLUMN);
768 myEnforcedMeshTableWidget->setItemDelegate(new EnforcedMeshTableWidgetDelegate());
770 myEnfMeshWdg = new StdMeshersGUI_ObjectReferenceParamWdg( SMESH::IDSOURCE, myEnfMeshGroup, /*multiSel=*/true);
771 myEnfMeshWdg->SetDefaultText(tr("GHS3D_ENF_SELECT_MESH"), "QLineEdit { color: grey }");
773 myEnfMeshWdg->AvoidSimultaneousSelection(myEnfVertexWdg);
775 QLabel* myMeshConstraintLabel = new QLabel( tr( "GHS3D_ENF_MESH_CONSTRAINT_LABEL" ), myEnfMeshGroup );
776 myEnfMeshConstraint = new QComboBox(myEnfMeshGroup);
777 myEnfMeshConstraint->insertItems(0,myEnfMeshConstraintLabels);
778 myEnfMeshConstraint->setEditable(false);
779 myEnfMeshConstraint->setCurrentIndex(0);
781 QLabel* myMeshGroupNameLabel = new QLabel( tr( "GHS3D_ENF_GROUP_LABEL" ), myEnfMeshGroup );
782 myMeshGroupName = new QLineEdit(myEnfMeshGroup);
784 addEnfMeshButton = new QPushButton(tr("GHS3D_ENF_ADD"),myEnfMeshGroup);
785 removeEnfMeshButton = new QPushButton(tr("GHS3D_ENF_REMOVE"),myEnfMeshGroup);
787 anEnfMeshLayout->addWidget(myEnforcedMeshTableWidget, ENF_MESH_MESH, 0, ENF_MESH_NB_LINES , 1);
789 QGridLayout* anEnfMeshLayout2 = new QGridLayout(myEnfMeshGroup);
790 anEnfMeshLayout2->addWidget(myEnfMeshWdg, ENF_MESH_MESH, 0, 1, 2);
791 anEnfMeshLayout2->addWidget(myMeshConstraintLabel, ENF_MESH_CONSTRAINT, 0, 1, 1);
792 anEnfMeshLayout2->addWidget(myEnfMeshConstraint, ENF_MESH_CONSTRAINT, 1, 1, 1);
793 anEnfMeshLayout2->addWidget(myMeshGroupNameLabel, ENF_MESH_GROUP, 0, 1, 1);
794 anEnfMeshLayout2->addWidget(myMeshGroupName, ENF_MESH_GROUP, 1, 1, 1);
795 anEnfMeshLayout2->addWidget(addEnfMeshButton, ENF_MESH_BTN, 0, 1, 1);
796 anEnfMeshLayout2->addWidget(removeEnfMeshButton, ENF_MESH_BTN, 1, 1, 1);
797 anEnfMeshLayout2->setRowStretch(ENF_MESH_NB_LINES, 1);
799 anEnfMeshLayout->addLayout(anEnfMeshLayout2, ENF_MESH_MESH, 1, ENF_MESH_NB_LINES, 1);
800 anEnfMeshLayout->setRowStretch(ENF_MESH_MESH, 10);
803 tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
804 tab->insertTab( ADV_TAB, myAdvGroup, tr( "GHS3D_ADV_ARGS" ) );
805 if ( !isOptimization() )
807 tab->insertTab( ENF_VER_TAB, myEnfGroup, tr( "GHS3D_ENFORCED_VERTICES" ) );
808 tab->insertTab( ENF_MESH_TAB, myEnfMeshGroup, tr( "GHS3D_ENFORCED_MESHES" ) );
810 tab->setCurrentIndex( STD_TAB );
812 connect( myAdvWidget->maxMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
813 connect( myAdvWidget->initialMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
814 connect( myAdvWidget->logInFileCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
815 connect( myAdvWidget->keepWorkingFilesCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
816 connect( myAdvWidget->workingDirectoryPushButton, SIGNAL( clicked() ), this, SLOT( onDirBtnClicked() ) );
817 connect( myAdvWidget->addBtn, SIGNAL( clicked() ), this, SLOT( onAddOption() ) );
819 connect( myEnforcedTableWidget, SIGNAL( itemClicked(QTableWidgetItem *)), this, SLOT( synchronizeCoords() ) );
820 connect( myEnforcedTableWidget, SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
821 connect( myEnforcedTableWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
822 connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertex() ) );
823 connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
824 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
825 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
826 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
827 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
828 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
829 connect( mySizeValue, SIGNAL( textChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) );
830 connect( myXCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
831 connect( myYCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
832 connect( myZCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
833 connect( mySizeValue, SIGNAL( valueChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) );
834 connect( this, SIGNAL( vertexDefined(bool) ), addVertexButton, SLOT( setEnabled(bool) ) );
836 connect( addEnfMeshButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedMesh() ) );
837 connect( removeEnfMeshButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedMesh() ) );
843 * This method checks if an enforced vertex is defined;
845 void GHS3DPluginGUI_HypothesisCreator::clearEnfVertexSelection()
847 if (myEnfVertexWdg->NbObjects() != 0) {
848 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
849 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
850 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
851 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
852 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
854 GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
855 that->checkVertexIsDefined();
859 * This method checks if an enforced vertex is defined;
861 void GHS3DPluginGUI_HypothesisCreator::checkVertexIsDefined()
863 bool enfVertexIsDefined = false;
864 enfVertexIsDefined = (!mySizeValue->GetString().isEmpty() &&
865 (!myEnfVertexWdg->NbObjects() == 0 ||
866 (myEnfVertexWdg->NbObjects() == 0 && !myXCoord->GetString().isEmpty()
867 && !myYCoord->GetString().isEmpty()
868 && !myZCoord->GetString().isEmpty())));
869 emit vertexDefined(enfVertexIsDefined);
873 * This method checks if an enforced mesh is defined;
875 void GHS3DPluginGUI_HypothesisCreator::checkEnfMeshIsDefined()
877 emit enfMeshDefined( myEnfVertexWdg->NbObjects() != 0);
881 * This method resets the content of the X, Y, Z, size and GroupName widgets;
883 void GHS3DPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
885 myXCoord->setCleared(true);
886 myYCoord->setCleared(true);
887 myZCoord->setCleared(true);
888 myXCoord->setText("");
889 myYCoord->setText("");
890 myZCoord->setText("");
891 addVertexButton->setEnabled(false);
894 /** GHS3DPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item)
895 This method updates the tooltip of a modified item. The QLineEdit widgets content
896 is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
898 void GHS3DPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTableWidgetItem* item)
900 int row = myEnforcedTableWidget->row(item);
902 QVariant vertexName = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole);
903 QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole);
904 QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole);
905 QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole);
906 QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole);
907 QVariant entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
908 QString groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole).toString();
910 clearEnforcedVertexWidgets();
912 if ( !x.isNull() || !entry.isNull()) {
913 QString toolTip = vertexName.toString();
914 toolTip += QString("(");
915 if (entry.isNull() || (!entry.isNull() && entry.toString() == "")) {
916 toolTip += x.toString();
917 toolTip += QString(", ") + y.toString();
918 toolTip += QString(", ") + z.toString();
921 toolTip += entry.toString();
922 toolTip += QString(")");
925 toolTip += QString("=") + size.toString();
927 if (!groupName.isEmpty())
928 toolTip += QString(" [") + groupName + QString("]");
930 for (int col=0;col<ENF_VER_NB_COLUMNS;col++)
931 myEnforcedTableWidget->item(row,col)->setToolTip(toolTip);
934 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
935 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
936 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
937 myXCoord->SetValue(x.toDouble());
938 myYCoord->SetValue(y.toDouble());
939 myZCoord->SetValue(z.toDouble());
940 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
941 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
942 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
945 mySizeValue->SetValue(size.toDouble());
947 if (!groupName.isEmpty())
948 myGroupName->setText(groupName);
952 void GHS3DPluginGUI_HypothesisCreator::onSelectEnforcedVertex()
954 size_t nbSelEnfVertex = myEnfVertexWdg->NbObjects();
955 clearEnforcedVertexWidgets();
956 if (nbSelEnfVertex == 1)
958 if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() )
961 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
962 if (myEnfVertex == GEOM::GEOM_Object::_nil())
964 if (myEnfVertex->GetShapeType() == GEOM::VERTEX)
966 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( );
967 if (CORBA::is_nil(measureOp))
971 measureOp->PointCoordinates (myEnfVertex, x, y, z);
972 if ( measureOp->IsDone() )
974 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
975 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
976 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
977 myXCoord->SetValue(x);
978 myYCoord->SetValue(y);
979 myZCoord->SetValue(z);
980 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
981 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
982 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
988 /** GHS3DPluginGUI_HypothesisCreator::synchronizeCoords()
989 This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
990 of the enforced vertex clicked in the tree widget.
992 void GHS3DPluginGUI_HypothesisCreator::synchronizeCoords()
994 clearEnforcedVertexWidgets();
995 QList<QTableWidgetItem *> items = myEnforcedTableWidget->selectedItems();
996 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
997 if (! items.isEmpty()) {
998 QTableWidgetItem *item;
1001 if (items.size() == 1) {
1003 row = myEnforcedTableWidget->row(item);
1004 QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole);
1005 QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole);
1006 QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole);
1007 QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole);
1008 entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
1009 if (!entry.isNull()) {
1010 SMESH::string_array_var objIds = new SMESH::string_array;
1012 objIds[0] = entry.toString().toStdString().c_str();
1013 myEnfVertexWdg->SetObjects(objIds);
1016 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1018 QVariant group = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole);
1019 if (!x.isNull()/* && entry.isNull()*/) {
1020 // disconnect( myXCoord, SIGNAL( textChanged(const QString &)), this, SLOT( onSelectEnforcedVertex() ) );
1021 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
1022 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
1023 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
1024 myXCoord->SetValue(x.toDouble());
1025 myYCoord->SetValue(y.toDouble());
1026 myZCoord->SetValue(z.toDouble());
1027 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
1028 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
1029 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
1032 mySizeValue->SetValue(size.toDouble());
1034 if (!group.isNull() && (!x.isNull() || !entry.isNull()))
1035 myGroupName->setText(group.toString());
1038 QList<QString> entryList;
1039 for (int i = 0; i < items.size(); ++i) {
1041 row = myEnforcedTableWidget->row(item);
1042 entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
1043 if (!entry.isNull())
1044 entryList << entry.toString();
1046 if (entryList.size() > 0) {
1047 SMESH::string_array_var objIds = new SMESH::string_array;
1048 objIds->length(entryList.size());
1049 for (int i = 0; i < entryList.size() ; i++)
1050 objIds[i] = entryList.at(i).toStdString().c_str();
1051 myEnfVertexWdg->SetObjects(objIds);
1054 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1059 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1061 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
1062 GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
1063 that->checkVertexIsDefined();
1066 /** GHS3DPluginGUI_HypothesisCreator::addEnforcedMesh( meshName, geomEntry, elemType, size, groupName)
1067 This method adds in the tree widget an enforced mesh from mesh, submesh or group with optionally size and and groupName.
1069 void GHS3DPluginGUI_HypothesisCreator::addEnforcedMesh(std::string name,
1072 std::string groupName)
1074 bool okToCreate = true;
1075 QString itemEntry = "";
1076 int itemElementType = 0;
1077 int rowCount = myEnforcedMeshTableWidget->rowCount();
1078 bool allColumns = true;
1079 for (int row = 0;row<rowCount;row++) {
1080 for (int col = 0 ; col < ENF_MESH_NB_COLUMNS ; col++) {
1081 if (col == ENF_MESH_CONSTRAINT_COLUMN){
1082 if (qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row, col)) == 0) {
1087 else if (myEnforcedMeshTableWidget->item(row, col) == 0) {
1091 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1092 QComboBox* itemComboBox = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row, col));
1093 itemElementType = itemComboBox->currentIndex();
1095 else if (col == ENF_MESH_ENTRY_COLUMN)
1096 itemEntry = myEnforcedMeshTableWidget->item(row, col)->data(Qt::EditRole).toString();
1102 if (itemEntry == QString(entry.c_str()) && itemElementType == elementType) {
1112 myEnforcedMeshTableWidget->setRowCount(rowCount+1);
1113 myEnforcedMeshTableWidget->setSortingEnabled(false);
1115 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++) {
1116 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1117 QComboBox* comboBox = new QComboBox();
1118 QPalette pal = comboBox->palette();
1119 pal.setColor(QPalette::Button, Qt::white);
1120 comboBox->setPalette(pal);
1121 comboBox->insertItems(0,myEnfMeshConstraintLabels);
1122 comboBox->setEditable(false);
1123 comboBox->setCurrentIndex(elementType);
1124 myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox);
1127 QTableWidgetItem* item = new QTableWidgetItem();
1128 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1130 case ENF_MESH_NAME_COLUMN:
1131 item->setData( 0, name.c_str() );
1132 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1133 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1135 case ENF_MESH_ENTRY_COLUMN:
1136 item->setData( 0, entry.c_str() );
1137 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1138 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1140 case ENF_MESH_GROUP_COLUMN:
1141 item->setData( 0, groupName.c_str() );
1142 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1149 myEnforcedMeshTableWidget->setSortingEnabled(true);
1152 /** GHS3DPluginGUI_HypothesisCreator::addEnforcedVertex( x, y, z, size, vertexName, geomEntry, groupName)
1153 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.
1155 void GHS3DPluginGUI_HypothesisCreator::addEnforcedVertex(double x, double y, double z, double size, std::string vertexName, std::string geomEntry, std::string groupName, bool isCompound)
1157 myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1158 bool okToCreate = true;
1159 double itemX=0.,itemY=0.,itemZ=0.,itemSize = 0;
1160 QString itemEntry, itemGroupName = QString("");
1161 // bool itemIsCompound;
1162 int rowCount = myEnforcedTableWidget->rowCount();
1165 for (int row = 0;row<rowCount;row++) {
1167 for (int col = 0 ; col < ENF_VER_NB_COLUMNS ; col++) {
1168 if (myEnforcedTableWidget->item(row, col) == 0) {
1173 data = myEnforcedTableWidget->item(row, col)->data(Qt::EditRole);
1174 if (!data.isNull()) {
1176 case ENF_VER_GROUP_COLUMN:
1177 itemGroupName = data.toString();
1179 case ENF_VER_ENTRY_COLUMN:
1180 itemEntry = data.toString();
1182 case ENF_VER_X_COLUMN:
1183 itemX = data.toDouble();
1185 case ENF_VER_Y_COLUMN:
1186 itemY = data.toDouble();
1188 case ENF_VER_Z_COLUMN:
1189 itemZ = data.toDouble();
1191 case ENF_VER_SIZE_COLUMN:
1192 itemSize = data.toDouble();
1204 if (( !isCompound && ((itemX == x) && (itemY == y) && (itemZ == z))) ||
1205 ( !itemEntry.isEmpty() && ( itemEntry == geomEntry.c_str() )))
1208 if (itemSize != size) {
1209 myEnforcedTableWidget->item(row, ENF_VER_SIZE_COLUMN)->setData( Qt::EditRole, QVariant(size));
1211 // update group name
1212 if (itemGroupName.toStdString() != groupName) {
1213 myEnforcedTableWidget->item(row, ENF_VER_GROUP_COLUMN)->setData( Qt::EditRole, QVariant(groupName.c_str()));
1220 if (geomEntry.empty()) {
1229 QString myVertexName;
1230 while(indexRef != vertexIndex) {
1231 indexRef = vertexIndex;
1232 if (vertexName.empty())
1233 myVertexName = QString("Vertex #%1").arg(vertexIndex);
1235 myVertexName = QString(vertexName.c_str());
1237 for (int row = 0;row<rowCount;row++) {
1238 QString name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString();
1239 if (myVertexName == name) {
1246 myEnforcedTableWidget->setRowCount(rowCount+1);
1247 myEnforcedTableWidget->setSortingEnabled(false);
1248 for (int col=0;col<ENF_VER_NB_COLUMNS;col++) {
1249 QTableWidgetItem* item = new QTableWidgetItem();
1250 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1252 case ENF_VER_NAME_COLUMN:
1253 item->setData( Qt::EditRole, myVertexName );
1254 if (!geomEntry.empty()) {
1256 item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1258 item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1261 case ENF_VER_X_COLUMN:
1263 item->setData( 0, QVariant(x) );
1265 case ENF_VER_Y_COLUMN:
1267 item->setData( 0, QVariant(y) );
1269 case ENF_VER_Z_COLUMN:
1271 item->setData( 0, QVariant(z) );
1273 case ENF_VER_SIZE_COLUMN:
1274 item->setData( 0, QVariant(size) );
1276 case ENF_VER_ENTRY_COLUMN:
1277 if (!geomEntry.empty())
1278 item->setData( 0, QString(geomEntry.c_str()) );
1280 case ENF_VER_COMPOUND_COLUMN:
1281 item->setData( Qt::CheckStateRole, isCompound );
1282 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
1284 case ENF_VER_GROUP_COLUMN:
1285 if (!groupName.empty())
1286 item->setData( 0, QString(groupName.c_str()) );
1292 myEnforcedTableWidget->setItem(rowCount,col,item);
1295 connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1297 myEnforcedTableWidget->setSortingEnabled(true);
1298 // myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1299 updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1302 /** GHS3DPluginGUI_HypothesisCreator::onAddEnforcedMesh()
1303 This method is called when a item is added into the enforced meshes tree widget
1305 void GHS3DPluginGUI_HypothesisCreator::onAddEnforcedMesh()
1307 GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
1309 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1310 myEnfMeshWdg->deactivateSelection();
1312 for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column)
1313 myEnforcedMeshTableWidget->resizeColumnToContents(column);
1316 size_t selEnfMeshes = myEnfMeshWdg->NbObjects();
1317 if (selEnfMeshes == 0)
1320 std::string groupName = myMeshGroupName->text().simplified().toStdString();
1322 int elementType = myEnfMeshConstraint->currentIndex();
1325 _PTR(Study) aStudy = SMESH::getStudy();
1326 _PTR(SObject) aSObj;
1327 QString meshEntry = myEnfMeshWdg->GetValue();
1329 if (selEnfMeshes == 1)
1331 aSObj = aStudy->FindObjectID(meshEntry.toStdString().c_str());
1332 CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj);
1333 if (!CORBA::is_nil(anObj)) {
1334 addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
1339 QStringList meshEntries = meshEntry.split(" ", QString::SkipEmptyParts);
1340 QStringListIterator meshEntriesIt (meshEntries);
1341 while (meshEntriesIt.hasNext()) {
1342 aSObj = aStudy->FindObjectID(meshEntriesIt.next().toStdString().c_str());
1343 CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj);
1344 if (!CORBA::is_nil(anObj)) {
1345 addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
1350 myEnfVertexWdg->SetObject(SMESH::SMESH_IDSource::_nil());
1352 for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column)
1353 myEnforcedMeshTableWidget->resizeColumnToContents(column);
1357 /** GHS3DPluginGUI_HypothesisCreator::onAddEnforcedVertex()
1358 This method is called when a item is added into the enforced vertices tree widget
1360 void GHS3DPluginGUI_HypothesisCreator::onAddEnforcedVertex()
1362 GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
1364 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1365 myEnfVertexWdg->deactivateSelection();
1367 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1368 myEnforcedTableWidget->resizeColumnToContents(column);
1371 size_t selEnfVertex = myEnfVertexWdg->NbObjects();
1372 bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty());
1373 if ((selEnfVertex == 0) && coordsEmpty)
1376 std::string groupName = myGroupName->text().simplified().toStdString();
1378 double size = mySizeValue->GetValue();
1380 if (selEnfVertex <= 1)
1382 double x = 0, y = 0, z=0;
1383 if (myXCoord->GetString() != "") {
1384 x = myXCoord->GetValue();
1385 y = myYCoord->GetValue();
1386 z = myZCoord->GetValue();
1388 if (selEnfVertex == 1) {
1389 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >();
1390 std::string entry = "", name = "";
1391 bool isCompound = false;
1392 if ( !myEnfVertex->_is_nil() ) {
1393 entry = SMESH::toStdStr( myEnfVertex->GetStudyEntry() );
1394 name = SMESH::toStdStr( myEnfVertex->GetName() );
1395 isCompound = ( myEnfVertex->GetShapeType() == GEOM::COMPOUND );
1397 addEnforcedVertex(x, y, z, size, name, entry, groupName, isCompound);
1400 addEnforcedVertex(x, y, z, size, "", "", groupName);
1405 if ( CORBA::is_nil(getGeomEngine()))
1408 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( );
1409 if (CORBA::is_nil(measureOp))
1412 CORBA::Double x = 0, y = 0,z = 0;
1413 for ( size_t j = 0 ; j < selEnfVertex ; j++)
1415 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j);
1416 if (myEnfVertex == GEOM::GEOM_Object::_nil())
1418 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1419 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1420 if ( measureOp->IsDone() )
1421 addEnforcedVertex(x, y, z, size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1422 } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) {
1423 addEnforcedVertex(0., 0., 0., size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName, true);
1428 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1430 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1431 myEnforcedTableWidget->resizeColumnToContents(column);
1434 /** GHS3DPluginGUI_HypothesisCreator::onRemoveEnforcedMesh()
1435 This method is called when a item is removed from the enforced meshes tree widget
1437 void GHS3DPluginGUI_HypothesisCreator::onRemoveEnforcedMesh()
1439 QList<int> selectedRows;
1440 QList<QTableWidgetItem *> selectedItems = myEnforcedMeshTableWidget->selectedItems();
1441 QTableWidgetItem* item;
1443 foreach( item, selectedItems ) {
1445 if (!selectedRows.contains( row ) )
1446 selectedRows.append(row);
1449 qSort( selectedRows );
1450 QListIterator<int> it( selectedRows );
1452 while ( it.hasPrevious() ) {
1453 row = it.previous();
1454 myEnforcedMeshTableWidget->removeRow(row );
1457 myEnforcedMeshTableWidget->selectionModel()->clearSelection();
1460 /** GHS3DPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1461 This method is called when a item is removed from the enforced vertices tree widget
1463 void GHS3DPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1465 QList<int> selectedRows;
1466 QList<QTableWidgetItem *> selectedItems = myEnforcedTableWidget->selectedItems();
1467 QTableWidgetItem* item;
1469 foreach( item, selectedItems ) {
1471 if (!selectedRows.contains( row ) )
1472 selectedRows.append(row);
1475 qSort( selectedRows );
1476 QListIterator<int> it( selectedRows );
1478 while ( it.hasPrevious() ) {
1479 row = it.previous();
1480 myEnforcedTableWidget->removeRow(row );
1483 myEnforcedTableWidget->selectionModel()->clearSelection();
1486 void GHS3DPluginGUI_HypothesisCreator::onToMeshHoles(bool /*isOn*/)
1488 // myToMakeGroupsOfDomains->setEnabled( isOn );
1490 // myToMakeGroupsOfDomains->setChecked( false );
1493 void GHS3DPluginGUI_HypothesisCreator::onDirBtnClicked()
1495 QString dir = SUIT_FileDlg::getExistingDirectory( dlg(), myAdvWidget->workingDirectoryLineEdit->text(), QString() );
1496 if ( !dir.isEmpty() )
1497 myAdvWidget->workingDirectoryLineEdit->setText( dir );
1500 void GHS3DPluginGUI_HypothesisCreator::updateWidgets()
1502 //myToMakeGroupsOfDomains->setEnabled( myToMeshHolesCheck->isChecked() );
1503 myAdvWidget->maxMemorySpin->setEnabled( myAdvWidget->maxMemoryCheck->isChecked() );
1504 //myAdvWidget->initialMemoryCheck->setEnabled( !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1505 myAdvWidget->initialMemorySpin->setEnabled( myAdvWidget->initialMemoryCheck->isChecked() /*&& !myAdvWidget->boundaryRecoveryCheck->isChecked()*/ );
1506 //myOptimizationLevelCombo->setEnabled( !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1507 if ( sender() == myAdvWidget->logInFileCheck ||
1508 sender() == myAdvWidget->keepWorkingFilesCheck )
1510 bool logFileRemovable = ( myAdvWidget->logInFileCheck->isChecked() &&
1511 !myAdvWidget->keepWorkingFilesCheck->isChecked() );
1512 myAdvWidget->removeLogOnSuccessCheck->setEnabled( logFileRemovable );
1516 bool GHS3DPluginGUI_HypothesisCreator::checkParams(QString& msg) const
1518 if ( !QFileInfo( myAdvWidget->workingDirectoryLineEdit->text().trimmed() ).isWritable() ) {
1519 SUIT_MessageBox::warning( dlg(),
1520 tr( "SMESH_WRN_WARNING" ),
1521 tr( "GHS3D_PERMISSION_DENIED" ) );
1525 GHS3DPlugin::GHS3DPlugin_Hypothesis_var h =
1526 GHS3DPlugin::GHS3DPlugin_Hypothesis::_narrow( hypothesis() );
1528 myAdvWidget->myOptionTable->setFocus();
1529 QApplication::instance()->processEvents();
1531 QString name, value;
1532 bool isDefault, ok = true;
1533 int iRow = 0, nbRows = myAdvWidget->myOptionTable->topLevelItemCount();
1534 for ( ; iRow < nbRows; ++iRow )
1536 QTreeWidgetItem* row = myAdvWidget->myOptionTable->topLevelItem( iRow );
1537 myAdvWidget->GetOptionAndValue( row, name, value, isDefault );
1539 if ( name.simplified().isEmpty() )
1540 continue; // invalid custom option
1542 if ( isDefault ) // not selected option
1546 h->SetOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
1548 catch ( const SALOME::SALOME_Exception& ex )
1550 msg = ex.details.text.in();
1558 h->SetOptionValues( myOptions ); // restore values
1564 void GHS3DPluginGUI_HypothesisCreator::retrieveParams() const
1566 GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
1567 GHS3DHypothesisData data;
1568 readParamsFromHypo( data );
1572 myName->setText( data.myName );
1574 int width = QFontMetrics( myName->font() ).width( data.myName );
1575 QGridLayout* aStdLayout = (QGridLayout*) myStdGroup->layout();
1576 aStdLayout->setColumnMinimumWidth( 1, width + 10 );
1578 myToMeshHolesCheck ->setChecked ( data.myToMeshHoles );
1579 myToMakeGroupsOfDomains ->setChecked ( data.myToMakeGroupsOfDomains );
1581 if ( data.myAlgorithm == GHS3DPlugin_Hypothesis::MGTetraHPC && data.myOptimizationLevel == GHS3DPlugin_Hypothesis::StandardPlus /*not implemented by MGTetraHPC*/ )
1582 myOptimizationLevelCombo ->setCurrentIndex( GHS3DPlugin_Hypothesis::None );
1584 myOptimizationLevelCombo ->setCurrentIndex( data.myOptimizationLevel );
1586 if ( myOptimizationCombo ) // optimizer
1588 myOptimizationCombo ->setCurrentIndex( data.myOptimization );
1589 mySplitOverConstrainedCombo ->setCurrentIndex( data.mySplitOverConstrained );
1590 myPThreadsModeCombo ->setCurrentIndex( data.myPThreadsMode );
1591 myNumberOfThreadsSpin ->setValue ( data.myNumberOfThreads );
1592 mySmoothOffSliversCheck ->setChecked ( data.mySmoothOffSlivers );
1593 myCreateNewNodesCheck ->setChecked ( data.myToCreateNewNodes );
1597 myRadioBottomGroup ->button( data.myAlgorithm )->setChecked( true );
1598 myMinSizeSpin ->setValue( data.myMinSize );
1599 myMinSizeCheck ->setChecked( data.myUseMinSize );
1600 myMaxSizeSpin ->setValue( data.myMaxSize );
1601 myMaxSizeCheck ->setChecked( data.myUseMaxSize );
1602 myGradationCheck ->setChecked( data.myUseGradation );
1603 myGradationSpin ->setValue( data.myUseGradation ? data.myGradation : GHS3DPlugin_Hypothesis::DefaultGradation() );
1604 myUseProximityGroup ->setChecked( data.myUseProximity );
1605 myNbProximityLayers ->setValue( data.myNbProximityLayers );
1606 myNumOfThreadsCheck ->setChecked( data.myUseNumOfThreads );
1607 myNumOfThreadsSpin ->setValue( data.myNumOfThreads );
1608 myPthreadMode ->setCurrentIndex( data.myPthreadMode );
1609 myParallelMode ->setCurrentIndex( data.myParallelMode );
1611 myAdvWidget->maxMemoryCheck ->setChecked ( data.myMaximumMemory > 0 );
1612 myAdvWidget->maxMemorySpin ->setValue
1613 ( qMax( data.myMaximumMemory, (float)myAdvWidget->maxMemorySpin->minimum() ));
1614 myAdvWidget->initialMemoryCheck ->setChecked ( data.myInitialMemory > 0 );
1615 myAdvWidget->initialMemorySpin ->setValue
1616 ( qMax( data.myInitialMemory, (float)myAdvWidget->initialMemorySpin->minimum() ));
1617 myAdvWidget->workingDirectoryLineEdit ->setText ( data.myWorkingDir );
1618 myAdvWidget->keepWorkingFilesCheck ->setChecked ( data.myKeepFiles );
1619 myAdvWidget->verboseLevelSpin ->setValue ( data.myVerboseLevel );
1620 myAdvWidget->logInFileCheck ->setChecked ( !data.myLogInStandardOutput );
1621 myAdvWidget->removeLogOnSuccessCheck ->setChecked ( data.myRemoveLogOnSuccess );
1623 if ( myOptions.operator->() ) {
1624 for ( int i = 0, nb = myOptions->length(); i < nb; ++i )
1625 myAdvWidget->AddOption( that->myOptions[i].in() );
1627 if ( myCustomOptions.operator->() ) {
1628 for ( int i = 0, nb = myCustomOptions->length(); i < nb; ++i )
1629 myAdvWidget->AddOption( that->myCustomOptions[i].in() );
1631 myAdvWidget->myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
1632 myAdvWidget->EnableAdvancedOptions( data.myAlgorithm == GHS3DPlugin_Hypothesis::MGTetra );
1634 TEnfVertexList::const_iterator it;
1636 myEnforcedTableWidget->clearContents();
1637 myEnforcedTableWidget->setSortingEnabled(false);
1638 myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1639 for(it = data.myEnforcedVertices.begin() ; it != data.myEnforcedVertices.end(); it++ )
1641 TEnfVertex* enfVertex = (*it);
1642 myEnforcedTableWidget->setRowCount(rowCount+1);
1644 for (int col=0;col<ENF_VER_NB_COLUMNS;col++) {
1645 QTableWidgetItem* item = new QTableWidgetItem();
1646 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1648 case ENF_VER_NAME_COLUMN:
1649 item->setData( 0, enfVertex->name.c_str() );
1650 if (!enfVertex->geomEntry.empty()) {
1651 if (enfVertex->isCompound)
1652 item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1654 item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1658 case ENF_VER_X_COLUMN:
1659 if (!enfVertex->isCompound) {
1660 item->setData( 0, enfVertex->coords.at(0) );
1663 case ENF_VER_Y_COLUMN:
1664 if (!enfVertex->isCompound) {
1665 item->setData( 0, enfVertex->coords.at(1) );
1668 case ENF_VER_Z_COLUMN:
1669 if (!enfVertex->isCompound) {
1670 item->setData( 0, enfVertex->coords.at(2) );
1673 case ENF_VER_SIZE_COLUMN:
1674 item->setData( 0, enfVertex->size );
1676 case ENF_VER_ENTRY_COLUMN:
1677 item->setData( 0, enfVertex->geomEntry.c_str() );
1679 case ENF_VER_COMPOUND_COLUMN:
1680 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
1681 item->setData( Qt::CheckStateRole, enfVertex->isCompound );
1683 case ENF_VER_GROUP_COLUMN:
1684 item->setData( 0, enfVertex->groupName.c_str() );
1690 myEnforcedTableWidget->setItem(rowCount,col,item);
1692 that->updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1696 connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1697 myEnforcedTableWidget->setSortingEnabled(true);
1699 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1700 myEnforcedTableWidget->resizeColumnToContents(column);
1702 // Update Enforced meshes QTableWidget
1703 TEnfMeshList::const_iterator itMesh;
1705 myEnforcedMeshTableWidget->clearContents();
1706 myEnforcedMeshTableWidget->setSortingEnabled(false);
1707 // myEnforcedMeshTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1708 for(itMesh = data.myEnforcedMeshes.begin() ; itMesh != data.myEnforcedMeshes.end(); itMesh++ )
1710 TEnfMesh* enfMesh = (*itMesh);
1711 myEnforcedMeshTableWidget->setRowCount(rowCount+1);
1713 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++) {
1714 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1715 QComboBox* comboBox = new QComboBox();
1716 QPalette pal = comboBox->palette();
1717 pal.setColor(QPalette::Button, Qt::white);
1718 comboBox->setPalette(pal);
1719 comboBox->insertItems(0,myEnfMeshConstraintLabels);
1720 comboBox->setEditable(false);
1721 comboBox->setCurrentIndex(enfMesh->elementType);
1722 myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox);
1725 QTableWidgetItem* item = new QTableWidgetItem();
1726 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1728 case ENF_MESH_NAME_COLUMN:
1729 item->setData( 0, enfMesh->name.c_str() );
1730 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1731 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1733 case ENF_MESH_ENTRY_COLUMN:
1734 item->setData( 0, enfMesh->entry.c_str() );
1735 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1736 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1738 case ENF_MESH_GROUP_COLUMN:
1739 item->setData( 0, enfMesh->groupName.c_str() );
1740 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1751 myEnforcedMeshTableWidget->setSortingEnabled(true);
1753 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++)
1754 myEnforcedMeshTableWidget->resizeColumnToContents(col);
1756 that->updateWidgets();
1757 that->checkVertexIsDefined();
1760 QString GHS3DPluginGUI_HypothesisCreator::storeParams() const
1762 GHS3DHypothesisData data;
1763 readParamsFromWidgets( data );
1764 storeParamsToHypo( data );
1766 QString valStr = "";
1768 if ( !data.myBoundaryRecovery )
1769 valStr = " --components " + data.myToMeshHoles ? "all" : "outside_components" ;
1771 if ( data.myOptimizationLevel >= 0 && data.myOptimizationLevel < 5 && !data.myBoundaryRecovery) {
1772 const char* level[] = { "none" , "light" , "standard" , "standard+" , "strong" };
1773 valStr += " --optimisation_level ";
1774 valStr += level[ data.myOptimizationLevel ];
1776 if ( data.myMaximumMemory > 0 ) {
1777 valStr += " --max_memory ";
1778 valStr += QString::number( data.myMaximumMemory );
1780 if ( data.myInitialMemory > 0 && !data.myBoundaryRecovery ) {
1781 valStr += " --automatic_memory ";
1782 valStr += QString::number( data.myInitialMemory );
1784 valStr += " --verbose ";
1785 valStr += QString::number( data.myVerboseLevel );
1787 if ( !data.myToCreateNewNodes )
1788 valStr += " --no_internal_points";
1790 if ( data.myRemoveInitialCentralPoint )
1791 valStr += " --no_initial_central_point";
1793 // if ( data.myBoundaryRecovery )
1796 // if ( data.myFEMCorrection )
1797 // valStr += " -FEM";
1799 if ( data.myGradation != 1.05 ) {
1800 valStr += " -Dcpropa=";
1801 valStr += QString::number( data.myGradation );
1807 bool GHS3DPluginGUI_HypothesisCreator::readParamsFromHypo( GHS3DHypothesisData& h_data ) const
1809 GHS3DPlugin::GHS3DPlugin_Hypothesis_var h =
1810 GHS3DPlugin::GHS3DPlugin_Hypothesis::_narrow( initParamsHypothesis() );
1811 GHS3DPlugin::GHS3DPlugin_OptimizerHypothesis_var opt =
1812 GHS3DPlugin::GHS3DPlugin_OptimizerHypothesis::_narrow( initParamsHypothesis() );
1814 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
1815 h_data.myName = isCreation() && data ? hypName() : "";
1817 if ( !opt->_is_nil() )
1819 h_data.myOptimization = opt->GetOptimization();
1820 h_data.mySplitOverConstrained = opt->GetSplitOverConstrained();
1821 h_data.myPThreadsMode = opt->GetPThreadsMode();
1822 h_data.myNumberOfThreads = opt->GetMaximalNumberOfThreads();
1823 h_data.mySmoothOffSlivers = opt->GetSmoothOffSlivers();
1827 // avoid "Conditional jump or move depends on uninitialised value" error
1828 h_data.myOptimization = 1;
1829 h_data.mySplitOverConstrained = 1;
1830 h_data.myPThreadsMode = 1;
1831 h_data.myNumberOfThreads = 1;
1832 h_data.mySmoothOffSlivers = 1;
1834 h_data.myAlgorithm = h->GetAlgorithm();
1835 h_data.myOptimizationLevel = h->GetOptimizationLevel();
1836 h_data.myMinSize = h->GetMinSize();
1837 h_data.myMaxSize = h->GetMaxSize();
1838 this->myMinSizeDefault = h->GetMinSizeDefault();
1839 this->myMaxSizeDefault = h->GetMaxSizeDefault();
1840 if ( ! ( h_data.myUseMinSize = h_data.myMinSize > 0 ))
1841 h_data.myMinSize = this->myMinSizeDefault;
1842 if ( ! ( h_data.myUseMaxSize = h_data.myMaxSize > 0 ))
1843 h_data.myMaxSize = this->myMaxSizeDefault;
1844 h_data.myNbProximityLayers = h->GetNbVolumeProximityLayers();
1845 h_data.myUseGradation = h->GetGradation() != GHS3DPlugin_Hypothesis::DefaultGradation();
1846 h_data.myUseProximity = h->GetVolumeProximity();
1847 h_data.myToMeshHoles = h->GetToMeshHoles();
1848 h_data.myToMakeGroupsOfDomains = h->GetToMakeGroupsOfDomains();
1849 h_data.myMaximumMemory = h->GetMaximumMemory();
1850 h_data.myInitialMemory = h->GetInitialMemory();
1851 h_data.myInitialMemory = h->GetInitialMemory();
1852 h_data.myKeepFiles = h->GetKeepFiles();
1853 h_data.myWorkingDir = h->GetWorkingDirectory();
1854 h_data.myVerboseLevel = h->GetVerboseLevel();
1855 h_data.myToCreateNewNodes = h->GetToCreateNewNodes();
1856 //h_data.myRemoveInitialCentralPoint = h->GetToRemoveCentralPoint();
1857 //h_data.myBoundaryRecovery = h->GetToUseBoundaryRecoveryVersion();
1858 //h_data.myFEMCorrection = h->GetFEMCorrection();
1859 h_data.myGradation = h->GetGradation();
1860 //h_data.myTextOption = h->GetAdvancedOption();
1861 h_data.myLogInStandardOutput = h->GetStandardOutputLog();
1862 h_data.myRemoveLogOnSuccess = h->GetRemoveLogOnSuccess();
1863 h_data.myUseNumOfThreads = h->GetUseNumOfThreads();
1864 h_data.myNumOfThreads = h->GetNumOfThreads();
1865 h_data.myPthreadMode = h->GetPthreadMode();
1866 h_data.myParallelMode = h->GetParallelMode();
1868 GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
1869 that->myOptions = h->GetOptionValues();
1870 that->myCustomOptions = h->GetAdvancedOptionValues();
1872 GHS3DPlugin::GHS3DEnforcedVertexList_var vertices = h->GetEnforcedVertices();
1873 h_data.myEnforcedVertices.clear();
1874 for (CORBA::ULong i=0 ; i<vertices->length() ; i++) {
1875 TEnfVertex* myVertex = new TEnfVertex();
1876 myVertex->name = CORBA::string_dup(vertices[i].name.in());
1877 myVertex->geomEntry = CORBA::string_dup(vertices[i].geomEntry.in());
1878 myVertex->groupName = CORBA::string_dup(vertices[i].groupName.in());
1879 myVertex->size = vertices[i].size;
1880 myVertex->isCompound = vertices[i].isCompound;
1881 if (vertices[i].coords.length()) {
1882 for (CORBA::ULong c = 0; c < vertices[i].coords.length() ; c++)
1883 myVertex->coords.push_back(vertices[i].coords[c]);
1885 h_data.myEnforcedVertices.insert(myVertex);
1888 GHS3DPlugin::GHS3DEnforcedMeshList_var enfMeshes = h->GetEnforcedMeshes();
1889 h_data.myEnforcedMeshes.clear();
1890 for (CORBA::ULong i=0 ; i<enfMeshes->length() ; i++) {
1891 TEnfMesh* myEnfMesh = new TEnfMesh();
1892 myEnfMesh->name = CORBA::string_dup(enfMeshes[i].name.in());
1893 myEnfMesh->entry = CORBA::string_dup(enfMeshes[i].entry.in());
1894 myEnfMesh->groupName = CORBA::string_dup(enfMeshes[i].groupName.in());
1895 switch (enfMeshes[i].elementType) {
1897 myEnfMesh->elementType = 0;
1900 myEnfMesh->elementType = 1;
1903 myEnfMesh->elementType = 2;
1908 // myEnfMesh->elementType = enfMeshes[i].elementType;
1909 h_data.myEnforcedMeshes.insert(myEnfMesh);
1914 bool GHS3DPluginGUI_HypothesisCreator::storeParamsToHypo( const GHS3DHypothesisData& h_data ) const
1916 GHS3DPlugin::GHS3DPlugin_Hypothesis_var h =
1917 GHS3DPlugin::GHS3DPlugin_Hypothesis::_narrow( hypothesis() );
1918 GHS3DPlugin::GHS3DPlugin_OptimizerHypothesis_var opt =
1919 GHS3DPlugin::GHS3DPlugin_OptimizerHypothesis::_narrow( initParamsHypothesis() );
1925 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
1927 if ( opt->_is_nil() )
1929 h->SetAlgorithm ((CORBA::Short) h_data.myAlgorithm );
1930 h->SetUseNumOfThreads ( h_data.myUseNumOfThreads );
1931 h->SetNumOfThreads ( (CORBA::Short) h_data.myNumOfThreads );
1932 h->SetPthreadMode ( (CORBA::Short) h_data.myPthreadMode );
1933 h->SetParallelMode ( (CORBA::Short) h_data.myParallelMode );
1934 h->SetGradation ( h_data.myGradation );
1935 h->SetToMeshHoles ( h_data.myToMeshHoles );
1936 h->SetToMakeGroupsOfDomains ( h_data.myToMakeGroupsOfDomains );
1937 h->SetVolumeProximity ( h_data.myUseProximity );
1938 h->SetNbVolumeProximityLayers ((CORBA::Short) h_data.myNbProximityLayers );
1941 // Common existing options optimization a MGTetra && MGTetraHPC
1942 h->SetOptimizationLevel ((CORBA::Short) h_data.myOptimizationLevel );
1943 h->SetMinSize ( h_data.myUseMinSize ? h_data.myMinSize : 0 );
1944 h->SetMaxSize ( h_data.myUseMaxSize ? h_data.myMaxSize : 0 );
1945 h->SetMinMaxSizeDefault ( this->myMinSizeDefault, this->myMaxSizeDefault );
1947 h->SetMaximumMemory ( h_data.myMaximumMemory );
1948 h->SetInitialMemory ( h_data.myInitialMemory );
1949 h->SetKeepFiles ( h_data.myKeepFiles );
1950 h->SetWorkingDirectory ( h_data.myWorkingDir.toLatin1().constData() );
1951 h->SetVerboseLevel ( h_data.myVerboseLevel );
1952 //h->SetToRemoveCentralPoint ( h_data.myRemoveInitialCentralPoint );
1953 //h->SetToUseBoundaryRecoveryVersion( h_data.myBoundaryRecovery );
1954 //h->SetFEMCorrection ( h_data.myFEMCorrection );
1955 h->SetStandardOutputLog ( h_data.myLogInStandardOutput );
1956 h->SetRemoveLogOnSuccess ( h_data.myRemoveLogOnSuccess );
1959 if ( !opt->_is_nil() )
1961 opt->SetToCreateNewNodes ( h_data.myToCreateNewNodes );
1962 opt->SetOptimization ( (GHS3DPlugin::Mode) h_data.myOptimization );
1963 opt->SetSplitOverConstrained ( (GHS3DPlugin::Mode) h_data.mySplitOverConstrained );
1964 opt->SetPThreadsMode ( (GHS3DPlugin::PThreadsMode) h_data.myPThreadsMode );
1965 opt->SetSmoothOffSlivers ( h_data.mySmoothOffSlivers );
1966 opt->SetMaximalNumberOfThreads((CORBA::Short) h_data.myNumberOfThreads );
1969 // Enforced vertices
1970 GHS3DPlugin::GHS3DEnforcedVertexList_var vertexHyp = h->GetEnforcedVertices();
1971 int nbVertexHyp = vertexHyp->length();
1973 // 1. Clear all enforced vertices in hypothesis
1974 // 2. Add new enforced vertex according to h_data
1975 if ( nbVertexHyp > 0)
1976 h->ClearEnforcedVertices();
1978 TEnfVertexList::const_iterator it;
1979 double x = 0, y = 0, z = 0;
1980 for(it = h_data.myEnforcedVertices.begin() ; it != h_data.myEnforcedVertices.end(); it++ ) {
1981 TEnfVertex* enfVertex = (*it);
1983 if (enfVertex->coords.size()) {
1984 x = enfVertex->coords.at(0);
1985 y = enfVertex->coords.at(1);
1986 z = enfVertex->coords.at(2);
1988 ok = h->p_SetEnforcedVertex( enfVertex->size, x, y, z, enfVertex->name.c_str(), enfVertex->geomEntry.c_str(), enfVertex->groupName.c_str(), enfVertex->isCompound);
1992 GHS3DPlugin::GHS3DEnforcedMeshList_var enfMeshListHyp = h->GetEnforcedMeshes();
1993 int nbEnfMeshListHyp = enfMeshListHyp->length();
1995 // 1. Clear all enforced vertices in hypothesis
1996 // 2. Add new enforced vertex according to h_data
1997 if ( nbEnfMeshListHyp > 0)
1998 h->ClearEnforcedMeshes();
2000 TEnfMeshList::const_iterator itEnfMesh;
2002 _PTR(Study) aStudy = SMESH::getStudy();
2004 for(itEnfMesh = h_data.myEnforcedMeshes.begin() ; itEnfMesh != h_data.myEnforcedMeshes.end(); itEnfMesh++ ) {
2005 TEnfMesh* enfMesh = (*itEnfMesh);
2007 _PTR(SObject) aSObj = aStudy->FindObjectID(enfMesh->entry.c_str());
2008 SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
2010 SMESH::ElementType elementType = SMESH::NODE;
2011 switch(enfMesh->elementType) {
2013 elementType = SMESH::NODE;
2016 elementType = SMESH::EDGE;
2019 elementType = SMESH::FACE;
2025 ok = h->p_SetEnforcedMesh(theSource, elementType, enfMesh->name.c_str(), enfMesh->groupName.c_str());
2028 catch ( const SALOME::SALOME_Exception& ex )
2030 SalomeApp_Tools::QtCatchCorbaException( ex );
2036 bool GHS3DPluginGUI_HypothesisCreator::readParamsFromWidgets( GHS3DHypothesisData& h_data ) const
2038 h_data.myName = myName ? myName->text() : "";
2039 h_data.myOptimizationLevel = myOptimizationLevelCombo->currentIndex();
2040 if ( mySplitOverConstrainedCombo ) // optimizer
2042 h_data.myToCreateNewNodes = myCreateNewNodesCheck->isChecked();
2043 h_data.myOptimization = myOptimizationCombo->currentIndex();
2044 h_data.mySplitOverConstrained = mySplitOverConstrainedCombo->currentIndex();
2045 h_data.myPThreadsMode = myPThreadsModeCombo->currentIndex();
2046 h_data.myNumberOfThreads = myNumberOfThreadsSpin->value();
2047 h_data.mySmoothOffSlivers = mySmoothOffSliversCheck->isChecked();
2051 h_data.myMinSize = myMinSizeSpin->value();
2052 h_data.myMaxSize = myMaxSizeSpin->value();
2053 h_data.myUseMinSize = myMinSizeCheck->isChecked();
2054 h_data.myUseMaxSize = myMaxSizeCheck->isChecked();
2055 h_data.myGradation = myGradationSpin->value();
2056 h_data.myUseGradation = myGradationCheck->isChecked();
2057 h_data.myUseProximity = myUseProximityGroup->isChecked();
2058 h_data.myNbProximityLayers = myNbProximityLayers->value();
2059 h_data.myToMeshHoles = myToMeshHolesCheck->isChecked();
2060 h_data.myToMakeGroupsOfDomains = myToMakeGroupsOfDomains->isChecked();
2061 h_data.myAlgorithm = myRadioBottomGroup->checkedId();
2062 h_data.myUseNumOfThreads = myNumOfThreadsCheck->isChecked();
2063 h_data.myNumOfThreads = myNumOfThreadsSpin->value();
2064 h_data.myPthreadMode = myPthreadMode->currentIndex();
2065 h_data.myParallelMode = myParallelMode->currentIndex();
2067 h_data.myMaximumMemory = float( myAdvWidget->maxMemoryCheck->isChecked() ? myAdvWidget->maxMemorySpin->value() : -1 );
2068 h_data.myInitialMemory = float( myAdvWidget->initialMemoryCheck->isChecked() ? myAdvWidget->initialMemorySpin->value() : -1 );
2069 h_data.myKeepFiles = myAdvWidget->keepWorkingFilesCheck->isChecked();
2070 h_data.myWorkingDir = myAdvWidget->workingDirectoryLineEdit->text().trimmed();
2071 h_data.myVerboseLevel = short( myAdvWidget->verboseLevelSpin->value() );
2072 h_data.myLogInStandardOutput = !myAdvWidget->logInFileCheck->isChecked();
2073 h_data.myRemoveLogOnSuccess = myAdvWidget->removeLogOnSuccessCheck->isChecked();
2075 // Enforced vertices
2076 h_data.myEnforcedVertices.clear();
2077 QVariant valueX, valueY, valueZ;
2078 for (int row=0 ; row<myEnforcedTableWidget->rowCount() ; row++)
2080 TEnfVertex *myVertex = new TEnfVertex();
2081 myVertex->name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString();
2082 myVertex->geomEntry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString();
2083 myVertex->groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
2084 valueX = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data(Qt::EditRole);
2085 valueY = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data(Qt::EditRole);
2086 valueZ = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data(Qt::EditRole);
2087 if (!valueX.isNull() && !valueY.isNull() && !valueZ.isNull()) {
2088 myVertex->coords.push_back(valueX.toDouble());
2089 myVertex->coords.push_back(valueY.toDouble());
2090 myVertex->coords.push_back(valueZ.toDouble());
2092 myVertex->size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data(Qt::EditRole).toDouble();
2093 myVertex->isCompound = myEnforcedTableWidget->item(row,ENF_VER_COMPOUND_COLUMN)->data(Qt::CheckStateRole).toBool();
2094 h_data.myEnforcedVertices.insert(myVertex);
2098 h_data.myEnforcedMeshes.clear();
2100 for (int row=0 ; row<myEnforcedMeshTableWidget->rowCount() ; row++)
2102 TEnfMesh *myEnfMesh = new TEnfMesh();
2103 myEnfMesh->name = myEnforcedMeshTableWidget->item(row,ENF_MESH_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString();
2104 myEnfMesh->entry = myEnforcedMeshTableWidget->item(row,ENF_MESH_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString();
2105 myEnfMesh->groupName = myEnforcedMeshTableWidget->item(row,ENF_MESH_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
2106 QComboBox* combo = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row,ENF_MESH_CONSTRAINT_COLUMN));
2107 myEnfMesh->elementType = combo->currentIndex();
2108 h_data.myEnforcedMeshes.insert(myEnfMesh);
2114 QString GHS3DPluginGUI_HypothesisCreator::caption() const
2116 return tr( "GHS3D_TITLE" );
2119 QPixmap GHS3DPluginGUI_HypothesisCreator::icon() const
2121 return SUIT_Session::session()->resourceMgr()->loadPixmap( "GHS3DPlugin", tr( "ICON_DLG_GHS3D_PARAMETERS" ) );
2124 QString GHS3DPluginGUI_HypothesisCreator::type() const
2126 return tr( isOptimization() ? "GHS3D_OPTIMIZATIOL_HYPOTHESIS" : "GHS3D_HYPOTHESIS" );
2129 QString GHS3DPluginGUI_HypothesisCreator::helpPage() const
2131 return isOptimization() ? "optimization_page.html" : "ghs3d_hypo_page.html";
2134 void GHS3DPluginGUI_HypothesisCreator::onAddOption()
2136 myAdvWidget->AddOption( NULL, true );