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 QGridLayout* anEnfMeshLayout = new QGridLayout(myEnfMeshGroup);
612 myEnforcedMeshTableWidget = new QTableWidget(myEnfGroup);
613 myEnforcedMeshTableWidget->setRowCount( 0 );
614 myEnforcedMeshTableWidget->setColumnCount( ENF_MESH_NB_COLUMNS );
615 myEnforcedMeshTableWidget->setSortingEnabled(true);
616 myEnforcedMeshTableWidget->verticalHeader()->hide();
617 QStringList enforcedMeshHeaders;
618 enforcedMeshHeaders << tr( "HYBRID_ENF_NAME_COLUMN" )
619 << tr( "HYBRID_ENF_ENTRY_COLUMN" )
620 << tr( "HYBRID_ENF_MESH_CONSTRAINT_COLUMN" )
621 << tr( "HYBRID_ENF_GROUP_COLUMN" );
622 myEnforcedMeshTableWidget->setHorizontalHeaderLabels(enforcedMeshHeaders);
623 myEnforcedMeshTableWidget->horizontalHeader()->setStretchLastSection(true);
624 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
625 myEnforcedMeshTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
627 myEnforcedMeshTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
629 myEnforcedMeshTableWidget->setAlternatingRowColors(true);
630 myEnforcedMeshTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
631 myEnforcedMeshTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
632 myEnforcedMeshTableWidget->resizeColumnsToContents();
633 myEnforcedMeshTableWidget->hideColumn(ENF_MESH_ENTRY_COLUMN);
635 myEnforcedMeshTableWidget->setItemDelegate(new EnforcedMeshTableWidgetDelegate());
637 // myEnfMesh = SMESH::SMESH_Mesh::_nil();
638 // myEnfMeshArray = new SMESH::mesh_array();
640 myEnfMeshWdg = new StdMeshersGUI_ObjectReferenceParamWdg( SMESH::IDSOURCE, myEnfMeshGroup, /*multiSel=*/true);
641 myEnfMeshWdg->SetDefaultText(tr("HYBRID_ENF_SELECT_MESH"), "QLineEdit { color: grey }");
643 myEnfMeshWdg->AvoidSimultaneousSelection(myEnfVertexWdg);
644 ////myEnfMeshWdg->hide(); //may be used later
646 QLabel* myMeshConstraintLabel = new QLabel( tr( "HYBRID_ENF_MESH_CONSTRAINT_LABEL" ), myEnfMeshGroup );
647 myEnfMeshConstraint = new QComboBox(myEnfMeshGroup);
648 myEnfMeshConstraint->insertItems(0,myEnfMeshConstraintLabels);
649 myEnfMeshConstraint->setEditable(false);
650 myEnfMeshConstraint->setCurrentIndex(2); //EZ: use mesh group of faces for a layer
651 myMeshConstraintLabel->hide(); //may be used later
652 myEnfMeshConstraint->hide(); //may be used later
654 QLabel* myMeshGroupNameLabel = new QLabel( tr( "HYBRID_ENF_GROUP_LABEL" ), myEnfMeshGroup );
655 myMeshGroupName = new QLineEdit(myEnfMeshGroup);
656 myMeshGroupNameLabel->hide(); //may be used later
657 myMeshGroupName->hide(); //may be used later
659 addEnfMeshButton = new QPushButton(tr("HYBRID_ENF_ADD"),myEnfMeshGroup);
660 // addEnfMeshButton->setEnabled(false);
661 removeEnfMeshButton = new QPushButton(tr("HYBRID_ENF_REMOVE"),myEnfMeshGroup);
663 // QGroupBox* GroupBox2 = new QGroupBox( myEnfMeshGroup );
664 // QLabel* info2 = new QLabel( GroupBox2 );
665 // info2->setText( tr( "HYBRID_ENF_MESH_INFO" ) );
666 // info2->setWordWrap( true );
667 // QVBoxLayout* GroupBox2VLayout = new QVBoxLayout( GroupBox2 );
668 // GroupBox2VLayout->setSpacing( 6 );
669 // GroupBox2VLayout->setMargin( 11 );
670 // GroupBox2VLayout->addWidget( info2 );
672 // anEnfMeshLayout->addWidget( GroupBox2, ENF_MESH_WARNING, 0, 1, 2 );
673 //anEnfMeshLayout->addWidget(myLayersOnAllWrapCheck, ENF_MESH_MESH, 0, 1 , 1);
674 anEnfMeshLayout->addWidget(myEnforcedMeshTableWidget, ENF_MESH_MESH, 0, ENF_MESH_NB_LINES , 1);
676 QGridLayout* anEnfMeshLayout2 = new QGridLayout(myEnfMeshGroup);
677 anEnfMeshLayout2->addWidget(myEnfMeshWdg, ENF_MESH_MESH, 0, 1, 2);
678 //TODO remove or not be lateful to select layers...
679 //anEnfMeshLayout2->addWidget(myMeshConstraintLabel, ENF_MESH_CONSTRAINT, 0, 1, 1);
680 //anEnfMeshLayout2->addWidget(myEnfMeshConstraint, ENF_MESH_CONSTRAINT, 1, 1, 1);
681 //anEnfMeshLayout2->addWidget(myMeshGroupNameLabel, ENF_MESH_GROUP, 0, 1, 1);
682 //anEnfMeshLayout2->addWidget(myMeshGroupName, ENF_MESH_GROUP, 1, 1, 1);
683 anEnfMeshLayout2->addWidget(addEnfMeshButton, ENF_MESH_BTN, 0, 1, 1);
684 anEnfMeshLayout2->addWidget(removeEnfMeshButton, ENF_MESH_BTN, 1, 1, 1);
685 anEnfMeshLayout2->setRowStretch(ENF_MESH_NB_LINES, 1);
687 anEnfMeshLayout->addLayout(anEnfMeshLayout2, ENF_MESH_MESH, 1, ENF_MESH_NB_LINES, 1);
688 anEnfMeshLayout->setRowStretch(ENF_MESH_MESH, 10);
691 // selection of faces for layers
693 QWidget* faceSelLayersGroup = new QWidget( dlg() );
694 myLayersOnAllWrapCheck = new QCheckBox( tr( "HYBRID_LAYERS_ON_ALL_WRAP" ), faceSelLayersGroup );
695 QGridLayout* faceSelLayersLayout = new QGridLayout( faceSelLayersGroup );
696 faceSelLayersLayout->addWidget(myLayersOnAllWrapCheck, 0, 0 );
698 myFacesLbl = new QLabel( tr("HYBRID_FACE_IDS"), faceSelLayersGroup );
699 faceSelLayersLayout->addWidget( myFacesLbl, 1, 0 );
701 myFaceSelectorLayers = new StdMeshersGUI_SubShapeSelectorWdg( faceSelLayersGroup, TopAbs_FACE, true, true );
702 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
703 QString aSubEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
704 myFaceSelectorLayers->SetGeomShapeEntry( aSubEntry, aMainEntry );
705 faceSelLayersLayout->addWidget( myFaceSelectorLayers, 2, 0);
706 faceSelLayersLayout->setRowStretch( 2, 10);
708 // selection of faces for imprinting
710 QWidget* faceSelImprintingGroup = new QWidget( dlg() );
711 QGridLayout* faceSelImprintingLayout = new QGridLayout( faceSelImprintingGroup );
713 QLabel* facesLblImprinting = new QLabel( tr("HYBRID_FACE_IDS"), faceSelImprintingGroup );
714 faceSelImprintingLayout->addWidget( facesLblImprinting, 0, 0 );
716 myFaceSelectorImprinting = new StdMeshersGUI_SubShapeSelectorWdg( faceSelImprintingGroup, TopAbs_FACE, true, true );
717 myFaceSelectorImprinting->SetGeomShapeEntry( aSubEntry, aMainEntry );
718 faceSelImprintingLayout->addWidget( myFaceSelectorImprinting, 1, 0, 2, 2 );
719 faceSelImprintingLayout->setRowStretch( 1, 10);
722 tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
723 tab->insertTab( ADV_TAB, myAdvGroup, tr( "HYBRID_ADV_ARGS" ) );
724 if ( aMainEntry.isEmpty() && aSubEntry.isEmpty() ) // mesh not based of geometry
725 faceSelLayersGroup->hide();
727 tab->insertTab( FACE_SEL_LAYERS_TAB, faceSelLayersGroup, tr( "HYBRID_FACES_LAYERS_TAB" ));
728 tab->insertTab( FACE_SEL_IMPRINTING_TAB, faceSelImprintingGroup, tr( "HYBRID_FACES_IMPRINTING_TAB" ));
730 tab->insertTab( ENF_MESH_TAB, myEnfMeshGroup, tr( "HYBRID_ENFORCED_MESHES" ) );
731 tab->setCurrentIndex( STD_TAB );
734 connect( tab, SIGNAL( currentChanged ( int )), this, SLOT( onTabChanged( int ) ) );
735 //connect( myLayersOnAllWrapCheck, SIGNAL( toggled( bool ) ), this, SLOT( onLayersOnAllWrap(bool)));
736 connect( myLayersOnAllWrapCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
737 //connect( myToMeshHolesCheck, SIGNAL( toggled( bool ) ), this, SLOT( onToMeshHoles(bool)));
738 //connect( myAdvWidget->maxMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
739 //connect( myAdvWidget->initialMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
740 //connect( myAdvWidget->boundaryRecoveryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
742 //connect( myBoundaryLayersGrowthCombo, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
743 //connect( myElementGenerationCombo, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
744 connect( myAddMultinormalsCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
745 connect( mySmoothNormalsCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
747 connect( myAdvWidget->logInFileCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
748 connect( myAdvWidget->keepWorkingFilesCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
749 connect( myAdvWidget->workingDirectoryPushButton, SIGNAL( clicked() ), this, SLOT( onDirBtnClicked() ) );
751 connect( myEnforcedTableWidget, SIGNAL( itemClicked(QTableWidgetItem *)), this, SLOT( synchronizeCoords() ) );
752 connect( myEnforcedTableWidget, SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
753 connect( myEnforcedTableWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
754 connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertex() ) );
755 connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
756 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
757 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
758 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
759 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
760 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
761 connect( mySizeValue, SIGNAL( textChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) );
762 connect( myXCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
763 connect( myYCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
764 connect( myZCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
765 connect( mySizeValue, SIGNAL( valueChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) );
766 connect( this, SIGNAL( vertexDefined(bool) ), addVertexButton, SLOT( setEnabled(bool) ) );
768 connect( addEnfMeshButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedMesh() ) );
769 connect( removeEnfMeshButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedMesh() ) );
770 // connect( myEnfMeshWdg, SIGNAL( contentModified()), this, SLOT( checkEnfMeshIsDefined() ) );
771 // connect( myEnfMeshConstraint, SIGNAL( currentIndexChanged(int) ), this, SLOT( checkEnfMeshIsDefined() ) );
772 // connect( this, SIGNAL( enfMeshDefined(bool) ), addEnfMeshButton, SLOT( setEnabled(bool) ) );
778 * This method checks if an enforced vertex is defined;
780 void HYBRIDPluginGUI_HypothesisCreator::clearEnfVertexSelection()
782 if (myEnfVertexWdg->NbObjects() != 0) {
783 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
784 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
785 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
786 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
787 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
789 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
790 that->checkVertexIsDefined();
794 * This method checks if an enforced vertex is defined;
796 void HYBRIDPluginGUI_HypothesisCreator::checkVertexIsDefined()
798 bool enfVertexIsDefined = false;
799 enfVertexIsDefined = (!mySizeValue->GetString().isEmpty() &&
800 (!myEnfVertexWdg->NbObjects() == 0 ||
801 (myEnfVertexWdg->NbObjects() == 0 && !myXCoord->GetString().isEmpty()
802 && !myYCoord->GetString().isEmpty()
803 && !myZCoord->GetString().isEmpty())));
804 emit vertexDefined(enfVertexIsDefined);
808 * This method checks if an enforced mesh is defined;
810 void HYBRIDPluginGUI_HypothesisCreator::checkEnfMeshIsDefined()
812 emit enfMeshDefined( myEnfVertexWdg->NbObjects() != 0);
816 * This method resets the content of the X, Y, Z, size and GroupName widgets;
818 void HYBRIDPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
820 myXCoord->setCleared(true);
821 myYCoord->setCleared(true);
822 myZCoord->setCleared(true);
823 // mySizeValue->setCleared(true);
824 myXCoord->setText("");
825 myYCoord->setText("");
826 myZCoord->setText("");
827 // mySizeValue->setText("");
828 // myGroupName->setText("");
829 addVertexButton->setEnabled(false);
832 /** HYBRIDPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item)
833 This method updates the tooltip of a modified item. The QLineEdit widgets content
834 is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
836 void HYBRIDPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTableWidgetItem* item) {
837 int row = myEnforcedTableWidget->row(item);
839 QVariant vertexName = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole);
840 QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole);
841 QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole);
842 QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole);
843 QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole);
844 QVariant entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
845 QString groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole).toString();
847 clearEnforcedVertexWidgets();
849 if ( !x.isNull() || !entry.isNull()) {
850 QString toolTip = vertexName.toString();
851 toolTip += QString("(");
852 if (entry.isNull() || (!entry.isNull() && entry.toString() == "")) {
853 toolTip += x.toString();
854 toolTip += QString(", ") + y.toString();
855 toolTip += QString(", ") + z.toString();
858 toolTip += entry.toString();
859 toolTip += QString(")");
862 toolTip += QString("=") + size.toString();
864 if (!groupName.isEmpty())
865 toolTip += QString(" [") + groupName + QString("]");
867 for (int col=0;col<ENF_VER_NB_COLUMNS;col++)
868 myEnforcedTableWidget->item(row,col)->setToolTip(toolTip);
871 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
872 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
873 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
874 myXCoord->SetValue(x.toDouble());
875 myYCoord->SetValue(y.toDouble());
876 myZCoord->SetValue(z.toDouble());
877 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
878 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
879 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
882 mySizeValue->SetValue(size.toDouble());
884 if (!groupName.isEmpty())
885 myGroupName->setText(groupName);
889 void HYBRIDPluginGUI_HypothesisCreator::onSelectEnforcedVertex() {
890 int nbSelEnfVertex = myEnfVertexWdg->NbObjects();
891 clearEnforcedVertexWidgets();
892 if (nbSelEnfVertex == 1)
894 if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() )
897 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
898 if (myEnfVertex == GEOM::GEOM_Object::_nil())
900 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
901 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
902 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
903 if (CORBA::is_nil(measureOp))
907 measureOp->PointCoordinates (myEnfVertex, x, y, z);
908 if ( measureOp->IsDone() )
910 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
911 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
912 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
913 myXCoord->SetValue(x);
914 myYCoord->SetValue(y);
915 myZCoord->SetValue(z);
916 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
917 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
918 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
924 /** HYBRIDPluginGUI_HypothesisCreator::synchronizeCoords()
925 This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
926 of the enforced vertex clicked in the tree widget.
928 void HYBRIDPluginGUI_HypothesisCreator::synchronizeCoords() {
929 clearEnforcedVertexWidgets();
930 QList<QTableWidgetItem *> items = myEnforcedTableWidget->selectedItems();
931 // myEnfVertexWdg->disconnect(SIGNAL(contentModified()));
932 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
933 if (! items.isEmpty()) {
934 QTableWidgetItem *item;
937 if (items.size() == 1) {
939 row = myEnforcedTableWidget->row(item);
940 QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole);
941 QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole);
942 QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole);
943 QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole);
944 entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
945 if (!entry.isNull()) {
946 SMESH::string_array_var objIds = new SMESH::string_array;
948 objIds[0] = entry.toString().toStdString().c_str();
949 myEnfVertexWdg->SetObjects(objIds);
952 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
954 QVariant group = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole);
955 if (!x.isNull()/* && entry.isNull()*/) {
956 // disconnect( myXCoord, SIGNAL( textChanged(const QString &)), this, SLOT( onSelectEnforcedVertex() ) );
957 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
958 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
959 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
960 myXCoord->SetValue(x.toDouble());
961 myYCoord->SetValue(y.toDouble());
962 myZCoord->SetValue(z.toDouble());
963 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
964 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
965 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
968 mySizeValue->SetValue(size.toDouble());
970 if (!group.isNull() && (!x.isNull() || !entry.isNull()))
971 myGroupName->setText(group.toString());
974 QList<QString> entryList;
975 for (int i = 0; i < items.size(); ++i) {
977 row = myEnforcedTableWidget->row(item);
978 entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
980 entryList << entry.toString();
982 if (entryList.size() > 0) {
983 SMESH::string_array_var objIds = new SMESH::string_array;
984 objIds->length(entryList.size());
985 for (int i = 0; i < entryList.size() ; i++)
986 objIds[i] = entryList.at(i).toStdString().c_str();
987 myEnfVertexWdg->SetObjects(objIds);
990 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
995 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
997 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
998 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
999 that->checkVertexIsDefined();
1002 /** HYBRIDPluginGUI_HypothesisCreator::addEnforcedMesh( meshName, geomEntry, elemType, size, groupName)
1003 This method adds in the tree widget an enforced mesh from mesh, submesh or group with optionally size and and groupName.
1005 void HYBRIDPluginGUI_HypothesisCreator::addEnforcedMesh(std::string name, std::string entry, int elementType, std::string groupName)
1007 bool okToCreate = true;
1008 QString itemEntry = "";
1009 int itemElementType = 0;
1010 int rowCount = myEnforcedMeshTableWidget->rowCount();
1011 bool allColumns = true;
1012 for (int row = 0;row<rowCount;row++) {
1013 for (int col = 0 ; col < ENF_MESH_NB_COLUMNS ; col++) {
1014 if (col == ENF_MESH_CONSTRAINT_COLUMN){
1015 if (qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row, col)) == 0) {
1020 else if (myEnforcedMeshTableWidget->item(row, col) == 0) {
1024 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1025 QComboBox* itemComboBox = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row, col));
1026 itemElementType = itemComboBox->currentIndex();
1028 else if (col == ENF_MESH_ENTRY_COLUMN)
1029 itemEntry = myEnforcedMeshTableWidget->item(row, col)->data(Qt::EditRole).toString();
1035 if (itemEntry == QString(entry.c_str()) && itemElementType == elementType) {
1036 // // update group name
1037 // if (itemGroupName.toStdString() != groupName) {
1038 // myEnforcedMeshTableWidget->item(row, ENF_MESH_GROUP_COLUMN)->setData( Qt::EditRole, QVariant(groupName.c_str()));
1050 myEnforcedMeshTableWidget->setRowCount(rowCount+1);
1051 myEnforcedMeshTableWidget->setSortingEnabled(false);
1053 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++) {
1054 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1055 QComboBox* comboBox = new QComboBox();
1056 QPalette pal = comboBox->palette();
1057 pal.setColor(QPalette::Button, Qt::white);
1058 comboBox->setPalette(pal);
1059 comboBox->insertItems(0,myEnfMeshConstraintLabels);
1060 comboBox->setEditable(false);
1061 comboBox->setCurrentIndex(elementType);
1062 myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox);
1065 QTableWidgetItem* item = new QTableWidgetItem();
1066 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1068 case ENF_MESH_NAME_COLUMN:
1069 item->setData( 0, name.c_str() );
1070 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1071 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1073 case ENF_MESH_ENTRY_COLUMN:
1074 item->setData( 0, entry.c_str() );
1075 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1076 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1078 case ENF_MESH_GROUP_COLUMN:
1079 item->setData( 0, groupName.c_str() );
1080 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1088 // connect( myEnforcedMeshTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1090 myEnforcedMeshTableWidget->setSortingEnabled(true);
1091 // myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1092 // updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1096 /** HYBRIDPluginGUI_HypothesisCreator::addEnforcedVertex( x, y, z, size, vertexName, geomEntry, groupName)
1097 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.
1099 void HYBRIDPluginGUI_HypothesisCreator::addEnforcedVertex(double x, double y, double z, double size, std::string vertexName, std::string geomEntry, std::string groupName, bool isCompound)
1101 myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1102 bool okToCreate = true;
1103 double itemX,itemY,itemZ,itemSize = 0;
1104 QString itemEntry, itemGroupName = QString("");
1105 // bool itemIsCompound;
1106 int rowCount = myEnforcedTableWidget->rowCount();
1109 for (int row = 0;row<rowCount;row++) {
1111 for (int col = 0 ; col < ENF_VER_NB_COLUMNS ; col++) {
1112 if (myEnforcedTableWidget->item(row, col) == 0) {
1117 data = myEnforcedTableWidget->item(row, col)->data(Qt::EditRole);
1118 if (!data.isNull()) {
1120 case ENF_VER_GROUP_COLUMN:
1121 itemGroupName = data.toString();
1123 case ENF_VER_ENTRY_COLUMN:
1124 itemEntry = data.toString();
1126 // case ENF_VER_COMPOUND_COLUMN:
1127 // itemIsCompound = data.toBool();
1129 case ENF_VER_X_COLUMN:
1130 itemX = data.toDouble();
1132 case ENF_VER_Y_COLUMN:
1133 itemY = data.toDouble();
1135 case ENF_VER_Z_COLUMN:
1136 itemZ = data.toDouble();
1138 case ENF_VER_SIZE_COLUMN:
1139 itemSize = data.toDouble();
1151 if (( !isCompound && ((itemX == x) && (itemY == y) && (itemZ == z))) || /*( (itemEntry.toStdString() != "") && */ (itemEntry.toStdString() == geomEntry)/*)*/) {
1153 if (itemSize != size) {
1154 myEnforcedTableWidget->item(row, ENF_VER_SIZE_COLUMN)->setData( Qt::EditRole, QVariant(size));
1156 // update group name
1157 if (itemGroupName.toStdString() != groupName) {
1158 myEnforcedTableWidget->item(row, ENF_VER_GROUP_COLUMN)->setData( Qt::EditRole, QVariant(groupName.c_str()));
1165 if (geomEntry.empty()) {
1172 if (geomEntry.empty()) {
1179 QString myVertexName;
1180 while(indexRef != vertexIndex) {
1181 indexRef = vertexIndex;
1182 if (vertexName.empty())
1183 myVertexName = QString("Vertex #%1").arg(vertexIndex);
1185 myVertexName = QString(vertexName.c_str());
1187 for (int row = 0;row<rowCount;row++) {
1188 QString name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString();
1189 if (myVertexName == name) {
1196 myEnforcedTableWidget->setRowCount(rowCount+1);
1197 myEnforcedTableWidget->setSortingEnabled(false);
1198 for (int col=0;col<ENF_VER_NB_COLUMNS;col++) {
1199 QTableWidgetItem* item = new QTableWidgetItem();
1200 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1202 case ENF_VER_NAME_COLUMN:
1203 item->setData( Qt::EditRole, myVertexName );
1204 if (!geomEntry.empty()) {
1206 item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1208 item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1211 case ENF_VER_X_COLUMN:
1213 item->setData( 0, QVariant(x) );
1215 case ENF_VER_Y_COLUMN:
1217 item->setData( 0, QVariant(y) );
1219 case ENF_VER_Z_COLUMN:
1221 item->setData( 0, QVariant(z) );
1223 case ENF_VER_SIZE_COLUMN:
1224 item->setData( 0, QVariant(size) );
1226 case ENF_VER_ENTRY_COLUMN:
1227 if (!geomEntry.empty())
1228 item->setData( 0, QString(geomEntry.c_str()) );
1230 case ENF_VER_COMPOUND_COLUMN:
1231 item->setData( Qt::CheckStateRole, isCompound );
1232 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
1234 case ENF_VER_GROUP_COLUMN:
1235 if (!groupName.empty())
1236 item->setData( 0, QString(groupName.c_str()) );
1242 myEnforcedTableWidget->setItem(rowCount,col,item);
1245 connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1247 myEnforcedTableWidget->setSortingEnabled(true);
1248 // myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1249 updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1252 /** HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedMesh()
1253 This method is called when a item is added into the enforced meshes tree widget
1255 void HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedMesh()
1258 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1260 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1261 myEnfMeshWdg->deactivateSelection();
1263 for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column)
1264 myEnforcedMeshTableWidget->resizeColumnToContents(column);
1267 int selEnfMeshes = myEnfMeshWdg->NbObjects();
1268 if (selEnfMeshes == 0)
1271 std::string groupName = myMeshGroupName->text().toStdString();
1272 // if (myGlobalGroupName->isChecked())
1273 // groupName = myGlobalGroupName->text().toStdString();
1275 if (boost::trim_copy(groupName).empty())
1276 groupName = "LayersGroup"; //have to be not empty until non used
1278 int elementType = myEnfMeshConstraint->currentIndex();
1281 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1282 _PTR(SObject) aSObj; //SMESH::SMESH_IDSource::_nil;
1283 QString meshEntry = myEnfMeshWdg->GetValue();
1285 if (selEnfMeshes == 1)
1287 // myEnfMesh = myEnfMeshWdg->GetObject< SMESH::SMESH_IDSource >();
1288 // std::string entry = myEnfMeshWdg->GetValue();
1289 aSObj = aStudy->FindObjectID(meshEntry.toStdString().c_str());
1290 CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy);
1291 if (!CORBA::is_nil(anObj)) {
1292 // SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1293 addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
1298 QStringList meshEntries = meshEntry.split(" ", QString::SkipEmptyParts);
1299 QStringListIterator meshEntriesIt (meshEntries);
1300 while (meshEntriesIt.hasNext()) {
1301 aSObj = aStudy->FindObjectID(meshEntriesIt.next().toStdString().c_str());
1302 CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy);
1303 if (!CORBA::is_nil(anObj)) {
1304 // SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1305 addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
1310 myEnfVertexWdg->SetObject(SMESH::SMESH_IDSource::_nil());
1312 for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column)
1313 myEnforcedMeshTableWidget->resizeColumnToContents(column);
1317 /** HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedVertex()
1318 This method is called when a item is added into the enforced vertices tree widget
1320 void HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedVertex()
1323 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1325 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1326 myEnfVertexWdg->deactivateSelection();
1328 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1329 myEnforcedTableWidget->resizeColumnToContents(column);
1332 int selEnfVertex = myEnfVertexWdg->NbObjects();
1333 bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty());
1334 if ((selEnfVertex == 0) && coordsEmpty)
1337 std::string groupName = myGroupName->text().toStdString();
1338 // if (myGlobalGroupName->isChecked())
1339 // groupName = myGlobalGroupName->text().toStdString();
1341 if (boost::trim_copy(groupName).empty())
1344 double size = mySizeValue->GetValue();
1346 if (selEnfVertex <= 1)
1348 double x = 0, y = 0, z=0;
1349 if (myXCoord->GetString() != "") {
1350 x = myXCoord->GetValue();
1351 y = myYCoord->GetValue();
1352 z = myZCoord->GetValue();
1354 if (selEnfVertex == 1) {
1355 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >();
1356 std::string entry = "";
1357 if (myEnfVertex != GEOM::GEOM_Object::_nil())
1358 entry = myEnfVertex->GetStudyEntry();
1359 addEnforcedVertex(x, y, z, size, myEnfVertex->GetName(),entry, groupName, myEnfVertex->GetShapeType() == GEOM::COMPOUND);
1362 addEnforcedVertex(x, y, z, size, "", "", groupName);
1367 if ( CORBA::is_nil(getGeomEngine()))
1370 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
1371 if (CORBA::is_nil(measureOp))
1374 CORBA::Double x = 0, y = 0,z = 0;
1375 for (int j = 0 ; j < selEnfVertex ; j++)
1377 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j);
1378 if (myEnfVertex == GEOM::GEOM_Object::_nil())
1380 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1381 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1382 if ( measureOp->IsDone() )
1383 addEnforcedVertex(x, y, z, size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1384 } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) {
1385 addEnforcedVertex(0., 0., 0., size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName, true);
1390 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1392 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1393 myEnforcedTableWidget->resizeColumnToContents(column);
1396 /** HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedMesh()
1397 This method is called when a item is removed from the enforced meshes tree widget
1399 void HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedMesh()
1401 QList<int> selectedRows;
1402 QList<QTableWidgetItem *> selectedItems = myEnforcedMeshTableWidget->selectedItems();
1403 QTableWidgetItem* item;
1405 foreach( item, selectedItems ) {
1407 if (!selectedRows.contains( row ) )
1408 selectedRows.append(row);
1411 qSort( selectedRows );
1412 QListIterator<int> it( selectedRows );
1414 while ( it.hasPrevious() ) {
1415 row = it.previous();
1416 myEnforcedMeshTableWidget->removeRow(row );
1419 myEnforcedMeshTableWidget->selectionModel()->clearSelection();
1422 /** HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1423 This method is called when a item is removed from the enforced vertices tree widget
1425 void HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1427 QList<int> selectedRows;
1428 QList<QTableWidgetItem *> selectedItems = myEnforcedTableWidget->selectedItems();
1429 QTableWidgetItem* item;
1431 foreach( item, selectedItems ) {
1433 if (!selectedRows.contains( row ) )
1434 selectedRows.append(row);
1437 qSort( selectedRows );
1438 QListIterator<int> it( selectedRows );
1440 while ( it.hasPrevious() ) {
1441 row = it.previous();
1442 myEnforcedTableWidget->removeRow(row );
1445 myEnforcedTableWidget->selectionModel()->clearSelection();
1448 void HYBRIDPluginGUI_HypothesisCreator::onLayersOnAllWrap(bool isOn)
1450 // myToMakeGroupsOfDomains->setEnabled( isOn );
1452 // myToMakeGroupsOfDomains->setChecked( false );
1455 void HYBRIDPluginGUI_HypothesisCreator::onToMeshHoles(bool isOn)
1457 // myToMakeGroupsOfDomains->setEnabled( isOn );
1459 // myToMakeGroupsOfDomains->setChecked( false );
1462 void HYBRIDPluginGUI_HypothesisCreator::onDirBtnClicked()
1464 QString dir = SUIT_FileDlg::getExistingDirectory( dlg(), myAdvWidget->workingDirectoryLineEdit->text(), QString() );
1465 if ( !dir.isEmpty() )
1466 myAdvWidget->workingDirectoryLineEdit->setText( dir );
1469 void HYBRIDPluginGUI_HypothesisCreator::onTabChanged( int )
1471 myEnfVertexWdg->deactivateSelection();
1472 myEnfMeshWdg->deactivateSelection();
1473 myFaceSelectorLayers->ActivateSelection( false );
1474 myFaceSelectorLayers->ShowPreview( false );
1475 myFaceSelectorImprinting->ActivateSelection( false );
1476 myFaceSelectorImprinting->ShowPreview( false );
1479 void HYBRIDPluginGUI_HypothesisCreator::updateWidgets()
1481 //customs automatic set
1482 //myToMakeGroupsOfDomains->setEnabled( myToMeshHolesCheck->isChecked() );
1483 //myAdvWidget->maxMemorySpin->setEnabled( myAdvWidget->maxMemoryCheck->isChecked() );
1484 //myAdvWidget->initialMemoryCheck->setEnabled( !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1485 //myAdvWidget->initialMemorySpin->setEnabled( myAdvWidget->initialMemoryCheck->isChecked() && !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1486 //myOptimizationLevelCombo->setEnabled( !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1487 myMultinormalsAngleSpin->setEnabled( myAddMultinormalsCheck->isChecked() );
1488 if ( sender() == myAdvWidget->logInFileCheck ||
1489 sender() == myAdvWidget->keepWorkingFilesCheck )
1491 bool logFileRemovable = myAdvWidget->logInFileCheck->isChecked() &&
1492 !myAdvWidget->keepWorkingFilesCheck->isChecked();
1494 myAdvWidget->removeLogOnSuccessCheck->setEnabled( logFileRemovable );
1496 bool enabled = !myLayersOnAllWrapCheck->isChecked();
1497 myFacesLbl->setEnabled(enabled);
1498 myFaceSelectorLayers->setEnabled(enabled);
1499 if ( QTabWidget* tab = qobject_cast<QTabWidget*>( myStdGroup->parentWidget()->parentWidget() )) {
1500 tab->setTabEnabled( FACE_SEL_IMPRINTING_TAB, enabled );
1504 bool HYBRIDPluginGUI_HypothesisCreator::checkParams(QString& msg) const
1507 if ( !QFileInfo( myAdvWidget->workingDirectoryLineEdit->text().trimmed() ).isWritable() ) {
1508 SUIT_MessageBox::warning( dlg(),
1509 tr( "SMESH_WRN_WARNING" ),
1510 tr( "HYBRID_PERMISSION_DENIED" ) );
1517 void HYBRIDPluginGUI_HypothesisCreator::retrieveParams() const
1519 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1520 HYBRIDHypothesisData data;
1521 readParamsFromHypo( data );
1524 myName->setText( data.myName );
1525 myLayersOnAllWrapCheck ->setChecked ( data.myLayersOnAllWrap );
1526 myToMeshHolesCheck ->setChecked ( data.myToMeshHoles );
1527 myToMakeGroupsOfDomains ->setChecked ( data.myToMakeGroupsOfDomains );
1528 myOptimizationLevelCombo ->setCurrentIndex( data.myOptimizationLevel );
1529 myAdvWidget->maxMemoryCheck ->setChecked ( data.myMaximumMemory > 0 );
1530 myAdvWidget->maxMemorySpin ->setValue ( qMax( data.myMaximumMemory,
1531 myAdvWidget->maxMemorySpin->minimum() ));
1532 myAdvWidget->initialMemoryCheck ->setChecked ( data.myInitialMemory > 0 );
1533 myAdvWidget->initialMemorySpin ->setValue ( qMax( data.myInitialMemory,
1534 myAdvWidget->initialMemorySpin->minimum() ));
1536 myCollisionModeCombo ->setCurrentIndex( data.myCollisionMode );
1537 myBoundaryLayersGrowthCombo ->setCurrentIndex( data.myBoundaryLayersGrowth );
1538 myElementGenerationCombo ->setCurrentIndex( data.myElementGeneration );
1539 myAddMultinormalsCheck -> setChecked ( data.myAddMultinormals );
1540 mySmoothNormalsCheck -> setChecked ( data.mySmoothNormals );
1541 myHeightFirstLayerSpin -> setValue( data.myHeightFirstLayer );
1542 myNbOfBoundaryLayersSpin -> setValue( data.myNbOfBoundaryLayers );
1543 myBoundaryLayersProgressionSpin -> setValue( data.myBoundaryLayersProgression );
1544 if (data.myCoreSize <= 0)
1545 myCoreSizeSpin->setText("");
1547 myCoreSizeSpin -> setValue( data.myCoreSize );
1548 myMultinormalsAngleSpin -> setValue( data.myMultinormalsAngle );
1549 myFaceSelectorLayers ->SetListOfIDs( data.myFaceWLIds );
1550 myFaceSelectorImprinting ->SetListOfIDs( data.myFaceWIIds );
1552 myAdvWidget->workingDirectoryLineEdit ->setText ( data.myWorkingDir );
1553 myAdvWidget->keepWorkingFilesCheck ->setChecked( data.myKeepFiles );
1554 myAdvWidget->verboseLevelSpin ->setValue ( data.myVerboseLevel );
1555 myAdvWidget->createNewNodesCheck ->setChecked( data.myToCreateNewNodes );
1556 myAdvWidget->removeInitialCentralPointCheck ->setChecked( data.myRemoveInitialCentralPoint );
1557 myAdvWidget->boundaryRecoveryCheck ->setChecked( data.myBoundaryRecovery );
1558 myAdvWidget->FEMCorrectionCheck ->setChecked( data.myFEMCorrection );
1559 myAdvWidget->gradationSpinBox ->setValue ( data.myGradation );
1560 myAdvWidget->myAdvOptionsTable ->SetCustomOptions( data.myTextOption );
1561 myAdvWidget->logInFileCheck ->setChecked( !data.myLogInStandardOutput );
1562 myAdvWidget->removeLogOnSuccessCheck ->setChecked( data.myRemoveLogOnSuccess );
1564 TEnfVertexList::const_iterator it;
1566 myEnforcedTableWidget->clearContents();
1567 myEnforcedTableWidget->setSortingEnabled(false);
1568 myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1569 for(it = data.myEnforcedVertices.begin() ; it != data.myEnforcedVertices.end(); it++ )
1571 TEnfVertex* enfVertex = (*it);
1572 myEnforcedTableWidget->setRowCount(rowCount+1);
1574 for (int col=0;col<ENF_VER_NB_COLUMNS;col++) {
1575 QTableWidgetItem* item = new QTableWidgetItem();
1576 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1578 case ENF_VER_NAME_COLUMN:
1579 item->setData( 0, enfVertex->name.c_str() );
1580 if (!enfVertex->geomEntry.empty()) {
1581 if (enfVertex->isCompound)
1582 item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1584 item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1588 case ENF_VER_X_COLUMN:
1589 if (!enfVertex->isCompound) {
1590 item->setData( 0, enfVertex->coords.at(0) );
1593 case ENF_VER_Y_COLUMN:
1594 if (!enfVertex->isCompound) {
1595 item->setData( 0, enfVertex->coords.at(1) );
1598 case ENF_VER_Z_COLUMN:
1599 if (!enfVertex->isCompound) {
1600 item->setData( 0, enfVertex->coords.at(2) );
1603 case ENF_VER_SIZE_COLUMN:
1604 item->setData( 0, enfVertex->size );
1606 case ENF_VER_ENTRY_COLUMN:
1607 item->setData( 0, enfVertex->geomEntry.c_str() );
1609 case ENF_VER_COMPOUND_COLUMN:
1610 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
1611 item->setData( Qt::CheckStateRole, enfVertex->isCompound );
1613 case ENF_VER_GROUP_COLUMN:
1614 item->setData( 0, enfVertex->groupName.c_str() );
1620 myEnforcedTableWidget->setItem(rowCount,col,item);
1622 that->updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1626 connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1627 myEnforcedTableWidget->setSortingEnabled(true);
1629 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1630 myEnforcedTableWidget->resizeColumnToContents(column);
1632 // Update Enforced meshes QTableWidget
1633 TEnfMeshList::const_iterator itMesh;
1635 myEnforcedMeshTableWidget->clearContents();
1636 myEnforcedMeshTableWidget->setSortingEnabled(false);
1637 // myEnforcedMeshTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1638 for(itMesh = data.myEnforcedMeshes.begin() ; itMesh != data.myEnforcedMeshes.end(); itMesh++ )
1640 TEnfMesh* enfMesh = (*itMesh);
1641 myEnforcedMeshTableWidget->setRowCount(rowCount+1);
1643 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++) {
1644 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1645 QComboBox* comboBox = new QComboBox();
1646 QPalette pal = comboBox->palette();
1647 pal.setColor(QPalette::Button, Qt::white);
1648 comboBox->setPalette(pal);
1649 comboBox->insertItems(0,myEnfMeshConstraintLabels);
1650 comboBox->setEditable(false);
1651 comboBox->setCurrentIndex(enfMesh->elementType);
1652 myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox);
1655 QTableWidgetItem* item = new QTableWidgetItem();
1656 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1658 case ENF_MESH_NAME_COLUMN:
1659 item->setData( 0, enfMesh->name.c_str() );
1660 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1661 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1663 case ENF_MESH_ENTRY_COLUMN:
1664 item->setData( 0, enfMesh->entry.c_str() );
1665 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1666 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1668 case ENF_MESH_GROUP_COLUMN:
1669 item->setData( 0, enfMesh->groupName.c_str() );
1670 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1677 // myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1679 // that->updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1683 // connect( myEnforcedMeshTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1684 myEnforcedMeshTableWidget->setSortingEnabled(true);
1686 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++)
1687 myEnforcedMeshTableWidget->resizeColumnToContents(col);
1689 that->updateWidgets();
1690 that->checkVertexIsDefined();
1693 QString HYBRIDPluginGUI_HypothesisCreator::storeParams() const
1695 HYBRIDHypothesisData data;
1696 readParamsFromWidgets( data );
1697 storeParamsToHypo( data );
1699 QString valStr = "";
1701 if ( !data.myBoundaryRecovery )
1702 valStr = "-c " + QString::number( !data.myToMeshHoles );
1704 if ( data.myOptimizationLevel >= 0 && data.myOptimizationLevel < 5 && !data.myBoundaryRecovery) {
1705 const char* level[] = { "none" , "light" , "standard" , "standard+" , "strong" };
1707 valStr += level[ data.myOptimizationLevel ];
1709 if ( data.myMaximumMemory > 0 ) {
1711 valStr += QString::number( data.myMaximumMemory );
1713 if ( data.myInitialMemory > 0 && !data.myBoundaryRecovery ) {
1715 valStr += QString::number( data.myInitialMemory );
1718 valStr += QString::number( data.myVerboseLevel );
1720 if ( !data.myToCreateNewNodes )
1723 if ( data.myRemoveInitialCentralPoint )
1724 valStr += " -no_initial_central_point";
1726 if ( data.myBoundaryRecovery )
1729 if ( data.myFEMCorrection )
1732 if ( data.myGradation != 1.05 ) {
1733 valStr += " -Dcpropa=";
1734 valStr += QString::number( data.myGradation );
1738 valStr += data.myTextOption;
1740 // valStr += " #BEGIN ENFORCED VERTICES#";
1741 // // Add size map parameters storage
1742 // for (int i=0 ; i<mySmpModel->rowCount() ; i++) {
1744 // double x = mySmpModel->data(mySmpModel->index(i,ENF_VER_X_COLUMN)).toDouble();
1745 // double y = mySmpModel->data(mySmpModel->index(i,ENF_VER_Y_COLUMN)).toDouble();
1746 // double z = mySmpModel->data(mySmpModel->index(i,ENF_VER_Z_COLUMN)).toDouble();
1747 // double size = mySmpModel->data(mySmpModel->index(i,ENF_VER_SIZE_COLUMN)).toDouble();
1748 // valStr += QString::number( x );
1750 // valStr += QString::number( y );
1752 // valStr += QString::number( z );
1754 // valStr += QString::number( size );
1755 // if (i!=mySmpModel->rowCount()-1)
1758 // valStr += " #END ENFORCED VERTICES#";
1762 bool HYBRIDPluginGUI_HypothesisCreator::readParamsFromHypo( HYBRIDHypothesisData& h_data ) const
1764 HYBRIDPlugin::HYBRIDPlugin_Hypothesis_var h =
1765 HYBRIDPlugin::HYBRIDPlugin_Hypothesis::_narrow( initParamsHypothesis() );
1767 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
1768 h_data.myName = isCreation() && data ? hypName() : "";
1770 h_data.myCollisionMode = h->GetCollisionMode();
1771 h_data.myBoundaryLayersGrowth = h->GetBoundaryLayersGrowth();
1772 h_data.myElementGeneration = h->GetElementGeneration();
1773 h_data.myAddMultinormals = h->GetAddMultinormals();
1774 h_data.mySmoothNormals = h->GetSmoothNormals();
1775 h_data.myHeightFirstLayer = h->GetHeightFirstLayer();
1776 h_data.myBoundaryLayersProgression = h->GetBoundaryLayersProgression();
1777 h_data.myCoreSize = h->GetCoreSize();
1778 h_data.myMultinormalsAngle = h->GetMultinormalsAngle();
1779 h_data.myNbOfBoundaryLayers = h->GetNbOfBoundaryLayers();
1780 h_data.myFaceWLIds = h->GetFacesWithLayers();
1781 h_data.myFaceWIIds = h->GetFacesWithImprinting();
1783 h_data.myLayersOnAllWrap = h->GetLayersOnAllWrap();
1784 h_data.myToMeshHoles = h->GetToMeshHoles();
1785 h_data.myToMakeGroupsOfDomains = /*h->GetToMeshHoles() &&*/ h->GetToMakeGroupsOfDomains();
1786 h_data.myMaximumMemory = h->GetMaximumMemory();
1787 h_data.myInitialMemory = h->GetInitialMemory();
1788 h_data.myInitialMemory = h->GetInitialMemory();
1789 h_data.myOptimizationLevel = h->GetOptimizationLevel();
1791 h_data.myKeepFiles = h->GetKeepFiles();
1792 h_data.myWorkingDir = h->GetWorkingDirectory();
1793 h_data.myVerboseLevel = h->GetVerboseLevel();
1794 h_data.myToCreateNewNodes = h->GetToCreateNewNodes();
1795 h_data.myRemoveInitialCentralPoint = h->GetToRemoveCentralPoint();
1796 h_data.myBoundaryRecovery = h->GetToUseBoundaryRecoveryVersion();
1797 h_data.myFEMCorrection = h->GetFEMCorrection();
1798 h_data.myGradation = h->GetGradation();
1799 h_data.myTextOption = h->GetAdvancedOption();
1800 h_data.myLogInStandardOutput = h->GetStandardOutputLog();
1801 h_data.myRemoveLogOnSuccess = h->GetRemoveLogOnSuccess();
1803 HYBRIDPlugin::HYBRIDEnforcedVertexList_var vertices = h->GetEnforcedVertices();
1804 h_data.myEnforcedVertices.clear();
1805 for (CORBA::ULong i=0 ; i<vertices->length() ; i++) {
1806 TEnfVertex* myVertex = new TEnfVertex();
1807 myVertex->name = CORBA::string_dup(vertices[i].name.in());
1808 myVertex->geomEntry = CORBA::string_dup(vertices[i].geomEntry.in());
1809 myVertex->groupName = CORBA::string_dup(vertices[i].groupName.in());
1810 myVertex->size = vertices[i].size;
1811 myVertex->isCompound = vertices[i].isCompound;
1812 if (vertices[i].coords.length()) {
1813 for (CORBA::ULong c = 0; c < vertices[i].coords.length() ; c++)
1814 myVertex->coords.push_back(vertices[i].coords[c]);
1816 h_data.myEnforcedVertices.insert(myVertex);
1819 HYBRIDPlugin::HYBRIDEnforcedMeshList_var enfMeshes = h->GetEnforcedMeshes();
1820 h_data.myEnforcedMeshes.clear();
1821 for (CORBA::ULong i=0 ; i<enfMeshes->length() ; i++) {
1822 TEnfMesh* myEnfMesh = new TEnfMesh();
1823 myEnfMesh->name = CORBA::string_dup(enfMeshes[i].name.in());
1824 myEnfMesh->entry = CORBA::string_dup(enfMeshes[i].entry.in());
1825 myEnfMesh->groupName = CORBA::string_dup(enfMeshes[i].groupName.in());
1826 switch (enfMeshes[i].elementType) {
1828 myEnfMesh->elementType = 0;
1831 myEnfMesh->elementType = 1;
1834 myEnfMesh->elementType = 2;
1839 // myEnfMesh->elementType = enfMeshes[i].elementType;
1840 h_data.myEnforcedMeshes.insert(myEnfMesh);
1845 bool HYBRIDPluginGUI_HypothesisCreator::storeParamsToHypo( const HYBRIDHypothesisData& h_data ) const
1847 HYBRIDPlugin::HYBRIDPlugin_Hypothesis_var h =
1848 HYBRIDPlugin::HYBRIDPlugin_Hypothesis::_narrow( hypothesis() );
1854 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
1856 if ( h->GetLayersOnAllWrap() != h_data.myLayersOnAllWrap ) // avoid duplication of DumpPython commands
1857 h->SetLayersOnAllWrap ( h_data.myLayersOnAllWrap );
1858 if ( h->GetToMeshHoles() != h_data.myToMeshHoles ) // avoid duplication of DumpPython commands
1859 h->SetToMeshHoles ( h_data.myToMeshHoles );
1860 if ( h->GetToMakeGroupsOfDomains() != h_data.myToMakeGroupsOfDomains )
1861 h->SetToMakeGroupsOfDomains( h_data.myToMakeGroupsOfDomains );
1862 if ( h->GetMaximumMemory() != h_data.myMaximumMemory )
1863 h->SetMaximumMemory ( h_data.myMaximumMemory );
1864 if ( h->GetInitialMemory() != h_data.myInitialMemory )
1865 h->SetInitialMemory ( h_data.myInitialMemory );
1866 if ( h->GetInitialMemory() != h_data.myInitialMemory )
1867 h->SetInitialMemory ( h_data.myInitialMemory );
1868 if ( h->GetOptimizationLevel() != h_data.myOptimizationLevel )
1869 h->SetOptimizationLevel( h_data.myOptimizationLevel );
1871 if ( h->GetCollisionMode() != h_data.myCollisionMode )
1872 h->SetCollisionMode( h_data.myCollisionMode );
1873 if ( h->GetBoundaryLayersGrowth() != h_data.myBoundaryLayersGrowth )
1874 h->SetBoundaryLayersGrowth( h_data.myBoundaryLayersGrowth );
1875 if ( h->GetElementGeneration() != h_data.myElementGeneration )
1876 h->SetElementGeneration( h_data.myElementGeneration );
1878 if ( h->GetAddMultinormals() != h_data.myAddMultinormals )
1879 h->SetAddMultinormals ( h_data.myAddMultinormals );
1880 if ( h->GetSmoothNormals() != h_data.mySmoothNormals )
1881 h->SetSmoothNormals ( h_data.mySmoothNormals );
1882 if ( h->GetHeightFirstLayer() != h_data.myHeightFirstLayer )
1883 h->SetHeightFirstLayer ( h_data.myHeightFirstLayer );
1884 if ( h->GetBoundaryLayersProgression() != h_data.myBoundaryLayersProgression )
1885 h->SetBoundaryLayersProgression ( h_data.myBoundaryLayersProgression );
1886 if ( h->GetCoreSize() != h_data.myCoreSize )
1887 h->SetCoreSize ( h_data.myCoreSize );
1888 if ( h->GetMultinormalsAngle() != h_data.myMultinormalsAngle )
1889 h->SetMultinormalsAngle ( h_data.myMultinormalsAngle );
1890 if ( h->GetNbOfBoundaryLayers() != h_data.myNbOfBoundaryLayers )
1891 h->SetNbOfBoundaryLayers ( h_data.myNbOfBoundaryLayers );
1892 h->SetFacesWithLayers( h_data.myFaceWLIds );
1893 h->SetFacesWithImprinting( h_data.myFaceWIIds );
1895 if ( h->GetKeepFiles() != h_data.myKeepFiles)
1896 h->SetKeepFiles ( h_data.myKeepFiles);
1897 if ( h->GetWorkingDirectory() != h_data.myWorkingDir )
1898 h->SetWorkingDirectory ( h_data.myWorkingDir.toLatin1().constData() );
1899 if ( h->GetVerboseLevel() != h_data.myVerboseLevel )
1900 h->SetVerboseLevel ( h_data.myVerboseLevel );
1901 if ( h->GetToCreateNewNodes() != h_data.myToCreateNewNodes )
1902 h->SetToCreateNewNodes ( h_data.myToCreateNewNodes );
1903 if ( h->GetToRemoveCentralPoint() != h_data.myRemoveInitialCentralPoint )
1904 h->SetToRemoveCentralPoint ( h_data.myRemoveInitialCentralPoint );
1905 if ( h->GetToUseBoundaryRecoveryVersion() != h_data.myBoundaryRecovery )
1906 h->SetToUseBoundaryRecoveryVersion ( h_data.myBoundaryRecovery );
1907 if ( h->GetFEMCorrection() != h_data.myFEMCorrection )
1908 h->SetFEMCorrection ( h_data.myFEMCorrection );
1909 if ( h->GetGradation() != h_data.myGradation )
1910 h->SetGradation ( h_data.myGradation );
1911 if ( h->GetTextOption() != h_data.myTextOption )
1912 h->SetAdvancedOption ( h_data.myTextOption.toLatin1().constData() );
1913 if ( h->GetStandardOutputLog() != h_data.myLogInStandardOutput )
1914 h->SetStandardOutputLog ( h_data.myLogInStandardOutput );
1915 if ( h->GetRemoveLogOnSuccess() != h_data.myRemoveLogOnSuccess )
1916 h->SetRemoveLogOnSuccess ( h_data.myRemoveLogOnSuccess );
1918 // Enforced vertices
1919 //int nbVertex = (int) h_data.myEnforcedVertices.size();
1920 HYBRIDPlugin::HYBRIDEnforcedVertexList_var vertexHyp = h->GetEnforcedVertices();
1921 int nbVertexHyp = vertexHyp->length();
1924 // 1. Clear all enforced vertices in hypothesis
1925 // 2. Add new enforced vertex according to h_data
1926 if ( nbVertexHyp > 0)
1927 h->ClearEnforcedVertices();
1929 TEnfVertexList::const_iterator it;
1930 double x = 0, y = 0, z = 0;
1931 for(it = h_data.myEnforcedVertices.begin() ; it != h_data.myEnforcedVertices.end(); it++ ) {
1932 TEnfVertex* enfVertex = (*it);
1934 if (enfVertex->coords.size()) {
1935 x = enfVertex->coords.at(0);
1936 y = enfVertex->coords.at(1);
1937 z = enfVertex->coords.at(2);
1939 ok = h->p_SetEnforcedVertex( enfVertex->size, x, y, z, enfVertex->name.c_str(), enfVertex->geomEntry.c_str(), enfVertex->groupName.c_str(), enfVertex->isCompound);
1943 //int nbEnfMeshes = (int) h_data.myEnforcedMeshes.size();
1944 HYBRIDPlugin::HYBRIDEnforcedMeshList_var enfMeshListHyp = h->GetEnforcedMeshes();
1945 int nbEnfMeshListHyp = enfMeshListHyp->length();
1948 // 1. Clear all enforced vertices in hypothesis
1949 // 2. Add new enforced vertex according to h_data
1950 if ( nbEnfMeshListHyp > 0)
1951 h->ClearEnforcedMeshes();
1953 TEnfMeshList::const_iterator itEnfMesh;
1955 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1957 for(itEnfMesh = h_data.myEnforcedMeshes.begin() ; itEnfMesh != h_data.myEnforcedMeshes.end(); itEnfMesh++ ) {
1958 TEnfMesh* enfMesh = (*itEnfMesh);
1960 _PTR(SObject) aSObj = aStudy->FindObjectID(enfMesh->entry.c_str());
1961 SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1963 SMESH::ElementType elementType;
1964 switch(enfMesh->elementType) {
1966 elementType = SMESH::NODE;
1969 elementType = SMESH::EDGE;
1972 elementType = SMESH::FACE;
1978 std::cout << "h->p_SetEnforcedMesh(theSource, "<< elementType <<", \""<< enfMesh->name << "\", \"" << enfMesh->groupName.c_str() <<"\")"<<std::endl;
1979 ok = h->p_SetEnforcedMesh(theSource, elementType, enfMesh->name.c_str(), enfMesh->groupName.c_str());
1982 // catch(const std::exception& ex) {
1983 // std::cout << "Exception: " << ex.what() << std::endl;
1986 catch ( const SALOME::SALOME_Exception& ex )
1988 SalomeApp_Tools::QtCatchCorbaException( ex );
1994 bool HYBRIDPluginGUI_HypothesisCreator::readParamsFromWidgets( HYBRIDHypothesisData& h_data ) const
1996 h_data.myName = myName ? myName->text() : "";
1997 h_data.myLayersOnAllWrap = myLayersOnAllWrapCheck->isChecked();
1998 h_data.myToMeshHoles = myToMeshHolesCheck->isChecked();
1999 h_data.myToMakeGroupsOfDomains = myToMakeGroupsOfDomains->isChecked();
2000 h_data.myMaximumMemory = myAdvWidget->maxMemoryCheck->isChecked() ? myAdvWidget->maxMemorySpin->value() : -1;
2001 h_data.myInitialMemory = myAdvWidget->initialMemoryCheck->isChecked() ? myAdvWidget->initialMemorySpin->value() : -1;
2002 h_data.myOptimizationLevel = myOptimizationLevelCombo->currentIndex();
2004 h_data.myCollisionMode = myCollisionModeCombo->currentIndex();
2005 h_data.myBoundaryLayersGrowth = myBoundaryLayersGrowthCombo->currentIndex();
2006 h_data.myElementGeneration = myElementGenerationCombo->currentIndex();
2007 h_data.myAddMultinormals = myAddMultinormalsCheck->isChecked();
2008 h_data.mySmoothNormals = mySmoothNormalsCheck->isChecked();
2010 h_data.myHeightFirstLayer = myHeightFirstLayerSpin -> value();
2011 h_data.myNbOfBoundaryLayers = myNbOfBoundaryLayersSpin -> value();
2012 h_data.myBoundaryLayersProgression = myBoundaryLayersProgressionSpin -> value();
2013 h_data.myCoreSize = myCoreSizeSpin->text().isEmpty() ? 0.0 : myCoreSizeSpin -> value();
2014 h_data.myMultinormalsAngle = myMultinormalsAngleSpin -> value();
2015 h_data.myFaceWLIds = myFaceSelectorLayers->GetListOfIDs();
2016 h_data.myFaceWIIds = myFaceSelectorImprinting->GetListOfIDs();
2018 h_data.myKeepFiles = myAdvWidget->keepWorkingFilesCheck->isChecked();
2019 h_data.myWorkingDir = myAdvWidget->workingDirectoryLineEdit->text().trimmed();
2020 h_data.myVerboseLevel = myAdvWidget->verboseLevelSpin->value();
2021 h_data.myToCreateNewNodes = myAdvWidget->createNewNodesCheck->isChecked();
2022 h_data.myRemoveInitialCentralPoint = myAdvWidget->removeInitialCentralPointCheck->isChecked();
2023 h_data.myBoundaryRecovery = myAdvWidget->boundaryRecoveryCheck->isChecked();
2024 h_data.myFEMCorrection = myAdvWidget->FEMCorrectionCheck->isChecked();
2025 h_data.myGradation = myAdvWidget->gradationSpinBox->value();
2026 h_data.myTextOption = myAdvWidget->myAdvOptionsTable->GetCustomOptions();
2027 h_data.myLogInStandardOutput = !myAdvWidget->logInFileCheck->isChecked();
2028 h_data.myRemoveLogOnSuccess = myAdvWidget->removeLogOnSuccessCheck->isChecked();
2030 // Enforced vertices
2031 h_data.myEnforcedVertices.clear();
2032 QVariant valueX, valueY, valueZ;
2033 for (int row=0 ; row<myEnforcedTableWidget->rowCount() ; row++) {
2035 TEnfVertex *myVertex = new TEnfVertex();
2036 myVertex->name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString();
2037 myVertex->geomEntry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString();
2038 if (myVertex->geomEntry.size())
2039 myVertex->groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
2040 if (myVertex->groupName.size())
2041 valueX = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data(Qt::EditRole);
2042 valueY = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data(Qt::EditRole);
2043 valueZ = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data(Qt::EditRole);
2044 if (!valueX.isNull() && !valueY.isNull() && !valueZ.isNull()) {
2045 myVertex->coords.push_back(valueX.toDouble());
2046 myVertex->coords.push_back(valueY.toDouble());
2047 myVertex->coords.push_back(valueZ.toDouble());
2049 myVertex->size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data(Qt::EditRole).toDouble();
2050 myVertex->isCompound = myEnforcedTableWidget->item(row,ENF_VER_COMPOUND_COLUMN)->data(Qt::CheckStateRole).toBool();
2051 h_data.myEnforcedVertices.insert(myVertex);
2055 h_data.myEnforcedMeshes.clear();
2057 for (int row=0 ; row<myEnforcedMeshTableWidget->rowCount() ; row++) {
2059 TEnfMesh *myEnfMesh = new TEnfMesh();
2060 myEnfMesh->name = myEnforcedMeshTableWidget->item(row,ENF_MESH_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString();
2061 myEnfMesh->entry = myEnforcedMeshTableWidget->item(row,ENF_MESH_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString();
2062 myEnfMesh->groupName = myEnforcedMeshTableWidget->item(row,ENF_MESH_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
2063 QComboBox* combo = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row,ENF_MESH_CONSTRAINT_COLUMN));
2064 myEnfMesh->elementType = combo->currentIndex();
2065 h_data.myEnforcedMeshes.insert(myEnfMesh);
2066 std::cout << "h_data.myEnforcedMeshes.size(): " << h_data.myEnforcedMeshes.size() << std::endl;
2072 QString HYBRIDPluginGUI_HypothesisCreator::caption() const
2074 return tr( "HYBRID_TITLE" );
2077 QPixmap HYBRIDPluginGUI_HypothesisCreator::icon() const
2079 return SUIT_Session::session()->resourceMgr()->loadPixmap( "HYBRIDPlugin", tr( "ICON_DLG_HYBRID_PARAMETERS" ) );
2082 QString HYBRIDPluginGUI_HypothesisCreator::type() const
2084 return tr( "HYBRID_HYPOTHESIS" );
2087 QString HYBRIDPluginGUI_HypothesisCreator::helpPage() const
2089 return "hybrid_hypo_page.html";