1 // Copyright (C) 2011-2016 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"
23 #include "MEDPresentationScalarMap.hxx"
24 #include "MEDPresentationContour.hxx"
25 #include "MEDPresentationVectorField.hxx"
26 #include "MEDPresentationSlices.hxx"
27 #include "MEDPresentationDeflectionShape.hxx"
28 #include "MEDPresentationPointSprite.hxx"
30 MEDPresentationManager_i* MEDPresentationManager_i::_instance = NULL;
32 MEDPresentationManager_i*
33 MEDPresentationManager_i::getInstance() {
34 if ( _instance == NULL )
35 _instance = new MEDPresentationManager_i();
39 MEDPresentationManager_i::MEDPresentationManager_i()
43 MEDPresentationManager_i::~MEDPresentationManager_i()
46 std::vector<MEDPresentation*>::iterator itr = this->_presentations.begin();
47 for ( ; itr != this->_presentations.end(); ++itr) {
51 this->_presentations.clear();
55 TypeID MEDPresentationManager_i::GenerateID()
57 static TypeID START_ID = -1;
65 MEDPresentationManager_i::setPresentationProperty(TypeID presentationID, const char * propName, const char * propValue)
67 if (_presentations.find(presentationID) != _presentations.end())
69 MEDPresentation * pres(_presentations[presentationID]);
70 pres->setProperty(propName, propValue);
74 std::cerr << "setPresentationProperty(): presentation not found!!" << std::endl;
79 MEDPresentationManager_i::getPresentationProperty(TypeID presentationID, const char* propName)
81 if (_presentations.find(presentationID) != _presentations.end()) {
82 MEDPresentation* pres = _presentations[presentationID];
83 return (char*) pres->getProperty(propName).c_str();
86 std::cerr << "getPresentationProperty(): presentation not found!!" << std::endl;
92 MEDPresentationManager_i::makeScalarMap(const MEDCALC::ScalarMapParameters& params)
94 MEDCALC::MEDDataManager_ptr dataManager(MEDFactoryClient::getDataManager());
96 TypeID fieldHandlerId = params.fieldHandlerId;
97 MEDCALC::MEDPresentationViewMode viewMode = params.viewMode;
99 MEDCALC::FieldHandler* fieldHandler = dataManager->getFieldHandler(fieldHandlerId);
100 MEDCALC::MeshHandler* meshHandler = dataManager->getMesh(fieldHandler->meshid);
101 MEDCALC::DatasourceHandler* dataSHandler = dataManager->getDatasourceHandlerFromID(meshHandler->sourceid);
103 std::cout << "\tfieldHandlerId: " << fieldHandlerId << std::endl;
104 std::cout << "\tviewMode: " << viewMode << std::endl;
105 std::cout << "\tfileName: " << dataSHandler->uri << std::endl;
106 std::cout << "\tfiedName: " << fieldHandler->fieldname << std::endl;
108 // Create a new presentation instance
109 TypeID newID = MEDPresentationManager_i::GenerateID();
110 MEDPresentationScalarMap * presentation = new MEDPresentationScalarMap(fieldHandler, true); // on stack or on heap?? stack for now
111 _presentations.insert( std::pair<TypeID, MEDPresentation *>(newID, presentation) );
113 presentation->generatePipeline();
119 MEDPresentationManager_i::makeContour(const MEDCALC::ContourParameters& params)
121 MEDCALC::MEDDataManager_ptr dataManager(MEDFactoryClient::getDataManager());
123 TypeID fieldHandlerId = params.fieldHandlerId;
124 MEDCALC::MEDPresentationViewMode viewMode = params.viewMode;
126 MEDCALC::FieldHandler* fieldHandler = dataManager->getFieldHandler(fieldHandlerId);
127 MEDCALC::MeshHandler* meshHandler = dataManager->getMesh(fieldHandler->meshid);
128 MEDCALC::DatasourceHandler* dataSHandler = dataManager->getDatasourceHandlerFromID(meshHandler->sourceid);
130 std::cout << "\tfieldHandlerId: " << fieldHandlerId << std::endl;
131 std::cout << "\tviewMode: " << viewMode << std::endl;
132 std::cout << "\tfileName: " << dataSHandler->uri << std::endl;
133 std::cout << "\tfiedName: " << fieldHandler->fieldname << std::endl;
135 // Create a new presentation instance
136 TypeID newID = MEDPresentationManager_i::GenerateID();
137 MEDPresentationContour * presentation = new MEDPresentationContour(fieldHandler, true); // on stack or on heap?? stack for now
138 _presentations.insert( std::pair<TypeID, MEDPresentation *>(newID, presentation) );
140 presentation->generatePipeline();
146 MEDPresentationManager_i::makeVectorField(const MEDCALC::VectorFieldParameters& params)
148 MEDCALC::MEDDataManager_ptr dataManager(MEDFactoryClient::getDataManager());
150 TypeID fieldHandlerId = params.fieldHandlerId;
151 MEDCALC::MEDPresentationViewMode viewMode = params.viewMode;
153 MEDCALC::FieldHandler* fieldHandler = dataManager->getFieldHandler(fieldHandlerId);
154 MEDCALC::MeshHandler* meshHandler = dataManager->getMesh(fieldHandler->meshid);
155 MEDCALC::DatasourceHandler* dataSHandler = dataManager->getDatasourceHandlerFromID(meshHandler->sourceid);
157 std::cout << "\tfieldHandlerId: " << fieldHandlerId << std::endl;
158 std::cout << "\tviewMode: " << viewMode << std::endl;
159 std::cout << "\tfileName: " << dataSHandler->uri << std::endl;
160 std::cout << "\tfiedName: " << fieldHandler->fieldname << std::endl;
162 // Create a new presentation instance
163 TypeID newID = MEDPresentationManager_i::GenerateID();
164 MEDPresentationVectorField * presentation = new MEDPresentationVectorField(fieldHandler, true); // on stack or on heap?? stack for now
165 _presentations.insert( std::pair<TypeID, MEDPresentation *>(newID, presentation) );
167 presentation->generatePipeline();
173 MEDPresentationManager_i::makeSlices(const MEDCALC::SlicesParameters& params)
175 MEDCALC::MEDDataManager_ptr dataManager(MEDFactoryClient::getDataManager());
177 TypeID fieldHandlerId = params.fieldHandlerId;
178 MEDCALC::MEDPresentationViewMode viewMode = params.viewMode;
180 MEDCALC::FieldHandler* fieldHandler = dataManager->getFieldHandler(fieldHandlerId);
181 MEDCALC::MeshHandler* meshHandler = dataManager->getMesh(fieldHandler->meshid);
182 MEDCALC::DatasourceHandler* dataSHandler = dataManager->getDatasourceHandlerFromID(meshHandler->sourceid);
184 std::cout << "\tfieldHandlerId: " << fieldHandlerId << std::endl;
185 std::cout << "\tviewMode: " << viewMode << std::endl;
186 std::cout << "\tfileName: " << dataSHandler->uri << std::endl;
187 std::cout << "\tfiedName: " << fieldHandler->fieldname << std::endl;
189 // Create a new presentation instance
190 TypeID newID = MEDPresentationManager_i::GenerateID();
191 MEDPresentationSlices * presentation = new MEDPresentationSlices(fieldHandler, true); // on stack or on heap?? stack for now
192 _presentations.insert( std::pair<TypeID, MEDPresentation *>(newID, presentation) );
194 presentation->generatePipeline();
200 MEDPresentationManager_i::makeDeflectionShape(const MEDCALC::DeflectionShapeParameters& params)
202 MEDCALC::MEDDataManager_ptr dataManager(MEDFactoryClient::getDataManager());
204 TypeID fieldHandlerId = params.fieldHandlerId;
205 MEDCALC::MEDPresentationViewMode viewMode = params.viewMode;
207 MEDCALC::FieldHandler* fieldHandler = dataManager->getFieldHandler(fieldHandlerId);
208 MEDCALC::MeshHandler* meshHandler = dataManager->getMesh(fieldHandler->meshid);
209 MEDCALC::DatasourceHandler* dataSHandler = dataManager->getDatasourceHandlerFromID(meshHandler->sourceid);
211 std::cout << "\tfieldHandlerId: " << fieldHandlerId << std::endl;
212 std::cout << "\tviewMode: " << viewMode << std::endl;
213 std::cout << "\tfileName: " << dataSHandler->uri << std::endl;
214 std::cout << "\tfiedName: " << fieldHandler->fieldname << std::endl;
216 // Create a new presentation instance
217 TypeID newID = MEDPresentationManager_i::GenerateID();
218 MEDPresentationDeflectionShape * presentation = new MEDPresentationDeflectionShape(fieldHandler, true); // on stack or on heap?? stack for now
219 _presentations.insert( std::pair<TypeID, MEDPresentation *>(newID, presentation) );
221 presentation->generatePipeline();
227 MEDPresentationManager_i::makePointSprite(const MEDCALC::PointSpriteParameters& params)
229 MEDCALC::MEDDataManager_ptr dataManager(MEDFactoryClient::getDataManager());
231 TypeID fieldHandlerId = params.fieldHandlerId;
232 MEDCALC::MEDPresentationViewMode viewMode = params.viewMode;
234 MEDCALC::FieldHandler* fieldHandler = dataManager->getFieldHandler(fieldHandlerId);
235 MEDCALC::MeshHandler* meshHandler = dataManager->getMesh(fieldHandler->meshid);
236 MEDCALC::DatasourceHandler* dataSHandler = dataManager->getDatasourceHandlerFromID(meshHandler->sourceid);
238 std::cout << "\tfieldHandlerId: " << fieldHandlerId << std::endl;
239 std::cout << "\tviewMode: " << viewMode << std::endl;
240 std::cout << "\tfileName: " << dataSHandler->uri << std::endl;
241 std::cout << "\tfiedName: " << fieldHandler->fieldname << std::endl;
243 // Create a new presentation instance
244 TypeID newID = MEDPresentationManager_i::GenerateID();
245 MEDPresentationPointSprite * presentation = new MEDPresentationPointSprite(fieldHandler, true); // on stack or on heap?? stack for now
246 _presentations.insert( std::pair<TypeID, MEDPresentation *>(newID, presentation) );
248 presentation->generatePipeline();