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>
41 * This class defines a DockWidget plugged in the SALOME application,
42 * and containing a tree view for rendering a hierarchical data
43 * model. This datamodel contains the objects used in the workspace.
45 WorkspaceController::WorkspaceController(MEDModule* salomeModule)
46 : TreeGuiManager(salomeModule->getApp(), "Workspace")
48 _salomeModule = salomeModule;
49 getDockWidgets()->getDockWidget()->setObjectName("medWorkspaceDock");
51 this->tabifyDockWidgets(false);
53 // -------------------------------------------------------------
54 // Setup the MEDEventListener to manage notification from the
57 // We create a MEDEventListener CORBA object inside this GUI class
58 // with the role of listening events coming from the python console
59 // (or even the components if needed). The events arising in the
60 // python console are send as CORBA request to this CORBA
61 // servant. Then this object can process the event by notifying the
62 // GUI of something to update for example (using signals and slots
64 _medEventListener = MEDEventListener_i::getInstance();
65 MEDCALC::MEDEventListener_ptr medEventListenerServant = _medEventListener->_this();
67 // We store the IOR inside the MEDDataManager to share this data
68 // with other parts of the application, in particular the python
69 // console that could retrieve this IOR using the
70 // getEventListenerIOR() function of the MEDDataManager.
71 SalomeApp_Application* salomeApp = salomeModule->getApp();
72 const char* medEventListenerIOR =
73 salomeApp->orb()->object_to_string(medEventListenerServant);
74 MEDFactoryClient::getDataManager()->setEventListenerIOR(medEventListenerIOR);
76 // Connect the signals emitted from the MEDEventListener to slot of
78 connect(_medEventListener, SIGNAL(medEventSignal(const MEDCALC::MedEvent*)),
79 this, SLOT(processMedEvent(const MEDCALC::MedEvent*)));
81 // Note that this class must be mocked (Q_OBJECT + moc file
82 // generated from header file) so that to be able to connect a
83 // signal to a slot of this class.
85 // -------------------------------------------------------------
86 // Customize the treeview rendering the datamodel with specific
87 // action for the popup menu
88 this->getDataTreeView()->clearActions();
89 _actionIds.display = this->getDataTreeView()->addAction(tr("VISUALIZE_SCALAR_MAP"));
90 _actionIds.useInTui = this->getDataTreeView()->addAction(tr("USE_IN_CONSOLE"));
91 _actionIds.exportToPv = this->getDataTreeView()->addAction(tr("EXPORT_TO_PARAVIS"));
92 _actionIds.save = this->getDataTreeView()->addAction(tr("SAVE_AS_MED"));
93 _actionIds.remove = this->getDataTreeView()->addAction(tr("REMOVE_FROM_WORKSPACE"));
95 // -------------------------------------------------------------
96 // Initialize the python console. Note that this must be done at
97 // last because the setup will try to initiate a connection to the
99 _consoleDriver = new XmedConsoleDriver(salomeModule);
100 _consoleDriver->setup();
103 WorkspaceController::~WorkspaceController() {
104 STDLOG("WorkspaceController::~WorkspaceController()");
105 MEDEventListener_i::release();
109 * This creates the GUI actions for driving the Workspace. The
110 * WorkspaceController creates itself this actions and implements the
113 void WorkspaceController::createActions() {
114 QWidget* dsk = _salomeModule->getApp()->desktop();
115 SUIT_ResourceMgr* resMgr = _salomeModule->getApp()->resourceMgr();
116 int toolbarId = _salomeModule->createTool("Workspace", "WorkspaceToolbar");
118 QString label = tr("LAB_SAVE_WORKSPACE");
119 QString tooltip = tr("TIP_SAVE_WORKSPACE");
120 QString icon = tr("ICO_WORKSPACE_SAVE");
121 int actionId = _salomeModule->createStandardAction(label,this,SLOT(OnSaveWorkspace()),icon,tooltip);
122 _salomeModule->createTool(actionId, toolbarId);
124 label = tr("LAB_CLEAN_WORKSPACE");
125 tooltip = tr("TIP_CLEAN_WORKSPACE");
126 icon = tr("ICO_WORKSPACE_CLEAN");
127 actionId = _salomeModule->createStandardAction(label,this,SLOT(OnCleanWorkspace()),icon,tooltip);
128 _salomeModule->createTool(actionId, toolbarId);
132 * Implementation of the slot processItemList inherited from TreeGuiManager
134 void WorkspaceController::processItemList(QStringList itemNameIdList, int actionId) {
135 if ( actionId == _actionIds.display ) {
136 STDLOG("WorkspaceController::processItemList: display");
137 this->_viewItemList(itemNameIdList);
139 else if ( actionId == _actionIds.useInTui ) {
140 STDLOG("WorkspaceController::processItemList: use");
141 this->_importItemList(itemNameIdList);
143 else if ( actionId == _actionIds.exportToPv ) {
144 STDLOG("WorkspaceController::processItemList: export");
145 this->_exportItemList(itemNameIdList);
147 else if ( actionId == _actionIds.save ) {
148 STDLOG("WorkspaceController::processItemList: save");
149 this->_saveItemList(itemNameIdList);
151 else if ( actionId == _actionIds.remove ) {
152 STDLOG("WorkspaceController::processItemList: remove");
153 this->_removeItemList(itemNameIdList);
156 STDLOG("WorkspaceController::processItemList: ERR : action unknown ");
161 * This function import in the console all the fields associated to
162 * the model items of the specified list. "Import a fields" means
163 * "define a field proxy variable in the python context to manipulate
164 * the real field in the database".
166 void WorkspaceController::_importItemList(QStringList itemNameIdList) {
167 LOG("WorkspaceController: signal received : display item list "<<itemNameIdList);
168 QStringList::const_iterator it;
169 for (it = itemNameIdList.constBegin(); it != itemNameIdList.constEnd(); ++it) {
170 QString itemNameId = *it;
171 this->_importItem(itemNameId);
176 * This function is the unit function used to import field in the
177 * console (see _importItemList).
179 void WorkspaceController::_importItem(QString itemNameId) {
180 XmedDataModel* dataModel = (XmedDataModel*)this->getDataModel();
181 if ( dataModel == NULL ) {
182 LOG("No data model associated to this tree view");
186 // We can request the dataModel to obtain the dataObject associated
187 // to this item (iteNameId is a TreeView id, Qt stuff only).
188 XmedDataObject* dataObject =
189 (XmedDataObject*)dataModel->getDataObject(QS2S(itemNameId));
191 if ( dataObject == NULL ) {
192 LOG("WorkspaceController: WARN! No data object associated to the item "<<itemNameId);
196 // Then, we can request this data object to obtain the associated
198 MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
199 STDLOG("Field: mesh="<<fieldHandler->meshname<<" name="<<fieldHandler->fieldname);
201 // Finally, we can import the field
202 bool askForOptions = true;
203 _importFieldIntoConsole(fieldHandler, askForOptions);
207 * This function import the specified field into the tui console. This
208 * means to define a field proxy variable in the python context to
209 * manipulate the field. We can raise a gui to specify some import
210 * options or simply specify the alias (i.e. the name of the python
213 void WorkspaceController::_importFieldIntoConsole(MEDCALC::FieldHandler* fieldHandler,
217 STDLOG("alias="<<alias);
219 // By default, the alias is the name of the field
220 QString*effectiveAlias;
221 if ( alias == NULL ) {
222 effectiveAlias = new QString(fieldHandler->fieldname);
225 effectiveAlias = new QString(alias);
228 // We can propose to the user to specify some additionnal
229 // informations concerning what must be imported.
231 // In this version, we just ask the alias the field will be
232 // manipulated with. The default alias is the field name. This alias
233 // should be asked to the user to get a short name to manipulate.
234 if ( askForOptions ) {
236 dialog.setAlias(*effectiveAlias);
237 int choice = dialog.exec();
238 if ( choice == QDialog::Rejected ) {
239 // The user decides to cancel the operation
242 *effectiveAlias = dialog.getAlias();
246 // Then, the list of python commands can be written and executed to
247 // define the field in the console
249 QStringList commands;
250 commands+=QString("%1=medcalc.newFieldProxy(fieldHandlerId=%2)")
251 .arg(*effectiveAlias)
252 .arg(fieldHandler->id);
254 _consoleDriver->exec(commands);
258 * This function is a Qt slot connected to the signal medEventSignal
259 * emitted from the MEDEventListener. It processes events coming from
260 * the python console.
262 void WorkspaceController::processMedEvent(const MEDCALC::MedEvent* event) {
263 STDLOG("WorkspaceController::processMedEvent");
264 STDLOG("dataId :"<<event->dataId);
266 XmedDataModel* dataModel = (XmedDataModel*)this->getDataModel();
267 if ( dataModel == NULL ) {
268 STDLOG("No data model associated to this tree view");
272 if ( event->type == MEDCALC::EVENT_UPDATE_FIELD ) {
273 std::cout << "WorkspaceController::processMedEvent[MEDCALC::EVENT_UPDATE_FIELD]: Not implemented yet";
275 else if ( event->type == MEDCALC::EVENT_PUT_IN_WORKSPACE ) {
276 STDLOG("add new field");
277 MEDCALC::FieldHandler* fieldHandler =
278 MEDFactoryClient::getDataManager()->getFieldHandler(event->dataId);
280 XmedDataObject* dataObject = (XmedDataObject*)dataModel->newDataObject();
281 dataObject->setFieldHandler(*fieldHandler);
282 this->getDataTreeModel()->addData(dataObject);
284 else if ( event->type == MEDCALC::EVENT_REMOVE_FROM_WORKSPACE ) {
285 STDLOG("remove field");
286 std::map<string, DataObject*>::iterator itr = dataModel->begin();
287 for ( ; itr != dataModel->end(); ++itr) {
288 XmedDataObject* obj = dynamic_cast<XmedDataObject*>(itr->second);
289 if (obj->getFieldHandler()->id == event->dataId) {
290 std::string itemNameId = obj->getNameId();
291 this->getDataTreeModel()->removeData(obj);
292 dataModel->removeDataObject(itemNameId);
297 else if ( event->type == MEDCALC::EVENT_CLEAN_WORKSPACE ) {
298 STDLOG("clean workspace");
299 std::map<string, DataObject*>::iterator itr = dataModel->begin();
300 for ( ; itr != dataModel->end(); ++itr) {
301 XmedDataObject* obj = dynamic_cast<XmedDataObject*>(itr->second);
302 std::string itemNameId = obj->getNameId();
303 this->getDataTreeModel()->removeData(obj);
304 dataModel->removeDataObject(itemNameId);
307 else if ( event->type == MEDCALC::EVENT_ADD_DATASOURCE ) {
308 emit workspaceSignal(event); // forward to DatasourceController
310 else if ( event->type == MEDCALC::EVENT_ADD_PRESENTATION ) {
311 emit workspaceSignal(event); // forward to DatasourceController
313 else if ( event->type == MEDCALC::EVENT_PLAY_TEST ) {
314 emit workspaceSignal(event); // forward to TestController
316 else if ( event->type == MEDCALC::EVENT_QUIT_SALOME ) {
317 emit workspaceSignal(event); // forward to TestController
322 * This function save a list of fields in a med file. The med file
323 * name is requested to the user using a file chooser dialog box
325 void WorkspaceController::_saveItemList(QStringList itemNameIdList) {
326 XmedDataProcessor* dataProcessor = new XmedDataProcessor(this->getDataModel());
327 dataProcessor->process(itemNameIdList);
328 MEDCALC::FieldIdList_var fieldIdList = dataProcessor->getResultingFieldIdList();
329 delete dataProcessor;
332 filter.append(tr("FILE_FILTER_MED"));
333 QString filename = SUIT_FileDlg::getFileName(_salomeModule->getApp()->desktop(),
336 tr("SAVE_SELECTED_FIELDS"),
339 if ( filename.isEmpty() ) return;
341 MEDFactoryClient::getDataManager()->saveFields(QCHARSTAR(filename), fieldIdList);
345 * This function remove the selected item from workspace.
347 void WorkspaceController::_removeItemList(QStringList itemNameIdList) {
348 XmedDataModel* dataModel = (XmedDataModel*)this->getDataModel();
349 if ( dataModel == NULL ) {
350 LOG("No data model associated to this tree view");
354 // __GBO__: In this version, we consider only the first field in the selection
355 QString itemNameId = itemNameIdList[0];
357 // We can request the dataModel to obtain the dataObject associated
358 // to this item (iteNameId is a TreeView id, Qt stuff only).
359 XmedDataObject* dataObject =
360 (XmedDataObject*)dataModel->getDataObject(QS2S(itemNameId));
362 if ( dataObject == NULL ) {
363 LOG("WorkspaceController: WARN! No data object associated to the item "<<itemNameId);
367 // Then, we can request this data object to obtain the associated
369 MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
370 STDLOG("Field: mesh="<<fieldHandler->meshname<<" name="<<fieldHandler->fieldname);
372 // Remove the field variable from console
373 QStringList commands;
374 commands+=QString("removeFromWorkspace(accessField(%1))").arg(fieldHandler->id);
375 _consoleDriver->exec(commands);
377 // Finally, we can remove the field from tree data model and tree view
378 this->getDataTreeModel()->removeData(dataObject);
379 dataModel->removeDataObject(QS2S(itemNameId));
383 * This function export the list of specified field item to PARAVIS
384 * module. This consists in create a med file gathering the selected
385 * items, then to import this file in PARAVIS, and finally to create a
386 * scalar map of the first item to start the job.
388 void WorkspaceController::_exportItemList(QStringList itemNameIdList) {
389 XmedDataProcessor* dataProcessor = new XmedDataProcessor(this->getDataModel());
390 dataProcessor->process(itemNameIdList);
391 MEDCALC::FieldIdList_var fieldIdList = dataProcessor->getResultingFieldIdList();
392 delete dataProcessor;
394 // _GBO_ We use a temporary file to proceed with this export to
395 // paravis. I'm sure it could be better in a futur version or when I
396 // will get a better understanding of paravis API.
397 const char* tmpfilename = "/tmp/medcalc_export2paravis.med";
398 MEDFactoryClient::getDataManager()->saveFields(tmpfilename, fieldIdList);
400 // We import the whole file but create a scalar map for the first
401 // selected field only (it's just an export to continue the job in
403 XmedDataModel* dataModel = (XmedDataModel*)this->getDataModel();
404 if ( dataModel == NULL ) {
405 STDLOG("No data model associated to this tree view");
408 QString itemNameId = itemNameIdList[0];
409 XmedDataObject* dataObject = (XmedDataObject*)dataModel->getDataObject(QS2S(itemNameId));
410 if ( dataObject == NULL ) {
411 LOG("WorkspaceController: WARN! No data object associated to the item "<<itemNameId);
414 MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
415 QStringList commands;
417 commands+=QString("from xmed.driver_pvis import pvis_scalarmap");
418 commands+=QString("pvis_scalarmap('%1','%2','%3',%4,%5)")
420 .arg(QString(fieldHandler->meshname))
421 .arg(QString(fieldHandler->fieldname))
422 .arg(fieldHandler->type)
423 .arg(fieldHandler->iteration);
425 commands += "print 'Not implemented yet'";
426 _consoleDriver->exec(commands);
431 * This function sends a request to the SALOME data visualisation
432 * (module VISU or PARAVIS) for displaying a scalar map of the fields
433 * associated to the model items in the specified list.
436 void WorkspaceController::_viewItemList(QStringList itemNameIdList) {
438 // __GBO__: In this version, we consider only the first field in the selection
439 QString itemNameId = itemNameIdList[0];
441 XmedDataModel* dataModel = (XmedDataModel*)this->getDataModel();
442 if ( dataModel == NULL ) {
443 LOG("No data model associated to this tree view");
447 // We can request the dataModel to obtain the dataObject associated
448 // to this item (iteNameId is a TreeView id, Qt stuff only).
449 XmedDataObject* dataObject =
450 (XmedDataObject*)dataModel->getDataObject(QS2S(itemNameId));
451 if ( dataObject == NULL ) {
452 LOG("WorkspaceController: WARN! No data object associated to the item "<<itemNameId);
456 // Then, we can request this data object to obtain the associated
458 MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
460 // And finally, we can create the set of medcalc instructions to
461 // generate the scalar map on this field.
462 QStringList commands;
463 //commands+=QString("view(accessField(%1))").arg(fieldHandler->id);
464 commands += "print 'Not implemented yet'";
465 _consoleDriver->exec(commands);
469 * This slot can process the event coming from the
470 * DatasourceController. The connection between the datasource signal
471 * and this slot is realized by the main class MEDModule.
473 void WorkspaceController::processDatasourceEvent(const DatasourceEvent* event) {
474 XmedDataModel* dataModel = (XmedDataModel*)this->getDataModel();
475 if ( dataModel == NULL ) {
476 STDLOG("No data model associated to this tree view");
481 // __GBO__ To know what to do we should test the type, because the
482 // object could be a mesh, a timeseries or a single field. We test
483 // here the case of a single field. Moreover, there could have
484 // options such that "change the underlying mesh".
487 XmedDataObject* dataObject = event->objectdata;
489 if ( event->eventtype == DatasourceEvent::EVENT_IMPORT_OBJECT ) {
490 std::cout << "IMPORT object in workspace: " << dataObject->toString() << std::endl;
491 STDLOG("IMPORT object in workspace:\n"<<dataObject->toString());
492 // _GBO_ QUESTION: tag automatically the object as a peristant object ??
493 // We first add the data object to the internal data model
494 dataModel->addDataObject(dataObject);
495 // Then we request the tree view to consider this new object
496 this->getDataTreeModel()->addData(dataObject);
498 else if ( event->eventtype == DatasourceEvent::EVENT_USE_OBJECT ) {
499 STDLOG("USE object in workspace:\n"<<dataObject->toString());
500 // We first add the data object to the internal data model
501 dataModel->addDataObject(dataObject);
502 // Then we request the tree view to consider this new object
503 this->getDataTreeModel()->addData(dataObject);
505 // We define a proxy for this object in the tui console.
506 STDLOG("Define a proxy variable in the console with name : "<<QCHARSTAR(event->objectalias));
507 bool askForOptions = false;
508 _importFieldIntoConsole(dataObject->getFieldHandler(),
510 QCHARSTAR(event->objectalias));
512 else if ( event->eventtype == DatasourceEvent::EVENT_ADD_DATASOURCE ) {
513 QStringList commands;
514 commands += QString("medcalc.LoadDataSource('%1')").arg(event->objectalias);
515 _consoleDriver->exec(commands);
517 else if ( event->eventtype == DatasourceEvent::EVENT_ADD_IMAGE_AS_DATASOURCE ) {
518 QStringList commands;
519 commands += QString("medcalc.LoadImageAsDataSource('%1')").arg(event->objectalias);
520 _consoleDriver->exec(commands);
523 STDLOG("The event "<<event->eventtype<<" is not implemented yet");
528 WorkspaceController::_getViewMode()
530 MEDCALC::MEDPresentationViewMode viewMode = _salomeModule->getSelectedViewMode();
532 case MEDCALC::VIEW_MODE_REPLACE: return "MEDCALC.VIEW_MODE_REPLACE";
533 case MEDCALC::VIEW_MODE_OVERLAP: return "MEDCALC.VIEW_MODE_OVERLAP";
534 case MEDCALC::VIEW_MODE_NEW_LAYOUT: return "MEDCALC.VIEW_MODE_NEW_LAYOUT";
535 case MEDCALC::VIEW_MODE_SPLIT_VIEW: return "MEDCALC.VIEW_MODE_SPLIT_VIEW";
541 WorkspaceController::_getColorMap()
543 MEDCALC::MEDPresentationColorMap colorMap = _salomeModule->getSelectedColorMap();
545 case MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW: return "MEDCALC.COLOR_MAP_BLUE_TO_RED_RAINBOW";
546 case MEDCALC::COLOR_MAP_COOL_TO_WARM: return "MEDCALC.COLOR_MAP_COOL_TO_WARM";
552 * This slot can process the event coming from the
553 * DatasourceController. The connection between the datasource signal
554 * and this slot is realized by the main class MEDModule.
556 void WorkspaceController::processPresentationEvent(const PresentationEvent* event) {
557 XmedDataModel* dataModel = (XmedDataModel*)this->getDataModel();
558 if ( dataModel == NULL ) {
559 STDLOG("No data model associated to this tree view");
564 // __GBO__ To know what to do we should test the type, because the
565 // object could be a mesh, a timeseries or a single field. We test
566 // here the case of a single field. Moreover, there could have
567 // options such that "change the underlying mesh".
570 XmedDataObject* dataObject = event->objectdata;
572 // --> Send commands to SALOME Python console
573 if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SCALAR_MAP ) {
574 QString viewMode = _getViewMode();
575 //QString displayedInfo = ; // from PresentationController combobox
576 //QString scalarBarRange = ; // from PresentationController spinbox
577 QString colorMap = _getColorMap();
578 MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
579 QStringList commands;
580 commands += QString("medcalc.MakeScalarMap(accessField(%1), %2, colorMap=%3)").arg(fieldHandler->id).arg(viewMode).arg(colorMap);
581 _consoleDriver->exec(commands);
583 else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_CONTOUR ) {
584 QString viewMode = _getViewMode();
585 MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
586 QStringList commands;
587 commands += QString("medcalc.MakeContour(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
588 _consoleDriver->exec(commands);
590 else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_VECTOR_FIELD ) {
591 QString viewMode = _getViewMode();
592 MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
593 QStringList commands;
594 commands += QString("medcalc.MakeVectorField(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
595 _consoleDriver->exec(commands);
597 else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SLICES ) {
598 QString viewMode = _getViewMode();
599 MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
600 QStringList commands;
601 commands += QString("medcalc.MakeSlices(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
602 _consoleDriver->exec(commands);
604 else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_DEFLECTION_SHAPE ) {
605 QString viewMode = _getViewMode();
606 MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
607 QStringList commands;
608 commands += QString("medcalc.MakeDeflectionShape(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
609 _consoleDriver->exec(commands);
611 else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_POINT_SPRITE ) {
612 QString viewMode = _getViewMode();
613 MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
614 QStringList commands;
615 commands += QString("medcalc.MakePointSprite(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
616 _consoleDriver->exec(commands);
619 STDLOG("The event "<<event->eventtype<<" is not implemented yet");
624 WorkspaceController::processProcessingEvent(const ProcessingEvent* event)
626 XmedDataModel* dataModel = (XmedDataModel*)this->getDataModel();
627 if ( dataModel == NULL ) {
628 STDLOG("No data model associated to this tree view");
633 // __GBO__ To know what to do we should test the type, because the
634 // object could be a mesh, a timeseries or a single field. We test
635 // here the case of a single field. Moreover, there could have
636 // options such that "change the underlying mesh".
639 XmedDataObject* dataObject = event->objectdata;
641 if ( event->eventtype == ProcessingEvent::EVENT_IMPORT_OBJECT ) {
642 std::cout << "IMPORT object in workspace: " << dataObject->toString() << std::endl;
643 STDLOG("IMPORT object in workspace:\n"<<dataObject->toString());
644 // _GBO_ QUESTION: tag automatically the object as a peristant object ??
645 // We first add the data object to the internal data model
646 dataModel->addDataObject(dataObject);
647 // Then we request the tree view to consider this new object
648 this->getDataTreeModel()->addData(dataObject);
652 void WorkspaceController::OnSaveWorkspace() {
654 // Dialog to get the filename where the workspace must be saved into
656 filter.append(tr("FILE_FILTER_MED"));
658 QString filename = SUIT_FileDlg::getFileName(_salomeModule->getApp()->desktop(),
661 tr("SAVE_WORKSPACE_DATA"),
664 if ( filename.isEmpty() ) return;
666 STDLOG("OnWorkspaceSave: save the workspace in the file " << QCHARSTAR(filename));
667 QStringList commands;
668 commands+=QString("saveWorkspace('%1')").arg(filename);
669 _consoleDriver->exec(commands);
672 #include <QMessageBox>
673 void WorkspaceController::OnCleanWorkspace() {
674 // Remove field from console
675 QStringList commands;
676 commands += QString("cleanWorkspace()");
677 _consoleDriver->exec(commands);