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 "MEDPresentationMeshView.hxx"
22 #include <SALOME_KernelServices.hxx>
23 #undef LOG // should be fixed in KERNEL - double definition
24 #include <Basics_Utils.hxx>
28 const std::string MEDPresentationMeshView::TYPE_NAME = "MEDPresentationMeshView";
29 const std::string MEDPresentationMeshView::PROP_MESH_MODE = "meshMode";
31 MEDPresentationMeshView::MEDPresentationMeshView(const MEDCALC::MeshViewParameters& params,
32 const MEDCALC::MEDPresentationViewMode viewMode) :
33 // Cheating a bit here - a mesh view doesn't need a color map or a range:
34 MEDPresentation(params.fieldHandlerId, TYPE_NAME, viewMode, MEDCALC::COLOR_MAP_DEFAULT,
35 MEDCALC::SCALAR_BAR_RANGE_DEFAULT),
38 setIntProperty(MEDPresentationMeshView::PROP_MESH_MODE, params.mode);
42 MEDPresentationMeshView::getMeshViewCommand() const
44 std::ostringstream oss1;
48 case MEDCALC::MESH_MODE_WIREFRAME:
49 oss1 << _dispVar << ".SetRepresentationType('Wireframe');";
51 case MEDCALC::MESH_MODE_SURFACE_EDGES:
52 oss1 << _dispVar << ".SetRepresentationType('Surface With Edges');";
54 case MEDCALC::MESH_MODE_SURFACE:
55 oss1 << _dispVar << ".SetRepresentationType('Surface');";
58 const char * mes = "Unexpected getMeshViewCommand error!";
60 throw KERNEL::createSalomeException(mes);
67 MEDPresentationMeshView::internalGeneratePipeline()
69 MEDPresentation::internalGeneratePipeline();
71 MEDPyLockWrapper lock;
73 std::ostringstream oss;
74 std::string view(getRenderViewVar());
76 oss << _srcObjVar << " = pvs.MEDReader(FileName='" << _fileName << "');";
77 pushAndExecPyLine(oss.str()); oss.str("");
78 pushAndExecPyLine( getRenderViewCommand() ); // instanciate __viewXXX
79 oss << _objVar << " = " << _srcObjVar << ";";
80 pushAndExecPyLine(oss.str()); oss.str("");
81 oss << _dispVar << " = pvs.Show(" << _objVar << ", " << view << ");";
82 pushAndExecPyLine(oss.str()); oss.str("");
83 pushAndExecPyLine(getMeshViewCommand());
84 pushAndExecPyLine(getResetCameraCommand());
85 pushAndExecPyLine("pvs.Render();");
89 MEDPresentationMeshView::updatePipeline(const MEDCALC::MeshViewParameters& params)
91 if (params.fieldHandlerId != _params.fieldHandlerId)
92 throw KERNEL::createSalomeException("Unexpected updatePipeline error! Mismatching fieldHandlerId!");
94 if (params.mode != _params.mode)
95 updateMeshMode(params.mode);
99 MEDPresentationMeshView::updateMeshMode(const MEDCALC::MEDPresentationMeshMode mode)
104 setIntProperty(MEDPresentationMeshView::PROP_MESH_MODE, mode);
106 // Update the pipeline:
108 MEDPyLockWrapper lock;
109 std::string cmd = getMeshViewCommand();
110 pushAndExecPyLine(cmd);
111 pushAndExecPyLine("pvs.Render();");