Salome HOME
[MEDCalc] Prepare to presentation edition
[modules/med.git] / src / MEDCalc / cmp / MEDPresentationManager_i.cxx
1 // Copyright (C) 2011-2016  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "MEDPresentationManager_i.hxx"
21 #include "MEDFactoryClient.hxx"
22
23 // presentations
24 #include "MEDPresentationScalarMap.hxx"
25 #include "MEDPresentationContour.hxx"
26 #include "MEDPresentationVectorField.hxx"
27 #include "MEDPresentationSlices.hxx"
28 #include "MEDPresentationDeflectionShape.hxx"
29 #include "MEDPresentationPointSprite.hxx"
30
31 #include <iostream>
32
33 MEDPresentationManager_i* MEDPresentationManager_i::_instance = NULL;
34
35 MEDPresentationManager_i*
36 MEDPresentationManager_i::getInstance() {
37   if ( _instance == NULL )
38     _instance = new MEDPresentationManager_i();
39   return _instance;
40 }
41
42 MEDPresentationManager_i::MEDPresentationManager_i()
43 {
44 }
45
46 MEDPresentationManager_i::~MEDPresentationManager_i()
47 {
48   /*
49   std::vector<MEDPresentation*>::iterator itr = this->_presentations.begin();
50   for ( ; itr != this->_presentations.end(); ++itr) {
51     delete *itr;
52     *itr = NULL;
53   }
54   this->_presentations.clear();
55   */
56 }
57
58 MEDPresentation::TypeID
59 MEDPresentationManager_i::GenerateID()
60 {
61   static MEDPresentation::TypeID START_ID = -1;
62   START_ID++;
63   return START_ID;
64 }
65
66 MEDPresentation*
67 MEDPresentationManager_i::_getPresentation(MEDPresentation::TypeID presentationID) const
68 {
69   std::map<MEDPresentation::TypeID, MEDPresentation*>::const_iterator citr = _presentations.find(presentationID);
70   if (citr == _presentations.end())
71     return NULL;
72   return (*citr).second;
73 }
74
75 void
76 MEDPresentationManager_i::setPresentationProperty(MEDPresentation::TypeID presentationID, const char* propName, const char* propValue)
77 {
78   MEDPresentation* pres = _getPresentation(presentationID);
79   if (pres)
80     pres->setProperty(propName, propValue);
81   else
82     std::cerr << "setPresentationProperty(): presentation not found!!" << std::endl;
83 }
84
85 char*
86 MEDPresentationManager_i::getPresentationProperty(MEDPresentation::TypeID presentationID, const char* propName)
87 {
88   MEDPresentation* pres = _getPresentation(presentationID);
89   if (pres) {
90     return (char*) pres->getProperty(propName).c_str();
91   }
92   else {
93     std::cerr << "getPresentationProperty(): presentation not found!!" << std::endl;
94     return (char*) "";
95   }
96 }
97
98 MEDPresentation::TypeID
99 MEDPresentationManager_i::makeScalarMap(const MEDCALC::ScalarMapParameters& params)
100 {
101   return _makePresentation<MEDPresentationScalarMap>(params);
102 }
103
104 MEDPresentation::TypeID
105 MEDPresentationManager_i::makeContour(const MEDCALC::ContourParameters& params)
106 {
107   return _makePresentation<MEDPresentationContour>(params);
108 }
109
110 MEDPresentation::TypeID
111 MEDPresentationManager_i::makeVectorField(const MEDCALC::VectorFieldParameters& params)
112 {
113   return _makePresentation<MEDPresentationVectorField>(params);
114 }
115
116 MEDPresentation::TypeID
117 MEDPresentationManager_i::makeSlices(const MEDCALC::SlicesParameters& params)
118 {
119   return _makePresentation<MEDPresentationSlices>(params);
120 }
121
122 MEDPresentation::TypeID
123 MEDPresentationManager_i::makeDeflectionShape(const MEDCALC::DeflectionShapeParameters& params)
124 {
125   return _makePresentation<MEDPresentationDeflectionShape>(params);
126 }
127
128 MEDPresentation::TypeID
129 MEDPresentationManager_i::makePointSprite(const MEDCALC::PointSpriteParameters& params)
130 {
131   return _makePresentation<MEDPresentationPointSprite>(params);
132 }
133
134 void
135 MEDPresentationManager_i::updateScalarMap(MEDPresentation::TypeID presentationID, const MEDCALC::ScalarMapParameters& params)
136 {
137   return _updatePresentation<MEDPresentationScalarMap>(presentationID, params);
138 }
139
140 void
141 MEDPresentationManager_i::updateContour(MEDPresentation::TypeID presentationID, const MEDCALC::ContourParameters& params)
142 {
143   return _updatePresentation<MEDPresentationContour>(presentationID, params);
144 }
145
146 void
147 MEDPresentationManager_i::updateVectorField(MEDPresentation::TypeID presentationID, const MEDCALC::VectorFieldParameters& params)
148 {
149   return _updatePresentation<MEDPresentationVectorField>(presentationID, params);
150 }
151
152 void
153 MEDPresentationManager_i::updateSlices(MEDPresentation::TypeID presentationID, const MEDCALC::SlicesParameters& params)
154 {
155   return _updatePresentation<MEDPresentationSlices>(presentationID, params);
156 }
157
158 void
159 MEDPresentationManager_i::updateDeflectionShape(MEDPresentation::TypeID presentationID, const MEDCALC::DeflectionShapeParameters& params)
160 {
161   return _updatePresentation<MEDPresentationDeflectionShape>(presentationID, params);
162 }
163
164 void
165 MEDPresentationManager_i::updatePointSprite(MEDPresentation::TypeID presentationID, const MEDCALC::PointSpriteParameters& params)
166 {
167   return _updatePresentation<MEDPresentationPointSprite>(presentationID, params);
168 }