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 "Basics_Utils.hxx"
25 #include "MEDPresentationScalarMap.hxx"
26 #include "MEDPresentationContour.hxx"
27 #include "MEDPresentationVectorField.hxx"
28 #include "MEDPresentationSlices.hxx"
29 #include "MEDPresentationDeflectionShape.hxx"
30 #include "MEDPresentationPointSprite.hxx"
35 MEDPresentationManager_i* MEDPresentationManager_i::_instance = NULL;
37 MEDPresentationManager_i*
38 MEDPresentationManager_i::getInstance() {
39 if ( _instance == NULL )
40 _instance = new MEDPresentationManager_i();
44 MEDPresentationManager_i::MEDPresentationManager_i()
48 MEDPresentationManager_i::~MEDPresentationManager_i()
51 std::vector<MEDPresentation*>::iterator itr = this->_presentations.begin();
52 for ( ; itr != this->_presentations.end(); ++itr) {
56 this->_presentations.clear();
60 MEDPresentation::TypeID
61 MEDPresentationManager_i::GenerateID()
63 static MEDPresentation::TypeID START_ID = -1;
69 MEDPresentationManager_i::_getPresentation(MEDPresentation::TypeID presentationID) const
71 std::map<MEDPresentation::TypeID, MEDPresentation*>::const_iterator citr = _presentations.find(presentationID);
72 if (citr == _presentations.end())
74 return (*citr).second;
78 MEDPresentationManager_i::setPresentationProperty(MEDPresentation::TypeID presentationID, const char* propName, const char* propValue)
80 MEDPresentation* pres = _getPresentation(presentationID);
82 pres->setProperty(propName, propValue);
84 std::cerr << "setPresentationProperty(): presentation not found!!" << std::endl;
88 MEDPresentationManager_i::getPresentationProperty(MEDPresentation::TypeID presentationID, const char* propName)
90 MEDPresentation* pres = _getPresentation(presentationID);
92 return (char*) pres->getProperty(propName).c_str();
95 std::cerr << "getPresentationProperty(): presentation not found!!" << std::endl;
100 MEDPresentation::TypeID
101 MEDPresentationManager_i::makeScalarMap(const MEDCALC::ScalarMapParameters& params)
103 return _makePresentation<MEDPresentationScalarMap>(params);
106 MEDPresentation::TypeID
107 MEDPresentationManager_i::makeContour(const MEDCALC::ContourParameters& params)
109 return _makePresentation<MEDPresentationContour>(params);
112 MEDPresentation::TypeID
113 MEDPresentationManager_i::makeVectorField(const MEDCALC::VectorFieldParameters& params)
115 return _makePresentation<MEDPresentationVectorField>(params);
118 MEDPresentation::TypeID
119 MEDPresentationManager_i::makeSlices(const MEDCALC::SlicesParameters& params)
121 return _makePresentation<MEDPresentationSlices>(params);
124 MEDPresentation::TypeID
125 MEDPresentationManager_i::makeDeflectionShape(const MEDCALC::DeflectionShapeParameters& params)
127 return _makePresentation<MEDPresentationDeflectionShape>(params);
130 MEDPresentation::TypeID
131 MEDPresentationManager_i::makePointSprite(const MEDCALC::PointSpriteParameters& params)
133 return _makePresentation<MEDPresentationPointSprite>(params);
137 MEDPresentationManager_i::updateScalarMap(MEDPresentation::TypeID presentationID, const MEDCALC::ScalarMapParameters& params)
139 return _updatePresentation<MEDPresentationScalarMap>(presentationID, params);
143 MEDPresentationManager_i::updateContour(MEDPresentation::TypeID presentationID, const MEDCALC::ContourParameters& params)
145 return _updatePresentation<MEDPresentationContour>(presentationID, params);
149 MEDPresentationManager_i::updateVectorField(MEDPresentation::TypeID presentationID, const MEDCALC::VectorFieldParameters& params)
151 return _updatePresentation<MEDPresentationVectorField>(presentationID, params);
155 MEDPresentationManager_i::updateSlices(MEDPresentation::TypeID presentationID, const MEDCALC::SlicesParameters& params)
157 return _updatePresentation<MEDPresentationSlices>(presentationID, params);
161 MEDPresentationManager_i::updateDeflectionShape(MEDPresentation::TypeID presentationID, const MEDCALC::DeflectionShapeParameters& params)
163 return _updatePresentation<MEDPresentationDeflectionShape>(presentationID, params);
167 MEDPresentationManager_i::updatePointSprite(MEDPresentation::TypeID presentationID, const MEDCALC::PointSpriteParameters& params)
169 return _updatePresentation<MEDPresentationPointSprite>(presentationID, params);
173 MEDPresentationManager_i::removePresentation(MEDPresentation::TypeID presentationID)
175 std::map<MEDPresentation::TypeID, MEDPresentation*>::const_iterator citr = _presentations.find(presentationID);
176 if (citr == _presentations.end()) {
177 std::cerr << "removePresentation(): presentation not found!!" << std::endl;
180 MEDPresentation* presentation = (*citr).second;
183 _presentations.erase(presentationID);
185 std::stringstream sstm;
186 sstm << "Presentation " << presentationID << " has been removed.\n";
193 MEDPresentationManager_i::activateView(MEDPresentation::TypeID presentationID)
195 std::map<MEDPresentation::TypeID, MEDPresentation*>::const_iterator citr = _presentations.find(presentationID);
196 if (citr == _presentations.end()) {
197 std::cerr << "getPresentationPyViewId(): presentation not found!!" << std::endl;
200 MEDPresentation* presentation = (*citr).second;
202 presentation->activateView();
206 MEDCALC::MEDPresentationViewMode
207 MEDPresentationManager_i::getPresentationViewMode(MEDPresentation::TypeID presentationID)
209 MEDPresentation* pres = _getPresentation(presentationID);
211 return pres->getViewMode();
213 std::cerr << "setPresentationProperty(): presentation not found!!" << std::endl;
214 return MEDCALC::VIEW_MODE_DEFAULT;