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 : 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
65 // Size maps tab, table columns order
73 // Size map table widget delegate
76 SizeMapsTableWidgetDelegate::SizeMapsTableWidgetDelegate(QObject *parent)
77 : QItemDelegate(parent)
81 QWidget* SizeMapsTableWidgetDelegate::createEditor(QWidget *parent,
82 const QStyleOptionViewItem &/* option */,
83 const QModelIndex &/* index */) const
85 SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent);
86 editor->RangeStepAndValidator(0.0, COORD_MAX, 10.0, "length_precision");
90 void SizeMapsTableWidgetDelegate::setEditorData(QWidget *editor,
91 const QModelIndex &index) const
93 double value = index.model()->data(index, Qt::EditRole).toDouble();
94 SMESHGUI_SpinBox *spinBox = static_cast<SMESHGUI_SpinBox*>(editor);
95 spinBox->setValue(value);
98 void SizeMapsTableWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
99 const QModelIndex &index) const
101 SMESHGUI_SpinBox *spinBox = static_cast<SMESHGUI_SpinBox*>(editor);
102 spinBox->interpretText();
103 double value = spinBox->value();
105 SUIT_MessageBox::critical( spinBox, tr( "SMESH_ERROR" ), tr( "Hexotic_NULL_LOCAL_SIZE" ) );
107 model->setData(index, value, Qt::EditRole);
110 void SizeMapsTableWidgetDelegate::updateEditorGeometry(QWidget *editor,
111 const QStyleOptionViewItem &option,
112 const QModelIndex &/* index */) const
114 editor->setGeometry(option.rect);
121 HexoticPluginGUI_HypothesisCreator::HexoticPluginGUI_HypothesisCreator( const QString& theHypType )
122 : SMESHGUI_GenericHypothesisCreator( theHypType ),
128 HexoticPluginGUI_HypothesisCreator::~HexoticPluginGUI_HypothesisCreator()
132 bool HexoticPluginGUI_HypothesisCreator::checkParams(QString& msg) const
136 HexoticHypothesisData data_old, data_new;
137 readParamsFromHypo( data_old );
139 bool res = readParamsFromWidgets( data_new );
144 res = storeParamsToHypo( data_new );
146 storeParamsToHypo( data_old );
150 res = data_new.myMinSize <= data_new.myMaxSize;
152 msg = tr(QString("Min size (%1) is higher than max size (%2)").arg(data_new.myMinSize).arg(data_new.myMaxSize).toStdString().c_str());
156 res = data_new.myHexesMinLevel == 0 || \
157 ( data_new.myHexesMinLevel != 0 && (data_new.myHexesMinLevel < data_new.myHexesMaxLevel) );
159 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());
166 QFrame* HexoticPluginGUI_HypothesisCreator::buildFrame()
168 QFrame* fr = new QFrame( 0 );
169 QVBoxLayout* lay = new QVBoxLayout( fr );
171 lay->setSpacing( 6 );
173 // main TabWidget of the dialog
174 QTabWidget* aTabWidget = new QTabWidget( fr );
175 aTabWidget->setTabShape( QTabWidget::Rounded );
176 aTabWidget->setTabPosition( QTabWidget::North );
177 lay->addWidget( aTabWidget );
179 // Standard arguments tab
180 QWidget* aStdGroup = new QWidget();
181 QGridLayout* l = new QGridLayout( aStdGroup );
188 l->addWidget( new QLabel( tr( "SMESH_NAME" ), aStdGroup ), row, 0, 1, 1 );
189 myName = new QLineEdit( aStdGroup );
190 l->addWidget( myName, row++, 1, 1, 2 );
191 myName->setMinimumWidth( 150 );
194 HexoticPlugin::HexoticPlugin_Hypothesis_var h =
195 HexoticPlugin::HexoticPlugin_Hypothesis::_narrow( initParamsHypothesis() );
197 myStdWidget = new HexoticPluginGUI_StdWidget(aStdGroup);
199 myStdWidget->label_6->hide();
200 myStdWidget->myHexoticNbProc->hide();
202 l->addWidget( myStdWidget, row++, 0, 1, 3 );
203 myStdWidget->onSdModeSelected(SD_MODE_4);
207 QWidget* aSmpGroup = new QWidget();
208 lay->addWidget( aSmpGroup );
210 // Size map widget creation and initialisation
211 mySmpWidget = new HexoticPluginGUI_SizeMapsWidget(aSmpGroup);
212 mySmpWidget->doubleSpinBox->RangeStepAndValidator(0.0, COORD_MAX, 1.0, "length_precision");
213 mySmpWidget->doubleSpinBox->setValue(0.0);
215 // Filters of selection
216 TColStd_MapOfInteger SM_ShapeTypes;
217 SM_ShapeTypes.Add( TopAbs_VERTEX );
218 SM_ShapeTypes.Add( TopAbs_EDGE );
219 SM_ShapeTypes.Add( TopAbs_WIRE );
220 SM_ShapeTypes.Add( TopAbs_FACE );
221 SM_ShapeTypes.Add( TopAbs_SOLID );
222 SM_ShapeTypes.Add( TopAbs_COMPOUND );
223 SMESH_NumberFilter* aFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, SM_ShapeTypes);
226 myGeomSelWdg = new StdMeshersGUI_ObjectReferenceParamWdg( aFilter, mySmpWidget, /*multiSel=*/false);
227 myGeomSelWdg->SetDefaultText(tr("Hexotic_SEL_SHAPE"), "QLineEdit { color: grey }");
228 mySmpWidget->gridLayout->addWidget(myGeomSelWdg, 0, 1);
230 // Configuration of the table widget
231 QStringList headerLabels;
232 headerLabels << tr("Hexotic_ENTRY")<< tr("Hexotic_NAME")<< tr("Hexotic_SIZE");
233 mySmpWidget->tableWidget->setHorizontalHeaderLabels(headerLabels);
234 mySmpWidget->tableWidget->resizeColumnsToContents();
235 mySmpWidget->tableWidget->hideColumn( 0 );
236 mySmpWidget->label->setText(tr("LOCAL_SIZE"));
237 mySmpWidget->pushButton_1->setText(tr("Hexotic_ADD"));
238 mySmpWidget->pushButton_2->setText(tr("Hexotic_REMOVE"));
240 // Setting a custom delegate for the size column
241 SizeMapsTableWidgetDelegate* delegate = new SizeMapsTableWidgetDelegate();
242 mySmpWidget->tableWidget->setItemDelegateForColumn(SIZE_COL, delegate);
244 // Add the size maps widget to a layout
245 QHBoxLayout* aSmpLayout = new QHBoxLayout( aSmpGroup );
246 aSmpLayout->setMargin( 0 );
247 aSmpLayout->addWidget( mySmpWidget);
249 // Viscous Layers tab
250 QWidget* aVLGroup = new QWidget();
251 lay->addWidget( aVLGroup );
253 // Viscous layers widget creation and initialisation
254 myVLWidget = new HexoticPluginGUI_ViscousLayersWidget(aVLGroup);
256 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
257 QString aSubEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
259 if ( !aMainEntry.isEmpty() )
261 myVLWidget->myFacesWithLayers->SetGeomShapeEntry( aSubEntry, aMainEntry );
262 myVLWidget->myImprintedFaces->SetGeomShapeEntry( aSubEntry, aMainEntry );
266 myVLWidget->labelFacesWithLayers->setVisible(false);
267 myVLWidget->myFacesWithLayers->setVisible(false);
268 myVLWidget->labelImprintedFaces->setVisible(false);
269 myVLWidget->myImprintedFaces->setVisible(false);
272 // Add the viscous layers widget to a layout
273 QHBoxLayout* aVLLayout = new QHBoxLayout( aVLGroup );
274 aVLLayout->setSpacing( 6 );
275 aVLLayout->setMargin( 11 );
276 aVLLayout->addWidget( myVLWidget );
280 aTabWidget->insertTab( STD_TAB, aStdGroup, tr( "SMESH_ARGUMENTS" ) );
281 aTabWidget->insertTab( SMP_TAB, aSmpGroup, tr( "LOCAL_SIZE" ) );
282 aTabWidget->insertTab( VL_TAB, aVLGroup, tr( "Hexotic_VISCOUS_LAYERS") );
287 mySizeMapsToRemove.clear();
288 connect( mySmpWidget->pushButton_1, SIGNAL( clicked() ), this, SLOT( onAddLocalSize() ) );
289 connect( mySmpWidget->pushButton_2, SIGNAL( clicked() ), this, SLOT( onRemoveLocalSize() ) );
290 connect( aTabWidget, SIGNAL( currentChanged(int)), this, SLOT( onTabChanged( int ) ) );
294 void HexoticPluginGUI_HypothesisCreator::onAddLocalSize()
296 int rowCount = mySmpWidget->tableWidget->rowCount();
297 //int columnCount = mySmpWidget->tableWidget->columnCount();
299 // Get the selected object properties
300 GEOM::GEOM_Object_var sizeMapObject = myGeomSelWdg->GetObject< GEOM::GEOM_Object >(0);
301 if (sizeMapObject->_is_nil())
304 std::string entry, shapeName;
305 entry = (std::string) sizeMapObject->GetStudyEntry();
306 shapeName = sizeMapObject->GetName();
308 // Check if the object is already in the widget
309 QList<QTableWidgetItem *> listFound = mySmpWidget->tableWidget
310 ->findItems( QString(entry.c_str()), Qt::MatchExactly );
311 if ( !listFound.isEmpty() )
314 // Get the size value
315 double size = mySmpWidget->doubleSpinBox->value();
318 SUIT_MessageBox::critical( mySmpWidget, tr( "SMESH_ERROR" ), tr( "Hexotic_NULL_LOCAL_SIZE" ) );
322 // Set items for the inserted row
323 insertLocalSizeInWidget( entry, shapeName, size, rowCount );
326 void HexoticPluginGUI_HypothesisCreator::insertLocalSizeInWidget( std::string entry,
327 std::string shapeName,
331 MESSAGE("HexoticPluginGUI_HypothesisCreator:insertLocalSizeInWidget")
332 int columnCount = mySmpWidget->tableWidget->columnCount();
334 // Add a row at the end of the table
335 mySmpWidget->tableWidget->insertRow(row);
338 for (int col = 0; col<columnCount; col++)
340 QTableWidgetItem* item = new QTableWidgetItem();
345 value = QVariant( entry.c_str() );
346 item->setData(Qt::DisplayRole, value );
349 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
350 value = QVariant( shapeName.c_str() );
351 item->setData(Qt::DisplayRole, value );
354 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
355 value = QVariant( size );
356 item->setData(Qt::EditRole, value );
359 mySmpWidget->tableWidget->setItem(row,col,item);
363 void HexoticPluginGUI_HypothesisCreator::onRemoveLocalSize()
365 // Remove the selected rows in the table
366 QList<QTableWidgetSelectionRange> ranges = mySmpWidget->tableWidget->selectedRanges();
367 if ( ranges.isEmpty() ) // If none is selected remove the last one
369 int lastRow = mySmpWidget->tableWidget->rowCount() - 1;
370 std::string entry = mySmpWidget->tableWidget->item( lastRow, ENTRY_COL )->text().toStdString();
371 mySizeMapsToRemove.push_back(entry);
372 mySmpWidget->tableWidget->removeRow( lastRow );
376 QList<QTableWidgetSelectionRange>::iterator it;
377 for ( it = ranges.begin(); it != ranges.end(); ++it )
379 for ( int row = it->topRow(); row <= it->bottomRow(); row++ )
381 std::string entry = mySmpWidget->tableWidget->item( row, ENTRY_COL )->text().toStdString();
382 mySizeMapsToRemove.push_back(entry);
383 MESSAGE("ADDING entry : "<<entry<<"to the Size Maps to remove")
385 mySmpWidget->tableWidget->model()->removeRows(it->topRow(), it->rowCount());
390 //=================================================================================
391 // function : resizeEvent [REDEFINED]
393 //=================================================================================
394 void HexoticPluginGUI_HypothesisCreator::resizeEvent(QResizeEvent */*event*/) {
395 QSize scaledSize = myStdWidget->imageSdMode.size();
396 scaledSize.scale(myStdWidget->sdModeLabel->size(), Qt::KeepAspectRatioByExpanding);
397 if (!myStdWidget->sdModeLabel->pixmap() || scaledSize != myStdWidget->sdModeLabel->pixmap()->size())
398 myStdWidget->sdModeLabel->setPixmap(myStdWidget->imageSdMode.scaled(myStdWidget->sdModeLabel->size(),
400 Qt::SmoothTransformation));
403 void HexoticPluginGUI_HypothesisCreator::retrieveParams() const
405 HexoticHypothesisData data;
406 readParamsFromHypo( data );
410 myName->setText( data.myName );
412 myStdWidget->myMinSize->setCleared(data.myMinSize == 0);
413 if (data.myMinSize == 0)
414 myStdWidget->myMinSize->setText("");
416 myStdWidget->myMinSize->setValue( data.myMinSize );
418 myStdWidget->myMaxSize->setCleared(data.myMaxSize == 0);
419 if (data.myMaxSize == 0)
420 myStdWidget->myMaxSize->setText("");
422 myStdWidget->myMaxSize->setValue( data.myMaxSize );
424 myStdWidget->myHexesMinLevel->setCleared(data.myHexesMinLevel == 0);
425 if (data.myHexesMinLevel == 0)
426 myStdWidget->myHexesMinLevel->setText("");
428 myStdWidget->myHexesMinLevel->setValue( data.myHexesMinLevel );
430 myStdWidget->myHexesMaxLevel->setCleared(data.myHexesMaxLevel == 0);
431 if (data.myHexesMaxLevel == 0)
432 myStdWidget->myHexesMaxLevel->setText("");
434 myStdWidget->myHexesMaxLevel->setValue( data.myHexesMaxLevel );
436 myStdWidget->myHexoticIgnoreRidges->setChecked( data.myHexoticIgnoreRidges );
437 myStdWidget->myHexoticInvalidElements->setChecked( data.myHexoticInvalidElements );
439 myStdWidget->myHexoticSharpAngleThreshold->setCleared(data.myHexoticSharpAngleThreshold == 0);
440 if (data.myHexoticSharpAngleThreshold == 0)
441 myStdWidget->myHexoticSharpAngleThreshold->setText("");
443 myStdWidget->myHexoticSharpAngleThreshold->setValue( data.myHexoticSharpAngleThreshold );
445 myStdWidget->myHexoticNbProc->setValue( data.myHexoticNbProc );
447 myStdWidget->myHexoticWorkingDir->setText( data.myHexoticWorkingDir );
449 myStdWidget->myHexoticVerbosity->setValue( data.myHexoticVerbosity );
451 myStdWidget->myHexoticMaxMemory->setValue( data.myHexoticMaxMemory );
453 myStdWidget->myHexoticSdMode->setCurrentIndex(data.myHexoticSdMode);
455 myStdWidget->myTextOptions->setText(data.myTextOptions);
457 HexoticPlugin_Hypothesis::THexoticSizeMaps::const_iterator it = data.mySizeMaps.begin();
458 for ( int row = 0; it != data.mySizeMaps.end(); it++, row++ )
460 std::string entry = it->first;
461 double size = it->second;
462 GEOM::GEOM_Object_var anObject = entryToObject( entry );
463 std::string shapeName = anObject->GetName();
465 MESSAGE(" Insert local size, entry : "<<entry<<", size : "<<size<<", at row : "<<row)
466 insertLocalSizeInWidget( entry, shapeName, size , row );
469 myVLWidget->myNbLayers->setCleared(data.myNbLayers == 0);
470 if (data.myNbLayers == 0)
471 myVLWidget->myNbLayers->setText("");
473 myVLWidget->myNbLayers->setValue( data.myNbLayers );
475 myVLWidget->myFirstLayerSize->setCleared(data.myFirstLayerSize == 0);
476 if (data.myFirstLayerSize == 0)
477 myVLWidget->myFirstLayerSize->setText("");
479 myVLWidget->myFirstLayerSize->setValue( data.myFirstLayerSize );
481 myVLWidget->myDirection->setCurrentIndex( data.myDirection ? 0 : 1 );
482 myVLWidget->myGrowth->setCleared(data.myGrowth == 0);
483 if (data.myGrowth == 0)
484 myVLWidget->myGrowth->setText("");
486 myVLWidget->myGrowth->setValue( data.myGrowth );
488 std::vector<int> vector = data.myFacesWithLayers;
489 SMESH::long_array_var aVec = new SMESH::long_array;
490 aVec->length(vector.size());
491 for (size_t i = 0; i < vector.size(); i++)
492 aVec[i]=vector.at(i);
493 myVLWidget->myFacesWithLayers->SetListOfIDs(aVec);
494 vector = data.myImprintedFaces;
495 aVec = new SMESH::long_array;
496 aVec->length(vector.size());
497 for (size_t i = 0; i < vector.size(); i++)
498 aVec[i]=vector.at(i);
499 myVLWidget->myImprintedFaces->SetListOfIDs(aVec);
502 std::cout << "myStdWidget->myMinSize->value(): " << myStdWidget->myMinSize->value() << std::endl;
503 std::cout << "myStdWidget->myMaxSize->value(): " << myStdWidget->myMaxSize->value() << std::endl;
504 std::cout << "myStdWidget->myHexesMinLevel->value(): " << myStdWidget->myHexesMinLevel->value() << std::endl;
505 std::cout << "myStdWidget->myHexesMaxLevel->value(): " << myStdWidget->myHexesMaxLevel->value() << std::endl;
506 std::cout << "myStdWidget->myHexoticSharpAngleThreshold->value(): " << myStdWidget->myHexoticSharpAngleThreshold->value() << std::endl;
510 void HexoticPluginGUI_HypothesisCreator::printData( HexoticHypothesisData& data) const
513 valStr += tr("Hexotic_MIN_SIZE") + " = " + QString::number( data.myMinSize ) + "; ";
514 valStr += tr("Hexotic_MAX_SIZE") + " = " + QString::number( data.myMaxSize ) + "; ";
515 valStr += tr("Hexotic_HEXES_MIN_LEVEL") + " = " + QString::number( data.myHexesMinLevel ) + "; ";
516 valStr += tr("Hexotic_HEXES_MAX_LEVEL") + " = " + QString::number( data.myHexesMaxLevel ) + "; ";
517 valStr += tr("Hexotic_IGNORE_RIDGES") + " = " + QString::number( data.myHexoticIgnoreRidges ) + "; ";
518 valStr += tr("Hexotic_INVALID_ELEMENTS") + " = " + QString::number( data.myHexoticInvalidElements ) + "; ";
519 valStr += tr("Hexotic_SHARP_ANGLE_THRESHOLD") + " = " + QString::number( data.myHexoticSharpAngleThreshold ) + "; ";
520 valStr += tr("Hexotic_NB_PROC") + " = " + QString::number( data.myHexoticNbProc ) + "; ";
521 valStr += tr("Hexotic_WORKING_DIR") + " = " + data.myHexoticWorkingDir + "; ";
522 valStr += tr("Hexotic_VERBOSITY") + " = " + QString::number( data.myHexoticVerbosity ) + "; ";
523 valStr += tr("Hexotic_MAX_MEMORY") + " = " + QString::number( data.myHexoticMaxMemory ) + "; ";
524 valStr += tr("Hexotic_SD_MODE") + " = " + QString::number( data.myHexoticSdMode ) + "; ";
525 valStr += tr("Hexotic_TEXT_OPTIONS") + " = " + data.myTextOptions + ";";
527 std::cout << "Data: " << valStr.toStdString() << std::endl;
530 QString HexoticPluginGUI_HypothesisCreator::storeParams() const
532 HexoticHypothesisData data;
533 readParamsFromWidgets( data );
534 storeParamsToHypo( data );
537 valStr += tr("Hexotic_MIN_SIZE") + " = " + QString::number( data.myMinSize ) + "; ";
538 valStr += tr("Hexotic_MAX_SIZE") + " = " + QString::number( data.myMaxSize ) + "; ";
539 valStr += tr("Hexotic_HEXES_MIN_LEVEL") + " = " + QString::number( data.myHexesMinLevel ) + "; ";
540 valStr += tr("Hexotic_HEXES_MAX_LEVEL") + " = " + QString::number( data.myHexesMaxLevel ) + "; ";
541 valStr += tr("Hexotic_IGNORE_RIDGES") + " = " + QString::number( data.myHexoticIgnoreRidges ) + "; ";
542 valStr += tr("Hexotic_INVALID_ELEMENTS") + " = " + QString::number( data.myHexoticInvalidElements ) + "; ";
543 valStr += tr("Hexotic_SHARP_ANGLE_THRESHOLD") + " = " + QString::number( data.myHexoticSharpAngleThreshold ) + "; ";
544 valStr += tr("Hexotic_NB_PROC") + " = " + QString::number( data.myHexoticNbProc ) + "; ";
545 valStr += tr("Hexotic_WORKING_DIR") + " = " + data.myHexoticWorkingDir + "; ";
546 valStr += tr("Hexotic_VERBOSITY") + " = " + QString::number( data.myHexoticVerbosity) + "; ";
547 valStr += tr("Hexotic_MAX_MEMORY") + " = " + QString::number( data.myHexoticMaxMemory ) + "; ";
548 valStr += tr("Hexotic_SD_MODE") + " = " + QString::number( data.myHexoticSdMode) + "; ";
549 valStr += tr("Hexotic_TEXT_OPTIONS") + " = " + data.myTextOptions + "; ";
551 valStr += tr("Hexotic_NB_LAYERS") + " = " + QString::number(data.myNbLayers) + ";";
552 valStr += tr("Hexotic_FIRST_LAYER_SIZE") + " = " + QString::number(data.myFirstLayerSize) + ";";
553 valStr += tr("Hexotic_DIRECTION") + " = " + QString::number(data.myDirection) + ";";
554 valStr += tr("Hexotic_GROWTH") + " = " + QString::number(data.myGrowth) + ";";
556 // std::cout << "Data: " << valStr.toStdString() << std::endl;
561 bool HexoticPluginGUI_HypothesisCreator::readParamsFromHypo( HexoticHypothesisData& h_data ) const
563 HexoticPlugin::HexoticPlugin_Hypothesis_var h =
564 HexoticPlugin::HexoticPlugin_Hypothesis::_narrow( initParamsHypothesis() );
566 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
567 h_data.myName = isCreation() && data ? data->Label : "";
568 h_data.myMinSize = h->GetMinSize();
569 h_data.myMaxSize = h->GetMaxSize();
570 h_data.myHexesMinLevel = h->GetHexesMinLevel();
571 h_data.myHexesMaxLevel = h->GetHexesMaxLevel();
572 h_data.myHexoticIgnoreRidges = h->GetHexoticIgnoreRidges();
573 h_data.myHexoticInvalidElements = h->GetHexoticInvalidElements();
574 h_data.myHexoticSharpAngleThreshold = h->GetHexoticSharpAngleThreshold();
575 h_data.myHexoticNbProc = h->GetHexoticNbProc();
576 h_data.myHexoticWorkingDir = h->GetHexoticWorkingDirectory();
577 h_data.myHexoticVerbosity = h->GetHexoticVerbosity();
578 h_data.myHexoticMaxMemory = h->GetHexoticMaxMemory();
579 h_data.myHexoticSdMode = h->GetHexoticSdMode()-1;
580 h_data.myTextOptions = h->GetTextOptions();
583 HexoticPlugin::HexoticPluginSizeMapsList_var sizeMaps = h->GetSizeMaps();
584 for ( CORBA::ULong i = 0 ; i < sizeMaps->length() ; i++)
586 HexoticPlugin::HexoticPluginSizeMap aSizeMap = sizeMaps[i];
587 std::string entry = CORBA::string_dup(aSizeMap.entry.in());
588 double size = aSizeMap.size;
589 h_data.mySizeMaps[ entry ] = size;
590 MESSAGE("READING Size map : entry "<<entry<<" size : "<<size)
594 h_data.myNbLayers = h->GetNbLayers();
595 h_data.myFirstLayerSize = h->GetFirstLayerSize();
596 h_data.myDirection = h->GetDirection();
597 h_data.myGrowth = h->GetGrowth();
598 SMESH::long_array_var vector = h->GetFacesWithLayers();
599 for ( CORBA::ULong i = 0; i < vector->length(); i++)
600 h_data.myFacesWithLayers.push_back(vector[i]);
601 vector = h->GetImprintedFaces();
602 for ( CORBA::ULong i = 0; i < vector->length(); i++)
603 h_data.myImprintedFaces.push_back(vector[i]);
608 bool HexoticPluginGUI_HypothesisCreator::storeParamsToHypo( const HexoticHypothesisData& h_data ) const
610 HexoticPlugin::HexoticPlugin_Hypothesis_var h =
611 HexoticPlugin::HexoticPlugin_Hypothesis::_narrow( hypothesis() );
618 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
620 h->SetMinSize( h_data.myMinSize );
621 h->SetMaxSize( h_data.myMaxSize );
622 h->SetHexesMinLevel( h_data.myHexesMinLevel );
623 h->SetHexesMaxLevel( h_data.myHexesMaxLevel );
624 h->SetHexoticIgnoreRidges( h_data.myHexoticIgnoreRidges );
625 h->SetHexoticInvalidElements( h_data.myHexoticInvalidElements );
626 h->SetHexoticSharpAngleThreshold( h_data.myHexoticSharpAngleThreshold );
627 h->SetHexoticNbProc( h_data.myHexoticNbProc );
628 h->SetHexoticWorkingDirectory( h_data.myHexoticWorkingDir.toLatin1().constData() );
629 h->SetHexoticVerbosity( h_data.myHexoticVerbosity );
630 h->SetHexoticMaxMemory( h_data.myHexoticMaxMemory );
631 h->SetHexoticSdMode( h_data.myHexoticSdMode+1 );
632 h->SetTextOptions( h_data.myTextOptions.toLatin1().constData() );
634 HexoticPlugin_Hypothesis::THexoticSizeMaps::const_iterator it;
636 for ( it = h_data.mySizeMaps.begin(); it != h_data.mySizeMaps.end(); it++ )
638 h->SetSizeMapEntry( it->first.c_str(), it->second );
639 MESSAGE("STORING Size map : entry "<<it->first.c_str()<<" size : "<<it->second)
641 std::vector< std::string >::const_iterator entry_it;
642 for ( entry_it = mySizeMapsToRemove.begin(); entry_it!= mySizeMapsToRemove.end(); entry_it++ )
644 h->UnsetSizeMapEntry(entry_it->c_str());
648 h->SetNbLayers( h_data.myNbLayers );
649 h->SetFirstLayerSize( h_data.myFirstLayerSize );
650 h->SetDirection( h_data.myDirection );
651 h->SetGrowth( h_data.myGrowth );
653 std::vector<int> vector = h_data.myFacesWithLayers;
654 SMESH::long_array_var aVec = new SMESH::long_array;
655 aVec->length(vector.size());
656 for ( size_t i = 0; i < vector.size(); i++)
657 aVec[i]=vector.at(i);
658 h->SetFacesWithLayers( aVec );
660 vector = h_data.myImprintedFaces;
661 aVec = new SMESH::long_array;
662 aVec->length(vector.size());
663 for ( size_t i = 0; i < vector.size(); i++)
664 aVec[i]=vector.at(i);
665 h->SetImprintedFaces( aVec );
667 catch(const SALOME::SALOME_Exception& ex)
669 SalomeApp_Tools::QtCatchCorbaException(ex);
675 bool HexoticPluginGUI_HypothesisCreator::readParamsFromWidgets( HexoticHypothesisData& h_data ) const
677 h_data.myName = myName ? myName->text() : "";
679 h_data.myHexoticIgnoreRidges = myStdWidget->myHexoticIgnoreRidges->isChecked();
680 h_data.myHexoticInvalidElements = myStdWidget->myHexoticInvalidElements->isChecked();
682 h_data.myHexoticNbProc = myStdWidget->myHexoticNbProc->value();
684 h_data.myHexoticWorkingDir = myStdWidget->myHexoticWorkingDir->text();
685 h_data.myHexoticVerbosity = myStdWidget->myHexoticVerbosity->value();
686 h_data.myHexoticMaxMemory = myStdWidget->myHexoticMaxMemory->value();
687 h_data.myHexoticSdMode = myStdWidget->myHexoticSdMode->currentIndex();
688 h_data.myTextOptions = myStdWidget->myTextOptions->text();
690 h_data.myMinSize = myStdWidget->myMinSize->text().isEmpty() ? 0.0 : myStdWidget->myMinSize->value();
691 h_data.myMaxSize = myStdWidget->myMaxSize->text().isEmpty() ? 0.0 : myStdWidget->myMaxSize->value();
692 h_data.myHexesMinLevel = myStdWidget->myHexesMinLevel->text().isEmpty() ? 0 : myStdWidget->myHexesMinLevel->value();
693 h_data.myHexesMaxLevel = myStdWidget->myHexesMaxLevel->text().isEmpty() ? 0 : myStdWidget->myHexesMaxLevel->value();
694 h_data.myHexoticSharpAngleThreshold = myStdWidget->myHexoticSharpAngleThreshold->text().isEmpty() ? 0 : myStdWidget->myHexoticSharpAngleThreshold->value();
697 bool ok = readSizeMapsFromWidgets( h_data );
701 h_data.myNbLayers = myVLWidget->myNbLayers->text().isEmpty() ? 0.0 : myVLWidget->myNbLayers->value();
702 h_data.myFirstLayerSize = myVLWidget->myFirstLayerSize->text().isEmpty() ? 0.0 : myVLWidget->myFirstLayerSize->value();
703 h_data.myDirection = myVLWidget->myDirection->currentIndex() == 0 ? true : false;
704 h_data.myGrowth = myVLWidget->myGrowth->text().isEmpty() ? 0.0 : myVLWidget->myGrowth->value();
705 SMESH::long_array_var ids = myVLWidget->myFacesWithLayers->GetListOfIDs();
706 for ( CORBA::ULong i = 0; i < ids->length(); i++)
707 h_data.myFacesWithLayers.push_back( ids[i] );
708 ids = myVLWidget->myImprintedFaces->GetListOfIDs();
709 for ( CORBA::ULong i = 0; i < ids->length(); i++)
710 h_data.myImprintedFaces.push_back( ids[i] );
717 bool HexoticPluginGUI_HypothesisCreator::readSizeMapsFromWidgets( HexoticHypothesisData& h_data ) const
719 int rowCount = mySmpWidget->tableWidget->rowCount();
720 for ( int row = 0; row < rowCount; row++ )
722 std::string entry = mySmpWidget->tableWidget->item( row, ENTRY_COL )->text().toStdString();
723 QVariant size_variant = mySmpWidget->tableWidget->item( row, SIZE_COL )->data(Qt::DisplayRole);
725 // Convert the size to double
727 double size = size_variant.toDouble(&ok);
732 h_data.mySizeMaps[ entry ] = size;
733 MESSAGE("READING Size map from WIDGET: entry "<<entry<<" size : "<<size)
738 GEOM::GEOM_Object_var HexoticPluginGUI_HypothesisCreator::entryToObject( std::string entry) const
740 SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
741 SALOMEDS::Study_var myStudy = smeshGen_i->GetCurrentStudy();
742 GEOM::GEOM_Object_var aGeomObj;
743 SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.c_str() );
744 if (!aSObj->_is_nil()) {
745 CORBA::Object_var obj = aSObj->GetObject();
746 aGeomObj = GEOM::GEOM_Object::_narrow(obj);
752 QString HexoticPluginGUI_HypothesisCreator::caption() const
754 return myIs3D ? tr( "Hexotic_3D_TITLE" ) : tr( "Hexotic_3D_TITLE" ); // ??? 3D/2D ???
757 QPixmap HexoticPluginGUI_HypothesisCreator::icon() const
759 QString hypIconName = myIs3D ? tr( "ICON_DLG_Hexotic_PARAMETERS" ) : tr( "ICON_DLG_Hexotic_PARAMETERS" );
760 return SUIT_Session::session()->resourceMgr()->loadPixmap( "HexoticPLUGIN", hypIconName );
763 QString HexoticPluginGUI_HypothesisCreator::type() const
765 return myIs3D ? tr( "Hexotic_3D_HYPOTHESIS" ) : tr( "Hexotic_3D_HYPOTHESIS" ); // ??? 3D/2D ???
768 QString HexoticPluginGUI_HypothesisCreator::helpPage() const
770 return "hexotic_hypo_page.html";
773 void HexoticPluginGUI_HypothesisCreator::onTabChanged(int i)
775 myVLWidget->myFacesWithLayers->ShowPreview( i == VL_TAB );
776 myVLWidget->myImprintedFaces->ShowPreview( false );