Salome HOME
Copyright update 2022
[modules/med.git] / src / MEDCalc / gui / dialogs / DlgInterpolateField.cxx
index 4ef53c6f2ec3b36cfbb94bec799a0d93e348eaee..e8409c67e1c9b13c9e9656354b1c53add5b54e13 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2015-2016  CEA/DEN, EDF R&D
+// Copyright (C) 2015-2022  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 #include "DlgInterpolateField.hxx"
 #include <MEDCalcConstants.hxx>
 
+#include <SALOMEDS_SObject.hxx>
+#include <SALOMEDS_Study.hxx>
+#include CORBA_CLIENT_HEADER(SALOMEDS)
+#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
+
 #include <QString>
 #include <QMessageBox>
 #include <QDoubleValidator>
@@ -113,9 +118,17 @@ void DlgInterpolateField::OnSelectMesh() {
   SALOME_StudyEditor::SObjectList * listOfSObject = _studyEditor->getSelectedObjects();
   if ( listOfSObject->size() > 0 ) {
     SALOMEDS::SObject_var soMesh = listOfSObject->at(0);
-    // _GBO_ TODO: we should test here if it is a mesh (attribute in
-    // the sobject)
-    _meshId = _studyEditor->getParameterInt(soMesh,MESH_ID);
+    std::string name(_studyEditor->getName(soMesh));
+    if (soMesh->_is_nil() || name == "MEDCalc")
+      return;
+    SALOMEDS::GenericAttribute_var anAttr;
+    SALOMEDS::AttributeParameter_var aParam;
+    if ( soMesh->FindAttribute(anAttr,"AttributeParameter") ) {
+      aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
+      if (! aParam->IsSet(MESH_ID, PT_INTEGER))
+        return;
+    }
+    _meshId = aParam->GetInt(MESH_ID);
     const char * meshname = _studyEditor->getName(soMesh);
     this->ui.txtMesh->setText(QString(meshname));
   }