Salome HOME
Updated copyright comment
[modules/med.git] / src / MEDCalc / cmp / MEDPresentationScalarMap.cxx
1 // Copyright (C) 2016-2024  CEA, EDF
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 "MEDPyLockWrapper.hxx"
21
22 #include "MEDPresentationScalarMap.hxx"
23 #include "MEDPresentationException.hxx"
24
25 #include <SALOME_KernelServices.hxx>
26 #undef LOG  // should be fixed in KERNEL - double definition
27 #include <Basics_Utils.hxx>
28
29 #include <sstream>
30
31 const std::string MEDPresentationScalarMap::TYPE_NAME = "MEDPresentationScalarMap";
32
33 MEDPresentationScalarMap::MEDPresentationScalarMap(const MEDCALC::ScalarMapParameters& params,
34                                                    const MEDCALC::ViewModeType viewMode) :
35     MEDPresentation(params.fieldHandlerId, TYPE_NAME, viewMode, params.colorMap, params.scalarBarRange), _params(params)
36 {
37 }
38
39 void
40 MEDPresentationScalarMap::internalGeneratePipeline()
41 {
42   MEDPresentation::internalGeneratePipeline();
43
44   MEDPyLockWrapper lock;
45
46   setOrCreateRenderView(); // instantiate __viewXXX
47   createSource();
48   setTimestamp();
49
50   // Populate internal array of available components:
51   fillAvailableFieldComponents();
52
53   // Nothing to do in a scalar map, obj = source:
54   pushAndExecPyLine(_objVar + " = " + _srcObjVar);
55
56   showObject();
57
58   colorBy();
59   showScalarBar();
60   selectColorMap();
61   rescaleTransferFunction();
62   resetCameraAndRender();
63   pushAndExecPyLine(_dispVar+".SetRepresentationType('Surface')");
64 }
65
66 void
67 MEDPresentationScalarMap::updatePipeline(const MEDCALC::ScalarMapParameters& params)
68 {
69   if (params.fieldHandlerId != _params.fieldHandlerId)
70     throw KERNEL::createSalomeException("Unexpected updatePipeline error! Mismatching fieldHandlerId!");
71
72   if (params.colorMap != _params.colorMap)
73     updateColorMap<MEDPresentationScalarMap, MEDCALC::ScalarMapParameters>(params.colorMap);
74
75   if (std::string(params.displayedComponent) != std::string(_params.displayedComponent))
76     updateComponent<MEDPresentationScalarMap, MEDCALC::ScalarMapParameters>(std::string(params.displayedComponent));
77   if (params.scalarBarRange != _params.scalarBarRange ||
78       params.hideDataOutsideCustomRange != _params.hideDataOutsideCustomRange ||
79       params.scalarBarRangeArray[0] != _params.scalarBarRangeArray[0] ||
80       params.scalarBarRangeArray[1] != _params.scalarBarRangeArray[1] )
81     updateScalarBarRange<MEDPresentationScalarMap, MEDCALC::ScalarMapParameters>(params.scalarBarRange,
82                                                                                  params.hideDataOutsideCustomRange,
83                                                                                  params.scalarBarRangeArray[0],
84                                                                                  params.scalarBarRangeArray[1]);
85   if (params.visibility != _params.visibility)
86     updateVisibility<MEDPresentationScalarMap, MEDCALC::ScalarMapParameters>(params.visibility);
87   if (params.scalarBarVisibility != _params.scalarBarVisibility)
88     updateScalarBarVisibility<MEDPresentationScalarMap, MEDCALC::ScalarMapParameters>(params.scalarBarVisibility);
89 }
90