From afa6a20404fdd8def7ebc3b7a3145b342ed902d3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Aguerre?= Date: Tue, 21 Jul 2015 17:04:44 +0200 Subject: [PATCH] define the skeloeton for presentations --- idl/CMakeLists.txt | 1 + idl/MEDOPFactory.idl | 4 +- idl/MEDPresentationManager.idl | 38 +++++++++++++ src/MEDOP/cmp/CMakeLists.txt | 2 + src/MEDOP/cmp/MEDOPFactory_i.cxx | 7 +++ src/MEDOP/cmp/MEDOPFactory_i.hxx | 7 ++- src/MEDOP/cmp/MEDPresentationManager_i.cxx | 48 +++++++++++++++++ src/MEDOP/cmp/MEDPresentationManager_i.hxx | 53 +++++++++++++++++++ src/MEDOP/gui/DatasourceController.cxx | 17 +++--- src/MEDOP/gui/DatasourceController.hxx | 6 ++- src/MEDOP/gui/MED_msg_en.ts | 4 ++ src/MEDOP/gui/MED_msg_fr.ts | 4 ++ src/MEDOP/gui/WorkspaceController.cxx | 7 ++- src/MEDOP/tui/CMakeLists.txt | 1 + src/MEDOP/tui/medpresentation/CMakeLists.txt | 25 +++++++++ src/MEDOP/tui/medpresentation/__init__.py | 21 ++++++++ .../tui/medpresentation/medpresentation.py | 40 ++++++++++++++ 17 files changed, 269 insertions(+), 16 deletions(-) create mode 100644 idl/MEDPresentationManager.idl create mode 100644 src/MEDOP/cmp/MEDPresentationManager_i.cxx create mode 100644 src/MEDOP/cmp/MEDPresentationManager_i.hxx create mode 100644 src/MEDOP/tui/medpresentation/CMakeLists.txt create mode 100644 src/MEDOP/tui/medpresentation/__init__.py create mode 100644 src/MEDOP/tui/medpresentation/medpresentation.py diff --git a/idl/CMakeLists.txt b/idl/CMakeLists.txt index 63dbe7318..9f47f7c2b 100644 --- a/idl/CMakeLists.txt +++ b/idl/CMakeLists.txt @@ -31,6 +31,7 @@ SET(SalomeIDLMED_IDLSOURCES MEDDataManager.idl MEDCalculator.idl MEDEventListener.idl + MEDPresentationManager.idl MEDOPFactory.idl ) diff --git a/idl/MEDOPFactory.idl b/idl/MEDOPFactory.idl index 14251795a..517a3e694 100644 --- a/idl/MEDOPFactory.idl +++ b/idl/MEDOPFactory.idl @@ -17,7 +17,6 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // - #ifndef __MEDOPFactory_IDL_ #define __MEDOPFactory_IDL_ @@ -25,6 +24,7 @@ #include "SALOME_Exception.idl" #include "MEDDataManager.idl" #include "MEDCalculator.idl" +#include "MEDPresentationManager.idl" /*! * This module contains the interface required for starting with MED @@ -41,9 +41,9 @@ module MEDOP MEDOP::MEDDataManager getDataManager(); MEDOP::MEDCalculator getCalculator(); + MEDOP::MEDPresentationManager getPresentationManager(); }; }; #endif - diff --git a/idl/MEDPresentationManager.idl b/idl/MEDPresentationManager.idl new file mode 100644 index 000000000..4a426f436 --- /dev/null +++ b/idl/MEDPresentationManager.idl @@ -0,0 +1,38 @@ +// Copyright (C) 2005-2015 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_MANAGER_IDL_ +#define __MED_PRESENTATION_MANAGER_IDL_ + +#include "SALOME_GenericObj.idl" +#include "MEDDataManager.idl" + +module MEDOP +{ + + interface MEDPresentationManager : SALOME::GenericObj + { + + void MakeScalarMap(in long fieldHandlerId, in string viewMode); + + }; + +}; + +#endif diff --git a/src/MEDOP/cmp/CMakeLists.txt b/src/MEDOP/cmp/CMakeLists.txt index e6a2f1bb2..8c74dbc76 100644 --- a/src/MEDOP/cmp/CMakeLists.txt +++ b/src/MEDOP/cmp/CMakeLists.txt @@ -35,8 +35,10 @@ INCLUDE_DIRECTORIES( SET(MEDOPFactoryEngine_SOURCES MEDDataManager_i.cxx MEDCalculator_i.cxx + MEDPresentationManager_i.cxx MEDOPFactory_i.cxx ) + SET(COMMON_LIBS medloader SalomeIDLMED diff --git a/src/MEDOP/cmp/MEDOPFactory_i.cxx b/src/MEDOP/cmp/MEDOPFactory_i.cxx index 1ddf0511c..f95429137 100644 --- a/src/MEDOP/cmp/MEDOPFactory_i.cxx +++ b/src/MEDOP/cmp/MEDOPFactory_i.cxx @@ -26,6 +26,7 @@ #include "MEDDataManager_i.hxx" #include "MEDCalculator_i.hxx" +#include "MEDPresentationManager_i.hxx" using namespace std; @@ -63,6 +64,12 @@ MEDOP::MEDCalculator_ptr MEDOPFactory_i::getCalculator() { return medCalculatorPtr; } +MEDOP::MEDPresentationManager_ptr MEDOPFactory_i::getPresentationManager() { + MEDPresentationManager_i * manager = MEDPresentationManager_i::getInstance(); + MEDOP::MEDPresentationManager_ptr managerPtr = manager->_this(); + return managerPtr; +} + extern "C" { PortableServer::ObjectId * MEDOPFactoryEngine_factory( diff --git a/src/MEDOP/cmp/MEDOPFactory_i.hxx b/src/MEDOP/cmp/MEDOPFactory_i.hxx index 49a8196ba..a724e297c 100644 --- a/src/MEDOP/cmp/MEDOPFactory_i.hxx +++ b/src/MEDOP/cmp/MEDOPFactory_i.hxx @@ -26,13 +26,14 @@ #include CORBA_SERVER_HEADER(MEDOPFactory) #include CORBA_SERVER_HEADER(MEDDataManager) #include CORBA_SERVER_HEADER(MEDCalculator) +#include CORBA_SERVER_HEADER(MEDPresentationManager) #include "SALOME_Component_i.hxx" #include "MEDOP.hxx" class MEDOP_EXPORT MEDOPFactory_i: public POA_MEDOP::MEDOPFactory, public Engines_Component_i { - + public: MEDOPFactory_i(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, @@ -45,7 +46,9 @@ public: MEDOP::MEDDataManager_ptr getDataManager(); /*! Returns the singleton instance of the calculator */ MEDOP::MEDCalculator_ptr getCalculator(); - + /*! Returns the singleton instance of the prsentation manager */ + MEDOP::MEDPresentationManager_ptr getPresentationManager(); + }; extern "C" diff --git a/src/MEDOP/cmp/MEDPresentationManager_i.cxx b/src/MEDOP/cmp/MEDPresentationManager_i.cxx new file mode 100644 index 000000000..ad94d0c49 --- /dev/null +++ b/src/MEDOP/cmp/MEDPresentationManager_i.cxx @@ -0,0 +1,48 @@ +// Copyright (C) 2011-2015 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "MEDPresentationManager_i.hxx" +#include "SALOME_KernelServices.hxx" +#include "Basics_Utils.hxx" + +MEDPresentationManager_i* MEDPresentationManager_i::_instance = NULL; + +MEDPresentationManager_i* +MEDPresentationManager_i::getInstance() { + if ( _instance == NULL ) + _instance = new MEDPresentationManager_i(); + return _instance; +} + +MEDPresentationManager_i::MEDPresentationManager_i() +{ +} + +MEDPresentationManager_i::~MEDPresentationManager_i() +{ +} + +#include + +void +MEDPresentationManager_i::MakeScalarMap(CORBA::Long fieldHandlerId, const char* viewMode) +{ + //throw KERNEL::createSalomeException("Not implemented yet"); + std::cout << "MEDPresentationManager_i::MakeScalarMap: Not implemented yet\n"; +} diff --git a/src/MEDOP/cmp/MEDPresentationManager_i.hxx b/src/MEDOP/cmp/MEDPresentationManager_i.hxx new file mode 100644 index 000000000..c6d199808 --- /dev/null +++ b/src/MEDOP/cmp/MEDPresentationManager_i.hxx @@ -0,0 +1,53 @@ +// Copyright (C) 2007-2015 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_MANAGER_I_HXX_ +#define _MED_PRESENTATION_MANAGER_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(MEDDataManager) +#include CORBA_SERVER_HEADER(MEDPresentationManager) +#include "SALOME_GenericObj_i.hh" + +#include "MEDDataManager_i.hxx" +#include "MEDOP.hxx" + +class MEDOP_EXPORT MEDPresentationManager_i: public POA_MEDOP::MEDPresentationManager, + public SALOME::GenericObj_i +{ + public: + + static MEDPresentationManager_i* getInstance(); + + void MakeScalarMap(CORBA::Long fieldHandlerId, const char*); + + private: + + MEDPresentationManager_i(); + virtual ~MEDPresentationManager_i(); + + private : + + // The MEDPresentationManager is a singleton, whose instance can be obtained + // using the getInstance static method. + static MEDPresentationManager_i * _instance; + +}; + +#endif // _MED_PRESENTATION_MANAGER_I_HXX_ diff --git a/src/MEDOP/gui/DatasourceController.cxx b/src/MEDOP/gui/DatasourceController.cxx index ad7c3f53c..f46e9b5e0 100644 --- a/src/MEDOP/gui/DatasourceController.cxx +++ b/src/MEDOP/gui/DatasourceController.cxx @@ -90,11 +90,11 @@ void DatasourceController::createActions() { actionId = _salomeModule->createStandardAction(label,this,SLOT(OnExpandField()),icon); _salomeModule->addActionInPopupMenu(actionId); - // Create a control view - label = tr("LAB_VISUALIZE"); + // Create a view submenu with usual visualization functions + label = tr("LAB_VISUALIZE_SCALARMAP"); icon = tr("ICO_DATASOURCE_VIEW"); - actionId = _salomeModule->createStandardAction(label,this,SLOT(OnVisualize()),icon); - _salomeModule->addActionInPopupMenu(actionId); + actionId = _salomeModule->createStandardAction(label,this,SLOT(OnVisualizeScalarMap()),icon); + _salomeModule->addActionInPopupMenu(actionId, tr("LAB_VISUALIZE")); // Use in workspace label = tr("LAB_USE_IN_WORKSPACE"); @@ -282,9 +282,7 @@ void DatasourceController::OnExpandField() _salomeModule->updateObjBrowser(true); } -void DatasourceController::OnVisualize() { - STDLOG("OnVisualize: To Be Implemented"); - +void DatasourceController::visualize(DatasourceEvent::EventType eventType) { // We need a _studyEditor updated on the active study _studyEditor->updateActiveStudy(); @@ -311,13 +309,16 @@ void DatasourceController::OnVisualize() { } DatasourceEvent * event = new DatasourceEvent(); - event->eventtype = DatasourceEvent::EVENT_VIEW_OBJECT; + event->eventtype = eventType; XmedDataObject * dataObject = new XmedDataObject(); dataObject->setFieldHandler(*fieldHandler); event->objectdata = dataObject; emit datasourceSignal(event); } +} +void DatasourceController::OnVisualizeScalarMap() { + this->visualize(DatasourceEvent::EVENT_VIEW_OBJECT_SCALAR_MAP); } void DatasourceController::OnUseInWorkspace() { diff --git a/src/MEDOP/gui/DatasourceController.hxx b/src/MEDOP/gui/DatasourceController.hxx index 20824f8f2..435aebec9 100644 --- a/src/MEDOP/gui/DatasourceController.hxx +++ b/src/MEDOP/gui/DatasourceController.hxx @@ -53,7 +53,7 @@ typedef struct { EVENT_IMPORT_OBJECT, // Simply import the object in the workspace EVENT_USE_OBJECT, // Import in the workspace AND define a proxy // variable in the tui console to use it - EVENT_VIEW_OBJECT // View with a salome viewer (SMESH/VISU/PARAVIS) + EVENT_VIEW_OBJECT_SCALAR_MAP }; int eventtype; XmedDataObject * objectdata; @@ -87,11 +87,13 @@ protected slots: void OnAddDatasource(); void OnAddImagesource(); void OnExpandField(); - void OnVisualize(); + void OnVisualizeScalarMap(); void OnUseInWorkspace(); void OnChangeUnderlyingMesh(); void OnInterpolateField(); +private: + void visualize(DatasourceEvent::EventType); private: StandardApp_Module * _salomeModule; diff --git a/src/MEDOP/gui/MED_msg_en.ts b/src/MEDOP/gui/MED_msg_en.ts index 4008c8a7b..0689fc4f9 100644 --- a/src/MEDOP/gui/MED_msg_en.ts +++ b/src/MEDOP/gui/MED_msg_en.ts @@ -28,6 +28,10 @@ LAB_EXPAND_FIELD Expand field timeseries + + LAB_VISUALIZE_SCALARMAP + Scalar map + LAB_VISUALIZE diff --git a/src/MEDOP/gui/MED_msg_fr.ts b/src/MEDOP/gui/MED_msg_fr.ts index 2254d0549..d918d3010 100644 --- a/src/MEDOP/gui/MED_msg_fr.ts +++ b/src/MEDOP/gui/MED_msg_fr.ts @@ -28,6 +28,10 @@ LAB_EXPAND_FIELD Étendre les series temporelles du champ + + LAB_VISUALIZE_SCALARMAP + Carte scalaire + LAB_VISUALIZE diff --git a/src/MEDOP/gui/WorkspaceController.cxx b/src/MEDOP/gui/WorkspaceController.cxx index 017a44c6e..e9930e846 100644 --- a/src/MEDOP/gui/WorkspaceController.cxx +++ b/src/MEDOP/gui/WorkspaceController.cxx @@ -482,9 +482,12 @@ void WorkspaceController::processDatasourceEvent(const DatasourceEvent * event) askForOptions, QCHARSTAR(event->objectalias)); } - else if ( event->eventtype == DatasourceEvent::EVENT_VIEW_OBJECT ) { + else if ( event->eventtype == DatasourceEvent::EVENT_VIEW_OBJECT_SCALAR_MAP ) { QStringList commands; - commands+=QString("view(get(%1))").arg(dataObject->getFieldHandler()->id); + commands += QString("from medpresentation import MakeScalarMap"); + QString viewMode = "view mode"; // :TODO: change this (get value from dedicated dialog) + MEDOP::FieldHandler* fieldHandler = dataObject->getFieldHandler(); + commands += QString("MakeScalarMap(get(%1), '%2')").arg(fieldHandler->id).arg(viewMode); _consoleDriver->exec(commands); } else { diff --git a/src/MEDOP/tui/CMakeLists.txt b/src/MEDOP/tui/CMakeLists.txt index f1af30c4e..9e4b18ab7 100644 --- a/src/MEDOP/tui/CMakeLists.txt +++ b/src/MEDOP/tui/CMakeLists.txt @@ -18,3 +18,4 @@ # ADD_SUBDIRECTORY(xmedpy) +ADD_SUBDIRECTORY(medpresentation) diff --git a/src/MEDOP/tui/medpresentation/CMakeLists.txt b/src/MEDOP/tui/medpresentation/CMakeLists.txt new file mode 100644 index 000000000..c76faf093 --- /dev/null +++ b/src/MEDOP/tui/medpresentation/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (C) 2012-2015 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 +# + +SET(PYFILES_TO_INSTALL + __init__.py + medpresentation.py + ) + +SALOME_INSTALL_SCRIPTS("${PYFILES_TO_INSTALL}" ${SALOME_INSTALL_PYTHON}/medpresentation) diff --git a/src/MEDOP/tui/medpresentation/__init__.py b/src/MEDOP/tui/medpresentation/__init__.py new file mode 100644 index 000000000..8c9de9e25 --- /dev/null +++ b/src/MEDOP/tui/medpresentation/__init__.py @@ -0,0 +1,21 @@ +# Copyright (C) 2011-2015 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 +# + +from medpresentation import LoadDataSource +from medpresentation import MakeScalarMap diff --git a/src/MEDOP/tui/medpresentation/medpresentation.py b/src/MEDOP/tui/medpresentation/medpresentation.py new file mode 100644 index 000000000..11b029ad5 --- /dev/null +++ b/src/MEDOP/tui/medpresentation/medpresentation.py @@ -0,0 +1,40 @@ +# Copyright (C) 2011-2015 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 +# + +import xmed +import MEDOP +import SALOME + +__manager = xmed.factory.getPresentationManager() + +def LoadDataSource(filename): + dataHandler = xmed.dataManager.addDatasource(filename) + print data + #return data +# + +def MakeScalarMap(proxy, viewMode): + # Create the presentation instance in CORBA engine + # The engine in turn creates the ParaView pipeline elements + + print "In MakeScalarMap (Python)" + __manager.MakeScalarMap(proxy.id, viewMode) + + +# -- 2.39.2