]> SALOME platform Git repositories - modules/gui.git/blob - src/SalomeApp/SalomeApp_Selection.cxx
Salome HOME
debug IPAL9411: redefine virtual methods createEmptyStudy and activateModule
[modules/gui.git] / src / SalomeApp / SalomeApp_Selection.cxx
1
2 #include "SalomeApp_Selection.h"
3
4 #include "SalomeApp_SelectionMgr.h"
5 #include "SalomeApp_DataOwner.h"
6 #include "SalomeApp_Study.h"
7 #include "SalomeApp_Application.h"
8
9 #include "SUIT_Session.h"
10 #include "SUIT_ViewWindow.h"
11
12 SalomeApp_Selection::SalomeApp_Selection()
13 : myStudy( 0 )
14 {
15 }
16
17 SalomeApp_Selection::~SalomeApp_Selection()
18 {
19 }
20
21 void SalomeApp_Selection::init( const QString& client, SalomeApp_SelectionMgr* mgr)
22 {
23   myPopupClient = client;
24   
25   if( mgr )
26   {
27     if ( mgr->application() )
28       myStudy = dynamic_cast<SalomeApp_Study*>( mgr->application()->activeStudy() );
29
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++ )
34     {
35       SUIT_DataOwner* owner = ( SUIT_DataOwner* )( (*anIt ).get() );
36       SalomeApp_DataOwner* sowner = dynamic_cast<SalomeApp_DataOwner*>( owner );
37       if( sowner ) {
38         myEntries.append( sowner->entry() );
39         processOwner( sowner );
40       }
41     }
42   }
43 }
44
45 int SalomeApp_Selection::count() const
46 {
47   return myEntries.count();
48 }
49
50 QtxValue SalomeApp_Selection::param( const int, const QString& p ) const
51 {
52   return QtxValue();
53 }
54
55 QtxValue SalomeApp_Selection::globalParam( const QString& p ) const
56 {
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 );
61 }
62
63 void SalomeApp_Selection::processOwner( const SalomeApp_DataOwner* )
64 {
65 }
66
67 QString SalomeApp_Selection::entry( const int index ) const
68 {
69   if ( index >= 0 && index < count() )
70     return myEntries[ index ];
71   return QString();
72 }
73
74 QString SalomeApp_Selection::activeViewType() const
75 {
76   SUIT_ViewWindow* win = activeVW();
77   if ( win ) {
78     SUIT_ViewManager* vm = win->getViewManager();
79     if ( vm )
80       return vm->getType();
81   }
82   return QString::null;
83 }
84
85 SUIT_ViewWindow* SalomeApp_Selection::activeVW() const
86 {
87   SUIT_Session* session = SUIT_Session::session();
88   if ( session ) {
89     SUIT_Application* app = session->activeApplication();
90     if ( app ) {
91       SUIT_Desktop* desk = app->desktop();
92       if ( desk ) 
93         return desk->activeWindow();
94     }
95   }
96   return 0;
97 }