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 "WorkspaceController.hxx"
23 #include "QtHelper.hxx"
24 #include "MEDFactoryClient.hxx"
25 #include "MEDModule.hxx"
26 #include "XmedDataModel.hxx"
27 #include "DlgAlias.hxx"
29 #include <SALOMEconfig.h>
30 #include CORBA_CLIENT_HEADER(MEDEventListener)
32 #include <SalomeApp_Application.h>
33 #include <SALOME_LifeCycleCORBA.hxx>
34 #include <SUIT_FileDlg.h>
35 #include <SUIT_Desktop.h>
36 #include <SUIT_ResourceMgr.h>
39 * This class defines a DockWidget plugged in the SALOME application,
40 * and containing a tree view for rendering a hierarchical data
41 * model. This datamodel contains the objects used in the workspace.
43 WorkspaceController::WorkspaceController(MEDModule* salomeModule)
44 : TreeGuiManager(salomeModule->getApp(), "Workspace")
46 _salomeModule = salomeModule;
47 getDockWidgets()->getDockWidget()->setObjectName("medWorkspaceDock");
49 this->tabifyDockWidgets(false);
51 // -------------------------------------------------------------
52 // Setup the MEDEventListener to manage notification from the
55 // We create a MEDEventListener CORBA object inside this GUI class
56 // with the role of listening events coming from the python console
57 // (or even the components if needed). The events arising in the
58 // python console are send as CORBA request to this CORBA
59 // servant. Then this object can process the event by notifying the
60 // GUI of something to update for example (using signals and slots
62 _medEventListener = MEDEventListener_i::getInstance();
63 MEDCALC::MEDEventListener_ptr medEventListenerServant = _medEventListener->_this();
65 // We store the IOR inside the MEDDataManager to share this data
66 // with other parts of the application, in particular the python
67 // console that could retrieve this IOR using the
68 // getEventListenerIOR() function of the MEDDataManager.
69 SalomeApp_Application* salomeApp = salomeModule->getApp();
70 const char* medEventListenerIOR =
71 salomeApp->orb()->object_to_string(medEventListenerServant);
72 MEDFactoryClient::getDataManager()->setEventListenerIOR(medEventListenerIOR);
74 // Connect the signals emitted from the MEDEventListener to slot of
76 connect(_medEventListener, SIGNAL(medEventSignal(const MEDCALC::MedEvent*)),
77 this, SLOT(processMedEvent(const MEDCALC::MedEvent*)));
79 // Note that this class must be mocked (Q_OBJECT + moc file
80 // generated from header file) so that to be able to connect a
81 // signal to a slot of this class.
83 // -------------------------------------------------------------
84 // Customize the treeview rendering the datamodel with specific
85 // action for the popup menu
86 this->getDataTreeView()->clearActions();
87 _actionIds.display = this->getDataTreeView()->addAction(tr("VISUALIZE_SCALAR_MAP"));
88 _actionIds.useInTui = this->getDataTreeView()->addAction(tr("USE_IN_CONSOLE"));
89 _actionIds.exportToPv = this->getDataTreeView()->addAction(tr("EXPORT_TO_PARAVIS"));
90 _actionIds.save = this->getDataTreeView()->addAction(tr("SAVE_AS_MED"));
91 _actionIds.remove = this->getDataTreeView()->addAction(tr("REMOVE_FROM_WORKSPACE"));
93 // -------------------------------------------------------------
94 // Initialize the python console. Note that this must be done at
95 // last because the setup will try to initiate a connection to the
97 _consoleDriver = new XmedConsoleDriver(salomeModule);
98 _consoleDriver->setup();
101 WorkspaceController::~WorkspaceController() {
102 STDLOG("WorkspaceController::~WorkspaceController()");
103 MEDEventListener_i::release();
107 * This creates the GUI actions for driving the Workspace. The
108 * WorkspaceController creates itself this actions and implements the
111 void WorkspaceController::createActions() {
112 QWidget* dsk = _salomeModule->getApp()->desktop();
113 SUIT_ResourceMgr* resMgr = _salomeModule->getApp()->resourceMgr();
114 int toolbarId = _salomeModule->createTool("Workspace", "WorkspaceToolbar");
116 QString label = tr("LAB_SAVE_WORKSPACE");
117 QString tooltip = tr("TIP_SAVE_WORKSPACE");
118 QString icon = tr("ICO_WORKSPACE_SAVE");
119 int actionId = _salomeModule->createStandardAction(label,this,SLOT(OnSaveWorkspace()),icon,tooltip);
120 _salomeModule->createTool(actionId, toolbarId);
122 label = tr("LAB_CLEAN_WORKSPACE");
123 tooltip = tr("TIP_CLEAN_WORKSPACE");
124 icon = tr("ICO_WORKSPACE_CLEAN");
125 actionId = _salomeModule->createStandardAction(label,this,SLOT(OnCleanWorkspace()),icon,tooltip);
126 _salomeModule->createTool(actionId, toolbarId);
130 * Implementation of the slot processItemList inherited from TreeGuiManager
132 void WorkspaceController::processItemList(QStringList itemNameIdList, int actionId) {
133 if ( actionId == _actionIds.display ) {
134 STDLOG("WorkspaceController::processItemList: display");
135 this->_viewItemList(itemNameIdList);
137 else if ( actionId == _actionIds.useInTui ) {
138 STDLOG("WorkspaceController::processItemList: use");
139 this->_importItemList(itemNameIdList);
141 else if ( actionId == _actionIds.exportToPv ) {
142 STDLOG("WorkspaceController::processItemList: export");
143 this->_exportItemList(itemNameIdList);
145 else if ( actionId == _actionIds.save ) {
146 STDLOG("WorkspaceController::processItemList: save");
147 this->_saveItemList(itemNameIdList);
149 else if ( actionId == _actionIds.remove ) {
150 STDLOG("WorkspaceController::processItemList: remove");
151 this->_removeItemList(itemNameIdList);
154 STDLOG("WorkspaceController::processItemList: ERR : action unknown ");
159 * This function import in the console all the fields associated to
160 * the model items of the specified list. "Import a fields" means
161 * "define a field proxy variable in the python context to manipulate
162 * the real field in the database".
164 void WorkspaceController::_importItemList(QStringList itemNameIdList) {
165 LOG("WorkspaceController: signal received : display item list "<<itemNameIdList);
166 QStringList::const_iterator it;
167 for (it = itemNameIdList.constBegin(); it != itemNameIdList.constEnd(); ++it) {
168 QString itemNameId = *it;
169 this->_importItem(itemNameId);
174 * This function is the unit function used to import field in the
175 * console (see _importItemList).
177 void WorkspaceController::_importItem(QString itemNameId) {
178 XmedDataModel* dataModel = (XmedDataModel*)this->getDataModel();
179 if ( dataModel == NULL ) {
180 LOG("No data model associated to this tree view");
184 // We can request the dataModel to obtain the dataObject associated
185 // to this item (iteNameId is a TreeView id, Qt stuff only).
186 XmedDataObject* dataObject =
187 (XmedDataObject*)dataModel->getDataObject(QS2S(itemNameId));
189 if ( dataObject == NULL ) {
190 LOG("WorkspaceController: WARN! No data object associated to the item "<<itemNameId);
194 // Then, we can request this data object to obtain the associated
196 MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
197 STDLOG("Field: mesh="<<fieldHandler->meshname<<" name="<<fieldHandler->fieldname);
199 // Finally, we can import the field
200 bool askForOptions = true;
201 _importFieldIntoConsole(fieldHandler, askForOptions);
205 * This function import the specified field into the tui console. This
206 * means to define a field proxy variable in the python context to
207 * manipulate the field. We can raise a gui to specify some import
208 * options or simply specify the alias (i.e. the name of the python
211 void WorkspaceController::_importFieldIntoConsole(MEDCALC::FieldHandler* fieldHandler,
215 STDLOG("alias="<<alias);
217 // By default, the alias is the name of the field
218 QString*effectiveAlias;
219 if ( alias == NULL ) {
220 effectiveAlias = new QString(fieldHandler->fieldname);
223 effectiveAlias = new QString(alias);
226 // We can propose to the user to specify some additionnal
227 // informations concerning what must be imported.
229 // In this version, we just ask the alias the field will be
230 // manipulated with. The default alias is the field name. This alias
231 // should be asked to the user to get a short name to manipulate.
232 if ( askForOptions ) {
234 dialog.setAlias(*effectiveAlias);
235 int choice = dialog.exec();
236 if ( choice == QDialog::Rejected ) {
237 // The user decides to cancel the operation
240 *effectiveAlias = dialog.getAlias();
244 // Then, the list of python commands can be written and executed to
245 // define the field in the console
247 QStringList commands;
248 commands+=QString("%1=medcalc.newFieldProxy(fieldHandlerId=%2)")
249 .arg(*effectiveAlias)
250 .arg(fieldHandler->id);
252 _consoleDriver->exec(commands);
256 * This function is a Qt slot connected to the signal medEventSignal
257 * emitted from the MEDEventListener. It processes events coming from
258 * the python console.
260 void WorkspaceController::processMedEvent(const MEDCALC::MedEvent* event) {
261 STDLOG("WorkspaceController::processMedEvent");
262 STDLOG("dataId :"<<event->dataId);
264 XmedDataModel* dataModel = (XmedDataModel*)this->getDataModel();
265 if ( dataModel == NULL ) {
266 STDLOG("No data model associated to this tree view");
270 if ( event->type == MEDCALC::EVENT_UPDATE_FIELD ) {
271 std::cout << "WorkspaceController::processMedEvent[MEDCALC::EVENT_UPDATE_FIELD]: Not implemented yet";
273 else if ( event->type == MEDCALC::EVENT_PUT_IN_WORKSPACE ) {
274 STDLOG("add new field");
275 MEDCALC::FieldHandler* fieldHandler =
276 MEDFactoryClient::getDataManager()->getFieldHandler(event->dataId);
278 XmedDataObject* dataObject = (XmedDataObject*)dataModel->newDataObject();
279 dataObject->setFieldHandler(*fieldHandler);
280 this->getDataTreeModel()->addData(dataObject);
282 else if ( event->type == MEDCALC::EVENT_REMOVE_FROM_WORKSPACE ) {
283 STDLOG("remove field");
284 std::map<string, DataObject*>::iterator itr = dataModel->begin();
285 for ( ; itr != dataModel->end(); ++itr) {
286 XmedDataObject* obj = dynamic_cast<XmedDataObject*>(itr->second);
287 if (obj->getFieldHandler()->id == event->dataId) {
288 std::string itemNameId = obj->getNameId();
289 this->getDataTreeModel()->removeData(obj);
290 dataModel->removeDataObject(itemNameId);
295 else if ( event->type == MEDCALC::EVENT_CLEAN_WORKSPACE ) {
296 STDLOG("clean workspace");
297 std::map<string, DataObject*>::iterator itr = dataModel->begin();
298 for ( ; itr != dataModel->end(); ++itr) {
299 XmedDataObject* obj = dynamic_cast<XmedDataObject*>(itr->second);
300 std::string itemNameId = obj->getNameId();
301 this->getDataTreeModel()->removeData(obj);
302 dataModel->removeDataObject(itemNameId);
305 else if ( event->type == MEDCALC::EVENT_ADD_DATASOURCE ) {
306 emit workspaceSignal(event); // forward to DatasourceController
308 else if ( event->type == MEDCALC::EVENT_ADD_PRESENTATION ) {
309 emit workspaceSignal(event); // forward to DatasourceController
311 else if ( event->type == MEDCALC::EVENT_PLAY_TEST ) {
312 emit workspaceSignal(event); // forward to TestController
318 * This function save a list of fields in a med file. The med file
319 * name is requested to the user using a file chooser dialog box
321 void WorkspaceController::_saveItemList(QStringList itemNameIdList) {
322 XmedDataProcessor* dataProcessor = new XmedDataProcessor(this->getDataModel());
323 dataProcessor->process(itemNameIdList);
324 MEDCALC::FieldIdList_var fieldIdList = dataProcessor->getResultingFieldIdList();
325 delete dataProcessor;
328 filter.append(tr("FILE_FILTER_MED"));
329 QString filename = SUIT_FileDlg::getFileName(_salomeModule->getApp()->desktop(),
332 tr("SAVE_SELECTED_FIELDS"),
335 if ( filename.isEmpty() ) return;
337 MEDFactoryClient::getDataManager()->saveFields(QCHARSTAR(filename), fieldIdList);
341 * This function remove the selected item from workspace.
343 void WorkspaceController::_removeItemList(QStringList itemNameIdList) {
344 XmedDataModel* dataModel = (XmedDataModel*)this->getDataModel();
345 if ( dataModel == NULL ) {
346 LOG("No data model associated to this tree view");
350 // __GBO__: In this version, we consider only the first field in the selection
351 QString itemNameId = itemNameIdList[0];
353 // We can request the dataModel to obtain the dataObject associated
354 // to this item (iteNameId is a TreeView id, Qt stuff only).
355 XmedDataObject* dataObject =
356 (XmedDataObject*)dataModel->getDataObject(QS2S(itemNameId));
358 if ( dataObject == NULL ) {
359 LOG("WorkspaceController: WARN! No data object associated to the item "<<itemNameId);
363 // Then, we can request this data object to obtain the associated
365 MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
366 STDLOG("Field: mesh="<<fieldHandler->meshname<<" name="<<fieldHandler->fieldname);
368 // Remove the field variable from console
369 QStringList commands;
370 commands+=QString("removeFromWorkspace(accessField(%1))").arg(fieldHandler->id);
371 _consoleDriver->exec(commands);
373 // Finally, we can remove the field from tree data model and tree view
374 this->getDataTreeModel()->removeData(dataObject);
375 dataModel->removeDataObject(QS2S(itemNameId));
379 * This function export the list of specified field item to PARAVIS
380 * module. This consists in create a med file gathering the selected
381 * items, then to import this file in PARAVIS, and finally to create a
382 * scalar map of the first item to start the job.
384 void WorkspaceController::_exportItemList(QStringList itemNameIdList) {
385 XmedDataProcessor* dataProcessor = new XmedDataProcessor(this->getDataModel());
386 dataProcessor->process(itemNameIdList);
387 MEDCALC::FieldIdList_var fieldIdList = dataProcessor->getResultingFieldIdList();
388 delete dataProcessor;
390 // _GBO_ We use a temporary file to proceed with this export to
391 // paravis. I'm sure it could be better in a futur version or when I
392 // will get a better understanding of paravis API.
393 const char* tmpfilename = "/tmp/medcalc_export2paravis.med";
394 MEDFactoryClient::getDataManager()->saveFields(tmpfilename, fieldIdList);
396 // We import the whole file but create a scalar map for the first
397 // selected field only (it's just an export to continue the job in
399 XmedDataModel* dataModel = (XmedDataModel*)this->getDataModel();
400 if ( dataModel == NULL ) {
401 STDLOG("No data model associated to this tree view");
404 QString itemNameId = itemNameIdList[0];
405 XmedDataObject* dataObject = (XmedDataObject*)dataModel->getDataObject(QS2S(itemNameId));
406 if ( dataObject == NULL ) {
407 LOG("WorkspaceController: WARN! No data object associated to the item "<<itemNameId);
410 MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
411 QStringList commands;
413 commands+=QString("from xmed.driver_pvis import pvis_scalarmap");
414 commands+=QString("pvis_scalarmap('%1','%2','%3',%4,%5)")
416 .arg(QString(fieldHandler->meshname))
417 .arg(QString(fieldHandler->fieldname))
418 .arg(fieldHandler->type)
419 .arg(fieldHandler->iteration);
421 commands += "print 'Not implemented yet'";
422 _consoleDriver->exec(commands);
427 * This function sends a request to the SALOME data visualisation
428 * (module VISU or PARAVIS) for displaying a scalar map of the fields
429 * associated to the model items in the specified list.
432 void WorkspaceController::_viewItemList(QStringList itemNameIdList) {
434 // __GBO__: In this version, we consider only the first field in the selection
435 QString itemNameId = itemNameIdList[0];
437 XmedDataModel* dataModel = (XmedDataModel*)this->getDataModel();
438 if ( dataModel == NULL ) {
439 LOG("No data model associated to this tree view");
443 // We can request the dataModel to obtain the dataObject associated
444 // to this item (iteNameId is a TreeView id, Qt stuff only).
445 XmedDataObject* dataObject =
446 (XmedDataObject*)dataModel->getDataObject(QS2S(itemNameId));
447 if ( dataObject == NULL ) {
448 LOG("WorkspaceController: WARN! No data object associated to the item "<<itemNameId);
452 // Then, we can request this data object to obtain the associated
454 MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
456 // And finally, we can create the set of medcalc instructions to
457 // generate the scalar map on this field.
458 QStringList commands;
459 //commands+=QString("view(accessField(%1))").arg(fieldHandler->id);
460 commands += "print 'Not implemented yet'";
461 _consoleDriver->exec(commands);
465 * This slot can process the event coming from the
466 * DatasourceController. The connection between the datasource signal
467 * and this slot is realized by the main class MEDModule.
469 void WorkspaceController::processDatasourceEvent(const DatasourceEvent* event) {
470 XmedDataModel* dataModel = (XmedDataModel*)this->getDataModel();
471 if ( dataModel == NULL ) {
472 STDLOG("No data model associated to this tree view");
477 // __GBO__ To know what to do we should test the type, because the
478 // object could be a mesh, a timeseries or a single field. We test
479 // here the case of a single field. Moreover, there could have
480 // options such that "change the underlying mesh".
483 XmedDataObject* dataObject = event->objectdata;
485 if ( event->eventtype == DatasourceEvent::EVENT_IMPORT_OBJECT ) {
486 std::cout << "IMPORT object in workspace: " << dataObject->toString() << std::endl;
487 STDLOG("IMPORT object in workspace:\n"<<dataObject->toString());
488 // _GBO_ QUESTION: tag automatically the object as a peristant object ??
489 // We first add the data object to the internal data model
490 dataModel->addDataObject(dataObject);
491 // Then we request the tree view to consider this new object
492 this->getDataTreeModel()->addData(dataObject);
494 else if ( event->eventtype == DatasourceEvent::EVENT_USE_OBJECT ) {
495 STDLOG("USE object in workspace:\n"<<dataObject->toString());
496 // We first add the data object to the internal data model
497 dataModel->addDataObject(dataObject);
498 // Then we request the tree view to consider this new object
499 this->getDataTreeModel()->addData(dataObject);
501 // We define a proxy for this object in the tui console.
502 STDLOG("Define a proxy variable in the console with name : "<<QCHARSTAR(event->objectalias));
503 bool askForOptions = false;
504 _importFieldIntoConsole(dataObject->getFieldHandler(),
506 QCHARSTAR(event->objectalias));
508 else if ( event->eventtype == DatasourceEvent::EVENT_ADD_DATASOURCE ) {
509 QStringList commands;
510 commands += QString("medcalc.LoadDataSource('%1')").arg(event->objectalias);
511 _consoleDriver->exec(commands);
513 else if ( event->eventtype == DatasourceEvent::EVENT_ADD_IMAGE_AS_DATASOURCE ) {
514 QStringList commands;
515 commands += QString("medcalc.LoadImageAsDataSource('%1')").arg(event->objectalias);
516 _consoleDriver->exec(commands);
519 STDLOG("The event "<<event->eventtype<<" is not implemented yet");
524 WorkspaceController::_getViewMode()
526 MEDCALC::MEDPresentationViewMode viewMode = _salomeModule->getSelectedViewMode();
528 case MEDCALC::VIEW_MODE_REPLACE: return "MEDCALC.VIEW_MODE_REPLACE";
529 case MEDCALC::VIEW_MODE_OVERLAP: return "MEDCALC.VIEW_MODE_OVERLAP";
530 case MEDCALC::VIEW_MODE_NEW_LAYOUT: return "MEDCALC.VIEW_MODE_NEW_LAYOUT";
531 case MEDCALC::VIEW_MODE_SPLIT_VIEW: return "MEDCALC.VIEW_MODE_SPLIT_VIEW";
537 WorkspaceController::_getColorMap()
539 MEDCALC::MEDPresentationColorMap colorMap = _salomeModule->getSelectedColorMap();
541 case MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW: return "MEDCALC.COLOR_MAP_BLUE_TO_RED_RAINBOW";
542 case MEDCALC::COLOR_MAP_COOL_TO_WARM: return "MEDCALC.COLOR_MAP_COOL_TO_WARM";
548 * This slot can process the event coming from the
549 * DatasourceController. The connection between the datasource signal
550 * and this slot is realized by the main class MEDModule.
552 void WorkspaceController::processPresentationEvent(const PresentationEvent* event) {
553 XmedDataModel* dataModel = (XmedDataModel*)this->getDataModel();
554 if ( dataModel == NULL ) {
555 STDLOG("No data model associated to this tree view");
560 // __GBO__ To know what to do we should test the type, because the
561 // object could be a mesh, a timeseries or a single field. We test
562 // here the case of a single field. Moreover, there could have
563 // options such that "change the underlying mesh".
566 XmedDataObject* dataObject = event->objectdata;
568 // --> Send commands to SALOME Python console
569 if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SCALAR_MAP ) {
570 QString viewMode = _getViewMode();
571 //QString displayedInfo = ; // from PresentationController combobox
572 //QString scalarBarRange = ; // from PresentationController spinbox
573 QString colorMap = _getColorMap();
574 MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
575 QStringList commands;
576 commands += QString("medcalc.MakeScalarMap(accessField(%1), %2, colorMap=%3)").arg(fieldHandler->id).arg(viewMode).arg(colorMap);
577 _consoleDriver->exec(commands);
579 else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_CONTOUR ) {
580 QString viewMode = _getViewMode();
581 MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
582 QStringList commands;
583 commands += QString("medcalc.MakeContour(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
584 _consoleDriver->exec(commands);
586 else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_VECTOR_FIELD ) {
587 QString viewMode = _getViewMode();
588 MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
589 QStringList commands;
590 commands += QString("medcalc.MakeVectorField(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
591 _consoleDriver->exec(commands);
593 else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SLICES ) {
594 QString viewMode = _getViewMode();
595 MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
596 QStringList commands;
597 commands += QString("medcalc.MakeSlices(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
598 _consoleDriver->exec(commands);
600 else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_DEFLECTION_SHAPE ) {
601 QString viewMode = _getViewMode();
602 MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
603 QStringList commands;
604 commands += QString("medcalc.MakeDeflectionShape(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
605 _consoleDriver->exec(commands);
607 else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_POINT_SPRITE ) {
608 QString viewMode = _getViewMode();
609 MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
610 QStringList commands;
611 commands += QString("medcalc.MakePointSprite(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
612 _consoleDriver->exec(commands);
615 STDLOG("The event "<<event->eventtype<<" is not implemented yet");
620 WorkspaceController::processProcessingEvent(const ProcessingEvent* event)
622 XmedDataModel* dataModel = (XmedDataModel*)this->getDataModel();
623 if ( dataModel == NULL ) {
624 STDLOG("No data model associated to this tree view");
629 // __GBO__ To know what to do we should test the type, because the
630 // object could be a mesh, a timeseries or a single field. We test
631 // here the case of a single field. Moreover, there could have
632 // options such that "change the underlying mesh".
635 XmedDataObject* dataObject = event->objectdata;
637 if ( event->eventtype == ProcessingEvent::EVENT_IMPORT_OBJECT ) {
638 std::cout << "IMPORT object in workspace: " << dataObject->toString() << std::endl;
639 STDLOG("IMPORT object in workspace:\n"<<dataObject->toString());
640 // _GBO_ QUESTION: tag automatically the object as a peristant object ??
641 // We first add the data object to the internal data model
642 dataModel->addDataObject(dataObject);
643 // Then we request the tree view to consider this new object
644 this->getDataTreeModel()->addData(dataObject);
648 void WorkspaceController::OnSaveWorkspace() {
650 // Dialog to get the filename where the workspace must be saved into
652 filter.append(tr("FILE_FILTER_MED"));
654 QString filename = SUIT_FileDlg::getFileName(_salomeModule->getApp()->desktop(),
657 tr("SAVE_WORKSPACE_DATA"),
660 if ( filename.isEmpty() ) return;
662 STDLOG("OnWorkspaceSave: save the workspace in the file " << QCHARSTAR(filename));
663 QStringList commands;
664 commands+=QString("saveWorkspace('%1')").arg(filename);
665 _consoleDriver->exec(commands);
668 #include <QMessageBox>
669 void WorkspaceController::OnCleanWorkspace() {
670 // Remove field from console
671 QStringList commands;
672 commands += QString("cleanWorkspace()");
673 _consoleDriver->exec(commands);