1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : HYBRIDPluginGUI_HypothesisCreator.cxx
22 // Author : Christian VAN WAMBEKE (CEA)
25 #include "HYBRIDPluginGUI_HypothesisCreator.h"
26 #include "HYBRIDPluginGUI_Enums.h"
27 #include "HYBRIDPluginGUI_Dlg.h"
29 #include <GeometryGUI.h>
31 #include <SMESHGUI_HypothesesUtils.h>
32 #include <SMESHGUI_SpinBox.h>
33 #include <SMESHGUI_Utils.h>
34 #include <SMESH_NumberFilter.hxx>
35 #include <SMESH_TypeFilter.hxx>
36 #include <StdMeshersGUI_ObjectReferenceParamWdg.h>
37 #include <StdMeshersGUI_SubShapeSelectorWdg.h>
39 #include <LightApp_SelectionMgr.h>
40 #include <SUIT_Session.h>
41 #include <SUIT_MessageBox.h>
42 #include <SUIT_ResourceMgr.h>
43 #include <SUIT_FileDlg.h>
44 #include <SalomeApp_Tools.h>
45 #include <SalomeApp_TypeFilter.h>
47 #include <TopoDS_Iterator.hxx>
53 #include <QVBoxLayout>
54 #include <QGridLayout>
59 #include <QPushButton>
63 #include <QTableWidget>
64 #include <QTableWidgetItem>
65 #include <QHeaderView>
68 #include <utilities.h>
70 #include <boost/algorithm/string.hpp>
75 // #include <windows.h>
77 // #include <sys/sysinfo.h>
80 // int maxAvailableMemory()
83 // // See http://msdn.microsoft.com/en-us/library/aa366589.aspx
84 // MEMORYSTATUSEX statex;
85 // statex.dwLength = sizeof (statex);
86 // int err = GlobalMemoryStatusEx (&statex);
89 // statex.ullTotalPhys / 1024 / 1024 +
90 // statex.ullTotalPageFile / 1024 / 1024 +
91 // statex.ullTotalVirtual / 1024 / 1024;
92 // return (int) ( 0.7 * totMB );
96 // int err = sysinfo( &si );
99 // si.totalram * si.mem_unit / 1024 / 1024 +
100 // si.totalswap * si.mem_unit / 1024 / 1024 ;
101 // return (int) ( 0.7 * totMB );
109 // BEGIN EnforcedVertexTableWidgetDelegate
112 EnforcedVertexTableWidgetDelegate::EnforcedVertexTableWidgetDelegate(QObject *parent)
113 : QItemDelegate(parent)
117 QWidget *EnforcedVertexTableWidgetDelegate::createEditor(QWidget *parent,
118 const QStyleOptionViewItem & option ,
119 const QModelIndex & index ) const
121 QModelIndex father = index.parent();
122 QString entry = father.child(index.row(), ENF_VER_ENTRY_COLUMN).data().toString();
124 if (index.column() == ENF_VER_X_COLUMN ||
125 index.column() == ENF_VER_Y_COLUMN ||
126 index.column() == ENF_VER_Z_COLUMN ||
127 index.column() == ENF_VER_SIZE_COLUMN) {
128 SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent);
129 if (index.column() == ENF_VER_SIZE_COLUMN)
130 editor->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
132 editor->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
133 editor->setReadOnly(!entry.isEmpty());
134 editor->setDisabled(!entry.isEmpty());
137 // else if (index.column() == ENF_VER_COMPOUND_COLUMN) {
138 // QCheckBox *editor = new QCheckBox(parent);
139 // editor->setDisabled(!entry.isEmpty());
142 else if (index.column() == ENF_VER_GROUP_COLUMN ||
143 index.column() == ENF_VER_NAME_COLUMN) {
145 QLineEdit *editor = new QLineEdit(parent);
146 if (index.column() != ENF_VER_GROUP_COLUMN) {
147 editor->setReadOnly(!entry.isEmpty());
148 editor->setDisabled(!entry.isEmpty());
152 return QItemDelegate::createEditor(parent, option, index);
155 void EnforcedVertexTableWidgetDelegate::setEditorData(QWidget *editor,
156 const QModelIndex &index) const
158 if (index.column() == ENF_VER_X_COLUMN ||
159 index.column() == ENF_VER_Y_COLUMN ||
160 index.column() == ENF_VER_Z_COLUMN ||
161 index.column() == ENF_VER_SIZE_COLUMN)
163 SMESHGUI_SpinBox *lineEdit = qobject_cast<SMESHGUI_SpinBox*>(editor);
164 lineEdit->SetValue(index.data().toDouble());
166 else if (index.column() == ENF_VER_COMPOUND_COLUMN) {
167 QCheckBox *checkBox = qobject_cast<QCheckBox*>(editor);
168 checkBox->setChecked(index.data().toBool());
171 QItemDelegate::setEditorData(editor, index);
175 void EnforcedVertexTableWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
176 const QModelIndex &index) const
178 QModelIndex parent = index.parent();
180 QString entry = parent.child(index.row(), ENF_VER_ENTRY_COLUMN).data().toString();
181 bool isCompound = parent.child(index.row(), ENF_VER_COMPOUND_COLUMN).data(Qt::CheckStateRole).toBool();
183 if (index.column() == ENF_VER_X_COLUMN ||
184 index.column() == ENF_VER_Y_COLUMN ||
185 index.column() == ENF_VER_Z_COLUMN) {
186 SMESHGUI_SpinBox *lineEdit = qobject_cast<SMESHGUI_SpinBox*>(editor);
187 if (!isCompound && !vertexExists(model, index, lineEdit->GetString()))
188 model->setData(index, lineEdit->GetValue(), Qt::EditRole);
190 else if (index.column() == ENF_VER_SIZE_COLUMN)
192 SMESHGUI_SpinBox *lineEdit = qobject_cast<SMESHGUI_SpinBox*>(editor);
193 const double newsize = lineEdit->GetValue();
195 model->setData(index, newsize, Qt::EditRole);
197 else if (index.column() == ENF_VER_NAME_COLUMN) {
198 QLineEdit *lineEdit = qobject_cast<QLineEdit*>(editor);
199 QString value = lineEdit->text();
200 if (entry.isEmpty() && !vertexExists(model, index, value))
201 model->setData(index, value, Qt::EditRole);
203 else if (index.column() == ENF_VER_ENTRY_COLUMN) {
204 QLineEdit *lineEdit = qobject_cast<QLineEdit*>(editor);
205 QString value = lineEdit->text();
206 if (! vertexExists(model, index, value))
207 model->setData(index, value, Qt::EditRole);
209 else if (index.column() == ENF_VER_COMPOUND_COLUMN) {
210 QCheckBox *checkBox = qobject_cast<QCheckBox*>(editor);
211 model->setData(index, checkBox->isChecked(), Qt::CheckStateRole);
214 QItemDelegate::setModelData(editor, model, index);
218 void EnforcedVertexTableWidgetDelegate::updateEditorGeometry(QWidget *editor,
219 const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
221 editor->setGeometry(option.rect);
224 bool EnforcedVertexTableWidgetDelegate::vertexExists(QAbstractItemModel *model,
225 const QModelIndex &index,
229 QModelIndex parent = index.parent();
230 int row = index.row();
231 int col = index.column();
233 if (parent.isValid() && !value.isEmpty()) {
234 if (col == ENF_VER_X_COLUMN || col == ENF_VER_Y_COLUMN || col == ENF_VER_Z_COLUMN) {
236 if (col == ENF_VER_X_COLUMN) {
237 x = value.toDouble();
238 y = parent.child(row, ENF_VER_Y_COLUMN).data().toDouble();
239 z = parent.child(row, ENF_VER_Z_COLUMN).data().toDouble();
241 if (col == ENF_VER_Y_COLUMN) {
242 y = value.toDouble();
243 x = parent.child(row, ENF_VER_X_COLUMN).data().toDouble();
244 z = parent.child(row, ENF_VER_Z_COLUMN).data().toDouble();
246 if (col == ENF_VER_Z_COLUMN) {
247 z = value.toDouble();
248 x = parent.child(row, ENF_VER_X_COLUMN).data().toDouble();
249 y = parent.child(row, ENF_VER_Y_COLUMN).data().toDouble();
251 int nbChildren = model->rowCount(parent);
252 for (int i = 0 ; i < nbChildren ; i++) {
254 double childX = parent.child(i, ENF_VER_X_COLUMN).data().toDouble();
255 double childY = parent.child(i, ENF_VER_Y_COLUMN).data().toDouble();
256 double childZ = parent.child(i, ENF_VER_Z_COLUMN).data().toDouble();
257 if ((childX == x) && (childY == y) && (childZ == z)) {
264 else if (col == ENF_VER_NAME_COLUMN) {
265 QString name = parent.child(row, ENF_VER_NAME_COLUMN).data().toString();
275 // END EnforcedVertexTableWidgetDelegate
279 // BEGIN EnforcedMeshTableWidgetDelegate
282 EnforcedMeshTableWidgetDelegate::EnforcedMeshTableWidgetDelegate(QObject *parent)
283 : QItemDelegate(parent)
287 QWidget *EnforcedMeshTableWidgetDelegate::createEditor(QWidget *parent,
288 const QStyleOptionViewItem & option ,
289 const QModelIndex & index ) const
291 return QItemDelegate::createEditor(parent, option, index);
294 void EnforcedMeshTableWidgetDelegate::setEditorData(QWidget *editor,
295 const QModelIndex &index) const
297 QItemDelegate::setEditorData(editor, index);
300 void EnforcedMeshTableWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
301 const QModelIndex &index) const
303 QItemDelegate::setModelData(editor, model, index);
307 void EnforcedMeshTableWidgetDelegate::updateEditorGeometry(QWidget *editor,
308 const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
310 editor->setGeometry(option.rect);
313 // bool EnforcedMeshTableWidgetDelegate::enfMeshExists(QAbstractItemModel *model,
314 // const QModelIndex &index,
315 // QString value) const
317 // bool exists = false;
318 // QModelIndex parent = index.parent();
319 // int row = index.row();
320 // int col = index.column();
325 // END EnforcedMeshTableWidgetDelegate
329 HYBRIDPluginGUI_HypothesisCreator::HYBRIDPluginGUI_HypothesisCreator( const QString& theHypType )
330 : SMESHGUI_GenericHypothesisCreator( theHypType )
332 GeomToolSelected = NULL;
333 GeomToolSelected = getGeomSelectionTool();
335 iconVertex = QPixmap(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_OBJBROWSER_VERTEX")));
336 iconCompound = QPixmap(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_OBJBROWSER_COMPOUND")));
337 // mySelectionMgr = SMESH::GetSelectionMgr(SMESHGUI::GetSMESHGUI());
338 myEnfMeshConstraintLabels << tr( "HYBRID_ENF_MESH_CONSTRAINT_NODE" ) << tr( "HYBRID_ENF_MESH_CONSTRAINT_EDGE" ) << tr("HYBRID_ENF_MESH_CONSTRAINT_FACE");
341 HYBRIDPluginGUI_HypothesisCreator::~HYBRIDPluginGUI_HypothesisCreator()
343 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
344 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
345 myEnfMeshWdg->deactivateSelection();
349 * \brief {Get or create the geom selection tool for active study}
351 GeomSelectionTools* HYBRIDPluginGUI_HypothesisCreator::getGeomSelectionTool()
353 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
354 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
355 if (that->GeomToolSelected == NULL || that->GeomToolSelected->getMyStudy() != aStudy) {
356 that->GeomToolSelected = new GeomSelectionTools(aStudy);
358 return that->GeomToolSelected;
361 GEOM::GEOM_Gen_var HYBRIDPluginGUI_HypothesisCreator::getGeomEngine()
363 return GeometryGUI::GetGeomGen();
366 QFrame* HYBRIDPluginGUI_HypothesisCreator::buildFrame()
368 QFrame* fr = new QFrame( 0 );
369 QVBoxLayout* lay = new QVBoxLayout( fr );
371 lay->setSpacing( 0 );
374 QTabWidget* tab = new QTabWidget( fr );
375 tab->setTabShape( QTabWidget::Rounded );
376 tab->setTabPosition( QTabWidget::North );
377 lay->addWidget( tab );
380 myStdGroup = new QWidget();
381 QGridLayout* aStdLayout = new QGridLayout( myStdGroup );
382 aStdLayout->setSpacing( 6 );
383 aStdLayout->setMargin( 11 );
389 aStdLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), myStdGroup ), row, 0, 1, 1 );
390 myName = new QLineEdit( myStdGroup );
391 aStdLayout->addWidget( myName, row++, 1, 1, 1 );
394 myToMeshHolesCheck = new QCheckBox( tr( "HYBRID_TO_MESH_HOLES" ), myStdGroup );
395 //aStdLayout->addWidget( myToMeshHolesCheck, row, 0, 1, 1 ); #stay, not view, may be used tomorrow...
396 myToMeshHolesCheck->hide();
397 myToMakeGroupsOfDomains = new QCheckBox( tr( "HYBRID_TO_MAKE_DOMAIN_GROUPS" ), myStdGroup );
398 //aStdLayout->addWidget( myToMakeGroupsOfDomains, row++, 1, 1, 1 ); #stay, not view, may be used tomorrow...
399 myToMakeGroupsOfDomains->hide();
400 //aStdLayout->addWidget( new QLabel( tr( "HYBRID_OPTIMIZATIOL_LEVEL" ), myStdGroup ), row, 0, 1, 1 );
401 myOptimizationLevelCombo = new QComboBox( myStdGroup );
402 //aStdLayout->addWidget( myOptimizationLevelCombo, row++, 1, 1, 1 ); #stay, not view, may be used tomorrow...
403 myOptimizationLevelCombo->hide();
406 types << tr( "LEVEL_NONE" ) << tr( "LEVEL_LIGHT" ) << tr( "LEVEL_MEDIUM" ) << tr( "LEVEL_STANDARDPLUS" ) << tr( "LEVEL_STRONG" );
407 myOptimizationLevelCombo->addItems( types );
409 QLabel* aLabel = new QLabel( tr( "HYBRID_BOUNDARY_LAYERS_GROWTH" ), myStdGroup );
410 aLabel->setToolTip(tr( "HYBRID_BOUNDARY_LAYERS_HELP" ));
411 aStdLayout->addWidget( aLabel, row, 0, 1, 1 );
412 myBoundaryLayersGrowthCombo = new QComboBox( myStdGroup );
413 myBoundaryLayersGrowthCombo->setToolTip(tr( "HYBRID_BOUNDARY_LAYERS_HELP" ));
415 aStdLayout->addWidget( myBoundaryLayersGrowthCombo, row++, 1, 1, 1 );
417 QStringList typesBoundaryLayersGrowth;
418 typesBoundaryLayersGrowth << tr( "HYBRID_LAYER_GROWTH_DOWNWARD" ) << tr( "HYBRID_LAYER_GROWTH_UPWARD" );
419 myBoundaryLayersGrowthCombo->addItems( typesBoundaryLayersGrowth );
421 aStdLayout->addWidget( new QLabel( tr( "HYBRID_HeightFirstLayer" ), myStdGroup ), row, 0, 1, 1 );
422 myHeightFirstLayerSpin = new SMESHGUI_SpinBox( myStdGroup );
423 myHeightFirstLayerSpin->RangeStepAndValidator(0., 100., .1, "HeightFirstLayer");
424 aStdLayout->addWidget( myHeightFirstLayerSpin, row++, 1, 1, 1 );
426 aStdLayout->addWidget( new QLabel( tr( "HYBRID_NbOfBoundaryLayers" ), myStdGroup ), row, 0, 1, 1 );
427 myNbOfBoundaryLayersSpin = new QSpinBox( myStdGroup );
428 aStdLayout->addWidget( myNbOfBoundaryLayersSpin, row++, 1, 1, 1 );
430 aStdLayout->addWidget( new QLabel( tr( "HYBRID_BoundaryLayersProgression" ), myStdGroup ), row, 0, 1, 1 );
431 myBoundaryLayersProgressionSpin = new SMESHGUI_SpinBox( myStdGroup );
432 myBoundaryLayersProgressionSpin->RangeStepAndValidator(0., 10., .1, "BoundaryLayersProgression");
433 aStdLayout->addWidget( myBoundaryLayersProgressionSpin, row++, 1, 1, 1 );
435 aStdLayout->addWidget( new QLabel( tr( "COLLISION_MODE" ), myStdGroup ), row, 0, 1, 1 );
436 myCollisionModeCombo = new QComboBox( myStdGroup );
437 aStdLayout->addWidget( myCollisionModeCombo, row++, 1, 1, 1 );
439 QStringList typescoll;
440 typescoll << tr( "COLLISION_DECREASE" ) << tr( "COLLISION_STOP" );
441 myCollisionModeCombo->addItems( typescoll );
443 aStdLayout->addWidget( new QLabel( tr( "HYBRID_GENERATION_ELEMENT" ), myStdGroup ), row, 0, 1, 1 );
444 myElementGenerationCombo = new QComboBox( myStdGroup );
445 aStdLayout->addWidget( myElementGenerationCombo, row++, 1, 1, 1 );
447 QStringList typesElementGeneration;
448 typesElementGeneration << tr( "HYBRID_GENERATION_TETRA_DOMINANT" ) << tr( "HYBRID_GENERATION_HEXA_DOMINANT" );
449 myElementGenerationCombo->addItems( typesElementGeneration );
451 myAddMultinormalsCheck = new QCheckBox( tr( "HYBRID_ADD_MULTINORMALS" ), myStdGroup );
452 aStdLayout->addWidget( myAddMultinormalsCheck, row++, 0, 1, 1 );
454 aStdLayout->addWidget( new QLabel( tr( "HYBRID_MULTINORMAL_ANGLE" ), myStdGroup ), row, 0, 1, 1 );
455 myMultinormalsAngleSpin = new SMESHGUI_SpinBox( myStdGroup );
456 myMultinormalsAngleSpin->RangeStepAndValidator(0., 90., 2., "threshold");
457 aStdLayout->addWidget( myMultinormalsAngleSpin, row++, 1, 1, 1 );
459 mySmoothNormalsCheck = new QCheckBox( tr( "HYBRID_SMOOTH_NORMALS" ), myStdGroup );
460 aStdLayout->addWidget( mySmoothNormalsCheck, row++, 0, 1, 1 );
461 aStdLayout->setRowStretch( row, 10 );
463 // advanced parameters
464 myAdvGroup = new QWidget();
465 QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup );
466 anAdvLayout->setSpacing( 6 );
467 anAdvLayout->setMargin( 11 );
468 myAdvWidget = new HYBRIDPluginGUI_AdvWidget(myAdvGroup);
469 anAdvLayout->addWidget( myAdvWidget);
471 myAdvWidget->maxMemoryCheck->setText(tr( "MAX_MEMORY_SIZE" ));
472 myAdvWidget->initialMemoryCheck->setText(tr( "INIT_MEMORY_SIZE" ));
474 myAdvWidget->maxMemorySpin->RangeStepAndValidator(20.0, 1e6, 10.0);
475 myAdvWidget->maxMemorySpin->setValue( 128.0 );
477 myAdvWidget->initialMemorySpin->RangeStepAndValidator(0.0, 1e6, 10.0);
478 myAdvWidget->initialMemorySpin->setValue( 100.0 );
480 myAdvWidget->initialMemoryLabel ->setText (tr( "MEGABYTE" ));
481 myAdvWidget->maxMemoryLabel ->setText (tr( "MEGABYTE" ));
483 myAdvWidget->workingDirectoryPushButton ->setText (tr( "SELECT_DIR" ));
484 myAdvWidget->keepWorkingFilesCheck ->setText (tr( "KEEP_WORKING_FILES" ));
485 myAdvWidget->verboseLevelLabel ->setText (tr( "VERBOSE_LEVEL" ));
486 myAdvWidget->removeLogOnSuccessCheck ->setText (tr( "REMOVE_LOG_ON_SUCCESS" ));
487 myAdvWidget->logInFileCheck ->setText (tr( "LOG_IN_FILE" ));
489 myAdvWidget->memoryGroupBox ->setTitle(tr( "MEMORY_GROUP_TITLE" ));
490 myAdvWidget->logGroupBox ->setTitle(tr( "LOG_GROUP_TITLE" ));
491 myAdvWidget->advancedMeshingGroupBox ->setTitle(tr( "ADVANCED_MESHING_GROUP_TITLE" ));
493 myAdvWidget->memoryGroupBox->hide();
495 myAdvWidget->createNewNodesCheck->hide();
496 //myAdvWidget->createNewNodesLabel->hide();
497 myAdvWidget->removeInitialCentralPointCheck->hide();
498 myAdvWidget->boundaryRecoveryCheck->hide();
499 myAdvWidget->FEMCorrectionCheck->hide();
500 myAdvWidget->gradationLabel->hide();
501 myAdvWidget->gradationSpinBox->hide();
503 myAdvWidget->createNewNodesCheck ->setText (tr( "TO_ADD_NODES" ));
504 myAdvWidget->removeInitialCentralPointCheck->setText (tr( "NO_INITIAL_CENTRAL_POINT" ));
505 myAdvWidget->boundaryRecoveryCheck ->setText (tr( "RECOVERY_VERSION" ));
506 myAdvWidget->FEMCorrectionCheck ->setText (tr( "FEM_CORRECTION" ));
507 myAdvWidget->gradationLabel ->setText (tr( "HYBRID_GRADATION" ));
508 myAdvWidget->gradationSpinBox->RangeStepAndValidator(1.05, 5.0, 0.05, "length_precision");
510 // Enforced vertices parameters
511 myEnfGroup = new QWidget();
512 QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup);
513 myEnforcedTableWidget = new QTableWidget(myEnfGroup);
514 myEnforcedTableWidget ->setMinimumWidth(300);
515 myEnforcedTableWidget->setRowCount( 0 );
516 myEnforcedTableWidget->setColumnCount( ENF_VER_NB_COLUMNS );
517 myEnforcedTableWidget->setSortingEnabled(true);
518 QStringList enforcedHeaders;
519 enforcedHeaders << tr( "HYBRID_ENF_NAME_COLUMN" )
520 << tr( "HYBRID_ENF_VER_X_COLUMN" )<< tr( "HYBRID_ENF_VER_Y_COLUMN" ) << tr( "HYBRID_ENF_VER_Z_COLUMN" )
521 << tr( "HYBRID_ENF_SIZE_COLUMN" ) << tr("HYBRID_ENF_ENTRY_COLUMN") << tr("HYBRID_ENF_VER_COMPOUND_COLUMN") << tr( "HYBRID_ENF_GROUP_COLUMN" );
523 myEnforcedTableWidget->setHorizontalHeaderLabels(enforcedHeaders);
524 myEnforcedTableWidget->verticalHeader()->hide();
525 myEnforcedTableWidget->horizontalHeader()->setStretchLastSection(true);
526 myEnforcedTableWidget->setAlternatingRowColors(true);
527 myEnforcedTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
528 myEnforcedTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
529 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
530 myEnforcedTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
532 myEnforcedTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
534 myEnforcedTableWidget->resizeColumnsToContents();
535 myEnforcedTableWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
536 myEnforcedTableWidget->hideColumn(ENF_VER_COMPOUND_COLUMN);
538 myEnforcedTableWidget->setItemDelegate(new EnforcedVertexTableWidgetDelegate());
541 TColStd_MapOfInteger shapeTypes;
542 shapeTypes.Add( TopAbs_VERTEX );
543 shapeTypes.Add( TopAbs_COMPOUND );
545 SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes);
546 myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true);
547 myEnfVertexWdg->SetDefaultText(tr("HYBRID_ENF_SELECT_VERTEX"), "QLineEdit { color: grey }");
549 QLabel* myXCoordLabel = new QLabel( tr( "HYBRID_ENF_VER_X_LABEL" ), myEnfGroup );
550 myXCoord = new SMESHGUI_SpinBox(myEnfGroup);
551 myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
552 QLabel* myYCoordLabel = new QLabel( tr( "HYBRID_ENF_VER_Y_LABEL" ), myEnfGroup );
553 myYCoord = new SMESHGUI_SpinBox(myEnfGroup);
554 myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
555 QLabel* myZCoordLabel = new QLabel( tr( "HYBRID_ENF_VER_Z_LABEL" ), myEnfGroup );
556 myZCoord = new SMESHGUI_SpinBox(myEnfGroup);
557 myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
558 QLabel* mySizeLabel = new QLabel( tr( "HYBRID_ENF_SIZE_LABEL" ), myEnfGroup );
559 mySizeValue = new SMESHGUI_SpinBox(myEnfGroup);
560 mySizeValue->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
562 QLabel* myGroupNameLabel = new QLabel( tr( "HYBRID_ENF_GROUP_LABEL" ), myEnfGroup );
563 myGroupName = new QLineEdit(myEnfGroup);
565 addVertexButton = new QPushButton(tr("HYBRID_ENF_ADD"),myEnfGroup);
566 addVertexButton->setEnabled(false);
567 removeVertexButton = new QPushButton(tr("HYBRID_ENF_REMOVE"),myEnfGroup);
568 // myGlobalGroupName = new QCheckBox(tr("HYBRID_ENF_VER_GROUPS"), myEnfGroup);
569 // myGlobalGroupName->setChecked(false);
571 // QGroupBox* GroupBox = new QGroupBox( myEnfGroup );
572 // QLabel* info = new QLabel( GroupBox );
573 // info->setText( tr( "HYBRID_ENF_VER_INFO" ) );
574 // info->setWordWrap( true );
575 // QVBoxLayout* GroupBoxVLayout = new QVBoxLayout( GroupBox );
576 // GroupBoxVLayout->setSpacing( 6 );
577 // GroupBoxVLayout->setMargin( 11 );
578 // GroupBoxVLayout->addWidget( info );
581 //anEnfLayout->addWidget(GroupBox, ENF_VER_WARNING, 0, 1, 2 );
582 anEnfLayout->addWidget(myEnforcedTableWidget, ENF_VER_VERTEX, 0, ENF_VER_NB_LINES, 1);
584 QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup);
585 anEnfLayout2->addWidget(myEnfVertexWdg, ENF_VER_VERTEX, 0, 1, 2);
586 anEnfLayout2->addWidget(myXCoordLabel, ENF_VER_X_COORD, 0, 1, 1);
587 anEnfLayout2->addWidget(myXCoord, ENF_VER_X_COORD, 1, 1, 1);
588 anEnfLayout2->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 0, 1, 1);
589 anEnfLayout2->addWidget(myYCoord, ENF_VER_Y_COORD, 1, 1, 1);
590 anEnfLayout2->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 0, 1, 1);
591 anEnfLayout2->addWidget(myZCoord, ENF_VER_Z_COORD, 1, 1, 1);
592 anEnfLayout2->addWidget(mySizeLabel, ENF_VER_SIZE, 0, 1, 1);
593 anEnfLayout2->addWidget(mySizeValue, ENF_VER_SIZE, 1, 1, 1);
594 anEnfLayout2->addWidget(myGroupNameLabel, ENF_VER_GROUP, 0, 1, 1);
595 anEnfLayout2->addWidget(myGroupName, ENF_VER_GROUP, 1, 1, 1);
596 anEnfLayout2->addWidget(addVertexButton, ENF_VER_BTN, 0, 1, 1);
597 anEnfLayout2->addWidget(removeVertexButton, ENF_VER_BTN, 1, 1, 1);
598 anEnfLayout2->setRowStretch(ENF_VER_NB_LINES, 1);
600 anEnfLayout->addLayout(anEnfLayout2, ENF_VER_VERTEX, 1,ENF_VER_NB_LINES, 1);
601 anEnfLayout->setRowStretch(ENF_VER_VERTEX, 10);
603 // Enforced meshes parameters
604 myEnfMeshGroup = new QWidget();
605 myLayersOnAllWrapCheck = new QCheckBox( tr( "HYBRID_LAYERS_ON_ALL_WRAP" ), myEnfMeshGroup );
606 QGridLayout* anEnfMeshLayout = new QGridLayout(myEnfMeshGroup);
608 myEnforcedMeshTableWidget = new QTableWidget(myEnfGroup);
609 myEnforcedMeshTableWidget->setRowCount( 0 );
610 myEnforcedMeshTableWidget->setColumnCount( ENF_MESH_NB_COLUMNS );
611 myEnforcedMeshTableWidget->setSortingEnabled(true);
612 myEnforcedMeshTableWidget->verticalHeader()->hide();
613 QStringList enforcedMeshHeaders;
614 enforcedMeshHeaders << tr( "HYBRID_ENF_NAME_COLUMN" )
615 << tr( "HYBRID_ENF_ENTRY_COLUMN" )
616 << tr( "HYBRID_ENF_MESH_CONSTRAINT_COLUMN" )
617 << tr( "HYBRID_ENF_GROUP_COLUMN" );
618 myEnforcedMeshTableWidget->setHorizontalHeaderLabels(enforcedMeshHeaders);
619 myEnforcedMeshTableWidget->horizontalHeader()->setStretchLastSection(true);
620 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
621 myEnforcedMeshTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
623 myEnforcedMeshTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
625 myEnforcedMeshTableWidget->setAlternatingRowColors(true);
626 myEnforcedMeshTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
627 myEnforcedMeshTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
628 myEnforcedMeshTableWidget->resizeColumnsToContents();
629 myEnforcedMeshTableWidget->hideColumn(ENF_MESH_ENTRY_COLUMN);
631 myEnforcedMeshTableWidget->setItemDelegate(new EnforcedMeshTableWidgetDelegate());
633 // myEnfMesh = SMESH::SMESH_Mesh::_nil();
634 // myEnfMeshArray = new SMESH::mesh_array();
636 myEnfMeshWdg = new StdMeshersGUI_ObjectReferenceParamWdg( SMESH::IDSOURCE, myEnfMeshGroup, /*multiSel=*/true);
637 myEnfMeshWdg->SetDefaultText(tr("HYBRID_ENF_SELECT_MESH"), "QLineEdit { color: grey }");
639 myEnfMeshWdg->AvoidSimultaneousSelection(myEnfVertexWdg);
640 ////myEnfMeshWdg->hide(); //may be used later
642 QLabel* myMeshConstraintLabel = new QLabel( tr( "HYBRID_ENF_MESH_CONSTRAINT_LABEL" ), myEnfMeshGroup );
643 myEnfMeshConstraint = new QComboBox(myEnfMeshGroup);
644 myEnfMeshConstraint->insertItems(0,myEnfMeshConstraintLabels);
645 myEnfMeshConstraint->setEditable(false);
646 myEnfMeshConstraint->setCurrentIndex(2); //EZ: use mesh group of faces for a layer
647 myMeshConstraintLabel->hide(); //may be used later
648 myEnfMeshConstraint->hide(); //may be used later
650 QLabel* myMeshGroupNameLabel = new QLabel( tr( "HYBRID_ENF_GROUP_LABEL" ), myEnfMeshGroup );
651 myMeshGroupName = new QLineEdit(myEnfMeshGroup);
652 myMeshGroupNameLabel->hide(); //may be used later
653 myMeshGroupName->hide(); //may be used later
655 addEnfMeshButton = new QPushButton(tr("HYBRID_ENF_ADD"),myEnfMeshGroup);
656 // addEnfMeshButton->setEnabled(false);
657 removeEnfMeshButton = new QPushButton(tr("HYBRID_ENF_REMOVE"),myEnfMeshGroup);
659 // QGroupBox* GroupBox2 = new QGroupBox( myEnfMeshGroup );
660 // QLabel* info2 = new QLabel( GroupBox2 );
661 // info2->setText( tr( "HYBRID_ENF_MESH_INFO" ) );
662 // info2->setWordWrap( true );
663 // QVBoxLayout* GroupBox2VLayout = new QVBoxLayout( GroupBox2 );
664 // GroupBox2VLayout->setSpacing( 6 );
665 // GroupBox2VLayout->setMargin( 11 );
666 // GroupBox2VLayout->addWidget( info2 );
668 // anEnfMeshLayout->addWidget( GroupBox2, ENF_MESH_WARNING, 0, 1, 2 );
669 anEnfMeshLayout->addWidget(myLayersOnAllWrapCheck, ENF_MESH_MESH, 0, 1 , 1);
670 anEnfMeshLayout->addWidget(myEnforcedMeshTableWidget, ENF_MESH_MESH+1, 0, ENF_MESH_NB_LINES , 1);
672 QGridLayout* anEnfMeshLayout2 = new QGridLayout(myEnfMeshGroup);
673 anEnfMeshLayout2->addWidget(myEnfMeshWdg, ENF_MESH_MESH, 0, 1, 2);
674 //TODO remove or not be lateful to select layers...
675 //anEnfMeshLayout2->addWidget(myMeshConstraintLabel, ENF_MESH_CONSTRAINT, 0, 1, 1);
676 //anEnfMeshLayout2->addWidget(myEnfMeshConstraint, ENF_MESH_CONSTRAINT, 1, 1, 1);
677 //anEnfMeshLayout2->addWidget(myMeshGroupNameLabel, ENF_MESH_GROUP, 0, 1, 1);
678 //anEnfMeshLayout2->addWidget(myMeshGroupName, ENF_MESH_GROUP, 1, 1, 1);
679 anEnfMeshLayout2->addWidget(addEnfMeshButton, ENF_MESH_BTN, 0, 1, 1);
680 anEnfMeshLayout2->addWidget(removeEnfMeshButton, ENF_MESH_BTN, 1, 1, 1);
681 anEnfMeshLayout2->setRowStretch(ENF_MESH_NB_LINES, 1);
683 anEnfMeshLayout->addLayout(anEnfMeshLayout2, ENF_MESH_MESH+1, 1, ENF_MESH_NB_LINES, 1);
684 anEnfMeshLayout->setRowStretch(ENF_MESH_MESH, 10);
687 // selection of faces
689 QWidget* faceSelGroup = new QWidget( dlg() );
690 QGridLayout* faceSelLayout = new QGridLayout( faceSelGroup );
692 QLabel* facesLbl = new QLabel( tr("HYBRID_FACE_IDS"), faceSelGroup );
693 faceSelLayout->addWidget( facesLbl, 0, 0 );
695 myFaceSelector = new StdMeshersGUI_SubShapeSelectorWdg( faceSelGroup, TopAbs_FACE, true, true );
696 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
697 QString aSubEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
698 myFaceSelector->SetGeomShapeEntry( aSubEntry, aMainEntry );
699 faceSelLayout->addWidget( myFaceSelector, 1, 0, 2, 2 );
700 faceSelLayout->setRowStretch( 1, 10);
704 tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
705 tab->insertTab( ADV_TAB, myAdvGroup, tr( "HYBRID_ADV_ARGS" ) );
706 tab->insertTab( ENF_MESH_TAB, myEnfMeshGroup, tr( "HYBRID_ENFORCED_MESHES" ) );
707 if ( aMainEntry.isEmpty() && aSubEntry.isEmpty() ) // mesh not based of geometry
708 faceSelGroup->hide();
710 tab->insertTab( FACE_SEL_TAB, faceSelGroup, tr( "HYBRID_FACES_TAB" ));
711 tab->setCurrentIndex( STD_TAB );
714 connect( tab, SIGNAL( currentChanged ( int )), this, SLOT( onTabChanged( int ) ) );
715 //connect( myLayersOnAllWrapCheck, SIGNAL( toggled( bool ) ), this, SLOT( onLayersOnAllWrap(bool)));
716 connect( myLayersOnAllWrapCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
717 //connect( myToMeshHolesCheck, SIGNAL( toggled( bool ) ), this, SLOT( onToMeshHoles(bool)));
718 //connect( myAdvWidget->maxMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
719 //connect( myAdvWidget->initialMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
720 //connect( myAdvWidget->boundaryRecoveryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
722 //connect( myBoundaryLayersGrowthCombo, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
723 //connect( myElementGenerationCombo, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
724 connect( myAddMultinormalsCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
725 connect( mySmoothNormalsCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
727 connect( myAdvWidget->logInFileCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
728 connect( myAdvWidget->keepWorkingFilesCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
729 connect( myAdvWidget->workingDirectoryPushButton, SIGNAL( clicked() ), this, SLOT( onDirBtnClicked() ) );
731 connect( myEnforcedTableWidget, SIGNAL( itemClicked(QTableWidgetItem *)), this, SLOT( synchronizeCoords() ) );
732 connect( myEnforcedTableWidget, SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
733 connect( myEnforcedTableWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
734 connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertex() ) );
735 connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
736 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
737 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
738 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
739 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
740 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
741 connect( mySizeValue, SIGNAL( textChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) );
742 connect( myXCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
743 connect( myYCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
744 connect( myZCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
745 connect( mySizeValue, SIGNAL( valueChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) );
746 connect( this, SIGNAL( vertexDefined(bool) ), addVertexButton, SLOT( setEnabled(bool) ) );
748 connect( addEnfMeshButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedMesh() ) );
749 connect( removeEnfMeshButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedMesh() ) );
750 // connect( myEnfMeshWdg, SIGNAL( contentModified()), this, SLOT( checkEnfMeshIsDefined() ) );
751 // connect( myEnfMeshConstraint, SIGNAL( currentIndexChanged(int) ), this, SLOT( checkEnfMeshIsDefined() ) );
752 // connect( this, SIGNAL( enfMeshDefined(bool) ), addEnfMeshButton, SLOT( setEnabled(bool) ) );
758 * This method checks if an enforced vertex is defined;
760 void HYBRIDPluginGUI_HypothesisCreator::clearEnfVertexSelection()
762 if (myEnfVertexWdg->NbObjects() != 0) {
763 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
764 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
765 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
766 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
767 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
769 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
770 that->checkVertexIsDefined();
774 * This method checks if an enforced vertex is defined;
776 void HYBRIDPluginGUI_HypothesisCreator::checkVertexIsDefined()
778 bool enfVertexIsDefined = false;
779 enfVertexIsDefined = (!mySizeValue->GetString().isEmpty() &&
780 (!myEnfVertexWdg->NbObjects() == 0 ||
781 (myEnfVertexWdg->NbObjects() == 0 && !myXCoord->GetString().isEmpty()
782 && !myYCoord->GetString().isEmpty()
783 && !myZCoord->GetString().isEmpty())));
784 emit vertexDefined(enfVertexIsDefined);
788 * This method checks if an enforced mesh is defined;
790 void HYBRIDPluginGUI_HypothesisCreator::checkEnfMeshIsDefined()
792 emit enfMeshDefined( myEnfVertexWdg->NbObjects() != 0);
796 * This method resets the content of the X, Y, Z, size and GroupName widgets;
798 void HYBRIDPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
800 myXCoord->setCleared(true);
801 myYCoord->setCleared(true);
802 myZCoord->setCleared(true);
803 // mySizeValue->setCleared(true);
804 myXCoord->setText("");
805 myYCoord->setText("");
806 myZCoord->setText("");
807 // mySizeValue->setText("");
808 // myGroupName->setText("");
809 addVertexButton->setEnabled(false);
812 /** HYBRIDPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item)
813 This method updates the tooltip of a modified item. The QLineEdit widgets content
814 is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
816 void HYBRIDPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTableWidgetItem* item) {
817 int row = myEnforcedTableWidget->row(item);
819 QVariant vertexName = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole);
820 QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole);
821 QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole);
822 QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole);
823 QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole);
824 QVariant entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
825 QString groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole).toString();
827 clearEnforcedVertexWidgets();
829 if ( !x.isNull() || !entry.isNull()) {
830 QString toolTip = vertexName.toString();
831 toolTip += QString("(");
832 if (entry.isNull() || (!entry.isNull() && entry.toString() == "")) {
833 toolTip += x.toString();
834 toolTip += QString(", ") + y.toString();
835 toolTip += QString(", ") + z.toString();
838 toolTip += entry.toString();
839 toolTip += QString(")");
842 toolTip += QString("=") + size.toString();
844 if (!groupName.isEmpty())
845 toolTip += QString(" [") + groupName + QString("]");
847 for (int col=0;col<ENF_VER_NB_COLUMNS;col++)
848 myEnforcedTableWidget->item(row,col)->setToolTip(toolTip);
851 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
852 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
853 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
854 myXCoord->SetValue(x.toDouble());
855 myYCoord->SetValue(y.toDouble());
856 myZCoord->SetValue(z.toDouble());
857 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
858 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
859 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
862 mySizeValue->SetValue(size.toDouble());
864 if (!groupName.isEmpty())
865 myGroupName->setText(groupName);
869 void HYBRIDPluginGUI_HypothesisCreator::onSelectEnforcedVertex() {
870 int nbSelEnfVertex = myEnfVertexWdg->NbObjects();
871 clearEnforcedVertexWidgets();
872 if (nbSelEnfVertex == 1)
874 if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() )
877 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
878 if (myEnfVertex == GEOM::GEOM_Object::_nil())
880 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
881 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
882 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
883 if (CORBA::is_nil(measureOp))
887 measureOp->PointCoordinates (myEnfVertex, x, y, z);
888 if ( measureOp->IsDone() )
890 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
891 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
892 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
893 myXCoord->SetValue(x);
894 myYCoord->SetValue(y);
895 myZCoord->SetValue(z);
896 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
897 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
898 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
904 /** HYBRIDPluginGUI_HypothesisCreator::synchronizeCoords()
905 This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
906 of the enforced vertex clicked in the tree widget.
908 void HYBRIDPluginGUI_HypothesisCreator::synchronizeCoords() {
909 clearEnforcedVertexWidgets();
910 QList<QTableWidgetItem *> items = myEnforcedTableWidget->selectedItems();
911 // myEnfVertexWdg->disconnect(SIGNAL(contentModified()));
912 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
913 if (! items.isEmpty()) {
914 QTableWidgetItem *item;
917 if (items.size() == 1) {
919 row = myEnforcedTableWidget->row(item);
920 QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole);
921 QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole);
922 QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole);
923 QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole);
924 entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
925 if (!entry.isNull()) {
926 SMESH::string_array_var objIds = new SMESH::string_array;
928 objIds[0] = entry.toString().toStdString().c_str();
929 myEnfVertexWdg->SetObjects(objIds);
932 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
934 QVariant group = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole);
935 if (!x.isNull()/* && entry.isNull()*/) {
936 // disconnect( myXCoord, SIGNAL( textChanged(const QString &)), this, SLOT( onSelectEnforcedVertex() ) );
937 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
938 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
939 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
940 myXCoord->SetValue(x.toDouble());
941 myYCoord->SetValue(y.toDouble());
942 myZCoord->SetValue(z.toDouble());
943 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
944 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
945 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
948 mySizeValue->SetValue(size.toDouble());
950 if (!group.isNull() && (!x.isNull() || !entry.isNull()))
951 myGroupName->setText(group.toString());
954 QList<QString> entryList;
955 for (int i = 0; i < items.size(); ++i) {
957 row = myEnforcedTableWidget->row(item);
958 entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
960 entryList << entry.toString();
962 if (entryList.size() > 0) {
963 SMESH::string_array_var objIds = new SMESH::string_array;
964 objIds->length(entryList.size());
965 for (int i = 0; i < entryList.size() ; i++)
966 objIds[i] = entryList.at(i).toStdString().c_str();
967 myEnfVertexWdg->SetObjects(objIds);
970 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
975 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
977 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
978 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
979 that->checkVertexIsDefined();
982 /** HYBRIDPluginGUI_HypothesisCreator::addEnforcedMesh( meshName, geomEntry, elemType, size, groupName)
983 This method adds in the tree widget an enforced mesh from mesh, submesh or group with optionally size and and groupName.
985 void HYBRIDPluginGUI_HypothesisCreator::addEnforcedMesh(std::string name, std::string entry, int elementType, std::string groupName)
987 bool okToCreate = true;
988 QString itemEntry = "";
989 int itemElementType = 0;
990 int rowCount = myEnforcedMeshTableWidget->rowCount();
991 bool allColumns = true;
992 for (int row = 0;row<rowCount;row++) {
993 for (int col = 0 ; col < ENF_MESH_NB_COLUMNS ; col++) {
994 if (col == ENF_MESH_CONSTRAINT_COLUMN){
995 if (qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row, col)) == 0) {
1000 else if (myEnforcedMeshTableWidget->item(row, col) == 0) {
1004 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1005 QComboBox* itemComboBox = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row, col));
1006 itemElementType = itemComboBox->currentIndex();
1008 else if (col == ENF_MESH_ENTRY_COLUMN)
1009 itemEntry = myEnforcedMeshTableWidget->item(row, col)->data(Qt::EditRole).toString();
1015 if (itemEntry == QString(entry.c_str()) && itemElementType == elementType) {
1016 // // update group name
1017 // if (itemGroupName.toStdString() != groupName) {
1018 // myEnforcedMeshTableWidget->item(row, ENF_MESH_GROUP_COLUMN)->setData( Qt::EditRole, QVariant(groupName.c_str()));
1030 myEnforcedMeshTableWidget->setRowCount(rowCount+1);
1031 myEnforcedMeshTableWidget->setSortingEnabled(false);
1033 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++) {
1034 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1035 QComboBox* comboBox = new QComboBox();
1036 QPalette pal = comboBox->palette();
1037 pal.setColor(QPalette::Button, Qt::white);
1038 comboBox->setPalette(pal);
1039 comboBox->insertItems(0,myEnfMeshConstraintLabels);
1040 comboBox->setEditable(false);
1041 comboBox->setCurrentIndex(elementType);
1042 myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox);
1045 QTableWidgetItem* item = new QTableWidgetItem();
1046 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1048 case ENF_MESH_NAME_COLUMN:
1049 item->setData( 0, name.c_str() );
1050 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1051 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1053 case ENF_MESH_ENTRY_COLUMN:
1054 item->setData( 0, entry.c_str() );
1055 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1056 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1058 case ENF_MESH_GROUP_COLUMN:
1059 item->setData( 0, groupName.c_str() );
1060 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1068 // connect( myEnforcedMeshTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1070 myEnforcedMeshTableWidget->setSortingEnabled(true);
1071 // myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1072 // updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1076 /** HYBRIDPluginGUI_HypothesisCreator::addEnforcedVertex( x, y, z, size, vertexName, geomEntry, groupName)
1077 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.
1079 void HYBRIDPluginGUI_HypothesisCreator::addEnforcedVertex(double x, double y, double z, double size, std::string vertexName, std::string geomEntry, std::string groupName, bool isCompound)
1081 myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1082 bool okToCreate = true;
1083 double itemX,itemY,itemZ,itemSize = 0;
1084 QString itemEntry, itemGroupName = QString("");
1085 // bool itemIsCompound;
1086 int rowCount = myEnforcedTableWidget->rowCount();
1089 for (int row = 0;row<rowCount;row++) {
1091 for (int col = 0 ; col < ENF_VER_NB_COLUMNS ; col++) {
1092 if (myEnforcedTableWidget->item(row, col) == 0) {
1097 data = myEnforcedTableWidget->item(row, col)->data(Qt::EditRole);
1098 if (!data.isNull()) {
1100 case ENF_VER_GROUP_COLUMN:
1101 itemGroupName = data.toString();
1103 case ENF_VER_ENTRY_COLUMN:
1104 itemEntry = data.toString();
1106 // case ENF_VER_COMPOUND_COLUMN:
1107 // itemIsCompound = data.toBool();
1109 case ENF_VER_X_COLUMN:
1110 itemX = data.toDouble();
1112 case ENF_VER_Y_COLUMN:
1113 itemY = data.toDouble();
1115 case ENF_VER_Z_COLUMN:
1116 itemZ = data.toDouble();
1118 case ENF_VER_SIZE_COLUMN:
1119 itemSize = data.toDouble();
1131 if (( !isCompound && ((itemX == x) && (itemY == y) && (itemZ == z))) || /*( (itemEntry.toStdString() != "") && */ (itemEntry.toStdString() == geomEntry)/*)*/) {
1133 if (itemSize != size) {
1134 myEnforcedTableWidget->item(row, ENF_VER_SIZE_COLUMN)->setData( Qt::EditRole, QVariant(size));
1136 // update group name
1137 if (itemGroupName.toStdString() != groupName) {
1138 myEnforcedTableWidget->item(row, ENF_VER_GROUP_COLUMN)->setData( Qt::EditRole, QVariant(groupName.c_str()));
1145 if (geomEntry.empty()) {
1152 if (geomEntry.empty()) {
1159 QString myVertexName;
1160 while(indexRef != vertexIndex) {
1161 indexRef = vertexIndex;
1162 if (vertexName.empty())
1163 myVertexName = QString("Vertex #%1").arg(vertexIndex);
1165 myVertexName = QString(vertexName.c_str());
1167 for (int row = 0;row<rowCount;row++) {
1168 QString name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString();
1169 if (myVertexName == name) {
1176 myEnforcedTableWidget->setRowCount(rowCount+1);
1177 myEnforcedTableWidget->setSortingEnabled(false);
1178 for (int col=0;col<ENF_VER_NB_COLUMNS;col++) {
1179 QTableWidgetItem* item = new QTableWidgetItem();
1180 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1182 case ENF_VER_NAME_COLUMN:
1183 item->setData( Qt::EditRole, myVertexName );
1184 if (!geomEntry.empty()) {
1186 item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1188 item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1191 case ENF_VER_X_COLUMN:
1193 item->setData( 0, QVariant(x) );
1195 case ENF_VER_Y_COLUMN:
1197 item->setData( 0, QVariant(y) );
1199 case ENF_VER_Z_COLUMN:
1201 item->setData( 0, QVariant(z) );
1203 case ENF_VER_SIZE_COLUMN:
1204 item->setData( 0, QVariant(size) );
1206 case ENF_VER_ENTRY_COLUMN:
1207 if (!geomEntry.empty())
1208 item->setData( 0, QString(geomEntry.c_str()) );
1210 case ENF_VER_COMPOUND_COLUMN:
1211 item->setData( Qt::CheckStateRole, isCompound );
1212 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
1214 case ENF_VER_GROUP_COLUMN:
1215 if (!groupName.empty())
1216 item->setData( 0, QString(groupName.c_str()) );
1222 myEnforcedTableWidget->setItem(rowCount,col,item);
1225 connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1227 myEnforcedTableWidget->setSortingEnabled(true);
1228 // myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1229 updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1232 /** HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedMesh()
1233 This method is called when a item is added into the enforced meshes tree widget
1235 void HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedMesh()
1238 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1240 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1241 myEnfMeshWdg->deactivateSelection();
1243 for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column)
1244 myEnforcedMeshTableWidget->resizeColumnToContents(column);
1247 int selEnfMeshes = myEnfMeshWdg->NbObjects();
1248 if (selEnfMeshes == 0)
1251 std::string groupName = myMeshGroupName->text().toStdString();
1252 // if (myGlobalGroupName->isChecked())
1253 // groupName = myGlobalGroupName->text().toStdString();
1255 if (boost::trim_copy(groupName).empty())
1256 groupName = "LayersGroup"; //have to be not empty until non used
1258 int elementType = myEnfMeshConstraint->currentIndex();
1261 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1262 _PTR(SObject) aSObj; //SMESH::SMESH_IDSource::_nil;
1263 QString meshEntry = myEnfMeshWdg->GetValue();
1265 if (selEnfMeshes == 1)
1267 // myEnfMesh = myEnfMeshWdg->GetObject< SMESH::SMESH_IDSource >();
1268 // std::string entry = myEnfMeshWdg->GetValue();
1269 aSObj = aStudy->FindObjectID(meshEntry.toStdString().c_str());
1270 CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy);
1271 if (!CORBA::is_nil(anObj)) {
1272 // SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1273 addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
1278 QStringList meshEntries = meshEntry.split(" ", QString::SkipEmptyParts);
1279 QStringListIterator meshEntriesIt (meshEntries);
1280 while (meshEntriesIt.hasNext()) {
1281 aSObj = aStudy->FindObjectID(meshEntriesIt.next().toStdString().c_str());
1282 CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy);
1283 if (!CORBA::is_nil(anObj)) {
1284 // SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1285 addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
1290 myEnfVertexWdg->SetObject(SMESH::SMESH_IDSource::_nil());
1292 for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column)
1293 myEnforcedMeshTableWidget->resizeColumnToContents(column);
1297 /** HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedVertex()
1298 This method is called when a item is added into the enforced vertices tree widget
1300 void HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedVertex()
1303 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1305 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1306 myEnfVertexWdg->deactivateSelection();
1308 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1309 myEnforcedTableWidget->resizeColumnToContents(column);
1312 int selEnfVertex = myEnfVertexWdg->NbObjects();
1313 bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty());
1314 if ((selEnfVertex == 0) && coordsEmpty)
1317 std::string groupName = myGroupName->text().toStdString();
1318 // if (myGlobalGroupName->isChecked())
1319 // groupName = myGlobalGroupName->text().toStdString();
1321 if (boost::trim_copy(groupName).empty())
1324 double size = mySizeValue->GetValue();
1326 if (selEnfVertex <= 1)
1328 double x = 0, y = 0, z=0;
1329 if (myXCoord->GetString() != "") {
1330 x = myXCoord->GetValue();
1331 y = myYCoord->GetValue();
1332 z = myZCoord->GetValue();
1334 if (selEnfVertex == 1) {
1335 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >();
1336 std::string entry = "";
1337 if (myEnfVertex != GEOM::GEOM_Object::_nil())
1338 entry = myEnfVertex->GetStudyEntry();
1339 addEnforcedVertex(x, y, z, size, myEnfVertex->GetName(),entry, groupName, myEnfVertex->GetShapeType() == GEOM::COMPOUND);
1342 addEnforcedVertex(x, y, z, size, "", "", groupName);
1347 if ( CORBA::is_nil(getGeomEngine()))
1350 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
1351 if (CORBA::is_nil(measureOp))
1354 CORBA::Double x = 0, y = 0,z = 0;
1355 for (int j = 0 ; j < selEnfVertex ; j++)
1357 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j);
1358 if (myEnfVertex == GEOM::GEOM_Object::_nil())
1360 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1361 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1362 if ( measureOp->IsDone() )
1363 addEnforcedVertex(x, y, z, size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1364 } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) {
1365 addEnforcedVertex(0., 0., 0., size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName, true);
1370 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1372 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1373 myEnforcedTableWidget->resizeColumnToContents(column);
1376 /** HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedMesh()
1377 This method is called when a item is removed from the enforced meshes tree widget
1379 void HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedMesh()
1381 QList<int> selectedRows;
1382 QList<QTableWidgetItem *> selectedItems = myEnforcedMeshTableWidget->selectedItems();
1383 QTableWidgetItem* item;
1385 foreach( item, selectedItems ) {
1387 if (!selectedRows.contains( row ) )
1388 selectedRows.append(row);
1391 qSort( selectedRows );
1392 QListIterator<int> it( selectedRows );
1394 while ( it.hasPrevious() ) {
1395 row = it.previous();
1396 myEnforcedMeshTableWidget->removeRow(row );
1399 myEnforcedMeshTableWidget->selectionModel()->clearSelection();
1402 /** HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1403 This method is called when a item is removed from the enforced vertices tree widget
1405 void HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1407 QList<int> selectedRows;
1408 QList<QTableWidgetItem *> selectedItems = myEnforcedTableWidget->selectedItems();
1409 QTableWidgetItem* item;
1411 foreach( item, selectedItems ) {
1413 if (!selectedRows.contains( row ) )
1414 selectedRows.append(row);
1417 qSort( selectedRows );
1418 QListIterator<int> it( selectedRows );
1420 while ( it.hasPrevious() ) {
1421 row = it.previous();
1422 myEnforcedTableWidget->removeRow(row );
1425 myEnforcedTableWidget->selectionModel()->clearSelection();
1428 void HYBRIDPluginGUI_HypothesisCreator::onLayersOnAllWrap(bool isOn)
1430 // myToMakeGroupsOfDomains->setEnabled( isOn );
1432 // myToMakeGroupsOfDomains->setChecked( false );
1435 void HYBRIDPluginGUI_HypothesisCreator::onToMeshHoles(bool isOn)
1437 // myToMakeGroupsOfDomains->setEnabled( isOn );
1439 // myToMakeGroupsOfDomains->setChecked( false );
1442 void HYBRIDPluginGUI_HypothesisCreator::onDirBtnClicked()
1444 QString dir = SUIT_FileDlg::getExistingDirectory( dlg(), myAdvWidget->workingDirectoryLineEdit->text(), QString() );
1445 if ( !dir.isEmpty() )
1446 myAdvWidget->workingDirectoryLineEdit->setText( dir );
1449 void HYBRIDPluginGUI_HypothesisCreator::onTabChanged( int )
1451 myEnfVertexWdg->deactivateSelection();
1452 myEnfMeshWdg->deactivateSelection();
1453 myFaceSelector->ActivateSelection( false );
1454 myFaceSelector->ShowPreview( false );
1457 void HYBRIDPluginGUI_HypothesisCreator::updateWidgets()
1459 //customs automatic set
1460 //myToMakeGroupsOfDomains->setEnabled( myToMeshHolesCheck->isChecked() );
1461 //myAdvWidget->maxMemorySpin->setEnabled( myAdvWidget->maxMemoryCheck->isChecked() );
1462 //myAdvWidget->initialMemoryCheck->setEnabled( !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1463 //myAdvWidget->initialMemorySpin->setEnabled( myAdvWidget->initialMemoryCheck->isChecked() && !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1464 //myOptimizationLevelCombo->setEnabled( !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1465 myMultinormalsAngleSpin->setEnabled( myAddMultinormalsCheck->isChecked() );
1466 if ( sender() == myAdvWidget->logInFileCheck ||
1467 sender() == myAdvWidget->keepWorkingFilesCheck )
1469 bool logFileRemovable = myAdvWidget->logInFileCheck->isChecked() &&
1470 !myAdvWidget->keepWorkingFilesCheck->isChecked();
1472 myAdvWidget->removeLogOnSuccessCheck->setEnabled( logFileRemovable );
1474 bool enabled = !myLayersOnAllWrapCheck->isChecked();
1475 myEnforcedMeshTableWidget->setEnabled(enabled);
1476 addEnfMeshButton->setEnabled(enabled);
1477 removeEnfMeshButton->setEnabled(enabled);
1478 myEnfMeshWdg->setEnabled(enabled);
1479 if ( QTabWidget* tab = qobject_cast<QTabWidget*>( myStdGroup->parentWidget()->parentWidget() ))
1480 tab->setTabEnabled( FACE_SEL_TAB, enabled );
1483 bool HYBRIDPluginGUI_HypothesisCreator::checkParams(QString& msg) const
1486 if ( !QFileInfo( myAdvWidget->workingDirectoryLineEdit->text().trimmed() ).isWritable() ) {
1487 SUIT_MessageBox::warning( dlg(),
1488 tr( "SMESH_WRN_WARNING" ),
1489 tr( "HYBRID_PERMISSION_DENIED" ) );
1496 void HYBRIDPluginGUI_HypothesisCreator::retrieveParams() const
1498 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1499 HYBRIDHypothesisData data;
1500 readParamsFromHypo( data );
1503 myName->setText( data.myName );
1504 myLayersOnAllWrapCheck ->setChecked ( data.myLayersOnAllWrap );
1505 myToMeshHolesCheck ->setChecked ( data.myToMeshHoles );
1506 myToMakeGroupsOfDomains ->setChecked ( data.myToMakeGroupsOfDomains );
1507 myOptimizationLevelCombo ->setCurrentIndex( data.myOptimizationLevel );
1508 myAdvWidget->maxMemoryCheck ->setChecked ( data.myMaximumMemory > 0 );
1509 myAdvWidget->maxMemorySpin ->setValue ( qMax( data.myMaximumMemory,
1510 myAdvWidget->maxMemorySpin->minimum() ));
1511 myAdvWidget->initialMemoryCheck ->setChecked ( data.myInitialMemory > 0 );
1512 myAdvWidget->initialMemorySpin ->setValue ( qMax( data.myInitialMemory,
1513 myAdvWidget->initialMemorySpin->minimum() ));
1515 myCollisionModeCombo ->setCurrentIndex( data.myCollisionMode );
1516 myBoundaryLayersGrowthCombo ->setCurrentIndex( data.myBoundaryLayersGrowth );
1517 myElementGenerationCombo ->setCurrentIndex( data.myElementGeneration );
1518 myAddMultinormalsCheck -> setChecked ( data.myAddMultinormals );
1519 mySmoothNormalsCheck -> setChecked ( data.mySmoothNormals );
1520 myHeightFirstLayerSpin -> setValue( data.myHeightFirstLayer );
1521 myNbOfBoundaryLayersSpin -> setValue( data.myNbOfBoundaryLayers );
1522 myBoundaryLayersProgressionSpin -> setValue( data.myBoundaryLayersProgression );
1523 myMultinormalsAngleSpin -> setValue( data.myMultinormalsAngle );
1524 myFaceSelector ->SetListOfIDs( data.myFaceWLIds );
1526 myAdvWidget->workingDirectoryLineEdit ->setText ( data.myWorkingDir );
1527 myAdvWidget->keepWorkingFilesCheck ->setChecked( data.myKeepFiles );
1528 myAdvWidget->verboseLevelSpin ->setValue ( data.myVerboseLevel );
1529 myAdvWidget->createNewNodesCheck ->setChecked( data.myToCreateNewNodes );
1530 myAdvWidget->removeInitialCentralPointCheck ->setChecked( data.myRemoveInitialCentralPoint );
1531 myAdvWidget->boundaryRecoveryCheck ->setChecked( data.myBoundaryRecovery );
1532 myAdvWidget->FEMCorrectionCheck ->setChecked( data.myFEMCorrection );
1533 myAdvWidget->gradationSpinBox ->setValue ( data.myGradation );
1534 myAdvWidget->myAdvOptionsTable ->SetCustomOptions( data.myTextOption );
1535 myAdvWidget->logInFileCheck ->setChecked( !data.myLogInStandardOutput );
1536 myAdvWidget->removeLogOnSuccessCheck ->setChecked( data.myRemoveLogOnSuccess );
1538 TEnfVertexList::const_iterator it;
1540 myEnforcedTableWidget->clearContents();
1541 myEnforcedTableWidget->setSortingEnabled(false);
1542 myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1543 for(it = data.myEnforcedVertices.begin() ; it != data.myEnforcedVertices.end(); it++ )
1545 TEnfVertex* enfVertex = (*it);
1546 myEnforcedTableWidget->setRowCount(rowCount+1);
1548 for (int col=0;col<ENF_VER_NB_COLUMNS;col++) {
1549 QTableWidgetItem* item = new QTableWidgetItem();
1550 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1552 case ENF_VER_NAME_COLUMN:
1553 item->setData( 0, enfVertex->name.c_str() );
1554 if (!enfVertex->geomEntry.empty()) {
1555 if (enfVertex->isCompound)
1556 item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1558 item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1562 case ENF_VER_X_COLUMN:
1563 if (!enfVertex->isCompound) {
1564 item->setData( 0, enfVertex->coords.at(0) );
1567 case ENF_VER_Y_COLUMN:
1568 if (!enfVertex->isCompound) {
1569 item->setData( 0, enfVertex->coords.at(1) );
1572 case ENF_VER_Z_COLUMN:
1573 if (!enfVertex->isCompound) {
1574 item->setData( 0, enfVertex->coords.at(2) );
1577 case ENF_VER_SIZE_COLUMN:
1578 item->setData( 0, enfVertex->size );
1580 case ENF_VER_ENTRY_COLUMN:
1581 item->setData( 0, enfVertex->geomEntry.c_str() );
1583 case ENF_VER_COMPOUND_COLUMN:
1584 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
1585 item->setData( Qt::CheckStateRole, enfVertex->isCompound );
1587 case ENF_VER_GROUP_COLUMN:
1588 item->setData( 0, enfVertex->groupName.c_str() );
1594 myEnforcedTableWidget->setItem(rowCount,col,item);
1596 that->updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1600 connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1601 myEnforcedTableWidget->setSortingEnabled(true);
1603 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1604 myEnforcedTableWidget->resizeColumnToContents(column);
1606 // Update Enforced meshes QTableWidget
1607 TEnfMeshList::const_iterator itMesh;
1609 myEnforcedMeshTableWidget->clearContents();
1610 myEnforcedMeshTableWidget->setSortingEnabled(false);
1611 // myEnforcedMeshTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1612 for(itMesh = data.myEnforcedMeshes.begin() ; itMesh != data.myEnforcedMeshes.end(); itMesh++ )
1614 TEnfMesh* enfMesh = (*itMesh);
1615 myEnforcedMeshTableWidget->setRowCount(rowCount+1);
1617 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++) {
1618 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1619 QComboBox* comboBox = new QComboBox();
1620 QPalette pal = comboBox->palette();
1621 pal.setColor(QPalette::Button, Qt::white);
1622 comboBox->setPalette(pal);
1623 comboBox->insertItems(0,myEnfMeshConstraintLabels);
1624 comboBox->setEditable(false);
1625 comboBox->setCurrentIndex(enfMesh->elementType);
1626 myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox);
1629 QTableWidgetItem* item = new QTableWidgetItem();
1630 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1632 case ENF_MESH_NAME_COLUMN:
1633 item->setData( 0, enfMesh->name.c_str() );
1634 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1635 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1637 case ENF_MESH_ENTRY_COLUMN:
1638 item->setData( 0, enfMesh->entry.c_str() );
1639 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1640 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1642 case ENF_MESH_GROUP_COLUMN:
1643 item->setData( 0, enfMesh->groupName.c_str() );
1644 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1651 // myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1653 // that->updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1657 // connect( myEnforcedMeshTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1658 myEnforcedMeshTableWidget->setSortingEnabled(true);
1660 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++)
1661 myEnforcedMeshTableWidget->resizeColumnToContents(col);
1663 that->updateWidgets();
1664 that->checkVertexIsDefined();
1667 QString HYBRIDPluginGUI_HypothesisCreator::storeParams() const
1669 HYBRIDHypothesisData data;
1670 readParamsFromWidgets( data );
1671 storeParamsToHypo( data );
1673 QString valStr = "";
1675 if ( !data.myBoundaryRecovery )
1676 valStr = "-c " + QString::number( !data.myToMeshHoles );
1678 if ( data.myOptimizationLevel >= 0 && data.myOptimizationLevel < 5 && !data.myBoundaryRecovery) {
1679 const char* level[] = { "none" , "light" , "standard" , "standard+" , "strong" };
1681 valStr += level[ data.myOptimizationLevel ];
1683 if ( data.myMaximumMemory > 0 ) {
1685 valStr += QString::number( data.myMaximumMemory );
1687 if ( data.myInitialMemory > 0 && !data.myBoundaryRecovery ) {
1689 valStr += QString::number( data.myInitialMemory );
1692 valStr += QString::number( data.myVerboseLevel );
1694 if ( !data.myToCreateNewNodes )
1697 if ( data.myRemoveInitialCentralPoint )
1698 valStr += " -no_initial_central_point";
1700 if ( data.myBoundaryRecovery )
1703 if ( data.myFEMCorrection )
1706 if ( data.myGradation != 1.05 ) {
1707 valStr += " -Dcpropa=";
1708 valStr += QString::number( data.myGradation );
1712 valStr += data.myTextOption;
1714 // valStr += " #BEGIN ENFORCED VERTICES#";
1715 // // Add size map parameters storage
1716 // for (int i=0 ; i<mySmpModel->rowCount() ; i++) {
1718 // double x = mySmpModel->data(mySmpModel->index(i,ENF_VER_X_COLUMN)).toDouble();
1719 // double y = mySmpModel->data(mySmpModel->index(i,ENF_VER_Y_COLUMN)).toDouble();
1720 // double z = mySmpModel->data(mySmpModel->index(i,ENF_VER_Z_COLUMN)).toDouble();
1721 // double size = mySmpModel->data(mySmpModel->index(i,ENF_VER_SIZE_COLUMN)).toDouble();
1722 // valStr += QString::number( x );
1724 // valStr += QString::number( y );
1726 // valStr += QString::number( z );
1728 // valStr += QString::number( size );
1729 // if (i!=mySmpModel->rowCount()-1)
1732 // valStr += " #END ENFORCED VERTICES#";
1736 bool HYBRIDPluginGUI_HypothesisCreator::readParamsFromHypo( HYBRIDHypothesisData& h_data ) const
1738 HYBRIDPlugin::HYBRIDPlugin_Hypothesis_var h =
1739 HYBRIDPlugin::HYBRIDPlugin_Hypothesis::_narrow( initParamsHypothesis() );
1741 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
1742 h_data.myName = isCreation() && data ? hypName() : "";
1744 h_data.myCollisionMode = h->GetCollisionMode();
1745 h_data.myBoundaryLayersGrowth = h->GetBoundaryLayersGrowth();
1746 h_data.myElementGeneration = h->GetElementGeneration();
1747 h_data.myAddMultinormals = h->GetAddMultinormals();
1748 h_data.mySmoothNormals = h->GetSmoothNormals();
1749 h_data.myHeightFirstLayer = h->GetHeightFirstLayer();
1750 h_data.myBoundaryLayersProgression = h->GetBoundaryLayersProgression();
1751 h_data.myMultinormalsAngle = h->GetMultinormalsAngle();
1752 h_data.myNbOfBoundaryLayers = h->GetNbOfBoundaryLayers();
1753 h_data.myFaceWLIds = h->GetFacesWithLayers();
1755 h_data.myLayersOnAllWrap = h->GetLayersOnAllWrap();
1756 h_data.myToMeshHoles = h->GetToMeshHoles();
1757 h_data.myToMakeGroupsOfDomains = /*h->GetToMeshHoles() &&*/ h->GetToMakeGroupsOfDomains();
1758 h_data.myMaximumMemory = h->GetMaximumMemory();
1759 h_data.myInitialMemory = h->GetInitialMemory();
1760 h_data.myInitialMemory = h->GetInitialMemory();
1761 h_data.myOptimizationLevel = h->GetOptimizationLevel();
1763 h_data.myKeepFiles = h->GetKeepFiles();
1764 h_data.myWorkingDir = h->GetWorkingDirectory();
1765 h_data.myVerboseLevel = h->GetVerboseLevel();
1766 h_data.myToCreateNewNodes = h->GetToCreateNewNodes();
1767 h_data.myRemoveInitialCentralPoint = h->GetToRemoveCentralPoint();
1768 h_data.myBoundaryRecovery = h->GetToUseBoundaryRecoveryVersion();
1769 h_data.myFEMCorrection = h->GetFEMCorrection();
1770 h_data.myGradation = h->GetGradation();
1771 h_data.myTextOption = h->GetAdvancedOption();
1772 h_data.myLogInStandardOutput = h->GetStandardOutputLog();
1773 h_data.myRemoveLogOnSuccess = h->GetRemoveLogOnSuccess();
1775 HYBRIDPlugin::HYBRIDEnforcedVertexList_var vertices = h->GetEnforcedVertices();
1776 h_data.myEnforcedVertices.clear();
1777 for (CORBA::ULong i=0 ; i<vertices->length() ; i++) {
1778 TEnfVertex* myVertex = new TEnfVertex();
1779 myVertex->name = CORBA::string_dup(vertices[i].name.in());
1780 myVertex->geomEntry = CORBA::string_dup(vertices[i].geomEntry.in());
1781 myVertex->groupName = CORBA::string_dup(vertices[i].groupName.in());
1782 myVertex->size = vertices[i].size;
1783 myVertex->isCompound = vertices[i].isCompound;
1784 if (vertices[i].coords.length()) {
1785 for (CORBA::ULong c = 0; c < vertices[i].coords.length() ; c++)
1786 myVertex->coords.push_back(vertices[i].coords[c]);
1788 h_data.myEnforcedVertices.insert(myVertex);
1791 HYBRIDPlugin::HYBRIDEnforcedMeshList_var enfMeshes = h->GetEnforcedMeshes();
1792 h_data.myEnforcedMeshes.clear();
1793 for (CORBA::ULong i=0 ; i<enfMeshes->length() ; i++) {
1794 TEnfMesh* myEnfMesh = new TEnfMesh();
1795 myEnfMesh->name = CORBA::string_dup(enfMeshes[i].name.in());
1796 myEnfMesh->entry = CORBA::string_dup(enfMeshes[i].entry.in());
1797 myEnfMesh->groupName = CORBA::string_dup(enfMeshes[i].groupName.in());
1798 switch (enfMeshes[i].elementType) {
1800 myEnfMesh->elementType = 0;
1803 myEnfMesh->elementType = 1;
1806 myEnfMesh->elementType = 2;
1811 // myEnfMesh->elementType = enfMeshes[i].elementType;
1812 h_data.myEnforcedMeshes.insert(myEnfMesh);
1817 bool HYBRIDPluginGUI_HypothesisCreator::storeParamsToHypo( const HYBRIDHypothesisData& h_data ) const
1819 HYBRIDPlugin::HYBRIDPlugin_Hypothesis_var h =
1820 HYBRIDPlugin::HYBRIDPlugin_Hypothesis::_narrow( hypothesis() );
1826 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
1828 if ( h->GetLayersOnAllWrap() != h_data.myLayersOnAllWrap ) // avoid duplication of DumpPython commands
1829 h->SetLayersOnAllWrap ( h_data.myLayersOnAllWrap );
1830 if ( h->GetToMeshHoles() != h_data.myToMeshHoles ) // avoid duplication of DumpPython commands
1831 h->SetToMeshHoles ( h_data.myToMeshHoles );
1832 if ( h->GetToMakeGroupsOfDomains() != h_data.myToMakeGroupsOfDomains )
1833 h->SetToMakeGroupsOfDomains( h_data.myToMakeGroupsOfDomains );
1834 if ( h->GetMaximumMemory() != h_data.myMaximumMemory )
1835 h->SetMaximumMemory ( h_data.myMaximumMemory );
1836 if ( h->GetInitialMemory() != h_data.myInitialMemory )
1837 h->SetInitialMemory ( h_data.myInitialMemory );
1838 if ( h->GetInitialMemory() != h_data.myInitialMemory )
1839 h->SetInitialMemory ( h_data.myInitialMemory );
1840 if ( h->GetOptimizationLevel() != h_data.myOptimizationLevel )
1841 h->SetOptimizationLevel( h_data.myOptimizationLevel );
1843 if ( h->GetCollisionMode() != h_data.myCollisionMode )
1844 h->SetCollisionMode( h_data.myCollisionMode );
1845 if ( h->GetBoundaryLayersGrowth() != h_data.myBoundaryLayersGrowth )
1846 h->SetBoundaryLayersGrowth( h_data.myBoundaryLayersGrowth );
1847 if ( h->GetElementGeneration() != h_data.myElementGeneration )
1848 h->SetElementGeneration( h_data.myElementGeneration );
1850 if ( h->GetAddMultinormals() != h_data.myAddMultinormals )
1851 h->SetAddMultinormals ( h_data.myAddMultinormals );
1852 if ( h->GetSmoothNormals() != h_data.mySmoothNormals )
1853 h->SetSmoothNormals ( h_data.mySmoothNormals );
1854 if ( h->GetHeightFirstLayer() != h_data.myHeightFirstLayer )
1855 h->SetHeightFirstLayer ( h_data.myHeightFirstLayer );
1856 if ( h->GetBoundaryLayersProgression() != h_data.myBoundaryLayersProgression )
1857 h->SetBoundaryLayersProgression ( h_data.myBoundaryLayersProgression );
1858 if ( h->GetMultinormalsAngle() != h_data.myMultinormalsAngle )
1859 h->SetMultinormalsAngle ( h_data.myMultinormalsAngle );
1860 if ( h->GetNbOfBoundaryLayers() != h_data.myNbOfBoundaryLayers )
1861 h->SetNbOfBoundaryLayers ( h_data.myNbOfBoundaryLayers );
1862 h->SetFacesWithLayers( h_data.myFaceWLIds );
1864 if ( h->GetKeepFiles() != h_data.myKeepFiles)
1865 h->SetKeepFiles ( h_data.myKeepFiles);
1866 if ( h->GetWorkingDirectory() != h_data.myWorkingDir )
1867 h->SetWorkingDirectory ( h_data.myWorkingDir.toLatin1().constData() );
1868 if ( h->GetVerboseLevel() != h_data.myVerboseLevel )
1869 h->SetVerboseLevel ( h_data.myVerboseLevel );
1870 if ( h->GetToCreateNewNodes() != h_data.myToCreateNewNodes )
1871 h->SetToCreateNewNodes ( h_data.myToCreateNewNodes );
1872 if ( h->GetToRemoveCentralPoint() != h_data.myRemoveInitialCentralPoint )
1873 h->SetToRemoveCentralPoint ( h_data.myRemoveInitialCentralPoint );
1874 if ( h->GetToUseBoundaryRecoveryVersion() != h_data.myBoundaryRecovery )
1875 h->SetToUseBoundaryRecoveryVersion ( h_data.myBoundaryRecovery );
1876 if ( h->GetFEMCorrection() != h_data.myFEMCorrection )
1877 h->SetFEMCorrection ( h_data.myFEMCorrection );
1878 if ( h->GetGradation() != h_data.myGradation )
1879 h->SetGradation ( h_data.myGradation );
1880 if ( h->GetTextOption() != h_data.myTextOption )
1881 h->SetAdvancedOption ( h_data.myTextOption.toLatin1().constData() );
1882 if ( h->GetStandardOutputLog() != h_data.myLogInStandardOutput )
1883 h->SetStandardOutputLog ( h_data.myLogInStandardOutput );
1884 if ( h->GetRemoveLogOnSuccess() != h_data.myRemoveLogOnSuccess )
1885 h->SetRemoveLogOnSuccess ( h_data.myRemoveLogOnSuccess );
1887 // Enforced vertices
1888 //int nbVertex = (int) h_data.myEnforcedVertices.size();
1889 HYBRIDPlugin::HYBRIDEnforcedVertexList_var vertexHyp = h->GetEnforcedVertices();
1890 int nbVertexHyp = vertexHyp->length();
1893 // 1. Clear all enforced vertices in hypothesis
1894 // 2. Add new enforced vertex according to h_data
1895 if ( nbVertexHyp > 0)
1896 h->ClearEnforcedVertices();
1898 TEnfVertexList::const_iterator it;
1899 double x = 0, y = 0, z = 0;
1900 for(it = h_data.myEnforcedVertices.begin() ; it != h_data.myEnforcedVertices.end(); it++ ) {
1901 TEnfVertex* enfVertex = (*it);
1903 if (enfVertex->coords.size()) {
1904 x = enfVertex->coords.at(0);
1905 y = enfVertex->coords.at(1);
1906 z = enfVertex->coords.at(2);
1908 ok = h->p_SetEnforcedVertex( enfVertex->size, x, y, z, enfVertex->name.c_str(), enfVertex->geomEntry.c_str(), enfVertex->groupName.c_str(), enfVertex->isCompound);
1912 //int nbEnfMeshes = (int) h_data.myEnforcedMeshes.size();
1913 HYBRIDPlugin::HYBRIDEnforcedMeshList_var enfMeshListHyp = h->GetEnforcedMeshes();
1914 int nbEnfMeshListHyp = enfMeshListHyp->length();
1917 // 1. Clear all enforced vertices in hypothesis
1918 // 2. Add new enforced vertex according to h_data
1919 if ( nbEnfMeshListHyp > 0)
1920 h->ClearEnforcedMeshes();
1922 TEnfMeshList::const_iterator itEnfMesh;
1924 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1926 for(itEnfMesh = h_data.myEnforcedMeshes.begin() ; itEnfMesh != h_data.myEnforcedMeshes.end(); itEnfMesh++ ) {
1927 TEnfMesh* enfMesh = (*itEnfMesh);
1929 _PTR(SObject) aSObj = aStudy->FindObjectID(enfMesh->entry.c_str());
1930 SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1932 SMESH::ElementType elementType;
1933 switch(enfMesh->elementType) {
1935 elementType = SMESH::NODE;
1938 elementType = SMESH::EDGE;
1941 elementType = SMESH::FACE;
1947 std::cout << "h->p_SetEnforcedMesh(theSource, "<< elementType <<", \""<< enfMesh->name << "\", \"" << enfMesh->groupName.c_str() <<"\")"<<std::endl;
1948 ok = h->p_SetEnforcedMesh(theSource, elementType, enfMesh->name.c_str(), enfMesh->groupName.c_str());
1951 // catch(const std::exception& ex) {
1952 // std::cout << "Exception: " << ex.what() << std::endl;
1955 catch ( const SALOME::SALOME_Exception& ex )
1957 SalomeApp_Tools::QtCatchCorbaException( ex );
1963 bool HYBRIDPluginGUI_HypothesisCreator::readParamsFromWidgets( HYBRIDHypothesisData& h_data ) const
1965 h_data.myName = myName ? myName->text() : "";
1966 h_data.myLayersOnAllWrap = myLayersOnAllWrapCheck->isChecked();
1967 h_data.myToMeshHoles = myToMeshHolesCheck->isChecked();
1968 h_data.myToMakeGroupsOfDomains = myToMakeGroupsOfDomains->isChecked();
1969 h_data.myMaximumMemory = myAdvWidget->maxMemoryCheck->isChecked() ? myAdvWidget->maxMemorySpin->value() : -1;
1970 h_data.myInitialMemory = myAdvWidget->initialMemoryCheck->isChecked() ? myAdvWidget->initialMemorySpin->value() : -1;
1971 h_data.myOptimizationLevel = myOptimizationLevelCombo->currentIndex();
1973 h_data.myCollisionMode = myCollisionModeCombo->currentIndex();
1974 h_data.myBoundaryLayersGrowth = myBoundaryLayersGrowthCombo->currentIndex();
1975 h_data.myElementGeneration = myElementGenerationCombo->currentIndex();
1976 h_data.myAddMultinormals = myAddMultinormalsCheck->isChecked();
1977 h_data.mySmoothNormals = mySmoothNormalsCheck->isChecked();
1979 h_data.myHeightFirstLayer = myHeightFirstLayerSpin -> value();
1980 h_data.myNbOfBoundaryLayers = myNbOfBoundaryLayersSpin -> value();
1981 h_data.myBoundaryLayersProgression = myBoundaryLayersProgressionSpin -> value();
1982 h_data.myMultinormalsAngle = myMultinormalsAngleSpin -> value();
1983 h_data.myFaceWLIds = myFaceSelector->GetListOfIDs();
1985 h_data.myKeepFiles = myAdvWidget->keepWorkingFilesCheck->isChecked();
1986 h_data.myWorkingDir = myAdvWidget->workingDirectoryLineEdit->text().trimmed();
1987 h_data.myVerboseLevel = myAdvWidget->verboseLevelSpin->value();
1988 h_data.myToCreateNewNodes = myAdvWidget->createNewNodesCheck->isChecked();
1989 h_data.myRemoveInitialCentralPoint = myAdvWidget->removeInitialCentralPointCheck->isChecked();
1990 h_data.myBoundaryRecovery = myAdvWidget->boundaryRecoveryCheck->isChecked();
1991 h_data.myFEMCorrection = myAdvWidget->FEMCorrectionCheck->isChecked();
1992 h_data.myGradation = myAdvWidget->gradationSpinBox->value();
1993 h_data.myTextOption = myAdvWidget->myAdvOptionsTable->GetCustomOptions();
1994 h_data.myLogInStandardOutput = !myAdvWidget->logInFileCheck->isChecked();
1995 h_data.myRemoveLogOnSuccess = myAdvWidget->removeLogOnSuccessCheck->isChecked();
1997 // Enforced vertices
1998 h_data.myEnforcedVertices.clear();
1999 QVariant valueX, valueY, valueZ;
2000 for (int row=0 ; row<myEnforcedTableWidget->rowCount() ; row++) {
2002 TEnfVertex *myVertex = new TEnfVertex();
2003 myVertex->name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString();
2004 myVertex->geomEntry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString();
2005 if (myVertex->geomEntry.size())
2006 myVertex->groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
2007 if (myVertex->groupName.size())
2008 valueX = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data(Qt::EditRole);
2009 valueY = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data(Qt::EditRole);
2010 valueZ = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data(Qt::EditRole);
2011 if (!valueX.isNull() && !valueY.isNull() && !valueZ.isNull()) {
2012 myVertex->coords.push_back(valueX.toDouble());
2013 myVertex->coords.push_back(valueY.toDouble());
2014 myVertex->coords.push_back(valueZ.toDouble());
2016 myVertex->size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data(Qt::EditRole).toDouble();
2017 myVertex->isCompound = myEnforcedTableWidget->item(row,ENF_VER_COMPOUND_COLUMN)->data(Qt::CheckStateRole).toBool();
2018 h_data.myEnforcedVertices.insert(myVertex);
2022 h_data.myEnforcedMeshes.clear();
2024 for (int row=0 ; row<myEnforcedMeshTableWidget->rowCount() ; row++) {
2026 TEnfMesh *myEnfMesh = new TEnfMesh();
2027 myEnfMesh->name = myEnforcedMeshTableWidget->item(row,ENF_MESH_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString();
2028 myEnfMesh->entry = myEnforcedMeshTableWidget->item(row,ENF_MESH_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString();
2029 myEnfMesh->groupName = myEnforcedMeshTableWidget->item(row,ENF_MESH_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
2030 QComboBox* combo = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row,ENF_MESH_CONSTRAINT_COLUMN));
2031 myEnfMesh->elementType = combo->currentIndex();
2032 h_data.myEnforcedMeshes.insert(myEnfMesh);
2033 std::cout << "h_data.myEnforcedMeshes.size(): " << h_data.myEnforcedMeshes.size() << std::endl;
2039 QString HYBRIDPluginGUI_HypothesisCreator::caption() const
2041 return tr( "HYBRID_TITLE" );
2044 QPixmap HYBRIDPluginGUI_HypothesisCreator::icon() const
2046 return SUIT_Session::session()->resourceMgr()->loadPixmap( "HYBRIDPlugin", tr( "ICON_DLG_HYBRID_PARAMETERS" ) );
2049 QString HYBRIDPluginGUI_HypothesisCreator::type() const
2051 return tr( "HYBRID_HYPOTHESIS" );
2054 QString HYBRIDPluginGUI_HypothesisCreator::helpPage() const
2056 return "hybrid_hypo_page.html";