From: Cédric Aguerre Date: Wed, 5 Aug 2015 13:31:50 +0000 (+0200) Subject: Add presentation in datasource tree X-Git-Tag: V8_0_0a1~5^2~33 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bb6d28ff5b18878d9351223d03e3eeb909483b50;p=modules%2Fmed.git Add presentation in datasource tree --- diff --git a/idl/MEDEventListener.idl b/idl/MEDEventListener.idl index 5d4df9211..5eb198e82 100644 --- a/idl/MEDEventListener.idl +++ b/idl/MEDEventListener.idl @@ -41,6 +41,7 @@ module MEDCALC MedEventType type; long dataId; string filename; + long presentationId; }; interface MEDEventListener: SALOME::GenericObj { diff --git a/src/MEDCalc/cmp/MEDPresentation.cxx b/src/MEDCalc/cmp/MEDPresentation.cxx index 7c129c23c..b389d5884 100644 --- a/src/MEDCalc/cmp/MEDPresentation.cxx +++ b/src/MEDCalc/cmp/MEDPresentation.cxx @@ -24,6 +24,12 @@ #include #include +MEDPresentation::MEDPresentation(MEDCALC::FieldHandler* fieldHdl, std::string name) + : _fieldHandler(fieldHdl), _pipeline(0), _display(0), _properties() +{ + setProperty("name", name); +} + void MEDPresentation::generatePipeline() { // Might be more complicated in the future: diff --git a/src/MEDCalc/cmp/MEDPresentation.hxx b/src/MEDCalc/cmp/MEDPresentation.hxx index ef1bdf791..6fb01555a 100644 --- a/src/MEDCalc/cmp/MEDPresentation.hxx +++ b/src/MEDCalc/cmp/MEDPresentation.hxx @@ -46,9 +46,7 @@ public: protected: - MEDPresentation(MEDCALC::FieldHandler* fieldHdl): - _fieldHandler(fieldHdl), _pipeline(0), _display(0), _properties() - {} + MEDPresentation(MEDCALC::FieldHandler* fieldHdl, std::string name); void generatePipeline(); virtual void internalGeneratePipeline() = 0; @@ -74,7 +72,7 @@ class MEDCALC_EXPORT MEDPresentationScalarMap : public MEDPresentation { public: MEDPresentationScalarMap(MEDCALC::FieldHandler* fieldHdl, bool wireframe) : - MEDPresentation(fieldHdl), + MEDPresentation(fieldHdl, "MEDPresentationScalarMap"), _isWireframe(wireframe) {} virtual ~MEDPresentationScalarMap() {} diff --git a/src/MEDCalc/gui/DatasourceController.cxx b/src/MEDCalc/gui/DatasourceController.cxx index 4d7bc8b8e..386fa5e2d 100644 --- a/src/MEDCalc/gui/DatasourceController.cxx +++ b/src/MEDCalc/gui/DatasourceController.cxx @@ -40,7 +40,9 @@ // Datasource controller // ============================================================== // -DatasourceController::DatasourceController(StandardApp_Module * salomeModule) { +DatasourceController::DatasourceController(StandardApp_Module * salomeModule) + : _fieldSeriesEntries() +{ STDLOG("Creating a DatasourceController"); _salomeModule = salomeModule; _studyEditor = new SALOME_AppStudyEditor(_salomeModule->getApp()); @@ -150,7 +152,6 @@ DatasourceController::updateTreeViewWithNewDatasource(const MEDCALC::DatasourceH _studyEditor->setIcon(soDatasource,tr("ICO_DATASOURCE").toStdString().c_str()); _studyEditor->setParameterInt(soDatasource,OBJECT_ID,datasourceHandler->id); - // We can add the meshes as children of the datasource MEDCALC::MeshHandlerList * meshHandlerList = MEDFactoryClient::getDataManager()->getMeshList(datasourceHandler->id); @@ -171,6 +172,7 @@ DatasourceController::updateTreeViewWithNewDatasource(const MEDCALC::DatasourceH for(CORBA::ULong iFieldseries=0; iFieldserieslength(); iFieldseries++) { MEDCALC::FieldseriesHandler fieldseriesHandler = (*fieldseriesHandlerList)[iFieldseries]; SALOMEDS::SObject_var soFieldseries = _studyEditor->newObject(soMesh); + _fieldSeriesEntries[fieldseriesHandler.id] = soFieldseries->GetID(); std::string label(fieldseriesHandler.name); label +=" ("+std::string(XmedDataObject::mapTypeOfFieldLabel[fieldseriesHandler.type])+")"; @@ -179,23 +181,33 @@ DatasourceController::updateTreeViewWithNewDatasource(const MEDCALC::DatasourceH _studyEditor->setIcon(soFieldseries,tr("ICO_DATASOURCE_FIELD").toStdString().c_str()); _studyEditor->setParameterInt(soFieldseries,OBJECT_ID,fieldseriesHandler.id); _studyEditor->setParameterBool(soFieldseries,OBJECT_IS_IN_WORKSPACE,false); - //std::cout << "soFieldseries.GetIOR(): " << soFieldseries._retn()->GetIOR() << std::endl; - //std::cout << _studyEditor->findObject(soFieldseries._retn()->GetIOR())->GetIOR() << std::endl; - std::cout << "soFieldseries.GetName(): " << soFieldseries._retn()->GetName() << std::endl; - } } } void -DatasourceController::updateTreeViewWithNewPresentation(long presentationId) +DatasourceController::updateTreeViewWithNewPresentation(long fieldId, long presentationId) { if (presentationId < 0) { + std::cerr << "Unknown presentation\n"; return; } - std::string name = MEDFactoryClient::getPresentationManager()->getPresentationProperty(presentationId, "name"); + if (_fieldSeriesEntries.find(fieldId) == _fieldSeriesEntries.end()) { + std::cerr << "Field not found\n"; + return; + } + std::string entry = _fieldSeriesEntries[fieldId]; + SALOMEDS::SObject_ptr soFieldseries = _studyEditor->findObject(entry.c_str()); + if (soFieldseries->IsNull()) { + std::cerr << "Entry not found\n"; + return; + } + std::string name = MEDFactoryClient::getPresentationManager()->getPresentationProperty(presentationId, "name"); + SALOMEDS::SObject_var soPresentation = _studyEditor->newObject(soFieldseries); + _studyEditor->setName(soPresentation, tr(name.c_str()).toStdString().c_str()); + _studyEditor->setIcon(soPresentation, tr("ICO_MED_PRESENTATION").toStdString().c_str()); } void DatasourceController::OnAddDatasource() @@ -584,7 +596,7 @@ DatasourceController::processWorkspaceEvent(const MEDCALC::MedEvent* event) _salomeModule->updateObjBrowser(true); } else if ( event->type == MEDCALC::EVENT_ADD_PRESENTATION ) { - this->updateTreeViewWithNewPresentation(event->dataId); + this->updateTreeViewWithNewPresentation(event->dataId, event->presentationId); _salomeModule->updateObjBrowser(true); } } diff --git a/src/MEDCalc/gui/DatasourceController.hxx b/src/MEDCalc/gui/DatasourceController.hxx index 09ecdc140..0ec0a1806 100644 --- a/src/MEDCalc/gui/DatasourceController.hxx +++ b/src/MEDCalc/gui/DatasourceController.hxx @@ -102,11 +102,12 @@ private: void visualize(DatasourceEvent::EventType); void addDatasource(const char* filename); void updateTreeViewWithNewDatasource(const MEDCALC::DatasourceHandler*); - void updateTreeViewWithNewPresentation(long presentationId); + void updateTreeViewWithNewPresentation(long fieldId, long presentationId); private: StandardApp_Module * _salomeModule; SALOME_AppStudyEditor * _studyEditor; + std::map _fieldSeriesEntries; DlgChangeUnderlyingMesh * _dlgChangeUnderlyingMesh; DlgInterpolateField * _dlgInterpolateField; diff --git a/src/MEDCalc/gui/MED_images.ts b/src/MEDCalc/gui/MED_images.ts index 95df2d88e..86476bca1 100644 --- a/src/MEDCalc/gui/MED_images.ts +++ b/src/MEDCalc/gui/MED_images.ts @@ -3,6 +3,10 @@ @default + + ICO_MED_PRESENTATION + pqAppIcon16.png + ICO_IMPORT_MED datasource_add.png diff --git a/src/MEDCalc/gui/MED_msg_en.ts b/src/MEDCalc/gui/MED_msg_en.ts index bb06235c7..3f12bcf9b 100644 --- a/src/MEDCalc/gui/MED_msg_en.ts +++ b/src/MEDCalc/gui/MED_msg_en.ts @@ -3,6 +3,10 @@ DatasourceController + + MEDPresentationScalarMap + Scalar Map + LAB_ADD_DATA_SOURCE diff --git a/src/MEDCalc/gui/MED_msg_fr.ts b/src/MEDCalc/gui/MED_msg_fr.ts index 7ff258e34..c8d917f5b 100644 --- a/src/MEDCalc/gui/MED_msg_fr.ts +++ b/src/MEDCalc/gui/MED_msg_fr.ts @@ -3,6 +3,10 @@ DatasourceController + + MEDPresentationScalarMap + Carte scalaire + LAB_ADD_DATA_SOURCE diff --git a/src/MEDCalc/res/CMakeLists.txt b/src/MEDCalc/res/CMakeLists.txt index 87f6ab69f..fb78aa13c 100644 --- a/src/MEDCalc/res/CMakeLists.txt +++ b/src/MEDCalc/res/CMakeLists.txt @@ -36,5 +36,6 @@ SET(MED_RESOURCES_FILES MEDCalc_small.png workspace_clean.png workspace_save.png + pqAppIcon16.png ) INSTALL(FILES ${MED_RESOURCES_FILES} DESTINATION ${SALOME_MED_INSTALL_RES_DATA}) diff --git a/src/MEDCalc/res/pqAppIcon16.png b/src/MEDCalc/res/pqAppIcon16.png new file mode 100644 index 000000000..38713ca69 Binary files /dev/null and b/src/MEDCalc/res/pqAppIcon16.png differ diff --git a/src/MEDCalc/tui/medevents.py b/src/MEDCalc/tui/medevents.py index 2feb1645d..96ad59ed4 100644 --- a/src/MEDCalc/tui/medevents.py +++ b/src/MEDCalc/tui/medevents.py @@ -83,8 +83,8 @@ connectEventListener() # that they could be used in another context than the FieldProxy instances import MEDCALC -def __notifyGui(eventType, dataId=-1, filename=""): - medEvent = MEDCALC.MedEvent(eventType, dataId, filename) +def __notifyGui(eventType, dataId=-1, filename="", presentationId=-1): + medEvent = MEDCALC.MedEvent(eventType, dataId, filename, presentationId) if not eventListenerIsRunning(): return # Notify the GUI of the update event @@ -97,21 +97,21 @@ def notifyGui_updateField(fieldId): meta-data have changed so it could update the gui presentations of this field. """ - __notifyGui(MEDCALC.EVENT_UPDATE_FIELD,fieldId) + __notifyGui(MEDCALC.EVENT_UPDATE_FIELD, dataId=fieldId) # def notifyGui_putInWorkspace(fieldId): - __notifyGui(MEDCALC.EVENT_PUT_IN_WORKSPACE,fieldId) + __notifyGui(MEDCALC.EVENT_PUT_IN_WORKSPACE, dataId=fieldId) # def notifyGui_removeFromWorkspace(fieldId): - __notifyGui(MEDCALC.EVENT_REMOVE_FROM_WORKSPACE, fieldId) + __notifyGui(MEDCALC.EVENT_REMOVE_FROM_WORKSPACE, dataId=fieldId) def notifyGui_cleanWorkspace(): __notifyGui(MEDCALC.EVENT_CLEAN_WORKSPACE) # def notifyGui_addDatasource(filename): - __notifyGui(MEDCALC.EVENT_ADD_DATASOURCE, -1, filename) + __notifyGui(MEDCALC.EVENT_ADD_DATASOURCE, filename=filename) # -def notifyGui_addPresentation(presentation_id): - __notifyGui(MEDCALC.EVENT_ADD_PRESENTATION, presentation_id) +def notifyGui_addPresentation(fieldId, presId): + __notifyGui(MEDCALC.EVENT_ADD_PRESENTATION, dataId=fieldId, presentationId=presId) # diff --git a/src/MEDCalc/tui/medpresentation.py b/src/MEDCalc/tui/medpresentation.py index fad2d9680..0395826b5 100644 --- a/src/MEDCalc/tui/medpresentation.py +++ b/src/MEDCalc/tui/medpresentation.py @@ -33,7 +33,7 @@ def MakeScalarMap(proxy, viewMode=MEDCALC.VIEW_MODE_REPLACE): params = MEDCALC.ScalarMapParameters(proxy.id, viewMode) presentation_id = __manager.makeScalarMap(params) - notifyGui_addPresentation(presentation_id) + notifyGui_addPresentation(proxy.id, presentation_id) # def MakeIsoSurface():