1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // Author : Guillaume Boulant (EDF)
22 #include "DatasourceController.hxx"
23 #include "DatasourceConstants.hxx"
25 #include "MEDFactoryClient.hxx"
26 #include "QtHelper.hxx"
28 #include CORBA_CLIENT_HEADER(SALOMEDS)
29 #include <SUIT_FileDlg.h>
30 #include <SUIT_Desktop.h>
32 #include <QStringList>
34 #include <QMessageBox>
36 #include "DlgAlias.hxx"
39 // ==============================================================
40 // Datasource controller
41 // ==============================================================
43 DatasourceController::DatasourceController(StandardApp_Module * salomeModule)
44 : _fieldSeriesEntries()
46 STDLOG("Creating a DatasourceController");
47 _salomeModule = salomeModule;
48 _studyEditor = new SALOME_AppStudyEditor(_salomeModule->getApp());
50 _dlgChangeUnderlyingMesh = new DlgChangeUnderlyingMesh(_studyEditor);
51 connect(_dlgChangeUnderlyingMesh,SIGNAL(inputValidated()),
52 this, SLOT(OnChangeUnderlyingMeshInputValidated()));
54 _dlgInterpolateField = new DlgInterpolateField(_studyEditor);
55 connect(_dlgInterpolateField,SIGNAL(inputValidated()),
56 this, SLOT(OnInterpolateFieldInputValidated()));
60 DatasourceController::~DatasourceController() {
61 STDLOG("Deleting the DatasourceController");
65 void DatasourceController::createActions() {
67 // Main actions (toolbar and menubar)
69 QString label = tr("LAB_ADD_DATA_SOURCE");
70 QString tooltip = tr("TIP_ADD_DATA_SOURCE");
71 QString icon = tr("ICO_DATASOURCE_ADD");
73 actionId = _salomeModule->createStandardAction(label,this, SLOT(OnAddDatasource()),icon,tooltip);
74 _salomeModule->addActionInToolbar(actionId);
76 // This action has to be placed in the general file menu with the label "Import MED file"
77 int menuId = _salomeModule->createMenu( tr( "MEN_FILE" ), -1, 1 );
78 _salomeModule->addActionInMenubar(actionId, menuId);
80 label = tr("LAB_ADD_IMAGE_SOURCE");
81 tooltip = tr("TIP_ADD_IMAGE_SOURCE");
82 icon = tr("ICO_IMAGE_ADD");
83 actionId = _salomeModule->createStandardAction(label,this, SLOT(OnAddImagesource()),icon,tooltip);
84 _salomeModule->addActionInToolbar(actionId);
87 // Actions for popup menu only
89 // Expand field timeseries
90 label = tr("LAB_EXPAND_FIELD");
91 icon = tr("ICO_DATASOURCE_EXPAND_FIELD");
92 actionId = _salomeModule->createStandardAction(label,this,SLOT(OnExpandField()),icon);
93 _salomeModule->addActionInPopupMenu(actionId);
95 // Create a view submenu with usual visualization functions
96 label = tr("LAB_VISUALIZE_SCALARMAP");
97 icon = tr("ICO_DATASOURCE_VIEW");
98 actionId = _salomeModule->createStandardAction(label,this,SLOT(OnVisualizeScalarMap()),icon);
99 _salomeModule->addActionInPopupMenu(actionId, tr("LAB_VISUALIZE"));
102 label = tr("LAB_USE_IN_WORKSPACE");
103 icon = tr("ICO_DATASOURCE_USE");
104 actionId = _salomeModule->createStandardAction(label,this,SLOT(OnUseInWorkspace()),icon);
105 _salomeModule->addActionInPopupMenu(actionId);
107 // Change underlying mesh (note that this action creates a new field in
108 // the workspace that corresponds to a copy of the selected field
109 // modified by the change of the underlying mesh.
110 label = tr("LAB_CHANGE_MESH");
111 icon = tr("ICO_DATASOURCE_CHANGE_MESH");
112 actionId = _salomeModule->createStandardAction(label,this,SLOT(OnChangeUnderlyingMesh()),icon);
113 _salomeModule->addActionInPopupMenu(actionId);
115 label = tr("LAB_INTERPOLATE_FIELD");
116 icon = tr("ICO_DATASOURCE_INTERPOLATE_FIELD");
117 actionId = _salomeModule->createStandardAction(label,this,SLOT(OnInterpolateField()),icon);
118 _salomeModule->addActionInPopupMenu(actionId);
122 * This function adds the specified MED file as a datasource in the
123 * dataspace. Technically speaking, the engine loads the
124 * meta-information concerning med data from the file, gives this
125 * informations to the GUI, and the GUI creates a tree view of these
126 * data in the study object browser.
128 // This function emits a signal that will be caught by workspace to delegate command (datasource creation) to python console.
130 DatasourceController::addDatasource(const char* filename)
132 DatasourceEvent* event = new DatasourceEvent();
133 event->eventtype = DatasourceEvent::EVENT_ADD_DATASOURCE;
134 event->objectalias = filename;
135 emit datasourceSignal(event);
137 // After above data source creation, python console emits a signal, forwarded by workspace, to update the GUI
139 DatasourceController::updateTreeViewWithNewDatasource(const MEDCALC::DatasourceHandler* datasourceHandler)
141 if (!datasourceHandler) {
145 // We need a studyEditor updated on the active study
146 _studyEditor->updateActiveStudy();
148 // Create a datasource SObject as a father of the module root
149 SALOMEDS::SComponent_var root = _studyEditor->findRoot(QCHARSTAR(_salomeModule->moduleName()));
150 SALOMEDS::SObject_var soDatasource = _studyEditor->newObject(root);
151 _studyEditor->setName(soDatasource,datasourceHandler->name);
152 _studyEditor->setIcon(soDatasource,tr("ICO_DATASOURCE").toStdString().c_str());
153 _studyEditor->setParameterInt(soDatasource,OBJECT_ID,datasourceHandler->id);
155 // We can add the meshes as children of the datasource
156 MEDCALC::MeshHandlerList * meshHandlerList =
157 MEDFactoryClient::getDataManager()->getMeshList(datasourceHandler->id);
159 for(CORBA::ULong iMesh=0; iMesh<meshHandlerList->length(); iMesh++) {
160 MEDCALC::MeshHandler meshHandler = (*meshHandlerList)[iMesh];
161 SALOMEDS::SObject_var soMesh = _studyEditor->newObject(soDatasource);
162 _studyEditor->setName(soMesh,meshHandler.name);
163 _studyEditor->setIcon(soMesh,tr("ICO_DATASOURCE_MESH").toStdString().c_str());
164 _studyEditor->setParameterInt(soMesh,OBJECT_ID,meshHandler.id);
165 _studyEditor->setParameterBool(soMesh,OBJECT_IS_IN_WORKSPACE,false);
167 // We add the field timeseries defined on this mesh, as children
168 // of the mesh SObject
169 MEDCALC::FieldseriesHandlerList * fieldseriesHandlerList =
170 MEDFactoryClient::getDataManager()->getFieldseriesListOnMesh(meshHandler.id);
172 for(CORBA::ULong iFieldseries=0; iFieldseries<fieldseriesHandlerList->length(); iFieldseries++) {
173 MEDCALC::FieldseriesHandler fieldseriesHandler = (*fieldseriesHandlerList)[iFieldseries];
174 SALOMEDS::SObject_var soFieldseries = _studyEditor->newObject(soMesh);
175 _fieldSeriesEntries[fieldseriesHandler.id] = soFieldseries->GetID();
177 std::string label(fieldseriesHandler.name);
178 label +=" ("+std::string(XmedDataObject::mapTypeOfFieldLabel[fieldseriesHandler.type])+")";
179 _studyEditor->setName(soFieldseries,label.c_str());
181 _studyEditor->setIcon(soFieldseries,tr("ICO_DATASOURCE_FIELD").toStdString().c_str());
182 _studyEditor->setParameterInt(soFieldseries,OBJECT_ID,fieldseriesHandler.id);
183 _studyEditor->setParameterBool(soFieldseries,OBJECT_IS_IN_WORKSPACE,false);
189 DatasourceController::updateTreeViewWithNewPresentation(long fieldId, long presentationId)
191 if (presentationId < 0) {
192 std::cerr << "Unknown presentation\n";
196 if (_fieldSeriesEntries.find(fieldId) == _fieldSeriesEntries.end()) {
197 std::cerr << "Field not found\n";
200 std::string entry = _fieldSeriesEntries[fieldId];
201 SALOMEDS::SObject_ptr soFieldseries = _studyEditor->findObject(entry.c_str());
202 if (soFieldseries->IsNull()) {
203 std::cerr << "Entry not found\n";
207 std::string name = MEDFactoryClient::getPresentationManager()->getPresentationProperty(presentationId, "name");
208 SALOMEDS::SObject_var soPresentation = _studyEditor->newObject(soFieldseries);
209 _studyEditor->setName(soPresentation, tr(name.c_str()).toStdString().c_str());
210 _studyEditor->setIcon(soPresentation, tr("ICO_MED_PRESENTATION").toStdString().c_str());
213 void DatasourceController::OnAddDatasource()
215 // Dialog to get the filename where the input data are read from
217 filter.append(tr("FILE_FILTER_MED"));
219 QString anInitialPath = "";
220 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
221 anInitialPath = QDir::currentPath();
223 QStringList filenames = SUIT_FileDlg::getOpenFileNames( _salomeModule->getApp()->desktop(),
226 tr("IMPORT_MED_FIELDS") );
228 if ( filenames.count() <= 0 ) return;
229 for ( QStringList::ConstIterator itFile = filenames.begin();
230 itFile != filenames.end(); ++itFile ) {
231 QString filename = *itFile;
232 this->addDatasource(QCHARSTAR(filename));
233 _salomeModule->updateObjBrowser(true);
237 #include "DlgImageToMed.hxx"
239 //#include <stdlib.h>
240 void DatasourceController::OnAddImagesource()
243 DlgImageToMed dialog;
244 dialog.setAutoLoaded(true);
245 int choice = dialog.exec();
246 if ( choice == QDialog::Rejected ) {
247 // The user decides to cancel the operation
251 QString imageFilename = dialog.getImageFilepath();
253 QString medFilename = dialog.getMedFilepath();
254 bool autoLoad = dialog.isAutoLoaded();
256 std::string ROOT_DIR(getenv("MED_ROOT_DIR"));
257 std::string command(ROOT_DIR+"/bin/salome/med/image2med.py");
258 command += " -i "+QS2S(imageFilename);
259 command += " -m "+QS2S(medFilename);
260 int error = system(command.c_str());
262 QMessageBox::critical(_salomeModule->getApp()->desktop(),
263 tr("Operation failed"),
264 tr("The creation of med data from the image file failed"));
269 this->addDatasource(QCHARSTAR(medFilename));
270 _salomeModule->updateObjBrowser(true);
274 DatasourceEvent* event = new DatasourceEvent();
275 event->eventtype = DatasourceEvent::EVENT_ADD_IMAGE_AS_DATASOURCE;
276 event->objectalias = imageFilename;
277 emit datasourceSignal(event);
280 void DatasourceController::OnExpandField()
282 // We need a studyEditor updated on the active study
283 _studyEditor->updateActiveStudy();
285 // Get the selected objects in the study (SObject)
286 SALOME_StudyEditor::SObjectList * listOfSObject = _studyEditor->getSelectedObjects();
287 for (int i=0; i<listOfSObject->size(); i++) {
288 SALOMEDS::SObject_var soFieldseries = listOfSObject->at(i);
290 // First retrieve the fieldseries id associated to this study object
291 long fieldseriesId = _studyEditor->getParameterInt(soFieldseries,OBJECT_ID);
292 STDLOG("Expand the field timeseries "<<fieldseriesId);
294 // If fieldseriesId equals -1, then it means that it is not a
295 // fieldseries managed by the MED module, and we stop this
297 if ( fieldseriesId < 0 )
299 // _GBO_ A better correction should be to no display the
300 // contextual menu if the selected object is not conform
302 // Then retrieve the list of fields in this timeseries
303 MEDCALC::FieldHandlerList * fieldHandlerList =
304 MEDFactoryClient::getDataManager()->getFieldListInFieldseries(fieldseriesId);
306 // Finally, create an entry for each of the field
307 for(CORBA::ULong iField=0; iField<fieldHandlerList->length(); iField++) {
308 MEDCALC::FieldHandler fieldHandler = (*fieldHandlerList)[iField];
309 SALOMEDS::SObject_var soField = _studyEditor->newObject(soFieldseries);
310 std::string label("it="); label += ToString(fieldHandler.iteration);
311 _studyEditor->setName(soField,label.c_str());
312 _studyEditor->setParameterInt(soField, OBJECT_ID, fieldHandler.id);
313 _studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,false);
316 _salomeModule->updateObjBrowser(true);
319 void DatasourceController::visualize(DatasourceEvent::EventType eventType) {
320 // We need a _studyEditor updated on the active study
321 _studyEditor->updateActiveStudy();
323 // Get the selected objects in the study (SObject)
324 SALOME_StudyEditor::SObjectList * listOfSObject = _studyEditor->getSelectedObjects();
326 // For each object, emit a signal to the workspace to request a
327 // visualisation using the tui command (so that the user can see how
328 // to make a view of an object from the tui console).
329 for (int i=0; i<listOfSObject->size(); i++) {
330 SALOMEDS::SObject_var soField = listOfSObject->at(i);
331 int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
332 // If fieldId equals -1, then it means that it is not a field
333 // managed by the MED module, and we stop this function process.
337 MEDCALC::FieldHandler * fieldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
338 if (! fieldHandler) {
339 QMessageBox::warning(_salomeModule->getApp()->desktop(),
340 tr("Operation not allowed"),
341 tr("No field is defined"));
345 DatasourceEvent * event = new DatasourceEvent();
346 event->eventtype = eventType;
347 XmedDataObject * dataObject = new XmedDataObject();
348 dataObject->setFieldHandler(*fieldHandler);
349 event->objectdata = dataObject;
350 emit datasourceSignal(event);
354 void DatasourceController::OnVisualizeScalarMap() {
355 this->visualize(DatasourceEvent::EVENT_VIEW_OBJECT_SCALAR_MAP);
358 void DatasourceController::OnUseInWorkspace() {
359 // We need a studyEditor updated on the active study
360 _studyEditor->updateActiveStudy();
362 // Get the selected objects in the study (SObject)
363 SALOME_StudyEditor::SObjectList * listOfSObject = _studyEditor->getSelectedObjects();
364 if ( listOfSObject->size() == 1 ) {
365 // In this case we ask the name of the variable for the python
369 // _GBO_ Note that it works only for a single field but the
370 // XmedDataObject will be improved to deal with mesh, timeseries
371 // and single field in a futur version. We suppose here that a
372 // single field has been selected.
375 SALOMEDS::SObject_var soField = listOfSObject->at(0);
377 bool isInWorkspace = _studyEditor->getParameterBool(soField,OBJECT_IS_IN_WORKSPACE);
378 if ( isInWorkspace ) {
379 QMessageBox::warning(_salomeModule->getApp()->desktop(),
380 tr("Operation not allowed"),
381 tr("This field is already defined in the workspace"));
385 int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
387 // If fieldId equals -1, then it means that it is not a field
388 // managed by the MED module, and we stop this function process.
390 QMessageBox::warning(_salomeModule->getApp()->desktop(),
391 tr("Operation not allowed"),
392 tr("This element is not a field object"));
396 MEDCALC::FieldHandler * fieldHandler =
397 MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
399 if (! fieldHandler) {
400 QMessageBox::warning(_salomeModule->getApp()->desktop(),
401 tr("Operation not allowed"),
402 tr("No field is defined"));
406 QString alias(fieldHandler->fieldname);
408 dialog.setAlias(alias);
409 int choice = dialog.exec();
410 if ( choice == QDialog::Rejected ) {
411 // The user decides to cancel the operation
414 alias = dialog.getAlias();
416 DatasourceEvent * event = new DatasourceEvent();
417 event->eventtype = DatasourceEvent::EVENT_USE_OBJECT;
418 XmedDataObject * dataObject = new XmedDataObject();
419 dataObject->setFieldHandler(*fieldHandler);
420 event->objectdata = dataObject;
421 event->objectalias = alias;
422 emit datasourceSignal(event);
423 // Tag the item to prevent double import
424 // _studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,true);
425 // Tag the field as persistent on the server. It means that a
426 // saving of the workspace will save at least this field (maybe it
427 // should be an option?)
428 MEDFactoryClient::getDataManager()->markAsPersistent(fieldId, true);
431 // In this case, we don't ask the user to specify an alias for
432 // each item, we just import the whole set of items.
433 for (int i=0; i<listOfSObject->size(); i++) {
434 SALOMEDS::SObject_var soField = listOfSObject->at(i);
436 bool isInWorkspace = _studyEditor->getParameterBool(soField,OBJECT_IS_IN_WORKSPACE);
437 if ( !isInWorkspace ) {
438 int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
439 MEDCALC::FieldHandler * fieldHandler =
440 MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
441 DatasourceEvent * event = new DatasourceEvent();
442 event->eventtype = DatasourceEvent::EVENT_IMPORT_OBJECT;
443 XmedDataObject * dataObject = new XmedDataObject();
444 dataObject->setFieldHandler(*fieldHandler);
445 event->objectdata = dataObject;
446 emit datasourceSignal(event);
447 // Note that this signal is processed by the WorkspaceController
449 // Tag the item to prevent double import
450 // _studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,true);
451 // Tag the field as persistent on the server. It means that a
452 // saving of the workspace will save at least this field (maybe it
453 // should be an option?)
454 MEDFactoryClient::getDataManager()->markAsPersistent(fieldId, true);
457 STDLOG("The field "<<_studyEditor->getName(soField)<<
458 " is already defined in the workspace");
464 void DatasourceController::OnChangeUnderlyingMesh() {
465 // We need a studyEditor updated on the active study
466 _studyEditor->updateActiveStudy();
468 // Get the selected objects in the study (SObject). In cas of a
469 // multiple selection, we consider only the first item. At least one
470 // item must be selected.
471 SALOME_StudyEditor::SObjectList * listOfSObject = _studyEditor->getSelectedObjects();
472 if ( listOfSObject->size() > 0 ) {
473 SALOMEDS::SObject_var soField = listOfSObject->at(0);
474 int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
475 // _GBO_ : the dialog should not be modal, so that we can choose a
476 // mesh in the browser. Then we have to emit a signal from the
477 // dialog.accept, connected to a slot of the DatasourceControler
478 _dlgChangeUnderlyingMesh->setFieldId(fieldId);
479 Qt::WindowFlags flags = _dlgChangeUnderlyingMesh->windowFlags();
480 _dlgChangeUnderlyingMesh->setWindowFlags(flags | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint);
481 _dlgChangeUnderlyingMesh->open();
485 void DatasourceController::OnChangeUnderlyingMeshInputValidated() {
486 int meshId = _dlgChangeUnderlyingMesh->getMeshId();
487 STDLOG("meshId = " << ToString(meshId));
488 int fieldId = _dlgChangeUnderlyingMesh->getFieldId();
489 MEDCALC::FieldHandler * fieldHandler =
490 MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
492 // We don't modify the original field but create first a duplicate
493 MEDCALC::FieldHandler * duplicate = MEDFactoryClient::getCalculator()->dup(*fieldHandler);
494 MEDFactoryClient::getDataManager()->changeUnderlyingMesh(duplicate->id, meshId);
496 // Request once more the duplicate to update the meta-data on this
498 duplicate = MEDFactoryClient::getDataManager()->getFieldHandler(duplicate->id);
501 // WARN: the following is a temporary code for test purpose
502 // Automatically add in ws
503 DatasourceEvent * event = new DatasourceEvent();
504 event->eventtype = DatasourceEvent::EVENT_IMPORT_OBJECT;
505 XmedDataObject * dataObject = new XmedDataObject();
506 dataObject->setFieldHandler(*duplicate);
507 event->objectdata = dataObject;
508 emit datasourceSignal(event);
509 // Note that this signal is processed by the WorkspaceController
511 // Tag the item to prevent double import
512 //_studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,true);
515 void DatasourceController::OnInterpolateField() {
516 // We need a studyEditor updated on the active study
517 _studyEditor->updateActiveStudy();
519 // Get the selected objects in the study (SObject). In case of a
520 // multiple selection, we consider only the first item. At least one
521 // item must be selected.
522 SALOME_StudyEditor::SObjectList * listOfSObject = _studyEditor->getSelectedObjects();
523 if ( listOfSObject->size() > 0 ) {
524 SALOMEDS::SObject_var soField = listOfSObject->at(0);
525 int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
526 // _GBO_ : the dialog should not be modal, so that we can choose a
527 // mesh in the browser. Then we have to emit a signal from the
528 // dialog.accept, connected to a slot of the DatasourceControler
529 _dlgInterpolateField->setFieldId(fieldId);
530 Qt::WindowFlags flags = _dlgInterpolateField->windowFlags();
531 _dlgInterpolateField->setWindowFlags(flags | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint);
532 _dlgInterpolateField->open();
536 void DatasourceController::OnInterpolateFieldInputValidated() {
537 MEDCALC::InterpolationParameters params;
538 params.precision = _dlgInterpolateField->getPrecision();
539 STDLOG("precision = " << params.precision);
540 params.defaultValue = _dlgInterpolateField->getDefaultValue();
541 STDLOG("defaultValue = " << params.defaultValue);
542 params.reverse = _dlgInterpolateField->getReverse();
543 STDLOG("reverse = " << params.reverse);
544 params.intersectionType = _dlgInterpolateField->getIntersectionType().c_str();
545 STDLOG("intersectionType = " << params.intersectionType);
546 params.method = _dlgInterpolateField->getMethod().c_str();
547 STDLOG("method = " << params.method);
548 params.nature = _dlgInterpolateField->getFieldNature().c_str();
549 STDLOG("nature = " << params.nature);
551 int meshId = _dlgInterpolateField->getMeshId();
552 STDLOG("meshId = " << ToString(meshId));
553 int fieldId = _dlgInterpolateField->getFieldId();
554 MEDCALC::FieldHandler* fieldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
556 // We don't modify the original field but create first a duplicate
557 // MEDCALC::FieldHandler* duplicate = MEDFactoryClient::getCalculator()->dup(*fieldHandler);
558 //MEDFactoryClient::getDataManager()->changeUnderlyingMesh(duplicate->id, meshId);
559 MEDCALC::FieldHandler* result = NULL;
561 result = MEDFactoryClient::getDataManager()->interpolateField(fieldId, meshId, params);
564 STDLOG("Unable to process field interpolation; please check interpolation parameters");
565 QMessageBox::critical(_salomeModule->getApp()->desktop(),
566 tr("Operation failed"),
567 tr("Unable to process field interpolation; please check interpolation parameters"));
571 // Request once more the duplicate to update the meta-data on this
573 // duplicate = MEDFactoryClient::getDataManager()->getFieldHandler(duplicate->id);
576 // WARN: the following is a temporary code for test purpose
577 // Automatically add in ws
578 DatasourceEvent * event = new DatasourceEvent();
579 event->eventtype = DatasourceEvent::EVENT_IMPORT_OBJECT;
580 XmedDataObject * dataObject = new XmedDataObject();
581 dataObject->setFieldHandler(*result);
582 event->objectdata = dataObject;
583 emit datasourceSignal(event);
584 // Note that this signal is processed by the WorkspaceController
586 // // Tag the item to prevent double import
587 // //_studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,true);
591 DatasourceController::processWorkspaceEvent(const MEDCALC::MedEvent* event)
593 if ( event->type == MEDCALC::EVENT_ADD_DATASOURCE ) {
594 MEDCALC::DatasourceHandler* datasourceHandler = MEDFactoryClient::getDataManager()->getDatasourceHandler(event->filename);
595 this->updateTreeViewWithNewDatasource(datasourceHandler);
596 _salomeModule->updateObjBrowser(true);
598 else if ( event->type == MEDCALC::EVENT_ADD_PRESENTATION ) {
599 this->updateTreeViewWithNewPresentation(event->dataId, event->presentationId);
600 _salomeModule->updateObjBrowser(true);