From 0b1452b15de601cbc30e771a4aac70c3413fb80d Mon Sep 17 00:00:00 2001 From: GERALD NICOLAS Date: Fri, 12 Feb 2021 15:40:12 +0100 Subject: [PATCH] Filtrage des options selon les dimensions --- src/SMESHGUI/MG_ADAPTGUI.cxx | 37 ++++++++++++++++++++++++++++-------- src/SMESHGUI/MG_ADAPTGUI.hxx | 7 ++++--- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/SMESHGUI/MG_ADAPTGUI.cxx b/src/SMESHGUI/MG_ADAPTGUI.cxx index 9fae60140..a449cdd0b 100644 --- a/src/SMESHGUI/MG_ADAPTGUI.cxx +++ b/src/SMESHGUI/MG_ADAPTGUI.cxx @@ -487,6 +487,7 @@ SMESHGUI_MgAdaptArguments::SMESHGUI_MgAdaptArguments( QWidget* parent ) } meshDim = 0; + meshDimBG = 0; // Mesh in aMeshIn = new QGroupBox( tr( "MeshIn" ), this ); aMedfile = new QRadioButton( tr( "MEDFile" ), aMeshIn ); @@ -701,6 +702,10 @@ void SMESHGUI_MgAdaptArguments::onSelectMedFileBackgroundbutton() int typeStepInField = it->second > 2 ? 2 : it->second ; timeStepGroupChanged(typeStepInField, false); } + // Dimension du maillage de fonds + MEDCoupling::MCAuto mfd = MEDCoupling::MEDFileData::New(fileName.toStdString()); + meshDimBG = mfd->getMeshes()->getMeshAtPos(0)->getMeshDimension() ; + valueAdaptation (); } } else @@ -756,8 +761,9 @@ void SMESHGUI_MgAdaptArguments::onSelectMedFilebuttonClicked() else { meshNameLineEdit->setText(aMeshName); - ADAPTATION_MODE aMode = meshDim == 3 ? ADAPTATION_MODE::BOTH : ADAPTATION_MODE::SURFACE; // and when dimesh 3 without 2D mesh? - emit meshDimSignal(aMode); + valueAdaptation (); +// ADAPTATION_MODE aMode = meshDim == 3 ? ADAPTATION_MODE::BOTH : ADAPTATION_MODE::SURFACE; // and when dimesh 3 without 2D mesh? +// emit meshDimSignal(aMode); } } else @@ -776,6 +782,20 @@ void SMESHGUI_MgAdaptArguments::onSelectMedFilebuttonClicked() } +void SMESHGUI_MgAdaptArguments::valueAdaptation() +{ + ADAPTATION_MODE aMode ; + if ( meshDimBG < 3 ) + { + aMode = meshDim == 3 ? ADAPTATION_MODE::BOTH : ADAPTATION_MODE::SURFACE; + } + else + { + aMode = ADAPTATION_MODE::BOTH; + } + emit meshDimSignal(aMode); +} + void SMESHGUI_MgAdaptArguments::onLocalSelected(QString filePath) { myFieldList = GetListeChamps(filePath, false); @@ -886,7 +906,6 @@ void SMESHGUI_MgAdaptArguments::sizeMapDefChanged( int theSizeMap ) valueLabel->hide(); dvalue->hide(); sizeMapField->setEnabled(true); - } else { @@ -899,6 +918,8 @@ void SMESHGUI_MgAdaptArguments::sizeMapDefChanged( int theSizeMap ) dvalue->show(); sizeMapField->setEnabled(false); } + meshDimBG = 0; + valueAdaptation(); } void SMESHGUI_MgAdaptArguments::timeStepGroupChanged(int timeStepType, bool disableOther, int vmax) { @@ -925,10 +946,10 @@ void SMESHGUI_MgAdaptArguments::clear() meshNameLineEdit->clear(); selectOutMedFileLineEdit->clear(); } -med_int SMESHGUI_MgAdaptArguments::getMeshDim() const -{ - return meshDim; -} +// med_int SMESHGUI_MgAdaptArguments::getMeshDim() const +// { +// return meshDim; +// } QWidget* ItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &o, const QModelIndex &index) const { bool editable = index.data( EDITABLE_ROLE ).toInt(); @@ -1149,7 +1170,7 @@ void MgAdaptAdvWidget::_onWorkingDirectoryPushButton() void MgAdaptAdvWidget::onMeshDimChanged(ADAPTATION_MODE aMode) { /* default adaptation mode - * assume that if meshDim == 2 -->adaptation surface + * assume that if meshDim == 2 and no 3D backgrounmesh-->adaptation surface * if meshDim == 3 and if there is not 2D mesh -->VOLUME * else BOTH */ diff --git a/src/SMESHGUI/MG_ADAPTGUI.hxx b/src/SMESHGUI/MG_ADAPTGUI.hxx index 3204a11af..5121d1102 100644 --- a/src/SMESHGUI/MG_ADAPTGUI.hxx +++ b/src/SMESHGUI/MG_ADAPTGUI.hxx @@ -103,8 +103,8 @@ QString lireNomMaillage(QString aFile, med_int& meshDim); std::string remove_extension(const std::string& filename); enum ADAPTATION_MODE{ - SURFACE, // surface adaption when meshDim == 2 - VOLUME, // + SURFACE, + VOLUME, BOTH }; //================================================================================= @@ -164,7 +164,6 @@ public: SMESHGUI_MgAdaptArguments( QWidget* parent); ~SMESHGUI_MgAdaptArguments(); void setMode( const Mode, const SIZEMAP ); - med_int getMeshDim() const; QString* myFileInDir; QString* myFileOutDir; @@ -239,12 +238,14 @@ private slots: void onLastTimeStep(bool disableOther = false); void onChosenTimeStep(bool disableOther = false, int vmax = 0); void visibleTimeStepRankLabel(bool visible); + void valueAdaptation (); private: QString getMedFileName(bool avertir); LightApp_SelectionMgr* selMgr ; med_int meshDim; + med_int meshDimBG; std::map myFieldList; }; -- 2.39.2