Salome HOME
[MEDCalc] Preparation for presentation edition: connect double click
authorCédric Aguerre <cedric.aguerre@edf.fr>
Thu, 31 Mar 2016 16:36:00 +0000 (18:36 +0200)
committerCédric Aguerre <cedric.aguerre@edf.fr>
Thu, 31 Mar 2016 16:40:40 +0000 (18:40 +0200)
16 files changed:
src/MEDCalc/CMakeLists.txt
src/MEDCalc/MEDCalcConstants.hxx [new file with mode: 0644]
src/MEDCalc/cmp/CMakeLists.txt
src/MEDCalc/cmp/MED.cxx
src/MEDCalc/gui/CMakeLists.txt
src/MEDCalc/gui/DatasourceConstants.hxx [deleted file]
src/MEDCalc/gui/DatasourceController.cxx
src/MEDCalc/gui/MEDModule.cxx
src/MEDCalc/gui/MEDModule.hxx
src/MEDCalc/gui/PresentationController.cxx
src/MEDCalc/gui/ProcessingController.cxx
src/MEDCalc/gui/XmedDataModel.cxx
src/MEDCalc/gui/XmedDataModel.hxx
src/MEDCalc/gui/dialogs/CMakeLists.txt
src/MEDCalc/gui/dialogs/DlgChangeUnderlyingMesh.cxx
src/MEDCalc/gui/dialogs/DlgInterpolateField.cxx

index d65662dc571c2796279b9c4d9eeafaa345d5c889..a0815a29fca2fabac4763f367882eab2a0ee255c 100644 (file)
@@ -28,3 +28,5 @@ IF(SALOME_MED_ENABLE_PYTHON)
   ADD_SUBDIRECTORY(tui)
   ADD_SUBDIRECTORY(exe)
 ENDIF()
+
+INSTALL(FILES MEDCalcConstants.hxx DESTINATION ${SALOME_INSTALL_HEADERS})
diff --git a/src/MEDCalc/MEDCalcConstants.hxx b/src/MEDCalc/MEDCalcConstants.hxx
new file mode 100644 (file)
index 0000000..995cb14
--- /dev/null
@@ -0,0 +1,32 @@
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// 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
+//
+
+// 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"
+
+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 2ba66eb94eb9542d25fc9f4687db0599e5ca3da3..7ae135aa37296dbe2babf5e94eda61b5f26bf87b 100644 (file)
@@ -27,6 +27,7 @@ INCLUDE_DIRECTORIES(
   ${PYTHON_INCLUDE_DIRS}
   ${MEDCOUPLING_INCLUDE_DIRS}
   ${CMAKE_CURRENT_BINARY_DIR}
+  ${CMAKE_CURRENT_SOURCE_DIR}/..
   ${PROJECT_BINARY_DIR}/idl
 )
 
index b937447dbec18d6a023dfdbe2a824887fa993db9..6eae6c580fdec128a65011e94ca76c7f900c78ae 100644 (file)
 //
 
 #include "MED.hxx"
-
 #include "MEDFactoryClient.hxx"
+#include <MEDCalcConstants.hxx>
 
 #include <SALOMEconfig.h>
 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
 
 #include <SALOMEDS_SObject.hxx>
-
 #include <Utils_ExceptHandlers.hxx>
 
 #include <string>
@@ -58,15 +57,6 @@ MED::~MED()
   // nothing to do
 }
 
-// Duplicate gui/DatasourceConstants
-#define OBJECT_ID              "objectid"
-#define OBJECT_IS_IN_WORKSPACE "isInWorkspace"
-
-// Duplicate gui/XmedDataModel
-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" };
-
 MED_ORB::status
 MED::addDatasourceToStudy(SALOMEDS::Study_ptr study,
                           const MEDCALC::DatasourceHandler& datasourceHandler)
@@ -202,6 +192,13 @@ MED::registerPresentation(SALOMEDS::Study_ptr study,
   soPresentation->SetAttrString("AttributeName", name);
   soPresentation->SetAttrString("AttributePixMap", label);
 
+  SALOMEDS::GenericAttribute_var anAttr;
+  SALOMEDS::AttributeParameter_var aParam;
+  anAttr = studyBuilder->FindOrCreateAttribute(soPresentation, "AttributeParameter");
+  aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
+  aParam->SetInt(FIELD_ID, fieldId);
+  aParam->SetBool(IS_PRESENTATION, true);
+
   result = MED_ORB::OP_OK;
   return result;
 }
index 125b6099530f4981ca16ce236ee03faa6092ae68..b51c1432b4ef48d174f7a46ab5ecde1ec7cd714a 100644 (file)
@@ -46,6 +46,7 @@ INCLUDE_DIRECTORIES(
   ${CMAKE_CURRENT_BINARY_DIR}
   ${CMAKE_CURRENT_SOURCE_DIR}/dialogs
   ${CMAKE_CURRENT_BINARY_DIR}/dialogs
+  ${CMAKE_CURRENT_SOURCE_DIR}/..
   ${CMAKE_CURRENT_SOURCE_DIR}/../cmp
   ${CMAKE_CURRENT_SOURCE_DIR}/../../MEDGUI
   ${PROJECT_BINARY_DIR}/idl
diff --git a/src/MEDCalc/gui/DatasourceConstants.hxx b/src/MEDCalc/gui/DatasourceConstants.hxx
deleted file mode 100644 (file)
index 891c3d3..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// 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
-//
-
-// 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"
index bd939552487b53f11e7c8a946717e1ad6234df1d..a3f7cd0be7db6396f53d0767f64f43931b716ad0 100644 (file)
@@ -20,7 +20,7 @@
 // Author : Guillaume Boulant (EDF)
 
 #include "DatasourceController.hxx"
-#include "DatasourceConstants.hxx"
+#include <MEDCalcConstants.hxx>
 
 #include <SalomeApp_Application.h>
 #include <SalomeApp_Study.h>
index 3a8848dccd039676e4ee7bd706405d3eacf038de..c40bbe231b300f1c340483d29da6de13206ef4f9 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "MEDModule.hxx"
 #include "QtHelper.hxx"
+#include <MEDCalcConstants.hxx>
 
 #include "SALOME_LifeCycleCORBA.hxx"
 #include "QtxPopupMgr.h"
 #include <SUIT_Desktop.h>
 #include <SUIT_ResourceMgr.h>
 #include <SUIT_Session.h>
+#include <SUIT_DataBrowser.h>
 #include <SalomeApp_Study.h>
+#include <SalomeApp_DataObject.h>
+#include <SalomeApp_DataModel.h>
+
+#include <SALOMEconfig.h>
+#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
+#include <SALOMEDS_SObject.hxx>
+#include <SALOMEDS_Study.hxx>
 
 #ifndef DISABLE_PVVIEWER
 #include "PVViewer_ViewModel.h"
 #endif
 
+#include <sstream>
+
 //! The only instance of the reference to engine
 MED_ORB::MED_Gen_var MEDModule::myEngine;
 
@@ -85,6 +96,11 @@ MEDModule::initialize( CAM_Application* app )
   // call the parent implementation
   SalomeApp_Module::initialize( app );
 
+  if (app && app->desktop()) {
+    connect((QObject*) (getApp()->objectBrowser()->treeView()), SIGNAL(doubleClicked(const QModelIndex&)),
+            this, SLOT(onDblClick(const QModelIndex&)));
+  }
+
   // The following initializes the GUI widget and associated actions
   this->createModuleWidgets();
   this->createModuleActions();
@@ -287,3 +303,49 @@ MEDModule::getSelectedColorMap()
 {
   return _presentationController->getSelectedColorMap();
 }
+
+void
+MEDModule::onDblClick(const QModelIndex& index)
+{
+  DataObjectList dol = getApp()->objectBrowser()->getSelected();
+  if (dol.isEmpty())
+    return;
+  SalomeApp_DataObject* item = dynamic_cast<SalomeApp_DataObject*>(dol[0]);
+  if (!item)
+    return;
+  SalomeApp_DataModel *model = dynamic_cast<SalomeApp_DataModel*>(dataModel());
+  if (!model)
+    return;
+
+  if (item->componentDataType().toStdString() != "MED")
+    return;
+  _PTR(SObject) obj = item->object();
+  _PTR(GenericAttribute) anAttribute;
+
+  if (! obj->FindAttribute(anAttribute, "AttributeName"))
+    return;
+  _PTR(AttributeName) attrName(anAttribute);
+  std::string name = attrName->Value();
+
+  if (! obj->FindAttribute(anAttribute, "AttributeParameter"))
+    return;
+  _PTR(AttributeParameter) attrParam(anAttribute);
+  if (! attrParam->IsSet(IS_PRESENTATION, PT_BOOLEAN)
+      || ! attrParam->GetBool(IS_PRESENTATION)) { // Not a presentation
+    return;
+  }
+  if (!attrParam->IsSet(FIELD_ID, PT_INTEGER))
+    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());
+  std::ostringstream oss;
+  oss << fieldId;
+  STDLOG("    - Field id:          " + oss.str());
+  STDLOG("    - Presentation name: " + name);
+
+}
index cec0dbf4afe131518b94192a04aa2e18f0799ffa..f05d6616e834e2d5b5c745e9831bff3886e7ce0c 100644 (file)
@@ -37,6 +37,8 @@
 #include CORBA_CLIENT_HEADER(MED_Gen)
 #include CORBA_SERVER_HEADER(MEDPresentationManager)
 
+#include <QModelIndex>
+
 class SalomeApp_Application;
 
 /*!
@@ -83,6 +85,7 @@ public:
 public slots:
   virtual bool activateModule(SUIT_Study* theStudy);
   virtual bool deactivateModule(SUIT_Study* theStudy);
+  virtual void onDblClick(const QModelIndex& index);
 
 private:
   void createModuleWidgets();
index 9a28d60c78d4cd0b01142a95da7c41fa500241a7..ceaf424bb527c281bd1337b1967ad7898b1184d8 100644 (file)
@@ -18,7 +18,7 @@
 //
 
 #include "PresentationController.hxx"
-#include "DatasourceConstants.hxx"
+#include <MEDCalcConstants.hxx>
 #include "MEDModule.hxx"
 #include "Basics_Utils.hxx"
 #include "QtxActionGroup.h"
index 35cdb73953cc1e143ce60d1f9347f5915f0984b0..a7ce3c5e60a8839f44eeb59b0087de4597cfabef 100644 (file)
@@ -18,7 +18,7 @@
 //
 
 #include "ProcessingController.hxx"
-#include "DatasourceConstants.hxx"
+#include <MEDCalcConstants.hxx>
 
 #include "MEDFactoryClient.hxx"
 #include "MEDModule.hxx"
index fbe391186f3891a5a25147d92919dc282be5a0c8..62e37a660edd109d0957dec7bd04671ed52d4057 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "XmedDataModel.hxx"
 #include <Basics_Utils.hxx>
+#include "MEDCalcConstants.hxx"
 
 //
 // =================================================================
@@ -47,8 +48,6 @@ MEDCALC::FieldHandler * XmedDataObject::getFieldHandler() {
   return &_fieldHandler;
 }
 
-const char * XmedDataObject::mapTypeOfFieldLabel[XmedDataObject::NB_TYPE_OF_FIELDS] =
-  {"ON_CELLS", "ON_NODES", "ON_GAUSS_PT", "ON_GAUSS_NE" };
 /*!
  * This function implements the convention for displaying a fieldname
  * characterized by its spatial discretisation type.
@@ -64,7 +63,7 @@ string XmedDataObject::_getTypedFieldLabel() {
   // 2 = ON_GAUSS_PT
   // 3 = ON_GAUSS_NE
   if ( _fieldHandler.type < 0 ||
-       _fieldHandler.type >= XmedDataObject::NB_TYPE_OF_FIELDS ) {
+       _fieldHandler.type >= NB_TYPE_OF_FIELDS ) {
     return string("UNKNOWN");
   }
   string label(_fieldHandler.fieldname);
index 75a3dcec3021d2c22878979b2277eaff4605f4ba..4027ccf6bc1683953f31775885ede3e100ac32ad 100644 (file)
@@ -40,9 +40,6 @@ public:
   void setFieldHandler(MEDCALC::FieldHandler fieldHandler);
   MEDCALC::FieldHandler * getFieldHandler();
 
-  static const int NB_TYPE_OF_FIELDS = 4;
-  static const char *  mapTypeOfFieldLabel[NB_TYPE_OF_FIELDS];
-
 private:
   MEDCALC::FieldHandler _fieldHandler;
   string _getTypedFieldLabel();
index 138719d3cbc6e1d52a06150dff014ff35f6bbff4..6fda54173c12586a6e6ff39bffa4e3077d55ba67 100644 (file)
@@ -40,6 +40,7 @@ INCLUDE_DIRECTORIES(
   ${CMAKE_CURRENT_BINARY_DIR}
   ${GUI_INCLUDE_DIRS}
   ${CMAKE_CURRENT_SOURCE_DIR}/..
+  ${CMAKE_CURRENT_SOURCE_DIR}/../..
   ${PROJECT_BINARY_DIR}/idl
 )
 
index 7a711a94d2cb74a3dd7af79d795c433a8e66353f..c51ca9bdaf466c2bca489456683705046014454f 100644 (file)
@@ -18,7 +18,7 @@
 //
 
 #include "DlgChangeUnderlyingMesh.hxx"
-#include "DatasourceConstants.hxx"
+#include <MEDCalcConstants.hxx>
 
 #include <QString>
 #include <QMessageBox>
index 677db864d14d68e82f71e156f02071aadc336bcb..8daf9886bfc68dcf117dc0e2400e50085d5519b3 100644 (file)
@@ -18,7 +18,7 @@
 //
 
 #include "DlgInterpolateField.hxx"
-#include "DatasourceConstants.hxx"
+#include <MEDCalcConstants.hxx>
 
 #include <QString>
 #include <QMessageBox>