X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCalc%2Fcmp%2FMEDPresentationManager_i.cxx;h=a2e3cfb0925649157def5f5f9dc42e781cf19f27;hb=80657e4615027595184835a4c2f3d5548dc1b18d;hp=a268f47f84e3a569be08c8707ff991f52b7d984e;hpb=7d5fb5a50f6d091af34805871047f2fe72bdf293;p=modules%2Fmed.git diff --git a/src/MEDCalc/cmp/MEDPresentationManager_i.cxx b/src/MEDCalc/cmp/MEDPresentationManager_i.cxx index a268f47f8..a2e3cfb09 100644 --- a/src/MEDCalc/cmp/MEDPresentationManager_i.cxx +++ b/src/MEDCalc/cmp/MEDPresentationManager_i.cxx @@ -1,4 +1,4 @@ -// 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 @@ -19,7 +19,16 @@ #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 MEDPresentationManager_i* MEDPresentationManager_i::_instance = NULL; @@ -46,34 +55,38 @@ MEDPresentationManager_i::~MEDPresentationManager_i() */ } -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 +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(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 { @@ -82,29 +95,97 @@ MEDPresentationManager_i::getPresentationProperty(TypeID presentationID, const c } } -TypeID +MEDPresentation::TypeID MEDPresentationManager_i::makeScalarMap(const MEDCALC::ScalarMapParameters& params) { - MEDCALC::MEDDataManager_ptr dataManager(MEDFactoryClient::getDataManager()); + return _makePresentation(params); +} + +MEDPresentation::TypeID +MEDPresentationManager_i::makeContour(const MEDCALC::ContourParameters& params) +{ + return _makePresentation(params); +} + +MEDPresentation::TypeID +MEDPresentationManager_i::makeVectorField(const MEDCALC::VectorFieldParameters& params) +{ + return _makePresentation(params); +} - TypeID fieldHandlerId = params.fieldHandlerId; - MEDCALC::MEDPresentationViewMode viewMode = params.viewMode; +MEDPresentation::TypeID +MEDPresentationManager_i::makeSlices(const MEDCALC::SlicesParameters& params) +{ + return _makePresentation(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(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(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(newID, scalarMap) ); +void +MEDPresentationManager_i::updateScalarMap(MEDPresentation::TypeID presentationID, const MEDCALC::ScalarMapParameters& params) +{ + return _updatePresentation(presentationID, params); +} - scalarMap->generatePipeline(); +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); +} + +CORBA::Boolean +MEDPresentationManager_i::removePresentation(MEDPresentation::TypeID presentationID) +{ + std::map::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; }