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"
15 SalomeApp_Selection::SalomeApp_Selection()
23 SalomeApp_Selection::~SalomeApp_Selection()
30 void SalomeApp_Selection::init( const QString& client, SalomeApp_SelectionMgr* mgr)
32 myPopupClient = client;
36 if ( mgr->application() )
37 myStudy = dynamic_cast<SalomeApp_Study*>( mgr->application()->activeStudy() );
39 SUIT_DataOwnerPtrList sel;
40 mgr->selected( sel, client );
41 SUIT_DataOwnerPtrList::const_iterator anIt = sel.begin(), aLast = sel.end();
42 for( ; anIt!=aLast; anIt++ )
44 SUIT_DataOwner* owner = ( SUIT_DataOwner* )( (*anIt ).get() );
45 SalomeApp_DataOwner* sowner = dynamic_cast<SalomeApp_DataOwner*>( owner );
47 myEntries.append( sowner->entry() );
48 processOwner( sowner );
55 Gets count of entries.
57 int SalomeApp_Selection::count() const
59 return myEntries.count();
65 QtxValue SalomeApp_Selection::param( const int, const QString& p ) const
71 Gets global parameters. client, isActiveView, activeView etc.
73 QtxValue SalomeApp_Selection::globalParam( const QString& p ) const
75 if ( p == "client" ) return QtxValue( myPopupClient );
76 else if ( p == "isActiveView" ) return QtxValue( (bool)activeVW() );
77 else if ( p == "activeView" ) return QtxValue( activeViewType() );
79 else return QtxPopupMgr::Selection::globalParam( p );
81 else return Selection::globalParam( p );
88 void SalomeApp_Selection::processOwner( const SalomeApp_DataOwner* )
93 Gets entry with index \a index.
95 QString SalomeApp_Selection::entry( const int index ) const
97 if ( index >= 0 && index < count() )
98 return myEntries[ index ];
103 Gets type of active view manager.
105 QString SalomeApp_Selection::activeViewType() const
107 SUIT_ViewWindow* win = activeVW();
109 SUIT_ViewManager* vm = win->getViewManager();
111 return vm->getType();
113 return QString::null;
117 Gets active view window.
119 SUIT_ViewWindow* SalomeApp_Selection::activeVW() const
121 SUIT_Session* session = SUIT_Session::session();
123 SUIT_Application* app = session->activeApplication();
125 SUIT_Desktop* desk = app->desktop();
127 return desk->activeWindow();