1 // Copyright (C) 2016-2022 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"
21 #include "MEDFactoryClient.hxx"
23 #include <SALOME_KernelServices.hxx>
24 #undef LOG // should be fixed in KERNEL - double definition
25 #include <Basics_Utils.hxx>
29 const std::string MEDPresentationMeshView::TYPE_NAME = "MEDPresentationMeshView";
30 const std::string MEDPresentationMeshView::PROP_MESH_MODE = "meshMode";
32 MEDPresentationMeshView::MEDPresentationMeshView(const MEDCALC::MeshViewParameters& params,
33 const MEDCALC::ViewModeType viewMode) :
34 // Cheating a bit here - a mesh view doesn't need a color map or a range:
35 MEDPresentation(params.meshHandlerId, TYPE_NAME, viewMode, MEDCALC::COLOR_MAP_DEFAULT,
36 MEDCALC::SCALAR_BAR_RANGE_DEFAULT),
39 setIntProperty(MEDPresentationMeshView::PROP_MESH_MODE, params.mode);
43 MEDPresentationMeshView::initFieldMeshInfos()
45 MEDCALC::MEDDataManager_ptr dataManager(MEDFactoryClient::getDataManager());
46 MEDCALC::MeshHandler* meshHandler = dataManager->getMeshHandler(_handlerId);
47 MEDCALC::DatasourceHandler* dataSHandler = dataManager->getDatasourceHandlerFromID(meshHandler->sourceid);
49 extractFileName(std::string(dataSHandler->uri));
51 _meshName = meshHandler->name;
55 MEDPresentationMeshView::representationType()
57 std::ostringstream oss1;
61 case MEDCALC::MESH_MODE_WIREFRAME:
62 oss1 << _dispVar << ".SetRepresentationType('Wireframe');";
64 case MEDCALC::MESH_MODE_SURFACE_EDGES:
65 oss1 << _dispVar << ".SetRepresentationType('Surface With Edges');";
67 case MEDCALC::MESH_MODE_SURFACE:
68 oss1 << _dispVar << ".SetRepresentationType('Surface');";
71 const char * mes = "Unexpected getMeshViewCommand error!";
73 throw KERNEL::createSalomeException(mes);
75 pushAndExecPyLine(oss1.str());
79 MEDPresentationMeshView::internalGeneratePipeline()
81 MEDPresentation::internalGeneratePipeline();
83 MEDPyLockWrapper lock;
86 setOrCreateRenderView();
88 std::ostringstream oss;
89 oss << _objVar << " = " << _srcObjVar << ";";
90 pushAndExecPyLine(oss.str()); oss.str("");
96 MEDPresentationMeshView::recreateViewSetup()
100 resetCameraAndRender();
104 MEDPresentationMeshView::updatePipeline(const MEDCALC::MeshViewParameters& params)
106 if (params.meshHandlerId != _params.meshHandlerId)
107 throw KERNEL::createSalomeException("Unexpected updatePipeline error! Mismatching meshHandlerId!");
109 if (params.mode != _params.mode)
110 updateMeshMode(params.mode);
111 if (params.visibility != _params.visibility)
112 updateVisibility<MEDPresentationMeshView, MEDCALC::MeshViewParameters>(params.visibility);
117 MEDPresentationMeshView::updateMeshMode(const MEDCALC::MeshModeType mode)
122 setIntProperty(MEDPresentationMeshView::PROP_MESH_MODE, mode);
124 // Update the pipeline:
126 MEDPyLockWrapper lock;
127 representationType();
128 pushAndExecPyLine("pvs.Render();");