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 // ... "View cube" group <<start>>
2859 int occViewCubeGroup = pref->addPreference( tr( "PREF_GROUP_VIEWCUBE" ), occGroup );
2860 pref->setItemProperty( "columns", 2, occViewCubeGroup );
2861 // .... -> show view cube on viewer start
2862 pref->addPreference( tr( "PREF_VIEWCUBE_SHOW" ), occViewCubeGroup,
2863 LightApp_Preferences::Bool, "OCCViewer", "viewcube_show" );
2864 // .... -> view cube duration of animation (sec)
2865 int viewcube_dur = pref->addPreference( tr( "PREF_VIEWCUBE_DURATION" ), occViewCubeGroup,
2866 LightApp_Preferences::DblSpin, "OCCViewer", "viewcube_duration" );
2867 pref->setItemProperty( "min", 0.1, viewcube_dur );
2868 pref->setItemProperty( "max", 10.0, viewcube_dur );
2869 pref->setItemProperty( "step", 0.1, viewcube_dur );
2870 // .... -> show view cube axes
2871 pref->addPreference( tr( "PREF_VIEWCUBE_AXES" ), occViewCubeGroup,
2872 LightApp_Preferences::Bool, "OCCViewer", "viewcube_axes" );
2873 // ... "View cube" group <<end>>
2875 // ... "View cube default (OCCT) attributes" group <<start>>
2876 int occViewCubeAttrsGroup = pref->addPreference( tr( "PREF_VIEWCUBE_CUSTOM" ), occGroup,
2877 LightApp_Preferences::Auto, "OCCViewer", "viewcube_custom" );
2878 pref->setItemProperty( "columns", 2, occViewCubeAttrsGroup );
2879 // .... -> box color
2880 pref->addPreference( tr( "PREF_VIEWCUBE_COLOR" ), occViewCubeAttrsGroup,
2881 LightApp_Preferences::Color, "OCCViewer", "viewcube_color" );
2882 // .... -> view cube size
2883 int viewcube_size = pref->addPreference( tr( "PREF_VIEWCUBE_SIZE" ), occViewCubeAttrsGroup,
2884 LightApp_Preferences::DblSpin, "OCCViewer", "viewcube_size" );
2885 pref->setItemProperty( "min", 30.0, viewcube_size );
2886 pref->setItemProperty( "max", 100.0, viewcube_size );
2887 pref->setItemProperty( "step", 10.0, viewcube_size );
2888 // .... -> text color
2889 pref->addPreference( tr( "PREF_VIEWCUBE_TEXTCOLOR" ), occViewCubeAttrsGroup,
2890 LightApp_Preferences::Color, "OCCViewer", "viewcube_text_color" );
2891 // ... "View cube" group <<end>>
2893 // ... -> empty frame (for layout) <<start>>
2894 int occGen = pref->addPreference( "", occGroup, LightApp_Preferences::Frame );
2895 pref->setItemProperty( "margin", 0, occGen );
2896 pref->setItemProperty( "columns", 2, occGen );
2897 // ... -> empty frame (for layout) <<end>>
2899 // .. "OCC viewer" group <<end>>
2902 #ifndef DISABLE_VTKVIEWER
2903 // .. "VTK viewer" group <<start>>
2904 int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), salomeCat ); //viewTab
2906 // ... -> empty frame (for layout) <<start>>
2907 int vtkGen = pref->addPreference( "", vtkGroup, LightApp_Preferences::Frame );
2908 //pref->setItemProperty( "columns", 2, vtkGen );
2909 // .... -> projection mode
2910 int vtkProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), vtkGen,
2911 LightApp_Preferences::Selector, "VTKViewer", "projection_mode" );
2912 aValuesList.clear();
2913 anIndicesList.clear();
2914 aValuesList << tr("PREF_ORTHOGRAPHIC") << tr("PREF_PERSPECTIVE");
2915 anIndicesList << 0 << 1;
2916 pref->setItemProperty( "strings", aValuesList, vtkProjMode );
2917 pref->setItemProperty( "indexes", anIndicesList, vtkProjMode );
2919 // .... -> Stereo group
2920 int vtkStereoGroup = pref->addPreference( tr( "PREF_GROUP_STEREO" ), vtkGroup);
2921 pref->setItemProperty( "columns", 2, vtkStereoGroup );
2922 // .... -> Stereo type
2923 int vtkStereoType = pref->addPreference( tr( "PREF_STEREO_TYPE" ), vtkStereoGroup,
2924 LightApp_Preferences::Selector, "VTKViewer", "stereo_type" );
2925 aValuesList.clear();
2926 anIndicesList.clear();
2928 SVTK_Viewer::stereoData( aValuesList, idList);
2929 foreach( int gid, idList ) anIndicesList << gid;
2930 pref->setItemProperty( "strings", aValuesList, vtkStereoType );
2931 pref->setItemProperty( "indexes", anIndicesList, vtkStereoType );
2932 // .... -> Anaglyph filter
2933 int vtkAnaglyphFilter = pref->addPreference( tr( "PREF_ANAGLYPH_FILTER" ), vtkStereoGroup,
2934 LightApp_Preferences::Selector, "VTKViewer", "anaglyph_filter" );
2935 aValuesList.clear();
2936 anIndicesList.clear();
2937 aValuesList << tr("PREF_ANAGLYPH_RED_CYAN") << tr("PREF_ANAGLYPH_YELLOW_BLUE") << tr("PREF_ANAGLYPH_GREEN_MAGENTA");
2938 anIndicesList << 0 << 1 << 2;
2940 pref->setItemProperty( "strings", aValuesList, vtkAnaglyphFilter );
2941 pref->setItemProperty( "indexes", anIndicesList, vtkAnaglyphFilter );
2943 // .... -> Enable quad-buffer support
2944 pref->addPreference( tr( "PREF_ENABLE_QUAD_BUFFER_SUPPORT" ), vtkStereoGroup,
2945 LightApp_Preferences::Bool, "VTKViewer", "enable_quad_buffer_support" );
2947 // .... -> background
2948 aValuesList.clear();
2949 anIndicesList.clear();
2952 #ifndef DISABLE_SALOMEOBJECT
2953 formats = SVTK_Viewer::backgroundData( aValuesList, idList, txtList );
2955 foreach( int gid, idList ) anIndicesList << gid;
2956 bgId = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGen,
2957 LightApp_Preferences::Background, "VTKViewer", "background" );
2958 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2959 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2960 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2961 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2962 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2963 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2964 pref->setItemProperty( "custom_enabled", false, bgId );
2965 #ifndef DISABLE_SALOMEOBJECT
2966 pref->setItemProperty( "image_formats", formats, bgId );
2968 // .... -> speed increment
2969 int vtkSpeed = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED" ), vtkGen,
2970 LightApp_Preferences::IntSpin, "VTKViewer", "speed_value" );
2971 pref->setItemProperty( "min", 1, vtkSpeed );
2972 pref->setItemProperty( "max", 1000, vtkSpeed );
2973 // .... -> speed mode
2974 int vtkSpeedMode = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED_MODE" ), vtkGen,
2975 LightApp_Preferences::Selector, "VTKViewer", "speed_mode" );
2976 aValuesList.clear();
2977 anIndicesList.clear();
2978 aValuesList << tr("PREF_ARITHMETIC") << tr("PREF_GEOMETRICAL");
2979 anIndicesList << 0 << 1;
2980 pref->setItemProperty( "strings", aValuesList, vtkSpeedMode );
2981 pref->setItemProperty( "indexes", anIndicesList, vtkSpeedMode );
2983 // ... "Selection" group <<start>>
2984 int vtkSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), vtkGroup );
2985 pref->setItemProperty( "columns", 2, vtkSelectionGroup );
2986 // .... -> preselection
2987 int vtkPreselection = pref->addPreference( tr( "PREF_PRESELECTION" ), vtkSelectionGroup,
2988 LightApp_Preferences::Selector, "VTKViewer", "preselection" );
2989 aValuesList.clear();
2990 anIndicesList.clear();
2991 aValuesList << tr("PREF_PRESELECTION_STANDARD") << tr("PREF_PRESELECTION_DYNAMIC") << tr("PREF_PRESELECTION_DISABLED");
2992 anIndicesList << 0 << 1 << 2;
2993 pref->setItemProperty( "strings", aValuesList, vtkPreselection );
2994 pref->setItemProperty( "indexes", anIndicesList, vtkPreselection );
2995 // .... -> enable selection
2996 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), vtkSelectionGroup, LightApp_Preferences::Bool, "VTKViewer", "enable_selection" );
2997 // ... "Selection" group <<end>>
2999 // ... -> empty frame (for layout) <<end>>
3001 // ... space mouse sub-group <<start>>
3002 int vtkSM = pref->addPreference( tr( "PREF_FRAME_SPACEMOUSE" ), vtkGroup, LightApp_Preferences::GroupBox );
3003 //pref->setItemProperty( "columns", 2, vtkSM );
3004 // .... -> decrease speed increment
3005 int spacemousePref1 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_1" ), vtkSM,
3006 LightApp_Preferences::Selector, "VTKViewer",
3007 "spacemouse_func1_btn" );
3008 // .... -> increase speed increment
3009 int spacemousePref2 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_2" ), vtkSM,
3010 LightApp_Preferences::Selector, "VTKViewer",
3011 "spacemouse_func2_btn" );
3012 // .... -> dominant / combined switch
3013 int spacemousePref3 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_3" ), vtkSM,
3014 LightApp_Preferences::Selector, "VTKViewer",
3015 "spacemouse_func5_btn" ); //
3016 aValuesList.clear();
3017 anIndicesList.clear();
3018 aValuesList << tr( "PREF_SPACEMOUSE_BTN_1" ) << tr( "PREF_SPACEMOUSE_BTN_2" ) << tr( "PREF_SPACEMOUSE_BTN_3" );
3019 aValuesList << tr( "PREF_SPACEMOUSE_BTN_4" ) << tr( "PREF_SPACEMOUSE_BTN_5" ) << tr( "PREF_SPACEMOUSE_BTN_6" );
3020 aValuesList << tr( "PREF_SPACEMOUSE_BTN_7" ) << tr( "PREF_SPACEMOUSE_BTN_8" ) << tr( "PREF_SPACEMOUSE_BTN_*" );
3021 aValuesList << tr( "PREF_SPACEMOUSE_BTN_10" ) << tr( "PREF_SPACEMOUSE_BTN_11" );
3022 anIndicesList << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11;
3023 pref->setItemProperty( "strings", aValuesList, spacemousePref1 );
3024 pref->setItemProperty( "indexes", anIndicesList, spacemousePref1 );
3025 pref->setItemProperty( "strings", aValuesList, spacemousePref2 );
3026 pref->setItemProperty( "indexes", anIndicesList, spacemousePref2 );
3027 pref->setItemProperty( "strings", aValuesList, spacemousePref3 );
3028 pref->setItemProperty( "indexes", anIndicesList, spacemousePref3 );
3029 // ... space mouse sub-group <<end>>
3031 // ... avi recording sub-group <<start>>
3032 int vtkRec = pref->addPreference( tr( "PREF_FRAME_RECORDING" ), vtkGroup, LightApp_Preferences::GroupBox );
3033 pref->setItemProperty( "columns", 2, vtkRec );
3034 // .... -> recording mode
3035 int modePref = pref->addPreference( tr( "PREF_RECORDING_MODE" ), vtkRec,
3036 LightApp_Preferences::Selector, "VTKViewer", "recorder_mode" );
3037 aValuesList.clear();
3038 anIndicesList.clear();
3039 aValuesList << tr( "PREF_SKIPPED_FRAMES" ) << tr( "PREF_ALL_DISLPAYED_FRAMES" );
3040 anIndicesList << 0 << 1;
3041 pref->setItemProperty( "strings", aValuesList, modePref );
3042 pref->setItemProperty( "indexes", anIndicesList, modePref );
3044 int fpsPref = pref->addPreference( tr( "PREF_FPS" ), vtkRec,
3045 LightApp_Preferences::DblSpin, "VTKViewer", "recorder_fps" );
3046 pref->setItemProperty( "min", 0.1, fpsPref );
3047 pref->setItemProperty( "max", 100, fpsPref );
3049 int qualityPref = pref->addPreference( tr( "PREF_QUALITY" ), vtkRec,
3050 LightApp_Preferences::IntSpin, "VTKViewer", "recorder_quality" );
3051 pref->setItemProperty( "min", 1, qualityPref );
3052 pref->setItemProperty( "max", 100, qualityPref );
3053 // .... -> progressive mode
3054 pref->addPreference( tr( "PREF_PROGRESSIVE" ), vtkRec,
3055 LightApp_Preferences::Bool, "VTKViewer", "recorder_progressive" );
3056 // ... avi recording sub-group <<end>>
3058 // ... group names sub-group <<start>>
3059 int vtkGN = pref->addPreference( tr( "PREF_FRAME_GROUP_NAMES" ), vtkGroup,
3060 LightApp_Preferences::GroupBox, "VTKViewer", "show_group_names" );
3061 pref->setItemProperty( "columns", 2, vtkGN );
3062 // .... -> text color
3063 pref->addPreference( tr( "PREF_GROUP_NAMES_TEXT_COLOR" ), vtkGN,
3064 LightApp_Preferences::Color, "VTKViewer", "group_names_text_color" );
3065 // .... -> transparency
3066 int transPref = pref->addPreference( tr( "PREF_GROUP_NAMES_TRANSPARENCY" ), vtkGN,
3067 LightApp_Preferences::DblSpin, "VTKViewer", "group_names_transparency" );
3068 pref->setItemProperty( "min", 0.0, transPref );
3069 pref->setItemProperty( "max", 1.0, transPref );
3070 pref->setItemProperty( "step", 0.1, transPref );
3071 // ... -> group names sub-group <<end>>
3072 // .. "VTK viewer" group <<end>>
3075 // .. "Plot2d viewer" group <<start>>
3076 int plot2dGroup = pref->addPreference( tr( "PREF_GROUP_PLOT2DVIEWER" ), salomeCat ); //viewTab
3077 //pref->setItemProperty( "columns", 2, plot2dGroup );
3079 // ... -> background
3080 pref->addPreference( tr( "PREF_VIEWER_BACKGROUND_COLOR" ), plot2dGroup,
3081 LightApp_Preferences::Color, "Plot2d", "Background" );
3082 // ... -> selection color
3083 pref->addPreference( tr( "PREF_VIEWER_SELECTION" ), plot2dGroup,
3084 LightApp_Preferences::Color, "Plot2d", "SelectionColor" );
3086 // ... "Viewer" group <<start>>
3087 int plot2dViewerGroup = pref->addPreference( tr( "PREF_GROUP_VIEWER" ), plot2dGroup );
3089 // .... -> curve type
3090 int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dViewerGroup,
3091 LightApp_Preferences::Selector, "Plot2d", "CurveType" );
3092 aValuesList.clear();
3093 anIndicesList.clear();
3094 aValuesList << tr("PREF_POINTS") << tr("PREF_LINES") << tr("PREF_SPLINE");
3095 anIndicesList << 0 << 1 << 2 ;
3096 pref->setItemProperty( "strings", aValuesList, curveType );
3097 pref->setItemProperty( "indexes", anIndicesList, curveType );
3098 // .... -> marker size
3099 int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dViewerGroup,
3100 LightApp_Preferences::IntSpin, "Plot2d", "MarkerSize" );
3101 pref->setItemProperty( "min", 0, markerSize );
3102 pref->setItemProperty( "max", 100, markerSize );
3103 // .... -> horizontal scaling mode
3104 int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dViewerGroup,
3105 LightApp_Preferences::Selector, "Plot2d", "HorScaleMode" );
3106 aValuesList.clear();
3107 anIndicesList.clear();
3108 aValuesList << tr("PREF_LINEAR") << tr("PREF_LOGARITHMIC");
3109 anIndicesList << 0 << 1 ;
3110 pref->setItemProperty( "strings", aValuesList, horScale );
3111 pref->setItemProperty( "indexes", anIndicesList, horScale );
3112 // .... -> vertical scaling mode
3113 int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dViewerGroup,
3114 LightApp_Preferences::Selector, "Plot2d", "VerScaleMode" );
3115 pref->setItemProperty( "strings", aValuesList, verScale );
3116 pref->setItemProperty( "indexes", anIndicesList, verScale );
3118 // .... -> errors/deviation colot
3119 pref->addPreference( tr( "PREF_DEVIATION_COLOR" ), plot2dViewerGroup,
3120 LightApp_Preferences::Color, "Plot2d", "DeviationMarkerColor" );
3121 // .... -> deviation markers line size
3122 int deviationMarkerLw = pref->addPreference( tr( "PREF_DEVIATION_MARKER_LW" ), plot2dViewerGroup,
3123 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerLineWidth" );
3124 pref->setItemProperty( "min", 1, deviationMarkerLw );
3125 pref->setItemProperty( "max", 5, deviationMarkerLw );
3126 // .... -> deviation markers tick mark size
3127 int deviationMarkerTs = pref->addPreference( tr( "PREF_DEVIATION_MARKER_TS" ), plot2dViewerGroup,
3128 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerTickSize" );
3129 pref->setItemProperty( "min", 1, deviationMarkerTs );
3130 pref->setItemProperty( "max", 5, deviationMarkerTs );
3131 // .... "Viewer" group <<end>>
3133 // ... "Legend" group <<start>>
3134 int plot2dLegendGroup = pref->addPreference( tr( "PREF_GROUP_LEGEND" ), plot2dGroup );
3136 // .... -> show legend
3137 pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dLegendGroup,
3138 LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
3139 // .... -> legend position
3140 int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dLegendGroup,
3141 LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
3142 aValuesList.clear();
3143 anIndicesList.clear();
3144 aValuesList << tr("PREF_LEFT") << tr("PREF_RIGHT") << tr("PREF_TOP") << tr("PREF_BOTTOM");
3145 anIndicesList << 0 << 1 << 2 << 3 ;
3146 pref->setItemProperty( "strings", aValuesList, legendPosition );
3147 pref->setItemProperty( "indexes", anIndicesList, legendPosition );
3148 // .... -> Symbol type
3149 int legendSymbolType = pref->addPreference( tr( "PREF_LEGEND_SYMBOL_TYPE" ), plot2dLegendGroup,
3150 LightApp_Preferences::Selector, "Plot2d", "LegendSymbolType" );
3151 aValuesList.clear();
3152 anIndicesList.clear();
3153 aValuesList << tr("PREF_MARKER_ON_LINE") << tr("PREF_MARKER_ABOVE_LINE");
3154 anIndicesList << 0 << 1 ;
3155 pref->setItemProperty( "strings", aValuesList, legendSymbolType );
3156 pref->setItemProperty( "indexes", anIndicesList, legendSymbolType );
3157 // .... -> legend font
3158 pref->addPreference( tr( "PREF_LEGEND_FONT" ), plot2dLegendGroup, LightApp_Preferences::Font, "Plot2d", "LegendFont" );
3159 // ... -> font color
3160 pref->addPreference( tr( "PREF_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "LegendFontColor" );
3161 // ... -> selection font color
3162 pref->addPreference( tr( "PREF_SELECTED_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "SelectedLegendFontColor" );
3163 // ... "Legend" group <<end>>
3165 // .. "Plot2d viewer" group <<end>>
3167 // .. "PyViewer" preferences tab <<start>>
3168 int pyeditTab = pref->addPreference( tr( "PREF_TAB_PYEDITOR" ), salomeCat );
3169 // ... "Font settings" group <<start>>
3170 int pyFontGroup = pref->addPreference( tr( "PREF_GROUP_PY_FONT" ), pyeditTab );
3171 int pyFont = pref->addPreference( tr( "PREF_PY_FONT" ), pyFontGroup,
3172 LightApp_Preferences::Font, "PyEditor", "Font" );
3173 pref->setItemProperty( "features", QtxFontEdit::Family | QtxFontEdit::Size | QtxFontEdit::UserSize, pyFont );
3174 // ... "Font settings" group <<end>>
3175 // ... "Display settings" group <<start>>
3176 int pyDispGroup = pref->addPreference( tr( "PREF_GROUP_PY_DISPLAY" ), pyeditTab );
3177 pref->setItemProperty( "columns", 2, pyDispGroup );
3178 // ... -> current line highlight
3179 pref->addPreference( tr( "PREF_PY_CURRLINE_HIGHLIGHT" ), pyDispGroup,
3180 LightApp_Preferences::Bool, "PyEditor", "HighlightCurrentLine" );
3181 // ... -> text wrapping
3182 pref->addPreference( tr( "PREF_PY_TEXT_WRAP" ), pyDispGroup,
3183 LightApp_Preferences::Bool, "PyEditor", "TextWrapping" );
3184 // ... -> center cursor on scroll
3185 pref->addPreference( tr( "PREF_PY_CURSON_ON_SCROLL" ), pyDispGroup,
3186 LightApp_Preferences::Bool, "PyEditor", "CenterCursorOnScroll" );
3187 // ... -> line numbers area
3188 pref->addPreference( tr( "PREF_PY_LINE_NUMBS_AREA" ), pyDispGroup,
3189 LightApp_Preferences::Bool, "PyEditor", "LineNumberArea" );
3190 // ... "Display settings" group <<end>>
3192 // ... "Editor settings" group <<start>>
3193 int pyEditGroup = pref->addPreference( tr( "PREF_GROUP_PY_EDITOR" ), pyeditTab );
3194 // ... -> navigation mode
3195 int pyCompletion = pref->addPreference( tr( "PREF_PY_COMPLETION_MODE" ), pyEditGroup,
3196 LightApp_Preferences::Selector, "PyEditor", "CompletionPolicy" );
3197 aValuesList.clear();
3198 anIndicesList.clear();
3199 aValuesList << tr("PREF_PY_NONE") << tr("PREF_PY_AUTO") << tr("PREF_PY_MANUAL") << tr("PREF_PY_ALWAYS");
3200 anIndicesList << 0 << 1 << 2 << 3 ;
3201 pref->setItemProperty( "strings", aValuesList, pyCompletion );
3202 pref->setItemProperty( "indexes", anIndicesList, pyCompletion );
3203 // ... "Editor settings" group <<end>>
3205 // ... "Tab settings" group <<start>>
3206 int pyTabGroup = pref->addPreference( tr( "PREF_GROUP_PY_TAB" ), pyeditTab );
3207 pref->setItemProperty( "columns", 2, pyTabGroup );
3208 // ... -> tab whitespaces
3209 pref->addPreference( tr( "PREF_PY_TAB_WHITESPACES" ), pyTabGroup,
3210 LightApp_Preferences::Bool, "PyEditor", "TabSpaceVisible" );
3212 pref->addPreference( tr( "PREF_PY_TAB_SIZE" ), pyTabGroup,
3213 LightApp_Preferences::IntSpin, "PyEditor", "TabSize" );
3214 // ... "Tab settings" group <<end>>
3215 // ... "Vertical edge settings" group <<start>>
3216 int pyVertEdgeGroup = pref->addPreference( tr( "PREF_GROUP_VERT_EDGE" ), pyeditTab );
3217 pref->setItemProperty( "columns", 2, pyVertEdgeGroup );
3218 // ... -> vertical edge
3219 pref->addPreference( tr( "PREF_PY_VERT_EDGE" ), pyVertEdgeGroup,
3220 LightApp_Preferences::Bool, "PyEditor", "VerticalEdge" );
3221 // ... -> number of columns
3222 pref->addPreference( tr( "PREF_PY_NUM_COLUMNS" ), pyVertEdgeGroup,
3223 LightApp_Preferences::IntSpin, "PyEditor", "NumberColumns" );
3224 // ... "Vertical edge settings" group <<end>>
3225 // .. "PyEditor" preferences tab <<end>>
3227 // .. "Directories" preferences tab <<start>>
3228 int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat );
3229 // ... --> quick directories list
3230 int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab );
3231 pref->addPreference( tr( "" ), dirGroup,
3232 LightApp_Preferences::DirList, "FileDlg", "QuickDirList" );
3233 // .. "Directories" preferences tab <<end>>
3235 // .. "Object browser" preferences tab <<start>>
3236 int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
3238 // ... "Search tool" group <<start>>
3239 int stGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SEARCH_TOOL" ), obTab );
3240 // .... --> auto-hide
3241 pref->addPreference( tr( "PREF_AUTO_HIDE_SEARCH_TOOL" ), stGroup, LightApp_Preferences::Bool,
3242 "ObjectBrowser", "auto_hide_search_tool" );
3243 // ... "Search tool" group <<end>>
3245 // ... "Object browser settings" group <<start>>
3246 int objSetGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), obTab );
3247 pref->setItemProperty( "columns", 2, objSetGroup );
3248 // .... -> auto size first column
3249 pref->addPreference( tr( "PREF_AUTO_SIZE_FIRST" ), objSetGroup, LightApp_Preferences::Bool,
3250 "ObjectBrowser", "auto_size_first" );
3251 // .... -> auto size other columns
3252 pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool,
3253 "ObjectBrowser", "auto_size" );
3254 // .... -> resize columns on expand item
3255 pref->addPreference( tr( "PREF_RESIZE_ON_EXPAND_ITEM" ), objSetGroup, LightApp_Preferences::Bool,
3256 "ObjectBrowser", "resize_on_expand_item" );
3257 // .... -> browse to published object
3258 int browsePublished = pref->addPreference( tr( "PREF_BROWSE_TO_THE_PUBLISHED_OBJECT" ), objSetGroup, LightApp_Preferences::Selector,
3259 "ObjectBrowser", "browse_published_object" );
3260 aValuesList.clear();
3261 anIndicesList.clear();
3262 aValuesList << tr( "PREF_BROWSE_NEVER" ) << tr( "PREF_BROWSE_AFTER_APPLY_AND_CLOSE_ONLY" ) << tr( "PREF_BROWSE_ALWAYS" );
3263 anIndicesList << BP_Never << BP_ApplyAndClose << BP_Always;
3264 pref->setItemProperty( "strings", aValuesList, browsePublished );
3265 pref->setItemProperty( "indexes", anIndicesList, browsePublished );
3266 // ... "Object browser settings" group <<end>>
3267 // .. "Object browser" preferences tab <<end>>
3269 // .. "Shortcuts" preferences tab <<start>>
3270 int shortcutTab = pref->addPreference( tr( "PREF_TAB_SHORTCUTS" ), salomeCat );
3271 // ... "Shortcuts settings" group <<start>>
3272 int shortcutGroup = pref->addPreference( tr( "PREF_GROUP_SHORTCUTS" ), shortcutTab );
3273 pref->addPreference( tr( "" ), shortcutGroup,
3274 LightApp_Preferences::ShortcutTree, "shortcuts" );
3275 // ... "Shortcuts settings" group <<end>>
3276 // .. "Shortcuts" preferences tab <<end>>
3277 // . Top-level "SALOME" preferences group <<end>>
3283 Changes appearance of application according to changed preferences
3284 \param sec - section
3285 \param param - name of changed parameter
3287 void LightApp_Application::preferencesChanged( const QString& sec, const QString& param )
3289 SUIT_ResourceMgr* resMgr = resourceMgr();
3293 if ( sec == "viewers" && param == "drop_down_buttons" )
3295 ViewManagerList vmlist = viewManagers();
3296 foreach( SUIT_ViewManager* vm, vmlist )
3298 QVector<SUIT_ViewWindow*> vwlist = vm->getViews();
3299 foreach( SUIT_ViewWindow* vw, vwlist )
3300 if ( vw ) vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
3304 if ( sec == QString( "3DViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )))
3306 double sz = resMgr->doubleValue( sec, "trihedron_size", -1 );
3307 bool relative = resMgr->booleanValue( sec, "relative_size", true );
3308 QList<SUIT_ViewManager*> lst;
3309 #ifndef DISABLE_OCCVIEWER
3310 viewManagers( OCCViewer_Viewer::Type(), lst );
3311 QListIterator<SUIT_ViewManager*> itOCC( lst );
3312 while ( itOCC.hasNext() && sz >= 0 )
3314 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3315 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3318 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3319 occVM->setTrihedronSize( sz, relative );
3320 occVM->getAISContext()->UpdateCurrentViewer();
3323 #ifndef DISABLE_VTKVIEWER
3324 #ifndef DISABLE_SALOMEOBJECT
3325 viewManagers( SVTK_Viewer::Type(), lst );
3326 QListIterator<SUIT_ViewManager*> itVTK( lst );
3327 while ( itVTK.hasNext() && sz >= 0 )
3329 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3330 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3333 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3336 vtkVM->setTrihedronSize( sz, relative );
3344 if ( sec == QString( "3DViewer" ) && param == QString( "show_static_trihedron" ) )
3346 bool isVisible = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
3347 QList<SUIT_ViewManager*> lst;
3348 #ifndef DISABLE_OCCVIEWER
3349 viewManagers( OCCViewer_Viewer::Type(), lst );
3350 QListIterator<SUIT_ViewManager*> itOCC( lst );
3351 while ( itOCC.hasNext() )
3353 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3354 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3357 OCCViewer_Viewer* occVM = dynamic_cast<OCCViewer_Viewer*>( vm );
3360 occVM->setStaticTrihedronDisplayed( isVisible );
3364 #ifndef DISABLE_VTKVIEWER
3365 #ifndef DISABLE_SALOMEOBJECT
3366 viewManagers( SVTK_Viewer::Type(), lst );
3367 QListIterator<SUIT_ViewManager*> itVTK( lst );
3368 while ( itVTK.hasNext() )
3370 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3371 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3374 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3377 vtkVM->setStaticTrihedronVisible( isVisible );
3385 if ( sec == QString( "3DViewer" ) && param == QString( "navigation_mode" ) )
3387 int mode = resMgr->integerValue( "3DViewer", "navigation_mode", 0 );
3388 QList<SUIT_ViewManager*> lst;
3389 #ifndef DISABLE_OCCVIEWER
3390 viewManagers( OCCViewer_Viewer::Type(), lst );
3391 QListIterator<SUIT_ViewManager*> itOCC( lst );
3392 while ( itOCC.hasNext() )
3394 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3395 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3398 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3399 occVM->setInteractionStyle( mode );
3402 #ifndef DISABLE_VTKVIEWER
3403 #ifndef DISABLE_SALOMEOBJECT
3404 viewManagers( SVTK_Viewer::Type(), lst );
3405 QListIterator<SUIT_ViewManager*> itVTK( lst );
3406 while ( itVTK.hasNext() )
3408 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3409 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3412 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3413 if( vtkVM ) vtkVM->setInteractionStyle( mode );
3419 #ifndef DISABLE_OCCVIEWER
3420 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_preselection" ) )
3422 bool isToEnablePreselection = resMgr->booleanValue( "OCCViewer", "enable_preselection", true );
3423 QList<SUIT_ViewManager*> lst;
3424 viewManagers( OCCViewer_Viewer::Type(), lst );
3425 QListIterator<SUIT_ViewManager*> it( lst );
3426 while ( it.hasNext() )
3428 SUIT_ViewModel* vm = it.next()->getViewModel();
3429 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3432 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3433 occVM->enablePreselection( isToEnablePreselection );
3438 #ifndef DISABLE_OCCVIEWER
3439 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_selection" ) )
3441 bool isToEnableSelection = resMgr->booleanValue( "OCCViewer", "enable_selection", true );
3442 QList<SUIT_ViewManager*> lst;
3443 viewManagers( OCCViewer_Viewer::Type(), lst );
3444 QListIterator<SUIT_ViewManager*> it( lst );
3445 while ( it.hasNext() )
3447 SUIT_ViewModel* vm = it.next()->getViewModel();
3448 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3451 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3452 occVM->enableSelection( isToEnableSelection );
3457 #ifndef DISABLE_OCCVIEWER
3458 if ( sec == QString( "OCCViewer" ) && param == QString( "clipping_color" ) )
3460 QColor aColor = resMgr->colorValue( "OCCViewer", "clipping_color", QColor( 50, 50, 50 ) );
3461 QList<SUIT_ViewManager*> lst;
3462 viewManagers( OCCViewer_Viewer::Type(), lst );
3463 QListIterator<SUIT_ViewManager*> it( lst );
3464 while ( it.hasNext() )
3466 SUIT_ViewModel* vm = it.next()->getViewModel();
3467 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3470 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3471 occVM->setClippingColor( aColor );
3476 #ifndef DISABLE_OCCVIEWER
3477 if ( sec == QString( "OCCViewer" ) && ( param == QString( "clipping_use_default_texture" ) ||
3478 param == QString( "clipping_texture" ) ||
3479 param == QString( "clipping_modulate" ) ||
3480 param == QString( "clipping_scale" ) ) )
3482 bool isDefaultTextureUsed = resMgr->booleanValue( "OCCViewer", "clipping_use_default_texture" );
3483 QString aTexture = resMgr->stringValue( "OCCViewer", "clipping_texture" );
3484 bool isModulated = resMgr->booleanValue( "OCCViewer", "clipping_modulate" );
3485 double aScale = resMgr->doubleValue( "OCCViewer", "clipping_scale" );
3486 QList<SUIT_ViewManager*> lst;
3487 viewManagers( OCCViewer_Viewer::Type(), lst );
3488 QListIterator<SUIT_ViewManager*> it( lst );
3489 while ( it.hasNext() )
3491 SUIT_ViewModel* vm = it.next()->getViewModel();
3492 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3495 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3496 occVM->setClippingTextureParams( isDefaultTextureUsed, aTexture, isModulated, aScale );
3501 #ifndef DISABLE_OCCVIEWER
3502 if ( sec == QString( "OCCViewer" ) && param == QString( "projection_mode" ) )
3504 int mode = resMgr->integerValue( "OCCViewer", "projection_mode", 0 );
3505 QList<SUIT_ViewManager*> lst;
3506 viewManagers( OCCViewer_Viewer::Type(), lst );
3507 QListIterator<SUIT_ViewManager*> it( lst );
3508 while ( it.hasNext() )
3510 SUIT_ViewModel* vm = it.next()->getViewModel();
3511 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3514 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3515 occVM->setProjectionType( mode );
3521 #ifndef DISABLE_OCCVIEWER
3522 if (sec == QString("OCCViewer") && param == QString("adv_selection_mode"))
3524 int mode = resMgr->integerValue("OCCViewer", "adv_selection_mode", 0);
3525 QList<SUIT_ViewManager*> lst;
3526 viewManagers(OCCViewer_Viewer::Type(), lst);
3527 QListIterator<SUIT_ViewManager*> it(lst);
3528 while (it.hasNext())
3530 SUIT_ViewModel* vm = it.next()->getViewModel();
3531 if (!vm || !vm->inherits("OCCViewer_Viewer"))
3534 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3535 occVM->setSelectionStyle((OCCViewer_ViewWindow::SelectionStyle)mode);
3541 #ifndef DISABLE_OCCVIEWER
3542 if ( sec == QString( "OCCViewer" ) && param == QString( "stereo_type" ) )
3544 int mode = resMgr->integerValue( "OCCViewer", "stereo_type", 0 );
3545 QList<SUIT_ViewManager*> lst;
3546 viewManagers( OCCViewer_Viewer::Type(), lst );
3547 QListIterator<SUIT_ViewManager*> it( lst );
3548 while ( it.hasNext() )
3550 SUIT_ViewModel* vm = it.next()->getViewModel();
3551 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3554 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3555 occVM->setStereoType( mode );
3560 #ifndef DISABLE_OCCVIEWER
3561 if ( sec == QString( "OCCViewer" ) && param == QString( "anaglyph_filter" ) )
3563 int mode = resMgr->integerValue( "OCCViewer", "anaglyph_filter", 0 );
3564 QList<SUIT_ViewManager*> lst;
3565 viewManagers( OCCViewer_Viewer::Type(), lst );
3566 QListIterator<SUIT_ViewManager*> it( lst );
3567 while ( it.hasNext() )
3569 SUIT_ViewModel* vm = it.next()->getViewModel();
3570 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3573 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3574 occVM->setAnaglyphFilter( mode );
3579 #ifndef DISABLE_OCCVIEWER
3580 if ( sec == QString( "OCCViewer" ) && ( param == QString( "focus_type" ) ||
3581 param == QString( "focus_value" ) ) )
3583 int aType = resMgr->integerValue( "OCCViewer", "focus_type" );
3584 double aValue = resMgr->doubleValue( "OCCViewer", "focus_value" );
3585 QList<SUIT_ViewManager*> lst;
3586 viewManagers( OCCViewer_Viewer::Type(), lst );
3587 QListIterator<SUIT_ViewManager*> it( lst );
3588 while ( it.hasNext() )
3590 SUIT_ViewModel* vm = it.next()->getViewModel();
3591 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3594 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3595 occVM->setStereographicFocus( aType, aValue );
3600 #ifndef DISABLE_OCCVIEWER
3601 if ( sec == QString( "OCCViewer" ) && ( param == QString( "iod_type" ) ||
3602 param == QString( "iod_value" ) ) )
3604 int aType = resMgr->integerValue( "OCCViewer", "iod_type" );
3605 double aValue = resMgr->doubleValue( "OCCViewer", "iod_value" );
3606 QList<SUIT_ViewManager*> lst;
3607 viewManagers( OCCViewer_Viewer::Type(), lst );
3608 QListIterator<SUIT_ViewManager*> it( lst );
3609 while ( it.hasNext() )
3611 SUIT_ViewModel* vm = it.next()->getViewModel();
3612 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3615 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3616 occVM->setInterocularDistance( aType, aValue );
3621 #ifndef DISABLE_OCCVIEWER
3622 if ( sec == QString( "OCCViewer" ) && param == QString( "reverse_stereo" ) )
3624 bool reverse = resMgr->booleanValue( "OCCViewer", "reverse_stereo", false );
3625 QList<SUIT_ViewManager*> lst;
3626 viewManagers( OCCViewer_Viewer::Type(), lst );
3627 QListIterator<SUIT_ViewManager*> it( lst );
3628 while ( it.hasNext() )
3630 SUIT_ViewModel* vm = it.next()->getViewModel();
3631 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3634 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3635 occVM->setReverseStereo( reverse );
3640 #ifndef DISABLE_OCCVIEWER
3641 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_vsync" ) )
3643 bool enable = resMgr->booleanValue( "OCCViewer", "enable_vsync", true );
3644 QList<SUIT_ViewManager*> lst;
3645 viewManagers( OCCViewer_Viewer::Type(), lst );
3646 QListIterator<SUIT_ViewManager*> it( lst );
3647 while ( it.hasNext() )
3649 SUIT_ViewModel* vm = it.next()->getViewModel();
3650 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3653 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3654 occVM->setVSync( enable );
3659 #ifndef DISABLE_OCCVIEWER
3660 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_quad_buffer_support" ) )
3662 bool enable = resMgr->booleanValue( "OCCViewer", "enable_quad_buffer_support", false );
3663 QList<SUIT_ViewManager*> lst;
3664 viewManagers( OCCViewer_Viewer::Type(), lst );
3665 QListIterator<SUIT_ViewManager*> it( lst );
3666 while ( it.hasNext() )
3668 SUIT_ViewModel* vm = it.next()->getViewModel();
3669 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3672 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3673 occVM->setQuadBufferSupport( enable );
3678 #ifndef DISABLE_OCCVIEWER
3679 if ( sec == QString( "OCCViewer" ) && param.contains( "viewcube" ) )
3681 QList<SUIT_ViewManager*> lst;
3682 viewManagers( OCCViewer_Viewer::Type(), lst );
3683 QListIterator<SUIT_ViewManager*> it( lst );
3684 while ( it.hasNext() )
3686 SUIT_ViewModel* vm = it.next()->getViewModel();
3687 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3690 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3691 occVM->setViewCubeParamsFromPreferences();
3696 if ( sec == QString( "3DViewer" ) && param == QString( "zooming_mode" ) )
3698 int mode = resMgr->integerValue( "3DViewer", "zooming_mode", 0 );
3699 QList<SUIT_ViewManager*> lst;
3700 #ifndef DISABLE_OCCVIEWER
3701 viewManagers( OCCViewer_Viewer::Type(), lst );
3702 QListIterator<SUIT_ViewManager*> itOCC( lst );
3703 while ( itOCC.hasNext() )
3705 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3706 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3709 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3710 occVM->setZoomingStyle( mode );
3713 #ifndef DISABLE_VTKVIEWER
3714 #ifndef DISABLE_SALOMEOBJECT
3715 viewManagers( SVTK_Viewer::Type(), lst );
3716 QListIterator<SUIT_ViewManager*> itVTK( lst );
3717 while ( itVTK.hasNext() )
3719 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3720 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3723 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3724 if( vtkVM ) vtkVM->setZoomingStyle( mode );
3730 #ifndef DISABLE_VTKVIEWER
3731 if ( sec == QString( "VTKViewer" ) && (param == QString( "speed_value" ) || param == QString( "speed_mode" )) )
3733 int speed = resMgr->integerValue( "VTKViewer", "speed_value", 10 );
3734 int mode = resMgr->integerValue( "VTKViewer", "speed_mode", 0 );
3735 QList<SUIT_ViewManager*> lst;
3736 #ifndef DISABLE_SALOMEOBJECT
3737 viewManagers( SVTK_Viewer::Type(), lst );
3738 QListIterator<SUIT_ViewManager*> it( lst );
3739 while ( it.hasNext() )
3741 SUIT_ViewModel* vm = it.next()->getViewModel();
3742 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3745 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3746 if( vtkVM ) vtkVM->setIncrementalSpeed( speed, mode );
3752 #ifndef DISABLE_VTKVIEWER
3753 if ( sec == QString( "VTKViewer" ) && param == QString( "projection_mode" ) )
3755 int mode = resMgr->integerValue( "VTKViewer", "projection_mode", 0 );
3756 QList<SUIT_ViewManager*> lst;
3757 #ifndef DISABLE_SALOMEOBJECT
3758 viewManagers( SVTK_Viewer::Type(), lst );
3759 QListIterator<SUIT_ViewManager*> it( lst );
3760 while ( it.hasNext() )
3762 SUIT_ViewModel* vm = it.next()->getViewModel();
3763 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3766 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3767 if( vtkVM ) vtkVM->setProjectionMode( mode );
3773 #ifndef DISABLE_VTKVIEWER
3774 if ( sec == QString( "VTKViewer" ) && param == QString( "stereo_type" ) )
3776 int mode = resMgr->integerValue( "VTKViewer", "stereo_type", 0 );
3777 QList<SUIT_ViewManager*> lst;
3778 #ifndef DISABLE_SALOMEOBJECT
3779 viewManagers( SVTK_Viewer::Type(), lst );
3780 QListIterator<SUIT_ViewManager*> it( lst );
3781 while ( it.hasNext() )
3783 SUIT_ViewModel* vm = it.next()->getViewModel();
3784 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3787 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3788 if( vtkVM ) vtkVM->setStereoType( mode );
3794 #ifndef DISABLE_VTKVIEWER
3795 if ( sec == QString( "VTKViewer" ) && param == QString( "anaglyph_filter" ) )
3797 int mode = resMgr->integerValue( "VTKViewer", "anaglyph_filter", 0 );
3798 QList<SUIT_ViewManager*> lst;
3799 #ifndef DISABLE_SALOMEOBJECT
3800 viewManagers( SVTK_Viewer::Type(), lst );
3801 QListIterator<SUIT_ViewManager*> it( lst );
3802 while ( it.hasNext() )
3804 SUIT_ViewModel* vm = it.next()->getViewModel();
3805 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3808 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3809 if( vtkVM ) vtkVM->setAnaglyphFilter( mode );
3815 #ifndef DISABLE_VTKVIEWER
3816 if ( sec == QString( "VTKViewer" ) && param == QString( "enable_quad_buffer_support" ) )
3818 int enable = resMgr->booleanValue( "VTKViewer", "enable_quad_buffer_support", false );
3819 QList<SUIT_ViewManager*> lst;
3820 #ifndef DISABLE_SALOMEOBJECT
3821 viewManagers( SVTK_Viewer::Type(), lst );
3822 QListIterator<SUIT_ViewManager*> it( lst );
3823 while ( it.hasNext() )
3825 SUIT_ViewModel* vm = it.next()->getViewModel();
3826 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3829 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3830 if( vtkVM ) vtkVM->setQuadBufferSupport( enable );
3836 #ifndef DISABLE_VTKVIEWER
3837 if ( sec == QString( "VTKViewer" ) && param == QString( "preselection" ) )
3839 int mode = resMgr->integerValue( "VTKViewer", "preselection", 0 );
3840 QList<SUIT_ViewManager*> lst;
3841 #ifndef DISABLE_SALOMEOBJECT
3842 viewManagers( SVTK_Viewer::Type(), lst );
3843 QListIterator<SUIT_ViewManager*> it( lst );
3844 while ( it.hasNext() )
3846 SUIT_ViewModel* vm = it.next()->getViewModel();
3847 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3850 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3851 if( vtkVM ) vtkVM->setPreSelectionMode( mode );
3857 #ifndef DISABLE_VTKVIEWER
3858 if ( sec == QString( "VTKViewer" ) && param == QString( "enable_selection" ) )
3860 bool isToEnableSelection = resMgr->booleanValue( "VTKViewer", "enable_selection", true );
3861 QList<SUIT_ViewManager*> lst;
3862 #ifndef DISABLE_SALOMEOBJECT
3863 viewManagers( SVTK_Viewer::Type(), lst );
3864 QListIterator<SUIT_ViewManager*> it( lst );
3865 while ( it.hasNext() )
3867 SUIT_ViewModel* vm = it.next()->getViewModel();
3868 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3871 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3872 if( vtkVM ) vtkVM->enableSelection( isToEnableSelection );
3878 #ifndef DISABLE_VTKVIEWER
3879 if ( sec == QString( "VTKViewer" ) && (param == QString( "spacemouse_func1_btn" ) ||
3880 param == QString( "spacemouse_func2_btn" ) ||
3881 param == QString( "spacemouse_func5_btn" ) ) )
3883 int btn1 = resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", 1 );
3884 int btn2 = resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", 2 );
3885 int btn3 = resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", 9 );
3886 QList<SUIT_ViewManager*> lst;
3887 #ifndef DISABLE_SALOMEOBJECT
3888 viewManagers( SVTK_Viewer::Type(), lst );
3889 QListIterator<SUIT_ViewManager*> it( lst );
3890 while ( it.hasNext() )
3892 SUIT_ViewModel* vm = it.next()->getViewModel();
3893 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3896 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3897 if( vtkVM ) vtkVM->setSpacemouseButtons( btn1, btn2, btn3 );
3902 if( sec=="ObjectBrowser" )
3904 SUIT_DataBrowser* ob = objectBrowser();
3908 if ( param=="auto_size_first" )
3910 bool autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
3911 ob->setAutoSizeFirstColumn( autoSizeFirst );
3912 if ( autoSizeFirst )
3913 ob->adjustFirstColumnWidth();
3915 else if ( param=="auto_size" ) {
3916 bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
3917 ob->setAutoSizeColumns(autoSize);
3919 ob->adjustColumnsWidth();
3921 else if ( param=="resize_on_expand_item" ) {
3922 bool resizeOnExpandItem = resMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
3923 ob->setResizeOnExpandItem(resizeOnExpandItem);
3925 else if ( param == "auto_hide_search_tool" ) {
3926 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
3932 if( param=="auto_save_interval" ) {
3933 myAutoSaveTimer->stop();
3934 int autoSaveInterval = resMgr->integerValue( "Study", "auto_save_interval", 0 );
3935 if ( activeStudy() && autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
3939 #ifndef DISABLE_PYCONSOLE
3940 if( sec=="PyConsole" && pythonConsole() )
3942 if ( param=="font" ) {
3943 pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) );
3945 else if ( param=="show_banner" ) {
3946 pythonConsole()->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
3948 else if ( param=="auto_completion" ) {
3949 pythonConsole()->setAutoCompletion( resMgr->booleanValue( "PyConsole", "auto_completion", true ) );
3956 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3958 if ( param == "visible_count" )
3959 mru->setVisibleCount( resMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
3960 else if ( param == "max_count" )
3961 mru->setHistoryCount( resMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
3962 else if ( param == "insert_mode" )
3963 mru->setInsertMode( resMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
3964 else if ( param == "link_type" )
3965 mru->setLinkType( resMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
3966 else if ( param == "show_clear" )
3967 mru->setClearPossible( resMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
3968 else if ( param == "show_mru" )
3969 mru->setVisible( resMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
3972 if ( sec == "language" && param == "language" )
3974 // VSR 18.06.2015 : commented out : single warning dialog box is now shown by the LightApp_PreferencesDlg
3975 //SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LANG_CHANGED" ) );
3977 if ( sec == "language" && param == "locale")
3979 // VSR 18.06.2015: commented out : single warning dialog box is now shown by the LightApp_PreferencesDlg
3980 //SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LOCALE_CHANGED" ) );
3982 if ( sec == "desktop" && param == "opaque_resize" ) {
3983 bool opaqueResize = resMgr->booleanValue( "desktop", "opaque_resize", false );
3984 // RNV: This code has been commented, because clearing of the QMainWindow::AnimatedDocks option
3985 // leads to strange behaviour of the dockable windows (at least at qt-5.6.1):
3986 // any dockable window can't be docked to the another area, except initial area.
3987 // It is possible to move window to another area, but it always returns to the initial area.
3989 // QMainWindow::DockOptions dopts = desktop()->dockOptions();
3990 // if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
3991 // else dopts &= ~QMainWindow::AnimatedDocks;
3992 // desktop()->setDockOptions( dopts );
3993 desktop()->setOpaqueResize( opaqueResize );
3994 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
3995 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
3998 #ifndef DISABLE_PLOT2DVIEWER
3999 QList<SUIT_ViewManager*> lst;
4000 viewManagers( Plot2d_Viewer::Type(), lst );
4001 QListIterator<SUIT_ViewManager*> itPlot2d( lst );
4002 while ( itPlot2d.hasNext() ) {
4003 SUIT_ViewManager* viewMgr = itPlot2d.next();
4004 SUIT_ViewModel* vm = viewMgr->getViewModel();
4005 if ( !vm || !vm->inherits( "Plot2d_Viewer" ) )
4008 //Plot2d_Viewer* Plot2dVM = dynamic_cast<Plot2d_Viewer*>( vm );
4010 viewMgr->setViewModel( vm );
4011 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
4013 Plot2d_ViewFrame* frame = wnd->getViewFrame();
4014 frame->SetPreference();
4023 void LightApp_Application::loadPreferences()
4025 CAM_Application::loadPreferences();
4027 SUIT_ResourceMgr* aResMgr = resourceMgr();
4032 static bool mru_load = true;
4035 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
4037 mru->setVisible( aResMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
4038 mru->setVisibleCount( aResMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
4039 mru->setHistoryCount( aResMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
4040 mru->setInsertMode( aResMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
4041 mru->setLinkType( aResMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
4042 mru->setClearPossible( aResMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
4043 mru->loadLinks( aResMgr, "MRU" );
4049 QStringList mods = aResMgr->parameters( "windows_visibility" );
4050 for ( QStringList::const_iterator itr = mods.begin(); itr != mods.end(); ++itr )
4053 if ( aResMgr->value( "windows_visibility", *itr, arr ) )
4054 myWinVis.insert( *itr, arr );
4058 desktop()->retrieveGeometry( aResMgr->stringValue( "desktop", "geometry" ) );
4059 bool opaqueResize = aResMgr->booleanValue( "desktop", "opaque_resize", false );
4060 // QMainWindow::DockOptions dopts = desktop()->dockOptions();
4061 // if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
4062 // else dopts &= ~QMainWindow::AnimatedDocks;
4063 // desktop()->setDockOptions( dopts );
4064 desktop()->setOpaqueResize( opaqueResize );
4065 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
4066 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
4073 void LightApp_Application::savePreferences()
4075 CAM_Application::savePreferences();
4077 saveDockWindowsState();
4079 SUIT_ResourceMgr* aResMgr = resourceMgr();
4084 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
4086 mru->saveLinks( aResMgr, "MRU" );
4088 for ( WinVis::const_iterator itr = myWinVis.begin(); itr != myWinVis.end(); ++itr )
4089 aResMgr->setValue( "windows_visibility", itr.key(), itr.value() );
4092 aResMgr->setValue( "desktop", "geometry", desktop()->storeGeometry() );
4094 #if GUI_DEVELOPMENT > 0
4095 aResMgr->setValue( "salome", "version", QString(GUI_VERSION_STR)+"dev" );
4097 aResMgr->setValue( "salome", "version", QString(GUI_VERSION_STR) );
4104 Updates desktop title
4106 void LightApp_Application::updateDesktopTitle()
4108 QString aTitle = applicationName();
4109 QString aVer = applicationVersion();
4110 if ( !aVer.isEmpty() )
4111 aTitle += QString( " " ) + aVer;
4113 if ( activeStudy() ) {
4114 QString sName = SUIT_Tools::file( activeStudy()->studyName().trimmed(), false );
4115 aTitle += QString( " - [%1]" ).arg( sName );
4118 desktop()->setWindowTitle( aTitle );
4122 \brief Get map of the operations which can be performed
4123 on the module activation.
4125 The method should return the map of the kind \c {<id>:<name>}
4126 where \c <id> is an integer identifier of the operation and
4127 \c <name> is a title for the button to be added to the
4128 dialog box. After user selects the required operation by the
4129 clicking the corresponding button in the dialog box, its identifier
4130 is passed to the moduleActionSelected() method to process
4133 \return map of the operations
4134 \sa moduleActionSelected()
4136 QMap<int, QString> LightApp_Application::activateModuleActions() const
4138 QMap<int, QString> opmap;
4139 opmap.insert( NewStudyId, tr( "ACTIVATE_MODULE_OP_NEW" ) );
4140 opmap.insert( OpenStudyId, tr( "ACTIVATE_MODULE_OP_OPEN" ) );
4145 \brief Called when the used selectes required operation chosen
4146 from "Activate module" dialog box.
4148 Performs the required operation according to the user choice.
4150 \param id operation identifier
4151 \sa activateModuleActions()
4153 void LightApp_Application::moduleActionSelected( const int id )
4168 Updates windows after close document
4170 void LightApp_Application::afterCloseDoc()
4174 CAM_Application::afterCloseDoc();
4178 Updates actions of active module
4180 void LightApp_Application::updateModuleActions()
4182 emit moduleActivated( activeModule() ? activeModule()->moduleName() : QString() );
4185 bool LightApp_Application::checkModule( const QString& title )
4187 if ( title.isEmpty() )
4190 QString library = moduleLibrary( title, true );
4191 if ( library.isEmpty() )
4194 QString name = moduleName( title );
4196 bool isPyModule = library.contains( "SalomePyQtGUI" ) || library.contains( "SalomePyQtGUILight" );
4200 paths = QString( Qtx::getenv( "PATH" ) ).split( ";", QString::SkipEmptyParts );
4201 #elif defined(__APPLE__)
4202 paths = QString( Qtx::getenv( "DYLD_LIBRARY_PATH" ) ).split( ":", QString::SkipEmptyParts );
4204 paths = QString( Qtx::getenv( "LD_LIBRARY_PATH" ) ).split( ":", QString::SkipEmptyParts );
4207 bool isFound = false;
4208 QStringList::const_iterator it;
4209 for ( it = paths.begin(); it != paths.end() && !isFound; ++it )
4211 isFound = QFileInfo( Qtx::addSlash( *it ) + library ).exists();
4217 "****************************************************************" << std::endl <<
4218 " Warning: library " << qPrintable( library ) << " is not found!" << std::endl <<
4219 " Module " << qPrintable( title ) << " will not be available in GUI mode!" << std::endl <<
4220 "****************************************************************" << std::endl);
4226 QString pyModule = QString( "%1GUI.py" ).arg( name );
4228 paths = QString( Qtx::getenv( "PYTHONPATH" ) ).split( ";", QString::SkipEmptyParts );
4230 paths = QString( Qtx::getenv( "PYTHONPATH" ) ).split( ":", QString::SkipEmptyParts );
4233 for ( it = paths.begin(); it != paths.end() && !isFound; ++it )
4235 isFound = QFileInfo( Qtx::addSlash( *it ) + pyModule ).exists();
4241 "****************************************************************" << std::endl <<
4242 " Warning: Python module " << qPrintable( pyModule ) << " is not found!" << std::endl <<
4243 " Module " << qPrintable( title ) << " will not be available in GUI mode!" << std::endl <<
4244 "****************************************************************" << std::endl);
4253 Gets current windows.
4254 \param winMap - output current windows map.
4256 void LightApp_Application::currentWindows( QMap<int, int>& winMap ) const
4259 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
4260 ((LightApp_Module*)activeModule())->windows( winMap );
4262 defaultWindows( winMap );
4266 Gets current view managers.
4267 \param lst - output current view managers list.
4269 void LightApp_Application::currentViewManagers( QStringList& lst ) const
4272 if ( !activeStudy() )
4275 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
4276 ((LightApp_Module*)activeModule())->viewManagers( lst );
4278 defaultViewManagers( lst );
4284 void LightApp_Application::updateWindows()
4286 QMap<int, int> winMap;
4287 currentWindows( winMap );
4289 for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
4291 if ( !dockWindow( it.key() ) )
4292 getWindow( it.key() );
4295 for ( WinMap::ConstIterator it = myWin.begin(); it != myWin.end(); ++it )
4297 QWidget* wid = it.value();
4300 if ( winMap.contains( it.key() ) )
4301 wid->setVisible( true );
4302 else if ( !activeStudy() )
4305 wid->setVisible( false );
4308 loadDockWindowsState();
4310 if ( !activeModule() && infoPanel() )
4312 infoPanel()->clear();
4313 infoPanel()->setTitle( tr( "INFO_WELCOME_TO_SALOME" ) );
4315 int grp = infoPanel()->addGroup( tr( "INFO_GETTING_STARTED" ) );
4316 infoPanel()->addAction( action( FileNewId ), grp );
4317 infoPanel()->addLabel( action( FileNewId )->statusTip(), grp );
4318 infoPanel()->addAction( action( FileOpenId ), grp );
4319 infoPanel()->addLabel( action( FileOpenId )->statusTip(), grp );
4320 if ( HAS_TUTORIAL_URL ) {
4321 infoPanel()->addAction( action( TutorialsId ), grp );
4322 infoPanel()->addLabel( action( TutorialsId )->statusTip(), grp );
4324 infoPanel()->addAction( action( VideosId ), grp );
4325 infoPanel()->addLabel( action( VideosId )->statusTip(), grp );
4327 LightApp_ModuleAction* ma = qobject_cast<LightApp_ModuleAction*>(action(ModulesListId));
4328 if ( ma && ma->count() > 0 )
4330 grp = infoPanel()->addGroup( tr( "INFO_AVAILABLE_MODULES" ) );
4331 foreach ( QString mname, ma->modules() )
4333 infoPanel()->addAction( ma->moduleAction( mname ), grp );
4334 if ( !moduleDescription( mname ).isEmpty() )
4335 infoPanel()->addLabel( moduleDescription( mname ), grp );
4342 Updates view managers
4344 void LightApp_Application::updateViewManagers()
4347 currentViewManagers( lst );
4349 for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
4350 getViewManager( *it, true );
4354 Loads windows geometry
4356 void LightApp_Application::loadDockWindowsState()
4360 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
4361 bool storeWin = aResMgr->booleanValue( "Study", "store_positions", true );
4362 bool storeTb = aResMgr->booleanValue( "Study", "store_tool_positions", true );
4365 if ( activeModule() )
4366 modName = activeModule()->name();
4367 else if ( activeStudy() )
4368 modName = "nomodule";
4370 QtxResourceMgr::WorkingMode prevMode = aResMgr->setWorkingMode( QtxResourceMgr::IgnoreUserValues );
4371 QByteArray aDefaultState;
4372 aResMgr->value( "windows_geometry", modName, aDefaultState );
4373 QByteArray aDefaultVisibility;
4374 aResMgr->value( "windows_visibility", modName, aDefaultVisibility );
4375 bool hasDefaultVisibility = !aDefaultVisibility.isEmpty();
4376 aResMgr->setWorkingMode( prevMode );
4378 if( !storeWin && !storeTb && aDefaultState.isEmpty() && !hasDefaultVisibility)
4381 if ( aResMgr->hasValue("windows_geometry" ,modName ) ) {
4382 long version = Qtx::versionToId( aResMgr->stringValue( "windows_geometry_version", modName, "" ) );
4384 if ( version > Qtx::versionToId( "7.4.1" ) )
4385 aResMgr->value( "windows_geometry", modName , arr );
4387 arr = aDefaultState;
4388 QByteArray aTargetArray = processState(arr, storeWin, storeTb, true, aDefaultState);
4389 desktop()->restoreState( aTargetArray );
4392 QStringList mainToolbarsNames;
4393 mainToolbarsNames << "SalomeStandard" << "SalomeModules";
4394 QList<QToolBar*> mainToolbars = findToolBars( mainToolbarsNames );
4395 foreach( QToolBar* tb, mainToolbars ) tb->setVisible( true );
4397 if ( !myWinVis.contains( modName ) && aDefaultVisibility.isEmpty())
4400 QMap<QString, bool> *tbMap = 0;
4401 QMap<QString, bool> *dwMap = 0;
4403 QMap<QString, bool> userTbMap, userDwMap;
4404 dockWindowsState( myWinVis[modName], userTbMap, userDwMap );
4406 QMap<QString, bool> defaultTbMap, defaultDwMap;
4407 if(hasDefaultVisibility) {
4408 dockWindowsState( aDefaultVisibility, defaultTbMap, defaultDwMap);
4414 if(hasDefaultVisibility){
4415 tbMap = &defaultTbMap;
4422 if(hasDefaultVisibility){
4423 dwMap = &defaultDwMap;
4428 QList<QToolBar*> tbList = findToolBars();
4429 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit )
4431 QToolBar* tb = *tit;
4432 if ( tbMap->contains( tb->objectName() ) ) {
4433 tb->setVisible( (*tbMap)[tb->objectName()] );
4439 QList<QDockWidget*> dwList = desktop()->findChildren<QDockWidget*>();
4440 for ( QList<QDockWidget*>::iterator dit = dwList.begin(); dit != dwList.end(); ++dit )
4442 QDockWidget* dw = *dit;
4444 QObject* po = Qtx::findParent( dw, "QMainWindow" );
4445 if ( po != desktop() )
4448 if ( dwMap->contains( dw->objectName() ) )
4449 dw->setVisible( (*dwMap)[dw->objectName()] );
4457 Saves windows geometry
4459 void LightApp_Application::saveDockWindowsState()
4464 bool storeWin = resourceMgr()->booleanValue( "Study", "store_positions", true );
4465 bool storeTb = resourceMgr()->booleanValue( "Study", "store_tool_positions", true );
4467 if( !storeWin && !storeTb )
4471 if ( activeModule() )
4472 modName = activeModule()->name();
4473 else if ( activeStudy() )
4474 modName = "nomodule";
4476 QString versionId = GUI_VERSION_STR;
4477 #if GUI_DEVELOPMENT > 0
4481 QByteArray arr = desktop()->saveState();
4482 resourceMgr()->setValue( "windows_geometry", modName, processState(arr, storeWin, storeTb, false) );
4483 resourceMgr()->setValue( "windows_geometry_version", modName, versionId );
4486 if ( myWinVis.contains( modName ) )
4487 visArr = myWinVis[modName];
4489 QMap<QString, bool> tbMap, dwMap;
4490 dockWindowsState( visArr, tbMap, dwMap );
4492 QList<QToolBar*> tbList = desktop()->findChildren<QToolBar*>();
4493 for ( QList<QToolBar*>::iterator it = tbList.begin(); it != tbList.end(); ++it )
4496 tbMap.insert( tb->objectName(), tb->toggleViewAction()->isChecked() );
4499 QList<QDockWidget*> dwList = desktop()->findChildren<QDockWidget*>();
4500 for ( QList<QDockWidget*>::iterator it = dwList.begin(); it != dwList.end(); ++it )
4502 QDockWidget* wid = *it;
4503 dwMap.insert( wid->objectName(), wid->toggleViewAction()->isChecked() );
4506 visArr = dockWindowsState( tbMap, dwMap );
4508 myWinVis.insert( modName, visArr );
4511 QByteArray LightApp_Application::dockWindowsState( const QMap<QString, bool>& tb, const QMap<QString, bool>& dw ) const
4514 QDataStream stream( &visArr, QIODevice::WriteOnly );
4516 stream << (uchar)ToolBarMarker;
4517 stream << tb.size();
4518 for ( QMap<QString, bool>::const_iterator tit = tb.begin(); tit != tb.end(); ++tit )
4520 stream << tit.key();
4521 stream << (uchar)( tit.value() ? 1 : 0 );
4524 stream << (uchar)DockWidgetMarker;
4525 stream << dw.size();
4526 for ( QMap<QString, bool>::const_iterator wit = dw.begin(); wit != dw.end(); ++wit )
4528 stream << wit.key();
4529 stream << (uchar)( wit.value() ? 1 : 0 );
4535 void LightApp_Application::dockWindowsState( const QByteArray& arr, QMap<QString, bool>& tb, QMap<QString, bool>& dw ) const
4540 QByteArray visArr = arr;
4541 QDataStream stream( &visArr, QIODevice::ReadOnly );
4545 if ( marker != ToolBarMarker )
4550 for ( int i = 0; i < lines; ++i )
4553 stream >> objectName;
4556 tb.insert( objectName, shown );
4560 if ( marker != DockWidgetMarker )
4564 for ( int j = 0; j < lines; ++j )
4567 stream >> objectName;
4570 dw.insert( objectName, shown );
4574 QPixmap LightApp_Application::moduleIcon( const QString& moduleTitle, const int size ) const
4577 if ( resourceMgr() )
4579 QPixmap defaultIcon = resourceMgr()->loadPixmap( "LightApp", tr( "APP_MODULE_ICO" ), QPixmap( imageEmptyIcon ) );
4580 QString iconName = resourceMgr()->stringValue( moduleName( moduleTitle ), "icon", QString() );
4581 icon = resourceMgr()->loadPixmap( moduleName( moduleTitle ), iconName, defaultIcon );
4583 icon = Qtx::scaleIcon( icon, size );
4589 Inserts items in popup, which necessary for current application
4591 void LightApp_Application::contextMenuPopup( const QString& type, QMenu* thePopup, QString& title )
4594 LightApp_SelectionMgr* selMgr = LightApp_Application::selectionMgr();
4595 bool cacheIsOn = selMgr->isSelectionCacheEnabled();
4596 selMgr->setSelectionCacheEnabled( true );
4598 SUIT_DataBrowser* ob = objectBrowser();
4600 CAM_Application::contextMenuPopup( type, thePopup, title );
4602 if ( ob && type == ob->popupClientType() ) {
4603 thePopup->addSeparator();
4604 QAction* a = thePopup->addAction( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
4605 if ( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) )
4606 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) );
4609 #ifndef DISABLE_SALOMEOBJECT
4610 if ( selMgr && ob ) {
4611 SALOME_ListIO selected;
4612 selMgr->selectedObjects( selected );
4613 if(selected.Extent() == 1){
4614 Handle(SALOME_InteractiveObject) anIObject = selected.First();
4615 SUIT_DataObject* obj = findObject(anIObject->getEntry());
4616 if(obj && obj->renameAllowed()) {
4617 QAction* a = new QAction(tr("MEN_RENAME_OBJ"), thePopup);
4618 connect( a, SIGNAL( triggered(bool) ), ob, SLOT( onStartEditing() ) );
4619 if ( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) )
4620 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) );
4622 QList<QAction*> acts = thePopup->actions();
4623 QAction* firstAction = acts.count() > 0 ? acts.first() : 0;
4624 thePopup->insertAction(firstAction,a);
4630 selMgr->setSelectionCacheEnabled( cacheIsOn );
4636 void LightApp_Application::createEmptyStudy()
4638 CAM_Application::createEmptyStudy();
4640 if ( objectBrowser() )
4641 objectBrowser()->updateTree();
4643 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
4644 if ( aResMgr && activeStudy() ) {
4645 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
4646 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
4651 void LightApp_Application::setDesktop( SUIT_Desktop* desk )
4653 CAM_Application::setDesktop( desk );
4656 connect( desk, SIGNAL( message( const QString& ) ),
4657 this, SLOT( onDesktopMessage( const QString& ) ), Qt::UniqueConnection );
4658 connect( desk, SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
4659 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
4660 /* connect( desk, SIGNAL( windowMoved( SUIT_ViewWindow* ) ),
4661 this, SLOT( onWindowMoved( SUIT_ViewWindow* ) ), Qt::UniqueConnection ); */
4667 \param mod - module to be activated
4669 bool LightApp_Application::activateModule( CAM_Module* mod )
4671 bool res = CAM_Application::activateModule( mod );
4673 if ( objectBrowser() )
4674 objectBrowser()->updateTree();
4680 \return keyborad accelerators manager object
4682 SUIT_Accel* LightApp_Application::accel() const
4688 Removes dead widget container from map
4690 void LightApp_Application::onWCDestroyed( QObject* ob )
4692 // remove destroyed widget container from windows map
4693 for ( WinMap::ConstIterator itr = myWin.begin(); itr != myWin.end(); ++itr )
4695 if ( itr.value() != ob )
4698 int key = itr.key();
4699 myWin.remove( key );
4704 void LightApp_Application::onMRUActivated( const QString& name )
4706 SUIT_Session* s = SUIT_Session::session();
4707 if ( s && s->activeApplication() == this )
4711 void LightApp_Application::onStylePreferences()
4713 #ifdef USE_SALOME_STYLE
4714 Style_PrefDlg dlg( desktop() );
4717 resourceMgr()->setValue( "Style", "use_salome_style", Style_Salome::isActive() );
4718 #endif // USE_SALOME_STYLE
4721 void LightApp_Application::onFullScreen(){
4722 if(myScreenHelper) {
4723 if(desktop()->isFullScreen())
4724 myScreenHelper->switchToNormalScreen();
4726 myScreenHelper->switchToFullScreen();
4731 Connects just added view manager
4733 void LightApp_Application::addViewManager( SUIT_ViewManager* vm )
4735 connect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
4736 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
4737 CAM_Application::addViewManager( vm );
4741 Remove view manager from memory
4743 void LightApp_Application::removeViewManager( SUIT_ViewManager* vm )
4745 disconnect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
4746 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
4747 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
4749 aStudy->removeObjectProperties( vm->getGlobalId() );
4751 CAM_Application::removeViewManager( vm );
4753 LightApp_SelectionMgr* selMgr = selectionMgr();
4754 QList<SUIT_Selector*> selectors;
4755 selMgr->selectors( selectors );
4756 foreach( SUIT_Selector* selector, selectors ) {
4757 if ( selector->owner() == vm->getViewModel() ) {
4762 // IPAL22894: Crash on closing OCC view
4768 Renames active window of desktop
4770 void LightApp_Application::onRenameWindow()
4775 QWidget* w = desktop()->activeWindow();
4780 QString name = QInputDialog::getText( w, tr( "TOT_RENAME" ), tr( "PRP_RENAME" ), QLineEdit::Normal, w->windowTitle(), &ok );
4781 if( ok && !name.isEmpty() )
4782 w->setWindowTitle( name );
4786 Closes active window of desktop
4788 void LightApp_Application::onCloseWindow()
4793 QWidget* w = desktop()->activeWindow();
4801 Closes all windows of desktop
4803 void LightApp_Application::onCloseAllWindow()
4805 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
4809 QList<SUIT_ViewWindow*> wndList = desk->windows();
4810 SUIT_ViewWindow* wnd;
4811 foreach( wnd, wndList )
4819 Groups all windows of desktop
4821 void LightApp_Application::onGroupAllWindow()
4823 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
4827 QtxWorkstack* wgStack = desk->workstack();
4833 \return default name for an active study
4835 void LightApp_Application::setDefaultStudyName( const QString& theName )
4837 QStringList anInfoList;
4838 modules( anInfoList, false );
4840 LightApp_Study* aStudy = (LightApp_Study*)activeStudy();
4841 if( anInfoList.count() == 1 && // to avoid a conflict between different modules
4842 !aStudy->isSaved() )
4844 aStudy->setStudyName( theName );
4845 updateDesktopTitle();
4850 Custom event handler
4852 bool LightApp_Application::event( QEvent* e )
4854 if( e && e->type()==2000 )
4856 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
4857 QString* d = ( QString* )ce->data();
4858 if( SUIT_MessageBox::question(0, tr("WRN_WARNING"),
4860 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
4861 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
4864 path << tr( "PREF_CATEGORY_SALOME" ) << tr( "PREF_TAB_GENERAL" )
4865 << tr( "PREF_GROUP_EXT_BROWSER" ) << tr( "PREF_APP" );
4866 showPreferences( path );
4872 return CAM_Application::event( e );
4875 /*! Check data object */
4876 bool LightApp_Application::checkDataObject(LightApp_DataObject* theObj)
4880 bool isSuitable = !theObj->entry().isEmpty() &&
4881 !theObj->componentDataType().isEmpty() &&
4882 !theObj->name().isEmpty();
4889 int LightApp_Application::openChoice( const QString& aName )
4891 int choice = CAM_Application::openChoice( aName );
4893 if ( choice == OpenExist ) // The document is already open.
4895 // Do you want to reload it?
4896 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "QUE_DOC_ALREADYOPEN" ).arg( aName ),
4897 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No ) == SUIT_MessageBox::Yes )
4898 choice = OpenReload;
4904 bool LightApp_Application::openAction( const int choice, const QString& aName )
4911 STD_Application* app = 0;
4912 SUIT_Session* session = SUIT_Session::session();
4913 QList<SUIT_Application*> appList = session->applications();
4914 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !app; ++it )
4916 if ( (*it)->activeStudy() && (*it)->activeStudy()->studyName() == aName )
4917 app = ::qobject_cast<STD_Application*>( *it );
4922 app->onCloseDoc( false );
4923 appList = session->applications();
4924 STD_Application* other = 0;
4925 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !other; ++it )
4926 other = ::qobject_cast<STD_Application*>( *it );
4929 res = other->onOpenDoc( aName );
4934 res = CAM_Application::openAction( choice, aName );
4941 QStringList LightApp_Application::viewManagersTypes() const
4943 QStringList aTypesList;
4944 aTypesList += myUserWmTypes;
4945 #ifndef DISABLE_GLVIEWER
4946 aTypesList<<GLViewer_Viewer::Type();
4948 #ifndef DISABLE_PLOT2DVIEWER
4949 aTypesList<<Plot2d_Viewer::Type();
4951 #ifndef DISABLE_QXGRAPHVIEWER
4952 aTypesList<<QxScene_Viewer::Type();
4954 #ifndef DISABLE_PVVIEWER
4955 aTypesList<<PVViewer_Viewer::Type();
4957 #ifndef DISABLE_PYVIEWER
4958 aTypesList<<PyViewer_Viewer::Type();
4960 #ifndef DISABLE_OCCVIEWER
4961 aTypesList<<OCCViewer_Viewer::Type();
4963 #ifndef DISABLE_VTKVIEWER
4964 #ifndef DISABLE_SALOMEOBJECT
4965 aTypesList<<SVTK_Viewer::Type();
4967 aTypesList<<VTKViewer_Viewer::Type();
4973 * Removes all view managers of known types
4974 * Other view managers are ignored
4976 void LightApp_Application::clearKnownViewManagers()
4978 QStringList aTypesList = viewManagersTypes();
4979 QList<SUIT_ViewManager*> aMgrList;
4980 viewManagers( aMgrList );
4981 foreach (SUIT_ViewManager* aMgr, aMgrList) {
4982 if (aTypesList.contains(aMgr->getType()))
4983 removeViewManager(aMgr);
4988 Copy of current selection
4990 void LightApp_Application::onCopy()
4992 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
4998 Paste of current data in clipboard
5000 void LightApp_Application::onPaste()
5002 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
5008 Browse (i.e. set focus on) the published objects
5009 \param theIsApplyAndClose - flag indicating that the dialog for creating objects
5010 has been accepted by Ok (or Apply & Close) button
5011 \param theIsOptimizedBrowsing - flag switching to optimized browsing mode
5012 (to select the first published object only)
5013 \return entry of the selected object
5015 QString LightApp_Application::browseObjects( const QStringList& theEntryList,
5016 const bool theIsApplyAndClose,
5017 const bool theIsOptimizedBrowsing )
5020 if( SUIT_ResourceMgr* aResourceMgr = resourceMgr() )
5022 int aBrowsePolicy = aResourceMgr->integerValue( "ObjectBrowser", "browse_published_object", (int)BP_Never );
5023 switch( aBrowsePolicy )
5027 case BP_ApplyAndClose:
5028 if( !theIsApplyAndClose )
5036 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
5040 SUIT_DataBrowser* anOB = objectBrowser();
5044 SUIT_AbstractModel* aModel = dynamic_cast<SUIT_AbstractModel*>( anOB->model() );
5048 QStringListIterator anIter( theEntryList );
5049 if( theIsOptimizedBrowsing )
5051 // go to the last entry
5053 if( anIter.hasPrevious() )
5057 // scroll to each entry in the list
5058 // (in optimized mode - to the last entry only)
5060 LightApp_DataObject* anObject = 0;
5061 while( anIter.hasNext() )
5063 anEntry = anIter.next();
5064 if( !anEntry.isEmpty() )
5066 anObject = aStudy->findObjectByEntry( anEntry );
5069 QModelIndex anIndex = aModel->index( anObject );
5070 anOB->treeView()->scrollTo( anIndex );
5075 // always select the last object
5076 if( anObject && !anEntry.isEmpty() )
5078 QList<SUIT_Selector*> aSelectorList;
5079 selectionMgr()->selectors( "ObjectBrowser", aSelectorList );
5080 if( !aSelectorList.isEmpty() )
5082 if( LightApp_OBSelector* aSelector = dynamic_cast<LightApp_OBSelector*>( aSelectorList.first() ) )
5084 bool anIsAutoBlock = aSelector->autoBlock();
5086 // temporarily disable auto block, to emit LightApp_SelectionMgr::currentSelectionChanged() signal
5087 aSelector->setAutoBlock( false );
5089 SUIT_DataOwnerPtrList aList;
5090 #ifndef DISABLE_SALOMEOBJECT
5091 Handle(SALOME_InteractiveObject) aSObj = new SALOME_InteractiveObject
5092 ( anObject->entry().toUtf8().constData(),
5093 anObject->componentDataType().toLatin1().constData(),
5094 anObject->name().toUtf8().constData() );
5095 LightApp_DataOwner* owner = new LightApp_DataOwner( aSObj );
5097 LightApp_DataOwner* owner = new LightApp_DataOwner( anEntry );
5100 aList.append( owner );
5101 selectionMgr()->setSelected( aList );
5104 // restore auto block flag
5105 aSelector->setAutoBlock( anIsAutoBlock );
5113 SUIT_DataObject* LightApp_Application::findObject( const QString& id ) const
5115 LightApp_Study* study = dynamic_cast<LightApp_Study*>( activeStudy() );
5116 return study ? study->findObjectByEntry( id ) : 0;
5120 Checks that an object can be renamed.
5121 \param entry entry of the object
5122 \brief Return \c true if object can be renamed
5124 bool LightApp_Application::renameAllowed( const QString& /*entry*/) const {
5129 Rename object by entry.
5130 \param entry entry of the object
5131 \param name new name of the object
5132 \brief Return \c true if rename operation finished successfully, \c false otherwise.
5134 bool LightApp_Application::renameObject( const QString& /*entry*/, const QString& /*name*/ ) {
5138 /*! Process standard messages from desktop */
5139 void LightApp_Application::onDesktopMessage( const QString& message )
5141 const QString sectionSeparator = "/";
5143 if ( message.toLower() == "updateobjectbrowser" ||
5144 message.toLower() == "updateobjbrowser" ) {
5145 // update object browser
5146 updateObjectBrowser();
5148 else if ( message.toLower().startsWith( "activate_viewer" ) ) {
5149 QString vtype = message.split( sectionSeparator ).last();
5150 if ( !vtype.isEmpty() )
5151 getViewManager( vtype, true );
5153 else if ( message.toLower().startsWith("register_module_in_study" ) ) {
5154 QString moduleName = message.split( sectionSeparator ).last();
5155 // Check name of current activating module name in order to avoid ciclik
5156 // call because of messages
5157 if (!property("activateModule").toBool()) {
5158 CAM_Module* mod = module(moduleName);
5160 mod = module(moduleTitle(moduleName));
5162 mod = loadModule(moduleName);
5164 mod = loadModule(moduleTitle(moduleName));
5170 CAM_Study* anActiveStudy = dynamic_cast<CAM_Study*>(activeStudy());
5171 if (anActiveStudy) {
5172 mod->connectToStudy(anActiveStudy);
5173 LightApp_DataModel* aDM = dynamic_cast<LightApp_DataModel*>(mod->dataModel());
5175 aDM->initRootObject();
5182 QStringList data = message.split( sectionSeparator );
5183 if ( data.count() > 1 ) {
5184 QString msgType = data[0].trimmed();
5185 LightApp_Module* sMod = 0;
5186 CAM_Module* mod = module( msgType );
5188 mod = module( moduleTitle( msgType ) );
5189 if ( mod && mod->inherits( "LightApp_Module" ) )
5190 sMod = (LightApp_Module*)mod;
5192 if ( msgType.toLower() == "preferences" ) {
5193 // requested preferences change: should be given as "preferences/<section>/<name>/<value>"
5194 // for example "preferences/Study/multi_file_dump/true"
5195 if ( data.count() > 3 ) {
5196 QString section = data[1].trimmed();
5197 QString param = data[2].trimmed();
5198 QString value = QStringList( data.mid(3) ).join( sectionSeparator );
5199 resourceMgr()->setValue( section, param, value );
5203 // received message for the module
5204 QString msg = QStringList( data.mid(1) ).join( sectionSeparator );
5205 sMod->message( msg );
5211 void LightApp_Application::onInfoPanelShown()
5213 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
5214 ((LightApp_Module*)activeModule())->updateInfoPanel();
5219 Returns all top level toolbars.
5220 Note : Result list contains only main window toolbars, not including toolbars from viewers.
5222 QList<QToolBar*> LightApp_Application::findToolBars( const QStringList& names )
5224 QList<QToolBar*> aResult;
5225 QList<QToolBar*> tbList = desktop()->findChildren<QToolBar*>();
5226 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit ) {
5227 QToolBar* tb = *tit;
5228 QObject* po = Qtx::findParent( tb, "QMainWindow" );
5229 if ( po != desktop() )
5231 if ( names.isEmpty() || names.contains( tb->objectName() ) )
5238 Internal method to parse toolbars and dockable windows state.
5240 QByteArray LightApp_Application::processState(QByteArray& input,
5241 const bool processWin,
5242 const bool processTb,
5243 const bool isRestoring,
5244 QByteArray defaultState) {
5247 bool hasDefaultState = !defaultState.isEmpty();
5248 bool isDockWinWriten = false;
5250 //Write date from users settings
5252 QDataStream tmpInputData(&input, QIODevice::ReadOnly);
5253 int marker, version;
5255 tmpInputData >> marker;
5256 tmpInputData >> version;
5257 tmpInputData >> dockmarker;
5258 tmpInputData >> nbDocWin;
5260 if(processWin && processTb && !isRestoring) {
5262 } else if(!processWin && !processTb ) {
5264 aRes = defaultState;
5266 QDataStream aData(&aRes, QIODevice::WriteOnly);
5267 QList<QToolBar*> aToolBars = findToolBars();
5270 for ( QList<QToolBar*>::iterator tit = aToolBars.begin(); tit != aToolBars.end(); ++tit ) {
5271 QToolBar* tb = *tit;
5272 aNames.append(tb->objectName());
5275 int toolBarMarkerIndex = getToolbarMarkerIndex(input,aNames);
5276 if(toolBarMarkerIndex < 0)
5278 QDataStream anInputData(&input, QIODevice::ReadOnly);
5280 int toolBarMarkerIndexDef = 0;
5281 if(hasDefaultState) {
5282 toolBarMarkerIndexDef = getToolbarMarkerIndex(defaultState, aNames);
5283 if(toolBarMarkerIndexDef < 0)
5286 QDataStream anInputDataDef(&defaultState, QIODevice::ReadOnly);
5288 QDataStream* aTargetData = 0;
5289 int aTargetIndex = -1;
5291 QByteArray currentArr = desktop()->saveState();
5292 QDataStream anInputDataCur(¤tArr, QIODevice::ReadOnly);
5293 bool useInputData = !isRestoring || (isRestoring && nbDocWin > 0);
5294 if(processWin && useInputData) {
5295 aTargetData = &anInputData;
5296 aTargetIndex = toolBarMarkerIndex;
5298 //Write date from default settings
5299 if(hasDefaultState) {
5300 aTargetData = &anInputDataDef;
5301 aTargetIndex = toolBarMarkerIndexDef;
5303 //If no default state, write current snapshot of the dockable windows
5305 aTargetData = &anInputDataCur;
5306 int toolBarMarkerIndexCur = getToolbarMarkerIndex(currentArr, aNames);
5307 aTargetIndex = toolBarMarkerIndexCur;
5312 if(aTargetData && aTargetIndex >= 0 ) {
5313 aTargetData->device()->seek(0);
5314 while( aTargetData->device()->pos() < aTargetIndex ) {
5319 isDockWinWriten = true;
5326 aTargetData = &anInputData;
5327 aTargetIndex = toolBarMarkerIndex;
5329 if(hasDefaultState) {
5330 aTargetData = &anInputDataDef;
5331 aTargetIndex = toolBarMarkerIndexDef;
5335 if(aTargetData && aTargetIndex >= 0) {
5337 if(!isDockWinWriten ) {
5338 //Write version marker
5339 int marker, version;
5340 aTargetData->device()->seek(0);
5341 *aTargetData >> marker;
5342 *aTargetData >> version;
5345 aData << (uchar) QDockWidgetMarker;
5347 int shift = 4*sizeof(int) + sizeof(QSize);
5348 index = aTargetIndex - shift;
5350 index = aTargetIndex;
5353 aTargetData->device()->seek(index);
5354 while(!aTargetData->atEnd()) {
5359 } else { // Not treat toolbars
5360 aData << (uchar) QToolBarMarker;
5361 aData << (int) 0; //Nb toolbars = 0
5368 \brief Emits operationFinished signal.
5369 \param theModuleName the name of the module which perfomed the operation
5370 \param theOperationName the operation name
5371 \param theEntryList the list of the created objects entries
5373 void LightApp_Application::emitOperationFinished( const QString& theModuleName,
5374 const QString& theOperationName,
5375 const QStringList& theEntryList )
5377 emit operationFinished( theModuleName, theOperationName, theEntryList );
5381 Update visibility state of given objects
5383 void LightApp_Application::updateVisibilityState( DataObjectList& theList,
5384 SUIT_ViewModel* theViewModel )
5386 if ( !theViewModel || theList.isEmpty() ) return;
5388 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
5389 if ( !aStudy ) return;
5391 SALOME_View* aView = dynamic_cast<SALOME_View*>( theViewModel );
5393 for ( DataObjectList::iterator itr = theList.begin(); itr != theList.end(); ++itr ) {
5394 LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>(*itr);
5396 if ( !obj || aStudy->isComponent( obj->entry() ) )
5399 QString mname = aStudy->componentDataType(obj->entry());
5400 LightApp_Displayer* aDisplayer = LightApp_Displayer::FindDisplayer(mname, false);
5402 Qtx::VisibilityState anObjState = Qtx::UnpresentableState;
5403 if ( aDisplayer->canBeDisplayed( obj->entry(), theViewModel->getType() ) ) {
5404 if ( aDisplayer->IsDisplayed( obj->entry(), aView ) )
5405 anObjState = Qtx::ShownState;
5407 anObjState = Qtx::HiddenState;
5409 aStudy->setVisibilityState( obj->entry(), anObjState );
5415 Update presentations of all displayed objects of theComponent in specified viewers
5417 void LightApp_Application::updatePresentations( const QString& theComponent,
5418 const QStringList& theViewManagerTypes )
5420 LightApp_Displayer* aDisplayer = LightApp_Displayer::FindDisplayer(theComponent, false);
5422 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
5423 DataObjectList aComps;
5424 bool isFound = false;
5425 aStudy->root()->children( aComps );
5426 DataObjectList::const_iterator aCompsIt = aComps.begin();
5427 for ( ; aCompsIt != aComps.end() && !isFound; aCompsIt++ ) {
5428 LightApp_DataObject* aComp = dynamic_cast<LightApp_DataObject*>( *aCompsIt );
5429 if ( aComp && aComp->componentDataType() == theComponent) {
5431 DataObjectList anObjs;
5432 aComp->children(anObjs, true);
5434 QList<SUIT_ViewManager*> aViewMgrs;
5435 QStringList::const_iterator itVMTypes = theViewManagerTypes.begin();
5436 for ( ; itVMTypes != theViewManagerTypes.end(); ++itVMTypes )
5437 viewManagers( *itVMTypes, aViewMgrs );
5439 DataObjectList::const_iterator itObjs = anObjs.begin();
5440 for ( ; itObjs != anObjs.end(); itObjs++ ) {
5441 LightApp_DataObject* anObj = dynamic_cast<LightApp_DataObject*>( *itObjs );
5442 QString anEntry = anObj->entry();
5444 QListIterator<SUIT_ViewManager*> itViewMgrs( aViewMgrs );
5445 while ( itViewMgrs.hasNext()) {
5446 SUIT_ViewModel* aVM = itViewMgrs.next()->getViewModel();
5448 SALOME_View* aView = dynamic_cast<SALOME_View*>(aVM);
5450 bool isDisp = aDisplayer->IsDisplayed( anEntry, aView );
5451 aDisplayer->Erase( anEntry, true, false, aView );
5453 aDisplayer->Display( anEntry, false, aView );
5465 * Called when window activated
5467 void LightApp_Application::onWindowActivated( SUIT_ViewWindow* theViewWindow )
5469 SUIT_DataBrowser* anOB = objectBrowser();
5472 SUIT_DataObject* rootObj = anOB->root();
5476 DataObjectList listObj = rootObj->children( true );
5478 SUIT_ViewModel* vmod = 0;
5479 if ( SUIT_ViewManager* vman = theViewWindow->getViewManager() )
5480 vmod = vman->getViewModel();
5481 updateVisibilityState( listObj, vmod );
5485 Called then view manager removed
5487 void LightApp_Application::onViewManagerRemoved( SUIT_ViewManager* )
5489 ViewManagerList lst;
5490 viewManagers( lst );
5491 if ( lst.count() == 1) { // in case if closed last view window
5492 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
5494 aStudy->setVisibilityStateForAll( Qtx::UnpresentableState );
5499 Check existing document.
5501 bool LightApp_Application::checkExistingDoc( bool closeExistingDoc )
5504 if( activeStudy() ) {
5505 int answer = !activeStudy()->isModified() ? 1 :
5506 SUIT_MessageBox::question( desktop(),
5507 tr( "APPCLOSE_CAPTION" ),
5508 tr( "STUDYCLOSE_DESCRIPTION" ),
5509 tr( "APPCLOSE_SAVE" ),
5510 tr( "APPCLOSE_CLOSE" ),
5511 tr( "APPCLOSE_CANCEL" ), 0 );
5513 if ( activeStudy()->isSaved() ) {
5515 if (closeExistingDoc) {
5518 } else if ( onSaveAsDoc() ) {
5519 if (closeExistingDoc) {
5520 if( !closeDoc( false ) ) {
5528 else if( answer == 1 ) {
5529 if (closeExistingDoc) {
5532 } else if( answer == 2 ) {
5539 #ifndef DISABLE_PYCONSOLE
5541 PyConsole_Interp* LightApp_Application::getPyInterp()
5543 static PyConsole_Interp* myInterp = 0;
5545 myInterp = createPyInterp();
5546 myInterp->initialize();
5551 PyConsole_Interp* LightApp_Application::createPyInterp()
5553 return new PyConsole_Interp();
5556 #endif // DISABLE_PYCONSOLE
5558 void LightApp_Application::createHelpItems( const QString& modTitle )
5560 if ( modTitle.isEmpty() )
5563 QString userGuide = "User's Guide";
5564 QString devGuide = "Developer's Guide";
5566 int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
5568 createMenu( userGuide, helpMenu, -1, 5 );
5569 createMenu( devGuide, helpMenu, -1, 5 );
5571 IMap <QString, QString> helpData; // list of help files for the module
5572 QString helpSubMenu; // help submenu name (empty if not needed)
5573 QString modName = moduleName( modTitle ); // module name
5574 if ( modName.isEmpty() ) modName = modTitle; // for KERNEL and GUI
5575 QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName ); // module root dir env variable
5576 QString modDir = Qtx::getenv( rootDir.toUtf8().constData() ); // module root dir path
5578 if ( resourceMgr()->hasValue( modName, "documentation" ) )
5579 docSection = resourceMgr()->stringValue( modName, "documentation" );
5580 else if ( resourceMgr()->hasSection( modName + "_documentation" ) )
5581 docSection = modName + "_documentation";
5582 if ( !docSection.isEmpty() )
5584 helpSubMenu = resourceMgr()->stringValue( docSection, "sub_menu", "" );
5585 if ( helpSubMenu.contains( "%1" ) )
5586 helpSubMenu = helpSubMenu.arg( modTitle );
5587 foreach( QString paramName, resourceMgr()->parameters( docSection ) )
5589 QString key = paramName.contains( "%1" ) ? paramName.arg( modTitle ) : paramName;
5590 QString helpItem = getHelpItem( docSection, paramName );
5591 if ( !helpItem.isEmpty() )
5592 helpData.insert( key, helpItem );
5596 if ( helpData.isEmpty() && !modDir.isEmpty() )
5598 QStringList idxLst = QStringList() << modDir << "share" << "doc" << "salome" << "gui" << modName << "index.html";
5599 QString indexFile = idxLst.join( QDir::separator() ); // index file
5600 if ( QFile::exists( indexFile ) )
5601 helpData.insert( tr( "%1 module Users's Guide" ).arg( modTitle ), indexFile );
5604 IMapConstIterator<QString, QString > fileIt;
5605 for ( fileIt = helpData.begin(); fileIt != helpData.end(); fileIt++ )
5607 QString helpItemPath = fileIt.key();
5608 // remove all '//' occurances
5609 while ( helpItemPath.contains( "//" ) )
5610 helpItemPath.replace( "//", "" );
5611 // obtain submenus hierarchy if given
5612 QStringList smenus = helpItemPath.split( "/" );
5613 helpItemPath = smenus.takeLast();
5614 // workaround for User's Guide and Developer's Guide to avoid having single item in module's submenu.
5615 if ( helpItemPath == userGuide || helpItemPath == devGuide )
5617 QString menuPath = smenus.join( "/" );
5618 QStringList allKeys = helpData.keys();
5619 QStringList total = allKeys.filter( QRegExp( QString( "^%1" ).arg( menuPath ) ) );
5620 if ( total.count() == 1 && smenus.count() > 0 )
5621 helpItemPath = smenus.takeLast();
5623 QPixmap helpIcon = fileIt.value().startsWith( "http", Qt::CaseInsensitive ) ?
5624 resourceMgr()->loadPixmap( "STD", tr( "ICON_WWW" ), false ) :
5625 resourceMgr()->loadPixmap( "STD", tr( "ICON_HELP" ), false );
5626 QAction* a = createAction( -1, helpItemPath, helpIcon, helpItemPath, helpItemPath,
5627 0, desktop(), false, this, SLOT( onHelpContentsModule() ) );
5628 a->setData( fileIt.value() );
5629 if ( !helpSubMenu.isEmpty() )
5630 smenus.prepend( helpSubMenu );
5631 // create sub-menus hierarchy
5632 int menuId = helpMenu;
5633 foreach ( QString subMenu, smenus )
5634 menuId = createMenu( subMenu, menuId, -1, 5 );
5635 createMenu( a, menuId, -1, ( menuId != helpMenu && ( helpItemPath == userGuide || helpItemPath == devGuide ) ) ? 0 : 5 );
5636 if ( !myHelpItems.contains( modName ) )
5637 myHelpItems[modName] = IdList();
5638 myHelpItems[modName].append( actionId( a ) );
5642 void LightApp_Application::removeHelpItems( const QString& modTitle )
5644 QString modName = moduleName( modTitle );
5645 if ( myHelpItems.contains( modName ) )
5647 foreach( int id, myHelpItems[modName] )
5648 setMenuShown( id, false );
5649 myHelpItems.remove( modName );