1 // Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File: LightApp_Application.cxx
24 // Created: 6/20/2005 18:39:45 PM
25 // Author: Natalia Donis
28 // E.A. : On windows with python 2.6, there is a conflict
29 // E.A. : between pymath.h and Standard_math.h which define
30 // E.A. : some same symbols : acosh, asinh, ...
31 #include <Standard_math.hxx>
32 #ifndef DISABLE_PYCONSOLE
37 #ifndef DISABLE_PYCONSOLE
38 #include "PyConsole_Interp.h"
39 #include "LightApp_PyEditor.h"
40 #include "PyConsole_Console.h"
43 #include "LightApp_Application.h"
44 #include "LightApp_Module.h"
45 #include "LightApp_DataModel.h"
46 #include "LightApp_DataOwner.h"
47 #include "LightApp_Displayer.h"
48 #include "LightApp_Study.h"
49 #include "LightApp_Preferences.h"
50 #include "LightApp_PreferencesDlg.h"
51 #include "LightApp_ModuleDlg.h"
52 #include "LightApp_AboutDlg.h"
53 #include "LightApp_ModuleAction.h"
54 // temporary commented
55 #include "LightApp_EventFilter.h"
56 #include "LightApp_OBSelector.h"
57 #include "LightApp_SelectionMgr.h"
58 #include "LightApp_DataObject.h"
59 #include "LightApp_WgViewModel.h"
60 #include "LightApp_FullScreenHelper.h"
62 #include <GUI_version.h>
64 #include <SALOME_Event.h>
66 #ifdef USE_SALOME_STYLE
67 #include <Style_Salome.h>
68 #include <Style_PrefDlg.h>
69 #endif // USE_SALOME_STYLE
71 #include <CAM_Module.h>
72 #include <CAM_DataModel.h>
73 #include <CAM_Study.h>
74 #include <STD_TabDesktop.h>
76 #include <SUIT_DataBrowser.h>
77 #include <SUIT_Session.h>
78 #include <SUIT_Study.h>
79 #include <SUIT_FileDlg.h>
80 #include <SUIT_ResourceMgr.h>
81 #include <SUIT_ShortcutMgr.h>
82 #include <SUIT_Tools.h>
83 #include <SUIT_Accel.h>
84 #include <SUIT_MessageBox.h>
85 #include <SUIT_ViewWindow.h>
88 #include <QtxFontEdit.h>
89 #include <QtxToolBar.h>
90 #include <QtxTreeView.h>
91 #include <QtxInfoPanel.h>
92 #include <QtxMRUAction.h>
93 #include <QtxDockAction.h>
94 #include <QtxDockWidget.h>
95 #include <QtxActionToolMgr.h>
96 #include <QtxSearchTool.h>
97 #include <QtxWorkstack.h>
100 #include <LogWindow.h>
102 #ifndef DISABLE_GLVIEWER
103 #include <GLViewer_Viewer.h>
104 #include <GLViewer_ViewManager.h>
105 #include "LightApp_GLSelector.h"
108 #ifndef DISABLE_PLOT2DVIEWER
109 #include <Plot2d_ViewManager.h>
110 #include <Plot2d_ViewModel.h>
111 #include <Plot2d_ViewWindow.h>
112 #include <Plot2d_ViewFrame.h>
113 #include "LightApp_Plot2dSelector.h"
114 #ifndef DISABLE_SALOMEOBJECT
115 #include <SPlot2d_ViewModel.h>
117 #include <Plot2d_ViewModel.h>
121 #ifndef DISABLE_OCCVIEWER
122 #include <OCCViewer_ViewManager.h>
123 #include <OCCViewer_ViewFrame.h>
124 #include <OCCViewer_ViewPort3d.h>
125 #ifndef DISABLE_SALOMEOBJECT
126 #include <SOCC_ViewModel.h>
128 #include <OCCViewer_ViewModel.h>
130 #include "LightApp_OCCSelector.h"
133 #ifndef DISABLE_VTKVIEWER
134 #ifndef DISABLE_SALOMEOBJECT
135 #include <SVTK_ViewModel.h>
136 #include <SVTK_ViewManager.h>
137 #include "LightApp_VTKSelector.h"
139 #include <VTKViewer_ViewModel.h>
140 #include <VTKViewer_ViewManager.h>
142 #include <VTKViewer_ViewModel.h>
145 #ifndef DISABLE_QXGRAPHVIEWER
146 #include <QxScene_ViewManager.h>
147 #include <QxScene_ViewModel.h>
148 #include <QxScene_ViewWindow.h>
151 #ifndef DISABLE_GRAPHICSVIEW
152 #include "GraphicsView_Viewer.h"
153 #include "GraphicsView_ViewManager.h"
154 #include "LightApp_GVSelector.h"
157 #ifndef DISABLE_PVVIEWER
158 #include "PVViewer_ViewManager.h"
159 #include "PVViewer_ViewWindow.h"
160 #include "PVViewer_ViewModel.h"
163 #ifndef DISABLE_PYVIEWER
164 #include <PyViewer_ViewManager.h>
165 #include <PyViewer_ViewModel.h>
166 #include <PyViewer_ViewWindow.h>
170 #define VISIBILITY_COLUMN_WIDTH 25
176 #include <QStringList>
178 #include <QApplication>
180 #include <QStatusBar>
182 #include <QObjectList>
184 #include <QInputDialog>
185 #include <QFontDatabase>
187 #include <QByteArray>
191 #include <QHeaderView>
197 #include <utilities.h>
199 #define FIRST_HELP_ID 1000000
200 #define HAS_WWW_URL true
201 #define HAS_FORUM_URL true
202 #define HAS_YOUTUBE_URL true
203 #define HAS_TUTORIAL_URL false
205 #ifndef DISABLE_SALOMEOBJECT
206 #include <SALOME_InteractiveObject.hxx>
207 #include <SALOME_ListIO.hxx>
210 #include <Standard_Version.hxx>
212 #define ToolBarMarker 0
213 #define DockWidgetMarker 1
215 static const char* imageEmptyIcon[] = {
218 "....................",
219 "....................",
220 "....................",
221 "....................",
222 "....................",
223 "....................",
224 "....................",
225 "....................",
226 "....................",
227 "....................",
228 "....................",
229 "....................",
230 "....................",
231 "....................",
232 "....................",
233 "....................",
234 "....................",
235 "....................",
236 "....................",
237 "...................."};
239 // Markers used to parse array with dockable windows and toolbars state.
240 // For more details please see the qdockarealayout.cpp && qtoolbararealayout.cpp
241 // in the Qt source code.
243 #define QDockWidgetMarker 0xfd // = DockWidgetStateMarker
244 #define QToolBarMarker 0xfc // = ToolBarStateMarkerEx
246 // Format of the Byte array with the windows and toolbar state is:
247 // VersionMarker|version|DockWidgetStateMarker|nbDockWidgetLines|...DocWidgetData...|ToolBarStateMarkerEx|nbToolBarLines|...ToolBarData...
249 //Find toolbar marker position in the array in the following way:
250 //since the 'toolbar marker' is not unique, find index of first occurrence of the
251 //'toolbar marker' in the array and check that next string is name of the toolbar
253 void LightAppCleanUpAppResources()
255 if ( LightApp_Application::_prefs_ ) {
256 delete LightApp_Application::_prefs_;
257 LightApp_Application::_prefs_ = 0;
263 int getToolbarMarkerIndex( QByteArray input, const QStringList& aFlags ) {
264 int aResult = -1,tmp = 0;
265 int inputLen = input.length();
266 QDataStream anInputData( &input, QIODevice::ReadOnly );
267 while ( tmp < inputLen ) {
268 tmp = input.indexOf( (uchar)QToolBarMarker, tmp + 1 );
271 anInputData.device()->seek( tmp );
275 anInputData >> lines;
277 if ( lines == 0 && anInputData.atEnd() ) {
278 //Case then array doesn't contain information about toolbars,
289 if ( aFlags.contains( str ) ) {
297 QString langToName( const QString& lang )
299 // special processing for English language to avoid such result as "American English"
300 // as Qt cannot just say "English"
305 result = QLocale( lang ).nativeLanguageName();
309 QString getHelpItem( const QString& section, const QString& parameter, const QString& root = QString() )
311 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
312 foreach( QString item, resMgr->stringValue( section, parameter ).split( ";;", QString::SkipEmptyParts ) )
314 if ( item.startsWith( "http", Qt::CaseInsensitive ) )
317 path.remove( QRegExp( "#.*$" ) );
318 QFileInfo fi( path );
319 if ( fi.isRelative() && !root.isEmpty() )
320 path = Qtx::addSlash( root ) + path;
321 if ( QFile::exists( path ) )
327 const bool HAS_SALOME_ON_DEMAND =
328 #if defined(WITH_SALOME_ON_DEMAND)
335 /*!Create new instance of LightApp_Application.*/
336 extern "C" LIGHTAPP_EXPORT SUIT_Application* createApplication()
338 return new LightApp_Application();
341 /*! \var global preferences of LightApp */
342 LightApp_Preferences* LightApp_Application::_prefs_ = 0;
346 \class LightApp_Application
347 Application containing LightApp module
351 LightApp_Application::LightApp_Application()
352 : CAM_Application( false ),
354 myScreenHelper(new LightApp_FullScreenHelper())
356 Q_INIT_RESOURCE( LightApp );
358 STD_TabDesktop* desk = new STD_TabDesktop();
359 desk->setFullScreenAllowed(false);
360 desk->setMinimizeAllowed(false);
364 // initialize auto save timer
365 myAutoSaveTimer = new QTimer( this );
366 myAutoSaveTimer->setSingleShot( true );
367 connect( myAutoSaveTimer, SIGNAL( timeout() ), this, SLOT( onSaveDoc() ) );
369 //connect( this, SIGNAL( moving() ), this, SLOT( onMoved() ) );
371 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
372 QPixmap aLogo = aResMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
374 desktop()->setWindowIcon( aLogo );
375 desktop()->setDockableMenuBar( false );
376 desktop()->setDockableStatusBar( false );
378 // base logo (salome itself)
379 desktop()->logoInsert( "_app_base", aResMgr->loadPixmap( "LightApp", tr( "APP_BASE_LOGO" ), false ) );
380 // extra logo (salome-based application)
381 desktop()->logoInsert( "_app_extra", aResMgr->loadPixmap( "LightApp", tr( "APP_EXTRA_LOGO" ), false ) );
385 mySelMgr = new LightApp_SelectionMgr( this );
387 myAccel = SUIT_Accel::getAccel();
389 #ifndef DISABLE_OCCVIEWER
390 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, OCCViewer_Viewer::Type() );
391 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, OCCViewer_Viewer::Type() );
392 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, OCCViewer_Viewer::Type() );
393 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, OCCViewer_Viewer::Type() );
394 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, OCCViewer_Viewer::Type() );
395 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, OCCViewer_Viewer::Type() );
396 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, OCCViewer_Viewer::Type() );
397 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, OCCViewer_Viewer::Type() );
398 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, OCCViewer_Viewer::Type() );
399 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, OCCViewer_Viewer::Type() );
400 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, OCCViewer_Viewer::Type() );
401 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, OCCViewer_Viewer::Type() );
403 #ifndef DISABLE_VTKVIEWER
404 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, VTKViewer_Viewer::Type() );
405 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, VTKViewer_Viewer::Type() );
406 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, VTKViewer_Viewer::Type() );
407 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, VTKViewer_Viewer::Type() );
408 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, VTKViewer_Viewer::Type() );
409 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, VTKViewer_Viewer::Type() );
410 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, VTKViewer_Viewer::Type() );
411 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, VTKViewer_Viewer::Type() );
412 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, VTKViewer_Viewer::Type() );
413 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, VTKViewer_Viewer::Type() );
414 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, VTKViewer_Viewer::Type() );
415 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, VTKViewer_Viewer::Type() );
417 #ifndef DISABLE_PLOT2DVIEWER
418 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, Plot2d_Viewer::Type() );
419 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, Plot2d_Viewer::Type() );
420 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, Plot2d_Viewer::Type() );
421 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, Plot2d_Viewer::Type() );
422 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, Plot2d_Viewer::Type() );
423 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, Plot2d_Viewer::Type() );
424 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, Plot2d_Viewer::Type() );
425 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, Plot2d_Viewer::Type() );
428 connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) );
429 connect( desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
430 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
431 connect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
432 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ), Qt::UniqueConnection );
435 // Set existing font for the python console in resources
436 if( !aResMgr->hasValue( "PyConsole", "font" ) )
439 QFont f = aResMgr->fontValue( "PyConsole", "font" );
441 QStringList famdb = fdb.families();
443 if ( famdb.contains(f.family()) || !aResMgr->hasValue( "PyConsole", "additional_families" ) )
446 QStringList anAddFamilies = aResMgr->stringValue( "PyConsole", "additional_families" ).split( ";", QString::SkipEmptyParts );
448 for ( QStringList::Iterator it = anAddFamilies.begin(); it != anAddFamilies.end(); ++it )
451 if ( famdb.contains(aFamily) )
453 f.setFamily( aFamily );
454 aResMgr->setValue( "PyConsole", "font", f );
461 *\li Save window geometry.
462 *\li Save desktop geometry.
463 *\li Save resource maneger.
464 *\li Delete selection manager.
466 LightApp_Application::~LightApp_Application()
470 delete myScreenHelper;
474 /*!Start application.*/
475 void LightApp_Application::start()
477 CAM_Application::start();
480 updateViewManagers();
481 updateCommandsStatus();
484 desktop()->statusBar()->showMessage( "" );
486 LightApp_EventFilter::Init();
491 /*!Closeapplication.*/
492 void LightApp_Application::closeApplication()
494 #ifndef DISABLE_QTXWEBBROWSER
495 QProcess::startDetached( "HelpBrowser",
496 QStringList() << QString( "--remove=%1" ).arg( QApplication::instance()->applicationPid() ) );
498 CAM_Application::closeApplication();
501 /*!Gets application name.*/
502 QString LightApp_Application::applicationName() const
504 static QString _app_name;
505 if ( _app_name.isEmpty() )
506 _app_name = tr( "APP_NAME" );
510 /*!Gets application version.*/
511 QString LightApp_Application::applicationVersion() const
513 static QString _app_version;
515 if ( _app_version.isEmpty() )
517 QString resVersion = tr( "APP_VERSION" );
518 if ( resVersion != "APP_VERSION" )
520 _app_version = resVersion;
524 _app_version = GUI_VERSION_STR;
530 /*!Load module by \a name.*/
531 CAM_Module* LightApp_Application::loadModule( const QString& name, const bool showMsg )
533 CAM_Module* mod = CAM_Application::loadModule( name, showMsg );
536 connect( this, SIGNAL( studyOpened() ), mod, SLOT( onModelOpened() ) );
537 connect( this, SIGNAL( studySaved() ), mod, SLOT( onModelSaved() ) );
538 connect( this, SIGNAL( studyClosed() ), mod, SLOT( onModelClosed() ) );
543 /*!Activate module by \a modName*/
544 bool LightApp_Application::activateModule( const QString& modName )
547 CAM_Module* prevMod = activeModule();
550 actName = prevMod->moduleName();
552 QString name = modName;
553 if ( !name.isEmpty() && !moduleTitle( modName ).isEmpty() )
554 name = moduleTitle( modName );
556 if ( actName == name )
559 putInfo( tr( "ACTIVATING_MODULE" ).arg( name ) );
561 saveDockWindowsState();
564 infoPanel()->clear();
566 bool status = CAM_Application::activateModule( name );
568 updateModuleActions();
576 updateViewManagers();
578 if ( activeStudy() && activeStudy()->root() && objectBrowser() ) {
579 if ( objectBrowser()->root() != activeStudy()->root() )
580 objectBrowser()->setRoot( activeStudy()->root() );
581 updateObjectBrowser( true );
584 if ( activeModule() ) activeModule()->updateModuleVisibilityState();
590 /*!Gets selection manager.*/
591 LightApp_SelectionMgr* LightApp_Application::selectionMgr() const
596 /*!Creat action "New window" for certain type of viewer:*/
597 void LightApp_Application::createActionForViewer( const int id,
599 const QString& suffix,
602 QString vtlt = tr( QString( "NEW_WINDOW_%1" ).arg( suffix ).toLatin1().constData() );
603 QString tip = tr( "CREATING_NEW_WINDOW" ).arg( vtlt.remove( "&" ) );
604 QAction* a = createAction( id, // menu action id
611 false, // toggle flag
613 SLOT( onNewWindow() ) ); // slot
614 createMenu( a, parentId, -1 );
619 void LightApp_Application::createActions()
621 CAM_Application::createActions();
623 SUIT_Desktop* desk = desktop();
624 SUIT_ResourceMgr* resMgr = resourceMgr();
627 createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIcon(),
628 tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
629 Qt::CTRL+Qt::Key_P, desk, false, this, SLOT( onPreferences() ) );
633 int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
637 // a) Link to web site
639 url = resMgr->stringValue("GUI", "site_url");
640 if ( !url.isEmpty() ) {
641 QString title = tr ( "SALOME_SITE" );
642 QAction* as = createAction( WebSiteId, title,
643 resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ),
645 0, desk, false, this, SLOT( onHelpContentsModule() ) );
647 createMenu( as, helpMenu, -1, 0 );
652 if ( HAS_FORUM_URL ) {
653 url = resMgr->stringValue("GUI", "forum_url");
654 if ( !url.isEmpty() ) {
655 QString title = tr ( "SALOME_FORUM" );
656 QAction* af = createAction( ForumId, title,
657 resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ),
659 0, desk, false, this, SLOT( onHelpContentsModule() ) );
661 createMenu( af, helpMenu, -1, 0 );
665 // c) Link to YouTube channel
666 if ( HAS_YOUTUBE_URL ) {
667 url = resMgr->stringValue("GUI", "channel_url");
668 if ( !url.isEmpty() ) {
669 createMenu( separator(), helpMenu, -1, 0 );
670 QString title = tr ( "SALOME_VIDEO_TUTORIALS" );
671 QAction* av = createAction( VideosId, title,
672 resMgr->loadPixmap( "LightApp", tr( "ICON_LIFE_RIGN" ), false ),
673 title, tr( "PRP_SALOME_VIDEO_TUTORIALS" ),
674 0, desk, false, this, SLOT( onHelpContentsModule() ) );
676 createMenu( av, helpMenu, -1, 0 );
680 // d) Link to Tutorials
681 if ( HAS_TUTORIAL_URL ) {
682 url = resMgr->stringValue("GUI", "tutorials_url");
683 if ( !url.isEmpty() ) {
684 QString title = tr ( "SALOME_TUTORIALS" );
685 QAction* as = createAction( TutorialsId, title,
686 resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ),
687 title, tr( "PRP_SALOME_TUTORIALS" ),
688 0, desk, false, this, SLOT( onHelpContentsModule() ) );
690 createMenu( as, helpMenu, -1, 0 );
694 // e) Help for modules
696 QStringList aModuleList;
697 modules( aModuleList, false );
698 aModuleList.prepend( "GUI" );
699 aModuleList.prepend( "KERNEL" );
701 foreach( QString aModule, aModuleList )
702 createHelpItems( aModule );
704 // f) Additional help items
706 int id = LightApp_Application::UserID + FIRST_HELP_ID + 1000;
707 createMenu( separator(), helpMenu, -1, 10 );
709 QStringList addHelpItems = resMgr->parameters( "add_help" );
710 foreach ( QString paramName, addHelpItems ) {
711 QString helpItem = getHelpItem( "add_help", paramName );
712 if ( !helpItem.isEmpty() )
714 QPixmap helpIcon = helpItem.startsWith( "http", Qt::CaseInsensitive ) ?
715 resMgr->loadPixmap( "STD", tr( "ICON_WWW" ), false ) : resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false );
716 QAction* a = createAction( id++, paramName, helpIcon, paramName, paramName,
717 0, desk, false, this, SLOT( onHelpContentsModule() ) );
718 a->setData( helpItem );
719 createMenu( a, helpMenu, -1, 10 );
724 static QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), 0 );
725 connect( mru, SIGNAL( activated( const QString& ) ), this, SLOT( onMRUActivated( const QString& ) ) );
726 registerAction( MRUId, mru );
729 LightApp_ModuleAction* moduleAction = new LightApp_ModuleAction( resMgr, desk );
730 registerAction( ModulesListId, moduleAction );
731 // a. here we add regular modules (specified to GUI via --modules cmd line option, or default list from configuration)
732 // b. custom modules are added in customize() method
734 modules( modList, false );
735 foreach ( QString aModule, modList )
736 moduleAction->insertModule( aModule, moduleIcon( aModule, 20 ) ); // scale icon to 20x20 pix
738 connect( this, SIGNAL( moduleActivated( QString ) ),
739 moduleAction, SLOT( setActiveModule( QString ) ) );
740 connect( moduleAction, SIGNAL( moduleActivated( const QString& ) ),
741 this, SLOT( onModuleActivation( const QString& ) ) );
742 connect( moduleAction, SIGNAL( adding() ),
743 this, SLOT( onModuleAdding() ) );
744 connect( moduleAction, SIGNAL( removing( QString ) ),
745 this, SLOT( onModuleRemoving( QString ) ) );
748 int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, MenuWindowId, 100 );
749 int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
751 createAction( CloseId, tr( "TOT_CLOSE" ), QIcon(), tr( "MEN_DESK_CLOSE" ), tr( "PRP_CLOSE" ),
752 Qt::CTRL+Qt::Key_F4, desk, false, this, SLOT( onCloseWindow() ) );
753 createAction( CloseAllId, tr( "TOT_CLOSE_ALL" ), QIcon(), tr( "MEN_DESK_CLOSE_ALL" ), tr( "PRP_CLOSE_ALL" ),
754 0, desk, false, this, SLOT( onCloseAllWindow() ) );
755 createAction( GroupAllId, tr( "TOT_GROUP_ALL" ), QIcon(), tr( "MEN_DESK_GROUP_ALL" ), tr( "PRP_GROUP_ALL" ),
756 0, desk, false, this, SLOT( onGroupAllWindow() ) );
758 createMenu( CloseId, windowMenu, 0, -1 );
759 createMenu( CloseAllId, windowMenu, 0, -1 );
760 createMenu( GroupAllId, windowMenu, 0, -1 );
761 createMenu( separator(), windowMenu, -1, 0 );
763 #ifndef DISABLE_GLVIEWER
764 createActionForViewer( NewGLViewId, newWinMenu, QString::number( 0 ), Qt::ALT+Qt::Key_G );
766 #ifndef DISABLE_PLOT2DVIEWER
767 createActionForViewer( NewPlot2dId, newWinMenu, QString::number( 1 ), Qt::ALT+Qt::Key_P );
769 #ifndef DISABLE_OCCVIEWER
770 createActionForViewer( NewOCCViewId, newWinMenu, QString::number( 2 ), Qt::ALT+Qt::Key_O );
772 #ifndef DISABLE_VTKVIEWER
773 createActionForViewer( NewVTKViewId, newWinMenu, QString::number( 3 ), Qt::ALT+Qt::Key_K );
775 #ifndef DISABLE_QXGRAPHVIEWER
776 createActionForViewer( NewQxSceneViewId, newWinMenu, QString::number( 4 ), Qt::ALT+Qt::Key_S );
778 #ifndef DISABLE_GRAPHICSVIEW
779 createActionForViewer( NewGraphicsViewId, newWinMenu, QString::number( 5 ), Qt::ALT+Qt::Key_C );
781 #ifndef DISABLE_PVVIEWER
782 createActionForViewer( NewPVViewId, newWinMenu, QString::number( 6 ), Qt::ALT+Qt::Key_A );
784 #ifndef DISABLE_PYVIEWER
785 createActionForViewer( NewPyViewerId, newWinMenu, QString::number( 7 ), Qt::ALT+Qt::Key_Y );
788 createAction( RenameId, tr( "TOT_RENAME" ), QIcon(), tr( "MEN_DESK_RENAME" ), tr( "PRP_RENAME" ),
789 Qt::ALT+Qt::SHIFT+Qt::Key_R, desk, false, this, SLOT( onRenameWindow() ) );
790 createMenu( RenameId, windowMenu, -1 );
792 int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
793 createMenu( PreferencesId, fileMenu, 50, -1 );
794 createMenu( separator(), fileMenu, -1, 50, -1 );
796 createMenu( separator(), fileMenu, -1, 100, -1 );
797 createMenu( MRUId, fileMenu, 100, -1 );
798 createMenu( separator(), fileMenu, -1, 100, -1 );
800 #ifdef USE_SALOME_STYLE
801 createAction( StyleId, tr( "TOT_THEME" ), QIcon(), tr( "MEN_DESK_THEME" ), tr( "PRP_THEME" ),
802 0, desk, false, this, SLOT( onStylePreferences() ) );
803 #endif // USE_SALOME_STYLE
805 createAction( FullScreenId, tr( "TOT_FULLSCREEN" ), QIcon(), tr( "MEN_DESK_FULLSCREEN" ), tr( "PRP_FULLSCREEN" ),
806 Qt::Key_F11, desk, false, this, SLOT( onFullScreen() ) );
809 int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1 );
810 createMenu( separator(), viewMenu, -1, 20, -1 );
811 #ifdef USE_SALOME_STYLE
812 createMenu( StyleId, viewMenu, 20, -1 );
813 #endif // USE_SALOME_STYLE
814 createMenu( FullScreenId, viewMenu, 20, -1 );
815 createMenu( separator(), viewMenu, -1, 20, -1 );
816 createMenu( ModulesListId, viewMenu );
818 int modTBar = createTool( tr( "INF_TOOLBAR_MODULES" ), // title (language-dependant)
819 QString( "SalomeModules" ) ); // name (language-independant)
820 createTool( ModulesListId, modTBar );
826 void LightApp_Application::customize()
829 LightApp_ModuleAction* moduleAction = qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
830 // a. regular modules were added in createActions() method
831 // b. here we add custom modules (manually added by the user)
832 if ( HAS_SALOME_ON_DEMAND )
834 QStringList modList = resourceMgr()->stringValue( "launch", "user_modules" ).split( ";", QString::SkipEmptyParts );
835 foreach ( QString aModule, modList )
836 addUserModule( aModule, resourceMgr()->stringValue( "user_modules", aModule ) );
840 moduleAction->setModeEnabled( LightApp_ModuleAction::AddRemove, false );
844 /*!On module activation action.*/
845 void LightApp_Application::onModuleActivation( const QString& modTitle )
847 // Force user to create/open a study before module activation
848 QPixmap icon = moduleIcon( modTitle );
849 bool cancelled = false;
851 while ( !modTitle.isEmpty() && !activeStudy() && !cancelled ){
852 LightApp_ModuleDlg aDlg( desktop(), modTitle, icon );
853 QMap<int, QString> opmap = activateModuleActions();
854 for ( QMap<int, QString>::ConstIterator it = opmap.begin(); it != opmap.end(); ++it )
855 aDlg.addButton( it.value(), it.key() );
857 int res = aDlg.exec();
859 // some operation is selected
860 moduleActionSelected( res );
864 putInfo( tr("INF_CANCELLED") );
865 emit moduleActivated( QString() );
871 activateModule( modTitle );
874 /*!On module adding action.*/
875 void LightApp_Application::onModuleAdding()
877 // show dialog to browse configuration file
878 QStringList filters = ( QStringList() << tr( "Config files") + " (*.salomex)" << tr( "All files" ) + " (*)" );
879 QStringList paths = getOpenFileNames( QString(), filters.join( ";;" ), QString(), desktop() );
880 if ( paths.isEmpty() ) // cancelled
883 // loop via selected configuration files
884 foreach( QString path, paths )
886 // read description file (.salomex) and check it's OK
887 QtxResourceMgr resMgr;
888 if ( !resMgr.addResource( path ) )
890 SUIT_MessageBox::warning( desktop(), tr( "WRN_WARNING" ), tr( "WRN_MODULE_BAD_SALOMEX_FILE" ).arg( path ) );
893 // retrieve module name
894 QString name = resMgr.stringValue( "General", "name" ).trimmed();
895 if ( name.isEmpty() )
897 SUIT_MessageBox::warning( desktop(), tr( "WRN_WARNING" ), tr( "WRN_MODULE_EMPTY_NAME" ).arg( path ) );
900 // retrieve root directory
901 QString root = resMgr.stringValue( "General", "root" ).trimmed();
902 if ( root.isEmpty() )
904 SUIT_MessageBox::warning( desktop(), tr( "WRN_WARNING" ), tr( "WRN_MODULE_EMPTY_ROOT" ).arg( path ) );
907 addUserModule( name, root, true );
912 bool LightApp_Application::addUserModule( const QString& name, const QString& root, bool interactive )
914 if ( name.isEmpty() || root.isEmpty() )
917 if ( !moduleTitle( name ).isEmpty() ) // module alread in current session
920 SUIT_MessageBox::warning( desktop(), tr( "WRN_WARNING" ), tr( "WRN_MODULE_DUPLICATED" ).arg( name ) );
923 if ( !QFileInfo( root ).exists() ) // root directory does not exist
926 SUIT_MessageBox::warning( desktop(), tr( "WRN_WARNING" ), tr( "WRN_MODULE_ROOT_DOES_NOT_EXIST" ).arg( root ) );
929 // resources directory
930 QString resDir = Qtx::joinPath( QStringList() << root << "share" << "salome" << "resources" << name.toLower() );
931 if ( !QFileInfo( resDir ).exists() ) // resources directory does not exist
934 SUIT_MessageBox::warning( desktop(), tr( "WRN_WARNING" ), tr( "WRN_MODULE_BAD_RESDIR" ).arg( resDir ) );
937 // read XML configuration file
938 resourceMgr()->setConstant( QString( "%1_ROOT_DIR" ).arg( name ), root );
939 if ( !resourceMgr()->addResource( resDir ) ) // cannot read configuration
942 SUIT_MessageBox::warning( desktop(), tr( "WRN_WARNING" ), tr( "WRN_MODULE_CANNOT_READ_CFG" ).arg( resDir ) );
945 // fill in information about module
946 if ( !appendModuleInfo( name ) ) // cannot append module information to internal table
949 SUIT_MessageBox::warning( desktop(), tr( "WRN_WARNING" ), tr( "WRN_MODULE_BAD_CFG_FILE" ).arg( name ) );
953 resourceMgr()->loadLanguage( name );
954 // append module to the menu / toolbar
955 LightApp_ModuleAction* moduleAction = qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
957 moduleAction->insertModule( moduleTitle( name ), moduleIcon( moduleTitle( name ), 20 ), true ); // scale icon to 20x20 pix
958 // add empty page to Preferences dialog
959 LightApp_Preferences* prefs = preferences();
960 if ( prefs && !prefs->hasModule( moduleTitle( name ) ) )
962 int prefId = prefs->addPreference( moduleTitle( name ) );
963 prefs->setItemIcon( prefId, moduleIcon( moduleTitle( name ), 20 ) ); // scale icon to 20x20 pix
964 LightApp_Module* m = qobject_cast<LightApp_Module*>( module( moduleTitle( name ) ) );
967 m->createPreferences();
968 emptyPreferences( moduleTitle( name ) );
972 createHelpItems( moduleTitle( name ) );
973 // extend module catalog
974 QString catalogue = QDir( resDir ).filePath( QString( "%1Catalog.xml" ).arg( name ) );
975 addCatalogue( name, catalogue );
976 // update windows (in particular, Info panel)
978 // save module in the resource manager
981 QStringList customModules = resourceMgr()->stringValue( "launch", "user_modules" ).split( ";", QString::SkipEmptyParts );
982 customModules << name;
983 customModules.removeDuplicates();
984 resourceMgr()->setValue( "launch", "user_modules", customModules.join( ";" ) );
985 resourceMgr()->setValue( "user_modules", name, root );
990 /*!On module removing action.*/
991 void LightApp_Application::onModuleRemoving( const QString& title )
993 QString root = resourceMgr()->stringValue( "user_modules", moduleName( title ) );
994 QDir rootDirectory = QDir( root );
996 if ( rootDirectory.exists() )
998 int answer = SUIT_MessageBox::question( desktop(),
999 tr( "TLT_REMOVE_MODULE" ),
1000 tr( "QUE_REMOVE_MODULE_DIR" ).arg( root ),
1001 SUIT_MessageBox::Yes | SUIT_MessageBox::No | SUIT_MessageBox::Cancel,
1002 SUIT_MessageBox::No );
1003 if ( answer == SUIT_MessageBox::Cancel )
1004 return; // cancelled
1005 if ( answer == SUIT_MessageBox::Yes )
1007 if ( activeStudy() && activeStudy()->isModified() && !onSaveDoc() )
1008 // doc is not saved, or saving cancelled
1010 if ( !rootDirectory.removeRecursively() )
1012 // canont remove directory
1013 if ( SUIT_MessageBox::question( desktop(),
1014 tr( "WRN_WARNING" ),
1015 tr( "WRN_CANNOT_REMOVE_DIR" ).arg( root ),
1016 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1017 SUIT_MessageBox::No ) == SUIT_MessageBox::No )
1018 return; // removal is cancelled
1023 if ( activeModule() && activeModule()->moduleName() == title )
1024 activateModule( "" );
1026 // remove from "Modules" menu and toolbar
1027 LightApp_ModuleAction* moduleAction = qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
1030 moduleAction->removeModule( title );
1032 // remove Help menu items
1033 removeHelpItems( title );
1034 // remove Preferences
1035 LightApp_Preferences* prefs = preferences();
1037 prefs->removeModule( title );
1039 QStringList customModules = resourceMgr()->stringValue( "launch", "user_modules" ).split( ";", QString::SkipEmptyParts );
1040 customModules.removeAll( moduleName( title ) );
1041 resourceMgr()->setValue( "launch", "user_modules", customModules.join( ";" ) );
1042 removeModuleInfo( moduleName( title ) );
1043 // update windows (in particular, Info panel)
1047 /*!Default module activation.*/
1048 QString LightApp_Application::defaultModule() const
1050 QStringList aModuleNames;
1051 modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration
1052 //! If there's the one and only module --> activate it automatically
1053 //! TODO: Possible improvement - default module can be taken from preferences
1054 return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" );
1057 /*!On new window slot.*/
1058 void LightApp_Application::onNewWindow()
1060 const QObject* obj = sender();
1061 if ( !obj || !obj->inherits( "QAction" ) )
1065 int id = actionId( (QAction*)obj );
1068 #ifndef DISABLE_GLVIEWER
1070 type = GLViewer_Viewer::Type();
1073 #ifndef DISABLE_PLOT2DVIEWER
1075 type = Plot2d_Viewer::Type();
1078 #ifndef DISABLE_OCCVIEWER
1080 type = OCCViewer_Viewer::Type();
1083 #ifndef DISABLE_VTKVIEWER
1085 type = VTKViewer_Viewer::Type();
1088 #ifndef DISABLE_QXGRAPHVIEWER
1089 case NewQxSceneViewId:
1090 type = QxScene_Viewer::Type();
1093 #ifndef DISABLE_GRAPHICSVIEW
1094 case NewGraphicsViewId:
1095 type = GraphicsView_Viewer::Type();
1098 #ifndef DISABLE_PVVIEWER
1100 type = PVViewer_Viewer::Type();
1103 #ifndef DISABLE_PYVIEWER
1105 type = PyViewer_Viewer::Type();
1110 if ( !type.isEmpty() )
1111 createViewManager( type );
1115 SLOT: Creates new document
1117 void LightApp_Application::onNewDoc()
1119 if ( !checkExistingDoc() )
1122 //asl: fix for 0020515
1123 saveDockWindowsState();
1125 CAM_Application::onNewDoc();
1129 SLOT: Opens new document
1131 void LightApp_Application::onOpenDoc()
1133 SUIT_Study* study = activeStudy();
1135 if ( !checkExistingDoc( false ) )
1138 QString aName = getFileName( true, QString(), getFileFilter( true ), QString(), 0 );
1139 if ( aName.isNull() ) //Cancel
1144 if ( !study ) // new study will be create in THIS application
1147 updateViewManagers();
1151 bool LightApp_Application::canOpenDoc( const QString& )
1157 SLOT: Opens new document.
1158 \param aName - name of file
1160 bool LightApp_Application::onOpenDoc( const QString& aName )
1162 if ( !canOpenDoc(aName)) {
1163 bool showError = !property("open_study_from_command_line").isValid() ||
1164 !property("open_study_from_command_line").toBool();
1166 putInfo( tr("OPEN_DOCUMENT_PROBLEM") );
1168 SUIT_MessageBox::critical( desktop(), tr("ERR_ERROR"), tr("OPEN_DOCUMENT_PROBLEM"));
1175 if ( !checkExistingDoc() )
1178 saveDockWindowsState();
1180 // We should take mru action first because this application instance can be deleted later.
1181 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
1183 bool res = CAM_Application::onOpenDoc( aName );
1188 mru->insert( aName );
1190 mru->remove( aName );
1196 SLOT: Displays "About" message box
1198 void LightApp_Application::onHelpAbout()
1200 LightApp_AboutDlg dlg( applicationName(), applicationVersion(), desktop() );
1205 Private SLOT: Called on selection is changed
1206 Dispatchs active module that selection is changed
1208 void LightApp_Application::onSelection()
1210 //MESSAGE("onSelection")
1211 onSelectionChanged();
1213 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
1214 ((LightApp_Module*)activeModule())->selectionChanged();
1219 \param study - SUIT_Study.
1221 void LightApp_Application::setActiveStudy( SUIT_Study* study )
1223 CAM_Application::setActiveStudy( study );
1227 Enables/Disables menu items and toolbar buttons. Rebuild menu
1229 void LightApp_Application::updateCommandsStatus()
1231 CAM_Application::updateCommandsStatus();
1234 #ifndef DISABLE_GLVIEWER
1235 a = action( NewGLViewId );
1237 a->setEnabled( activeStudy() );
1240 #ifndef DISABLE_PLOT2DVIEWER
1241 a = action( NewPlot2dId );
1243 a->setEnabled( activeStudy() );
1246 #ifndef DISABLE_OCCVIEWER
1247 a = action( NewOCCViewId );
1249 a->setEnabled( activeStudy() );
1252 #ifndef DISABLE_VTKVIEWER
1253 a = action( NewVTKViewId );
1255 a->setEnabled( activeStudy() );
1258 #ifndef DISABLE_QXGRAPHVIEWER
1259 a = action( NewQxSceneViewId );
1261 a->setEnabled( activeStudy() );
1264 #ifndef DISABLE_GRAPHICSVIEW
1265 a = action( NewGraphicsViewId );
1267 a->setEnabled( activeStudy() );
1270 #ifndef DISABLE_PVVIEWER
1271 a = action( NewPVViewId );
1273 a->setEnabled( activeStudy() );
1276 #ifndef DISABLE_PYVIEWER
1277 a = action( NewPyViewerId );
1279 a->setEnabled( activeStudy() );
1285 Runs system command in separate thread
1287 class RunBrowser: public QThread
1290 static void execute( LightApp_Application* application,
1291 const QString& browser,
1292 const QString& parameters,
1293 const QString& url )
1295 (new RunBrowser( application, browser, parameters, url ))->start();
1299 RunBrowser( LightApp_Application* application,
1300 const QString& browser,
1301 const QString& parameters,
1303 : myApplication( application ),
1304 myBrowser( browser ),
1305 myParameters( parameters ),
1308 if ( !myUrl.startsWith( "http", Qt::CaseInsensitive ) )
1311 if ( myUrl.startsWith( "file://", Qt::CaseInsensitive ) )
1312 myUrl = myUrl.remove( 0, QString( "file://" ).count() );
1313 // For the external browser we always specify 'file://' protocol,
1314 // because some web browsers (e.g. Mozilla Firefox) can't open local file without protocol.
1315 myUrl = myUrl.prepend( "file://" );
1317 connect(this, SIGNAL(finished()), SLOT(deleteLater()));
1322 if ( !myBrowser.isEmpty() && !myUrl.isEmpty() )
1324 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
1326 QString cmdLine = QString( "\"%1\" %2 \"%3\"" ).arg( myBrowser, myParameters, myUrl );
1328 QString cmdLine = QString( "%1 %2 \"%3\"" ).arg( myBrowser, myParameters, myUrl );
1329 // remove LD_LIBRARY_PATH from the environement before starting launcher to avoid bad interactions.
1330 // (especially in the case of universal binaries)
1331 env.remove("LD_LIBRARY_PATH");
1333 QProcess* proc = new QProcess();
1334 proc->setProcessEnvironment(env);
1335 proc->start( cmdLine );
1336 if ( !proc->waitForStarted() )
1338 SALOME_CustomEvent* ce2000 = new SALOME_CustomEvent( 2000 );
1339 QString* msg = new QString( QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).arg( myBrowser, myUrl ) );
1340 ce2000->setData( msg );
1341 QApplication::postEvent( myApplication, ce2000 );
1347 LightApp_Application* myApplication;
1349 QString myParameters;
1353 void LightApp_Application::showHelp( const QString& path )
1355 SUIT_ResourceMgr* resMgr = resourceMgr();
1357 #if DISABLE_QTXWEBBROWSER
1358 bool useExternalBrowser = true;
1360 bool useExternalBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1363 if ( useExternalBrowser )
1366 QString browser = resMgr->stringValue( "ExternalBrowser", "winapplication" ) ;
1368 QString browser = resMgr->stringValue( "ExternalBrowser", "application" );
1370 QString parameters = resMgr->stringValue("ExternalBrowser", "parameters");
1372 if ( !browser.isEmpty() )
1374 RunBrowser::execute( this, browser, parameters, path );
1378 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1379 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1380 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1383 path << tr( "PREF_CATEGORY_SALOME" ) << tr( "PREF_TAB_GENERAL" )
1384 << tr( "PREF_GROUP_EXT_BROWSER" ) << tr( "PREF_APP" );
1385 showPreferences( path );
1391 QStringList cmdLine;
1392 cmdLine << QString( "--language=%1" ).arg( resMgr->stringValue( "language", "language" ) );
1393 cmdLine << QString( "--add=%1" ).arg( QApplication::instance()->applicationPid() );
1395 QProcess::startDetached( "HelpBrowser", cmdLine );
1400 SLOT: Displays help contents for choosen module
1402 void LightApp_Application::onHelpContentsModule()
1404 const QAction* a = (QAction*) sender();
1405 QString helpFile = a->data().toString();
1406 if ( !helpFile.isEmpty() )
1407 showHelp( helpFile );
1411 SLOT: Displays contextual help (e.g. for choosen dialog)
1413 void LightApp_Application::onHelpContextModule( const QString& component,
1415 const QString& context )
1418 if ( !url.startsWith( "http", Qt::CaseInsensitive ) )
1421 QFileInfo fi( url );
1422 if ( fi.isRelative() && !component.isEmpty() )
1424 QString rootDir = Qtx::getenv( (component + "_ROOT_DIR").toLatin1().constData() );
1425 if ( !rootDir.isEmpty() )
1427 path = (QStringList() << rootDir << "share" << "doc" << "salome" << "gui" << component << url).join( QDir::separator() );
1431 if ( !context.isEmpty() )
1433 path += QString( "#%1" ).arg( context );
1439 Sets enable or disable some actions on selection changed.
1441 void LightApp_Application::onSelectionChanged()
1443 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
1444 bool canCopy = m ? m->canCopy() : false;
1445 bool canPaste = m ? m->canPaste() : false;
1447 action( EditCopyId )->setEnabled(canCopy);
1448 action( EditPasteId )->setEnabled(canPaste);
1452 SLOT: Performs some actions when dockable windows are triggered
1454 void LightApp_Application::onDockWindowVisibilityChanged( bool )
1458 QWidget* LightApp_Application::dockWindow( const int id ) const
1461 if ( myWin.contains( id ) )
1466 QDockWidget* LightApp_Application::windowDock( QWidget* wid ) const
1471 QDockWidget* dock = 0;
1472 QWidget* w = wid->parentWidget();
1473 while ( w && !dock )
1475 dock = ::qobject_cast<QDockWidget*>( w );
1476 w = w->parentWidget();
1481 void LightApp_Application::insertDockWindow( const int id, QWidget* wid )
1486 if ( wid != dockWindow( id ) )
1487 removeDockWindow( id );
1489 myWin.insert( id, wid );
1491 QtxDockWidget* dock = new QtxDockWidget( true, desktop() );
1492 if ( id == WT_InfoPanel ) {
1493 // Info panel's position is strongly limited to the right area;
1494 // It is not movable and not floatable.
1495 dock->setAllowedAreas( Qt::RightDockWidgetArea );
1496 dock->setFeatures( QDockWidget::DockWidgetClosable );
1497 connect( dock, SIGNAL( aboutToShow()), this, SLOT( onInfoPanelShown() ) );
1500 dock->setFeatures( QDockWidget::AllDockWidgetFeatures );
1502 connect( dock, SIGNAL( destroyed( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
1504 dock->setObjectName( wid->objectName().isEmpty() ? QString( "window_%1" ).arg( id ) :
1505 QString( "%1Dock" ).arg( wid->objectName() ) );
1506 dock->setWidget( wid );
1507 dock->toggleViewAction()->setData( QVariant( wid->objectName() ) );
1508 connect( dock->toggleViewAction(), SIGNAL( triggered( bool ) ),
1509 this, SLOT( onDockWindowVisibilityChanged( bool ) ) );
1511 QKeySequence accel = wid->property( "shortcut" ).value<QKeySequence>();
1512 if ( !accel.isEmpty() )
1513 dock->toggleViewAction()->setShortcut( accel );
1518 void LightApp_Application::removeDockWindow( const int id )
1520 QWidget* wid = dockWindow( id );
1526 QDockWidget* dock = windowDock( wid );
1530 dock->setWidget( 0 );
1531 wid->setParent( 0 );
1532 wid->setVisible( false );
1536 void LightApp_Application::placeDockWindow( const int id, Qt::DockWidgetArea place )
1538 QDockWidget* dock = windowDock( dockWindow( id ) );
1539 if ( dock && desktop() ) {
1540 desktop()->addDockWidget( place, dock );
1541 QtxDockAction* a = qobject_cast<QtxDockAction*>( action( ViewWindowsId ) );
1542 if ( a ) a->update();
1548 \param flag - key for window
1549 Flag used how identificator of window in windows list.
1551 QWidget* LightApp_Application::getWindow( const int flag)
1553 QWidget* wid = dockWindow( flag );
1555 insertDockWindow( flag, wid = createWindow( flag ) );
1557 QMap<int, int> winMap;
1558 currentWindows( winMap );
1559 if ( winMap.contains( flag ) )
1560 placeDockWindow( flag, (Qt::DockWidgetArea)winMap[flag] );
1566 \return Object Browser
1568 SUIT_DataBrowser* LightApp_Application::objectBrowser()
1570 return qobject_cast<SUIT_DataBrowser*>( dockWindow( WT_ObjectBrowser ) );
1573 QtxInfoPanel* LightApp_Application::infoPanel()
1575 return qobject_cast<QtxInfoPanel *>( dockWindow( WT_InfoPanel ));
1581 LogWindow* LightApp_Application::logWindow()
1583 return qobject_cast<LogWindow*>( dockWindow( WT_LogWindow ) );
1586 #ifndef DISABLE_PYCONSOLE
1588 This returns the python console integrated to the GUI. Depending
1589 when you request the python console, this function could return
1590 null. Then the optional parameter force (default to false) can be
1591 set to force the creation of the python console if it is not done
1593 \param force - if true, the pythonConsole is created if it does not exist yet
1594 \return Python Console
1596 PyConsole_Console* LightApp_Application::pythonConsole(const bool force)
1598 QWidget* wid = dockWindow( WT_PyConsole );
1599 if ( !wid && force==true) {
1600 wid = getWindow(WT_PyConsole);
1602 return qobject_cast<PyConsole_Console*>( wid );
1607 Updates object browser and maybe data models
1608 \param updateModels - if it is true, then data models are updated
1610 void LightApp_Application::updateObjectBrowser( const bool updateModels )
1612 // update existing data models
1615 const bool isAutoUpdate = objectBrowser() ? objectBrowser()->autoUpdate() : true;
1616 if ( objectBrowser() )
1617 objectBrowser()->setAutoUpdate( false );
1619 LightApp_Study* study = dynamic_cast<LightApp_Study*>(activeStudy());
1621 CAM_Study::ModelList dm_list;
1622 study->dataModels( dm_list );
1623 QListIterator<CAM_DataModel*> it( dm_list );
1624 while ( it.hasNext() ) {
1625 CAM_DataModel* camDM = it.next();
1626 if ( camDM && camDM->inherits( "LightApp_DataModel" ) )
1627 ((LightApp_DataModel*)camDM)->update();
1631 if( objectBrowser() )
1632 objectBrowser()->setAutoUpdate( isAutoUpdate );
1635 if ( objectBrowser() ) {
1636 objectBrowser()->updateGeometry();
1637 objectBrowser()->updateTree( 0, false );
1644 LightApp_Preferences* LightApp_Application::preferences() const
1646 return preferences( false );
1650 \return first view manager of some type
1651 \param vmType - type of view manager
1652 \param create - is it necessary to create view manager in case, when there is no manager of such type
1654 SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, const bool create )
1656 SUIT_ViewManager* aVM = viewManager( vmType );
1657 SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
1658 MESSAGE("vmType: " << vmType.toStdString() << " aVM: " << aVM << " anActiveVM: " << anActiveVM );
1659 if ( anActiveVM && anActiveVM->getType() == vmType )
1661 MESSAGE("aVM = anActiveVM");
1665 bool keepDetached = property("keep_detached").toBool();
1666 if ( aVM && (!aVM->getDetached() || keepDetached) && create )
1668 if ( !aVM->getActiveView() )
1670 MESSAGE("aVM->createView()");
1675 MESSAGE("desktop()->setActiveWindow: " << aVM->getActiveView());
1676 desktop()->setActiveWindow( aVM->getActiveView() );
1681 MESSAGE("aVM = createViewManager( vmType )");
1682 aVM = createViewManager( vmType );
1689 Creates view manager of some type
1690 \param vmType - type of view manager
1692 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, bool detached )
1694 SUIT_ResourceMgr* resMgr = resourceMgr();
1696 SUIT_ViewManager* viewMgr = 0;
1697 #ifndef DISABLE_GLVIEWER
1698 if( vmType == GLViewer_Viewer::Type() )
1700 viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() );
1701 new LightApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
1704 #ifndef DISABLE_PLOT2DVIEWER
1705 if( vmType == Plot2d_Viewer::Type() )
1707 viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
1709 #ifndef DISABLE_SALOMEOBJECT
1710 SPlot2d_Viewer* v = new SPlot2d_Viewer();
1712 new LightApp_Plot2dSelector( v, mySelMgr );
1714 vm = new Plot2d_Viewer();
1716 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1717 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
1720 Plot2d_ViewFrame* frame = wnd->getViewFrame();
1721 frame->setBackgroundColor( resMgr->colorValue( "Plot2d", "Background", frame->backgroundColor() ) );
1725 #ifndef DISABLE_QXGRAPHVIEWER
1726 if( vmType == QxScene_Viewer::Type() )
1728 viewMgr = new QxScene_ViewManager( activeStudy(), desktop() );
1729 QxScene_Viewer* vm = new QxScene_Viewer();
1730 viewMgr->setViewModel( vm );
1731 //QxScene_ViewWindow* wnd = dynamic_cast<QxScene_ViewWindow*>( viewMgr->getActiveView() );
1734 #ifndef DISABLE_GRAPHICSVIEW
1735 if( vmType == GraphicsView_Viewer::Type() )
1737 viewMgr = new GraphicsView_ViewManager( activeStudy(), desktop() );
1738 new LightApp_GVSelector( (GraphicsView_Viewer*)viewMgr->getViewModel(), mySelMgr );
1741 #ifndef DISABLE_PVVIEWER
1742 if( vmType == PVViewer_Viewer::Type() )
1744 if (( viewMgr = dynamic_cast<PVViewer_ViewManager*>( getViewManager( vmType, false )))) {
1745 viewMgr->getActiveView()->setFocus();
1748 viewMgr = new PVViewer_ViewManager( activeStudy(), desktop() );
1752 #ifndef DISABLE_PYVIEWER
1753 if( vmType == PyViewer_Viewer::Type() )
1755 viewMgr = new PyViewer_ViewManager( activeStudy(), desktop() );
1758 #ifndef DISABLE_OCCVIEWER
1759 if( vmType == OCCViewer_Viewer::Type() )
1761 viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
1762 OCCViewer_Viewer* vm;
1763 #ifndef DISABLE_SALOMEOBJECT
1764 vm = new SOCC_Viewer();
1766 vm = new OCCViewer_Viewer( true );
1768 vm->setBackground( OCCViewer_ViewFrame::TOP_LEFT,
1769 resMgr->backgroundValue( "OCCViewer", "xz_background", vm->background(OCCViewer_ViewFrame::TOP_LEFT) ) );
1770 vm->setBackground( OCCViewer_ViewFrame::TOP_RIGHT,
1771 resMgr->backgroundValue( "OCCViewer", "yz_background", vm->background(OCCViewer_ViewFrame::TOP_RIGHT) ) );
1772 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_LEFT,
1773 resMgr->backgroundValue( "OCCViewer", "xy_background", vm->background(OCCViewer_ViewFrame::BOTTOM_LEFT) ) );
1774 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_RIGHT,
1775 resMgr->backgroundValue( "OCCViewer", "background", vm->background(OCCViewer_ViewFrame::MAIN_VIEW) ) );
1777 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1778 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ));
1779 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1780 vm->setProjectionType( resMgr->integerValue( "OCCViewer", "projection_mode", vm->projectionType() ) );
1781 vm->setStereoType( resMgr->integerValue( "OCCViewer", "stereo_type", vm->stereoType() ) );
1782 vm->setAnaglyphFilter( resMgr->integerValue( "OCCViewer", "anaglyph_filter", vm->anaglyphFilter() ) );
1783 vm->setStereographicFocus( resMgr->integerValue( "OCCViewer", "focus_type", vm->stereographicFocusType() ),
1784 resMgr->doubleValue( "OCCViewer", "focus_value", vm->stereographicFocusValue() ));
1785 vm->setInterocularDistance( resMgr->integerValue( "OCCViewer", "iod_type", vm->interocularDistanceType() ),
1786 resMgr->doubleValue( "OCCViewer", "iod_value", vm->interocularDistanceValue() ));
1787 vm->setSelectionStyle((OCCViewer_ViewWindow::SelectionStyle) resMgr->integerValue( "OCCViewer", "adv_selection_mode", vm->selectionStyle() ) );
1789 vm->setReverseStereo( resMgr->booleanValue( "OCCViewer", "reverse_stereo", vm->isReverseStereo() ) );
1790 vm->setVSync( resMgr->booleanValue( "OCCViewer", "enable_vsync", vm->isVSync() ) );
1791 vm->setQuadBufferSupport( resMgr->booleanValue( "OCCViewer", "enable_quad_buffer_support", vm->isQuadBufferSupport() ) );
1792 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1793 vm->enablePreselection( resMgr->booleanValue( "OCCViewer", "enable_preselection", vm->isPreselectionEnabled() ) );
1794 vm->enableSelection( resMgr->booleanValue( "OCCViewer", "enable_selection", vm->isSelectionEnabled() ) );
1795 vm->setClippingColor( resMgr->colorValue( "OCCViewer", "clipping_color", vm->clippingColor() ) );
1796 vm->setClippingTextureParams( resMgr->booleanValue( "OCCViewer", "clipping_use_default_texture", vm->isDefaultTextureUsed() ),
1797 resMgr->stringValue( "OCCViewer", "clipping_texture", vm->clippingTexture() ),
1798 resMgr->booleanValue( "OCCViewer", "clipping_modulate", vm->isTextureModulated() ),
1799 resMgr->doubleValue( "OCCViewer", "clipping_scale", vm->clippingTextureScale() ) );
1802 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1803 new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
1806 #ifndef DISABLE_VTKVIEWER
1807 #ifndef DISABLE_SALOMEOBJECT
1808 if ( vmType == SVTK_Viewer::Type() )
1810 if ( vmType == VTKViewer_Viewer::Type() )
1813 #ifndef DISABLE_SALOMEOBJECT
1814 viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
1815 SVTK_Viewer* vm = dynamic_cast<SVTK_Viewer*>( viewMgr->getViewModel() );
1818 vm->setProjectionMode( resMgr->integerValue( "VTKViewer", "projection_mode", vm->projectionMode() ) );
1819 vm->setStereoType( resMgr->integerValue( "VTKViewer", "stereo_type", vm->stereoType() ) );
1820 vm->setAnaglyphFilter( resMgr->integerValue( "VTKViewer", "anaglyph_filter", vm->anaglyphFilter() ) );
1821 vm->setQuadBufferSupport( resMgr->booleanValue( "VTKViewer", "enable_quad_buffer_support", vm->isQuadBufferSupport() ) );
1822 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1823 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1824 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ) );
1825 vm->setStaticTrihedronVisible( resMgr->booleanValue( "3DViewer", "show_static_trihedron", vm->isStaticTrihedronVisible() ) );
1826 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1827 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1828 vm->setPreSelectionMode(resMgr->integerValue( "VTKViewer", "preselection", vm->preSelectionMode() ) );
1829 vm->enableSelection( resMgr->booleanValue( "VTKViewer", "enable_selection", vm->isSelectionEnabled() ) );
1830 vm->setIncrementalSpeed( resMgr->integerValue( "VTKViewer", "speed_value", vm->incrementalSpeed() ),
1831 resMgr->integerValue( "VTKViewer", "speed_mode", vm->incrementalSpeedMode() ) );
1832 vm->setSpacemouseButtons( resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", vm->spacemouseBtn(1) ),
1833 resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", vm->spacemouseBtn(2) ),
1834 resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", vm->spacemouseBtn(3) ) );
1835 new LightApp_VTKSelector( vm, mySelMgr );
1838 viewMgr = new VTKViewer_ViewManager( activeStudy(), desktop() );
1839 VTKViewer_Viewer* vm = dynamic_cast<VTKViewer_Viewer*>( viewMgr->getViewModel() );
1841 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1849 viewMgr->setDetached(detached);
1850 addViewManager( viewMgr );
1851 SUIT_ViewWindow* viewWin = viewMgr->createViewWindow();
1853 if ( viewWin && desktop() ) {
1854 viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1855 viewWin->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1861 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, QWidget* w )
1863 SUIT_ResourceMgr* resMgr = resourceMgr();
1865 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
1867 new LightApp_WgViewModel( vmType, w ) );
1868 vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
1870 addViewManager( vm );
1871 SUIT_ViewWindow* vw = vm->createViewWindow();
1872 if ( vw && desktop() ) {
1873 vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1874 vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1877 if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
1878 myUserWmTypes << vmType;
1883 SUIT_ViewManager* LightApp_Application::createViewManager( SUIT_ViewModel* theModel )
1885 SUIT_ResourceMgr* resMgr = resourceMgr();
1887 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
1891 QString vmType = vm->getType();
1893 vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
1895 addViewManager( vm );
1896 SUIT_ViewWindow* vw = vm->createViewWindow();
1897 if ( vw && desktop() ) {
1898 vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1899 vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1902 if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
1903 myUserWmTypes << vmType;
1909 SLOT: Removes view manager from application
1911 void LightApp_Application::onCloseView( SUIT_ViewManager* theVM )
1913 removeViewManager( theVM );
1917 Protected SLOT: On study created.
1918 \param theStudy - just created study
1920 void LightApp_Application::onStudyCreated( SUIT_Study* theStudy )
1922 SUIT_DataObject* aRoot = 0;
1923 if ( theStudy && theStudy->root() )
1925 aRoot = theStudy->root();
1926 //aRoot->setName( tr( "DATA_MODELS" ) );
1929 getWindow( WT_ObjectBrowser );
1930 getWindow( WT_InfoPanel );
1932 loadDockWindowsState();
1934 if ( objectBrowser() )
1935 objectBrowser()->setRoot( aRoot );
1937 activateModule( defaultModule() );
1939 if ( objectBrowser() )
1940 objectBrowser()->openLevels();
1942 #ifndef DISABLE_PYCONSOLE
1943 if( pythonConsole() )
1944 getPyInterp()->initStudy();
1949 Protected SLOT: On study opened.
1950 \param theStudy - just opened study
1952 void LightApp_Application::onStudyOpened( SUIT_Study* theStudy )
1954 SUIT_DataObject* aRoot = 0;
1955 if ( theStudy && theStudy->root() )
1957 aRoot = theStudy->root();
1961 getWindow( WT_ObjectBrowser );
1962 getWindow( WT_InfoPanel );
1964 loadDockWindowsState();
1966 if ( objectBrowser() )
1967 objectBrowser()->setRoot( aRoot );
1969 activateModule( defaultModule() );
1971 if ( objectBrowser() )
1972 objectBrowser()->openLevels();
1974 #ifndef DISABLE_PYCONSOLE
1975 if( pythonConsole() )
1976 getPyInterp()->initStudy();
1982 /*!Protected SLOT. On study saved.*/
1983 void LightApp_Application::onStudySaved( SUIT_Study* s )
1985 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
1987 mru->insert( s->studyName() );
1992 /*!Protected SLOT. On study closed.*/
1993 void LightApp_Application::onStudyClosed( SUIT_Study* /*s*/ )
1996 disconnect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
1997 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
2000 // stop auto-save timer
2001 myAutoSaveTimer->stop();
2003 // Bug 10396: clear selection
2004 mySelMgr->clearSelected();
2006 // Bug 12944: emit signal only after clear selection
2009 activateModule( "" );
2012 /*!Protected SLOT.On desktop activated.*/
2013 void LightApp_Application::onDesktopActivated()
2015 CAM_Application::onDesktopActivated();
2016 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>(activeModule());
2018 aModule->studyActivated();
2021 void LightApp_Application::studyOpened( SUIT_Study* s )
2023 CAM_Application::studyOpened( s );
2026 updateViewManagers();
2029 void LightApp_Application::studySaved( SUIT_Study* s )
2031 CAM_Application::studyOpened( s );
2032 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
2033 if ( aResMgr && activeStudy() ) {
2034 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
2035 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
2039 void LightApp_Application::studyCreated( SUIT_Study* s )
2041 CAM_Application::studyCreated( s );
2044 updateViewManagers();
2047 /*!Gets file filter.
2048 *\retval QString "(*.hdf)"
2050 QString LightApp_Application::getFileFilter( bool /*open*/) const
2056 Shows file dialog and return user selected file name
2058 QString LightApp_Application::getFileName( bool open, const QString& initial, const QString& filters,
2059 const QString& caption, QWidget* parent )
2063 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
2064 return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
2067 /*! Gets directory*/
2068 QString LightApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
2072 return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true );
2075 /*! Get open file names*/
2076 QStringList LightApp_Application::getOpenFileNames( const QString& initial, const QString& filters,
2077 const QString& caption, QWidget* parent )
2081 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
2082 return SUIT_FileDlg::getOpenFileNames( parent, initial, fls, caption, true );
2085 /*!Private SLOT. Update object browser.*/
2086 void LightApp_Application::onRefresh()
2088 updateObjectBrowser( true );
2091 /*!Private SLOT. Update actions after rename object.*/
2092 void LightApp_Application::onRenamed()
2094 activeStudy()->Modified();
2098 // IMN 08.07.2015 : issue 002556: Some stereo outputs are affected by window position.
2099 // To prevent reversion the window should be either aligned during movement and resize.
2100 /*!Private SLOT. Update actions after rename object.*/
2101 /*void LightApp_Application::onMoved()
2103 OCCViewer_ViewManager* viewMgr = 0;
2104 viewMgr = dynamic_cast<OCCViewer_ViewManager*>( getViewManager( OCCViewer_Viewer::Type(), false ) );
2106 OCCViewer_ViewWindow* view = 0;
2107 view = dynamic_cast<OCCViewer_ViewWindow*>( viewMgr->getActiveView() );
2109 view->getViewPort()->repaintViewAfterMove();
2114 /*!Private SLOT. Support drag-and-drop operation.*/
2115 void LightApp_Application::onDropped( const QList<SUIT_DataObject*>& objects, SUIT_DataObject* parent, int row, Qt::DropAction action )
2117 LightApp_DataObject* parentObj = dynamic_cast<LightApp_DataObject*>( parent );
2121 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>( parentObj->module() );
2123 aModule->dropObjects( objects, parentObj, row, action );
2126 /*!Private SLOT. On preferences.*/
2127 void LightApp_Application::onPreferences()
2129 showPreferences( activeModule() ? activeModule()->moduleName() : tr( "PREF_CATEGORY_SALOME" ) );
2132 /*!Private SLOT. On preferences.*/
2133 void LightApp_Application::showPreferences( const QString& path )
2135 showPreferences( QStringList() << path );
2138 void LightApp_Application::showPreferences( const QStringList& path )
2140 QApplication::setOverrideCursor( Qt::WaitCursor );
2142 LightApp_PreferencesDlg* prefDlg = new LightApp_PreferencesDlg( preferences( true ), desktop());
2144 QApplication::restoreOverrideCursor();
2149 preferences()->activateItem( path );
2151 if ( ( prefDlg->exec() == QDialog::Accepted || prefDlg->isSaved() ) && resourceMgr() )
2154 resourceMgr()->setValue( "desktop", "geometry", desktop()->storeGeometry() );
2155 resourceMgr()->save();
2158 shortcutMgr()->updateShortcuts();
2164 /*!Protected SLOT. On preferences changed.*/
2165 void LightApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param )
2167 LightApp_Module* sMod = 0;
2168 CAM_Module* mod = module( modName );
2169 if ( mod && mod->inherits( "LightApp_Module" ) )
2170 sMod = (LightApp_Module*)mod;
2173 sMod->preferencesChanged( section, param );
2175 preferencesChanged( section, param );
2176 // emit signal to allow additional preferences changing processing
2177 emit preferenceChanged( modName, section, param );
2180 /*!Remove all windows from study.*/
2181 void LightApp_Application::beforeCloseDoc( SUIT_Study* s )
2183 saveDockWindowsState();
2185 if ( SUIT_DataBrowser* ob = objectBrowser() )
2188 CAM_Application::beforeCloseDoc( s );
2191 /*!Update actions.*/
2192 void LightApp_Application::updateActions()
2194 updateCommandsStatus();
2200 SUIT_Study* LightApp_Application::createNewStudy()
2202 LightApp_Study* aStudy = new LightApp_Study( this );
2204 // Set up processing of major study-related events
2205 connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
2206 connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
2207 connect( aStudy, SIGNAL( saved ( SUIT_Study* ) ), this, SLOT( onStudySaved ( SUIT_Study* ) ) );
2208 connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
2214 Creates window by flag.
2215 \param flag - identificator of window type
2217 QWidget* LightApp_Application::createWindow( const int flag )
2221 SUIT_ResourceMgr* resMgr = resourceMgr();
2223 if ( flag == WT_ObjectBrowser )
2225 SUIT_DataBrowser* ob = new SUIT_DataBrowser( new LightApp_DataObject(), desktop() );
2226 ob->setObjectName( "objectBrowser" );
2227 ob->setSortMenuEnabled( true );
2228 ob->setAutoUpdate( true );
2229 if ( resMgr->hasValue( "ObjectBrowser", "auto_hide_search_tool" ) )
2230 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
2232 //ob->setAutoOpenLevel( 1 ); // commented by ASV as a fix to bug IPAL10107
2233 ob->setWindowTitle( tr( "OBJECT_BROWSER" ) );
2234 connect( ob, SIGNAL( requestUpdate() ), this, SLOT( onRefresh() ) );
2236 QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
2237 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
2238 treeModel->setSearcher( this );
2239 treeModel->registerColumn( 0, EntryCol, LightApp_DataObject::EntryId );
2240 treeModel->setAppropriate( EntryCol, Qtx::Toggled );
2242 // Mantis issue 0020136: Drag&Drop in OB
2243 SUIT_ProxyModel* proxyModel = dynamic_cast<SUIT_ProxyModel*>(treeModel);
2245 connect( proxyModel, SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
2246 this, SLOT( onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
2247 connect( proxyModel, SIGNAL( renamed( SUIT_DataObject* ) ),
2248 this, SLOT( onRenamed( ) ) );
2252 // temporary commented
2254 OB_ListView* ob_list = dynamic_cast<OB_ListView*>( const_cast<QListView*>( ob->listView() ) );
2256 ob_list->setColumnMaxWidth( 0, desktop()->width()/4 );
2259 // Create OBSelector
2260 new LightApp_OBSelector( ob, mySelMgr );
2261 ob->treeView()->header()->setSectionResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
2262 ob->treeView()->header()->moveSection(SUIT_DataObject::NameId,SUIT_DataObject::VisibilityId);
2263 ob->treeView()->setColumnWidth(SUIT_DataObject::VisibilityId, VISIBILITY_COLUMN_WIDTH);
2264 ob->setProperty( "shortcut", QKeySequence( "Alt+Shift+O" ) );
2266 ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
2268 else if ( flag == WT_InfoPanel)
2270 QtxInfoPanel* ipanel = new QtxInfoPanel( desktop() );
2271 ipanel->setObjectName( "infoPanel" );
2272 ipanel->setWindowTitle( tr( "INFO_PANEL" ) );
2275 #ifndef DISABLE_PYCONSOLE
2276 else if ( flag == WT_PyConsole )
2278 PyConsole_Console* pyCons = new PyConsole_Console( desktop(), new LightApp_PyEditor( getPyInterp() ) );
2279 pyCons->setObjectName( "pythonConsole" );
2280 pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
2281 pyCons->setFont( resMgr->fontValue( "PyConsole", "font" ) );
2282 pyCons->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
2283 pyCons->setAutoCompletion( resMgr->booleanValue( "PyConsole", "auto_completion", true ) );
2284 pyCons->setProperty( "shortcut", QKeySequence( "Alt+Shift+P" ) );
2288 else if ( flag == WT_LogWindow )
2290 LogWindow* logWin = new LogWindow( desktop() );
2291 logWin->handleQtMessages( true );
2292 logWin->setObjectName( "logWindow" );
2293 logWin->setWindowTitle( tr( "LOG_WINDOW" ) );
2294 logWin->setProperty( "shortcut", QKeySequence( "Alt+Shift+L" ) );
2296 logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
2302 \return default windows( Object Browser, Python Console )
2303 Adds to map \a aMap.
2305 void LightApp_Application::defaultWindows( QMap<int, int>& aMap ) const
2307 #ifndef DISABLE_PYCONSOLE
2308 aMap.insert( WT_PyConsole, Qt::BottomDockWidgetArea );
2310 if ( activeStudy() ) {
2311 aMap.insert( WT_ObjectBrowser, Qt::LeftDockWidgetArea );
2312 aMap.insert( WT_InfoPanel, Qt::RightDockWidgetArea );
2313 // aMap.insert( WT_LogWindow, Qt::DockBottom );
2317 /*!Default view managers*/
2318 void LightApp_Application::defaultViewManagers( QStringList& ) const
2324 \return preferences.
2325 Create preferences, if \a crt = true.
2327 LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const
2332 LightApp_Application* that = (LightApp_Application*)this;
2334 bool toCreate = !_prefs_ && crt;
2337 _prefs_ = new LightApp_Preferences( resourceMgr() );
2338 that->createPreferences( _prefs_ );
2339 qAddPostRoutine( LightAppCleanUpAppResources );
2342 that->myPrefs = _prefs_;
2344 connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
2345 this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ), Qt::UniqueConnection );
2346 connect( myPrefs, SIGNAL( resetToDefaults() ),
2347 this, SIGNAL( preferenceResetToDefaults() ), Qt::UniqueConnection );
2352 QList<SUIT_Application*> appList = SUIT_Session::session()->applications();
2353 for ( QList<SUIT_Application*>::iterator appIt = appList.begin(); appIt != appList.end(); ++appIt )
2355 LightApp_Application* app = ::qobject_cast<LightApp_Application*>( *appIt );
2359 // all modules available in current session
2361 app->modules( names, false );
2363 // step 1: iterate through list of all available modules
2364 // and add empty preferences page
2365 for ( QStringList::const_iterator it = names.begin(); it != names.end(); ++it )
2367 if ( !_prefs_->hasModule( *it ) ) // prevent possible duplications
2369 int modId = _prefs_->addPreference( *it ); // add empty page
2370 _prefs_->setItemIcon( modId, moduleIcon( *it, 20 ) ); // scale icon to 20x20 pix
2374 // step 2: iterate through list of all loaded modules
2375 // and initialize their preferences
2376 ModuleList loadedModules;
2377 app->modules( loadedModules );
2378 QListIterator<CAM_Module*> itr( loadedModules );
2379 while ( itr.hasNext() )
2381 LightApp_Module* module = 0;
2382 CAM_Module* m = itr.next();
2383 if ( m->inherits( "LightApp_Module" ) )
2384 module = (LightApp_Module*)m;
2386 if ( module && !_prefs_->hasModule( module->moduleName() ) )
2388 _prefs_->addPreference( module->moduleName() ); // add page (for sure, had to be done at step 1)
2389 module->createPreferences(); // initialize preferences
2390 that->emptyPreferences( module->moduleName() ); // show dummy page if module does not export any preferences
2394 _prefs_->setItemProperty( "info", tr( "PREFERENCES_NOT_LOADED" ) ); // dummy page for modules which are not loaded yet
2400 Adds new module to application
2402 void LightApp_Application::moduleAdded( CAM_Module* mod )
2404 CAM_Application::moduleAdded( mod );
2406 LightApp_Module* lightMod = 0;
2407 if ( mod && mod->inherits( "LightApp_Module" ) )
2408 lightMod = (LightApp_Module*)mod;
2410 if ( myPrefs && lightMod && !myPrefs->hasModule( lightMod->moduleName() ))
2412 myPrefs->addPreference( mod->moduleName() );
2413 lightMod->createPreferences();
2414 emptyPreferences( mod->moduleName() );
2418 void LightApp_Application::moduleDeactivated( CAM_Module* /*mod*/ )
2421 infoPanel()->clear();
2424 void LightApp_Application::emptyPreferences( const QString& modName )
2426 QtxPreferenceItem* item = myPrefs->findItem( modName, true );
2427 if ( !item || !item->isEmpty() )
2430 QtxPagePrefFrameItem* frm = new QtxPagePrefFrameItem( item->title(), item->parentItem() );
2431 frm->setIcon( item->icon() );
2432 frm->setStretch( false );
2433 item->parentItem()->insertItem( frm, item );
2434 new QtxPagePrefLabelItem( Qt::AlignCenter, tr( "PREFERENCES_NOT_SUPPORTED" ).arg( modName ), frm );
2441 void LightApp_Application::createPreferences( LightApp_Preferences* pref )
2446 QStringList aValuesList;
2447 QList<QVariant> anIndicesList;
2451 // . Top-level "SALOME" preferences group <<start>>
2452 int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
2453 pref->setItemIcon( salomeCat, Qtx::scaleIcon( resourceMgr()->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false ), 20 ) );
2455 // .. "General" preferences tab <<start>>
2456 int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat );
2458 // ... "Language" group <<start>>
2459 int langGroup = pref->addPreference( tr( "PREF_GROUP_LANGUAGE" ), genTab );
2460 pref->setItemProperty( "columns", 2, langGroup );
2461 // .... -> application language
2462 int curLang = pref->addPreference( tr( "PREF_CURRENT_LANGUAGE" ), langGroup,
2463 LightApp_Preferences::Selector, "language", "language" );
2464 QStringList aLangs = SUIT_Session::session()->resourceMgr()->stringValue( "language", "languages", "en" ).split( "," );
2465 QList<QVariant> aIcons;
2466 QList<QVariant> aNumbers;
2467 QStringList aTitles;
2468 foreach ( QString aLang, aLangs ) {
2469 aIcons << QPixmap( QString( ":/images/%1" ).arg( aLang ) );
2471 aTitles << langToName( aLang );
2473 pref->setItemProperty( "strings", aTitles, curLang );
2474 pref->setItemProperty( "ids", aNumbers, curLang );
2475 pref->setItemProperty( "icons", aIcons, curLang );
2476 pref->setItemProperty( "restart", true, curLang );
2478 int curLocale = pref->addPreference( tr( "PREF_CURRENT_LOCALE" ), langGroup,
2479 LightApp_Preferences::Bool, "language", "locale" );
2480 pref->setItemProperty( "restart", true, curLocale );
2481 // ... "Language" group <<end>>
2483 // ... "Look and feel" group <<start>>
2484 int lookGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), genTab );
2485 pref->setItemProperty( "columns", 2, lookGroup );
2486 // .... -> show splash-screen
2487 pref->addPreference( tr( "PREF_SHOW_SPLASH" ), lookGroup, LightApp_Preferences::Bool, "launch", "splash" );
2488 // .... -> opaque resize
2489 pref->addPreference( tr( "PREF_OPAQUE_RESIZE" ), lookGroup, LightApp_Preferences::Bool, "desktop", "opaque_resize" );
2490 // .... -> drop-down buttons
2491 pref->addPreference( tr( "PREF_DROP_DOWN_BUTTONS" ), lookGroup, LightApp_Preferences::Bool, "viewers", "drop_down_buttons" );
2492 // .... -> Notification timeout
2493 int delay = pref->addPreference( tr( "PREF_NOTIFY_TIMEOUT" ), lookGroup, LightApp_Preferences::IntSpin, "notification", "timeout" );
2494 pref->setItemProperty( "special", tr("PREF_NOTIFY_TIMEOUT_NONE"), delay );
2495 pref->setItemProperty( "min", 0, delay );
2496 pref->setItemProperty( "max", 100, delay );
2497 pref->setItemProperty( "suffix", " sec", delay );
2498 // ... "Look and feel" group <<end>>
2500 // ... "Study properties" group <<start>>
2501 int studyGroup = pref->addPreference( tr( "PREF_GROUP_STUDY" ), genTab );
2502 pref->setItemProperty( "columns", 2, studyGroup );
2503 // .... -> multi-file save
2504 pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "multi_file" );
2505 // .... -> ascii save mode
2506 pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" );
2507 // .... -> store windows geometry
2508 pref->addPreference( tr( "PREF_LOAD_LIGHT" ), studyGroup, LightApp_Preferences::Bool, "Study", "autoload_light_modules" );
2509 pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" );
2510 pref->addPreference( "", studyGroup, LightApp_Preferences::Space );
2511 pref->addPreference( tr( "PREF_STORE_TOOL_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_tool_positions" );
2512 // .... -> auto-save
2513 int autoSaveInterval = pref->addPreference( tr( "PREF_AUTO_SAVE" ), studyGroup,
2514 LightApp_Preferences::IntSpin, "Study", "auto_save_interval" );
2515 pref->setItemProperty( "min", 0, autoSaveInterval );
2516 pref->setItemProperty( "max", 1440, autoSaveInterval );
2517 pref->setItemProperty( "special", tr( "PREF_AUTO_SAVE_DISABLED" ), autoSaveInterval );
2518 // ... "Study properties" group <<end>>
2520 // ... "Help browser" group <<start>>
2521 #ifndef DISABLE_QTXWEBBROWSER
2522 int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab, LightApp_Preferences::Auto, "ExternalBrowser", "use_external_browser");
2524 int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab );
2528 QString platform = "winapplication";
2530 QString platform = "application";
2532 // .... -> browser application
2533 int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, LightApp_Preferences::File, "ExternalBrowser", platform );
2534 pref->setItemProperty( "mode", Qtx::PT_OpenFile, apppref );
2535 // .... -> browser parameters
2536 pref->addPreference( tr( "PREF_PARAM" ), extgroup, LightApp_Preferences::String, "ExternalBrowser", "parameters" );
2537 // ... "Help browser" group <<end>>
2539 // ... "Python console properties" group <<start>>
2540 int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab );
2541 pref->setItemProperty( "columns", 2, pythonConsoleGroup );
2543 pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, LightApp_Preferences::Font, "PyConsole", "font" );
2544 // .... -> show banner
2545 pref->addPreference( tr( "PREF_SHOW_BANNER" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "show_banner" );
2546 // .... -> auto-completion
2547 pref->addPreference( tr( "PREF_AUTO_COMPLETION" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "auto_completion" );
2548 // ... "Python console properties" group <<end>>
2550 // ... "MRU" preferences group <<start>>
2551 int mruGroup = pref->addPreference( tr( "PREF_GROUP_MRU" ), genTab, LightApp_Preferences::Auto, "MRU", "show_mru" );
2552 pref->setItemProperty( "columns", 4, mruGroup );
2553 // number of MRU items
2554 int mruVisCount = pref->addPreference( tr( "PREF_MRU_VISIBLE_COUNT" ), mruGroup, LightApp_Preferences::IntSpin,
2555 "MRU", "visible_count" );
2556 pref->setItemProperty( "min", 0, mruVisCount );
2557 pref->setItemProperty( "max", 100, mruVisCount );
2559 int mruLinkType = pref->addPreference( tr( "PREF_MRU_LINK_TYPE" ), mruGroup, LightApp_Preferences::Selector,
2560 "MRU", "link_type" );
2561 aValuesList.clear();
2562 anIndicesList.clear();
2563 aValuesList << tr("PREF_MRU_LINK_AUTO") << tr("PREF_MRU_LINK_SHORT") << tr("PREF_MRU_LINK_FULL");
2564 anIndicesList << 0 << 1 << 2 ;
2565 pref->setItemProperty( "strings", aValuesList, mruLinkType );
2566 pref->setItemProperty( "indexes", anIndicesList, mruLinkType );
2567 // ... "MRU" preferences group <<end>>
2569 // ... "Full-screen" group <<start>>
2570 int fullScreenGroup = pref->addPreference( tr( "PREF_GROUP_FULL_SCREEN" ), genTab );
2571 pref->setItemProperty( "columns", 2, fullScreenGroup );
2572 // .... -> automatic hiding toolbars
2573 pref->addPreference( tr( "PREF_FULL_SCREEN_AUTO" ), fullScreenGroup,
2574 LightApp_Preferences::Bool, "OCCViewer", "automatic_hiding" );
2575 // ... "Full-screen" group <<end>>
2577 // .. "General" preferences tab <<end>>
2579 // .. "3D viewer" group <<start>>
2580 int Viewer3DGroup = pref->addPreference( tr( "PREF_GROUP_3DVIEWER" ), salomeCat );
2581 // ... -> navigation mode
2582 int vtkStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), Viewer3DGroup,
2583 LightApp_Preferences::Selector, "3DViewer", "navigation_mode" );
2584 aValuesList.clear();
2585 anIndicesList.clear();
2586 aValuesList << tr("PREF_STANDARD_STYLE") << tr("PREF_KEYFREE_STYLE");
2587 anIndicesList << 0 << 1;
2588 pref->setItemProperty( "strings", aValuesList, vtkStyleMode );
2589 pref->setItemProperty( "indexes", anIndicesList, vtkStyleMode );
2590 // ... -> zooming mode
2591 int occZoomingStyleMode = pref->addPreference( tr( "PREF_ZOOMING" ), Viewer3DGroup,
2592 LightApp_Preferences::Selector, "3DViewer", "zooming_mode" );
2593 aValuesList.clear();
2594 anIndicesList.clear();
2595 aValuesList << tr("PREF_ZOOMING_AT_CENTER") << tr("PREF_ZOOMING_AT_CURSOR");
2596 anIndicesList << 0 << 1;
2597 pref->setItemProperty( "strings", aValuesList, occZoomingStyleMode );
2598 pref->setItemProperty( "indexes", anIndicesList, occZoomingStyleMode );
2599 // ... "Trihedron" group <<start>>
2600 int occTriGroup = pref->addPreference( tr( "PREF_TRIHEDRON" ), Viewer3DGroup );
2601 pref->setItemProperty( "columns", 2, occTriGroup );
2602 // .... -> trihedron size
2603 int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occTriGroup,
2604 LightApp_Preferences::DblSpin, "3DViewer", "trihedron_size" );
2605 pref->setItemProperty( "min", 1.0E-06, occTS );
2606 pref->setItemProperty( "max", 1000, occTS );
2607 // .... -> relative size of trihedron
2608 pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "relative_size" );
2609 // .... -> show static trihedron
2610 pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "show_static_trihedron" );
2611 // ... "Trihedron" group <<end>>
2612 // .. "3D viewer" group <<end>>
2616 #ifndef DISABLE_OCCVIEWER
2617 // .. "OCC viewer" group <<start>>
2618 int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), salomeCat );
2620 // .... -> Projection mode
2621 int occProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), occGroup,
2622 LightApp_Preferences::Selector, "OCCViewer", "projection_mode" );
2623 aValuesList.clear();
2624 anIndicesList.clear();
2625 aValuesList << tr("PREF_ORTHOGRAPHIC") << tr("PREF_PERSPECTIVE");
2626 anIndicesList << 0 << 1;
2627 pref->setItemProperty( "strings", aValuesList, occProjMode );
2628 pref->setItemProperty( "indexes", anIndicesList, occProjMode );
2630 // .... -> Stereo group
2631 int stereoGroup = pref->addPreference( tr( "PREF_GROUP_STEREO" ), occGroup);
2632 pref->setItemProperty( "columns", 2, stereoGroup );
2633 // .... -> Stereo type
2634 int stereoType = pref->addPreference( tr( "PREF_STEREO_TYPE" ), stereoGroup,
2635 LightApp_Preferences::Selector, "OCCViewer", "stereo_type" );
2636 aValuesList.clear();
2637 anIndicesList.clear();
2639 OCCViewer_Viewer::stereoData( aValuesList, idList);
2640 foreach( int gid, idList ) anIndicesList << gid;
2641 pref->setItemProperty( "strings", aValuesList, stereoType );
2642 pref->setItemProperty( "indexes", anIndicesList, stereoType );
2644 // .... -> Anaglyph filter
2645 int anaglyphFilter = pref->addPreference( tr( "PREF_ANAGLYPH_FILTER" ), stereoGroup,
2646 LightApp_Preferences::Selector, "OCCViewer", "anaglyph_filter" );
2647 aValuesList.clear();
2648 anIndicesList.clear();
2649 aValuesList << tr("PREF_ANAGLYPH_RED_CYAN") << tr("PREF_ANAGLYPH_YELLOW_BLUE") << tr("PREF_ANAGLYPH_GREEN_MAGENTA");
2650 anIndicesList << 0 << 1 << 2;
2652 pref->setItemProperty( "strings", aValuesList, anaglyphFilter );
2653 pref->setItemProperty( "indexes", anIndicesList, anaglyphFilter );
2655 // .... -> Convergence distance type
2656 int occFocusType = pref->addPreference( tr( "PREF_FOCUS_TYPE" ), stereoGroup,
2657 LightApp_Preferences::Selector, "OCCViewer", "focus_type" );
2658 aValuesList.clear();
2659 anIndicesList.clear();
2660 aValuesList << tr("PREF_ABSOLUTE") << tr("PREF_RELATIVE");
2661 anIndicesList << 0 << 1;
2662 pref->setItemProperty( "strings", aValuesList, occFocusType );
2663 pref->setItemProperty( "indexes", anIndicesList, occFocusType );
2665 // .... -> Stereographic focus value
2666 int focusValue = pref->addPreference( tr( "PREF_FOCUS_VALUE" ), stereoGroup,
2667 LightApp_Preferences::DblSpin, "OCCViewer", "focus_value" );
2668 pref->setItemProperty( "precision", 3, focusValue );
2669 pref->setItemProperty( "min", 1.0E-03, focusValue );
2670 pref->setItemProperty( "max", 1.0E03, focusValue );
2671 pref->setItemProperty( "step", 0.05, focusValue );
2674 int occIODType = pref->addPreference( tr( "PREF_IOD_TYPE" ), stereoGroup,
2675 LightApp_Preferences::Selector, "OCCViewer", "iod_type" );
2676 aValuesList.clear();
2677 anIndicesList.clear();
2678 aValuesList << tr("PREF_ABSOLUTE") << tr("PREF_RELATIVE");
2679 anIndicesList << 0 << 1;
2680 pref->setItemProperty( "strings", aValuesList, occIODType );
2681 pref->setItemProperty( "indexes", anIndicesList, occIODType );
2683 // .... -> Interocular distance (IOD) value
2684 int IODValue = pref->addPreference( tr( "PREF_IOD_VALUE" ), stereoGroup,
2685 LightApp_Preferences::DblSpin, "OCCViewer", "iod_value" );
2686 pref->setItemProperty( "precision", 3, IODValue );
2687 pref->setItemProperty( "min", 1.0E-03, IODValue );
2688 pref->setItemProperty( "max", 1.0E03, IODValue );
2689 pref->setItemProperty( "step", 0.05, IODValue );
2691 // .... -> Reverse stereo
2692 pref->addPreference( tr( "PREF_REVERSE_STEREO" ), stereoGroup,
2693 LightApp_Preferences::Bool, "OCCViewer", "reverse_stereo" );
2694 // .... -> Enable V-Sync
2695 pref->addPreference( tr( "PREF_ENABLE_VSYNC" ), stereoGroup,
2696 LightApp_Preferences::Bool, "OCCViewer", "enable_vsync" );
2697 // .... -> Enable quad-buffer support
2698 pref->addPreference( tr( "PREF_ENABLE_QUAD_BUFFER_SUPPORT" ), stereoGroup,
2699 LightApp_Preferences::Bool, "OCCViewer", "enable_quad_buffer_support" );
2701 // ... "Background" group <<start>>
2702 int bgGroup = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup );
2703 // pref->setItemProperty( "columns", 2, bgGroup );
2704 aValuesList.clear();
2705 anIndicesList.clear();
2708 formats = OCCViewer_Viewer::backgroundData( aValuesList, idList, txtList );
2709 foreach( int gid, idList ) anIndicesList << gid;
2710 // .... -> 3D viewer background
2711 bgId = pref->addPreference( tr( "PREF_3DVIEWER_BACKGROUND" ), bgGroup,
2712 LightApp_Preferences::Background, "OCCViewer", "background" );
2713 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2714 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2715 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2716 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2717 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2718 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2719 pref->setItemProperty( "custom_enabled", false, bgId );
2720 pref->setItemProperty( "image_formats", formats, bgId );
2721 // .... -> XZ viewer background
2722 bgId = pref->addPreference( tr( "PREF_XZVIEWER_BACKGROUND" ), bgGroup,
2723 LightApp_Preferences::Background, "OCCViewer", "xz_background" );
2724 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2725 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2726 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2727 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2728 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2729 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2730 pref->setItemProperty( "custom_enabled", false, bgId );
2731 pref->setItemProperty( "image_formats", formats, bgId );
2732 // .... -> YZ viewer background
2733 bgId = pref->addPreference( tr( "PREF_YZVIEWER_BACKGROUND" ), bgGroup,
2734 LightApp_Preferences::Background, "OCCViewer", "yz_background" );
2735 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2736 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2737 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2738 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2739 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2740 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2741 pref->setItemProperty( "custom_enabled", false, bgId );
2742 pref->setItemProperty( "image_formats", formats, bgId );
2743 // .... -> XY viewer background
2744 bgId = pref->addPreference( tr( "PREF_XYVIEWER_BACKGROUND" ), bgGroup,
2745 LightApp_Preferences::Background, "OCCViewer", "xy_background" );
2746 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2747 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2748 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2749 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2750 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2751 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2752 pref->setItemProperty( "custom_enabled", false, bgId );
2753 pref->setItemProperty( "image_formats", formats, bgId );
2754 // ... "Background" group <<end>>
2757 // ... "Selection" group <<start>>
2758 int occSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), occGroup );
2759 pref->setItemProperty( "columns", 3, occSelectionGroup );
2760 // .... -> enable preselection
2761 pref->addPreference( tr( "PREF_ENABLE_PRESELECTION" ), occSelectionGroup,
2762 LightApp_Preferences::Bool, "OCCViewer", "enable_preselection" );
2763 // .... -> enable selection
2764 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), occSelectionGroup,
2765 LightApp_Preferences::Bool, "OCCViewer", "enable_selection" );
2766 // .... -> selection style
2767 int aSeleStyle = pref->addPreference( tr( "PREF_SELECTION_STYLE" ), occSelectionGroup,
2768 LightApp_Preferences::Selector, "OCCViewer", "adv_selection_mode" );
2769 aValuesList.clear();
2770 anIndicesList.clear();
2771 aValuesList << tr("PREF_POLYGON_SELECTION") << tr("PREF_CIRCLE_SELECTION");
2772 anIndicesList << 0 << 1;
2773 pref->setItemProperty( "strings", aValuesList, aSeleStyle);
2774 pref->setItemProperty( "indexes", anIndicesList, aSeleStyle);
2775 // ... "Selection" group <<end>>
2777 // ... "Clipping" group <<start>>
2778 int occClippingGroup = pref->addPreference( tr( "PREF_GROUP_CLIPPING" ), occGroup );
2779 // .... -> clipping color
2780 pref->addPreference( tr( "PREF_CLIPPING_COLOR" ), occClippingGroup,
2781 LightApp_Preferences::Color, "OCCViewer", "clipping_color" );
2782 int texturePref = pref->addPreference( "", occClippingGroup, LightApp_Preferences::Frame );
2783 pref->setItemProperty( "columns", 2, texturePref );
2784 // .... -> use default texture
2785 pref->addPreference( tr( "PREF_CLIPPING_DEFAULT_TEXTURE" ), texturePref,
2786 LightApp_Preferences::Bool, "OCCViewer", "clipping_use_default_texture" );
2787 // .... -> clipping texture
2788 int filePref = pref->addPreference( tr( "PREF_CLIPPING_TEXTURE" ), texturePref,
2789 LightApp_Preferences::File, "OCCViewer", "clipping_texture" );
2790 pref->setItemProperty( "path_filter", tr( "OCC_TEXTURE_FILES" ), filePref );
2792 pref->addPreference( tr( "PREF_CLIPPING_MODULATE" ), texturePref,
2793 LightApp_Preferences::Bool, "OCCViewer", "clipping_modulate" );
2794 // .... -> scale factor
2795 int scaleFactor = pref->addPreference( tr( "PREF_CLIPPING_SCALE" ), texturePref,
2796 LightApp_Preferences::DblSpin, "OCCViewer", "clipping_scale" );
2797 pref->setItemProperty( "precision", 3, scaleFactor );
2798 pref->setItemProperty( "min", 1.0E-03, scaleFactor );
2799 pref->setItemProperty( "max", 1.0E03, scaleFactor );
2800 pref->setItemProperty( "step", 0.1, scaleFactor );
2801 // ... "Clipping" group <<end>>
2803 // ... "Ray tracing" group <<start>>
2804 int occRayTracingGroup = pref->addPreference( tr( "PREF_GROUP_RAY_TRACING" ), occGroup );
2805 int rtPref = pref->addPreference( "", occRayTracingGroup, LightApp_Preferences::Frame );
2806 pref->setItemProperty( "columns", 2, rtPref );
2808 int rt_depth = pref->addPreference( tr( "PREF_RAY_TRACING_DEPTH" ), rtPref,
2809 LightApp_Preferences::IntSpin, "OCCViewer", "rt_depth" );
2810 pref->setItemProperty( "min", 1, rt_depth );
2811 pref->setItemProperty( "max", 10, rt_depth );
2812 pref->setItemProperty( "step", 1, rt_depth );
2813 pref->addPreference( "", rtPref, LightApp_Preferences::Frame );
2814 // .... -> specular reflections
2815 pref->addPreference( tr( "PREF_RAY_TRACING_REFLECTION" ), rtPref,
2816 LightApp_Preferences::Bool, "OCCViewer", "rt_reflection" );
2817 // .... -> adaptive anti-aliasing
2818 pref->addPreference( tr( "PREF_RAY_TRACING_ANTIALIASING" ), rtPref,
2819 LightApp_Preferences::Bool, "OCCViewer", "rt_antialiasing" );
2820 // .... -> shadows rendering
2821 pref->addPreference( tr( "PREF_RAY_TRACING_SHADOW" ), rtPref,
2822 LightApp_Preferences::Bool, "OCCViewer", "rt_shadow" );
2823 // .... -> transparent shadow
2824 pref->addPreference( tr( "PREF_RAY_TRACING_TRANS_SHADOW" ), rtPref,
2825 LightApp_Preferences::Bool, "OCCViewer", "rt_trans_shadow" );
2826 // ... "Ray tracing" group <<end>>
2828 // ... "Light source" group <<start>>
2829 int occLightGroup = pref->addPreference( tr( "PREF_GROUP_LIGHT" ), occGroup );
2830 // .... -> light color
2831 pref->addPreference( tr( "PREF_LIGHT_COLOR" ), occLightGroup,
2832 LightApp_Preferences::Color, "OCCViewer", "light_color" );
2833 int directionPref = pref->addPreference( "", occLightGroup, LightApp_Preferences::Frame );
2834 pref->setItemProperty( "columns", 3, directionPref );
2835 // .... -> light direction (dx component)
2836 int light_dx = pref->addPreference( tr( "Dx" ), directionPref,
2837 LightApp_Preferences::DblSpin, "OCCViewer", "light_dx" );
2838 pref->setItemProperty( "precision", 2, light_dx );
2839 pref->setItemProperty( "min", -1.0E03, light_dx );
2840 pref->setItemProperty( "max", 1.0E03, light_dx );
2841 pref->setItemProperty( "step", 0.1, light_dx );
2842 // .... -> light direction (dy component)
2843 int light_dy = pref->addPreference( tr( "Dy" ), directionPref,
2844 LightApp_Preferences::DblSpin, "OCCViewer", "light_dy" );
2845 pref->setItemProperty( "precision", 2, light_dy );
2846 pref->setItemProperty( "min", -1.0E03, light_dy );
2847 pref->setItemProperty( "max", 1.0E03, light_dy );
2848 pref->setItemProperty( "step", 0.1, light_dy );
2849 // .... -> light direction (dz component)
2850 int light_dz = pref->addPreference( tr( "Dz" ), directionPref,
2851 LightApp_Preferences::DblSpin, "OCCViewer", "light_dz" );
2852 pref->setItemProperty( "precision", 2, light_dz );
2853 pref->setItemProperty( "min", -1.0E03, light_dz );
2854 pref->setItemProperty( "max", 1.0E03, light_dz );
2855 pref->setItemProperty( "step", 0.1, light_dz );
2856 // ... "Light source" group <<end>>
2858 // ... -> empty frame (for layout) <<start>>
2859 int occGen = pref->addPreference( "", occGroup, LightApp_Preferences::Frame );
2860 pref->setItemProperty( "margin", 0, occGen );
2861 pref->setItemProperty( "columns", 2, occGen );
2862 // ... -> empty frame (for layout) <<end>>
2864 // .. "OCC viewer" group <<end>>
2867 #ifndef DISABLE_VTKVIEWER
2868 // .. "VTK viewer" group <<start>>
2869 int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), salomeCat ); //viewTab
2871 // ... -> empty frame (for layout) <<start>>
2872 int vtkGen = pref->addPreference( "", vtkGroup, LightApp_Preferences::Frame );
2873 //pref->setItemProperty( "columns", 2, vtkGen );
2874 // .... -> projection mode
2875 int vtkProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), vtkGen,
2876 LightApp_Preferences::Selector, "VTKViewer", "projection_mode" );
2877 aValuesList.clear();
2878 anIndicesList.clear();
2879 aValuesList << tr("PREF_ORTHOGRAPHIC") << tr("PREF_PERSPECTIVE");
2880 anIndicesList << 0 << 1;
2881 pref->setItemProperty( "strings", aValuesList, vtkProjMode );
2882 pref->setItemProperty( "indexes", anIndicesList, vtkProjMode );
2884 // .... -> Stereo group
2885 int vtkStereoGroup = pref->addPreference( tr( "PREF_GROUP_STEREO" ), vtkGroup);
2886 pref->setItemProperty( "columns", 2, vtkStereoGroup );
2887 // .... -> Stereo type
2888 int vtkStereoType = pref->addPreference( tr( "PREF_STEREO_TYPE" ), vtkStereoGroup,
2889 LightApp_Preferences::Selector, "VTKViewer", "stereo_type" );
2890 aValuesList.clear();
2891 anIndicesList.clear();
2893 SVTK_Viewer::stereoData( aValuesList, idList);
2894 foreach( int gid, idList ) anIndicesList << gid;
2895 pref->setItemProperty( "strings", aValuesList, vtkStereoType );
2896 pref->setItemProperty( "indexes", anIndicesList, vtkStereoType );
2897 // .... -> Anaglyph filter
2898 int vtkAnaglyphFilter = pref->addPreference( tr( "PREF_ANAGLYPH_FILTER" ), vtkStereoGroup,
2899 LightApp_Preferences::Selector, "VTKViewer", "anaglyph_filter" );
2900 aValuesList.clear();
2901 anIndicesList.clear();
2902 aValuesList << tr("PREF_ANAGLYPH_RED_CYAN") << tr("PREF_ANAGLYPH_YELLOW_BLUE") << tr("PREF_ANAGLYPH_GREEN_MAGENTA");
2903 anIndicesList << 0 << 1 << 2;
2905 pref->setItemProperty( "strings", aValuesList, vtkAnaglyphFilter );
2906 pref->setItemProperty( "indexes", anIndicesList, vtkAnaglyphFilter );
2908 // .... -> Enable quad-buffer support
2909 pref->addPreference( tr( "PREF_ENABLE_QUAD_BUFFER_SUPPORT" ), vtkStereoGroup,
2910 LightApp_Preferences::Bool, "VTKViewer", "enable_quad_buffer_support" );
2912 // .... -> background
2913 aValuesList.clear();
2914 anIndicesList.clear();
2917 #ifndef DISABLE_SALOMEOBJECT
2918 formats = SVTK_Viewer::backgroundData( aValuesList, idList, txtList );
2920 foreach( int gid, idList ) anIndicesList << gid;
2921 bgId = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGen,
2922 LightApp_Preferences::Background, "VTKViewer", "background" );
2923 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2924 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2925 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2926 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2927 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2928 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2929 pref->setItemProperty( "custom_enabled", false, bgId );
2930 #ifndef DISABLE_SALOMEOBJECT
2931 pref->setItemProperty( "image_formats", formats, bgId );
2933 // .... -> speed increment
2934 int vtkSpeed = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED" ), vtkGen,
2935 LightApp_Preferences::IntSpin, "VTKViewer", "speed_value" );
2936 pref->setItemProperty( "min", 1, vtkSpeed );
2937 pref->setItemProperty( "max", 1000, vtkSpeed );
2938 // .... -> speed mode
2939 int vtkSpeedMode = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED_MODE" ), vtkGen,
2940 LightApp_Preferences::Selector, "VTKViewer", "speed_mode" );
2941 aValuesList.clear();
2942 anIndicesList.clear();
2943 aValuesList << tr("PREF_ARITHMETIC") << tr("PREF_GEOMETRICAL");
2944 anIndicesList << 0 << 1;
2945 pref->setItemProperty( "strings", aValuesList, vtkSpeedMode );
2946 pref->setItemProperty( "indexes", anIndicesList, vtkSpeedMode );
2948 // ... "Selection" group <<start>>
2949 int vtkSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), vtkGroup );
2950 pref->setItemProperty( "columns", 2, vtkSelectionGroup );
2951 // .... -> preselection
2952 int vtkPreselection = pref->addPreference( tr( "PREF_PRESELECTION" ), vtkSelectionGroup,
2953 LightApp_Preferences::Selector, "VTKViewer", "preselection" );
2954 aValuesList.clear();
2955 anIndicesList.clear();
2956 aValuesList << tr("PREF_PRESELECTION_STANDARD") << tr("PREF_PRESELECTION_DYNAMIC") << tr("PREF_PRESELECTION_DISABLED");
2957 anIndicesList << 0 << 1 << 2;
2958 pref->setItemProperty( "strings", aValuesList, vtkPreselection );
2959 pref->setItemProperty( "indexes", anIndicesList, vtkPreselection );
2960 // .... -> enable selection
2961 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), vtkSelectionGroup, LightApp_Preferences::Bool, "VTKViewer", "enable_selection" );
2962 // ... "Selection" group <<end>>
2964 // ... -> empty frame (for layout) <<end>>
2966 // ... space mouse sub-group <<start>>
2967 int vtkSM = pref->addPreference( tr( "PREF_FRAME_SPACEMOUSE" ), vtkGroup, LightApp_Preferences::GroupBox );
2968 //pref->setItemProperty( "columns", 2, vtkSM );
2969 // .... -> decrease speed increment
2970 int spacemousePref1 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_1" ), vtkSM,
2971 LightApp_Preferences::Selector, "VTKViewer",
2972 "spacemouse_func1_btn" );
2973 // .... -> increase speed increment
2974 int spacemousePref2 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_2" ), vtkSM,
2975 LightApp_Preferences::Selector, "VTKViewer",
2976 "spacemouse_func2_btn" );
2977 // .... -> dominant / combined switch
2978 int spacemousePref3 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_3" ), vtkSM,
2979 LightApp_Preferences::Selector, "VTKViewer",
2980 "spacemouse_func5_btn" ); //
2981 aValuesList.clear();
2982 anIndicesList.clear();
2983 aValuesList << tr( "PREF_SPACEMOUSE_BTN_1" ) << tr( "PREF_SPACEMOUSE_BTN_2" ) << tr( "PREF_SPACEMOUSE_BTN_3" );
2984 aValuesList << tr( "PREF_SPACEMOUSE_BTN_4" ) << tr( "PREF_SPACEMOUSE_BTN_5" ) << tr( "PREF_SPACEMOUSE_BTN_6" );
2985 aValuesList << tr( "PREF_SPACEMOUSE_BTN_7" ) << tr( "PREF_SPACEMOUSE_BTN_8" ) << tr( "PREF_SPACEMOUSE_BTN_*" );
2986 aValuesList << tr( "PREF_SPACEMOUSE_BTN_10" ) << tr( "PREF_SPACEMOUSE_BTN_11" );
2987 anIndicesList << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11;
2988 pref->setItemProperty( "strings", aValuesList, spacemousePref1 );
2989 pref->setItemProperty( "indexes", anIndicesList, spacemousePref1 );
2990 pref->setItemProperty( "strings", aValuesList, spacemousePref2 );
2991 pref->setItemProperty( "indexes", anIndicesList, spacemousePref2 );
2992 pref->setItemProperty( "strings", aValuesList, spacemousePref3 );
2993 pref->setItemProperty( "indexes", anIndicesList, spacemousePref3 );
2994 // ... space mouse sub-group <<end>>
2996 // ... avi recording sub-group <<start>>
2997 int vtkRec = pref->addPreference( tr( "PREF_FRAME_RECORDING" ), vtkGroup, LightApp_Preferences::GroupBox );
2998 pref->setItemProperty( "columns", 2, vtkRec );
2999 // .... -> recording mode
3000 int modePref = pref->addPreference( tr( "PREF_RECORDING_MODE" ), vtkRec,
3001 LightApp_Preferences::Selector, "VTKViewer", "recorder_mode" );
3002 aValuesList.clear();
3003 anIndicesList.clear();
3004 aValuesList << tr( "PREF_SKIPPED_FRAMES" ) << tr( "PREF_ALL_DISLPAYED_FRAMES" );
3005 anIndicesList << 0 << 1;
3006 pref->setItemProperty( "strings", aValuesList, modePref );
3007 pref->setItemProperty( "indexes", anIndicesList, modePref );
3009 int fpsPref = pref->addPreference( tr( "PREF_FPS" ), vtkRec,
3010 LightApp_Preferences::DblSpin, "VTKViewer", "recorder_fps" );
3011 pref->setItemProperty( "min", 0.1, fpsPref );
3012 pref->setItemProperty( "max", 100, fpsPref );
3014 int qualityPref = pref->addPreference( tr( "PREF_QUALITY" ), vtkRec,
3015 LightApp_Preferences::IntSpin, "VTKViewer", "recorder_quality" );
3016 pref->setItemProperty( "min", 1, qualityPref );
3017 pref->setItemProperty( "max", 100, qualityPref );
3018 // .... -> progressive mode
3019 pref->addPreference( tr( "PREF_PROGRESSIVE" ), vtkRec,
3020 LightApp_Preferences::Bool, "VTKViewer", "recorder_progressive" );
3021 // ... avi recording sub-group <<end>>
3023 // ... group names sub-group <<start>>
3024 int vtkGN = pref->addPreference( tr( "PREF_FRAME_GROUP_NAMES" ), vtkGroup,
3025 LightApp_Preferences::GroupBox, "VTKViewer", "show_group_names" );
3026 pref->setItemProperty( "columns", 2, vtkGN );
3027 // .... -> text color
3028 pref->addPreference( tr( "PREF_GROUP_NAMES_TEXT_COLOR" ), vtkGN,
3029 LightApp_Preferences::Color, "VTKViewer", "group_names_text_color" );
3030 // .... -> transparency
3031 int transPref = pref->addPreference( tr( "PREF_GROUP_NAMES_TRANSPARENCY" ), vtkGN,
3032 LightApp_Preferences::DblSpin, "VTKViewer", "group_names_transparency" );
3033 pref->setItemProperty( "min", 0.0, transPref );
3034 pref->setItemProperty( "max", 1.0, transPref );
3035 pref->setItemProperty( "step", 0.1, transPref );
3036 // ... -> group names sub-group <<end>>
3037 // .. "VTK viewer" group <<end>>
3040 // .. "Plot2d viewer" group <<start>>
3041 int plot2dGroup = pref->addPreference( tr( "PREF_GROUP_PLOT2DVIEWER" ), salomeCat ); //viewTab
3042 //pref->setItemProperty( "columns", 2, plot2dGroup );
3044 // ... -> background
3045 pref->addPreference( tr( "PREF_VIEWER_BACKGROUND_COLOR" ), plot2dGroup,
3046 LightApp_Preferences::Color, "Plot2d", "Background" );
3047 // ... -> selection color
3048 pref->addPreference( tr( "PREF_VIEWER_SELECTION" ), plot2dGroup,
3049 LightApp_Preferences::Color, "Plot2d", "SelectionColor" );
3051 // ... "Viewer" group <<start>>
3052 int plot2dViewerGroup = pref->addPreference( tr( "PREF_GROUP_VIEWER" ), plot2dGroup );
3054 // .... -> curve type
3055 int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dViewerGroup,
3056 LightApp_Preferences::Selector, "Plot2d", "CurveType" );
3057 aValuesList.clear();
3058 anIndicesList.clear();
3059 aValuesList << tr("PREF_POINTS") << tr("PREF_LINES") << tr("PREF_SPLINE");
3060 anIndicesList << 0 << 1 << 2 ;
3061 pref->setItemProperty( "strings", aValuesList, curveType );
3062 pref->setItemProperty( "indexes", anIndicesList, curveType );
3063 // .... -> marker size
3064 int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dViewerGroup,
3065 LightApp_Preferences::IntSpin, "Plot2d", "MarkerSize" );
3066 pref->setItemProperty( "min", 0, markerSize );
3067 pref->setItemProperty( "max", 100, markerSize );
3068 // .... -> horizontal scaling mode
3069 int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dViewerGroup,
3070 LightApp_Preferences::Selector, "Plot2d", "HorScaleMode" );
3071 aValuesList.clear();
3072 anIndicesList.clear();
3073 aValuesList << tr("PREF_LINEAR") << tr("PREF_LOGARITHMIC");
3074 anIndicesList << 0 << 1 ;
3075 pref->setItemProperty( "strings", aValuesList, horScale );
3076 pref->setItemProperty( "indexes", anIndicesList, horScale );
3077 // .... -> vertical scaling mode
3078 int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dViewerGroup,
3079 LightApp_Preferences::Selector, "Plot2d", "VerScaleMode" );
3080 pref->setItemProperty( "strings", aValuesList, verScale );
3081 pref->setItemProperty( "indexes", anIndicesList, verScale );
3083 // .... -> errors/deviation colot
3084 pref->addPreference( tr( "PREF_DEVIATION_COLOR" ), plot2dViewerGroup,
3085 LightApp_Preferences::Color, "Plot2d", "DeviationMarkerColor" );
3086 // .... -> deviation markers line size
3087 int deviationMarkerLw = pref->addPreference( tr( "PREF_DEVIATION_MARKER_LW" ), plot2dViewerGroup,
3088 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerLineWidth" );
3089 pref->setItemProperty( "min", 1, deviationMarkerLw );
3090 pref->setItemProperty( "max", 5, deviationMarkerLw );
3091 // .... -> deviation markers tick mark size
3092 int deviationMarkerTs = pref->addPreference( tr( "PREF_DEVIATION_MARKER_TS" ), plot2dViewerGroup,
3093 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerTickSize" );
3094 pref->setItemProperty( "min", 1, deviationMarkerTs );
3095 pref->setItemProperty( "max", 5, deviationMarkerTs );
3096 // .... "Viewer" group <<end>>
3098 // ... "Legend" group <<start>>
3099 int plot2dLegendGroup = pref->addPreference( tr( "PREF_GROUP_LEGEND" ), plot2dGroup );
3101 // .... -> show legend
3102 pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dLegendGroup,
3103 LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
3104 // .... -> legend position
3105 int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dLegendGroup,
3106 LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
3107 aValuesList.clear();
3108 anIndicesList.clear();
3109 aValuesList << tr("PREF_LEFT") << tr("PREF_RIGHT") << tr("PREF_TOP") << tr("PREF_BOTTOM");
3110 anIndicesList << 0 << 1 << 2 << 3 ;
3111 pref->setItemProperty( "strings", aValuesList, legendPosition );
3112 pref->setItemProperty( "indexes", anIndicesList, legendPosition );
3113 // .... -> Symbol type
3114 int legendSymbolType = pref->addPreference( tr( "PREF_LEGEND_SYMBOL_TYPE" ), plot2dLegendGroup,
3115 LightApp_Preferences::Selector, "Plot2d", "LegendSymbolType" );
3116 aValuesList.clear();
3117 anIndicesList.clear();
3118 aValuesList << tr("PREF_MARKER_ON_LINE") << tr("PREF_MARKER_ABOVE_LINE");
3119 anIndicesList << 0 << 1 ;
3120 pref->setItemProperty( "strings", aValuesList, legendSymbolType );
3121 pref->setItemProperty( "indexes", anIndicesList, legendSymbolType );
3122 // .... -> legend font
3123 pref->addPreference( tr( "PREF_LEGEND_FONT" ), plot2dLegendGroup, LightApp_Preferences::Font, "Plot2d", "LegendFont" );
3124 // ... -> font color
3125 pref->addPreference( tr( "PREF_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "LegendFontColor" );
3126 // ... -> selection font color
3127 pref->addPreference( tr( "PREF_SELECTED_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "SelectedLegendFontColor" );
3128 // ... "Legend" group <<end>>
3130 // .. "Plot2d viewer" group <<end>>
3132 // .. "PyViewer" preferences tab <<start>>
3133 int pyeditTab = pref->addPreference( tr( "PREF_TAB_PYEDITOR" ), salomeCat );
3134 // ... "Font settings" group <<start>>
3135 int pyFontGroup = pref->addPreference( tr( "PREF_GROUP_PY_FONT" ), pyeditTab );
3136 int pyFont = pref->addPreference( tr( "PREF_PY_FONT" ), pyFontGroup,
3137 LightApp_Preferences::Font, "PyEditor", "Font" );
3138 pref->setItemProperty( "features", QtxFontEdit::Family | QtxFontEdit::Size | QtxFontEdit::UserSize, pyFont );
3139 // ... "Font settings" group <<end>>
3140 // ... "Display settings" group <<start>>
3141 int pyDispGroup = pref->addPreference( tr( "PREF_GROUP_PY_DISPLAY" ), pyeditTab );
3142 pref->setItemProperty( "columns", 2, pyDispGroup );
3143 // ... -> current line highlight
3144 pref->addPreference( tr( "PREF_PY_CURRLINE_HIGHLIGHT" ), pyDispGroup,
3145 LightApp_Preferences::Bool, "PyEditor", "HighlightCurrentLine" );
3146 // ... -> text wrapping
3147 pref->addPreference( tr( "PREF_PY_TEXT_WRAP" ), pyDispGroup,
3148 LightApp_Preferences::Bool, "PyEditor", "TextWrapping" );
3149 // ... -> center cursor on scroll
3150 pref->addPreference( tr( "PREF_PY_CURSON_ON_SCROLL" ), pyDispGroup,
3151 LightApp_Preferences::Bool, "PyEditor", "CenterCursorOnScroll" );
3152 // ... -> line numbers area
3153 pref->addPreference( tr( "PREF_PY_LINE_NUMBS_AREA" ), pyDispGroup,
3154 LightApp_Preferences::Bool, "PyEditor", "LineNumberArea" );
3155 // ... "Display settings" group <<end>>
3157 // ... "Editor settings" group <<start>>
3158 int pyEditGroup = pref->addPreference( tr( "PREF_GROUP_PY_EDITOR" ), pyeditTab );
3159 // ... -> navigation mode
3160 int pyCompletion = pref->addPreference( tr( "PREF_PY_COMPLETION_MODE" ), pyEditGroup,
3161 LightApp_Preferences::Selector, "PyEditor", "CompletionPolicy" );
3162 aValuesList.clear();
3163 anIndicesList.clear();
3164 aValuesList << tr("PREF_PY_NONE") << tr("PREF_PY_AUTO") << tr("PREF_PY_MANUAL") << tr("PREF_PY_ALWAYS");
3165 anIndicesList << 0 << 1 << 2 << 3 ;
3166 pref->setItemProperty( "strings", aValuesList, pyCompletion );
3167 pref->setItemProperty( "indexes", anIndicesList, pyCompletion );
3168 // ... "Editor settings" group <<end>>
3170 // ... "Tab settings" group <<start>>
3171 int pyTabGroup = pref->addPreference( tr( "PREF_GROUP_PY_TAB" ), pyeditTab );
3172 pref->setItemProperty( "columns", 2, pyTabGroup );
3173 // ... -> tab whitespaces
3174 pref->addPreference( tr( "PREF_PY_TAB_WHITESPACES" ), pyTabGroup,
3175 LightApp_Preferences::Bool, "PyEditor", "TabSpaceVisible" );
3177 pref->addPreference( tr( "PREF_PY_TAB_SIZE" ), pyTabGroup,
3178 LightApp_Preferences::IntSpin, "PyEditor", "TabSize" );
3179 // ... "Tab settings" group <<end>>
3180 // ... "Vertical edge settings" group <<start>>
3181 int pyVertEdgeGroup = pref->addPreference( tr( "PREF_GROUP_VERT_EDGE" ), pyeditTab );
3182 pref->setItemProperty( "columns", 2, pyVertEdgeGroup );
3183 // ... -> vertical edge
3184 pref->addPreference( tr( "PREF_PY_VERT_EDGE" ), pyVertEdgeGroup,
3185 LightApp_Preferences::Bool, "PyEditor", "VerticalEdge" );
3186 // ... -> number of columns
3187 pref->addPreference( tr( "PREF_PY_NUM_COLUMNS" ), pyVertEdgeGroup,
3188 LightApp_Preferences::IntSpin, "PyEditor", "NumberColumns" );
3189 // ... "Vertical edge settings" group <<end>>
3190 // .. "PyEditor" preferences tab <<end>>
3192 // .. "Directories" preferences tab <<start>>
3193 int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat );
3194 // ... --> quick directories list
3195 int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab );
3196 pref->addPreference( tr( "" ), dirGroup,
3197 LightApp_Preferences::DirList, "FileDlg", "QuickDirList" );
3198 // .. "Directories" preferences tab <<end>>
3200 // .. "Object browser" preferences tab <<start>>
3201 int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
3203 // ... "Search tool" group <<start>>
3204 int stGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SEARCH_TOOL" ), obTab );
3205 // .... --> auto-hide
3206 pref->addPreference( tr( "PREF_AUTO_HIDE_SEARCH_TOOL" ), stGroup, LightApp_Preferences::Bool,
3207 "ObjectBrowser", "auto_hide_search_tool" );
3208 // ... "Search tool" group <<end>>
3210 // ... "Object browser settings" group <<start>>
3211 int objSetGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), obTab );
3212 pref->setItemProperty( "columns", 2, objSetGroup );
3213 // .... -> auto size first column
3214 pref->addPreference( tr( "PREF_AUTO_SIZE_FIRST" ), objSetGroup, LightApp_Preferences::Bool,
3215 "ObjectBrowser", "auto_size_first" );
3216 // .... -> auto size other columns
3217 pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool,
3218 "ObjectBrowser", "auto_size" );
3219 // .... -> resize columns on expand item
3220 pref->addPreference( tr( "PREF_RESIZE_ON_EXPAND_ITEM" ), objSetGroup, LightApp_Preferences::Bool,
3221 "ObjectBrowser", "resize_on_expand_item" );
3222 // .... -> browse to published object
3223 int browsePublished = pref->addPreference( tr( "PREF_BROWSE_TO_THE_PUBLISHED_OBJECT" ), objSetGroup, LightApp_Preferences::Selector,
3224 "ObjectBrowser", "browse_published_object" );
3225 aValuesList.clear();
3226 anIndicesList.clear();
3227 aValuesList << tr( "PREF_BROWSE_NEVER" ) << tr( "PREF_BROWSE_AFTER_APPLY_AND_CLOSE_ONLY" ) << tr( "PREF_BROWSE_ALWAYS" );
3228 anIndicesList << BP_Never << BP_ApplyAndClose << BP_Always;
3229 pref->setItemProperty( "strings", aValuesList, browsePublished );
3230 pref->setItemProperty( "indexes", anIndicesList, browsePublished );
3231 // ... "Object browser settings" group <<end>>
3232 // .. "Object browser" preferences tab <<end>>
3234 // .. "Shortcuts" preferences tab <<start>>
3235 int shortcutTab = pref->addPreference( tr( "PREF_TAB_SHORTCUTS" ), salomeCat );
3236 // ... "Shortcuts settings" group <<start>>
3237 int shortcutGroup = pref->addPreference( tr( "PREF_GROUP_SHORTCUTS" ), shortcutTab );
3238 pref->addPreference( tr( "" ), shortcutGroup,
3239 LightApp_Preferences::ShortcutTree, "shortcuts" );
3240 // ... "Shortcuts settings" group <<end>>
3241 // .. "Shortcuts" preferences tab <<end>>
3242 // . Top-level "SALOME" preferences group <<end>>
3248 Changes appearance of application according to changed preferences
3249 \param sec - section
3250 \param param - name of changed parameter
3252 void LightApp_Application::preferencesChanged( const QString& sec, const QString& param )
3254 SUIT_ResourceMgr* resMgr = resourceMgr();
3258 if ( sec == "viewers" && param == "drop_down_buttons" )
3260 ViewManagerList vmlist = viewManagers();
3261 foreach( SUIT_ViewManager* vm, vmlist )
3263 QVector<SUIT_ViewWindow*> vwlist = vm->getViews();
3264 foreach( SUIT_ViewWindow* vw, vwlist )
3265 if ( vw ) vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
3269 if ( sec == QString( "3DViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )))
3271 double sz = resMgr->doubleValue( sec, "trihedron_size", -1 );
3272 bool relative = resMgr->booleanValue( sec, "relative_size", true );
3273 QList<SUIT_ViewManager*> lst;
3274 #ifndef DISABLE_OCCVIEWER
3275 viewManagers( OCCViewer_Viewer::Type(), lst );
3276 QListIterator<SUIT_ViewManager*> itOCC( lst );
3277 while ( itOCC.hasNext() && sz >= 0 )
3279 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3280 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3283 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3284 occVM->setTrihedronSize( sz, relative );
3285 occVM->getAISContext()->UpdateCurrentViewer();
3288 #ifndef DISABLE_VTKVIEWER
3289 #ifndef DISABLE_SALOMEOBJECT
3290 viewManagers( SVTK_Viewer::Type(), lst );
3291 QListIterator<SUIT_ViewManager*> itVTK( lst );
3292 while ( itVTK.hasNext() && sz >= 0 )
3294 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3295 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3298 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3301 vtkVM->setTrihedronSize( sz, relative );
3309 if ( sec == QString( "3DViewer" ) && param == QString( "show_static_trihedron" ) )
3311 bool isVisible = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
3312 QList<SUIT_ViewManager*> lst;
3313 #ifndef DISABLE_OCCVIEWER
3314 viewManagers( OCCViewer_Viewer::Type(), lst );
3315 QListIterator<SUIT_ViewManager*> itOCC( lst );
3316 while ( itOCC.hasNext() )
3318 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3319 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3322 OCCViewer_Viewer* occVM = dynamic_cast<OCCViewer_Viewer*>( vm );
3325 occVM->setStaticTrihedronDisplayed( isVisible );
3329 #ifndef DISABLE_VTKVIEWER
3330 #ifndef DISABLE_SALOMEOBJECT
3331 viewManagers( SVTK_Viewer::Type(), lst );
3332 QListIterator<SUIT_ViewManager*> itVTK( lst );
3333 while ( itVTK.hasNext() )
3335 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3336 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3339 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3342 vtkVM->setStaticTrihedronVisible( isVisible );
3350 if ( sec == QString( "3DViewer" ) && param == QString( "navigation_mode" ) )
3352 int mode = resMgr->integerValue( "3DViewer", "navigation_mode", 0 );
3353 QList<SUIT_ViewManager*> lst;
3354 #ifndef DISABLE_OCCVIEWER
3355 viewManagers( OCCViewer_Viewer::Type(), lst );
3356 QListIterator<SUIT_ViewManager*> itOCC( lst );
3357 while ( itOCC.hasNext() )
3359 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3360 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3363 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3364 occVM->setInteractionStyle( mode );
3367 #ifndef DISABLE_VTKVIEWER
3368 #ifndef DISABLE_SALOMEOBJECT
3369 viewManagers( SVTK_Viewer::Type(), lst );
3370 QListIterator<SUIT_ViewManager*> itVTK( lst );
3371 while ( itVTK.hasNext() )
3373 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3374 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3377 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3378 if( vtkVM ) vtkVM->setInteractionStyle( mode );
3384 #ifndef DISABLE_OCCVIEWER
3385 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_preselection" ) )
3387 bool isToEnablePreselection = resMgr->booleanValue( "OCCViewer", "enable_preselection", true );
3388 QList<SUIT_ViewManager*> lst;
3389 viewManagers( OCCViewer_Viewer::Type(), lst );
3390 QListIterator<SUIT_ViewManager*> it( lst );
3391 while ( it.hasNext() )
3393 SUIT_ViewModel* vm = it.next()->getViewModel();
3394 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3397 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3398 occVM->enablePreselection( isToEnablePreselection );
3403 #ifndef DISABLE_OCCVIEWER
3404 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_selection" ) )
3406 bool isToEnableSelection = resMgr->booleanValue( "OCCViewer", "enable_selection", true );
3407 QList<SUIT_ViewManager*> lst;
3408 viewManagers( OCCViewer_Viewer::Type(), lst );
3409 QListIterator<SUIT_ViewManager*> it( lst );
3410 while ( it.hasNext() )
3412 SUIT_ViewModel* vm = it.next()->getViewModel();
3413 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3416 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3417 occVM->enableSelection( isToEnableSelection );
3422 #ifndef DISABLE_OCCVIEWER
3423 if ( sec == QString( "OCCViewer" ) && param == QString( "clipping_color" ) )
3425 QColor aColor = resMgr->colorValue( "OCCViewer", "clipping_color", QColor( 50, 50, 50 ) );
3426 QList<SUIT_ViewManager*> lst;
3427 viewManagers( OCCViewer_Viewer::Type(), lst );
3428 QListIterator<SUIT_ViewManager*> it( lst );
3429 while ( it.hasNext() )
3431 SUIT_ViewModel* vm = it.next()->getViewModel();
3432 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3435 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3436 occVM->setClippingColor( aColor );
3441 #ifndef DISABLE_OCCVIEWER
3442 if ( sec == QString( "OCCViewer" ) && ( param == QString( "clipping_use_default_texture" ) ||
3443 param == QString( "clipping_texture" ) ||
3444 param == QString( "clipping_modulate" ) ||
3445 param == QString( "clipping_scale" ) ) )
3447 bool isDefaultTextureUsed = resMgr->booleanValue( "OCCViewer", "clipping_use_default_texture" );
3448 QString aTexture = resMgr->stringValue( "OCCViewer", "clipping_texture" );
3449 bool isModulated = resMgr->booleanValue( "OCCViewer", "clipping_modulate" );
3450 double aScale = resMgr->doubleValue( "OCCViewer", "clipping_scale" );
3451 QList<SUIT_ViewManager*> lst;
3452 viewManagers( OCCViewer_Viewer::Type(), lst );
3453 QListIterator<SUIT_ViewManager*> it( lst );
3454 while ( it.hasNext() )
3456 SUIT_ViewModel* vm = it.next()->getViewModel();
3457 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3460 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3461 occVM->setClippingTextureParams( isDefaultTextureUsed, aTexture, isModulated, aScale );
3466 #ifndef DISABLE_OCCVIEWER
3467 if ( sec == QString( "OCCViewer" ) && param == QString( "projection_mode" ) )
3469 int mode = resMgr->integerValue( "OCCViewer", "projection_mode", 0 );
3470 QList<SUIT_ViewManager*> lst;
3471 viewManagers( OCCViewer_Viewer::Type(), lst );
3472 QListIterator<SUIT_ViewManager*> it( lst );
3473 while ( it.hasNext() )
3475 SUIT_ViewModel* vm = it.next()->getViewModel();
3476 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3479 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3480 occVM->setProjectionType( mode );
3486 #ifndef DISABLE_OCCVIEWER
3487 if (sec == QString("OCCViewer") && param == QString("adv_selection_mode"))
3489 int mode = resMgr->integerValue("OCCViewer", "adv_selection_mode", 0);
3490 QList<SUIT_ViewManager*> lst;
3491 viewManagers(OCCViewer_Viewer::Type(), lst);
3492 QListIterator<SUIT_ViewManager*> it(lst);
3493 while (it.hasNext())
3495 SUIT_ViewModel* vm = it.next()->getViewModel();
3496 if (!vm || !vm->inherits("OCCViewer_Viewer"))
3499 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3500 occVM->setSelectionStyle((OCCViewer_ViewWindow::SelectionStyle)mode);
3506 #ifndef DISABLE_OCCVIEWER
3507 if ( sec == QString( "OCCViewer" ) && param == QString( "stereo_type" ) )
3509 int mode = resMgr->integerValue( "OCCViewer", "stereo_type", 0 );
3510 QList<SUIT_ViewManager*> lst;
3511 viewManagers( OCCViewer_Viewer::Type(), lst );
3512 QListIterator<SUIT_ViewManager*> it( lst );
3513 while ( it.hasNext() )
3515 SUIT_ViewModel* vm = it.next()->getViewModel();
3516 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3519 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3520 occVM->setStereoType( mode );
3525 #ifndef DISABLE_OCCVIEWER
3526 if ( sec == QString( "OCCViewer" ) && param == QString( "anaglyph_filter" ) )
3528 int mode = resMgr->integerValue( "OCCViewer", "anaglyph_filter", 0 );
3529 QList<SUIT_ViewManager*> lst;
3530 viewManagers( OCCViewer_Viewer::Type(), lst );
3531 QListIterator<SUIT_ViewManager*> it( lst );
3532 while ( it.hasNext() )
3534 SUIT_ViewModel* vm = it.next()->getViewModel();
3535 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3538 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3539 occVM->setAnaglyphFilter( mode );
3544 #ifndef DISABLE_OCCVIEWER
3545 if ( sec == QString( "OCCViewer" ) && ( param == QString( "focus_type" ) ||
3546 param == QString( "focus_value" ) ) )
3548 int aType = resMgr->integerValue( "OCCViewer", "focus_type" );
3549 double aValue = resMgr->doubleValue( "OCCViewer", "focus_value" );
3550 QList<SUIT_ViewManager*> lst;
3551 viewManagers( OCCViewer_Viewer::Type(), lst );
3552 QListIterator<SUIT_ViewManager*> it( lst );
3553 while ( it.hasNext() )
3555 SUIT_ViewModel* vm = it.next()->getViewModel();
3556 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3559 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3560 occVM->setStereographicFocus( aType, aValue );
3565 #ifndef DISABLE_OCCVIEWER
3566 if ( sec == QString( "OCCViewer" ) && ( param == QString( "iod_type" ) ||
3567 param == QString( "iod_value" ) ) )
3569 int aType = resMgr->integerValue( "OCCViewer", "iod_type" );
3570 double aValue = resMgr->doubleValue( "OCCViewer", "iod_value" );
3571 QList<SUIT_ViewManager*> lst;
3572 viewManagers( OCCViewer_Viewer::Type(), lst );
3573 QListIterator<SUIT_ViewManager*> it( lst );
3574 while ( it.hasNext() )
3576 SUIT_ViewModel* vm = it.next()->getViewModel();
3577 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3580 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3581 occVM->setInterocularDistance( aType, aValue );
3586 #ifndef DISABLE_OCCVIEWER
3587 if ( sec == QString( "OCCViewer" ) && param == QString( "reverse_stereo" ) )
3589 bool reverse = resMgr->booleanValue( "OCCViewer", "reverse_stereo", false );
3590 QList<SUIT_ViewManager*> lst;
3591 viewManagers( OCCViewer_Viewer::Type(), lst );
3592 QListIterator<SUIT_ViewManager*> it( lst );
3593 while ( it.hasNext() )
3595 SUIT_ViewModel* vm = it.next()->getViewModel();
3596 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3599 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3600 occVM->setReverseStereo( reverse );
3605 #ifndef DISABLE_OCCVIEWER
3606 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_vsync" ) )
3608 bool enable = resMgr->booleanValue( "OCCViewer", "enable_vsync", true );
3609 QList<SUIT_ViewManager*> lst;
3610 viewManagers( OCCViewer_Viewer::Type(), lst );
3611 QListIterator<SUIT_ViewManager*> it( lst );
3612 while ( it.hasNext() )
3614 SUIT_ViewModel* vm = it.next()->getViewModel();
3615 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3618 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3619 occVM->setVSync( enable );
3624 #ifndef DISABLE_OCCVIEWER
3625 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_quad_buffer_support" ) )
3627 bool enable = resMgr->booleanValue( "OCCViewer", "enable_quad_buffer_support", false );
3628 QList<SUIT_ViewManager*> lst;
3629 viewManagers( OCCViewer_Viewer::Type(), lst );
3630 QListIterator<SUIT_ViewManager*> it( lst );
3631 while ( it.hasNext() )
3633 SUIT_ViewModel* vm = it.next()->getViewModel();
3634 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3637 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3638 occVM->setQuadBufferSupport( enable );
3643 if ( sec == QString( "3DViewer" ) && param == QString( "zooming_mode" ) )
3645 int mode = resMgr->integerValue( "3DViewer", "zooming_mode", 0 );
3646 QList<SUIT_ViewManager*> lst;
3647 #ifndef DISABLE_OCCVIEWER
3648 viewManagers( OCCViewer_Viewer::Type(), lst );
3649 QListIterator<SUIT_ViewManager*> itOCC( lst );
3650 while ( itOCC.hasNext() )
3652 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3653 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3656 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3657 occVM->setZoomingStyle( mode );
3660 #ifndef DISABLE_VTKVIEWER
3661 #ifndef DISABLE_SALOMEOBJECT
3662 viewManagers( SVTK_Viewer::Type(), lst );
3663 QListIterator<SUIT_ViewManager*> itVTK( lst );
3664 while ( itVTK.hasNext() )
3666 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3667 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3670 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3671 if( vtkVM ) vtkVM->setZoomingStyle( mode );
3677 #ifndef DISABLE_VTKVIEWER
3678 if ( sec == QString( "VTKViewer" ) && (param == QString( "speed_value" ) || param == QString( "speed_mode" )) )
3680 int speed = resMgr->integerValue( "VTKViewer", "speed_value", 10 );
3681 int mode = resMgr->integerValue( "VTKViewer", "speed_mode", 0 );
3682 QList<SUIT_ViewManager*> lst;
3683 #ifndef DISABLE_SALOMEOBJECT
3684 viewManagers( SVTK_Viewer::Type(), lst );
3685 QListIterator<SUIT_ViewManager*> it( lst );
3686 while ( it.hasNext() )
3688 SUIT_ViewModel* vm = it.next()->getViewModel();
3689 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3692 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3693 if( vtkVM ) vtkVM->setIncrementalSpeed( speed, mode );
3699 #ifndef DISABLE_VTKVIEWER
3700 if ( sec == QString( "VTKViewer" ) && param == QString( "projection_mode" ) )
3702 int mode = resMgr->integerValue( "VTKViewer", "projection_mode", 0 );
3703 QList<SUIT_ViewManager*> lst;
3704 #ifndef DISABLE_SALOMEOBJECT
3705 viewManagers( SVTK_Viewer::Type(), lst );
3706 QListIterator<SUIT_ViewManager*> it( lst );
3707 while ( it.hasNext() )
3709 SUIT_ViewModel* vm = it.next()->getViewModel();
3710 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3713 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3714 if( vtkVM ) vtkVM->setProjectionMode( mode );
3720 #ifndef DISABLE_VTKVIEWER
3721 if ( sec == QString( "VTKViewer" ) && param == QString( "stereo_type" ) )
3723 int mode = resMgr->integerValue( "VTKViewer", "stereo_type", 0 );
3724 QList<SUIT_ViewManager*> lst;
3725 #ifndef DISABLE_SALOMEOBJECT
3726 viewManagers( SVTK_Viewer::Type(), lst );
3727 QListIterator<SUIT_ViewManager*> it( lst );
3728 while ( it.hasNext() )
3730 SUIT_ViewModel* vm = it.next()->getViewModel();
3731 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3734 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3735 if( vtkVM ) vtkVM->setStereoType( mode );
3741 #ifndef DISABLE_VTKVIEWER
3742 if ( sec == QString( "VTKViewer" ) && param == QString( "anaglyph_filter" ) )
3744 int mode = resMgr->integerValue( "VTKViewer", "anaglyph_filter", 0 );
3745 QList<SUIT_ViewManager*> lst;
3746 #ifndef DISABLE_SALOMEOBJECT
3747 viewManagers( SVTK_Viewer::Type(), lst );
3748 QListIterator<SUIT_ViewManager*> it( lst );
3749 while ( it.hasNext() )
3751 SUIT_ViewModel* vm = it.next()->getViewModel();
3752 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3755 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3756 if( vtkVM ) vtkVM->setAnaglyphFilter( mode );
3762 #ifndef DISABLE_VTKVIEWER
3763 if ( sec == QString( "VTKViewer" ) && param == QString( "enable_quad_buffer_support" ) )
3765 int enable = resMgr->booleanValue( "VTKViewer", "enable_quad_buffer_support", false );
3766 QList<SUIT_ViewManager*> lst;
3767 #ifndef DISABLE_SALOMEOBJECT
3768 viewManagers( SVTK_Viewer::Type(), lst );
3769 QListIterator<SUIT_ViewManager*> it( lst );
3770 while ( it.hasNext() )
3772 SUIT_ViewModel* vm = it.next()->getViewModel();
3773 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3776 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3777 if( vtkVM ) vtkVM->setQuadBufferSupport( enable );
3783 #ifndef DISABLE_VTKVIEWER
3784 if ( sec == QString( "VTKViewer" ) && param == QString( "preselection" ) )
3786 int mode = resMgr->integerValue( "VTKViewer", "preselection", 0 );
3787 QList<SUIT_ViewManager*> lst;
3788 #ifndef DISABLE_SALOMEOBJECT
3789 viewManagers( SVTK_Viewer::Type(), lst );
3790 QListIterator<SUIT_ViewManager*> it( lst );
3791 while ( it.hasNext() )
3793 SUIT_ViewModel* vm = it.next()->getViewModel();
3794 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3797 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3798 if( vtkVM ) vtkVM->setPreSelectionMode( mode );
3804 #ifndef DISABLE_VTKVIEWER
3805 if ( sec == QString( "VTKViewer" ) && param == QString( "enable_selection" ) )
3807 bool isToEnableSelection = resMgr->booleanValue( "VTKViewer", "enable_selection", true );
3808 QList<SUIT_ViewManager*> lst;
3809 #ifndef DISABLE_SALOMEOBJECT
3810 viewManagers( SVTK_Viewer::Type(), lst );
3811 QListIterator<SUIT_ViewManager*> it( lst );
3812 while ( it.hasNext() )
3814 SUIT_ViewModel* vm = it.next()->getViewModel();
3815 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3818 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3819 if( vtkVM ) vtkVM->enableSelection( isToEnableSelection );
3825 #ifndef DISABLE_VTKVIEWER
3826 if ( sec == QString( "VTKViewer" ) && (param == QString( "spacemouse_func1_btn" ) ||
3827 param == QString( "spacemouse_func2_btn" ) ||
3828 param == QString( "spacemouse_func5_btn" ) ) )
3830 int btn1 = resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", 1 );
3831 int btn2 = resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", 2 );
3832 int btn3 = resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", 9 );
3833 QList<SUIT_ViewManager*> lst;
3834 #ifndef DISABLE_SALOMEOBJECT
3835 viewManagers( SVTK_Viewer::Type(), lst );
3836 QListIterator<SUIT_ViewManager*> it( lst );
3837 while ( it.hasNext() )
3839 SUIT_ViewModel* vm = it.next()->getViewModel();
3840 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3843 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3844 if( vtkVM ) vtkVM->setSpacemouseButtons( btn1, btn2, btn3 );
3849 if( sec=="ObjectBrowser" )
3851 SUIT_DataBrowser* ob = objectBrowser();
3855 if ( param=="auto_size_first" )
3857 bool autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
3858 ob->setAutoSizeFirstColumn( autoSizeFirst );
3859 if ( autoSizeFirst )
3860 ob->adjustFirstColumnWidth();
3862 else if ( param=="auto_size" ) {
3863 bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
3864 ob->setAutoSizeColumns(autoSize);
3866 ob->adjustColumnsWidth();
3868 else if ( param=="resize_on_expand_item" ) {
3869 bool resizeOnExpandItem = resMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
3870 ob->setResizeOnExpandItem(resizeOnExpandItem);
3872 else if ( param == "auto_hide_search_tool" ) {
3873 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
3879 if( param=="auto_save_interval" ) {
3880 myAutoSaveTimer->stop();
3881 int autoSaveInterval = resMgr->integerValue( "Study", "auto_save_interval", 0 );
3882 if ( activeStudy() && autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
3886 #ifndef DISABLE_PYCONSOLE
3887 if( sec=="PyConsole" && pythonConsole() )
3889 if ( param=="font" ) {
3890 pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) );
3892 else if ( param=="show_banner" ) {
3893 pythonConsole()->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
3895 else if ( param=="auto_completion" ) {
3896 pythonConsole()->setAutoCompletion( resMgr->booleanValue( "PyConsole", "auto_completion", true ) );
3903 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3905 if ( param == "visible_count" )
3906 mru->setVisibleCount( resMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
3907 else if ( param == "max_count" )
3908 mru->setHistoryCount( resMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
3909 else if ( param == "insert_mode" )
3910 mru->setInsertMode( resMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
3911 else if ( param == "link_type" )
3912 mru->setLinkType( resMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
3913 else if ( param == "show_clear" )
3914 mru->setClearPossible( resMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
3915 else if ( param == "show_mru" )
3916 mru->setVisible( resMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
3919 if ( sec == "language" && param == "language" )
3921 // VSR 18.06.2015 : commented out : single warning dialog box is now shown by the LightApp_PreferencesDlg
3922 //SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LANG_CHANGED" ) );
3924 if ( sec == "language" && param == "locale")
3926 // VSR 18.06.2015: commented out : single warning dialog box is now shown by the LightApp_PreferencesDlg
3927 //SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LOCALE_CHANGED" ) );
3929 if ( sec == "desktop" && param == "opaque_resize" ) {
3930 bool opaqueResize = resMgr->booleanValue( "desktop", "opaque_resize", false );
3931 // RNV: This code has been commented, because clearing of the QMainWindow::AnimatedDocks option
3932 // leads to strange behaviour of the dockable windows (at least at qt-5.6.1):
3933 // any dockable window can't be docked to the another area, except initial area.
3934 // It is possible to move window to another area, but it always returns to the initial area.
3936 // QMainWindow::DockOptions dopts = desktop()->dockOptions();
3937 // if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
3938 // else dopts &= ~QMainWindow::AnimatedDocks;
3939 // desktop()->setDockOptions( dopts );
3940 desktop()->setOpaqueResize( opaqueResize );
3941 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
3942 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
3945 #ifndef DISABLE_PLOT2DVIEWER
3946 QList<SUIT_ViewManager*> lst;
3947 viewManagers( Plot2d_Viewer::Type(), lst );
3948 QListIterator<SUIT_ViewManager*> itPlot2d( lst );
3949 while ( itPlot2d.hasNext() ) {
3950 SUIT_ViewManager* viewMgr = itPlot2d.next();
3951 SUIT_ViewModel* vm = viewMgr->getViewModel();
3952 if ( !vm || !vm->inherits( "Plot2d_Viewer" ) )
3955 //Plot2d_Viewer* Plot2dVM = dynamic_cast<Plot2d_Viewer*>( vm );
3957 viewMgr->setViewModel( vm );
3958 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
3960 Plot2d_ViewFrame* frame = wnd->getViewFrame();
3961 frame->SetPreference();
3970 void LightApp_Application::loadPreferences()
3972 CAM_Application::loadPreferences();
3974 SUIT_ResourceMgr* aResMgr = resourceMgr();
3979 static bool mru_load = true;
3982 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3984 mru->setVisible( aResMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
3985 mru->setVisibleCount( aResMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
3986 mru->setHistoryCount( aResMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
3987 mru->setInsertMode( aResMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
3988 mru->setLinkType( aResMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
3989 mru->setClearPossible( aResMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
3990 mru->loadLinks( aResMgr, "MRU" );
3996 QStringList mods = aResMgr->parameters( "windows_visibility" );
3997 for ( QStringList::const_iterator itr = mods.begin(); itr != mods.end(); ++itr )
4000 if ( aResMgr->value( "windows_visibility", *itr, arr ) )
4001 myWinVis.insert( *itr, arr );
4005 desktop()->retrieveGeometry( aResMgr->stringValue( "desktop", "geometry" ) );
4006 bool opaqueResize = aResMgr->booleanValue( "desktop", "opaque_resize", false );
4007 // QMainWindow::DockOptions dopts = desktop()->dockOptions();
4008 // if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
4009 // else dopts &= ~QMainWindow::AnimatedDocks;
4010 // desktop()->setDockOptions( dopts );
4011 desktop()->setOpaqueResize( opaqueResize );
4012 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
4013 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
4020 void LightApp_Application::savePreferences()
4022 CAM_Application::savePreferences();
4024 saveDockWindowsState();
4026 SUIT_ResourceMgr* aResMgr = resourceMgr();
4031 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
4033 mru->saveLinks( aResMgr, "MRU" );
4035 for ( WinVis::const_iterator itr = myWinVis.begin(); itr != myWinVis.end(); ++itr )
4036 aResMgr->setValue( "windows_visibility", itr.key(), itr.value() );
4039 aResMgr->setValue( "desktop", "geometry", desktop()->storeGeometry() );
4041 #if GUI_DEVELOPMENT > 0
4042 aResMgr->setValue( "salome", "version", QString(GUI_VERSION_STR)+"dev" );
4044 aResMgr->setValue( "salome", "version", QString(GUI_VERSION_STR) );
4051 Updates desktop title
4053 void LightApp_Application::updateDesktopTitle()
4055 QString aTitle = applicationName();
4056 QString aVer = applicationVersion();
4057 if ( !aVer.isEmpty() )
4058 aTitle += QString( " " ) + aVer;
4060 if ( activeStudy() ) {
4061 QString sName = SUIT_Tools::file( activeStudy()->studyName().trimmed(), false );
4062 aTitle += QString( " - [%1]" ).arg( sName );
4065 desktop()->setWindowTitle( aTitle );
4069 \brief Get map of the operations which can be performed
4070 on the module activation.
4072 The method should return the map of the kind \c {<id>:<name>}
4073 where \c <id> is an integer identifier of the operation and
4074 \c <name> is a title for the button to be added to the
4075 dialog box. After user selects the required operation by the
4076 clicking the corresponding button in the dialog box, its identifier
4077 is passed to the moduleActionSelected() method to process
4080 \return map of the operations
4081 \sa moduleActionSelected()
4083 QMap<int, QString> LightApp_Application::activateModuleActions() const
4085 QMap<int, QString> opmap;
4086 opmap.insert( NewStudyId, tr( "ACTIVATE_MODULE_OP_NEW" ) );
4087 opmap.insert( OpenStudyId, tr( "ACTIVATE_MODULE_OP_OPEN" ) );
4092 \brief Called when the used selectes required operation chosen
4093 from "Activate module" dialog box.
4095 Performs the required operation according to the user choice.
4097 \param id operation identifier
4098 \sa activateModuleActions()
4100 void LightApp_Application::moduleActionSelected( const int id )
4115 Updates windows after close document
4117 void LightApp_Application::afterCloseDoc()
4121 CAM_Application::afterCloseDoc();
4125 Updates actions of active module
4127 void LightApp_Application::updateModuleActions()
4129 emit moduleActivated( activeModule() ? activeModule()->moduleName() : QString() );
4132 bool LightApp_Application::checkModule( const QString& title )
4134 if ( title.isEmpty() )
4137 QString library = moduleLibrary( title, true );
4138 if ( library.isEmpty() )
4141 QString name = moduleName( title );
4143 bool isPyModule = library.contains( "SalomePyQtGUI" ) || library.contains( "SalomePyQtGUILight" );
4147 paths = QString( Qtx::getenv( "PATH" ) ).split( ";", QString::SkipEmptyParts );
4148 #elif defined(__APPLE__)
4149 paths = QString( Qtx::getenv( "DYLD_LIBRARY_PATH" ) ).split( ":", QString::SkipEmptyParts );
4151 paths = QString( Qtx::getenv( "LD_LIBRARY_PATH" ) ).split( ":", QString::SkipEmptyParts );
4154 bool isFound = false;
4155 QStringList::const_iterator it;
4156 for ( it = paths.begin(); it != paths.end() && !isFound; ++it )
4158 isFound = QFileInfo( Qtx::addSlash( *it ) + library ).exists();
4164 "****************************************************************" << std::endl <<
4165 " Warning: library " << qPrintable( library ) << " is not found!" << std::endl <<
4166 " Module " << qPrintable( title ) << " will not be available in GUI mode!" << std::endl <<
4167 "****************************************************************" << std::endl);
4173 QString pyModule = QString( "%1GUI.py" ).arg( name );
4175 paths = QString( Qtx::getenv( "PYTHONPATH" ) ).split( ";", QString::SkipEmptyParts );
4177 paths = QString( Qtx::getenv( "PYTHONPATH" ) ).split( ":", QString::SkipEmptyParts );
4180 for ( it = paths.begin(); it != paths.end() && !isFound; ++it )
4182 isFound = QFileInfo( Qtx::addSlash( *it ) + pyModule ).exists();
4188 "****************************************************************" << std::endl <<
4189 " Warning: Python module " << qPrintable( pyModule ) << " is not found!" << std::endl <<
4190 " Module " << qPrintable( title ) << " will not be available in GUI mode!" << std::endl <<
4191 "****************************************************************" << std::endl);
4200 Gets current windows.
4201 \param winMap - output current windows map.
4203 void LightApp_Application::currentWindows( QMap<int, int>& winMap ) const
4206 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
4207 ((LightApp_Module*)activeModule())->windows( winMap );
4209 defaultWindows( winMap );
4213 Gets current view managers.
4214 \param lst - output current view managers list.
4216 void LightApp_Application::currentViewManagers( QStringList& lst ) const
4219 if ( !activeStudy() )
4222 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
4223 ((LightApp_Module*)activeModule())->viewManagers( lst );
4225 defaultViewManagers( lst );
4231 void LightApp_Application::updateWindows()
4233 QMap<int, int> winMap;
4234 currentWindows( winMap );
4236 for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
4238 if ( !dockWindow( it.key() ) )
4239 getWindow( it.key() );
4242 for ( WinMap::ConstIterator it = myWin.begin(); it != myWin.end(); ++it )
4244 QWidget* wid = it.value();
4247 if ( winMap.contains( it.key() ) )
4248 wid->setVisible( true );
4249 else if ( !activeStudy() )
4252 wid->setVisible( false );
4255 loadDockWindowsState();
4257 if ( !activeModule() && infoPanel() )
4259 infoPanel()->clear();
4260 infoPanel()->setTitle( tr( "INFO_WELCOME_TO_SALOME" ) );
4262 int grp = infoPanel()->addGroup( tr( "INFO_GETTING_STARTED" ) );
4263 infoPanel()->addAction( action( FileNewId ), grp );
4264 infoPanel()->addLabel( action( FileNewId )->statusTip(), grp );
4265 infoPanel()->addAction( action( FileOpenId ), grp );
4266 infoPanel()->addLabel( action( FileOpenId )->statusTip(), grp );
4267 if ( HAS_TUTORIAL_URL ) {
4268 infoPanel()->addAction( action( TutorialsId ), grp );
4269 infoPanel()->addLabel( action( TutorialsId )->statusTip(), grp );
4271 infoPanel()->addAction( action( VideosId ), grp );
4272 infoPanel()->addLabel( action( VideosId )->statusTip(), grp );
4274 LightApp_ModuleAction* ma = qobject_cast<LightApp_ModuleAction*>(action(ModulesListId));
4275 if ( ma && ma->count() > 0 )
4277 grp = infoPanel()->addGroup( tr( "INFO_AVAILABLE_MODULES" ) );
4278 foreach ( QString mname, ma->modules() )
4280 infoPanel()->addAction( ma->moduleAction( mname ), grp );
4281 if ( !moduleDescription( mname ).isEmpty() )
4282 infoPanel()->addLabel( moduleDescription( mname ), grp );
4289 Updates view managers
4291 void LightApp_Application::updateViewManagers()
4294 currentViewManagers( lst );
4296 for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
4297 getViewManager( *it, true );
4301 Loads windows geometry
4303 void LightApp_Application::loadDockWindowsState()
4307 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
4308 bool storeWin = aResMgr->booleanValue( "Study", "store_positions", true );
4309 bool storeTb = aResMgr->booleanValue( "Study", "store_tool_positions", true );
4312 if ( activeModule() )
4313 modName = activeModule()->name();
4314 else if ( activeStudy() )
4315 modName = "nomodule";
4317 QtxResourceMgr::WorkingMode prevMode = aResMgr->setWorkingMode( QtxResourceMgr::IgnoreUserValues );
4318 QByteArray aDefaultState;
4319 aResMgr->value( "windows_geometry", modName, aDefaultState );
4320 QByteArray aDefaultVisibility;
4321 aResMgr->value( "windows_visibility", modName, aDefaultVisibility );
4322 bool hasDefaultVisibility = !aDefaultVisibility.isEmpty();
4323 aResMgr->setWorkingMode( prevMode );
4325 if( !storeWin && !storeTb && aDefaultState.isEmpty() && !hasDefaultVisibility)
4328 if ( aResMgr->hasValue("windows_geometry" ,modName ) ) {
4329 long version = Qtx::versionToId( aResMgr->stringValue( "windows_geometry_version", modName, "" ) );
4331 if ( version > Qtx::versionToId( "7.4.1" ) )
4332 aResMgr->value( "windows_geometry", modName , arr );
4334 arr = aDefaultState;
4335 QByteArray aTargetArray = processState(arr, storeWin, storeTb, true, aDefaultState);
4336 desktop()->restoreState( aTargetArray );
4339 QStringList mainToolbarsNames;
4340 mainToolbarsNames << "SalomeStandard" << "SalomeModules";
4341 QList<QToolBar*> mainToolbars = findToolBars( mainToolbarsNames );
4342 foreach( QToolBar* tb, mainToolbars ) tb->setVisible( true );
4344 if ( !myWinVis.contains( modName ) && aDefaultVisibility.isEmpty())
4347 QMap<QString, bool> *tbMap = 0;
4348 QMap<QString, bool> *dwMap = 0;
4350 QMap<QString, bool> userTbMap, userDwMap;
4351 dockWindowsState( myWinVis[modName], userTbMap, userDwMap );
4353 QMap<QString, bool> defaultTbMap, defaultDwMap;
4354 if(hasDefaultVisibility) {
4355 dockWindowsState( aDefaultVisibility, defaultTbMap, defaultDwMap);
4361 if(hasDefaultVisibility){
4362 tbMap = &defaultTbMap;
4369 if(hasDefaultVisibility){
4370 dwMap = &defaultDwMap;
4375 QList<QToolBar*> tbList = findToolBars();
4376 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit )
4378 QToolBar* tb = *tit;
4379 if ( tbMap->contains( tb->objectName() ) ) {
4380 tb->setVisible( (*tbMap)[tb->objectName()] );
4386 QList<QDockWidget*> dwList = desktop()->findChildren<QDockWidget*>();
4387 for ( QList<QDockWidget*>::iterator dit = dwList.begin(); dit != dwList.end(); ++dit )
4389 QDockWidget* dw = *dit;
4391 QObject* po = Qtx::findParent( dw, "QMainWindow" );
4392 if ( po != desktop() )
4395 if ( dwMap->contains( dw->objectName() ) )
4396 dw->setVisible( (*dwMap)[dw->objectName()] );
4404 Saves windows geometry
4406 void LightApp_Application::saveDockWindowsState()
4411 bool storeWin = resourceMgr()->booleanValue( "Study", "store_positions", true );
4412 bool storeTb = resourceMgr()->booleanValue( "Study", "store_tool_positions", true );
4414 if( !storeWin && !storeTb )
4418 if ( activeModule() )
4419 modName = activeModule()->name();
4420 else if ( activeStudy() )
4421 modName = "nomodule";
4423 QString versionId = GUI_VERSION_STR;
4424 #if GUI_DEVELOPMENT > 0
4428 QByteArray arr = desktop()->saveState();
4429 resourceMgr()->setValue( "windows_geometry", modName, processState(arr, storeWin, storeTb, false) );
4430 resourceMgr()->setValue( "windows_geometry_version", modName, versionId );
4433 if ( myWinVis.contains( modName ) )
4434 visArr = myWinVis[modName];
4436 QMap<QString, bool> tbMap, dwMap;
4437 dockWindowsState( visArr, tbMap, dwMap );
4439 QList<QToolBar*> tbList = desktop()->findChildren<QToolBar*>();
4440 for ( QList<QToolBar*>::iterator it = tbList.begin(); it != tbList.end(); ++it )
4443 tbMap.insert( tb->objectName(), tb->toggleViewAction()->isChecked() );
4446 QList<QDockWidget*> dwList = desktop()->findChildren<QDockWidget*>();
4447 for ( QList<QDockWidget*>::iterator it = dwList.begin(); it != dwList.end(); ++it )
4449 QDockWidget* wid = *it;
4450 dwMap.insert( wid->objectName(), wid->toggleViewAction()->isChecked() );
4453 visArr = dockWindowsState( tbMap, dwMap );
4455 myWinVis.insert( modName, visArr );
4458 QByteArray LightApp_Application::dockWindowsState( const QMap<QString, bool>& tb, const QMap<QString, bool>& dw ) const
4461 QDataStream stream( &visArr, QIODevice::WriteOnly );
4463 stream << (uchar)ToolBarMarker;
4464 stream << tb.size();
4465 for ( QMap<QString, bool>::const_iterator tit = tb.begin(); tit != tb.end(); ++tit )
4467 stream << tit.key();
4468 stream << (uchar)( tit.value() ? 1 : 0 );
4471 stream << (uchar)DockWidgetMarker;
4472 stream << dw.size();
4473 for ( QMap<QString, bool>::const_iterator wit = dw.begin(); wit != dw.end(); ++wit )
4475 stream << wit.key();
4476 stream << (uchar)( wit.value() ? 1 : 0 );
4482 void LightApp_Application::dockWindowsState( const QByteArray& arr, QMap<QString, bool>& tb, QMap<QString, bool>& dw ) const
4487 QByteArray visArr = arr;
4488 QDataStream stream( &visArr, QIODevice::ReadOnly );
4492 if ( marker != ToolBarMarker )
4497 for ( int i = 0; i < lines; ++i )
4500 stream >> objectName;
4503 tb.insert( objectName, shown );
4507 if ( marker != DockWidgetMarker )
4511 for ( int j = 0; j < lines; ++j )
4514 stream >> objectName;
4517 dw.insert( objectName, shown );
4521 QPixmap LightApp_Application::moduleIcon( const QString& moduleTitle, const int size ) const
4524 if ( resourceMgr() )
4526 QPixmap defaultIcon = resourceMgr()->loadPixmap( "LightApp", tr( "APP_MODULE_ICO" ), QPixmap( imageEmptyIcon ) );
4527 QString iconName = resourceMgr()->stringValue( moduleName( moduleTitle ), "icon", QString() );
4528 icon = resourceMgr()->loadPixmap( moduleName( moduleTitle ), iconName, defaultIcon );
4530 icon = Qtx::scaleIcon( icon, size );
4536 Inserts items in popup, which necessary for current application
4538 void LightApp_Application::contextMenuPopup( const QString& type, QMenu* thePopup, QString& title )
4541 LightApp_SelectionMgr* selMgr = LightApp_Application::selectionMgr();
4542 bool cacheIsOn = selMgr->isSelectionCacheEnabled();
4543 selMgr->setSelectionCacheEnabled( true );
4545 SUIT_DataBrowser* ob = objectBrowser();
4547 CAM_Application::contextMenuPopup( type, thePopup, title );
4549 if ( ob && type == ob->popupClientType() ) {
4550 thePopup->addSeparator();
4551 QAction* a = thePopup->addAction( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
4552 if ( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) )
4553 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) );
4556 #ifndef DISABLE_SALOMEOBJECT
4557 if ( selMgr && ob ) {
4558 SALOME_ListIO selected;
4559 selMgr->selectedObjects( selected );
4560 if(selected.Extent() == 1){
4561 Handle(SALOME_InteractiveObject) anIObject = selected.First();
4562 SUIT_DataObject* obj = findObject(anIObject->getEntry());
4563 if(obj && obj->renameAllowed()) {
4564 QAction* a = new QAction(tr("MEN_RENAME_OBJ"), thePopup);
4565 connect( a, SIGNAL( triggered(bool) ), ob, SLOT( onStartEditing() ) );
4566 if ( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) )
4567 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) );
4569 QList<QAction*> acts = thePopup->actions();
4570 QAction* firstAction = acts.count() > 0 ? acts.first() : 0;
4571 thePopup->insertAction(firstAction,a);
4577 selMgr->setSelectionCacheEnabled( cacheIsOn );
4583 void LightApp_Application::createEmptyStudy()
4585 CAM_Application::createEmptyStudy();
4587 if ( objectBrowser() )
4588 objectBrowser()->updateTree();
4590 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
4591 if ( aResMgr && activeStudy() ) {
4592 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
4593 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
4598 void LightApp_Application::setDesktop( SUIT_Desktop* desk )
4600 CAM_Application::setDesktop( desk );
4603 connect( desk, SIGNAL( message( const QString& ) ),
4604 this, SLOT( onDesktopMessage( const QString& ) ), Qt::UniqueConnection );
4605 connect( desk, SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
4606 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
4607 /* connect( desk, SIGNAL( windowMoved( SUIT_ViewWindow* ) ),
4608 this, SLOT( onWindowMoved( SUIT_ViewWindow* ) ), Qt::UniqueConnection ); */
4614 \param mod - module to be activated
4616 bool LightApp_Application::activateModule( CAM_Module* mod )
4618 bool res = CAM_Application::activateModule( mod );
4620 if ( objectBrowser() )
4621 objectBrowser()->updateTree();
4627 \return keyborad accelerators manager object
4629 SUIT_Accel* LightApp_Application::accel() const
4635 Removes dead widget container from map
4637 void LightApp_Application::onWCDestroyed( QObject* ob )
4639 // remove destroyed widget container from windows map
4640 for ( WinMap::ConstIterator itr = myWin.begin(); itr != myWin.end(); ++itr )
4642 if ( itr.value() != ob )
4645 int key = itr.key();
4646 myWin.remove( key );
4651 void LightApp_Application::onMRUActivated( const QString& name )
4653 SUIT_Session* s = SUIT_Session::session();
4654 if ( s && s->activeApplication() == this )
4658 void LightApp_Application::onStylePreferences()
4660 #ifdef USE_SALOME_STYLE
4661 Style_PrefDlg dlg( desktop() );
4664 resourceMgr()->setValue( "Style", "use_salome_style", Style_Salome::isActive() );
4665 #endif // USE_SALOME_STYLE
4668 void LightApp_Application::onFullScreen(){
4669 if(myScreenHelper) {
4670 if(desktop()->isFullScreen())
4671 myScreenHelper->switchToNormalScreen();
4673 myScreenHelper->switchToFullScreen();
4678 Connects just added view manager
4680 void LightApp_Application::addViewManager( SUIT_ViewManager* vm )
4682 connect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
4683 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
4684 CAM_Application::addViewManager( vm );
4688 Remove view manager from memory
4690 void LightApp_Application::removeViewManager( SUIT_ViewManager* vm )
4692 disconnect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
4693 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
4694 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
4696 aStudy->removeObjectProperties( vm->getGlobalId() );
4698 CAM_Application::removeViewManager( vm );
4700 LightApp_SelectionMgr* selMgr = selectionMgr();
4701 QList<SUIT_Selector*> selectors;
4702 selMgr->selectors( selectors );
4703 foreach( SUIT_Selector* selector, selectors ) {
4704 if ( selector->owner() == vm->getViewModel() ) {
4709 // IPAL22894: Crash on closing OCC view
4715 Renames active window of desktop
4717 void LightApp_Application::onRenameWindow()
4722 QWidget* w = desktop()->activeWindow();
4727 QString name = QInputDialog::getText( w, tr( "TOT_RENAME" ), tr( "PRP_RENAME" ), QLineEdit::Normal, w->windowTitle(), &ok );
4728 if( ok && !name.isEmpty() )
4729 w->setWindowTitle( name );
4733 Closes active window of desktop
4735 void LightApp_Application::onCloseWindow()
4740 QWidget* w = desktop()->activeWindow();
4748 Closes all windows of desktop
4750 void LightApp_Application::onCloseAllWindow()
4752 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
4756 QList<SUIT_ViewWindow*> wndList = desk->windows();
4757 SUIT_ViewWindow* wnd;
4758 foreach( wnd, wndList )
4766 Groups all windows of desktop
4768 void LightApp_Application::onGroupAllWindow()
4770 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
4774 QtxWorkstack* wgStack = desk->workstack();
4780 \return default name for an active study
4782 void LightApp_Application::setDefaultStudyName( const QString& theName )
4784 QStringList anInfoList;
4785 modules( anInfoList, false );
4787 LightApp_Study* aStudy = (LightApp_Study*)activeStudy();
4788 if( anInfoList.count() == 1 && // to avoid a conflict between different modules
4789 !aStudy->isSaved() )
4791 aStudy->setStudyName( theName );
4792 updateDesktopTitle();
4797 Custom event handler
4799 bool LightApp_Application::event( QEvent* e )
4801 if( e && e->type()==2000 )
4803 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
4804 QString* d = ( QString* )ce->data();
4805 if( SUIT_MessageBox::question(0, tr("WRN_WARNING"),
4807 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
4808 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
4811 path << tr( "PREF_CATEGORY_SALOME" ) << tr( "PREF_TAB_GENERAL" )
4812 << tr( "PREF_GROUP_EXT_BROWSER" ) << tr( "PREF_APP" );
4813 showPreferences( path );
4819 return CAM_Application::event( e );
4822 /*! Check data object */
4823 bool LightApp_Application::checkDataObject(LightApp_DataObject* theObj)
4827 bool isSuitable = !theObj->entry().isEmpty() &&
4828 !theObj->componentDataType().isEmpty() &&
4829 !theObj->name().isEmpty();
4836 int LightApp_Application::openChoice( const QString& aName )
4838 int choice = CAM_Application::openChoice( aName );
4840 if ( choice == OpenExist ) // The document is already open.
4842 // Do you want to reload it?
4843 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "QUE_DOC_ALREADYOPEN" ).arg( aName ),
4844 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No ) == SUIT_MessageBox::Yes )
4845 choice = OpenReload;
4851 bool LightApp_Application::openAction( const int choice, const QString& aName )
4858 STD_Application* app = 0;
4859 SUIT_Session* session = SUIT_Session::session();
4860 QList<SUIT_Application*> appList = session->applications();
4861 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !app; ++it )
4863 if ( (*it)->activeStudy() && (*it)->activeStudy()->studyName() == aName )
4864 app = ::qobject_cast<STD_Application*>( *it );
4869 app->onCloseDoc( false );
4870 appList = session->applications();
4871 STD_Application* other = 0;
4872 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !other; ++it )
4873 other = ::qobject_cast<STD_Application*>( *it );
4876 res = other->onOpenDoc( aName );
4881 res = CAM_Application::openAction( choice, aName );
4888 QStringList LightApp_Application::viewManagersTypes() const
4890 QStringList aTypesList;
4891 aTypesList += myUserWmTypes;
4892 #ifndef DISABLE_GLVIEWER
4893 aTypesList<<GLViewer_Viewer::Type();
4895 #ifndef DISABLE_PLOT2DVIEWER
4896 aTypesList<<Plot2d_Viewer::Type();
4898 #ifndef DISABLE_QXGRAPHVIEWER
4899 aTypesList<<QxScene_Viewer::Type();
4901 #ifndef DISABLE_PVVIEWER
4902 aTypesList<<PVViewer_Viewer::Type();
4904 #ifndef DISABLE_PYVIEWER
4905 aTypesList<<PyViewer_Viewer::Type();
4907 #ifndef DISABLE_OCCVIEWER
4908 aTypesList<<OCCViewer_Viewer::Type();
4910 #ifndef DISABLE_VTKVIEWER
4911 #ifndef DISABLE_SALOMEOBJECT
4912 aTypesList<<SVTK_Viewer::Type();
4914 aTypesList<<VTKViewer_Viewer::Type();
4920 * Removes all view managers of known types
4921 * Other view managers are ignored
4923 void LightApp_Application::clearKnownViewManagers()
4925 QStringList aTypesList = viewManagersTypes();
4926 QList<SUIT_ViewManager*> aMgrList;
4927 viewManagers( aMgrList );
4928 foreach (SUIT_ViewManager* aMgr, aMgrList) {
4929 if (aTypesList.contains(aMgr->getType()))
4930 removeViewManager(aMgr);
4935 Copy of current selection
4937 void LightApp_Application::onCopy()
4939 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
4945 Paste of current data in clipboard
4947 void LightApp_Application::onPaste()
4949 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
4955 Browse (i.e. set focus on) the published objects
4956 \param theIsApplyAndClose - flag indicating that the dialog for creating objects
4957 has been accepted by Ok (or Apply & Close) button
4958 \param theIsOptimizedBrowsing - flag switching to optimized browsing mode
4959 (to select the first published object only)
4960 \return entry of the selected object
4962 QString LightApp_Application::browseObjects( const QStringList& theEntryList,
4963 const bool theIsApplyAndClose,
4964 const bool theIsOptimizedBrowsing )
4967 if( SUIT_ResourceMgr* aResourceMgr = resourceMgr() )
4969 int aBrowsePolicy = aResourceMgr->integerValue( "ObjectBrowser", "browse_published_object", (int)BP_Never );
4970 switch( aBrowsePolicy )
4974 case BP_ApplyAndClose:
4975 if( !theIsApplyAndClose )
4983 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
4987 SUIT_DataBrowser* anOB = objectBrowser();
4991 SUIT_AbstractModel* aModel = dynamic_cast<SUIT_AbstractModel*>( anOB->model() );
4995 QStringListIterator anIter( theEntryList );
4996 if( theIsOptimizedBrowsing )
4998 // go to the last entry
5000 if( anIter.hasPrevious() )
5004 // scroll to each entry in the list
5005 // (in optimized mode - to the last entry only)
5007 LightApp_DataObject* anObject = 0;
5008 while( anIter.hasNext() )
5010 anEntry = anIter.next();
5011 if( !anEntry.isEmpty() )
5013 anObject = aStudy->findObjectByEntry( anEntry );
5016 QModelIndex anIndex = aModel->index( anObject );
5017 anOB->treeView()->scrollTo( anIndex );
5022 // always select the last object
5023 if( anObject && !anEntry.isEmpty() )
5025 QList<SUIT_Selector*> aSelectorList;
5026 selectionMgr()->selectors( "ObjectBrowser", aSelectorList );
5027 if( !aSelectorList.isEmpty() )
5029 if( LightApp_OBSelector* aSelector = dynamic_cast<LightApp_OBSelector*>( aSelectorList.first() ) )
5031 bool anIsAutoBlock = aSelector->autoBlock();
5033 // temporarily disable auto block, to emit LightApp_SelectionMgr::currentSelectionChanged() signal
5034 aSelector->setAutoBlock( false );
5036 SUIT_DataOwnerPtrList aList;
5037 #ifndef DISABLE_SALOMEOBJECT
5038 Handle(SALOME_InteractiveObject) aSObj = new SALOME_InteractiveObject
5039 ( anObject->entry().toUtf8().constData(),
5040 anObject->componentDataType().toLatin1().constData(),
5041 anObject->name().toUtf8().constData() );
5042 LightApp_DataOwner* owner = new LightApp_DataOwner( aSObj );
5044 LightApp_DataOwner* owner = new LightApp_DataOwner( anEntry );
5047 aList.append( owner );
5048 selectionMgr()->setSelected( aList );
5051 // restore auto block flag
5052 aSelector->setAutoBlock( anIsAutoBlock );
5060 SUIT_DataObject* LightApp_Application::findObject( const QString& id ) const
5062 LightApp_Study* study = dynamic_cast<LightApp_Study*>( activeStudy() );
5063 return study ? study->findObjectByEntry( id ) : 0;
5067 Checks that an object can be renamed.
5068 \param entry entry of the object
5069 \brief Return \c true if object can be renamed
5071 bool LightApp_Application::renameAllowed( const QString& /*entry*/) const {
5076 Rename object by entry.
5077 \param entry entry of the object
5078 \param name new name of the object
5079 \brief Return \c true if rename operation finished successfully, \c false otherwise.
5081 bool LightApp_Application::renameObject( const QString& /*entry*/, const QString& /*name*/ ) {
5085 /*! Process standard messages from desktop */
5086 void LightApp_Application::onDesktopMessage( const QString& message )
5088 const QString sectionSeparator = "/";
5090 if ( message.toLower() == "updateobjectbrowser" ||
5091 message.toLower() == "updateobjbrowser" ) {
5092 // update object browser
5093 updateObjectBrowser();
5095 else if ( message.toLower().startsWith( "activate_viewer" ) ) {
5096 QString vtype = message.split( sectionSeparator ).last();
5097 if ( !vtype.isEmpty() )
5098 getViewManager( vtype, true );
5100 else if ( message.toLower().startsWith("register_module_in_study" ) ) {
5101 QString moduleName = message.split( sectionSeparator ).last();
5102 // Check name of current activating module name in order to avoid ciclik
5103 // call because of messages
5104 if (!property("activateModule").toBool()) {
5105 CAM_Module* mod = module(moduleName);
5107 mod = module(moduleTitle(moduleName));
5109 mod = loadModule(moduleName);
5111 mod = loadModule(moduleTitle(moduleName));
5117 CAM_Study* anActiveStudy = dynamic_cast<CAM_Study*>(activeStudy());
5118 if (anActiveStudy) {
5119 mod->connectToStudy(anActiveStudy);
5120 LightApp_DataModel* aDM = dynamic_cast<LightApp_DataModel*>(mod->dataModel());
5122 aDM->initRootObject();
5129 QStringList data = message.split( sectionSeparator );
5130 if ( data.count() > 1 ) {
5131 QString msgType = data[0].trimmed();
5132 LightApp_Module* sMod = 0;
5133 CAM_Module* mod = module( msgType );
5135 mod = module( moduleTitle( msgType ) );
5136 if ( mod && mod->inherits( "LightApp_Module" ) )
5137 sMod = (LightApp_Module*)mod;
5139 if ( msgType.toLower() == "preferences" ) {
5140 // requested preferences change: should be given as "preferences/<section>/<name>/<value>"
5141 // for example "preferences/Study/multi_file_dump/true"
5142 if ( data.count() > 3 ) {
5143 QString section = data[1].trimmed();
5144 QString param = data[2].trimmed();
5145 QString value = QStringList( data.mid(3) ).join( sectionSeparator );
5146 resourceMgr()->setValue( section, param, value );
5150 // received message for the module
5151 QString msg = QStringList( data.mid(1) ).join( sectionSeparator );
5152 sMod->message( msg );
5158 void LightApp_Application::onInfoPanelShown()
5160 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
5161 ((LightApp_Module*)activeModule())->updateInfoPanel();
5166 Returns all top level toolbars.
5167 Note : Result list contains only main window toolbars, not including toolbars from viewers.
5169 QList<QToolBar*> LightApp_Application::findToolBars( const QStringList& names )
5171 QList<QToolBar*> aResult;
5172 QList<QToolBar*> tbList = desktop()->findChildren<QToolBar*>();
5173 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit ) {
5174 QToolBar* tb = *tit;
5175 QObject* po = Qtx::findParent( tb, "QMainWindow" );
5176 if ( po != desktop() )
5178 if ( names.isEmpty() || names.contains( tb->objectName() ) )
5185 Internal method to parse toolbars and dockable windows state.
5187 QByteArray LightApp_Application::processState(QByteArray& input,
5188 const bool processWin,
5189 const bool processTb,
5190 const bool isRestoring,
5191 QByteArray defaultState) {
5194 bool hasDefaultState = !defaultState.isEmpty();
5195 bool isDockWinWriten = false;
5197 //Write date from users settings
5199 QDataStream tmpInputData(&input, QIODevice::ReadOnly);
5200 int marker, version;
5202 tmpInputData >> marker;
5203 tmpInputData >> version;
5204 tmpInputData >> dockmarker;
5205 tmpInputData >> nbDocWin;
5207 if(processWin && processTb && !isRestoring) {
5209 } else if(!processWin && !processTb ) {
5211 aRes = defaultState;
5213 QDataStream aData(&aRes, QIODevice::WriteOnly);
5214 QList<QToolBar*> aToolBars = findToolBars();
5217 for ( QList<QToolBar*>::iterator tit = aToolBars.begin(); tit != aToolBars.end(); ++tit ) {
5218 QToolBar* tb = *tit;
5219 aNames.append(tb->objectName());
5222 int toolBarMarkerIndex = getToolbarMarkerIndex(input,aNames);
5223 if(toolBarMarkerIndex < 0)
5225 QDataStream anInputData(&input, QIODevice::ReadOnly);
5227 int toolBarMarkerIndexDef = 0;
5228 if(hasDefaultState) {
5229 toolBarMarkerIndexDef = getToolbarMarkerIndex(defaultState, aNames);
5230 if(toolBarMarkerIndexDef < 0)
5233 QDataStream anInputDataDef(&defaultState, QIODevice::ReadOnly);
5235 QDataStream* aTargetData = 0;
5236 int aTargetIndex = -1;
5238 QByteArray currentArr = desktop()->saveState();
5239 QDataStream anInputDataCur(¤tArr, QIODevice::ReadOnly);
5240 bool useInputData = !isRestoring || (isRestoring && nbDocWin > 0);
5241 if(processWin && useInputData) {
5242 aTargetData = &anInputData;
5243 aTargetIndex = toolBarMarkerIndex;
5245 //Write date from default settings
5246 if(hasDefaultState) {
5247 aTargetData = &anInputDataDef;
5248 aTargetIndex = toolBarMarkerIndexDef;
5250 //If no default state, write current snapshot of the dockable windows
5252 aTargetData = &anInputDataCur;
5253 int toolBarMarkerIndexCur = getToolbarMarkerIndex(currentArr, aNames);
5254 aTargetIndex = toolBarMarkerIndexCur;
5259 if(aTargetData && aTargetIndex >= 0 ) {
5260 aTargetData->device()->seek(0);
5261 while( aTargetData->device()->pos() < aTargetIndex ) {
5266 isDockWinWriten = true;
5273 aTargetData = &anInputData;
5274 aTargetIndex = toolBarMarkerIndex;
5276 if(hasDefaultState) {
5277 aTargetData = &anInputDataDef;
5278 aTargetIndex = toolBarMarkerIndexDef;
5282 if(aTargetData && aTargetIndex >= 0) {
5284 if(!isDockWinWriten ) {
5285 //Write version marker
5286 int marker, version;
5287 aTargetData->device()->seek(0);
5288 *aTargetData >> marker;
5289 *aTargetData >> version;
5292 aData << (uchar) QDockWidgetMarker;
5294 int shift = 4*sizeof(int) + sizeof(QSize);
5295 index = aTargetIndex - shift;
5297 index = aTargetIndex;
5300 aTargetData->device()->seek(index);
5301 while(!aTargetData->atEnd()) {
5306 } else { // Not treat toolbars
5307 aData << (uchar) QToolBarMarker;
5308 aData << (int) 0; //Nb toolbars = 0
5315 \brief Emits operationFinished signal.
5316 \param theModuleName the name of the module which perfomed the operation
5317 \param theOperationName the operation name
5318 \param theEntryList the list of the created objects entries
5320 void LightApp_Application::emitOperationFinished( const QString& theModuleName,
5321 const QString& theOperationName,
5322 const QStringList& theEntryList )
5324 emit operationFinished( theModuleName, theOperationName, theEntryList );
5328 Update visibility state of given objects
5330 void LightApp_Application::updateVisibilityState( DataObjectList& theList,
5331 SUIT_ViewModel* theViewModel )
5333 if ( !theViewModel || theList.isEmpty() ) return;
5335 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
5336 if ( !aStudy ) return;
5338 SALOME_View* aView = dynamic_cast<SALOME_View*>( theViewModel );
5340 for ( DataObjectList::iterator itr = theList.begin(); itr != theList.end(); ++itr ) {
5341 LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>(*itr);
5343 if ( !obj || aStudy->isComponent( obj->entry() ) )
5346 QString mname = aStudy->componentDataType(obj->entry());
5347 LightApp_Displayer* aDisplayer = LightApp_Displayer::FindDisplayer(mname, false);
5349 Qtx::VisibilityState anObjState = Qtx::UnpresentableState;
5350 if ( aDisplayer->canBeDisplayed( obj->entry(), theViewModel->getType() ) ) {
5351 if ( aDisplayer->IsDisplayed( obj->entry(), aView ) )
5352 anObjState = Qtx::ShownState;
5354 anObjState = Qtx::HiddenState;
5356 aStudy->setVisibilityState( obj->entry(), anObjState );
5362 Update presentations of all displayed objects of theComponent in specified viewers
5364 void LightApp_Application::updatePresentations( const QString& theComponent,
5365 const QStringList& theViewManagerTypes )
5367 LightApp_Displayer* aDisplayer = LightApp_Displayer::FindDisplayer(theComponent, false);
5369 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
5370 DataObjectList aComps;
5371 bool isFound = false;
5372 aStudy->root()->children( aComps );
5373 DataObjectList::const_iterator aCompsIt = aComps.begin();
5374 for ( ; aCompsIt != aComps.end() && !isFound; aCompsIt++ ) {
5375 LightApp_DataObject* aComp = dynamic_cast<LightApp_DataObject*>( *aCompsIt );
5376 if ( aComp && aComp->componentDataType() == theComponent) {
5378 DataObjectList anObjs;
5379 aComp->children(anObjs, true);
5381 QList<SUIT_ViewManager*> aViewMgrs;
5382 QStringList::const_iterator itVMTypes = theViewManagerTypes.begin();
5383 for ( ; itVMTypes != theViewManagerTypes.end(); ++itVMTypes )
5384 viewManagers( *itVMTypes, aViewMgrs );
5386 DataObjectList::const_iterator itObjs = anObjs.begin();
5387 for ( ; itObjs != anObjs.end(); itObjs++ ) {
5388 LightApp_DataObject* anObj = dynamic_cast<LightApp_DataObject*>( *itObjs );
5389 QString anEntry = anObj->entry();
5391 QListIterator<SUIT_ViewManager*> itViewMgrs( aViewMgrs );
5392 while ( itViewMgrs.hasNext()) {
5393 SUIT_ViewModel* aVM = itViewMgrs.next()->getViewModel();
5395 SALOME_View* aView = dynamic_cast<SALOME_View*>(aVM);
5397 bool isDisp = aDisplayer->IsDisplayed( anEntry, aView );
5398 aDisplayer->Erase( anEntry, true, false, aView );
5400 aDisplayer->Display( anEntry, false, aView );
5412 * Called when window activated
5414 void LightApp_Application::onWindowActivated( SUIT_ViewWindow* theViewWindow )
5416 SUIT_DataBrowser* anOB = objectBrowser();
5419 SUIT_DataObject* rootObj = anOB->root();
5423 DataObjectList listObj = rootObj->children( true );
5425 SUIT_ViewModel* vmod = 0;
5426 if ( SUIT_ViewManager* vman = theViewWindow->getViewManager() )
5427 vmod = vman->getViewModel();
5428 updateVisibilityState( listObj, vmod );
5432 Called then view manager removed
5434 void LightApp_Application::onViewManagerRemoved( SUIT_ViewManager* )
5436 ViewManagerList lst;
5437 viewManagers( lst );
5438 if ( lst.count() == 1) { // in case if closed last view window
5439 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
5441 aStudy->setVisibilityStateForAll( Qtx::UnpresentableState );
5446 Check existing document.
5448 bool LightApp_Application::checkExistingDoc( bool closeExistingDoc )
5451 if( activeStudy() ) {
5452 int answer = !activeStudy()->isModified() ? 1 :
5453 SUIT_MessageBox::question( desktop(),
5454 tr( "APPCLOSE_CAPTION" ),
5455 tr( "STUDYCLOSE_DESCRIPTION" ),
5456 tr( "APPCLOSE_SAVE" ),
5457 tr( "APPCLOSE_CLOSE" ),
5458 tr( "APPCLOSE_CANCEL" ), 0 );
5460 if ( activeStudy()->isSaved() ) {
5462 if (closeExistingDoc) {
5465 } else if ( onSaveAsDoc() ) {
5466 if (closeExistingDoc) {
5467 if( !closeDoc( false ) ) {
5475 else if( answer == 1 ) {
5476 if (closeExistingDoc) {
5479 } else if( answer == 2 ) {
5486 #ifndef DISABLE_PYCONSOLE
5488 PyConsole_Interp* LightApp_Application::getPyInterp()
5490 static PyConsole_Interp* myInterp = 0;
5492 myInterp = createPyInterp();
5493 myInterp->initialize();
5498 PyConsole_Interp* LightApp_Application::createPyInterp()
5500 return new PyConsole_Interp();
5503 #endif // DISABLE_PYCONSOLE
5505 void LightApp_Application::createHelpItems( const QString& modTitle )
5507 if ( modTitle.isEmpty() )
5510 QString userGuide = "User's Guide";
5511 QString devGuide = "Developer's Guide";
5513 int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
5515 createMenu( userGuide, helpMenu, -1, 5 );
5516 createMenu( devGuide, helpMenu, -1, 5 );
5518 IMap <QString, QString> helpData; // list of help files for the module
5519 QString helpSubMenu; // help submenu name (empty if not needed)
5520 QString modName = moduleName( modTitle ); // module name
5521 if ( modName.isEmpty() ) modName = modTitle; // for KERNEL and GUI
5522 QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName ); // module root dir env variable
5523 QString modDir = Qtx::getenv( rootDir.toUtf8().constData() ); // module root dir path
5525 if ( resourceMgr()->hasValue( modName, "documentation" ) )
5526 docSection = resourceMgr()->stringValue( modName, "documentation" );
5527 else if ( resourceMgr()->hasSection( modName + "_documentation" ) )
5528 docSection = modName + "_documentation";
5529 if ( !docSection.isEmpty() )
5531 helpSubMenu = resourceMgr()->stringValue( docSection, "sub_menu", "" );
5532 if ( helpSubMenu.contains( "%1" ) )
5533 helpSubMenu = helpSubMenu.arg( modTitle );
5534 foreach( QString paramName, resourceMgr()->parameters( docSection ) )
5536 QString key = paramName.contains( "%1" ) ? paramName.arg( modTitle ) : paramName;
5537 QString helpItem = getHelpItem( docSection, paramName );
5538 if ( !helpItem.isEmpty() )
5539 helpData.insert( key, helpItem );
5543 if ( helpData.isEmpty() && !modDir.isEmpty() )
5545 QStringList idxLst = QStringList() << modDir << "share" << "doc" << "salome" << "gui" << modName << "index.html";
5546 QString indexFile = idxLst.join( QDir::separator() ); // index file
5547 if ( QFile::exists( indexFile ) )
5548 helpData.insert( tr( "%1 module Users's Guide" ).arg( modTitle ), indexFile );
5551 IMapConstIterator<QString, QString > fileIt;
5552 for ( fileIt = helpData.begin(); fileIt != helpData.end(); fileIt++ )
5554 QString helpItemPath = fileIt.key();
5555 // remove all '//' occurances
5556 while ( helpItemPath.contains( "//" ) )
5557 helpItemPath.replace( "//", "" );
5558 // obtain submenus hierarchy if given
5559 QStringList smenus = helpItemPath.split( "/" );
5560 helpItemPath = smenus.takeLast();
5561 // workaround for User's Guide and Developer's Guide to avoid having single item in module's submenu.
5562 if ( helpItemPath == userGuide || helpItemPath == devGuide )
5564 QString menuPath = smenus.join( "/" );
5565 QStringList allKeys = helpData.keys();
5566 QStringList total = allKeys.filter( QRegExp( QString( "^%1" ).arg( menuPath ) ) );
5567 if ( total.count() == 1 && smenus.count() > 0 )
5568 helpItemPath = smenus.takeLast();
5570 QPixmap helpIcon = fileIt.value().startsWith( "http", Qt::CaseInsensitive ) ?
5571 resourceMgr()->loadPixmap( "STD", tr( "ICON_WWW" ), false ) :
5572 resourceMgr()->loadPixmap( "STD", tr( "ICON_HELP" ), false );
5573 QAction* a = createAction( -1, helpItemPath, helpIcon, helpItemPath, helpItemPath,
5574 0, desktop(), false, this, SLOT( onHelpContentsModule() ) );
5575 a->setData( fileIt.value() );
5576 if ( !helpSubMenu.isEmpty() )
5577 smenus.prepend( helpSubMenu );
5578 // create sub-menus hierarchy
5579 int menuId = helpMenu;
5580 foreach ( QString subMenu, smenus )
5581 menuId = createMenu( subMenu, menuId, -1, 5 );
5582 createMenu( a, menuId, -1, ( menuId != helpMenu && ( helpItemPath == userGuide || helpItemPath == devGuide ) ) ? 0 : 5 );
5583 if ( !myHelpItems.contains( modName ) )
5584 myHelpItems[modName] = IdList();
5585 myHelpItems[modName].append( actionId( a ) );
5589 void LightApp_Application::removeHelpItems( const QString& modTitle )
5591 QString modName = moduleName( modTitle );
5592 if ( myHelpItems.contains( modName ) )
5594 foreach( int id, myHelpItems[modName] )
5595 setMenuShown( id, false );
5596 myHelpItems.remove( modName );