1 // Copyright (C) 2004-2022 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>
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),
307 myNumOfThreadsCheck(0),
312 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::onRadioButtomSelect()
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 );
385 else if ( myRadioBottomGroup->checkedId() == GHS3DPlugin_Hypothesis::MGTetraHPC )
387 // Disable selection of stadart+
388 item->setEnabled(false);
389 // Set to false memory checks and disable checkbox
390 myAdvWidget->maxMemoryCheck ->setChecked( false );
391 myAdvWidget->initialMemoryCheck ->setChecked( false );
392 myAdvWidget->maxMemoryCheck ->setEnabled( false );
393 myAdvWidget->initialMemoryCheck ->setEnabled( false );
394 myAdvWidget->EnableAdvancedOptions( false );
399 void GHS3DPluginGUI_HypothesisCreator::onNumOfThreadsCheck()
401 if ( myRadioBottomGroup->checkedId() == GHS3DPlugin_Hypothesis::MGTetra )
403 if ( myNumOfThreadsCheck->isChecked() )
404 myPthreadMode->setEnabled( true );
406 myPthreadMode->setEnabled( false );
408 myParallelMode->setEnabled( false );
410 else if ( myRadioBottomGroup->checkedId() == GHS3DPlugin_Hypothesis::MGTetraHPC )
412 if ( myNumOfThreadsCheck->isChecked() )
413 myParallelMode->setEnabled( true );
415 myParallelMode->setEnabled( false );
417 myPthreadMode->setEnabled( false );
425 QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame()
427 QFrame* fr = new QFrame( 0 );
428 QVBoxLayout* lay = new QVBoxLayout( fr );
430 lay->setSpacing( 0 );
433 QTabWidget* tab = new QTabWidget( fr );
434 tab->setTabShape( QTabWidget::Rounded );
435 tab->setTabPosition( QTabWidget::North );
436 lay->addWidget( tab );
439 myStdGroup = new QWidget();
440 QGridLayout* aStdLayout = new QGridLayout( myStdGroup );
441 aStdLayout->setSpacing( 6 );
442 aStdLayout->setMargin( 11 );
447 aStdLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), myStdGroup ), row, 0, 1, 1 );
448 myName = new QLineEdit( myStdGroup );
449 aStdLayout->addWidget( myName, row++, 1, 1, 1 );
451 if ( isOptimization() )
453 myToMeshHolesCheck = new QCheckBox( tr( "GHS3D_TO_MESH_HOLES" ), myStdGroup );
454 aStdLayout->addWidget( myToMeshHolesCheck, row, 0, 1, 1 );
455 myToMakeGroupsOfDomains = new QCheckBox( tr( "GHS3D_TO_MAKE_DOMAIN_GROUPS" ), myStdGroup );
456 aStdLayout->addWidget( myToMakeGroupsOfDomains, row++, 1, 1, 1 );
458 QLabel* optimizationLbl = new QLabel( tr( "GHS3D_OPTIMIZATION" ), myStdGroup );
459 aStdLayout->addWidget( optimizationLbl, row, 0, 1, 1 );
460 myOptimizationCombo = getModeCombo( myStdGroup, false );
461 aStdLayout->addWidget( myOptimizationCombo, row++, 1, 1, 1 );
463 QLabel* optimizatiolLevelLbl = new QLabel( tr( "GHS3D_OPTIMIZATIOL_LEVEL" ), myStdGroup );
464 aStdLayout->addWidget( optimizatiolLevelLbl, row, 0, 1, 1 );
465 myOptimizationLevelCombo = new QComboBox( myStdGroup );
466 aStdLayout->addWidget( myOptimizationLevelCombo, row++, 1, 1, 1 );
468 QLabel* splitOverconstrainedLbl = new QLabel( tr("GHS3D_SPLIT_OVERCONSTRAINED"), myStdGroup );
469 aStdLayout->addWidget( splitOverconstrainedLbl, row, 0, 1, 1 );
470 mySplitOverConstrainedCombo = getModeCombo( myStdGroup, false );
471 aStdLayout->addWidget( mySplitOverConstrainedCombo, row++, 1, 1, 1 );
473 QLabel* pthreadsModeLbl = new QLabel( tr( "GHS3D_PTHREADS_MODE" ), myStdGroup);
474 aStdLayout->addWidget( pthreadsModeLbl, row, 0, 1, 1 );
475 myPThreadsModeCombo = getModeCombo( myStdGroup, true );
476 aStdLayout->addWidget( myPThreadsModeCombo, row++, 1, 1, 1 );
478 QLabel* nbThreadsLbl = new QLabel( tr( "GHS3D_NB_THREADS" ), myStdGroup);
479 aStdLayout->addWidget( nbThreadsLbl, row, 0, 1, 1 );
480 myNumberOfThreadsSpin = new SalomeApp_IntSpinBox( 0, 1000, 1, myStdGroup );
481 aStdLayout->addWidget( myNumberOfThreadsSpin, row++, 1, 1, 1 );
483 mySmoothOffSliversCheck = new QCheckBox( tr( "GHS3D_SMOOTH_OFF_SLIVERS" ), myStdGroup );
484 aStdLayout->addWidget( mySmoothOffSliversCheck, row, 0, 1, 1 );
485 myCreateNewNodesCheck = new QCheckBox( tr( "TO_ADD_NODES" ), myStdGroup );
486 aStdLayout->addWidget( myCreateNewNodesCheck, row++, 1, 1, 1 );
490 // Algorithm selection
491 QGroupBox* radioBottomGroup = new QGroupBox( tr("GHS3D_ALGO_SELECTION"), myStdGroup );
492 myRadioBottomGroup = new QButtonGroup( radioBottomGroup );
494 QRadioButton * GM_MSH = new QRadioButton(tr("GHS3D_ALGO_MGTETRA"), radioBottomGroup );
495 QRadioButton * GM_MSH_HPC = new QRadioButton(tr("GHS3D_ALGO_MGTETRAHPC"), radioBottomGroup );
497 myRadioBottomGroup->addButton( GM_MSH, 1 );
498 myRadioBottomGroup->addButton( GM_MSH_HPC, 0 );
499 GM_MSH->setChecked( true );
501 QGridLayout* radioBottomLayout = new QGridLayout( radioBottomGroup );
502 radioBottomLayout->setSpacing( 4 );
503 radioBottomLayout->setMargin( 11 );
504 radioBottomLayout->addWidget( GM_MSH, 0, 0, 1, 1 );
505 radioBottomLayout->addWidget( GM_MSH_HPC, 0, 1, 1, 1 );
508 QGroupBox* mainGroup = new QGroupBox( tr("GHS3D_MAIN_PARAMS"), myStdGroup );
509 QLabel* optimizatiolLevelLbl = new QLabel( tr( "GHS3D_OPTIMIZATIOL_LEVEL" ), mainGroup );
510 QLabel* pthreadModeLbl = new QLabel( tr( "GHS3D_PTHREAD_MODE" ), mainGroup );
511 QLabel* parallelStrat = new QLabel( tr( "GHS3D_PARALLE_STRAT" ), mainGroup );
513 myOptimizationLevelCombo = new QComboBox( mainGroup );
514 myMinSizeCheck = new QCheckBox( tr("GHS3D_MIN_SIZE"), mainGroup );
515 myMaxSizeCheck = new QCheckBox( tr("GHS3D_MAX_SIZE"), mainGroup );
516 myNumOfThreadsCheck = new QCheckBox( tr("GHS3D_THREADS_SIZE"), mainGroup );
517 myPthreadMode = new QComboBox( mainGroup );
518 myParallelMode = new QComboBox( mainGroup );
520 myMinSizeSpin = new SMESHGUI_SpinBox( mainGroup );
521 myMaxSizeSpin = new SMESHGUI_SpinBox( mainGroup );
522 myNumOfThreadsSpin = new SalomeApp_IntSpinBox( 1, 128, 1, mainGroup );
524 myMinSizeCheck->setChecked( false );
525 myMaxSizeCheck->setChecked( false );
526 myNumOfThreadsCheck->setChecked( false );
528 myMinSizeSpin->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
529 myMaxSizeSpin->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
530 myNumOfThreadsSpin->setValue( 4 );
532 myMinSizeSpin ->setEnabled( false );
533 myMaxSizeSpin ->setEnabled( false );
534 myNumOfThreadsSpin->setEnabled(false);
535 myPthreadMode ->setEnabled( false );
536 myParallelMode->setEnabled( false );
538 // ACTIONS ON BUTTOMS
539 connect( myMinSizeCheck, SIGNAL( toggled(bool)), myMinSizeSpin, SLOT( setEnabled(bool)));
540 connect( myMaxSizeCheck, SIGNAL( toggled(bool)), myMaxSizeSpin, SLOT( setEnabled(bool)));
541 connect( myNumOfThreadsCheck, SIGNAL( toggled(bool)), myNumOfThreadsSpin, SLOT( setEnabled(bool)));
542 connect( myNumOfThreadsCheck, SIGNAL( toggled(bool)), this, SLOT( onNumOfThreadsCheck() ));
543 connect( myNumOfThreadsCheck, SIGNAL( toggled(bool)), this, SLOT( onNumOfThreadsCheck() ));
544 connect( GM_MSH, SIGNAL( toggled( bool )),this, SLOT( onRadioButtomSelect() ));
546 QGridLayout* mainLayout = new QGridLayout( mainGroup );
547 mainLayout->setSpacing( 12 );
548 mainLayout->setMargin( 11 );
549 mainLayout->addWidget( optimizatiolLevelLbl, 0, 0, 1, 1 );
550 mainLayout->addWidget( myOptimizationLevelCombo, 0, 1, 1, 1 );
551 mainLayout->addWidget( myMinSizeCheck, 1, 0, 1, 1 );
552 mainLayout->addWidget( myMinSizeSpin, 1, 1, 1, 1 );
553 mainLayout->addWidget( myMaxSizeCheck, 2, 0, 1, 1 );
554 mainLayout->addWidget( myMaxSizeSpin, 2, 1, 1, 1 );
555 mainLayout->addWidget( myNumOfThreadsCheck, 3, 0, 1, 1 );
556 mainLayout->addWidget( myNumOfThreadsSpin, 3, 1, 1, 1 );
557 mainLayout->addWidget( pthreadModeLbl, 4, 0, 1, 1 );
558 mainLayout->addWidget( myPthreadMode, 4, 1, 1, 1 );
559 mainLayout->addWidget( parallelStrat, 5, 0, 1, 1 );
560 mainLayout->addWidget( myParallelMode, 5, 1, 1, 1 );
564 QGroupBox* proxyGroup = new QGroupBox( tr("GHS3D_VOLUME_PROXIMITY"), myStdGroup );
565 myGradationCheck = new QCheckBox( tr("GHS3D_GRADATION"), proxyGroup );
566 myGradationSpin = new SMESHGUI_SpinBox( proxyGroup );
567 myGradationSpin->RangeStepAndValidator(1, COORD_MAX, 0.1, "length_precision");
568 myGradationSpin->setEnabled( false );
569 connect( myGradationCheck, SIGNAL( toggled(bool)), myGradationSpin, SLOT( setEnabled(bool)));
570 myUseProximityGroup = new QGroupBox( tr("GHS3D_USE_VOLUME_PROXIMITY"), proxyGroup );
571 myUseProximityGroup->setCheckable( true );
572 //myUseProximityGroup->setChecked( false );
573 QLabel* nbProximityLayersLabel = new QLabel( tr("GHS3D_NB_LAYERS"));
574 myNbProximityLayers = new SalomeApp_IntSpinBox( 2, 1e6, 1, proxyGroup );
576 QHBoxLayout* useProxyLayout = new QHBoxLayout( myUseProximityGroup );
577 useProxyLayout->addWidget( nbProximityLayersLabel );
578 useProxyLayout->addWidget( myNbProximityLayers );
580 QGridLayout* proxyLayout = new QGridLayout( proxyGroup );
581 proxyLayout->setSpacing( 6 );
582 proxyLayout->setMargin( 11 );
583 proxyLayout->addWidget( myGradationCheck, 0, 0, 1, 1 );
584 proxyLayout->addWidget( myGradationSpin, 0, 1, 1, 1 );
585 proxyLayout->addWidget( myUseProximityGroup, 1, 0, 1, 2 );
589 QGroupBox* otherGroup = new QGroupBox( tr("GHS3D_OTHER_PARAMETERS"), myStdGroup );
590 myToMeshHolesCheck = new QCheckBox( tr( "GHS3D_TO_MESH_HOLES" ), otherGroup );
591 myToMakeGroupsOfDomains = new QCheckBox( tr( "GHS3D_TO_MAKE_DOMAIN_GROUPS" ), otherGroup );
593 QGridLayout* otherLayout = new QGridLayout( otherGroup );
594 otherLayout->setSpacing( 6 );
595 otherLayout->setMargin( 11 );
596 otherLayout->addWidget( myToMeshHolesCheck, 0, 0 );
597 otherLayout->addWidget( myToMakeGroupsOfDomains, 1, 0 );
599 aStdLayout->addWidget( radioBottomGroup,row++, 0, 1, 2 );
600 aStdLayout->addWidget( mainGroup, row++, 0, 1, 2 );
601 aStdLayout->addWidget( proxyGroup, row++, 0, 1, 2 );
602 aStdLayout->addWidget( otherGroup, row++, 0, 1, 2 );
604 myPthreadMode->addItems( QStringList() << tr( "MODE_NONE" ) << tr( "MODE_AGGRESSIVE" ) << tr( "MODE_SAFE" ) );
605 myParallelMode->addItems( QStringList() << tr( "MODE_NONE" ) << tr( "MODE_REPRODUCIBLE_GIVEN_MAX_THREADS" ) << tr( "MODE_REPRODUCIBLE" ) << tr( "MODE_AGGRESSIVE" ) );
607 aStdLayout->setRowStretch( row, 10 );
609 myOptimizationLevelCombo->addItems( QStringList()
610 << tr( "LEVEL_NONE" ) << tr( "LEVEL_LIGHT" )
611 << tr( "LEVEL_MEDIUM" ) << tr( "LEVEL_STANDARDPLUS" )
612 << tr( "LEVEL_STRONG" ));
614 // advanced parameters
615 myAdvGroup = new QWidget();
616 QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup );
617 anAdvLayout->setSpacing( 6 );
618 anAdvLayout->setMargin( 11 );
619 myAdvWidget = new GHS3DPluginGUI_AdvWidget(myAdvGroup);
620 anAdvLayout->addWidget( myAdvWidget);
622 myAdvWidget->maxMemoryCheck->setText(tr( "MAX_MEMORY_SIZE" ));
623 myAdvWidget->initialMemoryCheck->setText(tr( "INIT_MEMORY_SIZE" ));
625 myAdvWidget->maxMemorySpin->stepBy(10);
626 myAdvWidget->maxMemorySpin->setValue( 128 );
628 myAdvWidget->initialMemorySpin->stepBy(10);
629 myAdvWidget->initialMemorySpin->setValue( 100 );
631 myAdvWidget->initialMemoryLabel ->setText (tr( "MEGABYTE" ));
632 myAdvWidget->maxMemoryLabel ->setText (tr( "MEGABYTE" ));
634 myAdvWidget->workingDirectoryLabel ->setText (tr( "WORKING_DIR" ));
635 myAdvWidget->workingDirectoryPushButton ->setText (tr( "SELECT_DIR" ));
636 myAdvWidget->keepWorkingFilesCheck ->setText (tr( "KEEP_WORKING_FILES" ));
637 myAdvWidget->verboseLevelLabel ->setText (tr( "VERBOSE_LEVEL" ));
638 myAdvWidget->removeLogOnSuccessCheck ->setText (tr( "REMOVE_LOG_ON_SUCCESS" ));
639 myAdvWidget->logInFileCheck ->setText (tr( "LOG_IN_FILE" ));
641 myAdvWidget->memoryGroupBox ->setTitle(tr( "MEMORY_GROUP_TITLE" ));
642 myAdvWidget->logGroupBox ->setTitle(tr( "LOG_GROUP_TITLE" ));
643 //myAdvWidget->advancedMeshingGroupBox ->setTitle(tr( "ADVANCED_MESHING_GROUP_TITLE" ));
645 // myAdvWidget->createNewNodesCheck ->setText (tr( "TO_ADD_NODES" ));
646 // myAdvWidget->removeInitialCentralPointCheck->setText (tr( "NO_INITIAL_CENTRAL_POINT" ));
647 // myAdvWidget->boundaryRecoveryCheck ->setText (tr( "RECOVERY_VERSION" ));
648 // myAdvWidget->FEMCorrectionCheck ->setText (tr( "FEM_CORRECTION" ));
649 // myAdvWidget->gradationLabel ->setText (tr( "GHS3D_GRADATION" ));
650 // myAdvWidget->gradationSpinBox->RangeStepAndValidator(0.0, 5.0, 0.05, "length_precision");
652 // if ( isOptimization() )
654 // myAdvWidget->createNewNodesCheck->hide();
655 // myAdvWidget->removeInitialCentralPointCheck->hide();
656 // myAdvWidget->boundaryRecoveryCheck->hide();
657 // myAdvWidget->FEMCorrectionCheck->hide();
658 // myAdvWidget->gradationLabel->hide();
659 // myAdvWidget->gradationSpinBox->hide();
662 // Enforced vertices parameters
663 myEnfGroup = new QWidget();
664 QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup);
666 myEnforcedTableWidget = new QTableWidget(myEnfGroup);
667 myEnforcedTableWidget->setMinimumWidth(300);
668 myEnforcedTableWidget->setRowCount( 0 );
669 myEnforcedTableWidget->setColumnCount( ENF_VER_NB_COLUMNS );
670 myEnforcedTableWidget->setSortingEnabled(true);
671 myEnforcedTableWidget->setHorizontalHeaderLabels
673 << tr( "GHS3D_ENF_NAME_COLUMN" ) << tr( "GHS3D_ENF_VER_X_COLUMN" )
674 << tr( "GHS3D_ENF_VER_Y_COLUMN" ) << tr( "GHS3D_ENF_VER_Z_COLUMN" )
675 << tr( "GHS3D_ENF_SIZE_COLUMN" ) << tr("GHS3D_ENF_ENTRY_COLUMN")
676 << tr("GHS3D_ENF_VER_COMPOUND_COLUMN") << tr( "GHS3D_ENF_GROUP_COLUMN" ));
677 myEnforcedTableWidget->verticalHeader()->hide();
678 myEnforcedTableWidget->horizontalHeader()->setStretchLastSection(true);
679 myEnforcedTableWidget->setAlternatingRowColors(true);
680 myEnforcedTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
681 myEnforcedTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
682 myEnforcedTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
684 myEnforcedTableWidget->resizeColumnsToContents();
685 myEnforcedTableWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
686 myEnforcedTableWidget->hideColumn(ENF_VER_COMPOUND_COLUMN);
688 myEnforcedTableWidget->setItemDelegate(new EnforcedVertexTableWidgetDelegate());
691 TColStd_MapOfInteger shapeTypes;
692 shapeTypes.Add( TopAbs_VERTEX );
693 shapeTypes.Add( TopAbs_COMPOUND );
695 SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes);
696 myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true);
697 myEnfVertexWdg->SetDefaultText(tr("GHS3D_ENF_SELECT_VERTEX"), "QLineEdit { color: grey }");
699 QLabel* myXCoordLabel = new QLabel( tr( "GHS3D_ENF_VER_X_LABEL" ), myEnfGroup );
700 myXCoord = new SMESHGUI_SpinBox(myEnfGroup);
701 myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
702 QLabel* myYCoordLabel = new QLabel( tr( "GHS3D_ENF_VER_Y_LABEL" ), myEnfGroup );
703 myYCoord = new SMESHGUI_SpinBox(myEnfGroup);
704 myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
705 QLabel* myZCoordLabel = new QLabel( tr( "GHS3D_ENF_VER_Z_LABEL" ), myEnfGroup );
706 myZCoord = new SMESHGUI_SpinBox(myEnfGroup);
707 myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
708 QLabel* mySizeLabel = new QLabel( tr( "GHS3D_ENF_SIZE_LABEL" ), myEnfGroup );
709 mySizeValue = new SMESHGUI_SpinBox(myEnfGroup);
710 mySizeValue->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
712 QLabel* myGroupNameLabel = new QLabel( tr( "GHS3D_ENF_GROUP_LABEL" ), myEnfGroup );
713 myGroupName = new QLineEdit(myEnfGroup);
715 addVertexButton = new QPushButton(tr("GHS3D_ENF_ADD"),myEnfGroup);
716 addVertexButton->setEnabled(false);
717 removeVertexButton = new QPushButton(tr("GHS3D_ENF_REMOVE"),myEnfGroup);
719 anEnfLayout->addWidget(myEnforcedTableWidget, ENF_VER_VERTEX, 0, ENF_VER_NB_LINES, 1);
721 QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup);
722 anEnfLayout2->addWidget(myEnfVertexWdg, ENF_VER_VERTEX, 0, 1, 2);
723 anEnfLayout2->addWidget(myXCoordLabel, ENF_VER_X_COORD, 0, 1, 1);
724 anEnfLayout2->addWidget(myXCoord, ENF_VER_X_COORD, 1, 1, 1);
725 anEnfLayout2->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 0, 1, 1);
726 anEnfLayout2->addWidget(myYCoord, ENF_VER_Y_COORD, 1, 1, 1);
727 anEnfLayout2->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 0, 1, 1);
728 anEnfLayout2->addWidget(myZCoord, ENF_VER_Z_COORD, 1, 1, 1);
729 anEnfLayout2->addWidget(mySizeLabel, ENF_VER_SIZE, 0, 1, 1);
730 anEnfLayout2->addWidget(mySizeValue, ENF_VER_SIZE, 1, 1, 1);
731 anEnfLayout2->addWidget(myGroupNameLabel, ENF_VER_GROUP, 0, 1, 1);
732 anEnfLayout2->addWidget(myGroupName, ENF_VER_GROUP, 1, 1, 1);
733 anEnfLayout2->addWidget(addVertexButton, ENF_VER_BTN, 0, 1, 1);
734 anEnfLayout2->addWidget(removeVertexButton, ENF_VER_BTN, 1, 1, 1);
735 anEnfLayout2->setRowStretch(ENF_VER_NB_LINES, 1);
737 anEnfLayout->addLayout(anEnfLayout2, ENF_VER_VERTEX, 1,ENF_VER_NB_LINES, 1);
738 anEnfLayout->setRowStretch(ENF_VER_VERTEX, 10);
741 // Enforced meshes parameters
742 myEnfMeshGroup = new QWidget();
743 QGridLayout* anEnfMeshLayout = new QGridLayout(myEnfMeshGroup);
745 myEnforcedMeshTableWidget = new QTableWidget(myEnfGroup);
746 myEnforcedMeshTableWidget->setRowCount( 0 );
747 myEnforcedMeshTableWidget->setColumnCount( ENF_MESH_NB_COLUMNS );
748 myEnforcedMeshTableWidget->setSortingEnabled(true);
749 myEnforcedMeshTableWidget->verticalHeader()->hide();
750 QStringList enforcedMeshHeaders;
751 enforcedMeshHeaders << tr( "GHS3D_ENF_NAME_COLUMN" )
752 << tr( "GHS3D_ENF_ENTRY_COLUMN" )
753 << tr( "GHS3D_ENF_MESH_CONSTRAINT_COLUMN" )
754 << tr( "GHS3D_ENF_GROUP_COLUMN" );
755 myEnforcedMeshTableWidget->setHorizontalHeaderLabels(enforcedMeshHeaders);
756 myEnforcedMeshTableWidget->horizontalHeader()->setStretchLastSection(true);
757 myEnforcedMeshTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
759 myEnforcedMeshTableWidget->setAlternatingRowColors(true);
760 myEnforcedMeshTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
761 myEnforcedMeshTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
762 myEnforcedMeshTableWidget->resizeColumnsToContents();
763 myEnforcedMeshTableWidget->hideColumn(ENF_MESH_ENTRY_COLUMN);
765 myEnforcedMeshTableWidget->setItemDelegate(new EnforcedMeshTableWidgetDelegate());
767 myEnfMeshWdg = new StdMeshersGUI_ObjectReferenceParamWdg( SMESH::IDSOURCE, myEnfMeshGroup, /*multiSel=*/true);
768 myEnfMeshWdg->SetDefaultText(tr("GHS3D_ENF_SELECT_MESH"), "QLineEdit { color: grey }");
770 myEnfMeshWdg->AvoidSimultaneousSelection(myEnfVertexWdg);
772 QLabel* myMeshConstraintLabel = new QLabel( tr( "GHS3D_ENF_MESH_CONSTRAINT_LABEL" ), myEnfMeshGroup );
773 myEnfMeshConstraint = new QComboBox(myEnfMeshGroup);
774 myEnfMeshConstraint->insertItems(0,myEnfMeshConstraintLabels);
775 myEnfMeshConstraint->setEditable(false);
776 myEnfMeshConstraint->setCurrentIndex(0);
778 QLabel* myMeshGroupNameLabel = new QLabel( tr( "GHS3D_ENF_GROUP_LABEL" ), myEnfMeshGroup );
779 myMeshGroupName = new QLineEdit(myEnfMeshGroup);
781 addEnfMeshButton = new QPushButton(tr("GHS3D_ENF_ADD"),myEnfMeshGroup);
782 removeEnfMeshButton = new QPushButton(tr("GHS3D_ENF_REMOVE"),myEnfMeshGroup);
784 anEnfMeshLayout->addWidget(myEnforcedMeshTableWidget, ENF_MESH_MESH, 0, ENF_MESH_NB_LINES , 1);
786 QGridLayout* anEnfMeshLayout2 = new QGridLayout(myEnfMeshGroup);
787 anEnfMeshLayout2->addWidget(myEnfMeshWdg, ENF_MESH_MESH, 0, 1, 2);
788 anEnfMeshLayout2->addWidget(myMeshConstraintLabel, ENF_MESH_CONSTRAINT, 0, 1, 1);
789 anEnfMeshLayout2->addWidget(myEnfMeshConstraint, ENF_MESH_CONSTRAINT, 1, 1, 1);
790 anEnfMeshLayout2->addWidget(myMeshGroupNameLabel, ENF_MESH_GROUP, 0, 1, 1);
791 anEnfMeshLayout2->addWidget(myMeshGroupName, ENF_MESH_GROUP, 1, 1, 1);
792 anEnfMeshLayout2->addWidget(addEnfMeshButton, ENF_MESH_BTN, 0, 1, 1);
793 anEnfMeshLayout2->addWidget(removeEnfMeshButton, ENF_MESH_BTN, 1, 1, 1);
794 anEnfMeshLayout2->setRowStretch(ENF_MESH_NB_LINES, 1);
796 anEnfMeshLayout->addLayout(anEnfMeshLayout2, ENF_MESH_MESH, 1, ENF_MESH_NB_LINES, 1);
797 anEnfMeshLayout->setRowStretch(ENF_MESH_MESH, 10);
800 tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
801 tab->insertTab( ADV_TAB, myAdvGroup, tr( "GHS3D_ADV_ARGS" ) );
802 if ( !isOptimization() )
804 tab->insertTab( ENF_VER_TAB, myEnfGroup, tr( "GHS3D_ENFORCED_VERTICES" ) );
805 tab->insertTab( ENF_MESH_TAB, myEnfMeshGroup, tr( "GHS3D_ENFORCED_MESHES" ) );
807 tab->setCurrentIndex( STD_TAB );
809 connect( myAdvWidget->maxMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
810 connect( myAdvWidget->initialMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
811 connect( myAdvWidget->logInFileCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
812 connect( myAdvWidget->keepWorkingFilesCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
813 connect( myAdvWidget->workingDirectoryPushButton, SIGNAL( clicked() ), this, SLOT( onDirBtnClicked() ) );
814 connect( myAdvWidget->addBtn, SIGNAL( clicked() ), this, SLOT( onAddOption() ) );
816 connect( myEnforcedTableWidget, SIGNAL( itemClicked(QTableWidgetItem *)), this, SLOT( synchronizeCoords() ) );
817 connect( myEnforcedTableWidget, SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
818 connect( myEnforcedTableWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
819 connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertex() ) );
820 connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
821 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
822 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
823 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
824 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
825 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
826 connect( mySizeValue, SIGNAL( textChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) );
827 connect( myXCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
828 connect( myYCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
829 connect( myZCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
830 connect( mySizeValue, SIGNAL( valueChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) );
831 connect( this, SIGNAL( vertexDefined(bool) ), addVertexButton, SLOT( setEnabled(bool) ) );
833 connect( addEnfMeshButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedMesh() ) );
834 connect( removeEnfMeshButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedMesh() ) );
840 * This method checks if an enforced vertex is defined;
842 void GHS3DPluginGUI_HypothesisCreator::clearEnfVertexSelection()
844 if (myEnfVertexWdg->NbObjects() != 0) {
845 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
846 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
847 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
848 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
849 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
851 GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
852 that->checkVertexIsDefined();
856 * This method checks if an enforced vertex is defined;
858 void GHS3DPluginGUI_HypothesisCreator::checkVertexIsDefined()
860 bool enfVertexIsDefined = false;
861 enfVertexIsDefined = (!mySizeValue->GetString().isEmpty() &&
862 (!myEnfVertexWdg->NbObjects() == 0 ||
863 (myEnfVertexWdg->NbObjects() == 0 && !myXCoord->GetString().isEmpty()
864 && !myYCoord->GetString().isEmpty()
865 && !myZCoord->GetString().isEmpty())));
866 emit vertexDefined(enfVertexIsDefined);
870 * This method checks if an enforced mesh is defined;
872 void GHS3DPluginGUI_HypothesisCreator::checkEnfMeshIsDefined()
874 emit enfMeshDefined( myEnfVertexWdg->NbObjects() != 0);
878 * This method resets the content of the X, Y, Z, size and GroupName widgets;
880 void GHS3DPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
882 myXCoord->setCleared(true);
883 myYCoord->setCleared(true);
884 myZCoord->setCleared(true);
885 myXCoord->setText("");
886 myYCoord->setText("");
887 myZCoord->setText("");
888 addVertexButton->setEnabled(false);
891 /** GHS3DPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item)
892 This method updates the tooltip of a modified item. The QLineEdit widgets content
893 is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
895 void GHS3DPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTableWidgetItem* item)
897 int row = myEnforcedTableWidget->row(item);
899 QVariant vertexName = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole);
900 QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole);
901 QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole);
902 QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole);
903 QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole);
904 QVariant entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
905 QString groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole).toString();
907 clearEnforcedVertexWidgets();
909 if ( !x.isNull() || !entry.isNull()) {
910 QString toolTip = vertexName.toString();
911 toolTip += QString("(");
912 if (entry.isNull() || (!entry.isNull() && entry.toString() == "")) {
913 toolTip += x.toString();
914 toolTip += QString(", ") + y.toString();
915 toolTip += QString(", ") + z.toString();
918 toolTip += entry.toString();
919 toolTip += QString(")");
922 toolTip += QString("=") + size.toString();
924 if (!groupName.isEmpty())
925 toolTip += QString(" [") + groupName + QString("]");
927 for (int col=0;col<ENF_VER_NB_COLUMNS;col++)
928 myEnforcedTableWidget->item(row,col)->setToolTip(toolTip);
931 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
932 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
933 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
934 myXCoord->SetValue(x.toDouble());
935 myYCoord->SetValue(y.toDouble());
936 myZCoord->SetValue(z.toDouble());
937 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
938 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
939 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
942 mySizeValue->SetValue(size.toDouble());
944 if (!groupName.isEmpty())
945 myGroupName->setText(groupName);
949 void GHS3DPluginGUI_HypothesisCreator::onSelectEnforcedVertex()
951 size_t nbSelEnfVertex = myEnfVertexWdg->NbObjects();
952 clearEnforcedVertexWidgets();
953 if (nbSelEnfVertex == 1)
955 if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() )
958 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
959 if (myEnfVertex == GEOM::GEOM_Object::_nil())
961 if (myEnfVertex->GetShapeType() == GEOM::VERTEX)
963 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( );
964 if (CORBA::is_nil(measureOp))
968 measureOp->PointCoordinates (myEnfVertex, x, y, z);
969 if ( measureOp->IsDone() )
971 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
972 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
973 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
974 myXCoord->SetValue(x);
975 myYCoord->SetValue(y);
976 myZCoord->SetValue(z);
977 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
978 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
979 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
985 /** GHS3DPluginGUI_HypothesisCreator::synchronizeCoords()
986 This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
987 of the enforced vertex clicked in the tree widget.
989 void GHS3DPluginGUI_HypothesisCreator::synchronizeCoords()
991 clearEnforcedVertexWidgets();
992 QList<QTableWidgetItem *> items = myEnforcedTableWidget->selectedItems();
993 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
994 if (! items.isEmpty()) {
995 QTableWidgetItem *item;
998 if (items.size() == 1) {
1000 row = myEnforcedTableWidget->row(item);
1001 QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole);
1002 QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole);
1003 QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole);
1004 QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole);
1005 entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
1006 if (!entry.isNull()) {
1007 SMESH::string_array_var objIds = new SMESH::string_array;
1009 objIds[0] = entry.toString().toStdString().c_str();
1010 myEnfVertexWdg->SetObjects(objIds);
1013 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1015 QVariant group = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole);
1016 if (!x.isNull()/* && entry.isNull()*/) {
1017 // disconnect( myXCoord, SIGNAL( textChanged(const QString &)), this, SLOT( onSelectEnforcedVertex() ) );
1018 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
1019 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
1020 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
1021 myXCoord->SetValue(x.toDouble());
1022 myYCoord->SetValue(y.toDouble());
1023 myZCoord->SetValue(z.toDouble());
1024 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
1025 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
1026 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
1029 mySizeValue->SetValue(size.toDouble());
1031 if (!group.isNull() && (!x.isNull() || !entry.isNull()))
1032 myGroupName->setText(group.toString());
1035 QList<QString> entryList;
1036 for (int i = 0; i < items.size(); ++i) {
1038 row = myEnforcedTableWidget->row(item);
1039 entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
1040 if (!entry.isNull())
1041 entryList << entry.toString();
1043 if (entryList.size() > 0) {
1044 SMESH::string_array_var objIds = new SMESH::string_array;
1045 objIds->length(entryList.size());
1046 for (int i = 0; i < entryList.size() ; i++)
1047 objIds[i] = entryList.at(i).toStdString().c_str();
1048 myEnfVertexWdg->SetObjects(objIds);
1051 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1056 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1058 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
1059 GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
1060 that->checkVertexIsDefined();
1063 /** GHS3DPluginGUI_HypothesisCreator::addEnforcedMesh( meshName, geomEntry, elemType, size, groupName)
1064 This method adds in the tree widget an enforced mesh from mesh, submesh or group with optionally size and and groupName.
1066 void GHS3DPluginGUI_HypothesisCreator::addEnforcedMesh(std::string name,
1069 std::string groupName)
1071 bool okToCreate = true;
1072 QString itemEntry = "";
1073 int itemElementType = 0;
1074 int rowCount = myEnforcedMeshTableWidget->rowCount();
1075 bool allColumns = true;
1076 for (int row = 0;row<rowCount;row++) {
1077 for (int col = 0 ; col < ENF_MESH_NB_COLUMNS ; col++) {
1078 if (col == ENF_MESH_CONSTRAINT_COLUMN){
1079 if (qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row, col)) == 0) {
1084 else if (myEnforcedMeshTableWidget->item(row, col) == 0) {
1088 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1089 QComboBox* itemComboBox = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row, col));
1090 itemElementType = itemComboBox->currentIndex();
1092 else if (col == ENF_MESH_ENTRY_COLUMN)
1093 itemEntry = myEnforcedMeshTableWidget->item(row, col)->data(Qt::EditRole).toString();
1099 if (itemEntry == QString(entry.c_str()) && itemElementType == elementType) {
1109 myEnforcedMeshTableWidget->setRowCount(rowCount+1);
1110 myEnforcedMeshTableWidget->setSortingEnabled(false);
1112 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++) {
1113 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1114 QComboBox* comboBox = new QComboBox();
1115 QPalette pal = comboBox->palette();
1116 pal.setColor(QPalette::Button, Qt::white);
1117 comboBox->setPalette(pal);
1118 comboBox->insertItems(0,myEnfMeshConstraintLabels);
1119 comboBox->setEditable(false);
1120 comboBox->setCurrentIndex(elementType);
1121 myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox);
1124 QTableWidgetItem* item = new QTableWidgetItem();
1125 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1127 case ENF_MESH_NAME_COLUMN:
1128 item->setData( 0, name.c_str() );
1129 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1130 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1132 case ENF_MESH_ENTRY_COLUMN:
1133 item->setData( 0, entry.c_str() );
1134 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1135 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1137 case ENF_MESH_GROUP_COLUMN:
1138 item->setData( 0, groupName.c_str() );
1139 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1146 myEnforcedMeshTableWidget->setSortingEnabled(true);
1149 /** GHS3DPluginGUI_HypothesisCreator::addEnforcedVertex( x, y, z, size, vertexName, geomEntry, groupName)
1150 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.
1152 void GHS3DPluginGUI_HypothesisCreator::addEnforcedVertex(double x, double y, double z, double size, std::string vertexName, std::string geomEntry, std::string groupName, bool isCompound)
1154 myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1155 bool okToCreate = true;
1156 double itemX=0.,itemY=0.,itemZ=0.,itemSize = 0;
1157 QString itemEntry, itemGroupName = QString("");
1158 // bool itemIsCompound;
1159 int rowCount = myEnforcedTableWidget->rowCount();
1162 for (int row = 0;row<rowCount;row++) {
1164 for (int col = 0 ; col < ENF_VER_NB_COLUMNS ; col++) {
1165 if (myEnforcedTableWidget->item(row, col) == 0) {
1170 data = myEnforcedTableWidget->item(row, col)->data(Qt::EditRole);
1171 if (!data.isNull()) {
1173 case ENF_VER_GROUP_COLUMN:
1174 itemGroupName = data.toString();
1176 case ENF_VER_ENTRY_COLUMN:
1177 itemEntry = data.toString();
1179 case ENF_VER_X_COLUMN:
1180 itemX = data.toDouble();
1182 case ENF_VER_Y_COLUMN:
1183 itemY = data.toDouble();
1185 case ENF_VER_Z_COLUMN:
1186 itemZ = data.toDouble();
1188 case ENF_VER_SIZE_COLUMN:
1189 itemSize = data.toDouble();
1201 if (( !isCompound && ((itemX == x) && (itemY == y) && (itemZ == z))) ||
1202 ( !itemEntry.isEmpty() && ( itemEntry == geomEntry.c_str() )))
1205 if (itemSize != size) {
1206 myEnforcedTableWidget->item(row, ENF_VER_SIZE_COLUMN)->setData( Qt::EditRole, QVariant(size));
1208 // update group name
1209 if (itemGroupName.toStdString() != groupName) {
1210 myEnforcedTableWidget->item(row, ENF_VER_GROUP_COLUMN)->setData( Qt::EditRole, QVariant(groupName.c_str()));
1217 if (geomEntry.empty()) {
1226 QString myVertexName;
1227 while(indexRef != vertexIndex) {
1228 indexRef = vertexIndex;
1229 if (vertexName.empty())
1230 myVertexName = QString("Vertex #%1").arg(vertexIndex);
1232 myVertexName = QString(vertexName.c_str());
1234 for (int row = 0;row<rowCount;row++) {
1235 QString name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString();
1236 if (myVertexName == name) {
1243 myEnforcedTableWidget->setRowCount(rowCount+1);
1244 myEnforcedTableWidget->setSortingEnabled(false);
1245 for (int col=0;col<ENF_VER_NB_COLUMNS;col++) {
1246 QTableWidgetItem* item = new QTableWidgetItem();
1247 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1249 case ENF_VER_NAME_COLUMN:
1250 item->setData( Qt::EditRole, myVertexName );
1251 if (!geomEntry.empty()) {
1253 item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1255 item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1258 case ENF_VER_X_COLUMN:
1260 item->setData( 0, QVariant(x) );
1262 case ENF_VER_Y_COLUMN:
1264 item->setData( 0, QVariant(y) );
1266 case ENF_VER_Z_COLUMN:
1268 item->setData( 0, QVariant(z) );
1270 case ENF_VER_SIZE_COLUMN:
1271 item->setData( 0, QVariant(size) );
1273 case ENF_VER_ENTRY_COLUMN:
1274 if (!geomEntry.empty())
1275 item->setData( 0, QString(geomEntry.c_str()) );
1277 case ENF_VER_COMPOUND_COLUMN:
1278 item->setData( Qt::CheckStateRole, isCompound );
1279 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
1281 case ENF_VER_GROUP_COLUMN:
1282 if (!groupName.empty())
1283 item->setData( 0, QString(groupName.c_str()) );
1289 myEnforcedTableWidget->setItem(rowCount,col,item);
1292 connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1294 myEnforcedTableWidget->setSortingEnabled(true);
1295 // myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1296 updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1299 /** GHS3DPluginGUI_HypothesisCreator::onAddEnforcedMesh()
1300 This method is called when a item is added into the enforced meshes tree widget
1302 void GHS3DPluginGUI_HypothesisCreator::onAddEnforcedMesh()
1304 GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
1306 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1307 myEnfMeshWdg->deactivateSelection();
1309 for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column)
1310 myEnforcedMeshTableWidget->resizeColumnToContents(column);
1313 size_t selEnfMeshes = myEnfMeshWdg->NbObjects();
1314 if (selEnfMeshes == 0)
1317 std::string groupName = myMeshGroupName->text().simplified().toStdString();
1319 int elementType = myEnfMeshConstraint->currentIndex();
1322 _PTR(Study) aStudy = SMESH::getStudy();
1323 _PTR(SObject) aSObj;
1324 QString meshEntry = myEnfMeshWdg->GetValue();
1326 if (selEnfMeshes == 1)
1328 aSObj = aStudy->FindObjectID(meshEntry.toStdString().c_str());
1329 CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj);
1330 if (!CORBA::is_nil(anObj)) {
1331 addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
1336 QStringList meshEntries = meshEntry.split(" ", QString::SkipEmptyParts);
1337 QStringListIterator meshEntriesIt (meshEntries);
1338 while (meshEntriesIt.hasNext()) {
1339 aSObj = aStudy->FindObjectID(meshEntriesIt.next().toStdString().c_str());
1340 CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj);
1341 if (!CORBA::is_nil(anObj)) {
1342 addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
1347 myEnfVertexWdg->SetObject(SMESH::SMESH_IDSource::_nil());
1349 for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column)
1350 myEnforcedMeshTableWidget->resizeColumnToContents(column);
1354 /** GHS3DPluginGUI_HypothesisCreator::onAddEnforcedVertex()
1355 This method is called when a item is added into the enforced vertices tree widget
1357 void GHS3DPluginGUI_HypothesisCreator::onAddEnforcedVertex()
1359 GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
1361 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1362 myEnfVertexWdg->deactivateSelection();
1364 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1365 myEnforcedTableWidget->resizeColumnToContents(column);
1368 size_t selEnfVertex = myEnfVertexWdg->NbObjects();
1369 bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty());
1370 if ((selEnfVertex == 0) && coordsEmpty)
1373 std::string groupName = myGroupName->text().simplified().toStdString();
1375 double size = mySizeValue->GetValue();
1377 if (selEnfVertex <= 1)
1379 double x = 0, y = 0, z=0;
1380 if (myXCoord->GetString() != "") {
1381 x = myXCoord->GetValue();
1382 y = myYCoord->GetValue();
1383 z = myZCoord->GetValue();
1385 if (selEnfVertex == 1) {
1386 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >();
1387 std::string entry = "", name = "";
1388 bool isCompound = false;
1389 if ( !myEnfVertex->_is_nil() ) {
1390 entry = SMESH::toStdStr( myEnfVertex->GetStudyEntry() );
1391 name = SMESH::toStdStr( myEnfVertex->GetName() );
1392 isCompound = ( myEnfVertex->GetShapeType() == GEOM::COMPOUND );
1394 addEnforcedVertex(x, y, z, size, name, entry, groupName, isCompound);
1397 addEnforcedVertex(x, y, z, size, "", "", groupName);
1402 if ( CORBA::is_nil(getGeomEngine()))
1405 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( );
1406 if (CORBA::is_nil(measureOp))
1409 CORBA::Double x = 0, y = 0,z = 0;
1410 for ( size_t j = 0 ; j < selEnfVertex ; j++)
1412 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j);
1413 if (myEnfVertex == GEOM::GEOM_Object::_nil())
1415 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1416 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1417 if ( measureOp->IsDone() )
1418 addEnforcedVertex(x, y, z, size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1419 } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) {
1420 addEnforcedVertex(0., 0., 0., size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName, true);
1425 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1427 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1428 myEnforcedTableWidget->resizeColumnToContents(column);
1431 /** GHS3DPluginGUI_HypothesisCreator::onRemoveEnforcedMesh()
1432 This method is called when a item is removed from the enforced meshes tree widget
1434 void GHS3DPluginGUI_HypothesisCreator::onRemoveEnforcedMesh()
1436 QList<int> selectedRows;
1437 QList<QTableWidgetItem *> selectedItems = myEnforcedMeshTableWidget->selectedItems();
1438 QTableWidgetItem* item;
1440 foreach( item, selectedItems ) {
1442 if (!selectedRows.contains( row ) )
1443 selectedRows.append(row);
1446 qSort( selectedRows );
1447 QListIterator<int> it( selectedRows );
1449 while ( it.hasPrevious() ) {
1450 row = it.previous();
1451 myEnforcedMeshTableWidget->removeRow(row );
1454 myEnforcedMeshTableWidget->selectionModel()->clearSelection();
1457 /** GHS3DPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1458 This method is called when a item is removed from the enforced vertices tree widget
1460 void GHS3DPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1462 QList<int> selectedRows;
1463 QList<QTableWidgetItem *> selectedItems = myEnforcedTableWidget->selectedItems();
1464 QTableWidgetItem* item;
1466 foreach( item, selectedItems ) {
1468 if (!selectedRows.contains( row ) )
1469 selectedRows.append(row);
1472 qSort( selectedRows );
1473 QListIterator<int> it( selectedRows );
1475 while ( it.hasPrevious() ) {
1476 row = it.previous();
1477 myEnforcedTableWidget->removeRow(row );
1480 myEnforcedTableWidget->selectionModel()->clearSelection();
1483 void GHS3DPluginGUI_HypothesisCreator::onToMeshHoles(bool /*isOn*/)
1485 // myToMakeGroupsOfDomains->setEnabled( isOn );
1487 // myToMakeGroupsOfDomains->setChecked( false );
1490 void GHS3DPluginGUI_HypothesisCreator::onDirBtnClicked()
1492 QString dir = SUIT_FileDlg::getExistingDirectory( dlg(), myAdvWidget->workingDirectoryLineEdit->text(), QString() );
1493 if ( !dir.isEmpty() )
1494 myAdvWidget->workingDirectoryLineEdit->setText( dir );
1497 void GHS3DPluginGUI_HypothesisCreator::updateWidgets()
1499 //myToMakeGroupsOfDomains->setEnabled( myToMeshHolesCheck->isChecked() );
1500 myAdvWidget->maxMemorySpin->setEnabled( myAdvWidget->maxMemoryCheck->isChecked() );
1501 //myAdvWidget->initialMemoryCheck->setEnabled( !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1502 myAdvWidget->initialMemorySpin->setEnabled( myAdvWidget->initialMemoryCheck->isChecked() /*&& !myAdvWidget->boundaryRecoveryCheck->isChecked()*/ );
1503 //myOptimizationLevelCombo->setEnabled( !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1504 if ( sender() == myAdvWidget->logInFileCheck ||
1505 sender() == myAdvWidget->keepWorkingFilesCheck )
1507 bool logFileRemovable = ( myAdvWidget->logInFileCheck->isChecked() &&
1508 !myAdvWidget->keepWorkingFilesCheck->isChecked() );
1509 myAdvWidget->removeLogOnSuccessCheck->setEnabled( logFileRemovable );
1513 bool GHS3DPluginGUI_HypothesisCreator::checkParams(QString& msg) const
1515 if ( !QFileInfo( myAdvWidget->workingDirectoryLineEdit->text().trimmed() ).isWritable() ) {
1516 SUIT_MessageBox::warning( dlg(),
1517 tr( "SMESH_WRN_WARNING" ),
1518 tr( "GHS3D_PERMISSION_DENIED" ) );
1522 GHS3DPlugin::GHS3DPlugin_Hypothesis_var h =
1523 GHS3DPlugin::GHS3DPlugin_Hypothesis::_narrow( hypothesis() );
1525 myAdvWidget->myOptionTable->setFocus();
1526 QApplication::instance()->processEvents();
1528 QString name, value;
1529 bool isDefault, ok = true;
1530 int iRow = 0, nbRows = myAdvWidget->myOptionTable->topLevelItemCount();
1531 for ( ; iRow < nbRows; ++iRow )
1533 QTreeWidgetItem* row = myAdvWidget->myOptionTable->topLevelItem( iRow );
1534 myAdvWidget->GetOptionAndValue( row, name, value, isDefault );
1536 if ( name.simplified().isEmpty() )
1537 continue; // invalid custom option
1539 if ( isDefault ) // not selected option
1543 h->SetOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
1545 catch ( const SALOME::SALOME_Exception& ex )
1547 msg = ex.details.text.in();
1555 h->SetOptionValues( myOptions ); // restore values
1561 void GHS3DPluginGUI_HypothesisCreator::retrieveParams() const
1563 GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
1564 GHS3DHypothesisData data;
1565 readParamsFromHypo( data );
1569 myName->setText( data.myName );
1571 int width = QFontMetrics( myName->font() ).width( data.myName );
1572 QGridLayout* aStdLayout = (QGridLayout*) myStdGroup->layout();
1573 aStdLayout->setColumnMinimumWidth( 1, width + 10 );
1575 myToMeshHolesCheck ->setChecked ( data.myToMeshHoles );
1576 myToMakeGroupsOfDomains ->setChecked ( data.myToMakeGroupsOfDomains );
1578 if ( data.myAlgorithm == GHS3DPlugin_Hypothesis::MGTetraHPC && data.myOptimizationLevel == GHS3DPlugin_Hypothesis::StandardPlus /*not implemented by MGTetraHPC*/ )
1579 myOptimizationLevelCombo ->setCurrentIndex( GHS3DPlugin_Hypothesis::None );
1581 myOptimizationLevelCombo ->setCurrentIndex( data.myOptimizationLevel );
1583 if ( myOptimizationCombo ) // optimizer
1585 myOptimizationCombo ->setCurrentIndex( data.myOptimization );
1586 mySplitOverConstrainedCombo ->setCurrentIndex( data.mySplitOverConstrained );
1587 myPThreadsModeCombo ->setCurrentIndex( data.myPThreadsMode );
1588 myNumberOfThreadsSpin ->setValue ( data.myNumberOfThreads );
1589 mySmoothOffSliversCheck ->setChecked ( data.mySmoothOffSlivers );
1590 myCreateNewNodesCheck ->setChecked ( data.myToCreateNewNodes );
1594 myRadioBottomGroup ->button( data.myAlgorithm )->setChecked( true );
1595 myMinSizeSpin ->setValue( data.myMinSize );
1596 myMinSizeCheck ->setChecked( data.myUseMinSize );
1597 myMaxSizeSpin ->setValue( data.myMaxSize );
1598 myMaxSizeCheck ->setChecked( data.myUseMaxSize );
1599 myGradationCheck ->setChecked( data.myUseGradation );
1600 myGradationSpin ->setValue( data.myUseGradation ? data.myGradation : GHS3DPlugin_Hypothesis::DefaultGradation() );
1601 myUseProximityGroup ->setChecked( data.myUseProximity );
1602 myNbProximityLayers ->setValue( data.myNbProximityLayers );
1603 myNumOfThreadsCheck ->setChecked( data.myUseNumOfThreads );
1604 myNumOfThreadsSpin ->setValue( data.myNumOfThreads );
1605 myPthreadMode ->setCurrentIndex( data.myPthreadMode );
1606 myParallelMode ->setCurrentIndex( data.myParallelMode );
1608 myAdvWidget->maxMemoryCheck ->setChecked ( data.myMaximumMemory > 0 );
1609 myAdvWidget->maxMemorySpin ->setValue
1610 ( qMax( data.myMaximumMemory, (float)myAdvWidget->maxMemorySpin->minimum() ));
1611 myAdvWidget->initialMemoryCheck ->setChecked ( data.myInitialMemory > 0 );
1612 myAdvWidget->initialMemorySpin ->setValue
1613 ( qMax( data.myInitialMemory, (float)myAdvWidget->initialMemorySpin->minimum() ));
1614 myAdvWidget->workingDirectoryLineEdit ->setText ( data.myWorkingDir );
1615 myAdvWidget->keepWorkingFilesCheck ->setChecked ( data.myKeepFiles );
1616 myAdvWidget->verboseLevelSpin ->setValue ( data.myVerboseLevel );
1617 myAdvWidget->logInFileCheck ->setChecked ( !data.myLogInStandardOutput );
1618 myAdvWidget->removeLogOnSuccessCheck ->setChecked ( data.myRemoveLogOnSuccess );
1620 if ( myOptions.operator->() ) {
1621 for ( int i = 0, nb = myOptions->length(); i < nb; ++i )
1622 myAdvWidget->AddOption( that->myOptions[i].in() );
1624 if ( myCustomOptions.operator->() ) {
1625 for ( int i = 0, nb = myCustomOptions->length(); i < nb; ++i )
1626 myAdvWidget->AddOption( that->myCustomOptions[i].in() );
1628 myAdvWidget->myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
1629 myAdvWidget->EnableAdvancedOptions( data.myAlgorithm == GHS3DPlugin_Hypothesis::MGTetra );
1631 TEnfVertexList::const_iterator it;
1633 myEnforcedTableWidget->clearContents();
1634 myEnforcedTableWidget->setSortingEnabled(false);
1635 myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1636 for(it = data.myEnforcedVertices.begin() ; it != data.myEnforcedVertices.end(); it++ )
1638 TEnfVertex* enfVertex = (*it);
1639 myEnforcedTableWidget->setRowCount(rowCount+1);
1641 for (int col=0;col<ENF_VER_NB_COLUMNS;col++) {
1642 QTableWidgetItem* item = new QTableWidgetItem();
1643 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1645 case ENF_VER_NAME_COLUMN:
1646 item->setData( 0, enfVertex->name.c_str() );
1647 if (!enfVertex->geomEntry.empty()) {
1648 if (enfVertex->isCompound)
1649 item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1651 item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1655 case ENF_VER_X_COLUMN:
1656 if (!enfVertex->isCompound) {
1657 item->setData( 0, enfVertex->coords.at(0) );
1660 case ENF_VER_Y_COLUMN:
1661 if (!enfVertex->isCompound) {
1662 item->setData( 0, enfVertex->coords.at(1) );
1665 case ENF_VER_Z_COLUMN:
1666 if (!enfVertex->isCompound) {
1667 item->setData( 0, enfVertex->coords.at(2) );
1670 case ENF_VER_SIZE_COLUMN:
1671 item->setData( 0, enfVertex->size );
1673 case ENF_VER_ENTRY_COLUMN:
1674 item->setData( 0, enfVertex->geomEntry.c_str() );
1676 case ENF_VER_COMPOUND_COLUMN:
1677 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
1678 item->setData( Qt::CheckStateRole, enfVertex->isCompound );
1680 case ENF_VER_GROUP_COLUMN:
1681 item->setData( 0, enfVertex->groupName.c_str() );
1687 myEnforcedTableWidget->setItem(rowCount,col,item);
1689 that->updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1693 connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1694 myEnforcedTableWidget->setSortingEnabled(true);
1696 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1697 myEnforcedTableWidget->resizeColumnToContents(column);
1699 // Update Enforced meshes QTableWidget
1700 TEnfMeshList::const_iterator itMesh;
1702 myEnforcedMeshTableWidget->clearContents();
1703 myEnforcedMeshTableWidget->setSortingEnabled(false);
1704 // myEnforcedMeshTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1705 for(itMesh = data.myEnforcedMeshes.begin() ; itMesh != data.myEnforcedMeshes.end(); itMesh++ )
1707 TEnfMesh* enfMesh = (*itMesh);
1708 myEnforcedMeshTableWidget->setRowCount(rowCount+1);
1710 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++) {
1711 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1712 QComboBox* comboBox = new QComboBox();
1713 QPalette pal = comboBox->palette();
1714 pal.setColor(QPalette::Button, Qt::white);
1715 comboBox->setPalette(pal);
1716 comboBox->insertItems(0,myEnfMeshConstraintLabels);
1717 comboBox->setEditable(false);
1718 comboBox->setCurrentIndex(enfMesh->elementType);
1719 myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox);
1722 QTableWidgetItem* item = new QTableWidgetItem();
1723 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1725 case ENF_MESH_NAME_COLUMN:
1726 item->setData( 0, enfMesh->name.c_str() );
1727 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1728 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1730 case ENF_MESH_ENTRY_COLUMN:
1731 item->setData( 0, enfMesh->entry.c_str() );
1732 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1733 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1735 case ENF_MESH_GROUP_COLUMN:
1736 item->setData( 0, enfMesh->groupName.c_str() );
1737 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1748 myEnforcedMeshTableWidget->setSortingEnabled(true);
1750 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++)
1751 myEnforcedMeshTableWidget->resizeColumnToContents(col);
1753 that->updateWidgets();
1754 that->checkVertexIsDefined();
1757 QString GHS3DPluginGUI_HypothesisCreator::storeParams() const
1759 GHS3DHypothesisData data;
1760 readParamsFromWidgets( data );
1761 storeParamsToHypo( data );
1763 QString valStr = "";
1765 if ( !data.myBoundaryRecovery )
1766 valStr = " --components " + data.myToMeshHoles ? "all" : "outside_components" ;
1768 if ( data.myOptimizationLevel >= 0 && data.myOptimizationLevel < 5 && !data.myBoundaryRecovery) {
1769 const char* level[] = { "none" , "light" , "standard" , "standard+" , "strong" };
1770 valStr += " --optimisation_level ";
1771 valStr += level[ data.myOptimizationLevel ];
1773 if ( data.myMaximumMemory > 0 ) {
1774 valStr += " --max_memory ";
1775 valStr += QString::number( data.myMaximumMemory );
1777 if ( data.myInitialMemory > 0 && !data.myBoundaryRecovery ) {
1778 valStr += " --automatic_memory ";
1779 valStr += QString::number( data.myInitialMemory );
1781 valStr += " --verbose ";
1782 valStr += QString::number( data.myVerboseLevel );
1784 if ( !data.myToCreateNewNodes )
1785 valStr += " --no_internal_points";
1787 if ( data.myRemoveInitialCentralPoint )
1788 valStr += " --no_initial_central_point";
1790 // if ( data.myBoundaryRecovery )
1793 // if ( data.myFEMCorrection )
1794 // valStr += " -FEM";
1796 if ( data.myGradation != 1.05 ) {
1797 valStr += " -Dcpropa=";
1798 valStr += QString::number( data.myGradation );
1804 bool GHS3DPluginGUI_HypothesisCreator::readParamsFromHypo( GHS3DHypothesisData& h_data ) const
1806 GHS3DPlugin::GHS3DPlugin_Hypothesis_var h =
1807 GHS3DPlugin::GHS3DPlugin_Hypothesis::_narrow( initParamsHypothesis() );
1808 GHS3DPlugin::GHS3DPlugin_OptimizerHypothesis_var opt =
1809 GHS3DPlugin::GHS3DPlugin_OptimizerHypothesis::_narrow( initParamsHypothesis() );
1811 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
1812 h_data.myName = isCreation() && data ? hypName() : "";
1814 if ( !opt->_is_nil() )
1816 h_data.myOptimization = opt->GetOptimization();
1817 h_data.mySplitOverConstrained = opt->GetSplitOverConstrained();
1818 h_data.myPThreadsMode = opt->GetPThreadsMode();
1819 h_data.myNumberOfThreads = opt->GetMaximalNumberOfThreads();
1820 h_data.mySmoothOffSlivers = opt->GetSmoothOffSlivers();
1824 // avoid "Conditional jump or move depends on uninitialised value" error
1825 h_data.myOptimization = 1;
1826 h_data.mySplitOverConstrained = 1;
1827 h_data.myPThreadsMode = 1;
1828 h_data.myNumberOfThreads = 1;
1829 h_data.mySmoothOffSlivers = 1;
1831 h_data.myAlgorithm = h->GetAlgorithm();
1832 h_data.myOptimizationLevel = h->GetOptimizationLevel();
1833 h_data.myMinSize = h->GetMinSize();
1834 h_data.myMaxSize = h->GetMaxSize();
1835 this->myMinSizeDefault = h->GetMinSizeDefault();
1836 this->myMaxSizeDefault = h->GetMaxSizeDefault();
1837 if ( ! ( h_data.myUseMinSize = h_data.myMinSize > 0 ))
1838 h_data.myMinSize = this->myMinSizeDefault;
1839 if ( ! ( h_data.myUseMaxSize = h_data.myMaxSize > 0 ))
1840 h_data.myMaxSize = this->myMaxSizeDefault;
1841 h_data.myNbProximityLayers = h->GetNbVolumeProximityLayers();
1842 h_data.myUseGradation = h->GetGradation() != GHS3DPlugin_Hypothesis::DefaultGradation();
1843 h_data.myUseProximity = h->GetVolumeProximity();
1844 h_data.myToMeshHoles = h->GetToMeshHoles();
1845 h_data.myToMakeGroupsOfDomains = h->GetToMakeGroupsOfDomains();
1846 h_data.myMaximumMemory = h->GetMaximumMemory();
1847 h_data.myInitialMemory = h->GetInitialMemory();
1848 h_data.myInitialMemory = h->GetInitialMemory();
1849 h_data.myKeepFiles = h->GetKeepFiles();
1850 h_data.myWorkingDir = h->GetWorkingDirectory();
1851 h_data.myVerboseLevel = h->GetVerboseLevel();
1852 h_data.myToCreateNewNodes = h->GetToCreateNewNodes();
1853 //h_data.myRemoveInitialCentralPoint = h->GetToRemoveCentralPoint();
1854 //h_data.myBoundaryRecovery = h->GetToUseBoundaryRecoveryVersion();
1855 //h_data.myFEMCorrection = h->GetFEMCorrection();
1856 h_data.myGradation = h->GetGradation();
1857 //h_data.myTextOption = h->GetAdvancedOption();
1858 h_data.myLogInStandardOutput = h->GetStandardOutputLog();
1859 h_data.myRemoveLogOnSuccess = h->GetRemoveLogOnSuccess();
1860 h_data.myUseNumOfThreads = h->GetUseNumOfThreads();
1861 h_data.myNumOfThreads = h->GetNumOfThreads();
1862 h_data.myPthreadMode = h->GetPthreadMode();
1863 h_data.myParallelMode = h->GetParallelMode();
1865 GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
1866 that->myOptions = h->GetOptionValues();
1867 that->myCustomOptions = h->GetAdvancedOptionValues();
1869 GHS3DPlugin::GHS3DEnforcedVertexList_var vertices = h->GetEnforcedVertices();
1870 h_data.myEnforcedVertices.clear();
1871 for (CORBA::ULong i=0 ; i<vertices->length() ; i++) {
1872 TEnfVertex* myVertex = new TEnfVertex();
1873 myVertex->name = CORBA::string_dup(vertices[i].name.in());
1874 myVertex->geomEntry = CORBA::string_dup(vertices[i].geomEntry.in());
1875 myVertex->groupName = CORBA::string_dup(vertices[i].groupName.in());
1876 myVertex->size = vertices[i].size;
1877 myVertex->isCompound = vertices[i].isCompound;
1878 if (vertices[i].coords.length()) {
1879 for (CORBA::ULong c = 0; c < vertices[i].coords.length() ; c++)
1880 myVertex->coords.push_back(vertices[i].coords[c]);
1882 h_data.myEnforcedVertices.insert(myVertex);
1885 GHS3DPlugin::GHS3DEnforcedMeshList_var enfMeshes = h->GetEnforcedMeshes();
1886 h_data.myEnforcedMeshes.clear();
1887 for (CORBA::ULong i=0 ; i<enfMeshes->length() ; i++) {
1888 TEnfMesh* myEnfMesh = new TEnfMesh();
1889 myEnfMesh->name = CORBA::string_dup(enfMeshes[i].name.in());
1890 myEnfMesh->entry = CORBA::string_dup(enfMeshes[i].entry.in());
1891 myEnfMesh->groupName = CORBA::string_dup(enfMeshes[i].groupName.in());
1892 switch (enfMeshes[i].elementType) {
1894 myEnfMesh->elementType = 0;
1897 myEnfMesh->elementType = 1;
1900 myEnfMesh->elementType = 2;
1905 // myEnfMesh->elementType = enfMeshes[i].elementType;
1906 h_data.myEnforcedMeshes.insert(myEnfMesh);
1911 bool GHS3DPluginGUI_HypothesisCreator::storeParamsToHypo( const GHS3DHypothesisData& h_data ) const
1913 GHS3DPlugin::GHS3DPlugin_Hypothesis_var h =
1914 GHS3DPlugin::GHS3DPlugin_Hypothesis::_narrow( hypothesis() );
1915 GHS3DPlugin::GHS3DPlugin_OptimizerHypothesis_var opt =
1916 GHS3DPlugin::GHS3DPlugin_OptimizerHypothesis::_narrow( initParamsHypothesis() );
1922 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
1924 if ( opt->_is_nil() )
1926 h->SetAlgorithm ((CORBA::Short) h_data.myAlgorithm );
1927 h->SetUseNumOfThreads ( h_data.myUseNumOfThreads );
1928 h->SetNumOfThreads ( (CORBA::Short) h_data.myNumOfThreads );
1929 h->SetPthreadMode ( (CORBA::Short) h_data.myPthreadMode );
1930 h->SetParallelMode ( (CORBA::Short) h_data.myParallelMode );
1931 h->SetGradation ( h_data.myGradation );
1932 h->SetToMeshHoles ( h_data.myToMeshHoles );
1933 h->SetToMakeGroupsOfDomains ( h_data.myToMakeGroupsOfDomains );
1934 h->SetVolumeProximity ( h_data.myUseProximity );
1935 h->SetNbVolumeProximityLayers ((CORBA::Short) h_data.myNbProximityLayers );
1938 // Common existing options optimization a MGTetra && MGTetraHPC
1939 h->SetOptimizationLevel ((CORBA::Short) h_data.myOptimizationLevel );
1940 h->SetMinSize ( h_data.myUseMinSize ? h_data.myMinSize : 0 );
1941 h->SetMaxSize ( h_data.myUseMaxSize ? h_data.myMaxSize : 0 );
1942 h->SetMinMaxSizeDefault ( this->myMinSizeDefault, this->myMaxSizeDefault );
1944 h->SetMaximumMemory ( h_data.myMaximumMemory );
1945 h->SetInitialMemory ( h_data.myInitialMemory );
1946 h->SetKeepFiles ( h_data.myKeepFiles );
1947 h->SetWorkingDirectory ( h_data.myWorkingDir.toLatin1().constData() );
1948 h->SetVerboseLevel ( h_data.myVerboseLevel );
1949 //h->SetToRemoveCentralPoint ( h_data.myRemoveInitialCentralPoint );
1950 //h->SetToUseBoundaryRecoveryVersion( h_data.myBoundaryRecovery );
1951 //h->SetFEMCorrection ( h_data.myFEMCorrection );
1952 h->SetStandardOutputLog ( h_data.myLogInStandardOutput );
1953 h->SetRemoveLogOnSuccess ( h_data.myRemoveLogOnSuccess );
1956 if ( !opt->_is_nil() )
1958 opt->SetToCreateNewNodes ( h_data.myToCreateNewNodes );
1959 opt->SetOptimization ( (GHS3DPlugin::Mode) h_data.myOptimization );
1960 opt->SetSplitOverConstrained ( (GHS3DPlugin::Mode) h_data.mySplitOverConstrained );
1961 opt->SetPThreadsMode ( (GHS3DPlugin::PThreadsMode) h_data.myPThreadsMode );
1962 opt->SetSmoothOffSlivers ( h_data.mySmoothOffSlivers );
1963 opt->SetMaximalNumberOfThreads((CORBA::Short) h_data.myNumberOfThreads );
1966 // Enforced vertices
1967 GHS3DPlugin::GHS3DEnforcedVertexList_var vertexHyp = h->GetEnforcedVertices();
1968 int nbVertexHyp = vertexHyp->length();
1970 // 1. Clear all enforced vertices in hypothesis
1971 // 2. Add new enforced vertex according to h_data
1972 if ( nbVertexHyp > 0)
1973 h->ClearEnforcedVertices();
1975 TEnfVertexList::const_iterator it;
1976 double x = 0, y = 0, z = 0;
1977 for(it = h_data.myEnforcedVertices.begin() ; it != h_data.myEnforcedVertices.end(); it++ ) {
1978 TEnfVertex* enfVertex = (*it);
1980 if (enfVertex->coords.size()) {
1981 x = enfVertex->coords.at(0);
1982 y = enfVertex->coords.at(1);
1983 z = enfVertex->coords.at(2);
1985 ok = h->p_SetEnforcedVertex( enfVertex->size, x, y, z, enfVertex->name.c_str(), enfVertex->geomEntry.c_str(), enfVertex->groupName.c_str(), enfVertex->isCompound);
1989 GHS3DPlugin::GHS3DEnforcedMeshList_var enfMeshListHyp = h->GetEnforcedMeshes();
1990 int nbEnfMeshListHyp = enfMeshListHyp->length();
1992 // 1. Clear all enforced vertices in hypothesis
1993 // 2. Add new enforced vertex according to h_data
1994 if ( nbEnfMeshListHyp > 0)
1995 h->ClearEnforcedMeshes();
1997 TEnfMeshList::const_iterator itEnfMesh;
1999 _PTR(Study) aStudy = SMESH::getStudy();
2001 for(itEnfMesh = h_data.myEnforcedMeshes.begin() ; itEnfMesh != h_data.myEnforcedMeshes.end(); itEnfMesh++ ) {
2002 TEnfMesh* enfMesh = (*itEnfMesh);
2004 _PTR(SObject) aSObj = aStudy->FindObjectID(enfMesh->entry.c_str());
2005 SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
2007 SMESH::ElementType elementType = SMESH::NODE;
2008 switch(enfMesh->elementType) {
2010 elementType = SMESH::NODE;
2013 elementType = SMESH::EDGE;
2016 elementType = SMESH::FACE;
2022 ok = h->p_SetEnforcedMesh(theSource, elementType, enfMesh->name.c_str(), enfMesh->groupName.c_str());
2025 catch ( const SALOME::SALOME_Exception& ex )
2027 SalomeApp_Tools::QtCatchCorbaException( ex );
2033 bool GHS3DPluginGUI_HypothesisCreator::readParamsFromWidgets( GHS3DHypothesisData& h_data ) const
2035 h_data.myName = myName ? myName->text() : "";
2036 h_data.myOptimizationLevel = myOptimizationLevelCombo->currentIndex();
2037 if ( mySplitOverConstrainedCombo ) // optimizer
2039 h_data.myToCreateNewNodes = myCreateNewNodesCheck->isChecked();
2040 h_data.myOptimization = myOptimizationCombo->currentIndex();
2041 h_data.mySplitOverConstrained = mySplitOverConstrainedCombo->currentIndex();
2042 h_data.myPThreadsMode = myPThreadsModeCombo->currentIndex();
2043 h_data.myNumberOfThreads = myNumberOfThreadsSpin->value();
2044 h_data.mySmoothOffSlivers = mySmoothOffSliversCheck->isChecked();
2048 h_data.myMinSize = myMinSizeSpin->value();
2049 h_data.myMaxSize = myMaxSizeSpin->value();
2050 h_data.myUseMinSize = myMinSizeCheck->isChecked();
2051 h_data.myUseMaxSize = myMaxSizeCheck->isChecked();
2052 h_data.myGradation = myGradationSpin->value();
2053 h_data.myUseGradation = myGradationCheck->isChecked();
2054 h_data.myUseProximity = myUseProximityGroup->isChecked();
2055 h_data.myNbProximityLayers = myNbProximityLayers->value();
2056 h_data.myToMeshHoles = myToMeshHolesCheck->isChecked();
2057 h_data.myToMakeGroupsOfDomains = myToMakeGroupsOfDomains->isChecked();
2058 h_data.myAlgorithm = myRadioBottomGroup->checkedId();
2059 h_data.myUseNumOfThreads = myNumOfThreadsCheck->isChecked();
2060 h_data.myNumOfThreads = myNumOfThreadsSpin->value();
2061 h_data.myPthreadMode = myPthreadMode->currentIndex();
2062 h_data.myParallelMode = myParallelMode->currentIndex();
2064 h_data.myMaximumMemory = float( myAdvWidget->maxMemoryCheck->isChecked() ? myAdvWidget->maxMemorySpin->value() : -1 );
2065 h_data.myInitialMemory = float( myAdvWidget->initialMemoryCheck->isChecked() ? myAdvWidget->initialMemorySpin->value() : -1 );
2066 h_data.myKeepFiles = myAdvWidget->keepWorkingFilesCheck->isChecked();
2067 h_data.myWorkingDir = myAdvWidget->workingDirectoryLineEdit->text().trimmed();
2068 h_data.myVerboseLevel = short( myAdvWidget->verboseLevelSpin->value() );
2069 h_data.myLogInStandardOutput = !myAdvWidget->logInFileCheck->isChecked();
2070 h_data.myRemoveLogOnSuccess = myAdvWidget->removeLogOnSuccessCheck->isChecked();
2072 // Enforced vertices
2073 h_data.myEnforcedVertices.clear();
2074 QVariant valueX, valueY, valueZ;
2075 for (int row=0 ; row<myEnforcedTableWidget->rowCount() ; row++)
2077 TEnfVertex *myVertex = new TEnfVertex();
2078 myVertex->name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString();
2079 myVertex->geomEntry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString();
2080 myVertex->groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
2081 valueX = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data(Qt::EditRole);
2082 valueY = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data(Qt::EditRole);
2083 valueZ = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data(Qt::EditRole);
2084 if (!valueX.isNull() && !valueY.isNull() && !valueZ.isNull()) {
2085 myVertex->coords.push_back(valueX.toDouble());
2086 myVertex->coords.push_back(valueY.toDouble());
2087 myVertex->coords.push_back(valueZ.toDouble());
2089 myVertex->size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data(Qt::EditRole).toDouble();
2090 myVertex->isCompound = myEnforcedTableWidget->item(row,ENF_VER_COMPOUND_COLUMN)->data(Qt::CheckStateRole).toBool();
2091 h_data.myEnforcedVertices.insert(myVertex);
2095 h_data.myEnforcedMeshes.clear();
2097 for (int row=0 ; row<myEnforcedMeshTableWidget->rowCount() ; row++)
2099 TEnfMesh *myEnfMesh = new TEnfMesh();
2100 myEnfMesh->name = myEnforcedMeshTableWidget->item(row,ENF_MESH_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString();
2101 myEnfMesh->entry = myEnforcedMeshTableWidget->item(row,ENF_MESH_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString();
2102 myEnfMesh->groupName = myEnforcedMeshTableWidget->item(row,ENF_MESH_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
2103 QComboBox* combo = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row,ENF_MESH_CONSTRAINT_COLUMN));
2104 myEnfMesh->elementType = combo->currentIndex();
2105 h_data.myEnforcedMeshes.insert(myEnfMesh);
2111 QString GHS3DPluginGUI_HypothesisCreator::caption() const
2113 return tr( "GHS3D_TITLE" );
2116 QPixmap GHS3DPluginGUI_HypothesisCreator::icon() const
2118 return SUIT_Session::session()->resourceMgr()->loadPixmap( "GHS3DPlugin", tr( "ICON_DLG_GHS3D_PARAMETERS" ) );
2121 QString GHS3DPluginGUI_HypothesisCreator::type() const
2123 return tr( isOptimization() ? "GHS3D_OPTIMIZATIOL_HYPOTHESIS" : "GHS3D_HYPOTHESIS" );
2126 QString GHS3DPluginGUI_HypothesisCreator::helpPage() const
2128 return isOptimization() ? "optimization_page.html" : "ghs3d_hypo_page.html";
2131 void GHS3DPluginGUI_HypothesisCreator::onAddOption()
2133 myAdvWidget->AddOption( NULL, true );