+
+//MEDCALC::ViewModeType
+//MEDModule::getSelectedViewMode() const
+//{
+// return _presentationController->getSelectedViewMode();
+//}
+//
+//MEDCALC::ColorMapType
+//MEDModule::getSelectedColorMap() const
+//{
+// return _presentationController->getSelectedColorMap();
+//}
+//
+//MEDCALC::ScalarBarRangeType
+//MEDModule::getSelectedScalarBarRange() const
+//{
+// return _presentationController->getSelectedScalarBarRange();
+//}
+
+
+/**
+ * Returns presentation name, type and ID from the currently selected presentation in the object
+ * browser.
+ */
+bool
+MEDModule::itemClickGeneric(std::string & name, std::string & type, int & presId) const
+{
+ DataObjectList dol = getApp()->objectBrowser()->getSelected();
+ if (dol.isEmpty())
+ return false;
+ SalomeApp_DataObject* item = dynamic_cast<SalomeApp_DataObject*>(dol[0]);
+ if (!item)
+ return false;
+ SalomeApp_DataModel *model = dynamic_cast<SalomeApp_DataModel*>(dataModel());
+ if (!model)
+ return false;
+
+ if (item->componentDataType().toStdString() != "FIELDS")
+ return false;
+ _PTR(SObject) obj = item->object();
+ _PTR(GenericAttribute) anAttribute;
+
+ if (! obj->FindAttribute(anAttribute, "AttributeName"))
+ return false;
+ _PTR(AttributeName) attrName(anAttribute);
+ name = attrName->Value();
+
+ if (! obj->FindAttribute(anAttribute, "AttributeParameter"))
+ return false;
+ _PTR(AttributeParameter) attrParam(anAttribute);
+ if (! attrParam->IsSet(IS_PRESENTATION, PT_BOOLEAN)
+ || ! attrParam->GetBool(IS_PRESENTATION)) { // Not a presentation
+ return false;
+ }
+// if (!attrParam->IsSet(FIELD_ID, PT_INTEGER))
+// return false;
+// fieldId = attrParam->GetInt(FIELD_ID);
+ if (!attrParam->IsSet(PRESENTATION_ID, PT_INTEGER))
+ return false;
+ presId = attrParam->GetInt(PRESENTATION_ID);
+ if (!attrParam->IsSet(PRESENTATION_TYPE, PT_STRING))
+ return false;
+ type = attrParam->GetString(PRESENTATION_TYPE);
+ return true;
+}
+
+void
+MEDModule::onClick(const QModelIndex & index)
+{
+ int presId;
+ std::string name, type;
+ if (!itemClickGeneric(name, type, presId))
+ {
+ // Not a presentation - clear widget:
+ emit presentationSelected(-1, QString(""), QString(""));
+ return;
+ }
+
+// STDLOG("Presentation selection");
+// std::ostringstream oss;
+// oss << fieldId << " / " << presId;
+// STDLOG(" - Field id / pres id: " + oss.str());
+// STDLOG(" - Presentation type: " + type);
+// STDLOG(" - Presentation name: " + name);
+
+ emit presentationSelected(presId, QString::fromStdString(type), QString::fromStdString(name) ); // caught by PresentationController
+}
+
+void
+MEDModule::onDblClick(const QModelIndex& index)
+{
+ int presId;
+ std::string name, type;
+ if (!itemClickGeneric(name, type, presId))
+ return;
+
+// STDLOG("Presentation double click");
+// STDLOG(" Presentation infos:");
+// STDLOG(" - Component: " + item->componentDataType().toStdString());
+// STDLOG(" - Item entry: " + item->entry().toStdString());
+// STDLOG(" - Item name: " + item->name().toStdString());
+// std::ostringstream oss;
+// oss << fieldId;
+// STDLOG(" - Field id: " + oss.str());
+// STDLOG(" - Presentation name: " + name);
+}
+
+void
+MEDModule::requestSALOMETermination() const
+{
+ STDLOG("Requesting SALOME termination!!");
+ SUIT_Session::session()->closeSession( SUIT_Session::DONT_SAVE, 1 ); // killServers = True
+}
+
+
+//bool MEDModule::hasMainEventLoopStarted() const
+//{
+// return _eventLoopStarted;
+//}
+
+int
+MEDModule::getIntParamFromStudyEditor(SALOMEDS::SObject_var obj, const char* name)
+{
+ if (obj->_is_nil())
+ return -1;
+
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeParameter_var aParam;
+ if ( obj->FindAttribute(anAttr,"AttributeParameter") ) {
+ aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
+ if (aParam->IsSet(name, PT_INTEGER))
+ return aParam->GetInt(name);
+ }
+ return -1;
+}