1 // File: SalomeApp_Application.cxx
2 // Created: 10/22/2004 3:23:45 PM
3 // Author: Sergey LITONIN
4 // Copyright (C) CEA 2004
6 #include "SalomeApp_PyInterp.h" // WARNING! This include must be the first!
8 #include "SalomeApp_Application.h"
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"
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"
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"
31 #include <LogWindow.h>
33 #include <GLViewer_Viewer.h>
34 #include <GLViewer_ViewManager.h>
36 #include <Plot2d_ViewManager.h>
37 #include <SPlot2d_ViewModel.h>
39 #include <OCCViewer_ViewManager.h>
40 #include <SOCC_ViewModel.h>
42 #include <SVTK_ViewModel.h>
43 #include <SVTK_ViewManager.h>
45 #include <STD_TabDesktop.h>
47 #include "STD_LoadStudiesDlg.h"
49 #include <SUIT_Tools.h>
50 #include <SUIT_Session.h>
52 #include <QtxToolBar.h>
53 #include <QtxMRUAction.h>
54 #include <QtxDockAction.h>
55 #include <QtxResourceEdit.h>
57 #include <OB_Browser.h>
59 #include <PythonConsole_PyConsole.h>
61 #include <SUIT_FileDlg.h>
62 #include <SUIT_MessageBox.h>
63 #include <SUIT_ResourceMgr.h>
64 #include <SUIT_ActionOperation.h>
66 #include <Utils_ORB_INIT.hxx>
67 #include <Utils_SINGLETON.hxx>
68 #include <SALOME_ModuleCatalog_impl.hxx>
69 #include <SALOME_LifeCycleCORBA.hxx>
77 #include <qcombobox.h>
78 #include <qmessagebox.h>
79 #include <qapplication.h>
83 #include "SALOMEDS_StudyManager.hxx"
85 #include "SALOME_ListIteratorOfListIO.hxx"
86 #include "SALOME_ListIO.hxx"
88 #define OBJECT_BROWSER_WIDTH 300
90 static const char* imageEmptyIcon[] = {
93 "....................",
94 "....................",
95 "....................",
96 "....................",
97 "....................",
98 "....................",
99 "....................",
100 "....................",
101 "....................",
102 "....................",
103 "....................",
104 "....................",
105 "....................",
106 "....................",
107 "....................",
108 "....................",
109 "....................",
110 "....................",
111 "....................",
112 "...................."};
114 extern "C" SALOMEAPP_EXPORT SUIT_Application* createApplication()
116 return new SalomeApp_Application();
119 SalomeApp_Preferences* SalomeApp_Application::_prefs_ = 0;
122 Class : SalomeApp_Application
123 Description : Application containing SalomeApp module
126 SalomeApp_Application::SalomeApp_Application()
127 : CAM_Application( false ),
130 STD_TabDesktop* desk = new STD_TabDesktop();
134 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
135 QPixmap aLogo = aResMgr->loadPixmap( "SalomeApp", tr( "APP_DEFAULT_ICO" ), false );
137 desktop()->setIcon( aLogo );
138 desktop()->setDockableMenuBar( true );
139 desktop()->setDockableStatusBar( false );
143 mySelMgr = new SalomeApp_SelectionMgr( this );
145 connect( desk, SIGNAL( closing( SUIT_Desktop*, QCloseEvent* ) ),
146 this, SLOT( onDesktopClosing( SUIT_Desktop*, QCloseEvent* ) ) );
148 connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) );
151 SalomeApp_Application::~SalomeApp_Application()
153 saveWindowsGeometry();
158 desktop()->saveGeometry( resourceMgr(), "desktop" );
159 resourceMgr()->save();
164 SalomeApp_EventFilter::Destroy();
167 void SalomeApp_Application::start()
170 desktop()->loadGeometry( resourceMgr(), "desktop" );
172 CAM_Application::start();
174 QAction* a = action( ViewWindowsId );
175 if ( a && a->inherits( "QtxDockAction" ) )
176 ((QtxDockAction*)a)->setAutoPlace( true );
178 SalomeApp_EventFilter::Init();
181 updateViewManagers();
186 QString SalomeApp_Application::applicationName() const
188 return tr( "APP_NAME" );
191 QString SalomeApp_Application::applicationVersion() const
193 static QString _app_version;
195 if ( _app_version.isEmpty() )
197 QString path( ::getenv( "GUI_ROOT_DIR" ) );
198 if ( !path.isEmpty() )
199 path += QDir::separator();
200 path += QString( "bin/salome/VERSION" );
203 if ( vf.open( IO_ReadOnly ) )
206 vf.readLine( line, 1024 );
209 if ( !line.isEmpty() )
211 while ( !line.isEmpty() && line.at( line.length() - 1 ) == QChar( '\n' ) )
212 line.remove( line.length() - 1, 1 );
214 int idx = line.findRev( ":" );
216 _app_version = line.mid( idx + 1 ).stripWhiteSpace();
224 CAM_Module* SalomeApp_Application::loadModule( const QString& name )
226 CAM_Module* mod = CAM_Application::loadModule( name );
229 connect( this, SIGNAL( studyOpened() ), mod, SLOT( onModelOpened() ) );
230 connect( this, SIGNAL( studySaved() ), mod, SLOT( onModelSaved() ) );
231 connect( this, SIGNAL( studyClosed() ), mod, SLOT( onModelClosed() ) );
236 bool SalomeApp_Application::activateModule( const QString& modName )
239 CAM_Module* prevMod = activeModule();
242 actName = prevMod->moduleName();
244 if ( actName == modName )
247 saveWindowsGeometry();
249 bool status = CAM_Application::activateModule( modName );
251 updateModuleActions();
257 updateViewManagers();
262 SalomeApp_SelectionMgr* SalomeApp_Application::selectionMgr() const
267 void SalomeApp_Application::createActions()
269 STD_Application::createActions();
271 SUIT_Desktop* desk = desktop();
272 SUIT_ResourceMgr* resMgr = resourceMgr();
275 createAction( DumpStudyId, tr( "TOT_DESK_FILE_DUMP_STUDY" ), QIconSet(),
276 tr( "MEN_DESK_FILE_DUMP_STUDY" ), tr( "PRP_DESK_FILE_DUMP_STUDY" ),
277 0, desk, false, this, SLOT( onDumpStudy() ) );
280 createAction( LoadScriptId, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), QIconSet(),
281 tr( "MEN_DESK_FILE_LOAD_SCRIPT" ), tr( "PRP_DESK_FILE_LOAD_SCRIPT" ),
282 0, desk, false, this, SLOT( onLoadScript() ) );
285 createAction( PropertiesId, tr( "TOT_DESK_PROPERTIES" ), QIconSet(),
286 tr( "MEN_DESK_PROPERTIES" ), tr( "PRP_DESK_PROPERTIES" ),
287 0, desk, false, this, SLOT( onProperties() ) );
290 createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIconSet(),
291 tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
292 CTRL+Key_P, desk, false, this, SLOT( onPreferences() ) );
295 QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), desk );
296 connect( mru, SIGNAL( activated( QString ) ), this, SLOT( onMRUActivated( QString ) ) );
297 registerAction( MRUId, mru );
299 // default icon for neutral point ('SALOME' module)
300 QPixmap defIcon = resMgr->loadPixmap( "SalomeApp", tr( "APP_DEFAULT_ICO" ), false );
301 if ( defIcon.isNull() )
302 defIcon = QPixmap( imageEmptyIcon );
304 // default icon for any module
305 QPixmap modIcon = resMgr->loadPixmap( "SalomeApp", tr( "APP_MODULE_ICO" ), false );
306 if ( modIcon.isNull() )
307 modIcon = QPixmap( imageEmptyIcon );
309 QToolBar* modTBar = new QtxToolBar( true, desk );
310 modTBar->setLabel( tr( "INF_TOOLBAR_MODULES" ) );
312 QActionGroup* modGroup = new QActionGroup( this );
313 modGroup->setExclusive( true );
314 modGroup->setUsesDropDown( true );
316 QAction* a = createAction( -1, tr( "APP_NAME" ), defIcon, tr( "APP_NAME" ),
317 tr( "PRP_APP_MODULE" ), 0, desk, true );
319 myActions.insert( QString(), a );
321 QMap<QString, QString> iconMap;
322 moduleIconNames( iconMap );
324 const int iconSize = 20;
326 modGroup->addTo( modTBar );
327 modTBar->addSeparator();
330 modules( modList, false );
332 for ( QStringList::Iterator it = modList.begin(); it != modList.end(); ++it )
334 if ( (*it).isEmpty() )
338 if ( iconMap.contains( *it ) )
339 iconName = iconMap[*it];
341 QString modName = moduleName( *it );
343 QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
347 icon.convertFromImage( icon.convertToImage().smoothScale( iconSize, iconSize, QImage::ScaleMin ) );
349 QAction* a = createAction( -1, *it, icon, *it, tr( "PRP_MODULE" ).arg( *it ), 0, desk, true );
353 myActions.insert( *it, a );
356 SUIT_Tools::simplifySeparators( modTBar );
360 int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, 100 );
361 int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
362 createMenu( separator(), windowMenu, -1, 1 );
364 QMap<int, int> accelMap;
365 accelMap[NewGLViewId] = ALT+Key_G;
366 accelMap[NewPlot2dId] = ALT+Key_P;
367 accelMap[NewOCCViewId] = ALT+Key_O;
368 accelMap[NewVTKViewId] = ALT+Key_K;
370 for ( int id = NewGLViewId; id <= NewVTKViewId; id++ )
372 QAction* a = createAction( id, tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ), QIconSet(),
373 tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ),
374 tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ),
375 accelMap.contains( id ) ? accelMap[id] : 0, desk, false, this, SLOT( onNewWindow() ) );
376 createMenu( a, newWinMenu, -1 );
378 connect( modGroup, SIGNAL( selected( QAction* ) ), this, SLOT( onModuleActivation( QAction* ) ) );
380 int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
382 createMenu( DumpStudyId, fileMenu, 10, -1 );
383 createMenu( separator(), fileMenu, -1, 15, -1 );
384 createMenu( LoadScriptId, fileMenu, 10, -1 );
385 createMenu( separator(), fileMenu, -1, 15, -1 );
386 createMenu( PropertiesId, fileMenu, 10, -1 );
387 createMenu( separator(), fileMenu, -1, 15, -1 );
388 createMenu( PreferencesId, fileMenu, 15, -1 );
389 createMenu( separator(), fileMenu, -1, 15, -1 );
392 createMenu( separator(), fileMenu, -1, 100, -1 );
393 createMenu( MRUId, fileMenu, 100, -1 );
394 createMenu( separator(), fileMenu, -1, 100, -1 );
398 void SalomeApp_Application::onModuleActivation( QAction* a )
403 QString modName = a->menuText();
404 if ( modName == tr( "APP_NAME" ) )
405 modName = QString::null;
407 // Force user to create/open a study before module activation
408 QMap<QString, QString> iconMap;
409 moduleIconNames( iconMap );
410 QPixmap icon = resourceMgr()->loadPixmap( moduleName( modName ), iconMap[ modName ], false );
412 icon = resourceMgr()->loadPixmap( "SalomeApp", tr( "APP_MODULE_BIG_ICO" ), false ); // default icon for any module
414 bool cancelled = false;
415 while ( !modName.isEmpty() && !activeStudy() && !cancelled ){
416 SalomeApp_ModuleDlg aDlg( desktop(), modName, icon );
417 int res = aDlg.exec();
431 putInfo( tr("INF_CANCELLED") );
432 myActions[QString()]->setOn( true );
438 activateModule( modName );
441 QString SalomeApp_Application::defaultModule() const
443 QStringList aModuleNames;
444 modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration
445 // If there's the one and only module --> activate it automatically
446 // TODO: Possible improvement - default module can be taken from preferences
447 return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" );
450 void SalomeApp_Application::onNewWindow()
452 const QObject* obj = sender();
453 if ( !obj || !obj->inherits( "QAction" ) )
457 int id = actionId( (QAction*)obj );
461 type = GLViewer_Viewer::Type();
464 type = Plot2d_Viewer::Type();
467 type = OCCViewer_Viewer::Type();
470 type = VTKViewer_Viewer::Type();
474 if ( !type.isEmpty() )
475 createViewManager( type );
478 //=======================================================================
480 // Purpose : SLOT. Create new document
481 //=======================================================================
482 void SalomeApp_Application::onNewDoc()
484 SUIT_Study* study = activeStudy();
486 saveWindowsGeometry();
488 CAM_Application::onNewDoc();
490 if ( !study ) // new study will be create in THIS application
493 updateViewManagers();
497 //=======================================================================
499 // Purpose : SLOT. Open new document
500 //=======================================================================
501 void SalomeApp_Application::onOpenDoc()
503 SUIT_Study* study = activeStudy();
504 saveWindowsGeometry();
506 CAM_Application::onOpenDoc();
508 if ( !study ) // new study will be create in THIS application
511 updateViewManagers();
515 bool SalomeApp_Application::onOpenDoc( const QString& aName )
517 bool res = CAM_Application::onOpenDoc( aName );
519 QAction* a = action( MRUId );
520 if ( a && a->inherits( "QtxMRUAction" ) )
522 QtxMRUAction* mru = (QtxMRUAction*)a;
524 mru->insert( aName );
526 mru->remove( aName );
531 void SalomeApp_Application::onLoadDoc()
533 QString name, studyname, ext;
535 STD_LoadStudiesDlg aDlg( desktop(), TRUE);
537 std::vector<std::string> List = studyMgr()->GetOpenStudies();
538 for (unsigned int ind = 0; ind < List.size(); ind++) {
539 studyname = List[ind];
540 aDlg.ListComponent->insertItem( studyname );
543 int retVal = aDlg.exec();
544 studyname = aDlg.ListComponent->currentText();
546 if (retVal == QDialog::Rejected)
549 if ( studyname.isNull() || studyname.isEmpty() )
553 name.replace( QRegExp(":"), "/" );
560 bool SalomeApp_Application::onLoadDoc( const QString& aName )
562 bool res = CAM_Application::onLoadDoc( aName );
564 /*jfa tmp:QAction* a = action( MRUId );
565 if ( a && a->inherits( "QtxMRUAction" ) )
567 QtxMRUAction* mru = (QtxMRUAction*)a;
569 mru->insert( aName );
571 mru->remove( aName );
576 void SalomeApp_Application::onSelection()
578 onSelectionChanged();
580 if ( activeModule() && activeModule()->inherits( "SalomeApp_Module" ) )
581 ((SalomeApp_Module*)activeModule())->selectionChanged();
584 void SalomeApp_Application::onCopy()
587 SalomeApp_SelectionMgr* mgr = selectionMgr();
588 mgr->selectedObjects(list);
590 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
591 if(study == NULL) return;
593 _PTR(Study) stdDS = study->studyDS();
596 SALOME_ListIteratorOfListIO it( list );
599 _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
601 studyMgr()->Copy(so);
602 onSelectionChanged();
609 void SalomeApp_Application::onPaste()
612 SalomeApp_SelectionMgr* mgr = selectionMgr();
613 mgr->selectedObjects(list);
615 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
616 if(study == NULL) return;
618 _PTR(Study) stdDS = study->studyDS();
621 SALOME_ListIteratorOfListIO it( list );
624 _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
626 studyMgr()->Paste(so);
627 updateObjectBrowser( true );
628 updateActions(); //SRN: BugID IPAL9377, case 3
635 void SalomeApp_Application::onSelectionChanged()
638 SalomeApp_SelectionMgr* mgr = selectionMgr();
639 mgr->selectedObjects(list);
641 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
642 if(study == NULL) return;
644 _PTR(Study) stdDS = study->studyDS();
649 SALOME_ListIteratorOfListIO it( list );
650 if(it.More() && list.Extent() == 1)
652 _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
654 qaction = action(EditCopyId);
655 if(studyMgr()->CanCopy(so) ) qaction->setEnabled(true);
656 else qaction->setEnabled(false);
658 qaction = action(EditPasteId);
659 if( studyMgr()->CanPaste(so) ) qaction->setEnabled(true);
660 else qaction->setEnabled(false);
663 qaction = action(EditCopyId);
664 qaction->setEnabled(false);
665 qaction = action(EditPasteId);
666 qaction->setEnabled(false);
670 void SalomeApp_Application::onRefresh()
672 updateObjectBrowser( true );
676 void SalomeApp_Application::onOpenWith()
678 QApplication::setOverrideCursor( Qt::waitCursor );
680 SalomeApp_SelectionMgr* mgr = selectionMgr();
681 mgr->selectedObjects(aList);
682 if (aList.Extent() != 1)
684 QApplication::restoreOverrideCursor();
687 Handle(SALOME_InteractiveObject) aIObj = aList.First();
688 QString aModuleName(aIObj->getComponentDataType());
689 QString aModuleTitle = moduleTitle(aModuleName);
690 activateModule(aModuleTitle);
691 QApplication::restoreOverrideCursor();
694 bool SalomeApp_Application::useStudy(const QString& theName)
697 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(activeStudy());
700 res = aStudy->loadDocument( theName );
701 updateDesktopTitle();
702 updateCommandsStatus();
706 void SalomeApp_Application::setActiveStudy( SUIT_Study* study )
708 CAM_Application::setActiveStudy( study );
713 //=======================================================================
714 // name : createNewStudy
715 // Purpose : Create new study
716 //=======================================================================
717 SUIT_Study* SalomeApp_Application::createNewStudy()
719 SalomeApp_Study* aStudy = new SalomeApp_Study( this );
721 // Set up processing of major study-related events
722 connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
723 connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
724 connect( aStudy, SIGNAL( saved ( SUIT_Study* ) ), this, SLOT( onStudySaved ( SUIT_Study* ) ) );
725 connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
730 //=======================================================================
731 // name : createNewStudy
732 // Purpose : Enable/Disable menu items and toolbar buttons. Rebuild menu
733 //=======================================================================
734 void SalomeApp_Application::updateCommandsStatus()
736 CAM_Application::updateCommandsStatus();
738 for ( int id = NewGLViewId; id <= NewVTKViewId; id++ )
740 QAction* a = action( id );
742 a->setEnabled( activeStudy() );
746 QAction* a = action( DumpStudyId );
748 a->setEnabled( activeStudy() );
751 a = action( LoadScriptId );
753 a->setEnabled( activeStudy() );
755 a = action( PropertiesId );
757 a->setEnabled( activeStudy() );
759 a = action(EditCopyId);
760 a->setEnabled(false);
761 a = action(EditPasteId);
762 a->setEnabled(false);
765 //=======================================================================
766 // name : onHelpAbout
767 // Purpose : SLOT. Display "About" message box
768 //=======================================================================
769 void SalomeApp_Application::onHelpAbout()
771 SalomeApp_AboutDlg* dlg = new SalomeApp_AboutDlg( applicationName(), applicationVersion(), desktop() );
776 QWidget* SalomeApp_Application::window( const int flag, const int studyId ) const
783 if ( !activeStudy() )
786 sId = activeStudy()->id();
789 if ( myWindows.contains( flag ) )
790 wid = myWindows[flag]->widget( sId );
795 void SalomeApp_Application::addWindow( QWidget* wid, const int flag, const int studyId )
803 if ( !activeStudy() )
806 sId = activeStudy()->id();
809 if ( !myWindows.contains( flag ) )
811 QMap<int, int> winMap;
812 currentWindows( winMap );
814 myWindows.insert( flag, new SalomeApp_WidgetContainer( flag, desktop() ) );
815 if ( winMap.contains( flag ) )
816 desktop()->moveDockWindow( myWindows[flag], (Dock)winMap[flag] );
818 myWindows[flag]->setResizeEnabled( true );
819 myWindows[flag]->setCloseMode( QDockWindow::Always );
820 myWindows[flag]->setName( QString( "dock_window_%1" ).arg( flag ) );
823 myWindows[flag]->insert( sId, wid );
825 setWindowShown( flag, !myWindows[flag]->isEmpty() );
828 void SalomeApp_Application::removeWindow( const int flag, const int studyId )
830 if ( !myWindows.contains( flag ) )
836 if ( !activeStudy() )
839 sId = activeStudy()->id();
842 QWidget* wid = myWindows[flag]->widget( sId );
843 myWindows[flag]->remove( sId );
846 setWindowShown( flag, !myWindows[flag]->isEmpty() );
849 QWidget* SalomeApp_Application::getWindow( const int flag, const int studyId )
851 QWidget* wid = window( flag, studyId );
853 addWindow( wid = createWindow( flag ), flag, studyId );
858 bool SalomeApp_Application::isWindowVisible( const int type ) const
861 if ( myWindows.contains( type ) )
863 SUIT_Desktop* desk = ((SalomeApp_Application*)this)->desktop();
864 res = desk && desk->appropriate( myWindows[type] );
869 void SalomeApp_Application::setWindowShown( const int type, const bool on )
871 if ( !desktop() || !myWindows.contains( type ) )
874 QDockWindow* dw = myWindows[type];
875 desktop()->setAppropriate( dw, on );
876 on ? dw->show() : dw->hide();
879 OB_Browser* SalomeApp_Application::objectBrowser()
882 QWidget* wid = getWindow( WT_ObjectBrowser );
883 if ( wid->inherits( "OB_Browser" ) )
884 ob = (OB_Browser*)wid;
888 LogWindow* SalomeApp_Application::logWindow()
891 QWidget* wid = getWindow( WT_LogWindow );
892 if ( wid->inherits( "LogWindow" ) )
893 lw = (LogWindow*)wid;
897 PythonConsole* SalomeApp_Application::pythonConsole()
899 PythonConsole* console = 0;
900 QWidget* wid = getWindow( WT_PyConsole );
901 if ( wid->inherits( "PythonConsole" ) )
902 console = (PythonConsole*)wid;
906 SalomeApp_Preferences* SalomeApp_Application::preferences() const
908 return preferences( false );
911 SUIT_ViewManager* SalomeApp_Application::getViewManager( const QString& vmType, const bool create )
913 SUIT_ViewManager* aVM = viewManager( vmType );
914 SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
916 if ( anActiveVM && anActiveVM->getType() == vmType )
921 if ( !aVM->getActiveView() )
924 aVM->getActiveView()->setFocus();
927 aVM = createViewManager( vmType );
932 SUIT_ViewManager* SalomeApp_Application::createViewManager( const QString& vmType )
934 SUIT_ResourceMgr* resMgr = resourceMgr();
936 SUIT_ViewManager* viewMgr = 0;
937 if ( vmType == GLViewer_Viewer::Type() )
939 viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() );
940 new SalomeApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
942 else if ( vmType == Plot2d_Viewer::Type() )
944 viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
945 viewMgr->setViewModel( new SPlot2d_Viewer() );// custom view model, which extends SALOME_View interface
947 else if ( vmType == OCCViewer_Viewer::Type() )
949 viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
950 SOCC_Viewer* vm = new SOCC_Viewer();
951 vm->setBackgroundColor( resMgr->colorValue( "OCCViewer", "background", vm->backgroundColor() ) );
952 vm->setTrihedronSize( resMgr->integerValue( "OCCViewer", "trihedron_size", vm->trihedronSize() ) );
955 u = resMgr->integerValue( "OCCViewer", "iso_number_u", u );
956 v = resMgr->integerValue( "OCCViewer", "iso_number_v", v );
958 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
959 new SalomeApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
961 else if ( vmType == SVTK_Viewer::Type() )
963 viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
964 SVTK_Viewer* vm = (SVTK_Viewer*)viewMgr->getViewModel();
965 vm->setBackgroundColor( resMgr->colorValue( "VTKViewer", "background", vm->backgroundColor() ) );
966 vm->setTrihedronSize( resMgr->integerValue( "VTKViewer", "trihedron_size", vm->trihedronSize() ) );
967 new SalomeApp_VTKSelector((SVTK_Viewer*)viewMgr->getViewModel(),mySelMgr);
973 addViewManager( viewMgr );
974 SUIT_ViewWindow* viewWin = viewMgr->createViewWindow();
976 if ( viewWin && desktop() )
977 viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
979 connect( viewMgr, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
980 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
985 void SalomeApp_Application::onCloseView( SUIT_ViewManager* theVM )
987 removeViewManager( theVM );
990 void SalomeApp_Application::onStudyCreated( SUIT_Study* theStudy )
992 SUIT_DataObject* aRoot = 0;
993 if ( theStudy && theStudy->root() )
995 aRoot = theStudy->root();
996 //aRoot->setName( tr( "DATA_MODELS" ) );
998 if ( objectBrowser() != 0 )
999 objectBrowser()->setRootObject( aRoot );
1001 activateModule( defaultModule() );
1006 void SalomeApp_Application::onStudyOpened( SUIT_Study* theStudy )
1008 SUIT_DataObject* aRoot = 0;
1009 if ( theStudy && theStudy->root() )
1011 aRoot = theStudy->root();
1014 if ( objectBrowser() != 0 ) {
1015 objectBrowser()->setRootObject( aRoot );
1018 activateModule( defaultModule() );
1025 void SalomeApp_Application::onStudySaved( SUIT_Study* )
1030 void SalomeApp_Application::onStudyClosed( SUIT_Study* )
1034 activateModule( "" );
1036 saveWindowsGeometry();
1039 void SalomeApp_Application::onDumpStudy( )
1041 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
1042 if ( !appStudy ) return;
1043 _PTR(Study) aStudy = appStudy->studyDS();
1045 QStringList aFilters;
1046 aFilters.append( tr( "PYTHON_FILES_FILTER" ) );
1048 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg( desktop(), false, tr("PUBLISH_IN_STUDY"), true, true);
1049 fd->setCaption( tr( "TOT_DESK_FILE_DUMP_STUDY" ) );
1050 fd->setFilters( aFilters );
1051 fd->SetChecked(true);
1053 QString aFileName = fd->selectedFile();
1054 bool toPublish = fd->IsChecked();
1057 if(!aFileName.isEmpty()) {
1058 QFileInfo aFileInfo(aFileName);
1059 aStudy->DumpStudy( aFileInfo.dirPath( true ).latin1(), aFileInfo.baseName().latin1(), toPublish );
1063 void SalomeApp_Application::onLoadScript( )
1065 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
1066 if ( !appStudy ) return;
1067 _PTR(Study) aStudy = appStudy->studyDS();
1069 if ( aStudy->GetProperties()->IsLocked() ) {
1070 SUIT_MessageBox::warn1 ( desktop(),
1071 QObject::tr("WRN_WARNING"),
1072 QObject::tr("WRN_STUDY_LOCKED"),
1073 QObject::tr("BUT_OK") );
1077 QStringList filtersList;
1078 filtersList.append(tr("PYTHON_FILES_FILTER"));
1079 filtersList.append(tr("ALL_FILES_FILTER"));
1081 QString aFile = SUIT_FileDlg::getFileName( desktop(), "", filtersList, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), true, true );
1083 if ( !aFile.isEmpty() )
1085 QString command = QString("execfile(\"%1\")").arg(aFile);
1087 PythonConsole* pyConsole = pythonConsole();
1090 pyConsole->exec( command );
1094 void SalomeApp_Application::onPreferences()
1096 QApplication::setOverrideCursor( Qt::waitCursor );
1098 SalomeApp_PreferencesDlg* prefDlg = new SalomeApp_PreferencesDlg( preferences( true ), desktop());
1100 QApplication::restoreOverrideCursor();
1110 void SalomeApp_Application::onMRUActivated( QString aName )
1115 void SalomeApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param )
1117 SalomeApp_Module* sMod = 0;
1118 CAM_Module* mod = module( modName );
1119 if ( mod && mod->inherits( "SalomeApp_Module" ) )
1120 sMod = (SalomeApp_Module*)mod;
1123 sMod->preferencesChanged( section, param );
1125 preferencesChanged( section, param );
1128 QString SalomeApp_Application::getFileFilter() const
1133 void SalomeApp_Application::beforeCloseDoc( SUIT_Study* s )
1135 CAM_Application::beforeCloseDoc( s );
1137 for ( WindowMap::ConstIterator itr = myWindows.begin(); s && itr != myWindows.end(); ++itr )
1138 removeWindow( itr.key(), s->id() );
1141 void SalomeApp_Application::updateActions()
1143 updateCommandsStatus();
1146 QWidget* SalomeApp_Application::createWindow( const int flag )
1150 SUIT_ResourceMgr* resMgr = resourceMgr();
1152 if ( flag == WT_ObjectBrowser )
1154 OB_Browser* ob = new OB_Browser( desktop() );
1155 ob->setAutoUpdate( true );
1156 ob->setAutoOpenLevel( 1 );
1157 ob->setCaption( tr( "OBJECT_BROWSER" ) );
1158 ob->resize( OBJECT_BROWSER_WIDTH, ob->height() );
1159 ob->setFilter( new SalomeApp_OBFilter( selectionMgr() ) );
1161 ob->setNameTitle( tr( "OBJ_BROWSER_NAME" ) );
1163 for ( int i = SalomeApp_DataObject::CT_Value; i <= SalomeApp_DataObject::CT_RefEntry; i++ )
1165 ob->addColumn( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i ) ), i );
1166 ob->setColumnShown( i, resMgr->booleanValue( "ObjectBrowser",
1167 QString().sprintf( "visibility_column_%d", i ), true ) );
1170 // Create OBSelector
1171 new SalomeApp_OBSelector( ob, mySelMgr );
1175 ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1177 else if ( flag == WT_PyConsole )
1179 PythonConsole* pyCons = new PythonConsole( desktop(), new SalomeApp_PyInterp() );
1180 pyCons->setCaption( tr( "PYTHON_CONSOLE" ) );
1183 // pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1185 else if ( flag == WT_LogWindow )
1187 LogWindow* logWin = new LogWindow( desktop() );
1188 logWin->setCaption( tr( "LOG_WINDOW" ) );
1191 logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1197 void SalomeApp_Application::defaultWindows( QMap<int, int>& aMap ) const
1199 aMap.insert( WT_ObjectBrowser, Qt::DockLeft );
1200 aMap.insert( WT_PyConsole, Qt::DockBottom );
1201 // aMap.insert( WT_LogWindow, Qt::DockBottom );
1204 void SalomeApp_Application::defaultViewManagers( QStringList& ) const
1208 SalomeApp_Preferences* SalomeApp_Application::preferences( const bool crt ) const
1213 SalomeApp_Application* that = (SalomeApp_Application*)this;
1215 if ( !_prefs_ && crt )
1217 _prefs_ = new SalomeApp_Preferences( resourceMgr() );
1218 that->createPreferences( _prefs_ );
1221 that->myPrefs = _prefs_;
1223 QPtrList<SUIT_Application> appList = SUIT_Session::session()->applications();
1224 for ( QPtrListIterator<SUIT_Application> appIt ( appList ); appIt.current(); ++appIt )
1226 if ( !appIt.current()->inherits( "SalomeApp_Application" ) )
1229 SalomeApp_Application* app = (SalomeApp_Application*)appIt.current();
1231 QStringList modNameList;
1232 app->modules( modNameList, false );
1233 for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it )
1235 int id = _prefs_->addPreference( *it );
1236 _prefs_->setProperty( id, "info", tr( "PREFERENCES_NOT_LOADED" ).arg( *it ) );
1240 app->modules( modList );
1241 for ( ModuleListIterator itr( modList ); itr.current(); ++itr )
1243 SalomeApp_Module* mod = 0;
1244 if ( itr.current()->inherits( "SalomeApp_Module" ) )
1245 mod = (SalomeApp_Module*)itr.current();
1247 if ( mod && !_prefs_->hasModule( mod->moduleName() ) )
1248 mod->createPreferences();
1252 connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
1253 this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ) );
1258 void SalomeApp_Application::moduleAdded( CAM_Module* mod )
1260 CAM_Application::moduleAdded( mod );
1262 SalomeApp_Module* salomeMod = 0;
1263 if ( mod && mod->inherits( "SalomeApp_Module" ) )
1264 salomeMod = (SalomeApp_Module*)mod;
1266 if ( myPrefs && salomeMod && !myPrefs->hasModule( salomeMod->moduleName() ))
1267 salomeMod->createPreferences();
1270 void SalomeApp_Application::createPreferences( SalomeApp_Preferences* pref )
1275 int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
1277 int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat );
1279 int obGroup = pref->addPreference( tr( "PREF_GROUP_OBJBROWSER" ), genTab );
1280 for ( int i = SalomeApp_DataObject::CT_Value; i <= SalomeApp_DataObject::CT_RefEntry; i++ )
1282 pref->addPreference( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i ) ), obGroup,
1283 SalomeApp_Preferences::Bool, "ObjectBrowser", QString().sprintf( "visibility_column_%d", i ) );
1285 pref->setProperty( obGroup, "columns", 1 );
1287 int viewTab = pref->addPreference( tr( "PREF_TAB_VIEWERS" ), salomeCat );
1289 int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), viewTab );
1291 int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), viewTab );
1292 pref->setProperty( occGroup, "columns", 1 );
1293 pref->setProperty( vtkGroup, "columns", 1 );
1295 int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occGroup,
1296 SalomeApp_Preferences::IntSpin, "OCCViewer", "trihedron_size" );
1297 pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup,
1298 SalomeApp_Preferences::Color, "OCCViewer", "background" );
1300 pref->setProperty( occTS, "min", 1 );
1301 pref->setProperty( occTS, "max", 150 );
1303 int isoU = pref->addPreference( tr( "PREF_ISOS_U" ), occGroup,
1304 SalomeApp_Preferences::IntSpin, "OCCViewer", "iso_number_u" );
1305 int isoV = pref->addPreference( tr( "PREF_ISOS_V" ), occGroup,
1306 SalomeApp_Preferences::IntSpin, "OCCViewer", "iso_number_v" );
1308 pref->setProperty( isoU, "min", 0 );
1309 pref->setProperty( isoU, "max", 100000 );
1311 pref->setProperty( isoV, "min", 0 );
1312 pref->setProperty( isoV, "max", 100000 );
1314 int vtkTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), vtkGroup,
1315 SalomeApp_Preferences::IntSpin, "VTKViewer", "trihedron_size" );
1316 pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGroup,
1317 SalomeApp_Preferences::Color, "VTKViewer", "background" );
1319 pref->setProperty( vtkTS, "min", 1 );
1320 pref->setProperty( vtkTS, "max", 150 );
1323 void SalomeApp_Application::preferencesChanged( const QString& sec, const QString& param )
1325 SUIT_ResourceMgr* resMgr = resourceMgr();
1329 if ( sec == QString( "OCCViewer" ) && param == QString( "trihedron_size" ) )
1331 int sz = resMgr->integerValue( sec, param, -1 );
1332 QPtrList<SUIT_ViewManager> lst;
1333 viewManagers( OCCViewer_Viewer::Type(), lst );
1334 for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current() && sz >= 0; ++it )
1336 SUIT_ViewModel* vm = it.current()->getViewModel();
1337 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
1340 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
1341 occVM->setTrihedronSize( sz );
1342 occVM->getAISContext()->UpdateCurrentViewer();
1346 if ( sec == QString( "VTKViewer" ) && param == QString( "trihedron_size" ) )
1348 int sz = resMgr->integerValue( sec, param, -1 );
1349 QPtrList<SUIT_ViewManager> lst;
1350 viewManagers( SVTK_Viewer::Type(), lst );
1351 for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current() && sz >= 0; ++it )
1353 SUIT_ViewModel* vm = it.current()->getViewModel();
1354 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
1357 SVTK_Viewer* vtkVM = (SVTK_Viewer*)vm;
1358 vtkVM->setTrihedronSize( sz );
1363 if ( sec == QString( "OCCViewer" ) && ( param == QString( "iso_number_u" ) || param == QString( "iso_number_v" ) ) )
1365 QPtrList<SUIT_ViewManager> lst;
1366 viewManagers( OCCViewer_Viewer::Type(), lst );
1367 int u = resMgr->integerValue( sec, "iso_number_u" );
1368 int v = resMgr->integerValue( sec, "iso_number_v" );
1369 for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current(); ++it )
1370 ((OCCViewer_Viewer*)it.current())->setIsos( u, v );
1375 void SalomeApp_Application::updateDesktopTitle() {
1376 QString aTitle = applicationName();
1377 QString aVer = applicationVersion();
1378 if ( !aVer.isEmpty() )
1379 aTitle += QString( " " ) + aVer;
1381 if ( activeStudy() )
1383 QString sName = SUIT_Tools::file( activeStudy()->studyName().stripWhiteSpace(), false );
1384 if ( !sName.isEmpty() ) {
1385 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
1386 _PTR(Study) stdDS = study->studyDS();
1388 if ( stdDS->GetProperties()->IsLocked() ) {
1389 aTitle += QString( " - [%1 (%2)]").arg( sName ).arg( tr( "STUDY_LOCKED" ) );
1391 aTitle += QString( " - [%1]" ).arg( sName );
1397 desktop()->setCaption( aTitle );
1400 void SalomeApp_Application::afterCloseDoc()
1404 CAM_Application::afterCloseDoc();
1407 CORBA::ORB_var SalomeApp_Application::orb()
1409 ORB_INIT& init = *SINGLETON_<ORB_INIT>::Instance();
1410 static CORBA::ORB_var _orb = init( qApp->argc(), qApp->argv() );
1414 SALOMEDSClient_StudyManager* SalomeApp_Application::studyMgr()
1416 static SALOMEDSClient_StudyManager* _sm = new SALOMEDS_StudyManager();
1420 SALOME_NamingService* SalomeApp_Application::namingService()
1422 static SALOME_NamingService* _ns = new SALOME_NamingService( orb() );
1426 SALOME_LifeCycleCORBA* SalomeApp_Application::lcc()
1428 static SALOME_LifeCycleCORBA* _lcc = new SALOME_LifeCycleCORBA( namingService() );
1432 QString SalomeApp_Application::defaultEngineIOR()
1434 // Look for a default module engine (needed for CORBAless modules to use SALOMEDS persistence)
1435 QString anIOR( "" );
1436 CORBA::Object_ptr anEngine = namingService()->Resolve( "/SalomeAppEngine" );
1437 if ( !CORBA::is_nil( anEngine ) )
1438 anIOR = orb()->object_to_string( anEngine );
1442 void SalomeApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) const
1446 SUIT_ResourceMgr* resMgr = resourceMgr();
1450 QStringList modList;
1451 modules( modList, false );
1453 for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )
1455 QString modName = *it;
1456 QString modIntr = moduleName( modName );
1457 QString modIcon = resMgr->stringValue( modIntr, "icon", QString::null );
1459 if ( modIcon.isEmpty() )
1462 if ( SUIT_Tools::extension( modIcon ).isEmpty() )
1463 modIcon += QString( ".png" );
1465 iconMap.insert( modName, modIcon );
1469 void SalomeApp_Application::updateModuleActions()
1472 if ( activeModule() )
1473 modName = activeModule()->moduleName();
1475 if ( myActions.contains( modName ) )
1476 myActions[modName]->setOn( true );
1479 void SalomeApp_Application::currentWindows( QMap<int, int>& winMap ) const
1482 if ( !activeStudy() )
1485 if ( activeModule() && activeModule()->inherits( "SalomeApp_Module" ) )
1486 ((SalomeApp_Module*)activeModule())->windows( winMap );
1488 defaultWindows( winMap );
1491 void SalomeApp_Application::currentViewManagers( QStringList& lst ) const
1494 if ( !activeStudy() )
1497 if ( activeModule() && activeModule()->inherits( "SalomeApp_Module" ) )
1498 ((SalomeApp_Module*)activeModule())->viewManagers( lst );
1500 defaultViewManagers( lst );
1503 void SalomeApp_Application::updateWindows()
1505 QMap<int, int> winMap;
1506 currentWindows( winMap );
1508 for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
1509 getWindow( it.key() );
1511 loadWindowsGeometry();
1513 for ( WindowMap::ConstIterator itr = myWindows.begin(); itr != myWindows.end(); ++itr )
1514 setWindowShown( itr.key(), !itr.data()->isEmpty() && winMap.contains( itr.key() ) );
1517 void SalomeApp_Application::updateViewManagers()
1520 currentViewManagers( lst );
1522 for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
1523 getViewManager( *it, true );
1526 void SalomeApp_Application::loadWindowsGeometry()
1528 QtxDockAction* dockMgr = 0;
1530 QAction* a = action( ViewWindowsId );
1531 if ( a && a->inherits( "QtxDockAction" ) )
1532 dockMgr = (QtxDockAction*)a;
1538 if ( activeModule() )
1539 modName = moduleLibrary( activeModule()->moduleName(), false );
1541 QString section = QString( "windows_geometry" );
1542 if ( !modName.isEmpty() )
1543 section += QString( "." ) + modName;
1545 dockMgr->loadGeometry( resourceMgr(), section, false );
1546 dockMgr->restoreGeometry();
1549 void SalomeApp_Application::saveWindowsGeometry()
1551 QtxDockAction* dockMgr = 0;
1553 QAction* a = action( ViewWindowsId );
1554 if ( a && a->inherits( "QtxDockAction" ) )
1555 dockMgr = (QtxDockAction*)a;
1561 if ( activeModule() )
1562 modName = moduleLibrary( activeModule()->moduleName(), false );
1564 QString section = QString( "windows_geometry" );
1565 if ( !modName.isEmpty() )
1566 section += QString( "." ) + modName;
1568 dockMgr->storeGeometry();
1569 dockMgr->saveGeometry( resourceMgr(), section, false );
1572 void SalomeApp_Application::activateWindows()
1574 if ( activeStudy() )
1576 for ( WindowMap::Iterator itr = myWindows.begin(); itr != myWindows.end(); ++itr )
1577 itr.data()->activate( activeStudy()->id() );
1581 void SalomeApp_Application::onProperties()
1583 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
1587 _PTR(StudyBuilder) SB = study->studyDS()->NewBuilder();
1590 SalomeApp_StudyPropertiesDlg aDlg( desktop() );
1591 int res = aDlg.exec();
1592 if( res==QDialog::Accepted && aDlg.isChanged() )
1593 SB->CommitCommand();
1597 //study->updateCaptions();
1598 updateDesktopTitle();
1601 QString SalomeApp_Application::getFileName( bool open, const QString& initial, const QString& filters,
1602 const QString& caption, QWidget* parent )
1606 QStringList fls = QStringList::split( ";;", filters, false );
1607 return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
1610 QString SalomeApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
1614 return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true );
1617 QStringList SalomeApp_Application::getOpenFileNames( const QString& initial, const QString& filters,
1618 const QString& caption, QWidget* parent )
1622 QStringList fls = QStringList::split( ";;", filters, false );
1623 return SUIT_FileDlg::getOpenFileNames( parent, initial, fls, caption, true );
1626 void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* thePopup, QString& title )
1628 CAM_Application::contextMenuPopup( type, thePopup, title );
1629 thePopup->insertSeparator();
1630 thePopup->insertItem( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
1632 // "Activate module" item should appear only if it's necessary
1633 OB_Browser* ob = objectBrowser();
1634 if ( !ob || type != ob->popupClientType() )
1636 SALOME_ListIO aList;
1637 SalomeApp_SelectionMgr* mgr = selectionMgr();
1638 mgr->selectedObjects(aList);
1639 if (aList.Extent() != 1)
1641 Handle(SALOME_InteractiveObject) aIObj = aList.First();
1642 QString aModuleName(aIObj->getComponentDataType());
1643 QString aModuleTitle = moduleTitle(aModuleName);
1644 CAM_Module* currentModule = activeModule();
1645 if (currentModule && currentModule->moduleName() == aModuleTitle)
1647 thePopup->insertItem( tr( "MEN_OPENWITH" ), this, SLOT( onOpenWith() ) );
1650 void SalomeApp_Application::updateObjectBrowser( const bool updateModels )
1652 // update existing data models (already loaded SComponents)
1655 for ( ModuleListIterator it = modules(); it.current(); ++it )
1657 CAM_DataModel* camDM = it.current()->dataModel();
1658 if ( camDM && camDM->inherits( "SalomeApp_DataModel" ) )
1659 ((SalomeApp_DataModel*)camDM)->update();
1662 // update "non-existing" (not loaded yet) data models
1663 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
1666 _PTR(Study) stdDS = study->studyDS();
1669 for ( _PTR(SComponentIterator) it ( stdDS->NewComponentIterator() ); it->More(); it->Next() )
1671 _PTR(SComponent) aComponent ( it->Value() );
1673 if ( aComponent->ComponentDataType() == "Interface Applicative" )
1674 continue; // skip the magic "Interface Applicative" component
1676 SalomeApp_DataModel::BuildTree( aComponent, study->root(), study, /*skipExisitng=*/true );
1681 if ( objectBrowser() )
1682 objectBrowser()->updateTree();
1686 //************************************************************
1687 void SalomeApp_Application::onDesktopActivated()
1689 CAM_Application::onDesktopActivated();
1690 SalomeApp_Module* aModule = dynamic_cast<SalomeApp_Module*>(activeModule());
1692 aModule->studyActivated();
1695 void SalomeApp_Application::createEmptyStudy()
1697 CAM_Application::createEmptyStudy();
1698 if ( objectBrowser() )
1699 objectBrowser()->updateTree();
1702 bool SalomeApp_Application::activateModule( CAM_Module* mod )
1704 CAM_Application::activateModule( mod );
1705 if ( objectBrowser() )
1706 objectBrowser()->updateTree();