1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File: LightApp_Application.cxx
24 // Created: 6/20/2005 18:39:45 PM
25 // Author: Natalia Donis
28 // E.A. : On windows with python 2.6, there is a conflict
29 // E.A. : between pymath.h and Standard_math.h which define
30 // E.A. : some same symbols : acosh, asinh, ...
31 #include <Standard_math.hxx>
32 #ifndef DISABLE_PYCONSOLE
37 #ifndef DISABLE_PYCONSOLE
38 #include "LightApp_PyInterp.h" // WARNING! This include must be the first!
39 #include <PyConsole_Console.h>
42 #include "LightApp_Application.h"
43 #include "LightApp_Module.h"
44 #include "LightApp_DataModel.h"
45 #include "LightApp_DataOwner.h"
46 #include "LightApp_Displayer.h"
47 #include "LightApp_Study.h"
48 #include "LightApp_Preferences.h"
49 #include "LightApp_PreferencesDlg.h"
50 #include "LightApp_ModuleDlg.h"
51 #include "LightApp_AboutDlg.h"
52 #include "LightApp_ModuleAction.h"
53 // temporary commented
54 #include "LightApp_EventFilter.h"
55 #include "LightApp_OBSelector.h"
56 #include "LightApp_SelectionMgr.h"
57 #include "LightApp_DataObject.h"
58 #include "LightApp_WgViewModel.h"
59 #include "LightApp_FullScreenHelper.h"
61 #include <GUI_version.h>
63 #include <SALOME_Event.h>
65 #include <Style_Salome.h>
66 #include <Style_PrefDlg.h>
68 #include <CAM_Module.h>
69 #include <CAM_DataModel.h>
70 #include <CAM_Study.h>
71 #include <STD_TabDesktop.h>
73 #include <SUIT_DataBrowser.h>
74 #include <SUIT_Session.h>
75 #include <SUIT_Study.h>
76 #include <SUIT_FileDlg.h>
77 #include <SUIT_ResourceMgr.h>
78 #include <SUIT_ShortcutMgr.h>
79 #include <SUIT_Tools.h>
80 #include <SUIT_Accel.h>
81 #include <SUIT_MessageBox.h>
82 #include <SUIT_ViewWindow.h>
85 #include <QtxToolBar.h>
86 #include <QtxTreeView.h>
87 #include <QtxMRUAction.h>
88 #include <QtxDockAction.h>
89 #include <QtxDockWidget.h>
90 #include <QtxActionToolMgr.h>
91 #include <QtxSearchTool.h>
92 #include <QtxWorkstack.h>
95 #include <LogWindow.h>
97 #ifndef DISABLE_GLVIEWER
98 #include <GLViewer_Viewer.h>
99 #include <GLViewer_ViewManager.h>
100 #include "LightApp_GLSelector.h"
103 #ifndef DISABLE_PLOT2DVIEWER
104 #include <Plot2d_ViewManager.h>
105 #include <Plot2d_ViewModel.h>
106 #include <Plot2d_ViewWindow.h>
107 #include <Plot2d_ViewFrame.h>
108 #include "LightApp_Plot2dSelector.h"
109 #ifndef DISABLE_SALOMEOBJECT
110 #include <SPlot2d_ViewModel.h>
112 #include <Plot2d_ViewModel.h>
116 #ifndef DISABLE_OCCVIEWER
117 #include <OCCViewer_ViewManager.h>
118 #include <OCCViewer_ViewFrame.h>
119 #ifndef DISABLE_SALOMEOBJECT
120 #include <SOCC_ViewModel.h>
122 #include <OCCViewer_ViewModel.h>
124 #include "LightApp_OCCSelector.h"
127 #ifndef DISABLE_VTKVIEWER
128 #ifndef DISABLE_SALOMEOBJECT
129 #include <SVTK_ViewModel.h>
130 #include <SVTK_ViewManager.h>
131 #include "LightApp_VTKSelector.h"
133 #include <VTKViewer_ViewModel.h>
134 #include <VTKViewer_ViewManager.h>
136 #include <VTKViewer_ViewModel.h>
139 #ifndef DISABLE_QXGRAPHVIEWER
140 #include <QxScene_ViewManager.h>
141 #include <QxScene_ViewModel.h>
142 #include <QxScene_ViewWindow.h>
145 #ifndef DISABLE_GRAPHICSVIEW
146 #include "GraphicsView_Viewer.h"
147 #include "GraphicsView_ViewManager.h"
148 #include "LightApp_GVSelector.h"
151 #ifndef DISABLE_PVVIEWER
152 #include "PVViewer_ViewManager.h"
153 #include "PVViewer_ViewWindow.h"
154 #include "PVViewer_ViewModel.h"
158 #define VISIBILITY_COLUMN_WIDTH 25
164 #include <QStringList>
166 #include <QApplication>
168 #include <QStatusBar>
170 #include <QObjectList>
172 #include <QInputDialog>
173 #include <QFontDatabase>
175 #include <QByteArray>
179 #include <QHeaderView>
184 #include <utilities.h>
186 #define FIRST_HELP_ID 1000000
188 #ifndef DISABLE_SALOMEOBJECT
189 #include <SALOME_InteractiveObject.hxx>
190 #include <SALOME_ListIO.hxx>
193 #include <Standard_Version.hxx>
195 #define ToolBarMarker 0
196 #define DockWidgetMarker 1
198 static const char* imageEmptyIcon[] = {
201 "....................",
202 "....................",
203 "....................",
204 "....................",
205 "....................",
206 "....................",
207 "....................",
208 "....................",
209 "....................",
210 "....................",
211 "....................",
212 "....................",
213 "....................",
214 "....................",
215 "....................",
216 "....................",
217 "....................",
218 "....................",
219 "....................",
220 "...................."};
222 int LightApp_Application::lastStudyId = 0;
224 // Markers used to parse array with dockable windows and toolbars state.
225 // For more details please see the qdockarealayout.cpp && qtoolbararealayout.cpp
226 // in the Qt source code.
228 #define QDockWidgetMarker 0xfd // = DockWidgetStateMarker
229 #define QToolBarMarker 0xfc // = ToolBarStateMarkerEx
231 // Format of the Byte array with the windows and toolbar state is:
232 // VersionMarker|version|DockWidgetStateMarker|nbDockWidgetLines|...DocWidgetData...|ToolBarStateMarkerEx|nbToolBarLines|...ToolBarData...
234 //Find toolbar marker position in the array in the following way:
235 //since the 'toolbar marker' is not unique, find index of first occurrence of the
236 //'toolbar marker' in the array and check that next string is name of the toolbar
238 int getToolbarMarkerIndex(QByteArray input, const QStringList& aFlags) {
239 int aResult = -1,tmp = 0;
240 int inputLen = input.length();
241 QDataStream anInputData(&input, QIODevice::ReadOnly);
242 while(tmp < inputLen) {
243 tmp = input.indexOf(QToolBarMarker, tmp + 1);
246 anInputData.device()->seek(tmp);
250 anInputData >> lines;
252 if(lines == 0 && anInputData.atEnd()){
253 //Case then array doesn't contain information about toolbars,
264 if(aFlags.contains(str)) {
273 \return last global id of study
275 int LightApp_Application::studyId()
277 return LightApp_Application::lastStudyId;
280 /*!Create new instance of LightApp_Application.*/
281 extern "C" LIGHTAPP_EXPORT SUIT_Application* createApplication()
283 return new LightApp_Application();
286 /*! \var global preferences of LightApp */
287 LightApp_Preferences* LightApp_Application::_prefs_ = 0;
291 \class LightApp_Application
292 Application containing LightApp module
296 LightApp_Application::LightApp_Application()
297 : CAM_Application( false ),
299 myScreenHelper(new LightApp_FullScreenHelper())
301 Q_INIT_RESOURCE( LightApp );
303 STD_TabDesktop* desk = new STD_TabDesktop();
304 desk->setFullScreenAllowed(false);
305 desk->setMinimizeAllowed(false);
309 // initialize auto save timer
310 myAutoSaveTimer = new QTimer( this );
311 myAutoSaveTimer->setSingleShot( true );
312 connect( myAutoSaveTimer, SIGNAL( timeout() ), this, SLOT( onSaveDoc() ) );
314 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
315 QPixmap aLogo = aResMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
317 desktop()->setWindowIcon( aLogo );
318 desktop()->setDockableMenuBar( false );
319 desktop()->setDockableStatusBar( false );
321 // base logo (salome itself)
322 desktop()->logoInsert( "_app_base", aResMgr->loadPixmap( "LightApp", tr( "APP_BASE_LOGO" ), false ) );
323 // extra logo (salome-based application)
324 desktop()->logoInsert( "_app_extra", aResMgr->loadPixmap( "LightApp", tr( "APP_EXTRA_LOGO" ), false ) );
328 mySelMgr = new LightApp_SelectionMgr( this );
330 myAccel = SUIT_Accel::getAccel();
332 #ifndef DISABLE_OCCVIEWER
333 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, OCCViewer_Viewer::Type() );
334 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, OCCViewer_Viewer::Type() );
335 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, OCCViewer_Viewer::Type() );
336 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, OCCViewer_Viewer::Type() );
337 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, OCCViewer_Viewer::Type() );
338 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, OCCViewer_Viewer::Type() );
339 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, OCCViewer_Viewer::Type() );
340 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, OCCViewer_Viewer::Type() );
341 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, OCCViewer_Viewer::Type() );
342 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, OCCViewer_Viewer::Type() );
343 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, OCCViewer_Viewer::Type() );
344 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, OCCViewer_Viewer::Type() );
346 #ifndef DISABLE_VTKVIEWER
347 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, VTKViewer_Viewer::Type() );
348 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, VTKViewer_Viewer::Type() );
349 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, VTKViewer_Viewer::Type() );
350 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, VTKViewer_Viewer::Type() );
351 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, VTKViewer_Viewer::Type() );
352 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, VTKViewer_Viewer::Type() );
353 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, VTKViewer_Viewer::Type() );
354 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, VTKViewer_Viewer::Type() );
355 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, VTKViewer_Viewer::Type() );
356 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, VTKViewer_Viewer::Type() );
357 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, VTKViewer_Viewer::Type() );
358 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, VTKViewer_Viewer::Type() );
360 #ifndef DISABLE_PLOT2DVIEWER
361 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, Plot2d_Viewer::Type() );
362 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, Plot2d_Viewer::Type() );
363 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, Plot2d_Viewer::Type() );
364 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, Plot2d_Viewer::Type() );
365 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, Plot2d_Viewer::Type() );
366 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, Plot2d_Viewer::Type() );
367 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, Plot2d_Viewer::Type() );
368 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, Plot2d_Viewer::Type() );
371 connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) );
372 connect( desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
373 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
374 connect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
375 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ), Qt::UniqueConnection );
378 // Set existing font for the python console in resources
379 if( !aResMgr->hasValue( "PyConsole", "font" ) )
382 QFont f = aResMgr->fontValue( "PyConsole", "font" );
384 QStringList famdb = fdb.families();
386 if ( famdb.contains(f.family()) || !aResMgr->hasValue( "PyConsole", "additional_families" ) )
389 QStringList anAddFamilies = aResMgr->stringValue( "PyConsole", "additional_families" ).split( ";", QString::SkipEmptyParts );
391 for ( QStringList::Iterator it = anAddFamilies.begin(); it != anAddFamilies.end(); ++it )
394 if ( famdb.contains(aFamily) )
396 f.setFamily( aFamily );
397 aResMgr->setValue( "PyConsole", "font", f );
404 *\li Save window geometry.
405 *\li Save desktop geometry.
406 *\li Save resource maneger.
407 *\li Delete selection manager.
409 LightApp_Application::~LightApp_Application()
412 delete myScreenHelper;
415 /*!Start application.*/
416 void LightApp_Application::start()
418 CAM_Application::start();
421 updateViewManagers();
422 updateCommandsStatus();
425 desktop()->statusBar()->showMessage( "" );
427 LightApp_EventFilter::Init();
430 /*!Gets application name.*/
431 QString LightApp_Application::applicationName() const
433 static QString _app_name;
434 if ( _app_name.isEmpty() )
435 _app_name = tr( "APP_NAME" );
439 /*!Gets application version.*/
440 QString LightApp_Application::applicationVersion() const
442 static QString _app_version;
444 if ( _app_version.isEmpty() )
446 QString resVersion = tr( "APP_VERSION" );
447 if ( resVersion != "APP_VERSION" )
449 _app_version = resVersion;
453 _app_version = GUI_VERSION_STR;
459 /*!Load module by \a name.*/
460 CAM_Module* LightApp_Application::loadModule( const QString& name, const bool showMsg )
462 CAM_Module* mod = CAM_Application::loadModule( name, showMsg );
465 connect( this, SIGNAL( studyOpened() ), mod, SLOT( onModelOpened() ) );
466 connect( this, SIGNAL( studySaved() ), mod, SLOT( onModelSaved() ) );
467 connect( this, SIGNAL( studyClosed() ), mod, SLOT( onModelClosed() ) );
472 /*!Activate module by \a modName*/
473 bool LightApp_Application::activateModule( const QString& modName )
476 CAM_Module* prevMod = activeModule();
479 actName = prevMod->moduleName();
481 if ( actName == modName )
484 putInfo( tr( "ACTIVATING_MODULE" ).arg( modName ) );
486 saveDockWindowsState();
488 bool status = CAM_Application::activateModule( modName );
490 updateModuleActions();
498 updateViewManagers();
500 if ( activeStudy() && activeStudy()->root() && objectBrowser() && objectBrowser()->root() != activeStudy()->root() ) {
501 objectBrowser()->setRoot( activeStudy()->root() );
502 updateObjectBrowser( true );
507 /*!Gets selection manager.*/
508 LightApp_SelectionMgr* LightApp_Application::selectionMgr() const
513 /*!Creat action "New window" for certain type of viewer:*/
514 void LightApp_Application::createActionForViewer( const int id,
516 const QString& suffix,
519 QString vtlt = tr( QString( "NEW_WINDOW_%1" ).arg( suffix ).toLatin1().constData() );
520 QString tip = tr( "CREATING_NEW_WINDOW" ).arg( vtlt.remove( "&" ) );
521 QAction* a = createAction( id, // menu action id
528 false, // toggle flag
530 SLOT( onNewWindow() ) ); // slot
531 createMenu( a, parentId, -1 );
536 void LightApp_Application::createActions()
538 CAM_Application::createActions();
540 SUIT_Desktop* desk = desktop();
541 SUIT_ResourceMgr* resMgr = resourceMgr();
544 createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIcon(),
545 tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
546 Qt::CTRL+Qt::Key_R, desk, false, this, SLOT( onPreferences() ) );
550 // - Help for modules
552 int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
553 createMenu( separator(), helpMenu, -1, 10 );
554 QStringList aModuleList;
555 modules( aModuleList, false );
556 aModuleList.prepend( "GUI" );
557 aModuleList.prepend( "KERNEL" );
559 int id = LightApp_Application::UserID + FIRST_HELP_ID;
562 foreach( aModule, aModuleList ) {
563 if ( aModule.isEmpty() ) // module title (user name)
565 IMap <QString, QString> helpData; // list of help files for the module
566 QString helpSubMenu; // help submenu name (empty if not needed)
567 QString modName = moduleName( aModule ); // module name
568 if ( modName.isEmpty() ) modName = aModule; // for KERNEL and GUI
569 QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName ); // module root dir variable
570 QString modDir = getenv( rootDir.toLatin1().constData() ); // module root dir
572 if (resMgr->hasValue( modName, "documentation" ) )
573 docSection = resMgr->stringValue(modName, "documentation");
574 else if ( resMgr->hasSection( modName + "_documentation" ) )
575 docSection = modName + "_documentation";
576 if ( !docSection.isEmpty() ) {
577 helpSubMenu = resMgr->stringValue( docSection, "sub_menu", "" ).arg( aModule );
578 QStringList listOfParam = resMgr->parameters( docSection );
579 foreach( QString paramName, listOfParam ) {
580 QString valueStr = resMgr->stringValue( docSection, paramName );
581 if ( !valueStr.isEmpty() ) {
582 QFileInfo fi( valueStr );
583 if ( fi.isRelative() && !modDir.isEmpty() )
584 valueStr = Qtx::addSlash( modDir ) + valueStr;
585 if ( QFile::exists( valueStr ) )
586 helpData.insert( paramName.arg( aModule ), valueStr );
591 if ( helpData.isEmpty() && !modDir.isEmpty() ) {
592 QStringList idxLst = QStringList() << modDir << "share" << "doc" << "salome" << "gui" << modName << "index.html";
593 QString indexFile = idxLst.join( QDir::separator() ); // index file
594 if ( QFile::exists( indexFile ) )
595 helpData.insert( tr( "%1 module Users's Guide" ).arg( aModule ), indexFile );
598 IMapConstIterator<QString, QString > fileIt;
599 for ( fileIt = helpData.begin(); fileIt != helpData.end(); fileIt++ ) {
600 QString helpFileName = fileIt.key();
601 // remove all '//' occurances
602 while ( helpFileName.contains( "//" ) )
603 helpFileName.replace( "//", "" );
604 // obtain submenus hierarchy if given
605 QStringList smenus = helpFileName.split( "/" );
606 helpFileName = smenus.last();
608 QAction* a = createAction( id, helpFileName,
609 resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
610 helpFileName, helpFileName,
611 0, desk, false, this, SLOT( onHelpContentsModule() ) );
612 a->setData( fileIt.value() );
613 if ( !helpSubMenu.isEmpty() ) {
614 smenus.prepend( helpSubMenu );
616 // create sub-menus hierarchy
617 int menuId = helpMenu;
618 foreach ( QString subMenu, smenus ) {
619 menuId = createMenu( subMenu, menuId, -1, 0 );
621 createMenu( a, menuId, -1, 0 );
626 // - Additional help items
628 createMenu( separator(), helpMenu, -1, 5 );
630 QStringList addHelpItems = resMgr->parameters( "add_help" );
631 foreach ( QString addHelpItem, addHelpItems ) {
632 QString valueStr = resMgr->stringValue( "add_help", addHelpItem );
633 if ( !valueStr.isEmpty() && QFile::exists( valueStr ) ) {
634 QAction* a = createAction( id, addHelpItem,
635 resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
636 addHelpItem, addHelpItem,
637 0, desk, false, this, SLOT( onHelpContentsModule() ) );
638 a->setData( valueStr );
639 createMenu( a, helpMenu, -1, 5 );
645 static QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), 0 );
646 connect( mru, SIGNAL( activated( const QString& ) ), this, SLOT( onMRUActivated( const QString& ) ) );
647 registerAction( MRUId, mru );
649 // default icon for neutral point ('SALOME' module)
650 QPixmap defIcon = resMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
651 if ( defIcon.isNull() )
652 defIcon = QPixmap( imageEmptyIcon );
654 //! default icon for any module
655 QPixmap modIcon = resMgr->loadPixmap( "LightApp", tr( "APP_MODULE_ICO" ), false );
656 if ( modIcon.isNull() )
657 modIcon = QPixmap( imageEmptyIcon );
660 modules( modList, false );
662 if ( modList.count() > 1 )
664 LightApp_ModuleAction* moduleAction =
665 new LightApp_ModuleAction( tr( "APP_NAME" ), defIcon, desk );
667 QMap<QString, QString> iconMap;
668 moduleIconNames( iconMap );
670 const int iconSize = 20;
672 QStringList::Iterator it;
673 for ( it = modList.begin(); it != modList.end(); ++it )
675 if ( !isLibExists( *it ) )
678 QString modName = moduleName( *it );
680 if ( !isModuleAccessible( *it ) )
684 if ( iconMap.contains( *it ) )
685 iconName = iconMap[*it];
687 QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
691 INFOS ( "\n****************************************************************" << std::endl
692 << "* Icon for " << (*it).toLatin1().constData()
693 << " not found. Using the default one." << std::endl
694 << "****************************************************************" << std::endl );
697 icon = Qtx::scaleIcon( icon, iconSize );
699 moduleAction->insertModule( *it, icon );
702 connect( moduleAction, SIGNAL( moduleActivated( const QString& ) ),
703 this, SLOT( onModuleActivation( const QString& ) ) );
704 registerAction( ModulesListId, moduleAction );
708 int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, MenuWindowId, 100 );
709 int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
711 createAction( CloseId, tr( "TOT_CLOSE" ), QIcon(), tr( "MEN_DESK_CLOSE" ), tr( "PRP_CLOSE" ),
712 Qt::CTRL+Qt::Key_F4, desk, false, this, SLOT( onCloseWindow() ) );
713 createAction( CloseAllId, tr( "TOT_CLOSE_ALL" ), QIcon(), tr( "MEN_DESK_CLOSE_ALL" ), tr( "PRP_CLOSE_ALL" ),
714 0, desk, false, this, SLOT( onCloseAllWindow() ) );
715 createAction( GroupAllId, tr( "TOT_GROUP_ALL" ), QIcon(), tr( "MEN_DESK_GROUP_ALL" ), tr( "PRP_GROUP_ALL" ),
716 0, desk, false, this, SLOT( onGroupAllWindow() ) );
718 createMenu( CloseId, windowMenu, 0, -1 );
719 createMenu( CloseAllId, windowMenu, 0, -1 );
720 createMenu( GroupAllId, windowMenu, 0, -1 );
721 createMenu( separator(), windowMenu, -1, 0 );
723 #ifndef DISABLE_GLVIEWER
724 createActionForViewer( NewGLViewId, newWinMenu, QString::number( 0 ), Qt::ALT+Qt::Key_G );
726 #ifndef DISABLE_PLOT2DVIEWER
727 createActionForViewer( NewPlot2dId, newWinMenu, QString::number( 1 ), Qt::ALT+Qt::Key_P );
729 #ifndef DISABLE_OCCVIEWER
730 createActionForViewer( NewOCCViewId, newWinMenu, QString::number( 2 ), Qt::ALT+Qt::Key_O );
732 #ifndef DISABLE_VTKVIEWER
733 createActionForViewer( NewVTKViewId, newWinMenu, QString::number( 3 ), Qt::ALT+Qt::Key_K );
735 #ifndef DISABLE_QXGRAPHVIEWER
736 createActionForViewer( NewQxSceneViewId, newWinMenu, QString::number( 4 ), Qt::ALT+Qt::Key_S );
738 #ifndef DISABLE_GRAPHICSVIEW
739 createActionForViewer( NewGraphicsViewId, newWinMenu, QString::number( 5 ), Qt::ALT+Qt::Key_R );
741 #ifndef DISABLE_PVVIEWER
742 createActionForViewer( NewPVViewId, newWinMenu, QString::number( 6 ), Qt::ALT+Qt::Key_W );
745 createAction( RenameId, tr( "TOT_RENAME" ), QIcon(), tr( "MEN_DESK_RENAME" ), tr( "PRP_RENAME" ),
746 Qt::ALT+Qt::SHIFT+Qt::Key_R, desk, false, this, SLOT( onRenameWindow() ) );
747 createMenu( RenameId, windowMenu, -1 );
749 int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
750 createMenu( PreferencesId, fileMenu, 50, -1 );
751 createMenu( separator(), fileMenu, -1, 50, -1 );
753 createMenu( separator(), fileMenu, -1, 100, -1 );
754 createMenu( MRUId, fileMenu, 100, -1 );
755 createMenu( separator(), fileMenu, -1, 100, -1 );
757 createAction( StyleId, tr( "TOT_THEME" ), QIcon(), tr( "MEN_DESK_THEME" ), tr( "PRP_THEME" ),
758 0, desk, false, this, SLOT( onStylePreferences() ) );
760 createAction( FullScreenId, tr( "TOT_FULLSCREEN" ), QIcon(), tr( "MEN_DESK_FULLSCREEN" ), tr( "PRP_FULLSCREEN" ),
761 Qt::Key_F11, desk, false, this, SLOT( onFullScreen() ) );
764 int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1 );
765 createMenu( separator(), viewMenu, -1, 20, -1 );
766 createMenu( StyleId, viewMenu, 20, -1 );
767 createMenu( FullScreenId, viewMenu, 20, -1 );
769 int modTBar = createTool( tr( "INF_TOOLBAR_MODULES" ), // title (language-dependant)
770 QString( "SalomeModules" ) ); // name (language-independant)
771 createTool( ModulesListId, modTBar );
774 /*!On module activation action.*/
775 void LightApp_Application::onModuleActivation( const QString& modName )
777 // Force user to create/open a study before module activation
778 QMap<QString, QString> iconMap;
779 moduleIconNames( iconMap );
780 QPixmap icon = resourceMgr()->loadPixmap( moduleName( modName ), iconMap[ modName ], false );
782 icon = resourceMgr()->loadPixmap( "LightApp", tr( "APP_MODULE_BIG_ICO" ), false ); // default icon for any module
784 bool cancelled = false;
786 while ( !modName.isEmpty() && !activeStudy() && !cancelled ){
787 LightApp_ModuleDlg aDlg( desktop(), modName, icon );
788 QMap<int, QString> opmap = activateModuleActions();
789 for ( QMap<int, QString>::ConstIterator it = opmap.begin(); it != opmap.end(); ++it )
790 aDlg.addButton( it.value(), it.key() );
792 int res = aDlg.exec();
794 // some operation is selected
795 moduleActionSelected( res );
799 putInfo( tr("INF_CANCELLED") );
801 LightApp_ModuleAction* moduleAction =
802 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
804 moduleAction->setActiveModule( QString() );
810 activateModule( modName );
813 /*!Default module activation.*/
814 QString LightApp_Application::defaultModule() const
816 QStringList aModuleNames;
817 modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration
818 //! If there's the one and only module --> activate it automatically
819 //! TODO: Possible improvement - default module can be taken from preferences
820 return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" );
823 /*!On new window slot.*/
824 void LightApp_Application::onNewWindow()
826 const QObject* obj = sender();
827 if ( !obj || !obj->inherits( "QAction" ) )
831 int id = actionId( (QAction*)obj );
834 #ifndef DISABLE_GLVIEWER
836 type = GLViewer_Viewer::Type();
839 #ifndef DISABLE_PLOT2DVIEWER
841 type = Plot2d_Viewer::Type();
844 #ifndef DISABLE_OCCVIEWER
846 type = OCCViewer_Viewer::Type();
849 #ifndef DISABLE_VTKVIEWER
851 type = VTKViewer_Viewer::Type();
854 #ifndef DISABLE_QXGRAPHVIEWER
855 case NewQxSceneViewId:
856 type = QxScene_Viewer::Type();
859 #ifndef DISABLE_GRAPHICSVIEW
860 case NewGraphicsViewId:
861 type = GraphicsView_Viewer::Type();
864 #ifndef DISABLE_PVVIEWER
866 type = PVViewer_Viewer::Type();
871 if ( !type.isEmpty() )
872 createViewManager( type );
876 SLOT: Creates new document
878 void LightApp_Application::onNewDoc()
880 #ifdef SINGLE_DESKTOP
881 if ( !checkExistingDoc() )
885 //asl: fix for 0020515
886 saveDockWindowsState();
888 CAM_Application::onNewDoc();
892 SLOT: Opens new document
894 void LightApp_Application::onOpenDoc()
896 SUIT_Study* study = activeStudy();
898 #ifdef SINGLE_DESKTOP
899 if ( !checkExistingDoc() )
903 CAM_Application::onOpenDoc();
905 if ( !study ) // new study will be create in THIS application
908 updateViewManagers();
913 SLOT: Opens new document.
914 \param aName - name of file
916 bool LightApp_Application::onOpenDoc( const QString& aName )
918 #ifdef SINGLE_DESKTOP
919 if ( !checkExistingDoc() )
923 saveDockWindowsState();
925 // We should take mru action first because this application instance can be deleted later.
926 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
928 bool res = CAM_Application::onOpenDoc( aName );
933 mru->insert( aName );
935 mru->remove( aName );
941 SLOT: Displays "About" message box
943 void LightApp_Application::onHelpAbout()
945 LightApp_AboutDlg dlg( applicationName(), applicationVersion(), desktop() );
950 Private SLOT: Called on selection is changed
951 Dispatchs active module that selection is changed
953 void LightApp_Application::onSelection()
955 onSelectionChanged();
957 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
958 ((LightApp_Module*)activeModule())->selectionChanged();
963 \param study - SUIT_Study.
965 void LightApp_Application::setActiveStudy( SUIT_Study* study )
967 CAM_Application::setActiveStudy( study );
971 Enables/Disables menu items and toolbar buttons. Rebuild menu
973 void LightApp_Application::updateCommandsStatus()
975 CAM_Application::updateCommandsStatus();
978 #ifndef DISABLE_GLVIEWER
979 a = action( NewGLViewId );
981 a->setEnabled( activeStudy() );
984 #ifndef DISABLE_PLOT2DVIEWER
985 a = action( NewPlot2dId );
987 a->setEnabled( activeStudy() );
990 #ifndef DISABLE_OCCVIEWER
991 a = action( NewOCCViewId );
993 a->setEnabled( activeStudy() );
996 #ifndef DISABLE_VTKVIEWER
997 a = action( NewVTKViewId );
999 a->setEnabled( activeStudy() );
1002 #ifndef DISABLE_QXGRAPHVIEWER
1003 a = action( NewQxSceneViewId );
1005 a->setEnabled( activeStudy() );
1008 #ifndef DISABLE_GRAPHICSVIEW
1009 a = action( NewGraphicsViewId );
1011 a->setEnabled( activeStudy() );
1014 #ifndef DISABLE_PVVIEWER
1015 a = action( NewPVViewId );
1017 a->setEnabled( activeStudy() );
1023 Runs system command in separate thread
1025 class RunBrowser: public QThread
1028 RunBrowser( LightApp_Application* app,
1029 const QString& theApp,
1030 const QString& theParams,
1031 const QString& theHelpFile,
1032 const QString& theContext = QString() )
1034 myParams( theParams ),
1035 myContext( theContext ),
1039 //For the external browser always specify 'file://' protocol,
1040 //because some WEB browsers (for example Mozilla Firefox) can't open local file without protocol.
1041 myHelpFile = QString("file://%1").arg( QFileInfo( theHelpFile ).canonicalFilePath() );
1046 if ( !myApp.isEmpty() && !myHelpFile.isEmpty()) {
1047 QString aCommand = QString( "%1 %2 \"%3%4\"" ).arg( myApp, myParams, myHelpFile, myContext.isEmpty() ? QString("") : QString( "#%1" ).arg( myContext ) );
1049 QProcess* proc = new QProcess();
1051 proc->start( aCommand );
1052 if ( !proc->waitForStarted() ) {
1053 SALOME_CustomEvent* ce2000 = new SALOME_CustomEvent( 2000 );
1054 QString* msg = new QString( QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).arg( myApp, myHelpFile ) );
1055 ce2000->setData( msg );
1056 QApplication::postEvent( myLApp, ce2000 );
1067 LightApp_Application* myLApp;
1071 SLOT: Displays help contents for choosen module
1073 void LightApp_Application::onHelpContentsModule()
1075 const QAction* a = (QAction*) sender();
1076 QString helpFile = a->data().toString();
1077 if ( helpFile.isEmpty() ) return;
1079 SUIT_ResourceMgr* resMgr = resourceMgr();
1082 platform = "winapplication";
1084 platform = "application";
1086 QString anApp = resMgr->stringValue("ExternalBrowser", platform);
1088 QString quote("\"");
1089 anApp.prepend( quote );
1090 anApp.append( quote );
1092 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
1093 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1095 if( useExtBrowser ) {
1096 if ( !anApp.isEmpty() ) {
1097 RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile );
1101 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1102 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1103 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1105 showPreferences( tr( "PREF_APP" ) );
1109 QStringList parameters;
1110 parameters << QString( "--language=%1" ).arg( resMgr->stringValue( "language", "language" ) );
1111 parameters << helpFile;
1112 QProcess::startDetached( "HelpBrowser", parameters );
1117 SLOT: Displays help contents for choosen dialog
1119 void LightApp_Application::onHelpContextModule( const QString& theComponentName,
1120 const QString& theFileName,
1121 const QString& theContext )
1123 QString fileName = theFileName;
1124 QString context = theContext;
1125 if ( !QFile::exists( fileName ) && theContext.isEmpty() ) {
1126 // context might be passed within theFileName argument
1127 QStringList comps = fileName.split("#");
1128 if ( comps.count() > 1 ) {
1129 context = comps.last();
1131 fileName = comps.join("#");
1135 QString homeDir = "";
1136 if ( !theComponentName.isEmpty() ) {
1137 QString dir = getenv( ( theComponentName + "_ROOT_DIR" ).toLatin1().constData() );
1138 if ( !dir.isEmpty() )
1139 homeDir = Qtx::addSlash( Qtx::addSlash( dir ) +
1140 Qtx::addSlash( "share" ) +
1141 Qtx::addSlash( "doc" ) +
1142 Qtx::addSlash( "salome" ) +
1143 Qtx::addSlash( "gui" ) +
1144 Qtx::addSlash( theComponentName ) );
1147 QString helpFile = QFileInfo( homeDir + fileName ).absoluteFilePath();
1148 SUIT_ResourceMgr* resMgr = resourceMgr();
1151 platform = "winapplication";
1153 platform = "application";
1155 QString anApp = resMgr->stringValue("ExternalBrowser", platform);
1157 QString quote("\"");
1158 anApp.prepend( quote );
1159 anApp.append( quote );
1162 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1165 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
1167 if ( !anApp.isEmpty() ) {
1168 RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile, context );
1172 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1173 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1174 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1175 showPreferences( tr( "PREF_APP" ) );
1179 QStringList parameters;
1180 parameters << QString( "--language=%1" ).arg( resMgr->stringValue( "language", "language" ) );
1181 parameters << QString( "%1#%2" ).arg( helpFile ).arg( context );
1182 QProcess::startDetached( "HelpBrowser", parameters );
1187 Sets enable or disable some actions on selection changed.
1189 void LightApp_Application::onSelectionChanged()
1191 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
1192 bool canCopy = m ? m->canCopy() : false;
1193 bool canPaste = m ? m->canPaste() : false;
1195 action( EditCopyId )->setEnabled(canCopy);
1196 action( EditPasteId )->setEnabled(canPaste);
1199 QWidget* LightApp_Application::dockWindow( const int id ) const
1202 if ( myWin.contains( id ) )
1207 QDockWidget* LightApp_Application::windowDock( QWidget* wid ) const
1212 QDockWidget* dock = 0;
1213 QWidget* w = wid->parentWidget();
1214 while ( w && !dock )
1216 dock = ::qobject_cast<QDockWidget*>( w );
1217 w = w->parentWidget();
1222 void LightApp_Application::insertDockWindow( const int id, QWidget* wid )
1227 if ( wid != dockWindow( id ) )
1228 removeDockWindow( id );
1230 myWin.insert( id, wid );
1232 QtxDockWidget* dock = new QtxDockWidget( true, desktop() );
1233 connect( dock, SIGNAL( destroyed( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
1235 dock->setFeatures( QDockWidget::AllDockWidgetFeatures );
1236 dock->setObjectName( wid->objectName().isEmpty() ? QString( "window_%1" ).arg( id ) :
1237 QString( "%1Dock" ).arg( wid->objectName() ) );
1238 dock->setWidget( wid );
1240 QKeySequence accel = wid->property( "shortcut" ).value<QKeySequence>();
1241 if ( !accel.isEmpty() )
1242 dock->toggleViewAction()->setShortcut( accel );
1247 void LightApp_Application::removeDockWindow( const int id )
1249 QWidget* wid = dockWindow( id );
1255 QDockWidget* dock = windowDock( wid );
1259 dock->setWidget( 0 );
1260 wid->setParent( 0 );
1261 wid->setVisible( false );
1265 void LightApp_Application::placeDockWindow( const int id, Qt::DockWidgetArea place )
1267 QDockWidget* dock = windowDock( dockWindow( id ) );
1268 if ( dock && desktop() ) {
1269 desktop()->addDockWidget( place, dock );
1270 QtxDockAction* a = qobject_cast<QtxDockAction*>( action( ViewWindowsId ) );
1271 if ( a ) a->update();
1277 \param flag - key for window
1278 \param studyId - study id
1279 Flag used how identificator of window in windows list.
1281 QWidget* LightApp_Application::getWindow( const int flag, const int )
1283 QWidget* wid = dockWindow( flag );
1285 insertDockWindow( flag, wid = createWindow( flag ) );
1287 QMap<int, int> winMap;
1288 currentWindows( winMap );
1289 if ( winMap.contains( flag ) )
1290 placeDockWindow( flag, (Qt::DockWidgetArea)winMap[flag] );
1296 \return Object Browser
1298 SUIT_DataBrowser* LightApp_Application::objectBrowser()
1300 return qobject_cast<SUIT_DataBrowser*>( dockWindow( WT_ObjectBrowser ) );
1306 LogWindow* LightApp_Application::logWindow()
1308 return qobject_cast<LogWindow*>( dockWindow( WT_LogWindow ) );
1311 #ifndef DISABLE_PYCONSOLE
1313 This returns the python console integrated to the GUI. Depending
1314 when you request the python console, this function could return
1315 null. Then the optional parameter force (default to false) can be
1316 set to force the creation of the python console if it is not done
1318 \param force - if true, the pythonConsole is created if it does not exist yet
1319 \return Python Console
1321 PyConsole_Console* LightApp_Application::pythonConsole(const bool force)
1323 QWidget* wid = dockWindow( WT_PyConsole );
1324 if ( !wid && force==true) {
1325 wid = getWindow(WT_PyConsole);
1327 return qobject_cast<PyConsole_Console*>( wid );
1332 Updates object browser and maybe data models
1333 \param updateModels - if it is true, then data models are updated
1335 void LightApp_Application::updateObjectBrowser( const bool updateModels )
1337 // update existing data models
1340 const bool isAutoUpdate = objectBrowser() ? objectBrowser()->autoUpdate() : true;
1341 if ( objectBrowser() )
1342 objectBrowser()->setAutoUpdate( false );
1344 LightApp_Study* study = dynamic_cast<LightApp_Study*>(activeStudy());
1346 CAM_Study::ModelList dm_list;
1347 study->dataModels( dm_list );
1348 QListIterator<CAM_DataModel*> it( dm_list );
1349 while ( it.hasNext() ) {
1350 CAM_DataModel* camDM = it.next();
1351 if ( camDM && camDM->inherits( "LightApp_DataModel" ) )
1352 ((LightApp_DataModel*)camDM)->update();
1356 if( objectBrowser() )
1357 objectBrowser()->setAutoUpdate( isAutoUpdate );
1360 if ( objectBrowser() ) {
1361 objectBrowser()->updateGeometry();
1362 objectBrowser()->updateTree( 0, false );
1369 LightApp_Preferences* LightApp_Application::preferences() const
1371 return preferences( false );
1375 \return first view manager of some type
1376 \param vmType - type of view manager
1377 \param create - is it necessary to create view manager in case, when there is no manager of such type
1379 SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, const bool create )
1381 SUIT_ViewManager* aVM = viewManager( vmType );
1382 SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
1384 if ( anActiveVM && anActiveVM->getType() == vmType )
1387 if ( aVM && create )
1389 if ( !aVM->getActiveView() )
1392 aVM->getActiveView()->setFocus();
1395 aVM = createViewManager( vmType );
1401 Creates view manager of some type
1402 \param vmType - type of view manager
1404 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType )
1406 SUIT_ResourceMgr* resMgr = resourceMgr();
1408 SUIT_ViewManager* viewMgr = 0;
1409 #ifndef DISABLE_GLVIEWER
1410 if( vmType == GLViewer_Viewer::Type() )
1412 viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() );
1413 new LightApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
1416 #ifndef DISABLE_PLOT2DVIEWER
1417 if( vmType == Plot2d_Viewer::Type() )
1419 viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
1421 #ifndef DISABLE_SALOMEOBJECT
1422 SPlot2d_Viewer* v = new SPlot2d_Viewer();
1424 new LightApp_Plot2dSelector( v, mySelMgr );
1426 vm = new Plot2d_Viewer();
1428 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1429 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
1432 Plot2d_ViewFrame* frame = wnd->getViewFrame();
1433 frame->setBackgroundColor( resMgr->colorValue( "Plot2d", "Background", frame->backgroundColor() ) );
1437 #ifndef DISABLE_QXGRAPHVIEWER
1438 if( vmType == QxScene_Viewer::Type() )
1440 viewMgr = new QxScene_ViewManager( activeStudy(), desktop() );
1441 QxScene_Viewer* vm = new QxScene_Viewer();
1442 viewMgr->setViewModel( vm );
1443 //QxScene_ViewWindow* wnd = dynamic_cast<QxScene_ViewWindow*>( viewMgr->getActiveView() );
1446 #ifndef DISABLE_GRAPHICSVIEW
1447 if( vmType == GraphicsView_Viewer::Type() )
1449 viewMgr = new GraphicsView_ViewManager( activeStudy(), desktop() );
1450 new LightApp_GVSelector( (GraphicsView_Viewer*)viewMgr->getViewModel(), mySelMgr );
1453 #ifndef DISABLE_PVVIEWER
1454 if( vmType == PVViewer_Viewer::Type() )
1456 viewMgr = new PVViewer_ViewManager( activeStudy(), desktop(), logWindow() );
1459 #ifndef DISABLE_OCCVIEWER
1460 if( vmType == OCCViewer_Viewer::Type() )
1462 viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
1463 OCCViewer_Viewer* vm;
1464 #ifndef DISABLE_SALOMEOBJECT
1465 vm = new SOCC_Viewer();
1467 vm = new OCCViewer_Viewer( true );
1469 vm->setBackground( OCCViewer_ViewFrame::TOP_LEFT,
1470 resMgr->backgroundValue( "OCCViewer", "xz_background", vm->background(OCCViewer_ViewFrame::TOP_LEFT) ) );
1471 vm->setBackground( OCCViewer_ViewFrame::TOP_RIGHT,
1472 resMgr->backgroundValue( "OCCViewer", "yz_background", vm->background(OCCViewer_ViewFrame::TOP_RIGHT) ) );
1473 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_LEFT,
1474 resMgr->backgroundValue( "OCCViewer", "xy_background", vm->background(OCCViewer_ViewFrame::BOTTOM_LEFT) ) );
1475 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_RIGHT,
1476 resMgr->backgroundValue( "OCCViewer", "background", vm->background(OCCViewer_ViewFrame::MAIN_VIEW) ) );
1478 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1479 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ));
1480 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1481 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1482 vm->enablePreselection( resMgr->booleanValue( "OCCViewer", "enable_preselection", vm->isPreselectionEnabled() ) );
1483 vm->enableSelection( resMgr->booleanValue( "OCCViewer", "enable_selection", vm->isSelectionEnabled() ) );
1485 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1486 new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
1489 #ifndef DISABLE_VTKVIEWER
1490 #ifndef DISABLE_SALOMEOBJECT
1491 if ( vmType == SVTK_Viewer::Type() )
1493 if ( vmType == VTKViewer_Viewer::Type() )
1496 #ifndef DISABLE_SALOMEOBJECT
1497 viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
1498 SVTK_Viewer* vm = dynamic_cast<SVTK_Viewer*>( viewMgr->getViewModel() );
1501 vm->setProjectionMode( resMgr->integerValue( "VTKViewer", "projection_mode", vm->projectionMode() ) );
1502 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1503 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1504 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ) );
1505 vm->setStaticTrihedronVisible( resMgr->booleanValue( "3DViewer", "show_static_trihedron", vm->isStaticTrihedronVisible() ) );
1506 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1507 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1508 vm->setPreSelectionMode(resMgr->integerValue( "VTKViewer", "preselection", vm->preSelectionMode() ) );
1509 vm->enableSelection( resMgr->booleanValue( "VTKViewer", "enable_selection", vm->isSelectionEnabled() ) );
1510 vm->setIncrementalSpeed( resMgr->integerValue( "VTKViewer", "speed_value", vm->incrementalSpeed() ),
1511 resMgr->integerValue( "VTKViewer", "speed_mode", vm->incrementalSpeedMode() ) );
1512 vm->setSpacemouseButtons( resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", vm->spacemouseBtn(1) ),
1513 resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", vm->spacemouseBtn(2) ),
1514 resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", vm->spacemouseBtn(3) ) );
1515 new LightApp_VTKSelector( vm, mySelMgr );
1518 viewMgr = new VTKViewer_ViewManager( activeStudy(), desktop() );
1519 VTKViewer_Viewer* vm = dynamic_cast<VTKViewer_Viewer*>( viewMgr->getViewModel() );
1521 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1529 addViewManager( viewMgr );
1530 SUIT_ViewWindow* viewWin = viewMgr->createViewWindow();
1532 if ( viewWin && desktop() ) {
1533 viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1534 viewWin->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1540 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, QWidget* w )
1542 SUIT_ResourceMgr* resMgr = resourceMgr();
1544 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
1546 new LightApp_WgViewModel( vmType, w ) );
1547 vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
1549 addViewManager( vm );
1550 SUIT_ViewWindow* vw = vm->createViewWindow();
1551 if ( vw && desktop() ) {
1552 vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1553 vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1556 if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
1557 myUserWmTypes << vmType;
1562 SUIT_ViewManager* LightApp_Application::createViewManager( SUIT_ViewModel* theModel )
1564 SUIT_ResourceMgr* resMgr = resourceMgr();
1566 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
1570 QString vmType = vm->getType();
1572 vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
1574 addViewManager( vm );
1575 SUIT_ViewWindow* vw = vm->createViewWindow();
1576 if ( vw && desktop() ) {
1577 vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1578 vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1581 if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
1582 myUserWmTypes << vmType;
1588 SLOT: Removes view manager from application
1590 void LightApp_Application::onCloseView( SUIT_ViewManager* theVM )
1592 removeViewManager( theVM );
1596 Protected SLOT: On study created.
1597 \param theStudy - just created study
1599 void LightApp_Application::onStudyCreated( SUIT_Study* theStudy )
1601 SUIT_DataObject* aRoot = 0;
1602 if ( theStudy && theStudy->root() )
1604 aRoot = theStudy->root();
1605 //aRoot->setName( tr( "DATA_MODELS" ) );
1608 getWindow( WT_ObjectBrowser );
1610 loadDockWindowsState();
1612 if ( objectBrowser() )
1613 objectBrowser()->setRoot( aRoot );
1615 activateModule( defaultModule() );
1617 if ( objectBrowser() )
1618 objectBrowser()->openLevels();
1620 #ifndef DISABLE_PYCONSOLE
1621 if( pythonConsole() )
1622 getPyInterp()->initStudy();
1627 Protected SLOT: On study opened.
1628 \param theStudy - just opened study
1630 void LightApp_Application::onStudyOpened( SUIT_Study* theStudy )
1632 SUIT_DataObject* aRoot = 0;
1633 if ( theStudy && theStudy->root() )
1635 aRoot = theStudy->root();
1639 getWindow( WT_ObjectBrowser );
1641 loadDockWindowsState();
1643 if ( objectBrowser() )
1644 objectBrowser()->setRoot( aRoot );
1646 activateModule( defaultModule() );
1648 if ( objectBrowser() )
1649 objectBrowser()->openLevels();
1651 #ifndef DISABLE_PYCONSOLE
1652 if( pythonConsole() )
1653 getPyInterp()->initStudy();
1659 /*!Protected SLOT. On study saved.*/
1660 void LightApp_Application::onStudySaved( SUIT_Study* s )
1662 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
1664 mru->insert( s->studyName() );
1669 /*!Protected SLOT. On study closed.*/
1670 void LightApp_Application::onStudyClosed( SUIT_Study* s )
1673 disconnect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
1674 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
1677 // stop auto-save timer
1678 myAutoSaveTimer->stop();
1680 // Bug 10396: clear selection
1681 mySelMgr->clearSelected();
1683 // Bug 12944: emit signal only after clear selection
1686 activateModule( "" );
1689 /*!Protected SLOT.On desktop activated.*/
1690 void LightApp_Application::onDesktopActivated()
1692 CAM_Application::onDesktopActivated();
1693 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>(activeModule());
1695 aModule->studyActivated();
1698 void LightApp_Application::studyOpened( SUIT_Study* s )
1700 CAM_Application::studyOpened( s );
1703 updateViewManagers();
1706 void LightApp_Application::studySaved( SUIT_Study* s )
1708 CAM_Application::studyOpened( s );
1709 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1710 if ( aResMgr && activeStudy() ) {
1711 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
1712 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
1716 void LightApp_Application::studyCreated( SUIT_Study* s )
1718 CAM_Application::studyCreated( s );
1721 updateViewManagers();
1724 /*!Gets file filter.
1725 *\retval QString "(*.bin)"
1727 QString LightApp_Application::getFileFilter() const
1735 Shows file dialog and return user selected file name
1737 QString LightApp_Application::getFileName( bool open, const QString& initial, const QString& filters,
1738 const QString& caption, QWidget* parent )
1742 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1743 return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
1746 /*! Gets directory*/
1747 QString LightApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
1751 return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true );
1754 /*! Get open file names*/
1755 QStringList LightApp_Application::getOpenFileNames( const QString& initial, const QString& filters,
1756 const QString& caption, QWidget* parent )
1760 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1761 return SUIT_FileDlg::getOpenFileNames( parent, initial, fls, caption, true );
1764 /*!Private SLOT. Update object browser.*/
1765 void LightApp_Application::onRefresh()
1767 updateObjectBrowser( true );
1770 /*!Private SLOT. Support drag-and-drop operation.*/
1771 void LightApp_Application::onDropped( const QList<SUIT_DataObject*>& objects, SUIT_DataObject* parent, int row, Qt::DropAction action )
1773 LightApp_DataObject* parentObj = dynamic_cast<LightApp_DataObject*>( parent );
1777 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>( parentObj->module() );
1779 aModule->dropObjects( objects, parentObj, row, action );
1782 /*!Private SLOT. On preferences.*/
1783 void LightApp_Application::onPreferences()
1785 showPreferences( activeModule() ? activeModule()->moduleName() : tr( "PREF_CATEGORY_SALOME" ) );
1788 /*!Private SLOT. On preferences.*/
1789 void LightApp_Application::showPreferences( const QString& itemText )
1791 QApplication::setOverrideCursor( Qt::WaitCursor );
1793 LightApp_PreferencesDlg* prefDlg = new LightApp_PreferencesDlg( preferences( true ), desktop());
1795 QApplication::restoreOverrideCursor();
1800 preferences()->activateItem( itemText );
1802 if ( ( prefDlg->exec() == QDialog::Accepted || prefDlg->isSaved() ) && resourceMgr() )
1805 resourceMgr()->setValue( "desktop", "geometry", desktop()->storeGeometry() );
1806 resourceMgr()->save();
1809 shortcutMgr()->updateShortcuts();
1815 /*!Protected SLOT. On preferences changed.*/
1816 void LightApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param )
1818 LightApp_Module* sMod = 0;
1819 CAM_Module* mod = module( modName );
1820 if ( mod && mod->inherits( "LightApp_Module" ) )
1821 sMod = (LightApp_Module*)mod;
1824 sMod->preferencesChanged( section, param );
1826 preferencesChanged( section, param );
1827 // emit signal to allow additional preferences changing processing
1828 emit preferenceChanged( modName, section, param );
1831 /*!Remove all windows from study.*/
1832 void LightApp_Application::beforeCloseDoc( SUIT_Study* s )
1834 saveDockWindowsState();
1836 if ( SUIT_DataBrowser* ob = objectBrowser() )
1839 CAM_Application::beforeCloseDoc( s );
1842 /*!Update actions.*/
1843 void LightApp_Application::updateActions()
1845 updateCommandsStatus();
1851 SUIT_Study* LightApp_Application::createNewStudy()
1853 LightApp_Application::lastStudyId++;
1855 LightApp_Study* aStudy = new LightApp_Study( this );
1857 // Set up processing of major study-related events
1858 connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
1859 connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
1860 connect( aStudy, SIGNAL( saved ( SUIT_Study* ) ), this, SLOT( onStudySaved ( SUIT_Study* ) ) );
1861 connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
1867 Creates window by flag.
1868 \param flag - identificator of window type
1870 QWidget* LightApp_Application::createWindow( const int flag )
1874 SUIT_ResourceMgr* resMgr = resourceMgr();
1876 if ( flag == WT_ObjectBrowser )
1878 SUIT_DataBrowser* ob = new SUIT_DataBrowser( new LightApp_DataObject(), desktop() );
1879 ob->setObjectName( "objectBrowser" );
1880 ob->setSortMenuEnabled( true );
1881 ob->setAutoUpdate( true );
1882 if ( resMgr->hasValue( "ObjectBrowser", "auto_hide_search_tool" ) )
1883 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
1885 //ob->setAutoOpenLevel( 1 ); // commented by ASV as a fix to bug IPAL10107
1886 ob->setWindowTitle( tr( "OBJECT_BROWSER" ) );
1887 connect( ob, SIGNAL( requestUpdate() ), this, SLOT( onRefresh() ) );
1889 QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
1890 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
1891 treeModel->setSearcher( this );
1892 treeModel->registerColumn( 0, EntryCol, LightApp_DataObject::EntryId );
1893 treeModel->setAppropriate( EntryCol, Qtx::Toggled );
1895 // Mantis issue 0020136: Drag&Drop in OB
1896 SUIT_ProxyModel* proxyModel = dynamic_cast<SUIT_ProxyModel*>(treeModel);
1898 connect( proxyModel, SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
1899 this, SLOT( onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
1902 // temporary commented
1904 OB_ListView* ob_list = dynamic_cast<OB_ListView*>( const_cast<QListView*>( ob->listView() ) );
1906 ob_list->setColumnMaxWidth( 0, desktop()->width()/4 );
1909 // Create OBSelector
1910 new LightApp_OBSelector( ob, mySelMgr );
1912 ob->treeView()->header()->setResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
1913 ob->treeView()->header()->moveSection(SUIT_DataObject::NameId,SUIT_DataObject::VisibilityId);
1914 ob->treeView()->setColumnWidth(SUIT_DataObject::VisibilityId, VISIBILITY_COLUMN_WIDTH);
1915 ob->setProperty( "shortcut", QKeySequence( "Alt+Shift+O" ) );
1917 ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1919 #ifndef DISABLE_PYCONSOLE
1920 else if ( flag == WT_PyConsole )
1922 PyConsole_Console* pyCons = new PyConsole_EnhConsole( desktop(), getPyInterp() );
1923 pyCons->setObjectName( "pythonConsole" );
1924 pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
1925 pyCons->setFont(resourceMgr()->fontValue( "PyConsole", "font" ));
1926 pyCons->setIsShowBanner(resourceMgr()->booleanValue( "PyConsole", "show_banner", true ));
1927 pyCons->setProperty( "shortcut", QKeySequence( "Alt+Shift+P" ) );
1930 pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1933 else if ( flag == WT_LogWindow )
1935 LogWindow* logWin = new LogWindow( desktop() );
1936 logWin->setObjectName( "logWindow" );
1937 logWin->setWindowTitle( tr( "LOG_WINDOW" ) );
1938 logWin->setProperty( "shortcut", QKeySequence( "Alt+Shift+L" ) );
1940 logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1946 \return default windows( Object Browser, Python Console )
1947 Adds to map \a aMap.
1949 void LightApp_Application::defaultWindows( QMap<int, int>& aMap ) const
1951 #ifndef DISABLE_PYCONSOLE
1952 aMap.insert( WT_PyConsole, Qt::BottomDockWidgetArea );
1954 if ( activeStudy() ) {
1955 aMap.insert( WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1956 // aMap.insert( WT_LogWindow, Qt::DockBottom );
1960 /*!Default view managers*/
1961 void LightApp_Application::defaultViewManagers( QStringList& ) const
1967 \return preferences.
1968 Create preferences, if \a crt = true.
1970 LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const
1975 LightApp_Application* that = (LightApp_Application*)this;
1977 bool toCreate = !_prefs_ && crt;
1980 _prefs_ = new LightApp_Preferences( resourceMgr() );
1981 that->createPreferences( _prefs_ );
1984 that->myPrefs = _prefs_;
1986 connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
1987 this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ), Qt::UniqueConnection );
1988 connect( myPrefs, SIGNAL( resetToDefaults() ),
1989 this, SIGNAL( preferenceResetToDefaults() ), Qt::UniqueConnection );
1994 SUIT_ResourceMgr* resMgr = resourceMgr();
1996 QList<SUIT_Application*> appList = SUIT_Session::session()->applications();
1997 for ( QList<SUIT_Application*>::iterator appIt = appList.begin(); appIt != appList.end(); ++appIt )
1999 LightApp_Application* app = ::qobject_cast<LightApp_Application*>( *appIt );
2003 QStringList modNameList;
2004 app->modules( modNameList, false );
2006 QMap<QString, QString> iconMap;
2007 app->moduleIconNames( iconMap );
2009 for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it )
2011 if ( !app->isLibExists( *it ) || _prefs_->hasModule( *it ) )
2014 int modId = _prefs_->addPreference( *it );
2015 if ( iconMap.contains( *it ) )
2016 _prefs_->setItemIcon( modId, Qtx::scaleIcon( resMgr->loadPixmap( moduleName( *it ), iconMap[*it], false ), 20 ) );
2020 app->modules( modList );
2021 QListIterator<CAM_Module*> itr( modList );
2022 while ( itr.hasNext() )
2024 LightApp_Module* mod = 0;
2026 CAM_Module* anItem = itr.next();
2027 if ( anItem->inherits( "LightApp_Module" ) )
2028 mod = (LightApp_Module*)anItem;
2030 if ( mod && !_prefs_->hasModule( mod->moduleName() ) )
2032 _prefs_->addPreference( mod->moduleName() );
2033 mod->createPreferences();
2034 that->emptyPreferences( mod->moduleName() );
2038 _prefs_->setItemProperty( "info", tr( "PREFERENCES_NOT_LOADED" ) );
2044 Adds new module to application
2046 void LightApp_Application::moduleAdded( CAM_Module* mod )
2048 CAM_Application::moduleAdded( mod );
2050 LightApp_Module* lightMod = 0;
2051 if ( mod && mod->inherits( "LightApp_Module" ) )
2052 lightMod = (LightApp_Module*)mod;
2054 if ( myPrefs && lightMod && !myPrefs->hasModule( lightMod->moduleName() ))
2056 myPrefs->addPreference( mod->moduleName() );
2057 lightMod->createPreferences();
2058 emptyPreferences( mod->moduleName() );
2062 void LightApp_Application::emptyPreferences( const QString& modName )
2064 QtxPreferenceItem* item = myPrefs->findItem( modName, true );
2065 if ( !item || !item->isEmpty() )
2068 // printf( "---------------------> Modify for empty module.\n" );
2070 QtxPagePrefFrameItem* frm = new QtxPagePrefFrameItem( item->title(), item->parentItem() );
2071 frm->setIcon( item->icon() );
2072 frm->setStretch( false );
2073 item->parentItem()->insertItem( frm, item );
2074 new QtxPagePrefLabelItem( Qt::AlignCenter, tr( "PREFERENCES_NOT_SUPPORTED" ).arg( modName ), frm );
2081 void LightApp_Application::createPreferences( LightApp_Preferences* pref )
2086 QStringList aValuesList;
2087 QList<QVariant> anIndicesList;
2091 // . Top-level "SALOME" preferences group <<start>>
2092 int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
2093 pref->setItemIcon( salomeCat, Qtx::scaleIcon( resourceMgr()->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false ), 20 ) );
2095 // .. "General" preferences tab <<start>>
2096 int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat );
2098 // ... "Language" group <<start>>
2099 int langGroup = pref->addPreference( tr( "PREF_GROUP_LANGUAGE" ), genTab );
2100 pref->setItemProperty( "columns", 2, langGroup );
2101 // .... -> application language
2102 int curLang = pref->addPreference( tr( "PREF_CURRENT_LANGUAGE" ), langGroup,
2103 LightApp_Preferences::Selector, "language", "language" );
2104 QStringList aLangs = SUIT_Session::session()->resourceMgr()->stringValue( "language", "languages", "en" ).split( "," );
2105 QList<QVariant> aIcons;
2106 foreach ( QString aLang, aLangs ) {
2107 aIcons << QPixmap( QString( ":/images/%1" ).arg( aLang ) );
2109 pref->setItemProperty( "strings", aLangs, curLang );
2110 pref->setItemProperty( "icons", aIcons, curLang );
2112 int curLocale = pref->addPreference( tr( "PREF_CURRENT_LOCALE" ), langGroup,
2113 LightApp_Preferences::Bool, "language", "locale" );
2114 // ... "Language" group <<end>>
2116 // ... "Look and feel" group <<start>>
2117 int lookGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), genTab );
2118 pref->setItemProperty( "columns", 2, lookGroup );
2119 // .... -> show splash-screen
2120 pref->addPreference( tr( "PREF_SHOW_SPLASH" ), lookGroup, LightApp_Preferences::Bool, "launch", "splash" );
2121 // .... -> opaque resize
2122 pref->addPreference( tr( "PREF_OPAQUE_RESIZE" ), lookGroup, LightApp_Preferences::Bool, "desktop", "opaque_resize" );
2123 // .... -> drop-down buttons
2124 pref->addPreference( tr( "PREF_DROP_DOWN_BUTTONS" ), lookGroup, LightApp_Preferences::Bool, "viewers", "drop_down_buttons" );
2125 // ... "Look and feel" group <<end>>
2127 // ... "Study properties" group <<start>>
2128 int studyGroup = pref->addPreference( tr( "PREF_GROUP_STUDY" ), genTab );
2129 pref->setItemProperty( "columns", 2, studyGroup );
2130 // .... -> multi-file save
2131 pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "multi_file" );
2132 // .... -> ascii save mode
2133 pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" );
2134 // .... -> store windows geometry
2135 pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" );
2136 pref->addPreference( "", studyGroup, LightApp_Preferences::Space );
2137 pref->addPreference( tr( "PREF_STORE_TOOL_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_tool_positions" );
2138 // .... -> auto-save
2139 int autoSaveInterval = pref->addPreference( tr( "PREF_AUTO_SAVE" ), studyGroup,
2140 LightApp_Preferences::IntSpin, "Study", "auto_save_interval" );
2141 pref->setItemProperty( "min", 0, autoSaveInterval );
2142 pref->setItemProperty( "max", 1440, autoSaveInterval );
2143 pref->setItemProperty( "special", tr( "PREF_AUTO_SAVE_DISABLED" ), autoSaveInterval );
2144 // ... "Study properties" group <<end>>
2146 // ... "Help browser" group <<start>>
2147 int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab, LightApp_Preferences::Auto, "ExternalBrowser", "use_external_browser");
2149 QString platform = "winapplication";
2151 QString platform = "application";
2153 // .... -> browser application
2154 int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, LightApp_Preferences::File, "ExternalBrowser", platform );
2155 pref->setItemProperty( "mode", Qtx::PT_OpenFile, apppref );
2156 // .... -> browser parameters
2157 pref->addPreference( tr( "PREF_PARAM" ), extgroup, LightApp_Preferences::String, "ExternalBrowser", "parameters" );
2158 // ... "Help browser" group <<end>>
2160 // ... "Python console properties" group <<start>>
2161 int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab );
2163 pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, LightApp_Preferences::Font, "PyConsole", "font" );
2164 // .... -> show banner
2165 pref->addPreference( tr( "PREF_SHOW_BANNER" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "show_banner" );
2166 // ... "Python console properties" group <<end>>
2168 // ... "MRU" preferences group <<start>>
2169 int mruGroup = pref->addPreference( tr( "PREF_GROUP_MRU" ), genTab, LightApp_Preferences::Auto, "MRU", "show_mru" );
2170 pref->setItemProperty( "columns", 4, mruGroup );
2171 // number of MRU items
2172 int mruVisCount = pref->addPreference( tr( "PREF_MRU_VISIBLE_COUNT" ), mruGroup, LightApp_Preferences::IntSpin,
2173 "MRU", "visible_count" );
2174 pref->setItemProperty( "min", 0, mruVisCount );
2175 pref->setItemProperty( "max", 100, mruVisCount );
2177 int mruLinkType = pref->addPreference( tr( "PREF_MRU_LINK_TYPE" ), mruGroup, LightApp_Preferences::Selector,
2178 "MRU", "link_type" );
2179 aValuesList.clear();
2180 anIndicesList.clear();
2181 aValuesList << tr("PREF_MRU_LINK_AUTO") << tr("PREF_MRU_LINK_SHORT") << tr("PREF_MRU_LINK_FULL");
2182 anIndicesList << 0 << 1 << 2 ;
2183 pref->setItemProperty( "strings", aValuesList, mruLinkType );
2184 pref->setItemProperty( "indexes", anIndicesList, mruLinkType );
2185 // ... "MRU" preferences group <<end>>
2186 // .. "General" preferences tab <<end>>
2188 // .. "3D viewer" group <<start>>
2189 int Viewer3DGroup = pref->addPreference( tr( "PREF_GROUP_3DVIEWER" ), salomeCat );
2190 // ... -> navigation mode
2191 int vtkStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), Viewer3DGroup,
2192 LightApp_Preferences::Selector, "3DViewer", "navigation_mode" );
2193 aValuesList.clear();
2194 anIndicesList.clear();
2195 aValuesList << tr("PREF_STANDARD_STYLE") << tr("PREF_KEYFREE_STYLE");
2196 anIndicesList << 0 << 1;
2197 pref->setItemProperty( "strings", aValuesList, vtkStyleMode );
2198 pref->setItemProperty( "indexes", anIndicesList, vtkStyleMode );
2199 // ... -> zooming mode
2200 int occZoomingStyleMode = pref->addPreference( tr( "PREF_ZOOMING" ), Viewer3DGroup,
2201 LightApp_Preferences::Selector, "3DViewer", "zooming_mode" );
2202 aValuesList.clear();
2203 anIndicesList.clear();
2204 aValuesList << tr("PREF_ZOOMING_AT_CENTER") << tr("PREF_ZOOMING_AT_CURSOR");
2205 anIndicesList << 0 << 1;
2206 pref->setItemProperty( "strings", aValuesList, occZoomingStyleMode );
2207 pref->setItemProperty( "indexes", anIndicesList, occZoomingStyleMode );
2208 // ... "Trihedron" group <<start>>
2209 int occTriGroup = pref->addPreference( tr( "PREF_TRIHEDRON" ), Viewer3DGroup );
2210 pref->setItemProperty( "columns", 2, occTriGroup );
2211 // .... -> trihedron size
2212 int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occTriGroup,
2213 LightApp_Preferences::DblSpin, "3DViewer", "trihedron_size" );
2214 pref->setItemProperty( "min", 1.0E-06, occTS );
2215 pref->setItemProperty( "max", 1000, occTS );
2216 // .... -> relative size of trihedron
2217 pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "relative_size" );
2218 // .... -> show static trihedron
2219 pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "show_static_trihedron" );
2220 // ... "Trihedron" group <<end>>
2221 // .. "3D viewer" group <<end>>
2225 #ifndef DISABLE_OCCVIEWER
2226 // .. "OCC viewer" group <<start>>
2227 int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), salomeCat );
2229 // ... "Background" group <<start>>
2230 int bgGroup = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup );
2231 // pref->setItemProperty( "columns", 2, bgGroup );
2232 aValuesList.clear();
2233 anIndicesList.clear();
2235 formats = OCCViewer_Viewer::backgroundData( aValuesList, idList, txtList );
2236 foreach( int gid, idList ) anIndicesList << gid;
2237 // .... -> 3D viewer background
2238 bgId = pref->addPreference( tr( "PREF_3DVIEWER_BACKGROUND" ), bgGroup,
2239 LightApp_Preferences::Background, "OCCViewer", "background" );
2240 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2241 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2242 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2243 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2244 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2245 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2246 pref->setItemProperty( "custom_enabled", false, bgId );
2247 pref->setItemProperty( "image_formats", formats, bgId );
2248 // .... -> XZ viewer background
2249 bgId = pref->addPreference( tr( "PREF_XZVIEWER_BACKGROUND" ), bgGroup,
2250 LightApp_Preferences::Background, "OCCViewer", "xz_background" );
2251 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2252 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2253 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2254 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2255 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2256 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2257 pref->setItemProperty( "custom_enabled", false, bgId );
2258 pref->setItemProperty( "image_formats", formats, bgId );
2259 // .... -> YZ viewer background
2260 bgId = pref->addPreference( tr( "PREF_YZVIEWER_BACKGROUND" ), bgGroup,
2261 LightApp_Preferences::Background, "OCCViewer", "yz_background" );
2262 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2263 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2264 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2265 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2266 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2267 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2268 pref->setItemProperty( "custom_enabled", false, bgId );
2269 pref->setItemProperty( "image_formats", formats, bgId );
2270 // .... -> XY viewer background
2271 bgId = pref->addPreference( tr( "PREF_XYVIEWER_BACKGROUND" ), bgGroup,
2272 LightApp_Preferences::Background, "OCCViewer", "xy_background" );
2273 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2274 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2275 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2276 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2277 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2278 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2279 pref->setItemProperty( "custom_enabled", false, bgId );
2280 pref->setItemProperty( "image_formats", formats, bgId );
2281 // ... "Background" group <<end>>
2284 // ... "Selection" group <<start>>
2285 int occSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), occGroup );
2286 pref->setItemProperty( "columns", 2, occSelectionGroup );
2287 // .... -> enable preselection
2288 pref->addPreference( tr( "PREF_ENABLE_PRESELECTION" ), occSelectionGroup,
2289 LightApp_Preferences::Bool, "OCCViewer", "enable_preselection" );
2290 // .... -> enable selection
2291 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), occSelectionGroup,
2292 LightApp_Preferences::Bool, "OCCViewer", "enable_selection" );
2293 // ... "Selection" group <<end>>
2295 // ... -> empty frame (for layout) <<start>>
2296 int occGen = pref->addPreference( "", occGroup, LightApp_Preferences::Frame );
2297 pref->setItemProperty( "margin", 0, occGen );
2298 pref->setItemProperty( "columns", 2, occGen );
2299 // ... -> empty frame (for layout) <<end>>
2300 // .. "OCC viewer" group <<end>>
2303 #ifndef DISABLE_VTKVIEWER
2304 // .. "VTK viewer" group <<start>>
2305 int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), salomeCat ); //viewTab
2307 // ... -> empty frame (for layout) <<start>>
2308 int vtkGen = pref->addPreference( "", vtkGroup, LightApp_Preferences::Frame );
2309 //pref->setItemProperty( "columns", 2, vtkGen );
2310 // .... -> projection mode
2311 int vtkProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), vtkGen,
2312 LightApp_Preferences::Selector, "VTKViewer", "projection_mode" );
2313 aValuesList.clear();
2314 anIndicesList.clear();
2315 aValuesList << tr("PREF_ORTHOGRAPHIC") << tr("PREF_PERSPECTIVE");
2316 anIndicesList << 0 << 1;
2317 pref->setItemProperty( "strings", aValuesList, vtkProjMode );
2318 pref->setItemProperty( "indexes", anIndicesList, vtkProjMode );
2319 // .... -> background
2320 aValuesList.clear();
2321 anIndicesList.clear();
2323 #ifndef DISABLE_SALOMEOBJECT
2324 formats = SVTK_Viewer::backgroundData( aValuesList, idList, txtList );
2326 foreach( int gid, idList ) anIndicesList << gid;
2327 bgId = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGen,
2328 LightApp_Preferences::Background, "VTKViewer", "background" );
2329 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2330 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2331 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2332 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2333 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2334 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2335 pref->setItemProperty( "custom_enabled", false, bgId );
2336 #ifndef DISABLE_SALOMEOBJECT
2337 pref->setItemProperty( "image_formats", formats, bgId );
2339 // .... -> speed increment
2340 int vtkSpeed = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED" ), vtkGen,
2341 LightApp_Preferences::IntSpin, "VTKViewer", "speed_value" );
2342 pref->setItemProperty( "min", 1, vtkSpeed );
2343 pref->setItemProperty( "max", 1000, vtkSpeed );
2344 // .... -> speed mode
2345 int vtkSpeedMode = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED_MODE" ), vtkGen,
2346 LightApp_Preferences::Selector, "VTKViewer", "speed_mode" );
2347 aValuesList.clear();
2348 anIndicesList.clear();
2349 aValuesList << tr("PREF_ARITHMETIC") << tr("PREF_GEOMETRICAL");
2350 anIndicesList << 0 << 1;
2351 pref->setItemProperty( "strings", aValuesList, vtkSpeedMode );
2352 pref->setItemProperty( "indexes", anIndicesList, vtkSpeedMode );
2354 // ... "Selection" group <<start>>
2355 int vtkSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), vtkGroup );
2356 pref->setItemProperty( "columns", 2, vtkSelectionGroup );
2357 // .... -> preselection
2358 int vtkPreselection = pref->addPreference( tr( "PREF_PRESELECTION" ), vtkSelectionGroup,
2359 LightApp_Preferences::Selector, "VTKViewer", "preselection" );
2360 aValuesList.clear();
2361 anIndicesList.clear();
2362 aValuesList << tr("PREF_PRESELECTION_STANDARD") << tr("PREF_PRESELECTION_DYNAMIC") << tr("PREF_PRESELECTION_DISABLED");
2363 anIndicesList << 0 << 1 << 2;
2364 pref->setItemProperty( "strings", aValuesList, vtkPreselection );
2365 pref->setItemProperty( "indexes", anIndicesList, vtkPreselection );
2366 // .... -> enable selection
2367 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), vtkSelectionGroup, LightApp_Preferences::Bool, "VTKViewer", "enable_selection" );
2368 // ... "Selection" group <<end>>
2370 // ... -> empty frame (for layout) <<end>>
2372 // ... space mouse sub-group <<start>>
2373 int vtkSM = pref->addPreference( tr( "PREF_FRAME_SPACEMOUSE" ), vtkGroup, LightApp_Preferences::GroupBox );
2374 //pref->setItemProperty( "columns", 2, vtkSM );
2375 // .... -> decrease speed increment
2376 int spacemousePref1 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_1" ), vtkSM,
2377 LightApp_Preferences::Selector, "VTKViewer",
2378 "spacemouse_func1_btn" );
2379 // .... -> increase speed increment
2380 int spacemousePref2 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_2" ), vtkSM,
2381 LightApp_Preferences::Selector, "VTKViewer",
2382 "spacemouse_func2_btn" );
2383 // .... -> dominant / combined switch
2384 int spacemousePref3 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_3" ), vtkSM,
2385 LightApp_Preferences::Selector, "VTKViewer",
2386 "spacemouse_func5_btn" ); //
2387 aValuesList.clear();
2388 anIndicesList.clear();
2389 aValuesList << tr( "PREF_SPACEMOUSE_BTN_1" ) << tr( "PREF_SPACEMOUSE_BTN_2" ) << tr( "PREF_SPACEMOUSE_BTN_3" );
2390 aValuesList << tr( "PREF_SPACEMOUSE_BTN_4" ) << tr( "PREF_SPACEMOUSE_BTN_5" ) << tr( "PREF_SPACEMOUSE_BTN_6" );
2391 aValuesList << tr( "PREF_SPACEMOUSE_BTN_7" ) << tr( "PREF_SPACEMOUSE_BTN_8" ) << tr( "PREF_SPACEMOUSE_BTN_*" );
2392 aValuesList << tr( "PREF_SPACEMOUSE_BTN_10" ) << tr( "PREF_SPACEMOUSE_BTN_11" );
2393 anIndicesList << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11;
2394 pref->setItemProperty( "strings", aValuesList, spacemousePref1 );
2395 pref->setItemProperty( "indexes", anIndicesList, spacemousePref1 );
2396 pref->setItemProperty( "strings", aValuesList, spacemousePref2 );
2397 pref->setItemProperty( "indexes", anIndicesList, spacemousePref2 );
2398 pref->setItemProperty( "strings", aValuesList, spacemousePref3 );
2399 pref->setItemProperty( "indexes", anIndicesList, spacemousePref3 );
2400 // ... space mouse sub-group <<end>>
2402 // ... avi recording sub-group <<start>>
2403 int vtkRec = pref->addPreference( tr( "PREF_FRAME_RECORDING" ), vtkGroup, LightApp_Preferences::GroupBox );
2404 pref->setItemProperty( "columns", 2, vtkRec );
2405 // .... -> recording mode
2406 int modePref = pref->addPreference( tr( "PREF_RECORDING_MODE" ), vtkRec,
2407 LightApp_Preferences::Selector, "VTKViewer", "recorder_mode" );
2408 aValuesList.clear();
2409 anIndicesList.clear();
2410 aValuesList << tr( "PREF_SKIPPED_FRAMES" ) << tr( "PREF_ALL_DISLPAYED_FRAMES" );
2411 anIndicesList << 0 << 1;
2412 pref->setItemProperty( "strings", aValuesList, modePref );
2413 pref->setItemProperty( "indexes", anIndicesList, modePref );
2415 int fpsPref = pref->addPreference( tr( "PREF_FPS" ), vtkRec,
2416 LightApp_Preferences::DblSpin, "VTKViewer", "recorder_fps" );
2417 pref->setItemProperty( "min", 0.1, fpsPref );
2418 pref->setItemProperty( "max", 100, fpsPref );
2420 int qualityPref = pref->addPreference( tr( "PREF_QUALITY" ), vtkRec,
2421 LightApp_Preferences::IntSpin, "VTKViewer", "recorder_quality" );
2422 pref->setItemProperty( "min", 1, qualityPref );
2423 pref->setItemProperty( "max", 100, qualityPref );
2424 // .... -> progressive mode
2425 pref->addPreference( tr( "PREF_PROGRESSIVE" ), vtkRec,
2426 LightApp_Preferences::Bool, "VTKViewer", "recorder_progressive" );
2427 // ... avi recording sub-group <<end>>
2429 // ... group names sub-group <<start>>
2430 int vtkGN = pref->addPreference( tr( "PREF_FRAME_GROUP_NAMES" ), vtkGroup,
2431 LightApp_Preferences::GroupBox, "VTKViewer", "show_group_names" );
2432 pref->setItemProperty( "columns", 2, vtkGN );
2433 // .... -> text color
2434 pref->addPreference( tr( "PREF_GROUP_NAMES_TEXT_COLOR" ), vtkGN,
2435 LightApp_Preferences::Color, "VTKViewer", "group_names_text_color" );
2436 // .... -> transparency
2437 int transPref = pref->addPreference( tr( "PREF_GROUP_NAMES_TRANSPARENCY" ), vtkGN,
2438 LightApp_Preferences::DblSpin, "VTKViewer", "group_names_transparency" );
2439 pref->setItemProperty( "min", 0.0, transPref );
2440 pref->setItemProperty( "max", 1.0, transPref );
2441 pref->setItemProperty( "step", 0.1, transPref );
2442 // ... -> group names sub-group <<end>>
2443 // .. "VTK viewer" group <<end>>
2446 // .. "Plot2d viewer" group <<start>>
2447 int plot2dGroup = pref->addPreference( tr( "PREF_GROUP_PLOT2DVIEWER" ), salomeCat ); //viewTab
2448 //pref->setItemProperty( "columns", 2, plot2dGroup );
2450 // ... -> background
2451 pref->addPreference( tr( "PREF_VIEWER_BACKGROUND_COLOR" ), plot2dGroup,
2452 LightApp_Preferences::Color, "Plot2d", "Background" );
2453 // ... -> selection color
2454 pref->addPreference( tr( "PREF_VIEWER_SELECTION" ), plot2dGroup,
2455 LightApp_Preferences::Color, "Plot2d", "SelectionColor" );
2457 // ... "Viewer" group <<start>>
2458 int plot2dViewerGroup = pref->addPreference( tr( "PREF_GROUP_VIEWER" ), plot2dGroup );
2460 // .... -> curve type
2461 int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dViewerGroup,
2462 LightApp_Preferences::Selector, "Plot2d", "CurveType" );
2463 aValuesList.clear();
2464 anIndicesList.clear();
2465 aValuesList << tr("PREF_POINTS") << tr("PREF_LINES") << tr("PREF_SPLINE");
2466 anIndicesList << 0 << 1 << 2 ;
2467 pref->setItemProperty( "strings", aValuesList, curveType );
2468 pref->setItemProperty( "indexes", anIndicesList, curveType );
2469 // .... -> marker size
2470 int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dViewerGroup,
2471 LightApp_Preferences::IntSpin, "Plot2d", "MarkerSize" );
2472 pref->setItemProperty( "min", 0, markerSize );
2473 pref->setItemProperty( "max", 100, markerSize );
2474 // .... -> horizontal scaling mode
2475 int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dViewerGroup,
2476 LightApp_Preferences::Selector, "Plot2d", "HorScaleMode" );
2477 aValuesList.clear();
2478 anIndicesList.clear();
2479 aValuesList << tr("PREF_LINEAR") << tr("PREF_LOGARITHMIC");
2480 anIndicesList << 0 << 1 ;
2481 pref->setItemProperty( "strings", aValuesList, horScale );
2482 pref->setItemProperty( "indexes", anIndicesList, horScale );
2483 // .... -> vertical scaling mode
2484 int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dViewerGroup,
2485 LightApp_Preferences::Selector, "Plot2d", "VerScaleMode" );
2486 pref->setItemProperty( "strings", aValuesList, verScale );
2487 pref->setItemProperty( "indexes", anIndicesList, verScale );
2489 // .... -> errors/deviation colot
2490 pref->addPreference( tr( "PREF_DEVIATION_COLOR" ), plot2dViewerGroup,
2491 LightApp_Preferences::Color, "Plot2d", "DeviationMarkerColor" );
2492 // .... -> deviation markers line size
2493 int deviationMarkerLw = pref->addPreference( tr( "PREF_DEVIATION_MARKER_LW" ), plot2dViewerGroup,
2494 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerLineWidth" );
2495 pref->setItemProperty( "min", 1, deviationMarkerLw );
2496 pref->setItemProperty( "max", 5, deviationMarkerLw );
2497 // .... -> deviation markers tick mark size
2498 int deviationMarkerTs = pref->addPreference( tr( "PREF_DEVIATION_MARKER_TS" ), plot2dViewerGroup,
2499 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerTickSize" );
2500 pref->setItemProperty( "min", 1, deviationMarkerTs );
2501 pref->setItemProperty( "max", 5, deviationMarkerTs );
2502 // .... "Viewer" group <<end>>
2504 // ... "Legend" group <<start>>
2505 int plot2dLegendGroup = pref->addPreference( tr( "PREF_GROUP_LEGEND" ), plot2dGroup );
2507 // .... -> show legend
2508 pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dLegendGroup,
2509 LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
2510 // .... -> legend position
2511 int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dLegendGroup,
2512 LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
2513 aValuesList.clear();
2514 anIndicesList.clear();
2515 aValuesList << tr("PREF_LEFT") << tr("PREF_RIGHT") << tr("PREF_TOP") << tr("PREF_BOTTOM");
2516 anIndicesList << 0 << 1 << 2 << 3 ;
2517 pref->setItemProperty( "strings", aValuesList, legendPosition );
2518 pref->setItemProperty( "indexes", anIndicesList, legendPosition );
2519 // .... -> Symbol type
2520 int legendSymbolType = pref->addPreference( tr( "PREF_LEGEND_SYMBOL_TYPE" ), plot2dLegendGroup,
2521 LightApp_Preferences::Selector, "Plot2d", "LegendSymbolType" );
2522 aValuesList.clear();
2523 anIndicesList.clear();
2524 aValuesList << tr("PREF_MARKER_ON_LINE") << tr("PREF_MARKER_ABOVE_LINE");
2525 anIndicesList << 0 << 1 ;
2526 pref->setItemProperty( "strings", aValuesList, legendSymbolType );
2527 pref->setItemProperty( "indexes", anIndicesList, legendSymbolType );
2528 // .... -> legend font
2529 pref->addPreference( tr( "PREF_LEGEND_FONT" ), plot2dLegendGroup, LightApp_Preferences::Font, "Plot2d", "LegendFont" );
2530 // ... -> font color
2531 pref->addPreference( tr( "PREF_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "LegendFontColor" );
2532 // ... -> selection font color
2533 pref->addPreference( tr( "PREF_SELECTED_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "SelectedLegendFontColor" );
2534 // ... "Legend" group <<end>>
2536 // .. "Plot2d viewer" group <<end>>
2538 // .. "Directories" preferences tab <<start>>
2539 int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat );
2540 // ... --> quick directories list
2541 int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab );
2542 pref->addPreference( tr( "" ), dirGroup,
2543 LightApp_Preferences::DirList, "FileDlg", "QuickDirList" );
2544 // .. "Directories" preferences tab <<end>>
2546 // .. "Object browser" preferences tab <<start>>
2547 int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
2549 // ... "Search tool" group <<start>>
2550 int stGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SEARCH_TOOL" ), obTab );
2551 // .... --> auto-hide
2552 pref->addPreference( tr( "PREF_AUTO_HIDE_SEARCH_TOOL" ), stGroup, LightApp_Preferences::Bool,
2553 "ObjectBrowser", "auto_hide_search_tool" );
2554 // ... "Search tool" group <<end>>
2556 // ... "Object browser settings" group <<start>>
2557 int objSetGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), obTab );
2558 pref->setItemProperty( "columns", 2, objSetGroup );
2559 // .... -> auto size first column
2560 pref->addPreference( tr( "PREF_AUTO_SIZE_FIRST" ), objSetGroup, LightApp_Preferences::Bool,
2561 "ObjectBrowser", "auto_size_first" );
2562 // .... -> auto size other columns
2563 pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool,
2564 "ObjectBrowser", "auto_size" );
2565 // .... -> resize columns on expand item
2566 pref->addPreference( tr( "PREF_RESIZE_ON_EXPAND_ITEM" ), objSetGroup, LightApp_Preferences::Bool,
2567 "ObjectBrowser", "resize_on_expand_item" );
2568 // .... -> browse to published object
2569 int browsePublished = pref->addPreference( tr( "PREF_BROWSE_TO_THE_PUBLISHED_OBJECT" ), objSetGroup, LightApp_Preferences::Selector,
2570 "ObjectBrowser", "browse_published_object" );
2571 aValuesList.clear();
2572 anIndicesList.clear();
2573 aValuesList << tr( "PREF_BROWSE_NEVER" ) << tr( "PREF_BROWSE_AFTER_APPLY_AND_CLOSE_ONLY" ) << tr( "PREF_BROWSE_ALWAYS" );
2574 anIndicesList << BP_Never << BP_ApplyAndClose << BP_Always;
2575 pref->setItemProperty( "strings", aValuesList, browsePublished );
2576 pref->setItemProperty( "indexes", anIndicesList, browsePublished );
2577 // ... "Object browser settings" group <<end>>
2578 // .. "Object browser" preferences tab <<end>>
2580 // .. "Shortcuts" preferences tab <<start>>
2581 int shortcutTab = pref->addPreference( tr( "PREF_TAB_SHORTCUTS" ), salomeCat );
2582 // ... "Shortcuts settings" group <<start>>
2583 int shortcutGroup = pref->addPreference( tr( "PREF_GROUP_SHORTCUTS" ), shortcutTab );
2584 pref->addPreference( tr( "" ), shortcutGroup,
2585 LightApp_Preferences::ShortcutTree, "shortcuts" );
2586 // ... "Shortcuts settings" group <<end>>
2587 // .. "Shortcuts" preferences tab <<end>>
2588 // . Top-level "SALOME" preferences group <<end>>
2594 Changes appearance of application according to changed preferences
2595 \param sec - section
2596 \param param - name of changed parameter
2598 void LightApp_Application::preferencesChanged( const QString& sec, const QString& param )
2600 SUIT_ResourceMgr* resMgr = resourceMgr();
2604 if ( sec == "viewers" && param == "drop_down_buttons" )
2606 ViewManagerList vmlist = viewManagers();
2607 foreach( SUIT_ViewManager* vm, vmlist )
2609 QVector<SUIT_ViewWindow*> vwlist = vm->getViews();
2610 foreach( SUIT_ViewWindow* vw, vwlist )
2611 if ( vw ) vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
2615 if ( sec == QString( "3DViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )))
2617 double sz = resMgr->doubleValue( sec, "trihedron_size", -1 );
2618 bool relative = resMgr->booleanValue( sec, "relative_size", true );
2619 QList<SUIT_ViewManager*> lst;
2620 #ifndef DISABLE_OCCVIEWER
2621 viewManagers( OCCViewer_Viewer::Type(), lst );
2622 QListIterator<SUIT_ViewManager*> itOCC( lst );
2623 while ( itOCC.hasNext() && sz >= 0 )
2625 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2626 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2629 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2630 occVM->setTrihedronSize( sz, relative );
2631 occVM->getAISContext()->UpdateCurrentViewer();
2634 #ifndef DISABLE_VTKVIEWER
2635 #ifndef DISABLE_SALOMEOBJECT
2636 viewManagers( SVTK_Viewer::Type(), lst );
2637 QListIterator<SUIT_ViewManager*> itVTK( lst );
2638 while ( itVTK.hasNext() && sz >= 0 )
2640 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2641 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2644 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2647 vtkVM->setTrihedronSize( sz, relative );
2655 if ( sec == QString( "3DViewer" ) && param == QString( "show_static_trihedron" ) )
2657 bool isVisible = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
2658 QList<SUIT_ViewManager*> lst;
2659 #ifndef DISABLE_OCCVIEWER
2660 viewManagers( OCCViewer_Viewer::Type(), lst );
2661 QListIterator<SUIT_ViewManager*> itOCC( lst );
2662 while ( itOCC.hasNext() )
2664 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2665 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2668 OCCViewer_Viewer* occVM = dynamic_cast<OCCViewer_Viewer*>( vm );
2671 occVM->setStaticTrihedronDisplayed( isVisible );
2675 #ifndef DISABLE_VTKVIEWER
2676 #ifndef DISABLE_SALOMEOBJECT
2677 viewManagers( SVTK_Viewer::Type(), lst );
2678 QListIterator<SUIT_ViewManager*> itVTK( lst );
2679 while ( itVTK.hasNext() )
2681 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2682 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2685 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2688 vtkVM->setStaticTrihedronVisible( isVisible );
2696 if ( sec == QString( "3DViewer" ) && param == QString( "navigation_mode" ) )
2698 int mode = resMgr->integerValue( "3DViewer", "navigation_mode", 0 );
2699 QList<SUIT_ViewManager*> lst;
2700 #ifndef DISABLE_OCCVIEWER
2701 viewManagers( OCCViewer_Viewer::Type(), lst );
2702 QListIterator<SUIT_ViewManager*> itOCC( lst );
2703 while ( itOCC.hasNext() )
2705 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2706 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2709 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2710 occVM->setInteractionStyle( mode );
2713 #ifndef DISABLE_VTKVIEWER
2714 #ifndef DISABLE_SALOMEOBJECT
2715 viewManagers( SVTK_Viewer::Type(), lst );
2716 QListIterator<SUIT_ViewManager*> itVTK( lst );
2717 while ( itVTK.hasNext() )
2719 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2720 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2723 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2724 if( vtkVM ) vtkVM->setInteractionStyle( mode );
2730 #ifndef DISABLE_OCCVIEWER
2731 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_preselection" ) )
2733 bool isToEnablePreselection = resMgr->booleanValue( "OCCViewer", "enable_preselection", true );
2734 QList<SUIT_ViewManager*> lst;
2735 viewManagers( OCCViewer_Viewer::Type(), lst );
2736 QListIterator<SUIT_ViewManager*> it( lst );
2737 while ( it.hasNext() )
2739 SUIT_ViewModel* vm = it.next()->getViewModel();
2740 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2743 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2744 occVM->enablePreselection( isToEnablePreselection );
2749 #ifndef DISABLE_OCCVIEWER
2750 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_selection" ) )
2752 bool isToEnableSelection = resMgr->booleanValue( "OCCViewer", "enable_selection", true );
2753 QList<SUIT_ViewManager*> lst;
2754 viewManagers( OCCViewer_Viewer::Type(), lst );
2755 QListIterator<SUIT_ViewManager*> it( lst );
2756 while ( it.hasNext() )
2758 SUIT_ViewModel* vm = it.next()->getViewModel();
2759 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2762 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2763 occVM->enableSelection( isToEnableSelection );
2768 if ( sec == QString( "3DViewer" ) && param == QString( "zooming_mode" ) )
2770 int mode = resMgr->integerValue( "3DViewer", "zooming_mode", 0 );
2771 QList<SUIT_ViewManager*> lst;
2772 #ifndef DISABLE_OCCVIEWER
2773 viewManagers( OCCViewer_Viewer::Type(), lst );
2774 QListIterator<SUIT_ViewManager*> itOCC( lst );
2775 while ( itOCC.hasNext() )
2777 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2778 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2781 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2782 occVM->setZoomingStyle( mode );
2785 #ifndef DISABLE_VTKVIEWER
2786 #ifndef DISABLE_SALOMEOBJECT
2787 viewManagers( SVTK_Viewer::Type(), lst );
2788 QListIterator<SUIT_ViewManager*> itVTK( lst );
2789 while ( itVTK.hasNext() )
2791 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2792 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2795 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2796 if( vtkVM ) vtkVM->setZoomingStyle( mode );
2802 #ifndef DISABLE_VTKVIEWER
2803 if ( sec == QString( "VTKViewer" ) && (param == QString( "speed_value" ) || param == QString( "speed_mode" )) )
2805 int speed = resMgr->integerValue( "VTKViewer", "speed_value", 10 );
2806 int mode = resMgr->integerValue( "VTKViewer", "speed_mode", 0 );
2807 QList<SUIT_ViewManager*> lst;
2808 #ifndef DISABLE_SALOMEOBJECT
2809 viewManagers( SVTK_Viewer::Type(), lst );
2810 QListIterator<SUIT_ViewManager*> it( lst );
2811 while ( it.hasNext() )
2813 SUIT_ViewModel* vm = it.next()->getViewModel();
2814 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2817 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2818 if( vtkVM ) vtkVM->setIncrementalSpeed( speed, mode );
2824 #ifndef DISABLE_VTKVIEWER
2825 if ( sec == QString( "VTKViewer" ) && param == QString( "projection_mode" ) )
2827 int mode = resMgr->integerValue( "VTKViewer", "projection_mode", 0 );
2828 QList<SUIT_ViewManager*> lst;
2829 #ifndef DISABLE_SALOMEOBJECT
2830 viewManagers( SVTK_Viewer::Type(), lst );
2831 QListIterator<SUIT_ViewManager*> it( lst );
2832 while ( it.hasNext() )
2834 SUIT_ViewModel* vm = it.next()->getViewModel();
2835 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2838 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2839 if( vtkVM ) vtkVM->setProjectionMode( mode );
2845 #ifndef DISABLE_VTKVIEWER
2846 if ( sec == QString( "VTKViewer" ) && param == QString( "preselection" ) )
2848 int mode = resMgr->integerValue( "VTKViewer", "preselection", 0 );
2849 QList<SUIT_ViewManager*> lst;
2850 #ifndef DISABLE_SALOMEOBJECT
2851 viewManagers( SVTK_Viewer::Type(), lst );
2852 QListIterator<SUIT_ViewManager*> it( lst );
2853 while ( it.hasNext() )
2855 SUIT_ViewModel* vm = it.next()->getViewModel();
2856 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2859 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2860 if( vtkVM ) vtkVM->setPreSelectionMode( mode );
2866 #ifndef DISABLE_VTKVIEWER
2867 if ( sec == QString( "VTKViewer" ) && param == QString( "enable_selection" ) )
2869 bool isToEnableSelection = resMgr->booleanValue( "VTKViewer", "enable_selection", true );
2870 QList<SUIT_ViewManager*> lst;
2871 #ifndef DISABLE_SALOMEOBJECT
2872 viewManagers( SVTK_Viewer::Type(), lst );
2873 QListIterator<SUIT_ViewManager*> it( lst );
2874 while ( it.hasNext() )
2876 SUIT_ViewModel* vm = it.next()->getViewModel();
2877 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2880 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2881 if( vtkVM ) vtkVM->enableSelection( isToEnableSelection );
2887 #ifndef DISABLE_VTKVIEWER
2888 if ( sec == QString( "VTKViewer" ) && (param == QString( "spacemouse_func1_btn" ) ||
2889 param == QString( "spacemouse_func2_btn" ) ||
2890 param == QString( "spacemouse_func5_btn" ) ) )
2892 int btn1 = resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", 1 );
2893 int btn2 = resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", 2 );
2894 int btn3 = resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", 9 );
2895 QList<SUIT_ViewManager*> lst;
2896 #ifndef DISABLE_SALOMEOBJECT
2897 viewManagers( SVTK_Viewer::Type(), lst );
2898 QListIterator<SUIT_ViewManager*> it( lst );
2899 while ( it.hasNext() )
2901 SUIT_ViewModel* vm = it.next()->getViewModel();
2902 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2905 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2906 if( vtkVM ) vtkVM->setSpacemouseButtons( btn1, btn2, btn3 );
2911 if( sec=="ObjectBrowser" )
2913 SUIT_DataBrowser* ob = objectBrowser();
2917 if ( param=="auto_size_first" )
2919 bool autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
2920 ob->setAutoSizeFirstColumn( autoSizeFirst );
2921 if ( autoSizeFirst )
2922 ob->adjustFirstColumnWidth();
2924 else if ( param=="auto_size" ) {
2925 bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
2926 ob->setAutoSizeColumns(autoSize);
2928 ob->adjustColumnsWidth();
2930 else if ( param=="resize_on_expand_item" ) {
2931 bool resizeOnExpandItem = resMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
2932 ob->setResizeOnExpandItem(resizeOnExpandItem);
2934 else if ( param == "auto_hide_search_tool" ) {
2935 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
2941 if( param=="auto_save_interval" ) {
2942 myAutoSaveTimer->stop();
2943 int autoSaveInterval = resMgr->integerValue( "Study", "auto_save_interval", 0 );
2944 if ( activeStudy() && autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
2948 #ifndef DISABLE_PYCONSOLE
2949 if( sec=="PyConsole" && pythonConsole() )
2951 if ( param=="font" ) {
2952 pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) );
2954 else if ( param=="show_banner" ) {
2955 pythonConsole()->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
2962 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
2964 if ( param == "visible_count" )
2965 mru->setVisibleCount( resMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
2966 else if ( param == "max_count" )
2967 mru->setHistoryCount( resMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
2968 else if ( param == "insert_mode" )
2969 mru->setInsertMode( resMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
2970 else if ( param == "link_type" )
2971 mru->setLinkType( resMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
2972 else if ( param == "show_clear" )
2973 mru->setClearPossible( resMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
2974 else if ( param == "show_mru" )
2975 mru->setVisible( resMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
2978 if ( sec == "language" && param == "language" )
2980 SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LANG_CHANGED" ) );
2982 if ( sec == "language" && param == "locale")
2984 SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LOCALE_CHANGED" ) );
2986 if ( sec == "desktop" && param == "opaque_resize" ) {
2987 bool opaqueResize = resMgr->booleanValue( "desktop", "opaque_resize", false );
2988 QMainWindow::DockOptions dopts = desktop()->dockOptions();
2989 if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
2990 else dopts &= ~QMainWindow::AnimatedDocks;
2991 desktop()->setDockOptions( dopts );
2992 desktop()->setOpaqueResize( opaqueResize );
2993 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
2994 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
2997 #ifndef DISABLE_PLOT2DVIEWER
2998 QList<SUIT_ViewManager*> lst;
2999 viewManagers( Plot2d_Viewer::Type(), lst );
3000 QListIterator<SUIT_ViewManager*> itPlot2d( lst );
3001 while ( itPlot2d.hasNext() ) {
3002 SUIT_ViewManager* viewMgr = itPlot2d.next();
3003 SUIT_ViewModel* vm = viewMgr->getViewModel();
3004 if ( !vm || !vm->inherits( "Plot2d_Viewer" ) )
3007 Plot2d_Viewer* Plot2dVM = dynamic_cast<Plot2d_Viewer*>( vm );
3009 viewMgr->setViewModel( vm );
3010 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
3012 Plot2d_ViewFrame* frame = wnd->getViewFrame();
3013 frame->SetPreference();
3022 void LightApp_Application::loadPreferences()
3024 CAM_Application::loadPreferences();
3026 SUIT_ResourceMgr* aResMgr = resourceMgr();
3031 static bool mru_load = true;
3034 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3036 mru->setVisible( aResMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
3037 mru->setVisibleCount( aResMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
3038 mru->setHistoryCount( aResMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
3039 mru->setInsertMode( aResMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
3040 mru->setLinkType( aResMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
3041 mru->setClearPossible( aResMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
3042 mru->loadLinks( aResMgr, "MRU" );
3048 QStringList mods = aResMgr->parameters( "windows_visibility" );
3049 for ( QStringList::const_iterator itr = mods.begin(); itr != mods.end(); ++itr )
3052 if ( aResMgr->value( "windows_visibility", *itr, arr ) )
3053 myWinVis.insert( *itr, arr );
3057 desktop()->retrieveGeometry( aResMgr->stringValue( "desktop", "geometry" ) );
3058 bool opaqueResize = aResMgr->booleanValue( "desktop", "opaque_resize", false );
3059 QMainWindow::DockOptions dopts = desktop()->dockOptions();
3060 if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
3061 else dopts &= ~QMainWindow::AnimatedDocks;
3062 desktop()->setDockOptions( dopts );
3063 desktop()->setOpaqueResize( opaqueResize );
3064 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
3065 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
3072 void LightApp_Application::savePreferences()
3074 CAM_Application::savePreferences();
3076 saveDockWindowsState();
3078 SUIT_ResourceMgr* aResMgr = resourceMgr();
3083 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3085 mru->saveLinks( aResMgr, "MRU" );
3087 for ( WinVis::const_iterator itr = myWinVis.begin(); itr != myWinVis.end(); ++itr )
3088 aResMgr->setValue( "windows_visibility", itr.key(), itr.value() );
3091 aResMgr->setValue( "desktop", "geometry", desktop()->storeGeometry() );
3093 #if GUI_DEVELOPMENT > 0
3094 aResMgr->setValue( "salome", "version", QString(GUI_VERSION_STR)+"dev" );
3096 aResMgr->setValue( "salome", "version", QString(GUI_VERSION_STR) );
3103 Updates desktop title
3105 void LightApp_Application::updateDesktopTitle()
3107 QString aTitle = applicationName();
3108 QString aVer = applicationVersion();
3109 if ( !aVer.isEmpty() )
3110 aTitle += QString( " " ) + aVer;
3112 if ( activeStudy() ) {
3113 QString sName = SUIT_Tools::file( activeStudy()->studyName().trimmed(), false );
3114 aTitle += QString( " - [%1]" ).arg( sName );
3117 desktop()->setWindowTitle( aTitle );
3121 \brief Get map of the operations which can be performed
3122 on the module activation.
3124 The method should return the map of the kind \c {<id>:<name>}
3125 where \c <id> is an integer identifier of the operation and
3126 \c <name> is a title for the button to be added to the
3127 dialog box. After user selects the required operation by the
3128 clicking the corresponding button in the dialog box, its identifier
3129 is passed to the moduleActionSelected() method to process
3132 \return map of the operations
3133 \sa moduleActionSelected()
3135 QMap<int, QString> LightApp_Application::activateModuleActions() const
3137 QMap<int, QString> opmap;
3138 opmap.insert( NewStudyId, tr( "ACTIVATE_MODULE_OP_NEW" ) );
3139 opmap.insert( OpenStudyId, tr( "ACTIVATE_MODULE_OP_OPEN" ) );
3144 \brief Called when the used selectes required operation chosen
3145 from "Activate module" dialog box.
3147 Performs the required operation according to the user choice.
3149 \param id operation identifier
3150 \sa activateModuleActions()
3152 void LightApp_Application::moduleActionSelected( const int id )
3167 Updates windows after close document
3169 void LightApp_Application::afterCloseDoc()
3173 CAM_Application::afterCloseDoc();
3177 Updates actions of active module
3179 void LightApp_Application::updateModuleActions()
3182 if ( activeModule() ) {
3183 modName = activeModule()->moduleName();
3184 if ( !isModuleAccessible( modName ) ) {
3185 QList<SUIT_Application*> apps = SUIT_Session::session()->applications();
3186 foreach( SUIT_Application* app, apps ) {
3187 LightApp_Application* lapp = dynamic_cast<LightApp_Application*>( app );
3188 if ( lapp && lapp != this )
3189 lapp->removeModuleAction( modName );
3194 LightApp_ModuleAction* moduleAction =
3195 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
3197 moduleAction->setActiveModule( modName );
3200 void LightApp_Application::removeModuleAction( const QString& modName )
3202 LightApp_ModuleAction* moduleAction =
3203 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
3205 moduleAction->removeModule( modName );
3209 Gets current windows.
3210 \param winMap - output current windows map.
3212 void LightApp_Application::currentWindows( QMap<int, int>& winMap ) const
3215 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
3216 ((LightApp_Module*)activeModule())->windows( winMap );
3218 defaultWindows( winMap );
3222 Gets current view managers.
3223 \param lst - output current view managers list.
3225 void LightApp_Application::currentViewManagers( QStringList& lst ) const
3228 if ( !activeStudy() )
3231 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
3232 ((LightApp_Module*)activeModule())->viewManagers( lst );
3234 defaultViewManagers( lst );
3240 void LightApp_Application::updateWindows()
3242 QMap<int, int> winMap;
3243 currentWindows( winMap );
3245 for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
3247 if ( !dockWindow( it.key() ) )
3248 getWindow( it.key() );
3251 for ( WinMap::ConstIterator it = myWin.begin(); it != myWin.end(); ++it )
3253 QWidget* wid = it.value();
3254 if ( winMap.contains( it.key() ) )
3255 wid->setVisible( true );
3260 loadDockWindowsState();
3264 Updates view managers
3266 void LightApp_Application::updateViewManagers()
3269 currentViewManagers( lst );
3271 for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
3272 getViewManager( *it, true );
3276 Loads windows geometry
3278 void LightApp_Application::loadDockWindowsState()
3282 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
3283 bool storeWin = aResMgr->booleanValue( "Study", "store_positions", true );
3284 bool storeTb = aResMgr->booleanValue( "Study", "store_tool_positions", true );
3287 if ( activeModule() )
3288 modName = activeModule()->name();
3289 else if ( activeStudy() )
3290 modName = "nomodule";
3292 QtxResourceMgr::WorkingMode prevMode = aResMgr->setWorkingMode( QtxResourceMgr::IgnoreUserValues );
3293 QByteArray aDefaultState;
3294 aResMgr->value( "windows_geometry", modName, aDefaultState );
3295 QByteArray aDefaultVisibility;
3296 aResMgr->value( "windows_visibility", modName, aDefaultVisibility );
3297 bool hasDefaultVisibility = !aDefaultVisibility.isEmpty();
3298 aResMgr->setWorkingMode( prevMode );
3300 if( !storeWin && !storeTb && aDefaultState.isEmpty() && !hasDefaultVisibility)
3303 if ( aResMgr->hasValue("windows_geometry" ,modName ) ) {
3304 long version = Qtx::versionToId( aResMgr->stringValue( "windows_geometry_version", modName, "" ) );
3306 if ( version > Qtx::versionToId( "7.4.1" ) )
3307 aResMgr->value( "windows_geometry", modName , arr );
3309 arr = aDefaultState;
3310 QByteArray aTargetArray = processState(arr, storeWin, storeTb, true, aDefaultState);
3311 desktop()->restoreState( aTargetArray );
3314 QStringList mainToolbarsNames;
3315 mainToolbarsNames << "SalomeStandard" << "SalomeModules";
3316 QList<QToolBar*> mainToolbars = findToolBars( mainToolbarsNames );
3317 foreach( QToolBar* tb, mainToolbars ) tb->setVisible( true );
3319 if ( !myWinVis.contains( modName ) && aDefaultVisibility.isEmpty())
3322 QMap<QString, bool> *tbMap = 0;
3323 QMap<QString, bool> *dwMap = 0;
3325 QMap<QString, bool> userTbMap, userDwMap;
3326 dockWindowsState( myWinVis[modName], userTbMap, userDwMap );
3328 QMap<QString, bool> defaultTbMap, defaultDwMap;
3329 if(hasDefaultVisibility) {
3330 dockWindowsState( aDefaultVisibility, defaultTbMap, defaultDwMap);
3336 if(hasDefaultVisibility){
3337 tbMap = &defaultTbMap;
3344 if(hasDefaultVisibility){
3345 dwMap = &defaultDwMap;
3350 QList<QToolBar*> tbList = findToolBars();
3351 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit )
3353 QToolBar* tb = *tit;
3354 if ( tbMap->contains( tb->objectName() ) ) {
3355 tb->setVisible( (*tbMap)[tb->objectName()] );
3361 QList<QDockWidget*> dwList = qFindChildren<QDockWidget*>( desktop() );
3362 for ( QList<QDockWidget*>::iterator dit = dwList.begin(); dit != dwList.end(); ++dit )
3364 QDockWidget* dw = *dit;
3366 QObject* po = Qtx::findParent( dw, "QMainWindow" );
3367 if ( po != desktop() )
3370 if ( dwMap->contains( dw->objectName() ) )
3371 dw->setVisible( (*dwMap)[dw->objectName()] );
3379 Saves windows geometry
3381 void LightApp_Application::saveDockWindowsState()
3386 bool storeWin = resourceMgr()->booleanValue( "Study", "store_positions", true );
3387 bool storeTb = resourceMgr()->booleanValue( "Study", "store_tool_positions", true );
3389 if( !storeWin && !storeTb )
3393 if ( activeModule() )
3394 modName = activeModule()->name();
3395 else if ( activeStudy() )
3396 modName = "nomodule";
3398 QString versionId = GUI_VERSION_STR;
3399 #if GUI_DEVELOPMENT > 0
3403 QByteArray arr = desktop()->saveState();
3404 resourceMgr()->setValue( "windows_geometry", modName, processState(arr, storeWin, storeTb, false) );
3405 resourceMgr()->setValue( "windows_geometry_version", modName, versionId );
3408 if ( myWinVis.contains( modName ) )
3409 visArr = myWinVis[modName];
3411 QMap<QString, bool> tbMap, dwMap;
3412 dockWindowsState( visArr, tbMap, dwMap );
3414 QList<QToolBar*> tbList = qFindChildren<QToolBar*>( desktop() );
3415 for ( QList<QToolBar*>::iterator it = tbList.begin(); it != tbList.end(); ++it )
3418 tbMap.insert( tb->objectName(), tb->toggleViewAction()->isChecked() );
3421 QList<QDockWidget*> dwList = qFindChildren<QDockWidget*>( desktop() );
3422 for ( QList<QDockWidget*>::iterator it = dwList.begin(); it != dwList.end(); ++it )
3424 QDockWidget* wid = *it;
3425 dwMap.insert( wid->objectName(), wid->toggleViewAction()->isChecked() );
3428 visArr = dockWindowsState( tbMap, dwMap );
3430 myWinVis.insert( modName, visArr );
3433 QByteArray LightApp_Application::dockWindowsState( const QMap<QString, bool>& tb, const QMap<QString, bool>& dw ) const
3436 QDataStream stream( &visArr, QIODevice::WriteOnly );
3438 stream << (uchar)ToolBarMarker;
3439 stream << tb.size();
3440 for ( QMap<QString, bool>::const_iterator tit = tb.begin(); tit != tb.end(); ++tit )
3442 stream << tit.key();
3443 stream << (uchar)( tit.value() ? 1 : 0 );
3446 stream << (uchar)DockWidgetMarker;
3447 stream << dw.size();
3448 for ( QMap<QString, bool>::const_iterator wit = dw.begin(); wit != dw.end(); ++wit )
3450 stream << wit.key();
3451 stream << (uchar)( wit.value() ? 1 : 0 );
3457 void LightApp_Application::dockWindowsState( const QByteArray& arr, QMap<QString, bool>& tb, QMap<QString, bool>& dw ) const
3462 QByteArray visArr = arr;
3463 QDataStream stream( &visArr, QIODevice::ReadOnly );
3467 if ( marker != ToolBarMarker )
3472 for ( int i = 0; i < lines; ++i )
3475 stream >> objectName;
3478 tb.insert( objectName, shown );
3482 if ( marker != DockWidgetMarker )
3486 for ( int j = 0; j < lines; ++j )
3489 stream >> objectName;
3492 dw.insert( objectName, shown );
3497 Adds icon names for modules
3499 void LightApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) const
3503 SUIT_ResourceMgr* resMgr = resourceMgr();
3507 QStringList modList;
3508 modules( modList, false );
3510 for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )
3512 QString modName = *it;
3513 QString modIntr = moduleName( modName );
3514 QString modIcon = resMgr->stringValue( modIntr, "icon", QString() );
3516 if ( modIcon.isEmpty() )
3519 if ( SUIT_Tools::extension( modIcon ).isEmpty() )
3520 modIcon += QString( ".png" );
3522 iconMap.insert( modName, modIcon );
3527 Inserts items in popup, which necessary for current application
3529 void LightApp_Application::contextMenuPopup( const QString& type, QMenu* thePopup, QString& title )
3532 LightApp_SelectionMgr* selMgr = LightApp_Application::selectionMgr();
3533 bool cacheIsOn = selMgr->isSelectionCacheEnabled();
3534 selMgr->setSelectionCacheEnabled( true );
3536 SUIT_DataBrowser* ob = objectBrowser();
3538 CAM_Application::contextMenuPopup( type, thePopup, title );
3540 if ( ob && type == ob->popupClientType() ) {
3541 thePopup->addSeparator();
3542 QAction* a = thePopup->addAction( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
3543 if ( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) )
3544 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) );
3547 #ifndef DISABLE_SALOMEOBJECT
3548 if ( selMgr && ob ) {
3549 SALOME_ListIO selected;
3550 selMgr->selectedObjects( selected );
3551 if(selected.Extent() == 1){
3552 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3553 SUIT_DataObject* obj = findObject(anIObject->getEntry());
3554 if(obj && obj->renameAllowed()) {
3555 QAction* a = new QAction(tr("MEN_RENAME_OBJ"), thePopup);
3556 connect( a, SIGNAL( triggered(bool) ), ob, SLOT( onStartEditing() ) );
3557 if ( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) )
3558 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) );
3560 QList<QAction*> acts = thePopup->actions();
3561 QAction* firstAction = acts.count() > 0 ? acts.first() : 0;
3562 thePopup->insertAction(firstAction,a);
3568 selMgr->setSelectionCacheEnabled( cacheIsOn );
3574 void LightApp_Application::createEmptyStudy()
3576 CAM_Application::createEmptyStudy();
3578 if ( objectBrowser() )
3579 objectBrowser()->updateTree();
3581 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
3582 if ( aResMgr && activeStudy() ) {
3583 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
3584 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
3589 void LightApp_Application::setDesktop( SUIT_Desktop* desk )
3591 CAM_Application::setDesktop( desk );
3594 connect( desk, SIGNAL( message( const QString& ) ),
3595 this, SLOT( onDesktopMessage( const QString& ) ), Qt::UniqueConnection );
3596 connect( desk, SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
3597 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
3603 \param mod - module to be activated
3605 bool LightApp_Application::activateModule( CAM_Module* mod )
3607 bool res = CAM_Application::activateModule( mod );
3609 if ( objectBrowser() )
3610 objectBrowser()->updateTree();
3616 \return keyborad accelerators manager object
3618 SUIT_Accel* LightApp_Application::accel() const
3624 Removes dead widget container from map
3626 void LightApp_Application::onWCDestroyed( QObject* ob )
3628 // remove destroyed widget container from windows map
3629 for ( WinMap::ConstIterator itr = myWin.begin(); itr != myWin.end(); ++itr )
3631 if ( itr.value() != ob )
3634 int key = itr.key();
3635 myWin.remove( key );
3640 void LightApp_Application::onMRUActivated( const QString& name )
3642 SUIT_Session* s = SUIT_Session::session();
3643 if ( s && s->activeApplication() == this )
3647 void LightApp_Application::onStylePreferences()
3649 Style_PrefDlg dlg( desktop() );
3652 resourceMgr()->setValue( "Style", "use_salome_style", Style_Salome::isActive() );
3655 void LightApp_Application::onFullScreen(){
3656 if(myScreenHelper) {
3657 if(desktop()->isFullScreen())
3658 myScreenHelper->switchToNormalScreen();
3660 myScreenHelper->switchToFullScreen();
3665 Connects just added view manager
3667 void LightApp_Application::addViewManager( SUIT_ViewManager* vm )
3669 connect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
3670 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
3671 CAM_Application::addViewManager( vm );
3675 Remove view manager from memory
3677 void LightApp_Application::removeViewManager( SUIT_ViewManager* vm )
3679 disconnect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
3680 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
3681 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
3683 aStudy->removeObjectProperties( vm->getGlobalId() );
3685 CAM_Application::removeViewManager( vm );
3687 LightApp_SelectionMgr* selMgr = selectionMgr();
3688 QList<SUIT_Selector*> selectors;
3689 selMgr->selectors( selectors );
3690 foreach( SUIT_Selector* selector, selectors ) {
3691 if ( selector->owner() == vm->getViewModel() ) {
3696 // IPAL22894: Crash on closing OCC view
3702 Renames active window of desktop
3704 void LightApp_Application::onRenameWindow()
3709 QWidget* w = desktop()->activeWindow();
3714 QString name = QInputDialog::getText( w, tr( "TOT_RENAME" ), tr( "PRP_RENAME" ), QLineEdit::Normal, w->windowTitle(), &ok );
3715 if( ok && !name.isEmpty() )
3716 w->setWindowTitle( name );
3720 Closes active window of desktop
3722 void LightApp_Application::onCloseWindow()
3727 QWidget* w = desktop()->activeWindow();
3735 Closes all windows of desktop
3737 void LightApp_Application::onCloseAllWindow()
3739 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
3743 QList<SUIT_ViewWindow*> wndList = desk->windows();
3744 SUIT_ViewWindow* wnd;
3745 foreach( wnd, wndList )
3753 Groups all windows of desktop
3755 void LightApp_Application::onGroupAllWindow()
3757 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
3761 QtxWorkstack* wgStack = desk->workstack();
3767 \return if the library of module exists
3768 \param moduleTitle - title of module
3770 bool LightApp_Application::isLibExists( const QString& moduleTitle ) const
3772 if( moduleTitle.isEmpty() )
3775 QString lib = moduleLibrary( moduleTitle );
3777 //abd: changed libSalomePyQtGUI to SalomePyQtGUI for WIN32
3778 bool isPythonModule = lib.contains("SalomePyQtGUI");
3779 bool isPythonLightModule = lib.contains("SalomePyQtGUILight");
3783 paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
3785 paths = QString(::getenv( "LD_LIBRARY_PATH" )).split( ":", QString::SkipEmptyParts );
3788 bool isLibFound = false;
3789 QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
3790 for( ; anIt!=aLast; anIt++ )
3792 QFileInfo inf( Qtx::addSlash( *anIt ) + lib );
3803 INFOS( "\n****************************************************************" << std::endl
3804 << "* Warning: library " << lib.toLatin1().constData() << " cannot be found" << std::endl
3805 << "* Module " << moduleTitle.toLatin1().constData() << " will not be available in GUI mode" << std::endl
3806 << "****************************************************************" << std::endl );
3808 else if ( !isPythonModule && !isPythonLightModule)
3811 if ( isPythonModule || isPythonLightModule)
3813 QString pylib = moduleName( moduleTitle ) + QString(".py");
3814 QString pylibgui = moduleName( moduleTitle ) + QString("GUI.py");
3816 // Check the python library
3818 // paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
3820 paths = QString(::getenv( "PYTHONPATH" )).split( ":", QString::SkipEmptyParts );
3822 bool isPyLib = false, isPyGuiLib = false;
3823 QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
3824 for( ; anIt!=aLast; anIt++ )
3826 QFileInfo inf( Qtx::addSlash( *anIt ) + pylib );
3827 QFileInfo infgui( Qtx::addSlash( *anIt ) + pylibgui );
3829 if(!isPythonLightModule)
3830 if( !isPyLib && inf.exists() )
3833 if( !isPyGuiLib && infgui.exists() )
3836 if ((isPyLib || isPythonLightModule ) && isPyGuiLib && isLibFound)
3840 printf( "\n****************************************************************\n" );
3841 printf( "* Warning: python library for %s cannot be found:\n", moduleTitle.toLatin1().constData() );
3843 printf( "* No module named %s\n", moduleName( moduleTitle ).toLatin1().constData() );
3845 printf( "* No module named %s\n", (moduleName( moduleTitle ) + QString("GUI")).toLatin1().constData() );
3846 printf( "****************************************************************\n" );
3853 \return default name for an active study
3855 void LightApp_Application::setDefaultStudyName( const QString& theName )
3857 QStringList anInfoList;
3858 modules( anInfoList, false );
3860 LightApp_Study* aStudy = (LightApp_Study*)activeStudy();
3861 if( anInfoList.count() == 1 && // to avoid a conflict between different modules
3862 !aStudy->isSaved() )
3864 aStudy->setStudyName( theName );
3865 updateDesktopTitle();
3870 Custom event handler
3872 bool LightApp_Application::event( QEvent* e )
3874 if( e && e->type()==2000 )
3876 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
3877 QString* d = ( QString* )ce->data();
3878 if( SUIT_MessageBox::question(0, tr("WRN_WARNING"),
3880 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
3881 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
3882 showPreferences( tr( "PREF_APP" ) );
3887 return CAM_Application::event( e );
3890 /*! Check data object */
3891 bool LightApp_Application::checkDataObject(LightApp_DataObject* theObj)
3895 bool isSuitable = !theObj->entry().isEmpty() &&
3896 !theObj->componentDataType().isEmpty() &&
3897 !theObj->name().isEmpty();
3904 int LightApp_Application::openChoice( const QString& aName )
3906 int choice = CAM_Application::openChoice( aName );
3908 if ( choice == OpenExist ) // The document is already open.
3910 // Do you want to reload it?
3911 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "QUE_DOC_ALREADYOPEN" ).arg( aName ),
3912 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No ) == SUIT_MessageBox::Yes )
3913 choice = OpenReload;
3919 bool LightApp_Application::openAction( const int choice, const QString& aName )
3926 STD_Application* app = 0;
3927 SUIT_Session* session = SUIT_Session::session();
3928 QList<SUIT_Application*> appList = session->applications();
3929 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !app; ++it )
3931 if ( (*it)->activeStudy() && (*it)->activeStudy()->studyName() == aName )
3932 app = ::qobject_cast<STD_Application*>( *it );
3937 app->onCloseDoc( false );
3938 appList = session->applications();
3939 STD_Application* other = 0;
3940 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !other; ++it )
3941 other = ::qobject_cast<STD_Application*>( *it );
3944 res = other->onOpenDoc( aName );
3949 res = CAM_Application::openAction( choice, aName );
3956 QStringList LightApp_Application::viewManagersTypes() const
3958 QStringList aTypesList;
3959 aTypesList += myUserWmTypes;
3960 #ifndef DISABLE_GLVIEWER
3961 aTypesList<<GLViewer_Viewer::Type();
3963 #ifndef DISABLE_PLOT2DVIEWER
3964 aTypesList<<Plot2d_Viewer::Type();
3966 #ifndef DISABLE_QXGRAPHVIEWER
3967 aTypesList<<QxScene_Viewer::Type();
3969 #ifndef DISABLE_PVVIEWER
3970 aTypesList<<PVViewer_Viewer::Type();
3972 #ifndef DISABLE_OCCVIEWER
3973 aTypesList<<OCCViewer_Viewer::Type();
3975 #ifndef DISABLE_VTKVIEWER
3976 #ifndef DISABLE_SALOMEOBJECT
3977 aTypesList<<SVTK_Viewer::Type();
3979 aTypesList<<VTKViewer_Viewer::Type();
3985 * Removes all view managers of known types
3986 * Other view managers are ignored
3988 void LightApp_Application::clearKnownViewManagers()
3990 QStringList aTypesList = viewManagersTypes();
3991 QList<SUIT_ViewManager*> aMgrList;
3992 viewManagers( aMgrList );
3993 foreach (SUIT_ViewManager* aMgr, aMgrList) {
3994 if (aTypesList.contains(aMgr->getType()))
3995 removeViewManager(aMgr);
4000 Copy of current selection
4002 void LightApp_Application::onCopy()
4004 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
4010 Paste of current data in clipboard
4012 void LightApp_Application::onPaste()
4014 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
4020 Browse (i.e. set focus on) the published objects
4021 \param theIsApplyAndClose - flag indicating that the dialog for creating objects
4022 has been accepted by Ok (or Apply & Close) button
4023 \param theIsOptimizedBrowsing - flag switching to optimized browsing mode
4024 (to select the first published object only)
4025 \return entry of the selected object
4027 QString LightApp_Application::browseObjects( const QStringList& theEntryList,
4028 const bool theIsApplyAndClose,
4029 const bool theIsOptimizedBrowsing )
4032 if( SUIT_ResourceMgr* aResourceMgr = resourceMgr() )
4034 int aBrowsePolicy = aResourceMgr->integerValue( "ObjectBrowser", "browse_published_object", (int)BP_Never );
4035 switch( aBrowsePolicy )
4039 case BP_ApplyAndClose:
4040 if( !theIsApplyAndClose )
4048 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
4052 SUIT_DataBrowser* anOB = objectBrowser();
4056 SUIT_AbstractModel* aModel = dynamic_cast<SUIT_AbstractModel*>( anOB->model() );
4060 QStringListIterator anIter( theEntryList );
4061 if( theIsOptimizedBrowsing )
4063 // go to the last entry
4065 if( anIter.hasPrevious() )
4069 // scroll to each entry in the list
4070 // (in optimized mode - to the last entry only)
4072 LightApp_DataObject* anObject = 0;
4073 while( anIter.hasNext() )
4075 anEntry = anIter.next();
4076 if( !anEntry.isEmpty() )
4078 anObject = aStudy->findObjectByEntry( anEntry );
4081 QModelIndex anIndex = aModel->index( anObject );
4082 anOB->treeView()->scrollTo( anIndex );
4087 // always select the last object
4088 if( anObject && !anEntry.isEmpty() )
4090 QList<SUIT_Selector*> aSelectorList;
4091 selectionMgr()->selectors( "ObjectBrowser", aSelectorList );
4092 if( !aSelectorList.isEmpty() )
4094 if( LightApp_OBSelector* aSelector = dynamic_cast<LightApp_OBSelector*>( aSelectorList.first() ) )
4096 bool anIsAutoBlock = aSelector->autoBlock();
4098 // temporarily disable auto block, to emit LightApp_SelectionMgr::currentSelectionChanged() signal
4099 aSelector->setAutoBlock( false );
4101 SUIT_DataOwnerPtrList aList;
4102 #ifndef DISABLE_SALOMEOBJECT
4103 Handle(SALOME_InteractiveObject) aSObj = new SALOME_InteractiveObject
4104 ( anObject->entry().toLatin1().constData(),
4105 anObject->componentDataType().toLatin1().constData(),
4106 anObject->name().toLatin1().constData() );
4107 LightApp_DataOwner* owner = new LightApp_DataOwner( aSObj );
4109 LightApp_DataOwner* owner = new LightApp_DataOwner( anEntry );
4112 aList.append( owner );
4113 selectionMgr()->setSelected( aList );
4116 // restore auto block flag
4117 aSelector->setAutoBlock( anIsAutoBlock );
4125 SUIT_DataObject* LightApp_Application::findObject( const QString& id ) const
4127 LightApp_Study* study = dynamic_cast<LightApp_Study*>( activeStudy() );
4128 return study ? study->findObjectByEntry( id ) : 0;
4132 Checks that an object can be renamed.
4133 \param entry entry of the object
4134 \brief Return \c true if object can be renamed
4136 bool LightApp_Application::renameAllowed( const QString& /*entry*/) const {
4141 Rename object by entry.
4142 \param entry entry of the object
4143 \param name new name of the object
4144 \brief Return \c true if rename operation finished successfully, \c false otherwise.
4146 bool LightApp_Application::renameObject( const QString& entry, const QString& ) {
4150 /*! Process standard messages from desktop */
4151 void LightApp_Application::onDesktopMessage( const QString& message )
4153 const QString sectionSeparator = "/";
4155 if ( message.toLower() == "updateobjectbrowser" ||
4156 message.toLower() == "updateobjbrowser" ) {
4157 // update object browser
4158 updateObjectBrowser();
4160 else if ( message.toLower().startsWith( "activate_viewer" ) ) {
4161 QString vtype = message.split( sectionSeparator ).last();
4162 if ( !vtype.isEmpty() )
4163 getViewManager( vtype, true );
4166 QStringList data = message.split( sectionSeparator );
4167 if ( data.count() > 1 ) {
4168 QString msgType = data[0].trimmed();
4169 LightApp_Module* sMod = 0;
4170 CAM_Module* mod = module( msgType );
4172 mod = module( moduleTitle( msgType ) );
4173 if ( mod && mod->inherits( "LightApp_Module" ) )
4174 sMod = (LightApp_Module*)mod;
4176 if ( msgType.toLower() == "preferences" ) {
4177 // requested preferences change: should be given as "preferences/<section>/<name>/<value>"
4178 // for example "preferences/Study/multi_file_dump/true"
4179 if ( data.count() > 3 ) {
4180 QString section = data[1].trimmed();
4181 QString param = data[2].trimmed();
4182 QString value = QStringList( data.mid(3) ).join( sectionSeparator );
4183 resourceMgr()->setValue( section, param, value );
4187 // received message for the module
4188 QString msg = QStringList( data.mid(1) ).join( sectionSeparator );
4189 sMod->message( msg );
4197 Returns all top level toolbars.
4198 Note : Result list contains only main window toolbars, not including toolbars from viewers.
4200 QList<QToolBar*> LightApp_Application::findToolBars( const QStringList& names )
4202 QList<QToolBar*> aResult;
4203 QList<QToolBar*> tbList = qFindChildren<QToolBar*>( desktop() );
4204 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit ) {
4205 QToolBar* tb = *tit;
4206 QObject* po = Qtx::findParent( tb, "QMainWindow" );
4207 if ( po != desktop() )
4209 if ( names.isEmpty() || names.contains( tb->objectName() ) )
4216 Internal method to parse toolbars and dockable windows state.
4218 QByteArray LightApp_Application::processState(QByteArray& input,
4219 const bool processWin,
4220 const bool processTb,
4221 const bool isRestoring,
4222 QByteArray defaultState) {
4225 bool hasDefaultState = !defaultState.isEmpty();
4226 bool isDockWinWriten = false;
4228 //Write date from users settings
4230 QDataStream tmpInputData(&input, QIODevice::ReadOnly);
4231 int marker, version;
4233 tmpInputData >> marker;
4234 tmpInputData >> version;
4235 tmpInputData >> dockmarker;
4236 tmpInputData >> nbDocWin;
4238 if(processWin && processTb && !isRestoring) {
4240 } else if(!processWin && !processTb ) {
4242 aRes = defaultState;
4244 QDataStream aData(&aRes, QIODevice::WriteOnly);
4245 QList<QToolBar*> aToolBars = findToolBars();
4248 for ( QList<QToolBar*>::iterator tit = aToolBars.begin(); tit != aToolBars.end(); ++tit ) {
4249 QToolBar* tb = *tit;
4250 aNames.append(tb->objectName());
4253 int toolBarMarkerIndex = getToolbarMarkerIndex(input,aNames);
4254 if(toolBarMarkerIndex < 0)
4256 QDataStream anInputData(&input, QIODevice::ReadOnly);
4258 int toolBarMarkerIndexDef;
4259 if(hasDefaultState) {
4260 toolBarMarkerIndexDef = getToolbarMarkerIndex(defaultState, aNames);
4261 if(toolBarMarkerIndexDef < 0)
4264 QDataStream anInputDataDef(&defaultState, QIODevice::ReadOnly);
4266 QDataStream* aTargetData = 0;
4267 int aTargetIndex = -1;
4269 QByteArray currentArr = desktop()->saveState();
4270 QDataStream anInputDataCur(¤tArr, QIODevice::ReadOnly);
4271 bool useInputData = !isRestoring || (isRestoring && nbDocWin > 0);
4272 if(processWin && useInputData) {
4273 aTargetData = &anInputData;
4274 aTargetIndex = toolBarMarkerIndex;
4276 //Write date from default settings
4277 if(hasDefaultState) {
4278 aTargetData = &anInputDataDef;
4279 aTargetIndex = toolBarMarkerIndexDef;
4281 //If no default state, write current snapshot of the dockable windows
4283 aTargetData = &anInputDataCur;
4284 int toolBarMarkerIndexCur = getToolbarMarkerIndex(currentArr, aNames);
4285 aTargetIndex = toolBarMarkerIndexCur;
4290 if(aTargetData && aTargetIndex >= 0 ) {
4291 aTargetData->device()->seek(0);
4292 while( aTargetData->device()->pos() < aTargetIndex ) {
4297 isDockWinWriten = true;
4304 aTargetData = &anInputData;
4305 aTargetIndex = toolBarMarkerIndex;
4307 if(hasDefaultState) {
4308 aTargetData = &anInputDataDef;
4309 aTargetIndex = toolBarMarkerIndexDef;
4313 if(aTargetData && aTargetIndex >= 0) {
4315 if(!isDockWinWriten ) {
4316 //Write version marker
4317 int marker, version;
4318 aTargetData->device()->seek(0);
4319 *aTargetData >> marker;
4320 *aTargetData >> version;
4323 aData << (uchar) QDockWidgetMarker;
4325 int shift = 4*sizeof(int) + sizeof(QSize);
4326 index = aTargetIndex - shift;
4328 index = aTargetIndex;
4331 aTargetData->device()->seek(index);
4332 while(!aTargetData->atEnd()) {
4337 } else { // Not treat toolbars
4338 aData << (uchar) QToolBarMarker;
4339 aData << (int) 0; //Nb toolbars = 0
4346 \brief Emits operationFinished signal.
4347 \param theModuleName the name of the module which perfomed the operation
4348 \param theOperationName the operation name
4349 \param theEntryList the list of the created objects entries
4351 void LightApp_Application::emitOperationFinished( const QString& theModuleName,
4352 const QString& theOperationName,
4353 const QStringList& theEntryList )
4355 emit operationFinished( theModuleName, theOperationName, theEntryList );
4359 Update visibility state of given objects
4361 void LightApp_Application::updateVisibilityState( DataObjectList& theList,
4362 SUIT_ViewModel* theViewModel )
4364 if ( !theViewModel || theList.isEmpty() ) return;
4366 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
4367 if ( !aStudy ) return;
4369 SALOME_View* aView = dynamic_cast<SALOME_View*>( theViewModel );
4371 for ( DataObjectList::iterator itr = theList.begin(); itr != theList.end(); ++itr ) {
4372 LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>(*itr);
4374 if ( !obj || aStudy->isComponent( obj->entry() ) )
4377 LightApp_Module* anObjModule = dynamic_cast<LightApp_Module*>(obj->module());
4378 if ( anObjModule ) {
4379 LightApp_Displayer* aDisplayer = anObjModule->displayer();
4381 Qtx::VisibilityState anObjState = Qtx::UnpresentableState;
4382 if ( aDisplayer->canBeDisplayed( obj->entry(), theViewModel->getType() ) ) {
4383 if ( aView && aDisplayer->IsDisplayed( obj->entry(), aView ) )
4384 anObjState = Qtx::ShownState;
4386 anObjState = Qtx::HiddenState;
4388 aStudy->setVisibilityState( obj->entry(), anObjState );
4395 * Called when window activated
4397 void LightApp_Application::onWindowActivated( SUIT_ViewWindow* theViewWindow )
4399 SUIT_DataBrowser* anOB = objectBrowser();
4402 SUIT_DataObject* rootObj = anOB->root();
4406 DataObjectList listObj = rootObj->children( true );
4408 SUIT_ViewModel* vmod = 0;
4409 if ( SUIT_ViewManager* vman = theViewWindow->getViewManager() )
4410 vmod = vman->getViewModel();
4411 updateVisibilityState( listObj, vmod );
4415 Called then view manager removed
4417 void LightApp_Application::onViewManagerRemoved( SUIT_ViewManager* )
4419 ViewManagerList lst;
4420 viewManagers( lst );
4421 if ( lst.count() == 1) { // in case if closed last view window
4422 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
4424 aStudy->setVisibilityStateForAll( Qtx::UnpresentableState );
4429 Check existing document.
4431 bool LightApp_Application::checkExistingDoc()
4434 if( activeStudy() ) {
4435 int answer = SUIT_MessageBox::question( desktop(),
4436 tr( "APPCLOSE_CAPTION" ),
4437 tr( "STUDYCLOSE_DESCRIPTION" ),
4438 tr( "APPCLOSE_SAVE" ),
4439 tr( "APPCLOSE_CLOSE" ),
4440 tr( "APPCLOSE_CANCEL" ), 0 );
4442 if ( activeStudy()->isSaved() ) {
4445 } else if ( onSaveAsDoc() ) {
4446 if( !closeDoc( false ) ) {
4453 else if( answer == 1 ) {
4455 } else if( answer == 2 ) {
4462 #ifndef DISABLE_PYCONSOLE
4464 PyConsole_Interp* LightApp_Application::getPyInterp()
4466 static PyConsole_Interp* myInterp = 0;
4468 myInterp = createPyInterp();
4472 PyConsole_Interp* LightApp_Application::createPyInterp()
4474 return new LightApp_PyInterp();
4477 #endif // DISABLE_PYCONSOLE