1 // Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File: LightApp_Application.cxx
24 // Created: 6/20/2005 18:39:45 PM
25 // Author: Natalia Donis
28 // E.A. : On windows with python 2.6, there is a conflict
29 // E.A. : between pymath.h and Standard_math.h which define
30 // E.A. : some same symbols : acosh, asinh, ...
31 #include <Standard_math.hxx>
32 #ifndef DISABLE_PYCONSOLE
37 #ifndef DISABLE_PYCONSOLE
38 #include "PyConsole_Interp.h"
39 #include "LightApp_PyEditor.h"
40 #include "PyConsole_Console.h"
43 #include "LightApp_Application.h"
44 #include "LightApp_Module.h"
45 #include "LightApp_DataModel.h"
46 #include "LightApp_DataOwner.h"
47 #include "LightApp_Displayer.h"
48 #include "LightApp_Study.h"
49 #include "LightApp_Preferences.h"
50 #include "LightApp_PreferencesDlg.h"
51 #include "LightApp_ModuleDlg.h"
52 #include "LightApp_AboutDlg.h"
53 #include "LightApp_ModuleAction.h"
54 // temporary commented
55 #include "LightApp_EventFilter.h"
56 #include "LightApp_OBSelector.h"
57 #include "LightApp_SelectionMgr.h"
58 #include "LightApp_DataObject.h"
59 #include "LightApp_WgViewModel.h"
60 #include "LightApp_FullScreenHelper.h"
62 #include <GUI_version.h>
64 #include <SALOME_Event.h>
66 #ifdef USE_SALOME_STYLE
67 #include <Style_Salome.h>
68 #include <Style_PrefDlg.h>
69 #endif // USE_SALOME_STYLE
71 #include <CAM_Module.h>
72 #include <CAM_DataModel.h>
73 #include <CAM_Study.h>
74 #include <STD_TabDesktop.h>
76 #include <SUIT_DataBrowser.h>
77 #include <SUIT_Session.h>
78 #include <SUIT_Study.h>
79 #include <SUIT_FileDlg.h>
80 #include <SUIT_ResourceMgr.h>
81 #include <SUIT_ShortcutMgr.h>
82 #include <SUIT_Tools.h>
83 #include <SUIT_Accel.h>
84 #include <SUIT_MessageBox.h>
85 #include <SUIT_ViewWindow.h>
88 #include <QtxFontEdit.h>
89 #include <QtxToolBar.h>
90 #include <QtxTreeView.h>
91 #include <QtxInfoPanel.h>
92 #include <QtxMRUAction.h>
93 #include <QtxDockAction.h>
94 #include <QtxDockWidget.h>
95 #include <QtxActionToolMgr.h>
96 #include <QtxSearchTool.h>
97 #include <QtxWorkstack.h>
100 #include <LogWindow.h>
102 #ifndef DISABLE_GLVIEWER
103 #include <GLViewer_Viewer.h>
104 #include <GLViewer_ViewManager.h>
105 #include "LightApp_GLSelector.h"
108 #ifndef DISABLE_PLOT2DVIEWER
109 #include <Plot2d_ViewManager.h>
110 #include <Plot2d_ViewModel.h>
111 #include <Plot2d_ViewWindow.h>
112 #include <Plot2d_ViewFrame.h>
113 #include "LightApp_Plot2dSelector.h"
114 #ifndef DISABLE_SALOMEOBJECT
115 #include <SPlot2d_ViewModel.h>
117 #include <Plot2d_ViewModel.h>
121 #ifndef DISABLE_OCCVIEWER
122 #include <OCCViewer_ViewManager.h>
123 #include <OCCViewer_ViewFrame.h>
124 #include <OCCViewer_ViewPort3d.h>
125 #ifndef DISABLE_SALOMEOBJECT
126 #include <SOCC_ViewModel.h>
128 #include <OCCViewer_ViewModel.h>
130 #include "LightApp_OCCSelector.h"
133 #ifndef DISABLE_VTKVIEWER
134 #ifndef DISABLE_SALOMEOBJECT
135 #include <SVTK_ViewModel.h>
136 #include <SVTK_ViewManager.h>
137 #include "LightApp_VTKSelector.h"
139 #include <VTKViewer_ViewModel.h>
140 #include <VTKViewer_ViewManager.h>
142 #include <VTKViewer_ViewModel.h>
145 #ifndef DISABLE_QXGRAPHVIEWER
146 #include <QxScene_ViewManager.h>
147 #include <QxScene_ViewModel.h>
148 #include <QxScene_ViewWindow.h>
151 #ifndef DISABLE_GRAPHICSVIEW
152 #include "GraphicsView_Viewer.h"
153 #include "GraphicsView_ViewManager.h"
154 #include "LightApp_GVSelector.h"
157 #ifndef DISABLE_PVVIEWER
158 #include "PVViewer_ViewManager.h"
159 #include "PVViewer_ViewWindow.h"
160 #include "PVViewer_ViewModel.h"
163 #ifndef DISABLE_PYVIEWER
164 #include <PyViewer_ViewManager.h>
165 #include <PyViewer_ViewModel.h>
166 #include <PyViewer_ViewWindow.h>
170 #define VISIBILITY_COLUMN_WIDTH 25
176 #include <QStringList>
178 #include <QApplication>
180 #include <QStatusBar>
182 #include <QObjectList>
184 #include <QInputDialog>
185 #include <QFontDatabase>
187 #include <QByteArray>
191 #include <QHeaderView>
197 #include <utilities.h>
199 #define FIRST_HELP_ID 1000000
200 #define HAS_WWW_URL true
201 #define HAS_FORUM_URL true
202 #define HAS_YOUTUBE_URL true
203 #define HAS_TUTORIAL_URL false
205 #ifndef DISABLE_SALOMEOBJECT
206 #include <SALOME_InteractiveObject.hxx>
207 #include <SALOME_ListIO.hxx>
210 #include <Standard_Version.hxx>
212 #define ToolBarMarker 0
213 #define DockWidgetMarker 1
215 static const char* imageEmptyIcon[] = {
218 "....................",
219 "....................",
220 "....................",
221 "....................",
222 "....................",
223 "....................",
224 "....................",
225 "....................",
226 "....................",
227 "....................",
228 "....................",
229 "....................",
230 "....................",
231 "....................",
232 "....................",
233 "....................",
234 "....................",
235 "....................",
236 "....................",
237 "...................."};
239 // Markers used to parse array with dockable windows and toolbars state.
240 // For more details please see the qdockarealayout.cpp && qtoolbararealayout.cpp
241 // in the Qt source code.
243 #define QDockWidgetMarker 0xfd // = DockWidgetStateMarker
244 #define QToolBarMarker 0xfc // = ToolBarStateMarkerEx
246 // Format of the Byte array with the windows and toolbar state is:
247 // VersionMarker|version|DockWidgetStateMarker|nbDockWidgetLines|...DocWidgetData...|ToolBarStateMarkerEx|nbToolBarLines|...ToolBarData...
249 //Find toolbar marker position in the array in the following way:
250 //since the 'toolbar marker' is not unique, find index of first occurrence of the
251 //'toolbar marker' in the array and check that next string is name of the toolbar
253 void LightAppCleanUpAppResources()
255 if ( LightApp_Application::_prefs_ ) {
256 delete LightApp_Application::_prefs_;
257 LightApp_Application::_prefs_ = 0;
263 int getToolbarMarkerIndex( QByteArray input, const QStringList& aFlags ) {
264 int aResult = -1,tmp = 0;
265 int inputLen = input.length();
266 QDataStream anInputData( &input, QIODevice::ReadOnly );
267 while ( tmp < inputLen ) {
268 tmp = input.indexOf( (uchar)QToolBarMarker, tmp + 1 );
271 anInputData.device()->seek( tmp );
275 anInputData >> lines;
277 if ( lines == 0 && anInputData.atEnd() ) {
278 //Case then array doesn't contain information about toolbars,
289 if ( aFlags.contains( str ) ) {
297 QString langToName( const QString& lang )
299 // special processing for English language to avoid such result as "American English"
300 // as Qt cannot just say "English"
305 result = QLocale( lang ).nativeLanguageName();
309 QString getHelpItem( const QString& section, const QString& parameter, const QString& root = QString() )
311 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
312 foreach( QString item, resMgr->stringValue( section, parameter ).split( ";;", QString::SkipEmptyParts ) )
314 if ( item.startsWith( "http", Qt::CaseInsensitive ) )
317 path.remove( QRegExp( "#.*$" ) );
318 QFileInfo fi( path );
319 if ( fi.isRelative() && !root.isEmpty() )
320 path = Qtx::addSlash( root ) + path;
321 if ( QFile::exists( path ) )
328 /*!Create new instance of LightApp_Application.*/
329 extern "C" LIGHTAPP_EXPORT SUIT_Application* createApplication()
331 return new LightApp_Application();
334 /*! \var global preferences of LightApp */
335 LightApp_Preferences* LightApp_Application::_prefs_ = 0;
339 \class LightApp_Application
340 Application containing LightApp module
344 LightApp_Application::LightApp_Application()
345 : CAM_Application( false ),
347 myScreenHelper(new LightApp_FullScreenHelper())
349 Q_INIT_RESOURCE( LightApp );
351 STD_TabDesktop* desk = new STD_TabDesktop();
352 desk->setFullScreenAllowed(false);
353 desk->setMinimizeAllowed(false);
357 // initialize auto save timer
358 myAutoSaveTimer = new QTimer( this );
359 myAutoSaveTimer->setSingleShot( true );
360 connect( myAutoSaveTimer, SIGNAL( timeout() ), this, SLOT( onSaveDoc() ) );
362 //connect( this, SIGNAL( moving() ), this, SLOT( onMoved() ) );
364 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
365 QPixmap aLogo = aResMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
367 desktop()->setWindowIcon( aLogo );
368 desktop()->setDockableMenuBar( false );
369 desktop()->setDockableStatusBar( false );
371 // base logo (salome itself)
372 desktop()->logoInsert( "_app_base", aResMgr->loadPixmap( "LightApp", tr( "APP_BASE_LOGO" ), false ) );
373 // extra logo (salome-based application)
374 desktop()->logoInsert( "_app_extra", aResMgr->loadPixmap( "LightApp", tr( "APP_EXTRA_LOGO" ), false ) );
378 mySelMgr = new LightApp_SelectionMgr( this );
380 myAccel = SUIT_Accel::getAccel();
382 #ifndef DISABLE_OCCVIEWER
383 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, OCCViewer_Viewer::Type() );
384 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, OCCViewer_Viewer::Type() );
385 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, OCCViewer_Viewer::Type() );
386 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, OCCViewer_Viewer::Type() );
387 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, OCCViewer_Viewer::Type() );
388 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, OCCViewer_Viewer::Type() );
389 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, OCCViewer_Viewer::Type() );
390 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, OCCViewer_Viewer::Type() );
391 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, OCCViewer_Viewer::Type() );
392 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, OCCViewer_Viewer::Type() );
393 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, OCCViewer_Viewer::Type() );
394 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, OCCViewer_Viewer::Type() );
396 #ifndef DISABLE_VTKVIEWER
397 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, VTKViewer_Viewer::Type() );
398 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, VTKViewer_Viewer::Type() );
399 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, VTKViewer_Viewer::Type() );
400 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, VTKViewer_Viewer::Type() );
401 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, VTKViewer_Viewer::Type() );
402 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, VTKViewer_Viewer::Type() );
403 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, VTKViewer_Viewer::Type() );
404 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, VTKViewer_Viewer::Type() );
405 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, VTKViewer_Viewer::Type() );
406 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, VTKViewer_Viewer::Type() );
407 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, VTKViewer_Viewer::Type() );
408 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, VTKViewer_Viewer::Type() );
410 #ifndef DISABLE_PLOT2DVIEWER
411 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, Plot2d_Viewer::Type() );
412 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, Plot2d_Viewer::Type() );
413 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, Plot2d_Viewer::Type() );
414 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, Plot2d_Viewer::Type() );
415 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, Plot2d_Viewer::Type() );
416 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, Plot2d_Viewer::Type() );
417 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, Plot2d_Viewer::Type() );
418 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, Plot2d_Viewer::Type() );
421 connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) );
422 connect( desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
423 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
424 connect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
425 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ), Qt::UniqueConnection );
428 // Set existing font for the python console in resources
429 if( !aResMgr->hasValue( "PyConsole", "font" ) )
432 QFont f = aResMgr->fontValue( "PyConsole", "font" );
434 QStringList famdb = fdb.families();
436 if ( famdb.contains(f.family()) || !aResMgr->hasValue( "PyConsole", "additional_families" ) )
439 QStringList anAddFamilies = aResMgr->stringValue( "PyConsole", "additional_families" ).split( ";", QString::SkipEmptyParts );
441 for ( QStringList::Iterator it = anAddFamilies.begin(); it != anAddFamilies.end(); ++it )
444 if ( famdb.contains(aFamily) )
446 f.setFamily( aFamily );
447 aResMgr->setValue( "PyConsole", "font", f );
454 *\li Save window geometry.
455 *\li Save desktop geometry.
456 *\li Save resource maneger.
457 *\li Delete selection manager.
459 LightApp_Application::~LightApp_Application()
463 delete myScreenHelper;
467 /*!Start application.*/
468 void LightApp_Application::start()
470 CAM_Application::start();
473 updateViewManagers();
474 updateCommandsStatus();
477 desktop()->statusBar()->showMessage( "" );
479 LightApp_EventFilter::Init();
484 /*!Closeapplication.*/
485 void LightApp_Application::closeApplication()
487 #ifndef DISABLE_QTXWEBBROWSER
488 QProcess::startDetached( "HelpBrowser",
489 QStringList() << QString( "--remove=%1" ).arg( QApplication::instance()->applicationPid() ) );
491 CAM_Application::closeApplication();
494 /*!Gets application name.*/
495 QString LightApp_Application::applicationName() const
497 static QString _app_name;
498 if ( _app_name.isEmpty() )
499 _app_name = tr( "APP_NAME" );
503 /*!Gets application version.*/
504 QString LightApp_Application::applicationVersion() const
506 static QString _app_version;
508 if ( _app_version.isEmpty() )
510 QString resVersion = tr( "APP_VERSION" );
511 if ( resVersion != "APP_VERSION" )
513 _app_version = resVersion;
517 _app_version = GUI_VERSION_STR;
523 /*!Load module by \a name.*/
524 CAM_Module* LightApp_Application::loadModule( const QString& name, const bool showMsg )
526 CAM_Module* mod = CAM_Application::loadModule( name, showMsg );
529 connect( this, SIGNAL( studyOpened() ), mod, SLOT( onModelOpened() ) );
530 connect( this, SIGNAL( studySaved() ), mod, SLOT( onModelSaved() ) );
531 connect( this, SIGNAL( studyClosed() ), mod, SLOT( onModelClosed() ) );
536 /*!Activate module by \a modName*/
537 bool LightApp_Application::activateModule( const QString& modName )
540 CAM_Module* prevMod = activeModule();
543 actName = prevMod->moduleName();
545 QString name = modName;
546 if ( !name.isEmpty() && !moduleTitle( modName ).isEmpty() )
547 name = moduleTitle( modName );
549 if ( actName == name )
552 putInfo( tr( "ACTIVATING_MODULE" ).arg( name ) );
554 saveDockWindowsState();
557 infoPanel()->clear();
559 bool status = CAM_Application::activateModule( name );
561 updateModuleActions();
569 updateViewManagers();
571 if ( activeStudy() && activeStudy()->root() && objectBrowser() ) {
572 if ( objectBrowser()->root() != activeStudy()->root() )
573 objectBrowser()->setRoot( activeStudy()->root() );
574 updateObjectBrowser( true );
577 if ( activeModule() ) activeModule()->updateModuleVisibilityState();
583 /*!Gets selection manager.*/
584 LightApp_SelectionMgr* LightApp_Application::selectionMgr() const
589 /*!Creat action "New window" for certain type of viewer:*/
590 void LightApp_Application::createActionForViewer( const int id,
592 const QString& suffix,
595 QString vtlt = tr( QString( "NEW_WINDOW_%1" ).arg( suffix ).toLatin1().constData() );
596 QString tip = tr( "CREATING_NEW_WINDOW" ).arg( vtlt.remove( "&" ) );
597 QAction* a = createAction( id, // menu action id
604 false, // toggle flag
606 SLOT( onNewWindow() ) ); // slot
607 createMenu( a, parentId, -1 );
612 void LightApp_Application::createActions()
614 CAM_Application::createActions();
616 SUIT_Desktop* desk = desktop();
617 SUIT_ResourceMgr* resMgr = resourceMgr();
620 createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIcon(),
621 tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
622 Qt::CTRL+Qt::Key_P, desk, false, this, SLOT( onPreferences() ) );
626 int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
628 int id = LightApp_Application::UserID + FIRST_HELP_ID;
632 // a) Link to web site
634 url = resMgr->stringValue("GUI", "site_url");
635 if ( !url.isEmpty() ) {
636 QString title = tr ( "SALOME_SITE" );
637 QAction* as = createAction( WebSiteId, title,
638 resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ),
640 0, desk, false, this, SLOT( onHelpContentsModule() ) );
642 createMenu( as, helpMenu, -1, 0 );
647 if ( HAS_FORUM_URL ) {
648 url = resMgr->stringValue("GUI", "forum_url");
649 if ( !url.isEmpty() ) {
650 QString title = tr ( "SALOME_FORUM" );
651 QAction* af = createAction( ForumId, title,
652 resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ),
654 0, desk, false, this, SLOT( onHelpContentsModule() ) );
656 createMenu( af, helpMenu, -1, 0 );
660 // c) Link to YouTube channel
661 if ( HAS_YOUTUBE_URL ) {
662 url = resMgr->stringValue("GUI", "channel_url");
663 if ( !url.isEmpty() ) {
664 createMenu( separator(), helpMenu, -1, 0 );
665 QString title = tr ( "SALOME_VIDEO_TUTORIALS" );
666 QAction* av = createAction( VideosId, title,
667 resMgr->loadPixmap( "LightApp", tr( "ICON_LIFE_RIGN" ), false ),
668 title, tr( "PRP_SALOME_VIDEO_TUTORIALS" ),
669 0, desk, false, this, SLOT( onHelpContentsModule() ) );
671 createMenu( av, helpMenu, -1, 0 );
675 // d) Link to Tutorials
676 if ( HAS_TUTORIAL_URL ) {
677 url = resMgr->stringValue("GUI", "tutorials_url");
678 if ( !url.isEmpty() ) {
679 QString title = tr ( "SALOME_TUTORIALS" );
680 QAction* as = createAction( TutorialsId, title,
681 resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ),
682 title, tr( "PRP_SALOME_TUTORIALS" ),
683 0, desk, false, this, SLOT( onHelpContentsModule() ) );
685 createMenu( as, helpMenu, -1, 0 );
689 // e) Help for modules
691 // - First create top-level menus to preserve correct order
692 QString userGuide = "User's Guide";
693 QString devGuide = "Developer's Guide";
694 createMenu( userGuide, helpMenu, -1, 5 );
695 createMenu( devGuide, helpMenu, -1, 5 );
697 QStringList aModuleList;
698 modules( aModuleList, false );
699 aModuleList.prepend( "GUI" );
700 aModuleList.prepend( "KERNEL" );
703 foreach( aModule, aModuleList ) {
704 if ( aModule.isEmpty() ) // module title (user name)
706 IMap <QString, QString> helpData; // list of help files for the module
707 QString helpSubMenu; // help submenu name (empty if not needed)
708 QString modName = moduleName( aModule ); // module name
709 if ( modName.isEmpty() ) modName = aModule; // for KERNEL and GUI
710 QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName ); // module root dir env variable
711 QString modDir = Qtx::getenv( rootDir.toUtf8().constData() ); // module root dir path
713 if (resMgr->hasValue( modName, "documentation" ) )
714 docSection = resMgr->stringValue(modName, "documentation");
715 else if ( resMgr->hasSection( modName + "_documentation" ) )
716 docSection = modName + "_documentation";
717 if ( !docSection.isEmpty() ) {
718 helpSubMenu = resMgr->stringValue( docSection, "sub_menu", "" );
719 if ( helpSubMenu.contains( "%1" ) )
720 helpSubMenu = helpSubMenu.arg( aModule );
721 foreach( QString paramName, resMgr->parameters( docSection ) ) {
722 QString key = paramName.contains( "%1" ) ? paramName.arg( aModule ) : paramName;
723 QString helpItem = getHelpItem( docSection, paramName );
724 if ( !helpItem.isEmpty() )
725 helpData.insert( key, helpItem );
729 if ( helpData.isEmpty() && !modDir.isEmpty() ) {
730 QStringList idxLst = QStringList() << modDir << "share" << "doc" << "salome" << "gui" << modName << "index.html";
731 QString indexFile = idxLst.join( QDir::separator() ); // index file
732 if ( QFile::exists( indexFile ) )
733 helpData.insert( tr( "%1 module Users's Guide" ).arg( aModule ), indexFile );
736 IMapConstIterator<QString, QString > fileIt;
737 for ( fileIt = helpData.begin(); fileIt != helpData.end(); fileIt++ ) {
738 QString helpItemPath = fileIt.key();
739 // remove all '//' occurances
740 while ( helpItemPath.contains( "//" ) )
741 helpItemPath.replace( "//", "" );
742 // obtain submenus hierarchy if given
743 QStringList smenus = helpItemPath.split( "/" );
744 helpItemPath = smenus.takeLast();
745 // workaround for User's Guide and Developer's Guide to avoid having single item in module's submenu.
746 if ( helpItemPath == userGuide || helpItemPath == devGuide ) {
747 QString menuPath = smenus.join( "/" );
748 QStringList allKeys = helpData.keys();
749 QStringList total = allKeys.filter( QRegExp( QString( "^%1" ).arg( menuPath ) ) );
750 if ( total.count() == 1 && smenus.count() > 0 )
751 helpItemPath = smenus.takeLast();
753 QPixmap helpIcon = fileIt.value().startsWith( "http", Qt::CaseInsensitive ) ?
754 resMgr->loadPixmap( "STD", tr( "ICON_WWW" ), false ) : resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false );
755 QAction* a = createAction( id, helpItemPath, helpIcon, helpItemPath, helpItemPath,
756 0, desk, false, this, SLOT( onHelpContentsModule() ) );
757 a->setData( fileIt.value() );
758 if ( !helpSubMenu.isEmpty() ) {
759 smenus.prepend( helpSubMenu );
761 // create sub-menus hierarchy
762 int menuId = helpMenu;
763 foreach ( QString subMenu, smenus )
764 menuId = createMenu( subMenu, menuId, -1, 5 );
765 createMenu( a, menuId, -1, ( menuId != helpMenu && (helpItemPath == userGuide || helpItemPath == devGuide) ) ? 0 : 5 );
770 // - Additional help items
772 createMenu( separator(), helpMenu, -1, 10 );
774 QStringList addHelpItems = resMgr->parameters( "add_help" );
775 foreach ( QString paramName, addHelpItems ) {
776 QString helpItem = getHelpItem( "add_help", paramName );
777 if ( !helpItem.isEmpty() )
779 QPixmap helpIcon = helpItem.startsWith( "http", Qt::CaseInsensitive ) ?
780 resMgr->loadPixmap( "STD", tr( "ICON_WWW" ), false ) : resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false );
781 QAction* a = createAction( id++, paramName, helpIcon, paramName, paramName,
782 0, desk, false, this, SLOT( onHelpContentsModule() ) );
783 a->setData( helpItem );
784 createMenu( a, helpMenu, -1, 10 );
789 static QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), 0 );
790 connect( mru, SIGNAL( activated( const QString& ) ), this, SLOT( onMRUActivated( const QString& ) ) );
791 registerAction( MRUId, mru );
793 // default icon for neutral point ('SALOME' module)
794 QPixmap defIcon = resMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
795 if ( defIcon.isNull() )
796 defIcon = QPixmap( imageEmptyIcon );
798 //! default icon for any module
799 QPixmap modIcon = resMgr->loadPixmap( "LightApp", tr( "APP_MODULE_ICO" ), false );
800 if ( modIcon.isNull() )
801 modIcon = QPixmap( imageEmptyIcon );
804 modules( modList, false );
806 if ( modList.count() > 1 )
808 LightApp_ModuleAction* moduleAction =
809 new LightApp_ModuleAction( tr( "APP_NAME" ), defIcon, desk );
811 QMap<QString, QString> iconMap;
812 moduleIconNames( iconMap );
814 const int iconSize = 20;
816 QStringList::Iterator it;
817 for ( it = modList.begin(); it != modList.end(); ++it )
819 QString modName = moduleName( *it );
822 if ( iconMap.contains( *it ) )
823 iconName = iconMap[*it];
825 QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
830 "****************************************************************" << std::endl <<
831 " Warning: icon for " << qPrintable(*it) << " is not found!" << std::endl <<
832 " Using the default icon." << std::endl <<
833 "****************************************************************" << std::endl);
835 icon = Qtx::scaleIcon( icon, iconSize );
837 moduleAction->insertModule( *it, icon );
840 connect( moduleAction, SIGNAL( moduleActivated( const QString& ) ),
841 this, SLOT( onModuleActivation( const QString& ) ) );
842 registerAction( ModulesListId, moduleAction );
846 int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, MenuWindowId, 100 );
847 int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
849 createAction( CloseId, tr( "TOT_CLOSE" ), QIcon(), tr( "MEN_DESK_CLOSE" ), tr( "PRP_CLOSE" ),
850 Qt::CTRL+Qt::Key_F4, desk, false, this, SLOT( onCloseWindow() ) );
851 createAction( CloseAllId, tr( "TOT_CLOSE_ALL" ), QIcon(), tr( "MEN_DESK_CLOSE_ALL" ), tr( "PRP_CLOSE_ALL" ),
852 0, desk, false, this, SLOT( onCloseAllWindow() ) );
853 createAction( GroupAllId, tr( "TOT_GROUP_ALL" ), QIcon(), tr( "MEN_DESK_GROUP_ALL" ), tr( "PRP_GROUP_ALL" ),
854 0, desk, false, this, SLOT( onGroupAllWindow() ) );
856 createMenu( CloseId, windowMenu, 0, -1 );
857 createMenu( CloseAllId, windowMenu, 0, -1 );
858 createMenu( GroupAllId, windowMenu, 0, -1 );
859 createMenu( separator(), windowMenu, -1, 0 );
861 #ifndef DISABLE_GLVIEWER
862 createActionForViewer( NewGLViewId, newWinMenu, QString::number( 0 ), Qt::ALT+Qt::Key_G );
864 #ifndef DISABLE_PLOT2DVIEWER
865 createActionForViewer( NewPlot2dId, newWinMenu, QString::number( 1 ), Qt::ALT+Qt::Key_P );
867 #ifndef DISABLE_OCCVIEWER
868 createActionForViewer( NewOCCViewId, newWinMenu, QString::number( 2 ), Qt::ALT+Qt::Key_O );
870 #ifndef DISABLE_VTKVIEWER
871 createActionForViewer( NewVTKViewId, newWinMenu, QString::number( 3 ), Qt::ALT+Qt::Key_K );
873 #ifndef DISABLE_QXGRAPHVIEWER
874 createActionForViewer( NewQxSceneViewId, newWinMenu, QString::number( 4 ), Qt::ALT+Qt::Key_S );
876 #ifndef DISABLE_GRAPHICSVIEW
877 createActionForViewer( NewGraphicsViewId, newWinMenu, QString::number( 5 ), Qt::ALT+Qt::Key_C );
879 #ifndef DISABLE_PVVIEWER
880 createActionForViewer( NewPVViewId, newWinMenu, QString::number( 6 ), Qt::ALT+Qt::Key_A );
882 #ifndef DISABLE_PYVIEWER
883 createActionForViewer( NewPyViewerId, newWinMenu, QString::number( 7 ), Qt::ALT+Qt::Key_Y );
886 createAction( RenameId, tr( "TOT_RENAME" ), QIcon(), tr( "MEN_DESK_RENAME" ), tr( "PRP_RENAME" ),
887 Qt::ALT+Qt::SHIFT+Qt::Key_R, desk, false, this, SLOT( onRenameWindow() ) );
888 createMenu( RenameId, windowMenu, -1 );
890 int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
891 createMenu( PreferencesId, fileMenu, 50, -1 );
892 createMenu( separator(), fileMenu, -1, 50, -1 );
894 createMenu( separator(), fileMenu, -1, 100, -1 );
895 createMenu( MRUId, fileMenu, 100, -1 );
896 createMenu( separator(), fileMenu, -1, 100, -1 );
898 #ifdef USE_SALOME_STYLE
899 createAction( StyleId, tr( "TOT_THEME" ), QIcon(), tr( "MEN_DESK_THEME" ), tr( "PRP_THEME" ),
900 0, desk, false, this, SLOT( onStylePreferences() ) );
901 #endif // USE_SALOME_STYLE
903 createAction( FullScreenId, tr( "TOT_FULLSCREEN" ), QIcon(), tr( "MEN_DESK_FULLSCREEN" ), tr( "PRP_FULLSCREEN" ),
904 Qt::Key_F11, desk, false, this, SLOT( onFullScreen() ) );
907 int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1 );
908 createMenu( separator(), viewMenu, -1, 20, -1 );
909 #ifdef USE_SALOME_STYLE
910 createMenu( StyleId, viewMenu, 20, -1 );
911 #endif // USE_SALOME_STYLE
912 createMenu( FullScreenId, viewMenu, 20, -1 );
914 int modTBar = createTool( tr( "INF_TOOLBAR_MODULES" ), // title (language-dependant)
915 QString( "SalomeModules" ) ); // name (language-independant)
916 createTool( ModulesListId, modTBar );
919 /*!On module activation action.*/
920 void LightApp_Application::onModuleActivation( const QString& modName )
922 // Force user to create/open a study before module activation
923 QMap<QString, QString> iconMap;
924 moduleIconNames( iconMap );
925 QPixmap icon = resourceMgr()->loadPixmap( moduleName( modName ), iconMap[ modName ], false );
927 icon = resourceMgr()->loadPixmap( "LightApp", tr( "APP_MODULE_BIG_ICO" ), false ); // default icon for any module
929 bool cancelled = false;
931 while ( !modName.isEmpty() && !activeStudy() && !cancelled ){
932 LightApp_ModuleDlg aDlg( desktop(), modName, icon );
933 QMap<int, QString> opmap = activateModuleActions();
934 for ( QMap<int, QString>::ConstIterator it = opmap.begin(); it != opmap.end(); ++it )
935 aDlg.addButton( it.value(), it.key() );
937 int res = aDlg.exec();
939 // some operation is selected
940 moduleActionSelected( res );
944 putInfo( tr("INF_CANCELLED") );
946 LightApp_ModuleAction* moduleAction =
947 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
949 moduleAction->setActiveModule( QString() );
955 activateModule( modName );
958 /*!Default module activation.*/
959 QString LightApp_Application::defaultModule() const
961 QStringList aModuleNames;
962 modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration
963 //! If there's the one and only module --> activate it automatically
964 //! TODO: Possible improvement - default module can be taken from preferences
965 return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" );
968 /*!On new window slot.*/
969 void LightApp_Application::onNewWindow()
971 const QObject* obj = sender();
972 if ( !obj || !obj->inherits( "QAction" ) )
976 int id = actionId( (QAction*)obj );
979 #ifndef DISABLE_GLVIEWER
981 type = GLViewer_Viewer::Type();
984 #ifndef DISABLE_PLOT2DVIEWER
986 type = Plot2d_Viewer::Type();
989 #ifndef DISABLE_OCCVIEWER
991 type = OCCViewer_Viewer::Type();
994 #ifndef DISABLE_VTKVIEWER
996 type = VTKViewer_Viewer::Type();
999 #ifndef DISABLE_QXGRAPHVIEWER
1000 case NewQxSceneViewId:
1001 type = QxScene_Viewer::Type();
1004 #ifndef DISABLE_GRAPHICSVIEW
1005 case NewGraphicsViewId:
1006 type = GraphicsView_Viewer::Type();
1009 #ifndef DISABLE_PVVIEWER
1011 type = PVViewer_Viewer::Type();
1014 #ifndef DISABLE_PYVIEWER
1016 type = PyViewer_Viewer::Type();
1021 if ( !type.isEmpty() )
1022 createViewManager( type );
1026 SLOT: Creates new document
1028 void LightApp_Application::onNewDoc()
1030 if ( !checkExistingDoc() )
1033 //asl: fix for 0020515
1034 saveDockWindowsState();
1036 CAM_Application::onNewDoc();
1040 SLOT: Opens new document
1042 void LightApp_Application::onOpenDoc()
1044 SUIT_Study* study = activeStudy();
1046 if ( !checkExistingDoc( false ) )
1049 QString aName = getFileName( true, QString(), getFileFilter( true ), QString(), 0 );
1050 if ( aName.isNull() ) //Cancel
1055 if ( !study ) // new study will be create in THIS application
1058 updateViewManagers();
1062 bool LightApp_Application::canOpenDoc( const QString& )
1068 SLOT: Opens new document.
1069 \param aName - name of file
1071 bool LightApp_Application::onOpenDoc( const QString& aName )
1073 if ( !canOpenDoc(aName)) {
1074 bool showError = !property("open_study_from_command_line").isValid() ||
1075 !property("open_study_from_command_line").toBool();
1077 putInfo( tr("OPEN_DOCUMENT_PROBLEM") );
1079 SUIT_MessageBox::critical( desktop(), tr("ERR_ERROR"), tr("OPEN_DOCUMENT_PROBLEM"));
1086 if ( !checkExistingDoc() )
1089 saveDockWindowsState();
1091 // We should take mru action first because this application instance can be deleted later.
1092 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
1094 bool res = CAM_Application::onOpenDoc( aName );
1099 mru->insert( aName );
1101 mru->remove( aName );
1107 SLOT: Displays "About" message box
1109 void LightApp_Application::onHelpAbout()
1111 LightApp_AboutDlg dlg( applicationName(), applicationVersion(), desktop() );
1116 Private SLOT: Called on selection is changed
1117 Dispatchs active module that selection is changed
1119 void LightApp_Application::onSelection()
1121 //MESSAGE("onSelection")
1122 onSelectionChanged();
1124 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
1125 ((LightApp_Module*)activeModule())->selectionChanged();
1130 \param study - SUIT_Study.
1132 void LightApp_Application::setActiveStudy( SUIT_Study* study )
1134 CAM_Application::setActiveStudy( study );
1138 Enables/Disables menu items and toolbar buttons. Rebuild menu
1140 void LightApp_Application::updateCommandsStatus()
1142 CAM_Application::updateCommandsStatus();
1145 #ifndef DISABLE_GLVIEWER
1146 a = action( NewGLViewId );
1148 a->setEnabled( activeStudy() );
1151 #ifndef DISABLE_PLOT2DVIEWER
1152 a = action( NewPlot2dId );
1154 a->setEnabled( activeStudy() );
1157 #ifndef DISABLE_OCCVIEWER
1158 a = action( NewOCCViewId );
1160 a->setEnabled( activeStudy() );
1163 #ifndef DISABLE_VTKVIEWER
1164 a = action( NewVTKViewId );
1166 a->setEnabled( activeStudy() );
1169 #ifndef DISABLE_QXGRAPHVIEWER
1170 a = action( NewQxSceneViewId );
1172 a->setEnabled( activeStudy() );
1175 #ifndef DISABLE_GRAPHICSVIEW
1176 a = action( NewGraphicsViewId );
1178 a->setEnabled( activeStudy() );
1181 #ifndef DISABLE_PVVIEWER
1182 a = action( NewPVViewId );
1184 a->setEnabled( activeStudy() );
1187 #ifndef DISABLE_PYVIEWER
1188 a = action( NewPyViewerId );
1190 a->setEnabled( activeStudy() );
1196 Runs system command in separate thread
1198 class RunBrowser: public QThread
1201 static void execute( LightApp_Application* application,
1202 const QString& browser,
1203 const QString& parameters,
1204 const QString& url )
1206 (new RunBrowser( application, browser, parameters, url ))->start();
1210 RunBrowser( LightApp_Application* application,
1211 const QString& browser,
1212 const QString& parameters,
1214 : myApplication( application ),
1215 myBrowser( browser ),
1216 myParameters( parameters ),
1219 if ( !myUrl.startsWith( "http", Qt::CaseInsensitive ) )
1222 if ( myUrl.startsWith( "file://", Qt::CaseInsensitive ) )
1223 myUrl = myUrl.remove( 0, QString( "file://" ).count() );
1224 // For the external browser we always specify 'file://' protocol,
1225 // because some web browsers (e.g. Mozilla Firefox) can't open local file without protocol.
1226 myUrl = myUrl.prepend( "file://" );
1228 connect(this, SIGNAL(finished()), SLOT(deleteLater()));
1233 if ( !myBrowser.isEmpty() && !myUrl.isEmpty() )
1235 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
1237 QString cmdLine = QString( "\"%1\" %2 \"%3\"" ).arg( myBrowser, myParameters, myUrl );
1239 QString cmdLine = QString( "%1 %2 \"%3\"" ).arg( myBrowser, myParameters, myUrl );
1240 // remove LD_LIBRARY_PATH from the environement before starting launcher to avoid bad interactions.
1241 // (especially in the case of universal binaries)
1242 env.remove("LD_LIBRARY_PATH");
1244 QProcess* proc = new QProcess();
1245 proc->setProcessEnvironment(env);
1246 proc->start( cmdLine );
1247 if ( !proc->waitForStarted() )
1249 SALOME_CustomEvent* ce2000 = new SALOME_CustomEvent( 2000 );
1250 QString* msg = new QString( QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).arg( myBrowser, myUrl ) );
1251 ce2000->setData( msg );
1252 QApplication::postEvent( myApplication, ce2000 );
1258 LightApp_Application* myApplication;
1260 QString myParameters;
1264 void LightApp_Application::showHelp( const QString& path )
1266 SUIT_ResourceMgr* resMgr = resourceMgr();
1268 #if DISABLE_QTXWEBBROWSER
1269 bool useExternalBrowser = true;
1271 bool useExternalBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1274 if ( useExternalBrowser )
1277 QString browser = resMgr->stringValue( "ExternalBrowser", "winapplication" ) ;
1279 QString browser = resMgr->stringValue( "ExternalBrowser", "application" );
1281 QString parameters = resMgr->stringValue("ExternalBrowser", "parameters");
1283 if ( !browser.isEmpty() )
1285 RunBrowser::execute( this, browser, parameters, path );
1289 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1290 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1291 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1294 path << tr( "PREF_CATEGORY_SALOME" ) << tr( "PREF_TAB_GENERAL" )
1295 << tr( "PREF_GROUP_EXT_BROWSER" ) << tr( "PREF_APP" );
1296 showPreferences( path );
1302 QStringList cmdLine;
1303 cmdLine << QString( "--language=%1" ).arg( resMgr->stringValue( "language", "language" ) );
1304 cmdLine << QString( "--add=%1" ).arg( QApplication::instance()->applicationPid() );
1306 QProcess::startDetached( "HelpBrowser", cmdLine );
1311 SLOT: Displays help contents for choosen module
1313 void LightApp_Application::onHelpContentsModule()
1315 const QAction* a = (QAction*) sender();
1316 QString helpFile = a->data().toString();
1317 if ( !helpFile.isEmpty() )
1318 showHelp( helpFile );
1322 SLOT: Displays contextual help (e.g. for choosen dialog)
1324 void LightApp_Application::onHelpContextModule( const QString& component,
1326 const QString& context )
1329 if ( !url.startsWith( "http", Qt::CaseInsensitive ) )
1332 QFileInfo fi( url );
1333 if ( fi.isRelative() && !component.isEmpty() )
1335 QString rootDir = Qtx::getenv( (component + "_ROOT_DIR").toLatin1().constData() );
1336 if ( !rootDir.isEmpty() )
1338 path = (QStringList() << rootDir << "share" << "doc" << "salome" << "gui" << component << url).join( QDir::separator() );
1342 if ( !context.isEmpty() )
1344 path += QString( "#%1" ).arg( context );
1350 Sets enable or disable some actions on selection changed.
1352 void LightApp_Application::onSelectionChanged()
1354 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
1355 bool canCopy = m ? m->canCopy() : false;
1356 bool canPaste = m ? m->canPaste() : false;
1358 action( EditCopyId )->setEnabled(canCopy);
1359 action( EditPasteId )->setEnabled(canPaste);
1363 SLOT: Performs some actions when dockable windows are triggered
1365 void LightApp_Application::onDockWindowVisibilityChanged( bool )
1369 QWidget* LightApp_Application::dockWindow( const int id ) const
1372 if ( myWin.contains( id ) )
1377 QDockWidget* LightApp_Application::windowDock( QWidget* wid ) const
1382 QDockWidget* dock = 0;
1383 QWidget* w = wid->parentWidget();
1384 while ( w && !dock )
1386 dock = ::qobject_cast<QDockWidget*>( w );
1387 w = w->parentWidget();
1392 void LightApp_Application::insertDockWindow( const int id, QWidget* wid )
1397 if ( wid != dockWindow( id ) )
1398 removeDockWindow( id );
1400 myWin.insert( id, wid );
1402 QtxDockWidget* dock = new QtxDockWidget( true, desktop() );
1403 if ( id == WT_InfoPanel ) {
1404 // Info panel's position is strongly limited to the right area;
1405 // It is not movable and not floatable.
1406 dock->setAllowedAreas( Qt::RightDockWidgetArea );
1407 dock->setFeatures( QDockWidget::DockWidgetClosable );
1408 connect( dock, SIGNAL( aboutToShow()), this, SLOT( onInfoPanelShown() ) );
1411 dock->setFeatures( QDockWidget::AllDockWidgetFeatures );
1413 connect( dock, SIGNAL( destroyed( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
1415 dock->setObjectName( wid->objectName().isEmpty() ? QString( "window_%1" ).arg( id ) :
1416 QString( "%1Dock" ).arg( wid->objectName() ) );
1417 dock->setWidget( wid );
1418 dock->toggleViewAction()->setData( QVariant( wid->objectName() ) );
1419 connect( dock->toggleViewAction(), SIGNAL( triggered( bool ) ),
1420 this, SLOT( onDockWindowVisibilityChanged( bool ) ) );
1422 QKeySequence accel = wid->property( "shortcut" ).value<QKeySequence>();
1423 if ( !accel.isEmpty() )
1424 dock->toggleViewAction()->setShortcut( accel );
1429 void LightApp_Application::removeDockWindow( const int id )
1431 QWidget* wid = dockWindow( id );
1437 QDockWidget* dock = windowDock( wid );
1441 dock->setWidget( 0 );
1442 wid->setParent( 0 );
1443 wid->setVisible( false );
1447 void LightApp_Application::placeDockWindow( const int id, Qt::DockWidgetArea place )
1449 QDockWidget* dock = windowDock( dockWindow( id ) );
1450 if ( dock && desktop() ) {
1451 desktop()->addDockWidget( place, dock );
1452 QtxDockAction* a = qobject_cast<QtxDockAction*>( action( ViewWindowsId ) );
1453 if ( a ) a->update();
1459 \param flag - key for window
1460 Flag used how identificator of window in windows list.
1462 QWidget* LightApp_Application::getWindow( const int flag)
1464 QWidget* wid = dockWindow( flag );
1466 insertDockWindow( flag, wid = createWindow( flag ) );
1468 QMap<int, int> winMap;
1469 currentWindows( winMap );
1470 if ( winMap.contains( flag ) )
1471 placeDockWindow( flag, (Qt::DockWidgetArea)winMap[flag] );
1477 \return Object Browser
1479 SUIT_DataBrowser* LightApp_Application::objectBrowser()
1481 return qobject_cast<SUIT_DataBrowser*>( dockWindow( WT_ObjectBrowser ) );
1484 QtxInfoPanel* LightApp_Application::infoPanel()
1486 return qobject_cast<QtxInfoPanel *>( dockWindow( WT_InfoPanel ));
1492 LogWindow* LightApp_Application::logWindow()
1494 return qobject_cast<LogWindow*>( dockWindow( WT_LogWindow ) );
1497 #ifndef DISABLE_PYCONSOLE
1499 This returns the python console integrated to the GUI. Depending
1500 when you request the python console, this function could return
1501 null. Then the optional parameter force (default to false) can be
1502 set to force the creation of the python console if it is not done
1504 \param force - if true, the pythonConsole is created if it does not exist yet
1505 \return Python Console
1507 PyConsole_Console* LightApp_Application::pythonConsole(const bool force)
1509 QWidget* wid = dockWindow( WT_PyConsole );
1510 if ( !wid && force==true) {
1511 wid = getWindow(WT_PyConsole);
1513 return qobject_cast<PyConsole_Console*>( wid );
1518 Updates object browser and maybe data models
1519 \param updateModels - if it is true, then data models are updated
1521 void LightApp_Application::updateObjectBrowser( const bool updateModels )
1523 // update existing data models
1526 const bool isAutoUpdate = objectBrowser() ? objectBrowser()->autoUpdate() : true;
1527 if ( objectBrowser() )
1528 objectBrowser()->setAutoUpdate( false );
1530 LightApp_Study* study = dynamic_cast<LightApp_Study*>(activeStudy());
1532 CAM_Study::ModelList dm_list;
1533 study->dataModels( dm_list );
1534 QListIterator<CAM_DataModel*> it( dm_list );
1535 while ( it.hasNext() ) {
1536 CAM_DataModel* camDM = it.next();
1537 if ( camDM && camDM->inherits( "LightApp_DataModel" ) )
1538 ((LightApp_DataModel*)camDM)->update();
1542 if( objectBrowser() )
1543 objectBrowser()->setAutoUpdate( isAutoUpdate );
1546 if ( objectBrowser() ) {
1547 objectBrowser()->updateGeometry();
1548 objectBrowser()->updateTree( 0, false );
1555 LightApp_Preferences* LightApp_Application::preferences() const
1557 return preferences( false );
1561 \return first view manager of some type
1562 \param vmType - type of view manager
1563 \param create - is it necessary to create view manager in case, when there is no manager of such type
1565 SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, const bool create )
1567 SUIT_ViewManager* aVM = viewManager( vmType );
1568 SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
1569 MESSAGE("vmType: " << vmType.toStdString() << " aVM: " << aVM << " anActiveVM: " << anActiveVM );
1570 if ( anActiveVM && anActiveVM->getType() == vmType )
1572 MESSAGE("aVM = anActiveVM");
1576 bool keepDetached = property("keep_detached").toBool();
1577 if ( aVM && (!aVM->getDetached() || keepDetached) && create )
1579 if ( !aVM->getActiveView() )
1581 MESSAGE("aVM->createView()");
1586 MESSAGE("desktop()->setActiveWindow: " << aVM->getActiveView());
1587 desktop()->setActiveWindow( aVM->getActiveView() );
1592 MESSAGE("aVM = createViewManager( vmType )");
1593 aVM = createViewManager( vmType );
1600 Creates view manager of some type
1601 \param vmType - type of view manager
1603 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, bool detached )
1605 SUIT_ResourceMgr* resMgr = resourceMgr();
1607 SUIT_ViewManager* viewMgr = 0;
1608 #ifndef DISABLE_GLVIEWER
1609 if( vmType == GLViewer_Viewer::Type() )
1611 viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() );
1612 new LightApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
1615 #ifndef DISABLE_PLOT2DVIEWER
1616 if( vmType == Plot2d_Viewer::Type() )
1618 viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
1620 #ifndef DISABLE_SALOMEOBJECT
1621 SPlot2d_Viewer* v = new SPlot2d_Viewer();
1623 new LightApp_Plot2dSelector( v, mySelMgr );
1625 vm = new Plot2d_Viewer();
1627 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1628 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
1631 Plot2d_ViewFrame* frame = wnd->getViewFrame();
1632 frame->setBackgroundColor( resMgr->colorValue( "Plot2d", "Background", frame->backgroundColor() ) );
1636 #ifndef DISABLE_QXGRAPHVIEWER
1637 if( vmType == QxScene_Viewer::Type() )
1639 viewMgr = new QxScene_ViewManager( activeStudy(), desktop() );
1640 QxScene_Viewer* vm = new QxScene_Viewer();
1641 viewMgr->setViewModel( vm );
1642 //QxScene_ViewWindow* wnd = dynamic_cast<QxScene_ViewWindow*>( viewMgr->getActiveView() );
1645 #ifndef DISABLE_GRAPHICSVIEW
1646 if( vmType == GraphicsView_Viewer::Type() )
1648 viewMgr = new GraphicsView_ViewManager( activeStudy(), desktop() );
1649 new LightApp_GVSelector( (GraphicsView_Viewer*)viewMgr->getViewModel(), mySelMgr );
1652 #ifndef DISABLE_PVVIEWER
1653 if( vmType == PVViewer_Viewer::Type() )
1655 if (( viewMgr = dynamic_cast<PVViewer_ViewManager*>( getViewManager( vmType, false )))) {
1656 viewMgr->getActiveView()->setFocus();
1659 viewMgr = new PVViewer_ViewManager( activeStudy(), desktop() );
1663 #ifndef DISABLE_PYVIEWER
1664 if( vmType == PyViewer_Viewer::Type() )
1666 viewMgr = new PyViewer_ViewManager( activeStudy(), desktop() );
1669 #ifndef DISABLE_OCCVIEWER
1670 if( vmType == OCCViewer_Viewer::Type() )
1672 viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
1673 OCCViewer_Viewer* vm;
1674 #ifndef DISABLE_SALOMEOBJECT
1675 vm = new SOCC_Viewer();
1677 vm = new OCCViewer_Viewer( true );
1679 vm->setBackground( OCCViewer_ViewFrame::TOP_LEFT,
1680 resMgr->backgroundValue( "OCCViewer", "xz_background", vm->background(OCCViewer_ViewFrame::TOP_LEFT) ) );
1681 vm->setBackground( OCCViewer_ViewFrame::TOP_RIGHT,
1682 resMgr->backgroundValue( "OCCViewer", "yz_background", vm->background(OCCViewer_ViewFrame::TOP_RIGHT) ) );
1683 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_LEFT,
1684 resMgr->backgroundValue( "OCCViewer", "xy_background", vm->background(OCCViewer_ViewFrame::BOTTOM_LEFT) ) );
1685 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_RIGHT,
1686 resMgr->backgroundValue( "OCCViewer", "background", vm->background(OCCViewer_ViewFrame::MAIN_VIEW) ) );
1688 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1689 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ));
1690 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1691 vm->setProjectionType( resMgr->integerValue( "OCCViewer", "projection_mode", vm->projectionType() ) );
1692 vm->setStereoType( resMgr->integerValue( "OCCViewer", "stereo_type", vm->stereoType() ) );
1693 vm->setAnaglyphFilter( resMgr->integerValue( "OCCViewer", "anaglyph_filter", vm->anaglyphFilter() ) );
1694 vm->setStereographicFocus( resMgr->integerValue( "OCCViewer", "focus_type", vm->stereographicFocusType() ),
1695 resMgr->doubleValue( "OCCViewer", "focus_value", vm->stereographicFocusValue() ));
1696 vm->setInterocularDistance( resMgr->integerValue( "OCCViewer", "iod_type", vm->interocularDistanceType() ),
1697 resMgr->doubleValue( "OCCViewer", "iod_value", vm->interocularDistanceValue() ));
1698 vm->setSelectionStyle((OCCViewer_ViewWindow::SelectionStyle) resMgr->integerValue( "OCCViewer", "adv_selection_mode", vm->selectionStyle() ) );
1700 vm->setReverseStereo( resMgr->booleanValue( "OCCViewer", "reverse_stereo", vm->isReverseStereo() ) );
1701 vm->setVSync( resMgr->booleanValue( "OCCViewer", "enable_vsync", vm->isVSync() ) );
1702 vm->setQuadBufferSupport( resMgr->booleanValue( "OCCViewer", "enable_quad_buffer_support", vm->isQuadBufferSupport() ) );
1703 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1704 vm->enablePreselection( resMgr->booleanValue( "OCCViewer", "enable_preselection", vm->isPreselectionEnabled() ) );
1705 vm->enableSelection( resMgr->booleanValue( "OCCViewer", "enable_selection", vm->isSelectionEnabled() ) );
1706 vm->setClippingColor( resMgr->colorValue( "OCCViewer", "clipping_color", vm->clippingColor() ) );
1707 vm->setClippingTextureParams( resMgr->booleanValue( "OCCViewer", "clipping_use_default_texture", vm->isDefaultTextureUsed() ),
1708 resMgr->stringValue( "OCCViewer", "clipping_texture", vm->clippingTexture() ),
1709 resMgr->booleanValue( "OCCViewer", "clipping_modulate", vm->isTextureModulated() ),
1710 resMgr->doubleValue( "OCCViewer", "clipping_scale", vm->clippingTextureScale() ) );
1713 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1714 new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
1717 #ifndef DISABLE_VTKVIEWER
1718 #ifndef DISABLE_SALOMEOBJECT
1719 if ( vmType == SVTK_Viewer::Type() )
1721 if ( vmType == VTKViewer_Viewer::Type() )
1724 #ifndef DISABLE_SALOMEOBJECT
1725 viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
1726 SVTK_Viewer* vm = dynamic_cast<SVTK_Viewer*>( viewMgr->getViewModel() );
1729 vm->setProjectionMode( resMgr->integerValue( "VTKViewer", "projection_mode", vm->projectionMode() ) );
1730 vm->setStereoType( resMgr->integerValue( "VTKViewer", "stereo_type", vm->stereoType() ) );
1731 vm->setAnaglyphFilter( resMgr->integerValue( "VTKViewer", "anaglyph_filter", vm->anaglyphFilter() ) );
1732 vm->setQuadBufferSupport( resMgr->booleanValue( "VTKViewer", "enable_quad_buffer_support", vm->isQuadBufferSupport() ) );
1733 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1734 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1735 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ) );
1736 vm->setStaticTrihedronVisible( resMgr->booleanValue( "3DViewer", "show_static_trihedron", vm->isStaticTrihedronVisible() ) );
1737 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1738 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1739 vm->setPreSelectionMode(resMgr->integerValue( "VTKViewer", "preselection", vm->preSelectionMode() ) );
1740 vm->enableSelection( resMgr->booleanValue( "VTKViewer", "enable_selection", vm->isSelectionEnabled() ) );
1741 vm->setIncrementalSpeed( resMgr->integerValue( "VTKViewer", "speed_value", vm->incrementalSpeed() ),
1742 resMgr->integerValue( "VTKViewer", "speed_mode", vm->incrementalSpeedMode() ) );
1743 vm->setSpacemouseButtons( resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", vm->spacemouseBtn(1) ),
1744 resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", vm->spacemouseBtn(2) ),
1745 resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", vm->spacemouseBtn(3) ) );
1746 new LightApp_VTKSelector( vm, mySelMgr );
1749 viewMgr = new VTKViewer_ViewManager( activeStudy(), desktop() );
1750 VTKViewer_Viewer* vm = dynamic_cast<VTKViewer_Viewer*>( viewMgr->getViewModel() );
1752 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1760 viewMgr->setDetached(detached);
1761 addViewManager( viewMgr );
1762 SUIT_ViewWindow* viewWin = viewMgr->createViewWindow();
1764 if ( viewWin && desktop() ) {
1765 viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1766 viewWin->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1772 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, QWidget* w )
1774 SUIT_ResourceMgr* resMgr = resourceMgr();
1776 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
1778 new LightApp_WgViewModel( vmType, w ) );
1779 vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
1781 addViewManager( vm );
1782 SUIT_ViewWindow* vw = vm->createViewWindow();
1783 if ( vw && desktop() ) {
1784 vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1785 vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1788 if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
1789 myUserWmTypes << vmType;
1794 SUIT_ViewManager* LightApp_Application::createViewManager( SUIT_ViewModel* theModel )
1796 SUIT_ResourceMgr* resMgr = resourceMgr();
1798 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
1802 QString vmType = vm->getType();
1804 vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
1806 addViewManager( vm );
1807 SUIT_ViewWindow* vw = vm->createViewWindow();
1808 if ( vw && desktop() ) {
1809 vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1810 vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1813 if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
1814 myUserWmTypes << vmType;
1820 SLOT: Removes view manager from application
1822 void LightApp_Application::onCloseView( SUIT_ViewManager* theVM )
1824 removeViewManager( theVM );
1828 Protected SLOT: On study created.
1829 \param theStudy - just created study
1831 void LightApp_Application::onStudyCreated( SUIT_Study* theStudy )
1833 SUIT_DataObject* aRoot = 0;
1834 if ( theStudy && theStudy->root() )
1836 aRoot = theStudy->root();
1837 //aRoot->setName( tr( "DATA_MODELS" ) );
1840 getWindow( WT_ObjectBrowser );
1841 getWindow( WT_InfoPanel );
1843 loadDockWindowsState();
1845 if ( objectBrowser() )
1846 objectBrowser()->setRoot( aRoot );
1848 activateModule( defaultModule() );
1850 if ( objectBrowser() )
1851 objectBrowser()->openLevels();
1853 #ifndef DISABLE_PYCONSOLE
1854 if( pythonConsole() )
1855 getPyInterp()->initStudy();
1860 Protected SLOT: On study opened.
1861 \param theStudy - just opened study
1863 void LightApp_Application::onStudyOpened( SUIT_Study* theStudy )
1865 SUIT_DataObject* aRoot = 0;
1866 if ( theStudy && theStudy->root() )
1868 aRoot = theStudy->root();
1872 getWindow( WT_ObjectBrowser );
1873 getWindow( WT_InfoPanel );
1875 loadDockWindowsState();
1877 if ( objectBrowser() )
1878 objectBrowser()->setRoot( aRoot );
1880 activateModule( defaultModule() );
1882 if ( objectBrowser() )
1883 objectBrowser()->openLevels();
1885 #ifndef DISABLE_PYCONSOLE
1886 if( pythonConsole() )
1887 getPyInterp()->initStudy();
1893 /*!Protected SLOT. On study saved.*/
1894 void LightApp_Application::onStudySaved( SUIT_Study* s )
1896 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
1898 mru->insert( s->studyName() );
1903 /*!Protected SLOT. On study closed.*/
1904 void LightApp_Application::onStudyClosed( SUIT_Study* /*s*/ )
1907 disconnect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
1908 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
1911 // stop auto-save timer
1912 myAutoSaveTimer->stop();
1914 // Bug 10396: clear selection
1915 mySelMgr->clearSelected();
1917 // Bug 12944: emit signal only after clear selection
1920 activateModule( "" );
1923 /*!Protected SLOT.On desktop activated.*/
1924 void LightApp_Application::onDesktopActivated()
1926 CAM_Application::onDesktopActivated();
1927 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>(activeModule());
1929 aModule->studyActivated();
1932 void LightApp_Application::studyOpened( SUIT_Study* s )
1934 CAM_Application::studyOpened( s );
1937 updateViewManagers();
1940 void LightApp_Application::studySaved( SUIT_Study* s )
1942 CAM_Application::studyOpened( s );
1943 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1944 if ( aResMgr && activeStudy() ) {
1945 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
1946 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
1950 void LightApp_Application::studyCreated( SUIT_Study* s )
1952 CAM_Application::studyCreated( s );
1955 updateViewManagers();
1958 /*!Gets file filter.
1959 *\retval QString "(*.hdf)"
1961 QString LightApp_Application::getFileFilter( bool /*open*/) const
1967 Shows file dialog and return user selected file name
1969 QString LightApp_Application::getFileName( bool open, const QString& initial, const QString& filters,
1970 const QString& caption, QWidget* parent )
1974 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1975 return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
1978 /*! Gets directory*/
1979 QString LightApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
1983 return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true );
1986 /*! Get open file names*/
1987 QStringList LightApp_Application::getOpenFileNames( const QString& initial, const QString& filters,
1988 const QString& caption, QWidget* parent )
1992 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1993 return SUIT_FileDlg::getOpenFileNames( parent, initial, fls, caption, true );
1996 /*!Private SLOT. Update object browser.*/
1997 void LightApp_Application::onRefresh()
1999 updateObjectBrowser( true );
2002 /*!Private SLOT. Update actions after rename object.*/
2003 void LightApp_Application::onRenamed()
2005 activeStudy()->Modified();
2009 // IMN 08.07.2015 : issue 002556: Some stereo outputs are affected by window position.
2010 // To prevent reversion the window should be either aligned during movement and resize.
2011 /*!Private SLOT. Update actions after rename object.*/
2012 /*void LightApp_Application::onMoved()
2014 OCCViewer_ViewManager* viewMgr = 0;
2015 viewMgr = dynamic_cast<OCCViewer_ViewManager*>( getViewManager( OCCViewer_Viewer::Type(), false ) );
2017 OCCViewer_ViewWindow* view = 0;
2018 view = dynamic_cast<OCCViewer_ViewWindow*>( viewMgr->getActiveView() );
2020 view->getViewPort()->repaintViewAfterMove();
2025 /*!Private SLOT. Support drag-and-drop operation.*/
2026 void LightApp_Application::onDropped( const QList<SUIT_DataObject*>& objects, SUIT_DataObject* parent, int row, Qt::DropAction action )
2028 LightApp_DataObject* parentObj = dynamic_cast<LightApp_DataObject*>( parent );
2032 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>( parentObj->module() );
2034 aModule->dropObjects( objects, parentObj, row, action );
2037 /*!Private SLOT. On preferences.*/
2038 void LightApp_Application::onPreferences()
2040 showPreferences( activeModule() ? activeModule()->moduleName() : tr( "PREF_CATEGORY_SALOME" ) );
2043 /*!Private SLOT. On preferences.*/
2044 void LightApp_Application::showPreferences( const QString& path )
2046 showPreferences( QStringList() << path );
2049 void LightApp_Application::showPreferences( const QStringList& path )
2051 QApplication::setOverrideCursor( Qt::WaitCursor );
2053 LightApp_PreferencesDlg* prefDlg = new LightApp_PreferencesDlg( preferences( true ), desktop());
2055 QApplication::restoreOverrideCursor();
2060 preferences()->activateItem( path );
2062 if ( ( prefDlg->exec() == QDialog::Accepted || prefDlg->isSaved() ) && resourceMgr() )
2065 resourceMgr()->setValue( "desktop", "geometry", desktop()->storeGeometry() );
2066 resourceMgr()->save();
2069 shortcutMgr()->updateShortcuts();
2075 /*!Protected SLOT. On preferences changed.*/
2076 void LightApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param )
2078 LightApp_Module* sMod = 0;
2079 CAM_Module* mod = module( modName );
2080 if ( mod && mod->inherits( "LightApp_Module" ) )
2081 sMod = (LightApp_Module*)mod;
2084 sMod->preferencesChanged( section, param );
2086 preferencesChanged( section, param );
2087 // emit signal to allow additional preferences changing processing
2088 emit preferenceChanged( modName, section, param );
2091 /*!Remove all windows from study.*/
2092 void LightApp_Application::beforeCloseDoc( SUIT_Study* s )
2094 saveDockWindowsState();
2096 if ( SUIT_DataBrowser* ob = objectBrowser() )
2099 CAM_Application::beforeCloseDoc( s );
2102 /*!Update actions.*/
2103 void LightApp_Application::updateActions()
2105 updateCommandsStatus();
2111 SUIT_Study* LightApp_Application::createNewStudy()
2113 LightApp_Study* aStudy = new LightApp_Study( this );
2115 // Set up processing of major study-related events
2116 connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
2117 connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
2118 connect( aStudy, SIGNAL( saved ( SUIT_Study* ) ), this, SLOT( onStudySaved ( SUIT_Study* ) ) );
2119 connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
2125 Creates window by flag.
2126 \param flag - identificator of window type
2128 QWidget* LightApp_Application::createWindow( const int flag )
2132 SUIT_ResourceMgr* resMgr = resourceMgr();
2134 if ( flag == WT_ObjectBrowser )
2136 SUIT_DataBrowser* ob = new SUIT_DataBrowser( new LightApp_DataObject(), desktop() );
2137 ob->setObjectName( "objectBrowser" );
2138 ob->setSortMenuEnabled( true );
2139 ob->setAutoUpdate( true );
2140 if ( resMgr->hasValue( "ObjectBrowser", "auto_hide_search_tool" ) )
2141 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
2143 //ob->setAutoOpenLevel( 1 ); // commented by ASV as a fix to bug IPAL10107
2144 ob->setWindowTitle( tr( "OBJECT_BROWSER" ) );
2145 connect( ob, SIGNAL( requestUpdate() ), this, SLOT( onRefresh() ) );
2147 QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
2148 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
2149 treeModel->setSearcher( this );
2150 treeModel->registerColumn( 0, EntryCol, LightApp_DataObject::EntryId );
2151 treeModel->setAppropriate( EntryCol, Qtx::Toggled );
2153 // Mantis issue 0020136: Drag&Drop in OB
2154 SUIT_ProxyModel* proxyModel = dynamic_cast<SUIT_ProxyModel*>(treeModel);
2156 connect( proxyModel, SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
2157 this, SLOT( onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
2158 connect( proxyModel, SIGNAL( renamed( SUIT_DataObject* ) ),
2159 this, SLOT( onRenamed( ) ) );
2163 // temporary commented
2165 OB_ListView* ob_list = dynamic_cast<OB_ListView*>( const_cast<QListView*>( ob->listView() ) );
2167 ob_list->setColumnMaxWidth( 0, desktop()->width()/4 );
2170 // Create OBSelector
2171 new LightApp_OBSelector( ob, mySelMgr );
2172 ob->treeView()->header()->setSectionResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
2173 ob->treeView()->header()->moveSection(SUIT_DataObject::NameId,SUIT_DataObject::VisibilityId);
2174 ob->treeView()->setColumnWidth(SUIT_DataObject::VisibilityId, VISIBILITY_COLUMN_WIDTH);
2175 ob->setProperty( "shortcut", QKeySequence( "Alt+Shift+O" ) );
2177 ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
2179 else if ( flag == WT_InfoPanel)
2181 QtxInfoPanel* ipanel = new QtxInfoPanel( desktop() );
2182 ipanel->setObjectName( "infoPanel" );
2183 ipanel->setWindowTitle( tr( "INFO_PANEL" ) );
2186 #ifndef DISABLE_PYCONSOLE
2187 else if ( flag == WT_PyConsole )
2189 PyConsole_Console* pyCons = new PyConsole_Console( desktop(), new LightApp_PyEditor( getPyInterp() ) );
2190 pyCons->setObjectName( "pythonConsole" );
2191 pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
2192 pyCons->setFont( resMgr->fontValue( "PyConsole", "font" ) );
2193 pyCons->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
2194 pyCons->setAutoCompletion( resMgr->booleanValue( "PyConsole", "auto_completion", true ) );
2195 pyCons->setProperty( "shortcut", QKeySequence( "Alt+Shift+P" ) );
2199 else if ( flag == WT_LogWindow )
2201 LogWindow* logWin = new LogWindow( desktop() );
2202 logWin->handleQtMessages( true );
2203 logWin->setObjectName( "logWindow" );
2204 logWin->setWindowTitle( tr( "LOG_WINDOW" ) );
2205 logWin->setProperty( "shortcut", QKeySequence( "Alt+Shift+L" ) );
2207 logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
2213 \return default windows( Object Browser, Python Console )
2214 Adds to map \a aMap.
2216 void LightApp_Application::defaultWindows( QMap<int, int>& aMap ) const
2218 #ifndef DISABLE_PYCONSOLE
2219 aMap.insert( WT_PyConsole, Qt::BottomDockWidgetArea );
2221 if ( activeStudy() ) {
2222 aMap.insert( WT_ObjectBrowser, Qt::LeftDockWidgetArea );
2223 aMap.insert( WT_InfoPanel, Qt::RightDockWidgetArea );
2224 // aMap.insert( WT_LogWindow, Qt::DockBottom );
2228 /*!Default view managers*/
2229 void LightApp_Application::defaultViewManagers( QStringList& ) const
2235 \return preferences.
2236 Create preferences, if \a crt = true.
2238 LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const
2243 LightApp_Application* that = (LightApp_Application*)this;
2245 bool toCreate = !_prefs_ && crt;
2248 _prefs_ = new LightApp_Preferences( resourceMgr() );
2249 that->createPreferences( _prefs_ );
2250 qAddPostRoutine( LightAppCleanUpAppResources );
2253 that->myPrefs = _prefs_;
2255 connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
2256 this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ), Qt::UniqueConnection );
2257 connect( myPrefs, SIGNAL( resetToDefaults() ),
2258 this, SIGNAL( preferenceResetToDefaults() ), Qt::UniqueConnection );
2263 SUIT_ResourceMgr* resMgr = resourceMgr();
2265 QList<SUIT_Application*> appList = SUIT_Session::session()->applications();
2266 for ( QList<SUIT_Application*>::iterator appIt = appList.begin(); appIt != appList.end(); ++appIt )
2268 LightApp_Application* app = ::qobject_cast<LightApp_Application*>( *appIt );
2272 // all modules available in current session
2274 app->modules( names, false );
2277 QMap<QString, QString> icons;
2278 app->moduleIconNames( icons );
2280 // step 1: iterate through list of all available modules
2281 // and add empty preferences page
2282 for ( QStringList::const_iterator it = names.begin(); it != names.end(); ++it )
2284 if ( !_prefs_->hasModule( *it ) ) // prevent possible duplications
2286 int modId = _prefs_->addPreference( *it ); // add empty page
2287 if ( icons.contains( *it ) ) // set icon
2288 _prefs_->setItemIcon( modId, Qtx::scaleIcon( resMgr->loadPixmap( moduleName( *it ),
2289 icons[*it], false ), 20 ) );
2293 // step 2: iterate through list of all loaded modules
2294 // and initialize their preferences
2295 ModuleList loadedModules;
2296 app->modules( loadedModules );
2297 QListIterator<CAM_Module*> itr( loadedModules );
2298 while ( itr.hasNext() )
2300 LightApp_Module* module = 0;
2301 CAM_Module* m = itr.next();
2302 if ( m->inherits( "LightApp_Module" ) )
2303 module = (LightApp_Module*)m;
2305 if ( module && !_prefs_->hasModule( module->moduleName() ) )
2307 _prefs_->addPreference( module->moduleName() ); // add page (for sure, had to be done at step 1)
2308 module->createPreferences(); // initialize preferences
2309 that->emptyPreferences( module->moduleName() ); // show dummy page if module does not export any preferences
2313 _prefs_->setItemProperty( "info", tr( "PREFERENCES_NOT_LOADED" ) ); // dummy page for modules which are not loaded yet
2319 Adds new module to application
2321 void LightApp_Application::moduleAdded( CAM_Module* mod )
2323 CAM_Application::moduleAdded( mod );
2325 LightApp_Module* lightMod = 0;
2326 if ( mod && mod->inherits( "LightApp_Module" ) )
2327 lightMod = (LightApp_Module*)mod;
2329 if ( myPrefs && lightMod && !myPrefs->hasModule( lightMod->moduleName() ))
2331 myPrefs->addPreference( mod->moduleName() );
2332 lightMod->createPreferences();
2333 emptyPreferences( mod->moduleName() );
2337 void LightApp_Application::moduleDeactivated( CAM_Module* /*mod*/ )
2340 infoPanel()->clear();
2343 void LightApp_Application::emptyPreferences( const QString& modName )
2345 QtxPreferenceItem* item = myPrefs->findItem( modName, true );
2346 if ( !item || !item->isEmpty() )
2349 QtxPagePrefFrameItem* frm = new QtxPagePrefFrameItem( item->title(), item->parentItem() );
2350 frm->setIcon( item->icon() );
2351 frm->setStretch( false );
2352 item->parentItem()->insertItem( frm, item );
2353 new QtxPagePrefLabelItem( Qt::AlignCenter, tr( "PREFERENCES_NOT_SUPPORTED" ).arg( modName ), frm );
2360 void LightApp_Application::createPreferences( LightApp_Preferences* pref )
2365 QStringList aValuesList;
2366 QList<QVariant> anIndicesList;
2370 // . Top-level "SALOME" preferences group <<start>>
2371 int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
2372 pref->setItemIcon( salomeCat, Qtx::scaleIcon( resourceMgr()->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false ), 20 ) );
2374 // .. "General" preferences tab <<start>>
2375 int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat );
2377 // ... "Language" group <<start>>
2378 int langGroup = pref->addPreference( tr( "PREF_GROUP_LANGUAGE" ), genTab );
2379 pref->setItemProperty( "columns", 2, langGroup );
2380 // .... -> application language
2381 int curLang = pref->addPreference( tr( "PREF_CURRENT_LANGUAGE" ), langGroup,
2382 LightApp_Preferences::Selector, "language", "language" );
2383 QStringList aLangs = SUIT_Session::session()->resourceMgr()->stringValue( "language", "languages", "en" ).split( "," );
2384 QList<QVariant> aIcons;
2385 QList<QVariant> aNumbers;
2386 QStringList aTitles;
2387 foreach ( QString aLang, aLangs ) {
2388 aIcons << QPixmap( QString( ":/images/%1" ).arg( aLang ) );
2390 aTitles << langToName( aLang );
2392 pref->setItemProperty( "strings", aTitles, curLang );
2393 pref->setItemProperty( "ids", aNumbers, curLang );
2394 pref->setItemProperty( "icons", aIcons, curLang );
2395 pref->setItemProperty( "restart", true, curLang );
2397 int curLocale = pref->addPreference( tr( "PREF_CURRENT_LOCALE" ), langGroup,
2398 LightApp_Preferences::Bool, "language", "locale" );
2399 pref->setItemProperty( "restart", true, curLocale );
2400 // ... "Language" group <<end>>
2402 // ... "Look and feel" group <<start>>
2403 int lookGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), genTab );
2404 pref->setItemProperty( "columns", 2, lookGroup );
2405 // .... -> show splash-screen
2406 pref->addPreference( tr( "PREF_SHOW_SPLASH" ), lookGroup, LightApp_Preferences::Bool, "launch", "splash" );
2407 // .... -> opaque resize
2408 pref->addPreference( tr( "PREF_OPAQUE_RESIZE" ), lookGroup, LightApp_Preferences::Bool, "desktop", "opaque_resize" );
2409 // .... -> drop-down buttons
2410 pref->addPreference( tr( "PREF_DROP_DOWN_BUTTONS" ), lookGroup, LightApp_Preferences::Bool, "viewers", "drop_down_buttons" );
2411 // .... -> Notification timeout
2412 int delay = pref->addPreference( tr( "PREF_NOTIFY_TIMEOUT" ), lookGroup, LightApp_Preferences::IntSpin, "notification", "timeout" );
2413 pref->setItemProperty( "special", tr("PREF_NOTIFY_TIMEOUT_NONE"), delay );
2414 pref->setItemProperty( "min", 0, delay );
2415 pref->setItemProperty( "max", 100, delay );
2416 pref->setItemProperty( "suffix", " sec", delay );
2417 // ... "Look and feel" group <<end>>
2419 // ... "Study properties" group <<start>>
2420 int studyGroup = pref->addPreference( tr( "PREF_GROUP_STUDY" ), genTab );
2421 pref->setItemProperty( "columns", 2, studyGroup );
2422 // .... -> multi-file save
2423 pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "multi_file" );
2424 // .... -> ascii save mode
2425 pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" );
2426 // .... -> store windows geometry
2427 pref->addPreference( tr( "PREF_LOAD_LIGHT" ), studyGroup, LightApp_Preferences::Bool, "Study", "autoload_light_modules" );
2428 pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" );
2429 pref->addPreference( "", studyGroup, LightApp_Preferences::Space );
2430 pref->addPreference( tr( "PREF_STORE_TOOL_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_tool_positions" );
2431 // .... -> auto-save
2432 int autoSaveInterval = pref->addPreference( tr( "PREF_AUTO_SAVE" ), studyGroup,
2433 LightApp_Preferences::IntSpin, "Study", "auto_save_interval" );
2434 pref->setItemProperty( "min", 0, autoSaveInterval );
2435 pref->setItemProperty( "max", 1440, autoSaveInterval );
2436 pref->setItemProperty( "special", tr( "PREF_AUTO_SAVE_DISABLED" ), autoSaveInterval );
2437 // ... "Study properties" group <<end>>
2439 // ... "Help browser" group <<start>>
2440 #ifndef DISABLE_QTXWEBBROWSER
2441 int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab, LightApp_Preferences::Auto, "ExternalBrowser", "use_external_browser");
2443 int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab );
2447 QString platform = "winapplication";
2449 QString platform = "application";
2451 // .... -> browser application
2452 int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, LightApp_Preferences::File, "ExternalBrowser", platform );
2453 pref->setItemProperty( "mode", Qtx::PT_OpenFile, apppref );
2454 // .... -> browser parameters
2455 pref->addPreference( tr( "PREF_PARAM" ), extgroup, LightApp_Preferences::String, "ExternalBrowser", "parameters" );
2456 // ... "Help browser" group <<end>>
2458 // ... "Python console properties" group <<start>>
2459 int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab );
2460 pref->setItemProperty( "columns", 2, pythonConsoleGroup );
2462 pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, LightApp_Preferences::Font, "PyConsole", "font" );
2463 // .... -> show banner
2464 pref->addPreference( tr( "PREF_SHOW_BANNER" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "show_banner" );
2465 // .... -> auto-completion
2466 pref->addPreference( tr( "PREF_AUTO_COMPLETION" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "auto_completion" );
2467 // ... "Python console properties" group <<end>>
2469 // ... "MRU" preferences group <<start>>
2470 int mruGroup = pref->addPreference( tr( "PREF_GROUP_MRU" ), genTab, LightApp_Preferences::Auto, "MRU", "show_mru" );
2471 pref->setItemProperty( "columns", 4, mruGroup );
2472 // number of MRU items
2473 int mruVisCount = pref->addPreference( tr( "PREF_MRU_VISIBLE_COUNT" ), mruGroup, LightApp_Preferences::IntSpin,
2474 "MRU", "visible_count" );
2475 pref->setItemProperty( "min", 0, mruVisCount );
2476 pref->setItemProperty( "max", 100, mruVisCount );
2478 int mruLinkType = pref->addPreference( tr( "PREF_MRU_LINK_TYPE" ), mruGroup, LightApp_Preferences::Selector,
2479 "MRU", "link_type" );
2480 aValuesList.clear();
2481 anIndicesList.clear();
2482 aValuesList << tr("PREF_MRU_LINK_AUTO") << tr("PREF_MRU_LINK_SHORT") << tr("PREF_MRU_LINK_FULL");
2483 anIndicesList << 0 << 1 << 2 ;
2484 pref->setItemProperty( "strings", aValuesList, mruLinkType );
2485 pref->setItemProperty( "indexes", anIndicesList, mruLinkType );
2486 // ... "MRU" preferences group <<end>>
2488 // ... "Full-screen" group <<start>>
2489 int fullScreenGroup = pref->addPreference( tr( "PREF_GROUP_FULL_SCREEN" ), genTab );
2490 pref->setItemProperty( "columns", 2, fullScreenGroup );
2491 // .... -> automatic hiding toolbars
2492 pref->addPreference( tr( "PREF_FULL_SCREEN_AUTO" ), fullScreenGroup,
2493 LightApp_Preferences::Bool, "OCCViewer", "automatic_hiding" );
2494 // ... "Full-screen" group <<end>>
2496 // .. "General" preferences tab <<end>>
2498 // .. "3D viewer" group <<start>>
2499 int Viewer3DGroup = pref->addPreference( tr( "PREF_GROUP_3DVIEWER" ), salomeCat );
2500 // ... -> navigation mode
2501 int vtkStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), Viewer3DGroup,
2502 LightApp_Preferences::Selector, "3DViewer", "navigation_mode" );
2503 aValuesList.clear();
2504 anIndicesList.clear();
2505 aValuesList << tr("PREF_STANDARD_STYLE") << tr("PREF_KEYFREE_STYLE");
2506 anIndicesList << 0 << 1;
2507 pref->setItemProperty( "strings", aValuesList, vtkStyleMode );
2508 pref->setItemProperty( "indexes", anIndicesList, vtkStyleMode );
2509 // ... -> zooming mode
2510 int occZoomingStyleMode = pref->addPreference( tr( "PREF_ZOOMING" ), Viewer3DGroup,
2511 LightApp_Preferences::Selector, "3DViewer", "zooming_mode" );
2512 aValuesList.clear();
2513 anIndicesList.clear();
2514 aValuesList << tr("PREF_ZOOMING_AT_CENTER") << tr("PREF_ZOOMING_AT_CURSOR");
2515 anIndicesList << 0 << 1;
2516 pref->setItemProperty( "strings", aValuesList, occZoomingStyleMode );
2517 pref->setItemProperty( "indexes", anIndicesList, occZoomingStyleMode );
2518 // ... "Trihedron" group <<start>>
2519 int occTriGroup = pref->addPreference( tr( "PREF_TRIHEDRON" ), Viewer3DGroup );
2520 pref->setItemProperty( "columns", 2, occTriGroup );
2521 // .... -> trihedron size
2522 int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occTriGroup,
2523 LightApp_Preferences::DblSpin, "3DViewer", "trihedron_size" );
2524 pref->setItemProperty( "min", 1.0E-06, occTS );
2525 pref->setItemProperty( "max", 1000, occTS );
2526 // .... -> relative size of trihedron
2527 pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "relative_size" );
2528 // .... -> show static trihedron
2529 pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "show_static_trihedron" );
2530 // ... "Trihedron" group <<end>>
2531 // .. "3D viewer" group <<end>>
2535 #ifndef DISABLE_OCCVIEWER
2536 // .. "OCC viewer" group <<start>>
2537 int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), salomeCat );
2539 // .... -> Projection mode
2540 int occProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), occGroup,
2541 LightApp_Preferences::Selector, "OCCViewer", "projection_mode" );
2542 aValuesList.clear();
2543 anIndicesList.clear();
2544 aValuesList << tr("PREF_ORTHOGRAPHIC") << tr("PREF_PERSPECTIVE");
2545 anIndicesList << 0 << 1;
2546 pref->setItemProperty( "strings", aValuesList, occProjMode );
2547 pref->setItemProperty( "indexes", anIndicesList, occProjMode );
2549 // .... -> Stereo group
2550 int stereoGroup = pref->addPreference( tr( "PREF_GROUP_STEREO" ), occGroup);
2551 pref->setItemProperty( "columns", 2, stereoGroup );
2552 // .... -> Stereo type
2553 int stereoType = pref->addPreference( tr( "PREF_STEREO_TYPE" ), stereoGroup,
2554 LightApp_Preferences::Selector, "OCCViewer", "stereo_type" );
2555 aValuesList.clear();
2556 anIndicesList.clear();
2558 OCCViewer_Viewer::stereoData( aValuesList, idList);
2559 foreach( int gid, idList ) anIndicesList << gid;
2560 pref->setItemProperty( "strings", aValuesList, stereoType );
2561 pref->setItemProperty( "indexes", anIndicesList, stereoType );
2563 // .... -> Anaglyph filter
2564 int anaglyphFilter = pref->addPreference( tr( "PREF_ANAGLYPH_FILTER" ), stereoGroup,
2565 LightApp_Preferences::Selector, "OCCViewer", "anaglyph_filter" );
2566 aValuesList.clear();
2567 anIndicesList.clear();
2568 aValuesList << tr("PREF_ANAGLYPH_RED_CYAN") << tr("PREF_ANAGLYPH_YELLOW_BLUE") << tr("PREF_ANAGLYPH_GREEN_MAGENTA");
2569 anIndicesList << 0 << 1 << 2;
2571 pref->setItemProperty( "strings", aValuesList, anaglyphFilter );
2572 pref->setItemProperty( "indexes", anIndicesList, anaglyphFilter );
2574 // .... -> Convergence distance type
2575 int occFocusType = pref->addPreference( tr( "PREF_FOCUS_TYPE" ), stereoGroup,
2576 LightApp_Preferences::Selector, "OCCViewer", "focus_type" );
2577 aValuesList.clear();
2578 anIndicesList.clear();
2579 aValuesList << tr("PREF_ABSOLUTE") << tr("PREF_RELATIVE");
2580 anIndicesList << 0 << 1;
2581 pref->setItemProperty( "strings", aValuesList, occFocusType );
2582 pref->setItemProperty( "indexes", anIndicesList, occFocusType );
2584 // .... -> Stereographic focus value
2585 int focusValue = pref->addPreference( tr( "PREF_FOCUS_VALUE" ), stereoGroup,
2586 LightApp_Preferences::DblSpin, "OCCViewer", "focus_value" );
2587 pref->setItemProperty( "precision", 3, focusValue );
2588 pref->setItemProperty( "min", 1.0E-03, focusValue );
2589 pref->setItemProperty( "max", 1.0E03, focusValue );
2590 pref->setItemProperty( "step", 0.05, focusValue );
2593 int occIODType = pref->addPreference( tr( "PREF_IOD_TYPE" ), stereoGroup,
2594 LightApp_Preferences::Selector, "OCCViewer", "iod_type" );
2595 aValuesList.clear();
2596 anIndicesList.clear();
2597 aValuesList << tr("PREF_ABSOLUTE") << tr("PREF_RELATIVE");
2598 anIndicesList << 0 << 1;
2599 pref->setItemProperty( "strings", aValuesList, occIODType );
2600 pref->setItemProperty( "indexes", anIndicesList, occIODType );
2602 // .... -> Interocular distance (IOD) value
2603 int IODValue = pref->addPreference( tr( "PREF_IOD_VALUE" ), stereoGroup,
2604 LightApp_Preferences::DblSpin, "OCCViewer", "iod_value" );
2605 pref->setItemProperty( "precision", 3, IODValue );
2606 pref->setItemProperty( "min", 1.0E-03, IODValue );
2607 pref->setItemProperty( "max", 1.0E03, IODValue );
2608 pref->setItemProperty( "step", 0.05, IODValue );
2610 // .... -> Reverse stereo
2611 pref->addPreference( tr( "PREF_REVERSE_STEREO" ), stereoGroup,
2612 LightApp_Preferences::Bool, "OCCViewer", "reverse_stereo" );
2613 // .... -> Enable V-Sync
2614 pref->addPreference( tr( "PREF_ENABLE_VSYNC" ), stereoGroup,
2615 LightApp_Preferences::Bool, "OCCViewer", "enable_vsync" );
2616 // .... -> Enable quad-buffer support
2617 pref->addPreference( tr( "PREF_ENABLE_QUAD_BUFFER_SUPPORT" ), stereoGroup,
2618 LightApp_Preferences::Bool, "OCCViewer", "enable_quad_buffer_support" );
2620 // ... "Background" group <<start>>
2621 int bgGroup = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup );
2622 // pref->setItemProperty( "columns", 2, bgGroup );
2623 aValuesList.clear();
2624 anIndicesList.clear();
2627 formats = OCCViewer_Viewer::backgroundData( aValuesList, idList, txtList );
2628 foreach( int gid, idList ) anIndicesList << gid;
2629 // .... -> 3D viewer background
2630 bgId = pref->addPreference( tr( "PREF_3DVIEWER_BACKGROUND" ), bgGroup,
2631 LightApp_Preferences::Background, "OCCViewer", "background" );
2632 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2633 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2634 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2635 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2636 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2637 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2638 pref->setItemProperty( "custom_enabled", false, bgId );
2639 pref->setItemProperty( "image_formats", formats, bgId );
2640 // .... -> XZ viewer background
2641 bgId = pref->addPreference( tr( "PREF_XZVIEWER_BACKGROUND" ), bgGroup,
2642 LightApp_Preferences::Background, "OCCViewer", "xz_background" );
2643 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2644 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2645 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2646 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2647 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2648 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2649 pref->setItemProperty( "custom_enabled", false, bgId );
2650 pref->setItemProperty( "image_formats", formats, bgId );
2651 // .... -> YZ viewer background
2652 bgId = pref->addPreference( tr( "PREF_YZVIEWER_BACKGROUND" ), bgGroup,
2653 LightApp_Preferences::Background, "OCCViewer", "yz_background" );
2654 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2655 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2656 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2657 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2658 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2659 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2660 pref->setItemProperty( "custom_enabled", false, bgId );
2661 pref->setItemProperty( "image_formats", formats, bgId );
2662 // .... -> XY viewer background
2663 bgId = pref->addPreference( tr( "PREF_XYVIEWER_BACKGROUND" ), bgGroup,
2664 LightApp_Preferences::Background, "OCCViewer", "xy_background" );
2665 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2666 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2667 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2668 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2669 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2670 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2671 pref->setItemProperty( "custom_enabled", false, bgId );
2672 pref->setItemProperty( "image_formats", formats, bgId );
2673 // ... "Background" group <<end>>
2676 // ... "Selection" group <<start>>
2677 int occSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), occGroup );
2678 pref->setItemProperty( "columns", 3, occSelectionGroup );
2679 // .... -> enable preselection
2680 pref->addPreference( tr( "PREF_ENABLE_PRESELECTION" ), occSelectionGroup,
2681 LightApp_Preferences::Bool, "OCCViewer", "enable_preselection" );
2682 // .... -> enable selection
2683 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), occSelectionGroup,
2684 LightApp_Preferences::Bool, "OCCViewer", "enable_selection" );
2685 // .... -> selection style
2686 int aSeleStyle = pref->addPreference( tr( "PREF_SELECTION_STYLE" ), occSelectionGroup,
2687 LightApp_Preferences::Selector, "OCCViewer", "adv_selection_mode" );
2688 aValuesList.clear();
2689 anIndicesList.clear();
2690 aValuesList << tr("PREF_POLYGON_SELECTION") << tr("PREF_CIRCLE_SELECTION");
2691 anIndicesList << 0 << 1;
2692 pref->setItemProperty( "strings", aValuesList, aSeleStyle);
2693 pref->setItemProperty( "indexes", anIndicesList, aSeleStyle);
2694 // ... "Selection" group <<end>>
2696 // ... "Clipping" group <<start>>
2697 int occClippingGroup = pref->addPreference( tr( "PREF_GROUP_CLIPPING" ), occGroup );
2698 // .... -> clipping color
2699 pref->addPreference( tr( "PREF_CLIPPING_COLOR" ), occClippingGroup,
2700 LightApp_Preferences::Color, "OCCViewer", "clipping_color" );
2701 int texturePref = pref->addPreference( "", occClippingGroup, LightApp_Preferences::Frame );
2702 pref->setItemProperty( "columns", 2, texturePref );
2703 // .... -> use default texture
2704 pref->addPreference( tr( "PREF_CLIPPING_DEFAULT_TEXTURE" ), texturePref,
2705 LightApp_Preferences::Bool, "OCCViewer", "clipping_use_default_texture" );
2706 // .... -> clipping texture
2707 int filePref = pref->addPreference( tr( "PREF_CLIPPING_TEXTURE" ), texturePref,
2708 LightApp_Preferences::File, "OCCViewer", "clipping_texture" );
2709 pref->setItemProperty( "path_filter", tr( "OCC_TEXTURE_FILES" ), filePref );
2711 pref->addPreference( tr( "PREF_CLIPPING_MODULATE" ), texturePref,
2712 LightApp_Preferences::Bool, "OCCViewer", "clipping_modulate" );
2713 // .... -> scale factor
2714 int scaleFactor = pref->addPreference( tr( "PREF_CLIPPING_SCALE" ), texturePref,
2715 LightApp_Preferences::DblSpin, "OCCViewer", "clipping_scale" );
2716 pref->setItemProperty( "precision", 3, scaleFactor );
2717 pref->setItemProperty( "min", 1.0E-03, scaleFactor );
2718 pref->setItemProperty( "max", 1.0E03, scaleFactor );
2719 pref->setItemProperty( "step", 0.1, scaleFactor );
2720 // ... "Clipping" group <<end>>
2722 // ... "Ray tracing" group <<start>>
2723 int occRayTracingGroup = pref->addPreference( tr( "PREF_GROUP_RAY_TRACING" ), occGroup );
2724 int rtPref = pref->addPreference( "", occRayTracingGroup, LightApp_Preferences::Frame );
2725 pref->setItemProperty( "columns", 2, rtPref );
2727 int rt_depth = pref->addPreference( tr( "PREF_RAY_TRACING_DEPTH" ), rtPref,
2728 LightApp_Preferences::IntSpin, "OCCViewer", "rt_depth" );
2729 pref->setItemProperty( "min", 1, rt_depth );
2730 pref->setItemProperty( "max", 10, rt_depth );
2731 pref->setItemProperty( "step", 1, rt_depth );
2732 pref->addPreference( "", rtPref, LightApp_Preferences::Frame );
2733 // .... -> specular reflections
2734 pref->addPreference( tr( "PREF_RAY_TRACING_REFLECTION" ), rtPref,
2735 LightApp_Preferences::Bool, "OCCViewer", "rt_reflection" );
2736 // .... -> adaptive anti-aliasing
2737 pref->addPreference( tr( "PREF_RAY_TRACING_ANTIALIASING" ), rtPref,
2738 LightApp_Preferences::Bool, "OCCViewer", "rt_antialiasing" );
2739 // .... -> shadows rendering
2740 pref->addPreference( tr( "PREF_RAY_TRACING_SHADOW" ), rtPref,
2741 LightApp_Preferences::Bool, "OCCViewer", "rt_shadow" );
2742 // .... -> transparent shadow
2743 pref->addPreference( tr( "PREF_RAY_TRACING_TRANS_SHADOW" ), rtPref,
2744 LightApp_Preferences::Bool, "OCCViewer", "rt_trans_shadow" );
2745 // ... "Ray tracing" group <<end>>
2747 // ... "Light source" group <<start>>
2748 int occLightGroup = pref->addPreference( tr( "PREF_GROUP_LIGHT" ), occGroup );
2749 // .... -> light color
2750 pref->addPreference( tr( "PREF_LIGHT_COLOR" ), occLightGroup,
2751 LightApp_Preferences::Color, "OCCViewer", "light_color" );
2752 int directionPref = pref->addPreference( "", occLightGroup, LightApp_Preferences::Frame );
2753 pref->setItemProperty( "columns", 3, directionPref );
2754 // .... -> light direction (dx component)
2755 int light_dx = pref->addPreference( tr( "Dx" ), directionPref,
2756 LightApp_Preferences::DblSpin, "OCCViewer", "light_dx" );
2757 pref->setItemProperty( "precision", 2, light_dx );
2758 pref->setItemProperty( "min", -1.0E03, light_dx );
2759 pref->setItemProperty( "max", 1.0E03, light_dx );
2760 pref->setItemProperty( "step", 0.1, light_dx );
2761 // .... -> light direction (dy component)
2762 int light_dy = pref->addPreference( tr( "Dy" ), directionPref,
2763 LightApp_Preferences::DblSpin, "OCCViewer", "light_dy" );
2764 pref->setItemProperty( "precision", 2, light_dy );
2765 pref->setItemProperty( "min", -1.0E03, light_dy );
2766 pref->setItemProperty( "max", 1.0E03, light_dy );
2767 pref->setItemProperty( "step", 0.1, light_dy );
2768 // .... -> light direction (dz component)
2769 int light_dz = pref->addPreference( tr( "Dz" ), directionPref,
2770 LightApp_Preferences::DblSpin, "OCCViewer", "light_dz" );
2771 pref->setItemProperty( "precision", 2, light_dz );
2772 pref->setItemProperty( "min", -1.0E03, light_dz );
2773 pref->setItemProperty( "max", 1.0E03, light_dz );
2774 pref->setItemProperty( "step", 0.1, light_dz );
2775 // ... "Light source" group <<end>>
2777 // ... -> empty frame (for layout) <<start>>
2778 int occGen = pref->addPreference( "", occGroup, LightApp_Preferences::Frame );
2779 pref->setItemProperty( "margin", 0, occGen );
2780 pref->setItemProperty( "columns", 2, occGen );
2781 // ... -> empty frame (for layout) <<end>>
2783 // .. "OCC viewer" group <<end>>
2786 #ifndef DISABLE_VTKVIEWER
2787 // .. "VTK viewer" group <<start>>
2788 int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), salomeCat ); //viewTab
2790 // ... -> empty frame (for layout) <<start>>
2791 int vtkGen = pref->addPreference( "", vtkGroup, LightApp_Preferences::Frame );
2792 //pref->setItemProperty( "columns", 2, vtkGen );
2793 // .... -> projection mode
2794 int vtkProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), vtkGen,
2795 LightApp_Preferences::Selector, "VTKViewer", "projection_mode" );
2796 aValuesList.clear();
2797 anIndicesList.clear();
2798 aValuesList << tr("PREF_ORTHOGRAPHIC") << tr("PREF_PERSPECTIVE");
2799 anIndicesList << 0 << 1;
2800 pref->setItemProperty( "strings", aValuesList, vtkProjMode );
2801 pref->setItemProperty( "indexes", anIndicesList, vtkProjMode );
2803 // .... -> Stereo group
2804 int vtkStereoGroup = pref->addPreference( tr( "PREF_GROUP_STEREO" ), vtkGroup);
2805 pref->setItemProperty( "columns", 2, vtkStereoGroup );
2806 // .... -> Stereo type
2807 int vtkStereoType = pref->addPreference( tr( "PREF_STEREO_TYPE" ), vtkStereoGroup,
2808 LightApp_Preferences::Selector, "VTKViewer", "stereo_type" );
2809 aValuesList.clear();
2810 anIndicesList.clear();
2812 SVTK_Viewer::stereoData( aValuesList, idList);
2813 foreach( int gid, idList ) anIndicesList << gid;
2814 pref->setItemProperty( "strings", aValuesList, vtkStereoType );
2815 pref->setItemProperty( "indexes", anIndicesList, vtkStereoType );
2816 // .... -> Anaglyph filter
2817 int vtkAnaglyphFilter = pref->addPreference( tr( "PREF_ANAGLYPH_FILTER" ), vtkStereoGroup,
2818 LightApp_Preferences::Selector, "VTKViewer", "anaglyph_filter" );
2819 aValuesList.clear();
2820 anIndicesList.clear();
2821 aValuesList << tr("PREF_ANAGLYPH_RED_CYAN") << tr("PREF_ANAGLYPH_YELLOW_BLUE") << tr("PREF_ANAGLYPH_GREEN_MAGENTA");
2822 anIndicesList << 0 << 1 << 2;
2824 pref->setItemProperty( "strings", aValuesList, vtkAnaglyphFilter );
2825 pref->setItemProperty( "indexes", anIndicesList, vtkAnaglyphFilter );
2827 // .... -> Enable quad-buffer support
2828 pref->addPreference( tr( "PREF_ENABLE_QUAD_BUFFER_SUPPORT" ), vtkStereoGroup,
2829 LightApp_Preferences::Bool, "VTKViewer", "enable_quad_buffer_support" );
2831 // .... -> background
2832 aValuesList.clear();
2833 anIndicesList.clear();
2836 #ifndef DISABLE_SALOMEOBJECT
2837 formats = SVTK_Viewer::backgroundData( aValuesList, idList, txtList );
2839 foreach( int gid, idList ) anIndicesList << gid;
2840 bgId = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGen,
2841 LightApp_Preferences::Background, "VTKViewer", "background" );
2842 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2843 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2844 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2845 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2846 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2847 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2848 pref->setItemProperty( "custom_enabled", false, bgId );
2849 #ifndef DISABLE_SALOMEOBJECT
2850 pref->setItemProperty( "image_formats", formats, bgId );
2852 // .... -> speed increment
2853 int vtkSpeed = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED" ), vtkGen,
2854 LightApp_Preferences::IntSpin, "VTKViewer", "speed_value" );
2855 pref->setItemProperty( "min", 1, vtkSpeed );
2856 pref->setItemProperty( "max", 1000, vtkSpeed );
2857 // .... -> speed mode
2858 int vtkSpeedMode = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED_MODE" ), vtkGen,
2859 LightApp_Preferences::Selector, "VTKViewer", "speed_mode" );
2860 aValuesList.clear();
2861 anIndicesList.clear();
2862 aValuesList << tr("PREF_ARITHMETIC") << tr("PREF_GEOMETRICAL");
2863 anIndicesList << 0 << 1;
2864 pref->setItemProperty( "strings", aValuesList, vtkSpeedMode );
2865 pref->setItemProperty( "indexes", anIndicesList, vtkSpeedMode );
2867 // ... "Selection" group <<start>>
2868 int vtkSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), vtkGroup );
2869 pref->setItemProperty( "columns", 2, vtkSelectionGroup );
2870 // .... -> preselection
2871 int vtkPreselection = pref->addPreference( tr( "PREF_PRESELECTION" ), vtkSelectionGroup,
2872 LightApp_Preferences::Selector, "VTKViewer", "preselection" );
2873 aValuesList.clear();
2874 anIndicesList.clear();
2875 aValuesList << tr("PREF_PRESELECTION_STANDARD") << tr("PREF_PRESELECTION_DYNAMIC") << tr("PREF_PRESELECTION_DISABLED");
2876 anIndicesList << 0 << 1 << 2;
2877 pref->setItemProperty( "strings", aValuesList, vtkPreselection );
2878 pref->setItemProperty( "indexes", anIndicesList, vtkPreselection );
2879 // .... -> enable selection
2880 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), vtkSelectionGroup, LightApp_Preferences::Bool, "VTKViewer", "enable_selection" );
2881 // ... "Selection" group <<end>>
2883 // ... -> empty frame (for layout) <<end>>
2885 // ... space mouse sub-group <<start>>
2886 int vtkSM = pref->addPreference( tr( "PREF_FRAME_SPACEMOUSE" ), vtkGroup, LightApp_Preferences::GroupBox );
2887 //pref->setItemProperty( "columns", 2, vtkSM );
2888 // .... -> decrease speed increment
2889 int spacemousePref1 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_1" ), vtkSM,
2890 LightApp_Preferences::Selector, "VTKViewer",
2891 "spacemouse_func1_btn" );
2892 // .... -> increase speed increment
2893 int spacemousePref2 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_2" ), vtkSM,
2894 LightApp_Preferences::Selector, "VTKViewer",
2895 "spacemouse_func2_btn" );
2896 // .... -> dominant / combined switch
2897 int spacemousePref3 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_3" ), vtkSM,
2898 LightApp_Preferences::Selector, "VTKViewer",
2899 "spacemouse_func5_btn" ); //
2900 aValuesList.clear();
2901 anIndicesList.clear();
2902 aValuesList << tr( "PREF_SPACEMOUSE_BTN_1" ) << tr( "PREF_SPACEMOUSE_BTN_2" ) << tr( "PREF_SPACEMOUSE_BTN_3" );
2903 aValuesList << tr( "PREF_SPACEMOUSE_BTN_4" ) << tr( "PREF_SPACEMOUSE_BTN_5" ) << tr( "PREF_SPACEMOUSE_BTN_6" );
2904 aValuesList << tr( "PREF_SPACEMOUSE_BTN_7" ) << tr( "PREF_SPACEMOUSE_BTN_8" ) << tr( "PREF_SPACEMOUSE_BTN_*" );
2905 aValuesList << tr( "PREF_SPACEMOUSE_BTN_10" ) << tr( "PREF_SPACEMOUSE_BTN_11" );
2906 anIndicesList << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11;
2907 pref->setItemProperty( "strings", aValuesList, spacemousePref1 );
2908 pref->setItemProperty( "indexes", anIndicesList, spacemousePref1 );
2909 pref->setItemProperty( "strings", aValuesList, spacemousePref2 );
2910 pref->setItemProperty( "indexes", anIndicesList, spacemousePref2 );
2911 pref->setItemProperty( "strings", aValuesList, spacemousePref3 );
2912 pref->setItemProperty( "indexes", anIndicesList, spacemousePref3 );
2913 // ... space mouse sub-group <<end>>
2915 // ... avi recording sub-group <<start>>
2916 int vtkRec = pref->addPreference( tr( "PREF_FRAME_RECORDING" ), vtkGroup, LightApp_Preferences::GroupBox );
2917 pref->setItemProperty( "columns", 2, vtkRec );
2918 // .... -> recording mode
2919 int modePref = pref->addPreference( tr( "PREF_RECORDING_MODE" ), vtkRec,
2920 LightApp_Preferences::Selector, "VTKViewer", "recorder_mode" );
2921 aValuesList.clear();
2922 anIndicesList.clear();
2923 aValuesList << tr( "PREF_SKIPPED_FRAMES" ) << tr( "PREF_ALL_DISLPAYED_FRAMES" );
2924 anIndicesList << 0 << 1;
2925 pref->setItemProperty( "strings", aValuesList, modePref );
2926 pref->setItemProperty( "indexes", anIndicesList, modePref );
2928 int fpsPref = pref->addPreference( tr( "PREF_FPS" ), vtkRec,
2929 LightApp_Preferences::DblSpin, "VTKViewer", "recorder_fps" );
2930 pref->setItemProperty( "min", 0.1, fpsPref );
2931 pref->setItemProperty( "max", 100, fpsPref );
2933 int qualityPref = pref->addPreference( tr( "PREF_QUALITY" ), vtkRec,
2934 LightApp_Preferences::IntSpin, "VTKViewer", "recorder_quality" );
2935 pref->setItemProperty( "min", 1, qualityPref );
2936 pref->setItemProperty( "max", 100, qualityPref );
2937 // .... -> progressive mode
2938 pref->addPreference( tr( "PREF_PROGRESSIVE" ), vtkRec,
2939 LightApp_Preferences::Bool, "VTKViewer", "recorder_progressive" );
2940 // ... avi recording sub-group <<end>>
2942 // ... group names sub-group <<start>>
2943 int vtkGN = pref->addPreference( tr( "PREF_FRAME_GROUP_NAMES" ), vtkGroup,
2944 LightApp_Preferences::GroupBox, "VTKViewer", "show_group_names" );
2945 pref->setItemProperty( "columns", 2, vtkGN );
2946 // .... -> text color
2947 pref->addPreference( tr( "PREF_GROUP_NAMES_TEXT_COLOR" ), vtkGN,
2948 LightApp_Preferences::Color, "VTKViewer", "group_names_text_color" );
2949 // .... -> transparency
2950 int transPref = pref->addPreference( tr( "PREF_GROUP_NAMES_TRANSPARENCY" ), vtkGN,
2951 LightApp_Preferences::DblSpin, "VTKViewer", "group_names_transparency" );
2952 pref->setItemProperty( "min", 0.0, transPref );
2953 pref->setItemProperty( "max", 1.0, transPref );
2954 pref->setItemProperty( "step", 0.1, transPref );
2955 // ... -> group names sub-group <<end>>
2956 // .. "VTK viewer" group <<end>>
2959 // .. "Plot2d viewer" group <<start>>
2960 int plot2dGroup = pref->addPreference( tr( "PREF_GROUP_PLOT2DVIEWER" ), salomeCat ); //viewTab
2961 //pref->setItemProperty( "columns", 2, plot2dGroup );
2963 // ... -> background
2964 pref->addPreference( tr( "PREF_VIEWER_BACKGROUND_COLOR" ), plot2dGroup,
2965 LightApp_Preferences::Color, "Plot2d", "Background" );
2966 // ... -> selection color
2967 pref->addPreference( tr( "PREF_VIEWER_SELECTION" ), plot2dGroup,
2968 LightApp_Preferences::Color, "Plot2d", "SelectionColor" );
2970 // ... "Viewer" group <<start>>
2971 int plot2dViewerGroup = pref->addPreference( tr( "PREF_GROUP_VIEWER" ), plot2dGroup );
2973 // .... -> curve type
2974 int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dViewerGroup,
2975 LightApp_Preferences::Selector, "Plot2d", "CurveType" );
2976 aValuesList.clear();
2977 anIndicesList.clear();
2978 aValuesList << tr("PREF_POINTS") << tr("PREF_LINES") << tr("PREF_SPLINE");
2979 anIndicesList << 0 << 1 << 2 ;
2980 pref->setItemProperty( "strings", aValuesList, curveType );
2981 pref->setItemProperty( "indexes", anIndicesList, curveType );
2982 // .... -> marker size
2983 int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dViewerGroup,
2984 LightApp_Preferences::IntSpin, "Plot2d", "MarkerSize" );
2985 pref->setItemProperty( "min", 0, markerSize );
2986 pref->setItemProperty( "max", 100, markerSize );
2987 // .... -> horizontal scaling mode
2988 int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dViewerGroup,
2989 LightApp_Preferences::Selector, "Plot2d", "HorScaleMode" );
2990 aValuesList.clear();
2991 anIndicesList.clear();
2992 aValuesList << tr("PREF_LINEAR") << tr("PREF_LOGARITHMIC");
2993 anIndicesList << 0 << 1 ;
2994 pref->setItemProperty( "strings", aValuesList, horScale );
2995 pref->setItemProperty( "indexes", anIndicesList, horScale );
2996 // .... -> vertical scaling mode
2997 int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dViewerGroup,
2998 LightApp_Preferences::Selector, "Plot2d", "VerScaleMode" );
2999 pref->setItemProperty( "strings", aValuesList, verScale );
3000 pref->setItemProperty( "indexes", anIndicesList, verScale );
3002 // .... -> errors/deviation colot
3003 pref->addPreference( tr( "PREF_DEVIATION_COLOR" ), plot2dViewerGroup,
3004 LightApp_Preferences::Color, "Plot2d", "DeviationMarkerColor" );
3005 // .... -> deviation markers line size
3006 int deviationMarkerLw = pref->addPreference( tr( "PREF_DEVIATION_MARKER_LW" ), plot2dViewerGroup,
3007 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerLineWidth" );
3008 pref->setItemProperty( "min", 1, deviationMarkerLw );
3009 pref->setItemProperty( "max", 5, deviationMarkerLw );
3010 // .... -> deviation markers tick mark size
3011 int deviationMarkerTs = pref->addPreference( tr( "PREF_DEVIATION_MARKER_TS" ), plot2dViewerGroup,
3012 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerTickSize" );
3013 pref->setItemProperty( "min", 1, deviationMarkerTs );
3014 pref->setItemProperty( "max", 5, deviationMarkerTs );
3015 // .... "Viewer" group <<end>>
3017 // ... "Legend" group <<start>>
3018 int plot2dLegendGroup = pref->addPreference( tr( "PREF_GROUP_LEGEND" ), plot2dGroup );
3020 // .... -> show legend
3021 pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dLegendGroup,
3022 LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
3023 // .... -> legend position
3024 int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dLegendGroup,
3025 LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
3026 aValuesList.clear();
3027 anIndicesList.clear();
3028 aValuesList << tr("PREF_LEFT") << tr("PREF_RIGHT") << tr("PREF_TOP") << tr("PREF_BOTTOM");
3029 anIndicesList << 0 << 1 << 2 << 3 ;
3030 pref->setItemProperty( "strings", aValuesList, legendPosition );
3031 pref->setItemProperty( "indexes", anIndicesList, legendPosition );
3032 // .... -> Symbol type
3033 int legendSymbolType = pref->addPreference( tr( "PREF_LEGEND_SYMBOL_TYPE" ), plot2dLegendGroup,
3034 LightApp_Preferences::Selector, "Plot2d", "LegendSymbolType" );
3035 aValuesList.clear();
3036 anIndicesList.clear();
3037 aValuesList << tr("PREF_MARKER_ON_LINE") << tr("PREF_MARKER_ABOVE_LINE");
3038 anIndicesList << 0 << 1 ;
3039 pref->setItemProperty( "strings", aValuesList, legendSymbolType );
3040 pref->setItemProperty( "indexes", anIndicesList, legendSymbolType );
3041 // .... -> legend font
3042 pref->addPreference( tr( "PREF_LEGEND_FONT" ), plot2dLegendGroup, LightApp_Preferences::Font, "Plot2d", "LegendFont" );
3043 // ... -> font color
3044 pref->addPreference( tr( "PREF_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "LegendFontColor" );
3045 // ... -> selection font color
3046 pref->addPreference( tr( "PREF_SELECTED_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "SelectedLegendFontColor" );
3047 // ... "Legend" group <<end>>
3049 // .. "Plot2d viewer" group <<end>>
3051 // .. "PyViewer" preferences tab <<start>>
3052 int pyeditTab = pref->addPreference( tr( "PREF_TAB_PYEDITOR" ), salomeCat );
3053 // ... "Font settings" group <<start>>
3054 int pyFontGroup = pref->addPreference( tr( "PREF_GROUP_PY_FONT" ), pyeditTab );
3055 int pyFont = pref->addPreference( tr( "PREF_PY_FONT" ), pyFontGroup,
3056 LightApp_Preferences::Font, "PyEditor", "Font" );
3057 pref->setItemProperty( "features", QtxFontEdit::Family | QtxFontEdit::Size | QtxFontEdit::UserSize, pyFont );
3058 // ... "Font settings" group <<end>>
3059 // ... "Display settings" group <<start>>
3060 int pyDispGroup = pref->addPreference( tr( "PREF_GROUP_PY_DISPLAY" ), pyeditTab );
3061 pref->setItemProperty( "columns", 2, pyDispGroup );
3062 // ... -> current line highlight
3063 pref->addPreference( tr( "PREF_PY_CURRLINE_HIGHLIGHT" ), pyDispGroup,
3064 LightApp_Preferences::Bool, "PyEditor", "HighlightCurrentLine" );
3065 // ... -> text wrapping
3066 pref->addPreference( tr( "PREF_PY_TEXT_WRAP" ), pyDispGroup,
3067 LightApp_Preferences::Bool, "PyEditor", "TextWrapping" );
3068 // ... -> center cursor on scroll
3069 pref->addPreference( tr( "PREF_PY_CURSON_ON_SCROLL" ), pyDispGroup,
3070 LightApp_Preferences::Bool, "PyEditor", "CenterCursorOnScroll" );
3071 // ... -> line numbers area
3072 pref->addPreference( tr( "PREF_PY_LINE_NUMBS_AREA" ), pyDispGroup,
3073 LightApp_Preferences::Bool, "PyEditor", "LineNumberArea" );
3074 // ... "Display settings" group <<end>>
3076 // ... "Editor settings" group <<start>>
3077 int pyEditGroup = pref->addPreference( tr( "PREF_GROUP_PY_EDITOR" ), pyeditTab );
3078 // ... -> navigation mode
3079 int pyCompletion = pref->addPreference( tr( "PREF_PY_COMPLETION_MODE" ), pyEditGroup,
3080 LightApp_Preferences::Selector, "PyEditor", "CompletionPolicy" );
3081 aValuesList.clear();
3082 anIndicesList.clear();
3083 aValuesList << tr("PREF_PY_NONE") << tr("PREF_PY_AUTO") << tr("PREF_PY_MANUAL") << tr("PREF_PY_ALWAYS");
3084 anIndicesList << 0 << 1 << 2 << 3 ;
3085 pref->setItemProperty( "strings", aValuesList, pyCompletion );
3086 pref->setItemProperty( "indexes", anIndicesList, pyCompletion );
3087 // ... "Editor settings" group <<end>>
3089 // ... "Tab settings" group <<start>>
3090 int pyTabGroup = pref->addPreference( tr( "PREF_GROUP_PY_TAB" ), pyeditTab );
3091 pref->setItemProperty( "columns", 2, pyTabGroup );
3092 // ... -> tab whitespaces
3093 pref->addPreference( tr( "PREF_PY_TAB_WHITESPACES" ), pyTabGroup,
3094 LightApp_Preferences::Bool, "PyEditor", "TabSpaceVisible" );
3096 pref->addPreference( tr( "PREF_PY_TAB_SIZE" ), pyTabGroup,
3097 LightApp_Preferences::IntSpin, "PyEditor", "TabSize" );
3098 // ... "Tab settings" group <<end>>
3099 // ... "Vertical edge settings" group <<start>>
3100 int pyVertEdgeGroup = pref->addPreference( tr( "PREF_GROUP_VERT_EDGE" ), pyeditTab );
3101 pref->setItemProperty( "columns", 2, pyVertEdgeGroup );
3102 // ... -> vertical edge
3103 pref->addPreference( tr( "PREF_PY_VERT_EDGE" ), pyVertEdgeGroup,
3104 LightApp_Preferences::Bool, "PyEditor", "VerticalEdge" );
3105 // ... -> number of columns
3106 pref->addPreference( tr( "PREF_PY_NUM_COLUMNS" ), pyVertEdgeGroup,
3107 LightApp_Preferences::IntSpin, "PyEditor", "NumberColumns" );
3108 // ... "Vertical edge settings" group <<end>>
3109 // .. "PyEditor" preferences tab <<end>>
3111 // .. "Directories" preferences tab <<start>>
3112 int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat );
3113 // ... --> quick directories list
3114 int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab );
3115 pref->addPreference( tr( "" ), dirGroup,
3116 LightApp_Preferences::DirList, "FileDlg", "QuickDirList" );
3117 // .. "Directories" preferences tab <<end>>
3119 // .. "Object browser" preferences tab <<start>>
3120 int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
3122 // ... "Search tool" group <<start>>
3123 int stGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SEARCH_TOOL" ), obTab );
3124 // .... --> auto-hide
3125 pref->addPreference( tr( "PREF_AUTO_HIDE_SEARCH_TOOL" ), stGroup, LightApp_Preferences::Bool,
3126 "ObjectBrowser", "auto_hide_search_tool" );
3127 // ... "Search tool" group <<end>>
3129 // ... "Object browser settings" group <<start>>
3130 int objSetGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), obTab );
3131 pref->setItemProperty( "columns", 2, objSetGroup );
3132 // .... -> auto size first column
3133 pref->addPreference( tr( "PREF_AUTO_SIZE_FIRST" ), objSetGroup, LightApp_Preferences::Bool,
3134 "ObjectBrowser", "auto_size_first" );
3135 // .... -> auto size other columns
3136 pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool,
3137 "ObjectBrowser", "auto_size" );
3138 // .... -> resize columns on expand item
3139 pref->addPreference( tr( "PREF_RESIZE_ON_EXPAND_ITEM" ), objSetGroup, LightApp_Preferences::Bool,
3140 "ObjectBrowser", "resize_on_expand_item" );
3141 // .... -> browse to published object
3142 int browsePublished = pref->addPreference( tr( "PREF_BROWSE_TO_THE_PUBLISHED_OBJECT" ), objSetGroup, LightApp_Preferences::Selector,
3143 "ObjectBrowser", "browse_published_object" );
3144 aValuesList.clear();
3145 anIndicesList.clear();
3146 aValuesList << tr( "PREF_BROWSE_NEVER" ) << tr( "PREF_BROWSE_AFTER_APPLY_AND_CLOSE_ONLY" ) << tr( "PREF_BROWSE_ALWAYS" );
3147 anIndicesList << BP_Never << BP_ApplyAndClose << BP_Always;
3148 pref->setItemProperty( "strings", aValuesList, browsePublished );
3149 pref->setItemProperty( "indexes", anIndicesList, browsePublished );
3150 // ... "Object browser settings" group <<end>>
3151 // .. "Object browser" preferences tab <<end>>
3153 // .. "Shortcuts" preferences tab <<start>>
3154 int shortcutTab = pref->addPreference( tr( "PREF_TAB_SHORTCUTS" ), salomeCat );
3155 // ... "Shortcuts settings" group <<start>>
3156 int shortcutGroup = pref->addPreference( tr( "PREF_GROUP_SHORTCUTS" ), shortcutTab );
3157 pref->addPreference( tr( "" ), shortcutGroup,
3158 LightApp_Preferences::ShortcutTree, "shortcuts" );
3159 // ... "Shortcuts settings" group <<end>>
3160 // .. "Shortcuts" preferences tab <<end>>
3161 // . Top-level "SALOME" preferences group <<end>>
3167 Changes appearance of application according to changed preferences
3168 \param sec - section
3169 \param param - name of changed parameter
3171 void LightApp_Application::preferencesChanged( const QString& sec, const QString& param )
3173 SUIT_ResourceMgr* resMgr = resourceMgr();
3177 if ( sec == "viewers" && param == "drop_down_buttons" )
3179 ViewManagerList vmlist = viewManagers();
3180 foreach( SUIT_ViewManager* vm, vmlist )
3182 QVector<SUIT_ViewWindow*> vwlist = vm->getViews();
3183 foreach( SUIT_ViewWindow* vw, vwlist )
3184 if ( vw ) vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
3188 if ( sec == QString( "3DViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )))
3190 double sz = resMgr->doubleValue( sec, "trihedron_size", -1 );
3191 bool relative = resMgr->booleanValue( sec, "relative_size", true );
3192 QList<SUIT_ViewManager*> lst;
3193 #ifndef DISABLE_OCCVIEWER
3194 viewManagers( OCCViewer_Viewer::Type(), lst );
3195 QListIterator<SUIT_ViewManager*> itOCC( lst );
3196 while ( itOCC.hasNext() && sz >= 0 )
3198 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3199 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3202 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3203 occVM->setTrihedronSize( sz, relative );
3204 occVM->getAISContext()->UpdateCurrentViewer();
3207 #ifndef DISABLE_VTKVIEWER
3208 #ifndef DISABLE_SALOMEOBJECT
3209 viewManagers( SVTK_Viewer::Type(), lst );
3210 QListIterator<SUIT_ViewManager*> itVTK( lst );
3211 while ( itVTK.hasNext() && sz >= 0 )
3213 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3214 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3217 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3220 vtkVM->setTrihedronSize( sz, relative );
3228 if ( sec == QString( "3DViewer" ) && param == QString( "show_static_trihedron" ) )
3230 bool isVisible = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
3231 QList<SUIT_ViewManager*> lst;
3232 #ifndef DISABLE_OCCVIEWER
3233 viewManagers( OCCViewer_Viewer::Type(), lst );
3234 QListIterator<SUIT_ViewManager*> itOCC( lst );
3235 while ( itOCC.hasNext() )
3237 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3238 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3241 OCCViewer_Viewer* occVM = dynamic_cast<OCCViewer_Viewer*>( vm );
3244 occVM->setStaticTrihedronDisplayed( isVisible );
3248 #ifndef DISABLE_VTKVIEWER
3249 #ifndef DISABLE_SALOMEOBJECT
3250 viewManagers( SVTK_Viewer::Type(), lst );
3251 QListIterator<SUIT_ViewManager*> itVTK( lst );
3252 while ( itVTK.hasNext() )
3254 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3255 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3258 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3261 vtkVM->setStaticTrihedronVisible( isVisible );
3269 if ( sec == QString( "3DViewer" ) && param == QString( "navigation_mode" ) )
3271 int mode = resMgr->integerValue( "3DViewer", "navigation_mode", 0 );
3272 QList<SUIT_ViewManager*> lst;
3273 #ifndef DISABLE_OCCVIEWER
3274 viewManagers( OCCViewer_Viewer::Type(), lst );
3275 QListIterator<SUIT_ViewManager*> itOCC( lst );
3276 while ( itOCC.hasNext() )
3278 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3279 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3282 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3283 occVM->setInteractionStyle( mode );
3286 #ifndef DISABLE_VTKVIEWER
3287 #ifndef DISABLE_SALOMEOBJECT
3288 viewManagers( SVTK_Viewer::Type(), lst );
3289 QListIterator<SUIT_ViewManager*> itVTK( lst );
3290 while ( itVTK.hasNext() )
3292 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3293 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3296 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3297 if( vtkVM ) vtkVM->setInteractionStyle( mode );
3303 #ifndef DISABLE_OCCVIEWER
3304 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_preselection" ) )
3306 bool isToEnablePreselection = resMgr->booleanValue( "OCCViewer", "enable_preselection", true );
3307 QList<SUIT_ViewManager*> lst;
3308 viewManagers( OCCViewer_Viewer::Type(), lst );
3309 QListIterator<SUIT_ViewManager*> it( lst );
3310 while ( it.hasNext() )
3312 SUIT_ViewModel* vm = it.next()->getViewModel();
3313 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3316 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3317 occVM->enablePreselection( isToEnablePreselection );
3322 #ifndef DISABLE_OCCVIEWER
3323 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_selection" ) )
3325 bool isToEnableSelection = resMgr->booleanValue( "OCCViewer", "enable_selection", true );
3326 QList<SUIT_ViewManager*> lst;
3327 viewManagers( OCCViewer_Viewer::Type(), lst );
3328 QListIterator<SUIT_ViewManager*> it( lst );
3329 while ( it.hasNext() )
3331 SUIT_ViewModel* vm = it.next()->getViewModel();
3332 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3335 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3336 occVM->enableSelection( isToEnableSelection );
3341 #ifndef DISABLE_OCCVIEWER
3342 if ( sec == QString( "OCCViewer" ) && param == QString( "clipping_color" ) )
3344 QColor aColor = resMgr->colorValue( "OCCViewer", "clipping_color", QColor( 50, 50, 50 ) );
3345 QList<SUIT_ViewManager*> lst;
3346 viewManagers( OCCViewer_Viewer::Type(), lst );
3347 QListIterator<SUIT_ViewManager*> it( lst );
3348 while ( it.hasNext() )
3350 SUIT_ViewModel* vm = it.next()->getViewModel();
3351 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3354 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3355 occVM->setClippingColor( aColor );
3360 #ifndef DISABLE_OCCVIEWER
3361 if ( sec == QString( "OCCViewer" ) && ( param == QString( "clipping_use_default_texture" ) ||
3362 param == QString( "clipping_texture" ) ||
3363 param == QString( "clipping_modulate" ) ||
3364 param == QString( "clipping_scale" ) ) )
3366 bool isDefaultTextureUsed = resMgr->booleanValue( "OCCViewer", "clipping_use_default_texture" );
3367 QString aTexture = resMgr->stringValue( "OCCViewer", "clipping_texture" );
3368 bool isModulated = resMgr->booleanValue( "OCCViewer", "clipping_modulate" );
3369 double aScale = resMgr->doubleValue( "OCCViewer", "clipping_scale" );
3370 QList<SUIT_ViewManager*> lst;
3371 viewManagers( OCCViewer_Viewer::Type(), lst );
3372 QListIterator<SUIT_ViewManager*> it( lst );
3373 while ( it.hasNext() )
3375 SUIT_ViewModel* vm = it.next()->getViewModel();
3376 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3379 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3380 occVM->setClippingTextureParams( isDefaultTextureUsed, aTexture, isModulated, aScale );
3385 #ifndef DISABLE_OCCVIEWER
3386 if ( sec == QString( "OCCViewer" ) && param == QString( "projection_mode" ) )
3388 int mode = resMgr->integerValue( "OCCViewer", "projection_mode", 0 );
3389 QList<SUIT_ViewManager*> lst;
3390 viewManagers( OCCViewer_Viewer::Type(), lst );
3391 QListIterator<SUIT_ViewManager*> it( lst );
3392 while ( it.hasNext() )
3394 SUIT_ViewModel* vm = it.next()->getViewModel();
3395 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3398 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3399 occVM->setProjectionType( mode );
3405 #ifndef DISABLE_OCCVIEWER
3406 if (sec == QString("OCCViewer") && param == QString("adv_selection_mode"))
3408 int mode = resMgr->integerValue("OCCViewer", "adv_selection_mode", 0);
3409 QList<SUIT_ViewManager*> lst;
3410 viewManagers(OCCViewer_Viewer::Type(), lst);
3411 QListIterator<SUIT_ViewManager*> it(lst);
3412 while (it.hasNext())
3414 SUIT_ViewModel* vm = it.next()->getViewModel();
3415 if (!vm || !vm->inherits("OCCViewer_Viewer"))
3418 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3419 occVM->setSelectionStyle((OCCViewer_ViewWindow::SelectionStyle)mode);
3425 #ifndef DISABLE_OCCVIEWER
3426 if ( sec == QString( "OCCViewer" ) && param == QString( "stereo_type" ) )
3428 int mode = resMgr->integerValue( "OCCViewer", "stereo_type", 0 );
3429 QList<SUIT_ViewManager*> lst;
3430 viewManagers( OCCViewer_Viewer::Type(), lst );
3431 QListIterator<SUIT_ViewManager*> it( lst );
3432 while ( it.hasNext() )
3434 SUIT_ViewModel* vm = it.next()->getViewModel();
3435 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3438 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3439 occVM->setStereoType( mode );
3444 #ifndef DISABLE_OCCVIEWER
3445 if ( sec == QString( "OCCViewer" ) && param == QString( "anaglyph_filter" ) )
3447 int mode = resMgr->integerValue( "OCCViewer", "anaglyph_filter", 0 );
3448 QList<SUIT_ViewManager*> lst;
3449 viewManagers( OCCViewer_Viewer::Type(), lst );
3450 QListIterator<SUIT_ViewManager*> it( lst );
3451 while ( it.hasNext() )
3453 SUIT_ViewModel* vm = it.next()->getViewModel();
3454 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3457 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3458 occVM->setAnaglyphFilter( mode );
3463 #ifndef DISABLE_OCCVIEWER
3464 if ( sec == QString( "OCCViewer" ) && ( param == QString( "focus_type" ) ||
3465 param == QString( "focus_value" ) ) )
3467 int aType = resMgr->integerValue( "OCCViewer", "focus_type" );
3468 double aValue = resMgr->doubleValue( "OCCViewer", "focus_value" );
3469 QList<SUIT_ViewManager*> lst;
3470 viewManagers( OCCViewer_Viewer::Type(), lst );
3471 QListIterator<SUIT_ViewManager*> it( lst );
3472 while ( it.hasNext() )
3474 SUIT_ViewModel* vm = it.next()->getViewModel();
3475 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3478 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3479 occVM->setStereographicFocus( aType, aValue );
3484 #ifndef DISABLE_OCCVIEWER
3485 if ( sec == QString( "OCCViewer" ) && ( param == QString( "iod_type" ) ||
3486 param == QString( "iod_value" ) ) )
3488 int aType = resMgr->integerValue( "OCCViewer", "iod_type" );
3489 double aValue = resMgr->doubleValue( "OCCViewer", "iod_value" );
3490 QList<SUIT_ViewManager*> lst;
3491 viewManagers( OCCViewer_Viewer::Type(), lst );
3492 QListIterator<SUIT_ViewManager*> it( lst );
3493 while ( it.hasNext() )
3495 SUIT_ViewModel* vm = it.next()->getViewModel();
3496 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3499 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3500 occVM->setInterocularDistance( aType, aValue );
3505 #ifndef DISABLE_OCCVIEWER
3506 if ( sec == QString( "OCCViewer" ) && param == QString( "reverse_stereo" ) )
3508 bool reverse = resMgr->booleanValue( "OCCViewer", "reverse_stereo", false );
3509 QList<SUIT_ViewManager*> lst;
3510 viewManagers( OCCViewer_Viewer::Type(), lst );
3511 QListIterator<SUIT_ViewManager*> it( lst );
3512 while ( it.hasNext() )
3514 SUIT_ViewModel* vm = it.next()->getViewModel();
3515 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3518 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3519 occVM->setReverseStereo( reverse );
3524 #ifndef DISABLE_OCCVIEWER
3525 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_vsync" ) )
3527 bool enable = resMgr->booleanValue( "OCCViewer", "enable_vsync", true );
3528 QList<SUIT_ViewManager*> lst;
3529 viewManagers( OCCViewer_Viewer::Type(), lst );
3530 QListIterator<SUIT_ViewManager*> it( lst );
3531 while ( it.hasNext() )
3533 SUIT_ViewModel* vm = it.next()->getViewModel();
3534 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3537 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3538 occVM->setVSync( enable );
3543 #ifndef DISABLE_OCCVIEWER
3544 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_quad_buffer_support" ) )
3546 bool enable = resMgr->booleanValue( "OCCViewer", "enable_quad_buffer_support", false );
3547 QList<SUIT_ViewManager*> lst;
3548 viewManagers( OCCViewer_Viewer::Type(), lst );
3549 QListIterator<SUIT_ViewManager*> it( lst );
3550 while ( it.hasNext() )
3552 SUIT_ViewModel* vm = it.next()->getViewModel();
3553 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3556 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3557 occVM->setQuadBufferSupport( enable );
3562 if ( sec == QString( "3DViewer" ) && param == QString( "zooming_mode" ) )
3564 int mode = resMgr->integerValue( "3DViewer", "zooming_mode", 0 );
3565 QList<SUIT_ViewManager*> lst;
3566 #ifndef DISABLE_OCCVIEWER
3567 viewManagers( OCCViewer_Viewer::Type(), lst );
3568 QListIterator<SUIT_ViewManager*> itOCC( lst );
3569 while ( itOCC.hasNext() )
3571 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3572 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3575 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3576 occVM->setZoomingStyle( mode );
3579 #ifndef DISABLE_VTKVIEWER
3580 #ifndef DISABLE_SALOMEOBJECT
3581 viewManagers( SVTK_Viewer::Type(), lst );
3582 QListIterator<SUIT_ViewManager*> itVTK( lst );
3583 while ( itVTK.hasNext() )
3585 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3586 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3589 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3590 if( vtkVM ) vtkVM->setZoomingStyle( mode );
3596 #ifndef DISABLE_VTKVIEWER
3597 if ( sec == QString( "VTKViewer" ) && (param == QString( "speed_value" ) || param == QString( "speed_mode" )) )
3599 int speed = resMgr->integerValue( "VTKViewer", "speed_value", 10 );
3600 int mode = resMgr->integerValue( "VTKViewer", "speed_mode", 0 );
3601 QList<SUIT_ViewManager*> lst;
3602 #ifndef DISABLE_SALOMEOBJECT
3603 viewManagers( SVTK_Viewer::Type(), lst );
3604 QListIterator<SUIT_ViewManager*> it( lst );
3605 while ( it.hasNext() )
3607 SUIT_ViewModel* vm = it.next()->getViewModel();
3608 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3611 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3612 if( vtkVM ) vtkVM->setIncrementalSpeed( speed, mode );
3618 #ifndef DISABLE_VTKVIEWER
3619 if ( sec == QString( "VTKViewer" ) && param == QString( "projection_mode" ) )
3621 int mode = resMgr->integerValue( "VTKViewer", "projection_mode", 0 );
3622 QList<SUIT_ViewManager*> lst;
3623 #ifndef DISABLE_SALOMEOBJECT
3624 viewManagers( SVTK_Viewer::Type(), lst );
3625 QListIterator<SUIT_ViewManager*> it( lst );
3626 while ( it.hasNext() )
3628 SUIT_ViewModel* vm = it.next()->getViewModel();
3629 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3632 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3633 if( vtkVM ) vtkVM->setProjectionMode( mode );
3639 #ifndef DISABLE_VTKVIEWER
3640 if ( sec == QString( "VTKViewer" ) && param == QString( "stereo_type" ) )
3642 int mode = resMgr->integerValue( "VTKViewer", "stereo_type", 0 );
3643 QList<SUIT_ViewManager*> lst;
3644 #ifndef DISABLE_SALOMEOBJECT
3645 viewManagers( SVTK_Viewer::Type(), lst );
3646 QListIterator<SUIT_ViewManager*> it( lst );
3647 while ( it.hasNext() )
3649 SUIT_ViewModel* vm = it.next()->getViewModel();
3650 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3653 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3654 if( vtkVM ) vtkVM->setStereoType( mode );
3660 #ifndef DISABLE_VTKVIEWER
3661 if ( sec == QString( "VTKViewer" ) && param == QString( "anaglyph_filter" ) )
3663 int mode = resMgr->integerValue( "VTKViewer", "anaglyph_filter", 0 );
3664 QList<SUIT_ViewManager*> lst;
3665 #ifndef DISABLE_SALOMEOBJECT
3666 viewManagers( SVTK_Viewer::Type(), lst );
3667 QListIterator<SUIT_ViewManager*> it( lst );
3668 while ( it.hasNext() )
3670 SUIT_ViewModel* vm = it.next()->getViewModel();
3671 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3674 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3675 if( vtkVM ) vtkVM->setAnaglyphFilter( mode );
3681 #ifndef DISABLE_VTKVIEWER
3682 if ( sec == QString( "VTKViewer" ) && param == QString( "enable_quad_buffer_support" ) )
3684 int enable = resMgr->booleanValue( "VTKViewer", "enable_quad_buffer_support", false );
3685 QList<SUIT_ViewManager*> lst;
3686 #ifndef DISABLE_SALOMEOBJECT
3687 viewManagers( SVTK_Viewer::Type(), lst );
3688 QListIterator<SUIT_ViewManager*> it( lst );
3689 while ( it.hasNext() )
3691 SUIT_ViewModel* vm = it.next()->getViewModel();
3692 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3695 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3696 if( vtkVM ) vtkVM->setQuadBufferSupport( enable );
3702 #ifndef DISABLE_VTKVIEWER
3703 if ( sec == QString( "VTKViewer" ) && param == QString( "preselection" ) )
3705 int mode = resMgr->integerValue( "VTKViewer", "preselection", 0 );
3706 QList<SUIT_ViewManager*> lst;
3707 #ifndef DISABLE_SALOMEOBJECT
3708 viewManagers( SVTK_Viewer::Type(), lst );
3709 QListIterator<SUIT_ViewManager*> it( lst );
3710 while ( it.hasNext() )
3712 SUIT_ViewModel* vm = it.next()->getViewModel();
3713 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3716 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3717 if( vtkVM ) vtkVM->setPreSelectionMode( mode );
3723 #ifndef DISABLE_VTKVIEWER
3724 if ( sec == QString( "VTKViewer" ) && param == QString( "enable_selection" ) )
3726 bool isToEnableSelection = resMgr->booleanValue( "VTKViewer", "enable_selection", true );
3727 QList<SUIT_ViewManager*> lst;
3728 #ifndef DISABLE_SALOMEOBJECT
3729 viewManagers( SVTK_Viewer::Type(), lst );
3730 QListIterator<SUIT_ViewManager*> it( lst );
3731 while ( it.hasNext() )
3733 SUIT_ViewModel* vm = it.next()->getViewModel();
3734 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3737 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3738 if( vtkVM ) vtkVM->enableSelection( isToEnableSelection );
3744 #ifndef DISABLE_VTKVIEWER
3745 if ( sec == QString( "VTKViewer" ) && (param == QString( "spacemouse_func1_btn" ) ||
3746 param == QString( "spacemouse_func2_btn" ) ||
3747 param == QString( "spacemouse_func5_btn" ) ) )
3749 int btn1 = resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", 1 );
3750 int btn2 = resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", 2 );
3751 int btn3 = resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", 9 );
3752 QList<SUIT_ViewManager*> lst;
3753 #ifndef DISABLE_SALOMEOBJECT
3754 viewManagers( SVTK_Viewer::Type(), lst );
3755 QListIterator<SUIT_ViewManager*> it( lst );
3756 while ( it.hasNext() )
3758 SUIT_ViewModel* vm = it.next()->getViewModel();
3759 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3762 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3763 if( vtkVM ) vtkVM->setSpacemouseButtons( btn1, btn2, btn3 );
3768 if( sec=="ObjectBrowser" )
3770 SUIT_DataBrowser* ob = objectBrowser();
3774 if ( param=="auto_size_first" )
3776 bool autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
3777 ob->setAutoSizeFirstColumn( autoSizeFirst );
3778 if ( autoSizeFirst )
3779 ob->adjustFirstColumnWidth();
3781 else if ( param=="auto_size" ) {
3782 bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
3783 ob->setAutoSizeColumns(autoSize);
3785 ob->adjustColumnsWidth();
3787 else if ( param=="resize_on_expand_item" ) {
3788 bool resizeOnExpandItem = resMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
3789 ob->setResizeOnExpandItem(resizeOnExpandItem);
3791 else if ( param == "auto_hide_search_tool" ) {
3792 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
3798 if( param=="auto_save_interval" ) {
3799 myAutoSaveTimer->stop();
3800 int autoSaveInterval = resMgr->integerValue( "Study", "auto_save_interval", 0 );
3801 if ( activeStudy() && autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
3805 #ifndef DISABLE_PYCONSOLE
3806 if( sec=="PyConsole" && pythonConsole() )
3808 if ( param=="font" ) {
3809 pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) );
3811 else if ( param=="show_banner" ) {
3812 pythonConsole()->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
3814 else if ( param=="auto_completion" ) {
3815 pythonConsole()->setAutoCompletion( resMgr->booleanValue( "PyConsole", "auto_completion", true ) );
3822 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3824 if ( param == "visible_count" )
3825 mru->setVisibleCount( resMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
3826 else if ( param == "max_count" )
3827 mru->setHistoryCount( resMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
3828 else if ( param == "insert_mode" )
3829 mru->setInsertMode( resMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
3830 else if ( param == "link_type" )
3831 mru->setLinkType( resMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
3832 else if ( param == "show_clear" )
3833 mru->setClearPossible( resMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
3834 else if ( param == "show_mru" )
3835 mru->setVisible( resMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
3838 if ( sec == "language" && param == "language" )
3840 // VSR 18.06.2015 : commented out : single warning dialog box is now shown by the LightApp_PreferencesDlg
3841 //SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LANG_CHANGED" ) );
3843 if ( sec == "language" && param == "locale")
3845 // VSR 18.06.2015: commented out : single warning dialog box is now shown by the LightApp_PreferencesDlg
3846 //SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LOCALE_CHANGED" ) );
3848 if ( sec == "desktop" && param == "opaque_resize" ) {
3849 bool opaqueResize = resMgr->booleanValue( "desktop", "opaque_resize", false );
3850 // RNV: This code has been commented, because clearing of the QMainWindow::AnimatedDocks option
3851 // leads to strange behaviour of the dockable windows (at least at qt-5.6.1):
3852 // any dockable window can't be docked to the another area, except initial area.
3853 // It is possible to move window to another area, but it always returns to the initial area.
3855 // QMainWindow::DockOptions dopts = desktop()->dockOptions();
3856 // if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
3857 // else dopts &= ~QMainWindow::AnimatedDocks;
3858 // desktop()->setDockOptions( dopts );
3859 desktop()->setOpaqueResize( opaqueResize );
3860 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
3861 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
3864 #ifndef DISABLE_PLOT2DVIEWER
3865 QList<SUIT_ViewManager*> lst;
3866 viewManagers( Plot2d_Viewer::Type(), lst );
3867 QListIterator<SUIT_ViewManager*> itPlot2d( lst );
3868 while ( itPlot2d.hasNext() ) {
3869 SUIT_ViewManager* viewMgr = itPlot2d.next();
3870 SUIT_ViewModel* vm = viewMgr->getViewModel();
3871 if ( !vm || !vm->inherits( "Plot2d_Viewer" ) )
3874 //Plot2d_Viewer* Plot2dVM = dynamic_cast<Plot2d_Viewer*>( vm );
3876 viewMgr->setViewModel( vm );
3877 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
3879 Plot2d_ViewFrame* frame = wnd->getViewFrame();
3880 frame->SetPreference();
3889 void LightApp_Application::loadPreferences()
3891 CAM_Application::loadPreferences();
3893 SUIT_ResourceMgr* aResMgr = resourceMgr();
3898 static bool mru_load = true;
3901 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3903 mru->setVisible( aResMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
3904 mru->setVisibleCount( aResMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
3905 mru->setHistoryCount( aResMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
3906 mru->setInsertMode( aResMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
3907 mru->setLinkType( aResMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
3908 mru->setClearPossible( aResMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
3909 mru->loadLinks( aResMgr, "MRU" );
3915 QStringList mods = aResMgr->parameters( "windows_visibility" );
3916 for ( QStringList::const_iterator itr = mods.begin(); itr != mods.end(); ++itr )
3919 if ( aResMgr->value( "windows_visibility", *itr, arr ) )
3920 myWinVis.insert( *itr, arr );
3924 desktop()->retrieveGeometry( aResMgr->stringValue( "desktop", "geometry" ) );
3925 bool opaqueResize = aResMgr->booleanValue( "desktop", "opaque_resize", false );
3926 // QMainWindow::DockOptions dopts = desktop()->dockOptions();
3927 // if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
3928 // else dopts &= ~QMainWindow::AnimatedDocks;
3929 // desktop()->setDockOptions( dopts );
3930 desktop()->setOpaqueResize( opaqueResize );
3931 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
3932 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
3939 void LightApp_Application::savePreferences()
3941 CAM_Application::savePreferences();
3943 saveDockWindowsState();
3945 SUIT_ResourceMgr* aResMgr = resourceMgr();
3950 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3952 mru->saveLinks( aResMgr, "MRU" );
3954 for ( WinVis::const_iterator itr = myWinVis.begin(); itr != myWinVis.end(); ++itr )
3955 aResMgr->setValue( "windows_visibility", itr.key(), itr.value() );
3958 aResMgr->setValue( "desktop", "geometry", desktop()->storeGeometry() );
3960 #if GUI_DEVELOPMENT > 0
3961 aResMgr->setValue( "salome", "version", QString(GUI_VERSION_STR)+"dev" );
3963 aResMgr->setValue( "salome", "version", QString(GUI_VERSION_STR) );
3970 Updates desktop title
3972 void LightApp_Application::updateDesktopTitle()
3974 QString aTitle = applicationName();
3975 QString aVer = applicationVersion();
3976 if ( !aVer.isEmpty() )
3977 aTitle += QString( " " ) + aVer;
3979 if ( activeStudy() ) {
3980 QString sName = SUIT_Tools::file( activeStudy()->studyName().trimmed(), false );
3981 aTitle += QString( " - [%1]" ).arg( sName );
3984 desktop()->setWindowTitle( aTitle );
3988 \brief Get map of the operations which can be performed
3989 on the module activation.
3991 The method should return the map of the kind \c {<id>:<name>}
3992 where \c <id> is an integer identifier of the operation and
3993 \c <name> is a title for the button to be added to the
3994 dialog box. After user selects the required operation by the
3995 clicking the corresponding button in the dialog box, its identifier
3996 is passed to the moduleActionSelected() method to process
3999 \return map of the operations
4000 \sa moduleActionSelected()
4002 QMap<int, QString> LightApp_Application::activateModuleActions() const
4004 QMap<int, QString> opmap;
4005 opmap.insert( NewStudyId, tr( "ACTIVATE_MODULE_OP_NEW" ) );
4006 opmap.insert( OpenStudyId, tr( "ACTIVATE_MODULE_OP_OPEN" ) );
4011 \brief Called when the used selectes required operation chosen
4012 from "Activate module" dialog box.
4014 Performs the required operation according to the user choice.
4016 \param id operation identifier
4017 \sa activateModuleActions()
4019 void LightApp_Application::moduleActionSelected( const int id )
4034 Updates windows after close document
4036 void LightApp_Application::afterCloseDoc()
4040 CAM_Application::afterCloseDoc();
4044 Updates actions of active module
4046 void LightApp_Application::updateModuleActions()
4049 if ( activeModule() )
4050 modName = activeModule()->moduleName();
4052 LightApp_ModuleAction* moduleAction =
4053 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
4055 moduleAction->setActiveModule( modName );
4058 void LightApp_Application::removeModuleAction( const QString& modName )
4060 LightApp_ModuleAction* moduleAction =
4061 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
4063 moduleAction->removeModule( modName );
4066 bool LightApp_Application::checkModule( const QString& title )
4068 if ( title.isEmpty() )
4071 QString library = moduleLibrary( title, true );
4072 if ( library.isEmpty() )
4075 QString name = moduleName( title );
4077 bool isPyModule = library.contains( "SalomePyQtGUI" ) || library.contains( "SalomePyQtGUILight" );
4081 paths = QString( Qtx::getenv( "PATH" ) ).split( ";", QString::SkipEmptyParts );
4082 #elif defined(__APPLE__)
4083 paths = QString( Qtx::getenv( "DYLD_LIBRARY_PATH" ) ).split( ":", QString::SkipEmptyParts );
4085 paths = QString( Qtx::getenv( "LD_LIBRARY_PATH" ) ).split( ":", QString::SkipEmptyParts );
4088 bool isFound = false;
4089 QStringList::const_iterator it;
4090 for ( it = paths.begin(); it != paths.end() && !isFound; ++it )
4092 isFound = QFileInfo( Qtx::addSlash( *it ) + library ).exists();
4098 "****************************************************************" << std::endl <<
4099 " Warning: library " << qPrintable( library ) << " is not found!" << std::endl <<
4100 " Module " << qPrintable( title ) << " will not be available in GUI mode!" << std::endl <<
4101 "****************************************************************" << std::endl);
4107 QString pyModule = QString( "%1GUI.py" ).arg( name );
4109 paths = QString( Qtx::getenv( "PYTHONPATH" ) ).split( ";", QString::SkipEmptyParts );
4111 paths = QString( Qtx::getenv( "PYTHONPATH" ) ).split( ":", QString::SkipEmptyParts );
4114 for ( it = paths.begin(); it != paths.end() && !isFound; ++it )
4116 isFound = QFileInfo( Qtx::addSlash( *it ) + pyModule ).exists();
4122 "****************************************************************" << std::endl <<
4123 " Warning: Python module " << qPrintable( pyModule ) << " is not found!" << std::endl <<
4124 " Module " << qPrintable( title ) << " will not be available in GUI mode!" << std::endl <<
4125 "****************************************************************" << std::endl);
4134 Gets current windows.
4135 \param winMap - output current windows map.
4137 void LightApp_Application::currentWindows( QMap<int, int>& winMap ) const
4140 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
4141 ((LightApp_Module*)activeModule())->windows( winMap );
4143 defaultWindows( winMap );
4147 Gets current view managers.
4148 \param lst - output current view managers list.
4150 void LightApp_Application::currentViewManagers( QStringList& lst ) const
4153 if ( !activeStudy() )
4156 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
4157 ((LightApp_Module*)activeModule())->viewManagers( lst );
4159 defaultViewManagers( lst );
4165 void LightApp_Application::updateWindows()
4167 QMap<int, int> winMap;
4168 currentWindows( winMap );
4170 for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
4172 if ( !dockWindow( it.key() ) )
4173 getWindow( it.key() );
4176 for ( WinMap::ConstIterator it = myWin.begin(); it != myWin.end(); ++it )
4178 QWidget* wid = it.value();
4181 if ( winMap.contains( it.key() ) )
4182 wid->setVisible( true );
4183 else if ( !activeStudy() )
4186 wid->setVisible( false );
4189 loadDockWindowsState();
4191 if ( !activeModule() && infoPanel() )
4193 infoPanel()->clear();
4194 infoPanel()->setTitle( tr( "INFO_WELCOME_TO_SALOME" ) );
4196 int grp = infoPanel()->addGroup( tr( "INFO_GETTING_STARTED" ) );
4197 infoPanel()->addAction( action( FileNewId ), grp );
4198 infoPanel()->addLabel( action( FileNewId )->statusTip(), grp );
4199 infoPanel()->addAction( action( FileOpenId ), grp );
4200 infoPanel()->addLabel( action( FileOpenId )->statusTip(), grp );
4201 if ( HAS_TUTORIAL_URL ) {
4202 infoPanel()->addAction( action( TutorialsId ), grp );
4203 infoPanel()->addLabel( action( TutorialsId )->statusTip(), grp );
4205 infoPanel()->addAction( action( VideosId ), grp );
4206 infoPanel()->addLabel( action( VideosId )->statusTip(), grp );
4208 LightApp_ModuleAction* ma = qobject_cast<LightApp_ModuleAction*>(action(ModulesListId));
4209 if ( ma && ma->count() > 0 )
4211 grp = infoPanel()->addGroup( tr( "INFO_AVAILABLE_MODULES" ) );
4212 foreach ( QString mname, ma->modules() )
4214 infoPanel()->addAction( ma->moduleAction( mname ), grp );
4215 if ( !moduleDescription( mname ).isEmpty() )
4216 infoPanel()->addLabel( moduleDescription( mname ), grp );
4223 Updates view managers
4225 void LightApp_Application::updateViewManagers()
4228 currentViewManagers( lst );
4230 for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
4231 getViewManager( *it, true );
4235 Loads windows geometry
4237 void LightApp_Application::loadDockWindowsState()
4241 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
4242 bool storeWin = aResMgr->booleanValue( "Study", "store_positions", true );
4243 bool storeTb = aResMgr->booleanValue( "Study", "store_tool_positions", true );
4246 if ( activeModule() )
4247 modName = activeModule()->name();
4248 else if ( activeStudy() )
4249 modName = "nomodule";
4251 QtxResourceMgr::WorkingMode prevMode = aResMgr->setWorkingMode( QtxResourceMgr::IgnoreUserValues );
4252 QByteArray aDefaultState;
4253 aResMgr->value( "windows_geometry", modName, aDefaultState );
4254 QByteArray aDefaultVisibility;
4255 aResMgr->value( "windows_visibility", modName, aDefaultVisibility );
4256 bool hasDefaultVisibility = !aDefaultVisibility.isEmpty();
4257 aResMgr->setWorkingMode( prevMode );
4259 if( !storeWin && !storeTb && aDefaultState.isEmpty() && !hasDefaultVisibility)
4262 if ( aResMgr->hasValue("windows_geometry" ,modName ) ) {
4263 long version = Qtx::versionToId( aResMgr->stringValue( "windows_geometry_version", modName, "" ) );
4265 if ( version > Qtx::versionToId( "7.4.1" ) )
4266 aResMgr->value( "windows_geometry", modName , arr );
4268 arr = aDefaultState;
4269 QByteArray aTargetArray = processState(arr, storeWin, storeTb, true, aDefaultState);
4270 desktop()->restoreState( aTargetArray );
4273 QStringList mainToolbarsNames;
4274 mainToolbarsNames << "SalomeStandard" << "SalomeModules";
4275 QList<QToolBar*> mainToolbars = findToolBars( mainToolbarsNames );
4276 foreach( QToolBar* tb, mainToolbars ) tb->setVisible( true );
4278 if ( !myWinVis.contains( modName ) && aDefaultVisibility.isEmpty())
4281 QMap<QString, bool> *tbMap = 0;
4282 QMap<QString, bool> *dwMap = 0;
4284 QMap<QString, bool> userTbMap, userDwMap;
4285 dockWindowsState( myWinVis[modName], userTbMap, userDwMap );
4287 QMap<QString, bool> defaultTbMap, defaultDwMap;
4288 if(hasDefaultVisibility) {
4289 dockWindowsState( aDefaultVisibility, defaultTbMap, defaultDwMap);
4295 if(hasDefaultVisibility){
4296 tbMap = &defaultTbMap;
4303 if(hasDefaultVisibility){
4304 dwMap = &defaultDwMap;
4309 QList<QToolBar*> tbList = findToolBars();
4310 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit )
4312 QToolBar* tb = *tit;
4313 if ( tbMap->contains( tb->objectName() ) ) {
4314 tb->setVisible( (*tbMap)[tb->objectName()] );
4320 QList<QDockWidget*> dwList = desktop()->findChildren<QDockWidget*>();
4321 for ( QList<QDockWidget*>::iterator dit = dwList.begin(); dit != dwList.end(); ++dit )
4323 QDockWidget* dw = *dit;
4325 QObject* po = Qtx::findParent( dw, "QMainWindow" );
4326 if ( po != desktop() )
4329 if ( dwMap->contains( dw->objectName() ) )
4330 dw->setVisible( (*dwMap)[dw->objectName()] );
4338 Saves windows geometry
4340 void LightApp_Application::saveDockWindowsState()
4345 bool storeWin = resourceMgr()->booleanValue( "Study", "store_positions", true );
4346 bool storeTb = resourceMgr()->booleanValue( "Study", "store_tool_positions", true );
4348 if( !storeWin && !storeTb )
4352 if ( activeModule() )
4353 modName = activeModule()->name();
4354 else if ( activeStudy() )
4355 modName = "nomodule";
4357 QString versionId = GUI_VERSION_STR;
4358 #if GUI_DEVELOPMENT > 0
4362 QByteArray arr = desktop()->saveState();
4363 resourceMgr()->setValue( "windows_geometry", modName, processState(arr, storeWin, storeTb, false) );
4364 resourceMgr()->setValue( "windows_geometry_version", modName, versionId );
4367 if ( myWinVis.contains( modName ) )
4368 visArr = myWinVis[modName];
4370 QMap<QString, bool> tbMap, dwMap;
4371 dockWindowsState( visArr, tbMap, dwMap );
4373 QList<QToolBar*> tbList = desktop()->findChildren<QToolBar*>();
4374 for ( QList<QToolBar*>::iterator it = tbList.begin(); it != tbList.end(); ++it )
4377 tbMap.insert( tb->objectName(), tb->toggleViewAction()->isChecked() );
4380 QList<QDockWidget*> dwList = desktop()->findChildren<QDockWidget*>();
4381 for ( QList<QDockWidget*>::iterator it = dwList.begin(); it != dwList.end(); ++it )
4383 QDockWidget* wid = *it;
4384 dwMap.insert( wid->objectName(), wid->toggleViewAction()->isChecked() );
4387 visArr = dockWindowsState( tbMap, dwMap );
4389 myWinVis.insert( modName, visArr );
4392 QByteArray LightApp_Application::dockWindowsState( const QMap<QString, bool>& tb, const QMap<QString, bool>& dw ) const
4395 QDataStream stream( &visArr, QIODevice::WriteOnly );
4397 stream << (uchar)ToolBarMarker;
4398 stream << tb.size();
4399 for ( QMap<QString, bool>::const_iterator tit = tb.begin(); tit != tb.end(); ++tit )
4401 stream << tit.key();
4402 stream << (uchar)( tit.value() ? 1 : 0 );
4405 stream << (uchar)DockWidgetMarker;
4406 stream << dw.size();
4407 for ( QMap<QString, bool>::const_iterator wit = dw.begin(); wit != dw.end(); ++wit )
4409 stream << wit.key();
4410 stream << (uchar)( wit.value() ? 1 : 0 );
4416 void LightApp_Application::dockWindowsState( const QByteArray& arr, QMap<QString, bool>& tb, QMap<QString, bool>& dw ) const
4421 QByteArray visArr = arr;
4422 QDataStream stream( &visArr, QIODevice::ReadOnly );
4426 if ( marker != ToolBarMarker )
4431 for ( int i = 0; i < lines; ++i )
4434 stream >> objectName;
4437 tb.insert( objectName, shown );
4441 if ( marker != DockWidgetMarker )
4445 for ( int j = 0; j < lines; ++j )
4448 stream >> objectName;
4451 dw.insert( objectName, shown );
4456 Adds icon names for modules
4458 void LightApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) const
4462 SUIT_ResourceMgr* resMgr = resourceMgr();
4466 QStringList modList;
4467 modules( modList, false );
4469 for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )
4471 QString modName = *it;
4472 QString modIntr = moduleName( modName );
4473 QString modIcon = resMgr->stringValue( modIntr, "icon", QString() );
4475 if ( modIcon.isEmpty() )
4478 if ( SUIT_Tools::extension( modIcon ).isEmpty() )
4479 modIcon += QString( ".png" );
4481 iconMap.insert( modName, modIcon );
4486 Inserts items in popup, which necessary for current application
4488 void LightApp_Application::contextMenuPopup( const QString& type, QMenu* thePopup, QString& title )
4491 LightApp_SelectionMgr* selMgr = LightApp_Application::selectionMgr();
4492 bool cacheIsOn = selMgr->isSelectionCacheEnabled();
4493 selMgr->setSelectionCacheEnabled( true );
4495 SUIT_DataBrowser* ob = objectBrowser();
4497 CAM_Application::contextMenuPopup( type, thePopup, title );
4499 if ( ob && type == ob->popupClientType() ) {
4500 thePopup->addSeparator();
4501 QAction* a = thePopup->addAction( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
4502 if ( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) )
4503 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) );
4506 #ifndef DISABLE_SALOMEOBJECT
4507 if ( selMgr && ob ) {
4508 SALOME_ListIO selected;
4509 selMgr->selectedObjects( selected );
4510 if(selected.Extent() == 1){
4511 Handle(SALOME_InteractiveObject) anIObject = selected.First();
4512 SUIT_DataObject* obj = findObject(anIObject->getEntry());
4513 if(obj && obj->renameAllowed()) {
4514 QAction* a = new QAction(tr("MEN_RENAME_OBJ"), thePopup);
4515 connect( a, SIGNAL( triggered(bool) ), ob, SLOT( onStartEditing() ) );
4516 if ( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) )
4517 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) );
4519 QList<QAction*> acts = thePopup->actions();
4520 QAction* firstAction = acts.count() > 0 ? acts.first() : 0;
4521 thePopup->insertAction(firstAction,a);
4527 selMgr->setSelectionCacheEnabled( cacheIsOn );
4533 void LightApp_Application::createEmptyStudy()
4535 CAM_Application::createEmptyStudy();
4537 if ( objectBrowser() )
4538 objectBrowser()->updateTree();
4540 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
4541 if ( aResMgr && activeStudy() ) {
4542 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
4543 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
4548 void LightApp_Application::setDesktop( SUIT_Desktop* desk )
4550 CAM_Application::setDesktop( desk );
4553 connect( desk, SIGNAL( message( const QString& ) ),
4554 this, SLOT( onDesktopMessage( const QString& ) ), Qt::UniqueConnection );
4555 connect( desk, SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
4556 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
4557 /* connect( desk, SIGNAL( windowMoved( SUIT_ViewWindow* ) ),
4558 this, SLOT( onWindowMoved( SUIT_ViewWindow* ) ), Qt::UniqueConnection ); */
4564 \param mod - module to be activated
4566 bool LightApp_Application::activateModule( CAM_Module* mod )
4568 bool res = CAM_Application::activateModule( mod );
4570 if ( objectBrowser() )
4571 objectBrowser()->updateTree();
4577 \return keyborad accelerators manager object
4579 SUIT_Accel* LightApp_Application::accel() const
4585 Removes dead widget container from map
4587 void LightApp_Application::onWCDestroyed( QObject* ob )
4589 // remove destroyed widget container from windows map
4590 for ( WinMap::ConstIterator itr = myWin.begin(); itr != myWin.end(); ++itr )
4592 if ( itr.value() != ob )
4595 int key = itr.key();
4596 myWin.remove( key );
4601 void LightApp_Application::onMRUActivated( const QString& name )
4603 SUIT_Session* s = SUIT_Session::session();
4604 if ( s && s->activeApplication() == this )
4608 void LightApp_Application::onStylePreferences()
4610 #ifdef USE_SALOME_STYLE
4611 Style_PrefDlg dlg( desktop() );
4614 resourceMgr()->setValue( "Style", "use_salome_style", Style_Salome::isActive() );
4615 #endif // USE_SALOME_STYLE
4618 void LightApp_Application::onFullScreen(){
4619 if(myScreenHelper) {
4620 if(desktop()->isFullScreen())
4621 myScreenHelper->switchToNormalScreen();
4623 myScreenHelper->switchToFullScreen();
4628 Connects just added view manager
4630 void LightApp_Application::addViewManager( SUIT_ViewManager* vm )
4632 connect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
4633 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
4634 CAM_Application::addViewManager( vm );
4638 Remove view manager from memory
4640 void LightApp_Application::removeViewManager( SUIT_ViewManager* vm )
4642 disconnect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
4643 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
4644 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
4646 aStudy->removeObjectProperties( vm->getGlobalId() );
4648 CAM_Application::removeViewManager( vm );
4650 LightApp_SelectionMgr* selMgr = selectionMgr();
4651 QList<SUIT_Selector*> selectors;
4652 selMgr->selectors( selectors );
4653 foreach( SUIT_Selector* selector, selectors ) {
4654 if ( selector->owner() == vm->getViewModel() ) {
4659 // IPAL22894: Crash on closing OCC view
4665 Renames active window of desktop
4667 void LightApp_Application::onRenameWindow()
4672 QWidget* w = desktop()->activeWindow();
4677 QString name = QInputDialog::getText( w, tr( "TOT_RENAME" ), tr( "PRP_RENAME" ), QLineEdit::Normal, w->windowTitle(), &ok );
4678 if( ok && !name.isEmpty() )
4679 w->setWindowTitle( name );
4683 Closes active window of desktop
4685 void LightApp_Application::onCloseWindow()
4690 QWidget* w = desktop()->activeWindow();
4698 Closes all windows of desktop
4700 void LightApp_Application::onCloseAllWindow()
4702 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
4706 QList<SUIT_ViewWindow*> wndList = desk->windows();
4707 SUIT_ViewWindow* wnd;
4708 foreach( wnd, wndList )
4716 Groups all windows of desktop
4718 void LightApp_Application::onGroupAllWindow()
4720 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
4724 QtxWorkstack* wgStack = desk->workstack();
4730 \return default name for an active study
4732 void LightApp_Application::setDefaultStudyName( const QString& theName )
4734 QStringList anInfoList;
4735 modules( anInfoList, false );
4737 LightApp_Study* aStudy = (LightApp_Study*)activeStudy();
4738 if( anInfoList.count() == 1 && // to avoid a conflict between different modules
4739 !aStudy->isSaved() )
4741 aStudy->setStudyName( theName );
4742 updateDesktopTitle();
4747 Custom event handler
4749 bool LightApp_Application::event( QEvent* e )
4751 if( e && e->type()==2000 )
4753 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
4754 QString* d = ( QString* )ce->data();
4755 if( SUIT_MessageBox::question(0, tr("WRN_WARNING"),
4757 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
4758 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
4761 path << tr( "PREF_CATEGORY_SALOME" ) << tr( "PREF_TAB_GENERAL" )
4762 << tr( "PREF_GROUP_EXT_BROWSER" ) << tr( "PREF_APP" );
4763 showPreferences( path );
4769 return CAM_Application::event( e );
4772 /*! Check data object */
4773 bool LightApp_Application::checkDataObject(LightApp_DataObject* theObj)
4777 bool isSuitable = !theObj->entry().isEmpty() &&
4778 !theObj->componentDataType().isEmpty() &&
4779 !theObj->name().isEmpty();
4786 int LightApp_Application::openChoice( const QString& aName )
4788 int choice = CAM_Application::openChoice( aName );
4790 if ( choice == OpenExist ) // The document is already open.
4792 // Do you want to reload it?
4793 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "QUE_DOC_ALREADYOPEN" ).arg( aName ),
4794 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No ) == SUIT_MessageBox::Yes )
4795 choice = OpenReload;
4801 bool LightApp_Application::openAction( const int choice, const QString& aName )
4808 STD_Application* app = 0;
4809 SUIT_Session* session = SUIT_Session::session();
4810 QList<SUIT_Application*> appList = session->applications();
4811 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !app; ++it )
4813 if ( (*it)->activeStudy() && (*it)->activeStudy()->studyName() == aName )
4814 app = ::qobject_cast<STD_Application*>( *it );
4819 app->onCloseDoc( false );
4820 appList = session->applications();
4821 STD_Application* other = 0;
4822 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !other; ++it )
4823 other = ::qobject_cast<STD_Application*>( *it );
4826 res = other->onOpenDoc( aName );
4831 res = CAM_Application::openAction( choice, aName );
4838 QStringList LightApp_Application::viewManagersTypes() const
4840 QStringList aTypesList;
4841 aTypesList += myUserWmTypes;
4842 #ifndef DISABLE_GLVIEWER
4843 aTypesList<<GLViewer_Viewer::Type();
4845 #ifndef DISABLE_PLOT2DVIEWER
4846 aTypesList<<Plot2d_Viewer::Type();
4848 #ifndef DISABLE_QXGRAPHVIEWER
4849 aTypesList<<QxScene_Viewer::Type();
4851 #ifndef DISABLE_PVVIEWER
4852 aTypesList<<PVViewer_Viewer::Type();
4854 #ifndef DISABLE_PYVIEWER
4855 aTypesList<<PyViewer_Viewer::Type();
4857 #ifndef DISABLE_OCCVIEWER
4858 aTypesList<<OCCViewer_Viewer::Type();
4860 #ifndef DISABLE_VTKVIEWER
4861 #ifndef DISABLE_SALOMEOBJECT
4862 aTypesList<<SVTK_Viewer::Type();
4864 aTypesList<<VTKViewer_Viewer::Type();
4870 * Removes all view managers of known types
4871 * Other view managers are ignored
4873 void LightApp_Application::clearKnownViewManagers()
4875 QStringList aTypesList = viewManagersTypes();
4876 QList<SUIT_ViewManager*> aMgrList;
4877 viewManagers( aMgrList );
4878 foreach (SUIT_ViewManager* aMgr, aMgrList) {
4879 if (aTypesList.contains(aMgr->getType()))
4880 removeViewManager(aMgr);
4885 Copy of current selection
4887 void LightApp_Application::onCopy()
4889 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
4895 Paste of current data in clipboard
4897 void LightApp_Application::onPaste()
4899 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
4905 Browse (i.e. set focus on) the published objects
4906 \param theIsApplyAndClose - flag indicating that the dialog for creating objects
4907 has been accepted by Ok (or Apply & Close) button
4908 \param theIsOptimizedBrowsing - flag switching to optimized browsing mode
4909 (to select the first published object only)
4910 \return entry of the selected object
4912 QString LightApp_Application::browseObjects( const QStringList& theEntryList,
4913 const bool theIsApplyAndClose,
4914 const bool theIsOptimizedBrowsing )
4917 if( SUIT_ResourceMgr* aResourceMgr = resourceMgr() )
4919 int aBrowsePolicy = aResourceMgr->integerValue( "ObjectBrowser", "browse_published_object", (int)BP_Never );
4920 switch( aBrowsePolicy )
4924 case BP_ApplyAndClose:
4925 if( !theIsApplyAndClose )
4933 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
4937 SUIT_DataBrowser* anOB = objectBrowser();
4941 SUIT_AbstractModel* aModel = dynamic_cast<SUIT_AbstractModel*>( anOB->model() );
4945 QStringListIterator anIter( theEntryList );
4946 if( theIsOptimizedBrowsing )
4948 // go to the last entry
4950 if( anIter.hasPrevious() )
4954 // scroll to each entry in the list
4955 // (in optimized mode - to the last entry only)
4957 LightApp_DataObject* anObject = 0;
4958 while( anIter.hasNext() )
4960 anEntry = anIter.next();
4961 if( !anEntry.isEmpty() )
4963 anObject = aStudy->findObjectByEntry( anEntry );
4966 QModelIndex anIndex = aModel->index( anObject );
4967 anOB->treeView()->scrollTo( anIndex );
4972 // always select the last object
4973 if( anObject && !anEntry.isEmpty() )
4975 QList<SUIT_Selector*> aSelectorList;
4976 selectionMgr()->selectors( "ObjectBrowser", aSelectorList );
4977 if( !aSelectorList.isEmpty() )
4979 if( LightApp_OBSelector* aSelector = dynamic_cast<LightApp_OBSelector*>( aSelectorList.first() ) )
4981 bool anIsAutoBlock = aSelector->autoBlock();
4983 // temporarily disable auto block, to emit LightApp_SelectionMgr::currentSelectionChanged() signal
4984 aSelector->setAutoBlock( false );
4986 SUIT_DataOwnerPtrList aList;
4987 #ifndef DISABLE_SALOMEOBJECT
4988 Handle(SALOME_InteractiveObject) aSObj = new SALOME_InteractiveObject
4989 ( anObject->entry().toUtf8().constData(),
4990 anObject->componentDataType().toLatin1().constData(),
4991 anObject->name().toUtf8().constData() );
4992 LightApp_DataOwner* owner = new LightApp_DataOwner( aSObj );
4994 LightApp_DataOwner* owner = new LightApp_DataOwner( anEntry );
4997 aList.append( owner );
4998 selectionMgr()->setSelected( aList );
5001 // restore auto block flag
5002 aSelector->setAutoBlock( anIsAutoBlock );
5010 SUIT_DataObject* LightApp_Application::findObject( const QString& id ) const
5012 LightApp_Study* study = dynamic_cast<LightApp_Study*>( activeStudy() );
5013 return study ? study->findObjectByEntry( id ) : 0;
5017 Checks that an object can be renamed.
5018 \param entry entry of the object
5019 \brief Return \c true if object can be renamed
5021 bool LightApp_Application::renameAllowed( const QString& /*entry*/) const {
5026 Rename object by entry.
5027 \param entry entry of the object
5028 \param name new name of the object
5029 \brief Return \c true if rename operation finished successfully, \c false otherwise.
5031 bool LightApp_Application::renameObject( const QString& /*entry*/, const QString& /*name*/ ) {
5035 /*! Process standard messages from desktop */
5036 void LightApp_Application::onDesktopMessage( const QString& message )
5038 const QString sectionSeparator = "/";
5040 if ( message.toLower() == "updateobjectbrowser" ||
5041 message.toLower() == "updateobjbrowser" ) {
5042 // update object browser
5043 updateObjectBrowser();
5045 else if ( message.toLower().startsWith( "activate_viewer" ) ) {
5046 QString vtype = message.split( sectionSeparator ).last();
5047 if ( !vtype.isEmpty() )
5048 getViewManager( vtype, true );
5050 else if ( message.toLower().startsWith("register_module_in_study" ) ) {
5051 QString moduleName = message.split( sectionSeparator ).last();
5052 // Check name of current activating module name in order to avoid ciclik
5053 // call because of messages
5054 if (!property("activateModule").toBool()) {
5055 CAM_Module* mod = module(moduleName);
5057 mod = module(moduleTitle(moduleName));
5059 mod = loadModule(moduleName);
5061 mod = loadModule(moduleTitle(moduleName));
5067 CAM_Study* anActiveStudy = dynamic_cast<CAM_Study*>(activeStudy());
5068 if (anActiveStudy) {
5069 mod->connectToStudy(anActiveStudy);
5070 LightApp_DataModel* aDM = dynamic_cast<LightApp_DataModel*>(mod->dataModel());
5072 aDM->initRootObject();
5079 QStringList data = message.split( sectionSeparator );
5080 if ( data.count() > 1 ) {
5081 QString msgType = data[0].trimmed();
5082 LightApp_Module* sMod = 0;
5083 CAM_Module* mod = module( msgType );
5085 mod = module( moduleTitle( msgType ) );
5086 if ( mod && mod->inherits( "LightApp_Module" ) )
5087 sMod = (LightApp_Module*)mod;
5089 if ( msgType.toLower() == "preferences" ) {
5090 // requested preferences change: should be given as "preferences/<section>/<name>/<value>"
5091 // for example "preferences/Study/multi_file_dump/true"
5092 if ( data.count() > 3 ) {
5093 QString section = data[1].trimmed();
5094 QString param = data[2].trimmed();
5095 QString value = QStringList( data.mid(3) ).join( sectionSeparator );
5096 resourceMgr()->setValue( section, param, value );
5100 // received message for the module
5101 QString msg = QStringList( data.mid(1) ).join( sectionSeparator );
5102 sMod->message( msg );
5108 void LightApp_Application::onInfoPanelShown()
5110 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
5111 ((LightApp_Module*)activeModule())->updateInfoPanel();
5116 Returns all top level toolbars.
5117 Note : Result list contains only main window toolbars, not including toolbars from viewers.
5119 QList<QToolBar*> LightApp_Application::findToolBars( const QStringList& names )
5121 QList<QToolBar*> aResult;
5122 QList<QToolBar*> tbList = desktop()->findChildren<QToolBar*>();
5123 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit ) {
5124 QToolBar* tb = *tit;
5125 QObject* po = Qtx::findParent( tb, "QMainWindow" );
5126 if ( po != desktop() )
5128 if ( names.isEmpty() || names.contains( tb->objectName() ) )
5135 Internal method to parse toolbars and dockable windows state.
5137 QByteArray LightApp_Application::processState(QByteArray& input,
5138 const bool processWin,
5139 const bool processTb,
5140 const bool isRestoring,
5141 QByteArray defaultState) {
5144 bool hasDefaultState = !defaultState.isEmpty();
5145 bool isDockWinWriten = false;
5147 //Write date from users settings
5149 QDataStream tmpInputData(&input, QIODevice::ReadOnly);
5150 int marker, version;
5152 tmpInputData >> marker;
5153 tmpInputData >> version;
5154 tmpInputData >> dockmarker;
5155 tmpInputData >> nbDocWin;
5157 if(processWin && processTb && !isRestoring) {
5159 } else if(!processWin && !processTb ) {
5161 aRes = defaultState;
5163 QDataStream aData(&aRes, QIODevice::WriteOnly);
5164 QList<QToolBar*> aToolBars = findToolBars();
5167 for ( QList<QToolBar*>::iterator tit = aToolBars.begin(); tit != aToolBars.end(); ++tit ) {
5168 QToolBar* tb = *tit;
5169 aNames.append(tb->objectName());
5172 int toolBarMarkerIndex = getToolbarMarkerIndex(input,aNames);
5173 if(toolBarMarkerIndex < 0)
5175 QDataStream anInputData(&input, QIODevice::ReadOnly);
5177 int toolBarMarkerIndexDef = 0;
5178 if(hasDefaultState) {
5179 toolBarMarkerIndexDef = getToolbarMarkerIndex(defaultState, aNames);
5180 if(toolBarMarkerIndexDef < 0)
5183 QDataStream anInputDataDef(&defaultState, QIODevice::ReadOnly);
5185 QDataStream* aTargetData = 0;
5186 int aTargetIndex = -1;
5188 QByteArray currentArr = desktop()->saveState();
5189 QDataStream anInputDataCur(¤tArr, QIODevice::ReadOnly);
5190 bool useInputData = !isRestoring || (isRestoring && nbDocWin > 0);
5191 if(processWin && useInputData) {
5192 aTargetData = &anInputData;
5193 aTargetIndex = toolBarMarkerIndex;
5195 //Write date from default settings
5196 if(hasDefaultState) {
5197 aTargetData = &anInputDataDef;
5198 aTargetIndex = toolBarMarkerIndexDef;
5200 //If no default state, write current snapshot of the dockable windows
5202 aTargetData = &anInputDataCur;
5203 int toolBarMarkerIndexCur = getToolbarMarkerIndex(currentArr, aNames);
5204 aTargetIndex = toolBarMarkerIndexCur;
5209 if(aTargetData && aTargetIndex >= 0 ) {
5210 aTargetData->device()->seek(0);
5211 while( aTargetData->device()->pos() < aTargetIndex ) {
5216 isDockWinWriten = true;
5223 aTargetData = &anInputData;
5224 aTargetIndex = toolBarMarkerIndex;
5226 if(hasDefaultState) {
5227 aTargetData = &anInputDataDef;
5228 aTargetIndex = toolBarMarkerIndexDef;
5232 if(aTargetData && aTargetIndex >= 0) {
5234 if(!isDockWinWriten ) {
5235 //Write version marker
5236 int marker, version;
5237 aTargetData->device()->seek(0);
5238 *aTargetData >> marker;
5239 *aTargetData >> version;
5242 aData << (uchar) QDockWidgetMarker;
5244 int shift = 4*sizeof(int) + sizeof(QSize);
5245 index = aTargetIndex - shift;
5247 index = aTargetIndex;
5250 aTargetData->device()->seek(index);
5251 while(!aTargetData->atEnd()) {
5256 } else { // Not treat toolbars
5257 aData << (uchar) QToolBarMarker;
5258 aData << (int) 0; //Nb toolbars = 0
5265 \brief Emits operationFinished signal.
5266 \param theModuleName the name of the module which perfomed the operation
5267 \param theOperationName the operation name
5268 \param theEntryList the list of the created objects entries
5270 void LightApp_Application::emitOperationFinished( const QString& theModuleName,
5271 const QString& theOperationName,
5272 const QStringList& theEntryList )
5274 emit operationFinished( theModuleName, theOperationName, theEntryList );
5278 Update visibility state of given objects
5280 void LightApp_Application::updateVisibilityState( DataObjectList& theList,
5281 SUIT_ViewModel* theViewModel )
5283 if ( !theViewModel || theList.isEmpty() ) return;
5285 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
5286 if ( !aStudy ) return;
5288 SALOME_View* aView = dynamic_cast<SALOME_View*>( theViewModel );
5290 for ( DataObjectList::iterator itr = theList.begin(); itr != theList.end(); ++itr ) {
5291 LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>(*itr);
5293 if ( !obj || aStudy->isComponent( obj->entry() ) )
5296 QString mname = aStudy->componentDataType(obj->entry());
5297 LightApp_Displayer* aDisplayer = LightApp_Displayer::FindDisplayer(mname, false);
5299 Qtx::VisibilityState anObjState = Qtx::UnpresentableState;
5300 if ( aDisplayer->canBeDisplayed( obj->entry(), theViewModel->getType() ) ) {
5301 if ( aDisplayer->IsDisplayed( obj->entry(), aView ) )
5302 anObjState = Qtx::ShownState;
5304 anObjState = Qtx::HiddenState;
5306 aStudy->setVisibilityState( obj->entry(), anObjState );
5312 Update presentations of all displayed objects of theComponent in specified viewers
5314 void LightApp_Application::updatePresentations( const QString& theComponent,
5315 const QStringList& theViewManagerTypes )
5317 LightApp_Displayer* aDisplayer = LightApp_Displayer::FindDisplayer(theComponent, false);
5319 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
5320 DataObjectList aComps;
5321 bool isFound = false;
5322 aStudy->root()->children( aComps );
5323 DataObjectList::const_iterator aCompsIt = aComps.begin();
5324 for ( ; aCompsIt != aComps.end() && !isFound; aCompsIt++ ) {
5325 LightApp_DataObject* aComp = dynamic_cast<LightApp_DataObject*>( *aCompsIt );
5326 if ( aComp && aComp->componentDataType() == theComponent) {
5328 DataObjectList anObjs;
5329 aComp->children(anObjs, true);
5331 QList<SUIT_ViewManager*> aViewMgrs;
5332 QStringList::const_iterator itVMTypes = theViewManagerTypes.begin();
5333 for ( ; itVMTypes != theViewManagerTypes.end(); ++itVMTypes )
5334 viewManagers( *itVMTypes, aViewMgrs );
5336 DataObjectList::const_iterator itObjs = anObjs.begin();
5337 for ( ; itObjs != anObjs.end(); itObjs++ ) {
5338 LightApp_DataObject* anObj = dynamic_cast<LightApp_DataObject*>( *itObjs );
5339 QString anEntry = anObj->entry();
5341 QListIterator<SUIT_ViewManager*> itViewMgrs( aViewMgrs );
5342 while ( itViewMgrs.hasNext()) {
5343 SUIT_ViewModel* aVM = itViewMgrs.next()->getViewModel();
5345 SALOME_View* aView = dynamic_cast<SALOME_View*>(aVM);
5347 bool isDisp = aDisplayer->IsDisplayed( anEntry, aView );
5348 aDisplayer->Erase( anEntry, true, false, aView );
5350 aDisplayer->Display( anEntry, false, aView );
5362 * Called when window activated
5364 void LightApp_Application::onWindowActivated( SUIT_ViewWindow* theViewWindow )
5366 SUIT_DataBrowser* anOB = objectBrowser();
5369 SUIT_DataObject* rootObj = anOB->root();
5373 DataObjectList listObj = rootObj->children( true );
5375 SUIT_ViewModel* vmod = 0;
5376 if ( SUIT_ViewManager* vman = theViewWindow->getViewManager() )
5377 vmod = vman->getViewModel();
5378 updateVisibilityState( listObj, vmod );
5382 Called then view manager removed
5384 void LightApp_Application::onViewManagerRemoved( SUIT_ViewManager* )
5386 ViewManagerList lst;
5387 viewManagers( lst );
5388 if ( lst.count() == 1) { // in case if closed last view window
5389 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
5391 aStudy->setVisibilityStateForAll( Qtx::UnpresentableState );
5396 Check existing document.
5398 bool LightApp_Application::checkExistingDoc( bool closeExistingDoc )
5401 if( activeStudy() ) {
5402 int answer = !activeStudy()->isModified() ? 1 :
5403 SUIT_MessageBox::question( desktop(),
5404 tr( "APPCLOSE_CAPTION" ),
5405 tr( "STUDYCLOSE_DESCRIPTION" ),
5406 tr( "APPCLOSE_SAVE" ),
5407 tr( "APPCLOSE_CLOSE" ),
5408 tr( "APPCLOSE_CANCEL" ), 0 );
5410 if ( activeStudy()->isSaved() ) {
5412 if (closeExistingDoc) {
5415 } else if ( onSaveAsDoc() ) {
5416 if (closeExistingDoc) {
5417 if( !closeDoc( false ) ) {
5425 else if( answer == 1 ) {
5426 if (closeExistingDoc) {
5429 } else if( answer == 2 ) {
5436 #ifndef DISABLE_PYCONSOLE
5438 PyConsole_Interp* LightApp_Application::getPyInterp()
5440 static PyConsole_Interp* myInterp = 0;
5442 myInterp = createPyInterp();
5443 myInterp->initialize();
5448 PyConsole_Interp* LightApp_Application::createPyInterp()
5450 return new PyConsole_Interp();
5453 #endif // DISABLE_PYCONSOLE