]> SALOME platform Git repositories - modules/med.git/commitdiff
Salome HOME
Merge remote-tracking branch 'origin/vsr/qtesting'
authorabn <adrien.bruneton@cea.fr>
Wed, 27 Jul 2016 10:12:25 +0000 (12:12 +0200)
committerabn <adrien.bruneton@cea.fr>
Wed, 27 Jul 2016 10:12:25 +0000 (12:12 +0200)
55 files changed:
CMakeLists.txt
CTestTestfileInstall.cmake
idl/MEDEventListener.idl
idl/MEDPresentationManager.idl
idl/MED_Gen.idl
src/MEDCalc/CMakeLists.txt
src/MEDCalc/MEDCalcConstants.hxx
src/MEDCalc/cmp/CMakeLists.txt
src/MEDCalc/cmp/MED.cxx
src/MEDCalc/cmp/MED.hxx
src/MEDCalc/cmp/MEDPresentation.cxx
src/MEDCalc/cmp/MEDPresentation.hxx
src/MEDCalc/cmp/MEDPresentation.txx [new file with mode: 0644]
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.cxx
src/MEDCalc/cmp/MEDPresentationManager_i.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/DatasourceController.cxx
src/MEDCalc/gui/MEDModule.cxx
src/MEDCalc/gui/MEDModule.hxx
src/MEDCalc/gui/MED_images.ts
src/MEDCalc/gui/MED_msg_en.ts
src/MEDCalc/gui/MED_msg_fr.ts
src/MEDCalc/gui/PresentationController.cxx
src/MEDCalc/gui/PresentationController.hxx
src/MEDCalc/gui/ProcessingController.cxx
src/MEDCalc/gui/WorkspaceController.cxx
src/MEDCalc/gui/XmedDataModel.cxx
src/MEDCalc/gui/XmedDataModel.hxx
src/MEDCalc/gui/dialogs/DlgChangeUnderlyingMesh.cxx
src/MEDCalc/gui/dialogs/DlgInterpolateField.cxx
src/MEDCalc/gui/dialogs/WidgetPresentationParameters.cxx
src/MEDCalc/gui/dialogs/WidgetPresentationParameters.hxx
src/MEDCalc/gui/dialogs/WidgetPresentationParameters.ui
src/MEDCalc/res/close.png [new file with mode: 0755]
src/MEDCalc/test/CMakeLists.txt
src/MEDCalc/test/CTestTestfileInstall.cmake
src/MEDCalc/test/test_qttesting.py
src/MEDCalc/tui/__init__.py
src/MEDCalc/tui/medevents.py
src/MEDCalc/tui/medio.py
src/MEDCalc/tui/medpresentation.py
src/MEDCalculator/Test/CMakeLists.txt
src/MEDCalculator/Test/CTestTestfileInstall.cmake

index 77fac8b3e68b773c3ef2634534a6456ccdd9408c..e9cda51078534062dbd073c93f6f9dd40fb4bdfd 100644 (file)
@@ -23,6 +23,9 @@ PROJECT(SalomeMED C CXX)
 
 # Ensure a proper linker behavior:
 CMAKE_POLICY(SET CMP0003 NEW)
+IF(WIN32)
+  CMAKE_POLICY(SET CMP0020 OLD) # disable automatic linking to qtmain.lib 
+ENDIF(WIN32)
 
 # Versioning
 # ===========
@@ -110,7 +113,7 @@ IF(SALOME_BUILD_GUI)
       FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui)
     ELSE()
       FIND_PACKAGE(SalomeQt5 REQUIRED)
-    ENDIF()    
+    ENDIF()
 ENDIF(SALOME_BUILD_GUI)
 
 IF(SALOME_MED_ENABLE_PYTHON)
@@ -235,7 +238,7 @@ IF(SALOME_USE_MPI)
   LIST(APPEND _${PROJECT_NAME}_exposed_targets paramedcouplingcorba paramedmemcompo)
 ENDIF()
 
-LIST(APPEND _${PROJECT_NAME}_exposed_targets 
+LIST(APPEND _${PROJECT_NAME}_exposed_targets
     medcouplingcorba medcouplingclient medcalculator MEDFactoryEngine)
 IF(SALOME_MED_ENABLE_PYTHON)
   LIST(APPEND _${PROJECT_NAME}_exposed_targets medcalculatorspython)
@@ -280,11 +283,11 @@ SET(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
 
 # Build variables that will be expanded when configuring Salome<MODULE>Config.cmake:
 IF(NOT SALOME_GUI_BUILD_WITH_QT5)
-   SALOME_CONFIGURE_PREPARE(MEDCoupling Qt4 MPI omniORB CppUnit Graphviz Doxygen Sphinx  
-                                                                       PThread Python)
- ELSE()                     
-   SALOME_CONFIGURE_PREPARE(MEDCoupling Qt5 MPI omniORB CppUnit Graphviz Doxygen Sphinx  
-                                                                       PThread Python)
+   SALOME_CONFIGURE_PREPARE(MEDCoupling Qt4 MPI omniORB CppUnit Graphviz Doxygen Sphinx
+                                                                        PThread Python)
+ ELSE()
+   SALOME_CONFIGURE_PREPARE(MEDCoupling Qt5 MPI omniORB CppUnit Graphviz Doxygen Sphinx
+                                                                        PThread Python)
 ENDIF()
 
 CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in
@@ -292,7 +295,7 @@ CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in
     INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
     PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
        KERNEL_ROOT_DIR GUI_ROOT_DIR MEDCOUPLING_ROOT_DIR QT_ROOT_DIR MPI_ROOT_DIR
-       OMNIORB_ROOT_DIR PTHREAD_ROOT_DIR SWIG_ROOT_DIR PYTHON_ROOT_DIR CPPUNIT_ROOT_DIR 
+       OMNIORB_ROOT_DIR PTHREAD_ROOT_DIR SWIG_ROOT_DIR PYTHON_ROOT_DIR CPPUNIT_ROOT_DIR
        GRAPHVIZ_ROOT_DIR DOXYGEN_ROOT_DIR SPHINX_ROOT_DIR)
 
 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
@@ -308,3 +311,8 @@ INSTALL(FILES
 # Install the export set for use with the install-tree
 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
         FILE ${PROJECT_NAME}Targets.cmake)
+
+# Application tests
+INSTALL(FILES CTestTestfileInstall.cmake
+  DESTINATION ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test
+  RENAME CTestTestfile.cmake)
index 105165093ba6ef5ce65501a1e3a27c26dcbae678..0fb26934ae4384fc1ab870b2dcc172f0bde1639c 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2015-2016  CEA/DEN, EDF R&D
+# 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
@@ -17,6 +17,8 @@
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
-SET(SALOME_TEST_DRIVER "$ENV{ABSOLUTE_APPLI_PATH}/bin/salome/appliskel/salome_test_driver.py")
-SET(SALOME_TEST_DRIVER_GUI "$ENV{ABSOLUTE_APPLI_PATH}/bin/salome/appliskel/salome_test_driver_gui.py")
+SET(COMPONENT_NAME MEDCALC)
+SET(TIMEOUT        300)
+
+SUBDIRS(MEDCalculator)
 SUBDIRS(MEDCalc)
index 77fcc8fa3e114c33e2e6e2dfc475f35a7bb8147e..97a84d6f1e178ec826efd2711d3e1836eb99dd89 100644 (file)
@@ -34,6 +34,7 @@ module MEDCALC
     EVENT_CLEAN_WORKSPACE,
     EVENT_ADD_DATASOURCE,
     EVENT_ADD_PRESENTATION,
+    EVENT_REMOVE_PRESENTATION,
     EVENT_PLAY_TEST,
     EVENT_QUIT_SALOME,
     EVENT_UNKNOWN
index d108a917e7c87c91dd4f8985056d062e627fdfa4..c3e100225381634171c8dcb7ca63d8ba505220bf 100644 (file)
@@ -132,6 +132,19 @@ module MEDCALC
     void setPresentationProperty(in long presId, in string propName, in string propValue);
     string getPresentationProperty(in long presId, in string propName);
 
+    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);
+
+    boolean removePresentation(in long presId);
+
+    // Helper functions to keep GUI sync
+    boolean activateView(in long presentationId);
+
+    MEDPresentationViewMode getPresentationViewMode(in long presId);
   };
 
 };
index 84589339c5daf1036daa01f2051da668894a84d9..21df0b93374d867cc8eee8fd69501dd57e7aa0c0 100644 (file)
@@ -34,6 +34,8 @@ module MED_ORB
     OP_ERROR                 //!< ERROR: other problems
   };
 
+  typedef sequence<long> PresentationsList;
+
   interface
   MED_Gen : Engines::EngineComponent
   {
@@ -44,8 +46,18 @@ module MED_ORB
     status registerPresentation(in SALOMEDS::Study study,
                                 in long fieldId,
                                 in string name,
-                                in string label)
+                                in string label,
+                                in long presentationId)
+      raises (SALOME::SALOME_Exception);
+
+    status unregisterPresentation(in SALOMEDS::Study study,
+                                  in long presentationId)
       raises (SALOME::SALOME_Exception);
+
+    PresentationsList getSiblingPresentations(in SALOMEDS::Study study,
+                                              in long presentationId)
+      raises (SALOME::SALOME_Exception);
+
   };
 };
 
index d6a1e4d3a8a25ec13c97dbbbe8ff04decc4a6687..560ecadd9b65a4c9b46fdd9a4c1424ecc2546d10 100644 (file)
@@ -23,10 +23,10 @@ ADD_SUBDIRECTORY(res)
 IF(SALOME_BUILD_GUI)
   ADD_SUBDIRECTORY(gui)
 
-  IF(SALOME_MED_WITH_QTTESTING)  
+  IF(SALOME_MED_WITH_QTTESTING)
     ADD_SUBDIRECTORY(test)
   ENDIF()
-  
+
 ENDIF()
 
 IF(SALOME_MED_ENABLE_PYTHON)
index 995cb149b149454cd3fbefb6f31802a3b1a2f77b..2023db6d7986d89c7c3f48c0290308ba08ba6e37 100644 (file)
 
 // This constant strings are used to specify an attribute name for
 // AttributeParameter attributes associated to a SObject
-#define OBJECT_ID              "objectid"
-#define OBJECT_IS_IN_WORKSPACE "isInWorkspace"
+#define IS_IN_WORKSPACE  "isInWorkspace"
+#define SOURCE_ID        "sourceId"
+#define MESH_ID          "meshId"
+#define FIELD_SERIES_ID  "fieldSeriesId"
+#define FIELD_ID         "fieldId"
+#define PRESENTATION_ID  "presentationId"
+#define IS_PRESENTATION  "isPresentation"
+
 
 static const int NB_TYPE_OF_FIELDS = 4;
 static const char* mapTypeOfFieldLabel[NB_TYPE_OF_FIELDS] =
   {"ON_CELLS", "ON_NODES", "ON_GAUSS_PT", "ON_GAUSS_NE" };
-
-
-// Used by presentations
-#define FIELD_ID "fieldid"
-#define IS_PRESENTATION "ispresentation"
index 7ae135aa37296dbe2babf5e94eda61b5f26bf87b..63415add6e5c2ee18715fc1ca79656d4c6395f53 100644 (file)
@@ -29,6 +29,7 @@ INCLUDE_DIRECTORIES(
   ${CMAKE_CURRENT_BINARY_DIR}
   ${CMAKE_CURRENT_SOURCE_DIR}/..
   ${PROJECT_BINARY_DIR}/idl
+  ${GUI_INCLUDE_DIRS}  # For PyLockWrapper 
 )
 
 SET(COMMON_SOURCES
@@ -68,6 +69,7 @@ SET(COMMON_LIBS
   ${OMNIORB_LIBRARIES}
   ${PYTHON_LIBRARIES}
   ${MEDCoupling_medcoupling} ${MEDCoupling_medloader} ${MEDCoupling_medcouplingremapper}
+  ${GUI_PyInterp}
 )
 
 # This undefines the macros MIN and MAX which are specified in the windows headers
index 6eae6c580fdec128a65011e94ca76c7f900c78ae..99b6976c6a07e0c4f55d4395e7af546b4494aef1 100644 (file)
 
 #include <SALOMEDS_SObject.hxx>
 #include <Utils_ExceptHandlers.hxx>
+#include <SALOME_LifeCycleCORBA.hxx>
+#include <SALOME_NamingService.hxx>
 
 #include <string>
+#include <sstream>
 
 /*!
   \brief Constructor
@@ -64,9 +67,6 @@ MED::addDatasourceToStudy(SALOMEDS::Study_ptr study,
   // set exception handler to catch unexpected CORBA exceptions
   Unexpect aCatch(SALOME_SalomeException);
 
-  // set result status to error initially
-  MED_ORB::status result = MED_ORB::OP_ERROR;
-
   // check if reference to study is valid
   if (!CORBA::is_nil(study)) {
     // get full object path
@@ -103,7 +103,7 @@ MED::addDatasourceToStudy(SALOMEDS::Study_ptr study,
       soDatasource->SetAttrString("AttributePixMap", "ICO_DATASOURCE");
       anAttr = studyBuilder->FindOrCreateAttribute(soDatasource, "AttributeParameter");
       aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
-      aParam->SetInt(OBJECT_ID, datasourceHandler.id);
+      aParam->SetInt(SOURCE_ID, datasourceHandler.id);
       useCaseBuilder->AppendTo(soDatasource->GetFather(), soDatasource);
 
       // We can add the meshes as children of the datasource
@@ -117,10 +117,8 @@ MED::addDatasourceToStudy(SALOMEDS::Study_ptr study,
         soMesh->SetAttrString("AttributePixMap", "ICO_DATASOURCE_MESH");
         anAttr = studyBuilder->FindOrCreateAttribute(soMesh, "AttributeParameter");
         aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
-        aParam->SetInt(OBJECT_ID, meshHandler.id);
-        anAttr = studyBuilder->FindOrCreateAttribute(soMesh, "AttributeParameter");
-        aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
-        aParam->SetBool(OBJECT_IS_IN_WORKSPACE, false);
+        aParam->SetInt(MESH_ID, meshHandler.id);
+        aParam->SetBool(IS_IN_WORKSPACE, false);
         useCaseBuilder->AppendTo(soMesh->GetFather(), soMesh);
 
         // We add the field timeseries defined on this mesh, as children of the mesh SObject
@@ -138,10 +136,9 @@ MED::addDatasourceToStudy(SALOMEDS::Study_ptr study,
           soFieldseries->SetAttrString("AttributePixMap", "ICO_DATASOURCE_FIELD");
           anAttr = studyBuilder->FindOrCreateAttribute(soFieldseries, "AttributeParameter");
           aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
-          aParam->SetInt(OBJECT_ID, fieldseriesHandler.id);
-          anAttr = studyBuilder->FindOrCreateAttribute(soFieldseries, "AttributeParameter");
-          aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
-          aParam->SetBool(OBJECT_IS_IN_WORKSPACE, false);
+          aParam->SetInt(FIELD_SERIES_ID, fieldseriesHandler.id);
+          //aParam->SetInt(FIELD_ID, fieldseriesHandler.id);
+          aParam->SetBool(IS_IN_WORKSPACE, false);
 
           useCaseBuilder->AppendTo(soFieldseries->GetFather(), soFieldseries);
           soFieldseries->UnRegister();
@@ -155,22 +152,19 @@ MED::addDatasourceToStudy(SALOMEDS::Study_ptr study,
     }
   }
 
-  result = MED_ORB::OP_OK;
-  return result;
+  return MED_ORB::OP_OK;
 }
 
 MED_ORB::status
 MED::registerPresentation(SALOMEDS::Study_ptr study,
                           CORBA::Long fieldId,
                           const char* name,
-                          const char* label)
+                          const char* label,
+                          CORBA::Long presentationId)
 {
   // set exception handler to catch unexpected CORBA exceptions
   Unexpect aCatch(SALOME_SalomeException);
 
-  // set result status to error initially
-  MED_ORB::status result = MED_ORB::OP_ERROR;
-
   if (_fieldSeriesEntries.find(fieldId) == _fieldSeriesEntries.end()) {
     std::cerr << "Field not found\n";
     return MED_ORB::OP_ERROR ;
@@ -181,7 +175,7 @@ MED::registerPresentation(SALOMEDS::Study_ptr study,
 
   if (soFieldseries->IsNull()) {
     std::cerr << "Entry not found\n";
-    return  MED_ORB::OP_ERROR;
+    return MED_ORB::OP_ERROR;
   }
 
   SALOMEDS::StudyBuilder_var studyBuilder = study->NewBuilder();
@@ -198,9 +192,90 @@ MED::registerPresentation(SALOMEDS::Study_ptr study,
   aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
   aParam->SetInt(FIELD_ID, fieldId);
   aParam->SetBool(IS_PRESENTATION, true);
+  aParam->SetInt(PRESENTATION_ID, presentationId);
 
-  result = MED_ORB::OP_OK;
-  return result;
+  return MED_ORB::OP_OK;
+}
+
+MED_ORB::status
+MED::unregisterPresentation(SALOMEDS::Study_ptr study,
+                            CORBA::Long presentationId)
+{
+  // set exception handler to catch unexpected CORBA exceptions
+  Unexpect aCatch(SALOME_SalomeException);
+
+  SALOMEDS::StudyBuilder_var studyBuilder = study->NewBuilder();
+  SALOMEDS::UseCaseBuilder_var useCaseBuilder = study->GetUseCaseBuilder();
+
+  SALOMEDS::GenericAttribute_var anAttribute;
+  SALOMEDS::SComponent_var father = study->FindComponent("MED");
+  SALOMEDS::ChildIterator_var it = study->NewChildIterator(father);
+  for (it->InitEx(true); it->More(); it->Next()) {
+    SALOMEDS::SObject_var child(it->Value());
+
+    if (child->FindAttribute(anAttribute, "AttributeParameter")) {
+      SALOMEDS::AttributeParameter_var attrParam = SALOMEDS::AttributeParameter::_narrow(anAttribute);
+      if (!attrParam->IsSet(IS_PRESENTATION, PT_BOOLEAN) || !attrParam->GetBool(IS_PRESENTATION) || !attrParam->IsSet(PRESENTATION_ID, PT_INTEGER))
+        continue;
+
+      if (presentationId == attrParam->GetInt(PRESENTATION_ID)) {
+        // remove object from study
+        studyBuilder->RemoveObjectWithChildren(child);
+        // remove object from use case tree
+        useCaseBuilder->Remove(child);
+      }
+    }
+  }
+
+  return MED_ORB::OP_OK;
+}
+
+MED_ORB::PresentationsList*
+MED::getSiblingPresentations(SALOMEDS::Study_ptr study, CORBA::Long presentationId)
+{
+  // set exception handler to catch unexpected CORBA exceptions
+  Unexpect aCatch(SALOME_SalomeException);
+
+  MED_ORB::PresentationsList* presList = new MED_ORB::PresentationsList;
+
+  SALOMEDS::StudyBuilder_var studyBuilder = study->NewBuilder();
+  SALOMEDS::UseCaseBuilder_var useCaseBuilder = study->GetUseCaseBuilder();
+
+  SALOMEDS::GenericAttribute_var anAttribute;
+  SALOMEDS::SComponent_var father = study->FindComponent("MED");
+  SALOMEDS::ChildIterator_var it = study->NewChildIterator(father);
+  for (it->InitEx(true); it->More(); it->Next()) {
+    SALOMEDS::SObject_var child(it->Value());
+
+    if (child->FindAttribute(anAttribute, "AttributeParameter")) {
+      SALOMEDS::AttributeParameter_var attrParam = SALOMEDS::AttributeParameter::_narrow(anAttribute);
+      if (!attrParam->IsSet(IS_PRESENTATION, PT_BOOLEAN) || !attrParam->GetBool(IS_PRESENTATION) || !attrParam->IsSet(PRESENTATION_ID, PT_INTEGER))
+        continue;
+
+      if (presentationId == attrParam->GetInt(PRESENTATION_ID)) {
+        // get siblings
+        SALOMEDS::ChildIterator_var siblItr = study->NewChildIterator(child->GetFather());
+        for (siblItr->InitEx(true); siblItr->More(); siblItr->Next()) {
+          SALOMEDS::SObject_var sibl(siblItr->Value());
+
+          if (sibl->FindAttribute(anAttribute, "AttributeParameter")) {
+            SALOMEDS::AttributeParameter_var attrParam = SALOMEDS::AttributeParameter::_narrow(anAttribute);
+            if (!attrParam->IsSet(IS_PRESENTATION, PT_BOOLEAN) || !attrParam->GetBool(IS_PRESENTATION) || !attrParam->IsSet(PRESENTATION_ID, PT_INTEGER))
+              continue;
+
+            if (attrParam->GetInt(PRESENTATION_ID) != presentationId) {
+              CORBA::ULong size = presList->length();
+              presList->length(size+1);
+              (*presList)[size] = attrParam->GetInt(PRESENTATION_ID);
+            }
+          }
+        }
+        return presList;
+      }
+    }
+  }
+
+  return presList;
 }
 
 Engines::TMPFile*
@@ -242,6 +317,80 @@ MED::DumpPython(CORBA::Object_ptr theStudy,
   return aStreamFile._retn();
 }
 
+CORBA::Boolean
+MED::hasObjectInfo()
+{
+  return true;
+}
+
+char*
+MED::getObjectInfo(CORBA::Long studyId, const char* entry)
+{
+  SALOME_LifeCycleCORBA lcc;
+  CORBA::Object_var aSMObject = lcc.namingService()->Resolve( "/myStudyManager" );
+  SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow( aSMObject );
+  SALOMEDS::Study_var aStudy = aStudyManager->GetStudyByID( studyId );
+  SALOMEDS::SObject_var aSObj = aStudy->FindObjectID( entry );
+  SALOMEDS::SObject_var aResultSObj;
+  if (aSObj->ReferencedObject(aResultSObj))
+    aSObj = aResultSObj;
+
+  if (aSObj->_is_nil())
+    return CORBA::string_dup("unknown");
+
+  SALOMEDS::GenericAttribute_var anAttribute;
+
+  std::string name("unknown");
+  if (aSObj->FindAttribute(anAttribute, "AttributeName")) {
+    SALOMEDS::AttributeName_var attrName = SALOMEDS::AttributeName::_narrow(anAttribute);
+    name = std::string(attrName->Value());
+  }
+
+  bool isInWorkspace = false;
+  //bool isPresentation = false;
+  int sourceId = -1;
+  int meshId = -1;
+  int fieldSeriesId = -1;
+  int fieldId = -1;
+  int presentationId = -1;
+  if (aSObj->FindAttribute(anAttribute, "AttributeParameter")) {
+    SALOMEDS::AttributeParameter_var attrParam = SALOMEDS::AttributeParameter::_narrow(anAttribute);
+    if (attrParam->IsSet(IS_IN_WORKSPACE, PT_BOOLEAN))
+      isInWorkspace = attrParam->GetBool(IS_IN_WORKSPACE);
+    //if (attrParam->IsSet(IS_PRESENTATION, PT_BOOLEAN))
+    //  isPresentation = attrParam->GetBool(IS_PRESENTATION);
+    if (attrParam->IsSet(SOURCE_ID, PT_INTEGER))
+      sourceId = attrParam->GetInt(SOURCE_ID);
+    if (attrParam->IsSet(MESH_ID, PT_INTEGER))
+      meshId = attrParam->GetInt(MESH_ID);
+    if (attrParam->IsSet(FIELD_SERIES_ID, PT_INTEGER))
+      fieldSeriesId = attrParam->GetInt(FIELD_SERIES_ID);
+    if (attrParam->IsSet(FIELD_ID, PT_INTEGER))
+      fieldId = attrParam->GetInt(FIELD_ID);
+    if (attrParam->IsSet(PRESENTATION_ID, PT_INTEGER))
+      presentationId = attrParam->GetInt(PRESENTATION_ID);
+  }
+
+  if (!aSObj->_is_nil() )
+    aSObj->UnRegister();
+
+  std::ostringstream oss;
+  if (sourceId > -1)
+    oss << "Source id: " << sourceId << std::endl;
+  if (meshId > -1)
+    oss << "Mesh id: " << meshId << std::endl;
+  if (fieldSeriesId > -1)
+    oss << "Field series id: " << fieldSeriesId << std::endl;
+  if (fieldId > -1)
+    oss << "Field id: " << fieldId << std::endl;
+  //oss << "Is presentation: " << isPresentation << std::endl;
+  if (presentationId > -1)
+    oss << "Presentation id: " << presentationId << std::endl;
+  oss << "Is in workspace: " << isInWorkspace << std::endl;
+
+  return CORBA::string_dup(oss.str().c_str());
+}
+
 extern "C"
 {
   /*!
index 449049b0befb30db74fbcc04615f814f6dd94924..ddd373a7696924a51e0c47d5c525203f565d937c 100644 (file)
@@ -58,7 +58,15 @@ public:
   MED_ORB::status registerPresentation(SALOMEDS::Study_ptr study,
                                        CORBA::Long fieldId,
                                        const char* name,
-                                       const char* label);
+                                       const char* label,
+                                       CORBA::Long presentationId);
+
+  MED_ORB::status unregisterPresentation(SALOMEDS::Study_ptr study,
+                                         CORBA::Long presentationId);
+
+  // Caller owns the returned list, and is responsible for the list deletion.
+  MED_ORB::PresentationsList* getSiblingPresentations(SALOMEDS::Study_ptr study,
+                                                      CORBA::Long presentationId);
 
   /*! Dump the study as a Python file */
   virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
@@ -66,6 +74,10 @@ public:
                                        CORBA::Boolean isMultiFile,
                                        CORBA::Boolean& isValidScript);
 
+  // For tooltips
+  virtual CORBA::Boolean hasObjectInfo();
+  virtual char* getObjectInfo(CORBA::Long studyId, const char* entry);
+
  private:
   std::map<long, std::string> _fieldSeriesEntries;
 };
index 24d36c5a6bc78a9836aaffb8784b56cce69f332b..48305be826ccb315fcda4adcfdbef4c0c288bc16 100644 (file)
 #include "MEDPresentation.hxx"
 #include "MEDPresentationException.hxx"
 #include "MEDCouplingRefCountObject.hxx"
-#include <iostream>
+#include "Basics_Utils.hxx"
+#include "PyInterp_Utils.h"
 
-MEDPresentation::MEDPresentation(MEDPresentation::TypeID fieldHandlerId, std::string name)
-    : _fieldHandlerId(fieldHandlerId), _pipeline(0), _display(0), _properties()
+#include <sstream>
+
+MEDPresentation::MEDPresentation(MEDPresentation::TypeID fieldHandlerId, const std::string& name)
+    : _fieldHandlerId(fieldHandlerId), _pipeline(0), _display(0), _properties(),
+      _renderViewPyId(GeneratePythonId())
 {
   MEDCALC::MEDDataManager_ptr dataManager(MEDFactoryClient::getDataManager());
   MEDCALC::FieldHandler* fieldHandler = dataManager->getFieldHandler(fieldHandlerId);
@@ -45,20 +49,49 @@ MEDPresentation::MEDPresentation(MEDPresentation::TypeID fieldHandlerId, std::st
   setProperty("name", name);
 }
 
-void MEDPresentation::generatePipeline()
+MEDPresentation::~MEDPresentation()
+{
+  STDLOG("~MEDPresentation(): clear display");
+  {
+    PyLockWrapper lock;
+    std::ostringstream oss_o, oss_v, oss;
+    // Get top level object and display:
+    oss_o << "__obj" << _pipeline.front().first;
+    oss_v << "__view" << _renderViewPyId;
+    oss << "pvs.Hide(" << oss_o.str() <<  ", view=" << oss_v.str() << ");";
+    oss << "pvs.Render();";
+
+//    std::cerr << oss.str() << std::endl;
+    PyRun_SimpleString(oss.str().c_str());
+  }
+}
+
+void
+MEDPresentation::generatePipeline()
 {
   // Might be more complicated in the future:
 
   this->internalGeneratePipeline();
 }
 
-void MEDPresentation::pushInternal(PyObject * obj, PyObject * disp)
+void
+MEDPresentation::pushPyObjects(PyObjectId obj, PyObjectId disp)
 {
   _pipeline.push_back(obj);
   _display.push_back(disp);
 }
 
-void MEDPresentation::setProperty(const std::string& propName, const std::string& propValue)
+void
+MEDPresentation::pushAndExecPyLine(const std::string & lin)
+{
+  // TODO: store internally for low level dump
+  PyLockWrapper lock;
+//  std::cerr << lin << std::endl;
+  PyRun_SimpleString(lin.c_str());
+}
+
+void
+MEDPresentation::setProperty(const std::string& propName, const std::string& propValue)
 {
   // LIMITED!!! For now switch the first display element to Wireframe
   /*
@@ -77,12 +110,13 @@ MEDPresentation::getProperty(const std::string& propName) const
     return (*it).second;
   }
   else {
-    std::cerr << "getProperty(): no property named " << propName << std::endl;
+    STDLOG("MEDPresentation::getProperty(): no property named " + propName);
     return std::string();
   }
 }
 
-PyObject * MEDPresentation::getPythonObjectFromMain(const char * python_var) const
+PyObject*
+MEDPresentation::getPythonObjectFromMain(const char* python_var) const
 {
   // TODO: improve to avoid getting dict at each call
 
@@ -92,7 +126,8 @@ PyObject * MEDPresentation::getPythonObjectFromMain(const char * python_var) con
   return PyDict_GetItemString(global_dict, python_var);
 }
 
-std::string MEDPresentation::getFieldTypeString(MEDCoupling::TypeOfField fieldType) const
+std::string
+MEDPresentation::getFieldTypeString(MEDCoupling::TypeOfField fieldType) const
 {
   switch(fieldType)
   {
@@ -101,7 +136,7 @@ std::string MEDPresentation::getFieldTypeString(MEDCoupling::TypeOfField fieldTy
     case MEDCoupling::ON_NODES:
       return "POINTS";
     default:
-      std::cerr << "MEDPresentation::getFieldTypeString() -- Not implemented ! Gauss points?";
+      STDLOG("MEDPresentation::getFieldTypeString() -- Not implemented ! Gauss points?");
       return "";
   }
 }
@@ -109,34 +144,55 @@ std::string MEDPresentation::getFieldTypeString(MEDCoupling::TypeOfField fieldTy
 std::string
 MEDPresentation::getRenderViewCommand(MEDCALC::MEDPresentationViewMode viewMode) const
 {
-  std::string cmd = std::string("pvs._DisableFirstRenderCameraReset();");
+  std::ostringstream oss, oss2;
+  oss << "__view" << _renderViewPyId;
+  std::string view(oss.str());
+  oss2 << "pvs._DisableFirstRenderCameraReset();";
   if (viewMode == MEDCALC::VIEW_MODE_OVERLAP) {
-    cmd += std::string("__view1 = pvs.GetActiveViewOrCreate('RenderView');");
+      oss2 << view << " = 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();");
+      oss2 << view << " = pvs.GetActiveViewOrCreate('RenderView');";
+      oss2 << "pvs.active_objects.source and pvs.Hide(view=" << view << ");";
+      oss2 << "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');");
+      oss2 <<  "__layout1 = pvs.servermanager.misc.ViewLayout(registrationGroup='layouts');";
+      oss2 << view << " = pvs.CreateView('RenderView');";
   } else if (viewMode == MEDCALC::VIEW_MODE_SPLIT_VIEW) {
-    cmd += std::string("__view1 = pvs.CreateView('RenderView');");
+      oss2 << view << " = pvs.CreateView('RenderView');";
   }
-  return cmd;
+  return oss2.str();
 }
 
 std::string
 MEDPresentation::getResetCameraCommand() const
 {
-  return std::string("__view1.ResetCamera();");
+  std::ostringstream oss;
+  oss << "__view" << _renderViewPyId << ".ResetCamera();";
+  return oss.str();
 }
 
-
 std::string
 MEDPresentation::getColorMapCommand(MEDCALC::MEDPresentationColorMap colorMap) const
 {
-  switch(colorMap) {
+  switch (colorMap) {
   case MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW: return "Blue to Red Rainbow";
   case MEDCALC::COLOR_MAP_COOL_TO_WARM: return "Cool to Warm";
   }
 }
+
+int
+MEDPresentation::GeneratePythonId()
+{
+  static int INIT_ID = 0;
+  return INIT_ID++;
+}
+
+void
+MEDPresentation::activateView() const
+{
+  PyLockWrapper lock;
+  std::ostringstream oss;
+  oss << "pvs.SetActiveView(__view" << _renderViewPyId << ");";
+  std::cerr << oss.str() << std::endl;
+  PyRun_SimpleString(oss.str().c_str());
+}
index aac5c5a003ec9bee003219ffc46921889105ded5..d67971dbed4236e2d3c43efa12d569b161309871 100644 (file)
@@ -41,47 +41,64 @@ public:
 
   typedef ::CORBA::Long TypeID;
 
-  virtual ~MEDPresentation() {}
+  virtual ~MEDPresentation();
 
   void setProperty(const std::string& propName, const std::string& propValue);
   const std::string getProperty(const std::string& propName) const;
 
+  void activateView() const;
+
 protected:
+  typedef std::pair<int, PyObject *> PyObjectId;
 
-  MEDPresentation(MEDPresentation::TypeID fieldHandlerId, std::string name);
+  MEDPresentation(MEDPresentation::TypeID fieldHandlerId, const std::string& name);
   std::string getRenderViewCommand(MEDCALC::MEDPresentationViewMode viewMode) const;
   std::string getResetCameraCommand() const;
   std::string getColorMapCommand(MEDCALC::MEDPresentationColorMap colorMap) const;
 
   virtual void internalGeneratePipeline() = 0;
-  PyObject * getPythonObjectFromMain(const char * var) const;
-  void pushInternal(PyObject * obj, PyObject * disp = NULL);
+  PyObject* getPythonObjectFromMain(const char* var) const;
+  void pushPyObjects(PyObjectId obj, PyObjectId disp);
+  void pushAndExecPyLine(const std::string & lin);
 
   MEDPresentation::TypeID getID() const { return _fieldHandlerId; }
+  long getPyViewID() const { return _renderViewPyId; }
+
+  static int GeneratePythonId();
+
+  virtual MEDCALC::MEDPresentationViewMode getViewMode() = 0;
 
 private:
 
-  void generatePipeline(); // reserved to friend class MEDPresentationManager
   std::string getFieldTypeString(MEDCoupling::TypeOfField fieldType) const;
 
-protected:
+  // The following functions are reserved to friend class MEDPresentationManager
+  void generatePipeline();
+
+  template<typename PresentationType, typename PresentationParameters>
+  void updatePipeline(PresentationParameters params);
 
+protected:
   std::string _fileName;
   std::string _fieldName;
   std::string _fieldType;
 
-private:
+  ///! Identifier (in the Python dump) of the render view
+  int _renderViewPyId;
 
+private:
   MEDPresentation::TypeID _fieldHandlerId;
 
   ///! Pipeline elements
-  std::vector< PyObject * > _pipeline;
+  std::vector<PyObjectId> _pipeline;
 
   ///! Corresponding display object, if any:
-  std::vector< PyObject * > _display;
+  std::vector<PyObjectId> _display;
 
   ///! Presentation properties <key,value>
   std::map<std::string, std::string> _properties;
 };
 
+#include "MEDPresentation.txx"
+
 #endif /* SRC_MEDCALC_CMP_MEDPRESENTATION_HXX_ */
diff --git a/src/MEDCalc/cmp/MEDPresentation.txx b/src/MEDCalc/cmp/MEDPresentation.txx
new file mode 100644 (file)
index 0000000..a99a462
--- /dev/null
@@ -0,0 +1,30 @@
+// 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 _MED_PRESENTATION_TXX_
+#define _MED_PRESENTATION_TXX_
+
+template<typename PresentationType, typename PresentationParameters>
+void
+MEDPresentation::updatePipeline(PresentationParameters params)
+{
+  static_cast<PresentationType*>(this)->updatePipeline(params);
+}
+
+#endif // _MED_PRESENTATION_TXX_
index 883cfb176a17cc0e2b057dfd068c156c8082afac..87ce8e8c2818d17eb0e5d64abf814b2130d23bdf 100644 (file)
 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();");
-
-  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("__isovolume1");
-  PyObject* disp = getPythonObjectFromMain("__disp1");
-  pushInternal(obj, disp);
+//  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();");
+//
+//  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("__isovolume1");
+//  PyObject* disp = getPythonObjectFromMain("__disp1");
+//  pushInternal(obj, disp);
+//
+//  PyGILState_Release(_gil_state);
+}
 
-  PyGILState_Release(_gil_state);
+void
+MEDPresentationContour::updatePipeline(const MEDCALC::ContourParameters& params)
+{
+  // :TODO:
 }
index 555dfe7706faffafe4786358fc10158e3c3d4e05..364965cd6000563a9748ba0d5b0dc99fcfc0f7e5 100644 (file)
@@ -31,6 +31,9 @@ public:
   {}
   virtual ~MEDPresentationContour() {}
 
+  void updatePipeline(const MEDCALC::ContourParameters& params);
+  MEDCALC::MEDPresentationViewMode getViewMode() { return _params.viewMode; }
+
 protected:
   virtual void internalGeneratePipeline();
 
index 1a20da49355c0eec4b636dbb9a77e009bd61a064..12a1d288a6ebcdf5f493583733e2622ca9eb33a0 100644 (file)
 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_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);
+}
 
-  PyGILState_Release(_gil_state);
+void
+MEDPresentationDeflectionShape::updatePipeline(const MEDCALC::DeflectionShapeParameters& params)
+{
+  // :TODO:
 }
index 9d614bf1998dee912759ad674c7a951c62bf8e9b..f03240e087ff2cab0c09d56e7b70bb3fcf6b9e84 100644 (file)
@@ -31,6 +31,9 @@ public:
   {}
   virtual ~MEDPresentationDeflectionShape() {}
 
+  void updatePipeline(const MEDCALC::DeflectionShapeParameters& params);
+  MEDCALC::MEDPresentationViewMode getViewMode() { return _params.viewMode; }
+
 protected:
   virtual void internalGeneratePipeline();
 
index b6c9ba970a8d378e7d0503d4a99a4a154646ecfb..920d0e060e2d92ddadbd893dafb224e0bd38eee9 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "MEDPresentationManager_i.hxx"
 #include "MEDFactoryClient.hxx"
+#include "Basics_Utils.hxx"
 
 // presentations
 #include "MEDPresentationScalarMap.hxx"
@@ -29,6 +30,7 @@
 #include "MEDPresentationPointSprite.hxx"
 
 #include <iostream>
+#include <sstream>
 
 MEDPresentationManager_i* MEDPresentationManager_i::_instance = NULL;
 
@@ -63,25 +65,30 @@ MEDPresentationManager_i::GenerateID()
   return START_ID;
 }
 
+MEDPresentation*
+MEDPresentationManager_i::_getPresentation(MEDPresentation::TypeID presentationID) const
+{
+  std::map<MEDPresentation::TypeID, MEDPresentation*>::const_iterator citr = _presentations.find(presentationID);
+  if (citr == _presentations.end())
+    return NULL;
+  return (*citr).second;
+}
+
 void
-MEDPresentationManager_i::setPresentationProperty(MEDPresentation::TypeID presentationID, const char * propName, const char * propValue)
+MEDPresentationManager_i::setPresentationProperty(MEDPresentation::TypeID presentationID, const char* propName, const char* propValue)
 {
-  if (_presentations.find(presentationID) != _presentations.end())
-    {
-      MEDPresentation * pres(_presentations[presentationID]);
-      pres->setProperty(propName, propValue);
-    }
+  MEDPresentation* pres = _getPresentation(presentationID);
+  if (pres)
+    pres->setProperty(propName, propValue);
   else
-    {
-      std::cerr << "setPresentationProperty(): presentation not found!!" << std::endl;
-    }
+    std::cerr << "setPresentationProperty(): presentation not found!!" << std::endl;
 }
 
 char*
 MEDPresentationManager_i::getPresentationProperty(MEDPresentation::TypeID presentationID, const char* propName)
 {
-  if (_presentations.find(presentationID) != _presentations.end()) {
-    MEDPresentation* pres = _presentations[presentationID];
+  MEDPresentation* pres = _getPresentation(presentationID);
+  if (pres) {
     return (char*) pres->getProperty(propName).c_str();
   }
   else {
@@ -125,3 +132,85 @@ MEDPresentationManager_i::makePointSprite(const MEDCALC::PointSpriteParameters&
 {
   return _makePresentation<MEDPresentationPointSprite>(params);
 }
+
+void
+MEDPresentationManager_i::updateScalarMap(MEDPresentation::TypeID presentationID, const MEDCALC::ScalarMapParameters& params)
+{
+  return _updatePresentation<MEDPresentationScalarMap>(presentationID, params);
+}
+
+void
+MEDPresentationManager_i::updateContour(MEDPresentation::TypeID presentationID, const MEDCALC::ContourParameters& params)
+{
+  return _updatePresentation<MEDPresentationContour>(presentationID, params);
+}
+
+void
+MEDPresentationManager_i::updateVectorField(MEDPresentation::TypeID presentationID, const MEDCALC::VectorFieldParameters& params)
+{
+  return _updatePresentation<MEDPresentationVectorField>(presentationID, params);
+}
+
+void
+MEDPresentationManager_i::updateSlices(MEDPresentation::TypeID presentationID, const MEDCALC::SlicesParameters& params)
+{
+  return _updatePresentation<MEDPresentationSlices>(presentationID, params);
+}
+
+void
+MEDPresentationManager_i::updateDeflectionShape(MEDPresentation::TypeID presentationID, const MEDCALC::DeflectionShapeParameters& params)
+{
+  return _updatePresentation<MEDPresentationDeflectionShape>(presentationID, params);
+}
+
+void
+MEDPresentationManager_i::updatePointSprite(MEDPresentation::TypeID presentationID, const MEDCALC::PointSpriteParameters& params)
+{
+  return _updatePresentation<MEDPresentationPointSprite>(presentationID, params);
+}
+
+CORBA::Boolean
+MEDPresentationManager_i::removePresentation(MEDPresentation::TypeID presentationID)
+{
+  std::map<MEDPresentation::TypeID, MEDPresentation*>::const_iterator citr = _presentations.find(presentationID);
+  if (citr == _presentations.end()) {
+    std::cerr << "removePresentation(): presentation not found!!" << std::endl;
+    return false;
+  }
+  MEDPresentation* presentation = (*citr).second;
+  if (presentation)
+    delete presentation;
+  _presentations.erase(presentationID);
+
+  std::stringstream sstm;
+  sstm << "Presentation " << presentationID << " has been removed.\n";
+  STDLOG(sstm.str());
+
+  return true;
+}
+
+CORBA::Boolean
+MEDPresentationManager_i::activateView(MEDPresentation::TypeID presentationID)
+{
+  std::map<MEDPresentation::TypeID, MEDPresentation*>::const_iterator citr = _presentations.find(presentationID);
+  if (citr == _presentations.end()) {
+    std::cerr << "getPresentationPyViewId(): presentation not found!!" << std::endl;
+    return false;
+  }
+  MEDPresentation* presentation = (*citr).second;
+
+  presentation->activateView();
+  return true;
+}
+
+MEDCALC::MEDPresentationViewMode
+MEDPresentationManager_i::getPresentationViewMode(MEDPresentation::TypeID presentationID)
+{
+  MEDPresentation* pres = _getPresentation(presentationID);
+  if (pres) {
+    return pres->getViewMode();
+  } else {
+    std::cerr << "setPresentationProperty(): presentation not found!!" << std::endl;
+    return MEDCALC::VIEW_MODE_DEFAULT;
+  }
+}
index 5af811002f60044a3aecea53b91a22df5e856bfe..4d455d20de4ac817d2b90d4b202b5886d37c67af 100644 (file)
@@ -46,8 +46,21 @@ class MEDPresentationManager_i: public POA_MEDCALC::MEDPresentationManager,
   MEDCALC_EXPORT MEDPresentation::TypeID makeDeflectionShape(const MEDCALC::DeflectionShapeParameters&);
   MEDCALC_EXPORT MEDPresentation::TypeID makePointSprite(const MEDCALC::PointSpriteParameters&);
 
-  MEDCALC_EXPORT void setPresentationProperty(MEDPresentation::TypeID presentationID, const char * propName, const char * propValue);
-  MEDCALC_EXPORT char* getPresentationProperty(MEDPresentation::TypeID presentationID, const char* propName);
+  MEDCALC_EXPORT void setPresentationProperty(MEDPresentation::TypeID, const char* propName, const char* propValue);
+  MEDCALC_EXPORT char* getPresentationProperty(MEDPresentation::TypeID, const char* propName);
+
+  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 updatePointSprite(MEDPresentation::TypeID, const MEDCALC::PointSpriteParameters&);
+
+  MEDCALC_EXPORT CORBA::Boolean removePresentation(MEDPresentation::TypeID);
+
+  MEDCALC_EXPORT CORBA::Boolean activateView(MEDPresentation::TypeID);
+
+  MEDCALC_EXPORT MEDCALC::MEDPresentationViewMode getPresentationViewMode(MEDPresentation::TypeID);
 
  private:
   MEDPresentationManager_i();
@@ -59,14 +72,20 @@ class MEDPresentationManager_i: public POA_MEDCALC::MEDPresentationManager,
   template<typename PresentationType, typename PresentationParameters>
   MEDPresentation::TypeID _makePresentation(PresentationParameters params);
 
+  // Update presentation
+  template<typename PresentationType, typename PresentationParameters>
+  void _updatePresentation(MEDPresentation::TypeID presentationID, PresentationParameters params);
+
+  MEDPresentation* _getPresentation(MEDPresentation::TypeID) const;
+
  private :
 
   // The MEDPresentationManager is a singleton, whose instance can be obtained
   // using the getInstance static method.
-  static MEDPresentationManager_i * _instance;
+  static MEDPresentationManager_i* _instance;
 
   // Owns a list of MEDPresentation objects
-  std::map< MEDPresentation::TypeID, MEDPresentation * > _presentations;
+  std::map<MEDPresentation::TypeID, MEDPresentation*> _presentations;
 
 };
 
index c315746ea00a361d30c68bff2cf5ff990a562c2b..eb283bf152986e6e60abcb850c3e4dd16c52e227 100644 (file)
@@ -40,4 +40,17 @@ MEDPresentationManager_i::_makePresentation(PresentationParameters params)
   return newID;
 }
 
+template<typename PresentationType, typename PresentationParameters>
+void
+MEDPresentationManager_i::_updatePresentation(MEDPresentation::TypeID presentationID, PresentationParameters params)
+{
+  MEDPresentation* presentation = _getPresentation(presentationID);
+  if (!presentation) {
+    std::cerr << "_updatePresentation(): presentation not found!!" << std::endl;
+    return;
+  }
+
+  presentation->updatePipeline<PresentationType>(params);
+}
+
 #endif // _MED_PRESENTATION_MANAGER_I_TXX_
index 3d618575fdc4dccb5c3df4d62a029c6a313e7d5c..18fdff4d37e6f17f3cbcb5c434a839904a2f88bc 100644 (file)
 void
 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, __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("__disp1.SetRepresentationType('Point Sprite');");
-  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("__obj1");
-  PyObject* disp = getPythonObjectFromMain("__disp1");
-  pushInternal(obj, disp);
+//  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, __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("__disp1.SetRepresentationType('Point Sprite');");
+//  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("__obj1");
+//  PyObject* disp = getPythonObjectFromMain("__disp1");
+//  pushInternal(obj, disp);
+//
+//  PyGILState_Release(_gil_state);
+}
 
-  PyGILState_Release(_gil_state);
+void
+MEDPresentationPointSprite::updatePipeline(const MEDCALC::PointSpriteParameters& params)
+{
+  // :TODO:
 }
index 34f0dd17080054830537769018a4128c45c6e9ae..49b200b125a1d7c71c2436784f485f6b94f11738 100644 (file)
@@ -31,6 +31,9 @@ public:
   {}
   virtual ~MEDPresentationPointSprite() {}
 
+  void updatePipeline(const MEDCALC::PointSpriteParameters& params);
+  MEDCALC::MEDPresentationViewMode getViewMode() { return _params.viewMode; }
+
 protected:
   virtual void internalGeneratePipeline();
 
index a09da3febeeeb5a73181ac06d8b8c4e1f0b03e14..6af5375bd2729fc3fe637f8a4f6778a9839dcc7c 100644 (file)
 //
 
 #include "MEDPresentationScalarMap.hxx"
+#include "PyInterp_Utils.h"
+
+#include <sstream>
 
 void
 MEDPresentationScalarMap::internalGeneratePipeline()
 {
-  PyGILState_STATE _gil_state = PyGILState_Ensure();
+  PyLockWrapper lock;
+
+  int disp_id(GeneratePythonId());
+  int obj_id(disp_id);
+  std::ostringstream oss_o, oss_d, oss, oss_v;
+  oss_o << "__obj" << obj_id;      std::string obj(oss_o.str());
+  oss_d << "__disp" << disp_id;    std::string disp(oss_d.str());
 
-  std::string cmd = std::string("import pvsimple as pvs;");
-  cmd += getRenderViewCommand(_params.viewMode); // define __view1
+  pushAndExecPyLine( "import pvsimple as pvs;");
+  pushAndExecPyLine( getRenderViewCommand(_params.viewMode) ); // define __viewXXX
 
-  cmd += std::string("__obj1 = pvs.MEDReader(FileName='") + _fileName + std::string("');");
-  cmd += std::string("__disp1 = pvs.Show(__obj1, __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("__lut = pvs.GetColorTransferFunction('")+_fieldName+std::string("');");
-  cmd += std::string("__lut.ApplyPreset('")+getColorMapCommand(_params.colorMap)+std::string("',True);");
-  cmd += std::string("pvs.Render();");
+  oss_v << "__view" << _renderViewPyId;    std::string view(oss_v.str());
 
-  cmd += getResetCameraCommand();
+  oss << obj << " = pvs.MEDReader(FileName='" << _fileName << "');";
+  pushAndExecPyLine(oss.str()); oss.str("");
+  oss << disp << " = pvs.Show(" << obj << ", " << view << ");";
+  pushAndExecPyLine(oss.str()); oss.str("");
+  oss << "pvs.ColorBy(" << disp << ", ('" << _fieldType << "', '" << _fieldName << "'));";
+  pushAndExecPyLine(oss.str()); oss.str("");
+  oss << disp <<  ".SetScalarBarVisibility(" << view << ", True);";
+  pushAndExecPyLine(oss.str()); oss.str("");
+  oss << disp <<  ".RescaleTransferFunctionToDataRangeOverTime();";
+  pushAndExecPyLine(oss.str()); oss.str("");
+  oss << "__lut = pvs.GetColorTransferFunction('" << _fieldName << "');";
+  pushAndExecPyLine(oss.str()); oss.str("");
+  oss << "__lut.ApplyPreset('" << getColorMapCommand(_params.colorMap) << "',True);";
+  pushAndExecPyLine(oss.str()); oss.str("");
+  pushAndExecPyLine(getResetCameraCommand());
+  pushAndExecPyLine("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");
-  pushInternal(obj, disp);
+  PyObject* p_obj = getPythonObjectFromMain(obj.c_str());
+  PyObject* p_disp = getPythonObjectFromMain(disp.c_str());
+  pushPyObjects(std::make_pair(obj_id, p_obj), std::make_pair(disp_id, p_disp));
+}
 
-  PyGILState_Release(_gil_state);
+void
+MEDPresentationScalarMap::updatePipeline(const MEDCALC::ScalarMapParameters& params)
+{
+  // :TODO:
 }
index 1b26af56ffa9ef50f663d3bc1e2eece3b26ba526..2b35a3482b76b79c36441525f1e0d93cd7167641 100644 (file)
@@ -31,6 +31,9 @@ public:
   {}
   virtual ~MEDPresentationScalarMap() {}
 
+  void updatePipeline(const MEDCALC::ScalarMapParameters& params);
+  MEDCALC::MEDPresentationViewMode getViewMode() { return _params.viewMode; }
+
 protected:
   virtual void internalGeneratePipeline();
 
index 4b5636aad1a854370e6bd232e955eb16c6683c1d..243468f0b36ea97498df4564480426d07f588d1c 100644 (file)
 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_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);
+}
 
-  PyGILState_Release(_gil_state);
+void
+MEDPresentationSlices::updatePipeline(const MEDCALC::SlicesParameters& params)
+{
+  // :TODO:
 }
index a738d7a3f8fda84736bed290a031eb422d922a69..7166a92bdb5baafe88e6bbba1727257ce74ad308 100644 (file)
@@ -31,6 +31,9 @@ public:
   {}
   virtual ~MEDPresentationSlices() {}
 
+  void updatePipeline(const MEDCALC::SlicesParameters& params);
+  MEDCALC::MEDPresentationViewMode getViewMode() { return _params.viewMode; }
+
 protected:
   virtual void internalGeneratePipeline();
 
index ae03a030da00d9f8559eddf27d21f1fd978e63b3..979f8ed8cfa258e55a11271c642c5495c135d032 100644 (file)
 void
 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, __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("__disp1.SetRepresentationType('3D Glyphs');");
-  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("__obj1");
-  PyObject* disp = getPythonObjectFromMain("__disp1");
-  pushInternal(obj, disp);
+//  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, __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("__disp1.SetRepresentationType('3D Glyphs');");
+//  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("__obj1");
+//  PyObject* disp = getPythonObjectFromMain("__disp1");
+//  pushInternal(obj, disp);
+//
+//  PyGILState_Release(_gil_state);
+}
 
-  PyGILState_Release(_gil_state);
+void
+MEDPresentationVectorField::updatePipeline(const MEDCALC::VectorFieldParameters& params)
+{
+  // :TODO:
 }
index a7fc8d89f4191102edf9d43042aa3495eb1a87ed..3da7403113c2ab6e15240c44b7b04a803acfa9c9 100644 (file)
@@ -31,6 +31,9 @@ public:
   {}
   virtual ~MEDPresentationVectorField() {}
 
+  void updatePipeline(const MEDCALC::VectorFieldParameters& params);
+  MEDCALC::MEDPresentationViewMode getViewMode() { return _params.viewMode; }
+
 protected:
   virtual void internalGeneratePipeline();
 
index ccfe685b27947ae983cef24c7ef5b05d594fddee..8fa43b3f67fe603f1527ebd5330456da9fda6f5f 100644 (file)
@@ -230,7 +230,8 @@ void DatasourceController::OnExpandField()
     SALOMEDS::SObject_var soFieldseries = listOfSObject->at(i);
 
     // First retrieve the fieldseries id associated to this study object
-    long fieldseriesId = _studyEditor->getParameterInt(soFieldseries,OBJECT_ID);
+    long fieldseriesId = _studyEditor->getParameterInt(soFieldseries,FIELD_SERIES_ID);
+    //long fieldseriesId = _studyEditor->getParameterInt(soFieldseries,FIELD_ID);
     STDLOG("Expand the field timeseries "<<fieldseriesId);
 
     // If fieldseriesId equals -1, then it means that it is not a
@@ -251,8 +252,8 @@ void DatasourceController::OnExpandField()
       SALOMEDS::SObject_var soField = _studyEditor->newObject(soFieldseries);
       std::string label("it="); label += ToString(fieldHandler.iteration);
       _studyEditor->setName(soField,label.c_str());
-      _studyEditor->setParameterInt(soField, OBJECT_ID, fieldHandler.id);
-      _studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,false);
+      _studyEditor->setParameterInt(soField, FIELD_ID, fieldHandler.id);
+      _studyEditor->setParameterBool(soField,IS_IN_WORKSPACE,false);
     }
   }
   _salomeModule->updateObjBrowser(true);
@@ -277,7 +278,7 @@ void DatasourceController::OnUseInWorkspace() {
 
     SALOMEDS::SObject_var soField = listOfSObject->at(0);
 
-    bool isInWorkspace = _studyEditor->getParameterBool(soField,OBJECT_IS_IN_WORKSPACE);
+    bool isInWorkspace = _studyEditor->getParameterBool(soField,IS_IN_WORKSPACE);
     if ( isInWorkspace ) {
       QMessageBox::warning(_salomeModule->getApp()->desktop(),
          tr("Operation not allowed"),
@@ -285,7 +286,7 @@ void DatasourceController::OnUseInWorkspace() {
       return;
     }
 
-    int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
+    int fieldId = _studyEditor->getParameterInt(soField,FIELD_ID);
 
     // If fieldId equals -1, then it means that it is not a field
     // managed by the MED module, and we stop this function process.
@@ -324,7 +325,7 @@ void DatasourceController::OnUseInWorkspace() {
     event->objectalias = alias;
     emit datasourceSignal(event);
     // Tag the item to prevent double import
-    //    _studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,true);
+    //    _studyEditor->setParameterBool(soField,IS_IN_WORKSPACE,true);
     // Tag the field as persistent on the server. It means that a
     // saving of the workspace will save at least this field (maybe it
     // should be an option?)
@@ -336,9 +337,9 @@ void DatasourceController::OnUseInWorkspace() {
     for (int i=0; i<listOfSObject->size(); i++) {
       SALOMEDS::SObject_var soField = listOfSObject->at(i);
 
-      bool isInWorkspace = _studyEditor->getParameterBool(soField,OBJECT_IS_IN_WORKSPACE);
+      bool isInWorkspace = _studyEditor->getParameterBool(soField,IS_IN_WORKSPACE);
       if ( !isInWorkspace ) {
-        int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
+        int fieldId = _studyEditor->getParameterInt(soField,FIELD_ID);
         MEDCALC::FieldHandler* fieldHandler =
           MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
         DatasourceEvent* event = new DatasourceEvent();
@@ -350,7 +351,7 @@ void DatasourceController::OnUseInWorkspace() {
         // Note that this signal is processed by the WorkspaceController
 
         // Tag the item to prevent double import
-        //        _studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,true);
+        //        _studyEditor->setParameterBool(soField,IS_IN_WORKSPACE,true);
         // Tag the field as persistent on the server. It means that a
         // saving of the workspace will save at least this field (maybe it
         // should be an option?)
index 7b8ffb2e1f495267b9b9312023165e56067c8627..1501c32b102dd4fc0e387875955f985435bbc9d5 100644 (file)
 
 #ifndef DISABLE_PVVIEWER
 #include "PVViewer_ViewModel.h"
+#include "PVViewer_GUIElements.h"
 #endif
 
+
+#include "MEDFactoryClient.hxx"
+#include "MEDPresentationManager_i.hxx"
 #include <QTimer>
 
 #include <sstream>
 
+#include <pqAnimationManager.h>
+#include <pqPVApplicationCore.h>
+
+
 //! The only instance of the reference to engine
-MED_ORB::MED_Gen_var MEDModule::myEngine;
+MED_ORB::MED_Gen_var MEDModule::_MED_engine;
+//! The only instance of the MEDPresentationManager
+MEDCALC::MEDPresentationManager_ptr MEDModule::_presManager;
 
 MEDModule::MEDModule() :
-  SalomeApp_Module("MED"), _studyEditor(0), _datasourceController(0), _workspaceController(0),
-  _presentationController(0), _processingController(0)
+  SalomeApp_Module("MED"), _studyEditor(0),
+  _datasourceController(0), _workspaceController(0), _presentationController(0),
+  _processingController(0), _pvGuiElements(0)
 {
   // Note also that we can't use the getApp() function here because
   // the initialize(...) function has not been called yet.
@@ -79,18 +90,23 @@ MED_ORB::MED_Gen_var
 MEDModule::engine()
 {
   init(); // initialize engine, if necessary
-  return myEngine;
+  return _MED_engine;
 }
 
 void
 MEDModule::init()
 {
   // initialize MED module engine (load, if necessary)
-  if ( CORBA::is_nil( myEngine ) ) {
+  if ( CORBA::is_nil( _MED_engine ) ) {
     Engines::EngineComponent_var comp =
       SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "MED" );
-    myEngine = MED_ORB::MED_Gen::_narrow( comp );
+    _MED_engine = MED_ORB::MED_Gen::_narrow( comp );
   }
+
+  // Retrieve MEDFactory to get MEDPresentationManager (sometimes
+  if ( ! _presManager ) {
+      _presManager = MEDFactoryClient::getFactory()->getPresentationManager();
+    }
 }
 
 //void MEDModule::onEventLoopStarted()
@@ -108,9 +124,13 @@ MEDModule::initialize( CAM_Application* app )
   // call the parent implementation
   SalomeApp_Module::initialize( app );
 
+  getApp()->objectBrowser()->setAutoOpenLevel(5);
+
   if (app && app->desktop()) {
     connect((QObject*) (getApp()->objectBrowser()->treeView()), SIGNAL(doubleClicked(const QModelIndex&)),
             this, SLOT(onDblClick(const QModelIndex&)));
+    connect((QObject*) (getApp()->objectBrowser()->treeView()), SIGNAL(clicked(const QModelIndex&)),
+                this, SLOT(onClick(const QModelIndex&)));
   }
 
   // The following initializes the GUI widget and associated actions
@@ -122,7 +142,7 @@ QString
 MEDModule::engineIOR() const
 {
   init(); // initialize engine, if necessary
-  CORBA::String_var anIOR = getApp()->orb()->object_to_string( myEngine.in() );
+  CORBA::String_var anIOR = getApp()->orb()->object_to_string( _MED_engine.in() );
   return QString( anIOR.in() );
 }
 
@@ -174,7 +194,7 @@ MEDModule::createPreferences()
 bool
 MEDModule::activateModule( SUIT_Study* theStudy )
 {
-  if ( CORBA::is_nil( myEngine ) )
+  if ( CORBA::is_nil( _MED_engine ) )
     return false;
 
   // call parent implementation
@@ -257,6 +277,28 @@ MEDModule::createModuleWidgets() {
   connect(_workspaceController, SIGNAL(workspaceSignal(const MEDCALC::MedEvent*)),
     _presentationController, SLOT(processWorkspaceEvent(const MEDCALC::MedEvent*)));
 
+
+  // Now that the workspace controller is created, ParaView core application has normally been started,
+  // and hidden GUI elements have been created.  We can fire the VCR toolbar activation:
+  initToolbars();
+}
+
+void
+MEDModule::initToolbars()
+{
+  // VCR and Time toolbars:
+  SUIT_Desktop* dsk = getApp()->desktop();
+  _pvGuiElements = PVViewer_GUIElements::GetInstance(dsk);
+
+  _pvGuiElements->getVCRToolbar();  // make sure VCR toolbar is built
+  _pvGuiElements->setToolBarVisible(false);
+  _pvGuiElements->setVCRTimeToolBarVisible(true);
+
+  // Emit signal in order to make sure that animation scene is set - same trick as in PARAVIS module activation
+  QMetaObject::invokeMethod( pqPVApplicationCore::instance()->animationManager(),
+                             "activeSceneChanged",
+                             Q_ARG( pqAnimationScene*, pqPVApplicationCore::instance()->animationManager()->getActiveScene() ) );
+
 #ifdef MED_HAS_QTTESTING
   connect(_workspaceController, SIGNAL(workspaceSignal(const MEDCALC::MedEvent*)),
     _testController, SLOT(processWorkspaceEvent(const MEDCALC::MedEvent*)));
@@ -313,7 +355,7 @@ void
 MEDModule::addActionInPopupMenu(int actionId,const QString& menus,const QString& rule)
 {
   // _GBO_ for a fine customization of the rule (for example with a
-  // test on the type of the selected object), see the LIGTH module:
+  // test on the type of the selected object), see the LIGHT module:
   // implement "LightApp_Selection*    createSelection() const;"
   int parentId = -1;
   QtxPopupMgr* mgr = this->popupMgr();
@@ -337,50 +379,85 @@ MEDModule::getSelectedColorMap()
   return _presentationController->getSelectedColorMap();
 }
 
-void
-MEDModule::onDblClick(const QModelIndex& index)
+bool
+MEDModule::itemClickGeneric(const QModelIndex & index, std::string & name, int & fieldId, int & presId) const
 {
   DataObjectList dol = getApp()->objectBrowser()->getSelected();
   if (dol.isEmpty())
-    return;
+    return false;
   SalomeApp_DataObject* item = dynamic_cast<SalomeApp_DataObject*>(dol[0]);
   if (!item)
-    return;
+    return false;
   SalomeApp_DataModel *model = dynamic_cast<SalomeApp_DataModel*>(dataModel());
   if (!model)
-    return;
+    return false;
 
   if (item->componentDataType().toStdString() != "MED")
-    return;
+    return false;
   _PTR(SObject) obj = item->object();
   _PTR(GenericAttribute) anAttribute;
 
   if (! obj->FindAttribute(anAttribute, "AttributeName"))
-    return;
+    return false;
   _PTR(AttributeName) attrName(anAttribute);
-  std::string name = attrName->Value();
+  name = attrName->Value();
 
   if (! obj->FindAttribute(anAttribute, "AttributeParameter"))
-    return;
+    return false;
   _PTR(AttributeParameter) attrParam(anAttribute);
   if (! attrParam->IsSet(IS_PRESENTATION, PT_BOOLEAN)
       || ! attrParam->GetBool(IS_PRESENTATION)) { // Not a presentation
-    return;
+      return false;
   }
   if (!attrParam->IsSet(FIELD_ID, PT_INTEGER))
+    return false;
+  fieldId = attrParam->GetInt(FIELD_ID);
+  if (!attrParam->IsSet(PRESENTATION_ID, PT_INTEGER))
+      return false;
+  presId = attrParam->GetInt(PRESENTATION_ID);
+  return true;
+}
+
+void
+MEDModule::onClick(const QModelIndex & index)
+{
+  int fieldId, presId;
+  std::string name;
+  if (!itemClickGeneric(index, name, fieldId, presId))
+    return;
+
+  STDLOG("Presentation selection (activate view)");
+  std::ostringstream oss;
+  oss << fieldId << " / " << presId;
+  STDLOG("    - Field id / pres id:   " + oss.str());
+  STDLOG("    - Presentation name: " + name);
+
+  _presManager->activateView(presId);
+}
+
+void
+MEDModule::onDblClick(const QModelIndex& index)
+{
+  int fieldId, presId;
+  std::string name;
+  if (!itemClickGeneric(index, name, fieldId, presId))
     return;
-  int fieldId = attrParam->GetInt(FIELD_ID);
 
   STDLOG("Presentation edition: NOT IMPLEMENTED YET");
   STDLOG("  Presention infos:");
-  STDLOG("    - Component:         " + item->componentDataType().toStdString());
-  STDLOG("    - Item entry:        " + item->entry().toStdString());
-  STDLOG("    - Item name:         " + item->name().toStdString());
+//  STDLOG("    - Component:         " + item->componentDataType().toStdString());
+//  STDLOG("    - Item entry:        " + item->entry().toStdString());
+//  STDLOG("    - Item name:         " + item->name().toStdString());
   std::ostringstream oss;
   oss << fieldId;
   STDLOG("    - Field id:          " + oss.str());
   STDLOG("    - Presentation name: " + name);
 
+  // :TODO:
+  // get edited values from a popup widget
+  // get presentation
+  // call presentation edit function
+
 }
 
 void
index 4a2e01851234a9dd92d1565f4ce48ca4198e905a..7541e3f919534227299daf9d2a097c0430144fd1 100644 (file)
@@ -41,6 +41,8 @@
 #include <QModelIndex>
 
 class SalomeApp_Application;
+class PVViewer_GUIElements;
+class MEDPresentationManager_i;
 
 /*!
  * This class defines the gui of the MED module.
@@ -91,10 +93,15 @@ public slots:
   virtual bool activateModule(SUIT_Study* theStudy);
   virtual bool deactivateModule(SUIT_Study* theStudy);
   virtual void onDblClick(const QModelIndex& index);
+  virtual void onClick(const QModelIndex& index);
+
+
 
 private:
   void createModuleWidgets();
   void createModuleActions();
+  void initToolbars();
+  bool itemClickGeneric(const QModelIndex & index, std::string & name, int & fieldId, int & presId) const;
 
   static void init();
 
@@ -105,10 +112,17 @@ private:
   XmedDataModel* _xmedDataModel;
   PresentationController* _presentationController;
   ProcessingController* _processingController;
+
+  PVViewer_GUIElements*   _pvGuiElements;
+
+  static MED_ORB::MED_Gen_var _MED_engine;
+
+  // GUI needs to talk directly to the pres manager to activate a view, get some params, etc ...:
+  static MEDCALC::MEDPresentationManager_ptr _presManager;
+
 #ifdef MED_HAS_QTTESTING
   TestController * _testController;
 #endif
-  static MED_ORB::MED_Gen_var myEngine;
 };
 
 #endif
index 7484fc4c111b09db7227ddef25907df34442fbca..cd650e7434ab4ed11459443b89a688eb0954d370 100644 (file)
       <source>ICO_MEDPresentationPointSprite_CLASSIC</source>
       <translation>visu_points16.png</translation>
     </message>
+    <message>
+      <source>ICO_DELETE_PRESENTATION</source>
+      <translation>close.png</translation>
+    </message>
   </context>
 </TS>
index 8754beb6b09bc21c26409d280839844815041856..8841a7d85311851e091b114119a001c61a799214 100644 (file)
       <source>TIP_PRESENTATION_POINT_SPRITE</source>
       <translation>Point sprite</translation>
     </message>
+    <message>
+      <source>LAB_DELETE_PRESENTATION</source>
+      <translation>Delete presentation</translation>
+    </message>
+    <message>
+      <source>TIP_DELETE_PRESENTATION</source>
+      <translation>Delete selected presentation</translation>
+    </message> 
     <message>
       <source>MENU_PRESENTATIONS</source>
       <translation>Presentations</translation>
   <context>
     <name>WidgetPresentationParameters</name>
     <message>
-      <source>LAB_FIELD</source>
-      <translation>Field:</translation>
+      <source>LAB_DISP_COMP</source>
+      <translation>Displayed component:</translation>
     </message>
     <message>
       <source>LAB_EUCLIDEAN_NORM</source>
index 7481ad5a8c563170041cde48130aafebfff15fb0..acf347d1f6f4c1ad65587139eee58e312bfeeb1d 100644 (file)
   <context>
     <name>WidgetPresentationParameters</name>
     <message>
-      <source>LAB_FIELD</source>
-      <translation>Champ :</translation>
+      <source>LAB_DISP_COMP</source>
+      <translation>Composante affichée :</translation>
     </message>
     <message>
       <source>LAB_EUCLIDEAN_NORM</source>
index ceaf424bb527c281bd1337b1967ad7898b1184d8..1785436a6c16c255701b6e79554e1f1686373d9c 100644 (file)
@@ -24,6 +24,7 @@
 #include "QtxActionGroup.h"
 #include "QtxActionToolMgr.h"
 #include "MEDFactoryClient.hxx"
+#include "MEDPresentationManager_i.hxx"
 
 #include <SalomeApp_Application.h>
 #include <SalomeApp_Study.h>
 #include <SUIT_Session.h>
 #include <SUIT_ResourceMgr.h>
 #include <QMessageBox>
+#include <sstream>
 
-PresentationController::PresentationController(MEDModule* salomeModule)
+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) :
+    _salomeModule(salomeModule),
+    _studyEditor(salomeModule->getStudyEditor())
 {
   STDLOG("Creating a PresentationController");
-  _salomeModule = salomeModule;
-  _studyEditor = _salomeModule->getStudyEditor();
 
   _widgetPresentationParameters = new WidgetPresentationParameters();
 
@@ -84,12 +92,44 @@ PresentationController::createActions()
 {
   STDLOG("Creating PresentationController actions");
 
+  // View Mode
+  int viewModeToolbarId = _salomeModule->createTool("View Mode", "ViewModeToolbar");
+  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, viewModeToolbarId);
+
+  // Presentations
   int presentationToolbarId = _salomeModule->createTool("Presentations", "PresentationToolbar");
   int presentationMenuId = _salomeModule->createMenu(tr("MENU_PRESENTATIONS"), -1, 1);
 
-  // Presentations
-  QString label   = tr("LAB_PRESENTATION_SCALAR_MAP");
-  QString tooltip = tr("TIP_PRESENTATION_SCALAR_MAP");
+  label   = tr("LAB_PRESENTATION_SCALAR_MAP");
+  tooltip = tr("TIP_PRESENTATION_SCALAR_MAP");
   QString icon = tr(_getIconName("ICO_PRESENTATION_SCALAR_MAP").c_str());
   int actionId;
   actionId = _salomeModule->createStandardAction(label,this, SLOT(OnVisualizeScalarMap()),icon,tooltip);
@@ -136,12 +176,35 @@ PresentationController::createActions()
   _salomeModule->createTool(actionId, presentationToolbarId);
   _salomeModule->action(actionId)->setIconVisibleInMenu(true);
   _salomeModule->createMenu(actionId, presentationMenuId);
+
+  label   = tr("LAB_DELETE_PRESENTATION");
+  tooltip = tr("TIP_DELETE_PRESENTATION");
+  icon    = tr(_getIconName("ICO_DELETE_PRESENTATION").c_str());
+  actionId = _salomeModule->createStandardAction(label,this, SLOT(OnDeletePresentation()),icon,tooltip);
+//  _salomeModule->createTool(actionId, presentationToolbarId);
+//  _salomeModule->action(actionId)->setIconVisibleInMenu(true);
+  _salomeModule->createMenu(actionId, presentationMenuId);
+
 }
 
 MEDCALC::MEDPresentationViewMode
 PresentationController::getSelectedViewMode()
 {
-  return _widgetPresentationParameters->getViewMode();
+  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;
+  }
+  // Should not happen
+  STDLOG("Strange!! No matching view mode found - returning VIEW_MODE_REPLACE.");
+  return MEDCALC::VIEW_MODE_REPLACE;
 }
 
 MEDCALC::MEDPresentationColorMap
@@ -164,11 +227,27 @@ PresentationController::visualize(PresentationEvent::EventType eventType)
   // to make a view of an object from the tui console).
   for (int i=0; i<listOfSObject->size(); i++) {
     SALOMEDS::SObject_var soField = listOfSObject->at(i);
-    int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
-    // If fieldId equals -1, then it means that it is not a field
-    // managed by the MED module, and we stop this function process.
-    if ( fieldId < 0 )
-      continue;
+    int fieldId = -1;
+    try {
+        fieldId = _studyEditor->getParameterInt(soField,FIELD_ID);    }
+    catch(...)    { }
+    if (fieldId < 0)  // is it a field serie ?
+      {
+        int fieldSeriesId = -1;
+        try {
+            fieldSeriesId = _studyEditor->getParameterInt(soField,FIELD_SERIES_ID);      }
+        catch(...)  { }
+        // If fieldId and fieldSeriesId equals -1, then it means that it is not a field
+        // managed by the MED module, and we stop this function process.
+        if ( fieldSeriesId < 0)
+          continue;
+        MEDCALC::FieldHandlerList* fieldHandlerList = MEDFactoryClient::getDataManager()->getFieldListInFieldseries(fieldSeriesId);
+        if (fieldHandlerList->length() < 0)
+          continue;
+        // For a field series, get the first real field entry:
+        MEDCALC::FieldHandler fieldHandler = (*fieldHandlerList)[0];
+        fieldId = fieldHandler.id;
+      }
 
     MEDCALC::FieldHandler* fieldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
     if (! fieldHandler) {
@@ -223,6 +302,38 @@ PresentationController::OnVisualizePointSprite()
   this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_POINT_SPRITE);
 }
 
+void
+PresentationController::OnDeletePresentation()
+{
+  // We need a _studyEditor updated on the active study
+  _studyEditor->updateActiveStudy();
+
+  // Get the selected objects in the study (SObject)
+  SALOME_StudyEditor::SObjectList* listOfSObject = _studyEditor->getSelectedObjects();
+
+  // For each object, emit a signal to the workspace to request pres deletion
+  for (int i=0; i<listOfSObject->size(); i++) {
+    SALOMEDS::SObject_var soPres = listOfSObject->at(i);
+    int presId = _studyEditor->getParameterInt(soPres,PRESENTATION_ID);
+    // If fieldId equals -1, then it means that it is not a field
+    // managed by the MED module, and we stop this function process.
+    if ( presId < 0 )
+      continue;
+
+    STDLOG("Requesting deletion of presentation: ")
+    std::ostringstream oss;
+    oss << presId;
+    STDLOG("    - Pres id:          " + oss.str());
+
+    PresentationEvent* event = new PresentationEvent();
+    event->eventtype = PresentationEvent::EVENT_DELETE_PRESENTATION;
+    XmedDataObject* dataObject = new XmedDataObject();
+    dataObject->setPresentationId(presId);
+    event->objectdata = dataObject;
+    emit presentationSignal(event); // --> WorkspaceController::processPresentationEvent
+  }
+}
+
 void
 PresentationController::updateTreeViewWithNewPresentation(long fieldId, long presentationId)
 {
@@ -240,7 +351,50 @@ PresentationController::updateTreeViewWithNewPresentation(long fieldId, long pre
   SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(_salomeModule->application()->activeStudy());
   _PTR(Study) studyDS = study->studyDS();
 
-  _salomeModule->engine()->registerPresentation(_CAST(Study, studyDS)->GetStudy(), fieldId, name.c_str(), label.c_str());
+  _salomeModule->engine()->registerPresentation(_CAST(Study, studyDS)->GetStudy(), fieldId, name.c_str(), label.c_str(), presentationId);
+
+
+  MEDCALC::MEDPresentationViewMode viewMode = MEDFactoryClient::getPresentationManager()->getPresentationViewMode(presentationId);
+
+  // Remove sibling presentations if view mode is set to REPLACE
+  if (viewMode == MEDCALC::VIEW_MODE_REPLACE) {
+    MED_ORB::PresentationsList* presList = _salomeModule->engine()->getSiblingPresentations(_CAST(Study, studyDS)->GetStudy(), presentationId);
+    CORBA::ULong size = presList->length();
+
+    std::stringstream sstm;
+    sstm << "Removing sibling presentation(s): ";
+    for (int i = 0; i < size; ++i)
+      sstm << (*presList)[i] << "  ";
+    STDLOG(sstm.str());
+
+    for (int i = 0; i < size; ++i) {
+      PresentationEvent* event = new PresentationEvent();
+      event->eventtype = PresentationEvent::EVENT_DELETE_PRESENTATION;
+      XmedDataObject* dataObject = new XmedDataObject();
+      dataObject->setPresentationId((*presList)[i]);
+      event->objectdata = dataObject;
+      emit presentationSignal(event); // --> WorkspaceController::processPresentationEvent
+    }
+
+    delete presList;
+  }
+
+  // update Object browser
+  _salomeModule->getApp()->updateObjectBrowser(true);
+}
+
+void
+PresentationController::updateTreeViewForPresentationRemoval(long presentationId)
+{
+  if (presentationId < 0) {
+    std::cerr << "Unknown presentation\n";
+    return;
+  }
+
+  SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(_salomeModule->application()->activeStudy());
+  _PTR(Study) studyDS = study->studyDS();
+
+  _salomeModule->engine()->unregisterPresentation(_CAST(Study, studyDS)->GetStudy(), presentationId);
 
   // update Object browser
   _salomeModule->getApp()->updateObjectBrowser(true);
@@ -252,6 +406,9 @@ PresentationController::processWorkspaceEvent(const MEDCALC::MedEvent* event)
   if ( event->type == MEDCALC::EVENT_ADD_PRESENTATION ) {
     this->updateTreeViewWithNewPresentation(event->dataId, event->presentationId);
   }
+  else if ( event->type == MEDCALC::EVENT_REMOVE_PRESENTATION ) {
+    this->updateTreeViewForPresentationRemoval(event->presentationId);
+  }
 }
 
 void
index 53c0272ad01f59a81344c81baef20745fce1a21c..d2d9fc4617f699895b3f84421bed7d272c71d103 100644 (file)
@@ -39,7 +39,8 @@ typedef struct {
     EVENT_VIEW_OBJECT_POINT_SPRITE,
     EVENT_VIEW_OBJECT_SCALAR_MAP,
     EVENT_VIEW_OBJECT_SLICES,
-    EVENT_VIEW_OBJECT_VECTOR_FIELD
+    EVENT_VIEW_OBJECT_VECTOR_FIELD,
+    EVENT_DELETE_PRESENTATION
   };
   int eventtype;
   XmedDataObject* objectdata;
@@ -72,16 +73,21 @@ protected slots:
   void OnVisualizeSlices();
   void OnVisualizeDeflectionShape();
   void OnVisualizePointSprite();
+
+  void OnDeletePresentation();
+
   void processWorkspaceEvent(const MEDCALC::MedEvent*);
 
 private:
   void visualize(PresentationEvent::EventType);
   void updateTreeViewWithNewPresentation(long, long);
+  void updateTreeViewForPresentationRemoval(long);
   std::string _getIconName(const std::string&);
 
 private:
   MEDModule* _salomeModule;
   SALOME_AppStudyEditor* _studyEditor; // borrowed to MEDModule
+
   QDockWidget *_dockWidget;
   WidgetPresentationParameters* _widgetPresentationParameters;
 };
index a7ce3c5e60a8839f44eeb59b0087de4597cfabef..a554668d76d6d2cd0029eb91ab49ef3028e228fa 100644 (file)
@@ -86,7 +86,8 @@ ProcessingController::OnChangeUnderlyingMesh()
   SALOME_StudyEditor::SObjectList* listOfSObject = _studyEditor->getSelectedObjects();
   if ( listOfSObject->size() > 0 ) {
     SALOMEDS::SObject_var soField = listOfSObject->at(0);
-    int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
+    //int fieldId = _studyEditor->getParameterInt(soField,FIELD_SERIES_ID);
+    int fieldId = _studyEditor->getParameterInt(soField,FIELD_ID);
     // _GBO_ : the dialog should not be modal, so that we can choose a
     // mesh in the browser. Then we have to emit a signal from the
     // dialog.accept, connected to a slot of the DatasourceControler
@@ -141,7 +142,7 @@ ProcessingController::OnInterpolateField()
   SALOME_StudyEditor::SObjectList* listOfSObject = _studyEditor->getSelectedObjects();
   if ( listOfSObject->size() > 0 ) {
     SALOMEDS::SObject_var soField = listOfSObject->at(0);
-    int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
+    int fieldId = _studyEditor->getParameterInt(soField,FIELD_ID);
     // _GBO_ : the dialog should not be modal, so that we can choose a
     // mesh in the browser. Then we have to emit a signal from the
     // dialog.accept, connected to a slot of the DatasourceControler
index 223eb7815cdd525aee6819d6888d244ce77fea4f..8a2231969f58aaa2312c0988c4220679b0247fb8 100644 (file)
@@ -308,7 +308,10 @@ void WorkspaceController::processMedEvent(const MEDCALC::MedEvent* event) {
     emit workspaceSignal(event); // forward to DatasourceController
   }
   else if ( event->type == MEDCALC::EVENT_ADD_PRESENTATION ) {
-    emit workspaceSignal(event); // forward to DatasourceController
+    emit workspaceSignal(event); // forward to PresentationController
+  }
+  else if ( event->type == MEDCALC::EVENT_REMOVE_PRESENTATION ) {
+    emit workspaceSignal(event); // forward to PresentationController
   }
   else if ( event->type == MEDCALC::EVENT_PLAY_TEST ) {
     emit workspaceSignal(event); // forward to TestController
@@ -511,12 +514,14 @@ void WorkspaceController::processDatasourceEvent(const DatasourceEvent* event) {
   }
   else if ( event->eventtype == DatasourceEvent::EVENT_ADD_DATASOURCE ) {
     QStringList commands;
-    commands += QString("medcalc.LoadDataSource('%1')").arg(event->objectalias);
+    commands += QString("source_id = medcalc.LoadDataSource('%1')").arg(event->objectalias);
+    commands += QString("source_id");
     _consoleDriver->exec(commands);
   }
   else if ( event->eventtype == DatasourceEvent::EVENT_ADD_IMAGE_AS_DATASOURCE ) {
     QStringList commands;
-    commands += QString("medcalc.LoadImageAsDataSource('%1')").arg(event->objectalias);
+    commands += QString("source_id = medcalc.LoadImageAsDataSource('%1')").arg(event->objectalias);
+    commands += QString("source_id");
     _consoleDriver->exec(commands);
   }
   else {
@@ -577,44 +582,55 @@ void WorkspaceController::processPresentationEvent(const PresentationEvent* even
     QString colorMap = _getColorMap();
     MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
     QStringList commands;
-    commands += QString("medcalc.MakeScalarMap(accessField(%1), %2, colorMap=%3)").arg(fieldHandler->id).arg(viewMode).arg(colorMap);
+    commands += QString("presentation_id = medcalc.MakeScalarMap(accessField(%1), %2, colorMap=%3)").arg(fieldHandler->id).arg(viewMode).arg(colorMap);
+    commands += QString("presentation_id");
     _consoleDriver->exec(commands);
   }
   else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_CONTOUR ) {
     QString viewMode = _getViewMode();
     MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
     QStringList commands;
-    commands += QString("medcalc.MakeContour(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+    commands += QString("presentation_id = medcalc.MakeContour(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+    commands += QString("presentation_id");
     _consoleDriver->exec(commands);
   }
   else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_VECTOR_FIELD ) {
     QString viewMode = _getViewMode();
     MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
     QStringList commands;
-    commands += QString("medcalc.MakeVectorField(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+    commands += QString("presentation_id = medcalc.MakeVectorField(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+    commands += QString("presentation_id");
     _consoleDriver->exec(commands);
   }
   else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SLICES ) {
     QString viewMode = _getViewMode();
     MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
     QStringList commands;
-    commands += QString("medcalc.MakeSlices(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+    commands += QString("presentation_id = medcalc.MakeSlices(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+    commands += QString("presentation_id");
     _consoleDriver->exec(commands);
   }
   else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_DEFLECTION_SHAPE ) {
     QString viewMode = _getViewMode();
     MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
     QStringList commands;
-    commands += QString("medcalc.MakeDeflectionShape(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+    commands += QString("presentation_id = medcalc.MakeDeflectionShape(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+    commands += QString("presentation_id");
     _consoleDriver->exec(commands);
   }
   else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_POINT_SPRITE ) {
     QString viewMode = _getViewMode();
     MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
     QStringList commands;
-    commands += QString("medcalc.MakePointSprite(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+    commands += QString("presentation_id = medcalc.MakePointSprite(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+    commands += QString("presentation_id");
     _consoleDriver->exec(commands);
   }
+  else if ( event->eventtype == PresentationEvent::EVENT_DELETE_PRESENTATION ) {
+      QStringList commands;
+      commands += QString("medcalc.RemovePresentation(%1)").arg(dataObject->getPresentationId());
+      _consoleDriver->exec(commands);
+  }
   else {
     STDLOG("The event "<<event->eventtype<<" is not implemented yet");
   }
index 62e37a660edd109d0957dec7bd04671ed52d4057..cb4b6fc15beb59807742727b8a656d04051e0fac 100644 (file)
@@ -27,7 +27,7 @@
 // =================================================================
 //
 
-XmedDataObject::XmedDataObject() : DataObject() {
+XmedDataObject::XmedDataObject() : DataObject(), _presId(-1) {
 }
 
 /*! This function specified the localization of the object in the
@@ -48,6 +48,13 @@ MEDCALC::FieldHandler * XmedDataObject::getFieldHandler() {
   return &_fieldHandler;
 }
 
+void XmedDataObject::setPresentationId(int presId) {
+  _presId = presId;
+}
+
+int XmedDataObject::getPresentationId() const { return _presId; }
+
+
 /*!
  * This function implements the convention for displaying a fieldname
  * characterized by its spatial discretisation type.
index 4027ccf6bc1683953f31775885ede3e100ac32ad..43f2252909e22267ce8ced04c23f73f3761a3212 100644 (file)
@@ -40,8 +40,12 @@ public:
   void setFieldHandler(MEDCALC::FieldHandler fieldHandler);
   MEDCALC::FieldHandler * getFieldHandler();
 
+  void setPresentationId(int presId);
+  int getPresentationId() const;
+
 private:
   MEDCALC::FieldHandler _fieldHandler;
+  int _presId;
   string _getTypedFieldLabel();
 };
 
index c51ca9bdaf466c2bca489456683705046014454f..26defc750ed7fa9f7bf981ccb46c612075832988 100644 (file)
@@ -66,7 +66,7 @@ void DlgChangeUnderlyingMesh::OnSelectMesh() {
     SALOMEDS::SObject_var soMesh = listOfSObject->at(0);
     // _GBO_ TODO: we should test here if it is a mesh (attribute in
     // the sobject)
-    _meshId = _studyEditor->getParameterInt(soMesh,OBJECT_ID);
+    _meshId = _studyEditor->getParameterInt(soMesh,MESH_ID);
     const char * meshname = _studyEditor->getName(soMesh);
     this->ui.txtMesh->setText(QString(meshname));
   }
index 8daf9886bfc68dcf117dc0e2400e50085d5519b3..4ef53c6f2ec3b36cfbb94bec799a0d93e348eaee 100644 (file)
@@ -115,7 +115,7 @@ void DlgInterpolateField::OnSelectMesh() {
     SALOMEDS::SObject_var soMesh = listOfSObject->at(0);
     // _GBO_ TODO: we should test here if it is a mesh (attribute in
     // the sobject)
-    _meshId = _studyEditor->getParameterInt(soMesh,OBJECT_ID);
+    _meshId = _studyEditor->getParameterInt(soMesh,MESH_ID);
     const char * meshname = _studyEditor->getName(soMesh);
     this->ui.txtMesh->setText(QString(meshname));
   }
index d314cfa355342193fd4587d2736196d590d283ef..380784b0200829cb8cc3d519c9e4fa3105abc5ca 100644 (file)
@@ -26,26 +26,6 @@ WidgetPresentationParameters::WidgetPresentationParameters(QWidget* parent)
   ui.setupUi(this); // To be done first
 }
 
-MEDCALC::MEDPresentationViewMode
-WidgetPresentationParameters::getViewMode() {
-  QString viewMode = this->ui.comboBoxViewMode->currentText();
-  if (viewMode == tr("LAB_VIEW_MODE_REPLACE")) {
-    return MEDCALC::VIEW_MODE_REPLACE;
-  }
-  else if (viewMode == tr("LAB_VIEW_MODE_OVERLAP")) {
-    return MEDCALC::VIEW_MODE_OVERLAP;
-  }
-  else if (viewMode == tr("LAB_VIEW_MODE_NEW_LAYOUT")) {
-    return MEDCALC::VIEW_MODE_NEW_LAYOUT;
-  }
-  else if (viewMode == tr("LAB_VIEW_MODE_SPLIT_VIEW")) {
-    return MEDCALC::VIEW_MODE_SPLIT_VIEW;
-  }
-  // Should not happen
-  STDLOG("Strange!! No matching view mode found - returning VIEW_MODE_REPLACE.");
-  return MEDCALC::VIEW_MODE_REPLACE;
-}
-
 std::string
 WidgetPresentationParameters::getField()
 {
index 7187e2ee65dc75b0a138720a6b1300d79f2f6a28..8e1905a8c9258fa7a9e81e88f30453836d2d7a94 100644 (file)
@@ -29,7 +29,7 @@
 
 #include <QObject>
 
-class WidgetPresentationParameters : public QWidget
+class MEDCALCGUI_DIALOGS_EXPORT WidgetPresentationParameters : public QWidget
 {
   Q_OBJECT
 
@@ -37,7 +37,6 @@ public:
   WidgetPresentationParameters(QWidget* parent = 0);
   virtual ~WidgetPresentationParameters() {}
 
-  MEDCALC::MEDPresentationViewMode getViewMode();
   std::string getField();
   std::string getScalarBarRange();
   double getScalarBarTimestep();
index 00882636e3fbef6ac6f7067e6bdd339ca8ae244d..291ef54fe787993fe09be5595110983c8d6a9f33 100644 (file)
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>404</width>
-    <height>230</height>
+    <height>200</height>
    </rect>
   </property>
   <property name="minimumSize">
    <string>Form</string>
   </property>
   <layout class="QGridLayout" name="gridLayout">
-   <item row="1" column="0">
+   <item row="0" column="0">
     <widget class="QLabel" name="label">
      <property name="text">
-      <string>LAB_FIELD</string>
+      <string>LAB_DISP_COMP</string>
      </property>
     </widget>
    </item>
-   <item row="1" column="1">
+   <item row="0" column="1">
     <widget class="QComboBox" name="comboBoxField">
      <item>
       <property name="text">
@@ -36,7 +36,7 @@
      </item>
     </widget>
    </item>
-   <item row="5" column="0">
+   <item row="4" column="0">
     <widget class="QLabel" name="labelTimeStep">
      <property name="enabled">
       <bool>false</bool>
      </property>
     </widget>
    </item>
-   <item row="5" column="1">
+   <item row="4" column="1">
     <widget class="QDoubleSpinBox" name="doubleSpinBoxTimeStep">
      <property name="enabled">
       <bool>false</bool>
      </property>
     </widget>
    </item>
-   <item row="6" column="0">
+   <item row="5" column="0">
     <widget class="QLabel" name="labelMinVal">
      <property name="enabled">
       <bool>false</bool>
      </property>
     </widget>
    </item>
-   <item row="6" column="1">
+   <item row="5" column="1">
     <widget class="QDoubleSpinBox" name="doubleSpinBoxMinVal">
      <property name="enabled">
       <bool>false</bool>
      </property>
     </widget>
    </item>
-   <item row="7" column="0">
+   <item row="6" column="0">
     <widget class="QLabel" name="labelMaxVal">
      <property name="enabled">
       <bool>false</bool>
      </property>
     </widget>
    </item>
-   <item row="7" column="1">
+   <item row="6" column="1">
     <widget class="QDoubleSpinBox" name="doubleSpinBoxMaxVal">
      <property name="enabled">
       <bool>false</bool>
      </property>
     </widget>
    </item>
-   <item row="8" column="0">
+   <item row="7" column="0">
     <widget class="QLabel" name="label_3">
      <property name="text">
       <string>LAB_COLOR_MAP</string>
      </property>
     </widget>
    </item>
-   <item row="8" column="1">
+   <item row="7" column="1">
     <widget class="QComboBox" name="comboBoxColorMap">
      <item>
       <property name="text">
      </item>
     </widget>
    </item>
-   <item row="0" column="0">
-    <widget class="QLabel" name="label_4">
-     <property name="text">
-      <string>LAB_VIEW_MODE</string>
-     </property>
-    </widget>
-   </item>
-   <item row="0" column="1">
-    <widget class="QComboBox" name="comboBoxViewMode">
-     <item>
-      <property name="text">
-       <string>LAB_VIEW_MODE_REPLACE</string>
-      </property>
-     </item>
-     <item>
-      <property name="text">
-       <string>LAB_VIEW_MODE_OVERLAP</string>
-      </property>
-     </item>
-     <item>
-      <property name="text">
-       <string>LAB_VIEW_MODE_NEW_LAYOUT</string>
-      </property>
-     </item>
-     <item>
-      <property name="text">
-       <string>LAB_VIEW_MODE_SPLIT_VIEW</string>
-      </property>
-     </item>
-    </widget>
-   </item>
-   <item row="4" column="1">
+   <item row="3" column="1">
     <widget class="QComboBox" name="comboBoxScalarBarRange">
      <property name="enabled">
       <bool>true</bool>
      </item>
     </widget>
    </item>
-   <item row="2" column="0">
+   <item row="1" column="0">
     <widget class="QLabel" name="label_2">
      <property name="text">
       <string>LAB_SCALARBAR</string>
      </property>
     </widget>
    </item>
-   <item row="4" column="0">
+   <item row="3" column="0">
     <widget class="QLabel" name="label_5">
      <property name="enabled">
       <bool>true</bool>
diff --git a/src/MEDCalc/res/close.png b/src/MEDCalc/res/close.png
new file mode 100755 (executable)
index 0000000..4364ce7
Binary files /dev/null and b/src/MEDCalc/res/close.png differ
index 620afc49aade6042906521c6f6e7f9a231fc55d0..329a4d3ae30b87adb5c1d51838b82971be8ab48a 100644 (file)
@@ -36,13 +36,17 @@ SET(_test_files
 )
 
 # Install rules
-SALOME_INSTALL_SCRIPTS(test_qttesting.py ${SALOME_MED_INSTALL_TEST}/MEDCalc)
-SALOME_INSTALL_SCRIPTS(${CMAKE_CURRENT_BINARY_DIR}/medcalc_testutils.py ${SALOME_MED_INSTALL_TEST}/MEDCalc)
+SET(TEST_INSTALL_DIRECTORY ${SALOME_MED_INSTALL_TEST}/MEDCalc)
+
+SALOME_INSTALL_SCRIPTS(test_qttesting.py ${TEST_INSTALL_DIRECTORY})
+SALOME_INSTALL_SCRIPTS(${CMAKE_CURRENT_BINARY_DIR}/medcalc_testutils.py ${TEST_INSTALL_DIRECTORY})
 
 SALOME_INSTALL_SCRIPTS("${_test_scripts}" ${SALOME_INSTALL_PYTHON}/tests)
+
 INSTALL(FILES ${_test_scenarii} DESTINATION ${SALOME_MED_INSTALL_RES_DATA}/tests/scenarios)
 INSTALL(FILES ${_test_baselines} DESTINATION ${SALOME_MED_INSTALL_RES_DATA}/tests/baselines)
 INSTALL(FILES ${_test_files} DESTINATION ${SALOME_MED_INSTALL_RES_DATA}/tests/medfiles)
 
-INSTALL(FILES CTestTestfileInstall.cmake DESTINATION ${SALOME_MED_INSTALL_TEST}/MEDCalc RENAME CTestTestfile.cmake)
+INSTALL(FILES CTestTestfileInstall.cmake
+  DESTINATION ${TEST_INSTALL_DIRECTORY}
+  RENAME CTestTestfile.cmake)
index f0491770c4e141150487b47de958e6056cffaf59..ef479a14e216708f8a79d3ee49c18f2fb94a543f 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2015-2016  CEA/DEN, EDF R&D
+# 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
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
-SET(COMPONENT_NAME MEDCALC)
-SET(TIMEOUT        180)   # the GUI needs to start - so let some time here!
+SET(TEST_NAMES
+  test_qttesting
+)
 
-ADD_TEST(MEDCalcQtTesting python test_qttesting.py)
-SET_TESTS_PROPERTIES(MEDCalcQtTesting PROPERTIES LABELS "${COMPONENT_NAME}")
+FOREACH(tfile ${TEST_NAMES})
+  SET(TEST_NAME ${COMPONENT_NAME}_${tfile})
+  ADD_TEST(${TEST_NAME} python ${tfile}.py)
+  SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES
+    LABELS "${COMPONENT_NAME}"
+    TIMEOUT ${TIMEOUT}
+    )
+ENDFOREACH()
index 4a547e3d11d15cc0deef56369f4bf384a9e63d7c..e059b853bddeafe048c58892f7d5c5cfc694aebf 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2011-2016  CEA/DEN, EDF R&D
+# 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
@@ -26,7 +26,7 @@ class MEDGUITest(unittest.TestCase):
     unittest.TestCase.__init__(self, methodName=methodName)
     self._tmpDir = ""
     self._removeDir = True
-    
+
   def setUp(self):
     import tempfile
     self._tmpDir = tempfile.mkdtemp(prefix="med_gui_tests_")
@@ -37,7 +37,7 @@ class MEDGUITest(unittest.TestCase):
     unittest.TestCase.tearDown(self)
     if self._removeDir:
       shutil.rmtree(self._tmpDir, False)
-    
+
   def getTestName(self):
     """ Return name of the test being currently executed. """
     return self.id().split(".")[-1]
@@ -61,13 +61,15 @@ class MEDGUITest(unittest.TestCase):
     Assert if not matching. """
     import filecmp
     from medcalc_testutils import GetBaselineDir
-    
+
     base_pth = os.path.join(GetBaselineDir(), basename)
     gen_path = os.path.join(self._tmpDir, basename)
     print base_pth, gen_path
     try:
       ret = filecmp.cmp(base_pth, gen_path, shallow=False)
     except OSError:
+      import traceback
+      traceback.print_exc()
       ret = False
     if not ret:
       # Keep file if comparison fails
@@ -90,7 +92,7 @@ class MEDGUITest(unittest.TestCase):
     filedata = filedata.replace("/tmp/%s" % med_file, os.path.join(GetMEDFileDir(), med_file))
     with open(scen_pth2,'w') as f:
       f.write(filedata)
-      
+
   ##
   ## Now the tests themselves
   ##
index 01f092cce296301d8fa98d5f873441563d2a96ca..0877a8c1d098bbf1fbb98537f7e23c29fcbb23b5 100644 (file)
@@ -45,6 +45,7 @@ from medpresentation import MakeVectorField
 from medpresentation import MakeSlices
 from medpresentation import MakeDeflectionShape
 from medpresentation import MakePointSprite
+from medpresentation import RemovePresentation
 
 # Console commands
 import medconsole
index 6c3c28d711802337e8fae9466598fe60fab78736..2c819f6b3a38a86524c9cc4fb800394825b5b543 100644 (file)
@@ -109,15 +109,17 @@ def notifyGui_removeFromWorkspace(fieldId):
 def notifyGui_cleanWorkspace():
   __notifyGui(MEDCALC.EVENT_CLEAN_WORKSPACE)
 #
-def notifyGui_addDatasource(filename):
-  __notifyGui(MEDCALC.EVENT_ADD_DATASOURCE, filename=filename)
+def notifyGui_addDatasource(handlerId, filename):
+  __notifyGui(MEDCALC.EVENT_ADD_DATASOURCE, dataId=handlerId, filename=filename)
 #
 def notifyGui_addPresentation(fieldId, presId):
   __notifyGui(MEDCALC.EVENT_ADD_PRESENTATION, dataId=fieldId, presentationId=presId)
 #
+def notifyGui_removePresentation(presId):
+  __notifyGui(MEDCALC.EVENT_REMOVE_PRESENTATION, presentationId=presId)
+#
 def notifyGui_playQtTestingScenario(filename):
   __notifyGui(MEDCALC.EVENT_PLAY_TEST, filename=filename)
 #
 def notifyGui_termination():
   __notifyGui(MEDCALC.EVENT_QUIT_SALOME)
-
index b0c42e23ec8bfc29cec25eb43b28a03131723140..364fbba3fa5fba607fa9692ba52c0cc8e18e3df3 100644 (file)
@@ -21,9 +21,10 @@ import medcalc
 
 def LoadDataSource(filename):
   dataManager = medcalc.medcorba.factory.getDataManager()
-  dataManager.loadDatasource(filename)
+  handler = dataManager.loadDatasource(filename)
   from medcalc.medevents import notifyGui_addDatasource
-  notifyGui_addDatasource(filename)
+  notifyGui_addDatasource(handler.id, filename)
+  return handler.id
 #
 
 def LoadImageAsDataSource(filename):
@@ -36,5 +37,5 @@ def LoadImageAsDataSource(filename):
   from medimages import FieldBuilder
   builder = FieldBuilder()
   builder.image2med(filename, medfilename)
-  LoadDataSource(medfilename)
+  return LoadDataSource(medfilename)
 #
index fd1100627f61c7e55ea099ec3023c95110d7480d..c48eebd485bf085a12eb97b33bfc3c4d388afe1c 100644 (file)
@@ -19,7 +19,7 @@
 
 import medcalc
 import MEDCALC
-from medcalc.medevents import notifyGui_addPresentation
+from medcalc.medevents import notifyGui_addPresentation, notifyGui_removePresentation
 
 __manager = medcalc.medcorba.factory.getPresentationManager()
 
@@ -35,6 +35,7 @@ def MakeScalarMap(proxy,
   params = MEDCALC.ScalarMapParameters(proxy.id, viewMode, displayedInfo, scalarBarRange, colorMap)
   presentation_id = __manager.makeScalarMap(params)
   notifyGui_addPresentation(proxy.id, presentation_id)
+  return presentation_id
 #
 
 def MakeContour(proxy,
@@ -48,6 +49,7 @@ def MakeContour(proxy,
   params = MEDCALC.ContourParameters(proxy.id, viewMode, displayedInfo, scalarBarRange, colorMap, nbContours)
   presentation_id = __manager.makeContour(params)
   notifyGui_addPresentation(proxy.id, presentation_id)
+  return presentation_id
 #
 
 def MakeVectorField(proxy,
@@ -56,6 +58,7 @@ def MakeVectorField(proxy,
   params = MEDCALC.VectorFieldParameters(proxy.id, viewMode)
   presentation_id = __manager.makeVectorField(params)
   notifyGui_addPresentation(proxy.id, presentation_id)
+  return presentation_id
 #
 
 def MakeSlices(proxy,
@@ -66,6 +69,7 @@ def MakeSlices(proxy,
   params = MEDCALC.SlicesParameters(proxy.id, viewMode, orientation, nbSlices)
   presentation_id = __manager.makeSlices(params)
   notifyGui_addPresentation(proxy.id, presentation_id)
+  return presentation_id
 #
 
 def MakeDeflectionShape(proxy,
@@ -74,6 +78,7 @@ def MakeDeflectionShape(proxy,
   params = MEDCALC.DeflectionShapeParameters(proxy.id, viewMode)
   presentation_id = __manager.makeDeflectionShape(params)
   notifyGui_addPresentation(proxy.id, presentation_id)
+  return presentation_id
 #
 
 def MakePointSprite(proxy,
@@ -86,4 +91,11 @@ def MakePointSprite(proxy,
   params = MEDCALC.PointSpriteParameters(proxy.id, viewMode, displayedInfo, scalarBarRange, colorMap)
   presentation_id = __manager.makePointSprite(params)
   notifyGui_addPresentation(proxy.id, presentation_id)
+  return presentation_id
+#
+
+def RemovePresentation(presentation_id):
+  ok = __manager.removePresentation(presentation_id)
+  if ok:
+    notifyGui_removePresentation(presentation_id)
 #
index 0043ee90a7b0ffa6adc3b0263a9352bfcc09baf6..8dbaa37748ba12f6614b9e920ca4a8df7621bbc8 100644 (file)
@@ -45,7 +45,7 @@ INSTALL(TARGETS TestMEDCalculator DESTINATION ${SALOME_INSTALL_BINS})
 
 # Application tests
 
-SET(TEST_INSTALL_DIRECTORY ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test/MEDCoupling/MEDCalculator)
+SET(TEST_INSTALL_DIRECTORY ${SALOME_MED_INSTALL_TEST}/MEDCalculator)
 INSTALL(TARGETS TestMEDCalculator DESTINATION ${TEST_INSTALL_DIRECTORY})
 
 INSTALL(FILES CTestTestfileInstall.cmake
index 20cb6a16f8e3fc31fd521ecd21a0f45f688e0db7..e79a45278935f121ef1e5953472efcebde744c5a 100644 (file)
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
-ADD_TEST(TestMEDCalculator TestMEDCalculator)
-SET_TESTS_PROPERTIES(TestMEDCalculator PROPERTIES LABELS "${COMPONENT_NAME}")
+SET(TEST_NAMES
+  TestMEDCalculator
+)
+
+FOREACH(tfile ${TEST_NAMES})
+  SET(TEST_NAME ${COMPONENT_NAME}_${tfile})
+  ADD_TEST(${TEST_NAME} ${tfile})
+  SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES
+    LABELS "${COMPONENT_NAME}"
+    TIMEOUT ${TIMEOUT}
+    )
+ENDFOREACH()