Salome HOME
29c44c9b300c7512e056babe5e97944725d4638b
[modules/gui.git] / src / SalomeApp / SalomeApp_Application.cxx
1 // File:      SalomeApp_Application.cxx
2 // Created:   10/22/2004 3:23:45 PM
3 // Author:    Sergey LITONIN
4 // Copyright (C) CEA 2004
5
6 #include "SalomeApp_PyInterp.h" // WARNING! This include must be the first!
7
8 #include "SalomeApp_Application.h"
9
10 #include "SalomeApp_Study.h"
11 #include "SalomeApp_Module.h"
12 #include "SalomeApp_OBFilter.h"
13 #include "SalomeApp_DataModel.h"
14 #include "SalomeApp_DataObject.h"
15 #include "SalomeApp_EventFilter.h"
16 #include "SalomeApp_WidgetContainer.h"
17
18 #include "SalomeApp_AboutDlg.h"
19 #include "SalomeApp_ModuleDlg.h"
20 #include "SalomeApp_Preferences.h"
21 #include "SalomeApp_PreferencesDlg.h"
22 #include "SalomeApp_StudyPropertiesDlg.h"
23
24 #include "SalomeApp_GLSelector.h"
25 #include "SalomeApp_OBSelector.h"
26 #include "SalomeApp_OCCSelector.h"
27 #include "SalomeApp_VTKSelector.h"
28 #include "SalomeApp_SelectionMgr.h"
29
30 #include <LogWindow.h>
31
32 #include <GLViewer_Viewer.h>
33 #include <GLViewer_ViewManager.h>
34
35 #include <Plot2d_ViewManager.h>
36 #include <SPlot2d_ViewModel.h>
37
38 #include <OCCViewer_ViewManager.h>
39 #include <SOCC_ViewModel.h>
40
41 #include <SVTK_ViewModel.h>
42 #include <SVTK_ViewManager.h>
43
44 #include <STD_TabDesktop.h>
45
46 #include <SUIT_Tools.h>
47 #include <SUIT_Session.h>
48
49 #include <QtxToolBar.h>
50 #include <QtxMRUAction.h>
51 #include <QtxDockAction.h>
52 #include <QtxResourceEdit.h>
53
54 #include <OB_Browser.h>
55
56 #include <PythonConsole_PyConsole.h>
57
58 #include <SUIT_FileDlg.h>
59 #include <SUIT_MessageBox.h>
60 #include <SUIT_ResourceMgr.h>
61 #include <SUIT_ActionOperation.h>
62
63 #include <Utils_ORB_INIT.hxx>
64 #include <Utils_SINGLETON.hxx>
65 #include <SALOME_ModuleCatalog_impl.hxx>
66 #include <SALOME_LifeCycleCORBA.hxx>
67
68 #include <qmap.h>
69 #include <qdir.h>
70 #include <qlabel.h>
71 #include <qimage.h>
72 #include <qaction.h>
73 #include <qmenubar.h>
74 #include <qcombobox.h>
75 #include <qmessagebox.h>
76 #include <qapplication.h>
77
78 #include "SALOMEDS_StudyManager.hxx"
79
80 #include "SALOME_ListIteratorOfListIO.hxx"
81 #include "SALOME_ListIO.hxx"
82
83 #define OBJECT_BROWSER_WIDTH 300
84
85 static const char* imageEmptyIcon[] = {
86 "20 20 1 1",
87 ".      c None",
88 "....................",
89 "....................",
90 "....................",
91 "....................",
92 "....................",
93 "....................",
94 "....................",
95 "....................",
96 "....................",
97 "....................",
98 "....................",
99 "....................",
100 "....................",
101 "....................",
102 "....................",
103 "....................",
104 "....................",
105 "....................",
106 "....................",
107 "...................."};
108
109 extern "C" SALOMEAPP_EXPORT SUIT_Application* createApplication()
110 {
111   return new SalomeApp_Application();
112 }
113
114 SalomeApp_Preferences* SalomeApp_Application::_prefs_ = 0;
115
116 /*
117   Class       : SalomeApp_Application
118   Description : Application containing SalomeApp module
119 */
120
121 SalomeApp_Application::SalomeApp_Application()
122 : CAM_Application( false ),
123 myPrefs( 0 )
124 {
125   STD_TabDesktop* desk = new STD_TabDesktop();
126
127   setDesktop( desk );
128
129   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
130   QPixmap aLogo = aResMgr->loadPixmap( "SalomeApp", tr( "APP_DEFAULT_ICO" ) );
131
132   desktop()->setIcon( aLogo );
133   desktop()->setDockableMenuBar( true );
134   desktop()->setDockableStatusBar( false );
135
136   clearViewManagers();
137
138   mySelMgr = new SalomeApp_SelectionMgr( this );
139
140   connect( desk, SIGNAL( closing( SUIT_Desktop*, QCloseEvent* ) ),
141            this, SLOT( onDesktopClosing( SUIT_Desktop*, QCloseEvent* ) ) );
142
143   connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) );
144 }
145
146 SalomeApp_Application::~SalomeApp_Application()
147 {
148   saveWindowsGeometry();
149
150   if ( resourceMgr() )
151   {
152     if ( desktop() )
153       desktop()->saveGeometry( resourceMgr(), "desktop" );
154     resourceMgr()->save();
155   }
156
157   delete mySelMgr;
158
159   SalomeApp_EventFilter::Destroy();
160 }
161
162 void SalomeApp_Application::start()
163 {
164   if ( desktop() )
165     desktop()->loadGeometry( resourceMgr(), "desktop" );
166
167   CAM_Application::start();
168
169   QAction* a = action( ViewWindowsId );
170   if ( a && a->inherits( "QtxDockAction" ) )
171     ((QtxDockAction*)a)->setAutoPlace( true );
172
173   SalomeApp_EventFilter::Init();
174
175   updateWindows();
176   updateViewManagers();
177
178   putInfo( "" );
179 }
180
181 QString SalomeApp_Application::applicationName() const
182 {
183   return tr( "APP_NAME" );
184 }
185
186 QString SalomeApp_Application::applicationVersion() const
187 {
188   static QString _app_version;
189
190   if ( _app_version.isEmpty() )
191   {
192     QString path( ::getenv( "GUI_ROOT_DIR" ) );
193     if ( !path.isEmpty() )
194       path += QDir::separator();
195     path += QString( "bin/salome/VERSION" );
196
197     QFile vf( path );
198     if ( vf.open( IO_ReadOnly ) )
199     {
200       QString line;
201       vf.readLine( line, 1024 );
202       vf.close();
203
204       if ( !line.isEmpty() )
205       {
206         while ( !line.isEmpty() && line.at( line.length() - 1 ) == QChar( '\n' ) )
207           line.remove( line.length() - 1, 1 );
208
209         int idx = line.findRev( ":" );
210         if ( idx != -1 )
211           _app_version = line.mid( idx + 1 ).stripWhiteSpace();
212       }
213     }
214   }
215
216   return _app_version;
217 }
218
219 CAM_Module* SalomeApp_Application::loadModule( const QString& name )
220 {
221   CAM_Module* mod = CAM_Application::loadModule( name );
222   if ( mod )
223   {
224     connect( this, SIGNAL( studyOpened() ), mod, SLOT( onModelOpened() ) );
225     connect( this, SIGNAL( studySaved() ),  mod, SLOT( onModelSaved() ) );
226     connect( this, SIGNAL( studyClosed() ), mod, SLOT( onModelClosed() ) );
227   }
228   return mod;
229 }
230
231 bool SalomeApp_Application::activateModule( const QString& modName )
232 {
233   QString actName;
234   CAM_Module* prevMod = activeModule();
235
236   if ( prevMod )
237     actName = prevMod->moduleName();
238
239   if ( actName == modName )
240     return true;
241
242   saveWindowsGeometry();
243
244   bool status = CAM_Application::activateModule( modName );
245
246   updateModuleActions();
247
248   if ( !status )
249     return false;
250
251   updateWindows();
252   updateViewManagers();
253
254   return true;
255 }
256
257 SalomeApp_SelectionMgr* SalomeApp_Application::selectionMgr() const
258 {
259   return mySelMgr;
260 }
261
262 void SalomeApp_Application::createActions()
263 {
264   STD_Application::createActions();
265
266   SUIT_Desktop* desk = desktop();
267   SUIT_ResourceMgr* resMgr = resourceMgr();
268
269   // Load script
270   createAction( LoadScriptId, tr( "TOT_DESK_LOADSCRIPT" ), QIconSet(),
271                 tr( "MEN_DESK_LOADSCRIPT" ), tr( "PRP_DESK_LOADSCRIPT" ),
272                 0, desk, false, this, SLOT( onLoadScript() ) );
273
274   // Properties
275   createAction( PropertiesId, tr( "TOT_DESK_PROPERTIES" ), QIconSet(),
276                 tr( "MEN_DESK_PROPERTIES" ), tr( "PRP_DESK_PROPERTIES" ),
277                 0, desk, false, this, SLOT( onProperties() ) );
278
279   // Preferences
280   createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIconSet(),
281                 tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
282                 CTRL+Key_P, desk, false, this, SLOT( onPreferences() ) );
283
284   // MRU
285   QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), desk );
286   connect( mru, SIGNAL( activated( QString ) ), this, SLOT( onMRUActivated( QString ) ) );
287   registerAction( MRUId, mru );
288
289   // default icon for neutral point ('SALOME' module)
290   QPixmap defIcon = resMgr->loadPixmap( "SalomeApp", tr( "APP_DEFAULT_ICO" ) );
291   if ( defIcon.isNull() )
292     defIcon = QPixmap( imageEmptyIcon );
293
294   // default icon for any module
295   QPixmap modIcon = resMgr->loadPixmap( "SalomeApp", tr( "APP_MODULE_ICO" ) );
296   if ( modIcon.isNull() )
297     modIcon = QPixmap( imageEmptyIcon );
298
299   QToolBar* modTBar = new QtxToolBar( true, desk );
300   modTBar->setLabel( tr( "INF_TOOLBAR_MODULES" ) );
301
302   QActionGroup* modGroup = new QActionGroup( this );
303   modGroup->setExclusive( true );
304   modGroup->setUsesDropDown( true );
305
306   QAction* a = createAction( -1, tr( "APP_NAME" ), defIcon, tr( "APP_NAME" ),
307                              tr( "PRP_APP_MODULE" ), 0, desk, true );
308   modGroup->add( a );
309   myActions.insert( QString(), a );
310
311   QMap<QString, QString> iconMap;
312   moduleIconNames( iconMap );
313
314   const int iconSize = 20;
315
316   modGroup->addTo( modTBar );
317   modTBar->addSeparator();
318
319   QStringList modList;
320   modules( modList, false );
321
322   for ( QStringList::Iterator it = modList.begin(); it != modList.end(); ++it )
323   {
324     if ( (*it).isEmpty() )
325       continue;
326
327     QString iconName;
328     if ( iconMap.contains( *it ) )
329       iconName = iconMap[*it];
330
331     QString modName = moduleName( *it );
332
333     QPixmap icon = resMgr->loadPixmap( modName, iconName );
334     if ( icon.isNull() )
335       icon = modIcon;
336
337     icon.convertFromImage( icon.convertToImage().smoothScale( iconSize, iconSize, QImage::ScaleMin ) );
338
339     QAction* a = createAction( -1, *it, icon, *it, tr( "PRP_MODULE" ).arg( *it ), 0, desk, true );
340     a->addTo( modTBar );
341     modGroup->add( a );
342
343     myActions.insert( *it, a );
344   }
345
346   SUIT_Tools::simplifySeparators( modTBar );
347
348   // New window
349
350   int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, 100 );
351   int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
352   createMenu( separator(), windowMenu, -1, 1 );
353
354   QMap<int, int> accelMap;
355   accelMap[NewGLViewId]  = ALT+Key_G;
356   accelMap[NewPlot2dId]  = ALT+Key_P;
357   accelMap[NewOCCViewId] = ALT+Key_O;
358   accelMap[NewVTKViewId] = ALT+Key_K;
359
360   for ( int id = NewGLViewId; id <= NewVTKViewId; id++ )
361   {
362     QAction* a = createAction( id, tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ), QIconSet(),
363                                tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ),
364                                tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ),
365                                accelMap.contains( id ) ? accelMap[id] : 0, desk, false, this, SLOT( onNewWindow() ) );
366     createMenu( a, newWinMenu, -1 );
367   }
368   connect( modGroup, SIGNAL( selected( QAction* ) ), this, SLOT( onModuleActivation( QAction* ) ) );
369
370
371
372   int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
373
374   createMenu( separator(), fileMenu, -1, 15, -1 );
375   createMenu( LoadScriptId, fileMenu, 15, -1 );
376   createMenu( separator(), fileMenu, -1, 15, -1 );
377   createMenu( PropertiesId, fileMenu, 10, -1 );
378   createMenu( separator(), fileMenu, -1, 15, -1 );
379   createMenu( PreferencesId, fileMenu, 15, -1 );
380   createMenu( separator(), fileMenu, -1, 15, -1 );
381
382   /*
383   createMenu( separator(), fileMenu, -1, 100, -1 );
384   createMenu( MRUId, fileMenu, 100, -1 );
385   createMenu( separator(), fileMenu, -1, 100, -1 );
386   */
387 }
388
389 void SalomeApp_Application::onModuleActivation( QAction* a )
390 {
391   if ( !a )
392     return;
393
394   QString modName = a->menuText();
395   if ( modName == tr( "APP_NAME" ) )
396     modName = QString::null;
397
398   // Force user to create/open a study before module activation
399   QMap<QString, QString> iconMap;
400   moduleIconNames( iconMap );
401   QPixmap icon = resourceMgr()->loadPixmap( moduleName( modName ), iconMap[ modName ] );
402
403   bool cancelled = false;
404   while ( !modName.isEmpty() && !activeStudy() && !cancelled ){
405     SalomeApp_ModuleDlg aDlg( desktop(), modName, icon );
406     int res = aDlg.exec();
407
408     switch ( res ){
409     case 1:
410       onNewDoc();
411       break;
412     case 2:
413       onOpenDoc();
414       break;
415     case 3:
416       //onLoadStudy();
417       //break;
418     case 0:
419     default:
420       putInfo( tr("INF_CANCELLED") );
421       myActions[QString()]->setOn( true );
422       cancelled = true;
423     }
424   }
425
426   if ( !cancelled )
427     activateModule( modName );
428 }
429
430 QString SalomeApp_Application::defaultModule() const
431 {
432   QStringList aModuleNames;
433   modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration
434   // If there's the one and only module --> activate it automatically
435   // TODO: Possible improvement - default module can be taken from preferences
436   return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" );
437 }
438
439 void SalomeApp_Application::onNewWindow()
440 {
441   const QObject* obj = sender();
442   if ( !obj || !obj->inherits( "QAction" ) )
443     return;
444
445   QString type;
446   int id = actionId( (QAction*)obj );
447   switch ( id )
448   {
449   case NewGLViewId:
450     type = GLViewer_Viewer::Type();
451     break;
452   case NewPlot2dId:
453     type = Plot2d_Viewer::Type();
454     break;
455   case NewOCCViewId:
456     type = OCCViewer_Viewer::Type();
457     break;
458   case NewVTKViewId:
459     type = VTKViewer_Viewer::Type();
460     break;
461   }
462
463   if ( !type.isEmpty() )
464     createViewManager( type );
465 }
466
467 //=======================================================================
468 // name    : onNewDoc
469 // Purpose : SLOT. Create new document
470 //=======================================================================
471 void SalomeApp_Application::onNewDoc()
472 {
473   SUIT_Study* study = activeStudy();
474
475   saveWindowsGeometry();
476
477   CAM_Application::onNewDoc();
478
479   if ( !study ) // new study will be create in THIS application
480   {
481     updateWindows();
482     updateViewManagers();
483   }
484 }
485
486 //=======================================================================
487 // name    : onOpenDoc
488 // Purpose : SLOT. Open new document
489 //=======================================================================
490 void SalomeApp_Application::onOpenDoc()
491 {
492   SUIT_Study* study = activeStudy();
493   saveWindowsGeometry();
494
495   CAM_Application::onOpenDoc();
496
497   if ( !study ) // new study will be create in THIS application
498   {
499     updateWindows();
500     updateViewManagers();
501   }
502 }
503
504 bool SalomeApp_Application::onOpenDoc( const QString& aName )
505 {
506   bool res = CAM_Application::onOpenDoc( aName );
507
508   QAction* a = action( MRUId );
509   if ( a && a->inherits( "QtxMRUAction" ) )
510   {
511     QtxMRUAction* mru = (QtxMRUAction*)a;
512     if ( res )
513       mru->insert( aName );
514     else
515       mru->remove( aName );
516   }
517   return res;
518 }
519
520 void SalomeApp_Application::onSelection()
521 {
522   onSelectionChanged();
523
524   if ( activeModule() && activeModule()->inherits( "SalomeApp_Module" ) )
525     ((SalomeApp_Module*)activeModule())->selectionChanged();
526 }
527
528 void SalomeApp_Application::onSelectionChanged()
529 {
530  /*
531    SalomeApp_Module* module = dynamic_cast<SalomeApp_Module*>(activeModule());
532    if(module == NULL) return;
533    
534    QString ior = module->engineIOR();
535    if(ior.length() < 5) return; //Not a real CORBA IOR
536    CORBA::Object_var obj = orb()->string_to_object(ior.latin1());
537    if(CORBA::is_nil(obj)) return;
538    
539    SALOMEDS::Driver_var engine = SALOMEDS::Driver::_narrow(obj);
540    if(CORBA::is_nil(engine)) return;
541 */
542
543    SALOME_ListIO list;
544    SalomeApp_SelectionMgr* mgr = selectionMgr();
545    mgr->selectedObjects(list);
546    
547    SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
548    if(study == NULL) return;
549    
550    _PTR(Study) stdDS = study->studyDS();
551    if(!stdDS) return;
552    
553    QAction* qaction;  
554    
555    for ( SALOME_ListIteratorOfListIO it( list ); it.More(); it.Next() )
556    {
557       _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
558       qaction = action(EditCutId);
559       if( studyMgr()->CanCopy(so) ) {
560         qaction->setEnabled(true);
561         qaction = action(EditCopyId); 
562         qaction->setEnabled(true);  
563       }
564       else {
565         qaction->setEnabled(false);
566         qaction = action(EditCopyId);
567         qaction->setEnabled(false);         
568       }
569       qaction = action(EditPasteId);
570       if( studyMgr()->CanPaste(so) ) qaction->setEnabled(true);
571       else qaction->setEnabled(false);
572    } 
573 }               
574  
575
576 void SalomeApp_Application::onRefresh()
577 {
578   for ( ModuleListIterator it = modules(); it.current(); ++it )
579   {    
580     CAM_DataModel* camDM = it.current()->dataModel();
581     if ( camDM && camDM->inherits( "SalomeApp_DataModel" ) )
582       ((SalomeApp_DataModel*)camDM)->update();
583   }
584   objectBrowser()->updateTree();
585 }
586
587 void SalomeApp_Application::setActiveStudy( SUIT_Study* study )
588 {
589   CAM_Application::setActiveStudy( study );
590
591   activateWindows();
592 }
593
594 //=======================================================================
595 // name    : createNewStudy
596 // Purpose : Create new study
597 //=======================================================================
598 SUIT_Study* SalomeApp_Application::createNewStudy()
599 {
600   SalomeApp_Study* aStudy = new SalomeApp_Study( this );
601
602   // Set up processing of major study-related events
603   connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
604   connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
605   connect( aStudy, SIGNAL( saved  ( SUIT_Study* ) ), this, SLOT( onStudySaved  ( SUIT_Study* ) ) );
606   connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
607
608   return aStudy;
609 }
610
611 //=======================================================================
612 // name    : createNewStudy
613 // Purpose : Enable/Disable menu items and toolbar buttons. Rebuild menu
614 //=======================================================================
615 void SalomeApp_Application::updateCommandsStatus()
616 {
617   CAM_Application::updateCommandsStatus();
618
619   for ( int id = NewGLViewId; id <= NewVTKViewId; id++ )
620   {
621     QAction* a = action( id );
622     if ( a )
623       a->setEnabled( activeStudy() );
624   }
625
626   // Load script menu
627   QAction* a = action( LoadScriptId );
628   if ( a )
629     a->setEnabled( activeStudy() );
630   
631   a = action( PropertiesId );
632   if( a )
633     a->setEnabled( activeStudy() );
634     
635   a = action(EditCutId);
636   a->setEnabled(false); 
637   a = action(EditCopyId);
638   a->setEnabled(false);       
639   a = action(EditPasteId);
640   a->setEnabled(false);      
641 }
642
643 //=======================================================================
644 // name    : onHelpAbout
645 // Purpose : SLOT. Display "About" message box
646 //=======================================================================
647 void SalomeApp_Application::onHelpAbout()
648 {
649   SalomeApp_AboutDlg* dlg = new SalomeApp_AboutDlg( applicationName(), applicationVersion(), desktop() );
650   dlg->exec();
651   delete dlg;
652 }
653
654 QWidget* SalomeApp_Application::window( const int flag, const int studyId ) const
655 {
656   QWidget* wid = 0;
657
658   int sId = studyId;
659   if ( sId < 0 )
660   {
661     if ( !activeStudy() )
662       return 0;
663     else
664       sId = activeStudy()->id();
665   }
666
667   if ( myWindows.contains( flag ) )
668     wid = myWindows[flag]->widget( sId );
669
670   return wid;
671 }
672
673 void SalomeApp_Application::addWindow( QWidget* wid, const int flag, const int studyId )
674 {
675   if ( !wid )
676     return;
677
678   int sId = studyId;
679   if ( sId < 0 )
680   {
681     if ( !activeStudy() )
682       return;
683     else
684       sId = activeStudy()->id();
685   }
686
687   if ( !myWindows.contains( flag ) )
688   {
689     QMap<int, int> winMap;
690     currentWindows( winMap );
691
692     myWindows.insert( flag, new SalomeApp_WidgetContainer( flag, desktop() ) );
693     if ( winMap.contains( flag ) )
694       desktop()->moveDockWindow( myWindows[flag], (Dock)winMap[flag] );
695
696     myWindows[flag]->setResizeEnabled( true );
697     myWindows[flag]->setCloseMode( QDockWindow::Always );
698     myWindows[flag]->setName( QString( "dock_window_%1" ).arg( flag ) );
699   }
700
701   myWindows[flag]->insert( sId, wid );
702
703   setWindowShown( flag, !myWindows[flag]->isEmpty() );
704 }
705
706 void SalomeApp_Application::removeWindow( const int flag, const int studyId )
707 {
708   if ( !myWindows.contains( flag ) )
709     return;
710
711   int sId = studyId;
712   if ( sId < 0 )
713   {
714     if ( !activeStudy() )
715       return;
716     else
717       sId = activeStudy()->id();
718   }
719
720   QWidget* wid = myWindows[flag]->widget( sId );
721   myWindows[flag]->remove( sId );
722   delete wid;
723
724   setWindowShown( flag, !myWindows[flag]->isEmpty() );
725 }
726
727 QWidget* SalomeApp_Application::getWindow( const int flag, const int studyId )
728 {
729   QWidget* wid = window( flag, studyId );
730   if ( !wid )
731     addWindow( wid = createWindow( flag ), flag, studyId );
732
733   return wid;
734 }
735
736 bool SalomeApp_Application::isWindowVisible( const int type ) const
737 {
738   bool res = false;
739   if ( myWindows.contains( type ) )
740   {
741     SUIT_Desktop* desk = ((SalomeApp_Application*)this)->desktop();
742     res = desk && desk->appropriate( myWindows[type] );
743   }
744   return res;
745 }
746
747 void SalomeApp_Application::setWindowShown( const int type, const bool on )
748 {
749   if ( !desktop() || !myWindows.contains( type ) )
750     return;
751
752   QDockWindow* dw = myWindows[type];
753   desktop()->setAppropriate( dw, on );
754   on ? dw->show() : dw->hide();
755 }
756
757 OB_Browser* SalomeApp_Application::objectBrowser()
758 {
759   OB_Browser* ob = 0;
760   QWidget* wid = getWindow( WT_ObjectBrowser );
761   if ( wid->inherits( "OB_Browser" ) )
762     ob = (OB_Browser*)wid;
763   return ob;
764 }
765
766 LogWindow* SalomeApp_Application::logWindow()
767 {
768   LogWindow* lw = 0;
769   QWidget* wid = getWindow( WT_LogWindow );
770   if ( wid->inherits( "LogWindow" ) )
771     lw = (LogWindow*)wid;
772   return lw;
773 }
774
775 PythonConsole* SalomeApp_Application::pythonConsole()
776 {
777   PythonConsole* console = 0;
778   QWidget* wid = getWindow( WT_PyConsole );
779   if ( wid->inherits( "PythonConsole" ) )
780     console = (PythonConsole*)wid;
781   return console;
782 }
783
784 SalomeApp_Preferences* SalomeApp_Application::preferences() const
785 {
786   return preferences( false );
787 }
788
789 SUIT_ViewManager* SalomeApp_Application::getViewManager( const QString& vmType, const bool create )
790 {
791   SUIT_ViewManager* aVM = viewManager( vmType );
792   SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
793
794   if ( anActiveVM && anActiveVM->getType() == vmType )
795     aVM = anActiveVM;
796
797   if ( aVM && create )
798   {
799     if ( !aVM->getActiveView() )
800       aVM->createView();
801     else
802       aVM->getActiveView()->setFocus();
803   }
804   else if ( create )
805     aVM = createViewManager( vmType );
806
807   return aVM;
808 }
809
810 SUIT_ViewManager* SalomeApp_Application::createViewManager( const QString& vmType )
811 {
812   SUIT_ResourceMgr* resMgr = resourceMgr();
813
814   SUIT_ViewManager* viewMgr = 0;
815   if ( vmType == GLViewer_Viewer::Type() )
816   {
817     viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() );
818     new SalomeApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
819   }
820   else if ( vmType == Plot2d_Viewer::Type() )
821   {
822     viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
823     viewMgr->setViewModel( new SPlot2d_Viewer() );// custom view model, which extends SALOME_View interface
824   }
825   else if ( vmType == OCCViewer_Viewer::Type() )
826   {
827     viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
828     SOCC_Viewer* vm = new SOCC_Viewer();
829     vm->setBackgroundColor( resMgr->colorValue( "OCCViewer", "background", vm->backgroundColor() ) );
830     vm->setTrihedronSize( resMgr->integerValue( "OCCViewer", "trihedron_size", vm->trihedronSize() ) );
831     viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
832     new SalomeApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
833   }
834   else if ( vmType == SVTK_Viewer::Type() )
835   {
836     viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
837     SVTK_Viewer* vm = (SVTK_Viewer*)viewMgr->getViewModel();
838     vm->setBackgroundColor( resMgr->colorValue( "VTKViewer", "background", vm->backgroundColor() ) );
839     new SalomeApp_VTKSelector((SVTK_Viewer*)viewMgr->getViewModel(),mySelMgr);
840   }
841
842   if ( !viewMgr )
843     return 0;
844
845   addViewManager( viewMgr );
846   SUIT_ViewWindow* viewWin = viewMgr->createViewWindow();
847
848   if ( viewWin && desktop() )
849     viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
850
851   connect( viewMgr, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
852            this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
853
854   return viewMgr;
855 }
856
857 void SalomeApp_Application::onCloseView( SUIT_ViewManager* theVM )
858 {
859   removeViewManager( theVM );
860 }
861
862 void SalomeApp_Application::onStudyCreated( SUIT_Study* theStudy )
863 {
864   SUIT_DataObject* aRoot = 0;
865   if ( theStudy && theStudy->root() )
866   {
867     aRoot = theStudy->root();
868     //aRoot->setName( tr( "DATA_MODELS" ) );
869   }
870   if ( objectBrowser() != 0 )
871     objectBrowser()->setRootObject( aRoot );
872
873   activateModule( defaultModule() );
874
875   activateWindows();
876 }
877
878 void SalomeApp_Application::onStudyOpened( SUIT_Study* theStudy )
879 {
880   SUIT_DataObject* aRoot = 0;
881   if ( theStudy && theStudy->root() )
882   {
883     aRoot = theStudy->root();
884     //aRoot->dump();
885   }
886   if ( objectBrowser() != 0 ) {
887     objectBrowser()->setRootObject( aRoot );
888   }
889
890   activateModule( defaultModule() );
891
892   activateWindows();
893
894   emit studyOpened();
895 }
896
897 void SalomeApp_Application::onStudySaved( SUIT_Study* )
898 {
899   emit studySaved();
900 }
901
902 void SalomeApp_Application::onStudyClosed( SUIT_Study* )
903 {
904   emit studyClosed();
905
906   activateModule( "" );
907
908   saveWindowsGeometry();
909 }
910
911 void SalomeApp_Application::onLoadScript( )
912 {
913   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
914   if ( !appStudy ) return;
915   _PTR(Study) aStudy = appStudy->studyDS();
916
917   if ( aStudy->GetProperties()->IsLocked() ) {
918     SUIT_MessageBox::warn1 ( desktop(),
919                              QObject::tr("WRN_WARNING"),
920                              QObject::tr("WRN_STUDY_LOCKED"),
921                              QObject::tr("BUT_OK") );
922     return;
923   }
924
925   QStringList filtersList;
926   filtersList.append(tr("PYTHON_FILES_FILTER"));
927   filtersList.append(tr("ALL_FILES_FILTER"));
928
929   QString aFile = SUIT_FileDlg::getFileName( desktop(), "", filtersList, tr( "TOT_DESK_LOADSCRIPT" ), true, true );
930
931   if ( !aFile.isEmpty() )
932   {
933     QString command = QString("execfile(\"%1\")").arg(aFile);
934
935     PythonConsole* pyConsole = pythonConsole();
936
937     if ( pyConsole )
938       pyConsole->exec( command );
939   }
940 }
941
942 void SalomeApp_Application::onPreferences()
943 {
944   QApplication::setOverrideCursor( Qt::waitCursor );
945
946   SalomeApp_PreferencesDlg* prefDlg = new SalomeApp_PreferencesDlg( preferences( true ), desktop());
947
948   QApplication::restoreOverrideCursor();
949
950   if ( !prefDlg )
951     return;
952
953   prefDlg->exec();
954
955   delete prefDlg;
956 }
957
958 void SalomeApp_Application::onMRUActivated( QString aName )
959 {
960   onOpenDoc( aName );
961 }
962
963 void SalomeApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param )
964 {
965   SalomeApp_Module* sMod = 0;
966   CAM_Module* mod = module( modName );
967   if ( mod && mod->inherits( "SalomeApp_Module" ) )
968     sMod = (SalomeApp_Module*)mod;
969
970   if ( sMod )
971     sMod->preferencesChanged( section, param );
972   else
973     preferencesChanged( section, param );
974 }
975
976 QString SalomeApp_Application::getFileFilter() const
977 {
978   return "(*.hdf)";
979 }
980
981 void SalomeApp_Application::beforeCloseDoc( SUIT_Study* s )
982 {
983   CAM_Application::beforeCloseDoc( s );
984
985   for ( WindowMap::ConstIterator itr = myWindows.begin(); s && itr != myWindows.end(); ++itr )
986     removeWindow( itr.key(), s->id() );
987 }
988
989 void SalomeApp_Application::updateActions()
990 {
991   updateCommandsStatus();
992 }
993
994 QWidget* SalomeApp_Application::createWindow( const int flag )
995 {
996   QWidget* wid = 0;
997
998   SUIT_ResourceMgr* resMgr = resourceMgr();
999
1000   if ( flag == WT_ObjectBrowser )
1001   {
1002     OB_Browser* ob = new OB_Browser( desktop() );
1003     ob->setAutoUpdate( true );
1004     ob->setAutoOpenLevel( 1 );
1005     ob->setCaption( tr( "OBJECT_BROWSER" ) );
1006     ob->resize( OBJECT_BROWSER_WIDTH, ob->height() );
1007     ob->setFilter( new SalomeApp_OBFilter( selectionMgr() ) );
1008
1009     ob->setNameTitle( tr( "OBJ_BROWSER_NAME" ) );
1010
1011     for ( int i = SalomeApp_DataObject::CT_Value; i <= SalomeApp_DataObject::CT_RefEntry; i++ )
1012     {
1013       ob->addColumn( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i ) ), i );
1014       ob->setColumnShown( i, resMgr->booleanValue( "ObjectBrowser",
1015                                                    QString().sprintf( "visibility_column_%d", i ), true ) );
1016     }
1017
1018     // Create OBSelector
1019     new SalomeApp_OBSelector( ob, mySelMgr );
1020
1021     wid = ob;
1022
1023     ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1024   }
1025   else if ( flag == WT_PyConsole )
1026   {
1027     PythonConsole* pyCons = new PythonConsole( desktop(), new SalomeApp_PyInterp() );
1028     pyCons->setCaption( tr( "PYTHON_CONSOLE" ) );
1029     wid = pyCons;
1030
1031     //    pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1032   }
1033   else if ( flag == WT_LogWindow )
1034   {
1035     LogWindow* logWin = new LogWindow( desktop() );
1036     logWin->setCaption( tr( "LOG_WINDOW" ) );
1037     wid = logWin;
1038
1039     logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1040   }
1041
1042   return wid;
1043 }
1044
1045 void SalomeApp_Application::defaultWindows( QMap<int, int>& aMap ) const
1046 {
1047   aMap.insert( WT_ObjectBrowser, Qt::DockLeft );
1048   aMap.insert( WT_PyConsole, Qt::DockBottom );
1049   //  aMap.insert( WT_LogWindow, Qt::DockBottom );
1050 }
1051
1052 void SalomeApp_Application::defaultViewManagers( QStringList& ) const
1053 {
1054 }
1055
1056 SalomeApp_Preferences* SalomeApp_Application::preferences( const bool crt ) const
1057 {
1058   if ( myPrefs )
1059     return myPrefs;
1060
1061   SalomeApp_Application* that = (SalomeApp_Application*)this;
1062
1063   if ( !_prefs_ && crt )
1064   {
1065     _prefs_ = new SalomeApp_Preferences( resourceMgr() );
1066     that->createPreferences( _prefs_ );
1067   }
1068
1069   that->myPrefs = _prefs_;
1070
1071   QPtrList<SUIT_Application> appList = SUIT_Session::session()->applications();
1072   for ( QPtrListIterator<SUIT_Application> appIt ( appList ); appIt.current(); ++appIt )
1073   {
1074     if ( !appIt.current()->inherits( "SalomeApp_Application" ) )
1075       continue;
1076
1077     SalomeApp_Application* app = (SalomeApp_Application*)appIt.current();
1078
1079     QStringList modNameList;
1080     app->modules( modNameList, false );
1081     for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it )
1082     {
1083       int id = _prefs_->addPreference( *it );
1084       _prefs_->setProperty( id, "info", tr( "PREFERENCES_NOT_LOADED" ).arg( *it ) );
1085     }
1086
1087     ModuleList modList;
1088     app->modules( modList );
1089     for ( ModuleListIterator itr( modList ); itr.current(); ++itr )
1090     {
1091       SalomeApp_Module* mod = 0;
1092       if ( itr.current()->inherits( "SalomeApp_Module" ) )
1093         mod = (SalomeApp_Module*)itr.current();
1094
1095       if ( mod && !_prefs_->hasModule( mod->moduleName() ) )
1096         mod->createPreferences();
1097     }
1098   }
1099
1100   connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
1101            this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ) );
1102
1103   return myPrefs;
1104 }
1105
1106 void SalomeApp_Application::moduleAdded( CAM_Module* mod )
1107 {
1108   CAM_Application::moduleAdded( mod );
1109
1110   SalomeApp_Module* salomeMod = 0;
1111   if ( mod && mod->inherits( "SalomeApp_Module" ) )
1112     salomeMod = (SalomeApp_Module*)mod;
1113
1114   if ( myPrefs && salomeMod && !myPrefs->hasModule( salomeMod->moduleName() ))
1115     salomeMod->createPreferences();
1116 }
1117
1118 void SalomeApp_Application::createPreferences( SalomeApp_Preferences* pref )
1119 {
1120   if ( !pref )
1121     return;
1122
1123   int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
1124
1125   int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat );
1126
1127   int obGroup = pref->addPreference( tr( "PREF_GROUP_OBJBROWSER" ), genTab );
1128   for ( int i = SalomeApp_DataObject::CT_Value; i <= SalomeApp_DataObject::CT_RefEntry; i++ )
1129   {
1130     pref->addPreference( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i ) ), obGroup,
1131                          SalomeApp_Preferences::Bool, "ObjectBrowser", QString().sprintf( "visibility_column_%d", i ) );
1132   }
1133   pref->setProperty( obGroup, "columns", 1 );
1134
1135   int viewTab = pref->addPreference( tr( "PREF_TAB_VIEWERS" ), salomeCat );
1136
1137   int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), viewTab );
1138
1139   int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), viewTab );
1140   pref->setProperty( occGroup, "columns", 1 );
1141   pref->setProperty( vtkGroup, "columns", 1 );
1142
1143   pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occGroup,
1144                        SalomeApp_Preferences::IntSpin, "OCCViewer", "trihedron_size" );
1145   pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup,
1146                        SalomeApp_Preferences::Color, "OCCViewer", "background" );
1147
1148   pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), vtkGroup,
1149                        SalomeApp_Preferences::IntSpin, "VTKViewer", "trihedron_size" );
1150   pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGroup,
1151                        SalomeApp_Preferences::Color, "VTKViewer", "background" );
1152 }
1153
1154 void SalomeApp_Application::preferencesChanged( const QString& sec, const QString& param )
1155 {
1156   SUIT_ResourceMgr* resMgr = resourceMgr();
1157   if ( !resMgr )
1158     return;
1159
1160   if ( sec == QString( "OCCViewer" ) && param == QString( "trihedron_size" ) )
1161   {
1162     int sz = resMgr->integerValue( sec, param, -1 );
1163     QPtrList<SUIT_ViewManager> lst;
1164     viewManagers( OCCViewer_Viewer::Type(), lst );
1165     for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current() && sz >= 0; ++it )
1166     {
1167       SUIT_ViewModel* vm = it.current()->getViewModel();
1168       if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
1169         continue;
1170
1171       OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
1172       occVM->setTrihedronSize( sz );
1173       occVM->getAISContext()->UpdateCurrentViewer();
1174     }
1175   }
1176 }
1177
1178 void SalomeApp_Application::afterCloseDoc()
1179 {
1180   updateWindows();
1181
1182   CAM_Application::afterCloseDoc();
1183 }
1184
1185 CORBA::ORB_var SalomeApp_Application::orb()
1186 {
1187   ORB_INIT& init = *SINGLETON_<ORB_INIT>::Instance();
1188   static CORBA::ORB_var _orb = init( qApp->argc(), qApp->argv() );
1189   return _orb;
1190 }
1191
1192 SALOMEDSClient_StudyManager* SalomeApp_Application::studyMgr()
1193 {
1194   static SALOMEDSClient_StudyManager* _sm = new SALOMEDS_StudyManager();
1195   return _sm;
1196 }
1197
1198 SALOME_NamingService* SalomeApp_Application::namingService()
1199 {
1200   static SALOME_NamingService* _ns = new SALOME_NamingService( orb() );
1201   return _ns;
1202 }
1203
1204 SALOME_LifeCycleCORBA* SalomeApp_Application::lcc()
1205 {
1206   static SALOME_LifeCycleCORBA* _lcc = new SALOME_LifeCycleCORBA( namingService() );
1207   return _lcc;
1208 }
1209
1210 QString SalomeApp_Application::defaultEngineIOR()
1211 {
1212   // Look for a default module engine (needed for CORBAless modules to use SALOMEDS persistence)
1213   QString anIOR( "" );
1214   CORBA::Object_ptr anEngine = namingService()->Resolve( "/SalomeAppEngine" );
1215   if ( !CORBA::is_nil( anEngine ) )
1216     anIOR = orb()->object_to_string( anEngine );
1217   return anIOR;
1218 }
1219
1220 void SalomeApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) const
1221 {
1222   iconMap.clear();
1223
1224   SUIT_ResourceMgr* resMgr = resourceMgr();
1225   if ( !resMgr )
1226     return;
1227
1228   QStringList modList;
1229   modules( modList, false );
1230
1231   for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )
1232   {
1233     QString modName = *it;
1234     QString modIntr = moduleName( modName );
1235     QString modIcon = resMgr->stringValue( modIntr, "icon", QString::null );
1236
1237     if ( modIcon.isEmpty() )
1238       continue;
1239
1240     if ( SUIT_Tools::extension( modIcon ).isEmpty() )
1241       modIcon += QString( ".png" );
1242
1243     iconMap.insert( modName, modIcon );
1244   }
1245 }
1246
1247 void SalomeApp_Application::updateModuleActions()
1248 {
1249   QString modName;
1250   if ( activeModule() )
1251     modName = activeModule()->moduleName();
1252
1253   if ( myActions.contains( modName ) )
1254     myActions[modName]->setOn( true );
1255 }
1256
1257 void SalomeApp_Application::currentWindows( QMap<int, int>& winMap ) const
1258 {
1259   winMap.clear();
1260   if ( !activeStudy() )
1261     return;
1262
1263   if ( activeModule() && activeModule()->inherits( "SalomeApp_Module" ) )
1264     ((SalomeApp_Module*)activeModule())->windows( winMap );
1265   else
1266     defaultWindows( winMap );
1267 }
1268
1269 void SalomeApp_Application::currentViewManagers( QStringList& lst ) const
1270 {
1271   lst.clear();
1272   if ( !activeStudy() )
1273     return;
1274
1275   if ( activeModule() && activeModule()->inherits( "SalomeApp_Module" ) )
1276     ((SalomeApp_Module*)activeModule())->viewManagers( lst );
1277   else
1278     defaultViewManagers( lst );
1279 }
1280
1281 void SalomeApp_Application::updateWindows()
1282 {
1283   QMap<int, int> winMap;
1284   currentWindows( winMap );
1285
1286   for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
1287     getWindow( it.key() );
1288
1289   loadWindowsGeometry();
1290
1291   for ( WindowMap::ConstIterator itr = myWindows.begin(); itr != myWindows.end(); ++itr )
1292     setWindowShown( itr.key(), !itr.data()->isEmpty() && winMap.contains( itr.key() ) );
1293 }
1294
1295 void SalomeApp_Application::updateViewManagers()
1296 {
1297   QStringList lst;
1298   currentViewManagers( lst );
1299
1300   for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
1301     getViewManager( *it, true );
1302 }
1303
1304 void SalomeApp_Application::loadWindowsGeometry()
1305 {
1306   QtxDockAction* dockMgr = 0;
1307
1308   QAction* a = action( ViewWindowsId );
1309   if ( a && a->inherits( "QtxDockAction" ) )
1310     dockMgr = (QtxDockAction*)a;
1311
1312   if ( !dockMgr )
1313     return;
1314
1315   QString modName;
1316   if ( activeModule() )
1317     modName = moduleLibrary( activeModule()->moduleName(), false );
1318
1319   QString section = QString( "windows_geometry" );
1320   if ( !modName.isEmpty() )
1321     section += QString( "." ) + modName;
1322
1323   dockMgr->loadGeometry( resourceMgr(), section, false );
1324   dockMgr->restoreGeometry();
1325 }
1326
1327 void SalomeApp_Application::saveWindowsGeometry()
1328 {
1329   QtxDockAction* dockMgr = 0;
1330
1331   QAction* a = action( ViewWindowsId );
1332   if ( a && a->inherits( "QtxDockAction" ) )
1333     dockMgr = (QtxDockAction*)a;
1334
1335   if ( !dockMgr )
1336     return;
1337
1338   QString modName;
1339   if ( activeModule() )
1340     modName = moduleLibrary( activeModule()->moduleName(), false );
1341
1342   QString section = QString( "windows_geometry" );
1343   if ( !modName.isEmpty() )
1344     section += QString( "." ) + modName;
1345
1346   dockMgr->storeGeometry();
1347   dockMgr->saveGeometry( resourceMgr(), section, false );
1348 }
1349
1350 void SalomeApp_Application::activateWindows()
1351 {
1352   if ( activeStudy() )
1353   {
1354     for ( WindowMap::Iterator itr = myWindows.begin(); itr != myWindows.end(); ++itr )
1355       itr.data()->activate( activeStudy()->id() );
1356   }
1357 }
1358
1359 void SalomeApp_Application::onProperties()
1360 {
1361   SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
1362   if( !study )
1363     return;
1364
1365   _PTR(StudyBuilder) SB = study->studyDS()->NewBuilder();
1366   SB->NewCommand();
1367
1368   SalomeApp_StudyPropertiesDlg aDlg( desktop() );
1369   int res = aDlg.exec();
1370   if( res==QDialog::Accepted && aDlg.isChanged() )
1371     SB->CommitCommand();
1372   else
1373     SB->AbortCommand();
1374
1375   //study->updateCaptions();
1376 }
1377
1378 QString SalomeApp_Application::getFileName( bool open, const QString& initial, const QString& filters, 
1379                                             const QString& caption, QWidget* parent )
1380 {
1381   if ( !parent )
1382     parent = desktop();
1383   QStringList fls = QStringList::split( ";", filters, false );
1384
1385   return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
1386 }
1387
1388 void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* thePopup, QString& title )
1389 {
1390   CAM_Application::contextMenuPopup( type, thePopup, title );
1391   thePopup->insertSeparator();
1392   thePopup->insertItem( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
1393 }
1394