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);
+
};
};
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
/*
}
}
-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
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)
{
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";
}
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<typename PresentationType, typename PresentationParameters>
+ void updatePipeline(PresentationParameters params);
+
protected:
std::string _fileName;
std::map<std::string, std::string> _properties;
};
+#include "MEDPresentation.txx"
+
#endif /* SRC_MEDCALC_CMP_MEDPRESENTATION_HXX_ */
--- /dev/null
+// 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<typename PresentationType, typename PresentationParameters>
+void
+MEDPresentation::updatePipeline(PresentationParameters params)
+{
+ static_cast<PresentationType*>(this)->updatePipeline(params);
+}
+
+#endif // _MED_PRESENTATION_TXX_
PyGILState_Release(_gil_state);
}
+
+void
+MEDPresentationContour::updatePipeline(const MEDCALC::ContourParameters& params)
+{
+ // :TODO:
+}
{}
virtual ~MEDPresentationContour() {}
+ void updatePipeline(const MEDCALC::ContourParameters& params);
+
protected:
virtual void internalGeneratePipeline();
PyGILState_Release(_gil_state);
}
+
+void
+MEDPresentationDeflectionShape::updatePipeline(const MEDCALC::DeflectionShapeParameters& params)
+{
+ // :TODO:
+}
{}
virtual ~MEDPresentationDeflectionShape() {}
+ void updatePipeline(const MEDCALC::DeflectionShapeParameters& params);
+
protected:
virtual void internalGeneratePipeline();
return START_ID;
}
+MEDPresentation*
+MEDPresentationManager_i::_getPresentation(MEDPresentation::TypeID presentationID) const
+{
+ std::map<MEDPresentation::TypeID, MEDPresentation*>::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 {
{
return _makePresentation<MEDPresentationPointSprite>(params);
}
+
+void
+MEDPresentationManager_i::updateScalarMap(MEDPresentation::TypeID presentationID, const MEDCALC::ScalarMapParameters& params)
+{
+ return _updatePresentation<MEDPresentationScalarMap>(presentationID, params);
+}
+
+void
+MEDPresentationManager_i::updateContour(MEDPresentation::TypeID presentationID, const MEDCALC::ContourParameters& params)
+{
+ return _updatePresentation<MEDPresentationContour>(presentationID, params);
+}
+
+void
+MEDPresentationManager_i::updateVectorField(MEDPresentation::TypeID presentationID, const MEDCALC::VectorFieldParameters& params)
+{
+ return _updatePresentation<MEDPresentationVectorField>(presentationID, params);
+}
+
+void
+MEDPresentationManager_i::updateSlices(MEDPresentation::TypeID presentationID, const MEDCALC::SlicesParameters& params)
+{
+ return _updatePresentation<MEDPresentationSlices>(presentationID, params);
+}
+
+void
+MEDPresentationManager_i::updateDeflectionShape(MEDPresentation::TypeID presentationID, const MEDCALC::DeflectionShapeParameters& params)
+{
+ return _updatePresentation<MEDPresentationDeflectionShape>(presentationID, params);
+}
+
+void
+MEDPresentationManager_i::updatePointSprite(MEDPresentation::TypeID presentationID, const MEDCALC::PointSpriteParameters& params)
+{
+ return _updatePresentation<MEDPresentationPointSprite>(presentationID, params);
+}
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();
template<typename PresentationType, typename PresentationParameters>
MEDPresentation::TypeID _makePresentation(PresentationParameters params);
+ // Update presentation
+ template<typename PresentationType, typename PresentationParameters>
+ 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<MEDPresentation::TypeID, MEDPresentation*> _presentations;
};
return newID;
}
+template<typename PresentationType, typename PresentationParameters>
+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<PresentationType>(params);
+}
+
#endif // _MED_PRESENTATION_MANAGER_I_TXX_
PyGILState_Release(_gil_state);
}
+
+void
+MEDPresentationPointSprite::updatePipeline(const MEDCALC::PointSpriteParameters& params)
+{
+ // :TODO:
+}
{}
virtual ~MEDPresentationPointSprite() {}
+ void updatePipeline(const MEDCALC::PointSpriteParameters& params);
+
protected:
virtual void internalGeneratePipeline();
PyGILState_Release(_gil_state);
}
+
+void
+MEDPresentationScalarMap::updatePipeline(const MEDCALC::ScalarMapParameters& params)
+{
+ // :TODO:
+}
{}
virtual ~MEDPresentationScalarMap() {}
+ void updatePipeline(const MEDCALC::ScalarMapParameters& params);
+
protected:
virtual void internalGeneratePipeline();
PyGILState_Release(_gil_state);
}
+
+void
+MEDPresentationSlices::updatePipeline(const MEDCALC::SlicesParameters& params)
+{
+ // :TODO:
+}
{}
virtual ~MEDPresentationSlices() {}
+ void updatePipeline(const MEDCALC::SlicesParameters& params);
+
protected:
virtual void internalGeneratePipeline();
PyGILState_Release(_gil_state);
}
+
+void
+MEDPresentationVectorField::updatePipeline(const MEDCALC::VectorFieldParameters& params)
+{
+ // :TODO:
+}
{}
virtual ~MEDPresentationVectorField() {}
+ void updatePipeline(const MEDCALC::VectorFieldParameters& params);
+
protected:
virtual void internalGeneratePipeline();
STDLOG(" - Field id: " + oss.str());
STDLOG(" - Presentation name: " + name);
+ // :TODO:
+ // get edited values from a popup widget
+ // get presentation
+ // call presentation edit function
+
}