1 // Copyright (C) 2007-2016 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 "LightApp_PyEditor.h"
39 #include "PyConsole_Interp.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 <QtxToolBar.h>
89 #include <QtxTreeView.h>
90 #include <QtxMRUAction.h>
91 #include <QtxDockAction.h>
92 #include <QtxDockWidget.h>
93 #include <QtxActionToolMgr.h>
94 #include <QtxSearchTool.h>
95 #include <QtxWorkstack.h>
98 #include <LogWindow.h>
100 #ifndef DISABLE_GLVIEWER
101 #include <GLViewer_Viewer.h>
102 #include <GLViewer_ViewManager.h>
103 #include "LightApp_GLSelector.h"
106 #ifndef DISABLE_PLOT2DVIEWER
107 #include <Plot2d_ViewManager.h>
108 #include <Plot2d_ViewModel.h>
109 #include <Plot2d_ViewWindow.h>
110 #include <Plot2d_ViewFrame.h>
111 #include "LightApp_Plot2dSelector.h"
112 #ifndef DISABLE_SALOMEOBJECT
113 #include <SPlot2d_ViewModel.h>
115 #include <Plot2d_ViewModel.h>
119 #ifndef DISABLE_OCCVIEWER
120 #include <OCCViewer_ViewManager.h>
121 #include <OCCViewer_ViewFrame.h>
122 #include <OCCViewer_ViewPort3d.h>
123 #ifndef DISABLE_SALOMEOBJECT
124 #include <SOCC_ViewModel.h>
126 #include <OCCViewer_ViewModel.h>
128 #include "LightApp_OCCSelector.h"
131 #ifndef DISABLE_VTKVIEWER
132 #ifndef DISABLE_SALOMEOBJECT
133 #include <SVTK_ViewModel.h>
134 #include <SVTK_ViewManager.h>
135 #include "LightApp_VTKSelector.h"
137 #include <VTKViewer_ViewModel.h>
138 #include <VTKViewer_ViewManager.h>
140 #include <VTKViewer_ViewModel.h>
143 #ifndef DISABLE_QXGRAPHVIEWER
144 #include <QxScene_ViewManager.h>
145 #include <QxScene_ViewModel.h>
146 #include <QxScene_ViewWindow.h>
149 #ifndef DISABLE_GRAPHICSVIEW
150 #include "GraphicsView_Viewer.h"
151 #include "GraphicsView_ViewManager.h"
152 #include "LightApp_GVSelector.h"
155 #ifndef DISABLE_PVVIEWER
156 #include "PVViewer_ViewManager.h"
157 #include "PVViewer_ViewWindow.h"
158 #include "PVViewer_ViewModel.h"
161 #ifndef DISABLE_PYVIEWER
162 #include <PyViewer_ViewManager.h>
163 #include <PyViewer_ViewModel.h>
164 #include <PyViewer_ViewWindow.h>
168 #define VISIBILITY_COLUMN_WIDTH 25
174 #include <QStringList>
176 #include <QApplication>
178 #include <QStatusBar>
180 #include <QObjectList>
182 #include <QInputDialog>
183 #include <QFontDatabase>
185 #include <QByteArray>
189 #include <QHeaderView>
194 #include <utilities.h>
196 #define FIRST_HELP_ID 1000000
198 #ifndef DISABLE_SALOMEOBJECT
199 #include <SALOME_InteractiveObject.hxx>
200 #include <SALOME_ListIO.hxx>
203 #include <Standard_Version.hxx>
205 #define ToolBarMarker 0
206 #define DockWidgetMarker 1
208 static const char* imageEmptyIcon[] = {
211 "....................",
212 "....................",
213 "....................",
214 "....................",
215 "....................",
216 "....................",
217 "....................",
218 "....................",
219 "....................",
220 "....................",
221 "....................",
222 "....................",
223 "....................",
224 "....................",
225 "....................",
226 "....................",
227 "....................",
228 "....................",
229 "....................",
230 "...................."};
232 int LightApp_Application::lastStudyId = 0;
234 // Markers used to parse array with dockable windows and toolbars state.
235 // For more details please see the qdockarealayout.cpp && qtoolbararealayout.cpp
236 // in the Qt source code.
238 #define QDockWidgetMarker 0xfd // = DockWidgetStateMarker
239 #define QToolBarMarker 0xfc // = ToolBarStateMarkerEx
241 // Format of the Byte array with the windows and toolbar state is:
242 // VersionMarker|version|DockWidgetStateMarker|nbDockWidgetLines|...DocWidgetData...|ToolBarStateMarkerEx|nbToolBarLines|...ToolBarData...
244 //Find toolbar marker position in the array in the following way:
245 //since the 'toolbar marker' is not unique, find index of first occurrence of the
246 //'toolbar marker' in the array and check that next string is name of the toolbar
248 int getToolbarMarkerIndex(QByteArray input, const QStringList& aFlags) {
249 int aResult = -1,tmp = 0;
250 int inputLen = input.length();
251 QDataStream anInputData(&input, QIODevice::ReadOnly);
252 while(tmp < inputLen) {
253 tmp = input.indexOf(QToolBarMarker, tmp + 1);
256 anInputData.device()->seek(tmp);
260 anInputData >> lines;
262 if(lines == 0 && anInputData.atEnd()){
263 //Case then array doesn't contain information about toolbars,
274 if(aFlags.contains(str)) {
283 \return last global id of study
285 int LightApp_Application::studyId()
287 return LightApp_Application::lastStudyId;
290 /*!Create new instance of LightApp_Application.*/
291 extern "C" LIGHTAPP_EXPORT SUIT_Application* createApplication()
293 return new LightApp_Application();
296 /*! \var global preferences of LightApp */
297 LightApp_Preferences* LightApp_Application::_prefs_ = 0;
301 \class LightApp_Application
302 Application containing LightApp module
306 LightApp_Application::LightApp_Application()
307 : CAM_Application( false ),
309 myScreenHelper(new LightApp_FullScreenHelper())
311 Q_INIT_RESOURCE( LightApp );
313 STD_TabDesktop* desk = new STD_TabDesktop();
314 desk->setFullScreenAllowed(false);
315 desk->setMinimizeAllowed(false);
319 // initialize auto save timer
320 myAutoSaveTimer = new QTimer( this );
321 myAutoSaveTimer->setSingleShot( true );
322 connect( myAutoSaveTimer, SIGNAL( timeout() ), this, SLOT( onSaveDoc() ) );
324 //connect( this, SIGNAL( moving() ), this, SLOT( onMoved() ) );
326 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
327 QPixmap aLogo = aResMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
329 desktop()->setWindowIcon( aLogo );
330 desktop()->setDockableMenuBar( false );
331 desktop()->setDockableStatusBar( false );
333 // base logo (salome itself)
334 desktop()->logoInsert( "_app_base", aResMgr->loadPixmap( "LightApp", tr( "APP_BASE_LOGO" ), false ) );
335 // extra logo (salome-based application)
336 desktop()->logoInsert( "_app_extra", aResMgr->loadPixmap( "LightApp", tr( "APP_EXTRA_LOGO" ), false ) );
340 mySelMgr = new LightApp_SelectionMgr( this );
342 myAccel = SUIT_Accel::getAccel();
344 #ifndef DISABLE_OCCVIEWER
345 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, OCCViewer_Viewer::Type() );
346 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, OCCViewer_Viewer::Type() );
347 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, OCCViewer_Viewer::Type() );
348 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, OCCViewer_Viewer::Type() );
349 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, OCCViewer_Viewer::Type() );
350 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, OCCViewer_Viewer::Type() );
351 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, OCCViewer_Viewer::Type() );
352 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, OCCViewer_Viewer::Type() );
353 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, OCCViewer_Viewer::Type() );
354 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, OCCViewer_Viewer::Type() );
355 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, OCCViewer_Viewer::Type() );
356 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, OCCViewer_Viewer::Type() );
358 #ifndef DISABLE_VTKVIEWER
359 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, VTKViewer_Viewer::Type() );
360 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, VTKViewer_Viewer::Type() );
361 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, VTKViewer_Viewer::Type() );
362 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, VTKViewer_Viewer::Type() );
363 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, VTKViewer_Viewer::Type() );
364 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, VTKViewer_Viewer::Type() );
365 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, VTKViewer_Viewer::Type() );
366 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, VTKViewer_Viewer::Type() );
367 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, VTKViewer_Viewer::Type() );
368 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, VTKViewer_Viewer::Type() );
369 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, VTKViewer_Viewer::Type() );
370 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, VTKViewer_Viewer::Type() );
372 #ifndef DISABLE_PLOT2DVIEWER
373 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, Plot2d_Viewer::Type() );
374 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, Plot2d_Viewer::Type() );
375 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, Plot2d_Viewer::Type() );
376 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, Plot2d_Viewer::Type() );
377 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, Plot2d_Viewer::Type() );
378 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, Plot2d_Viewer::Type() );
379 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, Plot2d_Viewer::Type() );
380 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, Plot2d_Viewer::Type() );
383 connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) );
384 connect( desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
385 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
386 connect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
387 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ), Qt::UniqueConnection );
390 // Set existing font for the python console in resources
391 if( !aResMgr->hasValue( "PyConsole", "font" ) )
394 QFont f = aResMgr->fontValue( "PyConsole", "font" );
396 QStringList famdb = fdb.families();
398 if ( famdb.contains(f.family()) || !aResMgr->hasValue( "PyConsole", "additional_families" ) )
401 QStringList anAddFamilies = aResMgr->stringValue( "PyConsole", "additional_families" ).split( ";", QString::SkipEmptyParts );
403 for ( QStringList::Iterator it = anAddFamilies.begin(); it != anAddFamilies.end(); ++it )
406 if ( famdb.contains(aFamily) )
408 f.setFamily( aFamily );
409 aResMgr->setValue( "PyConsole", "font", f );
416 *\li Save window geometry.
417 *\li Save desktop geometry.
418 *\li Save resource maneger.
419 *\li Delete selection manager.
421 LightApp_Application::~LightApp_Application()
424 delete myScreenHelper;
427 /*!Start application.*/
428 void LightApp_Application::start()
430 CAM_Application::start();
433 updateViewManagers();
434 updateCommandsStatus();
437 desktop()->statusBar()->showMessage( "" );
439 LightApp_EventFilter::Init();
442 /*!Closeapplication.*/
443 void LightApp_Application::closeApplication()
445 QProcess::startDetached( "HelpBrowser",
446 QStringList() << QString( "--remove=%1" ).arg( QApplication::instance()->applicationPid() ) );
448 CAM_Application::closeApplication();
451 /*!Gets application name.*/
452 QString LightApp_Application::applicationName() const
454 static QString _app_name;
455 if ( _app_name.isEmpty() )
456 _app_name = tr( "APP_NAME" );
460 /*!Gets application version.*/
461 QString LightApp_Application::applicationVersion() const
463 static QString _app_version;
465 if ( _app_version.isEmpty() )
467 QString resVersion = tr( "APP_VERSION" );
468 if ( resVersion != "APP_VERSION" )
470 _app_version = resVersion;
474 _app_version = GUI_VERSION_STR;
480 /*!Load module by \a name.*/
481 CAM_Module* LightApp_Application::loadModule( const QString& name, const bool showMsg )
483 CAM_Module* mod = CAM_Application::loadModule( name, showMsg );
486 connect( this, SIGNAL( studyOpened() ), mod, SLOT( onModelOpened() ) );
487 connect( this, SIGNAL( studySaved() ), mod, SLOT( onModelSaved() ) );
488 connect( this, SIGNAL( studyClosed() ), mod, SLOT( onModelClosed() ) );
493 /*!Activate module by \a modName*/
494 bool LightApp_Application::activateModule( const QString& modName )
497 CAM_Module* prevMod = activeModule();
500 actName = prevMod->moduleName();
502 if ( actName == modName )
505 putInfo( tr( "ACTIVATING_MODULE" ).arg( modName ) );
507 saveDockWindowsState();
509 bool status = CAM_Application::activateModule( modName );
511 updateModuleActions();
519 updateViewManagers();
521 if ( activeStudy() && activeStudy()->root() && objectBrowser() ) {
522 if ( objectBrowser()->root() != activeStudy()->root() )
523 objectBrowser()->setRoot( activeStudy()->root() );
524 updateObjectBrowser( true );
527 if ( activeModule() ) activeModule()->updateModuleVisibilityState();
532 /*!Gets selection manager.*/
533 LightApp_SelectionMgr* LightApp_Application::selectionMgr() const
538 /*!Creat action "New window" for certain type of viewer:*/
539 void LightApp_Application::createActionForViewer( const int id,
541 const QString& suffix,
544 QString vtlt = tr( QString( "NEW_WINDOW_%1" ).arg( suffix ).toLatin1().constData() );
545 QString tip = tr( "CREATING_NEW_WINDOW" ).arg( vtlt.remove( "&" ) );
546 QAction* a = createAction( id, // menu action id
553 false, // toggle flag
555 SLOT( onNewWindow() ) ); // slot
556 createMenu( a, parentId, -1 );
561 void LightApp_Application::createActions()
563 CAM_Application::createActions();
565 SUIT_Desktop* desk = desktop();
566 SUIT_ResourceMgr* resMgr = resourceMgr();
569 createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIcon(),
570 tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
571 Qt::CTRL+Qt::Key_R, desk, false, this, SLOT( onPreferences() ) );
575 // - Help for modules
577 int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
578 createMenu( separator(), helpMenu, -1, 10 );
579 QStringList aModuleList;
580 modules( aModuleList, false );
581 aModuleList.prepend( "GUI" );
582 aModuleList.prepend( "KERNEL" );
584 int id = LightApp_Application::UserID + FIRST_HELP_ID;
587 foreach( aModule, aModuleList ) {
588 if ( aModule.isEmpty() ) // module title (user name)
590 IMap <QString, QString> helpData; // list of help files for the module
591 QString helpSubMenu; // help submenu name (empty if not needed)
592 QString modName = moduleName( aModule ); // module name
593 if ( modName.isEmpty() ) modName = aModule; // for KERNEL and GUI
594 QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName ); // module root dir variable
595 QString modDir = getenv( rootDir.toLatin1().constData() ); // module root dir
597 if (resMgr->hasValue( modName, "documentation" ) )
598 docSection = resMgr->stringValue(modName, "documentation");
599 else if ( resMgr->hasSection( modName + "_documentation" ) )
600 docSection = modName + "_documentation";
601 if ( !docSection.isEmpty() ) {
602 helpSubMenu = resMgr->stringValue( docSection, "sub_menu", "" ).arg( aModule );
603 QStringList listOfParam = resMgr->parameters( docSection );
604 foreach( QString paramName, listOfParam ) {
605 QString valueStr = resMgr->stringValue( docSection, paramName );
606 if ( !valueStr.isEmpty() ) {
607 QFileInfo fi( valueStr );
608 if ( fi.isRelative() && !modDir.isEmpty() )
609 valueStr = Qtx::addSlash( modDir ) + valueStr;
610 if ( QFile::exists( valueStr ) )
611 helpData.insert( paramName.arg( aModule ), valueStr );
616 if ( helpData.isEmpty() && !modDir.isEmpty() ) {
617 QStringList idxLst = QStringList() << modDir << "share" << "doc" << "salome" << "gui" << modName << "index.html";
618 QString indexFile = idxLst.join( QDir::separator() ); // index file
619 if ( QFile::exists( indexFile ) )
620 helpData.insert( tr( "%1 module Users's Guide" ).arg( aModule ), indexFile );
623 IMapConstIterator<QString, QString > fileIt;
624 for ( fileIt = helpData.begin(); fileIt != helpData.end(); fileIt++ ) {
625 QString helpFileName = fileIt.key();
626 // remove all '//' occurances
627 while ( helpFileName.contains( "//" ) )
628 helpFileName.replace( "//", "" );
629 // obtain submenus hierarchy if given
630 QStringList smenus = helpFileName.split( "/" );
631 helpFileName = smenus.last();
633 QAction* a = createAction( id, helpFileName,
634 resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
635 helpFileName, helpFileName,
636 0, desk, false, this, SLOT( onHelpContentsModule() ) );
637 a->setData( fileIt.value() );
638 if ( !helpSubMenu.isEmpty() ) {
639 smenus.prepend( helpSubMenu );
641 // create sub-menus hierarchy
642 int menuId = helpMenu;
643 foreach ( QString subMenu, smenus ) {
644 menuId = createMenu( subMenu, menuId, -1, 0 );
646 createMenu( a, menuId, -1, 0 );
651 // - Additional help items
653 createMenu( separator(), helpMenu, -1, 5 );
655 QStringList addHelpItems = resMgr->parameters( "add_help" );
656 foreach ( QString addHelpItem, addHelpItems ) {
657 QString valueStr = resMgr->stringValue( "add_help", addHelpItem );
658 if ( !valueStr.isEmpty() && QFile::exists( valueStr ) ) {
659 QAction* a = createAction( id, addHelpItem,
660 resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
661 addHelpItem, addHelpItem,
662 0, desk, false, this, SLOT( onHelpContentsModule() ) );
663 a->setData( valueStr );
664 createMenu( a, helpMenu, -1, 5 );
670 static QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), 0 );
671 connect( mru, SIGNAL( activated( const QString& ) ), this, SLOT( onMRUActivated( const QString& ) ) );
672 registerAction( MRUId, mru );
674 // default icon for neutral point ('SALOME' module)
675 QPixmap defIcon = resMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
676 if ( defIcon.isNull() )
677 defIcon = QPixmap( imageEmptyIcon );
679 //! default icon for any module
680 QPixmap modIcon = resMgr->loadPixmap( "LightApp", tr( "APP_MODULE_ICO" ), false );
681 if ( modIcon.isNull() )
682 modIcon = QPixmap( imageEmptyIcon );
685 modules( modList, false );
687 if ( modList.count() > 1 )
689 LightApp_ModuleAction* moduleAction =
690 new LightApp_ModuleAction( tr( "APP_NAME" ), defIcon, desk );
692 QMap<QString, QString> iconMap;
693 moduleIconNames( iconMap );
695 const int iconSize = 20;
697 QStringList::Iterator it;
698 for ( it = modList.begin(); it != modList.end(); ++it )
700 if ( !isLibExists( *it ) )
703 QString modName = moduleName( *it );
705 if ( !isModuleAccessible( *it ) )
709 if ( iconMap.contains( *it ) )
710 iconName = iconMap[*it];
712 QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
716 INFOS ( "\n****************************************************************" << std::endl
717 << "* Icon for " << (*it).toLatin1().constData()
718 << " not found. Using the default one." << std::endl
719 << "****************************************************************" << std::endl );
722 icon = Qtx::scaleIcon( icon, iconSize );
724 moduleAction->insertModule( *it, icon );
727 connect( moduleAction, SIGNAL( moduleActivated( const QString& ) ),
728 this, SLOT( onModuleActivation( const QString& ) ) );
729 registerAction( ModulesListId, moduleAction );
733 int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, MenuWindowId, 100 );
734 int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
736 createAction( CloseId, tr( "TOT_CLOSE" ), QIcon(), tr( "MEN_DESK_CLOSE" ), tr( "PRP_CLOSE" ),
737 Qt::CTRL+Qt::Key_F4, desk, false, this, SLOT( onCloseWindow() ) );
738 createAction( CloseAllId, tr( "TOT_CLOSE_ALL" ), QIcon(), tr( "MEN_DESK_CLOSE_ALL" ), tr( "PRP_CLOSE_ALL" ),
739 0, desk, false, this, SLOT( onCloseAllWindow() ) );
740 createAction( GroupAllId, tr( "TOT_GROUP_ALL" ), QIcon(), tr( "MEN_DESK_GROUP_ALL" ), tr( "PRP_GROUP_ALL" ),
741 0, desk, false, this, SLOT( onGroupAllWindow() ) );
743 createMenu( CloseId, windowMenu, 0, -1 );
744 createMenu( CloseAllId, windowMenu, 0, -1 );
745 createMenu( GroupAllId, windowMenu, 0, -1 );
746 createMenu( separator(), windowMenu, -1, 0 );
748 #ifndef DISABLE_GLVIEWER
749 createActionForViewer( NewGLViewId, newWinMenu, QString::number( 0 ), Qt::ALT+Qt::Key_G );
751 #ifndef DISABLE_PLOT2DVIEWER
752 createActionForViewer( NewPlot2dId, newWinMenu, QString::number( 1 ), Qt::ALT+Qt::Key_P );
754 #ifndef DISABLE_OCCVIEWER
755 createActionForViewer( NewOCCViewId, newWinMenu, QString::number( 2 ), Qt::ALT+Qt::Key_O );
757 #ifndef DISABLE_VTKVIEWER
758 createActionForViewer( NewVTKViewId, newWinMenu, QString::number( 3 ), Qt::ALT+Qt::Key_K );
760 #ifndef DISABLE_QXGRAPHVIEWER
761 createActionForViewer( NewQxSceneViewId, newWinMenu, QString::number( 4 ), Qt::ALT+Qt::Key_S );
763 #ifndef DISABLE_GRAPHICSVIEW
764 createActionForViewer( NewGraphicsViewId, newWinMenu, QString::number( 5 ), Qt::ALT+Qt::Key_C );
766 #ifndef DISABLE_PVVIEWER
767 createActionForViewer( NewPVViewId, newWinMenu, QString::number( 6 ), Qt::ALT+Qt::Key_A );
769 #ifndef DISABLE_PYVIEWER
770 createActionForViewer( NewPyViewerId, newWinMenu, QString::number( 7 ), Qt::ALT+Qt::Key_Y );
773 createAction( RenameId, tr( "TOT_RENAME" ), QIcon(), tr( "MEN_DESK_RENAME" ), tr( "PRP_RENAME" ),
774 Qt::ALT+Qt::SHIFT+Qt::Key_R, desk, false, this, SLOT( onRenameWindow() ) );
775 createMenu( RenameId, windowMenu, -1 );
777 int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
778 createMenu( PreferencesId, fileMenu, 50, -1 );
779 createMenu( separator(), fileMenu, -1, 50, -1 );
781 createMenu( separator(), fileMenu, -1, 100, -1 );
782 createMenu( MRUId, fileMenu, 100, -1 );
783 createMenu( separator(), fileMenu, -1, 100, -1 );
785 #ifdef USE_SALOME_STYLE
786 createAction( StyleId, tr( "TOT_THEME" ), QIcon(), tr( "MEN_DESK_THEME" ), tr( "PRP_THEME" ),
787 0, desk, false, this, SLOT( onStylePreferences() ) );
788 #endif // USE_SALOME_STYLE
790 createAction( FullScreenId, tr( "TOT_FULLSCREEN" ), QIcon(), tr( "MEN_DESK_FULLSCREEN" ), tr( "PRP_FULLSCREEN" ),
791 Qt::Key_F11, desk, false, this, SLOT( onFullScreen() ) );
794 int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1 );
795 createMenu( separator(), viewMenu, -1, 20, -1 );
796 #ifdef USE_SALOME_STYLE
797 createMenu( StyleId, viewMenu, 20, -1 );
798 #endif // USE_SALOME_STYLE
799 createMenu( FullScreenId, viewMenu, 20, -1 );
801 int modTBar = createTool( tr( "INF_TOOLBAR_MODULES" ), // title (language-dependant)
802 QString( "SalomeModules" ) ); // name (language-independant)
803 createTool( ModulesListId, modTBar );
806 /*!On module activation action.*/
807 void LightApp_Application::onModuleActivation( const QString& modName )
809 // Force user to create/open a study before module activation
810 QMap<QString, QString> iconMap;
811 moduleIconNames( iconMap );
812 QPixmap icon = resourceMgr()->loadPixmap( moduleName( modName ), iconMap[ modName ], false );
814 icon = resourceMgr()->loadPixmap( "LightApp", tr( "APP_MODULE_BIG_ICO" ), false ); // default icon for any module
816 bool cancelled = false;
818 while ( !modName.isEmpty() && !activeStudy() && !cancelled ){
819 LightApp_ModuleDlg aDlg( desktop(), modName, icon );
820 QMap<int, QString> opmap = activateModuleActions();
821 for ( QMap<int, QString>::ConstIterator it = opmap.begin(); it != opmap.end(); ++it )
822 aDlg.addButton( it.value(), it.key() );
824 int res = aDlg.exec();
826 // some operation is selected
827 moduleActionSelected( res );
831 putInfo( tr("INF_CANCELLED") );
833 LightApp_ModuleAction* moduleAction =
834 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
836 moduleAction->setActiveModule( QString() );
842 activateModule( modName );
845 /*!Default module activation.*/
846 QString LightApp_Application::defaultModule() const
848 QStringList aModuleNames;
849 modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration
850 //! If there's the one and only module --> activate it automatically
851 //! TODO: Possible improvement - default module can be taken from preferences
852 return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" );
855 /*!On new window slot.*/
856 void LightApp_Application::onNewWindow()
858 const QObject* obj = sender();
859 if ( !obj || !obj->inherits( "QAction" ) )
863 int id = actionId( (QAction*)obj );
866 #ifndef DISABLE_GLVIEWER
868 type = GLViewer_Viewer::Type();
871 #ifndef DISABLE_PLOT2DVIEWER
873 type = Plot2d_Viewer::Type();
876 #ifndef DISABLE_OCCVIEWER
878 type = OCCViewer_Viewer::Type();
881 #ifndef DISABLE_VTKVIEWER
883 type = VTKViewer_Viewer::Type();
886 #ifndef DISABLE_QXGRAPHVIEWER
887 case NewQxSceneViewId:
888 type = QxScene_Viewer::Type();
891 #ifndef DISABLE_GRAPHICSVIEW
892 case NewGraphicsViewId:
893 type = GraphicsView_Viewer::Type();
896 #ifndef DISABLE_PVVIEWER
898 type = PVViewer_Viewer::Type();
901 #ifndef DISABLE_PYVIEWER
903 type = PyViewer_Viewer::Type();
908 if ( !type.isEmpty() )
909 createViewManager( type );
913 SLOT: Creates new document
915 void LightApp_Application::onNewDoc()
917 #ifdef SINGLE_DESKTOP
918 if ( !checkExistingDoc() )
922 //asl: fix for 0020515
923 saveDockWindowsState();
925 CAM_Application::onNewDoc();
929 SLOT: Opens new document
931 void LightApp_Application::onOpenDoc()
933 SUIT_Study* study = activeStudy();
935 #ifdef SINGLE_DESKTOP
936 if ( !checkExistingDoc() )
940 CAM_Application::onOpenDoc();
942 if ( !study ) // new study will be create in THIS application
945 updateViewManagers();
950 SLOT: Opens new document.
951 \param aName - name of file
953 bool LightApp_Application::onOpenDoc( const QString& aName )
955 #ifdef SINGLE_DESKTOP
956 if ( !checkExistingDoc() )
960 saveDockWindowsState();
962 // We should take mru action first because this application instance can be deleted later.
963 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
965 bool res = CAM_Application::onOpenDoc( aName );
970 mru->insert( aName );
972 mru->remove( aName );
978 SLOT: Displays "About" message box
980 void LightApp_Application::onHelpAbout()
982 LightApp_AboutDlg dlg( applicationName(), applicationVersion(), desktop() );
987 Private SLOT: Called on selection is changed
988 Dispatchs active module that selection is changed
990 void LightApp_Application::onSelection()
992 onSelectionChanged();
994 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
995 ((LightApp_Module*)activeModule())->selectionChanged();
1000 \param study - SUIT_Study.
1002 void LightApp_Application::setActiveStudy( SUIT_Study* study )
1004 CAM_Application::setActiveStudy( study );
1008 Enables/Disables menu items and toolbar buttons. Rebuild menu
1010 void LightApp_Application::updateCommandsStatus()
1012 CAM_Application::updateCommandsStatus();
1015 #ifndef DISABLE_GLVIEWER
1016 a = action( NewGLViewId );
1018 a->setEnabled( activeStudy() );
1021 #ifndef DISABLE_PLOT2DVIEWER
1022 a = action( NewPlot2dId );
1024 a->setEnabled( activeStudy() );
1027 #ifndef DISABLE_OCCVIEWER
1028 a = action( NewOCCViewId );
1030 a->setEnabled( activeStudy() );
1033 #ifndef DISABLE_VTKVIEWER
1034 a = action( NewVTKViewId );
1036 a->setEnabled( activeStudy() );
1039 #ifndef DISABLE_QXGRAPHVIEWER
1040 a = action( NewQxSceneViewId );
1042 a->setEnabled( activeStudy() );
1045 #ifndef DISABLE_GRAPHICSVIEW
1046 a = action( NewGraphicsViewId );
1048 a->setEnabled( activeStudy() );
1051 #ifndef DISABLE_PVVIEWER
1052 a = action( NewPVViewId );
1054 a->setEnabled( activeStudy() );
1057 #ifndef DISABLE_PYVIEWER
1058 a = action( NewPyViewerId );
1060 a->setEnabled( activeStudy() );
1066 Runs system command in separate thread
1068 class RunBrowser: public QThread
1071 RunBrowser( LightApp_Application* app,
1072 const QString& theApp,
1073 const QString& theParams,
1074 const QString& theHelpFile,
1075 const QString& theContext = QString() )
1077 myParams( theParams ),
1078 myContext( theContext ),
1082 //For the external browser always specify 'file://' protocol,
1083 //because some WEB browsers (for example Mozilla Firefox) can't open local file without protocol.
1084 myHelpFile = QString("file://%1").arg( QFileInfo( theHelpFile ).canonicalFilePath() );
1089 if ( !myApp.isEmpty() && !myHelpFile.isEmpty()) {
1090 QString aCommand = QString( "%1 %2 \"%3%4\"" ).arg( myApp, myParams, myHelpFile, myContext.isEmpty() ? QString("") : QString( "#%1" ).arg( myContext ) );
1092 QProcess* proc = new QProcess();
1094 proc->start( aCommand );
1095 if ( !proc->waitForStarted() ) {
1096 SALOME_CustomEvent* ce2000 = new SALOME_CustomEvent( 2000 );
1097 QString* msg = new QString( QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).arg( myApp, myHelpFile ) );
1098 ce2000->setData( msg );
1099 QApplication::postEvent( myLApp, ce2000 );
1110 LightApp_Application* myLApp;
1114 SLOT: Displays help contents for choosen module
1116 void LightApp_Application::onHelpContentsModule()
1118 const QAction* a = (QAction*) sender();
1119 QString helpFile = a->data().toString();
1120 if ( helpFile.isEmpty() ) return;
1122 SUIT_ResourceMgr* resMgr = resourceMgr();
1125 platform = "winapplication";
1127 platform = "application";
1129 QString anApp = resMgr->stringValue("ExternalBrowser", platform);
1131 QString quote("\"");
1132 anApp.prepend( quote );
1133 anApp.append( quote );
1135 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
1136 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1138 if( useExtBrowser ) {
1139 if ( !anApp.isEmpty() ) {
1140 RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile );
1144 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1145 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1146 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1148 showPreferences( tr( "PREF_APP" ) );
1152 QStringList parameters;
1153 parameters << QString( "--language=%1" ).arg( resMgr->stringValue( "language", "language" ) );
1154 parameters << QString( "--add=%1" ).arg( QApplication::instance()->applicationPid() );
1155 parameters << helpFile;
1156 QProcess::startDetached( "HelpBrowser", parameters );
1161 SLOT: Displays help contents for choosen dialog
1163 void LightApp_Application::onHelpContextModule( const QString& theComponentName,
1164 const QString& theFileName,
1165 const QString& theContext )
1167 QString fileName = theFileName;
1168 QString context = theContext;
1169 if ( !QFile::exists( fileName ) && theContext.isEmpty() ) {
1170 // context might be passed within theFileName argument
1171 QStringList comps = fileName.split("#");
1172 if ( comps.count() > 1 ) {
1173 context = comps.last();
1175 fileName = comps.join("#");
1179 QString homeDir = "";
1180 if ( !theComponentName.isEmpty() ) {
1181 QString dir = getenv( ( theComponentName + "_ROOT_DIR" ).toLatin1().constData() );
1182 if ( !dir.isEmpty() )
1183 homeDir = Qtx::addSlash( Qtx::addSlash( dir ) +
1184 Qtx::addSlash( "share" ) +
1185 Qtx::addSlash( "doc" ) +
1186 Qtx::addSlash( "salome" ) +
1187 Qtx::addSlash( "gui" ) +
1188 Qtx::addSlash( theComponentName ) );
1191 QString helpFile = QFileInfo( homeDir + fileName ).absoluteFilePath();
1192 SUIT_ResourceMgr* resMgr = resourceMgr();
1195 platform = "winapplication";
1197 platform = "application";
1199 QString anApp = resMgr->stringValue("ExternalBrowser", platform);
1201 QString quote("\"");
1202 anApp.prepend( quote );
1203 anApp.append( quote );
1206 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1209 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
1211 if ( !anApp.isEmpty() ) {
1212 RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile, context );
1216 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1217 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1218 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1219 showPreferences( tr( "PREF_APP" ) );
1223 QStringList parameters;
1224 parameters << QString( "--language=%1" ).arg( resMgr->stringValue( "language", "language" ) );
1225 parameters << QString( "--add=%1" ).arg( QApplication::instance()->applicationPid() );
1226 parameters << QString( "%1#%2" ).arg( helpFile ).arg( context );
1227 QProcess::startDetached( "HelpBrowser", parameters );
1232 Sets enable or disable some actions on selection changed.
1234 void LightApp_Application::onSelectionChanged()
1236 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
1237 bool canCopy = m ? m->canCopy() : false;
1238 bool canPaste = m ? m->canPaste() : false;
1240 action( EditCopyId )->setEnabled(canCopy);
1241 action( EditPasteId )->setEnabled(canPaste);
1245 SLOT: Performs some actions when dockable windows are triggered
1247 void LightApp_Application::onDockWindowVisibilityChanged( bool )
1251 QWidget* LightApp_Application::dockWindow( const int id ) const
1254 if ( myWin.contains( id ) )
1259 QDockWidget* LightApp_Application::windowDock( QWidget* wid ) const
1264 QDockWidget* dock = 0;
1265 QWidget* w = wid->parentWidget();
1266 while ( w && !dock )
1268 dock = ::qobject_cast<QDockWidget*>( w );
1269 w = w->parentWidget();
1274 void LightApp_Application::insertDockWindow( const int id, QWidget* wid )
1279 if ( wid != dockWindow( id ) )
1280 removeDockWindow( id );
1282 myWin.insert( id, wid );
1284 QtxDockWidget* dock = new QtxDockWidget( true, desktop() );
1285 connect( dock, SIGNAL( destroyed( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
1287 dock->setFeatures( QDockWidget::AllDockWidgetFeatures );
1288 dock->setObjectName( wid->objectName().isEmpty() ? QString( "window_%1" ).arg( id ) :
1289 QString( "%1Dock" ).arg( wid->objectName() ) );
1290 dock->setWidget( wid );
1291 dock->toggleViewAction()->setData( QVariant( wid->objectName() ) );
1292 connect( dock->toggleViewAction(), SIGNAL( triggered( bool ) ),
1293 this, SLOT( onDockWindowVisibilityChanged( bool ) ) );
1295 QKeySequence accel = wid->property( "shortcut" ).value<QKeySequence>();
1296 if ( !accel.isEmpty() )
1297 dock->toggleViewAction()->setShortcut( accel );
1302 void LightApp_Application::removeDockWindow( const int id )
1304 QWidget* wid = dockWindow( id );
1310 QDockWidget* dock = windowDock( wid );
1314 dock->setWidget( 0 );
1315 wid->setParent( 0 );
1316 wid->setVisible( false );
1320 void LightApp_Application::placeDockWindow( const int id, Qt::DockWidgetArea place )
1322 QDockWidget* dock = windowDock( dockWindow( id ) );
1323 if ( dock && desktop() ) {
1324 desktop()->addDockWidget( place, dock );
1325 QtxDockAction* a = qobject_cast<QtxDockAction*>( action( ViewWindowsId ) );
1326 if ( a ) a->update();
1332 \param flag - key for window
1333 \param studyId - study id
1334 Flag used how identificator of window in windows list.
1336 QWidget* LightApp_Application::getWindow( const int flag, const int )
1338 QWidget* wid = dockWindow( flag );
1340 insertDockWindow( flag, wid = createWindow( flag ) );
1342 QMap<int, int> winMap;
1343 currentWindows( winMap );
1344 if ( winMap.contains( flag ) )
1345 placeDockWindow( flag, (Qt::DockWidgetArea)winMap[flag] );
1351 \return Object Browser
1353 SUIT_DataBrowser* LightApp_Application::objectBrowser()
1355 return qobject_cast<SUIT_DataBrowser*>( dockWindow( WT_ObjectBrowser ) );
1361 LogWindow* LightApp_Application::logWindow()
1363 return qobject_cast<LogWindow*>( dockWindow( WT_LogWindow ) );
1366 #ifndef DISABLE_PYCONSOLE
1368 This returns the python console integrated to the GUI. Depending
1369 when you request the python console, this function could return
1370 null. Then the optional parameter force (default to false) can be
1371 set to force the creation of the python console if it is not done
1373 \param force - if true, the pythonConsole is created if it does not exist yet
1374 \return Python Console
1376 PyConsole_Console* LightApp_Application::pythonConsole(const bool force)
1378 QWidget* wid = dockWindow( WT_PyConsole );
1379 if ( !wid && force==true) {
1380 wid = getWindow(WT_PyConsole);
1382 return qobject_cast<PyConsole_Console*>( wid );
1387 Updates object browser and maybe data models
1388 \param updateModels - if it is true, then data models are updated
1390 void LightApp_Application::updateObjectBrowser( const bool updateModels )
1392 // update existing data models
1395 const bool isAutoUpdate = objectBrowser() ? objectBrowser()->autoUpdate() : true;
1396 if ( objectBrowser() )
1397 objectBrowser()->setAutoUpdate( false );
1399 LightApp_Study* study = dynamic_cast<LightApp_Study*>(activeStudy());
1401 CAM_Study::ModelList dm_list;
1402 study->dataModels( dm_list );
1403 QListIterator<CAM_DataModel*> it( dm_list );
1404 while ( it.hasNext() ) {
1405 CAM_DataModel* camDM = it.next();
1406 if ( camDM && camDM->inherits( "LightApp_DataModel" ) )
1407 ((LightApp_DataModel*)camDM)->update();
1411 if( objectBrowser() )
1412 objectBrowser()->setAutoUpdate( isAutoUpdate );
1415 if ( objectBrowser() ) {
1416 objectBrowser()->updateGeometry();
1417 objectBrowser()->updateTree( 0, false );
1424 LightApp_Preferences* LightApp_Application::preferences() const
1426 return preferences( false );
1430 \return first view manager of some type
1431 \param vmType - type of view manager
1432 \param create - is it necessary to create view manager in case, when there is no manager of such type
1434 SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, const bool create )
1436 SUIT_ViewManager* aVM = viewManager( vmType );
1437 SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
1439 if ( anActiveVM && anActiveVM->getType() == vmType )
1442 if ( aVM && create )
1444 if ( !aVM->getActiveView() )
1447 desktop()->setActiveWindow( aVM->getActiveView() );
1450 aVM = createViewManager( vmType );
1456 Creates view manager of some type
1457 \param vmType - type of view manager
1459 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType )
1461 SUIT_ResourceMgr* resMgr = resourceMgr();
1463 SUIT_ViewManager* viewMgr = 0;
1464 #ifndef DISABLE_GLVIEWER
1465 if( vmType == GLViewer_Viewer::Type() )
1467 viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() );
1468 new LightApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
1471 #ifndef DISABLE_PLOT2DVIEWER
1472 if( vmType == Plot2d_Viewer::Type() )
1474 viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
1476 #ifndef DISABLE_SALOMEOBJECT
1477 SPlot2d_Viewer* v = new SPlot2d_Viewer();
1479 new LightApp_Plot2dSelector( v, mySelMgr );
1481 vm = new Plot2d_Viewer();
1483 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1484 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
1487 Plot2d_ViewFrame* frame = wnd->getViewFrame();
1488 frame->setBackgroundColor( resMgr->colorValue( "Plot2d", "Background", frame->backgroundColor() ) );
1492 #ifndef DISABLE_QXGRAPHVIEWER
1493 if( vmType == QxScene_Viewer::Type() )
1495 viewMgr = new QxScene_ViewManager( activeStudy(), desktop() );
1496 QxScene_Viewer* vm = new QxScene_Viewer();
1497 viewMgr->setViewModel( vm );
1498 //QxScene_ViewWindow* wnd = dynamic_cast<QxScene_ViewWindow*>( viewMgr->getActiveView() );
1501 #ifndef DISABLE_GRAPHICSVIEW
1502 if( vmType == GraphicsView_Viewer::Type() )
1504 viewMgr = new GraphicsView_ViewManager( activeStudy(), desktop() );
1505 new LightApp_GVSelector( (GraphicsView_Viewer*)viewMgr->getViewModel(), mySelMgr );
1508 #ifndef DISABLE_PVVIEWER
1509 if( vmType == PVViewer_Viewer::Type() )
1511 if ( viewMgr = dynamic_cast<PVViewer_ViewManager*>( getViewManager( vmType, false ) ) ) {
1512 viewMgr->getActiveView()->setFocus();
1515 viewMgr = new PVViewer_ViewManager( activeStudy(), desktop(), logWindow() );
1519 #ifndef DISABLE_PYVIEWER
1520 if( vmType == PyViewer_Viewer::Type() )
1522 viewMgr = new PyViewer_ViewManager( activeStudy(), desktop() );
1525 #ifndef DISABLE_OCCVIEWER
1526 if( vmType == OCCViewer_Viewer::Type() )
1528 viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
1529 OCCViewer_Viewer* vm;
1530 #ifndef DISABLE_SALOMEOBJECT
1531 vm = new SOCC_Viewer();
1533 vm = new OCCViewer_Viewer( true );
1535 vm->setBackground( OCCViewer_ViewFrame::TOP_LEFT,
1536 resMgr->backgroundValue( "OCCViewer", "xz_background", vm->background(OCCViewer_ViewFrame::TOP_LEFT) ) );
1537 vm->setBackground( OCCViewer_ViewFrame::TOP_RIGHT,
1538 resMgr->backgroundValue( "OCCViewer", "yz_background", vm->background(OCCViewer_ViewFrame::TOP_RIGHT) ) );
1539 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_LEFT,
1540 resMgr->backgroundValue( "OCCViewer", "xy_background", vm->background(OCCViewer_ViewFrame::BOTTOM_LEFT) ) );
1541 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_RIGHT,
1542 resMgr->backgroundValue( "OCCViewer", "background", vm->background(OCCViewer_ViewFrame::MAIN_VIEW) ) );
1544 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1545 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ));
1546 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1547 vm->setProjectionType( resMgr->integerValue( "OCCViewer", "projection_mode", vm->projectionType() ) );
1548 #if OCC_VERSION_LARGE > 0x06090000
1549 vm->setStereoType( resMgr->integerValue( "OCCViewer", "stereo_type", vm->stereoType() ) );
1550 vm->setAnaglyphFilter( resMgr->integerValue( "OCCViewer", "anaglyph_filter", vm->anaglyphFilter() ) );
1551 vm->setStereographicFocus( resMgr->integerValue( "OCCViewer", "focus_type", vm->stereographicFocusType() ),
1552 resMgr->doubleValue( "OCCViewer", "focus_value", vm->stereographicFocusValue() ));
1553 vm->setInterocularDistance( resMgr->integerValue( "OCCViewer", "iod_type", vm->interocularDistanceType() ),
1554 resMgr->doubleValue( "OCCViewer", "iod_value", vm->interocularDistanceValue() ));
1556 vm->setReverseStereo( resMgr->booleanValue( "OCCViewer", "reverse_stereo", vm->isReverseStereo() ) );
1557 vm->setVSync( resMgr->booleanValue( "OCCViewer", "enable_vsync", vm->isVSync() ) );
1558 vm->setQuadBufferSupport( resMgr->booleanValue( "OCCViewer", "enable_quad_buffer_support", vm->isQuadBufferSupport() ) );
1560 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1561 vm->enablePreselection( resMgr->booleanValue( "OCCViewer", "enable_preselection", vm->isPreselectionEnabled() ) );
1562 vm->enableSelection( resMgr->booleanValue( "OCCViewer", "enable_selection", vm->isSelectionEnabled() ) );
1563 vm->setClippingColor( resMgr->colorValue( "OCCViewer", "clipping_color", vm->clippingColor() ) );
1564 vm->setClippingTextureParams( resMgr->booleanValue( "OCCViewer", "clipping_use_default_texture", vm->isDefaultTextureUsed() ),
1565 resMgr->stringValue( "OCCViewer", "clipping_texture", vm->clippingTexture() ),
1566 resMgr->booleanValue( "OCCViewer", "clipping_modulate", vm->isTextureModulated() ),
1567 resMgr->doubleValue( "OCCViewer", "clipping_scale", vm->clippingTextureScale() ) );
1570 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1571 new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
1574 #ifndef DISABLE_VTKVIEWER
1575 #ifndef DISABLE_SALOMEOBJECT
1576 if ( vmType == SVTK_Viewer::Type() )
1578 if ( vmType == VTKViewer_Viewer::Type() )
1581 #ifndef DISABLE_SALOMEOBJECT
1582 viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
1583 SVTK_Viewer* vm = dynamic_cast<SVTK_Viewer*>( viewMgr->getViewModel() );
1586 vm->setProjectionMode( resMgr->integerValue( "VTKViewer", "projection_mode", vm->projectionMode() ) );
1587 vm->setStereoType( resMgr->integerValue( "VTKViewer", "stereo_type", vm->stereoType() ) );
1588 vm->setAnaglyphFilter( resMgr->integerValue( "VTKViewer", "anaglyph_filter", vm->anaglyphFilter() ) );
1589 vm->setQuadBufferSupport( resMgr->booleanValue( "VTKViewer", "enable_quad_buffer_support", vm->isQuadBufferSupport() ) );
1590 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1591 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1592 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ) );
1593 vm->setStaticTrihedronVisible( resMgr->booleanValue( "3DViewer", "show_static_trihedron", vm->isStaticTrihedronVisible() ) );
1594 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1595 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1596 vm->setPreSelectionMode(resMgr->integerValue( "VTKViewer", "preselection", vm->preSelectionMode() ) );
1597 vm->enableSelection( resMgr->booleanValue( "VTKViewer", "enable_selection", vm->isSelectionEnabled() ) );
1598 vm->setIncrementalSpeed( resMgr->integerValue( "VTKViewer", "speed_value", vm->incrementalSpeed() ),
1599 resMgr->integerValue( "VTKViewer", "speed_mode", vm->incrementalSpeedMode() ) );
1600 vm->setSpacemouseButtons( resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", vm->spacemouseBtn(1) ),
1601 resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", vm->spacemouseBtn(2) ),
1602 resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", vm->spacemouseBtn(3) ) );
1603 new LightApp_VTKSelector( vm, mySelMgr );
1606 viewMgr = new VTKViewer_ViewManager( activeStudy(), desktop() );
1607 VTKViewer_Viewer* vm = dynamic_cast<VTKViewer_Viewer*>( viewMgr->getViewModel() );
1609 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1617 addViewManager( viewMgr );
1618 SUIT_ViewWindow* viewWin = viewMgr->createViewWindow();
1620 if ( viewWin && desktop() ) {
1621 viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1622 viewWin->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1628 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, QWidget* w )
1630 SUIT_ResourceMgr* resMgr = resourceMgr();
1632 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
1634 new LightApp_WgViewModel( vmType, w ) );
1635 vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
1637 addViewManager( vm );
1638 SUIT_ViewWindow* vw = vm->createViewWindow();
1639 if ( vw && desktop() ) {
1640 vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1641 vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1644 if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
1645 myUserWmTypes << vmType;
1650 SUIT_ViewManager* LightApp_Application::createViewManager( SUIT_ViewModel* theModel )
1652 SUIT_ResourceMgr* resMgr = resourceMgr();
1654 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
1658 QString vmType = vm->getType();
1660 vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
1662 addViewManager( vm );
1663 SUIT_ViewWindow* vw = vm->createViewWindow();
1664 if ( vw && desktop() ) {
1665 vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1666 vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1669 if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
1670 myUserWmTypes << vmType;
1676 SLOT: Removes view manager from application
1678 void LightApp_Application::onCloseView( SUIT_ViewManager* theVM )
1680 removeViewManager( theVM );
1684 Protected SLOT: On study created.
1685 \param theStudy - just created study
1687 void LightApp_Application::onStudyCreated( SUIT_Study* theStudy )
1689 SUIT_DataObject* aRoot = 0;
1690 if ( theStudy && theStudy->root() )
1692 aRoot = theStudy->root();
1693 //aRoot->setName( tr( "DATA_MODELS" ) );
1696 getWindow( WT_ObjectBrowser );
1698 loadDockWindowsState();
1700 if ( objectBrowser() )
1701 objectBrowser()->setRoot( aRoot );
1703 activateModule( defaultModule() );
1705 if ( objectBrowser() )
1706 objectBrowser()->openLevels();
1708 #ifndef DISABLE_PYCONSOLE
1709 if( pythonConsole() )
1710 getPyInterp()->initStudy();
1715 Protected SLOT: On study opened.
1716 \param theStudy - just opened study
1718 void LightApp_Application::onStudyOpened( SUIT_Study* theStudy )
1720 SUIT_DataObject* aRoot = 0;
1721 if ( theStudy && theStudy->root() )
1723 aRoot = theStudy->root();
1727 getWindow( WT_ObjectBrowser );
1729 loadDockWindowsState();
1731 if ( objectBrowser() )
1732 objectBrowser()->setRoot( aRoot );
1734 activateModule( defaultModule() );
1736 if ( objectBrowser() )
1737 objectBrowser()->openLevels();
1739 #ifndef DISABLE_PYCONSOLE
1740 if( pythonConsole() )
1741 getPyInterp()->initStudy();
1747 /*!Protected SLOT. On study saved.*/
1748 void LightApp_Application::onStudySaved( SUIT_Study* s )
1750 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
1752 mru->insert( s->studyName() );
1757 /*!Protected SLOT. On study closed.*/
1758 void LightApp_Application::onStudyClosed( SUIT_Study* s )
1761 disconnect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
1762 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
1765 // stop auto-save timer
1766 myAutoSaveTimer->stop();
1768 // Bug 10396: clear selection
1769 mySelMgr->clearSelected();
1771 // Bug 12944: emit signal only after clear selection
1774 activateModule( "" );
1777 /*!Protected SLOT.On desktop activated.*/
1778 void LightApp_Application::onDesktopActivated()
1780 CAM_Application::onDesktopActivated();
1781 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>(activeModule());
1783 aModule->studyActivated();
1786 void LightApp_Application::studyOpened( SUIT_Study* s )
1788 CAM_Application::studyOpened( s );
1791 updateViewManagers();
1794 void LightApp_Application::studySaved( SUIT_Study* s )
1796 CAM_Application::studyOpened( s );
1797 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1798 if ( aResMgr && activeStudy() ) {
1799 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
1800 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
1804 void LightApp_Application::studyCreated( SUIT_Study* s )
1806 CAM_Application::studyCreated( s );
1809 updateViewManagers();
1812 /*!Gets file filter.
1813 *\retval QString "(*.bin)"
1815 QString LightApp_Application::getFileFilter() const
1823 Shows file dialog and return user selected file name
1825 QString LightApp_Application::getFileName( bool open, const QString& initial, const QString& filters,
1826 const QString& caption, QWidget* parent )
1830 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1831 return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
1834 /*! Gets directory*/
1835 QString LightApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
1839 return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true );
1842 /*! Get open file names*/
1843 QStringList LightApp_Application::getOpenFileNames( const QString& initial, const QString& filters,
1844 const QString& caption, QWidget* parent )
1848 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1849 return SUIT_FileDlg::getOpenFileNames( parent, initial, fls, caption, true );
1852 /*!Private SLOT. Update object browser.*/
1853 void LightApp_Application::onRefresh()
1855 updateObjectBrowser( true );
1858 /*!Private SLOT. Update actions after rename object.*/
1859 void LightApp_Application::onRenamed()
1861 activeStudy()->Modified();
1865 // IMN 08.07.2015 : issue 002556: Some stereo outputs are affected by window position.
1866 // To prevent reversion the window should be either aligned during movement and resize.
1867 /*!Private SLOT. Update actions after rename object.*/
1868 /*void LightApp_Application::onMoved()
1870 OCCViewer_ViewManager* viewMgr = 0;
1871 viewMgr = dynamic_cast<OCCViewer_ViewManager*>( getViewManager( OCCViewer_Viewer::Type(), false ) );
1873 OCCViewer_ViewWindow* view = 0;
1874 view = dynamic_cast<OCCViewer_ViewWindow*>( viewMgr->getActiveView() );
1876 view->getViewPort()->repaintViewAfterMove();
1881 /*!Private SLOT. Support drag-and-drop operation.*/
1882 void LightApp_Application::onDropped( const QList<SUIT_DataObject*>& objects, SUIT_DataObject* parent, int row, Qt::DropAction action )
1884 LightApp_DataObject* parentObj = dynamic_cast<LightApp_DataObject*>( parent );
1888 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>( parentObj->module() );
1890 aModule->dropObjects( objects, parentObj, row, action );
1893 /*!Private SLOT. On preferences.*/
1894 void LightApp_Application::onPreferences()
1896 showPreferences( activeModule() ? activeModule()->moduleName() : tr( "PREF_CATEGORY_SALOME" ) );
1899 /*!Private SLOT. On preferences.*/
1900 void LightApp_Application::showPreferences( const QString& itemText )
1902 QApplication::setOverrideCursor( Qt::WaitCursor );
1904 LightApp_PreferencesDlg* prefDlg = new LightApp_PreferencesDlg( preferences( true ), desktop());
1906 QApplication::restoreOverrideCursor();
1911 preferences()->activateItem( itemText );
1913 if ( ( prefDlg->exec() == QDialog::Accepted || prefDlg->isSaved() ) && resourceMgr() )
1916 resourceMgr()->setValue( "desktop", "geometry", desktop()->storeGeometry() );
1917 resourceMgr()->save();
1920 shortcutMgr()->updateShortcuts();
1926 /*!Protected SLOT. On preferences changed.*/
1927 void LightApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param )
1929 LightApp_Module* sMod = 0;
1930 CAM_Module* mod = module( modName );
1931 if ( mod && mod->inherits( "LightApp_Module" ) )
1932 sMod = (LightApp_Module*)mod;
1935 sMod->preferencesChanged( section, param );
1937 preferencesChanged( section, param );
1938 // emit signal to allow additional preferences changing processing
1939 emit preferenceChanged( modName, section, param );
1942 /*!Remove all windows from study.*/
1943 void LightApp_Application::beforeCloseDoc( SUIT_Study* s )
1945 saveDockWindowsState();
1947 if ( SUIT_DataBrowser* ob = objectBrowser() )
1950 CAM_Application::beforeCloseDoc( s );
1953 /*!Update actions.*/
1954 void LightApp_Application::updateActions()
1956 updateCommandsStatus();
1962 SUIT_Study* LightApp_Application::createNewStudy()
1964 LightApp_Application::lastStudyId++;
1966 LightApp_Study* aStudy = new LightApp_Study( this );
1968 // Set up processing of major study-related events
1969 connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
1970 connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
1971 connect( aStudy, SIGNAL( saved ( SUIT_Study* ) ), this, SLOT( onStudySaved ( SUIT_Study* ) ) );
1972 connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
1978 Creates window by flag.
1979 \param flag - identificator of window type
1981 QWidget* LightApp_Application::createWindow( const int flag )
1985 SUIT_ResourceMgr* resMgr = resourceMgr();
1987 if ( flag == WT_ObjectBrowser )
1989 SUIT_DataBrowser* ob = new SUIT_DataBrowser( new LightApp_DataObject(), desktop() );
1990 ob->setObjectName( "objectBrowser" );
1991 ob->setSortMenuEnabled( true );
1992 ob->setAutoUpdate( true );
1993 if ( resMgr->hasValue( "ObjectBrowser", "auto_hide_search_tool" ) )
1994 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
1996 //ob->setAutoOpenLevel( 1 ); // commented by ASV as a fix to bug IPAL10107
1997 ob->setWindowTitle( tr( "OBJECT_BROWSER" ) );
1998 connect( ob, SIGNAL( requestUpdate() ), this, SLOT( onRefresh() ) );
2000 QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
2001 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
2002 treeModel->setSearcher( this );
2003 treeModel->registerColumn( 0, EntryCol, LightApp_DataObject::EntryId );
2004 treeModel->setAppropriate( EntryCol, Qtx::Toggled );
2006 // Mantis issue 0020136: Drag&Drop in OB
2007 SUIT_ProxyModel* proxyModel = dynamic_cast<SUIT_ProxyModel*>(treeModel);
2009 connect( proxyModel, SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
2010 this, SLOT( onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
2011 connect( proxyModel, SIGNAL( renamed( SUIT_DataObject* ) ),
2012 this, SLOT( onRenamed( ) ) );
2016 // temporary commented
2018 OB_ListView* ob_list = dynamic_cast<OB_ListView*>( const_cast<QListView*>( ob->listView() ) );
2020 ob_list->setColumnMaxWidth( 0, desktop()->width()/4 );
2023 // Create OBSelector
2024 new LightApp_OBSelector( ob, mySelMgr );
2025 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
2026 ob->treeView()->header()->setResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
2028 ob->treeView()->header()->setSectionResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
2030 ob->treeView()->header()->moveSection(SUIT_DataObject::NameId,SUIT_DataObject::VisibilityId);
2031 ob->treeView()->setColumnWidth(SUIT_DataObject::VisibilityId, VISIBILITY_COLUMN_WIDTH);
2032 ob->setProperty( "shortcut", QKeySequence( "Alt+Shift+O" ) );
2034 ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
2036 #ifndef DISABLE_PYCONSOLE
2037 else if ( flag == WT_PyConsole )
2039 PyConsole_Console* pyCons = new PyConsole_Console( desktop(), new LightApp_PyEditor( getPyInterp() ) );
2040 pyCons->setObjectName( "pythonConsole" );
2041 pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
2042 pyCons->setFont( resMgr->fontValue( "PyConsole", "font" ) );
2043 pyCons->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
2044 pyCons->setAutoCompletion( resMgr->booleanValue( "PyConsole", "auto_completion", true ) );
2045 pyCons->setProperty( "shortcut", QKeySequence( "Alt+Shift+P" ) );
2049 else if ( flag == WT_LogWindow )
2051 LogWindow* logWin = new LogWindow( desktop() );
2052 logWin->setObjectName( "logWindow" );
2053 logWin->setWindowTitle( tr( "LOG_WINDOW" ) );
2054 logWin->setProperty( "shortcut", QKeySequence( "Alt+Shift+L" ) );
2056 logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
2062 \return default windows( Object Browser, Python Console )
2063 Adds to map \a aMap.
2065 void LightApp_Application::defaultWindows( QMap<int, int>& aMap ) const
2067 #ifndef DISABLE_PYCONSOLE
2068 aMap.insert( WT_PyConsole, Qt::BottomDockWidgetArea );
2070 if ( activeStudy() ) {
2071 aMap.insert( WT_ObjectBrowser, Qt::LeftDockWidgetArea );
2072 // aMap.insert( WT_LogWindow, Qt::DockBottom );
2076 /*!Default view managers*/
2077 void LightApp_Application::defaultViewManagers( QStringList& ) const
2083 \return preferences.
2084 Create preferences, if \a crt = true.
2086 LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const
2091 LightApp_Application* that = (LightApp_Application*)this;
2093 bool toCreate = !_prefs_ && crt;
2096 _prefs_ = new LightApp_Preferences( resourceMgr() );
2097 that->createPreferences( _prefs_ );
2100 that->myPrefs = _prefs_;
2102 connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
2103 this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ), Qt::UniqueConnection );
2104 connect( myPrefs, SIGNAL( resetToDefaults() ),
2105 this, SIGNAL( preferenceResetToDefaults() ), Qt::UniqueConnection );
2110 SUIT_ResourceMgr* resMgr = resourceMgr();
2112 QList<SUIT_Application*> appList = SUIT_Session::session()->applications();
2113 for ( QList<SUIT_Application*>::iterator appIt = appList.begin(); appIt != appList.end(); ++appIt )
2115 LightApp_Application* app = ::qobject_cast<LightApp_Application*>( *appIt );
2119 QStringList modNameList;
2120 app->modules( modNameList, false );
2122 QMap<QString, QString> iconMap;
2123 app->moduleIconNames( iconMap );
2125 for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it )
2127 if ( !app->isLibExists( *it ) || _prefs_->hasModule( *it ) )
2130 int modId = _prefs_->addPreference( *it );
2131 if ( iconMap.contains( *it ) )
2132 _prefs_->setItemIcon( modId, Qtx::scaleIcon( resMgr->loadPixmap( moduleName( *it ), iconMap[*it], false ), 20 ) );
2136 app->modules( modList );
2137 QListIterator<CAM_Module*> itr( modList );
2138 while ( itr.hasNext() )
2140 LightApp_Module* mod = 0;
2142 CAM_Module* anItem = itr.next();
2143 if ( anItem->inherits( "LightApp_Module" ) )
2144 mod = (LightApp_Module*)anItem;
2146 if ( mod && !_prefs_->hasModule( mod->moduleName() ) )
2148 _prefs_->addPreference( mod->moduleName() );
2149 mod->createPreferences();
2150 that->emptyPreferences( mod->moduleName() );
2154 _prefs_->setItemProperty( "info", tr( "PREFERENCES_NOT_LOADED" ) );
2160 Adds new module to application
2162 void LightApp_Application::moduleAdded( CAM_Module* mod )
2164 CAM_Application::moduleAdded( mod );
2166 LightApp_Module* lightMod = 0;
2167 if ( mod && mod->inherits( "LightApp_Module" ) )
2168 lightMod = (LightApp_Module*)mod;
2170 if ( myPrefs && lightMod && !myPrefs->hasModule( lightMod->moduleName() ))
2172 myPrefs->addPreference( mod->moduleName() );
2173 lightMod->createPreferences();
2174 emptyPreferences( mod->moduleName() );
2178 void LightApp_Application::emptyPreferences( const QString& modName )
2180 QtxPreferenceItem* item = myPrefs->findItem( modName, true );
2181 if ( !item || !item->isEmpty() )
2184 // printf( "---------------------> Modify for empty module.\n" );
2186 QtxPagePrefFrameItem* frm = new QtxPagePrefFrameItem( item->title(), item->parentItem() );
2187 frm->setIcon( item->icon() );
2188 frm->setStretch( false );
2189 item->parentItem()->insertItem( frm, item );
2190 new QtxPagePrefLabelItem( Qt::AlignCenter, tr( "PREFERENCES_NOT_SUPPORTED" ).arg( modName ), frm );
2197 void LightApp_Application::createPreferences( LightApp_Preferences* pref )
2202 QStringList aValuesList;
2203 QList<QVariant> anIndicesList;
2207 // . Top-level "SALOME" preferences group <<start>>
2208 int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
2209 pref->setItemIcon( salomeCat, Qtx::scaleIcon( resourceMgr()->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false ), 20 ) );
2211 // .. "General" preferences tab <<start>>
2212 int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat );
2214 // ... "Language" group <<start>>
2215 int langGroup = pref->addPreference( tr( "PREF_GROUP_LANGUAGE" ), genTab );
2216 pref->setItemProperty( "columns", 2, langGroup );
2217 // .... -> application language
2218 int curLang = pref->addPreference( tr( "PREF_CURRENT_LANGUAGE" ), langGroup,
2219 LightApp_Preferences::Selector, "language", "language" );
2220 QStringList aLangs = SUIT_Session::session()->resourceMgr()->stringValue( "language", "languages", "en" ).split( "," );
2221 QList<QVariant> aIcons;
2222 foreach ( QString aLang, aLangs ) {
2223 aIcons << QPixmap( QString( ":/images/%1" ).arg( aLang ) );
2225 pref->setItemProperty( "strings", aLangs, curLang );
2226 pref->setItemProperty( "icons", aIcons, curLang );
2227 pref->setItemProperty( "restart", true, curLang );
2229 int curLocale = pref->addPreference( tr( "PREF_CURRENT_LOCALE" ), langGroup,
2230 LightApp_Preferences::Bool, "language", "locale" );
2231 pref->setItemProperty( "restart", true, curLocale );
2232 // ... "Language" group <<end>>
2234 // ... "Look and feel" group <<start>>
2235 int lookGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), genTab );
2236 pref->setItemProperty( "columns", 2, lookGroup );
2237 // .... -> show splash-screen
2238 pref->addPreference( tr( "PREF_SHOW_SPLASH" ), lookGroup, LightApp_Preferences::Bool, "launch", "splash" );
2239 // .... -> opaque resize
2240 pref->addPreference( tr( "PREF_OPAQUE_RESIZE" ), lookGroup, LightApp_Preferences::Bool, "desktop", "opaque_resize" );
2241 // .... -> drop-down buttons
2242 pref->addPreference( tr( "PREF_DROP_DOWN_BUTTONS" ), lookGroup, LightApp_Preferences::Bool, "viewers", "drop_down_buttons" );
2243 // ... "Look and feel" group <<end>>
2245 // ... "Study properties" group <<start>>
2246 int studyGroup = pref->addPreference( tr( "PREF_GROUP_STUDY" ), genTab );
2247 pref->setItemProperty( "columns", 2, studyGroup );
2248 // .... -> multi-file save
2249 pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "multi_file" );
2250 // .... -> ascii save mode
2251 pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" );
2252 // .... -> store windows geometry
2253 pref->addPreference( tr( "PREF_LOAD_LIGHT" ), studyGroup, LightApp_Preferences::Bool, "Study", "autoload_light_modules" );
2254 pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" );
2255 pref->addPreference( "", studyGroup, LightApp_Preferences::Space );
2256 pref->addPreference( tr( "PREF_STORE_TOOL_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_tool_positions" );
2257 // .... -> auto-save
2258 int autoSaveInterval = pref->addPreference( tr( "PREF_AUTO_SAVE" ), studyGroup,
2259 LightApp_Preferences::IntSpin, "Study", "auto_save_interval" );
2260 pref->setItemProperty( "min", 0, autoSaveInterval );
2261 pref->setItemProperty( "max", 1440, autoSaveInterval );
2262 pref->setItemProperty( "special", tr( "PREF_AUTO_SAVE_DISABLED" ), autoSaveInterval );
2263 // ... "Study properties" group <<end>>
2265 // ... "Help browser" group <<start>>
2266 int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab, LightApp_Preferences::Auto, "ExternalBrowser", "use_external_browser");
2268 QString platform = "winapplication";
2270 QString platform = "application";
2272 // .... -> browser application
2273 int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, LightApp_Preferences::File, "ExternalBrowser", platform );
2274 pref->setItemProperty( "mode", Qtx::PT_OpenFile, apppref );
2275 // .... -> browser parameters
2276 pref->addPreference( tr( "PREF_PARAM" ), extgroup, LightApp_Preferences::String, "ExternalBrowser", "parameters" );
2277 // ... "Help browser" group <<end>>
2279 // ... "Python console properties" group <<start>>
2280 int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab );
2281 pref->setItemProperty( "columns", 2, pythonConsoleGroup );
2283 pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, LightApp_Preferences::Font, "PyConsole", "font" );
2284 // .... -> show banner
2285 pref->addPreference( tr( "PREF_SHOW_BANNER" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "show_banner" );
2286 // .... -> auto-completion
2287 pref->addPreference( tr( "PREF_AUTO_COMPLETION" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "auto_completion" );
2288 // ... "Python console properties" group <<end>>
2290 // ... "MRU" preferences group <<start>>
2291 int mruGroup = pref->addPreference( tr( "PREF_GROUP_MRU" ), genTab, LightApp_Preferences::Auto, "MRU", "show_mru" );
2292 pref->setItemProperty( "columns", 4, mruGroup );
2293 // number of MRU items
2294 int mruVisCount = pref->addPreference( tr( "PREF_MRU_VISIBLE_COUNT" ), mruGroup, LightApp_Preferences::IntSpin,
2295 "MRU", "visible_count" );
2296 pref->setItemProperty( "min", 0, mruVisCount );
2297 pref->setItemProperty( "max", 100, mruVisCount );
2299 int mruLinkType = pref->addPreference( tr( "PREF_MRU_LINK_TYPE" ), mruGroup, LightApp_Preferences::Selector,
2300 "MRU", "link_type" );
2301 aValuesList.clear();
2302 anIndicesList.clear();
2303 aValuesList << tr("PREF_MRU_LINK_AUTO") << tr("PREF_MRU_LINK_SHORT") << tr("PREF_MRU_LINK_FULL");
2304 anIndicesList << 0 << 1 << 2 ;
2305 pref->setItemProperty( "strings", aValuesList, mruLinkType );
2306 pref->setItemProperty( "indexes", anIndicesList, mruLinkType );
2307 // ... "MRU" preferences group <<end>>
2309 // ... "Full-screen" group <<start>>
2310 int fullScreenGroup = pref->addPreference( tr( "PREF_GROUP_FULL_SCREEN" ), genTab );
2311 pref->setItemProperty( "columns", 2, fullScreenGroup );
2312 // .... -> automatic hiding toolbars
2313 pref->addPreference( tr( "PREF_FULL_SCREEN_AUTO" ), fullScreenGroup,
2314 LightApp_Preferences::Bool, "OCCViewer", "automatic_hiding" );
2315 // ... "Full-screen" group <<end>>
2317 // .. "General" preferences tab <<end>>
2319 // .. "3D viewer" group <<start>>
2320 int Viewer3DGroup = pref->addPreference( tr( "PREF_GROUP_3DVIEWER" ), salomeCat );
2321 // ... -> navigation mode
2322 int vtkStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), Viewer3DGroup,
2323 LightApp_Preferences::Selector, "3DViewer", "navigation_mode" );
2324 aValuesList.clear();
2325 anIndicesList.clear();
2326 aValuesList << tr("PREF_STANDARD_STYLE") << tr("PREF_KEYFREE_STYLE");
2327 anIndicesList << 0 << 1;
2328 pref->setItemProperty( "strings", aValuesList, vtkStyleMode );
2329 pref->setItemProperty( "indexes", anIndicesList, vtkStyleMode );
2330 // ... -> zooming mode
2331 int occZoomingStyleMode = pref->addPreference( tr( "PREF_ZOOMING" ), Viewer3DGroup,
2332 LightApp_Preferences::Selector, "3DViewer", "zooming_mode" );
2333 aValuesList.clear();
2334 anIndicesList.clear();
2335 aValuesList << tr("PREF_ZOOMING_AT_CENTER") << tr("PREF_ZOOMING_AT_CURSOR");
2336 anIndicesList << 0 << 1;
2337 pref->setItemProperty( "strings", aValuesList, occZoomingStyleMode );
2338 pref->setItemProperty( "indexes", anIndicesList, occZoomingStyleMode );
2339 // ... "Trihedron" group <<start>>
2340 int occTriGroup = pref->addPreference( tr( "PREF_TRIHEDRON" ), Viewer3DGroup );
2341 pref->setItemProperty( "columns", 2, occTriGroup );
2342 // .... -> trihedron size
2343 int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occTriGroup,
2344 LightApp_Preferences::DblSpin, "3DViewer", "trihedron_size" );
2345 pref->setItemProperty( "min", 1.0E-06, occTS );
2346 pref->setItemProperty( "max", 1000, occTS );
2347 // .... -> relative size of trihedron
2348 pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "relative_size" );
2349 // .... -> show static trihedron
2350 pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "show_static_trihedron" );
2351 // ... "Trihedron" group <<end>>
2352 // .. "3D viewer" group <<end>>
2356 #ifndef DISABLE_OCCVIEWER
2357 // .. "OCC viewer" group <<start>>
2358 int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), salomeCat );
2360 // .... -> Projection mode
2361 int occProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), occGroup,
2362 LightApp_Preferences::Selector, "OCCViewer", "projection_mode" );
2363 aValuesList.clear();
2364 anIndicesList.clear();
2365 aValuesList << tr("PREF_ORTHOGRAPHIC") << tr("PREF_PERSPECTIVE");
2366 anIndicesList << 0 << 1;
2367 pref->setItemProperty( "strings", aValuesList, occProjMode );
2368 pref->setItemProperty( "indexes", anIndicesList, occProjMode );
2369 #if OCC_VERSION_LARGE > 0x06090000
2370 // .... -> Stereo group
2371 int stereoGroup = pref->addPreference( tr( "PREF_GROUP_STEREO" ), occGroup);
2372 pref->setItemProperty( "columns", 2, stereoGroup );
2373 // .... -> Stereo type
2374 int stereoType = pref->addPreference( tr( "PREF_STEREO_TYPE" ), stereoGroup,
2375 LightApp_Preferences::Selector, "OCCViewer", "stereo_type" );
2376 aValuesList.clear();
2377 anIndicesList.clear();
2379 OCCViewer_Viewer::stereoData( aValuesList, idList);
2380 foreach( int gid, idList ) anIndicesList << gid;
2381 pref->setItemProperty( "strings", aValuesList, stereoType );
2382 pref->setItemProperty( "indexes", anIndicesList, stereoType );
2384 // .... -> Anaglyph filter
2385 int anaglyphFilter = pref->addPreference( tr( "PREF_ANAGLYPH_FILTER" ), stereoGroup,
2386 LightApp_Preferences::Selector, "OCCViewer", "anaglyph_filter" );
2387 aValuesList.clear();
2388 anIndicesList.clear();
2389 aValuesList << tr("PREF_ANAGLYPH_RED_CYAN") << tr("PREF_ANAGLYPH_YELLOW_BLUE") << tr("PREF_ANAGLYPH_GREEN_MAGENTA");
2390 anIndicesList << 0 << 1 << 2;
2392 pref->setItemProperty( "strings", aValuesList, anaglyphFilter );
2393 pref->setItemProperty( "indexes", anIndicesList, anaglyphFilter );
2395 // .... -> Convergence distance type
2396 int occFocusType = pref->addPreference( tr( "PREF_FOCUS_TYPE" ), stereoGroup,
2397 LightApp_Preferences::Selector, "OCCViewer", "focus_type" );
2398 aValuesList.clear();
2399 anIndicesList.clear();
2400 aValuesList << tr("PREF_ABSOLUTE") << tr("PREF_RELATIVE");
2401 anIndicesList << 0 << 1;
2402 pref->setItemProperty( "strings", aValuesList, occFocusType );
2403 pref->setItemProperty( "indexes", anIndicesList, occFocusType );
2405 // .... -> Stereographic focus value
2406 int focusValue = pref->addPreference( tr( "PREF_FOCUS_VALUE" ), stereoGroup,
2407 LightApp_Preferences::DblSpin, "OCCViewer", "focus_value" );
2408 pref->setItemProperty( "precision", 3, focusValue );
2409 pref->setItemProperty( "min", 1.0E-03, focusValue );
2410 pref->setItemProperty( "max", 1.0E03, focusValue );
2411 pref->setItemProperty( "step", 0.05, focusValue );
2414 int occIODType = pref->addPreference( tr( "PREF_IOD_TYPE" ), stereoGroup,
2415 LightApp_Preferences::Selector, "OCCViewer", "iod_type" );
2416 aValuesList.clear();
2417 anIndicesList.clear();
2418 aValuesList << tr("PREF_ABSOLUTE") << tr("PREF_RELATIVE");
2419 anIndicesList << 0 << 1;
2420 pref->setItemProperty( "strings", aValuesList, occIODType );
2421 pref->setItemProperty( "indexes", anIndicesList, occIODType );
2423 // .... -> Interocular distance (IOD) value
2424 int IODValue = pref->addPreference( tr( "PREF_IOD_VALUE" ), stereoGroup,
2425 LightApp_Preferences::DblSpin, "OCCViewer", "iod_value" );
2426 pref->setItemProperty( "precision", 3, IODValue );
2427 pref->setItemProperty( "min", 1.0E-03, IODValue );
2428 pref->setItemProperty( "max", 1.0E03, IODValue );
2429 pref->setItemProperty( "step", 0.05, IODValue );
2431 // .... -> Reverse stereo
2432 pref->addPreference( tr( "PREF_REVERSE_STEREO" ), stereoGroup,
2433 LightApp_Preferences::Bool, "OCCViewer", "reverse_stereo" );
2434 // .... -> Enable V-Sync
2435 pref->addPreference( tr( "PREF_ENABLE_VSYNC" ), stereoGroup,
2436 LightApp_Preferences::Bool, "OCCViewer", "enable_vsync" );
2437 // .... -> Enable quad-buffer support
2438 pref->addPreference( tr( "PREF_ENABLE_QUAD_BUFFER_SUPPORT" ), stereoGroup,
2439 LightApp_Preferences::Bool, "OCCViewer", "enable_quad_buffer_support" );
2441 // ... "Background" group <<start>>
2442 int bgGroup = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup );
2443 // pref->setItemProperty( "columns", 2, bgGroup );
2444 aValuesList.clear();
2445 anIndicesList.clear();
2448 formats = OCCViewer_Viewer::backgroundData( aValuesList, idList, txtList );
2449 foreach( int gid, idList ) anIndicesList << gid;
2450 // .... -> 3D viewer background
2451 bgId = pref->addPreference( tr( "PREF_3DVIEWER_BACKGROUND" ), bgGroup,
2452 LightApp_Preferences::Background, "OCCViewer", "background" );
2453 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2454 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2455 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2456 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2457 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2458 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2459 pref->setItemProperty( "custom_enabled", false, bgId );
2460 pref->setItemProperty( "image_formats", formats, bgId );
2461 // .... -> XZ viewer background
2462 bgId = pref->addPreference( tr( "PREF_XZVIEWER_BACKGROUND" ), bgGroup,
2463 LightApp_Preferences::Background, "OCCViewer", "xz_background" );
2464 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2465 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2466 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2467 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2468 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2469 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2470 pref->setItemProperty( "custom_enabled", false, bgId );
2471 pref->setItemProperty( "image_formats", formats, bgId );
2472 // .... -> YZ viewer background
2473 bgId = pref->addPreference( tr( "PREF_YZVIEWER_BACKGROUND" ), bgGroup,
2474 LightApp_Preferences::Background, "OCCViewer", "yz_background" );
2475 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2476 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2477 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2478 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2479 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2480 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2481 pref->setItemProperty( "custom_enabled", false, bgId );
2482 pref->setItemProperty( "image_formats", formats, bgId );
2483 // .... -> XY viewer background
2484 bgId = pref->addPreference( tr( "PREF_XYVIEWER_BACKGROUND" ), bgGroup,
2485 LightApp_Preferences::Background, "OCCViewer", "xy_background" );
2486 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2487 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2488 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2489 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2490 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2491 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2492 pref->setItemProperty( "custom_enabled", false, bgId );
2493 pref->setItemProperty( "image_formats", formats, bgId );
2494 // ... "Background" group <<end>>
2497 // ... "Selection" group <<start>>
2498 int occSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), occGroup );
2499 pref->setItemProperty( "columns", 2, occSelectionGroup );
2500 // .... -> enable preselection
2501 pref->addPreference( tr( "PREF_ENABLE_PRESELECTION" ), occSelectionGroup,
2502 LightApp_Preferences::Bool, "OCCViewer", "enable_preselection" );
2503 // .... -> enable selection
2504 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), occSelectionGroup,
2505 LightApp_Preferences::Bool, "OCCViewer", "enable_selection" );
2506 // ... "Selection" group <<end>>
2508 // ... "Clipping" group <<start>>
2509 int occClippingGroup = pref->addPreference( tr( "PREF_GROUP_CLIPPING" ), occGroup );
2510 // .... -> clipping color
2511 pref->addPreference( tr( "PREF_CLIPPING_COLOR" ), occClippingGroup,
2512 LightApp_Preferences::Color, "OCCViewer", "clipping_color" );
2513 int texturePref = pref->addPreference( "", occClippingGroup, LightApp_Preferences::Frame );
2514 pref->setItemProperty( "columns", 2, texturePref );
2515 // .... -> use default texture
2516 pref->addPreference( tr( "PREF_CLIPPING_DEFAULT_TEXTURE" ), texturePref,
2517 LightApp_Preferences::Bool, "OCCViewer", "clipping_use_default_texture" );
2518 // .... -> clipping texture
2519 int filePref = pref->addPreference( tr( "PREF_CLIPPING_TEXTURE" ), texturePref,
2520 LightApp_Preferences::File, "OCCViewer", "clipping_texture" );
2521 pref->setItemProperty( "path_filter", tr( "OCC_TEXTURE_FILES" ), filePref );
2523 pref->addPreference( tr( "PREF_CLIPPING_MODULATE" ), texturePref,
2524 LightApp_Preferences::Bool, "OCCViewer", "clipping_modulate" );
2525 // .... -> scale factor
2526 int scaleFactor = pref->addPreference( tr( "PREF_CLIPPING_SCALE" ), texturePref,
2527 LightApp_Preferences::DblSpin, "OCCViewer", "clipping_scale" );
2528 pref->setItemProperty( "precision", 3, scaleFactor );
2529 pref->setItemProperty( "min", 1.0E-03, scaleFactor );
2530 pref->setItemProperty( "max", 1.0E03, scaleFactor );
2531 pref->setItemProperty( "step", 0.1, scaleFactor );
2532 // ... "Clipping" group <<end>>
2534 // ... "Ray tracing" group <<start>>
2535 int occRayTracingGroup = pref->addPreference( tr( "PREF_GROUP_RAY_TRACING" ), occGroup );
2536 int rtPref = pref->addPreference( "", occRayTracingGroup, LightApp_Preferences::Frame );
2537 pref->setItemProperty( "columns", 2, rtPref );
2539 int rt_depth = pref->addPreference( tr( "PREF_RAY_TRACING_DEPTH" ), rtPref,
2540 LightApp_Preferences::IntSpin, "OCCViewer", "rt_depth" );
2541 pref->setItemProperty( "min", 1, rt_depth );
2542 pref->setItemProperty( "max", 10, rt_depth );
2543 pref->setItemProperty( "step", 1, rt_depth );
2544 pref->addPreference( "", rtPref, LightApp_Preferences::Frame );
2545 // .... -> specular reflections
2546 pref->addPreference( tr( "PREF_RAY_TRACING_REFLECTION" ), rtPref,
2547 LightApp_Preferences::Bool, "OCCViewer", "rt_reflection" );
2548 // .... -> adaptive anti-aliasing
2549 pref->addPreference( tr( "PREF_RAY_TRACING_ANTIALIASING" ), rtPref,
2550 LightApp_Preferences::Bool, "OCCViewer", "rt_antialiasing" );
2551 // .... -> shadows rendering
2552 pref->addPreference( tr( "PREF_RAY_TRACING_SHADOW" ), rtPref,
2553 LightApp_Preferences::Bool, "OCCViewer", "rt_shadow" );
2554 // .... -> transparent shadow
2555 pref->addPreference( tr( "PREF_RAY_TRACING_TRANS_SHADOW" ), rtPref,
2556 LightApp_Preferences::Bool, "OCCViewer", "rt_trans_shadow" );
2557 // ... "Ray tracing" group <<end>>
2559 // ... "Light source" group <<start>>
2560 int occLightGroup = pref->addPreference( tr( "PREF_GROUP_LIGHT" ), occGroup );
2561 // .... -> light color
2562 pref->addPreference( tr( "PREF_LIGHT_COLOR" ), occLightGroup,
2563 LightApp_Preferences::Color, "OCCViewer", "light_color" );
2564 int directionPref = pref->addPreference( "", occLightGroup, LightApp_Preferences::Frame );
2565 pref->setItemProperty( "columns", 3, directionPref );
2566 // .... -> light direction (dx component)
2567 int light_dx = pref->addPreference( tr( "Dx" ), directionPref,
2568 LightApp_Preferences::DblSpin, "OCCViewer", "light_dx" );
2569 pref->setItemProperty( "precision", 2, light_dx );
2570 pref->setItemProperty( "min", -1.0E03, light_dx );
2571 pref->setItemProperty( "max", 1.0E03, light_dx );
2572 pref->setItemProperty( "step", 0.1, light_dx );
2573 // .... -> light direction (dy component)
2574 int light_dy = pref->addPreference( tr( "Dy" ), directionPref,
2575 LightApp_Preferences::DblSpin, "OCCViewer", "light_dy" );
2576 pref->setItemProperty( "precision", 2, light_dy );
2577 pref->setItemProperty( "min", -1.0E03, light_dy );
2578 pref->setItemProperty( "max", 1.0E03, light_dy );
2579 pref->setItemProperty( "step", 0.1, light_dy );
2580 // .... -> light direction (dz component)
2581 int light_dz = pref->addPreference( tr( "Dz" ), directionPref,
2582 LightApp_Preferences::DblSpin, "OCCViewer", "light_dz" );
2583 pref->setItemProperty( "precision", 2, light_dz );
2584 pref->setItemProperty( "min", -1.0E03, light_dz );
2585 pref->setItemProperty( "max", 1.0E03, light_dz );
2586 pref->setItemProperty( "step", 0.1, light_dz );
2587 // ... "Light source" group <<end>>
2589 // ... -> empty frame (for layout) <<start>>
2590 int occGen = pref->addPreference( "", occGroup, LightApp_Preferences::Frame );
2591 pref->setItemProperty( "margin", 0, occGen );
2592 pref->setItemProperty( "columns", 2, occGen );
2593 // ... -> empty frame (for layout) <<end>>
2595 // .. "OCC viewer" group <<end>>
2598 #ifndef DISABLE_VTKVIEWER
2599 // .. "VTK viewer" group <<start>>
2600 int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), salomeCat ); //viewTab
2602 // ... -> empty frame (for layout) <<start>>
2603 int vtkGen = pref->addPreference( "", vtkGroup, LightApp_Preferences::Frame );
2604 //pref->setItemProperty( "columns", 2, vtkGen );
2605 // .... -> projection mode
2606 int vtkProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), vtkGen,
2607 LightApp_Preferences::Selector, "VTKViewer", "projection_mode" );
2608 aValuesList.clear();
2609 anIndicesList.clear();
2610 aValuesList << tr("PREF_ORTHOGRAPHIC") << tr("PREF_PERSPECTIVE");
2611 anIndicesList << 0 << 1;
2612 pref->setItemProperty( "strings", aValuesList, vtkProjMode );
2613 pref->setItemProperty( "indexes", anIndicesList, vtkProjMode );
2615 // .... -> Stereo group
2616 int vtkStereoGroup = pref->addPreference( tr( "PREF_GROUP_STEREO" ), vtkGroup);
2617 pref->setItemProperty( "columns", 2, vtkStereoGroup );
2618 // .... -> Stereo type
2619 int vtkStereoType = pref->addPreference( tr( "PREF_STEREO_TYPE" ), vtkStereoGroup,
2620 LightApp_Preferences::Selector, "VTKViewer", "stereo_type" );
2621 aValuesList.clear();
2622 anIndicesList.clear();
2624 SVTK_Viewer::stereoData( aValuesList, idList);
2625 foreach( int gid, idList ) anIndicesList << gid;
2626 pref->setItemProperty( "strings", aValuesList, vtkStereoType );
2627 pref->setItemProperty( "indexes", anIndicesList, vtkStereoType );
2628 // .... -> Anaglyph filter
2629 int vtkAnaglyphFilter = pref->addPreference( tr( "PREF_ANAGLYPH_FILTER" ), vtkStereoGroup,
2630 LightApp_Preferences::Selector, "VTKViewer", "anaglyph_filter" );
2631 aValuesList.clear();
2632 anIndicesList.clear();
2633 aValuesList << tr("PREF_ANAGLYPH_RED_CYAN") << tr("PREF_ANAGLYPH_YELLOW_BLUE") << tr("PREF_ANAGLYPH_GREEN_MAGENTA");
2634 anIndicesList << 0 << 1 << 2;
2636 pref->setItemProperty( "strings", aValuesList, vtkAnaglyphFilter );
2637 pref->setItemProperty( "indexes", anIndicesList, vtkAnaglyphFilter );
2639 // .... -> Enable quad-buffer support
2640 pref->addPreference( tr( "PREF_ENABLE_QUAD_BUFFER_SUPPORT" ), vtkStereoGroup,
2641 LightApp_Preferences::Bool, "VTKViewer", "enable_quad_buffer_support" );
2643 // .... -> background
2644 aValuesList.clear();
2645 anIndicesList.clear();
2648 #ifndef DISABLE_SALOMEOBJECT
2649 formats = SVTK_Viewer::backgroundData( aValuesList, idList, txtList );
2651 foreach( int gid, idList ) anIndicesList << gid;
2652 bgId = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGen,
2653 LightApp_Preferences::Background, "VTKViewer", "background" );
2654 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2655 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2656 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2657 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2658 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2659 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2660 pref->setItemProperty( "custom_enabled", false, bgId );
2661 #ifndef DISABLE_SALOMEOBJECT
2662 pref->setItemProperty( "image_formats", formats, bgId );
2664 // .... -> speed increment
2665 int vtkSpeed = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED" ), vtkGen,
2666 LightApp_Preferences::IntSpin, "VTKViewer", "speed_value" );
2667 pref->setItemProperty( "min", 1, vtkSpeed );
2668 pref->setItemProperty( "max", 1000, vtkSpeed );
2669 // .... -> speed mode
2670 int vtkSpeedMode = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED_MODE" ), vtkGen,
2671 LightApp_Preferences::Selector, "VTKViewer", "speed_mode" );
2672 aValuesList.clear();
2673 anIndicesList.clear();
2674 aValuesList << tr("PREF_ARITHMETIC") << tr("PREF_GEOMETRICAL");
2675 anIndicesList << 0 << 1;
2676 pref->setItemProperty( "strings", aValuesList, vtkSpeedMode );
2677 pref->setItemProperty( "indexes", anIndicesList, vtkSpeedMode );
2679 // ... "Selection" group <<start>>
2680 int vtkSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), vtkGroup );
2681 pref->setItemProperty( "columns", 2, vtkSelectionGroup );
2682 // .... -> preselection
2683 int vtkPreselection = pref->addPreference( tr( "PREF_PRESELECTION" ), vtkSelectionGroup,
2684 LightApp_Preferences::Selector, "VTKViewer", "preselection" );
2685 aValuesList.clear();
2686 anIndicesList.clear();
2687 aValuesList << tr("PREF_PRESELECTION_STANDARD") << tr("PREF_PRESELECTION_DYNAMIC") << tr("PREF_PRESELECTION_DISABLED");
2688 anIndicesList << 0 << 1 << 2;
2689 pref->setItemProperty( "strings", aValuesList, vtkPreselection );
2690 pref->setItemProperty( "indexes", anIndicesList, vtkPreselection );
2691 // .... -> enable selection
2692 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), vtkSelectionGroup, LightApp_Preferences::Bool, "VTKViewer", "enable_selection" );
2693 // ... "Selection" group <<end>>
2695 // ... -> empty frame (for layout) <<end>>
2697 // ... space mouse sub-group <<start>>
2698 int vtkSM = pref->addPreference( tr( "PREF_FRAME_SPACEMOUSE" ), vtkGroup, LightApp_Preferences::GroupBox );
2699 //pref->setItemProperty( "columns", 2, vtkSM );
2700 // .... -> decrease speed increment
2701 int spacemousePref1 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_1" ), vtkSM,
2702 LightApp_Preferences::Selector, "VTKViewer",
2703 "spacemouse_func1_btn" );
2704 // .... -> increase speed increment
2705 int spacemousePref2 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_2" ), vtkSM,
2706 LightApp_Preferences::Selector, "VTKViewer",
2707 "spacemouse_func2_btn" );
2708 // .... -> dominant / combined switch
2709 int spacemousePref3 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_3" ), vtkSM,
2710 LightApp_Preferences::Selector, "VTKViewer",
2711 "spacemouse_func5_btn" ); //
2712 aValuesList.clear();
2713 anIndicesList.clear();
2714 aValuesList << tr( "PREF_SPACEMOUSE_BTN_1" ) << tr( "PREF_SPACEMOUSE_BTN_2" ) << tr( "PREF_SPACEMOUSE_BTN_3" );
2715 aValuesList << tr( "PREF_SPACEMOUSE_BTN_4" ) << tr( "PREF_SPACEMOUSE_BTN_5" ) << tr( "PREF_SPACEMOUSE_BTN_6" );
2716 aValuesList << tr( "PREF_SPACEMOUSE_BTN_7" ) << tr( "PREF_SPACEMOUSE_BTN_8" ) << tr( "PREF_SPACEMOUSE_BTN_*" );
2717 aValuesList << tr( "PREF_SPACEMOUSE_BTN_10" ) << tr( "PREF_SPACEMOUSE_BTN_11" );
2718 anIndicesList << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11;
2719 pref->setItemProperty( "strings", aValuesList, spacemousePref1 );
2720 pref->setItemProperty( "indexes", anIndicesList, spacemousePref1 );
2721 pref->setItemProperty( "strings", aValuesList, spacemousePref2 );
2722 pref->setItemProperty( "indexes", anIndicesList, spacemousePref2 );
2723 pref->setItemProperty( "strings", aValuesList, spacemousePref3 );
2724 pref->setItemProperty( "indexes", anIndicesList, spacemousePref3 );
2725 // ... space mouse sub-group <<end>>
2727 // ... avi recording sub-group <<start>>
2728 int vtkRec = pref->addPreference( tr( "PREF_FRAME_RECORDING" ), vtkGroup, LightApp_Preferences::GroupBox );
2729 pref->setItemProperty( "columns", 2, vtkRec );
2730 // .... -> recording mode
2731 int modePref = pref->addPreference( tr( "PREF_RECORDING_MODE" ), vtkRec,
2732 LightApp_Preferences::Selector, "VTKViewer", "recorder_mode" );
2733 aValuesList.clear();
2734 anIndicesList.clear();
2735 aValuesList << tr( "PREF_SKIPPED_FRAMES" ) << tr( "PREF_ALL_DISLPAYED_FRAMES" );
2736 anIndicesList << 0 << 1;
2737 pref->setItemProperty( "strings", aValuesList, modePref );
2738 pref->setItemProperty( "indexes", anIndicesList, modePref );
2740 int fpsPref = pref->addPreference( tr( "PREF_FPS" ), vtkRec,
2741 LightApp_Preferences::DblSpin, "VTKViewer", "recorder_fps" );
2742 pref->setItemProperty( "min", 0.1, fpsPref );
2743 pref->setItemProperty( "max", 100, fpsPref );
2745 int qualityPref = pref->addPreference( tr( "PREF_QUALITY" ), vtkRec,
2746 LightApp_Preferences::IntSpin, "VTKViewer", "recorder_quality" );
2747 pref->setItemProperty( "min", 1, qualityPref );
2748 pref->setItemProperty( "max", 100, qualityPref );
2749 // .... -> progressive mode
2750 pref->addPreference( tr( "PREF_PROGRESSIVE" ), vtkRec,
2751 LightApp_Preferences::Bool, "VTKViewer", "recorder_progressive" );
2752 // ... avi recording sub-group <<end>>
2754 // ... group names sub-group <<start>>
2755 int vtkGN = pref->addPreference( tr( "PREF_FRAME_GROUP_NAMES" ), vtkGroup,
2756 LightApp_Preferences::GroupBox, "VTKViewer", "show_group_names" );
2757 pref->setItemProperty( "columns", 2, vtkGN );
2758 // .... -> text color
2759 pref->addPreference( tr( "PREF_GROUP_NAMES_TEXT_COLOR" ), vtkGN,
2760 LightApp_Preferences::Color, "VTKViewer", "group_names_text_color" );
2761 // .... -> transparency
2762 int transPref = pref->addPreference( tr( "PREF_GROUP_NAMES_TRANSPARENCY" ), vtkGN,
2763 LightApp_Preferences::DblSpin, "VTKViewer", "group_names_transparency" );
2764 pref->setItemProperty( "min", 0.0, transPref );
2765 pref->setItemProperty( "max", 1.0, transPref );
2766 pref->setItemProperty( "step", 0.1, transPref );
2767 // ... -> group names sub-group <<end>>
2768 // .. "VTK viewer" group <<end>>
2771 // .. "Plot2d viewer" group <<start>>
2772 int plot2dGroup = pref->addPreference( tr( "PREF_GROUP_PLOT2DVIEWER" ), salomeCat ); //viewTab
2773 //pref->setItemProperty( "columns", 2, plot2dGroup );
2775 // ... -> background
2776 pref->addPreference( tr( "PREF_VIEWER_BACKGROUND_COLOR" ), plot2dGroup,
2777 LightApp_Preferences::Color, "Plot2d", "Background" );
2778 // ... -> selection color
2779 pref->addPreference( tr( "PREF_VIEWER_SELECTION" ), plot2dGroup,
2780 LightApp_Preferences::Color, "Plot2d", "SelectionColor" );
2782 // ... "Viewer" group <<start>>
2783 int plot2dViewerGroup = pref->addPreference( tr( "PREF_GROUP_VIEWER" ), plot2dGroup );
2785 // .... -> curve type
2786 int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dViewerGroup,
2787 LightApp_Preferences::Selector, "Plot2d", "CurveType" );
2788 aValuesList.clear();
2789 anIndicesList.clear();
2790 aValuesList << tr("PREF_POINTS") << tr("PREF_LINES") << tr("PREF_SPLINE");
2791 anIndicesList << 0 << 1 << 2 ;
2792 pref->setItemProperty( "strings", aValuesList, curveType );
2793 pref->setItemProperty( "indexes", anIndicesList, curveType );
2794 // .... -> marker size
2795 int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dViewerGroup,
2796 LightApp_Preferences::IntSpin, "Plot2d", "MarkerSize" );
2797 pref->setItemProperty( "min", 0, markerSize );
2798 pref->setItemProperty( "max", 100, markerSize );
2799 // .... -> horizontal scaling mode
2800 int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dViewerGroup,
2801 LightApp_Preferences::Selector, "Plot2d", "HorScaleMode" );
2802 aValuesList.clear();
2803 anIndicesList.clear();
2804 aValuesList << tr("PREF_LINEAR") << tr("PREF_LOGARITHMIC");
2805 anIndicesList << 0 << 1 ;
2806 pref->setItemProperty( "strings", aValuesList, horScale );
2807 pref->setItemProperty( "indexes", anIndicesList, horScale );
2808 // .... -> vertical scaling mode
2809 int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dViewerGroup,
2810 LightApp_Preferences::Selector, "Plot2d", "VerScaleMode" );
2811 pref->setItemProperty( "strings", aValuesList, verScale );
2812 pref->setItemProperty( "indexes", anIndicesList, verScale );
2814 // .... -> errors/deviation colot
2815 pref->addPreference( tr( "PREF_DEVIATION_COLOR" ), plot2dViewerGroup,
2816 LightApp_Preferences::Color, "Plot2d", "DeviationMarkerColor" );
2817 // .... -> deviation markers line size
2818 int deviationMarkerLw = pref->addPreference( tr( "PREF_DEVIATION_MARKER_LW" ), plot2dViewerGroup,
2819 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerLineWidth" );
2820 pref->setItemProperty( "min", 1, deviationMarkerLw );
2821 pref->setItemProperty( "max", 5, deviationMarkerLw );
2822 // .... -> deviation markers tick mark size
2823 int deviationMarkerTs = pref->addPreference( tr( "PREF_DEVIATION_MARKER_TS" ), plot2dViewerGroup,
2824 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerTickSize" );
2825 pref->setItemProperty( "min", 1, deviationMarkerTs );
2826 pref->setItemProperty( "max", 5, deviationMarkerTs );
2827 // .... "Viewer" group <<end>>
2829 // ... "Legend" group <<start>>
2830 int plot2dLegendGroup = pref->addPreference( tr( "PREF_GROUP_LEGEND" ), plot2dGroup );
2832 // .... -> show legend
2833 pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dLegendGroup,
2834 LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
2835 // .... -> legend position
2836 int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dLegendGroup,
2837 LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
2838 aValuesList.clear();
2839 anIndicesList.clear();
2840 aValuesList << tr("PREF_LEFT") << tr("PREF_RIGHT") << tr("PREF_TOP") << tr("PREF_BOTTOM");
2841 anIndicesList << 0 << 1 << 2 << 3 ;
2842 pref->setItemProperty( "strings", aValuesList, legendPosition );
2843 pref->setItemProperty( "indexes", anIndicesList, legendPosition );
2844 // .... -> Symbol type
2845 int legendSymbolType = pref->addPreference( tr( "PREF_LEGEND_SYMBOL_TYPE" ), plot2dLegendGroup,
2846 LightApp_Preferences::Selector, "Plot2d", "LegendSymbolType" );
2847 aValuesList.clear();
2848 anIndicesList.clear();
2849 aValuesList << tr("PREF_MARKER_ON_LINE") << tr("PREF_MARKER_ABOVE_LINE");
2850 anIndicesList << 0 << 1 ;
2851 pref->setItemProperty( "strings", aValuesList, legendSymbolType );
2852 pref->setItemProperty( "indexes", anIndicesList, legendSymbolType );
2853 // .... -> legend font
2854 pref->addPreference( tr( "PREF_LEGEND_FONT" ), plot2dLegendGroup, LightApp_Preferences::Font, "Plot2d", "LegendFont" );
2855 // ... -> font color
2856 pref->addPreference( tr( "PREF_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "LegendFontColor" );
2857 // ... -> selection font color
2858 pref->addPreference( tr( "PREF_SELECTED_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "SelectedLegendFontColor" );
2859 // ... "Legend" group <<end>>
2861 // .. "Plot2d viewer" group <<end>>
2863 // .. "PyViewer" preferences tab <<start>>
2864 int pyeditTab = pref->addPreference( tr( "PREF_TAB_PYEDITOR" ), salomeCat );
2865 // ... "Font settings" group <<start>>
2866 int pyFontGroup = pref->addPreference( tr( "PREF_GROUP_PY_FONT" ), pyeditTab );
2867 pref->addPreference( tr( "PREF_PY_FONT" ), pyFontGroup,
2868 LightApp_Preferences::Font, "PyEditor", "Font" );
2869 // ... "Font settings" group <<end>>
2870 // ... "Display settings" group <<start>>
2871 int pyDispGroup = pref->addPreference( tr( "PREF_GROUP_PY_DISPLAY" ), pyeditTab );
2872 pref->setItemProperty( "columns", 2, pyDispGroup );
2873 // ... -> current line highlight
2874 pref->addPreference( tr( "PREF_PY_CURRLINE_HIGHLIGHT" ), pyDispGroup,
2875 LightApp_Preferences::Bool, "PyEditor", "HighlightCurrentLine" );
2876 // ... -> text wrapping
2877 pref->addPreference( tr( "PREF_PY_TEXT_WRAP" ), pyDispGroup,
2878 LightApp_Preferences::Bool, "PyEditor", "TextWrapping" );
2879 // ... -> center cursor on scroll
2880 pref->addPreference( tr( "PREF_PY_CURSON_ON_SCROLL" ), pyDispGroup,
2881 LightApp_Preferences::Bool, "PyEditor", "CenterCursorOnScroll" );
2882 // ... -> line numbers area
2883 pref->addPreference( tr( "PREF_PY_LINE_NUMBS_AREA" ), pyDispGroup,
2884 LightApp_Preferences::Bool, "PyEditor", "LineNumberArea" );
2885 // ... "Display settings" group <<end>>
2886 // ... "Tab settings" group <<start>>
2887 int pyTabGroup = pref->addPreference( tr( "PREF_GROUP_PY_TAB" ), pyeditTab );
2888 pref->setItemProperty( "columns", 2, pyTabGroup );
2889 // ... -> tab whitespaces
2890 pref->addPreference( tr( "PREF_PY_TAB_WHITESPACES" ), pyTabGroup,
2891 LightApp_Preferences::Bool, "PyEditor", "TabSpaceVisible" );
2893 pref->addPreference( tr( "PREF_PY_TAB_SIZE" ), pyTabGroup,
2894 LightApp_Preferences::IntSpin, "PyEditor", "TabSize" );
2895 // ... "Tab settings" group <<end>>
2896 // ... "Vertical edge settings" group <<start>>
2897 int pyVertEdgeGroup = pref->addPreference( tr( "PREF_GROUP_VERT_EDGE" ), pyeditTab );
2898 pref->setItemProperty( "columns", 2, pyVertEdgeGroup );
2899 // ... -> vertical edge
2900 pref->addPreference( tr( "PREF_PY_VERT_EDGE" ), pyVertEdgeGroup,
2901 LightApp_Preferences::Bool, "PyEditor", "VerticalEdge" );
2902 // ... -> number of columns
2903 pref->addPreference( tr( "PREF_PY_NUM_COLUMNS" ), pyVertEdgeGroup,
2904 LightApp_Preferences::IntSpin, "PyEditor", "NumberColumns" );
2905 // ... "Vertical edge settings" group <<end>>
2906 // .. "PyEditor" preferences tab <<end>>
2908 // .. "Directories" preferences tab <<start>>
2909 int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat );
2910 // ... --> quick directories list
2911 int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab );
2912 pref->addPreference( tr( "" ), dirGroup,
2913 LightApp_Preferences::DirList, "FileDlg", "QuickDirList" );
2914 // .. "Directories" preferences tab <<end>>
2916 // .. "Object browser" preferences tab <<start>>
2917 int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
2919 // ... "Search tool" group <<start>>
2920 int stGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SEARCH_TOOL" ), obTab );
2921 // .... --> auto-hide
2922 pref->addPreference( tr( "PREF_AUTO_HIDE_SEARCH_TOOL" ), stGroup, LightApp_Preferences::Bool,
2923 "ObjectBrowser", "auto_hide_search_tool" );
2924 // ... "Search tool" group <<end>>
2926 // ... "Object browser settings" group <<start>>
2927 int objSetGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), obTab );
2928 pref->setItemProperty( "columns", 2, objSetGroup );
2929 // .... -> auto size first column
2930 pref->addPreference( tr( "PREF_AUTO_SIZE_FIRST" ), objSetGroup, LightApp_Preferences::Bool,
2931 "ObjectBrowser", "auto_size_first" );
2932 // .... -> auto size other columns
2933 pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool,
2934 "ObjectBrowser", "auto_size" );
2935 // .... -> resize columns on expand item
2936 pref->addPreference( tr( "PREF_RESIZE_ON_EXPAND_ITEM" ), objSetGroup, LightApp_Preferences::Bool,
2937 "ObjectBrowser", "resize_on_expand_item" );
2938 // .... -> browse to published object
2939 int browsePublished = pref->addPreference( tr( "PREF_BROWSE_TO_THE_PUBLISHED_OBJECT" ), objSetGroup, LightApp_Preferences::Selector,
2940 "ObjectBrowser", "browse_published_object" );
2941 aValuesList.clear();
2942 anIndicesList.clear();
2943 aValuesList << tr( "PREF_BROWSE_NEVER" ) << tr( "PREF_BROWSE_AFTER_APPLY_AND_CLOSE_ONLY" ) << tr( "PREF_BROWSE_ALWAYS" );
2944 anIndicesList << BP_Never << BP_ApplyAndClose << BP_Always;
2945 pref->setItemProperty( "strings", aValuesList, browsePublished );
2946 pref->setItemProperty( "indexes", anIndicesList, browsePublished );
2947 // ... "Object browser settings" group <<end>>
2948 // .. "Object browser" preferences tab <<end>>
2950 // .. "Shortcuts" preferences tab <<start>>
2951 int shortcutTab = pref->addPreference( tr( "PREF_TAB_SHORTCUTS" ), salomeCat );
2952 // ... "Shortcuts settings" group <<start>>
2953 int shortcutGroup = pref->addPreference( tr( "PREF_GROUP_SHORTCUTS" ), shortcutTab );
2954 pref->addPreference( tr( "" ), shortcutGroup,
2955 LightApp_Preferences::ShortcutTree, "shortcuts" );
2956 // ... "Shortcuts settings" group <<end>>
2957 // .. "Shortcuts" preferences tab <<end>>
2958 // . Top-level "SALOME" preferences group <<end>>
2964 Changes appearance of application according to changed preferences
2965 \param sec - section
2966 \param param - name of changed parameter
2968 void LightApp_Application::preferencesChanged( const QString& sec, const QString& param )
2970 SUIT_ResourceMgr* resMgr = resourceMgr();
2974 if ( sec == "viewers" && param == "drop_down_buttons" )
2976 ViewManagerList vmlist = viewManagers();
2977 foreach( SUIT_ViewManager* vm, vmlist )
2979 QVector<SUIT_ViewWindow*> vwlist = vm->getViews();
2980 foreach( SUIT_ViewWindow* vw, vwlist )
2981 if ( vw ) vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
2985 if ( sec == QString( "3DViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )))
2987 double sz = resMgr->doubleValue( sec, "trihedron_size", -1 );
2988 bool relative = resMgr->booleanValue( sec, "relative_size", true );
2989 QList<SUIT_ViewManager*> lst;
2990 #ifndef DISABLE_OCCVIEWER
2991 viewManagers( OCCViewer_Viewer::Type(), lst );
2992 QListIterator<SUIT_ViewManager*> itOCC( lst );
2993 while ( itOCC.hasNext() && sz >= 0 )
2995 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2996 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2999 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3000 occVM->setTrihedronSize( sz, relative );
3001 occVM->getAISContext()->UpdateCurrentViewer();
3004 #ifndef DISABLE_VTKVIEWER
3005 #ifndef DISABLE_SALOMEOBJECT
3006 viewManagers( SVTK_Viewer::Type(), lst );
3007 QListIterator<SUIT_ViewManager*> itVTK( lst );
3008 while ( itVTK.hasNext() && sz >= 0 )
3010 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3011 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3014 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3017 vtkVM->setTrihedronSize( sz, relative );
3025 if ( sec == QString( "3DViewer" ) && param == QString( "show_static_trihedron" ) )
3027 bool isVisible = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
3028 QList<SUIT_ViewManager*> lst;
3029 #ifndef DISABLE_OCCVIEWER
3030 viewManagers( OCCViewer_Viewer::Type(), lst );
3031 QListIterator<SUIT_ViewManager*> itOCC( lst );
3032 while ( itOCC.hasNext() )
3034 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3035 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3038 OCCViewer_Viewer* occVM = dynamic_cast<OCCViewer_Viewer*>( vm );
3041 occVM->setStaticTrihedronDisplayed( isVisible );
3045 #ifndef DISABLE_VTKVIEWER
3046 #ifndef DISABLE_SALOMEOBJECT
3047 viewManagers( SVTK_Viewer::Type(), lst );
3048 QListIterator<SUIT_ViewManager*> itVTK( lst );
3049 while ( itVTK.hasNext() )
3051 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3052 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3055 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3058 vtkVM->setStaticTrihedronVisible( isVisible );
3066 if ( sec == QString( "3DViewer" ) && param == QString( "navigation_mode" ) )
3068 int mode = resMgr->integerValue( "3DViewer", "navigation_mode", 0 );
3069 QList<SUIT_ViewManager*> lst;
3070 #ifndef DISABLE_OCCVIEWER
3071 viewManagers( OCCViewer_Viewer::Type(), lst );
3072 QListIterator<SUIT_ViewManager*> itOCC( lst );
3073 while ( itOCC.hasNext() )
3075 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3076 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3079 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3080 occVM->setInteractionStyle( mode );
3083 #ifndef DISABLE_VTKVIEWER
3084 #ifndef DISABLE_SALOMEOBJECT
3085 viewManagers( SVTK_Viewer::Type(), lst );
3086 QListIterator<SUIT_ViewManager*> itVTK( lst );
3087 while ( itVTK.hasNext() )
3089 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3090 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3093 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3094 if( vtkVM ) vtkVM->setInteractionStyle( mode );
3100 #ifndef DISABLE_OCCVIEWER
3101 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_preselection" ) )
3103 bool isToEnablePreselection = resMgr->booleanValue( "OCCViewer", "enable_preselection", true );
3104 QList<SUIT_ViewManager*> lst;
3105 viewManagers( OCCViewer_Viewer::Type(), lst );
3106 QListIterator<SUIT_ViewManager*> it( lst );
3107 while ( it.hasNext() )
3109 SUIT_ViewModel* vm = it.next()->getViewModel();
3110 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3113 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3114 occVM->enablePreselection( isToEnablePreselection );
3119 #ifndef DISABLE_OCCVIEWER
3120 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_selection" ) )
3122 bool isToEnableSelection = resMgr->booleanValue( "OCCViewer", "enable_selection", true );
3123 QList<SUIT_ViewManager*> lst;
3124 viewManagers( OCCViewer_Viewer::Type(), lst );
3125 QListIterator<SUIT_ViewManager*> it( lst );
3126 while ( it.hasNext() )
3128 SUIT_ViewModel* vm = it.next()->getViewModel();
3129 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3132 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3133 occVM->enableSelection( isToEnableSelection );
3138 #ifndef DISABLE_OCCVIEWER
3139 if ( sec == QString( "OCCViewer" ) && param == QString( "clipping_color" ) )
3141 QColor aColor = resMgr->colorValue( "OCCViewer", "clipping_color", QColor( 50, 50, 50 ) );
3142 QList<SUIT_ViewManager*> lst;
3143 viewManagers( OCCViewer_Viewer::Type(), lst );
3144 QListIterator<SUIT_ViewManager*> it( lst );
3145 while ( it.hasNext() )
3147 SUIT_ViewModel* vm = it.next()->getViewModel();
3148 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3151 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3152 occVM->setClippingColor( aColor );
3157 #ifndef DISABLE_OCCVIEWER
3158 if ( sec == QString( "OCCViewer" ) && ( param == QString( "clipping_use_default_texture" ) ||
3159 param == QString( "clipping_texture" ) ||
3160 param == QString( "clipping_modulate" ) ||
3161 param == QString( "clipping_scale" ) ) )
3163 bool isDefaultTextureUsed = resMgr->booleanValue( "OCCViewer", "clipping_use_default_texture" );
3164 QString aTexture = resMgr->stringValue( "OCCViewer", "clipping_texture" );
3165 bool isModulated = resMgr->booleanValue( "OCCViewer", "clipping_modulate" );
3166 double aScale = resMgr->doubleValue( "OCCViewer", "clipping_scale" );
3167 QList<SUIT_ViewManager*> lst;
3168 viewManagers( OCCViewer_Viewer::Type(), lst );
3169 QListIterator<SUIT_ViewManager*> it( lst );
3170 while ( it.hasNext() )
3172 SUIT_ViewModel* vm = it.next()->getViewModel();
3173 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3176 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3177 occVM->setClippingTextureParams( isDefaultTextureUsed, aTexture, isModulated, aScale );
3182 #ifndef DISABLE_OCCVIEWER
3183 if ( sec == QString( "OCCViewer" ) && param == QString( "projection_mode" ) )
3185 int mode = resMgr->integerValue( "OCCViewer", "projection_mode", 0 );
3186 QList<SUIT_ViewManager*> lst;
3187 viewManagers( OCCViewer_Viewer::Type(), lst );
3188 QListIterator<SUIT_ViewManager*> it( lst );
3189 while ( it.hasNext() )
3191 SUIT_ViewModel* vm = it.next()->getViewModel();
3192 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3195 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3196 occVM->setProjectionType( mode );
3200 #if OCC_VERSION_LARGE > 0x06090000
3201 #ifndef DISABLE_OCCVIEWER
3202 if ( sec == QString( "OCCViewer" ) && param == QString( "stereo_type" ) )
3204 int mode = resMgr->integerValue( "OCCViewer", "stereo_type", 0 );
3205 QList<SUIT_ViewManager*> lst;
3206 viewManagers( OCCViewer_Viewer::Type(), lst );
3207 QListIterator<SUIT_ViewManager*> it( lst );
3208 while ( it.hasNext() )
3210 SUIT_ViewModel* vm = it.next()->getViewModel();
3211 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3214 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3215 occVM->setStereoType( mode );
3220 #ifndef DISABLE_OCCVIEWER
3221 if ( sec == QString( "OCCViewer" ) && param == QString( "anaglyph_filter" ) )
3223 int mode = resMgr->integerValue( "OCCViewer", "anaglyph_filter", 0 );
3224 QList<SUIT_ViewManager*> lst;
3225 viewManagers( OCCViewer_Viewer::Type(), lst );
3226 QListIterator<SUIT_ViewManager*> it( lst );
3227 while ( it.hasNext() )
3229 SUIT_ViewModel* vm = it.next()->getViewModel();
3230 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3233 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3234 occVM->setAnaglyphFilter( mode );
3239 #ifndef DISABLE_OCCVIEWER
3240 if ( sec == QString( "OCCViewer" ) && ( param == QString( "focus_type" ) ||
3241 param == QString( "focus_value" ) ) )
3243 int aType = resMgr->integerValue( "OCCViewer", "focus_type" );
3244 double aValue = resMgr->doubleValue( "OCCViewer", "focus_value" );
3245 QList<SUIT_ViewManager*> lst;
3246 viewManagers( OCCViewer_Viewer::Type(), lst );
3247 QListIterator<SUIT_ViewManager*> it( lst );
3248 while ( it.hasNext() )
3250 SUIT_ViewModel* vm = it.next()->getViewModel();
3251 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3254 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3255 occVM->setStereographicFocus( aType, aValue );
3260 #ifndef DISABLE_OCCVIEWER
3261 if ( sec == QString( "OCCViewer" ) && ( param == QString( "iod_type" ) ||
3262 param == QString( "iod_value" ) ) )
3264 int aType = resMgr->integerValue( "OCCViewer", "iod_type" );
3265 double aValue = resMgr->doubleValue( "OCCViewer", "iod_value" );
3266 QList<SUIT_ViewManager*> lst;
3267 viewManagers( OCCViewer_Viewer::Type(), lst );
3268 QListIterator<SUIT_ViewManager*> it( lst );
3269 while ( it.hasNext() )
3271 SUIT_ViewModel* vm = it.next()->getViewModel();
3272 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3275 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3276 occVM->setInterocularDistance( aType, aValue );
3281 #ifndef DISABLE_OCCVIEWER
3282 if ( sec == QString( "OCCViewer" ) && param == QString( "reverse_stereo" ) )
3284 bool reverse = resMgr->booleanValue( "OCCViewer", "reverse_stereo", false );
3285 QList<SUIT_ViewManager*> lst;
3286 viewManagers( OCCViewer_Viewer::Type(), lst );
3287 QListIterator<SUIT_ViewManager*> it( lst );
3288 while ( it.hasNext() )
3290 SUIT_ViewModel* vm = it.next()->getViewModel();
3291 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3294 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3295 occVM->setReverseStereo( reverse );
3300 #ifndef DISABLE_OCCVIEWER
3301 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_vsync" ) )
3303 bool enable = resMgr->booleanValue( "OCCViewer", "enable_vsync", true );
3304 QList<SUIT_ViewManager*> lst;
3305 viewManagers( OCCViewer_Viewer::Type(), lst );
3306 QListIterator<SUIT_ViewManager*> it( lst );
3307 while ( it.hasNext() )
3309 SUIT_ViewModel* vm = it.next()->getViewModel();
3310 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3313 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3314 occVM->setVSync( enable );
3319 #ifndef DISABLE_OCCVIEWER
3320 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_quad_buffer_support" ) )
3322 bool enable = resMgr->booleanValue( "OCCViewer", "enable_quad_buffer_support", false );
3323 QList<SUIT_ViewManager*> lst;
3324 viewManagers( OCCViewer_Viewer::Type(), lst );
3325 QListIterator<SUIT_ViewManager*> it( lst );
3326 while ( it.hasNext() )
3328 SUIT_ViewModel* vm = it.next()->getViewModel();
3329 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3332 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3333 occVM->setQuadBufferSupport( enable );
3338 if ( sec == QString( "3DViewer" ) && param == QString( "zooming_mode" ) )
3340 int mode = resMgr->integerValue( "3DViewer", "zooming_mode", 0 );
3341 QList<SUIT_ViewManager*> lst;
3342 #ifndef DISABLE_OCCVIEWER
3343 viewManagers( OCCViewer_Viewer::Type(), lst );
3344 QListIterator<SUIT_ViewManager*> itOCC( lst );
3345 while ( itOCC.hasNext() )
3347 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3348 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3351 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3352 occVM->setZoomingStyle( mode );
3355 #ifndef DISABLE_VTKVIEWER
3356 #ifndef DISABLE_SALOMEOBJECT
3357 viewManagers( SVTK_Viewer::Type(), lst );
3358 QListIterator<SUIT_ViewManager*> itVTK( lst );
3359 while ( itVTK.hasNext() )
3361 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3362 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3365 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3366 if( vtkVM ) vtkVM->setZoomingStyle( mode );
3372 #ifndef DISABLE_VTKVIEWER
3373 if ( sec == QString( "VTKViewer" ) && (param == QString( "speed_value" ) || param == QString( "speed_mode" )) )
3375 int speed = resMgr->integerValue( "VTKViewer", "speed_value", 10 );
3376 int mode = resMgr->integerValue( "VTKViewer", "speed_mode", 0 );
3377 QList<SUIT_ViewManager*> lst;
3378 #ifndef DISABLE_SALOMEOBJECT
3379 viewManagers( SVTK_Viewer::Type(), lst );
3380 QListIterator<SUIT_ViewManager*> it( lst );
3381 while ( it.hasNext() )
3383 SUIT_ViewModel* vm = it.next()->getViewModel();
3384 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3387 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3388 if( vtkVM ) vtkVM->setIncrementalSpeed( speed, mode );
3394 #ifndef DISABLE_VTKVIEWER
3395 if ( sec == QString( "VTKViewer" ) && param == QString( "projection_mode" ) )
3397 int mode = resMgr->integerValue( "VTKViewer", "projection_mode", 0 );
3398 QList<SUIT_ViewManager*> lst;
3399 #ifndef DISABLE_SALOMEOBJECT
3400 viewManagers( SVTK_Viewer::Type(), lst );
3401 QListIterator<SUIT_ViewManager*> it( lst );
3402 while ( it.hasNext() )
3404 SUIT_ViewModel* vm = it.next()->getViewModel();
3405 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3408 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3409 if( vtkVM ) vtkVM->setProjectionMode( mode );
3415 #ifndef DISABLE_VTKVIEWER
3416 if ( sec == QString( "VTKViewer" ) && param == QString( "stereo_type" ) )
3418 int mode = resMgr->integerValue( "VTKViewer", "stereo_type", 0 );
3419 QList<SUIT_ViewManager*> lst;
3420 #ifndef DISABLE_SALOMEOBJECT
3421 viewManagers( SVTK_Viewer::Type(), lst );
3422 QListIterator<SUIT_ViewManager*> it( lst );
3423 while ( it.hasNext() )
3425 SUIT_ViewModel* vm = it.next()->getViewModel();
3426 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3429 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3430 if( vtkVM ) vtkVM->setStereoType( mode );
3436 #ifndef DISABLE_VTKVIEWER
3437 if ( sec == QString( "VTKViewer" ) && param == QString( "anaglyph_filter" ) )
3439 int mode = resMgr->integerValue( "VTKViewer", "anaglyph_filter", 0 );
3440 QList<SUIT_ViewManager*> lst;
3441 #ifndef DISABLE_SALOMEOBJECT
3442 viewManagers( SVTK_Viewer::Type(), lst );
3443 QListIterator<SUIT_ViewManager*> it( lst );
3444 while ( it.hasNext() )
3446 SUIT_ViewModel* vm = it.next()->getViewModel();
3447 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3450 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3451 if( vtkVM ) vtkVM->setAnaglyphFilter( mode );
3457 #ifndef DISABLE_VTKVIEWER
3458 if ( sec == QString( "VTKViewer" ) && param == QString( "enable_quad_buffer_support" ) )
3460 int enable = resMgr->booleanValue( "VTKViewer", "enable_quad_buffer_support", false );
3461 QList<SUIT_ViewManager*> lst;
3462 #ifndef DISABLE_SALOMEOBJECT
3463 viewManagers( SVTK_Viewer::Type(), lst );
3464 QListIterator<SUIT_ViewManager*> it( lst );
3465 while ( it.hasNext() )
3467 SUIT_ViewModel* vm = it.next()->getViewModel();
3468 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3471 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3472 if( vtkVM ) vtkVM->setQuadBufferSupport( enable );
3478 #ifndef DISABLE_VTKVIEWER
3479 if ( sec == QString( "VTKViewer" ) && param == QString( "preselection" ) )
3481 int mode = resMgr->integerValue( "VTKViewer", "preselection", 0 );
3482 QList<SUIT_ViewManager*> lst;
3483 #ifndef DISABLE_SALOMEOBJECT
3484 viewManagers( SVTK_Viewer::Type(), lst );
3485 QListIterator<SUIT_ViewManager*> it( lst );
3486 while ( it.hasNext() )
3488 SUIT_ViewModel* vm = it.next()->getViewModel();
3489 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3492 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3493 if( vtkVM ) vtkVM->setPreSelectionMode( mode );
3499 #ifndef DISABLE_VTKVIEWER
3500 if ( sec == QString( "VTKViewer" ) && param == QString( "enable_selection" ) )
3502 bool isToEnableSelection = resMgr->booleanValue( "VTKViewer", "enable_selection", true );
3503 QList<SUIT_ViewManager*> lst;
3504 #ifndef DISABLE_SALOMEOBJECT
3505 viewManagers( SVTK_Viewer::Type(), lst );
3506 QListIterator<SUIT_ViewManager*> it( lst );
3507 while ( it.hasNext() )
3509 SUIT_ViewModel* vm = it.next()->getViewModel();
3510 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3513 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3514 if( vtkVM ) vtkVM->enableSelection( isToEnableSelection );
3520 #ifndef DISABLE_VTKVIEWER
3521 if ( sec == QString( "VTKViewer" ) && (param == QString( "spacemouse_func1_btn" ) ||
3522 param == QString( "spacemouse_func2_btn" ) ||
3523 param == QString( "spacemouse_func5_btn" ) ) )
3525 int btn1 = resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", 1 );
3526 int btn2 = resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", 2 );
3527 int btn3 = resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", 9 );
3528 QList<SUIT_ViewManager*> lst;
3529 #ifndef DISABLE_SALOMEOBJECT
3530 viewManagers( SVTK_Viewer::Type(), lst );
3531 QListIterator<SUIT_ViewManager*> it( lst );
3532 while ( it.hasNext() )
3534 SUIT_ViewModel* vm = it.next()->getViewModel();
3535 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3538 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3539 if( vtkVM ) vtkVM->setSpacemouseButtons( btn1, btn2, btn3 );
3544 if( sec=="ObjectBrowser" )
3546 SUIT_DataBrowser* ob = objectBrowser();
3550 if ( param=="auto_size_first" )
3552 bool autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
3553 ob->setAutoSizeFirstColumn( autoSizeFirst );
3554 if ( autoSizeFirst )
3555 ob->adjustFirstColumnWidth();
3557 else if ( param=="auto_size" ) {
3558 bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
3559 ob->setAutoSizeColumns(autoSize);
3561 ob->adjustColumnsWidth();
3563 else if ( param=="resize_on_expand_item" ) {
3564 bool resizeOnExpandItem = resMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
3565 ob->setResizeOnExpandItem(resizeOnExpandItem);
3567 else if ( param == "auto_hide_search_tool" ) {
3568 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
3574 if( param=="auto_save_interval" ) {
3575 myAutoSaveTimer->stop();
3576 int autoSaveInterval = resMgr->integerValue( "Study", "auto_save_interval", 0 );
3577 if ( activeStudy() && autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
3581 #ifndef DISABLE_PYCONSOLE
3582 if( sec=="PyConsole" && pythonConsole() )
3584 if ( param=="font" ) {
3585 pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) );
3587 else if ( param=="show_banner" ) {
3588 pythonConsole()->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
3590 else if ( param=="auto_completion" ) {
3591 pythonConsole()->setAutoCompletion( resMgr->booleanValue( "PyConsole", "auto_completion", true ) );
3598 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3600 if ( param == "visible_count" )
3601 mru->setVisibleCount( resMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
3602 else if ( param == "max_count" )
3603 mru->setHistoryCount( resMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
3604 else if ( param == "insert_mode" )
3605 mru->setInsertMode( resMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
3606 else if ( param == "link_type" )
3607 mru->setLinkType( resMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
3608 else if ( param == "show_clear" )
3609 mru->setClearPossible( resMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
3610 else if ( param == "show_mru" )
3611 mru->setVisible( resMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
3614 if ( sec == "language" && param == "language" )
3616 // VSR 18.06.2015 : commented out : single warning dialog box is now shown by the LightApp_PreferencesDlg
3617 //SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LANG_CHANGED" ) );
3619 if ( sec == "language" && param == "locale")
3621 // VSR 18.06.2015: commented out : single warning dialog box is now shown by the LightApp_PreferencesDlg
3622 //SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LOCALE_CHANGED" ) );
3624 if ( sec == "desktop" && param == "opaque_resize" ) {
3625 bool opaqueResize = resMgr->booleanValue( "desktop", "opaque_resize", false );
3626 QMainWindow::DockOptions dopts = desktop()->dockOptions();
3627 if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
3628 else dopts &= ~QMainWindow::AnimatedDocks;
3629 desktop()->setDockOptions( dopts );
3630 desktop()->setOpaqueResize( opaqueResize );
3631 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
3632 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
3635 #ifndef DISABLE_PLOT2DVIEWER
3636 QList<SUIT_ViewManager*> lst;
3637 viewManagers( Plot2d_Viewer::Type(), lst );
3638 QListIterator<SUIT_ViewManager*> itPlot2d( lst );
3639 while ( itPlot2d.hasNext() ) {
3640 SUIT_ViewManager* viewMgr = itPlot2d.next();
3641 SUIT_ViewModel* vm = viewMgr->getViewModel();
3642 if ( !vm || !vm->inherits( "Plot2d_Viewer" ) )
3645 Plot2d_Viewer* Plot2dVM = dynamic_cast<Plot2d_Viewer*>( vm );
3647 viewMgr->setViewModel( vm );
3648 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
3650 Plot2d_ViewFrame* frame = wnd->getViewFrame();
3651 frame->SetPreference();
3656 #ifndef DISABLE_PYVIEWER
3657 if ( sec == QString( "PyViewer" ) && ( param == QString( "HighlightCurrentLine" ) ||
3658 param == QString( "LineNumberArea" ) ||
3659 param == QString( "TextWrapping" ) ||
3660 param == QString( "CenterCursorOnScroll" ) ||
3661 param == QString( "TabSpaceVisible" ) ||
3662 param == QString( "TabSize" ) ||
3663 param == QString( "VerticalEdge" ) ||
3664 param == QString( "NumberColumns" ) ||
3665 param == QString( "Font" ) ) )
3667 QList<SUIT_ViewManager*> lst;
3668 viewManagers( PyViewer_Viewer::Type(), lst );
3669 QListIterator<SUIT_ViewManager*> itPy( lst );
3670 while ( itPy.hasNext() )
3672 SUIT_ViewManager* viewMgr = itPy.next();
3673 SUIT_ViewModel* vm = viewMgr->getViewModel();
3674 if ( !vm || !vm->inherits( "PyViewer_Viewer" ) )
3677 PyViewer_Viewer* pyEditVM = dynamic_cast<PyViewer_Viewer*>( vm );
3679 viewMgr->setViewModel( vm );
3680 PyViewer_ViewWindow* pyView = dynamic_cast<PyViewer_ViewWindow*>( viewMgr->getActiveView() );
3683 pyView->setPreferences();
3693 void LightApp_Application::loadPreferences()
3695 CAM_Application::loadPreferences();
3697 SUIT_ResourceMgr* aResMgr = resourceMgr();
3702 static bool mru_load = true;
3705 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3707 mru->setVisible( aResMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
3708 mru->setVisibleCount( aResMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
3709 mru->setHistoryCount( aResMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
3710 mru->setInsertMode( aResMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
3711 mru->setLinkType( aResMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
3712 mru->setClearPossible( aResMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
3713 mru->loadLinks( aResMgr, "MRU" );
3719 QStringList mods = aResMgr->parameters( "windows_visibility" );
3720 for ( QStringList::const_iterator itr = mods.begin(); itr != mods.end(); ++itr )
3723 if ( aResMgr->value( "windows_visibility", *itr, arr ) )
3724 myWinVis.insert( *itr, arr );
3728 desktop()->retrieveGeometry( aResMgr->stringValue( "desktop", "geometry" ) );
3729 bool opaqueResize = aResMgr->booleanValue( "desktop", "opaque_resize", false );
3730 QMainWindow::DockOptions dopts = desktop()->dockOptions();
3731 if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
3732 else dopts &= ~QMainWindow::AnimatedDocks;
3733 desktop()->setDockOptions( dopts );
3734 desktop()->setOpaqueResize( opaqueResize );
3735 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
3736 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
3743 void LightApp_Application::savePreferences()
3745 CAM_Application::savePreferences();
3747 saveDockWindowsState();
3749 SUIT_ResourceMgr* aResMgr = resourceMgr();
3754 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3756 mru->saveLinks( aResMgr, "MRU" );
3758 for ( WinVis::const_iterator itr = myWinVis.begin(); itr != myWinVis.end(); ++itr )
3759 aResMgr->setValue( "windows_visibility", itr.key(), itr.value() );
3762 aResMgr->setValue( "desktop", "geometry", desktop()->storeGeometry() );
3764 #if GUI_DEVELOPMENT > 0
3765 aResMgr->setValue( "salome", "version", QString(GUI_VERSION_STR)+"dev" );
3767 aResMgr->setValue( "salome", "version", QString(GUI_VERSION_STR) );
3774 Updates desktop title
3776 void LightApp_Application::updateDesktopTitle()
3778 QString aTitle = applicationName();
3779 QString aVer = applicationVersion();
3780 if ( !aVer.isEmpty() )
3781 aTitle += QString( " " ) + aVer;
3783 if ( activeStudy() ) {
3784 QString sName = SUIT_Tools::file( activeStudy()->studyName().trimmed(), false );
3785 aTitle += QString( " - [%1]" ).arg( sName );
3788 desktop()->setWindowTitle( aTitle );
3792 \brief Get map of the operations which can be performed
3793 on the module activation.
3795 The method should return the map of the kind \c {<id>:<name>}
3796 where \c <id> is an integer identifier of the operation and
3797 \c <name> is a title for the button to be added to the
3798 dialog box. After user selects the required operation by the
3799 clicking the corresponding button in the dialog box, its identifier
3800 is passed to the moduleActionSelected() method to process
3803 \return map of the operations
3804 \sa moduleActionSelected()
3806 QMap<int, QString> LightApp_Application::activateModuleActions() const
3808 QMap<int, QString> opmap;
3809 opmap.insert( NewStudyId, tr( "ACTIVATE_MODULE_OP_NEW" ) );
3810 opmap.insert( OpenStudyId, tr( "ACTIVATE_MODULE_OP_OPEN" ) );
3815 \brief Called when the used selectes required operation chosen
3816 from "Activate module" dialog box.
3818 Performs the required operation according to the user choice.
3820 \param id operation identifier
3821 \sa activateModuleActions()
3823 void LightApp_Application::moduleActionSelected( const int id )
3838 Updates windows after close document
3840 void LightApp_Application::afterCloseDoc()
3844 CAM_Application::afterCloseDoc();
3848 Updates actions of active module
3850 void LightApp_Application::updateModuleActions()
3853 if ( activeModule() ) {
3854 modName = activeModule()->moduleName();
3855 if ( !isModuleAccessible( modName ) ) {
3856 QList<SUIT_Application*> apps = SUIT_Session::session()->applications();
3857 foreach( SUIT_Application* app, apps ) {
3858 LightApp_Application* lapp = dynamic_cast<LightApp_Application*>( app );
3859 if ( lapp && lapp != this )
3860 lapp->removeModuleAction( modName );
3865 LightApp_ModuleAction* moduleAction =
3866 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
3868 moduleAction->setActiveModule( modName );
3871 void LightApp_Application::removeModuleAction( const QString& modName )
3873 LightApp_ModuleAction* moduleAction =
3874 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
3876 moduleAction->removeModule( modName );
3880 Gets current windows.
3881 \param winMap - output current windows map.
3883 void LightApp_Application::currentWindows( QMap<int, int>& winMap ) const
3886 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
3887 ((LightApp_Module*)activeModule())->windows( winMap );
3889 defaultWindows( winMap );
3893 Gets current view managers.
3894 \param lst - output current view managers list.
3896 void LightApp_Application::currentViewManagers( QStringList& lst ) const
3899 if ( !activeStudy() )
3902 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
3903 ((LightApp_Module*)activeModule())->viewManagers( lst );
3905 defaultViewManagers( lst );
3911 void LightApp_Application::updateWindows()
3913 QMap<int, int> winMap;
3914 currentWindows( winMap );
3916 for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
3918 if ( !dockWindow( it.key() ) )
3919 getWindow( it.key() );
3922 for ( WinMap::ConstIterator it = myWin.begin(); it != myWin.end(); ++it )
3924 QWidget* wid = it.value();
3925 if ( winMap.contains( it.key() ) )
3926 wid->setVisible( true );
3931 loadDockWindowsState();
3935 Updates view managers
3937 void LightApp_Application::updateViewManagers()
3940 currentViewManagers( lst );
3942 for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
3943 getViewManager( *it, true );
3947 Loads windows geometry
3949 void LightApp_Application::loadDockWindowsState()
3953 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
3954 bool storeWin = aResMgr->booleanValue( "Study", "store_positions", true );
3955 bool storeTb = aResMgr->booleanValue( "Study", "store_tool_positions", true );
3958 if ( activeModule() )
3959 modName = activeModule()->name();
3960 else if ( activeStudy() )
3961 modName = "nomodule";
3963 QtxResourceMgr::WorkingMode prevMode = aResMgr->setWorkingMode( QtxResourceMgr::IgnoreUserValues );
3964 QByteArray aDefaultState;
3965 aResMgr->value( "windows_geometry", modName, aDefaultState );
3966 QByteArray aDefaultVisibility;
3967 aResMgr->value( "windows_visibility", modName, aDefaultVisibility );
3968 bool hasDefaultVisibility = !aDefaultVisibility.isEmpty();
3969 aResMgr->setWorkingMode( prevMode );
3971 if( !storeWin && !storeTb && aDefaultState.isEmpty() && !hasDefaultVisibility)
3974 if ( aResMgr->hasValue("windows_geometry" ,modName ) ) {
3975 long version = Qtx::versionToId( aResMgr->stringValue( "windows_geometry_version", modName, "" ) );
3977 if ( version > Qtx::versionToId( "7.4.1" ) )
3978 aResMgr->value( "windows_geometry", modName , arr );
3980 arr = aDefaultState;
3981 QByteArray aTargetArray = processState(arr, storeWin, storeTb, true, aDefaultState);
3982 desktop()->restoreState( aTargetArray );
3985 QStringList mainToolbarsNames;
3986 mainToolbarsNames << "SalomeStandard" << "SalomeModules";
3987 QList<QToolBar*> mainToolbars = findToolBars( mainToolbarsNames );
3988 foreach( QToolBar* tb, mainToolbars ) tb->setVisible( true );
3990 if ( !myWinVis.contains( modName ) && aDefaultVisibility.isEmpty())
3993 QMap<QString, bool> *tbMap = 0;
3994 QMap<QString, bool> *dwMap = 0;
3996 QMap<QString, bool> userTbMap, userDwMap;
3997 dockWindowsState( myWinVis[modName], userTbMap, userDwMap );
3999 QMap<QString, bool> defaultTbMap, defaultDwMap;
4000 if(hasDefaultVisibility) {
4001 dockWindowsState( aDefaultVisibility, defaultTbMap, defaultDwMap);
4007 if(hasDefaultVisibility){
4008 tbMap = &defaultTbMap;
4015 if(hasDefaultVisibility){
4016 dwMap = &defaultDwMap;
4021 QList<QToolBar*> tbList = findToolBars();
4022 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit )
4024 QToolBar* tb = *tit;
4025 if ( tbMap->contains( tb->objectName() ) ) {
4026 tb->setVisible( (*tbMap)[tb->objectName()] );
4032 QList<QDockWidget*> dwList = desktop()->findChildren<QDockWidget*>();
4033 for ( QList<QDockWidget*>::iterator dit = dwList.begin(); dit != dwList.end(); ++dit )
4035 QDockWidget* dw = *dit;
4037 QObject* po = Qtx::findParent( dw, "QMainWindow" );
4038 if ( po != desktop() )
4041 if ( dwMap->contains( dw->objectName() ) )
4042 dw->setVisible( (*dwMap)[dw->objectName()] );
4050 Saves windows geometry
4052 void LightApp_Application::saveDockWindowsState()
4057 bool storeWin = resourceMgr()->booleanValue( "Study", "store_positions", true );
4058 bool storeTb = resourceMgr()->booleanValue( "Study", "store_tool_positions", true );
4060 if( !storeWin && !storeTb )
4064 if ( activeModule() )
4065 modName = activeModule()->name();
4066 else if ( activeStudy() )
4067 modName = "nomodule";
4069 QString versionId = GUI_VERSION_STR;
4070 #if GUI_DEVELOPMENT > 0
4074 QByteArray arr = desktop()->saveState();
4075 resourceMgr()->setValue( "windows_geometry", modName, processState(arr, storeWin, storeTb, false) );
4076 resourceMgr()->setValue( "windows_geometry_version", modName, versionId );
4079 if ( myWinVis.contains( modName ) )
4080 visArr = myWinVis[modName];
4082 QMap<QString, bool> tbMap, dwMap;
4083 dockWindowsState( visArr, tbMap, dwMap );
4085 QList<QToolBar*> tbList = desktop()->findChildren<QToolBar*>();
4086 for ( QList<QToolBar*>::iterator it = tbList.begin(); it != tbList.end(); ++it )
4089 tbMap.insert( tb->objectName(), tb->toggleViewAction()->isChecked() );
4092 QList<QDockWidget*> dwList = desktop()->findChildren<QDockWidget*>();
4093 for ( QList<QDockWidget*>::iterator it = dwList.begin(); it != dwList.end(); ++it )
4095 QDockWidget* wid = *it;
4096 dwMap.insert( wid->objectName(), wid->toggleViewAction()->isChecked() );
4099 visArr = dockWindowsState( tbMap, dwMap );
4101 myWinVis.insert( modName, visArr );
4104 QByteArray LightApp_Application::dockWindowsState( const QMap<QString, bool>& tb, const QMap<QString, bool>& dw ) const
4107 QDataStream stream( &visArr, QIODevice::WriteOnly );
4109 stream << (uchar)ToolBarMarker;
4110 stream << tb.size();
4111 for ( QMap<QString, bool>::const_iterator tit = tb.begin(); tit != tb.end(); ++tit )
4113 stream << tit.key();
4114 stream << (uchar)( tit.value() ? 1 : 0 );
4117 stream << (uchar)DockWidgetMarker;
4118 stream << dw.size();
4119 for ( QMap<QString, bool>::const_iterator wit = dw.begin(); wit != dw.end(); ++wit )
4121 stream << wit.key();
4122 stream << (uchar)( wit.value() ? 1 : 0 );
4128 void LightApp_Application::dockWindowsState( const QByteArray& arr, QMap<QString, bool>& tb, QMap<QString, bool>& dw ) const
4133 QByteArray visArr = arr;
4134 QDataStream stream( &visArr, QIODevice::ReadOnly );
4138 if ( marker != ToolBarMarker )
4143 for ( int i = 0; i < lines; ++i )
4146 stream >> objectName;
4149 tb.insert( objectName, shown );
4153 if ( marker != DockWidgetMarker )
4157 for ( int j = 0; j < lines; ++j )
4160 stream >> objectName;
4163 dw.insert( objectName, shown );
4168 Adds icon names for modules
4170 void LightApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) const
4174 SUIT_ResourceMgr* resMgr = resourceMgr();
4178 QStringList modList;
4179 modules( modList, false );
4181 for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )
4183 QString modName = *it;
4184 QString modIntr = moduleName( modName );
4185 QString modIcon = resMgr->stringValue( modIntr, "icon", QString() );
4187 if ( modIcon.isEmpty() )
4190 if ( SUIT_Tools::extension( modIcon ).isEmpty() )
4191 modIcon += QString( ".png" );
4193 iconMap.insert( modName, modIcon );
4198 Inserts items in popup, which necessary for current application
4200 void LightApp_Application::contextMenuPopup( const QString& type, QMenu* thePopup, QString& title )
4203 LightApp_SelectionMgr* selMgr = LightApp_Application::selectionMgr();
4204 bool cacheIsOn = selMgr->isSelectionCacheEnabled();
4205 selMgr->setSelectionCacheEnabled( true );
4207 SUIT_DataBrowser* ob = objectBrowser();
4209 CAM_Application::contextMenuPopup( type, thePopup, title );
4211 if ( ob && type == ob->popupClientType() ) {
4212 thePopup->addSeparator();
4213 QAction* a = thePopup->addAction( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
4214 if ( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) )
4215 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) );
4218 #ifndef DISABLE_SALOMEOBJECT
4219 if ( selMgr && ob ) {
4220 SALOME_ListIO selected;
4221 selMgr->selectedObjects( selected );
4222 if(selected.Extent() == 1){
4223 Handle(SALOME_InteractiveObject) anIObject = selected.First();
4224 SUIT_DataObject* obj = findObject(anIObject->getEntry());
4225 if(obj && obj->renameAllowed()) {
4226 QAction* a = new QAction(tr("MEN_RENAME_OBJ"), thePopup);
4227 connect( a, SIGNAL( triggered(bool) ), ob, SLOT( onStartEditing() ) );
4228 if ( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) )
4229 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) );
4231 QList<QAction*> acts = thePopup->actions();
4232 QAction* firstAction = acts.count() > 0 ? acts.first() : 0;
4233 thePopup->insertAction(firstAction,a);
4239 selMgr->setSelectionCacheEnabled( cacheIsOn );
4245 void LightApp_Application::createEmptyStudy()
4247 CAM_Application::createEmptyStudy();
4249 if ( objectBrowser() )
4250 objectBrowser()->updateTree();
4252 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
4253 if ( aResMgr && activeStudy() ) {
4254 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
4255 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
4260 void LightApp_Application::setDesktop( SUIT_Desktop* desk )
4262 CAM_Application::setDesktop( desk );
4265 connect( desk, SIGNAL( message( const QString& ) ),
4266 this, SLOT( onDesktopMessage( const QString& ) ), Qt::UniqueConnection );
4267 connect( desk, SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
4268 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
4269 /* connect( desk, SIGNAL( windowMoved( SUIT_ViewWindow* ) ),
4270 this, SLOT( onWindowMoved( SUIT_ViewWindow* ) ), Qt::UniqueConnection ); */
4276 \param mod - module to be activated
4278 bool LightApp_Application::activateModule( CAM_Module* mod )
4280 bool res = CAM_Application::activateModule( mod );
4282 if ( objectBrowser() )
4283 objectBrowser()->updateTree();
4289 \return keyborad accelerators manager object
4291 SUIT_Accel* LightApp_Application::accel() const
4297 Removes dead widget container from map
4299 void LightApp_Application::onWCDestroyed( QObject* ob )
4301 // remove destroyed widget container from windows map
4302 for ( WinMap::ConstIterator itr = myWin.begin(); itr != myWin.end(); ++itr )
4304 if ( itr.value() != ob )
4307 int key = itr.key();
4308 myWin.remove( key );
4313 void LightApp_Application::onMRUActivated( const QString& name )
4315 SUIT_Session* s = SUIT_Session::session();
4316 if ( s && s->activeApplication() == this )
4320 void LightApp_Application::onStylePreferences()
4322 #ifdef USE_SALOME_STYLE
4323 Style_PrefDlg dlg( desktop() );
4326 resourceMgr()->setValue( "Style", "use_salome_style", Style_Salome::isActive() );
4327 #endif // USE_SALOME_STYLE
4330 void LightApp_Application::onFullScreen(){
4331 if(myScreenHelper) {
4332 if(desktop()->isFullScreen())
4333 myScreenHelper->switchToNormalScreen();
4335 myScreenHelper->switchToFullScreen();
4340 Connects just added view manager
4342 void LightApp_Application::addViewManager( SUIT_ViewManager* vm )
4344 connect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
4345 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
4346 CAM_Application::addViewManager( vm );
4350 Remove view manager from memory
4352 void LightApp_Application::removeViewManager( SUIT_ViewManager* vm )
4354 disconnect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
4355 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
4356 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
4358 aStudy->removeObjectProperties( vm->getGlobalId() );
4360 CAM_Application::removeViewManager( vm );
4362 LightApp_SelectionMgr* selMgr = selectionMgr();
4363 QList<SUIT_Selector*> selectors;
4364 selMgr->selectors( selectors );
4365 foreach( SUIT_Selector* selector, selectors ) {
4366 if ( selector->owner() == vm->getViewModel() ) {
4371 // IPAL22894: Crash on closing OCC view
4377 Renames active window of desktop
4379 void LightApp_Application::onRenameWindow()
4384 QWidget* w = desktop()->activeWindow();
4389 QString name = QInputDialog::getText( w, tr( "TOT_RENAME" ), tr( "PRP_RENAME" ), QLineEdit::Normal, w->windowTitle(), &ok );
4390 if( ok && !name.isEmpty() )
4391 w->setWindowTitle( name );
4395 Closes active window of desktop
4397 void LightApp_Application::onCloseWindow()
4402 QWidget* w = desktop()->activeWindow();
4410 Closes all windows of desktop
4412 void LightApp_Application::onCloseAllWindow()
4414 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
4418 QList<SUIT_ViewWindow*> wndList = desk->windows();
4419 SUIT_ViewWindow* wnd;
4420 foreach( wnd, wndList )
4428 Groups all windows of desktop
4430 void LightApp_Application::onGroupAllWindow()
4432 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
4436 QtxWorkstack* wgStack = desk->workstack();
4442 \return if the library of module exists
4443 \param moduleTitle - title of module
4445 bool LightApp_Application::isLibExists( const QString& moduleTitle ) const
4447 if( moduleTitle.isEmpty() )
4450 QString lib = moduleLibrary( moduleTitle );
4452 //abd: changed libSalomePyQtGUI to SalomePyQtGUI for WIN32
4453 bool isPythonModule = lib.contains("SalomePyQtGUI");
4454 bool isPythonLightModule = lib.contains("SalomePyQtGUILight");
4458 paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
4460 paths = QString(::getenv( "LD_LIBRARY_PATH" )).split( ":", QString::SkipEmptyParts );
4463 bool isLibFound = false;
4464 QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
4465 for( ; anIt!=aLast; anIt++ )
4467 QFileInfo inf( Qtx::addSlash( *anIt ) + lib );
4478 INFOS( "\n****************************************************************" << std::endl
4479 << "* Warning: library " << lib.toLatin1().constData() << " cannot be found" << std::endl
4480 << "* Module " << moduleTitle.toLatin1().constData() << " will not be available in GUI mode" << std::endl
4481 << "****************************************************************" << std::endl );
4483 else if ( !isPythonModule && !isPythonLightModule)
4486 if ( isPythonModule || isPythonLightModule)
4488 QString pylib = moduleName( moduleTitle ) + QString(".py");
4489 QString pylibgui = moduleName( moduleTitle ) + QString("GUI.py");
4491 // Check the python library
4493 // paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
4495 paths = QString(::getenv( "PYTHONPATH" )).split( ":", QString::SkipEmptyParts );
4497 bool isPyLib = false, isPyGuiLib = false;
4498 QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
4499 for( ; anIt!=aLast; anIt++ )
4501 QFileInfo inf( Qtx::addSlash( *anIt ) + pylib );
4502 QFileInfo infgui( Qtx::addSlash( *anIt ) + pylibgui );
4504 if(!isPythonLightModule)
4505 if( !isPyLib && inf.exists() )
4508 if( !isPyGuiLib && infgui.exists() )
4511 if ((isPyLib || isPythonLightModule ) && isPyGuiLib && isLibFound)
4515 printf( "\n****************************************************************\n" );
4516 printf( "* Warning: python library for %s cannot be found:\n", moduleTitle.toLatin1().constData() );
4518 printf( "* No module named %s\n", moduleName( moduleTitle ).toLatin1().constData() );
4520 printf( "* No module named %s\n", (moduleName( moduleTitle ) + QString("GUI")).toLatin1().constData() );
4521 printf( "****************************************************************\n" );
4528 \return default name for an active study
4530 void LightApp_Application::setDefaultStudyName( const QString& theName )
4532 QStringList anInfoList;
4533 modules( anInfoList, false );
4535 LightApp_Study* aStudy = (LightApp_Study*)activeStudy();
4536 if( anInfoList.count() == 1 && // to avoid a conflict between different modules
4537 !aStudy->isSaved() )
4539 aStudy->setStudyName( theName );
4540 updateDesktopTitle();
4545 Custom event handler
4547 bool LightApp_Application::event( QEvent* e )
4549 if( e && e->type()==2000 )
4551 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
4552 QString* d = ( QString* )ce->data();
4553 if( SUIT_MessageBox::question(0, tr("WRN_WARNING"),
4555 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
4556 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
4557 showPreferences( tr( "PREF_APP" ) );
4562 return CAM_Application::event( e );
4565 /*! Check data object */
4566 bool LightApp_Application::checkDataObject(LightApp_DataObject* theObj)
4570 bool isSuitable = !theObj->entry().isEmpty() &&
4571 !theObj->componentDataType().isEmpty() &&
4572 !theObj->name().isEmpty();
4579 int LightApp_Application::openChoice( const QString& aName )
4581 int choice = CAM_Application::openChoice( aName );
4583 if ( choice == OpenExist ) // The document is already open.
4585 // Do you want to reload it?
4586 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "QUE_DOC_ALREADYOPEN" ).arg( aName ),
4587 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No ) == SUIT_MessageBox::Yes )
4588 choice = OpenReload;
4594 bool LightApp_Application::openAction( const int choice, const QString& aName )
4601 STD_Application* app = 0;
4602 SUIT_Session* session = SUIT_Session::session();
4603 QList<SUIT_Application*> appList = session->applications();
4604 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !app; ++it )
4606 if ( (*it)->activeStudy() && (*it)->activeStudy()->studyName() == aName )
4607 app = ::qobject_cast<STD_Application*>( *it );
4612 app->onCloseDoc( false );
4613 appList = session->applications();
4614 STD_Application* other = 0;
4615 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !other; ++it )
4616 other = ::qobject_cast<STD_Application*>( *it );
4619 res = other->onOpenDoc( aName );
4624 res = CAM_Application::openAction( choice, aName );
4631 QStringList LightApp_Application::viewManagersTypes() const
4633 QStringList aTypesList;
4634 aTypesList += myUserWmTypes;
4635 #ifndef DISABLE_GLVIEWER
4636 aTypesList<<GLViewer_Viewer::Type();
4638 #ifndef DISABLE_PLOT2DVIEWER
4639 aTypesList<<Plot2d_Viewer::Type();
4641 #ifndef DISABLE_QXGRAPHVIEWER
4642 aTypesList<<QxScene_Viewer::Type();
4644 #ifndef DISABLE_PVVIEWER
4645 aTypesList<<PVViewer_Viewer::Type();
4647 #ifndef DISABLE_PYVIEWER
4648 aTypesList<<PyViewer_Viewer::Type();
4650 #ifndef DISABLE_OCCVIEWER
4651 aTypesList<<OCCViewer_Viewer::Type();
4653 #ifndef DISABLE_VTKVIEWER
4654 #ifndef DISABLE_SALOMEOBJECT
4655 aTypesList<<SVTK_Viewer::Type();
4657 aTypesList<<VTKViewer_Viewer::Type();
4663 * Removes all view managers of known types
4664 * Other view managers are ignored
4666 void LightApp_Application::clearKnownViewManagers()
4668 QStringList aTypesList = viewManagersTypes();
4669 QList<SUIT_ViewManager*> aMgrList;
4670 viewManagers( aMgrList );
4671 foreach (SUIT_ViewManager* aMgr, aMgrList) {
4672 if (aTypesList.contains(aMgr->getType()))
4673 removeViewManager(aMgr);
4678 Copy of current selection
4680 void LightApp_Application::onCopy()
4682 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
4688 Paste of current data in clipboard
4690 void LightApp_Application::onPaste()
4692 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
4698 Browse (i.e. set focus on) the published objects
4699 \param theIsApplyAndClose - flag indicating that the dialog for creating objects
4700 has been accepted by Ok (or Apply & Close) button
4701 \param theIsOptimizedBrowsing - flag switching to optimized browsing mode
4702 (to select the first published object only)
4703 \return entry of the selected object
4705 QString LightApp_Application::browseObjects( const QStringList& theEntryList,
4706 const bool theIsApplyAndClose,
4707 const bool theIsOptimizedBrowsing )
4710 if( SUIT_ResourceMgr* aResourceMgr = resourceMgr() )
4712 int aBrowsePolicy = aResourceMgr->integerValue( "ObjectBrowser", "browse_published_object", (int)BP_Never );
4713 switch( aBrowsePolicy )
4717 case BP_ApplyAndClose:
4718 if( !theIsApplyAndClose )
4726 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
4730 SUIT_DataBrowser* anOB = objectBrowser();
4734 SUIT_AbstractModel* aModel = dynamic_cast<SUIT_AbstractModel*>( anOB->model() );
4738 QStringListIterator anIter( theEntryList );
4739 if( theIsOptimizedBrowsing )
4741 // go to the last entry
4743 if( anIter.hasPrevious() )
4747 // scroll to each entry in the list
4748 // (in optimized mode - to the last entry only)
4750 LightApp_DataObject* anObject = 0;
4751 while( anIter.hasNext() )
4753 anEntry = anIter.next();
4754 if( !anEntry.isEmpty() )
4756 anObject = aStudy->findObjectByEntry( anEntry );
4759 QModelIndex anIndex = aModel->index( anObject );
4760 anOB->treeView()->scrollTo( anIndex );
4765 // always select the last object
4766 if( anObject && !anEntry.isEmpty() )
4768 QList<SUIT_Selector*> aSelectorList;
4769 selectionMgr()->selectors( "ObjectBrowser", aSelectorList );
4770 if( !aSelectorList.isEmpty() )
4772 if( LightApp_OBSelector* aSelector = dynamic_cast<LightApp_OBSelector*>( aSelectorList.first() ) )
4774 bool anIsAutoBlock = aSelector->autoBlock();
4776 // temporarily disable auto block, to emit LightApp_SelectionMgr::currentSelectionChanged() signal
4777 aSelector->setAutoBlock( false );
4779 SUIT_DataOwnerPtrList aList;
4780 #ifndef DISABLE_SALOMEOBJECT
4781 Handle(SALOME_InteractiveObject) aSObj = new SALOME_InteractiveObject
4782 ( anObject->entry().toLatin1().constData(),
4783 anObject->componentDataType().toLatin1().constData(),
4784 anObject->name().toLatin1().constData() );
4785 LightApp_DataOwner* owner = new LightApp_DataOwner( aSObj );
4787 LightApp_DataOwner* owner = new LightApp_DataOwner( anEntry );
4790 aList.append( owner );
4791 selectionMgr()->setSelected( aList );
4794 // restore auto block flag
4795 aSelector->setAutoBlock( anIsAutoBlock );
4803 SUIT_DataObject* LightApp_Application::findObject( const QString& id ) const
4805 LightApp_Study* study = dynamic_cast<LightApp_Study*>( activeStudy() );
4806 return study ? study->findObjectByEntry( id ) : 0;
4810 Checks that an object can be renamed.
4811 \param entry entry of the object
4812 \brief Return \c true if object can be renamed
4814 bool LightApp_Application::renameAllowed( const QString& /*entry*/) const {
4819 Rename object by entry.
4820 \param entry entry of the object
4821 \param name new name of the object
4822 \brief Return \c true if rename operation finished successfully, \c false otherwise.
4824 bool LightApp_Application::renameObject( const QString& entry, const QString& ) {
4828 /*! Process standard messages from desktop */
4829 void LightApp_Application::onDesktopMessage( const QString& message )
4831 const QString sectionSeparator = "/";
4833 if ( message.toLower() == "updateobjectbrowser" ||
4834 message.toLower() == "updateobjbrowser" ) {
4835 // update object browser
4836 updateObjectBrowser();
4838 else if ( message.toLower().startsWith( "activate_viewer" ) ) {
4839 QString vtype = message.split( sectionSeparator ).last();
4840 if ( !vtype.isEmpty() )
4841 getViewManager( vtype, true );
4844 QStringList data = message.split( sectionSeparator );
4845 if ( data.count() > 1 ) {
4846 QString msgType = data[0].trimmed();
4847 LightApp_Module* sMod = 0;
4848 CAM_Module* mod = module( msgType );
4850 mod = module( moduleTitle( msgType ) );
4851 if ( mod && mod->inherits( "LightApp_Module" ) )
4852 sMod = (LightApp_Module*)mod;
4854 if ( msgType.toLower() == "preferences" ) {
4855 // requested preferences change: should be given as "preferences/<section>/<name>/<value>"
4856 // for example "preferences/Study/multi_file_dump/true"
4857 if ( data.count() > 3 ) {
4858 QString section = data[1].trimmed();
4859 QString param = data[2].trimmed();
4860 QString value = QStringList( data.mid(3) ).join( sectionSeparator );
4861 resourceMgr()->setValue( section, param, value );
4865 // received message for the module
4866 QString msg = QStringList( data.mid(1) ).join( sectionSeparator );
4867 sMod->message( msg );
4875 Returns all top level toolbars.
4876 Note : Result list contains only main window toolbars, not including toolbars from viewers.
4878 QList<QToolBar*> LightApp_Application::findToolBars( const QStringList& names )
4880 QList<QToolBar*> aResult;
4881 QList<QToolBar*> tbList = desktop()->findChildren<QToolBar*>();
4882 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit ) {
4883 QToolBar* tb = *tit;
4884 QObject* po = Qtx::findParent( tb, "QMainWindow" );
4885 if ( po != desktop() )
4887 if ( names.isEmpty() || names.contains( tb->objectName() ) )
4894 Internal method to parse toolbars and dockable windows state.
4896 QByteArray LightApp_Application::processState(QByteArray& input,
4897 const bool processWin,
4898 const bool processTb,
4899 const bool isRestoring,
4900 QByteArray defaultState) {
4903 bool hasDefaultState = !defaultState.isEmpty();
4904 bool isDockWinWriten = false;
4906 //Write date from users settings
4908 QDataStream tmpInputData(&input, QIODevice::ReadOnly);
4909 int marker, version;
4911 tmpInputData >> marker;
4912 tmpInputData >> version;
4913 tmpInputData >> dockmarker;
4914 tmpInputData >> nbDocWin;
4916 if(processWin && processTb && !isRestoring) {
4918 } else if(!processWin && !processTb ) {
4920 aRes = defaultState;
4922 QDataStream aData(&aRes, QIODevice::WriteOnly);
4923 QList<QToolBar*> aToolBars = findToolBars();
4926 for ( QList<QToolBar*>::iterator tit = aToolBars.begin(); tit != aToolBars.end(); ++tit ) {
4927 QToolBar* tb = *tit;
4928 aNames.append(tb->objectName());
4931 int toolBarMarkerIndex = getToolbarMarkerIndex(input,aNames);
4932 if(toolBarMarkerIndex < 0)
4934 QDataStream anInputData(&input, QIODevice::ReadOnly);
4936 int toolBarMarkerIndexDef;
4937 if(hasDefaultState) {
4938 toolBarMarkerIndexDef = getToolbarMarkerIndex(defaultState, aNames);
4939 if(toolBarMarkerIndexDef < 0)
4942 QDataStream anInputDataDef(&defaultState, QIODevice::ReadOnly);
4944 QDataStream* aTargetData = 0;
4945 int aTargetIndex = -1;
4947 QByteArray currentArr = desktop()->saveState();
4948 QDataStream anInputDataCur(¤tArr, QIODevice::ReadOnly);
4949 bool useInputData = !isRestoring || (isRestoring && nbDocWin > 0);
4950 if(processWin && useInputData) {
4951 aTargetData = &anInputData;
4952 aTargetIndex = toolBarMarkerIndex;
4954 //Write date from default settings
4955 if(hasDefaultState) {
4956 aTargetData = &anInputDataDef;
4957 aTargetIndex = toolBarMarkerIndexDef;
4959 //If no default state, write current snapshot of the dockable windows
4961 aTargetData = &anInputDataCur;
4962 int toolBarMarkerIndexCur = getToolbarMarkerIndex(currentArr, aNames);
4963 aTargetIndex = toolBarMarkerIndexCur;
4968 if(aTargetData && aTargetIndex >= 0 ) {
4969 aTargetData->device()->seek(0);
4970 while( aTargetData->device()->pos() < aTargetIndex ) {
4975 isDockWinWriten = true;
4982 aTargetData = &anInputData;
4983 aTargetIndex = toolBarMarkerIndex;
4985 if(hasDefaultState) {
4986 aTargetData = &anInputDataDef;
4987 aTargetIndex = toolBarMarkerIndexDef;
4991 if(aTargetData && aTargetIndex >= 0) {
4993 if(!isDockWinWriten ) {
4994 //Write version marker
4995 int marker, version;
4996 aTargetData->device()->seek(0);
4997 *aTargetData >> marker;
4998 *aTargetData >> version;
5001 aData << (uchar) QDockWidgetMarker;
5003 int shift = 4*sizeof(int) + sizeof(QSize);
5004 index = aTargetIndex - shift;
5006 index = aTargetIndex;
5009 aTargetData->device()->seek(index);
5010 while(!aTargetData->atEnd()) {
5015 } else { // Not treat toolbars
5016 aData << (uchar) QToolBarMarker;
5017 aData << (int) 0; //Nb toolbars = 0
5024 \brief Emits operationFinished signal.
5025 \param theModuleName the name of the module which perfomed the operation
5026 \param theOperationName the operation name
5027 \param theEntryList the list of the created objects entries
5029 void LightApp_Application::emitOperationFinished( const QString& theModuleName,
5030 const QString& theOperationName,
5031 const QStringList& theEntryList )
5033 emit operationFinished( theModuleName, theOperationName, theEntryList );
5037 Update visibility state of given objects
5039 void LightApp_Application::updateVisibilityState( DataObjectList& theList,
5040 SUIT_ViewModel* theViewModel )
5042 if ( !theViewModel || theList.isEmpty() ) return;
5044 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
5045 if ( !aStudy ) return;
5047 SALOME_View* aView = dynamic_cast<SALOME_View*>( theViewModel );
5049 for ( DataObjectList::iterator itr = theList.begin(); itr != theList.end(); ++itr ) {
5050 LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>(*itr);
5052 if ( !obj || aStudy->isComponent( obj->entry() ) )
5055 LightApp_Module* anObjModule = dynamic_cast<LightApp_Module*>(obj->module());
5056 if ( anObjModule ) {
5057 LightApp_Displayer* aDisplayer = anObjModule->displayer();
5059 Qtx::VisibilityState anObjState = Qtx::UnpresentableState;
5060 if ( aDisplayer->canBeDisplayed( obj->entry(), theViewModel->getType() ) ) {
5061 if ( aView && aDisplayer->IsDisplayed( obj->entry(), aView ) )
5062 anObjState = Qtx::ShownState;
5064 anObjState = Qtx::HiddenState;
5066 aStudy->setVisibilityState( obj->entry(), anObjState );
5073 * Called when window activated
5075 void LightApp_Application::onWindowActivated( SUIT_ViewWindow* theViewWindow )
5077 SUIT_DataBrowser* anOB = objectBrowser();
5080 SUIT_DataObject* rootObj = anOB->root();
5084 DataObjectList listObj = rootObj->children( true );
5086 SUIT_ViewModel* vmod = 0;
5087 if ( SUIT_ViewManager* vman = theViewWindow->getViewManager() )
5088 vmod = vman->getViewModel();
5089 updateVisibilityState( listObj, vmod );
5093 Called then view manager removed
5095 void LightApp_Application::onViewManagerRemoved( SUIT_ViewManager* )
5097 ViewManagerList lst;
5098 viewManagers( lst );
5099 if ( lst.count() == 1) { // in case if closed last view window
5100 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
5102 aStudy->setVisibilityStateForAll( Qtx::UnpresentableState );
5107 Check existing document.
5109 bool LightApp_Application::checkExistingDoc()
5112 if( activeStudy() ) {
5113 int answer = SUIT_MessageBox::question( desktop(),
5114 tr( "APPCLOSE_CAPTION" ),
5115 tr( "STUDYCLOSE_DESCRIPTION" ),
5116 tr( "APPCLOSE_SAVE" ),
5117 tr( "APPCLOSE_CLOSE" ),
5118 tr( "APPCLOSE_CANCEL" ), 0 );
5120 if ( activeStudy()->isSaved() ) {
5123 } else if ( onSaveAsDoc() ) {
5124 if( !closeDoc( false ) ) {
5131 else if( answer == 1 ) {
5133 } else if( answer == 2 ) {
5140 #ifndef DISABLE_PYCONSOLE
5142 PyConsole_Interp* LightApp_Application::getPyInterp()
5144 static PyConsole_Interp* myInterp = 0;
5146 myInterp = createPyInterp();
5147 myInterp->initialize();
5152 PyConsole_Interp* LightApp_Application::createPyInterp()
5154 return new PyConsole_Interp();
5157 #endif // DISABLE_PYCONSOLE