-// Copyright (C) 2011-2015 CEA/DEN, EDF R&D
+// Copyright (C) 2011-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
#include "MEDPresentationManager_i.hxx"
#include "MEDFactoryClient.hxx"
-#include "MEDPresentation.hxx"
+
+// presentations
+#include "MEDPresentationScalarMap.hxx"
+#include "MEDPresentationContour.hxx"
+#include "MEDPresentationVectorField.hxx"
+#include "MEDPresentationSlices.hxx"
+#include "MEDPresentationDeflectionShape.hxx"
+#include "MEDPresentationPointSprite.hxx"
+
+#include <iostream>
MEDPresentationManager_i* MEDPresentationManager_i::_instance = NULL;
*/
}
-TypeID MEDPresentationManager_i::GenerateID()
+MEDPresentation::TypeID
+MEDPresentationManager_i::GenerateID()
{
- static TypeID START_ID = -1;
+ static MEDPresentation::TypeID START_ID = -1;
START_ID++;
return START_ID;
}
-#include <iostream>
+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(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(TypeID presentationID, const char* propName)
+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 {
}
}
-TypeID
+MEDPresentation::TypeID
MEDPresentationManager_i::makeScalarMap(const MEDCALC::ScalarMapParameters& params)
{
- MEDCALC::MEDDataManager_ptr dataManager(MEDFactoryClient::getDataManager());
+ return _makePresentation<MEDPresentationScalarMap>(params);
+}
+
+MEDPresentation::TypeID
+MEDPresentationManager_i::makeContour(const MEDCALC::ContourParameters& params)
+{
+ return _makePresentation<MEDPresentationContour>(params);
+}
+
+MEDPresentation::TypeID
+MEDPresentationManager_i::makeVectorField(const MEDCALC::VectorFieldParameters& params)
+{
+ return _makePresentation<MEDPresentationVectorField>(params);
+}
- TypeID fieldHandlerId = params.fieldHandlerId;
- MEDCALC::MEDPresentationViewMode viewMode = params.viewMode;
+MEDPresentation::TypeID
+MEDPresentationManager_i::makeSlices(const MEDCALC::SlicesParameters& params)
+{
+ return _makePresentation<MEDPresentationSlices>(params);
+}
- MEDCALC::FieldHandler* fieldHandler = dataManager->getFieldHandler(fieldHandlerId);
- MEDCALC::MeshHandler* meshHandler = dataManager->getMesh(fieldHandler->meshid);
- MEDCALC::DatasourceHandler* dataSHandler = dataManager->getDatasourceHandlerFromID(meshHandler->sourceid);
+MEDPresentation::TypeID
+MEDPresentationManager_i::makeDeflectionShape(const MEDCALC::DeflectionShapeParameters& params)
+{
+ return _makePresentation<MEDPresentationDeflectionShape>(params);
+}
- std::cout << "\tfieldHandlerId: " << fieldHandlerId << std::endl;
- std::cout << "\tviewMode: " << viewMode << std::endl;
- std::cout << "\tfileName: " << dataSHandler->uri << std::endl;
- std::cout << "\tfiedName: " << fieldHandler->fieldname << std::endl;
+MEDPresentation::TypeID
+MEDPresentationManager_i::makePointSprite(const MEDCALC::PointSpriteParameters& params)
+{
+ return _makePresentation<MEDPresentationPointSprite>(params);
+}
- // Create a new presentation instance
- TypeID newID = MEDPresentationManager_i::GenerateID();
- MEDPresentationScalarMap * scalarMap = new MEDPresentationScalarMap(fieldHandler, true); // on stack or on heap?? stack for now
- _presentations.insert( std::pair<TypeID, MEDPresentation *>(newID, scalarMap) );
+void
+MEDPresentationManager_i::updateScalarMap(MEDPresentation::TypeID presentationID, const MEDCALC::ScalarMapParameters& params)
+{
+ return _updatePresentation<MEDPresentationScalarMap>(presentationID, params);
+}
- scalarMap->generatePipeline();
+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);
+}
+
+CORBA::Boolean
+MEDPresentationManager_i::removePresentation(MEDPresentation::TypeID presentationID)
+{
+ std::map<MEDPresentation::TypeID, MEDPresentation*>::const_iterator citr = _presentations.find(presentationID);
+ if (citr == _presentations.end()) {
+ std::cerr << "removePresentation(): presentation not found!!" << std::endl;
+ return false;
+ }
+ MEDPresentation* presentation = (*citr).second;
+ if (presentation)
+ delete presentation;
+ _presentations.erase(presentationID);
+ return true;
+}
+
+MEDPresentation::TypeID
+MEDPresentationManager_i::_getActivePresentationId() const
+{
+ // :TODO:
- return newID;
+ return -1;
}