1 // Copyright (C) 2007-2019 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : HYBRIDPluginGUI_HypothesisCreator.cxx
22 // Author : Christian VAN WAMBEKE (CEA)
25 #include "HYBRIDPluginGUI_HypothesisCreator.h"
26 #include "HYBRIDPluginGUI_Enums.h"
27 #include "HYBRIDPluginGUI_Dlg.h"
29 #include <GeometryGUI.h>
31 #include <SMESHGUI_HypothesesUtils.h>
32 #include <SMESHGUI_SpinBox.h>
33 #include <SMESHGUI_Utils.h>
34 #include <SMESH_NumberFilter.hxx>
35 #include <SMESH_TypeFilter.hxx>
36 #include <StdMeshersGUI_ObjectReferenceParamWdg.h>
37 #include <StdMeshersGUI_SubShapeSelectorWdg.h>
39 #include <LightApp_SelectionMgr.h>
40 #include <SUIT_Session.h>
41 #include <SUIT_MessageBox.h>
42 #include <SUIT_ResourceMgr.h>
43 #include <SUIT_FileDlg.h>
44 #include <SalomeApp_Tools.h>
45 #include <SalomeApp_TypeFilter.h>
47 #include <TopoDS_Iterator.hxx>
53 #include <QVBoxLayout>
54 #include <QGridLayout>
59 #include <QPushButton>
63 #include <QTableWidget>
64 #include <QTableWidgetItem>
65 #include <QHeaderView>
68 #include <utilities.h>
70 #include <boost/algorithm/string.hpp>
75 // #include <windows.h>
77 // #include <sys/sysinfo.h>
80 // int maxAvailableMemory()
83 // // See http://msdn.microsoft.com/en-us/library/aa366589.aspx
84 // MEMORYSTATUSEX statex;
85 // statex.dwLength = sizeof (statex);
86 // int err = GlobalMemoryStatusEx (&statex);
89 // statex.ullTotalPhys / 1024 / 1024 +
90 // statex.ullTotalPageFile / 1024 / 1024 +
91 // statex.ullTotalVirtual / 1024 / 1024;
92 // return (int) ( 0.7 * totMB );
96 // int err = sysinfo( &si );
99 // si.totalram * si.mem_unit / 1024 / 1024 +
100 // si.totalswap * si.mem_unit / 1024 / 1024 ;
101 // return (int) ( 0.7 * totMB );
109 // BEGIN EnforcedVertexTableWidgetDelegate
112 EnforcedVertexTableWidgetDelegate::EnforcedVertexTableWidgetDelegate(QObject *parent)
113 : QItemDelegate(parent)
117 QWidget *EnforcedVertexTableWidgetDelegate::createEditor(QWidget *parent,
118 const QStyleOptionViewItem & option ,
119 const QModelIndex & index ) const
121 QModelIndex father = index.parent();
122 QString entry = father.child(index.row(), ENF_VER_ENTRY_COLUMN).data().toString();
124 if (index.column() == ENF_VER_X_COLUMN ||
125 index.column() == ENF_VER_Y_COLUMN ||
126 index.column() == ENF_VER_Z_COLUMN ||
127 index.column() == ENF_VER_SIZE_COLUMN) {
128 SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent);
129 if (index.column() == ENF_VER_SIZE_COLUMN)
130 editor->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
132 editor->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
133 editor->setReadOnly(!entry.isEmpty());
134 editor->setDisabled(!entry.isEmpty());
137 // else if (index.column() == ENF_VER_COMPOUND_COLUMN) {
138 // QCheckBox *editor = new QCheckBox(parent);
139 // editor->setDisabled(!entry.isEmpty());
142 else if (index.column() == ENF_VER_GROUP_COLUMN ||
143 index.column() == ENF_VER_NAME_COLUMN) {
145 QLineEdit *editor = new QLineEdit(parent);
146 if (index.column() != ENF_VER_GROUP_COLUMN) {
147 editor->setReadOnly(!entry.isEmpty());
148 editor->setDisabled(!entry.isEmpty());
152 return QItemDelegate::createEditor(parent, option, index);
155 void EnforcedVertexTableWidgetDelegate::setEditorData(QWidget *editor,
156 const QModelIndex &index) const
158 if (index.column() == ENF_VER_X_COLUMN ||
159 index.column() == ENF_VER_Y_COLUMN ||
160 index.column() == ENF_VER_Z_COLUMN ||
161 index.column() == ENF_VER_SIZE_COLUMN)
163 SMESHGUI_SpinBox *lineEdit = qobject_cast<SMESHGUI_SpinBox*>(editor);
164 lineEdit->SetValue(index.data().toDouble());
166 else if (index.column() == ENF_VER_COMPOUND_COLUMN) {
167 QCheckBox *checkBox = qobject_cast<QCheckBox*>(editor);
168 checkBox->setChecked(index.data().toBool());
171 QItemDelegate::setEditorData(editor, index);
175 void EnforcedVertexTableWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
176 const QModelIndex &index) const
178 QModelIndex parent = index.parent();
180 QString entry = parent.child(index.row(), ENF_VER_ENTRY_COLUMN).data().toString();
181 bool isCompound = parent.child(index.row(), ENF_VER_COMPOUND_COLUMN).data(Qt::CheckStateRole).toBool();
183 if (index.column() == ENF_VER_X_COLUMN ||
184 index.column() == ENF_VER_Y_COLUMN ||
185 index.column() == ENF_VER_Z_COLUMN) {
186 SMESHGUI_SpinBox *lineEdit = qobject_cast<SMESHGUI_SpinBox*>(editor);
187 if (!isCompound && !vertexExists(model, index, lineEdit->GetString()))
188 model->setData(index, lineEdit->GetValue(), Qt::EditRole);
190 else if (index.column() == ENF_VER_SIZE_COLUMN)
192 SMESHGUI_SpinBox *lineEdit = qobject_cast<SMESHGUI_SpinBox*>(editor);
193 const double newsize = lineEdit->GetValue();
195 model->setData(index, newsize, Qt::EditRole);
197 else if (index.column() == ENF_VER_NAME_COLUMN) {
198 QLineEdit *lineEdit = qobject_cast<QLineEdit*>(editor);
199 QString value = lineEdit->text();
200 if (entry.isEmpty() && !vertexExists(model, index, value))
201 model->setData(index, value, Qt::EditRole);
203 else if (index.column() == ENF_VER_ENTRY_COLUMN) {
204 QLineEdit *lineEdit = qobject_cast<QLineEdit*>(editor);
205 QString value = lineEdit->text();
206 if (! vertexExists(model, index, value))
207 model->setData(index, value, Qt::EditRole);
209 else if (index.column() == ENF_VER_COMPOUND_COLUMN) {
210 QCheckBox *checkBox = qobject_cast<QCheckBox*>(editor);
211 model->setData(index, checkBox->isChecked(), Qt::CheckStateRole);
214 QItemDelegate::setModelData(editor, model, index);
218 void EnforcedVertexTableWidgetDelegate::updateEditorGeometry(QWidget *editor,
219 const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
221 editor->setGeometry(option.rect);
224 bool EnforcedVertexTableWidgetDelegate::vertexExists(QAbstractItemModel *model,
225 const QModelIndex &index,
229 QModelIndex parent = index.parent();
230 int row = index.row();
231 int col = index.column();
233 if (parent.isValid() && !value.isEmpty()) {
234 if (col == ENF_VER_X_COLUMN || col == ENF_VER_Y_COLUMN || col == ENF_VER_Z_COLUMN) {
236 if (col == ENF_VER_X_COLUMN) {
237 x = value.toDouble();
238 y = parent.child(row, ENF_VER_Y_COLUMN).data().toDouble();
239 z = parent.child(row, ENF_VER_Z_COLUMN).data().toDouble();
241 if (col == ENF_VER_Y_COLUMN) {
242 y = value.toDouble();
243 x = parent.child(row, ENF_VER_X_COLUMN).data().toDouble();
244 z = parent.child(row, ENF_VER_Z_COLUMN).data().toDouble();
246 if (col == ENF_VER_Z_COLUMN) {
247 z = value.toDouble();
248 x = parent.child(row, ENF_VER_X_COLUMN).data().toDouble();
249 y = parent.child(row, ENF_VER_Y_COLUMN).data().toDouble();
251 int nbChildren = model->rowCount(parent);
252 for (int i = 0 ; i < nbChildren ; i++) {
254 double childX = parent.child(i, ENF_VER_X_COLUMN).data().toDouble();
255 double childY = parent.child(i, ENF_VER_Y_COLUMN).data().toDouble();
256 double childZ = parent.child(i, ENF_VER_Z_COLUMN).data().toDouble();
257 if ((childX == x) && (childY == y) && (childZ == z)) {
264 else if (col == ENF_VER_NAME_COLUMN) {
265 QString name = parent.child(row, ENF_VER_NAME_COLUMN).data().toString();
275 // END EnforcedVertexTableWidgetDelegate
279 // BEGIN EnforcedMeshTableWidgetDelegate
282 EnforcedMeshTableWidgetDelegate::EnforcedMeshTableWidgetDelegate(QObject *parent)
283 : QItemDelegate(parent)
287 QWidget *EnforcedMeshTableWidgetDelegate::createEditor(QWidget *parent,
288 const QStyleOptionViewItem & option ,
289 const QModelIndex & index ) const
291 return QItemDelegate::createEditor(parent, option, index);
294 void EnforcedMeshTableWidgetDelegate::setEditorData(QWidget *editor,
295 const QModelIndex &index) const
297 QItemDelegate::setEditorData(editor, index);
300 void EnforcedMeshTableWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
301 const QModelIndex &index) const
303 QItemDelegate::setModelData(editor, model, index);
307 void EnforcedMeshTableWidgetDelegate::updateEditorGeometry(QWidget *editor,
308 const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
310 editor->setGeometry(option.rect);
313 // bool EnforcedMeshTableWidgetDelegate::enfMeshExists(QAbstractItemModel *model,
314 // const QModelIndex &index,
315 // QString value) const
317 // bool exists = false;
318 // QModelIndex parent = index.parent();
319 // int row = index.row();
320 // int col = index.column();
325 // END EnforcedMeshTableWidgetDelegate
329 HYBRIDPluginGUI_HypothesisCreator::HYBRIDPluginGUI_HypothesisCreator( const QString& theHypType )
330 : SMESHGUI_GenericHypothesisCreator( theHypType )
332 GeomToolSelected = NULL;
333 GeomToolSelected = getGeomSelectionTool();
335 iconVertex = QPixmap(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_OBJBROWSER_VERTEX")));
336 iconCompound = QPixmap(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_OBJBROWSER_COMPOUND")));
337 // mySelectionMgr = SMESH::GetSelectionMgr(SMESHGUI::GetSMESHGUI());
338 myEnfMeshConstraintLabels << tr( "HYBRID_ENF_MESH_CONSTRAINT_NODE" ) << tr( "HYBRID_ENF_MESH_CONSTRAINT_EDGE" ) << tr("HYBRID_ENF_MESH_CONSTRAINT_FACE");
341 HYBRIDPluginGUI_HypothesisCreator::~HYBRIDPluginGUI_HypothesisCreator()
343 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
344 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
345 myEnfMeshWdg->deactivateSelection();
349 * \brief {Get or create the geom selection tool for active study}
351 GeomSelectionTools* HYBRIDPluginGUI_HypothesisCreator::getGeomSelectionTool()
353 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
354 if (that->GeomToolSelected == NULL) {
355 that->GeomToolSelected = new GeomSelectionTools();
357 return that->GeomToolSelected;
360 GEOM::GEOM_Gen_var HYBRIDPluginGUI_HypothesisCreator::getGeomEngine()
362 return GeometryGUI::GetGeomGen();
365 QFrame* HYBRIDPluginGUI_HypothesisCreator::buildFrame()
367 QFrame* fr = new QFrame( 0 );
368 QVBoxLayout* lay = new QVBoxLayout( fr );
370 lay->setSpacing( 0 );
373 QTabWidget* tab = new QTabWidget( fr );
374 tab->setTabShape( QTabWidget::Rounded );
375 tab->setTabPosition( QTabWidget::North );
376 lay->addWidget( tab );
379 myStdGroup = new QWidget();
380 QGridLayout* aStdLayout = new QGridLayout( myStdGroup );
381 aStdLayout->setSpacing( 6 );
382 aStdLayout->setMargin( 11 );
388 aStdLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), myStdGroup ), row, 0, 1, 1 );
389 myName = new QLineEdit( myStdGroup );
390 aStdLayout->addWidget( myName, row++, 1, 1, 1 );
393 myToMeshHolesCheck = new QCheckBox( tr( "HYBRID_TO_MESH_HOLES" ), myStdGroup );
394 //aStdLayout->addWidget( myToMeshHolesCheck, row, 0, 1, 1 ); #stay, not view, may be used tomorrow...
395 myToMeshHolesCheck->hide();
396 myToMakeGroupsOfDomains = new QCheckBox( tr( "HYBRID_TO_MAKE_DOMAIN_GROUPS" ), myStdGroup );
397 //aStdLayout->addWidget( myToMakeGroupsOfDomains, row++, 1, 1, 1 ); #stay, not view, may be used tomorrow...
398 myToMakeGroupsOfDomains->hide();
399 //aStdLayout->addWidget( new QLabel( tr( "HYBRID_OPTIMIZATIOL_LEVEL" ), myStdGroup ), row, 0, 1, 1 );
400 myOptimizationLevelCombo = new QComboBox( myStdGroup );
401 //aStdLayout->addWidget( myOptimizationLevelCombo, row++, 1, 1, 1 ); #stay, not view, may be used tomorrow...
402 myOptimizationLevelCombo->hide();
405 types << tr( "LEVEL_NONE" ) << tr( "LEVEL_LIGHT" ) << tr( "LEVEL_MEDIUM" ) << tr( "LEVEL_STANDARDPLUS" ) << tr( "LEVEL_STRONG" );
406 myOptimizationLevelCombo->addItems( types );
408 QLabel* aLabel = new QLabel( tr( "HYBRID_BOUNDARY_LAYERS_GROWTH" ), myStdGroup );
409 aLabel->setToolTip(tr( "HYBRID_BOUNDARY_LAYERS_HELP" ));
410 aStdLayout->addWidget( aLabel, row, 0, 1, 1 );
411 myBoundaryLayersGrowthCombo = new QComboBox( myStdGroup );
412 myBoundaryLayersGrowthCombo->setToolTip(tr( "HYBRID_BOUNDARY_LAYERS_HELP" ));
414 aStdLayout->addWidget( myBoundaryLayersGrowthCombo, row++, 1, 1, 1 );
416 QStringList typesBoundaryLayersGrowth;
417 typesBoundaryLayersGrowth << tr( "HYBRID_LAYER_GROWTH_DOWNWARD" ) << tr( "HYBRID_LAYER_GROWTH_UPWARD" );
418 myBoundaryLayersGrowthCombo->addItems( typesBoundaryLayersGrowth );
420 aStdLayout->addWidget( new QLabel( tr( "HYBRID_HeightFirstLayer" ), myStdGroup ), row, 0, 1, 1 );
421 myHeightFirstLayerSpin = new SMESHGUI_SpinBox( myStdGroup );
422 myHeightFirstLayerSpin->RangeStepAndValidator(0., COORD_MAX, .1, "length_precision");
423 aStdLayout->addWidget( myHeightFirstLayerSpin, row++, 1, 1, 1 );
425 aStdLayout->addWidget( new QLabel( tr( "HYBRID_NbOfBoundaryLayers" ), myStdGroup ), row, 0, 1, 1 );
426 myNbOfBoundaryLayersSpin = new QSpinBox( myStdGroup );
427 aStdLayout->addWidget( myNbOfBoundaryLayersSpin, row++, 1, 1, 1 );
429 aStdLayout->addWidget( new QLabel( tr( "HYBRID_BoundaryLayersProgression" ), myStdGroup ), row, 0, 1, 1 );
430 myBoundaryLayersProgressionSpin = new SMESHGUI_SpinBox( myStdGroup );
431 myBoundaryLayersProgressionSpin->RangeStepAndValidator(0., 10., .1, "length_precision");
432 aStdLayout->addWidget( myBoundaryLayersProgressionSpin, row++, 1, 1, 1 );
434 aStdLayout->addWidget( new QLabel( tr( "COLLISION_MODE" ), myStdGroup ), row, 0, 1, 1 );
435 myCollisionModeCombo = new QComboBox( myStdGroup );
436 aStdLayout->addWidget( myCollisionModeCombo, row++, 1, 1, 1 );
438 QStringList typescoll;
439 typescoll << tr( "COLLISION_DECREASE" ) << tr( "COLLISION_STOP" );
440 myCollisionModeCombo->addItems( typescoll );
442 aStdLayout->addWidget( new QLabel( tr( "HYBRID_GENERATION_ELEMENT" ), myStdGroup ), row, 0, 1, 1 );
443 myElementGenerationCombo = new QComboBox( myStdGroup );
444 aStdLayout->addWidget( myElementGenerationCombo, row++, 1, 1, 1 );
446 QStringList typesElementGeneration;
447 typesElementGeneration << tr( "HYBRID_GENERATION_TETRA_DOMINANT" ) << tr( "HYBRID_GENERATION_HEXA_DOMINANT" ) << tr( "HYBRID_GENERATION_CARTESIAN_CORE" );
448 myElementGenerationCombo->addItems( typesElementGeneration );
450 aStdLayout->addWidget( new QLabel( tr( "HYBRID_CORE_SIZE" ), myStdGroup ), row, 0, 1, 1 );
451 myCoreSizeSpin = new SMESHGUI_SpinBox( myStdGroup );
452 myCoreSizeSpin->RangeStepAndValidator(0., COORD_MAX, 10., "length_precision");
453 aStdLayout->addWidget( myCoreSizeSpin, row++, 1, 1, 1 );
455 myAddMultinormalsCheck = new QCheckBox( tr( "HYBRID_ADD_MULTINORMALS" ), myStdGroup );
456 aStdLayout->addWidget( myAddMultinormalsCheck, row++, 0, 1, 1 );
458 aStdLayout->addWidget( new QLabel( tr( "HYBRID_MULTINORMAL_ANGLE" ), myStdGroup ), row, 0, 1, 1 );
459 myMultinormalsAngleSpin = new SMESHGUI_SpinBox( myStdGroup );
460 myMultinormalsAngleSpin->RangeStepAndValidator(0., 90., 2., "threshold");
461 aStdLayout->addWidget( myMultinormalsAngleSpin, row++, 1, 1, 1 );
463 mySmoothNormalsCheck = new QCheckBox( tr( "HYBRID_SMOOTH_NORMALS" ), myStdGroup );
464 aStdLayout->addWidget( mySmoothNormalsCheck, row++, 0, 1, 1 );
465 aStdLayout->setRowStretch( row, 10 );
467 // advanced parameters
468 myAdvGroup = new QWidget();
469 QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup );
470 anAdvLayout->setSpacing( 6 );
471 anAdvLayout->setMargin( 11 );
472 myAdvWidget = new HYBRIDPluginGUI_AdvWidget(myAdvGroup);
473 anAdvLayout->addWidget( myAdvWidget);
475 myAdvWidget->maxMemoryCheck->setText(tr( "MAX_MEMORY_SIZE" ));
476 myAdvWidget->initialMemoryCheck->setText(tr( "INIT_MEMORY_SIZE" ));
478 myAdvWidget->maxMemorySpin->RangeStepAndValidator(20.0, 1e6, 10.0);
479 myAdvWidget->maxMemorySpin->setValue( 128.0 );
481 myAdvWidget->initialMemorySpin->RangeStepAndValidator(0.0, 1e6, 10.0);
482 myAdvWidget->initialMemorySpin->setValue( 100.0 );
484 myAdvWidget->initialMemoryLabel ->setText (tr( "MEGABYTE" ));
485 myAdvWidget->maxMemoryLabel ->setText (tr( "MEGABYTE" ));
487 myAdvWidget->workingDirectoryPushButton ->setText (tr( "SELECT_DIR" ));
488 myAdvWidget->keepWorkingFilesCheck ->setText (tr( "KEEP_WORKING_FILES" ));
489 myAdvWidget->verboseLevelLabel ->setText (tr( "VERBOSE_LEVEL" ));
490 myAdvWidget->removeLogOnSuccessCheck ->setText (tr( "REMOVE_LOG_ON_SUCCESS" ));
491 myAdvWidget->logInFileCheck ->setText (tr( "LOG_IN_FILE" ));
493 myAdvWidget->memoryGroupBox ->setTitle(tr( "MEMORY_GROUP_TITLE" ));
494 myAdvWidget->logGroupBox ->setTitle(tr( "LOG_GROUP_TITLE" ));
495 myAdvWidget->advancedMeshingGroupBox ->setTitle(tr( "ADVANCED_MESHING_GROUP_TITLE" ));
497 myAdvWidget->memoryGroupBox->hide();
499 myAdvWidget->createNewNodesCheck->hide();
500 //myAdvWidget->createNewNodesLabel->hide();
501 myAdvWidget->removeInitialCentralPointCheck->hide();
502 myAdvWidget->boundaryRecoveryCheck->hide();
503 myAdvWidget->FEMCorrectionCheck->hide();
504 myAdvWidget->gradationLabel->hide();
505 myAdvWidget->gradationSpinBox->hide();
507 myAdvWidget->createNewNodesCheck ->setText (tr( "TO_ADD_NODES" ));
508 myAdvWidget->removeInitialCentralPointCheck->setText (tr( "NO_INITIAL_CENTRAL_POINT" ));
509 myAdvWidget->boundaryRecoveryCheck ->setText (tr( "RECOVERY_VERSION" ));
510 myAdvWidget->FEMCorrectionCheck ->setText (tr( "FEM_CORRECTION" ));
511 myAdvWidget->gradationLabel ->setText (tr( "HYBRID_GRADATION" ));
512 myAdvWidget->gradationSpinBox->RangeStepAndValidator(1.05, 5.0, 0.05, "length_precision");
514 // Enforced vertices parameters
515 myEnfGroup = new QWidget();
516 QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup);
517 myEnforcedTableWidget = new QTableWidget(myEnfGroup);
518 myEnforcedTableWidget ->setMinimumWidth(300);
519 myEnforcedTableWidget->setRowCount( 0 );
520 myEnforcedTableWidget->setColumnCount( ENF_VER_NB_COLUMNS );
521 myEnforcedTableWidget->setSortingEnabled(true);
522 QStringList enforcedHeaders;
523 enforcedHeaders << tr( "HYBRID_ENF_NAME_COLUMN" )
524 << tr( "HYBRID_ENF_VER_X_COLUMN" )<< tr( "HYBRID_ENF_VER_Y_COLUMN" ) << tr( "HYBRID_ENF_VER_Z_COLUMN" )
525 << tr( "HYBRID_ENF_SIZE_COLUMN" ) << tr("HYBRID_ENF_ENTRY_COLUMN") << tr("HYBRID_ENF_VER_COMPOUND_COLUMN") << tr( "HYBRID_ENF_GROUP_COLUMN" );
527 myEnforcedTableWidget->setHorizontalHeaderLabels(enforcedHeaders);
528 myEnforcedTableWidget->verticalHeader()->hide();
529 myEnforcedTableWidget->horizontalHeader()->setStretchLastSection(true);
530 myEnforcedTableWidget->setAlternatingRowColors(true);
531 myEnforcedTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
532 myEnforcedTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
533 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
534 myEnforcedTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
536 myEnforcedTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
538 myEnforcedTableWidget->resizeColumnsToContents();
539 myEnforcedTableWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
540 myEnforcedTableWidget->hideColumn(ENF_VER_COMPOUND_COLUMN);
542 myEnforcedTableWidget->setItemDelegate(new EnforcedVertexTableWidgetDelegate());
545 TColStd_MapOfInteger shapeTypes;
546 shapeTypes.Add( TopAbs_VERTEX );
547 shapeTypes.Add( TopAbs_COMPOUND );
549 SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes);
550 myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true);
551 myEnfVertexWdg->SetDefaultText(tr("HYBRID_ENF_SELECT_VERTEX"), "QLineEdit { color: grey }");
553 QLabel* myXCoordLabel = new QLabel( tr( "HYBRID_ENF_VER_X_LABEL" ), myEnfGroup );
554 myXCoord = new SMESHGUI_SpinBox(myEnfGroup);
555 myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
556 QLabel* myYCoordLabel = new QLabel( tr( "HYBRID_ENF_VER_Y_LABEL" ), myEnfGroup );
557 myYCoord = new SMESHGUI_SpinBox(myEnfGroup);
558 myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
559 QLabel* myZCoordLabel = new QLabel( tr( "HYBRID_ENF_VER_Z_LABEL" ), myEnfGroup );
560 myZCoord = new SMESHGUI_SpinBox(myEnfGroup);
561 myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
562 QLabel* mySizeLabel = new QLabel( tr( "HYBRID_ENF_SIZE_LABEL" ), myEnfGroup );
563 mySizeValue = new SMESHGUI_SpinBox(myEnfGroup);
564 mySizeValue->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
566 QLabel* myGroupNameLabel = new QLabel( tr( "HYBRID_ENF_GROUP_LABEL" ), myEnfGroup );
567 myGroupName = new QLineEdit(myEnfGroup);
569 addVertexButton = new QPushButton(tr("HYBRID_ENF_ADD"),myEnfGroup);
570 addVertexButton->setEnabled(false);
571 removeVertexButton = new QPushButton(tr("HYBRID_ENF_REMOVE"),myEnfGroup);
572 // myGlobalGroupName = new QCheckBox(tr("HYBRID_ENF_VER_GROUPS"), myEnfGroup);
573 // myGlobalGroupName->setChecked(false);
575 // QGroupBox* GroupBox = new QGroupBox( myEnfGroup );
576 // QLabel* info = new QLabel( GroupBox );
577 // info->setText( tr( "HYBRID_ENF_VER_INFO" ) );
578 // info->setWordWrap( true );
579 // QVBoxLayout* GroupBoxVLayout = new QVBoxLayout( GroupBox );
580 // GroupBoxVLayout->setSpacing( 6 );
581 // GroupBoxVLayout->setMargin( 11 );
582 // GroupBoxVLayout->addWidget( info );
585 //anEnfLayout->addWidget(GroupBox, ENF_VER_WARNING, 0, 1, 2 );
586 anEnfLayout->addWidget(myEnforcedTableWidget, ENF_VER_VERTEX, 0, ENF_VER_NB_LINES, 1);
588 QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup);
589 anEnfLayout2->addWidget(myEnfVertexWdg, ENF_VER_VERTEX, 0, 1, 2);
590 anEnfLayout2->addWidget(myXCoordLabel, ENF_VER_X_COORD, 0, 1, 1);
591 anEnfLayout2->addWidget(myXCoord, ENF_VER_X_COORD, 1, 1, 1);
592 anEnfLayout2->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 0, 1, 1);
593 anEnfLayout2->addWidget(myYCoord, ENF_VER_Y_COORD, 1, 1, 1);
594 anEnfLayout2->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 0, 1, 1);
595 anEnfLayout2->addWidget(myZCoord, ENF_VER_Z_COORD, 1, 1, 1);
596 anEnfLayout2->addWidget(mySizeLabel, ENF_VER_SIZE, 0, 1, 1);
597 anEnfLayout2->addWidget(mySizeValue, ENF_VER_SIZE, 1, 1, 1);
598 anEnfLayout2->addWidget(myGroupNameLabel, ENF_VER_GROUP, 0, 1, 1);
599 anEnfLayout2->addWidget(myGroupName, ENF_VER_GROUP, 1, 1, 1);
600 anEnfLayout2->addWidget(addVertexButton, ENF_VER_BTN, 0, 1, 1);
601 anEnfLayout2->addWidget(removeVertexButton, ENF_VER_BTN, 1, 1, 1);
602 anEnfLayout2->setRowStretch(ENF_VER_NB_LINES, 1);
604 anEnfLayout->addLayout(anEnfLayout2, ENF_VER_VERTEX, 1,ENF_VER_NB_LINES, 1);
605 anEnfLayout->setRowStretch(ENF_VER_VERTEX, 10);
607 // Enforced meshes parameters
608 myEnfMeshGroup = new QWidget();
609 QGridLayout* anEnfMeshLayout = new QGridLayout(myEnfMeshGroup);
611 myEnforcedMeshTableWidget = new QTableWidget(myEnfGroup);
612 myEnforcedMeshTableWidget->setRowCount( 0 );
613 myEnforcedMeshTableWidget->setColumnCount( ENF_MESH_NB_COLUMNS );
614 myEnforcedMeshTableWidget->setSortingEnabled(true);
615 myEnforcedMeshTableWidget->verticalHeader()->hide();
616 QStringList enforcedMeshHeaders;
617 enforcedMeshHeaders << tr( "HYBRID_ENF_NAME_COLUMN" )
618 << tr( "HYBRID_ENF_ENTRY_COLUMN" )
619 << tr( "HYBRID_ENF_MESH_CONSTRAINT_COLUMN" )
620 << tr( "HYBRID_ENF_GROUP_COLUMN" );
621 myEnforcedMeshTableWidget->setHorizontalHeaderLabels(enforcedMeshHeaders);
622 myEnforcedMeshTableWidget->horizontalHeader()->setStretchLastSection(true);
623 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
624 myEnforcedMeshTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
626 myEnforcedMeshTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
628 myEnforcedMeshTableWidget->setAlternatingRowColors(true);
629 myEnforcedMeshTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
630 myEnforcedMeshTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
631 myEnforcedMeshTableWidget->resizeColumnsToContents();
632 myEnforcedMeshTableWidget->hideColumn(ENF_MESH_ENTRY_COLUMN);
634 myEnforcedMeshTableWidget->setItemDelegate(new EnforcedMeshTableWidgetDelegate());
636 // myEnfMesh = SMESH::SMESH_Mesh::_nil();
637 // myEnfMeshArray = new SMESH::mesh_array();
639 myEnfMeshWdg = new StdMeshersGUI_ObjectReferenceParamWdg( SMESH::IDSOURCE, myEnfMeshGroup, /*multiSel=*/true);
640 myEnfMeshWdg->SetDefaultText(tr("HYBRID_ENF_SELECT_MESH"), "QLineEdit { color: grey }");
642 myEnfMeshWdg->AvoidSimultaneousSelection(myEnfVertexWdg);
643 ////myEnfMeshWdg->hide(); //may be used later
645 QLabel* myMeshConstraintLabel = new QLabel( tr( "HYBRID_ENF_MESH_CONSTRAINT_LABEL" ), myEnfMeshGroup );
646 myEnfMeshConstraint = new QComboBox(myEnfMeshGroup);
647 myEnfMeshConstraint->insertItems(0,myEnfMeshConstraintLabels);
648 myEnfMeshConstraint->setEditable(false);
649 myEnfMeshConstraint->setCurrentIndex(2); //EZ: use mesh group of faces for a layer
650 myMeshConstraintLabel->hide(); //may be used later
651 myEnfMeshConstraint->hide(); //may be used later
653 QLabel* myMeshGroupNameLabel = new QLabel( tr( "HYBRID_ENF_GROUP_LABEL" ), myEnfMeshGroup );
654 myMeshGroupName = new QLineEdit(myEnfMeshGroup);
655 myMeshGroupNameLabel->hide(); //may be used later
656 myMeshGroupName->hide(); //may be used later
658 addEnfMeshButton = new QPushButton(tr("HYBRID_ENF_ADD"),myEnfMeshGroup);
659 // addEnfMeshButton->setEnabled(false);
660 removeEnfMeshButton = new QPushButton(tr("HYBRID_ENF_REMOVE"),myEnfMeshGroup);
662 // QGroupBox* GroupBox2 = new QGroupBox( myEnfMeshGroup );
663 // QLabel* info2 = new QLabel( GroupBox2 );
664 // info2->setText( tr( "HYBRID_ENF_MESH_INFO" ) );
665 // info2->setWordWrap( true );
666 // QVBoxLayout* GroupBox2VLayout = new QVBoxLayout( GroupBox2 );
667 // GroupBox2VLayout->setSpacing( 6 );
668 // GroupBox2VLayout->setMargin( 11 );
669 // GroupBox2VLayout->addWidget( info2 );
671 // anEnfMeshLayout->addWidget( GroupBox2, ENF_MESH_WARNING, 0, 1, 2 );
672 //anEnfMeshLayout->addWidget(myLayersOnAllWrapCheck, ENF_MESH_MESH, 0, 1 , 1);
673 anEnfMeshLayout->addWidget(myEnforcedMeshTableWidget, ENF_MESH_MESH, 0, ENF_MESH_NB_LINES , 1);
675 QGridLayout* anEnfMeshLayout2 = new QGridLayout(myEnfMeshGroup);
676 anEnfMeshLayout2->addWidget(myEnfMeshWdg, ENF_MESH_MESH, 0, 1, 2);
677 //TODO remove or not be lateful to select layers...
678 //anEnfMeshLayout2->addWidget(myMeshConstraintLabel, ENF_MESH_CONSTRAINT, 0, 1, 1);
679 //anEnfMeshLayout2->addWidget(myEnfMeshConstraint, ENF_MESH_CONSTRAINT, 1, 1, 1);
680 //anEnfMeshLayout2->addWidget(myMeshGroupNameLabel, ENF_MESH_GROUP, 0, 1, 1);
681 //anEnfMeshLayout2->addWidget(myMeshGroupName, ENF_MESH_GROUP, 1, 1, 1);
682 anEnfMeshLayout2->addWidget(addEnfMeshButton, ENF_MESH_BTN, 0, 1, 1);
683 anEnfMeshLayout2->addWidget(removeEnfMeshButton, ENF_MESH_BTN, 1, 1, 1);
684 anEnfMeshLayout2->setRowStretch(ENF_MESH_NB_LINES, 1);
686 anEnfMeshLayout->addLayout(anEnfMeshLayout2, ENF_MESH_MESH, 1, ENF_MESH_NB_LINES, 1);
687 anEnfMeshLayout->setRowStretch(ENF_MESH_MESH, 10);
690 // selection of faces for layers
692 QWidget* faceSelLayersGroup = new QWidget( dlg() );
693 myLayersOnAllWrapCheck = new QCheckBox( tr( "HYBRID_LAYERS_ON_ALL_WRAP" ), faceSelLayersGroup );
694 QGridLayout* faceSelLayersLayout = new QGridLayout( faceSelLayersGroup );
695 faceSelLayersLayout->addWidget(myLayersOnAllWrapCheck, 0, 0 );
697 myFacesLbl = new QLabel( tr("HYBRID_FACE_IDS"), faceSelLayersGroup );
698 faceSelLayersLayout->addWidget( myFacesLbl, 1, 0 );
700 myFaceSelectorLayers = new StdMeshersGUI_SubShapeSelectorWdg( faceSelLayersGroup, TopAbs_FACE, true, true );
701 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
702 QString aSubEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
703 myFaceSelectorLayers->SetGeomShapeEntry( aSubEntry, aMainEntry );
704 faceSelLayersLayout->addWidget( myFaceSelectorLayers, 2, 0);
705 faceSelLayersLayout->setRowStretch( 2, 10);
707 // selection of faces for imprinting
709 QWidget* faceSelImprintingGroup = new QWidget( dlg() );
710 QGridLayout* faceSelImprintingLayout = new QGridLayout( faceSelImprintingGroup );
712 QLabel* facesLblImprinting = new QLabel( tr("HYBRID_FACE_IDS"), faceSelImprintingGroup );
713 faceSelImprintingLayout->addWidget( facesLblImprinting, 0, 0 );
715 myFaceSelectorImprinting = new StdMeshersGUI_SubShapeSelectorWdg( faceSelImprintingGroup, TopAbs_FACE, true, true );
716 myFaceSelectorImprinting->SetGeomShapeEntry( aSubEntry, aMainEntry );
717 faceSelImprintingLayout->addWidget( myFaceSelectorImprinting, 1, 0, 2, 2 );
718 faceSelImprintingLayout->setRowStretch( 1, 10);
720 // selection of faces for snapping
722 QWidget* faceSelSnappingGroup = new QWidget( dlg() );
723 QGridLayout* faceSelSnappingLayout = new QGridLayout( faceSelSnappingGroup );
725 QLabel* facesLblSnapping = new QLabel( tr("HYBRID_FACE_IDS"), faceSelSnappingGroup );
726 faceSelSnappingLayout->addWidget( facesLblSnapping, 0, 0 );
728 myFaceSelectorSnapping = new StdMeshersGUI_SubShapeSelectorWdg( faceSelSnappingGroup, TopAbs_FACE, true, true );
729 myFaceSelectorSnapping->SetGeomShapeEntry( aSubEntry, aMainEntry );
730 faceSelSnappingLayout->addWidget( myFaceSelectorSnapping, 1, 0, 2, 2 );
731 faceSelSnappingLayout->setRowStretch( 1, 10);
734 tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
735 tab->insertTab( ADV_TAB, myAdvGroup, tr( "HYBRID_ADV_ARGS" ) );
736 if ( aMainEntry.isEmpty() && aSubEntry.isEmpty() ) // mesh not based of geometry
737 faceSelLayersGroup->hide();
739 tab->insertTab( FACE_SEL_LAYERS_TAB, faceSelLayersGroup, tr( "HYBRID_FACES_LAYERS_TAB" ));
740 tab->insertTab( FACE_SEL_IMPRINTING_TAB, faceSelImprintingGroup, tr( "HYBRID_FACES_IMPRINTING_TAB" ));
741 tab->insertTab( FACE_SEL_SNAPPING_TAB, faceSelSnappingGroup, tr( "HYBRID_FACES_SNAPPING_TAB" ));
743 tab->insertTab( ENF_MESH_TAB, myEnfMeshGroup, tr( "HYBRID_ENFORCED_MESHES" ) );
744 tab->setCurrentIndex( STD_TAB );
747 connect( tab, SIGNAL( currentChanged ( int )), this, SLOT( onTabChanged( int ) ) );
748 //connect( myLayersOnAllWrapCheck, SIGNAL( toggled( bool ) ), this, SLOT( onLayersOnAllWrap(bool)));
749 connect( myLayersOnAllWrapCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
750 //connect( myToMeshHolesCheck, SIGNAL( toggled( bool ) ), this, SLOT( onToMeshHoles(bool)));
751 //connect( myAdvWidget->maxMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
752 //connect( myAdvWidget->initialMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
753 //connect( myAdvWidget->boundaryRecoveryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
755 //connect( myBoundaryLayersGrowthCombo, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
756 //connect( myElementGenerationCombo, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
757 connect( myAddMultinormalsCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
758 connect( mySmoothNormalsCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
760 connect( myAdvWidget->logInFileCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
761 connect( myAdvWidget->keepWorkingFilesCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
762 connect( myAdvWidget->workingDirectoryPushButton, SIGNAL( clicked() ), this, SLOT( onDirBtnClicked() ) );
764 connect( myEnforcedTableWidget, SIGNAL( itemClicked(QTableWidgetItem *)), this, SLOT( synchronizeCoords() ) );
765 connect( myEnforcedTableWidget, SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
766 connect( myEnforcedTableWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
767 connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertex() ) );
768 connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
769 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
770 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
771 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
772 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
773 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
774 connect( mySizeValue, SIGNAL( textChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) );
775 connect( myXCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
776 connect( myYCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
777 connect( myZCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
778 connect( mySizeValue, SIGNAL( valueChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) );
779 connect( this, SIGNAL( vertexDefined(bool) ), addVertexButton, SLOT( setEnabled(bool) ) );
781 connect( addEnfMeshButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedMesh() ) );
782 connect( removeEnfMeshButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedMesh() ) );
783 // connect( myEnfMeshWdg, SIGNAL( contentModified()), this, SLOT( checkEnfMeshIsDefined() ) );
784 // connect( myEnfMeshConstraint, SIGNAL( currentIndexChanged(int) ), this, SLOT( checkEnfMeshIsDefined() ) );
785 // connect( this, SIGNAL( enfMeshDefined(bool) ), addEnfMeshButton, SLOT( setEnabled(bool) ) );
791 * This method checks if an enforced vertex is defined;
793 void HYBRIDPluginGUI_HypothesisCreator::clearEnfVertexSelection()
795 if (myEnfVertexWdg->NbObjects() != 0) {
796 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
797 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
798 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
799 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
800 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
802 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
803 that->checkVertexIsDefined();
807 * This method checks if an enforced vertex is defined;
809 void HYBRIDPluginGUI_HypothesisCreator::checkVertexIsDefined()
811 bool enfVertexIsDefined = false;
812 enfVertexIsDefined = (!mySizeValue->GetString().isEmpty() &&
813 (!myEnfVertexWdg->NbObjects() == 0 ||
814 (myEnfVertexWdg->NbObjects() == 0 && !myXCoord->GetString().isEmpty()
815 && !myYCoord->GetString().isEmpty()
816 && !myZCoord->GetString().isEmpty())));
817 emit vertexDefined(enfVertexIsDefined);
821 * This method checks if an enforced mesh is defined;
823 void HYBRIDPluginGUI_HypothesisCreator::checkEnfMeshIsDefined()
825 emit enfMeshDefined( myEnfVertexWdg->NbObjects() != 0);
829 * This method resets the content of the X, Y, Z, size and GroupName widgets;
831 void HYBRIDPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
833 myXCoord->setCleared(true);
834 myYCoord->setCleared(true);
835 myZCoord->setCleared(true);
836 // mySizeValue->setCleared(true);
837 myXCoord->setText("");
838 myYCoord->setText("");
839 myZCoord->setText("");
840 // mySizeValue->setText("");
841 // myGroupName->setText("");
842 addVertexButton->setEnabled(false);
845 /** HYBRIDPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item)
846 This method updates the tooltip of a modified item. The QLineEdit widgets content
847 is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
849 void HYBRIDPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTableWidgetItem* item) {
850 int row = myEnforcedTableWidget->row(item);
852 QVariant vertexName = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole);
853 QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole);
854 QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole);
855 QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole);
856 QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole);
857 QVariant entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
858 QString groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole).toString();
860 clearEnforcedVertexWidgets();
862 if ( !x.isNull() || !entry.isNull()) {
863 QString toolTip = vertexName.toString();
864 toolTip += QString("(");
865 if (entry.isNull() || (!entry.isNull() && entry.toString() == "")) {
866 toolTip += x.toString();
867 toolTip += QString(", ") + y.toString();
868 toolTip += QString(", ") + z.toString();
871 toolTip += entry.toString();
872 toolTip += QString(")");
875 toolTip += QString("=") + size.toString();
877 if (!groupName.isEmpty())
878 toolTip += QString(" [") + groupName + QString("]");
880 for (int col=0;col<ENF_VER_NB_COLUMNS;col++)
881 myEnforcedTableWidget->item(row,col)->setToolTip(toolTip);
884 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
885 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
886 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
887 myXCoord->SetValue(x.toDouble());
888 myYCoord->SetValue(y.toDouble());
889 myZCoord->SetValue(z.toDouble());
890 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
891 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
892 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
895 mySizeValue->SetValue(size.toDouble());
897 if (!groupName.isEmpty())
898 myGroupName->setText(groupName);
902 void HYBRIDPluginGUI_HypothesisCreator::onSelectEnforcedVertex() {
903 int nbSelEnfVertex = myEnfVertexWdg->NbObjects();
904 clearEnforcedVertexWidgets();
905 if (nbSelEnfVertex == 1)
907 if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() )
910 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
911 if (myEnfVertex == GEOM::GEOM_Object::_nil())
913 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
914 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
915 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations();
916 if (CORBA::is_nil(measureOp))
920 measureOp->PointCoordinates (myEnfVertex, x, y, z);
921 if ( measureOp->IsDone() )
923 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
924 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
925 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
926 myXCoord->SetValue(x);
927 myYCoord->SetValue(y);
928 myZCoord->SetValue(z);
929 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
930 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
931 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
937 /** HYBRIDPluginGUI_HypothesisCreator::synchronizeCoords()
938 This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
939 of the enforced vertex clicked in the tree widget.
941 void HYBRIDPluginGUI_HypothesisCreator::synchronizeCoords() {
942 clearEnforcedVertexWidgets();
943 QList<QTableWidgetItem *> items = myEnforcedTableWidget->selectedItems();
944 // myEnfVertexWdg->disconnect(SIGNAL(contentModified()));
945 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
946 if (! items.isEmpty()) {
947 QTableWidgetItem *item;
950 if (items.size() == 1) {
952 row = myEnforcedTableWidget->row(item);
953 QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole);
954 QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole);
955 QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole);
956 QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole);
957 entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
958 if (!entry.isNull()) {
959 SMESH::string_array_var objIds = new SMESH::string_array;
961 objIds[0] = entry.toString().toStdString().c_str();
962 myEnfVertexWdg->SetObjects(objIds);
965 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
967 QVariant group = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole);
968 if (!x.isNull()/* && entry.isNull()*/) {
969 // disconnect( myXCoord, SIGNAL( textChanged(const QString &)), this, SLOT( onSelectEnforcedVertex() ) );
970 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
971 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
972 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
973 myXCoord->SetValue(x.toDouble());
974 myYCoord->SetValue(y.toDouble());
975 myZCoord->SetValue(z.toDouble());
976 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
977 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
978 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
981 mySizeValue->SetValue(size.toDouble());
983 if (!group.isNull() && (!x.isNull() || !entry.isNull()))
984 myGroupName->setText(group.toString());
987 QList<QString> entryList;
988 for (int i = 0; i < items.size(); ++i) {
990 row = myEnforcedTableWidget->row(item);
991 entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
993 entryList << entry.toString();
995 if (entryList.size() > 0) {
996 SMESH::string_array_var objIds = new SMESH::string_array;
997 objIds->length(entryList.size());
998 for (int i = 0; i < entryList.size() ; i++)
999 objIds[i] = entryList.at(i).toStdString().c_str();
1000 myEnfVertexWdg->SetObjects(objIds);
1003 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1008 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1010 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
1011 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1012 that->checkVertexIsDefined();
1015 /** HYBRIDPluginGUI_HypothesisCreator::addEnforcedMesh( meshName, geomEntry, elemType, size, groupName)
1016 This method adds in the tree widget an enforced mesh from mesh, submesh or group with optionally size and and groupName.
1018 void HYBRIDPluginGUI_HypothesisCreator::addEnforcedMesh(std::string name, std::string entry, int elementType, std::string groupName)
1020 bool okToCreate = true;
1021 QString itemEntry = "";
1022 int itemElementType = 0;
1023 int rowCount = myEnforcedMeshTableWidget->rowCount();
1024 bool allColumns = true;
1025 for (int row = 0;row<rowCount;row++) {
1026 for (int col = 0 ; col < ENF_MESH_NB_COLUMNS ; col++) {
1027 if (col == ENF_MESH_CONSTRAINT_COLUMN){
1028 if (qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row, col)) == 0) {
1033 else if (myEnforcedMeshTableWidget->item(row, col) == 0) {
1037 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1038 QComboBox* itemComboBox = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row, col));
1039 itemElementType = itemComboBox->currentIndex();
1041 else if (col == ENF_MESH_ENTRY_COLUMN)
1042 itemEntry = myEnforcedMeshTableWidget->item(row, col)->data(Qt::EditRole).toString();
1048 if (itemEntry == QString(entry.c_str()) && itemElementType == elementType) {
1049 // // update group name
1050 // if (itemGroupName.toStdString() != groupName) {
1051 // myEnforcedMeshTableWidget->item(row, ENF_MESH_GROUP_COLUMN)->setData( Qt::EditRole, QVariant(groupName.c_str()));
1063 myEnforcedMeshTableWidget->setRowCount(rowCount+1);
1064 myEnforcedMeshTableWidget->setSortingEnabled(false);
1066 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++) {
1067 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1068 QComboBox* comboBox = new QComboBox();
1069 QPalette pal = comboBox->palette();
1070 pal.setColor(QPalette::Button, Qt::white);
1071 comboBox->setPalette(pal);
1072 comboBox->insertItems(0,myEnfMeshConstraintLabels);
1073 comboBox->setEditable(false);
1074 comboBox->setCurrentIndex(elementType);
1075 myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox);
1078 QTableWidgetItem* item = new QTableWidgetItem();
1079 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1081 case ENF_MESH_NAME_COLUMN:
1082 item->setData( 0, name.c_str() );
1083 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1084 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1086 case ENF_MESH_ENTRY_COLUMN:
1087 item->setData( 0, entry.c_str() );
1088 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1089 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1091 case ENF_MESH_GROUP_COLUMN:
1092 item->setData( 0, groupName.c_str() );
1093 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1101 // connect( myEnforcedMeshTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1103 myEnforcedMeshTableWidget->setSortingEnabled(true);
1104 // myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1105 // updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1109 /** HYBRIDPluginGUI_HypothesisCreator::addEnforcedVertex( x, y, z, size, vertexName, geomEntry, groupName)
1110 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.
1112 void HYBRIDPluginGUI_HypothesisCreator::addEnforcedVertex(double x, double y, double z, double size, std::string vertexName, std::string geomEntry, std::string groupName, bool isCompound)
1114 myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1115 bool okToCreate = true;
1116 double itemX,itemY,itemZ,itemSize = 0;
1117 QString itemEntry, itemGroupName = QString("");
1118 // bool itemIsCompound;
1119 int rowCount = myEnforcedTableWidget->rowCount();
1122 for (int row = 0;row<rowCount;row++) {
1124 for (int col = 0 ; col < ENF_VER_NB_COLUMNS ; col++) {
1125 if (myEnforcedTableWidget->item(row, col) == 0) {
1130 data = myEnforcedTableWidget->item(row, col)->data(Qt::EditRole);
1131 if (!data.isNull()) {
1133 case ENF_VER_GROUP_COLUMN:
1134 itemGroupName = data.toString();
1136 case ENF_VER_ENTRY_COLUMN:
1137 itemEntry = data.toString();
1139 // case ENF_VER_COMPOUND_COLUMN:
1140 // itemIsCompound = data.toBool();
1142 case ENF_VER_X_COLUMN:
1143 itemX = data.toDouble();
1145 case ENF_VER_Y_COLUMN:
1146 itemY = data.toDouble();
1148 case ENF_VER_Z_COLUMN:
1149 itemZ = data.toDouble();
1151 case ENF_VER_SIZE_COLUMN:
1152 itemSize = data.toDouble();
1164 if (( !isCompound && ((itemX == x) && (itemY == y) && (itemZ == z))) || /*( (itemEntry.toStdString() != "") && */ (itemEntry.toStdString() == geomEntry)/*)*/) {
1166 if (itemSize != size) {
1167 myEnforcedTableWidget->item(row, ENF_VER_SIZE_COLUMN)->setData( Qt::EditRole, QVariant(size));
1169 // update group name
1170 if (itemGroupName.toStdString() != groupName) {
1171 myEnforcedTableWidget->item(row, ENF_VER_GROUP_COLUMN)->setData( Qt::EditRole, QVariant(groupName.c_str()));
1178 if (geomEntry.empty()) {
1185 if (geomEntry.empty()) {
1192 QString myVertexName;
1193 while(indexRef != vertexIndex) {
1194 indexRef = vertexIndex;
1195 if (vertexName.empty())
1196 myVertexName = QString("Vertex #%1").arg(vertexIndex);
1198 myVertexName = QString(vertexName.c_str());
1200 for (int row = 0;row<rowCount;row++) {
1201 QString name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString();
1202 if (myVertexName == name) {
1209 myEnforcedTableWidget->setRowCount(rowCount+1);
1210 myEnforcedTableWidget->setSortingEnabled(false);
1211 for (int col=0;col<ENF_VER_NB_COLUMNS;col++) {
1212 QTableWidgetItem* item = new QTableWidgetItem();
1213 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1215 case ENF_VER_NAME_COLUMN:
1216 item->setData( Qt::EditRole, myVertexName );
1217 if (!geomEntry.empty()) {
1219 item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1221 item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1224 case ENF_VER_X_COLUMN:
1226 item->setData( 0, QVariant(x) );
1228 case ENF_VER_Y_COLUMN:
1230 item->setData( 0, QVariant(y) );
1232 case ENF_VER_Z_COLUMN:
1234 item->setData( 0, QVariant(z) );
1236 case ENF_VER_SIZE_COLUMN:
1237 item->setData( 0, QVariant(size) );
1239 case ENF_VER_ENTRY_COLUMN:
1240 if (!geomEntry.empty())
1241 item->setData( 0, QString(geomEntry.c_str()) );
1243 case ENF_VER_COMPOUND_COLUMN:
1244 item->setData( Qt::CheckStateRole, isCompound );
1245 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
1247 case ENF_VER_GROUP_COLUMN:
1248 if (!groupName.empty())
1249 item->setData( 0, QString(groupName.c_str()) );
1255 myEnforcedTableWidget->setItem(rowCount,col,item);
1258 connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1260 myEnforcedTableWidget->setSortingEnabled(true);
1261 // myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1262 updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1265 /** HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedMesh()
1266 This method is called when a item is added into the enforced meshes tree widget
1268 void HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedMesh()
1271 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1273 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1274 myEnfMeshWdg->deactivateSelection();
1276 for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column)
1277 myEnforcedMeshTableWidget->resizeColumnToContents(column);
1280 int selEnfMeshes = myEnfMeshWdg->NbObjects();
1281 if (selEnfMeshes == 0)
1284 std::string groupName = myMeshGroupName->text().toStdString();
1285 // if (myGlobalGroupName->isChecked())
1286 // groupName = myGlobalGroupName->text().toStdString();
1288 if (boost::trim_copy(groupName).empty())
1289 groupName = "LayersGroup"; //have to be not empty until non used
1291 int elementType = myEnfMeshConstraint->currentIndex();
1294 _PTR(Study) aStudy = SMESH::getStudy();
1295 _PTR(SObject) aSObj; //SMESH::SMESH_IDSource::_nil;
1296 QString meshEntry = myEnfMeshWdg->GetValue();
1298 if (selEnfMeshes == 1)
1300 // myEnfMesh = myEnfMeshWdg->GetObject< SMESH::SMESH_IDSource >();
1301 // std::string entry = myEnfMeshWdg->GetValue();
1302 aSObj = aStudy->FindObjectID(meshEntry.toStdString().c_str());
1303 CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj);
1304 if (!CORBA::is_nil(anObj)) {
1305 // SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1306 addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
1311 QStringList meshEntries = meshEntry.split(" ", QString::SkipEmptyParts);
1312 QStringListIterator meshEntriesIt (meshEntries);
1313 while (meshEntriesIt.hasNext()) {
1314 aSObj = aStudy->FindObjectID(meshEntriesIt.next().toStdString().c_str());
1315 CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj);
1316 if (!CORBA::is_nil(anObj)) {
1317 // SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1318 addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
1323 myEnfVertexWdg->SetObject(SMESH::SMESH_IDSource::_nil());
1325 for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column)
1326 myEnforcedMeshTableWidget->resizeColumnToContents(column);
1330 /** HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedVertex()
1331 This method is called when a item is added into the enforced vertices tree widget
1333 void HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedVertex()
1336 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1338 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1339 myEnfVertexWdg->deactivateSelection();
1341 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1342 myEnforcedTableWidget->resizeColumnToContents(column);
1345 int selEnfVertex = myEnfVertexWdg->NbObjects();
1346 bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty());
1347 if ((selEnfVertex == 0) && coordsEmpty)
1350 std::string groupName = myGroupName->text().toStdString();
1351 // if (myGlobalGroupName->isChecked())
1352 // groupName = myGlobalGroupName->text().toStdString();
1354 if (boost::trim_copy(groupName).empty())
1357 double size = mySizeValue->GetValue();
1359 if (selEnfVertex <= 1)
1361 double x = 0, y = 0, z=0;
1362 if (myXCoord->GetString() != "") {
1363 x = myXCoord->GetValue();
1364 y = myYCoord->GetValue();
1365 z = myZCoord->GetValue();
1367 if (selEnfVertex == 1) {
1368 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >();
1369 std::string entry = "";
1370 if (myEnfVertex != GEOM::GEOM_Object::_nil())
1371 entry = myEnfVertex->GetStudyEntry();
1372 addEnforcedVertex(x, y, z, size, myEnfVertex->GetName(),entry, groupName, myEnfVertex->GetShapeType() == GEOM::COMPOUND);
1375 addEnforcedVertex(x, y, z, size, "", "", groupName);
1380 if ( CORBA::is_nil(getGeomEngine()))
1383 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations();
1384 if (CORBA::is_nil(measureOp))
1387 CORBA::Double x = 0, y = 0,z = 0;
1388 for (int j = 0 ; j < selEnfVertex ; j++)
1390 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j);
1391 if (myEnfVertex == GEOM::GEOM_Object::_nil())
1393 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1394 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1395 if ( measureOp->IsDone() )
1396 addEnforcedVertex(x, y, z, size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1397 } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) {
1398 addEnforcedVertex(0., 0., 0., size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName, true);
1403 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1405 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1406 myEnforcedTableWidget->resizeColumnToContents(column);
1409 /** HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedMesh()
1410 This method is called when a item is removed from the enforced meshes tree widget
1412 void HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedMesh()
1414 QList<int> selectedRows;
1415 QList<QTableWidgetItem *> selectedItems = myEnforcedMeshTableWidget->selectedItems();
1416 QTableWidgetItem* item;
1418 foreach( item, selectedItems ) {
1420 if (!selectedRows.contains( row ) )
1421 selectedRows.append(row);
1424 qSort( selectedRows );
1425 QListIterator<int> it( selectedRows );
1427 while ( it.hasPrevious() ) {
1428 row = it.previous();
1429 myEnforcedMeshTableWidget->removeRow(row );
1432 myEnforcedMeshTableWidget->selectionModel()->clearSelection();
1435 /** HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1436 This method is called when a item is removed from the enforced vertices tree widget
1438 void HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1440 QList<int> selectedRows;
1441 QList<QTableWidgetItem *> selectedItems = myEnforcedTableWidget->selectedItems();
1442 QTableWidgetItem* item;
1444 foreach( item, selectedItems ) {
1446 if (!selectedRows.contains( row ) )
1447 selectedRows.append(row);
1450 qSort( selectedRows );
1451 QListIterator<int> it( selectedRows );
1453 while ( it.hasPrevious() ) {
1454 row = it.previous();
1455 myEnforcedTableWidget->removeRow(row );
1458 myEnforcedTableWidget->selectionModel()->clearSelection();
1461 void HYBRIDPluginGUI_HypothesisCreator::onLayersOnAllWrap(bool isOn)
1463 // myToMakeGroupsOfDomains->setEnabled( isOn );
1465 // myToMakeGroupsOfDomains->setChecked( false );
1468 void HYBRIDPluginGUI_HypothesisCreator::onToMeshHoles(bool isOn)
1470 // myToMakeGroupsOfDomains->setEnabled( isOn );
1472 // myToMakeGroupsOfDomains->setChecked( false );
1475 void HYBRIDPluginGUI_HypothesisCreator::onDirBtnClicked()
1477 QString dir = SUIT_FileDlg::getExistingDirectory( dlg(), myAdvWidget->workingDirectoryLineEdit->text(), QString() );
1478 if ( !dir.isEmpty() )
1479 myAdvWidget->workingDirectoryLineEdit->setText( dir );
1482 void HYBRIDPluginGUI_HypothesisCreator::onTabChanged( int )
1484 myEnfVertexWdg->deactivateSelection();
1485 myEnfMeshWdg->deactivateSelection();
1486 myFaceSelectorLayers->ActivateSelection( false );
1487 myFaceSelectorLayers->ShowPreview( false );
1488 myFaceSelectorImprinting->ActivateSelection( false );
1489 myFaceSelectorImprinting->ShowPreview( false );
1490 myFaceSelectorSnapping->ActivateSelection( false );
1491 myFaceSelectorSnapping->ShowPreview( false );
1494 void HYBRIDPluginGUI_HypothesisCreator::updateWidgets()
1496 //customs automatic set
1497 //myToMakeGroupsOfDomains->setEnabled( myToMeshHolesCheck->isChecked() );
1498 //myAdvWidget->maxMemorySpin->setEnabled( myAdvWidget->maxMemoryCheck->isChecked() );
1499 //myAdvWidget->initialMemoryCheck->setEnabled( !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1500 //myAdvWidget->initialMemorySpin->setEnabled( myAdvWidget->initialMemoryCheck->isChecked() && !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1501 //myOptimizationLevelCombo->setEnabled( !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1502 myMultinormalsAngleSpin->setEnabled( myAddMultinormalsCheck->isChecked() );
1503 if ( sender() == myAdvWidget->logInFileCheck ||
1504 sender() == myAdvWidget->keepWorkingFilesCheck )
1506 bool logFileRemovable = myAdvWidget->logInFileCheck->isChecked() &&
1507 !myAdvWidget->keepWorkingFilesCheck->isChecked();
1509 myAdvWidget->removeLogOnSuccessCheck->setEnabled( logFileRemovable );
1511 bool enabled = !myLayersOnAllWrapCheck->isChecked();
1512 myFacesLbl->setEnabled(enabled);
1513 myFaceSelectorLayers->setEnabled(enabled);
1514 if ( QTabWidget* tab = qobject_cast<QTabWidget*>( myStdGroup->parentWidget()->parentWidget() )) {
1515 tab->setTabEnabled( FACE_SEL_IMPRINTING_TAB, enabled );
1516 tab->setTabEnabled( FACE_SEL_SNAPPING_TAB, enabled );
1520 bool HYBRIDPluginGUI_HypothesisCreator::checkParams(QString& msg) const
1523 if ( !QFileInfo( myAdvWidget->workingDirectoryLineEdit->text().trimmed() ).isWritable() ) {
1524 SUIT_MessageBox::warning( dlg(),
1525 tr( "SMESH_WRN_WARNING" ),
1526 tr( "HYBRID_PERMISSION_DENIED" ) );
1533 void HYBRIDPluginGUI_HypothesisCreator::retrieveParams() const
1535 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1536 HYBRIDHypothesisData data;
1537 readParamsFromHypo( data );
1540 myName->setText( data.myName );
1541 myLayersOnAllWrapCheck ->setChecked ( data.myLayersOnAllWrap );
1542 myToMeshHolesCheck ->setChecked ( data.myToMeshHoles );
1543 myToMakeGroupsOfDomains ->setChecked ( data.myToMakeGroupsOfDomains );
1544 myOptimizationLevelCombo ->setCurrentIndex( data.myOptimizationLevel );
1545 myAdvWidget->maxMemoryCheck ->setChecked ( data.myMaximumMemory > 0 );
1546 myAdvWidget->maxMemorySpin ->setValue ( qMax( data.myMaximumMemory,
1547 myAdvWidget->maxMemorySpin->minimum() ));
1548 myAdvWidget->initialMemoryCheck ->setChecked ( data.myInitialMemory > 0 );
1549 myAdvWidget->initialMemorySpin ->setValue ( qMax( data.myInitialMemory,
1550 myAdvWidget->initialMemorySpin->minimum() ));
1552 myCollisionModeCombo ->setCurrentIndex( data.myCollisionMode );
1553 myBoundaryLayersGrowthCombo ->setCurrentIndex( data.myBoundaryLayersGrowth );
1554 myElementGenerationCombo ->setCurrentIndex( data.myElementGeneration );
1555 myAddMultinormalsCheck -> setChecked ( data.myAddMultinormals );
1556 mySmoothNormalsCheck -> setChecked ( data.mySmoothNormals );
1557 myHeightFirstLayerSpin -> setValue( data.myHeightFirstLayer );
1558 myNbOfBoundaryLayersSpin -> setValue( data.myNbOfBoundaryLayers );
1559 myBoundaryLayersProgressionSpin -> setValue( data.myBoundaryLayersProgression );
1560 if (data.myCoreSize <= 0)
1561 myCoreSizeSpin->setText("");
1563 myCoreSizeSpin -> setValue( data.myCoreSize );
1564 myMultinormalsAngleSpin -> setValue( data.myMultinormalsAngle );
1565 myFaceSelectorLayers ->SetListOfIDs( data.myFaceWLIds );
1566 myFaceSelectorImprinting ->SetListOfIDs( data.myFaceWIIds );
1567 myFaceSelectorSnapping ->SetListOfIDs( data.myFaceWSIds );
1569 myAdvWidget->workingDirectoryLineEdit ->setText ( data.myWorkingDir );
1570 myAdvWidget->keepWorkingFilesCheck ->setChecked( data.myKeepFiles );
1571 myAdvWidget->verboseLevelSpin ->setValue ( data.myVerboseLevel );
1572 myAdvWidget->createNewNodesCheck ->setChecked( data.myToCreateNewNodes );
1573 myAdvWidget->removeInitialCentralPointCheck ->setChecked( data.myRemoveInitialCentralPoint );
1574 myAdvWidget->boundaryRecoveryCheck ->setChecked( data.myBoundaryRecovery );
1575 myAdvWidget->FEMCorrectionCheck ->setChecked( data.myFEMCorrection );
1576 myAdvWidget->gradationSpinBox ->setValue ( data.myGradation );
1577 myAdvWidget->myAdvOptionsTable ->SetCustomOptions( data.myTextOption );
1578 myAdvWidget->logInFileCheck ->setChecked( !data.myLogInStandardOutput );
1579 myAdvWidget->removeLogOnSuccessCheck ->setChecked( data.myRemoveLogOnSuccess );
1581 TEnfVertexList::const_iterator it;
1583 myEnforcedTableWidget->clearContents();
1584 myEnforcedTableWidget->setSortingEnabled(false);
1585 myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1586 for(it = data.myEnforcedVertices.begin() ; it != data.myEnforcedVertices.end(); it++ )
1588 TEnfVertex* enfVertex = (*it);
1589 myEnforcedTableWidget->setRowCount(rowCount+1);
1591 for (int col=0;col<ENF_VER_NB_COLUMNS;col++) {
1592 QTableWidgetItem* item = new QTableWidgetItem();
1593 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1595 case ENF_VER_NAME_COLUMN:
1596 item->setData( 0, enfVertex->name.c_str() );
1597 if (!enfVertex->geomEntry.empty()) {
1598 if (enfVertex->isCompound)
1599 item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1601 item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1605 case ENF_VER_X_COLUMN:
1606 if (!enfVertex->isCompound) {
1607 item->setData( 0, enfVertex->coords.at(0) );
1610 case ENF_VER_Y_COLUMN:
1611 if (!enfVertex->isCompound) {
1612 item->setData( 0, enfVertex->coords.at(1) );
1615 case ENF_VER_Z_COLUMN:
1616 if (!enfVertex->isCompound) {
1617 item->setData( 0, enfVertex->coords.at(2) );
1620 case ENF_VER_SIZE_COLUMN:
1621 item->setData( 0, enfVertex->size );
1623 case ENF_VER_ENTRY_COLUMN:
1624 item->setData( 0, enfVertex->geomEntry.c_str() );
1626 case ENF_VER_COMPOUND_COLUMN:
1627 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
1628 item->setData( Qt::CheckStateRole, enfVertex->isCompound );
1630 case ENF_VER_GROUP_COLUMN:
1631 item->setData( 0, enfVertex->groupName.c_str() );
1637 myEnforcedTableWidget->setItem(rowCount,col,item);
1639 that->updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1643 connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1644 myEnforcedTableWidget->setSortingEnabled(true);
1646 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1647 myEnforcedTableWidget->resizeColumnToContents(column);
1649 // Update Enforced meshes QTableWidget
1650 TEnfMeshList::const_iterator itMesh;
1652 myEnforcedMeshTableWidget->clearContents();
1653 myEnforcedMeshTableWidget->setSortingEnabled(false);
1654 // myEnforcedMeshTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1655 for(itMesh = data.myEnforcedMeshes.begin() ; itMesh != data.myEnforcedMeshes.end(); itMesh++ )
1657 TEnfMesh* enfMesh = (*itMesh);
1658 myEnforcedMeshTableWidget->setRowCount(rowCount+1);
1660 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++) {
1661 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1662 QComboBox* comboBox = new QComboBox();
1663 QPalette pal = comboBox->palette();
1664 pal.setColor(QPalette::Button, Qt::white);
1665 comboBox->setPalette(pal);
1666 comboBox->insertItems(0,myEnfMeshConstraintLabels);
1667 comboBox->setEditable(false);
1668 comboBox->setCurrentIndex(enfMesh->elementType);
1669 myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox);
1672 QTableWidgetItem* item = new QTableWidgetItem();
1673 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1675 case ENF_MESH_NAME_COLUMN:
1676 item->setData( 0, enfMesh->name.c_str() );
1677 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1678 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1680 case ENF_MESH_ENTRY_COLUMN:
1681 item->setData( 0, enfMesh->entry.c_str() );
1682 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1683 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1685 case ENF_MESH_GROUP_COLUMN:
1686 item->setData( 0, enfMesh->groupName.c_str() );
1687 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1694 // myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1696 // that->updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1700 // connect( myEnforcedMeshTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1701 myEnforcedMeshTableWidget->setSortingEnabled(true);
1703 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++)
1704 myEnforcedMeshTableWidget->resizeColumnToContents(col);
1706 that->updateWidgets();
1707 that->checkVertexIsDefined();
1710 QString HYBRIDPluginGUI_HypothesisCreator::storeParams() const
1712 HYBRIDHypothesisData data;
1713 readParamsFromWidgets( data );
1714 storeParamsToHypo( data );
1716 QString valStr = "";
1718 if ( !data.myBoundaryRecovery )
1719 valStr = "-c " + QString::number( !data.myToMeshHoles );
1721 if ( data.myOptimizationLevel >= 0 && data.myOptimizationLevel < 5 && !data.myBoundaryRecovery) {
1722 const char* level[] = { "none" , "light" , "standard" , "standard+" , "strong" };
1724 valStr += level[ data.myOptimizationLevel ];
1726 if ( data.myMaximumMemory > 0 ) {
1728 valStr += QString::number( data.myMaximumMemory );
1730 if ( data.myInitialMemory > 0 && !data.myBoundaryRecovery ) {
1732 valStr += QString::number( data.myInitialMemory );
1735 valStr += QString::number( data.myVerboseLevel );
1737 if ( !data.myToCreateNewNodes )
1740 if ( data.myRemoveInitialCentralPoint )
1741 valStr += " -no_initial_central_point";
1743 if ( data.myBoundaryRecovery )
1746 if ( data.myFEMCorrection )
1749 if ( data.myGradation != 1.05 ) {
1750 valStr += " -Dcpropa=";
1751 valStr += QString::number( data.myGradation );
1755 valStr += data.myTextOption;
1757 // valStr += " #BEGIN ENFORCED VERTICES#";
1758 // // Add size map parameters storage
1759 // for (int i=0 ; i<mySmpModel->rowCount() ; i++) {
1761 // double x = mySmpModel->data(mySmpModel->index(i,ENF_VER_X_COLUMN)).toDouble();
1762 // double y = mySmpModel->data(mySmpModel->index(i,ENF_VER_Y_COLUMN)).toDouble();
1763 // double z = mySmpModel->data(mySmpModel->index(i,ENF_VER_Z_COLUMN)).toDouble();
1764 // double size = mySmpModel->data(mySmpModel->index(i,ENF_VER_SIZE_COLUMN)).toDouble();
1765 // valStr += QString::number( x );
1767 // valStr += QString::number( y );
1769 // valStr += QString::number( z );
1771 // valStr += QString::number( size );
1772 // if (i!=mySmpModel->rowCount()-1)
1775 // valStr += " #END ENFORCED VERTICES#";
1779 bool HYBRIDPluginGUI_HypothesisCreator::readParamsFromHypo( HYBRIDHypothesisData& h_data ) const
1781 HYBRIDPlugin::HYBRIDPlugin_Hypothesis_var h =
1782 HYBRIDPlugin::HYBRIDPlugin_Hypothesis::_narrow( initParamsHypothesis() );
1784 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
1785 h_data.myName = isCreation() && data ? hypName() : "";
1787 h_data.myCollisionMode = h->GetCollisionMode();
1788 h_data.myBoundaryLayersGrowth = h->GetBoundaryLayersGrowth();
1789 h_data.myElementGeneration = h->GetElementGeneration();
1790 h_data.myAddMultinormals = h->GetAddMultinormals();
1791 h_data.mySmoothNormals = h->GetSmoothNormals();
1792 h_data.myHeightFirstLayer = h->GetHeightFirstLayer();
1793 h_data.myBoundaryLayersProgression = h->GetBoundaryLayersProgression();
1794 h_data.myCoreSize = h->GetCoreSize();
1795 h_data.myMultinormalsAngle = h->GetMultinormalsAngle();
1796 h_data.myNbOfBoundaryLayers = h->GetNbOfBoundaryLayers();
1797 h_data.myFaceWLIds = h->GetFacesWithLayers();
1798 h_data.myFaceWIIds = h->GetFacesWithImprinting();
1799 h_data.myFaceWSIds = h->GetFacesWithSnapping();
1801 h_data.myLayersOnAllWrap = h->GetLayersOnAllWrap();
1802 h_data.myToMeshHoles = h->GetToMeshHoles();
1803 h_data.myToMakeGroupsOfDomains = /*h->GetToMeshHoles() &&*/ h->GetToMakeGroupsOfDomains();
1804 h_data.myMaximumMemory = h->GetMaximumMemory();
1805 h_data.myInitialMemory = h->GetInitialMemory();
1806 h_data.myInitialMemory = h->GetInitialMemory();
1807 h_data.myOptimizationLevel = h->GetOptimizationLevel();
1809 h_data.myKeepFiles = h->GetKeepFiles();
1810 h_data.myWorkingDir = h->GetWorkingDirectory();
1811 h_data.myVerboseLevel = h->GetVerboseLevel();
1812 h_data.myToCreateNewNodes = h->GetToCreateNewNodes();
1813 h_data.myRemoveInitialCentralPoint = h->GetToRemoveCentralPoint();
1814 h_data.myBoundaryRecovery = h->GetToUseBoundaryRecoveryVersion();
1815 h_data.myFEMCorrection = h->GetFEMCorrection();
1816 h_data.myGradation = h->GetGradation();
1817 h_data.myTextOption = h->GetAdvancedOption();
1818 h_data.myLogInStandardOutput = h->GetStandardOutputLog();
1819 h_data.myRemoveLogOnSuccess = h->GetRemoveLogOnSuccess();
1821 HYBRIDPlugin::HYBRIDEnforcedVertexList_var vertices = h->GetEnforcedVertices();
1822 h_data.myEnforcedVertices.clear();
1823 for (CORBA::ULong i=0 ; i<vertices->length() ; i++) {
1824 TEnfVertex* myVertex = new TEnfVertex();
1825 myVertex->name = CORBA::string_dup(vertices[i].name.in());
1826 myVertex->geomEntry = CORBA::string_dup(vertices[i].geomEntry.in());
1827 myVertex->groupName = CORBA::string_dup(vertices[i].groupName.in());
1828 myVertex->size = vertices[i].size;
1829 myVertex->isCompound = vertices[i].isCompound;
1830 if (vertices[i].coords.length()) {
1831 for (CORBA::ULong c = 0; c < vertices[i].coords.length() ; c++)
1832 myVertex->coords.push_back(vertices[i].coords[c]);
1834 h_data.myEnforcedVertices.insert(myVertex);
1837 HYBRIDPlugin::HYBRIDEnforcedMeshList_var enfMeshes = h->GetEnforcedMeshes();
1838 h_data.myEnforcedMeshes.clear();
1839 for (CORBA::ULong i=0 ; i<enfMeshes->length() ; i++) {
1840 TEnfMesh* myEnfMesh = new TEnfMesh();
1841 myEnfMesh->name = CORBA::string_dup(enfMeshes[i].name.in());
1842 myEnfMesh->entry = CORBA::string_dup(enfMeshes[i].entry.in());
1843 myEnfMesh->groupName = CORBA::string_dup(enfMeshes[i].groupName.in());
1844 switch (enfMeshes[i].elementType) {
1846 myEnfMesh->elementType = 0;
1849 myEnfMesh->elementType = 1;
1852 myEnfMesh->elementType = 2;
1857 // myEnfMesh->elementType = enfMeshes[i].elementType;
1858 h_data.myEnforcedMeshes.insert(myEnfMesh);
1863 bool HYBRIDPluginGUI_HypothesisCreator::storeParamsToHypo( const HYBRIDHypothesisData& h_data ) const
1865 HYBRIDPlugin::HYBRIDPlugin_Hypothesis_var h =
1866 HYBRIDPlugin::HYBRIDPlugin_Hypothesis::_narrow( hypothesis() );
1872 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
1874 if ( h->GetLayersOnAllWrap() != h_data.myLayersOnAllWrap ) // avoid duplication of DumpPython commands
1875 h->SetLayersOnAllWrap ( h_data.myLayersOnAllWrap );
1876 if ( h->GetToMeshHoles() != h_data.myToMeshHoles ) // avoid duplication of DumpPython commands
1877 h->SetToMeshHoles ( h_data.myToMeshHoles );
1878 if ( h->GetToMakeGroupsOfDomains() != h_data.myToMakeGroupsOfDomains )
1879 h->SetToMakeGroupsOfDomains( h_data.myToMakeGroupsOfDomains );
1880 if ( h->GetMaximumMemory() != h_data.myMaximumMemory )
1881 h->SetMaximumMemory ( h_data.myMaximumMemory );
1882 if ( h->GetInitialMemory() != h_data.myInitialMemory )
1883 h->SetInitialMemory ( h_data.myInitialMemory );
1884 if ( h->GetInitialMemory() != h_data.myInitialMemory )
1885 h->SetInitialMemory ( h_data.myInitialMemory );
1886 if ( h->GetOptimizationLevel() != h_data.myOptimizationLevel )
1887 h->SetOptimizationLevel( h_data.myOptimizationLevel );
1889 if ( h->GetCollisionMode() != h_data.myCollisionMode )
1890 h->SetCollisionMode( h_data.myCollisionMode );
1891 if ( h->GetBoundaryLayersGrowth() != h_data.myBoundaryLayersGrowth )
1892 h->SetBoundaryLayersGrowth( h_data.myBoundaryLayersGrowth );
1893 if ( h->GetElementGeneration() != h_data.myElementGeneration )
1894 h->SetElementGeneration( h_data.myElementGeneration );
1896 if ( h->GetAddMultinormals() != h_data.myAddMultinormals )
1897 h->SetAddMultinormals ( h_data.myAddMultinormals );
1898 if ( h->GetSmoothNormals() != h_data.mySmoothNormals )
1899 h->SetSmoothNormals ( h_data.mySmoothNormals );
1900 if ( h->GetHeightFirstLayer() != h_data.myHeightFirstLayer )
1901 h->SetHeightFirstLayer ( h_data.myHeightFirstLayer );
1902 if ( h->GetBoundaryLayersProgression() != h_data.myBoundaryLayersProgression )
1903 h->SetBoundaryLayersProgression ( h_data.myBoundaryLayersProgression );
1904 if ( h->GetCoreSize() != h_data.myCoreSize )
1905 h->SetCoreSize ( h_data.myCoreSize );
1906 if ( h->GetMultinormalsAngle() != h_data.myMultinormalsAngle )
1907 h->SetMultinormalsAngle ( h_data.myMultinormalsAngle );
1908 if ( h->GetNbOfBoundaryLayers() != h_data.myNbOfBoundaryLayers )
1909 h->SetNbOfBoundaryLayers ( h_data.myNbOfBoundaryLayers );
1910 h->SetFacesWithLayers( h_data.myFaceWLIds );
1911 h->SetFacesWithImprinting( h_data.myFaceWIIds );
1912 h->SetFacesWithSnapping( h_data.myFaceWSIds );
1914 if ( h->GetKeepFiles() != h_data.myKeepFiles)
1915 h->SetKeepFiles ( h_data.myKeepFiles);
1916 if ( h->GetWorkingDirectory() != h_data.myWorkingDir )
1917 h->SetWorkingDirectory ( h_data.myWorkingDir.toLatin1().constData() );
1918 if ( h->GetVerboseLevel() != h_data.myVerboseLevel )
1919 h->SetVerboseLevel ( h_data.myVerboseLevel );
1920 if ( h->GetToCreateNewNodes() != h_data.myToCreateNewNodes )
1921 h->SetToCreateNewNodes ( h_data.myToCreateNewNodes );
1922 if ( h->GetToRemoveCentralPoint() != h_data.myRemoveInitialCentralPoint )
1923 h->SetToRemoveCentralPoint ( h_data.myRemoveInitialCentralPoint );
1924 if ( h->GetToUseBoundaryRecoveryVersion() != h_data.myBoundaryRecovery )
1925 h->SetToUseBoundaryRecoveryVersion ( h_data.myBoundaryRecovery );
1926 if ( h->GetFEMCorrection() != h_data.myFEMCorrection )
1927 h->SetFEMCorrection ( h_data.myFEMCorrection );
1928 if ( h->GetGradation() != h_data.myGradation )
1929 h->SetGradation ( h_data.myGradation );
1930 if ( h->GetTextOption() != h_data.myTextOption )
1931 h->SetAdvancedOption ( h_data.myTextOption.toLatin1().constData() );
1932 if ( h->GetStandardOutputLog() != h_data.myLogInStandardOutput )
1933 h->SetStandardOutputLog ( h_data.myLogInStandardOutput );
1934 if ( h->GetRemoveLogOnSuccess() != h_data.myRemoveLogOnSuccess )
1935 h->SetRemoveLogOnSuccess ( h_data.myRemoveLogOnSuccess );
1937 // Enforced vertices
1938 //int nbVertex = (int) h_data.myEnforcedVertices.size();
1939 HYBRIDPlugin::HYBRIDEnforcedVertexList_var vertexHyp = h->GetEnforcedVertices();
1940 int nbVertexHyp = vertexHyp->length();
1943 // 1. Clear all enforced vertices in hypothesis
1944 // 2. Add new enforced vertex according to h_data
1945 if ( nbVertexHyp > 0)
1946 h->ClearEnforcedVertices();
1948 TEnfVertexList::const_iterator it;
1949 double x = 0, y = 0, z = 0;
1950 for(it = h_data.myEnforcedVertices.begin() ; it != h_data.myEnforcedVertices.end(); it++ ) {
1951 TEnfVertex* enfVertex = (*it);
1953 if (enfVertex->coords.size()) {
1954 x = enfVertex->coords.at(0);
1955 y = enfVertex->coords.at(1);
1956 z = enfVertex->coords.at(2);
1958 ok = h->p_SetEnforcedVertex( enfVertex->size, x, y, z, enfVertex->name.c_str(), enfVertex->geomEntry.c_str(), enfVertex->groupName.c_str(), enfVertex->isCompound);
1962 //int nbEnfMeshes = (int) h_data.myEnforcedMeshes.size();
1963 HYBRIDPlugin::HYBRIDEnforcedMeshList_var enfMeshListHyp = h->GetEnforcedMeshes();
1964 int nbEnfMeshListHyp = enfMeshListHyp->length();
1967 // 1. Clear all enforced vertices in hypothesis
1968 // 2. Add new enforced vertex according to h_data
1969 if ( nbEnfMeshListHyp > 0)
1970 h->ClearEnforcedMeshes();
1972 TEnfMeshList::const_iterator itEnfMesh;
1974 _PTR(Study) aStudy = SMESH::getStudy();
1976 for(itEnfMesh = h_data.myEnforcedMeshes.begin() ; itEnfMesh != h_data.myEnforcedMeshes.end(); itEnfMesh++ ) {
1977 TEnfMesh* enfMesh = (*itEnfMesh);
1979 _PTR(SObject) aSObj = aStudy->FindObjectID(enfMesh->entry.c_str());
1980 SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1982 SMESH::ElementType elementType;
1983 switch(enfMesh->elementType) {
1985 elementType = SMESH::NODE;
1988 elementType = SMESH::EDGE;
1991 elementType = SMESH::FACE;
1997 std::cout << "h->p_SetEnforcedMesh(theSource, "<< elementType <<", \""<< enfMesh->name << "\", \"" << enfMesh->groupName.c_str() <<"\")"<<std::endl;
1998 ok = h->p_SetEnforcedMesh(theSource, elementType, enfMesh->name.c_str(), enfMesh->groupName.c_str());
2001 // catch(const std::exception& ex) {
2002 // std::cout << "Exception: " << ex.what() << std::endl;
2005 catch ( const SALOME::SALOME_Exception& ex )
2007 SalomeApp_Tools::QtCatchCorbaException( ex );
2013 bool HYBRIDPluginGUI_HypothesisCreator::readParamsFromWidgets( HYBRIDHypothesisData& h_data ) const
2015 h_data.myName = myName ? myName->text() : "";
2016 h_data.myLayersOnAllWrap = myLayersOnAllWrapCheck->isChecked();
2017 h_data.myToMeshHoles = myToMeshHolesCheck->isChecked();
2018 h_data.myToMakeGroupsOfDomains = myToMakeGroupsOfDomains->isChecked();
2019 h_data.myMaximumMemory = myAdvWidget->maxMemoryCheck->isChecked() ? myAdvWidget->maxMemorySpin->value() : -1;
2020 h_data.myInitialMemory = myAdvWidget->initialMemoryCheck->isChecked() ? myAdvWidget->initialMemorySpin->value() : -1;
2021 h_data.myOptimizationLevel = myOptimizationLevelCombo->currentIndex();
2023 h_data.myCollisionMode = myCollisionModeCombo->currentIndex();
2024 h_data.myBoundaryLayersGrowth = myBoundaryLayersGrowthCombo->currentIndex();
2025 h_data.myElementGeneration = myElementGenerationCombo->currentIndex();
2026 h_data.myAddMultinormals = myAddMultinormalsCheck->isChecked();
2027 h_data.mySmoothNormals = mySmoothNormalsCheck->isChecked();
2029 h_data.myHeightFirstLayer = myHeightFirstLayerSpin -> value();
2030 h_data.myNbOfBoundaryLayers = myNbOfBoundaryLayersSpin -> value();
2031 h_data.myBoundaryLayersProgression = myBoundaryLayersProgressionSpin -> value();
2032 h_data.myCoreSize = myCoreSizeSpin->text().isEmpty() ? 0.0 : myCoreSizeSpin -> value();
2033 h_data.myMultinormalsAngle = myMultinormalsAngleSpin -> value();
2034 h_data.myFaceWLIds = myFaceSelectorLayers->GetListOfIDs();
2035 h_data.myFaceWIIds = myFaceSelectorImprinting->GetListOfIDs();
2036 h_data.myFaceWSIds = myFaceSelectorSnapping->GetListOfIDs();
2038 h_data.myKeepFiles = myAdvWidget->keepWorkingFilesCheck->isChecked();
2039 h_data.myWorkingDir = myAdvWidget->workingDirectoryLineEdit->text().trimmed();
2040 h_data.myVerboseLevel = myAdvWidget->verboseLevelSpin->value();
2041 h_data.myToCreateNewNodes = myAdvWidget->createNewNodesCheck->isChecked();
2042 h_data.myRemoveInitialCentralPoint = myAdvWidget->removeInitialCentralPointCheck->isChecked();
2043 h_data.myBoundaryRecovery = myAdvWidget->boundaryRecoveryCheck->isChecked();
2044 h_data.myFEMCorrection = myAdvWidget->FEMCorrectionCheck->isChecked();
2045 h_data.myGradation = myAdvWidget->gradationSpinBox->value();
2046 h_data.myTextOption = myAdvWidget->myAdvOptionsTable->GetCustomOptions();
2047 h_data.myLogInStandardOutput = !myAdvWidget->logInFileCheck->isChecked();
2048 h_data.myRemoveLogOnSuccess = myAdvWidget->removeLogOnSuccessCheck->isChecked();
2050 // Enforced vertices
2051 h_data.myEnforcedVertices.clear();
2052 QVariant valueX, valueY, valueZ;
2053 for (int row=0 ; row<myEnforcedTableWidget->rowCount() ; row++) {
2055 TEnfVertex *myVertex = new TEnfVertex();
2056 myVertex->name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString();
2057 myVertex->geomEntry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString();
2058 if (myVertex->geomEntry.size())
2059 myVertex->groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
2060 if (myVertex->groupName.size())
2061 valueX = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data(Qt::EditRole);
2062 valueY = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data(Qt::EditRole);
2063 valueZ = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data(Qt::EditRole);
2064 if (!valueX.isNull() && !valueY.isNull() && !valueZ.isNull()) {
2065 myVertex->coords.push_back(valueX.toDouble());
2066 myVertex->coords.push_back(valueY.toDouble());
2067 myVertex->coords.push_back(valueZ.toDouble());
2069 myVertex->size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data(Qt::EditRole).toDouble();
2070 myVertex->isCompound = myEnforcedTableWidget->item(row,ENF_VER_COMPOUND_COLUMN)->data(Qt::CheckStateRole).toBool();
2071 h_data.myEnforcedVertices.insert(myVertex);
2075 h_data.myEnforcedMeshes.clear();
2077 for (int row=0 ; row<myEnforcedMeshTableWidget->rowCount() ; row++) {
2079 TEnfMesh *myEnfMesh = new TEnfMesh();
2080 myEnfMesh->name = myEnforcedMeshTableWidget->item(row,ENF_MESH_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString();
2081 myEnfMesh->entry = myEnforcedMeshTableWidget->item(row,ENF_MESH_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString();
2082 myEnfMesh->groupName = myEnforcedMeshTableWidget->item(row,ENF_MESH_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
2083 QComboBox* combo = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row,ENF_MESH_CONSTRAINT_COLUMN));
2084 myEnfMesh->elementType = combo->currentIndex();
2085 h_data.myEnforcedMeshes.insert(myEnfMesh);
2086 std::cout << "h_data.myEnforcedMeshes.size(): " << h_data.myEnforcedMeshes.size() << std::endl;
2092 QString HYBRIDPluginGUI_HypothesisCreator::caption() const
2094 return tr( "HYBRID_TITLE" );
2097 QPixmap HYBRIDPluginGUI_HypothesisCreator::icon() const
2099 return SUIT_Session::session()->resourceMgr()->loadPixmap( "HYBRIDPlugin", tr( "ICON_DLG_HYBRID_PARAMETERS" ) );
2102 QString HYBRIDPluginGUI_HypothesisCreator::type() const
2104 return tr( "HYBRID_HYPOTHESIS" );
2107 QString HYBRIDPluginGUI_HypothesisCreator::helpPage() const
2109 return "hybrid_hypo_page.html";