1 // Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // file : MG_ADAPTGUI.cxx
24 #include "MG_ADAPTGUI.hxx"
26 #include "MEDFileData.hxx"
27 #include "MEDLoader.hxx"
29 #include "SUIT_Desktop.h"
30 #include "SUIT_Application.h"
31 #include "SUIT_Session.h"
33 #include "SalomeApp_Application.h"
34 #include "SalomeApp_Module.h"
35 #include "SalomeApp_Study.h"
36 #include <SUIT_MessageBox.h>
37 #include <LightApp_SelectionMgr.h>
38 #include <SUIT_OverrideCursor.h>
39 #include <SUIT_ResourceMgr.h>
40 #include <SVTK_ViewWindow.h>
41 #include <SALOME_ListIO.hxx>
42 #include <SUIT_FileDlg.h>
43 #include <QApplication>
44 #include <QButtonGroup>
45 #include <QGridLayout>
47 #include <QHBoxLayout>
52 #include <QPushButton>
53 #include <QRadioButton>
55 #include <QVBoxLayout>
56 #include <QDoubleSpinBox>
58 #include <QTreeWidget>
59 #include <QTreeWidgetItem>
60 #include <QSpacerItem>
62 #include <QHeaderView>
63 #include <QItemDelegate>
64 #include <QFileDialog>
65 #include <QMessageBox>
68 #include <vtkPoints.h>
69 #include <vtkUnstructuredGrid.h>
70 #include <vtkIdList.h>
71 #include <vtkCellArray.h>
72 #include <vtkUnsignedCharArray.h>
73 #include <vtkDataSetMapper.h>
74 #include <VTKViewer_CellLocationsArray.h>
75 #include <vtkProperty.h>
78 // SALOME KERNEL includes
79 #include <SALOMEDS_SComponent.hxx>
80 #include <SALOMEDS_SObject.hxx>
81 #include <SALOMEDS_Study.hxx>
82 #include <SALOMEDS_wrap.hxx>
83 #include "SalomeApp_Tools.h"
84 #include <SALOMEconfig.h>
86 #include <utilities.h>
88 #include <TCollection_AsciiString.hxx>
90 const int SPACING = 6; // layout spacing
91 const int MARGIN = 9; // layout margin
93 //=================================================================================
94 // function : SMESHGUI_MgAdaptDlg()
96 //=================================================================================
97 SMESHGUI_MgAdaptDlg::SMESHGUI_MgAdaptDlg( SalomeApp_Module* theModule, SMESH::MG_ADAPT_ptr myModel, QWidget* parent, bool isCreation )
98 : mySMESHGUI( theModule ), QDialog(parent)
100 //~model = new MgAdapt(*myModel);
101 model = SMESH::MG_ADAPT::_duplicate(myModel);
102 myData = model->getData();
104 if (!isCreation) readParamsFromHypo();
107 void SMESHGUI_MgAdaptDlg::buildDlg()
110 setAttribute( Qt::WA_DeleteOnClose, true );
111 setWindowTitle( tr( "ADAPT_PREF_MG_ADAPT" ) );
112 setSizeGripEnabled( true );
114 myTabWidget = new QTabWidget( this );
118 myArgs = new SMESHGUI_MgAdaptArguments( myTabWidget );
119 SMESH::str_array* str = model->getOptionValuesStrVec();
120 SMESH::str_array* str2 = model->getCustomOptionValuesStrVec();
121 std::vector<std::string> s;
122 for (int i = 0; i< str->length(); i++) s.push_back( (*str)[i].in());
123 for (int j = str->length(); j< str2->length(); j++) s.push_back((*str2)[ j - str->length() ].in() );
124 //~str.insert( str.end(), str2.begin(), str2.end() );
126 myAdvOpt = new MgAdaptAdvWidget(myTabWidget, &s);
128 int argsTab = myTabWidget->addTab( myArgs, tr( "Args" ) );
129 int advTab = myTabWidget->addTab( myAdvOpt, tr( "ADVOP" ) );
131 myAdvOpt->workingDirectoryLabel ->setText (tr( "WORKING_DIR" ));
132 myAdvOpt->workingDirectoryPushButton ->setText (tr( "SELECT_DIR" ));
133 myAdvOpt->keepWorkingFilesCheck ->setText (tr( "KEEP_WORKING_FILES" ));
134 myAdvOpt->verboseLevelLabel ->setText (tr( "VERBOSE_LEVEL" ));
135 myAdvOpt->removeLogOnSuccessCheck ->setText (tr( "REMOVE_LOG_ON_SUCCESS" ));
136 myAdvOpt->logInFileCheck ->setText (tr( "LOG_IN_FILE" ));
137 myAdvOpt->logGroupBox ->setTitle(tr( "LOG_GROUP_TITLE" ));
140 QPushButton* buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), this);
141 buttonOk->setAutoDefault(false);
142 QPushButton* buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), this);
143 buttonApply->setAutoDefault(false);
144 QPushButton* buttonCancel = new QPushButton( tr( "SMESH_BUT_CANCEL" ), this );
145 buttonCancel->setAutoDefault( false );
146 QPushButton* buttonHelp = new QPushButton( tr( "SMESH_BUT_HELP" ), this );
147 buttonHelp->setAutoDefault( false );
149 QHBoxLayout* btnLayout = new QHBoxLayout;
150 btnLayout->setSpacing( SPACING );
151 btnLayout->setMargin( 0 );
152 btnLayout->addWidget( buttonOk );
153 btnLayout->addStretch( 10 );
154 btnLayout->addWidget( buttonApply );
155 btnLayout->addStretch( 10 );
156 btnLayout->addWidget( buttonCancel );
157 btnLayout->addStretch( 10 );
158 btnLayout->addWidget( buttonHelp );
160 QVBoxLayout* l = new QVBoxLayout ( this );
161 l->setMargin( MARGIN );
162 l->setSpacing( SPACING );
163 l->addWidget( myTabWidget );
165 l->addLayout( btnLayout );
167 connect( buttonOk, SIGNAL(pressed()), this, SLOT(PushOnOK()));
168 connect( buttonApply, SIGNAL(pressed()), this, SLOT(PushOnApply()));
169 connect( buttonCancel, SIGNAL(pressed()), this, SLOT(close()));
170 connect( buttonHelp, SIGNAL(pressed()), this, SLOT(PushOnHelp()));
172 connect( myArgs, SIGNAL(meshDimSignal(ADAPTATION_MODE)), myAdvOpt, SLOT( onMeshDimChanged(ADAPTATION_MODE)) );
176 //=================================================================================
177 // function : ~SMESHGUI_MgAdaptDlg()
178 // purpose : Destroys the object and frees any allocated resources
179 //=================================================================================
180 SMESHGUI_MgAdaptDlg::~SMESHGUI_MgAdaptDlg()
185 //~void SMESHGUI_MgAdaptDlg::setModel(MgAdapt* mg)
189 SMESH::MG_ADAPT_ptr SMESHGUI_MgAdaptDlg::getModel() const
194 \brief Perform clean-up actions on the dialog box closing.
196 bool SMESHGUI_MgAdaptDlg::PushOnApply()
198 bool ret = readParamsFromWidgets();
201 void SMESHGUI_MgAdaptDlg::PushOnOK()
203 bool ret = PushOnApply();
206 void SMESHGUI_MgAdaptDlg::reject()
210 bool SMESHGUI_MgAdaptDlg::readParamsFromHypo( ) const
213 myArgs->aMedfile->setChecked(myData->fromMedFile) ;
214 if (myData->fromMedFile)
217 *(myArgs->myFileInDir) = QString(myData->myFileInDir) ;
218 myArgs->selectMedFileLineEdit->setText(QString(myData->myMeshFileIn)) ;
219 // myData->myInMeshName = // TODO
224 myArgs->aBrowserObject->setText(QString(myData->myInMeshName));
225 //~ myArgs->myFileInDir =""; // TODO
226 //~ myArgs->selectMedFileLineEdit->setText(); // TODO
228 myArgs->meshNameLineEdit->setText(QString(myData->myOutMeshName));
229 myArgs->medFileCheckBox->setChecked(myData->myMeshOutMed);
231 if(myData->myMeshOutMed)
233 *(myArgs->myFileOutDir) = QString(myData->myFileOutDir);
234 myArgs->selectOutMedFileLineEdit->setText(QString(myData->myMeshFileOut));
238 *(myArgs->myFileOutDir) = QString(""); //TODO
241 myArgs->publishOut->setChecked(myData->myPublish);
243 myArgs->localButton->setChecked(myData->myUseLocalMap);
244 myArgs->backgroundButton->setChecked(myData->myUseBackgroundMap);
245 myArgs->constantButton->setChecked(myData->myUseConstantValue);
247 if (myData->myUseConstantValue)
249 myArgs->dvalue->setValue(myData->myConstantValue);
253 myArgs->dvalue->setValue(0.0);
256 if (myData->myUseBackgroundMap)
259 *(myArgs->myFileSizeMapDir) = QString(myData->myFileSizeMapDir) ;
260 myArgs->selectMedFileBackgroundLineEdit->setText(QString(myData->myMeshFileBackground));
264 *(myArgs->myFileSizeMapDir) = QString("") ; //TODO
265 myArgs->selectMedFileBackgroundLineEdit->setText(""); //TODO
268 myArgs->fieldNameCmb->setCurrentText(QString(myData->myFieldName));
269 myArgs->noTimeStep->setChecked(myData->myUseNoTimeStep);
270 myArgs->lastTimeStep->setChecked( myData->myUseLastTimeStep);
271 myArgs->chosenTimeStep->setChecked(myData->myUseChosenTimeStep);
272 if (myData->myUseChosenTimeStep)
274 myArgs->rankSpinBox->setValue(myData->myRank);
275 myArgs->timeStep->setValue(myData->myTimeStep);
278 myAdvOpt->workingDirectoryLineEdit->setText(QString(myData->myWorkingDir));
279 myAdvOpt->logInFileCheck->setChecked(myData->myPrintLogInFile);
281 myAdvOpt->verboseLevelSpin->setValue(myData->myVerboseLevel);
282 myAdvOpt->removeLogOnSuccessCheck->setChecked(myData->myRemoveLogOnSuccess);
283 myAdvOpt->keepWorkingFilesCheck->setChecked(myData->myKeepFiles);
289 bool SMESHGUI_MgAdaptDlg::readParamsFromWidgets()
291 MESSAGE ("readParamsFromWidgets") ;
293 SMESH::MgAdaptHypothesisData* aData = new SMESH::MgAdaptHypothesisData();
296 // 1. Fichier du maillage de départ
297 aData->fromMedFile = myArgs->aMedfile->isChecked();
298 if (aData->fromMedFile)
300 aData->myFileInDir = CORBA::string_dup(myArgs->myFileInDir->toStdString().c_str());
301 aData->myMeshFileIn = CORBA::string_dup(myArgs->selectMedFileLineEdit->text().toStdString().c_str());
302 // aData->myInMeshName = // TODO
306 QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
307 QObject::tr("MG_ADAPT_MED_FILE_4") );
310 // aData->myInMeshName = CORBA::string_dup(myArgs->aBrowserObject->text().toStdString().c_str());
311 // aData->myFileInDir = CORBA::string_dup(myAdvOpt->workingDirectoryLineEdit->text().toStdString().c_str());
313 // TCollection_AsciiString aGenericName = (char*)aData->myFileInDir;
314 // TCollection_AsciiString aGenericName2 = "MgAdapt_";
315 // aGenericName2 += getpid();
316 // aGenericName2 += "_";
317 // aGenericName2 += Abs((Standard_Integer)(long) aGenericName.ToCString());
318 // aGenericName2 += ".med";
319 // aGenericName+=aGenericName2;
320 // emit myArgs->toExportMED(aGenericName.ToCString());
321 // aData->myMeshFileIn = aGenericName2.ToCString();
323 // 2. Fichier du maillage de sortie
324 aData->myOutMeshName = CORBA::string_dup(myArgs->meshNameLineEdit->text().toStdString().c_str());
325 aData->myMeshOutMed = myArgs->medFileCheckBox->isChecked();
326 if(aData->myMeshOutMed)
328 aData->myFileOutDir = CORBA::string_dup(myArgs->myFileOutDir->toStdString().c_str());
329 aData->myMeshFileOut = CORBA::string_dup(myArgs->selectOutMedFileLineEdit->text().toStdString().c_str());
333 aData->myMeshFileOut = "";
335 aData->myPublish = myArgs->publishOut->isChecked();
337 // 3. Type de carte de tailles
338 aData->myUseLocalMap = myArgs->localButton->isChecked();
339 aData->myUseBackgroundMap = myArgs->backgroundButton->isChecked();
340 aData->myUseConstantValue = myArgs->constantButton->isChecked();
342 if (aData->myUseConstantValue)
344 aData->myConstantValue = myArgs->dvalue->value();
348 aData->myConstantValue = 0.0;
350 // 3.2. Arrière-plan
351 if (aData->myUseBackgroundMap)
353 aData->myFileSizeMapDir = CORBA::string_dup(myArgs->myFileSizeMapDir->toStdString().c_str());
354 aData->myMeshFileBackground = CORBA::string_dup(myArgs->selectMedFileBackgroundLineEdit->text().toStdString().c_str());
358 aData->myMeshFileBackground = "";
362 if ( ! aData->myUseConstantValue )
364 if ( strlen(myArgs->fieldNameCmb->currentText().toStdString().c_str()) == 0 )
366 QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
367 QObject::tr("MG_ADAPT_MED_FILE_5") );
372 aData->myFieldName = CORBA::string_dup(myArgs->fieldNameCmb->currentText().toStdString().c_str());
373 aData->myUseNoTimeStep = myArgs->noTimeStep->isChecked();
374 aData->myUseLastTimeStep = myArgs->lastTimeStep->isChecked();
375 aData->myUseChosenTimeStep = myArgs->chosenTimeStep->isChecked();
376 if (aData->myUseChosenTimeStep)
378 aData->myRank = myArgs->rankSpinBox->value();
379 aData->myTimeStep = myArgs->timeStep->value();
384 // 5. Options avancées
385 aData->myWorkingDir = CORBA::string_dup(myAdvOpt->workingDirectoryLineEdit->text().toStdString().c_str());
386 aData->myPrintLogInFile = myAdvOpt->logInFileCheck->isChecked();
387 aData->myVerboseLevel = myAdvOpt->verboseLevelSpin->value();
388 aData->myRemoveLogOnSuccess = myAdvOpt->removeLogOnSuccessCheck->isChecked();
389 aData->myKeepFiles = myAdvOpt->keepWorkingFilesCheck->isChecked();
390 model->setData(*aData);
401 bool SMESHGUI_MgAdaptDlg::storeParamsToHypo( const SMESH::MgAdaptHypothesisData& ) const
405 \brief Show help page
407 void SMESHGUI_MgAdaptDlg::PushOnHelp()
409 // QString aHelpFile;
410 // if ( myTabWidget->currentIndex() == MinDistance ) {
411 // aHelpFile = "measurements.html#min-distance-anchor";
412 // } else if ( myTabWidget->currentIndex() == BoundingBox ) {
413 // aHelpFile = "measurements.html#bounding-box-anchor";
414 // } else if ( myTabWidget->currentWidget() == myAngle ) {
415 // aHelpFile = "measurements.html#angle-anchor";
417 // aHelpFile = "measurements.html#basic-properties-anchor";
420 // SMESH::ShowHelpFile( aHelpFile );
422 bool SMESHGUI_MgAdaptDlg::checkParams(QString& msg)
424 if ( !QFileInfo( myAdvOpt->workingDirectoryLineEdit->text().trimmed() ).isWritable() )
426 SUIT_MessageBox::warning( this,
427 tr( "SMESH_WRN_WARNING" ),
428 tr( "NO_PERMISSION" ) );
433 myAdvOpt->myOptionTable->setFocus();
434 QApplication::instance()->processEvents();
437 bool isDefault, ok = true;
438 int iRow = 0, nbRows = myAdvOpt->myOptionTable->topLevelItemCount();
439 for ( ; iRow < nbRows; ++iRow )
441 QTreeWidgetItem* row = myAdvOpt->myOptionTable->topLevelItem( iRow );
442 myAdvOpt->GetOptionAndValue( row, name, value, isDefault );
444 if ( name.simplified().isEmpty() )
445 continue; // invalid custom option
447 if ( isDefault ) // not selected option
452 model->setOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
454 catch ( const SALOME::SALOME_Exception& ex )
456 msg = ex.details.text.in();
465 //=================================================================================
466 // function : SMESHGUI_MgAdaptArguments()
468 //=================================================================================
469 SMESHGUI_MgAdaptArguments::SMESHGUI_MgAdaptArguments( QWidget* parent )
473 myFileInDir = new QString("");
474 myFileOutDir = new QString("");
475 myFileSizeMapDir = new QString("");
476 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
478 *myFileInDir = QDir::currentPath();
479 *myFileOutDir = QDir::currentPath();
480 *myFileSizeMapDir = QDir::currentPath();
484 *myFileInDir = SUIT_FileDlg::getLastVisitedPath();
485 *myFileOutDir = SUIT_FileDlg::getLastVisitedPath();
486 *myFileSizeMapDir = SUIT_FileDlg::getLastVisitedPath();
491 aMeshIn = new QGroupBox( tr( "MeshIn" ), this );
492 aMedfile = new QRadioButton( tr( "MEDFile" ), aMeshIn );
493 aBrowser = new QRadioButton( tr( "Browser" ), aMeshIn );
494 aBrowserObject = new QLineEdit( aMeshIn );
495 selectMedFilebutton = new QPushButton("", aMeshIn);
496 selectMedFileLineEdit = new QLineEdit( aMeshIn );
498 meshIn = new QGridLayout( aMeshIn );
500 meshIn->setMargin( MARGIN );
501 meshIn->setSpacing( SPACING );
502 meshIn->addWidget( aMedfile, 0, 0, 1,1 );
503 meshIn->addWidget( aBrowser, 0, 1,1,1);
504 meshIn->addWidget( aBrowserObject, 0, 2, 1, 1 );
505 meshIn->addWidget( selectMedFilebutton, 1, 0,1, 1);
506 meshIn->addWidget( selectMedFileLineEdit, 1, 1, 1, 1 );
507 hspacer = new QSpacerItem(188, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
509 meshInGroup = new QButtonGroup( this );
510 meshInGroup->addButton( aMedfile, 0 );
511 meshInGroup->addButton( aBrowser, 1 );
515 aMeshOut = new QGroupBox( tr( "MeshOut" ), this );
516 meshName = new QLabel(tr("MeshName"), aMeshOut);
517 secondHspacer = new QSpacerItem(100, 30);
518 meshNameLineEdit = new QLineEdit(aMeshOut) ;
519 medFileCheckBox = new QCheckBox(tr("MEDFile"), aMeshOut);
520 selectOutMedFilebutton = new QPushButton("", aMeshOut);
521 thirdHspacer = new QSpacerItem(188, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
522 selectOutMedFileLineEdit = new QLineEdit(aMeshOut) ;
523 publishOut = new QCheckBox(tr("Publish_MG_ADAPT"), aMeshOut);
525 meshOut = new QGridLayout( aMeshOut );
527 meshOut->setMargin( MARGIN );
528 meshOut->setSpacing( SPACING );
529 meshOut->addWidget( meshName, 0, 0, 1,1 );
530 meshOut->addItem( secondHspacer, 0, 1, 1, 1 );
531 meshOut->addWidget( meshNameLineEdit, 0, 2,1,1);
532 meshOut->addWidget( medFileCheckBox, 1, 0,1,1 );
533 meshOut->addWidget( selectOutMedFilebutton, 1, 1,1,1 );
534 meshOut->addWidget( selectOutMedFileLineEdit, 1, 2,1,1);
535 meshOut->addWidget( publishOut, 2, 0,1,1 );
537 //size map definition
539 sizeMapDefinition = new QGroupBox(tr("SIZE_MAP_DEF"), this);
540 localButton = new QRadioButton(tr("LOCAL_MG_ADAPT"), sizeMapDefinition);
541 backgroundButton = new QRadioButton(tr("BACKGRND_MG_ADAPT"), sizeMapDefinition);
542 constantButton = new QRadioButton(tr("CNST_MG_ADAPT"), sizeMapDefinition);
543 medFileBackground = new QLabel(tr("MED_FILE_BCKG"), sizeMapDefinition);
544 selectMedFileBackgroundbutton = new QPushButton(tr(""), sizeMapDefinition);
545 selectMedFileBackgroundLineEdit = new QLineEdit(sizeMapDefinition);
546 valueLabel = new QLabel(tr("VALUE_MG_ADAPT"), sizeMapDefinition);
547 dvalue = new QDoubleSpinBox(sizeMapDefinition);
548 sizeMapDefGroup = new QButtonGroup( this );
549 sizeMapDefGroup->addButton( localButton, 0 );
550 sizeMapDefGroup->addButton( backgroundButton, 1 );
551 sizeMapDefGroup->addButton( constantButton, 2 );
553 sizeMapDefGroupLayout = new QGridLayout(sizeMapDefinition);
554 sizeMapDefGroupLayout->addWidget(localButton, 0,0);
555 sizeMapDefGroupLayout->addWidget(backgroundButton, 0,1);
556 sizeMapDefGroupLayout->addWidget(constantButton, 0,2);
557 sizeMapDefGroupLayout->addWidget(medFileBackground, 1,0);
558 sizeMapDefGroupLayout->addWidget(selectMedFileBackgroundbutton, 1,1);
559 sizeMapDefGroupLayout->addWidget(selectMedFileBackgroundLineEdit, 1,2);
560 sizeMapDefGroupLayout->addWidget(valueLabel, 2,0);
561 sizeMapDefGroupLayout->addWidget(dvalue, 2,1);
564 sizeMapField = new QGroupBox(tr("SIZE_MAP_FIELD"), this);
565 fieldName = new QLabel(tr("MG_ADAPT_FIELD_NAME"), sizeMapField);
566 fieldNameCmb = new QComboBox(sizeMapField);
567 noTimeStep = new QRadioButton(tr("MG_ADAPT_NO_T_ST"), sizeMapField);
568 lastTimeStep = new QRadioButton(tr("MG_ADAPT_L_ST"), sizeMapField);
569 chosenTimeStep = new QRadioButton(tr("MG_ADAPT_CH_ST"), sizeMapField);
570 timeStepLabel = new QLabel(tr("MG_ADAPT_TSTP"), sizeMapField);
571 timeStep = new QSpinBox(sizeMapField);
572 timeStep->setMinimum(-1);
573 rankLabel = new QLabel(tr("MG_ADAPT_RANK"), sizeMapField);
574 rankSpinBox = new QSpinBox(sizeMapField);
575 rankSpinBox->setMinimum(-1);
577 timeStepGroup = new QButtonGroup(this);
578 timeStepGroup->addButton(noTimeStep, 0);
579 timeStepGroup->addButton(lastTimeStep, 1);
580 timeStepGroup->addButton(chosenTimeStep, 2);
582 sizeMapFieldGroupLayout = new QGridLayout(sizeMapField);
584 sizeMapFieldGroupLayout->addWidget(fieldName, 0,0);
585 sizeMapFieldGroupLayout->addWidget(fieldNameCmb, 0,1);
586 sizeMapFieldGroupLayout->addWidget(noTimeStep, 1,0);
587 sizeMapFieldGroupLayout->addWidget(lastTimeStep, 1,1);
588 sizeMapFieldGroupLayout->addWidget(chosenTimeStep, 1,2);
589 sizeMapFieldGroupLayout->addWidget(timeStepLabel, 2,0);
590 sizeMapFieldGroupLayout->addWidget(timeStep, 2,1);
591 sizeMapFieldGroupLayout->addWidget(rankLabel, 2,2);
592 sizeMapFieldGroupLayout->addWidget(rankSpinBox, 2,3);
594 QGridLayout* argumentsLayout = new QGridLayout( this );
595 argumentsLayout->setMargin( MARGIN );
596 argumentsLayout->setSpacing( SPACING );
598 argumentsLayout->addWidget( aMeshIn, 0, 0, 1, 3 );
599 argumentsLayout->addWidget( aMeshOut, 1, 0, 1, 3 );
600 argumentsLayout->addWidget( sizeMapDefinition, 2, 0, 1, 3 );
601 argumentsLayout->addWidget( sizeMapField, 3, 0, 1, 3 );
602 argumentsLayout->setColumnStretch( 1, 5 );
603 argumentsLayout->setRowStretch( 4, 5 );
606 setMode( Mesh, Local);
607 medFileCheckBox->setChecked(true);
608 visibleTimeStepRankLabel (false);
611 connect( meshInGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( modeChanged( int ) ) );
612 connect( sizeMapDefGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( sizeMapDefChanged( int ) ) );
613 connect( selectMedFilebutton, SIGNAL( pressed( ) ), this, SLOT( onSelectMedFilebuttonClicked( ) ) );
614 connect( medFileCheckBox, SIGNAL (stateChanged(int)), this, SLOT(onMedFileCheckBox(int) ) );
615 connect( publishOut, SIGNAL (stateChanged(int)), this, SLOT(onPublishOut(int) ) );
616 connect( selectOutMedFilebutton, SIGNAL( pressed()), this, SLOT(onSelectOutMedFilebutton()));
617 connect( selectMedFileBackgroundbutton, SIGNAL(pressed()), this, SLOT(onSelectMedFileBackgroundbutton()) );
618 connect( timeStepGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( timeStepGroupChanged( int ) ) );
619 emit updateSelection();
622 //=================================================================================
623 // function : ~SMESHGUI_MgAdaptArguments()
624 // purpose : Destroys the object and frees any allocated resources
625 //=================================================================================
626 SMESHGUI_MgAdaptArguments::~SMESHGUI_MgAdaptArguments()
630 void SMESHGUI_MgAdaptArguments::onNoTimeStep(bool disableOther)
632 noTimeStep->setChecked(true);
634 visibleTimeStepRankLabel (false);
635 rankSpinBox->setValue(-2);
636 timeStep->setValue(-2);
638 lastTimeStep->setDisabled(disableOther);
639 chosenTimeStep->setDisabled(disableOther);
641 void SMESHGUI_MgAdaptArguments::onLastTimeStep(bool disableOther)
643 lastTimeStep->setChecked(true);
645 visibleTimeStepRankLabel (false);
646 rankSpinBox->setValue(-1);
647 timeStep->setValue(-1);
648 noTimeStep->setDisabled(disableOther);
650 void SMESHGUI_MgAdaptArguments::onChosenTimeStep(bool disableOther, int vmax)
652 chosenTimeStep->setChecked(true);
654 visibleTimeStepRankLabel (true);
655 rankSpinBox->setValue(-1);
656 timeStep->setValue(-1);
657 if (vmax) timeStep->setMaximum(vmax);
660 void SMESHGUI_MgAdaptArguments::visibleTimeStepRankLabel(bool visible)
662 rankLabel->setVisible(visible);
663 rankSpinBox->setVisible(visible);
665 timeStepLabel->setVisible(visible);
666 timeStep->setVisible(visible);
669 void SMESHGUI_MgAdaptArguments::onSelectOutMedFilebutton()
672 QString filtre = QString("Med") ;
673 filtre += QString(" files (*.") + QString("med") + QString(");;");
674 QString fileName = QFileDialog::getSaveFileName(this, tr("SAVE_MED"), QString(""), filtre);
675 QFileInfo myFileInfo(fileName);
676 selectOutMedFileLineEdit->setText(myFileInfo.fileName());
677 *myFileOutDir = myFileInfo.path();
680 void SMESHGUI_MgAdaptArguments::onSelectMedFileBackgroundbutton()
682 QString fileName0 = selectMedFileBackgroundbutton->text().trimmed();
684 QString fileName = getMedFileName(false);
685 if (fileName != QString::null)
687 myFieldList = GetListeChamps(fileName);
688 if (myFieldList.empty())
690 fileName = fileName0;
691 fieldNameCmb->clear();
695 // fill field name Combobox
696 fieldNameCmb->clear();
697 std::map<QString, int>::const_iterator it;
698 for ( it=myFieldList.begin() ; it != myFieldList.end(); it++)
700 fieldNameCmb->insertItem(0,QString(it->first));
701 int typeStepInField = it->second > 2 ? 2 : it->second ;
702 timeStepGroupChanged(typeStepInField, false);
708 fileName = fileName0;
709 fieldNameCmb->clear();
712 QFileInfo myFileInfo(fileName);
713 *myFileSizeMapDir = myFileInfo.path();
714 selectMedFileBackgroundLineEdit->setText(myFileInfo.fileName());
717 void SMESHGUI_MgAdaptArguments::onMedFileCheckBox(int state)
719 if (state == Qt::Checked)
721 selectOutMedFilebutton->show();
722 selectOutMedFileLineEdit->show();
723 selectOutMedFilebutton->setEnabled(true);
724 selectOutMedFileLineEdit->setEnabled(true);
728 selectOutMedFilebutton->setEnabled(false);
729 selectOutMedFileLineEdit->setEnabled(false);
730 publishOut->setChecked(true);
733 void SMESHGUI_MgAdaptArguments::onPublishOut(int state)
735 if (state == Qt::Unchecked)
737 medFileCheckBox->setChecked(true);
741 void SMESHGUI_MgAdaptArguments::onSelectMedFilebuttonClicked()
743 // bool keep = false;
744 QString fileName0 = selectMedFileLineEdit->text().trimmed();
746 QString fileName = getMedFileName(false);
747 if(fileName != QString::null)
749 QString aMeshName = lireNomMaillage(fileName.trimmed(), meshDim);
750 if (aMeshName == QString::null )
752 QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
753 QObject::tr("MG_ADAPT_MED_FILE_2") );
754 fileName = fileName0;
758 meshNameLineEdit->setText(aMeshName);
759 ADAPTATION_MODE aMode = meshDim == 3 ? ADAPTATION_MODE::BOTH : ADAPTATION_MODE::SURFACE; // and when dimesh 3 without 2D mesh?
760 emit meshDimSignal(aMode);
768 QFileInfo myFileInfo(fileName);
769 *myFileInDir = myFileInfo.path();
770 *myFileOutDir = myFileInfo.path();
771 selectMedFileLineEdit->setText(myFileInfo.fileName());
772 QString outF = fileName == QString::null ? myFileInfo.fileName() :
773 QString( remove_extension(myFileInfo.fileName().toStdString() ).c_str() )+ QString(".adapt.med");
774 selectOutMedFileLineEdit->setText(outF);
775 onLocalSelected(myFileInfo.filePath());
779 void SMESHGUI_MgAdaptArguments::onLocalSelected(QString filePath)
781 myFieldList = GetListeChamps(filePath, false);
782 if (myFieldList.empty())
784 if (localButton->isChecked())
786 fieldNameCmb->clear();
791 // fill field name Combobox
792 fieldNameCmb->clear();
793 std::map<QString, int>::const_iterator it;
794 for ( it = myFieldList.begin() ; it != myFieldList.end(); it++)
796 fieldNameCmb->insertItem(0,QString(it->first));
797 // Je ne comprends pas le rapport entre pas de temps et apparition d'un nouveau champ... GN
798 int typeStepInField = it->second > 2 ? 2 : it->second ;
799 // std::cout << "SMESHGUI_MgAdaptArguments::onLocalSelected typeStepInField : " << typeStepInField << std::endl;
800 timeStepGroupChanged(typeStepInField, false);
804 // =======================================================================
805 // Gestion les boutons qui permettent de
806 // 1) retourne le nom d'un fichier par une fenetre de dialogue si aucun
807 // objet est selectionne dans l arbre d etude
808 // 2) retourne le nom du fichier asocie a l objet
809 // selectionne dans l arbre d etude
810 // =======================================================================
811 QString SMESHGUI_MgAdaptArguments::getMedFileName(bool avertir)
814 QString aFile = QString::null;
815 QString filtre = QString("Med") ;
816 filtre += QString(" files (*.") + QString("med") + QString(");;");
817 aFile = SUIT_FileDlg::getOpenFileName(0, QObject::tr("MG_ADAPT_SELECT_FILE_0"), QString(""), filtre );
822 void SMESHGUI_MgAdaptArguments::setMode(const Mode theMode, const SIZEMAP theSizeMap )
824 QRadioButton* aButton = qobject_cast<QRadioButton*>( meshInGroup->button( theMode ) );
825 QRadioButton* bButton = qobject_cast<QRadioButton*>( sizeMapDefGroup->button( theSizeMap ) );
828 aButton->setChecked( true );
829 modeChanged( theMode );
833 bButton->setChecked( true );
834 sizeMapDefChanged( theSizeMap );
838 void SMESHGUI_MgAdaptArguments::modeChanged( int theMode )
843 aBrowserObject->hide();
844 selectMedFileLineEdit->show();
845 selectMedFilebutton->show();
846 localButton->setEnabled(true);
850 selectMedFileLineEdit->hide();
851 selectMedFilebutton->hide();
852 localButton->setEnabled(false);
853 aBrowserObject->show();
854 sizeMapDefChanged(Background);
855 emit updateSelection();
859 void SMESHGUI_MgAdaptArguments::sizeMapDefChanged( int theSizeMap )
861 fieldNameCmb->clear();
862 if(theSizeMap == Local)
864 localButton->setEnabled(true);
865 localButton->setChecked(true);
866 medFileBackground->hide();
867 selectMedFileBackgroundbutton->hide();
868 selectMedFileBackgroundLineEdit->hide();
869 selectMedFileBackgroundLineEdit->clear();
873 sizeMapField->setEnabled(true);
874 if (!selectMedFileLineEdit->text().isEmpty())
876 QFileInfo myFileInfo(QDir(*myFileInDir), selectMedFileLineEdit->text());
877 onLocalSelected(myFileInfo.filePath());
880 else if (theSizeMap == Background)
882 medFileBackground->show();
883 backgroundButton->setChecked(true);
884 selectMedFileBackgroundbutton->show();
885 selectMedFileBackgroundLineEdit->show();
888 sizeMapField->setEnabled(true);
893 medFileBackground->hide();
894 constantButton->setChecked(true);
895 selectMedFileBackgroundbutton->hide();
896 selectMedFileBackgroundLineEdit->clear();
897 selectMedFileBackgroundLineEdit->hide();
900 sizeMapField->setEnabled(false);
903 void SMESHGUI_MgAdaptArguments::timeStepGroupChanged(int timeStepType, bool disableOther, int vmax)
905 switch (timeStepType)
908 onNoTimeStep(disableOther);
911 onLastTimeStep(disableOther);
914 onChosenTimeStep(disableOther, vmax);
920 void SMESHGUI_MgAdaptArguments::clear()
922 selectMedFileLineEdit->clear();
923 aBrowserObject->clear();
925 meshNameLineEdit->clear();
926 selectOutMedFileLineEdit->clear();
928 med_int SMESHGUI_MgAdaptArguments::getMeshDim() const
932 QWidget* ItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &o, const QModelIndex &index) const
934 bool editable = index.data( EDITABLE_ROLE ).toInt();
935 return editable ? QItemDelegate::createEditor( parent, o, index ) : 0;
938 //////////////////////////////////////////
940 //////////////////////////////////////////
942 MgAdaptAdvWidget::MgAdaptAdvWidget( QWidget* parent, std::vector <std::string>* options, Qt::WindowFlags f )
943 : QWidget( parent, f ), myOptions(options)
946 myOptionTable->header()->setSectionResizeMode( QHeaderView::ResizeToContents );
947 myOptionTable->setItemDelegate( new ItemDelegate( myOptionTable ) );
949 for ( int i = 0, nb = myOptions->size(); i < nb; ++i )
951 AddOption( (*myOptions)[i].c_str() );
954 connect( myOptionTable, SIGNAL( itemChanged(QTreeWidgetItem *, int)), SLOT( itemChanged(QTreeWidgetItem *, int )));
955 connect( addBtn, SIGNAL(clicked()), this, SLOT( onAddOption() ) );
956 connect(workingDirectoryPushButton, SIGNAL(pressed()), this, SLOT(_onWorkingDirectoryPushButton()));
959 MgAdaptAdvWidget::~MgAdaptAdvWidget()
963 void MgAdaptAdvWidget::AddOption( const char* option, bool isCustom )
966 bool isDefault = false;
969 QStringList name_value_type = QString(option).split( ":", QString::KeepEmptyParts );
970 if ( name_value_type.size() > 0 )
971 name = name_value_type[0];
972 if ( name_value_type.size() > 1 )
973 value = name_value_type[1];
974 if ( name_value_type.size() > 2 )
975 isDefault = !name_value_type[2].toInt();
977 QTreeWidget* table = myOptionTable;
978 //table->setExpanded( true );
980 QTreeWidgetItem* row;
981 if (optionTreeWidgetItem.size())
983 std::map<QString, QTreeWidgetItem *>::iterator it = optionTreeWidgetItem.find(name);
984 if(it != optionTreeWidgetItem.end()) return; // option exist
987 row = getNewQTreeWidgetItem(table, option, name, isCustom);
992 row = getNewQTreeWidgetItem(table, option, name, isCustom);
994 row->setText( 0, tr( name.toLatin1().constData() ));
995 row->setText( 1, tr( value.toLatin1().constData() ));
996 row->setCheckState( 0, isDefault ? Qt::Unchecked : Qt::Checked);
997 row->setData( NAME_COL, PARAM_NAME, name );
1001 myOptionTable->scrollToItem( row );
1002 myOptionTable->setCurrentItem( row );
1003 myOptionTable->editItem( row, NAME_COL );
1007 QTreeWidgetItem* MgAdaptAdvWidget::getNewQTreeWidgetItem(QTreeWidget* table, const char* option, QString& name, bool isCustom)
1009 QTreeWidgetItem* row = new QTreeWidgetItem( table );
1010 row->setData( NAME_COL, EDITABLE_ROLE, int( isCustom && !option ));
1011 row->setFlags( row->flags() | Qt::ItemIsEditable );
1012 optionTreeWidgetItem.insert(std::pair <QString, QTreeWidgetItem*> (name, row));
1017 void MgAdaptAdvWidget::onAddOption()
1019 AddOption( NULL, true );
1021 void MgAdaptAdvWidget::GetOptionAndValue( QTreeWidgetItem * tblRow,
1026 option = tblRow->data( NAME_COL, PARAM_NAME ).toString();
1027 value = tblRow->text( VALUE_COL );
1028 isDefault = ! tblRow->checkState( NAME_COL );
1032 void MgAdaptAdvWidget::itemChanged(QTreeWidgetItem* tblRow, int column)
1036 myOptionTable->blockSignals( true );
1038 tblRow->setData( VALUE_COL, EDITABLE_ROLE, int( tblRow->checkState( NAME_COL )));
1040 int c = tblRow->checkState( NAME_COL ) ? 0 : 150;
1041 tblRow->setForeground( VALUE_COL, QBrush( QColor( c, c, c )));
1043 if ( column == NAME_COL && tblRow->data( NAME_COL, EDITABLE_ROLE ).toInt() ) // custom table
1045 tblRow->setData( NAME_COL, PARAM_NAME, tblRow->text( NAME_COL ));
1048 myOptionTable->blockSignals( false );
1051 void MgAdaptAdvWidget::setupWidget()
1053 if (this->objectName().isEmpty())
1054 this->setObjectName(QString(tr("MG-ADAPT-ADV")));
1055 this->resize(337, 369);
1056 gridLayout_4 = new QGridLayout(this);
1057 gridLayout_4->setObjectName(QString("gridLayout_4"));
1058 myOptionTable = new MgAdaptAdvWidgetTreeWidget(this);
1060 font.setBold(false);
1062 QTreeWidgetItem *__qtreewidgetitem = new QTreeWidgetItem();
1063 __qtreewidgetitem->setFont(1, font);
1064 __qtreewidgetitem->setFont(0, font);
1065 __qtreewidgetitem->setText(1, tr("OPTION_VALUE_COLUMN"));
1066 __qtreewidgetitem->setText(0, tr("OPTION_NAME_COLUMN"));
1067 myOptionTable->setHeaderItem(__qtreewidgetitem);
1068 myOptionTable->setObjectName(QString("myOptionTable"));
1069 myOptionTable->setEditTriggers(QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed);
1070 myOptionTable->setTabKeyNavigation(true);
1072 gridLayout_4->addWidget(myOptionTable, 0, 0, 1, 2);
1074 addBtn = new QPushButton(this);
1075 addBtn->setObjectName(QString("addBtn"));
1077 gridLayout_4->addWidget(addBtn, 1, 0, 1, 1);
1079 horizontalSpacer = new QSpacerItem(188, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
1081 gridLayout_4->addItem(horizontalSpacer, 1, 1, 1, 1);
1083 logGroupBox = new QGroupBox(this);
1084 logGroupBox->setObjectName(QString("logGroupBox"));
1085 gridLayout_2 = new QGridLayout(logGroupBox);
1086 gridLayout_2->setObjectName(QString("gridLayout_2"));
1087 gridLayout = new QGridLayout();
1088 gridLayout->setObjectName(QString("gridLayout"));
1089 workingDirectoryLabel = new QLabel(logGroupBox);
1090 workingDirectoryLabel->setObjectName(QString("workingDirectoryLabel"));
1092 gridLayout->addWidget(workingDirectoryLabel, 0, 0, 1, 1);
1094 workingDirectoryLineEdit = new QLineEdit(logGroupBox);
1095 workingDirectoryLineEdit->setObjectName(QString("workingDirectoryLineEdit"));
1097 gridLayout->addWidget(workingDirectoryLineEdit, 0, 1, 1, 1);
1099 workingDirectoryPushButton = new QPushButton(logGroupBox);
1100 workingDirectoryPushButton->setObjectName(QString("workingDirectoryPushButton"));
1102 gridLayout->addWidget(workingDirectoryPushButton, 0, 2, 1, 1);
1104 verboseLevelLabel = new QLabel(logGroupBox);
1105 verboseLevelLabel->setObjectName(QString("verboseLevelLabel"));
1107 gridLayout->addWidget(verboseLevelLabel, 1, 0, 1, 1);
1109 verboseLevelSpin = new QSpinBox(logGroupBox);
1110 verboseLevelSpin->setObjectName(QString("verboseLevelSpin"));
1112 gridLayout->addWidget(verboseLevelSpin, 1, 1, 1, 1);
1115 gridLayout_2->addLayout(gridLayout, 0, 0, 1, 1);
1117 horizontalLayout = new QHBoxLayout();
1118 horizontalLayout->setObjectName(QString("horizontalLayout"));
1119 logInFileCheck = new QCheckBox(logGroupBox);
1120 logInFileCheck->setObjectName(QString("logInFileCheck"));
1121 logInFileCheck->setChecked(true);
1123 horizontalLayout->addWidget(logInFileCheck);
1125 removeLogOnSuccessCheck = new QCheckBox(logGroupBox);
1126 removeLogOnSuccessCheck->setObjectName(QString("removeLogOnSuccessCheck"));
1127 removeLogOnSuccessCheck->setChecked(true);
1129 horizontalLayout->addWidget(removeLogOnSuccessCheck);
1132 gridLayout_2->addLayout(horizontalLayout, 1, 0, 1, 1);
1134 keepWorkingFilesCheck = new QCheckBox(logGroupBox);
1135 keepWorkingFilesCheck->setObjectName(QString("keepWorkingFilesCheck"));
1136 keepWorkingFilesCheck->setAutoExclusive(false);
1138 gridLayout_2->addWidget(keepWorkingFilesCheck, 2, 0, 1, 1);
1141 gridLayout_4->addWidget(logGroupBox, 3, 0, 1, 2);
1144 void MgAdaptAdvWidget::_onWorkingDirectoryPushButton()
1146 QString aDirName=QFileDialog::getExistingDirectory ();
1147 if (!(aDirName.isEmpty()))workingDirectoryLineEdit->setText(aDirName);
1149 void MgAdaptAdvWidget::onMeshDimChanged(ADAPTATION_MODE aMode)
1151 /* default adaptation mode
1152 * assume that if meshDim == 2 -->adaptation surface
1153 * if meshDim == 3 and if there is not 2D mesh -->VOLUME
1157 QString adaptation("adaptation"), value;
1160 case ADAPTATION_MODE::SURFACE:
1163 setOptionValue(adaptation, value);
1166 case ADAPTATION_MODE::BOTH :
1169 setOptionValue(adaptation, value);
1172 case ADAPTATION_MODE::VOLUME :
1175 setOptionValue(adaptation, value);
1180 void MgAdaptAdvWidget::setOptionValue(QString& option, QString& value)
1182 std::map<QString, QTreeWidgetItem *>::iterator it = optionTreeWidgetItem.find(option);
1183 if (it != optionTreeWidgetItem.end())
1185 it->second->setText( 0, tr( option.toLatin1().constData() ));
1186 it->second->setText( 1, tr( value.toLatin1().constData() ));
1187 it->second->setCheckState( 0, Qt::Checked );
1188 it->second->setData( NAME_COL, PARAM_NAME, option );
1189 myOptionTable->editItem( it->second, NAME_COL );
1194 bool isEditable( const QModelIndex& index )
1196 return index.isValid() &&
1197 index.flags() & Qt::ItemIsEditable &&
1198 index.flags() & Qt::ItemIsEnabled &&
1199 ( !index.data( Qt::UserRole + 1 ).isValid() || index.data( Qt::UserRole + 1 ).toInt() != 0 );
1203 MgAdaptAdvWidgetTreeWidget::MgAdaptAdvWidgetTreeWidget( QWidget* parent )
1204 : QTreeWidget( parent )
1208 QModelIndex MgAdaptAdvWidgetTreeWidget::moveCursor( CursorAction action, Qt::KeyboardModifiers modifiers )
1210 QModelIndex current = currentIndex();
1211 int column = current.column();
1212 if ( action == MoveNext )
1214 if ( column < columnCount()-1 )
1216 QModelIndex next = current.sibling( current.row(), column+1 );
1217 if ( isEditable( next ) ) return next;
1221 QModelIndex next = current.sibling( current.row()+1, 0 );
1222 if ( isEditable( next ) ) return next;
1225 else if ( action == MovePrevious )
1227 if ( column == 0 ) {
1228 QModelIndex next = current.sibling( current.row()-1, columnCount()-1 );
1229 if ( isEditable( next ) ) return next;
1232 QModelIndex next = current.sibling( current.row(), column-1 );
1233 if ( isEditable( next ) ) return next;
1236 return QTreeWidget::moveCursor( action, modifiers );
1239 void MgAdaptAdvWidgetTreeWidget::keyPressEvent( QKeyEvent* e )
1245 QModelIndex index = currentIndex();
1246 if ( !isEditable( index ) ) {
1247 for ( int i = 0; i < columnCount(); i++ ) {
1248 QModelIndex sibling = index.sibling( index.row(), i );
1249 if ( isEditable( sibling ) ) {
1250 if ( !edit( sibling, EditKeyPressed, e ) ) e->ignore();
1259 QTreeWidget::keyPressEvent( e );
1263 // =======================================================================
1264 // renvoie le medId associe au fichier Med apres ouverture
1265 // =======================================================================
1266 med_idt OuvrirFichier(QString aFile)
1268 med_idt medIdt = MEDfileOpen(aFile.toStdString().c_str(),MED_ACC_RDONLY);
1271 QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
1272 QObject::tr("MG_ADAPT_MED_FILE_1") );
1277 // ======================================================
1278 // ========================================================
1279 QString lireNomMaillage(QString aFile, med_int& meshdim)
1281 QString nomMaillage = QString::null ;
1283 std::vector<std::string> listMeshesNames = MEDCoupling::GetMeshNames(aFile.toStdString());
1285 std::size_t numberOfMeshes(listMeshesNames.size());
1286 // std::cout << "numberOfMeshes:" << numberOfMeshes << std::endl;
1287 if (numberOfMeshes == 0 )
1289 QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
1290 QObject::tr("MG_ADAPT_MED_FILE_2") );
1293 if (numberOfMeshes > 1 )
1295 QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
1296 QObject::tr("MG_ADAPT_MED_FILE_3") );
1300 // std::cout << "numberOfMeshes:" << numberOfMeshes << std::endl;
1301 std::cout << "nomMaillage:" << listMeshesNames[0] << std::endl;
1302 nomMaillage = QString(listMeshesNames[0].c_str());
1307 // =======================================================================
1309 // =======================================================================
1310 std::map<QString, int> GetListeChamps(QString aFile, bool errorMessage)
1311 // =======================================================================
1313 // Il faut voir si plusieurs maillages
1315 MESSAGE("GetListeChamps");
1316 std::map<QString, int> ListeChamp ;
1318 med_err erreur = 0 ;
1320 while ( erreur == 0 )
1322 MEDCoupling::MCAuto<MEDCoupling::MEDFileData> mfd = MEDCoupling::MEDFileData::New(aFile.toStdString());
1323 std::vector<std::string> listFieldsNames(mfd->getFields()->getFieldsNames());
1324 std::size_t jaux(listFieldsNames.size());
1329 QMessageBox::critical( 0, QObject::tr("_ERROR"),
1330 QObject::tr("HOM_MED_FILE_5") );
1335 med_int nbofcstp = 1;
1336 for(std::size_t j=0;j<jaux;j++)
1338 // std::cout << listFieldsNames[j] << std::endl;
1339 ListeChamp.insert(std::pair<QString, int> (QString(listFieldsNames[j].c_str()), nbofcstp));
1347 std::string remove_extension(const std::string& filename)
1349 size_t lastdot = filename.find_last_of(".");
1350 if (lastdot == std::string::npos) return filename;
1351 return filename.substr(0, lastdot);