From: Cédric Aguerre Date: Thu, 31 Mar 2016 16:36:00 +0000 (+0200) Subject: [MEDCalc] Preparation for presentation edition: connect double click X-Git-Tag: V8_1_0a1~13 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fdebd143a8ada98b760e8ff2dec38877ff3eec68;p=modules%2Fmed.git [MEDCalc] Preparation for presentation edition: connect double click --- 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/MEDCalcConstants.hxx b/src/MEDCalc/MEDCalcConstants.hxx new file mode 100644 index 000000000..995cb149b --- /dev/null +++ b/src/MEDCalc/MEDCalcConstants.hxx @@ -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" 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/DatasourceConstants.hxx b/src/MEDCalc/gui/DatasourceConstants.hxx deleted file mode 100644 index 891c3d3d9..000000000 --- a/src/MEDCalc/gui/DatasourceConstants.hxx +++ /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" 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