1 // Copyright (C) 2007-2023 CEA, EDF, 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
27 // E.A. : On windows with python 2.6, there is a conflict
28 // E.A. : between pymath.h and Standard_math.h which define
29 // E.A. : some same symbols : acosh, asinh, ...
30 #include <Standard_math.hxx>
31 #ifndef DISABLE_PYCONSOLE
36 #ifndef DISABLE_PYCONSOLE
37 #include "PyConsole_Interp.h"
38 #include "LightApp_PyEditor.h"
39 #include "PyConsole_Console.h"
42 #include "LightApp_Application.h"
43 #include "LightApp_Module.h"
44 #include "LightApp_DataModel.h"
45 #include "LightApp_DataOwner.h"
46 #include "LightApp_Displayer.h"
47 #include "LightApp_Study.h"
48 #include "LightApp_Preferences.h"
49 #include "LightApp_PreferencesDlg.h"
50 #include "LightApp_ModuleDlg.h"
51 #include "LightApp_AboutDlg.h"
52 #include "LightApp_ExtInfoDlg.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>
101 #include <SalomeApprc_utils.h>
103 #ifndef DISABLE_GLVIEWER
104 #include <GLViewer_Viewer.h>
105 #include <GLViewer_ViewManager.h>
106 #include "LightApp_GLSelector.h"
109 #ifndef DISABLE_PLOT2DVIEWER
110 #include <Plot2d_ViewManager.h>
111 #include <Plot2d_ViewModel.h>
112 #include <Plot2d_ViewWindow.h>
113 #include <Plot2d_ViewFrame.h>
114 #include "LightApp_Plot2dSelector.h"
115 #ifndef DISABLE_SALOMEOBJECT
116 #include <SPlot2d_ViewModel.h>
118 #include <Plot2d_ViewModel.h>
122 #ifndef DISABLE_OCCVIEWER
123 #include <OCCViewer_ViewManager.h>
124 #include <OCCViewer_ViewFrame.h>
125 #include <OCCViewer_ViewPort3d.h>
126 #ifndef DISABLE_SALOMEOBJECT
127 #include <SOCC_ViewModel.h>
129 #include <OCCViewer_ViewModel.h>
131 #include "LightApp_OCCSelector.h"
134 #ifndef DISABLE_VTKVIEWER
135 #ifndef DISABLE_SALOMEOBJECT
136 #include <SVTK_ViewModel.h>
137 #include <SVTK_ViewManager.h>
138 #include "LightApp_VTKSelector.h"
140 #include <VTKViewer_ViewModel.h>
141 #include <VTKViewer_ViewManager.h>
143 #include <VTKViewer_ViewModel.h>
146 #ifndef DISABLE_QXGRAPHVIEWER
147 #include <QxScene_ViewManager.h>
148 #include <QxScene_ViewModel.h>
149 #include <QxScene_ViewWindow.h>
152 #ifndef DISABLE_GRAPHICSVIEW
153 #include "GraphicsView_Viewer.h"
154 #include "GraphicsView_ViewManager.h"
155 #include "LightApp_GVSelector.h"
158 #ifndef DISABLE_PVVIEWER
159 #include "PVViewer_ViewManager.h"
160 #include "PVViewer_ViewWindow.h"
161 #include "PVViewer_ViewModel.h"
164 #ifndef DISABLE_PYVIEWER
165 #include <PyViewer_ViewManager.h>
166 #include <PyViewer_ViewModel.h>
167 #include <PyViewer_ViewWindow.h>
170 #ifndef DISABLE_PV3DVIEWER
171 #ifndef DISABLE_SALOMEOBJECT
172 #include <SPV3D_ViewModel.h>
173 #include <SPV3D_ViewManager.h>
174 #include "LightApp_PV3DSelector.h"
176 #include <PV3DViewer_ViewModel.h>
177 #include <PV3DViewer_ViewManager.h>
179 #include <PV3DViewer_ViewManager.h>
180 #include <PV3DViewer_ViewModel.h>
181 #include "PV3DViewer_ViewWindow.h"
185 #define VISIBILITY_COLUMN_WIDTH 25
191 #include <QStringList>
193 #include <QApplication>
195 #include <QStatusBar>
197 #include <QObjectList>
199 #include <QInputDialog>
200 #include <QFontDatabase>
202 #include <QByteArray>
206 #include <QHeaderView>
212 #include <utilities.h>
214 #define FIRST_HELP_ID 1000000
215 #define HAS_WWW_URL true
216 #define HAS_FORUM_URL true
217 #define HAS_YOUTUBE_URL true
218 #define HAS_TUTORIAL_URL false
220 #ifndef DISABLE_SALOMEOBJECT
221 #include <SALOME_InteractiveObject.hxx>
222 #include <SALOME_ListIO.hxx>
225 #include <Standard_Version.hxx>
227 #define ToolBarMarker 0
228 #define DockWidgetMarker 1
230 static const char* imageEmptyIcon[] = {
233 "....................",
234 "....................",
235 "....................",
236 "....................",
237 "....................",
238 "....................",
239 "....................",
240 "....................",
241 "....................",
242 "....................",
243 "....................",
244 "....................",
245 "....................",
246 "....................",
247 "....................",
248 "....................",
249 "....................",
250 "....................",
251 "....................",
252 "...................."};
254 // Markers used to parse array with dockable windows and toolbars state.
255 // For more details please see the qdockarealayout.cpp && qtoolbararealayout.cpp
256 // in the Qt source code.
258 #define QDockWidgetMarker 0xfd // = DockWidgetStateMarker
259 #define QToolBarMarker 0xfc // = ToolBarStateMarkerEx
261 // Format of the Byte array with the windows and toolbar state is:
262 // VersionMarker|version|DockWidgetStateMarker|nbDockWidgetLines|...DocWidgetData...|ToolBarStateMarkerEx|nbToolBarLines|...ToolBarData...
264 //Find toolbar marker position in the array in the following way:
265 //since the 'toolbar marker' is not unique, find index of first occurrence of the
266 //'toolbar marker' in the array and check that next string is name of the toolbar
270 const char* salomeAppDir = "SALOME_APPLICATION_DIR";
273 void LightAppCleanUpAppResources()
275 if ( LightApp_Application::_prefs_ ) {
276 delete LightApp_Application::_prefs_;
277 LightApp_Application::_prefs_ = 0;
283 int getToolbarMarkerIndex( QByteArray input, const QStringList& aFlags ) {
284 int aResult = -1,tmp = 0;
285 int inputLen = input.length();
286 QDataStream anInputData( &input, QIODevice::ReadOnly );
287 while ( tmp < inputLen ) {
288 tmp = input.indexOf( (uchar)QToolBarMarker, tmp + 1 );
291 anInputData.device()->seek( tmp );
295 anInputData >> lines;
297 if ( lines == 0 && anInputData.atEnd() ) {
298 //Case then array doesn't contain information about toolbars,
309 if ( aFlags.contains( str ) ) {
317 QString langToName( const QString& lang )
319 // special processing for English language to avoid such result as "American English"
320 // as Qt cannot just say "English"
325 result = QLocale( lang ).nativeLanguageName();
329 QString getHelpItem( const QString& section, const QString& parameter, const QString& root = QString() )
331 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
332 foreach( QString item, resMgr->stringValue( section, parameter ).split( ";;", QString::SkipEmptyParts ) )
334 if ( item.startsWith( "http", Qt::CaseInsensitive ) )
337 path.remove( QRegExp( "#.*$" ) );
338 QFileInfo fi( path );
339 if ( fi.isRelative() && !root.isEmpty() )
340 path = Qtx::addSlash( root ) + path;
341 if ( QFile::exists( path ) )
347 const bool HAS_SALOME_ON_DEMAND =
348 #if defined(WITH_SALOME_ON_DEMAND)
355 /*!Create new instance of LightApp_Application.*/
356 extern "C" LIGHTAPP_EXPORT SUIT_Application* createApplication()
358 return new LightApp_Application();
361 /*! \var global preferences of LightApp */
362 LightApp_Preferences* LightApp_Application::_prefs_ = 0;
366 \class LightApp_Application
367 Application containing LightApp module
371 LightApp_Application::LightApp_Application()
372 : CAM_Application( false ),
374 myScreenHelper(new LightApp_FullScreenHelper())
376 Q_INIT_RESOURCE( LightApp );
378 STD_TabDesktop* desk = new STD_TabDesktop();
379 desk->setFullScreenAllowed(false);
380 desk->setMinimizeAllowed(false);
384 // initialize auto save timer
385 myAutoSaveTimer = new QTimer( this );
386 myAutoSaveTimer->setSingleShot( true );
387 connect( myAutoSaveTimer, SIGNAL( timeout() ), this, SLOT( onSaveDoc() ) );
389 //connect( this, SIGNAL( moving() ), this, SLOT( onMoved() ) );
391 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
392 QPixmap aLogo = aResMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
394 desktop()->setWindowIcon( aLogo );
395 desktop()->setDockableMenuBar( false );
396 desktop()->setDockableStatusBar( false );
398 // base logo (salome itself)
399 desktop()->logoInsert( "_app_base", aResMgr->loadPixmap( "LightApp", tr( "APP_BASE_LOGO" ), false ) );
400 // extra logo (salome-based application)
401 desktop()->logoInsert( "_app_extra", aResMgr->loadPixmap( "LightApp", tr( "APP_EXTRA_LOGO" ), false ) );
405 mySelMgr = new LightApp_SelectionMgr( this );
407 myAccel = SUIT_Accel::getAccel();
409 #ifndef DISABLE_OCCVIEWER
410 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, OCCViewer_Viewer::Type() );
411 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, OCCViewer_Viewer::Type() );
412 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, OCCViewer_Viewer::Type() );
413 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, OCCViewer_Viewer::Type() );
414 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, OCCViewer_Viewer::Type() );
415 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, OCCViewer_Viewer::Type() );
416 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, OCCViewer_Viewer::Type() );
417 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, OCCViewer_Viewer::Type() );
418 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, OCCViewer_Viewer::Type() );
419 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, OCCViewer_Viewer::Type() );
420 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, OCCViewer_Viewer::Type() );
421 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, OCCViewer_Viewer::Type() );
423 #ifndef DISABLE_VTKVIEWER
424 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, VTKViewer_Viewer::Type() );
425 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, VTKViewer_Viewer::Type() );
426 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, VTKViewer_Viewer::Type() );
427 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, VTKViewer_Viewer::Type() );
428 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, VTKViewer_Viewer::Type() );
429 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, VTKViewer_Viewer::Type() );
430 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, VTKViewer_Viewer::Type() );
431 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, VTKViewer_Viewer::Type() );
432 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, VTKViewer_Viewer::Type() );
433 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, VTKViewer_Viewer::Type() );
434 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, VTKViewer_Viewer::Type() );
435 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, VTKViewer_Viewer::Type() );
437 #ifndef DISABLE_PLOT2DVIEWER
438 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, Plot2d_Viewer::Type() );
439 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, Plot2d_Viewer::Type() );
440 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, Plot2d_Viewer::Type() );
441 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, Plot2d_Viewer::Type() );
442 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, Plot2d_Viewer::Type() );
443 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, Plot2d_Viewer::Type() );
444 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, Plot2d_Viewer::Type() );
445 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, Plot2d_Viewer::Type() );
448 connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) );
449 connect( desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
450 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
451 connect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
452 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ), Qt::UniqueConnection );
455 // Set existing font for the python console in resources
456 if( !aResMgr->hasValue( "PyConsole", "font" ) )
459 QFont f = aResMgr->fontValue( "PyConsole", "font" );
461 QStringList famdb = fdb.families();
463 if ( famdb.contains(f.family()) || !aResMgr->hasValue( "PyConsole", "additional_families" ) )
466 QStringList anAddFamilies = aResMgr->stringValue( "PyConsole", "additional_families" ).split( ";", QString::SkipEmptyParts );
468 for ( QStringList::Iterator it = anAddFamilies.begin(); it != anAddFamilies.end(); ++it )
471 if ( famdb.contains(aFamily) )
473 f.setFamily( aFamily );
474 aResMgr->setValue( "PyConsole", "font", f );
481 *\li Save window geometry.
482 *\li Save desktop geometry.
483 *\li Save resource maneger.
484 *\li Delete selection manager.
486 LightApp_Application::~LightApp_Application()
490 delete myScreenHelper;
494 /*!Start application.*/
495 void LightApp_Application::start()
497 CAM_Application::start();
500 updateViewManagers();
501 updateCommandsStatus();
504 desktop()->statusBar()->showMessage( "" );
506 LightApp_EventFilter::Init();
511 /*!Closeapplication.*/
512 void LightApp_Application::closeApplication()
514 #ifndef DISABLE_QTXWEBBROWSER
515 QProcess::startDetached( "HelpBrowser",
516 QStringList() << QString( "--remove=%1" ).arg( QApplication::instance()->applicationPid() ) );
518 CAM_Application::closeApplication();
521 /*!Gets application name.*/
522 QString LightApp_Application::applicationName() const
524 static QString _app_name;
525 if ( _app_name.isEmpty() )
526 _app_name = tr( "APP_NAME" );
530 /*!Gets application version.*/
531 QString LightApp_Application::applicationVersion() const
533 static QString _app_version;
535 if ( _app_version.isEmpty() )
537 QString resVersion = tr( "APP_VERSION" );
538 if ( resVersion != "APP_VERSION" )
540 _app_version = resVersion;
544 _app_version = GUI_VERSION_STR;
550 /*!Load module by \a name.*/
551 CAM_Module* LightApp_Application::loadModule( const QString& name, const bool showMsg )
553 CAM_Module* mod = CAM_Application::loadModule( name, showMsg );
556 connect( this, SIGNAL( studyOpened() ), mod, SLOT( onModelOpened() ) );
557 connect( this, SIGNAL( studySaved() ), mod, SLOT( onModelSaved() ) );
558 connect( this, SIGNAL( studyClosed() ), mod, SLOT( onModelClosed() ) );
563 /*!Activate module by \a modName*/
564 bool LightApp_Application::activateModule( const QString& modName )
567 CAM_Module* prevMod = activeModule();
570 actName = prevMod->moduleName();
572 QString name = modName;
573 if ( !name.isEmpty() && !moduleTitle( modName ).isEmpty() )
574 name = moduleTitle( modName );
576 if ( actName == name )
579 putInfo( tr( "ACTIVATING_MODULE" ).arg( name ) );
581 saveDockWindowsState();
584 infoPanel()->clear();
586 bool status = CAM_Application::activateModule( name );
588 updateModuleActions();
596 updateViewManagers();
598 if ( activeStudy() && activeStudy()->root() && objectBrowser() ) {
599 if ( objectBrowser()->root() != activeStudy()->root() )
600 objectBrowser()->setRoot( activeStudy()->root() );
601 updateObjectBrowser( true );
604 if ( activeModule() ) activeModule()->updateModuleVisibilityState();
610 /*!Gets selection manager.*/
611 LightApp_SelectionMgr* LightApp_Application::selectionMgr() const
616 /*!Creat action "New window" for certain type of viewer:*/
617 void LightApp_Application::createActionForViewer( const int id,
619 const QString& suffix,
622 QString vtlt = tr( QString( "NEW_WINDOW_%1" ).arg( suffix ).toLatin1().constData() );
623 QString tip = tr( "CREATING_NEW_WINDOW" ).arg( vtlt.remove( "&" ) );
624 QAction* a = createAction( id, // menu action id
631 false, // toggle flag
633 SLOT( onNewWindow() ) ); // slot
634 createMenu( a, parentId, -1 );
639 void LightApp_Application::createActions()
641 CAM_Application::createActions();
643 SUIT_Desktop* desk = desktop();
644 SUIT_ResourceMgr* resMgr = resourceMgr();
647 createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIcon(),
648 tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
649 Qt::CTRL+Qt::Key_P, desk, false, this, SLOT( onPreferences() ) );
653 int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
657 // a) Link to web site
659 url = resMgr->stringValue("GUI", "site_url");
660 if ( !url.isEmpty() ) {
661 QString title = tr ( "SALOME_SITE" );
662 QAction* as = createAction( WebSiteId, title,
663 resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ),
665 0, desk, false, this, SLOT( onHelpContentsModule() ) );
667 createMenu( as, helpMenu, -1, 0 );
672 if ( HAS_FORUM_URL ) {
673 url = resMgr->stringValue("GUI", "forum_url");
674 if ( !url.isEmpty() ) {
675 QString title = tr ( "SALOME_FORUM" );
676 QAction* af = createAction( ForumId, title,
677 resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ),
679 0, desk, false, this, SLOT( onHelpContentsModule() ) );
681 createMenu( af, helpMenu, -1, 0 );
685 // c) Link to YouTube channel
686 if ( HAS_YOUTUBE_URL ) {
687 url = resMgr->stringValue("GUI", "channel_url");
688 if ( !url.isEmpty() ) {
689 createMenu( separator(), helpMenu, -1, 0 );
690 QString title = tr ( "SALOME_VIDEO_TUTORIALS" );
691 QAction* av = createAction( VideosId, title,
692 resMgr->loadPixmap( "LightApp", tr( "ICON_LIFE_RIGN" ), false ),
693 title, tr( "PRP_SALOME_VIDEO_TUTORIALS" ),
694 0, desk, false, this, SLOT( onHelpContentsModule() ) );
696 createMenu( av, helpMenu, -1, 0 );
700 // d) Link to Tutorials
701 if ( HAS_TUTORIAL_URL ) {
702 url = resMgr->stringValue("GUI", "tutorials_url");
703 if ( !url.isEmpty() ) {
704 QString title = tr ( "SALOME_TUTORIALS" );
705 QAction* as = createAction( TutorialsId, title,
706 resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ),
707 title, tr( "PRP_SALOME_TUTORIALS" ),
708 0, desk, false, this, SLOT( onHelpContentsModule() ) );
710 createMenu( as, helpMenu, -1, 0 );
714 // e) Help for modules
716 QStringList aModuleList;
717 modules( aModuleList, false );
718 aModuleList.prepend( "GUI" );
719 aModuleList.prepend( "KERNEL" );
721 foreach( QString aModule, aModuleList )
722 createHelpItems( aModule );
724 // f) Additional help items
726 int id = LightApp_Application::UserID + FIRST_HELP_ID + 1000;
727 createMenu( separator(), helpMenu, -1, 10 );
729 QStringList addHelpItems = resMgr->parameters( "add_help" );
730 foreach ( QString paramName, addHelpItems ) {
731 QString helpItem = getHelpItem( "add_help", paramName );
732 if ( !helpItem.isEmpty() )
734 QPixmap helpIcon = helpItem.startsWith( "http", Qt::CaseInsensitive ) ?
735 resMgr->loadPixmap( "STD", tr( "ICON_WWW" ), false ) : resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false );
736 QAction* a = createAction( id++, paramName, helpIcon, paramName, paramName,
737 0, desk, false, this, SLOT( onHelpContentsModule() ) );
738 a->setData( helpItem );
739 createMenu( a, helpMenu, -1, 10 );
744 static QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), 0 );
745 connect( mru, SIGNAL( activated( const QString& ) ), this, SLOT( onMRUActivated( const QString& ) ) );
746 registerAction( MRUId, mru );
749 LightApp_ModuleAction* moduleAction = new LightApp_ModuleAction( resMgr, desk );
750 registerAction( ModulesListId, moduleAction );
751 // a. here we add regular modules (specified to GUI via --modules cmd line option, or default list from configuration)
752 // b. custom modules are added in customize() method
754 modules( modList, false );
755 foreach ( QString aModule, modList )
756 moduleAction->insertModule( aModule, moduleIcon( aModule, 20 ) ); // scale icon to 20x20 pix
758 connect( this, SIGNAL( moduleActivated( QString ) ),
759 moduleAction, SLOT( setActiveModule( QString ) ) );
760 connect( moduleAction, SIGNAL( moduleActivated( const QString& ) ),
761 this, SLOT( onModuleActivation( const QString& ) ) );
762 connect( moduleAction, SIGNAL( adding() ),
763 this, SLOT( onExtAdding() ) );
764 connect( moduleAction, SIGNAL( removing( QString ) ),
765 this, SLOT( onExtRemoving( QString ) ) );
766 connect( moduleAction, SIGNAL(showExtInfo()),
767 this, SLOT(onShowExtInfo()));
769 addExtensionsActions(moduleAction);
772 int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, MenuWindowId, 100 );
773 int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
775 createAction( CloseId, tr( "TOT_CLOSE" ), QIcon(), tr( "MEN_DESK_CLOSE" ), tr( "PRP_CLOSE" ),
776 Qt::CTRL+Qt::Key_F4, desk, false, this, SLOT( onCloseWindow() ) );
777 createAction( CloseAllId, tr( "TOT_CLOSE_ALL" ), QIcon(), tr( "MEN_DESK_CLOSE_ALL" ), tr( "PRP_CLOSE_ALL" ),
778 0, desk, false, this, SLOT( onCloseAllWindow() ) );
779 createAction( GroupAllId, tr( "TOT_GROUP_ALL" ), QIcon(), tr( "MEN_DESK_GROUP_ALL" ), tr( "PRP_GROUP_ALL" ),
780 0, desk, false, this, SLOT( onGroupAllWindow() ) );
782 createMenu( CloseId, windowMenu, 0, -1 );
783 createMenu( CloseAllId, windowMenu, 0, -1 );
784 createMenu( GroupAllId, windowMenu, 0, -1 );
785 createMenu( separator(), windowMenu, -1, 0 );
787 #ifndef DISABLE_GLVIEWER
788 createActionForViewer( NewGLViewId, newWinMenu, QString::number( 0 ), Qt::ALT+Qt::Key_G );
790 #ifndef DISABLE_PLOT2DVIEWER
791 createActionForViewer( NewPlot2dId, newWinMenu, QString::number( 1 ), Qt::ALT+Qt::Key_P );
793 #ifndef DISABLE_OCCVIEWER
794 createActionForViewer( NewOCCViewId, newWinMenu, QString::number( 2 ), Qt::ALT+Qt::Key_O );
796 #ifndef DISABLE_VTKVIEWER
797 createActionForViewer( NewVTKViewId, newWinMenu, QString::number( 3 ), Qt::ALT+Qt::Key_K );
799 #ifndef DISABLE_QXGRAPHVIEWER
800 createActionForViewer( NewQxSceneViewId, newWinMenu, QString::number( 4 ), Qt::ALT+Qt::Key_S );
802 #ifndef DISABLE_GRAPHICSVIEW
803 createActionForViewer( NewGraphicsViewId, newWinMenu, QString::number( 5 ), Qt::ALT+Qt::Key_C );
805 #ifndef DISABLE_PVVIEWER
806 createActionForViewer( NewPVViewId, newWinMenu, QString::number( 6 ), Qt::ALT+Qt::Key_A );
808 #ifndef DISABLE_PYVIEWER
809 createActionForViewer( NewPyViewerId, newWinMenu, QString::number( 7 ), Qt::ALT+Qt::Key_Y );
811 #ifndef DISABLE_PV3DVIEWER
812 createActionForViewer( NewPV3DViewId, newWinMenu, QString::number( 8 ), Qt::ALT+Qt::Key_3 );
815 createAction( RenameId, tr( "TOT_RENAME" ), QIcon(), tr( "MEN_DESK_RENAME" ), tr( "PRP_RENAME" ),
816 Qt::ALT+Qt::SHIFT+Qt::Key_R, desk, false, this, SLOT( onRenameWindow() ) );
817 createMenu( RenameId, windowMenu, -1 );
819 int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
820 createMenu( PreferencesId, fileMenu, 50, -1 );
821 createMenu( separator(), fileMenu, -1, 50, -1 );
823 createMenu( separator(), fileMenu, -1, 100, -1 );
824 createMenu( MRUId, fileMenu, 100, -1 );
825 createMenu( separator(), fileMenu, -1, 100, -1 );
827 #ifdef USE_SALOME_STYLE
828 createAction( StyleId, tr( "TOT_THEME" ), QIcon(), tr( "MEN_DESK_THEME" ), tr( "PRP_THEME" ),
829 0, desk, false, this, SLOT( onStylePreferences() ) );
830 #endif // USE_SALOME_STYLE
832 createAction( FullScreenId, tr( "TOT_FULLSCREEN" ), QIcon(), tr( "MEN_DESK_FULLSCREEN" ), tr( "PRP_FULLSCREEN" ),
833 Qt::Key_F11, desk, false, this, SLOT( onFullScreen() ) );
836 int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1 );
837 createMenu( separator(), viewMenu, -1, 20, -1 );
838 #ifdef USE_SALOME_STYLE
839 createMenu( StyleId, viewMenu, 20, -1 );
840 #endif // USE_SALOME_STYLE
841 createMenu( FullScreenId, viewMenu, 20, -1 );
842 createMenu( separator(), viewMenu, -1, 20, -1 );
843 createMenu( ModulesListId, viewMenu );
845 int modTBar = createTool( tr( "INF_TOOLBAR_MODULES" ), // title (language-dependant)
846 QString( "SalomeModules" ) ); // name (language-independant)
847 createTool( ModulesListId, modTBar );
850 /*!Create actions for installed extensions:*/
851 void LightApp_Application::addExtensionsActions(LightApp_ModuleAction* moduleAction)
855 MESSAGE("Couldn't get a moduleAction! Return.");
859 // It should be set on the app start if we use an --on_demand 1 command line option
860 auto extRootDir = getenv(salomeAppDir);
863 // It's ok if we don't use --on_demand
868 // Import Python module that manages SALOME extensions.
869 PyLockWrapper lck; // acquire GIL
870 PyObjWrapper extensionQuery = PyImport_ImportModule((char*)"SalomeOnDemandTK.extension_query");
871 PyObjWrapper installedExtensions = PyObject_CallMethod(
872 extensionQuery, (char*)"ext_by_name", (char*)"s", extRootDir);
873 if (!installedExtensions)
878 // Iterate installed extensions
879 for (Py_ssize_t pos = 0; pos < PyList_Size(installedExtensions); ++pos)
881 // Get the current ext name
882 auto extNameItem = PyList_GetItem(installedExtensions, pos);
883 QString extName(PyUnicode_AsUTF8(extNameItem));
884 SCRUTE(extName.toStdString());
886 moduleAction->insertExtension(extName);
889 // Udate actions only once after all of them were already inserted
890 moduleAction->updateExtActions();
896 void LightApp_Application::customize()
899 LightApp_ModuleAction* moduleAction = qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
900 // a. regular modules were added in createActions() method
901 // b. here we add custom modules (manually added by the user)
902 if ( HAS_SALOME_ON_DEMAND && QString::compare(getenv("SALOME_ON_DEMAND"),"HIDE", Qt::CaseInsensitive) != 0)
907 QStringList modList = resourceMgr()->stringValue( "launch", "user_modules" ).split( ";", QString::SkipEmptyParts );
908 foreach ( QString aModule, modList )
909 addUserModule( aModule, resourceMgr()->stringValue( "user_modules", aModule ), true );
913 moduleAction->setModeEnabled( LightApp_ModuleAction::AddRemove, false );
918 Update rc file with SALOME_APPLICATION_DIR or with SALOME_MODULES.
920 void LightApp_Application::updateSalomeApprc()
922 SUIT_ResourceMgr* resMgr = resourceMgr();
923 auto extRootDir = getenv(salomeAppDir);
925 QString salomemodules(getenv("SALOME_MODULES"));
926 if(salomemodules.isEmpty())
927 UpdateCompInfo_with_salomeappdir( QDir(extRootDir), resMgr );
929 UpdateCompInfo_with_salomemodules(salomemodules, QDir(extRootDir), resMgr);
932 /*!On module activation action.*/
933 void LightApp_Application::onModuleActivation( const QString& modTitle )
935 // Force user to create/open a study before module activation
936 QPixmap icon = moduleIcon( modTitle );
937 bool cancelled = false;
939 while ( !modTitle.isEmpty() && !activeStudy() && !cancelled ){
940 LightApp_ModuleDlg aDlg( desktop(), modTitle, icon );
941 QMap<int, QString> opmap = activateModuleActions();
942 for ( QMap<int, QString>::ConstIterator it = opmap.begin(); it != opmap.end(); ++it )
943 aDlg.addButton( it.value(), it.key() );
945 int res = aDlg.exec();
947 // some operation is selected
948 moduleActionSelected( res );
952 putInfo( tr("INF_CANCELLED") );
953 emit moduleActivated( QString() );
959 activateModule( modTitle );
962 /*!On extension adding action.*/
963 void LightApp_Application::onExtAdding()
965 // Show dialog to browse a salome extension file
966 QStringList filters = (QStringList() << tr("Salome extension files") + " (*.salomex)" << tr("All files") + " (*)");
967 QStringList paths = getOpenFileNames(QString(), filters.join(";;"), QString(), desktop());
970 MESSAGE("Adding an extension was cancelled.");
974 LightApp_ModuleAction* moduleAction = qobject_cast<LightApp_ModuleAction*>(action(ModulesListId));
977 MESSAGE("Couldn't get a moduleAction! Return.");
981 // It should be set on the app start
982 auto extRootDir = getenv(salomeAppDir);
985 SUIT_MessageBox::warning(desktop(), tr("WRN_WARNING"), tr("WRN_SALOME_APPLICATION_DIR"));
990 // We'll load all the extensions modules from this path
991 auto SalomeExtDir = QDir::cleanPath(QString(extRootDir) + QDir::separator() + "__SALOME_EXT__");
992 SCRUTE(SalomeExtDir.toStdString());
994 // Import Python module that manages SALOME extensions.
995 // It seems to be faster to lock and unlock once than on each iteration,
996 // but I didn't compare the performance for each case.
997 PyLockWrapper lck; // acquire GIL
998 PyObjWrapper extensionUnpacker = PyImport_ImportModule((char*)"SalomeOnDemandTK.extension_unpacker");
999 PyObjWrapper runSalomeOnDemand = PyImport_ImportModule((char*)"runSalomeOnDemand");
1001 // Loop via selected extensions files
1002 foreach(QString path, paths)
1004 std::string extPath = path.toStdString();
1007 PyObjWrapper unpackedModules = PyObject_CallMethod(
1008 extensionUnpacker, (char*)"install_salomex", (char*)"s", extPath.c_str());
1009 if (!unpackedModules || unpackedModules == Py_None)
1011 SUIT_MessageBox::warning(desktop(), tr("WRN_WARNING"), tr("WRN_FAILED_UNPACK_EXTENSION").arg(path) );
1015 PyObjWrapper pKeys = PyDict_Keys(unpackedModules);
1016 // Iterate all the components (modules) for this extension
1017 for (Py_ssize_t pos = 0; pos < PyDict_Size(unpackedModules); ++pos)
1019 auto moduleNameItem = PyList_GetItem(pKeys, pos);
1020 auto interactiveItem = PyDict_GetItem(unpackedModules, moduleNameItem);
1022 QString moduleName(PyUnicode_AsUTF8(moduleNameItem));
1023 SCRUTE(moduleName.toStdString());
1024 addUserModule(moduleName, SalomeExtDir, PyObject_IsTrue(interactiveItem));
1027 // Add an extension to GUI
1028 QFileInfo extFileInfo(path);
1029 QString extName = extFileInfo.baseName();
1032 moduleAction->insertExtension(extName);
1035 // Update environment of salome
1036 PyObjWrapper update_env = PyObject_CallMethod(
1037 runSalomeOnDemand, (char*)"set_selext_env", (char*)"ss", extRootDir, extName.toStdString().c_str());
1040 SUIT_MessageBox::warning(desktop(), tr("WRN_WARNING"), tr("WRN_FAILED_UPDATE_ENV").arg(extName + "_env.py") );
1045 // Udate actions only once after all of them were already inserted
1046 moduleAction->updateExtActions();
1049 /*Add user module.*/
1050 bool LightApp_Application::addUserModule( const QString& name, const QString& root, bool interactive )
1052 if ( name == "KERNEL" || name == "GUI" )
1053 return false; // skip KERNEL and GUI modules
1055 if ( name.isEmpty() || root.isEmpty() )
1058 if ( !moduleTitle( name ).isEmpty() ) // module alread in current session
1061 SUIT_MessageBox::warning( desktop(), tr( "WRN_WARNING" ), tr( "WRN_MODULE_DUPLICATED" ).arg( name ) );
1064 if ( !QFileInfo( root ).exists() ) // root directory does not exist
1067 SUIT_MessageBox::warning( desktop(), tr( "WRN_WARNING" ), tr( "WRN_MODULE_ROOT_DOES_NOT_EXIST" ).arg( root ) );
1070 // resources directory
1071 QString resDir = Qtx::joinPath( QStringList() << root << "share" << "salome" << "resources" << name.toLower() );
1072 if ( !QFileInfo( resDir ).exists() ) // resources directory does not exist
1075 SUIT_MessageBox::warning( desktop(), tr( "WRN_WARNING" ), tr( "WRN_MODULE_BAD_RESDIR" ).arg( resDir ) );
1079 SUIT_ResourceMgr* resMgr = resourceMgr();
1081 // read XML configuration file
1082 resMgr->setConstant(QString("%1_ROOT_DIR").arg(name), root);
1083 if (!resMgr->addResource(resDir)) // cannot read configuration
1086 SUIT_MessageBox::warning( desktop(), tr( "WRN_WARNING" ), tr( "WRN_MODULE_CANNOT_READ_CFG" ).arg( resDir ) );
1089 // fill in information about module
1090 if ( !appendModuleInfo( name ) ) // cannot append module information to internal table
1093 SUIT_MessageBox::warning( desktop(), tr( "WRN_WARNING" ), tr( "WRN_MODULE_BAD_CFG_FILE" ).arg( name ) );
1097 // load translations
1098 resMgr->loadLanguage(name);
1100 // Do all the GUI related stuff only if the module supports that.
1101 // We already did check for GUI inside CAM_Application::appendModuleInfo, but
1102 // need to do that again.
1103 // TODO: Maybe it's better to return ModuleInfo from appendModuleInfo() and check status.
1104 const QString title = resMgr->stringValue(name, "name", QString()).trimmed();
1105 if (resMgr->booleanValue(name, "gui", false) || !title.isEmpty() && interactive)
1107 // Append module to the menu / toolbar
1108 LightApp_ModuleAction* moduleAction = qobject_cast<LightApp_ModuleAction*>(action(ModulesListId));
1111 // Scale icon to 20x20 pix
1112 moduleAction->insertModule(moduleTitle(name), moduleIcon(moduleTitle(name), 20), true);
1116 // add empty page to Preferences dialog
1117 LightApp_Preferences* prefs = preferences();
1118 if ( prefs && !prefs->hasModule( moduleTitle( name ) ) )
1120 int prefId = prefs->addPreference( moduleTitle( name ) );
1121 prefs->setItemIcon( prefId, moduleIcon( moduleTitle( name ), 20 ) ); // scale icon to 20x20 pix
1122 LightApp_Module* m = qobject_cast<LightApp_Module*>( module( moduleTitle( name ) ) );
1125 m->createPreferences();
1126 emptyPreferences( moduleTitle( name ) );
1130 createHelpItems( moduleTitle( name ) );
1131 // extend module catalog
1132 QString catalogue = QDir( resDir ).filePath( QString( "%1Catalog.xml" ).arg( name ) );
1133 addCatalogue( name, catalogue );
1134 // update windows (in particular, Info panel)
1136 // save module in the resource manager
1139 QStringList customModules = resMgr->stringValue("launch", "user_modules").split(";", QString::SkipEmptyParts);
1140 customModules << name;
1141 customModules.removeDuplicates();
1142 resMgr->setValue( "launch", "user_modules", customModules.join( ";" ) );
1143 resMgr->setValue( "user_modules", name, root );
1148 /*!Remove user module from UI.*/
1149 void LightApp_Application::removeUserModule(const QString& moduleInnerName, LightApp_ModuleAction* moduleAction)
1151 MESSAGE("Remove a module from UI...");
1152 SCRUTE(moduleInnerName.toStdString());
1154 // There is a some confusion point, because now we have a module's 'inner' name
1155 // from the extension's salomexd file.
1156 // But, in the next GUI methods we need to use a module title (user name).
1157 // For example, PYHELLO (inner name) and PyHello (user name to display in GUI).
1158 // Then, from the inner module's name we need to get a user one.
1159 QString moduleUserName = moduleTitle(moduleInnerName);
1160 SCRUTE(moduleUserName.toStdString());
1162 // Set current state in modules combo box
1163 // Don't confuse again, because activeModule()->moduleName() returns a module title, not an inner one!
1164 if (activeModule() && activeModule()->moduleName() == moduleUserName)
1167 // Remove from "Modules" menu and toolbar
1170 moduleAction->removeModule(moduleUserName);
1173 // Remove Help menu items
1174 removeHelpItems(moduleUserName);
1176 // Remove Preferences
1177 LightApp_Preferences* prefs = preferences();
1179 prefs->removeModule(moduleUserName);
1182 // Here we use an inner module name!
1183 QStringList customModules = resourceMgr()->stringValue("launch", "user_modules").split(";", QString::SkipEmptyParts);
1184 customModules.removeAll(moduleInnerName);
1185 resourceMgr()->setValue("launch", "user_modules", customModules.join(";"));
1186 removeModuleInfo(moduleInnerName);
1189 /*!On module removing action.*/
1190 void LightApp_Application::onExtRemoving(const QString& title)
1192 MESSAGE("Remove an extension...");
1193 std::string extName = title.toStdString();
1196 // Ask user if he's ready to completely remove an extension and all its modules.
1197 int answer = SUIT_MessageBox::question(
1199 tr("TLT_REMOVE_EXTENSION"),
1200 tr("QUE_REMOVE_EXTENSION").arg(title),
1201 SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel,
1205 if (answer == SUIT_MessageBox::Cancel)
1207 MESSAGE("Removing of an extension was cancelled");
1208 return; // cancelled
1211 if (activeStudy() && activeStudy()->isModified() && !onSaveDoc())
1213 // doc is not saved, or saving cancelled
1214 SUIT_MessageBox::warning(
1216 tr("WRN_WARNING"), tr("WRN_CANCEL_REMOVE_EXTENSION_UNSAVE").arg(title)
1222 // It should be set on the app start
1223 auto extRootDir = getenv(salomeAppDir);
1226 SUIT_MessageBox::warning(desktop(), tr("WRN_WARNING"), tr("WRN_SALOME_APPLICATION_DIR"));
1231 // Import Python module that manages SALOME extensions.
1232 PyLockWrapper lck; // acquire GIL
1233 PyObjWrapper extensionRemover = PyImport_ImportModule((char*)"SalomeOnDemandTK.extension_remover");
1234 PyObjWrapper removedModules = PyObject_CallMethod(
1235 extensionRemover, (char*)"remove_salomex", (char*)"ss", extRootDir, extName.c_str());
1236 if (!removedModules || removedModules == Py_None)
1238 SUIT_MessageBox::warning(desktop(), tr("WRN_WARNING"), tr("WRN_FAILED_REMOVE_EXTENSION").arg(title));
1242 // We need it to remove ext and modules from UI
1243 LightApp_ModuleAction* moduleAction = qobject_cast<LightApp_ModuleAction*>(action(ModulesListId));
1246 MESSAGE("Cannot get a pointer to LightApp_ModuleAction! Removing from menue and toolbars will skipped.");
1249 // Module's content was already removed on python remove_salomex call,
1250 // then all we do next - just remove UI items.
1251 for (Py_ssize_t pos = 0; pos < PyList_Size(removedModules); ++pos)
1253 // Get the current module's name
1254 auto moduleNameItem = PyList_GetItem(removedModules, pos);
1255 const QString moduleInnerName(PyUnicode_AsUTF8(moduleNameItem));
1257 removeUserModule(moduleInnerName, moduleAction);
1260 // Remove an ext from UI
1263 moduleAction->removeExtension(title);
1266 // Update windows (in particular, Info panel)
1270 /*!On show extension info action.*/
1271 void LightApp_Application::onShowExtInfo()
1273 // Show dialog with information about loaded salome extensions
1274 LightApp_ExtInfoDlg dlg(desktop());
1278 /*!Default module activation.*/
1279 QString LightApp_Application::defaultModule() const
1281 QStringList aModuleNames;
1282 modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration
1283 //! If there's the one and only module --> activate it automatically
1284 //! TODO: Possible improvement - default module can be taken from preferences
1285 return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" );
1288 /*!On new window slot.*/
1289 void LightApp_Application::onNewWindow()
1291 const QObject* obj = sender();
1292 if ( !obj || !obj->inherits( "QAction" ) )
1296 int id = actionId( (QAction*)obj );
1299 #ifndef DISABLE_GLVIEWER
1301 type = GLViewer_Viewer::Type();
1304 #ifndef DISABLE_PLOT2DVIEWER
1306 type = Plot2d_Viewer::Type();
1309 #ifndef DISABLE_OCCVIEWER
1311 type = OCCViewer_Viewer::Type();
1314 #ifndef DISABLE_VTKVIEWER
1316 type = VTKViewer_Viewer::Type();
1319 #ifndef DISABLE_QXGRAPHVIEWER
1320 case NewQxSceneViewId:
1321 type = QxScene_Viewer::Type();
1324 #ifndef DISABLE_GRAPHICSVIEW
1325 case NewGraphicsViewId:
1326 type = GraphicsView_Viewer::Type();
1329 #ifndef DISABLE_PVVIEWER
1331 type = PVViewer_Viewer::Type();
1334 #ifndef DISABLE_PYVIEWER
1336 type = PyViewer_Viewer::Type();
1339 #ifndef DISABLE_PV3DVIEWER
1341 type = PV3DViewer_ViewModel::Type();
1346 if ( !type.isEmpty() )
1347 createViewManager( type );
1351 SLOT: Creates new document
1353 void LightApp_Application::onNewDoc()
1355 if ( !checkExistingDoc() )
1358 //asl: fix for 0020515
1359 saveDockWindowsState();
1361 CAM_Application::onNewDoc();
1365 SLOT: Opens new document
1367 void LightApp_Application::onOpenDoc()
1369 SUIT_Study* study = activeStudy();
1371 if ( !checkExistingDoc( false ) )
1374 QString aName = getFileName( true, QString(), getFileFilter( true ), QString(), 0 );
1375 if ( aName.isNull() ) //Cancel
1380 if ( !study ) // new study will be create in THIS application
1383 updateViewManagers();
1387 bool LightApp_Application::canOpenDoc( const QString& )
1393 SLOT: Opens new document.
1394 \param aName - name of file
1396 bool LightApp_Application::onOpenDoc( const QString& aName )
1398 if ( !canOpenDoc(aName)) {
1399 bool showError = !property("open_study_from_command_line").isValid() ||
1400 !property("open_study_from_command_line").toBool();
1402 putInfo( tr("OPEN_DOCUMENT_PROBLEM") );
1404 SUIT_MessageBox::critical( desktop(), tr("ERR_ERROR"), tr("OPEN_DOCUMENT_PROBLEM"));
1411 if ( !checkExistingDoc() )
1414 saveDockWindowsState();
1416 // We should take mru action first because this application instance can be deleted later.
1417 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
1419 bool res = CAM_Application::onOpenDoc( aName );
1424 mru->insert( aName );
1426 mru->remove( aName );
1432 SLOT: Displays "About" message box
1434 void LightApp_Application::onHelpAbout()
1436 LightApp_AboutDlg dlg( applicationName(), applicationVersion(), desktop() );
1441 Private SLOT: Called on selection is changed
1442 Dispatchs active module that selection is changed
1444 void LightApp_Application::onSelection()
1446 //MESSAGE("onSelection")
1447 onSelectionChanged();
1449 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
1450 ((LightApp_Module*)activeModule())->selectionChanged();
1455 \param study - SUIT_Study.
1457 void LightApp_Application::setActiveStudy( SUIT_Study* study )
1459 CAM_Application::setActiveStudy( study );
1463 Enables/Disables menu items and toolbar buttons. Rebuild menu
1465 void LightApp_Application::updateCommandsStatus()
1467 CAM_Application::updateCommandsStatus();
1470 #ifndef DISABLE_GLVIEWER
1471 a = action( NewGLViewId );
1473 a->setEnabled( activeStudy() );
1476 #ifndef DISABLE_PLOT2DVIEWER
1477 a = action( NewPlot2dId );
1479 a->setEnabled( activeStudy() );
1482 #ifndef DISABLE_OCCVIEWER
1483 a = action( NewOCCViewId );
1485 a->setEnabled( activeStudy() );
1488 #ifndef DISABLE_VTKVIEWER
1489 a = action( NewVTKViewId );
1491 a->setEnabled( activeStudy() );
1494 #ifndef DISABLE_QXGRAPHVIEWER
1495 a = action( NewQxSceneViewId );
1497 a->setEnabled( activeStudy() );
1500 #ifndef DISABLE_GRAPHICSVIEW
1501 a = action( NewGraphicsViewId );
1503 a->setEnabled( activeStudy() );
1506 #ifndef DISABLE_PVVIEWER
1507 a = action( NewPVViewId );
1509 a->setEnabled( activeStudy() );
1512 #ifndef DISABLE_PYVIEWER
1513 a = action( NewPyViewerId );
1515 a->setEnabled( activeStudy() );
1518 #ifndef DISABLE_PV3DVIEWER
1519 a = action( NewPV3DViewId );
1521 a->setEnabled( activeStudy() );
1527 Runs system command in separate thread
1529 class RunBrowser: public QThread
1532 static void execute( LightApp_Application* application,
1533 const QString& browser,
1534 const QString& parameters,
1535 const QString& url )
1537 (new RunBrowser( application, browser, parameters, url ))->start();
1541 RunBrowser( LightApp_Application* application,
1542 const QString& browser,
1543 const QString& parameters,
1545 : myApplication( application ),
1546 myBrowser( browser ),
1547 myParameters( parameters ),
1550 if ( !myUrl.startsWith( "http", Qt::CaseInsensitive ) )
1553 if ( myUrl.startsWith( "file://", Qt::CaseInsensitive ) )
1554 myUrl = myUrl.remove( 0, QString( "file://" ).count() );
1555 // For the external browser we always specify 'file://' protocol,
1556 // because some web browsers (e.g. Mozilla Firefox) can't open local file without protocol.
1557 myUrl = myUrl.prepend( "file://" );
1559 connect(this, SIGNAL(finished()), SLOT(deleteLater()));
1564 if ( !myBrowser.isEmpty() && !myUrl.isEmpty() )
1566 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
1568 QString cmdLine = QString( "\"%1\" %2 \"%3\"" ).arg( myBrowser, myParameters, myUrl );
1570 QString cmdLine = QString( "%1 %2 \"%3\"" ).arg( myBrowser, myParameters, myUrl );
1571 // remove LD_LIBRARY_PATH from the environement before starting launcher to avoid bad interactions.
1572 // (especially in the case of universal binaries)
1573 env.remove("LD_LIBRARY_PATH");
1575 QProcess* proc = new QProcess();
1576 proc->setProcessEnvironment(env);
1577 proc->start( cmdLine );
1578 if ( !proc->waitForStarted() )
1580 SALOME_CustomEvent* ce2000 = new SALOME_CustomEvent( 2000 );
1581 QString* msg = new QString( QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).arg( myBrowser, myUrl ) );
1582 ce2000->setData( msg );
1583 QApplication::postEvent( myApplication, ce2000 );
1589 LightApp_Application* myApplication;
1591 QString myParameters;
1595 void LightApp_Application::showHelp( const QString& path )
1597 SUIT_ResourceMgr* resMgr = resourceMgr();
1599 #if DISABLE_QTXWEBBROWSER
1600 bool useExternalBrowser = true;
1602 bool useExternalBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1605 if ( useExternalBrowser )
1608 QString browser = resMgr->stringValue( "ExternalBrowser", "winapplication" ) ;
1610 QString browser = resMgr->stringValue( "ExternalBrowser", "application" );
1612 QString parameters = resMgr->stringValue("ExternalBrowser", "parameters");
1614 if ( !browser.isEmpty() )
1616 RunBrowser::execute( this, browser, parameters, path );
1620 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1621 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1622 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1625 path << tr( "PREF_CATEGORY_SALOME" ) << tr( "PREF_TAB_GENERAL" )
1626 << tr( "PREF_GROUP_EXT_BROWSER" ) << tr( "PREF_APP" );
1627 showPreferences( path );
1633 QStringList cmdLine;
1634 cmdLine << QString( "--language=%1" ).arg( resMgr->stringValue( "language", "language" ) );
1635 cmdLine << QString( "--add=%1" ).arg( QApplication::instance()->applicationPid() );
1637 QProcess::startDetached( "HelpBrowser", cmdLine );
1642 SLOT: Displays help contents for choosen module
1644 void LightApp_Application::onHelpContentsModule()
1646 const QAction* a = (QAction*) sender();
1647 QString helpFile = a->data().toString();
1648 if ( !helpFile.isEmpty() )
1649 showHelp( helpFile );
1653 SLOT: Displays contextual help (e.g. for choosen dialog)
1655 void LightApp_Application::onHelpContextModule( const QString& component,
1657 const QString& context )
1660 if ( !url.startsWith( "http", Qt::CaseInsensitive ) )
1663 QFileInfo fi( url );
1664 if ( fi.isRelative() && !component.isEmpty() )
1666 QString rootDir = Qtx::getenv( (component + "_ROOT_DIR").toLatin1().constData() );
1667 if ( !rootDir.isEmpty() )
1669 path = (QStringList() << rootDir << "share" << "doc" << "salome" << "gui" << component << url).join( QDir::separator() );
1673 if ( !context.isEmpty() )
1675 path += QString( "#%1" ).arg( context );
1681 Sets enable or disable some actions on selection changed.
1683 void LightApp_Application::onSelectionChanged()
1685 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
1686 bool canCopy = m ? m->canCopy() : false;
1687 bool canPaste = m ? m->canPaste() : false;
1689 action( EditCopyId )->setEnabled(canCopy);
1690 action( EditPasteId )->setEnabled(canPaste);
1694 SLOT: Performs some actions when dockable windows are triggered
1696 void LightApp_Application::onDockWindowVisibilityChanged( bool )
1700 QWidget* LightApp_Application::dockWindow( const int id ) const
1703 if ( myWin.contains( id ) )
1708 QDockWidget* LightApp_Application::windowDock( QWidget* wid ) const
1713 QDockWidget* dock = 0;
1714 QWidget* w = wid->parentWidget();
1715 while ( w && !dock )
1717 dock = ::qobject_cast<QDockWidget*>( w );
1718 w = w->parentWidget();
1723 void LightApp_Application::insertDockWindow( const int id, QWidget* wid )
1728 if ( wid != dockWindow( id ) )
1729 removeDockWindow( id );
1731 myWin.insert( id, wid );
1733 QtxDockWidget* dock = new QtxDockWidget( true, desktop() );
1734 if ( id == WT_InfoPanel ) {
1735 // Info panel's position is strongly limited to the right area;
1736 // It is not movable and not floatable.
1737 dock->setAllowedAreas( Qt::RightDockWidgetArea );
1738 dock->setFeatures( QDockWidget::DockWidgetClosable );
1739 connect( dock, SIGNAL( aboutToShow()), this, SLOT( onInfoPanelShown() ) );
1742 dock->setFeatures( QDockWidget::AllDockWidgetFeatures );
1744 connect( dock, SIGNAL( destroyed( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
1746 dock->setObjectName( wid->objectName().isEmpty() ? QString( "window_%1" ).arg( id ) :
1747 QString( "%1Dock" ).arg( wid->objectName() ) );
1748 dock->setWidget( wid );
1749 dock->toggleViewAction()->setData( QVariant( wid->objectName() ) );
1750 connect( dock->toggleViewAction(), SIGNAL( triggered( bool ) ),
1751 this, SLOT( onDockWindowVisibilityChanged( bool ) ) );
1753 QKeySequence accel = wid->property( "shortcut" ).value<QKeySequence>();
1754 if ( !accel.isEmpty() )
1755 dock->toggleViewAction()->setShortcut( accel );
1760 void LightApp_Application::removeDockWindow( const int id )
1762 QWidget* wid = dockWindow( id );
1768 QDockWidget* dock = windowDock( wid );
1772 dock->setWidget( 0 );
1773 wid->setParent( 0 );
1774 wid->setVisible( false );
1778 void LightApp_Application::placeDockWindow( const int id, Qt::DockWidgetArea place )
1780 QDockWidget* dock = windowDock( dockWindow( id ) );
1781 if ( dock && desktop() ) {
1782 desktop()->addDockWidget( place, dock );
1783 QtxDockAction* a = qobject_cast<QtxDockAction*>( action( ViewWindowsId ) );
1784 if ( a ) a->update();
1790 \param flag - key for window
1791 Flag used how identificator of window in windows list.
1793 QWidget* LightApp_Application::getWindow( const int flag)
1795 QWidget* wid = dockWindow( flag );
1797 insertDockWindow( flag, wid = createWindow( flag ) );
1799 QMap<int, int> winMap;
1800 currentWindows( winMap );
1801 if ( winMap.contains( flag ) )
1802 placeDockWindow( flag, (Qt::DockWidgetArea)winMap[flag] );
1808 \return Object Browser
1810 SUIT_DataBrowser* LightApp_Application::objectBrowser()
1812 return qobject_cast<SUIT_DataBrowser*>( dockWindow( WT_ObjectBrowser ) );
1815 QtxInfoPanel* LightApp_Application::infoPanel()
1817 return qobject_cast<QtxInfoPanel *>( dockWindow( WT_InfoPanel ));
1823 LogWindow* LightApp_Application::logWindow()
1825 return qobject_cast<LogWindow*>( dockWindow( WT_LogWindow ) );
1828 #ifndef DISABLE_PYCONSOLE
1830 This returns the python console integrated to the GUI. Depending
1831 when you request the python console, this function could return
1832 null. Then the optional parameter force (default to false) can be
1833 set to force the creation of the python console if it is not done
1835 \param force - if true, the pythonConsole is created if it does not exist yet
1836 \return Python Console
1838 PyConsole_Console* LightApp_Application::pythonConsole(const bool force)
1840 QWidget* wid = dockWindow( WT_PyConsole );
1841 if ( !wid && force==true) {
1842 wid = getWindow(WT_PyConsole);
1844 return qobject_cast<PyConsole_Console*>( wid );
1849 Updates object browser and maybe data models
1850 \param updateModels - if it is true, then data models are updated
1852 void LightApp_Application::updateObjectBrowser( const bool updateModels )
1854 // update existing data models
1857 const bool isAutoUpdate = objectBrowser() ? objectBrowser()->autoUpdate() : true;
1858 if ( objectBrowser() )
1859 objectBrowser()->setAutoUpdate( false );
1861 LightApp_Study* study = dynamic_cast<LightApp_Study*>(activeStudy());
1863 CAM_Study::ModelList dm_list;
1864 study->dataModels( dm_list );
1865 QListIterator<CAM_DataModel*> it( dm_list );
1866 while ( it.hasNext() ) {
1867 CAM_DataModel* camDM = it.next();
1868 if ( camDM && camDM->inherits( "LightApp_DataModel" ) )
1869 ((LightApp_DataModel*)camDM)->update();
1873 if( objectBrowser() )
1874 objectBrowser()->setAutoUpdate( isAutoUpdate );
1877 if ( objectBrowser() ) {
1878 objectBrowser()->updateGeometry();
1879 objectBrowser()->updateTree( 0, false );
1886 LightApp_Preferences* LightApp_Application::preferences() const
1888 return preferences( false );
1892 \return first view manager of some type
1893 \param vmType - type of view manager
1894 \param create - is it necessary to create view manager in case, when there is no manager of such type
1896 SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, const bool create )
1898 SUIT_ViewManager* aVM = viewManager( vmType );
1899 SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
1900 MESSAGE("vmType: " << vmType.toStdString() << " aVM: " << aVM << " anActiveVM: " << anActiveVM );
1901 if ( anActiveVM && anActiveVM->getType() == vmType )
1903 MESSAGE("aVM = anActiveVM");
1907 bool keepDetached = property("keep_detached").toBool();
1908 if ( aVM && (!aVM->getDetached() || keepDetached) && create )
1910 if ( !aVM->getActiveView() )
1912 MESSAGE("aVM->createView()");
1917 MESSAGE("desktop()->setActiveWindow: " << aVM->getActiveView());
1918 desktop()->setActiveWindow( aVM->getActiveView() );
1923 MESSAGE("aVM = createViewManager( vmType )");
1924 aVM = createViewManager( vmType );
1931 Creates view manager of some type
1932 \param vmType - type of view manager
1934 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, bool detached )
1936 SUIT_ResourceMgr* resMgr = resourceMgr();
1938 SUIT_ViewManager* viewMgr = 0;
1939 #ifndef DISABLE_GLVIEWER
1940 if( vmType == GLViewer_Viewer::Type() )
1942 viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() );
1943 new LightApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
1946 #ifndef DISABLE_PLOT2DVIEWER
1947 if( vmType == Plot2d_Viewer::Type() )
1949 viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
1951 #ifndef DISABLE_SALOMEOBJECT
1952 SPlot2d_Viewer* v = new SPlot2d_Viewer();
1954 new LightApp_Plot2dSelector( v, mySelMgr );
1956 vm = new Plot2d_Viewer();
1958 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1959 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
1962 Plot2d_ViewFrame* frame = wnd->getViewFrame();
1963 frame->setBackgroundColor( resMgr->colorValue( "Plot2d", "Background", frame->backgroundColor() ) );
1967 #ifndef DISABLE_QXGRAPHVIEWER
1968 if( vmType == QxScene_Viewer::Type() )
1970 viewMgr = new QxScene_ViewManager( activeStudy(), desktop() );
1971 QxScene_Viewer* vm = new QxScene_Viewer();
1972 viewMgr->setViewModel( vm );
1973 //QxScene_ViewWindow* wnd = dynamic_cast<QxScene_ViewWindow*>( viewMgr->getActiveView() );
1976 #ifndef DISABLE_GRAPHICSVIEW
1977 if( vmType == GraphicsView_Viewer::Type() )
1979 viewMgr = new GraphicsView_ViewManager( activeStudy(), desktop() );
1980 new LightApp_GVSelector( (GraphicsView_Viewer*)viewMgr->getViewModel(), mySelMgr );
1983 #ifndef DISABLE_PVVIEWER
1984 if( vmType == PVViewer_Viewer::Type() )
1986 if (( viewMgr = dynamic_cast<PVViewer_ViewManager*>( getViewManager( vmType, false )))) {
1987 viewMgr->getActiveView()->setFocus();
1990 viewMgr = new PVViewer_ViewManager( activeStudy(), desktop() );
1994 #ifndef DISABLE_PYVIEWER
1995 if( vmType == PyViewer_Viewer::Type() )
1997 viewMgr = new PyViewer_ViewManager( activeStudy(), desktop() );
2000 #ifndef DISABLE_OCCVIEWER
2001 if( vmType == OCCViewer_Viewer::Type() )
2003 viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
2004 OCCViewer_Viewer* vm;
2005 #ifndef DISABLE_SALOMEOBJECT
2006 vm = new SOCC_Viewer();
2008 vm = new OCCViewer_Viewer( true );
2010 vm->setBackground( OCCViewer_ViewFrame::TOP_LEFT,
2011 resMgr->backgroundValue( "OCCViewer", "xz_background", vm->background(OCCViewer_ViewFrame::TOP_LEFT) ) );
2012 vm->setBackground( OCCViewer_ViewFrame::TOP_RIGHT,
2013 resMgr->backgroundValue( "OCCViewer", "yz_background", vm->background(OCCViewer_ViewFrame::TOP_RIGHT) ) );
2014 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_LEFT,
2015 resMgr->backgroundValue( "OCCViewer", "xy_background", vm->background(OCCViewer_ViewFrame::BOTTOM_LEFT) ) );
2016 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_RIGHT,
2017 resMgr->backgroundValue( "OCCViewer", "background", vm->background(OCCViewer_ViewFrame::MAIN_VIEW) ) );
2019 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
2020 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ));
2021 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
2022 vm->setProjectionType( resMgr->integerValue( "OCCViewer", "projection_mode", vm->projectionType() ) );
2023 vm->setStereoType( resMgr->integerValue( "OCCViewer", "stereo_type", vm->stereoType() ) );
2024 vm->setAnaglyphFilter( resMgr->integerValue( "OCCViewer", "anaglyph_filter", vm->anaglyphFilter() ) );
2025 vm->setStereographicFocus( resMgr->integerValue( "OCCViewer", "focus_type", vm->stereographicFocusType() ),
2026 resMgr->doubleValue( "OCCViewer", "focus_value", vm->stereographicFocusValue() ));
2027 vm->setInterocularDistance( resMgr->integerValue( "OCCViewer", "iod_type", vm->interocularDistanceType() ),
2028 resMgr->doubleValue( "OCCViewer", "iod_value", vm->interocularDistanceValue() ));
2029 vm->setSelectionStyle((OCCViewer_ViewWindow::SelectionStyle) resMgr->integerValue( "OCCViewer", "adv_selection_mode", vm->selectionStyle() ) );
2031 vm->setReverseStereo( resMgr->booleanValue( "OCCViewer", "reverse_stereo", vm->isReverseStereo() ) );
2032 vm->setVSync( resMgr->booleanValue( "OCCViewer", "enable_vsync", vm->isVSync() ) );
2033 vm->setQuadBufferSupport( resMgr->booleanValue( "OCCViewer", "enable_quad_buffer_support", vm->isQuadBufferSupport() ) );
2034 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
2035 vm->enablePreselection( resMgr->booleanValue( "OCCViewer", "enable_preselection", vm->isPreselectionEnabled() ) );
2036 vm->enableSelection( resMgr->booleanValue( "OCCViewer", "enable_selection", vm->isSelectionEnabled() ) );
2037 vm->setClippingColor( resMgr->colorValue( "OCCViewer", "clipping_color", vm->clippingColor() ) );
2038 vm->setClippingTextureParams( resMgr->booleanValue( "OCCViewer", "clipping_use_default_texture", vm->isDefaultTextureUsed() ),
2039 resMgr->stringValue( "OCCViewer", "clipping_texture", vm->clippingTexture() ),
2040 resMgr->booleanValue( "OCCViewer", "clipping_modulate", vm->isTextureModulated() ),
2041 resMgr->doubleValue( "OCCViewer", "clipping_scale", vm->clippingTextureScale() ) );
2044 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
2045 new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
2048 #ifndef DISABLE_VTKVIEWER
2049 #ifndef DISABLE_SALOMEOBJECT
2050 if ( vmType == SVTK_Viewer::Type() )
2052 if ( vmType == VTKViewer_Viewer::Type() )
2055 #ifndef DISABLE_SALOMEOBJECT
2056 viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
2057 SVTK_Viewer* vm = dynamic_cast<SVTK_Viewer*>( viewMgr->getViewModel() );
2060 vm->setProjectionMode( resMgr->integerValue( "VTKViewer", "projection_mode", vm->projectionMode() ) );
2061 vm->setStereoType( resMgr->integerValue( "VTKViewer", "stereo_type", vm->stereoType() ) );
2062 vm->setAnaglyphFilter( resMgr->integerValue( "VTKViewer", "anaglyph_filter", vm->anaglyphFilter() ) );
2063 vm->setQuadBufferSupport( resMgr->booleanValue( "VTKViewer", "enable_quad_buffer_support", vm->isQuadBufferSupport() ) );
2064 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
2065 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
2066 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ) );
2067 vm->setStaticTrihedronVisible( resMgr->booleanValue( "3DViewer", "show_static_trihedron", vm->isStaticTrihedronVisible() ) );
2068 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
2069 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
2070 vm->setPreSelectionMode(resMgr->integerValue( "VTKViewer", "preselection", vm->preSelectionMode() ) );
2071 vm->enableSelection( resMgr->booleanValue( "VTKViewer", "enable_selection", vm->isSelectionEnabled() ) );
2072 vm->setIncrementalSpeed( resMgr->integerValue( "VTKViewer", "speed_value", vm->incrementalSpeed() ),
2073 resMgr->integerValue( "VTKViewer", "speed_mode", vm->incrementalSpeedMode() ) );
2074 vm->setSpacemouseButtons( resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", vm->spacemouseBtn(1) ),
2075 resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", vm->spacemouseBtn(2) ),
2076 resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", vm->spacemouseBtn(3) ) );
2077 new LightApp_VTKSelector( vm, mySelMgr );
2080 viewMgr = new VTKViewer_ViewManager( activeStudy(), desktop() );
2081 VTKViewer_Viewer* vm = dynamic_cast<VTKViewer_Viewer*>( viewMgr->getViewModel() );
2083 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
2088 #ifndef DISABLE_PV3DVIEWER
2089 # ifndef DISABLE_SALOMEOBJECT
2090 if ( vmType == SPV3D_ViewModel::Type() )
2092 if ( vmType == PV3DViewer_ViewModel::Type() )
2095 viewMgr = new SPV3D_ViewManager( activeStudy(), desktop() );
2096 SPV3D_ViewModel* vm = dynamic_cast<SPV3D_ViewModel*>( viewMgr->getViewModel() );
2099 // vm->setBackground(...); //NYI
2102 new LightApp_PV3DSelector( vm, mySelMgr );
2105 viewMgr = new PV3DViewer_ViewManager( activeStudy(), desktop() );
2106 PV3DViewer_ViewModel* vm = dynamic_cast<PV3DViewer_ViewModel*>( viewMgr->getViewModel() );
2109 // vm->setBackground(...); //NYI
2117 viewMgr->setDetached(detached);
2118 addViewManager( viewMgr );
2119 SUIT_ViewWindow* viewWin = viewMgr->createViewWindow();
2121 if ( viewWin && desktop() ) {
2122 viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
2123 viewWin->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
2129 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, QWidget* w )
2131 SUIT_ResourceMgr* resMgr = resourceMgr();
2133 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
2135 new LightApp_WgViewModel( vmType, w ) );
2136 vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
2138 addViewManager( vm );
2139 SUIT_ViewWindow* vw = vm->createViewWindow();
2140 if ( vw && desktop() ) {
2141 vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
2142 vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
2145 if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
2146 myUserWmTypes << vmType;
2151 SUIT_ViewManager* LightApp_Application::createViewManager( SUIT_ViewModel* theModel )
2153 SUIT_ResourceMgr* resMgr = resourceMgr();
2155 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
2159 QString vmType = vm->getType();
2161 vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
2163 addViewManager( vm );
2164 SUIT_ViewWindow* vw = vm->createViewWindow();
2165 if ( vw && desktop() ) {
2166 vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
2167 vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
2170 if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
2171 myUserWmTypes << vmType;
2177 SLOT: Removes view manager from application
2179 void LightApp_Application::onCloseView( SUIT_ViewManager* theVM )
2181 removeViewManager( theVM );
2185 Protected SLOT: On study created.
2186 \param theStudy - just created study
2188 void LightApp_Application::onStudyCreated( SUIT_Study* theStudy )
2190 SUIT_DataObject* aRoot = 0;
2191 if ( theStudy && theStudy->root() )
2193 aRoot = theStudy->root();
2194 //aRoot->setName( tr( "DATA_MODELS" ) );
2197 getWindow( WT_ObjectBrowser );
2198 getWindow( WT_InfoPanel );
2200 loadDockWindowsState();
2202 if ( objectBrowser() )
2203 objectBrowser()->setRoot( aRoot );
2205 activateModule( defaultModule() );
2207 if ( objectBrowser() )
2208 objectBrowser()->openLevels();
2210 #ifndef DISABLE_PYCONSOLE
2211 if( pythonConsole() )
2212 getPyInterp()->initStudy();
2217 Protected SLOT: On study opened.
2218 \param theStudy - just opened study
2220 void LightApp_Application::onStudyOpened( SUIT_Study* theStudy )
2222 SUIT_DataObject* aRoot = 0;
2223 if ( theStudy && theStudy->root() )
2225 aRoot = theStudy->root();
2229 getWindow( WT_ObjectBrowser );
2230 getWindow( WT_InfoPanel );
2232 loadDockWindowsState();
2234 if ( objectBrowser() )
2235 objectBrowser()->setRoot( aRoot );
2237 activateModule( defaultModule() );
2239 if ( objectBrowser() )
2240 objectBrowser()->openLevels();
2242 #ifndef DISABLE_PYCONSOLE
2243 if( pythonConsole() )
2244 getPyInterp()->initStudy();
2250 /*!Protected SLOT. On study saved.*/
2251 void LightApp_Application::onStudySaved( SUIT_Study* s )
2253 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
2255 mru->insert( s->studyName() );
2260 /*!Protected SLOT. On study closed.*/
2261 void LightApp_Application::onStudyClosed( SUIT_Study* /*s*/ )
2264 disconnect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
2265 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
2268 // stop auto-save timer
2269 myAutoSaveTimer->stop();
2271 // Bug 10396: clear selection
2272 mySelMgr->clearSelected();
2274 // Bug 12944: emit signal only after clear selection
2277 activateModule( "" );
2280 /*!Protected SLOT.On desktop activated.*/
2281 void LightApp_Application::onDesktopActivated()
2283 CAM_Application::onDesktopActivated();
2284 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>(activeModule());
2286 aModule->studyActivated();
2289 void LightApp_Application::studyOpened( SUIT_Study* s )
2291 CAM_Application::studyOpened( s );
2294 updateViewManagers();
2297 void LightApp_Application::studySaved( SUIT_Study* s )
2299 CAM_Application::studyOpened( s );
2300 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
2301 if ( aResMgr && activeStudy() ) {
2302 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
2303 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
2307 void LightApp_Application::studyCreated( SUIT_Study* s )
2309 CAM_Application::studyCreated( s );
2312 updateViewManagers();
2315 /*!Gets file filter.
2316 *\retval QString "(*.hdf)"
2318 QString LightApp_Application::getFileFilter( bool /*open*/) const
2324 Shows file dialog and return user selected file name
2326 QString LightApp_Application::getFileName( bool open, const QString& initial, const QString& filters,
2327 const QString& caption, QWidget* parent )
2331 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
2332 return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
2335 /*! Gets directory*/
2336 QString LightApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
2340 return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true );
2343 /*! Get open file names*/
2344 QStringList LightApp_Application::getOpenFileNames( const QString& initial, const QString& filters,
2345 const QString& caption, QWidget* parent )
2349 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
2350 return SUIT_FileDlg::getOpenFileNames( parent, initial, fls, caption, true );
2353 /*!Private SLOT. Update object browser.*/
2354 void LightApp_Application::onRefresh()
2356 updateObjectBrowser( true );
2359 /*!Private SLOT. Update actions after rename object.*/
2360 void LightApp_Application::onRenamed()
2362 activeStudy()->Modified();
2366 // IMN 08.07.2015 : issue 002556: Some stereo outputs are affected by window position.
2367 // To prevent reversion the window should be either aligned during movement and resize.
2368 /*!Private SLOT. Update actions after rename object.*/
2369 /*void LightApp_Application::onMoved()
2371 OCCViewer_ViewManager* viewMgr = 0;
2372 viewMgr = dynamic_cast<OCCViewer_ViewManager*>( getViewManager( OCCViewer_Viewer::Type(), false ) );
2374 OCCViewer_ViewWindow* view = 0;
2375 view = dynamic_cast<OCCViewer_ViewWindow*>( viewMgr->getActiveView() );
2377 view->getViewPort()->repaintViewAfterMove();
2382 /*!Private SLOT. Support drag-and-drop operation.*/
2383 void LightApp_Application::onDropped( const QList<SUIT_DataObject*>& objects, SUIT_DataObject* parent, int row, Qt::DropAction action )
2385 LightApp_DataObject* parentObj = dynamic_cast<LightApp_DataObject*>( parent );
2389 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>( parentObj->module() );
2391 aModule->dropObjects( objects, parentObj, row, action );
2394 /*!Private SLOT. On preferences.*/
2395 void LightApp_Application::onPreferences()
2397 showPreferences( activeModule() ? activeModule()->moduleName() : tr( "PREF_CATEGORY_SALOME" ) );
2400 /*!Private SLOT. On preferences.*/
2401 void LightApp_Application::showPreferences( const QString& path )
2403 showPreferences( QStringList() << path );
2406 void LightApp_Application::showPreferences( const QStringList& path )
2408 QApplication::setOverrideCursor( Qt::WaitCursor );
2410 LightApp_PreferencesDlg* prefDlg = new LightApp_PreferencesDlg( preferences( true ), desktop());
2412 QApplication::restoreOverrideCursor();
2417 preferences()->activateItem( path );
2419 if ( ( prefDlg->exec() == QDialog::Accepted || prefDlg->isSaved() ) && resourceMgr() )
2422 resourceMgr()->setValue( "desktop", "geometry", desktop()->storeGeometry() );
2423 resourceMgr()->save();
2426 shortcutMgr()->updateShortcuts();
2432 /*!Protected SLOT. On preferences changed.*/
2433 void LightApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param )
2435 LightApp_Module* sMod = 0;
2436 CAM_Module* mod = module( modName );
2437 if ( mod && mod->inherits( "LightApp_Module" ) )
2438 sMod = (LightApp_Module*)mod;
2441 sMod->preferencesChanged( section, param );
2443 preferencesChanged( section, param );
2444 // emit signal to allow additional preferences changing processing
2445 emit preferenceChanged( modName, section, param );
2448 /*!Remove all windows from study.*/
2449 void LightApp_Application::beforeCloseDoc( SUIT_Study* s )
2451 saveDockWindowsState();
2453 if ( SUIT_DataBrowser* ob = objectBrowser() )
2456 CAM_Application::beforeCloseDoc( s );
2459 /*!Update actions.*/
2460 void LightApp_Application::updateActions()
2462 updateCommandsStatus();
2468 SUIT_Study* LightApp_Application::createNewStudy()
2470 LightApp_Study* aStudy = new LightApp_Study( this );
2472 // Set up processing of major study-related events
2473 connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
2474 connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
2475 connect( aStudy, SIGNAL( saved ( SUIT_Study* ) ), this, SLOT( onStudySaved ( SUIT_Study* ) ) );
2476 connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
2482 Creates window by flag.
2483 \param flag - identificator of window type
2485 QWidget* LightApp_Application::createWindow( const int flag )
2489 SUIT_ResourceMgr* resMgr = resourceMgr();
2491 if ( flag == WT_ObjectBrowser )
2493 SUIT_DataBrowser* ob = new SUIT_DataBrowser( new LightApp_DataObject(), desktop() );
2494 ob->setObjectName( "objectBrowser" );
2495 ob->setSortMenuEnabled( true );
2496 ob->setAutoUpdate( true );
2497 if ( resMgr->hasValue( "ObjectBrowser", "auto_hide_search_tool" ) )
2498 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
2500 //ob->setAutoOpenLevel( 1 ); // commented by ASV as a fix to bug IPAL10107
2501 ob->setWindowTitle( tr( "OBJECT_BROWSER" ) );
2502 connect( ob, SIGNAL( requestUpdate() ), this, SLOT( onRefresh() ) );
2504 QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
2505 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
2506 treeModel->setSearcher( this );
2507 treeModel->registerColumn( 0, EntryCol, LightApp_DataObject::EntryId );
2508 treeModel->setAppropriate( EntryCol, Qtx::Toggled );
2510 // Mantis issue 0020136: Drag&Drop in OB
2511 SUIT_ProxyModel* proxyModel = dynamic_cast<SUIT_ProxyModel*>(treeModel);
2513 connect( proxyModel, SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
2514 this, SLOT( onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
2515 connect( proxyModel, SIGNAL( renamed( SUIT_DataObject* ) ),
2516 this, SLOT( onRenamed( ) ) );
2520 // temporary commented
2522 OB_ListView* ob_list = dynamic_cast<OB_ListView*>( const_cast<QListView*>( ob->listView() ) );
2524 ob_list->setColumnMaxWidth( 0, desktop()->width()/4 );
2527 // Create OBSelector
2528 new LightApp_OBSelector( ob, mySelMgr );
2529 ob->treeView()->header()->setSectionResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
2530 ob->treeView()->header()->moveSection(SUIT_DataObject::NameId,SUIT_DataObject::VisibilityId);
2531 ob->treeView()->setColumnWidth(SUIT_DataObject::VisibilityId, VISIBILITY_COLUMN_WIDTH);
2532 ob->setProperty( "shortcut", QKeySequence( "Alt+Shift+O" ) );
2534 ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
2536 else if ( flag == WT_InfoPanel)
2538 QtxInfoPanel* ipanel = new QtxInfoPanel( desktop() );
2539 ipanel->setObjectName( "infoPanel" );
2540 ipanel->setWindowTitle( tr( "INFO_PANEL" ) );
2543 #ifndef DISABLE_PYCONSOLE
2544 else if ( flag == WT_PyConsole )
2546 PyConsole_Console* pyCons = new PyConsole_Console( desktop(), new LightApp_PyEditor( getPyInterp() ) );
2547 pyCons->setObjectName( "pythonConsole" );
2548 pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
2549 pyCons->setFont( resMgr->fontValue( "PyConsole", "font" ) );
2550 pyCons->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
2551 pyCons->setAutoCompletion( resMgr->booleanValue( "PyConsole", "auto_completion", true ) );
2552 pyCons->setProperty( "shortcut", QKeySequence( "Alt+Shift+P" ) );
2556 else if ( flag == WT_LogWindow )
2558 LogWindow* logWin = new LogWindow( desktop() );
2559 logWin->handleQtMessages( true );
2560 logWin->setObjectName( "logWindow" );
2561 logWin->setWindowTitle( tr( "LOG_WINDOW" ) );
2562 logWin->setProperty( "shortcut", QKeySequence( "Alt+Shift+L" ) );
2564 logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
2570 \return default windows( Object Browser, Python Console )
2571 Adds to map \a aMap.
2573 void LightApp_Application::defaultWindows( QMap<int, int>& aMap ) const
2575 #ifndef DISABLE_PYCONSOLE
2576 aMap.insert( WT_PyConsole, Qt::BottomDockWidgetArea );
2578 if ( activeStudy() ) {
2579 aMap.insert( WT_ObjectBrowser, Qt::LeftDockWidgetArea );
2580 aMap.insert( WT_InfoPanel, Qt::RightDockWidgetArea );
2581 // aMap.insert( WT_LogWindow, Qt::DockBottom );
2585 /*!Default view managers*/
2586 void LightApp_Application::defaultViewManagers( QStringList& ) const
2592 \return preferences.
2593 Create preferences, if \a crt = true.
2595 LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const
2600 LightApp_Application* that = (LightApp_Application*)this;
2602 bool toCreate = !_prefs_ && crt;
2605 _prefs_ = new LightApp_Preferences( resourceMgr() );
2606 that->createPreferences( _prefs_ );
2607 qAddPostRoutine( LightAppCleanUpAppResources );
2610 that->myPrefs = _prefs_;
2612 connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
2613 this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ), Qt::UniqueConnection );
2614 connect( myPrefs, SIGNAL( resetToDefaults() ),
2615 this, SIGNAL( preferenceResetToDefaults() ), Qt::UniqueConnection );
2620 QList<SUIT_Application*> appList = SUIT_Session::session()->applications();
2621 for ( QList<SUIT_Application*>::iterator appIt = appList.begin(); appIt != appList.end(); ++appIt )
2623 LightApp_Application* app = ::qobject_cast<LightApp_Application*>( *appIt );
2627 // all modules available in current session
2629 app->modules( names, false );
2631 // step 1: iterate through list of all available modules
2632 // and add empty preferences page
2633 for ( QStringList::const_iterator it = names.begin(); it != names.end(); ++it )
2635 if ( !_prefs_->hasModule( *it ) ) // prevent possible duplications
2637 int modId = _prefs_->addPreference( *it ); // add empty page
2638 _prefs_->setItemIcon( modId, moduleIcon( *it, 20 ) ); // scale icon to 20x20 pix
2642 // step 2: iterate through list of all loaded modules
2643 // and initialize their preferences
2644 ModuleList loadedModules;
2645 app->modules( loadedModules );
2646 QListIterator<CAM_Module*> itr( loadedModules );
2647 while ( itr.hasNext() )
2649 LightApp_Module* module = 0;
2650 CAM_Module* m = itr.next();
2651 if ( m->inherits( "LightApp_Module" ) )
2652 module = (LightApp_Module*)m;
2654 if ( module && !_prefs_->hasModule( module->moduleName() ) )
2656 _prefs_->addPreference( module->moduleName() ); // add page (for sure, had to be done at step 1)
2657 module->createPreferences(); // initialize preferences
2658 that->emptyPreferences( module->moduleName() ); // show dummy page if module does not export any preferences
2662 _prefs_->setItemProperty( "info", tr( "PREFERENCES_NOT_LOADED" ) ); // dummy page for modules which are not loaded yet
2668 Adds new module to application
2670 void LightApp_Application::moduleAdded( CAM_Module* mod )
2672 CAM_Application::moduleAdded( mod );
2674 LightApp_Module* lightMod = 0;
2675 if ( mod && mod->inherits( "LightApp_Module" ) )
2676 lightMod = (LightApp_Module*)mod;
2678 if ( myPrefs && lightMod && !myPrefs->hasModule( lightMod->moduleName() ))
2680 myPrefs->addPreference( mod->moduleName() );
2681 lightMod->createPreferences();
2682 emptyPreferences( mod->moduleName() );
2686 void LightApp_Application::moduleDeactivated( CAM_Module* /*mod*/ )
2689 infoPanel()->clear();
2692 void LightApp_Application::emptyPreferences( const QString& modName )
2694 QtxPreferenceItem* item = myPrefs->findItem( modName, true );
2695 if ( !item || !item->isEmpty() )
2698 QtxPagePrefFrameItem* frm = new QtxPagePrefFrameItem( item->title(), item->parentItem() );
2699 frm->setIcon( item->icon() );
2700 frm->setStretch( false );
2701 item->parentItem()->insertItem( frm, item );
2702 new QtxPagePrefLabelItem( Qt::AlignCenter, tr( "PREFERENCES_NOT_SUPPORTED" ).arg( modName ), frm );
2709 void LightApp_Application::createPreferences( LightApp_Preferences* pref )
2714 QStringList aValuesList;
2715 QList<QVariant> anIndicesList;
2719 // . Top-level "SALOME" preferences group <<start>>
2720 int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
2721 pref->setItemIcon( salomeCat, Qtx::scaleIcon( resourceMgr()->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false ), 20 ) );
2723 // .. "General" preferences tab <<start>>
2724 int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat );
2726 // ... "Language" group <<start>>
2727 int langGroup = pref->addPreference( tr( "PREF_GROUP_LANGUAGE" ), genTab );
2728 pref->setItemProperty( "columns", 2, langGroup );
2729 // .... -> application language
2730 int curLang = pref->addPreference( tr( "PREF_CURRENT_LANGUAGE" ), langGroup,
2731 LightApp_Preferences::Selector, "language", "language" );
2732 QStringList aLangs = SUIT_Session::session()->resourceMgr()->stringValue( "language", "languages", "en" ).split( "," );
2733 QList<QVariant> aIcons;
2734 QList<QVariant> aNumbers;
2735 QStringList aTitles;
2736 foreach ( QString aLang, aLangs ) {
2737 aIcons << QPixmap( QString( ":/images/%1" ).arg( aLang ) );
2739 aTitles << langToName( aLang );
2741 pref->setItemProperty( "strings", aTitles, curLang );
2742 pref->setItemProperty( "ids", aNumbers, curLang );
2743 pref->setItemProperty( "icons", aIcons, curLang );
2744 pref->setItemProperty( "restart", true, curLang );
2746 int curLocale = pref->addPreference( tr( "PREF_CURRENT_LOCALE" ), langGroup,
2747 LightApp_Preferences::Bool, "language", "locale" );
2748 pref->setItemProperty( "restart", true, curLocale );
2749 // ... "Language" group <<end>>
2751 // ... "Look and feel" group <<start>>
2752 int lookGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), genTab );
2753 pref->setItemProperty( "columns", 2, lookGroup );
2754 // .... -> show splash-screen
2755 pref->addPreference( tr( "PREF_SHOW_SPLASH" ), lookGroup, LightApp_Preferences::Bool, "launch", "splash" );
2756 // .... -> opaque resize
2757 pref->addPreference( tr( "PREF_OPAQUE_RESIZE" ), lookGroup, LightApp_Preferences::Bool, "desktop", "opaque_resize" );
2758 // .... -> drop-down buttons
2759 pref->addPreference( tr( "PREF_DROP_DOWN_BUTTONS" ), lookGroup, LightApp_Preferences::Bool, "viewers", "drop_down_buttons" );
2760 // .... -> Notification timeout
2761 int delay = pref->addPreference( tr( "PREF_NOTIFY_TIMEOUT" ), lookGroup, LightApp_Preferences::IntSpin, "notification", "timeout" );
2762 pref->setItemProperty( "special", tr("PREF_NOTIFY_TIMEOUT_NONE"), delay );
2763 pref->setItemProperty( "min", 0, delay );
2764 pref->setItemProperty( "max", 100, delay );
2765 pref->setItemProperty( "suffix", " sec", delay );
2766 // ... "Look and feel" group <<end>>
2768 // ... "Study properties" group <<start>>
2769 int studyGroup = pref->addPreference( tr( "PREF_GROUP_STUDY" ), genTab );
2770 pref->setItemProperty( "columns", 2, studyGroup );
2771 // .... -> multi-file save
2772 pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "multi_file" );
2773 // .... -> ascii save mode
2774 pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" );
2775 // .... -> store windows geometry
2776 pref->addPreference( tr( "PREF_LOAD_LIGHT" ), studyGroup, LightApp_Preferences::Bool, "Study", "autoload_light_modules" );
2777 pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" );
2778 pref->addPreference( "", studyGroup, LightApp_Preferences::Space );
2779 pref->addPreference( tr( "PREF_STORE_TOOL_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_tool_positions" );
2780 // .... -> auto-save
2781 int autoSaveInterval = pref->addPreference( tr( "PREF_AUTO_SAVE" ), studyGroup,
2782 LightApp_Preferences::IntSpin, "Study", "auto_save_interval" );
2783 pref->setItemProperty( "min", 0, autoSaveInterval );
2784 pref->setItemProperty( "max", 1440, autoSaveInterval );
2785 pref->setItemProperty( "special", tr( "PREF_AUTO_SAVE_DISABLED" ), autoSaveInterval );
2786 // ... "Study properties" group <<end>>
2788 // ... "Help browser" group <<start>>
2789 #ifndef DISABLE_QTXWEBBROWSER
2790 int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab, LightApp_Preferences::Auto, "ExternalBrowser", "use_external_browser");
2792 int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab );
2796 QString platform = "winapplication";
2798 QString platform = "application";
2800 // .... -> browser application
2801 int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, LightApp_Preferences::File, "ExternalBrowser", platform );
2802 pref->setItemProperty( "mode", Qtx::PT_OpenFile, apppref );
2803 // .... -> browser parameters
2804 pref->addPreference( tr( "PREF_PARAM" ), extgroup, LightApp_Preferences::String, "ExternalBrowser", "parameters" );
2805 // ... "Help browser" group <<end>>
2807 // ... "Python console properties" group <<start>>
2808 int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab );
2809 pref->setItemProperty( "columns", 2, pythonConsoleGroup );
2811 pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, LightApp_Preferences::Font, "PyConsole", "font" );
2812 // .... -> show banner
2813 pref->addPreference( tr( "PREF_SHOW_BANNER" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "show_banner" );
2814 // .... -> auto-completion
2815 pref->addPreference( tr( "PREF_AUTO_COMPLETION" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "auto_completion" );
2816 // ... "Python console properties" group <<end>>
2818 // ... "MRU" preferences group <<start>>
2819 int mruGroup = pref->addPreference( tr( "PREF_GROUP_MRU" ), genTab, LightApp_Preferences::Auto, "MRU", "show_mru" );
2820 pref->setItemProperty( "columns", 4, mruGroup );
2821 // number of MRU items
2822 int mruVisCount = pref->addPreference( tr( "PREF_MRU_VISIBLE_COUNT" ), mruGroup, LightApp_Preferences::IntSpin,
2823 "MRU", "visible_count" );
2824 pref->setItemProperty( "min", 0, mruVisCount );
2825 pref->setItemProperty( "max", 100, mruVisCount );
2827 int mruLinkType = pref->addPreference( tr( "PREF_MRU_LINK_TYPE" ), mruGroup, LightApp_Preferences::Selector,
2828 "MRU", "link_type" );
2829 aValuesList.clear();
2830 anIndicesList.clear();
2831 aValuesList << tr("PREF_MRU_LINK_AUTO") << tr("PREF_MRU_LINK_SHORT") << tr("PREF_MRU_LINK_FULL");
2832 anIndicesList << 0 << 1 << 2 ;
2833 pref->setItemProperty( "strings", aValuesList, mruLinkType );
2834 pref->setItemProperty( "indexes", anIndicesList, mruLinkType );
2835 // ... "MRU" preferences group <<end>>
2837 // ... "Full-screen" group <<start>>
2838 int fullScreenGroup = pref->addPreference( tr( "PREF_GROUP_FULL_SCREEN" ), genTab );
2839 pref->setItemProperty( "columns", 2, fullScreenGroup );
2840 // .... -> automatic hiding toolbars
2841 pref->addPreference( tr( "PREF_FULL_SCREEN_AUTO" ), fullScreenGroup,
2842 LightApp_Preferences::Bool, "OCCViewer", "automatic_hiding" );
2843 // ... "Full-screen" group <<end>>
2845 // .. "General" preferences tab <<end>>
2847 // .. "3D viewer" group <<start>>
2848 int Viewer3DGroup = pref->addPreference( tr( "PREF_GROUP_3DVIEWER" ), salomeCat );
2849 // ... -> navigation mode
2850 int vtkStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), Viewer3DGroup,
2851 LightApp_Preferences::Selector, "3DViewer", "navigation_mode" );
2852 aValuesList.clear();
2853 anIndicesList.clear();
2854 aValuesList << tr("PREF_STANDARD_STYLE") << tr("PREF_KEYFREE_STYLE");
2855 anIndicesList << 0 << 1;
2856 pref->setItemProperty( "strings", aValuesList, vtkStyleMode );
2857 pref->setItemProperty( "indexes", anIndicesList, vtkStyleMode );
2858 // ... -> zooming mode
2859 int occZoomingStyleMode = pref->addPreference( tr( "PREF_ZOOMING" ), Viewer3DGroup,
2860 LightApp_Preferences::Selector, "3DViewer", "zooming_mode" );
2861 aValuesList.clear();
2862 anIndicesList.clear();
2863 aValuesList << tr("PREF_ZOOMING_AT_CENTER") << tr("PREF_ZOOMING_AT_CURSOR");
2864 anIndicesList << 0 << 1;
2865 pref->setItemProperty( "strings", aValuesList, occZoomingStyleMode );
2866 pref->setItemProperty( "indexes", anIndicesList, occZoomingStyleMode );
2867 // ... "Trihedron" group <<start>>
2868 int occTriGroup = pref->addPreference( tr( "PREF_TRIHEDRON" ), Viewer3DGroup );
2869 pref->setItemProperty( "columns", 2, occTriGroup );
2870 // .... -> trihedron size
2871 int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occTriGroup,
2872 LightApp_Preferences::DblSpin, "3DViewer", "trihedron_size" );
2873 pref->setItemProperty( "min", 1.0E-06, occTS );
2874 pref->setItemProperty( "max", 1000, occTS );
2875 // .... -> relative size of trihedron
2876 pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "relative_size" );
2877 // .... -> show static trihedron
2878 pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "show_static_trihedron" );
2879 // ... "Trihedron" group <<end>>
2880 // .. "3D viewer" group <<end>>
2884 #ifndef DISABLE_OCCVIEWER
2885 // .. "OCC viewer" group <<start>>
2886 int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), salomeCat );
2888 // .... -> Projection mode
2889 int occProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), occGroup,
2890 LightApp_Preferences::Selector, "OCCViewer", "projection_mode" );
2891 aValuesList.clear();
2892 anIndicesList.clear();
2893 aValuesList << tr("PREF_ORTHOGRAPHIC") << tr("PREF_PERSPECTIVE");
2894 anIndicesList << 0 << 1;
2895 pref->setItemProperty( "strings", aValuesList, occProjMode );
2896 pref->setItemProperty( "indexes", anIndicesList, occProjMode );
2898 // .... -> Stereo group
2899 int stereoGroup = pref->addPreference( tr( "PREF_GROUP_STEREO" ), occGroup);
2900 pref->setItemProperty( "columns", 2, stereoGroup );
2901 // .... -> Stereo type
2902 int stereoType = pref->addPreference( tr( "PREF_STEREO_TYPE" ), stereoGroup,
2903 LightApp_Preferences::Selector, "OCCViewer", "stereo_type" );
2904 aValuesList.clear();
2905 anIndicesList.clear();
2907 OCCViewer_Viewer::stereoData( aValuesList, idList);
2908 foreach( int gid, idList ) anIndicesList << gid;
2909 pref->setItemProperty( "strings", aValuesList, stereoType );
2910 pref->setItemProperty( "indexes", anIndicesList, stereoType );
2912 // .... -> Anaglyph filter
2913 int anaglyphFilter = pref->addPreference( tr( "PREF_ANAGLYPH_FILTER" ), stereoGroup,
2914 LightApp_Preferences::Selector, "OCCViewer", "anaglyph_filter" );
2915 aValuesList.clear();
2916 anIndicesList.clear();
2917 aValuesList << tr("PREF_ANAGLYPH_RED_CYAN") << tr("PREF_ANAGLYPH_YELLOW_BLUE") << tr("PREF_ANAGLYPH_GREEN_MAGENTA");
2918 anIndicesList << 0 << 1 << 2;
2920 pref->setItemProperty( "strings", aValuesList, anaglyphFilter );
2921 pref->setItemProperty( "indexes", anIndicesList, anaglyphFilter );
2923 // .... -> Convergence distance type
2924 int occFocusType = pref->addPreference( tr( "PREF_FOCUS_TYPE" ), stereoGroup,
2925 LightApp_Preferences::Selector, "OCCViewer", "focus_type" );
2926 aValuesList.clear();
2927 anIndicesList.clear();
2928 aValuesList << tr("PREF_ABSOLUTE") << tr("PREF_RELATIVE");
2929 anIndicesList << 0 << 1;
2930 pref->setItemProperty( "strings", aValuesList, occFocusType );
2931 pref->setItemProperty( "indexes", anIndicesList, occFocusType );
2933 // .... -> Stereographic focus value
2934 int focusValue = pref->addPreference( tr( "PREF_FOCUS_VALUE" ), stereoGroup,
2935 LightApp_Preferences::DblSpin, "OCCViewer", "focus_value" );
2936 pref->setItemProperty( "precision", 3, focusValue );
2937 pref->setItemProperty( "min", 1.0E-03, focusValue );
2938 pref->setItemProperty( "max", 1.0E03, focusValue );
2939 pref->setItemProperty( "step", 0.05, focusValue );
2942 int occIODType = pref->addPreference( tr( "PREF_IOD_TYPE" ), stereoGroup,
2943 LightApp_Preferences::Selector, "OCCViewer", "iod_type" );
2944 aValuesList.clear();
2945 anIndicesList.clear();
2946 aValuesList << tr("PREF_ABSOLUTE") << tr("PREF_RELATIVE");
2947 anIndicesList << 0 << 1;
2948 pref->setItemProperty( "strings", aValuesList, occIODType );
2949 pref->setItemProperty( "indexes", anIndicesList, occIODType );
2951 // .... -> Interocular distance (IOD) value
2952 int IODValue = pref->addPreference( tr( "PREF_IOD_VALUE" ), stereoGroup,
2953 LightApp_Preferences::DblSpin, "OCCViewer", "iod_value" );
2954 pref->setItemProperty( "precision", 3, IODValue );
2955 pref->setItemProperty( "min", 1.0E-03, IODValue );
2956 pref->setItemProperty( "max", 1.0E03, IODValue );
2957 pref->setItemProperty( "step", 0.05, IODValue );
2959 // .... -> Reverse stereo
2960 pref->addPreference( tr( "PREF_REVERSE_STEREO" ), stereoGroup,
2961 LightApp_Preferences::Bool, "OCCViewer", "reverse_stereo" );
2962 // .... -> Enable V-Sync
2963 pref->addPreference( tr( "PREF_ENABLE_VSYNC" ), stereoGroup,
2964 LightApp_Preferences::Bool, "OCCViewer", "enable_vsync" );
2965 // .... -> Enable quad-buffer support
2966 pref->addPreference( tr( "PREF_ENABLE_QUAD_BUFFER_SUPPORT" ), stereoGroup,
2967 LightApp_Preferences::Bool, "OCCViewer", "enable_quad_buffer_support" );
2969 // ... "Background" group <<start>>
2970 int bgGroup = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup );
2971 // pref->setItemProperty( "columns", 2, bgGroup );
2972 aValuesList.clear();
2973 anIndicesList.clear();
2976 formats = OCCViewer_Viewer::backgroundData( aValuesList, idList, txtList );
2977 foreach( int gid, idList ) anIndicesList << gid;
2978 // .... -> 3D viewer background
2979 bgId = pref->addPreference( tr( "PREF_3DVIEWER_BACKGROUND" ), bgGroup,
2980 LightApp_Preferences::Background, "OCCViewer", "background" );
2981 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2982 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2983 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2984 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2985 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2986 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2987 pref->setItemProperty( "custom_enabled", false, bgId );
2988 pref->setItemProperty( "image_formats", formats, bgId );
2989 // .... -> XZ viewer background
2990 bgId = pref->addPreference( tr( "PREF_XZVIEWER_BACKGROUND" ), bgGroup,
2991 LightApp_Preferences::Background, "OCCViewer", "xz_background" );
2992 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2993 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2994 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2995 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2996 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2997 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2998 pref->setItemProperty( "custom_enabled", false, bgId );
2999 pref->setItemProperty( "image_formats", formats, bgId );
3000 // .... -> YZ viewer background
3001 bgId = pref->addPreference( tr( "PREF_YZVIEWER_BACKGROUND" ), bgGroup,
3002 LightApp_Preferences::Background, "OCCViewer", "yz_background" );
3003 pref->setItemProperty( "gradient_names", aValuesList, bgId );
3004 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
3005 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
3006 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
3007 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
3008 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
3009 pref->setItemProperty( "custom_enabled", false, bgId );
3010 pref->setItemProperty( "image_formats", formats, bgId );
3011 // .... -> XY viewer background
3012 bgId = pref->addPreference( tr( "PREF_XYVIEWER_BACKGROUND" ), bgGroup,
3013 LightApp_Preferences::Background, "OCCViewer", "xy_background" );
3014 pref->setItemProperty( "gradient_names", aValuesList, bgId );
3015 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
3016 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
3017 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
3018 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
3019 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
3020 pref->setItemProperty( "custom_enabled", false, bgId );
3021 pref->setItemProperty( "image_formats", formats, bgId );
3022 // ... "Background" group <<end>>
3025 // ... "Selection" group <<start>>
3026 int occSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), occGroup );
3027 pref->setItemProperty( "columns", 3, occSelectionGroup );
3028 // .... -> enable preselection
3029 pref->addPreference( tr( "PREF_ENABLE_PRESELECTION" ), occSelectionGroup,
3030 LightApp_Preferences::Bool, "OCCViewer", "enable_preselection" );
3031 // .... -> enable selection
3032 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), occSelectionGroup,
3033 LightApp_Preferences::Bool, "OCCViewer", "enable_selection" );
3034 // .... -> selection style
3035 int aSeleStyle = pref->addPreference( tr( "PREF_SELECTION_STYLE" ), occSelectionGroup,
3036 LightApp_Preferences::Selector, "OCCViewer", "adv_selection_mode" );
3037 aValuesList.clear();
3038 anIndicesList.clear();
3039 aValuesList << tr("PREF_POLYGON_SELECTION") << tr("PREF_CIRCLE_SELECTION");
3040 anIndicesList << 0 << 1;
3041 pref->setItemProperty( "strings", aValuesList, aSeleStyle);
3042 pref->setItemProperty( "indexes", anIndicesList, aSeleStyle);
3043 // ... "Selection" group <<end>>
3045 // ... "Clipping" group <<start>>
3046 int occClippingGroup = pref->addPreference( tr( "PREF_GROUP_CLIPPING" ), occGroup );
3047 // .... -> clipping color
3048 pref->addPreference( tr( "PREF_CLIPPING_COLOR" ), occClippingGroup,
3049 LightApp_Preferences::Color, "OCCViewer", "clipping_color" );
3050 int texturePref = pref->addPreference( "", occClippingGroup, LightApp_Preferences::Frame );
3051 pref->setItemProperty( "columns", 2, texturePref );
3052 // .... -> use default texture
3053 pref->addPreference( tr( "PREF_CLIPPING_DEFAULT_TEXTURE" ), texturePref,
3054 LightApp_Preferences::Bool, "OCCViewer", "clipping_use_default_texture" );
3055 // .... -> clipping texture
3056 int filePref = pref->addPreference( tr( "PREF_CLIPPING_TEXTURE" ), texturePref,
3057 LightApp_Preferences::File, "OCCViewer", "clipping_texture" );
3058 pref->setItemProperty( "path_filter", tr( "OCC_TEXTURE_FILES" ), filePref );
3060 pref->addPreference( tr( "PREF_CLIPPING_MODULATE" ), texturePref,
3061 LightApp_Preferences::Bool, "OCCViewer", "clipping_modulate" );
3062 // .... -> scale factor
3063 int scaleFactor = pref->addPreference( tr( "PREF_CLIPPING_SCALE" ), texturePref,
3064 LightApp_Preferences::DblSpin, "OCCViewer", "clipping_scale" );
3065 pref->setItemProperty( "precision", 3, scaleFactor );
3066 pref->setItemProperty( "min", 1.0E-03, scaleFactor );
3067 pref->setItemProperty( "max", 1.0E03, scaleFactor );
3068 pref->setItemProperty( "step", 0.1, scaleFactor );
3069 // ... "Clipping" group <<end>>
3071 // ... "Ray tracing" group <<start>>
3072 int occRayTracingGroup = pref->addPreference( tr( "PREF_GROUP_RAY_TRACING" ), occGroup );
3073 int rtPref = pref->addPreference( "", occRayTracingGroup, LightApp_Preferences::Frame );
3074 pref->setItemProperty( "columns", 2, rtPref );
3076 int rt_depth = pref->addPreference( tr( "PREF_RAY_TRACING_DEPTH" ), rtPref,
3077 LightApp_Preferences::IntSpin, "OCCViewer", "rt_depth" );
3078 pref->setItemProperty( "min", 1, rt_depth );
3079 pref->setItemProperty( "max", 10, rt_depth );
3080 pref->setItemProperty( "step", 1, rt_depth );
3081 pref->addPreference( "", rtPref, LightApp_Preferences::Frame );
3082 // .... -> specular reflections
3083 pref->addPreference( tr( "PREF_RAY_TRACING_REFLECTION" ), rtPref,
3084 LightApp_Preferences::Bool, "OCCViewer", "rt_reflection" );
3085 // .... -> adaptive anti-aliasing
3086 pref->addPreference( tr( "PREF_RAY_TRACING_ANTIALIASING" ), rtPref,
3087 LightApp_Preferences::Bool, "OCCViewer", "rt_antialiasing" );
3088 // .... -> shadows rendering
3089 pref->addPreference( tr( "PREF_RAY_TRACING_SHADOW" ), rtPref,
3090 LightApp_Preferences::Bool, "OCCViewer", "rt_shadow" );
3091 // .... -> transparent shadow
3092 pref->addPreference( tr( "PREF_RAY_TRACING_TRANS_SHADOW" ), rtPref,
3093 LightApp_Preferences::Bool, "OCCViewer", "rt_trans_shadow" );
3094 // ... "Ray tracing" group <<end>>
3096 // ... "Light source" group <<start>>
3097 int occLightGroup = pref->addPreference( tr( "PREF_GROUP_LIGHT" ), occGroup );
3098 // .... -> light color
3099 pref->addPreference( tr( "PREF_LIGHT_COLOR" ), occLightGroup,
3100 LightApp_Preferences::Color, "OCCViewer", "light_color" );
3101 int directionPref = pref->addPreference( "", occLightGroup, LightApp_Preferences::Frame );
3102 pref->setItemProperty( "columns", 3, directionPref );
3103 // .... -> light direction (dx component)
3104 int light_dx = pref->addPreference( tr( "Dx" ), directionPref,
3105 LightApp_Preferences::DblSpin, "OCCViewer", "light_dx" );
3106 pref->setItemProperty( "precision", 2, light_dx );
3107 pref->setItemProperty( "min", -1.0E03, light_dx );
3108 pref->setItemProperty( "max", 1.0E03, light_dx );
3109 pref->setItemProperty( "step", 0.1, light_dx );
3110 // .... -> light direction (dy component)
3111 int light_dy = pref->addPreference( tr( "Dy" ), directionPref,
3112 LightApp_Preferences::DblSpin, "OCCViewer", "light_dy" );
3113 pref->setItemProperty( "precision", 2, light_dy );
3114 pref->setItemProperty( "min", -1.0E03, light_dy );
3115 pref->setItemProperty( "max", 1.0E03, light_dy );
3116 pref->setItemProperty( "step", 0.1, light_dy );
3117 // .... -> light direction (dz component)
3118 int light_dz = pref->addPreference( tr( "Dz" ), directionPref,
3119 LightApp_Preferences::DblSpin, "OCCViewer", "light_dz" );
3120 pref->setItemProperty( "precision", 2, light_dz );
3121 pref->setItemProperty( "min", -1.0E03, light_dz );
3122 pref->setItemProperty( "max", 1.0E03, light_dz );
3123 pref->setItemProperty( "step", 0.1, light_dz );
3124 // ... "Light source" group <<end>>
3126 // ... "View cube" group <<start>>
3127 int occViewCubeGroup = pref->addPreference( tr( "PREF_GROUP_VIEWCUBE" ), occGroup );
3128 pref->setItemProperty( "columns", 2, occViewCubeGroup );
3129 // .... -> show view cube on viewer start
3130 pref->addPreference( tr( "PREF_VIEWCUBE_SHOW" ), occViewCubeGroup,
3131 LightApp_Preferences::Bool, "OCCViewer", "viewcube_show" );
3132 // .... -> view cube duration of animation (sec)
3133 int viewcube_dur = pref->addPreference( tr( "PREF_VIEWCUBE_DURATION" ), occViewCubeGroup,
3134 LightApp_Preferences::DblSpin, "OCCViewer", "viewcube_duration" );
3135 pref->setItemProperty( "min", 0.1, viewcube_dur );
3136 pref->setItemProperty( "max", 10.0, viewcube_dur );
3137 pref->setItemProperty( "step", 0.1, viewcube_dur );
3138 // .... -> show view cube axes
3139 pref->addPreference( tr( "PREF_VIEWCUBE_AXES" ), occViewCubeGroup,
3140 LightApp_Preferences::Bool, "OCCViewer", "viewcube_axes" );
3141 // ... "View cube" group <<end>>
3143 // ... "View cube default (OCCT) attributes" group <<start>>
3144 int occViewCubeAttrsGroup = pref->addPreference( tr( "PREF_VIEWCUBE_CUSTOM" ), occGroup,
3145 LightApp_Preferences::Auto, "OCCViewer", "viewcube_custom" );
3146 pref->setItemProperty( "columns", 2, occViewCubeAttrsGroup );
3147 // .... -> box color
3148 pref->addPreference( tr( "PREF_VIEWCUBE_COLOR" ), occViewCubeAttrsGroup,
3149 LightApp_Preferences::Color, "OCCViewer", "viewcube_color" );
3150 // .... -> view cube size
3151 int viewcube_size = pref->addPreference( tr( "PREF_VIEWCUBE_SIZE" ), occViewCubeAttrsGroup,
3152 LightApp_Preferences::DblSpin, "OCCViewer", "viewcube_size" );
3153 pref->setItemProperty( "min", 30.0, viewcube_size );
3154 pref->setItemProperty( "max", 100.0, viewcube_size );
3155 pref->setItemProperty( "step", 10.0, viewcube_size );
3156 // .... -> text color
3157 pref->addPreference( tr( "PREF_VIEWCUBE_TEXTCOLOR" ), occViewCubeAttrsGroup,
3158 LightApp_Preferences::Color, "OCCViewer", "viewcube_text_color" );
3159 // ... "View cube" group <<end>>
3161 // ... -> empty frame (for layout) <<start>>
3162 int occGen = pref->addPreference( "", occGroup, LightApp_Preferences::Frame );
3163 pref->setItemProperty( "margin", 0, occGen );
3164 pref->setItemProperty( "columns", 2, occGen );
3165 // ... -> empty frame (for layout) <<end>>
3167 // .. "OCC viewer" group <<end>>
3170 #ifndef DISABLE_VTKVIEWER
3171 // .. "VTK viewer" group <<start>>
3172 int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), salomeCat ); //viewTab
3174 // ... -> empty frame (for layout) <<start>>
3175 int vtkGen = pref->addPreference( "", vtkGroup, LightApp_Preferences::Frame );
3176 //pref->setItemProperty( "columns", 2, vtkGen );
3177 // .... -> projection mode
3178 int vtkProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), vtkGen,
3179 LightApp_Preferences::Selector, "VTKViewer", "projection_mode" );
3180 aValuesList.clear();
3181 anIndicesList.clear();
3182 aValuesList << tr("PREF_ORTHOGRAPHIC") << tr("PREF_PERSPECTIVE");
3183 anIndicesList << 0 << 1;
3184 pref->setItemProperty( "strings", aValuesList, vtkProjMode );
3185 pref->setItemProperty( "indexes", anIndicesList, vtkProjMode );
3187 // .... -> Stereo group
3188 int vtkStereoGroup = pref->addPreference( tr( "PREF_GROUP_STEREO" ), vtkGroup);
3189 pref->setItemProperty( "columns", 2, vtkStereoGroup );
3190 // .... -> Stereo type
3191 int vtkStereoType = pref->addPreference( tr( "PREF_STEREO_TYPE" ), vtkStereoGroup,
3192 LightApp_Preferences::Selector, "VTKViewer", "stereo_type" );
3193 aValuesList.clear();
3194 anIndicesList.clear();
3196 SVTK_Viewer::stereoData( aValuesList, idList);
3197 foreach( int gid, idList ) anIndicesList << gid;
3198 pref->setItemProperty( "strings", aValuesList, vtkStereoType );
3199 pref->setItemProperty( "indexes", anIndicesList, vtkStereoType );
3200 // .... -> Anaglyph filter
3201 int vtkAnaglyphFilter = pref->addPreference( tr( "PREF_ANAGLYPH_FILTER" ), vtkStereoGroup,
3202 LightApp_Preferences::Selector, "VTKViewer", "anaglyph_filter" );
3203 aValuesList.clear();
3204 anIndicesList.clear();
3205 aValuesList << tr("PREF_ANAGLYPH_RED_CYAN") << tr("PREF_ANAGLYPH_YELLOW_BLUE") << tr("PREF_ANAGLYPH_GREEN_MAGENTA");
3206 anIndicesList << 0 << 1 << 2;
3208 pref->setItemProperty( "strings", aValuesList, vtkAnaglyphFilter );
3209 pref->setItemProperty( "indexes", anIndicesList, vtkAnaglyphFilter );
3211 // .... -> Enable quad-buffer support
3212 pref->addPreference( tr( "PREF_ENABLE_QUAD_BUFFER_SUPPORT" ), vtkStereoGroup,
3213 LightApp_Preferences::Bool, "VTKViewer", "enable_quad_buffer_support" );
3215 // .... -> background
3216 aValuesList.clear();
3217 anIndicesList.clear();
3220 #ifndef DISABLE_SALOMEOBJECT
3221 formats = SVTK_Viewer::backgroundData( aValuesList, idList, txtList );
3223 foreach( int gid, idList ) anIndicesList << gid;
3224 bgId = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGen,
3225 LightApp_Preferences::Background, "VTKViewer", "background" );
3226 pref->setItemProperty( "gradient_names", aValuesList, bgId );
3227 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
3228 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
3229 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
3230 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
3231 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
3232 pref->setItemProperty( "custom_enabled", false, bgId );
3233 #ifndef DISABLE_SALOMEOBJECT
3234 pref->setItemProperty( "image_formats", formats, bgId );
3236 // .... -> speed increment
3237 int vtkSpeed = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED" ), vtkGen,
3238 LightApp_Preferences::IntSpin, "VTKViewer", "speed_value" );
3239 pref->setItemProperty( "min", 1, vtkSpeed );
3240 pref->setItemProperty( "max", 1000, vtkSpeed );
3241 // .... -> speed mode
3242 int vtkSpeedMode = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED_MODE" ), vtkGen,
3243 LightApp_Preferences::Selector, "VTKViewer", "speed_mode" );
3244 aValuesList.clear();
3245 anIndicesList.clear();
3246 aValuesList << tr("PREF_ARITHMETIC") << tr("PREF_GEOMETRICAL");
3247 anIndicesList << 0 << 1;
3248 pref->setItemProperty( "strings", aValuesList, vtkSpeedMode );
3249 pref->setItemProperty( "indexes", anIndicesList, vtkSpeedMode );
3251 // ... "Selection" group <<start>>
3252 int vtkSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), vtkGroup );
3253 pref->setItemProperty( "columns", 2, vtkSelectionGroup );
3254 // .... -> preselection
3255 int vtkPreselection = pref->addPreference( tr( "PREF_PRESELECTION" ), vtkSelectionGroup,
3256 LightApp_Preferences::Selector, "VTKViewer", "preselection" );
3257 aValuesList.clear();
3258 anIndicesList.clear();
3259 aValuesList << tr("PREF_PRESELECTION_STANDARD") << tr("PREF_PRESELECTION_DYNAMIC") << tr("PREF_PRESELECTION_DISABLED");
3260 anIndicesList << 0 << 1 << 2;
3261 pref->setItemProperty( "strings", aValuesList, vtkPreselection );
3262 pref->setItemProperty( "indexes", anIndicesList, vtkPreselection );
3263 // .... -> enable selection
3264 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), vtkSelectionGroup, LightApp_Preferences::Bool, "VTKViewer", "enable_selection" );
3265 // ... "Selection" group <<end>>
3267 // ... -> empty frame (for layout) <<end>>
3269 // ... space mouse sub-group <<start>>
3270 int vtkSM = pref->addPreference( tr( "PREF_FRAME_SPACEMOUSE" ), vtkGroup, LightApp_Preferences::GroupBox );
3271 //pref->setItemProperty( "columns", 2, vtkSM );
3272 // .... -> decrease speed increment
3273 int spacemousePref1 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_1" ), vtkSM,
3274 LightApp_Preferences::Selector, "VTKViewer",
3275 "spacemouse_func1_btn" );
3276 // .... -> increase speed increment
3277 int spacemousePref2 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_2" ), vtkSM,
3278 LightApp_Preferences::Selector, "VTKViewer",
3279 "spacemouse_func2_btn" );
3280 // .... -> dominant / combined switch
3281 int spacemousePref3 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_3" ), vtkSM,
3282 LightApp_Preferences::Selector, "VTKViewer",
3283 "spacemouse_func5_btn" ); //
3284 aValuesList.clear();
3285 anIndicesList.clear();
3286 aValuesList << tr( "PREF_SPACEMOUSE_BTN_1" ) << tr( "PREF_SPACEMOUSE_BTN_2" ) << tr( "PREF_SPACEMOUSE_BTN_3" );
3287 aValuesList << tr( "PREF_SPACEMOUSE_BTN_4" ) << tr( "PREF_SPACEMOUSE_BTN_5" ) << tr( "PREF_SPACEMOUSE_BTN_6" );
3288 aValuesList << tr( "PREF_SPACEMOUSE_BTN_7" ) << tr( "PREF_SPACEMOUSE_BTN_8" ) << tr( "PREF_SPACEMOUSE_BTN_*" );
3289 aValuesList << tr( "PREF_SPACEMOUSE_BTN_10" ) << tr( "PREF_SPACEMOUSE_BTN_11" );
3290 anIndicesList << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11;
3291 pref->setItemProperty( "strings", aValuesList, spacemousePref1 );
3292 pref->setItemProperty( "indexes", anIndicesList, spacemousePref1 );
3293 pref->setItemProperty( "strings", aValuesList, spacemousePref2 );
3294 pref->setItemProperty( "indexes", anIndicesList, spacemousePref2 );
3295 pref->setItemProperty( "strings", aValuesList, spacemousePref3 );
3296 pref->setItemProperty( "indexes", anIndicesList, spacemousePref3 );
3297 // ... space mouse sub-group <<end>>
3299 // ... avi recording sub-group <<start>>
3300 int vtkRec = pref->addPreference( tr( "PREF_FRAME_RECORDING" ), vtkGroup, LightApp_Preferences::GroupBox );
3301 pref->setItemProperty( "columns", 2, vtkRec );
3302 // .... -> recording mode
3303 int modePref = pref->addPreference( tr( "PREF_RECORDING_MODE" ), vtkRec,
3304 LightApp_Preferences::Selector, "VTKViewer", "recorder_mode" );
3305 aValuesList.clear();
3306 anIndicesList.clear();
3307 aValuesList << tr( "PREF_SKIPPED_FRAMES" ) << tr( "PREF_ALL_DISLPAYED_FRAMES" );
3308 anIndicesList << 0 << 1;
3309 pref->setItemProperty( "strings", aValuesList, modePref );
3310 pref->setItemProperty( "indexes", anIndicesList, modePref );
3312 int fpsPref = pref->addPreference( tr( "PREF_FPS" ), vtkRec,
3313 LightApp_Preferences::DblSpin, "VTKViewer", "recorder_fps" );
3314 pref->setItemProperty( "min", 0.1, fpsPref );
3315 pref->setItemProperty( "max", 100, fpsPref );
3317 int qualityPref = pref->addPreference( tr( "PREF_QUALITY" ), vtkRec,
3318 LightApp_Preferences::IntSpin, "VTKViewer", "recorder_quality" );
3319 pref->setItemProperty( "min", 1, qualityPref );
3320 pref->setItemProperty( "max", 100, qualityPref );
3321 // .... -> progressive mode
3322 pref->addPreference( tr( "PREF_PROGRESSIVE" ), vtkRec,
3323 LightApp_Preferences::Bool, "VTKViewer", "recorder_progressive" );
3324 // ... avi recording sub-group <<end>>
3326 // ... group names sub-group <<start>>
3327 int vtkGN = pref->addPreference( tr( "PREF_FRAME_GROUP_NAMES" ), vtkGroup,
3328 LightApp_Preferences::GroupBox, "VTKViewer", "show_group_names" );
3329 pref->setItemProperty( "columns", 2, vtkGN );
3330 // .... -> text color
3331 pref->addPreference( tr( "PREF_GROUP_NAMES_TEXT_COLOR" ), vtkGN,
3332 LightApp_Preferences::Color, "VTKViewer", "group_names_text_color" );
3333 // .... -> transparency
3334 int transPref = pref->addPreference( tr( "PREF_GROUP_NAMES_TRANSPARENCY" ), vtkGN,
3335 LightApp_Preferences::DblSpin, "VTKViewer", "group_names_transparency" );
3336 pref->setItemProperty( "min", 0.0, transPref );
3337 pref->setItemProperty( "max", 1.0, transPref );
3338 pref->setItemProperty( "step", 0.1, transPref );
3339 // ... -> group names sub-group <<end>>
3340 // .. "VTK viewer" group <<end>>
3343 // .. "Plot2d viewer" group <<start>>
3344 int plot2dGroup = pref->addPreference( tr( "PREF_GROUP_PLOT2DVIEWER" ), salomeCat ); //viewTab
3345 //pref->setItemProperty( "columns", 2, plot2dGroup );
3347 // ... -> background
3348 pref->addPreference( tr( "PREF_VIEWER_BACKGROUND_COLOR" ), plot2dGroup,
3349 LightApp_Preferences::Color, "Plot2d", "Background" );
3350 // ... -> selection color
3351 pref->addPreference( tr( "PREF_VIEWER_SELECTION" ), plot2dGroup,
3352 LightApp_Preferences::Color, "Plot2d", "SelectionColor" );
3354 // ... "Viewer" group <<start>>
3355 int plot2dViewerGroup = pref->addPreference( tr( "PREF_GROUP_VIEWER" ), plot2dGroup );
3357 // .... -> curve type
3358 int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dViewerGroup,
3359 LightApp_Preferences::Selector, "Plot2d", "CurveType" );
3360 aValuesList.clear();
3361 anIndicesList.clear();
3362 aValuesList << tr("PREF_POINTS") << tr("PREF_LINES") << tr("PREF_SPLINE");
3363 anIndicesList << 0 << 1 << 2 ;
3364 pref->setItemProperty( "strings", aValuesList, curveType );
3365 pref->setItemProperty( "indexes", anIndicesList, curveType );
3366 // .... -> marker size
3367 int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dViewerGroup,
3368 LightApp_Preferences::IntSpin, "Plot2d", "MarkerSize" );
3369 pref->setItemProperty( "min", 0, markerSize );
3370 pref->setItemProperty( "max", 100, markerSize );
3371 // .... -> horizontal scaling mode
3372 int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dViewerGroup,
3373 LightApp_Preferences::Selector, "Plot2d", "HorScaleMode" );
3374 aValuesList.clear();
3375 anIndicesList.clear();
3376 aValuesList << tr("PREF_LINEAR") << tr("PREF_LOGARITHMIC");
3377 anIndicesList << 0 << 1 ;
3378 pref->setItemProperty( "strings", aValuesList, horScale );
3379 pref->setItemProperty( "indexes", anIndicesList, horScale );
3380 // .... -> vertical scaling mode
3381 int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dViewerGroup,
3382 LightApp_Preferences::Selector, "Plot2d", "VerScaleMode" );
3383 pref->setItemProperty( "strings", aValuesList, verScale );
3384 pref->setItemProperty( "indexes", anIndicesList, verScale );
3386 // .... -> errors/deviation colot
3387 pref->addPreference( tr( "PREF_DEVIATION_COLOR" ), plot2dViewerGroup,
3388 LightApp_Preferences::Color, "Plot2d", "DeviationMarkerColor" );
3389 // .... -> deviation markers line size
3390 int deviationMarkerLw = pref->addPreference( tr( "PREF_DEVIATION_MARKER_LW" ), plot2dViewerGroup,
3391 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerLineWidth" );
3392 pref->setItemProperty( "min", 1, deviationMarkerLw );
3393 pref->setItemProperty( "max", 5, deviationMarkerLw );
3394 // .... -> deviation markers tick mark size
3395 int deviationMarkerTs = pref->addPreference( tr( "PREF_DEVIATION_MARKER_TS" ), plot2dViewerGroup,
3396 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerTickSize" );
3397 pref->setItemProperty( "min", 1, deviationMarkerTs );
3398 pref->setItemProperty( "max", 5, deviationMarkerTs );
3399 // .... "Viewer" group <<end>>
3401 // ... "Legend" group <<start>>
3402 int plot2dLegendGroup = pref->addPreference( tr( "PREF_GROUP_LEGEND" ), plot2dGroup );
3404 // .... -> show legend
3405 pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dLegendGroup,
3406 LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
3407 // .... -> legend position
3408 int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dLegendGroup,
3409 LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
3410 aValuesList.clear();
3411 anIndicesList.clear();
3412 aValuesList << tr("PREF_LEFT") << tr("PREF_RIGHT") << tr("PREF_TOP") << tr("PREF_BOTTOM");
3413 anIndicesList << 0 << 1 << 2 << 3 ;
3414 pref->setItemProperty( "strings", aValuesList, legendPosition );
3415 pref->setItemProperty( "indexes", anIndicesList, legendPosition );
3416 // .... -> Symbol type
3417 int legendSymbolType = pref->addPreference( tr( "PREF_LEGEND_SYMBOL_TYPE" ), plot2dLegendGroup,
3418 LightApp_Preferences::Selector, "Plot2d", "LegendSymbolType" );
3419 aValuesList.clear();
3420 anIndicesList.clear();
3421 aValuesList << tr("PREF_MARKER_ON_LINE") << tr("PREF_MARKER_ABOVE_LINE");
3422 anIndicesList << 0 << 1 ;
3423 pref->setItemProperty( "strings", aValuesList, legendSymbolType );
3424 pref->setItemProperty( "indexes", anIndicesList, legendSymbolType );
3425 // .... -> legend font
3426 pref->addPreference( tr( "PREF_LEGEND_FONT" ), plot2dLegendGroup, LightApp_Preferences::Font, "Plot2d", "LegendFont" );
3427 // ... -> font color
3428 pref->addPreference( tr( "PREF_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "LegendFontColor" );
3429 // ... -> selection font color
3430 pref->addPreference( tr( "PREF_SELECTED_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "SelectedLegendFontColor" );
3431 // ... "Legend" group <<end>>
3433 // .. "Plot2d viewer" group <<end>>
3435 // .. "PyViewer" preferences tab <<start>>
3436 int pyeditTab = pref->addPreference( tr( "PREF_TAB_PYEDITOR" ), salomeCat );
3437 // ... "Font settings" group <<start>>
3438 int pyFontGroup = pref->addPreference( tr( "PREF_GROUP_PY_FONT" ), pyeditTab );
3439 int pyFont = pref->addPreference( tr( "PREF_PY_FONT" ), pyFontGroup,
3440 LightApp_Preferences::Font, "PyEditor", "Font" );
3441 pref->setItemProperty( "features", QtxFontEdit::Family | QtxFontEdit::Size | QtxFontEdit::UserSize, pyFont );
3442 // ... "Font settings" group <<end>>
3443 // ... "Display settings" group <<start>>
3444 int pyDispGroup = pref->addPreference( tr( "PREF_GROUP_PY_DISPLAY" ), pyeditTab );
3445 pref->setItemProperty( "columns", 2, pyDispGroup );
3446 // ... -> current line highlight
3447 pref->addPreference( tr( "PREF_PY_CURRLINE_HIGHLIGHT" ), pyDispGroup,
3448 LightApp_Preferences::Bool, "PyEditor", "HighlightCurrentLine" );
3449 // ... -> text wrapping
3450 pref->addPreference( tr( "PREF_PY_TEXT_WRAP" ), pyDispGroup,
3451 LightApp_Preferences::Bool, "PyEditor", "TextWrapping" );
3452 // ... -> center cursor on scroll
3453 pref->addPreference( tr( "PREF_PY_CURSON_ON_SCROLL" ), pyDispGroup,
3454 LightApp_Preferences::Bool, "PyEditor", "CenterCursorOnScroll" );
3455 // ... -> line numbers area
3456 pref->addPreference( tr( "PREF_PY_LINE_NUMBS_AREA" ), pyDispGroup,
3457 LightApp_Preferences::Bool, "PyEditor", "LineNumberArea" );
3458 // ... "Display settings" group <<end>>
3460 // ... "Editor settings" group <<start>>
3461 int pyEditGroup = pref->addPreference( tr( "PREF_GROUP_PY_EDITOR" ), pyeditTab );
3462 // ... -> navigation mode
3463 int pyCompletion = pref->addPreference( tr( "PREF_PY_COMPLETION_MODE" ), pyEditGroup,
3464 LightApp_Preferences::Selector, "PyEditor", "CompletionPolicy" );
3465 aValuesList.clear();
3466 anIndicesList.clear();
3467 aValuesList << tr("PREF_PY_NONE") << tr("PREF_PY_AUTO") << tr("PREF_PY_MANUAL") << tr("PREF_PY_ALWAYS");
3468 anIndicesList << 0 << 1 << 2 << 3 ;
3469 pref->setItemProperty( "strings", aValuesList, pyCompletion );
3470 pref->setItemProperty( "indexes", anIndicesList, pyCompletion );
3471 // ... "Editor settings" group <<end>>
3473 // ... "Tab settings" group <<start>>
3474 int pyTabGroup = pref->addPreference( tr( "PREF_GROUP_PY_TAB" ), pyeditTab );
3475 pref->setItemProperty( "columns", 2, pyTabGroup );
3476 // ... -> tab whitespaces
3477 pref->addPreference( tr( "PREF_PY_TAB_WHITESPACES" ), pyTabGroup,
3478 LightApp_Preferences::Bool, "PyEditor", "TabSpaceVisible" );
3480 pref->addPreference( tr( "PREF_PY_TAB_SIZE" ), pyTabGroup,
3481 LightApp_Preferences::IntSpin, "PyEditor", "TabSize" );
3482 // ... "Tab settings" group <<end>>
3483 // ... "Vertical edge settings" group <<start>>
3484 int pyVertEdgeGroup = pref->addPreference( tr( "PREF_GROUP_VERT_EDGE" ), pyeditTab );
3485 pref->setItemProperty( "columns", 2, pyVertEdgeGroup );
3486 // ... -> vertical edge
3487 pref->addPreference( tr( "PREF_PY_VERT_EDGE" ), pyVertEdgeGroup,
3488 LightApp_Preferences::Bool, "PyEditor", "VerticalEdge" );
3489 // ... -> number of columns
3490 pref->addPreference( tr( "PREF_PY_NUM_COLUMNS" ), pyVertEdgeGroup,
3491 LightApp_Preferences::IntSpin, "PyEditor", "NumberColumns" );
3492 // ... "Vertical edge settings" group <<end>>
3493 // .. "PyEditor" preferences tab <<end>>
3495 // .. "Directories" preferences tab <<start>>
3496 int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat );
3497 // ... --> quick directories list
3498 int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab );
3499 pref->addPreference( tr( "" ), dirGroup,
3500 LightApp_Preferences::DirList, "FileDlg", "QuickDirList" );
3501 // .. "Directories" preferences tab <<end>>
3503 // .. "Object browser" preferences tab <<start>>
3504 int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
3506 // ... "Search tool" group <<start>>
3507 int stGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SEARCH_TOOL" ), obTab );
3508 // .... --> auto-hide
3509 pref->addPreference( tr( "PREF_AUTO_HIDE_SEARCH_TOOL" ), stGroup, LightApp_Preferences::Bool,
3510 "ObjectBrowser", "auto_hide_search_tool" );
3511 // ... "Search tool" group <<end>>
3513 // ... "Object browser settings" group <<start>>
3514 int objSetGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), obTab );
3515 pref->setItemProperty( "columns", 2, objSetGroup );
3516 // .... -> auto size first column
3517 pref->addPreference( tr( "PREF_AUTO_SIZE_FIRST" ), objSetGroup, LightApp_Preferences::Bool,
3518 "ObjectBrowser", "auto_size_first" );
3519 // .... -> auto size other columns
3520 pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool,
3521 "ObjectBrowser", "auto_size" );
3522 // .... -> resize columns on expand item
3523 pref->addPreference( tr( "PREF_RESIZE_ON_EXPAND_ITEM" ), objSetGroup, LightApp_Preferences::Bool,
3524 "ObjectBrowser", "resize_on_expand_item" );
3525 // .... -> browse to published object
3526 int browsePublished = pref->addPreference( tr( "PREF_BROWSE_TO_THE_PUBLISHED_OBJECT" ), objSetGroup, LightApp_Preferences::Selector,
3527 "ObjectBrowser", "browse_published_object" );
3528 aValuesList.clear();
3529 anIndicesList.clear();
3530 aValuesList << tr( "PREF_BROWSE_NEVER" ) << tr( "PREF_BROWSE_AFTER_APPLY_AND_CLOSE_ONLY" ) << tr( "PREF_BROWSE_ALWAYS" );
3531 anIndicesList << BP_Never << BP_ApplyAndClose << BP_Always;
3532 pref->setItemProperty( "strings", aValuesList, browsePublished );
3533 pref->setItemProperty( "indexes", anIndicesList, browsePublished );
3534 // ... "Object browser settings" group <<end>>
3535 // .. "Object browser" preferences tab <<end>>
3537 // .. "Shortcuts" preferences tab <<start>>
3538 int shortcutTab = pref->addPreference( tr( "PREF_TAB_SHORTCUTS" ), salomeCat );
3539 // ... "Shortcuts settings" group <<start>>
3540 int shortcutGroup = pref->addPreference( tr( "PREF_GROUP_SHORTCUTS" ), shortcutTab );
3541 pref->addPreference( tr( "" ), shortcutGroup,
3542 LightApp_Preferences::ShortcutTree, "shortcuts" );
3543 // ... "Shortcuts settings" group <<end>>
3544 // .. "Shortcuts" preferences tab <<end>>
3545 // . Top-level "SALOME" preferences group <<end>>
3551 Changes appearance of application according to changed preferences
3552 \param sec - section
3553 \param param - name of changed parameter
3555 void LightApp_Application::preferencesChanged( const QString& sec, const QString& param )
3557 SUIT_ResourceMgr* resMgr = resourceMgr();
3561 if ( sec == "viewers" && param == "drop_down_buttons" )
3563 ViewManagerList vmlist = viewManagers();
3564 foreach( SUIT_ViewManager* vm, vmlist )
3566 QVector<SUIT_ViewWindow*> vwlist = vm->getViews();
3567 foreach( SUIT_ViewWindow* vw, vwlist )
3568 if ( vw ) vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
3572 if ( sec == QString( "3DViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )))
3574 double sz = resMgr->doubleValue( sec, "trihedron_size", -1 );
3575 bool relative = resMgr->booleanValue( sec, "relative_size", true );
3576 QList<SUIT_ViewManager*> lst;
3577 #ifndef DISABLE_OCCVIEWER
3578 viewManagers( OCCViewer_Viewer::Type(), lst );
3579 QListIterator<SUIT_ViewManager*> itOCC( lst );
3580 while ( itOCC.hasNext() && sz >= 0 )
3582 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3583 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3586 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3587 occVM->setTrihedronSize( sz, relative );
3588 occVM->getAISContext()->UpdateCurrentViewer();
3591 #ifndef DISABLE_VTKVIEWER
3592 #ifndef DISABLE_SALOMEOBJECT
3593 viewManagers( SVTK_Viewer::Type(), lst );
3594 QListIterator<SUIT_ViewManager*> itVTK( lst );
3595 while ( itVTK.hasNext() && sz >= 0 )
3597 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3598 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3601 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3604 vtkVM->setTrihedronSize( sz, relative );
3612 if ( sec == QString( "3DViewer" ) && param == QString( "show_static_trihedron" ) )
3614 bool isVisible = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
3615 QList<SUIT_ViewManager*> lst;
3616 #ifndef DISABLE_OCCVIEWER
3617 viewManagers( OCCViewer_Viewer::Type(), lst );
3618 QListIterator<SUIT_ViewManager*> itOCC( lst );
3619 while ( itOCC.hasNext() )
3621 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3622 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3625 OCCViewer_Viewer* occVM = dynamic_cast<OCCViewer_Viewer*>( vm );
3628 occVM->setStaticTrihedronDisplayed( isVisible );
3632 #ifndef DISABLE_VTKVIEWER
3633 #ifndef DISABLE_SALOMEOBJECT
3634 viewManagers( SVTK_Viewer::Type(), lst );
3635 QListIterator<SUIT_ViewManager*> itVTK( lst );
3636 while ( itVTK.hasNext() )
3638 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3639 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3642 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3645 vtkVM->setStaticTrihedronVisible( isVisible );
3653 if ( sec == QString( "3DViewer" ) && param == QString( "navigation_mode" ) )
3655 int mode = resMgr->integerValue( "3DViewer", "navigation_mode", 0 );
3656 QList<SUIT_ViewManager*> lst;
3657 #ifndef DISABLE_OCCVIEWER
3658 viewManagers( OCCViewer_Viewer::Type(), lst );
3659 QListIterator<SUIT_ViewManager*> itOCC( lst );
3660 while ( itOCC.hasNext() )
3662 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3663 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3666 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3667 occVM->setInteractionStyle( mode );
3670 #ifndef DISABLE_VTKVIEWER
3671 #ifndef DISABLE_SALOMEOBJECT
3672 viewManagers( SVTK_Viewer::Type(), lst );
3673 QListIterator<SUIT_ViewManager*> itVTK( lst );
3674 while ( itVTK.hasNext() )
3676 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3677 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3680 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3681 if( vtkVM ) vtkVM->setInteractionStyle( mode );
3687 #ifndef DISABLE_OCCVIEWER
3688 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_preselection" ) )
3690 bool isToEnablePreselection = resMgr->booleanValue( "OCCViewer", "enable_preselection", true );
3691 QList<SUIT_ViewManager*> lst;
3692 viewManagers( OCCViewer_Viewer::Type(), lst );
3693 QListIterator<SUIT_ViewManager*> it( lst );
3694 while ( it.hasNext() )
3696 SUIT_ViewModel* vm = it.next()->getViewModel();
3697 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3700 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3701 occVM->enablePreselection( isToEnablePreselection );
3706 #ifndef DISABLE_OCCVIEWER
3707 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_selection" ) )
3709 bool isToEnableSelection = resMgr->booleanValue( "OCCViewer", "enable_selection", true );
3710 QList<SUIT_ViewManager*> lst;
3711 viewManagers( OCCViewer_Viewer::Type(), lst );
3712 QListIterator<SUIT_ViewManager*> it( lst );
3713 while ( it.hasNext() )
3715 SUIT_ViewModel* vm = it.next()->getViewModel();
3716 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3719 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3720 occVM->enableSelection( isToEnableSelection );
3725 #ifndef DISABLE_OCCVIEWER
3726 if ( sec == QString( "OCCViewer" ) && param == QString( "clipping_color" ) )
3728 QColor aColor = resMgr->colorValue( "OCCViewer", "clipping_color", QColor( 50, 50, 50 ) );
3729 QList<SUIT_ViewManager*> lst;
3730 viewManagers( OCCViewer_Viewer::Type(), lst );
3731 QListIterator<SUIT_ViewManager*> it( lst );
3732 while ( it.hasNext() )
3734 SUIT_ViewModel* vm = it.next()->getViewModel();
3735 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3738 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3739 occVM->setClippingColor( aColor );
3744 #ifndef DISABLE_OCCVIEWER
3745 if ( sec == QString( "OCCViewer" ) && ( param == QString( "clipping_use_default_texture" ) ||
3746 param == QString( "clipping_texture" ) ||
3747 param == QString( "clipping_modulate" ) ||
3748 param == QString( "clipping_scale" ) ) )
3750 bool isDefaultTextureUsed = resMgr->booleanValue( "OCCViewer", "clipping_use_default_texture" );
3751 QString aTexture = resMgr->stringValue( "OCCViewer", "clipping_texture" );
3752 bool isModulated = resMgr->booleanValue( "OCCViewer", "clipping_modulate" );
3753 double aScale = resMgr->doubleValue( "OCCViewer", "clipping_scale" );
3754 QList<SUIT_ViewManager*> lst;
3755 viewManagers( OCCViewer_Viewer::Type(), lst );
3756 QListIterator<SUIT_ViewManager*> it( lst );
3757 while ( it.hasNext() )
3759 SUIT_ViewModel* vm = it.next()->getViewModel();
3760 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3763 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3764 occVM->setClippingTextureParams( isDefaultTextureUsed, aTexture, isModulated, aScale );
3769 #ifndef DISABLE_OCCVIEWER
3770 if ( sec == QString( "OCCViewer" ) && param == QString( "projection_mode" ) )
3772 int mode = resMgr->integerValue( "OCCViewer", "projection_mode", 0 );
3773 QList<SUIT_ViewManager*> lst;
3774 viewManagers( OCCViewer_Viewer::Type(), lst );
3775 QListIterator<SUIT_ViewManager*> it( lst );
3776 while ( it.hasNext() )
3778 SUIT_ViewModel* vm = it.next()->getViewModel();
3779 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3782 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3783 occVM->setProjectionType( mode );
3789 #ifndef DISABLE_OCCVIEWER
3790 if (sec == QString("OCCViewer") && param == QString("adv_selection_mode"))
3792 int mode = resMgr->integerValue("OCCViewer", "adv_selection_mode", 0);
3793 QList<SUIT_ViewManager*> lst;
3794 viewManagers(OCCViewer_Viewer::Type(), lst);
3795 QListIterator<SUIT_ViewManager*> it(lst);
3796 while (it.hasNext())
3798 SUIT_ViewModel* vm = it.next()->getViewModel();
3799 if (!vm || !vm->inherits("OCCViewer_Viewer"))
3802 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3803 occVM->setSelectionStyle((OCCViewer_ViewWindow::SelectionStyle)mode);
3809 #ifndef DISABLE_OCCVIEWER
3810 if ( sec == QString( "OCCViewer" ) && param == QString( "stereo_type" ) )
3812 int mode = resMgr->integerValue( "OCCViewer", "stereo_type", 0 );
3813 QList<SUIT_ViewManager*> lst;
3814 viewManagers( OCCViewer_Viewer::Type(), lst );
3815 QListIterator<SUIT_ViewManager*> it( lst );
3816 while ( it.hasNext() )
3818 SUIT_ViewModel* vm = it.next()->getViewModel();
3819 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3822 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3823 occVM->setStereoType( mode );
3828 #ifndef DISABLE_OCCVIEWER
3829 if ( sec == QString( "OCCViewer" ) && param == QString( "anaglyph_filter" ) )
3831 int mode = resMgr->integerValue( "OCCViewer", "anaglyph_filter", 0 );
3832 QList<SUIT_ViewManager*> lst;
3833 viewManagers( OCCViewer_Viewer::Type(), lst );
3834 QListIterator<SUIT_ViewManager*> it( lst );
3835 while ( it.hasNext() )
3837 SUIT_ViewModel* vm = it.next()->getViewModel();
3838 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3841 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3842 occVM->setAnaglyphFilter( mode );
3847 #ifndef DISABLE_OCCVIEWER
3848 if ( sec == QString( "OCCViewer" ) && ( param == QString( "focus_type" ) ||
3849 param == QString( "focus_value" ) ) )
3851 int aType = resMgr->integerValue( "OCCViewer", "focus_type" );
3852 double aValue = resMgr->doubleValue( "OCCViewer", "focus_value" );
3853 QList<SUIT_ViewManager*> lst;
3854 viewManagers( OCCViewer_Viewer::Type(), lst );
3855 QListIterator<SUIT_ViewManager*> it( lst );
3856 while ( it.hasNext() )
3858 SUIT_ViewModel* vm = it.next()->getViewModel();
3859 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3862 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3863 occVM->setStereographicFocus( aType, aValue );
3868 #ifndef DISABLE_OCCVIEWER
3869 if ( sec == QString( "OCCViewer" ) && ( param == QString( "iod_type" ) ||
3870 param == QString( "iod_value" ) ) )
3872 int aType = resMgr->integerValue( "OCCViewer", "iod_type" );
3873 double aValue = resMgr->doubleValue( "OCCViewer", "iod_value" );
3874 QList<SUIT_ViewManager*> lst;
3875 viewManagers( OCCViewer_Viewer::Type(), lst );
3876 QListIterator<SUIT_ViewManager*> it( lst );
3877 while ( it.hasNext() )
3879 SUIT_ViewModel* vm = it.next()->getViewModel();
3880 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3883 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3884 occVM->setInterocularDistance( aType, aValue );
3889 #ifndef DISABLE_OCCVIEWER
3890 if ( sec == QString( "OCCViewer" ) && param == QString( "reverse_stereo" ) )
3892 bool reverse = resMgr->booleanValue( "OCCViewer", "reverse_stereo", false );
3893 QList<SUIT_ViewManager*> lst;
3894 viewManagers( OCCViewer_Viewer::Type(), lst );
3895 QListIterator<SUIT_ViewManager*> it( lst );
3896 while ( it.hasNext() )
3898 SUIT_ViewModel* vm = it.next()->getViewModel();
3899 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3902 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3903 occVM->setReverseStereo( reverse );
3908 #ifndef DISABLE_OCCVIEWER
3909 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_vsync" ) )
3911 bool enable = resMgr->booleanValue( "OCCViewer", "enable_vsync", true );
3912 QList<SUIT_ViewManager*> lst;
3913 viewManagers( OCCViewer_Viewer::Type(), lst );
3914 QListIterator<SUIT_ViewManager*> it( lst );
3915 while ( it.hasNext() )
3917 SUIT_ViewModel* vm = it.next()->getViewModel();
3918 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3921 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3922 occVM->setVSync( enable );
3927 #ifndef DISABLE_OCCVIEWER
3928 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_quad_buffer_support" ) )
3930 bool enable = resMgr->booleanValue( "OCCViewer", "enable_quad_buffer_support", false );
3931 QList<SUIT_ViewManager*> lst;
3932 viewManagers( OCCViewer_Viewer::Type(), lst );
3933 QListIterator<SUIT_ViewManager*> it( lst );
3934 while ( it.hasNext() )
3936 SUIT_ViewModel* vm = it.next()->getViewModel();
3937 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3940 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3941 occVM->setQuadBufferSupport( enable );
3946 #ifndef DISABLE_OCCVIEWER
3947 if ( sec == QString( "OCCViewer" ) && param.contains( "viewcube" ) )
3949 QList<SUIT_ViewManager*> lst;
3950 viewManagers( OCCViewer_Viewer::Type(), lst );
3951 QListIterator<SUIT_ViewManager*> it( lst );
3952 while ( it.hasNext() )
3954 SUIT_ViewModel* vm = it.next()->getViewModel();
3955 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3958 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3959 occVM->setViewCubeParamsFromPreferences();
3964 if ( sec == QString( "3DViewer" ) && param == QString( "zooming_mode" ) )
3966 int mode = resMgr->integerValue( "3DViewer", "zooming_mode", 0 );
3967 QList<SUIT_ViewManager*> lst;
3968 #ifndef DISABLE_OCCVIEWER
3969 viewManagers( OCCViewer_Viewer::Type(), lst );
3970 QListIterator<SUIT_ViewManager*> itOCC( lst );
3971 while ( itOCC.hasNext() )
3973 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3974 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3977 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3978 occVM->setZoomingStyle( mode );
3981 #ifndef DISABLE_VTKVIEWER
3982 #ifndef DISABLE_SALOMEOBJECT
3983 viewManagers( SVTK_Viewer::Type(), lst );
3984 QListIterator<SUIT_ViewManager*> itVTK( lst );
3985 while ( itVTK.hasNext() )
3987 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3988 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3991 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3992 if( vtkVM ) vtkVM->setZoomingStyle( mode );
3998 #ifndef DISABLE_VTKVIEWER
3999 if ( sec == QString( "VTKViewer" ) && (param == QString( "speed_value" ) || param == QString( "speed_mode" )) )
4001 int speed = resMgr->integerValue( "VTKViewer", "speed_value", 10 );
4002 int mode = resMgr->integerValue( "VTKViewer", "speed_mode", 0 );
4003 QList<SUIT_ViewManager*> lst;
4004 #ifndef DISABLE_SALOMEOBJECT
4005 viewManagers( SVTK_Viewer::Type(), lst );
4006 QListIterator<SUIT_ViewManager*> it( lst );
4007 while ( it.hasNext() )
4009 SUIT_ViewModel* vm = it.next()->getViewModel();
4010 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
4013 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
4014 if( vtkVM ) vtkVM->setIncrementalSpeed( speed, mode );
4020 #ifndef DISABLE_VTKVIEWER
4021 if ( sec == QString( "VTKViewer" ) && param == QString( "projection_mode" ) )
4023 int mode = resMgr->integerValue( "VTKViewer", "projection_mode", 0 );
4024 QList<SUIT_ViewManager*> lst;
4025 #ifndef DISABLE_SALOMEOBJECT
4026 viewManagers( SVTK_Viewer::Type(), lst );
4027 QListIterator<SUIT_ViewManager*> it( lst );
4028 while ( it.hasNext() )
4030 SUIT_ViewModel* vm = it.next()->getViewModel();
4031 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
4034 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
4035 if( vtkVM ) vtkVM->setProjectionMode( mode );
4041 #ifndef DISABLE_VTKVIEWER
4042 if ( sec == QString( "VTKViewer" ) && param == QString( "stereo_type" ) )
4044 int mode = resMgr->integerValue( "VTKViewer", "stereo_type", 0 );
4045 QList<SUIT_ViewManager*> lst;
4046 #ifndef DISABLE_SALOMEOBJECT
4047 viewManagers( SVTK_Viewer::Type(), lst );
4048 QListIterator<SUIT_ViewManager*> it( lst );
4049 while ( it.hasNext() )
4051 SUIT_ViewModel* vm = it.next()->getViewModel();
4052 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
4055 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
4056 if( vtkVM ) vtkVM->setStereoType( mode );
4062 #ifndef DISABLE_VTKVIEWER
4063 if ( sec == QString( "VTKViewer" ) && param == QString( "anaglyph_filter" ) )
4065 int mode = resMgr->integerValue( "VTKViewer", "anaglyph_filter", 0 );
4066 QList<SUIT_ViewManager*> lst;
4067 #ifndef DISABLE_SALOMEOBJECT
4068 viewManagers( SVTK_Viewer::Type(), lst );
4069 QListIterator<SUIT_ViewManager*> it( lst );
4070 while ( it.hasNext() )
4072 SUIT_ViewModel* vm = it.next()->getViewModel();
4073 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
4076 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
4077 if( vtkVM ) vtkVM->setAnaglyphFilter( mode );
4083 #ifndef DISABLE_VTKVIEWER
4084 if ( sec == QString( "VTKViewer" ) && param == QString( "enable_quad_buffer_support" ) )
4086 int enable = resMgr->booleanValue( "VTKViewer", "enable_quad_buffer_support", false );
4087 QList<SUIT_ViewManager*> lst;
4088 #ifndef DISABLE_SALOMEOBJECT
4089 viewManagers( SVTK_Viewer::Type(), lst );
4090 QListIterator<SUIT_ViewManager*> it( lst );
4091 while ( it.hasNext() )
4093 SUIT_ViewModel* vm = it.next()->getViewModel();
4094 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
4097 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
4098 if( vtkVM ) vtkVM->setQuadBufferSupport( enable );
4104 #ifndef DISABLE_VTKVIEWER
4105 if ( sec == QString( "VTKViewer" ) && param == QString( "preselection" ) )
4107 int mode = resMgr->integerValue( "VTKViewer", "preselection", 0 );
4108 QList<SUIT_ViewManager*> lst;
4109 #ifndef DISABLE_SALOMEOBJECT
4110 viewManagers( SVTK_Viewer::Type(), lst );
4111 QListIterator<SUIT_ViewManager*> it( lst );
4112 while ( it.hasNext() )
4114 SUIT_ViewModel* vm = it.next()->getViewModel();
4115 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
4118 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
4119 if( vtkVM ) vtkVM->setPreSelectionMode( mode );
4125 #ifndef DISABLE_VTKVIEWER
4126 if ( sec == QString( "VTKViewer" ) && param == QString( "enable_selection" ) )
4128 bool isToEnableSelection = resMgr->booleanValue( "VTKViewer", "enable_selection", true );
4129 QList<SUIT_ViewManager*> lst;
4130 #ifndef DISABLE_SALOMEOBJECT
4131 viewManagers( SVTK_Viewer::Type(), lst );
4132 QListIterator<SUIT_ViewManager*> it( lst );
4133 while ( it.hasNext() )
4135 SUIT_ViewModel* vm = it.next()->getViewModel();
4136 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
4139 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
4140 if( vtkVM ) vtkVM->enableSelection( isToEnableSelection );
4146 #ifndef DISABLE_VTKVIEWER
4147 if ( sec == QString( "VTKViewer" ) && (param == QString( "spacemouse_func1_btn" ) ||
4148 param == QString( "spacemouse_func2_btn" ) ||
4149 param == QString( "spacemouse_func5_btn" ) ) )
4151 int btn1 = resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", 1 );
4152 int btn2 = resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", 2 );
4153 int btn3 = resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", 9 );
4154 QList<SUIT_ViewManager*> lst;
4155 #ifndef DISABLE_SALOMEOBJECT
4156 viewManagers( SVTK_Viewer::Type(), lst );
4157 QListIterator<SUIT_ViewManager*> it( lst );
4158 while ( it.hasNext() )
4160 SUIT_ViewModel* vm = it.next()->getViewModel();
4161 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
4164 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
4165 if( vtkVM ) vtkVM->setSpacemouseButtons( btn1, btn2, btn3 );
4170 if( sec=="ObjectBrowser" )
4172 SUIT_DataBrowser* ob = objectBrowser();
4176 if ( param=="auto_size_first" )
4178 bool autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
4179 ob->setAutoSizeFirstColumn( autoSizeFirst );
4180 if ( autoSizeFirst )
4181 ob->adjustFirstColumnWidth();
4183 else if ( param=="auto_size" ) {
4184 bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
4185 ob->setAutoSizeColumns(autoSize);
4187 ob->adjustColumnsWidth();
4189 else if ( param=="resize_on_expand_item" ) {
4190 bool resizeOnExpandItem = resMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
4191 ob->setResizeOnExpandItem(resizeOnExpandItem);
4193 else if ( param == "auto_hide_search_tool" ) {
4194 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
4200 if( param=="auto_save_interval" ) {
4201 myAutoSaveTimer->stop();
4202 int autoSaveInterval = resMgr->integerValue( "Study", "auto_save_interval", 0 );
4203 if ( activeStudy() && autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
4207 #ifndef DISABLE_PYCONSOLE
4208 if( sec=="PyConsole" && pythonConsole() )
4210 if ( param=="font" ) {
4211 pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) );
4213 else if ( param=="show_banner" ) {
4214 pythonConsole()->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
4216 else if ( param=="auto_completion" ) {
4217 pythonConsole()->setAutoCompletion( resMgr->booleanValue( "PyConsole", "auto_completion", true ) );
4224 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
4226 if ( param == "visible_count" )
4227 mru->setVisibleCount( resMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
4228 else if ( param == "max_count" )
4229 mru->setHistoryCount( resMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
4230 else if ( param == "insert_mode" )
4231 mru->setInsertMode( resMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
4232 else if ( param == "link_type" )
4233 mru->setLinkType( resMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
4234 else if ( param == "show_clear" )
4235 mru->setClearPossible( resMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
4236 else if ( param == "show_mru" )
4237 mru->setVisible( resMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
4240 if ( sec == "language" && param == "language" )
4242 // VSR 18.06.2015 : commented out : single warning dialog box is now shown by the LightApp_PreferencesDlg
4243 //SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LANG_CHANGED" ) );
4245 if ( sec == "language" && param == "locale")
4247 // VSR 18.06.2015: commented out : single warning dialog box is now shown by the LightApp_PreferencesDlg
4248 //SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LOCALE_CHANGED" ) );
4250 if ( sec == "desktop" && param == "opaque_resize" ) {
4251 bool opaqueResize = resMgr->booleanValue( "desktop", "opaque_resize", false );
4252 // RNV: This code has been commented, because clearing of the QMainWindow::AnimatedDocks option
4253 // leads to strange behaviour of the dockable windows (at least at qt-5.6.1):
4254 // any dockable window can't be docked to the another area, except initial area.
4255 // It is possible to move window to another area, but it always returns to the initial area.
4257 // QMainWindow::DockOptions dopts = desktop()->dockOptions();
4258 // if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
4259 // else dopts &= ~QMainWindow::AnimatedDocks;
4260 // desktop()->setDockOptions( dopts );
4261 desktop()->setOpaqueResize( opaqueResize );
4262 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
4263 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
4266 #ifndef DISABLE_PLOT2DVIEWER
4267 QList<SUIT_ViewManager*> lst;
4268 viewManagers( Plot2d_Viewer::Type(), lst );
4269 QListIterator<SUIT_ViewManager*> itPlot2d( lst );
4270 while ( itPlot2d.hasNext() ) {
4271 SUIT_ViewManager* viewMgr = itPlot2d.next();
4272 SUIT_ViewModel* vm = viewMgr->getViewModel();
4273 if ( !vm || !vm->inherits( "Plot2d_Viewer" ) )
4276 //Plot2d_Viewer* Plot2dVM = dynamic_cast<Plot2d_Viewer*>( vm );
4278 viewMgr->setViewModel( vm );
4279 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
4281 Plot2d_ViewFrame* frame = wnd->getViewFrame();
4282 frame->SetPreference();
4291 void LightApp_Application::loadPreferences()
4293 CAM_Application::loadPreferences();
4295 SUIT_ResourceMgr* aResMgr = resourceMgr();
4300 static bool mru_load = true;
4303 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
4305 mru->setVisible( aResMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
4306 mru->setVisibleCount( aResMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
4307 mru->setHistoryCount( aResMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
4308 mru->setInsertMode( aResMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
4309 mru->setLinkType( aResMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
4310 mru->setClearPossible( aResMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
4311 mru->loadLinks( aResMgr, "MRU" );
4317 QStringList mods = aResMgr->parameters( "windows_visibility" );
4318 for ( QStringList::const_iterator itr = mods.begin(); itr != mods.end(); ++itr )
4321 if ( aResMgr->value( "windows_visibility", *itr, arr ) )
4322 myWinVis.insert( *itr, arr );
4326 desktop()->retrieveGeometry( aResMgr->stringValue( "desktop", "geometry" ) );
4327 bool opaqueResize = aResMgr->booleanValue( "desktop", "opaque_resize", false );
4328 // QMainWindow::DockOptions dopts = desktop()->dockOptions();
4329 // if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
4330 // else dopts &= ~QMainWindow::AnimatedDocks;
4331 // desktop()->setDockOptions( dopts );
4332 desktop()->setOpaqueResize( opaqueResize );
4333 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
4334 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
4341 void LightApp_Application::savePreferences()
4343 CAM_Application::savePreferences();
4345 saveDockWindowsState();
4347 SUIT_ResourceMgr* aResMgr = resourceMgr();
4352 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
4354 mru->saveLinks( aResMgr, "MRU" );
4356 for ( WinVis::const_iterator itr = myWinVis.begin(); itr != myWinVis.end(); ++itr )
4357 aResMgr->setValue( "windows_visibility", itr.key(), itr.value() );
4360 aResMgr->setValue( "desktop", "geometry", desktop()->storeGeometry() );
4362 #if GUI_DEVELOPMENT > 0
4363 aResMgr->setValue( "salome", "version", QString(GUI_VERSION_STR)+"dev" );
4365 aResMgr->setValue( "salome", "version", QString(GUI_VERSION_STR) );
4372 Updates desktop title
4374 void LightApp_Application::updateDesktopTitle()
4376 QString aTitle = applicationName();
4377 QString aVer = applicationVersion();
4378 if ( !aVer.isEmpty() )
4379 aTitle += QString( " " ) + aVer;
4381 if ( activeStudy() ) {
4382 QString sName = SUIT_Tools::file( activeStudy()->studyName().trimmed(), false );
4383 aTitle += QString( " - [%1]" ).arg( sName );
4386 desktop()->setWindowTitle( aTitle );
4390 \brief Get map of the operations which can be performed
4391 on the module activation.
4393 The method should return the map of the kind \c {<id>:<name>}
4394 where \c <id> is an integer identifier of the operation and
4395 \c <name> is a title for the button to be added to the
4396 dialog box. After user selects the required operation by the
4397 clicking the corresponding button in the dialog box, its identifier
4398 is passed to the moduleActionSelected() method to process
4401 \return map of the operations
4402 \sa moduleActionSelected()
4404 QMap<int, QString> LightApp_Application::activateModuleActions() const
4406 QMap<int, QString> opmap;
4407 opmap.insert( NewStudyId, tr( "ACTIVATE_MODULE_OP_NEW" ) );
4408 opmap.insert( OpenStudyId, tr( "ACTIVATE_MODULE_OP_OPEN" ) );
4413 \brief Called when the used selectes required operation chosen
4414 from "Activate module" dialog box.
4416 Performs the required operation according to the user choice.
4418 \param id operation identifier
4419 \sa activateModuleActions()
4421 void LightApp_Application::moduleActionSelected( const int id )
4436 Updates windows after close document
4438 void LightApp_Application::afterCloseDoc()
4442 CAM_Application::afterCloseDoc();
4446 Updates actions of active module
4448 void LightApp_Application::updateModuleActions()
4450 emit moduleActivated( activeModule() ? activeModule()->moduleName() : QString() );
4453 bool LightApp_Application::checkModule( const QString& title )
4455 if ( title.isEmpty() )
4458 QString library = moduleLibrary( title, true );
4459 if ( library.isEmpty() )
4462 QString name = moduleName( title );
4464 bool isPyModule = library.contains( "SalomePyQtGUI" ) || library.contains( "SalomePyQtGUILight" );
4468 paths = QString( Qtx::getenv( "PATH" ) ).split( ";", QString::SkipEmptyParts );
4469 #elif defined(__APPLE__)
4470 paths = QString( Qtx::getenv( "DYLD_LIBRARY_PATH" ) ).split( ":", QString::SkipEmptyParts );
4472 paths = QString( Qtx::getenv( "LD_LIBRARY_PATH" ) ).split( ":", QString::SkipEmptyParts );
4475 bool isFound = false;
4476 QStringList::const_iterator it;
4477 for ( it = paths.begin(); it != paths.end() && !isFound; ++it )
4479 isFound = QFileInfo( Qtx::addSlash( *it ) + library ).exists();
4485 "****************************************************************" << std::endl <<
4486 " Warning: library " << qPrintable( library ) << " is not found!" << std::endl <<
4487 " Module " << qPrintable( title ) << " will not be available in GUI mode!" << std::endl <<
4488 "****************************************************************" << std::endl);
4494 QString pyModule = QString( "%1GUI.py" ).arg( name );
4496 paths = QString( Qtx::getenv( "PYTHONPATH" ) ).split( ";", QString::SkipEmptyParts );
4498 paths = QString( Qtx::getenv( "PYTHONPATH" ) ).split( ":", QString::SkipEmptyParts );
4501 for ( it = paths.begin(); it != paths.end() && !isFound; ++it )
4503 isFound = QFileInfo( Qtx::addSlash( *it ) + pyModule ).exists();
4509 "****************************************************************" << std::endl <<
4510 " Warning: Python module " << qPrintable( pyModule ) << " is not found!" << std::endl <<
4511 " Module " << qPrintable( title ) << " will not be available in GUI mode!" << std::endl <<
4512 "****************************************************************" << std::endl);
4521 Gets current windows.
4522 \param winMap - output current windows map.
4524 void LightApp_Application::currentWindows( QMap<int, int>& winMap ) const
4527 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
4528 ((LightApp_Module*)activeModule())->windows( winMap );
4530 defaultWindows( winMap );
4534 Gets current view managers.
4535 \param lst - output current view managers list.
4537 void LightApp_Application::currentViewManagers( QStringList& lst ) const
4540 if ( !activeStudy() )
4543 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
4544 ((LightApp_Module*)activeModule())->viewManagers( lst );
4546 defaultViewManagers( lst );
4552 void LightApp_Application::updateWindows()
4554 QMap<int, int> winMap;
4555 currentWindows( winMap );
4557 for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
4559 if ( !dockWindow( it.key() ) )
4560 getWindow( it.key() );
4563 for ( WinMap::ConstIterator it = myWin.begin(); it != myWin.end(); ++it )
4565 QWidget* wid = it.value();
4568 if ( winMap.contains( it.key() ) )
4569 wid->setVisible( true );
4570 else if ( !activeStudy() )
4573 wid->setVisible( false );
4576 loadDockWindowsState();
4578 if ( !activeModule() && infoPanel() )
4580 infoPanel()->clear();
4581 infoPanel()->setTitle( tr( "INFO_WELCOME_TO_SALOME" ) );
4583 int grp = infoPanel()->addGroup( tr( "INFO_GETTING_STARTED" ) );
4584 infoPanel()->addAction( action( FileNewId ), grp );
4585 infoPanel()->addLabel( action( FileNewId )->statusTip(), grp );
4586 infoPanel()->addAction( action( FileOpenId ), grp );
4587 infoPanel()->addLabel( action( FileOpenId )->statusTip(), grp );
4588 if ( HAS_TUTORIAL_URL ) {
4589 infoPanel()->addAction( action( TutorialsId ), grp );
4590 infoPanel()->addLabel( action( TutorialsId )->statusTip(), grp );
4592 infoPanel()->addAction( action( VideosId ), grp );
4593 infoPanel()->addLabel( action( VideosId )->statusTip(), grp );
4595 LightApp_ModuleAction* ma = qobject_cast<LightApp_ModuleAction*>(action(ModulesListId));
4596 if ( ma && ma->count() > 0 )
4598 grp = infoPanel()->addGroup( tr( "INFO_AVAILABLE_MODULES" ) );
4599 foreach ( QString mname, ma->modules() )
4601 infoPanel()->addAction( ma->moduleAction( mname ), grp );
4602 if ( !moduleDescription( mname ).isEmpty() )
4603 infoPanel()->addLabel( moduleDescription( mname ), grp );
4610 Updates view managers
4612 void LightApp_Application::updateViewManagers()
4615 currentViewManagers( lst );
4617 for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
4618 getViewManager( *it, true );
4622 Loads windows geometry
4624 void LightApp_Application::loadDockWindowsState()
4628 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
4629 bool storeWin = aResMgr->booleanValue( "Study", "store_positions", true );
4630 bool storeTb = aResMgr->booleanValue( "Study", "store_tool_positions", true );
4633 if ( activeModule() )
4634 modName = activeModule()->name();
4635 else if ( activeStudy() )
4636 modName = "nomodule";
4638 QtxResourceMgr::WorkingMode prevMode = aResMgr->setWorkingMode( QtxResourceMgr::IgnoreUserValues );
4639 QByteArray aDefaultState;
4640 aResMgr->value( "windows_geometry", modName, aDefaultState );
4641 QByteArray aDefaultVisibility;
4642 aResMgr->value( "windows_visibility", modName, aDefaultVisibility );
4643 bool hasDefaultVisibility = !aDefaultVisibility.isEmpty();
4644 aResMgr->setWorkingMode( prevMode );
4646 if( !storeWin && !storeTb && aDefaultState.isEmpty() && !hasDefaultVisibility)
4649 if ( aResMgr->hasValue("windows_geometry" ,modName ) ) {
4650 long version = Qtx::versionToId( aResMgr->stringValue( "windows_geometry_version", modName, "" ) );
4652 if ( version > Qtx::versionToId( "7.4.1" ) )
4653 aResMgr->value( "windows_geometry", modName , arr );
4655 arr = aDefaultState;
4656 QByteArray aTargetArray = processState(arr, storeWin, storeTb, true, aDefaultState);
4657 desktop()->restoreState( aTargetArray );
4660 QStringList mainToolbarsNames;
4661 mainToolbarsNames << "SalomeStandard" << "SalomeModules";
4662 QList<QToolBar*> mainToolbars = findToolBars( mainToolbarsNames );
4663 foreach( QToolBar* tb, mainToolbars ) tb->setVisible( true );
4665 if ( !myWinVis.contains( modName ) && aDefaultVisibility.isEmpty())
4668 QMap<QString, bool> *tbMap = 0;
4669 QMap<QString, bool> *dwMap = 0;
4671 QMap<QString, bool> userTbMap, userDwMap;
4672 dockWindowsState( myWinVis[modName], userTbMap, userDwMap );
4674 QMap<QString, bool> defaultTbMap, defaultDwMap;
4675 if(hasDefaultVisibility) {
4676 dockWindowsState( aDefaultVisibility, defaultTbMap, defaultDwMap);
4682 if(hasDefaultVisibility){
4683 tbMap = &defaultTbMap;
4690 if(hasDefaultVisibility){
4691 dwMap = &defaultDwMap;
4696 QList<QToolBar*> tbList = findToolBars();
4697 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit )
4699 QToolBar* tb = *tit;
4700 if ( tbMap->contains( tb->objectName() ) ) {
4701 tb->setVisible( (*tbMap)[tb->objectName()] );
4707 QList<QDockWidget*> dwList = desktop()->findChildren<QDockWidget*>();
4708 for ( QList<QDockWidget*>::iterator dit = dwList.begin(); dit != dwList.end(); ++dit )
4710 QDockWidget* dw = *dit;
4712 QObject* po = Qtx::findParent( dw, "QMainWindow" );
4713 if ( po != desktop() )
4716 if ( dwMap->contains( dw->objectName() ) )
4717 dw->setVisible( (*dwMap)[dw->objectName()] );
4725 Saves windows geometry
4727 void LightApp_Application::saveDockWindowsState()
4732 bool storeWin = resourceMgr()->booleanValue( "Study", "store_positions", true );
4733 bool storeTb = resourceMgr()->booleanValue( "Study", "store_tool_positions", true );
4735 if( !storeWin && !storeTb )
4739 if ( activeModule() )
4740 modName = activeModule()->name();
4741 else if ( activeStudy() )
4742 modName = "nomodule";
4744 QString versionId = GUI_VERSION_STR;
4745 #if GUI_DEVELOPMENT > 0
4749 QByteArray arr = desktop()->saveState();
4750 resourceMgr()->setValue( "windows_geometry", modName, processState(arr, storeWin, storeTb, false) );
4751 resourceMgr()->setValue( "windows_geometry_version", modName, versionId );
4754 if ( myWinVis.contains( modName ) )
4755 visArr = myWinVis[modName];
4757 QMap<QString, bool> tbMap, dwMap;
4758 dockWindowsState( visArr, tbMap, dwMap );
4760 QList<QToolBar*> tbList = desktop()->findChildren<QToolBar*>();
4761 for ( QList<QToolBar*>::iterator it = tbList.begin(); it != tbList.end(); ++it )
4764 tbMap.insert( tb->objectName(), tb->toggleViewAction()->isChecked() );
4767 QList<QDockWidget*> dwList = desktop()->findChildren<QDockWidget*>();
4768 for ( QList<QDockWidget*>::iterator it = dwList.begin(); it != dwList.end(); ++it )
4770 QDockWidget* wid = *it;
4771 dwMap.insert( wid->objectName(), wid->toggleViewAction()->isChecked() );
4774 visArr = dockWindowsState( tbMap, dwMap );
4776 myWinVis.insert( modName, visArr );
4779 QByteArray LightApp_Application::dockWindowsState( const QMap<QString, bool>& tb, const QMap<QString, bool>& dw ) const
4782 QDataStream stream( &visArr, QIODevice::WriteOnly );
4784 stream << (uchar)ToolBarMarker;
4785 stream << tb.size();
4786 for ( QMap<QString, bool>::const_iterator tit = tb.begin(); tit != tb.end(); ++tit )
4788 stream << tit.key();
4789 stream << (uchar)( tit.value() ? 1 : 0 );
4792 stream << (uchar)DockWidgetMarker;
4793 stream << dw.size();
4794 for ( QMap<QString, bool>::const_iterator wit = dw.begin(); wit != dw.end(); ++wit )
4796 stream << wit.key();
4797 stream << (uchar)( wit.value() ? 1 : 0 );
4803 void LightApp_Application::dockWindowsState( const QByteArray& arr, QMap<QString, bool>& tb, QMap<QString, bool>& dw ) const
4808 QByteArray visArr = arr;
4809 QDataStream stream( &visArr, QIODevice::ReadOnly );
4813 if ( marker != ToolBarMarker )
4818 for ( int i = 0; i < lines; ++i )
4821 stream >> objectName;
4824 tb.insert( objectName, shown );
4828 if ( marker != DockWidgetMarker )
4832 for ( int j = 0; j < lines; ++j )
4835 stream >> objectName;
4838 dw.insert( objectName, shown );
4842 QPixmap LightApp_Application::moduleIcon( const QString& moduleTitle, const int size ) const
4845 if ( resourceMgr() )
4847 QPixmap defaultIcon = resourceMgr()->loadPixmap( "LightApp", tr( "APP_MODULE_ICO" ), QPixmap( imageEmptyIcon ) );
4848 QString iconName = resourceMgr()->stringValue( moduleName( moduleTitle ), "icon", QString() );
4849 icon = resourceMgr()->loadPixmap( moduleName( moduleTitle ), iconName, defaultIcon );
4851 icon = Qtx::scaleIcon( icon, size );
4857 Inserts items in popup, which necessary for current application
4859 void LightApp_Application::contextMenuPopup( const QString& type, QMenu* thePopup, QString& title )
4862 LightApp_SelectionMgr* selMgr = LightApp_Application::selectionMgr();
4863 bool cacheIsOn = selMgr->isSelectionCacheEnabled();
4864 selMgr->setSelectionCacheEnabled( true );
4866 SUIT_DataBrowser* ob = objectBrowser();
4868 CAM_Application::contextMenuPopup( type, thePopup, title );
4870 if ( ob && type == ob->popupClientType() ) {
4871 thePopup->addSeparator();
4872 QAction* a = thePopup->addAction( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
4873 if ( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) )
4874 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) );
4877 #ifndef DISABLE_SALOMEOBJECT
4878 if ( selMgr && ob ) {
4879 SALOME_ListIO selected;
4880 selMgr->selectedObjects( selected );
4881 if(selected.Extent() == 1){
4882 Handle(SALOME_InteractiveObject) anIObject = selected.First();
4883 SUIT_DataObject* obj = findObject(anIObject->getEntry());
4884 if(obj && obj->renameAllowed()) {
4885 QAction* a = new QAction(tr("MEN_RENAME_OBJ"), thePopup);
4886 connect( a, SIGNAL( triggered(bool) ), ob, SLOT( onStartEditing() ) );
4887 if ( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) )
4888 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) );
4890 QList<QAction*> acts = thePopup->actions();
4891 QAction* firstAction = acts.count() > 0 ? acts.first() : 0;
4892 thePopup->insertAction(firstAction,a);
4898 selMgr->setSelectionCacheEnabled( cacheIsOn );
4904 void LightApp_Application::createEmptyStudy()
4906 CAM_Application::createEmptyStudy();
4908 if ( objectBrowser() )
4909 objectBrowser()->updateTree();
4911 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
4912 if ( aResMgr && activeStudy() ) {
4913 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
4914 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
4919 void LightApp_Application::setDesktop( SUIT_Desktop* desk )
4921 CAM_Application::setDesktop( desk );
4924 connect( desk, SIGNAL( message( const QString& ) ),
4925 this, SLOT( onDesktopMessage( const QString& ) ), Qt::UniqueConnection );
4926 connect( desk, SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
4927 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
4928 /* connect( desk, SIGNAL( windowMoved( SUIT_ViewWindow* ) ),
4929 this, SLOT( onWindowMoved( SUIT_ViewWindow* ) ), Qt::UniqueConnection ); */
4935 \param mod - module to be activated
4937 bool LightApp_Application::activateModule( CAM_Module* mod )
4939 bool res = CAM_Application::activateModule( mod );
4941 if ( objectBrowser() )
4942 objectBrowser()->updateTree();
4948 \return keyborad accelerators manager object
4950 SUIT_Accel* LightApp_Application::accel() const
4956 Removes dead widget container from map
4958 void LightApp_Application::onWCDestroyed( QObject* ob )
4960 // remove destroyed widget container from windows map
4961 for ( WinMap::ConstIterator itr = myWin.begin(); itr != myWin.end(); ++itr )
4963 if ( itr.value() != ob )
4966 int key = itr.key();
4967 myWin.remove( key );
4972 void LightApp_Application::onMRUActivated( const QString& name )
4974 SUIT_Session* s = SUIT_Session::session();
4975 if ( s && s->activeApplication() == this )
4979 void LightApp_Application::onStylePreferences()
4981 #ifdef USE_SALOME_STYLE
4982 Style_PrefDlg dlg( desktop() );
4985 resourceMgr()->setValue( "Style", "use_salome_style", Style_Salome::isActive() );
4986 #endif // USE_SALOME_STYLE
4989 void LightApp_Application::onFullScreen(){
4990 if(myScreenHelper) {
4991 if(desktop()->isFullScreen())
4992 myScreenHelper->switchToNormalScreen();
4994 myScreenHelper->switchToFullScreen();
4999 Connects just added view manager
5001 void LightApp_Application::addViewManager( SUIT_ViewManager* vm )
5003 connect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
5004 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
5005 CAM_Application::addViewManager( vm );
5009 Remove view manager from memory
5011 void LightApp_Application::removeViewManager( SUIT_ViewManager* vm )
5013 disconnect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
5014 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
5015 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
5017 aStudy->removeObjectProperties( vm->getGlobalId() );
5019 CAM_Application::removeViewManager( vm );
5021 LightApp_SelectionMgr* selMgr = selectionMgr();
5022 QList<SUIT_Selector*> selectors;
5023 selMgr->selectors( selectors );
5024 foreach( SUIT_Selector* selector, selectors ) {
5025 if ( selector->owner() == vm->getViewModel() ) {
5030 // IPAL22894: Crash on closing OCC view
5036 Renames active window of desktop
5038 void LightApp_Application::onRenameWindow()
5043 QWidget* w = desktop()->activeWindow();
5048 QString name = QInputDialog::getText( w, tr( "TOT_RENAME" ), tr( "PRP_RENAME" ), QLineEdit::Normal, w->windowTitle(), &ok );
5049 if( ok && !name.isEmpty() )
5050 w->setWindowTitle( name );
5054 Closes active window of desktop
5056 void LightApp_Application::onCloseWindow()
5061 QWidget* w = desktop()->activeWindow();
5069 Closes all windows of desktop
5071 void LightApp_Application::onCloseAllWindow()
5073 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
5077 QList<SUIT_ViewWindow*> wndList = desk->windows();
5078 SUIT_ViewWindow* wnd;
5079 foreach( wnd, wndList )
5087 Groups all windows of desktop
5089 void LightApp_Application::onGroupAllWindow()
5091 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
5095 QtxWorkstack* wgStack = desk->workstack();
5101 \return default name for an active study
5103 void LightApp_Application::setDefaultStudyName( const QString& theName )
5105 QStringList anInfoList;
5106 modules( anInfoList, false );
5108 LightApp_Study* aStudy = (LightApp_Study*)activeStudy();
5109 if( anInfoList.count() == 1 && // to avoid a conflict between different modules
5110 !aStudy->isSaved() )
5112 aStudy->setStudyName( theName );
5113 updateDesktopTitle();
5118 Custom event handler
5120 bool LightApp_Application::event( QEvent* e )
5122 if( e && e->type()==2000 )
5124 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
5125 QString* d = ( QString* )ce->data();
5126 if( SUIT_MessageBox::question(0, tr("WRN_WARNING"),
5128 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
5129 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
5132 path << tr( "PREF_CATEGORY_SALOME" ) << tr( "PREF_TAB_GENERAL" )
5133 << tr( "PREF_GROUP_EXT_BROWSER" ) << tr( "PREF_APP" );
5134 showPreferences( path );
5140 return CAM_Application::event( e );
5143 /*! Check data object */
5144 bool LightApp_Application::checkDataObject(LightApp_DataObject* theObj)
5148 bool isSuitable = !theObj->entry().isEmpty() &&
5149 !theObj->componentDataType().isEmpty() &&
5150 !theObj->name().isEmpty();
5157 int LightApp_Application::openChoice( const QString& aName )
5159 int choice = CAM_Application::openChoice( aName );
5161 if ( choice == OpenExist ) // The document is already open.
5163 // Do you want to reload it?
5164 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "QUE_DOC_ALREADYOPEN" ).arg( aName ),
5165 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No ) == SUIT_MessageBox::Yes )
5166 choice = OpenReload;
5172 bool LightApp_Application::openAction( const int choice, const QString& aName )
5179 STD_Application* app = 0;
5180 SUIT_Session* session = SUIT_Session::session();
5181 QList<SUIT_Application*> appList = session->applications();
5182 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !app; ++it )
5184 if ( (*it)->activeStudy() && (*it)->activeStudy()->studyName() == aName )
5185 app = ::qobject_cast<STD_Application*>( *it );
5190 app->onCloseDoc( false );
5191 appList = session->applications();
5192 STD_Application* other = 0;
5193 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !other; ++it )
5194 other = ::qobject_cast<STD_Application*>( *it );
5197 res = other->onOpenDoc( aName );
5202 res = CAM_Application::openAction( choice, aName );
5209 QStringList LightApp_Application::viewManagersTypes() const
5211 QStringList aTypesList;
5212 aTypesList += myUserWmTypes;
5213 #ifndef DISABLE_GLVIEWER
5214 aTypesList<<GLViewer_Viewer::Type();
5216 #ifndef DISABLE_PLOT2DVIEWER
5217 aTypesList<<Plot2d_Viewer::Type();
5219 #ifndef DISABLE_QXGRAPHVIEWER
5220 aTypesList<<QxScene_Viewer::Type();
5222 #ifndef DISABLE_PVVIEWER
5223 aTypesList<<PVViewer_Viewer::Type();
5225 #ifndef DISABLE_PYVIEWER
5226 aTypesList<<PyViewer_Viewer::Type();
5228 #ifndef DISABLE_OCCVIEWER
5229 aTypesList<<OCCViewer_Viewer::Type();
5231 #ifndef DISABLE_VTKVIEWER
5232 #ifndef DISABLE_SALOMEOBJECT
5233 aTypesList<<SVTK_Viewer::Type();
5235 aTypesList<<VTKViewer_Viewer::Type();
5238 #ifndef DISABLE_PV3DVIEWER
5239 aTypesList<<PV3DViewer_ViewModel::Type();
5244 * Removes all view managers of known types
5245 * Other view managers are ignored
5247 void LightApp_Application::clearKnownViewManagers()
5249 QStringList aTypesList = viewManagersTypes();
5250 QList<SUIT_ViewManager*> aMgrList;
5251 viewManagers( aMgrList );
5252 foreach (SUIT_ViewManager* aMgr, aMgrList) {
5253 if (aTypesList.contains(aMgr->getType()))
5254 removeViewManager(aMgr);
5259 Copy of current selection
5261 void LightApp_Application::onCopy()
5263 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
5269 Paste of current data in clipboard
5271 void LightApp_Application::onPaste()
5273 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
5279 Browse (i.e. set focus on) the published objects
5280 \param theIsApplyAndClose - flag indicating that the dialog for creating objects
5281 has been accepted by Ok (or Apply & Close) button
5282 \param theIsOptimizedBrowsing - flag switching to optimized browsing mode
5283 (to select the first published object only)
5284 \return entry of the selected object
5286 QString LightApp_Application::browseObjects( const QStringList& theEntryList,
5287 const bool theIsApplyAndClose,
5288 const bool theIsOptimizedBrowsing )
5291 if( SUIT_ResourceMgr* aResourceMgr = resourceMgr() )
5293 int aBrowsePolicy = aResourceMgr->integerValue( "ObjectBrowser", "browse_published_object", (int)BP_Never );
5294 switch( aBrowsePolicy )
5298 case BP_ApplyAndClose:
5299 if( !theIsApplyAndClose )
5307 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
5311 SUIT_DataBrowser* anOB = objectBrowser();
5315 SUIT_AbstractModel* aModel = dynamic_cast<SUIT_AbstractModel*>( anOB->model() );
5319 QStringListIterator anIter( theEntryList );
5320 if( theIsOptimizedBrowsing )
5322 // go to the last entry
5324 if( anIter.hasPrevious() )
5328 // scroll to each entry in the list
5329 // (in optimized mode - to the last entry only)
5331 LightApp_DataObject* anObject = 0;
5332 while( anIter.hasNext() )
5334 anEntry = anIter.next();
5335 if( !anEntry.isEmpty() )
5337 anObject = aStudy->findObjectByEntry( anEntry );
5340 QModelIndex anIndex = aModel->index( anObject );
5341 anOB->treeView()->scrollTo( anIndex );
5346 // always select the last object
5347 if( anObject && !anEntry.isEmpty() )
5349 QList<SUIT_Selector*> aSelectorList;
5350 selectionMgr()->selectors( "ObjectBrowser", aSelectorList );
5351 if( !aSelectorList.isEmpty() )
5353 if( LightApp_OBSelector* aSelector = dynamic_cast<LightApp_OBSelector*>( aSelectorList.first() ) )
5355 bool anIsAutoBlock = aSelector->autoBlock();
5357 // temporarily disable auto block, to emit LightApp_SelectionMgr::currentSelectionChanged() signal
5358 aSelector->setAutoBlock( false );
5360 SUIT_DataOwnerPtrList aList;
5361 #ifndef DISABLE_SALOMEOBJECT
5362 Handle(SALOME_InteractiveObject) aSObj = new SALOME_InteractiveObject
5363 ( anObject->entry().toUtf8().constData(),
5364 anObject->componentDataType().toLatin1().constData(),
5365 anObject->name().toUtf8().constData() );
5366 LightApp_DataOwner* owner = new LightApp_DataOwner( aSObj );
5368 LightApp_DataOwner* owner = new LightApp_DataOwner( anEntry );
5371 aList.append( owner );
5372 selectionMgr()->setSelected( aList );
5375 // restore auto block flag
5376 aSelector->setAutoBlock( anIsAutoBlock );
5384 SUIT_DataObject* LightApp_Application::findObject( const QString& id ) const
5386 LightApp_Study* study = dynamic_cast<LightApp_Study*>( activeStudy() );
5387 return study ? study->findObjectByEntry( id ) : 0;
5391 Checks that an object can be renamed.
5392 \param entry entry of the object
5393 \brief Return \c true if object can be renamed
5395 bool LightApp_Application::renameAllowed( const QString& /*entry*/) const {
5400 Rename object by entry.
5401 \param entry entry of the object
5402 \param name new name of the object
5403 \brief Return \c true if rename operation finished successfully, \c false otherwise.
5405 bool LightApp_Application::renameObject( const QString& /*entry*/, const QString& /*name*/ ) {
5409 /*! Process standard messages from desktop */
5410 void LightApp_Application::onDesktopMessage( const QString& message )
5412 const QString sectionSeparator = "/";
5414 if ( message.toLower() == "updateobjectbrowser" ||
5415 message.toLower() == "updateobjbrowser" ) {
5416 // update object browser
5417 updateObjectBrowser();
5419 else if ( message.toLower().startsWith( "activate_viewer" ) ) {
5420 QString vtype = message.split( sectionSeparator ).last();
5421 if ( !vtype.isEmpty() )
5422 getViewManager( vtype, true );
5424 else if ( message.toLower().startsWith("register_module_in_study" ) ) {
5425 QString moduleName = message.split( sectionSeparator ).last();
5426 // Check name of current activating module name in order to avoid ciclik
5427 // call because of messages
5428 if (!property("activateModule").toBool()) {
5429 CAM_Module* mod = module(moduleName);
5431 mod = module(moduleTitle(moduleName));
5433 mod = loadModule(moduleName);
5435 mod = loadModule(moduleTitle(moduleName));
5441 CAM_Study* anActiveStudy = dynamic_cast<CAM_Study*>(activeStudy());
5442 if (anActiveStudy) {
5443 mod->connectToStudy(anActiveStudy);
5444 LightApp_DataModel* aDM = dynamic_cast<LightApp_DataModel*>(mod->dataModel());
5446 aDM->initRootObject();
5453 QStringList data = message.split( sectionSeparator );
5454 if ( data.count() > 1 ) {
5455 QString msgType = data[0].trimmed();
5456 LightApp_Module* sMod = 0;
5457 CAM_Module* mod = module( msgType );
5459 mod = module( moduleTitle( msgType ) );
5460 if ( mod && mod->inherits( "LightApp_Module" ) )
5461 sMod = (LightApp_Module*)mod;
5463 if ( msgType.toLower() == "preferences" ) {
5464 // requested preferences change: should be given as "preferences/<section>/<name>/<value>"
5465 // for example "preferences/Study/multi_file_dump/true"
5466 if ( data.count() > 3 ) {
5467 QString section = data[1].trimmed();
5468 QString param = data[2].trimmed();
5469 QString value = QStringList( data.mid(3) ).join( sectionSeparator );
5470 resourceMgr()->setValue( section, param, value );
5474 // received message for the module
5475 QString msg = QStringList( data.mid(1) ).join( sectionSeparator );
5476 sMod->message( msg );
5482 void LightApp_Application::onInfoPanelShown()
5484 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
5485 ((LightApp_Module*)activeModule())->updateInfoPanel();
5490 Returns all top level toolbars.
5491 Note : Result list contains only main window toolbars, not including toolbars from viewers.
5493 QList<QToolBar*> LightApp_Application::findToolBars( const QStringList& names )
5495 QList<QToolBar*> aResult;
5496 QList<QToolBar*> tbList = desktop()->findChildren<QToolBar*>();
5497 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit ) {
5498 QToolBar* tb = *tit;
5499 QObject* po = Qtx::findParent( tb, "QMainWindow" );
5500 if ( po != desktop() )
5502 if ( names.isEmpty() || names.contains( tb->objectName() ) )
5509 Internal method to parse toolbars and dockable windows state.
5511 QByteArray LightApp_Application::processState(QByteArray& input,
5512 const bool processWin,
5513 const bool processTb,
5514 const bool isRestoring,
5515 QByteArray defaultState) {
5518 bool hasDefaultState = !defaultState.isEmpty();
5519 bool isDockWinWriten = false;
5521 //Write date from users settings
5523 QDataStream tmpInputData(&input, QIODevice::ReadOnly);
5524 int marker, version;
5526 tmpInputData >> marker;
5527 tmpInputData >> version;
5528 tmpInputData >> dockmarker;
5529 tmpInputData >> nbDocWin;
5531 if(processWin && processTb && !isRestoring) {
5533 } else if(!processWin && !processTb ) {
5535 aRes = defaultState;
5537 QDataStream aData(&aRes, QIODevice::WriteOnly);
5538 QList<QToolBar*> aToolBars = findToolBars();
5541 for ( QList<QToolBar*>::iterator tit = aToolBars.begin(); tit != aToolBars.end(); ++tit ) {
5542 QToolBar* tb = *tit;
5543 aNames.append(tb->objectName());
5546 int toolBarMarkerIndex = getToolbarMarkerIndex(input,aNames);
5547 if(toolBarMarkerIndex < 0)
5549 QDataStream anInputData(&input, QIODevice::ReadOnly);
5551 int toolBarMarkerIndexDef = 0;
5552 if(hasDefaultState) {
5553 toolBarMarkerIndexDef = getToolbarMarkerIndex(defaultState, aNames);
5554 if(toolBarMarkerIndexDef < 0)
5557 QDataStream anInputDataDef(&defaultState, QIODevice::ReadOnly);
5559 QDataStream* aTargetData = 0;
5560 int aTargetIndex = -1;
5562 QByteArray currentArr = desktop()->saveState();
5563 QDataStream anInputDataCur(¤tArr, QIODevice::ReadOnly);
5564 bool useInputData = !isRestoring || (isRestoring && nbDocWin > 0);
5565 if(processWin && useInputData) {
5566 aTargetData = &anInputData;
5567 aTargetIndex = toolBarMarkerIndex;
5569 //Write date from default settings
5570 if(hasDefaultState) {
5571 aTargetData = &anInputDataDef;
5572 aTargetIndex = toolBarMarkerIndexDef;
5574 //If no default state, write current snapshot of the dockable windows
5576 aTargetData = &anInputDataCur;
5577 int toolBarMarkerIndexCur = getToolbarMarkerIndex(currentArr, aNames);
5578 aTargetIndex = toolBarMarkerIndexCur;
5583 if(aTargetData && aTargetIndex >= 0 ) {
5584 aTargetData->device()->seek(0);
5585 while( aTargetData->device()->pos() < aTargetIndex ) {
5590 isDockWinWriten = true;
5597 aTargetData = &anInputData;
5598 aTargetIndex = toolBarMarkerIndex;
5600 if(hasDefaultState) {
5601 aTargetData = &anInputDataDef;
5602 aTargetIndex = toolBarMarkerIndexDef;
5606 if(aTargetData && aTargetIndex >= 0) {
5608 if(!isDockWinWriten ) {
5609 //Write version marker
5610 int marker, version;
5611 aTargetData->device()->seek(0);
5612 *aTargetData >> marker;
5613 *aTargetData >> version;
5616 aData << (uchar) QDockWidgetMarker;
5618 int shift = 4*sizeof(int) + sizeof(QSize);
5619 index = aTargetIndex - shift;
5621 index = aTargetIndex;
5624 aTargetData->device()->seek(index);
5625 while(!aTargetData->atEnd()) {
5630 } else { // Not treat toolbars
5631 aData << (uchar) QToolBarMarker;
5632 aData << (int) 0; //Nb toolbars = 0
5639 \brief Emits operationFinished signal.
5640 \param theModuleName the name of the module which perfomed the operation
5641 \param theOperationName the operation name
5642 \param theEntryList the list of the created objects entries
5644 void LightApp_Application::emitOperationFinished( const QString& theModuleName,
5645 const QString& theOperationName,
5646 const QStringList& theEntryList )
5648 emit operationFinished( theModuleName, theOperationName, theEntryList );
5652 Update visibility state of given objects
5654 void LightApp_Application::updateVisibilityState( DataObjectList& theList,
5655 SUIT_ViewModel* theViewModel )
5657 if ( !theViewModel || theList.isEmpty() ) return;
5659 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
5660 if ( !aStudy ) return;
5662 SALOME_View* aView = dynamic_cast<SALOME_View*>( theViewModel );
5664 for ( DataObjectList::iterator itr = theList.begin(); itr != theList.end(); ++itr ) {
5665 LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>(*itr);
5667 if ( !obj || aStudy->isComponent( obj->entry() ) )
5670 QString mname = aStudy->componentDataType(obj->entry());
5671 LightApp_Displayer* aDisplayer = LightApp_Displayer::FindDisplayer(mname, false);
5673 Qtx::VisibilityState anObjState = Qtx::UnpresentableState;
5674 if ( aDisplayer->canBeDisplayed( obj->entry(), theViewModel->getType() ) ) {
5675 if ( aDisplayer->IsDisplayed( obj->entry(), aView ) )
5676 anObjState = Qtx::ShownState;
5678 anObjState = Qtx::HiddenState;
5680 aStudy->setVisibilityState( obj->entry(), anObjState );
5686 Update presentations of all displayed objects of theComponent in specified viewers
5688 void LightApp_Application::updatePresentations( const QString& theComponent,
5689 const QStringList& theViewManagerTypes )
5691 LightApp_Displayer* aDisplayer = LightApp_Displayer::FindDisplayer(theComponent, false);
5693 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
5694 DataObjectList aComps;
5695 bool isFound = false;
5696 aStudy->root()->children( aComps );
5697 DataObjectList::const_iterator aCompsIt = aComps.begin();
5698 for ( ; aCompsIt != aComps.end() && !isFound; aCompsIt++ ) {
5699 LightApp_DataObject* aComp = dynamic_cast<LightApp_DataObject*>( *aCompsIt );
5700 if ( aComp && aComp->componentDataType() == theComponent) {
5702 DataObjectList anObjs;
5703 aComp->children(anObjs, true);
5705 QList<SUIT_ViewManager*> aViewMgrs;
5706 QStringList::const_iterator itVMTypes = theViewManagerTypes.begin();
5707 for ( ; itVMTypes != theViewManagerTypes.end(); ++itVMTypes )
5708 viewManagers( *itVMTypes, aViewMgrs );
5710 DataObjectList::const_iterator itObjs = anObjs.begin();
5711 for ( ; itObjs != anObjs.end(); itObjs++ ) {
5712 LightApp_DataObject* anObj = dynamic_cast<LightApp_DataObject*>( *itObjs );
5713 QString anEntry = anObj->entry();
5715 QListIterator<SUIT_ViewManager*> itViewMgrs( aViewMgrs );
5716 while ( itViewMgrs.hasNext()) {
5717 SUIT_ViewModel* aVM = itViewMgrs.next()->getViewModel();
5719 SALOME_View* aView = dynamic_cast<SALOME_View*>(aVM);
5721 bool isDisp = aDisplayer->IsDisplayed( anEntry, aView );
5722 aDisplayer->Erase( anEntry, true, false, aView );
5724 aDisplayer->Display( anEntry, false, aView );
5736 * Called when window activated
5738 void LightApp_Application::onWindowActivated( SUIT_ViewWindow* theViewWindow )
5740 SUIT_DataBrowser* anOB = objectBrowser();
5743 SUIT_DataObject* rootObj = anOB->root();
5747 DataObjectList listObj = rootObj->children( true );
5749 SUIT_ViewModel* vmod = 0;
5750 if ( SUIT_ViewManager* vman = theViewWindow->getViewManager() )
5751 vmod = vman->getViewModel();
5752 updateVisibilityState( listObj, vmod );
5756 Called then view manager removed
5758 void LightApp_Application::onViewManagerRemoved( SUIT_ViewManager* )
5760 ViewManagerList lst;
5761 viewManagers( lst );
5762 if ( lst.count() == 1) { // in case if closed last view window
5763 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
5765 aStudy->setVisibilityStateForAll( Qtx::UnpresentableState );
5770 Check existing document.
5772 bool LightApp_Application::checkExistingDoc( bool closeExistingDoc )
5775 if( activeStudy() ) {
5776 int answer = !activeStudy()->isModified() ? 1 :
5777 SUIT_MessageBox::question( desktop(),
5778 tr( "APPCLOSE_CAPTION" ),
5779 tr( "STUDYCLOSE_DESCRIPTION" ),
5780 tr( "APPCLOSE_SAVE" ),
5781 tr( "APPCLOSE_CLOSE" ),
5782 tr( "APPCLOSE_CANCEL" ), 0 );
5784 if ( activeStudy()->isSaved() ) {
5786 if (closeExistingDoc) {
5789 } else if ( onSaveAsDoc() ) {
5790 if (closeExistingDoc) {
5791 if( !closeDoc( false ) ) {
5799 else if( answer == 1 ) {
5800 if (closeExistingDoc) {
5803 } else if( answer == 2 ) {
5810 #ifndef DISABLE_PYCONSOLE
5812 PyConsole_Interp* LightApp_Application::getPyInterp()
5814 static PyConsole_Interp* myInterp = 0;
5816 myInterp = createPyInterp();
5817 myInterp->initialize();
5822 PyConsole_Interp* LightApp_Application::createPyInterp()
5824 return new PyConsole_Interp();
5827 #endif // DISABLE_PYCONSOLE
5829 void LightApp_Application::createHelpItems( const QString& modTitle )
5831 if ( modTitle.isEmpty() )
5834 QString userGuide = "User's Guide";
5835 QString devGuide = "Developer's Guide";
5837 int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
5839 createMenu( userGuide, helpMenu, -1, 5 );
5840 createMenu( devGuide, helpMenu, -1, 5 );
5842 IMap <QString, QString> helpData; // list of help files for the module
5843 QString helpSubMenu; // help submenu name (empty if not needed)
5844 QString modName = moduleName( modTitle ); // module name
5845 if ( modName.isEmpty() ) modName = modTitle; // for KERNEL and GUI
5846 QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName ); // module root dir env variable
5847 QString modDir = Qtx::getenv( rootDir.toUtf8().constData() ); // module root dir path
5849 if ( resourceMgr()->hasValue( modName, "documentation" ) )
5850 docSection = resourceMgr()->stringValue( modName, "documentation" );
5851 else if ( resourceMgr()->hasSection( modName + "_documentation" ) )
5852 docSection = modName + "_documentation";
5853 if ( !docSection.isEmpty() )
5855 helpSubMenu = resourceMgr()->stringValue( docSection, "sub_menu", "" );
5856 if ( helpSubMenu.contains( "%1" ) )
5857 helpSubMenu = helpSubMenu.arg( modTitle );
5858 foreach( QString paramName, resourceMgr()->parameters( docSection ) )
5860 QString key = paramName.contains( "%1" ) ? paramName.arg( modTitle ) : paramName;
5861 QString helpItem = getHelpItem( docSection, paramName );
5862 if ( !helpItem.isEmpty() )
5863 helpData.insert( key, helpItem );
5867 if ( helpData.isEmpty() && !modDir.isEmpty() )
5869 QStringList idxLst = QStringList() << modDir << "share" << "doc" << "salome" << "gui" << modName << "index.html";
5870 QString indexFile = idxLst.join( QDir::separator() ); // index file
5871 if ( QFile::exists( indexFile ) )
5872 helpData.insert( tr( "%1 module Users's Guide" ).arg( modTitle ), indexFile );
5875 IMapConstIterator<QString, QString > fileIt;
5876 for ( fileIt = helpData.begin(); fileIt != helpData.end(); fileIt++ )
5878 QString helpItemPath = fileIt.key();
5879 // remove all '//' occurances
5880 while ( helpItemPath.contains( "//" ) )
5881 helpItemPath.replace( "//", "" );
5882 // obtain submenus hierarchy if given
5883 QStringList smenus = helpItemPath.split( "/" );
5884 helpItemPath = smenus.takeLast();
5885 // workaround for User's Guide and Developer's Guide to avoid having single item in module's submenu.
5886 if ( helpItemPath == userGuide || helpItemPath == devGuide )
5888 QString menuPath = smenus.join( "/" );
5889 QStringList allKeys = helpData.keys();
5890 QStringList total = allKeys.filter( QRegExp( QString( "^%1" ).arg( menuPath ) ) );
5891 if ( total.count() == 1 && smenus.count() > 0 )
5892 helpItemPath = smenus.takeLast();
5894 QPixmap helpIcon = fileIt.value().startsWith( "http", Qt::CaseInsensitive ) ?
5895 resourceMgr()->loadPixmap( "STD", tr( "ICON_WWW" ), false ) :
5896 resourceMgr()->loadPixmap( "STD", tr( "ICON_HELP" ), false );
5897 QAction* a = createAction( -1, helpItemPath, helpIcon, helpItemPath, helpItemPath,
5898 0, desktop(), false, this, SLOT( onHelpContentsModule() ) );
5899 a->setData( fileIt.value() );
5900 if ( !helpSubMenu.isEmpty() )
5901 smenus.prepend( helpSubMenu );
5902 // create sub-menus hierarchy
5903 int menuId = helpMenu;
5904 foreach ( QString subMenu, smenus )
5905 menuId = createMenu( subMenu, menuId, -1, 5 );
5906 createMenu( a, menuId, -1, ( menuId != helpMenu && ( helpItemPath == userGuide || helpItemPath == devGuide ) ) ? 0 : 5 );
5907 if ( !myHelpItems.contains( modName ) )
5908 myHelpItems[modName] = IdList();
5909 myHelpItems[modName].append( actionId( a ) );
5913 void LightApp_Application::removeHelpItems( const QString& modTitle )
5915 QString modName = moduleName( modTitle );
5916 if ( myHelpItems.contains( modName ) )
5918 foreach( int id, myHelpItems[modName] )
5919 setMenuShown( id, false );
5920 myHelpItems.remove( modName );