X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCalc%2Fcmp%2FMEDPresentationMeshView.cxx;h=7a4b099072e59b2a9868826da839193016672ca4;hb=9a9f81053e1e8fa736b90baf2843b49e6df8af81;hp=ff23a68b895f36fb317099fd548d5794bc4c51dc;hpb=4f9f7dab21a26bad39e3e2383dc59e4028c350d3;p=modules%2Fmed.git diff --git a/src/MEDCalc/cmp/MEDPresentationMeshView.cxx b/src/MEDCalc/cmp/MEDPresentationMeshView.cxx index ff23a68b8..7a4b09907 100644 --- a/src/MEDCalc/cmp/MEDPresentationMeshView.cxx +++ b/src/MEDCalc/cmp/MEDPresentationMeshView.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2016 CEA/DEN, EDF R&D +// Copyright (C) 2016-2021 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -18,6 +18,7 @@ // #include "MEDPresentationMeshView.hxx" +#include "MEDFactoryClient.hxx" #include #undef LOG // should be fixed in KERNEL - double definition @@ -29,17 +30,29 @@ const std::string MEDPresentationMeshView::TYPE_NAME = "MEDPresentationMeshView" const std::string MEDPresentationMeshView::PROP_MESH_MODE = "meshMode"; MEDPresentationMeshView::MEDPresentationMeshView(const MEDCALC::MeshViewParameters& params, - const MEDCALC::MEDPresentationViewMode viewMode) : + const MEDCALC::ViewModeType viewMode) : // Cheating a bit here - a mesh view doesn't need a color map or a range: - MEDPresentation(params.fieldHandlerId, TYPE_NAME, viewMode, MEDCALC::COLOR_MAP_DEFAULT, + MEDPresentation(params.meshHandlerId, TYPE_NAME, viewMode, MEDCALC::COLOR_MAP_DEFAULT, MEDCALC::SCALAR_BAR_RANGE_DEFAULT), _params(params) { setIntProperty(MEDPresentationMeshView::PROP_MESH_MODE, params.mode); } -std::string -MEDPresentationMeshView::getMeshViewCommand() const +void +MEDPresentationMeshView::initFieldMeshInfos() +{ + MEDCALC::MEDDataManager_ptr dataManager(MEDFactoryClient::getDataManager()); + MEDCALC::MeshHandler* meshHandler = dataManager->getMeshHandler(_handlerId); + MEDCALC::DatasourceHandler* dataSHandler = dataManager->getDatasourceHandlerFromID(meshHandler->sourceid); + + extractFileName(std::string(dataSHandler->uri)); + + _meshName = meshHandler->name; +} + +void +MEDPresentationMeshView::representationType() { std::ostringstream oss1; @@ -59,8 +72,7 @@ MEDPresentationMeshView::getMeshViewCommand() const STDLOG(mes); throw KERNEL::createSalomeException(mes); } - - return oss1.str(); + pushAndExecPyLine(oss1.str()); } void @@ -70,33 +82,39 @@ MEDPresentationMeshView::internalGeneratePipeline() MEDPyLockWrapper lock; - std::ostringstream oss; - std::string view(getRenderViewVar()); + createSource(); + setOrCreateRenderView(); - oss << _srcObjVar << " = pvs.MEDReader(FileName='" << _fileName << "');"; - pushAndExecPyLine(oss.str()); oss.str(""); - pushAndExecPyLine( getRenderViewCommand() ); // instanciate __viewXXX + std::ostringstream oss; oss << _objVar << " = " << _srcObjVar << ";"; pushAndExecPyLine(oss.str()); oss.str(""); - oss << _dispVar << " = pvs.Show(" << _objVar << ", " << view << ");"; - pushAndExecPyLine(oss.str()); oss.str(""); - pushAndExecPyLine(getMeshViewCommand()); - pushAndExecPyLine(getResetCameraCommand()); - pushAndExecPyLine("pvs.Render();"); + + recreateViewSetup(); +} + +void +MEDPresentationMeshView::recreateViewSetup() +{ + showObject(); + representationType(); + resetCameraAndRender(); } void MEDPresentationMeshView::updatePipeline(const MEDCALC::MeshViewParameters& params) { - if (params.fieldHandlerId != _params.fieldHandlerId) - throw KERNEL::createSalomeException("Unexpected updatePipeline error! Mismatching fieldHandlerId!"); + if (params.meshHandlerId != _params.meshHandlerId) + throw KERNEL::createSalomeException("Unexpected updatePipeline error! Mismatching meshHandlerId!"); if (params.mode != _params.mode) updateMeshMode(params.mode); + if (params.visibility != _params.visibility) + updateVisibility(params.visibility); + } void -MEDPresentationMeshView::updateMeshMode(const MEDCALC::MEDPresentationMeshMode mode) +MEDPresentationMeshView::updateMeshMode(const MEDCALC::MeshModeType mode) { _params.mode = mode; @@ -106,8 +124,7 @@ MEDPresentationMeshView::updateMeshMode(const MEDCALC::MEDPresentationMeshMode m // Update the pipeline: { MEDPyLockWrapper lock; - std::string cmd = getMeshViewCommand(); - pushAndExecPyLine(cmd); + representationType(); pushAndExecPyLine("pvs.Render();"); } }