From: abn Date: Thu, 7 Jul 2016 09:24:22 +0000 (+0200) Subject: [MEDCalc] selecting a presentation activates the proper view. X-Git-Tag: V8_1_0b1~29 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7ddbc150b72576b70905f223e46abe7778ed7b57;p=modules%2Fmed.git [MEDCalc] selecting a presentation activates the proper view. --- diff --git a/idl/MEDPresentationManager.idl b/idl/MEDPresentationManager.idl index c797e4036..86bc0b21f 100644 --- a/idl/MEDPresentationManager.idl +++ b/idl/MEDPresentationManager.idl @@ -140,7 +140,9 @@ module MEDCALC void updatePointSprite(in long presId, in PointSpriteParameters params); boolean removePresentation(in long presId); - + + // Helper functions to keep GUI sync + boolean activateView(in long presentationId); }; }; diff --git a/src/MEDCalc/cmp/MEDPresentation.cxx b/src/MEDCalc/cmp/MEDPresentation.cxx index 2fd8ff90d..48305be82 100644 --- a/src/MEDCalc/cmp/MEDPresentation.cxx +++ b/src/MEDCalc/cmp/MEDPresentation.cxx @@ -186,3 +186,13 @@ 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()); +} diff --git a/src/MEDCalc/cmp/MEDPresentation.hxx b/src/MEDCalc/cmp/MEDPresentation.hxx index c407be158..d6458d2f6 100644 --- a/src/MEDCalc/cmp/MEDPresentation.hxx +++ b/src/MEDCalc/cmp/MEDPresentation.hxx @@ -46,6 +46,8 @@ public: 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 PyObjectId; @@ -60,6 +62,7 @@ protected: void pushAndExecPyLine(const std::string & lin); MEDPresentation::TypeID getID() const { return _fieldHandlerId; } + long getPyViewID() const { return _renderViewPyId; } static int GeneratePythonId(); diff --git a/src/MEDCalc/cmp/MEDPresentationManager_i.cxx b/src/MEDCalc/cmp/MEDPresentationManager_i.cxx index a2e3cfb09..563979e16 100644 --- a/src/MEDCalc/cmp/MEDPresentationManager_i.cxx +++ b/src/MEDCalc/cmp/MEDPresentationManager_i.cxx @@ -182,6 +182,20 @@ MEDPresentationManager_i::removePresentation(MEDPresentation::TypeID presentatio return true; } +CORBA::Boolean +MEDPresentationManager_i::activateView(MEDPresentation::TypeID presentationID) +{ + std::map::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; +} + MEDPresentation::TypeID MEDPresentationManager_i::_getActivePresentationId() const { diff --git a/src/MEDCalc/cmp/MEDPresentationManager_i.hxx b/src/MEDCalc/cmp/MEDPresentationManager_i.hxx index e7ec9677c..0b073ebd5 100644 --- a/src/MEDCalc/cmp/MEDPresentationManager_i.hxx +++ b/src/MEDCalc/cmp/MEDPresentationManager_i.hxx @@ -58,6 +58,8 @@ class MEDPresentationManager_i: public POA_MEDCALC::MEDPresentationManager, MEDCALC_EXPORT CORBA::Boolean removePresentation(MEDPresentation::TypeID presentationID); + MEDCALC_EXPORT CORBA::Boolean activateView(MEDPresentation::TypeID presentationID); + private: MEDPresentationManager_i(); virtual ~MEDPresentationManager_i(); diff --git a/src/MEDCalc/gui/MEDModule.cxx b/src/MEDCalc/gui/MEDModule.cxx index 83443ad7e..8662acdf0 100644 --- a/src/MEDCalc/gui/MEDModule.cxx +++ b/src/MEDCalc/gui/MEDModule.cxx @@ -45,6 +45,9 @@ #include "PVViewer_GUIElements.h" #endif +#include "MEDFactoryClient.hxx" +#include "MEDPresentationManager_i.hxx" + #include #include @@ -52,7 +55,9 @@ //! 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), @@ -83,18 +88,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 @@ -119,7 +129,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() ); } @@ -171,7 +181,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 @@ -381,15 +391,13 @@ MEDModule::onClick(const QModelIndex & index) if (!itemClickGeneric(index, name, fieldId, presId)) return; - STDLOG("Presentation selection (should activate view): NOT IMPLEMENTED YET"); - STDLOG(" Presention infos:"); + STDLOG("Presentation selection (activate view)"); std::ostringstream oss; oss << fieldId << " / " << presId; STDLOG(" - Field id / pres id: " + oss.str()); STDLOG(" - Presentation name: " + name); - // TODO: activate corresponding view - + _presManager->activateView(presId); } void diff --git a/src/MEDCalc/gui/MEDModule.hxx b/src/MEDCalc/gui/MEDModule.hxx index 38c624e88..4c783a6bc 100644 --- a/src/MEDCalc/gui/MEDModule.hxx +++ b/src/MEDCalc/gui/MEDModule.hxx @@ -41,6 +41,7 @@ class SalomeApp_Application; class PVViewer_GUIElements; +class MEDPresentationManager_i; /*! * This class defines the gui of the MED module. @@ -106,8 +107,12 @@ private: XmedDataModel* _xmedDataModel; PresentationController* _presentationController; ProcessingController* _processingController; - static MED_ORB::MED_Gen_var myEngine; 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; }; #endif