Salome HOME
Integration from GUITHARE team: correction of Help menu behavior
[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 = getWindow( WT_ObjectBrowser );
976   if ( 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   if ( objectBrowser() != 0 )
1144     objectBrowser()->setRootObject( aRoot );
1145
1146   activateModule( defaultModule() );
1147
1148   activateWindows();
1149 }
1150
1151 /*!Protected SLOT. On study opened.*/
1152 void LightApp_Application::onStudyOpened( SUIT_Study* theStudy )
1153 {
1154   SUIT_DataObject* aRoot = 0;
1155   if ( theStudy && theStudy->root() )
1156   {
1157     aRoot = theStudy->root();
1158     //aRoot->dump();
1159   }
1160   if ( objectBrowser() != 0 ) {
1161     objectBrowser()->setRootObject( aRoot );
1162   }
1163
1164   activateModule( defaultModule() );
1165
1166   activateWindows();
1167
1168   emit studyOpened();
1169 }
1170
1171 /*!Protected SLOT. On study saved.*/
1172 void LightApp_Application::onStudySaved( SUIT_Study* )
1173 {
1174   emit studySaved();
1175 }
1176
1177 /*!Protected SLOT. On study closed.*/
1178 void LightApp_Application::onStudyClosed( SUIT_Study* )
1179 {
1180   emit studyClosed();
1181
1182   // Bug 10396: clear selection
1183   mySelMgr->clearSelected();
1184
1185   activateModule( "" );
1186
1187   saveWindowsGeometry();
1188 }
1189
1190 /*!Protected SLOT.On desktop activated.*/
1191 void LightApp_Application::onDesktopActivated()
1192 {
1193   CAM_Application::onDesktopActivated();
1194   LightApp_Module* aModule = dynamic_cast<LightApp_Module*>(activeModule());
1195   if(aModule)
1196     aModule->studyActivated();
1197 }
1198
1199 /*!Gets file filter.
1200  *\retval QString "(*.bin)"
1201  */
1202 QString LightApp_Application::getFileFilter() const
1203 {
1204   return "(*.bin)";
1205 }
1206
1207 /*! Gets file name*/
1208 QString LightApp_Application::getFileName( bool open, const QString& initial, const QString& filters, 
1209                                            const QString& caption, QWidget* parent )
1210 {
1211   if ( !parent )
1212     parent = desktop();
1213   QStringList fls = QStringList::split( ";;", filters, false );
1214   return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
1215 }
1216
1217 /*! Gets directory*/
1218 QString LightApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
1219 {
1220   if ( !parent )
1221     parent = desktop();
1222   return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true );
1223 }
1224
1225 /*! Get open file names*/
1226 QStringList LightApp_Application::getOpenFileNames( const QString& initial, const QString& filters, 
1227                                                     const QString& caption, QWidget* parent )
1228 {
1229   if ( !parent )
1230     parent = desktop();
1231   QStringList fls = QStringList::split( ";;", filters, false );
1232   return SUIT_FileDlg::getOpenFileNames( parent, initial, fls, caption, true );
1233 }
1234
1235 /*!Private SLOT. Update object browser.*/
1236 void LightApp_Application::onRefresh()
1237 {
1238   updateObjectBrowser( true );
1239 }
1240
1241 /*!Private SLOT. On preferences.*/
1242 void LightApp_Application::onPreferences()
1243 {
1244   QApplication::setOverrideCursor( Qt::waitCursor );
1245
1246   LightApp_PreferencesDlg* prefDlg = new LightApp_PreferencesDlg( preferences( true ), desktop());
1247
1248   QApplication::restoreOverrideCursor();
1249
1250   if ( !prefDlg )
1251     return;
1252
1253   prefDlg->exec();
1254
1255   delete prefDlg;
1256 }
1257
1258 /*!Protected SLOT. On preferences changed.*/
1259 void LightApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param )
1260 {
1261   LightApp_Module* sMod = 0;
1262   CAM_Module* mod = module( modName );
1263   if ( mod && mod->inherits( "LightApp_Module" ) )
1264     sMod = (LightApp_Module*)mod;
1265
1266   if ( sMod )
1267     sMod->preferencesChanged( section, param );
1268   else
1269     preferencesChanged( section, param );
1270 }
1271
1272 /*!Private SLOT. On open document with name \a aName.*/
1273 void LightApp_Application::onMRUActivated( QString aName )
1274 {
1275   onOpenDoc( aName );
1276 }
1277
1278 /*!Remove all windows from study.*/
1279 void LightApp_Application::beforeCloseDoc( SUIT_Study* s )
1280 {
1281   CAM_Application::beforeCloseDoc( s );
1282
1283   for ( WindowMap::ConstIterator itr = myWindows.begin(); s && itr != myWindows.end(); ++itr )
1284     removeWindow( itr.key(), s->id() );
1285 }
1286
1287 /*!Update actions.*/
1288 void LightApp_Application::updateActions()
1289 {
1290   updateCommandsStatus();
1291 }
1292
1293 //=======================================================================
1294 // name    : createNewStudy
1295 /*! Purpose : Create new study*/
1296 //=======================================================================
1297 SUIT_Study* LightApp_Application::createNewStudy()
1298 {
1299   LightApp_Study* aStudy = new LightApp_Study( this );
1300
1301   // Set up processing of major study-related events
1302   connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
1303   connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
1304   connect( aStudy, SIGNAL( saved  ( SUIT_Study* ) ), this, SLOT( onStudySaved  ( SUIT_Study* ) ) );
1305   connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
1306
1307   return aStudy;
1308 }
1309
1310 /*!Create window.*/
1311 QWidget* LightApp_Application::createWindow( const int flag )
1312 {
1313   QWidget* wid = 0;
1314   if ( flag == WT_ObjectBrowser )
1315   {
1316     OB_Browser* ob = new OB_Browser( desktop() );
1317     ob->setAutoUpdate( true );
1318     ob->setAutoOpenLevel( 1 );
1319     ob->setCaption( tr( "OBJECT_BROWSER" ) );
1320     ob->listView()->setColumnWidth( 0, OBJECT_COLUMN_WIDTH );
1321     ob->resize( OBJECT_BROWSER_WIDTH, ob->height() );
1322     ob->setFilter( new LightApp_OBFilter( selectionMgr() ) );
1323
1324     ob->setNameTitle( tr( "OBJ_BROWSER_NAME" ) );
1325
1326     // Create OBSelector
1327     new LightApp_OBSelector( ob, mySelMgr );
1328
1329     wid = ob;
1330
1331     ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1332   }
1333   else  if ( flag == WT_PyConsole )
1334   {
1335     PythonConsole* pyCons = new PythonConsole( desktop() );
1336     pyCons->setCaption( tr( "PYTHON_CONSOLE" ) );
1337     wid = pyCons;
1338     //    pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1339   }
1340   else if ( flag == WT_LogWindow )
1341   {
1342     LogWindow* logWin = new LogWindow( desktop() );
1343     logWin->setCaption( tr( "LOG_WINDOW" ) );
1344     wid = logWin;
1345     logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1346   }
1347   return wid;
1348 }
1349
1350 /*!Default windows(Object Browser, Python Console).
1351  * Adds to map \a aMap.
1352  */
1353 void LightApp_Application::defaultWindows( QMap<int, int>& aMap ) const
1354 {  
1355   aMap.insert( WT_ObjectBrowser, Qt::DockLeft );
1356   aMap.insert( WT_PyConsole, Qt::DockBottom );
1357   //  aMap.insert( WT_LogWindow, Qt::DockBottom );
1358 }
1359
1360 /*!Default view manager.*/
1361 void LightApp_Application::defaultViewManagers( QStringList& ) const
1362 {
1363   /*!Do nothing.*/
1364 }
1365
1366 /*!Gets preferences.
1367  * Create preferences, if \a crt = true.
1368  */
1369 LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const
1370 {
1371   if ( myPrefs )
1372     return myPrefs;
1373
1374   LightApp_Application* that = (LightApp_Application*)this;
1375
1376   if ( !_prefs_ && crt )
1377   {
1378     _prefs_ = new LightApp_Preferences( resourceMgr() );
1379     that->createPreferences( _prefs_ );
1380   }
1381
1382   that->myPrefs = _prefs_;
1383
1384   QPtrList<SUIT_Application> appList = SUIT_Session::session()->applications();
1385   for ( QPtrListIterator<SUIT_Application> appIt ( appList ); appIt.current(); ++appIt )
1386   {
1387     if ( !appIt.current()->inherits( "LightApp_Application" ) )
1388       continue;
1389
1390     LightApp_Application* app = (LightApp_Application*)appIt.current();
1391
1392     QStringList modNameList;
1393     app->modules( modNameList, false );
1394     for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it )
1395     {
1396       int id = _prefs_->addPreference( *it );
1397       _prefs_->setItemProperty( id, "info", tr( "PREFERENCES_NOT_LOADED" ).arg( *it ) );
1398     }
1399
1400     ModuleList modList;
1401     app->modules( modList );
1402     for ( ModuleListIterator itr( modList ); itr.current(); ++itr )
1403     {
1404       LightApp_Module* mod = 0;
1405       if ( itr.current()->inherits( "LightApp_Module" ) )
1406         mod = (LightApp_Module*)itr.current();
1407
1408       if ( mod && !_prefs_->hasModule( mod->moduleName() ) )
1409       {
1410         int modCat = _prefs_->addPreference( mod->moduleName() );
1411         _prefs_->setItemProperty( modCat, "info", QString::null );
1412         mod->createPreferences();
1413       }
1414     }
1415   }
1416
1417   connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
1418            this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ) );
1419
1420   return myPrefs;
1421 }
1422
1423 /*!Add new module to application.*/
1424 void LightApp_Application::moduleAdded( CAM_Module* mod )
1425 {
1426   CAM_Application::moduleAdded( mod );
1427
1428   LightApp_Module* lightMod = 0;
1429   if ( mod && mod->inherits( "LightApp_Module" ) )
1430     lightMod = (LightApp_Module*)mod;
1431
1432   if ( myPrefs && lightMod && !myPrefs->hasModule( lightMod->moduleName() ))
1433   {
1434     int modCat = myPrefs->addPreference( mod->moduleName() );
1435     myPrefs->setItemProperty( modCat, "info", QString::null );
1436     lightMod->createPreferences();
1437   }
1438 }
1439
1440 /*!Create preferences.*/
1441 void LightApp_Application::createPreferences( LightApp_Preferences* pref )
1442 {
1443   if ( !pref )
1444     return;
1445
1446   int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
1447
1448   int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat );
1449   int studyGroup = pref->addPreference( tr( "PREF_GROUP_STUDY" ), genTab );
1450   pref->setItemProperty( studyGroup, "columns", 1 );
1451
1452   pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "multi_file" );
1453   pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" );
1454   int undoPref = pref->addPreference( tr( "PREF_UNDO_LEVEL" ), studyGroup, LightApp_Preferences::IntSpin, "Study", "undo_level" );
1455   pref->setItemProperty( undoPref, "min", 1 );
1456   pref->setItemProperty( undoPref, "max", 100 );
1457
1458   int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab );
1459   pref->setItemProperty( extgroup, "columns", 1 );
1460   int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, LightApp_Preferences::File, "ExternalBrowser", "application" );
1461   pref->setItemProperty( apppref, "existing", true );
1462   pref->setItemProperty( apppref, "flags", QFileInfo::ExeUser );
1463
1464   pref->addPreference( tr( "PREF_PARAM" ), extgroup, LightApp_Preferences::String, "ExternalBrowser", "parameters" );
1465
1466   int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab );
1467   pref->setItemProperty( pythonConsoleGroup, "columns", 1 );
1468   pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, LightApp_Preferences::Font, "PyConsole", "font" );
1469
1470   int viewTab = pref->addPreference( tr( "PREF_TAB_VIEWERS" ), salomeCat );
1471
1472   int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), viewTab );
1473
1474   int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), viewTab );
1475
1476   int plot2dGroup = pref->addPreference( tr( "PREF_GROUP_PLOT2DVIEWER" ), viewTab );
1477
1478   int supervGroup = pref->addPreference( tr( "PREF_GROUP_SUPERV" ), viewTab );
1479
1480   pref->setItemProperty( occGroup, "columns", 1 );
1481   pref->setItemProperty( vtkGroup, "columns", 1 );
1482   pref->setItemProperty( plot2dGroup, "columns", 1 );
1483
1484   int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occGroup,
1485                                    LightApp_Preferences::IntSpin, "OCCViewer", "trihedron_size" );
1486   pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup,
1487                        LightApp_Preferences::Color, "OCCViewer", "background" );
1488
1489   pref->setItemProperty( occTS, "min", 1 );
1490   pref->setItemProperty( occTS, "max", 150 );
1491
1492   int isoU = pref->addPreference( tr( "PREF_ISOS_U" ), occGroup,
1493                                   LightApp_Preferences::IntSpin, "OCCViewer", "iso_number_u" );
1494   int isoV = pref->addPreference( tr( "PREF_ISOS_V" ), occGroup,
1495                                   LightApp_Preferences::IntSpin, "OCCViewer", "iso_number_v" );
1496
1497   pref->setItemProperty( isoU, "min", 0 );
1498   pref->setItemProperty( isoU, "max", 100000 );
1499
1500   pref->setItemProperty( isoV, "min", 0 );
1501   pref->setItemProperty( isoV, "max", 100000 );
1502
1503   int vtkTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), vtkGroup,
1504                                    LightApp_Preferences::IntSpin, "VTKViewer", "trihedron_size" );
1505   pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGroup,
1506                        LightApp_Preferences::Color, "VTKViewer", "background" );
1507
1508   pref->setItemProperty( vtkTS, "min", 1 );
1509   pref->setItemProperty( vtkTS, "max", 150 );
1510
1511   pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dGroup,
1512                        LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
1513
1514   int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dGroup,
1515                                             LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
1516   QStringList aLegendPosList;
1517   aLegendPosList.append( tr("PREF_LEFT") );
1518   aLegendPosList.append( tr("PREF_RIGHT") );
1519   aLegendPosList.append( tr("PREF_TOP") );
1520   aLegendPosList.append( tr("PREF_BOTTOM") );
1521
1522   QValueList<QVariant> anIndexesList;
1523   anIndexesList.append(0);
1524   anIndexesList.append(1);
1525   anIndexesList.append(2);
1526   anIndexesList.append(3);
1527
1528   pref->setItemProperty( legendPosition, "strings", aLegendPosList );
1529   pref->setItemProperty( legendPosition, "indexes", anIndexesList );
1530
1531   int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dGroup,
1532                                        LightApp_Preferences::Selector, "Plot2d", "CurveType" );
1533   QStringList aCurveTypesList;
1534   aCurveTypesList.append( tr("PREF_POINTS") );
1535   aCurveTypesList.append( tr("PREF_LINES") );
1536   aCurveTypesList.append( tr("PREF_SPLINE") );
1537
1538   anIndexesList.clear();
1539   anIndexesList.append(0);
1540   anIndexesList.append(1);
1541   anIndexesList.append(2);
1542   
1543   pref->setItemProperty( curveType, "strings", aCurveTypesList );
1544   pref->setItemProperty( curveType, "indexes", anIndexesList );
1545
1546   int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dGroup,
1547                                         LightApp_Preferences::IntSpin, "Plot2d", "MarkerSize" );
1548
1549   pref->setItemProperty( markerSize, "min", 0 );
1550   pref->setItemProperty( markerSize, "max", 100 );
1551   
1552   QStringList aScaleModesList;
1553   aScaleModesList.append( tr("PREF_LINEAR") );
1554   aScaleModesList.append( tr("PREF_LOGARITHMIC") );
1555   
1556   anIndexesList.clear();
1557   anIndexesList.append(0);
1558   anIndexesList.append(1);
1559
1560   int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dGroup,
1561                                       LightApp_Preferences::Selector, "Plot2d", "HorScaleMode" );
1562
1563   pref->setItemProperty( horScale, "strings", aScaleModesList );
1564   pref->setItemProperty( horScale, "indexes", anIndexesList );
1565
1566   int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dGroup,
1567                                       LightApp_Preferences::Selector, "Plot2d", "VerScaleMode" );
1568
1569   pref->setItemProperty( verScale, "strings", aScaleModesList );
1570   pref->setItemProperty( verScale, "indexes", anIndexesList );
1571
1572   pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), plot2dGroup,
1573                        LightApp_Preferences::Color, "Plot2d", "Background" );
1574
1575   int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat );
1576   int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab );
1577   pref->setItemProperty( dirGroup, "columns", 1 );
1578   pref->addPreference( tr( "" ), dirGroup,
1579                        LightApp_Preferences::DirList, "FileDlg", "QuickDirList" );
1580
1581   pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), supervGroup,
1582                        LightApp_Preferences::Color, "SUPERVGraph", "Background" );
1583   pref->addPreference( tr( "PREF_SUPERV_TITLE_COLOR" ), supervGroup,
1584                        LightApp_Preferences::Color, "SUPERVGraph", "Title" );
1585 //  pref->addPreference( tr( "PREF_SUPERV_CTRL_COLOR" ), supervGroup,
1586 //                     LightApp_Preferences::Color, "SUPERVGraph", "Ctrl" );
1587 }
1588
1589 /*!Changed preferences */
1590 void LightApp_Application::preferencesChanged( const QString& sec, const QString& param )
1591 {
1592   SUIT_ResourceMgr* resMgr = resourceMgr();
1593   if ( !resMgr )
1594     return;
1595
1596   if ( sec == QString( "OCCViewer" ) && param == QString( "trihedron_size" ) )
1597   {
1598     int sz = resMgr->integerValue( sec, param, -1 );
1599     QPtrList<SUIT_ViewManager> lst;
1600     viewManagers( OCCViewer_Viewer::Type(), lst );
1601     for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current() && sz >= 0; ++it )
1602     {
1603       SUIT_ViewModel* vm = it.current()->getViewModel();
1604       if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
1605         continue;
1606
1607       OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
1608       occVM->setTrihedronSize( sz );
1609       occVM->getAISContext()->UpdateCurrentViewer();
1610     }
1611   }
1612
1613   if ( sec == QString( "VTKViewer" ) && param == QString( "trihedron_size" ) )
1614   {
1615     int sz = resMgr->integerValue( sec, param, -1 );
1616     QPtrList<SUIT_ViewManager> lst;
1617     viewManagers( SVTK_Viewer::Type(), lst );
1618     for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current() && sz >= 0; ++it )
1619     {
1620       SUIT_ViewModel* vm = it.current()->getViewModel();
1621       if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
1622         continue;
1623
1624       SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
1625       if( vtkVM )
1626       {
1627         vtkVM->setTrihedronSize( sz );
1628         vtkVM->Repaint();
1629       }
1630     }
1631   }
1632
1633   if ( sec == QString( "OCCViewer" ) && ( param == QString( "iso_number_u" ) || param == QString( "iso_number_v" ) ) )
1634   {
1635     QPtrList<SUIT_ViewManager> lst;
1636     viewManagers( OCCViewer_Viewer::Type(), lst );
1637     int u = resMgr->integerValue( sec, "iso_number_u" );
1638     int v = resMgr->integerValue( sec, "iso_number_v" );
1639     for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current(); ++it )
1640     {
1641       OCCViewer_ViewManager* mgr = dynamic_cast<OCCViewer_ViewManager*>( it.current() );
1642       if( mgr && mgr->getOCCViewer() )
1643         mgr->getOCCViewer()->setIsos( u, v );
1644     }
1645   }
1646
1647   if( sec=="ObjectBrowser" )
1648   {
1649     if( param=="auto_size" )
1650     {
1651       OB_Browser* ob = objectBrowser();
1652       if( !ob )
1653         return;
1654
1655       bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
1656       ob->setWidthMode( autoSize ? QListView::Maximum : QListView::Manual );
1657
1658       updateObjectBrowser( false );
1659     }
1660   }
1661
1662   if( sec=="PyConsole" )
1663   {
1664     if( param=="font" )
1665       if( pythonConsole() )
1666         pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) );
1667   }
1668 }
1669
1670 /*!Update desktop title.*/
1671 void LightApp_Application::updateDesktopTitle() {
1672   QString aTitle = applicationName();
1673   QString aVer = applicationVersion();
1674   if ( !aVer.isEmpty() )
1675     aTitle += QString( " " ) + aVer;
1676
1677   desktop()->setCaption( aTitle );
1678 }
1679
1680 /*!Update windows after close document.*/
1681 void LightApp_Application::afterCloseDoc()
1682 {
1683   updateWindows();
1684
1685   CAM_Application::afterCloseDoc();
1686 }
1687
1688 /*!Update module action.*/
1689 void LightApp_Application::updateModuleActions()
1690 {
1691   QString modName;
1692   if ( activeModule() )
1693     modName = activeModule()->moduleName();
1694
1695   if ( myActions.contains( modName ) )
1696     myActions[modName]->setOn( true );
1697 }
1698
1699 /*!Gets current windows.
1700  *\param winMap - output current windows map.
1701  */
1702 void LightApp_Application::currentWindows( QMap<int, int>& winMap ) const
1703 {
1704   winMap.clear();
1705   if ( !activeStudy() )
1706     return;
1707
1708   if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
1709     ((LightApp_Module*)activeModule())->windows( winMap );
1710   else
1711     defaultWindows( winMap );
1712 }
1713
1714 /*!Gets current view managers.
1715  *\param lst - output current view managers list.
1716  */
1717 void LightApp_Application::currentViewManagers( QStringList& lst ) const
1718 {
1719   lst.clear();
1720   if ( !activeStudy() )
1721     return;
1722
1723   if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
1724     ((LightApp_Module*)activeModule())->viewManagers( lst );
1725   else
1726     defaultViewManagers( lst );
1727 }
1728
1729 /*!Update windows.*/
1730 void LightApp_Application::updateWindows()
1731 {
1732   QMap<int, int> winMap;
1733   currentWindows( winMap );
1734
1735   for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
1736     getWindow( it.key() );
1737
1738   loadWindowsGeometry();
1739
1740   for ( WindowMap::ConstIterator itr = myWindows.begin(); itr != myWindows.end(); ++itr )
1741     setWindowShown( itr.key(), !itr.data()->isEmpty() && winMap.contains( itr.key() ) );
1742 }
1743
1744 /*!Update view managers.*/
1745 void LightApp_Application::updateViewManagers()
1746 {
1747   QStringList lst;
1748   currentViewManagers( lst );
1749
1750   for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
1751     getViewManager( *it, true );
1752 }
1753
1754 /*!Load windows geometry.*/
1755 void LightApp_Application::loadWindowsGeometry()
1756 {
1757   QtxDockAction* dockMgr = 0;
1758
1759   QAction* a = action( ViewWindowsId );
1760   if ( a && a->inherits( "QtxDockAction" ) )
1761     dockMgr = (QtxDockAction*)a;
1762
1763   if ( !dockMgr )
1764     return;
1765
1766   QString modName;
1767   if ( activeModule() )
1768     modName = activeModule()->name("");
1769
1770   QString section = QString( "windows_geometry" );
1771   if ( !modName.isEmpty() )
1772     section += QString( "." ) + modName;
1773
1774   dockMgr->loadGeometry( resourceMgr(), section, false );
1775   dockMgr->restoreGeometry();
1776 }
1777
1778 /*!Save windows geometry.*/
1779 void LightApp_Application::saveWindowsGeometry()
1780 {
1781   QtxDockAction* dockMgr = 0;
1782
1783   QAction* a = action( ViewWindowsId );
1784   if ( a && a->inherits( "QtxDockAction" ) )
1785     dockMgr = (QtxDockAction*)a;
1786
1787   if ( !dockMgr )
1788     return;
1789
1790   QString modName;
1791   if ( activeModule() )
1792     modName = activeModule()->name("");
1793
1794   QString section = QString( "windows_geometry" );
1795   if ( !modName.isEmpty() )
1796     section += QString( "." ) + modName;
1797
1798   dockMgr->storeGeometry();
1799   dockMgr->saveGeometry( resourceMgr(), section, false );
1800 }
1801
1802 /*!Activate windows.*/
1803 void LightApp_Application::activateWindows()
1804 {
1805   if ( activeStudy() )
1806   {
1807     for ( WindowMap::Iterator itr = myWindows.begin(); itr != myWindows.end(); ++itr )
1808       itr.data()->activate( activeStudy()->id() );
1809   }
1810 }
1811
1812 /*!Adds icon names for modules.*/
1813 void LightApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) const
1814 {
1815   iconMap.clear();
1816
1817   SUIT_ResourceMgr* resMgr = resourceMgr();
1818   if ( !resMgr )
1819     return;
1820
1821   QStringList modList;
1822   modules( modList, false );
1823
1824   for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )
1825   {
1826     QString modName = *it;
1827     QString modIntr = moduleName( modName );
1828     QString modIcon = resMgr->stringValue( modIntr, "icon", QString::null );
1829
1830     if ( modIcon.isEmpty() )
1831       continue;
1832
1833     if ( SUIT_Tools::extension( modIcon ).isEmpty() )
1834       modIcon += QString( ".png" );
1835
1836     iconMap.insert( modName, modIcon );
1837   }
1838 }
1839
1840 /*!Insert items in popup, which necessary for current application*/
1841 void LightApp_Application::contextMenuPopup( const QString& type, QPopupMenu* thePopup, QString& title )
1842 {
1843   CAM_Application::contextMenuPopup( type, thePopup, title );
1844
1845   OB_Browser* ob = objectBrowser();
1846   if ( !ob || type != ob->popupClientType() )
1847     return;
1848
1849   thePopup->insertSeparator();
1850   thePopup->insertItem( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
1851 }
1852
1853 /*!Create empty study.*/
1854 void LightApp_Application::createEmptyStudy()
1855 {
1856   CAM_Application::createEmptyStudy();
1857   if ( objectBrowser() )
1858     objectBrowser()->updateTree();
1859 }
1860
1861 /*!Activate module \a mod.*/
1862 bool LightApp_Application::activateModule( CAM_Module* mod )
1863 {
1864   bool res = CAM_Application::activateModule( mod );
1865   if ( objectBrowser() )
1866     objectBrowser()->updateTree();
1867   return res;
1868 }
1869
1870 /*!return keyborad accelerators manager object */
1871 SUIT_Accel* LightApp_Application::accel() const
1872 {
1873   return myAccel;
1874 }
1875
1876 /*! remove dead widget container from map */
1877 void LightApp_Application::onWCDestroyed( QObject* ob )
1878 {
1879   // remove destroyed widget container from windows map
1880   for ( WindowMap::ConstIterator itr = myWindows.begin(); itr != myWindows.end(); ++itr )
1881   {
1882     if ( itr.data() != ob )
1883       continue;
1884
1885     int key = itr.key();
1886     myWindows.remove( key );
1887     break;
1888   }
1889 }
1890
1891 /*! redefined to remove view manager from memory */
1892 void LightApp_Application::removeViewManager( SUIT_ViewManager* vm )
1893 {
1894   disconnect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
1895            this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
1896   STD_Application::removeViewManager( vm );
1897   delete vm;
1898 }
1899
1900 /*! rename active window of desktop */
1901 void LightApp_Application::onRenameWindow()
1902 {
1903   if( !desktop() )
1904     return;
1905
1906   QWidget* w = desktop()->activeWindow();
1907   if( !w )
1908     return;
1909
1910   bool ok;
1911   QString name = QInputDialog::getText( tr( "TOT_RENAME" ), tr( "PRP_RENAME" ), QLineEdit::Normal, w->caption(), &ok, w );
1912   if( ok && !name.isEmpty() )
1913     w->setCaption( name );
1914 }