2 #include "SalomeApp_Selection.h"
4 #include "SalomeApp_SelectionMgr.h"
5 #include "SalomeApp_DataOwner.h"
6 #include "SalomeApp_Study.h"
7 #include "SalomeApp_Application.h"
9 #include "SUIT_Session.h"
10 #include "SUIT_ViewWindow.h"
12 SalomeApp_Selection::SalomeApp_Selection()
17 SalomeApp_Selection::~SalomeApp_Selection()
21 void SalomeApp_Selection::init( const QString& client, SalomeApp_SelectionMgr* mgr)
23 myPopupClient = client;
27 if ( mgr->application() )
28 myStudy = dynamic_cast<SalomeApp_Study*>( mgr->application()->activeStudy() );
30 SUIT_DataOwnerPtrList sel;
31 mgr->selected( sel, client );
32 SUIT_DataOwnerPtrList::const_iterator anIt = sel.begin(), aLast = sel.end();
33 for( ; anIt!=aLast; anIt++ )
35 SUIT_DataOwner* owner = ( SUIT_DataOwner* )( (*anIt ).get() );
36 SalomeApp_DataOwner* sowner = dynamic_cast<SalomeApp_DataOwner*>( owner );
38 myEntries.append( sowner->entry() );
39 processOwner( sowner );
45 int SalomeApp_Selection::count() const
47 return myEntries.count();
50 QtxValue SalomeApp_Selection::param( const int, const QString& p ) const
55 QtxValue SalomeApp_Selection::globalParam( const QString& p ) const
57 if ( p == "client" ) return QtxValue( myPopupClient );
58 else if ( p == "isActiveView" ) return QtxValue( (bool)activeVW() );
59 else if ( p == "activeView" ) return QtxValue( activeViewType() );
60 else return QtxPopupMgr::Selection::globalParam( p );
63 void SalomeApp_Selection::processOwner( const SalomeApp_DataOwner* )
67 QString SalomeApp_Selection::entry( const int index ) const
69 if ( index >= 0 && index < count() )
70 return myEntries[ index ];
74 QString SalomeApp_Selection::activeViewType() const
76 SUIT_ViewWindow* win = activeVW();
78 SUIT_ViewManager* vm = win->getViewManager();
85 SUIT_ViewWindow* SalomeApp_Selection::activeVW() const
87 SUIT_Session* session = SUIT_Session::session();
89 SUIT_Application* app = session->activeApplication();
91 SUIT_Desktop* desk = app->desktop();
93 return desk->activeWindow();