Salome HOME
[MEDCalc] Remove sibling presentations in REPLACE view mode
[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(PresentationParameters params)
26 {
27   // Create a new presentation instance
28   PresentationType* presentation = NULL;
29   try {
30     presentation = new PresentationType(params);  // on stack or on heap?? stack for now
31   }
32   catch (const std::exception& e) {
33     std::cerr << e.what() << std::endl;
34     return -1;
35   }
36
37   MEDPresentation::TypeID newID = MEDPresentationManager_i::GenerateID();
38   _presentations.insert( std::pair<MEDPresentation::TypeID, MEDPresentation *>(newID, presentation) );
39   presentation->generatePipeline();
40   return newID;
41 }
42
43 template<typename PresentationType, typename PresentationParameters>
44 void
45 MEDPresentationManager_i::_updatePresentation(MEDPresentation::TypeID presentationID, PresentationParameters params)
46 {
47   MEDPresentation* presentation = _getPresentation(presentationID);
48   if (!presentation) {
49     std::cerr << "_updatePresentation(): presentation not found!!" << std::endl;
50     return;
51   }
52
53   presentation->updatePipeline<PresentationType>(params);
54 }
55
56 #endif // _MED_PRESENTATION_MANAGER_I_TXX_