1 // Copyright (C) 2007-2012 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_OBFilter.h"
53 #include "LightApp_EventFilter.h"
54 #include "LightApp_OBSelector.h"
55 #include "LightApp_SelectionMgr.h"
56 #include "LightApp_DataObject.h"
57 #include "LightApp_WgViewModel.h"
58 #include "LightApp_FullScreenHelper.h"
61 #include <GUI_version.h>
62 #include <Basics_OCCTVersion.hxx>
64 #include <SALOME_Event.h>
66 #include <Style_Salome.h>
67 #include <Style_PrefDlg.h>
69 #include <CAM_Module.h>
70 #include <CAM_DataModel.h>
71 #include <CAM_Study.h>
72 #include <STD_TabDesktop.h>
74 #include <SUIT_DataBrowser.h>
75 #include <SUIT_Session.h>
76 #include <SUIT_Study.h>
77 #include <SUIT_FileDlg.h>
78 #include <SUIT_ResourceMgr.h>
79 #include <SUIT_ShortcutMgr.h>
80 #include <SUIT_Tools.h>
81 #include <SUIT_Accel.h>
82 #include <SUIT_MessageBox.h>
83 #include <SUIT_ViewWindow.h>
86 #include <QtxToolBar.h>
87 #include <QtxTreeView.h>
88 #include <QtxMRUAction.h>
89 #include <QtxDockAction.h>
90 #include <QtxDockWidget.h>
91 #include <QtxActionToolMgr.h>
92 #include <QtxSearchTool.h>
93 #include <QtxWorkstack.h>
95 #include <QtxWebBrowser.h>
97 #include <LogWindow.h>
99 #ifndef DISABLE_GLVIEWER
100 #include <GLViewer_Viewer.h>
101 #include <GLViewer_ViewManager.h>
102 #include "LightApp_GLSelector.h"
105 #ifndef DISABLE_PLOT2DVIEWER
106 #include <Plot2d_ViewManager.h>
107 #include <Plot2d_ViewModel.h>
108 #include <Plot2d_ViewWindow.h>
109 #include <Plot2d_ViewFrame.h>
110 #include "LightApp_Plot2dSelector.h"
111 #ifndef DISABLE_SALOMEOBJECT
112 #include <SPlot2d_ViewModel.h>
114 #include <Plot2d_ViewModel.h>
118 #ifndef DISABLE_OCCVIEWER
119 #include <OCCViewer_ViewManager.h>
120 #include <OCCViewer_ViewFrame.h>
121 #ifndef DISABLE_SALOMEOBJECT
122 #include <SOCC_ViewModel.h>
124 #include <OCCViewer_ViewModel.h>
126 #include "LightApp_OCCSelector.h"
129 #ifndef DISABLE_VTKVIEWER
130 #ifndef DISABLE_SALOMEOBJECT
131 #include <SVTK_ViewModel.h>
132 #include <SVTK_ViewManager.h>
133 #include "LightApp_VTKSelector.h"
135 #include <VTKViewer_ViewModel.h>
136 #include <VTKViewer_ViewManager.h>
138 #include <VTKViewer_ViewModel.h>
141 //#ifndef DISABLE_SUPERVGRAPHVIEWER
142 // #include <SUPERVGraph_ViewModel.h>
143 // #include <SUPERVGraph_ViewFrame.h>
144 // #include <SUPERVGraph_ViewManager.h>
147 #ifndef DISABLE_QXGRAPHVIEWER
148 //VSR: QxGraph has been replaced by QxScene
149 // #include <QxGraph_ViewModel.h>
150 // #include <QxGraph_ViewWindow.h>
151 // #include <QxGraph_ViewManager.h>
152 #include <QxScene_ViewManager.h>
153 #include <QxScene_ViewModel.h>
154 #include <QxScene_ViewWindow.h>
158 #define VISIBILITY_COLUMN_WIDTH 25
164 #include <QStringList>
166 #include <QApplication>
168 #include <QStatusBar>
170 #include <QObjectList>
172 #include <QInputDialog>
173 #include <QFontDatabase>
175 #include <QByteArray>
179 #include <QHeaderView>
184 #include <utilities.h>
186 #define FIRST_HELP_ID 1000000
188 #ifndef DISABLE_SALOMEOBJECT
189 #include <SALOME_InteractiveObject.hxx>
190 #include <SALOME_ListIO.hxx>
193 #include <Standard_Version.hxx>
195 #define ToolBarMarker 0
196 #define DockWidgetMarker 1
198 static const char* imageEmptyIcon[] = {
201 "....................",
202 "....................",
203 "....................",
204 "....................",
205 "....................",
206 "....................",
207 "....................",
208 "....................",
209 "....................",
210 "....................",
211 "....................",
212 "....................",
213 "....................",
214 "....................",
215 "....................",
216 "....................",
217 "....................",
218 "....................",
219 "....................",
220 "...................."};
222 int LightApp_Application::lastStudyId = 0;
225 \return last global id of study
227 int LightApp_Application::studyId()
229 return LightApp_Application::lastStudyId;
232 /*!Create new instance of LightApp_Application.*/
233 extern "C" LIGHTAPP_EXPORT SUIT_Application* createApplication()
235 return new LightApp_Application();
238 /*! \var global preferences of LightApp */
239 LightApp_Preferences* LightApp_Application::_prefs_ = 0;
243 \class LightApp_Application
244 Application containing LightApp module
248 LightApp_Application::LightApp_Application()
249 : CAM_Application( false ),
251 myScreenHelper(new LightApp_FullScreenHelper())
253 Q_INIT_RESOURCE( LightApp );
255 STD_TabDesktop* desk = new STD_TabDesktop();
256 desk->setFullScreenAllowed(false);
260 // initialize auto save timer
261 myAutoSaveTimer = new QTimer( this );
262 myAutoSaveTimer->setSingleShot( true );
263 connect( myAutoSaveTimer, SIGNAL( timeout() ), this, SLOT( onSaveDoc() ) );
265 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
266 QPixmap aLogo = aResMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
268 QtxWebBrowser::setData("browser:icon", aResMgr->loadPixmap( "LightApp", tr( "BROWSER_ICON" ) ) );
269 QtxWebBrowser::setData("browser:title", tr( "BROWSER_TITLE" ) );
270 QtxWebBrowser::setData("toolbar:title", tr( "BROWSER_TOOLBAR_TITLE" ) );
271 QtxWebBrowser::setData("menu:file:title", tr( "BROWSER_FILEMENU" ) );
272 QtxWebBrowser::setData("action:close:title", tr( "BROWSER_CLOSE" ) );
273 QtxWebBrowser::setData("action:close:icon", aResMgr->loadPixmap( "LightApp", tr( "BROWSER_CLOSE_ICON" ) ) );
274 QtxWebBrowser::setData("action:back:title", tr( "BROWSER_BACK" ) );
275 QtxWebBrowser::setData("action:forward:title", tr( "BROWSER_FORWARD" ) );
276 QtxWebBrowser::setData("action:find:title", tr( "BROWSER_FIND" ) );
277 QtxWebBrowser::setData("action:findnext:title", tr( "BROWSER_FINDNEXT" ) );
278 QtxWebBrowser::setData("action:findprev:title", tr( "BROWSER_FINDPREV" ) );
280 desktop()->setWindowIcon( aLogo );
281 desktop()->setDockableMenuBar( false );
282 desktop()->setDockableStatusBar( false );
284 // base logo (salome itself)
285 desktop()->logoInsert( "_app_base", aResMgr->loadPixmap( "LightApp", tr( "APP_BASE_LOGO" ), false ) );
286 // extra logo (salome-based application)
287 desktop()->logoInsert( "_app_extra", aResMgr->loadPixmap( "LightApp", tr( "APP_EXTRA_LOGO" ), false ) );
291 mySelMgr = new LightApp_SelectionMgr( this );
293 myAccel = SUIT_Accel::getAccel();
295 #ifndef DISABLE_OCCVIEWER
296 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, OCCViewer_Viewer::Type() );
297 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, OCCViewer_Viewer::Type() );
298 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, OCCViewer_Viewer::Type() );
299 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, OCCViewer_Viewer::Type() );
300 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, OCCViewer_Viewer::Type() );
301 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, OCCViewer_Viewer::Type() );
302 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, OCCViewer_Viewer::Type() );
303 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, OCCViewer_Viewer::Type() );
304 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, OCCViewer_Viewer::Type() );
305 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, OCCViewer_Viewer::Type() );
306 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, OCCViewer_Viewer::Type() );
308 #ifndef DISABLE_VTKVIEWER
309 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, VTKViewer_Viewer::Type() );
310 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, VTKViewer_Viewer::Type() );
311 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, VTKViewer_Viewer::Type() );
312 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, VTKViewer_Viewer::Type() );
313 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, VTKViewer_Viewer::Type() );
314 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, VTKViewer_Viewer::Type() );
315 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, VTKViewer_Viewer::Type() );
316 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, VTKViewer_Viewer::Type() );
317 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, VTKViewer_Viewer::Type() );
318 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, VTKViewer_Viewer::Type() );
319 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, VTKViewer_Viewer::Type() );
321 #ifndef DISABLE_PLOT2DVIEWER
322 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, Plot2d_Viewer::Type() );
323 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, Plot2d_Viewer::Type() );
324 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, Plot2d_Viewer::Type() );
325 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, Plot2d_Viewer::Type() );
326 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, Plot2d_Viewer::Type() );
327 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, Plot2d_Viewer::Type() );
328 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, Plot2d_Viewer::Type() );
331 connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) );
333 // Set existing font for the python console in resources
334 if( !aResMgr->hasValue( "PyConsole", "font" ) )
337 QFont f = aResMgr->fontValue( "PyConsole", "font" );
339 QStringList famdb = fdb.families();
341 if ( famdb.contains(f.family()) || !aResMgr->hasValue( "PyConsole", "additional_families" ) )
344 QStringList anAddFamilies = aResMgr->stringValue( "PyConsole", "additional_families" ).split( ";", QString::SkipEmptyParts );
346 for ( QStringList::Iterator it = anAddFamilies.begin(); it != anAddFamilies.end(); ++it )
349 if ( famdb.contains(aFamily) )
351 f.setFamily( aFamily );
352 aResMgr->setValue( "PyConsole", "font", f );
359 *\li Save window geometry.
360 *\li Save desktop geometry.
361 *\li Save resource maneger.
362 *\li Delete selection manager.
364 LightApp_Application::~LightApp_Application()
367 delete myScreenHelper;
370 /*!Start application.*/
371 void LightApp_Application::start()
373 CAM_Application::start();
376 updateViewManagers();
379 desktop()->statusBar()->showMessage( "" );
381 LightApp_EventFilter::Init();
384 /*!Gets application name.*/
385 QString LightApp_Application::applicationName() const
387 static QString _app_name;
388 if ( _app_name.isEmpty() )
389 _app_name = tr( "APP_NAME" );
393 /*!Gets application version.*/
394 QString LightApp_Application::applicationVersion() const
396 static QString _app_version;
398 if ( _app_version.isEmpty() )
400 QString resVersion = tr( "APP_VERSION" );
401 if ( resVersion != "APP_VERSION" )
403 _app_version = resVersion;
407 _app_version = GUI_VERSION_STR;
413 /*!Load module by \a name.*/
414 CAM_Module* LightApp_Application::loadModule( const QString& name, const bool showMsg )
416 CAM_Module* mod = CAM_Application::loadModule( name, showMsg );
419 connect( this, SIGNAL( studyOpened() ), mod, SLOT( onModelOpened() ) );
420 connect( this, SIGNAL( studySaved() ), mod, SLOT( onModelSaved() ) );
421 connect( this, SIGNAL( studyClosed() ), mod, SLOT( onModelClosed() ) );
426 /*!Activate module by \a modName*/
427 bool LightApp_Application::activateModule( const QString& modName )
430 CAM_Module* prevMod = activeModule();
433 actName = prevMod->moduleName();
435 if ( actName == modName )
438 putInfo( tr( "ACTIVATING_MODULE" ).arg( modName ) );
440 saveDockWindowsState();
442 bool status = CAM_Application::activateModule( modName );
444 updateModuleActions();
452 updateViewManagers();
457 /*!Gets selection manager.*/
458 LightApp_SelectionMgr* LightApp_Application::selectionMgr() const
463 /*!Creat action "New window" for certain type of viewer:*/
464 void LightApp_Application::createActionForViewer( const int id,
466 const QString& suffix,
469 QString vtlt = tr( QString( "NEW_WINDOW_%1" ).arg( suffix ).toLatin1().constData() );
470 QString tip = tr( "CREATING_NEW_WINDOW" ).arg( vtlt.remove( "&" ) );
471 QAction* a = createAction( id, // menu action id
478 false, // toggle flag
480 SLOT( onNewWindow() ) ); // slot
481 createMenu( a, parentId, -1 );
486 void LightApp_Application::createActions()
488 STD_Application::createActions();
490 SUIT_Desktop* desk = desktop();
491 SUIT_ResourceMgr* resMgr = resourceMgr();
494 createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIcon(),
495 tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
496 Qt::CTRL+Qt::Key_R, desk, false, this, SLOT( onPreferences() ) );
499 int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
500 createMenu( separator(), helpMenu, -1, 1 );
501 QStringList aModuleList;
502 modules( aModuleList, false );
503 aModuleList.prepend( "GUI" );
504 aModuleList.prepend( "KERNEL" );
506 int id = LightApp_Application::UserID + FIRST_HELP_ID;
508 // help for other existing modules
511 foreach( aModule, aModuleList ) {
512 if ( aModule.isEmpty() ) // module title (user name)
514 IMap <QString, QString> helpData; // list of help files for the module
515 QString helpSubMenu; // help submenu name (empty if not needed)
516 QString modName = moduleName( aModule ); // module name
517 if ( modName.isEmpty() ) modName = aModule; // for KERNEL and GUI
518 QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName ); // module root dir variable
519 QString modDir = getenv( rootDir.toLatin1().constData() ); // module root dir
521 if (resMgr->hasValue( modName, "documentation" ) )
522 docSection = resMgr->stringValue(modName, "documentation");
523 else if ( resMgr->hasSection( modName + "_documentation" ) )
524 docSection = modName + "_documentation";
525 if ( !docSection.isEmpty() ) {
526 helpSubMenu = resMgr->stringValue( docSection, "sub_menu", "" ).arg( aModule );
527 QStringList listOfParam = resMgr->parameters( docSection );
528 foreach( QString paramName, listOfParam ) {
529 QString valueStr = resMgr->stringValue( docSection, paramName );
530 if ( !valueStr.isEmpty() ) {
531 QFileInfo fi( valueStr );
532 if ( fi.isRelative() && !modDir.isEmpty() )
533 valueStr = Qtx::addSlash( modDir ) + valueStr;
534 if ( QFile::exists( valueStr ) )
535 helpData.insert( paramName.arg( aModule ), valueStr );
540 if ( helpData.isEmpty() && !modDir.isEmpty() ) {
541 QStringList idxLst = QStringList() << modDir << "share" << "doc" << "salome" << "gui" << modName << "index.html";
542 QString indexFile = idxLst.join( QDir::separator() ); // index file
543 if ( QFile::exists( indexFile ) )
544 helpData.insert( tr( "%1 module Users's Guide" ).arg( aModule ), indexFile );
547 IMapConstIterator<QString, QString > fileIt;
548 for ( fileIt = helpData.begin(); fileIt != helpData.end(); fileIt++ ) {
549 QString helpFileName = fileIt.key();
550 // remove all '//' occurances
551 while ( helpFileName.contains( "//" ) )
552 helpFileName.replace( "//", "" );
553 // obtain submenus hierarchy if given
554 QStringList smenus = helpFileName.split( "/" );
555 helpFileName = smenus.last();
557 QAction* a = createAction( id, helpFileName,
558 resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
559 helpFileName, helpFileName,
560 0, desk, false, this, SLOT( onHelpContentsModule() ) );
561 a->setData( fileIt.value() );
562 if ( !helpSubMenu.isEmpty() ) {
563 smenus.prepend( helpSubMenu );
565 // create sub-menus hierarchy
566 int menuId = helpMenu;
567 foreach ( QString subMenu, smenus ) {
568 menuId = createMenu( subMenu, menuId, -1, 0 );
570 createMenu( a, menuId, -1, 0 );
576 static QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), 0 );
577 connect( mru, SIGNAL( activated( const QString& ) ), this, SLOT( onMRUActivated( const QString& ) ) );
578 registerAction( MRUId, mru );
580 // default icon for neutral point ('SALOME' module)
581 QPixmap defIcon = resMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
582 if ( defIcon.isNull() )
583 defIcon = QPixmap( imageEmptyIcon );
585 //! default icon for any module
586 QPixmap modIcon = resMgr->loadPixmap( "LightApp", tr( "APP_MODULE_ICO" ), false );
587 if ( modIcon.isNull() )
588 modIcon = QPixmap( imageEmptyIcon );
591 modules( modList, false );
593 if ( modList.count() > 1 )
595 LightApp_ModuleAction* moduleAction =
596 new LightApp_ModuleAction( tr( "APP_NAME" ), defIcon, desk );
598 QMap<QString, QString> iconMap;
599 moduleIconNames( iconMap );
601 const int iconSize = 20;
603 QStringList::Iterator it;
604 for ( it = modList.begin(); it != modList.end(); ++it )
606 if ( !isLibExists( *it ) )
609 QString modName = moduleName( *it );
611 if ( !isModuleAccessible( *it ) )
615 if ( iconMap.contains( *it ) )
616 iconName = iconMap[*it];
618 QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
622 INFOS ( "****************************************************************" << std::endl
623 << "* Icon for " << (*it).toLatin1().constData()
624 << " not found. Using the default one." << std::endl
625 << "****************************************************************" << std::endl );
628 icon = Qtx::scaleIcon( icon, iconSize );
630 moduleAction->insertModule( *it, icon );
633 connect( moduleAction, SIGNAL( moduleActivated( const QString& ) ),
634 this, SLOT( onModuleActivation( const QString& ) ) );
635 registerAction( ModulesListId, moduleAction );
639 int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, MenuWindowId, 100 );
640 int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
642 createAction( CloseId, tr( "TOT_CLOSE" ), QIcon(), tr( "MEN_DESK_CLOSE" ), tr( "PRP_CLOSE" ),
643 Qt::CTRL+Qt::Key_F4, desk, false, this, SLOT( onCloseWindow() ) );
644 createAction( CloseAllId, tr( "TOT_CLOSE_ALL" ), QIcon(), tr( "MEN_DESK_CLOSE_ALL" ), tr( "PRP_CLOSE_ALL" ),
645 0, desk, false, this, SLOT( onCloseAllWindow() ) );
646 createAction( GroupAllId, tr( "TOT_GROUP_ALL" ), QIcon(), tr( "MEN_DESK_GROUP_ALL" ), tr( "PRP_GROUP_ALL" ),
647 0, desk, false, this, SLOT( onGroupAllWindow() ) );
649 createMenu( CloseId, windowMenu, 0, -1 );
650 createMenu( CloseAllId, windowMenu, 0, -1 );
651 createMenu( GroupAllId, windowMenu, 0, -1 );
652 createMenu( separator(), windowMenu, -1, 0 );
654 #ifndef DISABLE_GLVIEWER
655 createActionForViewer( NewGLViewId, newWinMenu, QString::number( 0 ), Qt::ALT+Qt::Key_G );
657 #ifndef DISABLE_PLOT2DVIEWER
658 createActionForViewer( NewPlot2dId, newWinMenu, QString::number( 1 ), Qt::ALT+Qt::Key_P );
660 #ifndef DISABLE_OCCVIEWER
661 createActionForViewer( NewOCCViewId, newWinMenu, QString::number( 2 ), Qt::ALT+Qt::Key_O );
663 #ifndef DISABLE_VTKVIEWER
664 createActionForViewer( NewVTKViewId, newWinMenu, QString::number( 3 ), Qt::ALT+Qt::Key_K );
666 #ifndef DISABLE_QXGRAPHVIEWER
667 //VSR: QxGraph has been replaced by QxScene
668 // createActionForViewer( NewQxGraphViewId, newWinMenu, QString::number( 4 ), Qt::ALT+Qt::Key_C );
669 createActionForViewer( NewQxSceneViewId, newWinMenu, QString::number( 4 ), Qt::ALT+Qt::Key_S );
672 createAction( RenameId, tr( "TOT_RENAME" ), QIcon(), tr( "MEN_DESK_RENAME" ), tr( "PRP_RENAME" ),
673 Qt::ALT+Qt::SHIFT+Qt::Key_R, desk, false, this, SLOT( onRenameWindow() ) );
674 createMenu( RenameId, windowMenu, -1 );
676 int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
677 createMenu( PreferencesId, fileMenu, 50, -1 );
678 createMenu( separator(), fileMenu, -1, 50, -1 );
680 createMenu( separator(), fileMenu, -1, 100, -1 );
681 createMenu( MRUId, fileMenu, 100, -1 );
682 createMenu( separator(), fileMenu, -1, 100, -1 );
684 createAction( StyleId, tr( "TOT_THEME" ), QIcon(), tr( "MEN_DESK_THEME" ), tr( "PRP_THEME" ),
685 0, desk, false, this, SLOT( onStylePreferences() ) );
687 createAction( FullScreenId, tr( "TOT_FULLSCREEN" ), QIcon(), tr( "MEN_DESK_FULLSCREEN" ), tr( "PRP_FULLSCREEN" ),
688 Qt::Key_F11, desk, false, this, SLOT( onFullScreen() ) );
691 int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1 );
692 createMenu( separator(), viewMenu, -1, 20, -1 );
693 createMenu( StyleId, viewMenu, 20, -1 );
694 createMenu( FullScreenId, viewMenu, 20, -1 );
696 int modTBar = createTool( tr( "INF_TOOLBAR_MODULES" ) );
697 createTool( ModulesListId, modTBar );
700 /*!On module activation action.*/
701 void LightApp_Application::onModuleActivation( const QString& modName )
703 // Force user to create/open a study before module activation
704 QMap<QString, QString> iconMap;
705 moduleIconNames( iconMap );
706 QPixmap icon = resourceMgr()->loadPixmap( moduleName( modName ), iconMap[ modName ], false );
708 icon = resourceMgr()->loadPixmap( "LightApp", tr( "APP_MODULE_BIG_ICO" ), false ); // default icon for any module
710 bool cancelled = false;
712 while ( !modName.isEmpty() && !activeStudy() && !cancelled ){
713 LightApp_ModuleDlg aDlg( desktop(), modName, icon );
714 QMap<int, QString> opmap = activateModuleActions();
715 for ( QMap<int, QString>::ConstIterator it = opmap.begin(); it != opmap.end(); ++it )
716 aDlg.addButton( it.value(), it.key() );
718 int res = aDlg.exec();
720 // some operation is selected
721 moduleActionSelected( res );
725 putInfo( tr("INF_CANCELLED") );
727 LightApp_ModuleAction* moduleAction =
728 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
730 moduleAction->setActiveModule( QString() );
736 activateModule( modName );
739 /*!Default module activation.*/
740 QString LightApp_Application::defaultModule() const
742 QStringList aModuleNames;
743 modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration
744 //! If there's the one and only module --> activate it automatically
745 //! TODO: Possible improvement - default module can be taken from preferences
746 return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" );
749 /*!On new window slot.*/
750 void LightApp_Application::onNewWindow()
752 const QObject* obj = sender();
753 if ( !obj || !obj->inherits( "QAction" ) )
757 int id = actionId( (QAction*)obj );
760 #ifndef DISABLE_GLVIEWER
762 type = GLViewer_Viewer::Type();
765 #ifndef DISABLE_PLOT2DVIEWER
767 type = Plot2d_Viewer::Type();
770 #ifndef DISABLE_OCCVIEWER
772 type = OCCViewer_Viewer::Type();
775 #ifndef DISABLE_VTKVIEWER
777 type = VTKViewer_Viewer::Type();
780 #ifndef DISABLE_QXGRAPHVIEWER
781 //VSR: QxGraph has been replaced by QxScene
782 // case NewQxGraphViewId:
783 // type = QxGraph_Viewer::Type();
785 case NewQxSceneViewId:
786 type = QxScene_Viewer::Type();
791 if ( !type.isEmpty() )
792 createViewManager( type );
796 SLOT: Creates new document
798 void LightApp_Application::onNewDoc()
800 //asl: fix for 0020515
802 saveDockWindowsState();
804 CAM_Application::onNewDoc();
808 SLOT: Opens new document
810 void LightApp_Application::onOpenDoc()
812 SUIT_Study* study = activeStudy();
813 saveDockWindowsState();
815 CAM_Application::onOpenDoc();
817 if ( !study ) // new study will be create in THIS application
820 updateViewManagers();
825 SLOT: Opens new document.
826 \param aName - name of file
828 bool LightApp_Application::onOpenDoc( const QString& aName )
830 // We should take mru action first because this application instance can be deleted later.
831 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
833 bool res = CAM_Application::onOpenDoc( aName );
838 mru->insert( aName );
840 mru->remove( aName );
846 SLOT: Displays "About" message box
848 void LightApp_Application::onHelpAbout()
850 LightApp_AboutDlg dlg( applicationName(), applicationVersion(), desktop() );
855 Private SLOT: Called on selection is changed
856 Dispatchs active module that selection is changed
858 void LightApp_Application::onSelection()
860 onSelectionChanged();
862 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
863 ((LightApp_Module*)activeModule())->selectionChanged();
868 \param study - SUIT_Study.
870 void LightApp_Application::setActiveStudy( SUIT_Study* study )
872 CAM_Application::setActiveStudy( study );
876 Enables/Disables menu items and toolbar buttons. Rebuild menu
878 void LightApp_Application::updateCommandsStatus()
880 CAM_Application::updateCommandsStatus();
883 #ifndef DISABLE_GLVIEWER
884 a = action( NewGLViewId );
886 a->setEnabled( activeStudy() );
889 #ifndef DISABLE_PLOT2DVIEWER
890 a = action( NewPlot2dId );
892 a->setEnabled( activeStudy() );
895 #ifndef DISABLE_OCCVIEWER
896 a = action( NewOCCViewId );
898 a->setEnabled( activeStudy() );
901 #ifndef DISABLE_VTKVIEWER
902 a = action( NewVTKViewId );
904 a->setEnabled( activeStudy() );
907 #ifndef DISABLE_QXGRAPHVIEWER
908 //VSR: QxGraph has been replaced by QxScene
909 // a = action( NewQxGraphViewId );
910 a = action( NewQxSceneViewId );
912 a->setEnabled( activeStudy() );
918 Runs system command in separate thread
920 class RunBrowser: public QThread
923 RunBrowser( LightApp_Application* app,
924 const QString& theApp,
925 const QString& theParams,
926 const QString& theHelpFile,
927 const QString& theContext = QString() )
929 myParams( theParams ),
930 myContext( theContext ),
934 //For the external browser always specify 'file://' protocol,
935 //because some WEB browsers (for example Mozilla Firefox) can't open local file without protocol.
936 myHelpFile = QString("file://%1").arg( QFileInfo( theHelpFile ).canonicalFilePath() );
941 if ( !myApp.isEmpty() && !myHelpFile.isEmpty()) {
942 QString aCommand = QString( "%1 %2 \"%3%4\"" ).arg( myApp, myParams, myHelpFile, myContext.isEmpty() ? QString("") : QString( "#%1" ).arg( myContext ) );
944 QProcess* proc = new QProcess();
946 proc->start( aCommand );
947 if ( !proc->waitForStarted() ) {
948 SALOME_CustomEvent* ce2000 = new SALOME_CustomEvent( 2000 );
949 QString* msg = new QString( QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).arg( myApp, myHelpFile ) );
950 ce2000->setData( msg );
951 QApplication::postEvent( myLApp, ce2000 );
962 LightApp_Application* myLApp;
966 SLOT: Displays help contents for choosen module
968 void LightApp_Application::onHelpContentsModule()
970 const QAction* a = (QAction*) sender();
971 QString helpFile = a->data().toString();
972 if ( helpFile.isEmpty() ) return;
974 SUIT_ResourceMgr* resMgr = resourceMgr();
977 platform = "winapplication";
979 platform = "application";
981 QString anApp = resMgr->stringValue("ExternalBrowser", platform);
984 anApp.prepend( quote );
985 anApp.append( quote );
987 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
988 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
990 if( useExtBrowser ) {
991 if ( !anApp.isEmpty() ) {
992 RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile );
996 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
997 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
998 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1000 showPreferences( tr( "PREF_APP" ) );
1005 // On Win32 platform QWebKit of the Qt 4.6.3 hang up in case 'file://' protocol
1006 // is defined. On Linux platform QWebKit doesn't work correctly without 'file://' protocol.
1007 QtxWebBrowser::loadUrl(helpFile);
1009 QtxWebBrowser::loadUrl(QString("file://%1").arg(helpFile));
1015 SLOT: Displays help contents for choosen dialog
1017 void LightApp_Application::onHelpContextModule( const QString& theComponentName,
1018 const QString& theFileName,
1019 const QString& theContext )
1021 QString fileName = theFileName;
1022 QString context = theContext;
1023 if ( !QFile::exists( fileName ) && theContext.isEmpty() ) {
1024 // context might be passed within theFileName argument
1025 QStringList comps = fileName.split("#");
1026 if ( comps.count() > 1 ) {
1027 context = comps.last();
1029 fileName = comps.join("#");
1033 QString homeDir = "";
1034 if ( !theComponentName.isEmpty() ) {
1035 QString dir = getenv( ( theComponentName + "_ROOT_DIR" ).toLatin1().constData() );
1036 if ( !dir.isEmpty() )
1037 homeDir = Qtx::addSlash( Qtx::addSlash( dir ) +
1038 Qtx::addSlash( "share" ) +
1039 Qtx::addSlash( "doc" ) +
1040 Qtx::addSlash( "salome" ) +
1041 Qtx::addSlash( "gui" ) +
1042 Qtx::addSlash( theComponentName ) );
1045 QString helpFile = QFileInfo( homeDir + fileName ).absoluteFilePath();
1046 SUIT_ResourceMgr* resMgr = resourceMgr();
1049 platform = "winapplication";
1051 platform = "application";
1053 QString anApp = resMgr->stringValue("ExternalBrowser", platform);
1055 QString quote("\"");
1056 anApp.prepend( quote );
1057 anApp.append( quote );
1060 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1063 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
1065 if ( !anApp.isEmpty() ) {
1066 RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile, context );
1070 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1071 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1072 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, context);
1082 QtxWebBrowser::loadUrl(QString("file://%1").arg(helpFile),context);
1089 Sets enable or disable some actions on selection changed.
1091 void LightApp_Application::onSelectionChanged()
1093 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
1094 bool canCopy = m ? m->canCopy() : false;
1095 bool canPaste = m ? m->canPaste() : false;
1097 action( EditCopyId )->setEnabled(canCopy);
1098 action( EditPasteId )->setEnabled(canPaste);
1102 Adds window to application.
1103 \param wid - QWidget
1104 \param flag - key for window
1105 \param studyId - study id
1106 Flag used how identificator of window in windows list.
1109 void LightApp_Application::addWindow( QWidget* wid, const int flag, const int studyId )
1117 if ( !activeStudy() )
1120 sId = activeStudy()->id();
1123 if ( !myWindows.contains( flag ) )
1125 QMap<int, int> winMap;
1126 currentWindows( winMap );
1128 LightApp_WidgetContainer* newWC = new LightApp_WidgetContainer( flag, desktop() );
1129 connect( newWC, SIGNAL( destroyed ( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
1130 // asv: connecting a slot for storing visibility flag of a window
1131 connect( newWC, SIGNAL( visibilityChanged ( bool ) ), SLOT( onVisibilityChanged( bool ) ) );
1132 myWindows.insert( flag, newWC );
1133 if ( winMap.contains( flag ) ) {
1134 //desktop()->removeDockWidget( myWindows[flag] );
1135 desktop()->addDockWidget( (Qt::DockWidgetArea)winMap[flag], myWindows[flag] );
1138 //myWindows[flag]->setResizeEnabled( true );
1139 myWindows[flag]->setFeatures( QDockWidget::AllDockWidgetFeatures );
1140 myWindows[flag]->setObjectName( QString( "dock_window_%1" ).arg( flag ) );
1141 //myWindows[flag]->setFixedExtentWidth( wid->width() );
1142 //myWindows[flag]->setFixedExtentHeight( wid->height() );
1143 myWindows[flag]->resize( wid->width(), wid->height() );
1147 #ifndef DISABLE_PYCONSOLE
1148 if( wid->inherits( "PyConsole_Console" ) )
1150 if( resourceMgr()->hasValue( "PyConsole", "font" ) )
1151 f = resourceMgr()->fontValue( "PyConsole", "font" );
1154 f = ( ( PyConsole_Console* )wid )->font();
1155 resourceMgr()->setValue( "PyConsole", "font", f );
1162 myWindows[flag]->insert( sId, wid );
1165 setWindowShown( flag, !myWindows[flag]->isEmpty() );
1169 QWidget* LightApp_Application::dockWindow( const int id ) const
1172 if ( myWin.contains( id ) )
1177 QDockWidget* LightApp_Application::windowDock( QWidget* wid ) const
1182 QDockWidget* dock = 0;
1183 QWidget* w = wid->parentWidget();
1184 while ( w && !dock )
1186 dock = ::qobject_cast<QDockWidget*>( w );
1187 w = w->parentWidget();
1192 void LightApp_Application::insertDockWindow( const int id, QWidget* wid )
1197 if ( wid != dockWindow( id ) )
1198 removeDockWindow( id );
1200 myWin.insert( id, wid );
1202 QtxDockWidget* dock = new QtxDockWidget( true, desktop() );
1203 connect( dock, SIGNAL( destroyed( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
1205 dock->setFeatures( QDockWidget::AllDockWidgetFeatures );
1206 dock->setObjectName( QString( "window_%1" ).arg( id ) );
1207 dock->setWidget( wid );
1209 QKeySequence accel = wid->property( "shortcut" ).value<QKeySequence>();
1210 if ( !accel.isEmpty() )
1211 dock->toggleViewAction()->setShortcut( accel );
1216 void LightApp_Application::removeDockWindow( const int id )
1218 QWidget* wid = dockWindow( id );
1224 QDockWidget* dock = windowDock( wid );
1228 dock->setWidget( 0 );
1229 wid->setParent( 0 );
1230 wid->setVisible( false );
1234 void LightApp_Application::placeDockWindow( const int id, Qt::DockWidgetArea place )
1236 QDockWidget* dock = windowDock( dockWindow( id ) );
1237 if ( dock && desktop() ) {
1238 desktop()->addDockWidget( place, dock );
1239 QtxDockAction* a = qobject_cast<QtxDockAction*>( action( ViewWindowsId ) );
1240 if ( a ) a->update();
1246 \param flag - key for window
1247 \param studyId - study id
1248 Flag used how identificator of window in windows list.
1250 QWidget* LightApp_Application::getWindow( const int flag, const int )
1252 QWidget* wid = dockWindow( flag );
1254 insertDockWindow( flag, wid = createWindow( flag ) );
1256 QMap<int, int> winMap;
1257 currentWindows( winMap );
1258 if ( winMap.contains( flag ) )
1259 placeDockWindow( flag, (Qt::DockWidgetArea)winMap[flag] );
1265 \return Object Browser
1267 SUIT_DataBrowser* LightApp_Application::objectBrowser()
1269 return qobject_cast<SUIT_DataBrowser*>( dockWindow( WT_ObjectBrowser ) );
1275 LogWindow* LightApp_Application::logWindow()
1277 return qobject_cast<LogWindow*>( dockWindow( WT_LogWindow ) );
1280 #ifndef DISABLE_PYCONSOLE
1282 \return Python Console
1284 PyConsole_Console* LightApp_Application::pythonConsole()
1286 return qobject_cast<PyConsole_Console*>( dockWindow( WT_PyConsole ) );
1291 Updates object browser and maybe data models
1292 \param updateModels - if it is true, then data models are updated
1294 void LightApp_Application::updateObjectBrowser( const bool updateModels )
1296 // update existing data models
1299 const bool isAutoUpdate = objectBrowser() ? objectBrowser()->autoUpdate() : true;
1300 if ( objectBrowser() )
1301 objectBrowser()->setAutoUpdate( false );
1303 LightApp_Study* study = dynamic_cast<LightApp_Study*>(activeStudy());
1305 CAM_Study::ModelList dm_list;
1306 study->dataModels( dm_list );
1307 QListIterator<CAM_DataModel*> it( dm_list );
1308 while ( it.hasNext() ) {
1309 CAM_DataModel* camDM = it.next();
1310 if ( camDM && camDM->inherits( "LightApp_DataModel" ) )
1311 ((LightApp_DataModel*)camDM)->update();
1315 if( objectBrowser() )
1316 objectBrowser()->setAutoUpdate( isAutoUpdate );
1319 if ( objectBrowser() ) {
1320 objectBrowser()->updateGeometry();
1321 objectBrowser()->updateTree( 0, false );
1328 LightApp_Preferences* LightApp_Application::preferences() const
1330 return preferences( false );
1334 \return first view manager of some type
1335 \param vmType - type of view manager
1336 \param create - is it necessary to create view manager in case, when there is no manager of such type
1338 SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, const bool create )
1340 SUIT_ViewManager* aVM = viewManager( vmType );
1341 SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
1343 if ( anActiveVM && anActiveVM->getType() == vmType )
1346 if ( aVM && create )
1348 if ( !aVM->getActiveView() )
1351 aVM->getActiveView()->setFocus();
1354 aVM = createViewManager( vmType );
1360 Creates view manager of some type
1361 \param vmType - type of view manager
1363 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType )
1365 SUIT_ResourceMgr* resMgr = resourceMgr();
1367 SUIT_ViewManager* viewMgr = 0;
1368 #ifndef DISABLE_GLVIEWER
1369 if( vmType == GLViewer_Viewer::Type() )
1371 viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() );
1372 new LightApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
1375 #ifndef DISABLE_PLOT2DVIEWER
1376 if( vmType == Plot2d_Viewer::Type() )
1378 viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
1380 #ifndef DISABLE_SALOMEOBJECT
1381 SPlot2d_Viewer* v = new SPlot2d_Viewer();
1383 new LightApp_Plot2dSelector( v, mySelMgr );
1385 vm = new Plot2d_Viewer();
1387 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1388 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
1391 Plot2d_ViewFrame* frame = wnd->getViewFrame();
1392 frame->setBackgroundColor( resMgr->colorValue( "Plot2d", "Background", frame->backgroundColor() ) );
1396 //#ifndef DISABLE_SUPERVGRAPHVIEWER
1397 // if( vmType == SUPERVGraph_Viewer::Type() )
1399 // viewMgr = new SUPERVGraph_ViewManager( activeStudy(), desktop(), new SUPERVGraph_Viewer() );
1402 #ifndef DISABLE_QXGRAPHVIEWER
1403 //VSR: QxGraph has been replaced by QxScene
1404 // if( vmType == QxGraph_Viewer::Type() )
1406 // viewMgr = new QxGraph_ViewManager( activeStudy(), desktop(), new QxGraph_Viewer() );
1408 if( vmType == QxScene_Viewer::Type() )
1410 viewMgr = new QxScene_ViewManager( activeStudy(), desktop() );
1411 QxScene_Viewer* vm = new QxScene_Viewer();
1412 viewMgr->setViewModel( vm );
1413 //QxScene_ViewWindow* wnd = dynamic_cast<QxScene_ViewWindow*>( viewMgr->getActiveView() );
1416 #ifndef DISABLE_OCCVIEWER
1417 if( vmType == OCCViewer_Viewer::Type() )
1419 viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
1420 OCCViewer_Viewer* vm;
1421 #ifndef DISABLE_SALOMEOBJECT
1422 vm = new SOCC_Viewer();
1424 vm = new OCCViewer_Viewer( true );
1426 vm->setBackground( OCCViewer_ViewFrame::TOP_LEFT,
1427 resMgr->backgroundValue( "OCCViewer", "xz_background", vm->background(OCCViewer_ViewFrame::TOP_LEFT) ) );
1428 vm->setBackground( OCCViewer_ViewFrame::TOP_RIGHT,
1429 resMgr->backgroundValue( "OCCViewer", "yz_background", vm->background(OCCViewer_ViewFrame::TOP_RIGHT) ) );
1430 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_LEFT,
1431 resMgr->backgroundValue( "OCCViewer", "xy_background", vm->background(OCCViewer_ViewFrame::BOTTOM_LEFT) ) );
1432 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_RIGHT,
1433 resMgr->backgroundValue( "OCCViewer", "background", vm->background(OCCViewer_ViewFrame::MAIN_VIEW) ) );
1435 vm->setTrihedronSize( resMgr->doubleValue( "OCCViewer", "trihedron_size", vm->trihedronSize() ),
1436 resMgr->booleanValue( "OCCViewer", "relative_size", vm->trihedronRelative() ));
1439 u = resMgr->integerValue( "OCCViewer", "iso_number_u", u );
1440 v = resMgr->integerValue( "OCCViewer", "iso_number_v", v );
1441 vm->setIsos( u, v );
1442 vm->setInteractionStyle( resMgr->integerValue( "OCCViewer", "navigation_mode", vm->interactionStyle() ) );
1443 vm->setZoomingStyle( resMgr->integerValue( "OCCViewer", "zooming_mode", vm->zoomingStyle() ) );
1444 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1445 new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
1448 #ifndef DISABLE_VTKVIEWER
1449 #ifndef DISABLE_SALOMEOBJECT
1450 if ( vmType == SVTK_Viewer::Type() )
1452 if ( vmType == VTKViewer_Viewer::Type() )
1455 #ifndef DISABLE_SALOMEOBJECT
1456 viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
1457 SVTK_Viewer* vm = dynamic_cast<SVTK_Viewer*>( viewMgr->getViewModel() );
1460 vm->setProjectionMode( resMgr->integerValue( "VTKViewer", "projection_mode", vm->projectionMode() ) );
1461 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1462 vm->setTrihedronSize( resMgr->doubleValue( "VTKViewer", "trihedron_size", vm->trihedronSize() ),
1463 resMgr->booleanValue( "VTKViewer", "relative_size", vm->trihedronRelative() ) );
1464 vm->setStaticTrihedronVisible( resMgr->booleanValue( "VTKViewer", "show_static_trihedron", vm->isStaticTrihedronVisible() ) );
1465 vm->setInteractionStyle( resMgr->integerValue( "VTKViewer", "navigation_mode", vm->interactionStyle() ) );
1466 vm->setZoomingStyle( resMgr->integerValue( "VTKViewer", "zooming_mode", vm->zoomingStyle() ) );
1467 vm->setDynamicPreSelection( resMgr->booleanValue( "VTKViewer", "dynamic_preselection", vm->dynamicPreSelection() ) );
1468 vm->setIncrementalSpeed( resMgr->integerValue( "VTKViewer", "speed_value", vm->incrementalSpeed() ),
1469 resMgr->integerValue( "VTKViewer", "speed_mode", vm->incrementalSpeedMode() ) );
1470 vm->setSpacemouseButtons( resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", vm->spacemouseBtn(1) ),
1471 resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", vm->spacemouseBtn(2) ),
1472 resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", vm->spacemouseBtn(3) ) );
1473 new LightApp_VTKSelector( vm, mySelMgr );
1476 viewMgr = new VTKViewer_ViewManager( activeStudy(), desktop() );
1477 VTKViewer_Viewer* vm = dynamic_cast<VTKViewer_Viewer*>( viewMgr->getViewModel() );
1479 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1487 addViewManager( viewMgr );
1488 SUIT_ViewWindow* viewWin = viewMgr->createViewWindow();
1490 if ( viewWin && desktop() ) {
1491 viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1492 viewWin->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1498 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, QWidget* w )
1500 SUIT_ResourceMgr* resMgr = resourceMgr();
1502 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
1504 new LightApp_WgViewModel( vmType, w ) );
1505 vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
1507 addViewManager( vm );
1508 SUIT_ViewWindow* vw = vm->createViewWindow();
1509 if ( vw && desktop() ) {
1510 vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1511 vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1514 if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
1515 myUserWmTypes << vmType;
1521 SLOT: Removes view manager from application
1523 void LightApp_Application::onCloseView( SUIT_ViewManager* theVM )
1525 removeViewManager( theVM );
1529 Protected SLOT: On study created.
1530 \param theStudy - just created study
1532 void LightApp_Application::onStudyCreated( SUIT_Study* theStudy )
1534 SUIT_DataObject* aRoot = 0;
1535 if ( theStudy && theStudy->root() )
1537 aRoot = theStudy->root();
1538 //aRoot->setName( tr( "DATA_MODELS" ) );
1541 getWindow( WT_ObjectBrowser );
1543 loadDockWindowsState();
1545 if ( objectBrowser() )
1546 objectBrowser()->setRoot( aRoot );
1548 activateModule( defaultModule() );
1550 if ( objectBrowser() )
1551 objectBrowser()->openLevels();
1555 Protected SLOT: On study opened.
1556 \param theStudy - just opened study
1558 void LightApp_Application::onStudyOpened( SUIT_Study* theStudy )
1560 SUIT_DataObject* aRoot = 0;
1561 if ( theStudy && theStudy->root() )
1563 aRoot = theStudy->root();
1567 getWindow( WT_ObjectBrowser );
1569 loadDockWindowsState();
1571 if ( objectBrowser() )
1572 objectBrowser()->setRoot( aRoot );
1574 activateModule( defaultModule() );
1576 if ( objectBrowser() )
1577 objectBrowser()->openLevels();
1582 /*!Protected SLOT. On study saved.*/
1583 void LightApp_Application::onStudySaved( SUIT_Study* s )
1585 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
1587 mru->insert( s->studyName() );
1592 /*!Protected SLOT. On study closed.*/
1593 void LightApp_Application::onStudyClosed( SUIT_Study* s )
1595 // stop auto-save timer
1596 myAutoSaveTimer->stop();
1598 // Bug 10396: clear selection
1599 mySelMgr->clearSelected();
1601 // Bug 12944: emit signal only after clear selection
1604 activateModule( "" );
1607 /*!Protected SLOT.On desktop activated.*/
1608 void LightApp_Application::onDesktopActivated()
1610 CAM_Application::onDesktopActivated();
1611 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>(activeModule());
1613 aModule->studyActivated();
1616 void LightApp_Application::studyOpened( SUIT_Study* s )
1618 CAM_Application::studyOpened( s );
1621 updateViewManagers();
1624 void LightApp_Application::studySaved( SUIT_Study* s )
1626 CAM_Application::studyOpened( s );
1627 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1628 if ( aResMgr && activeStudy() ) {
1629 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
1630 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
1634 void LightApp_Application::studyCreated( SUIT_Study* s )
1636 CAM_Application::studyCreated( s );
1639 updateViewManagers();
1642 /*!Gets file filter.
1643 *\retval QString "(*.bin)"
1645 QString LightApp_Application::getFileFilter() const
1653 Shows file dialog and return user selected file name
1655 QString LightApp_Application::getFileName( bool open, const QString& initial, const QString& filters,
1656 const QString& caption, QWidget* parent )
1660 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1661 return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
1664 /*! Gets directory*/
1665 QString LightApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
1669 return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true );
1672 /*! Get open file names*/
1673 QStringList LightApp_Application::getOpenFileNames( const QString& initial, const QString& filters,
1674 const QString& caption, QWidget* parent )
1678 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1679 return SUIT_FileDlg::getOpenFileNames( parent, initial, fls, caption, true );
1682 /*!Private SLOT. Update object browser.*/
1683 void LightApp_Application::onRefresh()
1685 updateObjectBrowser( true );
1688 /*!Private SLOT. Support drag-and-drop operation.*/
1689 void LightApp_Application::onDropped( const QList<SUIT_DataObject*>& objects, SUIT_DataObject* parent, int row, Qt::DropAction action )
1691 LightApp_DataObject* parentObj = dynamic_cast<LightApp_DataObject*>( parent );
1695 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>( parentObj->module() );
1697 aModule->dropObjects( objects, parentObj, row, action );
1700 /*!Private SLOT. On preferences.*/
1701 void LightApp_Application::onPreferences()
1703 showPreferences( activeModule() ? activeModule()->moduleName() : tr( "PREF_CATEGORY_SALOME" ) );
1706 /*!Private SLOT. On preferences.*/
1707 void LightApp_Application::showPreferences( const QString& itemText )
1709 QApplication::setOverrideCursor( Qt::WaitCursor );
1711 LightApp_PreferencesDlg* prefDlg = new LightApp_PreferencesDlg( preferences( true ), desktop());
1713 QApplication::restoreOverrideCursor();
1718 preferences()->activateItem( itemText );
1720 if ( ( prefDlg->exec() == QDialog::Accepted || prefDlg->isSaved() ) && resourceMgr() )
1723 resourceMgr()->setValue( "desktop", "geometry", desktop()->storeGeometry() );
1724 resourceMgr()->save();
1727 shortcutMgr()->updateShortcuts();
1733 /*!Protected SLOT. On preferences changed.*/
1734 void LightApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param )
1736 LightApp_Module* sMod = 0;
1737 CAM_Module* mod = module( modName );
1738 if ( mod && mod->inherits( "LightApp_Module" ) )
1739 sMod = (LightApp_Module*)mod;
1742 sMod->preferencesChanged( section, param );
1744 preferencesChanged( section, param );
1745 // emit signal to allow additional preferences changing processing
1746 emit preferenceChanged( modName, section, param );
1749 /*!Remove all windows from study.*/
1750 void LightApp_Application::beforeCloseDoc( SUIT_Study* s )
1752 CAM_Application::beforeCloseDoc( s );
1755 /*!Update actions.*/
1756 void LightApp_Application::updateActions()
1758 updateCommandsStatus();
1764 SUIT_Study* LightApp_Application::createNewStudy()
1766 LightApp_Application::lastStudyId++;
1768 LightApp_Study* aStudy = new LightApp_Study( this );
1770 // Set up processing of major study-related events
1771 connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
1772 connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
1773 connect( aStudy, SIGNAL( saved ( SUIT_Study* ) ), this, SLOT( onStudySaved ( SUIT_Study* ) ) );
1774 connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
1780 Creates window by flag.
1781 \param flag - identificator of window type
1783 QWidget* LightApp_Application::createWindow( const int flag )
1787 SUIT_ResourceMgr* resMgr = resourceMgr();
1789 if ( flag == WT_ObjectBrowser )
1791 SUIT_DataBrowser* ob = new SUIT_DataBrowser( new LightApp_DataObject(), desktop() );
1792 ob->setSortMenuEnabled( true );
1793 ob->setAutoUpdate( true );
1794 if ( resMgr->hasValue( "ObjectBrowser", "auto_hide_search_tool" ) )
1795 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
1797 //ob->setAutoOpenLevel( 1 ); // commented by ASV as a fix to bug IPAL10107
1798 ob->setWindowTitle( tr( "OBJECT_BROWSER" ) );
1799 connect( ob, SIGNAL( requestUpdate() ), this, SLOT( onRefresh() ) );
1801 QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
1802 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
1803 treeModel->setSearcher( this );
1804 treeModel->registerColumn( 0, EntryCol, LightApp_DataObject::EntryId );
1805 treeModel->setAppropriate( EntryCol, Qtx::Toggled );
1807 // Mantis issue 0020136: Drag&Drop in OB
1808 SUIT_ProxyModel* proxyModel = dynamic_cast<SUIT_ProxyModel*>(treeModel);
1810 connect( proxyModel, SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
1811 this, SLOT( onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
1814 // temporary commented
1816 OB_ListView* ob_list = dynamic_cast<OB_ListView*>( const_cast<QListView*>( ob->listView() ) );
1818 ob_list->setColumnMaxWidth( 0, desktop()->width()/4 );
1820 ob->setFilter( new LightApp_OBFilter( selectionMgr() ) );
1823 // Create OBSelector
1824 new LightApp_OBSelector( ob, mySelMgr );
1826 ob->treeView()->header()->setResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
1827 ob->treeView()->header()->moveSection(SUIT_DataObject::NameId,SUIT_DataObject::VisibilityId);
1828 ob->treeView()->setColumnWidth(SUIT_DataObject::VisibilityId, VISIBILITY_COLUMN_WIDTH);
1829 ob->setProperty( "shortcut", QKeySequence( "Alt+Shift+O" ) );
1831 ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1833 #ifndef DISABLE_PYCONSOLE
1834 else if ( flag == WT_PyConsole )
1836 PyConsole_Console* pyCons = new PyConsole_Console( desktop(),new LightApp_PyInterp());
1837 pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
1838 pyCons->setFont(resourceMgr()->fontValue( "PyConsole", "font" ));
1839 pyCons->setIsShowBanner(resourceMgr()->booleanValue( "PyConsole", "show_banner", true ));
1840 pyCons->setProperty( "shortcut", QKeySequence( "Alt+Shift+P" ) );
1843 pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1846 else if ( flag == WT_LogWindow )
1848 LogWindow* logWin = new LogWindow( desktop() );
1849 logWin->setWindowTitle( tr( "LOG_WINDOW" ) );
1850 logWin->setProperty( "shortcut", QKeySequence( "Alt+Shift+L" ) );
1852 logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1858 \return default windows( Object Browser, Python Console )
1859 Adds to map \a aMap.
1861 void LightApp_Application::defaultWindows( QMap<int, int>& aMap ) const
1863 aMap.insert( WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1864 #ifndef DISABLE_PYCONSOLE
1865 aMap.insert( WT_PyConsole, Qt::BottomDockWidgetArea );
1867 // aMap.insert( WT_LogWindow, Qt::DockBottom );
1870 /*!Default view managers*/
1871 void LightApp_Application::defaultViewManagers( QStringList& ) const
1877 \return preferences.
1878 Create preferences, if \a crt = true.
1880 LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const
1885 LightApp_Application* that = (LightApp_Application*)this;
1887 bool toCreate = !_prefs_ && crt;
1890 _prefs_ = new LightApp_Preferences( resourceMgr() );
1891 that->createPreferences( _prefs_ );
1894 that->myPrefs = _prefs_;
1896 connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
1897 this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ) );
1902 SUIT_ResourceMgr* resMgr = resourceMgr();
1904 QList<SUIT_Application*> appList = SUIT_Session::session()->applications();
1905 for ( QList<SUIT_Application*>::iterator appIt = appList.begin(); appIt != appList.end(); ++appIt )
1907 LightApp_Application* app = ::qobject_cast<LightApp_Application*>( *appIt );
1911 QStringList modNameList;
1912 app->modules( modNameList, false );
1914 QMap<QString, QString> iconMap;
1915 app->moduleIconNames( iconMap );
1917 for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it )
1919 if ( !app->isLibExists( *it ) || _prefs_->hasModule( *it ) )
1922 int modId = _prefs_->addPreference( *it );
1923 if ( iconMap.contains( *it ) )
1924 _prefs_->setItemIcon( modId, Qtx::scaleIcon( resMgr->loadPixmap( moduleName( *it ), iconMap[*it], false ), 20 ) );
1928 app->modules( modList );
1929 QListIterator<CAM_Module*> itr( modList );
1930 while ( itr.hasNext() )
1932 LightApp_Module* mod = 0;
1934 CAM_Module* anItem = itr.next();
1935 if ( anItem->inherits( "LightApp_Module" ) )
1936 mod = (LightApp_Module*)anItem;
1938 if ( mod && !_prefs_->hasModule( mod->moduleName() ) )
1940 _prefs_->addPreference( mod->moduleName() );
1941 mod->createPreferences();
1942 that->emptyPreferences( mod->moduleName() );
1946 _prefs_->setItemProperty( "info", tr( "PREFERENCES_NOT_LOADED" ) );
1952 Adds new module to application
1954 void LightApp_Application::moduleAdded( CAM_Module* mod )
1956 CAM_Application::moduleAdded( mod );
1958 LightApp_Module* lightMod = 0;
1959 if ( mod && mod->inherits( "LightApp_Module" ) )
1960 lightMod = (LightApp_Module*)mod;
1962 if ( myPrefs && lightMod && !myPrefs->hasModule( lightMod->moduleName() ))
1964 myPrefs->addPreference( mod->moduleName() );
1965 lightMod->createPreferences();
1966 emptyPreferences( mod->moduleName() );
1970 void LightApp_Application::emptyPreferences( const QString& modName )
1972 QtxPreferenceItem* item = myPrefs->findItem( modName, true );
1973 if ( !item || !item->isEmpty() )
1976 // printf( "---------------------> Modify for empty module.\n" );
1978 QtxPagePrefFrameItem* frm = new QtxPagePrefFrameItem( item->title(), item->parentItem() );
1979 frm->setIcon( item->icon() );
1980 frm->setStretch( false );
1981 item->parentItem()->insertItem( frm, item );
1982 new QtxPagePrefLabelItem( Qt::AlignCenter, tr( "PREFERENCES_NOT_SUPPORTED" ).arg( modName ), frm );
1989 void LightApp_Application::createPreferences( LightApp_Preferences* pref )
1994 QStringList aValuesList;
1995 QList<QVariant> anIndicesList;
1999 // . Top-level "SALOME" preferences group <<start>>
2000 int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
2001 pref->setItemIcon( salomeCat, Qtx::scaleIcon( resourceMgr()->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false ), 20 ) );
2003 // .. "General" preferences tab <<start>>
2004 int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat );
2006 // ... "Language" group <<start>>
2007 int langGroup = pref->addPreference( tr( "PREF_GROUP_LANGUAGE" ), genTab );
2008 pref->setItemProperty( "columns", 2, langGroup );
2009 // .... -> application language
2010 int curLang = pref->addPreference( tr( "PREF_CURRENT_LANGUAGE" ), langGroup,
2011 LightApp_Preferences::Selector, "language", "language" );
2012 QStringList aLangs = SUIT_Session::session()->resourceMgr()->stringValue( "language", "languages", "en" ).split( "," );
2013 QList<QVariant> aIcons;
2014 foreach ( QString aLang, aLangs ) {
2015 aIcons << QPixmap( QString( ":/images/%1" ).arg( aLang ) );
2017 pref->setItemProperty( "strings", aLangs, curLang );
2018 pref->setItemProperty( "icons", aIcons, curLang );
2019 // ... "Language" group <<end>>
2021 // ... "Look and feel" group <<start>>
2022 int lookGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), genTab );
2023 // .... -> opaque resize
2024 pref->addPreference( tr( "PREF_OPAQUE_RESIZE" ), lookGroup, LightApp_Preferences::Bool, "desktop", "opaque_resize" );
2025 // .... -> drop-down buttons
2026 pref->addPreference( tr( "PREF_DROP_DOWN_BUTTONS" ), lookGroup, LightApp_Preferences::Bool, "viewers", "drop_down_buttons" );
2027 // ... "Look and feel" group <<end>>
2029 // ... "Study properties" group <<start>>
2030 int studyGroup = pref->addPreference( tr( "PREF_GROUP_STUDY" ), genTab );
2031 pref->setItemProperty( "columns", 2, studyGroup );
2032 // .... -> multi-file save
2033 pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "multi_file" );
2034 // .... -> ascii save mode
2035 pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" );
2036 // .... -> store windows geometry
2037 pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" );
2038 // .... -> auto-save
2039 int autoSaveInterval = pref->addPreference( tr( "PREF_AUTO_SAVE" ), studyGroup,
2040 LightApp_Preferences::IntSpin, "Study", "auto_save_interval" );
2041 pref->setItemProperty( "min", 0, autoSaveInterval );
2042 pref->setItemProperty( "max", 1440, autoSaveInterval );
2043 pref->setItemProperty( "special", tr( "PREF_AUTO_SAVE_DISABLED" ), autoSaveInterval );
2044 // ... "Study properties" group <<end>>
2046 // ... "Help browser" group <<start>>
2047 int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab, LightApp_Preferences::Auto, "ExternalBrowser", "use_external_browser");
2049 QString platform = "winapplication";
2051 QString platform = "application";
2053 // .... -> browser application
2054 int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, LightApp_Preferences::File, "ExternalBrowser", platform );
2055 pref->setItemProperty( "mode", Qtx::PT_OpenFile, apppref );
2056 // .... -> browser parameters
2057 pref->addPreference( tr( "PREF_PARAM" ), extgroup, LightApp_Preferences::String, "ExternalBrowser", "parameters" );
2058 // ... "Help browser" group <<end>>
2060 // ... "Python console properties" group <<start>>
2061 int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab );
2063 pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, LightApp_Preferences::Font, "PyConsole", "font" );
2064 // .... -> show banner
2065 pref->addPreference( tr( "PREF_SHOW_BANNER" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "show_banner" );
2066 // ... "Python console properties" group <<end>>
2068 // ... "MRU" preferences group <<start>>
2069 int mruGroup = pref->addPreference( tr( "PREF_GROUP_MRU" ), genTab, LightApp_Preferences::Auto, "MRU", "show_mru" );
2070 pref->setItemProperty( "columns", 4, mruGroup );
2071 // number of MRU items
2072 int mruVisCount = pref->addPreference( tr( "PREF_MRU_VISIBLE_COUNT" ), mruGroup, LightApp_Preferences::IntSpin,
2073 "MRU", "visible_count" );
2074 pref->setItemProperty( "min", 0, mruVisCount );
2075 pref->setItemProperty( "max", 100, mruVisCount );
2077 int mruLinkType = pref->addPreference( tr( "PREF_MRU_LINK_TYPE" ), mruGroup, LightApp_Preferences::Selector,
2078 "MRU", "link_type" );
2079 aValuesList.clear();
2080 anIndicesList.clear();
2081 aValuesList << tr("PREF_MRU_LINK_AUTO") << tr("PREF_MRU_LINK_SHORT") << tr("PREF_MRU_LINK_FULL");
2082 anIndicesList << 0 << 1 << 2 ;
2083 pref->setItemProperty( "strings", aValuesList, mruLinkType );
2084 pref->setItemProperty( "indexes", anIndicesList, mruLinkType );
2085 // ... "MRU" preferences group <<end>>
2086 // .. "General" preferences tab <<end>>
2088 // .. "OCC viewer" group <<start>>
2089 int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), salomeCat );
2091 // ... "Trihedron" group <<start>>
2092 int occTriGroup = pref->addPreference( tr( "PREF_TRIHEDRON" ), occGroup );
2093 pref->setItemProperty( "columns", 2, occTriGroup );
2094 // .... -> trihedron size
2095 int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occTriGroup,
2096 LightApp_Preferences::DblSpin, "OCCViewer", "trihedron_size" );
2097 pref->setItemProperty( "min", 1.0E-06, occTS );
2098 pref->setItemProperty( "max", 1000, occTS );
2099 // .... -> relative size of trihedron
2100 pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), occTriGroup, LightApp_Preferences::Bool, "OCCViewer", "relative_size" );
2101 // .... -> show static trihedron
2102 pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), occTriGroup, LightApp_Preferences::Bool, "OCCViewer", "show_static_trihedron" );
2103 // ... "Trihedron" group <<end>>
2105 // ... "Iso-lines" group <<start>>
2106 int isoGroup = pref->addPreference( tr( "PREF_ISOS" ), occGroup );
2107 pref->setItemProperty( "columns", 2, isoGroup );
2108 // .... -> nb isos U
2109 int isoU = pref->addPreference( tr( "PREF_ISOS_U" ), isoGroup,
2110 LightApp_Preferences::IntSpin, "OCCViewer", "iso_number_u" );
2111 pref->setItemProperty( "min", 0, isoU );
2112 pref->setItemProperty( "max", 100000, isoU );
2113 // .... -> nb isos V
2114 int isoV = pref->addPreference( tr( "PREF_ISOS_V" ), isoGroup,
2115 LightApp_Preferences::IntSpin, "OCCViewer", "iso_number_v" );
2116 pref->setItemProperty( "min", 0, isoV );
2117 pref->setItemProperty( "max", 100000, isoV );
2118 // ... "Iso-lines" group <<end>>
2120 // ... "Background" group <<start>>
2121 int bgGroup = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup );
2122 // pref->setItemProperty( "columns", 2, bgGroup );
2123 aValuesList.clear();
2124 anIndicesList.clear();
2126 QString formats = OCCViewer_Viewer::backgroundData( aValuesList, idList, txtList );
2127 foreach( int gid, idList ) anIndicesList << gid;
2128 // .... -> 3D viewer background
2129 int bgId = pref->addPreference( tr( "PREF_3DVIEWER_BACKGROUND" ), bgGroup,
2130 LightApp_Preferences::Background, "OCCViewer", "background" );
2131 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2132 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2133 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2134 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2135 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2136 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2137 pref->setItemProperty( "custom_enabled", false, bgId );
2138 pref->setItemProperty( "image_formats", formats, bgId );
2139 // .... -> XZ viewer background
2140 bgId = pref->addPreference( tr( "PREF_XZVIEWER_BACKGROUND" ), bgGroup,
2141 LightApp_Preferences::Background, "OCCViewer", "xz_background" );
2142 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2143 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2144 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2145 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2146 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2147 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2148 pref->setItemProperty( "custom_enabled", false, bgId );
2149 pref->setItemProperty( "image_formats", formats, bgId );
2150 // .... -> YZ viewer background
2151 bgId = pref->addPreference( tr( "PREF_YZVIEWER_BACKGROUND" ), bgGroup,
2152 LightApp_Preferences::Background, "OCCViewer", "yz_background" );
2153 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2154 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2155 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2156 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2157 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2158 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2159 pref->setItemProperty( "custom_enabled", false, bgId );
2160 pref->setItemProperty( "image_formats", formats, bgId );
2161 // .... -> XY viewer background
2162 bgId = pref->addPreference( tr( "PREF_XYVIEWER_BACKGROUND" ), bgGroup,
2163 LightApp_Preferences::Background, "OCCViewer", "xy_background" );
2164 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2165 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2166 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2167 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2168 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2169 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2170 pref->setItemProperty( "custom_enabled", false, bgId );
2171 pref->setItemProperty( "image_formats", formats, bgId );
2172 // ... "Background" group <<end>>
2174 // ... -> empty frame (for layout) <<start>>
2175 int occGen = pref->addPreference( "", occGroup, LightApp_Preferences::Frame );
2176 pref->setItemProperty( "margin", 0, occGen );
2177 pref->setItemProperty( "columns", 2, occGen );
2178 // .... -> navigation mode
2179 int occStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), occGen,
2180 LightApp_Preferences::Selector, "OCCViewer", "navigation_mode" );
2181 aValuesList.clear();
2182 anIndicesList.clear();
2183 aValuesList << tr("PREF_STANDARD_STYLE") << tr("PREF_KEYFREE_STYLE");
2184 anIndicesList << 0 << 1;
2185 pref->setItemProperty( "strings", aValuesList, occStyleMode );
2186 pref->setItemProperty( "indexes", anIndicesList, occStyleMode );
2187 // .... -> zooming mode
2188 #if OCC_VERSION_LARGE > 0x0603000A // available only with OCC-6.3-sp11 and higher version
2189 int occZoomingStyleMode = pref->addPreference( tr( "PREF_ZOOMING" ), occGen,
2190 LightApp_Preferences::Selector, "OCCViewer", "zooming_mode" );
2191 aValuesList.clear();
2192 anIndicesList.clear();
2193 aValuesList << tr("PREF_ZOOMING_AT_CENTER") << tr("PREF_ZOOMING_AT_CURSOR");
2194 anIndicesList << 0 << 1;
2195 pref->setItemProperty( "strings", aValuesList, occZoomingStyleMode );
2196 pref->setItemProperty( "indexes", anIndicesList, occZoomingStyleMode );
2198 // ... -> empty frame (for layout) <<end>>
2199 // .. "OCC viewer" group <<end>>
2201 // .. "VTK viewer" group <<start>>
2202 int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), salomeCat ); //viewTab
2204 // ... -> empty frame (for layout) <<start>>
2205 int vtkGen = pref->addPreference( "", vtkGroup, LightApp_Preferences::Frame );
2206 //pref->setItemProperty( "columns", 2, vtkGen );
2207 // .... -> projection mode
2208 int vtkProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), vtkGen,
2209 LightApp_Preferences::Selector, "VTKViewer", "projection_mode" );
2210 aValuesList.clear();
2211 anIndicesList.clear();
2212 aValuesList << tr("PREF_ORTHOGRAPHIC") << tr("PREF_PERSPECTIVE");
2213 anIndicesList << 0 << 1;
2214 pref->setItemProperty( "strings", aValuesList, vtkProjMode );
2215 pref->setItemProperty( "indexes", anIndicesList, vtkProjMode );
2216 // .... -> background
2217 aValuesList.clear();
2218 anIndicesList.clear();
2220 formats = SVTK_Viewer::backgroundData( aValuesList, idList, txtList );
2221 foreach( int gid, idList ) anIndicesList << gid;
2222 bgId = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGen,
2223 LightApp_Preferences::Background, "VTKViewer", "background" );
2224 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2225 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2226 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2227 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2228 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2229 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2230 pref->setItemProperty( "custom_enabled", false, bgId );
2231 pref->setItemProperty( "image_formats", formats, bgId );
2232 // .... -> navigation mode
2233 int vtkStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), vtkGen,
2234 LightApp_Preferences::Selector, "VTKViewer", "navigation_mode" );
2235 aValuesList.clear();
2236 anIndicesList.clear();
2237 aValuesList << tr("PREF_STANDARD_STYLE") << tr("PREF_KEYFREE_STYLE");
2238 anIndicesList << 0 << 1;
2239 pref->setItemProperty( "strings", aValuesList, vtkStyleMode );
2240 pref->setItemProperty( "indexes", anIndicesList, vtkStyleMode );
2241 // .... -> zooming mode
2242 int vtkZoomingStyleMode = pref->addPreference( tr( "PREF_ZOOMING" ), vtkGen,
2243 LightApp_Preferences::Selector, "VTKViewer", "zooming_mode" );
2244 aValuesList.clear();
2245 anIndicesList.clear();
2246 aValuesList << tr("PREF_ZOOMING_AT_CENTER") << tr("PREF_ZOOMING_AT_CURSOR");
2247 anIndicesList << 0 << 1;
2248 pref->setItemProperty( "strings", aValuesList, vtkZoomingStyleMode );
2249 pref->setItemProperty( "indexes", anIndicesList, vtkZoomingStyleMode );
2250 // .... -> speed increment
2251 int vtkSpeed = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED" ), vtkGen,
2252 LightApp_Preferences::IntSpin, "VTKViewer", "speed_value" );
2253 pref->setItemProperty( "min", 1, vtkSpeed );
2254 pref->setItemProperty( "max", 1000, vtkSpeed );
2255 // .... -> speed mode
2256 int vtkSpeedMode = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED_MODE" ), vtkGen,
2257 LightApp_Preferences::Selector, "VTKViewer", "speed_mode" );
2258 aValuesList.clear();
2259 anIndicesList.clear();
2260 aValuesList << tr("PREF_ARITHMETIC") << tr("PREF_GEOMETRICAL");
2261 anIndicesList << 0 << 1;
2262 pref->setItemProperty( "strings", aValuesList, vtkSpeedMode );
2263 pref->setItemProperty( "indexes", anIndicesList, vtkSpeedMode );
2264 // .... -> dynamic pre-selection
2265 pref->addPreference( tr( "PREF_DYNAMIC_PRESELECTION" ), vtkGen, LightApp_Preferences::Bool, "VTKViewer", "dynamic_preselection" );
2266 // ... -> empty frame (for layout) <<end>>
2268 // ... "Trihedron" group <<start>>
2269 int vtkTriGroup = pref->addPreference( tr( "PREF_TRIHEDRON" ), vtkGroup );
2270 pref->setItemProperty( "columns", 2, vtkTriGroup );
2271 // .... -> trihedron size
2272 int vtkTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), vtkTriGroup,
2273 LightApp_Preferences::DblSpin, "VTKViewer", "trihedron_size" );
2274 pref->setItemProperty( "min", 1.0E-06, vtkTS );
2275 pref->setItemProperty( "max", 150, vtkTS );
2276 // .... -> relative size of trihedron
2277 pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), vtkTriGroup, LightApp_Preferences::Bool, "VTKViewer", "relative_size" );
2278 // .... -> static trihedron
2279 pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), vtkTriGroup, LightApp_Preferences::Bool, "VTKViewer", "show_static_trihedron" );
2280 // ... "Trihedron" group <<end>>
2282 // ... space mouse sub-group <<start>>
2283 int vtkSM = pref->addPreference( tr( "PREF_FRAME_SPACEMOUSE" ), vtkGroup, LightApp_Preferences::GroupBox );
2284 //pref->setItemProperty( "columns", 2, vtkSM );
2285 // .... -> decrease speed increment
2286 int spacemousePref1 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_1" ), vtkSM,
2287 LightApp_Preferences::Selector, "VTKViewer",
2288 "spacemouse_func1_btn" );
2289 // .... -> increase speed increment
2290 int spacemousePref2 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_2" ), vtkSM,
2291 LightApp_Preferences::Selector, "VTKViewer",
2292 "spacemouse_func2_btn" );
2293 // .... -> dominant / combined switch
2294 int spacemousePref3 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_3" ), vtkSM,
2295 LightApp_Preferences::Selector, "VTKViewer",
2296 "spacemouse_func5_btn" ); //
2297 aValuesList.clear();
2298 anIndicesList.clear();
2299 aValuesList << tr( "PREF_SPACEMOUSE_BTN_1" ) << tr( "PREF_SPACEMOUSE_BTN_2" ) << tr( "PREF_SPACEMOUSE_BTN_3" );
2300 aValuesList << tr( "PREF_SPACEMOUSE_BTN_4" ) << tr( "PREF_SPACEMOUSE_BTN_5" ) << tr( "PREF_SPACEMOUSE_BTN_6" );
2301 aValuesList << tr( "PREF_SPACEMOUSE_BTN_7" ) << tr( "PREF_SPACEMOUSE_BTN_8" ) << tr( "PREF_SPACEMOUSE_BTN_*" );
2302 aValuesList << tr( "PREF_SPACEMOUSE_BTN_10" ) << tr( "PREF_SPACEMOUSE_BTN_11" );
2303 anIndicesList << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11;
2304 pref->setItemProperty( "strings", aValuesList, spacemousePref1 );
2305 pref->setItemProperty( "indexes", anIndicesList, spacemousePref1 );
2306 pref->setItemProperty( "strings", aValuesList, spacemousePref2 );
2307 pref->setItemProperty( "indexes", anIndicesList, spacemousePref2 );
2308 pref->setItemProperty( "strings", aValuesList, spacemousePref3 );
2309 pref->setItemProperty( "indexes", anIndicesList, spacemousePref3 );
2310 // ... space mouse sub-group <<end>>
2312 // ... avi recording sub-group <<start>>
2313 int vtkRec = pref->addPreference( tr( "PREF_FRAME_RECORDING" ), vtkGroup, LightApp_Preferences::GroupBox );
2314 pref->setItemProperty( "columns", 2, vtkRec );
2315 // .... -> recording mode
2316 int modePref = pref->addPreference( tr( "PREF_RECORDING_MODE" ), vtkRec,
2317 LightApp_Preferences::Selector, "VTKViewer", "recorder_mode" );
2318 aValuesList.clear();
2319 anIndicesList.clear();
2320 aValuesList << tr( "PREF_SKIPPED_FRAMES" ) << tr( "PREF_ALL_DISLPAYED_FRAMES" );
2321 anIndicesList << 0 << 1;
2322 pref->setItemProperty( "strings", aValuesList, modePref );
2323 pref->setItemProperty( "indexes", anIndicesList, modePref );
2325 int fpsPref = pref->addPreference( tr( "PREF_FPS" ), vtkRec,
2326 LightApp_Preferences::DblSpin, "VTKViewer", "recorder_fps" );
2327 pref->setItemProperty( "min", 0.1, fpsPref );
2328 pref->setItemProperty( "max", 100, fpsPref );
2330 int qualityPref = pref->addPreference( tr( "PREF_QUALITY" ), vtkRec,
2331 LightApp_Preferences::IntSpin, "VTKViewer", "recorder_quality" );
2332 pref->setItemProperty( "min", 1, qualityPref );
2333 pref->setItemProperty( "max", 100, qualityPref );
2334 // .... -> progressive mode
2335 pref->addPreference( tr( "PREF_PROGRESSIVE" ), vtkRec,
2336 LightApp_Preferences::Bool, "VTKViewer", "recorder_progressive" );
2337 // ... avi recording sub-group <<end>>
2339 // ... group names sub-group <<start>>
2340 int vtkGN = pref->addPreference( tr( "PREF_FRAME_GROUP_NAMES" ), vtkGroup,
2341 LightApp_Preferences::GroupBox, "VTKViewer", "show_group_names" );
2342 pref->setItemProperty( "columns", 2, vtkGN );
2343 // .... -> text color
2344 pref->addPreference( tr( "PREF_GROUP_NAMES_TEXT_COLOR" ), vtkGN,
2345 LightApp_Preferences::Color, "VTKViewer", "group_names_text_color" );
2346 // .... -> transparency
2347 int transPref = pref->addPreference( tr( "PREF_GROUP_NAMES_TRANSPARENCY" ), vtkGN,
2348 LightApp_Preferences::DblSpin, "VTKViewer", "group_names_transparency" );
2349 pref->setItemProperty( "min", 0.0, transPref );
2350 pref->setItemProperty( "max", 1.0, transPref );
2351 pref->setItemProperty( "step", 0.1, transPref );
2352 // ... -> group names sub-group <<end>>
2353 // .. "VTK viewer" group <<end>>
2355 // .. "Plot2d viewer" group <<start>>
2356 int plot2dGroup = pref->addPreference( tr( "PREF_GROUP_PLOT2DVIEWER" ), salomeCat ); //viewTab
2357 //pref->setItemProperty( "columns", 2, plot2dGroup );
2359 // ... -> show legend
2360 pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dGroup,
2361 LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
2362 // ... -> legend position
2363 int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dGroup,
2364 LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
2365 aValuesList.clear();
2366 anIndicesList.clear();
2367 aValuesList << tr("PREF_LEFT") << tr("PREF_RIGHT") << tr("PREF_TOP") << tr("PREF_BOTTOM");
2368 anIndicesList << 0 << 1 << 2 << 3 ;
2369 pref->setItemProperty( "strings", aValuesList, legendPosition );
2370 pref->setItemProperty( "indexes", anIndicesList, legendPosition );
2371 // ... -> legend font
2372 pref->addPreference( tr( "PREF_LEGEND_FONT" ), plot2dGroup, LightApp_Preferences::Font, "Plot2d", "LegendFont" );
2373 // ... -> curve type
2374 int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dGroup,
2375 LightApp_Preferences::Selector, "Plot2d", "CurveType" );
2376 aValuesList.clear();
2377 anIndicesList.clear();
2378 aValuesList << tr("PREF_POINTS") << tr("PREF_LINES") << tr("PREF_SPLINE");
2379 anIndicesList << 0 << 1 << 2 ;
2380 pref->setItemProperty( "strings", aValuesList, curveType );
2381 pref->setItemProperty( "indexes", anIndicesList, curveType );
2382 // ... -> marker size
2383 int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dGroup,
2384 LightApp_Preferences::IntSpin, "Plot2d", "MarkerSize" );
2385 pref->setItemProperty( "min", 0, markerSize );
2386 pref->setItemProperty( "max", 100, markerSize );
2387 // ... -> horizontal scaling mode
2388 int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dGroup,
2389 LightApp_Preferences::Selector, "Plot2d", "HorScaleMode" );
2390 aValuesList.clear();
2391 anIndicesList.clear();
2392 aValuesList << tr("PREF_LINEAR") << tr("PREF_LOGARITHMIC");
2393 anIndicesList << 0 << 1 ;
2394 pref->setItemProperty( "strings", aValuesList, horScale );
2395 pref->setItemProperty( "indexes", anIndicesList, horScale );
2396 // ... -> vertical scaling mode
2397 int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dGroup,
2398 LightApp_Preferences::Selector, "Plot2d", "VerScaleMode" );
2399 pref->setItemProperty( "strings", aValuesList, verScale );
2400 pref->setItemProperty( "indexes", anIndicesList, verScale );
2401 // ... -> background
2402 pref->addPreference( tr( "PREF_VIEWER_BACKGROUND_COLOR" ), plot2dGroup,
2403 LightApp_Preferences::Color, "Plot2d", "Background" );
2404 // ... -> font color
2405 pref->addPreference( tr( "PREF_FONT_COLOR" ), plot2dGroup, LightApp_Preferences::Color, "Plot2d", "LegendFontColor" );
2406 // ... -> selection font color
2407 pref->addPreference( tr( "PREF_SELECTED_FONT_COLOR" ), plot2dGroup, LightApp_Preferences::Color, "Plot2d", "SelectedLegendFontColor" );
2408 // ... -> selection color
2409 pref->addPreference( tr( "PREF_VIEWER_SELECTION" ), plot2dGroup,
2410 LightApp_Preferences::Color, "Plot2d", "SelectionColor" );
2411 // ... -> errors/deviation colot
2412 pref->addPreference( tr( "PREF_DEVIATION_COLOR" ), plot2dGroup,
2413 LightApp_Preferences::Color, "Plot2d", "DeviationMarkerColor" );
2414 // ... -> deviation markers line size
2415 int deviationMarkerLw = pref->addPreference( tr( "PREF_DEVIATION_MARKER_LW" ), plot2dGroup,
2416 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerLineWidth" );
2417 pref->setItemProperty( "min", 1, deviationMarkerLw );
2418 pref->setItemProperty( "max", 5, deviationMarkerLw );
2419 // ... -> deviation markers tick mark size
2420 int deviationMarkerTs = pref->addPreference( tr( "PREF_DEVIATION_MARKER_TS" ), plot2dGroup,
2421 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerTickSize" );
2422 pref->setItemProperty( "min", 1, deviationMarkerTs );
2423 pref->setItemProperty( "max", 5, deviationMarkerTs );
2424 // .. "Plot2d viewer" group <<end>>
2426 // .. "Directories" preferences tab <<start>>
2427 int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat );
2428 // ... --> quick directories list
2429 int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab );
2430 pref->addPreference( tr( "" ), dirGroup,
2431 LightApp_Preferences::DirList, "FileDlg", "QuickDirList" );
2432 // .. "Directories" preferences tab <<end>>
2434 // .. "Object browser" preferences tab <<start>>
2435 int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
2437 // ... "Search tool" group <<start>>
2438 int stGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SEARCH_TOOL" ), obTab );
2439 // .... --> auto-hide
2440 pref->addPreference( tr( "PREF_AUTO_HIDE_SEARCH_TOOL" ), stGroup, LightApp_Preferences::Bool,
2441 "ObjectBrowser", "auto_hide_search_tool" );
2442 // ... "Search tool" group <<end>>
2444 // ... "Object browser settings" group <<start>>
2445 int objSetGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), obTab );
2446 pref->setItemProperty( "columns", 2, objSetGroup );
2447 // .... -> auto size first column
2448 pref->addPreference( tr( "PREF_AUTO_SIZE_FIRST" ), objSetGroup, LightApp_Preferences::Bool,
2449 "ObjectBrowser", "auto_size_first" );
2450 // .... -> auto size other columns
2451 pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool,
2452 "ObjectBrowser", "auto_size" );
2453 // .... -> resize columns on expand item
2454 pref->addPreference( tr( "PREF_RESIZE_ON_EXPAND_ITEM" ), objSetGroup, LightApp_Preferences::Bool,
2455 "ObjectBrowser", "resize_on_expand_item" );
2456 // .... -> browse to published object
2457 int browsePublished = pref->addPreference( tr( "PREF_BROWSE_TO_THE_PUBLISHED_OBJECT" ), objSetGroup, LightApp_Preferences::Selector,
2458 "ObjectBrowser", "browse_published_object" );
2459 aValuesList.clear();
2460 anIndicesList.clear();
2461 aValuesList << tr( "PREF_BROWSE_NEVER" ) << tr( "PREF_BROWSE_AFTER_APPLY_AND_CLOSE_ONLY" ) << tr( "PREF_BROWSE_ALWAYS" );
2462 anIndicesList << BP_Never << BP_ApplyAndClose << BP_Always;
2463 pref->setItemProperty( "strings", aValuesList, browsePublished );
2464 pref->setItemProperty( "indexes", anIndicesList, browsePublished );
2465 // ... "Object browser settings" group <<end>>
2466 // .. "Object browser" preferences tab <<end>>
2468 // .. "Shortcuts" preferences tab <<start>>
2469 int shortcutTab = pref->addPreference( tr( "PREF_TAB_SHORTCUTS" ), salomeCat );
2470 // ... "Shortcuts settings" group <<start>>
2471 int shortcutGroup = pref->addPreference( tr( "PREF_GROUP_SHORTCUTS" ), shortcutTab );
2472 pref->addPreference( tr( "" ), shortcutGroup,
2473 LightApp_Preferences::ShortcutTree, "shortcuts" );
2474 // ... "Shortcuts settings" group <<end>>
2475 // .. "Shortcuts" preferences tab <<end>>
2476 // . Top-level "SALOME" preferences group <<end>>
2482 Changes appearance of application according to changed preferences
2483 \param sec - section
2484 \param param - name of changed parameter
2486 void LightApp_Application::preferencesChanged( const QString& sec, const QString& param )
2488 SUIT_ResourceMgr* resMgr = resourceMgr();
2492 if ( sec == "viewers" && param == "drop_down_buttons" )
2494 ViewManagerList vmlist = viewManagers();
2495 foreach( SUIT_ViewManager* vm, vmlist )
2497 QVector<SUIT_ViewWindow*> vwlist = vm->getViews();
2498 foreach( SUIT_ViewWindow* vw, vwlist )
2499 if ( vw ) vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
2503 #ifndef DISABLE_OCCVIEWER
2504 if ( sec == QString( "OCCViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )))
2506 double sz = resMgr->doubleValue( sec, "trihedron_size", -1 );
2507 bool relative = resMgr->booleanValue( sec, "relative_size", true );
2508 QList<SUIT_ViewManager*> lst;
2509 viewManagers( OCCViewer_Viewer::Type(), lst );
2510 QListIterator<SUIT_ViewManager*> it( lst );
2511 while ( it.hasNext() && sz >= 0 )
2513 SUIT_ViewModel* vm = it.next()->getViewModel();
2514 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2517 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2518 occVM->setTrihedronSize( sz, relative );
2519 occVM->getAISContext()->UpdateCurrentViewer();
2524 #ifndef DISABLE_OCCVIEWER
2525 if ( sec == QString( "OCCViewer" ) && param == QString( "show_static_trihedron" ) )
2527 bool isVisible = resMgr->booleanValue( "OCCViewer", "show_static_trihedron", true );
2528 QList<SUIT_ViewManager*> lst;
2529 viewManagers( OCCViewer_Viewer::Type(), lst );
2530 QListIterator<SUIT_ViewManager*> it( lst );
2531 while ( it.hasNext() )
2533 SUIT_ViewModel* vm = it.next()->getViewModel();
2534 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2537 OCCViewer_Viewer* occVM = dynamic_cast<OCCViewer_Viewer*>( vm );
2540 occVM->setStaticTrihedronDisplayed( isVisible );
2546 #ifndef DISABLE_OCCVIEWER
2547 if ( sec == QString( "OCCViewer" ) && param == QString( "navigation_mode" ) )
2549 int mode = resMgr->integerValue( "OCCViewer", "navigation_mode", 0 );
2550 QList<SUIT_ViewManager*> lst;
2551 viewManagers( OCCViewer_Viewer::Type(), lst );
2552 QListIterator<SUIT_ViewManager*> it( lst );
2553 while ( it.hasNext() )
2555 SUIT_ViewModel* vm = it.next()->getViewModel();
2556 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2559 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2560 occVM->setInteractionStyle( mode );
2565 #ifndef DISABLE_OCCVIEWER
2566 if ( sec == QString( "OCCViewer" ) && param == QString( "zooming_mode" ) )
2568 int mode = resMgr->integerValue( "OCCViewer", "zooming_mode", 0 );
2569 QList<SUIT_ViewManager*> lst;
2570 viewManagers( OCCViewer_Viewer::Type(), lst );
2571 QListIterator<SUIT_ViewManager*> it( lst );
2572 while ( it.hasNext() )
2574 SUIT_ViewModel* vm = it.next()->getViewModel();
2575 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2578 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2579 occVM->setZoomingStyle( mode );
2584 #ifndef DISABLE_VTKVIEWER
2585 if ( sec == QString( "VTKViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )) )
2587 double sz = resMgr->doubleValue( "VTKViewer", "trihedron_size", -1 );
2588 bool isRelative = resMgr->booleanValue( "VTKViewer", "relative_size", true );
2589 QList<SUIT_ViewManager*> lst;
2590 #ifndef DISABLE_SALOMEOBJECT
2591 viewManagers( SVTK_Viewer::Type(), lst );
2592 QListIterator<SUIT_ViewManager*> it( lst );
2593 while ( it.hasNext() && sz >= 0 )
2595 SUIT_ViewModel* vm = it.next()->getViewModel();
2596 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2599 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2602 vtkVM->setTrihedronSize( sz, isRelative );
2610 #ifndef DISABLE_VTKVIEWER
2611 if ( sec == QString( "VTKViewer" ) && (param == QString( "speed_value" ) || param == QString( "speed_mode" )) )
2613 int speed = resMgr->integerValue( "VTKViewer", "speed_value", 10 );
2614 int mode = resMgr->integerValue( "VTKViewer", "speed_mode", 0 );
2615 QList<SUIT_ViewManager*> lst;
2616 #ifndef DISABLE_SALOMEOBJECT
2617 viewManagers( SVTK_Viewer::Type(), lst );
2618 QListIterator<SUIT_ViewManager*> it( lst );
2619 while ( it.hasNext() )
2621 SUIT_ViewModel* vm = it.next()->getViewModel();
2622 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2625 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2626 if( vtkVM ) vtkVM->setIncrementalSpeed( speed, mode );
2632 #ifndef DISABLE_VTKVIEWER
2633 if ( sec == QString( "VTKViewer" ) && param == QString( "projection_mode" ) )
2635 int mode = resMgr->integerValue( "VTKViewer", "projection_mode", 0 );
2636 QList<SUIT_ViewManager*> lst;
2637 #ifndef DISABLE_SALOMEOBJECT
2638 viewManagers( SVTK_Viewer::Type(), lst );
2639 QListIterator<SUIT_ViewManager*> it( lst );
2640 while ( it.hasNext() )
2642 SUIT_ViewModel* vm = it.next()->getViewModel();
2643 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2646 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2647 if( vtkVM ) vtkVM->setProjectionMode( mode );
2653 #ifndef DISABLE_VTKVIEWER
2654 if ( sec == QString( "VTKViewer" ) && param == QString( "navigation_mode" ) )
2656 int mode = resMgr->integerValue( "VTKViewer", "navigation_mode", 0 );
2657 QList<SUIT_ViewManager*> lst;
2658 #ifndef DISABLE_SALOMEOBJECT
2659 viewManagers( SVTK_Viewer::Type(), lst );
2660 QListIterator<SUIT_ViewManager*> it( lst );
2661 while ( it.hasNext() )
2663 SUIT_ViewModel* vm = it.next()->getViewModel();
2664 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2667 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2668 if( vtkVM ) vtkVM->setInteractionStyle( mode );
2674 #ifndef DISABLE_VTKVIEWER
2675 if ( sec == QString( "VTKViewer" ) && param == QString( "zooming_mode" ) )
2677 int mode = resMgr->integerValue( "VTKViewer", "zooming_mode", 0 );
2678 QList<SUIT_ViewManager*> lst;
2679 #ifndef DISABLE_SALOMEOBJECT
2680 viewManagers( SVTK_Viewer::Type(), lst );
2681 QListIterator<SUIT_ViewManager*> it( lst );
2682 while ( it.hasNext() )
2684 SUIT_ViewModel* vm = it.next()->getViewModel();
2685 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2688 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2689 if( vtkVM ) vtkVM->setZoomingStyle( mode );
2695 #ifndef DISABLE_VTKVIEWER
2696 if ( sec == QString( "VTKViewer" ) && param == QString( "dynamic_preselection" ) )
2698 bool mode = resMgr->booleanValue( "VTKViewer", "dynamic_preselection", true );
2699 QList<SUIT_ViewManager*> lst;
2700 #ifndef DISABLE_SALOMEOBJECT
2701 viewManagers( SVTK_Viewer::Type(), lst );
2702 QListIterator<SUIT_ViewManager*> it( lst );
2703 while ( it.hasNext() )
2705 SUIT_ViewModel* vm = it.next()->getViewModel();
2706 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2709 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2710 if( vtkVM ) vtkVM->setDynamicPreSelection( mode );
2716 #ifndef DISABLE_VTKVIEWER
2717 if ( sec == QString( "VTKViewer" ) && param == QString( "show_static_trihedron" ) )
2719 bool isVisible = resMgr->booleanValue( "VTKViewer", "show_static_trihedron", true );
2720 QList<SUIT_ViewManager*> lst;
2721 #ifndef DISABLE_SALOMEOBJECT
2722 viewManagers( SVTK_Viewer::Type(), lst );
2723 QListIterator<SUIT_ViewManager*> it( lst );
2724 while ( it.hasNext() )
2726 SUIT_ViewModel* vm = it.next()->getViewModel();
2727 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2730 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2733 vtkVM->setStaticTrihedronVisible( isVisible );
2741 #ifndef DISABLE_VTKVIEWER
2742 if ( sec == QString( "VTKViewer" ) && (param == QString( "spacemouse_func1_btn" ) ||
2743 param == QString( "spacemouse_func2_btn" ) ||
2744 param == QString( "spacemouse_func5_btn" ) ) )
2746 int btn1 = resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", 1 );
2747 int btn2 = resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", 2 );
2748 int btn3 = resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", 9 );
2749 QList<SUIT_ViewManager*> lst;
2750 #ifndef DISABLE_SALOMEOBJECT
2751 viewManagers( SVTK_Viewer::Type(), lst );
2752 QListIterator<SUIT_ViewManager*> it( lst );
2753 while ( it.hasNext() )
2755 SUIT_ViewModel* vm = it.next()->getViewModel();
2756 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2759 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2760 if( vtkVM ) vtkVM->setSpacemouseButtons( btn1, btn2, btn3 );
2766 #ifndef DISABLE_OCCVIEWER
2767 if ( sec == QString( "OCCViewer" ) && ( param == QString( "iso_number_u" ) || param == QString( "iso_number_v" ) ) )
2769 QList<SUIT_ViewManager*> lst;
2770 viewManagers( OCCViewer_Viewer::Type(), lst );
2771 int u = resMgr->integerValue( sec, "iso_number_u" );
2772 int v = resMgr->integerValue( sec, "iso_number_v" );
2773 QListIterator<SUIT_ViewManager*> it( lst );
2774 while ( it.hasNext() )
2776 OCCViewer_ViewManager* mgr = dynamic_cast<OCCViewer_ViewManager*>( it.next() );
2777 if( mgr && mgr->getOCCViewer() )
2778 mgr->getOCCViewer()->setIsos( u, v );
2783 if( sec=="ObjectBrowser" )
2785 SUIT_DataBrowser* ob = objectBrowser();
2789 if ( param=="auto_size_first" )
2791 bool autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
2792 ob->setAutoSizeFirstColumn( autoSizeFirst );
2793 if ( autoSizeFirst )
2794 ob->adjustFirstColumnWidth();
2796 else if ( param=="auto_size" ) {
2797 bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
2798 ob->setAutoSizeColumns(autoSize);
2800 ob->adjustColumnsWidth();
2802 else if ( param=="resize_on_expand_item" ) {
2803 bool resizeOnExpandItem = resMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
2804 ob->setResizeOnExpandItem(resizeOnExpandItem);
2806 else if ( param == "auto_hide_search_tool" ) {
2807 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
2813 if( param=="store_positions" )
2815 if( param=="auto_save_interval" ) {
2816 myAutoSaveTimer->stop();
2817 int autoSaveInterval = resMgr->integerValue( "Study", "auto_save_interval", 0 );
2818 if ( activeStudy() && autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
2822 #ifndef DISABLE_PYCONSOLE
2823 if( sec=="PyConsole" && pythonConsole() )
2825 if ( param=="font" ) {
2826 pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) );
2828 else if ( param=="show_banner" ) {
2829 pythonConsole()->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
2836 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
2838 if ( param == "visible_count" )
2839 mru->setVisibleCount( resMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
2840 else if ( param == "max_count" )
2841 mru->setHistoryCount( resMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
2842 else if ( param == "insert_mode" )
2843 mru->setInsertMode( resMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
2844 else if ( param == "link_type" )
2845 mru->setLinkType( resMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
2846 else if ( param == "show_clear" )
2847 mru->setClearPossible( resMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
2848 else if ( param == "show_mru" )
2849 mru->setVisible( resMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
2852 if ( sec == "language" && param == "language" )
2854 SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LANG_CHANGED" ) );
2856 if ( sec == "desktop" && param == "opaque_resize" ) {
2857 bool opaqueResize = resMgr->booleanValue( "desktop", "opaque_resize", false );
2858 QMainWindow::DockOptions dopts = desktop()->dockOptions();
2859 if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
2860 else dopts &= ~QMainWindow::AnimatedDocks;
2861 desktop()->setDockOptions( dopts );
2862 desktop()->setOpaqueResize( opaqueResize );
2863 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
2864 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
2867 if ( sec == "ExternalBrowser" && param == "use_external_browser" ) {
2868 if ( resMgr->booleanValue("ExternalBrowser", "use_external_browser", false ) )
2870 if(QtxWebBrowser::webBrowser())
2871 QtxWebBrowser::webBrowser()->close();
2875 #ifndef DISABLE_PLOT2DVIEWER
2876 if ( sec == "Plot2d" ) {
2877 if( param == "SelectionColor" ) {
2878 QColor c = resMgr->colorValue( sec, param );
2879 Plot2d_Object::setSelectionColor(c);
2881 else if (param == "SelectedLegendFontColor") {
2882 QColor c = resMgr->colorValue( sec, param );
2883 Plot2d_Object::setHighlightedLegendTextColor(c);
2892 void LightApp_Application::loadPreferences()
2894 CAM_Application::loadPreferences();
2896 SUIT_ResourceMgr* aResMgr = resourceMgr();
2901 static bool mru_load = true;
2904 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
2906 mru->setVisible( aResMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
2907 mru->setVisibleCount( aResMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
2908 mru->setHistoryCount( aResMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
2909 mru->setInsertMode( aResMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
2910 mru->setLinkType( aResMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
2911 mru->setClearPossible( aResMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
2912 mru->loadLinks( aResMgr, "MRU" );
2918 QStringList mods = aResMgr->parameters( "windows_geometry" );
2919 for ( QStringList::const_iterator it = mods.begin(); it != mods.end(); ++it )
2922 if ( aResMgr->value( "windows_geometry", *it, arr ) )
2923 myWinGeom.insert( *it, arr );
2927 mods = aResMgr->parameters( "windows_visibility" );
2928 for ( QStringList::const_iterator itr = mods.begin(); itr != mods.end(); ++itr )
2931 if ( aResMgr->value( "windows_visibility", *itr, arr ) )
2932 myWinVis.insert( *itr, arr );
2936 desktop()->retrieveGeometry( aResMgr->stringValue( "desktop", "geometry" ) );
2937 bool opaqueResize = aResMgr->booleanValue( "desktop", "opaque_resize", false );
2938 QMainWindow::DockOptions dopts = desktop()->dockOptions();
2939 if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
2940 else dopts &= ~QMainWindow::AnimatedDocks;
2941 desktop()->setDockOptions( dopts );
2942 desktop()->setOpaqueResize( opaqueResize );
2943 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
2944 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
2951 void LightApp_Application::savePreferences()
2953 CAM_Application::savePreferences();
2955 saveDockWindowsState();
2957 SUIT_ResourceMgr* aResMgr = resourceMgr();
2962 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
2964 mru->saveLinks( aResMgr, "MRU" );
2966 for ( WinGeom::const_iterator it = myWinGeom.begin(); it != myWinGeom.end(); ++it )
2967 aResMgr->setValue( "windows_geometry", it.key(), it.value() );
2969 for ( WinVis::const_iterator itr = myWinVis.begin(); itr != myWinVis.end(); ++itr )
2970 aResMgr->setValue( "windows_visibility", itr.key(), itr.value() );
2973 aResMgr->setValue( "desktop", "geometry", desktop()->storeGeometry() );
2979 Updates desktop title
2981 void LightApp_Application::updateDesktopTitle()
2983 QString aTitle = applicationName();
2984 QString aVer = applicationVersion();
2985 if ( !aVer.isEmpty() )
2986 aTitle += QString( " " ) + aVer;
2988 if ( activeStudy() ) {
2989 QString sName = SUIT_Tools::file( activeStudy()->studyName().trimmed(), false );
2990 aTitle += QString( " - [%1]" ).arg( sName );
2993 desktop()->setWindowTitle( aTitle );
2997 \brief Get map of the operations which can be performed
2998 on the module activation.
3000 The method should return the map of the kind \c {<id>:<name>}
3001 where \c <id> is an integer identifier of the operation and
3002 \c <name> is a title for the button to be added to the
3003 dialog box. After user selects the required operation by the
3004 clicking the corresponding button in the dialog box, its identifier
3005 is passed to the moduleActionSelected() method to process
3008 \return map of the operations
3009 \sa moduleActionSelected()
3011 QMap<int, QString> LightApp_Application::activateModuleActions() const
3013 QMap<int, QString> opmap;
3014 opmap.insert( NewStudyId, tr( "ACTIVATE_MODULE_OP_NEW" ) );
3015 opmap.insert( OpenStudyId, tr( "ACTIVATE_MODULE_OP_OPEN" ) );
3020 \brief Called when the used selectes required operation chosen
3021 from "Activate module" dialog box.
3023 Performs the required operation according to the user choice.
3025 \param id operation identifier
3026 \sa activateModuleActions()
3028 void LightApp_Application::moduleActionSelected( const int id )
3043 Updates windows after close document
3045 void LightApp_Application::afterCloseDoc()
3049 CAM_Application::afterCloseDoc();
3053 Updates actions of active module
3055 void LightApp_Application::updateModuleActions()
3058 if ( activeModule() ) {
3059 modName = activeModule()->moduleName();
3060 if ( !isModuleAccessible( modName ) ) {
3061 QList<SUIT_Application*> apps = SUIT_Session::session()->applications();
3062 foreach( SUIT_Application* app, apps ) {
3063 LightApp_Application* lapp = dynamic_cast<LightApp_Application*>( app );
3064 if ( lapp && lapp != this )
3065 lapp->removeModuleAction( modName );
3070 LightApp_ModuleAction* moduleAction =
3071 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
3073 moduleAction->setActiveModule( modName );
3076 void LightApp_Application::removeModuleAction( const QString& modName )
3078 LightApp_ModuleAction* moduleAction =
3079 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
3081 moduleAction->removeModule( modName );
3085 Gets current windows.
3086 \param winMap - output current windows map.
3088 void LightApp_Application::currentWindows( QMap<int, int>& winMap ) const
3091 if ( !activeStudy() )
3094 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
3095 ((LightApp_Module*)activeModule())->windows( winMap );
3097 defaultWindows( winMap );
3101 Gets current view managers.
3102 \param lst - output current view managers list.
3104 void LightApp_Application::currentViewManagers( QStringList& lst ) const
3107 if ( !activeStudy() )
3110 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
3111 ((LightApp_Module*)activeModule())->viewManagers( lst );
3113 defaultViewManagers( lst );
3119 void LightApp_Application::updateWindows()
3121 QMap<int, int> winMap;
3122 currentWindows( winMap );
3124 if ( activeStudy() )
3126 for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
3128 if ( !dockWindow( it.key() ) )
3129 getWindow( it.key() );
3133 for ( WinMap::ConstIterator it = myWin.begin(); it != myWin.end(); ++it )
3135 QWidget* wid = it.value();
3136 if ( activeStudy() )
3137 wid->setVisible( winMap.contains( it.key() ) );
3142 if ( activeStudy() )
3143 loadDockWindowsState();
3149 Updates view managers
3151 void LightApp_Application::updateViewManagers()
3154 currentViewManagers( lst );
3156 for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
3157 getViewManager( *it, true );
3161 Loads windows geometry
3163 void LightApp_Application::loadDockWindowsState()
3168 bool store = resourceMgr()->booleanValue( "Study", "store_positions", true );
3173 if ( activeModule() )
3174 modName = activeModule()->name();
3176 if ( myWinGeom.contains( modName ) )
3177 desktop()->restoreState( myWinGeom[modName] );
3179 if ( !myWinVis.contains( modName ) )
3182 QMap<QString, bool> tbMap, dwMap;
3183 dockWindowsState( myWinVis[modName], tbMap, dwMap );
3185 QList<QToolBar*> tbList = qFindChildren<QToolBar*>( desktop() );
3186 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit )
3188 QToolBar* tb = *tit;
3190 QObject* po = Qtx::findParent( tb, "QMainWindow" );
3191 if ( po != desktop() )
3194 if ( tbMap.contains( tb->objectName() ) )
3195 tb->setVisible( tbMap[tb->objectName()] );
3198 QList<QDockWidget*> dwList = qFindChildren<QDockWidget*>( desktop() );
3199 for ( QList<QDockWidget*>::iterator dit = dwList.begin(); dit != dwList.end(); ++dit )
3201 QDockWidget* dw = *dit;
3203 QObject* po = Qtx::findParent( dw, "QMainWindow" );
3204 if ( po != desktop() )
3207 if ( dwMap.contains( dw->objectName() ) )
3208 dw->setVisible( dwMap[dw->objectName()] );
3213 Saves windows geometry
3215 void LightApp_Application::saveDockWindowsState()
3220 bool store = resourceMgr()->booleanValue( "Study", "store_positions", true );
3225 if ( activeModule() )
3226 modName = activeModule()->name();
3228 myWinGeom.insert( modName, desktop()->saveState() );
3231 if ( myWinVis.contains( modName ) )
3232 visArr = myWinVis[modName];
3234 QMap<QString, bool> tbMap, dwMap;
3235 dockWindowsState( visArr, tbMap, dwMap );
3237 QList<QToolBar*> tbList = qFindChildren<QToolBar*>( desktop() );
3238 for ( QList<QToolBar*>::iterator it = tbList.begin(); it != tbList.end(); ++it )
3241 tbMap.insert( tb->objectName(), tb->toggleViewAction()->isChecked() );
3244 QList<QDockWidget*> dwList = qFindChildren<QDockWidget*>( desktop() );
3245 for ( QList<QDockWidget*>::iterator it = dwList.begin(); it != dwList.end(); ++it )
3247 QDockWidget* wid = *it;
3248 dwMap.insert( wid->objectName(), wid->toggleViewAction()->isChecked() );
3251 visArr = dockWindowsState( tbMap, dwMap );
3253 myWinVis.insert( modName, visArr );
3256 QByteArray LightApp_Application::dockWindowsState( const QMap<QString, bool>& tb, const QMap<QString, bool>& dw ) const
3259 QDataStream stream( &visArr, QIODevice::WriteOnly );
3261 stream << (uchar)ToolBarMarker;
3262 stream << tb.size();
3263 for ( QMap<QString, bool>::const_iterator tit = tb.begin(); tit != tb.end(); ++tit )
3265 stream << tit.key();
3266 stream << (uchar)( tit.value() ? 1 : 0 );
3269 stream << (uchar)DockWidgetMarker;
3270 stream << dw.size();
3271 for ( QMap<QString, bool>::const_iterator wit = dw.begin(); wit != dw.end(); ++wit )
3273 stream << wit.key();
3274 stream << (uchar)( wit.value() ? 1 : 0 );
3280 void LightApp_Application::dockWindowsState( const QByteArray& arr, QMap<QString, bool>& tb, QMap<QString, bool>& dw ) const
3285 QByteArray visArr = arr;
3286 QDataStream stream( &visArr, QIODevice::ReadOnly );
3290 if ( marker != ToolBarMarker )
3295 for ( int i = 0; i < lines; ++i )
3298 stream >> objectName;
3301 tb.insert( objectName, shown );
3305 if ( marker != DockWidgetMarker )
3309 for ( int j = 0; j < lines; ++j )
3312 stream >> objectName;
3315 dw.insert( objectName, shown );
3320 Adds icon names for modules
3322 void LightApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) const
3326 SUIT_ResourceMgr* resMgr = resourceMgr();
3330 QStringList modList;
3331 modules( modList, false );
3333 for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )
3335 QString modName = *it;
3336 QString modIntr = moduleName( modName );
3337 QString modIcon = resMgr->stringValue( modIntr, "icon", QString() );
3339 if ( modIcon.isEmpty() )
3342 if ( SUIT_Tools::extension( modIcon ).isEmpty() )
3343 modIcon += QString( ".png" );
3345 iconMap.insert( modName, modIcon );
3350 Inserts items in popup, which necessary for current application
3352 void LightApp_Application::contextMenuPopup( const QString& type, QMenu* thePopup, QString& title )
3355 LightApp_SelectionMgr* selMgr = LightApp_Application::selectionMgr();
3356 bool cacheIsOn = selMgr->isSelectionCacheEnabled();
3357 selMgr->setSelectionCacheEnabled( true );
3359 SUIT_DataBrowser* ob = objectBrowser();
3361 CAM_Application::contextMenuPopup( type, thePopup, title );
3363 if ( ob && type == ob->popupClientType() ) {
3364 thePopup->addSeparator();
3365 QAction* a = thePopup->addAction( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
3366 if ( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) )
3367 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) );
3370 if ( selMgr && ob ) {
3371 SALOME_ListIO selected;
3372 selMgr->selectedObjects( selected );
3373 if(selected.Extent() == 1){
3374 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3375 SUIT_DataObject* obj = findObject(anIObject->getEntry());
3376 if(obj && obj->renameAllowed()) {
3377 QAction* a = new QAction(tr("MEN_RENAME_OBJ"), thePopup);
3378 connect( a, SIGNAL( triggered(bool) ), ob, SLOT( onStartEditing() ) );
3379 if ( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) )
3380 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) );
3382 QList<QAction*> acts = thePopup->actions();
3383 QAction* firstAction = acts.count() > 0 ? acts.first() : 0;
3384 thePopup->insertAction(firstAction,a);
3389 selMgr->setSelectionCacheEnabled( cacheIsOn );
3395 void LightApp_Application::createEmptyStudy()
3397 CAM_Application::createEmptyStudy();
3399 if ( objectBrowser() )
3400 objectBrowser()->updateTree();
3402 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
3403 if ( aResMgr && activeStudy() ) {
3404 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
3405 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
3410 void LightApp_Application::setDesktop( SUIT_Desktop* desk )
3412 CAM_Application::setDesktop( desk );
3415 connect( desk, SIGNAL( message( const QString& ) ),
3416 this, SLOT( onDesktopMessage( const QString& ) ), Qt::UniqueConnection );
3422 \param mod - module to be activated
3424 bool LightApp_Application::activateModule( CAM_Module* mod )
3426 bool res = CAM_Application::activateModule( mod );
3428 if ( objectBrowser() )
3429 objectBrowser()->updateTree();
3435 \return keyborad accelerators manager object
3437 SUIT_Accel* LightApp_Application::accel() const
3443 Removes dead widget container from map
3445 void LightApp_Application::onWCDestroyed( QObject* ob )
3447 // remove destroyed widget container from windows map
3448 for ( WinMap::ConstIterator itr = myWin.begin(); itr != myWin.end(); ++itr )
3450 if ( itr.value() != ob )
3453 int key = itr.key();
3454 myWin.remove( key );
3459 void LightApp_Application::onMRUActivated( const QString& name )
3461 SUIT_Session* s = SUIT_Session::session();
3462 if ( s && s->activeApplication() == this )
3466 void LightApp_Application::onStylePreferences()
3468 Style_PrefDlg dlg( desktop() );
3471 resourceMgr()->setValue( "Style", "use_salome_style", Style_Salome::isActive() );
3474 void LightApp_Application::onFullScreen(){
3475 if(myScreenHelper) {
3476 if(desktop()->isFullScreen())
3477 myScreenHelper->switchToNormalScreen();
3479 myScreenHelper->switchToFullScreen();
3484 Connects just added view manager
3486 void LightApp_Application::addViewManager( SUIT_ViewManager* vm )
3488 connect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
3489 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
3490 STD_Application::addViewManager( vm );
3494 Remove view manager from memory
3496 void LightApp_Application::removeViewManager( SUIT_ViewManager* vm )
3498 disconnect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
3499 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
3500 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
3502 aStudy->removeViewMgr(vm->getGlobalId());
3504 STD_Application::removeViewManager( vm );
3506 // IPAL22894: Crash on closing OCC view
3512 Renames active window of desktop
3514 void LightApp_Application::onRenameWindow()
3519 QWidget* w = desktop()->activeWindow();
3524 QString name = QInputDialog::getText( w, tr( "TOT_RENAME" ), tr( "PRP_RENAME" ), QLineEdit::Normal, w->windowTitle(), &ok );
3525 if( ok && !name.isEmpty() )
3526 w->setWindowTitle( name );
3530 Closes active window of desktop
3532 void LightApp_Application::onCloseWindow()
3537 QWidget* w = desktop()->activeWindow();
3545 Closes all windows of desktop
3547 void LightApp_Application::onCloseAllWindow()
3549 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
3553 QList<SUIT_ViewWindow*> wndList = desk->windows();
3554 SUIT_ViewWindow* wnd;
3555 foreach( wnd, wndList )
3563 Groups all windows of desktop
3565 void LightApp_Application::onGroupAllWindow()
3567 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
3571 QtxWorkstack* wgStack = desk->workstack();
3577 \return if the library of module exists
3578 \param moduleTitle - title of module
3580 bool LightApp_Application::isLibExists( const QString& moduleTitle ) const
3582 if( moduleTitle.isEmpty() )
3585 QString lib = moduleLibrary( moduleTitle );
3587 //abd: changed libSalomePyQtGUI to SalomePyQtGUI for WIN32
3588 bool isPythonModule = lib.contains("SalomePyQtGUI");
3589 bool isPythonLightModule = lib.contains("libSalomePyQtGUILight");
3593 paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
3595 paths = QString(::getenv( "LD_LIBRARY_PATH" )).split( ":", QString::SkipEmptyParts );
3598 bool isLibFound = false;
3599 QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
3600 for( ; anIt!=aLast; anIt++ )
3602 QFileInfo inf( Qtx::addSlash( *anIt ) + lib );
3613 INFOS( "****************************************************************" << std::endl
3614 << "* Warning: library " << lib.toLatin1().constData() << " cannot be found" << std::endl
3615 << "* Module " << moduleTitle.toLatin1().constData() << " will not be available in GUI mode" << std::endl
3616 << "****************************************************************" << std::endl );
3618 else if ( !isPythonModule && !isPythonLightModule)
3621 if ( isPythonModule || isPythonLightModule)
3623 QString pylib = moduleName( moduleTitle ) + QString(".py");
3624 QString pylibgui = moduleName( moduleTitle ) + QString("GUI.py");
3626 // Check the python library
3628 paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
3630 paths = QString(::getenv( "PYTHONPATH" )).split( ":", QString::SkipEmptyParts );
3632 bool isPyLib = false, isPyGuiLib = false;
3633 QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
3634 for( ; anIt!=aLast; anIt++ )
3636 QFileInfo inf( Qtx::addSlash( *anIt ) + pylib );
3637 QFileInfo infgui( Qtx::addSlash( *anIt ) + pylibgui );
3639 if(!isPythonLightModule)
3640 if( !isPyLib && inf.exists() )
3643 if( !isPyGuiLib && infgui.exists() )
3646 if ((isPyLib || isPythonLightModule ) && isPyGuiLib && isLibFound)
3650 printf( "****************************************************************\n" );
3651 printf( "* Warning: python library for %s cannot be found:\n", moduleTitle.toLatin1().constData() );
3653 printf( "* No module named %s\n", moduleName( moduleTitle ).toLatin1().constData() );
3655 printf( "* No module named %s\n", (moduleName( moduleTitle ) + QString("GUI")).toLatin1().constData() );
3656 printf( "****************************************************************\n" );
3663 \return default name for an active study
3665 void LightApp_Application::setDefaultStudyName( const QString& theName )
3667 QStringList anInfoList;
3668 modules( anInfoList, false );
3670 LightApp_Study* aStudy = (LightApp_Study*)activeStudy();
3671 if( anInfoList.count() == 1 && // to avoid a conflict between different modules
3672 !aStudy->isSaved() )
3674 aStudy->setStudyName( theName );
3675 updateDesktopTitle();
3680 Custom event handler
3682 bool LightApp_Application::event( QEvent* e )
3684 if( e && e->type()==2000 )
3686 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
3687 QString* d = ( QString* )ce->data();
3688 if( SUIT_MessageBox::question(0, tr("WRN_WARNING"),
3690 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
3691 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
3692 showPreferences( tr( "PREF_APP" ) );
3697 return CAM_Application::event( e );
3700 /*! Check data object */
3701 bool LightApp_Application::checkDataObject(LightApp_DataObject* theObj)
3705 bool isSuitable = !theObj->entry().isEmpty() &&
3706 !theObj->componentDataType().isEmpty() &&
3707 !theObj->name().isEmpty();
3714 int LightApp_Application::openChoice( const QString& aName )
3716 int choice = CAM_Application::openChoice( aName );
3718 if ( choice == OpenExist ) // The document is already open.
3720 // Do you want to reload it?
3721 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "QUE_DOC_ALREADYOPEN" ).arg( aName ),
3722 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No ) == SUIT_MessageBox::Yes )
3723 choice = OpenReload;
3729 bool LightApp_Application::openAction( const int choice, const QString& aName )
3736 STD_Application* app = 0;
3737 SUIT_Session* session = SUIT_Session::session();
3738 QList<SUIT_Application*> appList = session->applications();
3739 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !app; ++it )
3741 if ( (*it)->activeStudy() && (*it)->activeStudy()->studyName() == aName )
3742 app = ::qobject_cast<STD_Application*>( *it );
3747 app->onCloseDoc( false );
3748 appList = session->applications();
3749 STD_Application* other = 0;
3750 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !other; ++it )
3751 other = ::qobject_cast<STD_Application*>( *it );
3754 res = other->onOpenDoc( aName );
3759 res = CAM_Application::openAction( choice, aName );
3766 QStringList LightApp_Application::viewManagersTypes() const
3768 QStringList aTypesList;
3769 aTypesList += myUserWmTypes;
3770 #ifndef DISABLE_GLVIEWER
3771 aTypesList<<GLViewer_Viewer::Type();
3773 #ifndef DISABLE_PLOT2DVIEWER
3774 aTypesList<<Plot2d_Viewer::Type();
3776 #ifndef DISABLE_QXGRAPHVIEWER
3777 aTypesList<<QxScene_Viewer::Type();
3779 #ifndef DISABLE_OCCVIEWER
3780 aTypesList<<OCCViewer_Viewer::Type();
3782 #ifndef DISABLE_VTKVIEWER
3783 #ifndef DISABLE_SALOMEOBJECT
3784 aTypesList<<SVTK_Viewer::Type();
3786 aTypesList<<VTKViewer_Viewer::Type();
3792 * Removes all view managers of known types
3793 * Other view managers are ignored
3795 void LightApp_Application::clearKnownViewManagers()
3797 QStringList aTypesList = viewManagersTypes();
3798 QList<SUIT_ViewManager*> aMgrList;
3799 viewManagers( aMgrList );
3800 foreach (SUIT_ViewManager* aMgr, aMgrList) {
3801 if (aTypesList.contains(aMgr->getType()))
3802 removeViewManager(aMgr);
3807 Copy of current selection
3809 void LightApp_Application::onCopy()
3811 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
3817 Paste of current data in clipboard
3819 void LightApp_Application::onPaste()
3821 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
3827 Browse (i.e. set focus on) the published objects
3828 \param theIsApplyAndClose - flag indicating that the dialog for creating objects
3829 has been accepted by Ok (or Apply & Close) button
3830 \param theIsOptimizedBrowsing - flag switching to optimized browsing mode
3831 (to select the first published object only)
3832 \return entry of the selected object
3834 QString LightApp_Application::browseObjects( const QStringList& theEntryList,
3835 const bool theIsApplyAndClose,
3836 const bool theIsOptimizedBrowsing )
3839 if( SUIT_ResourceMgr* aResourceMgr = resourceMgr() )
3841 int aBrowsePolicy = aResourceMgr->integerValue( "ObjectBrowser", "browse_published_object", (int)BP_Never );
3842 switch( aBrowsePolicy )
3846 case BP_ApplyAndClose:
3847 if( !theIsApplyAndClose )
3855 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
3859 SUIT_DataBrowser* anOB = objectBrowser();
3863 SUIT_AbstractModel* aModel = dynamic_cast<SUIT_AbstractModel*>( anOB->model() );
3867 QStringListIterator anIter( theEntryList );
3868 if( theIsOptimizedBrowsing )
3870 // go to the last entry
3872 if( anIter.hasPrevious() )
3876 // scroll to each entry in the list
3877 // (in optimized mode - to the last entry only)
3879 LightApp_DataObject* anObject;
3880 while( anIter.hasNext() )
3882 anEntry = anIter.next();
3883 if( !anEntry.isEmpty() )
3885 anObject = aStudy->findObjectByEntry( anEntry );
3888 QModelIndex anIndex = aModel->index( anObject );
3889 anOB->treeView()->scrollTo( anIndex );
3894 // always select the last object
3895 if( anObject && !anEntry.isEmpty() )
3897 QList<SUIT_Selector*> aSelectorList;
3898 selectionMgr()->selectors( "ObjectBrowser", aSelectorList );
3899 if( !aSelectorList.isEmpty() )
3901 if( LightApp_OBSelector* aSelector = dynamic_cast<LightApp_OBSelector*>( aSelectorList.first() ) )
3903 bool anIsAutoBlock = aSelector->autoBlock();
3905 // temporarily disable auto block, to emit LightApp_SelectionMgr::currentSelectionChanged() signal
3906 aSelector->setAutoBlock( false );
3908 SUIT_DataOwnerPtrList aList;
3909 #ifndef DISABLE_SALOMEOBJECT
3910 Handle(SALOME_InteractiveObject) aSObj = new SALOME_InteractiveObject
3911 ( anObject->entry().toLatin1().constData(),
3912 anObject->componentDataType().toLatin1().constData(),
3913 anObject->name().toLatin1().constData() );
3914 LightApp_DataOwner* owner = new LightApp_DataOwner( aSObj );
3916 LightApp_DataOwner* owner = new LightApp_DataOwner( anEntry );
3919 aList.append( owner );
3920 selectionMgr()->setSelected( aList );
3923 // restore auto block flag
3924 aSelector->setAutoBlock( anIsAutoBlock );
3932 SUIT_DataObject* LightApp_Application::findObject( const QString& id ) const
3934 LightApp_Study* study = dynamic_cast<LightApp_Study*>( activeStudy() );
3935 return study ? study->findObjectByEntry( id ) : 0;
3939 Checks that an object can be renamed.
3940 \param entry entry of the object
3941 \brief Return \c true if object can be renamed
3943 bool LightApp_Application::renameAllowed( const QString& /*entry*/) const {
3948 Rename object by entry.
3949 \param entry entry of the object
3950 \param name new name of the object
3951 \brief Return \c true if rename operation finished successfully, \c false otherwise.
3953 bool LightApp_Application::renameObject( const QString& entry, const QString& ) {
3957 /*! Process standard messages from desktop */
3958 void LightApp_Application::onDesktopMessage( const QString& message )
3960 const QString sectionSeparator = "/";
3962 if ( message.toLower() == "updateobjectbrowser" ||
3963 message.toLower() == "updateobjbrowser" ) {
3964 // update object browser
3965 updateObjectBrowser();
3968 QStringList data = message.split( sectionSeparator );
3969 if ( data.count() > 1 ) {
3970 QString msgType = data[0].trimmed();
3971 LightApp_Module* sMod = 0;
3972 CAM_Module* mod = module( msgType );
3974 mod = module( moduleTitle( msgType ) );
3975 if ( mod && mod->inherits( "LightApp_Module" ) )
3976 sMod = (LightApp_Module*)mod;
3978 if ( msgType.toLower() == "preferences" ) {
3979 // requested preferences change: should be given as "preferences/<section>/<name>/<value>"
3980 // for example "preferences/Study/multi_file_dump/true"
3981 if ( data.count() > 3 ) {
3982 QString section = data[1].trimmed();
3983 QString param = data[2].trimmed();
3984 QString value = QStringList( data.mid(3) ).join( sectionSeparator );
3985 resourceMgr()->setValue( section, param, value );
3989 // received message for the module
3990 QString msg = QStringList( data.mid(1) ).join( sectionSeparator );
3991 sMod->message( msg );