1 // Copyright (C) 2007-2016 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 <SalomeApp_Application.h>
26 #include <SalomeApp_Study.h>
27 #include <SalomeApp_DataObject.h>
29 #include <SALOME_ListIO.hxx>
30 #include <LightApp_SelectionMgr.h>
32 #include <SALOME_LifeCycleCORBA.hxx>
33 #include <SALOMEDS_SObject.hxx>
34 #include <SALOMEDS_Study.hxx>
36 #include "MEDFactoryClient.hxx"
37 #include "MEDModule.hxx"
38 #include "QtHelper.hxx"
40 #include CORBA_CLIENT_HEADER(SALOMEDS)
41 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
42 #include <SUIT_FileDlg.h>
43 #include <SUIT_Desktop.h>
45 #include <QStringList>
47 #include <QMessageBox>
49 #include "DlgAlias.hxx"
52 // ==============================================================
53 // Datasource controller
54 // ==============================================================
56 //DatasourceController::DatasourceController(StandardApp_Module * salomeModule)
57 DatasourceController::DatasourceController(MEDModule * salomeModule)
59 STDLOG("Creating a DatasourceController");
60 _salomeModule = salomeModule;
61 _studyEditor = new SALOME_AppStudyEditor(_salomeModule->getApp());
63 _dlgChangeUnderlyingMesh = new DlgChangeUnderlyingMesh(_studyEditor);
64 connect(_dlgChangeUnderlyingMesh,SIGNAL(inputValidated()),
65 this, SLOT(OnChangeUnderlyingMeshInputValidated()));
67 _dlgInterpolateField = new DlgInterpolateField(_studyEditor);
68 connect(_dlgInterpolateField,SIGNAL(inputValidated()),
69 this, SLOT(OnInterpolateFieldInputValidated()));
73 DatasourceController::~DatasourceController() {
74 STDLOG("Deleting the DatasourceController");
78 void DatasourceController::createActions() {
79 //QWidget* dsk = _salomeModule->getApp()->desktop();
80 //SUIT_ResourceMgr* resMgr = _salomeModule->getApp()->resourceMgr();
81 int toolbarId = _salomeModule->createTool("Datasource", "DatasourceToolbar");
84 // Main actions (toolbar and menubar)
86 QString label = tr("LAB_ADD_DATA_SOURCE");
87 QString tooltip = tr("TIP_ADD_DATA_SOURCE");
88 QString icon = tr("ICO_DATASOURCE_ADD");
90 actionId = _salomeModule->createStandardAction(label,this, SLOT(OnAddDatasource()),icon,tooltip);
91 //_salomeModule->addActionInToolbar(actionId);
92 _salomeModule->createTool(actionId, toolbarId);
94 // This action has to be placed in the general file menu with the label "Import MED file"
95 int menuId = _salomeModule->createMenu( tr( "MEN_FILE" ), -1, 1 );
96 //_salomeModule->addActionInMenubar(actionId, menuId);
97 _salomeModule->action(actionId)->setIconVisibleInMenu(true);
98 _salomeModule->createMenu(actionId, menuId, 10);
100 label = tr("LAB_ADD_IMAGE_SOURCE");
101 tooltip = tr("TIP_ADD_IMAGE_SOURCE");
102 icon = tr("ICO_IMAGE_ADD");
103 actionId = _salomeModule->createStandardAction(label,this, SLOT(OnAddImagesource()),icon,tooltip);
104 // _salomeModule->addActionInToolbar(actionId);
105 _salomeModule->createTool(actionId, toolbarId);
108 // Actions for popup menu only
110 // Expand field timeseries
111 label = tr("LAB_EXPAND_FIELD");
112 icon = tr("ICO_DATASOURCE_EXPAND_FIELD");
113 actionId = _salomeModule->createStandardAction(label,this,SLOT(OnExpandField()),icon);
114 _salomeModule->addActionInPopupMenu(actionId);
116 // Create a view submenu with usual visualization functions
117 label = tr("LAB_VISUALIZE_SCALARMAP");
118 icon = tr("ICO_DATASOURCE_VIEW");
119 actionId = _salomeModule->createStandardAction(label,this,SLOT(OnVisualizeScalarMap()),icon);
120 _salomeModule->addActionInPopupMenu(actionId, tr("LAB_VISUALIZE"));
122 label = tr("LAB_VISUALIZE_CONTOUR");
123 icon = tr("ICO_DATASOURCE_VIEW");
124 actionId = _salomeModule->createStandardAction(label,this,SLOT(OnVisualizeContour()),icon);
125 _salomeModule->addActionInPopupMenu(actionId, tr("LAB_VISUALIZE"));
127 label = tr("LAB_VISUALIZE_VECTORFIELD");
128 icon = tr("ICO_DATASOURCE_VIEW");
129 actionId = _salomeModule->createStandardAction(label,this,SLOT(OnVisualizeVectorField()),icon);
130 _salomeModule->addActionInPopupMenu(actionId, tr("LAB_VISUALIZE"));
132 label = tr("LAB_VISUALIZE_SLICES");
133 icon = tr("ICO_DATASOURCE_VIEW");
134 actionId = _salomeModule->createStandardAction(label,this,SLOT(OnVisualizeSlices()),icon);
135 _salomeModule->addActionInPopupMenu(actionId, tr("LAB_VISUALIZE"));
137 label = tr("LAB_VISUALIZE_DEFLECTIONSHAPE");
138 icon = tr("ICO_DATASOURCE_VIEW");
139 actionId = _salomeModule->createStandardAction(label,this,SLOT(OnVisualizeDeflectionShape()),icon);
140 _salomeModule->addActionInPopupMenu(actionId, tr("LAB_VISUALIZE"));
142 label = tr("LAB_VISUALIZE_POINTSPRITE");
143 icon = tr("ICO_DATASOURCE_VIEW");
144 actionId = _salomeModule->createStandardAction(label,this,SLOT(OnVisualizePointSprite()),icon);
145 _salomeModule->addActionInPopupMenu(actionId, tr("LAB_VISUALIZE"));
148 label = tr("LAB_USE_IN_WORKSPACE");
149 icon = tr("ICO_DATASOURCE_USE");
150 actionId = _salomeModule->createStandardAction(label,this,SLOT(OnUseInWorkspace()),icon);
151 _salomeModule->addActionInPopupMenu(actionId);
153 // Change underlying mesh (note that this action creates a new field in
154 // the workspace that corresponds to a copy of the selected field
155 // modified by the change of the underlying mesh.
156 label = tr("LAB_CHANGE_MESH");
157 icon = tr("ICO_DATASOURCE_CHANGE_MESH");
158 actionId = _salomeModule->createStandardAction(label,this,SLOT(OnChangeUnderlyingMesh()),icon);
159 _salomeModule->addActionInPopupMenu(actionId);
161 label = tr("LAB_INTERPOLATE_FIELD");
162 icon = tr("ICO_DATASOURCE_INTERPOLATE_FIELD");
163 actionId = _salomeModule->createStandardAction(label,this,SLOT(OnInterpolateField()),icon);
164 _salomeModule->addActionInPopupMenu(actionId);
168 * This function adds the specified MED file as a datasource in the
169 * dataspace. Technically speaking, the engine loads the
170 * meta-information concerning med data from the file, gives this
171 * informations to the GUI, and the GUI creates a tree view of these
172 * data in the study object browser.
174 // This function emits a signal that will be caught by workspace to delegate command (datasource creation) to python console.
176 DatasourceController::addDatasource(const char* filename)
178 DatasourceEvent* event = new DatasourceEvent();
179 event->eventtype = DatasourceEvent::EVENT_ADD_DATASOURCE;
180 event->objectalias = filename;
181 emit datasourceSignal(event);
183 // After above data source creation, python console emits a signal, forwarded by workspace, to update the GUI
185 DatasourceController::updateTreeViewWithNewDatasource(const MEDCALC::DatasourceHandler* datasourceHandler)
187 if (!datasourceHandler) {
191 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(_salomeModule->application()->activeStudy());
192 _PTR(Study) studyDS = study->studyDS();
194 _salomeModule->engine()->addDatasourceToStudy(_CAST(Study, studyDS)->GetStudy(), *datasourceHandler);
196 // update Object browser
197 _salomeModule->getApp()->updateObjectBrowser(true);
201 DatasourceController::updateTreeViewWithNewPresentation(long fieldId, long presentationId)
203 if (presentationId < 0) {
204 std::cerr << "Unknown presentation\n";
208 std::string name = MEDFactoryClient::getPresentationManager()->getPresentationProperty(presentationId, "name");
209 name = tr(name.c_str()).toStdString();
210 std::string label = tr("ICO_MED_PRESENTATION").toStdString();
212 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(_salomeModule->application()->activeStudy());
213 _PTR(Study) studyDS = study->studyDS();
215 _salomeModule->engine()->registerPresentation(_CAST(Study, studyDS)->GetStudy(), fieldId, name.c_str(), label.c_str());
217 // update Object browser
218 _salomeModule->getApp()->updateObjectBrowser(true);
221 void DatasourceController::OnAddDatasource()
223 // Dialog to get the filename where the input data are read from
225 filter.append(tr("FILE_FILTER_MED"));
227 QString anInitialPath = "";
228 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
229 anInitialPath = QDir::currentPath();
231 QStringList filenames = SUIT_FileDlg::getOpenFileNames( _salomeModule->getApp()->desktop(),
234 tr("IMPORT_MED_FIELDS") );
236 if ( filenames.count() <= 0 ) return;
237 for ( QStringList::ConstIterator itFile = filenames.begin();
238 itFile != filenames.end(); ++itFile ) {
239 QString filename = *itFile;
240 this->addDatasource(QCHARSTAR(filename));
241 _salomeModule->updateObjBrowser(true);
245 #include "DlgImageToMed.hxx"
247 //#include <stdlib.h>
248 void DatasourceController::OnAddImagesource()
251 DlgImageToMed dialog;
252 dialog.setAutoLoaded(true);
253 int choice = dialog.exec();
254 if ( choice == QDialog::Rejected ) {
255 // The user decides to cancel the operation
259 QString imageFilename = dialog.getImageFilepath();
261 QString medFilename = dialog.getMedFilepath();
262 bool autoLoad = dialog.isAutoLoaded();
264 std::string ROOT_DIR(getenv("MED_ROOT_DIR"));
265 std::string command(ROOT_DIR+"/bin/salome/med/image2med.py");
266 command += " -i "+QS2S(imageFilename);
267 command += " -m "+QS2S(medFilename);
268 int error = system(command.c_str());
270 QMessageBox::critical(_salomeModule->getApp()->desktop(),
271 tr("Operation failed"),
272 tr("The creation of med data from the image file failed"));
277 this->addDatasource(QCHARSTAR(medFilename));
278 _salomeModule->updateObjBrowser(true);
282 DatasourceEvent* event = new DatasourceEvent();
283 event->eventtype = DatasourceEvent::EVENT_ADD_IMAGE_AS_DATASOURCE;
284 event->objectalias = imageFilename;
285 emit datasourceSignal(event);
288 void DatasourceController::OnExpandField()
290 // We need a studyEditor updated on the active study
291 _studyEditor->updateActiveStudy();
293 // Get the selected objects in the study (SObject)
294 SALOME_StudyEditor::SObjectList * listOfSObject = _studyEditor->getSelectedObjects();
295 for (int i=0; i<listOfSObject->size(); i++) {
296 SALOMEDS::SObject_var soFieldseries = listOfSObject->at(i);
298 // First retrieve the fieldseries id associated to this study object
299 long fieldseriesId = _studyEditor->getParameterInt(soFieldseries,OBJECT_ID);
300 STDLOG("Expand the field timeseries "<<fieldseriesId);
302 // If fieldseriesId equals -1, then it means that it is not a
303 // fieldseries managed by the MED module, and we stop this
305 if ( fieldseriesId < 0 )
307 // _GBO_ A better correction should be to no display the
308 // contextual menu if the selected object is not conform
310 // Then retrieve the list of fields in this timeseries
311 MEDCALC::FieldHandlerList * fieldHandlerList =
312 MEDFactoryClient::getDataManager()->getFieldListInFieldseries(fieldseriesId);
314 // Finally, create an entry for each of the field
315 for(CORBA::ULong iField=0; iField<fieldHandlerList->length(); iField++) {
316 MEDCALC::FieldHandler fieldHandler = (*fieldHandlerList)[iField];
317 SALOMEDS::SObject_var soField = _studyEditor->newObject(soFieldseries);
318 std::string label("it="); label += ToString(fieldHandler.iteration);
319 _studyEditor->setName(soField,label.c_str());
320 _studyEditor->setParameterInt(soField, OBJECT_ID, fieldHandler.id);
321 _studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,false);
324 _salomeModule->updateObjBrowser(true);
327 void DatasourceController::visualize(DatasourceEvent::EventType eventType) {
328 // We need a _studyEditor updated on the active study
329 _studyEditor->updateActiveStudy();
331 // Get the selected objects in the study (SObject)
332 SALOME_StudyEditor::SObjectList * listOfSObject = _studyEditor->getSelectedObjects();
334 // For each object, emit a signal to the workspace to request a
335 // visualisation using the tui command (so that the user can see how
336 // to make a view of an object from the tui console).
337 for (int i=0; i<listOfSObject->size(); i++) {
338 SALOMEDS::SObject_var soField = listOfSObject->at(i);
339 int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
340 // If fieldId equals -1, then it means that it is not a field
341 // managed by the MED module, and we stop this function process.
345 MEDCALC::FieldHandler * fieldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
346 if (! fieldHandler) {
347 QMessageBox::warning(_salomeModule->getApp()->desktop(),
348 tr("Operation not allowed"),
349 tr("No field is defined"));
353 DatasourceEvent * event = new DatasourceEvent();
354 event->eventtype = eventType;
355 XmedDataObject * dataObject = new XmedDataObject();
356 dataObject->setFieldHandler(*fieldHandler);
357 event->objectdata = dataObject;
358 emit datasourceSignal(event);
362 void DatasourceController::OnVisualizeScalarMap() {
363 this->visualize(DatasourceEvent::EVENT_VIEW_OBJECT_SCALAR_MAP);
366 void DatasourceController::OnVisualizeContour() {
367 this->visualize(DatasourceEvent::EVENT_VIEW_OBJECT_CONTOUR);
370 void DatasourceController::OnVisualizeVectorField() {
371 this->visualize(DatasourceEvent::EVENT_VIEW_OBJECT_VECTOR_FIELD);
374 void DatasourceController::OnVisualizeSlices() {
375 this->visualize(DatasourceEvent::EVENT_VIEW_OBJECT_SLICES);
378 void DatasourceController::OnVisualizeDeflectionShape() {
379 this->visualize(DatasourceEvent::EVENT_VIEW_OBJECT_DEFLECTION_SHAPE);
382 void DatasourceController::OnVisualizePointSprite() {
383 this->visualize(DatasourceEvent::EVENT_VIEW_OBJECT_POINT_SPRITE);
386 void DatasourceController::OnUseInWorkspace() {
387 // We need a studyEditor updated on the active study
388 _studyEditor->updateActiveStudy();
390 // Get the selected objects in the study (SObject)
391 SALOME_StudyEditor::SObjectList * listOfSObject = _studyEditor->getSelectedObjects();
392 if ( listOfSObject->size() == 1 ) {
393 // In this case we ask the name of the variable for the python
397 // _GBO_ Note that it works only for a single field but the
398 // XmedDataObject will be improved to deal with mesh, timeseries
399 // and single field in a futur version. We suppose here that a
400 // single field has been selected.
403 SALOMEDS::SObject_var soField = listOfSObject->at(0);
405 bool isInWorkspace = _studyEditor->getParameterBool(soField,OBJECT_IS_IN_WORKSPACE);
406 if ( isInWorkspace ) {
407 QMessageBox::warning(_salomeModule->getApp()->desktop(),
408 tr("Operation not allowed"),
409 tr("This field is already defined in the workspace"));
413 int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
415 // If fieldId equals -1, then it means that it is not a field
416 // managed by the MED module, and we stop this function process.
418 QMessageBox::warning(_salomeModule->getApp()->desktop(),
419 tr("Operation not allowed"),
420 tr("This element is not a field object"));
424 MEDCALC::FieldHandler * fieldHandler =
425 MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
427 if (! fieldHandler) {
428 QMessageBox::warning(_salomeModule->getApp()->desktop(),
429 tr("Operation not allowed"),
430 tr("No field is defined"));
434 QString alias(fieldHandler->fieldname);
436 dialog.setAlias(alias);
437 int choice = dialog.exec();
438 if ( choice == QDialog::Rejected ) {
439 // The user decides to cancel the operation
442 alias = dialog.getAlias();
444 DatasourceEvent * event = new DatasourceEvent();
445 event->eventtype = DatasourceEvent::EVENT_USE_OBJECT;
446 XmedDataObject * dataObject = new XmedDataObject();
447 dataObject->setFieldHandler(*fieldHandler);
448 event->objectdata = dataObject;
449 event->objectalias = alias;
450 emit datasourceSignal(event);
451 // Tag the item to prevent double import
452 // _studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,true);
453 // Tag the field as persistent on the server. It means that a
454 // saving of the workspace will save at least this field (maybe it
455 // should be an option?)
456 MEDFactoryClient::getDataManager()->markAsPersistent(fieldId, true);
459 // In this case, we don't ask the user to specify an alias for
460 // each item, we just import the whole set of items.
461 for (int i=0; i<listOfSObject->size(); i++) {
462 SALOMEDS::SObject_var soField = listOfSObject->at(i);
464 bool isInWorkspace = _studyEditor->getParameterBool(soField,OBJECT_IS_IN_WORKSPACE);
465 if ( !isInWorkspace ) {
466 int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
467 MEDCALC::FieldHandler * fieldHandler =
468 MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
469 DatasourceEvent * event = new DatasourceEvent();
470 event->eventtype = DatasourceEvent::EVENT_IMPORT_OBJECT;
471 XmedDataObject * dataObject = new XmedDataObject();
472 dataObject->setFieldHandler(*fieldHandler);
473 event->objectdata = dataObject;
474 emit datasourceSignal(event);
475 // Note that this signal is processed by the WorkspaceController
477 // Tag the item to prevent double import
478 // _studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,true);
479 // Tag the field as persistent on the server. It means that a
480 // saving of the workspace will save at least this field (maybe it
481 // should be an option?)
482 MEDFactoryClient::getDataManager()->markAsPersistent(fieldId, true);
485 STDLOG("The field "<<_studyEditor->getName(soField)<<
486 " is already defined in the workspace");
492 void DatasourceController::OnChangeUnderlyingMesh() {
493 // We need a studyEditor updated on the active study
494 _studyEditor->updateActiveStudy();
496 // Get the selected objects in the study (SObject). In cas of a
497 // multiple selection, we consider only the first item. At least one
498 // item must be selected.
499 SALOME_StudyEditor::SObjectList * listOfSObject = _studyEditor->getSelectedObjects();
500 if ( listOfSObject->size() > 0 ) {
501 SALOMEDS::SObject_var soField = listOfSObject->at(0);
502 int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
503 // _GBO_ : the dialog should not be modal, so that we can choose a
504 // mesh in the browser. Then we have to emit a signal from the
505 // dialog.accept, connected to a slot of the DatasourceControler
506 _dlgChangeUnderlyingMesh->setFieldId(fieldId);
507 Qt::WindowFlags flags = _dlgChangeUnderlyingMesh->windowFlags();
508 _dlgChangeUnderlyingMesh->setWindowFlags(flags | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint);
509 _dlgChangeUnderlyingMesh->open();
513 void DatasourceController::OnChangeUnderlyingMeshInputValidated() {
514 int meshId = _dlgChangeUnderlyingMesh->getMeshId();
515 STDLOG("meshId = " << ToString(meshId));
516 int fieldId = _dlgChangeUnderlyingMesh->getFieldId();
517 MEDCALC::FieldHandler * fieldHandler =
518 MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
520 // We don't modify the original field but create first a duplicate
521 MEDCALC::FieldHandler * duplicate = MEDFactoryClient::getCalculator()->dup(*fieldHandler);
522 MEDFactoryClient::getDataManager()->changeUnderlyingMesh(duplicate->id, meshId);
524 // Request once more the duplicate to update the meta-data on this
526 duplicate = MEDFactoryClient::getDataManager()->getFieldHandler(duplicate->id);
529 // WARN: the following is a temporary code for test purpose
530 // Automatically add in ws
531 DatasourceEvent * event = new DatasourceEvent();
532 event->eventtype = DatasourceEvent::EVENT_IMPORT_OBJECT;
533 XmedDataObject * dataObject = new XmedDataObject();
534 dataObject->setFieldHandler(*duplicate);
535 event->objectdata = dataObject;
536 emit datasourceSignal(event);
537 // Note that this signal is processed by the WorkspaceController
539 // Tag the item to prevent double import
540 //_studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,true);
543 void DatasourceController::OnInterpolateField() {
544 // We need a studyEditor updated on the active study
545 _studyEditor->updateActiveStudy();
547 // Get the selected objects in the study (SObject). In case of a
548 // multiple selection, we consider only the first item. At least one
549 // item must be selected.
550 SALOME_StudyEditor::SObjectList * listOfSObject = _studyEditor->getSelectedObjects();
551 if ( listOfSObject->size() > 0 ) {
552 SALOMEDS::SObject_var soField = listOfSObject->at(0);
553 int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
554 // _GBO_ : the dialog should not be modal, so that we can choose a
555 // mesh in the browser. Then we have to emit a signal from the
556 // dialog.accept, connected to a slot of the DatasourceControler
557 _dlgInterpolateField->setFieldId(fieldId);
558 Qt::WindowFlags flags = _dlgInterpolateField->windowFlags();
559 _dlgInterpolateField->setWindowFlags(flags | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint);
560 _dlgInterpolateField->open();
564 void DatasourceController::OnInterpolateFieldInputValidated() {
565 MEDCALC::InterpolationParameters params;
566 params.precision = _dlgInterpolateField->getPrecision();
567 STDLOG("precision = " << params.precision);
568 params.defaultValue = _dlgInterpolateField->getDefaultValue();
569 STDLOG("defaultValue = " << params.defaultValue);
570 params.reverse = _dlgInterpolateField->getReverse();
571 STDLOG("reverse = " << params.reverse);
572 params.intersectionType = _dlgInterpolateField->getIntersectionType().c_str();
573 STDLOG("intersectionType = " << params.intersectionType);
574 params.method = _dlgInterpolateField->getMethod().c_str();
575 STDLOG("method = " << params.method);
576 params.nature = _dlgInterpolateField->getFieldNature().c_str();
577 STDLOG("nature = " << params.nature);
579 int meshId = _dlgInterpolateField->getMeshId();
580 STDLOG("meshId = " << ToString(meshId));
581 int fieldId = _dlgInterpolateField->getFieldId();
582 MEDCALC::FieldHandler* fieldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
584 // We don't modify the original field but create first a duplicate
585 // MEDCALC::FieldHandler* duplicate = MEDFactoryClient::getCalculator()->dup(*fieldHandler);
586 //MEDFactoryClient::getDataManager()->changeUnderlyingMesh(duplicate->id, meshId);
587 MEDCALC::FieldHandler* result = NULL;
589 result = MEDFactoryClient::getDataManager()->interpolateField(fieldId, meshId, params);
592 STDLOG("Unable to process field interpolation; please check interpolation parameters");
593 QMessageBox::critical(_salomeModule->getApp()->desktop(),
594 tr("Operation failed"),
595 tr("Unable to process field interpolation; please check interpolation parameters"));
599 // Request once more the duplicate to update the meta-data on this
601 // duplicate = MEDFactoryClient::getDataManager()->getFieldHandler(duplicate->id);
604 // WARN: the following is a temporary code for test purpose
605 // Automatically add in ws
606 DatasourceEvent * event = new DatasourceEvent();
607 event->eventtype = DatasourceEvent::EVENT_IMPORT_OBJECT;
608 XmedDataObject * dataObject = new XmedDataObject();
609 dataObject->setFieldHandler(*result);
610 event->objectdata = dataObject;
611 emit datasourceSignal(event);
612 // Note that this signal is processed by the WorkspaceController
614 // // Tag the item to prevent double import
615 // //_studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,true);
619 DatasourceController::processWorkspaceEvent(const MEDCALC::MedEvent* event)
621 if ( event->type == MEDCALC::EVENT_ADD_DATASOURCE ) {
622 MEDCALC::DatasourceHandler* datasourceHandler = MEDFactoryClient::getDataManager()->getDatasourceHandler(event->filename);
623 this->updateTreeViewWithNewDatasource(datasourceHandler);
625 else if ( event->type == MEDCALC::EVENT_ADD_PRESENTATION ) {
626 this->updateTreeViewWithNewPresentation(event->dataId, event->presentationId);