From fdebd143a8ada98b760e8ff2dec38877ff3eec68 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Aguerre?= Date: Thu, 31 Mar 2016 18:36:00 +0200 Subject: [PATCH] [MEDCalc] Preparation for presentation edition: connect double click --- src/MEDCalc/CMakeLists.txt | 2 + ...urceConstants.hxx => MEDCalcConstants.hxx} | 9 +++ src/MEDCalc/cmp/CMakeLists.txt | 1 + src/MEDCalc/cmp/MED.cxx | 19 +++--- src/MEDCalc/gui/CMakeLists.txt | 1 + src/MEDCalc/gui/DatasourceController.cxx | 2 +- src/MEDCalc/gui/MEDModule.cxx | 62 +++++++++++++++++++ src/MEDCalc/gui/MEDModule.hxx | 3 + src/MEDCalc/gui/PresentationController.cxx | 2 +- src/MEDCalc/gui/ProcessingController.cxx | 2 +- src/MEDCalc/gui/XmedDataModel.cxx | 5 +- src/MEDCalc/gui/XmedDataModel.hxx | 3 - src/MEDCalc/gui/dialogs/CMakeLists.txt | 1 + .../gui/dialogs/DlgChangeUnderlyingMesh.cxx | 2 +- .../gui/dialogs/DlgInterpolateField.cxx | 2 +- 15 files changed, 94 insertions(+), 22 deletions(-) rename src/MEDCalc/{gui/DatasourceConstants.hxx => MEDCalcConstants.hxx} (80%) diff --git a/src/MEDCalc/CMakeLists.txt b/src/MEDCalc/CMakeLists.txt index d65662dc5..a0815a29f 100644 --- a/src/MEDCalc/CMakeLists.txt +++ b/src/MEDCalc/CMakeLists.txt @@ -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/gui/DatasourceConstants.hxx b/src/MEDCalc/MEDCalcConstants.hxx similarity index 80% rename from src/MEDCalc/gui/DatasourceConstants.hxx rename to src/MEDCalc/MEDCalcConstants.hxx index 891c3d3d9..995cb149b 100644 --- a/src/MEDCalc/gui/DatasourceConstants.hxx +++ b/src/MEDCalc/MEDCalcConstants.hxx @@ -21,3 +21,12 @@ // 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" diff --git a/src/MEDCalc/cmp/CMakeLists.txt b/src/MEDCalc/cmp/CMakeLists.txt index 2ba66eb94..7ae135aa3 100644 --- a/src/MEDCalc/cmp/CMakeLists.txt +++ b/src/MEDCalc/cmp/CMakeLists.txt @@ -27,6 +27,7 @@ INCLUDE_DIRECTORIES( ${PYTHON_INCLUDE_DIRS} ${MEDCOUPLING_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/.. ${PROJECT_BINARY_DIR}/idl ) diff --git a/src/MEDCalc/cmp/MED.cxx b/src/MEDCalc/cmp/MED.cxx index b937447db..6eae6c580 100644 --- a/src/MEDCalc/cmp/MED.cxx +++ b/src/MEDCalc/cmp/MED.cxx @@ -18,14 +18,13 @@ // #include "MED.hxx" - #include "MEDFactoryClient.hxx" +#include #include #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) #include - #include #include @@ -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; } diff --git a/src/MEDCalc/gui/CMakeLists.txt b/src/MEDCalc/gui/CMakeLists.txt index 125b60995..b51c1432b 100644 --- a/src/MEDCalc/gui/CMakeLists.txt +++ b/src/MEDCalc/gui/CMakeLists.txt @@ -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/DatasourceController.cxx b/src/MEDCalc/gui/DatasourceController.cxx index bd9395524..a3f7cd0be 100644 --- a/src/MEDCalc/gui/DatasourceController.cxx +++ b/src/MEDCalc/gui/DatasourceController.cxx @@ -20,7 +20,7 @@ // Author : Guillaume Boulant (EDF) #include "DatasourceController.hxx" -#include "DatasourceConstants.hxx" +#include #include #include diff --git a/src/MEDCalc/gui/MEDModule.cxx b/src/MEDCalc/gui/MEDModule.cxx index 3a8848dcc..c40bbe231 100644 --- a/src/MEDCalc/gui/MEDModule.cxx +++ b/src/MEDCalc/gui/MEDModule.cxx @@ -21,6 +21,7 @@ #include "MEDModule.hxx" #include "QtHelper.hxx" +#include #include "SALOME_LifeCycleCORBA.hxx" #include "QtxPopupMgr.h" @@ -29,12 +30,22 @@ #include #include #include +#include #include +#include +#include + +#include +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) +#include +#include #ifndef DISABLE_PVVIEWER #include "PVViewer_ViewModel.h" #endif +#include + //! 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(dol[0]); + if (!item) + return; + SalomeApp_DataModel *model = dynamic_cast(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); + +} diff --git a/src/MEDCalc/gui/MEDModule.hxx b/src/MEDCalc/gui/MEDModule.hxx index cec0dbf4a..f05d6616e 100644 --- a/src/MEDCalc/gui/MEDModule.hxx +++ b/src/MEDCalc/gui/MEDModule.hxx @@ -37,6 +37,8 @@ #include CORBA_CLIENT_HEADER(MED_Gen) #include CORBA_SERVER_HEADER(MEDPresentationManager) +#include + 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(); diff --git a/src/MEDCalc/gui/PresentationController.cxx b/src/MEDCalc/gui/PresentationController.cxx index 9a28d60c7..ceaf424bb 100644 --- a/src/MEDCalc/gui/PresentationController.cxx +++ b/src/MEDCalc/gui/PresentationController.cxx @@ -18,7 +18,7 @@ // #include "PresentationController.hxx" -#include "DatasourceConstants.hxx" +#include #include "MEDModule.hxx" #include "Basics_Utils.hxx" #include "QtxActionGroup.h" diff --git a/src/MEDCalc/gui/ProcessingController.cxx b/src/MEDCalc/gui/ProcessingController.cxx index 35cdb7395..a7ce3c5e6 100644 --- a/src/MEDCalc/gui/ProcessingController.cxx +++ b/src/MEDCalc/gui/ProcessingController.cxx @@ -18,7 +18,7 @@ // #include "ProcessingController.hxx" -#include "DatasourceConstants.hxx" +#include #include "MEDFactoryClient.hxx" #include "MEDModule.hxx" diff --git a/src/MEDCalc/gui/XmedDataModel.cxx b/src/MEDCalc/gui/XmedDataModel.cxx index fbe391186..62e37a660 100644 --- a/src/MEDCalc/gui/XmedDataModel.cxx +++ b/src/MEDCalc/gui/XmedDataModel.cxx @@ -19,6 +19,7 @@ #include "XmedDataModel.hxx" #include +#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); diff --git a/src/MEDCalc/gui/XmedDataModel.hxx b/src/MEDCalc/gui/XmedDataModel.hxx index 75a3dcec3..4027ccf6b 100644 --- a/src/MEDCalc/gui/XmedDataModel.hxx +++ b/src/MEDCalc/gui/XmedDataModel.hxx @@ -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(); diff --git a/src/MEDCalc/gui/dialogs/CMakeLists.txt b/src/MEDCalc/gui/dialogs/CMakeLists.txt index 138719d3c..6fda54173 100644 --- a/src/MEDCalc/gui/dialogs/CMakeLists.txt +++ b/src/MEDCalc/gui/dialogs/CMakeLists.txt @@ -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 ) diff --git a/src/MEDCalc/gui/dialogs/DlgChangeUnderlyingMesh.cxx b/src/MEDCalc/gui/dialogs/DlgChangeUnderlyingMesh.cxx index 7a711a94d..c51ca9bda 100644 --- a/src/MEDCalc/gui/dialogs/DlgChangeUnderlyingMesh.cxx +++ b/src/MEDCalc/gui/dialogs/DlgChangeUnderlyingMesh.cxx @@ -18,7 +18,7 @@ // #include "DlgChangeUnderlyingMesh.hxx" -#include "DatasourceConstants.hxx" +#include #include #include diff --git a/src/MEDCalc/gui/dialogs/DlgInterpolateField.cxx b/src/MEDCalc/gui/dialogs/DlgInterpolateField.cxx index 677db864d..8daf9886b 100644 --- a/src/MEDCalc/gui/dialogs/DlgInterpolateField.cxx +++ b/src/MEDCalc/gui/dialogs/DlgInterpolateField.cxx @@ -18,7 +18,7 @@ // #include "DlgInterpolateField.hxx" -#include "DatasourceConstants.hxx" +#include #include #include -- 2.39.2