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(":"), "/" );
555 if(onLoadDoc(name)) {
557 updateViewManagers();
563 bool SalomeApp_Application::onLoadDoc( const QString& aName )
565 bool res = CAM_Application::onLoadDoc( aName );
567 /*jfa tmp:QAction* a = action( MRUId );
568 if ( a && a->inherits( "QtxMRUAction" ) )
570 QtxMRUAction* mru = (QtxMRUAction*)a;
572 mru->insert( aName );
574 mru->remove( aName );
579 void SalomeApp_Application::onSelection()
581 onSelectionChanged();
583 if ( activeModule() && activeModule()->inherits( "SalomeApp_Module" ) )
584 ((SalomeApp_Module*)activeModule())->selectionChanged();
587 void SalomeApp_Application::onCopy()
590 SalomeApp_SelectionMgr* mgr = selectionMgr();
591 mgr->selectedObjects(list);
593 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
594 if(study == NULL) return;
596 _PTR(Study) stdDS = study->studyDS();
599 SALOME_ListIteratorOfListIO it( list );
602 _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
604 studyMgr()->Copy(so);
605 onSelectionChanged();
612 void SalomeApp_Application::onPaste()
615 SalomeApp_SelectionMgr* mgr = selectionMgr();
616 mgr->selectedObjects(list);
618 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
619 if(study == NULL) return;
621 _PTR(Study) stdDS = study->studyDS();
624 SALOME_ListIteratorOfListIO it( list );
627 _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
629 studyMgr()->Paste(so);
630 updateObjectBrowser( true );
631 updateActions(); //SRN: BugID IPAL9377, case 3
638 void SalomeApp_Application::onSelectionChanged()
641 SalomeApp_SelectionMgr* mgr = selectionMgr();
642 mgr->selectedObjects(list);
644 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
645 if(study == NULL) return;
647 _PTR(Study) stdDS = study->studyDS();
652 SALOME_ListIteratorOfListIO it( list );
653 if(it.More() && list.Extent() == 1)
655 _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
657 qaction = action(EditCopyId);
658 if(studyMgr()->CanCopy(so) ) qaction->setEnabled(true);
659 else qaction->setEnabled(false);
661 qaction = action(EditPasteId);
662 if( studyMgr()->CanPaste(so) ) qaction->setEnabled(true);
663 else qaction->setEnabled(false);
666 qaction = action(EditCopyId);
667 qaction->setEnabled(false);
668 qaction = action(EditPasteId);
669 qaction->setEnabled(false);
673 void SalomeApp_Application::onRefresh()
675 updateObjectBrowser( true );
679 void SalomeApp_Application::onOpenWith()
681 QApplication::setOverrideCursor( Qt::waitCursor );
683 SalomeApp_SelectionMgr* mgr = selectionMgr();
684 mgr->selectedObjects(aList);
685 if (aList.Extent() != 1)
687 QApplication::restoreOverrideCursor();
690 Handle(SALOME_InteractiveObject) aIObj = aList.First();
691 QString aModuleName(aIObj->getComponentDataType());
692 QString aModuleTitle = moduleTitle(aModuleName);
693 activateModule(aModuleTitle);
694 QApplication::restoreOverrideCursor();
697 bool SalomeApp_Application::useStudy(const QString& theName)
700 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(activeStudy());
703 res = aStudy->loadDocument( theName );
704 updateDesktopTitle();
705 updateCommandsStatus();
709 void SalomeApp_Application::setActiveStudy( SUIT_Study* study )
711 CAM_Application::setActiveStudy( study );
716 //=======================================================================
717 // name : createNewStudy
718 // Purpose : Create new study
719 //=======================================================================
720 SUIT_Study* SalomeApp_Application::createNewStudy()
722 SalomeApp_Study* aStudy = new SalomeApp_Study( this );
724 // Set up processing of major study-related events
725 connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
726 connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
727 connect( aStudy, SIGNAL( saved ( SUIT_Study* ) ), this, SLOT( onStudySaved ( SUIT_Study* ) ) );
728 connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
733 //=======================================================================
734 // name : createNewStudy
735 // Purpose : Enable/Disable menu items and toolbar buttons. Rebuild menu
736 //=======================================================================
737 void SalomeApp_Application::updateCommandsStatus()
739 CAM_Application::updateCommandsStatus();
741 for ( int id = NewGLViewId; id <= NewVTKViewId; id++ )
743 QAction* a = action( id );
745 a->setEnabled( activeStudy() );
749 QAction* a = action( DumpStudyId );
751 a->setEnabled( activeStudy() );
754 a = action( LoadScriptId );
756 a->setEnabled( activeStudy() );
758 a = action( PropertiesId );
760 a->setEnabled( activeStudy() );
762 a = action(EditCopyId);
763 a->setEnabled(false);
764 a = action(EditPasteId);
765 a->setEnabled(false);
768 //=======================================================================
769 // name : onHelpAbout
770 // Purpose : SLOT. Display "About" message box
771 //=======================================================================
772 void SalomeApp_Application::onHelpAbout()
774 SalomeApp_AboutDlg* dlg = new SalomeApp_AboutDlg( applicationName(), applicationVersion(), desktop() );
779 QWidget* SalomeApp_Application::window( const int flag, const int studyId ) const
786 if ( !activeStudy() )
789 sId = activeStudy()->id();
792 if ( myWindows.contains( flag ) )
793 wid = myWindows[flag]->widget( sId );
798 void SalomeApp_Application::addWindow( QWidget* wid, const int flag, const int studyId )
806 if ( !activeStudy() )
809 sId = activeStudy()->id();
812 if ( !myWindows.contains( flag ) )
814 QMap<int, int> winMap;
815 currentWindows( winMap );
817 myWindows.insert( flag, new SalomeApp_WidgetContainer( flag, desktop() ) );
818 if ( winMap.contains( flag ) )
819 desktop()->moveDockWindow( myWindows[flag], (Dock)winMap[flag] );
821 myWindows[flag]->setResizeEnabled( true );
822 myWindows[flag]->setCloseMode( QDockWindow::Always );
823 myWindows[flag]->setName( QString( "dock_window_%1" ).arg( flag ) );
826 myWindows[flag]->insert( sId, wid );
828 setWindowShown( flag, !myWindows[flag]->isEmpty() );
831 void SalomeApp_Application::removeWindow( const int flag, const int studyId )
833 if ( !myWindows.contains( flag ) )
839 if ( !activeStudy() )
842 sId = activeStudy()->id();
845 QWidget* wid = myWindows[flag]->widget( sId );
846 myWindows[flag]->remove( sId );
849 setWindowShown( flag, !myWindows[flag]->isEmpty() );
852 QWidget* SalomeApp_Application::getWindow( const int flag, const int studyId )
854 QWidget* wid = window( flag, studyId );
856 addWindow( wid = createWindow( flag ), flag, studyId );
861 bool SalomeApp_Application::isWindowVisible( const int type ) const
864 if ( myWindows.contains( type ) )
866 SUIT_Desktop* desk = ((SalomeApp_Application*)this)->desktop();
867 res = desk && desk->appropriate( myWindows[type] );
872 void SalomeApp_Application::setWindowShown( const int type, const bool on )
874 if ( !desktop() || !myWindows.contains( type ) )
877 QDockWindow* dw = myWindows[type];
878 desktop()->setAppropriate( dw, on );
879 on ? dw->show() : dw->hide();
882 OB_Browser* SalomeApp_Application::objectBrowser()
885 QWidget* wid = getWindow( WT_ObjectBrowser );
886 if ( wid->inherits( "OB_Browser" ) )
887 ob = (OB_Browser*)wid;
891 LogWindow* SalomeApp_Application::logWindow()
894 QWidget* wid = getWindow( WT_LogWindow );
895 if ( wid->inherits( "LogWindow" ) )
896 lw = (LogWindow*)wid;
900 PythonConsole* SalomeApp_Application::pythonConsole()
902 PythonConsole* console = 0;
903 QWidget* wid = getWindow( WT_PyConsole );
904 if ( wid->inherits( "PythonConsole" ) )
905 console = (PythonConsole*)wid;
909 SalomeApp_Preferences* SalomeApp_Application::preferences() const
911 return preferences( false );
914 SUIT_ViewManager* SalomeApp_Application::getViewManager( const QString& vmType, const bool create )
916 SUIT_ViewManager* aVM = viewManager( vmType );
917 SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
919 if ( anActiveVM && anActiveVM->getType() == vmType )
924 if ( !aVM->getActiveView() )
927 aVM->getActiveView()->setFocus();
930 aVM = createViewManager( vmType );
935 SUIT_ViewManager* SalomeApp_Application::createViewManager( const QString& vmType )
937 SUIT_ResourceMgr* resMgr = resourceMgr();
939 SUIT_ViewManager* viewMgr = 0;
940 if ( vmType == GLViewer_Viewer::Type() )
942 viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() );
943 new SalomeApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
945 else if ( vmType == Plot2d_Viewer::Type() )
947 viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
948 viewMgr->setViewModel( new SPlot2d_Viewer() );// custom view model, which extends SALOME_View interface
950 else if ( vmType == OCCViewer_Viewer::Type() )
952 viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
953 SOCC_Viewer* vm = new SOCC_Viewer();
954 vm->setBackgroundColor( resMgr->colorValue( "OCCViewer", "background", vm->backgroundColor() ) );
955 vm->setTrihedronSize( resMgr->integerValue( "OCCViewer", "trihedron_size", vm->trihedronSize() ) );
958 u = resMgr->integerValue( "OCCViewer", "iso_number_u", u );
959 v = resMgr->integerValue( "OCCViewer", "iso_number_v", v );
961 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
962 new SalomeApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
964 else if ( vmType == SVTK_Viewer::Type() )
966 viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
967 SVTK_Viewer* vm = (SVTK_Viewer*)viewMgr->getViewModel();
968 vm->setBackgroundColor( resMgr->colorValue( "VTKViewer", "background", vm->backgroundColor() ) );
969 vm->setTrihedronSize( resMgr->integerValue( "VTKViewer", "trihedron_size", vm->trihedronSize() ) );
970 new SalomeApp_VTKSelector((SVTK_Viewer*)viewMgr->getViewModel(),mySelMgr);
976 addViewManager( viewMgr );
977 SUIT_ViewWindow* viewWin = viewMgr->createViewWindow();
979 if ( viewWin && desktop() )
980 viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
982 connect( viewMgr, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
983 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
988 void SalomeApp_Application::onCloseView( SUIT_ViewManager* theVM )
990 removeViewManager( theVM );
993 void SalomeApp_Application::onStudyCreated( SUIT_Study* theStudy )
995 SUIT_DataObject* aRoot = 0;
996 if ( theStudy && theStudy->root() )
998 aRoot = theStudy->root();
999 //aRoot->setName( tr( "DATA_MODELS" ) );
1001 if ( objectBrowser() != 0 )
1002 objectBrowser()->setRootObject( aRoot );
1004 activateModule( defaultModule() );
1009 void SalomeApp_Application::onStudyOpened( SUIT_Study* theStudy )
1011 SUIT_DataObject* aRoot = 0;
1012 if ( theStudy && theStudy->root() )
1014 aRoot = theStudy->root();
1017 if ( objectBrowser() != 0 ) {
1018 objectBrowser()->setRootObject( aRoot );
1021 activateModule( defaultModule() );
1028 void SalomeApp_Application::onStudySaved( SUIT_Study* )
1033 void SalomeApp_Application::onStudyClosed( SUIT_Study* )
1037 activateModule( "" );
1039 saveWindowsGeometry();
1042 void SalomeApp_Application::onDumpStudy( )
1044 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
1045 if ( !appStudy ) return;
1046 _PTR(Study) aStudy = appStudy->studyDS();
1048 QStringList aFilters;
1049 aFilters.append( tr( "PYTHON_FILES_FILTER" ) );
1051 SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg( desktop(), false, tr("PUBLISH_IN_STUDY"), true, true);
1052 fd->setCaption( tr( "TOT_DESK_FILE_DUMP_STUDY" ) );
1053 fd->setFilters( aFilters );
1054 fd->SetChecked(true);
1056 QString aFileName = fd->selectedFile();
1057 bool toPublish = fd->IsChecked();
1060 if(!aFileName.isEmpty()) {
1061 QFileInfo aFileInfo(aFileName);
1062 aStudy->DumpStudy( aFileInfo.dirPath( true ).latin1(), aFileInfo.baseName().latin1(), toPublish );
1066 void SalomeApp_Application::onLoadScript( )
1068 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
1069 if ( !appStudy ) return;
1070 _PTR(Study) aStudy = appStudy->studyDS();
1072 if ( aStudy->GetProperties()->IsLocked() ) {
1073 SUIT_MessageBox::warn1 ( desktop(),
1074 QObject::tr("WRN_WARNING"),
1075 QObject::tr("WRN_STUDY_LOCKED"),
1076 QObject::tr("BUT_OK") );
1080 QStringList filtersList;
1081 filtersList.append(tr("PYTHON_FILES_FILTER"));
1082 filtersList.append(tr("ALL_FILES_FILTER"));
1084 QString aFile = SUIT_FileDlg::getFileName( desktop(), "", filtersList, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), true, true );
1086 if ( !aFile.isEmpty() )
1088 QString command = QString("execfile(\"%1\")").arg(aFile);
1090 PythonConsole* pyConsole = pythonConsole();
1093 pyConsole->exec( command );
1097 void SalomeApp_Application::onPreferences()
1099 QApplication::setOverrideCursor( Qt::waitCursor );
1101 SalomeApp_PreferencesDlg* prefDlg = new SalomeApp_PreferencesDlg( preferences( true ), desktop());
1103 QApplication::restoreOverrideCursor();
1113 void SalomeApp_Application::onMRUActivated( QString aName )
1118 void SalomeApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param )
1120 SalomeApp_Module* sMod = 0;
1121 CAM_Module* mod = module( modName );
1122 if ( mod && mod->inherits( "SalomeApp_Module" ) )
1123 sMod = (SalomeApp_Module*)mod;
1126 sMod->preferencesChanged( section, param );
1128 preferencesChanged( section, param );
1131 QString SalomeApp_Application::getFileFilter() const
1136 void SalomeApp_Application::beforeCloseDoc( SUIT_Study* s )
1138 CAM_Application::beforeCloseDoc( s );
1140 for ( WindowMap::ConstIterator itr = myWindows.begin(); s && itr != myWindows.end(); ++itr )
1141 removeWindow( itr.key(), s->id() );
1144 void SalomeApp_Application::updateActions()
1146 updateCommandsStatus();
1149 QWidget* SalomeApp_Application::createWindow( const int flag )
1153 SUIT_ResourceMgr* resMgr = resourceMgr();
1155 if ( flag == WT_ObjectBrowser )
1157 OB_Browser* ob = new OB_Browser( desktop() );
1158 ob->setAutoUpdate( true );
1159 ob->setAutoOpenLevel( 1 );
1160 ob->setCaption( tr( "OBJECT_BROWSER" ) );
1161 ob->resize( OBJECT_BROWSER_WIDTH, ob->height() );
1162 ob->setFilter( new SalomeApp_OBFilter( selectionMgr() ) );
1164 ob->setNameTitle( tr( "OBJ_BROWSER_NAME" ) );
1166 for ( int i = SalomeApp_DataObject::CT_Value; i <= SalomeApp_DataObject::CT_RefEntry; i++ )
1168 ob->addColumn( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i ) ), i );
1169 ob->setColumnShown( i, resMgr->booleanValue( "ObjectBrowser",
1170 QString().sprintf( "visibility_column_%d", i ), true ) );
1173 // Create OBSelector
1174 new SalomeApp_OBSelector( ob, mySelMgr );
1178 ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1180 else if ( flag == WT_PyConsole )
1182 PythonConsole* pyCons = new PythonConsole( desktop(), new SalomeApp_PyInterp() );
1183 pyCons->setCaption( tr( "PYTHON_CONSOLE" ) );
1186 // pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1188 else if ( flag == WT_LogWindow )
1190 LogWindow* logWin = new LogWindow( desktop() );
1191 logWin->setCaption( tr( "LOG_WINDOW" ) );
1194 logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1200 void SalomeApp_Application::defaultWindows( QMap<int, int>& aMap ) const
1202 aMap.insert( WT_ObjectBrowser, Qt::DockLeft );
1203 aMap.insert( WT_PyConsole, Qt::DockBottom );
1204 // aMap.insert( WT_LogWindow, Qt::DockBottom );
1207 void SalomeApp_Application::defaultViewManagers( QStringList& ) const
1211 SalomeApp_Preferences* SalomeApp_Application::preferences( const bool crt ) const
1216 SalomeApp_Application* that = (SalomeApp_Application*)this;
1218 if ( !_prefs_ && crt )
1220 _prefs_ = new SalomeApp_Preferences( resourceMgr() );
1221 that->createPreferences( _prefs_ );
1224 that->myPrefs = _prefs_;
1226 QPtrList<SUIT_Application> appList = SUIT_Session::session()->applications();
1227 for ( QPtrListIterator<SUIT_Application> appIt ( appList ); appIt.current(); ++appIt )
1229 if ( !appIt.current()->inherits( "SalomeApp_Application" ) )
1232 SalomeApp_Application* app = (SalomeApp_Application*)appIt.current();
1234 QStringList modNameList;
1235 app->modules( modNameList, false );
1236 for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it )
1238 int id = _prefs_->addPreference( *it );
1239 _prefs_->setProperty( id, "info", tr( "PREFERENCES_NOT_LOADED" ).arg( *it ) );
1243 app->modules( modList );
1244 for ( ModuleListIterator itr( modList ); itr.current(); ++itr )
1246 SalomeApp_Module* mod = 0;
1247 if ( itr.current()->inherits( "SalomeApp_Module" ) )
1248 mod = (SalomeApp_Module*)itr.current();
1250 if ( mod && !_prefs_->hasModule( mod->moduleName() ) )
1251 mod->createPreferences();
1255 connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
1256 this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ) );
1261 void SalomeApp_Application::moduleAdded( CAM_Module* mod )
1263 CAM_Application::moduleAdded( mod );
1265 SalomeApp_Module* salomeMod = 0;
1266 if ( mod && mod->inherits( "SalomeApp_Module" ) )
1267 salomeMod = (SalomeApp_Module*)mod;
1269 if ( myPrefs && salomeMod && !myPrefs->hasModule( salomeMod->moduleName() ))
1270 salomeMod->createPreferences();
1273 void SalomeApp_Application::createPreferences( SalomeApp_Preferences* pref )
1278 int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
1280 int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat );
1282 int obGroup = pref->addPreference( tr( "PREF_GROUP_OBJBROWSER" ), genTab );
1283 for ( int i = SalomeApp_DataObject::CT_Value; i <= SalomeApp_DataObject::CT_RefEntry; i++ )
1285 pref->addPreference( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i ) ), obGroup,
1286 SalomeApp_Preferences::Bool, "ObjectBrowser", QString().sprintf( "visibility_column_%d", i ) );
1288 pref->setProperty( obGroup, "columns", 1 );
1290 int viewTab = pref->addPreference( tr( "PREF_TAB_VIEWERS" ), salomeCat );
1292 int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), viewTab );
1294 int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), viewTab );
1295 pref->setProperty( occGroup, "columns", 1 );
1296 pref->setProperty( vtkGroup, "columns", 1 );
1298 int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occGroup,
1299 SalomeApp_Preferences::IntSpin, "OCCViewer", "trihedron_size" );
1300 pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup,
1301 SalomeApp_Preferences::Color, "OCCViewer", "background" );
1303 pref->setProperty( occTS, "min", 1 );
1304 pref->setProperty( occTS, "max", 150 );
1306 int isoU = pref->addPreference( tr( "PREF_ISOS_U" ), occGroup,
1307 SalomeApp_Preferences::IntSpin, "OCCViewer", "iso_number_u" );
1308 int isoV = pref->addPreference( tr( "PREF_ISOS_V" ), occGroup,
1309 SalomeApp_Preferences::IntSpin, "OCCViewer", "iso_number_v" );
1311 pref->setProperty( isoU, "min", 0 );
1312 pref->setProperty( isoU, "max", 100000 );
1314 pref->setProperty( isoV, "min", 0 );
1315 pref->setProperty( isoV, "max", 100000 );
1317 int vtkTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), vtkGroup,
1318 SalomeApp_Preferences::IntSpin, "VTKViewer", "trihedron_size" );
1319 pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGroup,
1320 SalomeApp_Preferences::Color, "VTKViewer", "background" );
1322 pref->setProperty( vtkTS, "min", 1 );
1323 pref->setProperty( vtkTS, "max", 150 );
1326 void SalomeApp_Application::preferencesChanged( const QString& sec, const QString& param )
1328 SUIT_ResourceMgr* resMgr = resourceMgr();
1332 if ( sec == QString( "OCCViewer" ) && param == QString( "trihedron_size" ) )
1334 int sz = resMgr->integerValue( sec, param, -1 );
1335 QPtrList<SUIT_ViewManager> lst;
1336 viewManagers( OCCViewer_Viewer::Type(), lst );
1337 for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current() && sz >= 0; ++it )
1339 SUIT_ViewModel* vm = it.current()->getViewModel();
1340 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
1343 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
1344 occVM->setTrihedronSize( sz );
1345 occVM->getAISContext()->UpdateCurrentViewer();
1349 if ( sec == QString( "VTKViewer" ) && param == QString( "trihedron_size" ) )
1351 int sz = resMgr->integerValue( sec, param, -1 );
1352 QPtrList<SUIT_ViewManager> lst;
1353 viewManagers( SVTK_Viewer::Type(), lst );
1354 for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current() && sz >= 0; ++it )
1356 SUIT_ViewModel* vm = it.current()->getViewModel();
1357 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
1360 SVTK_Viewer* vtkVM = (SVTK_Viewer*)vm;
1361 vtkVM->setTrihedronSize( sz );
1366 if ( sec == QString( "OCCViewer" ) && ( param == QString( "iso_number_u" ) || param == QString( "iso_number_v" ) ) )
1368 QPtrList<SUIT_ViewManager> lst;
1369 viewManagers( OCCViewer_Viewer::Type(), lst );
1370 int u = resMgr->integerValue( sec, "iso_number_u" );
1371 int v = resMgr->integerValue( sec, "iso_number_v" );
1372 for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current(); ++it )
1373 ((OCCViewer_Viewer*)it.current())->setIsos( u, v );
1378 void SalomeApp_Application::updateDesktopTitle() {
1379 QString aTitle = applicationName();
1380 QString aVer = applicationVersion();
1381 if ( !aVer.isEmpty() )
1382 aTitle += QString( " " ) + aVer;
1384 if ( activeStudy() )
1386 QString sName = SUIT_Tools::file( activeStudy()->studyName().stripWhiteSpace(), false );
1387 if ( !sName.isEmpty() ) {
1388 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
1389 _PTR(Study) stdDS = study->studyDS();
1391 if ( stdDS->GetProperties()->IsLocked() ) {
1392 aTitle += QString( " - [%1 (%2)]").arg( sName ).arg( tr( "STUDY_LOCKED" ) );
1394 aTitle += QString( " - [%1]" ).arg( sName );
1400 desktop()->setCaption( aTitle );
1403 void SalomeApp_Application::afterCloseDoc()
1407 CAM_Application::afterCloseDoc();
1410 CORBA::ORB_var SalomeApp_Application::orb()
1412 ORB_INIT& init = *SINGLETON_<ORB_INIT>::Instance();
1413 static CORBA::ORB_var _orb = init( qApp->argc(), qApp->argv() );
1417 SALOMEDSClient_StudyManager* SalomeApp_Application::studyMgr()
1419 static SALOMEDSClient_StudyManager* _sm = new SALOMEDS_StudyManager();
1423 SALOME_NamingService* SalomeApp_Application::namingService()
1425 static SALOME_NamingService* _ns = new SALOME_NamingService( orb() );
1429 SALOME_LifeCycleCORBA* SalomeApp_Application::lcc()
1431 static SALOME_LifeCycleCORBA* _lcc = new SALOME_LifeCycleCORBA( namingService() );
1435 QString SalomeApp_Application::defaultEngineIOR()
1437 // Look for a default module engine (needed for CORBAless modules to use SALOMEDS persistence)
1438 QString anIOR( "" );
1439 CORBA::Object_ptr anEngine = namingService()->Resolve( "/SalomeAppEngine" );
1440 if ( !CORBA::is_nil( anEngine ) )
1441 anIOR = orb()->object_to_string( anEngine );
1445 void SalomeApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) const
1449 SUIT_ResourceMgr* resMgr = resourceMgr();
1453 QStringList modList;
1454 modules( modList, false );
1456 for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )
1458 QString modName = *it;
1459 QString modIntr = moduleName( modName );
1460 QString modIcon = resMgr->stringValue( modIntr, "icon", QString::null );
1462 if ( modIcon.isEmpty() )
1465 if ( SUIT_Tools::extension( modIcon ).isEmpty() )
1466 modIcon += QString( ".png" );
1468 iconMap.insert( modName, modIcon );
1472 void SalomeApp_Application::updateModuleActions()
1475 if ( activeModule() )
1476 modName = activeModule()->moduleName();
1478 if ( myActions.contains( modName ) )
1479 myActions[modName]->setOn( true );
1482 void SalomeApp_Application::currentWindows( QMap<int, int>& winMap ) const
1485 if ( !activeStudy() )
1488 if ( activeModule() && activeModule()->inherits( "SalomeApp_Module" ) )
1489 ((SalomeApp_Module*)activeModule())->windows( winMap );
1491 defaultWindows( winMap );
1494 void SalomeApp_Application::currentViewManagers( QStringList& lst ) const
1497 if ( !activeStudy() )
1500 if ( activeModule() && activeModule()->inherits( "SalomeApp_Module" ) )
1501 ((SalomeApp_Module*)activeModule())->viewManagers( lst );
1503 defaultViewManagers( lst );
1506 void SalomeApp_Application::updateWindows()
1508 QMap<int, int> winMap;
1509 currentWindows( winMap );
1511 for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
1512 getWindow( it.key() );
1514 loadWindowsGeometry();
1516 for ( WindowMap::ConstIterator itr = myWindows.begin(); itr != myWindows.end(); ++itr )
1517 setWindowShown( itr.key(), !itr.data()->isEmpty() && winMap.contains( itr.key() ) );
1520 void SalomeApp_Application::updateViewManagers()
1523 currentViewManagers( lst );
1525 for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
1526 getViewManager( *it, true );
1529 void SalomeApp_Application::loadWindowsGeometry()
1531 QtxDockAction* dockMgr = 0;
1533 QAction* a = action( ViewWindowsId );
1534 if ( a && a->inherits( "QtxDockAction" ) )
1535 dockMgr = (QtxDockAction*)a;
1541 if ( activeModule() )
1542 modName = moduleLibrary( activeModule()->moduleName(), false );
1544 QString section = QString( "windows_geometry" );
1545 if ( !modName.isEmpty() )
1546 section += QString( "." ) + modName;
1548 dockMgr->loadGeometry( resourceMgr(), section, false );
1549 dockMgr->restoreGeometry();
1552 void SalomeApp_Application::saveWindowsGeometry()
1554 QtxDockAction* dockMgr = 0;
1556 QAction* a = action( ViewWindowsId );
1557 if ( a && a->inherits( "QtxDockAction" ) )
1558 dockMgr = (QtxDockAction*)a;
1564 if ( activeModule() )
1565 modName = moduleLibrary( activeModule()->moduleName(), false );
1567 QString section = QString( "windows_geometry" );
1568 if ( !modName.isEmpty() )
1569 section += QString( "." ) + modName;
1571 dockMgr->storeGeometry();
1572 dockMgr->saveGeometry( resourceMgr(), section, false );
1575 void SalomeApp_Application::activateWindows()
1577 if ( activeStudy() )
1579 for ( WindowMap::Iterator itr = myWindows.begin(); itr != myWindows.end(); ++itr )
1580 itr.data()->activate( activeStudy()->id() );
1584 void SalomeApp_Application::onProperties()
1586 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
1590 _PTR(StudyBuilder) SB = study->studyDS()->NewBuilder();
1593 SalomeApp_StudyPropertiesDlg aDlg( desktop() );
1594 int res = aDlg.exec();
1595 if( res==QDialog::Accepted && aDlg.isChanged() )
1596 SB->CommitCommand();
1600 //study->updateCaptions();
1601 updateDesktopTitle();
1604 QString SalomeApp_Application::getFileName( bool open, const QString& initial, const QString& filters,
1605 const QString& caption, QWidget* parent )
1609 QStringList fls = QStringList::split( ";;", filters, false );
1610 return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
1613 QString SalomeApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
1617 return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true );
1620 QStringList SalomeApp_Application::getOpenFileNames( const QString& initial, const QString& filters,
1621 const QString& caption, QWidget* parent )
1625 QStringList fls = QStringList::split( ";;", filters, false );
1626 return SUIT_FileDlg::getOpenFileNames( parent, initial, fls, caption, true );
1629 void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* thePopup, QString& title )
1631 CAM_Application::contextMenuPopup( type, thePopup, title );
1632 thePopup->insertSeparator();
1633 thePopup->insertItem( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
1635 // "Activate module" item should appear only if it's necessary
1636 OB_Browser* ob = objectBrowser();
1637 if ( !ob || type != ob->popupClientType() )
1639 SALOME_ListIO aList;
1640 SalomeApp_SelectionMgr* mgr = selectionMgr();
1641 mgr->selectedObjects(aList);
1642 if (aList.Extent() != 1)
1644 Handle(SALOME_InteractiveObject) aIObj = aList.First();
1645 QString aModuleName(aIObj->getComponentDataType());
1646 QString aModuleTitle = moduleTitle(aModuleName);
1647 CAM_Module* currentModule = activeModule();
1648 if (currentModule && currentModule->moduleName() == aModuleTitle)
1650 thePopup->insertItem( tr( "MEN_OPENWITH" ), this, SLOT( onOpenWith() ) );
1653 void SalomeApp_Application::updateObjectBrowser( const bool updateModels )
1655 // update existing data models (already loaded SComponents)
1658 for ( ModuleListIterator it = modules(); it.current(); ++it )
1660 CAM_DataModel* camDM = it.current()->dataModel();
1661 if ( camDM && camDM->inherits( "SalomeApp_DataModel" ) )
1662 ((SalomeApp_DataModel*)camDM)->update();
1665 // update "non-existing" (not loaded yet) data models
1666 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
1669 _PTR(Study) stdDS = study->studyDS();
1672 for ( _PTR(SComponentIterator) it ( stdDS->NewComponentIterator() ); it->More(); it->Next() )
1674 _PTR(SComponent) aComponent ( it->Value() );
1676 if ( aComponent->ComponentDataType() == "Interface Applicative" )
1677 continue; // skip the magic "Interface Applicative" component
1679 SalomeApp_DataModel::BuildTree( aComponent, study->root(), study, /*skipExisitng=*/true );
1684 if ( objectBrowser() )
1685 objectBrowser()->updateTree();
1689 //************************************************************
1690 void SalomeApp_Application::onDesktopActivated()
1692 CAM_Application::onDesktopActivated();
1693 SalomeApp_Module* aModule = dynamic_cast<SalomeApp_Module*>(activeModule());
1695 aModule->studyActivated();
1698 void SalomeApp_Application::createEmptyStudy()
1700 CAM_Application::createEmptyStudy();
1701 if ( objectBrowser() )
1702 objectBrowser()->updateTree();
1705 bool SalomeApp_Application::activateModule( CAM_Module* mod )
1707 CAM_Application::activateModule( mod );
1708 if ( objectBrowser() )
1709 objectBrowser()->updateTree();