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"
32 #include <SALOME_KernelServices.hxx>
37 MEDPresentationManager_i* MEDPresentationManager_i::_instance = NULL;
39 MEDPresentationManager_i*
40 MEDPresentationManager_i::getInstance() {
41 if ( _instance == NULL )
42 _instance = new MEDPresentationManager_i();
46 MEDPresentationManager_i::MEDPresentationManager_i() :
48 _activeViewPythonId(-1)
52 MEDPresentationManager_i::~MEDPresentationManager_i()
55 std::vector<MEDPresentation*>::iterator itr = this->_presentations.begin();
56 for ( ; itr != this->_presentations.end(); ++itr) {
60 this->_presentations.clear();
64 MEDPresentation::TypeID
65 MEDPresentationManager_i::GenerateID()
67 static MEDPresentation::TypeID START_ID = -1;
73 MEDPresentationManager_i::_getPresentation(MEDPresentation::TypeID presentationID) const
75 std::map<MEDPresentation::TypeID, MEDPresentation*>::const_iterator citr = _presentations.find(presentationID);
76 if (citr == _presentations.end())
78 return (*citr).second;
82 MEDPresentationManager_i::setPresentationStringProperty(MEDPresentation::TypeID presentationID, const char* propName, const char* propValue)
84 MEDPresentation* pres = _getPresentation(presentationID);
86 pres->setStringProperty(propName, propValue);
88 throw KERNEL::createSalomeException("setPresentationStringProperty(): presentation not found!!");
92 MEDPresentationManager_i::getPresentationStringProperty(MEDPresentation::TypeID presentationID, const char* propName)
94 MEDPresentation* pres = _getPresentation(presentationID);
96 return (char*) pres->getStringProperty(propName).c_str();
99 throw KERNEL::createSalomeException("getPresentationStringProperty(): presentation not found!!");
103 MEDPresentationManager_i::setPresentationIntProperty(MEDPresentation::TypeID presentationID, const char* propName,
104 const CORBA::Long propValue)
106 MEDPresentation* pres = _getPresentation(presentationID);
108 pres->setIntProperty(propName, propValue);
110 throw KERNEL::createSalomeException("setPresentationIntProperty(): presentation not found!!");
114 MEDPresentationManager_i::getPresentationIntProperty(MEDPresentation::TypeID presentationID, const char* propName)
116 MEDPresentation* pres = _getPresentation(presentationID);
118 return (CORBA::Long) pres->getIntProperty(propName);
121 throw KERNEL::createSalomeException("getPresentationIntProperty(): presentation not found!!");
125 MEDPresentation::TypeID
126 MEDPresentationManager_i::makeScalarMap(const MEDCALC::ScalarMapParameters& params, const MEDCALC::MEDPresentationViewMode viewMode)
128 return _makePresentation<MEDPresentationScalarMap>(params, viewMode);
131 //MEDPresentation::TypeID
132 //MEDPresentationManager_i::makeContour(const MEDCALC::ContourParameters& params)
134 // return _makePresentation<MEDPresentationContour>(params);
137 //MEDPresentation::TypeID
138 //MEDPresentationManager_i::makeVectorField(const MEDCALC::VectorFieldParameters& params)
140 // return _makePresentation<MEDPresentationVectorField>(params);
143 //MEDPresentation::TypeID
144 //MEDPresentationManager_i::makeSlices(const MEDCALC::SlicesParameters& params)
146 // return _makePresentation<MEDPresentationSlices>(params);
149 //MEDPresentation::TypeID
150 //MEDPresentationManager_i::makeDeflectionShape(const MEDCALC::DeflectionShapeParameters& params)
152 // return _makePresentation<MEDPresentationDeflectionShape>(params);
155 //MEDPresentation::TypeID
156 //MEDPresentationManager_i::makePointSprite(const MEDCALC::PointSpriteParameters& params)
158 // return _makePresentation<MEDPresentationPointSprite>(params);
161 MEDCALC::ScalarMapParameters*
162 MEDPresentationManager_i::getScalarMapParameters(MEDPresentation::TypeID presentationID)
164 MEDCALC::ScalarMapParameters* p = new MEDCALC::ScalarMapParameters();
165 _getParameters<MEDPresentationScalarMap>(presentationID, *p);
166 MEDCALC::ScalarMapParameters_var tmp(p);
171 MEDPresentationManager_i::updateScalarMap(MEDPresentation::TypeID presentationID, const MEDCALC::ScalarMapParameters& params)
173 return _updatePresentation<MEDPresentationScalarMap>(presentationID, params);
177 //MEDPresentationManager_i::updateContour(MEDPresentation::TypeID presentationID, const MEDCALC::ContourParameters& params)
179 // return _updatePresentation<MEDPresentationContour>(presentationID, params);
183 //MEDPresentationManager_i::updateVectorField(MEDPresentation::TypeID presentationID, const MEDCALC::VectorFieldParameters& params)
185 // return _updatePresentation<MEDPresentationVectorField>(presentationID, params);
189 //MEDPresentationManager_i::updateSlices(MEDPresentation::TypeID presentationID, const MEDCALC::SlicesParameters& params)
191 // return _updatePresentation<MEDPresentationSlices>(presentationID, params);
195 //MEDPresentationManager_i::updateDeflectionShape(MEDPresentation::TypeID presentationID, const MEDCALC::DeflectionShapeParameters& params)
197 // return _updatePresentation<MEDPresentationDeflectionShape>(presentationID, params);
201 //MEDPresentationManager_i::updatePointSprite(MEDPresentation::TypeID presentationID, const MEDCALC::PointSpriteParameters& params)
203 // return _updatePresentation<MEDPresentationPointSprite>(presentationID, params);
207 MEDPresentationManager_i::removePresentation(MEDPresentation::TypeID presentationID)
209 std::map<MEDPresentation::TypeID, MEDPresentation*>::const_iterator citr = _presentations.find(presentationID);
210 if (citr == _presentations.end()) {
211 std::cerr << "removePresentation(): presentation not found!!" << std::endl;
214 MEDPresentation* presentation = (*citr).second;
217 _presentations.erase(presentationID);
219 STDLOG("Presentation " << presentationID << " has been removed.");
224 MEDPresentationManager_i::activateView(MEDPresentation::TypeID presentationID)
226 std::map<MEDPresentation::TypeID, MEDPresentation*>::const_iterator citr = _presentations.find(presentationID);
227 if (citr == _presentations.end()) {
228 std::cerr << "activateView(): presentation not found!!" << std::endl;
231 MEDPresentation* presentation = (*citr).second;
233 presentation->activateView();
234 _activeViewPythonId = presentation->getPyViewID();
239 MEDPresentationManager_i::getActiveViewPythonId()
241 //TODO: should be more elaborate to re-identify the active ParaView view when another
242 //mechanism than MED module has activated another view.
243 // Idea: 1/ call Python to current active view
244 // 2/ compare with all id(__viewX) from currently existing presentations
245 return _activeViewPythonId;
249 //MEDCALC::MEDPresentationViewMode
250 //MEDPresentationManager_i::getPresentationViewMode(MEDPresentation::TypeID presentationID)
252 // MEDPresentation* pres = _getPresentation(presentationID);
254 // return pres->getViewMode();
256 // std::cerr << "setPresentationProperty(): presentation not found!!" << std::endl;
257 // return MEDCALC::VIEW_MODE_DEFAULT;
262 MEDPresentationManager_i::getParavisDump(MEDPresentation::TypeID presentationID)
264 MEDPresentation* pres = _getPresentation(presentationID);
266 return (char*) pres->paravisDump().c_str();
269 throw KERNEL::createSalomeException("getParavisDump(): presentation not found!!");