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