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 mgr->selected( sel, client );
43 SUIT_DataOwnerPtrList::const_iterator anIt = sel.begin(), aLast = sel.end();
45 QString entry, curEntry;
46 for( ; anIt!=aLast; anIt++ )
48 SUIT_DataOwner* owner = ( SUIT_DataOwner* )( (*anIt ).get() );
49 LightApp_DataOwner* sowner = dynamic_cast<LightApp_DataOwner*>( owner );
51 curEntry = sowner->entry();
52 entry = myStudy->referencedToEntry( curEntry );
53 myEntries.append( entry );
54 if ( curEntry == entry )
55 myIsReferences.append( true );
57 myIsReferences.append( false );
58 processOwner( sowner );
65 Gets count of entries.
67 int LightApp_Selection::count() const
69 return myEntries.count();
75 QtxValue LightApp_Selection::param( const int ind, const QString& p ) const
77 if( !( ind>=0 && ind<count() ) )
83 bool vis = d.IsDisplayed( myEntries[ ind ] );
84 return QtxValue( vis, 0 );
86 else if( p=="component" ) {
87 return myStudy->componentDataType( myEntries[ ind ] );
89 else if( p=="isReference" )
90 return QtxValue( isReference( ind ), false );
96 Gets global parameters. client, isActiveView, activeView etc.
98 QtxValue LightApp_Selection::globalParam( const QString& p ) const
100 if ( p == "client" ) return QtxValue( myPopupClient );
101 else if ( p == "activeModule" )
103 LightApp_Application* app = dynamic_cast<LightApp_Application*>( myStudy->application() );
104 QString mod_name = app ? QString( app->activeModule()->name() ) : QString::null;
105 //cout << "activeModule : " << mod_name.latin1() << endl;
106 if( !mod_name.isEmpty() )
111 else if ( p == "isActiveView" ) return QtxValue( (bool)activeVW() );
112 else if ( p == "activeView" ) return QtxValue( activeViewType() );
114 else return QtxPopupMgr::Selection::globalParam( p );
116 else return Selection::globalParam( p );
123 void LightApp_Selection::processOwner( const LightApp_DataOwner* )
128 Gets entry with index \a index.
130 QString LightApp_Selection::entry( const int index ) const
132 if ( index >= 0 && index < count() )
133 return myEntries[ index ];
138 Returns true if i-th selected object was reference to object with entry( i )
140 bool LightApp_Selection::isReference( const int index ) const
142 if( index >= 0 && index < count() )
143 return myIsReferences[ index ];
149 Gets type of active view manager.
151 QString LightApp_Selection::activeViewType() const
153 SUIT_ViewWindow* win = activeVW();
155 SUIT_ViewManager* vm = win->getViewManager();
157 return vm->getType();
159 return QString::null;
163 Gets active view window.
165 SUIT_ViewWindow* LightApp_Selection::activeVW() const
167 SUIT_Session* session = SUIT_Session::session();
169 SUIT_Application* app = session->activeApplication();
171 SUIT_Desktop* desk = app->desktop();
173 return desk->activeWindow();