From: abn Date: Thu, 4 Aug 2016 15:10:35 +0000 (+0200) Subject: [MEDCalc] Deflection shape presentation X-Git-Tag: V8_1_0b1~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9b6969c94951980dafe6f9c71b2d957d9d13dc62;p=modules%2Fmed.git [MEDCalc] Deflection shape presentation --- diff --git a/idl/MEDPresentationManager.idl b/idl/MEDPresentationManager.idl index 2d9e06634..b86b63e45 100644 --- a/idl/MEDPresentationManager.idl +++ b/idl/MEDPresentationManager.idl @@ -125,11 +125,13 @@ module MEDCALC SliceOrientationType orientation; long nbSlices; }; -// -// struct DeflectionShapeParameters { -// long fieldHandlerId; -// }; -// + + struct DeflectionShapeParameters { + long fieldHandlerId; + ScalarBarRangeType scalarBarRange; + ColorMapType colorMap; + }; + struct PointSpriteParameters { long fieldHandlerId; string displayedComponent; // DISPLAY_EUCLIDEAN_NORM or any component name @@ -147,9 +149,9 @@ module MEDCALC long makeScalarMap(in ScalarMapParameters params, in ViewModeType viewMode) raises (SALOME::SALOME_Exception); long makeContour(in ContourParameters params, in ViewModeType viewMode) raises (SALOME::SALOME_Exception); long makeVectorField(in VectorFieldParameters params, in ViewModeType viewMode) raises (SALOME::SALOME_Exception); - long makeSlices(in SlicesParameters params, in ViewModeType viewMode) raises (SALOME::SALOME_Exception); -// long makeDeflectionShape(in DeflectionShapeParameters params, in ViewModeType viewMode); - long makePointSprite(in PointSpriteParameters params, in ViewModeType viewMode); + long makeSlices(in SlicesParameters params, in ViewModeType viewMode) raises (SALOME::SALOME_Exception); + long makeDeflectionShape(in DeflectionShapeParameters params, in ViewModeType viewMode) raises (SALOME::SALOME_Exception); + long makePointSprite(in PointSpriteParameters params, in ViewModeType viewMode) raises (SALOME::SALOME_Exception); void setPresentationStringProperty(in long presId, in string propName, in string propValue); string getPresentationStringProperty(in long presId, in string propName); @@ -162,22 +164,23 @@ module MEDCALC SlicesParameters getSlicesParameters(in long presId); VectorFieldParameters getVectorFieldParameters(in long presId); PointSpriteParameters getPointSpriteParameters(in long presId); + DeflectionShapeParameters getDeflectionShapeParameters(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 updateDeflectionShape(in long presId, in DeflectionShapeParameters params); - void updatePointSprite(in long presId, in PointSpriteParameters params); + void updateMeshView(in long presId, in MeshViewParameters params) raises (SALOME::SALOME_Exception); + void updateScalarMap(in long presId, in ScalarMapParameters params) raises (SALOME::SALOME_Exception); + void updateContour(in long presId, in ContourParameters params) raises (SALOME::SALOME_Exception); + void updateVectorField(in long presId, in VectorFieldParameters params) raises (SALOME::SALOME_Exception); + void updateSlices(in long presId, in SlicesParameters params) raises (SALOME::SALOME_Exception); + void updateDeflectionShape(in long presId, in DeflectionShapeParameters params) raises (SALOME::SALOME_Exception); + void updatePointSprite(in long presId, in PointSpriteParameters params) raises (SALOME::SALOME_Exception); - boolean removePresentation(in long presId); + boolean removePresentation(in long presId) raises (SALOME::SALOME_Exception); // Helper function to keep GUI sync - boolean activateView(in long presentationId); + boolean activateView(in long presentationId) raises (SALOME::SALOME_Exception); // Low level ParaVis dump - string getParavisDump(in long presId); + string getParavisDump(in long presId) raises (SALOME::SALOME_Exception); // ViewModeType getPresentationViewMode(in long presId); diff --git a/src/MEDCalc/cmp/CMakeLists.txt b/src/MEDCalc/cmp/CMakeLists.txt index c735141c4..70c383a38 100644 --- a/src/MEDCalc/cmp/CMakeLists.txt +++ b/src/MEDCalc/cmp/CMakeLists.txt @@ -45,7 +45,7 @@ SET(COMMON_SOURCES MEDPresentationVectorField.cxx MEDPresentationSlices.cxx MEDPresentationPointSprite.cxx -# MEDPresentationDeflectionShape.cxx + MEDPresentationDeflectionShape.cxx ) SET(MEDFactoryEngine_SOURCES diff --git a/src/MEDCalc/cmp/MEDPresentationDeflectionShape.cxx b/src/MEDCalc/cmp/MEDPresentationDeflectionShape.cxx index 12a1d288a..9fab15f78 100644 --- a/src/MEDCalc/cmp/MEDPresentationDeflectionShape.cxx +++ b/src/MEDCalc/cmp/MEDPresentationDeflectionShape.cxx @@ -17,39 +17,89 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +#include "MEDPyLockWrapper.hxx" + #include "MEDPresentationDeflectionShape.hxx" +#include "MEDPresentationException.hxx" + +#include +#undef LOG // should be fixed in KERNEL - double definition +#include + +#include + +const std::string MEDPresentationDeflectionShape::TYPE_NAME = "MEDPresentationDeflectionShape"; + +MEDPresentationDeflectionShape::MEDPresentationDeflectionShape(const MEDCALC::DeflectionShapeParameters& params, + const MEDCALC::ViewModeType viewMode) : + MEDPresentation(params.fieldHandlerId, TYPE_NAME, viewMode, params.colorMap, params.scalarBarRange), _params(params) +{ +} + +void +MEDPresentationDeflectionShape::autoScale() +{ + std::ostringstream oss; + oss << "import medcalc;"; + pushAndExecPyLine(oss.str()); oss.str(""); + oss << _objVar << ".ScaleFactor = 3.0*medcalc.ComputeCellAverageSize(__srcObj0)/(" << _rangeVar + << "[1]-" << _rangeVar << "[0]);"; + pushAndExecPyLine(oss.str()); oss.str(""); +} void MEDPresentationDeflectionShape::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("__warpByVector1 = pvs.WarpByVector(Input=__obj1);"); -// cmd += std::string("__disp1 = pvs.Show(__warpByVector1, __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("__warpByVector1"); -// PyObject* disp = getPythonObjectFromMain("__disp1"); -// pushInternal(obj, disp); -// -// PyGILState_Release(_gil_state); + MEDPresentation::internalGeneratePipeline(); + + MEDPyLockWrapper lock; + + setOrCreateRenderView(); + createSource(); + + // Populate internal array of available components: + fillAvailableFieldComponents(); + if (getIntProperty(MEDPresentation::PROP_NB_COMPONENTS) <= 1) + { + const char * msg = "Deflection shape presentation does not work for scalar field!"; // this message will appear in GUI too + STDLOG(msg); + throw KERNEL::createSalomeException(msg); + } + + // Warp needs point data: + applyCellToPointIfNeeded(); + + std::ostringstream oss; + oss << _objVar << " = pvs.WarpByVector(Input=" << _srcObjVar << ");"; + pushAndExecPyLine(oss.str()); oss.str(""); + + showObject(); // to be done first so that the scale factor computation properly works + + oss << _objVar << ".Vectors = ['POINTS', '" << _fieldName << "'];"; + pushAndExecPyLine(oss.str()); oss.str(""); + + colorBy("POINTS"); + showScalarBar(); + selectColorMap(); + rescaleTransferFunction(); + + autoScale(); // to be called after transfer function so we have the range + + resetCameraAndRender(); } void MEDPresentationDeflectionShape::updatePipeline(const MEDCALC::DeflectionShapeParameters& params) { - // :TODO: + if (params.fieldHandlerId != _params.fieldHandlerId) + throw KERNEL::createSalomeException("Unexpected updatePipeline error! Mismatching fieldHandlerId!"); + + if (params.scalarBarRange != _params.scalarBarRange) + { + updateScalarBarRange(params.scalarBarRange); + autoScale(); + pushAndExecPyLine("pvs.Render();"); + } + if (params.colorMap != _params.colorMap) + updateColorMap(params.colorMap); } diff --git a/src/MEDCalc/cmp/MEDPresentationDeflectionShape.hxx b/src/MEDCalc/cmp/MEDPresentationDeflectionShape.hxx index e23be4374..f4ead11e3 100644 --- a/src/MEDCalc/cmp/MEDPresentationDeflectionShape.hxx +++ b/src/MEDCalc/cmp/MEDPresentationDeflectionShape.hxx @@ -26,16 +26,19 @@ class MEDCALC_EXPORT MEDPresentationDeflectionShape : public MEDPresentation { public: - MEDPresentationDeflectionShape(const MEDCALC::DeflectionShapeParameters& params) : - MEDPresentation(params.fieldHandlerId, "MEDPresentationDeflectionShape"), _params(params) - {} + static const std::string TYPE_NAME; + + MEDPresentationDeflectionShape(const MEDCALC::DeflectionShapeParameters& params, const MEDCALC::ViewModeType viewMode); virtual ~MEDPresentationDeflectionShape() {} void updatePipeline(const MEDCALC::DeflectionShapeParameters& params); - MEDCALC::ViewModeType getViewMode() { return _params.viewMode; } + + void getParameters(MEDCALC::DeflectionShapeParameters & params) const { params = _params; } ; + void setParameters(const MEDCALC::DeflectionShapeParameters & params) { _params = params; } ; protected: virtual void internalGeneratePipeline(); + void autoScale(); private: MEDCALC::DeflectionShapeParameters _params; diff --git a/src/MEDCalc/cmp/MEDPresentationManager_i.cxx b/src/MEDCalc/cmp/MEDPresentationManager_i.cxx index c787a16e9..9fd1a1e6a 100644 --- a/src/MEDCalc/cmp/MEDPresentationManager_i.cxx +++ b/src/MEDCalc/cmp/MEDPresentationManager_i.cxx @@ -27,7 +27,7 @@ #include "MEDPresentationContour.hxx" #include "MEDPresentationSlices.hxx" #include "MEDPresentationVectorField.hxx" -//#include "MEDPresentationDeflectionShape.hxx" +#include "MEDPresentationDeflectionShape.hxx" #include "MEDPresentationPointSprite.hxx" #include @@ -152,12 +152,12 @@ MEDPresentationManager_i::makeSlices(const MEDCALC::SlicesParameters& params, co { return _makePresentation(params, viewMode); } -// -//MEDPresentation::TypeID -//MEDPresentationManager_i::makeDeflectionShape(const MEDCALC::DeflectionShapeParameters& params) -//{ -// return _makePresentation(params); -//} + +MEDPresentation::TypeID +MEDPresentationManager_i::makeDeflectionShape(const MEDCALC::DeflectionShapeParameters& params, const MEDCALC::ViewModeType viewMode) +{ + return _makePresentation(params, viewMode); +} MEDPresentation::TypeID MEDPresentationManager_i::makePointSprite(const MEDCALC::PointSpriteParameters& params, const MEDCALC::ViewModeType viewMode) @@ -217,6 +217,15 @@ MEDPresentationManager_i::getPointSpriteParameters(MEDPresentation::TypeID prese return tmp._retn(); } +MEDCALC::DeflectionShapeParameters +MEDPresentationManager_i::getDeflectionShapeParameters(MEDPresentation::TypeID presentationID) +{ + MEDCALC::DeflectionShapeParameters p; + _getParameters(presentationID, p); + return p; +} + + void MEDPresentationManager_i::updateMeshView(MEDPresentation::TypeID presentationID, const MEDCALC::MeshViewParameters& params) { @@ -246,12 +255,12 @@ MEDPresentationManager_i::updateSlices(MEDPresentation::TypeID presentationID, c { return _updatePresentation(presentationID, params); } -// -//void -//MEDPresentationManager_i::updateDeflectionShape(MEDPresentation::TypeID presentationID, const MEDCALC::DeflectionShapeParameters& params) -//{ -// return _updatePresentation(presentationID, params); -//} + +void +MEDPresentationManager_i::updateDeflectionShape(MEDPresentation::TypeID presentationID, const MEDCALC::DeflectionShapeParameters& params) +{ + return _updatePresentation(presentationID, params); +} void MEDPresentationManager_i::updatePointSprite(MEDPresentation::TypeID presentationID, const MEDCALC::PointSpriteParameters& params) diff --git a/src/MEDCalc/cmp/MEDPresentationManager_i.hxx b/src/MEDCalc/cmp/MEDPresentationManager_i.hxx index 95fd9edf3..e984b56ed 100644 --- a/src/MEDCalc/cmp/MEDPresentationManager_i.hxx +++ b/src/MEDCalc/cmp/MEDPresentationManager_i.hxx @@ -44,7 +44,7 @@ class MEDPresentationManager_i: public POA_MEDCALC::MEDPresentationManager, MEDCALC_EXPORT MEDPresentation::TypeID makeContour(const MEDCALC::ContourParameters&, const MEDCALC::ViewModeType); MEDCALC_EXPORT MEDPresentation::TypeID makeVectorField(const MEDCALC::VectorFieldParameters&, const MEDCALC::ViewModeType); MEDCALC_EXPORT MEDPresentation::TypeID makeSlices(const MEDCALC::SlicesParameters&, const MEDCALC::ViewModeType); -// MEDCALC_EXPORT MEDPresentation::TypeID makeDeflectionShape(const MEDCALC::DeflectionShapeParameters&, const MEDCALC::ViewModeType); + MEDCALC_EXPORT MEDPresentation::TypeID makeDeflectionShape(const MEDCALC::DeflectionShapeParameters&, const MEDCALC::ViewModeType); MEDCALC_EXPORT MEDPresentation::TypeID makePointSprite(const MEDCALC::PointSpriteParameters&, const MEDCALC::ViewModeType); MEDCALC_EXPORT void setPresentationStringProperty(MEDPresentation::TypeID presentationID, const char* propName, const char* propValue); @@ -59,13 +59,14 @@ class MEDPresentationManager_i: public POA_MEDCALC::MEDPresentationManager, MEDCALC_EXPORT MEDCALC::SlicesParameters* getSlicesParameters(MEDPresentation::TypeID presentationID); MEDCALC_EXPORT MEDCALC::VectorFieldParameters getVectorFieldParameters(MEDPresentation::TypeID presentationID); MEDCALC_EXPORT MEDCALC::PointSpriteParameters* getPointSpriteParameters(MEDPresentation::TypeID presentationID); + MEDCALC_EXPORT MEDCALC::DeflectionShapeParameters getDeflectionShapeParameters(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 updateDeflectionShape(MEDPresentation::TypeID, const MEDCALC::DeflectionShapeParameters&); + MEDCALC_EXPORT void updateDeflectionShape(MEDPresentation::TypeID, const MEDCALC::DeflectionShapeParameters&); MEDCALC_EXPORT void updatePointSprite(MEDPresentation::TypeID, const MEDCALC::PointSpriteParameters&); MEDCALC_EXPORT CORBA::Boolean removePresentation(MEDPresentation::TypeID); diff --git a/src/MEDCalc/cmp/MEDPresentationVectorField.cxx b/src/MEDCalc/cmp/MEDPresentationVectorField.cxx index e17510815..d1dde7836 100644 --- a/src/MEDCalc/cmp/MEDPresentationVectorField.cxx +++ b/src/MEDCalc/cmp/MEDPresentationVectorField.cxx @@ -82,8 +82,6 @@ MEDPresentationVectorField::internalGeneratePipeline() pushAndExecPyLine(oss.str()); oss.str(""); oss << _objVar << "GlyphTransform = 'Transform2';"; // not sure this is really needed? pushAndExecPyLine(oss.str()); oss.str(""); - oss << _objVar << ".ScaleFactor = 0.1;"; - pushAndExecPyLine(oss.str()); oss.str(""); colorBy("POINTS"); showScalarBar(); diff --git a/src/MEDCalc/gui/CMakeLists.txt b/src/MEDCalc/gui/CMakeLists.txt index f968a8381..b8c67be0d 100644 --- a/src/MEDCalc/gui/CMakeLists.txt +++ b/src/MEDCalc/gui/CMakeLists.txt @@ -63,6 +63,7 @@ SET(MEDCALCGUI_HEADERS MEDWidgetHelperSlices.hxx MEDWidgetHelperPointSprite.hxx MEDWidgetHelperVectorField.hxx + MEDWidgetHelperDeflectionShape.hxx ) IF(SALOME_MED_WITH_QTTESTING) diff --git a/src/MEDCalc/gui/MEDWidgetHelperDeflectionShape.hxx b/src/MEDCalc/gui/MEDWidgetHelperDeflectionShape.hxx new file mode 100644 index 000000000..7ae5897c6 --- /dev/null +++ b/src/MEDCalc/gui/MEDWidgetHelperDeflectionShape.hxx @@ -0,0 +1,43 @@ +// 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_MEDWIDGETHELPERDEFLECTIONSHAPE_HXX_ +#define SRC_MEDCALC_GUI_MEDWIDGETHELPERDEFLECTIONSHAPE_HXX_ + +#include "MEDWidgetHelperComponent.hxx" + +class PresentationController; + +class MEDWidgetHelperDeflectionShape: public MEDWidgetHelper +{ + Q_OBJECT + +public: + MEDWidgetHelperDeflectionShape(const PresentationController* presController, + MEDCALC::MEDPresentationManager_ptr presManager, int presId, const std::string & presName, + WidgetPresentationParameters * paramW): + MEDWidgetHelper(presController, presManager, presId, presName, paramW) + {} + virtual ~MEDWidgetHelperDeflectionShape() {} + + virtual std::string getPythonTag() const { return "DeflectionShape"; } + +}; + +#endif /* SRC_MEDCALC_GUI_MEDWIDGETHELPERDEFLECTIONSHAPE_HXX_ */ diff --git a/src/MEDCalc/gui/PresentationController.cxx b/src/MEDCalc/gui/PresentationController.cxx index fe19f432e..09426d90f 100644 --- a/src/MEDCalc/gui/PresentationController.cxx +++ b/src/MEDCalc/gui/PresentationController.cxx @@ -33,7 +33,7 @@ #include "MEDPresentationSlices.hxx" #include "MEDPresentationPointSprite.hxx" #include "MEDPresentationVectorField.hxx" -//#include "MEDPresentationDeflectionShape.hxx" +#include "MEDPresentationDeflectionShape.hxx" #include "MEDWidgetHelperMeshView.hxx" #include "MEDWidgetHelperScalarMap.hxx" @@ -41,7 +41,7 @@ #include "MEDWidgetHelperSlices.hxx" #include "MEDWidgetHelperPointSprite.hxx" #include "MEDWidgetHelperVectorField.hxx" -//#include "MEDWidgetHelperDeflectionShape.hxx" +#include "MEDWidgetHelperDeflectionShape.hxx" #include #include @@ -484,6 +484,10 @@ PresentationController::processPresentationEvent(const PresentationEvent* event) QString scalarBarRange = getScalarBarRangePython(); MEDCALC::FieldHandler* fieldHandler = event->fieldHandler; QStringList commands; + + // [ABN] using event mechanism for all this is awkward? TODO: direct implementation in each + // dedicated widget helper class? + 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"); @@ -513,13 +517,13 @@ PresentationController::processPresentationEvent(const PresentationEvent* event) .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), 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"); - // [ABN] using event mechanism for this is awkward? TODO: direct implementation in each - // dedicated widget helper class? else if ( event->eventtype == PresentationEvent::EVENT_CHANGE_COMPONENT ) { std::string typ = getPresTypeFromWidgetHelper(event->presentationId); commands += QString("params = medcalc.Get%1Parameters(%2)").arg(QString::fromStdString(typ)).arg(event->presentationId); @@ -592,6 +596,8 @@ PresentationController::findOrCreateWidgetHelper(MEDCALC::MEDPresentationManager wh = new MEDWidgetHelperVectorField(this, _presManager, presId, name, _widgetPresentationParameters); else if (type == MEDPresentationPointSprite::TYPE_NAME) wh = new MEDWidgetHelperPointSprite(this, _presManager, presId, name, _widgetPresentationParameters); + else if (type == MEDPresentationDeflectionShape::TYPE_NAME) + wh = new MEDWidgetHelperDeflectionShape(this, _presManager, presId, name, _widgetPresentationParameters); else { const char * msg ="findOrCreateWidgetHelper(): NOT IMPLEMENTED !!!"; diff --git a/src/MEDCalc/test/tui/CMakeLists.txt b/src/MEDCalc/test/tui/CMakeLists.txt index 862434a7e..8a6cc20e4 100644 --- a/src/MEDCalc/test/tui/CMakeLists.txt +++ b/src/MEDCalc/test/tui/CMakeLists.txt @@ -22,6 +22,7 @@ INCLUDE(tests.set) SET(_test_files medfiles/smooth_surface_and_field.med medfiles/agitateur.med + medfiles/deplacements.med ) SET(TEST_INSTALL_DIRECTORY ${SALOME_MED_INSTALL_TEST}/MEDCalc/tui) diff --git a/src/MEDCalc/test/tui/deflection_shape.py b/src/MEDCalc/test/tui/deflection_shape.py new file mode 100644 index 000000000..3c718687c --- /dev/null +++ b/src/MEDCalc/test/tui/deflection_shape.py @@ -0,0 +1,39 @@ +# 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(), "deplacements.med") +source_id = medcalc.LoadDataSource(datafile) + +presentation_id = medcalc.MakeDeflectionShape(accessField(0), viewMode=MEDCALC.VIEW_MODE_REPLACE, + colorMap=MEDCALC.COLOR_MAP_BLUE_TO_RED_RAINBOW, + scalarBarRange=MEDCALC.SCALAR_BAR_CURRENT_TIMESTEP + ) +sleep(1) +medcalc.RemovePresentation(presentation_id) +sleep(1) diff --git a/src/MEDCalc/test/tui/medfiles/deplacements.med b/src/MEDCalc/test/tui/medfiles/deplacements.med new file mode 100644 index 000000000..ec1125f16 Binary files /dev/null and b/src/MEDCalc/test/tui/medfiles/deplacements.med differ diff --git a/src/MEDCalc/tui/__init__.py b/src/MEDCalc/tui/__init__.py index 949fadd91..7dc847e5d 100644 --- a/src/MEDCalc/tui/__init__.py +++ b/src/MEDCalc/tui/__init__.py @@ -46,7 +46,7 @@ from medpresentation import MakeVectorField from medpresentation import MakeSlices from medpresentation import MakePointSprite from medpresentation import RemovePresentation -#from medpresentation import MakeDeflectionShape +from medpresentation import MakeDeflectionShape from medpresentation import GetMeshViewParameters from medpresentation import GetScalarMapParameters @@ -54,7 +54,7 @@ from medpresentation import GetContourParameters from medpresentation import GetSlicesParameters from medpresentation import GetPointSpriteParameters from medpresentation import GetVectorFieldParameters -#from medpresentation import GetDeflectionShapeParameters +from medpresentation import GetDeflectionShapeParameters from medpresentation import UpdateMeshView from medpresentation import UpdateScalarMap @@ -62,7 +62,7 @@ from medpresentation import UpdateContour from medpresentation import UpdateSlices from medpresentation import UpdateVectorField from medpresentation import UpdatePointSprite -#from medpresentation import UpdateDeflectionShape +from medpresentation import UpdateDeflectionShape from medpresentation import ComputeCellAverageSize, GetDomainCenter, GetSliceOrigins diff --git a/src/MEDCalc/tui/medpresentation.py b/src/MEDCalc/tui/medpresentation.py index 01defc0da..ea9574ab8 100644 --- a/src/MEDCalc/tui/medpresentation.py +++ b/src/MEDCalc/tui/medpresentation.py @@ -106,17 +106,25 @@ def MakeSlices(proxy, 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, -# viewMode=MEDCALC.VIEW_MODE_DEFAULT -# ): -# params = MEDCALC.DeflectionShapeParameters(proxy.id, viewMode) -# presentation_id = __manager.makeDeflectionShape(params) -# notifyGui_addPresentation(proxy.id, presentation_id) -# return presentation_id -## -# + + +def MakeDeflectionShape(proxy, + viewMode=MEDCALC.VIEW_MODE_DEFAULT, + scalarBarRange=MEDCALC.SCALAR_BAR_RANGE_DEFAULT, + colorMap=MEDCALC.COLOR_MAP_DEFAULT + ): + # Create the presentation instance in CORBA engine + # The engine in turn creates the ParaView pipeline elements + params = MEDCALC.DeflectionShapeParameters(proxy.id, scalarBarRange, colorMap) + try: + presentation_id = __manager.makeDeflectionShape(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 deflection shape:\n" + e.details.text) + raise Exception(e.details.text) + + def MakePointSprite(proxy, viewMode=MEDCALC.VIEW_MODE_DEFAULT, displayedComponent=MEDCALC.DISPLAY_DEFAULT, @@ -150,7 +158,7 @@ GetContourParameters = lambda pres_id: __GetGENERICParameters("Contour", pres_id GetSlicesParameters = lambda pres_id: __GetGENERICParameters("Slices", pres_id) GetPointSpriteParameters = lambda pres_id: __GetGENERICParameters("PointSprite", pres_id) GetVectorFieldParameters = lambda pres_id: __GetGENERICParameters("VectorField", pres_id) -#GetDeflectionShapeParameters = lambda pres_id: __GetGENERICParameters("DeflectionShape", pres_id) +GetDeflectionShapeParameters = lambda pres_id: __GetGENERICParameters("DeflectionShape", pres_id) def __UpdateGENERIC(tag, presentation_id, params): @@ -163,7 +171,7 @@ UpdateContour = lambda pres_id, params: __UpdateGENERIC("Contour", pres_id, para UpdateSlices = lambda pres_id, params: __UpdateGENERIC("Slices", pres_id, params) UpdateVectorField = lambda pres_id, params: __UpdateGENERIC("VectorField", pres_id, params) UpdatePointSprite = lambda pres_id, params: __UpdateGENERIC("PointSprite", pres_id, params) -#UpdateDeflectionShape = lambda pres_id, params: __UpdateGENERIC("DeflectionShape", pres_id, params) +UpdateDeflectionShape = lambda pres_id, params: __UpdateGENERIC("DeflectionShape", pres_id, params) def ComputeCellAverageSize(obj): """