Salome HOME
[MEDCalc] add presentations and view mode
authorCédric Aguerre <cedric.aguerre@edf.fr>
Tue, 26 Jan 2016 16:18:37 +0000 (17:18 +0100)
committerCédric Aguerre <cedric.aguerre@edf.fr>
Fri, 29 Jan 2016 12:40:32 +0000 (13:40 +0100)
24 files changed:
src/MEDCalc/cmp/MEDPresentation.cxx
src/MEDCalc/cmp/MEDPresentation.hxx
src/MEDCalc/cmp/MEDPresentationContour.cxx
src/MEDCalc/cmp/MEDPresentationContour.hxx
src/MEDCalc/cmp/MEDPresentationDeflectionShape.cxx
src/MEDCalc/cmp/MEDPresentationDeflectionShape.hxx
src/MEDCalc/cmp/MEDPresentationManager_i.txx
src/MEDCalc/cmp/MEDPresentationPointSprite.cxx
src/MEDCalc/cmp/MEDPresentationPointSprite.hxx
src/MEDCalc/cmp/MEDPresentationScalarMap.cxx
src/MEDCalc/cmp/MEDPresentationScalarMap.hxx
src/MEDCalc/cmp/MEDPresentationSlices.cxx
src/MEDCalc/cmp/MEDPresentationSlices.hxx
src/MEDCalc/cmp/MEDPresentationVectorField.cxx
src/MEDCalc/cmp/MEDPresentationVectorField.hxx
src/MEDCalc/gui/CMakeLists.txt
src/MEDCalc/gui/MEDModule.cxx
src/MEDCalc/gui/MEDModule.hxx
src/MEDCalc/gui/MED_msg_en.ts
src/MEDCalc/gui/MED_msg_fr.ts
src/MEDCalc/gui/PresentationController.cxx [new file with mode: 0644]
src/MEDCalc/gui/PresentationController.hxx [new file with mode: 0644]
src/MEDCalc/gui/WorkspaceController.cxx
src/MEDCalc/tui/medpresentation.py

index 222a439b3875eed356c6a972a3f923d0a0f11a40..4ae979910bedb179ffda55514cc88cd5be935621 100644 (file)
@@ -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;
+}
index 91d8f88f4d8bb7e44cff6cc6f95bc4542a1e26c6..480723a980f782d272673d4b599c909f59caba2a 100644 (file)
@@ -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);
index abd3efbcad39a90e609c8afe1a7a1ba80ded6654..8db627f45639a628cdfb8bbfa9001b921b03358b 100644 (file)
@@ -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);
 }
index 9a800d783a7885856137078d7739024c3a8b2817..22b9cb3f198b6b6b8962c262e752516db12f93a3 100644 (file)
@@ -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() {}
 
index 491b0bc847d728f86d865c48dcf6c32cfe44db28..27a3466691eb46f9998d1bdc1f1f2d2cf384bd86 100644 (file)
@@ -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);
index 60278e1ba539bb5552b246510750ffe31c6be789..e5a121bb7a4a75c7d769db118e9b340e4d58b5b9 100644 (file)
@@ -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() {}
 
index 79eee1a5c4b796d24808f6566dfbf060dda0ea5a..c315746ea00a361d30c68bff2cf5ff990a562c2b 100644 (file)
@@ -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<typename PresentationType, typename PresentationParameters>
 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_
index a65ebd82d89423019c12ac5d3b734c9d973a91d5..65134ecc5896df37d4d50aab9813c723d5c35a94 100644 (file)
@@ -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);
index 2b3f081d4ba1786e251226e9c7e9a0c3c5952ef7..0666919552d7298001215cbb78f34ebbc2c77954 100644 (file)
@@ -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() {}
 
index 0beac00ac6633b055eea35309173a9f0e6b137f5..58a99a55317fe99fb814ddbbe304e45f901f2f6f 100644 (file)
@@ -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);
index d33f610267e244b87949e844f80ef744b701b7b9..cec568147440464ff900c93cc16eb1c70d8ac642 100644 (file)
@@ -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() {}
 
index 164d17cfbe34c64586935a3d27b69fb7a7d6af7d..601bbc5ac577fd83251001c7d6b81174aaed86a4 100644 (file)
@@ -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);
 }
index ebabec934d3b1cbd9d2b09af953c3bd798b659ca..42b4dfea80dcc8b6b633c5c61b218d09dcce605d 100644 (file)
@@ -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() {}
 
index f8d94a5e8792e60e1095a116b3a6075b15af5fbe..d267fa69407a6fc439c9143631ee8178d3c71e7b 100644 (file)
@@ -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);
index f67bd9b16ab4a3ed19ebd51486b382b26ab368d3..838af52fe01e9b2d2a278dd161d60f254e11ecf8 100644 (file)
@@ -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() {}
 
index ffad5a4aa64754f52a8ddecb1a8f230824d2b688..72e839cf49cb3e70b8bb409141f4116b19ef203e 100644 (file)
@@ -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})
 
 
index 460f88ebd4c3e5ad85331f4a3239da7d8dbf5e89..50c7a4203ee0d80de81f03607fd597b8ab398184 100644 (file)
@@ -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();
+}
index 6a64fea267659ced7077f9a1502cc8d693222514..8f39391ca3dec9c988265fc1f48b1f9768729607 100644 (file)
@@ -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
 #include "WorkspaceController.hxx"
 #include "XmedDataModel.hxx"
 #include "DatasourceController.hxx"
+#include "PresentationController.hxx"
 
 #include <SALOMEconfig.h>
 #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;
 };
 
index c3e7b4fbbc7f8df147e3af3a8955556d03e3680f..a1c303a63fcc2f30b93074e54e7e9d3664729fcd 100644 (file)
@@ -2,31 +2,42 @@
 <!DOCTYPE TS>
 <TS version="2.0">
   <context>
-    <name>DatasourceController</name>
+    <name>PresentationController</name>
     <message>
-      <source>MEDPresentationScalarMap</source>
-      <translation>Scalar map</translation>
+      <source>LAB_VIEW_MODE_REPLACE</source>
+      <translation>Replace</translation>
     </message>
     <message>
-      <source>MEDPresentationContour</source>
-      <translation>Contour</translation>
+      <source>TIP_VIEW_MODE_REPLACE</source>
+      <translation>Replace</translation>
     </message>
     <message>
-      <source>MEDPresentationVectorField</source>
-      <translation>Vector field</translation>
+      <source>LAB_VIEW_MODE_OVERLAP</source>
+      <translation>Overlap</translation>
     </message>
     <message>
-      <source>MEDPresentationSlices</source>
-      <translation>Slices</translation>
+      <source>TIP_VIEW_MODE_OVERLAP</source>
+      <translation>Overlap</translation>
     </message>
     <message>
-      <source>MEDPresentationDeflectionShape</source>
-      <translation>Deflection shape</translation>
+      <source>LAB_VIEW_MODE_NEW_LAYOUT</source>
+      <translation>New layout</translation>
     </message>
     <message>
-      <source>MEDPresentationPointSprite</source>
-      <translation>Point sprite</translation>
+      <source>TIP_VIEW_MODE_NEW_LAYOUT</source>
+      <translation>New layout</translation>
     </message>
+    <message>
+      <source>LAB_VIEW_MODE_SPLIT_VIEW</source>
+      <translation>Split</translation>
+    </message>
+    <message>
+      <source>TIP_VIEW_MODE_SPLIT_VIEW</source>
+      <translation>Split</translation>
+    </message>
+  </context>
+  <context>
+    <name>DatasourceController</name>
     <message>
       <location filename="MEDCALC/gui/DatasourceController.cxx" line="45"/>
       <source>LAB_ADD_DATA_SOURCE</source>
index 3a1595300cad2ea66ab1ffd2727450ebfb5844b0..812cfaeb25bf33c54ba94dde491381cf4e1b389d 100644 (file)
@@ -2,30 +2,45 @@
 <!DOCTYPE TS>
 <TS version="2.0">
   <context>
-    <name>DatasourceController</name>
+    <name>PresentationController</name>
     <message>
-      <source>MEDPresentationScalarMap</source>
-      <translation>Carte scalaire</translation>
+      <source>LAB_VIEW_MODE_REPLACE</source>
+      <translation>Remplacer</translation>
     </message>
     <message>
-      <source>MEDPresentationContour</source>
-      <translation>Contour</translation>
+      <source>TIP_VIEW_MODE_REPLACE</source>
+      <translation>Remplacer</translation>
     </message>
     <message>
-      <source>MEDPresentationVectorField</source>
-      <translation>Champ de vecteurs</translation>
+      <source>LAB_VIEW_MODE_OVERLAP</source>
+      <translation>Superposer</translation>
     </message>
     <message>
-      <source>MEDPresentationSlices</source>
-      <translation>Coupes</translation>
+      <source>TIP_VIEW_MODE_OVERLAP</source>
+      <translation>Superposer</translation>
     </message>
     <message>
-      <source>MEDPresentationDeflectionShape</source>
-      <translation>Déformée</translation>
+      <source>LAB_VIEW_MODE_NEW_LAYOUT</source>
+      <translation>Nouvel onglet</translation>
+    </message>
+    <message>
+      <source>TIP_VIEW_MODE_NEW_LAYOUT</source>
+      <translation>Nouvel onglet</translation>
     </message>
     <message>
-      <source>MEDPresentationPointSprite</source>
-      <translation>Point Sprite</translation>
+      <source>LAB_VIEW_MODE_SPLIT_VIEW</source>
+      <translation>Scinder</translation>
+    </message>
+    <message>
+      <source>TIP_VIEW_MODE_SPLIT_VIEW</source>
+      <translation>Scinder</translation>
+    </message>
+  </context>
+  <context>
+    <name>DatasourceController</name>
+    <message>
+      <source>MEDPresentationScalarMap</source>
+      <translation>Carte scalaire</translation>
     </message>
     <message>
       <location filename="MEDCALC/gui/DatasourceController.cxx" line="45"/>
diff --git a/src/MEDCalc/gui/PresentationController.cxx b/src/MEDCalc/gui/PresentationController.cxx
new file mode 100644 (file)
index 0000000..0e0bf84
--- /dev/null
@@ -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 (file)
index 0000000..fbd9073
--- /dev/null
@@ -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 <QtGui>
+#include "MEDCALCGUI.hxx"
+
+#include <SALOMEconfig.h>
+#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 */
index 643bd56f16f53815876720e579d016b45ade9ebc..0fc4f443fa95faaa55c3fa4979c15066eee4f763 100644 (file)
@@ -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";
+  }
 }
 
 /**
index 7c665b505220a0cc7075aae54d222d3e5fd29eb1..7dd0fe9463a5f89fe1e18b27542bb88fa98d3b0b 100644 (file)
@@ -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):