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 "MEDPresentationScalarMap.hxx"
21 #include "PyInterp_Utils.h"
26 MEDPresentationScalarMap::internalGeneratePipeline()
30 int disp_id(GeneratePythonId());
32 std::ostringstream oss_o, oss_d, oss, oss_v;
33 oss_o << "__obj" << obj_id; std::string obj(oss_o.str());
34 oss_d << "__disp" << disp_id; std::string disp(oss_d.str());
36 pushAndExecPyLine( "import pvsimple as pvs;");
37 pushAndExecPyLine( getRenderViewCommand(_params.viewMode) ); // define __viewXXX
39 oss_v << "__view" << _renderViewPyId; std::string view(oss_v.str());
41 oss << obj << " = pvs.MEDReader(FileName='" << _fileName << "');";
42 pushAndExecPyLine(oss.str()); oss.str("");
43 oss << disp << " = pvs.Show(" << obj << ", " << view << ");";
44 pushAndExecPyLine(oss.str()); oss.str("");
45 oss << "pvs.ColorBy(" << disp << ", ('" << _fieldType << "', '" << _fieldName << "'));";
46 pushAndExecPyLine(oss.str()); oss.str("");
47 oss << disp << ".SetScalarBarVisibility(" << view << ", True);";
48 pushAndExecPyLine(oss.str()); oss.str("");
49 oss << disp << ".RescaleTransferFunctionToDataRangeOverTime();";
50 pushAndExecPyLine(oss.str()); oss.str("");
51 oss << "__lut = pvs.GetColorTransferFunction('" << _fieldName << "');";
52 pushAndExecPyLine(oss.str()); oss.str("");
53 oss << "__lut.ApplyPreset('" << getColorMapCommand(_params.colorMap) << "',True);";
54 pushAndExecPyLine(oss.str()); oss.str("");
55 pushAndExecPyLine(getResetCameraCommand());
56 pushAndExecPyLine("pvs.Render();");
58 // Retrieve Python object for internal storage:
59 PyObject* p_obj = getPythonObjectFromMain(obj.c_str());
60 PyObject* p_disp = getPythonObjectFromMain(disp.c_str());
61 pushPyObjects(std::make_pair(obj_id, p_obj), std::make_pair(disp_id, p_disp));
65 MEDPresentationScalarMap::updatePipeline(const MEDCALC::ScalarMapParameters& params)