Salome HOME
Merge 'abn/V8_1_fix' branch into V8_1_BR.
[modules/med.git] / src / MEDCalc / gui / ProcessingController.cxx
index 35cdb73953cc1e143ce60d1f9347f5915f0984b0..d78eacd61f4fa7395470bfa3abff3ae4df7088bf 100644 (file)
 //
 
 #include "ProcessingController.hxx"
-#include "DatasourceConstants.hxx"
+#include <MEDCalcConstants.hxx>
+
+#include <SALOMEDS_SObject.hxx>
+#include <SALOMEDS_Study.hxx>
+#include CORBA_CLIENT_HEADER(SALOMEDS)
+#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
 
 #include "MEDFactoryClient.hxx"
 #include "MEDModule.hxx"
@@ -53,7 +58,7 @@ ProcessingController::createActions()
   STDLOG("Creating ProcessingController actions");
 
   int processingToolbarId = _salomeModule->createTool("Processing", "ProcessingToolbar");
-  int processingMenuId = _salomeModule->createMenu(tr("MENU_PROCESSING"), -1, 1);
+  int processingMenuId = _salomeModule->createMenu(tr("MENU_PROCESSING"), -1, -1, 12);
 
   // Change underlying mesh (note that this action creates a new field in
   // the workspace that corresponds to a copy of the selected field
@@ -86,7 +91,17 @@ ProcessingController::OnChangeUnderlyingMesh()
   SALOME_StudyEditor::SObjectList* listOfSObject = _studyEditor->getSelectedObjects();
   if ( listOfSObject->size() > 0 ) {
     SALOMEDS::SObject_var soField = listOfSObject->at(0);
-    int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
+    std::string name(_studyEditor->getName(soField));
+    if (soField->_is_nil() || name == "MEDCalc")
+      return;
+    SALOMEDS::GenericAttribute_var anAttr;
+    SALOMEDS::AttributeParameter_var aParam;
+    if ( soField->FindAttribute(anAttr,"AttributeParameter") ) {
+      aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
+      if (! aParam->IsSet(FIELD_SERIES_ID, PT_INTEGER))
+        return;
+    }
+    int fieldId = aParam->GetInt(FIELD_SERIES_ID);
     // _GBO_ : the dialog should not be modal, so that we can choose a
     // mesh in the browser. Then we have to emit a signal from the
     // dialog.accept, connected to a slot of the DatasourceControler
@@ -141,7 +156,17 @@ ProcessingController::OnInterpolateField()
   SALOME_StudyEditor::SObjectList* listOfSObject = _studyEditor->getSelectedObjects();
   if ( listOfSObject->size() > 0 ) {
     SALOMEDS::SObject_var soField = listOfSObject->at(0);
-    int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
+    std::string name(_studyEditor->getName(soField));
+    if (soField->_is_nil() || name == "MEDCalc")
+      return;
+    SALOMEDS::GenericAttribute_var anAttr;
+    SALOMEDS::AttributeParameter_var aParam;
+    if ( soField->FindAttribute(anAttr,"AttributeParameter") ) {
+      aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
+      if (! aParam->IsSet(FIELD_SERIES_ID, PT_INTEGER))
+        return;
+    }
+    int fieldId = aParam->GetInt(FIELD_SERIES_ID);
     // _GBO_ : the dialog should not be modal, so that we can choose a
     // mesh in the browser. Then we have to emit a signal from the
     // dialog.accept, connected to a slot of the DatasourceControler