From ee8af898695aaeca2adc5b1cd68bb7b6d1f4d1e9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Aguerre?= Date: Tue, 26 Jan 2016 17:18:37 +0100 Subject: [PATCH] [MEDCalc] add presentations and view mode --- src/MEDCalc/cmp/MEDPresentation.cxx | 20 ++++ src/MEDCalc/cmp/MEDPresentation.hxx | 1 + src/MEDCalc/cmp/MEDPresentationContour.cxx | 23 ++++- src/MEDCalc/cmp/MEDPresentationContour.hxx | 2 +- .../cmp/MEDPresentationDeflectionShape.cxx | 11 ++- .../cmp/MEDPresentationDeflectionShape.hxx | 2 +- src/MEDCalc/cmp/MEDPresentationManager_i.txx | 6 +- .../cmp/MEDPresentationPointSprite.cxx | 11 ++- .../cmp/MEDPresentationPointSprite.hxx | 2 +- src/MEDCalc/cmp/MEDPresentationScalarMap.cxx | 29 ++---- src/MEDCalc/cmp/MEDPresentationScalarMap.hxx | 2 +- src/MEDCalc/cmp/MEDPresentationSlices.cxx | 23 ++++- src/MEDCalc/cmp/MEDPresentationSlices.hxx | 2 +- .../cmp/MEDPresentationVectorField.cxx | 11 ++- .../cmp/MEDPresentationVectorField.hxx | 2 +- src/MEDCalc/gui/CMakeLists.txt | 3 +- src/MEDCalc/gui/MEDModule.cxx | 12 ++- src/MEDCalc/gui/MEDModule.hxx | 7 +- src/MEDCalc/gui/MED_msg_en.ts | 37 ++++--- src/MEDCalc/gui/MED_msg_fr.ts | 41 +++++--- src/MEDCalc/gui/PresentationController.cxx | 97 +++++++++++++++++++ src/MEDCalc/gui/PresentationController.hxx | 47 +++++++++ src/MEDCalc/gui/WorkspaceController.cxx | 13 +-- src/MEDCalc/tui/medpresentation.py | 19 ++-- 24 files changed, 328 insertions(+), 95 deletions(-) create mode 100644 src/MEDCalc/gui/PresentationController.cxx create mode 100644 src/MEDCalc/gui/PresentationController.hxx diff --git a/src/MEDCalc/cmp/MEDPresentation.cxx b/src/MEDCalc/cmp/MEDPresentation.cxx index 222a439b3..4ae979910 100644 --- a/src/MEDCalc/cmp/MEDPresentation.cxx +++ b/src/MEDCalc/cmp/MEDPresentation.cxx @@ -104,3 +104,23 @@ std::string MEDPresentation::getFieldTypeString(MEDCoupling::TypeOfField fieldTy return ""; } } + +std::string +MEDPresentation::getRenderViewCommand(MEDCALC::MEDPresentationViewMode viewMode) +{ + std::string cmd = std::string("pvs._DisableFirstRenderCameraReset();"); + if (viewMode == MEDCALC::VIEW_MODE_OVERLAP) { + cmd += std::string("__view1 = pvs.GetActiveViewOrCreate('RenderView');"); + } else if (viewMode == MEDCALC::VIEW_MODE_REPLACE) { + cmd += std::string("__view1 = pvs.GetActiveViewOrCreate('RenderView');"); + cmd += std::string("pvs.active_objects.source and pvs.Hide(view=__view1);"); + cmd += std::string("pvs.Render();"); + } else if (viewMode == MEDCALC::VIEW_MODE_NEW_LAYOUT) { + cmd += std::string("__layout1 = pvs.servermanager.misc.ViewLayout(registrationGroup='layouts');"); + cmd += std::string("__view1 = pvs.CreateView('RenderView');"); + } else if (viewMode == MEDCALC::VIEW_MODE_SPLIT_VIEW) { + cmd += std::string("__view1 = pvs.CreateView('RenderView');"); + } + cmd += std::string("__view1.ResetCamera();"); + return cmd; +} diff --git a/src/MEDCalc/cmp/MEDPresentation.hxx b/src/MEDCalc/cmp/MEDPresentation.hxx index 91d8f88f4..480723a98 100644 --- a/src/MEDCalc/cmp/MEDPresentation.hxx +++ b/src/MEDCalc/cmp/MEDPresentation.hxx @@ -49,6 +49,7 @@ public: protected: MEDPresentation(MEDPresentation::TypeID fieldHandlerId, std::string name); + std::string getRenderViewCommand(MEDCALC::MEDPresentationViewMode viewMode); virtual void internalGeneratePipeline() = 0; PyObject * getPythonObjectFromMain(const char * var); diff --git a/src/MEDCalc/cmp/MEDPresentationContour.cxx b/src/MEDCalc/cmp/MEDPresentationContour.cxx index abd3efbca..8db627f45 100644 --- a/src/MEDCalc/cmp/MEDPresentationContour.cxx +++ b/src/MEDCalc/cmp/MEDPresentationContour.cxx @@ -1,7 +1,28 @@ #include "MEDPresentationContour.hxx" -#include "MEDFactoryClient.hxx" void MEDPresentationContour::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("__isovolume1 = pvs.IsoVolume(Input=__obj1);"); + cmd += std::string("__disp1 = pvs.Show(__isovolume1, __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();"); + + //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("__isovolume1"); + PyObject* disp = getPythonObjectFromMain("__disp1"); + pushInternal(obj, disp); + + PyGILState_Release(_gil_state); } diff --git a/src/MEDCalc/cmp/MEDPresentationContour.hxx b/src/MEDCalc/cmp/MEDPresentationContour.hxx index 9a800d783..22b9cb3f1 100644 --- a/src/MEDCalc/cmp/MEDPresentationContour.hxx +++ b/src/MEDCalc/cmp/MEDPresentationContour.hxx @@ -26,7 +26,7 @@ class MEDCALC_EXPORT MEDPresentationContour : public MEDPresentation { public: MEDPresentationContour(const MEDCALC::ContourParameters& params) : - MEDPresentation(params.fieldHandlerId, "MEDPresentationContour") + MEDPresentation(params.fieldHandlerId, "MEDPresentationContour"), _params(params) {} virtual ~MEDPresentationContour() {} diff --git a/src/MEDCalc/cmp/MEDPresentationDeflectionShape.cxx b/src/MEDCalc/cmp/MEDPresentationDeflectionShape.cxx index 491b0bc84..27a346669 100644 --- a/src/MEDCalc/cmp/MEDPresentationDeflectionShape.cxx +++ b/src/MEDCalc/cmp/MEDPresentationDeflectionShape.cxx @@ -6,19 +6,22 @@ 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);"); + cmd += std::string("__disp1 = pvs.Show(__warpByVector1, __view1);"); cmd += std::string("pvs.ColorBy(__disp1, ('") + _fieldType + std::string("', '") + _fieldName + std::string("'));"); - cmd += std::string("pvs.GetActiveViewOrCreate('RenderView').ResetCamera();"); + cmd += std::string("__disp1.SetScalarBarVisibility(__view1, True);"); cmd += std::string("__disp1.RescaleTransferFunctionToDataRangeOverTime();"); + cmd += std::string("pvs.Render();"); //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"); + PyObject* obj = getPythonObjectFromMain("__warpByVector1"); + PyObject* disp = getPythonObjectFromMain("__disp1"); pushInternal(obj, disp); PyGILState_Release(_gil_state); diff --git a/src/MEDCalc/cmp/MEDPresentationDeflectionShape.hxx b/src/MEDCalc/cmp/MEDPresentationDeflectionShape.hxx index 60278e1ba..e5a121bb7 100644 --- a/src/MEDCalc/cmp/MEDPresentationDeflectionShape.hxx +++ b/src/MEDCalc/cmp/MEDPresentationDeflectionShape.hxx @@ -26,7 +26,7 @@ class MEDCALC_EXPORT MEDPresentationDeflectionShape : public MEDPresentation { public: MEDPresentationDeflectionShape(const MEDCALC::DeflectionShapeParameters& params) : - MEDPresentation(params.fieldHandlerId, "MEDPresentationDeflectionShape") + MEDPresentation(params.fieldHandlerId, "MEDPresentationDeflectionShape"), _params(params) {} virtual ~MEDPresentationDeflectionShape() {} diff --git a/src/MEDCalc/cmp/MEDPresentationManager_i.txx b/src/MEDCalc/cmp/MEDPresentationManager_i.txx index 79eee1a5c..c315746ea 100644 --- a/src/MEDCalc/cmp/MEDPresentationManager_i.txx +++ b/src/MEDCalc/cmp/MEDPresentationManager_i.txx @@ -17,8 +17,8 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#ifndef _MED_PRESENTATION_MANAGER_I_TPP_ -#define _MED_PRESENTATION_MANAGER_I_TPP_ +#ifndef _MED_PRESENTATION_MANAGER_I_TXX_ +#define _MED_PRESENTATION_MANAGER_I_TXX_ template MEDPresentation::TypeID @@ -40,4 +40,4 @@ MEDPresentationManager_i::_makePresentation(PresentationParameters params) return newID; } -#endif // _MED_PRESENTATION_MANAGER_I_TPP_ +#endif // _MED_PRESENTATION_MANAGER_I_TXX_ diff --git a/src/MEDCalc/cmp/MEDPresentationPointSprite.cxx b/src/MEDCalc/cmp/MEDPresentationPointSprite.cxx index a65ebd82d..65134ecc5 100644 --- a/src/MEDCalc/cmp/MEDPresentationPointSprite.cxx +++ b/src/MEDCalc/cmp/MEDPresentationPointSprite.cxx @@ -6,19 +6,22 @@ MEDPresentationPointSprite::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("__disp1 = pvs.Show(__obj1);"); + cmd += std::string("__disp1 = pvs.Show(__obj1, __view1);"); cmd += std::string("pvs.ColorBy(__disp1, ('") + _fieldType + std::string("', '") + _fieldName + std::string("'));"); - cmd += std::string("pvs.GetActiveViewOrCreate('RenderView').ResetCamera();"); + cmd += std::string("__disp1.SetScalarBarVisibility(__view1, True);"); cmd += std::string("__disp1.RescaleTransferFunctionToDataRangeOverTime();"); cmd += std::string("__disp1.SetRepresentationType('Point Sprite');"); + cmd += std::string("pvs.Render();"); //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("__obj1"); - PyObject * disp = getPythonObjectFromMain("__disp1"); + PyObject* obj = getPythonObjectFromMain("__obj1"); + PyObject* disp = getPythonObjectFromMain("__disp1"); pushInternal(obj, disp); PyGILState_Release(_gil_state); diff --git a/src/MEDCalc/cmp/MEDPresentationPointSprite.hxx b/src/MEDCalc/cmp/MEDPresentationPointSprite.hxx index 2b3f081d4..066691955 100644 --- a/src/MEDCalc/cmp/MEDPresentationPointSprite.hxx +++ b/src/MEDCalc/cmp/MEDPresentationPointSprite.hxx @@ -26,7 +26,7 @@ class MEDCALC_EXPORT MEDPresentationPointSprite : public MEDPresentation { public: MEDPresentationPointSprite(const MEDCALC::PointSpriteParameters& params) : - MEDPresentation(params.fieldHandlerId, "MEDPresentationPointSprite") + MEDPresentation(params.fieldHandlerId, "MEDPresentationPointSprite"), _params(params) {} virtual ~MEDPresentationPointSprite() {} diff --git a/src/MEDCalc/cmp/MEDPresentationScalarMap.cxx b/src/MEDCalc/cmp/MEDPresentationScalarMap.cxx index 0beac00ac..58a99a553 100644 --- a/src/MEDCalc/cmp/MEDPresentationScalarMap.cxx +++ b/src/MEDCalc/cmp/MEDPresentationScalarMap.cxx @@ -3,39 +3,24 @@ void MEDPresentationScalarMap::internalGeneratePipeline() { - //MEDPresentation::TypeID fieldHandlerId = params.fieldHandlerId; - //MEDCALC::MEDPresentationViewMode viewMode = params.viewMode; - - // :TODO: consider viewMode - - /* - MEDCALC::MEDDataManager_ptr dataManager(MEDFactoryClient::getDataManager()); - MEDCALC::FieldHandler* fieldHandler = dataManager->getFieldHandler(fieldHandlerId); - - std::cout << "\tfieldHandlerId: " << fieldHandlerId << std::endl; - std::cout << "\tviewMode: " << viewMode << std::endl; - - MEDCALC::MeshHandler* meshHandler = dataManager->getMesh(fieldHandler->meshid); - MEDCALC::DatasourceHandler* dataSHandler = dataManager->getDatasourceHandlerFromID(meshHandler->sourceid); - std::cout << "\tfileName: " << dataSHandler->uri << std::endl; - std::cout << "\tfiedName: " << fieldHandler->fieldname << std::endl; - */ - 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("__disp1 = pvs.Show(__obj1);"); + cmd += std::string("__disp1 = pvs.Show(__obj1, __view1);"); cmd += std::string("pvs.ColorBy(__disp1, ('") + _fieldType + std::string("', '") + _fieldName + std::string("'));"); - cmd += std::string("pvs.GetActiveViewOrCreate('RenderView').ResetCamera();"); + cmd += std::string("__disp1.SetScalarBarVisibility(__view1, True);"); cmd += std::string("__disp1.RescaleTransferFunctionToDataRangeOverTime();"); + cmd += std::string("pvs.Render();"); //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("__obj1"); - PyObject * disp = getPythonObjectFromMain("__disp1"); + PyObject* obj = getPythonObjectFromMain("__obj1"); + PyObject* disp = getPythonObjectFromMain("__disp1"); pushInternal(obj, disp); PyGILState_Release(_gil_state); diff --git a/src/MEDCalc/cmp/MEDPresentationScalarMap.hxx b/src/MEDCalc/cmp/MEDPresentationScalarMap.hxx index d33f61026..cec568147 100644 --- a/src/MEDCalc/cmp/MEDPresentationScalarMap.hxx +++ b/src/MEDCalc/cmp/MEDPresentationScalarMap.hxx @@ -26,7 +26,7 @@ class MEDCALC_EXPORT MEDPresentationScalarMap : public MEDPresentation { public: MEDPresentationScalarMap(const MEDCALC::ScalarMapParameters& params) : - MEDPresentation(params.fieldHandlerId, "MEDPresentationScalarMap") + MEDPresentation(params.fieldHandlerId, "MEDPresentationScalarMap"), _params(params) {} virtual ~MEDPresentationScalarMap() {} diff --git a/src/MEDCalc/cmp/MEDPresentationSlices.cxx b/src/MEDCalc/cmp/MEDPresentationSlices.cxx index 164d17cfb..601bbc5ac 100644 --- a/src/MEDCalc/cmp/MEDPresentationSlices.cxx +++ b/src/MEDCalc/cmp/MEDPresentationSlices.cxx @@ -1,7 +1,28 @@ #include "MEDPresentationSlices.hxx" -#include "MEDFactoryClient.hxx" 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();"); + + //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); } diff --git a/src/MEDCalc/cmp/MEDPresentationSlices.hxx b/src/MEDCalc/cmp/MEDPresentationSlices.hxx index ebabec934..42b4dfea8 100644 --- a/src/MEDCalc/cmp/MEDPresentationSlices.hxx +++ b/src/MEDCalc/cmp/MEDPresentationSlices.hxx @@ -26,7 +26,7 @@ class MEDCALC_EXPORT MEDPresentationSlices : public MEDPresentation { public: MEDPresentationSlices(const MEDCALC::SlicesParameters& params) : - MEDPresentation(params.fieldHandlerId, "MEDPresentationSlices") + MEDPresentation(params.fieldHandlerId, "MEDPresentationSlices"), _params(params) {} virtual ~MEDPresentationSlices() {} diff --git a/src/MEDCalc/cmp/MEDPresentationVectorField.cxx b/src/MEDCalc/cmp/MEDPresentationVectorField.cxx index f8d94a5e8..d267fa694 100644 --- a/src/MEDCalc/cmp/MEDPresentationVectorField.cxx +++ b/src/MEDCalc/cmp/MEDPresentationVectorField.cxx @@ -6,19 +6,22 @@ MEDPresentationVectorField::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("__disp1 = pvs.Show(__obj1);"); + cmd += std::string("__disp1 = pvs.Show(__obj1, __view1);"); cmd += std::string("pvs.ColorBy(__disp1, ('") + _fieldType + std::string("', '") + _fieldName + std::string("'));"); - cmd += std::string("pvs.GetActiveViewOrCreate('RenderView').ResetCamera();"); + cmd += std::string("__disp1.SetScalarBarVisibility(__view1, True);"); cmd += std::string("__disp1.RescaleTransferFunctionToDataRangeOverTime();"); cmd += std::string("__disp1.SetRepresentationType('3D Glyphs');"); + cmd += std::string("pvs.Render();"); //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("__obj1"); - PyObject * disp = getPythonObjectFromMain("__disp1"); + PyObject* obj = getPythonObjectFromMain("__obj1"); + PyObject* disp = getPythonObjectFromMain("__disp1"); pushInternal(obj, disp); PyGILState_Release(_gil_state); diff --git a/src/MEDCalc/cmp/MEDPresentationVectorField.hxx b/src/MEDCalc/cmp/MEDPresentationVectorField.hxx index f67bd9b16..838af52fe 100644 --- a/src/MEDCalc/cmp/MEDPresentationVectorField.hxx +++ b/src/MEDCalc/cmp/MEDPresentationVectorField.hxx @@ -26,7 +26,7 @@ class MEDCALC_EXPORT MEDPresentationVectorField : public MEDPresentation { public: MEDPresentationVectorField(const MEDCALC::VectorFieldParameters& params) : - MEDPresentation(params.fieldHandlerId, "MEDPresentationVectorField") + MEDPresentation(params.fieldHandlerId, "MEDPresentationVectorField"), _params(params) {} virtual ~MEDPresentationVectorField() {} diff --git a/src/MEDCalc/gui/CMakeLists.txt b/src/MEDCalc/gui/CMakeLists.txt index ffad5a4aa..72e839cf4 100644 --- a/src/MEDCalc/gui/CMakeLists.txt +++ b/src/MEDCalc/gui/CMakeLists.txt @@ -31,10 +31,11 @@ SET(MEDCALCGUI_SOURCES MEDEventListener_i.cxx MEDModule.cxx DatasourceController.cxx + PresentationController.cxx factory.cxx ) -SET(MEDCALCGUI_HEADERS MEDModule.hxx MEDEventListener_i.hxx WorkspaceController.hxx DatasourceController.hxx) +SET(MEDCALCGUI_HEADERS MEDModule.hxx MEDEventListener_i.hxx WorkspaceController.hxx DatasourceController.hxx PresentationController.hxx) QT_WRAP_MOC(MEDCALCGUI_HEADERS_MOC ${MEDCALCGUI_HEADERS}) diff --git a/src/MEDCalc/gui/MEDModule.cxx b/src/MEDCalc/gui/MEDModule.cxx index 460f88ebd..50c7a4203 100644 --- a/src/MEDCalc/gui/MEDModule.cxx +++ b/src/MEDCalc/gui/MEDModule.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D +// Copyright (C) 2007-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 @@ -173,6 +173,7 @@ MEDModule::createModuleWidgets() { _workspaceController = new WorkspaceController(this); _xmedDataModel = new XmedDataModel(); _workspaceController->setDataModel(_xmedDataModel); + _presentationController = new PresentationController(this); connect(_datasourceController, SIGNAL(datasourceSignal(const DatasourceEvent *)), _workspaceController, SLOT(processDatasourceEvent(const DatasourceEvent *))); @@ -183,10 +184,9 @@ MEDModule::createModuleWidgets() { void MEDModule::createModuleActions() { - // Creating actions concerning the dataspace _datasourceController->createActions(); - // Creating actions concerning the workspace _workspaceController->createActions(); + _presentationController->createActions(); } int @@ -233,3 +233,9 @@ MEDModule::addActionInPopupMenu(int actionId,const QString& menus,const QString& mgr->insert ( this->action( actionId ), parentId, 0 ); mgr->setRule( this->action( actionId ), rule, QtxPopupMgr::VisibleRule ); } + +MEDCALC::MEDPresentationViewMode +MEDModule::getSelectedViewMode() +{ + return _presentationController->getSelectedViewMode(); +} diff --git a/src/MEDCalc/gui/MEDModule.hxx b/src/MEDCalc/gui/MEDModule.hxx index 6a64fea26..8f39391ca 100644 --- a/src/MEDCalc/gui/MEDModule.hxx +++ b/src/MEDCalc/gui/MEDModule.hxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D +// Copyright (C) 2007-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 @@ -29,9 +29,11 @@ #include "WorkspaceController.hxx" #include "XmedDataModel.hxx" #include "DatasourceController.hxx" +#include "PresentationController.hxx" #include #include CORBA_CLIENT_HEADER(MED_Gen) +#include CORBA_SERVER_HEADER(MEDPresentationManager) class SalomeApp_Application; @@ -67,6 +69,8 @@ public: const QString& tooltip=QString()); void addActionInPopupMenu(int actionId,const QString& menus="",const QString& rule="client='ObjectBrowser'"); + MEDCALC::MEDPresentationViewMode getSelectedViewMode(); + public slots: virtual bool activateModule( SUIT_Study* theStudy ); virtual bool deactivateModule( SUIT_Study* theStudy ); @@ -80,6 +84,7 @@ private: DatasourceController * _datasourceController; WorkspaceController * _workspaceController; XmedDataModel * _xmedDataModel; + PresentationController * _presentationController; static MED_ORB::MED_Gen_var myEngine; }; diff --git a/src/MEDCalc/gui/MED_msg_en.ts b/src/MEDCalc/gui/MED_msg_en.ts index c3e7b4fbb..a1c303a63 100644 --- a/src/MEDCalc/gui/MED_msg_en.ts +++ b/src/MEDCalc/gui/MED_msg_en.ts @@ -2,31 +2,42 @@ - DatasourceController + PresentationController - MEDPresentationScalarMap - Scalar map + LAB_VIEW_MODE_REPLACE + Replace - MEDPresentationContour - Contour + TIP_VIEW_MODE_REPLACE + Replace - MEDPresentationVectorField - Vector field + LAB_VIEW_MODE_OVERLAP + Overlap - MEDPresentationSlices - Slices + TIP_VIEW_MODE_OVERLAP + Overlap - MEDPresentationDeflectionShape - Deflection shape + LAB_VIEW_MODE_NEW_LAYOUT + New layout - MEDPresentationPointSprite - Point sprite + TIP_VIEW_MODE_NEW_LAYOUT + New layout + + LAB_VIEW_MODE_SPLIT_VIEW + Split + + + TIP_VIEW_MODE_SPLIT_VIEW + Split + + + + DatasourceController LAB_ADD_DATA_SOURCE diff --git a/src/MEDCalc/gui/MED_msg_fr.ts b/src/MEDCalc/gui/MED_msg_fr.ts index 3a1595300..812cfaeb2 100644 --- a/src/MEDCalc/gui/MED_msg_fr.ts +++ b/src/MEDCalc/gui/MED_msg_fr.ts @@ -2,30 +2,45 @@ - DatasourceController + PresentationController - MEDPresentationScalarMap - Carte scalaire + LAB_VIEW_MODE_REPLACE + Remplacer - MEDPresentationContour - Contour + TIP_VIEW_MODE_REPLACE + Remplacer - MEDPresentationVectorField - Champ de vecteurs + LAB_VIEW_MODE_OVERLAP + Superposer - MEDPresentationSlices - Coupes + TIP_VIEW_MODE_OVERLAP + Superposer - MEDPresentationDeflectionShape - Déformée + LAB_VIEW_MODE_NEW_LAYOUT + Nouvel onglet + + + TIP_VIEW_MODE_NEW_LAYOUT + Nouvel onglet - MEDPresentationPointSprite - Point Sprite + LAB_VIEW_MODE_SPLIT_VIEW + Scinder + + + TIP_VIEW_MODE_SPLIT_VIEW + Scinder + + + + DatasourceController + + MEDPresentationScalarMap + Carte scalaire diff --git a/src/MEDCalc/gui/PresentationController.cxx b/src/MEDCalc/gui/PresentationController.cxx new file mode 100644 index 000000000..0e0bf8441 --- /dev/null +++ b/src/MEDCalc/gui/PresentationController.cxx @@ -0,0 +1,97 @@ +// 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 "PresentationController.hxx" +#include "MEDModule.hxx" +#include "Basics_Utils.hxx" +#include "QtxActionGroup.h" + +static const int OPTIONS_VIEW_MODE_ID = 943; +static const int OPTIONS_VIEW_MODE_REPLACE_ID = 944; +static const int OPTIONS_VIEW_MODE_OVERLAP_ID = 945; +static const int OPTIONS_VIEW_MODE_NEW_LAYOUT_ID = 946; +static const int OPTIONS_VIEW_MODE_SPLIT_VIEW_ID = 947; + +PresentationController::PresentationController(MEDModule* salomeModule) +{ + STDLOG("Creating a PresentationController"); + _salomeModule = salomeModule; +} + +PresentationController::~PresentationController() +{ + STDLOG("Deleting the PresentationController"); +} + +void +PresentationController::createActions() +{ + STDLOG("Creating PresentationController actions"); + int toolbarId = _salomeModule->createTool("View Mode", "PresentationToolbar"); + + QtxActionGroup* ag = _salomeModule->createActionGroup(OPTIONS_VIEW_MODE_ID, true); + ag->setText("View mode"); + ag->setUsesDropDown(true); + + QString label = tr("LAB_VIEW_MODE_REPLACE"); + QString tooltip = tr("TIP_VIEW_MODE_REPLACE"); + QAction* a = _salomeModule->createAction(OPTIONS_VIEW_MODE_REPLACE_ID,label,QIcon(),label,tooltip,0); + a->setCheckable(true); + a->setChecked(true); + ag->add(a); + + label = tr("LAB_VIEW_MODE_OVERLAP"); + tooltip = tr("TIP_VIEW_MODE_OVERLAP"); + a = _salomeModule->createAction(OPTIONS_VIEW_MODE_OVERLAP_ID,label,QIcon(),label,tooltip,0); + a->setCheckable(true); + ag->add(a); + + label = tr("LAB_VIEW_MODE_NEW_LAYOUT"); + tooltip = tr("TIP_VIEW_MODE_NEW_LAYOUT"); + a = _salomeModule->createAction(OPTIONS_VIEW_MODE_NEW_LAYOUT_ID,label,QIcon(),label,tooltip,0); + a->setCheckable(true); + ag->add(a); + + label = tr("LAB_VIEW_MODE_SPLIT_VIEW"); + tooltip = tr("TIP_VIEW_MODE_SPLIT_VIEW"); + a = _salomeModule->createAction(OPTIONS_VIEW_MODE_SPLIT_VIEW_ID,label,QIcon(),label,tooltip,0); + a->setCheckable(true); + ag->add(a); + + _salomeModule->createTool(OPTIONS_VIEW_MODE_ID, toolbarId); + + +} + +MEDCALC::MEDPresentationViewMode +PresentationController::getSelectedViewMode() +{ + if (_salomeModule->action(OPTIONS_VIEW_MODE_REPLACE_ID)->isChecked()) { + return MEDCALC::VIEW_MODE_REPLACE; + } + else if (_salomeModule->action(OPTIONS_VIEW_MODE_OVERLAP_ID)->isChecked()) { + return MEDCALC::VIEW_MODE_OVERLAP; + } + else if (_salomeModule->action(OPTIONS_VIEW_MODE_NEW_LAYOUT_ID)->isChecked()) { + return MEDCALC::VIEW_MODE_NEW_LAYOUT; + } + else if (_salomeModule->action(OPTIONS_VIEW_MODE_SPLIT_VIEW_ID)->isChecked()) { + return MEDCALC::VIEW_MODE_SPLIT_VIEW; + } +} diff --git a/src/MEDCalc/gui/PresentationController.hxx b/src/MEDCalc/gui/PresentationController.hxx new file mode 100644 index 000000000..fbd90737f --- /dev/null +++ b/src/MEDCalc/gui/PresentationController.hxx @@ -0,0 +1,47 @@ +// 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 PRESENTATION_CONTROLLER_HXX +#define PRESENTATION_CONTROLLER_HXX + +#include +#include "MEDCALCGUI.hxx" + +#include +#include CORBA_SERVER_HEADER(MEDPresentationManager) + +class MEDModule; + +class MEDCALCGUI_EXPORT PresentationController : public QObject { + Q_OBJECT + +public: + PresentationController(MEDModule* salomeModule); + ~PresentationController(); + + void createActions(); + + MEDCALC::MEDPresentationViewMode getSelectedViewMode(); + +private: + MEDModule* _salomeModule; + +}; + +#endif /* PRESENTATION_CONTROLLER_HXX */ diff --git a/src/MEDCalc/gui/WorkspaceController.cxx b/src/MEDCalc/gui/WorkspaceController.cxx index 643bd56f1..0fc4f443f 100644 --- a/src/MEDCalc/gui/WorkspaceController.cxx +++ b/src/MEDCalc/gui/WorkspaceController.cxx @@ -463,12 +463,13 @@ void WorkspaceController::_viewItemList(QStringList itemNameIdList) { QString WorkspaceController::_getViewMode() { -#define stringify( name ) # name - - QString viewMode = stringify(MEDCALC::VIEW_MODE_NEW_LAYOUT); // :TODO: change this (get value from dedicated dialog) - viewMode.replace("::", "."); - - return viewMode; + MEDCALC::MEDPresentationViewMode viewMode = _salomeModule->getSelectedViewMode(); + switch(viewMode) { + case MEDCALC::VIEW_MODE_REPLACE: return "MEDCALC.VIEW_MODE_REPLACE"; + case MEDCALC::VIEW_MODE_OVERLAP: return "MEDCALC.VIEW_MODE_OVERLAP"; + case MEDCALC::VIEW_MODE_NEW_LAYOUT: return "MEDCALC.VIEW_MODE_NEW_LAYOUT"; + case MEDCALC::VIEW_MODE_SPLIT_VIEW: return "MEDCALC.VIEW_MODE_SPLIT_VIEW"; + } } /** diff --git a/src/MEDCalc/tui/medpresentation.py b/src/MEDCalc/tui/medpresentation.py index 7c665b505..7dd0fe946 100644 --- a/src/MEDCalc/tui/medpresentation.py +++ b/src/MEDCalc/tui/medpresentation.py @@ -26,21 +26,15 @@ __manager = medcalc.medcorba.factory.getPresentationManager() def MakeScalarMap(proxy, viewMode=MEDCALC.VIEW_MODE_REPLACE): # Create the presentation instance in CORBA engine # The engine in turn creates the ParaView pipeline elements - - print "In MakeScalarMap (Python)" - - print "viewMode:", viewMode, " [", type(viewMode), "]" - params = MEDCALC.ScalarMapParameters(proxy.id, viewMode) presentation_id = __manager.makeScalarMap(params) notifyGui_addPresentation(proxy.id, presentation_id) # def MakeContour(proxy, viewMode=MEDCALC.VIEW_MODE_REPLACE): - print "Not implemented yet" - #params = MEDCALC.ContourParameters(proxy.id, viewMode) - #presentation_id = __manager.makeContour(params) - #notifyGui_addPresentation(proxy.id, presentation_id) + params = MEDCALC.ContourParameters(proxy.id, viewMode) + presentation_id = __manager.makeContour(params) + notifyGui_addPresentation(proxy.id, presentation_id) # def MakeVectorField(proxy, viewMode=MEDCALC.VIEW_MODE_REPLACE): @@ -50,10 +44,9 @@ def MakeVectorField(proxy, viewMode=MEDCALC.VIEW_MODE_REPLACE): # def MakeSlices(proxy, viewMode=MEDCALC.VIEW_MODE_REPLACE): - print "Not implemented yet" - #params = MEDCALC.SlicesParameters(proxy.id, viewMode) - #presentation_id = __manager.makeSlices(params) - #notifyGui_addPresentation(proxy.id, presentation_id) + params = MEDCALC.SlicesParameters(proxy.id, viewMode) + presentation_id = __manager.makeSlices(params) + notifyGui_addPresentation(proxy.id, presentation_id) # def MakeDeflectionShape(proxy, viewMode=MEDCALC.VIEW_MODE_REPLACE): -- 2.39.2