1 // Copyright (C) 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 "MEDPyLockWrapper.hxx"
22 #include "MEDPresentationScalarMap.hxx"
23 #include "MEDPresentationException.hxx"
25 #include <SALOME_KernelServices.hxx>
26 #undef LOG // should be fixed in KERNEL - double definition
27 #include <Basics_Utils.hxx>
31 const std::string MEDPresentationScalarMap::TYPE_NAME = "MEDPresentationScalarMap";
33 MEDPresentationScalarMap::MEDPresentationScalarMap(const MEDCALC::ScalarMapParameters& params,
34 const MEDCALC::MEDPresentationViewMode viewMode) :
35 MEDPresentation(params.fieldHandlerId, TYPE_NAME, viewMode, params.colorMap, params.scalarBarRange), _params(params)
40 MEDPresentationScalarMap::internalGeneratePipeline()
42 MEDPresentation::internalGeneratePipeline();
44 MEDPyLockWrapper lock;
46 std::ostringstream oss;
47 std::string view(getRenderViewVar());
49 pushAndExecPyLine( getRenderViewCommand() ); // instanciate __viewXXX
51 oss << _srcObjVar << " = pvs.MEDReader(FileName='" << _fileName << "');";
52 pushAndExecPyLine(oss.str()); oss.str("");
54 // Populate internal array of available components:
55 fillAvailableFieldComponents();
56 // dumpIntProperties();
57 // dumpStringProperties();
59 pushAndExecPyLine(_objVar + " = " + _srcObjVar);
61 oss << _dispVar << " = pvs.Show(" << _objVar << ", " << view << ");";
62 pushAndExecPyLine(oss.str()); oss.str("");
63 oss << "pvs.ColorBy(" << _dispVar << ", ('" << _fieldType << "', '" << _fieldName << "'));";
64 pushAndExecPyLine(oss.str()); oss.str("");
65 oss << _dispVar << ".SetScalarBarVisibility(" << view << ", True);";
66 pushAndExecPyLine(oss.str()); oss.str("");
67 oss << getRescaleCommand();
68 pushAndExecPyLine(oss.str()); oss.str("");
69 oss << _lutVar << " = pvs.GetColorTransferFunction('" << _fieldName << "');";
70 pushAndExecPyLine(oss.str()); oss.str("");
71 pushAndExecPyLine(getColorMapCommand()); oss.str("");
72 pushAndExecPyLine(getResetCameraCommand());
73 pushAndExecPyLine("pvs.Render();");
75 // Retrieve Python object for internal storage:
76 // PyObject* p_obj = getPythonObjectFromMain(obj.c_str());
77 // PyObject* p_disp = getPythonObjectFromMain(disp.c_str());
78 // pushPyObjects(std::make_pair(_objId, p_obj), std::make_pair(disp_id, p_disp));
82 MEDPresentationScalarMap::updatePipeline(const MEDCALC::ScalarMapParameters& params)
84 if (params.fieldHandlerId != _params.fieldHandlerId)
85 throw KERNEL::createSalomeException("Unexpected updatePipeline error! Mismatching fieldHandlerId!");
87 if (std::string(params.displayedComponent) != std::string(_params.displayedComponent))
89 STDLOG("about to updateCompo in scalar map");
90 STDLOG("from param " << params.displayedComponent);
91 STDLOG("from intern " << _params.displayedComponent);
92 updateComponent<MEDPresentationScalarMap, MEDCALC::ScalarMapParameters>(std::string(params.displayedComponent));
94 if (params.scalarBarRange != _params.scalarBarRange)
95 updateScalarBarRange<MEDPresentationScalarMap, MEDCALC::ScalarMapParameters>(params.scalarBarRange);
96 if (params.colorMap != _params.colorMap)
97 updateColorMap<MEDPresentationScalarMap, MEDCALC::ScalarMapParameters>(params.colorMap);