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 "SUIT_Desktop.h"
27 #include "SUIT_Application.h"
28 #include "SUIT_Session.h"
30 #include "SalomeApp_Application.h"
31 #include "SalomeApp_Module.h"
32 #include "SalomeApp_Study.h"
33 #include "SMESH_Actor.h"
34 #include <SUIT_MessageBox.h>
35 #include <SMESH_TypeFilter.hxx>
36 #include <SMESH_MeshAlgos.hxx>
37 #include <SMESH_LogicalFilter.hxx>
38 #include <SMDS_Mesh.hxx>
39 #include <SMDS_MeshNode.hxx>
40 #include <LightApp_SelectionMgr.h>
41 #include <SUIT_OverrideCursor.h>
42 #include <SUIT_ResourceMgr.h>
43 #include <SVTK_ViewWindow.h>
44 #include <SALOME_ListIO.hxx>
45 #include <SUIT_FileDlg.h>
46 #include <QApplication>
47 #include <QButtonGroup>
48 #include <QGridLayout>
50 #include <QHBoxLayout>
55 #include <QPushButton>
56 #include <QRadioButton>
58 #include <QVBoxLayout>
59 #include <QDoubleSpinBox>
61 #include <QTreeWidget>
62 #include <QTreeWidgetItem>
63 #include <QSpacerItem>
65 #include <QHeaderView>
66 #include <QItemDelegate>
67 #include <QFileDialog>
68 #include <QMessageBox>
71 #include <vtkPoints.h>
72 #include <vtkUnstructuredGrid.h>
73 #include <vtkIdList.h>
74 #include <vtkCellArray.h>
75 #include <vtkUnsignedCharArray.h>
76 #include <vtkDataSetMapper.h>
77 #include <VTKViewer_CellLocationsArray.h>
78 #include <vtkProperty.h>
81 // SALOME KERNEL includes
82 #include <SALOMEDS_SComponent.hxx>
83 #include <SALOMEDS_SObject.hxx>
84 #include <SALOMEDS_Study.hxx>
85 #include <SALOMEDS_wrap.hxx>
86 #include "SalomeApp_Tools.h"
87 #include <SALOMEconfig.h>
89 #include <utilities.h>
91 #include <TCollection_AsciiString.hxx>
94 const int SPACING = 6; // layout spacing
95 const int MARGIN = 9; // layout margin
97 //=================================================================================
98 // function : SMESHGUI_MgAdaptDlg()
100 //=================================================================================
101 SMESHGUI_MgAdaptDlg::SMESHGUI_MgAdaptDlg( SalomeApp_Module* theModule, MgAdapt* myModel, QWidget* parent, bool isCreation )
102 : mySMESHGUI( theModule ), QDialog(parent)
104 model = new MgAdapt(*myModel);
105 myData = model->getData();
107 if (!isCreation) readParamsFromHypo();
110 void SMESHGUI_MgAdaptDlg::buildDlg()
113 setAttribute( Qt::WA_DeleteOnClose, true );
114 setWindowTitle( tr( "ADAPT_PREF_MG_ADAPT" ) );
115 setSizeGripEnabled( true );
118 myTabWidget = new QTabWidget( this );
122 myArgs = new SMESHGUI_MgAdaptArguments( myTabWidget );
123 std::vector <std::string> str = model->getOptionValuesStrVec();
124 std::vector <std::string> str2 = model->getCustomOptionValuesStrVec();
125 str.insert( str.end(), str2.begin(), str2.end() );
127 myAdvOpt = new MgAdaptAdvWidget(myTabWidget, &str);
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* okBtn = new QPushButton( tr( "SMESH_BUT_OK" ), this );
141 okBtn->setAutoDefault( true );
142 okBtn->setDefault( true );
144 QPushButton* buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), this);
145 buttonApply->setAutoDefault(true);
146 QPushButton* buttonApplyAndClose = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), this);
147 buttonApplyAndClose->setAutoDefault(true);
148 QPushButton* cancelBtn = new QPushButton( tr( "SMESH_BUT_CANCEL" ), this );
149 cancelBtn->setAutoDefault( true );
150 QPushButton* helpBtn = new QPushButton( tr( "SMESH_BUT_HELP" ), this );
151 helpBtn->setAutoDefault( true );
153 QHBoxLayout* btnLayout = new QHBoxLayout;
154 btnLayout->setSpacing( SPACING );
155 btnLayout->setMargin( 0 );
156 btnLayout->addWidget( buttonApplyAndClose );
157 btnLayout->addStretch( 10 );
158 btnLayout->addWidget( buttonApply );
159 btnLayout->addStretch( 10 );
160 btnLayout->addWidget( okBtn );
161 btnLayout->addStretch( 10 );
162 btnLayout->addWidget( cancelBtn );
163 btnLayout->addStretch( 10 );
164 btnLayout->addWidget( helpBtn );
165 okBtn->hide(); // tab 1
167 QVBoxLayout* l = new QVBoxLayout ( this );
168 l->setMargin( MARGIN );
169 l->setSpacing( SPACING );
170 l->addWidget( myTabWidget );
172 l->addLayout( btnLayout );
175 connect( okBtn, SIGNAL( clicked() ), this, SLOT( clickOnOk() ) );
176 connect( helpBtn, SIGNAL( clicked() ), this, SLOT( clickOnHelp() ) );
177 connect(cancelBtn, SIGNAL(clicked()), this, SLOT(reject()));
178 connect(buttonApply, SIGNAL(clicked()), this,SLOT(clickOnApply()));
179 connect(buttonApplyAndClose, SIGNAL(clicked()), this,SLOT(clickOnOk()));
183 //=================================================================================
184 // function : ~SMESHGUI_MgAdaptDlg()
185 // purpose : Destroys the object and frees any allocated resources
186 //=================================================================================
187 SMESHGUI_MgAdaptDlg::~SMESHGUI_MgAdaptDlg()
192 void SMESHGUI_MgAdaptDlg::setModel(MgAdapt* mg)
196 MgAdapt* SMESHGUI_MgAdaptDlg::getModel() const
201 \brief Perform clean-up actions on the dialog box closing.
203 bool SMESHGUI_MgAdaptDlg::clickOnApply()
205 readParamsFromWidgets();
208 void SMESHGUI_MgAdaptDlg::clickOnOk()
213 void SMESHGUI_MgAdaptDlg::reject()
217 bool SMESHGUI_MgAdaptDlg::readParamsFromHypo( ) const
220 myArgs->aMedfile->setChecked(myData->fromMedFile) ;
221 if (myData->fromMedFile)
224 *(myArgs->myFileInDir) = QString(myData->myFileInDir.c_str()) ;
225 myArgs->selectMedFileLineEdit->setText(myData->myMeshFileIn.c_str()) ;
226 // myData->myInMeshName = // TODO
231 myArgs->aBrowserObject->setText(myData->myInMeshName.c_str());
232 //~ myArgs->myFileInDir =""; // TODO
233 //~ myArgs->selectMedFileLineEdit->setText(); // TODO
235 myArgs->meshNameLineEdit->setText(myData->myOutMeshName.c_str());
236 myArgs->medFileCheckBox->setChecked(myData->myMeshOutMed);
238 if(myData->myMeshOutMed)
240 *(myArgs->myFileOutDir) = QString(myData->myFileOutDir.c_str());
241 myArgs->selectOutMedFileLineEdit->setText(myData->myMeshFileOut.c_str());
246 *(myArgs->myFileOutDir) = QString(""); //TODO
249 myArgs->publishOut->setChecked(myData->myPublish);
251 myArgs->localButton->setChecked(myData->myUseLocalMap);
252 myArgs->backgroundButton->setChecked(myData->myUseBackgroundMap);
253 myArgs->constantButton->setChecked(myData->myUseConstantValue);
255 if (myData->myUseConstantValue)
257 myArgs->dvalue->setValue(myData->myConstantValue);
261 myArgs->dvalue->setValue(0.0);
264 if (myData->myUseBackgroundMap)
267 *(myArgs->myFileSizeMapDir) = QString(myData->myFileSizeMapDir.c_str()) ;
268 myArgs->selectMedFileBackgroundLineEdit->setText(myData->myMeshFileBackground.c_str());
272 *(myArgs->myFileSizeMapDir) = QString("") ; //TODO
273 myArgs->selectMedFileBackgroundLineEdit->setText(""); //TODO
276 myArgs->fieldNameCmb->setCurrentText(myData->myFieldName.c_str());
277 myArgs->noTimeStep->setChecked(myData->myUseNoTimeStep);
278 myArgs->lastTimeStep->setChecked( myData->myUseLastTimeStep);
279 myArgs->chosenTimeStep->setChecked(myData->myUseChosenTimeStep);
280 if (myData->myUseChosenTimeStep)
282 myArgs->rankSpinBox->setValue(myData->myRank);
283 myArgs->timeStep->setValue(myData->myTimeStep);
286 myAdvOpt->workingDirectoryLineEdit->setText(myData->myWorkingDir.c_str());
287 myAdvOpt->logInFileCheck->setChecked(myData->myPrintLogInFile);
289 myAdvOpt->verboseLevelSpin->setValue(myData->myVerboseLevel);
290 myAdvOpt->removeLogOnSuccessCheck->setChecked(myData->myRemoveLogOnSuccess);
291 myAdvOpt->keepWorkingFilesCheck->setChecked(myData->myKeepFiles);
298 bool SMESHGUI_MgAdaptDlg::readParamsFromWidgets()
301 MgAdaptHypothesisData* aData = new MgAdaptHypothesisData();
302 aData->fromMedFile = myArgs->aMedfile->isChecked();
303 if (aData->fromMedFile)
306 aData->myFileInDir = myArgs->myFileInDir->toStdString();
307 aData->myMeshFileIn = myArgs->selectMedFileLineEdit->text().toStdString();
308 // aData->myInMeshName = // TODO
312 aData->myInMeshName = myArgs->aBrowserObject->text().toStdString();
313 aData->myFileInDir = myAdvOpt->workingDirectoryLineEdit->text().toStdString();
315 TCollection_AsciiString aGenericName = (char*)aData->myFileInDir.c_str();
316 TCollection_AsciiString aGenericName2 = "MgAdapt_";
317 aGenericName2 += getpid();
318 aGenericName2 += "_";
319 aGenericName2 += Abs((Standard_Integer)(long) aGenericName.ToCString());
320 aGenericName2 += ".med";
321 aGenericName+=aGenericName2;
322 emit myArgs->toExportMED(aGenericName.ToCString());
323 aData->myMeshFileIn = aGenericName2.ToCString();
325 aData->myOutMeshName = myArgs->meshNameLineEdit->text().toStdString();
326 aData->myMeshOutMed = myArgs->medFileCheckBox->isChecked();
327 if(aData->myMeshOutMed)
329 aData->myFileOutDir = myArgs->myFileOutDir->toStdString();
330 aData->myMeshFileOut = myArgs->selectOutMedFileLineEdit->text().toStdString();
335 aData->myMeshFileOut = "";
338 aData->myPublish = myArgs->publishOut->isChecked();
341 aData->myUseLocalMap = myArgs->localButton->isChecked();
342 aData->myUseBackgroundMap = myArgs->backgroundButton->isChecked();
343 aData->myUseConstantValue = myArgs->constantButton->isChecked();
344 if (aData->myUseConstantValue)
346 aData->myConstantValue = myArgs->dvalue->value();
350 aData->myConstantValue = 0.0;
352 if (aData->myUseBackgroundMap)
354 aData->myFileSizeMapDir = myArgs->myFileSizeMapDir->toStdString();
355 aData->myMeshFileBackground = myArgs->selectMedFileBackgroundLineEdit->text().toStdString();
359 aData->myMeshFileBackground = "";
362 aData->myFieldName = myArgs->fieldNameCmb->currentText().toStdString();
363 aData->myUseNoTimeStep = myArgs->noTimeStep->isChecked();
364 aData->myUseLastTimeStep = myArgs->lastTimeStep->isChecked();
365 aData->myUseChosenTimeStep = myArgs->chosenTimeStep->isChecked();
366 if (aData->myUseChosenTimeStep)
368 aData->myRank = myArgs->rankSpinBox->value();
369 aData->myTimeStep = myArgs->timeStep->value();
374 aData->myWorkingDir = myAdvOpt->workingDirectoryLineEdit->text().toStdString();
375 aData->myPrintLogInFile = myAdvOpt->logInFileCheck->isChecked();
376 aData->myVerboseLevel = myAdvOpt->verboseLevelSpin->value();
377 aData->myRemoveLogOnSuccess = myAdvOpt->removeLogOnSuccessCheck->isChecked();
378 aData->myKeepFiles = myAdvOpt->keepWorkingFilesCheck->isChecked();
379 model->setData(aData);
385 bool SMESHGUI_MgAdaptDlg::storeParamsToHypo( const MgAdaptHypothesisData& ) const
390 \brief Show help page
392 void SMESHGUI_MgAdaptDlg::clickOnHelp()
394 // QString aHelpFile;
395 // if ( myTabWidget->currentIndex() == MinDistance ) {
396 // aHelpFile = "measurements.html#min-distance-anchor";
397 // } else if ( myTabWidget->currentIndex() == BoundingBox ) {
398 // aHelpFile = "measurements.html#bounding-box-anchor";
399 // } else if ( myTabWidget->currentWidget() == myAngle ) {
400 // aHelpFile = "measurements.html#angle-anchor";
402 // aHelpFile = "measurements.html#basic-properties-anchor";
405 // SMESH::ShowHelpFile( aHelpFile );
407 bool SMESHGUI_MgAdaptDlg::checkParams(QString& msg)
409 if ( !QFileInfo( myAdvOpt->workingDirectoryLineEdit->text().trimmed() ).isWritable() ) {
410 SUIT_MessageBox::warning( this,
411 tr( "SMESH_WRN_WARNING" ),
412 tr( "GHS3D_PERMISSION_DENIED" ) );
417 myAdvOpt->myOptionTable->setFocus();
418 QApplication::instance()->processEvents();
421 bool isDefault, ok = true;
422 int iRow = 0, nbRows = myAdvOpt->myOptionTable->topLevelItemCount();
423 for ( ; iRow < nbRows; ++iRow )
425 QTreeWidgetItem* row = myAdvOpt->myOptionTable->topLevelItem( iRow );
426 myAdvOpt->GetOptionAndValue( row, name, value, isDefault );
428 if ( name.simplified().isEmpty() )
429 continue; // invalid custom option
431 if ( isDefault ) // not selected option
435 model->setOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
437 catch ( const SALOME::SALOME_Exception& ex )
439 msg = ex.details.text.in();
449 //=================================================================================
450 // function : SMESHGUI_MgAdaptArguments()
452 //=================================================================================
453 SMESHGUI_MgAdaptArguments::SMESHGUI_MgAdaptArguments( QWidget* parent )
458 myFileInDir = new QString("");
459 myFileOutDir = new QString("");
460 myFileSizeMapDir = new QString("");
461 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
463 *myFileInDir = QDir::currentPath();
464 *myFileOutDir = QDir::currentPath();
465 *myFileSizeMapDir = QDir::currentPath();
469 *myFileInDir = SUIT_FileDlg::getLastVisitedPath();
470 *myFileOutDir = SUIT_FileDlg::getLastVisitedPath();
471 *myFileSizeMapDir = SUIT_FileDlg::getLastVisitedPath();
476 aMeshIn = new QGroupBox( tr( "MeshIn" ), this );
477 aMedfile = new QRadioButton( tr( "MEDFile" ), aMeshIn );
478 aBrowser = new QRadioButton( tr( "Browser" ), aMeshIn );
479 aBrowserObject = new QLineEdit( aMeshIn );
480 selectMedFilebutton = new QPushButton("", aMeshIn);
481 selectMedFileLineEdit = new QLineEdit( aMeshIn );
483 meshIn = new QGridLayout( aMeshIn );
485 meshIn->setMargin( MARGIN );
486 meshIn->setSpacing( SPACING );
487 meshIn->addWidget( aMedfile, 0, 0, 1,1 );
488 meshIn->addWidget( aBrowser, 0, 1,1,1);
489 meshIn->addWidget( aBrowserObject, 0, 2, 1, 1 );
490 meshIn->addWidget( selectMedFilebutton, 1, 0,1, 1);
491 meshIn->addWidget( selectMedFileLineEdit, 1, 1, 1, 1 );
492 hspacer = new QSpacerItem(188, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
494 meshInGroup = new QButtonGroup( this );
495 meshInGroup->addButton( aMedfile, 0 );
496 meshInGroup->addButton( aBrowser, 1 );
500 aMeshOut = new QGroupBox( tr( "MeshOut" ), this );
501 meshName = new QLabel(tr("MeshName"), aMeshOut);
502 secondHspacer = new QSpacerItem(100, 30);
503 meshNameLineEdit = new QLineEdit(aMeshOut) ;
504 medFileCheckBox = new QCheckBox(tr("MEDFile"), aMeshOut);
505 selectOutMedFilebutton = new QPushButton("", aMeshOut);
506 thirdHspacer = new QSpacerItem(188, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
507 selectOutMedFileLineEdit = new QLineEdit(aMeshOut) ;
508 publishOut = new QCheckBox(tr("Publish_MG_ADAPT"), aMeshOut);
510 meshOut = new QGridLayout( aMeshOut );
512 meshOut->setMargin( MARGIN );
513 meshOut->setSpacing( SPACING );
514 meshOut->addWidget( meshName, 0, 0, 1,1 );
515 meshOut->addItem( secondHspacer, 0, 1, 1, 1 );
516 meshOut->addWidget( meshNameLineEdit, 0, 2,1,1);
517 meshOut->addWidget( medFileCheckBox, 1, 0,1,1 );
518 meshOut->addWidget( selectOutMedFilebutton, 1, 1,1,1 );
519 meshOut->addWidget( selectOutMedFileLineEdit, 1, 2,1,1);
520 meshOut->addWidget( publishOut, 2, 0,1,1 );
522 //size map definition
524 sizeMapDefinition = new QGroupBox(tr("SIZE_MAP_DEF"), this);
525 localButton = new QRadioButton(tr("LOCAL_MG_ADAPT"), sizeMapDefinition);
526 backgroundButton = new QRadioButton(tr("BACKGRND_MG_ADAPT"), sizeMapDefinition);
527 constantButton = new QRadioButton(tr("CNST_MG_ADAPT"), sizeMapDefinition);
528 medFileBackground = new QLabel(tr("MED_FILE_BCKG"), sizeMapDefinition);
529 selectMedFileBackgroundbutton = new QPushButton(tr(""), sizeMapDefinition);
530 selectMedFileBackgroundLineEdit = new QLineEdit(sizeMapDefinition);
531 valueLabel = new QLabel(tr("VALUE_MG_ADAPT"), sizeMapDefinition);
532 dvalue = new QDoubleSpinBox(sizeMapDefinition);
533 sizeMapDefGroup = new QButtonGroup( this );
534 sizeMapDefGroup->addButton( localButton, 0 );
535 sizeMapDefGroup->addButton( backgroundButton, 1 );
536 sizeMapDefGroup->addButton( constantButton, 2 );
538 sizeMapDefGroupLayout = new QGridLayout(sizeMapDefinition);
539 sizeMapDefGroupLayout->addWidget(localButton, 0,0);
540 sizeMapDefGroupLayout->addWidget(backgroundButton, 0,1);
541 sizeMapDefGroupLayout->addWidget(constantButton, 0,2);
542 sizeMapDefGroupLayout->addWidget(medFileBackground, 1,0);
543 sizeMapDefGroupLayout->addWidget(selectMedFileBackgroundbutton, 1,1);
544 sizeMapDefGroupLayout->addWidget(selectMedFileBackgroundLineEdit, 1,2);
545 sizeMapDefGroupLayout->addWidget(valueLabel, 2,0);
546 sizeMapDefGroupLayout->addWidget(dvalue, 2,1);
549 sizeMapField = new QGroupBox(tr("SIZE_MAP_FIELD"), this);
550 fieldName = new QLabel(tr("MG_ADAPT_FIELD_NAME"), sizeMapField);
551 fieldNameCmb = new QComboBox(sizeMapField);
552 noTimeStep = new QRadioButton(tr("MG_ADAPT_NO_T_ST"), sizeMapField);
553 lastTimeStep = new QRadioButton(tr("MG_ADAPT_L_ST"), sizeMapField);
554 chosenTimeStep = new QRadioButton(tr("MG_ADAPT_CH_ST"), sizeMapField);
555 timeStepLabel = new QLabel(tr("MG_ADAPT_TSTP"), sizeMapField);
556 timeStep = new QSpinBox(sizeMapField);
557 //~timeStep->setMinimum(-1);
558 rankLabel = new QLabel(tr("MG_ADAPT_RANK"), sizeMapField);
559 rankSpinBox = new QSpinBox(sizeMapField);
560 rankSpinBox->setMinimum(-1);
562 timeStepGroup = new QButtonGroup(this);
563 timeStepGroup->addButton(noTimeStep, 0);
564 timeStepGroup->addButton(lastTimeStep, 1);
565 timeStepGroup->addButton(chosenTimeStep, 2);
567 sizeMapFieldGroupLayout = new QGridLayout(sizeMapField);
569 sizeMapFieldGroupLayout->addWidget(fieldName, 0,0);
570 sizeMapFieldGroupLayout->addWidget(fieldNameCmb, 0,1);
571 sizeMapFieldGroupLayout->addWidget(noTimeStep, 1,0);
572 sizeMapFieldGroupLayout->addWidget(lastTimeStep, 1,1);
573 sizeMapFieldGroupLayout->addWidget(chosenTimeStep, 1,2);
574 sizeMapFieldGroupLayout->addWidget(timeStepLabel, 2,0);
575 sizeMapFieldGroupLayout->addWidget(timeStep, 2,1);
576 sizeMapFieldGroupLayout->addWidget(rankLabel, 2,2);
577 sizeMapFieldGroupLayout->addWidget(rankSpinBox, 2,3);
580 QGridLayout* argumentsLayout = new QGridLayout( this );
581 argumentsLayout->setMargin( MARGIN );
582 argumentsLayout->setSpacing( SPACING );
584 argumentsLayout->addWidget( aMeshIn, 0, 0, 1, 3 );
585 argumentsLayout->addWidget( aMeshOut, 1, 0, 1, 3 );
586 argumentsLayout->addWidget( sizeMapDefinition, 2, 0, 1, 3 );
587 argumentsLayout->addWidget( sizeMapField, 3, 0, 1, 3 );
588 argumentsLayout->setColumnStretch( 1, 5 );
589 argumentsLayout->setRowStretch( 4, 5 );
592 setMode( Mesh, Local);
593 medFileCheckBox->setChecked(true);
596 connect( meshInGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( modeChanged( int ) ) );
597 connect( sizeMapDefGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( sizeMapDefChanged( int ) ) );
598 connect( selectMedFilebutton, SIGNAL( pressed( ) ), this, SLOT( onSelectMedFilebuttonClicked( ) ) );
599 connect(medFileCheckBox, SIGNAL (stateChanged(int)), this, SLOT(onMedFileCheckBox(int) ) );
600 connect(publishOut, SIGNAL (stateChanged(int)), this, SLOT(onPublishOut(int) ) );
601 connect(selectOutMedFilebutton, SIGNAL( pressed()), this, SLOT(onSelectOutMedFilebutton()));
602 connect(selectMedFileBackgroundbutton, SIGNAL(pressed()), this, SLOT(onSelectMedFileBackgroundbutton()) );
603 connect( timeStepGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( timeStepGroupChanged( int ) ) );
604 emit updateSelection();
607 //=================================================================================
608 // function : ~SMESHGUI_MgAdaptArguments()
609 // purpose : Destroys the object and frees any allocated resources
610 //=================================================================================
611 SMESHGUI_MgAdaptArguments::~SMESHGUI_MgAdaptArguments()
615 void SMESHGUI_MgAdaptArguments::onNoTimeStep(bool disableOther)
617 noTimeStep->setChecked(true);
619 rankLabel->setVisible(0);
620 rankSpinBox->setVisible(0);
621 rankSpinBox->setValue(-2);
623 timeStepLabel->setVisible(0);
624 timeStep->setVisible(0);
625 timeStep->setValue(-2);
627 lastTimeStep->setDisabled(disableOther);
628 chosenTimeStep->setDisabled(disableOther);
632 void SMESHGUI_MgAdaptArguments::onLastTimeStep(bool disableOther)
634 lastTimeStep->setChecked(true);
636 rankLabel->setVisible(0);
637 rankSpinBox->setVisible(0);
638 rankSpinBox->setValue(-1);
640 timeStepLabel->setVisible(0);
641 timeStep->setVisible(0);
642 timeStep->setValue(-1);
643 noTimeStep->setDisabled(disableOther);
646 void SMESHGUI_MgAdaptArguments::onChosenTimeStep(bool disableOther, int max)
648 chosenTimeStep->setChecked(true);
650 rankLabel->setVisible(1);
651 rankSpinBox->setVisible(1);
652 rankSpinBox->setValue(0);
654 timeStepLabel->setVisible(1);
655 timeStep->setVisible(1);
656 timeStep->setValue(0);
657 if (max) timeStep->setMaximum(max);
661 void SMESHGUI_MgAdaptArguments::onSelectOutMedFilebutton()
664 QString filtre = QString("Med") ;
665 filtre += QString(" files (*.") + QString("med") + QString(");;");
666 QString fileName = QFileDialog::getSaveFileName(this, tr("SAVE_MED"),
667 QString(""), filtre);
668 QFileInfo myFileInfo(fileName);
669 selectOutMedFileLineEdit->setText(myFileInfo.fileName());
670 *myFileOutDir = myFileInfo.path();
673 void SMESHGUI_MgAdaptArguments::onSelectMedFileBackgroundbutton()
675 QString fileName0 = selectMedFileBackgroundbutton->text().trimmed();
677 QString fileName = getMedFileName(false);
678 if (fileName != QString::null)
680 myFieldList = GetListeChamps(fileName);
681 if (myFieldList.empty())
683 fileName = fileName0;
684 fieldNameCmb->clear();
688 // fill field name Combobox
689 fieldNameCmb->clear();
690 std::map<QString, int>::const_iterator it;
691 for ( it=myFieldList.begin() ; it != myFieldList.end(); it++)
693 fieldNameCmb->insertItem(0,QString(it->first));
694 int typeStepInField = it->second > 2 ? 2 : it->second ;
695 timeStepGroupChanged(typeStepInField, true, it->second-1);
703 fileName = fileName0;
704 fieldNameCmb->clear();
707 QFileInfo myFileInfo(fileName);
708 *myFileSizeMapDir = myFileInfo.path();
709 selectMedFileBackgroundLineEdit->setText(myFileInfo.fileName());
712 void SMESHGUI_MgAdaptArguments::onMedFileCheckBox(int state)
714 if (state == Qt::Checked)
716 selectOutMedFilebutton->show();
717 selectOutMedFileLineEdit->show();
718 selectOutMedFilebutton->setEnabled(true);
719 selectOutMedFileLineEdit->setEnabled(true);
723 selectOutMedFilebutton->setEnabled(false);
724 selectOutMedFileLineEdit->setEnabled(false);
725 publishOut->setChecked(true);
728 void SMESHGUI_MgAdaptArguments::onPublishOut(int state)
730 if (state == Qt::Unchecked)
732 medFileCheckBox->setChecked(true);
736 void SMESHGUI_MgAdaptArguments::onSelectMedFilebuttonClicked()
738 // bool keep = false;
739 QString fileName0 = selectMedFileLineEdit->text().trimmed();
741 QString fileName = getMedFileName(false);
742 if(fileName != QString::null)
744 QString aMeshName = lireNomMaillage(fileName.trimmed());
745 if (aMeshName == QString::null )
747 QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
748 QObject::tr("MG_ADAPT_MED_FILE_2") );
749 fileName = fileName0;
753 meshNameLineEdit->setText(aMeshName);
763 QFileInfo myFileInfo(fileName);
764 *myFileInDir = myFileInfo.path();
765 *myFileOutDir = myFileInfo.path();
766 selectMedFileLineEdit->setText(myFileInfo.fileName());
767 selectOutMedFileLineEdit->setText(myFileInfo.fileName());
768 onLocalSelected(myFileInfo.filePath());
772 void SMESHGUI_MgAdaptArguments::onLocalSelected(QString filePath)
774 myFieldList = GetListeChamps(filePath, false);
775 if (myFieldList.empty())
777 if (localButton->isChecked())
779 fieldNameCmb->clear();
785 // fill field name Combobox
786 fieldNameCmb->clear();
787 std::map<QString, int>::const_iterator it;
788 for ( it=myFieldList.begin() ; it != myFieldList.end(); it++)
790 fieldNameCmb->insertItem(0,QString(it->first));
791 int typeStepInField = it->second > 2 ? 2 : it->second ;
792 timeStepGroupChanged(typeStepInField, true, it->second-1);
797 // =======================================================================
798 // Gestion les boutons qui permettent de
799 // 1) retourne le nom d'un fichier par une fenetre de dialogue si aucun
800 // objet est selectionne dans l arbre d etude
801 // 2) retourne le nom du fichier asocie a l objet
802 // selectionne dans l arbre d etude
803 // =======================================================================
804 QString SMESHGUI_MgAdaptArguments::getMedFileName(bool avertir)
807 QString aFile = QString::null;
808 QString filtre = QString("Med") ;
809 filtre += QString(" files (*.") + QString("med") + QString(");;");
810 aFile = SUIT_FileDlg::getOpenFileName(0, QObject::tr("MG_ADAPT_SELECT_FILE_0"), QString(""), filtre );
815 void SMESHGUI_MgAdaptArguments::setMode(const Mode theMode, const SIZEMAP theSizeMap )
817 QRadioButton* aButton = qobject_cast<QRadioButton*>( meshInGroup->button( theMode ) );
818 QRadioButton* bButton = qobject_cast<QRadioButton*>( sizeMapDefGroup->button( theSizeMap ) );
820 aButton->setChecked( true );
821 modeChanged( theMode );
824 bButton->setChecked( true );
825 sizeMapDefChanged( theSizeMap );
829 void SMESHGUI_MgAdaptArguments::modeChanged( int theMode )
834 aBrowserObject->hide();
835 selectMedFileLineEdit->show();
836 selectMedFilebutton->show();
837 localButton->setEnabled(true);
841 selectMedFileLineEdit->hide();
842 selectMedFilebutton->hide();
843 localButton->setEnabled(false);
844 aBrowserObject->show();
845 sizeMapDefChanged(Background);
846 emit updateSelection();
853 void SMESHGUI_MgAdaptArguments::sizeMapDefChanged( int theSizeMap )
855 fieldNameCmb->clear();
856 if(theSizeMap == Local)
858 localButton->setEnabled(true);
859 localButton->setChecked(true);
860 medFileBackground->hide();
861 selectMedFileBackgroundbutton->hide();
862 selectMedFileBackgroundLineEdit->hide();
863 selectMedFileBackgroundLineEdit->clear();
867 sizeMapField->setEnabled(true);
868 if (!selectMedFileLineEdit->text().isEmpty())
870 QFileInfo myFileInfo(QDir(*myFileInDir), selectMedFileLineEdit->text());
871 onLocalSelected(myFileInfo.filePath());
874 else if (theSizeMap == Background)
876 medFileBackground->show();
877 backgroundButton->setChecked(true);
878 selectMedFileBackgroundbutton->show();
879 selectMedFileBackgroundLineEdit->show();
882 sizeMapField->setEnabled(true);
887 medFileBackground->hide();
888 constantButton->setChecked(true);
889 selectMedFileBackgroundbutton->hide();
890 selectMedFileBackgroundLineEdit->clear();
891 selectMedFileBackgroundLineEdit->hide();
894 sizeMapField->setEnabled(false);
900 void SMESHGUI_MgAdaptArguments::timeStepGroupChanged(int timeStepType, bool disableOther, int max)
902 switch (timeStepType)
905 onNoTimeStep(disableOther);
908 onLastTimeStep(disableOther);
911 onChosenTimeStep(disableOther, max);
917 void SMESHGUI_MgAdaptArguments::clear()
919 selectMedFileLineEdit->clear();
920 aBrowserObject->clear();
922 meshNameLineEdit->clear();
923 selectOutMedFileLineEdit->clear();
926 QWidget* ItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &o, const QModelIndex &index) const
928 bool editable = index.data( EDITABLE_ROLE ).toInt();
929 return editable ? QItemDelegate::createEditor( parent, o, index ) : 0;
932 //////////////////////////////////////////
934 //////////////////////////////////////////
936 MgAdaptAdvWidget::MgAdaptAdvWidget( QWidget* parent, std::vector <std::string>* options, Qt::WindowFlags f )
937 : QWidget( parent, f ), myOptions(options)
940 myOptionTable->header()->setSectionResizeMode( QHeaderView::ResizeToContents );
941 myOptionTable->setItemDelegate( new ItemDelegate( myOptionTable ) );
943 for ( int i = 0, nb = myOptions->size(); i < nb; ++i )
945 AddOption( (*myOptions)[i].c_str() );
948 connect( myOptionTable, SIGNAL( itemChanged(QTreeWidgetItem *, int)), SLOT( itemChanged(QTreeWidgetItem *, int )));
949 connect( addBtn, SIGNAL( clicked() ), this, SLOT( onAddOption() ) );
950 connect(workingDirectoryPushButton, SIGNAL(pressed()), this, SLOT(_onWorkingDirectoryPushButton()));
953 MgAdaptAdvWidget::~MgAdaptAdvWidget()
957 void MgAdaptAdvWidget::AddOption( const char* option, bool isCustom )
959 QTreeWidget * table = myOptionTable;
960 //table->setExpanded( true );
962 QTreeWidgetItem * row = new QTreeWidgetItem( table );
963 row->setData( NAME_COL, EDITABLE_ROLE, int( isCustom && !option ));
964 row->setFlags( row->flags() | Qt::ItemIsEditable );
967 bool isDefault = false;
970 QStringList name_value_type = QString(option).split( ":", QString::KeepEmptyParts );
971 if ( name_value_type.size() > 0 )
972 name = name_value_type[0];
973 if ( name_value_type.size() > 1 )
974 value = name_value_type[1];
975 if ( name_value_type.size() > 2 )
976 isDefault = !name_value_type[2].toInt();
979 row->setText( 0, tr( name.toLatin1().constData() ));
980 row->setText( 1, tr( value.toLatin1().constData() ));
981 row->setCheckState( 0, isDefault ? Qt::Unchecked : Qt::Checked);
982 row->setData( NAME_COL, PARAM_NAME, name );
986 myOptionTable->scrollToItem( row );
987 myOptionTable->setCurrentItem( row );
988 myOptionTable->editItem( row, NAME_COL );
991 void MgAdaptAdvWidget::onAddOption()
993 AddOption( NULL, true );
995 void MgAdaptAdvWidget::GetOptionAndValue( QTreeWidgetItem * tblRow,
1000 option = tblRow->data( NAME_COL, PARAM_NAME ).toString();
1001 value = tblRow->text( VALUE_COL );
1002 isDefault = ! tblRow->checkState( NAME_COL );
1007 void MgAdaptAdvWidget::itemChanged(QTreeWidgetItem * tblRow, int column)
1011 myOptionTable->blockSignals( true );
1013 tblRow->setData( VALUE_COL, EDITABLE_ROLE, int( tblRow->checkState( NAME_COL )));
1015 int c = tblRow->checkState( NAME_COL ) ? 0 : 150;
1016 tblRow->setForeground( VALUE_COL, QBrush( QColor( c, c, c )));
1018 if ( column == NAME_COL && tblRow->data( NAME_COL, EDITABLE_ROLE ).toInt() ) // custom table
1020 tblRow->setData( NAME_COL, PARAM_NAME, tblRow->text( NAME_COL ));
1023 myOptionTable->blockSignals( false );
1026 void MgAdaptAdvWidget::setupWidget()
1028 if (this->objectName().isEmpty())
1029 this->setObjectName(QString(tr("MG-ADAPT-ADV")));
1030 this->resize(337, 369);
1031 gridLayout_4 = new QGridLayout(this);
1032 gridLayout_4->setObjectName(QString("gridLayout_4"));
1033 myOptionTable = new MgAdaptAdvWidgetTreeWidget(this);
1035 font.setBold(false);
1037 QTreeWidgetItem *__qtreewidgetitem = new QTreeWidgetItem();
1038 __qtreewidgetitem->setFont(1, font);
1039 __qtreewidgetitem->setFont(0, font);
1040 __qtreewidgetitem->setText(1, tr("OPTION_VALUE_COLUMN"));
1041 __qtreewidgetitem->setText(0, tr("OPTION_NAME_COLUMN"));
1042 myOptionTable->setHeaderItem(__qtreewidgetitem);
1043 myOptionTable->setObjectName(QString("myOptionTable"));
1044 myOptionTable->setEditTriggers(QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed);
1045 myOptionTable->setTabKeyNavigation(true);
1047 gridLayout_4->addWidget(myOptionTable, 0, 0, 1, 2);
1049 addBtn = new QPushButton(this);
1050 addBtn->setObjectName(QString("addBtn"));
1052 gridLayout_4->addWidget(addBtn, 1, 0, 1, 1);
1054 horizontalSpacer = new QSpacerItem(188, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
1056 gridLayout_4->addItem(horizontalSpacer, 1, 1, 1, 1);
1058 logGroupBox = new QGroupBox(this);
1059 logGroupBox->setObjectName(QString("logGroupBox"));
1060 gridLayout_2 = new QGridLayout(logGroupBox);
1061 gridLayout_2->setObjectName(QString("gridLayout_2"));
1062 gridLayout = new QGridLayout();
1063 gridLayout->setObjectName(QString("gridLayout"));
1064 workingDirectoryLabel = new QLabel(logGroupBox);
1065 workingDirectoryLabel->setObjectName(QString("workingDirectoryLabel"));
1067 gridLayout->addWidget(workingDirectoryLabel, 0, 0, 1, 1);
1069 workingDirectoryLineEdit = new QLineEdit(logGroupBox);
1070 workingDirectoryLineEdit->setObjectName(QString("workingDirectoryLineEdit"));
1072 gridLayout->addWidget(workingDirectoryLineEdit, 0, 1, 1, 1);
1074 workingDirectoryPushButton = new QPushButton(logGroupBox);
1075 workingDirectoryPushButton->setObjectName(QString("workingDirectoryPushButton"));
1077 gridLayout->addWidget(workingDirectoryPushButton, 0, 2, 1, 1);
1079 verboseLevelLabel = new QLabel(logGroupBox);
1080 verboseLevelLabel->setObjectName(QString("verboseLevelLabel"));
1082 gridLayout->addWidget(verboseLevelLabel, 1, 0, 1, 1);
1084 verboseLevelSpin = new QSpinBox(logGroupBox);
1085 verboseLevelSpin->setObjectName(QString("verboseLevelSpin"));
1087 gridLayout->addWidget(verboseLevelSpin, 1, 1, 1, 1);
1090 gridLayout_2->addLayout(gridLayout, 0, 0, 1, 1);
1092 horizontalLayout = new QHBoxLayout();
1093 horizontalLayout->setObjectName(QString("horizontalLayout"));
1094 logInFileCheck = new QCheckBox(logGroupBox);
1095 logInFileCheck->setObjectName(QString("logInFileCheck"));
1096 logInFileCheck->setChecked(true);
1098 horizontalLayout->addWidget(logInFileCheck);
1100 removeLogOnSuccessCheck = new QCheckBox(logGroupBox);
1101 removeLogOnSuccessCheck->setObjectName(QString("removeLogOnSuccessCheck"));
1102 removeLogOnSuccessCheck->setChecked(true);
1104 horizontalLayout->addWidget(removeLogOnSuccessCheck);
1107 gridLayout_2->addLayout(horizontalLayout, 1, 0, 1, 1);
1109 keepWorkingFilesCheck = new QCheckBox(logGroupBox);
1110 keepWorkingFilesCheck->setObjectName(QString("keepWorkingFilesCheck"));
1111 keepWorkingFilesCheck->setAutoExclusive(false);
1113 gridLayout_2->addWidget(keepWorkingFilesCheck, 2, 0, 1, 1);
1116 gridLayout_4->addWidget(logGroupBox, 3, 0, 1, 2);
1119 // retranslateUi(this);
1121 // QMetaObject::connectSlotsByName(this);
1124 void MgAdaptAdvWidget::_onWorkingDirectoryPushButton()
1126 QString aDirName=QFileDialog::getExistingDirectory ();
1127 if (!(aDirName.isEmpty()))workingDirectoryLineEdit->setText(aDirName);
1132 bool isEditable( const QModelIndex& index )
1134 return index.isValid() &&
1135 index.flags() & Qt::ItemIsEditable &&
1136 index.flags() & Qt::ItemIsEnabled &&
1137 ( !index.data( Qt::UserRole + 1 ).isValid() || index.data( Qt::UserRole + 1 ).toInt() != 0 );
1141 MgAdaptAdvWidgetTreeWidget::MgAdaptAdvWidgetTreeWidget( QWidget* parent )
1142 : QTreeWidget( parent )
1146 QModelIndex MgAdaptAdvWidgetTreeWidget::moveCursor( CursorAction action, Qt::KeyboardModifiers modifiers )
1148 QModelIndex current = currentIndex();
1149 int column = current.column();
1150 if ( action == MoveNext ) {
1151 if ( column < columnCount()-1 ) {
1152 QModelIndex next = current.sibling( current.row(), column+1 );
1153 if ( isEditable( next ) )
1157 QModelIndex next = current.sibling( current.row()+1, 0 );
1158 if ( isEditable( next ) )
1162 else if ( action == MovePrevious ) {
1163 if ( column == 0 ) {
1164 QModelIndex next = current.sibling( current.row()-1, columnCount()-1 );
1165 if ( isEditable( next ) )
1169 QModelIndex next = current.sibling( current.row(), column-1 );
1170 if ( isEditable( next ) )
1174 return QTreeWidget::moveCursor( action, modifiers );
1177 void MgAdaptAdvWidgetTreeWidget::keyPressEvent( QKeyEvent* e )
1179 switch ( e->key() ) {
1182 QModelIndex index = currentIndex();
1183 if ( !isEditable( index ) ) {
1184 for ( int i = 0; i < columnCount(); i++ ) {
1185 QModelIndex sibling = index.sibling( index.row(), i );
1186 if ( isEditable( sibling ) ) {
1187 if ( !edit( sibling, EditKeyPressed, e ) )
1197 QTreeWidget::keyPressEvent( e );
1201 // =======================================================================
1202 // renvoie le medId associe au fichier Med apres ouverture
1203 // =======================================================================
1204 med_idt OuvrirFichier(QString aFile)
1206 med_idt medIdt = MEDfileOpen(aFile.toStdString().c_str(),MED_ACC_RDONLY);
1209 QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
1210 QObject::tr("MG_ADAPT_MED_FILE_1") );
1215 // ======================================================
1216 // ========================================================
1217 QString lireNomMaillage(QString aFile)
1219 QString nomMaillage = QString::null ;
1223 // Ouverture du fichier
1224 medIdt = OuvrirFichier(aFile);
1230 med_int numberOfMeshes = MEDnMesh(medIdt) ;
1231 if (numberOfMeshes == 0 )
1233 QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
1234 QObject::tr("MG_ADAPT_MED_FILE_2") );
1238 if (numberOfMeshes > 1 )
1240 QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
1241 QObject::tr("MG_ADAPT_MED_FILE_3") );
1246 nomMaillage = lireNomMaillage2(medIdt,1);
1247 // Fermeture du fichier
1248 if ( medIdt > 0 ) MEDfileClose(medIdt);
1253 // =======================================================================
1254 // =======================================================================
1255 QString lireNomMaillage2(med_idt medIdt,int meshId)
1257 QString NomMaillage=QString::null;
1258 char meshname[MED_NAME_SIZE+1];
1259 med_int spacedim,meshdim;
1260 med_mesh_type meshtype;
1261 char descriptionription[MED_COMMENT_SIZE+1];
1262 char dtunit[MED_SNAME_SIZE+1];
1263 med_sorting_type sortingtype;
1265 med_axis_type axistype;
1266 int naxis = MEDmeshnAxis(medIdt,1);
1267 char *axisname=new char[naxis*MED_SNAME_SIZE+1];
1268 char *axisunit=new char[naxis*MED_SNAME_SIZE+1];
1269 med_err aRet = MEDmeshInfo(medIdt,
1284 QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"), \
1285 QObject::tr("MG_ADAPT_MED_FILE_4") );
1288 NomMaillage=QString(meshname);
1299 // =======================================================================
1300 std::map<QString, int> GetListeChamps(QString aFile, bool errorMessage)
1301 // =======================================================================
1303 // Il faut voir si plusieurs maillages
1305 MESSAGE("GetListeChamps");
1306 std::map<QString, int> ListeChamp ;
1308 med_err erreur = 0 ;
1311 while ( erreur == 0 )
1313 // Ouverture du fichier
1314 SCRUTE(aFile.toStdString());
1315 medIdt = OuvrirFichier(aFile);
1321 // Lecture du nombre de champs
1322 med_int ncha = MEDnField(medIdt) ;
1327 QMessageBox::critical( 0, QObject::tr("_ERROR"),
1328 QObject::tr("HOM_MED_FILE_5") );
1333 // Lecture des caracteristiques des champs
1334 for (int i=0; i< ncha; i++)
1336 // Lecture du nombre de composantes
1337 med_int ncomp = MEDfieldnComponent(medIdt,i+1);
1338 // Lecture du type du champ, des noms des composantes et du nom de l'unite
1339 char nomcha [MED_NAME_SIZE+1];
1340 char meshname[MED_NAME_SIZE+1];
1341 char * comp = (char*) malloc(ncomp*MED_SNAME_SIZE+1);
1342 char * unit = (char*) malloc(ncomp*MED_SNAME_SIZE+1);
1343 char dtunit[MED_SNAME_SIZE+1];
1345 med_field_type typcha;
1347 erreur = MEDfieldInfo(medIdt,i+1,nomcha,meshname,&local,&typcha,comp,unit,dtunit,&nbofcstp) ;
1354 QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
1355 QObject::tr("MG_ADAPT_MED_FILE_6") );
1360 ListeChamp.insert(std::pair<QString, int> (QString(nomcha), nbofcstp));
1365 // Fermeture du fichier
1366 if ( medIdt > 0 ) MEDfileClose(medIdt);