]> SALOME platform Git repositories - modules/gui.git/blob - src/LightApp/LightApp_Application.cxx
Salome HOME
3aa523b1c07dfac37b31a1336a9548a5710bfeb6
[modules/gui.git] / src / LightApp / LightApp_Application.cxx
1 // File:      LightApp_Application.cxx
2 // Created:   6/20/2005 18:39:45 PM
3 // Author:    Natalia Donis
4 // Copyright (C) CEA 2005
5
6 #include "PythonConsole_PyInterp.h" // WARNING! This include must be the first!
7
8 #include "LightApp_Application.h"
9 #include "LightApp_WidgetContainer.h"
10 #include "LightApp_Module.h"
11 #include "LightApp_DataModel.h"
12 #include "LightApp_Study.h"
13 #include "LightApp_Preferences.h"
14 #include "LightApp_PreferencesDlg.h"
15 #include "LightApp_ModuleDlg.h"
16 #include "LightApp_AboutDlg.h"
17
18 #include "LightApp_OBFilter.h"
19
20 #include "LightApp_GLSelector.h"
21 #include "LightApp_OBSelector.h"
22 #include "LightApp_OCCSelector.h"
23 #include "LightApp_VTKSelector.h"
24 #include "LightApp_SelectionMgr.h"
25
26 #include <CAM_Module.h>
27 #include <CAM_DataModel.h>
28 #include <CAM_Study.h>
29 #include <STD_TabDesktop.h>
30
31 #include <SUIT_Session.h>
32 #include <SUIT_Study.h>
33 #include <SUIT_FileDlg.h>
34 #include <SUIT_ResourceMgr.h>
35 #include <SUIT_Tools.h>
36 #include <SUIT_Accel.h>
37
38 #include <QtxMRUAction.h>
39 #include <QtxDockAction.h>
40 #include <QtxToolBar.h>
41
42 #include <LogWindow.h>
43 #include <OB_Browser.h>
44 #include <PythonConsole_PyConsole.h>
45
46 #include <GLViewer_Viewer.h>
47 #include <GLViewer_ViewManager.h>
48
49 #include <Plot2d_ViewManager.h>
50 #include <Plot2d_ViewModel.h>
51 #include <SPlot2d_ViewModel.h>
52
53 #include <OCCViewer_ViewManager.h>
54 #include <SOCC_ViewModel.h>
55
56 #include <SVTK_ViewModel.h>
57 #include <SVTK_ViewManager.h>
58 #include <VTKViewer_ViewModel.h>
59
60 #include <SUPERVGraph_ViewModel.h>
61 #include <SUPERVGraph_ViewFrame.h>
62 #include <SUPERVGraph_ViewManager.h>
63
64 #include <QtxWorkstack.h>
65
66 #include <qdir.h>
67 #include <qimage.h>
68 #include <qstring.h>
69 #include <qwidget.h>
70 #include <qstringlist.h>
71 #include <qfile.h>
72 #include <qapplication.h>
73 #include <qmap.h>
74 #include <qstatusbar.h>
75 #include <qthread.h>
76 #include <qobjectlist.h>
77 #include <qcombobox.h>
78 #include <qinputdialog.h>
79
80 #define OBJECT_BROWSER_WIDTH 300
81 #define OBJECT_COLUMN_WIDTH 150
82
83 #ifdef WIN32
84 #define DEFAULT_BROWSER "start iexplore.exe"
85 #else
86 #define DEFAULT_BROWSER "mozilla"
87 #endif
88
89 #define FIRST_HELP_ID 1000000
90
91 #include "SALOME_InteractiveObject.hxx"
92 #include "SALOME_ListIO.hxx"
93
94 static const char* imageEmptyIcon[] = {
95 "20 20 1 1",
96 ".      c None",
97 "....................",
98 "....................",
99 "....................",
100 "....................",
101 "....................",
102 "....................",
103 "....................",
104 "....................",
105 "....................",
106 "....................",
107 "....................",
108 "....................",
109 "....................",
110 "....................",
111 "....................",
112 "....................",
113 "....................",
114 "....................",
115 "....................",
116 "...................."};
117
118 /*!Create new instance of LightApp_Application.*/
119 extern "C" LIGHTAPP_EXPORT SUIT_Application* createApplication()
120 {
121   return new LightApp_Application();
122 }
123
124 LightApp_Preferences* LightApp_Application::_prefs_ = 0;
125
126 /*
127   Class       : LightApp_Application
128   Description : Application containing LightApp module
129 */
130
131 /*!Constructor.*/
132 LightApp_Application::LightApp_Application()
133 : CAM_Application( false ),
134 myPrefs( 0 )
135 {
136   STD_TabDesktop* desk = new STD_TabDesktop();
137
138   setDesktop( desk );
139
140   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
141   QPixmap aLogo = aResMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
142
143   desktop()->setIcon( aLogo );
144   desktop()->setDockableMenuBar( true );
145   desktop()->setDockableStatusBar( false );
146
147   // base logo (salome itself)
148   desktop()->addLogo( "_app_base",  aResMgr->loadPixmap( "LightApp", tr( "APP_BASE_LOGO" ), false ) );
149   // extra logo (salome-based application)
150   desktop()->addLogo( "_app_extra", aResMgr->loadPixmap( "LightApp", tr( "APP_EXTRA_LOGO" ), false ) );
151
152   clearViewManagers();
153
154   mySelMgr = new LightApp_SelectionMgr( this );
155
156   myAccel = new SUIT_Accel( desktop() );
157   myAccel->setActionKey( SUIT_Accel::PanLeft,     CTRL+Key_Left,     OCCViewer_Viewer::Type() );
158   myAccel->setActionKey( SUIT_Accel::PanRight,    CTRL+Key_Right,    OCCViewer_Viewer::Type() );
159   myAccel->setActionKey( SUIT_Accel::PanUp,       CTRL+Key_Up,       OCCViewer_Viewer::Type() );
160   myAccel->setActionKey( SUIT_Accel::PanDown,     CTRL+Key_Down,     OCCViewer_Viewer::Type() );
161   myAccel->setActionKey( SUIT_Accel::ZoomIn,      CTRL+Key_Plus,     OCCViewer_Viewer::Type() );
162   myAccel->setActionKey( SUIT_Accel::ZoomOut,     CTRL+Key_Minus,    OCCViewer_Viewer::Type() );
163   myAccel->setActionKey( SUIT_Accel::ZoomFit,     CTRL+Key_Asterisk, OCCViewer_Viewer::Type() );
164   myAccel->setActionKey( SUIT_Accel::RotateLeft,  ALT+Key_Left,      OCCViewer_Viewer::Type() );
165   myAccel->setActionKey( SUIT_Accel::RotateRight, ALT+Key_Right,     OCCViewer_Viewer::Type() );
166   myAccel->setActionKey( SUIT_Accel::RotateUp,    ALT+Key_Up,        OCCViewer_Viewer::Type() );
167   myAccel->setActionKey( SUIT_Accel::RotateDown,  ALT+Key_Down,      OCCViewer_Viewer::Type() );
168   myAccel->setActionKey( SUIT_Accel::PanLeft,     CTRL+Key_Left,     VTKViewer_Viewer::Type() );
169   myAccel->setActionKey( SUIT_Accel::PanRight,    CTRL+Key_Right,    VTKViewer_Viewer::Type() );
170   myAccel->setActionKey( SUIT_Accel::PanUp,       CTRL+Key_Up,       VTKViewer_Viewer::Type() );
171   myAccel->setActionKey( SUIT_Accel::PanDown,     CTRL+Key_Down,     VTKViewer_Viewer::Type() );
172   myAccel->setActionKey( SUIT_Accel::ZoomIn,      CTRL+Key_Plus,     VTKViewer_Viewer::Type() );
173   myAccel->setActionKey( SUIT_Accel::ZoomOut,     CTRL+Key_Minus,    VTKViewer_Viewer::Type() );
174   myAccel->setActionKey( SUIT_Accel::ZoomFit,     CTRL+Key_Asterisk, VTKViewer_Viewer::Type() );
175   myAccel->setActionKey( SUIT_Accel::RotateLeft,  ALT+Key_Left,      VTKViewer_Viewer::Type() );
176   myAccel->setActionKey( SUIT_Accel::RotateRight, ALT+Key_Right,     VTKViewer_Viewer::Type() );
177   myAccel->setActionKey( SUIT_Accel::RotateUp,    ALT+Key_Up,        VTKViewer_Viewer::Type() );
178   myAccel->setActionKey( SUIT_Accel::RotateDown,  ALT+Key_Down,      VTKViewer_Viewer::Type() );
179
180   connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) );
181 }
182
183 /*!Destructor.
184  *\li Save window geometry.
185  *\li Save desktop geometry.
186  *\li Save resource maneger.
187  *\li Delete selection manager.
188  */
189 LightApp_Application::~LightApp_Application()
190 {
191   saveWindowsGeometry();
192
193   if ( resourceMgr() )
194   {
195     if ( desktop() )
196       desktop()->saveGeometry( resourceMgr(), "desktop" );
197     resourceMgr()->save();
198   }
199   delete mySelMgr;
200 }
201
202 /*!Start application.*/
203 void LightApp_Application::start()
204 {
205   if ( desktop() )
206     desktop()->loadGeometry( resourceMgr(), "desktop" );
207
208   CAM_Application::start();
209
210   QAction* a = action( ViewWindowsId );
211   if ( a && a->inherits( "QtxDockAction" ) )
212     ((QtxDockAction*)a)->setAutoPlace( true );
213
214   updateWindows();
215   updateViewManagers();
216
217   putInfo( "" );
218   desktop()->statusBar()->message( "" );
219 }
220
221 /*!Gets application name.*/
222 QString LightApp_Application::applicationName() const
223 {
224   return tr( "APP_NAME" );
225 }
226
227 /*!Gets application version.*/
228 QString LightApp_Application::applicationVersion() const
229 {
230   static QString _app_version;
231
232   if ( _app_version.isEmpty() )
233   {
234     QString resVersion = tr( "APP_VERSION" );
235     if ( resVersion != "APP_VERSION" )
236     {
237       _app_version = resVersion;
238     }
239     else
240     {
241       QString path( ::getenv( "GUI_ROOT_DIR" ) );
242       if ( !path.isEmpty() )
243         path += QDir::separator();
244       path += QString( "bin/salome/VERSION" );
245
246       QFile vf( path );
247       if ( vf.open( IO_ReadOnly ) )
248       {
249         QString line;
250         vf.readLine( line, 1024 );
251         vf.close();
252
253         if ( !line.isEmpty() )
254         {
255           while ( !line.isEmpty() && line.at( line.length() - 1 ) == QChar( '\n' ) )
256             line.remove( line.length() - 1, 1 );
257
258           int idx = line.findRev( ":" );
259           if ( idx != -1 )
260             _app_version = line.mid( idx + 1 ).stripWhiteSpace();
261         }
262       }
263     }
264   }
265   return _app_version;  
266 }
267
268 /*!Load module by \a name.*/
269 CAM_Module* LightApp_Application::loadModule( const QString& name )
270 {
271   CAM_Module* mod = CAM_Application::loadModule( name );
272   if ( mod )
273   {
274     connect( this, SIGNAL( studyOpened() ), mod, SLOT( onModelOpened() ) );
275     connect( this, SIGNAL( studySaved() ),  mod, SLOT( onModelSaved() ) );
276     connect( this, SIGNAL( studyClosed() ), mod, SLOT( onModelClosed() ) );
277   }
278   return mod;
279 }
280
281 /*!Activate module by \a modName*/
282 bool LightApp_Application::activateModule( const QString& modName )
283 {
284   QString actName;
285   CAM_Module* prevMod = activeModule();
286
287   if ( prevMod )
288     actName = prevMod->moduleName();
289
290   if ( actName == modName )
291     return true;
292
293   putInfo( tr( "ACTIVATING_MODULE" ).arg( modName ) );  
294
295   saveWindowsGeometry();
296
297   bool status = CAM_Application::activateModule( modName );
298
299   updateModuleActions();
300
301   putInfo( "" );  
302
303   if ( !status )
304     return false;
305
306   updateWindows();
307   updateViewManagers();
308
309   return true;
310 }
311
312 bool LightApp_Application::useStudy(const QString& theName)
313 {
314   createEmptyStudy();
315   LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
316   bool res = false;
317   if (aStudy)
318     res = aStudy->loadDocument( theName );
319   updateDesktopTitle();
320   updateCommandsStatus();
321   return res;
322 }
323
324 /*!Gets selection manager.*/
325 LightApp_SelectionMgr* LightApp_Application::selectionMgr() const
326 {
327   return mySelMgr;
328 }
329
330 /*!Create actions:*/
331 void LightApp_Application::createActions()
332 {
333   STD_Application::createActions();
334
335   SUIT_Desktop* desk = desktop();
336   SUIT_ResourceMgr* resMgr = resourceMgr();
337
338   //! Preferences
339   createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIconSet(),
340                 tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
341                 CTRL+Key_P, desk, false, this, SLOT( onPreferences() ) );
342
343   //! Help for modules
344   int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
345   int helpModuleMenu = createMenu( tr( "MEN_DESK_MODULE_HELP" ), helpMenu, -1, 0 );
346   createMenu( separator(), helpMenu, -1, 1 );
347
348   QStringList aModuleList;
349   modules( aModuleList, false );
350
351   int id = LightApp_Application::UserID + FIRST_HELP_ID;
352   // help for KERNEL and GUI
353   QCString dir;
354   QString aFileName;
355   QString root;
356   QAction* a;
357   if (dir = getenv("GUI_ROOT_DIR")) {
358     aFileName = "GUI_index_v3.1.0.html";
359     root = Qtx::addSlash( Qtx::addSlash(dir) +  Qtx::addSlash("doc") +  Qtx::addSlash("salome") );
360     if ( QFileInfo( root + aFileName ).exists() ) {
361       a = createAction( id, tr( QString("Kernel & GUI Help") ), QIconSet(),
362                         tr( QString("Kernel && GUI Help") ),
363                         tr( QString("Kernel & GUI Help") ),
364                         0, desk, false, this, SLOT( onHelpContentsModule() ) );
365       a->setName( QString("GUI") );
366       createMenu( a, helpModuleMenu, -1 );
367       id++;
368     }
369   }
370   // help for other existing modules
371   QStringList::Iterator it;
372   for ( it = aModuleList.begin(); it != aModuleList.end(); ++it )
373   {
374     if ( (*it).isEmpty() )
375       continue;
376
377     QString modName = moduleName( *it );
378     aFileName = modName + "_index_v3.1.0.html";
379     
380     if (dir = getenv( modName + "_ROOT_DIR")) {
381       root = Qtx::addSlash( Qtx::addSlash(dir) +  Qtx::addSlash("doc") +  Qtx::addSlash("salome") );
382       if ( QFileInfo( root + aFileName ).exists() ) {
383
384         QAction* a = createAction( id, tr( moduleTitle(modName) + QString(" Help") ), QIconSet(),
385                                    tr( moduleTitle(modName) + QString(" Help") ),
386                                    tr( moduleTitle(modName) + QString(" Help") ),
387                                    0, desk, false, this, SLOT( onHelpContentsModule() ) );
388         a->setName( modName );
389         createMenu( a, helpModuleMenu, -1 );
390         id++;
391       }
392     }
393   }
394
395   //! MRU
396   QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), desk );
397   connect( mru, SIGNAL( activated( QString ) ), this, SLOT( onMRUActivated( QString ) ) );
398   registerAction( MRUId, mru );
399
400   // default icon for neutral point ('SALOME' module)
401   QPixmap defIcon = resMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
402   if ( defIcon.isNull() )
403     defIcon = QPixmap( imageEmptyIcon );
404
405   //! default icon for any module
406   QPixmap modIcon = resMgr->loadPixmap( "LightApp", tr( "APP_MODULE_ICO" ), false );
407   if ( modIcon.isNull() )
408     modIcon = QPixmap( imageEmptyIcon );
409
410   QToolBar* modTBar = new QtxToolBar( true, desk );
411   modTBar->setLabel( tr( "INF_TOOLBAR_MODULES" ) );
412
413   QActionGroup* modGroup = new QActionGroup( this );
414   modGroup->setExclusive( true );
415   modGroup->setUsesDropDown( true );
416
417   a = createAction( -1, tr( "APP_NAME" ), defIcon, tr( "APP_NAME" ),
418                     tr( "PRP_APP_MODULE" ), 0, desk, true );
419   modGroup->add( a );
420   myActions.insert( QString(), a );
421
422   QMap<QString, QString> iconMap;
423   moduleIconNames( iconMap );
424
425   const int iconSize = 20;
426
427   modGroup->addTo( modTBar );
428   QObjectList *l = modTBar->queryList( "QComboBox" );
429   QObjectListIt oit( *l );
430   while ( QObject* obj = oit.current() ) {
431     QComboBox* cb = (QComboBox*)obj;
432     if ( cb ) cb->setFocusPolicy( QWidget::NoFocus );
433     ++oit;
434   }
435   delete l;
436   
437    modTBar->addSeparator();
438
439   QStringList modList;
440   modules( modList, false );
441
442   for ( it = modList.begin(); it != modList.end(); ++it )
443   {
444     if ( (*it).isEmpty() )
445       continue;
446
447     QString iconName;
448     if ( iconMap.contains( *it ) )
449       iconName = iconMap[*it];
450
451     QString modName = moduleName( *it );
452
453     QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
454     if ( icon.isNull() )
455       icon = modIcon;
456
457     icon.convertFromImage( icon.convertToImage().smoothScale( iconSize, iconSize, QImage::ScaleMin ) );
458
459     QAction* a = createAction( -1, *it, icon, *it, tr( "PRP_MODULE" ).arg( *it ), 0, desk, true );
460     a->addTo( modTBar );
461     modGroup->add( a );
462
463     myActions.insert( *it, a );
464   }
465
466   SUIT_Tools::simplifySeparators( modTBar );
467
468   // New window
469   int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, 100 );
470   int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
471   createMenu( separator(), windowMenu, -1, 1 );
472
473   QMap<int, int> accelMap;
474   accelMap[NewGLViewId]  = ALT+Key_G;
475   accelMap[NewPlot2dId]  = ALT+Key_P;
476   accelMap[NewOCCViewId] = ALT+Key_O;
477   accelMap[NewVTKViewId] = ALT+Key_K;
478
479   for ( id = NewGLViewId; id <= NewVTKViewId; id++ )
480   {
481     QAction* a = createAction( id, tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ), QIconSet(),
482                                tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ),
483                                tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ),
484                                accelMap.contains( id ) ? accelMap[id] : 0, desk, false, this, SLOT( onNewWindow() ) );
485     createMenu( a, newWinMenu, -1 );
486   }
487
488   createAction( RenameId, tr( "TOT_RENAME" ), QIconSet(), tr( "MEN_RENAME" ), tr( "PRP_RENAME" ),
489                 0, desk, false, this, SLOT( onRenameWindow() ) );
490   createMenu( RenameId, windowMenu, -1 );
491
492   connect( modGroup, SIGNAL( selected( QAction* ) ), this, SLOT( onModuleActivation( QAction* ) ) );
493
494   int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
495   createMenu( PreferencesId, fileMenu, 15, -1 );
496   createMenu( separator(), fileMenu, -1, 15, -1 );
497
498   /*
499   createMenu( separator(), fileMenu, -1, 100, -1 );
500   createMenu( MRUId, fileMenu, 100, -1 );
501   createMenu( separator(), fileMenu, -1, 100, -1 );
502   */
503 }
504
505 /*!On module activation action.*/
506 void LightApp_Application::onModuleActivation( QAction* a )
507 {
508   if ( !a )
509     return;
510
511   QString modName = a->menuText();
512   if ( modName == tr( "APP_NAME" ) )
513     modName = QString::null;
514
515   // Force user to create/open a study before module activation
516   QMap<QString, QString> iconMap;
517   moduleIconNames( iconMap );
518   QPixmap icon = resourceMgr()->loadPixmap( moduleName( modName ), iconMap[ modName ], false );
519   if ( icon.isNull() )
520     icon = resourceMgr()->loadPixmap( "LightApp", tr( "APP_MODULE_BIG_ICO" ), false ); // default icon for any module
521
522   bool cancelled = false;
523   while ( !modName.isEmpty() && !activeStudy() && !cancelled ){
524     LightApp_ModuleDlg aDlg( desktop(), modName, icon );
525     int res = aDlg.exec();
526
527     switch ( res ){
528     case 1:
529       onNewDoc();
530       break;
531     case 2:
532       onOpenDoc();
533       break;
534     case 3:
535       //onLoadStudy();
536       //break;
537     case 0:
538     default:
539       putInfo( tr("INF_CANCELLED") );
540       myActions[QString()]->setOn( true );
541       cancelled = true;
542     }
543   }
544
545   if ( !cancelled )
546     activateModule( modName );
547 }
548
549 /*!Default module activation.*/
550 QString LightApp_Application::defaultModule() const
551 {
552   QStringList aModuleNames;
553   modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration
554   //! If there's the one and only module --> activate it automatically
555   //! TODO: Possible improvement - default module can be taken from preferences
556   return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" );
557 }
558
559 /*!On new window slot.*/
560 void LightApp_Application::onNewWindow()
561 {
562   const QObject* obj = sender();
563   if ( !obj || !obj->inherits( "QAction" ) )
564     return;
565
566   QString type;
567   int id = actionId( (QAction*)obj );
568   switch ( id )
569   {
570   case NewGLViewId:
571     type = GLViewer_Viewer::Type();
572     break;
573   case NewPlot2dId:
574     type = Plot2d_Viewer::Type();
575     break;
576   case NewOCCViewId:
577     type = OCCViewer_Viewer::Type();
578     break;
579   case NewVTKViewId:
580     type = VTKViewer_Viewer::Type();
581     break;
582   }
583
584   if ( !type.isEmpty() )
585     createViewManager( type );
586 }
587
588 //=======================================================================
589 //  name    : onNewDoc
590 /*! Purpose : SLOT. Create new document*/
591 //=======================================================================
592 void LightApp_Application::onNewDoc()
593 {
594   SUIT_Study* study = activeStudy();
595
596   saveWindowsGeometry();
597
598   CAM_Application::onNewDoc();
599
600   if ( !study ) // new study will be create in THIS application
601   {
602     updateWindows();
603     updateViewManagers();
604   }
605 }
606
607 //=======================================================================
608 // name    : onOpenDoc
609 /*! Purpose : SLOT. Open new document*/
610 //=======================================================================
611 void LightApp_Application::onOpenDoc()
612 {
613   SUIT_Study* study = activeStudy();
614   saveWindowsGeometry();
615
616   CAM_Application::onOpenDoc();
617
618   if ( !study ) // new study will be create in THIS application
619   {
620     updateWindows();
621     updateViewManagers();
622   }
623 }
624
625 #include "SUIT_MessageBox.h"
626 /*! Purpose : SLOT. Open new document with \a aName.*/
627 bool LightApp_Application::onOpenDoc( const QString& aName )
628 {
629   bool isAlreadyOpen = false;
630
631   // Look among opened studies
632   if (activeStudy()) { // at least one study is opened
633     SUIT_Session* aSession = SUIT_Session::session();
634     QPtrList<SUIT_Application> aAppList = aSession->applications();
635     QPtrListIterator<SUIT_Application> it (aAppList);
636     SUIT_Application* aApp = 0;
637     // iterate on all applications
638     for (; (aApp = it.current()) && !isAlreadyOpen; ++it) {
639       if (aApp->activeStudy()->studyName() == aName) {
640         isAlreadyOpen = true; // Already opened, ask user what to do
641
642         // The document ... is already open.
643         // Do you want to reload it?
644         int aAnswer = SUIT_MessageBox::warn2(desktop(), tr("WRN_WARNING"),
645                                              tr("QUE_DOC_ALREADYOPEN").arg(aName),
646                                              tr("BUT_YES"), tr("BUT_NO"), 1, 2, 2);
647         if (aAnswer == 1) { // reload
648           if (activeStudy()->studyName() == aName && aAppList.count() > 1) {
649             // Opened in THIS (active) application.
650             STD_Application* app1 = (STD_Application*)aAppList.at(0);
651             STD_Application* app2 = (STD_Application*)aAppList.at(1);
652             if (!app1 || !app2) {
653               // Error
654               return false;
655             }
656             if (app1->activeStudy()->studyName() == aName) {
657               // app1 is this application, we need another one
658               app1 = app2;
659             }
660             // Close document of this application. This application will be destroyed.
661             onCloseDoc(/*ask = */false);
662             // Open the file with another application, as this one will be destroyed.
663             return app1->onOpenDoc(aName);
664           } else {
665             // Opened in another application.
666             STD_Application* app = (STD_Application*)aApp;
667             if (app)
668               app->onCloseDoc(/*ask = */false);
669           }
670         } else { // do not reload
671           // OK, the study will not be reloaded, but we call
672           // CAM_Application::onOpenDoc( aName ) all the same.
673           // It will activate a desktop of the study <aName>.
674         }
675       }
676     }
677   }
678
679   bool res = CAM_Application::onOpenDoc( aName );
680
681   QAction* a = action( MRUId );
682   if ( a && a->inherits( "QtxMRUAction" ) )
683   {
684     QtxMRUAction* mru = (QtxMRUAction*)a;
685     if ( res )
686       mru->insert( aName );
687     else
688       mru->remove( aName );
689   }
690   return res;
691 }
692
693 //=======================================================================
694 // name    : onHelpAbout
695 /*! Purpose : SLOT. Display "About" message box*/
696 //=======================================================================
697 void LightApp_Application::onHelpAbout()
698 {
699   LightApp_AboutDlg* dlg = new LightApp_AboutDlg( applicationName(), applicationVersion(), desktop() );
700   dlg->exec();
701   delete dlg;
702 }
703
704 /*!SLOT. Load document with \a aName.*/
705 bool LightApp_Application::onLoadDoc( const QString& aName )
706 {
707   bool res = CAM_Application::onLoadDoc( aName );
708
709   /*jfa tmp:QAction* a = action( MRUId );
710   if ( a && a->inherits( "QtxMRUAction" ) )
711   {
712     QtxMRUAction* mru = (QtxMRUAction*)a;
713     if ( res )
714       mru->insert( aName );
715     else
716       mru->remove( aName );
717   }*/
718   return res;
719 }
720
721 /*!Private SLOT. Selection.*/
722 void LightApp_Application::onSelection()
723 {
724   onSelectionChanged();
725
726   if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
727     ((LightApp_Module*)activeModule())->selectionChanged();
728 }
729
730 /*!Set active study.
731  *\param study - SUIT_Study.
732  */
733 void LightApp_Application::setActiveStudy( SUIT_Study* study )
734 {
735   CAM_Application::setActiveStudy( study );
736
737   activateWindows();
738 }
739
740 //=======================================================================
741 // name    : updateCommandsStatus
742 /*! Purpose : Enable/Disable menu items and toolbar buttons. Rebuild menu*/
743 //=======================================================================
744 void LightApp_Application::updateCommandsStatus()
745 {
746   CAM_Application::updateCommandsStatus();
747
748   for ( int id = NewGLViewId; id <= NewVTKViewId; id++ )
749   {
750     QAction* a = action( id );
751     if ( a )
752       a->setEnabled( activeStudy() );
753   }
754 }
755
756 // Helps to execute command
757 class RunBrowser: public QThread {
758 public:
759
760   RunBrowser(QString theApp, QString theParams, QString theHelpFile, QString theContext=NULL):
761     myApp(theApp), myParams(theParams), 
762 #ifdef WIN32
763       myHelpFile("file://" + theHelpFile + theContext), 
764 #else
765       myHelpFile("file:" + theHelpFile + theContext),
766 #endif
767       myStatus(0) {};
768
769   virtual void run()
770   {
771     QString aCommand;
772
773     if ( !myApp.isEmpty())
774       {
775         aCommand.sprintf("%s %s %s",myApp.latin1(),myParams.latin1(),myHelpFile.latin1());
776         myStatus = system(aCommand);
777         if(myStatus != 0)
778           {
779             QCustomEvent* ce2000 = new QCustomEvent (2000);
780             postEvent (qApp, ce2000);
781           }
782       }
783
784     if( myStatus != 0 || myApp.isEmpty())
785       {
786         myParams = "";
787         aCommand.sprintf("%s %s %s", QString(DEFAULT_BROWSER).latin1(),myParams.latin1(), myHelpFile.latin1());
788         myStatus = system(aCommand);
789         if(myStatus != 0)
790           {
791             QCustomEvent* ce2001 = new QCustomEvent (2001);
792             postEvent (qApp, ce2001);
793           }
794       }
795   }
796
797 private:
798   QString myApp;
799   QString myParams;
800   QString myHelpFile;
801   int myStatus;
802
803 };
804
805 //=======================================================================
806 // name    : onHelpContentsModule
807 /*! Purpose : SLOT. Display help contents for choosen module*/
808 //=======================================================================
809 void LightApp_Application::onHelpContentsModule()
810 {
811   const QAction* obj = (QAction*) sender();
812
813   QString aComponentName = obj->name();
814   QString aFileName = aComponentName + "_index_v3.1.0.html";
815
816   QCString dir = getenv( aComponentName + "_ROOT_DIR");
817   QString homeDir = Qtx::addSlash( Qtx::addSlash(dir) +  Qtx::addSlash("doc") +  Qtx::addSlash("salome") );
818
819   QString helpFile = QFileInfo( homeDir + aFileName ).absFilePath();
820   SUIT_ResourceMgr* resMgr = resourceMgr();
821   QString anApp = resMgr->stringValue("ExternalBrowser", "application");
822   QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
823
824   RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile);
825   rs->start();
826 }
827
828 /*!Sets enable or disable some actions on selection changed.*/
829 void LightApp_Application::onSelectionChanged()
830 {
831 }
832
833 /*!Return window.
834  *\param flag - key for window
835  *\param studyId - study id
836  * Flag used how identificator of window in windows list.
837  */
838 QWidget* LightApp_Application::window( const int flag, const int studyId ) const
839 {
840   QWidget* wid = 0;
841
842  int sId = studyId;
843   if ( sId < 0 )
844   {
845     if ( !activeStudy() )
846       return 0;
847     else
848       sId = activeStudy()->id();
849   }
850
851   if ( myWindows.contains( flag ) )
852     wid = myWindows[flag]->widget( sId );
853
854   return wid;
855 }
856
857 /*!Adds window to application.
858  *\param wid - QWidget
859  *\param flag - key wor window
860  *\param studyId - study id
861  * Flag used how identificator of window in windows list.
862  */
863 void LightApp_Application::addWindow( QWidget* wid, const int flag, const int studyId )
864 {
865   if ( !wid )
866     return;
867
868   int sId = studyId;
869   if ( sId < 0 )
870   {
871     if ( !activeStudy() )
872       return;
873     else
874       sId = activeStudy()->id();
875   }
876
877   if ( !myWindows.contains( flag ) )
878   {
879     QMap<int, int> winMap;
880     currentWindows( winMap );
881
882     LightApp_WidgetContainer* newWC = new LightApp_WidgetContainer( flag, desktop() );
883     connect( newWC, SIGNAL(  destroyed ( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
884     myWindows.insert( flag, newWC );
885     if ( winMap.contains( flag ) )
886       desktop()->moveDockWindow( myWindows[flag], (Dock)winMap[flag] );
887
888     myWindows[flag]->setResizeEnabled( true );
889     myWindows[flag]->setCloseMode( QDockWindow::Always );
890     myWindows[flag]->setName( QString( "dock_window_%1" ).arg( flag ) );
891   }
892
893   QFont f;
894   if( wid->inherits( "PythonConsole" ) )
895     f = ( ( PythonConsole* )wid )->font();
896   else
897     f = wid->font();
898
899   myWindows[flag]->insert( sId, wid );
900   wid->setFont(f);
901
902   setWindowShown( flag, !myWindows[flag]->isEmpty() );
903 }
904
905 /*!Remove window from application.
906  *\param flag - key wor window
907  *\param studyId - study id
908  * Flag used how identificator of window in windows list.
909  */
910 void LightApp_Application::removeWindow( const int flag, const int studyId )
911 {
912   if ( !myWindows.contains( flag ) )
913     return;
914
915   int sId = studyId;
916   if ( sId < 0 )
917   {
918     if ( !activeStudy() )
919       return;
920     else
921       sId = activeStudy()->id();
922   }
923
924   QWidget* wid = myWindows[flag]->widget( sId );
925   myWindows[flag]->remove( sId );
926   delete wid;
927
928   setWindowShown( flag, !myWindows[flag]->isEmpty() );
929 }
930
931 /*!Gets window.
932  *\param flag - key wor window
933  *\param studyId - study id
934  * Flag used how identificator of window in windows list.
935  */
936 QWidget* LightApp_Application::getWindow( const int flag, const int studyId )
937 {
938   QWidget* wid = window( flag, studyId );
939   if ( !wid )
940     addWindow( wid = createWindow( flag ), flag, studyId );
941
942   return wid;
943 }
944
945 /*!Check is window visible?(with identificator \a type)*/
946 bool LightApp_Application::isWindowVisible( const int type ) const
947 {
948   bool res = false;
949   if ( myWindows.contains( type ) )
950   {
951     SUIT_Desktop* desk = ((LightApp_Application*)this)->desktop();
952     res = desk && desk->appropriate( myWindows[type] );
953   }
954   return res;
955 }
956
957 /*!Sets window show or hide.
958  *\param type - window identificator.
959  *\param on   - true/false (window show/hide)
960  */
961 void LightApp_Application::setWindowShown( const int type, const bool on )
962 {
963   if ( !desktop() || !myWindows.contains( type ) )
964     return;
965
966   QDockWindow* dw = myWindows[type];
967   desktop()->setAppropriate( dw, on );
968   on ? dw->show() : dw->hide();
969 }
970
971 /*!Gets "ObjectBrowser".*/
972 OB_Browser* LightApp_Application::objectBrowser()
973 {
974   OB_Browser* ob = 0;
975   QWidget* wid = window( WT_ObjectBrowser );
976   if ( wid && wid->inherits( "OB_Browser" ) )
977     ob = (OB_Browser*)wid;
978   return ob;
979 }
980
981 /*!Gets "LogWindow".*/
982 LogWindow* LightApp_Application::logWindow()
983 {
984   LogWindow* lw = 0;
985   QWidget* wid = getWindow( WT_LogWindow );
986   if ( wid->inherits( "LogWindow" ) )
987     lw = (LogWindow*)wid;
988   return lw;
989 }
990
991 /*!Get "PythonConsole"*/
992 PythonConsole* LightApp_Application::pythonConsole()
993 {
994   PythonConsole* console = 0;
995   QWidget* wid = getWindow( WT_PyConsole );
996   if ( wid->inherits( "PythonConsole" ) )
997     console = (PythonConsole*)wid;
998   return console;
999 }
1000
1001 /*!Update obect browser*/
1002 void LightApp_Application::updateObjectBrowser( const bool updateModels )
1003 {
1004   // update existing data models
1005   if ( updateModels ) 
1006   {
1007     LightApp_Study* study = dynamic_cast<LightApp_Study*>(activeStudy());
1008     if ( study ) {
1009       CAM_Study::ModelList dm_list;
1010       study->dataModels( dm_list );
1011       for ( CAM_Study::ModelListIterator it( dm_list ); it.current(); ++it ) {
1012         CAM_DataModel* camDM = it.current();
1013         if ( camDM && camDM->inherits( "LightApp_DataModel" ) )
1014           ((LightApp_DataModel*)camDM)->update();
1015       }
1016     }
1017   }
1018   if ( objectBrowser() )
1019   {
1020     objectBrowser()->updateGeometry();
1021     objectBrowser()->updateTree();
1022   }
1023 }
1024
1025 /*!Gets preferences.*/
1026 LightApp_Preferences* LightApp_Application::preferences() const
1027 {
1028   return preferences( false );
1029 }
1030
1031 /*!Gets view manager*/
1032 SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, const bool create )
1033 {
1034   SUIT_ViewManager* aVM = viewManager( vmType );
1035   SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
1036
1037   if ( anActiveVM && anActiveVM->getType() == vmType )
1038     aVM = anActiveVM;
1039
1040   if ( aVM && create )
1041   {
1042     if ( !aVM->getActiveView() )
1043       aVM->createView();
1044     else
1045       aVM->getActiveView()->setFocus();
1046   }
1047   else if ( create )
1048     aVM = createViewManager( vmType );
1049
1050   return aVM;
1051 }
1052
1053 /*!Create view manager.*/
1054 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType )
1055 {
1056   SUIT_ResourceMgr* resMgr = resourceMgr();
1057
1058   SUIT_ViewManager* viewMgr = 0;
1059   if( vmType == GLViewer_Viewer::Type() )
1060   {
1061     viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() );
1062     new LightApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
1063   }
1064   else if( vmType == Plot2d_Viewer::Type() )
1065   {
1066     viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
1067     SPlot2d_Viewer* vm = new SPlot2d_Viewer();
1068     viewMgr->setViewModel( vm  );// custom view model, which extends SALOME_View interface 
1069     Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
1070     if( wnd )
1071     {
1072       Plot2d_ViewFrame* frame = wnd->getViewFrame();
1073       frame->setBackgroundColor( resMgr->colorValue( "Plot2d", "Background", frame->backgroundColor() ) );
1074     }
1075   }
1076   else if( vmType == SUPERVGraph_Viewer::Type() )
1077   {
1078     viewMgr = new SUPERVGraph_ViewManager( activeStudy(), desktop() );
1079     SUPERVGraph_Viewer* vm = new SUPERVGraph_Viewer();
1080     SUPERVGraph_ViewFrame* view = dynamic_cast<SUPERVGraph_ViewFrame*>( vm->getViewManager()->getActiveView() );
1081     if( view )
1082       view->setBackgroundColor( resMgr->colorValue( "SUPERVGraph", "Background", view->backgroundColor() ) );
1083   }
1084   else if( vmType == OCCViewer_Viewer::Type() )
1085   {
1086     viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
1087     SOCC_Viewer* vm = new SOCC_Viewer();
1088     vm->setBackgroundColor( resMgr->colorValue( "OCCViewer", "background", vm->backgroundColor() ) );
1089     vm->setTrihedronSize( resMgr->integerValue( "OCCViewer", "trihedron_size", vm->trihedronSize() ) );
1090     int u( 1 ), v( 1 );
1091     vm->isos( u, v );
1092     u = resMgr->integerValue( "OCCViewer", "iso_number_u", u );
1093     v = resMgr->integerValue( "OCCViewer", "iso_number_v", v );
1094     vm->setIsos( u, v );
1095     viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1096     new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
1097   }
1098   else if ( vmType == SVTK_Viewer::Type() )
1099   {
1100     viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
1101     SVTK_Viewer* vm = dynamic_cast<SVTK_Viewer*>( viewMgr->getViewModel() );
1102     if( vm )
1103     {
1104       vm->setBackgroundColor( resMgr->colorValue( "VTKViewer", "background", vm->backgroundColor() ) );
1105       vm->setTrihedronSize( resMgr->integerValue( "VTKViewer", "trihedron_size", vm->trihedronSize() ) );
1106       new LightApp_VTKSelector( vm, mySelMgr );
1107     }
1108   }
1109
1110   if ( !viewMgr )
1111     return 0;
1112
1113   addViewManager( viewMgr );
1114   SUIT_ViewWindow* viewWin = viewMgr->createViewWindow();
1115
1116   if ( viewWin && desktop() )
1117     viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1118
1119   connect( viewMgr, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
1120            this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
1121
1122   return viewMgr;
1123 }
1124
1125 //=======================================================================
1126 // name    : onCloseView
1127 /*! Purpose : SLOT. Remove view manager from application*/
1128 //=======================================================================
1129 void LightApp_Application::onCloseView( SUIT_ViewManager* theVM )
1130 {
1131   removeViewManager( theVM );
1132 }
1133
1134 /*!Protected SLOT. On study created.*/
1135 void LightApp_Application::onStudyCreated( SUIT_Study* theStudy )
1136 {
1137   SUIT_DataObject* aRoot = 0;
1138   if ( theStudy && theStudy->root() )
1139   {
1140     aRoot = theStudy->root();
1141     //aRoot->setName( tr( "DATA_MODELS" ) );
1142   }
1143   getWindow( WT_ObjectBrowser );
1144   if ( objectBrowser() != 0 )
1145     objectBrowser()->setRootObject( aRoot );
1146
1147   activateModule( defaultModule() );
1148
1149   activateWindows();
1150 }
1151
1152 /*!Protected SLOT. On study opened.*/
1153 void LightApp_Application::onStudyOpened( SUIT_Study* theStudy )
1154 {
1155   SUIT_DataObject* aRoot = 0;
1156   if ( theStudy && theStudy->root() )
1157   {
1158     aRoot = theStudy->root();
1159     //aRoot->dump();
1160   }
1161   getWindow( WT_ObjectBrowser );
1162   if ( objectBrowser() != 0 ) {
1163     objectBrowser()->setRootObject( aRoot );
1164   }
1165
1166   activateModule( defaultModule() );
1167
1168   activateWindows();
1169
1170   emit studyOpened();
1171 }
1172
1173 /*!Protected SLOT. On study saved.*/
1174 void LightApp_Application::onStudySaved( SUIT_Study* )
1175 {
1176   emit studySaved();
1177 }
1178
1179 /*!Protected SLOT. On study closed.*/
1180 void LightApp_Application::onStudyClosed( SUIT_Study* )
1181 {
1182   emit studyClosed();
1183
1184   // Bug 10396: clear selection
1185   mySelMgr->clearSelected();
1186
1187   activateModule( "" );
1188
1189   saveWindowsGeometry();
1190 }
1191
1192 /*!Protected SLOT.On desktop activated.*/
1193 void LightApp_Application::onDesktopActivated()
1194 {
1195   CAM_Application::onDesktopActivated();
1196   LightApp_Module* aModule = dynamic_cast<LightApp_Module*>(activeModule());
1197   if(aModule)
1198     aModule->studyActivated();
1199 }
1200
1201 /*!Gets file filter.
1202  *\retval QString "(*.bin)"
1203  */
1204 QString LightApp_Application::getFileFilter() const
1205 {
1206   return "(*.bin)";
1207 }
1208
1209 /*! Gets file name*/
1210 QString LightApp_Application::getFileName( bool open, const QString& initial, const QString& filters, 
1211                                            const QString& caption, QWidget* parent )
1212 {
1213   if ( !parent )
1214     parent = desktop();
1215   QStringList fls = QStringList::split( ";;", filters, false );
1216   return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
1217 }
1218
1219 /*! Gets directory*/
1220 QString LightApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
1221 {
1222   if ( !parent )
1223     parent = desktop();
1224   return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true );
1225 }
1226
1227 /*! Get open file names*/
1228 QStringList LightApp_Application::getOpenFileNames( const QString& initial, const QString& filters, 
1229                                                     const QString& caption, QWidget* parent )
1230 {
1231   if ( !parent )
1232     parent = desktop();
1233   QStringList fls = QStringList::split( ";;", filters, false );
1234   return SUIT_FileDlg::getOpenFileNames( parent, initial, fls, caption, true );
1235 }
1236
1237 /*!Private SLOT. Update object browser.*/
1238 void LightApp_Application::onRefresh()
1239 {
1240   updateObjectBrowser( true );
1241 }
1242
1243 /*!Private SLOT. On preferences.*/
1244 void LightApp_Application::onPreferences()
1245 {
1246   QApplication::setOverrideCursor( Qt::waitCursor );
1247
1248   LightApp_PreferencesDlg* prefDlg = new LightApp_PreferencesDlg( preferences( true ), desktop());
1249
1250   QApplication::restoreOverrideCursor();
1251
1252   if ( !prefDlg )
1253     return;
1254
1255   prefDlg->exec();
1256
1257   delete prefDlg;
1258 }
1259
1260 /*!Protected SLOT. On preferences changed.*/
1261 void LightApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param )
1262 {
1263   LightApp_Module* sMod = 0;
1264   CAM_Module* mod = module( modName );
1265   if ( mod && mod->inherits( "LightApp_Module" ) )
1266     sMod = (LightApp_Module*)mod;
1267
1268   if ( sMod )
1269     sMod->preferencesChanged( section, param );
1270   else
1271     preferencesChanged( section, param );
1272 }
1273
1274 /*!Private SLOT. On open document with name \a aName.*/
1275 void LightApp_Application::onMRUActivated( QString aName )
1276 {
1277   onOpenDoc( aName );
1278 }
1279
1280 /*!Remove all windows from study.*/
1281 void LightApp_Application::beforeCloseDoc( SUIT_Study* s )
1282 {
1283   CAM_Application::beforeCloseDoc( s );
1284
1285   for ( WindowMap::ConstIterator itr = myWindows.begin(); s && itr != myWindows.end(); ++itr )
1286     removeWindow( itr.key(), s->id() );
1287 }
1288
1289 /*!Update actions.*/
1290 void LightApp_Application::updateActions()
1291 {
1292   updateCommandsStatus();
1293 }
1294
1295 //=======================================================================
1296 // name    : createNewStudy
1297 /*! Purpose : Create new study*/
1298 //=======================================================================
1299 SUIT_Study* LightApp_Application::createNewStudy()
1300 {
1301   LightApp_Study* aStudy = new LightApp_Study( this );
1302
1303   // Set up processing of major study-related events
1304   connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
1305   connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
1306   connect( aStudy, SIGNAL( saved  ( SUIT_Study* ) ), this, SLOT( onStudySaved  ( SUIT_Study* ) ) );
1307   connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
1308
1309   return aStudy;
1310 }
1311
1312 /*!Create window.*/
1313 QWidget* LightApp_Application::createWindow( const int flag )
1314 {
1315   QWidget* wid = 0;
1316   if ( flag == WT_ObjectBrowser )
1317   {
1318     OB_Browser* ob = new OB_Browser( desktop() );
1319     ob->setAutoUpdate( true );
1320     ob->setAutoOpenLevel( 1 );
1321     ob->setCaption( tr( "OBJECT_BROWSER" ) );
1322     ob->listView()->setColumnWidth( 0, OBJECT_COLUMN_WIDTH );
1323     ob->resize( OBJECT_BROWSER_WIDTH, ob->height() );
1324     ob->setFilter( new LightApp_OBFilter( selectionMgr() ) );
1325
1326     ob->setNameTitle( tr( "OBJ_BROWSER_NAME" ) );
1327
1328     // Create OBSelector
1329     new LightApp_OBSelector( ob, mySelMgr );
1330
1331     wid = ob;
1332
1333     ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1334   }
1335   else  if ( flag == WT_PyConsole )
1336   {
1337     PythonConsole* pyCons = new PythonConsole( desktop() );
1338     pyCons->setCaption( tr( "PYTHON_CONSOLE" ) );
1339     wid = pyCons;
1340     //    pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1341   }
1342   else if ( flag == WT_LogWindow )
1343   {
1344     LogWindow* logWin = new LogWindow( desktop() );
1345     logWin->setCaption( tr( "LOG_WINDOW" ) );
1346     wid = logWin;
1347     logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1348   }
1349   return wid;
1350 }
1351
1352 /*!Default windows(Object Browser, Python Console).
1353  * Adds to map \a aMap.
1354  */
1355 void LightApp_Application::defaultWindows( QMap<int, int>& aMap ) const
1356 {  
1357   aMap.insert( WT_ObjectBrowser, Qt::DockLeft );
1358   aMap.insert( WT_PyConsole, Qt::DockBottom );
1359   //  aMap.insert( WT_LogWindow, Qt::DockBottom );
1360 }
1361
1362 /*!Default view manager.*/
1363 void LightApp_Application::defaultViewManagers( QStringList& ) const
1364 {
1365   /*!Do nothing.*/
1366 }
1367
1368 /*!Gets preferences.
1369  * Create preferences, if \a crt = true.
1370  */
1371 LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const
1372 {
1373   if ( myPrefs )
1374     return myPrefs;
1375
1376   LightApp_Application* that = (LightApp_Application*)this;
1377
1378   if ( !_prefs_ && crt )
1379   {
1380     _prefs_ = new LightApp_Preferences( resourceMgr() );
1381     that->createPreferences( _prefs_ );
1382   }
1383
1384   that->myPrefs = _prefs_;
1385
1386   QPtrList<SUIT_Application> appList = SUIT_Session::session()->applications();
1387   for ( QPtrListIterator<SUIT_Application> appIt ( appList ); appIt.current(); ++appIt )
1388   {
1389     if ( !appIt.current()->inherits( "LightApp_Application" ) )
1390       continue;
1391
1392     LightApp_Application* app = (LightApp_Application*)appIt.current();
1393
1394     QStringList modNameList;
1395     app->modules( modNameList, false );
1396     for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it )
1397     {
1398       int id = _prefs_->addPreference( *it );
1399       _prefs_->setItemProperty( id, "info", tr( "PREFERENCES_NOT_LOADED" ).arg( *it ) );
1400     }
1401
1402     ModuleList modList;
1403     app->modules( modList );
1404     for ( ModuleListIterator itr( modList ); itr.current(); ++itr )
1405     {
1406       LightApp_Module* mod = 0;
1407       if ( itr.current()->inherits( "LightApp_Module" ) )
1408         mod = (LightApp_Module*)itr.current();
1409
1410       if ( mod && !_prefs_->hasModule( mod->moduleName() ) )
1411       {
1412         int modCat = _prefs_->addPreference( mod->moduleName() );
1413         _prefs_->setItemProperty( modCat, "info", QString::null );
1414         mod->createPreferences();
1415       }
1416     }
1417   }
1418
1419   connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
1420            this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ) );
1421
1422   return myPrefs;
1423 }
1424
1425 /*!Add new module to application.*/
1426 void LightApp_Application::moduleAdded( CAM_Module* mod )
1427 {
1428   CAM_Application::moduleAdded( mod );
1429
1430   LightApp_Module* lightMod = 0;
1431   if ( mod && mod->inherits( "LightApp_Module" ) )
1432     lightMod = (LightApp_Module*)mod;
1433
1434   if ( myPrefs && lightMod && !myPrefs->hasModule( lightMod->moduleName() ))
1435   {
1436     int modCat = myPrefs->addPreference( mod->moduleName() );
1437     myPrefs->setItemProperty( modCat, "info", QString::null );
1438     lightMod->createPreferences();
1439   }
1440 }
1441
1442 /*!Create preferences.*/
1443 void LightApp_Application::createPreferences( LightApp_Preferences* pref )
1444 {
1445   if ( !pref )
1446     return;
1447
1448   int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
1449
1450   int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat );
1451   int studyGroup = pref->addPreference( tr( "PREF_GROUP_STUDY" ), genTab );
1452   pref->setItemProperty( studyGroup, "columns", 1 );
1453
1454   pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "multi_file" );
1455   pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" );
1456   int undoPref = pref->addPreference( tr( "PREF_UNDO_LEVEL" ), studyGroup, LightApp_Preferences::IntSpin, "Study", "undo_level" );
1457   pref->setItemProperty( undoPref, "min", 1 );
1458   pref->setItemProperty( undoPref, "max", 100 );
1459
1460   int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab );
1461   pref->setItemProperty( extgroup, "columns", 1 );
1462   int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, LightApp_Preferences::File, "ExternalBrowser", "application" );
1463   pref->setItemProperty( apppref, "existing", true );
1464   pref->setItemProperty( apppref, "flags", QFileInfo::ExeUser );
1465
1466   pref->addPreference( tr( "PREF_PARAM" ), extgroup, LightApp_Preferences::String, "ExternalBrowser", "parameters" );
1467
1468   int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab );
1469   pref->setItemProperty( pythonConsoleGroup, "columns", 1 );
1470   pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, LightApp_Preferences::Font, "PyConsole", "font" );
1471
1472   int viewTab = pref->addPreference( tr( "PREF_TAB_VIEWERS" ), salomeCat );
1473
1474   int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), viewTab );
1475
1476   int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), viewTab );
1477
1478   int plot2dGroup = pref->addPreference( tr( "PREF_GROUP_PLOT2DVIEWER" ), viewTab );
1479
1480   int supervGroup = pref->addPreference( tr( "PREF_GROUP_SUPERV" ), viewTab );
1481
1482   pref->setItemProperty( occGroup, "columns", 1 );
1483   pref->setItemProperty( vtkGroup, "columns", 1 );
1484   pref->setItemProperty( plot2dGroup, "columns", 1 );
1485
1486   int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occGroup,
1487                                    LightApp_Preferences::IntSpin, "OCCViewer", "trihedron_size" );
1488   pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup,
1489                        LightApp_Preferences::Color, "OCCViewer", "background" );
1490
1491   pref->setItemProperty( occTS, "min", 1 );
1492   pref->setItemProperty( occTS, "max", 150 );
1493
1494   int isoU = pref->addPreference( tr( "PREF_ISOS_U" ), occGroup,
1495                                   LightApp_Preferences::IntSpin, "OCCViewer", "iso_number_u" );
1496   int isoV = pref->addPreference( tr( "PREF_ISOS_V" ), occGroup,
1497                                   LightApp_Preferences::IntSpin, "OCCViewer", "iso_number_v" );
1498
1499   pref->setItemProperty( isoU, "min", 0 );
1500   pref->setItemProperty( isoU, "max", 100000 );
1501
1502   pref->setItemProperty( isoV, "min", 0 );
1503   pref->setItemProperty( isoV, "max", 100000 );
1504
1505   int vtkTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), vtkGroup,
1506                                    LightApp_Preferences::IntSpin, "VTKViewer", "trihedron_size" );
1507   pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), vtkGroup, LightApp_Preferences::Bool, "VTKViewer", "relative_size" );
1508   pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGroup,
1509                        LightApp_Preferences::Color, "VTKViewer", "background" );
1510
1511   pref->setItemProperty( vtkTS, "min", 1 );
1512   pref->setItemProperty( vtkTS, "max", 150 );
1513
1514   pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dGroup,
1515                        LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
1516
1517   int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dGroup,
1518                                             LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
1519   QStringList aLegendPosList;
1520   aLegendPosList.append( tr("PREF_LEFT") );
1521   aLegendPosList.append( tr("PREF_RIGHT") );
1522   aLegendPosList.append( tr("PREF_TOP") );
1523   aLegendPosList.append( tr("PREF_BOTTOM") );
1524
1525   QValueList<QVariant> anIndexesList;
1526   anIndexesList.append(0);
1527   anIndexesList.append(1);
1528   anIndexesList.append(2);
1529   anIndexesList.append(3);
1530
1531   pref->setItemProperty( legendPosition, "strings", aLegendPosList );
1532   pref->setItemProperty( legendPosition, "indexes", anIndexesList );
1533
1534   int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dGroup,
1535                                        LightApp_Preferences::Selector, "Plot2d", "CurveType" );
1536   QStringList aCurveTypesList;
1537   aCurveTypesList.append( tr("PREF_POINTS") );
1538   aCurveTypesList.append( tr("PREF_LINES") );
1539   aCurveTypesList.append( tr("PREF_SPLINE") );
1540
1541   anIndexesList.clear();
1542   anIndexesList.append(0);
1543   anIndexesList.append(1);
1544   anIndexesList.append(2);
1545   
1546   pref->setItemProperty( curveType, "strings", aCurveTypesList );
1547   pref->setItemProperty( curveType, "indexes", anIndexesList );
1548
1549   int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dGroup,
1550                                         LightApp_Preferences::IntSpin, "Plot2d", "MarkerSize" );
1551
1552   pref->setItemProperty( markerSize, "min", 0 );
1553   pref->setItemProperty( markerSize, "max", 100 );
1554   
1555   QStringList aScaleModesList;
1556   aScaleModesList.append( tr("PREF_LINEAR") );
1557   aScaleModesList.append( tr("PREF_LOGARITHMIC") );
1558   
1559   anIndexesList.clear();
1560   anIndexesList.append(0);
1561   anIndexesList.append(1);
1562
1563   int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dGroup,
1564                                       LightApp_Preferences::Selector, "Plot2d", "HorScaleMode" );
1565
1566   pref->setItemProperty( horScale, "strings", aScaleModesList );
1567   pref->setItemProperty( horScale, "indexes", anIndexesList );
1568
1569   int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dGroup,
1570                                       LightApp_Preferences::Selector, "Plot2d", "VerScaleMode" );
1571
1572   pref->setItemProperty( verScale, "strings", aScaleModesList );
1573   pref->setItemProperty( verScale, "indexes", anIndexesList );
1574
1575   pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), plot2dGroup,
1576                        LightApp_Preferences::Color, "Plot2d", "Background" );
1577
1578   int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat );
1579   int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab );
1580   pref->setItemProperty( dirGroup, "columns", 1 );
1581   pref->addPreference( tr( "" ), dirGroup,
1582                        LightApp_Preferences::DirList, "FileDlg", "QuickDirList" );
1583
1584   pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), supervGroup,
1585                        LightApp_Preferences::Color, "SUPERVGraph", "Background" );
1586   pref->addPreference( tr( "PREF_SUPERV_TITLE_COLOR" ), supervGroup,
1587                        LightApp_Preferences::Color, "SUPERVGraph", "Title" );
1588 //  pref->addPreference( tr( "PREF_SUPERV_CTRL_COLOR" ), supervGroup,
1589 //                     LightApp_Preferences::Color, "SUPERVGraph", "Ctrl" );
1590 }
1591
1592 /*!Changed preferences */
1593 void LightApp_Application::preferencesChanged( const QString& sec, const QString& param )
1594 {
1595   SUIT_ResourceMgr* resMgr = resourceMgr();
1596   if ( !resMgr )
1597     return;
1598
1599   if ( sec == QString( "OCCViewer" ) && param == QString( "trihedron_size" ) )
1600   {
1601     int sz = resMgr->integerValue( sec, param, -1 );
1602     QPtrList<SUIT_ViewManager> lst;
1603     viewManagers( OCCViewer_Viewer::Type(), lst );
1604     for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current() && sz >= 0; ++it )
1605     {
1606       SUIT_ViewModel* vm = it.current()->getViewModel();
1607       if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
1608         continue;
1609
1610       OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
1611       occVM->setTrihedronSize( sz );
1612       occVM->getAISContext()->UpdateCurrentViewer();
1613     }
1614   }
1615
1616   if ( sec == QString( "VTKViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )) )
1617   {
1618     int sz = resMgr->integerValue( "VTKViewer", "trihedron_size", -1 );
1619     QPtrList<SUIT_ViewManager> lst;
1620     viewManagers( SVTK_Viewer::Type(), lst );
1621     for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current() && sz >= 0; ++it )
1622     {
1623       SUIT_ViewModel* vm = it.current()->getViewModel();
1624       if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
1625         continue;
1626
1627       SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
1628       if( vtkVM )
1629       {
1630         vtkVM->setTrihedronSize( sz );
1631         vtkVM->Repaint();
1632       }
1633     }
1634   }
1635
1636   if ( sec == QString( "OCCViewer" ) && ( param == QString( "iso_number_u" ) || param == QString( "iso_number_v" ) ) )
1637   {
1638     QPtrList<SUIT_ViewManager> lst;
1639     viewManagers( OCCViewer_Viewer::Type(), lst );
1640     int u = resMgr->integerValue( sec, "iso_number_u" );
1641     int v = resMgr->integerValue( sec, "iso_number_v" );
1642     for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current(); ++it )
1643     {
1644       OCCViewer_ViewManager* mgr = dynamic_cast<OCCViewer_ViewManager*>( it.current() );
1645       if( mgr && mgr->getOCCViewer() )
1646         mgr->getOCCViewer()->setIsos( u, v );
1647     }
1648   }
1649
1650   if( sec=="ObjectBrowser" )
1651   {
1652     if( param=="auto_size" )
1653     {
1654       OB_Browser* ob = objectBrowser();
1655       if( !ob )
1656         return;
1657
1658       bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
1659       ob->setWidthMode( autoSize ? QListView::Maximum : QListView::Manual );
1660
1661       updateObjectBrowser( false );
1662     }
1663   }
1664
1665   if( sec=="PyConsole" )
1666   {
1667     if( param=="font" )
1668       if( pythonConsole() )
1669         pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) );
1670   }
1671 }
1672
1673 /*!Update desktop title.*/
1674 void LightApp_Application::updateDesktopTitle() {
1675   QString aTitle = applicationName();
1676   QString aVer = applicationVersion();
1677   if ( !aVer.isEmpty() )
1678     aTitle += QString( " " ) + aVer;
1679
1680   desktop()->setCaption( aTitle );
1681 }
1682
1683 /*!Update windows after close document.*/
1684 void LightApp_Application::afterCloseDoc()
1685 {
1686   updateWindows();
1687
1688   CAM_Application::afterCloseDoc();
1689 }
1690
1691 /*!Update module action.*/
1692 void LightApp_Application::updateModuleActions()
1693 {
1694   QString modName;
1695   if ( activeModule() )
1696     modName = activeModule()->moduleName();
1697
1698   if ( myActions.contains( modName ) )
1699     myActions[modName]->setOn( true );
1700 }
1701
1702 /*!Gets current windows.
1703  *\param winMap - output current windows map.
1704  */
1705 void LightApp_Application::currentWindows( QMap<int, int>& winMap ) const
1706 {
1707   winMap.clear();
1708   if ( !activeStudy() )
1709     return;
1710
1711   if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
1712     ((LightApp_Module*)activeModule())->windows( winMap );
1713   else
1714     defaultWindows( winMap );
1715 }
1716
1717 /*!Gets current view managers.
1718  *\param lst - output current view managers list.
1719  */
1720 void LightApp_Application::currentViewManagers( QStringList& lst ) const
1721 {
1722   lst.clear();
1723   if ( !activeStudy() )
1724     return;
1725
1726   if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
1727     ((LightApp_Module*)activeModule())->viewManagers( lst );
1728   else
1729     defaultViewManagers( lst );
1730 }
1731
1732 /*!Update windows.*/
1733 void LightApp_Application::updateWindows()
1734 {
1735   QMap<int, int> winMap;
1736   currentWindows( winMap );
1737
1738   for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
1739     getWindow( it.key() );
1740
1741   loadWindowsGeometry();
1742
1743   for ( WindowMap::ConstIterator itr = myWindows.begin(); itr != myWindows.end(); ++itr )
1744     setWindowShown( itr.key(), !itr.data()->isEmpty() && winMap.contains( itr.key() ) );
1745 }
1746
1747 /*!Update view managers.*/
1748 void LightApp_Application::updateViewManagers()
1749 {
1750   QStringList lst;
1751   currentViewManagers( lst );
1752
1753   for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
1754     getViewManager( *it, true );
1755 }
1756
1757 /*!Load windows geometry.*/
1758 void LightApp_Application::loadWindowsGeometry()
1759 {
1760   QtxDockAction* dockMgr = 0;
1761
1762   QAction* a = action( ViewWindowsId );
1763   if ( a && a->inherits( "QtxDockAction" ) )
1764     dockMgr = (QtxDockAction*)a;
1765
1766   if ( !dockMgr )
1767     return;
1768
1769   QString modName;
1770   if ( activeModule() )
1771     modName = activeModule()->name("");
1772
1773   QString section = QString( "windows_geometry" );
1774   if ( !modName.isEmpty() )
1775     section += QString( "." ) + modName;
1776
1777   dockMgr->loadGeometry( resourceMgr(), section, false );
1778   dockMgr->restoreGeometry();
1779 }
1780
1781 /*!Save windows geometry.*/
1782 void LightApp_Application::saveWindowsGeometry()
1783 {
1784   QtxDockAction* dockMgr = 0;
1785
1786   QAction* a = action( ViewWindowsId );
1787   if ( a && a->inherits( "QtxDockAction" ) )
1788     dockMgr = (QtxDockAction*)a;
1789
1790   if ( !dockMgr )
1791     return;
1792
1793   QString modName;
1794   if ( activeModule() )
1795     modName = activeModule()->name("");
1796
1797   QString section = QString( "windows_geometry" );
1798   if ( !modName.isEmpty() )
1799     section += QString( "." ) + modName;
1800
1801   dockMgr->storeGeometry();
1802   dockMgr->saveGeometry( resourceMgr(), section, false );
1803 }
1804
1805 /*!Activate windows.*/
1806 void LightApp_Application::activateWindows()
1807 {
1808   if ( activeStudy() )
1809   {
1810     for ( WindowMap::Iterator itr = myWindows.begin(); itr != myWindows.end(); ++itr )
1811       itr.data()->activate( activeStudy()->id() );
1812   }
1813 }
1814
1815 /*!Adds icon names for modules.*/
1816 void LightApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) const
1817 {
1818   iconMap.clear();
1819
1820   SUIT_ResourceMgr* resMgr = resourceMgr();
1821   if ( !resMgr )
1822     return;
1823
1824   QStringList modList;
1825   modules( modList, false );
1826
1827   for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )
1828   {
1829     QString modName = *it;
1830     QString modIntr = moduleName( modName );
1831     QString modIcon = resMgr->stringValue( modIntr, "icon", QString::null );
1832
1833     if ( modIcon.isEmpty() )
1834       continue;
1835
1836     if ( SUIT_Tools::extension( modIcon ).isEmpty() )
1837       modIcon += QString( ".png" );
1838
1839     iconMap.insert( modName, modIcon );
1840   }
1841 }
1842
1843 /*!Insert items in popup, which necessary for current application*/
1844 void LightApp_Application::contextMenuPopup( const QString& type, QPopupMenu* thePopup, QString& title )
1845 {
1846   CAM_Application::contextMenuPopup( type, thePopup, title );
1847
1848   OB_Browser* ob = objectBrowser();
1849   if ( !ob || type != ob->popupClientType() )
1850     return;
1851
1852   thePopup->insertSeparator();
1853   thePopup->insertItem( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
1854 }
1855
1856 /*!Create empty study.*/
1857 void LightApp_Application::createEmptyStudy()
1858 {
1859   CAM_Application::createEmptyStudy();
1860   if ( objectBrowser() )
1861     objectBrowser()->updateTree();
1862 }
1863
1864 /*!Activate module \a mod.*/
1865 bool LightApp_Application::activateModule( CAM_Module* mod )
1866 {
1867   bool res = CAM_Application::activateModule( mod );
1868   if ( objectBrowser() )
1869     objectBrowser()->updateTree();
1870   return res;
1871 }
1872
1873 /*!return keyborad accelerators manager object */
1874 SUIT_Accel* LightApp_Application::accel() const
1875 {
1876   return myAccel;
1877 }
1878
1879 /*! remove dead widget container from map */
1880 void LightApp_Application::onWCDestroyed( QObject* ob )
1881 {
1882   // remove destroyed widget container from windows map
1883   for ( WindowMap::ConstIterator itr = myWindows.begin(); itr != myWindows.end(); ++itr )
1884   {
1885     if ( itr.data() != ob )
1886       continue;
1887
1888     int key = itr.key();
1889     myWindows.remove( key );
1890     break;
1891   }
1892 }
1893
1894 /*! redefined to remove view manager from memory */
1895 void LightApp_Application::removeViewManager( SUIT_ViewManager* vm )
1896 {
1897   disconnect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
1898            this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
1899   STD_Application::removeViewManager( vm );
1900   delete vm;
1901 }
1902
1903 /*! rename active window of desktop */
1904 void LightApp_Application::onRenameWindow()
1905 {
1906   if( !desktop() )
1907     return;
1908
1909   QWidget* w = desktop()->activeWindow();
1910   if( !w )
1911     return;
1912
1913   bool ok;
1914   QString name = QInputDialog::getText( tr( "TOT_RENAME" ), tr( "PRP_RENAME" ), QLineEdit::Normal, w->caption(), &ok, w );
1915   if( ok && !name.isEmpty() )
1916     w->setCaption( name );
1917 }