1 // Copyright (C) 2007-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
21 // File : HexoticPluginGUI_HypothesisCreator.cxx
22 // Author : Lioka RAZAFINDRAZAKA (CEA)
25 #include "HexoticPluginGUI_HypothesisCreator.h"
26 #include "HexoticPluginGUI_Dlg.h"
28 #include <SMESHGUI_Utils.h>
29 #include <SMESHGUI_HypothesesUtils.h>
30 #include "SMESH_NumberFilter.hxx"
32 #include "utilities.h"
34 #include CORBA_SERVER_HEADER(HexoticPlugin_Algorithm)
36 #include <SUIT_Session.h>
37 #include <SUIT_ResourceMgr.h>
38 #include <SUIT_MessageBox.h>
39 #include <SUIT_FileDlg.h>
40 #include <SalomeApp_Tools.h>
41 #include <QtxIntSpinBox.h>
45 #include <QVBoxLayout>
46 #include <QGridLayout>
50 #include <QPushButton>
52 #include "SMESH_Gen_i.hxx"
55 #include <TColStd_MapOfInteger.hxx>
58 // Main widget tabs identification
64 // Size maps tab, table columns order
72 // Size map table widget delegate
75 SizeMapsTableWidgetDelegate::SizeMapsTableWidgetDelegate(QObject *parent)
76 : QItemDelegate(parent)
80 QWidget* SizeMapsTableWidgetDelegate::createEditor(QWidget *parent,
81 const QStyleOptionViewItem &/* option */,
82 const QModelIndex &/* index */) const
84 SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent);
85 editor->RangeStepAndValidator(0.0, COORD_MAX, 10.0, "length_precision");
89 void SizeMapsTableWidgetDelegate::setEditorData(QWidget *editor,
90 const QModelIndex &index) const
92 double value = index.model()->data(index, Qt::EditRole).toDouble();
93 SMESHGUI_SpinBox *spinBox = static_cast<SMESHGUI_SpinBox*>(editor);
94 spinBox->setValue(value);
97 void SizeMapsTableWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
98 const QModelIndex &index) const
100 SMESHGUI_SpinBox *spinBox = static_cast<SMESHGUI_SpinBox*>(editor);
101 spinBox->interpretText();
102 double value = spinBox->value();
104 SUIT_MessageBox::critical( spinBox, tr( "SMESH_ERROR" ), tr( "Hexotic_NULL_LOCAL_SIZE" ) );
106 model->setData(index, value, Qt::EditRole);
109 void SizeMapsTableWidgetDelegate::updateEditorGeometry(QWidget *editor,
110 const QStyleOptionViewItem &option,
111 const QModelIndex &/* index */) const
113 editor->setGeometry(option.rect);
120 HexoticPluginGUI_HypothesisCreator::HexoticPluginGUI_HypothesisCreator( const QString& theHypType )
121 : SMESHGUI_GenericHypothesisCreator( theHypType ),
127 HexoticPluginGUI_HypothesisCreator::~HexoticPluginGUI_HypothesisCreator()
131 bool HexoticPluginGUI_HypothesisCreator::checkParams(QString& msg) const
135 HexoticHypothesisData data_old, data_new;
136 readParamsFromHypo( data_old );
138 bool res = readParamsFromWidgets( data_new );
143 res = storeParamsToHypo( data_new );
145 storeParamsToHypo( data_old );
149 res = data_new.myMinSize <= data_new.myMaxSize;
151 msg = tr(QString("Min size (%1) is higher than max size (%2)").arg(data_new.myMinSize).arg(data_new.myMaxSize).toStdString().c_str());
155 res = data_new.myHexesMinLevel == 0 || \
156 ( data_new.myHexesMinLevel != 0 && (data_new.myHexesMinLevel < data_new.myHexesMaxLevel) );
158 msg = tr(QString("Min hexes level (%1) is higher than max hexes level (%2)").arg(data_new.myHexesMinLevel).arg(data_new.myHexesMaxLevel).toStdString().c_str());
165 QFrame* HexoticPluginGUI_HypothesisCreator::buildFrame()
167 QFrame* fr = new QFrame( 0 );
168 QVBoxLayout* lay = new QVBoxLayout( fr );
170 lay->setSpacing( 6 );
172 // main TabWidget of the dialog
173 QTabWidget* aTabWidget = new QTabWidget( fr );
174 aTabWidget->setTabShape( QTabWidget::Rounded );
175 aTabWidget->setTabPosition( QTabWidget::North );
176 lay->addWidget( aTabWidget );
178 // Standard arguments tab
179 QWidget* aStdGroup = new QWidget();
180 QGridLayout* l = new QGridLayout( aStdGroup );
187 l->addWidget( new QLabel( tr( "SMESH_NAME" ), aStdGroup ), row, 0, 1, 1 );
188 myName = new QLineEdit( aStdGroup );
189 l->addWidget( myName, row++, 1, 1, 2 );
190 myName->setMinimumWidth( 150 );
193 HexoticPlugin::HexoticPlugin_Hypothesis_var h =
194 HexoticPlugin::HexoticPlugin_Hypothesis::_narrow( initParamsHypothesis() );
196 myStdWidget = new HexoticPluginGUI_StdWidget(aStdGroup);
197 l->addWidget( myStdWidget, row++, 0, 1, 3 );
198 myStdWidget->onSdModeSelected(SD_MODE_4);
202 QWidget* aSmpGroup = new QWidget();
203 lay->addWidget( aSmpGroup );
205 // Size map widget creation and initialisation
206 mySmpWidget = new HexoticPluginGUI_SizeMapsWidget(aSmpGroup);
207 mySmpWidget->doubleSpinBox->RangeStepAndValidator(0.0, COORD_MAX, 1.0, "length_precision");
208 mySmpWidget->doubleSpinBox->setValue(0.0);
210 // Filters of selection
211 TColStd_MapOfInteger SM_ShapeTypes;
212 SM_ShapeTypes.Add( TopAbs_VERTEX );
213 SM_ShapeTypes.Add( TopAbs_EDGE );
214 SM_ShapeTypes.Add( TopAbs_WIRE );
215 SM_ShapeTypes.Add( TopAbs_FACE );
216 SM_ShapeTypes.Add( TopAbs_SOLID );
217 SM_ShapeTypes.Add( TopAbs_COMPOUND );
218 SMESH_NumberFilter* aFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, SM_ShapeTypes);
221 myGeomSelWdg = new StdMeshersGUI_ObjectReferenceParamWdg( aFilter, mySmpWidget, /*multiSel=*/false,/*stretch=*/false);
222 myGeomSelWdg->SetDefaultText(tr("Hexotic_SEL_SHAPE"), "QLineEdit { color: grey }");
223 mySmpWidget->gridLayout->addWidget(myGeomSelWdg, 0, 1);
225 // Configuration of the table widget
226 QStringList headerLabels;
227 headerLabels << tr("Hexotic_ENTRY")<< tr("Hexotic_NAME")<< tr("Hexotic_SIZE");
228 mySmpWidget->tableWidget->setHorizontalHeaderLabels(headerLabels);
229 mySmpWidget->tableWidget->resizeColumnsToContents();
230 mySmpWidget->tableWidget->hideColumn( 0 );
231 mySmpWidget->label->setText(tr("LOCAL_SIZE"));
232 mySmpWidget->pushButton_1->setText(tr("Hexotic_ADD"));
233 mySmpWidget->pushButton_2->setText(tr("Hexotic_REMOVE"));
235 // Setting a custom delegate for the size column
236 SizeMapsTableWidgetDelegate* delegate = new SizeMapsTableWidgetDelegate();
237 mySmpWidget->tableWidget->setItemDelegateForColumn(SIZE_COL, delegate);
239 // Add the size maps widget to a layout
240 QHBoxLayout* aSmpLayout = new QHBoxLayout( aSmpGroup );
241 aSmpLayout->setMargin( 0 );
242 aSmpLayout->addWidget( mySmpWidget);
247 aTabWidget->insertTab( STD_TAB, aStdGroup, tr( "SMESH_ARGUMENTS" ) );
248 aTabWidget->insertTab( SMP_TAB, aSmpGroup, tr( "LOCAL_SIZE" ) );
253 mySizeMapsToRemove.clear();
254 connect( mySmpWidget->pushButton_1, SIGNAL( clicked() ), this, SLOT( onAddLocalSize() ) );
255 connect( mySmpWidget->pushButton_2, SIGNAL( clicked() ), this, SLOT( onRemoveLocalSize() ) );
260 void HexoticPluginGUI_HypothesisCreator::onAddLocalSize()
262 int rowCount = mySmpWidget->tableWidget->rowCount();
263 int columnCount = mySmpWidget->tableWidget->columnCount();
265 // Get the selected object properties
266 GEOM::GEOM_Object_var sizeMapObject = myGeomSelWdg->GetObject< GEOM::GEOM_Object >(0);
267 if (sizeMapObject->_is_nil())
270 std::string entry, shapeName;
271 entry = (std::string) sizeMapObject->GetStudyEntry();
272 shapeName = sizeMapObject->GetName();
274 // Check if the object is already in the widget
275 QList<QTableWidgetItem *> listFound = mySmpWidget->tableWidget
276 ->findItems( QString(entry.c_str()), Qt::MatchExactly );
277 if ( !listFound.isEmpty() )
280 // Get the size value
281 double size = mySmpWidget->doubleSpinBox->value();
284 SUIT_MessageBox::critical( mySmpWidget, tr( "SMESH_ERROR" ), tr( "Hexotic_NULL_LOCAL_SIZE" ) );
288 // Set items for the inserted row
289 insertLocalSizeInWidget( entry, shapeName, size, rowCount );
292 void HexoticPluginGUI_HypothesisCreator::insertLocalSizeInWidget( std::string entry,
293 std::string shapeName,
297 MESSAGE("HexoticPluginGUI_HypothesisCreator:insertLocalSizeInWidget")
298 int columnCount = mySmpWidget->tableWidget->columnCount();
300 // Add a row at the end of the table
301 mySmpWidget->tableWidget->insertRow(row);
304 for (int col = 0; col<columnCount; col++)
306 QTableWidgetItem* item = new QTableWidgetItem();
311 value = QVariant( entry.c_str() );
312 item->setData(Qt::DisplayRole, value );
315 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
316 value = QVariant( shapeName.c_str() );
317 item->setData(Qt::DisplayRole, value );
320 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
321 value = QVariant( size );
322 item->setData(Qt::EditRole, value );
325 mySmpWidget->tableWidget->setItem(row,col,item);
329 void HexoticPluginGUI_HypothesisCreator::onRemoveLocalSize()
331 // Remove the selected rows in the table
332 QList<QTableWidgetSelectionRange> ranges = mySmpWidget->tableWidget->selectedRanges();
333 if ( ranges.isEmpty() ) // If none is selected remove the last one
335 int lastRow = mySmpWidget->tableWidget->rowCount() - 1;
336 std::string entry = mySmpWidget->tableWidget->item( lastRow, ENTRY_COL )->text().toStdString();
337 mySizeMapsToRemove.push_back(entry);
338 mySmpWidget->tableWidget->removeRow( lastRow );
342 QTableWidgetSelectionRange& range = ranges.first();
343 for ( int row = range.topRow(); row < range.rowCount(); row++ )
345 std::string entry = mySmpWidget->tableWidget->item( row, ENTRY_COL )->text().toStdString();
346 mySizeMapsToRemove.push_back(entry);
348 mySmpWidget->tableWidget->model()->removeRows(range.topRow(), range.rowCount());
352 //=================================================================================
353 // function : resizeEvent [REDEFINED]
355 //=================================================================================
356 void HexoticPluginGUI_HypothesisCreator::resizeEvent(QResizeEvent */*event*/) {
357 QSize scaledSize = myStdWidget->imageSdMode.size();
358 scaledSize.scale(myStdWidget->sdModeLabel->size(), Qt::KeepAspectRatioByExpanding);
359 if (!myStdWidget->sdModeLabel->pixmap() || scaledSize != myStdWidget->sdModeLabel->pixmap()->size())
360 myStdWidget->sdModeLabel->setPixmap(myStdWidget->imageSdMode.scaled(myStdWidget->sdModeLabel->size(),
362 Qt::SmoothTransformation));
365 void HexoticPluginGUI_HypothesisCreator::retrieveParams() const
367 HexoticHypothesisData data;
368 readParamsFromHypo( data );
372 myName->setText( data.myName );
374 myStdWidget->myMinSize->setCleared(data.myMinSize == 0);
375 if (data.myMinSize == 0)
376 myStdWidget->myMinSize->setText("");
378 myStdWidget->myMinSize->setValue( data.myMinSize );
380 myStdWidget->myMaxSize->setCleared(data.myMaxSize == 0);
381 if (data.myMaxSize == 0)
382 myStdWidget->myMaxSize->setText("");
384 myStdWidget->myMaxSize->setValue( data.myMaxSize );
386 myStdWidget->myHexesMinLevel->setCleared(data.myHexesMinLevel == 0);
387 if (data.myHexesMinLevel == 0)
388 myStdWidget->myHexesMinLevel->setText("");
390 myStdWidget->myHexesMinLevel->setValue( data.myHexesMinLevel );
392 myStdWidget->myHexesMaxLevel->setCleared(data.myHexesMaxLevel == 0);
393 if (data.myHexesMaxLevel == 0)
394 myStdWidget->myHexesMaxLevel->setText("");
396 myStdWidget->myHexesMaxLevel->setValue( data.myHexesMaxLevel );
398 myStdWidget->myHexoticIgnoreRidges->setChecked( data.myHexoticIgnoreRidges );
399 myStdWidget->myHexoticInvalidElements->setChecked( data.myHexoticInvalidElements );
401 myStdWidget->myHexoticSharpAngleThreshold->setCleared(data.myHexoticSharpAngleThreshold == 0);
402 if (data.myHexoticSharpAngleThreshold == 0)
403 myStdWidget->myHexoticSharpAngleThreshold->setText("");
405 myStdWidget->myHexoticSharpAngleThreshold->setValue( data.myHexoticSharpAngleThreshold );
407 myStdWidget->myHexoticNbProc->setValue( data.myHexoticNbProc );
408 myStdWidget->myHexoticWorkingDir->setText( data.myHexoticWorkingDir );
410 myStdWidget->myHexoticVerbosity->setValue( data.myHexoticVerbosity );
412 myStdWidget->myHexoticMaxMemory->setValue( data.myHexoticMaxMemory );
414 myStdWidget->myHexoticSdMode->setCurrentIndex(data.myHexoticSdMode);
416 HexoticPlugin_Hypothesis::THexoticSizeMaps::const_iterator it = data.mySizeMaps.begin();
417 for ( int row = 0; it != data.mySizeMaps.end(); it++, row++ )
419 std::string entry = it->first;
420 double size = it->second;
421 GEOM::GEOM_Object_var anObject = entryToObject( entry );
422 std::string shapeName = anObject->GetName();
424 MESSAGE(" Insert local size, entry : "<<entry<<", size : "<<size<<", at row : "<<row)
425 insertLocalSizeInWidget( entry, shapeName, size , row );
428 std::cout << "myStdWidget->myMinSize->value(): " << myStdWidget->myMinSize->value() << std::endl;
429 std::cout << "myStdWidget->myMaxSize->value(): " << myStdWidget->myMaxSize->value() << std::endl;
430 std::cout << "myStdWidget->myHexesMinLevel->value(): " << myStdWidget->myHexesMinLevel->value() << std::endl;
431 std::cout << "myStdWidget->myHexesMaxLevel->value(): " << myStdWidget->myHexesMaxLevel->value() << std::endl;
432 std::cout << "myStdWidget->myHexoticSharpAngleThreshold->value(): " << myStdWidget->myHexoticSharpAngleThreshold->value() << std::endl;
436 void HexoticPluginGUI_HypothesisCreator::printData( HexoticHypothesisData& data) const
439 valStr += tr("Hexotic_MIN_SIZE") + " = " + QString::number( data.myMinSize ) + "; ";
440 valStr += tr("Hexotic_MAX_SIZE") + " = " + QString::number( data.myMaxSize ) + "; ";
441 valStr += tr("Hexotic_HEXES_MIN_LEVEL") + " = " + QString::number( data.myHexesMinLevel ) + "; ";
442 valStr += tr("Hexotic_HEXES_MAX_LEVEL") + " = " + QString::number( data.myHexesMaxLevel ) + "; ";
443 valStr += tr("Hexotic_IGNORE_RIDGES") + " = " + QString::number( data.myHexoticIgnoreRidges ) + "; ";
444 valStr += tr("Hexotic_INVALID_ELEMENTS") + " = " + QString::number( data.myHexoticInvalidElements ) + "; ";
445 valStr += tr("Hexotic_SHARP_ANGLE_THRESHOLD") + " = " + QString::number( data.myHexoticSharpAngleThreshold ) + "; ";
446 valStr += tr("Hexotic_NB_PROC") + " = " + QString::number( data.myHexoticNbProc ) + "; ";
447 valStr += tr("Hexotic_WORKING_DIR") + " = " + data.myHexoticWorkingDir + "; ";
448 valStr += tr("Hexotic_VERBOSITY") + " = " + QString::number( data.myHexoticVerbosity ) + "; ";
449 valStr += tr("Hexotic_MAX_MEMORY") + " = " + QString::number( data.myHexoticMaxMemory ) + "; ";
450 valStr += tr("Hexotic_SD_MODE") + " = " + QString::number( data.myHexoticSdMode ) + "; ";
452 std::cout << "Data: " << valStr.toStdString() << std::endl;
455 QString HexoticPluginGUI_HypothesisCreator::storeParams() const
457 HexoticHypothesisData data;
458 readParamsFromWidgets( data );
459 storeParamsToHypo( data );
462 valStr += tr("Hexotic_MIN_SIZE") + " = " + QString::number( data.myMinSize ) + "; ";
463 valStr += tr("Hexotic_MAX_SIZE") + " = " + QString::number( data.myMaxSize ) + "; ";
464 valStr += tr("Hexotic_HEXES_MIN_LEVEL") + " = " + QString::number( data.myHexesMinLevel ) + "; ";
465 valStr += tr("Hexotic_HEXES_MAX_LEVEL") + " = " + QString::number( data.myHexesMaxLevel ) + "; ";
466 valStr += tr("Hexotic_IGNORE_RIDGES") + " = " + QString::number( data.myHexoticIgnoreRidges ) + "; ";
467 valStr += tr("Hexotic_INVALID_ELEMENTS") + " = " + QString::number( data.myHexoticInvalidElements ) + "; ";
468 valStr += tr("Hexotic_SHARP_ANGLE_THRESHOLD") + " = " + QString::number( data.myHexoticSharpAngleThreshold ) + "; ";
469 valStr += tr("Hexotic_NB_PROC") + " = " + QString::number( data.myHexoticNbProc ) + "; ";
470 valStr += tr("Hexotic_WORKING_DIR") + " = " + data.myHexoticWorkingDir + "; ";
471 valStr += tr("Hexotic_VERBOSITY") + " = " + QString::number( data.myHexoticVerbosity) + "; ";
472 valStr += tr("Hexotic_MAX_MEMORY") + " = " + QString::number( data.myHexoticMaxMemory ) + "; ";
473 valStr += tr("Hexotic_SD_MODE") + " = " + QString::number( data.myHexoticSdMode) + "; ";
475 // std::cout << "Data: " << valStr.toStdString() << std::endl;
480 bool HexoticPluginGUI_HypothesisCreator::readParamsFromHypo( HexoticHypothesisData& h_data ) const
482 HexoticPlugin::HexoticPlugin_Hypothesis_var h =
483 HexoticPlugin::HexoticPlugin_Hypothesis::_narrow( initParamsHypothesis() );
485 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
486 h_data.myName = isCreation() && data ? data->Label : "";
487 h_data.myMinSize = h->GetMinSize();
488 h_data.myMaxSize = h->GetMaxSize();
489 h_data.myHexesMinLevel = h->GetHexesMinLevel();
490 h_data.myHexesMaxLevel = h->GetHexesMaxLevel();
491 h_data.myHexoticIgnoreRidges = h->GetHexoticIgnoreRidges();
492 h_data.myHexoticInvalidElements = h->GetHexoticInvalidElements();
493 h_data.myHexoticSharpAngleThreshold = h->GetHexoticSharpAngleThreshold();
494 h_data.myHexoticNbProc = h->GetHexoticNbProc();
495 h_data.myHexoticWorkingDir = h->GetHexoticWorkingDirectory();
496 h_data.myHexoticVerbosity = h->GetHexoticVerbosity();
497 h_data.myHexoticMaxMemory = h->GetHexoticMaxMemory();
498 h_data.myHexoticSdMode = h->GetHexoticSdMode()-1;
501 HexoticPlugin::HexoticPluginSizeMapsList_var sizeMaps = h->GetSizeMaps();
502 for ( int i = 0 ; i < sizeMaps->length() ; i++)
504 HexoticPlugin::HexoticPluginSizeMap aSizeMap = sizeMaps[i];
505 std::string entry = CORBA::string_dup(aSizeMap.entry.in());
506 double size = aSizeMap.size;
507 h_data.mySizeMaps[ entry ] = size;
508 MESSAGE("READING Size map : entry "<<entry<<" size : "<<size)
514 bool HexoticPluginGUI_HypothesisCreator::storeParamsToHypo( const HexoticHypothesisData& h_data ) const
516 HexoticPlugin::HexoticPlugin_Hypothesis_var h =
517 HexoticPlugin::HexoticPlugin_Hypothesis::_narrow( hypothesis() );
524 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
526 h->SetMinSize( h_data.myMinSize );
527 h->SetMaxSize( h_data.myMaxSize );
528 h->SetHexesMinLevel( h_data.myHexesMinLevel );
529 h->SetHexesMaxLevel( h_data.myHexesMaxLevel );
530 h->SetHexoticIgnoreRidges( h_data.myHexoticIgnoreRidges );
531 h->SetHexoticInvalidElements( h_data.myHexoticInvalidElements );
532 h->SetHexoticSharpAngleThreshold( h_data.myHexoticSharpAngleThreshold );
533 h->SetHexoticNbProc( h_data.myHexoticNbProc );
534 h->SetHexoticWorkingDirectory( h_data.myHexoticWorkingDir.toLatin1().constData() );
535 h->SetHexoticVerbosity( h_data.myHexoticVerbosity );
536 h->SetHexoticMaxMemory( h_data.myHexoticMaxMemory );
537 h->SetHexoticSdMode( h_data.myHexoticSdMode+1 );
539 HexoticPlugin_Hypothesis::THexoticSizeMaps::const_iterator it;
541 for ( it = h_data.mySizeMaps.begin(); it != h_data.mySizeMaps.end(); it++ )
543 h->SetSizeMapEntry( it->first.c_str(), it->second );
544 MESSAGE("STORING Size map : entry "<<it->first.c_str()<<" size : "<<it->second)
546 std::vector< std::string >::const_iterator entry_it;
547 for ( entry_it = mySizeMapsToRemove.begin(); entry_it!= mySizeMapsToRemove.end(); entry_it++ )
549 h->UnsetSizeMapEntry(entry_it->c_str());
552 catch(const SALOME::SALOME_Exception& ex)
554 SalomeApp_Tools::QtCatchCorbaException(ex);
560 bool HexoticPluginGUI_HypothesisCreator::readParamsFromWidgets( HexoticHypothesisData& h_data ) const
562 h_data.myName = myName ? myName->text() : "";
564 h_data.myHexoticIgnoreRidges = myStdWidget->myHexoticIgnoreRidges->isChecked();
565 h_data.myHexoticInvalidElements = myStdWidget->myHexoticInvalidElements->isChecked();
567 h_data.myHexoticNbProc = myStdWidget->myHexoticNbProc->value();
568 h_data.myHexoticWorkingDir = myStdWidget->myHexoticWorkingDir->text();
569 h_data.myHexoticVerbosity = myStdWidget->myHexoticVerbosity->value();
570 h_data.myHexoticMaxMemory = myStdWidget->myHexoticMaxMemory->value();
571 h_data.myHexoticSdMode = myStdWidget->myHexoticSdMode->currentIndex();
573 h_data.myMinSize = myStdWidget->myMinSize->text().isEmpty() ? 0.0 : myStdWidget->myMinSize->value();
574 h_data.myMaxSize = myStdWidget->myMaxSize->text().isEmpty() ? 0.0 : myStdWidget->myMaxSize->value();
575 h_data.myHexesMinLevel = myStdWidget->myHexesMinLevel->text().isEmpty() ? 0 : myStdWidget->myHexesMinLevel->value();
576 h_data.myHexesMaxLevel = myStdWidget->myHexesMaxLevel->text().isEmpty() ? 0 : myStdWidget->myHexesMaxLevel->value();
577 h_data.myHexoticSharpAngleThreshold = myStdWidget->myHexoticSharpAngleThreshold->text().isEmpty() ? 0 : myStdWidget->myHexoticSharpAngleThreshold->value();
580 bool ok = readSizeMapsFromWidgets( h_data );
589 bool HexoticPluginGUI_HypothesisCreator::readSizeMapsFromWidgets( HexoticHypothesisData& h_data ) const
591 int rowCount = mySmpWidget->tableWidget->rowCount();
592 for ( int row = 0; row < rowCount; row++ )
594 std::string entry = mySmpWidget->tableWidget->item( row, ENTRY_COL )->text().toStdString();
595 QVariant size_variant = mySmpWidget->tableWidget->item( row, SIZE_COL )->data(Qt::DisplayRole);
597 // Convert the size to double
599 double size = size_variant.toDouble(&ok);
604 h_data.mySizeMaps[ entry ] = size;
605 MESSAGE("READING Size map from WIDGET: entry "<<entry<<" size : "<<size)
609 GEOM::GEOM_Object_var HexoticPluginGUI_HypothesisCreator::entryToObject( std::string entry) const
611 SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
612 SALOMEDS::Study_var myStudy = smeshGen_i->GetCurrentStudy();
613 GEOM::GEOM_Object_var aGeomObj;
614 SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.c_str() );
615 if (!aSObj->_is_nil()) {
616 CORBA::Object_var obj = aSObj->GetObject();
617 aGeomObj = GEOM::GEOM_Object::_narrow(obj);
623 QString HexoticPluginGUI_HypothesisCreator::caption() const
625 return myIs3D ? tr( "Hexotic_3D_TITLE" ) : tr( "Hexotic_3D_TITLE" ); // ??? 3D/2D ???
628 QPixmap HexoticPluginGUI_HypothesisCreator::icon() const
630 QString hypIconName = myIs3D ? tr( "ICON_DLG_Hexotic_PARAMETERS" ) : tr( "ICON_DLG_Hexotic_PARAMETERS" );
631 return SUIT_Session::session()->resourceMgr()->loadPixmap( "HexoticPLUGIN", hypIconName );
634 QString HexoticPluginGUI_HypothesisCreator::type() const
636 return myIs3D ? tr( "Hexotic_3D_HYPOTHESIS" ) : tr( "Hexotic_3D_HYPOTHESIS" ); // ??? 3D/2D ???
639 QString HexoticPluginGUI_HypothesisCreator::helpPage() const
641 return "hexotic_hypo_page.html";