Salome HOME
[MEDCalc] Fully functional scalar map (other pres deactivated)
[modules/med.git] / src / MEDCalc / cmp / MEDPresentationManager_i.txx
1 // Copyright (C) 2007-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 #ifndef _MED_PRESENTATION_MANAGER_I_TXX_
21 #define _MED_PRESENTATION_MANAGER_I_TXX_
22
23 template<typename PresentationType, typename PresentationParameters>
24 MEDPresentation::TypeID
25 MEDPresentationManager_i::_makePresentation(const PresentationParameters params, const MEDCALC::MEDPresentationViewMode viewMode)
26 {
27   // Replace = Remove then add
28   if (viewMode == MEDCALC::VIEW_MODE_REPLACE) {
29     MEDPresentation::TypeID currentPresentationId = _getActivePresentationId();
30     if (currentPresentationId > -1)
31       removePresentation(currentPresentationId);
32   }
33
34   // Create a new presentation instance
35   PresentationType* presentation = NULL;
36   try {
37     presentation = new PresentationType(params, viewMode);  // on stack or on heap?? heap for now
38   }
39   catch (const std::exception& e) {
40     std::cerr << e.what() << std::endl;
41     return -1;
42   }
43
44   MEDPresentation::TypeID newID = MEDPresentationManager_i::GenerateID();
45   _presentations.insert( std::pair<MEDPresentation::TypeID, MEDPresentation *>(newID, presentation) );
46   presentation->generatePipeline();
47   return newID;
48 }
49
50 template<typename PresentationType, typename PresentationParameters>
51 void
52 MEDPresentationManager_i::_updatePresentation(MEDPresentation::TypeID presentationID, const PresentationParameters params)
53 {
54   MEDPresentation* presentation = _getPresentation(presentationID);
55   if (!presentation) {
56     std::cerr << "_updatePresentation(): presentation not found!!" << std::endl;
57     return;
58   }
59
60   presentation->updatePipeline<PresentationType>(params);
61 }
62
63 template<typename PresentationType, typename PresentationParameters>
64 void
65 MEDPresentationManager_i::_getParameters(MEDPresentation::TypeID presentationID, PresentationParameters & params) const
66 {
67   MEDPresentation* presentation = _getPresentation(presentationID);
68   if (!presentation) {
69     std::cerr << "_getParameters(): presentation not found!!" << std::endl;
70     return;
71   }
72
73   presentation->getParameters<PresentationType>(params);
74 }
75
76
77 #endif // _MED_PRESENTATION_MANAGER_I_TXX_