1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : HYBRIDPluginGUI_HypothesisCreator.cxx
22 // Author : Christian VAN WAMBEKE (CEA)
25 #include "HYBRIDPluginGUI_HypothesisCreator.h"
26 #include "HYBRIDPluginGUI_Enums.h"
27 #include "HYBRIDPluginGUI_Dlg.h"
29 #include <GeometryGUI.h>
31 #include <SMESHGUI_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>
74 // #include <windows.h>
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 ); #stay, not view, may be used tomorrow...
395 myToMeshHolesCheck->hide();
396 myToMakeGroupsOfDomains = new QCheckBox( tr( "HYBRID_TO_MAKE_DOMAIN_GROUPS" ), myStdGroup );
397 //aStdLayout->addWidget( myToMakeGroupsOfDomains, row++, 1, 1, 1 ); #stay, not view, may be used tomorrow...
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 ); #stay, not view, may be used tomorrow...
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");
509 // Enforced vertices parameters
510 myEnfGroup = new QWidget();
511 QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup);
512 myEnforcedTableWidget = new QTableWidget(myEnfGroup);
513 myEnforcedTableWidget ->setMinimumWidth(300);
514 myEnforcedTableWidget->setRowCount( 0 );
515 myEnforcedTableWidget->setColumnCount( ENF_VER_NB_COLUMNS );
516 myEnforcedTableWidget->setSortingEnabled(true);
517 QStringList enforcedHeaders;
518 enforcedHeaders << tr( "HYBRID_ENF_NAME_COLUMN" )
519 << tr( "HYBRID_ENF_VER_X_COLUMN" )<< tr( "HYBRID_ENF_VER_Y_COLUMN" ) << tr( "HYBRID_ENF_VER_Z_COLUMN" )
520 << tr( "HYBRID_ENF_SIZE_COLUMN" ) << tr("HYBRID_ENF_ENTRY_COLUMN") << tr("HYBRID_ENF_VER_COMPOUND_COLUMN") << tr( "HYBRID_ENF_GROUP_COLUMN" );
522 myEnforcedTableWidget->setHorizontalHeaderLabels(enforcedHeaders);
523 myEnforcedTableWidget->verticalHeader()->hide();
524 myEnforcedTableWidget->horizontalHeader()->setStretchLastSection(true);
525 myEnforcedTableWidget->setAlternatingRowColors(true);
526 myEnforcedTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
527 myEnforcedTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
528 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
529 myEnforcedTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
531 myEnforcedTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
533 myEnforcedTableWidget->resizeColumnsToContents();
534 myEnforcedTableWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
535 myEnforcedTableWidget->hideColumn(ENF_VER_COMPOUND_COLUMN);
537 myEnforcedTableWidget->setItemDelegate(new EnforcedVertexTableWidgetDelegate());
540 TColStd_MapOfInteger shapeTypes;
541 shapeTypes.Add( TopAbs_VERTEX );
542 shapeTypes.Add( TopAbs_COMPOUND );
544 SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes);
545 myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true);
546 myEnfVertexWdg->SetDefaultText(tr("HYBRID_ENF_SELECT_VERTEX"), "QLineEdit { color: grey }");
548 QLabel* myXCoordLabel = new QLabel( tr( "HYBRID_ENF_VER_X_LABEL" ), myEnfGroup );
549 myXCoord = new SMESHGUI_SpinBox(myEnfGroup);
550 myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
551 QLabel* myYCoordLabel = new QLabel( tr( "HYBRID_ENF_VER_Y_LABEL" ), myEnfGroup );
552 myYCoord = new SMESHGUI_SpinBox(myEnfGroup);
553 myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
554 QLabel* myZCoordLabel = new QLabel( tr( "HYBRID_ENF_VER_Z_LABEL" ), myEnfGroup );
555 myZCoord = new SMESHGUI_SpinBox(myEnfGroup);
556 myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
557 QLabel* mySizeLabel = new QLabel( tr( "HYBRID_ENF_SIZE_LABEL" ), myEnfGroup );
558 mySizeValue = new SMESHGUI_SpinBox(myEnfGroup);
559 mySizeValue->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
561 QLabel* myGroupNameLabel = new QLabel( tr( "HYBRID_ENF_GROUP_LABEL" ), myEnfGroup );
562 myGroupName = new QLineEdit(myEnfGroup);
564 addVertexButton = new QPushButton(tr("HYBRID_ENF_ADD"),myEnfGroup);
565 addVertexButton->setEnabled(false);
566 removeVertexButton = new QPushButton(tr("HYBRID_ENF_REMOVE"),myEnfGroup);
567 // myGlobalGroupName = new QCheckBox(tr("HYBRID_ENF_VER_GROUPS"), myEnfGroup);
568 // myGlobalGroupName->setChecked(false);
570 // QGroupBox* GroupBox = new QGroupBox( myEnfGroup );
571 // QLabel* info = new QLabel( GroupBox );
572 // info->setText( tr( "HYBRID_ENF_VER_INFO" ) );
573 // info->setWordWrap( true );
574 // QVBoxLayout* GroupBoxVLayout = new QVBoxLayout( GroupBox );
575 // GroupBoxVLayout->setSpacing( 6 );
576 // GroupBoxVLayout->setMargin( 11 );
577 // GroupBoxVLayout->addWidget( info );
580 //anEnfLayout->addWidget(GroupBox, ENF_VER_WARNING, 0, 1, 2 );
581 anEnfLayout->addWidget(myEnforcedTableWidget, ENF_VER_VERTEX, 0, ENF_VER_NB_LINES, 1);
583 QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup);
584 anEnfLayout2->addWidget(myEnfVertexWdg, ENF_VER_VERTEX, 0, 1, 2);
585 anEnfLayout2->addWidget(myXCoordLabel, ENF_VER_X_COORD, 0, 1, 1);
586 anEnfLayout2->addWidget(myXCoord, ENF_VER_X_COORD, 1, 1, 1);
587 anEnfLayout2->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 0, 1, 1);
588 anEnfLayout2->addWidget(myYCoord, ENF_VER_Y_COORD, 1, 1, 1);
589 anEnfLayout2->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 0, 1, 1);
590 anEnfLayout2->addWidget(myZCoord, ENF_VER_Z_COORD, 1, 1, 1);
591 anEnfLayout2->addWidget(mySizeLabel, ENF_VER_SIZE, 0, 1, 1);
592 anEnfLayout2->addWidget(mySizeValue, ENF_VER_SIZE, 1, 1, 1);
593 anEnfLayout2->addWidget(myGroupNameLabel, ENF_VER_GROUP, 0, 1, 1);
594 anEnfLayout2->addWidget(myGroupName, ENF_VER_GROUP, 1, 1, 1);
595 anEnfLayout2->addWidget(addVertexButton, ENF_VER_BTN, 0, 1, 1);
596 anEnfLayout2->addWidget(removeVertexButton, ENF_VER_BTN, 1, 1, 1);
597 anEnfLayout2->setRowStretch(ENF_VER_NB_LINES, 1);
599 anEnfLayout->addLayout(anEnfLayout2, ENF_VER_VERTEX, 1,ENF_VER_NB_LINES, 1);
600 anEnfLayout->setRowStretch(ENF_VER_VERTEX, 10);
602 // Enforced meshes parameters
603 myEnfMeshGroup = new QWidget();
604 myLayersOnAllWrapCheck = new QCheckBox( tr( "HYBRID_LAYERS_ON_ALL_WRAP" ), myEnfMeshGroup );
605 QGridLayout* anEnfMeshLayout = new QGridLayout(myEnfMeshGroup);
607 myEnforcedMeshTableWidget = new QTableWidget(myEnfGroup);
608 myEnforcedMeshTableWidget->setRowCount( 0 );
609 myEnforcedMeshTableWidget->setColumnCount( ENF_MESH_NB_COLUMNS );
610 myEnforcedMeshTableWidget->setSortingEnabled(true);
611 myEnforcedMeshTableWidget->verticalHeader()->hide();
612 QStringList enforcedMeshHeaders;
613 enforcedMeshHeaders << tr( "HYBRID_ENF_NAME_COLUMN" )
614 << tr( "HYBRID_ENF_ENTRY_COLUMN" )
615 << tr( "HYBRID_ENF_MESH_CONSTRAINT_COLUMN" )
616 << tr( "HYBRID_ENF_GROUP_COLUMN" );
617 myEnforcedMeshTableWidget->setHorizontalHeaderLabels(enforcedMeshHeaders);
618 myEnforcedMeshTableWidget->horizontalHeader()->setStretchLastSection(true);
619 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
620 myEnforcedMeshTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
622 myEnforcedMeshTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
624 myEnforcedMeshTableWidget->setAlternatingRowColors(true);
625 myEnforcedMeshTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
626 myEnforcedMeshTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
627 myEnforcedMeshTableWidget->resizeColumnsToContents();
628 myEnforcedMeshTableWidget->hideColumn(ENF_MESH_ENTRY_COLUMN);
630 myEnforcedMeshTableWidget->setItemDelegate(new EnforcedMeshTableWidgetDelegate());
632 // myEnfMesh = SMESH::SMESH_Mesh::_nil();
633 // myEnfMeshArray = new SMESH::mesh_array();
635 myEnfMeshWdg = new StdMeshersGUI_ObjectReferenceParamWdg( SMESH::IDSOURCE, myEnfMeshGroup, /*multiSel=*/true);
636 myEnfMeshWdg->SetDefaultText(tr("HYBRID_ENF_SELECT_MESH"), "QLineEdit { color: grey }");
638 myEnfMeshWdg->AvoidSimultaneousSelection(myEnfVertexWdg);
639 ////myEnfMeshWdg->hide(); //may be used later
641 QLabel* myMeshConstraintLabel = new QLabel( tr( "HYBRID_ENF_MESH_CONSTRAINT_LABEL" ), myEnfMeshGroup );
642 myEnfMeshConstraint = new QComboBox(myEnfMeshGroup);
643 myEnfMeshConstraint->insertItems(0,myEnfMeshConstraintLabels);
644 myEnfMeshConstraint->setEditable(false);
645 myEnfMeshConstraint->setCurrentIndex(2); //EZ: use mesh group of faces for a layer
646 myMeshConstraintLabel->hide(); //may be used later
647 myEnfMeshConstraint->hide(); //may be used later
649 QLabel* myMeshGroupNameLabel = new QLabel( tr( "HYBRID_ENF_GROUP_LABEL" ), myEnfMeshGroup );
650 myMeshGroupName = new QLineEdit(myEnfMeshGroup);
651 myMeshGroupNameLabel->hide(); //may be used later
652 myMeshGroupName->hide(); //may be used later
654 addEnfMeshButton = new QPushButton(tr("HYBRID_ENF_ADD"),myEnfMeshGroup);
655 // addEnfMeshButton->setEnabled(false);
656 removeEnfMeshButton = new QPushButton(tr("HYBRID_ENF_REMOVE"),myEnfMeshGroup);
658 // QGroupBox* GroupBox2 = new QGroupBox( myEnfMeshGroup );
659 // QLabel* info2 = new QLabel( GroupBox2 );
660 // info2->setText( tr( "HYBRID_ENF_MESH_INFO" ) );
661 // info2->setWordWrap( true );
662 // QVBoxLayout* GroupBox2VLayout = new QVBoxLayout( GroupBox2 );
663 // GroupBox2VLayout->setSpacing( 6 );
664 // GroupBox2VLayout->setMargin( 11 );
665 // GroupBox2VLayout->addWidget( info2 );
667 // anEnfMeshLayout->addWidget( GroupBox2, ENF_MESH_WARNING, 0, 1, 2 );
668 anEnfMeshLayout->addWidget(myLayersOnAllWrapCheck, ENF_MESH_MESH, 0, 1 , 1);
669 anEnfMeshLayout->addWidget(myEnforcedMeshTableWidget, ENF_MESH_MESH+1, 0, ENF_MESH_NB_LINES , 1);
671 QGridLayout* anEnfMeshLayout2 = new QGridLayout(myEnfMeshGroup);
672 anEnfMeshLayout2->addWidget(myEnfMeshWdg, ENF_MESH_MESH, 0, 1, 2);
673 //TODO remove or not be lateful to select layers...
674 //anEnfMeshLayout2->addWidget(myMeshConstraintLabel, ENF_MESH_CONSTRAINT, 0, 1, 1);
675 //anEnfMeshLayout2->addWidget(myEnfMeshConstraint, ENF_MESH_CONSTRAINT, 1, 1, 1);
676 //anEnfMeshLayout2->addWidget(myMeshGroupNameLabel, ENF_MESH_GROUP, 0, 1, 1);
677 //anEnfMeshLayout2->addWidget(myMeshGroupName, ENF_MESH_GROUP, 1, 1, 1);
678 anEnfMeshLayout2->addWidget(addEnfMeshButton, ENF_MESH_BTN, 0, 1, 1);
679 anEnfMeshLayout2->addWidget(removeEnfMeshButton, ENF_MESH_BTN, 1, 1, 1);
680 anEnfMeshLayout2->setRowStretch(ENF_MESH_NB_LINES, 1);
682 anEnfMeshLayout->addLayout(anEnfMeshLayout2, ENF_MESH_MESH+1, 1, ENF_MESH_NB_LINES, 1);
683 anEnfMeshLayout->setRowStretch(ENF_MESH_MESH, 10);
687 tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
688 tab->insertTab( ADV_TAB, myAdvGroup, tr( "HYBRID_ADV_ARGS" ) );
689 //TODO remove or er usmay be lateful to select layers...
690 //tab->insertTab( ENF_VER_TAB, myEnfGroup, tr( "HYBRID_ENFORCED_VERTICES" ) );
691 tab->insertTab( ENF_MESH_TAB, myEnfMeshGroup, tr( "HYBRID_ENFORCED_MESHES" ) );
692 tab->setCurrentIndex( STD_TAB );
695 //connect( myLayersOnAllWrapCheck, SIGNAL( toggled( bool ) ), this, SLOT( onLayersOnAllWrap(bool)));
696 connect( myLayersOnAllWrapCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
697 //connect( myToMeshHolesCheck, SIGNAL( toggled( bool ) ), this, SLOT( onToMeshHoles(bool)));
698 //connect( myAdvWidget->maxMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
699 //connect( myAdvWidget->initialMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
700 //connect( myAdvWidget->boundaryRecoveryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
702 //connect( myBoundaryLayersGrowthCombo, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
703 //connect( myElementGenerationCombo, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
704 connect( myAddMultinormalsCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
705 connect( mySmoothNormalsCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
707 connect( myAdvWidget->logInFileCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
708 connect( myAdvWidget->keepWorkingFilesCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
709 connect( myAdvWidget->workingDirectoryPushButton, SIGNAL( clicked() ), this, SLOT( onDirBtnClicked() ) );
711 connect( myEnforcedTableWidget, SIGNAL( itemClicked(QTableWidgetItem *)), this, SLOT( synchronizeCoords() ) );
712 connect( myEnforcedTableWidget, SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
713 connect( myEnforcedTableWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
714 connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertex() ) );
715 connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
716 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
717 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
718 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
719 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
720 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
721 connect( mySizeValue, SIGNAL( textChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) );
722 connect( myXCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
723 connect( myYCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
724 connect( myZCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
725 connect( mySizeValue, SIGNAL( valueChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) );
726 connect( this, SIGNAL( vertexDefined(bool) ), addVertexButton, SLOT( setEnabled(bool) ) );
728 connect( addEnfMeshButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedMesh() ) );
729 connect( removeEnfMeshButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedMesh() ) );
730 // connect( myEnfMeshWdg, SIGNAL( contentModified()), this, SLOT( checkEnfMeshIsDefined() ) );
731 // connect( myEnfMeshConstraint, SIGNAL( currentIndexChanged(int) ), this, SLOT( checkEnfMeshIsDefined() ) );
732 // connect( this, SIGNAL( enfMeshDefined(bool) ), addEnfMeshButton, SLOT( setEnabled(bool) ) );
738 * This method checks if an enforced vertex is defined;
740 void HYBRIDPluginGUI_HypothesisCreator::clearEnfVertexSelection()
742 if (myEnfVertexWdg->NbObjects() != 0) {
743 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
744 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
745 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
746 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
747 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
749 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
750 that->checkVertexIsDefined();
754 * This method checks if an enforced vertex is defined;
756 void HYBRIDPluginGUI_HypothesisCreator::checkVertexIsDefined()
758 bool enfVertexIsDefined = false;
759 enfVertexIsDefined = (!mySizeValue->GetString().isEmpty() &&
760 (!myEnfVertexWdg->NbObjects() == 0 ||
761 (myEnfVertexWdg->NbObjects() == 0 && !myXCoord->GetString().isEmpty()
762 && !myYCoord->GetString().isEmpty()
763 && !myZCoord->GetString().isEmpty())));
764 emit vertexDefined(enfVertexIsDefined);
768 * This method checks if an enforced mesh is defined;
770 void HYBRIDPluginGUI_HypothesisCreator::checkEnfMeshIsDefined()
772 emit enfMeshDefined( myEnfVertexWdg->NbObjects() != 0);
776 * This method resets the content of the X, Y, Z, size and GroupName widgets;
778 void HYBRIDPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
780 myXCoord->setCleared(true);
781 myYCoord->setCleared(true);
782 myZCoord->setCleared(true);
783 // mySizeValue->setCleared(true);
784 myXCoord->setText("");
785 myYCoord->setText("");
786 myZCoord->setText("");
787 // mySizeValue->setText("");
788 // myGroupName->setText("");
789 addVertexButton->setEnabled(false);
792 /** HYBRIDPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item)
793 This method updates the tooltip of a modified item. The QLineEdit widgets content
794 is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
796 void HYBRIDPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTableWidgetItem* item) {
797 // MESSAGE("HYBRIDPluginGUI_HypothesisCreator::updateEnforcedVertexValues");
798 int row = myEnforcedTableWidget->row(item);
800 QVariant vertexName = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole);
801 QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole);
802 QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole);
803 QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole);
804 QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole);
805 QVariant entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
806 QString groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole).toString();
808 clearEnforcedVertexWidgets();
810 if ( !x.isNull() || !entry.isNull()) {
811 QString toolTip = vertexName.toString();
812 toolTip += QString("(");
813 if (entry.isNull() || (!entry.isNull() && entry.toString() == "")) {
814 toolTip += x.toString();
815 toolTip += QString(", ") + y.toString();
816 toolTip += QString(", ") + z.toString();
819 toolTip += entry.toString();
820 toolTip += QString(")");
823 toolTip += QString("=") + size.toString();
825 if (!groupName.isEmpty())
826 toolTip += QString(" [") + groupName + QString("]");
828 // MESSAGE("Tooltip: " << toolTip.toStdString());
829 for (int col=0;col<ENF_VER_NB_COLUMNS;col++)
830 myEnforcedTableWidget->item(row,col)->setToolTip(toolTip);
833 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
834 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
835 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
836 myXCoord->SetValue(x.toDouble());
837 myYCoord->SetValue(y.toDouble());
838 myZCoord->SetValue(z.toDouble());
839 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
840 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
841 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
844 mySizeValue->SetValue(size.toDouble());
846 if (!groupName.isEmpty())
847 myGroupName->setText(groupName);
851 void HYBRIDPluginGUI_HypothesisCreator::onSelectEnforcedVertex() {
852 int nbSelEnfVertex = myEnfVertexWdg->NbObjects();
853 clearEnforcedVertexWidgets();
854 if (nbSelEnfVertex == 1)
856 if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() )
859 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
860 if (myEnfVertex == GEOM::GEOM_Object::_nil())
862 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
863 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
864 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations();
865 if (CORBA::is_nil(measureOp))
869 measureOp->PointCoordinates (myEnfVertex, x, y, z);
870 if ( measureOp->IsDone() )
872 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
873 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
874 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
875 myXCoord->SetValue(x);
876 myYCoord->SetValue(y);
877 myZCoord->SetValue(z);
878 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
879 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
880 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
886 /** HYBRIDPluginGUI_HypothesisCreator::synchronizeCoords()
887 This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
888 of the enforced vertex clicked in the tree widget.
890 void HYBRIDPluginGUI_HypothesisCreator::synchronizeCoords() {
891 clearEnforcedVertexWidgets();
892 QList<QTableWidgetItem *> items = myEnforcedTableWidget->selectedItems();
893 // myEnfVertexWdg->disconnect(SIGNAL(contentModified()));
894 disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
895 if (! items.isEmpty()) {
896 QTableWidgetItem *item;
899 if (items.size() == 1) {
901 row = myEnforcedTableWidget->row(item);
902 QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole);
903 QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole);
904 QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole);
905 QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole);
906 entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
907 if (!entry.isNull()) {
908 SMESH::string_array_var objIds = new SMESH::string_array;
910 objIds[0] = entry.toString().toStdString().c_str();
911 myEnfVertexWdg->SetObjects(objIds);
914 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
916 QVariant group = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole);
917 if (!x.isNull()/* && entry.isNull()*/) {
918 // disconnect( myXCoord, SIGNAL( textChanged(const QString &)), this, SLOT( onSelectEnforcedVertex() ) );
919 disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
920 disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
921 disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
922 myXCoord->SetValue(x.toDouble());
923 myYCoord->SetValue(y.toDouble());
924 myZCoord->SetValue(z.toDouble());
925 connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
926 connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
927 connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
930 mySizeValue->SetValue(size.toDouble());
932 if (!group.isNull() && (!x.isNull() || !entry.isNull()))
933 myGroupName->setText(group.toString());
936 QList<QString> entryList;
937 for (int i = 0; i < items.size(); ++i) {
939 row = myEnforcedTableWidget->row(item);
940 entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
942 entryList << entry.toString();
944 if (entryList.size() > 0) {
945 SMESH::string_array_var objIds = new SMESH::string_array;
946 objIds->length(entryList.size());
947 for (int i = 0; i < entryList.size() ; i++)
948 objIds[i] = entryList.at(i).toStdString().c_str();
949 myEnfVertexWdg->SetObjects(objIds);
952 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
957 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
959 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
960 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
961 that->checkVertexIsDefined();
964 /** HYBRIDPluginGUI_HypothesisCreator::addEnforcedMesh( meshName, geomEntry, elemType, size, groupName)
965 This method adds in the tree widget an enforced mesh from mesh, submesh or group with optionally size and and groupName.
967 void HYBRIDPluginGUI_HypothesisCreator::addEnforcedMesh(std::string name, std::string entry, int elementType, std::string groupName)
969 MESSAGE("addEnforcedMesh(\"" << name << ", \"" << entry << "\", " << elementType << ", \"" << groupName << "\")");
970 bool okToCreate = true;
971 QString itemEntry = "";
972 int itemElementType = 0;
973 int rowCount = myEnforcedMeshTableWidget->rowCount();
974 bool allColumns = true;
975 for (int row = 0;row<rowCount;row++) {
976 for (int col = 0 ; col < ENF_MESH_NB_COLUMNS ; col++) {
977 MESSAGE("col: " << col);
978 if (col == ENF_MESH_CONSTRAINT_COLUMN){
979 if (qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row, col)) == 0) {
981 MESSAGE("allColumns = false");
985 else if (myEnforcedMeshTableWidget->item(row, col) == 0) {
987 MESSAGE("allColumns = false");
990 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
991 QComboBox* itemComboBox = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row, col));
992 itemElementType = itemComboBox->currentIndex();
993 MESSAGE("itemElementType: " << itemElementType);
995 else if (col == ENF_MESH_ENTRY_COLUMN)
996 itemEntry = myEnforcedMeshTableWidget->item(row, col)->data(Qt::EditRole).toString();
1002 if (itemEntry == QString(entry.c_str()) && itemElementType == elementType) {
1003 // // update group name
1004 // if (itemGroupName.toStdString() != groupName) {
1005 // MESSAGE("Group is updated from \"" << itemGroupName.toStdString() << "\" to \"" << groupName << "\"");
1006 // myEnforcedMeshTableWidget->item(row, ENF_MESH_GROUP_COLUMN)->setData( Qt::EditRole, QVariant(groupName.c_str()));
1017 MESSAGE("Creation of enforced mesh");
1019 myEnforcedMeshTableWidget->setRowCount(rowCount+1);
1020 myEnforcedMeshTableWidget->setSortingEnabled(false);
1022 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++) {
1023 MESSAGE("Column: " << col);
1024 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1025 QComboBox* comboBox = new QComboBox();
1026 QPalette pal = comboBox->palette();
1027 pal.setColor(QPalette::Button, Qt::white);
1028 comboBox->setPalette(pal);
1029 comboBox->insertItems(0,myEnfMeshConstraintLabels);
1030 comboBox->setEditable(false);
1031 comboBox->setCurrentIndex(elementType);
1032 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << comboBox->currentText().toStdString());
1033 myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox);
1036 QTableWidgetItem* item = new QTableWidgetItem();
1037 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1039 case ENF_MESH_NAME_COLUMN:
1040 item->setData( 0, name.c_str() );
1041 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1042 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1043 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1045 case ENF_MESH_ENTRY_COLUMN:
1046 item->setData( 0, entry.c_str() );
1047 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1048 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1049 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1051 case ENF_MESH_GROUP_COLUMN:
1052 item->setData( 0, groupName.c_str() );
1053 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1054 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1063 // connect( myEnforcedMeshTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1065 myEnforcedMeshTableWidget->setSortingEnabled(true);
1066 // myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1067 // updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1071 /** HYBRIDPluginGUI_HypothesisCreator::addEnforcedVertex( x, y, z, size, vertexName, geomEntry, groupName)
1072 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.
1074 void HYBRIDPluginGUI_HypothesisCreator::addEnforcedVertex(double x, double y, double z, double size, std::string vertexName, std::string geomEntry, std::string groupName, bool isCompound)
1076 MESSAGE("addEnforcedVertex(" << x << ", " << y << ", " << z << ", " << size << ", \"" << vertexName << ", \"" << geomEntry << "\", \"" << groupName << "\", " << isCompound << ")");
1077 myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1078 bool okToCreate = true;
1079 double itemX,itemY,itemZ,itemSize = 0;
1080 QString itemEntry, itemGroupName = QString("");
1081 // bool itemIsCompound;
1082 int rowCount = myEnforcedTableWidget->rowCount();
1085 for (int row = 0;row<rowCount;row++) {
1087 for (int col = 0 ; col < ENF_VER_NB_COLUMNS ; col++) {
1088 if (myEnforcedTableWidget->item(row, col) == 0) {
1093 data = myEnforcedTableWidget->item(row, col)->data(Qt::EditRole);
1094 if (!data.isNull()) {
1096 case ENF_VER_GROUP_COLUMN:
1097 itemGroupName = data.toString();
1099 case ENF_VER_ENTRY_COLUMN:
1100 itemEntry = data.toString();
1102 // case ENF_VER_COMPOUND_COLUMN:
1103 // itemIsCompound = data.toBool();
1105 case ENF_VER_X_COLUMN:
1106 itemX = data.toDouble();
1108 case ENF_VER_Y_COLUMN:
1109 itemY = data.toDouble();
1111 case ENF_VER_Z_COLUMN:
1112 itemZ = data.toDouble();
1114 case ENF_VER_SIZE_COLUMN:
1115 itemSize = data.toDouble();
1127 if (( !isCompound && ((itemX == x) && (itemY == y) && (itemZ == z))) || /*( (itemEntry.toStdString() != "") && */ (itemEntry.toStdString() == geomEntry)/*)*/) {
1129 if (itemSize != size) {
1130 MESSAGE("Size is updated from \"" << itemSize << "\" to \"" << size << "\"");
1131 myEnforcedTableWidget->item(row, ENF_VER_SIZE_COLUMN)->setData( Qt::EditRole, QVariant(size));
1133 // update group name
1134 if (itemGroupName.toStdString() != groupName) {
1135 MESSAGE("Group is updated from \"" << itemGroupName.toStdString() << "\" to \"" << groupName << "\"");
1136 myEnforcedTableWidget->item(row, ENF_VER_GROUP_COLUMN)->setData( Qt::EditRole, QVariant(groupName.c_str()));
1143 if (geomEntry.empty()) {
1144 MESSAGE("Vertex with coords " << x << ", " << y << ", " << z << " already exist: dont create again");
1147 MESSAGE("Vertex with entry " << geomEntry << " already exist: dont create again");
1152 if (geomEntry.empty()) {
1153 MESSAGE("Vertex with coords " << x << ", " << y << ", " << z<< " is created");
1156 MESSAGE("Vertex with geom entry " << geomEntry << " is created");
1161 QString myVertexName;
1162 while(indexRef != vertexIndex) {
1163 indexRef = vertexIndex;
1164 if (vertexName.empty())
1165 myVertexName = QString("Vertex #%1").arg(vertexIndex);
1167 myVertexName = QString(vertexName.c_str());
1169 for (int row = 0;row<rowCount;row++) {
1170 QString name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString();
1171 if (myVertexName == name) {
1178 MESSAGE("myVertexName is \"" << myVertexName.toStdString() << "\"");
1179 myEnforcedTableWidget->setRowCount(rowCount+1);
1180 myEnforcedTableWidget->setSortingEnabled(false);
1181 for (int col=0;col<ENF_VER_NB_COLUMNS;col++) {
1182 MESSAGE("Column: " << col);
1183 QTableWidgetItem* item = new QTableWidgetItem();
1184 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1186 case ENF_VER_NAME_COLUMN:
1187 item->setData( Qt::EditRole, myVertexName );
1188 if (!geomEntry.empty()) {
1190 item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1192 item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1195 case ENF_VER_X_COLUMN:
1197 item->setData( 0, QVariant(x) );
1199 case ENF_VER_Y_COLUMN:
1201 item->setData( 0, QVariant(y) );
1203 case ENF_VER_Z_COLUMN:
1205 item->setData( 0, QVariant(z) );
1207 case ENF_VER_SIZE_COLUMN:
1208 item->setData( 0, QVariant(size) );
1210 case ENF_VER_ENTRY_COLUMN:
1211 if (!geomEntry.empty())
1212 item->setData( 0, QString(geomEntry.c_str()) );
1214 case ENF_VER_COMPOUND_COLUMN:
1215 item->setData( Qt::CheckStateRole, isCompound );
1216 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
1218 case ENF_VER_GROUP_COLUMN:
1219 if (!groupName.empty())
1220 item->setData( 0, QString(groupName.c_str()) );
1226 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1227 myEnforcedTableWidget->setItem(rowCount,col,item);
1231 connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1233 myEnforcedTableWidget->setSortingEnabled(true);
1234 // myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1235 updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1238 /** HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedMesh()
1239 This method is called when a item is added into the enforced meshes tree widget
1241 void HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedMesh()
1243 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedMesh()");
1245 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1247 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1248 myEnfMeshWdg->deactivateSelection();
1250 for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column)
1251 myEnforcedMeshTableWidget->resizeColumnToContents(column);
1254 int selEnfMeshes = myEnfMeshWdg->NbObjects();
1255 if (selEnfMeshes == 0)
1258 std::string groupName = myMeshGroupName->text().toStdString();
1259 // if (myGlobalGroupName->isChecked())
1260 // groupName = myGlobalGroupName->text().toStdString();
1262 if (boost::trim_copy(groupName).empty())
1263 groupName = "LayersGroup"; //have to be not empty until non used
1265 int elementType = myEnfMeshConstraint->currentIndex();
1268 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1269 _PTR(SObject) aSObj; //SMESH::SMESH_IDSource::_nil;
1270 QString meshEntry = myEnfMeshWdg->GetValue();
1271 MESSAGE("myEnfMeshWdg->GetValue()" << meshEntry.toStdString());
1273 if (selEnfMeshes == 1)
1275 MESSAGE("1 SMESH object selected");
1276 // myEnfMesh = myEnfMeshWdg->GetObject< SMESH::SMESH_IDSource >();
1277 // std::string entry = myEnfMeshWdg->GetValue();
1278 aSObj = aStudy->FindObjectID(meshEntry.toStdString().c_str());
1279 CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy);
1280 if (!CORBA::is_nil(anObj)) {
1281 // SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1282 addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
1287 MESSAGE(selEnfMeshes << " SMESH objects selected");
1288 QStringList meshEntries = meshEntry.split(" ", QString::SkipEmptyParts);
1289 QStringListIterator meshEntriesIt (meshEntries);
1290 while (meshEntriesIt.hasNext()) {
1291 aSObj = aStudy->FindObjectID(meshEntriesIt.next().toStdString().c_str());
1292 CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy);
1293 if (!CORBA::is_nil(anObj)) {
1294 // SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1295 addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
1300 myEnfVertexWdg->SetObject(SMESH::SMESH_IDSource::_nil());
1302 for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column)
1303 myEnforcedMeshTableWidget->resizeColumnToContents(column);
1307 /** HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedVertex()
1308 This method is called when a item is added into the enforced vertices tree widget
1310 void HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedVertex()
1312 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::onAddEnforcedVertex()");
1314 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1316 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1317 myEnfVertexWdg->deactivateSelection();
1319 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1320 myEnforcedTableWidget->resizeColumnToContents(column);
1323 int selEnfVertex = myEnfVertexWdg->NbObjects();
1324 bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty());
1325 if ((selEnfVertex == 0) && coordsEmpty)
1328 std::string groupName = myGroupName->text().toStdString();
1329 // if (myGlobalGroupName->isChecked())
1330 // groupName = myGlobalGroupName->text().toStdString();
1332 if (boost::trim_copy(groupName).empty())
1335 double size = mySizeValue->GetValue();
1337 if (selEnfVertex <= 1)
1339 MESSAGE("0 or 1 GEOM object selected");
1340 double x = 0, y = 0, z=0;
1341 if (myXCoord->GetString() != "") {
1342 x = myXCoord->GetValue();
1343 y = myYCoord->GetValue();
1344 z = myZCoord->GetValue();
1346 if (selEnfVertex == 1) {
1347 MESSAGE("1 GEOM object selected");
1348 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >();
1349 std::string entry = "";
1350 if (myEnfVertex != GEOM::GEOM_Object::_nil())
1351 entry = myEnfVertex->GetStudyEntry();
1352 addEnforcedVertex(x, y, z, size, myEnfVertex->GetName(),entry, groupName, myEnfVertex->GetShapeType() == GEOM::COMPOUND);
1355 MESSAGE("0 GEOM object selected");
1356 MESSAGE("Coords: ("<<x<<","<<y<<","<<z<<")");
1357 addEnforcedVertex(x, y, z, size, "", "", groupName);
1362 if ( CORBA::is_nil(getGeomEngine()))
1365 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations();
1366 if (CORBA::is_nil(measureOp))
1369 CORBA::Double x = 0, y = 0,z = 0;
1370 for (int j = 0 ; j < selEnfVertex ; j++)
1372 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j);
1373 if (myEnfVertex == GEOM::GEOM_Object::_nil())
1375 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1376 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1377 if ( measureOp->IsDone() )
1378 addEnforcedVertex(x, y, z, size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1379 } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) {
1380 addEnforcedVertex(0., 0., 0., size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName, true);
1385 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1387 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1388 myEnforcedTableWidget->resizeColumnToContents(column);
1391 /** HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedMesh()
1392 This method is called when a item is removed from the enforced meshes tree widget
1394 void HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedMesh()
1396 QList<int> selectedRows;
1397 QList<QTableWidgetItem *> selectedItems = myEnforcedMeshTableWidget->selectedItems();
1398 QTableWidgetItem* item;
1400 foreach( item, selectedItems ) {
1402 if (!selectedRows.contains( row ) )
1403 selectedRows.append(row);
1406 qSort( selectedRows );
1407 QListIterator<int> it( selectedRows );
1409 while ( it.hasPrevious() ) {
1410 row = it.previous();
1411 MESSAGE("delete row #"<< row);
1412 myEnforcedMeshTableWidget->removeRow(row );
1415 myEnforcedMeshTableWidget->selectionModel()->clearSelection();
1418 /** HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1419 This method is called when a item is removed from the enforced vertices tree widget
1421 void HYBRIDPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1423 QList<int> selectedRows;
1424 QList<QTableWidgetItem *> selectedItems = myEnforcedTableWidget->selectedItems();
1425 QTableWidgetItem* item;
1427 foreach( item, selectedItems ) {
1429 if (!selectedRows.contains( row ) )
1430 selectedRows.append(row);
1433 qSort( selectedRows );
1434 QListIterator<int> it( selectedRows );
1436 while ( it.hasPrevious() ) {
1437 row = it.previous();
1438 MESSAGE("delete row #"<< row);
1439 myEnforcedTableWidget->removeRow(row );
1442 myEnforcedTableWidget->selectionModel()->clearSelection();
1445 void HYBRIDPluginGUI_HypothesisCreator::onLayersOnAllWrap(bool isOn)
1447 // myToMakeGroupsOfDomains->setEnabled( isOn );
1449 // myToMakeGroupsOfDomains->setChecked( false );
1452 void HYBRIDPluginGUI_HypothesisCreator::onToMeshHoles(bool isOn)
1454 // myToMakeGroupsOfDomains->setEnabled( isOn );
1456 // myToMakeGroupsOfDomains->setChecked( false );
1459 void HYBRIDPluginGUI_HypothesisCreator::onDirBtnClicked()
1461 QString dir = SUIT_FileDlg::getExistingDirectory( dlg(), myAdvWidget->workingDirectoryLineEdit->text(), QString() );
1462 if ( !dir.isEmpty() )
1463 myAdvWidget->workingDirectoryLineEdit->setText( dir );
1466 void HYBRIDPluginGUI_HypothesisCreator::updateWidgets()
1468 //customs automatic set
1469 //myToMakeGroupsOfDomains->setEnabled( myToMeshHolesCheck->isChecked() );
1470 //myAdvWidget->maxMemorySpin->setEnabled( myAdvWidget->maxMemoryCheck->isChecked() );
1471 //myAdvWidget->initialMemoryCheck->setEnabled( !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1472 //myAdvWidget->initialMemorySpin->setEnabled( myAdvWidget->initialMemoryCheck->isChecked() && !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1473 //myOptimizationLevelCombo->setEnabled( !myAdvWidget->boundaryRecoveryCheck->isChecked() );
1474 myMultinormalsAngleSpin->setEnabled( myAddMultinormalsCheck->isChecked() );
1475 if ( sender() == myAdvWidget->logInFileCheck ||
1476 sender() == myAdvWidget->keepWorkingFilesCheck )
1478 bool logFileRemovable = myAdvWidget->logInFileCheck->isChecked() &&
1479 !myAdvWidget->keepWorkingFilesCheck->isChecked();
1481 myAdvWidget->removeLogOnSuccessCheck->setEnabled( logFileRemovable );
1483 bool enabled = !myLayersOnAllWrapCheck->isChecked();
1484 myEnforcedMeshTableWidget->setEnabled(enabled);
1485 addEnfMeshButton->setEnabled(enabled);
1486 removeEnfMeshButton->setEnabled(enabled);
1487 myEnfMeshWdg->setEnabled(enabled);
1488 //xxx->setEnabled(enabled);
1491 bool HYBRIDPluginGUI_HypothesisCreator::checkParams(QString& msg) const
1493 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::checkParams");
1495 if ( !QFileInfo( myAdvWidget->workingDirectoryLineEdit->text().trimmed() ).isWritable() ) {
1496 SUIT_MessageBox::warning( dlg(),
1497 tr( "SMESH_WRN_WARNING" ),
1498 tr( "HYBRID_PERMISSION_DENIED" ) );
1505 void HYBRIDPluginGUI_HypothesisCreator::retrieveParams() const
1507 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::retrieveParams");
1508 HYBRIDPluginGUI_HypothesisCreator* that = (HYBRIDPluginGUI_HypothesisCreator*)this;
1509 HYBRIDHypothesisData data;
1510 readParamsFromHypo( data );
1513 myName->setText( data.myName );
1514 myLayersOnAllWrapCheck ->setChecked ( data.myLayersOnAllWrap );
1515 myToMeshHolesCheck ->setChecked ( data.myToMeshHoles );
1516 myToMakeGroupsOfDomains ->setChecked ( data.myToMakeGroupsOfDomains );
1517 myOptimizationLevelCombo ->setCurrentIndex( data.myOptimizationLevel );
1518 myAdvWidget->maxMemoryCheck ->setChecked ( data.myMaximumMemory > 0 );
1519 myAdvWidget->maxMemorySpin ->setValue ( qMax( data.myMaximumMemory,
1520 myAdvWidget->maxMemorySpin->minimum() ));
1521 myAdvWidget->initialMemoryCheck ->setChecked ( data.myInitialMemory > 0 );
1522 myAdvWidget->initialMemorySpin ->setValue ( qMax( data.myInitialMemory,
1523 myAdvWidget->initialMemorySpin->minimum() ));
1525 myCollisionModeCombo ->setCurrentIndex( data.myCollisionMode );
1526 myBoundaryLayersGrowthCombo ->setCurrentIndex( data.myBoundaryLayersGrowth );
1527 myElementGenerationCombo ->setCurrentIndex( data.myElementGeneration );
1528 myAddMultinormalsCheck -> setChecked ( data.myAddMultinormals );
1529 mySmoothNormalsCheck -> setChecked ( data.mySmoothNormals );
1530 myHeightFirstLayerSpin -> setValue( data.myHeightFirstLayer );
1531 myNbOfBoundaryLayersSpin -> setValue( data.myNbOfBoundaryLayers );
1532 myBoundaryLayersProgressionSpin -> setValue( data.myBoundaryLayersProgression );
1533 myMultinormalsAngleSpin -> setValue( data.myMultinormalsAngle );
1535 myAdvWidget->workingDirectoryLineEdit ->setText ( data.myWorkingDir );
1536 myAdvWidget->keepWorkingFilesCheck ->setChecked( data.myKeepFiles );
1537 myAdvWidget->verboseLevelSpin ->setValue ( data.myVerboseLevel );
1538 myAdvWidget->createNewNodesCheck ->setChecked( data.myToCreateNewNodes );
1539 myAdvWidget->removeInitialCentralPointCheck ->setChecked( data.myRemoveInitialCentralPoint );
1540 myAdvWidget->boundaryRecoveryCheck ->setChecked( data.myBoundaryRecovery );
1541 myAdvWidget->FEMCorrectionCheck ->setChecked( data.myFEMCorrection );
1542 myAdvWidget->gradationSpinBox ->setValue ( data.myGradation );
1543 myAdvWidget->myAdvOptionsTable ->SetCustomOptions( data.myTextOption );
1544 myAdvWidget->logInFileCheck ->setChecked( !data.myLogInStandardOutput );
1545 myAdvWidget->removeLogOnSuccessCheck ->setChecked( data.myRemoveLogOnSuccess );
1547 TEnfVertexList::const_iterator it;
1549 myEnforcedTableWidget->clearContents();
1550 myEnforcedTableWidget->setSortingEnabled(false);
1551 myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1552 for(it = data.myEnforcedVertices.begin() ; it != data.myEnforcedVertices.end(); it++ )
1554 TEnfVertex* enfVertex = (*it);
1555 myEnforcedTableWidget->setRowCount(rowCount+1);
1557 for (int col=0;col<ENF_VER_NB_COLUMNS;col++) {
1558 MESSAGE("Column: " << col);
1559 // MESSAGE("enfVertex->isCompound: " << enfVertex->isCompound);
1560 QTableWidgetItem* item = new QTableWidgetItem();
1561 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1563 case ENF_VER_NAME_COLUMN:
1564 item->setData( 0, enfVertex->name.c_str() );
1565 if (!enfVertex->geomEntry.empty()) {
1566 if (enfVertex->isCompound)
1567 item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1569 item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1571 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1574 case ENF_VER_X_COLUMN:
1575 if (!enfVertex->isCompound) {
1576 item->setData( 0, enfVertex->coords.at(0) );
1577 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1580 case ENF_VER_Y_COLUMN:
1581 if (!enfVertex->isCompound) {
1582 item->setData( 0, enfVertex->coords.at(1) );
1583 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1586 case ENF_VER_Z_COLUMN:
1587 if (!enfVertex->isCompound) {
1588 item->setData( 0, enfVertex->coords.at(2) );
1589 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1592 case ENF_VER_SIZE_COLUMN:
1593 item->setData( 0, enfVertex->size );
1594 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1596 case ENF_VER_ENTRY_COLUMN:
1597 item->setData( 0, enfVertex->geomEntry.c_str() );
1598 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1600 case ENF_VER_COMPOUND_COLUMN:
1601 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
1602 item->setData( Qt::CheckStateRole, enfVertex->isCompound );
1603 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << enfVertex->isCompound);
1605 case ENF_VER_GROUP_COLUMN:
1606 item->setData( 0, enfVertex->groupName.c_str() );
1607 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1613 myEnforcedTableWidget->setItem(rowCount,col,item);
1616 that->updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1620 connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1621 myEnforcedTableWidget->setSortingEnabled(true);
1623 for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
1624 myEnforcedTableWidget->resizeColumnToContents(column);
1626 // Update Enforced meshes QTableWidget
1627 TEnfMeshList::const_iterator itMesh;
1629 myEnforcedMeshTableWidget->clearContents();
1630 myEnforcedMeshTableWidget->setSortingEnabled(false);
1631 // myEnforcedMeshTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
1632 for(itMesh = data.myEnforcedMeshes.begin() ; itMesh != data.myEnforcedMeshes.end(); itMesh++ )
1634 TEnfMesh* enfMesh = (*itMesh);
1635 myEnforcedMeshTableWidget->setRowCount(rowCount+1);
1637 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++) {
1638 MESSAGE("Column: " << col);
1639 if (col == ENF_MESH_CONSTRAINT_COLUMN) {
1640 QComboBox* comboBox = new QComboBox();
1641 QPalette pal = comboBox->palette();
1642 pal.setColor(QPalette::Button, Qt::white);
1643 comboBox->setPalette(pal);
1644 comboBox->insertItems(0,myEnfMeshConstraintLabels);
1645 comboBox->setEditable(false);
1646 comboBox->setCurrentIndex(enfMesh->elementType);
1647 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << comboBox->currentText().toStdString());
1648 myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox);
1651 QTableWidgetItem* item = new QTableWidgetItem();
1652 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1654 case ENF_MESH_NAME_COLUMN:
1655 item->setData( 0, enfMesh->name.c_str() );
1656 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1657 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1658 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1660 case ENF_MESH_ENTRY_COLUMN:
1661 item->setData( 0, enfMesh->entry.c_str() );
1662 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1663 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1664 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1666 case ENF_MESH_GROUP_COLUMN:
1667 item->setData( 0, enfMesh->groupName.c_str() );
1668 MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
1669 myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1676 // myEnforcedMeshTableWidget->setItem(rowCount,col,item);
1679 // that->updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
1683 // connect( myEnforcedMeshTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
1684 myEnforcedMeshTableWidget->setSortingEnabled(true);
1686 for (int col=0;col<ENF_MESH_NB_COLUMNS;col++)
1687 myEnforcedMeshTableWidget->resizeColumnToContents(col);
1689 that->updateWidgets();
1690 that->checkVertexIsDefined();
1693 QString HYBRIDPluginGUI_HypothesisCreator::storeParams() const
1695 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::storeParams");
1696 HYBRIDHypothesisData data;
1697 readParamsFromWidgets( data );
1698 storeParamsToHypo( data );
1700 QString valStr = "";
1702 if ( !data.myBoundaryRecovery )
1703 valStr = "-c " + QString::number( !data.myToMeshHoles );
1705 if ( data.myOptimizationLevel >= 0 && data.myOptimizationLevel < 5 && !data.myBoundaryRecovery) {
1706 const char* level[] = { "none" , "light" , "standard" , "standard+" , "strong" };
1708 valStr += level[ data.myOptimizationLevel ];
1710 if ( data.myMaximumMemory > 0 ) {
1712 valStr += QString::number( data.myMaximumMemory );
1714 if ( data.myInitialMemory > 0 && !data.myBoundaryRecovery ) {
1716 valStr += QString::number( data.myInitialMemory );
1719 valStr += QString::number( data.myVerboseLevel );
1721 if ( !data.myToCreateNewNodes )
1724 if ( data.myRemoveInitialCentralPoint )
1725 valStr += " -no_initial_central_point";
1727 if ( data.myBoundaryRecovery )
1730 if ( data.myFEMCorrection )
1733 if ( data.myGradation != 1.05 ) {
1734 valStr += " -Dcpropa=";
1735 valStr += QString::number( data.myGradation );
1739 valStr += data.myTextOption;
1741 // valStr += " #BEGIN ENFORCED VERTICES#";
1742 // // Add size map parameters storage
1743 // for (int i=0 ; i<mySmpModel->rowCount() ; i++) {
1745 // double x = mySmpModel->data(mySmpModel->index(i,ENF_VER_X_COLUMN)).toDouble();
1746 // double y = mySmpModel->data(mySmpModel->index(i,ENF_VER_Y_COLUMN)).toDouble();
1747 // double z = mySmpModel->data(mySmpModel->index(i,ENF_VER_Z_COLUMN)).toDouble();
1748 // double size = mySmpModel->data(mySmpModel->index(i,ENF_VER_SIZE_COLUMN)).toDouble();
1749 // valStr += QString::number( x );
1751 // valStr += QString::number( y );
1753 // valStr += QString::number( z );
1755 // valStr += QString::number( size );
1756 // if (i!=mySmpModel->rowCount()-1)
1759 // valStr += " #END ENFORCED VERTICES#";
1760 // MESSAGE(valStr.toStdString());
1764 bool HYBRIDPluginGUI_HypothesisCreator::readParamsFromHypo( HYBRIDHypothesisData& h_data ) const
1766 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::readParamsFromHypo");
1767 HYBRIDPlugin::HYBRIDPlugin_Hypothesis_var h =
1768 HYBRIDPlugin::HYBRIDPlugin_Hypothesis::_narrow( initParamsHypothesis() );
1770 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
1771 h_data.myName = isCreation() && data ? hypName() : "";
1773 h_data.myLayersOnAllWrap = h->GetLayersOnAllWrap();
1774 h_data.myToMeshHoles = h->GetToMeshHoles();
1775 h_data.myToMakeGroupsOfDomains = /*h->GetToMeshHoles() &&*/ h->GetToMakeGroupsOfDomains();
1776 h_data.myMaximumMemory = h->GetMaximumMemory();
1777 h_data.myInitialMemory = h->GetInitialMemory();
1778 h_data.myInitialMemory = h->GetInitialMemory();
1779 h_data.myOptimizationLevel = h->GetOptimizationLevel();
1781 h_data.myCollisionMode = h->GetCollisionMode();
1782 h_data.myBoundaryLayersGrowth = h->GetBoundaryLayersGrowth();
1783 h_data.myElementGeneration = h->GetElementGeneration();
1784 h_data.myAddMultinormals = h->GetAddMultinormals();
1785 h_data.mySmoothNormals = h->GetSmoothNormals();
1786 h_data.myHeightFirstLayer = h->GetHeightFirstLayer();
1787 h_data.myBoundaryLayersProgression = h->GetBoundaryLayersProgression();
1788 h_data.myMultinormalsAngle = h->GetMultinormalsAngle();
1789 h_data.myNbOfBoundaryLayers = h->GetNbOfBoundaryLayers();
1791 h_data.myKeepFiles = h->GetKeepFiles();
1792 h_data.myWorkingDir = h->GetWorkingDirectory();
1793 h_data.myVerboseLevel = h->GetVerboseLevel();
1794 h_data.myToCreateNewNodes = h->GetToCreateNewNodes();
1795 h_data.myRemoveInitialCentralPoint = h->GetToRemoveCentralPoint();
1796 h_data.myBoundaryRecovery = h->GetToUseBoundaryRecoveryVersion();
1797 h_data.myFEMCorrection = h->GetFEMCorrection();
1798 h_data.myGradation = h->GetGradation();
1799 h_data.myTextOption = h->GetAdvancedOption();
1800 h_data.myLogInStandardOutput = h->GetStandardOutputLog();
1801 h_data.myRemoveLogOnSuccess = h->GetRemoveLogOnSuccess();
1803 HYBRIDPlugin::HYBRIDEnforcedVertexList_var vertices = h->GetEnforcedVertices();
1804 MESSAGE("vertices->length(): " << vertices->length());
1805 h_data.myEnforcedVertices.clear();
1806 for (CORBA::ULong i=0 ; i<vertices->length() ; i++) {
1807 TEnfVertex* myVertex = new TEnfVertex();
1808 myVertex->name = CORBA::string_dup(vertices[i].name.in());
1809 myVertex->geomEntry = CORBA::string_dup(vertices[i].geomEntry.in());
1810 myVertex->groupName = CORBA::string_dup(vertices[i].groupName.in());
1811 myVertex->size = vertices[i].size;
1812 myVertex->isCompound = vertices[i].isCompound;
1813 if (vertices[i].coords.length()) {
1814 for (CORBA::ULong c = 0; c < vertices[i].coords.length() ; c++)
1815 myVertex->coords.push_back(vertices[i].coords[c]);
1816 MESSAGE("Add enforced vertex ("<< myVertex->coords.at(0) << ","<< myVertex->coords.at(1) << ","<< myVertex->coords.at(2) << ") ="<< myVertex->size);
1818 h_data.myEnforcedVertices.insert(myVertex);
1821 HYBRIDPlugin::HYBRIDEnforcedMeshList_var enfMeshes = h->GetEnforcedMeshes();
1822 MESSAGE("enfMeshes->length(): " << enfMeshes->length());
1823 h_data.myEnforcedMeshes.clear();
1824 for (CORBA::ULong i=0 ; i<enfMeshes->length() ; i++) {
1825 TEnfMesh* myEnfMesh = new TEnfMesh();
1826 myEnfMesh->name = CORBA::string_dup(enfMeshes[i].name.in());
1827 myEnfMesh->entry = CORBA::string_dup(enfMeshes[i].entry.in());
1828 myEnfMesh->groupName = CORBA::string_dup(enfMeshes[i].groupName.in());
1829 switch (enfMeshes[i].elementType) {
1831 myEnfMesh->elementType = 0;
1834 myEnfMesh->elementType = 1;
1837 myEnfMesh->elementType = 2;
1842 // myEnfMesh->elementType = enfMeshes[i].elementType;
1843 h_data.myEnforcedMeshes.insert(myEnfMesh);
1848 bool HYBRIDPluginGUI_HypothesisCreator::storeParamsToHypo( const HYBRIDHypothesisData& h_data ) const
1850 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::storeParamsToHypo");
1851 HYBRIDPlugin::HYBRIDPlugin_Hypothesis_var h =
1852 HYBRIDPlugin::HYBRIDPlugin_Hypothesis::_narrow( hypothesis() );
1858 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
1860 if ( h->GetLayersOnAllWrap() != h_data.myLayersOnAllWrap ) // avoid duplication of DumpPython commands
1861 h->SetLayersOnAllWrap ( h_data.myLayersOnAllWrap );
1862 if ( h->GetToMeshHoles() != h_data.myToMeshHoles ) // avoid duplication of DumpPython commands
1863 h->SetToMeshHoles ( h_data.myToMeshHoles );
1864 if ( h->GetToMakeGroupsOfDomains() != h_data.myToMakeGroupsOfDomains )
1865 h->SetToMakeGroupsOfDomains( h_data.myToMakeGroupsOfDomains );
1866 if ( h->GetMaximumMemory() != h_data.myMaximumMemory )
1867 h->SetMaximumMemory ( h_data.myMaximumMemory );
1868 if ( h->GetInitialMemory() != h_data.myInitialMemory )
1869 h->SetInitialMemory ( h_data.myInitialMemory );
1870 if ( h->GetInitialMemory() != h_data.myInitialMemory )
1871 h->SetInitialMemory ( h_data.myInitialMemory );
1872 if ( h->GetOptimizationLevel() != h_data.myOptimizationLevel )
1873 h->SetOptimizationLevel( h_data.myOptimizationLevel );
1875 if ( h->GetCollisionMode() != h_data.myCollisionMode )
1876 h->SetCollisionMode( h_data.myCollisionMode );
1877 if ( h->GetBoundaryLayersGrowth() != h_data.myBoundaryLayersGrowth )
1878 h->SetBoundaryLayersGrowth( h_data.myBoundaryLayersGrowth );
1879 if ( h->GetElementGeneration() != h_data.myElementGeneration )
1880 h->SetElementGeneration( h_data.myElementGeneration );
1882 if ( h->GetAddMultinormals() != h_data.myAddMultinormals )
1883 h->SetAddMultinormals ( h_data.myAddMultinormals );
1884 if ( h->GetSmoothNormals() != h_data.mySmoothNormals )
1885 h->SetSmoothNormals ( h_data.mySmoothNormals );
1886 if ( h->GetHeightFirstLayer() != h_data.myHeightFirstLayer )
1887 h->SetHeightFirstLayer ( h_data.myHeightFirstLayer );
1888 if ( h->GetBoundaryLayersProgression() != h_data.myBoundaryLayersProgression )
1889 h->SetBoundaryLayersProgression ( h_data.myBoundaryLayersProgression );
1890 if ( h->GetMultinormalsAngle() != h_data.myMultinormalsAngle )
1891 h->SetMultinormalsAngle ( h_data.myMultinormalsAngle );
1892 if ( h->GetNbOfBoundaryLayers() != h_data.myNbOfBoundaryLayers )
1893 h->SetNbOfBoundaryLayers ( h_data.myNbOfBoundaryLayers );
1895 if ( h->GetKeepFiles() != h_data.myKeepFiles)
1896 h->SetKeepFiles ( h_data.myKeepFiles);
1897 if ( h->GetWorkingDirectory() != h_data.myWorkingDir )
1898 h->SetWorkingDirectory ( h_data.myWorkingDir.toLatin1().constData() );
1899 if ( h->GetVerboseLevel() != h_data.myVerboseLevel )
1900 h->SetVerboseLevel ( h_data.myVerboseLevel );
1901 if ( h->GetToCreateNewNodes() != h_data.myToCreateNewNodes )
1902 h->SetToCreateNewNodes ( h_data.myToCreateNewNodes );
1903 if ( h->GetToRemoveCentralPoint() != h_data.myRemoveInitialCentralPoint )
1904 h->SetToRemoveCentralPoint ( h_data.myRemoveInitialCentralPoint );
1905 if ( h->GetToUseBoundaryRecoveryVersion() != h_data.myBoundaryRecovery )
1906 h->SetToUseBoundaryRecoveryVersion ( h_data.myBoundaryRecovery );
1907 if ( h->GetFEMCorrection() != h_data.myFEMCorrection )
1908 h->SetFEMCorrection ( h_data.myFEMCorrection );
1909 if ( h->GetGradation() != h_data.myGradation )
1910 h->SetGradation ( h_data.myGradation );
1911 if ( h->GetTextOption() != h_data.myTextOption )
1912 h->SetAdvancedOption ( h_data.myTextOption.toLatin1().constData() );
1913 if ( h->GetStandardOutputLog() != h_data.myLogInStandardOutput )
1914 h->SetStandardOutputLog ( h_data.myLogInStandardOutput );
1915 if ( h->GetRemoveLogOnSuccess() != h_data.myRemoveLogOnSuccess )
1916 h->SetRemoveLogOnSuccess ( h_data.myRemoveLogOnSuccess );
1918 // Enforced vertices
1919 int nbVertex = (int) h_data.myEnforcedVertices.size();
1920 HYBRIDPlugin::HYBRIDEnforcedVertexList_var vertexHyp = h->GetEnforcedVertices();
1921 int nbVertexHyp = vertexHyp->length();
1923 MESSAGE("Store params for size maps: " << nbVertex << " enforced vertices");
1924 MESSAGE("h->GetEnforcedVertices()->length(): " << nbVertexHyp);
1926 // 1. Clear all enforced vertices in hypothesis
1927 // 2. Add new enforced vertex according to h_data
1928 if ( nbVertexHyp > 0)
1929 h->ClearEnforcedVertices();
1931 TEnfVertexList::const_iterator it;
1932 double x = 0, y = 0, z = 0;
1933 for(it = h_data.myEnforcedVertices.begin() ; it != h_data.myEnforcedVertices.end(); it++ ) {
1934 TEnfVertex* enfVertex = (*it);
1936 if (enfVertex->coords.size()) {
1937 x = enfVertex->coords.at(0);
1938 y = enfVertex->coords.at(1);
1939 z = enfVertex->coords.at(2);
1941 ok = h->p_SetEnforcedVertex( enfVertex->size, x, y, z, enfVertex->name.c_str(), enfVertex->geomEntry.c_str(), enfVertex->groupName.c_str(), enfVertex->isCompound);
1945 int nbEnfMeshes = (int) h_data.myEnforcedMeshes.size();
1946 HYBRIDPlugin::HYBRIDEnforcedMeshList_var enfMeshListHyp = h->GetEnforcedMeshes();
1947 int nbEnfMeshListHyp = enfMeshListHyp->length();
1949 MESSAGE("Store params for size maps: " << nbEnfMeshes << " enforced meshes");
1950 MESSAGE("h->GetEnforcedMeshes()->length(): " << nbEnfMeshListHyp);
1952 // 1. Clear all enforced vertices in hypothesis
1953 // 2. Add new enforced vertex according to h_data
1954 if ( nbEnfMeshListHyp > 0)
1955 h->ClearEnforcedMeshes();
1957 TEnfMeshList::const_iterator itEnfMesh;
1959 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1961 for(itEnfMesh = h_data.myEnforcedMeshes.begin() ; itEnfMesh != h_data.myEnforcedMeshes.end(); itEnfMesh++ ) {
1962 TEnfMesh* enfMesh = (*itEnfMesh);
1964 _PTR(SObject) aSObj = aStudy->FindObjectID(enfMesh->entry.c_str());
1965 SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
1967 MESSAGE("enfMesh->elementType: " << enfMesh->elementType);
1968 SMESH::ElementType elementType;
1969 switch(enfMesh->elementType) {
1971 elementType = SMESH::NODE;
1974 elementType = SMESH::EDGE;
1977 elementType = SMESH::FACE;
1983 std::cout << "h->p_SetEnforcedMesh(theSource, "<< elementType <<", \""<< enfMesh->name << "\", \"" << enfMesh->groupName.c_str() <<"\")"<<std::endl;
1984 ok = h->p_SetEnforcedMesh(theSource, elementType, enfMesh->name.c_str(), enfMesh->groupName.c_str());
1987 // catch(const std::exception& ex) {
1988 // std::cout << "Exception: " << ex.what() << std::endl;
1991 catch ( const SALOME::SALOME_Exception& ex )
1993 SalomeApp_Tools::QtCatchCorbaException( ex );
1999 bool HYBRIDPluginGUI_HypothesisCreator::readParamsFromWidgets( HYBRIDHypothesisData& h_data ) const
2001 MESSAGE("HYBRIDPluginGUI_HypothesisCreator::readParamsFromWidgets");
2002 h_data.myName = myName ? myName->text() : "";
2003 h_data.myLayersOnAllWrap = myLayersOnAllWrapCheck->isChecked();
2004 h_data.myToMeshHoles = myToMeshHolesCheck->isChecked();
2005 h_data.myToMakeGroupsOfDomains = myToMakeGroupsOfDomains->isChecked();
2006 h_data.myMaximumMemory = myAdvWidget->maxMemoryCheck->isChecked() ? myAdvWidget->maxMemorySpin->value() : -1;
2007 h_data.myInitialMemory = myAdvWidget->initialMemoryCheck->isChecked() ? myAdvWidget->initialMemorySpin->value() : -1;
2008 h_data.myOptimizationLevel = myOptimizationLevelCombo->currentIndex();
2010 h_data.myCollisionMode = myCollisionModeCombo->currentIndex();
2011 h_data.myBoundaryLayersGrowth = myBoundaryLayersGrowthCombo->currentIndex();
2012 h_data.myElementGeneration = myElementGenerationCombo->currentIndex();
2013 h_data.myAddMultinormals = myAddMultinormalsCheck->isChecked();
2014 h_data.mySmoothNormals = mySmoothNormalsCheck->isChecked();
2016 h_data.myHeightFirstLayer = myHeightFirstLayerSpin -> value();
2017 h_data.myNbOfBoundaryLayers = myNbOfBoundaryLayersSpin -> value();
2018 h_data.myBoundaryLayersProgression = myBoundaryLayersProgressionSpin -> value();
2019 h_data.myMultinormalsAngle = myMultinormalsAngleSpin -> value();
2021 h_data.myKeepFiles = myAdvWidget->keepWorkingFilesCheck->isChecked();
2022 h_data.myWorkingDir = myAdvWidget->workingDirectoryLineEdit->text().trimmed();
2023 h_data.myVerboseLevel = myAdvWidget->verboseLevelSpin->value();
2024 h_data.myToCreateNewNodes = myAdvWidget->createNewNodesCheck->isChecked();
2025 h_data.myRemoveInitialCentralPoint = myAdvWidget->removeInitialCentralPointCheck->isChecked();
2026 h_data.myBoundaryRecovery = myAdvWidget->boundaryRecoveryCheck->isChecked();
2027 h_data.myFEMCorrection = myAdvWidget->FEMCorrectionCheck->isChecked();
2028 h_data.myGradation = myAdvWidget->gradationSpinBox->value();
2029 h_data.myTextOption = myAdvWidget->myAdvOptionsTable->GetCustomOptions();
2030 h_data.myLogInStandardOutput = !myAdvWidget->logInFileCheck->isChecked();
2031 h_data.myRemoveLogOnSuccess = myAdvWidget->removeLogOnSuccessCheck->isChecked();
2033 // Enforced vertices
2034 h_data.myEnforcedVertices.clear();
2035 QVariant valueX, valueY, valueZ;
2036 for (int row=0 ; row<myEnforcedTableWidget->rowCount() ; row++) {
2038 TEnfVertex *myVertex = new TEnfVertex();
2039 myVertex->name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString();
2040 MESSAGE("Add new enforced vertex \"" << myVertex->name << "\"" );
2041 myVertex->geomEntry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString();
2042 if (myVertex->geomEntry.size())
2043 MESSAGE("Geom entry is \"" << myVertex->geomEntry << "\"" );
2044 myVertex->groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
2045 if (myVertex->groupName.size())
2046 MESSAGE("Group name is \"" << myVertex->groupName << "\"" );
2047 valueX = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data(Qt::EditRole);
2048 valueY = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data(Qt::EditRole);
2049 valueZ = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data(Qt::EditRole);
2050 if (!valueX.isNull() && !valueY.isNull() && !valueZ.isNull()) {
2051 myVertex->coords.push_back(valueX.toDouble());
2052 myVertex->coords.push_back(valueY.toDouble());
2053 myVertex->coords.push_back(valueZ.toDouble());
2054 MESSAGE("Coords are (" << myVertex->coords.at(0) << ", "
2055 << myVertex->coords.at(1) << ", "
2056 << myVertex->coords.at(2) << ")");
2058 myVertex->size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data(Qt::EditRole).toDouble();
2059 MESSAGE("Size is " << myVertex->size);
2060 myVertex->isCompound = myEnforcedTableWidget->item(row,ENF_VER_COMPOUND_COLUMN)->data(Qt::CheckStateRole).toBool();
2061 MESSAGE("Is compound ? " << myVertex->isCompound);
2062 h_data.myEnforcedVertices.insert(myVertex);
2066 h_data.myEnforcedMeshes.clear();
2068 for (int row=0 ; row<myEnforcedMeshTableWidget->rowCount() ; row++) {
2070 TEnfMesh *myEnfMesh = new TEnfMesh();
2071 myEnfMesh->name = myEnforcedMeshTableWidget->item(row,ENF_MESH_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString();
2072 MESSAGE("Add new enforced mesh \"" << myEnfMesh->name << "\"" );
2073 myEnfMesh->entry = myEnforcedMeshTableWidget->item(row,ENF_MESH_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString();
2074 MESSAGE("Entry is \"" << myEnfMesh->entry << "\"" );
2075 myEnfMesh->groupName = myEnforcedMeshTableWidget->item(row,ENF_MESH_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
2076 MESSAGE("Group name is \"" << myEnfMesh->groupName << "\"" );
2077 QComboBox* combo = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row,ENF_MESH_CONSTRAINT_COLUMN));
2078 myEnfMesh->elementType = combo->currentIndex();
2079 MESSAGE("Element type: " << myEnfMesh->elementType);
2080 h_data.myEnforcedMeshes.insert(myEnfMesh);
2081 std::cout << "h_data.myEnforcedMeshes.size(): " << h_data.myEnforcedMeshes.size() << std::endl;
2087 QString HYBRIDPluginGUI_HypothesisCreator::caption() const
2089 return tr( "HYBRID_TITLE" );
2092 QPixmap HYBRIDPluginGUI_HypothesisCreator::icon() const
2094 return SUIT_Session::session()->resourceMgr()->loadPixmap( "HYBRIDPlugin", tr( "ICON_DLG_HYBRID_PARAMETERS" ) );
2097 QString HYBRIDPluginGUI_HypothesisCreator::type() const
2099 return tr( "HYBRID_HYPOTHESIS" );
2102 QString HYBRIDPluginGUI_HypothesisCreator::helpPage() const
2104 return "hybrid_hypo_page.html";