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"
28 #include "SUIT_Desktop.h"
29 #include "SUIT_Application.h"
30 #include "SUIT_Session.h"
32 #include "SalomeApp_Application.h"
33 #include "SalomeApp_Module.h"
34 #include "SalomeApp_Study.h"
35 #include <SUIT_MessageBox.h>
36 #include <LightApp_SelectionMgr.h>
37 #include <SUIT_OverrideCursor.h>
38 #include <SUIT_ResourceMgr.h>
39 #include <SVTK_ViewWindow.h>
40 #include <SALOME_ListIO.hxx>
41 #include <SUIT_FileDlg.h>
42 #include <QApplication>
43 #include <QButtonGroup>
44 #include <QGridLayout>
46 #include <QHBoxLayout>
51 #include <QPushButton>
52 #include <QRadioButton>
54 #include <QVBoxLayout>
55 #include <QDoubleSpinBox>
57 #include <QTreeWidget>
58 #include <QTreeWidgetItem>
59 #include <QSpacerItem>
61 #include <QHeaderView>
62 #include <QItemDelegate>
63 #include <QFileDialog>
64 #include <QMessageBox>
67 #include <vtkPoints.h>
68 #include <vtkUnstructuredGrid.h>
69 #include <vtkIdList.h>
70 #include <vtkCellArray.h>
71 #include <vtkUnsignedCharArray.h>
72 #include <vtkDataSetMapper.h>
73 #include <VTKViewer_CellLocationsArray.h>
74 #include <vtkProperty.h>
77 // SALOME KERNEL includes
78 #include <SALOMEDS_SComponent.hxx>
79 #include <SALOMEDS_SObject.hxx>
80 #include <SALOMEDS_Study.hxx>
81 #include <SALOMEDS_wrap.hxx>
82 #include "SalomeApp_Tools.h"
83 #include <SALOMEconfig.h>
85 #include <utilities.h>
87 #include <TCollection_AsciiString.hxx>
89 const int SPACING = 6; // layout spacing
90 const int MARGIN = 9; // layout margin
92 //=================================================================================
93 // function : SMESHGUI_MgAdaptDlg()
95 //=================================================================================
96 SMESHGUI_MgAdaptDlg::SMESHGUI_MgAdaptDlg( SalomeApp_Module* theModule, SMESH::MG_ADAPT_ptr myModel, QWidget* parent, bool isCreation )
97 : mySMESHGUI( theModule ), QDialog(parent)
99 //~model = new MgAdapt(*myModel);
100 model = SMESH::MG_ADAPT::_duplicate(myModel);
101 myData = model->getData();
103 if (!isCreation) readParamsFromHypo();
106 void SMESHGUI_MgAdaptDlg::buildDlg()
109 setAttribute( Qt::WA_DeleteOnClose, true );
110 setWindowTitle( tr( "ADAPT_PREF_MG_ADAPT" ) );
111 setSizeGripEnabled( true );
113 myTabWidget = new QTabWidget( this );
117 myArgs = new SMESHGUI_MgAdaptArguments( myTabWidget );
118 SMESH::str_array* str = model->getOptionValuesStrVec();
119 SMESH::str_array* str2 = model->getCustomOptionValuesStrVec();
120 std::vector<std::string> s;
121 for (int i = 0; i< str->length(); i++) s.push_back( (*str)[i].in());
122 for (int j = str->length(); j< str2->length(); j++) s.push_back((*str2)[ j - str->length() ].in() );
123 //~str.insert( str.end(), str2.begin(), str2.end() );
125 myAdvOpt = new MgAdaptAdvWidget(myTabWidget, &s);
127 int argsTab = myTabWidget->addTab( myArgs, tr( "Args" ) );
128 int advTab = myTabWidget->addTab( myAdvOpt, tr( "ADVOP" ) );
130 myAdvOpt->workingDirectoryLabel ->setText (tr( "WORKING_DIR" ));
131 myAdvOpt->workingDirectoryPushButton ->setText (tr( "SELECT_DIR" ));
132 myAdvOpt->keepWorkingFilesCheck ->setText (tr( "KEEP_WORKING_FILES" ));
133 myAdvOpt->verboseLevelLabel ->setText (tr( "VERBOSE_LEVEL" ));
134 myAdvOpt->removeLogOnSuccessCheck ->setText (tr( "REMOVE_LOG_ON_SUCCESS" ));
135 myAdvOpt->logInFileCheck ->setText (tr( "LOG_IN_FILE" ));
136 myAdvOpt->logGroupBox ->setTitle(tr( "LOG_GROUP_TITLE" ));
139 QPushButton* buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), this);
140 buttonOk->setAutoDefault(false);
141 QPushButton* buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), this);
142 buttonApply->setAutoDefault(false);
143 QPushButton* buttonCancel = new QPushButton( tr( "SMESH_BUT_CANCEL" ), this );
144 buttonCancel->setAutoDefault( false );
145 QPushButton* buttonHelp = new QPushButton( tr( "SMESH_BUT_HELP" ), this );
146 buttonHelp->setAutoDefault( false );
148 QHBoxLayout* btnLayout = new QHBoxLayout;
149 btnLayout->setSpacing( SPACING );
150 btnLayout->setMargin( 0 );
151 btnLayout->addWidget( buttonOk );
152 btnLayout->addStretch( 10 );
153 btnLayout->addWidget( buttonApply );
154 btnLayout->addStretch( 10 );
155 btnLayout->addWidget( buttonCancel );
156 btnLayout->addStretch( 10 );
157 btnLayout->addWidget( buttonHelp );
159 QVBoxLayout* l = new QVBoxLayout ( this );
160 l->setMargin( MARGIN );
161 l->setSpacing( SPACING );
162 l->addWidget( myTabWidget );
164 l->addLayout( btnLayout );
166 connect( buttonOk, SIGNAL(pressed()), this, SLOT(PushOnOK()));
167 connect( buttonApply, SIGNAL(pressed()), this, SLOT(PushOnApply()));
168 connect( buttonCancel, SIGNAL(pressed()), this, SLOT(close()));
169 connect( buttonHelp, SIGNAL(pressed()), this, SLOT(PushOnHelp()));
171 connect( myArgs, SIGNAL(meshDimSignal(ADAPTATION_MODE)), myAdvOpt, SLOT( onMeshDimChanged(ADAPTATION_MODE)) );
175 //=================================================================================
176 // function : ~SMESHGUI_MgAdaptDlg()
177 // purpose : Destroys the object and frees any allocated resources
178 //=================================================================================
179 SMESHGUI_MgAdaptDlg::~SMESHGUI_MgAdaptDlg()
184 //~void SMESHGUI_MgAdaptDlg::setModel(MgAdapt* mg)
188 SMESH::MG_ADAPT_ptr SMESHGUI_MgAdaptDlg::getModel() const
193 \brief Perform clean-up actions on the dialog box closing.
195 bool SMESHGUI_MgAdaptDlg::PushOnApply()
197 bool ret = readParamsFromWidgets();
200 void SMESHGUI_MgAdaptDlg::PushOnOK()
202 bool ret = PushOnApply();
205 void SMESHGUI_MgAdaptDlg::reject()
209 bool SMESHGUI_MgAdaptDlg::readParamsFromHypo( ) const
212 myArgs->aMedfile->setChecked(myData->fromMedFile) ;
213 if (myData->fromMedFile)
216 *(myArgs->myFileInDir) = QString(myData->myFileInDir) ;
217 myArgs->selectMedFileLineEdit->setText(QString(myData->myMeshFileIn)) ;
218 // myData->myInMeshName = // TODO
223 myArgs->aBrowserObject->setText(QString(myData->myInMeshName));
224 //~ myArgs->myFileInDir =""; // TODO
225 //~ myArgs->selectMedFileLineEdit->setText(); // TODO
227 myArgs->meshNameLineEdit->setText(QString(myData->myOutMeshName));
228 myArgs->medFileCheckBox->setChecked(myData->myMeshOutMed);
230 if(myData->myMeshOutMed)
232 *(myArgs->myFileOutDir) = QString(myData->myFileOutDir);
233 myArgs->selectOutMedFileLineEdit->setText(QString(myData->myMeshFileOut));
237 *(myArgs->myFileOutDir) = QString(""); //TODO
240 myArgs->publishOut->setChecked(myData->myPublish);
242 myArgs->localButton->setChecked(myData->myUseLocalMap);
243 myArgs->backgroundButton->setChecked(myData->myUseBackgroundMap);
244 myArgs->constantButton->setChecked(myData->myUseConstantValue);
246 if (myData->myUseConstantValue)
248 myArgs->dvalue->setValue(myData->myConstantValue);
252 myArgs->dvalue->setValue(0.0);
255 if (myData->myUseBackgroundMap)
258 *(myArgs->myFileSizeMapDir) = QString(myData->myFileSizeMapDir) ;
259 myArgs->selectMedFileBackgroundLineEdit->setText(QString(myData->myMeshFileBackground));
263 *(myArgs->myFileSizeMapDir) = QString("") ; //TODO
264 myArgs->selectMedFileBackgroundLineEdit->setText(""); //TODO
267 myArgs->fieldNameCmb->setCurrentText(QString(myData->myFieldName));
268 myArgs->noTimeStep->setChecked(myData->myUseNoTimeStep);
269 myArgs->lastTimeStep->setChecked( myData->myUseLastTimeStep);
270 myArgs->chosenTimeStep->setChecked(myData->myUseChosenTimeStep);
271 if (myData->myUseChosenTimeStep)
273 myArgs->rankSpinBox->setValue(myData->myRank);
274 myArgs->timeStep->setValue(myData->myTimeStep);
277 myAdvOpt->workingDirectoryLineEdit->setText(QString(myData->myWorkingDir));
278 myAdvOpt->logInFileCheck->setChecked(myData->myPrintLogInFile);
280 myAdvOpt->verboseLevelSpin->setValue(myData->myVerboseLevel);
281 myAdvOpt->removeLogOnSuccessCheck->setChecked(myData->myRemoveLogOnSuccess);
282 myAdvOpt->keepWorkingFilesCheck->setChecked(myData->myKeepFiles);
288 bool SMESHGUI_MgAdaptDlg::readParamsFromWidgets()
290 MESSAGE ("readParamsFromWidgets") ;
292 SMESH::MgAdaptHypothesisData* aData = new SMESH::MgAdaptHypothesisData();
295 // 1. Fichier du maillage de départ
296 aData->fromMedFile = myArgs->aMedfile->isChecked();
297 if (aData->fromMedFile)
299 aData->myFileInDir = CORBA::string_dup(myArgs->myFileInDir->toStdString().c_str());
300 aData->myMeshFileIn = CORBA::string_dup(myArgs->selectMedFileLineEdit->text().toStdString().c_str());
301 // aData->myInMeshName = // TODO
305 QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
306 QObject::tr("MG_ADAPT_MED_FILE_4") );
309 // aData->myInMeshName = CORBA::string_dup(myArgs->aBrowserObject->text().toStdString().c_str());
310 // aData->myFileInDir = CORBA::string_dup(myAdvOpt->workingDirectoryLineEdit->text().toStdString().c_str());
312 // TCollection_AsciiString aGenericName = (char*)aData->myFileInDir;
313 // TCollection_AsciiString aGenericName2 = "MgAdapt_";
314 // aGenericName2 += getpid();
315 // aGenericName2 += "_";
316 // aGenericName2 += Abs((Standard_Integer)(long) aGenericName.ToCString());
317 // aGenericName2 += ".med";
318 // aGenericName+=aGenericName2;
319 // emit myArgs->toExportMED(aGenericName.ToCString());
320 // aData->myMeshFileIn = aGenericName2.ToCString();
322 // 2. Fichier du maillage de sortie
323 aData->myOutMeshName = CORBA::string_dup(myArgs->meshNameLineEdit->text().toStdString().c_str());
324 aData->myMeshOutMed = myArgs->medFileCheckBox->isChecked();
325 if(aData->myMeshOutMed)
327 aData->myFileOutDir = CORBA::string_dup(myArgs->myFileOutDir->toStdString().c_str());
328 aData->myMeshFileOut = CORBA::string_dup(myArgs->selectOutMedFileLineEdit->text().toStdString().c_str());
332 aData->myMeshFileOut = "";
334 aData->myPublish = myArgs->publishOut->isChecked();
336 // 3. Type de carte de tailles
337 aData->myUseLocalMap = myArgs->localButton->isChecked();
338 aData->myUseBackgroundMap = myArgs->backgroundButton->isChecked();
339 aData->myUseConstantValue = myArgs->constantButton->isChecked();
341 if (aData->myUseConstantValue)
343 aData->myConstantValue = myArgs->dvalue->value();
347 aData->myConstantValue = 0.0;
349 // 3.2. Arrière-plan
350 if (aData->myUseBackgroundMap)
352 aData->myFileSizeMapDir = CORBA::string_dup(myArgs->myFileSizeMapDir->toStdString().c_str());
353 aData->myMeshFileBackground = CORBA::string_dup(myArgs->selectMedFileBackgroundLineEdit->text().toStdString().c_str());
357 aData->myMeshFileBackground = "";
361 if ( ! aData->myUseConstantValue )
363 if ( strlen(myArgs->fieldNameCmb->currentText().toStdString().c_str()) == 0 )
365 QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
366 QObject::tr("MG_ADAPT_MED_FILE_5") );
371 aData->myFieldName = CORBA::string_dup(myArgs->fieldNameCmb->currentText().toStdString().c_str());
372 aData->myUseNoTimeStep = myArgs->noTimeStep->isChecked();
373 aData->myUseLastTimeStep = myArgs->lastTimeStep->isChecked();
374 aData->myUseChosenTimeStep = myArgs->chosenTimeStep->isChecked();
375 if (aData->myUseChosenTimeStep)
377 aData->myRank = myArgs->rankSpinBox->value();
378 aData->myTimeStep = myArgs->timeStep->value();
383 // 5. Options avancées
384 aData->myWorkingDir = CORBA::string_dup(myAdvOpt->workingDirectoryLineEdit->text().toStdString().c_str());
385 aData->myPrintLogInFile = myAdvOpt->logInFileCheck->isChecked();
386 aData->myVerboseLevel = myAdvOpt->verboseLevelSpin->value();
387 aData->myRemoveLogOnSuccess = myAdvOpt->removeLogOnSuccessCheck->isChecked();
388 aData->myKeepFiles = myAdvOpt->keepWorkingFilesCheck->isChecked();
389 model->setData(*aData);
400 bool SMESHGUI_MgAdaptDlg::storeParamsToHypo( const SMESH::MgAdaptHypothesisData& ) const
404 \brief Show help page
406 void SMESHGUI_MgAdaptDlg::PushOnHelp()
408 // QString aHelpFile;
409 // if ( myTabWidget->currentIndex() == MinDistance ) {
410 // aHelpFile = "measurements.html#min-distance-anchor";
411 // } else if ( myTabWidget->currentIndex() == BoundingBox ) {
412 // aHelpFile = "measurements.html#bounding-box-anchor";
413 // } else if ( myTabWidget->currentWidget() == myAngle ) {
414 // aHelpFile = "measurements.html#angle-anchor";
416 // aHelpFile = "measurements.html#basic-properties-anchor";
419 // SMESH::ShowHelpFile( aHelpFile );
421 bool SMESHGUI_MgAdaptDlg::checkParams(QString& msg)
423 if ( !QFileInfo( myAdvOpt->workingDirectoryLineEdit->text().trimmed() ).isWritable() )
425 SUIT_MessageBox::warning( this,
426 tr( "SMESH_WRN_WARNING" ),
427 tr( "NO_PERMISSION" ) );
432 myAdvOpt->myOptionTable->setFocus();
433 QApplication::instance()->processEvents();
436 bool isDefault, ok = true;
437 int iRow = 0, nbRows = myAdvOpt->myOptionTable->topLevelItemCount();
438 for ( ; iRow < nbRows; ++iRow )
440 QTreeWidgetItem* row = myAdvOpt->myOptionTable->topLevelItem( iRow );
441 myAdvOpt->GetOptionAndValue( row, name, value, isDefault );
443 if ( name.simplified().isEmpty() )
444 continue; // invalid custom option
446 if ( isDefault ) // not selected option
451 model->setOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
453 catch ( const SALOME::SALOME_Exception& ex )
455 msg = ex.details.text.in();
464 //=================================================================================
465 // function : SMESHGUI_MgAdaptArguments()
467 //=================================================================================
468 SMESHGUI_MgAdaptArguments::SMESHGUI_MgAdaptArguments( QWidget* parent )
472 myFileInDir = new QString("");
473 myFileOutDir = new QString("");
474 myFileSizeMapDir = new QString("");
475 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
477 *myFileInDir = QDir::currentPath();
478 *myFileOutDir = QDir::currentPath();
479 *myFileSizeMapDir = QDir::currentPath();
483 *myFileInDir = SUIT_FileDlg::getLastVisitedPath();
484 *myFileOutDir = SUIT_FileDlg::getLastVisitedPath();
485 *myFileSizeMapDir = SUIT_FileDlg::getLastVisitedPath();
490 aMeshIn = new QGroupBox( tr( "MeshIn" ), this );
491 aMedfile = new QRadioButton( tr( "MEDFile" ), aMeshIn );
492 aBrowser = new QRadioButton( tr( "Browser" ), aMeshIn );
493 aBrowserObject = new QLineEdit( aMeshIn );
494 selectMedFilebutton = new QPushButton("", aMeshIn);
495 selectMedFileLineEdit = new QLineEdit( aMeshIn );
497 meshIn = new QGridLayout( aMeshIn );
499 meshIn->setMargin( MARGIN );
500 meshIn->setSpacing( SPACING );
501 meshIn->addWidget( aMedfile, 0, 0, 1,1 );
502 meshIn->addWidget( aBrowser, 0, 1,1,1);
503 meshIn->addWidget( aBrowserObject, 0, 2, 1, 1 );
504 meshIn->addWidget( selectMedFilebutton, 1, 0,1, 1);
505 meshIn->addWidget( selectMedFileLineEdit, 1, 1, 1, 1 );
506 hspacer = new QSpacerItem(188, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
508 meshInGroup = new QButtonGroup( this );
509 meshInGroup->addButton( aMedfile, 0 );
510 meshInGroup->addButton( aBrowser, 1 );
514 aMeshOut = new QGroupBox( tr( "MeshOut" ), this );
515 meshName = new QLabel(tr("MeshName"), aMeshOut);
516 secondHspacer = new QSpacerItem(100, 30);
517 meshNameLineEdit = new QLineEdit(aMeshOut) ;
518 medFileCheckBox = new QCheckBox(tr("MEDFile"), aMeshOut);
519 selectOutMedFilebutton = new QPushButton("", aMeshOut);
520 thirdHspacer = new QSpacerItem(188, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
521 selectOutMedFileLineEdit = new QLineEdit(aMeshOut) ;
522 publishOut = new QCheckBox(tr("Publish_MG_ADAPT"), aMeshOut);
524 meshOut = new QGridLayout( aMeshOut );
526 meshOut->setMargin( MARGIN );
527 meshOut->setSpacing( SPACING );
528 meshOut->addWidget( meshName, 0, 0, 1,1 );
529 meshOut->addItem( secondHspacer, 0, 1, 1, 1 );
530 meshOut->addWidget( meshNameLineEdit, 0, 2,1,1);
531 meshOut->addWidget( medFileCheckBox, 1, 0,1,1 );
532 meshOut->addWidget( selectOutMedFilebutton, 1, 1,1,1 );
533 meshOut->addWidget( selectOutMedFileLineEdit, 1, 2,1,1);
534 meshOut->addWidget( publishOut, 2, 0,1,1 );
536 //size map definition
538 sizeMapDefinition = new QGroupBox(tr("SIZE_MAP_DEF"), this);
539 localButton = new QRadioButton(tr("LOCAL_MG_ADAPT"), sizeMapDefinition);
540 backgroundButton = new QRadioButton(tr("BACKGRND_MG_ADAPT"), sizeMapDefinition);
541 constantButton = new QRadioButton(tr("CNST_MG_ADAPT"), sizeMapDefinition);
542 medFileBackground = new QLabel(tr("MED_FILE_BCKG"), sizeMapDefinition);
543 selectMedFileBackgroundbutton = new QPushButton(tr(""), sizeMapDefinition);
544 selectMedFileBackgroundLineEdit = new QLineEdit(sizeMapDefinition);
545 valueLabel = new QLabel(tr("VALUE_MG_ADAPT"), sizeMapDefinition);
546 dvalue = new QDoubleSpinBox(sizeMapDefinition);
547 sizeMapDefGroup = new QButtonGroup( this );
548 sizeMapDefGroup->addButton( localButton, 0 );
549 sizeMapDefGroup->addButton( backgroundButton, 1 );
550 sizeMapDefGroup->addButton( constantButton, 2 );
552 sizeMapDefGroupLayout = new QGridLayout(sizeMapDefinition);
553 sizeMapDefGroupLayout->addWidget(localButton, 0,0);
554 sizeMapDefGroupLayout->addWidget(backgroundButton, 0,1);
555 sizeMapDefGroupLayout->addWidget(constantButton, 0,2);
556 sizeMapDefGroupLayout->addWidget(medFileBackground, 1,0);
557 sizeMapDefGroupLayout->addWidget(selectMedFileBackgroundbutton, 1,1);
558 sizeMapDefGroupLayout->addWidget(selectMedFileBackgroundLineEdit, 1,2);
559 sizeMapDefGroupLayout->addWidget(valueLabel, 2,0);
560 sizeMapDefGroupLayout->addWidget(dvalue, 2,1);
563 sizeMapField = new QGroupBox(tr("SIZE_MAP_FIELD"), this);
564 fieldName = new QLabel(tr("MG_ADAPT_FIELD_NAME"), sizeMapField);
565 fieldNameCmb = new QComboBox(sizeMapField);
566 noTimeStep = new QRadioButton(tr("MG_ADAPT_NO_T_ST"), sizeMapField);
567 lastTimeStep = new QRadioButton(tr("MG_ADAPT_L_ST"), sizeMapField);
568 chosenTimeStep = new QRadioButton(tr("MG_ADAPT_CH_ST"), sizeMapField);
569 timeStepLabel = new QLabel(tr("MG_ADAPT_TSTP"), sizeMapField);
570 timeStep = new QSpinBox(sizeMapField);
571 timeStep->setMinimum(-1);
572 rankLabel = new QLabel(tr("MG_ADAPT_RANK"), sizeMapField);
573 rankSpinBox = new QSpinBox(sizeMapField);
574 rankSpinBox->setMinimum(-1);
576 timeStepGroup = new QButtonGroup(this);
577 timeStepGroup->addButton(noTimeStep, 0);
578 timeStepGroup->addButton(lastTimeStep, 1);
579 timeStepGroup->addButton(chosenTimeStep, 2);
581 sizeMapFieldGroupLayout = new QGridLayout(sizeMapField);
583 sizeMapFieldGroupLayout->addWidget(fieldName, 0,0);
584 sizeMapFieldGroupLayout->addWidget(fieldNameCmb, 0,1);
585 sizeMapFieldGroupLayout->addWidget(noTimeStep, 1,0);
586 sizeMapFieldGroupLayout->addWidget(lastTimeStep, 1,1);
587 sizeMapFieldGroupLayout->addWidget(chosenTimeStep, 1,2);
588 sizeMapFieldGroupLayout->addWidget(timeStepLabel, 2,0);
589 sizeMapFieldGroupLayout->addWidget(timeStep, 2,1);
590 sizeMapFieldGroupLayout->addWidget(rankLabel, 2,2);
591 sizeMapFieldGroupLayout->addWidget(rankSpinBox, 2,3);
593 QGridLayout* argumentsLayout = new QGridLayout( this );
594 argumentsLayout->setMargin( MARGIN );
595 argumentsLayout->setSpacing( SPACING );
597 argumentsLayout->addWidget( aMeshIn, 0, 0, 1, 3 );
598 argumentsLayout->addWidget( aMeshOut, 1, 0, 1, 3 );
599 argumentsLayout->addWidget( sizeMapDefinition, 2, 0, 1, 3 );
600 argumentsLayout->addWidget( sizeMapField, 3, 0, 1, 3 );
601 argumentsLayout->setColumnStretch( 1, 5 );
602 argumentsLayout->setRowStretch( 4, 5 );
605 setMode( Mesh, Local);
606 medFileCheckBox->setChecked(true);
607 visibleTimeStepRankLabel (false);
610 connect( meshInGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( modeChanged( int ) ) );
611 connect( sizeMapDefGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( sizeMapDefChanged( int ) ) );
612 connect( selectMedFilebutton, SIGNAL( pressed( ) ), this, SLOT( onSelectMedFilebuttonClicked( ) ) );
613 connect( medFileCheckBox, SIGNAL (stateChanged(int)), this, SLOT(onMedFileCheckBox(int) ) );
614 connect( publishOut, SIGNAL (stateChanged(int)), this, SLOT(onPublishOut(int) ) );
615 connect( selectOutMedFilebutton, SIGNAL( pressed()), this, SLOT(onSelectOutMedFilebutton()));
616 connect( selectMedFileBackgroundbutton, SIGNAL(pressed()), this, SLOT(onSelectMedFileBackgroundbutton()) );
617 connect( timeStepGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( timeStepGroupChanged( int ) ) );
618 emit updateSelection();
621 //=================================================================================
622 // function : ~SMESHGUI_MgAdaptArguments()
623 // purpose : Destroys the object and frees any allocated resources
624 //=================================================================================
625 SMESHGUI_MgAdaptArguments::~SMESHGUI_MgAdaptArguments()
629 void SMESHGUI_MgAdaptArguments::onNoTimeStep(bool disableOther)
631 noTimeStep->setChecked(true);
633 visibleTimeStepRankLabel (false);
634 rankSpinBox->setValue(-2);
635 timeStep->setValue(-2);
637 lastTimeStep->setDisabled(disableOther);
638 chosenTimeStep->setDisabled(disableOther);
640 void SMESHGUI_MgAdaptArguments::onLastTimeStep(bool disableOther)
642 lastTimeStep->setChecked(true);
644 visibleTimeStepRankLabel (false);
645 rankSpinBox->setValue(-1);
646 timeStep->setValue(-1);
647 noTimeStep->setDisabled(disableOther);
649 void SMESHGUI_MgAdaptArguments::onChosenTimeStep(bool disableOther, int vmax)
651 chosenTimeStep->setChecked(true);
653 visibleTimeStepRankLabel (true);
654 rankSpinBox->setValue(-1);
655 timeStep->setValue(-1);
656 if (vmax) timeStep->setMaximum(vmax);
659 void SMESHGUI_MgAdaptArguments::visibleTimeStepRankLabel(bool visible)
661 rankLabel->setVisible(visible);
662 rankSpinBox->setVisible(visible);
664 timeStepLabel->setVisible(visible);
665 timeStep->setVisible(visible);
668 void SMESHGUI_MgAdaptArguments::onSelectOutMedFilebutton()
671 QString filtre = QString("Med") ;
672 filtre += QString(" files (*.") + QString("med") + QString(");;");
673 QString fileName = QFileDialog::getSaveFileName(this, tr("SAVE_MED"), QString(""), filtre);
674 QFileInfo myFileInfo(fileName);
675 selectOutMedFileLineEdit->setText(myFileInfo.fileName());
676 *myFileOutDir = myFileInfo.path();
679 void SMESHGUI_MgAdaptArguments::onSelectMedFileBackgroundbutton()
681 QString fileName0 = selectMedFileBackgroundbutton->text().trimmed();
683 QString fileName = getMedFileName(false);
684 if (fileName != QString::null)
686 myFieldList = GetListeChamps(fileName);
687 if (myFieldList.empty())
689 fileName = fileName0;
690 fieldNameCmb->clear();
694 // fill field name Combobox
695 fieldNameCmb->clear();
696 std::map<QString, int>::const_iterator it;
697 for ( it=myFieldList.begin() ; it != myFieldList.end(); it++)
699 fieldNameCmb->insertItem(0,QString(it->first));
700 int typeStepInField = it->second > 2 ? 2 : it->second ;
701 timeStepGroupChanged(typeStepInField, false);
707 fileName = fileName0;
708 fieldNameCmb->clear();
711 QFileInfo myFileInfo(fileName);
712 *myFileSizeMapDir = myFileInfo.path();
713 selectMedFileBackgroundLineEdit->setText(myFileInfo.fileName());
716 void SMESHGUI_MgAdaptArguments::onMedFileCheckBox(int state)
718 if (state == Qt::Checked)
720 selectOutMedFilebutton->show();
721 selectOutMedFileLineEdit->show();
722 selectOutMedFilebutton->setEnabled(true);
723 selectOutMedFileLineEdit->setEnabled(true);
727 selectOutMedFilebutton->setEnabled(false);
728 selectOutMedFileLineEdit->setEnabled(false);
729 publishOut->setChecked(true);
732 void SMESHGUI_MgAdaptArguments::onPublishOut(int state)
734 if (state == Qt::Unchecked)
736 medFileCheckBox->setChecked(true);
740 void SMESHGUI_MgAdaptArguments::onSelectMedFilebuttonClicked()
742 // bool keep = false;
743 QString fileName0 = selectMedFileLineEdit->text().trimmed();
745 QString fileName = getMedFileName(false);
746 if(fileName != QString::null)
748 QString aMeshName = lireNomMaillage(fileName.trimmed(), meshDim);
749 if (aMeshName == QString::null )
751 QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
752 QObject::tr("MG_ADAPT_MED_FILE_2") );
753 fileName = fileName0;
757 meshNameLineEdit->setText(aMeshName);
758 ADAPTATION_MODE aMode = meshDim == 3 ? ADAPTATION_MODE::BOTH : ADAPTATION_MODE::SURFACE; // and when dimesh 3 without 2D mesh?
759 emit meshDimSignal(aMode);
767 QFileInfo myFileInfo(fileName);
768 *myFileInDir = myFileInfo.path();
769 *myFileOutDir = myFileInfo.path();
770 selectMedFileLineEdit->setText(myFileInfo.fileName());
771 QString outF = fileName == QString::null ? myFileInfo.fileName() :
772 QString( remove_extension(myFileInfo.fileName().toStdString() ).c_str() )+ QString(".adapt.med");
773 selectOutMedFileLineEdit->setText(outF);
774 onLocalSelected(myFileInfo.filePath());
778 void SMESHGUI_MgAdaptArguments::onLocalSelected(QString filePath)
780 myFieldList = GetListeChamps(filePath, false);
781 if (myFieldList.empty())
783 if (localButton->isChecked())
785 fieldNameCmb->clear();
790 // fill field name Combobox
791 fieldNameCmb->clear();
792 std::map<QString, int>::const_iterator it;
793 for ( it = myFieldList.begin() ; it != myFieldList.end(); it++)
795 fieldNameCmb->insertItem(0,QString(it->first));
796 // Je ne comprends pas le rapport entre pas de temps et apparition d'un nouveau champ... GN
797 int typeStepInField = it->second > 2 ? 2 : it->second ;
798 // std::cout << "SMESHGUI_MgAdaptArguments::onLocalSelected typeStepInField : " << typeStepInField << std::endl;
799 timeStepGroupChanged(typeStepInField, false);
803 // =======================================================================
804 // Gestion les boutons qui permettent de
805 // 1) retourne le nom d'un fichier par une fenetre de dialogue si aucun
806 // objet est selectionne dans l arbre d etude
807 // 2) retourne le nom du fichier asocie a l objet
808 // selectionne dans l arbre d etude
809 // =======================================================================
810 QString SMESHGUI_MgAdaptArguments::getMedFileName(bool avertir)
813 QString aFile = QString::null;
814 QString filtre = QString("Med") ;
815 filtre += QString(" files (*.") + QString("med") + QString(");;");
816 aFile = SUIT_FileDlg::getOpenFileName(0, QObject::tr("MG_ADAPT_SELECT_FILE_0"), QString(""), filtre );
821 void SMESHGUI_MgAdaptArguments::setMode(const Mode theMode, const SIZEMAP theSizeMap )
823 QRadioButton* aButton = qobject_cast<QRadioButton*>( meshInGroup->button( theMode ) );
824 QRadioButton* bButton = qobject_cast<QRadioButton*>( sizeMapDefGroup->button( theSizeMap ) );
827 aButton->setChecked( true );
828 modeChanged( theMode );
832 bButton->setChecked( true );
833 sizeMapDefChanged( theSizeMap );
837 void SMESHGUI_MgAdaptArguments::modeChanged( int theMode )
842 aBrowserObject->hide();
843 selectMedFileLineEdit->show();
844 selectMedFilebutton->show();
845 localButton->setEnabled(true);
849 selectMedFileLineEdit->hide();
850 selectMedFilebutton->hide();
851 localButton->setEnabled(false);
852 aBrowserObject->show();
853 sizeMapDefChanged(Background);
854 emit updateSelection();
858 void SMESHGUI_MgAdaptArguments::sizeMapDefChanged( int theSizeMap )
860 fieldNameCmb->clear();
861 if(theSizeMap == Local)
863 localButton->setEnabled(true);
864 localButton->setChecked(true);
865 medFileBackground->hide();
866 selectMedFileBackgroundbutton->hide();
867 selectMedFileBackgroundLineEdit->hide();
868 selectMedFileBackgroundLineEdit->clear();
872 sizeMapField->setEnabled(true);
873 if (!selectMedFileLineEdit->text().isEmpty())
875 QFileInfo myFileInfo(QDir(*myFileInDir), selectMedFileLineEdit->text());
876 onLocalSelected(myFileInfo.filePath());
879 else if (theSizeMap == Background)
881 medFileBackground->show();
882 backgroundButton->setChecked(true);
883 selectMedFileBackgroundbutton->show();
884 selectMedFileBackgroundLineEdit->show();
887 sizeMapField->setEnabled(true);
892 medFileBackground->hide();
893 constantButton->setChecked(true);
894 selectMedFileBackgroundbutton->hide();
895 selectMedFileBackgroundLineEdit->clear();
896 selectMedFileBackgroundLineEdit->hide();
899 sizeMapField->setEnabled(false);
902 void SMESHGUI_MgAdaptArguments::timeStepGroupChanged(int timeStepType, bool disableOther, int vmax)
904 switch (timeStepType)
907 onNoTimeStep(disableOther);
910 onLastTimeStep(disableOther);
913 onChosenTimeStep(disableOther, vmax);
919 void SMESHGUI_MgAdaptArguments::clear()
921 selectMedFileLineEdit->clear();
922 aBrowserObject->clear();
924 meshNameLineEdit->clear();
925 selectOutMedFileLineEdit->clear();
927 med_int SMESHGUI_MgAdaptArguments::getMeshDim() const
931 QWidget* ItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &o, const QModelIndex &index) const
933 bool editable = index.data( EDITABLE_ROLE ).toInt();
934 return editable ? QItemDelegate::createEditor( parent, o, index ) : 0;
937 //////////////////////////////////////////
939 //////////////////////////////////////////
941 MgAdaptAdvWidget::MgAdaptAdvWidget( QWidget* parent, std::vector <std::string>* options, Qt::WindowFlags f )
942 : QWidget( parent, f ), myOptions(options)
945 myOptionTable->header()->setSectionResizeMode( QHeaderView::ResizeToContents );
946 myOptionTable->setItemDelegate( new ItemDelegate( myOptionTable ) );
948 for ( int i = 0, nb = myOptions->size(); i < nb; ++i )
950 AddOption( (*myOptions)[i].c_str() );
953 connect( myOptionTable, SIGNAL( itemChanged(QTreeWidgetItem *, int)), SLOT( itemChanged(QTreeWidgetItem *, int )));
954 connect( addBtn, SIGNAL(clicked()), this, SLOT( onAddOption() ) );
955 connect(workingDirectoryPushButton, SIGNAL(pressed()), this, SLOT(_onWorkingDirectoryPushButton()));
958 MgAdaptAdvWidget::~MgAdaptAdvWidget()
962 void MgAdaptAdvWidget::AddOption( const char* option, bool isCustom )
965 bool isDefault = false;
968 QStringList name_value_type = QString(option).split( ":", QString::KeepEmptyParts );
969 if ( name_value_type.size() > 0 )
970 name = name_value_type[0];
971 if ( name_value_type.size() > 1 )
972 value = name_value_type[1];
973 if ( name_value_type.size() > 2 )
974 isDefault = !name_value_type[2].toInt();
976 QTreeWidget* table = myOptionTable;
977 //table->setExpanded( true );
979 QTreeWidgetItem* row;
980 if (optionTreeWidgetItem.size())
982 std::map<QString, QTreeWidgetItem *>::iterator it = optionTreeWidgetItem.find(name);
983 if(it != optionTreeWidgetItem.end()) return; // option exist
986 row = getNewQTreeWidgetItem(table, option, name, isCustom);
991 row = getNewQTreeWidgetItem(table, option, name, isCustom);
993 row->setText( 0, tr( name.toLatin1().constData() ));
994 row->setText( 1, tr( value.toLatin1().constData() ));
995 row->setCheckState( 0, isDefault ? Qt::Unchecked : Qt::Checked);
996 row->setData( NAME_COL, PARAM_NAME, name );
1000 myOptionTable->scrollToItem( row );
1001 myOptionTable->setCurrentItem( row );
1002 myOptionTable->editItem( row, NAME_COL );
1006 QTreeWidgetItem* MgAdaptAdvWidget::getNewQTreeWidgetItem(QTreeWidget* table, const char* option, QString& name, bool isCustom)
1008 QTreeWidgetItem* row = new QTreeWidgetItem( table );
1009 row->setData( NAME_COL, EDITABLE_ROLE, int( isCustom && !option ));
1010 row->setFlags( row->flags() | Qt::ItemIsEditable );
1011 optionTreeWidgetItem.insert(std::pair <QString, QTreeWidgetItem*> (name, row));
1016 void MgAdaptAdvWidget::onAddOption()
1018 AddOption( NULL, true );
1020 void MgAdaptAdvWidget::GetOptionAndValue( QTreeWidgetItem * tblRow,
1025 option = tblRow->data( NAME_COL, PARAM_NAME ).toString();
1026 value = tblRow->text( VALUE_COL );
1027 isDefault = ! tblRow->checkState( NAME_COL );
1031 void MgAdaptAdvWidget::itemChanged(QTreeWidgetItem* tblRow, int column)
1035 myOptionTable->blockSignals( true );
1037 tblRow->setData( VALUE_COL, EDITABLE_ROLE, int( tblRow->checkState( NAME_COL )));
1039 int c = tblRow->checkState( NAME_COL ) ? 0 : 150;
1040 tblRow->setForeground( VALUE_COL, QBrush( QColor( c, c, c )));
1042 if ( column == NAME_COL && tblRow->data( NAME_COL, EDITABLE_ROLE ).toInt() ) // custom table
1044 tblRow->setData( NAME_COL, PARAM_NAME, tblRow->text( NAME_COL ));
1047 myOptionTable->blockSignals( false );
1050 void MgAdaptAdvWidget::setupWidget()
1052 if (this->objectName().isEmpty())
1053 this->setObjectName(QString(tr("MG-ADAPT-ADV")));
1054 this->resize(337, 369);
1055 gridLayout_4 = new QGridLayout(this);
1056 gridLayout_4->setObjectName(QString("gridLayout_4"));
1057 myOptionTable = new MgAdaptAdvWidgetTreeWidget(this);
1059 font.setBold(false);
1061 QTreeWidgetItem *__qtreewidgetitem = new QTreeWidgetItem();
1062 __qtreewidgetitem->setFont(1, font);
1063 __qtreewidgetitem->setFont(0, font);
1064 __qtreewidgetitem->setText(1, tr("OPTION_VALUE_COLUMN"));
1065 __qtreewidgetitem->setText(0, tr("OPTION_NAME_COLUMN"));
1066 myOptionTable->setHeaderItem(__qtreewidgetitem);
1067 myOptionTable->setObjectName(QString("myOptionTable"));
1068 myOptionTable->setEditTriggers(QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed);
1069 myOptionTable->setTabKeyNavigation(true);
1071 gridLayout_4->addWidget(myOptionTable, 0, 0, 1, 2);
1073 addBtn = new QPushButton(this);
1074 addBtn->setObjectName(QString("addBtn"));
1076 gridLayout_4->addWidget(addBtn, 1, 0, 1, 1);
1078 horizontalSpacer = new QSpacerItem(188, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
1080 gridLayout_4->addItem(horizontalSpacer, 1, 1, 1, 1);
1082 logGroupBox = new QGroupBox(this);
1083 logGroupBox->setObjectName(QString("logGroupBox"));
1084 gridLayout_2 = new QGridLayout(logGroupBox);
1085 gridLayout_2->setObjectName(QString("gridLayout_2"));
1086 gridLayout = new QGridLayout();
1087 gridLayout->setObjectName(QString("gridLayout"));
1088 workingDirectoryLabel = new QLabel(logGroupBox);
1089 workingDirectoryLabel->setObjectName(QString("workingDirectoryLabel"));
1091 gridLayout->addWidget(workingDirectoryLabel, 0, 0, 1, 1);
1093 workingDirectoryLineEdit = new QLineEdit(logGroupBox);
1094 workingDirectoryLineEdit->setObjectName(QString("workingDirectoryLineEdit"));
1096 gridLayout->addWidget(workingDirectoryLineEdit, 0, 1, 1, 1);
1098 workingDirectoryPushButton = new QPushButton(logGroupBox);
1099 workingDirectoryPushButton->setObjectName(QString("workingDirectoryPushButton"));
1101 gridLayout->addWidget(workingDirectoryPushButton, 0, 2, 1, 1);
1103 verboseLevelLabel = new QLabel(logGroupBox);
1104 verboseLevelLabel->setObjectName(QString("verboseLevelLabel"));
1106 gridLayout->addWidget(verboseLevelLabel, 1, 0, 1, 1);
1108 verboseLevelSpin = new QSpinBox(logGroupBox);
1109 verboseLevelSpin->setObjectName(QString("verboseLevelSpin"));
1111 gridLayout->addWidget(verboseLevelSpin, 1, 1, 1, 1);
1114 gridLayout_2->addLayout(gridLayout, 0, 0, 1, 1);
1116 horizontalLayout = new QHBoxLayout();
1117 horizontalLayout->setObjectName(QString("horizontalLayout"));
1118 logInFileCheck = new QCheckBox(logGroupBox);
1119 logInFileCheck->setObjectName(QString("logInFileCheck"));
1120 logInFileCheck->setChecked(true);
1122 horizontalLayout->addWidget(logInFileCheck);
1124 removeLogOnSuccessCheck = new QCheckBox(logGroupBox);
1125 removeLogOnSuccessCheck->setObjectName(QString("removeLogOnSuccessCheck"));
1126 removeLogOnSuccessCheck->setChecked(true);
1128 horizontalLayout->addWidget(removeLogOnSuccessCheck);
1131 gridLayout_2->addLayout(horizontalLayout, 1, 0, 1, 1);
1133 keepWorkingFilesCheck = new QCheckBox(logGroupBox);
1134 keepWorkingFilesCheck->setObjectName(QString("keepWorkingFilesCheck"));
1135 keepWorkingFilesCheck->setAutoExclusive(false);
1137 gridLayout_2->addWidget(keepWorkingFilesCheck, 2, 0, 1, 1);
1140 gridLayout_4->addWidget(logGroupBox, 3, 0, 1, 2);
1143 void MgAdaptAdvWidget::_onWorkingDirectoryPushButton()
1145 QString aDirName=QFileDialog::getExistingDirectory ();
1146 if (!(aDirName.isEmpty()))workingDirectoryLineEdit->setText(aDirName);
1148 void MgAdaptAdvWidget::onMeshDimChanged(ADAPTATION_MODE aMode)
1150 /* default adaptation mode
1151 * assume that if meshDim == 2 -->adaptation surface
1152 * if meshDim == 3 and if there is not 2D mesh -->VOLUME
1156 QString adaptation("adaptation"), value;
1159 case ADAPTATION_MODE::SURFACE:
1162 setOptionValue(adaptation, value);
1165 case ADAPTATION_MODE::BOTH :
1168 setOptionValue(adaptation, value);
1171 case ADAPTATION_MODE::VOLUME :
1174 setOptionValue(adaptation, value);
1179 void MgAdaptAdvWidget::setOptionValue(QString& option, QString& value)
1181 std::map<QString, QTreeWidgetItem *>::iterator it = optionTreeWidgetItem.find(option);
1182 if (it != optionTreeWidgetItem.end())
1184 it->second->setText( 0, tr( option.toLatin1().constData() ));
1185 it->second->setText( 1, tr( value.toLatin1().constData() ));
1186 it->second->setCheckState( 0, Qt::Checked );
1187 it->second->setData( NAME_COL, PARAM_NAME, option );
1188 myOptionTable->editItem( it->second, NAME_COL );
1193 bool isEditable( const QModelIndex& index )
1195 return index.isValid() &&
1196 index.flags() & Qt::ItemIsEditable &&
1197 index.flags() & Qt::ItemIsEnabled &&
1198 ( !index.data( Qt::UserRole + 1 ).isValid() || index.data( Qt::UserRole + 1 ).toInt() != 0 );
1202 MgAdaptAdvWidgetTreeWidget::MgAdaptAdvWidgetTreeWidget( QWidget* parent )
1203 : QTreeWidget( parent )
1207 QModelIndex MgAdaptAdvWidgetTreeWidget::moveCursor( CursorAction action, Qt::KeyboardModifiers modifiers )
1209 QModelIndex current = currentIndex();
1210 int column = current.column();
1211 if ( action == MoveNext )
1213 if ( column < columnCount()-1 )
1215 QModelIndex next = current.sibling( current.row(), column+1 );
1216 if ( isEditable( next ) ) return next;
1220 QModelIndex next = current.sibling( current.row()+1, 0 );
1221 if ( isEditable( next ) ) return next;
1224 else if ( action == MovePrevious )
1226 if ( column == 0 ) {
1227 QModelIndex next = current.sibling( current.row()-1, columnCount()-1 );
1228 if ( isEditable( next ) ) return next;
1231 QModelIndex next = current.sibling( current.row(), column-1 );
1232 if ( isEditable( next ) ) return next;
1235 return QTreeWidget::moveCursor( action, modifiers );
1238 void MgAdaptAdvWidgetTreeWidget::keyPressEvent( QKeyEvent* e )
1244 QModelIndex index = currentIndex();
1245 if ( !isEditable( index ) ) {
1246 for ( int i = 0; i < columnCount(); i++ ) {
1247 QModelIndex sibling = index.sibling( index.row(), i );
1248 if ( isEditable( sibling ) ) {
1249 if ( !edit( sibling, EditKeyPressed, e ) ) e->ignore();
1258 QTreeWidget::keyPressEvent( e );
1262 // =======================================================================
1263 // renvoie le medId associe au fichier Med apres ouverture
1264 // =======================================================================
1265 med_idt OuvrirFichier(QString aFile)
1267 med_idt medIdt = MEDfileOpen(aFile.toStdString().c_str(),MED_ACC_RDONLY);
1270 QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
1271 QObject::tr("MG_ADAPT_MED_FILE_1") );
1276 // ======================================================
1277 // ========================================================
1278 QString lireNomMaillage(QString aFile, med_int& meshdim)
1280 QString nomMaillage = QString::null ;
1284 // Ouverture du fichier
1285 medIdt = OuvrirFichier(aFile);
1291 med_int numberOfMeshes = MEDnMesh(medIdt) ;
1292 if (numberOfMeshes == 0 )
1294 QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
1295 QObject::tr("MG_ADAPT_MED_FILE_2") );
1299 if (numberOfMeshes > 1 )
1301 QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"),
1302 QObject::tr("MG_ADAPT_MED_FILE_3") );
1307 nomMaillage = lireNomMaillage2(medIdt,1, meshdim);
1308 // Fermeture du fichier
1309 if ( medIdt > 0 ) MEDfileClose(medIdt);
1314 // =======================================================================
1315 // =======================================================================
1316 QString lireNomMaillage2(med_idt medIdt,int meshId, med_int& meshdim )
1318 QString NomMaillage=QString::null;
1319 char meshname[MED_NAME_SIZE+1];
1321 med_mesh_type meshtype;
1322 char descriptionription[MED_COMMENT_SIZE+1];
1323 char dtunit[MED_SNAME_SIZE+1];
1324 med_sorting_type sortingtype;
1326 med_axis_type axistype;
1327 int naxis = MEDmeshnAxis(medIdt,1);
1328 char *axisname=new char[naxis*MED_SNAME_SIZE+1];
1329 char *axisunit=new char[naxis*MED_SNAME_SIZE+1];
1330 med_err aRet = MEDmeshInfo(medIdt,
1345 QMessageBox::critical( 0, QObject::tr("MG_ADAPT_ERROR"), \
1346 QObject::tr("MG_ADAPT_MED_FILE_4") );
1349 NomMaillage=QString(meshname);
1358 // =======================================================================
1359 std::map<QString, int> GetListeChamps(QString aFile, bool errorMessage)
1360 // =======================================================================
1362 // Il faut voir si plusieurs maillages
1364 MESSAGE("GetListeChamps");
1365 std::map<QString, int> ListeChamp ;
1367 med_err erreur = 0 ;
1369 while ( erreur == 0 )
1371 MEDCoupling::MCAuto<MEDCoupling::MEDFileData> mfd = MEDCoupling::MEDFileData::New(aFile.toStdString());
1372 std::vector<std::string> listFieldsNames(mfd->getFields()->getFieldsNames());
1373 std::size_t jaux(listFieldsNames.size());
1378 QMessageBox::critical( 0, QObject::tr("_ERROR"),
1379 QObject::tr("HOM_MED_FILE_5") );
1384 med_int nbofcstp = 1;
1385 for(std::size_t j=0;j<jaux;j++)
1387 // std::cout << listFieldsNames[j] << std::endl;
1388 ListeChamp.insert(std::pair<QString, int> (QString(listFieldsNames[j].c_str()), nbofcstp));
1396 std::string remove_extension(const std::string& filename)
1398 size_t lastdot = filename.find_last_of(".");
1399 if (lastdot == std::string::npos) return filename;
1400 return filename.substr(0, lastdot);