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 QFrame* fr = new QFrame( 0 );
368 QVBoxLayout* lay = new QVBoxLayout( fr );
370 lay->setSpacing( 0 );
373 QTabWidget* tab = new QTabWidget( fr );
374 tab->setTabShape( QTabWidget::Rounded );
375 tab->setTabPosition( QTabWidget::North );
376 lay->addWidget( tab );
379 myStdGroup = new QWidget();
380 QGridLayout* aStdLayout = new QGridLayout( myStdGroup );
381 aStdLayout->setSpacing( 6 );
382 aStdLayout->setMargin( 11 );
388 aStdLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), myStdGroup ), row, 0, 1, 1 );
389 myName = new QLineEdit( myStdGroup );
390 aStdLayout->addWidget( myName, row++, 1, 1, 1 );
393 myToMeshHolesCheck = new QCheckBox( tr( "HYBRID_TO_MESH_HOLES" ), myStdGroup );
394 //aStdLayout->addWidget( myToMeshHolesCheck, row, 0, 1, 1 );
395 myToMeshHolesCheck->hide();
396 myToMakeGroupsOfDomains = new QCheckBox( tr( "HYBRID_TO_MAKE_DOMAIN_GROUPS" ), myStdGroup );
397 //aStdLayout->addWidget( myToMakeGroupsOfDomains, row++, 1, 1, 1 );
398 myToMakeGroupsOfDomains->hide();
399 //aStdLayout->addWidget( new QLabel( tr( "HYBRID_OPTIMIZATIOL_LEVEL" ), myStdGroup ), row, 0, 1, 1 );
400 myOptimizationLevelCombo = new QComboBox( myStdGroup );
401 //aStdLayout->addWidget( myOptimizationLevelCombo, row++, 1, 1, 1 );
402 myOptimizationLevelCombo->hide();
405 types << tr( "LEVEL_NONE" ) << tr( "LEVEL_LIGHT" ) << tr( "LEVEL_MEDIUM" ) << tr( "LEVEL_STANDARDPLUS" ) << tr( "LEVEL_STRONG" );
406 myOptimizationLevelCombo->addItems( types );
408 aStdLayout->addWidget( new QLabel( tr( "HYBRID_BOUNDARY_LAYERS_GROWTH" ), myStdGroup ), row, 0, 1, 1 );
409 myBoundaryLayersGrowthCombo = new QComboBox( myStdGroup );
410 aStdLayout->addWidget( myBoundaryLayersGrowthCombo, row++, 1, 1, 1 );
412 QStringList typesBoundaryLayersGrowth;
413 typesBoundaryLayersGrowth << tr( "HYBRID_LAYER_GROWTH_INWARD" ) << tr( "HYBRID_LAYER_GROWTH_OUTWARD" );
414 myBoundaryLayersGrowthCombo->addItems( typesBoundaryLayersGrowth );
416 aStdLayout->addWidget( new QLabel( tr( "HYBRID_HeightFirstLayer" ), myStdGroup ), row, 0, 1, 1 );
417 myHeightFirstLayerSpin = new SMESHGUI_SpinBox( myStdGroup );
418 myHeightFirstLayerSpin->RangeStepAndValidator(0., 100., .1, "HeightFirstLayer");
419 aStdLayout->addWidget( myHeightFirstLayerSpin, row++, 1, 1, 1 );
421 aStdLayout->addWidget( new QLabel( tr( "HYBRID_NbOfBoundaryLayers" ), myStdGroup ), row, 0, 1, 1 );
422 myNbOfBoundaryLayersSpin = new QSpinBox( myStdGroup );
423 aStdLayout->addWidget( myNbOfBoundaryLayersSpin, row++, 1, 1, 1 );
425 aStdLayout->addWidget( new QLabel( tr( "HYBRID_BoundaryLayersProgression" ), myStdGroup ), row, 0, 1, 1 );
426 myBoundaryLayersProgressionSpin = new SMESHGUI_SpinBox( myStdGroup );
427 myBoundaryLayersProgressionSpin->RangeStepAndValidator(0., 10., .1, "BoundaryLayersProgression");
428 aStdLayout->addWidget( myBoundaryLayersProgressionSpin, row++, 1, 1, 1 );
430 aStdLayout->addWidget( new QLabel( tr( "COLLISION_MODE" ), myStdGroup ), row, 0, 1, 1 );
431 myCollisionModeCombo = new QComboBox( myStdGroup );
432 aStdLayout->addWidget( myCollisionModeCombo, row++, 1, 1, 1 );
434 QStringList typescoll;
435 typescoll << tr( "COLLISION_DECREASE" ) << tr( "COLLISION_STOP" );
436 myCollisionModeCombo->addItems( typescoll );
438 aStdLayout->addWidget( new QLabel( tr( "HYBRID_GENERATION_ELEMENT" ), myStdGroup ), row, 0, 1, 1 );
439 myElementGenerationCombo = new QComboBox( myStdGroup );
440 aStdLayout->addWidget( myElementGenerationCombo, row++, 1, 1, 1 );
442 QStringList typesElementGeneration;
443 typesElementGeneration << tr( "HYBRID_GENERATION_TETRA_DOMINANT" ) << tr( "HYBRID_GENERATION_HEXA_DOMINANT" );
444 myElementGenerationCombo->addItems( typesElementGeneration );
446 myAddMultinormalsCheck = new QCheckBox( tr( "HYBRID_ADD_MULTINORMALS" ), myStdGroup );
447 aStdLayout->addWidget( myAddMultinormalsCheck, row++, 0, 1, 1 );
449 aStdLayout->addWidget( new QLabel( tr( "HYBRID_MULTINORMAL_ANGLE" ), myStdGroup ), row, 0, 1, 1 );
450 myMultinormalsAngleSpin = new SMESHGUI_SpinBox( myStdGroup );
451 myMultinormalsAngleSpin->RangeStepAndValidator(0., 90., 2., "threshold");
452 aStdLayout->addWidget( myMultinormalsAngleSpin, row++, 1, 1, 1 );
454 mySmoothNormalsCheck = new QCheckBox( tr( "HYBRID_SMOOTH_NORMALS" ), myStdGroup );
455 aStdLayout->addWidget( mySmoothNormalsCheck, row++, 0, 1, 1 );
456 aStdLayout->setRowStretch( row, 10 );
458 // advanced parameters
459 myAdvGroup = new QWidget();
460 QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup );
461 anAdvLayout->setSpacing( 6 );
462 anAdvLayout->setMargin( 11 );
463 myAdvWidget = new HYBRIDPluginGUI_AdvWidget(myAdvGroup);
464 anAdvLayout->addWidget( myAdvWidget);
466 myAdvWidget->maxMemoryCheck->setText(tr( "MAX_MEMORY_SIZE" ));
467 myAdvWidget->initialMemoryCheck->setText(tr( "INIT_MEMORY_SIZE" ));
469 myAdvWidget->maxMemorySpin->RangeStepAndValidator(20.0, 1e6, 10.0);
470 myAdvWidget->maxMemorySpin->setValue( 128.0 );
472 myAdvWidget->initialMemorySpin->RangeStepAndValidator(0.0, 1e6, 10.0);
473 myAdvWidget->initialMemorySpin->setValue( 100.0 );
475 myAdvWidget->initialMemoryLabel ->setText (tr( "MEGABYTE" ));
476 myAdvWidget->maxMemoryLabel ->setText (tr( "MEGABYTE" ));
478 myAdvWidget->workingDirectoryPushButton ->setText (tr( "SELECT_DIR" ));
479 myAdvWidget->keepWorkingFilesCheck ->setText (tr( "KEEP_WORKING_FILES" ));
480 myAdvWidget->verboseLevelLabel ->setText (tr( "VERBOSE_LEVEL" ));
481 myAdvWidget->removeLogOnSuccessCheck ->setText (tr( "REMOVE_LOG_ON_SUCCESS" ));
482 myAdvWidget->logInFileCheck ->setText (tr( "LOG_IN_FILE" ));
484 myAdvWidget->memoryGroupBox ->setTitle(tr( "MEMORY_GROUP_TITLE" ));
485 myAdvWidget->logGroupBox ->setTitle(tr( "LOG_GROUP_TITLE" ));
486 myAdvWidget->advancedMeshingGroupBox ->setTitle(tr( "ADVANCED_MESHING_GROUP_TITLE" ));
488 myAdvWidget->memoryGroupBox->hide();
490 myAdvWidget->createNewNodesCheck->hide();
491 //myAdvWidget->createNewNodesLabel->hide();
492 myAdvWidget->removeInitialCentralPointCheck->hide();
493 myAdvWidget->boundaryRecoveryCheck->hide();
494 myAdvWidget->FEMCorrectionCheck->hide();
495 myAdvWidget->gradationLabel->hide();
496 myAdvWidget->gradationSpinBox->hide();
498 myAdvWidget->createNewNodesCheck ->setText (tr( "TO_ADD_NODES" ));
499 myAdvWidget->removeInitialCentralPointCheck->setText (tr( "NO_INITIAL_CENTRAL_POINT" ));
500 myAdvWidget->boundaryRecoveryCheck ->setText (tr( "RECOVERY_VERSION" ));
501 myAdvWidget->FEMCorrectionCheck ->setText (tr( "FEM_CORRECTION" ));
502 myAdvWidget->gradationLabel ->setText (tr( "HYBRID_GRADATION" ));
503 myAdvWidget->gradationSpinBox->RangeStepAndValidator(1.05, 5.0, 0.05, "length_precision");
504 myAdvWidget->textOptionLabel->setText(tr( "TEXT_OPTION" ));
506 // Enforced vertices parameters
507 myEnfGroup = new QWidget();
508 QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup);
510 myEnforcedTableWidget = new QTableWidget(myEnfGroup);
511 myEnforcedTableWidget ->setMinimumWidth(300);
512 myEnforcedTableWidget->setRowCount( 0 );
513 myEnforcedTableWidget->setColumnCount( ENF_VER_NB_COLUMNS );
514 myEnforcedTableWidget->setSortingEnabled(true);
515 QStringList enforcedHeaders;
516 enforcedHeaders << tr( "HYBRID_ENF_NAME_COLUMN" )
517 << tr( "HYBRID_ENF_VER_X_COLUMN" )<< tr( "HYBRID_ENF_VER_Y_COLUMN" ) << tr( "HYBRID_ENF_VER_Z_COLUMN" )
518 << tr( "HYBRID_ENF_SIZE_COLUMN" ) << tr("HYBRID_ENF_ENTRY_COLUMN") << tr("HYBRID_ENF_VER_COMPOUND_COLUMN") << tr( "HYBRID_ENF_GROUP_COLUMN" );
520 myEnforcedTableWidget->setHorizontalHeaderLabels(enforcedHeaders);
521 myEnforcedTableWidget->verticalHeader()->hide();
522 myEnforcedTableWidget->horizontalHeader()->setStretchLastSection(true);
523 myEnforcedTableWidget->setAlternatingRowColors(true);
524 myEnforcedTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
525 myEnforcedTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
526 myEnforcedTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
527 myEnforcedTableWidget->resizeColumnsToContents();
528 myEnforcedTableWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
529 myEnforcedTableWidget->hideColumn(ENF_VER_COMPOUND_COLUMN);
531 myEnforcedTableWidget->setItemDelegate(new EnforcedVertexTableWidgetDelegate());
534 TColStd_MapOfInteger shapeTypes;
535 shapeTypes.Add( TopAbs_VERTEX );
536 shapeTypes.Add( TopAbs_COMPOUND );
538 SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes);
539 myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true, /*stretch=*/false);
540 myEnfVertexWdg->SetDefaultText(tr("HYBRID_ENF_SELECT_VERTEX"), "QLineEdit { color: grey }");
542 QLabel* myXCoordLabel = new QLabel( tr( "HYBRID_ENF_VER_X_LABEL" ), myEnfGroup );
543 myXCoord = new SMESHGUI_SpinBox(myEnfGroup);
544 myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
545 QLabel* myYCoordLabel = new QLabel( tr( "HYBRID_ENF_VER_Y_LABEL" ), myEnfGroup );
546 myYCoord = new SMESHGUI_SpinBox(myEnfGroup);
547 myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
548 QLabel* myZCoordLabel = new QLabel( tr( "HYBRID_ENF_VER_Z_LABEL" ), myEnfGroup );
549 myZCoord = new SMESHGUI_SpinBox(myEnfGroup);
550 myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
551 QLabel* mySizeLabel = new QLabel( tr( "HYBRID_ENF_SIZE_LABEL" ), myEnfGroup );
552 mySizeValue = new SMESHGUI_SpinBox(myEnfGroup);
553 mySizeValue->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
555 QLabel* myGroupNameLabel = new QLabel( tr( "HYBRID_ENF_GROUP_LABEL" ), myEnfGroup );
556 myGroupName = new QLineEdit(myEnfGroup);
558 addVertexButton = new QPushButton(tr("HYBRID_ENF_ADD"),myEnfGroup);
559 addVertexButton->setEnabled(false);
560 removeVertexButton = new QPushButton(tr("HYBRID_ENF_REMOVE"),myEnfGroup);
561 // myGlobalGroupName = new QCheckBox(tr("HYBRID_ENF_VER_GROUPS"), myEnfGroup);
562 // myGlobalGroupName->setChecked(false);
564 // QGroupBox* GroupBox = new QGroupBox( myEnfGroup );
565 // QLabel* info = new QLabel( GroupBox );
566 // info->setText( tr( "HYBRID_ENF_VER_INFO" ) );
567 // info->setWordWrap( true );
568 // QVBoxLayout* GroupBoxVLayout = new QVBoxLayout( GroupBox );
569 // GroupBoxVLayout->setSpacing( 6 );
570 // GroupBoxVLayout->setMargin( 11 );
571 // GroupBoxVLayout->addWidget( info );
574 //anEnfLayout->addWidget(GroupBox, ENF_VER_WARNING, 0, 1, 2 );
575 anEnfLayout->addWidget(myEnforcedTableWidget, ENF_VER_VERTEX, 0, ENF_VER_NB_LINES, 1);
577 QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup);
578 anEnfLayout2->addWidget(myEnfVertexWdg, ENF_VER_VERTEX, 0, 1, 2);
579 anEnfLayout2->addWidget(myXCoordLabel, ENF_VER_X_COORD, 0, 1, 1);
580 anEnfLayout2->addWidget(myXCoord, ENF_VER_X_COORD, 1, 1, 1);
581 anEnfLayout2->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 0, 1, 1);
582 anEnfLayout2->addWidget(myYCoord, ENF_VER_Y_COORD, 1, 1, 1);
583 anEnfLayout2->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 0, 1, 1);
584 anEnfLayout2->addWidget(myZCoord, ENF_VER_Z_COORD, 1, 1, 1);
585 anEnfLayout2->addWidget(mySizeLabel, ENF_VER_SIZE, 0, 1, 1);
586 anEnfLayout2->addWidget(mySizeValue, ENF_VER_SIZE, 1, 1, 1);
587 anEnfLayout2->addWidget(myGroupNameLabel, ENF_VER_GROUP, 0, 1, 1);
588 anEnfLayout2->addWidget(myGroupName, ENF_VER_GROUP, 1, 1, 1);
589 anEnfLayout2->addWidget(addVertexButton, ENF_VER_BTN, 0, 1, 1);
590 anEnfLayout2->addWidget(removeVertexButton, ENF_VER_BTN, 1, 1, 1);
591 anEnfLayout2->setRowStretch(ENF_VER_NB_LINES, 1);
593 anEnfLayout->addLayout(anEnfLayout2, ENF_VER_VERTEX, 1,ENF_VER_NB_LINES, 1);
594 anEnfLayout->setRowStretch(ENF_VER_VERTEX, 10);
597 // Enforced meshes parameters
598 myEnfMeshGroup = new QWidget();
599 QGridLayout* anEnfMeshLayout = new QGridLayout(myEnfMeshGroup);
601 myEnforcedMeshTableWidget = new QTableWidget(myEnfGroup);
602 myEnforcedMeshTableWidget->setRowCount( 0 );
603 myEnforcedMeshTableWidget->setColumnCount( ENF_MESH_NB_COLUMNS );
604 myEnforcedMeshTableWidget->setSortingEnabled(true);
605 myEnforcedMeshTableWidget->verticalHeader()->hide();
606 QStringList enforcedMeshHeaders;
607 enforcedMeshHeaders << tr( "HYBRID_ENF_NAME_COLUMN" )
608 << tr( "HYBRID_ENF_ENTRY_COLUMN" )
609 << tr( "HYBRID_ENF_MESH_CONSTRAINT_COLUMN" )
610 << tr( "HYBRID_ENF_GROUP_COLUMN" );
611 myEnforcedMeshTableWidget->setHorizontalHeaderLabels(enforcedMeshHeaders);
612 myEnforcedMeshTableWidget->horizontalHeader()->setStretchLastSection(true);
613 myEnforcedMeshTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
614 myEnforcedMeshTableWidget->setAlternatingRowColors(true);
615 myEnforcedMeshTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
616 myEnforcedMeshTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
617 myEnforcedMeshTableWidget->resizeColumnsToContents();
618 myEnforcedMeshTableWidget->hideColumn(ENF_MESH_ENTRY_COLUMN);
620 myEnforcedMeshTableWidget->setItemDelegate(new EnforcedMeshTableWidgetDelegate());
622 // myEnfMesh = SMESH::SMESH_Mesh::_nil();
623 // myEnfMeshArray = new SMESH::mesh_array();
625 myEnfMeshWdg = new StdMeshersGUI_ObjectReferenceParamWdg( SMESH::IDSOURCE, myEnfMeshGroup, /*multiSel=*/true);
626 myEnfMeshWdg->SetDefaultText(tr("HYBRID_ENF_SELECT_MESH"), "QLineEdit { color: grey }");
628 myEnfMeshWdg->AvoidSimultaneousSelection(myEnfVertexWdg);
630 QLabel* myMeshConstraintLabel = new QLabel( tr( "HYBRID_ENF_MESH_CONSTRAINT_LABEL" ), myEnfMeshGroup );
631 myEnfMeshConstraint = new QComboBox(myEnfMeshGroup);
632 myEnfMeshConstraint->insertItems(0,myEnfMeshConstraintLabels);
633 myEnfMeshConstraint->setEditable(false);
634 myEnfMeshConstraint->setCurrentIndex(0);
636 QLabel* myMeshGroupNameLabel = new QLabel( tr( "HYBRID_ENF_GROUP_LABEL" ), myEnfMeshGroup );
637 myMeshGroupName = new QLineEdit(myEnfMeshGroup);
639 addEnfMeshButton = new QPushButton(tr("HYBRID_ENF_ADD"),myEnfMeshGroup);
640 // addEnfMeshButton->setEnabled(false);
641 removeEnfMeshButton = new QPushButton(tr("HYBRID_ENF_REMOVE"),myEnfMeshGroup);
643 // QGroupBox* GroupBox2 = new QGroupBox( myEnfMeshGroup );
644 // QLabel* info2 = new QLabel( GroupBox2 );
645 // info2->setText( tr( "HYBRID_ENF_MESH_INFO" ) );
646 // info2->setWordWrap( true );
647 // QVBoxLayout* GroupBox2VLayout = new QVBoxLayout( GroupBox2 );
648 // GroupBox2VLayout->setSpacing( 6 );
649 // GroupBox2VLayout->setMargin( 11 );
650 // GroupBox2VLayout->addWidget( info2 );
652 // anEnfMeshLayout->addWidget( GroupBox2, ENF_MESH_WARNING, 0, 1, 2 );
653 anEnfMeshLayout->addWidget(myEnforcedMeshTableWidget, ENF_MESH_MESH, 0, ENF_MESH_NB_LINES , 1);
655 QGridLayout* anEnfMeshLayout2 = new QGridLayout(myEnfMeshGroup);
656 anEnfMeshLayout2->addWidget(myEnfMeshWdg, ENF_MESH_MESH, 0, 1, 2);
657 anEnfMeshLayout2->addWidget(myMeshConstraintLabel, ENF_MESH_CONSTRAINT, 0, 1, 1);
658 anEnfMeshLayout2->addWidget(myEnfMeshConstraint, ENF_MESH_CONSTRAINT, 1, 1, 1);
659 anEnfMeshLayout2->addWidget(myMeshGroupNameLabel, ENF_MESH_GROUP, 0, 1, 1);
660 anEnfMeshLayout2->addWidget(myMeshGroupName, ENF_MESH_GROUP, 1, 1, 1);
661 anEnfMeshLayout2->addWidget(addEnfMeshButton, ENF_MESH_BTN, 0, 1, 1);
662 anEnfMeshLayout2->addWidget(removeEnfMeshButton, ENF_MESH_BTN, 1, 1, 1);
663 anEnfMeshLayout2->setRowStretch(ENF_MESH_NB_LINES, 1);
665 anEnfMeshLayout->addLayout(anEnfMeshLayout2, ENF_MESH_MESH, 1, ENF_MESH_NB_LINES, 1);
666 anEnfMeshLayout->setRowStretch(ENF_MESH_MESH, 10);
669 tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
670 tab->insertTab( ADV_TAB, myAdvGroup, tr( "HYBRID_ADV_ARGS" ) );
671 tab->insertTab( ENF_VER_TAB, myEnfGroup, tr( "HYBRID_ENFORCED_VERTICES" ) );
672 tab->insertTab( ENF_MESH_TAB, myEnfMeshGroup, tr( "HYBRID_ENFORCED_MESHES" ) );
673 tab->setCurrentIndex( STD_TAB );
676 //connect( myToMeshHolesCheck, SIGNAL( toggled( bool ) ), this, SLOT( onToMeshHoles(bool)));
677 //connect( myAdvWidget->maxMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
678 //connect( myAdvWidget->initialMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
679 //connect( myAdvWidget->boundaryRecoveryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
681 //connect( myBoundaryLayersGrowthCombo, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
682 //connect( myElementGenerationCombo, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
683 connect( myAddMultinormalsCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
684 connect( mySmoothNormalsCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
686 connect( myAdvWidget->logInFileCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
687 connect( myAdvWidget->keepWorkingFilesCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
688 connect( myAdvWidget->workingDirectoryPushButton, SIGNAL( clicked() ), this, SLOT( onDirBtnClicked() ) );
690 connect( myEnforcedTableWidget, SIGNAL( itemClicked(QTableWidgetItem *)), this, SLOT( synchronizeCoords() ) );
691 connect( myEnforcedTableWidget, SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
692 connect( myEnforcedTableWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
693 connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertex() ) );
694 connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
695 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
696 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
697 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
698 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
699 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
700 connect( mySizeValue, SIGNAL( textChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) );
701 connect( myXCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
702 connect( myYCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
703 connect( myZCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
704 connect( mySizeValue, SIGNAL( valueChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) );
705 connect( this, SIGNAL( vertexDefined(bool) ), addVertexButton, SLOT( setEnabled(bool) ) );
707 connect( addEnfMeshButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedMesh() ) );
708 connect( removeEnfMeshButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedMesh() ) );
709 // connect( myEnfMeshWdg, SIGNAL( contentModified()), this, SLOT( checkEnfMeshIsDefined() ) );
710 // connect( myEnfMeshConstraint, SIGNAL( currentIndexChanged(int) ), this, SLOT( checkEnfMeshIsDefined() ) );
711 // connect( this, SIGNAL( enfMeshDefined(bool) ), addEnfMeshButton, SLOT( setEnabled(bool) ) );
717 * This method checks if an enforced vertex is defined;
719 void HYBRIDPluginGUI_HypothesisCreator::clearEnfVertexSelection()
721 if (myEnfVertexWdg->NbObjects() != 0) {
722 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
723 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
724 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
725 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
726 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
728 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
729 that->checkVertexIsDefined();
733 * This method checks if an enforced vertex is defined;
735 void HYBRIDPluginGUI_HypothesisCreator::checkVertexIsDefined()
737 bool enfVertexIsDefined = false;
738 enfVertexIsDefined = (!mySizeValue->GetString().isEmpty() &&
739 (!myEnfVertexWdg->NbObjects() == 0 ||
740 (myEnfVertexWdg->NbObjects() == 0 && !myXCoord->GetString().isEmpty()
741 && !myYCoord->GetString().isEmpty()
742 && !myZCoord->GetString().isEmpty())));
743 emit vertexDefined(enfVertexIsDefined);
747 * This method checks if an enforced mesh is defined;
749 void HYBRIDPluginGUI_HypothesisCreator::checkEnfMeshIsDefined()
751 emit enfMeshDefined( myEnfVertexWdg->NbObjects() != 0);
755 * This method resets the content of the X, Y, Z, size and GroupName widgets;
757 void HYBRIDPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
759 myXCoord->setCleared(true);
760 myYCoord->setCleared(true);
761 myZCoord->setCleared(true);
762 // mySizeValue->setCleared(true);
763 myXCoord->setText("");
764 myYCoord->setText("");
765 myZCoord->setText("");
766 // mySizeValue->setText("");
767 // myGroupName->setText("");
768 addVertexButton->setEnabled(false);
771 /** HYBRIDPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item)
772 This method updates the tooltip of a modified item. The QLineEdit widgets content
773 is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
775 void HYBRIDPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTableWidgetItem* item) {
776 // MESSAGE("HYBRIDPluginGUI_HypothesisCreator::updateEnforcedVertexValues");
777 int row = myEnforcedTableWidget->row(item);
779 QVariant vertexName = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole);
780 QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole);
781 QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole);
782 QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole);
783 QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole);
784 QVariant entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
785 QString groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole).toString();
787 clearEnforcedVertexWidgets();
789 if ( !x.isNull() || !entry.isNull()) {
790 QString toolTip = vertexName.toString();
791 toolTip += QString("(");
792 if (entry.isNull() || (!entry.isNull() && entry.toString() == "")) {
793 toolTip += x.toString();
794 toolTip += QString(", ") + y.toString();
795 toolTip += QString(", ") + z.toString();
798 toolTip += entry.toString();
799 toolTip += QString(")");
802 toolTip += QString("=") + size.toString();
804 if (!groupName.isEmpty())
805 toolTip += QString(" [") + groupName + QString("]");
807 // MESSAGE("Tooltip: " << toolTip.toStdString());
808 for (int col=0;col<ENF_VER_NB_COLUMNS;col++)
809 myEnforcedTableWidget->item(row,col)->setToolTip(toolTip);
812 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
813 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
814 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
815 myXCoord->SetValue(x.toDouble());
816 myYCoord->SetValue(y.toDouble());
817 myZCoord->SetValue(z.toDouble());
818 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
819 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
820 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
823 mySizeValue->SetValue(size.toDouble());
825 if (!groupName.isEmpty())
826 myGroupName->setText(groupName);
830 void HYBRIDPluginGUI_HypothesisCreator::onSelectEnforcedVertex() {
831 int nbSelEnfVertex = myEnfVertexWdg->NbObjects();
832 clearEnforcedVertexWidgets();
833 if (nbSelEnfVertex == 1)
835 if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() )
838 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
839 if (myEnfVertex == GEOM::GEOM_Object::_nil())
841 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
842 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
843 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
844 if (CORBA::is_nil(measureOp))
848 measureOp->PointCoordinates (myEnfVertex, x, y, z);
849 if ( measureOp->IsDone() )
851 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
852 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
853 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
854 myXCoord->SetValue(x);
855 myYCoord->SetValue(y);
856 myZCoord->SetValue(z);
857 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
858 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
859 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
865 /** HYBRIDPluginGUI_HypothesisCreator::synchronizeCoords()
866 This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
867 of the enforced vertex clicked in the tree widget.
869 void HYBRIDPluginGUI_HypothesisCreator::synchronizeCoords() {
870 clearEnforcedVertexWidgets();
871 QList<QTableWidgetItem *> items = myEnforcedTableWidget->selectedItems();
872 // myEnfVertexWdg->disconnect(SIGNAL(contentModified()));
873 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
874 if (! items.isEmpty()) {
875 QTableWidgetItem *item;
878 if (items.size() == 1) {
880 row = myEnforcedTableWidget->row(item);
881 QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole);
882 QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole);
883 QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole);
884 QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole);
885 entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
886 if (!entry.isNull()) {
887 SMESH::string_array_var objIds = new SMESH::string_array;
889 objIds[0] = entry.toString().toStdString().c_str();
890 myEnfVertexWdg->SetObjects(objIds);
893 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
895 QVariant group = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole);
896 if (!x.isNull()/* && entry.isNull()*/) {
897 // disconnect( myXCoord, SIGNAL( textChanged(const QString &)), this, SLOT( onSelectEnforcedVertex() ) );
898 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
899 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
900 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
901 myXCoord->SetValue(x.toDouble());
902 myYCoord->SetValue(y.toDouble());
903 myZCoord->SetValue(z.toDouble());
904 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
905 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
906 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
909 mySizeValue->SetValue(size.toDouble());
911 if (!group.isNull() && (!x.isNull() || !entry.isNull()))
912 myGroupName->setText(group.toString());
915 QList<QString> entryList;
916 for (int i = 0; i < items.size(); ++i) {
918 row = myEnforcedTableWidget->row(item);
919 entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
921 entryList << entry.toString();
923 if (entryList.size() > 0) {
924 SMESH::string_array_var objIds = new SMESH::string_array;
925 objIds->length(entryList.size());
926 for (int i = 0; i < entryList.size() ; i++)
927 objIds[i] = entryList.at(i).toStdString().c_str();
928 myEnfVertexWdg->SetObjects(objIds);
931 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
936 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
938 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
939 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
940 that->checkVertexIsDefined();
943 /** HYBRIDPluginGUI_HypothesisCreator::addEnforcedMesh( meshName, geomEntry, elemType, size, groupName)
944 This method adds in the tree widget an enforced mesh from mesh, submesh or group with optionally size and and groupName.
946 void HYBRIDPluginGUI_HypothesisCreator::addEnforcedMesh(std::string name, std::string entry, int elementType, std::string groupName)
948 MESSAGE("addEnforcedMesh(\"" << name << ", \"" << entry << "\", " << elementType << ", \"" << groupName << "\")");
949 bool okToCreate = true;
950 QString itemEntry = "";
951 int itemElementType = 0;
952 int rowCount = myEnforcedMeshTableWidget->rowCount();
953 bool allColumns = true;
954 for (int row = 0;row<rowCount;row++) {
955 for (int col = 0 ; col < ENF_MESH_NB_COLUMNS ; col++) {
956 MESSAGE("col: " << col);
957 if (col == ENF_MESH_CONSTRAINT_COLUMN){
958 if (qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row, col)) == 0) {
960 MESSAGE("allColumns = false");
964 else if (myEnforcedMeshTableWidget->item(row, col) == 0) {
966 MESSAGE("allColumns = false");
969 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
970 QComboBox* itemComboBox = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row, col));
971 itemElementType = itemComboBox->currentIndex();
972 MESSAGE("itemElementType: " << itemElementType);
974 else if (col == ENF_MESH_ENTRY_COLUMN)
975 itemEntry = myEnforcedMeshTableWidget->item(row, col)->data(Qt::EditRole).toString();
981 if (itemEntry == QString(entry.c_str()) && itemElementType == elementType) {
982 // // update group name
983 // if (itemGroupName.toStdString() != groupName) {
984 // MESSAGE("Group is updated from \"" << itemGroupName.toStdString() << "\" to \"" << groupName << "\"");
985 // myEnforcedMeshTableWidget->item(row, ENF_MESH_GROUP_COLUMN)->setData( Qt::EditRole, QVariant(groupName.c_str()));
996 MESSAGE("Creation of enforced mesh");
998 myEnforcedMeshTableWidget->setRowCount(rowCount+1);
999 myEnforcedMeshTableWidget->setSortingEnabled(false);
1001 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++) {
1002 MESSAGE("Column: " << col);
1003 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1004 QComboBox* comboBox = new QComboBox();
1005 QPalette pal = comboBox->palette();
1006 pal.setColor(QPalette::Button, Qt::white);
1007 comboBox->setPalette(pal);
1008 comboBox->insertItems(0,myEnfMeshConstraintLabels);
1009 comboBox->setEditable(false);
1010 comboBox->setCurrentIndex(elementType);
1011 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << comboBox->currentText().toStdString());
1012 myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox);
1015 QTableWidgetItem* item = new QTableWidgetItem();
1016 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1018 case ENF_MESH_NAME_COLUMN:
1019 item->setData( 0, name.c_str() );
1020 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1021 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1022 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1024 case ENF_MESH_ENTRY_COLUMN:
1025 item->setData( 0, entry.c_str() );
1026 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1027 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1028 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1030 case ENF_MESH_GROUP_COLUMN:
1031 item->setData( 0, groupName.c_str() );
1032 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1033 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1042 // connect( myEnforcedMeshTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1044 myEnforcedMeshTableWidget->setSortingEnabled(true);
1045 // myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1046 // updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1050 /** HYBRIDPluginGUI_HypothesisCreator::addEnforcedVertex( x, y, z, size, vertexName, geomEntry, groupName)
1051 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.
1053 void HYBRIDPluginGUI_HypothesisCreator::addEnforcedVertex(double x, double y, double z, double size, std::string vertexName, std::string geomEntry, std::string groupName, bool isCompound)
1055 MESSAGE("addEnforcedVertex(" << x << ", " << y << ", " << z << ", " << size << ", \"" << vertexName << ", \"" << geomEntry << "\", \"" << groupName << "\", " << isCompound << ")");
1056 myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1057 bool okToCreate = true;
1058 double itemX,itemY,itemZ,itemSize = 0;
1059 QString itemEntry, itemGroupName = QString("");
1060 // bool itemIsCompound;
1061 int rowCount = myEnforcedTableWidget->rowCount();
1064 for (int row = 0;row<rowCount;row++) {
1066 for (int col = 0 ; col < ENF_VER_NB_COLUMNS ; col++) {
1067 if (myEnforcedTableWidget->item(row, col) == 0) {
1072 data = myEnforcedTableWidget->item(row, col)->data(Qt::EditRole);
1073 if (!data.isNull()) {
1075 case ENF_VER_GROUP_COLUMN:
1076 itemGroupName = data.toString();
1078 case ENF_VER_ENTRY_COLUMN:
1079 itemEntry = data.toString();
1081 // case ENF_VER_COMPOUND_COLUMN:
1082 // itemIsCompound = data.toBool();
1084 case ENF_VER_X_COLUMN:
1085 itemX = data.toDouble();
1087 case ENF_VER_Y_COLUMN:
1088 itemY = data.toDouble();
1090 case ENF_VER_Z_COLUMN:
1091 itemZ = data.toDouble();
1093 case ENF_VER_SIZE_COLUMN:
1094 itemSize = data.toDouble();
1106 if (( !isCompound && ((itemX == x) && (itemY == y) && (itemZ == z))) || /*( (itemEntry.toStdString() != "") && */ (itemEntry.toStdString() == geomEntry)/*)*/) {
1108 if (itemSize != size) {
1109 MESSAGE("Size is updated from \"" << itemSize << "\" to \"" << size << "\"");
1110 myEnforcedTableWidget->item(row, ENF_VER_SIZE_COLUMN)->setData( Qt::EditRole, QVariant(size));
1112 // update group name
1113 if (itemGroupName.toStdString() != groupName) {
1114 MESSAGE("Group is updated from \"" << itemGroupName.toStdString() << "\" to \"" << groupName << "\"");
1115 myEnforcedTableWidget->item(row, ENF_VER_GROUP_COLUMN)->setData( Qt::EditRole, QVariant(groupName.c_str()));
1122 if (geomEntry.empty()) {
1123 MESSAGE("Vertex with coords " << x << ", " << y << ", " << z << " already exist: dont create again");
1126 MESSAGE("Vertex with entry " << geomEntry << " already exist: dont create again");
1131 if (geomEntry.empty()) {
1132 MESSAGE("Vertex with coords " << x << ", " << y << ", " << z<< " is created");
1135 MESSAGE("Vertex with geom entry " << geomEntry << " is created");
1140 QString myVertexName;
1141 while(indexRef != vertexIndex) {
1142 indexRef = vertexIndex;
1143 if (vertexName.empty())
1144 myVertexName = QString("Vertex #%1").arg(vertexIndex);
1146 myVertexName = QString(vertexName.c_str());
1148 for (int row = 0;row<rowCount;row++) {
1149 QString name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString();
1150 if (myVertexName == name) {
1157 MESSAGE("myVertexName is \"" << myVertexName.toStdString() << "\"");
1158 myEnforcedTableWidget->setRowCount(rowCount+1);
1159 myEnforcedTableWidget->setSortingEnabled(false);
1160 for (int col=0;col<ENF_VER_NB_COLUMNS;col++) {
1161 MESSAGE("Column: " << col);
1162 QTableWidgetItem* item = new QTableWidgetItem();
1163 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1165 case ENF_VER_NAME_COLUMN:
1166 item->setData( Qt::EditRole, myVertexName );
1167 if (!geomEntry.empty()) {
1169 item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1171 item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1174 case ENF_VER_X_COLUMN:
1176 item->setData( 0, QVariant(x) );
1178 case ENF_VER_Y_COLUMN:
1180 item->setData( 0, QVariant(y) );
1182 case ENF_VER_Z_COLUMN:
1184 item->setData( 0, QVariant(z) );
1186 case ENF_VER_SIZE_COLUMN:
1187 item->setData( 0, QVariant(size) );
1189 case ENF_VER_ENTRY_COLUMN:
1190 if (!geomEntry.empty())
1191 item->setData( 0, QString(geomEntry.c_str()) );
1193 case ENF_VER_COMPOUND_COLUMN:
1194 item->setData( Qt::CheckStateRole, isCompound );
1195 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
1197 case ENF_VER_GROUP_COLUMN:
1198 if (!groupName.empty())
1199 item->setData( 0, QString(groupName.c_str()) );
1205 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1206 myEnforcedTableWidget->setItem(rowCount,col,item);
1210 connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1212 myEnforcedTableWidget->setSortingEnabled(true);
1213 // myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1214 updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1217 /** HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedMesh()
1218 This method is called when a item is added into the enforced meshes tree widget
1220 void HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedMesh()
1222 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedMesh()");
1224 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1226 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1227 myEnfMeshWdg->deactivateSelection();
1229 for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column)
1230 myEnforcedMeshTableWidget->resizeColumnToContents(column);
1233 int selEnfMeshes = myEnfMeshWdg->NbObjects();
1234 if (selEnfMeshes == 0)
1237 std::string groupName = myMeshGroupName->text().toStdString();
1238 // if (myGlobalGroupName->isChecked())
1239 // groupName = myGlobalGroupName->text().toStdString();
1241 if (boost::trim_copy(groupName).empty())
1245 int elementType = myEnfMeshConstraint->currentIndex();
1248 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1249 _PTR(SObject) aSObj; //SMESH::SMESH_IDSource::_nil;
1250 QString meshEntry = myEnfMeshWdg->GetValue();
1251 MESSAGE("myEnfMeshWdg->GetValue()" << meshEntry.toStdString());
1253 if (selEnfMeshes == 1)
1255 MESSAGE("1 SMESH object selected");
1256 // myEnfMesh = myEnfMeshWdg->GetObject< SMESH::SMESH_IDSource >();
1257 // std::string entry = myEnfMeshWdg->GetValue();
1258 aSObj = aStudy->FindObjectID(meshEntry.toStdString().c_str());
1259 CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy);
1260 if (!CORBA::is_nil(anObj)) {
1261 // SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1262 addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
1267 MESSAGE(selEnfMeshes << " SMESH objects selected");
1268 QStringList meshEntries = meshEntry.split(" ", QString::SkipEmptyParts);
1269 QStringListIterator meshEntriesIt (meshEntries);
1270 while (meshEntriesIt.hasNext()) {
1271 aSObj = aStudy->FindObjectID(meshEntriesIt.next().toStdString().c_str());
1272 CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy);
1273 if (!CORBA::is_nil(anObj)) {
1274 // SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1275 addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
1280 myEnfVertexWdg->SetObject(SMESH::SMESH_IDSource::_nil());
1282 for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column)
1283 myEnforcedMeshTableWidget->resizeColumnToContents(column);
1287 /** HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedVertex()
1288 This method is called when a item is added into the enforced vertices tree widget
1290 void HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedVertex()
1292 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedVertex()");
1294 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1296 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1297 myEnfVertexWdg->deactivateSelection();
1299 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1300 myEnforcedTableWidget->resizeColumnToContents(column);
1303 int selEnfVertex = myEnfVertexWdg->NbObjects();
1304 bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty());
1305 if ((selEnfVertex == 0) && coordsEmpty)
1308 std::string groupName = myGroupName->text().toStdString();
1309 // if (myGlobalGroupName->isChecked())
1310 // groupName = myGlobalGroupName->text().toStdString();
1312 if (boost::trim_copy(groupName).empty())
1315 double size = mySizeValue->GetValue();
1317 if (selEnfVertex <= 1)
1319 MESSAGE("0 or 1 GEOM object selected");
1320 double x = 0, y = 0, z=0;
1321 if (myXCoord->GetString() != "") {
1322 x = myXCoord->GetValue();
1323 y = myYCoord->GetValue();
1324 z = myZCoord->GetValue();
1326 if (selEnfVertex == 1) {
1327 MESSAGE("1 GEOM object selected");
1328 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >();
1329 std::string entry = "";
1330 if (myEnfVertex != GEOM::GEOM_Object::_nil())
1331 entry = myEnfVertex->GetStudyEntry();
1332 addEnforcedVertex(x, y, z, size, myEnfVertex->GetName(),entry, groupName, myEnfVertex->GetShapeType() == GEOM::COMPOUND);
1335 MESSAGE("0 GEOM object selected");
1336 MESSAGE("Coords: ("<<x<<","<<y<<","<<z<<")");
1337 addEnforcedVertex(x, y, z, size, "", "", groupName);
1342 if ( CORBA::is_nil(getGeomEngine()))
1345 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
1346 if (CORBA::is_nil(measureOp))
1349 CORBA::Double x = 0, y = 0,z = 0;
1350 for (int j = 0 ; j < selEnfVertex ; j++)
1352 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j);
1353 if (myEnfVertex == GEOM::GEOM_Object::_nil())
1355 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1356 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1357 if ( measureOp->IsDone() )
1358 addEnforcedVertex(x, y, z, size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1359 } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) {
1360 addEnforcedVertex(0., 0., 0., size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName, true);
1365 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1367 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1368 myEnforcedTableWidget->resizeColumnToContents(column);
1371 /** HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedMesh()
1372 This method is called when a item is removed from the enforced meshes tree widget
1374 void HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedMesh()
1376 QList<int> selectedRows;
1377 QList<QTableWidgetItem *> selectedItems = myEnforcedMeshTableWidget->selectedItems();
1378 QTableWidgetItem* item;
1380 foreach( item, selectedItems ) {
1382 if (!selectedRows.contains( row ) )
1383 selectedRows.append(row);
1386 qSort( selectedRows );
1387 QListIterator<int> it( selectedRows );
1389 while ( it.hasPrevious() ) {
1390 row = it.previous();
1391 MESSAGE("delete row #"<< row);
1392 myEnforcedMeshTableWidget->removeRow(row );
1395 myEnforcedMeshTableWidget->selectionModel()->clearSelection();
1398 /** HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1399 This method is called when a item is removed from the enforced vertices tree widget
1401 void HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1403 QList<int> selectedRows;
1404 QList<QTableWidgetItem *> selectedItems = myEnforcedTableWidget->selectedItems();
1405 QTableWidgetItem* item;
1407 foreach( item, selectedItems ) {
1409 if (!selectedRows.contains( row ) )
1410 selectedRows.append(row);
1413 qSort( selectedRows );
1414 QListIterator<int> it( selectedRows );
1416 while ( it.hasPrevious() ) {
1417 row = it.previous();
1418 MESSAGE("delete row #"<< row);
1419 myEnforcedTableWidget->removeRow(row );
1422 myEnforcedTableWidget->selectionModel()->clearSelection();
1425 void HYBRIDPluginGUI_HypothesisCreator::onToMeshHoles(bool isOn)
1427 // myToMakeGroupsOfDomains->setEnabled( isOn );
1429 // myToMakeGroupsOfDomains->setChecked( false );
1432 void HYBRIDPluginGUI_HypothesisCreator::onDirBtnClicked()
1434 QString dir = SUIT_FileDlg::getExistingDirectory( dlg(), myAdvWidget->workingDirectoryLineEdit->text(), QString() );
1435 if ( !dir.isEmpty() )
1436 myAdvWidget->workingDirectoryLineEdit->setText( dir );
1439 void HYBRIDPluginGUI_HypothesisCreator::updateWidgets()
1441 //customs automatic set
1442 //myToMakeGroupsOfDomains->setEnabled( myToMeshHolesCheck->isChecked() );
1443 //myAdvWidget->maxMemorySpin->setEnabled( myAdvWidget->maxMemoryCheck->isChecked() );
1444 //myAdvWidget->initialMemoryCheck->setEnabled( !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1445 //myAdvWidget->initialMemorySpin->setEnabled( myAdvWidget->initialMemoryCheck->isChecked() && !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1446 //myOptimizationLevelCombo->setEnabled( !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1447 myMultinormalsAngleSpin->setEnabled( myAddMultinormalsCheck->isChecked() );
1448 if ( sender() == myAdvWidget->logInFileCheck ||
1449 sender() == myAdvWidget->keepWorkingFilesCheck )
1451 bool logFileRemovable = myAdvWidget->logInFileCheck->isChecked() &&
1452 !myAdvWidget->keepWorkingFilesCheck->isChecked();
1454 myAdvWidget->removeLogOnSuccessCheck->setEnabled( logFileRemovable );
1458 bool HYBRIDPluginGUI_HypothesisCreator::checkParams(QString& msg) const
1460 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::checkParams");
1462 if ( !QFileInfo( myAdvWidget->workingDirectoryLineEdit->text().trimmed() ).isWritable() ) {
1463 SUIT_MessageBox::warning( dlg(),
1464 tr( "SMESH_WRN_WARNING" ),
1465 tr( "HYBRID_PERMISSION_DENIED" ) );
1472 void HYBRIDPluginGUI_HypothesisCreator::retrieveParams() const
1474 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::retrieveParams");
1475 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1476 HYBRIDHypothesisData data;
1477 readParamsFromHypo( data );
1480 myName->setText( data.myName );
1482 myToMeshHolesCheck ->setChecked ( data.myToMeshHoles );
1483 myToMakeGroupsOfDomains ->setChecked ( data.myToMakeGroupsOfDomains );
1484 myOptimizationLevelCombo ->setCurrentIndex( data.myOptimizationLevel );
1485 myAdvWidget->maxMemoryCheck ->setChecked ( data.myMaximumMemory > 0 );
1486 myAdvWidget->maxMemorySpin ->setValue ( qMax( data.myMaximumMemory,
1487 myAdvWidget->maxMemorySpin->minimum() ));
1488 myAdvWidget->initialMemoryCheck ->setChecked ( data.myInitialMemory > 0 );
1489 myAdvWidget->initialMemorySpin ->setValue ( qMax( data.myInitialMemory,
1490 myAdvWidget->initialMemorySpin->minimum() ));
1492 myCollisionModeCombo ->setCurrentIndex( data.myCollisionMode );
1493 myBoundaryLayersGrowthCombo ->setCurrentIndex( data.myBoundaryLayersGrowth );
1494 myElementGenerationCombo ->setCurrentIndex( data.myElementGeneration );
1495 myAddMultinormalsCheck -> setChecked ( data.myAddMultinormals );
1496 mySmoothNormalsCheck -> setChecked ( data.mySmoothNormals );
1497 myHeightFirstLayerSpin -> setValue( data.myHeightFirstLayer );
1498 myNbOfBoundaryLayersSpin -> setValue( data.myNbOfBoundaryLayers );
1499 myBoundaryLayersProgressionSpin -> setValue( data.myBoundaryLayersProgression );
1500 myMultinormalsAngleSpin -> setValue( data.myMultinormalsAngle );
1502 myAdvWidget->workingDirectoryLineEdit ->setText ( data.myWorkingDir );
1503 myAdvWidget->keepWorkingFilesCheck ->setChecked ( data.myKeepFiles );
1504 myAdvWidget->verboseLevelSpin ->setValue ( data.myVerboseLevel );
1505 myAdvWidget->createNewNodesCheck ->setChecked ( data.myToCreateNewNodes );
1506 myAdvWidget->removeInitialCentralPointCheck ->setChecked ( data.myRemoveInitialCentralPoint );
1507 myAdvWidget->boundaryRecoveryCheck ->setChecked ( data.myBoundaryRecovery );
1508 myAdvWidget->FEMCorrectionCheck ->setChecked ( data.myFEMCorrection );
1509 myAdvWidget->gradationSpinBox ->setValue ( data.myGradation );
1510 myAdvWidget->textOptionLineEdit ->setText ( data.myTextOption );
1511 myAdvWidget->logInFileCheck ->setChecked ( !data.myLogInStandardOutput );
1512 myAdvWidget->removeLogOnSuccessCheck ->setChecked ( data.myRemoveLogOnSuccess );
1514 TEnfVertexList::const_iterator it;
1516 myEnforcedTableWidget->clearContents();
1517 myEnforcedTableWidget->setSortingEnabled(false);
1518 myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1519 for(it = data.myEnforcedVertices.begin() ; it != data.myEnforcedVertices.end(); it++ )
1521 TEnfVertex* enfVertex = (*it);
1522 myEnforcedTableWidget->setRowCount(rowCount+1);
1524 for (int col=0;col<ENF_VER_NB_COLUMNS;col++) {
1525 MESSAGE("Column: " << col);
1526 // MESSAGE("enfVertex->isCompound: " << enfVertex->isCompound);
1527 QTableWidgetItem* item = new QTableWidgetItem();
1528 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1530 case ENF_VER_NAME_COLUMN:
1531 item->setData( 0, enfVertex->name.c_str() );
1532 if (!enfVertex->geomEntry.empty()) {
1533 if (enfVertex->isCompound)
1534 item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1536 item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1538 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1541 case ENF_VER_X_COLUMN:
1542 if (!enfVertex->isCompound) {
1543 item->setData( 0, enfVertex->coords.at(0) );
1544 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1547 case ENF_VER_Y_COLUMN:
1548 if (!enfVertex->isCompound) {
1549 item->setData( 0, enfVertex->coords.at(1) );
1550 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1553 case ENF_VER_Z_COLUMN:
1554 if (!enfVertex->isCompound) {
1555 item->setData( 0, enfVertex->coords.at(2) );
1556 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1559 case ENF_VER_SIZE_COLUMN:
1560 item->setData( 0, enfVertex->size );
1561 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1563 case ENF_VER_ENTRY_COLUMN:
1564 item->setData( 0, enfVertex->geomEntry.c_str() );
1565 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1567 case ENF_VER_COMPOUND_COLUMN:
1568 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
1569 item->setData( Qt::CheckStateRole, enfVertex->isCompound );
1570 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << enfVertex->isCompound);
1572 case ENF_VER_GROUP_COLUMN:
1573 item->setData( 0, enfVertex->groupName.c_str() );
1574 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1580 myEnforcedTableWidget->setItem(rowCount,col,item);
1583 that->updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1587 connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1588 myEnforcedTableWidget->setSortingEnabled(true);
1590 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1591 myEnforcedTableWidget->resizeColumnToContents(column);
1593 // Update Enforced meshes QTableWidget
1594 TEnfMeshList::const_iterator itMesh;
1596 myEnforcedMeshTableWidget->clearContents();
1597 myEnforcedMeshTableWidget->setSortingEnabled(false);
1598 // myEnforcedMeshTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1599 for(itMesh = data.myEnforcedMeshes.begin() ; itMesh != data.myEnforcedMeshes.end(); itMesh++ )
1601 TEnfMesh* enfMesh = (*itMesh);
1602 myEnforcedMeshTableWidget->setRowCount(rowCount+1);
1604 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++) {
1605 MESSAGE("Column: " << col);
1606 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1607 QComboBox* comboBox = new QComboBox();
1608 QPalette pal = comboBox->palette();
1609 pal.setColor(QPalette::Button, Qt::white);
1610 comboBox->setPalette(pal);
1611 comboBox->insertItems(0,myEnfMeshConstraintLabels);
1612 comboBox->setEditable(false);
1613 comboBox->setCurrentIndex(enfMesh->elementType);
1614 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << comboBox->currentText().toStdString());
1615 myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox);
1618 QTableWidgetItem* item = new QTableWidgetItem();
1619 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1621 case ENF_MESH_NAME_COLUMN:
1622 item->setData( 0, enfMesh->name.c_str() );
1623 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1624 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1625 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1627 case ENF_MESH_ENTRY_COLUMN:
1628 item->setData( 0, enfMesh->entry.c_str() );
1629 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1630 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1631 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1633 case ENF_MESH_GROUP_COLUMN:
1634 item->setData( 0, enfMesh->groupName.c_str() );
1635 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1636 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1643 // myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1646 // that->updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1650 // connect( myEnforcedMeshTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1651 myEnforcedMeshTableWidget->setSortingEnabled(true);
1653 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++)
1654 myEnforcedMeshTableWidget->resizeColumnToContents(col);
1656 that->updateWidgets();
1657 that->checkVertexIsDefined();
1660 QString HYBRIDPluginGUI_HypothesisCreator::storeParams() const
1662 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::storeParams");
1663 HYBRIDHypothesisData data;
1664 readParamsFromWidgets( data );
1665 storeParamsToHypo( data );
1667 QString valStr = "";
1669 if ( !data.myBoundaryRecovery )
1670 valStr = "-c " + QString::number( !data.myToMeshHoles );
1672 if ( data.myOptimizationLevel >= 0 && data.myOptimizationLevel < 5 && !data.myBoundaryRecovery) {
1673 const char* level[] = { "none" , "light" , "standard" , "standard+" , "strong" };
1675 valStr += level[ data.myOptimizationLevel ];
1677 if ( data.myMaximumMemory > 0 ) {
1679 valStr += QString::number( data.myMaximumMemory );
1681 if ( data.myInitialMemory > 0 && !data.myBoundaryRecovery ) {
1683 valStr += QString::number( data.myInitialMemory );
1686 valStr += QString::number( data.myVerboseLevel );
1688 if ( !data.myToCreateNewNodes )
1691 if ( data.myRemoveInitialCentralPoint )
1692 valStr += " -no_initial_central_point";
1694 if ( data.myBoundaryRecovery )
1697 if ( data.myFEMCorrection )
1700 if ( data.myGradation != 1.05 ) {
1701 valStr += " -Dcpropa=";
1702 valStr += QString::number( data.myGradation );
1706 valStr += data.myTextOption;
1708 // valStr += " #BEGIN ENFORCED VERTICES#";
1709 // // Add size map parameters storage
1710 // for (int i=0 ; i<mySmpModel->rowCount() ; i++) {
1712 // double x = mySmpModel->data(mySmpModel->index(i,ENF_VER_X_COLUMN)).toDouble();
1713 // double y = mySmpModel->data(mySmpModel->index(i,ENF_VER_Y_COLUMN)).toDouble();
1714 // double z = mySmpModel->data(mySmpModel->index(i,ENF_VER_Z_COLUMN)).toDouble();
1715 // double size = mySmpModel->data(mySmpModel->index(i,ENF_VER_SIZE_COLUMN)).toDouble();
1716 // valStr += QString::number( x );
1718 // valStr += QString::number( y );
1720 // valStr += QString::number( z );
1722 // valStr += QString::number( size );
1723 // if (i!=mySmpModel->rowCount()-1)
1726 // valStr += " #END ENFORCED VERTICES#";
1727 // MESSAGE(valStr.toStdString());
1731 bool HYBRIDPluginGUI_HypothesisCreator::readParamsFromHypo( HYBRIDHypothesisData& h_data ) const
1733 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::readParamsFromHypo");
1734 HYBRIDPlugin::HYBRIDPlugin_Hypothesis_var h =
1735 HYBRIDPlugin::HYBRIDPlugin_Hypothesis::_narrow( initParamsHypothesis() );
1737 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
1738 h_data.myName = isCreation() && data ? hypName() : "";
1740 h_data.myToMeshHoles = h->GetToMeshHoles();
1741 h_data.myToMakeGroupsOfDomains = /*h->GetToMeshHoles() &&*/ h->GetToMakeGroupsOfDomains();
1742 h_data.myMaximumMemory = h->GetMaximumMemory();
1743 h_data.myInitialMemory = h->GetInitialMemory();
1744 h_data.myInitialMemory = h->GetInitialMemory();
1745 h_data.myOptimizationLevel = h->GetOptimizationLevel();
1747 h_data.myCollisionMode = h->GetCollisionMode();
1748 h_data.myBoundaryLayersGrowth = h->GetBoundaryLayersGrowth();
1749 h_data.myElementGeneration = h->GetElementGeneration();
1750 h_data.myAddMultinormals = h->GetAddMultinormals();
1751 h_data.mySmoothNormals = h->GetSmoothNormals();
1752 h_data.myHeightFirstLayer = h->GetHeightFirstLayer();
1753 h_data.myBoundaryLayersProgression = h->GetBoundaryLayersProgression();
1754 h_data.myMultinormalsAngle = h->GetMultinormalsAngle();
1755 h_data.myNbOfBoundaryLayers = h->GetNbOfBoundaryLayers();
1757 h_data.myKeepFiles = h->GetKeepFiles();
1758 h_data.myWorkingDir = h->GetWorkingDirectory();
1759 h_data.myVerboseLevel = h->GetVerboseLevel();
1760 h_data.myToCreateNewNodes = h->GetToCreateNewNodes();
1761 h_data.myRemoveInitialCentralPoint = h->GetToRemoveCentralPoint();
1762 h_data.myBoundaryRecovery = h->GetToUseBoundaryRecoveryVersion();
1763 h_data.myFEMCorrection = h->GetFEMCorrection();
1764 h_data.myGradation = h->GetGradation();
1765 h_data.myTextOption = h->GetTextOption();
1766 h_data.myLogInStandardOutput = h->GetStandardOutputLog();
1767 h_data.myRemoveLogOnSuccess = h->GetRemoveLogOnSuccess();
1769 HYBRIDPlugin::HYBRIDEnforcedVertexList_var vertices = h->GetEnforcedVertices();
1770 MESSAGE("vertices->length(): " << vertices->length());
1771 h_data.myEnforcedVertices.clear();
1772 for (int i=0 ; i<vertices->length() ; i++) {
1773 TEnfVertex* myVertex = new TEnfVertex();
1774 myVertex->name = CORBA::string_dup(vertices[i].name.in());
1775 myVertex->geomEntry = CORBA::string_dup(vertices[i].geomEntry.in());
1776 myVertex->groupName = CORBA::string_dup(vertices[i].groupName.in());
1777 myVertex->size = vertices[i].size;
1778 myVertex->isCompound = vertices[i].isCompound;
1779 if (vertices[i].coords.length()) {
1780 for (int c = 0; c < vertices[i].coords.length() ; c++)
1781 myVertex->coords.push_back(vertices[i].coords[c]);
1782 MESSAGE("Add enforced vertex ("<< myVertex->coords.at(0) << ","<< myVertex->coords.at(1) << ","<< myVertex->coords.at(2) << ") ="<< myVertex->size);
1784 h_data.myEnforcedVertices.insert(myVertex);
1787 HYBRIDPlugin::HYBRIDEnforcedMeshList_var enfMeshes = h->GetEnforcedMeshes();
1788 MESSAGE("enfMeshes->length(): " << enfMeshes->length());
1789 h_data.myEnforcedMeshes.clear();
1790 for (int i=0 ; i<enfMeshes->length() ; i++) {
1791 TEnfMesh* myEnfMesh = new TEnfMesh();
1792 myEnfMesh->name = CORBA::string_dup(enfMeshes[i].name.in());
1793 myEnfMesh->entry = CORBA::string_dup(enfMeshes[i].entry.in());
1794 myEnfMesh->groupName = CORBA::string_dup(enfMeshes[i].groupName.in());
1795 switch (enfMeshes[i].elementType) {
1797 myEnfMesh->elementType = 0;
1800 myEnfMesh->elementType = 1;
1803 myEnfMesh->elementType = 2;
1808 // myEnfMesh->elementType = enfMeshes[i].elementType;
1809 h_data.myEnforcedMeshes.insert(myEnfMesh);
1814 bool HYBRIDPluginGUI_HypothesisCreator::storeParamsToHypo( const HYBRIDHypothesisData& h_data ) const
1816 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::storeParamsToHypo");
1817 HYBRIDPlugin::HYBRIDPlugin_Hypothesis_var h =
1818 HYBRIDPlugin::HYBRIDPlugin_Hypothesis::_narrow( hypothesis() );
1824 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
1826 if ( h->GetToMeshHoles() != h_data.myToMeshHoles ) // avoid duplication of DumpPython commands
1827 h->SetToMeshHoles ( h_data.myToMeshHoles );
1828 if ( h->GetToMakeGroupsOfDomains() != h_data.myToMakeGroupsOfDomains )
1829 h->SetToMakeGroupsOfDomains( h_data.myToMakeGroupsOfDomains );
1830 if ( h->GetMaximumMemory() != h_data.myMaximumMemory )
1831 h->SetMaximumMemory ( h_data.myMaximumMemory );
1832 if ( h->GetInitialMemory() != h_data.myInitialMemory )
1833 h->SetInitialMemory ( h_data.myInitialMemory );
1834 if ( h->GetInitialMemory() != h_data.myInitialMemory )
1835 h->SetInitialMemory ( h_data.myInitialMemory );
1836 if ( h->GetOptimizationLevel() != h_data.myOptimizationLevel )
1837 h->SetOptimizationLevel( h_data.myOptimizationLevel );
1839 if ( h->GetCollisionMode() != h_data.myCollisionMode )
1840 h->SetCollisionMode( h_data.myCollisionMode );
1841 if ( h->GetBoundaryLayersGrowth() != h_data.myBoundaryLayersGrowth )
1842 h->SetBoundaryLayersGrowth( h_data.myBoundaryLayersGrowth );
1843 if ( h->GetElementGeneration() != h_data.myElementGeneration )
1844 h->SetElementGeneration( h_data.myElementGeneration );
1846 if ( h->GetAddMultinormals() != h_data.myAddMultinormals )
1847 h->SetAddMultinormals ( h_data.myAddMultinormals );
1848 if ( h->GetSmoothNormals() != h_data.mySmoothNormals )
1849 h->SetSmoothNormals ( h_data.mySmoothNormals );
1850 if ( h->GetHeightFirstLayer() != h_data.myHeightFirstLayer )
1851 h->SetHeightFirstLayer ( h_data.myHeightFirstLayer );
1852 if ( h->GetBoundaryLayersProgression() != h_data.myBoundaryLayersProgression )
1853 h->SetBoundaryLayersProgression ( h_data.myBoundaryLayersProgression );
1854 if ( h->GetMultinormalsAngle() != h_data.myMultinormalsAngle )
1855 h->SetMultinormalsAngle ( h_data.myMultinormalsAngle );
1856 if ( h->GetNbOfBoundaryLayers() != h_data.myNbOfBoundaryLayers )
1857 h->SetNbOfBoundaryLayers ( h_data.myNbOfBoundaryLayers );
1859 if ( h->GetKeepFiles() != h_data.myKeepFiles)
1860 h->SetKeepFiles ( h_data.myKeepFiles);
1861 if ( h->GetWorkingDirectory() != h_data.myWorkingDir )
1862 h->SetWorkingDirectory ( h_data.myWorkingDir.toLatin1().constData() );
1863 if ( h->GetVerboseLevel() != h_data.myVerboseLevel )
1864 h->SetVerboseLevel ( h_data.myVerboseLevel );
1865 if ( h->GetToCreateNewNodes() != h_data.myToCreateNewNodes )
1866 h->SetToCreateNewNodes ( h_data.myToCreateNewNodes );
1867 if ( h->GetToRemoveCentralPoint() != h_data.myRemoveInitialCentralPoint )
1868 h->SetToRemoveCentralPoint ( h_data.myRemoveInitialCentralPoint );
1869 if ( h->GetToUseBoundaryRecoveryVersion() != h_data.myBoundaryRecovery )
1870 h->SetToUseBoundaryRecoveryVersion ( h_data.myBoundaryRecovery );
1871 if ( h->GetFEMCorrection() != h_data.myFEMCorrection )
1872 h->SetFEMCorrection ( h_data.myFEMCorrection );
1873 if ( h->GetGradation() != h_data.myGradation )
1874 h->SetGradation ( h_data.myGradation );
1875 if ( h->GetTextOption() != h_data.myTextOption )
1876 h->SetTextOption ( h_data.myTextOption.toLatin1().constData() );
1877 if ( h->GetStandardOutputLog() != h_data.myLogInStandardOutput )
1878 h->SetStandardOutputLog ( h_data.myLogInStandardOutput );
1879 if ( h->GetRemoveLogOnSuccess() != h_data.myRemoveLogOnSuccess )
1880 h->SetRemoveLogOnSuccess ( h_data.myRemoveLogOnSuccess );
1882 // Enforced vertices
1883 int nbVertex = (int) h_data.myEnforcedVertices.size();
1884 HYBRIDPlugin::HYBRIDEnforcedVertexList_var vertexHyp = h->GetEnforcedVertices();
1885 int nbVertexHyp = vertexHyp->length();
1887 MESSAGE("Store params for size maps: " << nbVertex << " enforced vertices");
1888 MESSAGE("h->GetEnforcedVertices()->length(): " << nbVertexHyp);
1890 // 1. Clear all enforced vertices in hypothesis
1891 // 2. Add new enforced vertex according to h_data
1892 if ( nbVertexHyp > 0)
1893 h->ClearEnforcedVertices();
1895 TEnfVertexList::const_iterator it;
1896 double x = 0, y = 0, z = 0;
1897 for(it = h_data.myEnforcedVertices.begin() ; it != h_data.myEnforcedVertices.end(); it++ ) {
1898 TEnfVertex* enfVertex = (*it);
1900 if (enfVertex->coords.size()) {
1901 x = enfVertex->coords.at(0);
1902 y = enfVertex->coords.at(1);
1903 z = enfVertex->coords.at(2);
1905 ok = h->p_SetEnforcedVertex( enfVertex->size, x, y, z, enfVertex->name.c_str(), enfVertex->geomEntry.c_str(), enfVertex->groupName.c_str(), enfVertex->isCompound);
1909 int nbEnfMeshes = (int) h_data.myEnforcedMeshes.size();
1910 HYBRIDPlugin::HYBRIDEnforcedMeshList_var enfMeshListHyp = h->GetEnforcedMeshes();
1911 int nbEnfMeshListHyp = enfMeshListHyp->length();
1913 MESSAGE("Store params for size maps: " << nbEnfMeshes << " enforced meshes");
1914 MESSAGE("h->GetEnforcedMeshes()->length(): " << nbEnfMeshListHyp);
1916 // 1. Clear all enforced vertices in hypothesis
1917 // 2. Add new enforced vertex according to h_data
1918 if ( nbEnfMeshListHyp > 0)
1919 h->ClearEnforcedMeshes();
1921 TEnfMeshList::const_iterator itEnfMesh;
1923 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1925 for(itEnfMesh = h_data.myEnforcedMeshes.begin() ; itEnfMesh != h_data.myEnforcedMeshes.end(); itEnfMesh++ ) {
1926 TEnfMesh* enfMesh = (*itEnfMesh);
1928 _PTR(SObject) aSObj = aStudy->FindObjectID(enfMesh->entry.c_str());
1929 SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1931 MESSAGE("enfMesh->elementType: " << enfMesh->elementType);
1932 SMESH::ElementType elementType;
1933 switch(enfMesh->elementType) {
1935 elementType = SMESH::NODE;
1938 elementType = SMESH::EDGE;
1941 elementType = SMESH::FACE;
1947 std::cout << "h->p_SetEnforcedMesh(theSource, "<< elementType <<", \""<< enfMesh->name << "\", \"" << enfMesh->groupName.c_str() <<"\")"<<std::endl;
1948 ok = h->p_SetEnforcedMesh(theSource, elementType, enfMesh->name.c_str(), enfMesh->groupName.c_str());
1951 // catch(const std::exception& ex) {
1952 // std::cout << "Exception: " << ex.what() << std::endl;
1955 catch ( const SALOME::SALOME_Exception& ex )
1957 SalomeApp_Tools::QtCatchCorbaException( ex );
1963 bool HYBRIDPluginGUI_HypothesisCreator::readParamsFromWidgets( HYBRIDHypothesisData& h_data ) const
1965 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::readParamsFromWidgets");
1966 h_data.myName = myName ? myName->text() : "";
1967 h_data.myToMeshHoles = myToMeshHolesCheck->isChecked();
1968 h_data.myToMakeGroupsOfDomains = myToMakeGroupsOfDomains->isChecked();
1969 h_data.myMaximumMemory = myAdvWidget->maxMemoryCheck->isChecked() ? myAdvWidget->maxMemorySpin->value() : -1;
1970 h_data.myInitialMemory = myAdvWidget->initialMemoryCheck->isChecked() ? myAdvWidget->initialMemorySpin->value() : -1;
1971 h_data.myOptimizationLevel = myOptimizationLevelCombo->currentIndex();
1973 h_data.myCollisionMode = myCollisionModeCombo->currentIndex();
1974 h_data.myBoundaryLayersGrowth = myBoundaryLayersGrowthCombo->currentIndex();
1975 h_data.myElementGeneration = myElementGenerationCombo->currentIndex();
1976 h_data.myAddMultinormals = myAddMultinormalsCheck->isChecked();
1977 h_data.mySmoothNormals = mySmoothNormalsCheck->isChecked();
1979 h_data.myHeightFirstLayer = myHeightFirstLayerSpin -> value();
1980 h_data.myNbOfBoundaryLayers = myNbOfBoundaryLayersSpin -> value();
1981 h_data.myBoundaryLayersProgression = myBoundaryLayersProgressionSpin -> value();
1982 h_data.myMultinormalsAngle = myMultinormalsAngleSpin -> value();
1984 h_data.myKeepFiles = myAdvWidget->keepWorkingFilesCheck->isChecked();
1985 h_data.myWorkingDir = myAdvWidget->workingDirectoryLineEdit->text().trimmed();
1986 h_data.myVerboseLevel = myAdvWidget->verboseLevelSpin->value();
1987 h_data.myToCreateNewNodes = myAdvWidget->createNewNodesCheck->isChecked();
1988 h_data.myRemoveInitialCentralPoint = myAdvWidget->removeInitialCentralPointCheck->isChecked();
1989 h_data.myBoundaryRecovery = myAdvWidget->boundaryRecoveryCheck->isChecked();
1990 h_data.myFEMCorrection = myAdvWidget->FEMCorrectionCheck->isChecked();
1991 h_data.myGradation = myAdvWidget->gradationSpinBox->value();
1992 h_data.myTextOption = myAdvWidget->textOptionLineEdit->text();
1993 h_data.myLogInStandardOutput = !myAdvWidget->logInFileCheck->isChecked();
1994 h_data.myRemoveLogOnSuccess = myAdvWidget->removeLogOnSuccessCheck->isChecked();
1996 // Enforced vertices
1997 h_data.myEnforcedVertices.clear();
1998 QVariant valueX, valueY, valueZ;
1999 for (int row=0 ; row<myEnforcedTableWidget->rowCount() ; row++) {
2001 TEnfVertex *myVertex = new TEnfVertex();
2002 myVertex->name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString();
2003 MESSAGE("Add new enforced vertex \"" << myVertex->name << "\"" );
2004 myVertex->geomEntry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString();
2005 if (myVertex->geomEntry.size())
2006 MESSAGE("Geom entry is \"" << myVertex->geomEntry << "\"" );
2007 myVertex->groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
2008 if (myVertex->groupName.size())
2009 MESSAGE("Group name is \"" << myVertex->groupName << "\"" );
2010 valueX = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data(Qt::EditRole);
2011 valueY = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data(Qt::EditRole);
2012 valueZ = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data(Qt::EditRole);
2013 if (!valueX.isNull() && !valueY.isNull() && !valueZ.isNull()) {
2014 myVertex->coords.push_back(valueX.toDouble());
2015 myVertex->coords.push_back(valueY.toDouble());
2016 myVertex->coords.push_back(valueZ.toDouble());
2017 MESSAGE("Coords are (" << myVertex->coords.at(0) << ", "
2018 << myVertex->coords.at(1) << ", "
2019 << myVertex->coords.at(2) << ")");
2021 myVertex->size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data(Qt::EditRole).toDouble();
2022 MESSAGE("Size is " << myVertex->size);
2023 myVertex->isCompound = myEnforcedTableWidget->item(row,ENF_VER_COMPOUND_COLUMN)->data(Qt::CheckStateRole).toBool();
2024 MESSAGE("Is compound ? " << myVertex->isCompound);
2025 h_data.myEnforcedVertices.insert(myVertex);
2029 h_data.myEnforcedMeshes.clear();
2031 for (int row=0 ; row<myEnforcedMeshTableWidget->rowCount() ; row++) {
2033 TEnfMesh *myEnfMesh = new TEnfMesh();
2034 myEnfMesh->name = myEnforcedMeshTableWidget->item(row,ENF_MESH_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString();
2035 MESSAGE("Add new enforced mesh \"" << myEnfMesh->name << "\"" );
2036 myEnfMesh->entry = myEnforcedMeshTableWidget->item(row,ENF_MESH_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString();
2037 MESSAGE("Entry is \"" << myEnfMesh->entry << "\"" );
2038 myEnfMesh->groupName = myEnforcedMeshTableWidget->item(row,ENF_MESH_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
2039 MESSAGE("Group name is \"" << myEnfMesh->groupName << "\"" );
2040 QComboBox* combo = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row,ENF_MESH_CONSTRAINT_COLUMN));
2041 myEnfMesh->elementType = combo->currentIndex();
2042 MESSAGE("Element type: " << myEnfMesh->elementType);
2043 h_data.myEnforcedMeshes.insert(myEnfMesh);
2044 std::cout << "h_data.myEnforcedMeshes.size(): " << h_data.myEnforcedMeshes.size() << std::endl;
2050 QString HYBRIDPluginGUI_HypothesisCreator::caption() const
2052 return tr( "HYBRID_TITLE" );
2055 QPixmap HYBRIDPluginGUI_HypothesisCreator::icon() const
2057 return SUIT_Session::session()->resourceMgr()->loadPixmap( "HYBRIDPlugin", tr( "ICON_DLG_HYBRID_PARAMETERS" ) );
2060 QString HYBRIDPluginGUI_HypothesisCreator::type() const
2062 return tr( "HYBRID_HYPOTHESIS" );
2065 QString HYBRIDPluginGUI_HypothesisCreator::helpPage() const
2067 return "hybrid_hypo_page.html";