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