From bb6d28ff5b18878d9351223d03e3eeb909483b50 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Aguerre?= Date: Wed, 5 Aug 2015 15:31:50 +0200 Subject: [PATCH] Add presentation in datasource tree --- idl/MEDEventListener.idl | 1 + src/MEDCalc/cmp/MEDPresentation.cxx | 6 +++++ src/MEDCalc/cmp/MEDPresentation.hxx | 6 ++--- src/MEDCalc/gui/DatasourceController.cxx | 30 ++++++++++++++++------- src/MEDCalc/gui/DatasourceController.hxx | 3 ++- src/MEDCalc/gui/MED_images.ts | 4 +++ src/MEDCalc/gui/MED_msg_en.ts | 4 +++ src/MEDCalc/gui/MED_msg_fr.ts | 4 +++ src/MEDCalc/res/CMakeLists.txt | 1 + src/MEDCalc/res/pqAppIcon16.png | Bin 0 -> 812 bytes src/MEDCalc/tui/medevents.py | 16 ++++++------ src/MEDCalc/tui/medpresentation.py | 2 +- 12 files changed, 54 insertions(+), 23 deletions(-) create mode 100644 src/MEDCalc/res/pqAppIcon16.png 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 0000000000000000000000000000000000000000..38713ca6990799c167a51e9bfb3f997966b81c8f GIT binary patch literal 812 zcmV+{1JnG8P)< zK~y-)&CpLz6lVa(@!#{z%rmpI{8^Tw%W4TEC>Yyx+lZ(j&>Eryk{-Bdf*#s5^$qw6 zy!je>=?!8GX%D@ac&Nfw!LDhIAPdW1U14{pv%BofJTuQc(@Wtk)bHtc`W$}1{~b9R z6u{NaPOT#zXNr`>s#e9*e=7dz>t>89qRG`R}v`J_)GfM2+_^mHWwoABVW!G3k4RM&WPIj)8Bwx{Sf* z=9w|q9e1l$zU(yqOnuEVr>4bp4L<0qEW{Fn2J0TZWAW~>;Lr=gR_nU>3NfB+x`TqiegjK z+qp~80X@qrYAoU|YVWc^@kxaOzyy#vBg6$ThN@w>SwsFBJA+|r zqK$+!;*MO{&0bbvc4vqJsGet8f6Ol-;*tWu45b-e(-P2i6nuZJe8sJ43>Sz3Xr586 zu8U*vruI-)QIoyiE^-r|A`R}KMyey=D!t)@Ao3=GiX)YRsRuFtC{lp8&%G@FXu#>P@P zS9E*ixs?|cvKc;yof9@> qUXx|xasH(NyHpDHw)gA!X!;jzPewAnXz$$s0000