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 if ( actName == modName )
548 putInfo( tr( "ACTIVATING_MODULE" ).arg( modName ) );
550 saveDockWindowsState();
553 infoPanel()->clear();
555 bool status = CAM_Application::activateModule( modName );
557 updateModuleActions();
565 updateViewManagers();
567 if ( activeStudy() && activeStudy()->root() && objectBrowser() ) {
568 if ( objectBrowser()->root() != activeStudy()->root() )
569 objectBrowser()->setRoot( activeStudy()->root() );
570 updateObjectBrowser( true );
573 if ( activeModule() ) activeModule()->updateModuleVisibilityState();
579 /*!Gets selection manager.*/
580 LightApp_SelectionMgr* LightApp_Application::selectionMgr() const
585 /*!Creat action "New window" for certain type of viewer:*/
586 void LightApp_Application::createActionForViewer( const int id,
588 const QString& suffix,
591 QString vtlt = tr( QString( "NEW_WINDOW_%1" ).arg( suffix ).toLatin1().constData() );
592 QString tip = tr( "CREATING_NEW_WINDOW" ).arg( vtlt.remove( "&" ) );
593 QAction* a = createAction( id, // menu action id
600 false, // toggle flag
602 SLOT( onNewWindow() ) ); // slot
603 createMenu( a, parentId, -1 );
608 void LightApp_Application::createActions()
610 CAM_Application::createActions();
612 SUIT_Desktop* desk = desktop();
613 SUIT_ResourceMgr* resMgr = resourceMgr();
616 createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIcon(),
617 tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
618 Qt::CTRL+Qt::Key_P, desk, false, this, SLOT( onPreferences() ) );
622 int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
624 int id = LightApp_Application::UserID + FIRST_HELP_ID;
628 // a) Link to web site
630 url = resMgr->stringValue("GUI", "site_url");
631 if ( !url.isEmpty() ) {
632 QString title = tr ( "SALOME_SITE" );
633 QAction* as = createAction( WebSiteId, title,
634 resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ),
636 0, desk, false, this, SLOT( onHelpContentsModule() ) );
638 createMenu( as, helpMenu, -1, 0 );
643 if ( HAS_FORUM_URL ) {
644 url = resMgr->stringValue("GUI", "forum_url");
645 if ( !url.isEmpty() ) {
646 QString title = tr ( "SALOME_FORUM" );
647 QAction* af = createAction( ForumId, title,
648 resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ),
650 0, desk, false, this, SLOT( onHelpContentsModule() ) );
652 createMenu( af, helpMenu, -1, 0 );
656 // c) Link to YouTube channel
657 if ( HAS_YOUTUBE_URL ) {
658 url = resMgr->stringValue("GUI", "channel_url");
659 if ( !url.isEmpty() ) {
660 createMenu( separator(), helpMenu, -1, 0 );
661 QString title = tr ( "SALOME_VIDEO_TUTORIALS" );
662 QAction* av = createAction( VideosId, title,
663 resMgr->loadPixmap( "LightApp", tr( "ICON_LIFE_RIGN" ), false ),
664 title, tr( "PRP_SALOME_VIDEO_TUTORIALS" ),
665 0, desk, false, this, SLOT( onHelpContentsModule() ) );
667 createMenu( av, helpMenu, -1, 0 );
671 // d) Link to Tutorials
672 if ( HAS_TUTORIAL_URL ) {
673 url = resMgr->stringValue("GUI", "tutorials_url");
674 if ( !url.isEmpty() ) {
675 QString title = tr ( "SALOME_TUTORIALS" );
676 QAction* as = createAction( TutorialsId, title,
677 resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ),
678 title, tr( "PRP_SALOME_TUTORIALS" ),
679 0, desk, false, this, SLOT( onHelpContentsModule() ) );
681 createMenu( as, helpMenu, -1, 0 );
685 // e) Help for modules
687 // - First create top-level menus to preserve correct order
688 QString userGuide = "User's Guide";
689 QString devGuide = "Developer's Guide";
690 createMenu( userGuide, helpMenu, -1, 5 );
691 createMenu( devGuide, helpMenu, -1, 5 );
693 QStringList aModuleList;
694 modules( aModuleList, false );
695 aModuleList.prepend( "GUI" );
696 aModuleList.prepend( "KERNEL" );
699 foreach( aModule, aModuleList ) {
700 if ( aModule.isEmpty() ) // module title (user name)
702 IMap <QString, QString> helpData; // list of help files for the module
703 QString helpSubMenu; // help submenu name (empty if not needed)
704 QString modName = moduleName( aModule ); // module name
705 if ( modName.isEmpty() ) modName = aModule; // for KERNEL and GUI
706 QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName ); // module root dir env variable
707 QString modDir = Qtx::getenv( rootDir.toUtf8().constData() ); // module root dir path
709 if (resMgr->hasValue( modName, "documentation" ) )
710 docSection = resMgr->stringValue(modName, "documentation");
711 else if ( resMgr->hasSection( modName + "_documentation" ) )
712 docSection = modName + "_documentation";
713 if ( !docSection.isEmpty() ) {
714 helpSubMenu = resMgr->stringValue( docSection, "sub_menu", "" );
715 if ( helpSubMenu.contains( "%1" ) )
716 helpSubMenu = helpSubMenu.arg( aModule );
717 foreach( QString paramName, resMgr->parameters( docSection ) ) {
718 QString key = paramName.contains( "%1" ) ? paramName.arg( aModule ) : paramName;
719 QString helpItem = getHelpItem( docSection, paramName );
720 if ( !helpItem.isEmpty() )
721 helpData.insert( key, helpItem );
725 if ( helpData.isEmpty() && !modDir.isEmpty() ) {
726 QStringList idxLst = QStringList() << modDir << "share" << "doc" << "salome" << "gui" << modName << "index.html";
727 QString indexFile = idxLst.join( QDir::separator() ); // index file
728 if ( QFile::exists( indexFile ) )
729 helpData.insert( tr( "%1 module Users's Guide" ).arg( aModule ), indexFile );
732 IMapConstIterator<QString, QString > fileIt;
733 for ( fileIt = helpData.begin(); fileIt != helpData.end(); fileIt++ ) {
734 QString helpItemPath = fileIt.key();
735 // remove all '//' occurances
736 while ( helpItemPath.contains( "//" ) )
737 helpItemPath.replace( "//", "" );
738 // obtain submenus hierarchy if given
739 QStringList smenus = helpItemPath.split( "/" );
740 helpItemPath = smenus.takeLast();
741 // workaround for User's Guide and Developer's Guide to avoid having single item in module's submenu.
742 if ( helpItemPath == userGuide || helpItemPath == devGuide ) {
743 QString menuPath = smenus.join( "/" );
744 QStringList allKeys = helpData.keys();
745 QStringList total = allKeys.filter( QRegExp( QString( "^%1" ).arg( menuPath ) ) );
746 if ( total.count() == 1 && smenus.count() > 0 )
747 helpItemPath = smenus.takeLast();
749 QPixmap helpIcon = fileIt.value().startsWith( "http", Qt::CaseInsensitive ) ?
750 resMgr->loadPixmap( "STD", tr( "ICON_WWW" ), false ) : resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false );
751 QAction* a = createAction( id, helpItemPath, helpIcon, helpItemPath, helpItemPath,
752 0, desk, false, this, SLOT( onHelpContentsModule() ) );
753 a->setData( fileIt.value() );
754 if ( !helpSubMenu.isEmpty() ) {
755 smenus.prepend( helpSubMenu );
757 // create sub-menus hierarchy
758 int menuId = helpMenu;
759 foreach ( QString subMenu, smenus )
760 menuId = createMenu( subMenu, menuId, -1, 5 );
761 createMenu( a, menuId, -1, ( menuId != helpMenu && (helpItemPath == userGuide || helpItemPath == devGuide) ) ? 0 : 5 );
766 // - Additional help items
768 createMenu( separator(), helpMenu, -1, 10 );
770 QStringList addHelpItems = resMgr->parameters( "add_help" );
771 foreach ( QString paramName, addHelpItems ) {
772 QString helpItem = getHelpItem( "add_help", paramName );
773 if ( !helpItem.isEmpty() )
775 QPixmap helpIcon = helpItem.startsWith( "http", Qt::CaseInsensitive ) ?
776 resMgr->loadPixmap( "STD", tr( "ICON_WWW" ), false ) : resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false );
777 QAction* a = createAction( id++, paramName, helpIcon, paramName, paramName,
778 0, desk, false, this, SLOT( onHelpContentsModule() ) );
779 a->setData( helpItem );
780 createMenu( a, helpMenu, -1, 10 );
785 static QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), 0 );
786 connect( mru, SIGNAL( activated( const QString& ) ), this, SLOT( onMRUActivated( const QString& ) ) );
787 registerAction( MRUId, mru );
789 // default icon for neutral point ('SALOME' module)
790 QPixmap defIcon = resMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
791 if ( defIcon.isNull() )
792 defIcon = QPixmap( imageEmptyIcon );
794 //! default icon for any module
795 QPixmap modIcon = resMgr->loadPixmap( "LightApp", tr( "APP_MODULE_ICO" ), false );
796 if ( modIcon.isNull() )
797 modIcon = QPixmap( imageEmptyIcon );
800 modules( modList, false );
802 if ( modList.count() > 1 )
804 LightApp_ModuleAction* moduleAction =
805 new LightApp_ModuleAction( tr( "APP_NAME" ), defIcon, desk );
807 QMap<QString, QString> iconMap;
808 moduleIconNames( iconMap );
810 const int iconSize = 20;
812 QStringList::Iterator it;
813 for ( it = modList.begin(); it != modList.end(); ++it )
815 QString modName = moduleName( *it );
818 if ( iconMap.contains( *it ) )
819 iconName = iconMap[*it];
821 QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
826 "****************************************************************" << std::endl <<
827 " Warning: icon for " << qPrintable(*it) << " is not found!" << std::endl <<
828 " Using the default icon." << std::endl <<
829 "****************************************************************" << std::endl);
831 icon = Qtx::scaleIcon( icon, iconSize );
833 moduleAction->insertModule( *it, icon );
836 connect( moduleAction, SIGNAL( moduleActivated( const QString& ) ),
837 this, SLOT( onModuleActivation( const QString& ) ) );
838 registerAction( ModulesListId, moduleAction );
842 int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, MenuWindowId, 100 );
843 int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
845 createAction( CloseId, tr( "TOT_CLOSE" ), QIcon(), tr( "MEN_DESK_CLOSE" ), tr( "PRP_CLOSE" ),
846 Qt::CTRL+Qt::Key_F4, desk, false, this, SLOT( onCloseWindow() ) );
847 createAction( CloseAllId, tr( "TOT_CLOSE_ALL" ), QIcon(), tr( "MEN_DESK_CLOSE_ALL" ), tr( "PRP_CLOSE_ALL" ),
848 0, desk, false, this, SLOT( onCloseAllWindow() ) );
849 createAction( GroupAllId, tr( "TOT_GROUP_ALL" ), QIcon(), tr( "MEN_DESK_GROUP_ALL" ), tr( "PRP_GROUP_ALL" ),
850 0, desk, false, this, SLOT( onGroupAllWindow() ) );
852 createMenu( CloseId, windowMenu, 0, -1 );
853 createMenu( CloseAllId, windowMenu, 0, -1 );
854 createMenu( GroupAllId, windowMenu, 0, -1 );
855 createMenu( separator(), windowMenu, -1, 0 );
857 #ifndef DISABLE_GLVIEWER
858 createActionForViewer( NewGLViewId, newWinMenu, QString::number( 0 ), Qt::ALT+Qt::Key_G );
860 #ifndef DISABLE_PLOT2DVIEWER
861 createActionForViewer( NewPlot2dId, newWinMenu, QString::number( 1 ), Qt::ALT+Qt::Key_P );
863 #ifndef DISABLE_OCCVIEWER
864 createActionForViewer( NewOCCViewId, newWinMenu, QString::number( 2 ), Qt::ALT+Qt::Key_O );
866 #ifndef DISABLE_VTKVIEWER
867 createActionForViewer( NewVTKViewId, newWinMenu, QString::number( 3 ), Qt::ALT+Qt::Key_K );
869 #ifndef DISABLE_QXGRAPHVIEWER
870 createActionForViewer( NewQxSceneViewId, newWinMenu, QString::number( 4 ), Qt::ALT+Qt::Key_S );
872 #ifndef DISABLE_GRAPHICSVIEW
873 createActionForViewer( NewGraphicsViewId, newWinMenu, QString::number( 5 ), Qt::ALT+Qt::Key_C );
875 #ifndef DISABLE_PVVIEWER
876 createActionForViewer( NewPVViewId, newWinMenu, QString::number( 6 ), Qt::ALT+Qt::Key_A );
878 #ifndef DISABLE_PYVIEWER
879 createActionForViewer( NewPyViewerId, newWinMenu, QString::number( 7 ), Qt::ALT+Qt::Key_Y );
882 createAction( RenameId, tr( "TOT_RENAME" ), QIcon(), tr( "MEN_DESK_RENAME" ), tr( "PRP_RENAME" ),
883 Qt::ALT+Qt::SHIFT+Qt::Key_R, desk, false, this, SLOT( onRenameWindow() ) );
884 createMenu( RenameId, windowMenu, -1 );
886 int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
887 createMenu( PreferencesId, fileMenu, 50, -1 );
888 createMenu( separator(), fileMenu, -1, 50, -1 );
890 createMenu( separator(), fileMenu, -1, 100, -1 );
891 createMenu( MRUId, fileMenu, 100, -1 );
892 createMenu( separator(), fileMenu, -1, 100, -1 );
894 #ifdef USE_SALOME_STYLE
895 createAction( StyleId, tr( "TOT_THEME" ), QIcon(), tr( "MEN_DESK_THEME" ), tr( "PRP_THEME" ),
896 0, desk, false, this, SLOT( onStylePreferences() ) );
897 #endif // USE_SALOME_STYLE
899 createAction( FullScreenId, tr( "TOT_FULLSCREEN" ), QIcon(), tr( "MEN_DESK_FULLSCREEN" ), tr( "PRP_FULLSCREEN" ),
900 Qt::Key_F11, desk, false, this, SLOT( onFullScreen() ) );
903 int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1 );
904 createMenu( separator(), viewMenu, -1, 20, -1 );
905 #ifdef USE_SALOME_STYLE
906 createMenu( StyleId, viewMenu, 20, -1 );
907 #endif // USE_SALOME_STYLE
908 createMenu( FullScreenId, viewMenu, 20, -1 );
910 int modTBar = createTool( tr( "INF_TOOLBAR_MODULES" ), // title (language-dependant)
911 QString( "SalomeModules" ) ); // name (language-independant)
912 createTool( ModulesListId, modTBar );
915 /*!On module activation action.*/
916 void LightApp_Application::onModuleActivation( const QString& modName )
918 // Force user to create/open a study before module activation
919 QMap<QString, QString> iconMap;
920 moduleIconNames( iconMap );
921 QPixmap icon = resourceMgr()->loadPixmap( moduleName( modName ), iconMap[ modName ], false );
923 icon = resourceMgr()->loadPixmap( "LightApp", tr( "APP_MODULE_BIG_ICO" ), false ); // default icon for any module
925 bool cancelled = false;
927 while ( !modName.isEmpty() && !activeStudy() && !cancelled ){
928 LightApp_ModuleDlg aDlg( desktop(), modName, icon );
929 QMap<int, QString> opmap = activateModuleActions();
930 for ( QMap<int, QString>::ConstIterator it = opmap.begin(); it != opmap.end(); ++it )
931 aDlg.addButton( it.value(), it.key() );
933 int res = aDlg.exec();
935 // some operation is selected
936 moduleActionSelected( res );
940 putInfo( tr("INF_CANCELLED") );
942 LightApp_ModuleAction* moduleAction =
943 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
945 moduleAction->setActiveModule( QString() );
951 activateModule( modName );
954 /*!Default module activation.*/
955 QString LightApp_Application::defaultModule() const
957 QStringList aModuleNames;
958 modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration
959 //! If there's the one and only module --> activate it automatically
960 //! TODO: Possible improvement - default module can be taken from preferences
961 return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" );
964 /*!On new window slot.*/
965 void LightApp_Application::onNewWindow()
967 const QObject* obj = sender();
968 if ( !obj || !obj->inherits( "QAction" ) )
972 int id = actionId( (QAction*)obj );
975 #ifndef DISABLE_GLVIEWER
977 type = GLViewer_Viewer::Type();
980 #ifndef DISABLE_PLOT2DVIEWER
982 type = Plot2d_Viewer::Type();
985 #ifndef DISABLE_OCCVIEWER
987 type = OCCViewer_Viewer::Type();
990 #ifndef DISABLE_VTKVIEWER
992 type = VTKViewer_Viewer::Type();
995 #ifndef DISABLE_QXGRAPHVIEWER
996 case NewQxSceneViewId:
997 type = QxScene_Viewer::Type();
1000 #ifndef DISABLE_GRAPHICSVIEW
1001 case NewGraphicsViewId:
1002 type = GraphicsView_Viewer::Type();
1005 #ifndef DISABLE_PVVIEWER
1007 type = PVViewer_Viewer::Type();
1010 #ifndef DISABLE_PYVIEWER
1012 type = PyViewer_Viewer::Type();
1017 if ( !type.isEmpty() )
1018 createViewManager( type );
1022 SLOT: Creates new document
1024 void LightApp_Application::onNewDoc()
1026 if ( !checkExistingDoc() )
1029 //asl: fix for 0020515
1030 saveDockWindowsState();
1032 CAM_Application::onNewDoc();
1036 SLOT: Opens new document
1038 void LightApp_Application::onOpenDoc()
1040 SUIT_Study* study = activeStudy();
1042 if ( !checkExistingDoc( false ) )
1045 QString aName = getFileName( true, QString(), getFileFilter( true ), QString(), 0 );
1046 if ( aName.isNull() ) //Cancel
1051 if ( !study ) // new study will be create in THIS application
1054 updateViewManagers();
1058 bool LightApp_Application::canOpenDoc( const QString& )
1064 SLOT: Opens new document.
1065 \param aName - name of file
1067 bool LightApp_Application::onOpenDoc( const QString& aName )
1069 if ( !canOpenDoc(aName)) {
1070 bool showError = !property("open_study_from_command_line").isValid() ||
1071 !property("open_study_from_command_line").toBool();
1073 putInfo( tr("OPEN_DOCUMENT_PROBLEM") );
1075 SUIT_MessageBox::critical( desktop(), tr("ERR_ERROR"), tr("OPEN_DOCUMENT_PROBLEM"));
1082 if ( !checkExistingDoc() )
1085 saveDockWindowsState();
1087 // We should take mru action first because this application instance can be deleted later.
1088 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
1090 bool res = CAM_Application::onOpenDoc( aName );
1095 mru->insert( aName );
1097 mru->remove( aName );
1103 SLOT: Displays "About" message box
1105 void LightApp_Application::onHelpAbout()
1107 LightApp_AboutDlg dlg( applicationName(), applicationVersion(), desktop() );
1112 Private SLOT: Called on selection is changed
1113 Dispatchs active module that selection is changed
1115 void LightApp_Application::onSelection()
1117 //MESSAGE("onSelection")
1118 onSelectionChanged();
1120 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
1121 ((LightApp_Module*)activeModule())->selectionChanged();
1126 \param study - SUIT_Study.
1128 void LightApp_Application::setActiveStudy( SUIT_Study* study )
1130 CAM_Application::setActiveStudy( study );
1134 Enables/Disables menu items and toolbar buttons. Rebuild menu
1136 void LightApp_Application::updateCommandsStatus()
1138 CAM_Application::updateCommandsStatus();
1141 #ifndef DISABLE_GLVIEWER
1142 a = action( NewGLViewId );
1144 a->setEnabled( activeStudy() );
1147 #ifndef DISABLE_PLOT2DVIEWER
1148 a = action( NewPlot2dId );
1150 a->setEnabled( activeStudy() );
1153 #ifndef DISABLE_OCCVIEWER
1154 a = action( NewOCCViewId );
1156 a->setEnabled( activeStudy() );
1159 #ifndef DISABLE_VTKVIEWER
1160 a = action( NewVTKViewId );
1162 a->setEnabled( activeStudy() );
1165 #ifndef DISABLE_QXGRAPHVIEWER
1166 a = action( NewQxSceneViewId );
1168 a->setEnabled( activeStudy() );
1171 #ifndef DISABLE_GRAPHICSVIEW
1172 a = action( NewGraphicsViewId );
1174 a->setEnabled( activeStudy() );
1177 #ifndef DISABLE_PVVIEWER
1178 a = action( NewPVViewId );
1180 a->setEnabled( activeStudy() );
1183 #ifndef DISABLE_PYVIEWER
1184 a = action( NewPyViewerId );
1186 a->setEnabled( activeStudy() );
1192 Runs system command in separate thread
1194 class RunBrowser: public QThread
1197 static void execute( LightApp_Application* application,
1198 const QString& browser,
1199 const QString& parameters,
1200 const QString& url )
1202 (new RunBrowser( application, browser, parameters, url ))->start();
1206 RunBrowser( LightApp_Application* application,
1207 const QString& browser,
1208 const QString& parameters,
1210 : myApplication( application ),
1211 myBrowser( browser ),
1212 myParameters( parameters ),
1215 if ( !myUrl.startsWith( "http", Qt::CaseInsensitive ) )
1218 if ( myUrl.startsWith( "file://", Qt::CaseInsensitive ) )
1219 myUrl = myUrl.remove( 0, QString( "file://" ).count() );
1220 // For the external browser we always specify 'file://' protocol,
1221 // because some web browsers (e.g. Mozilla Firefox) can't open local file without protocol.
1222 myUrl = myUrl.prepend( "file://" );
1224 connect(this, SIGNAL(finished()), SLOT(deleteLater()));
1229 if ( !myBrowser.isEmpty() && !myUrl.isEmpty() )
1231 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
1233 QString cmdLine = QString( "\"%1\" %2 \"%3\"" ).arg( myBrowser, myParameters, myUrl );
1235 QString cmdLine = QString( "%1 %2 \"%3\"" ).arg( myBrowser, myParameters, myUrl );
1236 // remove LD_LIBRARY_PATH from the environement before starting launcher to avoid bad interactions.
1237 // (especially in the case of universal binaries)
1238 env.remove("LD_LIBRARY_PATH");
1240 QProcess* proc = new QProcess();
1241 proc->setProcessEnvironment(env);
1242 proc->start( cmdLine );
1243 if ( !proc->waitForStarted() )
1245 SALOME_CustomEvent* ce2000 = new SALOME_CustomEvent( 2000 );
1246 QString* msg = new QString( QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).arg( myBrowser, myUrl ) );
1247 ce2000->setData( msg );
1248 QApplication::postEvent( myApplication, ce2000 );
1254 LightApp_Application* myApplication;
1256 QString myParameters;
1260 void LightApp_Application::showHelp( const QString& path )
1262 SUIT_ResourceMgr* resMgr = resourceMgr();
1264 #if DISABLE_QTXWEBBROWSER
1265 bool useExternalBrowser = true;
1267 bool useExternalBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1270 if ( useExternalBrowser )
1273 QString browser = resMgr->stringValue( "ExternalBrowser", "winapplication" ) ;
1275 QString browser = resMgr->stringValue( "ExternalBrowser", "application" );
1277 QString parameters = resMgr->stringValue("ExternalBrowser", "parameters");
1279 if ( !browser.isEmpty() )
1281 RunBrowser::execute( this, browser, parameters, path );
1285 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1286 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1287 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1290 path << tr( "PREF_CATEGORY_SALOME" ) << tr( "PREF_TAB_GENERAL" )
1291 << tr( "PREF_GROUP_EXT_BROWSER" ) << tr( "PREF_APP" );
1292 showPreferences( path );
1298 QStringList cmdLine;
1299 cmdLine << QString( "--language=%1" ).arg( resMgr->stringValue( "language", "language" ) );
1300 cmdLine << QString( "--add=%1" ).arg( QApplication::instance()->applicationPid() );
1302 QProcess::startDetached( "HelpBrowser", cmdLine );
1307 SLOT: Displays help contents for choosen module
1309 void LightApp_Application::onHelpContentsModule()
1311 const QAction* a = (QAction*) sender();
1312 QString helpFile = a->data().toString();
1313 if ( !helpFile.isEmpty() )
1314 showHelp( helpFile );
1318 SLOT: Displays contextual help (e.g. for choosen dialog)
1320 void LightApp_Application::onHelpContextModule( const QString& component,
1322 const QString& context )
1325 if ( !url.startsWith( "http", Qt::CaseInsensitive ) )
1328 QFileInfo fi( url );
1329 if ( fi.isRelative() && !component.isEmpty() )
1331 QString rootDir = Qtx::getenv( (component + "_ROOT_DIR").toLatin1().constData() );
1332 if ( !rootDir.isEmpty() )
1334 path = (QStringList() << rootDir << "share" << "doc" << "salome" << "gui" << component << url).join( QDir::separator() );
1338 if ( !context.isEmpty() )
1340 path += QString( "#%1" ).arg( context );
1346 Sets enable or disable some actions on selection changed.
1348 void LightApp_Application::onSelectionChanged()
1350 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
1351 bool canCopy = m ? m->canCopy() : false;
1352 bool canPaste = m ? m->canPaste() : false;
1354 action( EditCopyId )->setEnabled(canCopy);
1355 action( EditPasteId )->setEnabled(canPaste);
1359 SLOT: Performs some actions when dockable windows are triggered
1361 void LightApp_Application::onDockWindowVisibilityChanged( bool )
1365 QWidget* LightApp_Application::dockWindow( const int id ) const
1368 if ( myWin.contains( id ) )
1373 QDockWidget* LightApp_Application::windowDock( QWidget* wid ) const
1378 QDockWidget* dock = 0;
1379 QWidget* w = wid->parentWidget();
1380 while ( w && !dock )
1382 dock = ::qobject_cast<QDockWidget*>( w );
1383 w = w->parentWidget();
1388 void LightApp_Application::insertDockWindow( const int id, QWidget* wid )
1393 if ( wid != dockWindow( id ) )
1394 removeDockWindow( id );
1396 myWin.insert( id, wid );
1398 QtxDockWidget* dock = new QtxDockWidget( true, desktop() );
1399 if ( id == WT_InfoPanel ) {
1400 // Info panel's position is strongly limited to the right area;
1401 // It is not movable and not floatable.
1402 dock->setAllowedAreas( Qt::RightDockWidgetArea );
1403 dock->setFeatures( QDockWidget::DockWidgetClosable );
1404 connect( dock, SIGNAL( aboutToShow()), this, SLOT( onInfoPanelShown() ) );
1407 dock->setFeatures( QDockWidget::AllDockWidgetFeatures );
1409 connect( dock, SIGNAL( destroyed( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
1411 dock->setObjectName( wid->objectName().isEmpty() ? QString( "window_%1" ).arg( id ) :
1412 QString( "%1Dock" ).arg( wid->objectName() ) );
1413 dock->setWidget( wid );
1414 dock->toggleViewAction()->setData( QVariant( wid->objectName() ) );
1415 connect( dock->toggleViewAction(), SIGNAL( triggered( bool ) ),
1416 this, SLOT( onDockWindowVisibilityChanged( bool ) ) );
1418 QKeySequence accel = wid->property( "shortcut" ).value<QKeySequence>();
1419 if ( !accel.isEmpty() )
1420 dock->toggleViewAction()->setShortcut( accel );
1425 void LightApp_Application::removeDockWindow( const int id )
1427 QWidget* wid = dockWindow( id );
1433 QDockWidget* dock = windowDock( wid );
1437 dock->setWidget( 0 );
1438 wid->setParent( 0 );
1439 wid->setVisible( false );
1443 void LightApp_Application::placeDockWindow( const int id, Qt::DockWidgetArea place )
1445 QDockWidget* dock = windowDock( dockWindow( id ) );
1446 if ( dock && desktop() ) {
1447 desktop()->addDockWidget( place, dock );
1448 QtxDockAction* a = qobject_cast<QtxDockAction*>( action( ViewWindowsId ) );
1449 if ( a ) a->update();
1455 \param flag - key for window
1456 Flag used how identificator of window in windows list.
1458 QWidget* LightApp_Application::getWindow( const int flag)
1460 QWidget* wid = dockWindow( flag );
1462 insertDockWindow( flag, wid = createWindow( flag ) );
1464 QMap<int, int> winMap;
1465 currentWindows( winMap );
1466 if ( winMap.contains( flag ) )
1467 placeDockWindow( flag, (Qt::DockWidgetArea)winMap[flag] );
1473 \return Object Browser
1475 SUIT_DataBrowser* LightApp_Application::objectBrowser()
1477 return qobject_cast<SUIT_DataBrowser*>( dockWindow( WT_ObjectBrowser ) );
1480 QtxInfoPanel* LightApp_Application::infoPanel()
1482 return qobject_cast<QtxInfoPanel *>( dockWindow( WT_InfoPanel ));
1488 LogWindow* LightApp_Application::logWindow()
1490 return qobject_cast<LogWindow*>( dockWindow( WT_LogWindow ) );
1493 #ifndef DISABLE_PYCONSOLE
1495 This returns the python console integrated to the GUI. Depending
1496 when you request the python console, this function could return
1497 null. Then the optional parameter force (default to false) can be
1498 set to force the creation of the python console if it is not done
1500 \param force - if true, the pythonConsole is created if it does not exist yet
1501 \return Python Console
1503 PyConsole_Console* LightApp_Application::pythonConsole(const bool force)
1505 QWidget* wid = dockWindow( WT_PyConsole );
1506 if ( !wid && force==true) {
1507 wid = getWindow(WT_PyConsole);
1509 return qobject_cast<PyConsole_Console*>( wid );
1514 Updates object browser and maybe data models
1515 \param updateModels - if it is true, then data models are updated
1517 void LightApp_Application::updateObjectBrowser( const bool updateModels )
1519 // update existing data models
1522 const bool isAutoUpdate = objectBrowser() ? objectBrowser()->autoUpdate() : true;
1523 if ( objectBrowser() )
1524 objectBrowser()->setAutoUpdate( false );
1526 LightApp_Study* study = dynamic_cast<LightApp_Study*>(activeStudy());
1528 CAM_Study::ModelList dm_list;
1529 study->dataModels( dm_list );
1530 QListIterator<CAM_DataModel*> it( dm_list );
1531 while ( it.hasNext() ) {
1532 CAM_DataModel* camDM = it.next();
1533 if ( camDM && camDM->inherits( "LightApp_DataModel" ) )
1534 ((LightApp_DataModel*)camDM)->update();
1538 if( objectBrowser() )
1539 objectBrowser()->setAutoUpdate( isAutoUpdate );
1542 if ( objectBrowser() ) {
1543 objectBrowser()->updateGeometry();
1544 objectBrowser()->updateTree( 0, false );
1551 LightApp_Preferences* LightApp_Application::preferences() const
1553 return preferences( false );
1557 \return first view manager of some type
1558 \param vmType - type of view manager
1559 \param create - is it necessary to create view manager in case, when there is no manager of such type
1561 SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, const bool create )
1563 SUIT_ViewManager* aVM = viewManager( vmType );
1564 SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
1565 MESSAGE("vmType: " << vmType.toStdString() << " aVM: " << aVM << " anActiveVM: " << anActiveVM );
1566 if ( anActiveVM && anActiveVM->getType() == vmType )
1568 MESSAGE("aVM = anActiveVM");
1572 bool keepDetached = property("keep_detached").toBool();
1573 if ( aVM && (!aVM->getDetached() || keepDetached) && create )
1575 if ( !aVM->getActiveView() )
1577 MESSAGE("aVM->createView()");
1582 MESSAGE("desktop()->setActiveWindow: " << aVM->getActiveView());
1583 desktop()->setActiveWindow( aVM->getActiveView() );
1588 MESSAGE("aVM = createViewManager( vmType )");
1589 aVM = createViewManager( vmType );
1596 Creates view manager of some type
1597 \param vmType - type of view manager
1599 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, bool detached )
1601 SUIT_ResourceMgr* resMgr = resourceMgr();
1603 SUIT_ViewManager* viewMgr = 0;
1604 #ifndef DISABLE_GLVIEWER
1605 if( vmType == GLViewer_Viewer::Type() )
1607 viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() );
1608 new LightApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
1611 #ifndef DISABLE_PLOT2DVIEWER
1612 if( vmType == Plot2d_Viewer::Type() )
1614 viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
1616 #ifndef DISABLE_SALOMEOBJECT
1617 SPlot2d_Viewer* v = new SPlot2d_Viewer();
1619 new LightApp_Plot2dSelector( v, mySelMgr );
1621 vm = new Plot2d_Viewer();
1623 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1624 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
1627 Plot2d_ViewFrame* frame = wnd->getViewFrame();
1628 frame->setBackgroundColor( resMgr->colorValue( "Plot2d", "Background", frame->backgroundColor() ) );
1632 #ifndef DISABLE_QXGRAPHVIEWER
1633 if( vmType == QxScene_Viewer::Type() )
1635 viewMgr = new QxScene_ViewManager( activeStudy(), desktop() );
1636 QxScene_Viewer* vm = new QxScene_Viewer();
1637 viewMgr->setViewModel( vm );
1638 //QxScene_ViewWindow* wnd = dynamic_cast<QxScene_ViewWindow*>( viewMgr->getActiveView() );
1641 #ifndef DISABLE_GRAPHICSVIEW
1642 if( vmType == GraphicsView_Viewer::Type() )
1644 viewMgr = new GraphicsView_ViewManager( activeStudy(), desktop() );
1645 new LightApp_GVSelector( (GraphicsView_Viewer*)viewMgr->getViewModel(), mySelMgr );
1648 #ifndef DISABLE_PVVIEWER
1649 if( vmType == PVViewer_Viewer::Type() )
1651 if (( viewMgr = dynamic_cast<PVViewer_ViewManager*>( getViewManager( vmType, false )))) {
1652 viewMgr->getActiveView()->setFocus();
1655 viewMgr = new PVViewer_ViewManager( activeStudy(), desktop() );
1659 #ifndef DISABLE_PYVIEWER
1660 if( vmType == PyViewer_Viewer::Type() )
1662 viewMgr = new PyViewer_ViewManager( activeStudy(), desktop() );
1665 #ifndef DISABLE_OCCVIEWER
1666 if( vmType == OCCViewer_Viewer::Type() )
1668 viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
1669 OCCViewer_Viewer* vm;
1670 #ifndef DISABLE_SALOMEOBJECT
1671 vm = new SOCC_Viewer();
1673 vm = new OCCViewer_Viewer( true );
1675 vm->setBackground( OCCViewer_ViewFrame::TOP_LEFT,
1676 resMgr->backgroundValue( "OCCViewer", "xz_background", vm->background(OCCViewer_ViewFrame::TOP_LEFT) ) );
1677 vm->setBackground( OCCViewer_ViewFrame::TOP_RIGHT,
1678 resMgr->backgroundValue( "OCCViewer", "yz_background", vm->background(OCCViewer_ViewFrame::TOP_RIGHT) ) );
1679 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_LEFT,
1680 resMgr->backgroundValue( "OCCViewer", "xy_background", vm->background(OCCViewer_ViewFrame::BOTTOM_LEFT) ) );
1681 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_RIGHT,
1682 resMgr->backgroundValue( "OCCViewer", "background", vm->background(OCCViewer_ViewFrame::MAIN_VIEW) ) );
1684 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1685 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ));
1686 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1687 vm->setProjectionType( resMgr->integerValue( "OCCViewer", "projection_mode", vm->projectionType() ) );
1688 vm->setStereoType( resMgr->integerValue( "OCCViewer", "stereo_type", vm->stereoType() ) );
1689 vm->setAnaglyphFilter( resMgr->integerValue( "OCCViewer", "anaglyph_filter", vm->anaglyphFilter() ) );
1690 vm->setStereographicFocus( resMgr->integerValue( "OCCViewer", "focus_type", vm->stereographicFocusType() ),
1691 resMgr->doubleValue( "OCCViewer", "focus_value", vm->stereographicFocusValue() ));
1692 vm->setInterocularDistance( resMgr->integerValue( "OCCViewer", "iod_type", vm->interocularDistanceType() ),
1693 resMgr->doubleValue( "OCCViewer", "iod_value", vm->interocularDistanceValue() ));
1694 vm->setSelectionStyle((OCCViewer_ViewWindow::SelectionStyle) resMgr->integerValue( "OCCViewer", "adv_selection_mode", vm->selectionStyle() ) );
1696 vm->setReverseStereo( resMgr->booleanValue( "OCCViewer", "reverse_stereo", vm->isReverseStereo() ) );
1697 vm->setVSync( resMgr->booleanValue( "OCCViewer", "enable_vsync", vm->isVSync() ) );
1698 vm->setQuadBufferSupport( resMgr->booleanValue( "OCCViewer", "enable_quad_buffer_support", vm->isQuadBufferSupport() ) );
1699 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1700 vm->enablePreselection( resMgr->booleanValue( "OCCViewer", "enable_preselection", vm->isPreselectionEnabled() ) );
1701 vm->enableSelection( resMgr->booleanValue( "OCCViewer", "enable_selection", vm->isSelectionEnabled() ) );
1702 vm->setClippingColor( resMgr->colorValue( "OCCViewer", "clipping_color", vm->clippingColor() ) );
1703 vm->setClippingTextureParams( resMgr->booleanValue( "OCCViewer", "clipping_use_default_texture", vm->isDefaultTextureUsed() ),
1704 resMgr->stringValue( "OCCViewer", "clipping_texture", vm->clippingTexture() ),
1705 resMgr->booleanValue( "OCCViewer", "clipping_modulate", vm->isTextureModulated() ),
1706 resMgr->doubleValue( "OCCViewer", "clipping_scale", vm->clippingTextureScale() ) );
1709 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1710 new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
1713 #ifndef DISABLE_VTKVIEWER
1714 #ifndef DISABLE_SALOMEOBJECT
1715 if ( vmType == SVTK_Viewer::Type() )
1717 if ( vmType == VTKViewer_Viewer::Type() )
1720 #ifndef DISABLE_SALOMEOBJECT
1721 viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
1722 SVTK_Viewer* vm = dynamic_cast<SVTK_Viewer*>( viewMgr->getViewModel() );
1725 vm->setProjectionMode( resMgr->integerValue( "VTKViewer", "projection_mode", vm->projectionMode() ) );
1726 vm->setStereoType( resMgr->integerValue( "VTKViewer", "stereo_type", vm->stereoType() ) );
1727 vm->setAnaglyphFilter( resMgr->integerValue( "VTKViewer", "anaglyph_filter", vm->anaglyphFilter() ) );
1728 vm->setQuadBufferSupport( resMgr->booleanValue( "VTKViewer", "enable_quad_buffer_support", vm->isQuadBufferSupport() ) );
1729 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1730 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1731 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ) );
1732 vm->setStaticTrihedronVisible( resMgr->booleanValue( "3DViewer", "show_static_trihedron", vm->isStaticTrihedronVisible() ) );
1733 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1734 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1735 vm->setPreSelectionMode(resMgr->integerValue( "VTKViewer", "preselection", vm->preSelectionMode() ) );
1736 vm->enableSelection( resMgr->booleanValue( "VTKViewer", "enable_selection", vm->isSelectionEnabled() ) );
1737 vm->setIncrementalSpeed( resMgr->integerValue( "VTKViewer", "speed_value", vm->incrementalSpeed() ),
1738 resMgr->integerValue( "VTKViewer", "speed_mode", vm->incrementalSpeedMode() ) );
1739 vm->setSpacemouseButtons( resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", vm->spacemouseBtn(1) ),
1740 resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", vm->spacemouseBtn(2) ),
1741 resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", vm->spacemouseBtn(3) ) );
1742 new LightApp_VTKSelector( vm, mySelMgr );
1745 viewMgr = new VTKViewer_ViewManager( activeStudy(), desktop() );
1746 VTKViewer_Viewer* vm = dynamic_cast<VTKViewer_Viewer*>( viewMgr->getViewModel() );
1748 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1756 viewMgr->setDetached(detached);
1757 addViewManager( viewMgr );
1758 SUIT_ViewWindow* viewWin = viewMgr->createViewWindow();
1760 if ( viewWin && desktop() ) {
1761 viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1762 viewWin->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1768 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, QWidget* w )
1770 SUIT_ResourceMgr* resMgr = resourceMgr();
1772 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
1774 new LightApp_WgViewModel( vmType, w ) );
1775 vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
1777 addViewManager( vm );
1778 SUIT_ViewWindow* vw = vm->createViewWindow();
1779 if ( vw && desktop() ) {
1780 vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1781 vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1784 if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
1785 myUserWmTypes << vmType;
1790 SUIT_ViewManager* LightApp_Application::createViewManager( SUIT_ViewModel* theModel )
1792 SUIT_ResourceMgr* resMgr = resourceMgr();
1794 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
1798 QString vmType = vm->getType();
1800 vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
1802 addViewManager( vm );
1803 SUIT_ViewWindow* vw = vm->createViewWindow();
1804 if ( vw && desktop() ) {
1805 vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1806 vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1809 if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
1810 myUserWmTypes << vmType;
1816 SLOT: Removes view manager from application
1818 void LightApp_Application::onCloseView( SUIT_ViewManager* theVM )
1820 removeViewManager( theVM );
1824 Protected SLOT: On study created.
1825 \param theStudy - just created study
1827 void LightApp_Application::onStudyCreated( SUIT_Study* theStudy )
1829 SUIT_DataObject* aRoot = 0;
1830 if ( theStudy && theStudy->root() )
1832 aRoot = theStudy->root();
1833 //aRoot->setName( tr( "DATA_MODELS" ) );
1836 getWindow( WT_ObjectBrowser );
1837 getWindow( WT_InfoPanel );
1839 loadDockWindowsState();
1841 if ( objectBrowser() )
1842 objectBrowser()->setRoot( aRoot );
1844 activateModule( defaultModule() );
1846 if ( objectBrowser() )
1847 objectBrowser()->openLevels();
1849 #ifndef DISABLE_PYCONSOLE
1850 if( pythonConsole() )
1851 getPyInterp()->initStudy();
1856 Protected SLOT: On study opened.
1857 \param theStudy - just opened study
1859 void LightApp_Application::onStudyOpened( SUIT_Study* theStudy )
1861 SUIT_DataObject* aRoot = 0;
1862 if ( theStudy && theStudy->root() )
1864 aRoot = theStudy->root();
1868 getWindow( WT_ObjectBrowser );
1869 getWindow( WT_InfoPanel );
1871 loadDockWindowsState();
1873 if ( objectBrowser() )
1874 objectBrowser()->setRoot( aRoot );
1876 activateModule( defaultModule() );
1878 if ( objectBrowser() )
1879 objectBrowser()->openLevels();
1881 #ifndef DISABLE_PYCONSOLE
1882 if( pythonConsole() )
1883 getPyInterp()->initStudy();
1889 /*!Protected SLOT. On study saved.*/
1890 void LightApp_Application::onStudySaved( SUIT_Study* s )
1892 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
1894 mru->insert( s->studyName() );
1899 /*!Protected SLOT. On study closed.*/
1900 void LightApp_Application::onStudyClosed( SUIT_Study* /*s*/ )
1903 disconnect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
1904 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
1907 // stop auto-save timer
1908 myAutoSaveTimer->stop();
1910 // Bug 10396: clear selection
1911 mySelMgr->clearSelected();
1913 // Bug 12944: emit signal only after clear selection
1916 activateModule( "" );
1919 /*!Protected SLOT.On desktop activated.*/
1920 void LightApp_Application::onDesktopActivated()
1922 CAM_Application::onDesktopActivated();
1923 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>(activeModule());
1925 aModule->studyActivated();
1928 void LightApp_Application::studyOpened( SUIT_Study* s )
1930 CAM_Application::studyOpened( s );
1933 updateViewManagers();
1936 void LightApp_Application::studySaved( SUIT_Study* s )
1938 CAM_Application::studyOpened( s );
1939 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1940 if ( aResMgr && activeStudy() ) {
1941 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
1942 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
1946 void LightApp_Application::studyCreated( SUIT_Study* s )
1948 CAM_Application::studyCreated( s );
1951 updateViewManagers();
1954 /*!Gets file filter.
1955 *\retval QString "(*.hdf)"
1957 QString LightApp_Application::getFileFilter( bool /*open*/) const
1963 Shows file dialog and return user selected file name
1965 QString LightApp_Application::getFileName( bool open, const QString& initial, const QString& filters,
1966 const QString& caption, QWidget* parent )
1970 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1971 return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
1974 /*! Gets directory*/
1975 QString LightApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
1979 return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true );
1982 /*! Get open file names*/
1983 QStringList LightApp_Application::getOpenFileNames( const QString& initial, const QString& filters,
1984 const QString& caption, QWidget* parent )
1988 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1989 return SUIT_FileDlg::getOpenFileNames( parent, initial, fls, caption, true );
1992 /*!Private SLOT. Update object browser.*/
1993 void LightApp_Application::onRefresh()
1995 updateObjectBrowser( true );
1998 /*!Private SLOT. Update actions after rename object.*/
1999 void LightApp_Application::onRenamed()
2001 activeStudy()->Modified();
2005 // IMN 08.07.2015 : issue 002556: Some stereo outputs are affected by window position.
2006 // To prevent reversion the window should be either aligned during movement and resize.
2007 /*!Private SLOT. Update actions after rename object.*/
2008 /*void LightApp_Application::onMoved()
2010 OCCViewer_ViewManager* viewMgr = 0;
2011 viewMgr = dynamic_cast<OCCViewer_ViewManager*>( getViewManager( OCCViewer_Viewer::Type(), false ) );
2013 OCCViewer_ViewWindow* view = 0;
2014 view = dynamic_cast<OCCViewer_ViewWindow*>( viewMgr->getActiveView() );
2016 view->getViewPort()->repaintViewAfterMove();
2021 /*!Private SLOT. Support drag-and-drop operation.*/
2022 void LightApp_Application::onDropped( const QList<SUIT_DataObject*>& objects, SUIT_DataObject* parent, int row, Qt::DropAction action )
2024 LightApp_DataObject* parentObj = dynamic_cast<LightApp_DataObject*>( parent );
2028 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>( parentObj->module() );
2030 aModule->dropObjects( objects, parentObj, row, action );
2033 /*!Private SLOT. On preferences.*/
2034 void LightApp_Application::onPreferences()
2036 showPreferences( activeModule() ? activeModule()->moduleName() : tr( "PREF_CATEGORY_SALOME" ) );
2039 /*!Private SLOT. On preferences.*/
2040 void LightApp_Application::showPreferences( const QString& path )
2042 showPreferences( QStringList() << path );
2045 void LightApp_Application::showPreferences( const QStringList& path )
2047 QApplication::setOverrideCursor( Qt::WaitCursor );
2049 LightApp_PreferencesDlg* prefDlg = new LightApp_PreferencesDlg( preferences( true ), desktop());
2051 QApplication::restoreOverrideCursor();
2056 preferences()->activateItem( path );
2058 if ( ( prefDlg->exec() == QDialog::Accepted || prefDlg->isSaved() ) && resourceMgr() )
2061 resourceMgr()->setValue( "desktop", "geometry", desktop()->storeGeometry() );
2062 resourceMgr()->save();
2065 shortcutMgr()->updateShortcuts();
2071 /*!Protected SLOT. On preferences changed.*/
2072 void LightApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param )
2074 LightApp_Module* sMod = 0;
2075 CAM_Module* mod = module( modName );
2076 if ( mod && mod->inherits( "LightApp_Module" ) )
2077 sMod = (LightApp_Module*)mod;
2080 sMod->preferencesChanged( section, param );
2082 preferencesChanged( section, param );
2083 // emit signal to allow additional preferences changing processing
2084 emit preferenceChanged( modName, section, param );
2087 /*!Remove all windows from study.*/
2088 void LightApp_Application::beforeCloseDoc( SUIT_Study* s )
2090 saveDockWindowsState();
2092 if ( SUIT_DataBrowser* ob = objectBrowser() )
2095 CAM_Application::beforeCloseDoc( s );
2098 /*!Update actions.*/
2099 void LightApp_Application::updateActions()
2101 updateCommandsStatus();
2107 SUIT_Study* LightApp_Application::createNewStudy()
2109 LightApp_Study* aStudy = new LightApp_Study( this );
2111 // Set up processing of major study-related events
2112 connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
2113 connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
2114 connect( aStudy, SIGNAL( saved ( SUIT_Study* ) ), this, SLOT( onStudySaved ( SUIT_Study* ) ) );
2115 connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
2121 Creates window by flag.
2122 \param flag - identificator of window type
2124 QWidget* LightApp_Application::createWindow( const int flag )
2128 SUIT_ResourceMgr* resMgr = resourceMgr();
2130 if ( flag == WT_ObjectBrowser )
2132 SUIT_DataBrowser* ob = new SUIT_DataBrowser( new LightApp_DataObject(), desktop() );
2133 ob->setObjectName( "objectBrowser" );
2134 ob->setSortMenuEnabled( true );
2135 ob->setAutoUpdate( true );
2136 if ( resMgr->hasValue( "ObjectBrowser", "auto_hide_search_tool" ) )
2137 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
2139 //ob->setAutoOpenLevel( 1 ); // commented by ASV as a fix to bug IPAL10107
2140 ob->setWindowTitle( tr( "OBJECT_BROWSER" ) );
2141 connect( ob, SIGNAL( requestUpdate() ), this, SLOT( onRefresh() ) );
2143 QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
2144 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
2145 treeModel->setSearcher( this );
2146 treeModel->registerColumn( 0, EntryCol, LightApp_DataObject::EntryId );
2147 treeModel->setAppropriate( EntryCol, Qtx::Toggled );
2149 // Mantis issue 0020136: Drag&Drop in OB
2150 SUIT_ProxyModel* proxyModel = dynamic_cast<SUIT_ProxyModel*>(treeModel);
2152 connect( proxyModel, SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
2153 this, SLOT( onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
2154 connect( proxyModel, SIGNAL( renamed( SUIT_DataObject* ) ),
2155 this, SLOT( onRenamed( ) ) );
2159 // temporary commented
2161 OB_ListView* ob_list = dynamic_cast<OB_ListView*>( const_cast<QListView*>( ob->listView() ) );
2163 ob_list->setColumnMaxWidth( 0, desktop()->width()/4 );
2166 // Create OBSelector
2167 new LightApp_OBSelector( ob, mySelMgr );
2168 ob->treeView()->header()->setSectionResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
2169 ob->treeView()->header()->moveSection(SUIT_DataObject::NameId,SUIT_DataObject::VisibilityId);
2170 ob->treeView()->setColumnWidth(SUIT_DataObject::VisibilityId, VISIBILITY_COLUMN_WIDTH);
2171 ob->setProperty( "shortcut", QKeySequence( "Alt+Shift+O" ) );
2173 ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
2175 else if ( flag == WT_InfoPanel)
2177 QtxInfoPanel* ipanel = new QtxInfoPanel( desktop() );
2178 ipanel->setObjectName( "infoPanel" );
2179 ipanel->setWindowTitle( tr( "INFO_PANEL" ) );
2182 #ifndef DISABLE_PYCONSOLE
2183 else if ( flag == WT_PyConsole )
2185 PyConsole_Console* pyCons = new PyConsole_Console( desktop(), new LightApp_PyEditor( getPyInterp() ) );
2186 pyCons->setObjectName( "pythonConsole" );
2187 pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
2188 pyCons->setFont( resMgr->fontValue( "PyConsole", "font" ) );
2189 pyCons->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
2190 pyCons->setAutoCompletion( resMgr->booleanValue( "PyConsole", "auto_completion", true ) );
2191 pyCons->setProperty( "shortcut", QKeySequence( "Alt+Shift+P" ) );
2195 else if ( flag == WT_LogWindow )
2197 LogWindow* logWin = new LogWindow( desktop() );
2198 logWin->handleQtMessages( true );
2199 logWin->setObjectName( "logWindow" );
2200 logWin->setWindowTitle( tr( "LOG_WINDOW" ) );
2201 logWin->setProperty( "shortcut", QKeySequence( "Alt+Shift+L" ) );
2203 logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
2209 \return default windows( Object Browser, Python Console )
2210 Adds to map \a aMap.
2212 void LightApp_Application::defaultWindows( QMap<int, int>& aMap ) const
2214 #ifndef DISABLE_PYCONSOLE
2215 aMap.insert( WT_PyConsole, Qt::BottomDockWidgetArea );
2217 if ( activeStudy() ) {
2218 aMap.insert( WT_ObjectBrowser, Qt::LeftDockWidgetArea );
2219 aMap.insert( WT_InfoPanel, Qt::RightDockWidgetArea );
2220 // aMap.insert( WT_LogWindow, Qt::DockBottom );
2224 /*!Default view managers*/
2225 void LightApp_Application::defaultViewManagers( QStringList& ) const
2231 \return preferences.
2232 Create preferences, if \a crt = true.
2234 LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const
2239 LightApp_Application* that = (LightApp_Application*)this;
2241 bool toCreate = !_prefs_ && crt;
2244 _prefs_ = new LightApp_Preferences( resourceMgr() );
2245 that->createPreferences( _prefs_ );
2246 qAddPostRoutine( LightAppCleanUpAppResources );
2249 that->myPrefs = _prefs_;
2251 connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
2252 this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ), Qt::UniqueConnection );
2253 connect( myPrefs, SIGNAL( resetToDefaults() ),
2254 this, SIGNAL( preferenceResetToDefaults() ), Qt::UniqueConnection );
2259 SUIT_ResourceMgr* resMgr = resourceMgr();
2261 QList<SUIT_Application*> appList = SUIT_Session::session()->applications();
2262 for ( QList<SUIT_Application*>::iterator appIt = appList.begin(); appIt != appList.end(); ++appIt )
2264 LightApp_Application* app = ::qobject_cast<LightApp_Application*>( *appIt );
2268 // all modules available in current session
2270 app->modules( names, false );
2273 QMap<QString, QString> icons;
2274 app->moduleIconNames( icons );
2276 // step 1: iterate through list of all available modules
2277 // and add empty preferences page
2278 for ( QStringList::const_iterator it = names.begin(); it != names.end(); ++it )
2280 if ( !_prefs_->hasModule( *it ) ) // prevent possible duplications
2282 int modId = _prefs_->addPreference( *it ); // add empty page
2283 if ( icons.contains( *it ) ) // set icon
2284 _prefs_->setItemIcon( modId, Qtx::scaleIcon( resMgr->loadPixmap( moduleName( *it ),
2285 icons[*it], false ), 20 ) );
2289 // step 2: iterate through list of all loaded modules
2290 // and initialize their preferences
2291 ModuleList loadedModules;
2292 app->modules( loadedModules );
2293 QListIterator<CAM_Module*> itr( loadedModules );
2294 while ( itr.hasNext() )
2296 LightApp_Module* module = 0;
2297 CAM_Module* m = itr.next();
2298 if ( m->inherits( "LightApp_Module" ) )
2299 module = (LightApp_Module*)m;
2301 if ( module && !_prefs_->hasModule( module->moduleName() ) )
2303 _prefs_->addPreference( module->moduleName() ); // add page (for sure, had to be done at step 1)
2304 module->createPreferences(); // initialize preferences
2305 that->emptyPreferences( module->moduleName() ); // show dummy page if module does not export any preferences
2309 _prefs_->setItemProperty( "info", tr( "PREFERENCES_NOT_LOADED" ) ); // dummy page for modules which are not loaded yet
2315 Adds new module to application
2317 void LightApp_Application::moduleAdded( CAM_Module* mod )
2319 CAM_Application::moduleAdded( mod );
2321 LightApp_Module* lightMod = 0;
2322 if ( mod && mod->inherits( "LightApp_Module" ) )
2323 lightMod = (LightApp_Module*)mod;
2325 if ( myPrefs && lightMod && !myPrefs->hasModule( lightMod->moduleName() ))
2327 myPrefs->addPreference( mod->moduleName() );
2328 lightMod->createPreferences();
2329 emptyPreferences( mod->moduleName() );
2333 void LightApp_Application::moduleDeactivated( CAM_Module* /*mod*/ )
2336 infoPanel()->clear();
2339 void LightApp_Application::emptyPreferences( const QString& modName )
2341 QtxPreferenceItem* item = myPrefs->findItem( modName, true );
2342 if ( !item || !item->isEmpty() )
2345 QtxPagePrefFrameItem* frm = new QtxPagePrefFrameItem( item->title(), item->parentItem() );
2346 frm->setIcon( item->icon() );
2347 frm->setStretch( false );
2348 item->parentItem()->insertItem( frm, item );
2349 new QtxPagePrefLabelItem( Qt::AlignCenter, tr( "PREFERENCES_NOT_SUPPORTED" ).arg( modName ), frm );
2356 void LightApp_Application::createPreferences( LightApp_Preferences* pref )
2361 QStringList aValuesList;
2362 QList<QVariant> anIndicesList;
2366 // . Top-level "SALOME" preferences group <<start>>
2367 int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
2368 pref->setItemIcon( salomeCat, Qtx::scaleIcon( resourceMgr()->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false ), 20 ) );
2370 // .. "General" preferences tab <<start>>
2371 int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat );
2373 // ... "Language" group <<start>>
2374 int langGroup = pref->addPreference( tr( "PREF_GROUP_LANGUAGE" ), genTab );
2375 pref->setItemProperty( "columns", 2, langGroup );
2376 // .... -> application language
2377 int curLang = pref->addPreference( tr( "PREF_CURRENT_LANGUAGE" ), langGroup,
2378 LightApp_Preferences::Selector, "language", "language" );
2379 QStringList aLangs = SUIT_Session::session()->resourceMgr()->stringValue( "language", "languages", "en" ).split( "," );
2380 QList<QVariant> aIcons;
2381 QList<QVariant> aNumbers;
2382 QStringList aTitles;
2383 foreach ( QString aLang, aLangs ) {
2384 aIcons << QPixmap( QString( ":/images/%1" ).arg( aLang ) );
2386 aTitles << langToName( aLang );
2388 pref->setItemProperty( "strings", aTitles, curLang );
2389 pref->setItemProperty( "ids", aNumbers, curLang );
2390 pref->setItemProperty( "icons", aIcons, curLang );
2391 pref->setItemProperty( "restart", true, curLang );
2393 int curLocale = pref->addPreference( tr( "PREF_CURRENT_LOCALE" ), langGroup,
2394 LightApp_Preferences::Bool, "language", "locale" );
2395 pref->setItemProperty( "restart", true, curLocale );
2396 // ... "Language" group <<end>>
2398 // ... "Look and feel" group <<start>>
2399 int lookGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), genTab );
2400 pref->setItemProperty( "columns", 2, lookGroup );
2401 // .... -> show splash-screen
2402 pref->addPreference( tr( "PREF_SHOW_SPLASH" ), lookGroup, LightApp_Preferences::Bool, "launch", "splash" );
2403 // .... -> opaque resize
2404 pref->addPreference( tr( "PREF_OPAQUE_RESIZE" ), lookGroup, LightApp_Preferences::Bool, "desktop", "opaque_resize" );
2405 // .... -> drop-down buttons
2406 pref->addPreference( tr( "PREF_DROP_DOWN_BUTTONS" ), lookGroup, LightApp_Preferences::Bool, "viewers", "drop_down_buttons" );
2407 // .... -> Notification timeout
2408 int delay = pref->addPreference( tr( "PREF_NOTIFY_TIMEOUT" ), lookGroup, LightApp_Preferences::IntSpin, "notification", "timeout" );
2409 pref->setItemProperty( "special", tr("PREF_NOTIFY_TIMEOUT_NONE"), delay );
2410 pref->setItemProperty( "min", 0, delay );
2411 pref->setItemProperty( "max", 100, delay );
2412 pref->setItemProperty( "suffix", " sec", delay );
2413 // ... "Look and feel" group <<end>>
2415 // ... "Study properties" group <<start>>
2416 int studyGroup = pref->addPreference( tr( "PREF_GROUP_STUDY" ), genTab );
2417 pref->setItemProperty( "columns", 2, studyGroup );
2418 // .... -> multi-file save
2419 pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "multi_file" );
2420 // .... -> ascii save mode
2421 pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" );
2422 // .... -> store windows geometry
2423 pref->addPreference( tr( "PREF_LOAD_LIGHT" ), studyGroup, LightApp_Preferences::Bool, "Study", "autoload_light_modules" );
2424 pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" );
2425 pref->addPreference( "", studyGroup, LightApp_Preferences::Space );
2426 pref->addPreference( tr( "PREF_STORE_TOOL_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_tool_positions" );
2427 // .... -> auto-save
2428 int autoSaveInterval = pref->addPreference( tr( "PREF_AUTO_SAVE" ), studyGroup,
2429 LightApp_Preferences::IntSpin, "Study", "auto_save_interval" );
2430 pref->setItemProperty( "min", 0, autoSaveInterval );
2431 pref->setItemProperty( "max", 1440, autoSaveInterval );
2432 pref->setItemProperty( "special", tr( "PREF_AUTO_SAVE_DISABLED" ), autoSaveInterval );
2433 // ... "Study properties" group <<end>>
2435 // ... "Help browser" group <<start>>
2436 #ifndef DISABLE_QTXWEBBROWSER
2437 int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab, LightApp_Preferences::Auto, "ExternalBrowser", "use_external_browser");
2439 int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab );
2443 QString platform = "winapplication";
2445 QString platform = "application";
2447 // .... -> browser application
2448 int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, LightApp_Preferences::File, "ExternalBrowser", platform );
2449 pref->setItemProperty( "mode", Qtx::PT_OpenFile, apppref );
2450 // .... -> browser parameters
2451 pref->addPreference( tr( "PREF_PARAM" ), extgroup, LightApp_Preferences::String, "ExternalBrowser", "parameters" );
2452 // ... "Help browser" group <<end>>
2454 // ... "Python console properties" group <<start>>
2455 int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab );
2456 pref->setItemProperty( "columns", 2, pythonConsoleGroup );
2458 pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, LightApp_Preferences::Font, "PyConsole", "font" );
2459 // .... -> show banner
2460 pref->addPreference( tr( "PREF_SHOW_BANNER" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "show_banner" );
2461 // .... -> auto-completion
2462 pref->addPreference( tr( "PREF_AUTO_COMPLETION" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "auto_completion" );
2463 // ... "Python console properties" group <<end>>
2465 // ... "MRU" preferences group <<start>>
2466 int mruGroup = pref->addPreference( tr( "PREF_GROUP_MRU" ), genTab, LightApp_Preferences::Auto, "MRU", "show_mru" );
2467 pref->setItemProperty( "columns", 4, mruGroup );
2468 // number of MRU items
2469 int mruVisCount = pref->addPreference( tr( "PREF_MRU_VISIBLE_COUNT" ), mruGroup, LightApp_Preferences::IntSpin,
2470 "MRU", "visible_count" );
2471 pref->setItemProperty( "min", 0, mruVisCount );
2472 pref->setItemProperty( "max", 100, mruVisCount );
2474 int mruLinkType = pref->addPreference( tr( "PREF_MRU_LINK_TYPE" ), mruGroup, LightApp_Preferences::Selector,
2475 "MRU", "link_type" );
2476 aValuesList.clear();
2477 anIndicesList.clear();
2478 aValuesList << tr("PREF_MRU_LINK_AUTO") << tr("PREF_MRU_LINK_SHORT") << tr("PREF_MRU_LINK_FULL");
2479 anIndicesList << 0 << 1 << 2 ;
2480 pref->setItemProperty( "strings", aValuesList, mruLinkType );
2481 pref->setItemProperty( "indexes", anIndicesList, mruLinkType );
2482 // ... "MRU" preferences group <<end>>
2484 // ... "Full-screen" group <<start>>
2485 int fullScreenGroup = pref->addPreference( tr( "PREF_GROUP_FULL_SCREEN" ), genTab );
2486 pref->setItemProperty( "columns", 2, fullScreenGroup );
2487 // .... -> automatic hiding toolbars
2488 pref->addPreference( tr( "PREF_FULL_SCREEN_AUTO" ), fullScreenGroup,
2489 LightApp_Preferences::Bool, "OCCViewer", "automatic_hiding" );
2490 // ... "Full-screen" group <<end>>
2492 // .. "General" preferences tab <<end>>
2494 // .. "3D viewer" group <<start>>
2495 int Viewer3DGroup = pref->addPreference( tr( "PREF_GROUP_3DVIEWER" ), salomeCat );
2496 // ... -> navigation mode
2497 int vtkStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), Viewer3DGroup,
2498 LightApp_Preferences::Selector, "3DViewer", "navigation_mode" );
2499 aValuesList.clear();
2500 anIndicesList.clear();
2501 aValuesList << tr("PREF_STANDARD_STYLE") << tr("PREF_KEYFREE_STYLE");
2502 anIndicesList << 0 << 1;
2503 pref->setItemProperty( "strings", aValuesList, vtkStyleMode );
2504 pref->setItemProperty( "indexes", anIndicesList, vtkStyleMode );
2505 // ... -> zooming mode
2506 int occZoomingStyleMode = pref->addPreference( tr( "PREF_ZOOMING" ), Viewer3DGroup,
2507 LightApp_Preferences::Selector, "3DViewer", "zooming_mode" );
2508 aValuesList.clear();
2509 anIndicesList.clear();
2510 aValuesList << tr("PREF_ZOOMING_AT_CENTER") << tr("PREF_ZOOMING_AT_CURSOR");
2511 anIndicesList << 0 << 1;
2512 pref->setItemProperty( "strings", aValuesList, occZoomingStyleMode );
2513 pref->setItemProperty( "indexes", anIndicesList, occZoomingStyleMode );
2514 // ... "Trihedron" group <<start>>
2515 int occTriGroup = pref->addPreference( tr( "PREF_TRIHEDRON" ), Viewer3DGroup );
2516 pref->setItemProperty( "columns", 2, occTriGroup );
2517 // .... -> trihedron size
2518 int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occTriGroup,
2519 LightApp_Preferences::DblSpin, "3DViewer", "trihedron_size" );
2520 pref->setItemProperty( "min", 1.0E-06, occTS );
2521 pref->setItemProperty( "max", 1000, occTS );
2522 // .... -> relative size of trihedron
2523 pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "relative_size" );
2524 // .... -> show static trihedron
2525 pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "show_static_trihedron" );
2526 // ... "Trihedron" group <<end>>
2527 // .. "3D viewer" group <<end>>
2531 #ifndef DISABLE_OCCVIEWER
2532 // .. "OCC viewer" group <<start>>
2533 int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), salomeCat );
2535 // .... -> Projection mode
2536 int occProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), occGroup,
2537 LightApp_Preferences::Selector, "OCCViewer", "projection_mode" );
2538 aValuesList.clear();
2539 anIndicesList.clear();
2540 aValuesList << tr("PREF_ORTHOGRAPHIC") << tr("PREF_PERSPECTIVE");
2541 anIndicesList << 0 << 1;
2542 pref->setItemProperty( "strings", aValuesList, occProjMode );
2543 pref->setItemProperty( "indexes", anIndicesList, occProjMode );
2545 // .... -> Stereo group
2546 int stereoGroup = pref->addPreference( tr( "PREF_GROUP_STEREO" ), occGroup);
2547 pref->setItemProperty( "columns", 2, stereoGroup );
2548 // .... -> Stereo type
2549 int stereoType = pref->addPreference( tr( "PREF_STEREO_TYPE" ), stereoGroup,
2550 LightApp_Preferences::Selector, "OCCViewer", "stereo_type" );
2551 aValuesList.clear();
2552 anIndicesList.clear();
2554 OCCViewer_Viewer::stereoData( aValuesList, idList);
2555 foreach( int gid, idList ) anIndicesList << gid;
2556 pref->setItemProperty( "strings", aValuesList, stereoType );
2557 pref->setItemProperty( "indexes", anIndicesList, stereoType );
2559 // .... -> Anaglyph filter
2560 int anaglyphFilter = pref->addPreference( tr( "PREF_ANAGLYPH_FILTER" ), stereoGroup,
2561 LightApp_Preferences::Selector, "OCCViewer", "anaglyph_filter" );
2562 aValuesList.clear();
2563 anIndicesList.clear();
2564 aValuesList << tr("PREF_ANAGLYPH_RED_CYAN") << tr("PREF_ANAGLYPH_YELLOW_BLUE") << tr("PREF_ANAGLYPH_GREEN_MAGENTA");
2565 anIndicesList << 0 << 1 << 2;
2567 pref->setItemProperty( "strings", aValuesList, anaglyphFilter );
2568 pref->setItemProperty( "indexes", anIndicesList, anaglyphFilter );
2570 // .... -> Convergence distance type
2571 int occFocusType = pref->addPreference( tr( "PREF_FOCUS_TYPE" ), stereoGroup,
2572 LightApp_Preferences::Selector, "OCCViewer", "focus_type" );
2573 aValuesList.clear();
2574 anIndicesList.clear();
2575 aValuesList << tr("PREF_ABSOLUTE") << tr("PREF_RELATIVE");
2576 anIndicesList << 0 << 1;
2577 pref->setItemProperty( "strings", aValuesList, occFocusType );
2578 pref->setItemProperty( "indexes", anIndicesList, occFocusType );
2580 // .... -> Stereographic focus value
2581 int focusValue = pref->addPreference( tr( "PREF_FOCUS_VALUE" ), stereoGroup,
2582 LightApp_Preferences::DblSpin, "OCCViewer", "focus_value" );
2583 pref->setItemProperty( "precision", 3, focusValue );
2584 pref->setItemProperty( "min", 1.0E-03, focusValue );
2585 pref->setItemProperty( "max", 1.0E03, focusValue );
2586 pref->setItemProperty( "step", 0.05, focusValue );
2589 int occIODType = pref->addPreference( tr( "PREF_IOD_TYPE" ), stereoGroup,
2590 LightApp_Preferences::Selector, "OCCViewer", "iod_type" );
2591 aValuesList.clear();
2592 anIndicesList.clear();
2593 aValuesList << tr("PREF_ABSOLUTE") << tr("PREF_RELATIVE");
2594 anIndicesList << 0 << 1;
2595 pref->setItemProperty( "strings", aValuesList, occIODType );
2596 pref->setItemProperty( "indexes", anIndicesList, occIODType );
2598 // .... -> Interocular distance (IOD) value
2599 int IODValue = pref->addPreference( tr( "PREF_IOD_VALUE" ), stereoGroup,
2600 LightApp_Preferences::DblSpin, "OCCViewer", "iod_value" );
2601 pref->setItemProperty( "precision", 3, IODValue );
2602 pref->setItemProperty( "min", 1.0E-03, IODValue );
2603 pref->setItemProperty( "max", 1.0E03, IODValue );
2604 pref->setItemProperty( "step", 0.05, IODValue );
2606 // .... -> Reverse stereo
2607 pref->addPreference( tr( "PREF_REVERSE_STEREO" ), stereoGroup,
2608 LightApp_Preferences::Bool, "OCCViewer", "reverse_stereo" );
2609 // .... -> Enable V-Sync
2610 pref->addPreference( tr( "PREF_ENABLE_VSYNC" ), stereoGroup,
2611 LightApp_Preferences::Bool, "OCCViewer", "enable_vsync" );
2612 // .... -> Enable quad-buffer support
2613 pref->addPreference( tr( "PREF_ENABLE_QUAD_BUFFER_SUPPORT" ), stereoGroup,
2614 LightApp_Preferences::Bool, "OCCViewer", "enable_quad_buffer_support" );
2616 // ... "Background" group <<start>>
2617 int bgGroup = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup );
2618 // pref->setItemProperty( "columns", 2, bgGroup );
2619 aValuesList.clear();
2620 anIndicesList.clear();
2623 formats = OCCViewer_Viewer::backgroundData( aValuesList, idList, txtList );
2624 foreach( int gid, idList ) anIndicesList << gid;
2625 // .... -> 3D viewer background
2626 bgId = pref->addPreference( tr( "PREF_3DVIEWER_BACKGROUND" ), bgGroup,
2627 LightApp_Preferences::Background, "OCCViewer", "background" );
2628 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2629 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2630 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2631 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2632 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2633 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2634 pref->setItemProperty( "custom_enabled", false, bgId );
2635 pref->setItemProperty( "image_formats", formats, bgId );
2636 // .... -> XZ viewer background
2637 bgId = pref->addPreference( tr( "PREF_XZVIEWER_BACKGROUND" ), bgGroup,
2638 LightApp_Preferences::Background, "OCCViewer", "xz_background" );
2639 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2640 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2641 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2642 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2643 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2644 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2645 pref->setItemProperty( "custom_enabled", false, bgId );
2646 pref->setItemProperty( "image_formats", formats, bgId );
2647 // .... -> YZ viewer background
2648 bgId = pref->addPreference( tr( "PREF_YZVIEWER_BACKGROUND" ), bgGroup,
2649 LightApp_Preferences::Background, "OCCViewer", "yz_background" );
2650 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2651 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2652 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2653 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2654 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2655 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2656 pref->setItemProperty( "custom_enabled", false, bgId );
2657 pref->setItemProperty( "image_formats", formats, bgId );
2658 // .... -> XY viewer background
2659 bgId = pref->addPreference( tr( "PREF_XYVIEWER_BACKGROUND" ), bgGroup,
2660 LightApp_Preferences::Background, "OCCViewer", "xy_background" );
2661 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2662 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2663 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2664 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2665 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2666 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2667 pref->setItemProperty( "custom_enabled", false, bgId );
2668 pref->setItemProperty( "image_formats", formats, bgId );
2669 // ... "Background" group <<end>>
2672 // ... "Selection" group <<start>>
2673 int occSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), occGroup );
2674 pref->setItemProperty( "columns", 3, occSelectionGroup );
2675 // .... -> enable preselection
2676 pref->addPreference( tr( "PREF_ENABLE_PRESELECTION" ), occSelectionGroup,
2677 LightApp_Preferences::Bool, "OCCViewer", "enable_preselection" );
2678 // .... -> enable selection
2679 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), occSelectionGroup,
2680 LightApp_Preferences::Bool, "OCCViewer", "enable_selection" );
2681 // .... -> selection style
2682 int aSeleStyle = pref->addPreference( tr( "PREF_SELECTION_STYLE" ), occSelectionGroup,
2683 LightApp_Preferences::Selector, "OCCViewer", "adv_selection_mode" );
2684 aValuesList.clear();
2685 anIndicesList.clear();
2686 aValuesList << tr("PREF_POLYGON_SELECTION") << tr("PREF_CIRCLE_SELECTION");
2687 anIndicesList << 0 << 1;
2688 pref->setItemProperty( "strings", aValuesList, aSeleStyle);
2689 pref->setItemProperty( "indexes", anIndicesList, aSeleStyle);
2690 // ... "Selection" group <<end>>
2692 // ... "Clipping" group <<start>>
2693 int occClippingGroup = pref->addPreference( tr( "PREF_GROUP_CLIPPING" ), occGroup );
2694 // .... -> clipping color
2695 pref->addPreference( tr( "PREF_CLIPPING_COLOR" ), occClippingGroup,
2696 LightApp_Preferences::Color, "OCCViewer", "clipping_color" );
2697 int texturePref = pref->addPreference( "", occClippingGroup, LightApp_Preferences::Frame );
2698 pref->setItemProperty( "columns", 2, texturePref );
2699 // .... -> use default texture
2700 pref->addPreference( tr( "PREF_CLIPPING_DEFAULT_TEXTURE" ), texturePref,
2701 LightApp_Preferences::Bool, "OCCViewer", "clipping_use_default_texture" );
2702 // .... -> clipping texture
2703 int filePref = pref->addPreference( tr( "PREF_CLIPPING_TEXTURE" ), texturePref,
2704 LightApp_Preferences::File, "OCCViewer", "clipping_texture" );
2705 pref->setItemProperty( "path_filter", tr( "OCC_TEXTURE_FILES" ), filePref );
2707 pref->addPreference( tr( "PREF_CLIPPING_MODULATE" ), texturePref,
2708 LightApp_Preferences::Bool, "OCCViewer", "clipping_modulate" );
2709 // .... -> scale factor
2710 int scaleFactor = pref->addPreference( tr( "PREF_CLIPPING_SCALE" ), texturePref,
2711 LightApp_Preferences::DblSpin, "OCCViewer", "clipping_scale" );
2712 pref->setItemProperty( "precision", 3, scaleFactor );
2713 pref->setItemProperty( "min", 1.0E-03, scaleFactor );
2714 pref->setItemProperty( "max", 1.0E03, scaleFactor );
2715 pref->setItemProperty( "step", 0.1, scaleFactor );
2716 // ... "Clipping" group <<end>>
2718 // ... "Ray tracing" group <<start>>
2719 int occRayTracingGroup = pref->addPreference( tr( "PREF_GROUP_RAY_TRACING" ), occGroup );
2720 int rtPref = pref->addPreference( "", occRayTracingGroup, LightApp_Preferences::Frame );
2721 pref->setItemProperty( "columns", 2, rtPref );
2723 int rt_depth = pref->addPreference( tr( "PREF_RAY_TRACING_DEPTH" ), rtPref,
2724 LightApp_Preferences::IntSpin, "OCCViewer", "rt_depth" );
2725 pref->setItemProperty( "min", 1, rt_depth );
2726 pref->setItemProperty( "max", 10, rt_depth );
2727 pref->setItemProperty( "step", 1, rt_depth );
2728 pref->addPreference( "", rtPref, LightApp_Preferences::Frame );
2729 // .... -> specular reflections
2730 pref->addPreference( tr( "PREF_RAY_TRACING_REFLECTION" ), rtPref,
2731 LightApp_Preferences::Bool, "OCCViewer", "rt_reflection" );
2732 // .... -> adaptive anti-aliasing
2733 pref->addPreference( tr( "PREF_RAY_TRACING_ANTIALIASING" ), rtPref,
2734 LightApp_Preferences::Bool, "OCCViewer", "rt_antialiasing" );
2735 // .... -> shadows rendering
2736 pref->addPreference( tr( "PREF_RAY_TRACING_SHADOW" ), rtPref,
2737 LightApp_Preferences::Bool, "OCCViewer", "rt_shadow" );
2738 // .... -> transparent shadow
2739 pref->addPreference( tr( "PREF_RAY_TRACING_TRANS_SHADOW" ), rtPref,
2740 LightApp_Preferences::Bool, "OCCViewer", "rt_trans_shadow" );
2741 // ... "Ray tracing" group <<end>>
2743 // ... "Light source" group <<start>>
2744 int occLightGroup = pref->addPreference( tr( "PREF_GROUP_LIGHT" ), occGroup );
2745 // .... -> light color
2746 pref->addPreference( tr( "PREF_LIGHT_COLOR" ), occLightGroup,
2747 LightApp_Preferences::Color, "OCCViewer", "light_color" );
2748 int directionPref = pref->addPreference( "", occLightGroup, LightApp_Preferences::Frame );
2749 pref->setItemProperty( "columns", 3, directionPref );
2750 // .... -> light direction (dx component)
2751 int light_dx = pref->addPreference( tr( "Dx" ), directionPref,
2752 LightApp_Preferences::DblSpin, "OCCViewer", "light_dx" );
2753 pref->setItemProperty( "precision", 2, light_dx );
2754 pref->setItemProperty( "min", -1.0E03, light_dx );
2755 pref->setItemProperty( "max", 1.0E03, light_dx );
2756 pref->setItemProperty( "step", 0.1, light_dx );
2757 // .... -> light direction (dy component)
2758 int light_dy = pref->addPreference( tr( "Dy" ), directionPref,
2759 LightApp_Preferences::DblSpin, "OCCViewer", "light_dy" );
2760 pref->setItemProperty( "precision", 2, light_dy );
2761 pref->setItemProperty( "min", -1.0E03, light_dy );
2762 pref->setItemProperty( "max", 1.0E03, light_dy );
2763 pref->setItemProperty( "step", 0.1, light_dy );
2764 // .... -> light direction (dz component)
2765 int light_dz = pref->addPreference( tr( "Dz" ), directionPref,
2766 LightApp_Preferences::DblSpin, "OCCViewer", "light_dz" );
2767 pref->setItemProperty( "precision", 2, light_dz );
2768 pref->setItemProperty( "min", -1.0E03, light_dz );
2769 pref->setItemProperty( "max", 1.0E03, light_dz );
2770 pref->setItemProperty( "step", 0.1, light_dz );
2771 // ... "Light source" group <<end>>
2773 // ... -> empty frame (for layout) <<start>>
2774 int occGen = pref->addPreference( "", occGroup, LightApp_Preferences::Frame );
2775 pref->setItemProperty( "margin", 0, occGen );
2776 pref->setItemProperty( "columns", 2, occGen );
2777 // ... -> empty frame (for layout) <<end>>
2779 // .. "OCC viewer" group <<end>>
2782 #ifndef DISABLE_VTKVIEWER
2783 // .. "VTK viewer" group <<start>>
2784 int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), salomeCat ); //viewTab
2786 // ... -> empty frame (for layout) <<start>>
2787 int vtkGen = pref->addPreference( "", vtkGroup, LightApp_Preferences::Frame );
2788 //pref->setItemProperty( "columns", 2, vtkGen );
2789 // .... -> projection mode
2790 int vtkProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), vtkGen,
2791 LightApp_Preferences::Selector, "VTKViewer", "projection_mode" );
2792 aValuesList.clear();
2793 anIndicesList.clear();
2794 aValuesList << tr("PREF_ORTHOGRAPHIC") << tr("PREF_PERSPECTIVE");
2795 anIndicesList << 0 << 1;
2796 pref->setItemProperty( "strings", aValuesList, vtkProjMode );
2797 pref->setItemProperty( "indexes", anIndicesList, vtkProjMode );
2799 // .... -> Stereo group
2800 int vtkStereoGroup = pref->addPreference( tr( "PREF_GROUP_STEREO" ), vtkGroup);
2801 pref->setItemProperty( "columns", 2, vtkStereoGroup );
2802 // .... -> Stereo type
2803 int vtkStereoType = pref->addPreference( tr( "PREF_STEREO_TYPE" ), vtkStereoGroup,
2804 LightApp_Preferences::Selector, "VTKViewer", "stereo_type" );
2805 aValuesList.clear();
2806 anIndicesList.clear();
2808 SVTK_Viewer::stereoData( aValuesList, idList);
2809 foreach( int gid, idList ) anIndicesList << gid;
2810 pref->setItemProperty( "strings", aValuesList, vtkStereoType );
2811 pref->setItemProperty( "indexes", anIndicesList, vtkStereoType );
2812 // .... -> Anaglyph filter
2813 int vtkAnaglyphFilter = pref->addPreference( tr( "PREF_ANAGLYPH_FILTER" ), vtkStereoGroup,
2814 LightApp_Preferences::Selector, "VTKViewer", "anaglyph_filter" );
2815 aValuesList.clear();
2816 anIndicesList.clear();
2817 aValuesList << tr("PREF_ANAGLYPH_RED_CYAN") << tr("PREF_ANAGLYPH_YELLOW_BLUE") << tr("PREF_ANAGLYPH_GREEN_MAGENTA");
2818 anIndicesList << 0 << 1 << 2;
2820 pref->setItemProperty( "strings", aValuesList, vtkAnaglyphFilter );
2821 pref->setItemProperty( "indexes", anIndicesList, vtkAnaglyphFilter );
2823 // .... -> Enable quad-buffer support
2824 pref->addPreference( tr( "PREF_ENABLE_QUAD_BUFFER_SUPPORT" ), vtkStereoGroup,
2825 LightApp_Preferences::Bool, "VTKViewer", "enable_quad_buffer_support" );
2827 // .... -> background
2828 aValuesList.clear();
2829 anIndicesList.clear();
2832 #ifndef DISABLE_SALOMEOBJECT
2833 formats = SVTK_Viewer::backgroundData( aValuesList, idList, txtList );
2835 foreach( int gid, idList ) anIndicesList << gid;
2836 bgId = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGen,
2837 LightApp_Preferences::Background, "VTKViewer", "background" );
2838 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2839 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2840 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2841 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2842 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2843 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2844 pref->setItemProperty( "custom_enabled", false, bgId );
2845 #ifndef DISABLE_SALOMEOBJECT
2846 pref->setItemProperty( "image_formats", formats, bgId );
2848 // .... -> speed increment
2849 int vtkSpeed = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED" ), vtkGen,
2850 LightApp_Preferences::IntSpin, "VTKViewer", "speed_value" );
2851 pref->setItemProperty( "min", 1, vtkSpeed );
2852 pref->setItemProperty( "max", 1000, vtkSpeed );
2853 // .... -> speed mode
2854 int vtkSpeedMode = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED_MODE" ), vtkGen,
2855 LightApp_Preferences::Selector, "VTKViewer", "speed_mode" );
2856 aValuesList.clear();
2857 anIndicesList.clear();
2858 aValuesList << tr("PREF_ARITHMETIC") << tr("PREF_GEOMETRICAL");
2859 anIndicesList << 0 << 1;
2860 pref->setItemProperty( "strings", aValuesList, vtkSpeedMode );
2861 pref->setItemProperty( "indexes", anIndicesList, vtkSpeedMode );
2863 // ... "Selection" group <<start>>
2864 int vtkSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), vtkGroup );
2865 pref->setItemProperty( "columns", 2, vtkSelectionGroup );
2866 // .... -> preselection
2867 int vtkPreselection = pref->addPreference( tr( "PREF_PRESELECTION" ), vtkSelectionGroup,
2868 LightApp_Preferences::Selector, "VTKViewer", "preselection" );
2869 aValuesList.clear();
2870 anIndicesList.clear();
2871 aValuesList << tr("PREF_PRESELECTION_STANDARD") << tr("PREF_PRESELECTION_DYNAMIC") << tr("PREF_PRESELECTION_DISABLED");
2872 anIndicesList << 0 << 1 << 2;
2873 pref->setItemProperty( "strings", aValuesList, vtkPreselection );
2874 pref->setItemProperty( "indexes", anIndicesList, vtkPreselection );
2875 // .... -> enable selection
2876 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), vtkSelectionGroup, LightApp_Preferences::Bool, "VTKViewer", "enable_selection" );
2877 // ... "Selection" group <<end>>
2879 // ... -> empty frame (for layout) <<end>>
2881 // ... space mouse sub-group <<start>>
2882 int vtkSM = pref->addPreference( tr( "PREF_FRAME_SPACEMOUSE" ), vtkGroup, LightApp_Preferences::GroupBox );
2883 //pref->setItemProperty( "columns", 2, vtkSM );
2884 // .... -> decrease speed increment
2885 int spacemousePref1 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_1" ), vtkSM,
2886 LightApp_Preferences::Selector, "VTKViewer",
2887 "spacemouse_func1_btn" );
2888 // .... -> increase speed increment
2889 int spacemousePref2 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_2" ), vtkSM,
2890 LightApp_Preferences::Selector, "VTKViewer",
2891 "spacemouse_func2_btn" );
2892 // .... -> dominant / combined switch
2893 int spacemousePref3 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_3" ), vtkSM,
2894 LightApp_Preferences::Selector, "VTKViewer",
2895 "spacemouse_func5_btn" ); //
2896 aValuesList.clear();
2897 anIndicesList.clear();
2898 aValuesList << tr( "PREF_SPACEMOUSE_BTN_1" ) << tr( "PREF_SPACEMOUSE_BTN_2" ) << tr( "PREF_SPACEMOUSE_BTN_3" );
2899 aValuesList << tr( "PREF_SPACEMOUSE_BTN_4" ) << tr( "PREF_SPACEMOUSE_BTN_5" ) << tr( "PREF_SPACEMOUSE_BTN_6" );
2900 aValuesList << tr( "PREF_SPACEMOUSE_BTN_7" ) << tr( "PREF_SPACEMOUSE_BTN_8" ) << tr( "PREF_SPACEMOUSE_BTN_*" );
2901 aValuesList << tr( "PREF_SPACEMOUSE_BTN_10" ) << tr( "PREF_SPACEMOUSE_BTN_11" );
2902 anIndicesList << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11;
2903 pref->setItemProperty( "strings", aValuesList, spacemousePref1 );
2904 pref->setItemProperty( "indexes", anIndicesList, spacemousePref1 );
2905 pref->setItemProperty( "strings", aValuesList, spacemousePref2 );
2906 pref->setItemProperty( "indexes", anIndicesList, spacemousePref2 );
2907 pref->setItemProperty( "strings", aValuesList, spacemousePref3 );
2908 pref->setItemProperty( "indexes", anIndicesList, spacemousePref3 );
2909 // ... space mouse sub-group <<end>>
2911 // ... avi recording sub-group <<start>>
2912 int vtkRec = pref->addPreference( tr( "PREF_FRAME_RECORDING" ), vtkGroup, LightApp_Preferences::GroupBox );
2913 pref->setItemProperty( "columns", 2, vtkRec );
2914 // .... -> recording mode
2915 int modePref = pref->addPreference( tr( "PREF_RECORDING_MODE" ), vtkRec,
2916 LightApp_Preferences::Selector, "VTKViewer", "recorder_mode" );
2917 aValuesList.clear();
2918 anIndicesList.clear();
2919 aValuesList << tr( "PREF_SKIPPED_FRAMES" ) << tr( "PREF_ALL_DISLPAYED_FRAMES" );
2920 anIndicesList << 0 << 1;
2921 pref->setItemProperty( "strings", aValuesList, modePref );
2922 pref->setItemProperty( "indexes", anIndicesList, modePref );
2924 int fpsPref = pref->addPreference( tr( "PREF_FPS" ), vtkRec,
2925 LightApp_Preferences::DblSpin, "VTKViewer", "recorder_fps" );
2926 pref->setItemProperty( "min", 0.1, fpsPref );
2927 pref->setItemProperty( "max", 100, fpsPref );
2929 int qualityPref = pref->addPreference( tr( "PREF_QUALITY" ), vtkRec,
2930 LightApp_Preferences::IntSpin, "VTKViewer", "recorder_quality" );
2931 pref->setItemProperty( "min", 1, qualityPref );
2932 pref->setItemProperty( "max", 100, qualityPref );
2933 // .... -> progressive mode
2934 pref->addPreference( tr( "PREF_PROGRESSIVE" ), vtkRec,
2935 LightApp_Preferences::Bool, "VTKViewer", "recorder_progressive" );
2936 // ... avi recording sub-group <<end>>
2938 // ... group names sub-group <<start>>
2939 int vtkGN = pref->addPreference( tr( "PREF_FRAME_GROUP_NAMES" ), vtkGroup,
2940 LightApp_Preferences::GroupBox, "VTKViewer", "show_group_names" );
2941 pref->setItemProperty( "columns", 2, vtkGN );
2942 // .... -> text color
2943 pref->addPreference( tr( "PREF_GROUP_NAMES_TEXT_COLOR" ), vtkGN,
2944 LightApp_Preferences::Color, "VTKViewer", "group_names_text_color" );
2945 // .... -> transparency
2946 int transPref = pref->addPreference( tr( "PREF_GROUP_NAMES_TRANSPARENCY" ), vtkGN,
2947 LightApp_Preferences::DblSpin, "VTKViewer", "group_names_transparency" );
2948 pref->setItemProperty( "min", 0.0, transPref );
2949 pref->setItemProperty( "max", 1.0, transPref );
2950 pref->setItemProperty( "step", 0.1, transPref );
2951 // ... -> group names sub-group <<end>>
2952 // .. "VTK viewer" group <<end>>
2955 // .. "Plot2d viewer" group <<start>>
2956 int plot2dGroup = pref->addPreference( tr( "PREF_GROUP_PLOT2DVIEWER" ), salomeCat ); //viewTab
2957 //pref->setItemProperty( "columns", 2, plot2dGroup );
2959 // ... -> background
2960 pref->addPreference( tr( "PREF_VIEWER_BACKGROUND_COLOR" ), plot2dGroup,
2961 LightApp_Preferences::Color, "Plot2d", "Background" );
2962 // ... -> selection color
2963 pref->addPreference( tr( "PREF_VIEWER_SELECTION" ), plot2dGroup,
2964 LightApp_Preferences::Color, "Plot2d", "SelectionColor" );
2966 // ... "Viewer" group <<start>>
2967 int plot2dViewerGroup = pref->addPreference( tr( "PREF_GROUP_VIEWER" ), plot2dGroup );
2969 // .... -> curve type
2970 int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dViewerGroup,
2971 LightApp_Preferences::Selector, "Plot2d", "CurveType" );
2972 aValuesList.clear();
2973 anIndicesList.clear();
2974 aValuesList << tr("PREF_POINTS") << tr("PREF_LINES") << tr("PREF_SPLINE");
2975 anIndicesList << 0 << 1 << 2 ;
2976 pref->setItemProperty( "strings", aValuesList, curveType );
2977 pref->setItemProperty( "indexes", anIndicesList, curveType );
2978 // .... -> marker size
2979 int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dViewerGroup,
2980 LightApp_Preferences::IntSpin, "Plot2d", "MarkerSize" );
2981 pref->setItemProperty( "min", 0, markerSize );
2982 pref->setItemProperty( "max", 100, markerSize );
2983 // .... -> horizontal scaling mode
2984 int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dViewerGroup,
2985 LightApp_Preferences::Selector, "Plot2d", "HorScaleMode" );
2986 aValuesList.clear();
2987 anIndicesList.clear();
2988 aValuesList << tr("PREF_LINEAR") << tr("PREF_LOGARITHMIC");
2989 anIndicesList << 0 << 1 ;
2990 pref->setItemProperty( "strings", aValuesList, horScale );
2991 pref->setItemProperty( "indexes", anIndicesList, horScale );
2992 // .... -> vertical scaling mode
2993 int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dViewerGroup,
2994 LightApp_Preferences::Selector, "Plot2d", "VerScaleMode" );
2995 pref->setItemProperty( "strings", aValuesList, verScale );
2996 pref->setItemProperty( "indexes", anIndicesList, verScale );
2998 // .... -> errors/deviation colot
2999 pref->addPreference( tr( "PREF_DEVIATION_COLOR" ), plot2dViewerGroup,
3000 LightApp_Preferences::Color, "Plot2d", "DeviationMarkerColor" );
3001 // .... -> deviation markers line size
3002 int deviationMarkerLw = pref->addPreference( tr( "PREF_DEVIATION_MARKER_LW" ), plot2dViewerGroup,
3003 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerLineWidth" );
3004 pref->setItemProperty( "min", 1, deviationMarkerLw );
3005 pref->setItemProperty( "max", 5, deviationMarkerLw );
3006 // .... -> deviation markers tick mark size
3007 int deviationMarkerTs = pref->addPreference( tr( "PREF_DEVIATION_MARKER_TS" ), plot2dViewerGroup,
3008 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerTickSize" );
3009 pref->setItemProperty( "min", 1, deviationMarkerTs );
3010 pref->setItemProperty( "max", 5, deviationMarkerTs );
3011 // .... "Viewer" group <<end>>
3013 // ... "Legend" group <<start>>
3014 int plot2dLegendGroup = pref->addPreference( tr( "PREF_GROUP_LEGEND" ), plot2dGroup );
3016 // .... -> show legend
3017 pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dLegendGroup,
3018 LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
3019 // .... -> legend position
3020 int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dLegendGroup,
3021 LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
3022 aValuesList.clear();
3023 anIndicesList.clear();
3024 aValuesList << tr("PREF_LEFT") << tr("PREF_RIGHT") << tr("PREF_TOP") << tr("PREF_BOTTOM");
3025 anIndicesList << 0 << 1 << 2 << 3 ;
3026 pref->setItemProperty( "strings", aValuesList, legendPosition );
3027 pref->setItemProperty( "indexes", anIndicesList, legendPosition );
3028 // .... -> Symbol type
3029 int legendSymbolType = pref->addPreference( tr( "PREF_LEGEND_SYMBOL_TYPE" ), plot2dLegendGroup,
3030 LightApp_Preferences::Selector, "Plot2d", "LegendSymbolType" );
3031 aValuesList.clear();
3032 anIndicesList.clear();
3033 aValuesList << tr("PREF_MARKER_ON_LINE") << tr("PREF_MARKER_ABOVE_LINE");
3034 anIndicesList << 0 << 1 ;
3035 pref->setItemProperty( "strings", aValuesList, legendSymbolType );
3036 pref->setItemProperty( "indexes", anIndicesList, legendSymbolType );
3037 // .... -> legend font
3038 pref->addPreference( tr( "PREF_LEGEND_FONT" ), plot2dLegendGroup, LightApp_Preferences::Font, "Plot2d", "LegendFont" );
3039 // ... -> font color
3040 pref->addPreference( tr( "PREF_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "LegendFontColor" );
3041 // ... -> selection font color
3042 pref->addPreference( tr( "PREF_SELECTED_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "SelectedLegendFontColor" );
3043 // ... "Legend" group <<end>>
3045 // .. "Plot2d viewer" group <<end>>
3047 // .. "PyViewer" preferences tab <<start>>
3048 int pyeditTab = pref->addPreference( tr( "PREF_TAB_PYEDITOR" ), salomeCat );
3049 // ... "Font settings" group <<start>>
3050 int pyFontGroup = pref->addPreference( tr( "PREF_GROUP_PY_FONT" ), pyeditTab );
3051 int pyFont = pref->addPreference( tr( "PREF_PY_FONT" ), pyFontGroup,
3052 LightApp_Preferences::Font, "PyEditor", "Font" );
3053 pref->setItemProperty( "features", QtxFontEdit::Family | QtxFontEdit::Size | QtxFontEdit::UserSize, pyFont );
3054 // ... "Font settings" group <<end>>
3055 // ... "Display settings" group <<start>>
3056 int pyDispGroup = pref->addPreference( tr( "PREF_GROUP_PY_DISPLAY" ), pyeditTab );
3057 pref->setItemProperty( "columns", 2, pyDispGroup );
3058 // ... -> current line highlight
3059 pref->addPreference( tr( "PREF_PY_CURRLINE_HIGHLIGHT" ), pyDispGroup,
3060 LightApp_Preferences::Bool, "PyEditor", "HighlightCurrentLine" );
3061 // ... -> text wrapping
3062 pref->addPreference( tr( "PREF_PY_TEXT_WRAP" ), pyDispGroup,
3063 LightApp_Preferences::Bool, "PyEditor", "TextWrapping" );
3064 // ... -> center cursor on scroll
3065 pref->addPreference( tr( "PREF_PY_CURSON_ON_SCROLL" ), pyDispGroup,
3066 LightApp_Preferences::Bool, "PyEditor", "CenterCursorOnScroll" );
3067 // ... -> line numbers area
3068 pref->addPreference( tr( "PREF_PY_LINE_NUMBS_AREA" ), pyDispGroup,
3069 LightApp_Preferences::Bool, "PyEditor", "LineNumberArea" );
3070 // ... "Display settings" group <<end>>
3072 // ... "Editor settings" group <<start>>
3073 int pyEditGroup = pref->addPreference( tr( "PREF_GROUP_PY_EDITOR" ), pyeditTab );
3074 // ... -> navigation mode
3075 int pyCompletion = pref->addPreference( tr( "PREF_PY_COMPLETION_MODE" ), pyEditGroup,
3076 LightApp_Preferences::Selector, "PyEditor", "CompletionPolicy" );
3077 aValuesList.clear();
3078 anIndicesList.clear();
3079 aValuesList << tr("PREF_PY_NONE") << tr("PREF_PY_AUTO") << tr("PREF_PY_MANUAL") << tr("PREF_PY_ALWAYS");
3080 anIndicesList << 0 << 1 << 2 << 3 ;
3081 pref->setItemProperty( "strings", aValuesList, pyCompletion );
3082 pref->setItemProperty( "indexes", anIndicesList, pyCompletion );
3083 // ... "Editor settings" group <<end>>
3085 // ... "Tab settings" group <<start>>
3086 int pyTabGroup = pref->addPreference( tr( "PREF_GROUP_PY_TAB" ), pyeditTab );
3087 pref->setItemProperty( "columns", 2, pyTabGroup );
3088 // ... -> tab whitespaces
3089 pref->addPreference( tr( "PREF_PY_TAB_WHITESPACES" ), pyTabGroup,
3090 LightApp_Preferences::Bool, "PyEditor", "TabSpaceVisible" );
3092 pref->addPreference( tr( "PREF_PY_TAB_SIZE" ), pyTabGroup,
3093 LightApp_Preferences::IntSpin, "PyEditor", "TabSize" );
3094 // ... "Tab settings" group <<end>>
3095 // ... "Vertical edge settings" group <<start>>
3096 int pyVertEdgeGroup = pref->addPreference( tr( "PREF_GROUP_VERT_EDGE" ), pyeditTab );
3097 pref->setItemProperty( "columns", 2, pyVertEdgeGroup );
3098 // ... -> vertical edge
3099 pref->addPreference( tr( "PREF_PY_VERT_EDGE" ), pyVertEdgeGroup,
3100 LightApp_Preferences::Bool, "PyEditor", "VerticalEdge" );
3101 // ... -> number of columns
3102 pref->addPreference( tr( "PREF_PY_NUM_COLUMNS" ), pyVertEdgeGroup,
3103 LightApp_Preferences::IntSpin, "PyEditor", "NumberColumns" );
3104 // ... "Vertical edge settings" group <<end>>
3105 // .. "PyEditor" preferences tab <<end>>
3107 // .. "Directories" preferences tab <<start>>
3108 int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat );
3109 // ... --> quick directories list
3110 int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab );
3111 pref->addPreference( tr( "" ), dirGroup,
3112 LightApp_Preferences::DirList, "FileDlg", "QuickDirList" );
3113 // .. "Directories" preferences tab <<end>>
3115 // .. "Object browser" preferences tab <<start>>
3116 int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
3118 // ... "Search tool" group <<start>>
3119 int stGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SEARCH_TOOL" ), obTab );
3120 // .... --> auto-hide
3121 pref->addPreference( tr( "PREF_AUTO_HIDE_SEARCH_TOOL" ), stGroup, LightApp_Preferences::Bool,
3122 "ObjectBrowser", "auto_hide_search_tool" );
3123 // ... "Search tool" group <<end>>
3125 // ... "Object browser settings" group <<start>>
3126 int objSetGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), obTab );
3127 pref->setItemProperty( "columns", 2, objSetGroup );
3128 // .... -> auto size first column
3129 pref->addPreference( tr( "PREF_AUTO_SIZE_FIRST" ), objSetGroup, LightApp_Preferences::Bool,
3130 "ObjectBrowser", "auto_size_first" );
3131 // .... -> auto size other columns
3132 pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool,
3133 "ObjectBrowser", "auto_size" );
3134 // .... -> resize columns on expand item
3135 pref->addPreference( tr( "PREF_RESIZE_ON_EXPAND_ITEM" ), objSetGroup, LightApp_Preferences::Bool,
3136 "ObjectBrowser", "resize_on_expand_item" );
3137 // .... -> browse to published object
3138 int browsePublished = pref->addPreference( tr( "PREF_BROWSE_TO_THE_PUBLISHED_OBJECT" ), objSetGroup, LightApp_Preferences::Selector,
3139 "ObjectBrowser", "browse_published_object" );
3140 aValuesList.clear();
3141 anIndicesList.clear();
3142 aValuesList << tr( "PREF_BROWSE_NEVER" ) << tr( "PREF_BROWSE_AFTER_APPLY_AND_CLOSE_ONLY" ) << tr( "PREF_BROWSE_ALWAYS" );
3143 anIndicesList << BP_Never << BP_ApplyAndClose << BP_Always;
3144 pref->setItemProperty( "strings", aValuesList, browsePublished );
3145 pref->setItemProperty( "indexes", anIndicesList, browsePublished );
3146 // ... "Object browser settings" group <<end>>
3147 // .. "Object browser" preferences tab <<end>>
3149 // .. "Shortcuts" preferences tab <<start>>
3150 int shortcutTab = pref->addPreference( tr( "PREF_TAB_SHORTCUTS" ), salomeCat );
3151 // ... "Shortcuts settings" group <<start>>
3152 int shortcutGroup = pref->addPreference( tr( "PREF_GROUP_SHORTCUTS" ), shortcutTab );
3153 pref->addPreference( tr( "" ), shortcutGroup,
3154 LightApp_Preferences::ShortcutTree, "shortcuts" );
3155 // ... "Shortcuts settings" group <<end>>
3156 // .. "Shortcuts" preferences tab <<end>>
3157 // . Top-level "SALOME" preferences group <<end>>
3163 Changes appearance of application according to changed preferences
3164 \param sec - section
3165 \param param - name of changed parameter
3167 void LightApp_Application::preferencesChanged( const QString& sec, const QString& param )
3169 SUIT_ResourceMgr* resMgr = resourceMgr();
3173 if ( sec == "viewers" && param == "drop_down_buttons" )
3175 ViewManagerList vmlist = viewManagers();
3176 foreach( SUIT_ViewManager* vm, vmlist )
3178 QVector<SUIT_ViewWindow*> vwlist = vm->getViews();
3179 foreach( SUIT_ViewWindow* vw, vwlist )
3180 if ( vw ) vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
3184 if ( sec == QString( "3DViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )))
3186 double sz = resMgr->doubleValue( sec, "trihedron_size", -1 );
3187 bool relative = resMgr->booleanValue( sec, "relative_size", true );
3188 QList<SUIT_ViewManager*> lst;
3189 #ifndef DISABLE_OCCVIEWER
3190 viewManagers( OCCViewer_Viewer::Type(), lst );
3191 QListIterator<SUIT_ViewManager*> itOCC( lst );
3192 while ( itOCC.hasNext() && sz >= 0 )
3194 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3195 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3198 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3199 occVM->setTrihedronSize( sz, relative );
3200 occVM->getAISContext()->UpdateCurrentViewer();
3203 #ifndef DISABLE_VTKVIEWER
3204 #ifndef DISABLE_SALOMEOBJECT
3205 viewManagers( SVTK_Viewer::Type(), lst );
3206 QListIterator<SUIT_ViewManager*> itVTK( lst );
3207 while ( itVTK.hasNext() && sz >= 0 )
3209 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3210 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3213 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3216 vtkVM->setTrihedronSize( sz, relative );
3224 if ( sec == QString( "3DViewer" ) && param == QString( "show_static_trihedron" ) )
3226 bool isVisible = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
3227 QList<SUIT_ViewManager*> lst;
3228 #ifndef DISABLE_OCCVIEWER
3229 viewManagers( OCCViewer_Viewer::Type(), lst );
3230 QListIterator<SUIT_ViewManager*> itOCC( lst );
3231 while ( itOCC.hasNext() )
3233 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3234 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3237 OCCViewer_Viewer* occVM = dynamic_cast<OCCViewer_Viewer*>( vm );
3240 occVM->setStaticTrihedronDisplayed( isVisible );
3244 #ifndef DISABLE_VTKVIEWER
3245 #ifndef DISABLE_SALOMEOBJECT
3246 viewManagers( SVTK_Viewer::Type(), lst );
3247 QListIterator<SUIT_ViewManager*> itVTK( lst );
3248 while ( itVTK.hasNext() )
3250 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3251 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3254 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3257 vtkVM->setStaticTrihedronVisible( isVisible );
3265 if ( sec == QString( "3DViewer" ) && param == QString( "navigation_mode" ) )
3267 int mode = resMgr->integerValue( "3DViewer", "navigation_mode", 0 );
3268 QList<SUIT_ViewManager*> lst;
3269 #ifndef DISABLE_OCCVIEWER
3270 viewManagers( OCCViewer_Viewer::Type(), lst );
3271 QListIterator<SUIT_ViewManager*> itOCC( lst );
3272 while ( itOCC.hasNext() )
3274 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3275 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3278 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3279 occVM->setInteractionStyle( mode );
3282 #ifndef DISABLE_VTKVIEWER
3283 #ifndef DISABLE_SALOMEOBJECT
3284 viewManagers( SVTK_Viewer::Type(), lst );
3285 QListIterator<SUIT_ViewManager*> itVTK( lst );
3286 while ( itVTK.hasNext() )
3288 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3289 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3292 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3293 if( vtkVM ) vtkVM->setInteractionStyle( mode );
3299 #ifndef DISABLE_OCCVIEWER
3300 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_preselection" ) )
3302 bool isToEnablePreselection = resMgr->booleanValue( "OCCViewer", "enable_preselection", true );
3303 QList<SUIT_ViewManager*> lst;
3304 viewManagers( OCCViewer_Viewer::Type(), lst );
3305 QListIterator<SUIT_ViewManager*> it( lst );
3306 while ( it.hasNext() )
3308 SUIT_ViewModel* vm = it.next()->getViewModel();
3309 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3312 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3313 occVM->enablePreselection( isToEnablePreselection );
3318 #ifndef DISABLE_OCCVIEWER
3319 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_selection" ) )
3321 bool isToEnableSelection = resMgr->booleanValue( "OCCViewer", "enable_selection", true );
3322 QList<SUIT_ViewManager*> lst;
3323 viewManagers( OCCViewer_Viewer::Type(), lst );
3324 QListIterator<SUIT_ViewManager*> it( lst );
3325 while ( it.hasNext() )
3327 SUIT_ViewModel* vm = it.next()->getViewModel();
3328 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3331 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3332 occVM->enableSelection( isToEnableSelection );
3337 #ifndef DISABLE_OCCVIEWER
3338 if ( sec == QString( "OCCViewer" ) && param == QString( "clipping_color" ) )
3340 QColor aColor = resMgr->colorValue( "OCCViewer", "clipping_color", QColor( 50, 50, 50 ) );
3341 QList<SUIT_ViewManager*> lst;
3342 viewManagers( OCCViewer_Viewer::Type(), lst );
3343 QListIterator<SUIT_ViewManager*> it( lst );
3344 while ( it.hasNext() )
3346 SUIT_ViewModel* vm = it.next()->getViewModel();
3347 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3350 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3351 occVM->setClippingColor( aColor );
3356 #ifndef DISABLE_OCCVIEWER
3357 if ( sec == QString( "OCCViewer" ) && ( param == QString( "clipping_use_default_texture" ) ||
3358 param == QString( "clipping_texture" ) ||
3359 param == QString( "clipping_modulate" ) ||
3360 param == QString( "clipping_scale" ) ) )
3362 bool isDefaultTextureUsed = resMgr->booleanValue( "OCCViewer", "clipping_use_default_texture" );
3363 QString aTexture = resMgr->stringValue( "OCCViewer", "clipping_texture" );
3364 bool isModulated = resMgr->booleanValue( "OCCViewer", "clipping_modulate" );
3365 double aScale = resMgr->doubleValue( "OCCViewer", "clipping_scale" );
3366 QList<SUIT_ViewManager*> lst;
3367 viewManagers( OCCViewer_Viewer::Type(), lst );
3368 QListIterator<SUIT_ViewManager*> it( lst );
3369 while ( it.hasNext() )
3371 SUIT_ViewModel* vm = it.next()->getViewModel();
3372 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3375 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3376 occVM->setClippingTextureParams( isDefaultTextureUsed, aTexture, isModulated, aScale );
3381 #ifndef DISABLE_OCCVIEWER
3382 if ( sec == QString( "OCCViewer" ) && param == QString( "projection_mode" ) )
3384 int mode = resMgr->integerValue( "OCCViewer", "projection_mode", 0 );
3385 QList<SUIT_ViewManager*> lst;
3386 viewManagers( OCCViewer_Viewer::Type(), lst );
3387 QListIterator<SUIT_ViewManager*> it( lst );
3388 while ( it.hasNext() )
3390 SUIT_ViewModel* vm = it.next()->getViewModel();
3391 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3394 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3395 occVM->setProjectionType( mode );
3401 #ifndef DISABLE_OCCVIEWER
3402 if (sec == QString("OCCViewer") && param == QString("adv_selection_mode"))
3404 int mode = resMgr->integerValue("OCCViewer", "adv_selection_mode", 0);
3405 QList<SUIT_ViewManager*> lst;
3406 viewManagers(OCCViewer_Viewer::Type(), lst);
3407 QListIterator<SUIT_ViewManager*> it(lst);
3408 while (it.hasNext())
3410 SUIT_ViewModel* vm = it.next()->getViewModel();
3411 if (!vm || !vm->inherits("OCCViewer_Viewer"))
3414 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3415 occVM->setSelectionStyle((OCCViewer_ViewWindow::SelectionStyle)mode);
3421 #ifndef DISABLE_OCCVIEWER
3422 if ( sec == QString( "OCCViewer" ) && param == QString( "stereo_type" ) )
3424 int mode = resMgr->integerValue( "OCCViewer", "stereo_type", 0 );
3425 QList<SUIT_ViewManager*> lst;
3426 viewManagers( OCCViewer_Viewer::Type(), lst );
3427 QListIterator<SUIT_ViewManager*> it( lst );
3428 while ( it.hasNext() )
3430 SUIT_ViewModel* vm = it.next()->getViewModel();
3431 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3434 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3435 occVM->setStereoType( mode );
3440 #ifndef DISABLE_OCCVIEWER
3441 if ( sec == QString( "OCCViewer" ) && param == QString( "anaglyph_filter" ) )
3443 int mode = resMgr->integerValue( "OCCViewer", "anaglyph_filter", 0 );
3444 QList<SUIT_ViewManager*> lst;
3445 viewManagers( OCCViewer_Viewer::Type(), lst );
3446 QListIterator<SUIT_ViewManager*> it( lst );
3447 while ( it.hasNext() )
3449 SUIT_ViewModel* vm = it.next()->getViewModel();
3450 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3453 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3454 occVM->setAnaglyphFilter( mode );
3459 #ifndef DISABLE_OCCVIEWER
3460 if ( sec == QString( "OCCViewer" ) && ( param == QString( "focus_type" ) ||
3461 param == QString( "focus_value" ) ) )
3463 int aType = resMgr->integerValue( "OCCViewer", "focus_type" );
3464 double aValue = resMgr->doubleValue( "OCCViewer", "focus_value" );
3465 QList<SUIT_ViewManager*> lst;
3466 viewManagers( OCCViewer_Viewer::Type(), lst );
3467 QListIterator<SUIT_ViewManager*> it( lst );
3468 while ( it.hasNext() )
3470 SUIT_ViewModel* vm = it.next()->getViewModel();
3471 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3474 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3475 occVM->setStereographicFocus( aType, aValue );
3480 #ifndef DISABLE_OCCVIEWER
3481 if ( sec == QString( "OCCViewer" ) && ( param == QString( "iod_type" ) ||
3482 param == QString( "iod_value" ) ) )
3484 int aType = resMgr->integerValue( "OCCViewer", "iod_type" );
3485 double aValue = resMgr->doubleValue( "OCCViewer", "iod_value" );
3486 QList<SUIT_ViewManager*> lst;
3487 viewManagers( OCCViewer_Viewer::Type(), lst );
3488 QListIterator<SUIT_ViewManager*> it( lst );
3489 while ( it.hasNext() )
3491 SUIT_ViewModel* vm = it.next()->getViewModel();
3492 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3495 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3496 occVM->setInterocularDistance( aType, aValue );
3501 #ifndef DISABLE_OCCVIEWER
3502 if ( sec == QString( "OCCViewer" ) && param == QString( "reverse_stereo" ) )
3504 bool reverse = resMgr->booleanValue( "OCCViewer", "reverse_stereo", false );
3505 QList<SUIT_ViewManager*> lst;
3506 viewManagers( OCCViewer_Viewer::Type(), lst );
3507 QListIterator<SUIT_ViewManager*> it( lst );
3508 while ( it.hasNext() )
3510 SUIT_ViewModel* vm = it.next()->getViewModel();
3511 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3514 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3515 occVM->setReverseStereo( reverse );
3520 #ifndef DISABLE_OCCVIEWER
3521 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_vsync" ) )
3523 bool enable = resMgr->booleanValue( "OCCViewer", "enable_vsync", true );
3524 QList<SUIT_ViewManager*> lst;
3525 viewManagers( OCCViewer_Viewer::Type(), lst );
3526 QListIterator<SUIT_ViewManager*> it( lst );
3527 while ( it.hasNext() )
3529 SUIT_ViewModel* vm = it.next()->getViewModel();
3530 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3533 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3534 occVM->setVSync( enable );
3539 #ifndef DISABLE_OCCVIEWER
3540 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_quad_buffer_support" ) )
3542 bool enable = resMgr->booleanValue( "OCCViewer", "enable_quad_buffer_support", false );
3543 QList<SUIT_ViewManager*> lst;
3544 viewManagers( OCCViewer_Viewer::Type(), lst );
3545 QListIterator<SUIT_ViewManager*> it( lst );
3546 while ( it.hasNext() )
3548 SUIT_ViewModel* vm = it.next()->getViewModel();
3549 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3552 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3553 occVM->setQuadBufferSupport( enable );
3558 if ( sec == QString( "3DViewer" ) && param == QString( "zooming_mode" ) )
3560 int mode = resMgr->integerValue( "3DViewer", "zooming_mode", 0 );
3561 QList<SUIT_ViewManager*> lst;
3562 #ifndef DISABLE_OCCVIEWER
3563 viewManagers( OCCViewer_Viewer::Type(), lst );
3564 QListIterator<SUIT_ViewManager*> itOCC( lst );
3565 while ( itOCC.hasNext() )
3567 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3568 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3571 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3572 occVM->setZoomingStyle( mode );
3575 #ifndef DISABLE_VTKVIEWER
3576 #ifndef DISABLE_SALOMEOBJECT
3577 viewManagers( SVTK_Viewer::Type(), lst );
3578 QListIterator<SUIT_ViewManager*> itVTK( lst );
3579 while ( itVTK.hasNext() )
3581 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3582 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3585 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3586 if( vtkVM ) vtkVM->setZoomingStyle( mode );
3592 #ifndef DISABLE_VTKVIEWER
3593 if ( sec == QString( "VTKViewer" ) && (param == QString( "speed_value" ) || param == QString( "speed_mode" )) )
3595 int speed = resMgr->integerValue( "VTKViewer", "speed_value", 10 );
3596 int mode = resMgr->integerValue( "VTKViewer", "speed_mode", 0 );
3597 QList<SUIT_ViewManager*> lst;
3598 #ifndef DISABLE_SALOMEOBJECT
3599 viewManagers( SVTK_Viewer::Type(), lst );
3600 QListIterator<SUIT_ViewManager*> it( lst );
3601 while ( it.hasNext() )
3603 SUIT_ViewModel* vm = it.next()->getViewModel();
3604 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3607 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3608 if( vtkVM ) vtkVM->setIncrementalSpeed( speed, mode );
3614 #ifndef DISABLE_VTKVIEWER
3615 if ( sec == QString( "VTKViewer" ) && param == QString( "projection_mode" ) )
3617 int mode = resMgr->integerValue( "VTKViewer", "projection_mode", 0 );
3618 QList<SUIT_ViewManager*> lst;
3619 #ifndef DISABLE_SALOMEOBJECT
3620 viewManagers( SVTK_Viewer::Type(), lst );
3621 QListIterator<SUIT_ViewManager*> it( lst );
3622 while ( it.hasNext() )
3624 SUIT_ViewModel* vm = it.next()->getViewModel();
3625 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3628 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3629 if( vtkVM ) vtkVM->setProjectionMode( mode );
3635 #ifndef DISABLE_VTKVIEWER
3636 if ( sec == QString( "VTKViewer" ) && param == QString( "stereo_type" ) )
3638 int mode = resMgr->integerValue( "VTKViewer", "stereo_type", 0 );
3639 QList<SUIT_ViewManager*> lst;
3640 #ifndef DISABLE_SALOMEOBJECT
3641 viewManagers( SVTK_Viewer::Type(), lst );
3642 QListIterator<SUIT_ViewManager*> it( lst );
3643 while ( it.hasNext() )
3645 SUIT_ViewModel* vm = it.next()->getViewModel();
3646 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3649 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3650 if( vtkVM ) vtkVM->setStereoType( mode );
3656 #ifndef DISABLE_VTKVIEWER
3657 if ( sec == QString( "VTKViewer" ) && param == QString( "anaglyph_filter" ) )
3659 int mode = resMgr->integerValue( "VTKViewer", "anaglyph_filter", 0 );
3660 QList<SUIT_ViewManager*> lst;
3661 #ifndef DISABLE_SALOMEOBJECT
3662 viewManagers( SVTK_Viewer::Type(), lst );
3663 QListIterator<SUIT_ViewManager*> it( lst );
3664 while ( it.hasNext() )
3666 SUIT_ViewModel* vm = it.next()->getViewModel();
3667 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3670 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3671 if( vtkVM ) vtkVM->setAnaglyphFilter( mode );
3677 #ifndef DISABLE_VTKVIEWER
3678 if ( sec == QString( "VTKViewer" ) && param == QString( "enable_quad_buffer_support" ) )
3680 int enable = resMgr->booleanValue( "VTKViewer", "enable_quad_buffer_support", false );
3681 QList<SUIT_ViewManager*> lst;
3682 #ifndef DISABLE_SALOMEOBJECT
3683 viewManagers( SVTK_Viewer::Type(), lst );
3684 QListIterator<SUIT_ViewManager*> it( lst );
3685 while ( it.hasNext() )
3687 SUIT_ViewModel* vm = it.next()->getViewModel();
3688 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3691 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3692 if( vtkVM ) vtkVM->setQuadBufferSupport( enable );
3698 #ifndef DISABLE_VTKVIEWER
3699 if ( sec == QString( "VTKViewer" ) && param == QString( "preselection" ) )
3701 int mode = resMgr->integerValue( "VTKViewer", "preselection", 0 );
3702 QList<SUIT_ViewManager*> lst;
3703 #ifndef DISABLE_SALOMEOBJECT
3704 viewManagers( SVTK_Viewer::Type(), lst );
3705 QListIterator<SUIT_ViewManager*> it( lst );
3706 while ( it.hasNext() )
3708 SUIT_ViewModel* vm = it.next()->getViewModel();
3709 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3712 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3713 if( vtkVM ) vtkVM->setPreSelectionMode( mode );
3719 #ifndef DISABLE_VTKVIEWER
3720 if ( sec == QString( "VTKViewer" ) && param == QString( "enable_selection" ) )
3722 bool isToEnableSelection = resMgr->booleanValue( "VTKViewer", "enable_selection", true );
3723 QList<SUIT_ViewManager*> lst;
3724 #ifndef DISABLE_SALOMEOBJECT
3725 viewManagers( SVTK_Viewer::Type(), lst );
3726 QListIterator<SUIT_ViewManager*> it( lst );
3727 while ( it.hasNext() )
3729 SUIT_ViewModel* vm = it.next()->getViewModel();
3730 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3733 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3734 if( vtkVM ) vtkVM->enableSelection( isToEnableSelection );
3740 #ifndef DISABLE_VTKVIEWER
3741 if ( sec == QString( "VTKViewer" ) && (param == QString( "spacemouse_func1_btn" ) ||
3742 param == QString( "spacemouse_func2_btn" ) ||
3743 param == QString( "spacemouse_func5_btn" ) ) )
3745 int btn1 = resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", 1 );
3746 int btn2 = resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", 2 );
3747 int btn3 = resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", 9 );
3748 QList<SUIT_ViewManager*> lst;
3749 #ifndef DISABLE_SALOMEOBJECT
3750 viewManagers( SVTK_Viewer::Type(), lst );
3751 QListIterator<SUIT_ViewManager*> it( lst );
3752 while ( it.hasNext() )
3754 SUIT_ViewModel* vm = it.next()->getViewModel();
3755 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3758 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3759 if( vtkVM ) vtkVM->setSpacemouseButtons( btn1, btn2, btn3 );
3764 if( sec=="ObjectBrowser" )
3766 SUIT_DataBrowser* ob = objectBrowser();
3770 if ( param=="auto_size_first" )
3772 bool autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
3773 ob->setAutoSizeFirstColumn( autoSizeFirst );
3774 if ( autoSizeFirst )
3775 ob->adjustFirstColumnWidth();
3777 else if ( param=="auto_size" ) {
3778 bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
3779 ob->setAutoSizeColumns(autoSize);
3781 ob->adjustColumnsWidth();
3783 else if ( param=="resize_on_expand_item" ) {
3784 bool resizeOnExpandItem = resMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
3785 ob->setResizeOnExpandItem(resizeOnExpandItem);
3787 else if ( param == "auto_hide_search_tool" ) {
3788 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
3794 if( param=="auto_save_interval" ) {
3795 myAutoSaveTimer->stop();
3796 int autoSaveInterval = resMgr->integerValue( "Study", "auto_save_interval", 0 );
3797 if ( activeStudy() && autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
3801 #ifndef DISABLE_PYCONSOLE
3802 if( sec=="PyConsole" && pythonConsole() )
3804 if ( param=="font" ) {
3805 pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) );
3807 else if ( param=="show_banner" ) {
3808 pythonConsole()->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
3810 else if ( param=="auto_completion" ) {
3811 pythonConsole()->setAutoCompletion( resMgr->booleanValue( "PyConsole", "auto_completion", true ) );
3818 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3820 if ( param == "visible_count" )
3821 mru->setVisibleCount( resMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
3822 else if ( param == "max_count" )
3823 mru->setHistoryCount( resMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
3824 else if ( param == "insert_mode" )
3825 mru->setInsertMode( resMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
3826 else if ( param == "link_type" )
3827 mru->setLinkType( resMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
3828 else if ( param == "show_clear" )
3829 mru->setClearPossible( resMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
3830 else if ( param == "show_mru" )
3831 mru->setVisible( resMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
3834 if ( sec == "language" && param == "language" )
3836 // VSR 18.06.2015 : commented out : single warning dialog box is now shown by the LightApp_PreferencesDlg
3837 //SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LANG_CHANGED" ) );
3839 if ( sec == "language" && param == "locale")
3841 // VSR 18.06.2015: commented out : single warning dialog box is now shown by the LightApp_PreferencesDlg
3842 //SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LOCALE_CHANGED" ) );
3844 if ( sec == "desktop" && param == "opaque_resize" ) {
3845 bool opaqueResize = resMgr->booleanValue( "desktop", "opaque_resize", false );
3846 // RNV: This code has been commented, because clearing of the QMainWindow::AnimatedDocks option
3847 // leads to strange behaviour of the dockable windows (at least at qt-5.6.1):
3848 // any dockable window can't be docked to the another area, except initial area.
3849 // It is possible to move window to another area, but it always returns to the initial area.
3851 // QMainWindow::DockOptions dopts = desktop()->dockOptions();
3852 // if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
3853 // else dopts &= ~QMainWindow::AnimatedDocks;
3854 // desktop()->setDockOptions( dopts );
3855 desktop()->setOpaqueResize( opaqueResize );
3856 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
3857 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
3860 #ifndef DISABLE_PLOT2DVIEWER
3861 QList<SUIT_ViewManager*> lst;
3862 viewManagers( Plot2d_Viewer::Type(), lst );
3863 QListIterator<SUIT_ViewManager*> itPlot2d( lst );
3864 while ( itPlot2d.hasNext() ) {
3865 SUIT_ViewManager* viewMgr = itPlot2d.next();
3866 SUIT_ViewModel* vm = viewMgr->getViewModel();
3867 if ( !vm || !vm->inherits( "Plot2d_Viewer" ) )
3870 //Plot2d_Viewer* Plot2dVM = dynamic_cast<Plot2d_Viewer*>( vm );
3872 viewMgr->setViewModel( vm );
3873 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
3875 Plot2d_ViewFrame* frame = wnd->getViewFrame();
3876 frame->SetPreference();
3885 void LightApp_Application::loadPreferences()
3887 CAM_Application::loadPreferences();
3889 SUIT_ResourceMgr* aResMgr = resourceMgr();
3894 static bool mru_load = true;
3897 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3899 mru->setVisible( aResMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
3900 mru->setVisibleCount( aResMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
3901 mru->setHistoryCount( aResMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
3902 mru->setInsertMode( aResMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
3903 mru->setLinkType( aResMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
3904 mru->setClearPossible( aResMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
3905 mru->loadLinks( aResMgr, "MRU" );
3911 QStringList mods = aResMgr->parameters( "windows_visibility" );
3912 for ( QStringList::const_iterator itr = mods.begin(); itr != mods.end(); ++itr )
3915 if ( aResMgr->value( "windows_visibility", *itr, arr ) )
3916 myWinVis.insert( *itr, arr );
3920 desktop()->retrieveGeometry( aResMgr->stringValue( "desktop", "geometry" ) );
3921 bool opaqueResize = aResMgr->booleanValue( "desktop", "opaque_resize", false );
3922 // QMainWindow::DockOptions dopts = desktop()->dockOptions();
3923 // if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
3924 // else dopts &= ~QMainWindow::AnimatedDocks;
3925 // desktop()->setDockOptions( dopts );
3926 desktop()->setOpaqueResize( opaqueResize );
3927 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
3928 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
3935 void LightApp_Application::savePreferences()
3937 CAM_Application::savePreferences();
3939 saveDockWindowsState();
3941 SUIT_ResourceMgr* aResMgr = resourceMgr();
3946 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3948 mru->saveLinks( aResMgr, "MRU" );
3950 for ( WinVis::const_iterator itr = myWinVis.begin(); itr != myWinVis.end(); ++itr )
3951 aResMgr->setValue( "windows_visibility", itr.key(), itr.value() );
3954 aResMgr->setValue( "desktop", "geometry", desktop()->storeGeometry() );
3956 #if GUI_DEVELOPMENT > 0
3957 aResMgr->setValue( "salome", "version", QString(GUI_VERSION_STR)+"dev" );
3959 aResMgr->setValue( "salome", "version", QString(GUI_VERSION_STR) );
3966 Updates desktop title
3968 void LightApp_Application::updateDesktopTitle()
3970 QString aTitle = applicationName();
3971 QString aVer = applicationVersion();
3972 if ( !aVer.isEmpty() )
3973 aTitle += QString( " " ) + aVer;
3975 if ( activeStudy() ) {
3976 QString sName = SUIT_Tools::file( activeStudy()->studyName().trimmed(), false );
3977 aTitle += QString( " - [%1]" ).arg( sName );
3980 desktop()->setWindowTitle( aTitle );
3984 \brief Get map of the operations which can be performed
3985 on the module activation.
3987 The method should return the map of the kind \c {<id>:<name>}
3988 where \c <id> is an integer identifier of the operation and
3989 \c <name> is a title for the button to be added to the
3990 dialog box. After user selects the required operation by the
3991 clicking the corresponding button in the dialog box, its identifier
3992 is passed to the moduleActionSelected() method to process
3995 \return map of the operations
3996 \sa moduleActionSelected()
3998 QMap<int, QString> LightApp_Application::activateModuleActions() const
4000 QMap<int, QString> opmap;
4001 opmap.insert( NewStudyId, tr( "ACTIVATE_MODULE_OP_NEW" ) );
4002 opmap.insert( OpenStudyId, tr( "ACTIVATE_MODULE_OP_OPEN" ) );
4007 \brief Called when the used selectes required operation chosen
4008 from "Activate module" dialog box.
4010 Performs the required operation according to the user choice.
4012 \param id operation identifier
4013 \sa activateModuleActions()
4015 void LightApp_Application::moduleActionSelected( const int id )
4030 Updates windows after close document
4032 void LightApp_Application::afterCloseDoc()
4036 CAM_Application::afterCloseDoc();
4040 Updates actions of active module
4042 void LightApp_Application::updateModuleActions()
4045 if ( activeModule() )
4046 modName = activeModule()->moduleName();
4048 LightApp_ModuleAction* moduleAction =
4049 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
4051 moduleAction->setActiveModule( modName );
4054 void LightApp_Application::removeModuleAction( const QString& modName )
4056 LightApp_ModuleAction* moduleAction =
4057 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
4059 moduleAction->removeModule( modName );
4062 bool LightApp_Application::checkModule( const QString& title )
4064 if ( title.isEmpty() )
4067 QString library = moduleLibrary( title, true );
4068 if ( library.isEmpty() )
4071 QString name = moduleName( title );
4073 bool isPyModule = library.contains( "SalomePyQtGUI" ) || library.contains( "SalomePyQtGUILight" );
4077 paths = QString( Qtx::getenv( "PATH" ) ).split( ";", QString::SkipEmptyParts );
4078 #elif defined(__APPLE__)
4079 paths = QString( Qtx::getenv( "DYLD_LIBRARY_PATH" ) ).split( ":", QString::SkipEmptyParts );
4081 paths = QString( Qtx::getenv( "LD_LIBRARY_PATH" ) ).split( ":", QString::SkipEmptyParts );
4084 bool isFound = false;
4085 QStringList::const_iterator it;
4086 for ( it = paths.begin(); it != paths.end() && !isFound; ++it )
4088 isFound = QFileInfo( Qtx::addSlash( *it ) + library ).exists();
4094 "****************************************************************" << std::endl <<
4095 " Warning: library " << qPrintable( library ) << " is not found!" << std::endl <<
4096 " Module " << qPrintable( title ) << " will not be available in GUI mode!" << std::endl <<
4097 "****************************************************************" << std::endl);
4103 QString pyModule = QString( "%1GUI.py" ).arg( name );
4105 paths = QString( Qtx::getenv( "PYTHONPATH" ) ).split( ";", QString::SkipEmptyParts );
4107 paths = QString( Qtx::getenv( "PYTHONPATH" ) ).split( ":", QString::SkipEmptyParts );
4110 for ( it = paths.begin(); it != paths.end() && !isFound; ++it )
4112 isFound = QFileInfo( Qtx::addSlash( *it ) + pyModule ).exists();
4118 "****************************************************************" << std::endl <<
4119 " Warning: Python module " << qPrintable( pyModule ) << " is not found!" << std::endl <<
4120 " Module " << qPrintable( title ) << " will not be available in GUI mode!" << std::endl <<
4121 "****************************************************************" << std::endl);
4130 Gets current windows.
4131 \param winMap - output current windows map.
4133 void LightApp_Application::currentWindows( QMap<int, int>& winMap ) const
4136 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
4137 ((LightApp_Module*)activeModule())->windows( winMap );
4139 defaultWindows( winMap );
4143 Gets current view managers.
4144 \param lst - output current view managers list.
4146 void LightApp_Application::currentViewManagers( QStringList& lst ) const
4149 if ( !activeStudy() )
4152 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
4153 ((LightApp_Module*)activeModule())->viewManagers( lst );
4155 defaultViewManagers( lst );
4161 void LightApp_Application::updateWindows()
4163 QMap<int, int> winMap;
4164 currentWindows( winMap );
4166 for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
4168 if ( !dockWindow( it.key() ) )
4169 getWindow( it.key() );
4172 for ( WinMap::ConstIterator it = myWin.begin(); it != myWin.end(); ++it )
4174 QWidget* wid = it.value();
4177 if ( winMap.contains( it.key() ) )
4178 wid->setVisible( true );
4179 else if ( !activeStudy() )
4182 wid->setVisible( false );
4185 loadDockWindowsState();
4187 if ( !activeModule() && infoPanel() )
4189 infoPanel()->clear();
4190 infoPanel()->setTitle( tr( "INFO_WELCOME_TO_SALOME" ) );
4192 int grp = infoPanel()->addGroup( tr( "INFO_GETTING_STARTED" ) );
4193 infoPanel()->addAction( action( FileNewId ), grp );
4194 infoPanel()->addLabel( action( FileNewId )->statusTip(), grp );
4195 infoPanel()->addAction( action( FileOpenId ), grp );
4196 infoPanel()->addLabel( action( FileOpenId )->statusTip(), grp );
4197 if ( HAS_TUTORIAL_URL ) {
4198 infoPanel()->addAction( action( TutorialsId ), grp );
4199 infoPanel()->addLabel( action( TutorialsId )->statusTip(), grp );
4201 infoPanel()->addAction( action( VideosId ), grp );
4202 infoPanel()->addLabel( action( VideosId )->statusTip(), grp );
4204 LightApp_ModuleAction* ma = qobject_cast<LightApp_ModuleAction*>(action(ModulesListId));
4205 if ( ma && ma->count() > 0 )
4207 grp = infoPanel()->addGroup( tr( "INFO_AVAILABLE_MODULES" ) );
4208 foreach ( QString mname, ma->modules() )
4210 infoPanel()->addAction( ma->moduleAction( mname ), grp );
4211 if ( !moduleDescription( mname ).isEmpty() )
4212 infoPanel()->addLabel( moduleDescription( mname ), grp );
4219 Updates view managers
4221 void LightApp_Application::updateViewManagers()
4224 currentViewManagers( lst );
4226 for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
4227 getViewManager( *it, true );
4231 Loads windows geometry
4233 void LightApp_Application::loadDockWindowsState()
4237 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
4238 bool storeWin = aResMgr->booleanValue( "Study", "store_positions", true );
4239 bool storeTb = aResMgr->booleanValue( "Study", "store_tool_positions", true );
4242 if ( activeModule() )
4243 modName = activeModule()->name();
4244 else if ( activeStudy() )
4245 modName = "nomodule";
4247 QtxResourceMgr::WorkingMode prevMode = aResMgr->setWorkingMode( QtxResourceMgr::IgnoreUserValues );
4248 QByteArray aDefaultState;
4249 aResMgr->value( "windows_geometry", modName, aDefaultState );
4250 QByteArray aDefaultVisibility;
4251 aResMgr->value( "windows_visibility", modName, aDefaultVisibility );
4252 bool hasDefaultVisibility = !aDefaultVisibility.isEmpty();
4253 aResMgr->setWorkingMode( prevMode );
4255 if( !storeWin && !storeTb && aDefaultState.isEmpty() && !hasDefaultVisibility)
4258 if ( aResMgr->hasValue("windows_geometry" ,modName ) ) {
4259 long version = Qtx::versionToId( aResMgr->stringValue( "windows_geometry_version", modName, "" ) );
4261 if ( version > Qtx::versionToId( "7.4.1" ) )
4262 aResMgr->value( "windows_geometry", modName , arr );
4264 arr = aDefaultState;
4265 QByteArray aTargetArray = processState(arr, storeWin, storeTb, true, aDefaultState);
4266 desktop()->restoreState( aTargetArray );
4269 QStringList mainToolbarsNames;
4270 mainToolbarsNames << "SalomeStandard" << "SalomeModules";
4271 QList<QToolBar*> mainToolbars = findToolBars( mainToolbarsNames );
4272 foreach( QToolBar* tb, mainToolbars ) tb->setVisible( true );
4274 if ( !myWinVis.contains( modName ) && aDefaultVisibility.isEmpty())
4277 QMap<QString, bool> *tbMap = 0;
4278 QMap<QString, bool> *dwMap = 0;
4280 QMap<QString, bool> userTbMap, userDwMap;
4281 dockWindowsState( myWinVis[modName], userTbMap, userDwMap );
4283 QMap<QString, bool> defaultTbMap, defaultDwMap;
4284 if(hasDefaultVisibility) {
4285 dockWindowsState( aDefaultVisibility, defaultTbMap, defaultDwMap);
4291 if(hasDefaultVisibility){
4292 tbMap = &defaultTbMap;
4299 if(hasDefaultVisibility){
4300 dwMap = &defaultDwMap;
4305 QList<QToolBar*> tbList = findToolBars();
4306 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit )
4308 QToolBar* tb = *tit;
4309 if ( tbMap->contains( tb->objectName() ) ) {
4310 tb->setVisible( (*tbMap)[tb->objectName()] );
4316 QList<QDockWidget*> dwList = desktop()->findChildren<QDockWidget*>();
4317 for ( QList<QDockWidget*>::iterator dit = dwList.begin(); dit != dwList.end(); ++dit )
4319 QDockWidget* dw = *dit;
4321 QObject* po = Qtx::findParent( dw, "QMainWindow" );
4322 if ( po != desktop() )
4325 if ( dwMap->contains( dw->objectName() ) )
4326 dw->setVisible( (*dwMap)[dw->objectName()] );
4334 Saves windows geometry
4336 void LightApp_Application::saveDockWindowsState()
4341 bool storeWin = resourceMgr()->booleanValue( "Study", "store_positions", true );
4342 bool storeTb = resourceMgr()->booleanValue( "Study", "store_tool_positions", true );
4344 if( !storeWin && !storeTb )
4348 if ( activeModule() )
4349 modName = activeModule()->name();
4350 else if ( activeStudy() )
4351 modName = "nomodule";
4353 QString versionId = GUI_VERSION_STR;
4354 #if GUI_DEVELOPMENT > 0
4358 QByteArray arr = desktop()->saveState();
4359 resourceMgr()->setValue( "windows_geometry", modName, processState(arr, storeWin, storeTb, false) );
4360 resourceMgr()->setValue( "windows_geometry_version", modName, versionId );
4363 if ( myWinVis.contains( modName ) )
4364 visArr = myWinVis[modName];
4366 QMap<QString, bool> tbMap, dwMap;
4367 dockWindowsState( visArr, tbMap, dwMap );
4369 QList<QToolBar*> tbList = desktop()->findChildren<QToolBar*>();
4370 for ( QList<QToolBar*>::iterator it = tbList.begin(); it != tbList.end(); ++it )
4373 tbMap.insert( tb->objectName(), tb->toggleViewAction()->isChecked() );
4376 QList<QDockWidget*> dwList = desktop()->findChildren<QDockWidget*>();
4377 for ( QList<QDockWidget*>::iterator it = dwList.begin(); it != dwList.end(); ++it )
4379 QDockWidget* wid = *it;
4380 dwMap.insert( wid->objectName(), wid->toggleViewAction()->isChecked() );
4383 visArr = dockWindowsState( tbMap, dwMap );
4385 myWinVis.insert( modName, visArr );
4388 QByteArray LightApp_Application::dockWindowsState( const QMap<QString, bool>& tb, const QMap<QString, bool>& dw ) const
4391 QDataStream stream( &visArr, QIODevice::WriteOnly );
4393 stream << (uchar)ToolBarMarker;
4394 stream << tb.size();
4395 for ( QMap<QString, bool>::const_iterator tit = tb.begin(); tit != tb.end(); ++tit )
4397 stream << tit.key();
4398 stream << (uchar)( tit.value() ? 1 : 0 );
4401 stream << (uchar)DockWidgetMarker;
4402 stream << dw.size();
4403 for ( QMap<QString, bool>::const_iterator wit = dw.begin(); wit != dw.end(); ++wit )
4405 stream << wit.key();
4406 stream << (uchar)( wit.value() ? 1 : 0 );
4412 void LightApp_Application::dockWindowsState( const QByteArray& arr, QMap<QString, bool>& tb, QMap<QString, bool>& dw ) const
4417 QByteArray visArr = arr;
4418 QDataStream stream( &visArr, QIODevice::ReadOnly );
4422 if ( marker != ToolBarMarker )
4427 for ( int i = 0; i < lines; ++i )
4430 stream >> objectName;
4433 tb.insert( objectName, shown );
4437 if ( marker != DockWidgetMarker )
4441 for ( int j = 0; j < lines; ++j )
4444 stream >> objectName;
4447 dw.insert( objectName, shown );
4452 Adds icon names for modules
4454 void LightApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) const
4458 SUIT_ResourceMgr* resMgr = resourceMgr();
4462 QStringList modList;
4463 modules( modList, false );
4465 for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )
4467 QString modName = *it;
4468 QString modIntr = moduleName( modName );
4469 QString modIcon = resMgr->stringValue( modIntr, "icon", QString() );
4471 if ( modIcon.isEmpty() )
4474 if ( SUIT_Tools::extension( modIcon ).isEmpty() )
4475 modIcon += QString( ".png" );
4477 iconMap.insert( modName, modIcon );
4482 Inserts items in popup, which necessary for current application
4484 void LightApp_Application::contextMenuPopup( const QString& type, QMenu* thePopup, QString& title )
4487 LightApp_SelectionMgr* selMgr = LightApp_Application::selectionMgr();
4488 bool cacheIsOn = selMgr->isSelectionCacheEnabled();
4489 selMgr->setSelectionCacheEnabled( true );
4491 SUIT_DataBrowser* ob = objectBrowser();
4493 CAM_Application::contextMenuPopup( type, thePopup, title );
4495 if ( ob && type == ob->popupClientType() ) {
4496 thePopup->addSeparator();
4497 QAction* a = thePopup->addAction( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
4498 if ( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) )
4499 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) );
4502 #ifndef DISABLE_SALOMEOBJECT
4503 if ( selMgr && ob ) {
4504 SALOME_ListIO selected;
4505 selMgr->selectedObjects( selected );
4506 if(selected.Extent() == 1){
4507 Handle(SALOME_InteractiveObject) anIObject = selected.First();
4508 SUIT_DataObject* obj = findObject(anIObject->getEntry());
4509 if(obj && obj->renameAllowed()) {
4510 QAction* a = new QAction(tr("MEN_RENAME_OBJ"), thePopup);
4511 connect( a, SIGNAL( triggered(bool) ), ob, SLOT( onStartEditing() ) );
4512 if ( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) )
4513 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) );
4515 QList<QAction*> acts = thePopup->actions();
4516 QAction* firstAction = acts.count() > 0 ? acts.first() : 0;
4517 thePopup->insertAction(firstAction,a);
4523 selMgr->setSelectionCacheEnabled( cacheIsOn );
4529 void LightApp_Application::createEmptyStudy()
4531 CAM_Application::createEmptyStudy();
4533 if ( objectBrowser() )
4534 objectBrowser()->updateTree();
4536 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
4537 if ( aResMgr && activeStudy() ) {
4538 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
4539 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
4544 void LightApp_Application::setDesktop( SUIT_Desktop* desk )
4546 CAM_Application::setDesktop( desk );
4549 connect( desk, SIGNAL( message( const QString& ) ),
4550 this, SLOT( onDesktopMessage( const QString& ) ), Qt::UniqueConnection );
4551 connect( desk, SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
4552 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
4553 /* connect( desk, SIGNAL( windowMoved( SUIT_ViewWindow* ) ),
4554 this, SLOT( onWindowMoved( SUIT_ViewWindow* ) ), Qt::UniqueConnection ); */
4560 \param mod - module to be activated
4562 bool LightApp_Application::activateModule( CAM_Module* mod )
4564 bool res = CAM_Application::activateModule( mod );
4566 if ( objectBrowser() )
4567 objectBrowser()->updateTree();
4573 \return keyborad accelerators manager object
4575 SUIT_Accel* LightApp_Application::accel() const
4581 Removes dead widget container from map
4583 void LightApp_Application::onWCDestroyed( QObject* ob )
4585 // remove destroyed widget container from windows map
4586 for ( WinMap::ConstIterator itr = myWin.begin(); itr != myWin.end(); ++itr )
4588 if ( itr.value() != ob )
4591 int key = itr.key();
4592 myWin.remove( key );
4597 void LightApp_Application::onMRUActivated( const QString& name )
4599 SUIT_Session* s = SUIT_Session::session();
4600 if ( s && s->activeApplication() == this )
4604 void LightApp_Application::onStylePreferences()
4606 #ifdef USE_SALOME_STYLE
4607 Style_PrefDlg dlg( desktop() );
4610 resourceMgr()->setValue( "Style", "use_salome_style", Style_Salome::isActive() );
4611 #endif // USE_SALOME_STYLE
4614 void LightApp_Application::onFullScreen(){
4615 if(myScreenHelper) {
4616 if(desktop()->isFullScreen())
4617 myScreenHelper->switchToNormalScreen();
4619 myScreenHelper->switchToFullScreen();
4624 Connects just added view manager
4626 void LightApp_Application::addViewManager( SUIT_ViewManager* vm )
4628 connect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
4629 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
4630 CAM_Application::addViewManager( vm );
4634 Remove view manager from memory
4636 void LightApp_Application::removeViewManager( SUIT_ViewManager* vm )
4638 disconnect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
4639 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
4640 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
4642 aStudy->removeObjectProperties( vm->getGlobalId() );
4644 CAM_Application::removeViewManager( vm );
4646 LightApp_SelectionMgr* selMgr = selectionMgr();
4647 QList<SUIT_Selector*> selectors;
4648 selMgr->selectors( selectors );
4649 foreach( SUIT_Selector* selector, selectors ) {
4650 if ( selector->owner() == vm->getViewModel() ) {
4655 // IPAL22894: Crash on closing OCC view
4661 Renames active window of desktop
4663 void LightApp_Application::onRenameWindow()
4668 QWidget* w = desktop()->activeWindow();
4673 QString name = QInputDialog::getText( w, tr( "TOT_RENAME" ), tr( "PRP_RENAME" ), QLineEdit::Normal, w->windowTitle(), &ok );
4674 if( ok && !name.isEmpty() )
4675 w->setWindowTitle( name );
4679 Closes active window of desktop
4681 void LightApp_Application::onCloseWindow()
4686 QWidget* w = desktop()->activeWindow();
4694 Closes all windows of desktop
4696 void LightApp_Application::onCloseAllWindow()
4698 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
4702 QList<SUIT_ViewWindow*> wndList = desk->windows();
4703 SUIT_ViewWindow* wnd;
4704 foreach( wnd, wndList )
4712 Groups all windows of desktop
4714 void LightApp_Application::onGroupAllWindow()
4716 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
4720 QtxWorkstack* wgStack = desk->workstack();
4726 \return default name for an active study
4728 void LightApp_Application::setDefaultStudyName( const QString& theName )
4730 QStringList anInfoList;
4731 modules( anInfoList, false );
4733 LightApp_Study* aStudy = (LightApp_Study*)activeStudy();
4734 if( anInfoList.count() == 1 && // to avoid a conflict between different modules
4735 !aStudy->isSaved() )
4737 aStudy->setStudyName( theName );
4738 updateDesktopTitle();
4743 Custom event handler
4745 bool LightApp_Application::event( QEvent* e )
4747 if( e && e->type()==2000 )
4749 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
4750 QString* d = ( QString* )ce->data();
4751 if( SUIT_MessageBox::question(0, tr("WRN_WARNING"),
4753 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
4754 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
4757 path << tr( "PREF_CATEGORY_SALOME" ) << tr( "PREF_TAB_GENERAL" )
4758 << tr( "PREF_GROUP_EXT_BROWSER" ) << tr( "PREF_APP" );
4759 showPreferences( path );
4765 return CAM_Application::event( e );
4768 /*! Check data object */
4769 bool LightApp_Application::checkDataObject(LightApp_DataObject* theObj)
4773 bool isSuitable = !theObj->entry().isEmpty() &&
4774 !theObj->componentDataType().isEmpty() &&
4775 !theObj->name().isEmpty();
4782 int LightApp_Application::openChoice( const QString& aName )
4784 int choice = CAM_Application::openChoice( aName );
4786 if ( choice == OpenExist ) // The document is already open.
4788 // Do you want to reload it?
4789 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "QUE_DOC_ALREADYOPEN" ).arg( aName ),
4790 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No ) == SUIT_MessageBox::Yes )
4791 choice = OpenReload;
4797 bool LightApp_Application::openAction( const int choice, const QString& aName )
4804 STD_Application* app = 0;
4805 SUIT_Session* session = SUIT_Session::session();
4806 QList<SUIT_Application*> appList = session->applications();
4807 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !app; ++it )
4809 if ( (*it)->activeStudy() && (*it)->activeStudy()->studyName() == aName )
4810 app = ::qobject_cast<STD_Application*>( *it );
4815 app->onCloseDoc( false );
4816 appList = session->applications();
4817 STD_Application* other = 0;
4818 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !other; ++it )
4819 other = ::qobject_cast<STD_Application*>( *it );
4822 res = other->onOpenDoc( aName );
4827 res = CAM_Application::openAction( choice, aName );
4834 QStringList LightApp_Application::viewManagersTypes() const
4836 QStringList aTypesList;
4837 aTypesList += myUserWmTypes;
4838 #ifndef DISABLE_GLVIEWER
4839 aTypesList<<GLViewer_Viewer::Type();
4841 #ifndef DISABLE_PLOT2DVIEWER
4842 aTypesList<<Plot2d_Viewer::Type();
4844 #ifndef DISABLE_QXGRAPHVIEWER
4845 aTypesList<<QxScene_Viewer::Type();
4847 #ifndef DISABLE_PVVIEWER
4848 aTypesList<<PVViewer_Viewer::Type();
4850 #ifndef DISABLE_PYVIEWER
4851 aTypesList<<PyViewer_Viewer::Type();
4853 #ifndef DISABLE_OCCVIEWER
4854 aTypesList<<OCCViewer_Viewer::Type();
4856 #ifndef DISABLE_VTKVIEWER
4857 #ifndef DISABLE_SALOMEOBJECT
4858 aTypesList<<SVTK_Viewer::Type();
4860 aTypesList<<VTKViewer_Viewer::Type();
4866 * Removes all view managers of known types
4867 * Other view managers are ignored
4869 void LightApp_Application::clearKnownViewManagers()
4871 QStringList aTypesList = viewManagersTypes();
4872 QList<SUIT_ViewManager*> aMgrList;
4873 viewManagers( aMgrList );
4874 foreach (SUIT_ViewManager* aMgr, aMgrList) {
4875 if (aTypesList.contains(aMgr->getType()))
4876 removeViewManager(aMgr);
4881 Copy of current selection
4883 void LightApp_Application::onCopy()
4885 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
4891 Paste of current data in clipboard
4893 void LightApp_Application::onPaste()
4895 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
4901 Browse (i.e. set focus on) the published objects
4902 \param theIsApplyAndClose - flag indicating that the dialog for creating objects
4903 has been accepted by Ok (or Apply & Close) button
4904 \param theIsOptimizedBrowsing - flag switching to optimized browsing mode
4905 (to select the first published object only)
4906 \return entry of the selected object
4908 QString LightApp_Application::browseObjects( const QStringList& theEntryList,
4909 const bool theIsApplyAndClose,
4910 const bool theIsOptimizedBrowsing )
4913 if( SUIT_ResourceMgr* aResourceMgr = resourceMgr() )
4915 int aBrowsePolicy = aResourceMgr->integerValue( "ObjectBrowser", "browse_published_object", (int)BP_Never );
4916 switch( aBrowsePolicy )
4920 case BP_ApplyAndClose:
4921 if( !theIsApplyAndClose )
4929 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
4933 SUIT_DataBrowser* anOB = objectBrowser();
4937 SUIT_AbstractModel* aModel = dynamic_cast<SUIT_AbstractModel*>( anOB->model() );
4941 QStringListIterator anIter( theEntryList );
4942 if( theIsOptimizedBrowsing )
4944 // go to the last entry
4946 if( anIter.hasPrevious() )
4950 // scroll to each entry in the list
4951 // (in optimized mode - to the last entry only)
4953 LightApp_DataObject* anObject = 0;
4954 while( anIter.hasNext() )
4956 anEntry = anIter.next();
4957 if( !anEntry.isEmpty() )
4959 anObject = aStudy->findObjectByEntry( anEntry );
4962 QModelIndex anIndex = aModel->index( anObject );
4963 anOB->treeView()->scrollTo( anIndex );
4968 // always select the last object
4969 if( anObject && !anEntry.isEmpty() )
4971 QList<SUIT_Selector*> aSelectorList;
4972 selectionMgr()->selectors( "ObjectBrowser", aSelectorList );
4973 if( !aSelectorList.isEmpty() )
4975 if( LightApp_OBSelector* aSelector = dynamic_cast<LightApp_OBSelector*>( aSelectorList.first() ) )
4977 bool anIsAutoBlock = aSelector->autoBlock();
4979 // temporarily disable auto block, to emit LightApp_SelectionMgr::currentSelectionChanged() signal
4980 aSelector->setAutoBlock( false );
4982 SUIT_DataOwnerPtrList aList;
4983 #ifndef DISABLE_SALOMEOBJECT
4984 Handle(SALOME_InteractiveObject) aSObj = new SALOME_InteractiveObject
4985 ( anObject->entry().toUtf8().constData(),
4986 anObject->componentDataType().toLatin1().constData(),
4987 anObject->name().toUtf8().constData() );
4988 LightApp_DataOwner* owner = new LightApp_DataOwner( aSObj );
4990 LightApp_DataOwner* owner = new LightApp_DataOwner( anEntry );
4993 aList.append( owner );
4994 selectionMgr()->setSelected( aList );
4997 // restore auto block flag
4998 aSelector->setAutoBlock( anIsAutoBlock );
5006 SUIT_DataObject* LightApp_Application::findObject( const QString& id ) const
5008 LightApp_Study* study = dynamic_cast<LightApp_Study*>( activeStudy() );
5009 return study ? study->findObjectByEntry( id ) : 0;
5013 Checks that an object can be renamed.
5014 \param entry entry of the object
5015 \brief Return \c true if object can be renamed
5017 bool LightApp_Application::renameAllowed( const QString& /*entry*/) const {
5022 Rename object by entry.
5023 \param entry entry of the object
5024 \param name new name of the object
5025 \brief Return \c true if rename operation finished successfully, \c false otherwise.
5027 bool LightApp_Application::renameObject( const QString& /*entry*/, const QString& /*name*/ ) {
5031 /*! Process standard messages from desktop */
5032 void LightApp_Application::onDesktopMessage( const QString& message )
5034 const QString sectionSeparator = "/";
5036 if ( message.toLower() == "updateobjectbrowser" ||
5037 message.toLower() == "updateobjbrowser" ) {
5038 // update object browser
5039 updateObjectBrowser();
5041 else if ( message.toLower().startsWith( "activate_viewer" ) ) {
5042 QString vtype = message.split( sectionSeparator ).last();
5043 if ( !vtype.isEmpty() )
5044 getViewManager( vtype, true );
5046 else if ( message.toLower().startsWith("register_module_in_study" ) ) {
5047 QString moduleName = message.split( sectionSeparator ).last();
5048 // Check name of current activating module name in order to avoid ciclik
5049 // call because of messages
5050 if (!property("activateModule").toBool()) {
5051 CAM_Module* mod = module(moduleName);
5053 mod = module(moduleTitle(moduleName));
5055 mod = loadModule(moduleName);
5057 mod = loadModule(moduleTitle(moduleName));
5063 CAM_Study* anActiveStudy = dynamic_cast<CAM_Study*>(activeStudy());
5064 if (anActiveStudy) {
5065 mod->connectToStudy(anActiveStudy);
5066 LightApp_DataModel* aDM = dynamic_cast<LightApp_DataModel*>(mod->dataModel());
5068 aDM->initRootObject();
5075 QStringList data = message.split( sectionSeparator );
5076 if ( data.count() > 1 ) {
5077 QString msgType = data[0].trimmed();
5078 LightApp_Module* sMod = 0;
5079 CAM_Module* mod = module( msgType );
5081 mod = module( moduleTitle( msgType ) );
5082 if ( mod && mod->inherits( "LightApp_Module" ) )
5083 sMod = (LightApp_Module*)mod;
5085 if ( msgType.toLower() == "preferences" ) {
5086 // requested preferences change: should be given as "preferences/<section>/<name>/<value>"
5087 // for example "preferences/Study/multi_file_dump/true"
5088 if ( data.count() > 3 ) {
5089 QString section = data[1].trimmed();
5090 QString param = data[2].trimmed();
5091 QString value = QStringList( data.mid(3) ).join( sectionSeparator );
5092 resourceMgr()->setValue( section, param, value );
5096 // received message for the module
5097 QString msg = QStringList( data.mid(1) ).join( sectionSeparator );
5098 sMod->message( msg );
5104 void LightApp_Application::onInfoPanelShown()
5106 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
5107 ((LightApp_Module*)activeModule())->updateInfoPanel();
5112 Returns all top level toolbars.
5113 Note : Result list contains only main window toolbars, not including toolbars from viewers.
5115 QList<QToolBar*> LightApp_Application::findToolBars( const QStringList& names )
5117 QList<QToolBar*> aResult;
5118 QList<QToolBar*> tbList = desktop()->findChildren<QToolBar*>();
5119 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit ) {
5120 QToolBar* tb = *tit;
5121 QObject* po = Qtx::findParent( tb, "QMainWindow" );
5122 if ( po != desktop() )
5124 if ( names.isEmpty() || names.contains( tb->objectName() ) )
5131 Internal method to parse toolbars and dockable windows state.
5133 QByteArray LightApp_Application::processState(QByteArray& input,
5134 const bool processWin,
5135 const bool processTb,
5136 const bool isRestoring,
5137 QByteArray defaultState) {
5140 bool hasDefaultState = !defaultState.isEmpty();
5141 bool isDockWinWriten = false;
5143 //Write date from users settings
5145 QDataStream tmpInputData(&input, QIODevice::ReadOnly);
5146 int marker, version;
5148 tmpInputData >> marker;
5149 tmpInputData >> version;
5150 tmpInputData >> dockmarker;
5151 tmpInputData >> nbDocWin;
5153 if(processWin && processTb && !isRestoring) {
5155 } else if(!processWin && !processTb ) {
5157 aRes = defaultState;
5159 QDataStream aData(&aRes, QIODevice::WriteOnly);
5160 QList<QToolBar*> aToolBars = findToolBars();
5163 for ( QList<QToolBar*>::iterator tit = aToolBars.begin(); tit != aToolBars.end(); ++tit ) {
5164 QToolBar* tb = *tit;
5165 aNames.append(tb->objectName());
5168 int toolBarMarkerIndex = getToolbarMarkerIndex(input,aNames);
5169 if(toolBarMarkerIndex < 0)
5171 QDataStream anInputData(&input, QIODevice::ReadOnly);
5173 int toolBarMarkerIndexDef = 0;
5174 if(hasDefaultState) {
5175 toolBarMarkerIndexDef = getToolbarMarkerIndex(defaultState, aNames);
5176 if(toolBarMarkerIndexDef < 0)
5179 QDataStream anInputDataDef(&defaultState, QIODevice::ReadOnly);
5181 QDataStream* aTargetData = 0;
5182 int aTargetIndex = -1;
5184 QByteArray currentArr = desktop()->saveState();
5185 QDataStream anInputDataCur(¤tArr, QIODevice::ReadOnly);
5186 bool useInputData = !isRestoring || (isRestoring && nbDocWin > 0);
5187 if(processWin && useInputData) {
5188 aTargetData = &anInputData;
5189 aTargetIndex = toolBarMarkerIndex;
5191 //Write date from default settings
5192 if(hasDefaultState) {
5193 aTargetData = &anInputDataDef;
5194 aTargetIndex = toolBarMarkerIndexDef;
5196 //If no default state, write current snapshot of the dockable windows
5198 aTargetData = &anInputDataCur;
5199 int toolBarMarkerIndexCur = getToolbarMarkerIndex(currentArr, aNames);
5200 aTargetIndex = toolBarMarkerIndexCur;
5205 if(aTargetData && aTargetIndex >= 0 ) {
5206 aTargetData->device()->seek(0);
5207 while( aTargetData->device()->pos() < aTargetIndex ) {
5212 isDockWinWriten = true;
5219 aTargetData = &anInputData;
5220 aTargetIndex = toolBarMarkerIndex;
5222 if(hasDefaultState) {
5223 aTargetData = &anInputDataDef;
5224 aTargetIndex = toolBarMarkerIndexDef;
5228 if(aTargetData && aTargetIndex >= 0) {
5230 if(!isDockWinWriten ) {
5231 //Write version marker
5232 int marker, version;
5233 aTargetData->device()->seek(0);
5234 *aTargetData >> marker;
5235 *aTargetData >> version;
5238 aData << (uchar) QDockWidgetMarker;
5240 int shift = 4*sizeof(int) + sizeof(QSize);
5241 index = aTargetIndex - shift;
5243 index = aTargetIndex;
5246 aTargetData->device()->seek(index);
5247 while(!aTargetData->atEnd()) {
5252 } else { // Not treat toolbars
5253 aData << (uchar) QToolBarMarker;
5254 aData << (int) 0; //Nb toolbars = 0
5261 \brief Emits operationFinished signal.
5262 \param theModuleName the name of the module which perfomed the operation
5263 \param theOperationName the operation name
5264 \param theEntryList the list of the created objects entries
5266 void LightApp_Application::emitOperationFinished( const QString& theModuleName,
5267 const QString& theOperationName,
5268 const QStringList& theEntryList )
5270 emit operationFinished( theModuleName, theOperationName, theEntryList );
5274 Update visibility state of given objects
5276 void LightApp_Application::updateVisibilityState( DataObjectList& theList,
5277 SUIT_ViewModel* theViewModel )
5279 if ( !theViewModel || theList.isEmpty() ) return;
5281 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
5282 if ( !aStudy ) return;
5284 SALOME_View* aView = dynamic_cast<SALOME_View*>( theViewModel );
5286 for ( DataObjectList::iterator itr = theList.begin(); itr != theList.end(); ++itr ) {
5287 LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>(*itr);
5289 if ( !obj || aStudy->isComponent( obj->entry() ) )
5292 QString mname = aStudy->componentDataType(obj->entry());
5293 LightApp_Displayer* aDisplayer = LightApp_Displayer::FindDisplayer(mname, false);
5295 Qtx::VisibilityState anObjState = Qtx::UnpresentableState;
5296 if ( aDisplayer->canBeDisplayed( obj->entry(), theViewModel->getType() ) ) {
5297 if ( aDisplayer->IsDisplayed( obj->entry(), aView ) )
5298 anObjState = Qtx::ShownState;
5300 anObjState = Qtx::HiddenState;
5302 aStudy->setVisibilityState( obj->entry(), anObjState );
5308 Update presentations of all displayed objects of theComponent in specified viewers
5310 void LightApp_Application::updatePresentations( const QString& theComponent,
5311 const QStringList& theViewManagerTypes )
5313 LightApp_Displayer* aDisplayer = LightApp_Displayer::FindDisplayer(theComponent, false);
5315 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
5316 DataObjectList aComps;
5317 bool isFound = false;
5318 aStudy->root()->children( aComps );
5319 DataObjectList::const_iterator aCompsIt = aComps.begin();
5320 for ( ; aCompsIt != aComps.end() && !isFound; aCompsIt++ ) {
5321 LightApp_DataObject* aComp = dynamic_cast<LightApp_DataObject*>( *aCompsIt );
5322 if ( aComp && aComp->componentDataType() == theComponent) {
5324 DataObjectList anObjs;
5325 aComp->children(anObjs, true);
5327 QList<SUIT_ViewManager*> aViewMgrs;
5328 QStringList::const_iterator itVMTypes = theViewManagerTypes.begin();
5329 for ( ; itVMTypes != theViewManagerTypes.end(); ++itVMTypes )
5330 viewManagers( *itVMTypes, aViewMgrs );
5332 DataObjectList::const_iterator itObjs = anObjs.begin();
5333 for ( ; itObjs != anObjs.end(); itObjs++ ) {
5334 LightApp_DataObject* anObj = dynamic_cast<LightApp_DataObject*>( *itObjs );
5335 QString anEntry = anObj->entry();
5337 QListIterator<SUIT_ViewManager*> itViewMgrs( aViewMgrs );
5338 while ( itViewMgrs.hasNext()) {
5339 SUIT_ViewModel* aVM = itViewMgrs.next()->getViewModel();
5341 SALOME_View* aView = dynamic_cast<SALOME_View*>(aVM);
5343 bool isDisp = aDisplayer->IsDisplayed( anEntry, aView );
5344 aDisplayer->Erase( anEntry, true, false, aView );
5346 aDisplayer->Display( anEntry, false, aView );
5358 * Called when window activated
5360 void LightApp_Application::onWindowActivated( SUIT_ViewWindow* theViewWindow )
5362 SUIT_DataBrowser* anOB = objectBrowser();
5365 SUIT_DataObject* rootObj = anOB->root();
5369 DataObjectList listObj = rootObj->children( true );
5371 SUIT_ViewModel* vmod = 0;
5372 if ( SUIT_ViewManager* vman = theViewWindow->getViewManager() )
5373 vmod = vman->getViewModel();
5374 updateVisibilityState( listObj, vmod );
5378 Called then view manager removed
5380 void LightApp_Application::onViewManagerRemoved( SUIT_ViewManager* )
5382 ViewManagerList lst;
5383 viewManagers( lst );
5384 if ( lst.count() == 1) { // in case if closed last view window
5385 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
5387 aStudy->setVisibilityStateForAll( Qtx::UnpresentableState );
5392 Check existing document.
5394 bool LightApp_Application::checkExistingDoc( bool closeExistingDoc )
5397 if( activeStudy() ) {
5398 int answer = !activeStudy()->isModified() ? 1 :
5399 SUIT_MessageBox::question( desktop(),
5400 tr( "APPCLOSE_CAPTION" ),
5401 tr( "STUDYCLOSE_DESCRIPTION" ),
5402 tr( "APPCLOSE_SAVE" ),
5403 tr( "APPCLOSE_CLOSE" ),
5404 tr( "APPCLOSE_CANCEL" ), 0 );
5406 if ( activeStudy()->isSaved() ) {
5408 if (closeExistingDoc) {
5411 } else if ( onSaveAsDoc() ) {
5412 if (closeExistingDoc) {
5413 if( !closeDoc( false ) ) {
5421 else if( answer == 1 ) {
5422 if (closeExistingDoc) {
5425 } else if( answer == 2 ) {
5432 #ifndef DISABLE_PYCONSOLE
5434 PyConsole_Interp* LightApp_Application::getPyInterp()
5436 static PyConsole_Interp* myInterp = 0;
5438 myInterp = createPyInterp();
5439 myInterp->initialize();
5444 PyConsole_Interp* LightApp_Application::createPyInterp()
5446 return new PyConsole_Interp();
5449 #endif // DISABLE_PYCONSOLE