1 // Copyright (C) 2007-2015 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 : 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);
198 myStdWidget->label_6->hide();
199 myStdWidget->myHexoticNbProc->hide();
201 l->addWidget( myStdWidget, row++, 0, 1, 3 );
202 myStdWidget->onSdModeSelected(SD_MODE_4);
206 QWidget* aSmpGroup = new QWidget();
207 lay->addWidget( aSmpGroup );
209 // Size map widget creation and initialisation
210 mySmpWidget = new HexoticPluginGUI_SizeMapsWidget(aSmpGroup);
211 mySmpWidget->doubleSpinBox->RangeStepAndValidator(0.0, COORD_MAX, 1.0, "length_precision");
212 mySmpWidget->doubleSpinBox->setValue(0.0);
214 // Filters of selection
215 TColStd_MapOfInteger SM_ShapeTypes;
216 SM_ShapeTypes.Add( TopAbs_VERTEX );
217 SM_ShapeTypes.Add( TopAbs_EDGE );
218 SM_ShapeTypes.Add( TopAbs_WIRE );
219 SM_ShapeTypes.Add( TopAbs_FACE );
220 SM_ShapeTypes.Add( TopAbs_SOLID );
221 SM_ShapeTypes.Add( TopAbs_COMPOUND );
222 SMESH_NumberFilter* aFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, SM_ShapeTypes);
225 myGeomSelWdg = new StdMeshersGUI_ObjectReferenceParamWdg( aFilter, mySmpWidget, /*multiSel=*/false);
226 myGeomSelWdg->SetDefaultText(tr("Hexotic_SEL_SHAPE"), "QLineEdit { color: grey }");
227 mySmpWidget->gridLayout->addWidget(myGeomSelWdg, 0, 1);
229 // Configuration of the table widget
230 QStringList headerLabels;
231 headerLabels << tr("Hexotic_ENTRY")<< tr("Hexotic_NAME")<< tr("Hexotic_SIZE");
232 mySmpWidget->tableWidget->setHorizontalHeaderLabels(headerLabels);
233 mySmpWidget->tableWidget->resizeColumnsToContents();
234 mySmpWidget->tableWidget->hideColumn( 0 );
235 mySmpWidget->label->setText(tr("LOCAL_SIZE"));
236 mySmpWidget->pushButton_1->setText(tr("Hexotic_ADD"));
237 mySmpWidget->pushButton_2->setText(tr("Hexotic_REMOVE"));
239 // Setting a custom delegate for the size column
240 SizeMapsTableWidgetDelegate* delegate = new SizeMapsTableWidgetDelegate();
241 mySmpWidget->tableWidget->setItemDelegateForColumn(SIZE_COL, delegate);
243 // Add the size maps widget to a layout
244 QHBoxLayout* aSmpLayout = new QHBoxLayout( aSmpGroup );
245 aSmpLayout->setMargin( 0 );
246 aSmpLayout->addWidget( mySmpWidget);
251 aTabWidget->insertTab( STD_TAB, aStdGroup, tr( "SMESH_ARGUMENTS" ) );
252 aTabWidget->insertTab( SMP_TAB, aSmpGroup, tr( "LOCAL_SIZE" ) );
257 mySizeMapsToRemove.clear();
258 connect( mySmpWidget->pushButton_1, SIGNAL( clicked() ), this, SLOT( onAddLocalSize() ) );
259 connect( mySmpWidget->pushButton_2, SIGNAL( clicked() ), this, SLOT( onRemoveLocalSize() ) );
264 void HexoticPluginGUI_HypothesisCreator::onAddLocalSize()
266 int rowCount = mySmpWidget->tableWidget->rowCount();
267 int columnCount = mySmpWidget->tableWidget->columnCount();
269 // Get the selected object properties
270 GEOM::GEOM_Object_var sizeMapObject = myGeomSelWdg->GetObject< GEOM::GEOM_Object >(0);
271 if (sizeMapObject->_is_nil())
274 std::string entry, shapeName;
275 entry = (std::string) sizeMapObject->GetStudyEntry();
276 shapeName = sizeMapObject->GetName();
278 // Check if the object is already in the widget
279 QList<QTableWidgetItem *> listFound = mySmpWidget->tableWidget
280 ->findItems( QString(entry.c_str()), Qt::MatchExactly );
281 if ( !listFound.isEmpty() )
284 // Get the size value
285 double size = mySmpWidget->doubleSpinBox->value();
288 SUIT_MessageBox::critical( mySmpWidget, tr( "SMESH_ERROR" ), tr( "Hexotic_NULL_LOCAL_SIZE" ) );
292 // Set items for the inserted row
293 insertLocalSizeInWidget( entry, shapeName, size, rowCount );
296 void HexoticPluginGUI_HypothesisCreator::insertLocalSizeInWidget( std::string entry,
297 std::string shapeName,
301 MESSAGE("HexoticPluginGUI_HypothesisCreator:insertLocalSizeInWidget")
302 int columnCount = mySmpWidget->tableWidget->columnCount();
304 // Add a row at the end of the table
305 mySmpWidget->tableWidget->insertRow(row);
308 for (int col = 0; col<columnCount; col++)
310 QTableWidgetItem* item = new QTableWidgetItem();
315 value = QVariant( entry.c_str() );
316 item->setData(Qt::DisplayRole, value );
319 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
320 value = QVariant( shapeName.c_str() );
321 item->setData(Qt::DisplayRole, value );
324 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
325 value = QVariant( size );
326 item->setData(Qt::EditRole, value );
329 mySmpWidget->tableWidget->setItem(row,col,item);
333 void HexoticPluginGUI_HypothesisCreator::onRemoveLocalSize()
335 // Remove the selected rows in the table
336 QList<QTableWidgetSelectionRange> ranges = mySmpWidget->tableWidget->selectedRanges();
337 if ( ranges.isEmpty() ) // If none is selected remove the last one
339 int lastRow = mySmpWidget->tableWidget->rowCount() - 1;
340 std::string entry = mySmpWidget->tableWidget->item( lastRow, ENTRY_COL )->text().toStdString();
341 mySizeMapsToRemove.push_back(entry);
342 mySmpWidget->tableWidget->removeRow( lastRow );
346 QList<QTableWidgetSelectionRange>::iterator it;
347 for ( it = ranges.begin(); it != ranges.end(); ++it )
349 for ( int row = it->topRow(); row <= it->bottomRow(); row++ )
351 std::string entry = mySmpWidget->tableWidget->item( row, ENTRY_COL )->text().toStdString();
352 mySizeMapsToRemove.push_back(entry);
353 MESSAGE("ADDING entry : "<<entry<<"to the Size Maps to remove")
355 mySmpWidget->tableWidget->model()->removeRows(it->topRow(), it->rowCount());
360 //=================================================================================
361 // function : resizeEvent [REDEFINED]
363 //=================================================================================
364 void HexoticPluginGUI_HypothesisCreator::resizeEvent(QResizeEvent */*event*/) {
365 QSize scaledSize = myStdWidget->imageSdMode.size();
366 scaledSize.scale(myStdWidget->sdModeLabel->size(), Qt::KeepAspectRatioByExpanding);
367 if (!myStdWidget->sdModeLabel->pixmap() || scaledSize != myStdWidget->sdModeLabel->pixmap()->size())
368 myStdWidget->sdModeLabel->setPixmap(myStdWidget->imageSdMode.scaled(myStdWidget->sdModeLabel->size(),
370 Qt::SmoothTransformation));
373 void HexoticPluginGUI_HypothesisCreator::retrieveParams() const
375 HexoticHypothesisData data;
376 readParamsFromHypo( data );
380 myName->setText( data.myName );
382 myStdWidget->myMinSize->setCleared(data.myMinSize == 0);
383 if (data.myMinSize == 0)
384 myStdWidget->myMinSize->setText("");
386 myStdWidget->myMinSize->setValue( data.myMinSize );
388 myStdWidget->myMaxSize->setCleared(data.myMaxSize == 0);
389 if (data.myMaxSize == 0)
390 myStdWidget->myMaxSize->setText("");
392 myStdWidget->myMaxSize->setValue( data.myMaxSize );
394 myStdWidget->myHexesMinLevel->setCleared(data.myHexesMinLevel == 0);
395 if (data.myHexesMinLevel == 0)
396 myStdWidget->myHexesMinLevel->setText("");
398 myStdWidget->myHexesMinLevel->setValue( data.myHexesMinLevel );
400 myStdWidget->myHexesMaxLevel->setCleared(data.myHexesMaxLevel == 0);
401 if (data.myHexesMaxLevel == 0)
402 myStdWidget->myHexesMaxLevel->setText("");
404 myStdWidget->myHexesMaxLevel->setValue( data.myHexesMaxLevel );
406 myStdWidget->myHexoticIgnoreRidges->setChecked( data.myHexoticIgnoreRidges );
407 myStdWidget->myHexoticInvalidElements->setChecked( data.myHexoticInvalidElements );
409 myStdWidget->myHexoticSharpAngleThreshold->setCleared(data.myHexoticSharpAngleThreshold == 0);
410 if (data.myHexoticSharpAngleThreshold == 0)
411 myStdWidget->myHexoticSharpAngleThreshold->setText("");
413 myStdWidget->myHexoticSharpAngleThreshold->setValue( data.myHexoticSharpAngleThreshold );
415 myStdWidget->myHexoticNbProc->setValue( data.myHexoticNbProc );
417 myStdWidget->myHexoticWorkingDir->setText( data.myHexoticWorkingDir );
419 myStdWidget->myHexoticVerbosity->setValue( data.myHexoticVerbosity );
421 myStdWidget->myHexoticMaxMemory->setValue( data.myHexoticMaxMemory );
423 myStdWidget->myHexoticSdMode->setCurrentIndex(data.myHexoticSdMode);
425 HexoticPlugin_Hypothesis::THexoticSizeMaps::const_iterator it = data.mySizeMaps.begin();
426 for ( int row = 0; it != data.mySizeMaps.end(); it++, row++ )
428 std::string entry = it->first;
429 double size = it->second;
430 GEOM::GEOM_Object_var anObject = entryToObject( entry );
431 std::string shapeName = anObject->GetName();
433 MESSAGE(" Insert local size, entry : "<<entry<<", size : "<<size<<", at row : "<<row)
434 insertLocalSizeInWidget( entry, shapeName, size , row );
437 std::cout << "myStdWidget->myMinSize->value(): " << myStdWidget->myMinSize->value() << std::endl;
438 std::cout << "myStdWidget->myMaxSize->value(): " << myStdWidget->myMaxSize->value() << std::endl;
439 std::cout << "myStdWidget->myHexesMinLevel->value(): " << myStdWidget->myHexesMinLevel->value() << std::endl;
440 std::cout << "myStdWidget->myHexesMaxLevel->value(): " << myStdWidget->myHexesMaxLevel->value() << std::endl;
441 std::cout << "myStdWidget->myHexoticSharpAngleThreshold->value(): " << myStdWidget->myHexoticSharpAngleThreshold->value() << std::endl;
445 void HexoticPluginGUI_HypothesisCreator::printData( HexoticHypothesisData& data) const
448 valStr += tr("Hexotic_MIN_SIZE") + " = " + QString::number( data.myMinSize ) + "; ";
449 valStr += tr("Hexotic_MAX_SIZE") + " = " + QString::number( data.myMaxSize ) + "; ";
450 valStr += tr("Hexotic_HEXES_MIN_LEVEL") + " = " + QString::number( data.myHexesMinLevel ) + "; ";
451 valStr += tr("Hexotic_HEXES_MAX_LEVEL") + " = " + QString::number( data.myHexesMaxLevel ) + "; ";
452 valStr += tr("Hexotic_IGNORE_RIDGES") + " = " + QString::number( data.myHexoticIgnoreRidges ) + "; ";
453 valStr += tr("Hexotic_INVALID_ELEMENTS") + " = " + QString::number( data.myHexoticInvalidElements ) + "; ";
454 valStr += tr("Hexotic_SHARP_ANGLE_THRESHOLD") + " = " + QString::number( data.myHexoticSharpAngleThreshold ) + "; ";
455 valStr += tr("Hexotic_NB_PROC") + " = " + QString::number( data.myHexoticNbProc ) + "; ";
456 valStr += tr("Hexotic_WORKING_DIR") + " = " + data.myHexoticWorkingDir + "; ";
457 valStr += tr("Hexotic_VERBOSITY") + " = " + QString::number( data.myHexoticVerbosity ) + "; ";
458 valStr += tr("Hexotic_MAX_MEMORY") + " = " + QString::number( data.myHexoticMaxMemory ) + "; ";
459 valStr += tr("Hexotic_SD_MODE") + " = " + QString::number( data.myHexoticSdMode ) + "; ";
461 std::cout << "Data: " << valStr.toStdString() << std::endl;
464 QString HexoticPluginGUI_HypothesisCreator::storeParams() const
466 HexoticHypothesisData data;
467 readParamsFromWidgets( data );
468 storeParamsToHypo( data );
471 valStr += tr("Hexotic_MIN_SIZE") + " = " + QString::number( data.myMinSize ) + "; ";
472 valStr += tr("Hexotic_MAX_SIZE") + " = " + QString::number( data.myMaxSize ) + "; ";
473 valStr += tr("Hexotic_HEXES_MIN_LEVEL") + " = " + QString::number( data.myHexesMinLevel ) + "; ";
474 valStr += tr("Hexotic_HEXES_MAX_LEVEL") + " = " + QString::number( data.myHexesMaxLevel ) + "; ";
475 valStr += tr("Hexotic_IGNORE_RIDGES") + " = " + QString::number( data.myHexoticIgnoreRidges ) + "; ";
476 valStr += tr("Hexotic_INVALID_ELEMENTS") + " = " + QString::number( data.myHexoticInvalidElements ) + "; ";
477 valStr += tr("Hexotic_SHARP_ANGLE_THRESHOLD") + " = " + QString::number( data.myHexoticSharpAngleThreshold ) + "; ";
478 valStr += tr("Hexotic_NB_PROC") + " = " + QString::number( data.myHexoticNbProc ) + "; ";
479 valStr += tr("Hexotic_WORKING_DIR") + " = " + data.myHexoticWorkingDir + "; ";
480 valStr += tr("Hexotic_VERBOSITY") + " = " + QString::number( data.myHexoticVerbosity) + "; ";
481 valStr += tr("Hexotic_MAX_MEMORY") + " = " + QString::number( data.myHexoticMaxMemory ) + "; ";
482 valStr += tr("Hexotic_SD_MODE") + " = " + QString::number( data.myHexoticSdMode) + "; ";
484 // std::cout << "Data: " << valStr.toStdString() << std::endl;
489 bool HexoticPluginGUI_HypothesisCreator::readParamsFromHypo( HexoticHypothesisData& h_data ) const
491 HexoticPlugin::HexoticPlugin_Hypothesis_var h =
492 HexoticPlugin::HexoticPlugin_Hypothesis::_narrow( initParamsHypothesis() );
494 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
495 h_data.myName = isCreation() && data ? data->Label : "";
496 h_data.myMinSize = h->GetMinSize();
497 h_data.myMaxSize = h->GetMaxSize();
498 h_data.myHexesMinLevel = h->GetHexesMinLevel();
499 h_data.myHexesMaxLevel = h->GetHexesMaxLevel();
500 h_data.myHexoticIgnoreRidges = h->GetHexoticIgnoreRidges();
501 h_data.myHexoticInvalidElements = h->GetHexoticInvalidElements();
502 h_data.myHexoticSharpAngleThreshold = h->GetHexoticSharpAngleThreshold();
503 h_data.myHexoticNbProc = h->GetHexoticNbProc();
504 h_data.myHexoticWorkingDir = h->GetHexoticWorkingDirectory();
505 h_data.myHexoticVerbosity = h->GetHexoticVerbosity();
506 h_data.myHexoticMaxMemory = h->GetHexoticMaxMemory();
507 h_data.myHexoticSdMode = h->GetHexoticSdMode()-1;
510 HexoticPlugin::HexoticPluginSizeMapsList_var sizeMaps = h->GetSizeMaps();
511 for ( int i = 0 ; i < sizeMaps->length() ; i++)
513 HexoticPlugin::HexoticPluginSizeMap aSizeMap = sizeMaps[i];
514 std::string entry = CORBA::string_dup(aSizeMap.entry.in());
515 double size = aSizeMap.size;
516 h_data.mySizeMaps[ entry ] = size;
517 MESSAGE("READING Size map : entry "<<entry<<" size : "<<size)
523 bool HexoticPluginGUI_HypothesisCreator::storeParamsToHypo( const HexoticHypothesisData& h_data ) const
525 HexoticPlugin::HexoticPlugin_Hypothesis_var h =
526 HexoticPlugin::HexoticPlugin_Hypothesis::_narrow( hypothesis() );
533 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
535 h->SetMinSize( h_data.myMinSize );
536 h->SetMaxSize( h_data.myMaxSize );
537 h->SetHexesMinLevel( h_data.myHexesMinLevel );
538 h->SetHexesMaxLevel( h_data.myHexesMaxLevel );
539 h->SetHexoticIgnoreRidges( h_data.myHexoticIgnoreRidges );
540 h->SetHexoticInvalidElements( h_data.myHexoticInvalidElements );
541 h->SetHexoticSharpAngleThreshold( h_data.myHexoticSharpAngleThreshold );
542 h->SetHexoticNbProc( h_data.myHexoticNbProc );
543 h->SetHexoticWorkingDirectory( h_data.myHexoticWorkingDir.toLatin1().constData() );
544 h->SetHexoticVerbosity( h_data.myHexoticVerbosity );
545 h->SetHexoticMaxMemory( h_data.myHexoticMaxMemory );
546 h->SetHexoticSdMode( h_data.myHexoticSdMode+1 );
548 HexoticPlugin_Hypothesis::THexoticSizeMaps::const_iterator it;
550 for ( it = h_data.mySizeMaps.begin(); it != h_data.mySizeMaps.end(); it++ )
552 h->SetSizeMapEntry( it->first.c_str(), it->second );
553 MESSAGE("STORING Size map : entry "<<it->first.c_str()<<" size : "<<it->second)
555 std::vector< std::string >::const_iterator entry_it;
556 for ( entry_it = mySizeMapsToRemove.begin(); entry_it!= mySizeMapsToRemove.end(); entry_it++ )
558 h->UnsetSizeMapEntry(entry_it->c_str());
561 catch(const SALOME::SALOME_Exception& ex)
563 SalomeApp_Tools::QtCatchCorbaException(ex);
569 bool HexoticPluginGUI_HypothesisCreator::readParamsFromWidgets( HexoticHypothesisData& h_data ) const
571 h_data.myName = myName ? myName->text() : "";
573 h_data.myHexoticIgnoreRidges = myStdWidget->myHexoticIgnoreRidges->isChecked();
574 h_data.myHexoticInvalidElements = myStdWidget->myHexoticInvalidElements->isChecked();
576 h_data.myHexoticNbProc = myStdWidget->myHexoticNbProc->value();
578 h_data.myHexoticWorkingDir = myStdWidget->myHexoticWorkingDir->text();
579 h_data.myHexoticVerbosity = myStdWidget->myHexoticVerbosity->value();
580 h_data.myHexoticMaxMemory = myStdWidget->myHexoticMaxMemory->value();
581 h_data.myHexoticSdMode = myStdWidget->myHexoticSdMode->currentIndex();
583 h_data.myMinSize = myStdWidget->myMinSize->text().isEmpty() ? 0.0 : myStdWidget->myMinSize->value();
584 h_data.myMaxSize = myStdWidget->myMaxSize->text().isEmpty() ? 0.0 : myStdWidget->myMaxSize->value();
585 h_data.myHexesMinLevel = myStdWidget->myHexesMinLevel->text().isEmpty() ? 0 : myStdWidget->myHexesMinLevel->value();
586 h_data.myHexesMaxLevel = myStdWidget->myHexesMaxLevel->text().isEmpty() ? 0 : myStdWidget->myHexesMaxLevel->value();
587 h_data.myHexoticSharpAngleThreshold = myStdWidget->myHexoticSharpAngleThreshold->text().isEmpty() ? 0 : myStdWidget->myHexoticSharpAngleThreshold->value();
590 bool ok = readSizeMapsFromWidgets( h_data );
599 bool HexoticPluginGUI_HypothesisCreator::readSizeMapsFromWidgets( HexoticHypothesisData& h_data ) const
601 int rowCount = mySmpWidget->tableWidget->rowCount();
602 for ( int row = 0; row < rowCount; row++ )
604 std::string entry = mySmpWidget->tableWidget->item( row, ENTRY_COL )->text().toStdString();
605 QVariant size_variant = mySmpWidget->tableWidget->item( row, SIZE_COL )->data(Qt::DisplayRole);
607 // Convert the size to double
609 double size = size_variant.toDouble(&ok);
614 h_data.mySizeMaps[ entry ] = size;
615 MESSAGE("READING Size map from WIDGET: entry "<<entry<<" size : "<<size)
620 GEOM::GEOM_Object_var HexoticPluginGUI_HypothesisCreator::entryToObject( std::string entry) const
622 SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
623 SALOMEDS::Study_var myStudy = smeshGen_i->GetCurrentStudy();
624 GEOM::GEOM_Object_var aGeomObj;
625 SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.c_str() );
626 if (!aSObj->_is_nil()) {
627 CORBA::Object_var obj = aSObj->GetObject();
628 aGeomObj = GEOM::GEOM_Object::_narrow(obj);
634 QString HexoticPluginGUI_HypothesisCreator::caption() const
636 return myIs3D ? tr( "Hexotic_3D_TITLE" ) : tr( "Hexotic_3D_TITLE" ); // ??? 3D/2D ???
639 QPixmap HexoticPluginGUI_HypothesisCreator::icon() const
641 QString hypIconName = myIs3D ? tr( "ICON_DLG_Hexotic_PARAMETERS" ) : tr( "ICON_DLG_Hexotic_PARAMETERS" );
642 return SUIT_Session::session()->resourceMgr()->loadPixmap( "HexoticPLUGIN", hypIconName );
645 QString HexoticPluginGUI_HypothesisCreator::type() const
647 return myIs3D ? tr( "Hexotic_3D_HYPOTHESIS" ) : tr( "Hexotic_3D_HYPOTHESIS" ); // ??? 3D/2D ???
650 QString HexoticPluginGUI_HypothesisCreator::helpPage() const
652 return "hexotic_hypo_page.html";