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"
24 #include "MEDPresentationScalarMap.hxx"
25 #include "MEDPresentationContour.hxx"
26 #include "MEDPresentationVectorField.hxx"
27 #include "MEDPresentationSlices.hxx"
28 #include "MEDPresentationDeflectionShape.hxx"
29 #include "MEDPresentationPointSprite.hxx"
33 MEDPresentationManager_i* MEDPresentationManager_i::_instance = NULL;
35 MEDPresentationManager_i*
36 MEDPresentationManager_i::getInstance() {
37 if ( _instance == NULL )
38 _instance = new MEDPresentationManager_i();
42 MEDPresentationManager_i::MEDPresentationManager_i()
46 MEDPresentationManager_i::~MEDPresentationManager_i()
49 std::vector<MEDPresentation*>::iterator itr = this->_presentations.begin();
50 for ( ; itr != this->_presentations.end(); ++itr) {
54 this->_presentations.clear();
58 MEDPresentation::TypeID
59 MEDPresentationManager_i::GenerateID()
61 static MEDPresentation::TypeID START_ID = -1;
67 MEDPresentationManager_i::_getPresentation(MEDPresentation::TypeID presentationID) const
69 std::map<MEDPresentation::TypeID, MEDPresentation*>::const_iterator citr = _presentations.find(presentationID);
70 if (citr == _presentations.end())
72 return (*citr).second;
76 MEDPresentationManager_i::setPresentationProperty(MEDPresentation::TypeID presentationID, const char* propName, const char* propValue)
78 MEDPresentation* pres = _getPresentation(presentationID);
80 pres->setProperty(propName, propValue);
82 std::cerr << "setPresentationProperty(): presentation not found!!" << std::endl;
86 MEDPresentationManager_i::getPresentationProperty(MEDPresentation::TypeID presentationID, const char* propName)
88 MEDPresentation* pres = _getPresentation(presentationID);
90 return (char*) pres->getProperty(propName).c_str();
93 std::cerr << "getPresentationProperty(): presentation not found!!" << std::endl;
98 MEDPresentation::TypeID
99 MEDPresentationManager_i::makeScalarMap(const MEDCALC::ScalarMapParameters& params)
101 return _makePresentation<MEDPresentationScalarMap>(params);
104 MEDPresentation::TypeID
105 MEDPresentationManager_i::makeContour(const MEDCALC::ContourParameters& params)
107 return _makePresentation<MEDPresentationContour>(params);
110 MEDPresentation::TypeID
111 MEDPresentationManager_i::makeVectorField(const MEDCALC::VectorFieldParameters& params)
113 return _makePresentation<MEDPresentationVectorField>(params);
116 MEDPresentation::TypeID
117 MEDPresentationManager_i::makeSlices(const MEDCALC::SlicesParameters& params)
119 return _makePresentation<MEDPresentationSlices>(params);
122 MEDPresentation::TypeID
123 MEDPresentationManager_i::makeDeflectionShape(const MEDCALC::DeflectionShapeParameters& params)
125 return _makePresentation<MEDPresentationDeflectionShape>(params);
128 MEDPresentation::TypeID
129 MEDPresentationManager_i::makePointSprite(const MEDCALC::PointSpriteParameters& params)
131 return _makePresentation<MEDPresentationPointSprite>(params);
135 MEDPresentationManager_i::updateScalarMap(MEDPresentation::TypeID presentationID, const MEDCALC::ScalarMapParameters& params)
137 return _updatePresentation<MEDPresentationScalarMap>(presentationID, params);
141 MEDPresentationManager_i::updateContour(MEDPresentation::TypeID presentationID, const MEDCALC::ContourParameters& params)
143 return _updatePresentation<MEDPresentationContour>(presentationID, params);
147 MEDPresentationManager_i::updateVectorField(MEDPresentation::TypeID presentationID, const MEDCALC::VectorFieldParameters& params)
149 return _updatePresentation<MEDPresentationVectorField>(presentationID, params);
153 MEDPresentationManager_i::updateSlices(MEDPresentation::TypeID presentationID, const MEDCALC::SlicesParameters& params)
155 return _updatePresentation<MEDPresentationSlices>(presentationID, params);
159 MEDPresentationManager_i::updateDeflectionShape(MEDPresentation::TypeID presentationID, const MEDCALC::DeflectionShapeParameters& params)
161 return _updatePresentation<MEDPresentationDeflectionShape>(presentationID, params);
165 MEDPresentationManager_i::updatePointSprite(MEDPresentation::TypeID presentationID, const MEDCALC::PointSpriteParameters& params)
167 return _updatePresentation<MEDPresentationPointSprite>(presentationID, params);
171 MEDPresentationManager_i::removePresentation(MEDPresentation::TypeID presentationID)
173 std::map<MEDPresentation::TypeID, MEDPresentation*>::const_iterator citr = _presentations.find(presentationID);
174 if (citr == _presentations.end()) {
175 std::cerr << "removePresentation(): presentation not found!!" << std::endl;
178 MEDPresentation* presentation = (*citr).second;
181 _presentations.erase(presentationID);
186 MEDPresentationManager_i::activateView(MEDPresentation::TypeID presentationID)
188 std::map<MEDPresentation::TypeID, MEDPresentation*>::const_iterator citr = _presentations.find(presentationID);
189 if (citr == _presentations.end()) {
190 std::cerr << "getPresentationPyViewId(): presentation not found!!" << std::endl;
193 MEDPresentation* presentation = (*citr).second;
195 presentation->activateView();
199 MEDPresentation::TypeID
200 MEDPresentationManager_i::_getActivePresentationId() const