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" ) << tr( "HYBRID_GENERATION_CARTESIAN_CORE" );
449 myElementGenerationCombo->addItems( typesElementGeneration );
451 aStdLayout->addWidget( new QLabel( tr( "HYBRID_CORE_SIZE" ), myStdGroup ), row, 0, 1, 1 );
452 myCoreSizeSpin = new SMESHGUI_SpinBox( myStdGroup );
453 myCoreSizeSpin->RangeStepAndValidator(0., COORD_MAX, 10., "length_precision");
454 aStdLayout->addWidget( myCoreSizeSpin, row++, 1, 1, 1 );
456 myAddMultinormalsCheck = new QCheckBox( tr( "HYBRID_ADD_MULTINORMALS" ), myStdGroup );
457 aStdLayout->addWidget( myAddMultinormalsCheck, row++, 0, 1, 1 );
459 aStdLayout->addWidget( new QLabel( tr( "HYBRID_MULTINORMAL_ANGLE" ), myStdGroup ), row, 0, 1, 1 );
460 myMultinormalsAngleSpin = new SMESHGUI_SpinBox( myStdGroup );
461 myMultinormalsAngleSpin->RangeStepAndValidator(0., 90., 2., "threshold");
462 aStdLayout->addWidget( myMultinormalsAngleSpin, row++, 1, 1, 1 );
464 mySmoothNormalsCheck = new QCheckBox( tr( "HYBRID_SMOOTH_NORMALS" ), myStdGroup );
465 aStdLayout->addWidget( mySmoothNormalsCheck, row++, 0, 1, 1 );
466 aStdLayout->setRowStretch( row, 10 );
468 // advanced parameters
469 myAdvGroup = new QWidget();
470 QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup );
471 anAdvLayout->setSpacing( 6 );
472 anAdvLayout->setMargin( 11 );
473 myAdvWidget = new HYBRIDPluginGUI_AdvWidget(myAdvGroup);
474 anAdvLayout->addWidget( myAdvWidget);
476 myAdvWidget->maxMemoryCheck->setText(tr( "MAX_MEMORY_SIZE" ));
477 myAdvWidget->initialMemoryCheck->setText(tr( "INIT_MEMORY_SIZE" ));
479 myAdvWidget->maxMemorySpin->RangeStepAndValidator(20.0, 1e6, 10.0);
480 myAdvWidget->maxMemorySpin->setValue( 128.0 );
482 myAdvWidget->initialMemorySpin->RangeStepAndValidator(0.0, 1e6, 10.0);
483 myAdvWidget->initialMemorySpin->setValue( 100.0 );
485 myAdvWidget->initialMemoryLabel ->setText (tr( "MEGABYTE" ));
486 myAdvWidget->maxMemoryLabel ->setText (tr( "MEGABYTE" ));
488 myAdvWidget->workingDirectoryPushButton ->setText (tr( "SELECT_DIR" ));
489 myAdvWidget->keepWorkingFilesCheck ->setText (tr( "KEEP_WORKING_FILES" ));
490 myAdvWidget->verboseLevelLabel ->setText (tr( "VERBOSE_LEVEL" ));
491 myAdvWidget->removeLogOnSuccessCheck ->setText (tr( "REMOVE_LOG_ON_SUCCESS" ));
492 myAdvWidget->logInFileCheck ->setText (tr( "LOG_IN_FILE" ));
494 myAdvWidget->memoryGroupBox ->setTitle(tr( "MEMORY_GROUP_TITLE" ));
495 myAdvWidget->logGroupBox ->setTitle(tr( "LOG_GROUP_TITLE" ));
496 myAdvWidget->advancedMeshingGroupBox ->setTitle(tr( "ADVANCED_MESHING_GROUP_TITLE" ));
498 myAdvWidget->memoryGroupBox->hide();
500 myAdvWidget->createNewNodesCheck->hide();
501 //myAdvWidget->createNewNodesLabel->hide();
502 myAdvWidget->removeInitialCentralPointCheck->hide();
503 myAdvWidget->boundaryRecoveryCheck->hide();
504 myAdvWidget->FEMCorrectionCheck->hide();
505 myAdvWidget->gradationLabel->hide();
506 myAdvWidget->gradationSpinBox->hide();
508 myAdvWidget->createNewNodesCheck ->setText (tr( "TO_ADD_NODES" ));
509 myAdvWidget->removeInitialCentralPointCheck->setText (tr( "NO_INITIAL_CENTRAL_POINT" ));
510 myAdvWidget->boundaryRecoveryCheck ->setText (tr( "RECOVERY_VERSION" ));
511 myAdvWidget->FEMCorrectionCheck ->setText (tr( "FEM_CORRECTION" ));
512 myAdvWidget->gradationLabel ->setText (tr( "HYBRID_GRADATION" ));
513 myAdvWidget->gradationSpinBox->RangeStepAndValidator(1.05, 5.0, 0.05, "length_precision");
515 // Enforced vertices parameters
516 myEnfGroup = new QWidget();
517 QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup);
518 myEnforcedTableWidget = new QTableWidget(myEnfGroup);
519 myEnforcedTableWidget ->setMinimumWidth(300);
520 myEnforcedTableWidget->setRowCount( 0 );
521 myEnforcedTableWidget->setColumnCount( ENF_VER_NB_COLUMNS );
522 myEnforcedTableWidget->setSortingEnabled(true);
523 QStringList enforcedHeaders;
524 enforcedHeaders << tr( "HYBRID_ENF_NAME_COLUMN" )
525 << tr( "HYBRID_ENF_VER_X_COLUMN" )<< tr( "HYBRID_ENF_VER_Y_COLUMN" ) << tr( "HYBRID_ENF_VER_Z_COLUMN" )
526 << tr( "HYBRID_ENF_SIZE_COLUMN" ) << tr("HYBRID_ENF_ENTRY_COLUMN") << tr("HYBRID_ENF_VER_COMPOUND_COLUMN") << tr( "HYBRID_ENF_GROUP_COLUMN" );
528 myEnforcedTableWidget->setHorizontalHeaderLabels(enforcedHeaders);
529 myEnforcedTableWidget->verticalHeader()->hide();
530 myEnforcedTableWidget->horizontalHeader()->setStretchLastSection(true);
531 myEnforcedTableWidget->setAlternatingRowColors(true);
532 myEnforcedTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
533 myEnforcedTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
534 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
535 myEnforcedTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
537 myEnforcedTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
539 myEnforcedTableWidget->resizeColumnsToContents();
540 myEnforcedTableWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
541 myEnforcedTableWidget->hideColumn(ENF_VER_COMPOUND_COLUMN);
543 myEnforcedTableWidget->setItemDelegate(new EnforcedVertexTableWidgetDelegate());
546 TColStd_MapOfInteger shapeTypes;
547 shapeTypes.Add( TopAbs_VERTEX );
548 shapeTypes.Add( TopAbs_COMPOUND );
550 SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes);
551 myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true);
552 myEnfVertexWdg->SetDefaultText(tr("HYBRID_ENF_SELECT_VERTEX"), "QLineEdit { color: grey }");
554 QLabel* myXCoordLabel = new QLabel( tr( "HYBRID_ENF_VER_X_LABEL" ), myEnfGroup );
555 myXCoord = new SMESHGUI_SpinBox(myEnfGroup);
556 myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
557 QLabel* myYCoordLabel = new QLabel( tr( "HYBRID_ENF_VER_Y_LABEL" ), myEnfGroup );
558 myYCoord = new SMESHGUI_SpinBox(myEnfGroup);
559 myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
560 QLabel* myZCoordLabel = new QLabel( tr( "HYBRID_ENF_VER_Z_LABEL" ), myEnfGroup );
561 myZCoord = new SMESHGUI_SpinBox(myEnfGroup);
562 myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
563 QLabel* mySizeLabel = new QLabel( tr( "HYBRID_ENF_SIZE_LABEL" ), myEnfGroup );
564 mySizeValue = new SMESHGUI_SpinBox(myEnfGroup);
565 mySizeValue->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
567 QLabel* myGroupNameLabel = new QLabel( tr( "HYBRID_ENF_GROUP_LABEL" ), myEnfGroup );
568 myGroupName = new QLineEdit(myEnfGroup);
570 addVertexButton = new QPushButton(tr("HYBRID_ENF_ADD"),myEnfGroup);
571 addVertexButton->setEnabled(false);
572 removeVertexButton = new QPushButton(tr("HYBRID_ENF_REMOVE"),myEnfGroup);
573 // myGlobalGroupName = new QCheckBox(tr("HYBRID_ENF_VER_GROUPS"), myEnfGroup);
574 // myGlobalGroupName->setChecked(false);
576 // QGroupBox* GroupBox = new QGroupBox( myEnfGroup );
577 // QLabel* info = new QLabel( GroupBox );
578 // info->setText( tr( "HYBRID_ENF_VER_INFO" ) );
579 // info->setWordWrap( true );
580 // QVBoxLayout* GroupBoxVLayout = new QVBoxLayout( GroupBox );
581 // GroupBoxVLayout->setSpacing( 6 );
582 // GroupBoxVLayout->setMargin( 11 );
583 // GroupBoxVLayout->addWidget( info );
586 //anEnfLayout->addWidget(GroupBox, ENF_VER_WARNING, 0, 1, 2 );
587 anEnfLayout->addWidget(myEnforcedTableWidget, ENF_VER_VERTEX, 0, ENF_VER_NB_LINES, 1);
589 QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup);
590 anEnfLayout2->addWidget(myEnfVertexWdg, ENF_VER_VERTEX, 0, 1, 2);
591 anEnfLayout2->addWidget(myXCoordLabel, ENF_VER_X_COORD, 0, 1, 1);
592 anEnfLayout2->addWidget(myXCoord, ENF_VER_X_COORD, 1, 1, 1);
593 anEnfLayout2->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 0, 1, 1);
594 anEnfLayout2->addWidget(myYCoord, ENF_VER_Y_COORD, 1, 1, 1);
595 anEnfLayout2->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 0, 1, 1);
596 anEnfLayout2->addWidget(myZCoord, ENF_VER_Z_COORD, 1, 1, 1);
597 anEnfLayout2->addWidget(mySizeLabel, ENF_VER_SIZE, 0, 1, 1);
598 anEnfLayout2->addWidget(mySizeValue, ENF_VER_SIZE, 1, 1, 1);
599 anEnfLayout2->addWidget(myGroupNameLabel, ENF_VER_GROUP, 0, 1, 1);
600 anEnfLayout2->addWidget(myGroupName, ENF_VER_GROUP, 1, 1, 1);
601 anEnfLayout2->addWidget(addVertexButton, ENF_VER_BTN, 0, 1, 1);
602 anEnfLayout2->addWidget(removeVertexButton, ENF_VER_BTN, 1, 1, 1);
603 anEnfLayout2->setRowStretch(ENF_VER_NB_LINES, 1);
605 anEnfLayout->addLayout(anEnfLayout2, ENF_VER_VERTEX, 1,ENF_VER_NB_LINES, 1);
606 anEnfLayout->setRowStretch(ENF_VER_VERTEX, 10);
608 // Enforced meshes parameters
609 myEnfMeshGroup = new QWidget();
610 myLayersOnAllWrapCheck = new QCheckBox( tr( "HYBRID_LAYERS_ON_ALL_WRAP" ), myEnfMeshGroup );
611 QGridLayout* anEnfMeshLayout = new QGridLayout(myEnfMeshGroup);
613 myEnforcedMeshTableWidget = new QTableWidget(myEnfGroup);
614 myEnforcedMeshTableWidget->setRowCount( 0 );
615 myEnforcedMeshTableWidget->setColumnCount( ENF_MESH_NB_COLUMNS );
616 myEnforcedMeshTableWidget->setSortingEnabled(true);
617 myEnforcedMeshTableWidget->verticalHeader()->hide();
618 QStringList enforcedMeshHeaders;
619 enforcedMeshHeaders << tr( "HYBRID_ENF_NAME_COLUMN" )
620 << tr( "HYBRID_ENF_ENTRY_COLUMN" )
621 << tr( "HYBRID_ENF_MESH_CONSTRAINT_COLUMN" )
622 << tr( "HYBRID_ENF_GROUP_COLUMN" );
623 myEnforcedMeshTableWidget->setHorizontalHeaderLabels(enforcedMeshHeaders);
624 myEnforcedMeshTableWidget->horizontalHeader()->setStretchLastSection(true);
625 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
626 myEnforcedMeshTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
628 myEnforcedMeshTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
630 myEnforcedMeshTableWidget->setAlternatingRowColors(true);
631 myEnforcedMeshTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
632 myEnforcedMeshTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
633 myEnforcedMeshTableWidget->resizeColumnsToContents();
634 myEnforcedMeshTableWidget->hideColumn(ENF_MESH_ENTRY_COLUMN);
636 myEnforcedMeshTableWidget->setItemDelegate(new EnforcedMeshTableWidgetDelegate());
638 // myEnfMesh = SMESH::SMESH_Mesh::_nil();
639 // myEnfMeshArray = new SMESH::mesh_array();
641 myEnfMeshWdg = new StdMeshersGUI_ObjectReferenceParamWdg( SMESH::IDSOURCE, myEnfMeshGroup, /*multiSel=*/true);
642 myEnfMeshWdg->SetDefaultText(tr("HYBRID_ENF_SELECT_MESH"), "QLineEdit { color: grey }");
644 myEnfMeshWdg->AvoidSimultaneousSelection(myEnfVertexWdg);
645 ////myEnfMeshWdg->hide(); //may be used later
647 QLabel* myMeshConstraintLabel = new QLabel( tr( "HYBRID_ENF_MESH_CONSTRAINT_LABEL" ), myEnfMeshGroup );
648 myEnfMeshConstraint = new QComboBox(myEnfMeshGroup);
649 myEnfMeshConstraint->insertItems(0,myEnfMeshConstraintLabels);
650 myEnfMeshConstraint->setEditable(false);
651 myEnfMeshConstraint->setCurrentIndex(2); //EZ: use mesh group of faces for a layer
652 myMeshConstraintLabel->hide(); //may be used later
653 myEnfMeshConstraint->hide(); //may be used later
655 QLabel* myMeshGroupNameLabel = new QLabel( tr( "HYBRID_ENF_GROUP_LABEL" ), myEnfMeshGroup );
656 myMeshGroupName = new QLineEdit(myEnfMeshGroup);
657 myMeshGroupNameLabel->hide(); //may be used later
658 myMeshGroupName->hide(); //may be used later
660 addEnfMeshButton = new QPushButton(tr("HYBRID_ENF_ADD"),myEnfMeshGroup);
661 // addEnfMeshButton->setEnabled(false);
662 removeEnfMeshButton = new QPushButton(tr("HYBRID_ENF_REMOVE"),myEnfMeshGroup);
664 // QGroupBox* GroupBox2 = new QGroupBox( myEnfMeshGroup );
665 // QLabel* info2 = new QLabel( GroupBox2 );
666 // info2->setText( tr( "HYBRID_ENF_MESH_INFO" ) );
667 // info2->setWordWrap( true );
668 // QVBoxLayout* GroupBox2VLayout = new QVBoxLayout( GroupBox2 );
669 // GroupBox2VLayout->setSpacing( 6 );
670 // GroupBox2VLayout->setMargin( 11 );
671 // GroupBox2VLayout->addWidget( info2 );
673 // anEnfMeshLayout->addWidget( GroupBox2, ENF_MESH_WARNING, 0, 1, 2 );
674 anEnfMeshLayout->addWidget(myLayersOnAllWrapCheck, ENF_MESH_MESH, 0, 1 , 1);
675 anEnfMeshLayout->addWidget(myEnforcedMeshTableWidget, ENF_MESH_MESH+1, 0, ENF_MESH_NB_LINES , 1);
677 QGridLayout* anEnfMeshLayout2 = new QGridLayout(myEnfMeshGroup);
678 anEnfMeshLayout2->addWidget(myEnfMeshWdg, ENF_MESH_MESH, 0, 1, 2);
679 //TODO remove or not be lateful to select layers...
680 //anEnfMeshLayout2->addWidget(myMeshConstraintLabel, ENF_MESH_CONSTRAINT, 0, 1, 1);
681 //anEnfMeshLayout2->addWidget(myEnfMeshConstraint, ENF_MESH_CONSTRAINT, 1, 1, 1);
682 //anEnfMeshLayout2->addWidget(myMeshGroupNameLabel, ENF_MESH_GROUP, 0, 1, 1);
683 //anEnfMeshLayout2->addWidget(myMeshGroupName, ENF_MESH_GROUP, 1, 1, 1);
684 anEnfMeshLayout2->addWidget(addEnfMeshButton, ENF_MESH_BTN, 0, 1, 1);
685 anEnfMeshLayout2->addWidget(removeEnfMeshButton, ENF_MESH_BTN, 1, 1, 1);
686 anEnfMeshLayout2->setRowStretch(ENF_MESH_NB_LINES, 1);
688 anEnfMeshLayout->addLayout(anEnfMeshLayout2, ENF_MESH_MESH+1, 1, ENF_MESH_NB_LINES, 1);
689 anEnfMeshLayout->setRowStretch(ENF_MESH_MESH, 10);
692 // selection of faces
694 QWidget* faceSelGroup = new QWidget( dlg() );
695 QGridLayout* faceSelLayout = new QGridLayout( faceSelGroup );
697 QLabel* facesLbl = new QLabel( tr("HYBRID_FACE_IDS"), faceSelGroup );
698 faceSelLayout->addWidget( facesLbl, 0, 0 );
700 myFaceSelector = new StdMeshersGUI_SubShapeSelectorWdg( faceSelGroup, TopAbs_FACE, true, true );
701 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
702 QString aSubEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
703 myFaceSelector->SetGeomShapeEntry( aSubEntry, aMainEntry );
704 faceSelLayout->addWidget( myFaceSelector, 1, 0, 2, 2 );
705 faceSelLayout->setRowStretch( 1, 10);
709 tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
710 tab->insertTab( ADV_TAB, myAdvGroup, tr( "HYBRID_ADV_ARGS" ) );
711 tab->insertTab( ENF_MESH_TAB, myEnfMeshGroup, tr( "HYBRID_ENFORCED_MESHES" ) );
712 if ( aMainEntry.isEmpty() && aSubEntry.isEmpty() ) // mesh not based of geometry
713 faceSelGroup->hide();
715 tab->insertTab( FACE_SEL_TAB, faceSelGroup, tr( "HYBRID_FACES_TAB" ));
716 tab->setCurrentIndex( STD_TAB );
719 connect( tab, SIGNAL( currentChanged ( int )), this, SLOT( onTabChanged( int ) ) );
720 //connect( myLayersOnAllWrapCheck, SIGNAL( toggled( bool ) ), this, SLOT( onLayersOnAllWrap(bool)));
721 connect( myLayersOnAllWrapCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
722 //connect( myToMeshHolesCheck, SIGNAL( toggled( bool ) ), this, SLOT( onToMeshHoles(bool)));
723 //connect( myAdvWidget->maxMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
724 //connect( myAdvWidget->initialMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
725 //connect( myAdvWidget->boundaryRecoveryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
727 //connect( myBoundaryLayersGrowthCombo, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
728 //connect( myElementGenerationCombo, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
729 connect( myAddMultinormalsCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
730 connect( mySmoothNormalsCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
732 connect( myAdvWidget->logInFileCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
733 connect( myAdvWidget->keepWorkingFilesCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
734 connect( myAdvWidget->workingDirectoryPushButton, SIGNAL( clicked() ), this, SLOT( onDirBtnClicked() ) );
736 connect( myEnforcedTableWidget, SIGNAL( itemClicked(QTableWidgetItem *)), this, SLOT( synchronizeCoords() ) );
737 connect( myEnforcedTableWidget, SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
738 connect( myEnforcedTableWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
739 connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertex() ) );
740 connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
741 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
742 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
743 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
744 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
745 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
746 connect( mySizeValue, SIGNAL( textChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) );
747 connect( myXCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
748 connect( myYCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
749 connect( myZCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
750 connect( mySizeValue, SIGNAL( valueChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) );
751 connect( this, SIGNAL( vertexDefined(bool) ), addVertexButton, SLOT( setEnabled(bool) ) );
753 connect( addEnfMeshButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedMesh() ) );
754 connect( removeEnfMeshButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedMesh() ) );
755 // connect( myEnfMeshWdg, SIGNAL( contentModified()), this, SLOT( checkEnfMeshIsDefined() ) );
756 // connect( myEnfMeshConstraint, SIGNAL( currentIndexChanged(int) ), this, SLOT( checkEnfMeshIsDefined() ) );
757 // connect( this, SIGNAL( enfMeshDefined(bool) ), addEnfMeshButton, SLOT( setEnabled(bool) ) );
763 * This method checks if an enforced vertex is defined;
765 void HYBRIDPluginGUI_HypothesisCreator::clearEnfVertexSelection()
767 if (myEnfVertexWdg->NbObjects() != 0) {
768 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
769 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
770 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
771 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
772 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
774 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
775 that->checkVertexIsDefined();
779 * This method checks if an enforced vertex is defined;
781 void HYBRIDPluginGUI_HypothesisCreator::checkVertexIsDefined()
783 bool enfVertexIsDefined = false;
784 enfVertexIsDefined = (!mySizeValue->GetString().isEmpty() &&
785 (!myEnfVertexWdg->NbObjects() == 0 ||
786 (myEnfVertexWdg->NbObjects() == 0 && !myXCoord->GetString().isEmpty()
787 && !myYCoord->GetString().isEmpty()
788 && !myZCoord->GetString().isEmpty())));
789 emit vertexDefined(enfVertexIsDefined);
793 * This method checks if an enforced mesh is defined;
795 void HYBRIDPluginGUI_HypothesisCreator::checkEnfMeshIsDefined()
797 emit enfMeshDefined( myEnfVertexWdg->NbObjects() != 0);
801 * This method resets the content of the X, Y, Z, size and GroupName widgets;
803 void HYBRIDPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
805 myXCoord->setCleared(true);
806 myYCoord->setCleared(true);
807 myZCoord->setCleared(true);
808 // mySizeValue->setCleared(true);
809 myXCoord->setText("");
810 myYCoord->setText("");
811 myZCoord->setText("");
812 // mySizeValue->setText("");
813 // myGroupName->setText("");
814 addVertexButton->setEnabled(false);
817 /** HYBRIDPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item)
818 This method updates the tooltip of a modified item. The QLineEdit widgets content
819 is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
821 void HYBRIDPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTableWidgetItem* item) {
822 int row = myEnforcedTableWidget->row(item);
824 QVariant vertexName = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole);
825 QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole);
826 QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole);
827 QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole);
828 QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole);
829 QVariant entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
830 QString groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole).toString();
832 clearEnforcedVertexWidgets();
834 if ( !x.isNull() || !entry.isNull()) {
835 QString toolTip = vertexName.toString();
836 toolTip += QString("(");
837 if (entry.isNull() || (!entry.isNull() && entry.toString() == "")) {
838 toolTip += x.toString();
839 toolTip += QString(", ") + y.toString();
840 toolTip += QString(", ") + z.toString();
843 toolTip += entry.toString();
844 toolTip += QString(")");
847 toolTip += QString("=") + size.toString();
849 if (!groupName.isEmpty())
850 toolTip += QString(" [") + groupName + QString("]");
852 for (int col=0;col<ENF_VER_NB_COLUMNS;col++)
853 myEnforcedTableWidget->item(row,col)->setToolTip(toolTip);
856 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
857 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
858 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
859 myXCoord->SetValue(x.toDouble());
860 myYCoord->SetValue(y.toDouble());
861 myZCoord->SetValue(z.toDouble());
862 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
863 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
864 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
867 mySizeValue->SetValue(size.toDouble());
869 if (!groupName.isEmpty())
870 myGroupName->setText(groupName);
874 void HYBRIDPluginGUI_HypothesisCreator::onSelectEnforcedVertex() {
875 int nbSelEnfVertex = myEnfVertexWdg->NbObjects();
876 clearEnforcedVertexWidgets();
877 if (nbSelEnfVertex == 1)
879 if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() )
882 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
883 if (myEnfVertex == GEOM::GEOM_Object::_nil())
885 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
886 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
887 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
888 if (CORBA::is_nil(measureOp))
892 measureOp->PointCoordinates (myEnfVertex, x, y, z);
893 if ( measureOp->IsDone() )
895 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
896 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
897 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
898 myXCoord->SetValue(x);
899 myYCoord->SetValue(y);
900 myZCoord->SetValue(z);
901 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
902 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
903 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
909 /** HYBRIDPluginGUI_HypothesisCreator::synchronizeCoords()
910 This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
911 of the enforced vertex clicked in the tree widget.
913 void HYBRIDPluginGUI_HypothesisCreator::synchronizeCoords() {
914 clearEnforcedVertexWidgets();
915 QList<QTableWidgetItem *> items = myEnforcedTableWidget->selectedItems();
916 // myEnfVertexWdg->disconnect(SIGNAL(contentModified()));
917 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
918 if (! items.isEmpty()) {
919 QTableWidgetItem *item;
922 if (items.size() == 1) {
924 row = myEnforcedTableWidget->row(item);
925 QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole);
926 QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole);
927 QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole);
928 QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole);
929 entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
930 if (!entry.isNull()) {
931 SMESH::string_array_var objIds = new SMESH::string_array;
933 objIds[0] = entry.toString().toStdString().c_str();
934 myEnfVertexWdg->SetObjects(objIds);
937 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
939 QVariant group = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole);
940 if (!x.isNull()/* && entry.isNull()*/) {
941 // disconnect( myXCoord, SIGNAL( textChanged(const QString &)), this, SLOT( onSelectEnforcedVertex() ) );
942 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
943 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
944 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
945 myXCoord->SetValue(x.toDouble());
946 myYCoord->SetValue(y.toDouble());
947 myZCoord->SetValue(z.toDouble());
948 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
949 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
950 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
953 mySizeValue->SetValue(size.toDouble());
955 if (!group.isNull() && (!x.isNull() || !entry.isNull()))
956 myGroupName->setText(group.toString());
959 QList<QString> entryList;
960 for (int i = 0; i < items.size(); ++i) {
962 row = myEnforcedTableWidget->row(item);
963 entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
965 entryList << entry.toString();
967 if (entryList.size() > 0) {
968 SMESH::string_array_var objIds = new SMESH::string_array;
969 objIds->length(entryList.size());
970 for (int i = 0; i < entryList.size() ; i++)
971 objIds[i] = entryList.at(i).toStdString().c_str();
972 myEnfVertexWdg->SetObjects(objIds);
975 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
980 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
982 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
983 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
984 that->checkVertexIsDefined();
987 /** HYBRIDPluginGUI_HypothesisCreator::addEnforcedMesh( meshName, geomEntry, elemType, size, groupName)
988 This method adds in the tree widget an enforced mesh from mesh, submesh or group with optionally size and and groupName.
990 void HYBRIDPluginGUI_HypothesisCreator::addEnforcedMesh(std::string name, std::string entry, int elementType, std::string groupName)
992 bool okToCreate = true;
993 QString itemEntry = "";
994 int itemElementType = 0;
995 int rowCount = myEnforcedMeshTableWidget->rowCount();
996 bool allColumns = true;
997 for (int row = 0;row<rowCount;row++) {
998 for (int col = 0 ; col < ENF_MESH_NB_COLUMNS ; col++) {
999 if (col == ENF_MESH_CONSTRAINT_COLUMN){
1000 if (qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row, col)) == 0) {
1005 else if (myEnforcedMeshTableWidget->item(row, col) == 0) {
1009 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1010 QComboBox* itemComboBox = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row, col));
1011 itemElementType = itemComboBox->currentIndex();
1013 else if (col == ENF_MESH_ENTRY_COLUMN)
1014 itemEntry = myEnforcedMeshTableWidget->item(row, col)->data(Qt::EditRole).toString();
1020 if (itemEntry == QString(entry.c_str()) && itemElementType == elementType) {
1021 // // update group name
1022 // if (itemGroupName.toStdString() != groupName) {
1023 // myEnforcedMeshTableWidget->item(row, ENF_MESH_GROUP_COLUMN)->setData( Qt::EditRole, QVariant(groupName.c_str()));
1035 myEnforcedMeshTableWidget->setRowCount(rowCount+1);
1036 myEnforcedMeshTableWidget->setSortingEnabled(false);
1038 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++) {
1039 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1040 QComboBox* comboBox = new QComboBox();
1041 QPalette pal = comboBox->palette();
1042 pal.setColor(QPalette::Button, Qt::white);
1043 comboBox->setPalette(pal);
1044 comboBox->insertItems(0,myEnfMeshConstraintLabels);
1045 comboBox->setEditable(false);
1046 comboBox->setCurrentIndex(elementType);
1047 myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox);
1050 QTableWidgetItem* item = new QTableWidgetItem();
1051 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1053 case ENF_MESH_NAME_COLUMN:
1054 item->setData( 0, name.c_str() );
1055 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1056 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1058 case ENF_MESH_ENTRY_COLUMN:
1059 item->setData( 0, entry.c_str() );
1060 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1061 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1063 case ENF_MESH_GROUP_COLUMN:
1064 item->setData( 0, groupName.c_str() );
1065 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1073 // connect( myEnforcedMeshTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1075 myEnforcedMeshTableWidget->setSortingEnabled(true);
1076 // myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1077 // updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1081 /** HYBRIDPluginGUI_HypothesisCreator::addEnforcedVertex( x, y, z, size, vertexName, geomEntry, groupName)
1082 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.
1084 void HYBRIDPluginGUI_HypothesisCreator::addEnforcedVertex(double x, double y, double z, double size, std::string vertexName, std::string geomEntry, std::string groupName, bool isCompound)
1086 myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1087 bool okToCreate = true;
1088 double itemX,itemY,itemZ,itemSize = 0;
1089 QString itemEntry, itemGroupName = QString("");
1090 // bool itemIsCompound;
1091 int rowCount = myEnforcedTableWidget->rowCount();
1094 for (int row = 0;row<rowCount;row++) {
1096 for (int col = 0 ; col < ENF_VER_NB_COLUMNS ; col++) {
1097 if (myEnforcedTableWidget->item(row, col) == 0) {
1102 data = myEnforcedTableWidget->item(row, col)->data(Qt::EditRole);
1103 if (!data.isNull()) {
1105 case ENF_VER_GROUP_COLUMN:
1106 itemGroupName = data.toString();
1108 case ENF_VER_ENTRY_COLUMN:
1109 itemEntry = data.toString();
1111 // case ENF_VER_COMPOUND_COLUMN:
1112 // itemIsCompound = data.toBool();
1114 case ENF_VER_X_COLUMN:
1115 itemX = data.toDouble();
1117 case ENF_VER_Y_COLUMN:
1118 itemY = data.toDouble();
1120 case ENF_VER_Z_COLUMN:
1121 itemZ = data.toDouble();
1123 case ENF_VER_SIZE_COLUMN:
1124 itemSize = data.toDouble();
1136 if (( !isCompound && ((itemX == x) && (itemY == y) && (itemZ == z))) || /*( (itemEntry.toStdString() != "") && */ (itemEntry.toStdString() == geomEntry)/*)*/) {
1138 if (itemSize != size) {
1139 myEnforcedTableWidget->item(row, ENF_VER_SIZE_COLUMN)->setData( Qt::EditRole, QVariant(size));
1141 // update group name
1142 if (itemGroupName.toStdString() != groupName) {
1143 myEnforcedTableWidget->item(row, ENF_VER_GROUP_COLUMN)->setData( Qt::EditRole, QVariant(groupName.c_str()));
1150 if (geomEntry.empty()) {
1157 if (geomEntry.empty()) {
1164 QString myVertexName;
1165 while(indexRef != vertexIndex) {
1166 indexRef = vertexIndex;
1167 if (vertexName.empty())
1168 myVertexName = QString("Vertex #%1").arg(vertexIndex);
1170 myVertexName = QString(vertexName.c_str());
1172 for (int row = 0;row<rowCount;row++) {
1173 QString name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString();
1174 if (myVertexName == name) {
1181 myEnforcedTableWidget->setRowCount(rowCount+1);
1182 myEnforcedTableWidget->setSortingEnabled(false);
1183 for (int col=0;col<ENF_VER_NB_COLUMNS;col++) {
1184 QTableWidgetItem* item = new QTableWidgetItem();
1185 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1187 case ENF_VER_NAME_COLUMN:
1188 item->setData( Qt::EditRole, myVertexName );
1189 if (!geomEntry.empty()) {
1191 item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1193 item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1196 case ENF_VER_X_COLUMN:
1198 item->setData( 0, QVariant(x) );
1200 case ENF_VER_Y_COLUMN:
1202 item->setData( 0, QVariant(y) );
1204 case ENF_VER_Z_COLUMN:
1206 item->setData( 0, QVariant(z) );
1208 case ENF_VER_SIZE_COLUMN:
1209 item->setData( 0, QVariant(size) );
1211 case ENF_VER_ENTRY_COLUMN:
1212 if (!geomEntry.empty())
1213 item->setData( 0, QString(geomEntry.c_str()) );
1215 case ENF_VER_COMPOUND_COLUMN:
1216 item->setData( Qt::CheckStateRole, isCompound );
1217 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
1219 case ENF_VER_GROUP_COLUMN:
1220 if (!groupName.empty())
1221 item->setData( 0, QString(groupName.c_str()) );
1227 myEnforcedTableWidget->setItem(rowCount,col,item);
1230 connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1232 myEnforcedTableWidget->setSortingEnabled(true);
1233 // myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1234 updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1237 /** HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedMesh()
1238 This method is called when a item is added into the enforced meshes tree widget
1240 void HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedMesh()
1243 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1245 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1246 myEnfMeshWdg->deactivateSelection();
1248 for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column)
1249 myEnforcedMeshTableWidget->resizeColumnToContents(column);
1252 int selEnfMeshes = myEnfMeshWdg->NbObjects();
1253 if (selEnfMeshes == 0)
1256 std::string groupName = myMeshGroupName->text().toStdString();
1257 // if (myGlobalGroupName->isChecked())
1258 // groupName = myGlobalGroupName->text().toStdString();
1260 if (boost::trim_copy(groupName).empty())
1261 groupName = "LayersGroup"; //have to be not empty until non used
1263 int elementType = myEnfMeshConstraint->currentIndex();
1266 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1267 _PTR(SObject) aSObj; //SMESH::SMESH_IDSource::_nil;
1268 QString meshEntry = myEnfMeshWdg->GetValue();
1270 if (selEnfMeshes == 1)
1272 // myEnfMesh = myEnfMeshWdg->GetObject< SMESH::SMESH_IDSource >();
1273 // std::string entry = myEnfMeshWdg->GetValue();
1274 aSObj = aStudy->FindObjectID(meshEntry.toStdString().c_str());
1275 CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy);
1276 if (!CORBA::is_nil(anObj)) {
1277 // SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1278 addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
1283 QStringList meshEntries = meshEntry.split(" ", QString::SkipEmptyParts);
1284 QStringListIterator meshEntriesIt (meshEntries);
1285 while (meshEntriesIt.hasNext()) {
1286 aSObj = aStudy->FindObjectID(meshEntriesIt.next().toStdString().c_str());
1287 CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy);
1288 if (!CORBA::is_nil(anObj)) {
1289 // SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1290 addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
1295 myEnfVertexWdg->SetObject(SMESH::SMESH_IDSource::_nil());
1297 for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column)
1298 myEnforcedMeshTableWidget->resizeColumnToContents(column);
1302 /** HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedVertex()
1303 This method is called when a item is added into the enforced vertices tree widget
1305 void HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedVertex()
1308 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1310 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1311 myEnfVertexWdg->deactivateSelection();
1313 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1314 myEnforcedTableWidget->resizeColumnToContents(column);
1317 int selEnfVertex = myEnfVertexWdg->NbObjects();
1318 bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty());
1319 if ((selEnfVertex == 0) && coordsEmpty)
1322 std::string groupName = myGroupName->text().toStdString();
1323 // if (myGlobalGroupName->isChecked())
1324 // groupName = myGlobalGroupName->text().toStdString();
1326 if (boost::trim_copy(groupName).empty())
1329 double size = mySizeValue->GetValue();
1331 if (selEnfVertex <= 1)
1333 double x = 0, y = 0, z=0;
1334 if (myXCoord->GetString() != "") {
1335 x = myXCoord->GetValue();
1336 y = myYCoord->GetValue();
1337 z = myZCoord->GetValue();
1339 if (selEnfVertex == 1) {
1340 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >();
1341 std::string entry = "";
1342 if (myEnfVertex != GEOM::GEOM_Object::_nil())
1343 entry = myEnfVertex->GetStudyEntry();
1344 addEnforcedVertex(x, y, z, size, myEnfVertex->GetName(),entry, groupName, myEnfVertex->GetShapeType() == GEOM::COMPOUND);
1347 addEnforcedVertex(x, y, z, size, "", "", groupName);
1352 if ( CORBA::is_nil(getGeomEngine()))
1355 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
1356 if (CORBA::is_nil(measureOp))
1359 CORBA::Double x = 0, y = 0,z = 0;
1360 for (int j = 0 ; j < selEnfVertex ; j++)
1362 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j);
1363 if (myEnfVertex == GEOM::GEOM_Object::_nil())
1365 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1366 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1367 if ( measureOp->IsDone() )
1368 addEnforcedVertex(x, y, z, size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1369 } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) {
1370 addEnforcedVertex(0., 0., 0., size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName, true);
1375 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1377 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1378 myEnforcedTableWidget->resizeColumnToContents(column);
1381 /** HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedMesh()
1382 This method is called when a item is removed from the enforced meshes tree widget
1384 void HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedMesh()
1386 QList<int> selectedRows;
1387 QList<QTableWidgetItem *> selectedItems = myEnforcedMeshTableWidget->selectedItems();
1388 QTableWidgetItem* item;
1390 foreach( item, selectedItems ) {
1392 if (!selectedRows.contains( row ) )
1393 selectedRows.append(row);
1396 qSort( selectedRows );
1397 QListIterator<int> it( selectedRows );
1399 while ( it.hasPrevious() ) {
1400 row = it.previous();
1401 myEnforcedMeshTableWidget->removeRow(row );
1404 myEnforcedMeshTableWidget->selectionModel()->clearSelection();
1407 /** HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1408 This method is called when a item is removed from the enforced vertices tree widget
1410 void HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1412 QList<int> selectedRows;
1413 QList<QTableWidgetItem *> selectedItems = myEnforcedTableWidget->selectedItems();
1414 QTableWidgetItem* item;
1416 foreach( item, selectedItems ) {
1418 if (!selectedRows.contains( row ) )
1419 selectedRows.append(row);
1422 qSort( selectedRows );
1423 QListIterator<int> it( selectedRows );
1425 while ( it.hasPrevious() ) {
1426 row = it.previous();
1427 myEnforcedTableWidget->removeRow(row );
1430 myEnforcedTableWidget->selectionModel()->clearSelection();
1433 void HYBRIDPluginGUI_HypothesisCreator::onLayersOnAllWrap(bool isOn)
1435 // myToMakeGroupsOfDomains->setEnabled( isOn );
1437 // myToMakeGroupsOfDomains->setChecked( false );
1440 void HYBRIDPluginGUI_HypothesisCreator::onToMeshHoles(bool isOn)
1442 // myToMakeGroupsOfDomains->setEnabled( isOn );
1444 // myToMakeGroupsOfDomains->setChecked( false );
1447 void HYBRIDPluginGUI_HypothesisCreator::onDirBtnClicked()
1449 QString dir = SUIT_FileDlg::getExistingDirectory( dlg(), myAdvWidget->workingDirectoryLineEdit->text(), QString() );
1450 if ( !dir.isEmpty() )
1451 myAdvWidget->workingDirectoryLineEdit->setText( dir );
1454 void HYBRIDPluginGUI_HypothesisCreator::onTabChanged( int )
1456 myEnfVertexWdg->deactivateSelection();
1457 myEnfMeshWdg->deactivateSelection();
1458 myFaceSelector->ActivateSelection( false );
1459 myFaceSelector->ShowPreview( false );
1462 void HYBRIDPluginGUI_HypothesisCreator::updateWidgets()
1464 //customs automatic set
1465 //myToMakeGroupsOfDomains->setEnabled( myToMeshHolesCheck->isChecked() );
1466 //myAdvWidget->maxMemorySpin->setEnabled( myAdvWidget->maxMemoryCheck->isChecked() );
1467 //myAdvWidget->initialMemoryCheck->setEnabled( !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1468 //myAdvWidget->initialMemorySpin->setEnabled( myAdvWidget->initialMemoryCheck->isChecked() && !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1469 //myOptimizationLevelCombo->setEnabled( !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1470 myMultinormalsAngleSpin->setEnabled( myAddMultinormalsCheck->isChecked() );
1471 if ( sender() == myAdvWidget->logInFileCheck ||
1472 sender() == myAdvWidget->keepWorkingFilesCheck )
1474 bool logFileRemovable = myAdvWidget->logInFileCheck->isChecked() &&
1475 !myAdvWidget->keepWorkingFilesCheck->isChecked();
1477 myAdvWidget->removeLogOnSuccessCheck->setEnabled( logFileRemovable );
1479 bool enabled = !myLayersOnAllWrapCheck->isChecked();
1480 myEnforcedMeshTableWidget->setEnabled(enabled);
1481 addEnfMeshButton->setEnabled(enabled);
1482 removeEnfMeshButton->setEnabled(enabled);
1483 myEnfMeshWdg->setEnabled(enabled);
1484 if ( QTabWidget* tab = qobject_cast<QTabWidget*>( myStdGroup->parentWidget()->parentWidget() ))
1485 tab->setTabEnabled( FACE_SEL_TAB, enabled );
1488 bool HYBRIDPluginGUI_HypothesisCreator::checkParams(QString& msg) const
1491 if ( !QFileInfo( myAdvWidget->workingDirectoryLineEdit->text().trimmed() ).isWritable() ) {
1492 SUIT_MessageBox::warning( dlg(),
1493 tr( "SMESH_WRN_WARNING" ),
1494 tr( "HYBRID_PERMISSION_DENIED" ) );
1501 void HYBRIDPluginGUI_HypothesisCreator::retrieveParams() const
1503 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1504 HYBRIDHypothesisData data;
1505 readParamsFromHypo( data );
1508 myName->setText( data.myName );
1509 myLayersOnAllWrapCheck ->setChecked ( data.myLayersOnAllWrap );
1510 myToMeshHolesCheck ->setChecked ( data.myToMeshHoles );
1511 myToMakeGroupsOfDomains ->setChecked ( data.myToMakeGroupsOfDomains );
1512 myOptimizationLevelCombo ->setCurrentIndex( data.myOptimizationLevel );
1513 myAdvWidget->maxMemoryCheck ->setChecked ( data.myMaximumMemory > 0 );
1514 myAdvWidget->maxMemorySpin ->setValue ( qMax( data.myMaximumMemory,
1515 myAdvWidget->maxMemorySpin->minimum() ));
1516 myAdvWidget->initialMemoryCheck ->setChecked ( data.myInitialMemory > 0 );
1517 myAdvWidget->initialMemorySpin ->setValue ( qMax( data.myInitialMemory,
1518 myAdvWidget->initialMemorySpin->minimum() ));
1520 myCollisionModeCombo ->setCurrentIndex( data.myCollisionMode );
1521 myBoundaryLayersGrowthCombo ->setCurrentIndex( data.myBoundaryLayersGrowth );
1522 myElementGenerationCombo ->setCurrentIndex( data.myElementGeneration );
1523 myAddMultinormalsCheck -> setChecked ( data.myAddMultinormals );
1524 mySmoothNormalsCheck -> setChecked ( data.mySmoothNormals );
1525 myHeightFirstLayerSpin -> setValue( data.myHeightFirstLayer );
1526 myNbOfBoundaryLayersSpin -> setValue( data.myNbOfBoundaryLayers );
1527 myBoundaryLayersProgressionSpin -> setValue( data.myBoundaryLayersProgression );
1528 if (data.myCoreSize <= 0)
1529 myCoreSizeSpin->setText("");
1531 myCoreSizeSpin -> setValue( data.myCoreSize );
1532 myMultinormalsAngleSpin -> setValue( data.myMultinormalsAngle );
1533 myFaceSelector ->SetListOfIDs( data.myFaceWLIds );
1535 myAdvWidget->workingDirectoryLineEdit ->setText ( data.myWorkingDir );
1536 myAdvWidget->keepWorkingFilesCheck ->setChecked( data.myKeepFiles );
1537 myAdvWidget->verboseLevelSpin ->setValue ( data.myVerboseLevel );
1538 myAdvWidget->createNewNodesCheck ->setChecked( data.myToCreateNewNodes );
1539 myAdvWidget->removeInitialCentralPointCheck ->setChecked( data.myRemoveInitialCentralPoint );
1540 myAdvWidget->boundaryRecoveryCheck ->setChecked( data.myBoundaryRecovery );
1541 myAdvWidget->FEMCorrectionCheck ->setChecked( data.myFEMCorrection );
1542 myAdvWidget->gradationSpinBox ->setValue ( data.myGradation );
1543 myAdvWidget->myAdvOptionsTable ->SetCustomOptions( data.myTextOption );
1544 myAdvWidget->logInFileCheck ->setChecked( !data.myLogInStandardOutput );
1545 myAdvWidget->removeLogOnSuccessCheck ->setChecked( data.myRemoveLogOnSuccess );
1547 TEnfVertexList::const_iterator it;
1549 myEnforcedTableWidget->clearContents();
1550 myEnforcedTableWidget->setSortingEnabled(false);
1551 myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1552 for(it = data.myEnforcedVertices.begin() ; it != data.myEnforcedVertices.end(); it++ )
1554 TEnfVertex* enfVertex = (*it);
1555 myEnforcedTableWidget->setRowCount(rowCount+1);
1557 for (int col=0;col<ENF_VER_NB_COLUMNS;col++) {
1558 QTableWidgetItem* item = new QTableWidgetItem();
1559 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1561 case ENF_VER_NAME_COLUMN:
1562 item->setData( 0, enfVertex->name.c_str() );
1563 if (!enfVertex->geomEntry.empty()) {
1564 if (enfVertex->isCompound)
1565 item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1567 item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1571 case ENF_VER_X_COLUMN:
1572 if (!enfVertex->isCompound) {
1573 item->setData( 0, enfVertex->coords.at(0) );
1576 case ENF_VER_Y_COLUMN:
1577 if (!enfVertex->isCompound) {
1578 item->setData( 0, enfVertex->coords.at(1) );
1581 case ENF_VER_Z_COLUMN:
1582 if (!enfVertex->isCompound) {
1583 item->setData( 0, enfVertex->coords.at(2) );
1586 case ENF_VER_SIZE_COLUMN:
1587 item->setData( 0, enfVertex->size );
1589 case ENF_VER_ENTRY_COLUMN:
1590 item->setData( 0, enfVertex->geomEntry.c_str() );
1592 case ENF_VER_COMPOUND_COLUMN:
1593 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
1594 item->setData( Qt::CheckStateRole, enfVertex->isCompound );
1596 case ENF_VER_GROUP_COLUMN:
1597 item->setData( 0, enfVertex->groupName.c_str() );
1603 myEnforcedTableWidget->setItem(rowCount,col,item);
1605 that->updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1609 connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1610 myEnforcedTableWidget->setSortingEnabled(true);
1612 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1613 myEnforcedTableWidget->resizeColumnToContents(column);
1615 // Update Enforced meshes QTableWidget
1616 TEnfMeshList::const_iterator itMesh;
1618 myEnforcedMeshTableWidget->clearContents();
1619 myEnforcedMeshTableWidget->setSortingEnabled(false);
1620 // myEnforcedMeshTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1621 for(itMesh = data.myEnforcedMeshes.begin() ; itMesh != data.myEnforcedMeshes.end(); itMesh++ )
1623 TEnfMesh* enfMesh = (*itMesh);
1624 myEnforcedMeshTableWidget->setRowCount(rowCount+1);
1626 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++) {
1627 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1628 QComboBox* comboBox = new QComboBox();
1629 QPalette pal = comboBox->palette();
1630 pal.setColor(QPalette::Button, Qt::white);
1631 comboBox->setPalette(pal);
1632 comboBox->insertItems(0,myEnfMeshConstraintLabels);
1633 comboBox->setEditable(false);
1634 comboBox->setCurrentIndex(enfMesh->elementType);
1635 myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox);
1638 QTableWidgetItem* item = new QTableWidgetItem();
1639 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1641 case ENF_MESH_NAME_COLUMN:
1642 item->setData( 0, enfMesh->name.c_str() );
1643 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1644 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1646 case ENF_MESH_ENTRY_COLUMN:
1647 item->setData( 0, enfMesh->entry.c_str() );
1648 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1649 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1651 case ENF_MESH_GROUP_COLUMN:
1652 item->setData( 0, enfMesh->groupName.c_str() );
1653 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1660 // myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1662 // that->updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1666 // connect( myEnforcedMeshTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1667 myEnforcedMeshTableWidget->setSortingEnabled(true);
1669 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++)
1670 myEnforcedMeshTableWidget->resizeColumnToContents(col);
1672 that->updateWidgets();
1673 that->checkVertexIsDefined();
1676 QString HYBRIDPluginGUI_HypothesisCreator::storeParams() const
1678 HYBRIDHypothesisData data;
1679 readParamsFromWidgets( data );
1680 storeParamsToHypo( data );
1682 QString valStr = "";
1684 if ( !data.myBoundaryRecovery )
1685 valStr = "-c " + QString::number( !data.myToMeshHoles );
1687 if ( data.myOptimizationLevel >= 0 && data.myOptimizationLevel < 5 && !data.myBoundaryRecovery) {
1688 const char* level[] = { "none" , "light" , "standard" , "standard+" , "strong" };
1690 valStr += level[ data.myOptimizationLevel ];
1692 if ( data.myMaximumMemory > 0 ) {
1694 valStr += QString::number( data.myMaximumMemory );
1696 if ( data.myInitialMemory > 0 && !data.myBoundaryRecovery ) {
1698 valStr += QString::number( data.myInitialMemory );
1701 valStr += QString::number( data.myVerboseLevel );
1703 if ( !data.myToCreateNewNodes )
1706 if ( data.myRemoveInitialCentralPoint )
1707 valStr += " -no_initial_central_point";
1709 if ( data.myBoundaryRecovery )
1712 if ( data.myFEMCorrection )
1715 if ( data.myGradation != 1.05 ) {
1716 valStr += " -Dcpropa=";
1717 valStr += QString::number( data.myGradation );
1721 valStr += data.myTextOption;
1723 // valStr += " #BEGIN ENFORCED VERTICES#";
1724 // // Add size map parameters storage
1725 // for (int i=0 ; i<mySmpModel->rowCount() ; i++) {
1727 // double x = mySmpModel->data(mySmpModel->index(i,ENF_VER_X_COLUMN)).toDouble();
1728 // double y = mySmpModel->data(mySmpModel->index(i,ENF_VER_Y_COLUMN)).toDouble();
1729 // double z = mySmpModel->data(mySmpModel->index(i,ENF_VER_Z_COLUMN)).toDouble();
1730 // double size = mySmpModel->data(mySmpModel->index(i,ENF_VER_SIZE_COLUMN)).toDouble();
1731 // valStr += QString::number( x );
1733 // valStr += QString::number( y );
1735 // valStr += QString::number( z );
1737 // valStr += QString::number( size );
1738 // if (i!=mySmpModel->rowCount()-1)
1741 // valStr += " #END ENFORCED VERTICES#";
1745 bool HYBRIDPluginGUI_HypothesisCreator::readParamsFromHypo( HYBRIDHypothesisData& h_data ) const
1747 HYBRIDPlugin::HYBRIDPlugin_Hypothesis_var h =
1748 HYBRIDPlugin::HYBRIDPlugin_Hypothesis::_narrow( initParamsHypothesis() );
1750 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
1751 h_data.myName = isCreation() && data ? hypName() : "";
1753 h_data.myCollisionMode = h->GetCollisionMode();
1754 h_data.myBoundaryLayersGrowth = h->GetBoundaryLayersGrowth();
1755 h_data.myElementGeneration = h->GetElementGeneration();
1756 h_data.myAddMultinormals = h->GetAddMultinormals();
1757 h_data.mySmoothNormals = h->GetSmoothNormals();
1758 h_data.myHeightFirstLayer = h->GetHeightFirstLayer();
1759 h_data.myBoundaryLayersProgression = h->GetBoundaryLayersProgression();
1760 h_data.myCoreSize = h->GetCoreSize();
1761 h_data.myMultinormalsAngle = h->GetMultinormalsAngle();
1762 h_data.myNbOfBoundaryLayers = h->GetNbOfBoundaryLayers();
1763 h_data.myFaceWLIds = h->GetFacesWithLayers();
1765 h_data.myLayersOnAllWrap = h->GetLayersOnAllWrap();
1766 h_data.myToMeshHoles = h->GetToMeshHoles();
1767 h_data.myToMakeGroupsOfDomains = /*h->GetToMeshHoles() &&*/ h->GetToMakeGroupsOfDomains();
1768 h_data.myMaximumMemory = h->GetMaximumMemory();
1769 h_data.myInitialMemory = h->GetInitialMemory();
1770 h_data.myInitialMemory = h->GetInitialMemory();
1771 h_data.myOptimizationLevel = h->GetOptimizationLevel();
1773 h_data.myKeepFiles = h->GetKeepFiles();
1774 h_data.myWorkingDir = h->GetWorkingDirectory();
1775 h_data.myVerboseLevel = h->GetVerboseLevel();
1776 h_data.myToCreateNewNodes = h->GetToCreateNewNodes();
1777 h_data.myRemoveInitialCentralPoint = h->GetToRemoveCentralPoint();
1778 h_data.myBoundaryRecovery = h->GetToUseBoundaryRecoveryVersion();
1779 h_data.myFEMCorrection = h->GetFEMCorrection();
1780 h_data.myGradation = h->GetGradation();
1781 h_data.myTextOption = h->GetAdvancedOption();
1782 h_data.myLogInStandardOutput = h->GetStandardOutputLog();
1783 h_data.myRemoveLogOnSuccess = h->GetRemoveLogOnSuccess();
1785 HYBRIDPlugin::HYBRIDEnforcedVertexList_var vertices = h->GetEnforcedVertices();
1786 h_data.myEnforcedVertices.clear();
1787 for (CORBA::ULong i=0 ; i<vertices->length() ; i++) {
1788 TEnfVertex* myVertex = new TEnfVertex();
1789 myVertex->name = CORBA::string_dup(vertices[i].name.in());
1790 myVertex->geomEntry = CORBA::string_dup(vertices[i].geomEntry.in());
1791 myVertex->groupName = CORBA::string_dup(vertices[i].groupName.in());
1792 myVertex->size = vertices[i].size;
1793 myVertex->isCompound = vertices[i].isCompound;
1794 if (vertices[i].coords.length()) {
1795 for (CORBA::ULong c = 0; c < vertices[i].coords.length() ; c++)
1796 myVertex->coords.push_back(vertices[i].coords[c]);
1798 h_data.myEnforcedVertices.insert(myVertex);
1801 HYBRIDPlugin::HYBRIDEnforcedMeshList_var enfMeshes = h->GetEnforcedMeshes();
1802 h_data.myEnforcedMeshes.clear();
1803 for (CORBA::ULong i=0 ; i<enfMeshes->length() ; i++) {
1804 TEnfMesh* myEnfMesh = new TEnfMesh();
1805 myEnfMesh->name = CORBA::string_dup(enfMeshes[i].name.in());
1806 myEnfMesh->entry = CORBA::string_dup(enfMeshes[i].entry.in());
1807 myEnfMesh->groupName = CORBA::string_dup(enfMeshes[i].groupName.in());
1808 switch (enfMeshes[i].elementType) {
1810 myEnfMesh->elementType = 0;
1813 myEnfMesh->elementType = 1;
1816 myEnfMesh->elementType = 2;
1821 // myEnfMesh->elementType = enfMeshes[i].elementType;
1822 h_data.myEnforcedMeshes.insert(myEnfMesh);
1827 bool HYBRIDPluginGUI_HypothesisCreator::storeParamsToHypo( const HYBRIDHypothesisData& h_data ) const
1829 HYBRIDPlugin::HYBRIDPlugin_Hypothesis_var h =
1830 HYBRIDPlugin::HYBRIDPlugin_Hypothesis::_narrow( hypothesis() );
1836 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
1838 if ( h->GetLayersOnAllWrap() != h_data.myLayersOnAllWrap ) // avoid duplication of DumpPython commands
1839 h->SetLayersOnAllWrap ( h_data.myLayersOnAllWrap );
1840 if ( h->GetToMeshHoles() != h_data.myToMeshHoles ) // avoid duplication of DumpPython commands
1841 h->SetToMeshHoles ( h_data.myToMeshHoles );
1842 if ( h->GetToMakeGroupsOfDomains() != h_data.myToMakeGroupsOfDomains )
1843 h->SetToMakeGroupsOfDomains( h_data.myToMakeGroupsOfDomains );
1844 if ( h->GetMaximumMemory() != h_data.myMaximumMemory )
1845 h->SetMaximumMemory ( h_data.myMaximumMemory );
1846 if ( h->GetInitialMemory() != h_data.myInitialMemory )
1847 h->SetInitialMemory ( h_data.myInitialMemory );
1848 if ( h->GetInitialMemory() != h_data.myInitialMemory )
1849 h->SetInitialMemory ( h_data.myInitialMemory );
1850 if ( h->GetOptimizationLevel() != h_data.myOptimizationLevel )
1851 h->SetOptimizationLevel( h_data.myOptimizationLevel );
1853 if ( h->GetCollisionMode() != h_data.myCollisionMode )
1854 h->SetCollisionMode( h_data.myCollisionMode );
1855 if ( h->GetBoundaryLayersGrowth() != h_data.myBoundaryLayersGrowth )
1856 h->SetBoundaryLayersGrowth( h_data.myBoundaryLayersGrowth );
1857 if ( h->GetElementGeneration() != h_data.myElementGeneration )
1858 h->SetElementGeneration( h_data.myElementGeneration );
1860 if ( h->GetAddMultinormals() != h_data.myAddMultinormals )
1861 h->SetAddMultinormals ( h_data.myAddMultinormals );
1862 if ( h->GetSmoothNormals() != h_data.mySmoothNormals )
1863 h->SetSmoothNormals ( h_data.mySmoothNormals );
1864 if ( h->GetHeightFirstLayer() != h_data.myHeightFirstLayer )
1865 h->SetHeightFirstLayer ( h_data.myHeightFirstLayer );
1866 if ( h->GetBoundaryLayersProgression() != h_data.myBoundaryLayersProgression )
1867 h->SetBoundaryLayersProgression ( h_data.myBoundaryLayersProgression );
1868 if ( h->GetCoreSize() != h_data.myCoreSize )
1869 h->SetCoreSize ( h_data.myCoreSize );
1870 if ( h->GetMultinormalsAngle() != h_data.myMultinormalsAngle )
1871 h->SetMultinormalsAngle ( h_data.myMultinormalsAngle );
1872 if ( h->GetNbOfBoundaryLayers() != h_data.myNbOfBoundaryLayers )
1873 h->SetNbOfBoundaryLayers ( h_data.myNbOfBoundaryLayers );
1874 h->SetFacesWithLayers( h_data.myFaceWLIds );
1876 if ( h->GetKeepFiles() != h_data.myKeepFiles)
1877 h->SetKeepFiles ( h_data.myKeepFiles);
1878 if ( h->GetWorkingDirectory() != h_data.myWorkingDir )
1879 h->SetWorkingDirectory ( h_data.myWorkingDir.toLatin1().constData() );
1880 if ( h->GetVerboseLevel() != h_data.myVerboseLevel )
1881 h->SetVerboseLevel ( h_data.myVerboseLevel );
1882 if ( h->GetToCreateNewNodes() != h_data.myToCreateNewNodes )
1883 h->SetToCreateNewNodes ( h_data.myToCreateNewNodes );
1884 if ( h->GetToRemoveCentralPoint() != h_data.myRemoveInitialCentralPoint )
1885 h->SetToRemoveCentralPoint ( h_data.myRemoveInitialCentralPoint );
1886 if ( h->GetToUseBoundaryRecoveryVersion() != h_data.myBoundaryRecovery )
1887 h->SetToUseBoundaryRecoveryVersion ( h_data.myBoundaryRecovery );
1888 if ( h->GetFEMCorrection() != h_data.myFEMCorrection )
1889 h->SetFEMCorrection ( h_data.myFEMCorrection );
1890 if ( h->GetGradation() != h_data.myGradation )
1891 h->SetGradation ( h_data.myGradation );
1892 if ( h->GetTextOption() != h_data.myTextOption )
1893 h->SetAdvancedOption ( h_data.myTextOption.toLatin1().constData() );
1894 if ( h->GetStandardOutputLog() != h_data.myLogInStandardOutput )
1895 h->SetStandardOutputLog ( h_data.myLogInStandardOutput );
1896 if ( h->GetRemoveLogOnSuccess() != h_data.myRemoveLogOnSuccess )
1897 h->SetRemoveLogOnSuccess ( h_data.myRemoveLogOnSuccess );
1899 // Enforced vertices
1900 //int nbVertex = (int) h_data.myEnforcedVertices.size();
1901 HYBRIDPlugin::HYBRIDEnforcedVertexList_var vertexHyp = h->GetEnforcedVertices();
1902 int nbVertexHyp = vertexHyp->length();
1905 // 1. Clear all enforced vertices in hypothesis
1906 // 2. Add new enforced vertex according to h_data
1907 if ( nbVertexHyp > 0)
1908 h->ClearEnforcedVertices();
1910 TEnfVertexList::const_iterator it;
1911 double x = 0, y = 0, z = 0;
1912 for(it = h_data.myEnforcedVertices.begin() ; it != h_data.myEnforcedVertices.end(); it++ ) {
1913 TEnfVertex* enfVertex = (*it);
1915 if (enfVertex->coords.size()) {
1916 x = enfVertex->coords.at(0);
1917 y = enfVertex->coords.at(1);
1918 z = enfVertex->coords.at(2);
1920 ok = h->p_SetEnforcedVertex( enfVertex->size, x, y, z, enfVertex->name.c_str(), enfVertex->geomEntry.c_str(), enfVertex->groupName.c_str(), enfVertex->isCompound);
1924 //int nbEnfMeshes = (int) h_data.myEnforcedMeshes.size();
1925 HYBRIDPlugin::HYBRIDEnforcedMeshList_var enfMeshListHyp = h->GetEnforcedMeshes();
1926 int nbEnfMeshListHyp = enfMeshListHyp->length();
1929 // 1. Clear all enforced vertices in hypothesis
1930 // 2. Add new enforced vertex according to h_data
1931 if ( nbEnfMeshListHyp > 0)
1932 h->ClearEnforcedMeshes();
1934 TEnfMeshList::const_iterator itEnfMesh;
1936 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1938 for(itEnfMesh = h_data.myEnforcedMeshes.begin() ; itEnfMesh != h_data.myEnforcedMeshes.end(); itEnfMesh++ ) {
1939 TEnfMesh* enfMesh = (*itEnfMesh);
1941 _PTR(SObject) aSObj = aStudy->FindObjectID(enfMesh->entry.c_str());
1942 SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1944 SMESH::ElementType elementType;
1945 switch(enfMesh->elementType) {
1947 elementType = SMESH::NODE;
1950 elementType = SMESH::EDGE;
1953 elementType = SMESH::FACE;
1959 std::cout << "h->p_SetEnforcedMesh(theSource, "<< elementType <<", \""<< enfMesh->name << "\", \"" << enfMesh->groupName.c_str() <<"\")"<<std::endl;
1960 ok = h->p_SetEnforcedMesh(theSource, elementType, enfMesh->name.c_str(), enfMesh->groupName.c_str());
1963 // catch(const std::exception& ex) {
1964 // std::cout << "Exception: " << ex.what() << std::endl;
1967 catch ( const SALOME::SALOME_Exception& ex )
1969 SalomeApp_Tools::QtCatchCorbaException( ex );
1975 bool HYBRIDPluginGUI_HypothesisCreator::readParamsFromWidgets( HYBRIDHypothesisData& h_data ) const
1977 h_data.myName = myName ? myName->text() : "";
1978 h_data.myLayersOnAllWrap = myLayersOnAllWrapCheck->isChecked();
1979 h_data.myToMeshHoles = myToMeshHolesCheck->isChecked();
1980 h_data.myToMakeGroupsOfDomains = myToMakeGroupsOfDomains->isChecked();
1981 h_data.myMaximumMemory = myAdvWidget->maxMemoryCheck->isChecked() ? myAdvWidget->maxMemorySpin->value() : -1;
1982 h_data.myInitialMemory = myAdvWidget->initialMemoryCheck->isChecked() ? myAdvWidget->initialMemorySpin->value() : -1;
1983 h_data.myOptimizationLevel = myOptimizationLevelCombo->currentIndex();
1985 h_data.myCollisionMode = myCollisionModeCombo->currentIndex();
1986 h_data.myBoundaryLayersGrowth = myBoundaryLayersGrowthCombo->currentIndex();
1987 h_data.myElementGeneration = myElementGenerationCombo->currentIndex();
1988 h_data.myAddMultinormals = myAddMultinormalsCheck->isChecked();
1989 h_data.mySmoothNormals = mySmoothNormalsCheck->isChecked();
1991 h_data.myHeightFirstLayer = myHeightFirstLayerSpin -> value();
1992 h_data.myNbOfBoundaryLayers = myNbOfBoundaryLayersSpin -> value();
1993 h_data.myBoundaryLayersProgression = myBoundaryLayersProgressionSpin -> value();
1994 h_data.myCoreSize = myCoreSizeSpin->text().isEmpty() ? 0.0 : myCoreSizeSpin -> value();
1995 h_data.myMultinormalsAngle = myMultinormalsAngleSpin -> value();
1996 h_data.myFaceWLIds = myFaceSelector->GetListOfIDs();
1998 h_data.myKeepFiles = myAdvWidget->keepWorkingFilesCheck->isChecked();
1999 h_data.myWorkingDir = myAdvWidget->workingDirectoryLineEdit->text().trimmed();
2000 h_data.myVerboseLevel = myAdvWidget->verboseLevelSpin->value();
2001 h_data.myToCreateNewNodes = myAdvWidget->createNewNodesCheck->isChecked();
2002 h_data.myRemoveInitialCentralPoint = myAdvWidget->removeInitialCentralPointCheck->isChecked();
2003 h_data.myBoundaryRecovery = myAdvWidget->boundaryRecoveryCheck->isChecked();
2004 h_data.myFEMCorrection = myAdvWidget->FEMCorrectionCheck->isChecked();
2005 h_data.myGradation = myAdvWidget->gradationSpinBox->value();
2006 h_data.myTextOption = myAdvWidget->myAdvOptionsTable->GetCustomOptions();
2007 h_data.myLogInStandardOutput = !myAdvWidget->logInFileCheck->isChecked();
2008 h_data.myRemoveLogOnSuccess = myAdvWidget->removeLogOnSuccessCheck->isChecked();
2010 // Enforced vertices
2011 h_data.myEnforcedVertices.clear();
2012 QVariant valueX, valueY, valueZ;
2013 for (int row=0 ; row<myEnforcedTableWidget->rowCount() ; row++) {
2015 TEnfVertex *myVertex = new TEnfVertex();
2016 myVertex->name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString();
2017 myVertex->geomEntry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString();
2018 if (myVertex->geomEntry.size())
2019 myVertex->groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
2020 if (myVertex->groupName.size())
2021 valueX = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data(Qt::EditRole);
2022 valueY = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data(Qt::EditRole);
2023 valueZ = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data(Qt::EditRole);
2024 if (!valueX.isNull() && !valueY.isNull() && !valueZ.isNull()) {
2025 myVertex->coords.push_back(valueX.toDouble());
2026 myVertex->coords.push_back(valueY.toDouble());
2027 myVertex->coords.push_back(valueZ.toDouble());
2029 myVertex->size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data(Qt::EditRole).toDouble();
2030 myVertex->isCompound = myEnforcedTableWidget->item(row,ENF_VER_COMPOUND_COLUMN)->data(Qt::CheckStateRole).toBool();
2031 h_data.myEnforcedVertices.insert(myVertex);
2035 h_data.myEnforcedMeshes.clear();
2037 for (int row=0 ; row<myEnforcedMeshTableWidget->rowCount() ; row++) {
2039 TEnfMesh *myEnfMesh = new TEnfMesh();
2040 myEnfMesh->name = myEnforcedMeshTableWidget->item(row,ENF_MESH_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString();
2041 myEnfMesh->entry = myEnforcedMeshTableWidget->item(row,ENF_MESH_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString();
2042 myEnfMesh->groupName = myEnforcedMeshTableWidget->item(row,ENF_MESH_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
2043 QComboBox* combo = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row,ENF_MESH_CONSTRAINT_COLUMN));
2044 myEnfMesh->elementType = combo->currentIndex();
2045 h_data.myEnforcedMeshes.insert(myEnfMesh);
2046 std::cout << "h_data.myEnforcedMeshes.size(): " << h_data.myEnforcedMeshes.size() << std::endl;
2052 QString HYBRIDPluginGUI_HypothesisCreator::caption() const
2054 return tr( "HYBRID_TITLE" );
2057 QPixmap HYBRIDPluginGUI_HypothesisCreator::icon() const
2059 return SUIT_Session::session()->resourceMgr()->loadPixmap( "HYBRIDPlugin", tr( "ICON_DLG_HYBRID_PARAMETERS" ) );
2062 QString HYBRIDPluginGUI_HypothesisCreator::type() const
2064 return tr( "HYBRID_HYPOTHESIS" );
2067 QString HYBRIDPluginGUI_HypothesisCreator::helpPage() const
2069 return "hybrid_hypo_page.html";