#include <SUIT_ResourceMgr.h>
#include <QTimer>
+#include <QMessageBox>
/*!
* This class defines a DockWidget plugged in the SALOME application,
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!!!");
}
/*!
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;
}
}
-QString
-WorkspaceController::_getViewMode()
-{
- 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";
- }
- return QString();
-}
-
-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";
- }
- return QString();
-}
-
-/**
- * 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");
- return;
- }
-
- // >>>
- // __GBO__ To know what to do we should test the type, because the
- // object could be a mesh, a timeseries or a single field. We test
- // here the case of a single field. Moreover, there could have
- // options such that "change the underlying mesh".
- // <<<
-
- 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("presentation_id = medcalc.MakeScalarMap(accessField(%1), %2, colorMap=%3)").arg(fieldHandler->id).arg(viewMode).arg(colorMap);
- commands += QString("presentation_id");
- _consoleDriver->exec(commands);
- }
- else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_CONTOUR ) {
- QString viewMode = _getViewMode();
- MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
- QStringList commands;
- commands += QString("presentation_id = medcalc.MakeContour(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
- commands += QString("presentation_id");
- _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("presentation_id = medcalc.MakeVectorField(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
- commands += QString("presentation_id");
- _consoleDriver->exec(commands);
- }
- else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SLICES ) {
- QString viewMode = _getViewMode();
- MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
- QStringList commands;
- commands += QString("presentation_id = medcalc.MakeSlices(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
- commands += QString("presentation_id");
- _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("presentation_id = medcalc.MakeDeflectionShape(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
- commands += QString("presentation_id");
- _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("presentation_id = medcalc.MakePointSprite(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
- commands += QString("presentation_id");
- _consoleDriver->exec(commands);
- }
- else if ( event->eventtype == PresentationEvent::EVENT_DELETE_PRESENTATION ) {
- QStringList commands;
- commands += QString("medcalc.RemovePresentation(%1)").arg(dataObject->getPresentationId());
- _consoleDriver->exec(commands);
- }
- else {
- STDLOG("The event "<<event->eventtype<<" is not implemented yet");
- }
-}
-
void
WorkspaceController::processProcessingEvent(const ProcessingEvent* event)
{