From: Cédric Aguerre Date: Fri, 15 Apr 2016 15:31:28 +0000 (+0200) Subject: [MEDCalc] Prepare to presentation edition X-Git-Tag: V8_1_0a1~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=76bad17550130ffef04019e0209ffda14d26d39d;p=modules%2Fmed.git [MEDCalc] Prepare to presentation edition --- diff --git a/idl/MEDPresentationManager.idl b/idl/MEDPresentationManager.idl index d108a917e..deb0f0a52 100644 --- a/idl/MEDPresentationManager.idl +++ b/idl/MEDPresentationManager.idl @@ -132,6 +132,13 @@ module MEDCALC void setPresentationProperty(in long presId, in string propName, in string propValue); string getPresentationProperty(in long presId, in string propName); + void updateScalarMap(in long presId, in ScalarMapParameters params); + void updateContour(in long presId, in ContourParameters params); + void updateVectorField(in long presId, in VectorFieldParameters params); + void updateSlices(in long presId, in SlicesParameters params); + void updateDeflectionShape(in long presId, in DeflectionShapeParameters params); + void updatePointSprite(in long presId, in PointSpriteParameters params); + }; }; diff --git a/src/MEDCalc/cmp/MEDPresentation.cxx b/src/MEDCalc/cmp/MEDPresentation.cxx index 24d36c5a6..10fe56a44 100644 --- a/src/MEDCalc/cmp/MEDPresentation.cxx +++ b/src/MEDCalc/cmp/MEDPresentation.cxx @@ -45,20 +45,23 @@ MEDPresentation::MEDPresentation(MEDPresentation::TypeID fieldHandlerId, std::st setProperty("name", name); } -void MEDPresentation::generatePipeline() +void +MEDPresentation::generatePipeline() { // Might be more complicated in the future: this->internalGeneratePipeline(); } -void MEDPresentation::pushInternal(PyObject * obj, PyObject * disp) +void +MEDPresentation::pushInternal(PyObject* obj, PyObject* disp) { _pipeline.push_back(obj); _display.push_back(disp); } -void MEDPresentation::setProperty(const std::string& propName, const std::string& propValue) +void +MEDPresentation::setProperty(const std::string& propName, const std::string& propValue) { // LIMITED!!! For now switch the first display element to Wireframe /* @@ -82,7 +85,8 @@ MEDPresentation::getProperty(const std::string& propName) const } } -PyObject * MEDPresentation::getPythonObjectFromMain(const char * python_var) const +PyObject* +MEDPresentation::getPythonObjectFromMain(const char* python_var) const { // TODO: improve to avoid getting dict at each call @@ -92,7 +96,8 @@ PyObject * MEDPresentation::getPythonObjectFromMain(const char * python_var) con return PyDict_GetItemString(global_dict, python_var); } -std::string MEDPresentation::getFieldTypeString(MEDCoupling::TypeOfField fieldType) const +std::string +MEDPresentation::getFieldTypeString(MEDCoupling::TypeOfField fieldType) const { switch(fieldType) { @@ -135,7 +140,7 @@ MEDPresentation::getResetCameraCommand() const std::string MEDPresentation::getColorMapCommand(MEDCALC::MEDPresentationColorMap colorMap) const { - switch(colorMap) { + switch (colorMap) { case MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW: return "Blue to Red Rainbow"; case MEDCALC::COLOR_MAP_COOL_TO_WARM: return "Cool to Warm"; } diff --git a/src/MEDCalc/cmp/MEDPresentation.hxx b/src/MEDCalc/cmp/MEDPresentation.hxx index aac5c5a00..e76750107 100644 --- a/src/MEDCalc/cmp/MEDPresentation.hxx +++ b/src/MEDCalc/cmp/MEDPresentation.hxx @@ -61,9 +61,14 @@ protected: private: - void generatePipeline(); // reserved to friend class MEDPresentationManager std::string getFieldTypeString(MEDCoupling::TypeOfField fieldType) const; + // The following functions are reserved to friend class MEDPresentationManager + void generatePipeline(); + + template + void updatePipeline(PresentationParameters params); + protected: std::string _fileName; @@ -84,4 +89,6 @@ private: std::map _properties; }; +#include "MEDPresentation.txx" + #endif /* SRC_MEDCALC_CMP_MEDPRESENTATION_HXX_ */ diff --git a/src/MEDCalc/cmp/MEDPresentation.txx b/src/MEDCalc/cmp/MEDPresentation.txx new file mode 100644 index 000000000..a99a46260 --- /dev/null +++ b/src/MEDCalc/cmp/MEDPresentation.txx @@ -0,0 +1,30 @@ +// Copyright (C) 2016 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef _MED_PRESENTATION_TXX_ +#define _MED_PRESENTATION_TXX_ + +template +void +MEDPresentation::updatePipeline(PresentationParameters params) +{ + static_cast(this)->updatePipeline(params); +} + +#endif // _MED_PRESENTATION_TXX_ diff --git a/src/MEDCalc/cmp/MEDPresentationContour.cxx b/src/MEDCalc/cmp/MEDPresentationContour.cxx index 883cfb176..cdf86ed67 100644 --- a/src/MEDCalc/cmp/MEDPresentationContour.cxx +++ b/src/MEDCalc/cmp/MEDPresentationContour.cxx @@ -47,3 +47,9 @@ MEDPresentationContour::internalGeneratePipeline() PyGILState_Release(_gil_state); } + +void +MEDPresentationContour::updatePipeline(const MEDCALC::ContourParameters& params) +{ + // :TODO: +} diff --git a/src/MEDCalc/cmp/MEDPresentationContour.hxx b/src/MEDCalc/cmp/MEDPresentationContour.hxx index 555dfe770..e03b76b58 100644 --- a/src/MEDCalc/cmp/MEDPresentationContour.hxx +++ b/src/MEDCalc/cmp/MEDPresentationContour.hxx @@ -31,6 +31,8 @@ public: {} virtual ~MEDPresentationContour() {} + void updatePipeline(const MEDCALC::ContourParameters& params); + protected: virtual void internalGeneratePipeline(); diff --git a/src/MEDCalc/cmp/MEDPresentationDeflectionShape.cxx b/src/MEDCalc/cmp/MEDPresentationDeflectionShape.cxx index 1a20da493..e56aa9f4b 100644 --- a/src/MEDCalc/cmp/MEDPresentationDeflectionShape.cxx +++ b/src/MEDCalc/cmp/MEDPresentationDeflectionShape.cxx @@ -47,3 +47,9 @@ MEDPresentationDeflectionShape::internalGeneratePipeline() PyGILState_Release(_gil_state); } + +void +MEDPresentationDeflectionShape::updatePipeline(const MEDCALC::DeflectionShapeParameters& params) +{ + // :TODO: +} diff --git a/src/MEDCalc/cmp/MEDPresentationDeflectionShape.hxx b/src/MEDCalc/cmp/MEDPresentationDeflectionShape.hxx index 9d614bf19..f9bbbb2f2 100644 --- a/src/MEDCalc/cmp/MEDPresentationDeflectionShape.hxx +++ b/src/MEDCalc/cmp/MEDPresentationDeflectionShape.hxx @@ -31,6 +31,8 @@ public: {} virtual ~MEDPresentationDeflectionShape() {} + void updatePipeline(const MEDCALC::DeflectionShapeParameters& params); + protected: virtual void internalGeneratePipeline(); diff --git a/src/MEDCalc/cmp/MEDPresentationManager_i.cxx b/src/MEDCalc/cmp/MEDPresentationManager_i.cxx index b6c9ba970..c5f7a8f0b 100644 --- a/src/MEDCalc/cmp/MEDPresentationManager_i.cxx +++ b/src/MEDCalc/cmp/MEDPresentationManager_i.cxx @@ -63,25 +63,30 @@ MEDPresentationManager_i::GenerateID() return START_ID; } +MEDPresentation* +MEDPresentationManager_i::_getPresentation(MEDPresentation::TypeID presentationID) const +{ + std::map::const_iterator citr = _presentations.find(presentationID); + if (citr == _presentations.end()) + return NULL; + return (*citr).second; +} + void -MEDPresentationManager_i::setPresentationProperty(MEDPresentation::TypeID presentationID, const char * propName, const char * propValue) +MEDPresentationManager_i::setPresentationProperty(MEDPresentation::TypeID presentationID, const char* propName, const char* propValue) { - if (_presentations.find(presentationID) != _presentations.end()) - { - MEDPresentation * pres(_presentations[presentationID]); - pres->setProperty(propName, propValue); - } + MEDPresentation* pres = _getPresentation(presentationID); + if (pres) + pres->setProperty(propName, propValue); else - { - std::cerr << "setPresentationProperty(): presentation not found!!" << std::endl; - } + std::cerr << "setPresentationProperty(): presentation not found!!" << std::endl; } char* MEDPresentationManager_i::getPresentationProperty(MEDPresentation::TypeID presentationID, const char* propName) { - if (_presentations.find(presentationID) != _presentations.end()) { - MEDPresentation* pres = _presentations[presentationID]; + MEDPresentation* pres = _getPresentation(presentationID); + if (pres) { return (char*) pres->getProperty(propName).c_str(); } else { @@ -125,3 +130,39 @@ MEDPresentationManager_i::makePointSprite(const MEDCALC::PointSpriteParameters& { return _makePresentation(params); } + +void +MEDPresentationManager_i::updateScalarMap(MEDPresentation::TypeID presentationID, const MEDCALC::ScalarMapParameters& params) +{ + return _updatePresentation(presentationID, params); +} + +void +MEDPresentationManager_i::updateContour(MEDPresentation::TypeID presentationID, const MEDCALC::ContourParameters& params) +{ + return _updatePresentation(presentationID, params); +} + +void +MEDPresentationManager_i::updateVectorField(MEDPresentation::TypeID presentationID, const MEDCALC::VectorFieldParameters& params) +{ + return _updatePresentation(presentationID, params); +} + +void +MEDPresentationManager_i::updateSlices(MEDPresentation::TypeID presentationID, const MEDCALC::SlicesParameters& params) +{ + return _updatePresentation(presentationID, params); +} + +void +MEDPresentationManager_i::updateDeflectionShape(MEDPresentation::TypeID presentationID, const MEDCALC::DeflectionShapeParameters& params) +{ + return _updatePresentation(presentationID, params); +} + +void +MEDPresentationManager_i::updatePointSprite(MEDPresentation::TypeID presentationID, const MEDCALC::PointSpriteParameters& params) +{ + return _updatePresentation(presentationID, params); +} diff --git a/src/MEDCalc/cmp/MEDPresentationManager_i.hxx b/src/MEDCalc/cmp/MEDPresentationManager_i.hxx index 5af811002..826ecc7bb 100644 --- a/src/MEDCalc/cmp/MEDPresentationManager_i.hxx +++ b/src/MEDCalc/cmp/MEDPresentationManager_i.hxx @@ -46,9 +46,16 @@ class MEDPresentationManager_i: public POA_MEDCALC::MEDPresentationManager, MEDCALC_EXPORT MEDPresentation::TypeID makeDeflectionShape(const MEDCALC::DeflectionShapeParameters&); MEDCALC_EXPORT MEDPresentation::TypeID makePointSprite(const MEDCALC::PointSpriteParameters&); - MEDCALC_EXPORT void setPresentationProperty(MEDPresentation::TypeID presentationID, const char * propName, const char * propValue); + MEDCALC_EXPORT void setPresentationProperty(MEDPresentation::TypeID presentationID, const char* propName, const char* propValue); MEDCALC_EXPORT char* getPresentationProperty(MEDPresentation::TypeID presentationID, const char* propName); + MEDCALC_EXPORT void updateScalarMap(MEDPresentation::TypeID presentationID, const MEDCALC::ScalarMapParameters&); + MEDCALC_EXPORT void updateContour(MEDPresentation::TypeID presentationID, const MEDCALC::ContourParameters&); + MEDCALC_EXPORT void updateVectorField(MEDPresentation::TypeID presentationID, const MEDCALC::VectorFieldParameters&); + MEDCALC_EXPORT void updateSlices(MEDPresentation::TypeID presentationID, const MEDCALC::SlicesParameters&); + MEDCALC_EXPORT void updateDeflectionShape(MEDPresentation::TypeID presentationID, const MEDCALC::DeflectionShapeParameters&); + MEDCALC_EXPORT void updatePointSprite(MEDPresentation::TypeID presentationID, const MEDCALC::PointSpriteParameters&); + private: MEDPresentationManager_i(); virtual ~MEDPresentationManager_i(); @@ -59,14 +66,20 @@ class MEDPresentationManager_i: public POA_MEDCALC::MEDPresentationManager, template MEDPresentation::TypeID _makePresentation(PresentationParameters params); + // Update presentation + template + void _updatePresentation(MEDPresentation::TypeID presentationID, PresentationParameters params); + + MEDPresentation* _getPresentation(MEDPresentation::TypeID) const; + private : // The MEDPresentationManager is a singleton, whose instance can be obtained // using the getInstance static method. - static MEDPresentationManager_i * _instance; + static MEDPresentationManager_i* _instance; // Owns a list of MEDPresentation objects - std::map< MEDPresentation::TypeID, MEDPresentation * > _presentations; + std::map _presentations; }; diff --git a/src/MEDCalc/cmp/MEDPresentationManager_i.txx b/src/MEDCalc/cmp/MEDPresentationManager_i.txx index c315746ea..eb283bf15 100644 --- a/src/MEDCalc/cmp/MEDPresentationManager_i.txx +++ b/src/MEDCalc/cmp/MEDPresentationManager_i.txx @@ -40,4 +40,17 @@ MEDPresentationManager_i::_makePresentation(PresentationParameters params) return newID; } +template +void +MEDPresentationManager_i::_updatePresentation(MEDPresentation::TypeID presentationID, PresentationParameters params) +{ + MEDPresentation* presentation = _getPresentation(presentationID); + if (!presentation) { + std::cerr << "_updatePresentation(): presentation not found!!" << std::endl; + return; + } + + presentation->updatePipeline(params); +} + #endif // _MED_PRESENTATION_MANAGER_I_TXX_ diff --git a/src/MEDCalc/cmp/MEDPresentationPointSprite.cxx b/src/MEDCalc/cmp/MEDPresentationPointSprite.cxx index 3d618575f..f36880369 100644 --- a/src/MEDCalc/cmp/MEDPresentationPointSprite.cxx +++ b/src/MEDCalc/cmp/MEDPresentationPointSprite.cxx @@ -47,3 +47,9 @@ MEDPresentationPointSprite::internalGeneratePipeline() PyGILState_Release(_gil_state); } + +void +MEDPresentationPointSprite::updatePipeline(const MEDCALC::PointSpriteParameters& params) +{ + // :TODO: +} diff --git a/src/MEDCalc/cmp/MEDPresentationPointSprite.hxx b/src/MEDCalc/cmp/MEDPresentationPointSprite.hxx index 34f0dd170..27530af82 100644 --- a/src/MEDCalc/cmp/MEDPresentationPointSprite.hxx +++ b/src/MEDCalc/cmp/MEDPresentationPointSprite.hxx @@ -31,6 +31,8 @@ public: {} virtual ~MEDPresentationPointSprite() {} + void updatePipeline(const MEDCALC::PointSpriteParameters& params); + protected: virtual void internalGeneratePipeline(); diff --git a/src/MEDCalc/cmp/MEDPresentationScalarMap.cxx b/src/MEDCalc/cmp/MEDPresentationScalarMap.cxx index a09da3feb..6042bf8f3 100644 --- a/src/MEDCalc/cmp/MEDPresentationScalarMap.cxx +++ b/src/MEDCalc/cmp/MEDPresentationScalarMap.cxx @@ -48,3 +48,9 @@ MEDPresentationScalarMap::internalGeneratePipeline() PyGILState_Release(_gil_state); } + +void +MEDPresentationScalarMap::updatePipeline(const MEDCALC::ScalarMapParameters& params) +{ + // :TODO: +} diff --git a/src/MEDCalc/cmp/MEDPresentationScalarMap.hxx b/src/MEDCalc/cmp/MEDPresentationScalarMap.hxx index 1b26af56f..d3d1ae1cf 100644 --- a/src/MEDCalc/cmp/MEDPresentationScalarMap.hxx +++ b/src/MEDCalc/cmp/MEDPresentationScalarMap.hxx @@ -31,6 +31,8 @@ public: {} virtual ~MEDPresentationScalarMap() {} + void updatePipeline(const MEDCALC::ScalarMapParameters& params); + protected: virtual void internalGeneratePipeline(); diff --git a/src/MEDCalc/cmp/MEDPresentationSlices.cxx b/src/MEDCalc/cmp/MEDPresentationSlices.cxx index 4b5636aad..9b5d97c3c 100644 --- a/src/MEDCalc/cmp/MEDPresentationSlices.cxx +++ b/src/MEDCalc/cmp/MEDPresentationSlices.cxx @@ -47,3 +47,9 @@ MEDPresentationSlices::internalGeneratePipeline() PyGILState_Release(_gil_state); } + +void +MEDPresentationSlices::updatePipeline(const MEDCALC::SlicesParameters& params) +{ + // :TODO: +} diff --git a/src/MEDCalc/cmp/MEDPresentationSlices.hxx b/src/MEDCalc/cmp/MEDPresentationSlices.hxx index a738d7a3f..b7ee4184e 100644 --- a/src/MEDCalc/cmp/MEDPresentationSlices.hxx +++ b/src/MEDCalc/cmp/MEDPresentationSlices.hxx @@ -31,6 +31,8 @@ public: {} virtual ~MEDPresentationSlices() {} + void updatePipeline(const MEDCALC::SlicesParameters& params); + protected: virtual void internalGeneratePipeline(); diff --git a/src/MEDCalc/cmp/MEDPresentationVectorField.cxx b/src/MEDCalc/cmp/MEDPresentationVectorField.cxx index ae03a030d..c5a1b3e34 100644 --- a/src/MEDCalc/cmp/MEDPresentationVectorField.cxx +++ b/src/MEDCalc/cmp/MEDPresentationVectorField.cxx @@ -47,3 +47,9 @@ MEDPresentationVectorField::internalGeneratePipeline() PyGILState_Release(_gil_state); } + +void +MEDPresentationVectorField::updatePipeline(const MEDCALC::VectorFieldParameters& params) +{ + // :TODO: +} diff --git a/src/MEDCalc/cmp/MEDPresentationVectorField.hxx b/src/MEDCalc/cmp/MEDPresentationVectorField.hxx index a7fc8d89f..7981f4264 100644 --- a/src/MEDCalc/cmp/MEDPresentationVectorField.hxx +++ b/src/MEDCalc/cmp/MEDPresentationVectorField.hxx @@ -31,6 +31,8 @@ public: {} virtual ~MEDPresentationVectorField() {} + void updatePipeline(const MEDCALC::VectorFieldParameters& params); + protected: virtual void internalGeneratePipeline(); diff --git a/src/MEDCalc/gui/MEDModule.cxx b/src/MEDCalc/gui/MEDModule.cxx index c40bbe231..448cc7f04 100644 --- a/src/MEDCalc/gui/MEDModule.cxx +++ b/src/MEDCalc/gui/MEDModule.cxx @@ -348,4 +348,9 @@ MEDModule::onDblClick(const QModelIndex& index) STDLOG(" - Field id: " + oss.str()); STDLOG(" - Presentation name: " + name); + // :TODO: + // get edited values from a popup widget + // get presentation + // call presentation edit function + }