#include <SUIT_Desktop.h>
#include <SUIT_ResourceMgr.h>
+#include <QTimer>
+#include <QMessageBox>
+
/*!
* This class defines a DockWidget plugged in the SALOME application,
* and containing a tree view for rendering a hierarchical data
emit workspaceSignal(event); // forward to DatasourceController
}
else if ( event->type == MEDCALC::EVENT_ADD_PRESENTATION ) {
- emit workspaceSignal(event); // forward to DatasourceController
+ emit workspaceSignal(event); // forward to PresentationController
}
-
+ else if ( event->type == MEDCALC::EVENT_REMOVE_PRESENTATION ) {
+ emit workspaceSignal(event); // forward to PresentationController
+ }
+ else if ( event->type == MEDCALC::EVENT_MODIFY_PRESENTATION ) {
+ emit workspaceSignal(event); // forward to PresentationController
+ }
+ else if ( event->type == MEDCALC::EVENT_PLAY_TEST ) {
+ emit workspaceSignal(event); // forward to TestController
+ }
+ else if ( event->type == MEDCALC::EVENT_QUIT_SALOME ) {
+ emit workspaceSignal(event); // forward to TestController
+ }
+ else if ( event->type == MEDCALC::EVENT_ERROR ) {
+ std::string msg(event->msg);
+ QMessageBox::warning(_salomeModule->getApp()->desktop(), "Error", QString::fromStdString(msg));
+ }
+ else
+ STDLOG("WorkspaceController::processMedEvent(): Unhandled event!!!");
}
/*!
}
else if ( event->eventtype == DatasourceEvent::EVENT_ADD_DATASOURCE ) {
QStringList commands;
- commands += QString("medcalc.LoadDataSource('%1')").arg(event->objectalias);
+ commands += QString("source_id = medcalc.LoadDataSource('%1')").arg(event->objectalias);
+ commands += QString("source_id");
_consoleDriver->exec(commands);
+
+ // Create a default presentation when loading a file
+ MEDCALC::MedEvent* evt = new MEDCALC::MedEvent();
+ evt->type = MEDCALC::EVENT_ADD_PRESENTATION;
+ evt->dataId = -1;
+ emit workspaceSignal(evt); // forward to PresentationController
}
else if ( event->eventtype == DatasourceEvent::EVENT_ADD_IMAGE_AS_DATASOURCE ) {
QStringList commands;
- commands += QString("medcalc.LoadImageAsDataSource('%1')").arg(event->objectalias);
+ commands += QString("source_id = medcalc.LoadImageAsDataSource('%1')").arg(event->objectalias);
+ commands += QString("source_id");
_consoleDriver->exec(commands);
}
else {
}
}
-QString
-WorkspaceController::_getViewMode()
+void
+WorkspaceController::processProcessingEvent(const ProcessingEvent* event)
{
- MEDCALC::MEDPresentationViewMode viewMode = _salomeModule->getSelectedViewMode();
- switch(viewMode) {
- case MEDCALC::VIEW_MODE_REPLACE: return "MEDCALC.VIEW_MODE_REPLACE";
- case MEDCALC::VIEW_MODE_OVERLAP: return "MEDCALC.VIEW_MODE_OVERLAP";
- case MEDCALC::VIEW_MODE_NEW_LAYOUT: return "MEDCALC.VIEW_MODE_NEW_LAYOUT";
- case MEDCALC::VIEW_MODE_SPLIT_VIEW: return "MEDCALC.VIEW_MODE_SPLIT_VIEW";
- }
-}
-
-QString
-WorkspaceController::_getColorMap()
-{
- MEDCALC::MEDPresentationColorMap colorMap = _salomeModule->getSelectedColorMap();
- switch(colorMap) {
- case MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW: return "MEDCALC.COLOR_MAP_BLUE_TO_RED_RAINBOW";
- case MEDCALC::COLOR_MAP_COOL_TO_WARM: return "MEDCALC.COLOR_MAP_COOL_TO_WARM";
- }
-}
-
-/**
- * This slot can process the event coming from the
- * DatasourceController. The connection between the datasource signal
- * and this slot is realized by the main class MEDModule.
- */
-void WorkspaceController::processPresentationEvent(const PresentationEvent* event) {
XmedDataModel* dataModel = (XmedDataModel*)this->getDataModel();
if ( dataModel == NULL ) {
STDLOG("No data model associated to this tree view");
XmedDataObject* dataObject = event->objectdata;
- // --> Send commands to SALOME Python console
- if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SCALAR_MAP ) {
- QString viewMode = _getViewMode();
- //QString displayedInfo = ; // from PresentationController combobox
- //QString scalarBarRange = ; // from PresentationController spinbox
- QString colorMap = _getColorMap();
- MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
- QStringList commands;
- commands += QString("medcalc.MakeScalarMap(accessField(%1), %2, colorMap=%3)").arg(fieldHandler->id).arg(viewMode).arg(colorMap);
- _consoleDriver->exec(commands);
- }
- else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_CONTOUR ) {
- QString viewMode = _getViewMode();
- MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
- QStringList commands;
- commands += QString("medcalc.MakeContour(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
- _consoleDriver->exec(commands);
- }
- else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_VECTOR_FIELD ) {
- QString viewMode = _getViewMode();
- MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
- QStringList commands;
- commands += QString("medcalc.MakeVectorField(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
- _consoleDriver->exec(commands);
- }
- else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SLICES ) {
- QString viewMode = _getViewMode();
- MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
- QStringList commands;
- commands += QString("medcalc.MakeSlices(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
- _consoleDriver->exec(commands);
- }
- else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_DEFLECTION_SHAPE ) {
- QString viewMode = _getViewMode();
- MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
- QStringList commands;
- commands += QString("medcalc.MakeDeflectionShape(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
- _consoleDriver->exec(commands);
- }
- else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_POINT_SPRITE ) {
- QString viewMode = _getViewMode();
- MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
- QStringList commands;
- commands += QString("medcalc.MakePointSprite(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
- _consoleDriver->exec(commands);
- }
- else {
- STDLOG("The event "<<event->eventtype<<" is not implemented yet");
+ if ( event->eventtype == ProcessingEvent::EVENT_IMPORT_OBJECT ) {
+ std::cout << "IMPORT object in workspace: " << dataObject->toString() << std::endl;
+ STDLOG("IMPORT object in workspace:\n"<<dataObject->toString());
+ // _GBO_ QUESTION: tag automatically the object as a peristant object ??
+ // We first add the data object to the internal data model
+ dataModel->addDataObject(dataObject);
+ // Then we request the tree view to consider this new object
+ this->getDataTreeModel()->addData(dataObject);
}
}