From 4f9f7dab21a26bad39e3e2383dc59e4028c350d3 Mon Sep 17 00:00:00 2001 From: abn Date: Mon, 1 Aug 2016 17:07:45 +0200 Subject: [PATCH] [MEDCalc] Mesh view and slice presentation. --- idl/MEDPresentationManager.idl | 49 +++-- src/MEDCalc/cmp/CMakeLists.txt | 3 +- src/MEDCalc/cmp/MEDPresentation.hxx | 1 - src/MEDCalc/cmp/MEDPresentation.txx | 3 - src/MEDCalc/cmp/MEDPresentationContour.hxx | 1 - src/MEDCalc/cmp/MEDPresentationManager_i.cxx | 54 ++++- src/MEDCalc/cmp/MEDPresentationManager_i.hxx | 14 +- src/MEDCalc/cmp/MEDPresentationMeshView.cxx | 113 +++++++++++ src/MEDCalc/cmp/MEDPresentationMeshView.hxx | 50 +++++ src/MEDCalc/cmp/MEDPresentationScalarMap.cxx | 7 +- src/MEDCalc/cmp/MEDPresentationSlices.cxx | 176 +++++++++++++--- src/MEDCalc/cmp/MEDPresentationSlices.hxx | 17 +- src/MEDCalc/gui/CMakeLists.txt | 4 + src/MEDCalc/gui/MEDWidgetHelperMeshView.cxx | 82 ++++++++ src/MEDCalc/gui/MEDWidgetHelperMeshView.hxx | 52 +++++ src/MEDCalc/gui/MEDWidgetHelperSlices.cxx | 93 +++++++++ src/MEDCalc/gui/MEDWidgetHelperSlices.hxx | 54 +++++ src/MEDCalc/gui/MED_images.ts | 24 +++ src/MEDCalc/gui/MED_msg_en.ts | 71 +++++++ src/MEDCalc/gui/PresentationController.cxx | 102 ++++++++-- src/MEDCalc/gui/PresentationController.hxx | 3 + src/MEDCalc/gui/PresentationEvent.hxx | 6 +- .../dialogs/WidgetPresentationParameters.cxx | 189 +++++++++++++++++- .../dialogs/WidgetPresentationParameters.hxx | 16 +- .../dialogs/WidgetPresentationParameters.ui | 93 +++++++-- .../res/presentations/classic/visu_mesh16.png | Bin 0 -> 330 bytes .../res/presentations/classic/visu_mesh24.png | Bin 0 -> 525 bytes .../res/presentations/modern/mesh16.png | Bin 0 -> 330 bytes .../res/presentations/modern/mesh24.png | Bin 0 -> 525 bytes .../res/presentations/modern/mesh24_1.png | Bin 0 -> 1846 bytes src/MEDCalc/test/tui/CMakeLists.txt | 1 + src/MEDCalc/test/tui/contour.py | 6 +- src/MEDCalc/test/tui/mesh_view.py | 36 ++++ src/MEDCalc/test/tui/scalar_map.py | 4 +- src/MEDCalc/test/tui/slices.py | 36 ++++ src/MEDCalc/test/tui/tests.set | 3 + src/MEDCalc/tui/__init__.py | 7 +- src/MEDCalc/tui/medpresentation.py | 66 ++++-- 38 files changed, 1285 insertions(+), 151 deletions(-) create mode 100644 src/MEDCalc/cmp/MEDPresentationMeshView.cxx create mode 100644 src/MEDCalc/cmp/MEDPresentationMeshView.hxx create mode 100644 src/MEDCalc/gui/MEDWidgetHelperMeshView.cxx create mode 100644 src/MEDCalc/gui/MEDWidgetHelperMeshView.hxx create mode 100644 src/MEDCalc/gui/MEDWidgetHelperSlices.cxx create mode 100644 src/MEDCalc/gui/MEDWidgetHelperSlices.hxx create mode 100644 src/MEDCalc/res/presentations/classic/visu_mesh16.png create mode 100644 src/MEDCalc/res/presentations/classic/visu_mesh24.png create mode 100644 src/MEDCalc/res/presentations/modern/mesh16.png create mode 100644 src/MEDCalc/res/presentations/modern/mesh24.png create mode 100644 src/MEDCalc/res/presentations/modern/mesh24_1.png create mode 100644 src/MEDCalc/test/tui/mesh_view.py create mode 100644 src/MEDCalc/test/tui/slices.py diff --git a/idl/MEDPresentationManager.idl b/idl/MEDPresentationManager.idl index d95aca9bc..f66f62721 100644 --- a/idl/MEDPresentationManager.idl +++ b/idl/MEDPresentationManager.idl @@ -44,6 +44,13 @@ module MEDCALC SCALAR_BAR_CURRENT_TIMESTEP }; + enum MEDPresentationMeshMode { + MESH_MODE_WIREFRAME, + MESH_MODE_SURFACE_EDGES, + MESH_MODE_SURFACE + }; + + // struct ScalarBarRange { // // (valMin,valMax) defines the scalar bar range from: @@ -57,7 +64,7 @@ module MEDCALC const string DISPLAY_EUCLIDEAN_NORM = ""; // Void string to avoid clash with a real component name -- never used actually? - enum SliceOrientation { + enum MEDPresentationSliceOrientation { SLICE_NORMAL_TO_X, SLICE_NORMAL_TO_Y, SLICE_NORMAL_TO_Z, @@ -72,15 +79,23 @@ module MEDCALC const MEDPresentationViewMode VIEW_MODE_DEFAULT = VIEW_MODE_REPLACE; const MEDPresentationColorMap COLOR_MAP_DEFAULT = COLOR_MAP_BLUE_TO_RED_RAINBOW; const MEDPresentationScalarBarRange SCALAR_BAR_RANGE_DEFAULT = SCALAR_BAR_ALL_TIMESTEPS; - const long SCALAR_BAR_RANGE_VAL_MIN_DEFAULT = -1; - const long SCALAR_BAR_RANGE_VAL_MAX_DEFAULT = -1; + const MEDPresentationMeshMode MESH_MODE_DEFAULT = MESH_MODE_WIREFRAME; +// const long SCALAR_BAR_RANGE_VAL_MIN_DEFAULT = -1; +// const long SCALAR_BAR_RANGE_VAL_MAX_DEFAULT = -1; const string DISPLAY_DEFAULT = DISPLAY_EUCLIDEAN_NORM; - const SliceOrientation SLICE_ORIENTATION_DEFAULT = SLICE_NORMAL_TO_Z; + const MEDPresentationSliceOrientation SLICE_ORIENTATION_DEFAULT = SLICE_NORMAL_TO_X; const long NB_CONTOURS_DEFAULT = 10; const long NB_SLICES_DEFAULT = 1; /* Structs */ + // Just showing the mesh + struct MeshViewParameters { + long fieldHandlerId; // TODO should be a meshHandlerId really ... + MEDPresentationMeshMode mode; + }; + + // A simple scalar map struct ScalarMapParameters { long fieldHandlerId; string displayedComponent; // DISPLAY_EUCLIDEAN_NORM or any component name @@ -103,14 +118,14 @@ module MEDCALC // MEDPresentationColorMap colorMap; // }; // -// struct SlicesParameters { -// long fieldHandlerId; -// string displayedComponent; // DISPLAY_EUCLIDEAN_NORM or any component name -// MEDPresentationScalarBarRange scalarBarRange; -// MEDPresentationColorMap colorMap; -// SliceOrientation orientation; -// long nbSlices; -// }; + struct SlicesParameters { + long fieldHandlerId; + string displayedComponent; // DISPLAY_EUCLIDEAN_NORM or any component name + MEDPresentationScalarBarRange scalarBarRange; + MEDPresentationColorMap colorMap; + MEDPresentationSliceOrientation orientation; + long nbSlices; + }; // // struct DeflectionShapeParameters { // long fieldHandlerId; @@ -129,11 +144,12 @@ module MEDCALC interface MEDPresentationManager : SALOME::GenericObj { + long makeMeshView(in MeshViewParameters params, in MEDPresentationViewMode viewMode); long makeScalarMap(in ScalarMapParameters params, in MEDPresentationViewMode viewMode); long makeContour(in ContourParameters params, in MEDPresentationViewMode viewMode) raises (SALOME::SALOME_Exception); // long makeVectorField(in VectorFieldParameters params, in MEDPresentationViewMode viewMode); -// long makeSlices(in SlicesParameters params, in MEDPresentationViewMode viewMode); + long makeSlices(in SlicesParameters params, in MEDPresentationViewMode viewMode); // long makeDeflectionShape(in DeflectionShapeParameters params, in MEDPresentationViewMode viewMode); // long makePointSprite(in PointSpriteParameters params, in MEDPresentationViewMode viewMode); @@ -142,13 +158,16 @@ module MEDCALC void setPresentationIntProperty(in long presId, in string propName, in long propValue); long getPresentationIntProperty(in long presId, in string propName); + MeshViewParameters getMeshViewParameters(in long presId); ScalarMapParameters getScalarMapParameters(in long presId); - ContourParameters getContourParameters(in long presId); + ContourParameters getContourParameters(in long presId); + SlicesParameters getSlicesParameters(in long presId); + void updateMeshView(in long presId, in MeshViewParameters params); void updateScalarMap(in long presId, in ScalarMapParameters params); void updateContour(in long presId, in ContourParameters params); // void updateVectorField(in long presId, in VectorFieldParameters params); -// void updateSlices(in long presId, in SlicesParameters params); + void updateSlices(in long presId, in SlicesParameters params); // void updateDeflectionShape(in long presId, in DeflectionShapeParameters params); // void updatePointSprite(in long presId, in PointSpriteParameters params); diff --git a/src/MEDCalc/cmp/CMakeLists.txt b/src/MEDCalc/cmp/CMakeLists.txt index edad94b61..3a443934c 100644 --- a/src/MEDCalc/cmp/CMakeLists.txt +++ b/src/MEDCalc/cmp/CMakeLists.txt @@ -39,10 +39,11 @@ SET(COMMON_SOURCES MEDPresentationManager_i.cxx MEDPresentation.cxx # presentations + MEDPresentationMeshView.cxx MEDPresentationScalarMap.cxx MEDPresentationContour.cxx # MEDPresentationVectorField.cxx -# MEDPresentationSlices.cxx + MEDPresentationSlices.cxx # MEDPresentationDeflectionShape.cxx # MEDPresentationPointSprite.cxx ) diff --git a/src/MEDCalc/cmp/MEDPresentation.hxx b/src/MEDCalc/cmp/MEDPresentation.hxx index 4b75c4f48..a47d1b2ff 100644 --- a/src/MEDCalc/cmp/MEDPresentation.hxx +++ b/src/MEDCalc/cmp/MEDPresentation.hxx @@ -46,7 +46,6 @@ public: static const std::string PROP_NB_COMPONENTS; // number of field components static const std::string PROP_SELECTED_COMPONENT; // index of the selected component - 0 means Euclidean norm static const std::string PROP_COMPONENT; // string prefix for all properties storing component names - static const std::string PROP_COLOR_MAP; // color map - TODO: arch fix - should be in params only static const std::string PROP_SCALAR_BAR_RANGE; // scalar bar range - TODO: arch fix - should be in params only diff --git a/src/MEDCalc/cmp/MEDPresentation.txx b/src/MEDCalc/cmp/MEDPresentation.txx index 0e061fc20..8d6fa6f07 100644 --- a/src/MEDCalc/cmp/MEDPresentation.txx +++ b/src/MEDCalc/cmp/MEDPresentation.txx @@ -47,7 +47,6 @@ MEDPresentation::setParameters(const PresentationParameters& params) p->setParameters(params); } - /** * Update the ParaVis pipeline so that the given component appears on screen. * Blank means "Euclidean norm" @@ -64,8 +63,6 @@ MEDPresentation::updateComponent(const std::string& newCompo) params.displayedComponent = newCompo.c_str(); p->setParameters(params); - - int nbCompo = getIntProperty(MEDPresentation::PROP_NB_COMPONENTS); int idx = -1; for (int i=0; i < nbCompo; i++) diff --git a/src/MEDCalc/cmp/MEDPresentationContour.hxx b/src/MEDCalc/cmp/MEDPresentationContour.hxx index 4fb42ab28..7a61ce020 100644 --- a/src/MEDCalc/cmp/MEDPresentationContour.hxx +++ b/src/MEDCalc/cmp/MEDPresentationContour.hxx @@ -33,7 +33,6 @@ public: virtual ~MEDPresentationContour() {} void updatePipeline(const MEDCALC::ContourParameters& params); -// MEDCALC::MEDPresentationViewMode getViewMode() { return _params.viewMode; } void getParameters(MEDCALC::ContourParameters & params) const { params = _params; } ; void setParameters(const MEDCALC::ContourParameters & params) { _params = params; } ; diff --git a/src/MEDCalc/cmp/MEDPresentationManager_i.cxx b/src/MEDCalc/cmp/MEDPresentationManager_i.cxx index fc758a161..ad763cb67 100644 --- a/src/MEDCalc/cmp/MEDPresentationManager_i.cxx +++ b/src/MEDCalc/cmp/MEDPresentationManager_i.cxx @@ -22,9 +22,10 @@ #include "Basics_Utils.hxx" // presentations +#include "MEDPresentationMeshView.hxx" #include "MEDPresentationScalarMap.hxx" #include "MEDPresentationContour.hxx" -//#include "MEDPresentationSlices.hxx" +#include "MEDPresentationSlices.hxx" //#include "MEDPresentationVectorField.hxx" //#include "MEDPresentationDeflectionShape.hxx" //#include "MEDPresentationPointSprite.hxx" @@ -122,6 +123,12 @@ MEDPresentationManager_i::getPresentationIntProperty(MEDPresentation::TypeID pre } +MEDPresentation::TypeID +MEDPresentationManager_i::makeMeshView(const MEDCALC::MeshViewParameters& params, const MEDCALC::MEDPresentationViewMode viewMode) +{ + return _makePresentation(params, viewMode); +} + MEDPresentation::TypeID MEDPresentationManager_i::makeScalarMap(const MEDCALC::ScalarMapParameters& params, const MEDCALC::MEDPresentationViewMode viewMode) { @@ -140,11 +147,11 @@ MEDPresentationManager_i::makeContour(const MEDCALC::ContourParameters& params, // return _makePresentation(params); //} // -//MEDPresentation::TypeID -//MEDPresentationManager_i::makeSlices(const MEDCALC::SlicesParameters& params) -//{ -// return _makePresentation(params); -//} +MEDPresentation::TypeID +MEDPresentationManager_i::makeSlices(const MEDCALC::SlicesParameters& params, const MEDCALC::MEDPresentationViewMode viewMode) +{ + return _makePresentation(params, viewMode); +} // //MEDPresentation::TypeID //MEDPresentationManager_i::makeDeflectionShape(const MEDCALC::DeflectionShapeParameters& params) @@ -158,6 +165,15 @@ MEDPresentationManager_i::makeContour(const MEDCALC::ContourParameters& params, // return _makePresentation(params); //} +MEDCALC::MeshViewParameters +MEDPresentationManager_i::getMeshViewParameters(MEDPresentation::TypeID presentationID) +{ + MEDCALC::MeshViewParameters p; + _getParameters(presentationID, p); + return p; +} + + MEDCALC::ScalarMapParameters* MEDPresentationManager_i::getScalarMapParameters(MEDPresentation::TypeID presentationID) { @@ -175,6 +191,22 @@ MEDPresentationManager_i::getContourParameters(MEDPresentation::TypeID presentat return p; } +MEDCALC::SlicesParameters* +MEDPresentationManager_i::getSlicesParameters(MEDPresentation::TypeID presentationID) +{ + MEDCALC::SlicesParameters* p = new MEDCALC::SlicesParameters(); + _getParameters(presentationID, *p); + MEDCALC::SlicesParameters_var tmp(p); + return tmp._retn(); +} + + +void +MEDPresentationManager_i::updateMeshView(MEDPresentation::TypeID presentationID, const MEDCALC::MeshViewParameters& params) +{ + return _updatePresentation(presentationID, params); +} + void MEDPresentationManager_i::updateScalarMap(MEDPresentation::TypeID presentationID, const MEDCALC::ScalarMapParameters& params) { @@ -193,11 +225,11 @@ MEDPresentationManager_i::updateContour(MEDPresentation::TypeID presentationID, // return _updatePresentation(presentationID, params); //} // -//void -//MEDPresentationManager_i::updateSlices(MEDPresentation::TypeID presentationID, const MEDCALC::SlicesParameters& params) -//{ -// return _updatePresentation(presentationID, params); -//} +void +MEDPresentationManager_i::updateSlices(MEDPresentation::TypeID presentationID, const MEDCALC::SlicesParameters& params) +{ + return _updatePresentation(presentationID, params); +} // //void //MEDPresentationManager_i::updateDeflectionShape(MEDPresentation::TypeID presentationID, const MEDCALC::DeflectionShapeParameters& params) diff --git a/src/MEDCalc/cmp/MEDPresentationManager_i.hxx b/src/MEDCalc/cmp/MEDPresentationManager_i.hxx index 1016968e8..7c0cb19a0 100644 --- a/src/MEDCalc/cmp/MEDPresentationManager_i.hxx +++ b/src/MEDCalc/cmp/MEDPresentationManager_i.hxx @@ -39,12 +39,13 @@ class MEDPresentationManager_i: public POA_MEDCALC::MEDPresentationManager, static MEDPresentationManager_i* getInstance(); + MEDCALC_EXPORT MEDPresentation::TypeID makeMeshView(const MEDCALC::MeshViewParameters&, const MEDCALC::MEDPresentationViewMode); MEDCALC_EXPORT MEDPresentation::TypeID makeScalarMap(const MEDCALC::ScalarMapParameters&, const MEDCALC::MEDPresentationViewMode); MEDCALC_EXPORT MEDPresentation::TypeID makeContour(const MEDCALC::ContourParameters&, const MEDCALC::MEDPresentationViewMode); -// MEDCALC_EXPORT MEDPresentation::TypeID makeVectorField(const MEDCALC::VectorFieldParameters&); -// MEDCALC_EXPORT MEDPresentation::TypeID makeSlices(const MEDCALC::SlicesParameters&); -// MEDCALC_EXPORT MEDPresentation::TypeID makeDeflectionShape(const MEDCALC::DeflectionShapeParameters&); -// MEDCALC_EXPORT MEDPresentation::TypeID makePointSprite(const MEDCALC::PointSpriteParameters&); +// MEDCALC_EXPORT MEDPresentation::TypeID makeVectorField(const MEDCALC::VectorFieldParameters&, const MEDCALC::MEDPresentationViewMode); + MEDCALC_EXPORT MEDPresentation::TypeID makeSlices(const MEDCALC::SlicesParameters&, const MEDCALC::MEDPresentationViewMode); +// MEDCALC_EXPORT MEDPresentation::TypeID makeDeflectionShape(const MEDCALC::DeflectionShapeParameters&, const MEDCALC::MEDPresentationViewMode); +// MEDCALC_EXPORT MEDPresentation::TypeID makePointSprite(const MEDCALC::PointSpriteParameters&, const MEDCALC::MEDPresentationViewMode); MEDCALC_EXPORT void setPresentationStringProperty(MEDPresentation::TypeID presentationID, const char* propName, const char* propValue); MEDCALC_EXPORT char* getPresentationStringProperty(MEDPresentation::TypeID presentationID, const char* propName); @@ -52,13 +53,16 @@ class MEDPresentationManager_i: public POA_MEDCALC::MEDPresentationManager, MEDCALC_EXPORT void setPresentationIntProperty(MEDPresentation::TypeID presentationID, const char* propName, const CORBA::Long propValue); MEDCALC_EXPORT CORBA::Long getPresentationIntProperty(MEDPresentation::TypeID presentationID, const char* propName); + MEDCALC_EXPORT MEDCALC::MeshViewParameters getMeshViewParameters(MEDPresentation::TypeID presentationID); MEDCALC_EXPORT MEDCALC::ScalarMapParameters* getScalarMapParameters(MEDPresentation::TypeID presentationID); MEDCALC_EXPORT MEDCALC::ContourParameters getContourParameters(MEDPresentation::TypeID presentationID); + MEDCALC_EXPORT MEDCALC::SlicesParameters* getSlicesParameters(MEDPresentation::TypeID presentationID); + MEDCALC_EXPORT void updateMeshView(MEDPresentation::TypeID, const MEDCALC::MeshViewParameters&); MEDCALC_EXPORT void updateScalarMap(MEDPresentation::TypeID, const MEDCALC::ScalarMapParameters&); MEDCALC_EXPORT void updateContour(MEDPresentation::TypeID, const MEDCALC::ContourParameters&); // MEDCALC_EXPORT void updateVectorField(MEDPresentation::TypeID, const MEDCALC::VectorFieldParameters&); -// MEDCALC_EXPORT void updateSlices(MEDPresentation::TypeID, const MEDCALC::SlicesParameters&); + MEDCALC_EXPORT void updateSlices(MEDPresentation::TypeID, const MEDCALC::SlicesParameters&); // MEDCALC_EXPORT void updateDeflectionShape(MEDPresentation::TypeID, const MEDCALC::DeflectionShapeParameters&); // MEDCALC_EXPORT void updatePointSprite(MEDPresentation::TypeID, const MEDCALC::PointSpriteParameters&); diff --git a/src/MEDCalc/cmp/MEDPresentationMeshView.cxx b/src/MEDCalc/cmp/MEDPresentationMeshView.cxx new file mode 100644 index 000000000..ff23a68b8 --- /dev/null +++ b/src/MEDCalc/cmp/MEDPresentationMeshView.cxx @@ -0,0 +1,113 @@ +// Copyright (C) 2016 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 +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MEDPresentationMeshView.hxx" + +#include +#undef LOG // should be fixed in KERNEL - double definition +#include + +#include + +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) : + // 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, + MEDCALC::SCALAR_BAR_RANGE_DEFAULT), + _params(params) +{ + setIntProperty(MEDPresentationMeshView::PROP_MESH_MODE, params.mode); +} + +std::string +MEDPresentationMeshView::getMeshViewCommand() const +{ + std::ostringstream oss1; + + switch (_params.mode) + { + case MEDCALC::MESH_MODE_WIREFRAME: + oss1 << _dispVar << ".SetRepresentationType('Wireframe');"; + break; + case MEDCALC::MESH_MODE_SURFACE_EDGES: + oss1 << _dispVar << ".SetRepresentationType('Surface With Edges');"; + break; + case MEDCALC::MESH_MODE_SURFACE: + oss1 << _dispVar << ".SetRepresentationType('Surface');"; + break; + default: + const char * mes = "Unexpected getMeshViewCommand error!"; + STDLOG(mes); + throw KERNEL::createSalomeException(mes); + } + + return oss1.str(); +} + +void +MEDPresentationMeshView::internalGeneratePipeline() +{ + MEDPresentation::internalGeneratePipeline(); + + MEDPyLockWrapper lock; + + std::ostringstream oss; + std::string view(getRenderViewVar()); + + oss << _srcObjVar << " = pvs.MEDReader(FileName='" << _fileName << "');"; + pushAndExecPyLine(oss.str()); oss.str(""); + pushAndExecPyLine( getRenderViewCommand() ); // instanciate __viewXXX + 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();"); +} + +void +MEDPresentationMeshView::updatePipeline(const MEDCALC::MeshViewParameters& params) +{ + if (params.fieldHandlerId != _params.fieldHandlerId) + throw KERNEL::createSalomeException("Unexpected updatePipeline error! Mismatching fieldHandlerId!"); + + if (params.mode != _params.mode) + updateMeshMode(params.mode); +} + +void +MEDPresentationMeshView::updateMeshMode(const MEDCALC::MEDPresentationMeshMode mode) +{ + _params.mode = mode; + + // GUI helper: + setIntProperty(MEDPresentationMeshView::PROP_MESH_MODE, mode); + + // Update the pipeline: + { + MEDPyLockWrapper lock; + std::string cmd = getMeshViewCommand(); + pushAndExecPyLine(cmd); + pushAndExecPyLine("pvs.Render();"); + } +} diff --git a/src/MEDCalc/cmp/MEDPresentationMeshView.hxx b/src/MEDCalc/cmp/MEDPresentationMeshView.hxx new file mode 100644 index 000000000..06c43fa92 --- /dev/null +++ b/src/MEDCalc/cmp/MEDPresentationMeshView.hxx @@ -0,0 +1,50 @@ +// Copyright (C) 2016 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 +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef SRC_MEDCALC_CMP_MEDPRESENTATION_MESHVIEW_HXX_ +#define SRC_MEDCALC_CMP_MEDPRESENTATION_MESHVIEW_HXX_ + +#include "MEDCALC.hxx" +#include "MEDPresentation.hxx" + +class MEDCALC_EXPORT MEDPresentationMeshView : public MEDPresentation +{ +public: + static const std::string TYPE_NAME; + static const std::string PROP_MESH_MODE; + + MEDPresentationMeshView(const MEDCALC::MeshViewParameters& params, const MEDCALC::MEDPresentationViewMode viewMode); + virtual ~MEDPresentationMeshView() {} + + void updatePipeline(const MEDCALC::MeshViewParameters& params); + + void getParameters(MEDCALC::MeshViewParameters & params) const { params = _params; } ; + void setParameters(const MEDCALC::MeshViewParameters & params) { _params = params; } ; + +protected: + void updateMeshMode(const MEDCALC::MEDPresentationMeshMode mode); + virtual void internalGeneratePipeline(); + + std::string getMeshViewCommand() const; + +private: + MEDCALC::MeshViewParameters _params; +}; + +#endif diff --git a/src/MEDCalc/cmp/MEDPresentationScalarMap.cxx b/src/MEDCalc/cmp/MEDPresentationScalarMap.cxx index 50d6ebbdc..3f603db7b 100644 --- a/src/MEDCalc/cmp/MEDPresentationScalarMap.cxx +++ b/src/MEDCalc/cmp/MEDPresentationScalarMap.cxx @@ -85,12 +85,7 @@ MEDPresentationScalarMap::updatePipeline(const MEDCALC::ScalarMapParameters& par throw KERNEL::createSalomeException("Unexpected updatePipeline error! Mismatching fieldHandlerId!"); if (std::string(params.displayedComponent) != std::string(_params.displayedComponent)) - { - STDLOG("about to updateCompo in scalar map"); - STDLOG("from param " << params.displayedComponent); - STDLOG("from intern " << _params.displayedComponent); - updateComponent(std::string(params.displayedComponent)); - } + updateComponent(std::string(params.displayedComponent)); if (params.scalarBarRange != _params.scalarBarRange) updateScalarBarRange(params.scalarBarRange); if (params.colorMap != _params.colorMap) diff --git a/src/MEDCalc/cmp/MEDPresentationSlices.cxx b/src/MEDCalc/cmp/MEDPresentationSlices.cxx index 243468f0b..a71284f03 100644 --- a/src/MEDCalc/cmp/MEDPresentationSlices.cxx +++ b/src/MEDCalc/cmp/MEDPresentationSlices.cxx @@ -19,37 +19,163 @@ #include "MEDPresentationSlices.hxx" +#include +#undef LOG // should be fixed in KERNEL - double definition +#include + +#include + +const std::string MEDPresentationSlices::TYPE_NAME = "MEDPresentationSlices"; +const std::string MEDPresentationSlices::PROP_NB_SLICES = "nbSlices"; +const std::string MEDPresentationSlices::PROP_SLICE_ORIENTATION = "slicesOrientation"; + +MEDPresentationSlices::MEDPresentationSlices(const MEDCALC::SlicesParameters& params, + const MEDCALC::MEDPresentationViewMode viewMode) : + MEDPresentation(params.fieldHandlerId, TYPE_NAME, viewMode, params.colorMap, params.scalarBarRange), + _params(params) +{ + setIntProperty(MEDPresentationSlices::PROP_NB_SLICES, params.nbSlices); + setIntProperty(MEDPresentationSlices::PROP_SLICE_ORIENTATION, params.orientation); +} + +std::string +MEDPresentationSlices::getNbSlicesCommand() const +{ + std::ostringstream oss1; + // TODO +// oss1 << _objVar << ".SliceType.Normal = " << norm << ";"; + return oss1.str(); +} + +std::string +MEDPresentationSlices::getOrientationCommand() const +{ + std::ostringstream oss1; + std::string norm; + + switch(_params.orientation) + { + case MEDCALC::SLICE_NORMAL_TO_X: + norm = "[1.0, 0.0, 0.0]"; + break; + case MEDCALC::SLICE_NORMAL_TO_Y: + norm = "[0.0, 1.0, 0.0]"; + break; + case MEDCALC::SLICE_NORMAL_TO_Z: + norm = "[0.0, 0.0, 1.0]"; + break; + case MEDCALC::SLICE_NORMAL_TO_XY: + norm = "[1.0, 1.0, 0.0]"; + break; + case MEDCALC::SLICE_NORMAL_TO_XZ: + norm = "[1.0, 0.0, 1.0]"; + break; + case MEDCALC::SLICE_NORMAL_TO_YZ: + norm = "[0.0, 1.0, 1.0]"; + break; + case MEDCALC::SLICE_NORMAL_TO_XYZ: + norm = "[1.0, 1.0, 1.0]"; + break; + default: + const char * mes = "Unexpected getSliceOrientationCommand() error!"; + STDLOG(mes); + throw KERNEL::createSalomeException(mes); + } + + oss1 << _objVar << ".SliceType.Normal = " << norm << ";"; + return oss1.str(); +} + + void MEDPresentationSlices::internalGeneratePipeline() { -// PyGILState_STATE _gil_state = PyGILState_Ensure(); -// -// std::string cmd = std::string("import pvsimple as pvs;"); -// cmd += getRenderViewCommand(_params.viewMode); // define __view1 -// -// cmd += std::string("__obj1 = pvs.MEDReader(FileName='") + _fileName + std::string("');"); -// cmd += std::string("__slice1 = pvs.Slice(Input=__obj1);"); -// cmd += std::string("__disp1 = pvs.Show(__slice1, __view1);"); -// cmd += std::string("pvs.ColorBy(__disp1, ('") + _fieldType + std::string("', '") + _fieldName + std::string("'));"); -// cmd += std::string("__disp1.SetScalarBarVisibility(__view1, True);"); -// cmd += std::string("__disp1.RescaleTransferFunctionToDataRangeOverTime();"); -// cmd += std::string("pvs.Render();"); -// -// cmd += getResetCameraCommand(); -// -// //std::cerr << "Python command:" << std::endl; -// //std::cerr << cmd << std::endl; -// PyRun_SimpleString(cmd.c_str()); -// // Retrieve Python object for internal storage: -// PyObject* obj = getPythonObjectFromMain("__slice1"); -// PyObject* disp = getPythonObjectFromMain("__disp1"); -// pushInternal(obj, disp); -// -// PyGILState_Release(_gil_state); + MEDPresentation::internalGeneratePipeline(); + + MEDPyLockWrapper lock; + + std::ostringstream oss_o, oss; + std::string view(getRenderViewVar()); + + oss << _srcObjVar << " = pvs.MEDReader(FileName='" << _fileName << "');"; + pushAndExecPyLine(oss.str()); oss.str(""); + + // Populate internal array of available components: + fillAvailableFieldComponents(); + pushAndExecPyLine( getRenderViewCommand() ); // instanciate __viewXXX + oss << _objVar << " = pvs.Slice(Input=" << _srcObjVar << ");"; + pushAndExecPyLine(oss.str()); oss.str(""); + oss << _objVar << ".SliceType = 'Plane';"; + pushAndExecPyLine(oss.str()); oss.str(""); + + // Set slice orientation + pushAndExecPyLine(getOrientationCommand()); + + oss << _dispVar << " = pvs.Show(" << _objVar << ", " << view << ");"; + pushAndExecPyLine(oss.str()); oss.str(""); + oss << "pvs.ColorBy(" << _dispVar << ", ('" << _fieldType << "', '" << _fieldName << "'));"; + pushAndExecPyLine(oss.str()); oss.str(""); + oss << _dispVar << ".SetScalarBarVisibility(" << view << ", True);"; + pushAndExecPyLine(oss.str()); oss.str(""); + oss << getRescaleCommand(); + pushAndExecPyLine(oss.str()); oss.str(""); + oss << _lutVar << " = pvs.GetColorTransferFunction('" << _fieldName << "');"; + pushAndExecPyLine(oss.str()); oss.str(""); + pushAndExecPyLine(getColorMapCommand()); oss.str(""); + pushAndExecPyLine(getResetCameraCommand()); + pushAndExecPyLine("pvs.Render();"); } void MEDPresentationSlices::updatePipeline(const MEDCALC::SlicesParameters& params) { - // :TODO: + if (params.fieldHandlerId != _params.fieldHandlerId) + throw KERNEL::createSalomeException("Unexpected updatePipeline error! Mismatching fieldHandlerId!"); + + if (std::string(params.displayedComponent) != std::string(_params.displayedComponent)) + updateComponent(std::string(params.displayedComponent)); + if (params.scalarBarRange != _params.scalarBarRange) + updateScalarBarRange(params.scalarBarRange); + if (params.colorMap != _params.colorMap) + updateColorMap(params.colorMap); + + if (params.orientation != _params.orientation) + updateOrientation(params.orientation); + if (params.nbSlices != _params.nbSlices) + updateNbSlices(params.nbSlices); +} + +void +MEDPresentationSlices::updateNbSlices(const int nbSlices) +{ + _params.nbSlices = nbSlices; + + // GUI helper: + setIntProperty(MEDPresentationSlices::PROP_NB_SLICES, nbSlices); + + // Update the pipeline: + { + MEDPyLockWrapper lock; + std::string cmd = getNbSlicesCommand(); + pushAndExecPyLine(cmd); + pushAndExecPyLine("pvs.Render();"); + } +} + +void +MEDPresentationSlices::updateOrientation(const MEDCALC::MEDPresentationSliceOrientation orientation) +{ + _params.orientation = orientation; + + // GUI helper: + setIntProperty(MEDPresentationSlices::PROP_SLICE_ORIENTATION, orientation); + + // Update the pipeline: + { + MEDPyLockWrapper lock; + std::string cmd = getOrientationCommand(); + pushAndExecPyLine(cmd); + pushAndExecPyLine("pvs.Render();"); + } } + diff --git a/src/MEDCalc/cmp/MEDPresentationSlices.hxx b/src/MEDCalc/cmp/MEDPresentationSlices.hxx index 7166a92bd..bc55bbcfd 100644 --- a/src/MEDCalc/cmp/MEDPresentationSlices.hxx +++ b/src/MEDCalc/cmp/MEDPresentationSlices.hxx @@ -26,17 +26,26 @@ class MEDCALC_EXPORT MEDPresentationSlices : public MEDPresentation { public: - MEDPresentationSlices(const MEDCALC::SlicesParameters& params) : - MEDPresentation(params.fieldHandlerId, "MEDPresentationSlices"), _params(params) - {} + static const std::string TYPE_NAME; + static const std::string PROP_NB_SLICES; + static const std::string PROP_SLICE_ORIENTATION; + + MEDPresentationSlices(const MEDCALC::SlicesParameters& params, const MEDCALC::MEDPresentationViewMode viewMode); virtual ~MEDPresentationSlices() {} void updatePipeline(const MEDCALC::SlicesParameters& params); - MEDCALC::MEDPresentationViewMode getViewMode() { return _params.viewMode; } + + void getParameters(MEDCALC::SlicesParameters & params) const { params = _params; } ; + void setParameters(const MEDCALC::SlicesParameters & params) { _params = params; } ; protected: + void updateNbSlices(const int nbSlices); + void updateOrientation(const MEDCALC::MEDPresentationSliceOrientation orientation); virtual void internalGeneratePipeline(); + std::string getNbSlicesCommand() const; + std::string getOrientationCommand() const; + private: MEDCALC::SlicesParameters _params; }; diff --git a/src/MEDCalc/gui/CMakeLists.txt b/src/MEDCalc/gui/CMakeLists.txt index f0398bb01..0ff4b8f45 100644 --- a/src/MEDCalc/gui/CMakeLists.txt +++ b/src/MEDCalc/gui/CMakeLists.txt @@ -38,8 +38,10 @@ SET(MEDCALCGUI_SOURCES XmedConsoleDriver.cxx XmedDataModel.cxx MEDWidgetHelper.cxx + MEDWidgetHelperMeshView.cxx MEDWidgetHelperScalarMap.cxx MEDWidgetHelperContour.cxx + MEDWidgetHelperSlices.cxx ) IF(SALOME_MED_WITH_QTTESTING) @@ -54,8 +56,10 @@ SET(MEDCALCGUI_HEADERS PresentationController.hxx ProcessingController.hxx MEDWidgetHelper.hxx + MEDWidgetHelperMeshView.hxx MEDWidgetHelperScalarMap.hxx MEDWidgetHelperContour.hxx + MEDWidgetHelperSlices.hxx ) IF(SALOME_MED_WITH_QTTESTING) diff --git a/src/MEDCalc/gui/MEDWidgetHelperMeshView.cxx b/src/MEDCalc/gui/MEDWidgetHelperMeshView.cxx new file mode 100644 index 000000000..d927164b8 --- /dev/null +++ b/src/MEDCalc/gui/MEDWidgetHelperMeshView.cxx @@ -0,0 +1,82 @@ +// Copyright (C) 2016 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 +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MEDWidgetHelperMeshView.hxx" +#include "MEDPresentationMeshView.hxx" // from component side. +#include "PresentationController.hxx" + +#include + +#include + +MEDWidgetHelperMeshView::MEDWidgetHelperMeshView(const PresentationController * presController, + MEDCALC::MEDPresentationManager_ptr presManager, int presId, + const std::string & presName, WidgetPresentationParameters * paramW): + MEDWidgetHelper(presController, presManager, presId, presName, paramW) +{ +} + +MEDWidgetHelperMeshView::~MEDWidgetHelperMeshView() +{} + +void MEDWidgetHelperMeshView::loadParametersFromEngine() +{ + MEDWidgetHelper::loadParametersFromEngine(); + _meshMode = static_cast( + _presManager->getPresentationIntProperty(_presId, MEDPresentationMeshView::PROP_MESH_MODE.c_str())); +} + +void MEDWidgetHelperMeshView::udpateWidget() +{ + MEDWidgetHelper::udpateWidget(); + + // MeshView presentation needs the mesh mode that's all. + _paramWidget->setMeshMode(_meshMode); + // Hide color map and scalar bar range + _paramWidget->toggleCommonFieldWidget(false); + + // Connect combo box changes + QObject::connect( this, SIGNAL(presentationUpdateSignal(const PresentationEvent *)), + _presController, SIGNAL(presentationSignal(const PresentationEvent *)) ); + QObject::connect( _paramWidget, SIGNAL(comboMeshIndexChanged(int)), this, SLOT(onMeshModeChanged(int)) ); +} + +void MEDWidgetHelperMeshView::releaseWidget() +{ + MEDWidgetHelper::releaseWidget(); + + // Show color map and scalar bar range + _paramWidget->toggleCommonFieldWidget(true); + + QObject::disconnect( this, SIGNAL(presentationUpdateSignal(const PresentationEvent *)), + _presController, SIGNAL(presentationSignal(const PresentationEvent *)) ); + QObject::disconnect( _paramWidget, SIGNAL(comboMeshIndexChanged(int)), this, SLOT(onMeshModeChanged(int)) ); +} + +void MEDWidgetHelperMeshView::onMeshModeChanged(int meshMode) +{ + STDLOG("MEDWidgetHelperMeshView::onMeshModeChanged"); + PresentationEvent* event = new PresentationEvent(); + event->eventtype = PresentationEvent::EVENT_CHANGE_MESH_MODE; + event->presentationId = _presId; + event->anInteger = static_cast(_paramWidget->getMeshMode()); + + emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent +} + diff --git a/src/MEDCalc/gui/MEDWidgetHelperMeshView.hxx b/src/MEDCalc/gui/MEDWidgetHelperMeshView.hxx new file mode 100644 index 000000000..4a04c56fd --- /dev/null +++ b/src/MEDCalc/gui/MEDWidgetHelperMeshView.hxx @@ -0,0 +1,52 @@ +// Copyright (C) 2016 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 +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef SRC_MEDCALC_GUI_MEDWIDGETHELPERMESHVIEW_HXX_ +#define SRC_MEDCALC_GUI_MEDWIDGETHELPERMESHVIEW_HXX_ + +#include "MEDWidgetHelper.hxx" + +class PresentationController; + +class MEDWidgetHelperMeshView: public MEDWidgetHelper +{ + Q_OBJECT + +public: + MEDWidgetHelperMeshView(const PresentationController* presController, + MEDCALC::MEDPresentationManager_ptr presManager, int presId, const std::string & presName, + WidgetPresentationParameters * paramW); + virtual ~MEDWidgetHelperMeshView(); + + virtual void udpateWidget(); + virtual void releaseWidget(); + + virtual std::string getPythonTag() const { return "MeshView"; } + +protected slots: + void onMeshModeChanged(int index); + +protected: + virtual void loadParametersFromEngine(); + +private: + MEDCALC::MEDPresentationMeshMode _meshMode; +}; + +#endif /* SRC_MEDCALC_GUI_MEDWIDGETHELPERMESHVIEW_HXX_ */ diff --git a/src/MEDCalc/gui/MEDWidgetHelperSlices.cxx b/src/MEDCalc/gui/MEDWidgetHelperSlices.cxx new file mode 100644 index 000000000..f9cb1b7d8 --- /dev/null +++ b/src/MEDCalc/gui/MEDWidgetHelperSlices.cxx @@ -0,0 +1,93 @@ +// Copyright (C) 2016 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 +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MEDWidgetHelperSlices.hxx" +#include "MEDPresentationSlices.hxx" // from component side. +#include "PresentationController.hxx" + +#include + +#include + +MEDWidgetHelperSlices::MEDWidgetHelperSlices(const PresentationController * presController, + MEDCALC::MEDPresentationManager_ptr presManager, int presId, + const std::string & presName, WidgetPresentationParameters * paramW): + MEDWidgetHelper(presController, presManager, presId, presName, paramW), + _nbSlices(-1), + _sliceOrientation(MEDCALC::SLICE_ORIENTATION_DEFAULT) +{} + +MEDWidgetHelperSlices::~MEDWidgetHelperSlices() +{} + +void MEDWidgetHelperSlices::loadParametersFromEngine() +{ + MEDWidgetHelper::loadParametersFromEngine(); + _nbSlices = _presManager->getPresentationIntProperty(_presId, MEDPresentationSlices::PROP_NB_SLICES.c_str()); + _sliceOrientation = static_cast( + _presManager->getPresentationIntProperty(_presId, MEDPresentationSlices::PROP_SLICE_ORIENTATION.c_str())); +} + +void MEDWidgetHelperSlices::udpateWidget() +{ + MEDWidgetHelper::udpateWidget(); + STDLOG("MEDWidgetHelperSlices::udpateWidget() nbSlices is " << _nbSlices); + +// _paramWidget->setNbSlices(_nbSlices); // TODO: uncomment when ready to deal with slice number + _paramWidget->setSliceOrientation(_sliceOrientation); + + // Connect combo box changes + QObject::connect( this, SIGNAL(presentationUpdateSignal(const PresentationEvent *)), + _presController, SIGNAL(presentationSignal(const PresentationEvent *)) ); + QObject::connect( _paramWidget, SIGNAL(spinBoxValueChanged(int)), this, SLOT(onNbSlicesChanged(int)) ); + QObject::connect( _paramWidget, SIGNAL(comboOrientIndexChanged(int)), this, SLOT(onSliceOrientationChanged(int)) ); +} + +void MEDWidgetHelperSlices::releaseWidget() +{ + MEDWidgetHelper::releaseWidget(); + + QObject::disconnect( this, SIGNAL(presentationUpdateSignal(const PresentationEvent *)), + _presController, SIGNAL(presentationSignal(const PresentationEvent *)) ); + QObject::disconnect( _paramWidget, SIGNAL(spinBoxValueChanged(int)), this, SLOT(onNbSlicesChanged(int)) ); + QObject::disconnect( _paramWidget, SIGNAL(comboOrientIndexChanged(int)), this, SLOT(onSliceOrientationChanged(int)) ); +} + +void MEDWidgetHelperSlices::onNbSlicesChanged(int nbSlices) +{ + STDLOG("MEDWidgetHelperSlices::onNbSlicesChanged"); + PresentationEvent* event = new PresentationEvent(); + event->eventtype = PresentationEvent::EVENT_CHANGE_NB_SLICES; + event->presentationId = _presId; + event->anInteger = nbSlices; + + emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent +} + + +void MEDWidgetHelperSlices::onSliceOrientationChanged(int sliceOrient) +{ + STDLOG("MEDWidgetHelperSlices::onNbSlicesChanged"); + PresentationEvent* event = new PresentationEvent(); + event->eventtype = PresentationEvent::EVENT_CHANGE_SLICE_ORIENTATION; + event->presentationId = _presId; + event->anInteger = static_cast(_paramWidget->getSliceOrientation()); + + emit presentationUpdateSignal(event); // --> PresentationController::processPresentationEvent +} diff --git a/src/MEDCalc/gui/MEDWidgetHelperSlices.hxx b/src/MEDCalc/gui/MEDWidgetHelperSlices.hxx new file mode 100644 index 000000000..aace3b709 --- /dev/null +++ b/src/MEDCalc/gui/MEDWidgetHelperSlices.hxx @@ -0,0 +1,54 @@ +// Copyright (C) 2016 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 +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef SRC_MEDCALC_GUI_MEDWIDGETHELPERSLICES_HXX_ +#define SRC_MEDCALC_GUI_MEDWIDGETHELPERSLICES_HXX_ + +#include "MEDWidgetHelper.hxx" + +class PresentationController; + +class MEDWidgetHelperSlices: public MEDWidgetHelper +{ + Q_OBJECT + +public: + MEDWidgetHelperSlices(const PresentationController* presController, + MEDCALC::MEDPresentationManager_ptr presManager, int presId, const std::string & presName, + WidgetPresentationParameters * paramW); + virtual ~MEDWidgetHelperSlices(); + + virtual void udpateWidget(); + virtual void releaseWidget(); + + virtual std::string getPythonTag() const { return "Slices"; } + +protected slots: + void onSliceOrientationChanged(int idx); + void onNbSlicesChanged(int nbSlices); + +protected: + virtual void loadParametersFromEngine(); + +private: + int _nbSlices; + MEDCALC::MEDPresentationSliceOrientation _sliceOrientation; +}; + +#endif /* SRC_MEDCALC_GUI_MEDWIDGETHELPERSLICES_HXX_ */ diff --git a/src/MEDCalc/gui/MED_images.ts b/src/MEDCalc/gui/MED_images.ts index cd650e743..5bc3ee90b 100644 --- a/src/MEDCalc/gui/MED_images.ts +++ b/src/MEDCalc/gui/MED_images.ts @@ -64,6 +64,10 @@ workspace_save.png + + ICO_PRESENTATION_MESH_VIEW_DEFAULT + mesh24.png + ICO_PRESENTATION_SCALAR_MAP_DEFAULT scalarmap24.png @@ -89,6 +93,10 @@ pqNodeMapData24.png + + ICO_MEDPresentationMeshView_DEFAULT + mesh16.png + ICO_MEDPresentationScalarMap_DEFAULT scalarmap16.png @@ -114,6 +122,10 @@ pqNodeMapData16.png + + ICO_PRESENTATION_MESH_VIEW_MODERN + mesh24.png + ICO_PRESENTATION_SCALAR_MAP_MODERN scalarmap24.png @@ -139,6 +151,10 @@ pqNodeMapData24.png + + ICO_MEDPresentationMeshView_MODERN + mesh16.png + ICO_MEDPresentationScalarMap_MODERN scalarmap16.png @@ -164,6 +180,10 @@ pqNodeMapData16.png + + ICO_PRESENTATION_MESH_VIEW_CLASSIC + visu_mesh24.png + ICO_PRESENTATION_SCALAR_MAP_CLASSIC visu_scalars24.png @@ -189,6 +209,10 @@ visu_points24.png + + ICO_MEDPresentationMeshView_CLASSIC + visu_mesh16.png + ICO_MEDPresentationScalarMap_CLASSIC visu_scalars16.png diff --git a/src/MEDCalc/gui/MED_msg_en.ts b/src/MEDCalc/gui/MED_msg_en.ts index 73d655dfe..a3564ddd2 100644 --- a/src/MEDCalc/gui/MED_msg_en.ts +++ b/src/MEDCalc/gui/MED_msg_en.ts @@ -7,6 +7,14 @@ TITLE_PRESENTATION_PARAMETERS Presentation parameters + + LAB_PRESENTATION_MESH_VIEW + Mesh + + + TIP_PRESENTATION_MESH_VIEW + Mesh + LAB_PRESENTATION_SCALAR_MAP Scalar map @@ -67,6 +75,10 @@ MENU_PRESENTATIONS Presentations + + MEDPresentationMeshView + Mesh view + MEDPresentationScalarMap Scalar map @@ -211,6 +223,65 @@ LAB_COLOR_MAP Color map: + + + LAB_MESH_WIREFRAME + Wireframe + + + LAB_MESH_SURFACE + Surface + + + LAB_MESH_SURF_EDGES + Surface With Edges + + + LAB_DISP_MESH_MODE + Mesh display: + + + LAB_NB_CONTOURS + Number of contours: + + + LAB_NB_SLICES + Number of slices: + + + LAB_SLICE_ORIENT + Slice orientation: + + + + LAB_SLICE_NORMAL_TO_X + Normal to X + + + LAB_SLICE_NORMAL_TO_Y + Normal to Y + + + LAB_SLICE_NORMAL_TO_Z + Normal to Z + + + LAB_SLICE_NORMAL_TO_XY + Normal to XY + + + LAB_SLICE_NORMAL_TO_XZ + Normal to XZ + + + LAB_SLICE_NORMAL_TO_YZ + Normal to YZ + + + LAB_SLICE_NORMAL_TO_XYZ + Normal to XYZ + + DlgAlias diff --git a/src/MEDCalc/gui/PresentationController.cxx b/src/MEDCalc/gui/PresentationController.cxx index 9d9b7c0ba..d9ea2b2b9 100644 --- a/src/MEDCalc/gui/PresentationController.cxx +++ b/src/MEDCalc/gui/PresentationController.cxx @@ -27,11 +27,15 @@ #include "MEDPresentationManager_i.hxx" #include "XmedConsoleDriver.hxx" +#include "MEDPresentationMeshView.hxx" #include "MEDPresentationScalarMap.hxx" #include "MEDPresentationContour.hxx" +#include "MEDPresentationSlices.hxx" +#include "MEDWidgetHelperMeshView.hxx" #include "MEDWidgetHelperScalarMap.hxx" #include "MEDWidgetHelperContour.hxx" +#include "MEDWidgetHelperSlices.hxx" #include #include @@ -170,10 +174,18 @@ PresentationController::createActions() int presentationToolbarId = _salomeModule->createTool("Presentations", "PresentationToolbar"); int presentationMenuId = _salomeModule->createMenu(tr("MENU_PRESENTATIONS"), -1, 1); + label = tr("LAB_PRESENTATION_MESH_VIEW"); + tooltip = tr("TIP_PRESENTATION_MESH_VIEW"); + QString icon = tr(_getIconName("ICO_PRESENTATION_MESH_VIEW").c_str()); + int actionId; + actionId = _salomeModule->createStandardAction(label,this, SLOT(onVisualizeMeshView()),icon,tooltip); + _salomeModule->createTool(actionId, presentationToolbarId); + _salomeModule->action(actionId)->setIconVisibleInMenu(true); + _salomeModule->createMenu(actionId, presentationMenuId); + label = tr("LAB_PRESENTATION_SCALAR_MAP"); tooltip = tr("TIP_PRESENTATION_SCALAR_MAP"); - QString icon = tr(_getIconName("ICO_PRESENTATION_SCALAR_MAP").c_str()); - int actionId; + icon = tr(_getIconName("ICO_PRESENTATION_SCALAR_MAP").c_str()); actionId = _salomeModule->createStandardAction(label,this, SLOT(onVisualizeScalarMap()),icon,tooltip); _salomeModule->createTool(actionId, presentationToolbarId); _salomeModule->action(actionId)->setIconVisibleInMenu(true); @@ -319,6 +331,12 @@ PresentationController::visualize(PresentationEvent::EventType eventType) } } +void +PresentationController::onVisualizeMeshView() +{ + this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_MESH_VIEW); +} + void PresentationController::onVisualizeScalarMap() { @@ -415,6 +433,34 @@ PresentationController::getScalarBarRangePython() const return QString(); } +QString +PresentationController::getMeshModePython(const int mode) const +{ + MEDCALC::MEDPresentationMeshMode mod = static_cast(mode); + switch(mod) { + case MEDCALC::MESH_MODE_WIREFRAME: return "MEDCALC.MESH_MODE_WIREFRAME"; + case MEDCALC::MESH_MODE_SURFACE: return "MEDCALC.MESH_MODE_SURFACE"; + case MEDCALC::MESH_MODE_SURFACE_EDGES: return "MEDCALC.MESH_MODE_SURFACE_EDGES"; + } + return QString(); +} + +QString +PresentationController::getSliceOrientationPython(const int orientation) const +{ + MEDCALC::MEDPresentationSliceOrientation orient = static_cast(orientation); + switch(orient) { + case MEDCALC::SLICE_NORMAL_TO_X: return "MEDCALC.SLICE_NORMAL_TO_X"; + case MEDCALC::SLICE_NORMAL_TO_Y: return "MEDCALC.SLICE_NORMAL_TO_Y"; + case MEDCALC::SLICE_NORMAL_TO_Z: return "MEDCALC.SLICE_NORMAL_TO_Z"; + case MEDCALC::SLICE_NORMAL_TO_XY: return "MEDCALC.SLICE_NORMAL_TO_XY"; + case MEDCALC::SLICE_NORMAL_TO_XZ: return "MEDCALC.SLICE_NORMAL_TO_XZ"; + case MEDCALC::SLICE_NORMAL_TO_YZ: return "MEDCALC.SLICE_NORMAL_TO_YZ"; + case MEDCALC::SLICE_NORMAL_TO_XYZ: return "MEDCALC.SLICE_NORMAL_TO_XYZ"; + } + return QString(); +} + std::string PresentationController::getPresTypeFromWidgetHelper(int presId) const { @@ -432,7 +478,11 @@ PresentationController::processPresentationEvent(const PresentationEvent* event) QString scalarBarRange = getScalarBarRangePython(); MEDCALC::FieldHandler* fieldHandler = event->fieldHandler; QStringList commands; - if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SCALAR_MAP ) { + if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_MESH_VIEW ) { + commands += QString("presentation_id = medcalc.MakeMeshView(accessField(%1), viewMode=%2)").arg(fieldHandler->id).arg(viewMode); + commands += QString("presentation_id"); + } + else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SCALAR_MAP ) { commands += QString("presentation_id = medcalc.MakeScalarMap(accessField(%1), viewMode=%2, scalarBarRange=%3, colorMap=%4)") .arg(fieldHandler->id).arg(viewMode).arg(scalarBarRange).arg(colorMap); commands += QString("presentation_id"); @@ -446,10 +496,11 @@ PresentationController::processPresentationEvent(const PresentationEvent* event) // commands += QString("presentation_id = medcalc.MakeVectorField(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode); // commands += QString("presentation_id"); // } - // else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SLICES ) { - // commands += QString("presentation_id = medcalc.MakeSlices(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode); - // commands += QString("presentation_id"); - // } + else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SLICES ) { + commands += QString("presentation_id = medcalc.MakeSlices(accessField(%1), viewMode=%2, scalarBarRange=%3, colorMap=%4)") + .arg(fieldHandler->id).arg(viewMode).arg(scalarBarRange).arg(colorMap); + commands += QString("presentation_id"); + } // else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_DEFLECTION_SHAPE ) { // commands += QString("presentation_id = medcalc.MakeDeflectionShape(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode); // commands += QString("presentation_id"); @@ -485,6 +536,25 @@ PresentationController::processPresentationEvent(const PresentationEvent* event) commands += QString("params.nbContours = %1").arg(event->anInteger); commands += QString("medcalc.UpdateContour(%1, params)").arg(event->presentationId); } + else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_MESH_MODE ) { + std::string typ = getPresTypeFromWidgetHelper(event->presentationId); + commands += QString("params = medcalc.GetMeshViewParameters(%2)").arg(event->presentationId); + commands += QString("params.mode = %1").arg(getMeshModePython(event->anInteger)); + commands += QString("medcalc.UpdateMeshView(%1, params)").arg(event->presentationId); + } + else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_NB_SLICES ) { + std::string typ = getPresTypeFromWidgetHelper(event->presentationId); + commands += QString("params = medcalc.GetSlicesParameters(%2)").arg(event->presentationId); + commands += QString("params.nbSlices = %1").arg(event->anInteger); + commands += QString("medcalc.UpdateSlices(%1, params)").arg(event->presentationId); + } + else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_SLICE_ORIENTATION ) { + std::string typ = getPresTypeFromWidgetHelper(event->presentationId); + commands += QString("params = medcalc.GetSlicesParameters(%2)").arg(event->presentationId); + commands += QString("params.orientation = %1").arg(getSliceOrientationPython(event->anInteger)); + commands += QString("medcalc.UpdateSlices(%1, params)").arg(event->presentationId); + } + else if ( event->eventtype == PresentationEvent::EVENT_DELETE_PRESENTATION ) { commands += QString("medcalc.RemovePresentation(%1)").arg(event->presentationId); } @@ -502,25 +572,17 @@ PresentationController::findOrCreateWidgetHelper(MEDCALC::MEDPresentationManager if (it != _presHelperMap.end()) return (*it).second; MEDWidgetHelper * wh; - if (type == MEDPresentationScalarMap::TYPE_NAME) + if (type == MEDPresentationMeshView::TYPE_NAME) + wh = new MEDWidgetHelperMeshView(this, _presManager, presId, name, _widgetPresentationParameters); + else if (type == MEDPresentationScalarMap::TYPE_NAME) wh = new MEDWidgetHelperScalarMap(this, _presManager, presId, name, _widgetPresentationParameters); else if (type == MEDPresentationContour::TYPE_NAME) wh = new MEDWidgetHelperContour(this, _presManager, presId, name, _widgetPresentationParameters); + else if (type == MEDPresentationSlices::TYPE_NAME) + wh = new MEDWidgetHelperSlices(this, _presManager, presId, name, _widgetPresentationParameters); else { - // case PRES_CONTOUR: - //// break; - // case PRES_DEFLECTION: - //// break; - // case PRES_VECTOR_FIELD: - // // break; - // case PRES_POINT_SPRITE: - // // break; - // case PRES_POINT_SPRITE: - // // break; - // default: STDLOG("findOrCreateWidgetHelper(): NOT IMPLEMENTED !!!"); - } _presHelperMap[presId] = wh; return wh; diff --git a/src/MEDCalc/gui/PresentationController.hxx b/src/MEDCalc/gui/PresentationController.hxx index 98fc9ffb6..9d92c1b0a 100644 --- a/src/MEDCalc/gui/PresentationController.hxx +++ b/src/MEDCalc/gui/PresentationController.hxx @@ -62,6 +62,7 @@ signals: void presentationSignal(const PresentationEvent*); protected slots: + void onVisualizeMeshView(); void onVisualizeScalarMap(); void onVisualizeContour(); void onVisualizeVectorField(); @@ -90,6 +91,8 @@ private: QString getViewModePython() const; QString getColorMapPython() const; QString getScalarBarRangePython() const; + QString getMeshModePython(const int mode) const; + QString getSliceOrientationPython(const int orient) const; private: MEDModule* _salomeModule; diff --git a/src/MEDCalc/gui/PresentationEvent.hxx b/src/MEDCalc/gui/PresentationEvent.hxx index 784fbb314..648ebf102 100644 --- a/src/MEDCalc/gui/PresentationEvent.hxx +++ b/src/MEDCalc/gui/PresentationEvent.hxx @@ -5,6 +5,7 @@ typedef struct { enum EventType { + EVENT_VIEW_OBJECT_MESH_VIEW, EVENT_VIEW_OBJECT_CONTOUR, EVENT_VIEW_OBJECT_DEFLECTION_SHAPE, EVENT_VIEW_OBJECT_POINT_SPRITE, @@ -17,7 +18,10 @@ typedef struct { EVENT_CHANGE_COLORMAP, EVENT_CHANGE_TIME_RANGE, - EVENT_CHANGE_NB_CONTOUR + EVENT_CHANGE_MESH_MODE, + EVENT_CHANGE_NB_CONTOUR, + EVENT_CHANGE_SLICE_ORIENTATION, + EVENT_CHANGE_NB_SLICES }; EventType eventtype; diff --git a/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.cxx b/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.cxx index 4e7231b11..65238551d 100644 --- a/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.cxx +++ b/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.cxx @@ -30,10 +30,14 @@ WidgetPresentationParameters::WidgetPresentationParameters(QWidget* parent) toggleWidget(false); QObject::connect(_ui.comboBoxCompo, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboCompoIndexChanged(int)) ); + QObject::connect(_ui.comboBoxMesh, SIGNAL(currentIndexChanged(int)), + this, SLOT(onComboMeshIndexChanged(int)) ); QObject::connect(_ui.comboBoxScalarBarRange, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboScalarBarRangeIndexChanged(int)) ); QObject::connect(_ui.comboBoxColorMap, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboColorMapIndexChanged(int)) ); + QObject::connect(_ui.comboBoxSliceOrient, SIGNAL(currentIndexChanged(int)), + this, SLOT(onComboOrientIndexChanged(int)) ); QObject::connect(_ui.spinBox, SIGNAL(valueChanged(int)), this, SLOT(onSpinBoxValueChanged(int)) ); } @@ -44,6 +48,19 @@ WidgetPresentationParameters::onComboCompoIndexChanged(int idx) if (!_blockSig) emit comboCompoIndexChanged(idx); } +void +WidgetPresentationParameters::onComboOrientIndexChanged(int idx) +{ + if (!_blockSig) emit comboOrientIndexChanged(idx); +} + + +void +WidgetPresentationParameters::onComboMeshIndexChanged(int idx) +{ + if (!_blockSig) emit comboMeshIndexChanged(idx); +} + void WidgetPresentationParameters::onComboColorMapIndexChanged(int idx) { @@ -62,11 +79,21 @@ WidgetPresentationParameters::onSpinBoxValueChanged(int val) if (!_blockSig) emit spinBoxValueChanged(val); } +void +WidgetPresentationParameters::toggleCommonFieldWidget(bool show) +{ + _blockSig = true; + _ui.commonWidget->setEnabled(show); + _blockSig = false; +} + void WidgetPresentationParameters::toggleWidget(bool show) { if (!show) { + toggleCommonFieldWidget(true); + _blockSig = true; _ui.widgetDynamic->hide(); setPresName("Choose a presentation"); @@ -80,6 +107,8 @@ WidgetPresentationParameters::toggleWidget(bool show) // It is the WidgetHelper responsability to re-show the widgets it needs _ui.labelCompo->hide(); _ui.comboBoxCompo->hide(); + _ui.labelMeshMode->hide(); + _ui.comboBoxMesh->hide(); _ui.labelSpinBox->hide(); _ui.spinBox->hide(); _ui.labelSliceOrient->hide(); @@ -129,7 +158,7 @@ WidgetPresentationParameters::setNbContour(int nbContour) } // Show the widget: - _ui.labelSpinBox->setText(tr("LAB_NB_CONTOUR")); + _ui.labelSpinBox->setText(tr("LAB_NB_CONTOURS")); _ui.labelSpinBox->show(); _ui.spinBox->show(); @@ -138,11 +167,36 @@ WidgetPresentationParameters::setNbContour(int nbContour) _blockSig = false; } +void +WidgetPresentationParameters::setNbSlices(int nbSlices) +{ + if (nbSlices <= 0) + { + //TODO throw? + STDLOG("WidgetPresentationParameters::setNbSlices(): invalid number of slices!"); + } + + // Show the widget: + _ui.labelSpinBox->setText(tr("LAB_NB_SLICES")); + _ui.labelSpinBox->show(); + _ui.spinBox->show(); + + _blockSig = true; + _ui.spinBox->setValue(nbSlices); + _blockSig = false; +} + int WidgetPresentationParameters::getNbContour() const { return _ui.spinBox->value(); } +int WidgetPresentationParameters::getNbSlices() const +{ + return _ui.spinBox->value(); +} + + void WidgetPresentationParameters::setScalarBarRange(MEDCALC::MEDPresentationScalarBarRange sbrange) { @@ -165,7 +219,7 @@ WidgetPresentationParameters::setScalarBarRange(MEDCALC::MEDPresentationScalarBa void WidgetPresentationParameters::setColorMap(MEDCALC::MEDPresentationColorMap colorMap) { - int idx; + int idx = -1; if (colorMap == MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW) idx = _ui.comboBoxColorMap->findText(tr("LAB_BLUE_TO_RED")); else if (colorMap == MEDCALC::COLOR_MAP_COOL_TO_WARM) @@ -182,6 +236,131 @@ WidgetPresentationParameters::setColorMap(MEDCALC::MEDPresentationColorMap color STDLOG("Strange!! No matching found - unable to set color map in GUI."); } +void +WidgetPresentationParameters::setMeshMode(MEDCALC::MEDPresentationMeshMode mode) +{ + // Show the widget: + _ui.labelMeshMode->show(); + _ui.comboBoxMesh->show(); + + int idx; + switch(mode) + { + case MEDCALC::MESH_MODE_WIREFRAME: + idx = _ui.comboBoxMesh->findText(tr("LAB_MESH_WIREFRAME")); + break; + case MEDCALC::MESH_MODE_SURFACE: + idx = _ui.comboBoxMesh->findText(tr("LAB_MESH_SURFACE")); + break; + case MEDCALC::MESH_MODE_SURFACE_EDGES: + idx = _ui.comboBoxMesh->findText(tr("LAB_MESH_SURF_EDGES")); + break; + default: + idx = -1; + } + if (idx >= 0) + { + _blockSig = true; + _ui.comboBoxMesh->setCurrentIndex(idx); + _blockSig = false; + } + else + STDLOG("Strange!! No matching found - unable to set mesh mode in GUI."); +} + +void +WidgetPresentationParameters::setSliceOrientation(MEDCALC::MEDPresentationSliceOrientation orient) +{ + // Show the widget: + _ui.labelSliceOrient->show(); + _ui.comboBoxSliceOrient->show(); + + int idx; + switch(orient) + { + case MEDCALC::SLICE_NORMAL_TO_X: + idx = _ui.comboBoxSliceOrient->findText(tr("LAB_SLICE_NORMAL_TO_X")); + break; + case MEDCALC::SLICE_NORMAL_TO_Y: + idx = _ui.comboBoxSliceOrient->findText(tr("LAB_SLICE_NORMAL_TO_Y")); + break; + case MEDCALC::SLICE_NORMAL_TO_Z: + idx = _ui.comboBoxSliceOrient->findText(tr("LAB_SLICE_NORMAL_TO_Z")); + break; + case MEDCALC::SLICE_NORMAL_TO_XY: + idx = _ui.comboBoxSliceOrient->findText(tr("LAB_SLICE_NORMAL_TO_XY")); + break; + case MEDCALC::SLICE_NORMAL_TO_XZ: + idx = _ui.comboBoxSliceOrient->findText(tr("LAB_SLICE_NORMAL_TO_XZ")); + break; + case MEDCALC::SLICE_NORMAL_TO_YZ: + idx = _ui.comboBoxSliceOrient->findText(tr("LAB_SLICE_NORMAL_TO_YZ")); + break; + case MEDCALC::SLICE_NORMAL_TO_XYZ: + idx = _ui.comboBoxSliceOrient->findText(tr("LAB_SLICE_NORMAL_TO_XYZ")); + break; + default: + idx = -1; + } + if (idx >= 0) + { + _blockSig = true; + _ui.comboBoxSliceOrient->setCurrentIndex(idx); + _blockSig = false; + } + else + STDLOG("Strange!! No matching found - unable to set slice orientation in GUI."); +} + + +MEDCALC::MEDPresentationSliceOrientation +WidgetPresentationParameters::getSliceOrientation() const +{ + QString sbrange = _ui.comboBoxSliceOrient->currentText(); + if (sbrange == tr("LAB_SLICE_NORMAL_TO_X")) { + return MEDCALC::SLICE_NORMAL_TO_X; + } + else if (sbrange == tr("LAB_SLICE_NORMAL_TO_Y")) { + return MEDCALC::SLICE_NORMAL_TO_Y; + } + else if (sbrange == tr("LAB_SLICE_NORMAL_TO_Z")) { + return MEDCALC::SLICE_NORMAL_TO_Z; + } + else if (sbrange == tr("LAB_SLICE_NORMAL_TO_XY")) { + return MEDCALC::SLICE_NORMAL_TO_XY; + } + else if (sbrange == tr("LAB_SLICE_NORMAL_TO_XZ")) { + return MEDCALC::SLICE_NORMAL_TO_XZ; + } + else if (sbrange == tr("LAB_SLICE_NORMAL_TO_YZ")) { + return MEDCALC::SLICE_NORMAL_TO_YZ; + } + else if (sbrange == tr("LAB_SLICE_NORMAL_TO_XYZ")) { + return MEDCALC::SLICE_NORMAL_TO_XYZ; + } + // Should not happen + STDLOG("Strange!! No matching found - returning SLICE_NORMAL_TO_X."); + return MEDCALC::SLICE_NORMAL_TO_X; +} + +MEDCALC::MEDPresentationMeshMode +WidgetPresentationParameters::getMeshMode() const +{ + QString mesm = _ui.comboBoxMesh->currentText(); + if (mesm == tr("LAB_MESH_WIREFRAME")) { + return MEDCALC::MESH_MODE_WIREFRAME; + } + else if (mesm == tr("LAB_MESH_SURFACE")) { + return MEDCALC::MESH_MODE_SURFACE; + } + else if (mesm == tr("LAB_MESH_SURF_EDGES")) { + return MEDCALC::MESH_MODE_SURFACE_EDGES; + } + // Should not happen + STDLOG("Strange!! No matching found - returning MESH_MODE_WIREFRAME."); + return MEDCALC::MESH_MODE_WIREFRAME; +} + MEDCALC::MEDPresentationScalarBarRange WidgetPresentationParameters::getScalarBarRange() const @@ -231,12 +410,6 @@ WidgetPresentationParameters::getColorMap() const return MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW; } -QComboBox * -WidgetPresentationParameters::getComboBoxCompo() -{ - return _ui.comboBoxCompo; -} - void WidgetPresentationParameters::setPresName(const std::string& name) { diff --git a/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.hxx b/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.hxx index 42888a65a..530ca6478 100644 --- a/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.hxx +++ b/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.hxx @@ -42,6 +42,9 @@ public: std::string getComponent() const; void setComponents(std::vector compos, int selecIndex); + MEDCALC::MEDPresentationMeshMode getMeshMode() const; + void setMeshMode(MEDCALC::MEDPresentationMeshMode mode); + MEDCALC::MEDPresentationScalarBarRange getScalarBarRange() const; void setScalarBarRange(MEDCALC::MEDPresentationScalarBarRange); @@ -56,20 +59,31 @@ public: int getNbContour() const; void setNbContour(int nbContour); + int getNbSlices() const; + void setNbSlices(int nbSlices); + + MEDCALC::MEDPresentationSliceOrientation getSliceOrientation() const; + void setSliceOrientation(MEDCALC::MEDPresentationSliceOrientation orient); + void toggleWidget(bool show); bool isShown() const; - QComboBox * getComboBoxCompo(); + + void toggleCommonFieldWidget(bool show); signals: void comboScalarBarRangeIndexChanged(int); void comboColorMapIndexChanged(int); void comboCompoIndexChanged(int); + void comboOrientIndexChanged(int); + void comboMeshIndexChanged(int); void spinBoxValueChanged(int); private slots: void onComboScalarBarRangeIndexChanged(int); void onComboColorMapIndexChanged(int); void onComboCompoIndexChanged(int); + void onComboOrientIndexChanged(int); + void onComboMeshIndexChanged(int); void onSpinBoxValueChanged(int); private: diff --git a/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.ui b/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.ui index 85279d369..d1c47f0c2 100644 --- a/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.ui +++ b/src/MEDCalc/gui/dialogs/WidgetPresentationParameters.ui @@ -6,8 +6,8 @@ 0 0 - 439 - 359 + 784 + 584 @@ -28,7 +28,7 @@ - + @@ -54,8 +54,24 @@ + + + + + 0 + 0 + + + + LAB_RANGE + + + + + true + LAB_BLUE_TO_RED @@ -68,19 +84,6 @@ - - - - - 0 - 0 - - - - LAB_RANGE - - - @@ -95,13 +98,39 @@ + + + LAB_DISP_MESH_MODE + + + + + + + + LAB_MESH_WIREFRAME + + + + + LAB_MESH_SURFACE + + + + + LAB_MESH_SURF_EDGES + + + + + LAB_DISP_COMP - + @@ -110,17 +139,17 @@ - + LAB_SPIN_BOX - + - + Qt::Horizontal @@ -133,14 +162,14 @@ - + LAB_SLICE_ORIENT - + @@ -157,6 +186,26 @@ LAB_SLICE_NORMAL_TO_Z + + + LAB_SLICE_NORMAL_TO_XY + + + + + LAB_SLICE_NORMAL_TO_XZ + + + + + LAB_SLICE_NORMAL_TO_YZ + + + + + LAB_SLICE_NORMAL_TO_XYZ + + diff --git a/src/MEDCalc/res/presentations/classic/visu_mesh16.png b/src/MEDCalc/res/presentations/classic/visu_mesh16.png new file mode 100644 index 0000000000000000000000000000000000000000..1105b373753ad9b14d01afd7ef22615420e64099 GIT binary patch literal 330 zcmV-Q0k!^#P)R%)T1wliBsHjLo29YUXL9e#;=NNBMFI`)P$C_gXBUYWmiV; zDtp(v2|%)HOy!5K`N^iNgygAR?PjvQ?XEn@0YBaO%5_B;$Dz#M ceNBY;0lt}R<7x0#IRF3v07*qoM6N<$f~3cYbpQYW literal 0 HcmV?d00001 diff --git a/src/MEDCalc/res/presentations/classic/visu_mesh24.png b/src/MEDCalc/res/presentations/classic/visu_mesh24.png new file mode 100644 index 0000000000000000000000000000000000000000..3b3de8b4a828a5534ec47e4613938b1d8bd85be7 GIT binary patch literal 525 zcmV+o0`mQdP)a3&j1I1|Fa-CObF(K zoUFSD9>aea=wP>TVrztRp%On2$aBp2|9?K0^qwEc5{Lc8gw;>~|9?_bRKj~dT;h8S zL&W2^c}$tFFfcH%hd!75!SMV4|KH5trJsec z!#&8v@Sm@a(YU(Gn5l*zD#pUV!0`VQ!~b6fwP(T@cNwqW_n+b8f0&NYmd_0T8BO(c zO&I_G|I`=?H>z;G{&h|UhJXJU7&x!#Z7PO^731!2i#WBe{rBidFr>f6ER3|JvI9{lCWM z-*p{ks8MgU3}U`AF);D-F)=WGOVLz(4RsaYx;<|$ZFR%)T1wliBsHjLo29YUXL9e#;=NNBMFI`)P$C_gXBUYWmiV; zDtp(v2|%)HOy!5K`N^iNgygAR?PjvQ?XEn@0YBaO%5_B;$Dz#M ceNBY;0lt}R<7x0#IRF3v07*qoM6N<$f~3cYbpQYW literal 0 HcmV?d00001 diff --git a/src/MEDCalc/res/presentations/modern/mesh24.png b/src/MEDCalc/res/presentations/modern/mesh24.png new file mode 100644 index 0000000000000000000000000000000000000000..3b3de8b4a828a5534ec47e4613938b1d8bd85be7 GIT binary patch literal 525 zcmV+o0`mQdP)a3&j1I1|Fa-CObF(K zoUFSD9>aea=wP>TVrztRp%On2$aBp2|9?K0^qwEc5{Lc8gw;>~|9?_bRKj~dT;h8S zL&W2^c}$tFFfcH%hd!75!SMV4|KH5trJsec z!#&8v@Sm@a(YU(Gn5l*zD#pUV!0`VQ!~b6fwP(T@cNwqW_n+b8f0&NYmd_0T8BO(c zO&I_G|I`=?H>z;G{&h|UhJXJU7&x!#Z7PO^731!2i#WBe{rBidFr>f6ER3|JvI9{lCWM z-*p{ks8MgU3}U`AF);D-F)=WGOVLz(4RsaYx;<|$ZF0h@z-~*XzyDG|jlK3kabxJ4urN^FPKg49K!P_Lk4*ktm80gyX-8Mx(#sc|JKD z4(pq>+I=cNKq8TVy}i9LfS2d_iC8RlAvQhzYYf9K zp8E8ZU>Jt8ySqzSrsZW>)(HlKa;x2@n#~r)^Kl~@nS$b*lGW`Bj}Rhm)M~X#yWQ>r zfIXH$C=~i>CX@N&mtTCrvMj5pn(91TeHIJ^0%kUwl_{SOJ3Kt}ciL@?q9}*w`O#=J z!nd}zXg}?D5;F;VI2@ASEH5|r_xFFP>w5it06KT>+|RCEyLRTqix=J(FV|VGmxN1~ zelnOz%osvfAPa>;kYyP-fBt+w7z*00c8iiE*&FA1GnGoItE(oFJHdAu(Y%!B7|((?>7sD*G#=$_w#(*{PD$$3PK2N6biJeszf@SHso`jAfXofk2?IX<9%O#lH;(1L1uDp{gpBN+rs+EKApQ_tK?Hz0KHAGRs3sw!65+$7)b?GdxHv+}uf=ld+n8b^nR#G5y7+=Ko7 z5yx>mnx>TvUEi8LcC4e0G!92No=heM*Kr6*l2}dC{HA4n1RxMXt|*Ey(lq?&=+Ij( zmq^EUjH#)qIz^JLt*xzuqN#dk(G4B#?CyjO(>~h<<1R^3hOUeH`uaK= z4hA$A;H>nC6T)n2wkLFih^i`+{oVk_5k3k80y@ia(%jr}xl}5}N28G!A%um(VOckH z>!Ttggxtl&h2HdZbekZM6p2PmK@j|9oKvPw6 zZEY=P+ZMsk@Jce79C%66IXpZH0{}fXXp^DPrwqd^7B&io-|x5Q=jT;LQIAKW(dle9 zOSRkW@X3=oz%k6zYPE-h!GILHLM#%Anm!*jn$OP*>n~sOk|<5o>-B;tiY@>!0H6ba zMNlN^L?V&8EXxz${`=buO*8U^3l}_wq1)+n#_{`o?!?4IVE^EN>JNJTR4OIJ`S>uO z&r1&zB(O$nUGNaMR&gF6k!BEhvs7i_;2onHy z0N@A!OaK7n^Z9lT4h}(<<03 zZ!~r$Pn}xoc)ech#M}vOWo0E)EEcc#`~CZ}tn}aQ1^@sgNs_j|zh9mVh5prOG!8{k znxC4QO8I<#Jd?=)LWtxz&U5eHJ@VD7jnU*}NXld~gU>!YBR+ooq=E1?i!MjC6(=?c-ISvSi!=S1vxUTCIi$%3ksZ{-b|6gz4zWr2D zl(~F9pSCQ^+S%FJ>vY=Yty{MqfA`(fKXp2tlA scalar presentation_id = medcalc.MakeContour(accessField(0), MEDCALC.VIEW_MODE_REPLACE, colorMap=MEDCALC.COLOR_MAP_BLUE_TO_RED_RAINBOW) -sleep(2) +sleep(1) medcalc.RemovePresentation(presentation_id) -sleep(2) +sleep(1) # Field 55 = VITESSE_ELEM_DOM (ON_CELLS) -> vector field, contour should fail. try: @@ -42,4 +42,4 @@ try: sys.exit(-1); except: print "Contour failed as expected." -sleep(2) +sleep(1) diff --git a/src/MEDCalc/test/tui/mesh_view.py b/src/MEDCalc/test/tui/mesh_view.py new file mode 100644 index 000000000..6f4f7f5f8 --- /dev/null +++ b/src/MEDCalc/test/tui/mesh_view.py @@ -0,0 +1,36 @@ +# Copyright (C) 2016 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 +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +import os +from time import sleep + +import medcalc +medcalc.medconsole.setConsoleGlobals(globals()) +import MEDCALC +from medcalc.medconsole import accessField + +from medcalc_testutils import GetMEDFileDirTUI + +datafile = os.path.join(GetMEDFileDirTUI(), "smooth_surface_and_field.med") +source_id = medcalc.LoadDataSource(datafile) + +presentation_id = medcalc.MakeMeshView(accessField(0), MEDCALC.VIEW_MODE_REPLACE) +sleep(1) +medcalc.RemovePresentation(presentation_id) +sleep(1) diff --git a/src/MEDCalc/test/tui/scalar_map.py b/src/MEDCalc/test/tui/scalar_map.py index 343aa051d..004826c0d 100644 --- a/src/MEDCalc/test/tui/scalar_map.py +++ b/src/MEDCalc/test/tui/scalar_map.py @@ -31,6 +31,6 @@ datafile = os.path.join(GetMEDFileDirTUI(), "smooth_surface_and_field.med") source_id = medcalc.LoadDataSource(datafile) presentation_id = medcalc.MakeScalarMap(accessField(0), MEDCALC.VIEW_MODE_REPLACE, colorMap=MEDCALC.COLOR_MAP_BLUE_TO_RED_RAINBOW) -sleep(2) +sleep(1) medcalc.RemovePresentation(presentation_id) -sleep(2) +sleep(1) diff --git a/src/MEDCalc/test/tui/slices.py b/src/MEDCalc/test/tui/slices.py new file mode 100644 index 000000000..413a3d118 --- /dev/null +++ b/src/MEDCalc/test/tui/slices.py @@ -0,0 +1,36 @@ +# Copyright (C) 2016 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 +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +import os +from time import sleep + +import medcalc +medcalc.medconsole.setConsoleGlobals(globals()) +import MEDCALC +from medcalc.medconsole import accessField + +from medcalc_testutils import GetMEDFileDirTUI + +datafile = os.path.join(GetMEDFileDirTUI(), "agitateur.med") +source_id = medcalc.LoadDataSource(datafile) + +presentation_id = medcalc.MakeSlices(accessField(0), MEDCALC.VIEW_MODE_REPLACE, colorMap=MEDCALC.COLOR_MAP_BLUE_TO_RED_RAINBOW) +sleep(1) +medcalc.RemovePresentation(presentation_id) +sleep(1) diff --git a/src/MEDCalc/test/tui/tests.set b/src/MEDCalc/test/tui/tests.set index 112519ff0..e2cad1b1e 100644 --- a/src/MEDCalc/test/tui/tests.set +++ b/src/MEDCalc/test/tui/tests.set @@ -22,4 +22,7 @@ SET(TEST_NAMES load_file import_pvsimple # scalar_map +# contour +# slices +# mesh_view ) diff --git a/src/MEDCalc/tui/__init__.py b/src/MEDCalc/tui/__init__.py index cf4dd4ea9..a409f477b 100644 --- a/src/MEDCalc/tui/__init__.py +++ b/src/MEDCalc/tui/__init__.py @@ -39,19 +39,24 @@ from medio import LoadDataSource from medio import LoadImageAsDataSource # Presentations +from medpresentation import MakeMeshView from medpresentation import MakeScalarMap from medpresentation import MakeContour #from medpresentation import MakeVectorField -#from medpresentation import MakeSlices +from medpresentation import MakeSlices #from medpresentation import MakeDeflectionShape #from medpresentation import MakePointSprite from medpresentation import RemovePresentation +from medpresentation import GetMeshViewParameters from medpresentation import GetScalarMapParameters from medpresentation import GetContourParameters +from medpresentation import GetSlicesParameters +from medpresentation import UpdateMeshView from medpresentation import UpdateScalarMap from medpresentation import UpdateContour +from medpresentation import UpdateSlices # Console commands import medconsole diff --git a/src/MEDCalc/tui/medpresentation.py b/src/MEDCalc/tui/medpresentation.py index b59490093..c1da528a4 100644 --- a/src/MEDCalc/tui/medpresentation.py +++ b/src/MEDCalc/tui/medpresentation.py @@ -23,6 +23,21 @@ from medcalc.medevents import notifyGui_addPresentation, notifyGui_removePresent __manager = medcalc.medcorba.factory.getPresentationManager() +def MakeMeshView(proxy, + viewMode=MEDCALC.VIEW_MODE_DEFAULT, + meshMode=MEDCALC.MESH_MODE_DEFAULT): + # Create the presentation instance in CORBA engine + # The engine in turn creates the ParaView pipeline elements + params = MEDCALC.MeshViewParameters(proxy.id, meshMode) + try: + presentation_id = __manager.makeMeshView(params, viewMode) + notifyGui_addPresentation(proxy.id, presentation_id) + return presentation_id + except SALOME.SALOME_Exception as e: + notifyGui_error("An error occured while creating the mesh view:\n" + e.details.text) + raise Exception(e.details.text) + + def MakeScalarMap(proxy, viewMode=MEDCALC.VIEW_MODE_DEFAULT, displayedComponent=MEDCALC.DISPLAY_DEFAULT, @@ -42,7 +57,6 @@ def MakeScalarMap(proxy, def MakeContour(proxy, viewMode=MEDCALC.VIEW_MODE_DEFAULT, - displayedComponent=MEDCALC.DISPLAY_DEFAULT, scalarBarRange=MEDCALC.SCALAR_BAR_RANGE_DEFAULT, colorMap=MEDCALC.COLOR_MAP_DEFAULT, nbContours=MEDCALC.NB_CONTOURS_DEFAULT @@ -67,15 +81,24 @@ def MakeContour(proxy, # return presentation_id ## # -#def MakeSlices(proxy, -# viewMode=MEDCALC.VIEW_MODE_DEFAULT, -# orientation=MEDCALC.SLICE_ORIENTATION_DEFAULT, -# nbSlices=MEDCALC.NB_SLICES_DEFAULT -# ): -# params = MEDCALC.SlicesParameters(proxy.id, viewMode, orientation, nbSlices) -# presentation_id = __manager.makeSlices(params) -# notifyGui_addPresentation(proxy.id, presentation_id) -# return presentation_id +def MakeSlices(proxy, + viewMode=MEDCALC.VIEW_MODE_DEFAULT, + displayedComponent=MEDCALC.DISPLAY_DEFAULT, + scalarBarRange=MEDCALC.SCALAR_BAR_RANGE_DEFAULT, + colorMap=MEDCALC.COLOR_MAP_DEFAULT, + sliceOrientation=MEDCALC.SLICE_ORIENTATION_DEFAULT, + nbSlices=MEDCALC.NB_SLICES_DEFAULT): + # Create the presentation instance in CORBA engine + # The engine in turn creates the ParaView pipeline elements + params = MEDCALC.SlicesParameters(proxy.id, displayedComponent,scalarBarRange, colorMap, + sliceOrientation, nbSlices) + try: + presentation_id = __manager.makeSlices(params, viewMode) + notifyGui_addPresentation(proxy.id, presentation_id) + return presentation_id + except SALOME.SALOME_Exception as e: + notifyGui_error("An error occured while creating the slices:\n" + e.details.text) + raise Exception(e.details.text) ## # #def MakeDeflectionShape(proxy, @@ -105,19 +128,20 @@ def RemovePresentation(presentation_id): notifyGui_removePresentation(presentation_id) # -def GetScalarMapParameters(presentation_id): - # TODO: check that pres id is really a ScalarMap ... - params = __manager.getScalarMapParameters(presentation_id) +def GetGENERICParameters(tag, presentation_id): + exec "params = __manager.get%sParameters(presentation_id)" % tag return params -def GetContourParameters(presentation_id): - # TODO: check that pres id is really a ScalarMap ... - params = __manager.getContourParameters(presentation_id) - return params +GetMeshViewParameters = lambda pres_id: GetGENERICParameters("MeshView", pres_id) +GetScalarMapParameters = lambda pres_id: GetGENERICParameters("ScalarMap", pres_id) +GetContourParameters = lambda pres_id: GetGENERICParameters("Contour", pres_id) +GetSlicesParameters = lambda pres_id: GetGENERICParameters("Slices", pres_id) -def UpdateScalarMap(presentation_id, params): - __manager.updateScalarMap(presentation_id, params) -def UpdateContour(presentation_id, params): - __manager.updateContour(presentation_id, params) +def UpdateGENERIC(tag, presentation_id, params): + exec "__manager.update%s(presentation_id, params)" % tag +UpdateMeshView = lambda pres_id, params: UpdateGENERIC("MeshView", pres_id, params) +UpdateScalarMap = lambda pres_id, params: UpdateGENERIC("ScalarMap", pres_id, params) +UpdateContour = lambda pres_id, params: UpdateGENERIC("Contour", pres_id, params) +UpdateSlices = lambda pres_id, params: UpdateGENERIC("Slices", pres_id, params) -- 2.39.2