From c38f43d403eb949953f30b01d0c9e8faaa8a8e68 Mon Sep 17 00:00:00 2001 From: asv Date: Mon, 11 Jul 2005 11:06:42 +0000 Subject: [PATCH] "isActiveView" global parameter added, "activeView" parameter calculation is changed. new methods: activeVW(), activeViewType(). --- src/SalomeApp/SalomeApp_Selection.cxx | 42 +++++++++++++++++++-------- src/SalomeApp/SalomeApp_Selection.h | 3 ++ 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/src/SalomeApp/SalomeApp_Selection.cxx b/src/SalomeApp/SalomeApp_Selection.cxx index 4bba53662..3a45e9ecf 100644 --- a/src/SalomeApp/SalomeApp_Selection.cxx +++ b/src/SalomeApp/SalomeApp_Selection.cxx @@ -7,6 +7,7 @@ #include "SalomeApp_Application.h" #include "SUIT_Session.h" +#include "SUIT_ViewWindow.h" SalomeApp_Selection::SalomeApp_Selection() : myStudy( 0 ) @@ -53,18 +54,10 @@ QtxValue SalomeApp_Selection::param( const int, const QString& p ) const QtxValue SalomeApp_Selection::globalParam( const QString& p ) const { - if( p=="client" ) - return QtxValue( myPopupClient ); - else if ( p=="activeView" ) - { - QString aViewType = ""; - SUIT_ViewWindow* anActiveView = study()->application()->desktop()->activeWindow(); - if (anActiveView) - aViewType = anActiveView->getViewManager()->getType(); - return QtxValue(aViewType); - } - else - return QtxPopupMgr::Selection::globalParam( p ); + if ( p == "client" ) return QtxValue( myPopupClient ); + else if ( p == "isActiveView" ) return QtxValue( (bool)activeVW() ); + else if ( p == "activeView" ) return QtxValue( activeViewType() ); + else return QtxPopupMgr::Selection::globalParam( p ); } void SalomeApp_Selection::processOwner( const SalomeApp_DataOwner* ) @@ -77,3 +70,28 @@ QString SalomeApp_Selection::entry( const int index ) const return myEntries[ index ]; return QString(); } + +QString SalomeApp_Selection::activeViewType() const +{ + SUIT_ViewWindow* win = activeVW(); + if ( win ) { + SUIT_ViewManager* vm = win->getViewManager(); + if ( vm ) + return vm->getType(); + } + return QString::null; +} + +SUIT_ViewWindow* SalomeApp_Selection::activeVW() const +{ + SUIT_Session* session = SUIT_Session::session(); + if ( session ) { + SUIT_Application* app = session->activeApplication(); + if ( app ) { + SUIT_Desktop* desk = app->desktop(); + if ( desk ) + return desk->activeWindow(); + } + } + return 0; +} diff --git a/src/SalomeApp/SalomeApp_Selection.h b/src/SalomeApp/SalomeApp_Selection.h index a9134f93f..b3fca5bc9 100644 --- a/src/SalomeApp/SalomeApp_Selection.h +++ b/src/SalomeApp/SalomeApp_Selection.h @@ -35,6 +35,7 @@ class SalomeApp_SelectionMgr; class SalomeApp_DataOwner; class SalomeApp_Study; class SALOMEDSClient_Study; +class SUIT_ViewWindow; class SalomeApp_Selection : public QtxPopupMgr::Selection @@ -53,6 +54,8 @@ public: protected: QString entry( const int ) const; SalomeApp_Study* study() const { return myStudy; } + QString activeViewType() const; + SUIT_ViewWindow* activeVW() const; private: QString myPopupClient; -- 2.39.2