1 // Copyright (C) 2007-2022 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>
31 #include <SMESH_AdvOptionsWdg.h>
33 #include "utilities.h"
35 #include <SUIT_Session.h>
36 #include <SUIT_ResourceMgr.h>
37 #include <SUIT_MessageBox.h>
38 #include <SUIT_FileDlg.h>
39 #include <SalomeApp_Tools.h>
40 #include <QtxIntSpinBox.h>
44 #include <QVBoxLayout>
45 #include <QGridLayout>
49 #include <QPushButton>
51 #include "SMESH_Gen_i.hxx"
54 #include <TColStd_MapOfInteger.hxx>
57 // 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 HexoticPlugin::HexoticPlugin_Hypothesis_var h =
137 HexoticPlugin::HexoticPlugin_Hypothesis::_narrow( hypothesis() );
139 myAdvWidget->myOptionTable->setFocus();
140 QApplication::instance()->processEvents();
143 bool isDefault, ok = true;
144 int iRow = 0, nbRows = myAdvWidget->myOptionTable->topLevelItemCount();
145 for ( ; iRow < nbRows; ++iRow )
147 QTreeWidgetItem* row = myAdvWidget->myOptionTable->topLevelItem( iRow );
148 myAdvWidget->GetOptionAndValue( row, name, value, isDefault );
150 if ( name.simplified().isEmpty() )
151 continue; // invalid custom option
153 if ( isDefault ) // not selected option
157 h->SetOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
159 catch ( const SALOME::SALOME_Exception& ex )
161 msg = ex.details.text.in();
169 h->SetOptionValues( myOptions ); // restore values
173 HexoticHypothesisData data_old, data_new;
174 readParamsFromHypo( data_old ); // new values of advanced options ( myOptions ) are read
176 bool res = readParamsFromWidgets( data_new );
182 res = data_old.myMinSize <= data_old.myMaxSize;
184 msg = tr(QString("Min size (%1) is higher than max size (%2)").arg(data_old.myMinSize).arg(data_old.myMaxSize).toStdString().c_str());
188 res = data_old.myHexesMinLevel == 0 || \
189 ( data_old.myHexesMinLevel != 0 && (data_old.myHexesMinLevel < data_old.myHexesMaxLevel) );
191 msg = tr(QString("Min hexes level (%1) is higher than max hexes level (%2)").arg(data_old.myHexesMinLevel).arg(data_old.myHexesMaxLevel).toStdString().c_str());
195 res = storeParamsToHypo( data_new );
197 storeParamsToHypo( data_old );
204 QFrame* HexoticPluginGUI_HypothesisCreator::buildFrame()
206 QFrame* fr = new QFrame( 0 );
207 QVBoxLayout* lay = new QVBoxLayout( fr );
209 lay->setSpacing( 6 );
211 // main TabWidget of the dialog
212 QTabWidget* aTabWidget = new QTabWidget( fr );
213 aTabWidget->setTabShape( QTabWidget::Rounded );
214 aTabWidget->setTabPosition( QTabWidget::North );
215 lay->addWidget( aTabWidget );
217 // Standard arguments tab
218 QWidget* aStdGroup = new QWidget();
219 QGridLayout* l = new QGridLayout( aStdGroup );
226 l->addWidget( new QLabel( tr( "SMESH_NAME" ), aStdGroup ), row, 0, 1, 1 );
227 myName = new QLineEdit( aStdGroup );
228 l->addWidget( myName, row++, 1, 1, 2 );
229 myName->setMinimumWidth( 150 );
232 myStdWidget = new HexoticPluginGUI_StdWidget(aStdGroup);
233 l->addWidget( myStdWidget, row++, 0, 1, 3 );
234 myStdWidget->onSdModeSelected(SD_MODE_4);
235 //myStdWidget->gridLayout->setRowStretch( 1, 2 );
238 myAdvWidget = new HexoticPluginGUI_AdvWidget( aTabWidget );
239 //myAdvWidget->gridLayout->setRowStretch( 0, 2 );
242 mySmpWidget = new HexoticPluginGUI_SizeMapsWidget( aTabWidget );
243 mySmpWidget->doubleSpinBox->RangeStepAndValidator(0.0, COORD_MAX, 1.0, "length_precision");
244 mySmpWidget->doubleSpinBox->setValue(0.0);
246 // Filters of selection
247 TColStd_MapOfInteger SM_ShapeTypes;
248 SM_ShapeTypes.Add( TopAbs_VERTEX );
249 SM_ShapeTypes.Add( TopAbs_EDGE );
250 SM_ShapeTypes.Add( TopAbs_WIRE );
251 SM_ShapeTypes.Add( TopAbs_FACE );
252 SM_ShapeTypes.Add( TopAbs_SOLID );
253 SM_ShapeTypes.Add( TopAbs_COMPOUND );
254 SMESH_NumberFilter* aFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, SM_ShapeTypes);
257 myGeomSelWdg = new StdMeshersGUI_ObjectReferenceParamWdg( aFilter, mySmpWidget, /*multiSel=*/false);
258 myGeomSelWdg->SetDefaultText(tr("Hexotic_SEL_SHAPE"), "QLineEdit { color: grey }");
259 mySmpWidget->gridLayout->addWidget(myGeomSelWdg, 0, 1);
261 // Configuration of the table widget
262 QStringList headerLabels;
263 headerLabels << tr("Hexotic_ENTRY")<< tr("Hexotic_NAME")<< tr("Hexotic_SIZE");
264 mySmpWidget->tableWidget->setHorizontalHeaderLabels(headerLabels);
265 mySmpWidget->tableWidget->resizeColumnsToContents();
266 mySmpWidget->tableWidget->hideColumn( 0 );
267 mySmpWidget->label->setText(tr("LOCAL_SIZE"));
268 mySmpWidget->pushButton_1->setText(tr("Hexotic_ADD"));
269 mySmpWidget->pushButton_2->setText(tr("Hexotic_REMOVE"));
271 // Setting a custom delegate for the size column
272 SizeMapsTableWidgetDelegate* delegate = new SizeMapsTableWidgetDelegate();
273 mySmpWidget->tableWidget->setItemDelegateForColumn(SIZE_COL, delegate);
276 // Viscous Layers tab
278 // Viscous layers widget creation and initialisation
279 myVLWidget = new HexoticPluginGUI_ViscousLayersWidget( aTabWidget );
281 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
282 QString aSubEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
284 if ( !aMainEntry.isEmpty() )
286 myVLWidget->myFacesWithLayers->SetGeomShapeEntry( aSubEntry, aMainEntry );
287 myVLWidget->myImprintedFaces->SetGeomShapeEntry( aSubEntry, aMainEntry );
291 myVLWidget->labelFacesWithLayers->setVisible(false);
292 myVLWidget->myFacesWithLayers->setVisible(false);
293 myVLWidget->labelImprintedFaces->setVisible(false);
294 myVLWidget->myImprintedFaces->setVisible(false);
297 aTabWidget->insertTab( STD_TAB, aStdGroup, tr( "SMESH_ARGUMENTS" ));
298 aTabWidget->insertTab( ADV_TAB, myAdvWidget, tr( "SMESH_ADVANCED" ));
299 aTabWidget->insertTab( SMP_TAB, mySmpWidget, tr( "LOCAL_SIZE" ));
300 aTabWidget->insertTab( VL_TAB, myVLWidget, tr( "Hexotic_VISCOUS_LAYERS"));
305 mySizeMapsToRemove.clear();
306 connect( mySmpWidget->pushButton_1, SIGNAL( clicked() ), this, SLOT( onAddLocalSize() ) );
307 connect( mySmpWidget->pushButton_2, SIGNAL( clicked() ), this, SLOT( onRemoveLocalSize() ) );
308 connect( aTabWidget, SIGNAL( currentChanged(int)), this, SLOT( onTabChanged( int ) ) );
309 connect( myAdvWidget->addBtn, SIGNAL( clicked() ), this, SLOT( onAddOption() ) );
310 connect( myAdvWidget->dirBtn, SIGNAL( clicked() ), this, SLOT( onDirBtnClicked() ) );
314 void HexoticPluginGUI_HypothesisCreator::onAddLocalSize()
316 int rowCount = mySmpWidget->tableWidget->rowCount();
317 //int columnCount = mySmpWidget->tableWidget->columnCount();
319 // Get the selected object properties
320 GEOM::GEOM_Object_var sizeMapObject = myGeomSelWdg->GetObject< GEOM::GEOM_Object >(0);
321 if (sizeMapObject->_is_nil())
324 std::string entry, shapeName;
325 entry = (std::string) sizeMapObject->GetStudyEntry();
326 shapeName = sizeMapObject->GetName();
328 // Check if the object is already in the widget
329 QList<QTableWidgetItem *> listFound = mySmpWidget->tableWidget
330 ->findItems( QString(entry.c_str()), Qt::MatchExactly );
331 if ( !listFound.isEmpty() )
334 // Get the size value
335 double size = mySmpWidget->doubleSpinBox->value();
338 SUIT_MessageBox::critical( mySmpWidget, tr( "SMESH_ERROR" ), tr( "Hexotic_NULL_LOCAL_SIZE" ) );
342 // Set items for the inserted row
343 insertLocalSizeInWidget( entry, shapeName, size, rowCount );
346 void HexoticPluginGUI_HypothesisCreator::insertLocalSizeInWidget( std::string entry,
347 std::string shapeName,
351 MESSAGE("HexoticPluginGUI_HypothesisCreator:insertLocalSizeInWidget")
352 int columnCount = mySmpWidget->tableWidget->columnCount();
354 // Add a row at the end of the table
355 mySmpWidget->tableWidget->insertRow(row);
358 for (int col = 0; col<columnCount; col++)
360 QTableWidgetItem* item = new QTableWidgetItem();
365 value = QVariant( entry.c_str() );
366 item->setData(Qt::DisplayRole, value );
369 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
370 value = QVariant( shapeName.c_str() );
371 item->setData(Qt::DisplayRole, value );
374 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
375 value = QVariant( size );
376 item->setData(Qt::EditRole, value );
379 mySmpWidget->tableWidget->setItem(row,col,item);
383 void HexoticPluginGUI_HypothesisCreator::onRemoveLocalSize()
385 // Remove the selected rows in the table
386 QList<QTableWidgetSelectionRange> ranges = mySmpWidget->tableWidget->selectedRanges();
387 if ( ranges.isEmpty() && mySmpWidget->tableWidget->rowCount() > 0) // If none is selected remove the last one
389 int lastRow = mySmpWidget->tableWidget->rowCount() - 1;
390 std::string entry = mySmpWidget->tableWidget->item( lastRow, ENTRY_COL )->text().toStdString();
391 mySizeMapsToRemove.push_back(entry);
392 mySmpWidget->tableWidget->removeRow( lastRow );
396 QList<QTableWidgetSelectionRange>::iterator it;
397 for ( it = ranges.begin(); it != ranges.end(); ++it )
399 for ( int row = it->topRow(); row <= it->bottomRow(); row++ )
401 std::string entry = mySmpWidget->tableWidget->item( row, ENTRY_COL )->text().toStdString();
402 mySizeMapsToRemove.push_back(entry);
403 MESSAGE("ADDING entry : "<<entry<<"to the Size Maps to remove")
405 mySmpWidget->tableWidget->model()->removeRows(it->topRow(), it->rowCount());
410 //=================================================================================
411 // function : resizeEvent [REDEFINED]
413 //=================================================================================
414 void HexoticPluginGUI_HypothesisCreator::resizeEvent(QResizeEvent */*event*/) {
415 QSize scaledSize = myStdWidget->imageSdMode.size();
416 scaledSize.scale(myStdWidget->sdModeLabel->size(), Qt::KeepAspectRatioByExpanding);
417 if (!myStdWidget->sdModeLabel->pixmap() || scaledSize != myStdWidget->sdModeLabel->pixmap()->size())
418 myStdWidget->sdModeLabel->setPixmap(myStdWidget->imageSdMode.scaled(myStdWidget->sdModeLabel->size(),
420 Qt::SmoothTransformation));
423 void HexoticPluginGUI_HypothesisCreator::retrieveParams() const
425 HexoticHypothesisData data;
426 readParamsFromHypo( data );
430 myName->setText( data.myName );
432 myStdWidget->myPhySizeType->setCurrentIndex( data.myMinSize > 0 || data.myMaxSize > 0 );
434 myStdWidget->myMinSize->setCleared(data.myMinSize == 0);
435 if (data.myMinSize == 0)
436 myStdWidget->myMinSize->setText("");
438 myStdWidget->myMinSize->setValue( data.myMinSize );
440 myStdWidget->myMaxSize->setCleared(data.myMaxSize == 0);
441 if (data.myMaxSize == 0)
442 myStdWidget->myMaxSize->setText("");
444 myStdWidget->myMaxSize->setValue( data.myMaxSize );
446 myStdWidget->myGeomSizeType->setCurrentIndex( data.myApproxAngle > 0 );
448 myStdWidget->myGeomApproxAngle->setCleared( data.myApproxAngle == 0 );
449 if (data.myApproxAngle == 0)
450 myStdWidget->myGeomApproxAngle->setText("");
452 myStdWidget->myGeomApproxAngle->setValue( data.myApproxAngle );
454 myAdvWidget->myHexoticWorkingDir->setText( data.myHexoticWorkingDir );
456 myAdvWidget->myHexoticVerbosity->setValue( data.myHexoticVerbosity );
458 myStdWidget->myHexoticSdMode->setCurrentIndex(data.myHexoticSdMode);
460 //myAdvWidget->SetCustomOptions(data.myTextOptions);
462 if ( myOptions.operator->() ) {
463 for ( int i = 0, nb = myOptions->length(); i < nb; ++i )
464 myAdvWidget->AddOption( myOptions[i].in() );
466 if ( myCustomOptions.operator->() ) {
467 for ( int i = 0, nb = myCustomOptions->length(); i < nb; ++i )
468 myAdvWidget->AddOption( myCustomOptions[i].in() );
470 myAdvWidget->myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
472 myAdvWidget->keepWorkingFilesCheck->setChecked( data.myKeepFiles );
473 myAdvWidget->logInFileCheck->setChecked( !data.myLogInStandardOutput );
474 myAdvWidget->removeLogOnSuccessCheck->setChecked( data.myRemoveLogOnSuccess );
476 HexoticPlugin_Hypothesis::THexoticSizeMaps::const_iterator it = data.mySizeMaps.begin();
477 for ( int row = 0; it != data.mySizeMaps.end(); it++, row++ )
479 std::string entry = it->first;
480 double size = it->second;
481 GEOM::GEOM_Object_var anObject = entryToObject( entry );
482 std::string shapeName = anObject->GetName();
484 MESSAGE(" Insert local size, entry : "<<entry<<", size : "<<size<<", at row : "<<row)
485 insertLocalSizeInWidget( entry, shapeName, size , row );
488 myVLWidget->myNbLayers->setCleared(data.myNbLayers == 0);
489 if (data.myNbLayers == 0)
490 myVLWidget->myNbLayers->setText("");
492 myVLWidget->myNbLayers->setValue( data.myNbLayers );
494 myVLWidget->myFirstLayerSize->setCleared(data.myFirstLayerSize == 0);
495 if (data.myFirstLayerSize == 0)
496 myVLWidget->myFirstLayerSize->setText("");
498 myVLWidget->myFirstLayerSize->setValue( data.myFirstLayerSize );
500 myVLWidget->myDirection->setCurrentIndex( data.myDirection ? 0 : 1 );
501 myVLWidget->myGrowth->setCleared(data.myGrowth == 0);
502 if (data.myGrowth == 0)
503 myVLWidget->myGrowth->setText("");
505 myVLWidget->myGrowth->setValue( data.myGrowth );
507 std::vector<int> vector = data.myFacesWithLayers;
508 SMESH::long_array_var aVec = new SMESH::long_array;
509 aVec->length(vector.size());
510 for (size_t i = 0; i < vector.size(); i++)
511 aVec[i]=vector.at(i);
512 myVLWidget->myFacesWithLayers->SetListOfIDs(aVec);
513 vector = data.myImprintedFaces;
514 aVec = new SMESH::long_array;
515 aVec->length(vector.size());
516 for (size_t i = 0; i < vector.size(); i++)
517 aVec[i]=vector.at(i);
518 myVLWidget->myImprintedFaces->SetListOfIDs(aVec);
522 void HexoticPluginGUI_HypothesisCreator::printData( HexoticHypothesisData& data) const
525 valStr += tr("Hexotic_MIN_SIZE") + " = " + QString::number( data.myMinSize ) + "; ";
526 valStr += tr("Hexotic_MAX_SIZE") + " = " + QString::number( data.myMaxSize ) + "; ";
527 valStr += tr("Hexotic_HEXES_MIN_LEVEL") + " = " + QString::number( data.myHexesMinLevel ) + "; ";
528 valStr += tr("Hexotic_HEXES_MAX_LEVEL") + " = " + QString::number( data.myHexesMaxLevel ) + "; ";
529 valStr += tr("Hexotic_IGNORE_RIDGES") + " = " + QString::number( data.myHexoticIgnoreRidges ) + "; ";
530 valStr += tr("Hexotic_INVALID_ELEMENTS") + " = " + QString::number( data.myHexoticInvalidElements ) + "; ";
531 valStr += tr("Hexotic_SHARP_ANGLE_THRESHOLD") + " = " + QString::number( data.myHexoticSharpAngleThreshold ) + "; ";
532 valStr += tr("Hexotic_NB_PROC") + " = " + QString::number( data.myHexoticNbProc ) + "; ";
533 valStr += tr("Hexotic_WORKING_DIR") + " = " + data.myHexoticWorkingDir + "; ";
534 valStr += tr("Hexotic_VERBOSITY") + " = " + QString::number( data.myHexoticVerbosity ) + "; ";
535 valStr += tr("Hexotic_MAX_MEMORY") + " = " + QString::number( data.myHexoticMaxMemory ) + "; ";
536 valStr += tr("Hexotic_SD_MODE") + " = " + QString::number( data.myHexoticSdMode ) + "; ";
537 valStr += tr("Hexotic_TEXT_OPTIONS") + " = " + data.myTextOptions + ";";
539 std::cout << "Data: " << valStr.toStdString() << std::endl;
542 QString HexoticPluginGUI_HypothesisCreator::storeParams() const
544 HexoticHypothesisData data;
545 readParamsFromWidgets( data );
546 storeParamsToHypo( data );
549 valStr += tr("Hexotic_MIN_SIZE") + " = " + QString::number( data.myMinSize ) + "; ";
550 valStr += tr("Hexotic_MAX_SIZE") + " = " + QString::number( data.myMaxSize ) + "; ";
551 valStr += tr("Hexotic_HEXES_MIN_LEVEL") + " = " + QString::number( data.myHexesMinLevel ) + "; ";
552 valStr += tr("Hexotic_HEXES_MAX_LEVEL") + " = " + QString::number( data.myHexesMaxLevel ) + "; ";
553 valStr += tr("Hexotic_IGNORE_RIDGES") + " = " + QString::number( data.myHexoticIgnoreRidges ) + "; ";
554 valStr += tr("Hexotic_INVALID_ELEMENTS") + " = " + QString::number( data.myHexoticInvalidElements ) + "; ";
555 valStr += tr("Hexotic_SHARP_ANGLE_THRESHOLD") + " = " + QString::number( data.myHexoticSharpAngleThreshold ) + "; ";
556 valStr += tr("Hexotic_NB_PROC") + " = " + QString::number( data.myHexoticNbProc ) + "; ";
557 valStr += tr("Hexotic_WORKING_DIR") + " = " + data.myHexoticWorkingDir + "; ";
558 valStr += tr("Hexotic_VERBOSITY") + " = " + QString::number( data.myHexoticVerbosity) + "; ";
559 valStr += tr("Hexotic_MAX_MEMORY") + " = " + QString::number( data.myHexoticMaxMemory ) + "; ";
560 valStr += tr("Hexotic_SD_MODE") + " = " + QString::number( data.myHexoticSdMode) + "; ";
561 valStr += tr("Hexotic_TEXT_OPTIONS") + " = " + data.myTextOptions + "; ";
563 valStr += tr("Hexotic_NB_LAYERS") + " = " + QString::number(data.myNbLayers) + ";";
564 valStr += tr("Hexotic_FIRST_LAYER_SIZE") + " = " + QString::number(data.myFirstLayerSize) + ";";
565 valStr += tr("Hexotic_DIRECTION") + " = " + QString::number(data.myDirection) + ";";
566 valStr += tr("Hexotic_GROWTH") + " = " + QString::number(data.myGrowth) + ";";
568 // std::cout << "Data: " << valStr.toStdString() << std::endl;
573 bool HexoticPluginGUI_HypothesisCreator::readParamsFromHypo( HexoticHypothesisData& h_data ) const
575 HexoticPlugin::HexoticPlugin_Hypothesis_var h =
576 HexoticPlugin::HexoticPlugin_Hypothesis::_narrow( initParamsHypothesis() );
578 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
579 h_data.myName = isCreation() && data ? data->Label : "";
580 h_data.myMinSize = h->GetMinSize();
581 h_data.myMaxSize = h->GetMaxSize();
582 h_data.myApproxAngle = h->GetGeomApproxAngle();
583 h_data.myHexesMinLevel = h->GetHexesMinLevel();
584 h_data.myHexesMaxLevel = h->GetHexesMaxLevel();
585 h_data.myHexoticIgnoreRidges = h->GetHexoticIgnoreRidges();
586 h_data.myHexoticInvalidElements = h->GetHexoticInvalidElements();
587 h_data.myHexoticSharpAngleThreshold = h->GetHexoticSharpAngleThreshold();
588 h_data.myHexoticNbProc = h->GetHexoticNbProc();
589 h_data.myHexoticWorkingDir = h->GetHexoticWorkingDirectory();
590 h_data.myHexoticVerbosity = h->GetHexoticVerbosity();
591 h_data.myHexoticMaxMemory = h->GetHexoticMaxMemory();
592 h_data.myHexoticSdMode = h->GetHexoticSdMode()-1;
593 h_data.myKeepFiles = h->GetKeepFiles();
594 h_data.myLogInStandardOutput = h->GetStandardOutputLog();
595 h_data.myRemoveLogOnSuccess = h->GetRemoveLogOnSuccess();
596 //h_data.myTextOptions = h->GetAdvancedOption();
598 HexoticPluginGUI_HypothesisCreator* that = (HexoticPluginGUI_HypothesisCreator*)this;
599 that->myOptions = h->GetOptionValues();
600 that->myCustomOptions = h->GetAdvancedOptionValues();
603 HexoticPlugin::HexoticPluginSizeMapsList_var sizeMaps = h->GetSizeMaps();
604 for ( CORBA::ULong i = 0 ; i < sizeMaps->length() ; i++)
606 HexoticPlugin::HexoticPluginSizeMap aSizeMap = sizeMaps[i];
607 std::string entry = CORBA::string_dup(aSizeMap.entry.in());
608 double size = aSizeMap.size;
609 h_data.mySizeMaps[ entry ] = size;
610 MESSAGE("READING Size map : entry "<<entry<<" size : "<<size)
614 h_data.myNbLayers = h->GetNbLayers();
615 h_data.myFirstLayerSize = h->GetFirstLayerSize();
616 h_data.myDirection = h->GetDirection();
617 h_data.myGrowth = h->GetGrowth();
618 SMESH::long_array_var vector = h->GetFacesWithLayers();
619 for ( CORBA::ULong i = 0; i < vector->length(); i++)
620 h_data.myFacesWithLayers.push_back(vector[i]);
621 vector = h->GetImprintedFaces();
622 for ( CORBA::ULong i = 0; i < vector->length(); i++)
623 h_data.myImprintedFaces.push_back(vector[i]);
628 bool HexoticPluginGUI_HypothesisCreator::storeParamsToHypo( const HexoticHypothesisData& h_data ) const
630 HexoticPlugin::HexoticPlugin_Hypothesis_var h =
631 HexoticPlugin::HexoticPlugin_Hypothesis::_narrow( hypothesis() );
638 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
640 h->SetMinSize( h_data.myMinSize );
641 h->SetMaxSize( h_data.myMaxSize );
642 h->SetGeomApproxAngle( h_data.myApproxAngle );
643 h->SetHexoticWorkingDirectory( h_data.myHexoticWorkingDir.toLatin1().constData() );
644 h->SetHexoticVerbosity( h_data.myHexoticVerbosity );
645 h->SetHexoticSdMode( h_data.myHexoticSdMode+1 );
646 h->SetKeepFiles( h_data.myKeepFiles );
647 h->SetStandardOutputLog( h_data.myLogInStandardOutput );
648 h->SetRemoveLogOnSuccess( h_data.myRemoveLogOnSuccess );
650 HexoticPlugin_Hypothesis::THexoticSizeMaps::const_iterator it;
652 for ( it = h_data.mySizeMaps.begin(); it != h_data.mySizeMaps.end(); it++ )
654 h->SetSizeMapEntry( it->first.c_str(), it->second );
655 MESSAGE("STORING Size map : entry "<<it->first.c_str()<<" size : "<<it->second)
657 std::vector< std::string >::const_iterator entry_it;
658 for ( entry_it = mySizeMapsToRemove.begin(); entry_it!= mySizeMapsToRemove.end(); entry_it++ )
660 h->UnsetSizeMapEntry(entry_it->c_str());
664 h->SetNbLayers( h_data.myNbLayers );
665 h->SetFirstLayerSize( h_data.myFirstLayerSize );
666 h->SetDirection( h_data.myDirection );
667 h->SetGrowth( h_data.myGrowth );
669 std::vector<int> vector = h_data.myFacesWithLayers;
670 SMESH::long_array_var aVec = new SMESH::long_array;
671 aVec->length(vector.size());
672 for ( size_t i = 0; i < vector.size(); i++)
673 aVec[i]=vector.at(i);
674 h->SetFacesWithLayers( aVec );
676 vector = h_data.myImprintedFaces;
677 aVec = new SMESH::long_array;
678 aVec->length(vector.size());
679 for ( size_t i = 0; i < vector.size(); i++)
680 aVec[i]=vector.at(i);
681 h->SetImprintedFaces( aVec );
683 catch(const SALOME::SALOME_Exception& ex)
685 SalomeApp_Tools::QtCatchCorbaException(ex);
691 bool HexoticPluginGUI_HypothesisCreator::readParamsFromWidgets( HexoticHypothesisData& h_data ) const
693 h_data.myName = myName ? myName->text() : "";
695 h_data.myMinSize = myStdWidget->myMinSize->text().isEmpty() ? 0.0 : myStdWidget->myMinSize->value();
696 h_data.myMaxSize = myStdWidget->myMaxSize->text().isEmpty() ? 0.0 : myStdWidget->myMaxSize->value();
697 h_data.myApproxAngle = myStdWidget->myGeomApproxAngle->text().isEmpty() ? 0.0 : myStdWidget->myGeomApproxAngle->value();
698 h_data.myHexoticSdMode = myStdWidget->myHexoticSdMode->currentIndex();
700 h_data.myHexoticWorkingDir = myAdvWidget->myHexoticWorkingDir->text();
701 h_data.myHexoticVerbosity = myAdvWidget->myHexoticVerbosity->value();
702 h_data.myKeepFiles = myAdvWidget->keepWorkingFilesCheck->isChecked();
703 h_data.myLogInStandardOutput = !myAdvWidget->logInFileCheck->isChecked();
704 h_data.myRemoveLogOnSuccess = myAdvWidget->removeLogOnSuccessCheck->isChecked();
707 bool ok = readSizeMapsFromWidgets( h_data );
711 h_data.myNbLayers = myVLWidget->myNbLayers->text().isEmpty() ? 0.0 : myVLWidget->myNbLayers->value();
712 h_data.myFirstLayerSize = myVLWidget->myFirstLayerSize->text().isEmpty() ? 0.0 : myVLWidget->myFirstLayerSize->value();
713 h_data.myDirection = myVLWidget->myDirection->currentIndex() == 0 ? true : false;
714 h_data.myGrowth = myVLWidget->myGrowth->text().isEmpty() ? 0.0 : myVLWidget->myGrowth->value();
715 SMESH::long_array_var ids = myVLWidget->myFacesWithLayers->GetListOfIDs();
716 for ( CORBA::ULong i = 0; i < ids->length(); i++)
717 h_data.myFacesWithLayers.push_back( ids[i] );
718 ids = myVLWidget->myImprintedFaces->GetListOfIDs();
719 for ( CORBA::ULong i = 0; i < ids->length(); i++)
720 h_data.myImprintedFaces.push_back( ids[i] );
727 bool HexoticPluginGUI_HypothesisCreator::readSizeMapsFromWidgets( HexoticHypothesisData& h_data ) const
729 int rowCount = mySmpWidget->tableWidget->rowCount();
730 for ( int row = 0; row < rowCount; row++ )
732 std::string entry = mySmpWidget->tableWidget->item( row, ENTRY_COL )->text().toStdString();
733 QVariant size_variant = mySmpWidget->tableWidget->item( row, SIZE_COL )->data(Qt::DisplayRole);
735 // Convert the size to double
737 double size = size_variant.toDouble(&ok);
742 h_data.mySizeMaps[ entry ] = size;
743 MESSAGE("READING Size map from WIDGET: entry "<<entry<<" size : "<<size)
748 GEOM::GEOM_Object_var HexoticPluginGUI_HypothesisCreator::entryToObject( std::string entry) const
750 GEOM::GEOM_Object_var aGeomObj;
751 SALOMEDS::SObject_var aSObj = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( entry.c_str() );
752 if (!aSObj->_is_nil()) {
753 CORBA::Object_var obj = aSObj->GetObject();
754 aGeomObj = GEOM::GEOM_Object::_narrow(obj);
760 QString HexoticPluginGUI_HypothesisCreator::caption() const
762 return myIs3D ? tr( "Hexotic_3D_TITLE" ) : tr( "Hexotic_3D_TITLE" ); // ??? 3D/2D ???
765 QPixmap HexoticPluginGUI_HypothesisCreator::icon() const
767 QString hypIconName = myIs3D ? tr( "ICON_DLG_Hexotic_PARAMETERS" ) : tr( "ICON_DLG_Hexotic_PARAMETERS" );
768 return SUIT_Session::session()->resourceMgr()->loadPixmap( "HexoticPLUGIN", hypIconName );
771 QString HexoticPluginGUI_HypothesisCreator::type() const
773 return myIs3D ? tr( "Hexotic_3D_HYPOTHESIS" ) : tr( "Hexotic_3D_HYPOTHESIS" ); // ??? 3D/2D ???
776 QString HexoticPluginGUI_HypothesisCreator::helpPage() const
778 return "hexotic_hypo_page.html";
781 void HexoticPluginGUI_HypothesisCreator::onTabChanged(int i)
783 myVLWidget->myFacesWithLayers->ShowPreview( i == VL_TAB );
784 myVLWidget->myImprintedFaces->ShowPreview( false );
787 void HexoticPluginGUI_HypothesisCreator::onAddOption()
789 myAdvWidget->AddOption( NULL, true );
792 void HexoticPluginGUI_HypothesisCreator::onDirBtnClicked()
794 QString dir = SUIT_FileDlg::getExistingDirectory( dlg(), myAdvWidget->myHexoticWorkingDir->text(), QString() );
795 if ( !dir.isEmpty() )
796 myAdvWidget->myHexoticWorkingDir->setText( dir );