1 // Copyright (C) 2004-2013 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.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // HYBRIDPlugin GUI: GUI for plugged-in mesher HYBRIDPlugin
21 // File : HYBRIDPluginGUI_HypothesisCreator.cxx
22 // Author : Michael Zorin
23 // Module : HYBRIDPlugin
25 #include "HYBRIDPluginGUI_HypothesisCreator.h"
26 #include "HYBRIDPluginGUI_Enums.h"
27 #include "HYBRIDPluginGUI_Dlg.h"
29 #include <GeometryGUI.h>
31 #include <SMESHGUI_Utils.h>
32 #include <SMESHGUI_SpinBox.h>
33 #include <SMESHGUI_HypothesesUtils.h>
34 #include <SMESH_NumberFilter.hxx>
35 #include <SMESH_TypeFilter.hxx>
36 #include <StdMeshersGUI_ObjectReferenceParamWdg.h>
38 #include <LightApp_SelectionMgr.h>
39 #include <SUIT_Session.h>
40 #include <SUIT_MessageBox.h>
41 #include <SUIT_ResourceMgr.h>
42 #include <SUIT_FileDlg.h>
43 #include <SalomeApp_Tools.h>
44 #include <SalomeApp_TypeFilter.h>
46 #include <TopoDS_Iterator.hxx>
52 #include <QVBoxLayout>
53 #include <QGridLayout>
58 #include <QPushButton>
62 #include <QTableWidget>
63 #include <QTableWidgetItem>
64 #include <QHeaderView>
67 #include <utilities.h>
69 #include <boost/algorithm/string.hpp>
76 #include <sys/sysinfo.h>
79 int maxAvailableMemory()
82 // See http://msdn.microsoft.com/en-us/library/aa366589.aspx
83 MEMORYSTATUSEX statex;
84 statex.dwLength = sizeof (statex);
85 int err = GlobalMemoryStatusEx (&statex);
88 statex.ullTotalPhys / 1024 / 1024 +
89 statex.ullTotalPageFile / 1024 / 1024 +
90 statex.ullTotalVirtual / 1024 / 1024;
91 return (int) ( 0.7 * totMB );
95 int err = sysinfo( &si );
98 si.totalram * si.mem_unit / 1024 / 1024 +
99 si.totalswap * si.mem_unit / 1024 / 1024 ;
100 return (int) ( 0.7 * totMB );
108 // BEGIN EnforcedVertexTableWidgetDelegate
111 EnforcedVertexTableWidgetDelegate::EnforcedVertexTableWidgetDelegate(QObject *parent)
112 : QItemDelegate(parent)
116 QWidget *EnforcedVertexTableWidgetDelegate::createEditor(QWidget *parent,
117 const QStyleOptionViewItem & option ,
118 const QModelIndex & index ) const
120 QModelIndex father = index.parent();
121 QString entry = father.child(index.row(), ENF_VER_ENTRY_COLUMN).data().toString();
123 if (index.column() == ENF_VER_X_COLUMN ||
124 index.column() == ENF_VER_Y_COLUMN ||
125 index.column() == ENF_VER_Z_COLUMN ||
126 index.column() == ENF_VER_SIZE_COLUMN) {
127 SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent);
128 if (index.column() == ENF_VER_SIZE_COLUMN)
129 editor->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
131 editor->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
132 editor->setReadOnly(!entry.isEmpty());
133 editor->setDisabled(!entry.isEmpty());
136 // else if (index.column() == ENF_VER_COMPOUND_COLUMN) {
137 // QCheckBox *editor = new QCheckBox(parent);
138 // editor->setDisabled(!entry.isEmpty());
141 else if (index.column() == ENF_VER_GROUP_COLUMN ||
142 index.column() == ENF_VER_NAME_COLUMN) {
144 QLineEdit *editor = new QLineEdit(parent);
145 if (index.column() != ENF_VER_GROUP_COLUMN) {
146 editor->setReadOnly(!entry.isEmpty());
147 editor->setDisabled(!entry.isEmpty());
151 return QItemDelegate::createEditor(parent, option, index);
154 void EnforcedVertexTableWidgetDelegate::setEditorData(QWidget *editor,
155 const QModelIndex &index) const
157 if (index.column() == ENF_VER_X_COLUMN ||
158 index.column() == ENF_VER_Y_COLUMN ||
159 index.column() == ENF_VER_Z_COLUMN ||
160 index.column() == ENF_VER_SIZE_COLUMN)
162 SMESHGUI_SpinBox *lineEdit = qobject_cast<SMESHGUI_SpinBox*>(editor);
163 lineEdit->SetValue(index.data().toDouble());
165 else if (index.column() == ENF_VER_COMPOUND_COLUMN) {
166 QCheckBox *checkBox = qobject_cast<QCheckBox*>(editor);
167 checkBox->setChecked(index.data().toBool());
170 QItemDelegate::setEditorData(editor, index);
174 void EnforcedVertexTableWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
175 const QModelIndex &index) const
177 QModelIndex parent = index.parent();
179 QString entry = parent.child(index.row(), ENF_VER_ENTRY_COLUMN).data().toString();
180 bool isCompound = parent.child(index.row(), ENF_VER_COMPOUND_COLUMN).data(Qt::CheckStateRole).toBool();
182 if (index.column() == ENF_VER_X_COLUMN ||
183 index.column() == ENF_VER_Y_COLUMN ||
184 index.column() == ENF_VER_Z_COLUMN) {
185 SMESHGUI_SpinBox *lineEdit = qobject_cast<SMESHGUI_SpinBox*>(editor);
186 if (!isCompound && !vertexExists(model, index, lineEdit->GetString()))
187 model->setData(index, lineEdit->GetValue(), Qt::EditRole);
189 else if (index.column() == ENF_VER_SIZE_COLUMN)
191 SMESHGUI_SpinBox *lineEdit = qobject_cast<SMESHGUI_SpinBox*>(editor);
192 const double newsize = lineEdit->GetValue();
194 model->setData(index, newsize, Qt::EditRole);
196 else if (index.column() == ENF_VER_NAME_COLUMN) {
197 QLineEdit *lineEdit = qobject_cast<QLineEdit*>(editor);
198 QString value = lineEdit->text();
199 if (entry.isEmpty() && !vertexExists(model, index, value))
200 model->setData(index, value, Qt::EditRole);
202 else if (index.column() == ENF_VER_ENTRY_COLUMN) {
203 QLineEdit *lineEdit = qobject_cast<QLineEdit*>(editor);
204 QString value = lineEdit->text();
205 if (! vertexExists(model, index, value))
206 model->setData(index, value, Qt::EditRole);
208 else if (index.column() == ENF_VER_COMPOUND_COLUMN) {
209 QCheckBox *checkBox = qobject_cast<QCheckBox*>(editor);
210 model->setData(index, checkBox->isChecked(), Qt::CheckStateRole);
213 QItemDelegate::setModelData(editor, model, index);
217 void EnforcedVertexTableWidgetDelegate::updateEditorGeometry(QWidget *editor,
218 const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
220 editor->setGeometry(option.rect);
223 bool EnforcedVertexTableWidgetDelegate::vertexExists(QAbstractItemModel *model,
224 const QModelIndex &index,
228 QModelIndex parent = index.parent();
229 int row = index.row();
230 int col = index.column();
232 if (parent.isValid() && !value.isEmpty()) {
233 if (col == ENF_VER_X_COLUMN || col == ENF_VER_Y_COLUMN || col == ENF_VER_Z_COLUMN) {
235 if (col == ENF_VER_X_COLUMN) {
236 x = value.toDouble();
237 y = parent.child(row, ENF_VER_Y_COLUMN).data().toDouble();
238 z = parent.child(row, ENF_VER_Z_COLUMN).data().toDouble();
240 if (col == ENF_VER_Y_COLUMN) {
241 y = value.toDouble();
242 x = parent.child(row, ENF_VER_X_COLUMN).data().toDouble();
243 z = parent.child(row, ENF_VER_Z_COLUMN).data().toDouble();
245 if (col == ENF_VER_Z_COLUMN) {
246 z = value.toDouble();
247 x = parent.child(row, ENF_VER_X_COLUMN).data().toDouble();
248 y = parent.child(row, ENF_VER_Y_COLUMN).data().toDouble();
250 int nbChildren = model->rowCount(parent);
251 for (int i = 0 ; i < nbChildren ; i++) {
253 double childX = parent.child(i, ENF_VER_X_COLUMN).data().toDouble();
254 double childY = parent.child(i, ENF_VER_Y_COLUMN).data().toDouble();
255 double childZ = parent.child(i, ENF_VER_Z_COLUMN).data().toDouble();
256 if ((childX == x) && (childY == y) && (childZ == z)) {
263 else if (col == ENF_VER_NAME_COLUMN) {
264 QString name = parent.child(row, ENF_VER_NAME_COLUMN).data().toString();
274 // END EnforcedVertexTableWidgetDelegate
278 // BEGIN EnforcedMeshTableWidgetDelegate
281 EnforcedMeshTableWidgetDelegate::EnforcedMeshTableWidgetDelegate(QObject *parent)
282 : QItemDelegate(parent)
286 QWidget *EnforcedMeshTableWidgetDelegate::createEditor(QWidget *parent,
287 const QStyleOptionViewItem & option ,
288 const QModelIndex & index ) const
290 return QItemDelegate::createEditor(parent, option, index);
293 void EnforcedMeshTableWidgetDelegate::setEditorData(QWidget *editor,
294 const QModelIndex &index) const
296 QItemDelegate::setEditorData(editor, index);
299 void EnforcedMeshTableWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
300 const QModelIndex &index) const
302 QItemDelegate::setModelData(editor, model, index);
306 void EnforcedMeshTableWidgetDelegate::updateEditorGeometry(QWidget *editor,
307 const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
309 editor->setGeometry(option.rect);
312 // bool EnforcedMeshTableWidgetDelegate::enfMeshExists(QAbstractItemModel *model,
313 // const QModelIndex &index,
314 // QString value) const
316 // bool exists = false;
317 // QModelIndex parent = index.parent();
318 // int row = index.row();
319 // int col = index.column();
324 // END EnforcedMeshTableWidgetDelegate
328 HYBRIDPluginGUI_HypothesisCreator::HYBRIDPluginGUI_HypothesisCreator( const QString& theHypType )
329 : SMESHGUI_GenericHypothesisCreator( theHypType )
331 GeomToolSelected = NULL;
332 GeomToolSelected = getGeomSelectionTool();
334 iconVertex = QPixmap(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_OBJBROWSER_VERTEX")));
335 iconCompound = QPixmap(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_OBJBROWSER_COMPOUND")));
336 // mySelectionMgr = SMESH::GetSelectionMgr(SMESHGUI::GetSMESHGUI());
337 myEnfMeshConstraintLabels << tr( "HYBRID_ENF_MESH_CONSTRAINT_NODE" ) << tr( "HYBRID_ENF_MESH_CONSTRAINT_EDGE" ) << tr("HYBRID_ENF_MESH_CONSTRAINT_FACE");
340 HYBRIDPluginGUI_HypothesisCreator::~HYBRIDPluginGUI_HypothesisCreator()
342 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
343 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
344 myEnfMeshWdg->deactivateSelection();
348 * \brief {Get or create the geom selection tool for active study}
350 GeomSelectionTools* HYBRIDPluginGUI_HypothesisCreator::getGeomSelectionTool()
352 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
353 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
354 if (that->GeomToolSelected == NULL || that->GeomToolSelected->getMyStudy() != aStudy) {
355 that->GeomToolSelected = new GeomSelectionTools(aStudy);
357 return that->GeomToolSelected;
360 GEOM::GEOM_Gen_var HYBRIDPluginGUI_HypothesisCreator::getGeomEngine()
362 return GeometryGUI::GetGeomGen();
365 QFrame* HYBRIDPluginGUI_HypothesisCreator::buildFrame()
367 std::cout << std::endl << "!!!!!!!!!!!!!!!!!!!!buildFrame TOVERIFY" << std::endl;
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 );
396 myToMeshHolesCheck->hide();
397 myToMakeGroupsOfDomains = new QCheckBox( tr( "HYBRID_TO_MAKE_DOMAIN_GROUPS" ), myStdGroup );
398 //aStdLayout->addWidget( myToMakeGroupsOfDomains, row++, 1, 1, 1 );
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 );
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 myBoundaryLayersInwardCheck = new QCheckBox( tr( "HYBRID_LAYERS_INWARD" ), myStdGroup );
410 aStdLayout->addWidget( myBoundaryLayersInwardCheck, row++, 0, 1, 1 );
411 myBoundaryLayersInwardCheck->setToolTip(tr( "HYBRID_LAYERS_Outward" ) ); //"Outward growth if deselected");
413 aStdLayout->addWidget( new QLabel( tr( "HYBRID_HeightFirstLayer" ), myStdGroup ), row, 0, 1, 1 );
414 myHeightFirstLayerSpin = new SMESHGUI_SpinBox( myStdGroup );
415 myHeightFirstLayerSpin->RangeStepAndValidator(0., 100., .1, "HeightFirstLayer");
416 aStdLayout->addWidget( myHeightFirstLayerSpin, row++, 1, 1, 1 );
418 aStdLayout->addWidget( new QLabel( tr( "HYBRID_NbOfBoundaryLayers" ), myStdGroup ), row, 0, 1, 1 );
419 myNbOfBoundaryLayersSpin = new QSpinBox( myStdGroup );
420 aStdLayout->addWidget( myNbOfBoundaryLayersSpin, row++, 1, 1, 1 );
422 aStdLayout->addWidget( new QLabel( tr( "HYBRID_BoundaryLayersProgression" ), myStdGroup ), row, 0, 1, 1 );
423 myBoundaryLayersProgressionSpin = new SMESHGUI_SpinBox( myStdGroup );
424 myBoundaryLayersProgressionSpin->RangeStepAndValidator(0., 10., .1, "BoundaryLayersProgression");
425 aStdLayout->addWidget( myBoundaryLayersProgressionSpin, row++, 1, 1, 1 );
427 myElemGenTetraDominantCheck = new QCheckBox( tr( "HYBRID_TETRA_DOMINANT" ), myStdGroup );
428 aStdLayout->addWidget( myElemGenTetraDominantCheck, row++, 0, 1, 1 );
430 myAddMultinormalsCheck = new QCheckBox( tr( "HYBRID_ADD_MULTINORMALS" ), myStdGroup );
431 aStdLayout->addWidget( myAddMultinormalsCheck, row++, 0, 1, 1 );
433 aStdLayout->addWidget( new QLabel( tr( "HYBRID_MULTINORMAL_ANGLE" ), myStdGroup ), row, 0, 1, 1 );
434 myMultinormalsAngleSpin = new SMESHGUI_SpinBox( myStdGroup );
435 myMultinormalsAngleSpin->RangeStepAndValidator(0., 90., 2., "threshold");
436 aStdLayout->addWidget( myMultinormalsAngleSpin, row++, 1, 1, 1 );
438 mySmoothNormalsCheck = new QCheckBox( tr( "HYBRID_SMOOTH_NORMALS" ), myStdGroup );
439 aStdLayout->addWidget( mySmoothNormalsCheck, row++, 0, 1, 1 );
440 aStdLayout->setRowStretch( row, 10 );
442 // advanced parameters
443 myAdvGroup = new QWidget();
444 QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup );
445 anAdvLayout->setSpacing( 6 );
446 anAdvLayout->setMargin( 11 );
447 myAdvWidget = new HYBRIDPluginGUI_AdvWidget(myAdvGroup);
448 anAdvLayout->addWidget( myAdvWidget);
450 myAdvWidget->maxMemoryCheck->setText(tr( "MAX_MEMORY_SIZE" ));
451 myAdvWidget->initialMemoryCheck->setText(tr( "INIT_MEMORY_SIZE" ));
453 myAdvWidget->maxMemorySpin->RangeStepAndValidator(20.0, 1e6, 10.0);
454 myAdvWidget->maxMemorySpin->setValue( 128.0 );
456 myAdvWidget->initialMemorySpin->RangeStepAndValidator(0.0, 1e6, 10.0);
457 myAdvWidget->initialMemorySpin->setValue( 100.0 );
459 myAdvWidget->initialMemoryLabel ->setText (tr( "MEGABYTE" ));
460 myAdvWidget->maxMemoryLabel ->setText (tr( "MEGABYTE" ));
462 myAdvWidget->workingDirectoryPushButton ->setText (tr( "SELECT_DIR" ));
463 myAdvWidget->keepWorkingFilesCheck ->setText (tr( "KEEP_WORKING_FILES" ));
464 myAdvWidget->verboseLevelLabel ->setText (tr( "VERBOSE_LEVEL" ));
465 myAdvWidget->removeLogOnSuccessCheck ->setText (tr( "REMOVE_LOG_ON_SUCCESS" ));
466 myAdvWidget->logInFileCheck ->setText (tr( "LOG_IN_FILE" ));
468 myAdvWidget->memoryGroupBox ->setTitle(tr( "MEMORY_GROUP_TITLE" ));
469 myAdvWidget->logGroupBox ->setTitle(tr( "LOG_GROUP_TITLE" ));
470 myAdvWidget->advancedMeshingGroupBox ->setTitle(tr( "ADVANCED_MESHING_GROUP_TITLE" ));
472 myAdvWidget->memoryGroupBox->hide();
474 myAdvWidget->createNewNodesCheck->hide();
475 //myAdvWidget->createNewNodesLabel->hide();
476 myAdvWidget->removeInitialCentralPointCheck->hide();
477 myAdvWidget->boundaryRecoveryCheck->hide();
478 myAdvWidget->FEMCorrectionCheck->hide();
479 myAdvWidget->gradationLabel->hide();
480 myAdvWidget->gradationSpinBox->hide();
482 myAdvWidget->createNewNodesCheck ->setText (tr( "TO_ADD_NODES" ));
483 myAdvWidget->removeInitialCentralPointCheck->setText (tr( "NO_INITIAL_CENTRAL_POINT" ));
484 myAdvWidget->boundaryRecoveryCheck ->setText (tr( "RECOVERY_VERSION" ));
485 myAdvWidget->FEMCorrectionCheck ->setText (tr( "FEM_CORRECTION" ));
486 myAdvWidget->gradationLabel ->setText (tr( "HYBRID_GRADATION" ));
487 myAdvWidget->gradationSpinBox->RangeStepAndValidator(1.05, 5.0, 0.05, "length_precision");
488 myAdvWidget->textOptionLabel->setText(tr( "TEXT_OPTION" ));
490 // Enforced vertices parameters
491 myEnfGroup = new QWidget();
492 QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup);
494 myEnforcedTableWidget = new QTableWidget(myEnfGroup);
495 myEnforcedTableWidget ->setMinimumWidth(300);
496 myEnforcedTableWidget->setRowCount( 0 );
497 myEnforcedTableWidget->setColumnCount( ENF_VER_NB_COLUMNS );
498 myEnforcedTableWidget->setSortingEnabled(true);
499 QStringList enforcedHeaders;
500 enforcedHeaders << tr( "HYBRID_ENF_NAME_COLUMN" )
501 << tr( "HYBRID_ENF_VER_X_COLUMN" )<< tr( "HYBRID_ENF_VER_Y_COLUMN" ) << tr( "HYBRID_ENF_VER_Z_COLUMN" )
502 << tr( "HYBRID_ENF_SIZE_COLUMN" ) << tr("HYBRID_ENF_ENTRY_COLUMN") << tr("HYBRID_ENF_VER_COMPOUND_COLUMN") << tr( "HYBRID_ENF_GROUP_COLUMN" );
504 myEnforcedTableWidget->setHorizontalHeaderLabels(enforcedHeaders);
505 myEnforcedTableWidget->verticalHeader()->hide();
506 myEnforcedTableWidget->horizontalHeader()->setStretchLastSection(true);
507 myEnforcedTableWidget->setAlternatingRowColors(true);
508 myEnforcedTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
509 myEnforcedTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
510 myEnforcedTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
511 myEnforcedTableWidget->resizeColumnsToContents();
512 myEnforcedTableWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
513 myEnforcedTableWidget->hideColumn(ENF_VER_COMPOUND_COLUMN);
515 myEnforcedTableWidget->setItemDelegate(new EnforcedVertexTableWidgetDelegate());
518 TColStd_MapOfInteger shapeTypes;
519 shapeTypes.Add( TopAbs_VERTEX );
520 shapeTypes.Add( TopAbs_COMPOUND );
522 SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes);
523 myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true, /*stretch=*/false);
524 myEnfVertexWdg->SetDefaultText(tr("HYBRID_ENF_SELECT_VERTEX"), "QLineEdit { color: grey }");
526 QLabel* myXCoordLabel = new QLabel( tr( "HYBRID_ENF_VER_X_LABEL" ), myEnfGroup );
527 myXCoord = new SMESHGUI_SpinBox(myEnfGroup);
528 myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
529 QLabel* myYCoordLabel = new QLabel( tr( "HYBRID_ENF_VER_Y_LABEL" ), myEnfGroup );
530 myYCoord = new SMESHGUI_SpinBox(myEnfGroup);
531 myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
532 QLabel* myZCoordLabel = new QLabel( tr( "HYBRID_ENF_VER_Z_LABEL" ), myEnfGroup );
533 myZCoord = new SMESHGUI_SpinBox(myEnfGroup);
534 myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
535 QLabel* mySizeLabel = new QLabel( tr( "HYBRID_ENF_SIZE_LABEL" ), myEnfGroup );
536 mySizeValue = new SMESHGUI_SpinBox(myEnfGroup);
537 mySizeValue->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
539 QLabel* myGroupNameLabel = new QLabel( tr( "HYBRID_ENF_GROUP_LABEL" ), myEnfGroup );
540 myGroupName = new QLineEdit(myEnfGroup);
542 addVertexButton = new QPushButton(tr("HYBRID_ENF_ADD"),myEnfGroup);
543 addVertexButton->setEnabled(false);
544 removeVertexButton = new QPushButton(tr("HYBRID_ENF_REMOVE"),myEnfGroup);
545 // myGlobalGroupName = new QCheckBox(tr("HYBRID_ENF_VER_GROUPS"), myEnfGroup);
546 // myGlobalGroupName->setChecked(false);
548 // QGroupBox* GroupBox = new QGroupBox( myEnfGroup );
549 // QLabel* info = new QLabel( GroupBox );
550 // info->setText( tr( "HYBRID_ENF_VER_INFO" ) );
551 // info->setWordWrap( true );
552 // QVBoxLayout* GroupBoxVLayout = new QVBoxLayout( GroupBox );
553 // GroupBoxVLayout->setSpacing( 6 );
554 // GroupBoxVLayout->setMargin( 11 );
555 // GroupBoxVLayout->addWidget( info );
558 //anEnfLayout->addWidget(GroupBox, ENF_VER_WARNING, 0, 1, 2 );
559 anEnfLayout->addWidget(myEnforcedTableWidget, ENF_VER_VERTEX, 0, ENF_VER_NB_LINES, 1);
561 QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup);
562 anEnfLayout2->addWidget(myEnfVertexWdg, ENF_VER_VERTEX, 0, 1, 2);
563 anEnfLayout2->addWidget(myXCoordLabel, ENF_VER_X_COORD, 0, 1, 1);
564 anEnfLayout2->addWidget(myXCoord, ENF_VER_X_COORD, 1, 1, 1);
565 anEnfLayout2->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 0, 1, 1);
566 anEnfLayout2->addWidget(myYCoord, ENF_VER_Y_COORD, 1, 1, 1);
567 anEnfLayout2->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 0, 1, 1);
568 anEnfLayout2->addWidget(myZCoord, ENF_VER_Z_COORD, 1, 1, 1);
569 anEnfLayout2->addWidget(mySizeLabel, ENF_VER_SIZE, 0, 1, 1);
570 anEnfLayout2->addWidget(mySizeValue, ENF_VER_SIZE, 1, 1, 1);
571 anEnfLayout2->addWidget(myGroupNameLabel, ENF_VER_GROUP, 0, 1, 1);
572 anEnfLayout2->addWidget(myGroupName, ENF_VER_GROUP, 1, 1, 1);
573 anEnfLayout2->addWidget(addVertexButton, ENF_VER_BTN, 0, 1, 1);
574 anEnfLayout2->addWidget(removeVertexButton, ENF_VER_BTN, 1, 1, 1);
575 anEnfLayout2->setRowStretch(ENF_VER_NB_LINES, 1);
577 anEnfLayout->addLayout(anEnfLayout2, ENF_VER_VERTEX, 1,ENF_VER_NB_LINES, 1);
578 anEnfLayout->setRowStretch(ENF_VER_VERTEX, 10);
581 // Enforced meshes parameters
582 myEnfMeshGroup = new QWidget();
583 QGridLayout* anEnfMeshLayout = new QGridLayout(myEnfMeshGroup);
585 myEnforcedMeshTableWidget = new QTableWidget(myEnfGroup);
586 myEnforcedMeshTableWidget->setRowCount( 0 );
587 myEnforcedMeshTableWidget->setColumnCount( ENF_MESH_NB_COLUMNS );
588 myEnforcedMeshTableWidget->setSortingEnabled(true);
589 myEnforcedMeshTableWidget->verticalHeader()->hide();
590 QStringList enforcedMeshHeaders;
591 enforcedMeshHeaders << tr( "HYBRID_ENF_NAME_COLUMN" )
592 << tr( "HYBRID_ENF_ENTRY_COLUMN" )
593 << tr( "HYBRID_ENF_MESH_CONSTRAINT_COLUMN" )
594 << tr( "HYBRID_ENF_GROUP_COLUMN" );
595 myEnforcedMeshTableWidget->setHorizontalHeaderLabels(enforcedMeshHeaders);
596 myEnforcedMeshTableWidget->horizontalHeader()->setStretchLastSection(true);
597 myEnforcedMeshTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
598 myEnforcedMeshTableWidget->setAlternatingRowColors(true);
599 myEnforcedMeshTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
600 myEnforcedMeshTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
601 myEnforcedMeshTableWidget->resizeColumnsToContents();
602 myEnforcedMeshTableWidget->hideColumn(ENF_MESH_ENTRY_COLUMN);
604 myEnforcedMeshTableWidget->setItemDelegate(new EnforcedMeshTableWidgetDelegate());
606 // myEnfMesh = SMESH::SMESH_Mesh::_nil();
607 // myEnfMeshArray = new SMESH::mesh_array();
609 myEnfMeshWdg = new StdMeshersGUI_ObjectReferenceParamWdg( SMESH::IDSOURCE, myEnfMeshGroup, /*multiSel=*/true);
610 myEnfMeshWdg->SetDefaultText(tr("HYBRID_ENF_SELECT_MESH"), "QLineEdit { color: grey }");
612 myEnfMeshWdg->AvoidSimultaneousSelection(myEnfVertexWdg);
614 QLabel* myMeshConstraintLabel = new QLabel( tr( "HYBRID_ENF_MESH_CONSTRAINT_LABEL" ), myEnfMeshGroup );
615 myEnfMeshConstraint = new QComboBox(myEnfMeshGroup);
616 myEnfMeshConstraint->insertItems(0,myEnfMeshConstraintLabels);
617 myEnfMeshConstraint->setEditable(false);
618 myEnfMeshConstraint->setCurrentIndex(0);
620 QLabel* myMeshGroupNameLabel = new QLabel( tr( "HYBRID_ENF_GROUP_LABEL" ), myEnfMeshGroup );
621 myMeshGroupName = new QLineEdit(myEnfMeshGroup);
623 addEnfMeshButton = new QPushButton(tr("HYBRID_ENF_ADD"),myEnfMeshGroup);
624 // addEnfMeshButton->setEnabled(false);
625 removeEnfMeshButton = new QPushButton(tr("HYBRID_ENF_REMOVE"),myEnfMeshGroup);
627 // QGroupBox* GroupBox2 = new QGroupBox( myEnfMeshGroup );
628 // QLabel* info2 = new QLabel( GroupBox2 );
629 // info2->setText( tr( "HYBRID_ENF_MESH_INFO" ) );
630 // info2->setWordWrap( true );
631 // QVBoxLayout* GroupBox2VLayout = new QVBoxLayout( GroupBox2 );
632 // GroupBox2VLayout->setSpacing( 6 );
633 // GroupBox2VLayout->setMargin( 11 );
634 // GroupBox2VLayout->addWidget( info2 );
636 // anEnfMeshLayout->addWidget( GroupBox2, ENF_MESH_WARNING, 0, 1, 2 );
637 anEnfMeshLayout->addWidget(myEnforcedMeshTableWidget, ENF_MESH_MESH, 0, ENF_MESH_NB_LINES , 1);
639 QGridLayout* anEnfMeshLayout2 = new QGridLayout(myEnfMeshGroup);
640 anEnfMeshLayout2->addWidget(myEnfMeshWdg, ENF_MESH_MESH, 0, 1, 2);
641 anEnfMeshLayout2->addWidget(myMeshConstraintLabel, ENF_MESH_CONSTRAINT, 0, 1, 1);
642 anEnfMeshLayout2->addWidget(myEnfMeshConstraint, ENF_MESH_CONSTRAINT, 1, 1, 1);
643 anEnfMeshLayout2->addWidget(myMeshGroupNameLabel, ENF_MESH_GROUP, 0, 1, 1);
644 anEnfMeshLayout2->addWidget(myMeshGroupName, ENF_MESH_GROUP, 1, 1, 1);
645 anEnfMeshLayout2->addWidget(addEnfMeshButton, ENF_MESH_BTN, 0, 1, 1);
646 anEnfMeshLayout2->addWidget(removeEnfMeshButton, ENF_MESH_BTN, 1, 1, 1);
647 anEnfMeshLayout2->setRowStretch(ENF_MESH_NB_LINES, 1);
649 anEnfMeshLayout->addLayout(anEnfMeshLayout2, ENF_MESH_MESH, 1, ENF_MESH_NB_LINES, 1);
650 anEnfMeshLayout->setRowStretch(ENF_MESH_MESH, 10);
653 tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
654 tab->insertTab( ADV_TAB, myAdvGroup, tr( "HYBRID_ADV_ARGS" ) );
655 tab->insertTab( ENF_VER_TAB, myEnfGroup, tr( "HYBRID_ENFORCED_VERTICES" ) );
656 tab->insertTab( ENF_MESH_TAB, myEnfMeshGroup, tr( "HYBRID_ENFORCED_MESHES" ) );
657 tab->setCurrentIndex( STD_TAB );
660 //connect( myToMeshHolesCheck, SIGNAL( toggled( bool ) ), this, SLOT( onToMeshHoles(bool)));
661 //connect( myAdvWidget->maxMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
662 //connect( myAdvWidget->initialMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
663 //connect( myAdvWidget->boundaryRecoveryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
665 connect( myBoundaryLayersInwardCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
666 connect( myElemGenTetraDominantCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
667 connect( myAddMultinormalsCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
668 connect( mySmoothNormalsCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
670 connect( myAdvWidget->logInFileCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
671 connect( myAdvWidget->keepWorkingFilesCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
672 connect( myAdvWidget->workingDirectoryPushButton, SIGNAL( clicked() ), this, SLOT( onDirBtnClicked() ) );
674 connect( myEnforcedTableWidget, SIGNAL( itemClicked(QTableWidgetItem *)), this, SLOT( synchronizeCoords() ) );
675 connect( myEnforcedTableWidget, SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
676 connect( myEnforcedTableWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
677 connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertex() ) );
678 connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
679 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
680 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
681 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
682 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
683 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
684 connect( mySizeValue, SIGNAL( textChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) );
685 connect( myXCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
686 connect( myYCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
687 connect( myZCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
688 connect( mySizeValue, SIGNAL( valueChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) );
689 connect( this, SIGNAL( vertexDefined(bool) ), addVertexButton, SLOT( setEnabled(bool) ) );
691 connect( addEnfMeshButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedMesh() ) );
692 connect( removeEnfMeshButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedMesh() ) );
693 // connect( myEnfMeshWdg, SIGNAL( contentModified()), this, SLOT( checkEnfMeshIsDefined() ) );
694 // connect( myEnfMeshConstraint, SIGNAL( currentIndexChanged(int) ), this, SLOT( checkEnfMeshIsDefined() ) );
695 // connect( this, SIGNAL( enfMeshDefined(bool) ), addEnfMeshButton, SLOT( setEnabled(bool) ) );
697 std::cout << std::endl << "!!!!!!!!!!!!!!!!!!!!buildFrame TOVERIFY end" << std::endl;
702 * This method checks if an enforced vertex is defined;
704 void HYBRIDPluginGUI_HypothesisCreator::clearEnfVertexSelection()
706 if (myEnfVertexWdg->NbObjects() != 0) {
707 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
708 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
709 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
710 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
711 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
713 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
714 that->checkVertexIsDefined();
718 * This method checks if an enforced vertex is defined;
720 void HYBRIDPluginGUI_HypothesisCreator::checkVertexIsDefined()
722 bool enfVertexIsDefined = false;
723 enfVertexIsDefined = (!mySizeValue->GetString().isEmpty() &&
724 (!myEnfVertexWdg->NbObjects() == 0 ||
725 (myEnfVertexWdg->NbObjects() == 0 && !myXCoord->GetString().isEmpty()
726 && !myYCoord->GetString().isEmpty()
727 && !myZCoord->GetString().isEmpty())));
728 emit vertexDefined(enfVertexIsDefined);
732 * This method checks if an enforced mesh is defined;
734 void HYBRIDPluginGUI_HypothesisCreator::checkEnfMeshIsDefined()
736 emit enfMeshDefined( myEnfVertexWdg->NbObjects() != 0);
740 * This method resets the content of the X, Y, Z, size and GroupName widgets;
742 void HYBRIDPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
744 myXCoord->setCleared(true);
745 myYCoord->setCleared(true);
746 myZCoord->setCleared(true);
747 // mySizeValue->setCleared(true);
748 myXCoord->setText("");
749 myYCoord->setText("");
750 myZCoord->setText("");
751 // mySizeValue->setText("");
752 // myGroupName->setText("");
753 addVertexButton->setEnabled(false);
756 /** HYBRIDPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item)
757 This method updates the tooltip of a modified item. The QLineEdit widgets content
758 is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
760 void HYBRIDPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTableWidgetItem* item) {
761 // MESSAGE("HYBRIDPluginGUI_HypothesisCreator::updateEnforcedVertexValues");
762 int row = myEnforcedTableWidget->row(item);
764 QVariant vertexName = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole);
765 QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole);
766 QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole);
767 QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole);
768 QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole);
769 QVariant entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
770 QString groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole).toString();
772 clearEnforcedVertexWidgets();
774 if ( !x.isNull() || !entry.isNull()) {
775 QString toolTip = vertexName.toString();
776 toolTip += QString("(");
777 if (entry.isNull() || (!entry.isNull() && entry.toString() == "")) {
778 toolTip += x.toString();
779 toolTip += QString(", ") + y.toString();
780 toolTip += QString(", ") + z.toString();
783 toolTip += entry.toString();
784 toolTip += QString(")");
787 toolTip += QString("=") + size.toString();
789 if (!groupName.isEmpty())
790 toolTip += QString(" [") + groupName + QString("]");
792 // MESSAGE("Tooltip: " << toolTip.toStdString());
793 for (int col=0;col<ENF_VER_NB_COLUMNS;col++)
794 myEnforcedTableWidget->item(row,col)->setToolTip(toolTip);
797 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
798 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
799 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
800 myXCoord->SetValue(x.toDouble());
801 myYCoord->SetValue(y.toDouble());
802 myZCoord->SetValue(z.toDouble());
803 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
804 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
805 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
808 mySizeValue->SetValue(size.toDouble());
810 if (!groupName.isEmpty())
811 myGroupName->setText(groupName);
815 void HYBRIDPluginGUI_HypothesisCreator::onSelectEnforcedVertex() {
816 int nbSelEnfVertex = myEnfVertexWdg->NbObjects();
817 clearEnforcedVertexWidgets();
818 if (nbSelEnfVertex == 1)
820 if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() )
823 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
824 if (myEnfVertex == GEOM::GEOM_Object::_nil())
826 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
827 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
828 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
829 if (CORBA::is_nil(measureOp))
833 measureOp->PointCoordinates (myEnfVertex, x, y, z);
834 if ( measureOp->IsDone() )
836 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
837 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
838 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
839 myXCoord->SetValue(x);
840 myYCoord->SetValue(y);
841 myZCoord->SetValue(z);
842 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
843 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
844 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
850 /** HYBRIDPluginGUI_HypothesisCreator::synchronizeCoords()
851 This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
852 of the enforced vertex clicked in the tree widget.
854 void HYBRIDPluginGUI_HypothesisCreator::synchronizeCoords() {
855 clearEnforcedVertexWidgets();
856 QList<QTableWidgetItem *> items = myEnforcedTableWidget->selectedItems();
857 // myEnfVertexWdg->disconnect(SIGNAL(contentModified()));
858 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
859 if (! items.isEmpty()) {
860 QTableWidgetItem *item;
863 if (items.size() == 1) {
865 row = myEnforcedTableWidget->row(item);
866 QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole);
867 QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole);
868 QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole);
869 QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole);
870 entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
871 if (!entry.isNull()) {
872 SMESH::string_array_var objIds = new SMESH::string_array;
874 objIds[0] = entry.toString().toStdString().c_str();
875 myEnfVertexWdg->SetObjects(objIds);
878 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
880 QVariant group = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole);
881 if (!x.isNull()/* && entry.isNull()*/) {
882 // disconnect( myXCoord, SIGNAL( textChanged(const QString &)), this, SLOT( onSelectEnforcedVertex() ) );
883 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
884 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
885 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
886 myXCoord->SetValue(x.toDouble());
887 myYCoord->SetValue(y.toDouble());
888 myZCoord->SetValue(z.toDouble());
889 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
890 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
891 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
894 mySizeValue->SetValue(size.toDouble());
896 if (!group.isNull() && (!x.isNull() || !entry.isNull()))
897 myGroupName->setText(group.toString());
900 QList<QString> entryList;
901 for (int i = 0; i < items.size(); ++i) {
903 row = myEnforcedTableWidget->row(item);
904 entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
906 entryList << entry.toString();
908 if (entryList.size() > 0) {
909 SMESH::string_array_var objIds = new SMESH::string_array;
910 objIds->length(entryList.size());
911 for (int i = 0; i < entryList.size() ; i++)
912 objIds[i] = entryList.at(i).toStdString().c_str();
913 myEnfVertexWdg->SetObjects(objIds);
916 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
921 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
923 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
924 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
925 that->checkVertexIsDefined();
928 /** HYBRIDPluginGUI_HypothesisCreator::addEnforcedMesh( meshName, geomEntry, elemType, size, groupName)
929 This method adds in the tree widget an enforced mesh from mesh, submesh or group with optionally size and and groupName.
931 void HYBRIDPluginGUI_HypothesisCreator::addEnforcedMesh(std::string name, std::string entry, int elementType, std::string groupName)
933 MESSAGE("addEnforcedMesh(\"" << name << ", \"" << entry << "\", " << elementType << ", \"" << groupName << "\")");
934 bool okToCreate = true;
935 QString itemEntry = "";
936 int itemElementType = 0;
937 int rowCount = myEnforcedMeshTableWidget->rowCount();
938 bool allColumns = true;
939 for (int row = 0;row<rowCount;row++) {
940 for (int col = 0 ; col < ENF_MESH_NB_COLUMNS ; col++) {
941 MESSAGE("col: " << col);
942 if (col == ENF_MESH_CONSTRAINT_COLUMN){
943 if (qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row, col)) == 0) {
945 MESSAGE("allColumns = false");
949 else if (myEnforcedMeshTableWidget->item(row, col) == 0) {
951 MESSAGE("allColumns = false");
954 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
955 QComboBox* itemComboBox = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row, col));
956 itemElementType = itemComboBox->currentIndex();
957 MESSAGE("itemElementType: " << itemElementType);
959 else if (col == ENF_MESH_ENTRY_COLUMN)
960 itemEntry = myEnforcedMeshTableWidget->item(row, col)->data(Qt::EditRole).toString();
966 if (itemEntry == QString(entry.c_str()) && itemElementType == elementType) {
967 // // update group name
968 // if (itemGroupName.toStdString() != groupName) {
969 // MESSAGE("Group is updated from \"" << itemGroupName.toStdString() << "\" to \"" << groupName << "\"");
970 // myEnforcedMeshTableWidget->item(row, ENF_MESH_GROUP_COLUMN)->setData( Qt::EditRole, QVariant(groupName.c_str()));
981 MESSAGE("Creation of enforced mesh");
983 myEnforcedMeshTableWidget->setRowCount(rowCount+1);
984 myEnforcedMeshTableWidget->setSortingEnabled(false);
986 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++) {
987 MESSAGE("Column: " << col);
988 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
989 QComboBox* comboBox = new QComboBox();
990 QPalette pal = comboBox->palette();
991 pal.setColor(QPalette::Button, Qt::white);
992 comboBox->setPalette(pal);
993 comboBox->insertItems(0,myEnfMeshConstraintLabels);
994 comboBox->setEditable(false);
995 comboBox->setCurrentIndex(elementType);
996 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << comboBox->currentText().toStdString());
997 myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox);
1000 QTableWidgetItem* item = new QTableWidgetItem();
1001 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1003 case ENF_MESH_NAME_COLUMN:
1004 item->setData( 0, name.c_str() );
1005 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1006 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1007 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1009 case ENF_MESH_ENTRY_COLUMN:
1010 item->setData( 0, entry.c_str() );
1011 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1012 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1013 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1015 case ENF_MESH_GROUP_COLUMN:
1016 item->setData( 0, groupName.c_str() );
1017 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1018 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1027 // connect( myEnforcedMeshTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1029 myEnforcedMeshTableWidget->setSortingEnabled(true);
1030 // myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1031 // updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1035 /** HYBRIDPluginGUI_HypothesisCreator::addEnforcedVertex( x, y, z, size, vertexName, geomEntry, groupName)
1036 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.
1038 void HYBRIDPluginGUI_HypothesisCreator::addEnforcedVertex(double x, double y, double z, double size, std::string vertexName, std::string geomEntry, std::string groupName, bool isCompound)
1040 MESSAGE("addEnforcedVertex(" << x << ", " << y << ", " << z << ", " << size << ", \"" << vertexName << ", \"" << geomEntry << "\", \"" << groupName << "\", " << isCompound << ")");
1041 myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1042 bool okToCreate = true;
1043 double itemX,itemY,itemZ,itemSize = 0;
1044 QString itemEntry, itemGroupName = QString("");
1045 // bool itemIsCompound;
1046 int rowCount = myEnforcedTableWidget->rowCount();
1049 for (int row = 0;row<rowCount;row++) {
1051 for (int col = 0 ; col < ENF_VER_NB_COLUMNS ; col++) {
1052 if (myEnforcedTableWidget->item(row, col) == 0) {
1057 data = myEnforcedTableWidget->item(row, col)->data(Qt::EditRole);
1058 if (!data.isNull()) {
1060 case ENF_VER_GROUP_COLUMN:
1061 itemGroupName = data.toString();
1063 case ENF_VER_ENTRY_COLUMN:
1064 itemEntry = data.toString();
1066 // case ENF_VER_COMPOUND_COLUMN:
1067 // itemIsCompound = data.toBool();
1069 case ENF_VER_X_COLUMN:
1070 itemX = data.toDouble();
1072 case ENF_VER_Y_COLUMN:
1073 itemY = data.toDouble();
1075 case ENF_VER_Z_COLUMN:
1076 itemZ = data.toDouble();
1078 case ENF_VER_SIZE_COLUMN:
1079 itemSize = data.toDouble();
1091 if (( !isCompound && ((itemX == x) && (itemY == y) && (itemZ == z))) || /*( (itemEntry.toStdString() != "") && */ (itemEntry.toStdString() == geomEntry)/*)*/) {
1093 if (itemSize != size) {
1094 MESSAGE("Size is updated from \"" << itemSize << "\" to \"" << size << "\"");
1095 myEnforcedTableWidget->item(row, ENF_VER_SIZE_COLUMN)->setData( Qt::EditRole, QVariant(size));
1097 // update group name
1098 if (itemGroupName.toStdString() != groupName) {
1099 MESSAGE("Group is updated from \"" << itemGroupName.toStdString() << "\" to \"" << groupName << "\"");
1100 myEnforcedTableWidget->item(row, ENF_VER_GROUP_COLUMN)->setData( Qt::EditRole, QVariant(groupName.c_str()));
1107 if (geomEntry.empty()) {
1108 MESSAGE("Vertex with coords " << x << ", " << y << ", " << z << " already exist: dont create again");
1111 MESSAGE("Vertex with entry " << geomEntry << " already exist: dont create again");
1116 if (geomEntry.empty()) {
1117 MESSAGE("Vertex with coords " << x << ", " << y << ", " << z<< " is created");
1120 MESSAGE("Vertex with geom entry " << geomEntry << " is created");
1125 QString myVertexName;
1126 while(indexRef != vertexIndex) {
1127 indexRef = vertexIndex;
1128 if (vertexName.empty())
1129 myVertexName = QString("Vertex #%1").arg(vertexIndex);
1131 myVertexName = QString(vertexName.c_str());
1133 for (int row = 0;row<rowCount;row++) {
1134 QString name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString();
1135 if (myVertexName == name) {
1142 MESSAGE("myVertexName is \"" << myVertexName.toStdString() << "\"");
1143 myEnforcedTableWidget->setRowCount(rowCount+1);
1144 myEnforcedTableWidget->setSortingEnabled(false);
1145 for (int col=0;col<ENF_VER_NB_COLUMNS;col++) {
1146 MESSAGE("Column: " << col);
1147 QTableWidgetItem* item = new QTableWidgetItem();
1148 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1150 case ENF_VER_NAME_COLUMN:
1151 item->setData( Qt::EditRole, myVertexName );
1152 if (!geomEntry.empty()) {
1154 item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1156 item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1159 case ENF_VER_X_COLUMN:
1161 item->setData( 0, QVariant(x) );
1163 case ENF_VER_Y_COLUMN:
1165 item->setData( 0, QVariant(y) );
1167 case ENF_VER_Z_COLUMN:
1169 item->setData( 0, QVariant(z) );
1171 case ENF_VER_SIZE_COLUMN:
1172 item->setData( 0, QVariant(size) );
1174 case ENF_VER_ENTRY_COLUMN:
1175 if (!geomEntry.empty())
1176 item->setData( 0, QString(geomEntry.c_str()) );
1178 case ENF_VER_COMPOUND_COLUMN:
1179 item->setData( Qt::CheckStateRole, isCompound );
1180 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
1182 case ENF_VER_GROUP_COLUMN:
1183 if (!groupName.empty())
1184 item->setData( 0, QString(groupName.c_str()) );
1190 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1191 myEnforcedTableWidget->setItem(rowCount,col,item);
1195 connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1197 myEnforcedTableWidget->setSortingEnabled(true);
1198 // myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1199 updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1202 /** HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedMesh()
1203 This method is called when a item is added into the enforced meshes tree widget
1205 void HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedMesh()
1207 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedMesh()");
1209 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1211 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1212 myEnfMeshWdg->deactivateSelection();
1214 for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column)
1215 myEnforcedMeshTableWidget->resizeColumnToContents(column);
1218 int selEnfMeshes = myEnfMeshWdg->NbObjects();
1219 if (selEnfMeshes == 0)
1222 std::string groupName = myMeshGroupName->text().toStdString();
1223 // if (myGlobalGroupName->isChecked())
1224 // groupName = myGlobalGroupName->text().toStdString();
1226 if (boost::trim_copy(groupName).empty())
1230 int elementType = myEnfMeshConstraint->currentIndex();
1233 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1234 _PTR(SObject) aSObj; //SMESH::SMESH_IDSource::_nil;
1235 QString meshEntry = myEnfMeshWdg->GetValue();
1236 MESSAGE("myEnfMeshWdg->GetValue()" << meshEntry.toStdString());
1238 if (selEnfMeshes == 1)
1240 MESSAGE("1 SMESH object selected");
1241 // myEnfMesh = myEnfMeshWdg->GetObject< SMESH::SMESH_IDSource >();
1242 // std::string entry = myEnfMeshWdg->GetValue();
1243 aSObj = aStudy->FindObjectID(meshEntry.toStdString().c_str());
1244 CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy);
1245 if (!CORBA::is_nil(anObj)) {
1246 // SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1247 addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
1252 MESSAGE(selEnfMeshes << " SMESH objects selected");
1253 QStringList meshEntries = meshEntry.split(" ", QString::SkipEmptyParts);
1254 QStringListIterator meshEntriesIt (meshEntries);
1255 while (meshEntriesIt.hasNext()) {
1256 aSObj = aStudy->FindObjectID(meshEntriesIt.next().toStdString().c_str());
1257 CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy);
1258 if (!CORBA::is_nil(anObj)) {
1259 // SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1260 addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
1265 myEnfVertexWdg->SetObject(SMESH::SMESH_IDSource::_nil());
1267 for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column)
1268 myEnforcedMeshTableWidget->resizeColumnToContents(column);
1272 /** HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedVertex()
1273 This method is called when a item is added into the enforced vertices tree widget
1275 void HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedVertex()
1277 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedVertex()");
1279 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1281 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1282 myEnfVertexWdg->deactivateSelection();
1284 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1285 myEnforcedTableWidget->resizeColumnToContents(column);
1288 int selEnfVertex = myEnfVertexWdg->NbObjects();
1289 bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty());
1290 if ((selEnfVertex == 0) && coordsEmpty)
1293 std::string groupName = myGroupName->text().toStdString();
1294 // if (myGlobalGroupName->isChecked())
1295 // groupName = myGlobalGroupName->text().toStdString();
1297 if (boost::trim_copy(groupName).empty())
1300 double size = mySizeValue->GetValue();
1302 if (selEnfVertex <= 1)
1304 MESSAGE("0 or 1 GEOM object selected");
1305 double x = 0, y = 0, z=0;
1306 if (myXCoord->GetString() != "") {
1307 x = myXCoord->GetValue();
1308 y = myYCoord->GetValue();
1309 z = myZCoord->GetValue();
1311 if (selEnfVertex == 1) {
1312 MESSAGE("1 GEOM object selected");
1313 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >();
1314 std::string entry = "";
1315 if (myEnfVertex != GEOM::GEOM_Object::_nil())
1316 entry = myEnfVertex->GetStudyEntry();
1317 addEnforcedVertex(x, y, z, size, myEnfVertex->GetName(),entry, groupName, myEnfVertex->GetShapeType() == GEOM::COMPOUND);
1320 MESSAGE("0 GEOM object selected");
1321 MESSAGE("Coords: ("<<x<<","<<y<<","<<z<<")");
1322 addEnforcedVertex(x, y, z, size, "", "", groupName);
1327 if ( CORBA::is_nil(getGeomEngine()))
1330 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
1331 if (CORBA::is_nil(measureOp))
1334 CORBA::Double x = 0, y = 0,z = 0;
1335 for (int j = 0 ; j < selEnfVertex ; j++)
1337 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j);
1338 if (myEnfVertex == GEOM::GEOM_Object::_nil())
1340 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1341 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1342 if ( measureOp->IsDone() )
1343 addEnforcedVertex(x, y, z, size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1344 } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) {
1345 addEnforcedVertex(0., 0., 0., size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName, true);
1350 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1352 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1353 myEnforcedTableWidget->resizeColumnToContents(column);
1356 /** HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedMesh()
1357 This method is called when a item is removed from the enforced meshes tree widget
1359 void HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedMesh()
1361 QList<int> selectedRows;
1362 QList<QTableWidgetItem *> selectedItems = myEnforcedMeshTableWidget->selectedItems();
1363 QTableWidgetItem* item;
1365 foreach( item, selectedItems ) {
1367 if (!selectedRows.contains( row ) )
1368 selectedRows.append(row);
1371 qSort( selectedRows );
1372 QListIterator<int> it( selectedRows );
1374 while ( it.hasPrevious() ) {
1375 row = it.previous();
1376 MESSAGE("delete row #"<< row);
1377 myEnforcedMeshTableWidget->removeRow(row );
1380 myEnforcedMeshTableWidget->selectionModel()->clearSelection();
1383 /** HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1384 This method is called when a item is removed from the enforced vertices tree widget
1386 void HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1388 QList<int> selectedRows;
1389 QList<QTableWidgetItem *> selectedItems = myEnforcedTableWidget->selectedItems();
1390 QTableWidgetItem* item;
1392 foreach( item, selectedItems ) {
1394 if (!selectedRows.contains( row ) )
1395 selectedRows.append(row);
1398 qSort( selectedRows );
1399 QListIterator<int> it( selectedRows );
1401 while ( it.hasPrevious() ) {
1402 row = it.previous();
1403 MESSAGE("delete row #"<< row);
1404 myEnforcedTableWidget->removeRow(row );
1407 myEnforcedTableWidget->selectionModel()->clearSelection();
1410 void HYBRIDPluginGUI_HypothesisCreator::onToMeshHoles(bool isOn)
1412 // myToMakeGroupsOfDomains->setEnabled( isOn );
1414 // myToMakeGroupsOfDomains->setChecked( false );
1417 void HYBRIDPluginGUI_HypothesisCreator::onDirBtnClicked()
1419 QString dir = SUIT_FileDlg::getExistingDirectory( dlg(), myAdvWidget->workingDirectoryLineEdit->text(), QString() );
1420 if ( !dir.isEmpty() )
1421 myAdvWidget->workingDirectoryLineEdit->setText( dir );
1424 void HYBRIDPluginGUI_HypothesisCreator::updateWidgets()
1426 //customs automatic set
1427 //myToMakeGroupsOfDomains->setEnabled( myToMeshHolesCheck->isChecked() );
1428 //myAdvWidget->maxMemorySpin->setEnabled( myAdvWidget->maxMemoryCheck->isChecked() );
1429 //myAdvWidget->initialMemoryCheck->setEnabled( !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1430 //myAdvWidget->initialMemorySpin->setEnabled( myAdvWidget->initialMemoryCheck->isChecked() && !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1431 //myOptimizationLevelCombo->setEnabled( !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1432 myMultinormalsAngleSpin->setEnabled( myAddMultinormalsCheck->isChecked() );
1433 if ( sender() == myAdvWidget->logInFileCheck ||
1434 sender() == myAdvWidget->keepWorkingFilesCheck )
1436 bool logFileRemovable = myAdvWidget->logInFileCheck->isChecked() &&
1437 !myAdvWidget->keepWorkingFilesCheck->isChecked();
1439 myAdvWidget->removeLogOnSuccessCheck->setEnabled( logFileRemovable );
1443 bool HYBRIDPluginGUI_HypothesisCreator::checkParams(QString& msg) const
1445 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::checkParams");
1447 if ( !QFileInfo( myAdvWidget->workingDirectoryLineEdit->text().trimmed() ).isWritable() ) {
1448 SUIT_MessageBox::warning( dlg(),
1449 tr( "SMESH_WRN_WARNING" ),
1450 tr( "HYBRID_PERMISSION_DENIED" ) );
1457 void HYBRIDPluginGUI_HypothesisCreator::retrieveParams() const
1459 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::retrieveParams");
1460 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1461 HYBRIDHypothesisData data;
1462 readParamsFromHypo( data );
1465 myName->setText( data.myName );
1467 myToMeshHolesCheck ->setChecked ( data.myToMeshHoles );
1468 myToMakeGroupsOfDomains ->setChecked ( data.myToMakeGroupsOfDomains );
1469 myOptimizationLevelCombo ->setCurrentIndex( data.myOptimizationLevel );
1470 myAdvWidget->maxMemoryCheck ->setChecked ( data.myMaximumMemory > 0 );
1471 myAdvWidget->maxMemorySpin ->setValue ( qMax( data.myMaximumMemory,
1472 myAdvWidget->maxMemorySpin->minimum() ));
1473 myAdvWidget->initialMemoryCheck ->setChecked ( data.myInitialMemory > 0 );
1474 myAdvWidget->initialMemorySpin ->setValue ( qMax( data.myInitialMemory,
1475 myAdvWidget->initialMemorySpin->minimum() ));
1477 myBoundaryLayersInwardCheck -> setChecked ( data.myBoundaryLayersInward );
1478 myElemGenTetraDominantCheck -> setChecked ( data.myElemGenTetraDominant );
1479 myAddMultinormalsCheck -> setChecked ( data.myAddMultinormals );
1480 mySmoothNormalsCheck -> setChecked ( data.mySmoothNormals );
1481 myHeightFirstLayerSpin -> setValue( data.myHeightFirstLayer );
1482 myNbOfBoundaryLayersSpin -> setValue( data.myNbOfBoundaryLayers );
1483 myBoundaryLayersProgressionSpin -> setValue( data.myBoundaryLayersProgression );
1484 myMultinormalsAngleSpin -> setValue( data.myMultinormalsAngle );
1486 myAdvWidget->workingDirectoryLineEdit ->setText ( data.myWorkingDir );
1487 myAdvWidget->keepWorkingFilesCheck ->setChecked ( data.myKeepFiles );
1488 myAdvWidget->verboseLevelSpin ->setValue ( data.myVerboseLevel );
1489 myAdvWidget->createNewNodesCheck ->setChecked ( data.myToCreateNewNodes );
1490 myAdvWidget->removeInitialCentralPointCheck ->setChecked ( data.myRemoveInitialCentralPoint );
1491 myAdvWidget->boundaryRecoveryCheck ->setChecked ( data.myBoundaryRecovery );
1492 myAdvWidget->FEMCorrectionCheck ->setChecked ( data.myFEMCorrection );
1493 myAdvWidget->gradationSpinBox ->setValue ( data.myGradation );
1494 myAdvWidget->textOptionLineEdit ->setText ( data.myTextOption );
1495 myAdvWidget->logInFileCheck ->setChecked ( !data.myLogInStandardOutput );
1496 myAdvWidget->removeLogOnSuccessCheck ->setChecked ( data.myRemoveLogOnSuccess );
1498 TEnfVertexList::const_iterator it;
1500 myEnforcedTableWidget->clearContents();
1501 myEnforcedTableWidget->setSortingEnabled(false);
1502 myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1503 for(it = data.myEnforcedVertices.begin() ; it != data.myEnforcedVertices.end(); it++ )
1505 TEnfVertex* enfVertex = (*it);
1506 myEnforcedTableWidget->setRowCount(rowCount+1);
1508 for (int col=0;col<ENF_VER_NB_COLUMNS;col++) {
1509 MESSAGE("Column: " << col);
1510 // MESSAGE("enfVertex->isCompound: " << enfVertex->isCompound);
1511 QTableWidgetItem* item = new QTableWidgetItem();
1512 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1514 case ENF_VER_NAME_COLUMN:
1515 item->setData( 0, enfVertex->name.c_str() );
1516 if (!enfVertex->geomEntry.empty()) {
1517 if (enfVertex->isCompound)
1518 item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1520 item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1522 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1525 case ENF_VER_X_COLUMN:
1526 if (!enfVertex->isCompound) {
1527 item->setData( 0, enfVertex->coords.at(0) );
1528 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1531 case ENF_VER_Y_COLUMN:
1532 if (!enfVertex->isCompound) {
1533 item->setData( 0, enfVertex->coords.at(1) );
1534 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1537 case ENF_VER_Z_COLUMN:
1538 if (!enfVertex->isCompound) {
1539 item->setData( 0, enfVertex->coords.at(2) );
1540 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1543 case ENF_VER_SIZE_COLUMN:
1544 item->setData( 0, enfVertex->size );
1545 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1547 case ENF_VER_ENTRY_COLUMN:
1548 item->setData( 0, enfVertex->geomEntry.c_str() );
1549 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1551 case ENF_VER_COMPOUND_COLUMN:
1552 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
1553 item->setData( Qt::CheckStateRole, enfVertex->isCompound );
1554 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << enfVertex->isCompound);
1556 case ENF_VER_GROUP_COLUMN:
1557 item->setData( 0, enfVertex->groupName.c_str() );
1558 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1564 myEnforcedTableWidget->setItem(rowCount,col,item);
1567 that->updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1571 connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1572 myEnforcedTableWidget->setSortingEnabled(true);
1574 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1575 myEnforcedTableWidget->resizeColumnToContents(column);
1577 // Update Enforced meshes QTableWidget
1578 TEnfMeshList::const_iterator itMesh;
1580 myEnforcedMeshTableWidget->clearContents();
1581 myEnforcedMeshTableWidget->setSortingEnabled(false);
1582 // myEnforcedMeshTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1583 for(itMesh = data.myEnforcedMeshes.begin() ; itMesh != data.myEnforcedMeshes.end(); itMesh++ )
1585 TEnfMesh* enfMesh = (*itMesh);
1586 myEnforcedMeshTableWidget->setRowCount(rowCount+1);
1588 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++) {
1589 MESSAGE("Column: " << col);
1590 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1591 QComboBox* comboBox = new QComboBox();
1592 QPalette pal = comboBox->palette();
1593 pal.setColor(QPalette::Button, Qt::white);
1594 comboBox->setPalette(pal);
1595 comboBox->insertItems(0,myEnfMeshConstraintLabels);
1596 comboBox->setEditable(false);
1597 comboBox->setCurrentIndex(enfMesh->elementType);
1598 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << comboBox->currentText().toStdString());
1599 myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox);
1602 QTableWidgetItem* item = new QTableWidgetItem();
1603 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1605 case ENF_MESH_NAME_COLUMN:
1606 item->setData( 0, enfMesh->name.c_str() );
1607 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1608 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1609 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1611 case ENF_MESH_ENTRY_COLUMN:
1612 item->setData( 0, enfMesh->entry.c_str() );
1613 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1614 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1615 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1617 case ENF_MESH_GROUP_COLUMN:
1618 item->setData( 0, enfMesh->groupName.c_str() );
1619 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1620 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1627 // myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1630 // that->updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1634 // connect( myEnforcedMeshTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1635 myEnforcedMeshTableWidget->setSortingEnabled(true);
1637 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++)
1638 myEnforcedMeshTableWidget->resizeColumnToContents(col);
1640 that->updateWidgets();
1641 that->checkVertexIsDefined();
1644 QString HYBRIDPluginGUI_HypothesisCreator::storeParams() const
1646 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::storeParams");
1647 HYBRIDHypothesisData data;
1648 readParamsFromWidgets( data );
1649 storeParamsToHypo( data );
1651 QString valStr = "";
1653 if ( !data.myBoundaryRecovery )
1654 valStr = "-c " + QString::number( !data.myToMeshHoles );
1656 if ( data.myOptimizationLevel >= 0 && data.myOptimizationLevel < 5 && !data.myBoundaryRecovery) {
1657 const char* level[] = { "none" , "light" , "standard" , "standard+" , "strong" };
1659 valStr += level[ data.myOptimizationLevel ];
1661 if ( data.myMaximumMemory > 0 ) {
1663 valStr += QString::number( data.myMaximumMemory );
1665 if ( data.myInitialMemory > 0 && !data.myBoundaryRecovery ) {
1667 valStr += QString::number( data.myInitialMemory );
1670 valStr += QString::number( data.myVerboseLevel );
1672 if ( !data.myToCreateNewNodes )
1675 if ( data.myRemoveInitialCentralPoint )
1676 valStr += " -no_initial_central_point";
1678 if ( data.myBoundaryRecovery )
1681 if ( data.myFEMCorrection )
1684 if ( data.myGradation != 1.05 ) {
1685 valStr += " -Dcpropa=";
1686 valStr += QString::number( data.myGradation );
1690 valStr += data.myTextOption;
1692 // valStr += " #BEGIN ENFORCED VERTICES#";
1693 // // Add size map parameters storage
1694 // for (int i=0 ; i<mySmpModel->rowCount() ; i++) {
1696 // double x = mySmpModel->data(mySmpModel->index(i,ENF_VER_X_COLUMN)).toDouble();
1697 // double y = mySmpModel->data(mySmpModel->index(i,ENF_VER_Y_COLUMN)).toDouble();
1698 // double z = mySmpModel->data(mySmpModel->index(i,ENF_VER_Z_COLUMN)).toDouble();
1699 // double size = mySmpModel->data(mySmpModel->index(i,ENF_VER_SIZE_COLUMN)).toDouble();
1700 // valStr += QString::number( x );
1702 // valStr += QString::number( y );
1704 // valStr += QString::number( z );
1706 // valStr += QString::number( size );
1707 // if (i!=mySmpModel->rowCount()-1)
1710 // valStr += " #END ENFORCED VERTICES#";
1711 // MESSAGE(valStr.toStdString());
1715 bool HYBRIDPluginGUI_HypothesisCreator::readParamsFromHypo( HYBRIDHypothesisData& h_data ) const
1717 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::readParamsFromHypo");
1718 HYBRIDPlugin::HYBRIDPlugin_Hypothesis_var h =
1719 HYBRIDPlugin::HYBRIDPlugin_Hypothesis::_narrow( initParamsHypothesis() );
1721 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
1722 h_data.myName = isCreation() && data ? hypName() : "";
1724 h_data.myToMeshHoles = h->GetToMeshHoles();
1725 h_data.myToMakeGroupsOfDomains = /*h->GetToMeshHoles() &&*/ h->GetToMakeGroupsOfDomains();
1726 h_data.myMaximumMemory = h->GetMaximumMemory();
1727 h_data.myInitialMemory = h->GetInitialMemory();
1728 h_data.myInitialMemory = h->GetInitialMemory();
1729 h_data.myOptimizationLevel = h->GetOptimizationLevel();
1731 h_data.myBoundaryLayersInward = h->GetBoundaryLayersInward();
1732 h_data.myElemGenTetraDominant = h->GetElemGenTetraDominant();
1733 h_data.myAddMultinormals = h->GetAddMultinormals();
1734 h_data.mySmoothNormals = h->GetSmoothNormals();
1735 h_data.myHeightFirstLayer = h->GetHeightFirstLayer();
1736 h_data.myBoundaryLayersProgression = h->GetBoundaryLayersProgression();
1737 h_data.myMultinormalsAngle = h->GetMultinormalsAngle();
1738 h_data.myNbOfBoundaryLayers = h->GetNbOfBoundaryLayers();
1740 h_data.myKeepFiles = h->GetKeepFiles();
1741 h_data.myWorkingDir = h->GetWorkingDirectory();
1742 h_data.myVerboseLevel = h->GetVerboseLevel();
1743 h_data.myToCreateNewNodes = h->GetToCreateNewNodes();
1744 h_data.myRemoveInitialCentralPoint = h->GetToRemoveCentralPoint();
1745 h_data.myBoundaryRecovery = h->GetToUseBoundaryRecoveryVersion();
1746 h_data.myFEMCorrection = h->GetFEMCorrection();
1747 h_data.myGradation = h->GetGradation();
1748 h_data.myTextOption = h->GetTextOption();
1749 h_data.myLogInStandardOutput = h->GetStandardOutputLog();
1750 h_data.myRemoveLogOnSuccess = h->GetRemoveLogOnSuccess();
1752 HYBRIDPlugin::HYBRIDEnforcedVertexList_var vertices = h->GetEnforcedVertices();
1753 MESSAGE("vertices->length(): " << vertices->length());
1754 h_data.myEnforcedVertices.clear();
1755 for (int i=0 ; i<vertices->length() ; i++) {
1756 TEnfVertex* myVertex = new TEnfVertex();
1757 myVertex->name = CORBA::string_dup(vertices[i].name.in());
1758 myVertex->geomEntry = CORBA::string_dup(vertices[i].geomEntry.in());
1759 myVertex->groupName = CORBA::string_dup(vertices[i].groupName.in());
1760 myVertex->size = vertices[i].size;
1761 myVertex->isCompound = vertices[i].isCompound;
1762 if (vertices[i].coords.length()) {
1763 for (int c = 0; c < vertices[i].coords.length() ; c++)
1764 myVertex->coords.push_back(vertices[i].coords[c]);
1765 MESSAGE("Add enforced vertex ("<< myVertex->coords.at(0) << ","<< myVertex->coords.at(1) << ","<< myVertex->coords.at(2) << ") ="<< myVertex->size);
1767 h_data.myEnforcedVertices.insert(myVertex);
1770 HYBRIDPlugin::HYBRIDEnforcedMeshList_var enfMeshes = h->GetEnforcedMeshes();
1771 MESSAGE("enfMeshes->length(): " << enfMeshes->length());
1772 h_data.myEnforcedMeshes.clear();
1773 for (int i=0 ; i<enfMeshes->length() ; i++) {
1774 TEnfMesh* myEnfMesh = new TEnfMesh();
1775 myEnfMesh->name = CORBA::string_dup(enfMeshes[i].name.in());
1776 myEnfMesh->entry = CORBA::string_dup(enfMeshes[i].entry.in());
1777 myEnfMesh->groupName = CORBA::string_dup(enfMeshes[i].groupName.in());
1778 switch (enfMeshes[i].elementType) {
1780 myEnfMesh->elementType = 0;
1783 myEnfMesh->elementType = 1;
1786 myEnfMesh->elementType = 2;
1791 // myEnfMesh->elementType = enfMeshes[i].elementType;
1792 h_data.myEnforcedMeshes.insert(myEnfMesh);
1797 bool HYBRIDPluginGUI_HypothesisCreator::storeParamsToHypo( const HYBRIDHypothesisData& h_data ) const
1799 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::storeParamsToHypo");
1800 HYBRIDPlugin::HYBRIDPlugin_Hypothesis_var h =
1801 HYBRIDPlugin::HYBRIDPlugin_Hypothesis::_narrow( hypothesis() );
1807 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
1809 if ( h->GetToMeshHoles() != h_data.myToMeshHoles ) // avoid duplication of DumpPython commands
1810 h->SetToMeshHoles ( h_data.myToMeshHoles );
1811 if ( h->GetToMakeGroupsOfDomains() != h_data.myToMakeGroupsOfDomains )
1812 h->SetToMakeGroupsOfDomains( h_data.myToMakeGroupsOfDomains );
1813 if ( h->GetMaximumMemory() != h_data.myMaximumMemory )
1814 h->SetMaximumMemory ( h_data.myMaximumMemory );
1815 if ( h->GetInitialMemory() != h_data.myInitialMemory )
1816 h->SetInitialMemory ( h_data.myInitialMemory );
1817 if ( h->GetInitialMemory() != h_data.myInitialMemory )
1818 h->SetInitialMemory ( h_data.myInitialMemory );
1819 if ( h->GetOptimizationLevel() != h_data.myOptimizationLevel )
1820 h->SetOptimizationLevel( h_data.myOptimizationLevel );
1822 if ( h->GetBoundaryLayersInward() != h_data.myBoundaryLayersInward )
1823 h->SetBoundaryLayersInward ( h_data.myBoundaryLayersInward );
1824 if ( h->GetElemGenTetraDominant() != h_data.myElemGenTetraDominant )
1825 h->SetElemGenTetraDominant ( h_data.myElemGenTetraDominant );
1826 if ( h->GetAddMultinormals() != h_data.myAddMultinormals )
1827 h->SetAddMultinormals ( h_data.myAddMultinormals );
1828 if ( h->GetSmoothNormals() != h_data.mySmoothNormals )
1829 h->SetSmoothNormals ( h_data.mySmoothNormals );
1830 if ( h->GetHeightFirstLayer() != h_data.myHeightFirstLayer )
1831 h->SetHeightFirstLayer ( h_data.myHeightFirstLayer );
1832 if ( h->GetBoundaryLayersProgression() != h_data.myBoundaryLayersProgression )
1833 h->SetBoundaryLayersProgression ( h_data.myBoundaryLayersProgression );
1834 if ( h->GetMultinormalsAngle() != h_data.myMultinormalsAngle )
1835 h->SetMultinormalsAngle ( h_data.myMultinormalsAngle );
1836 if ( h->GetNbOfBoundaryLayers() != h_data.myNbOfBoundaryLayers )
1837 h->SetNbOfBoundaryLayers ( h_data.myNbOfBoundaryLayers );
1839 if ( h->GetKeepFiles() != h_data.myKeepFiles)
1840 h->SetKeepFiles ( h_data.myKeepFiles);
1841 if ( h->GetWorkingDirectory() != h_data.myWorkingDir )
1842 h->SetWorkingDirectory ( h_data.myWorkingDir.toLatin1().constData() );
1843 if ( h->GetVerboseLevel() != h_data.myVerboseLevel )
1844 h->SetVerboseLevel ( h_data.myVerboseLevel );
1845 if ( h->GetToCreateNewNodes() != h_data.myToCreateNewNodes )
1846 h->SetToCreateNewNodes ( h_data.myToCreateNewNodes );
1847 if ( h->GetToRemoveCentralPoint() != h_data.myRemoveInitialCentralPoint )
1848 h->SetToRemoveCentralPoint ( h_data.myRemoveInitialCentralPoint );
1849 if ( h->GetToUseBoundaryRecoveryVersion() != h_data.myBoundaryRecovery )
1850 h->SetToUseBoundaryRecoveryVersion ( h_data.myBoundaryRecovery );
1851 if ( h->GetFEMCorrection() != h_data.myFEMCorrection )
1852 h->SetFEMCorrection ( h_data.myFEMCorrection );
1853 if ( h->GetGradation() != h_data.myGradation )
1854 h->SetGradation ( h_data.myGradation );
1855 if ( h->GetTextOption() != h_data.myTextOption )
1856 h->SetTextOption ( h_data.myTextOption.toLatin1().constData() );
1857 if ( h->GetStandardOutputLog() != h_data.myLogInStandardOutput )
1858 h->SetStandardOutputLog ( h_data.myLogInStandardOutput );
1859 if ( h->GetRemoveLogOnSuccess() != h_data.myRemoveLogOnSuccess )
1860 h->SetRemoveLogOnSuccess ( h_data.myRemoveLogOnSuccess );
1862 // Enforced vertices
1863 int nbVertex = (int) h_data.myEnforcedVertices.size();
1864 HYBRIDPlugin::HYBRIDEnforcedVertexList_var vertexHyp = h->GetEnforcedVertices();
1865 int nbVertexHyp = vertexHyp->length();
1867 MESSAGE("Store params for size maps: " << nbVertex << " enforced vertices");
1868 MESSAGE("h->GetEnforcedVertices()->length(): " << nbVertexHyp);
1870 // 1. Clear all enforced vertices in hypothesis
1871 // 2. Add new enforced vertex according to h_data
1872 if ( nbVertexHyp > 0)
1873 h->ClearEnforcedVertices();
1875 TEnfVertexList::const_iterator it;
1876 double x = 0, y = 0, z = 0;
1877 for(it = h_data.myEnforcedVertices.begin() ; it != h_data.myEnforcedVertices.end(); it++ ) {
1878 TEnfVertex* enfVertex = (*it);
1880 if (enfVertex->coords.size()) {
1881 x = enfVertex->coords.at(0);
1882 y = enfVertex->coords.at(1);
1883 z = enfVertex->coords.at(2);
1885 ok = h->p_SetEnforcedVertex( enfVertex->size, x, y, z, enfVertex->name.c_str(), enfVertex->geomEntry.c_str(), enfVertex->groupName.c_str(), enfVertex->isCompound);
1889 int nbEnfMeshes = (int) h_data.myEnforcedMeshes.size();
1890 HYBRIDPlugin::HYBRIDEnforcedMeshList_var enfMeshListHyp = h->GetEnforcedMeshes();
1891 int nbEnfMeshListHyp = enfMeshListHyp->length();
1893 MESSAGE("Store params for size maps: " << nbEnfMeshes << " enforced meshes");
1894 MESSAGE("h->GetEnforcedMeshes()->length(): " << nbEnfMeshListHyp);
1896 // 1. Clear all enforced vertices in hypothesis
1897 // 2. Add new enforced vertex according to h_data
1898 if ( nbEnfMeshListHyp > 0)
1899 h->ClearEnforcedMeshes();
1901 TEnfMeshList::const_iterator itEnfMesh;
1903 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1905 for(itEnfMesh = h_data.myEnforcedMeshes.begin() ; itEnfMesh != h_data.myEnforcedMeshes.end(); itEnfMesh++ ) {
1906 TEnfMesh* enfMesh = (*itEnfMesh);
1908 _PTR(SObject) aSObj = aStudy->FindObjectID(enfMesh->entry.c_str());
1909 SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1911 MESSAGE("enfMesh->elementType: " << enfMesh->elementType);
1912 SMESH::ElementType elementType;
1913 switch(enfMesh->elementType) {
1915 elementType = SMESH::NODE;
1918 elementType = SMESH::EDGE;
1921 elementType = SMESH::FACE;
1927 std::cout << "h->p_SetEnforcedMesh(theSource, "<< elementType <<", \""<< enfMesh->name << "\", \"" << enfMesh->groupName.c_str() <<"\")"<<std::endl;
1928 ok = h->p_SetEnforcedMesh(theSource, elementType, enfMesh->name.c_str(), enfMesh->groupName.c_str());
1931 // catch(const std::exception& ex) {
1932 // std::cout << "Exception: " << ex.what() << std::endl;
1935 catch ( const SALOME::SALOME_Exception& ex )
1937 SalomeApp_Tools::QtCatchCorbaException( ex );
1943 bool HYBRIDPluginGUI_HypothesisCreator::readParamsFromWidgets( HYBRIDHypothesisData& h_data ) const
1945 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::readParamsFromWidgets");
1946 h_data.myName = myName ? myName->text() : "";
1947 h_data.myToMeshHoles = myToMeshHolesCheck->isChecked();
1948 h_data.myToMakeGroupsOfDomains = myToMakeGroupsOfDomains->isChecked();
1949 h_data.myMaximumMemory = myAdvWidget->maxMemoryCheck->isChecked() ? myAdvWidget->maxMemorySpin->value() : -1;
1950 h_data.myInitialMemory = myAdvWidget->initialMemoryCheck->isChecked() ? myAdvWidget->initialMemorySpin->value() : -1;
1951 h_data.myOptimizationLevel = myOptimizationLevelCombo->currentIndex();
1953 h_data.myBoundaryLayersInward = myBoundaryLayersInwardCheck->isChecked();
1954 h_data.myElemGenTetraDominant = myElemGenTetraDominantCheck->isChecked();
1955 h_data.myAddMultinormals = myAddMultinormalsCheck->isChecked();
1956 h_data.mySmoothNormals = mySmoothNormalsCheck->isChecked();
1958 h_data.myHeightFirstLayer = myHeightFirstLayerSpin -> value();
1959 h_data.myNbOfBoundaryLayers = myNbOfBoundaryLayersSpin -> value();
1960 h_data.myBoundaryLayersProgression = myBoundaryLayersProgressionSpin -> value();
1961 h_data.myMultinormalsAngle = myMultinormalsAngleSpin -> value();
1963 h_data.myKeepFiles = myAdvWidget->keepWorkingFilesCheck->isChecked();
1964 h_data.myWorkingDir = myAdvWidget->workingDirectoryLineEdit->text().trimmed();
1965 h_data.myVerboseLevel = myAdvWidget->verboseLevelSpin->value();
1966 h_data.myToCreateNewNodes = myAdvWidget->createNewNodesCheck->isChecked();
1967 h_data.myRemoveInitialCentralPoint = myAdvWidget->removeInitialCentralPointCheck->isChecked();
1968 h_data.myBoundaryRecovery = myAdvWidget->boundaryRecoveryCheck->isChecked();
1969 h_data.myFEMCorrection = myAdvWidget->FEMCorrectionCheck->isChecked();
1970 h_data.myGradation = myAdvWidget->gradationSpinBox->value();
1971 h_data.myTextOption = myAdvWidget->textOptionLineEdit->text();
1972 h_data.myLogInStandardOutput = !myAdvWidget->logInFileCheck->isChecked();
1973 h_data.myRemoveLogOnSuccess = myAdvWidget->removeLogOnSuccessCheck->isChecked();
1975 // Enforced vertices
1976 h_data.myEnforcedVertices.clear();
1977 QVariant valueX, valueY, valueZ;
1978 for (int row=0 ; row<myEnforcedTableWidget->rowCount() ; row++) {
1980 TEnfVertex *myVertex = new TEnfVertex();
1981 myVertex->name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString();
1982 MESSAGE("Add new enforced vertex \"" << myVertex->name << "\"" );
1983 myVertex->geomEntry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString();
1984 if (myVertex->geomEntry.size())
1985 MESSAGE("Geom entry is \"" << myVertex->geomEntry << "\"" );
1986 myVertex->groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
1987 if (myVertex->groupName.size())
1988 MESSAGE("Group name is \"" << myVertex->groupName << "\"" );
1989 valueX = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data(Qt::EditRole);
1990 valueY = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data(Qt::EditRole);
1991 valueZ = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data(Qt::EditRole);
1992 if (!valueX.isNull() && !valueY.isNull() && !valueZ.isNull()) {
1993 myVertex->coords.push_back(valueX.toDouble());
1994 myVertex->coords.push_back(valueY.toDouble());
1995 myVertex->coords.push_back(valueZ.toDouble());
1996 MESSAGE("Coords are (" << myVertex->coords.at(0) << ", "
1997 << myVertex->coords.at(1) << ", "
1998 << myVertex->coords.at(2) << ")");
2000 myVertex->size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data(Qt::EditRole).toDouble();
2001 MESSAGE("Size is " << myVertex->size);
2002 myVertex->isCompound = myEnforcedTableWidget->item(row,ENF_VER_COMPOUND_COLUMN)->data(Qt::CheckStateRole).toBool();
2003 MESSAGE("Is compound ? " << myVertex->isCompound);
2004 h_data.myEnforcedVertices.insert(myVertex);
2008 h_data.myEnforcedMeshes.clear();
2010 for (int row=0 ; row<myEnforcedMeshTableWidget->rowCount() ; row++) {
2012 TEnfMesh *myEnfMesh = new TEnfMesh();
2013 myEnfMesh->name = myEnforcedMeshTableWidget->item(row,ENF_MESH_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString();
2014 MESSAGE("Add new enforced mesh \"" << myEnfMesh->name << "\"" );
2015 myEnfMesh->entry = myEnforcedMeshTableWidget->item(row,ENF_MESH_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString();
2016 MESSAGE("Entry is \"" << myEnfMesh->entry << "\"" );
2017 myEnfMesh->groupName = myEnforcedMeshTableWidget->item(row,ENF_MESH_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
2018 MESSAGE("Group name is \"" << myEnfMesh->groupName << "\"" );
2019 QComboBox* combo = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row,ENF_MESH_CONSTRAINT_COLUMN));
2020 myEnfMesh->elementType = combo->currentIndex();
2021 MESSAGE("Element type: " << myEnfMesh->elementType);
2022 h_data.myEnforcedMeshes.insert(myEnfMesh);
2023 std::cout << "h_data.myEnforcedMeshes.size(): " << h_data.myEnforcedMeshes.size() << std::endl;
2029 QString HYBRIDPluginGUI_HypothesisCreator::caption() const
2031 return tr( "HYBRID_TITLE" );
2034 QPixmap HYBRIDPluginGUI_HypothesisCreator::icon() const
2036 return SUIT_Session::session()->resourceMgr()->loadPixmap( "HYBRIDPlugin", tr( "ICON_DLG_HYBRID_PARAMETERS" ) );
2039 QString HYBRIDPluginGUI_HypothesisCreator::type() const
2041 return tr( "HYBRID_HYPOTHESIS" );
2044 QString HYBRIDPluginGUI_HypothesisCreator::helpPage() const
2046 return "hybrid_hypo_page.html";