1 // Copyright (C) 2007-2013 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.
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_Study.h"
46 #include "LightApp_Preferences.h"
47 #include "LightApp_PreferencesDlg.h"
48 #include "LightApp_ModuleDlg.h"
49 #include "LightApp_AboutDlg.h"
50 #include "LightApp_ModuleAction.h"
51 // temporary commented
52 #include "LightApp_EventFilter.h"
53 #include "LightApp_OBSelector.h"
54 #include "LightApp_SelectionMgr.h"
55 #include "LightApp_DataObject.h"
56 #include "LightApp_WgViewModel.h"
57 #include "LightApp_FullScreenHelper.h"
60 #include <GUI_version.h>
61 #include <Basics_OCCTVersion.hxx>
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>
94 #include <QtxWebBrowser.h>
96 #include <LogWindow.h>
98 #ifndef DISABLE_GLVIEWER
99 #include <GLViewer_Viewer.h>
100 #include <GLViewer_ViewManager.h>
101 #include "LightApp_GLSelector.h"
104 #ifndef DISABLE_PLOT2DVIEWER
105 #include <Plot2d_ViewManager.h>
106 #include <Plot2d_ViewModel.h>
107 #include <Plot2d_ViewWindow.h>
108 #include <Plot2d_ViewFrame.h>
109 #include "LightApp_Plot2dSelector.h"
110 #ifndef DISABLE_SALOMEOBJECT
111 #include <SPlot2d_ViewModel.h>
113 #include <Plot2d_ViewModel.h>
117 #ifndef DISABLE_OCCVIEWER
118 #include <OCCViewer_ViewManager.h>
119 #include <OCCViewer_ViewFrame.h>
120 #ifndef DISABLE_SALOMEOBJECT
121 #include <SOCC_ViewModel.h>
123 #include <OCCViewer_ViewModel.h>
125 #include "LightApp_OCCSelector.h"
128 #ifndef DISABLE_VTKVIEWER
129 #ifndef DISABLE_SALOMEOBJECT
130 #include <SVTK_ViewModel.h>
131 #include <SVTK_ViewManager.h>
132 #include "LightApp_VTKSelector.h"
134 #include <VTKViewer_ViewModel.h>
135 #include <VTKViewer_ViewManager.h>
137 #include <VTKViewer_ViewModel.h>
140 #ifndef DISABLE_QXGRAPHVIEWER
141 #include <QxScene_ViewManager.h>
142 #include <QxScene_ViewModel.h>
143 #include <QxScene_ViewWindow.h>
146 #ifndef DISABLE_GRAPHICSVIEW
147 #include "GraphicsView_Viewer.h"
148 #include "GraphicsView_ViewManager.h"
149 #include "LightApp_GVSelector.h"
152 #define VISIBILITY_COLUMN_WIDTH 25
158 #include <QStringList>
160 #include <QApplication>
162 #include <QStatusBar>
164 #include <QObjectList>
166 #include <QInputDialog>
167 #include <QFontDatabase>
169 #include <QByteArray>
173 #include <QHeaderView>
178 #include <utilities.h>
180 #define FIRST_HELP_ID 1000000
182 #ifndef DISABLE_SALOMEOBJECT
183 #include <SALOME_InteractiveObject.hxx>
184 #include <SALOME_ListIO.hxx>
187 #include <Standard_Version.hxx>
189 #define ToolBarMarker 0
190 #define DockWidgetMarker 1
192 static const char* imageEmptyIcon[] = {
195 "....................",
196 "....................",
197 "....................",
198 "....................",
199 "....................",
200 "....................",
201 "....................",
202 "....................",
203 "....................",
204 "....................",
205 "....................",
206 "....................",
207 "....................",
208 "....................",
209 "....................",
210 "....................",
211 "....................",
212 "....................",
213 "....................",
214 "...................."};
216 int LightApp_Application::lastStudyId = 0;
219 // Markers used to parse array with dockable windows and toolbars state.
220 // For more details please see the qdockarealayout.cpp && qtoolbararealayout.cpp
221 // in the Qt source code.
223 #define QDockWidgetMarker 0xfd // = DockWidgetStateMarker
224 #define QToolBarMarker 0xfc // = ToolBarStateMarkerEx
226 // Format of the Byte array with the windows and toolbar state is:
227 // VersionMarker|version|DockWidgetStateMarker|nbDockWidgetLines|...DocWidgetData...|ToolBarStateMarkerEx|nbToolBarLines|...ToolBarData...
229 //Find toolbar marker position in the array in the following way:
230 //since the 'toolbar marker' is not unique, find index of first occurrence of the
231 //'toolbar marker' in the array and check that next string is name of the toolbar
233 int getToolbarMarkerIndex(QByteArray input, const QStringList& aFlags) {
234 int aResult = -1,tmp = 0;
235 int inputLen = input.length();
236 QDataStream anInputData(&input, QIODevice::ReadOnly);
237 while(tmp < inputLen) {
238 tmp = input.indexOf(QToolBarMarker, tmp + 1);
241 anInputData.device()->seek(tmp);
245 anInputData >> lines;
247 if(lines == 0 && anInputData.atEnd()){
248 //Case then array doesn't contain information about toolbars,
259 if(aFlags.contains(str)) {
268 \return last global id of study
270 int LightApp_Application::studyId()
272 return LightApp_Application::lastStudyId;
275 /*!Create new instance of LightApp_Application.*/
276 extern "C" LIGHTAPP_EXPORT SUIT_Application* createApplication()
278 return new LightApp_Application();
281 /*! \var global preferences of LightApp */
282 LightApp_Preferences* LightApp_Application::_prefs_ = 0;
286 \class LightApp_Application
287 Application containing LightApp module
291 LightApp_Application::LightApp_Application()
292 : CAM_Application( false ),
294 myScreenHelper(new LightApp_FullScreenHelper())
296 Q_INIT_RESOURCE( LightApp );
298 STD_TabDesktop* desk = new STD_TabDesktop();
299 desk->setFullScreenAllowed(false);
300 desk->setMinimizeAllowed(false);
304 // initialize auto save timer
305 myAutoSaveTimer = new QTimer( this );
306 myAutoSaveTimer->setSingleShot( true );
307 connect( myAutoSaveTimer, SIGNAL( timeout() ), this, SLOT( onSaveDoc() ) );
309 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
310 QPixmap aLogo = aResMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
312 QtxWebBrowser::setResourceManager( aResMgr );
313 QtxWebBrowser::setData("browser:icon", aResMgr->loadPixmap( "LightApp", tr( "BROWSER_ICON" ) ) );
314 QtxWebBrowser::setData("browser:title", tr( "BROWSER_TITLE" ) );
315 QtxWebBrowser::setData("toolbar:title", tr( "BROWSER_TOOLBAR_TITLE" ) );
316 QtxWebBrowser::setData("menu:file:title", tr( "BROWSER_FILEMENU" ) );
317 QtxWebBrowser::setData("action:close:title", tr( "BROWSER_CLOSE" ) );
318 QtxWebBrowser::setData("action:close:icon", aResMgr->loadPixmap( "LightApp", tr( "BROWSER_CLOSE_ICON" ) ) );
319 QtxWebBrowser::setData("action:back:title", tr( "BROWSER_BACK" ) );
320 QtxWebBrowser::setData("action:forward:title", tr( "BROWSER_FORWARD" ) );
321 QtxWebBrowser::setData("action:find:title", tr( "BROWSER_FIND" ) );
322 QtxWebBrowser::setData("action:findnext:title", tr( "BROWSER_FINDNEXT" ) );
323 QtxWebBrowser::setData("action:findprev:title", tr( "BROWSER_FINDPREV" ) );
325 desktop()->setWindowIcon( aLogo );
326 desktop()->setDockableMenuBar( false );
327 desktop()->setDockableStatusBar( false );
329 // base logo (salome itself)
330 desktop()->logoInsert( "_app_base", aResMgr->loadPixmap( "LightApp", tr( "APP_BASE_LOGO" ), false ) );
331 // extra logo (salome-based application)
332 desktop()->logoInsert( "_app_extra", aResMgr->loadPixmap( "LightApp", tr( "APP_EXTRA_LOGO" ), false ) );
336 mySelMgr = new LightApp_SelectionMgr( this );
338 myAccel = SUIT_Accel::getAccel();
340 #ifndef DISABLE_OCCVIEWER
341 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, OCCViewer_Viewer::Type() );
342 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, OCCViewer_Viewer::Type() );
343 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, OCCViewer_Viewer::Type() );
344 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, OCCViewer_Viewer::Type() );
345 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, OCCViewer_Viewer::Type() );
346 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, OCCViewer_Viewer::Type() );
347 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, OCCViewer_Viewer::Type() );
348 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, OCCViewer_Viewer::Type() );
349 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, OCCViewer_Viewer::Type() );
350 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, OCCViewer_Viewer::Type() );
351 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, OCCViewer_Viewer::Type() );
352 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, OCCViewer_Viewer::Type() );
354 #ifndef DISABLE_VTKVIEWER
355 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, VTKViewer_Viewer::Type() );
356 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, VTKViewer_Viewer::Type() );
357 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, VTKViewer_Viewer::Type() );
358 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, VTKViewer_Viewer::Type() );
359 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, VTKViewer_Viewer::Type() );
360 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, VTKViewer_Viewer::Type() );
361 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, VTKViewer_Viewer::Type() );
362 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, VTKViewer_Viewer::Type() );
363 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, VTKViewer_Viewer::Type() );
364 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, VTKViewer_Viewer::Type() );
365 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, VTKViewer_Viewer::Type() );
366 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, VTKViewer_Viewer::Type() );
368 #ifndef DISABLE_PLOT2DVIEWER
369 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, Plot2d_Viewer::Type() );
370 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, Plot2d_Viewer::Type() );
371 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, Plot2d_Viewer::Type() );
372 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, Plot2d_Viewer::Type() );
373 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, Plot2d_Viewer::Type() );
374 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, Plot2d_Viewer::Type() );
375 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, Plot2d_Viewer::Type() );
376 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, Plot2d_Viewer::Type() );
379 connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) );
381 // Set existing font for the python console in resources
382 if( !aResMgr->hasValue( "PyConsole", "font" ) )
385 QFont f = aResMgr->fontValue( "PyConsole", "font" );
387 QStringList famdb = fdb.families();
389 if ( famdb.contains(f.family()) || !aResMgr->hasValue( "PyConsole", "additional_families" ) )
392 QStringList anAddFamilies = aResMgr->stringValue( "PyConsole", "additional_families" ).split( ";", QString::SkipEmptyParts );
394 for ( QStringList::Iterator it = anAddFamilies.begin(); it != anAddFamilies.end(); ++it )
397 if ( famdb.contains(aFamily) )
399 f.setFamily( aFamily );
400 aResMgr->setValue( "PyConsole", "font", f );
407 *\li Save window geometry.
408 *\li Save desktop geometry.
409 *\li Save resource maneger.
410 *\li Delete selection manager.
412 LightApp_Application::~LightApp_Application()
415 delete myScreenHelper;
418 /*!Start application.*/
419 void LightApp_Application::start()
421 CAM_Application::start();
424 updateViewManagers();
427 desktop()->statusBar()->showMessage( "" );
429 LightApp_EventFilter::Init();
432 /*!Gets application name.*/
433 QString LightApp_Application::applicationName() const
435 static QString _app_name;
436 if ( _app_name.isEmpty() )
437 _app_name = tr( "APP_NAME" );
441 /*!Gets application version.*/
442 QString LightApp_Application::applicationVersion() const
444 static QString _app_version;
446 if ( _app_version.isEmpty() )
448 QString resVersion = tr( "APP_VERSION" );
449 if ( resVersion != "APP_VERSION" )
451 _app_version = resVersion;
455 _app_version = GUI_VERSION_STR;
461 /*!Load module by \a name.*/
462 CAM_Module* LightApp_Application::loadModule( const QString& name, const bool showMsg )
464 CAM_Module* mod = CAM_Application::loadModule( name, showMsg );
467 connect( this, SIGNAL( studyOpened() ), mod, SLOT( onModelOpened() ) );
468 connect( this, SIGNAL( studySaved() ), mod, SLOT( onModelSaved() ) );
469 connect( this, SIGNAL( studyClosed() ), mod, SLOT( onModelClosed() ) );
474 /*!Activate module by \a modName*/
475 bool LightApp_Application::activateModule( const QString& modName )
478 CAM_Module* prevMod = activeModule();
481 actName = prevMod->moduleName();
483 if ( actName == modName )
486 putInfo( tr( "ACTIVATING_MODULE" ).arg( modName ) );
488 saveDockWindowsState();
490 bool status = CAM_Application::activateModule( modName );
492 updateModuleActions();
500 updateViewManagers();
505 /*!Gets selection manager.*/
506 LightApp_SelectionMgr* LightApp_Application::selectionMgr() const
511 /*!Creat action "New window" for certain type of viewer:*/
512 void LightApp_Application::createActionForViewer( const int id,
514 const QString& suffix,
517 QString vtlt = tr( QString( "NEW_WINDOW_%1" ).arg( suffix ).toLatin1().constData() );
518 QString tip = tr( "CREATING_NEW_WINDOW" ).arg( vtlt.remove( "&" ) );
519 QAction* a = createAction( id, // menu action id
526 false, // toggle flag
528 SLOT( onNewWindow() ) ); // slot
529 createMenu( a, parentId, -1 );
534 void LightApp_Application::createActions()
536 CAM_Application::createActions();
538 SUIT_Desktop* desk = desktop();
539 SUIT_ResourceMgr* resMgr = resourceMgr();
542 createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIcon(),
543 tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
544 Qt::CTRL+Qt::Key_R, desk, false, this, SLOT( onPreferences() ) );
548 // - Help for modules
550 int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
551 createMenu( separator(), helpMenu, -1, 10 );
552 QStringList aModuleList;
553 modules( aModuleList, false );
554 aModuleList.prepend( "GUI" );
555 aModuleList.prepend( "KERNEL" );
557 int id = LightApp_Application::UserID + FIRST_HELP_ID;
560 foreach( aModule, aModuleList ) {
561 if ( aModule.isEmpty() ) // module title (user name)
563 IMap <QString, QString> helpData; // list of help files for the module
564 QString helpSubMenu; // help submenu name (empty if not needed)
565 QString modName = moduleName( aModule ); // module name
566 if ( modName.isEmpty() ) modName = aModule; // for KERNEL and GUI
567 QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName ); // module root dir variable
568 QString modDir = getenv( rootDir.toLatin1().constData() ); // module root dir
570 if (resMgr->hasValue( modName, "documentation" ) )
571 docSection = resMgr->stringValue(modName, "documentation");
572 else if ( resMgr->hasSection( modName + "_documentation" ) )
573 docSection = modName + "_documentation";
574 if ( !docSection.isEmpty() ) {
575 helpSubMenu = resMgr->stringValue( docSection, "sub_menu", "" ).arg( aModule );
576 QStringList listOfParam = resMgr->parameters( docSection );
577 foreach( QString paramName, listOfParam ) {
578 QString valueStr = resMgr->stringValue( docSection, paramName );
579 if ( !valueStr.isEmpty() ) {
580 QFileInfo fi( valueStr );
581 if ( fi.isRelative() && !modDir.isEmpty() )
582 valueStr = Qtx::addSlash( modDir ) + valueStr;
583 if ( QFile::exists( valueStr ) )
584 helpData.insert( paramName.arg( aModule ), valueStr );
589 if ( helpData.isEmpty() && !modDir.isEmpty() ) {
590 QStringList idxLst = QStringList() << modDir << "share" << "doc" << "salome" << "gui" << modName << "index.html";
591 QString indexFile = idxLst.join( QDir::separator() ); // index file
592 if ( QFile::exists( indexFile ) )
593 helpData.insert( tr( "%1 module Users's Guide" ).arg( aModule ), indexFile );
596 IMapConstIterator<QString, QString > fileIt;
597 for ( fileIt = helpData.begin(); fileIt != helpData.end(); fileIt++ ) {
598 QString helpFileName = fileIt.key();
599 // remove all '//' occurances
600 while ( helpFileName.contains( "//" ) )
601 helpFileName.replace( "//", "" );
602 // obtain submenus hierarchy if given
603 QStringList smenus = helpFileName.split( "/" );
604 helpFileName = smenus.last();
606 QAction* a = createAction( id, helpFileName,
607 resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
608 helpFileName, helpFileName,
609 0, desk, false, this, SLOT( onHelpContentsModule() ) );
610 a->setData( fileIt.value() );
611 if ( !helpSubMenu.isEmpty() ) {
612 smenus.prepend( helpSubMenu );
614 // create sub-menus hierarchy
615 int menuId = helpMenu;
616 foreach ( QString subMenu, smenus ) {
617 menuId = createMenu( subMenu, menuId, -1, 0 );
619 createMenu( a, menuId, -1, 0 );
624 // - Additional help items
626 createMenu( separator(), helpMenu, -1, 5 );
628 QStringList addHelpItems = resMgr->parameters( "add_help" );
629 foreach ( QString addHelpItem, addHelpItems ) {
630 QString valueStr = resMgr->stringValue( "add_help", addHelpItem );
631 if ( !valueStr.isEmpty() && QFile::exists( valueStr ) ) {
632 QAction* a = createAction( id, addHelpItem,
633 resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
634 addHelpItem, addHelpItem,
635 0, desk, false, this, SLOT( onHelpContentsModule() ) );
636 a->setData( valueStr );
637 createMenu( a, helpMenu, -1, 5 );
643 static QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), 0 );
644 connect( mru, SIGNAL( activated( const QString& ) ), this, SLOT( onMRUActivated( const QString& ) ) );
645 registerAction( MRUId, mru );
647 // default icon for neutral point ('SALOME' module)
648 QPixmap defIcon = resMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
649 if ( defIcon.isNull() )
650 defIcon = QPixmap( imageEmptyIcon );
652 //! default icon for any module
653 QPixmap modIcon = resMgr->loadPixmap( "LightApp", tr( "APP_MODULE_ICO" ), false );
654 if ( modIcon.isNull() )
655 modIcon = QPixmap( imageEmptyIcon );
658 modules( modList, false );
660 if ( modList.count() > 1 )
662 LightApp_ModuleAction* moduleAction =
663 new LightApp_ModuleAction( tr( "APP_NAME" ), defIcon, desk );
665 QMap<QString, QString> iconMap;
666 moduleIconNames( iconMap );
668 const int iconSize = 20;
670 QStringList::Iterator it;
671 for ( it = modList.begin(); it != modList.end(); ++it )
673 if ( !isLibExists( *it ) )
676 QString modName = moduleName( *it );
678 if ( !isModuleAccessible( *it ) )
682 if ( iconMap.contains( *it ) )
683 iconName = iconMap[*it];
685 QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
689 INFOS ( "\n****************************************************************" << std::endl
690 << "* Icon for " << (*it).toLatin1().constData()
691 << " not found. Using the default one." << std::endl
692 << "****************************************************************" << std::endl );
695 icon = Qtx::scaleIcon( icon, iconSize );
697 moduleAction->insertModule( *it, icon );
700 connect( moduleAction, SIGNAL( moduleActivated( const QString& ) ),
701 this, SLOT( onModuleActivation( const QString& ) ) );
702 registerAction( ModulesListId, moduleAction );
706 int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, MenuWindowId, 100 );
707 int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
709 createAction( CloseId, tr( "TOT_CLOSE" ), QIcon(), tr( "MEN_DESK_CLOSE" ), tr( "PRP_CLOSE" ),
710 Qt::CTRL+Qt::Key_F4, desk, false, this, SLOT( onCloseWindow() ) );
711 createAction( CloseAllId, tr( "TOT_CLOSE_ALL" ), QIcon(), tr( "MEN_DESK_CLOSE_ALL" ), tr( "PRP_CLOSE_ALL" ),
712 0, desk, false, this, SLOT( onCloseAllWindow() ) );
713 createAction( GroupAllId, tr( "TOT_GROUP_ALL" ), QIcon(), tr( "MEN_DESK_GROUP_ALL" ), tr( "PRP_GROUP_ALL" ),
714 0, desk, false, this, SLOT( onGroupAllWindow() ) );
716 createMenu( CloseId, windowMenu, 0, -1 );
717 createMenu( CloseAllId, windowMenu, 0, -1 );
718 createMenu( GroupAllId, windowMenu, 0, -1 );
719 createMenu( separator(), windowMenu, -1, 0 );
721 #ifndef DISABLE_GLVIEWER
722 createActionForViewer( NewGLViewId, newWinMenu, QString::number( 0 ), Qt::ALT+Qt::Key_G );
724 #ifndef DISABLE_PLOT2DVIEWER
725 createActionForViewer( NewPlot2dId, newWinMenu, QString::number( 1 ), Qt::ALT+Qt::Key_P );
727 #ifndef DISABLE_OCCVIEWER
728 createActionForViewer( NewOCCViewId, newWinMenu, QString::number( 2 ), Qt::ALT+Qt::Key_O );
730 #ifndef DISABLE_VTKVIEWER
731 createActionForViewer( NewVTKViewId, newWinMenu, QString::number( 3 ), Qt::ALT+Qt::Key_K );
733 #ifndef DISABLE_QXGRAPHVIEWER
734 createActionForViewer( NewQxSceneViewId, newWinMenu, QString::number( 4 ), Qt::ALT+Qt::Key_S );
736 #ifndef DISABLE_GRAPHICSVIEW
737 createActionForViewer( NewGraphicsViewId, newWinMenu, QString::number( 5 ), Qt::ALT+Qt::Key_R );
740 createAction( RenameId, tr( "TOT_RENAME" ), QIcon(), tr( "MEN_DESK_RENAME" ), tr( "PRP_RENAME" ),
741 Qt::ALT+Qt::SHIFT+Qt::Key_R, desk, false, this, SLOT( onRenameWindow() ) );
742 createMenu( RenameId, windowMenu, -1 );
744 int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
745 createMenu( PreferencesId, fileMenu, 50, -1 );
746 createMenu( separator(), fileMenu, -1, 50, -1 );
748 createMenu( separator(), fileMenu, -1, 100, -1 );
749 createMenu( MRUId, fileMenu, 100, -1 );
750 createMenu( separator(), fileMenu, -1, 100, -1 );
752 createAction( StyleId, tr( "TOT_THEME" ), QIcon(), tr( "MEN_DESK_THEME" ), tr( "PRP_THEME" ),
753 0, desk, false, this, SLOT( onStylePreferences() ) );
755 createAction( FullScreenId, tr( "TOT_FULLSCREEN" ), QIcon(), tr( "MEN_DESK_FULLSCREEN" ), tr( "PRP_FULLSCREEN" ),
756 Qt::Key_F11, desk, false, this, SLOT( onFullScreen() ) );
759 int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1 );
760 createMenu( separator(), viewMenu, -1, 20, -1 );
761 createMenu( StyleId, viewMenu, 20, -1 );
762 createMenu( FullScreenId, viewMenu, 20, -1 );
764 int modTBar = createTool( tr( "INF_TOOLBAR_MODULES" ) );
765 createTool( ModulesListId, modTBar );
768 /*!On module activation action.*/
769 void LightApp_Application::onModuleActivation( const QString& modName )
771 // Force user to create/open a study before module activation
772 QMap<QString, QString> iconMap;
773 moduleIconNames( iconMap );
774 QPixmap icon = resourceMgr()->loadPixmap( moduleName( modName ), iconMap[ modName ], false );
776 icon = resourceMgr()->loadPixmap( "LightApp", tr( "APP_MODULE_BIG_ICO" ), false ); // default icon for any module
778 bool cancelled = false;
780 while ( !modName.isEmpty() && !activeStudy() && !cancelled ){
781 LightApp_ModuleDlg aDlg( desktop(), modName, icon );
782 QMap<int, QString> opmap = activateModuleActions();
783 for ( QMap<int, QString>::ConstIterator it = opmap.begin(); it != opmap.end(); ++it )
784 aDlg.addButton( it.value(), it.key() );
786 int res = aDlg.exec();
788 // some operation is selected
789 moduleActionSelected( res );
793 putInfo( tr("INF_CANCELLED") );
795 LightApp_ModuleAction* moduleAction =
796 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
798 moduleAction->setActiveModule( QString() );
804 activateModule( modName );
807 /*!Default module activation.*/
808 QString LightApp_Application::defaultModule() const
810 QStringList aModuleNames;
811 modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration
812 //! If there's the one and only module --> activate it automatically
813 //! TODO: Possible improvement - default module can be taken from preferences
814 return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" );
817 /*!On new window slot.*/
818 void LightApp_Application::onNewWindow()
820 const QObject* obj = sender();
821 if ( !obj || !obj->inherits( "QAction" ) )
825 int id = actionId( (QAction*)obj );
828 #ifndef DISABLE_GLVIEWER
830 type = GLViewer_Viewer::Type();
833 #ifndef DISABLE_PLOT2DVIEWER
835 type = Plot2d_Viewer::Type();
838 #ifndef DISABLE_OCCVIEWER
840 type = OCCViewer_Viewer::Type();
843 #ifndef DISABLE_VTKVIEWER
845 type = VTKViewer_Viewer::Type();
848 #ifndef DISABLE_QXGRAPHVIEWER
849 case NewQxSceneViewId:
850 type = QxScene_Viewer::Type();
853 #ifndef DISABLE_GRAPHICSVIEW
854 case NewGraphicsViewId:
855 type = GraphicsView_Viewer::Type();
860 if ( !type.isEmpty() )
861 createViewManager( type );
865 SLOT: Creates new document
867 void LightApp_Application::onNewDoc()
869 //asl: fix for 0020515
871 saveDockWindowsState();
873 CAM_Application::onNewDoc();
877 SLOT: Opens new document
879 void LightApp_Application::onOpenDoc()
881 SUIT_Study* study = activeStudy();
882 saveDockWindowsState();
884 CAM_Application::onOpenDoc();
886 if ( !study ) // new study will be create in THIS application
889 updateViewManagers();
894 SLOT: Opens new document.
895 \param aName - name of file
897 bool LightApp_Application::onOpenDoc( const QString& aName )
899 // We should take mru action first because this application instance can be deleted later.
900 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
902 bool res = CAM_Application::onOpenDoc( aName );
907 mru->insert( aName );
909 mru->remove( aName );
915 SLOT: Displays "About" message box
917 void LightApp_Application::onHelpAbout()
919 LightApp_AboutDlg dlg( applicationName(), applicationVersion(), desktop() );
924 Private SLOT: Called on selection is changed
925 Dispatchs active module that selection is changed
927 void LightApp_Application::onSelection()
929 onSelectionChanged();
931 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
932 ((LightApp_Module*)activeModule())->selectionChanged();
937 \param study - SUIT_Study.
939 void LightApp_Application::setActiveStudy( SUIT_Study* study )
941 CAM_Application::setActiveStudy( study );
945 Enables/Disables menu items and toolbar buttons. Rebuild menu
947 void LightApp_Application::updateCommandsStatus()
949 CAM_Application::updateCommandsStatus();
952 #ifndef DISABLE_GLVIEWER
953 a = action( NewGLViewId );
955 a->setEnabled( activeStudy() );
958 #ifndef DISABLE_PLOT2DVIEWER
959 a = action( NewPlot2dId );
961 a->setEnabled( activeStudy() );
964 #ifndef DISABLE_OCCVIEWER
965 a = action( NewOCCViewId );
967 a->setEnabled( activeStudy() );
970 #ifndef DISABLE_VTKVIEWER
971 a = action( NewVTKViewId );
973 a->setEnabled( activeStudy() );
976 #ifndef DISABLE_QXGRAPHVIEWER
977 a = action( NewQxSceneViewId );
979 a->setEnabled( activeStudy() );
982 #ifndef DISABLE_GRAPHICSVIEW
983 a = action( NewGraphicsViewId );
985 a->setEnabled( activeStudy() );
991 Runs system command in separate thread
993 class RunBrowser: public QThread
996 RunBrowser( LightApp_Application* app,
997 const QString& theApp,
998 const QString& theParams,
999 const QString& theHelpFile,
1000 const QString& theContext = QString() )
1002 myParams( theParams ),
1003 myContext( theContext ),
1007 //For the external browser always specify 'file://' protocol,
1008 //because some WEB browsers (for example Mozilla Firefox) can't open local file without protocol.
1009 myHelpFile = QString("file://%1").arg( QFileInfo( theHelpFile ).canonicalFilePath() );
1014 if ( !myApp.isEmpty() && !myHelpFile.isEmpty()) {
1015 QString aCommand = QString( "%1 %2 \"%3%4\"" ).arg( myApp, myParams, myHelpFile, myContext.isEmpty() ? QString("") : QString( "#%1" ).arg( myContext ) );
1017 QProcess* proc = new QProcess();
1019 proc->start( aCommand );
1020 if ( !proc->waitForStarted() ) {
1021 SALOME_CustomEvent* ce2000 = new SALOME_CustomEvent( 2000 );
1022 QString* msg = new QString( QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).arg( myApp, myHelpFile ) );
1023 ce2000->setData( msg );
1024 QApplication::postEvent( myLApp, ce2000 );
1035 LightApp_Application* myLApp;
1039 SLOT: Displays help contents for choosen module
1041 void LightApp_Application::onHelpContentsModule()
1043 const QAction* a = (QAction*) sender();
1044 QString helpFile = a->data().toString();
1045 if ( helpFile.isEmpty() ) return;
1047 SUIT_ResourceMgr* resMgr = resourceMgr();
1050 platform = "winapplication";
1052 platform = "application";
1054 QString anApp = resMgr->stringValue("ExternalBrowser", platform);
1056 QString quote("\"");
1057 anApp.prepend( quote );
1058 anApp.append( quote );
1060 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
1061 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1063 if( useExtBrowser ) {
1064 if ( !anApp.isEmpty() ) {
1065 RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile );
1069 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1070 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1071 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1073 showPreferences( tr( "PREF_APP" ) );
1078 // On Win32 platform QWebKit of the Qt 4.6.3 hang up in case 'file://' protocol
1079 // is defined. On Linux platform QWebKit doesn't work correctly without 'file://' protocol.
1080 QtxWebBrowser::loadUrl(helpFile);
1082 QtxWebBrowser::loadUrl(QString("file://%1").arg(helpFile));
1088 SLOT: Displays help contents for choosen dialog
1090 void LightApp_Application::onHelpContextModule( const QString& theComponentName,
1091 const QString& theFileName,
1092 const QString& theContext )
1094 QString fileName = theFileName;
1095 QString context = theContext;
1096 if ( !QFile::exists( fileName ) && theContext.isEmpty() ) {
1097 // context might be passed within theFileName argument
1098 QStringList comps = fileName.split("#");
1099 if ( comps.count() > 1 ) {
1100 context = comps.last();
1102 fileName = comps.join("#");
1106 QString homeDir = "";
1107 if ( !theComponentName.isEmpty() ) {
1108 QString dir = getenv( ( theComponentName + "_ROOT_DIR" ).toLatin1().constData() );
1109 if ( !dir.isEmpty() )
1110 homeDir = Qtx::addSlash( Qtx::addSlash( dir ) +
1111 Qtx::addSlash( "share" ) +
1112 Qtx::addSlash( "doc" ) +
1113 Qtx::addSlash( "salome" ) +
1114 Qtx::addSlash( "gui" ) +
1115 Qtx::addSlash( theComponentName ) );
1118 QString helpFile = QFileInfo( homeDir + fileName ).absoluteFilePath();
1119 SUIT_ResourceMgr* resMgr = resourceMgr();
1122 platform = "winapplication";
1124 platform = "application";
1126 QString anApp = resMgr->stringValue("ExternalBrowser", platform);
1128 QString quote("\"");
1129 anApp.prepend( quote );
1130 anApp.append( quote );
1133 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1136 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
1138 if ( !anApp.isEmpty() ) {
1139 RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile, context );
1143 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1144 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1145 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1146 showPreferences( tr( "PREF_APP" ) );
1151 // On Win32 platform QWebKit of the Qt 4.6.3 hang up in case 'file://' protocol
1152 // is defined. On Linux platform QWebKit doesn't work correctly without 'file://' protocol.
1153 QtxWebBrowser::loadUrl(helpFile, context);
1155 QtxWebBrowser::loadUrl(QString("file://%1").arg(helpFile), context);
1162 Sets enable or disable some actions on selection changed.
1164 void LightApp_Application::onSelectionChanged()
1166 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
1167 bool canCopy = m ? m->canCopy() : false;
1168 bool canPaste = m ? m->canPaste() : false;
1170 action( EditCopyId )->setEnabled(canCopy);
1171 action( EditPasteId )->setEnabled(canPaste);
1175 Adds window to application.
1176 \param wid - QWidget
1177 \param flag - key for window
1178 \param studyId - study id
1179 Flag used how identificator of window in windows list.
1182 void LightApp_Application::addWindow( QWidget* wid, const int flag, const int studyId )
1190 if ( !activeStudy() )
1193 sId = activeStudy()->id();
1196 if ( !myWindows.contains( flag ) )
1198 QMap<int, int> winMap;
1199 currentWindows( winMap );
1201 LightApp_WidgetContainer* newWC = new LightApp_WidgetContainer( flag, desktop() );
1202 connect( newWC, SIGNAL( destroyed ( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
1203 // asv: connecting a slot for storing visibility flag of a window
1204 connect( newWC, SIGNAL( visibilityChanged ( bool ) ), SLOT( onVisibilityChanged( bool ) ) );
1205 myWindows.insert( flag, newWC );
1206 if ( winMap.contains( flag ) ) {
1207 //desktop()->removeDockWidget( myWindows[flag] );
1208 desktop()->addDockWidget( (Qt::DockWidgetArea)winMap[flag], myWindows[flag] );
1211 //myWindows[flag]->setResizeEnabled( true );
1212 myWindows[flag]->setFeatures( QDockWidget::AllDockWidgetFeatures );
1213 myWindows[flag]->setObjectName( QString( "dock_window_%1" ).arg( flag ) );
1214 //myWindows[flag]->setFixedExtentWidth( wid->width() );
1215 //myWindows[flag]->setFixedExtentHeight( wid->height() );
1216 myWindows[flag]->resize( wid->width(), wid->height() );
1220 #ifndef DISABLE_PYCONSOLE
1221 if( wid->inherits( "PyConsole_Console" ) )
1223 if( resourceMgr()->hasValue( "PyConsole", "font" ) )
1224 f = resourceMgr()->fontValue( "PyConsole", "font" );
1227 f = ( ( PyConsole_Console* )wid )->font();
1228 resourceMgr()->setValue( "PyConsole", "font", f );
1235 myWindows[flag]->insert( sId, wid );
1238 setWindowShown( flag, !myWindows[flag]->isEmpty() );
1242 QWidget* LightApp_Application::dockWindow( const int id ) const
1245 if ( myWin.contains( id ) )
1250 QDockWidget* LightApp_Application::windowDock( QWidget* wid ) const
1255 QDockWidget* dock = 0;
1256 QWidget* w = wid->parentWidget();
1257 while ( w && !dock )
1259 dock = ::qobject_cast<QDockWidget*>( w );
1260 w = w->parentWidget();
1265 void LightApp_Application::insertDockWindow( const int id, QWidget* wid )
1270 if ( wid != dockWindow( id ) )
1271 removeDockWindow( id );
1273 myWin.insert( id, wid );
1275 QtxDockWidget* dock = new QtxDockWidget( true, desktop() );
1276 connect( dock, SIGNAL( destroyed( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
1278 dock->setFeatures( QDockWidget::AllDockWidgetFeatures );
1279 dock->setObjectName( QString( "window_%1" ).arg( id ) );
1280 dock->setWidget( wid );
1282 QKeySequence accel = wid->property( "shortcut" ).value<QKeySequence>();
1283 if ( !accel.isEmpty() )
1284 dock->toggleViewAction()->setShortcut( accel );
1289 void LightApp_Application::removeDockWindow( const int id )
1291 QWidget* wid = dockWindow( id );
1297 QDockWidget* dock = windowDock( wid );
1301 dock->setWidget( 0 );
1302 wid->setParent( 0 );
1303 wid->setVisible( false );
1307 void LightApp_Application::placeDockWindow( const int id, Qt::DockWidgetArea place )
1309 QDockWidget* dock = windowDock( dockWindow( id ) );
1310 if ( dock && desktop() ) {
1311 desktop()->addDockWidget( place, dock );
1312 QtxDockAction* a = qobject_cast<QtxDockAction*>( action( ViewWindowsId ) );
1313 if ( a ) a->update();
1319 \param flag - key for window
1320 \param studyId - study id
1321 Flag used how identificator of window in windows list.
1323 QWidget* LightApp_Application::getWindow( const int flag, const int )
1325 QWidget* wid = dockWindow( flag );
1327 insertDockWindow( flag, wid = createWindow( flag ) );
1329 QMap<int, int> winMap;
1330 currentWindows( winMap );
1331 if ( winMap.contains( flag ) )
1332 placeDockWindow( flag, (Qt::DockWidgetArea)winMap[flag] );
1338 \return Object Browser
1340 SUIT_DataBrowser* LightApp_Application::objectBrowser()
1342 return qobject_cast<SUIT_DataBrowser*>( dockWindow( WT_ObjectBrowser ) );
1348 LogWindow* LightApp_Application::logWindow()
1350 return qobject_cast<LogWindow*>( dockWindow( WT_LogWindow ) );
1353 #ifndef DISABLE_PYCONSOLE
1355 This returns the python console integrated to the GUI. Depending
1356 when you request the python console, this function could return
1357 null. Then the optional parameter force (default to false) can be
1358 set to force the creation of the python console if it is not done
1360 \param force - if true, the pythonConsole is created if it does not exist yet
1361 \return Python Console
1363 PyConsole_Console* LightApp_Application::pythonConsole(const bool force)
1365 QWidget* wid = dockWindow( WT_PyConsole );
1366 if ( !wid && force==true) {
1367 wid = getWindow(WT_PyConsole);
1369 return qobject_cast<PyConsole_Console*>( wid );
1374 Updates object browser and maybe data models
1375 \param updateModels - if it is true, then data models are updated
1377 void LightApp_Application::updateObjectBrowser( const bool updateModels )
1379 // update existing data models
1382 const bool isAutoUpdate = objectBrowser() ? objectBrowser()->autoUpdate() : true;
1383 if ( objectBrowser() )
1384 objectBrowser()->setAutoUpdate( false );
1386 LightApp_Study* study = dynamic_cast<LightApp_Study*>(activeStudy());
1388 CAM_Study::ModelList dm_list;
1389 study->dataModels( dm_list );
1390 QListIterator<CAM_DataModel*> it( dm_list );
1391 while ( it.hasNext() ) {
1392 CAM_DataModel* camDM = it.next();
1393 if ( camDM && camDM->inherits( "LightApp_DataModel" ) )
1394 ((LightApp_DataModel*)camDM)->update();
1398 if( objectBrowser() )
1399 objectBrowser()->setAutoUpdate( isAutoUpdate );
1402 if ( objectBrowser() ) {
1403 objectBrowser()->updateGeometry();
1404 objectBrowser()->updateTree( 0, false );
1411 LightApp_Preferences* LightApp_Application::preferences() const
1413 return preferences( false );
1417 \return first view manager of some type
1418 \param vmType - type of view manager
1419 \param create - is it necessary to create view manager in case, when there is no manager of such type
1421 SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, const bool create )
1423 SUIT_ViewManager* aVM = viewManager( vmType );
1424 SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
1426 if ( anActiveVM && anActiveVM->getType() == vmType )
1429 if ( aVM && create )
1431 if ( !aVM->getActiveView() )
1434 aVM->getActiveView()->setFocus();
1437 aVM = createViewManager( vmType );
1443 Creates view manager of some type
1444 \param vmType - type of view manager
1446 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType )
1448 SUIT_ResourceMgr* resMgr = resourceMgr();
1450 SUIT_ViewManager* viewMgr = 0;
1451 #ifndef DISABLE_GLVIEWER
1452 if( vmType == GLViewer_Viewer::Type() )
1454 viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() );
1455 new LightApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
1458 #ifndef DISABLE_PLOT2DVIEWER
1459 if( vmType == Plot2d_Viewer::Type() )
1461 viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
1463 #ifndef DISABLE_SALOMEOBJECT
1464 SPlot2d_Viewer* v = new SPlot2d_Viewer();
1466 new LightApp_Plot2dSelector( v, mySelMgr );
1468 vm = new Plot2d_Viewer();
1470 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1471 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
1474 Plot2d_ViewFrame* frame = wnd->getViewFrame();
1475 frame->setBackgroundColor( resMgr->colorValue( "Plot2d", "Background", frame->backgroundColor() ) );
1479 #ifndef DISABLE_QXGRAPHVIEWER
1480 if( vmType == QxScene_Viewer::Type() )
1482 viewMgr = new QxScene_ViewManager( activeStudy(), desktop() );
1483 QxScene_Viewer* vm = new QxScene_Viewer();
1484 viewMgr->setViewModel( vm );
1485 //QxScene_ViewWindow* wnd = dynamic_cast<QxScene_ViewWindow*>( viewMgr->getActiveView() );
1488 #ifndef DISABLE_GRAPHICSVIEW
1489 if( vmType == GraphicsView_Viewer::Type() )
1491 viewMgr = new GraphicsView_ViewManager( activeStudy(), desktop() );
1492 new LightApp_GVSelector( (GraphicsView_Viewer*)viewMgr->getViewModel(), mySelMgr );
1495 #ifndef DISABLE_OCCVIEWER
1496 if( vmType == OCCViewer_Viewer::Type() )
1498 viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
1499 OCCViewer_Viewer* vm;
1500 #ifndef DISABLE_SALOMEOBJECT
1501 vm = new SOCC_Viewer();
1503 vm = new OCCViewer_Viewer( true );
1505 vm->setBackground( OCCViewer_ViewFrame::TOP_LEFT,
1506 resMgr->backgroundValue( "OCCViewer", "xz_background", vm->background(OCCViewer_ViewFrame::TOP_LEFT) ) );
1507 vm->setBackground( OCCViewer_ViewFrame::TOP_RIGHT,
1508 resMgr->backgroundValue( "OCCViewer", "yz_background", vm->background(OCCViewer_ViewFrame::TOP_RIGHT) ) );
1509 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_LEFT,
1510 resMgr->backgroundValue( "OCCViewer", "xy_background", vm->background(OCCViewer_ViewFrame::BOTTOM_LEFT) ) );
1511 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_RIGHT,
1512 resMgr->backgroundValue( "OCCViewer", "background", vm->background(OCCViewer_ViewFrame::MAIN_VIEW) ) );
1514 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1515 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ));
1516 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1517 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1518 vm->enablePreselection( resMgr->booleanValue( "OCCViewer", "enable_preselection", vm->isPreselectionEnabled() ) );
1519 vm->enableSelection( resMgr->booleanValue( "OCCViewer", "enable_selection", vm->isSelectionEnabled() ) );
1521 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1522 new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
1525 #ifndef DISABLE_VTKVIEWER
1526 #ifndef DISABLE_SALOMEOBJECT
1527 if ( vmType == SVTK_Viewer::Type() )
1529 if ( vmType == VTKViewer_Viewer::Type() )
1532 #ifndef DISABLE_SALOMEOBJECT
1533 viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
1534 SVTK_Viewer* vm = dynamic_cast<SVTK_Viewer*>( viewMgr->getViewModel() );
1537 vm->setProjectionMode( resMgr->integerValue( "VTKViewer", "projection_mode", vm->projectionMode() ) );
1538 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1539 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1540 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ) );
1541 vm->setStaticTrihedronVisible( resMgr->booleanValue( "3DViewer", "show_static_trihedron", vm->isStaticTrihedronVisible() ) );
1542 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1543 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1544 vm->setPreSelectionMode(resMgr->integerValue( "VTKViewer", "preselection", vm->preSelectionMode() ) );
1545 vm->enableSelection( resMgr->booleanValue( "VTKViewer", "enable_selection", vm->isSelectionEnabled() ) );
1546 vm->setIncrementalSpeed( resMgr->integerValue( "VTKViewer", "speed_value", vm->incrementalSpeed() ),
1547 resMgr->integerValue( "VTKViewer", "speed_mode", vm->incrementalSpeedMode() ) );
1548 vm->setSpacemouseButtons( resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", vm->spacemouseBtn(1) ),
1549 resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", vm->spacemouseBtn(2) ),
1550 resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", vm->spacemouseBtn(3) ) );
1551 new LightApp_VTKSelector( vm, mySelMgr );
1554 viewMgr = new VTKViewer_ViewManager( activeStudy(), desktop() );
1555 VTKViewer_Viewer* vm = dynamic_cast<VTKViewer_Viewer*>( viewMgr->getViewModel() );
1557 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1565 addViewManager( viewMgr );
1566 SUIT_ViewWindow* viewWin = viewMgr->createViewWindow();
1568 if ( viewWin && desktop() ) {
1569 viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1570 viewWin->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1576 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, QWidget* w )
1578 SUIT_ResourceMgr* resMgr = resourceMgr();
1580 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
1582 new LightApp_WgViewModel( vmType, w ) );
1583 vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
1585 addViewManager( vm );
1586 SUIT_ViewWindow* vw = vm->createViewWindow();
1587 if ( vw && desktop() ) {
1588 vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1589 vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1592 if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
1593 myUserWmTypes << vmType;
1599 SLOT: Removes view manager from application
1601 void LightApp_Application::onCloseView( SUIT_ViewManager* theVM )
1603 removeViewManager( theVM );
1607 Protected SLOT: On study created.
1608 \param theStudy - just created study
1610 void LightApp_Application::onStudyCreated( SUIT_Study* theStudy )
1612 SUIT_DataObject* aRoot = 0;
1613 if ( theStudy && theStudy->root() )
1615 aRoot = theStudy->root();
1616 //aRoot->setName( tr( "DATA_MODELS" ) );
1619 getWindow( WT_ObjectBrowser );
1621 loadDockWindowsState();
1623 if ( objectBrowser() )
1624 objectBrowser()->setRoot( aRoot );
1626 activateModule( defaultModule() );
1628 if ( objectBrowser() )
1629 objectBrowser()->openLevels();
1633 Protected SLOT: On study opened.
1634 \param theStudy - just opened study
1636 void LightApp_Application::onStudyOpened( SUIT_Study* theStudy )
1638 SUIT_DataObject* aRoot = 0;
1639 if ( theStudy && theStudy->root() )
1641 aRoot = theStudy->root();
1645 getWindow( WT_ObjectBrowser );
1647 loadDockWindowsState();
1649 if ( objectBrowser() )
1650 objectBrowser()->setRoot( aRoot );
1652 activateModule( defaultModule() );
1654 if ( objectBrowser() )
1655 objectBrowser()->openLevels();
1660 /*!Protected SLOT. On study saved.*/
1661 void LightApp_Application::onStudySaved( SUIT_Study* s )
1663 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
1665 mru->insert( s->studyName() );
1670 /*!Protected SLOT. On study closed.*/
1671 void LightApp_Application::onStudyClosed( SUIT_Study* s )
1673 // stop auto-save timer
1674 myAutoSaveTimer->stop();
1676 // Bug 10396: clear selection
1677 mySelMgr->clearSelected();
1679 // Bug 12944: emit signal only after clear selection
1682 activateModule( "" );
1685 /*!Protected SLOT.On desktop activated.*/
1686 void LightApp_Application::onDesktopActivated()
1688 CAM_Application::onDesktopActivated();
1689 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>(activeModule());
1691 aModule->studyActivated();
1694 void LightApp_Application::studyOpened( SUIT_Study* s )
1696 CAM_Application::studyOpened( s );
1699 updateViewManagers();
1702 void LightApp_Application::studySaved( SUIT_Study* s )
1704 CAM_Application::studyOpened( s );
1705 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1706 if ( aResMgr && activeStudy() ) {
1707 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
1708 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
1712 void LightApp_Application::studyCreated( SUIT_Study* s )
1714 CAM_Application::studyCreated( s );
1717 updateViewManagers();
1720 /*!Gets file filter.
1721 *\retval QString "(*.bin)"
1723 QString LightApp_Application::getFileFilter() const
1731 Shows file dialog and return user selected file name
1733 QString LightApp_Application::getFileName( bool open, const QString& initial, const QString& filters,
1734 const QString& caption, QWidget* parent )
1738 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1739 return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
1742 /*! Gets directory*/
1743 QString LightApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
1747 return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true );
1750 /*! Get open file names*/
1751 QStringList LightApp_Application::getOpenFileNames( const QString& initial, const QString& filters,
1752 const QString& caption, QWidget* parent )
1756 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1757 return SUIT_FileDlg::getOpenFileNames( parent, initial, fls, caption, true );
1760 /*!Private SLOT. Update object browser.*/
1761 void LightApp_Application::onRefresh()
1763 updateObjectBrowser( true );
1766 /*!Private SLOT. Support drag-and-drop operation.*/
1767 void LightApp_Application::onDropped( const QList<SUIT_DataObject*>& objects, SUIT_DataObject* parent, int row, Qt::DropAction action )
1769 LightApp_DataObject* parentObj = dynamic_cast<LightApp_DataObject*>( parent );
1773 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>( parentObj->module() );
1775 aModule->dropObjects( objects, parentObj, row, action );
1778 /*!Private SLOT. On preferences.*/
1779 void LightApp_Application::onPreferences()
1781 showPreferences( activeModule() ? activeModule()->moduleName() : tr( "PREF_CATEGORY_SALOME" ) );
1784 /*!Private SLOT. On preferences.*/
1785 void LightApp_Application::showPreferences( const QString& itemText )
1787 QApplication::setOverrideCursor( Qt::WaitCursor );
1789 LightApp_PreferencesDlg* prefDlg = new LightApp_PreferencesDlg( preferences( true ), desktop());
1791 QApplication::restoreOverrideCursor();
1796 preferences()->activateItem( itemText );
1798 if ( ( prefDlg->exec() == QDialog::Accepted || prefDlg->isSaved() ) && resourceMgr() )
1801 resourceMgr()->setValue( "desktop", "geometry", desktop()->storeGeometry() );
1802 resourceMgr()->save();
1805 shortcutMgr()->updateShortcuts();
1811 /*!Protected SLOT. On preferences changed.*/
1812 void LightApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param )
1814 LightApp_Module* sMod = 0;
1815 CAM_Module* mod = module( modName );
1816 if ( mod && mod->inherits( "LightApp_Module" ) )
1817 sMod = (LightApp_Module*)mod;
1820 sMod->preferencesChanged( section, param );
1822 preferencesChanged( section, param );
1823 // emit signal to allow additional preferences changing processing
1824 emit preferenceChanged( modName, section, param );
1827 /*!Remove all windows from study.*/
1828 void LightApp_Application::beforeCloseDoc( SUIT_Study* s )
1830 if ( SUIT_DataBrowser* ob = objectBrowser() )
1833 CAM_Application::beforeCloseDoc( s );
1836 /*!Update actions.*/
1837 void LightApp_Application::updateActions()
1839 updateCommandsStatus();
1845 SUIT_Study* LightApp_Application::createNewStudy()
1847 LightApp_Application::lastStudyId++;
1849 LightApp_Study* aStudy = new LightApp_Study( this );
1851 // Set up processing of major study-related events
1852 connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
1853 connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
1854 connect( aStudy, SIGNAL( saved ( SUIT_Study* ) ), this, SLOT( onStudySaved ( SUIT_Study* ) ) );
1855 connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
1861 Creates window by flag.
1862 \param flag - identificator of window type
1864 QWidget* LightApp_Application::createWindow( const int flag )
1868 SUIT_ResourceMgr* resMgr = resourceMgr();
1870 if ( flag == WT_ObjectBrowser )
1872 SUIT_DataBrowser* ob = new SUIT_DataBrowser( new LightApp_DataObject(), desktop() );
1873 ob->setSortMenuEnabled( true );
1874 ob->setAutoUpdate( true );
1875 if ( resMgr->hasValue( "ObjectBrowser", "auto_hide_search_tool" ) )
1876 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
1878 //ob->setAutoOpenLevel( 1 ); // commented by ASV as a fix to bug IPAL10107
1879 ob->setWindowTitle( tr( "OBJECT_BROWSER" ) );
1880 connect( ob, SIGNAL( requestUpdate() ), this, SLOT( onRefresh() ) );
1882 QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
1883 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
1884 treeModel->setSearcher( this );
1885 treeModel->registerColumn( 0, EntryCol, LightApp_DataObject::EntryId );
1886 treeModel->setAppropriate( EntryCol, Qtx::Toggled );
1888 // Mantis issue 0020136: Drag&Drop in OB
1889 SUIT_ProxyModel* proxyModel = dynamic_cast<SUIT_ProxyModel*>(treeModel);
1891 connect( proxyModel, SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
1892 this, SLOT( onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
1895 // temporary commented
1897 OB_ListView* ob_list = dynamic_cast<OB_ListView*>( const_cast<QListView*>( ob->listView() ) );
1899 ob_list->setColumnMaxWidth( 0, desktop()->width()/4 );
1902 // Create OBSelector
1903 new LightApp_OBSelector( ob, mySelMgr );
1905 ob->treeView()->header()->setResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
1906 ob->treeView()->header()->moveSection(SUIT_DataObject::NameId,SUIT_DataObject::VisibilityId);
1907 ob->treeView()->setColumnWidth(SUIT_DataObject::VisibilityId, VISIBILITY_COLUMN_WIDTH);
1908 ob->setProperty( "shortcut", QKeySequence( "Alt+Shift+O" ) );
1910 ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1912 #ifndef DISABLE_PYCONSOLE
1913 else if ( flag == WT_PyConsole )
1915 PyConsole_Console* pyCons = new PyConsole_EnhConsole( desktop(),new LightApp_PyInterp());
1916 pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
1917 pyCons->setFont(resourceMgr()->fontValue( "PyConsole", "font" ));
1918 pyCons->setIsShowBanner(resourceMgr()->booleanValue( "PyConsole", "show_banner", true ));
1919 pyCons->setProperty( "shortcut", QKeySequence( "Alt+Shift+P" ) );
1922 pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1925 else if ( flag == WT_LogWindow )
1927 LogWindow* logWin = new LogWindow( desktop() );
1928 logWin->setWindowTitle( tr( "LOG_WINDOW" ) );
1929 logWin->setProperty( "shortcut", QKeySequence( "Alt+Shift+L" ) );
1931 logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1937 \return default windows( Object Browser, Python Console )
1938 Adds to map \a aMap.
1940 void LightApp_Application::defaultWindows( QMap<int, int>& aMap ) const
1942 aMap.insert( WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1943 #ifndef DISABLE_PYCONSOLE
1944 aMap.insert( WT_PyConsole, Qt::BottomDockWidgetArea );
1946 // aMap.insert( WT_LogWindow, Qt::DockBottom );
1949 /*!Default view managers*/
1950 void LightApp_Application::defaultViewManagers( QStringList& ) const
1956 \return preferences.
1957 Create preferences, if \a crt = true.
1959 LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const
1964 LightApp_Application* that = (LightApp_Application*)this;
1966 bool toCreate = !_prefs_ && crt;
1969 _prefs_ = new LightApp_Preferences( resourceMgr() );
1970 that->createPreferences( _prefs_ );
1973 that->myPrefs = _prefs_;
1975 connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
1976 this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ) );
1981 SUIT_ResourceMgr* resMgr = resourceMgr();
1983 QList<SUIT_Application*> appList = SUIT_Session::session()->applications();
1984 for ( QList<SUIT_Application*>::iterator appIt = appList.begin(); appIt != appList.end(); ++appIt )
1986 LightApp_Application* app = ::qobject_cast<LightApp_Application*>( *appIt );
1990 QStringList modNameList;
1991 app->modules( modNameList, false );
1993 QMap<QString, QString> iconMap;
1994 app->moduleIconNames( iconMap );
1996 for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it )
1998 if ( !app->isLibExists( *it ) || _prefs_->hasModule( *it ) )
2001 int modId = _prefs_->addPreference( *it );
2002 if ( iconMap.contains( *it ) )
2003 _prefs_->setItemIcon( modId, Qtx::scaleIcon( resMgr->loadPixmap( moduleName( *it ), iconMap[*it], false ), 20 ) );
2007 app->modules( modList );
2008 QListIterator<CAM_Module*> itr( modList );
2009 while ( itr.hasNext() )
2011 LightApp_Module* mod = 0;
2013 CAM_Module* anItem = itr.next();
2014 if ( anItem->inherits( "LightApp_Module" ) )
2015 mod = (LightApp_Module*)anItem;
2017 if ( mod && !_prefs_->hasModule( mod->moduleName() ) )
2019 _prefs_->addPreference( mod->moduleName() );
2020 mod->createPreferences();
2021 that->emptyPreferences( mod->moduleName() );
2025 _prefs_->setItemProperty( "info", tr( "PREFERENCES_NOT_LOADED" ) );
2031 Adds new module to application
2033 void LightApp_Application::moduleAdded( CAM_Module* mod )
2035 CAM_Application::moduleAdded( mod );
2037 LightApp_Module* lightMod = 0;
2038 if ( mod && mod->inherits( "LightApp_Module" ) )
2039 lightMod = (LightApp_Module*)mod;
2041 if ( myPrefs && lightMod && !myPrefs->hasModule( lightMod->moduleName() ))
2043 myPrefs->addPreference( mod->moduleName() );
2044 lightMod->createPreferences();
2045 emptyPreferences( mod->moduleName() );
2049 void LightApp_Application::emptyPreferences( const QString& modName )
2051 QtxPreferenceItem* item = myPrefs->findItem( modName, true );
2052 if ( !item || !item->isEmpty() )
2055 // printf( "---------------------> Modify for empty module.\n" );
2057 QtxPagePrefFrameItem* frm = new QtxPagePrefFrameItem( item->title(), item->parentItem() );
2058 frm->setIcon( item->icon() );
2059 frm->setStretch( false );
2060 item->parentItem()->insertItem( frm, item );
2061 new QtxPagePrefLabelItem( Qt::AlignCenter, tr( "PREFERENCES_NOT_SUPPORTED" ).arg( modName ), frm );
2068 void LightApp_Application::createPreferences( LightApp_Preferences* pref )
2073 QStringList aValuesList;
2074 QList<QVariant> anIndicesList;
2078 // . Top-level "SALOME" preferences group <<start>>
2079 int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
2080 pref->setItemIcon( salomeCat, Qtx::scaleIcon( resourceMgr()->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false ), 20 ) );
2082 // .. "General" preferences tab <<start>>
2083 int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat );
2085 // ... "Language" group <<start>>
2086 int langGroup = pref->addPreference( tr( "PREF_GROUP_LANGUAGE" ), genTab );
2087 pref->setItemProperty( "columns", 2, langGroup );
2088 // .... -> application language
2089 int curLang = pref->addPreference( tr( "PREF_CURRENT_LANGUAGE" ), langGroup,
2090 LightApp_Preferences::Selector, "language", "language" );
2091 QStringList aLangs = SUIT_Session::session()->resourceMgr()->stringValue( "language", "languages", "en" ).split( "," );
2092 QList<QVariant> aIcons;
2093 foreach ( QString aLang, aLangs ) {
2094 aIcons << QPixmap( QString( ":/images/%1" ).arg( aLang ) );
2096 pref->setItemProperty( "strings", aLangs, curLang );
2097 pref->setItemProperty( "icons", aIcons, curLang );
2098 // ... "Language" group <<end>>
2100 // ... "Look and feel" group <<start>>
2101 int lookGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), genTab );
2102 pref->setItemProperty( "columns", 2, lookGroup );
2103 // .... -> show splash-screen
2104 pref->addPreference( tr( "PREF_SHOW_SPLASH" ), lookGroup, LightApp_Preferences::Bool, "launch", "splash" );
2105 // .... -> opaque resize
2106 pref->addPreference( tr( "PREF_OPAQUE_RESIZE" ), lookGroup, LightApp_Preferences::Bool, "desktop", "opaque_resize" );
2107 // .... -> drop-down buttons
2108 pref->addPreference( tr( "PREF_DROP_DOWN_BUTTONS" ), lookGroup, LightApp_Preferences::Bool, "viewers", "drop_down_buttons" );
2109 // ... "Look and feel" group <<end>>
2111 // ... "Study properties" group <<start>>
2112 int studyGroup = pref->addPreference( tr( "PREF_GROUP_STUDY" ), genTab );
2113 pref->setItemProperty( "columns", 2, studyGroup );
2114 // .... -> multi-file save
2115 pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "multi_file" );
2116 // .... -> ascii save mode
2117 pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" );
2118 // .... -> store windows geometry
2119 pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" );
2120 pref->addPreference( "", studyGroup, LightApp_Preferences::Space );
2121 pref->addPreference( tr( "PREF_STORE_TOOL_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_tool_positions" );
2122 // .... -> auto-save
2123 int autoSaveInterval = pref->addPreference( tr( "PREF_AUTO_SAVE" ), studyGroup,
2124 LightApp_Preferences::IntSpin, "Study", "auto_save_interval" );
2125 pref->setItemProperty( "min", 0, autoSaveInterval );
2126 pref->setItemProperty( "max", 1440, autoSaveInterval );
2127 pref->setItemProperty( "special", tr( "PREF_AUTO_SAVE_DISABLED" ), autoSaveInterval );
2128 // ... "Study properties" group <<end>>
2130 // ... "Help browser" group <<start>>
2131 int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab, LightApp_Preferences::Auto, "ExternalBrowser", "use_external_browser");
2133 QString platform = "winapplication";
2135 QString platform = "application";
2137 // .... -> browser application
2138 int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, LightApp_Preferences::File, "ExternalBrowser", platform );
2139 pref->setItemProperty( "mode", Qtx::PT_OpenFile, apppref );
2140 // .... -> browser parameters
2141 pref->addPreference( tr( "PREF_PARAM" ), extgroup, LightApp_Preferences::String, "ExternalBrowser", "parameters" );
2142 // ... "Help browser" group <<end>>
2144 // ... "Python console properties" group <<start>>
2145 int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab );
2147 pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, LightApp_Preferences::Font, "PyConsole", "font" );
2148 // .... -> show banner
2149 pref->addPreference( tr( "PREF_SHOW_BANNER" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "show_banner" );
2150 // ... "Python console properties" group <<end>>
2152 // ... "MRU" preferences group <<start>>
2153 int mruGroup = pref->addPreference( tr( "PREF_GROUP_MRU" ), genTab, LightApp_Preferences::Auto, "MRU", "show_mru" );
2154 pref->setItemProperty( "columns", 4, mruGroup );
2155 // number of MRU items
2156 int mruVisCount = pref->addPreference( tr( "PREF_MRU_VISIBLE_COUNT" ), mruGroup, LightApp_Preferences::IntSpin,
2157 "MRU", "visible_count" );
2158 pref->setItemProperty( "min", 0, mruVisCount );
2159 pref->setItemProperty( "max", 100, mruVisCount );
2161 int mruLinkType = pref->addPreference( tr( "PREF_MRU_LINK_TYPE" ), mruGroup, LightApp_Preferences::Selector,
2162 "MRU", "link_type" );
2163 aValuesList.clear();
2164 anIndicesList.clear();
2165 aValuesList << tr("PREF_MRU_LINK_AUTO") << tr("PREF_MRU_LINK_SHORT") << tr("PREF_MRU_LINK_FULL");
2166 anIndicesList << 0 << 1 << 2 ;
2167 pref->setItemProperty( "strings", aValuesList, mruLinkType );
2168 pref->setItemProperty( "indexes", anIndicesList, mruLinkType );
2169 // ... "MRU" preferences group <<end>>
2170 // .. "General" preferences tab <<end>>
2172 // .. "3D viewer" group <<start>>
2173 int Viewer3DGroup = pref->addPreference( tr( "PREF_GROUP_3DVIEWER" ), salomeCat );
2174 // ... -> navigation mode
2175 int vtkStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), Viewer3DGroup,
2176 LightApp_Preferences::Selector, "3DViewer", "navigation_mode" );
2177 aValuesList.clear();
2178 anIndicesList.clear();
2179 aValuesList << tr("PREF_STANDARD_STYLE") << tr("PREF_KEYFREE_STYLE");
2180 anIndicesList << 0 << 1;
2181 pref->setItemProperty( "strings", aValuesList, vtkStyleMode );
2182 pref->setItemProperty( "indexes", anIndicesList, vtkStyleMode );
2183 // ... -> zooming mode
2184 #if OCC_VERSION_LARGE > 0x0603000A // available only with OCC-6.3-sp11 and higher version
2185 int occZoomingStyleMode = pref->addPreference( tr( "PREF_ZOOMING" ), Viewer3DGroup,
2186 LightApp_Preferences::Selector, "3DViewer", "zooming_mode" );
2187 aValuesList.clear();
2188 anIndicesList.clear();
2189 aValuesList << tr("PREF_ZOOMING_AT_CENTER") << tr("PREF_ZOOMING_AT_CURSOR");
2190 anIndicesList << 0 << 1;
2191 pref->setItemProperty( "strings", aValuesList, occZoomingStyleMode );
2192 pref->setItemProperty( "indexes", anIndicesList, occZoomingStyleMode );
2194 // ... "Trihedron" group <<start>>
2195 int occTriGroup = pref->addPreference( tr( "PREF_TRIHEDRON" ), Viewer3DGroup );
2196 pref->setItemProperty( "columns", 2, occTriGroup );
2197 // .... -> trihedron size
2198 int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occTriGroup,
2199 LightApp_Preferences::DblSpin, "3DViewer", "trihedron_size" );
2200 pref->setItemProperty( "min", 1.0E-06, occTS );
2201 pref->setItemProperty( "max", 1000, occTS );
2202 // .... -> relative size of trihedron
2203 pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "relative_size" );
2204 // .... -> show static trihedron
2205 pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "show_static_trihedron" );
2206 // ... "Trihedron" group <<end>>
2207 // .. "3D viewer" group <<end>>
2209 // .. "OCC viewer" group <<start>>
2210 int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), salomeCat );
2212 // ... "Background" group <<start>>
2213 int bgGroup = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup );
2214 // pref->setItemProperty( "columns", 2, bgGroup );
2215 aValuesList.clear();
2216 anIndicesList.clear();
2218 QString formats = OCCViewer_Viewer::backgroundData( aValuesList, idList, txtList );
2219 foreach( int gid, idList ) anIndicesList << gid;
2220 // .... -> 3D viewer background
2221 int bgId = pref->addPreference( tr( "PREF_3DVIEWER_BACKGROUND" ), bgGroup,
2222 LightApp_Preferences::Background, "OCCViewer", "background" );
2223 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2224 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2225 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2226 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2227 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2228 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2229 pref->setItemProperty( "custom_enabled", false, bgId );
2230 pref->setItemProperty( "image_formats", formats, bgId );
2231 // .... -> XZ viewer background
2232 bgId = pref->addPreference( tr( "PREF_XZVIEWER_BACKGROUND" ), bgGroup,
2233 LightApp_Preferences::Background, "OCCViewer", "xz_background" );
2234 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2235 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2236 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2237 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2238 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2239 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2240 pref->setItemProperty( "custom_enabled", false, bgId );
2241 pref->setItemProperty( "image_formats", formats, bgId );
2242 // .... -> YZ viewer background
2243 bgId = pref->addPreference( tr( "PREF_YZVIEWER_BACKGROUND" ), bgGroup,
2244 LightApp_Preferences::Background, "OCCViewer", "yz_background" );
2245 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2246 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2247 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2248 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2249 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2250 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2251 pref->setItemProperty( "custom_enabled", false, bgId );
2252 pref->setItemProperty( "image_formats", formats, bgId );
2253 // .... -> XY viewer background
2254 bgId = pref->addPreference( tr( "PREF_XYVIEWER_BACKGROUND" ), bgGroup,
2255 LightApp_Preferences::Background, "OCCViewer", "xy_background" );
2256 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2257 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2258 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2259 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2260 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2261 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2262 pref->setItemProperty( "custom_enabled", false, bgId );
2263 pref->setItemProperty( "image_formats", formats, bgId );
2264 // ... "Background" group <<end>>
2267 // ... "Selection" group <<start>>
2268 int occSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), occGroup );
2269 pref->setItemProperty( "columns", 2, occSelectionGroup );
2270 // .... -> enable preselection
2271 pref->addPreference( tr( "PREF_ENABLE_PRESELECTION" ), occSelectionGroup,
2272 LightApp_Preferences::Bool, "OCCViewer", "enable_preselection" );
2273 // .... -> enable selection
2274 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), occSelectionGroup,
2275 LightApp_Preferences::Bool, "OCCViewer", "enable_selection" );
2276 // ... "Selection" group <<end>>
2278 // ... -> empty frame (for layout) <<start>>
2279 int occGen = pref->addPreference( "", occGroup, LightApp_Preferences::Frame );
2280 pref->setItemProperty( "margin", 0, occGen );
2281 pref->setItemProperty( "columns", 2, occGen );
2282 // ... -> empty frame (for layout) <<end>>
2283 // .. "OCC viewer" group <<end>>
2285 // .. "VTK viewer" group <<start>>
2286 int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), salomeCat ); //viewTab
2288 // ... -> empty frame (for layout) <<start>>
2289 int vtkGen = pref->addPreference( "", vtkGroup, LightApp_Preferences::Frame );
2290 //pref->setItemProperty( "columns", 2, vtkGen );
2291 // .... -> projection mode
2292 int vtkProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), vtkGen,
2293 LightApp_Preferences::Selector, "VTKViewer", "projection_mode" );
2294 aValuesList.clear();
2295 anIndicesList.clear();
2296 aValuesList << tr("PREF_ORTHOGRAPHIC") << tr("PREF_PERSPECTIVE");
2297 anIndicesList << 0 << 1;
2298 pref->setItemProperty( "strings", aValuesList, vtkProjMode );
2299 pref->setItemProperty( "indexes", anIndicesList, vtkProjMode );
2300 // .... -> background
2301 aValuesList.clear();
2302 anIndicesList.clear();
2304 formats = SVTK_Viewer::backgroundData( aValuesList, idList, txtList );
2305 foreach( int gid, idList ) anIndicesList << gid;
2306 bgId = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGen,
2307 LightApp_Preferences::Background, "VTKViewer", "background" );
2308 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2309 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2310 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2311 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2312 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2313 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2314 pref->setItemProperty( "custom_enabled", false, bgId );
2315 pref->setItemProperty( "image_formats", formats, bgId );
2316 // .... -> speed increment
2317 int vtkSpeed = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED" ), vtkGen,
2318 LightApp_Preferences::IntSpin, "VTKViewer", "speed_value" );
2319 pref->setItemProperty( "min", 1, vtkSpeed );
2320 pref->setItemProperty( "max", 1000, vtkSpeed );
2321 // .... -> speed mode
2322 int vtkSpeedMode = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED_MODE" ), vtkGen,
2323 LightApp_Preferences::Selector, "VTKViewer", "speed_mode" );
2324 aValuesList.clear();
2325 anIndicesList.clear();
2326 aValuesList << tr("PREF_ARITHMETIC") << tr("PREF_GEOMETRICAL");
2327 anIndicesList << 0 << 1;
2328 pref->setItemProperty( "strings", aValuesList, vtkSpeedMode );
2329 pref->setItemProperty( "indexes", anIndicesList, vtkSpeedMode );
2331 // ... "Selection" group <<start>>
2332 int vtkSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), vtkGroup );
2333 pref->setItemProperty( "columns", 2, vtkSelectionGroup );
2334 // .... -> preselection
2335 int vtkPreselection = pref->addPreference( tr( "PREF_PRESELECTION" ), vtkSelectionGroup,
2336 LightApp_Preferences::Selector, "VTKViewer", "preselection" );
2337 aValuesList.clear();
2338 anIndicesList.clear();
2339 aValuesList << tr("PREF_PRESELECTION_STANDARD") << tr("PREF_PRESELECTION_DYNAMIC") << tr("PREF_PRESELECTION_DISABLED");
2340 anIndicesList << 0 << 1 << 2;
2341 pref->setItemProperty( "strings", aValuesList, vtkPreselection );
2342 pref->setItemProperty( "indexes", anIndicesList, vtkPreselection );
2343 // .... -> enable selection
2344 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), vtkSelectionGroup, LightApp_Preferences::Bool, "VTKViewer", "enable_selection" );
2345 // ... "Selection" group <<end>>
2347 // ... -> empty frame (for layout) <<end>>
2349 // ... space mouse sub-group <<start>>
2350 int vtkSM = pref->addPreference( tr( "PREF_FRAME_SPACEMOUSE" ), vtkGroup, LightApp_Preferences::GroupBox );
2351 //pref->setItemProperty( "columns", 2, vtkSM );
2352 // .... -> decrease speed increment
2353 int spacemousePref1 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_1" ), vtkSM,
2354 LightApp_Preferences::Selector, "VTKViewer",
2355 "spacemouse_func1_btn" );
2356 // .... -> increase speed increment
2357 int spacemousePref2 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_2" ), vtkSM,
2358 LightApp_Preferences::Selector, "VTKViewer",
2359 "spacemouse_func2_btn" );
2360 // .... -> dominant / combined switch
2361 int spacemousePref3 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_3" ), vtkSM,
2362 LightApp_Preferences::Selector, "VTKViewer",
2363 "spacemouse_func5_btn" ); //
2364 aValuesList.clear();
2365 anIndicesList.clear();
2366 aValuesList << tr( "PREF_SPACEMOUSE_BTN_1" ) << tr( "PREF_SPACEMOUSE_BTN_2" ) << tr( "PREF_SPACEMOUSE_BTN_3" );
2367 aValuesList << tr( "PREF_SPACEMOUSE_BTN_4" ) << tr( "PREF_SPACEMOUSE_BTN_5" ) << tr( "PREF_SPACEMOUSE_BTN_6" );
2368 aValuesList << tr( "PREF_SPACEMOUSE_BTN_7" ) << tr( "PREF_SPACEMOUSE_BTN_8" ) << tr( "PREF_SPACEMOUSE_BTN_*" );
2369 aValuesList << tr( "PREF_SPACEMOUSE_BTN_10" ) << tr( "PREF_SPACEMOUSE_BTN_11" );
2370 anIndicesList << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11;
2371 pref->setItemProperty( "strings", aValuesList, spacemousePref1 );
2372 pref->setItemProperty( "indexes", anIndicesList, spacemousePref1 );
2373 pref->setItemProperty( "strings", aValuesList, spacemousePref2 );
2374 pref->setItemProperty( "indexes", anIndicesList, spacemousePref2 );
2375 pref->setItemProperty( "strings", aValuesList, spacemousePref3 );
2376 pref->setItemProperty( "indexes", anIndicesList, spacemousePref3 );
2377 // ... space mouse sub-group <<end>>
2379 // ... avi recording sub-group <<start>>
2380 int vtkRec = pref->addPreference( tr( "PREF_FRAME_RECORDING" ), vtkGroup, LightApp_Preferences::GroupBox );
2381 pref->setItemProperty( "columns", 2, vtkRec );
2382 // .... -> recording mode
2383 int modePref = pref->addPreference( tr( "PREF_RECORDING_MODE" ), vtkRec,
2384 LightApp_Preferences::Selector, "VTKViewer", "recorder_mode" );
2385 aValuesList.clear();
2386 anIndicesList.clear();
2387 aValuesList << tr( "PREF_SKIPPED_FRAMES" ) << tr( "PREF_ALL_DISLPAYED_FRAMES" );
2388 anIndicesList << 0 << 1;
2389 pref->setItemProperty( "strings", aValuesList, modePref );
2390 pref->setItemProperty( "indexes", anIndicesList, modePref );
2392 int fpsPref = pref->addPreference( tr( "PREF_FPS" ), vtkRec,
2393 LightApp_Preferences::DblSpin, "VTKViewer", "recorder_fps" );
2394 pref->setItemProperty( "min", 0.1, fpsPref );
2395 pref->setItemProperty( "max", 100, fpsPref );
2397 int qualityPref = pref->addPreference( tr( "PREF_QUALITY" ), vtkRec,
2398 LightApp_Preferences::IntSpin, "VTKViewer", "recorder_quality" );
2399 pref->setItemProperty( "min", 1, qualityPref );
2400 pref->setItemProperty( "max", 100, qualityPref );
2401 // .... -> progressive mode
2402 pref->addPreference( tr( "PREF_PROGRESSIVE" ), vtkRec,
2403 LightApp_Preferences::Bool, "VTKViewer", "recorder_progressive" );
2404 // ... avi recording sub-group <<end>>
2406 // ... group names sub-group <<start>>
2407 int vtkGN = pref->addPreference( tr( "PREF_FRAME_GROUP_NAMES" ), vtkGroup,
2408 LightApp_Preferences::GroupBox, "VTKViewer", "show_group_names" );
2409 pref->setItemProperty( "columns", 2, vtkGN );
2410 // .... -> text color
2411 pref->addPreference( tr( "PREF_GROUP_NAMES_TEXT_COLOR" ), vtkGN,
2412 LightApp_Preferences::Color, "VTKViewer", "group_names_text_color" );
2413 // .... -> transparency
2414 int transPref = pref->addPreference( tr( "PREF_GROUP_NAMES_TRANSPARENCY" ), vtkGN,
2415 LightApp_Preferences::DblSpin, "VTKViewer", "group_names_transparency" );
2416 pref->setItemProperty( "min", 0.0, transPref );
2417 pref->setItemProperty( "max", 1.0, transPref );
2418 pref->setItemProperty( "step", 0.1, transPref );
2419 // ... -> group names sub-group <<end>>
2420 // .. "VTK viewer" group <<end>>
2422 // .. "Plot2d viewer" group <<start>>
2423 int plot2dGroup = pref->addPreference( tr( "PREF_GROUP_PLOT2DVIEWER" ), salomeCat ); //viewTab
2424 //pref->setItemProperty( "columns", 2, plot2dGroup );
2426 // ... -> show legend
2427 pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dGroup,
2428 LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
2429 // ... -> legend position
2430 int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dGroup,
2431 LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
2432 aValuesList.clear();
2433 anIndicesList.clear();
2434 aValuesList << tr("PREF_LEFT") << tr("PREF_RIGHT") << tr("PREF_TOP") << tr("PREF_BOTTOM");
2435 anIndicesList << 0 << 1 << 2 << 3 ;
2436 pref->setItemProperty( "strings", aValuesList, legendPosition );
2437 pref->setItemProperty( "indexes", anIndicesList, legendPosition );
2438 // ... -> legend font
2439 pref->addPreference( tr( "PREF_LEGEND_FONT" ), plot2dGroup, LightApp_Preferences::Font, "Plot2d", "LegendFont" );
2440 // ... -> curve type
2441 int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dGroup,
2442 LightApp_Preferences::Selector, "Plot2d", "CurveType" );
2443 aValuesList.clear();
2444 anIndicesList.clear();
2445 aValuesList << tr("PREF_POINTS") << tr("PREF_LINES") << tr("PREF_SPLINE");
2446 anIndicesList << 0 << 1 << 2 ;
2447 pref->setItemProperty( "strings", aValuesList, curveType );
2448 pref->setItemProperty( "indexes", anIndicesList, curveType );
2449 // ... -> marker size
2450 int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dGroup,
2451 LightApp_Preferences::IntSpin, "Plot2d", "MarkerSize" );
2452 pref->setItemProperty( "min", 0, markerSize );
2453 pref->setItemProperty( "max", 100, markerSize );
2454 // ... -> horizontal scaling mode
2455 int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dGroup,
2456 LightApp_Preferences::Selector, "Plot2d", "HorScaleMode" );
2457 aValuesList.clear();
2458 anIndicesList.clear();
2459 aValuesList << tr("PREF_LINEAR") << tr("PREF_LOGARITHMIC");
2460 anIndicesList << 0 << 1 ;
2461 pref->setItemProperty( "strings", aValuesList, horScale );
2462 pref->setItemProperty( "indexes", anIndicesList, horScale );
2463 // ... -> vertical scaling mode
2464 int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dGroup,
2465 LightApp_Preferences::Selector, "Plot2d", "VerScaleMode" );
2466 pref->setItemProperty( "strings", aValuesList, verScale );
2467 pref->setItemProperty( "indexes", anIndicesList, verScale );
2468 // ... -> background
2469 pref->addPreference( tr( "PREF_VIEWER_BACKGROUND_COLOR" ), plot2dGroup,
2470 LightApp_Preferences::Color, "Plot2d", "Background" );
2471 // ... -> font color
2472 pref->addPreference( tr( "PREF_FONT_COLOR" ), plot2dGroup, LightApp_Preferences::Color, "Plot2d", "LegendFontColor" );
2473 // ... -> selection font color
2474 pref->addPreference( tr( "PREF_SELECTED_FONT_COLOR" ), plot2dGroup, LightApp_Preferences::Color, "Plot2d", "SelectedLegendFontColor" );
2475 // ... -> selection color
2476 pref->addPreference( tr( "PREF_VIEWER_SELECTION" ), plot2dGroup,
2477 LightApp_Preferences::Color, "Plot2d", "SelectionColor" );
2478 // ... -> errors/deviation colot
2479 pref->addPreference( tr( "PREF_DEVIATION_COLOR" ), plot2dGroup,
2480 LightApp_Preferences::Color, "Plot2d", "DeviationMarkerColor" );
2481 // ... -> deviation markers line size
2482 int deviationMarkerLw = pref->addPreference( tr( "PREF_DEVIATION_MARKER_LW" ), plot2dGroup,
2483 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerLineWidth" );
2484 pref->setItemProperty( "min", 1, deviationMarkerLw );
2485 pref->setItemProperty( "max", 5, deviationMarkerLw );
2486 // ... -> deviation markers tick mark size
2487 int deviationMarkerTs = pref->addPreference( tr( "PREF_DEVIATION_MARKER_TS" ), plot2dGroup,
2488 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerTickSize" );
2489 pref->setItemProperty( "min", 1, deviationMarkerTs );
2490 pref->setItemProperty( "max", 5, deviationMarkerTs );
2491 // .. "Plot2d viewer" group <<end>>
2493 // .. "Directories" preferences tab <<start>>
2494 int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat );
2495 // ... --> quick directories list
2496 int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab );
2497 pref->addPreference( tr( "" ), dirGroup,
2498 LightApp_Preferences::DirList, "FileDlg", "QuickDirList" );
2499 // .. "Directories" preferences tab <<end>>
2501 // .. "Object browser" preferences tab <<start>>
2502 int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
2504 // ... "Search tool" group <<start>>
2505 int stGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SEARCH_TOOL" ), obTab );
2506 // .... --> auto-hide
2507 pref->addPreference( tr( "PREF_AUTO_HIDE_SEARCH_TOOL" ), stGroup, LightApp_Preferences::Bool,
2508 "ObjectBrowser", "auto_hide_search_tool" );
2509 // ... "Search tool" group <<end>>
2511 // ... "Object browser settings" group <<start>>
2512 int objSetGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), obTab );
2513 pref->setItemProperty( "columns", 2, objSetGroup );
2514 // .... -> auto size first column
2515 pref->addPreference( tr( "PREF_AUTO_SIZE_FIRST" ), objSetGroup, LightApp_Preferences::Bool,
2516 "ObjectBrowser", "auto_size_first" );
2517 // .... -> auto size other columns
2518 pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool,
2519 "ObjectBrowser", "auto_size" );
2520 // .... -> resize columns on expand item
2521 pref->addPreference( tr( "PREF_RESIZE_ON_EXPAND_ITEM" ), objSetGroup, LightApp_Preferences::Bool,
2522 "ObjectBrowser", "resize_on_expand_item" );
2523 // .... -> browse to published object
2524 int browsePublished = pref->addPreference( tr( "PREF_BROWSE_TO_THE_PUBLISHED_OBJECT" ), objSetGroup, LightApp_Preferences::Selector,
2525 "ObjectBrowser", "browse_published_object" );
2526 aValuesList.clear();
2527 anIndicesList.clear();
2528 aValuesList << tr( "PREF_BROWSE_NEVER" ) << tr( "PREF_BROWSE_AFTER_APPLY_AND_CLOSE_ONLY" ) << tr( "PREF_BROWSE_ALWAYS" );
2529 anIndicesList << BP_Never << BP_ApplyAndClose << BP_Always;
2530 pref->setItemProperty( "strings", aValuesList, browsePublished );
2531 pref->setItemProperty( "indexes", anIndicesList, browsePublished );
2532 // ... "Object browser settings" group <<end>>
2533 // .. "Object browser" preferences tab <<end>>
2535 // .. "Shortcuts" preferences tab <<start>>
2536 int shortcutTab = pref->addPreference( tr( "PREF_TAB_SHORTCUTS" ), salomeCat );
2537 // ... "Shortcuts settings" group <<start>>
2538 int shortcutGroup = pref->addPreference( tr( "PREF_GROUP_SHORTCUTS" ), shortcutTab );
2539 pref->addPreference( tr( "" ), shortcutGroup,
2540 LightApp_Preferences::ShortcutTree, "shortcuts" );
2541 // ... "Shortcuts settings" group <<end>>
2542 // .. "Shortcuts" preferences tab <<end>>
2543 // . Top-level "SALOME" preferences group <<end>>
2549 Changes appearance of application according to changed preferences
2550 \param sec - section
2551 \param param - name of changed parameter
2553 void LightApp_Application::preferencesChanged( const QString& sec, const QString& param )
2555 SUIT_ResourceMgr* resMgr = resourceMgr();
2559 if ( sec == "viewers" && param == "drop_down_buttons" )
2561 ViewManagerList vmlist = viewManagers();
2562 foreach( SUIT_ViewManager* vm, vmlist )
2564 QVector<SUIT_ViewWindow*> vwlist = vm->getViews();
2565 foreach( SUIT_ViewWindow* vw, vwlist )
2566 if ( vw ) vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
2570 if ( sec == QString( "3DViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )))
2572 double sz = resMgr->doubleValue( sec, "trihedron_size", -1 );
2573 bool relative = resMgr->booleanValue( sec, "relative_size", true );
2574 QList<SUIT_ViewManager*> lst;
2575 #ifndef DISABLE_OCCVIEWER
2576 viewManagers( OCCViewer_Viewer::Type(), lst );
2577 QListIterator<SUIT_ViewManager*> itOCC( lst );
2578 while ( itOCC.hasNext() && sz >= 0 )
2580 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2581 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2584 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2585 occVM->setTrihedronSize( sz, relative );
2586 occVM->getAISContext()->UpdateCurrentViewer();
2589 #ifndef DISABLE_VTKVIEWER
2590 #ifndef DISABLE_SALOMEOBJECT
2591 viewManagers( SVTK_Viewer::Type(), lst );
2592 QListIterator<SUIT_ViewManager*> itVTK( lst );
2593 while ( itVTK.hasNext() && sz >= 0 )
2595 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2596 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2599 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2602 vtkVM->setTrihedronSize( sz, relative );
2610 if ( sec == QString( "3DViewer" ) && param == QString( "show_static_trihedron" ) )
2612 bool isVisible = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
2613 QList<SUIT_ViewManager*> lst;
2614 #ifndef DISABLE_OCCVIEWER
2615 viewManagers( OCCViewer_Viewer::Type(), lst );
2616 QListIterator<SUIT_ViewManager*> itOCC( lst );
2617 while ( itOCC.hasNext() )
2619 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2620 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2623 OCCViewer_Viewer* occVM = dynamic_cast<OCCViewer_Viewer*>( vm );
2626 occVM->setStaticTrihedronDisplayed( isVisible );
2630 #ifndef DISABLE_VTKVIEWER
2631 #ifndef DISABLE_SALOMEOBJECT
2632 viewManagers( SVTK_Viewer::Type(), lst );
2633 QListIterator<SUIT_ViewManager*> itVTK( lst );
2634 while ( itVTK.hasNext() )
2636 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2637 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2640 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2643 vtkVM->setStaticTrihedronVisible( isVisible );
2651 if ( sec == QString( "3DViewer" ) && param == QString( "navigation_mode" ) )
2653 int mode = resMgr->integerValue( "3DViewer", "navigation_mode", 0 );
2654 QList<SUIT_ViewManager*> lst;
2655 #ifndef DISABLE_OCCVIEWER
2656 viewManagers( OCCViewer_Viewer::Type(), lst );
2657 QListIterator<SUIT_ViewManager*> itOCC( lst );
2658 while ( itOCC.hasNext() )
2660 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2661 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2664 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2665 occVM->setInteractionStyle( mode );
2668 #ifndef DISABLE_VTKVIEWER
2669 #ifndef DISABLE_SALOMEOBJECT
2670 viewManagers( SVTK_Viewer::Type(), lst );
2671 QListIterator<SUIT_ViewManager*> itVTK( lst );
2672 while ( itVTK.hasNext() )
2674 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2675 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2678 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2679 if( vtkVM ) vtkVM->setInteractionStyle( mode );
2685 #ifndef DISABLE_OCCVIEWER
2686 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_preselection" ) )
2688 bool isToEnablePreselection = resMgr->booleanValue( "OCCViewer", "enable_preselection", true );
2689 QList<SUIT_ViewManager*> lst;
2690 viewManagers( OCCViewer_Viewer::Type(), lst );
2691 QListIterator<SUIT_ViewManager*> it( lst );
2692 while ( it.hasNext() )
2694 SUIT_ViewModel* vm = it.next()->getViewModel();
2695 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2698 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2699 occVM->enablePreselection( isToEnablePreselection );
2704 #ifndef DISABLE_OCCVIEWER
2705 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_selection" ) )
2707 bool isToEnableSelection = resMgr->booleanValue( "OCCViewer", "enable_selection", true );
2708 QList<SUIT_ViewManager*> lst;
2709 viewManagers( OCCViewer_Viewer::Type(), lst );
2710 QListIterator<SUIT_ViewManager*> it( lst );
2711 while ( it.hasNext() )
2713 SUIT_ViewModel* vm = it.next()->getViewModel();
2714 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2717 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2718 occVM->enableSelection( isToEnableSelection );
2723 if ( sec == QString( "3DViewer" ) && param == QString( "zooming_mode" ) )
2725 int mode = resMgr->integerValue( "3DViewer", "zooming_mode", 0 );
2726 QList<SUIT_ViewManager*> lst;
2727 #ifndef DISABLE_OCCVIEWER
2728 viewManagers( OCCViewer_Viewer::Type(), lst );
2729 QListIterator<SUIT_ViewManager*> itOCC( lst );
2730 while ( itOCC.hasNext() )
2732 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2733 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2736 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2737 occVM->setZoomingStyle( mode );
2740 #ifndef DISABLE_VTKVIEWER
2741 #ifndef DISABLE_SALOMEOBJECT
2742 viewManagers( SVTK_Viewer::Type(), lst );
2743 QListIterator<SUIT_ViewManager*> itVTK( lst );
2744 while ( itVTK.hasNext() )
2746 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2747 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2750 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2751 if( vtkVM ) vtkVM->setZoomingStyle( mode );
2757 #ifndef DISABLE_VTKVIEWER
2758 if ( sec == QString( "VTKViewer" ) && (param == QString( "speed_value" ) || param == QString( "speed_mode" )) )
2760 int speed = resMgr->integerValue( "VTKViewer", "speed_value", 10 );
2761 int mode = resMgr->integerValue( "VTKViewer", "speed_mode", 0 );
2762 QList<SUIT_ViewManager*> lst;
2763 #ifndef DISABLE_SALOMEOBJECT
2764 viewManagers( SVTK_Viewer::Type(), lst );
2765 QListIterator<SUIT_ViewManager*> it( lst );
2766 while ( it.hasNext() )
2768 SUIT_ViewModel* vm = it.next()->getViewModel();
2769 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2772 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2773 if( vtkVM ) vtkVM->setIncrementalSpeed( speed, mode );
2779 #ifndef DISABLE_VTKVIEWER
2780 if ( sec == QString( "VTKViewer" ) && param == QString( "projection_mode" ) )
2782 int mode = resMgr->integerValue( "VTKViewer", "projection_mode", 0 );
2783 QList<SUIT_ViewManager*> lst;
2784 #ifndef DISABLE_SALOMEOBJECT
2785 viewManagers( SVTK_Viewer::Type(), lst );
2786 QListIterator<SUIT_ViewManager*> it( lst );
2787 while ( it.hasNext() )
2789 SUIT_ViewModel* vm = it.next()->getViewModel();
2790 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2793 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2794 if( vtkVM ) vtkVM->setProjectionMode( mode );
2800 #ifndef DISABLE_VTKVIEWER
2801 if ( sec == QString( "VTKViewer" ) && param == QString( "preselection" ) )
2803 int mode = resMgr->integerValue( "VTKViewer", "preselection", 0 );
2804 QList<SUIT_ViewManager*> lst;
2805 #ifndef DISABLE_SALOMEOBJECT
2806 viewManagers( SVTK_Viewer::Type(), lst );
2807 QListIterator<SUIT_ViewManager*> it( lst );
2808 while ( it.hasNext() )
2810 SUIT_ViewModel* vm = it.next()->getViewModel();
2811 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2814 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2815 if( vtkVM ) vtkVM->setPreSelectionMode( mode );
2821 #ifndef DISABLE_VTKVIEWER
2822 if ( sec == QString( "VTKViewer" ) && param == QString( "enable_selection" ) )
2824 bool isToEnableSelection = resMgr->booleanValue( "VTKViewer", "enable_selection", true );
2825 QList<SUIT_ViewManager*> lst;
2826 #ifndef DISABLE_SALOMEOBJECT
2827 viewManagers( SVTK_Viewer::Type(), lst );
2828 QListIterator<SUIT_ViewManager*> it( lst );
2829 while ( it.hasNext() )
2831 SUIT_ViewModel* vm = it.next()->getViewModel();
2832 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2835 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2836 if( vtkVM ) vtkVM->enableSelection( isToEnableSelection );
2842 #ifndef DISABLE_VTKVIEWER
2843 if ( sec == QString( "VTKViewer" ) && (param == QString( "spacemouse_func1_btn" ) ||
2844 param == QString( "spacemouse_func2_btn" ) ||
2845 param == QString( "spacemouse_func5_btn" ) ) )
2847 int btn1 = resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", 1 );
2848 int btn2 = resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", 2 );
2849 int btn3 = resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", 9 );
2850 QList<SUIT_ViewManager*> lst;
2851 #ifndef DISABLE_SALOMEOBJECT
2852 viewManagers( SVTK_Viewer::Type(), lst );
2853 QListIterator<SUIT_ViewManager*> it( lst );
2854 while ( it.hasNext() )
2856 SUIT_ViewModel* vm = it.next()->getViewModel();
2857 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2860 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2861 if( vtkVM ) vtkVM->setSpacemouseButtons( btn1, btn2, btn3 );
2866 if( sec=="ObjectBrowser" )
2868 SUIT_DataBrowser* ob = objectBrowser();
2872 if ( param=="auto_size_first" )
2874 bool autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
2875 ob->setAutoSizeFirstColumn( autoSizeFirst );
2876 if ( autoSizeFirst )
2877 ob->adjustFirstColumnWidth();
2879 else if ( param=="auto_size" ) {
2880 bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
2881 ob->setAutoSizeColumns(autoSize);
2883 ob->adjustColumnsWidth();
2885 else if ( param=="resize_on_expand_item" ) {
2886 bool resizeOnExpandItem = resMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
2887 ob->setResizeOnExpandItem(resizeOnExpandItem);
2889 else if ( param == "auto_hide_search_tool" ) {
2890 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
2896 if( param=="auto_save_interval" ) {
2897 myAutoSaveTimer->stop();
2898 int autoSaveInterval = resMgr->integerValue( "Study", "auto_save_interval", 0 );
2899 if ( activeStudy() && autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
2903 #ifndef DISABLE_PYCONSOLE
2904 if( sec=="PyConsole" && pythonConsole() )
2906 if ( param=="font" ) {
2907 pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) );
2909 else if ( param=="show_banner" ) {
2910 pythonConsole()->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
2917 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
2919 if ( param == "visible_count" )
2920 mru->setVisibleCount( resMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
2921 else if ( param == "max_count" )
2922 mru->setHistoryCount( resMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
2923 else if ( param == "insert_mode" )
2924 mru->setInsertMode( resMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
2925 else if ( param == "link_type" )
2926 mru->setLinkType( resMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
2927 else if ( param == "show_clear" )
2928 mru->setClearPossible( resMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
2929 else if ( param == "show_mru" )
2930 mru->setVisible( resMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
2933 if ( sec == "language" && param == "language" )
2935 SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LANG_CHANGED" ) );
2937 if ( sec == "desktop" && param == "opaque_resize" ) {
2938 bool opaqueResize = resMgr->booleanValue( "desktop", "opaque_resize", false );
2939 QMainWindow::DockOptions dopts = desktop()->dockOptions();
2940 if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
2941 else dopts &= ~QMainWindow::AnimatedDocks;
2942 desktop()->setDockOptions( dopts );
2943 desktop()->setOpaqueResize( opaqueResize );
2944 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
2945 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
2948 if ( sec == "ExternalBrowser" && param == "use_external_browser" ) {
2949 if ( resMgr->booleanValue("ExternalBrowser", "use_external_browser", false ) )
2951 QtxWebBrowser::shutdown();
2955 #ifndef DISABLE_PLOT2DVIEWER
2956 if ( sec == "Plot2d" ) {
2957 if( param == "SelectionColor" ) {
2958 QColor c = resMgr->colorValue( sec, param );
2959 Plot2d_Object::setSelectionColor(c);
2961 else if (param == "SelectedLegendFontColor") {
2962 QColor c = resMgr->colorValue( sec, param );
2963 Plot2d_Object::setHighlightedLegendTextColor(c);
2972 void LightApp_Application::loadPreferences()
2974 CAM_Application::loadPreferences();
2976 SUIT_ResourceMgr* aResMgr = resourceMgr();
2981 static bool mru_load = true;
2984 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
2986 mru->setVisible( aResMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
2987 mru->setVisibleCount( aResMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
2988 mru->setHistoryCount( aResMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
2989 mru->setInsertMode( aResMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
2990 mru->setLinkType( aResMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
2991 mru->setClearPossible( aResMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
2992 mru->loadLinks( aResMgr, "MRU" );
2998 QStringList mods = aResMgr->parameters( "windows_visibility" );
2999 for ( QStringList::const_iterator itr = mods.begin(); itr != mods.end(); ++itr )
3002 if ( aResMgr->value( "windows_visibility", *itr, arr ) )
3003 myWinVis.insert( *itr, arr );
3007 desktop()->retrieveGeometry( aResMgr->stringValue( "desktop", "geometry" ) );
3008 bool opaqueResize = aResMgr->booleanValue( "desktop", "opaque_resize", false );
3009 QMainWindow::DockOptions dopts = desktop()->dockOptions();
3010 if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
3011 else dopts &= ~QMainWindow::AnimatedDocks;
3012 desktop()->setDockOptions( dopts );
3013 desktop()->setOpaqueResize( opaqueResize );
3014 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
3015 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
3022 void LightApp_Application::savePreferences()
3024 CAM_Application::savePreferences();
3026 saveDockWindowsState();
3028 SUIT_ResourceMgr* aResMgr = resourceMgr();
3033 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3035 mru->saveLinks( aResMgr, "MRU" );
3037 for ( WinVis::const_iterator itr = myWinVis.begin(); itr != myWinVis.end(); ++itr )
3038 aResMgr->setValue( "windows_visibility", itr.key(), itr.value() );
3041 aResMgr->setValue( "desktop", "geometry", desktop()->storeGeometry() );
3047 Updates desktop title
3049 void LightApp_Application::updateDesktopTitle()
3051 QString aTitle = applicationName();
3052 QString aVer = applicationVersion();
3053 if ( !aVer.isEmpty() )
3054 aTitle += QString( " " ) + aVer;
3056 if ( activeStudy() ) {
3057 QString sName = SUIT_Tools::file( activeStudy()->studyName().trimmed(), false );
3058 aTitle += QString( " - [%1]" ).arg( sName );
3061 desktop()->setWindowTitle( aTitle );
3065 \brief Get map of the operations which can be performed
3066 on the module activation.
3068 The method should return the map of the kind \c {<id>:<name>}
3069 where \c <id> is an integer identifier of the operation and
3070 \c <name> is a title for the button to be added to the
3071 dialog box. After user selects the required operation by the
3072 clicking the corresponding button in the dialog box, its identifier
3073 is passed to the moduleActionSelected() method to process
3076 \return map of the operations
3077 \sa moduleActionSelected()
3079 QMap<int, QString> LightApp_Application::activateModuleActions() const
3081 QMap<int, QString> opmap;
3082 opmap.insert( NewStudyId, tr( "ACTIVATE_MODULE_OP_NEW" ) );
3083 opmap.insert( OpenStudyId, tr( "ACTIVATE_MODULE_OP_OPEN" ) );
3088 \brief Called when the used selectes required operation chosen
3089 from "Activate module" dialog box.
3091 Performs the required operation according to the user choice.
3093 \param id operation identifier
3094 \sa activateModuleActions()
3096 void LightApp_Application::moduleActionSelected( const int id )
3111 Updates windows after close document
3113 void LightApp_Application::afterCloseDoc()
3117 CAM_Application::afterCloseDoc();
3121 Updates actions of active module
3123 void LightApp_Application::updateModuleActions()
3126 if ( activeModule() ) {
3127 modName = activeModule()->moduleName();
3128 if ( !isModuleAccessible( modName ) ) {
3129 QList<SUIT_Application*> apps = SUIT_Session::session()->applications();
3130 foreach( SUIT_Application* app, apps ) {
3131 LightApp_Application* lapp = dynamic_cast<LightApp_Application*>( app );
3132 if ( lapp && lapp != this )
3133 lapp->removeModuleAction( modName );
3138 LightApp_ModuleAction* moduleAction =
3139 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
3141 moduleAction->setActiveModule( modName );
3144 void LightApp_Application::removeModuleAction( const QString& modName )
3146 LightApp_ModuleAction* moduleAction =
3147 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
3149 moduleAction->removeModule( modName );
3153 Gets current windows.
3154 \param winMap - output current windows map.
3156 void LightApp_Application::currentWindows( QMap<int, int>& winMap ) const
3159 if ( !activeStudy() )
3162 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
3163 ((LightApp_Module*)activeModule())->windows( winMap );
3165 defaultWindows( winMap );
3169 Gets current view managers.
3170 \param lst - output current view managers list.
3172 void LightApp_Application::currentViewManagers( QStringList& lst ) const
3175 if ( !activeStudy() )
3178 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
3179 ((LightApp_Module*)activeModule())->viewManagers( lst );
3181 defaultViewManagers( lst );
3187 void LightApp_Application::updateWindows()
3189 QMap<int, int> winMap;
3190 currentWindows( winMap );
3192 if ( activeStudy() )
3194 for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
3196 if ( !dockWindow( it.key() ) )
3197 getWindow( it.key() );
3201 for ( WinMap::ConstIterator it = myWin.begin(); it != myWin.end(); ++it )
3203 QWidget* wid = it.value();
3204 if ( activeStudy() )
3205 wid->setVisible( winMap.contains( it.key() ) );
3210 if ( activeStudy() )
3211 loadDockWindowsState();
3217 Updates view managers
3219 void LightApp_Application::updateViewManagers()
3222 currentViewManagers( lst );
3224 for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
3225 getViewManager( *it, true );
3229 Loads windows geometry
3231 void LightApp_Application::loadDockWindowsState()
3235 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
3236 bool storeWin = aResMgr->booleanValue( "Study", "store_positions", true );
3237 bool storeTb = aResMgr->booleanValue( "Study", "store_tool_positions", true );
3240 if ( activeModule() )
3241 modName = activeModule()->name();
3243 QtxResourceMgr::WorkingMode prevMode = aResMgr->workingMode();
3244 aResMgr->setWorkingMode(QtxResourceMgr::IgnoreUserValues);
3245 QByteArray aDefaultState;
3246 aResMgr->value("windows_geometry", modName , aDefaultState );
3247 QByteArray aDefaultVisibility;
3248 aResMgr->value("windows_visibility", modName , aDefaultVisibility );
3249 bool hasDefaultVisibility = !aDefaultVisibility.isEmpty();
3250 aResMgr->setWorkingMode(prevMode);
3252 if( !storeWin && !storeTb && aDefaultState.isEmpty() && !hasDefaultVisibility)
3255 if ( aResMgr->hasValue("windows_geometry" ,modName ) ) {
3257 aResMgr->value("windows_geometry", modName , arr );
3258 QByteArray aTargetArray = processState(arr, storeWin, storeTb, aDefaultState);
3259 desktop()->restoreState( aTargetArray );
3262 if ( !myWinVis.contains( modName ) && aDefaultVisibility.isEmpty())
3265 QMap<QString, bool> *tbMap = 0;
3266 QMap<QString, bool> *dwMap = 0;
3268 QMap<QString, bool> userTbMap, userDwMap;
3269 dockWindowsState( myWinVis[modName], userTbMap, userDwMap );
3271 QMap<QString, bool> defaultTbMap, defaultDwMap;
3272 if(hasDefaultVisibility) {
3273 dockWindowsState( aDefaultVisibility, defaultTbMap, defaultDwMap);
3279 if(hasDefaultVisibility){
3280 tbMap = &defaultTbMap;
3287 if(hasDefaultVisibility){
3288 dwMap = &defaultDwMap;
3293 QList<QToolBar*> tbList = findToolBars();
3294 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit )
3296 QToolBar* tb = *tit;
3297 if ( tbMap->contains( tb->objectName() ) ) {
3298 tb->setVisible( (*tbMap)[tb->objectName()] );
3304 QList<QDockWidget*> dwList = qFindChildren<QDockWidget*>( desktop() );
3305 for ( QList<QDockWidget*>::iterator dit = dwList.begin(); dit != dwList.end(); ++dit )
3307 QDockWidget* dw = *dit;
3309 QObject* po = Qtx::findParent( dw, "QMainWindow" );
3310 if ( po != desktop() )
3313 if ( dwMap->contains( dw->objectName() ) )
3314 dw->setVisible( (*dwMap)[dw->objectName()] );
3321 Saves windows geometry
3323 void LightApp_Application::saveDockWindowsState()
3328 bool storeWin = resourceMgr()->booleanValue( "Study", "store_positions", true );
3329 bool storeTb = resourceMgr()->booleanValue( "Study", "store_tool_positions", true );
3331 if( !storeWin && !storeTb )
3335 if ( activeModule() )
3336 modName = activeModule()->name();
3338 QByteArray arr = desktop()->saveState();
3339 resourceMgr()->setValue( "windows_geometry", modName, processState(arr, storeWin, storeTb) );
3342 if ( myWinVis.contains( modName ) )
3343 visArr = myWinVis[modName];
3345 QMap<QString, bool> tbMap, dwMap;
3346 dockWindowsState( visArr, tbMap, dwMap );
3348 QList<QToolBar*> tbList = qFindChildren<QToolBar*>( desktop() );
3349 for ( QList<QToolBar*>::iterator it = tbList.begin(); it != tbList.end(); ++it )
3352 tbMap.insert( tb->objectName(), tb->toggleViewAction()->isChecked() );
3355 QList<QDockWidget*> dwList = qFindChildren<QDockWidget*>( desktop() );
3356 for ( QList<QDockWidget*>::iterator it = dwList.begin(); it != dwList.end(); ++it )
3358 QDockWidget* wid = *it;
3359 dwMap.insert( wid->objectName(), wid->toggleViewAction()->isChecked() );
3362 visArr = dockWindowsState( tbMap, dwMap );
3364 myWinVis.insert( modName, visArr );
3367 QByteArray LightApp_Application::dockWindowsState( const QMap<QString, bool>& tb, const QMap<QString, bool>& dw ) const
3370 QDataStream stream( &visArr, QIODevice::WriteOnly );
3372 stream << (uchar)ToolBarMarker;
3373 stream << tb.size();
3374 for ( QMap<QString, bool>::const_iterator tit = tb.begin(); tit != tb.end(); ++tit )
3376 stream << tit.key();
3377 stream << (uchar)( tit.value() ? 1 : 0 );
3380 stream << (uchar)DockWidgetMarker;
3381 stream << dw.size();
3382 for ( QMap<QString, bool>::const_iterator wit = dw.begin(); wit != dw.end(); ++wit )
3384 stream << wit.key();
3385 stream << (uchar)( wit.value() ? 1 : 0 );
3391 void LightApp_Application::dockWindowsState( const QByteArray& arr, QMap<QString, bool>& tb, QMap<QString, bool>& dw ) const
3396 QByteArray visArr = arr;
3397 QDataStream stream( &visArr, QIODevice::ReadOnly );
3401 if ( marker != ToolBarMarker )
3406 for ( int i = 0; i < lines; ++i )
3409 stream >> objectName;
3412 tb.insert( objectName, shown );
3416 if ( marker != DockWidgetMarker )
3420 for ( int j = 0; j < lines; ++j )
3423 stream >> objectName;
3426 dw.insert( objectName, shown );
3431 Adds icon names for modules
3433 void LightApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) const
3437 SUIT_ResourceMgr* resMgr = resourceMgr();
3441 QStringList modList;
3442 modules( modList, false );
3444 for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )
3446 QString modName = *it;
3447 QString modIntr = moduleName( modName );
3448 QString modIcon = resMgr->stringValue( modIntr, "icon", QString() );
3450 if ( modIcon.isEmpty() )
3453 if ( SUIT_Tools::extension( modIcon ).isEmpty() )
3454 modIcon += QString( ".png" );
3456 iconMap.insert( modName, modIcon );
3461 Inserts items in popup, which necessary for current application
3463 void LightApp_Application::contextMenuPopup( const QString& type, QMenu* thePopup, QString& title )
3466 LightApp_SelectionMgr* selMgr = LightApp_Application::selectionMgr();
3467 bool cacheIsOn = selMgr->isSelectionCacheEnabled();
3468 selMgr->setSelectionCacheEnabled( true );
3470 SUIT_DataBrowser* ob = objectBrowser();
3472 CAM_Application::contextMenuPopup( type, thePopup, title );
3474 if ( ob && type == ob->popupClientType() ) {
3475 thePopup->addSeparator();
3476 QAction* a = thePopup->addAction( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
3477 if ( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) )
3478 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) );
3481 if ( selMgr && ob ) {
3482 SALOME_ListIO selected;
3483 selMgr->selectedObjects( selected );
3484 if(selected.Extent() == 1){
3485 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3486 SUIT_DataObject* obj = findObject(anIObject->getEntry());
3487 if(obj && obj->renameAllowed()) {
3488 QAction* a = new QAction(tr("MEN_RENAME_OBJ"), thePopup);
3489 connect( a, SIGNAL( triggered(bool) ), ob, SLOT( onStartEditing() ) );
3490 if ( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) )
3491 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) );
3493 QList<QAction*> acts = thePopup->actions();
3494 QAction* firstAction = acts.count() > 0 ? acts.first() : 0;
3495 thePopup->insertAction(firstAction,a);
3500 selMgr->setSelectionCacheEnabled( cacheIsOn );
3506 void LightApp_Application::createEmptyStudy()
3508 CAM_Application::createEmptyStudy();
3510 if ( objectBrowser() )
3511 objectBrowser()->updateTree();
3513 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
3514 if ( aResMgr && activeStudy() ) {
3515 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
3516 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
3521 void LightApp_Application::setDesktop( SUIT_Desktop* desk )
3523 CAM_Application::setDesktop( desk );
3526 connect( desk, SIGNAL( message( const QString& ) ),
3527 this, SLOT( onDesktopMessage( const QString& ) ), Qt::UniqueConnection );
3533 \param mod - module to be activated
3535 bool LightApp_Application::activateModule( CAM_Module* mod )
3537 bool res = CAM_Application::activateModule( mod );
3539 if ( objectBrowser() )
3540 objectBrowser()->updateTree();
3546 \return keyborad accelerators manager object
3548 SUIT_Accel* LightApp_Application::accel() const
3554 Removes dead widget container from map
3556 void LightApp_Application::onWCDestroyed( QObject* ob )
3558 // remove destroyed widget container from windows map
3559 for ( WinMap::ConstIterator itr = myWin.begin(); itr != myWin.end(); ++itr )
3561 if ( itr.value() != ob )
3564 int key = itr.key();
3565 myWin.remove( key );
3570 void LightApp_Application::onMRUActivated( const QString& name )
3572 SUIT_Session* s = SUIT_Session::session();
3573 if ( s && s->activeApplication() == this )
3577 void LightApp_Application::onStylePreferences()
3579 Style_PrefDlg dlg( desktop() );
3582 resourceMgr()->setValue( "Style", "use_salome_style", Style_Salome::isActive() );
3585 void LightApp_Application::onFullScreen(){
3586 if(myScreenHelper) {
3587 if(desktop()->isFullScreen())
3588 myScreenHelper->switchToNormalScreen();
3590 myScreenHelper->switchToFullScreen();
3595 Connects just added view manager
3597 void LightApp_Application::addViewManager( SUIT_ViewManager* vm )
3599 connect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
3600 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
3601 CAM_Application::addViewManager( vm );
3605 Remove view manager from memory
3607 void LightApp_Application::removeViewManager( SUIT_ViewManager* vm )
3609 disconnect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
3610 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
3611 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
3613 aStudy->removeViewMgr(vm->getGlobalId());
3615 CAM_Application::removeViewManager( vm );
3617 LightApp_SelectionMgr* selMgr = selectionMgr();
3618 QList<SUIT_Selector*> selectors;
3619 selMgr->selectors( selectors );
3620 foreach( SUIT_Selector* selector, selectors ) {
3621 if ( selector->owner() == vm->getViewModel() ) {
3626 // IPAL22894: Crash on closing OCC view
3632 Renames active window of desktop
3634 void LightApp_Application::onRenameWindow()
3639 QWidget* w = desktop()->activeWindow();
3644 QString name = QInputDialog::getText( w, tr( "TOT_RENAME" ), tr( "PRP_RENAME" ), QLineEdit::Normal, w->windowTitle(), &ok );
3645 if( ok && !name.isEmpty() )
3646 w->setWindowTitle( name );
3650 Closes active window of desktop
3652 void LightApp_Application::onCloseWindow()
3657 QWidget* w = desktop()->activeWindow();
3665 Closes all windows of desktop
3667 void LightApp_Application::onCloseAllWindow()
3669 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
3673 QList<SUIT_ViewWindow*> wndList = desk->windows();
3674 SUIT_ViewWindow* wnd;
3675 foreach( wnd, wndList )
3683 Groups all windows of desktop
3685 void LightApp_Application::onGroupAllWindow()
3687 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
3691 QtxWorkstack* wgStack = desk->workstack();
3697 \return if the library of module exists
3698 \param moduleTitle - title of module
3700 bool LightApp_Application::isLibExists( const QString& moduleTitle ) const
3702 if( moduleTitle.isEmpty() )
3705 QString lib = moduleLibrary( moduleTitle );
3707 //abd: changed libSalomePyQtGUI to SalomePyQtGUI for WIN32
3708 bool isPythonModule = lib.contains("SalomePyQtGUI");
3709 bool isPythonLightModule = lib.contains("SalomePyQtGUILight");
3713 paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
3715 paths = QString(::getenv( "LD_LIBRARY_PATH" )).split( ":", QString::SkipEmptyParts );
3718 bool isLibFound = false;
3719 QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
3720 for( ; anIt!=aLast; anIt++ )
3722 QFileInfo inf( Qtx::addSlash( *anIt ) + lib );
3733 INFOS( "\n****************************************************************" << std::endl
3734 << "* Warning: library " << lib.toLatin1().constData() << " cannot be found" << std::endl
3735 << "* Module " << moduleTitle.toLatin1().constData() << " will not be available in GUI mode" << std::endl
3736 << "****************************************************************" << std::endl );
3738 else if ( !isPythonModule && !isPythonLightModule)
3741 if ( isPythonModule || isPythonLightModule)
3743 QString pylib = moduleName( moduleTitle ) + QString(".py");
3744 QString pylibgui = moduleName( moduleTitle ) + QString("GUI.py");
3746 // Check the python library
3748 // paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
3750 paths = QString(::getenv( "PYTHONPATH" )).split( ":", QString::SkipEmptyParts );
3752 bool isPyLib = false, isPyGuiLib = false;
3753 QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
3754 for( ; anIt!=aLast; anIt++ )
3756 QFileInfo inf( Qtx::addSlash( *anIt ) + pylib );
3757 QFileInfo infgui( Qtx::addSlash( *anIt ) + pylibgui );
3759 if(!isPythonLightModule)
3760 if( !isPyLib && inf.exists() )
3763 if( !isPyGuiLib && infgui.exists() )
3766 if ((isPyLib || isPythonLightModule ) && isPyGuiLib && isLibFound)
3770 printf( "\n****************************************************************\n" );
3771 printf( "* Warning: python library for %s cannot be found:\n", moduleTitle.toLatin1().constData() );
3773 printf( "* No module named %s\n", moduleName( moduleTitle ).toLatin1().constData() );
3775 printf( "* No module named %s\n", (moduleName( moduleTitle ) + QString("GUI")).toLatin1().constData() );
3776 printf( "****************************************************************\n" );
3783 \return default name for an active study
3785 void LightApp_Application::setDefaultStudyName( const QString& theName )
3787 QStringList anInfoList;
3788 modules( anInfoList, false );
3790 LightApp_Study* aStudy = (LightApp_Study*)activeStudy();
3791 if( anInfoList.count() == 1 && // to avoid a conflict between different modules
3792 !aStudy->isSaved() )
3794 aStudy->setStudyName( theName );
3795 updateDesktopTitle();
3800 Custom event handler
3802 bool LightApp_Application::event( QEvent* e )
3804 if( e && e->type()==2000 )
3806 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
3807 QString* d = ( QString* )ce->data();
3808 if( SUIT_MessageBox::question(0, tr("WRN_WARNING"),
3810 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
3811 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
3812 showPreferences( tr( "PREF_APP" ) );
3817 return CAM_Application::event( e );
3820 /*! Check data object */
3821 bool LightApp_Application::checkDataObject(LightApp_DataObject* theObj)
3825 bool isSuitable = !theObj->entry().isEmpty() &&
3826 !theObj->componentDataType().isEmpty() &&
3827 !theObj->name().isEmpty();
3834 int LightApp_Application::openChoice( const QString& aName )
3836 int choice = CAM_Application::openChoice( aName );
3838 if ( choice == OpenExist ) // The document is already open.
3840 // Do you want to reload it?
3841 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "QUE_DOC_ALREADYOPEN" ).arg( aName ),
3842 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No ) == SUIT_MessageBox::Yes )
3843 choice = OpenReload;
3849 bool LightApp_Application::openAction( const int choice, const QString& aName )
3856 STD_Application* app = 0;
3857 SUIT_Session* session = SUIT_Session::session();
3858 QList<SUIT_Application*> appList = session->applications();
3859 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !app; ++it )
3861 if ( (*it)->activeStudy() && (*it)->activeStudy()->studyName() == aName )
3862 app = ::qobject_cast<STD_Application*>( *it );
3867 app->onCloseDoc( false );
3868 appList = session->applications();
3869 STD_Application* other = 0;
3870 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !other; ++it )
3871 other = ::qobject_cast<STD_Application*>( *it );
3874 res = other->onOpenDoc( aName );
3879 res = CAM_Application::openAction( choice, aName );
3886 QStringList LightApp_Application::viewManagersTypes() const
3888 QStringList aTypesList;
3889 aTypesList += myUserWmTypes;
3890 #ifndef DISABLE_GLVIEWER
3891 aTypesList<<GLViewer_Viewer::Type();
3893 #ifndef DISABLE_PLOT2DVIEWER
3894 aTypesList<<Plot2d_Viewer::Type();
3896 #ifndef DISABLE_QXGRAPHVIEWER
3897 aTypesList<<QxScene_Viewer::Type();
3899 #ifndef DISABLE_OCCVIEWER
3900 aTypesList<<OCCViewer_Viewer::Type();
3902 #ifndef DISABLE_VTKVIEWER
3903 #ifndef DISABLE_SALOMEOBJECT
3904 aTypesList<<SVTK_Viewer::Type();
3906 aTypesList<<VTKViewer_Viewer::Type();
3912 * Removes all view managers of known types
3913 * Other view managers are ignored
3915 void LightApp_Application::clearKnownViewManagers()
3917 QStringList aTypesList = viewManagersTypes();
3918 QList<SUIT_ViewManager*> aMgrList;
3919 viewManagers( aMgrList );
3920 foreach (SUIT_ViewManager* aMgr, aMgrList) {
3921 if (aTypesList.contains(aMgr->getType()))
3922 removeViewManager(aMgr);
3927 Copy of current selection
3929 void LightApp_Application::onCopy()
3931 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
3937 Paste of current data in clipboard
3939 void LightApp_Application::onPaste()
3941 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
3947 Browse (i.e. set focus on) the published objects
3948 \param theIsApplyAndClose - flag indicating that the dialog for creating objects
3949 has been accepted by Ok (or Apply & Close) button
3950 \param theIsOptimizedBrowsing - flag switching to optimized browsing mode
3951 (to select the first published object only)
3952 \return entry of the selected object
3954 QString LightApp_Application::browseObjects( const QStringList& theEntryList,
3955 const bool theIsApplyAndClose,
3956 const bool theIsOptimizedBrowsing )
3959 if( SUIT_ResourceMgr* aResourceMgr = resourceMgr() )
3961 int aBrowsePolicy = aResourceMgr->integerValue( "ObjectBrowser", "browse_published_object", (int)BP_Never );
3962 switch( aBrowsePolicy )
3966 case BP_ApplyAndClose:
3967 if( !theIsApplyAndClose )
3975 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
3979 SUIT_DataBrowser* anOB = objectBrowser();
3983 SUIT_AbstractModel* aModel = dynamic_cast<SUIT_AbstractModel*>( anOB->model() );
3987 QStringListIterator anIter( theEntryList );
3988 if( theIsOptimizedBrowsing )
3990 // go to the last entry
3992 if( anIter.hasPrevious() )
3996 // scroll to each entry in the list
3997 // (in optimized mode - to the last entry only)
3999 LightApp_DataObject* anObject = 0;
4000 while( anIter.hasNext() )
4002 anEntry = anIter.next();
4003 if( !anEntry.isEmpty() )
4005 anObject = aStudy->findObjectByEntry( anEntry );
4008 QModelIndex anIndex = aModel->index( anObject );
4009 anOB->treeView()->scrollTo( anIndex );
4014 // always select the last object
4015 if( anObject && !anEntry.isEmpty() )
4017 QList<SUIT_Selector*> aSelectorList;
4018 selectionMgr()->selectors( "ObjectBrowser", aSelectorList );
4019 if( !aSelectorList.isEmpty() )
4021 if( LightApp_OBSelector* aSelector = dynamic_cast<LightApp_OBSelector*>( aSelectorList.first() ) )
4023 bool anIsAutoBlock = aSelector->autoBlock();
4025 // temporarily disable auto block, to emit LightApp_SelectionMgr::currentSelectionChanged() signal
4026 aSelector->setAutoBlock( false );
4028 SUIT_DataOwnerPtrList aList;
4029 #ifndef DISABLE_SALOMEOBJECT
4030 Handle(SALOME_InteractiveObject) aSObj = new SALOME_InteractiveObject
4031 ( anObject->entry().toLatin1().constData(),
4032 anObject->componentDataType().toLatin1().constData(),
4033 anObject->name().toLatin1().constData() );
4034 LightApp_DataOwner* owner = new LightApp_DataOwner( aSObj );
4036 LightApp_DataOwner* owner = new LightApp_DataOwner( anEntry );
4039 aList.append( owner );
4040 selectionMgr()->setSelected( aList );
4043 // restore auto block flag
4044 aSelector->setAutoBlock( anIsAutoBlock );
4052 SUIT_DataObject* LightApp_Application::findObject( const QString& id ) const
4054 LightApp_Study* study = dynamic_cast<LightApp_Study*>( activeStudy() );
4055 return study ? study->findObjectByEntry( id ) : 0;
4059 Checks that an object can be renamed.
4060 \param entry entry of the object
4061 \brief Return \c true if object can be renamed
4063 bool LightApp_Application::renameAllowed( const QString& /*entry*/) const {
4068 Rename object by entry.
4069 \param entry entry of the object
4070 \param name new name of the object
4071 \brief Return \c true if rename operation finished successfully, \c false otherwise.
4073 bool LightApp_Application::renameObject( const QString& entry, const QString& ) {
4077 /*! Process standard messages from desktop */
4078 void LightApp_Application::onDesktopMessage( const QString& message )
4080 const QString sectionSeparator = "/";
4082 if ( message.toLower() == "updateobjectbrowser" ||
4083 message.toLower() == "updateobjbrowser" ) {
4084 // update object browser
4085 updateObjectBrowser();
4088 QStringList data = message.split( sectionSeparator );
4089 if ( data.count() > 1 ) {
4090 QString msgType = data[0].trimmed();
4091 LightApp_Module* sMod = 0;
4092 CAM_Module* mod = module( msgType );
4094 mod = module( moduleTitle( msgType ) );
4095 if ( mod && mod->inherits( "LightApp_Module" ) )
4096 sMod = (LightApp_Module*)mod;
4098 if ( msgType.toLower() == "preferences" ) {
4099 // requested preferences change: should be given as "preferences/<section>/<name>/<value>"
4100 // for example "preferences/Study/multi_file_dump/true"
4101 if ( data.count() > 3 ) {
4102 QString section = data[1].trimmed();
4103 QString param = data[2].trimmed();
4104 QString value = QStringList( data.mid(3) ).join( sectionSeparator );
4105 resourceMgr()->setValue( section, param, value );
4109 // received message for the module
4110 QString msg = QStringList( data.mid(1) ).join( sectionSeparator );
4111 sMod->message( msg );
4119 Returns all top level toolbars.
4120 Note : Result list contains only main window toolbars, not including toolbars from viewers.
4122 QList<QToolBar*> LightApp_Application::findToolBars() {
4123 QList<QToolBar*> aResult;
4124 QList<QToolBar*> tbList = qFindChildren<QToolBar*>( desktop() );
4125 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit ) {
4126 QToolBar* tb = *tit;
4127 QObject* po = Qtx::findParent( tb, "QMainWindow" );
4128 if ( po != desktop() )
4136 Internal method to parse toolbars and dockable windows state.
4138 QByteArray LightApp_Application::processState(QByteArray& input, const bool processWin,const bool processTb, QByteArray defaultState) {
4141 bool hasDefaultState = !defaultState.isEmpty();
4142 bool isDockWinWriten = false;
4143 if(processWin && processTb) {
4145 } else if(!processWin && !processTb ) {
4147 aRes = defaultState;
4149 QDataStream aData(&aRes, QIODevice::WriteOnly);
4150 QList<QToolBar*> aToolBars = findToolBars();
4153 for ( QList<QToolBar*>::iterator tit = aToolBars.begin(); tit != aToolBars.end(); ++tit ) {
4154 QToolBar* tb = *tit;
4155 aNames.append(tb->objectName());
4158 int toolBarMarkerIndex = getToolbarMarkerIndex(input,aNames);
4159 QDataStream anInputData(&input, QIODevice::ReadOnly);
4160 if(toolBarMarkerIndex < 0)
4163 int toolBarMarkerIndexDef;
4164 if(hasDefaultState) {
4165 toolBarMarkerIndexDef = getToolbarMarkerIndex(defaultState, aNames);
4166 if(toolBarMarkerIndexDef < 0)
4169 QDataStream anInputDataDef(&defaultState, QIODevice::ReadOnly);
4171 QDataStream* aTargetData = 0;
4172 int aTargetIndex = -1;
4175 //Write date from users settings
4176 aTargetData = &anInputData;
4177 aTargetIndex = toolBarMarkerIndex;
4179 //Write date from default settings
4180 if(hasDefaultState) {
4181 aTargetData = &anInputDataDef;
4182 aTargetIndex = toolBarMarkerIndexDef;
4186 if(aTargetData && aTargetIndex >= 0 ) {
4187 aTargetData->device()->seek(0);
4188 while( aTargetData->device()->pos() < aTargetIndex ) {
4193 isDockWinWriten = true;
4200 aTargetData = &anInputData;
4201 aTargetIndex = toolBarMarkerIndex;
4203 if(hasDefaultState) {
4204 aTargetData = &anInputDataDef;
4205 aTargetIndex = toolBarMarkerIndexDef;
4209 if(aTargetData && aTargetIndex >= 0) {
4211 if(!isDockWinWriten ) {
4212 //Write version marker
4213 int marker, version;
4214 aTargetData->device()->seek(0);
4215 *aTargetData >> marker;
4216 *aTargetData >> version;
4219 aData << (uchar) QDockWidgetMarker;
4221 int shift = 4*sizeof(int) + sizeof(QSize);
4222 index = aTargetIndex - shift;
4224 index = aTargetIndex;
4227 aTargetData->device()->seek(index);
4228 while(!aTargetData->atEnd()) {
4233 } else { // Not treat toolbars
4234 aData << (uchar) QToolBarMarker;
4235 aData << (int) 0; //Nb toolbars = 0
4242 \brief Emits operationFinished signal.
4243 \param theModuleName the name of the module which perfomed the operation
4244 \param theOperationName the operation name
4245 \param theEntryList the list of the created objects entries
4247 void LightApp_Application::emitOperationFinished( const QString& theModuleName,
4248 const QString& theOperationName,
4249 const QStringList& theEntryList )
4251 emit operationFinished( theModuleName, theOperationName, theEntryList );