1 // Copyright (C) 2011-2015 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "MEDPresentationManager_i.hxx"
21 #include "MEDFactoryClient.hxx"
22 #include "MEDPresentation.hxx"
24 MEDPresentationManager_i* MEDPresentationManager_i::_instance = NULL;
26 MEDPresentationManager_i*
27 MEDPresentationManager_i::getInstance() {
28 if ( _instance == NULL )
29 _instance = new MEDPresentationManager_i();
33 MEDPresentationManager_i::MEDPresentationManager_i()
37 MEDPresentationManager_i::~MEDPresentationManager_i()
40 std::vector<MEDPresentation*>::iterator itr = this->_presentations.begin();
41 for ( ; itr != this->_presentations.end(); ++itr) {
45 this->_presentations.clear();
49 TypeID MEDPresentationManager_i::GenerateID()
51 static TypeID START_ID = -1;
59 MEDPresentationManager_i::setPresentationProperty(TypeID presentationID, const char * propName, const char * propValue)
61 if (_presentations.find(presentationID) != _presentations.end())
63 MEDPresentation * pres(_presentations[presentationID]);
64 pres->setProperty(propName, propValue);
68 std::cerr << "setPresentationProperty(): presentation not found!!" << std::endl;
73 MEDPresentationManager_i::getPresentationProperty(TypeID presentationID, const char* propName)
75 if (_presentations.find(presentationID) != _presentations.end()) {
76 MEDPresentation* pres = _presentations[presentationID];
77 return (char*) pres->getProperty(propName).c_str();
80 std::cerr << "getPresentationProperty(): presentation not found!!" << std::endl;
86 MEDPresentationManager_i::makeScalarMap(const MEDCALC::ScalarMapParameters& params)
88 MEDCALC::MEDDataManager_ptr dataManager(MEDFactoryClient::getDataManager());
90 TypeID fieldHandlerId = params.fieldHandlerId;
91 MEDCALC::MEDPresentationViewMode viewMode = params.viewMode;
93 MEDCALC::FieldHandler* fieldHandler = dataManager->getFieldHandler(fieldHandlerId);
94 MEDCALC::MeshHandler* meshHandler = dataManager->getMesh(fieldHandler->meshid);
95 MEDCALC::DatasourceHandler* dataSHandler = dataManager->getDatasourceHandlerFromID(meshHandler->sourceid);
97 std::cout << "\tfieldHandlerId: " << fieldHandlerId << std::endl;
98 std::cout << "\tviewMode: " << viewMode << std::endl;
99 std::cout << "\tfileName: " << dataSHandler->uri << std::endl;
100 std::cout << "\tfiedName: " << fieldHandler->fieldname << std::endl;
102 // Create a new presentation instance
103 TypeID newID = MEDPresentationManager_i::GenerateID();
104 MEDPresentationScalarMap * scalarMap = new MEDPresentationScalarMap(fieldHandler, true); // on stack or on heap?? stack for now
105 _presentations.insert( std::pair<TypeID, MEDPresentation *>(newID, scalarMap) );
107 scalarMap->generatePipeline();