2 #include "LightApp_Selection.h"
3 #include "LightApp_SelectionMgr.h"
4 #include "LightApp_DataOwner.h"
5 #include "LightApp_Study.h"
6 #include "LightApp_Application.h"
7 #include "LightApp_Displayer.h"
9 #include "SUIT_Session.h"
10 #include "SUIT_ViewWindow.h"
15 LightApp_Selection::LightApp_Selection()
23 LightApp_Selection::~LightApp_Selection()
30 void LightApp_Selection::init( const QString& client, LightApp_SelectionMgr* mgr)
32 myPopupClient = client;
36 if ( mgr->application() )
37 myStudy = dynamic_cast<LightApp_Study*>( mgr->application()->activeStudy() );
41 SUIT_DataOwnerPtrList sel;
42 //asl: fix for PAL10471
43 //mgr->selected( sel, client );
45 SUIT_DataOwnerPtrList::const_iterator anIt = sel.begin(), aLast = sel.end();
47 QString entry, curEntry;
48 for( ; anIt!=aLast; anIt++ )
50 SUIT_DataOwner* owner = ( SUIT_DataOwner* )( (*anIt ).get() );
51 LightApp_DataOwner* sowner = dynamic_cast<LightApp_DataOwner*>( owner );
53 curEntry = sowner->entry();
54 entry = myStudy->referencedToEntry( curEntry );
55 myEntries.append( entry );
56 if ( curEntry == entry )
57 myIsReferences.append( true );
59 myIsReferences.append( false );
60 processOwner( sowner );
67 Gets count of entries.
69 int LightApp_Selection::count() const
71 return myEntries.count();
77 QtxValue LightApp_Selection::param( const int ind, const QString& p ) const
79 if( !( ind>=0 && ind<count() ) )
85 bool vis = d.IsDisplayed( myEntries[ ind ] );
86 return QtxValue( vis, 0 );
88 else if( p=="component" ) {
89 return myStudy->componentDataType( myEntries[ ind ] );
91 else if( p=="isReference" )
92 return QtxValue( isReference( ind ), false );
98 Gets global parameters. client, isActiveView, activeView etc.
100 QtxValue LightApp_Selection::globalParam( const QString& p ) const
102 if ( p == "client" ) return QtxValue( myPopupClient );
103 else if ( p == "activeModule" )
105 LightApp_Application* app = dynamic_cast<LightApp_Application*>( myStudy->application() );
106 QString mod_name = app ? QString( app->activeModule()->name() ) : QString::null;
107 //cout << "activeModule : " << mod_name.latin1() << endl;
108 if( !mod_name.isEmpty() )
113 else if ( p == "isActiveView" ) return QtxValue( (bool)activeVW() );
114 else if ( p == "activeView" ) return QtxValue( activeViewType() );
116 else return QtxPopupMgr::Selection::globalParam( p );
118 else return Selection::globalParam( p );
125 void LightApp_Selection::processOwner( const LightApp_DataOwner* )
130 Gets entry with index \a index.
132 QString LightApp_Selection::entry( const int index ) const
134 if ( index >= 0 && index < count() )
135 return myEntries[ index ];
140 Returns true if i-th selected object was reference to object with entry( i )
142 bool LightApp_Selection::isReference( const int index ) const
144 if( index >= 0 && index < count() )
145 return myIsReferences[ index ];
151 Gets type of active view manager.
153 QString LightApp_Selection::activeViewType() const
155 SUIT_ViewWindow* win = activeVW();
157 SUIT_ViewManager* vm = win->getViewManager();
159 return vm->getType();
161 return QString::null;
165 Gets active view window.
167 SUIT_ViewWindow* LightApp_Selection::activeVW() const
169 SUIT_Session* session = SUIT_Session::session();
171 SUIT_Application* app = session->activeApplication();
173 SUIT_Desktop* desk = app->desktop();
175 return desk->activeWindow();