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 QLabel* aLabel = new QLabel( tr( "HYBRID_BOUNDARY_LAYERS_GROWTH" ), myStdGroup );
409 aLabel->setToolTip(tr( "HYBRID_BOUNDARY_LAYERS_HELP" ));
410 aStdLayout->addWidget( aLabel, row, 0, 1, 1 );
411 myBoundaryLayersGrowthCombo = new QComboBox( myStdGroup );
412 myBoundaryLayersGrowthCombo->setToolTip(tr( "HYBRID_BOUNDARY_LAYERS_HELP" ));
414 aStdLayout->addWidget( myBoundaryLayersGrowthCombo, row++, 1, 1, 1 );
416 QStringList typesBoundaryLayersGrowth;
417 typesBoundaryLayersGrowth << tr( "HYBRID_LAYER_GROWTH_UPWARD" ) << tr( "HYBRID_LAYER_GROWTH_DOWNWARD" );
418 myBoundaryLayersGrowthCombo->addItems( typesBoundaryLayersGrowth );
420 aStdLayout->addWidget( new QLabel( tr( "HYBRID_HeightFirstLayer" ), myStdGroup ), row, 0, 1, 1 );
421 myHeightFirstLayerSpin = new SMESHGUI_SpinBox( myStdGroup );
422 myHeightFirstLayerSpin->RangeStepAndValidator(0., 100., .1, "HeightFirstLayer");
423 aStdLayout->addWidget( myHeightFirstLayerSpin, row++, 1, 1, 1 );
425 aStdLayout->addWidget( new QLabel( tr( "HYBRID_NbOfBoundaryLayers" ), myStdGroup ), row, 0, 1, 1 );
426 myNbOfBoundaryLayersSpin = new QSpinBox( myStdGroup );
427 aStdLayout->addWidget( myNbOfBoundaryLayersSpin, row++, 1, 1, 1 );
429 aStdLayout->addWidget( new QLabel( tr( "HYBRID_BoundaryLayersProgression" ), myStdGroup ), row, 0, 1, 1 );
430 myBoundaryLayersProgressionSpin = new SMESHGUI_SpinBox( myStdGroup );
431 myBoundaryLayersProgressionSpin->RangeStepAndValidator(0., 10., .1, "BoundaryLayersProgression");
432 aStdLayout->addWidget( myBoundaryLayersProgressionSpin, row++, 1, 1, 1 );
434 aStdLayout->addWidget( new QLabel( tr( "COLLISION_MODE" ), myStdGroup ), row, 0, 1, 1 );
435 myCollisionModeCombo = new QComboBox( myStdGroup );
436 aStdLayout->addWidget( myCollisionModeCombo, row++, 1, 1, 1 );
438 QStringList typescoll;
439 typescoll << tr( "COLLISION_DECREASE" ) << tr( "COLLISION_STOP" );
440 myCollisionModeCombo->addItems( typescoll );
442 aStdLayout->addWidget( new QLabel( tr( "HYBRID_GENERATION_ELEMENT" ), myStdGroup ), row, 0, 1, 1 );
443 myElementGenerationCombo = new QComboBox( myStdGroup );
444 aStdLayout->addWidget( myElementGenerationCombo, row++, 1, 1, 1 );
446 QStringList typesElementGeneration;
447 typesElementGeneration << tr( "HYBRID_GENERATION_TETRA_DOMINANT" ) << tr( "HYBRID_GENERATION_HEXA_DOMINANT" );
448 myElementGenerationCombo->addItems( typesElementGeneration );
450 myAddMultinormalsCheck = new QCheckBox( tr( "HYBRID_ADD_MULTINORMALS" ), myStdGroup );
451 aStdLayout->addWidget( myAddMultinormalsCheck, row++, 0, 1, 1 );
453 aStdLayout->addWidget( new QLabel( tr( "HYBRID_MULTINORMAL_ANGLE" ), myStdGroup ), row, 0, 1, 1 );
454 myMultinormalsAngleSpin = new SMESHGUI_SpinBox( myStdGroup );
455 myMultinormalsAngleSpin->RangeStepAndValidator(0., 90., 2., "threshold");
456 aStdLayout->addWidget( myMultinormalsAngleSpin, row++, 1, 1, 1 );
458 mySmoothNormalsCheck = new QCheckBox( tr( "HYBRID_SMOOTH_NORMALS" ), myStdGroup );
459 aStdLayout->addWidget( mySmoothNormalsCheck, row++, 0, 1, 1 );
460 aStdLayout->setRowStretch( row, 10 );
462 // advanced parameters
463 myAdvGroup = new QWidget();
464 QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup );
465 anAdvLayout->setSpacing( 6 );
466 anAdvLayout->setMargin( 11 );
467 myAdvWidget = new HYBRIDPluginGUI_AdvWidget(myAdvGroup);
468 anAdvLayout->addWidget( myAdvWidget);
470 myAdvWidget->maxMemoryCheck->setText(tr( "MAX_MEMORY_SIZE" ));
471 myAdvWidget->initialMemoryCheck->setText(tr( "INIT_MEMORY_SIZE" ));
473 myAdvWidget->maxMemorySpin->RangeStepAndValidator(20.0, 1e6, 10.0);
474 myAdvWidget->maxMemorySpin->setValue( 128.0 );
476 myAdvWidget->initialMemorySpin->RangeStepAndValidator(0.0, 1e6, 10.0);
477 myAdvWidget->initialMemorySpin->setValue( 100.0 );
479 myAdvWidget->initialMemoryLabel ->setText (tr( "MEGABYTE" ));
480 myAdvWidget->maxMemoryLabel ->setText (tr( "MEGABYTE" ));
482 myAdvWidget->workingDirectoryPushButton ->setText (tr( "SELECT_DIR" ));
483 myAdvWidget->keepWorkingFilesCheck ->setText (tr( "KEEP_WORKING_FILES" ));
484 myAdvWidget->verboseLevelLabel ->setText (tr( "VERBOSE_LEVEL" ));
485 myAdvWidget->removeLogOnSuccessCheck ->setText (tr( "REMOVE_LOG_ON_SUCCESS" ));
486 myAdvWidget->logInFileCheck ->setText (tr( "LOG_IN_FILE" ));
488 myAdvWidget->memoryGroupBox ->setTitle(tr( "MEMORY_GROUP_TITLE" ));
489 myAdvWidget->logGroupBox ->setTitle(tr( "LOG_GROUP_TITLE" ));
490 myAdvWidget->advancedMeshingGroupBox ->setTitle(tr( "ADVANCED_MESHING_GROUP_TITLE" ));
492 myAdvWidget->memoryGroupBox->hide();
494 myAdvWidget->createNewNodesCheck->hide();
495 //myAdvWidget->createNewNodesLabel->hide();
496 myAdvWidget->removeInitialCentralPointCheck->hide();
497 myAdvWidget->boundaryRecoveryCheck->hide();
498 myAdvWidget->FEMCorrectionCheck->hide();
499 myAdvWidget->gradationLabel->hide();
500 myAdvWidget->gradationSpinBox->hide();
502 myAdvWidget->createNewNodesCheck ->setText (tr( "TO_ADD_NODES" ));
503 myAdvWidget->removeInitialCentralPointCheck->setText (tr( "NO_INITIAL_CENTRAL_POINT" ));
504 myAdvWidget->boundaryRecoveryCheck ->setText (tr( "RECOVERY_VERSION" ));
505 myAdvWidget->FEMCorrectionCheck ->setText (tr( "FEM_CORRECTION" ));
506 myAdvWidget->gradationLabel ->setText (tr( "HYBRID_GRADATION" ));
507 myAdvWidget->gradationSpinBox->RangeStepAndValidator(1.05, 5.0, 0.05, "length_precision");
508 myAdvWidget->textOptionLabel->setText(tr( "TEXT_OPTION" ));
510 // Enforced vertices parameters
511 myEnfGroup = new QWidget();
512 QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup);
514 myEnforcedTableWidget = new QTableWidget(myEnfGroup);
515 myEnforcedTableWidget ->setMinimumWidth(300);
516 myEnforcedTableWidget->setRowCount( 0 );
517 myEnforcedTableWidget->setColumnCount( ENF_VER_NB_COLUMNS );
518 myEnforcedTableWidget->setSortingEnabled(true);
519 QStringList enforcedHeaders;
520 enforcedHeaders << tr( "HYBRID_ENF_NAME_COLUMN" )
521 << tr( "HYBRID_ENF_VER_X_COLUMN" )<< tr( "HYBRID_ENF_VER_Y_COLUMN" ) << tr( "HYBRID_ENF_VER_Z_COLUMN" )
522 << tr( "HYBRID_ENF_SIZE_COLUMN" ) << tr("HYBRID_ENF_ENTRY_COLUMN") << tr("HYBRID_ENF_VER_COMPOUND_COLUMN") << tr( "HYBRID_ENF_GROUP_COLUMN" );
524 myEnforcedTableWidget->setHorizontalHeaderLabels(enforcedHeaders);
525 myEnforcedTableWidget->verticalHeader()->hide();
526 myEnforcedTableWidget->horizontalHeader()->setStretchLastSection(true);
527 myEnforcedTableWidget->setAlternatingRowColors(true);
528 myEnforcedTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
529 myEnforcedTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
530 myEnforcedTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
531 myEnforcedTableWidget->resizeColumnsToContents();
532 myEnforcedTableWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
533 myEnforcedTableWidget->hideColumn(ENF_VER_COMPOUND_COLUMN);
535 myEnforcedTableWidget->setItemDelegate(new EnforcedVertexTableWidgetDelegate());
538 TColStd_MapOfInteger shapeTypes;
539 shapeTypes.Add( TopAbs_VERTEX );
540 shapeTypes.Add( TopAbs_COMPOUND );
542 SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes);
543 myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true, /*stretch=*/false);
544 myEnfVertexWdg->SetDefaultText(tr("HYBRID_ENF_SELECT_VERTEX"), "QLineEdit { color: grey }");
546 QLabel* myXCoordLabel = new QLabel( tr( "HYBRID_ENF_VER_X_LABEL" ), myEnfGroup );
547 myXCoord = new SMESHGUI_SpinBox(myEnfGroup);
548 myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
549 QLabel* myYCoordLabel = new QLabel( tr( "HYBRID_ENF_VER_Y_LABEL" ), myEnfGroup );
550 myYCoord = new SMESHGUI_SpinBox(myEnfGroup);
551 myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
552 QLabel* myZCoordLabel = new QLabel( tr( "HYBRID_ENF_VER_Z_LABEL" ), myEnfGroup );
553 myZCoord = new SMESHGUI_SpinBox(myEnfGroup);
554 myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
555 QLabel* mySizeLabel = new QLabel( tr( "HYBRID_ENF_SIZE_LABEL" ), myEnfGroup );
556 mySizeValue = new SMESHGUI_SpinBox(myEnfGroup);
557 mySizeValue->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
559 QLabel* myGroupNameLabel = new QLabel( tr( "HYBRID_ENF_GROUP_LABEL" ), myEnfGroup );
560 myGroupName = new QLineEdit(myEnfGroup);
562 addVertexButton = new QPushButton(tr("HYBRID_ENF_ADD"),myEnfGroup);
563 addVertexButton->setEnabled(false);
564 removeVertexButton = new QPushButton(tr("HYBRID_ENF_REMOVE"),myEnfGroup);
565 // myGlobalGroupName = new QCheckBox(tr("HYBRID_ENF_VER_GROUPS"), myEnfGroup);
566 // myGlobalGroupName->setChecked(false);
568 // QGroupBox* GroupBox = new QGroupBox( myEnfGroup );
569 // QLabel* info = new QLabel( GroupBox );
570 // info->setText( tr( "HYBRID_ENF_VER_INFO" ) );
571 // info->setWordWrap( true );
572 // QVBoxLayout* GroupBoxVLayout = new QVBoxLayout( GroupBox );
573 // GroupBoxVLayout->setSpacing( 6 );
574 // GroupBoxVLayout->setMargin( 11 );
575 // GroupBoxVLayout->addWidget( info );
578 //anEnfLayout->addWidget(GroupBox, ENF_VER_WARNING, 0, 1, 2 );
579 anEnfLayout->addWidget(myEnforcedTableWidget, ENF_VER_VERTEX, 0, ENF_VER_NB_LINES, 1);
581 QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup);
582 anEnfLayout2->addWidget(myEnfVertexWdg, ENF_VER_VERTEX, 0, 1, 2);
583 anEnfLayout2->addWidget(myXCoordLabel, ENF_VER_X_COORD, 0, 1, 1);
584 anEnfLayout2->addWidget(myXCoord, ENF_VER_X_COORD, 1, 1, 1);
585 anEnfLayout2->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 0, 1, 1);
586 anEnfLayout2->addWidget(myYCoord, ENF_VER_Y_COORD, 1, 1, 1);
587 anEnfLayout2->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 0, 1, 1);
588 anEnfLayout2->addWidget(myZCoord, ENF_VER_Z_COORD, 1, 1, 1);
589 anEnfLayout2->addWidget(mySizeLabel, ENF_VER_SIZE, 0, 1, 1);
590 anEnfLayout2->addWidget(mySizeValue, ENF_VER_SIZE, 1, 1, 1);
591 anEnfLayout2->addWidget(myGroupNameLabel, ENF_VER_GROUP, 0, 1, 1);
592 anEnfLayout2->addWidget(myGroupName, ENF_VER_GROUP, 1, 1, 1);
593 anEnfLayout2->addWidget(addVertexButton, ENF_VER_BTN, 0, 1, 1);
594 anEnfLayout2->addWidget(removeVertexButton, ENF_VER_BTN, 1, 1, 1);
595 anEnfLayout2->setRowStretch(ENF_VER_NB_LINES, 1);
597 anEnfLayout->addLayout(anEnfLayout2, ENF_VER_VERTEX, 1,ENF_VER_NB_LINES, 1);
598 anEnfLayout->setRowStretch(ENF_VER_VERTEX, 10);
600 // Enforced meshes parameters
601 myEnfMeshGroup = new QWidget();
602 QGridLayout* anEnfMeshLayout = new QGridLayout(myEnfMeshGroup);
604 myEnforcedMeshTableWidget = new QTableWidget(myEnfGroup);
605 myEnforcedMeshTableWidget->setRowCount( 0 );
606 myEnforcedMeshTableWidget->setColumnCount( ENF_MESH_NB_COLUMNS );
607 myEnforcedMeshTableWidget->setSortingEnabled(true);
608 myEnforcedMeshTableWidget->verticalHeader()->hide();
609 QStringList enforcedMeshHeaders;
610 enforcedMeshHeaders << tr( "HYBRID_ENF_NAME_COLUMN" )
611 << tr( "HYBRID_ENF_ENTRY_COLUMN" )
612 << tr( "HYBRID_ENF_MESH_CONSTRAINT_COLUMN" )
613 << tr( "HYBRID_ENF_GROUP_COLUMN" );
614 myEnforcedMeshTableWidget->setHorizontalHeaderLabels(enforcedMeshHeaders);
615 myEnforcedMeshTableWidget->horizontalHeader()->setStretchLastSection(true);
616 myEnforcedMeshTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
617 myEnforcedMeshTableWidget->setAlternatingRowColors(true);
618 myEnforcedMeshTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
619 myEnforcedMeshTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
620 myEnforcedMeshTableWidget->resizeColumnsToContents();
621 myEnforcedMeshTableWidget->hideColumn(ENF_MESH_ENTRY_COLUMN);
623 myEnforcedMeshTableWidget->setItemDelegate(new EnforcedMeshTableWidgetDelegate());
625 // myEnfMesh = SMESH::SMESH_Mesh::_nil();
626 // myEnfMeshArray = new SMESH::mesh_array();
628 myEnfMeshWdg = new StdMeshersGUI_ObjectReferenceParamWdg( SMESH::IDSOURCE, myEnfMeshGroup, /*multiSel=*/true);
629 myEnfMeshWdg->SetDefaultText(tr("HYBRID_ENF_SELECT_MESH"), "QLineEdit { color: grey }");
631 myEnfMeshWdg->AvoidSimultaneousSelection(myEnfVertexWdg);
633 QLabel* myMeshConstraintLabel = new QLabel( tr( "HYBRID_ENF_MESH_CONSTRAINT_LABEL" ), myEnfMeshGroup );
634 myEnfMeshConstraint = new QComboBox(myEnfMeshGroup);
635 myEnfMeshConstraint->insertItems(0,myEnfMeshConstraintLabels);
636 myEnfMeshConstraint->setEditable(false);
637 myEnfMeshConstraint->setCurrentIndex(2); //EZ: use mesh group of faces for a layer
639 QLabel* myMeshGroupNameLabel = new QLabel( tr( "HYBRID_ENF_GROUP_LABEL" ), myEnfMeshGroup );
640 myMeshGroupName = new QLineEdit(myEnfMeshGroup);
642 addEnfMeshButton = new QPushButton(tr("HYBRID_ENF_ADD"),myEnfMeshGroup);
643 // addEnfMeshButton->setEnabled(false);
644 removeEnfMeshButton = new QPushButton(tr("HYBRID_ENF_REMOVE"),myEnfMeshGroup);
646 // QGroupBox* GroupBox2 = new QGroupBox( myEnfMeshGroup );
647 // QLabel* info2 = new QLabel( GroupBox2 );
648 // info2->setText( tr( "HYBRID_ENF_MESH_INFO" ) );
649 // info2->setWordWrap( true );
650 // QVBoxLayout* GroupBox2VLayout = new QVBoxLayout( GroupBox2 );
651 // GroupBox2VLayout->setSpacing( 6 );
652 // GroupBox2VLayout->setMargin( 11 );
653 // GroupBox2VLayout->addWidget( info2 );
655 // anEnfMeshLayout->addWidget( GroupBox2, ENF_MESH_WARNING, 0, 1, 2 );
656 anEnfMeshLayout->addWidget(myEnforcedMeshTableWidget, ENF_MESH_MESH, 0, ENF_MESH_NB_LINES , 1);
658 QGridLayout* anEnfMeshLayout2 = new QGridLayout(myEnfMeshGroup);
659 anEnfMeshLayout2->addWidget(myEnfMeshWdg, ENF_MESH_MESH, 0, 1, 2);
660 //TODO remove or er usmay be lateful to select layers...
661 //anEnfMeshLayout2->addWidget(myMeshConstraintLabel, ENF_MESH_CONSTRAINT, 0, 1, 1);
662 //anEnfMeshLayout2->addWidget(myEnfMeshConstraint, ENF_MESH_CONSTRAINT, 1, 1, 1);
663 //anEnfMeshLayout2->addWidget(myMeshGroupNameLabel, ENF_MESH_GROUP, 0, 1, 1);
664 //anEnfMeshLayout2->addWidget(myMeshGroupName, ENF_MESH_GROUP, 1, 1, 1);
665 anEnfMeshLayout2->addWidget(addEnfMeshButton, ENF_MESH_BTN, 0, 1, 1);
666 anEnfMeshLayout2->addWidget(removeEnfMeshButton, ENF_MESH_BTN, 1, 1, 1);
667 anEnfMeshLayout2->setRowStretch(ENF_MESH_NB_LINES, 1);
669 anEnfMeshLayout->addLayout(anEnfMeshLayout2, ENF_MESH_MESH, 1, ENF_MESH_NB_LINES, 1);
670 anEnfMeshLayout->setRowStretch(ENF_MESH_MESH, 10);
674 tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
675 tab->insertTab( ADV_TAB, myAdvGroup, tr( "HYBRID_ADV_ARGS" ) );
676 //TODO remove or er usmay be lateful to select layers...
677 //tab->insertTab( ENF_VER_TAB, myEnfGroup, tr( "HYBRID_ENFORCED_VERTICES" ) );
678 tab->insertTab( ENF_MESH_TAB, myEnfMeshGroup, tr( "HYBRID_ENFORCED_MESHES" ) );
679 tab->setCurrentIndex( STD_TAB );
682 //connect( myToMeshHolesCheck, SIGNAL( toggled( bool ) ), this, SLOT( onToMeshHoles(bool)));
683 //connect( myAdvWidget->maxMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
684 //connect( myAdvWidget->initialMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
685 //connect( myAdvWidget->boundaryRecoveryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
687 //connect( myBoundaryLayersGrowthCombo, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
688 //connect( myElementGenerationCombo, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
689 connect( myAddMultinormalsCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
690 connect( mySmoothNormalsCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
692 connect( myAdvWidget->logInFileCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
693 connect( myAdvWidget->keepWorkingFilesCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
694 connect( myAdvWidget->workingDirectoryPushButton, SIGNAL( clicked() ), this, SLOT( onDirBtnClicked() ) );
696 connect( myEnforcedTableWidget, SIGNAL( itemClicked(QTableWidgetItem *)), this, SLOT( synchronizeCoords() ) );
697 connect( myEnforcedTableWidget, SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
698 connect( myEnforcedTableWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
699 connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertex() ) );
700 connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
701 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
702 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
703 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
704 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
705 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
706 connect( mySizeValue, SIGNAL( textChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) );
707 connect( myXCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
708 connect( myYCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
709 connect( myZCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
710 connect( mySizeValue, SIGNAL( valueChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) );
711 connect( this, SIGNAL( vertexDefined(bool) ), addVertexButton, SLOT( setEnabled(bool) ) );
713 connect( addEnfMeshButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedMesh() ) );
714 connect( removeEnfMeshButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedMesh() ) );
715 // connect( myEnfMeshWdg, SIGNAL( contentModified()), this, SLOT( checkEnfMeshIsDefined() ) );
716 // connect( myEnfMeshConstraint, SIGNAL( currentIndexChanged(int) ), this, SLOT( checkEnfMeshIsDefined() ) );
717 // connect( this, SIGNAL( enfMeshDefined(bool) ), addEnfMeshButton, SLOT( setEnabled(bool) ) );
723 * This method checks if an enforced vertex is defined;
725 void HYBRIDPluginGUI_HypothesisCreator::clearEnfVertexSelection()
727 if (myEnfVertexWdg->NbObjects() != 0) {
728 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
729 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
730 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
731 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
732 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
734 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
735 that->checkVertexIsDefined();
739 * This method checks if an enforced vertex is defined;
741 void HYBRIDPluginGUI_HypothesisCreator::checkVertexIsDefined()
743 bool enfVertexIsDefined = false;
744 enfVertexIsDefined = (!mySizeValue->GetString().isEmpty() &&
745 (!myEnfVertexWdg->NbObjects() == 0 ||
746 (myEnfVertexWdg->NbObjects() == 0 && !myXCoord->GetString().isEmpty()
747 && !myYCoord->GetString().isEmpty()
748 && !myZCoord->GetString().isEmpty())));
749 emit vertexDefined(enfVertexIsDefined);
753 * This method checks if an enforced mesh is defined;
755 void HYBRIDPluginGUI_HypothesisCreator::checkEnfMeshIsDefined()
757 emit enfMeshDefined( myEnfVertexWdg->NbObjects() != 0);
761 * This method resets the content of the X, Y, Z, size and GroupName widgets;
763 void HYBRIDPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
765 myXCoord->setCleared(true);
766 myYCoord->setCleared(true);
767 myZCoord->setCleared(true);
768 // mySizeValue->setCleared(true);
769 myXCoord->setText("");
770 myYCoord->setText("");
771 myZCoord->setText("");
772 // mySizeValue->setText("");
773 // myGroupName->setText("");
774 addVertexButton->setEnabled(false);
777 /** HYBRIDPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item)
778 This method updates the tooltip of a modified item. The QLineEdit widgets content
779 is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
781 void HYBRIDPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTableWidgetItem* item) {
782 // MESSAGE("HYBRIDPluginGUI_HypothesisCreator::updateEnforcedVertexValues");
783 int row = myEnforcedTableWidget->row(item);
785 QVariant vertexName = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole);
786 QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole);
787 QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole);
788 QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole);
789 QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole);
790 QVariant entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
791 QString groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole).toString();
793 clearEnforcedVertexWidgets();
795 if ( !x.isNull() || !entry.isNull()) {
796 QString toolTip = vertexName.toString();
797 toolTip += QString("(");
798 if (entry.isNull() || (!entry.isNull() && entry.toString() == "")) {
799 toolTip += x.toString();
800 toolTip += QString(", ") + y.toString();
801 toolTip += QString(", ") + z.toString();
804 toolTip += entry.toString();
805 toolTip += QString(")");
808 toolTip += QString("=") + size.toString();
810 if (!groupName.isEmpty())
811 toolTip += QString(" [") + groupName + QString("]");
813 // MESSAGE("Tooltip: " << toolTip.toStdString());
814 for (int col=0;col<ENF_VER_NB_COLUMNS;col++)
815 myEnforcedTableWidget->item(row,col)->setToolTip(toolTip);
818 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
819 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
820 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
821 myXCoord->SetValue(x.toDouble());
822 myYCoord->SetValue(y.toDouble());
823 myZCoord->SetValue(z.toDouble());
824 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
825 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
826 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
829 mySizeValue->SetValue(size.toDouble());
831 if (!groupName.isEmpty())
832 myGroupName->setText(groupName);
836 void HYBRIDPluginGUI_HypothesisCreator::onSelectEnforcedVertex() {
837 int nbSelEnfVertex = myEnfVertexWdg->NbObjects();
838 clearEnforcedVertexWidgets();
839 if (nbSelEnfVertex == 1)
841 if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() )
844 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
845 if (myEnfVertex == GEOM::GEOM_Object::_nil())
847 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
848 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
849 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
850 if (CORBA::is_nil(measureOp))
854 measureOp->PointCoordinates (myEnfVertex, x, y, z);
855 if ( measureOp->IsDone() )
857 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
858 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
859 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
860 myXCoord->SetValue(x);
861 myYCoord->SetValue(y);
862 myZCoord->SetValue(z);
863 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
864 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
865 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
871 /** HYBRIDPluginGUI_HypothesisCreator::synchronizeCoords()
872 This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
873 of the enforced vertex clicked in the tree widget.
875 void HYBRIDPluginGUI_HypothesisCreator::synchronizeCoords() {
876 clearEnforcedVertexWidgets();
877 QList<QTableWidgetItem *> items = myEnforcedTableWidget->selectedItems();
878 // myEnfVertexWdg->disconnect(SIGNAL(contentModified()));
879 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
880 if (! items.isEmpty()) {
881 QTableWidgetItem *item;
884 if (items.size() == 1) {
886 row = myEnforcedTableWidget->row(item);
887 QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole);
888 QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole);
889 QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole);
890 QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole);
891 entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
892 if (!entry.isNull()) {
893 SMESH::string_array_var objIds = new SMESH::string_array;
895 objIds[0] = entry.toString().toStdString().c_str();
896 myEnfVertexWdg->SetObjects(objIds);
899 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
901 QVariant group = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole);
902 if (!x.isNull()/* && entry.isNull()*/) {
903 // disconnect( myXCoord, SIGNAL( textChanged(const QString &)), this, SLOT( onSelectEnforcedVertex() ) );
904 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
905 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
906 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
907 myXCoord->SetValue(x.toDouble());
908 myYCoord->SetValue(y.toDouble());
909 myZCoord->SetValue(z.toDouble());
910 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
911 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
912 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
915 mySizeValue->SetValue(size.toDouble());
917 if (!group.isNull() && (!x.isNull() || !entry.isNull()))
918 myGroupName->setText(group.toString());
921 QList<QString> entryList;
922 for (int i = 0; i < items.size(); ++i) {
924 row = myEnforcedTableWidget->row(item);
925 entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
927 entryList << entry.toString();
929 if (entryList.size() > 0) {
930 SMESH::string_array_var objIds = new SMESH::string_array;
931 objIds->length(entryList.size());
932 for (int i = 0; i < entryList.size() ; i++)
933 objIds[i] = entryList.at(i).toStdString().c_str();
934 myEnfVertexWdg->SetObjects(objIds);
937 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
942 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
944 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
945 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
946 that->checkVertexIsDefined();
949 /** HYBRIDPluginGUI_HypothesisCreator::addEnforcedMesh( meshName, geomEntry, elemType, size, groupName)
950 This method adds in the tree widget an enforced mesh from mesh, submesh or group with optionally size and and groupName.
952 void HYBRIDPluginGUI_HypothesisCreator::addEnforcedMesh(std::string name, std::string entry, int elementType, std::string groupName)
954 MESSAGE("addEnforcedMesh(\"" << name << ", \"" << entry << "\", " << elementType << ", \"" << groupName << "\")");
955 bool okToCreate = true;
956 QString itemEntry = "";
957 int itemElementType = 0;
958 int rowCount = myEnforcedMeshTableWidget->rowCount();
959 bool allColumns = true;
960 for (int row = 0;row<rowCount;row++) {
961 for (int col = 0 ; col < ENF_MESH_NB_COLUMNS ; col++) {
962 MESSAGE("col: " << col);
963 if (col == ENF_MESH_CONSTRAINT_COLUMN){
964 if (qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row, col)) == 0) {
966 MESSAGE("allColumns = false");
970 else if (myEnforcedMeshTableWidget->item(row, col) == 0) {
972 MESSAGE("allColumns = false");
975 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
976 QComboBox* itemComboBox = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row, col));
977 itemElementType = itemComboBox->currentIndex();
978 MESSAGE("itemElementType: " << itemElementType);
980 else if (col == ENF_MESH_ENTRY_COLUMN)
981 itemEntry = myEnforcedMeshTableWidget->item(row, col)->data(Qt::EditRole).toString();
987 if (itemEntry == QString(entry.c_str()) && itemElementType == elementType) {
988 // // update group name
989 // if (itemGroupName.toStdString() != groupName) {
990 // MESSAGE("Group is updated from \"" << itemGroupName.toStdString() << "\" to \"" << groupName << "\"");
991 // myEnforcedMeshTableWidget->item(row, ENF_MESH_GROUP_COLUMN)->setData( Qt::EditRole, QVariant(groupName.c_str()));
1002 MESSAGE("Creation of enforced mesh");
1004 myEnforcedMeshTableWidget->setRowCount(rowCount+1);
1005 myEnforcedMeshTableWidget->setSortingEnabled(false);
1007 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++) {
1008 MESSAGE("Column: " << col);
1009 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1010 QComboBox* comboBox = new QComboBox();
1011 QPalette pal = comboBox->palette();
1012 pal.setColor(QPalette::Button, Qt::white);
1013 comboBox->setPalette(pal);
1014 comboBox->insertItems(0,myEnfMeshConstraintLabels);
1015 comboBox->setEditable(false);
1016 comboBox->setCurrentIndex(elementType);
1017 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << comboBox->currentText().toStdString());
1018 myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox);
1021 QTableWidgetItem* item = new QTableWidgetItem();
1022 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1024 case ENF_MESH_NAME_COLUMN:
1025 item->setData( 0, name.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_ENTRY_COLUMN:
1031 item->setData( 0, entry.c_str() );
1032 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1033 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1034 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1036 case ENF_MESH_GROUP_COLUMN:
1037 item->setData( 0, groupName.c_str() );
1038 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1039 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1048 // connect( myEnforcedMeshTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1050 myEnforcedMeshTableWidget->setSortingEnabled(true);
1051 // myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1052 // updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1056 /** HYBRIDPluginGUI_HypothesisCreator::addEnforcedVertex( x, y, z, size, vertexName, geomEntry, groupName)
1057 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.
1059 void HYBRIDPluginGUI_HypothesisCreator::addEnforcedVertex(double x, double y, double z, double size, std::string vertexName, std::string geomEntry, std::string groupName, bool isCompound)
1061 MESSAGE("addEnforcedVertex(" << x << ", " << y << ", " << z << ", " << size << ", \"" << vertexName << ", \"" << geomEntry << "\", \"" << groupName << "\", " << isCompound << ")");
1062 myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1063 bool okToCreate = true;
1064 double itemX,itemY,itemZ,itemSize = 0;
1065 QString itemEntry, itemGroupName = QString("");
1066 // bool itemIsCompound;
1067 int rowCount = myEnforcedTableWidget->rowCount();
1070 for (int row = 0;row<rowCount;row++) {
1072 for (int col = 0 ; col < ENF_VER_NB_COLUMNS ; col++) {
1073 if (myEnforcedTableWidget->item(row, col) == 0) {
1078 data = myEnforcedTableWidget->item(row, col)->data(Qt::EditRole);
1079 if (!data.isNull()) {
1081 case ENF_VER_GROUP_COLUMN:
1082 itemGroupName = data.toString();
1084 case ENF_VER_ENTRY_COLUMN:
1085 itemEntry = data.toString();
1087 // case ENF_VER_COMPOUND_COLUMN:
1088 // itemIsCompound = data.toBool();
1090 case ENF_VER_X_COLUMN:
1091 itemX = data.toDouble();
1093 case ENF_VER_Y_COLUMN:
1094 itemY = data.toDouble();
1096 case ENF_VER_Z_COLUMN:
1097 itemZ = data.toDouble();
1099 case ENF_VER_SIZE_COLUMN:
1100 itemSize = data.toDouble();
1112 if (( !isCompound && ((itemX == x) && (itemY == y) && (itemZ == z))) || /*( (itemEntry.toStdString() != "") && */ (itemEntry.toStdString() == geomEntry)/*)*/) {
1114 if (itemSize != size) {
1115 MESSAGE("Size is updated from \"" << itemSize << "\" to \"" << size << "\"");
1116 myEnforcedTableWidget->item(row, ENF_VER_SIZE_COLUMN)->setData( Qt::EditRole, QVariant(size));
1118 // update group name
1119 if (itemGroupName.toStdString() != groupName) {
1120 MESSAGE("Group is updated from \"" << itemGroupName.toStdString() << "\" to \"" << groupName << "\"");
1121 myEnforcedTableWidget->item(row, ENF_VER_GROUP_COLUMN)->setData( Qt::EditRole, QVariant(groupName.c_str()));
1128 if (geomEntry.empty()) {
1129 MESSAGE("Vertex with coords " << x << ", " << y << ", " << z << " already exist: dont create again");
1132 MESSAGE("Vertex with entry " << geomEntry << " already exist: dont create again");
1137 if (geomEntry.empty()) {
1138 MESSAGE("Vertex with coords " << x << ", " << y << ", " << z<< " is created");
1141 MESSAGE("Vertex with geom entry " << geomEntry << " is created");
1146 QString myVertexName;
1147 while(indexRef != vertexIndex) {
1148 indexRef = vertexIndex;
1149 if (vertexName.empty())
1150 myVertexName = QString("Vertex #%1").arg(vertexIndex);
1152 myVertexName = QString(vertexName.c_str());
1154 for (int row = 0;row<rowCount;row++) {
1155 QString name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString();
1156 if (myVertexName == name) {
1163 MESSAGE("myVertexName is \"" << myVertexName.toStdString() << "\"");
1164 myEnforcedTableWidget->setRowCount(rowCount+1);
1165 myEnforcedTableWidget->setSortingEnabled(false);
1166 for (int col=0;col<ENF_VER_NB_COLUMNS;col++) {
1167 MESSAGE("Column: " << col);
1168 QTableWidgetItem* item = new QTableWidgetItem();
1169 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1171 case ENF_VER_NAME_COLUMN:
1172 item->setData( Qt::EditRole, myVertexName );
1173 if (!geomEntry.empty()) {
1175 item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1177 item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1180 case ENF_VER_X_COLUMN:
1182 item->setData( 0, QVariant(x) );
1184 case ENF_VER_Y_COLUMN:
1186 item->setData( 0, QVariant(y) );
1188 case ENF_VER_Z_COLUMN:
1190 item->setData( 0, QVariant(z) );
1192 case ENF_VER_SIZE_COLUMN:
1193 item->setData( 0, QVariant(size) );
1195 case ENF_VER_ENTRY_COLUMN:
1196 if (!geomEntry.empty())
1197 item->setData( 0, QString(geomEntry.c_str()) );
1199 case ENF_VER_COMPOUND_COLUMN:
1200 item->setData( Qt::CheckStateRole, isCompound );
1201 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
1203 case ENF_VER_GROUP_COLUMN:
1204 if (!groupName.empty())
1205 item->setData( 0, QString(groupName.c_str()) );
1211 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1212 myEnforcedTableWidget->setItem(rowCount,col,item);
1216 connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1218 myEnforcedTableWidget->setSortingEnabled(true);
1219 // myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1220 updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1223 /** HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedMesh()
1224 This method is called when a item is added into the enforced meshes tree widget
1226 void HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedMesh()
1228 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedMesh()");
1230 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1232 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1233 myEnfMeshWdg->deactivateSelection();
1235 for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column)
1236 myEnforcedMeshTableWidget->resizeColumnToContents(column);
1239 int selEnfMeshes = myEnfMeshWdg->NbObjects();
1240 if (selEnfMeshes == 0)
1243 std::string groupName = myMeshGroupName->text().toStdString();
1244 // if (myGlobalGroupName->isChecked())
1245 // groupName = myGlobalGroupName->text().toStdString();
1247 if (boost::trim_copy(groupName).empty())
1251 int elementType = myEnfMeshConstraint->currentIndex();
1254 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1255 _PTR(SObject) aSObj; //SMESH::SMESH_IDSource::_nil;
1256 QString meshEntry = myEnfMeshWdg->GetValue();
1257 MESSAGE("myEnfMeshWdg->GetValue()" << meshEntry.toStdString());
1259 if (selEnfMeshes == 1)
1261 MESSAGE("1 SMESH object selected");
1262 // myEnfMesh = myEnfMeshWdg->GetObject< SMESH::SMESH_IDSource >();
1263 // std::string entry = myEnfMeshWdg->GetValue();
1264 aSObj = aStudy->FindObjectID(meshEntry.toStdString().c_str());
1265 CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy);
1266 if (!CORBA::is_nil(anObj)) {
1267 // SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1268 addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
1273 MESSAGE(selEnfMeshes << " SMESH objects selected");
1274 QStringList meshEntries = meshEntry.split(" ", QString::SkipEmptyParts);
1275 QStringListIterator meshEntriesIt (meshEntries);
1276 while (meshEntriesIt.hasNext()) {
1277 aSObj = aStudy->FindObjectID(meshEntriesIt.next().toStdString().c_str());
1278 CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy);
1279 if (!CORBA::is_nil(anObj)) {
1280 // SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1281 addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
1286 myEnfVertexWdg->SetObject(SMESH::SMESH_IDSource::_nil());
1288 for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column)
1289 myEnforcedMeshTableWidget->resizeColumnToContents(column);
1293 /** HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedVertex()
1294 This method is called when a item is added into the enforced vertices tree widget
1296 void HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedVertex()
1298 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedVertex()");
1300 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1302 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1303 myEnfVertexWdg->deactivateSelection();
1305 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1306 myEnforcedTableWidget->resizeColumnToContents(column);
1309 int selEnfVertex = myEnfVertexWdg->NbObjects();
1310 bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty());
1311 if ((selEnfVertex == 0) && coordsEmpty)
1314 std::string groupName = myGroupName->text().toStdString();
1315 // if (myGlobalGroupName->isChecked())
1316 // groupName = myGlobalGroupName->text().toStdString();
1318 if (boost::trim_copy(groupName).empty())
1321 double size = mySizeValue->GetValue();
1323 if (selEnfVertex <= 1)
1325 MESSAGE("0 or 1 GEOM object selected");
1326 double x = 0, y = 0, z=0;
1327 if (myXCoord->GetString() != "") {
1328 x = myXCoord->GetValue();
1329 y = myYCoord->GetValue();
1330 z = myZCoord->GetValue();
1332 if (selEnfVertex == 1) {
1333 MESSAGE("1 GEOM object selected");
1334 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >();
1335 std::string entry = "";
1336 if (myEnfVertex != GEOM::GEOM_Object::_nil())
1337 entry = myEnfVertex->GetStudyEntry();
1338 addEnforcedVertex(x, y, z, size, myEnfVertex->GetName(),entry, groupName, myEnfVertex->GetShapeType() == GEOM::COMPOUND);
1341 MESSAGE("0 GEOM object selected");
1342 MESSAGE("Coords: ("<<x<<","<<y<<","<<z<<")");
1343 addEnforcedVertex(x, y, z, size, "", "", groupName);
1348 if ( CORBA::is_nil(getGeomEngine()))
1351 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
1352 if (CORBA::is_nil(measureOp))
1355 CORBA::Double x = 0, y = 0,z = 0;
1356 for (int j = 0 ; j < selEnfVertex ; j++)
1358 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j);
1359 if (myEnfVertex == GEOM::GEOM_Object::_nil())
1361 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1362 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1363 if ( measureOp->IsDone() )
1364 addEnforcedVertex(x, y, z, size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1365 } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) {
1366 addEnforcedVertex(0., 0., 0., size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName, true);
1371 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1373 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1374 myEnforcedTableWidget->resizeColumnToContents(column);
1377 /** HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedMesh()
1378 This method is called when a item is removed from the enforced meshes tree widget
1380 void HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedMesh()
1382 QList<int> selectedRows;
1383 QList<QTableWidgetItem *> selectedItems = myEnforcedMeshTableWidget->selectedItems();
1384 QTableWidgetItem* item;
1386 foreach( item, selectedItems ) {
1388 if (!selectedRows.contains( row ) )
1389 selectedRows.append(row);
1392 qSort( selectedRows );
1393 QListIterator<int> it( selectedRows );
1395 while ( it.hasPrevious() ) {
1396 row = it.previous();
1397 MESSAGE("delete row #"<< row);
1398 myEnforcedMeshTableWidget->removeRow(row );
1401 myEnforcedMeshTableWidget->selectionModel()->clearSelection();
1404 /** HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1405 This method is called when a item is removed from the enforced vertices tree widget
1407 void HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1409 QList<int> selectedRows;
1410 QList<QTableWidgetItem *> selectedItems = myEnforcedTableWidget->selectedItems();
1411 QTableWidgetItem* item;
1413 foreach( item, selectedItems ) {
1415 if (!selectedRows.contains( row ) )
1416 selectedRows.append(row);
1419 qSort( selectedRows );
1420 QListIterator<int> it( selectedRows );
1422 while ( it.hasPrevious() ) {
1423 row = it.previous();
1424 MESSAGE("delete row #"<< row);
1425 myEnforcedTableWidget->removeRow(row );
1428 myEnforcedTableWidget->selectionModel()->clearSelection();
1431 void HYBRIDPluginGUI_HypothesisCreator::onToMeshHoles(bool isOn)
1433 // myToMakeGroupsOfDomains->setEnabled( isOn );
1435 // myToMakeGroupsOfDomains->setChecked( false );
1438 void HYBRIDPluginGUI_HypothesisCreator::onDirBtnClicked()
1440 QString dir = SUIT_FileDlg::getExistingDirectory( dlg(), myAdvWidget->workingDirectoryLineEdit->text(), QString() );
1441 if ( !dir.isEmpty() )
1442 myAdvWidget->workingDirectoryLineEdit->setText( dir );
1445 void HYBRIDPluginGUI_HypothesisCreator::updateWidgets()
1447 //customs automatic set
1448 //myToMakeGroupsOfDomains->setEnabled( myToMeshHolesCheck->isChecked() );
1449 //myAdvWidget->maxMemorySpin->setEnabled( myAdvWidget->maxMemoryCheck->isChecked() );
1450 //myAdvWidget->initialMemoryCheck->setEnabled( !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1451 //myAdvWidget->initialMemorySpin->setEnabled( myAdvWidget->initialMemoryCheck->isChecked() && !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1452 //myOptimizationLevelCombo->setEnabled( !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1453 myMultinormalsAngleSpin->setEnabled( myAddMultinormalsCheck->isChecked() );
1454 if ( sender() == myAdvWidget->logInFileCheck ||
1455 sender() == myAdvWidget->keepWorkingFilesCheck )
1457 bool logFileRemovable = myAdvWidget->logInFileCheck->isChecked() &&
1458 !myAdvWidget->keepWorkingFilesCheck->isChecked();
1460 myAdvWidget->removeLogOnSuccessCheck->setEnabled( logFileRemovable );
1464 bool HYBRIDPluginGUI_HypothesisCreator::checkParams(QString& msg) const
1466 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::checkParams");
1468 if ( !QFileInfo( myAdvWidget->workingDirectoryLineEdit->text().trimmed() ).isWritable() ) {
1469 SUIT_MessageBox::warning( dlg(),
1470 tr( "SMESH_WRN_WARNING" ),
1471 tr( "HYBRID_PERMISSION_DENIED" ) );
1478 void HYBRIDPluginGUI_HypothesisCreator::retrieveParams() const
1480 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::retrieveParams");
1481 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1482 HYBRIDHypothesisData data;
1483 readParamsFromHypo( data );
1486 myName->setText( data.myName );
1488 myToMeshHolesCheck ->setChecked ( data.myToMeshHoles );
1489 myToMakeGroupsOfDomains ->setChecked ( data.myToMakeGroupsOfDomains );
1490 myOptimizationLevelCombo ->setCurrentIndex( data.myOptimizationLevel );
1491 myAdvWidget->maxMemoryCheck ->setChecked ( data.myMaximumMemory > 0 );
1492 myAdvWidget->maxMemorySpin ->setValue ( qMax( data.myMaximumMemory,
1493 myAdvWidget->maxMemorySpin->minimum() ));
1494 myAdvWidget->initialMemoryCheck ->setChecked ( data.myInitialMemory > 0 );
1495 myAdvWidget->initialMemorySpin ->setValue ( qMax( data.myInitialMemory,
1496 myAdvWidget->initialMemorySpin->minimum() ));
1498 myCollisionModeCombo ->setCurrentIndex( data.myCollisionMode );
1499 myBoundaryLayersGrowthCombo ->setCurrentIndex( data.myBoundaryLayersGrowth );
1500 myElementGenerationCombo ->setCurrentIndex( data.myElementGeneration );
1501 myAddMultinormalsCheck -> setChecked ( data.myAddMultinormals );
1502 mySmoothNormalsCheck -> setChecked ( data.mySmoothNormals );
1503 myHeightFirstLayerSpin -> setValue( data.myHeightFirstLayer );
1504 myNbOfBoundaryLayersSpin -> setValue( data.myNbOfBoundaryLayers );
1505 myBoundaryLayersProgressionSpin -> setValue( data.myBoundaryLayersProgression );
1506 myMultinormalsAngleSpin -> setValue( data.myMultinormalsAngle );
1508 myAdvWidget->workingDirectoryLineEdit ->setText ( data.myWorkingDir );
1509 myAdvWidget->keepWorkingFilesCheck ->setChecked ( data.myKeepFiles );
1510 myAdvWidget->verboseLevelSpin ->setValue ( data.myVerboseLevel );
1511 myAdvWidget->createNewNodesCheck ->setChecked ( data.myToCreateNewNodes );
1512 myAdvWidget->removeInitialCentralPointCheck ->setChecked ( data.myRemoveInitialCentralPoint );
1513 myAdvWidget->boundaryRecoveryCheck ->setChecked ( data.myBoundaryRecovery );
1514 myAdvWidget->FEMCorrectionCheck ->setChecked ( data.myFEMCorrection );
1515 myAdvWidget->gradationSpinBox ->setValue ( data.myGradation );
1516 myAdvWidget->textOptionLineEdit ->setText ( data.myTextOption );
1517 myAdvWidget->logInFileCheck ->setChecked ( !data.myLogInStandardOutput );
1518 myAdvWidget->removeLogOnSuccessCheck ->setChecked ( data.myRemoveLogOnSuccess );
1520 TEnfVertexList::const_iterator it;
1522 myEnforcedTableWidget->clearContents();
1523 myEnforcedTableWidget->setSortingEnabled(false);
1524 myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1525 for(it = data.myEnforcedVertices.begin() ; it != data.myEnforcedVertices.end(); it++ )
1527 TEnfVertex* enfVertex = (*it);
1528 myEnforcedTableWidget->setRowCount(rowCount+1);
1530 for (int col=0;col<ENF_VER_NB_COLUMNS;col++) {
1531 MESSAGE("Column: " << col);
1532 // MESSAGE("enfVertex->isCompound: " << enfVertex->isCompound);
1533 QTableWidgetItem* item = new QTableWidgetItem();
1534 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1536 case ENF_VER_NAME_COLUMN:
1537 item->setData( 0, enfVertex->name.c_str() );
1538 if (!enfVertex->geomEntry.empty()) {
1539 if (enfVertex->isCompound)
1540 item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1542 item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1544 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1547 case ENF_VER_X_COLUMN:
1548 if (!enfVertex->isCompound) {
1549 item->setData( 0, enfVertex->coords.at(0) );
1550 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1553 case ENF_VER_Y_COLUMN:
1554 if (!enfVertex->isCompound) {
1555 item->setData( 0, enfVertex->coords.at(1) );
1556 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1559 case ENF_VER_Z_COLUMN:
1560 if (!enfVertex->isCompound) {
1561 item->setData( 0, enfVertex->coords.at(2) );
1562 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1565 case ENF_VER_SIZE_COLUMN:
1566 item->setData( 0, enfVertex->size );
1567 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1569 case ENF_VER_ENTRY_COLUMN:
1570 item->setData( 0, enfVertex->geomEntry.c_str() );
1571 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1573 case ENF_VER_COMPOUND_COLUMN:
1574 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
1575 item->setData( Qt::CheckStateRole, enfVertex->isCompound );
1576 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << enfVertex->isCompound);
1578 case ENF_VER_GROUP_COLUMN:
1579 item->setData( 0, enfVertex->groupName.c_str() );
1580 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1586 myEnforcedTableWidget->setItem(rowCount,col,item);
1589 that->updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1593 connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1594 myEnforcedTableWidget->setSortingEnabled(true);
1596 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1597 myEnforcedTableWidget->resizeColumnToContents(column);
1599 // Update Enforced meshes QTableWidget
1600 TEnfMeshList::const_iterator itMesh;
1602 myEnforcedMeshTableWidget->clearContents();
1603 myEnforcedMeshTableWidget->setSortingEnabled(false);
1604 // myEnforcedMeshTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1605 for(itMesh = data.myEnforcedMeshes.begin() ; itMesh != data.myEnforcedMeshes.end(); itMesh++ )
1607 TEnfMesh* enfMesh = (*itMesh);
1608 myEnforcedMeshTableWidget->setRowCount(rowCount+1);
1610 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++) {
1611 MESSAGE("Column: " << col);
1612 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1613 QComboBox* comboBox = new QComboBox();
1614 QPalette pal = comboBox->palette();
1615 pal.setColor(QPalette::Button, Qt::white);
1616 comboBox->setPalette(pal);
1617 comboBox->insertItems(0,myEnfMeshConstraintLabels);
1618 comboBox->setEditable(false);
1619 comboBox->setCurrentIndex(enfMesh->elementType);
1620 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << comboBox->currentText().toStdString());
1621 myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox);
1624 QTableWidgetItem* item = new QTableWidgetItem();
1625 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1627 case ENF_MESH_NAME_COLUMN:
1628 item->setData( 0, enfMesh->name.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_ENTRY_COLUMN:
1634 item->setData( 0, enfMesh->entry.c_str() );
1635 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1636 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1637 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1639 case ENF_MESH_GROUP_COLUMN:
1640 item->setData( 0, enfMesh->groupName.c_str() );
1641 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1642 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1649 // myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1652 // that->updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1656 // connect( myEnforcedMeshTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1657 myEnforcedMeshTableWidget->setSortingEnabled(true);
1659 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++)
1660 myEnforcedMeshTableWidget->resizeColumnToContents(col);
1662 that->updateWidgets();
1663 that->checkVertexIsDefined();
1666 QString HYBRIDPluginGUI_HypothesisCreator::storeParams() const
1668 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::storeParams");
1669 HYBRIDHypothesisData data;
1670 readParamsFromWidgets( data );
1671 storeParamsToHypo( data );
1673 QString valStr = "";
1675 if ( !data.myBoundaryRecovery )
1676 valStr = "-c " + QString::number( !data.myToMeshHoles );
1678 if ( data.myOptimizationLevel >= 0 && data.myOptimizationLevel < 5 && !data.myBoundaryRecovery) {
1679 const char* level[] = { "none" , "light" , "standard" , "standard+" , "strong" };
1681 valStr += level[ data.myOptimizationLevel ];
1683 if ( data.myMaximumMemory > 0 ) {
1685 valStr += QString::number( data.myMaximumMemory );
1687 if ( data.myInitialMemory > 0 && !data.myBoundaryRecovery ) {
1689 valStr += QString::number( data.myInitialMemory );
1692 valStr += QString::number( data.myVerboseLevel );
1694 if ( !data.myToCreateNewNodes )
1697 if ( data.myRemoveInitialCentralPoint )
1698 valStr += " -no_initial_central_point";
1700 if ( data.myBoundaryRecovery )
1703 if ( data.myFEMCorrection )
1706 if ( data.myGradation != 1.05 ) {
1707 valStr += " -Dcpropa=";
1708 valStr += QString::number( data.myGradation );
1712 valStr += data.myTextOption;
1714 // valStr += " #BEGIN ENFORCED VERTICES#";
1715 // // Add size map parameters storage
1716 // for (int i=0 ; i<mySmpModel->rowCount() ; i++) {
1718 // double x = mySmpModel->data(mySmpModel->index(i,ENF_VER_X_COLUMN)).toDouble();
1719 // double y = mySmpModel->data(mySmpModel->index(i,ENF_VER_Y_COLUMN)).toDouble();
1720 // double z = mySmpModel->data(mySmpModel->index(i,ENF_VER_Z_COLUMN)).toDouble();
1721 // double size = mySmpModel->data(mySmpModel->index(i,ENF_VER_SIZE_COLUMN)).toDouble();
1722 // valStr += QString::number( x );
1724 // valStr += QString::number( y );
1726 // valStr += QString::number( z );
1728 // valStr += QString::number( size );
1729 // if (i!=mySmpModel->rowCount()-1)
1732 // valStr += " #END ENFORCED VERTICES#";
1733 // MESSAGE(valStr.toStdString());
1737 bool HYBRIDPluginGUI_HypothesisCreator::readParamsFromHypo( HYBRIDHypothesisData& h_data ) const
1739 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::readParamsFromHypo");
1740 HYBRIDPlugin::HYBRIDPlugin_Hypothesis_var h =
1741 HYBRIDPlugin::HYBRIDPlugin_Hypothesis::_narrow( initParamsHypothesis() );
1743 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
1744 h_data.myName = isCreation() && data ? hypName() : "";
1746 h_data.myToMeshHoles = h->GetToMeshHoles();
1747 h_data.myToMakeGroupsOfDomains = /*h->GetToMeshHoles() &&*/ h->GetToMakeGroupsOfDomains();
1748 h_data.myMaximumMemory = h->GetMaximumMemory();
1749 h_data.myInitialMemory = h->GetInitialMemory();
1750 h_data.myInitialMemory = h->GetInitialMemory();
1751 h_data.myOptimizationLevel = h->GetOptimizationLevel();
1753 h_data.myCollisionMode = h->GetCollisionMode();
1754 h_data.myBoundaryLayersGrowth = h->GetBoundaryLayersGrowth();
1755 h_data.myElementGeneration = h->GetElementGeneration();
1756 h_data.myAddMultinormals = h->GetAddMultinormals();
1757 h_data.mySmoothNormals = h->GetSmoothNormals();
1758 h_data.myHeightFirstLayer = h->GetHeightFirstLayer();
1759 h_data.myBoundaryLayersProgression = h->GetBoundaryLayersProgression();
1760 h_data.myMultinormalsAngle = h->GetMultinormalsAngle();
1761 h_data.myNbOfBoundaryLayers = h->GetNbOfBoundaryLayers();
1763 h_data.myKeepFiles = h->GetKeepFiles();
1764 h_data.myWorkingDir = h->GetWorkingDirectory();
1765 h_data.myVerboseLevel = h->GetVerboseLevel();
1766 h_data.myToCreateNewNodes = h->GetToCreateNewNodes();
1767 h_data.myRemoveInitialCentralPoint = h->GetToRemoveCentralPoint();
1768 h_data.myBoundaryRecovery = h->GetToUseBoundaryRecoveryVersion();
1769 h_data.myFEMCorrection = h->GetFEMCorrection();
1770 h_data.myGradation = h->GetGradation();
1771 h_data.myTextOption = h->GetTextOption();
1772 h_data.myLogInStandardOutput = h->GetStandardOutputLog();
1773 h_data.myRemoveLogOnSuccess = h->GetRemoveLogOnSuccess();
1775 HYBRIDPlugin::HYBRIDEnforcedVertexList_var vertices = h->GetEnforcedVertices();
1776 MESSAGE("vertices->length(): " << vertices->length());
1777 h_data.myEnforcedVertices.clear();
1778 for (int i=0 ; i<vertices->length() ; i++) {
1779 TEnfVertex* myVertex = new TEnfVertex();
1780 myVertex->name = CORBA::string_dup(vertices[i].name.in());
1781 myVertex->geomEntry = CORBA::string_dup(vertices[i].geomEntry.in());
1782 myVertex->groupName = CORBA::string_dup(vertices[i].groupName.in());
1783 myVertex->size = vertices[i].size;
1784 myVertex->isCompound = vertices[i].isCompound;
1785 if (vertices[i].coords.length()) {
1786 for (int c = 0; c < vertices[i].coords.length() ; c++)
1787 myVertex->coords.push_back(vertices[i].coords[c]);
1788 MESSAGE("Add enforced vertex ("<< myVertex->coords.at(0) << ","<< myVertex->coords.at(1) << ","<< myVertex->coords.at(2) << ") ="<< myVertex->size);
1790 h_data.myEnforcedVertices.insert(myVertex);
1793 HYBRIDPlugin::HYBRIDEnforcedMeshList_var enfMeshes = h->GetEnforcedMeshes();
1794 MESSAGE("enfMeshes->length(): " << enfMeshes->length());
1795 h_data.myEnforcedMeshes.clear();
1796 for (int i=0 ; i<enfMeshes->length() ; i++) {
1797 TEnfMesh* myEnfMesh = new TEnfMesh();
1798 myEnfMesh->name = CORBA::string_dup(enfMeshes[i].name.in());
1799 myEnfMesh->entry = CORBA::string_dup(enfMeshes[i].entry.in());
1800 myEnfMesh->groupName = CORBA::string_dup(enfMeshes[i].groupName.in());
1801 switch (enfMeshes[i].elementType) {
1803 myEnfMesh->elementType = 0;
1806 myEnfMesh->elementType = 1;
1809 myEnfMesh->elementType = 2;
1814 // myEnfMesh->elementType = enfMeshes[i].elementType;
1815 h_data.myEnforcedMeshes.insert(myEnfMesh);
1820 bool HYBRIDPluginGUI_HypothesisCreator::storeParamsToHypo( const HYBRIDHypothesisData& h_data ) const
1822 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::storeParamsToHypo");
1823 HYBRIDPlugin::HYBRIDPlugin_Hypothesis_var h =
1824 HYBRIDPlugin::HYBRIDPlugin_Hypothesis::_narrow( hypothesis() );
1830 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
1832 if ( h->GetToMeshHoles() != h_data.myToMeshHoles ) // avoid duplication of DumpPython commands
1833 h->SetToMeshHoles ( h_data.myToMeshHoles );
1834 if ( h->GetToMakeGroupsOfDomains() != h_data.myToMakeGroupsOfDomains )
1835 h->SetToMakeGroupsOfDomains( h_data.myToMakeGroupsOfDomains );
1836 if ( h->GetMaximumMemory() != h_data.myMaximumMemory )
1837 h->SetMaximumMemory ( h_data.myMaximumMemory );
1838 if ( h->GetInitialMemory() != h_data.myInitialMemory )
1839 h->SetInitialMemory ( h_data.myInitialMemory );
1840 if ( h->GetInitialMemory() != h_data.myInitialMemory )
1841 h->SetInitialMemory ( h_data.myInitialMemory );
1842 if ( h->GetOptimizationLevel() != h_data.myOptimizationLevel )
1843 h->SetOptimizationLevel( h_data.myOptimizationLevel );
1845 if ( h->GetCollisionMode() != h_data.myCollisionMode )
1846 h->SetCollisionMode( h_data.myCollisionMode );
1847 if ( h->GetBoundaryLayersGrowth() != h_data.myBoundaryLayersGrowth )
1848 h->SetBoundaryLayersGrowth( h_data.myBoundaryLayersGrowth );
1849 if ( h->GetElementGeneration() != h_data.myElementGeneration )
1850 h->SetElementGeneration( h_data.myElementGeneration );
1852 if ( h->GetAddMultinormals() != h_data.myAddMultinormals )
1853 h->SetAddMultinormals ( h_data.myAddMultinormals );
1854 if ( h->GetSmoothNormals() != h_data.mySmoothNormals )
1855 h->SetSmoothNormals ( h_data.mySmoothNormals );
1856 if ( h->GetHeightFirstLayer() != h_data.myHeightFirstLayer )
1857 h->SetHeightFirstLayer ( h_data.myHeightFirstLayer );
1858 if ( h->GetBoundaryLayersProgression() != h_data.myBoundaryLayersProgression )
1859 h->SetBoundaryLayersProgression ( h_data.myBoundaryLayersProgression );
1860 if ( h->GetMultinormalsAngle() != h_data.myMultinormalsAngle )
1861 h->SetMultinormalsAngle ( h_data.myMultinormalsAngle );
1862 if ( h->GetNbOfBoundaryLayers() != h_data.myNbOfBoundaryLayers )
1863 h->SetNbOfBoundaryLayers ( h_data.myNbOfBoundaryLayers );
1865 if ( h->GetKeepFiles() != h_data.myKeepFiles)
1866 h->SetKeepFiles ( h_data.myKeepFiles);
1867 if ( h->GetWorkingDirectory() != h_data.myWorkingDir )
1868 h->SetWorkingDirectory ( h_data.myWorkingDir.toLatin1().constData() );
1869 if ( h->GetVerboseLevel() != h_data.myVerboseLevel )
1870 h->SetVerboseLevel ( h_data.myVerboseLevel );
1871 if ( h->GetToCreateNewNodes() != h_data.myToCreateNewNodes )
1872 h->SetToCreateNewNodes ( h_data.myToCreateNewNodes );
1873 if ( h->GetToRemoveCentralPoint() != h_data.myRemoveInitialCentralPoint )
1874 h->SetToRemoveCentralPoint ( h_data.myRemoveInitialCentralPoint );
1875 if ( h->GetToUseBoundaryRecoveryVersion() != h_data.myBoundaryRecovery )
1876 h->SetToUseBoundaryRecoveryVersion ( h_data.myBoundaryRecovery );
1877 if ( h->GetFEMCorrection() != h_data.myFEMCorrection )
1878 h->SetFEMCorrection ( h_data.myFEMCorrection );
1879 if ( h->GetGradation() != h_data.myGradation )
1880 h->SetGradation ( h_data.myGradation );
1881 if ( h->GetTextOption() != h_data.myTextOption )
1882 h->SetTextOption ( h_data.myTextOption.toLatin1().constData() );
1883 if ( h->GetStandardOutputLog() != h_data.myLogInStandardOutput )
1884 h->SetStandardOutputLog ( h_data.myLogInStandardOutput );
1885 if ( h->GetRemoveLogOnSuccess() != h_data.myRemoveLogOnSuccess )
1886 h->SetRemoveLogOnSuccess ( h_data.myRemoveLogOnSuccess );
1888 // Enforced vertices
1889 int nbVertex = (int) h_data.myEnforcedVertices.size();
1890 HYBRIDPlugin::HYBRIDEnforcedVertexList_var vertexHyp = h->GetEnforcedVertices();
1891 int nbVertexHyp = vertexHyp->length();
1893 MESSAGE("Store params for size maps: " << nbVertex << " enforced vertices");
1894 MESSAGE("h->GetEnforcedVertices()->length(): " << nbVertexHyp);
1896 // 1. Clear all enforced vertices in hypothesis
1897 // 2. Add new enforced vertex according to h_data
1898 if ( nbVertexHyp > 0)
1899 h->ClearEnforcedVertices();
1901 TEnfVertexList::const_iterator it;
1902 double x = 0, y = 0, z = 0;
1903 for(it = h_data.myEnforcedVertices.begin() ; it != h_data.myEnforcedVertices.end(); it++ ) {
1904 TEnfVertex* enfVertex = (*it);
1906 if (enfVertex->coords.size()) {
1907 x = enfVertex->coords.at(0);
1908 y = enfVertex->coords.at(1);
1909 z = enfVertex->coords.at(2);
1911 ok = h->p_SetEnforcedVertex( enfVertex->size, x, y, z, enfVertex->name.c_str(), enfVertex->geomEntry.c_str(), enfVertex->groupName.c_str(), enfVertex->isCompound);
1915 int nbEnfMeshes = (int) h_data.myEnforcedMeshes.size();
1916 HYBRIDPlugin::HYBRIDEnforcedMeshList_var enfMeshListHyp = h->GetEnforcedMeshes();
1917 int nbEnfMeshListHyp = enfMeshListHyp->length();
1919 MESSAGE("Store params for size maps: " << nbEnfMeshes << " enforced meshes");
1920 MESSAGE("h->GetEnforcedMeshes()->length(): " << nbEnfMeshListHyp);
1922 // 1. Clear all enforced vertices in hypothesis
1923 // 2. Add new enforced vertex according to h_data
1924 if ( nbEnfMeshListHyp > 0)
1925 h->ClearEnforcedMeshes();
1927 TEnfMeshList::const_iterator itEnfMesh;
1929 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1931 for(itEnfMesh = h_data.myEnforcedMeshes.begin() ; itEnfMesh != h_data.myEnforcedMeshes.end(); itEnfMesh++ ) {
1932 TEnfMesh* enfMesh = (*itEnfMesh);
1934 _PTR(SObject) aSObj = aStudy->FindObjectID(enfMesh->entry.c_str());
1935 SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1937 MESSAGE("enfMesh->elementType: " << enfMesh->elementType);
1938 SMESH::ElementType elementType;
1939 switch(enfMesh->elementType) {
1941 elementType = SMESH::NODE;
1944 elementType = SMESH::EDGE;
1947 elementType = SMESH::FACE;
1953 std::cout << "h->p_SetEnforcedMesh(theSource, "<< elementType <<", \""<< enfMesh->name << "\", \"" << enfMesh->groupName.c_str() <<"\")"<<std::endl;
1954 ok = h->p_SetEnforcedMesh(theSource, elementType, enfMesh->name.c_str(), enfMesh->groupName.c_str());
1957 // catch(const std::exception& ex) {
1958 // std::cout << "Exception: " << ex.what() << std::endl;
1961 catch ( const SALOME::SALOME_Exception& ex )
1963 SalomeApp_Tools::QtCatchCorbaException( ex );
1969 bool HYBRIDPluginGUI_HypothesisCreator::readParamsFromWidgets( HYBRIDHypothesisData& h_data ) const
1971 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::readParamsFromWidgets");
1972 h_data.myName = myName ? myName->text() : "";
1973 h_data.myToMeshHoles = myToMeshHolesCheck->isChecked();
1974 h_data.myToMakeGroupsOfDomains = myToMakeGroupsOfDomains->isChecked();
1975 h_data.myMaximumMemory = myAdvWidget->maxMemoryCheck->isChecked() ? myAdvWidget->maxMemorySpin->value() : -1;
1976 h_data.myInitialMemory = myAdvWidget->initialMemoryCheck->isChecked() ? myAdvWidget->initialMemorySpin->value() : -1;
1977 h_data.myOptimizationLevel = myOptimizationLevelCombo->currentIndex();
1979 h_data.myCollisionMode = myCollisionModeCombo->currentIndex();
1980 h_data.myBoundaryLayersGrowth = myBoundaryLayersGrowthCombo->currentIndex();
1981 h_data.myElementGeneration = myElementGenerationCombo->currentIndex();
1982 h_data.myAddMultinormals = myAddMultinormalsCheck->isChecked();
1983 h_data.mySmoothNormals = mySmoothNormalsCheck->isChecked();
1985 h_data.myHeightFirstLayer = myHeightFirstLayerSpin -> value();
1986 h_data.myNbOfBoundaryLayers = myNbOfBoundaryLayersSpin -> value();
1987 h_data.myBoundaryLayersProgression = myBoundaryLayersProgressionSpin -> value();
1988 h_data.myMultinormalsAngle = myMultinormalsAngleSpin -> value();
1990 h_data.myKeepFiles = myAdvWidget->keepWorkingFilesCheck->isChecked();
1991 h_data.myWorkingDir = myAdvWidget->workingDirectoryLineEdit->text().trimmed();
1992 h_data.myVerboseLevel = myAdvWidget->verboseLevelSpin->value();
1993 h_data.myToCreateNewNodes = myAdvWidget->createNewNodesCheck->isChecked();
1994 h_data.myRemoveInitialCentralPoint = myAdvWidget->removeInitialCentralPointCheck->isChecked();
1995 h_data.myBoundaryRecovery = myAdvWidget->boundaryRecoveryCheck->isChecked();
1996 h_data.myFEMCorrection = myAdvWidget->FEMCorrectionCheck->isChecked();
1997 h_data.myGradation = myAdvWidget->gradationSpinBox->value();
1998 h_data.myTextOption = myAdvWidget->textOptionLineEdit->text();
1999 h_data.myLogInStandardOutput = !myAdvWidget->logInFileCheck->isChecked();
2000 h_data.myRemoveLogOnSuccess = myAdvWidget->removeLogOnSuccessCheck->isChecked();
2002 // Enforced vertices
2003 h_data.myEnforcedVertices.clear();
2004 QVariant valueX, valueY, valueZ;
2005 for (int row=0 ; row<myEnforcedTableWidget->rowCount() ; row++) {
2007 TEnfVertex *myVertex = new TEnfVertex();
2008 myVertex->name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString();
2009 MESSAGE("Add new enforced vertex \"" << myVertex->name << "\"" );
2010 myVertex->geomEntry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString();
2011 if (myVertex->geomEntry.size())
2012 MESSAGE("Geom entry is \"" << myVertex->geomEntry << "\"" );
2013 myVertex->groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
2014 if (myVertex->groupName.size())
2015 MESSAGE("Group name is \"" << myVertex->groupName << "\"" );
2016 valueX = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data(Qt::EditRole);
2017 valueY = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data(Qt::EditRole);
2018 valueZ = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data(Qt::EditRole);
2019 if (!valueX.isNull() && !valueY.isNull() && !valueZ.isNull()) {
2020 myVertex->coords.push_back(valueX.toDouble());
2021 myVertex->coords.push_back(valueY.toDouble());
2022 myVertex->coords.push_back(valueZ.toDouble());
2023 MESSAGE("Coords are (" << myVertex->coords.at(0) << ", "
2024 << myVertex->coords.at(1) << ", "
2025 << myVertex->coords.at(2) << ")");
2027 myVertex->size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data(Qt::EditRole).toDouble();
2028 MESSAGE("Size is " << myVertex->size);
2029 myVertex->isCompound = myEnforcedTableWidget->item(row,ENF_VER_COMPOUND_COLUMN)->data(Qt::CheckStateRole).toBool();
2030 MESSAGE("Is compound ? " << myVertex->isCompound);
2031 h_data.myEnforcedVertices.insert(myVertex);
2035 h_data.myEnforcedMeshes.clear();
2037 for (int row=0 ; row<myEnforcedMeshTableWidget->rowCount() ; row++) {
2039 TEnfMesh *myEnfMesh = new TEnfMesh();
2040 myEnfMesh->name = myEnforcedMeshTableWidget->item(row,ENF_MESH_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString();
2041 MESSAGE("Add new enforced mesh \"" << myEnfMesh->name << "\"" );
2042 myEnfMesh->entry = myEnforcedMeshTableWidget->item(row,ENF_MESH_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString();
2043 MESSAGE("Entry is \"" << myEnfMesh->entry << "\"" );
2044 myEnfMesh->groupName = myEnforcedMeshTableWidget->item(row,ENF_MESH_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
2045 MESSAGE("Group name is \"" << myEnfMesh->groupName << "\"" );
2046 QComboBox* combo = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row,ENF_MESH_CONSTRAINT_COLUMN));
2047 myEnfMesh->elementType = combo->currentIndex();
2048 MESSAGE("Element type: " << myEnfMesh->elementType);
2049 h_data.myEnforcedMeshes.insert(myEnfMesh);
2050 std::cout << "h_data.myEnforcedMeshes.size(): " << h_data.myEnforcedMeshes.size() << std::endl;
2056 QString HYBRIDPluginGUI_HypothesisCreator::caption() const
2058 return tr( "HYBRID_TITLE" );
2061 QPixmap HYBRIDPluginGUI_HypothesisCreator::icon() const
2063 return SUIT_Session::session()->resourceMgr()->loadPixmap( "HYBRIDPlugin", tr( "ICON_DLG_HYBRID_PARAMETERS" ) );
2066 QString HYBRIDPluginGUI_HypothesisCreator::type() const
2068 return tr( "HYBRID_HYPOTHESIS" );
2071 QString HYBRIDPluginGUI_HypothesisCreator::helpPage() const
2073 return "hybrid_hypo_page.html";