X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCalc%2Fgui%2FWorkspaceController.cxx;h=dd59a244776e709b9d1a9052e1951f3ac087960f;hb=51ed503edb7d4390ce4078ba445128995d70ed9c;hp=3137c82d2a84ecfd3a11c2e6f3dec1da05c07868;hpb=c55144bfb0c9d1d77af03ad9d0c34e18781a0532;p=modules%2Fmed.git diff --git a/src/MEDCalc/gui/WorkspaceController.cxx b/src/MEDCalc/gui/WorkspaceController.cxx index 3137c82d2..dd59a2447 100644 --- a/src/MEDCalc/gui/WorkspaceController.cxx +++ b/src/MEDCalc/gui/WorkspaceController.cxx @@ -35,12 +35,14 @@ #include #include +#include +#include + /*! * This class defines a DockWidget plugged in the SALOME application, * and containing a tree view for rendering a hierarchical data * model. This datamodel contains the objects used in the workspace. */ -//WorkspaceController::WorkspaceController(StandardApp_Module* salomeModule) WorkspaceController::WorkspaceController(MEDModule* salomeModule) : TreeGuiManager(salomeModule->getApp(), "Workspace") { @@ -100,7 +102,7 @@ WorkspaceController::WorkspaceController(MEDModule* salomeModule) } WorkspaceController::~WorkspaceController() { - std::cout << "WorkspaceController::~WorkspaceController()\n"; + STDLOG("WorkspaceController::~WorkspaceController()"); MEDEventListener_i::release(); } @@ -118,14 +120,12 @@ void WorkspaceController::createActions() { QString tooltip = tr("TIP_SAVE_WORKSPACE"); QString icon = tr("ICO_WORKSPACE_SAVE"); int actionId = _salomeModule->createStandardAction(label,this,SLOT(OnSaveWorkspace()),icon,tooltip); - //_salomeModule->addActionInToolbar(actionId); _salomeModule->createTool(actionId, toolbarId); label = tr("LAB_CLEAN_WORKSPACE"); tooltip = tr("TIP_CLEAN_WORKSPACE"); icon = tr("ICO_WORKSPACE_CLEAN"); actionId = _salomeModule->createStandardAction(label,this,SLOT(OnCleanWorkspace()),icon,tooltip); -//_salomeModule->addActionInToolbar(actionId); _salomeModule->createTool(actionId, toolbarId); } @@ -309,9 +309,26 @@ void WorkspaceController::processMedEvent(const MEDCALC::MedEvent* event) { 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!!!"); } /*! @@ -461,17 +478,6 @@ void WorkspaceController::_viewItemList(QStringList itemNameIdList) { _consoleDriver->exec(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"; - } -} - /** * This slot can process the event coming from the * DatasourceController. The connection between the datasource signal @@ -518,24 +524,24 @@ void WorkspaceController::processDatasourceEvent(const DatasourceEvent* 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); } 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 { STDLOG("The event "<eventtype<<" is not implemented yet"); } } -/** - * 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) { + +void +WorkspaceController::processProcessingEvent(const ProcessingEvent* event) +{ XmedDataModel* dataModel = (XmedDataModel*)this->getDataModel(); if ( dataModel == NULL ) { STDLOG("No data model associated to this tree view"); @@ -551,50 +557,14 @@ void WorkspaceController::processPresentationEvent(const PresentationEvent* even XmedDataObject* dataObject = event->objectdata; - if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SCALAR_MAP ) { - QString viewMode = _getViewMode(); - MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler(); - QStringList commands; - commands += QString("medcalc.MakeScalarMap(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode); - _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 "<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"<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); } }