]> SALOME platform Git repositories - modules/gui.git/blob - src/SalomeApp/SalomeApp_Application.cxx
Salome HOME
e52570a5f5b7d98861f563e504624ca129d21d71
[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 #include "SalomeApp_CheckFileDlg.h"
24
25 #include "SalomeApp_GLSelector.h"
26 #include "SalomeApp_OBSelector.h"
27 #include "SalomeApp_OCCSelector.h"
28 #include "SalomeApp_VTKSelector.h"
29 #include "SalomeApp_SelectionMgr.h"
30
31 #include <LogWindow.h>
32
33 #include <GLViewer_Viewer.h>
34 #include <GLViewer_ViewManager.h>
35
36 #include <Plot2d_ViewManager.h>
37 #include <SPlot2d_ViewModel.h>
38
39 #include <OCCViewer_ViewManager.h>
40 #include <SOCC_ViewModel.h>
41
42 #include <SVTK_ViewModel.h>
43 #include <SVTK_ViewManager.h>
44
45 #include <STD_TabDesktop.h>
46
47 #include "STD_LoadStudiesDlg.h"
48
49 #include <SUIT_Tools.h>
50 #include <SUIT_Session.h>
51
52 #include <QtxToolBar.h>
53 #include <QtxMRUAction.h>
54 #include <QtxDockAction.h>
55 #include <QtxResourceEdit.h>
56
57 #include <OB_Browser.h>
58
59 #include <PythonConsole_PyConsole.h>
60
61 #include <SUIT_FileDlg.h>
62 #include <SUIT_MessageBox.h>
63 #include <SUIT_ResourceMgr.h>
64 #include <SUIT_ActionOperation.h>
65
66 #include <Utils_ORB_INIT.hxx>
67 #include <Utils_SINGLETON.hxx>
68 #include <SALOME_ModuleCatalog_impl.hxx>
69 #include <SALOME_LifeCycleCORBA.hxx>
70
71 #include <qmap.h>
72 #include <qdir.h>
73 #include <qlabel.h>
74 #include <qimage.h>
75 #include <qaction.h>
76 #include <qmenubar.h>
77 #include <qcombobox.h>
78 #include <qmessagebox.h>
79 #include <qapplication.h>
80 #include <qlistbox.h>
81 #include <qregexp.h>
82
83 #include "SALOMEDS_StudyManager.hxx"
84
85 #include "SALOME_ListIteratorOfListIO.hxx"
86 #include "SALOME_ListIO.hxx"
87
88 #include "ToolsGUI_CatalogGeneratorDlg.h"
89 #include "ToolsGUI_RegWidget.h"
90
91 #define OBJECT_BROWSER_WIDTH 300
92
93 /*!Image for empty icon.*/
94 static const char* imageEmptyIcon[] = {
95 "20 20 1 1",
96 ".      c None",
97 "....................",
98 "....................",
99 "....................",
100 "....................",
101 "....................",
102 "....................",
103 "....................",
104 "....................",
105 "....................",
106 "....................",
107 "....................",
108 "....................",
109 "....................",
110 "....................",
111 "....................",
112 "....................",
113 "....................",
114 "....................",
115 "....................",
116 "...................."};
117
118 /*!Create new instance of SalomeApp_Application.*/
119 extern "C" SALOMEAPP_EXPORT SUIT_Application* createApplication()
120 {
121   return new SalomeApp_Application();
122 }
123
124 SalomeApp_Preferences* SalomeApp_Application::_prefs_ = 0;
125
126 /*
127   Class       : SalomeApp_Application
128   Description : Application containing SalomeApp module
129 */
130
131 /*!Constructor.*/
132 SalomeApp_Application::SalomeApp_Application()
133 : CAM_Application( false ),
134 myPrefs( 0 )
135 {
136   STD_TabDesktop* desk = new STD_TabDesktop();
137
138   setDesktop( desk );
139
140   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
141   QPixmap aLogo = aResMgr->loadPixmap( "SalomeApp", tr( "APP_DEFAULT_ICO" ), false );
142
143   desktop()->setIcon( aLogo );
144   desktop()->setDockableMenuBar( true );
145   desktop()->setDockableStatusBar( false );
146
147   clearViewManagers();
148
149   mySelMgr = new SalomeApp_SelectionMgr( this );
150
151   connect( desk, SIGNAL( closing( SUIT_Desktop*, QCloseEvent* ) ),
152            this, SLOT( onDesktopClosing( SUIT_Desktop*, QCloseEvent* ) ) );
153
154   connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) );
155 }
156
157 /*!Destructor.
158  *\li Save window geometry.
159  *\li Save desktop geometry.
160  *\li Save resource maneger.
161  *\li Delete selection manager.
162  *\li Destroy event filter.
163  */
164 SalomeApp_Application::~SalomeApp_Application()
165 {
166   saveWindowsGeometry();
167
168   if ( resourceMgr() )
169   {
170     if ( desktop() )
171       desktop()->saveGeometry( resourceMgr(), "desktop" );
172     resourceMgr()->save();
173   }
174
175   delete mySelMgr;
176
177   SalomeApp_EventFilter::Destroy();
178 }
179
180 /*!Start application.*/
181 void SalomeApp_Application::start()
182 {
183   if ( desktop() )
184     desktop()->loadGeometry( resourceMgr(), "desktop" );
185
186   CAM_Application::start();
187
188   QAction* a = action( ViewWindowsId );
189   if ( a && a->inherits( "QtxDockAction" ) )
190     ((QtxDockAction*)a)->setAutoPlace( true );
191
192   SalomeApp_EventFilter::Init();
193
194   updateWindows();
195   updateViewManagers();
196
197   putInfo( "" );
198 }
199
200 /*!Gets application name.*/
201 QString SalomeApp_Application::applicationName() const
202 {
203   return tr( "APP_NAME" );
204 }
205
206 /*!Gets application version.*/
207 QString SalomeApp_Application::applicationVersion() const
208 {
209   static QString _app_version;
210
211   if ( _app_version.isEmpty() )
212   {
213     QString path( ::getenv( "GUI_ROOT_DIR" ) );
214     if ( !path.isEmpty() )
215       path += QDir::separator();
216     path += QString( "bin/salome/VERSION" );
217
218     QFile vf( path );
219     if ( vf.open( IO_ReadOnly ) )
220     {
221       QString line;
222       vf.readLine( line, 1024 );
223       vf.close();
224
225       if ( !line.isEmpty() )
226       {
227         while ( !line.isEmpty() && line.at( line.length() - 1 ) == QChar( '\n' ) )
228           line.remove( line.length() - 1, 1 );
229
230         int idx = line.findRev( ":" );
231         if ( idx != -1 )
232           _app_version = line.mid( idx + 1 ).stripWhiteSpace();
233       }
234     }
235   }
236
237   return _app_version;
238 }
239
240 /*!Load module by \a name.*/
241 CAM_Module* SalomeApp_Application::loadModule( const QString& name )
242 {
243   CAM_Module* mod = CAM_Application::loadModule( name );
244   if ( mod )
245   {
246     connect( this, SIGNAL( studyOpened() ), mod, SLOT( onModelOpened() ) );
247     connect( this, SIGNAL( studySaved() ),  mod, SLOT( onModelSaved() ) );
248     connect( this, SIGNAL( studyClosed() ), mod, SLOT( onModelClosed() ) );
249   }
250   return mod;
251 }
252
253 /*!Activate module by \a modName*/
254 bool SalomeApp_Application::activateModule( const QString& modName )
255 {
256   QString actName;
257   CAM_Module* prevMod = activeModule();
258
259   if ( prevMod )
260     actName = prevMod->moduleName();
261
262   if ( actName == modName )
263     return true;
264
265   putInfo( tr( "ACTIVATING_MODULE" ).arg( modName ) );  
266
267   saveWindowsGeometry();
268
269   bool status = CAM_Application::activateModule( modName );
270
271   updateModuleActions();
272
273   putInfo( "" );  
274
275   if ( !status )
276     return false;
277
278   updateWindows();
279   updateViewManagers();
280
281   return true;
282 }
283
284 /*!Gets selection manager.*/
285 SalomeApp_SelectionMgr* SalomeApp_Application::selectionMgr() const
286 {
287   return mySelMgr;
288 }
289
290 /*!Create actions:*/
291 void SalomeApp_Application::createActions()
292 {
293   STD_Application::createActions();
294
295   SUIT_Desktop* desk = desktop();
296   SUIT_ResourceMgr* resMgr = resourceMgr();
297
298   //! Dump study
299   createAction( DumpStudyId, tr( "TOT_DESK_FILE_DUMP_STUDY" ), QIconSet(),
300                 tr( "MEN_DESK_FILE_DUMP_STUDY" ), tr( "PRP_DESK_FILE_DUMP_STUDY" ),
301                 0, desk, false, this, SLOT( onDumpStudy() ) );
302
303   //! Load script
304   createAction( LoadScriptId, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), QIconSet(),
305                 tr( "MEN_DESK_FILE_LOAD_SCRIPT" ), tr( "PRP_DESK_FILE_LOAD_SCRIPT" ),
306                 0, desk, false, this, SLOT( onLoadScript() ) );
307
308   //! Properties
309   createAction( PropertiesId, tr( "TOT_DESK_PROPERTIES" ), QIconSet(),
310                 tr( "MEN_DESK_PROPERTIES" ), tr( "PRP_DESK_PROPERTIES" ),
311                 0, desk, false, this, SLOT( onProperties() ) );
312
313   //! Preferences
314   createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIconSet(),
315                 tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
316                 CTRL+Key_P, desk, false, this, SLOT( onPreferences() ) );
317
318   //! Catalog Generator
319   createAction( CatalogGenId, tr( "TOT_DESK_CATALOG_GENERATOR" ),  QIconSet(),
320                 tr( "MEN_DESK_CATALOG_GENERATOR" ), tr( "PRP_DESK_CATALOG_GENERATOR" ),
321                 0, desk, false, this, SLOT( onCatalogGen() ) );
322
323   //! Registry Display
324   createAction( RegDisplayId, tr( "TOT_DESK_REGISTRY_DISPLAY" ),  QIconSet(),
325                 tr( "MEN_DESK_REGISTRY_DISPLAY" ), tr( "PRP_DESK_REGISTRY_DISPLAY" ),
326                 0, desk, false, this, SLOT( onRegDisplay() ) );
327
328   //! MRU
329   QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), desk );
330   connect( mru, SIGNAL( activated( QString ) ), this, SLOT( onMRUActivated( QString ) ) );
331   registerAction( MRUId, mru );
332
333   //! default icon for neutral point ('SALOME' module)
334   QPixmap defIcon = resMgr->loadPixmap( "SalomeApp", tr( "APP_DEFAULT_ICO" ), false );
335   if ( defIcon.isNull() )
336     defIcon = QPixmap( imageEmptyIcon );
337
338   //! default icon for any module
339   QPixmap modIcon = resMgr->loadPixmap( "SalomeApp", tr( "APP_MODULE_ICO" ), false );
340   if ( modIcon.isNull() )
341     modIcon = QPixmap( imageEmptyIcon );
342
343   QToolBar* modTBar = new QtxToolBar( true, desk );
344   modTBar->setLabel( tr( "INF_TOOLBAR_MODULES" ) );
345
346   QActionGroup* modGroup = new QActionGroup( this );
347   modGroup->setExclusive( true );
348   modGroup->setUsesDropDown( true );
349
350   QAction* a = createAction( -1, tr( "APP_NAME" ), defIcon, tr( "APP_NAME" ),
351                              tr( "PRP_APP_MODULE" ), 0, desk, true );
352   modGroup->add( a );
353   myActions.insert( QString(), a );
354
355   QMap<QString, QString> iconMap;
356   moduleIconNames( iconMap );
357
358   const int iconSize = 20;
359
360   modGroup->addTo( modTBar );
361   modTBar->addSeparator();
362
363   QStringList modList;
364   modules( modList, false );
365
366   for ( QStringList::Iterator it = modList.begin(); it != modList.end(); ++it )
367   {
368     if ( (*it).isEmpty() )
369       continue;
370
371     QString iconName;
372     if ( iconMap.contains( *it ) )
373       iconName = iconMap[*it];
374
375     QString modName = moduleName( *it );
376
377     QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
378     if ( icon.isNull() )
379       icon = modIcon;
380
381     icon.convertFromImage( icon.convertToImage().smoothScale( iconSize, iconSize, QImage::ScaleMin ) );
382
383     QAction* a = createAction( -1, *it, icon, *it, tr( "PRP_MODULE" ).arg( *it ), 0, desk, true );
384     a->addTo( modTBar );
385     modGroup->add( a );
386
387     myActions.insert( *it, a );
388   }
389
390   SUIT_Tools::simplifySeparators( modTBar );
391
392   //! New window
393
394   int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, 100 );
395   int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
396   createMenu( separator(), windowMenu, -1, 1 );
397
398   QMap<int, int> accelMap;
399   accelMap[NewGLViewId]  = ALT+Key_G;
400   accelMap[NewPlot2dId]  = ALT+Key_P;
401   accelMap[NewOCCViewId] = ALT+Key_O;
402   accelMap[NewVTKViewId] = ALT+Key_K;
403
404   for ( int id = NewGLViewId; id <= NewVTKViewId; id++ )
405   {
406     QAction* a = createAction( id, tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ), QIconSet(),
407                                tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ),
408                                tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ),
409                                accelMap.contains( id ) ? accelMap[id] : 0, desk, false, this, SLOT( onNewWindow() ) );
410     createMenu( a, newWinMenu, -1 );
411   }
412   connect( modGroup, SIGNAL( selected( QAction* ) ), this, SLOT( onModuleActivation( QAction* ) ) );
413
414   int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
415
416   createMenu( DumpStudyId, fileMenu, 10, -1 );
417   createMenu( separator(), fileMenu, -1, 15, -1 );
418   createMenu( LoadScriptId, fileMenu, 10, -1 );
419   createMenu( separator(), fileMenu, -1, 15, -1 );
420   createMenu( PropertiesId, fileMenu, 10, -1 );
421   createMenu( separator(), fileMenu, -1, 15, -1 );
422   createMenu( PreferencesId, fileMenu, 15, -1 );
423   createMenu( separator(), fileMenu, -1, 15, -1 );
424
425   int toolsMenu = createMenu( tr( "MEN_DESK_TOOLS" ), -1, -1, 50 );
426   createMenu( CatalogGenId, toolsMenu, 10, -1 );
427   createMenu( RegDisplayId, toolsMenu, 10, -1 );
428   createMenu( separator(), toolsMenu, -1, 15, -1 );
429
430   /*
431   createMenu( separator(), fileMenu, -1, 100, -1 );
432   createMenu( MRUId, fileMenu, 100, -1 );
433   createMenu( separator(), fileMenu, -1, 100, -1 );
434   */
435 }
436
437 /*!On module activation action.*/
438 void SalomeApp_Application::onModuleActivation( QAction* a )
439 {
440   if ( !a )
441     return;
442
443   QString modName = a->menuText();
444   if ( modName == tr( "APP_NAME" ) )
445     modName = QString::null;
446
447   // Force user to create/open a study before module activation
448   QMap<QString, QString> iconMap;
449   moduleIconNames( iconMap );
450   QPixmap icon = resourceMgr()->loadPixmap( moduleName( modName ), iconMap[ modName ], false );
451   if ( icon.isNull() )
452     icon = resourceMgr()->loadPixmap( "SalomeApp", tr( "APP_MODULE_BIG_ICO" ), false ); // default icon for any module
453
454   bool cancelled = false;
455   while ( !modName.isEmpty() && !activeStudy() && !cancelled ){
456     SalomeApp_ModuleDlg aDlg( desktop(), modName, icon );
457     int res = aDlg.exec();
458
459     switch ( res ){
460     case 1:
461       onNewDoc();
462       break;
463     case 2:
464       onOpenDoc();
465       break;
466     case 3:
467       //onLoadStudy();
468       //break;
469     case 0:
470     default:
471       putInfo( tr("INF_CANCELLED") );
472       myActions[QString()]->setOn( true );
473       cancelled = true;
474     }
475   }
476
477   if ( !cancelled )
478     activateModule( modName );
479 }
480
481 /*!Default module activation.*/
482 QString SalomeApp_Application::defaultModule() const
483 {
484   QStringList aModuleNames;
485   modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration
486   //! If there's the one and only module --> activate it automatically
487   //! TODO: Possible improvement - default module can be taken from preferences
488   return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" );
489 }
490
491 /*!On new window slot.*/
492 void SalomeApp_Application::onNewWindow()
493 {
494   const QObject* obj = sender();
495   if ( !obj || !obj->inherits( "QAction" ) )
496     return;
497
498   QString type;
499   int id = actionId( (QAction*)obj );
500   switch ( id )
501   {
502   case NewGLViewId:
503     type = GLViewer_Viewer::Type();
504     break;
505   case NewPlot2dId:
506     type = Plot2d_Viewer::Type();
507     break;
508   case NewOCCViewId:
509     type = OCCViewer_Viewer::Type();
510     break;
511   case NewVTKViewId:
512     type = VTKViewer_Viewer::Type();
513     break;
514   }
515
516   if ( !type.isEmpty() )
517     createViewManager( type );
518 }
519
520 //=======================================================================
521 //  name    : onNewDoc
522 /*! Purpose : SLOT. Create new document*/
523 //=======================================================================
524 void SalomeApp_Application::onNewDoc()
525 {
526   SUIT_Study* study = activeStudy();
527
528   saveWindowsGeometry();
529
530   CAM_Application::onNewDoc();
531
532   if ( !study ) // new study will be create in THIS application
533   {
534     updateWindows();
535     updateViewManagers();
536   }
537 }
538
539 //=======================================================================
540 // name    : onOpenDoc
541 /*! Purpose : SLOT. Open new document*/
542 //=======================================================================
543 void SalomeApp_Application::onOpenDoc()
544 {
545   SUIT_Study* study = activeStudy();
546   saveWindowsGeometry();
547
548   CAM_Application::onOpenDoc();
549
550   if ( !study ) // new study will be create in THIS application
551   {
552     updateWindows();
553     updateViewManagers();
554   }
555 }
556
557 /*! Purpose : SLOT. Open new document with \a aName.*/
558 bool SalomeApp_Application::onOpenDoc( const QString& aName )
559 {
560   bool res = CAM_Application::onOpenDoc( aName );
561
562   QAction* a = action( MRUId );
563   if ( a && a->inherits( "QtxMRUAction" ) )
564   {
565     QtxMRUAction* mru = (QtxMRUAction*)a;
566     if ( res )
567       mru->insert( aName );
568     else
569       mru->remove( aName );
570   }
571   return res;
572 }
573
574 /*!SLOT. Load document.*/
575 void SalomeApp_Application::onLoadDoc()
576 {
577   QString name, studyname, ext;
578
579   STD_LoadStudiesDlg aDlg( desktop(), TRUE);
580
581   std::vector<std::string> List = studyMgr()->GetOpenStudies();
582
583   SUIT_Session* aSession = SUIT_Session::session();
584   QPtrList<SUIT_Application> aAppList = aSession->applications();
585   SUIT_Application* aApp = 0;
586
587   for (unsigned int ind = 0; ind < List.size(); ind++) {
588      studyname = List[ind].c_str();
589      //Add to list only unloaded studies
590      bool isAlreadyOpen = false;
591      for ( QPtrListIterator<SUIT_Application> it( aAppList ); it.current() && !isAlreadyOpen; ++it )
592        {
593          aApp = it.current();
594          if(!aApp || !aApp->activeStudy()) continue;
595          if ( aApp->activeStudy()->studyName() == studyname ) isAlreadyOpen = true;
596        }
597
598      if ( !isAlreadyOpen ) aDlg.ListComponent->insertItem( studyname );
599   }
600
601   int retVal = aDlg.exec();
602   studyname = aDlg.ListComponent->currentText();
603
604   if (retVal == QDialog::Rejected)
605     return;
606
607   if ( studyname.isNull() || studyname.isEmpty() )
608     return;
609
610   name = studyname;
611   name.replace( QRegExp(":"), "/" );
612
613   if(onLoadDoc(name)) {
614      updateWindows();
615      updateViewManagers();
616      updateObjectBrowser(true);
617   }
618 }
619
620
621 /*!SLOT. Load document with \a aName.*/
622 bool SalomeApp_Application::onLoadDoc( const QString& aName )
623 {
624   bool res = CAM_Application::onLoadDoc( aName );
625
626   /*jfa tmp:QAction* a = action( MRUId );
627   if ( a && a->inherits( "QtxMRUAction" ) )
628   {
629     QtxMRUAction* mru = (QtxMRUAction*)a;
630     if ( res )
631       mru->insert( aName );
632     else
633       mru->remove( aName );
634   }*/
635   return res;
636 }
637
638 /*!Private SLOT. Selection.*/
639 void SalomeApp_Application::onSelection()
640 {
641   onSelectionChanged();
642
643   if ( activeModule() && activeModule()->inherits( "SalomeApp_Module" ) )
644     ((SalomeApp_Module*)activeModule())->selectionChanged();
645 }
646
647 /*!SLOT. Copy objects to study maneger from selection maneger..*/
648 void SalomeApp_Application::onCopy()
649 {
650   SALOME_ListIO list;
651   SalomeApp_SelectionMgr* mgr = selectionMgr();
652   mgr->selectedObjects(list);
653
654   SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
655   if(study == NULL) return;
656
657   _PTR(Study) stdDS = study->studyDS();
658   if(!stdDS) return;
659
660   SALOME_ListIteratorOfListIO it( list );
661   if(it.More())
662     {
663       _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
664       try {
665         studyMgr()->Copy(so);
666         onSelectionChanged();
667       }
668       catch(...) {
669       }
670     }
671 }
672
673 /*!SLOT. Paste objects to study maneger from selection manager.*/
674 void SalomeApp_Application::onPaste()
675 {
676   SALOME_ListIO list;
677   SalomeApp_SelectionMgr* mgr = selectionMgr();
678   mgr->selectedObjects(list);
679
680   SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
681   if(study == NULL) return;
682
683   _PTR(Study) stdDS = study->studyDS();
684   if(!stdDS) return;
685
686   SALOME_ListIteratorOfListIO it( list );
687   if(it.More())
688     {
689       _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
690       try {
691         studyMgr()->Paste(so);
692         updateObjectBrowser( true );
693         updateActions(); //SRN: BugID IPAL9377, case 3
694       }
695       catch(...) {
696       }
697     }
698 }
699
700 /*!Sets enable or disable some actions on selection changed.*/
701 void SalomeApp_Application::onSelectionChanged()
702 {
703    SALOME_ListIO list;
704    SalomeApp_SelectionMgr* mgr = selectionMgr();
705    mgr->selectedObjects(list);
706
707    SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
708    if(study == NULL) return;
709
710    _PTR(Study) stdDS = study->studyDS();
711    if(!stdDS) return;
712
713    QAction* qaction;
714
715    SALOME_ListIteratorOfListIO it( list );
716    if(it.More() && list.Extent() == 1)
717    {
718       _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
719
720       qaction = action(EditCopyId);
721       if(studyMgr()->CanCopy(so) ) qaction->setEnabled(true);
722       else qaction->setEnabled(false);
723
724       qaction = action(EditPasteId);
725       if( studyMgr()->CanPaste(so) ) qaction->setEnabled(true);
726       else qaction->setEnabled(false);
727    }
728    else {
729      qaction = action(EditCopyId);
730      qaction->setEnabled(false);
731      qaction = action(EditPasteId);
732      qaction->setEnabled(false);
733    }
734 }
735
736 /*!Update object browser.*/
737 void SalomeApp_Application::onRefresh()
738 {
739   updateObjectBrowser( true );
740 }
741
742 /*!Private SLOT. */
743 void SalomeApp_Application::onOpenWith()
744 {
745   QApplication::setOverrideCursor( Qt::waitCursor );
746   SALOME_ListIO aList;
747   SalomeApp_SelectionMgr* mgr = selectionMgr();
748   mgr->selectedObjects(aList);
749   if (aList.Extent() != 1)
750     {
751       QApplication::restoreOverrideCursor();
752       return;
753     }
754   Handle(SALOME_InteractiveObject) aIObj = aList.First();
755   QString aModuleName(aIObj->getComponentDataType());
756   QString aModuleTitle = moduleTitle(aModuleName);
757   activateModule(aModuleTitle);
758   QApplication::restoreOverrideCursor();
759 }
760
761 bool SalomeApp_Application::useStudy(const QString& theName)
762 {
763   createEmptyStudy();
764   SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(activeStudy());
765   bool res = false;
766   if (aStudy)
767     res = aStudy->loadDocument( theName );
768   updateDesktopTitle();
769   updateCommandsStatus();
770   return res;
771 }
772
773 /*!Set active study.
774  *\param study - SUIT_Study.
775  */
776 void SalomeApp_Application::setActiveStudy( SUIT_Study* study )
777 {
778   CAM_Application::setActiveStudy( study );
779
780   activateWindows();
781 }
782
783 //=======================================================================
784 // name    : createNewStudy
785 /*! Purpose : Create new study*/
786 //=======================================================================
787 SUIT_Study* SalomeApp_Application::createNewStudy()
788 {
789   SalomeApp_Study* aStudy = new SalomeApp_Study( this );
790
791   // Set up processing of major study-related events
792   connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
793   connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
794   connect( aStudy, SIGNAL( saved  ( SUIT_Study* ) ), this, SLOT( onStudySaved  ( SUIT_Study* ) ) );
795   connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
796
797   return aStudy;
798 }
799
800 //=======================================================================
801 // name    : createNewStudy
802 /*! Purpose : Enable/Disable menu items and toolbar buttons. Rebuild menu*/
803 //=======================================================================
804 void SalomeApp_Application::updateCommandsStatus()
805 {
806   CAM_Application::updateCommandsStatus();
807
808   for ( int id = NewGLViewId; id <= NewVTKViewId; id++ )
809   {
810     QAction* a = action( id );
811     if ( a )
812       a->setEnabled( activeStudy() );
813   }
814
815   // Dump study menu
816   QAction* a = action( DumpStudyId );
817   if ( a )
818     a->setEnabled( activeStudy() );
819
820   // Load script menu
821   a = action( LoadScriptId );
822   if ( a )
823     a->setEnabled( activeStudy() );
824
825   a = action( PropertiesId );
826   if( a )
827     a->setEnabled( activeStudy() );
828
829   a = action(EditCopyId);
830   a->setEnabled(false);
831   a = action(EditPasteId);
832   a->setEnabled(false);
833 }
834
835 //=======================================================================
836 // name    : onHelpAbout
837 /*! Purpose : SLOT. Display "About" message box*/
838 //=======================================================================
839 void SalomeApp_Application::onHelpAbout()
840 {
841   SalomeApp_AboutDlg* dlg = new SalomeApp_AboutDlg( applicationName(), applicationVersion(), desktop() );
842   dlg->exec();
843   delete dlg;
844 }
845
846 QWidget* SalomeApp_Application::window( const int flag, const int studyId ) const
847 {
848   QWidget* wid = 0;
849
850   int sId = studyId;
851   if ( sId < 0 )
852   {
853     if ( !activeStudy() )
854       return 0;
855     else
856       sId = activeStudy()->id();
857   }
858
859   if ( myWindows.contains( flag ) )
860     wid = myWindows[flag]->widget( sId );
861
862   return wid;
863 }
864
865 /*!Adds window to application.
866  *\param wid - QWidget
867  *\param flag - key wor window
868  *\param studyId - study id
869  * Flag used how identificator of window in windows list.
870  */
871 void SalomeApp_Application::addWindow( QWidget* wid, const int flag, const int studyId )
872 {
873   if ( !wid )
874     return;
875
876   int sId = studyId;
877   if ( sId < 0 )
878   {
879     if ( !activeStudy() )
880       return;
881     else
882       sId = activeStudy()->id();
883   }
884
885   if ( !myWindows.contains( flag ) )
886   {
887     QMap<int, int> winMap;
888     currentWindows( winMap );
889
890     myWindows.insert( flag, new SalomeApp_WidgetContainer( flag, desktop() ) );
891     if ( winMap.contains( flag ) )
892       desktop()->moveDockWindow( myWindows[flag], (Dock)winMap[flag] );
893
894     myWindows[flag]->setResizeEnabled( true );
895     myWindows[flag]->setCloseMode( QDockWindow::Always );
896     myWindows[flag]->setName( QString( "dock_window_%1" ).arg( flag ) );
897   }
898
899   QFont f;
900   if( wid->inherits( "PythonConsole" ) )
901     f = ( ( PythonConsole* )wid )->font();
902   else
903     f = wid->font();
904
905   myWindows[flag]->insert( sId, wid );
906   wid->setFont( f );
907
908   setWindowShown( flag, !myWindows[flag]->isEmpty() );
909 }
910
911 /*!Remove window from application.
912  *\param flag - key wor window
913  *\param studyId - study id
914  * Flag used how identificator of window in windows list.
915  */
916 void SalomeApp_Application::removeWindow( const int flag, const int studyId )
917 {
918   if ( !myWindows.contains( flag ) )
919     return;
920
921   int sId = studyId;
922   if ( sId < 0 )
923   {
924     if ( !activeStudy() )
925       return;
926     else
927       sId = activeStudy()->id();
928   }
929
930   QWidget* wid = myWindows[flag]->widget( sId );
931   myWindows[flag]->remove( sId );
932   delete wid;
933
934   setWindowShown( flag, !myWindows[flag]->isEmpty() );
935 }
936
937 /*!Gets window.
938  *\param flag - key wor window
939  *\param studyId - study id
940  * Flag used how identificator of window in windows list.
941  */
942 QWidget* SalomeApp_Application::getWindow( const int flag, const int studyId )
943 {
944   QWidget* wid = window( flag, studyId );
945   if ( !wid )
946     addWindow( wid = createWindow( flag ), flag, studyId );
947
948   return wid;
949 }
950
951 /*!Check is window visible?(with identificator \a type)*/
952 bool SalomeApp_Application::isWindowVisible( const int type ) const
953 {
954   bool res = false;
955   if ( myWindows.contains( type ) )
956   {
957     SUIT_Desktop* desk = ((SalomeApp_Application*)this)->desktop();
958     res = desk && desk->appropriate( myWindows[type] );
959   }
960   return res;
961 }
962
963 /*!Sets window show or hide.
964  *\param type - window identificator.
965  *\param on   - true/false (window show/hide)
966  */
967 void SalomeApp_Application::setWindowShown( const int type, const bool on )
968 {
969   if ( !desktop() || !myWindows.contains( type ) )
970     return;
971
972   QDockWindow* dw = myWindows[type];
973   desktop()->setAppropriate( dw, on );
974   on ? dw->show() : dw->hide();
975 }
976
977 OB_Browser* SalomeApp_Application::objectBrowser()
978 {
979   OB_Browser* ob = 0;
980   QWidget* wid = getWindow( WT_ObjectBrowser );
981   if ( wid->inherits( "OB_Browser" ) )
982     ob = (OB_Browser*)wid;
983   return ob;
984 }
985
986 /*!Gets "LogWindow".*/
987 LogWindow* SalomeApp_Application::logWindow()
988 {
989   LogWindow* lw = 0;
990   QWidget* wid = getWindow( WT_LogWindow );
991   if ( wid->inherits( "LogWindow" ) )
992     lw = (LogWindow*)wid;
993   return lw;
994 }
995
996 /*!Get "PythonConsole"*/
997 PythonConsole* SalomeApp_Application::pythonConsole()
998 {
999   PythonConsole* console = 0;
1000   QWidget* wid = getWindow( WT_PyConsole );
1001   if ( wid->inherits( "PythonConsole" ) )
1002     console = (PythonConsole*)wid;
1003   return console;
1004 }
1005
1006 /*!Gets preferences.*/
1007 SalomeApp_Preferences* SalomeApp_Application::preferences() const
1008 {
1009   return preferences( false );
1010 }
1011
1012 /*!Gets view manager*/
1013 SUIT_ViewManager* SalomeApp_Application::getViewManager( const QString& vmType, const bool create )
1014 {
1015   SUIT_ViewManager* aVM = viewManager( vmType );
1016   SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
1017
1018   if ( anActiveVM && anActiveVM->getType() == vmType )
1019     aVM = anActiveVM;
1020
1021   if ( aVM && create )
1022   {
1023     if ( !aVM->getActiveView() )
1024       aVM->createView();
1025     else
1026       aVM->getActiveView()->setFocus();
1027   }
1028   else if ( create )
1029     aVM = createViewManager( vmType );
1030
1031   return aVM;
1032 }
1033
1034 /*!Create view manager.*/
1035 SUIT_ViewManager* SalomeApp_Application::createViewManager( const QString& vmType )
1036 {
1037   SUIT_ResourceMgr* resMgr = resourceMgr();
1038
1039   SUIT_ViewManager* viewMgr = 0;
1040   if ( vmType == GLViewer_Viewer::Type() )
1041   {
1042     viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() );
1043     new SalomeApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
1044   }
1045   else if ( vmType == Plot2d_Viewer::Type() )
1046   {
1047     viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
1048     viewMgr->setViewModel( new SPlot2d_Viewer() );// custom view model, which extends SALOME_View interface
1049   }
1050   else if ( vmType == OCCViewer_Viewer::Type() )
1051   {
1052     viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
1053     SOCC_Viewer* vm = new SOCC_Viewer();
1054     vm->setBackgroundColor( resMgr->colorValue( "OCCViewer", "background", vm->backgroundColor() ) );
1055     vm->setTrihedronSize( resMgr->integerValue( "OCCViewer", "trihedron_size", vm->trihedronSize() ) );
1056     int u( 1 ), v( 1 );
1057     vm->isos( u, v );
1058     u = resMgr->integerValue( "OCCViewer", "iso_number_u", u );
1059     v = resMgr->integerValue( "OCCViewer", "iso_number_v", v );
1060     vm->setIsos( u, v );
1061     viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1062     new SalomeApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
1063   }
1064   else if ( vmType == SVTK_Viewer::Type() )
1065   {
1066     viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
1067     SVTK_Viewer* vm = (SVTK_Viewer*)viewMgr->getViewModel();
1068     vm->setBackgroundColor( resMgr->colorValue( "VTKViewer", "background", vm->backgroundColor() ) );
1069     vm->setTrihedronSize( resMgr->integerValue( "VTKViewer", "trihedron_size", vm->trihedronSize() ) );
1070     new SalomeApp_VTKSelector((SVTK_Viewer*)viewMgr->getViewModel(),mySelMgr);
1071   }
1072
1073   if ( !viewMgr )
1074     return 0;
1075
1076   addViewManager( viewMgr );
1077   SUIT_ViewWindow* viewWin = viewMgr->createViewWindow();
1078
1079   if ( viewWin && desktop() )
1080     viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1081
1082   connect( viewMgr, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
1083            this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
1084
1085   return viewMgr;
1086 }
1087
1088 void SalomeApp_Application::onCloseView( SUIT_ViewManager* theVM )
1089 {
1090   removeViewManager( theVM );
1091 }
1092
1093 /*!Private SLOT. On study created.*/
1094 void SalomeApp_Application::onStudyCreated( SUIT_Study* theStudy )
1095 {
1096   SUIT_DataObject* aRoot = 0;
1097   if ( theStudy && theStudy->root() )
1098   {
1099     aRoot = theStudy->root();
1100     //aRoot->setName( tr( "DATA_MODELS" ) );
1101   }
1102   if ( objectBrowser() != 0 )
1103     objectBrowser()->setRootObject( aRoot );
1104
1105   activateModule( defaultModule() );
1106
1107   activateWindows();
1108 }
1109
1110 /*!Private SLOT. On study opened.*/
1111 void SalomeApp_Application::onStudyOpened( SUIT_Study* theStudy )
1112 {
1113   SUIT_DataObject* aRoot = 0;
1114   if ( theStudy && theStudy->root() )
1115   {
1116     aRoot = theStudy->root();
1117     //aRoot->dump();
1118   }
1119   if ( objectBrowser() != 0 ) {
1120     objectBrowser()->setRootObject( aRoot );
1121   }
1122
1123   activateModule( defaultModule() );
1124
1125   activateWindows();
1126
1127   emit studyOpened();
1128 }
1129
1130 void SalomeApp_Application::onStudySaved( SUIT_Study* )
1131 {
1132   emit studySaved();
1133 }
1134
1135 /*!Private SLOT. On study closed.*/
1136 void SalomeApp_Application::onStudyClosed( SUIT_Study* )
1137 {
1138   emit studyClosed();
1139
1140   activateModule( "" );
1141
1142   saveWindowsGeometry();
1143 }
1144
1145 /*!Private SLOT. On dump study.*/
1146 void SalomeApp_Application::onDumpStudy( )
1147 {
1148   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
1149   if ( !appStudy ) return;
1150   _PTR(Study) aStudy = appStudy->studyDS();
1151
1152   QStringList aFilters;
1153   aFilters.append( tr( "PYTHON_FILES_FILTER" ) );
1154
1155   SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg( desktop(), false, tr("PUBLISH_IN_STUDY"), true, true);
1156   fd->setCaption( tr( "TOT_DESK_FILE_DUMP_STUDY" ) );
1157   fd->setFilters( aFilters );
1158   fd->SetChecked(true);
1159   fd->exec();
1160   QString aFileName = fd->selectedFile();
1161   bool toPublish = fd->IsChecked();
1162   delete fd;
1163
1164   if(!aFileName.isEmpty()) {
1165     QFileInfo aFileInfo(aFileName);
1166     aStudy->DumpStudy( aFileInfo.dirPath( true ).latin1(), aFileInfo.baseName().latin1(), toPublish );
1167   }
1168 }
1169
1170 /*!Private SLOT. On load script.*/
1171 void SalomeApp_Application::onLoadScript( )
1172 {
1173   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
1174   if ( !appStudy ) return;
1175   _PTR(Study) aStudy = appStudy->studyDS();
1176
1177   if ( aStudy->GetProperties()->IsLocked() ) {
1178     SUIT_MessageBox::warn1 ( desktop(),
1179                              QObject::tr("WRN_WARNING"),
1180                              QObject::tr("WRN_STUDY_LOCKED"),
1181                              QObject::tr("BUT_OK") );
1182     return;
1183   }
1184
1185   QStringList filtersList;
1186   filtersList.append(tr("PYTHON_FILES_FILTER"));
1187   filtersList.append(tr("ALL_FILES_FILTER"));
1188
1189   QString aFile = SUIT_FileDlg::getFileName( desktop(), "", filtersList, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), true, true );
1190
1191   if ( !aFile.isEmpty() )
1192   {
1193     QString command = QString("execfile(\"%1\")").arg(aFile);
1194
1195     PythonConsole* pyConsole = pythonConsole();
1196
1197     if ( pyConsole )
1198       pyConsole->exec( command );
1199   }
1200 }
1201
1202 /*!Private SLOT. On preferences.*/
1203 void SalomeApp_Application::onPreferences()
1204 {
1205   QApplication::setOverrideCursor( Qt::waitCursor );
1206
1207   SalomeApp_PreferencesDlg* prefDlg = new SalomeApp_PreferencesDlg( preferences( true ), desktop());
1208
1209   QApplication::restoreOverrideCursor();
1210
1211   if ( !prefDlg )
1212     return;
1213
1214   prefDlg->exec();
1215
1216   delete prefDlg;
1217 }
1218
1219 /*!Private SLOT. On open document with name \a aName.*/
1220 void SalomeApp_Application::onMRUActivated( QString aName )
1221 {
1222   onOpenDoc( aName );
1223 }
1224
1225 /*!Private SLOT. On preferences changed.*/
1226 void SalomeApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param )
1227 {
1228   SalomeApp_Module* sMod = 0;
1229   CAM_Module* mod = module( modName );
1230   if ( mod && mod->inherits( "SalomeApp_Module" ) )
1231     sMod = (SalomeApp_Module*)mod;
1232
1233   if ( sMod )
1234     sMod->preferencesChanged( section, param );
1235   else
1236     preferencesChanged( section, param );
1237 }
1238
1239 /*!Gets file filter.
1240  *\retval QString "(*.hdf)"
1241  */
1242 QString SalomeApp_Application::getFileFilter() const
1243 {
1244   return "(*.hdf)";
1245 }
1246
1247 /*!Remove all windows from study.*/
1248 void SalomeApp_Application::beforeCloseDoc( SUIT_Study* s )
1249 {
1250   CAM_Application::beforeCloseDoc( s );
1251
1252   for ( WindowMap::ConstIterator itr = myWindows.begin(); s && itr != myWindows.end(); ++itr )
1253     removeWindow( itr.key(), s->id() );
1254 }
1255
1256 /*!Update actions.*/
1257 void SalomeApp_Application::updateActions()
1258 {
1259   updateCommandsStatus();
1260 }
1261
1262 /*!Create window.*/
1263 QWidget* SalomeApp_Application::createWindow( const int flag )
1264 {
1265   QWidget* wid = 0;
1266
1267   SUIT_ResourceMgr* resMgr = resourceMgr();
1268
1269   if ( flag == WT_ObjectBrowser )
1270   {
1271     OB_Browser* ob = new OB_Browser( desktop() );
1272     ob->setAutoUpdate( true );
1273     ob->setAutoOpenLevel( 1 );
1274     ob->setCaption( tr( "OBJECT_BROWSER" ) );
1275     ob->resize( OBJECT_BROWSER_WIDTH, ob->height() );
1276     ob->setFilter( new SalomeApp_OBFilter( selectionMgr() ) );
1277
1278     ob->setNameTitle( tr( "OBJ_BROWSER_NAME" ) );
1279
1280     bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
1281     for ( int i = SalomeApp_DataObject::CT_Value; i <= SalomeApp_DataObject::CT_RefEntry; i++ )
1282     {
1283       ob->addColumn( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i ) ), i );
1284       ob->setColumnShown( i, resMgr->booleanValue( "ObjectBrowser",
1285                                                    QString().sprintf( "visibility_column_%d", i ), true ) );
1286     }
1287     ob->setWidthMode( autoSize ? QListView::Maximum : QListView::Manual );
1288
1289     // Create OBSelector
1290     new SalomeApp_OBSelector( ob, mySelMgr );
1291
1292     wid = ob;
1293
1294     ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1295   }
1296   else if ( flag == WT_PyConsole )
1297   {
1298     PythonConsole* pyCons = new PythonConsole( desktop(), new SalomeApp_PyInterp() );
1299     pyCons->setCaption( tr( "PYTHON_CONSOLE" ) );
1300     pyCons->setFont( resMgr->fontValue( "PyConsole", "font" ) );
1301     wid = pyCons;
1302
1303     //    pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1304   }
1305   else if ( flag == WT_LogWindow )
1306   {
1307     LogWindow* logWin = new LogWindow( desktop() );
1308     logWin->setCaption( tr( "LOG_WINDOW" ) );
1309     wid = logWin;
1310
1311     logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1312   }
1313
1314   return wid;
1315 }
1316
1317 /*!Default windows(Object Browser, Python Console).
1318  * Adds to map \a aMap.
1319  */
1320 void SalomeApp_Application::defaultWindows( QMap<int, int>& aMap ) const
1321 {
1322   aMap.insert( WT_ObjectBrowser, Qt::DockLeft );
1323   aMap.insert( WT_PyConsole, Qt::DockBottom );
1324   //  aMap.insert( WT_LogWindow, Qt::DockBottom );
1325 }
1326
1327 /*!Default view manager.*/
1328 void SalomeApp_Application::defaultViewManagers( QStringList& ) const
1329 {
1330   /*!Do nothing.*/
1331 }
1332
1333 /*!Gets preferences.
1334  * Create preferences, if \a crt = true.
1335  */
1336 SalomeApp_Preferences* SalomeApp_Application::preferences( const bool crt ) const
1337 {
1338   if ( myPrefs )
1339     return myPrefs;
1340
1341   SalomeApp_Application* that = (SalomeApp_Application*)this;
1342
1343   if ( !_prefs_ && crt )
1344   {
1345     _prefs_ = new SalomeApp_Preferences( resourceMgr() );
1346     that->createPreferences( _prefs_ );
1347   }
1348
1349   that->myPrefs = _prefs_;
1350
1351   QPtrList<SUIT_Application> appList = SUIT_Session::session()->applications();
1352   for ( QPtrListIterator<SUIT_Application> appIt ( appList ); appIt.current(); ++appIt )
1353   {
1354     if ( !appIt.current()->inherits( "SalomeApp_Application" ) )
1355       continue;
1356
1357     SalomeApp_Application* app = (SalomeApp_Application*)appIt.current();
1358
1359     QStringList modNameList;
1360     app->modules( modNameList, false );
1361     for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it )
1362     {
1363       int id = _prefs_->addPreference( *it );
1364       _prefs_->setItemProperty( id, "info", tr( "PREFERENCES_NOT_LOADED" ).arg( *it ) );
1365     }
1366
1367     ModuleList modList;
1368     app->modules( modList );
1369     for ( ModuleListIterator itr( modList ); itr.current(); ++itr )
1370     {
1371       SalomeApp_Module* mod = 0;
1372       if ( itr.current()->inherits( "SalomeApp_Module" ) )
1373         mod = (SalomeApp_Module*)itr.current();
1374
1375       if ( mod && !_prefs_->hasModule( mod->moduleName() ) )
1376       {
1377         int modCat = _prefs_->addPreference( mod->moduleName() );
1378         _prefs_->setItemProperty( modCat, "info", QString::null );
1379         mod->createPreferences();
1380       }
1381     }
1382   }
1383
1384   connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
1385            this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ) );
1386
1387   return myPrefs;
1388 }
1389
1390 /*!Add new module to application.*/
1391 void SalomeApp_Application::moduleAdded( CAM_Module* mod )
1392 {
1393   CAM_Application::moduleAdded( mod );
1394
1395   SalomeApp_Module* salomeMod = 0;
1396   if ( mod && mod->inherits( "SalomeApp_Module" ) )
1397     salomeMod = (SalomeApp_Module*)mod;
1398
1399   if ( myPrefs && salomeMod && !myPrefs->hasModule( salomeMod->moduleName() ) )
1400   {
1401     int modCat = myPrefs->addPreference( mod->moduleName() );
1402     myPrefs->setItemProperty( modCat, "info", QString::null );
1403     salomeMod->createPreferences();
1404   }
1405 }
1406
1407 /*!Create preferences.*/
1408 void SalomeApp_Application::createPreferences( SalomeApp_Preferences* pref )
1409 {
1410   if ( !pref )
1411     return;
1412
1413   int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
1414
1415   int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat );
1416   int studyGroup = pref->addPreference( tr( "PREF_GROUP_STUDY" ), genTab );
1417   pref->setItemProperty( studyGroup, "columns", 1 );
1418
1419   pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, SalomeApp_Preferences::Bool, "Study", "multi_file" );
1420   pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, SalomeApp_Preferences::Bool, "Study", "ascii_file" );
1421   int undoPref = pref->addPreference( tr( "PREF_UNDO_LEVEL" ), studyGroup, SalomeApp_Preferences::IntSpin, "Study", "undo_level" );
1422   pref->setItemProperty( undoPref, "min", 1 );
1423   pref->setItemProperty( undoPref, "max", 100 );
1424
1425   int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab );
1426   pref->setItemProperty( extgroup, "columns", 1 );
1427   int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, SalomeApp_Preferences::File, "ExternalBrowser", "application" );
1428   pref->setItemProperty( apppref, "existing", true );
1429   pref->setItemProperty( apppref, "flags", QFileInfo::ExeUser );
1430
1431   pref->addPreference( tr( "PREF_PARAM" ), extgroup, SalomeApp_Preferences::String, "ExternalBrowser", "parameters" );
1432
1433   int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab );
1434   pref->setItemProperty( pythonConsoleGroup, "columns", 1 );
1435   pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, SalomeApp_Preferences::Font, "PyConsole", "font" );
1436
1437
1438
1439   int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
1440   int defCols = pref->addPreference( tr( "PREF_GROUP_DEF_COLUMNS" ), obTab );
1441   for ( int i = SalomeApp_DataObject::CT_Value; i <= SalomeApp_DataObject::CT_RefEntry; i++ )
1442   {
1443     pref->addPreference( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i ) ), defCols,
1444                          SalomeApp_Preferences::Bool, "ObjectBrowser", QString().sprintf( "visibility_column_%d", i ) );
1445   }
1446   pref->setItemProperty( defCols, "columns", 1 );
1447
1448   int objSetGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SETTINGS" ), obTab );
1449   pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, SalomeApp_Preferences::Bool, "ObjectBrowser", "auto_size" );
1450
1451   int viewTab = pref->addPreference( tr( "PREF_TAB_VIEWERS" ), salomeCat );
1452
1453   int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), viewTab );
1454
1455   int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), viewTab );
1456   pref->setItemProperty( occGroup, "columns", 1 );
1457   pref->setItemProperty( vtkGroup, "columns", 1 );
1458
1459   int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occGroup,
1460                                    SalomeApp_Preferences::IntSpin, "OCCViewer", "trihedron_size" );
1461   pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup,
1462                        SalomeApp_Preferences::Color, "OCCViewer", "background" );
1463
1464   pref->setItemProperty( occTS, "min", 1 );
1465   pref->setItemProperty( occTS, "max", 150 );
1466
1467   int isoU = pref->addPreference( tr( "PREF_ISOS_U" ), occGroup,
1468                                   SalomeApp_Preferences::IntSpin, "OCCViewer", "iso_number_u" );
1469   int isoV = pref->addPreference( tr( "PREF_ISOS_V" ), occGroup,
1470                                   SalomeApp_Preferences::IntSpin, "OCCViewer", "iso_number_v" );
1471
1472   pref->setItemProperty( isoU, "min", 0 );
1473   pref->setItemProperty( isoU, "max", 100000 );
1474
1475   pref->setItemProperty( isoV, "min", 0 );
1476   pref->setItemProperty( isoV, "max", 100000 );
1477
1478   int vtkTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), vtkGroup,
1479                                    SalomeApp_Preferences::IntSpin, "VTKViewer", "trihedron_size" );
1480   pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGroup,
1481                        SalomeApp_Preferences::Color, "VTKViewer", "background" );
1482
1483   pref->setItemProperty( vtkTS, "min", 1 );
1484   pref->setItemProperty( vtkTS, "max", 150 );
1485
1486   int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat );
1487   int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab );
1488   pref->setItemProperty( dirGroup, "columns", 1 );
1489   pref->addPreference( tr( "" ), dirGroup,
1490                        SalomeApp_Preferences::DirList, "FileDlg", "QuickDirList" );
1491 }
1492
1493 void SalomeApp_Application::preferencesChanged( const QString& sec, const QString& param )
1494 {
1495   SUIT_ResourceMgr* resMgr = resourceMgr();
1496   if ( !resMgr )
1497     return;
1498
1499   if ( sec == QString( "OCCViewer" ) && param == QString( "trihedron_size" ) )
1500   {
1501     int sz = resMgr->integerValue( sec, param, -1 );
1502     QPtrList<SUIT_ViewManager> lst;
1503     viewManagers( OCCViewer_Viewer::Type(), lst );
1504     for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current() && sz >= 0; ++it )
1505     {
1506       SUIT_ViewModel* vm = it.current()->getViewModel();
1507       if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
1508         continue;
1509
1510       OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
1511       occVM->setTrihedronSize( sz );
1512       occVM->getAISContext()->UpdateCurrentViewer();
1513     }
1514   }
1515
1516   if ( sec == QString( "VTKViewer" ) && param == QString( "trihedron_size" ) )
1517   {
1518     int sz = resMgr->integerValue( sec, param, -1 );
1519     QPtrList<SUIT_ViewManager> lst;
1520     viewManagers( SVTK_Viewer::Type(), lst );
1521     for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current() && sz >= 0; ++it )
1522     {
1523       SUIT_ViewModel* vm = it.current()->getViewModel();
1524       if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
1525         continue;
1526
1527       SVTK_Viewer* vtkVM = (SVTK_Viewer*)vm;
1528       vtkVM->setTrihedronSize( sz );
1529       vtkVM->Repaint();
1530     }
1531   }
1532
1533   if ( sec == QString( "OCCViewer" ) && ( param == QString( "iso_number_u" ) || param == QString( "iso_number_v" ) ) )
1534   {
1535     QPtrList<SUIT_ViewManager> lst;
1536     viewManagers( OCCViewer_Viewer::Type(), lst );
1537     int u = resMgr->integerValue( sec, "iso_number_u" );
1538     int v = resMgr->integerValue( sec, "iso_number_v" );
1539     for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current(); ++it )
1540       ((OCCViewer_Viewer*)it.current())->setIsos( u, v );
1541   }
1542
1543   if( sec=="ObjectBrowser" )
1544   {
1545     if( param=="auto_size" )
1546     {
1547       OB_Browser* ob = objectBrowser();
1548       if( !ob )
1549         return;
1550
1551       bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
1552       ob->setWidthMode( autoSize ? QListView::Maximum : QListView::Manual );
1553
1554       updateObjectBrowser( false );
1555     }
1556   }
1557
1558   if( sec=="PyConsole" )
1559   {
1560     if( param=="font" )
1561       if( pythonConsole() )
1562         pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) );
1563   }
1564 }
1565
1566 /*!Update desktop title.*/
1567 void SalomeApp_Application::updateDesktopTitle() {
1568   QString aTitle = applicationName();
1569   QString aVer = applicationVersion();
1570   if ( !aVer.isEmpty() )
1571     aTitle += QString( " " ) + aVer;
1572
1573   if ( activeStudy() )
1574   {
1575     QString sName = SUIT_Tools::file( activeStudy()->studyName().stripWhiteSpace(), false );
1576     if ( !sName.isEmpty() ) {
1577       SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
1578       _PTR(Study) stdDS = study->studyDS();
1579       if(stdDS) {
1580         if ( stdDS->GetProperties()->IsLocked() ) {
1581           aTitle += QString( " - [%1 (%2)]").arg( sName ).arg( tr( "STUDY_LOCKED" ) );
1582         } else {
1583           aTitle += QString( " - [%1]" ).arg( sName );
1584         }
1585       }
1586     }
1587   }
1588
1589   desktop()->setCaption( aTitle );
1590 }
1591
1592 /*!Update windows after close document.*/
1593 void SalomeApp_Application::afterCloseDoc()
1594 {
1595   updateWindows();
1596
1597   CAM_Application::afterCloseDoc();
1598 }
1599
1600 /*!Gets CORBA::ORB_var*/
1601 CORBA::ORB_var SalomeApp_Application::orb()
1602 {
1603   ORB_INIT& init = *SINGLETON_<ORB_INIT>::Instance();
1604   static CORBA::ORB_var _orb = init( qApp->argc(), qApp->argv() );
1605   return _orb;
1606 }
1607
1608 /*!Create and return SALOMEDS_StudyManager.*/
1609 SALOMEDSClient_StudyManager* SalomeApp_Application::studyMgr()
1610 {
1611   static SALOMEDSClient_StudyManager* _sm = new SALOMEDS_StudyManager();
1612   return _sm;
1613 }
1614
1615 /*!Create and return SALOME_NamingService.*/
1616 SALOME_NamingService* SalomeApp_Application::namingService()
1617 {
1618   static SALOME_NamingService* _ns = new SALOME_NamingService( orb() );
1619   return _ns;
1620 }
1621
1622 /*!Create and return SALOME_LifeCycleCORBA.*/
1623 SALOME_LifeCycleCORBA* SalomeApp_Application::lcc()
1624 {
1625   static SALOME_LifeCycleCORBA* _lcc = new SALOME_LifeCycleCORBA( namingService() );
1626   return _lcc;
1627 }
1628
1629 QString SalomeApp_Application::defaultEngineIOR()
1630 {
1631   /// Look for a default module engine (needed for CORBAless modules to use SALOMEDS persistence)
1632   QString anIOR( "" );
1633   CORBA::Object_ptr anEngine = namingService()->Resolve( "/SalomeAppEngine" );
1634   if ( !CORBA::is_nil( anEngine ) )
1635     anIOR = orb()->object_to_string( anEngine );
1636   return anIOR;
1637 }
1638
1639 /*!Adds icon names for modules.*/
1640 void SalomeApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) const
1641 {
1642   iconMap.clear();
1643
1644   SUIT_ResourceMgr* resMgr = resourceMgr();
1645   if ( !resMgr )
1646     return;
1647
1648   QStringList modList;
1649   modules( modList, false );
1650
1651   for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )
1652   {
1653     QString modName = *it;
1654     QString modIntr = moduleName( modName );
1655     QString modIcon = resMgr->stringValue( modIntr, "icon", QString::null );
1656
1657     if ( modIcon.isEmpty() )
1658       continue;
1659
1660     if ( SUIT_Tools::extension( modIcon ).isEmpty() )
1661       modIcon += QString( ".png" );
1662
1663     iconMap.insert( modName, modIcon );
1664   }
1665 }
1666
1667 /*!Update module action.*/
1668 void SalomeApp_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 SalomeApp_Application::currentWindows( QMap<int, int>& winMap ) const
1682 {
1683   winMap.clear();
1684   if ( !activeStudy() )
1685     return;
1686
1687   if ( activeModule() && activeModule()->inherits( "SalomeApp_Module" ) )
1688     ((SalomeApp_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 SalomeApp_Application::currentViewManagers( QStringList& lst ) const
1697 {
1698   lst.clear();
1699   if ( !activeStudy() )
1700     return;
1701
1702   if ( activeModule() && activeModule()->inherits( "SalomeApp_Module" ) )
1703     ((SalomeApp_Module*)activeModule())->viewManagers( lst );
1704   else
1705     defaultViewManagers( lst );
1706 }
1707
1708 /*!Update windows.*/
1709 void SalomeApp_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 SalomeApp_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 SalomeApp_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 = moduleLibrary( activeModule()->moduleName(), false );
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 SalomeApp_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 = moduleLibrary( activeModule()->moduleName(), false );
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 SalomeApp_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 /*!Private SLOT. On preferences.*/
1792 void SalomeApp_Application::onProperties()
1793 {
1794   SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
1795   if( !study )
1796     return;
1797
1798   _PTR(StudyBuilder) SB = study->studyDS()->NewBuilder();
1799   SB->NewCommand();
1800
1801   SalomeApp_StudyPropertiesDlg aDlg( desktop() );
1802   int res = aDlg.exec();
1803   if( res==QDialog::Accepted && aDlg.isChanged() )
1804     SB->CommitCommand();
1805   else
1806     SB->AbortCommand();
1807
1808   //study->updateCaptions();
1809   updateDesktopTitle();
1810 }
1811
1812 /*!*/
1813 QString SalomeApp_Application::getFileName( bool open, const QString& initial, const QString& filters,
1814                                             const QString& caption, QWidget* parent )
1815 {
1816   if ( !parent )
1817     parent = desktop();
1818   QStringList fls = QStringList::split( ";;", filters, false );
1819   return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
1820 }
1821
1822 /*!*/
1823 QString SalomeApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
1824 {
1825   if ( !parent )
1826     parent = desktop();
1827   return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true );
1828 }
1829
1830 /*!*/
1831 QStringList SalomeApp_Application::getOpenFileNames( const QString& initial, const QString& filters,
1832                                                      const QString& caption, QWidget* parent )
1833 {
1834   if ( !parent )
1835     parent = desktop();
1836   QStringList fls = QStringList::split( ";;", filters, false );
1837   return SUIT_FileDlg::getOpenFileNames( parent, initial, fls, caption, true );
1838 }
1839
1840 /*!*/
1841 void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* thePopup, QString& title )
1842 {
1843   CAM_Application::contextMenuPopup( type, thePopup, title );
1844
1845   OB_Browser* ob = objectBrowser();
1846   if ( !ob || type != ob->popupClientType() )
1847     return;
1848
1849   thePopup->insertSeparator();
1850   thePopup->insertItem( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
1851
1852   // "Activate module" item should appear only if it's necessary
1853   SALOME_ListIO aList;
1854   SalomeApp_SelectionMgr* mgr = selectionMgr();
1855   mgr->selectedObjects(aList);
1856   if (aList.Extent() != 1)
1857     return;
1858   Handle(SALOME_InteractiveObject) aIObj = aList.First();
1859   QString aModuleName(aIObj->getComponentDataType());
1860   QString aModuleTitle = moduleTitle(aModuleName);
1861   CAM_Module* currentModule = activeModule();
1862   if (currentModule && currentModule->moduleName() == aModuleTitle)
1863     return;
1864   thePopup->insertItem( tr( "MEN_OPENWITH" ), this, SLOT( onOpenWith() ) );
1865 }
1866
1867 /*!Update obect browser*/
1868 void SalomeApp_Application::updateObjectBrowser( const bool updateModels )
1869 {
1870   // update existing data models (already loaded SComponents)
1871   if ( updateModels )
1872   {
1873     for ( ModuleListIterator it = modules(); it.current(); ++it )
1874     {
1875       CAM_DataModel* camDM = it.current()->dataModel();
1876       if ( camDM && camDM->inherits( "SalomeApp_DataModel" ) )
1877         ((SalomeApp_DataModel*)camDM)->update();
1878     }
1879   }
1880   // update "non-existing" (not loaded yet) data models
1881   SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
1882   if ( study )
1883   {
1884     _PTR(Study) stdDS = study->studyDS();
1885     if( stdDS )
1886     {
1887       for ( _PTR(SComponentIterator) it ( stdDS->NewComponentIterator() ); it->More(); it->Next() )
1888       {
1889         _PTR(SComponent) aComponent ( it->Value() );
1890
1891         if ( aComponent->ComponentDataType() == "Interface Applicative" )
1892           continue; // skip the magic "Interface Applicative" component
1893
1894         SalomeApp_DataModel::BuildTree( aComponent, study->root(), study, /*skipExisitng=*/true );
1895       }
1896     }
1897   }
1898
1899   if ( objectBrowser() )
1900   {
1901     objectBrowser()->updateGeometry();
1902     objectBrowser()->updateTree();
1903   }
1904 }
1905
1906 /*!Protected SLOT.On desktop activated.*/
1907 void SalomeApp_Application::onDesktopActivated()
1908 {
1909   CAM_Application::onDesktopActivated();
1910   SalomeApp_Module* aModule = dynamic_cast<SalomeApp_Module*>(activeModule());
1911   if(aModule)
1912     aModule->studyActivated();
1913 }
1914
1915 /*!Create empty study.*/
1916 void SalomeApp_Application::createEmptyStudy()
1917 {
1918   CAM_Application::createEmptyStudy();
1919   if ( objectBrowser() )
1920     objectBrowser()->updateTree();
1921 }
1922
1923 /*!Activate module \a mod.*/
1924 bool SalomeApp_Application::activateModule( CAM_Module* mod )
1925 {
1926   bool res = CAM_Application::activateModule( mod );
1927   if ( objectBrowser() )
1928     objectBrowser()->updateTree();
1929   return res;
1930 }
1931
1932 /*!Display Catalog Genenerator dialog */
1933 void SalomeApp_Application::onCatalogGen()
1934 {
1935   ToolsGUI_CatalogGeneratorDlg( desktop() ).exec();
1936 }
1937
1938 /*!Display Registry Display dialog */
1939 void SalomeApp_Application::onRegDisplay()
1940 {
1941   CORBA::ORB_var anOrb = orb();
1942   ToolsGUI_RegWidget* regWnd = ToolsGUI_RegWidget::GetRegWidget( anOrb, desktop(), "Registry" );
1943   regWnd->show();
1944   regWnd->raise();
1945   regWnd->setActiveWindow();
1946 }