-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2019 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 <QTimer>
#include <QMessageBox>
+#include "MEDLoader.hxx"
+using namespace MEDCoupling;
+#include "MEDDataManager_i.hxx"
+
/*!
* This class defines a DockWidget plugged in the SALOME application,
* and containing a tree view for rendering a hierarchical data
effectiveAlias = new QString(alias);
}
- // We can propose to the user to specify some additionnal
- // informations concerning what must be imported.
+ // We can propose to the user to specify some additional
+ // information concerning what must be imported.
//
// In this version, we just ask the alias the field will be
// manipulated with. The default alias is the field name. This alias
else if ( event->type == MEDCALC::EVENT_REMOVE_PRESENTATION ) {
emit workspaceSignal(event); // forward to PresentationController
}
+ else if ( event->type == MEDCALC::EVENT_MODIFY_PRESENTATION ) {
+ emit workspaceSignal(event); // forward to PresentationController
+ }
+ else if ( event->type == MEDCALC::EVENT_CHANGE_UNDERLYING_MESH
+ || event->type == MEDCALC::EVENT_INTERPOLATE_FIELD ) {
+ int fieldId = event->dataId;
+ MEDCALC::FieldHandler* fieldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
+ XmedDataObject* dataObject = new XmedDataObject();
+ dataObject->setFieldHandler(*fieldHandler);
+ std::cout << "IMPORT object in workspace: " << dataObject->toString() << std::endl;
+ STDLOG("IMPORT object in workspace:\n"<<dataObject->toString());
+ // _GBO_ QUESTION: tag automatically the object as a peristant object ??
+ // We first add the data object to the internal data model
+ dataModel->addDataObject(dataObject);
+ // Then we request the tree view to consider this new object
+ this->getDataTreeModel()->addData(dataObject);
+
+ // Workaround to visualize the result
+ MEDCouplingFieldDouble* fieldDouble = MEDDataManager_i::getInstance()->getFieldDouble(fieldHandler);
+ std::string filename = std::tmpnam(NULL);
+ WriteField(filename.c_str(), fieldDouble, true);
+
+ QStringList commands;
+ commands += QString("source_id = medcalc.LoadDataSource('%1')").arg(filename.c_str());
+ commands += QString("source_id");
+ commands += QString("mesh_id = medcalc.GetFirstMeshFromDataSource(source_id)");
+ commands += QString("mesh_id");
+ commands += QString("field_id = medcalc.GetFirstFieldFromMesh(mesh_id)");
+ commands += QString("field_id");
+ commands += QString("presentation_id = medcalc.MakeScalarMap(accessField(field_id), viewMode=MEDCALC.VIEW_MODE_NEW_LAYOUT)");
+ commands += QString("presentation_id");
+ _consoleDriver->exec(commands);
+ }
else if ( event->type == MEDCALC::EVENT_PLAY_TEST ) {
emit workspaceSignal(event); // forward to TestController
}
else if ( event->type == MEDCALC::EVENT_ERROR ) {
std::string msg(event->msg);
QMessageBox::warning(_salomeModule->getApp()->desktop(), "Error", QString::fromStdString(msg));
- }
+ }
+ else
+ STDLOG("WorkspaceController::processMedEvent(): Unhandled event!!!");
}
/*!
.arg(fieldHandler->type)
.arg(fieldHandler->iteration);
*/
- commands += "print 'Not implemented yet'";
+ commands += "print('Not implemented yet')";
_consoleDriver->exec(commands);
}
// generate the scalar map on this field.
QStringList commands;
//commands+=QString("view(accessField(%1))").arg(fieldHandler->id);
- commands += "print 'Not implemented yet'";
+ commands += "print('Not implemented yet')";
_consoleDriver->exec(commands);
}
commands += QString("source_id = medcalc.LoadDataSource('%1')").arg(event->objectalias);
commands += QString("source_id");
_consoleDriver->exec(commands);
+
+ // Create a default presentation when loading a file
+ MEDCALC::MedEvent* evt = new MEDCALC::MedEvent();
+ evt->type = MEDCALC::EVENT_ADD_PRESENTATION;
+ evt->dataId = -1;
+ emit workspaceSignal(evt); // forward to PresentationController
}
else if ( event->eventtype == DatasourceEvent::EVENT_ADD_IMAGE_AS_DATASOURCE ) {
QStringList commands;
return;
}
- // >>>
- // __GBO__ To know what to do we should test the type, because the
- // object could be a mesh, a timeseries or a single field. We test
- // here the case of a single field. Moreover, there could have
- // options such that "change the underlying mesh".
- // <<<
+ int fieldId = event->fieldId;
+ int meshId = event->meshId;
- XmedDataObject* dataObject = event->objectdata;
+ if ( event->eventtype == ProcessingEvent::EVENT_CHANGE_UNDERLYING_MESH ) {
+ QStringList commands;
+ commands += QString("result_id = medcalc.ChangeUnderlyingMesh(fieldId=%1,meshId=%2)").arg(fieldId).arg(meshId);
+ commands += QString("result_id");
+ _consoleDriver->exec(commands);
+ }
+ else if ( event->eventtype == ProcessingEvent::EVENT_INTERPOLATE_FIELD ) {
+ MEDCALC::InterpolationParameters params = event->interpParams;
+ QString method = QString(params.method);
+ QString nature = QString(params.nature);
+ QString intersectionType = QString(params.intersectionType);
- if ( event->eventtype == ProcessingEvent::EVENT_IMPORT_OBJECT ) {
- std::cout << "IMPORT object in workspace: " << dataObject->toString() << std::endl;
- STDLOG("IMPORT object in workspace:\n"<<dataObject->toString());
- // _GBO_ QUESTION: tag automatically the object as a peristant object ??
- // We first add the data object to the internal data model
- dataModel->addDataObject(dataObject);
- // Then we request the tree view to consider this new object
- this->getDataTreeModel()->addData(dataObject);
+ QStringList commands;
+ commands += QString("result_id = medcalc.InterpolateField(fieldId=%1,meshId=%2,precision=%3,defaultValue=%4,reverse=%5,method='%6',nature='%7',intersectionType='%8')").arg(fieldId).arg(meshId).arg(params.precision).arg(params.defaultValue).arg(params.reverse).arg(method).arg(nature).arg(intersectionType);
+ commands += QString("result_id");
+ _consoleDriver->exec(commands);
}
}