1 // Copyright (C) 2007-2013 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.
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_PyInterp.h" // WARNING! This include must be the first!
39 #include <PyConsole_Console.h>
42 #include "LightApp_Application.h"
43 #include "LightApp_Module.h"
44 #include "LightApp_DataModel.h"
45 #include "LightApp_Study.h"
46 #include "LightApp_Preferences.h"
47 #include "LightApp_PreferencesDlg.h"
48 #include "LightApp_ModuleDlg.h"
49 #include "LightApp_AboutDlg.h"
50 #include "LightApp_ModuleAction.h"
51 // temporary commented
52 #include "LightApp_EventFilter.h"
53 #include "LightApp_OBSelector.h"
54 #include "LightApp_SelectionMgr.h"
55 #include "LightApp_DataObject.h"
56 #include "LightApp_WgViewModel.h"
57 #include "LightApp_FullScreenHelper.h"
60 #include <GUI_version.h>
61 #include <Basics_OCCTVersion.hxx>
63 #include <SALOME_Event.h>
65 #include <Style_Salome.h>
66 #include <Style_PrefDlg.h>
68 #include <CAM_Module.h>
69 #include <CAM_DataModel.h>
70 #include <CAM_Study.h>
71 #include <STD_TabDesktop.h>
73 #include <SUIT_DataBrowser.h>
74 #include <SUIT_Session.h>
75 #include <SUIT_Study.h>
76 #include <SUIT_FileDlg.h>
77 #include <SUIT_ResourceMgr.h>
78 #include <SUIT_ShortcutMgr.h>
79 #include <SUIT_Tools.h>
80 #include <SUIT_Accel.h>
81 #include <SUIT_MessageBox.h>
82 #include <SUIT_ViewWindow.h>
85 #include <QtxToolBar.h>
86 #include <QtxTreeView.h>
87 #include <QtxMRUAction.h>
88 #include <QtxDockAction.h>
89 #include <QtxDockWidget.h>
90 #include <QtxActionToolMgr.h>
91 #include <QtxSearchTool.h>
92 #include <QtxWorkstack.h>
94 #include <QtxWebBrowser.h>
96 #include <LogWindow.h>
98 #ifndef DISABLE_GLVIEWER
99 #include <GLViewer_Viewer.h>
100 #include <GLViewer_ViewManager.h>
101 #include "LightApp_GLSelector.h"
104 #ifndef DISABLE_PLOT2DVIEWER
105 #include <Plot2d_ViewManager.h>
106 #include <Plot2d_ViewModel.h>
107 #include <Plot2d_ViewWindow.h>
108 #include <Plot2d_ViewFrame.h>
109 #include "LightApp_Plot2dSelector.h"
110 #ifndef DISABLE_SALOMEOBJECT
111 #include <SPlot2d_ViewModel.h>
113 #include <Plot2d_ViewModel.h>
117 #ifndef DISABLE_OCCVIEWER
118 #include <OCCViewer_ViewManager.h>
119 #include <OCCViewer_ViewFrame.h>
120 #ifndef DISABLE_SALOMEOBJECT
121 #include <SOCC_ViewModel.h>
123 #include <OCCViewer_ViewModel.h>
125 #include "LightApp_OCCSelector.h"
128 #ifndef DISABLE_VTKVIEWER
129 #ifndef DISABLE_SALOMEOBJECT
130 #include <SVTK_ViewModel.h>
131 #include <SVTK_ViewManager.h>
132 #include "LightApp_VTKSelector.h"
134 #include <VTKViewer_ViewModel.h>
135 #include <VTKViewer_ViewManager.h>
137 #include <VTKViewer_ViewModel.h>
140 #ifndef DISABLE_QXGRAPHVIEWER
141 #include <QxScene_ViewManager.h>
142 #include <QxScene_ViewModel.h>
143 #include <QxScene_ViewWindow.h>
147 #define VISIBILITY_COLUMN_WIDTH 25
153 #include <QStringList>
155 #include <QApplication>
157 #include <QStatusBar>
159 #include <QObjectList>
161 #include <QInputDialog>
162 #include <QFontDatabase>
164 #include <QByteArray>
168 #include <QHeaderView>
173 #include <utilities.h>
175 #define FIRST_HELP_ID 1000000
177 #ifndef DISABLE_SALOMEOBJECT
178 #include <SALOME_InteractiveObject.hxx>
179 #include <SALOME_ListIO.hxx>
182 #include <Standard_Version.hxx>
184 #define ToolBarMarker 0
185 #define DockWidgetMarker 1
187 static const char* imageEmptyIcon[] = {
190 "....................",
191 "....................",
192 "....................",
193 "....................",
194 "....................",
195 "....................",
196 "....................",
197 "....................",
198 "....................",
199 "....................",
200 "....................",
201 "....................",
202 "....................",
203 "....................",
204 "....................",
205 "....................",
206 "....................",
207 "....................",
208 "....................",
209 "...................."};
211 int LightApp_Application::lastStudyId = 0;
214 // Markers used to parse array with dockable windows and toolbars state.
215 // For more details please see the qdockarealayout.cpp && qtoolbararealayout.cpp
216 // in the Qt source code.
218 #define QDockWidgetMarker 0xfd // = DockWidgetStateMarker
219 #define QToolBarMarker 0xfc // = ToolBarStateMarkerEx
221 // Format of the Byte array with the windows and toolbar state is:
222 // VersionMarker|version|DockWidgetStateMarker|nbDockWidgetLines|...DocWidgetData...|ToolBarStateMarkerEx|nbToolBarLines|...ToolBarData...
224 //Find toolbar marker position in the array in the following way:
225 //since the 'toolbar marker' is not unique, find index of first occurrence of the
226 //'toolbar marker' in the array and check that next string is name of the toolbar
228 int getToolbarMarkerIndex(QByteArray input, const QStringList& aFlags) {
229 int aResult = -1,tmp = 0;
230 int inputLen = input.length();
231 QDataStream anInputData(&input, QIODevice::ReadOnly);
232 while(tmp < inputLen) {
233 tmp = input.indexOf(QToolBarMarker, tmp + 1);
236 anInputData.device()->seek(tmp);
240 anInputData >> lines;
242 if(lines == 0 && anInputData.atEnd()){
243 //Case then array doesn't contain information about toolbars,
254 if(aFlags.contains(str)) {
263 \return last global id of study
265 int LightApp_Application::studyId()
267 return LightApp_Application::lastStudyId;
270 /*!Create new instance of LightApp_Application.*/
271 extern "C" LIGHTAPP_EXPORT SUIT_Application* createApplication()
273 return new LightApp_Application();
276 /*! \var global preferences of LightApp */
277 LightApp_Preferences* LightApp_Application::_prefs_ = 0;
281 \class LightApp_Application
282 Application containing LightApp module
286 LightApp_Application::LightApp_Application()
287 : CAM_Application( false ),
289 myScreenHelper(new LightApp_FullScreenHelper())
291 Q_INIT_RESOURCE( LightApp );
293 STD_TabDesktop* desk = new STD_TabDesktop();
294 desk->setFullScreenAllowed(false);
295 desk->setMinimizeAllowed(false);
299 // initialize auto save timer
300 myAutoSaveTimer = new QTimer( this );
301 myAutoSaveTimer->setSingleShot( true );
302 connect( myAutoSaveTimer, SIGNAL( timeout() ), this, SLOT( onSaveDoc() ) );
304 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
305 QPixmap aLogo = aResMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
307 QtxWebBrowser::setResourceManager( aResMgr );
308 QtxWebBrowser::setData("browser:icon", aResMgr->loadPixmap( "LightApp", tr( "BROWSER_ICON" ) ) );
309 QtxWebBrowser::setData("browser:title", tr( "BROWSER_TITLE" ) );
310 QtxWebBrowser::setData("toolbar:title", tr( "BROWSER_TOOLBAR_TITLE" ) );
311 QtxWebBrowser::setData("menu:file:title", tr( "BROWSER_FILEMENU" ) );
312 QtxWebBrowser::setData("action:close:title", tr( "BROWSER_CLOSE" ) );
313 QtxWebBrowser::setData("action:close:icon", aResMgr->loadPixmap( "LightApp", tr( "BROWSER_CLOSE_ICON" ) ) );
314 QtxWebBrowser::setData("action:back:title", tr( "BROWSER_BACK" ) );
315 QtxWebBrowser::setData("action:forward:title", tr( "BROWSER_FORWARD" ) );
316 QtxWebBrowser::setData("action:find:title", tr( "BROWSER_FIND" ) );
317 QtxWebBrowser::setData("action:findnext:title", tr( "BROWSER_FINDNEXT" ) );
318 QtxWebBrowser::setData("action:findprev:title", tr( "BROWSER_FINDPREV" ) );
320 desktop()->setWindowIcon( aLogo );
321 desktop()->setDockableMenuBar( false );
322 desktop()->setDockableStatusBar( false );
324 // base logo (salome itself)
325 desktop()->logoInsert( "_app_base", aResMgr->loadPixmap( "LightApp", tr( "APP_BASE_LOGO" ), false ) );
326 // extra logo (salome-based application)
327 desktop()->logoInsert( "_app_extra", aResMgr->loadPixmap( "LightApp", tr( "APP_EXTRA_LOGO" ), false ) );
331 mySelMgr = new LightApp_SelectionMgr( this );
333 myAccel = SUIT_Accel::getAccel();
335 #ifndef DISABLE_OCCVIEWER
336 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, OCCViewer_Viewer::Type() );
337 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, OCCViewer_Viewer::Type() );
338 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, OCCViewer_Viewer::Type() );
339 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, OCCViewer_Viewer::Type() );
340 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, OCCViewer_Viewer::Type() );
341 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, OCCViewer_Viewer::Type() );
342 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, OCCViewer_Viewer::Type() );
343 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, OCCViewer_Viewer::Type() );
344 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, OCCViewer_Viewer::Type() );
345 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, OCCViewer_Viewer::Type() );
346 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, OCCViewer_Viewer::Type() );
347 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, OCCViewer_Viewer::Type() );
349 #ifndef DISABLE_VTKVIEWER
350 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, VTKViewer_Viewer::Type() );
351 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, VTKViewer_Viewer::Type() );
352 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, VTKViewer_Viewer::Type() );
353 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, VTKViewer_Viewer::Type() );
354 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, VTKViewer_Viewer::Type() );
355 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, VTKViewer_Viewer::Type() );
356 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, VTKViewer_Viewer::Type() );
357 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, VTKViewer_Viewer::Type() );
358 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, VTKViewer_Viewer::Type() );
359 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, VTKViewer_Viewer::Type() );
360 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, VTKViewer_Viewer::Type() );
361 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, VTKViewer_Viewer::Type() );
363 #ifndef DISABLE_PLOT2DVIEWER
364 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, Plot2d_Viewer::Type() );
365 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, Plot2d_Viewer::Type() );
366 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, Plot2d_Viewer::Type() );
367 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, Plot2d_Viewer::Type() );
368 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, Plot2d_Viewer::Type() );
369 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, Plot2d_Viewer::Type() );
370 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, Plot2d_Viewer::Type() );
371 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, Plot2d_Viewer::Type() );
374 connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) );
376 // Set existing font for the python console in resources
377 if( !aResMgr->hasValue( "PyConsole", "font" ) )
380 QFont f = aResMgr->fontValue( "PyConsole", "font" );
382 QStringList famdb = fdb.families();
384 if ( famdb.contains(f.family()) || !aResMgr->hasValue( "PyConsole", "additional_families" ) )
387 QStringList anAddFamilies = aResMgr->stringValue( "PyConsole", "additional_families" ).split( ";", QString::SkipEmptyParts );
389 for ( QStringList::Iterator it = anAddFamilies.begin(); it != anAddFamilies.end(); ++it )
392 if ( famdb.contains(aFamily) )
394 f.setFamily( aFamily );
395 aResMgr->setValue( "PyConsole", "font", f );
402 *\li Save window geometry.
403 *\li Save desktop geometry.
404 *\li Save resource maneger.
405 *\li Delete selection manager.
407 LightApp_Application::~LightApp_Application()
410 delete myScreenHelper;
413 /*!Start application.*/
414 void LightApp_Application::start()
416 CAM_Application::start();
419 updateViewManagers();
422 desktop()->statusBar()->showMessage( "" );
424 LightApp_EventFilter::Init();
427 /*!Gets application name.*/
428 QString LightApp_Application::applicationName() const
430 static QString _app_name;
431 if ( _app_name.isEmpty() )
432 _app_name = tr( "APP_NAME" );
436 /*!Gets application version.*/
437 QString LightApp_Application::applicationVersion() const
439 static QString _app_version;
441 if ( _app_version.isEmpty() )
443 QString resVersion = tr( "APP_VERSION" );
444 if ( resVersion != "APP_VERSION" )
446 _app_version = resVersion;
450 _app_version = GUI_VERSION_STR;
456 /*!Load module by \a name.*/
457 CAM_Module* LightApp_Application::loadModule( const QString& name, const bool showMsg )
459 CAM_Module* mod = CAM_Application::loadModule( name, showMsg );
462 connect( this, SIGNAL( studyOpened() ), mod, SLOT( onModelOpened() ) );
463 connect( this, SIGNAL( studySaved() ), mod, SLOT( onModelSaved() ) );
464 connect( this, SIGNAL( studyClosed() ), mod, SLOT( onModelClosed() ) );
469 /*!Activate module by \a modName*/
470 bool LightApp_Application::activateModule( const QString& modName )
473 CAM_Module* prevMod = activeModule();
476 actName = prevMod->moduleName();
478 if ( actName == modName )
481 putInfo( tr( "ACTIVATING_MODULE" ).arg( modName ) );
483 saveDockWindowsState();
485 bool status = CAM_Application::activateModule( modName );
487 updateModuleActions();
495 updateViewManagers();
500 /*!Gets selection manager.*/
501 LightApp_SelectionMgr* LightApp_Application::selectionMgr() const
506 /*!Creat action "New window" for certain type of viewer:*/
507 void LightApp_Application::createActionForViewer( const int id,
509 const QString& suffix,
512 QString vtlt = tr( QString( "NEW_WINDOW_%1" ).arg( suffix ).toLatin1().constData() );
513 QString tip = tr( "CREATING_NEW_WINDOW" ).arg( vtlt.remove( "&" ) );
514 QAction* a = createAction( id, // menu action id
521 false, // toggle flag
523 SLOT( onNewWindow() ) ); // slot
524 createMenu( a, parentId, -1 );
529 void LightApp_Application::createActions()
531 CAM_Application::createActions();
533 SUIT_Desktop* desk = desktop();
534 SUIT_ResourceMgr* resMgr = resourceMgr();
537 createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIcon(),
538 tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
539 Qt::CTRL+Qt::Key_R, desk, false, this, SLOT( onPreferences() ) );
543 // - Help for modules
545 int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
546 createMenu( separator(), helpMenu, -1, 10 );
547 QStringList aModuleList;
548 modules( aModuleList, false );
549 aModuleList.prepend( "GUI" );
550 aModuleList.prepend( "KERNEL" );
552 int id = LightApp_Application::UserID + FIRST_HELP_ID;
555 foreach( aModule, aModuleList ) {
556 if ( aModule.isEmpty() ) // module title (user name)
558 IMap <QString, QString> helpData; // list of help files for the module
559 QString helpSubMenu; // help submenu name (empty if not needed)
560 QString modName = moduleName( aModule ); // module name
561 if ( modName.isEmpty() ) modName = aModule; // for KERNEL and GUI
562 QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName ); // module root dir variable
563 QString modDir = getenv( rootDir.toLatin1().constData() ); // module root dir
565 if (resMgr->hasValue( modName, "documentation" ) )
566 docSection = resMgr->stringValue(modName, "documentation");
567 else if ( resMgr->hasSection( modName + "_documentation" ) )
568 docSection = modName + "_documentation";
569 if ( !docSection.isEmpty() ) {
570 helpSubMenu = resMgr->stringValue( docSection, "sub_menu", "" ).arg( aModule );
571 QStringList listOfParam = resMgr->parameters( docSection );
572 foreach( QString paramName, listOfParam ) {
573 QString valueStr = resMgr->stringValue( docSection, paramName );
574 if ( !valueStr.isEmpty() ) {
575 QFileInfo fi( valueStr );
576 if ( fi.isRelative() && !modDir.isEmpty() )
577 valueStr = Qtx::addSlash( modDir ) + valueStr;
578 if ( QFile::exists( valueStr ) )
579 helpData.insert( paramName.arg( aModule ), valueStr );
584 if ( helpData.isEmpty() && !modDir.isEmpty() ) {
585 QStringList idxLst = QStringList() << modDir << "share" << "doc" << "salome" << "gui" << modName << "index.html";
586 QString indexFile = idxLst.join( QDir::separator() ); // index file
587 if ( QFile::exists( indexFile ) )
588 helpData.insert( tr( "%1 module Users's Guide" ).arg( aModule ), indexFile );
591 IMapConstIterator<QString, QString > fileIt;
592 for ( fileIt = helpData.begin(); fileIt != helpData.end(); fileIt++ ) {
593 QString helpFileName = fileIt.key();
594 // remove all '//' occurances
595 while ( helpFileName.contains( "//" ) )
596 helpFileName.replace( "//", "" );
597 // obtain submenus hierarchy if given
598 QStringList smenus = helpFileName.split( "/" );
599 helpFileName = smenus.last();
601 QAction* a = createAction( id, helpFileName,
602 resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
603 helpFileName, helpFileName,
604 0, desk, false, this, SLOT( onHelpContentsModule() ) );
605 a->setData( fileIt.value() );
606 if ( !helpSubMenu.isEmpty() ) {
607 smenus.prepend( helpSubMenu );
609 // create sub-menus hierarchy
610 int menuId = helpMenu;
611 foreach ( QString subMenu, smenus ) {
612 menuId = createMenu( subMenu, menuId, -1, 0 );
614 createMenu( a, menuId, -1, 0 );
619 // - Additional help items
621 createMenu( separator(), helpMenu, -1, 5 );
623 QStringList addHelpItems = resMgr->parameters( "add_help" );
624 foreach ( QString addHelpItem, addHelpItems ) {
625 QString valueStr = resMgr->stringValue( "add_help", addHelpItem );
626 if ( !valueStr.isEmpty() && QFile::exists( valueStr ) ) {
627 QAction* a = createAction( id, addHelpItem,
628 resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
629 addHelpItem, addHelpItem,
630 0, desk, false, this, SLOT( onHelpContentsModule() ) );
631 a->setData( valueStr );
632 createMenu( a, helpMenu, -1, 5 );
638 static QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), 0 );
639 connect( mru, SIGNAL( activated( const QString& ) ), this, SLOT( onMRUActivated( const QString& ) ) );
640 registerAction( MRUId, mru );
642 // default icon for neutral point ('SALOME' module)
643 QPixmap defIcon = resMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
644 if ( defIcon.isNull() )
645 defIcon = QPixmap( imageEmptyIcon );
647 //! default icon for any module
648 QPixmap modIcon = resMgr->loadPixmap( "LightApp", tr( "APP_MODULE_ICO" ), false );
649 if ( modIcon.isNull() )
650 modIcon = QPixmap( imageEmptyIcon );
653 modules( modList, false );
655 if ( modList.count() > 1 )
657 LightApp_ModuleAction* moduleAction =
658 new LightApp_ModuleAction( tr( "APP_NAME" ), defIcon, desk );
660 QMap<QString, QString> iconMap;
661 moduleIconNames( iconMap );
663 const int iconSize = 20;
665 QStringList::Iterator it;
666 for ( it = modList.begin(); it != modList.end(); ++it )
668 if ( !isLibExists( *it ) )
671 QString modName = moduleName( *it );
673 if ( !isModuleAccessible( *it ) )
677 if ( iconMap.contains( *it ) )
678 iconName = iconMap[*it];
680 QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
684 INFOS ( "****************************************************************" << std::endl
685 << "* Icon for " << (*it).toLatin1().constData()
686 << " not found. Using the default one." << std::endl
687 << "****************************************************************" << std::endl );
690 icon = Qtx::scaleIcon( icon, iconSize );
692 moduleAction->insertModule( *it, icon );
695 connect( moduleAction, SIGNAL( moduleActivated( const QString& ) ),
696 this, SLOT( onModuleActivation( const QString& ) ) );
697 registerAction( ModulesListId, moduleAction );
701 int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, MenuWindowId, 100 );
702 int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
704 createAction( CloseId, tr( "TOT_CLOSE" ), QIcon(), tr( "MEN_DESK_CLOSE" ), tr( "PRP_CLOSE" ),
705 Qt::CTRL+Qt::Key_F4, desk, false, this, SLOT( onCloseWindow() ) );
706 createAction( CloseAllId, tr( "TOT_CLOSE_ALL" ), QIcon(), tr( "MEN_DESK_CLOSE_ALL" ), tr( "PRP_CLOSE_ALL" ),
707 0, desk, false, this, SLOT( onCloseAllWindow() ) );
708 createAction( GroupAllId, tr( "TOT_GROUP_ALL" ), QIcon(), tr( "MEN_DESK_GROUP_ALL" ), tr( "PRP_GROUP_ALL" ),
709 0, desk, false, this, SLOT( onGroupAllWindow() ) );
711 createMenu( CloseId, windowMenu, 0, -1 );
712 createMenu( CloseAllId, windowMenu, 0, -1 );
713 createMenu( GroupAllId, windowMenu, 0, -1 );
714 createMenu( separator(), windowMenu, -1, 0 );
716 #ifndef DISABLE_GLVIEWER
717 createActionForViewer( NewGLViewId, newWinMenu, QString::number( 0 ), Qt::ALT+Qt::Key_G );
719 #ifndef DISABLE_PLOT2DVIEWER
720 createActionForViewer( NewPlot2dId, newWinMenu, QString::number( 1 ), Qt::ALT+Qt::Key_P );
722 #ifndef DISABLE_OCCVIEWER
723 createActionForViewer( NewOCCViewId, newWinMenu, QString::number( 2 ), Qt::ALT+Qt::Key_O );
725 #ifndef DISABLE_VTKVIEWER
726 createActionForViewer( NewVTKViewId, newWinMenu, QString::number( 3 ), Qt::ALT+Qt::Key_K );
728 #ifndef DISABLE_QXGRAPHVIEWER
729 createActionForViewer( NewQxSceneViewId, newWinMenu, QString::number( 4 ), Qt::ALT+Qt::Key_S );
732 createAction( RenameId, tr( "TOT_RENAME" ), QIcon(), tr( "MEN_DESK_RENAME" ), tr( "PRP_RENAME" ),
733 Qt::ALT+Qt::SHIFT+Qt::Key_R, desk, false, this, SLOT( onRenameWindow() ) );
734 createMenu( RenameId, windowMenu, -1 );
736 int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
737 createMenu( PreferencesId, fileMenu, 50, -1 );
738 createMenu( separator(), fileMenu, -1, 50, -1 );
740 createMenu( separator(), fileMenu, -1, 100, -1 );
741 createMenu( MRUId, fileMenu, 100, -1 );
742 createMenu( separator(), fileMenu, -1, 100, -1 );
744 createAction( StyleId, tr( "TOT_THEME" ), QIcon(), tr( "MEN_DESK_THEME" ), tr( "PRP_THEME" ),
745 0, desk, false, this, SLOT( onStylePreferences() ) );
747 createAction( FullScreenId, tr( "TOT_FULLSCREEN" ), QIcon(), tr( "MEN_DESK_FULLSCREEN" ), tr( "PRP_FULLSCREEN" ),
748 Qt::Key_F11, desk, false, this, SLOT( onFullScreen() ) );
751 int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1 );
752 createMenu( separator(), viewMenu, -1, 20, -1 );
753 createMenu( StyleId, viewMenu, 20, -1 );
754 createMenu( FullScreenId, viewMenu, 20, -1 );
756 int modTBar = createTool( tr( "INF_TOOLBAR_MODULES" ) );
757 createTool( ModulesListId, modTBar );
760 /*!On module activation action.*/
761 void LightApp_Application::onModuleActivation( const QString& modName )
763 // Force user to create/open a study before module activation
764 QMap<QString, QString> iconMap;
765 moduleIconNames( iconMap );
766 QPixmap icon = resourceMgr()->loadPixmap( moduleName( modName ), iconMap[ modName ], false );
768 icon = resourceMgr()->loadPixmap( "LightApp", tr( "APP_MODULE_BIG_ICO" ), false ); // default icon for any module
770 bool cancelled = false;
772 while ( !modName.isEmpty() && !activeStudy() && !cancelled ){
773 LightApp_ModuleDlg aDlg( desktop(), modName, icon );
774 QMap<int, QString> opmap = activateModuleActions();
775 for ( QMap<int, QString>::ConstIterator it = opmap.begin(); it != opmap.end(); ++it )
776 aDlg.addButton( it.value(), it.key() );
778 int res = aDlg.exec();
780 // some operation is selected
781 moduleActionSelected( res );
785 putInfo( tr("INF_CANCELLED") );
787 LightApp_ModuleAction* moduleAction =
788 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
790 moduleAction->setActiveModule( QString() );
796 activateModule( modName );
799 /*!Default module activation.*/
800 QString LightApp_Application::defaultModule() const
802 QStringList aModuleNames;
803 modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration
804 //! If there's the one and only module --> activate it automatically
805 //! TODO: Possible improvement - default module can be taken from preferences
806 return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" );
809 /*!On new window slot.*/
810 void LightApp_Application::onNewWindow()
812 const QObject* obj = sender();
813 if ( !obj || !obj->inherits( "QAction" ) )
817 int id = actionId( (QAction*)obj );
820 #ifndef DISABLE_GLVIEWER
822 type = GLViewer_Viewer::Type();
825 #ifndef DISABLE_PLOT2DVIEWER
827 type = Plot2d_Viewer::Type();
830 #ifndef DISABLE_OCCVIEWER
832 type = OCCViewer_Viewer::Type();
835 #ifndef DISABLE_VTKVIEWER
837 type = VTKViewer_Viewer::Type();
840 #ifndef DISABLE_QXGRAPHVIEWER
841 case NewQxSceneViewId:
842 type = QxScene_Viewer::Type();
847 if ( !type.isEmpty() )
848 createViewManager( type );
852 SLOT: Creates new document
854 void LightApp_Application::onNewDoc()
856 //asl: fix for 0020515
858 saveDockWindowsState();
860 CAM_Application::onNewDoc();
864 SLOT: Opens new document
866 void LightApp_Application::onOpenDoc()
868 SUIT_Study* study = activeStudy();
869 saveDockWindowsState();
871 CAM_Application::onOpenDoc();
873 if ( !study ) // new study will be create in THIS application
876 updateViewManagers();
881 SLOT: Opens new document.
882 \param aName - name of file
884 bool LightApp_Application::onOpenDoc( const QString& aName )
886 // We should take mru action first because this application instance can be deleted later.
887 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
889 bool res = CAM_Application::onOpenDoc( aName );
894 mru->insert( aName );
896 mru->remove( aName );
902 SLOT: Displays "About" message box
904 void LightApp_Application::onHelpAbout()
906 LightApp_AboutDlg dlg( applicationName(), applicationVersion(), desktop() );
911 Private SLOT: Called on selection is changed
912 Dispatchs active module that selection is changed
914 void LightApp_Application::onSelection()
916 onSelectionChanged();
918 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
919 ((LightApp_Module*)activeModule())->selectionChanged();
924 \param study - SUIT_Study.
926 void LightApp_Application::setActiveStudy( SUIT_Study* study )
928 CAM_Application::setActiveStudy( study );
932 Enables/Disables menu items and toolbar buttons. Rebuild menu
934 void LightApp_Application::updateCommandsStatus()
936 CAM_Application::updateCommandsStatus();
939 #ifndef DISABLE_GLVIEWER
940 a = action( NewGLViewId );
942 a->setEnabled( activeStudy() );
945 #ifndef DISABLE_PLOT2DVIEWER
946 a = action( NewPlot2dId );
948 a->setEnabled( activeStudy() );
951 #ifndef DISABLE_OCCVIEWER
952 a = action( NewOCCViewId );
954 a->setEnabled( activeStudy() );
957 #ifndef DISABLE_VTKVIEWER
958 a = action( NewVTKViewId );
960 a->setEnabled( activeStudy() );
963 #ifndef DISABLE_QXGRAPHVIEWER
964 a = action( NewQxSceneViewId );
966 a->setEnabled( activeStudy() );
972 Runs system command in separate thread
974 class RunBrowser: public QThread
977 RunBrowser( LightApp_Application* app,
978 const QString& theApp,
979 const QString& theParams,
980 const QString& theHelpFile,
981 const QString& theContext = QString() )
983 myParams( theParams ),
984 myContext( theContext ),
988 //For the external browser always specify 'file://' protocol,
989 //because some WEB browsers (for example Mozilla Firefox) can't open local file without protocol.
990 myHelpFile = QString("file://%1").arg( QFileInfo( theHelpFile ).canonicalFilePath() );
995 if ( !myApp.isEmpty() && !myHelpFile.isEmpty()) {
996 QString aCommand = QString( "%1 %2 \"%3%4\"" ).arg( myApp, myParams, myHelpFile, myContext.isEmpty() ? QString("") : QString( "#%1" ).arg( myContext ) );
998 QProcess* proc = new QProcess();
1000 proc->start( aCommand );
1001 if ( !proc->waitForStarted() ) {
1002 SALOME_CustomEvent* ce2000 = new SALOME_CustomEvent( 2000 );
1003 QString* msg = new QString( QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).arg( myApp, myHelpFile ) );
1004 ce2000->setData( msg );
1005 QApplication::postEvent( myLApp, ce2000 );
1016 LightApp_Application* myLApp;
1020 SLOT: Displays help contents for choosen module
1022 void LightApp_Application::onHelpContentsModule()
1024 const QAction* a = (QAction*) sender();
1025 QString helpFile = a->data().toString();
1026 if ( helpFile.isEmpty() ) return;
1028 SUIT_ResourceMgr* resMgr = resourceMgr();
1031 platform = "winapplication";
1033 platform = "application";
1035 QString anApp = resMgr->stringValue("ExternalBrowser", platform);
1037 QString quote("\"");
1038 anApp.prepend( quote );
1039 anApp.append( quote );
1041 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
1042 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1044 if( useExtBrowser ) {
1045 if ( !anApp.isEmpty() ) {
1046 RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile );
1050 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1051 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1052 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1054 showPreferences( tr( "PREF_APP" ) );
1059 // On Win32 platform QWebKit of the Qt 4.6.3 hang up in case 'file://' protocol
1060 // is defined. On Linux platform QWebKit doesn't work correctly without 'file://' protocol.
1061 QtxWebBrowser::loadUrl(helpFile);
1063 QtxWebBrowser::loadUrl(QString("file://%1").arg(helpFile));
1069 SLOT: Displays help contents for choosen dialog
1071 void LightApp_Application::onHelpContextModule( const QString& theComponentName,
1072 const QString& theFileName,
1073 const QString& theContext )
1075 QString fileName = theFileName;
1076 QString context = theContext;
1077 if ( !QFile::exists( fileName ) && theContext.isEmpty() ) {
1078 // context might be passed within theFileName argument
1079 QStringList comps = fileName.split("#");
1080 if ( comps.count() > 1 ) {
1081 context = comps.last();
1083 fileName = comps.join("#");
1087 QString homeDir = "";
1088 if ( !theComponentName.isEmpty() ) {
1089 QString dir = getenv( ( theComponentName + "_ROOT_DIR" ).toLatin1().constData() );
1090 if ( !dir.isEmpty() )
1091 homeDir = Qtx::addSlash( Qtx::addSlash( dir ) +
1092 Qtx::addSlash( "share" ) +
1093 Qtx::addSlash( "doc" ) +
1094 Qtx::addSlash( "salome" ) +
1095 Qtx::addSlash( "gui" ) +
1096 Qtx::addSlash( theComponentName ) );
1099 QString helpFile = QFileInfo( homeDir + fileName ).absoluteFilePath();
1100 SUIT_ResourceMgr* resMgr = resourceMgr();
1103 platform = "winapplication";
1105 platform = "application";
1107 QString anApp = resMgr->stringValue("ExternalBrowser", platform);
1109 QString quote("\"");
1110 anApp.prepend( quote );
1111 anApp.append( quote );
1114 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1117 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
1119 if ( !anApp.isEmpty() ) {
1120 RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile, context );
1124 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1125 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1126 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1127 showPreferences( tr( "PREF_APP" ) );
1132 // On Win32 platform QWebKit of the Qt 4.6.3 hang up in case 'file://' protocol
1133 // is defined. On Linux platform QWebKit doesn't work correctly without 'file://' protocol.
1134 QtxWebBrowser::loadUrl(helpFile, context);
1136 QtxWebBrowser::loadUrl(QString("file://%1").arg(helpFile), context);
1143 Sets enable or disable some actions on selection changed.
1145 void LightApp_Application::onSelectionChanged()
1147 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
1148 bool canCopy = m ? m->canCopy() : false;
1149 bool canPaste = m ? m->canPaste() : false;
1151 action( EditCopyId )->setEnabled(canCopy);
1152 action( EditPasteId )->setEnabled(canPaste);
1156 Adds window to application.
1157 \param wid - QWidget
1158 \param flag - key for window
1159 \param studyId - study id
1160 Flag used how identificator of window in windows list.
1163 void LightApp_Application::addWindow( QWidget* wid, const int flag, const int studyId )
1171 if ( !activeStudy() )
1174 sId = activeStudy()->id();
1177 if ( !myWindows.contains( flag ) )
1179 QMap<int, int> winMap;
1180 currentWindows( winMap );
1182 LightApp_WidgetContainer* newWC = new LightApp_WidgetContainer( flag, desktop() );
1183 connect( newWC, SIGNAL( destroyed ( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
1184 // asv: connecting a slot for storing visibility flag of a window
1185 connect( newWC, SIGNAL( visibilityChanged ( bool ) ), SLOT( onVisibilityChanged( bool ) ) );
1186 myWindows.insert( flag, newWC );
1187 if ( winMap.contains( flag ) ) {
1188 //desktop()->removeDockWidget( myWindows[flag] );
1189 desktop()->addDockWidget( (Qt::DockWidgetArea)winMap[flag], myWindows[flag] );
1192 //myWindows[flag]->setResizeEnabled( true );
1193 myWindows[flag]->setFeatures( QDockWidget::AllDockWidgetFeatures );
1194 myWindows[flag]->setObjectName( QString( "dock_window_%1" ).arg( flag ) );
1195 //myWindows[flag]->setFixedExtentWidth( wid->width() );
1196 //myWindows[flag]->setFixedExtentHeight( wid->height() );
1197 myWindows[flag]->resize( wid->width(), wid->height() );
1201 #ifndef DISABLE_PYCONSOLE
1202 if( wid->inherits( "PyConsole_Console" ) )
1204 if( resourceMgr()->hasValue( "PyConsole", "font" ) )
1205 f = resourceMgr()->fontValue( "PyConsole", "font" );
1208 f = ( ( PyConsole_Console* )wid )->font();
1209 resourceMgr()->setValue( "PyConsole", "font", f );
1216 myWindows[flag]->insert( sId, wid );
1219 setWindowShown( flag, !myWindows[flag]->isEmpty() );
1223 QWidget* LightApp_Application::dockWindow( const int id ) const
1226 if ( myWin.contains( id ) )
1231 QDockWidget* LightApp_Application::windowDock( QWidget* wid ) const
1236 QDockWidget* dock = 0;
1237 QWidget* w = wid->parentWidget();
1238 while ( w && !dock )
1240 dock = ::qobject_cast<QDockWidget*>( w );
1241 w = w->parentWidget();
1246 void LightApp_Application::insertDockWindow( const int id, QWidget* wid )
1251 if ( wid != dockWindow( id ) )
1252 removeDockWindow( id );
1254 myWin.insert( id, wid );
1256 QtxDockWidget* dock = new QtxDockWidget( true, desktop() );
1257 connect( dock, SIGNAL( destroyed( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
1259 dock->setFeatures( QDockWidget::AllDockWidgetFeatures );
1260 dock->setObjectName( QString( "window_%1" ).arg( id ) );
1261 dock->setWidget( wid );
1263 QKeySequence accel = wid->property( "shortcut" ).value<QKeySequence>();
1264 if ( !accel.isEmpty() )
1265 dock->toggleViewAction()->setShortcut( accel );
1270 void LightApp_Application::removeDockWindow( const int id )
1272 QWidget* wid = dockWindow( id );
1278 QDockWidget* dock = windowDock( wid );
1282 dock->setWidget( 0 );
1283 wid->setParent( 0 );
1284 wid->setVisible( false );
1288 void LightApp_Application::placeDockWindow( const int id, Qt::DockWidgetArea place )
1290 QDockWidget* dock = windowDock( dockWindow( id ) );
1291 if ( dock && desktop() ) {
1292 desktop()->addDockWidget( place, dock );
1293 QtxDockAction* a = qobject_cast<QtxDockAction*>( action( ViewWindowsId ) );
1294 if ( a ) a->update();
1300 \param flag - key for window
1301 \param studyId - study id
1302 Flag used how identificator of window in windows list.
1304 QWidget* LightApp_Application::getWindow( const int flag, const int )
1306 QWidget* wid = dockWindow( flag );
1308 insertDockWindow( flag, wid = createWindow( flag ) );
1310 QMap<int, int> winMap;
1311 currentWindows( winMap );
1312 if ( winMap.contains( flag ) )
1313 placeDockWindow( flag, (Qt::DockWidgetArea)winMap[flag] );
1319 \return Object Browser
1321 SUIT_DataBrowser* LightApp_Application::objectBrowser()
1323 return qobject_cast<SUIT_DataBrowser*>( dockWindow( WT_ObjectBrowser ) );
1329 LogWindow* LightApp_Application::logWindow()
1331 return qobject_cast<LogWindow*>( dockWindow( WT_LogWindow ) );
1334 #ifndef DISABLE_PYCONSOLE
1336 This returns the python console integrated to the GUI. Depending
1337 when you request the python console, this function could return
1338 null. Then the optional parameter force (default to false) can be
1339 set to force the creation of the python console if it is not done
1341 \param force - if true, the pythonConsole is created if it does not exist yet
1342 \return Python Console
1344 PyConsole_Console* LightApp_Application::pythonConsole(const bool force)
1346 QWidget* wid = dockWindow( WT_PyConsole );
1347 if ( !wid && force==true) {
1348 wid = getWindow(WT_PyConsole);
1350 return qobject_cast<PyConsole_Console*>( wid );
1355 Updates object browser and maybe data models
1356 \param updateModels - if it is true, then data models are updated
1358 void LightApp_Application::updateObjectBrowser( const bool updateModels )
1360 // update existing data models
1363 const bool isAutoUpdate = objectBrowser() ? objectBrowser()->autoUpdate() : true;
1364 if ( objectBrowser() )
1365 objectBrowser()->setAutoUpdate( false );
1367 LightApp_Study* study = dynamic_cast<LightApp_Study*>(activeStudy());
1369 CAM_Study::ModelList dm_list;
1370 study->dataModels( dm_list );
1371 QListIterator<CAM_DataModel*> it( dm_list );
1372 while ( it.hasNext() ) {
1373 CAM_DataModel* camDM = it.next();
1374 if ( camDM && camDM->inherits( "LightApp_DataModel" ) )
1375 ((LightApp_DataModel*)camDM)->update();
1379 if( objectBrowser() )
1380 objectBrowser()->setAutoUpdate( isAutoUpdate );
1383 if ( objectBrowser() ) {
1384 objectBrowser()->updateGeometry();
1385 objectBrowser()->updateTree( 0, false );
1392 LightApp_Preferences* LightApp_Application::preferences() const
1394 return preferences( false );
1398 \return first view manager of some type
1399 \param vmType - type of view manager
1400 \param create - is it necessary to create view manager in case, when there is no manager of such type
1402 SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, const bool create )
1404 SUIT_ViewManager* aVM = viewManager( vmType );
1405 SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
1407 if ( anActiveVM && anActiveVM->getType() == vmType )
1410 if ( aVM && create )
1412 if ( !aVM->getActiveView() )
1415 aVM->getActiveView()->setFocus();
1418 aVM = createViewManager( vmType );
1424 Creates view manager of some type
1425 \param vmType - type of view manager
1427 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType )
1429 SUIT_ResourceMgr* resMgr = resourceMgr();
1431 SUIT_ViewManager* viewMgr = 0;
1432 #ifndef DISABLE_GLVIEWER
1433 if( vmType == GLViewer_Viewer::Type() )
1435 viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() );
1436 new LightApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
1439 #ifndef DISABLE_PLOT2DVIEWER
1440 if( vmType == Plot2d_Viewer::Type() )
1442 viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
1444 #ifndef DISABLE_SALOMEOBJECT
1445 SPlot2d_Viewer* v = new SPlot2d_Viewer();
1447 new LightApp_Plot2dSelector( v, mySelMgr );
1449 vm = new Plot2d_Viewer();
1451 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1452 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
1455 Plot2d_ViewFrame* frame = wnd->getViewFrame();
1456 frame->setBackgroundColor( resMgr->colorValue( "Plot2d", "Background", frame->backgroundColor() ) );
1460 #ifndef DISABLE_QXGRAPHVIEWER
1461 if( vmType == QxScene_Viewer::Type() )
1463 viewMgr = new QxScene_ViewManager( activeStudy(), desktop() );
1464 QxScene_Viewer* vm = new QxScene_Viewer();
1465 viewMgr->setViewModel( vm );
1466 //QxScene_ViewWindow* wnd = dynamic_cast<QxScene_ViewWindow*>( viewMgr->getActiveView() );
1469 #ifndef DISABLE_OCCVIEWER
1470 if( vmType == OCCViewer_Viewer::Type() )
1472 viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
1473 OCCViewer_Viewer* vm;
1474 #ifndef DISABLE_SALOMEOBJECT
1475 vm = new SOCC_Viewer();
1477 vm = new OCCViewer_Viewer( true );
1479 vm->setBackground( OCCViewer_ViewFrame::TOP_LEFT,
1480 resMgr->backgroundValue( "OCCViewer", "xz_background", vm->background(OCCViewer_ViewFrame::TOP_LEFT) ) );
1481 vm->setBackground( OCCViewer_ViewFrame::TOP_RIGHT,
1482 resMgr->backgroundValue( "OCCViewer", "yz_background", vm->background(OCCViewer_ViewFrame::TOP_RIGHT) ) );
1483 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_LEFT,
1484 resMgr->backgroundValue( "OCCViewer", "xy_background", vm->background(OCCViewer_ViewFrame::BOTTOM_LEFT) ) );
1485 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_RIGHT,
1486 resMgr->backgroundValue( "OCCViewer", "background", vm->background(OCCViewer_ViewFrame::MAIN_VIEW) ) );
1488 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1489 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ));
1490 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1491 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1492 vm->enablePreselection( resMgr->booleanValue( "OCCViewer", "enable_preselection", vm->isPreselectionEnabled() ) );
1493 vm->enableSelection( resMgr->booleanValue( "OCCViewer", "enable_selection", vm->isSelectionEnabled() ) );
1495 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1496 new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
1499 #ifndef DISABLE_VTKVIEWER
1500 #ifndef DISABLE_SALOMEOBJECT
1501 if ( vmType == SVTK_Viewer::Type() )
1503 if ( vmType == VTKViewer_Viewer::Type() )
1506 #ifndef DISABLE_SALOMEOBJECT
1507 viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
1508 SVTK_Viewer* vm = dynamic_cast<SVTK_Viewer*>( viewMgr->getViewModel() );
1511 vm->setProjectionMode( resMgr->integerValue( "VTKViewer", "projection_mode", vm->projectionMode() ) );
1512 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1513 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1514 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ) );
1515 vm->setStaticTrihedronVisible( resMgr->booleanValue( "3DViewer", "show_static_trihedron", vm->isStaticTrihedronVisible() ) );
1516 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1517 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1518 vm->setPreSelectionMode(resMgr->integerValue( "VTKViewer", "preselection", vm->preSelectionMode() ) );
1519 vm->enableSelection( resMgr->booleanValue( "VTKViewer", "enable_selection", vm->isSelectionEnabled() ) );
1520 vm->setIncrementalSpeed( resMgr->integerValue( "VTKViewer", "speed_value", vm->incrementalSpeed() ),
1521 resMgr->integerValue( "VTKViewer", "speed_mode", vm->incrementalSpeedMode() ) );
1522 vm->setSpacemouseButtons( resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", vm->spacemouseBtn(1) ),
1523 resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", vm->spacemouseBtn(2) ),
1524 resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", vm->spacemouseBtn(3) ) );
1525 new LightApp_VTKSelector( vm, mySelMgr );
1528 viewMgr = new VTKViewer_ViewManager( activeStudy(), desktop() );
1529 VTKViewer_Viewer* vm = dynamic_cast<VTKViewer_Viewer*>( viewMgr->getViewModel() );
1531 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1539 addViewManager( viewMgr );
1540 SUIT_ViewWindow* viewWin = viewMgr->createViewWindow();
1542 if ( viewWin && desktop() ) {
1543 viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1544 viewWin->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1550 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, QWidget* w )
1552 SUIT_ResourceMgr* resMgr = resourceMgr();
1554 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
1556 new LightApp_WgViewModel( vmType, w ) );
1557 vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
1559 addViewManager( vm );
1560 SUIT_ViewWindow* vw = vm->createViewWindow();
1561 if ( vw && desktop() ) {
1562 vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1563 vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1566 if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
1567 myUserWmTypes << vmType;
1573 SLOT: Removes view manager from application
1575 void LightApp_Application::onCloseView( SUIT_ViewManager* theVM )
1577 removeViewManager( theVM );
1581 Protected SLOT: On study created.
1582 \param theStudy - just created study
1584 void LightApp_Application::onStudyCreated( SUIT_Study* theStudy )
1586 SUIT_DataObject* aRoot = 0;
1587 if ( theStudy && theStudy->root() )
1589 aRoot = theStudy->root();
1590 //aRoot->setName( tr( "DATA_MODELS" ) );
1593 getWindow( WT_ObjectBrowser );
1595 loadDockWindowsState();
1597 if ( objectBrowser() )
1598 objectBrowser()->setRoot( aRoot );
1600 activateModule( defaultModule() );
1602 if ( objectBrowser() )
1603 objectBrowser()->openLevels();
1607 Protected SLOT: On study opened.
1608 \param theStudy - just opened study
1610 void LightApp_Application::onStudyOpened( SUIT_Study* theStudy )
1612 SUIT_DataObject* aRoot = 0;
1613 if ( theStudy && theStudy->root() )
1615 aRoot = theStudy->root();
1619 getWindow( WT_ObjectBrowser );
1621 loadDockWindowsState();
1623 if ( objectBrowser() )
1624 objectBrowser()->setRoot( aRoot );
1626 activateModule( defaultModule() );
1628 if ( objectBrowser() )
1629 objectBrowser()->openLevels();
1634 /*!Protected SLOT. On study saved.*/
1635 void LightApp_Application::onStudySaved( SUIT_Study* s )
1637 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
1639 mru->insert( s->studyName() );
1644 /*!Protected SLOT. On study closed.*/
1645 void LightApp_Application::onStudyClosed( SUIT_Study* s )
1647 // stop auto-save timer
1648 myAutoSaveTimer->stop();
1650 // Bug 10396: clear selection
1651 mySelMgr->clearSelected();
1653 // Bug 12944: emit signal only after clear selection
1656 activateModule( "" );
1659 /*!Protected SLOT.On desktop activated.*/
1660 void LightApp_Application::onDesktopActivated()
1662 CAM_Application::onDesktopActivated();
1663 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>(activeModule());
1665 aModule->studyActivated();
1668 void LightApp_Application::studyOpened( SUIT_Study* s )
1670 CAM_Application::studyOpened( s );
1673 updateViewManagers();
1676 void LightApp_Application::studySaved( SUIT_Study* s )
1678 CAM_Application::studyOpened( s );
1679 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1680 if ( aResMgr && activeStudy() ) {
1681 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
1682 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
1686 void LightApp_Application::studyCreated( SUIT_Study* s )
1688 CAM_Application::studyCreated( s );
1691 updateViewManagers();
1694 /*!Gets file filter.
1695 *\retval QString "(*.bin)"
1697 QString LightApp_Application::getFileFilter() const
1705 Shows file dialog and return user selected file name
1707 QString LightApp_Application::getFileName( bool open, const QString& initial, const QString& filters,
1708 const QString& caption, QWidget* parent )
1712 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1713 return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
1716 /*! Gets directory*/
1717 QString LightApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
1721 return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true );
1724 /*! Get open file names*/
1725 QStringList LightApp_Application::getOpenFileNames( const QString& initial, const QString& filters,
1726 const QString& caption, QWidget* parent )
1730 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1731 return SUIT_FileDlg::getOpenFileNames( parent, initial, fls, caption, true );
1734 /*!Private SLOT. Update object browser.*/
1735 void LightApp_Application::onRefresh()
1737 updateObjectBrowser( true );
1740 /*!Private SLOT. Support drag-and-drop operation.*/
1741 void LightApp_Application::onDropped( const QList<SUIT_DataObject*>& objects, SUIT_DataObject* parent, int row, Qt::DropAction action )
1743 LightApp_DataObject* parentObj = dynamic_cast<LightApp_DataObject*>( parent );
1747 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>( parentObj->module() );
1749 aModule->dropObjects( objects, parentObj, row, action );
1752 /*!Private SLOT. On preferences.*/
1753 void LightApp_Application::onPreferences()
1755 showPreferences( activeModule() ? activeModule()->moduleName() : tr( "PREF_CATEGORY_SALOME" ) );
1758 /*!Private SLOT. On preferences.*/
1759 void LightApp_Application::showPreferences( const QString& itemText )
1761 QApplication::setOverrideCursor( Qt::WaitCursor );
1763 LightApp_PreferencesDlg* prefDlg = new LightApp_PreferencesDlg( preferences( true ), desktop());
1765 QApplication::restoreOverrideCursor();
1770 preferences()->activateItem( itemText );
1772 if ( ( prefDlg->exec() == QDialog::Accepted || prefDlg->isSaved() ) && resourceMgr() )
1775 resourceMgr()->setValue( "desktop", "geometry", desktop()->storeGeometry() );
1776 resourceMgr()->save();
1779 shortcutMgr()->updateShortcuts();
1785 /*!Protected SLOT. On preferences changed.*/
1786 void LightApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param )
1788 LightApp_Module* sMod = 0;
1789 CAM_Module* mod = module( modName );
1790 if ( mod && mod->inherits( "LightApp_Module" ) )
1791 sMod = (LightApp_Module*)mod;
1794 sMod->preferencesChanged( section, param );
1796 preferencesChanged( section, param );
1797 // emit signal to allow additional preferences changing processing
1798 emit preferenceChanged( modName, section, param );
1801 /*!Remove all windows from study.*/
1802 void LightApp_Application::beforeCloseDoc( SUIT_Study* s )
1804 CAM_Application::beforeCloseDoc( s );
1807 /*!Update actions.*/
1808 void LightApp_Application::updateActions()
1810 updateCommandsStatus();
1816 SUIT_Study* LightApp_Application::createNewStudy()
1818 LightApp_Application::lastStudyId++;
1820 LightApp_Study* aStudy = new LightApp_Study( this );
1822 // Set up processing of major study-related events
1823 connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
1824 connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
1825 connect( aStudy, SIGNAL( saved ( SUIT_Study* ) ), this, SLOT( onStudySaved ( SUIT_Study* ) ) );
1826 connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
1832 Creates window by flag.
1833 \param flag - identificator of window type
1835 QWidget* LightApp_Application::createWindow( const int flag )
1839 SUIT_ResourceMgr* resMgr = resourceMgr();
1841 if ( flag == WT_ObjectBrowser )
1843 SUIT_DataBrowser* ob = new SUIT_DataBrowser( new LightApp_DataObject(), desktop() );
1844 ob->setSortMenuEnabled( true );
1845 ob->setAutoUpdate( true );
1846 if ( resMgr->hasValue( "ObjectBrowser", "auto_hide_search_tool" ) )
1847 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
1849 //ob->setAutoOpenLevel( 1 ); // commented by ASV as a fix to bug IPAL10107
1850 ob->setWindowTitle( tr( "OBJECT_BROWSER" ) );
1851 connect( ob, SIGNAL( requestUpdate() ), this, SLOT( onRefresh() ) );
1853 QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
1854 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
1855 treeModel->setSearcher( this );
1856 treeModel->registerColumn( 0, EntryCol, LightApp_DataObject::EntryId );
1857 treeModel->setAppropriate( EntryCol, Qtx::Toggled );
1859 // Mantis issue 0020136: Drag&Drop in OB
1860 SUIT_ProxyModel* proxyModel = dynamic_cast<SUIT_ProxyModel*>(treeModel);
1862 connect( proxyModel, SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
1863 this, SLOT( onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
1866 // temporary commented
1868 OB_ListView* ob_list = dynamic_cast<OB_ListView*>( const_cast<QListView*>( ob->listView() ) );
1870 ob_list->setColumnMaxWidth( 0, desktop()->width()/4 );
1873 // Create OBSelector
1874 new LightApp_OBSelector( ob, mySelMgr );
1876 ob->treeView()->header()->setResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
1877 ob->treeView()->header()->moveSection(SUIT_DataObject::NameId,SUIT_DataObject::VisibilityId);
1878 ob->treeView()->setColumnWidth(SUIT_DataObject::VisibilityId, VISIBILITY_COLUMN_WIDTH);
1879 ob->setProperty( "shortcut", QKeySequence( "Alt+Shift+O" ) );
1881 ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1883 #ifndef DISABLE_PYCONSOLE
1884 else if ( flag == WT_PyConsole )
1886 PyConsole_Console* pyCons = new PyConsole_EnhConsole( desktop(),new LightApp_PyInterp());
1887 pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
1888 pyCons->setFont(resourceMgr()->fontValue( "PyConsole", "font" ));
1889 pyCons->setIsShowBanner(resourceMgr()->booleanValue( "PyConsole", "show_banner", true ));
1890 pyCons->setProperty( "shortcut", QKeySequence( "Alt+Shift+P" ) );
1893 pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1896 else if ( flag == WT_LogWindow )
1898 LogWindow* logWin = new LogWindow( desktop() );
1899 logWin->setWindowTitle( tr( "LOG_WINDOW" ) );
1900 logWin->setProperty( "shortcut", QKeySequence( "Alt+Shift+L" ) );
1902 logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1908 \return default windows( Object Browser, Python Console )
1909 Adds to map \a aMap.
1911 void LightApp_Application::defaultWindows( QMap<int, int>& aMap ) const
1913 aMap.insert( WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1914 #ifndef DISABLE_PYCONSOLE
1915 aMap.insert( WT_PyConsole, Qt::BottomDockWidgetArea );
1917 // aMap.insert( WT_LogWindow, Qt::DockBottom );
1920 /*!Default view managers*/
1921 void LightApp_Application::defaultViewManagers( QStringList& ) const
1927 \return preferences.
1928 Create preferences, if \a crt = true.
1930 LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const
1935 LightApp_Application* that = (LightApp_Application*)this;
1937 bool toCreate = !_prefs_ && crt;
1940 _prefs_ = new LightApp_Preferences( resourceMgr() );
1941 that->createPreferences( _prefs_ );
1944 that->myPrefs = _prefs_;
1946 connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
1947 this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ) );
1952 SUIT_ResourceMgr* resMgr = resourceMgr();
1954 QList<SUIT_Application*> appList = SUIT_Session::session()->applications();
1955 for ( QList<SUIT_Application*>::iterator appIt = appList.begin(); appIt != appList.end(); ++appIt )
1957 LightApp_Application* app = ::qobject_cast<LightApp_Application*>( *appIt );
1961 QStringList modNameList;
1962 app->modules( modNameList, false );
1964 QMap<QString, QString> iconMap;
1965 app->moduleIconNames( iconMap );
1967 for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it )
1969 if ( !app->isLibExists( *it ) || _prefs_->hasModule( *it ) )
1972 int modId = _prefs_->addPreference( *it );
1973 if ( iconMap.contains( *it ) )
1974 _prefs_->setItemIcon( modId, Qtx::scaleIcon( resMgr->loadPixmap( moduleName( *it ), iconMap[*it], false ), 20 ) );
1978 app->modules( modList );
1979 QListIterator<CAM_Module*> itr( modList );
1980 while ( itr.hasNext() )
1982 LightApp_Module* mod = 0;
1984 CAM_Module* anItem = itr.next();
1985 if ( anItem->inherits( "LightApp_Module" ) )
1986 mod = (LightApp_Module*)anItem;
1988 if ( mod && !_prefs_->hasModule( mod->moduleName() ) )
1990 _prefs_->addPreference( mod->moduleName() );
1991 mod->createPreferences();
1992 that->emptyPreferences( mod->moduleName() );
1996 _prefs_->setItemProperty( "info", tr( "PREFERENCES_NOT_LOADED" ) );
2002 Adds new module to application
2004 void LightApp_Application::moduleAdded( CAM_Module* mod )
2006 CAM_Application::moduleAdded( mod );
2008 LightApp_Module* lightMod = 0;
2009 if ( mod && mod->inherits( "LightApp_Module" ) )
2010 lightMod = (LightApp_Module*)mod;
2012 if ( myPrefs && lightMod && !myPrefs->hasModule( lightMod->moduleName() ))
2014 myPrefs->addPreference( mod->moduleName() );
2015 lightMod->createPreferences();
2016 emptyPreferences( mod->moduleName() );
2020 void LightApp_Application::emptyPreferences( const QString& modName )
2022 QtxPreferenceItem* item = myPrefs->findItem( modName, true );
2023 if ( !item || !item->isEmpty() )
2026 // printf( "---------------------> Modify for empty module.\n" );
2028 QtxPagePrefFrameItem* frm = new QtxPagePrefFrameItem( item->title(), item->parentItem() );
2029 frm->setIcon( item->icon() );
2030 frm->setStretch( false );
2031 item->parentItem()->insertItem( frm, item );
2032 new QtxPagePrefLabelItem( Qt::AlignCenter, tr( "PREFERENCES_NOT_SUPPORTED" ).arg( modName ), frm );
2039 void LightApp_Application::createPreferences( LightApp_Preferences* pref )
2044 QStringList aValuesList;
2045 QList<QVariant> anIndicesList;
2049 // . Top-level "SALOME" preferences group <<start>>
2050 int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
2051 pref->setItemIcon( salomeCat, Qtx::scaleIcon( resourceMgr()->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false ), 20 ) );
2053 // .. "General" preferences tab <<start>>
2054 int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat );
2056 // ... "Language" group <<start>>
2057 int langGroup = pref->addPreference( tr( "PREF_GROUP_LANGUAGE" ), genTab );
2058 pref->setItemProperty( "columns", 2, langGroup );
2059 // .... -> application language
2060 int curLang = pref->addPreference( tr( "PREF_CURRENT_LANGUAGE" ), langGroup,
2061 LightApp_Preferences::Selector, "language", "language" );
2062 QStringList aLangs = SUIT_Session::session()->resourceMgr()->stringValue( "language", "languages", "en" ).split( "," );
2063 QList<QVariant> aIcons;
2064 foreach ( QString aLang, aLangs ) {
2065 aIcons << QPixmap( QString( ":/images/%1" ).arg( aLang ) );
2067 pref->setItemProperty( "strings", aLangs, curLang );
2068 pref->setItemProperty( "icons", aIcons, curLang );
2069 // ... "Language" group <<end>>
2071 // ... "Look and feel" group <<start>>
2072 int lookGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), genTab );
2073 pref->setItemProperty( "columns", 2, lookGroup );
2074 // .... -> show splash-screen
2075 pref->addPreference( tr( "PREF_SHOW_SPLASH" ), lookGroup, LightApp_Preferences::Bool, "launch", "splash" );
2076 // .... -> opaque resize
2077 pref->addPreference( tr( "PREF_OPAQUE_RESIZE" ), lookGroup, LightApp_Preferences::Bool, "desktop", "opaque_resize" );
2078 // .... -> drop-down buttons
2079 pref->addPreference( tr( "PREF_DROP_DOWN_BUTTONS" ), lookGroup, LightApp_Preferences::Bool, "viewers", "drop_down_buttons" );
2080 // ... "Look and feel" group <<end>>
2082 // ... "Study properties" group <<start>>
2083 int studyGroup = pref->addPreference( tr( "PREF_GROUP_STUDY" ), genTab );
2084 pref->setItemProperty( "columns", 2, studyGroup );
2085 // .... -> multi-file save
2086 pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "multi_file" );
2087 // .... -> ascii save mode
2088 pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" );
2089 // .... -> store windows geometry
2090 pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" );
2091 pref->addPreference( "", studyGroup, LightApp_Preferences::Space );
2092 pref->addPreference( tr( "PREF_STORE_TOOL_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_tool_positions" );
2093 // .... -> auto-save
2094 int autoSaveInterval = pref->addPreference( tr( "PREF_AUTO_SAVE" ), studyGroup,
2095 LightApp_Preferences::IntSpin, "Study", "auto_save_interval" );
2096 pref->setItemProperty( "min", 0, autoSaveInterval );
2097 pref->setItemProperty( "max", 1440, autoSaveInterval );
2098 pref->setItemProperty( "special", tr( "PREF_AUTO_SAVE_DISABLED" ), autoSaveInterval );
2099 // ... "Study properties" group <<end>>
2101 // ... "Help browser" group <<start>>
2102 int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab, LightApp_Preferences::Auto, "ExternalBrowser", "use_external_browser");
2104 QString platform = "winapplication";
2106 QString platform = "application";
2108 // .... -> browser application
2109 int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, LightApp_Preferences::File, "ExternalBrowser", platform );
2110 pref->setItemProperty( "mode", Qtx::PT_OpenFile, apppref );
2111 // .... -> browser parameters
2112 pref->addPreference( tr( "PREF_PARAM" ), extgroup, LightApp_Preferences::String, "ExternalBrowser", "parameters" );
2113 // ... "Help browser" group <<end>>
2115 // ... "Python console properties" group <<start>>
2116 int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab );
2118 pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, LightApp_Preferences::Font, "PyConsole", "font" );
2119 // .... -> show banner
2120 pref->addPreference( tr( "PREF_SHOW_BANNER" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "show_banner" );
2121 // ... "Python console properties" group <<end>>
2123 // ... "MRU" preferences group <<start>>
2124 int mruGroup = pref->addPreference( tr( "PREF_GROUP_MRU" ), genTab, LightApp_Preferences::Auto, "MRU", "show_mru" );
2125 pref->setItemProperty( "columns", 4, mruGroup );
2126 // number of MRU items
2127 int mruVisCount = pref->addPreference( tr( "PREF_MRU_VISIBLE_COUNT" ), mruGroup, LightApp_Preferences::IntSpin,
2128 "MRU", "visible_count" );
2129 pref->setItemProperty( "min", 0, mruVisCount );
2130 pref->setItemProperty( "max", 100, mruVisCount );
2132 int mruLinkType = pref->addPreference( tr( "PREF_MRU_LINK_TYPE" ), mruGroup, LightApp_Preferences::Selector,
2133 "MRU", "link_type" );
2134 aValuesList.clear();
2135 anIndicesList.clear();
2136 aValuesList << tr("PREF_MRU_LINK_AUTO") << tr("PREF_MRU_LINK_SHORT") << tr("PREF_MRU_LINK_FULL");
2137 anIndicesList << 0 << 1 << 2 ;
2138 pref->setItemProperty( "strings", aValuesList, mruLinkType );
2139 pref->setItemProperty( "indexes", anIndicesList, mruLinkType );
2140 // ... "MRU" preferences group <<end>>
2141 // .. "General" preferences tab <<end>>
2143 // .. "3D viewer" group <<start>>
2144 int Viewer3DGroup = pref->addPreference( tr( "PREF_GROUP_3DVIEWER" ), salomeCat );
2145 // ... -> navigation mode
2146 int vtkStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), Viewer3DGroup,
2147 LightApp_Preferences::Selector, "3DViewer", "navigation_mode" );
2148 aValuesList.clear();
2149 anIndicesList.clear();
2150 aValuesList << tr("PREF_STANDARD_STYLE") << tr("PREF_KEYFREE_STYLE");
2151 anIndicesList << 0 << 1;
2152 pref->setItemProperty( "strings", aValuesList, vtkStyleMode );
2153 pref->setItemProperty( "indexes", anIndicesList, vtkStyleMode );
2154 // ... -> zooming mode
2155 #if OCC_VERSION_LARGE > 0x0603000A // available only with OCC-6.3-sp11 and higher version
2156 int occZoomingStyleMode = pref->addPreference( tr( "PREF_ZOOMING" ), Viewer3DGroup,
2157 LightApp_Preferences::Selector, "3DViewer", "zooming_mode" );
2158 aValuesList.clear();
2159 anIndicesList.clear();
2160 aValuesList << tr("PREF_ZOOMING_AT_CENTER") << tr("PREF_ZOOMING_AT_CURSOR");
2161 anIndicesList << 0 << 1;
2162 pref->setItemProperty( "strings", aValuesList, occZoomingStyleMode );
2163 pref->setItemProperty( "indexes", anIndicesList, occZoomingStyleMode );
2165 // ... "Trihedron" group <<start>>
2166 int occTriGroup = pref->addPreference( tr( "PREF_TRIHEDRON" ), Viewer3DGroup );
2167 pref->setItemProperty( "columns", 2, occTriGroup );
2168 // .... -> trihedron size
2169 int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occTriGroup,
2170 LightApp_Preferences::DblSpin, "3DViewer", "trihedron_size" );
2171 pref->setItemProperty( "min", 1.0E-06, occTS );
2172 pref->setItemProperty( "max", 1000, occTS );
2173 // .... -> relative size of trihedron
2174 pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "relative_size" );
2175 // .... -> show static trihedron
2176 pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "show_static_trihedron" );
2177 // ... "Trihedron" group <<end>>
2178 // .. "3D viewer" group <<end>>
2180 // .. "OCC viewer" group <<start>>
2181 int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), salomeCat );
2183 // ... "Background" group <<start>>
2184 int bgGroup = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup );
2185 // pref->setItemProperty( "columns", 2, bgGroup );
2186 aValuesList.clear();
2187 anIndicesList.clear();
2189 QString formats = OCCViewer_Viewer::backgroundData( aValuesList, idList, txtList );
2190 foreach( int gid, idList ) anIndicesList << gid;
2191 // .... -> 3D viewer background
2192 int bgId = pref->addPreference( tr( "PREF_3DVIEWER_BACKGROUND" ), bgGroup,
2193 LightApp_Preferences::Background, "OCCViewer", "background" );
2194 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2195 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2196 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2197 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2198 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2199 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2200 pref->setItemProperty( "custom_enabled", false, bgId );
2201 pref->setItemProperty( "image_formats", formats, bgId );
2202 // .... -> XZ viewer background
2203 bgId = pref->addPreference( tr( "PREF_XZVIEWER_BACKGROUND" ), bgGroup,
2204 LightApp_Preferences::Background, "OCCViewer", "xz_background" );
2205 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2206 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2207 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2208 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2209 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2210 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2211 pref->setItemProperty( "custom_enabled", false, bgId );
2212 pref->setItemProperty( "image_formats", formats, bgId );
2213 // .... -> YZ viewer background
2214 bgId = pref->addPreference( tr( "PREF_YZVIEWER_BACKGROUND" ), bgGroup,
2215 LightApp_Preferences::Background, "OCCViewer", "yz_background" );
2216 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2217 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2218 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2219 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2220 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2221 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2222 pref->setItemProperty( "custom_enabled", false, bgId );
2223 pref->setItemProperty( "image_formats", formats, bgId );
2224 // .... -> XY viewer background
2225 bgId = pref->addPreference( tr( "PREF_XYVIEWER_BACKGROUND" ), bgGroup,
2226 LightApp_Preferences::Background, "OCCViewer", "xy_background" );
2227 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2228 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2229 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2230 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2231 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2232 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2233 pref->setItemProperty( "custom_enabled", false, bgId );
2234 pref->setItemProperty( "image_formats", formats, bgId );
2235 // ... "Background" group <<end>>
2238 // ... "Selection" group <<start>>
2239 int occSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), occGroup );
2240 pref->setItemProperty( "columns", 2, occSelectionGroup );
2241 // .... -> enable preselection
2242 pref->addPreference( tr( "PREF_ENABLE_PRESELECTION" ), occSelectionGroup,
2243 LightApp_Preferences::Bool, "OCCViewer", "enable_preselection" );
2244 // .... -> enable selection
2245 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), occSelectionGroup,
2246 LightApp_Preferences::Bool, "OCCViewer", "enable_selection" );
2247 // ... "Selection" group <<end>>
2249 // ... -> empty frame (for layout) <<start>>
2250 int occGen = pref->addPreference( "", occGroup, LightApp_Preferences::Frame );
2251 pref->setItemProperty( "margin", 0, occGen );
2252 pref->setItemProperty( "columns", 2, occGen );
2253 // ... -> empty frame (for layout) <<end>>
2254 // .. "OCC viewer" group <<end>>
2256 // .. "VTK viewer" group <<start>>
2257 int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), salomeCat ); //viewTab
2259 // ... -> empty frame (for layout) <<start>>
2260 int vtkGen = pref->addPreference( "", vtkGroup, LightApp_Preferences::Frame );
2261 //pref->setItemProperty( "columns", 2, vtkGen );
2262 // .... -> projection mode
2263 int vtkProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), vtkGen,
2264 LightApp_Preferences::Selector, "VTKViewer", "projection_mode" );
2265 aValuesList.clear();
2266 anIndicesList.clear();
2267 aValuesList << tr("PREF_ORTHOGRAPHIC") << tr("PREF_PERSPECTIVE");
2268 anIndicesList << 0 << 1;
2269 pref->setItemProperty( "strings", aValuesList, vtkProjMode );
2270 pref->setItemProperty( "indexes", anIndicesList, vtkProjMode );
2271 // .... -> background
2272 aValuesList.clear();
2273 anIndicesList.clear();
2275 formats = SVTK_Viewer::backgroundData( aValuesList, idList, txtList );
2276 foreach( int gid, idList ) anIndicesList << gid;
2277 bgId = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGen,
2278 LightApp_Preferences::Background, "VTKViewer", "background" );
2279 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2280 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2281 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2282 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2283 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2284 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2285 pref->setItemProperty( "custom_enabled", false, bgId );
2286 pref->setItemProperty( "image_formats", formats, bgId );
2287 // .... -> speed increment
2288 int vtkSpeed = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED" ), vtkGen,
2289 LightApp_Preferences::IntSpin, "VTKViewer", "speed_value" );
2290 pref->setItemProperty( "min", 1, vtkSpeed );
2291 pref->setItemProperty( "max", 1000, vtkSpeed );
2292 // .... -> speed mode
2293 int vtkSpeedMode = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED_MODE" ), vtkGen,
2294 LightApp_Preferences::Selector, "VTKViewer", "speed_mode" );
2295 aValuesList.clear();
2296 anIndicesList.clear();
2297 aValuesList << tr("PREF_ARITHMETIC") << tr("PREF_GEOMETRICAL");
2298 anIndicesList << 0 << 1;
2299 pref->setItemProperty( "strings", aValuesList, vtkSpeedMode );
2300 pref->setItemProperty( "indexes", anIndicesList, vtkSpeedMode );
2302 // ... "Selection" group <<start>>
2303 int vtkSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), vtkGroup );
2304 pref->setItemProperty( "columns", 2, vtkSelectionGroup );
2305 // .... -> preselection
2306 int vtkPreselection = pref->addPreference( tr( "PREF_PRESELECTION" ), vtkSelectionGroup,
2307 LightApp_Preferences::Selector, "VTKViewer", "preselection" );
2308 aValuesList.clear();
2309 anIndicesList.clear();
2310 aValuesList << tr("PREF_PRESELECTION_STANDARD") << tr("PREF_PRESELECTION_DYNAMIC") << tr("PREF_PRESELECTION_DISABLED");
2311 anIndicesList << 0 << 1 << 2;
2312 pref->setItemProperty( "strings", aValuesList, vtkPreselection );
2313 pref->setItemProperty( "indexes", anIndicesList, vtkPreselection );
2314 // .... -> enable selection
2315 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), vtkSelectionGroup, LightApp_Preferences::Bool, "VTKViewer", "enable_selection" );
2316 // ... "Selection" group <<end>>
2318 // ... -> empty frame (for layout) <<end>>
2320 // ... space mouse sub-group <<start>>
2321 int vtkSM = pref->addPreference( tr( "PREF_FRAME_SPACEMOUSE" ), vtkGroup, LightApp_Preferences::GroupBox );
2322 //pref->setItemProperty( "columns", 2, vtkSM );
2323 // .... -> decrease speed increment
2324 int spacemousePref1 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_1" ), vtkSM,
2325 LightApp_Preferences::Selector, "VTKViewer",
2326 "spacemouse_func1_btn" );
2327 // .... -> increase speed increment
2328 int spacemousePref2 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_2" ), vtkSM,
2329 LightApp_Preferences::Selector, "VTKViewer",
2330 "spacemouse_func2_btn" );
2331 // .... -> dominant / combined switch
2332 int spacemousePref3 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_3" ), vtkSM,
2333 LightApp_Preferences::Selector, "VTKViewer",
2334 "spacemouse_func5_btn" ); //
2335 aValuesList.clear();
2336 anIndicesList.clear();
2337 aValuesList << tr( "PREF_SPACEMOUSE_BTN_1" ) << tr( "PREF_SPACEMOUSE_BTN_2" ) << tr( "PREF_SPACEMOUSE_BTN_3" );
2338 aValuesList << tr( "PREF_SPACEMOUSE_BTN_4" ) << tr( "PREF_SPACEMOUSE_BTN_5" ) << tr( "PREF_SPACEMOUSE_BTN_6" );
2339 aValuesList << tr( "PREF_SPACEMOUSE_BTN_7" ) << tr( "PREF_SPACEMOUSE_BTN_8" ) << tr( "PREF_SPACEMOUSE_BTN_*" );
2340 aValuesList << tr( "PREF_SPACEMOUSE_BTN_10" ) << tr( "PREF_SPACEMOUSE_BTN_11" );
2341 anIndicesList << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11;
2342 pref->setItemProperty( "strings", aValuesList, spacemousePref1 );
2343 pref->setItemProperty( "indexes", anIndicesList, spacemousePref1 );
2344 pref->setItemProperty( "strings", aValuesList, spacemousePref2 );
2345 pref->setItemProperty( "indexes", anIndicesList, spacemousePref2 );
2346 pref->setItemProperty( "strings", aValuesList, spacemousePref3 );
2347 pref->setItemProperty( "indexes", anIndicesList, spacemousePref3 );
2348 // ... space mouse sub-group <<end>>
2350 // ... avi recording sub-group <<start>>
2351 int vtkRec = pref->addPreference( tr( "PREF_FRAME_RECORDING" ), vtkGroup, LightApp_Preferences::GroupBox );
2352 pref->setItemProperty( "columns", 2, vtkRec );
2353 // .... -> recording mode
2354 int modePref = pref->addPreference( tr( "PREF_RECORDING_MODE" ), vtkRec,
2355 LightApp_Preferences::Selector, "VTKViewer", "recorder_mode" );
2356 aValuesList.clear();
2357 anIndicesList.clear();
2358 aValuesList << tr( "PREF_SKIPPED_FRAMES" ) << tr( "PREF_ALL_DISLPAYED_FRAMES" );
2359 anIndicesList << 0 << 1;
2360 pref->setItemProperty( "strings", aValuesList, modePref );
2361 pref->setItemProperty( "indexes", anIndicesList, modePref );
2363 int fpsPref = pref->addPreference( tr( "PREF_FPS" ), vtkRec,
2364 LightApp_Preferences::DblSpin, "VTKViewer", "recorder_fps" );
2365 pref->setItemProperty( "min", 0.1, fpsPref );
2366 pref->setItemProperty( "max", 100, fpsPref );
2368 int qualityPref = pref->addPreference( tr( "PREF_QUALITY" ), vtkRec,
2369 LightApp_Preferences::IntSpin, "VTKViewer", "recorder_quality" );
2370 pref->setItemProperty( "min", 1, qualityPref );
2371 pref->setItemProperty( "max", 100, qualityPref );
2372 // .... -> progressive mode
2373 pref->addPreference( tr( "PREF_PROGRESSIVE" ), vtkRec,
2374 LightApp_Preferences::Bool, "VTKViewer", "recorder_progressive" );
2375 // ... avi recording sub-group <<end>>
2377 // ... group names sub-group <<start>>
2378 int vtkGN = pref->addPreference( tr( "PREF_FRAME_GROUP_NAMES" ), vtkGroup,
2379 LightApp_Preferences::GroupBox, "VTKViewer", "show_group_names" );
2380 pref->setItemProperty( "columns", 2, vtkGN );
2381 // .... -> text color
2382 pref->addPreference( tr( "PREF_GROUP_NAMES_TEXT_COLOR" ), vtkGN,
2383 LightApp_Preferences::Color, "VTKViewer", "group_names_text_color" );
2384 // .... -> transparency
2385 int transPref = pref->addPreference( tr( "PREF_GROUP_NAMES_TRANSPARENCY" ), vtkGN,
2386 LightApp_Preferences::DblSpin, "VTKViewer", "group_names_transparency" );
2387 pref->setItemProperty( "min", 0.0, transPref );
2388 pref->setItemProperty( "max", 1.0, transPref );
2389 pref->setItemProperty( "step", 0.1, transPref );
2390 // ... -> group names sub-group <<end>>
2391 // .. "VTK viewer" group <<end>>
2393 // .. "Plot2d viewer" group <<start>>
2394 int plot2dGroup = pref->addPreference( tr( "PREF_GROUP_PLOT2DVIEWER" ), salomeCat ); //viewTab
2395 //pref->setItemProperty( "columns", 2, plot2dGroup );
2397 // ... -> show legend
2398 pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dGroup,
2399 LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
2400 // ... -> legend position
2401 int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dGroup,
2402 LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
2403 aValuesList.clear();
2404 anIndicesList.clear();
2405 aValuesList << tr("PREF_LEFT") << tr("PREF_RIGHT") << tr("PREF_TOP") << tr("PREF_BOTTOM");
2406 anIndicesList << 0 << 1 << 2 << 3 ;
2407 pref->setItemProperty( "strings", aValuesList, legendPosition );
2408 pref->setItemProperty( "indexes", anIndicesList, legendPosition );
2409 // ... -> legend font
2410 pref->addPreference( tr( "PREF_LEGEND_FONT" ), plot2dGroup, LightApp_Preferences::Font, "Plot2d", "LegendFont" );
2411 // ... -> curve type
2412 int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dGroup,
2413 LightApp_Preferences::Selector, "Plot2d", "CurveType" );
2414 aValuesList.clear();
2415 anIndicesList.clear();
2416 aValuesList << tr("PREF_POINTS") << tr("PREF_LINES") << tr("PREF_SPLINE");
2417 anIndicesList << 0 << 1 << 2 ;
2418 pref->setItemProperty( "strings", aValuesList, curveType );
2419 pref->setItemProperty( "indexes", anIndicesList, curveType );
2420 // ... -> marker size
2421 int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dGroup,
2422 LightApp_Preferences::IntSpin, "Plot2d", "MarkerSize" );
2423 pref->setItemProperty( "min", 0, markerSize );
2424 pref->setItemProperty( "max", 100, markerSize );
2425 // ... -> horizontal scaling mode
2426 int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dGroup,
2427 LightApp_Preferences::Selector, "Plot2d", "HorScaleMode" );
2428 aValuesList.clear();
2429 anIndicesList.clear();
2430 aValuesList << tr("PREF_LINEAR") << tr("PREF_LOGARITHMIC");
2431 anIndicesList << 0 << 1 ;
2432 pref->setItemProperty( "strings", aValuesList, horScale );
2433 pref->setItemProperty( "indexes", anIndicesList, horScale );
2434 // ... -> vertical scaling mode
2435 int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dGroup,
2436 LightApp_Preferences::Selector, "Plot2d", "VerScaleMode" );
2437 pref->setItemProperty( "strings", aValuesList, verScale );
2438 pref->setItemProperty( "indexes", anIndicesList, verScale );
2439 // ... -> background
2440 pref->addPreference( tr( "PREF_VIEWER_BACKGROUND_COLOR" ), plot2dGroup,
2441 LightApp_Preferences::Color, "Plot2d", "Background" );
2442 // ... -> font color
2443 pref->addPreference( tr( "PREF_FONT_COLOR" ), plot2dGroup, LightApp_Preferences::Color, "Plot2d", "LegendFontColor" );
2444 // ... -> selection font color
2445 pref->addPreference( tr( "PREF_SELECTED_FONT_COLOR" ), plot2dGroup, LightApp_Preferences::Color, "Plot2d", "SelectedLegendFontColor" );
2446 // ... -> selection color
2447 pref->addPreference( tr( "PREF_VIEWER_SELECTION" ), plot2dGroup,
2448 LightApp_Preferences::Color, "Plot2d", "SelectionColor" );
2449 // ... -> errors/deviation colot
2450 pref->addPreference( tr( "PREF_DEVIATION_COLOR" ), plot2dGroup,
2451 LightApp_Preferences::Color, "Plot2d", "DeviationMarkerColor" );
2452 // ... -> deviation markers line size
2453 int deviationMarkerLw = pref->addPreference( tr( "PREF_DEVIATION_MARKER_LW" ), plot2dGroup,
2454 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerLineWidth" );
2455 pref->setItemProperty( "min", 1, deviationMarkerLw );
2456 pref->setItemProperty( "max", 5, deviationMarkerLw );
2457 // ... -> deviation markers tick mark size
2458 int deviationMarkerTs = pref->addPreference( tr( "PREF_DEVIATION_MARKER_TS" ), plot2dGroup,
2459 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerTickSize" );
2460 pref->setItemProperty( "min", 1, deviationMarkerTs );
2461 pref->setItemProperty( "max", 5, deviationMarkerTs );
2462 // .. "Plot2d viewer" group <<end>>
2464 // .. "Directories" preferences tab <<start>>
2465 int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat );
2466 // ... --> quick directories list
2467 int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab );
2468 pref->addPreference( tr( "" ), dirGroup,
2469 LightApp_Preferences::DirList, "FileDlg", "QuickDirList" );
2470 // .. "Directories" preferences tab <<end>>
2472 // .. "Object browser" preferences tab <<start>>
2473 int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
2475 // ... "Search tool" group <<start>>
2476 int stGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SEARCH_TOOL" ), obTab );
2477 // .... --> auto-hide
2478 pref->addPreference( tr( "PREF_AUTO_HIDE_SEARCH_TOOL" ), stGroup, LightApp_Preferences::Bool,
2479 "ObjectBrowser", "auto_hide_search_tool" );
2480 // ... "Search tool" group <<end>>
2482 // ... "Object browser settings" group <<start>>
2483 int objSetGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), obTab );
2484 pref->setItemProperty( "columns", 2, objSetGroup );
2485 // .... -> auto size first column
2486 pref->addPreference( tr( "PREF_AUTO_SIZE_FIRST" ), objSetGroup, LightApp_Preferences::Bool,
2487 "ObjectBrowser", "auto_size_first" );
2488 // .... -> auto size other columns
2489 pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool,
2490 "ObjectBrowser", "auto_size" );
2491 // .... -> resize columns on expand item
2492 pref->addPreference( tr( "PREF_RESIZE_ON_EXPAND_ITEM" ), objSetGroup, LightApp_Preferences::Bool,
2493 "ObjectBrowser", "resize_on_expand_item" );
2494 // .... -> browse to published object
2495 int browsePublished = pref->addPreference( tr( "PREF_BROWSE_TO_THE_PUBLISHED_OBJECT" ), objSetGroup, LightApp_Preferences::Selector,
2496 "ObjectBrowser", "browse_published_object" );
2497 aValuesList.clear();
2498 anIndicesList.clear();
2499 aValuesList << tr( "PREF_BROWSE_NEVER" ) << tr( "PREF_BROWSE_AFTER_APPLY_AND_CLOSE_ONLY" ) << tr( "PREF_BROWSE_ALWAYS" );
2500 anIndicesList << BP_Never << BP_ApplyAndClose << BP_Always;
2501 pref->setItemProperty( "strings", aValuesList, browsePublished );
2502 pref->setItemProperty( "indexes", anIndicesList, browsePublished );
2503 // ... "Object browser settings" group <<end>>
2504 // .. "Object browser" preferences tab <<end>>
2506 // .. "Shortcuts" preferences tab <<start>>
2507 int shortcutTab = pref->addPreference( tr( "PREF_TAB_SHORTCUTS" ), salomeCat );
2508 // ... "Shortcuts settings" group <<start>>
2509 int shortcutGroup = pref->addPreference( tr( "PREF_GROUP_SHORTCUTS" ), shortcutTab );
2510 pref->addPreference( tr( "" ), shortcutGroup,
2511 LightApp_Preferences::ShortcutTree, "shortcuts" );
2512 // ... "Shortcuts settings" group <<end>>
2513 // .. "Shortcuts" preferences tab <<end>>
2514 // . Top-level "SALOME" preferences group <<end>>
2520 Changes appearance of application according to changed preferences
2521 \param sec - section
2522 \param param - name of changed parameter
2524 void LightApp_Application::preferencesChanged( const QString& sec, const QString& param )
2526 SUIT_ResourceMgr* resMgr = resourceMgr();
2530 if ( sec == "viewers" && param == "drop_down_buttons" )
2532 ViewManagerList vmlist = viewManagers();
2533 foreach( SUIT_ViewManager* vm, vmlist )
2535 QVector<SUIT_ViewWindow*> vwlist = vm->getViews();
2536 foreach( SUIT_ViewWindow* vw, vwlist )
2537 if ( vw ) vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
2541 if ( sec == QString( "3DViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )))
2543 double sz = resMgr->doubleValue( sec, "trihedron_size", -1 );
2544 bool relative = resMgr->booleanValue( sec, "relative_size", true );
2545 QList<SUIT_ViewManager*> lst;
2546 #ifndef DISABLE_OCCVIEWER
2547 viewManagers( OCCViewer_Viewer::Type(), lst );
2548 QListIterator<SUIT_ViewManager*> itOCC( lst );
2549 while ( itOCC.hasNext() && sz >= 0 )
2551 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2552 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2555 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2556 occVM->setTrihedronSize( sz, relative );
2557 occVM->getAISContext()->UpdateCurrentViewer();
2560 #ifndef DISABLE_VTKVIEWER
2561 #ifndef DISABLE_SALOMEOBJECT
2562 viewManagers( SVTK_Viewer::Type(), lst );
2563 QListIterator<SUIT_ViewManager*> itVTK( lst );
2564 while ( itVTK.hasNext() && sz >= 0 )
2566 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2567 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2570 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2573 vtkVM->setTrihedronSize( sz, relative );
2581 if ( sec == QString( "3DViewer" ) && param == QString( "show_static_trihedron" ) )
2583 bool isVisible = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
2584 QList<SUIT_ViewManager*> lst;
2585 #ifndef DISABLE_OCCVIEWER
2586 viewManagers( OCCViewer_Viewer::Type(), lst );
2587 QListIterator<SUIT_ViewManager*> itOCC( lst );
2588 while ( itOCC.hasNext() )
2590 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2591 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2594 OCCViewer_Viewer* occVM = dynamic_cast<OCCViewer_Viewer*>( vm );
2597 occVM->setStaticTrihedronDisplayed( isVisible );
2601 #ifndef DISABLE_VTKVIEWER
2602 #ifndef DISABLE_SALOMEOBJECT
2603 viewManagers( SVTK_Viewer::Type(), lst );
2604 QListIterator<SUIT_ViewManager*> itVTK( lst );
2605 while ( itVTK.hasNext() )
2607 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2608 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2611 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2614 vtkVM->setStaticTrihedronVisible( isVisible );
2622 if ( sec == QString( "3DViewer" ) && param == QString( "navigation_mode" ) )
2624 int mode = resMgr->integerValue( "3DViewer", "navigation_mode", 0 );
2625 QList<SUIT_ViewManager*> lst;
2626 #ifndef DISABLE_OCCVIEWER
2627 viewManagers( OCCViewer_Viewer::Type(), lst );
2628 QListIterator<SUIT_ViewManager*> itOCC( lst );
2629 while ( itOCC.hasNext() )
2631 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2632 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2635 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2636 occVM->setInteractionStyle( mode );
2639 #ifndef DISABLE_VTKVIEWER
2640 #ifndef DISABLE_SALOMEOBJECT
2641 viewManagers( SVTK_Viewer::Type(), lst );
2642 QListIterator<SUIT_ViewManager*> itVTK( lst );
2643 while ( itVTK.hasNext() )
2645 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2646 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2649 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2650 if( vtkVM ) vtkVM->setInteractionStyle( mode );
2656 #ifndef DISABLE_OCCVIEWER
2657 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_preselection" ) )
2659 bool isToEnablePreselection = resMgr->booleanValue( "OCCViewer", "enable_preselection", true );
2660 QList<SUIT_ViewManager*> lst;
2661 viewManagers( OCCViewer_Viewer::Type(), lst );
2662 QListIterator<SUIT_ViewManager*> it( lst );
2663 while ( it.hasNext() )
2665 SUIT_ViewModel* vm = it.next()->getViewModel();
2666 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2669 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2670 occVM->enablePreselection( isToEnablePreselection );
2675 #ifndef DISABLE_OCCVIEWER
2676 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_selection" ) )
2678 bool isToEnableSelection = resMgr->booleanValue( "OCCViewer", "enable_selection", true );
2679 QList<SUIT_ViewManager*> lst;
2680 viewManagers( OCCViewer_Viewer::Type(), lst );
2681 QListIterator<SUIT_ViewManager*> it( lst );
2682 while ( it.hasNext() )
2684 SUIT_ViewModel* vm = it.next()->getViewModel();
2685 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2688 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2689 occVM->enableSelection( isToEnableSelection );
2694 if ( sec == QString( "3DViewer" ) && param == QString( "zooming_mode" ) )
2696 int mode = resMgr->integerValue( "3DViewer", "zooming_mode", 0 );
2697 QList<SUIT_ViewManager*> lst;
2698 #ifndef DISABLE_OCCVIEWER
2699 viewManagers( OCCViewer_Viewer::Type(), lst );
2700 QListIterator<SUIT_ViewManager*> itOCC( lst );
2701 while ( itOCC.hasNext() )
2703 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2704 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2707 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2708 occVM->setZoomingStyle( mode );
2711 #ifndef DISABLE_VTKVIEWER
2712 #ifndef DISABLE_SALOMEOBJECT
2713 viewManagers( SVTK_Viewer::Type(), lst );
2714 QListIterator<SUIT_ViewManager*> itVTK( lst );
2715 while ( itVTK.hasNext() )
2717 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2718 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2721 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2722 if( vtkVM ) vtkVM->setZoomingStyle( mode );
2728 #ifndef DISABLE_VTKVIEWER
2729 if ( sec == QString( "VTKViewer" ) && (param == QString( "speed_value" ) || param == QString( "speed_mode" )) )
2731 int speed = resMgr->integerValue( "VTKViewer", "speed_value", 10 );
2732 int mode = resMgr->integerValue( "VTKViewer", "speed_mode", 0 );
2733 QList<SUIT_ViewManager*> lst;
2734 #ifndef DISABLE_SALOMEOBJECT
2735 viewManagers( SVTK_Viewer::Type(), lst );
2736 QListIterator<SUIT_ViewManager*> it( lst );
2737 while ( it.hasNext() )
2739 SUIT_ViewModel* vm = it.next()->getViewModel();
2740 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2743 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2744 if( vtkVM ) vtkVM->setIncrementalSpeed( speed, mode );
2750 #ifndef DISABLE_VTKVIEWER
2751 if ( sec == QString( "VTKViewer" ) && param == QString( "projection_mode" ) )
2753 int mode = resMgr->integerValue( "VTKViewer", "projection_mode", 0 );
2754 QList<SUIT_ViewManager*> lst;
2755 #ifndef DISABLE_SALOMEOBJECT
2756 viewManagers( SVTK_Viewer::Type(), lst );
2757 QListIterator<SUIT_ViewManager*> it( lst );
2758 while ( it.hasNext() )
2760 SUIT_ViewModel* vm = it.next()->getViewModel();
2761 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2764 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2765 if( vtkVM ) vtkVM->setProjectionMode( mode );
2771 #ifndef DISABLE_VTKVIEWER
2772 if ( sec == QString( "VTKViewer" ) && param == QString( "preselection" ) )
2774 int mode = resMgr->integerValue( "VTKViewer", "preselection", 0 );
2775 QList<SUIT_ViewManager*> lst;
2776 #ifndef DISABLE_SALOMEOBJECT
2777 viewManagers( SVTK_Viewer::Type(), lst );
2778 QListIterator<SUIT_ViewManager*> it( lst );
2779 while ( it.hasNext() )
2781 SUIT_ViewModel* vm = it.next()->getViewModel();
2782 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2785 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2786 if( vtkVM ) vtkVM->setPreSelectionMode( mode );
2792 #ifndef DISABLE_VTKVIEWER
2793 if ( sec == QString( "VTKViewer" ) && param == QString( "enable_selection" ) )
2795 bool isToEnableSelection = resMgr->booleanValue( "VTKViewer", "enable_selection", true );
2796 QList<SUIT_ViewManager*> lst;
2797 #ifndef DISABLE_SALOMEOBJECT
2798 viewManagers( SVTK_Viewer::Type(), lst );
2799 QListIterator<SUIT_ViewManager*> it( lst );
2800 while ( it.hasNext() )
2802 SUIT_ViewModel* vm = it.next()->getViewModel();
2803 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2806 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2807 if( vtkVM ) vtkVM->enableSelection( isToEnableSelection );
2813 #ifndef DISABLE_VTKVIEWER
2814 if ( sec == QString( "VTKViewer" ) && (param == QString( "spacemouse_func1_btn" ) ||
2815 param == QString( "spacemouse_func2_btn" ) ||
2816 param == QString( "spacemouse_func5_btn" ) ) )
2818 int btn1 = resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", 1 );
2819 int btn2 = resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", 2 );
2820 int btn3 = resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", 9 );
2821 QList<SUIT_ViewManager*> lst;
2822 #ifndef DISABLE_SALOMEOBJECT
2823 viewManagers( SVTK_Viewer::Type(), lst );
2824 QListIterator<SUIT_ViewManager*> it( lst );
2825 while ( it.hasNext() )
2827 SUIT_ViewModel* vm = it.next()->getViewModel();
2828 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2831 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2832 if( vtkVM ) vtkVM->setSpacemouseButtons( btn1, btn2, btn3 );
2837 if( sec=="ObjectBrowser" )
2839 SUIT_DataBrowser* ob = objectBrowser();
2843 if ( param=="auto_size_first" )
2845 bool autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
2846 ob->setAutoSizeFirstColumn( autoSizeFirst );
2847 if ( autoSizeFirst )
2848 ob->adjustFirstColumnWidth();
2850 else if ( param=="auto_size" ) {
2851 bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
2852 ob->setAutoSizeColumns(autoSize);
2854 ob->adjustColumnsWidth();
2856 else if ( param=="resize_on_expand_item" ) {
2857 bool resizeOnExpandItem = resMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
2858 ob->setResizeOnExpandItem(resizeOnExpandItem);
2860 else if ( param == "auto_hide_search_tool" ) {
2861 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
2867 if( param=="auto_save_interval" ) {
2868 myAutoSaveTimer->stop();
2869 int autoSaveInterval = resMgr->integerValue( "Study", "auto_save_interval", 0 );
2870 if ( activeStudy() && autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
2874 #ifndef DISABLE_PYCONSOLE
2875 if( sec=="PyConsole" && pythonConsole() )
2877 if ( param=="font" ) {
2878 pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) );
2880 else if ( param=="show_banner" ) {
2881 pythonConsole()->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
2888 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
2890 if ( param == "visible_count" )
2891 mru->setVisibleCount( resMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
2892 else if ( param == "max_count" )
2893 mru->setHistoryCount( resMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
2894 else if ( param == "insert_mode" )
2895 mru->setInsertMode( resMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
2896 else if ( param == "link_type" )
2897 mru->setLinkType( resMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
2898 else if ( param == "show_clear" )
2899 mru->setClearPossible( resMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
2900 else if ( param == "show_mru" )
2901 mru->setVisible( resMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
2904 if ( sec == "language" && param == "language" )
2906 SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LANG_CHANGED" ) );
2908 if ( sec == "desktop" && param == "opaque_resize" ) {
2909 bool opaqueResize = resMgr->booleanValue( "desktop", "opaque_resize", false );
2910 QMainWindow::DockOptions dopts = desktop()->dockOptions();
2911 if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
2912 else dopts &= ~QMainWindow::AnimatedDocks;
2913 desktop()->setDockOptions( dopts );
2914 desktop()->setOpaqueResize( opaqueResize );
2915 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
2916 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
2919 if ( sec == "ExternalBrowser" && param == "use_external_browser" ) {
2920 if ( resMgr->booleanValue("ExternalBrowser", "use_external_browser", false ) )
2922 QtxWebBrowser::shutdown();
2926 #ifndef DISABLE_PLOT2DVIEWER
2927 if ( sec == "Plot2d" ) {
2928 if( param == "SelectionColor" ) {
2929 QColor c = resMgr->colorValue( sec, param );
2930 Plot2d_Object::setSelectionColor(c);
2932 else if (param == "SelectedLegendFontColor") {
2933 QColor c = resMgr->colorValue( sec, param );
2934 Plot2d_Object::setHighlightedLegendTextColor(c);
2943 void LightApp_Application::loadPreferences()
2945 CAM_Application::loadPreferences();
2947 SUIT_ResourceMgr* aResMgr = resourceMgr();
2952 static bool mru_load = true;
2955 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
2957 mru->setVisible( aResMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
2958 mru->setVisibleCount( aResMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
2959 mru->setHistoryCount( aResMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
2960 mru->setInsertMode( aResMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
2961 mru->setLinkType( aResMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
2962 mru->setClearPossible( aResMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
2963 mru->loadLinks( aResMgr, "MRU" );
2969 QStringList mods = aResMgr->parameters( "windows_visibility" );
2970 for ( QStringList::const_iterator itr = mods.begin(); itr != mods.end(); ++itr )
2973 if ( aResMgr->value( "windows_visibility", *itr, arr ) )
2974 myWinVis.insert( *itr, arr );
2978 desktop()->retrieveGeometry( aResMgr->stringValue( "desktop", "geometry" ) );
2979 bool opaqueResize = aResMgr->booleanValue( "desktop", "opaque_resize", false );
2980 QMainWindow::DockOptions dopts = desktop()->dockOptions();
2981 if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
2982 else dopts &= ~QMainWindow::AnimatedDocks;
2983 desktop()->setDockOptions( dopts );
2984 desktop()->setOpaqueResize( opaqueResize );
2985 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
2986 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
2993 void LightApp_Application::savePreferences()
2995 CAM_Application::savePreferences();
2997 saveDockWindowsState();
2999 SUIT_ResourceMgr* aResMgr = resourceMgr();
3004 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3006 mru->saveLinks( aResMgr, "MRU" );
3008 for ( WinVis::const_iterator itr = myWinVis.begin(); itr != myWinVis.end(); ++itr )
3009 aResMgr->setValue( "windows_visibility", itr.key(), itr.value() );
3012 aResMgr->setValue( "desktop", "geometry", desktop()->storeGeometry() );
3018 Updates desktop title
3020 void LightApp_Application::updateDesktopTitle()
3022 QString aTitle = applicationName();
3023 QString aVer = applicationVersion();
3024 if ( !aVer.isEmpty() )
3025 aTitle += QString( " " ) + aVer;
3027 if ( activeStudy() ) {
3028 QString sName = SUIT_Tools::file( activeStudy()->studyName().trimmed(), false );
3029 aTitle += QString( " - [%1]" ).arg( sName );
3032 desktop()->setWindowTitle( aTitle );
3036 \brief Get map of the operations which can be performed
3037 on the module activation.
3039 The method should return the map of the kind \c {<id>:<name>}
3040 where \c <id> is an integer identifier of the operation and
3041 \c <name> is a title for the button to be added to the
3042 dialog box. After user selects the required operation by the
3043 clicking the corresponding button in the dialog box, its identifier
3044 is passed to the moduleActionSelected() method to process
3047 \return map of the operations
3048 \sa moduleActionSelected()
3050 QMap<int, QString> LightApp_Application::activateModuleActions() const
3052 QMap<int, QString> opmap;
3053 opmap.insert( NewStudyId, tr( "ACTIVATE_MODULE_OP_NEW" ) );
3054 opmap.insert( OpenStudyId, tr( "ACTIVATE_MODULE_OP_OPEN" ) );
3059 \brief Called when the used selectes required operation chosen
3060 from "Activate module" dialog box.
3062 Performs the required operation according to the user choice.
3064 \param id operation identifier
3065 \sa activateModuleActions()
3067 void LightApp_Application::moduleActionSelected( const int id )
3082 Updates windows after close document
3084 void LightApp_Application::afterCloseDoc()
3088 CAM_Application::afterCloseDoc();
3092 Updates actions of active module
3094 void LightApp_Application::updateModuleActions()
3097 if ( activeModule() ) {
3098 modName = activeModule()->moduleName();
3099 if ( !isModuleAccessible( modName ) ) {
3100 QList<SUIT_Application*> apps = SUIT_Session::session()->applications();
3101 foreach( SUIT_Application* app, apps ) {
3102 LightApp_Application* lapp = dynamic_cast<LightApp_Application*>( app );
3103 if ( lapp && lapp != this )
3104 lapp->removeModuleAction( modName );
3109 LightApp_ModuleAction* moduleAction =
3110 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
3112 moduleAction->setActiveModule( modName );
3115 void LightApp_Application::removeModuleAction( const QString& modName )
3117 LightApp_ModuleAction* moduleAction =
3118 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
3120 moduleAction->removeModule( modName );
3124 Gets current windows.
3125 \param winMap - output current windows map.
3127 void LightApp_Application::currentWindows( QMap<int, int>& winMap ) const
3130 if ( !activeStudy() )
3133 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
3134 ((LightApp_Module*)activeModule())->windows( winMap );
3136 defaultWindows( winMap );
3140 Gets current view managers.
3141 \param lst - output current view managers list.
3143 void LightApp_Application::currentViewManagers( QStringList& lst ) const
3146 if ( !activeStudy() )
3149 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
3150 ((LightApp_Module*)activeModule())->viewManagers( lst );
3152 defaultViewManagers( lst );
3158 void LightApp_Application::updateWindows()
3160 QMap<int, int> winMap;
3161 currentWindows( winMap );
3163 if ( activeStudy() )
3165 for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
3167 if ( !dockWindow( it.key() ) )
3168 getWindow( it.key() );
3172 for ( WinMap::ConstIterator it = myWin.begin(); it != myWin.end(); ++it )
3174 QWidget* wid = it.value();
3175 if ( activeStudy() )
3176 wid->setVisible( winMap.contains( it.key() ) );
3181 if ( activeStudy() )
3182 loadDockWindowsState();
3188 Updates view managers
3190 void LightApp_Application::updateViewManagers()
3193 currentViewManagers( lst );
3195 for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
3196 getViewManager( *it, true );
3200 Loads windows geometry
3202 void LightApp_Application::loadDockWindowsState()
3206 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
3207 bool storeWin = aResMgr->booleanValue( "Study", "store_positions", true );
3208 bool storeTb = aResMgr->booleanValue( "Study", "store_tool_positions", true );
3211 if ( activeModule() )
3212 modName = activeModule()->name();
3214 QtxResourceMgr::WorkingMode prevMode = aResMgr->workingMode();
3215 aResMgr->setWorkingMode(QtxResourceMgr::IgnoreUserValues);
3216 QByteArray aDefaultState;
3217 aResMgr->value("windows_geometry", modName , aDefaultState );
3218 QByteArray aDefaultVisibility;
3219 aResMgr->value("windows_visibility", modName , aDefaultVisibility );
3220 bool hasDefaultVisibility = !aDefaultVisibility.isEmpty();
3221 aResMgr->setWorkingMode(prevMode);
3223 if( !storeWin && !storeTb && aDefaultState.isEmpty() && !hasDefaultVisibility)
3226 if ( aResMgr->hasValue("windows_geometry" ,modName ) ) {
3228 aResMgr->value("windows_geometry", modName , arr );
3229 QByteArray aTargetArray = processState(arr, storeWin, storeTb, aDefaultState);
3230 desktop()->restoreState( aTargetArray );
3233 if ( !myWinVis.contains( modName ) && aDefaultVisibility.isEmpty())
3236 QMap<QString, bool> *tbMap = 0;
3237 QMap<QString, bool> *dwMap = 0;
3239 QMap<QString, bool> userTbMap, userDwMap;
3240 dockWindowsState( myWinVis[modName], userTbMap, userDwMap );
3242 QMap<QString, bool> defaultTbMap, defaultDwMap;
3243 if(hasDefaultVisibility) {
3244 dockWindowsState( aDefaultVisibility, defaultTbMap, defaultDwMap);
3250 if(hasDefaultVisibility){
3251 tbMap = &defaultTbMap;
3258 if(hasDefaultVisibility){
3259 dwMap = &defaultDwMap;
3264 QList<QToolBar*> tbList = findToolBars();
3265 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit )
3267 QToolBar* tb = *tit;
3268 if ( tbMap->contains( tb->objectName() ) ) {
3269 tb->setVisible( (*tbMap)[tb->objectName()] );
3275 QList<QDockWidget*> dwList = qFindChildren<QDockWidget*>( desktop() );
3276 for ( QList<QDockWidget*>::iterator dit = dwList.begin(); dit != dwList.end(); ++dit )
3278 QDockWidget* dw = *dit;
3280 QObject* po = Qtx::findParent( dw, "QMainWindow" );
3281 if ( po != desktop() )
3284 if ( dwMap->contains( dw->objectName() ) )
3285 dw->setVisible( (*dwMap)[dw->objectName()] );
3292 Saves windows geometry
3294 void LightApp_Application::saveDockWindowsState()
3299 bool storeWin = resourceMgr()->booleanValue( "Study", "store_positions", true );
3300 bool storeTb = resourceMgr()->booleanValue( "Study", "store_tool_positions", true );
3302 if( !storeWin && !storeTb )
3306 if ( activeModule() )
3307 modName = activeModule()->name();
3309 QByteArray arr = desktop()->saveState();
3310 resourceMgr()->setValue( "windows_geometry", modName, processState(arr, storeWin, storeTb) );
3313 if ( myWinVis.contains( modName ) )
3314 visArr = myWinVis[modName];
3316 QMap<QString, bool> tbMap, dwMap;
3317 dockWindowsState( visArr, tbMap, dwMap );
3319 QList<QToolBar*> tbList = qFindChildren<QToolBar*>( desktop() );
3320 for ( QList<QToolBar*>::iterator it = tbList.begin(); it != tbList.end(); ++it )
3323 tbMap.insert( tb->objectName(), tb->toggleViewAction()->isChecked() );
3326 QList<QDockWidget*> dwList = qFindChildren<QDockWidget*>( desktop() );
3327 for ( QList<QDockWidget*>::iterator it = dwList.begin(); it != dwList.end(); ++it )
3329 QDockWidget* wid = *it;
3330 dwMap.insert( wid->objectName(), wid->toggleViewAction()->isChecked() );
3333 visArr = dockWindowsState( tbMap, dwMap );
3335 myWinVis.insert( modName, visArr );
3338 QByteArray LightApp_Application::dockWindowsState( const QMap<QString, bool>& tb, const QMap<QString, bool>& dw ) const
3341 QDataStream stream( &visArr, QIODevice::WriteOnly );
3343 stream << (uchar)ToolBarMarker;
3344 stream << tb.size();
3345 for ( QMap<QString, bool>::const_iterator tit = tb.begin(); tit != tb.end(); ++tit )
3347 stream << tit.key();
3348 stream << (uchar)( tit.value() ? 1 : 0 );
3351 stream << (uchar)DockWidgetMarker;
3352 stream << dw.size();
3353 for ( QMap<QString, bool>::const_iterator wit = dw.begin(); wit != dw.end(); ++wit )
3355 stream << wit.key();
3356 stream << (uchar)( wit.value() ? 1 : 0 );
3362 void LightApp_Application::dockWindowsState( const QByteArray& arr, QMap<QString, bool>& tb, QMap<QString, bool>& dw ) const
3367 QByteArray visArr = arr;
3368 QDataStream stream( &visArr, QIODevice::ReadOnly );
3372 if ( marker != ToolBarMarker )
3377 for ( int i = 0; i < lines; ++i )
3380 stream >> objectName;
3383 tb.insert( objectName, shown );
3387 if ( marker != DockWidgetMarker )
3391 for ( int j = 0; j < lines; ++j )
3394 stream >> objectName;
3397 dw.insert( objectName, shown );
3402 Adds icon names for modules
3404 void LightApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) const
3408 SUIT_ResourceMgr* resMgr = resourceMgr();
3412 QStringList modList;
3413 modules( modList, false );
3415 for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )
3417 QString modName = *it;
3418 QString modIntr = moduleName( modName );
3419 QString modIcon = resMgr->stringValue( modIntr, "icon", QString() );
3421 if ( modIcon.isEmpty() )
3424 if ( SUIT_Tools::extension( modIcon ).isEmpty() )
3425 modIcon += QString( ".png" );
3427 iconMap.insert( modName, modIcon );
3432 Inserts items in popup, which necessary for current application
3434 void LightApp_Application::contextMenuPopup( const QString& type, QMenu* thePopup, QString& title )
3437 LightApp_SelectionMgr* selMgr = LightApp_Application::selectionMgr();
3438 bool cacheIsOn = selMgr->isSelectionCacheEnabled();
3439 selMgr->setSelectionCacheEnabled( true );
3441 SUIT_DataBrowser* ob = objectBrowser();
3443 CAM_Application::contextMenuPopup( type, thePopup, title );
3445 if ( ob && type == ob->popupClientType() ) {
3446 thePopup->addSeparator();
3447 QAction* a = thePopup->addAction( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
3448 if ( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) )
3449 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) );
3452 if ( selMgr && ob ) {
3453 SALOME_ListIO selected;
3454 selMgr->selectedObjects( selected );
3455 if(selected.Extent() == 1){
3456 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3457 SUIT_DataObject* obj = findObject(anIObject->getEntry());
3458 if(obj && obj->renameAllowed()) {
3459 QAction* a = new QAction(tr("MEN_RENAME_OBJ"), thePopup);
3460 connect( a, SIGNAL( triggered(bool) ), ob, SLOT( onStartEditing() ) );
3461 if ( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) )
3462 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) );
3464 QList<QAction*> acts = thePopup->actions();
3465 QAction* firstAction = acts.count() > 0 ? acts.first() : 0;
3466 thePopup->insertAction(firstAction,a);
3471 selMgr->setSelectionCacheEnabled( cacheIsOn );
3477 void LightApp_Application::createEmptyStudy()
3479 CAM_Application::createEmptyStudy();
3481 if ( objectBrowser() )
3482 objectBrowser()->updateTree();
3484 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
3485 if ( aResMgr && activeStudy() ) {
3486 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
3487 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
3492 void LightApp_Application::setDesktop( SUIT_Desktop* desk )
3494 CAM_Application::setDesktop( desk );
3497 connect( desk, SIGNAL( message( const QString& ) ),
3498 this, SLOT( onDesktopMessage( const QString& ) ), Qt::UniqueConnection );
3504 \param mod - module to be activated
3506 bool LightApp_Application::activateModule( CAM_Module* mod )
3508 bool res = CAM_Application::activateModule( mod );
3510 if ( objectBrowser() )
3511 objectBrowser()->updateTree();
3517 \return keyborad accelerators manager object
3519 SUIT_Accel* LightApp_Application::accel() const
3525 Removes dead widget container from map
3527 void LightApp_Application::onWCDestroyed( QObject* ob )
3529 // remove destroyed widget container from windows map
3530 for ( WinMap::ConstIterator itr = myWin.begin(); itr != myWin.end(); ++itr )
3532 if ( itr.value() != ob )
3535 int key = itr.key();
3536 myWin.remove( key );
3541 void LightApp_Application::onMRUActivated( const QString& name )
3543 SUIT_Session* s = SUIT_Session::session();
3544 if ( s && s->activeApplication() == this )
3548 void LightApp_Application::onStylePreferences()
3550 Style_PrefDlg dlg( desktop() );
3553 resourceMgr()->setValue( "Style", "use_salome_style", Style_Salome::isActive() );
3556 void LightApp_Application::onFullScreen(){
3557 if(myScreenHelper) {
3558 if(desktop()->isFullScreen())
3559 myScreenHelper->switchToNormalScreen();
3561 myScreenHelper->switchToFullScreen();
3566 Connects just added view manager
3568 void LightApp_Application::addViewManager( SUIT_ViewManager* vm )
3570 connect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
3571 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
3572 CAM_Application::addViewManager( vm );
3576 Remove view manager from memory
3578 void LightApp_Application::removeViewManager( SUIT_ViewManager* vm )
3580 disconnect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
3581 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
3582 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
3584 aStudy->removeViewMgr(vm->getGlobalId());
3586 CAM_Application::removeViewManager( vm );
3588 LightApp_SelectionMgr* selMgr = selectionMgr();
3589 QList<SUIT_Selector*> selectors;
3590 selMgr->selectors( selectors );
3591 foreach( SUIT_Selector* selector, selectors ) {
3592 if ( selector->owner() == vm->getViewModel() ) {
3597 // IPAL22894: Crash on closing OCC view
3603 Renames active window of desktop
3605 void LightApp_Application::onRenameWindow()
3610 QWidget* w = desktop()->activeWindow();
3615 QString name = QInputDialog::getText( w, tr( "TOT_RENAME" ), tr( "PRP_RENAME" ), QLineEdit::Normal, w->windowTitle(), &ok );
3616 if( ok && !name.isEmpty() )
3617 w->setWindowTitle( name );
3621 Closes active window of desktop
3623 void LightApp_Application::onCloseWindow()
3628 QWidget* w = desktop()->activeWindow();
3636 Closes all windows of desktop
3638 void LightApp_Application::onCloseAllWindow()
3640 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
3644 QList<SUIT_ViewWindow*> wndList = desk->windows();
3645 SUIT_ViewWindow* wnd;
3646 foreach( wnd, wndList )
3654 Groups all windows of desktop
3656 void LightApp_Application::onGroupAllWindow()
3658 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
3662 QtxWorkstack* wgStack = desk->workstack();
3668 \return if the library of module exists
3669 \param moduleTitle - title of module
3671 bool LightApp_Application::isLibExists( const QString& moduleTitle ) const
3673 if( moduleTitle.isEmpty() )
3676 QString lib = moduleLibrary( moduleTitle );
3678 //abd: changed libSalomePyQtGUI to SalomePyQtGUI for WIN32
3679 bool isPythonModule = lib.contains("SalomePyQtGUI");
3680 bool isPythonLightModule = lib.contains("SalomePyQtGUILight");
3684 paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
3686 paths = QString(::getenv( "LD_LIBRARY_PATH" )).split( ":", QString::SkipEmptyParts );
3689 bool isLibFound = false;
3690 QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
3691 for( ; anIt!=aLast; anIt++ )
3693 QFileInfo inf( Qtx::addSlash( *anIt ) + lib );
3704 INFOS( "****************************************************************" << std::endl
3705 << "* Warning: library " << lib.toLatin1().constData() << " cannot be found" << std::endl
3706 << "* Module " << moduleTitle.toLatin1().constData() << " will not be available in GUI mode" << std::endl
3707 << "****************************************************************" << std::endl );
3709 else if ( !isPythonModule && !isPythonLightModule)
3712 if ( isPythonModule || isPythonLightModule)
3714 QString pylib = moduleName( moduleTitle ) + QString(".py");
3715 QString pylibgui = moduleName( moduleTitle ) + QString("GUI.py");
3717 // Check the python library
3719 // paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
3721 paths = QString(::getenv( "PYTHONPATH" )).split( ":", QString::SkipEmptyParts );
3723 bool isPyLib = false, isPyGuiLib = false;
3724 QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
3725 for( ; anIt!=aLast; anIt++ )
3727 QFileInfo inf( Qtx::addSlash( *anIt ) + pylib );
3728 QFileInfo infgui( Qtx::addSlash( *anIt ) + pylibgui );
3730 if(!isPythonLightModule)
3731 if( !isPyLib && inf.exists() )
3734 if( !isPyGuiLib && infgui.exists() )
3737 if ((isPyLib || isPythonLightModule ) && isPyGuiLib && isLibFound)
3741 printf( "****************************************************************\n" );
3742 printf( "* Warning: python library for %s cannot be found:\n", moduleTitle.toLatin1().constData() );
3744 printf( "* No module named %s\n", moduleName( moduleTitle ).toLatin1().constData() );
3746 printf( "* No module named %s\n", (moduleName( moduleTitle ) + QString("GUI")).toLatin1().constData() );
3747 printf( "****************************************************************\n" );
3754 \return default name for an active study
3756 void LightApp_Application::setDefaultStudyName( const QString& theName )
3758 QStringList anInfoList;
3759 modules( anInfoList, false );
3761 LightApp_Study* aStudy = (LightApp_Study*)activeStudy();
3762 if( anInfoList.count() == 1 && // to avoid a conflict between different modules
3763 !aStudy->isSaved() )
3765 aStudy->setStudyName( theName );
3766 updateDesktopTitle();
3771 Custom event handler
3773 bool LightApp_Application::event( QEvent* e )
3775 if( e && e->type()==2000 )
3777 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
3778 QString* d = ( QString* )ce->data();
3779 if( SUIT_MessageBox::question(0, tr("WRN_WARNING"),
3781 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
3782 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
3783 showPreferences( tr( "PREF_APP" ) );
3788 return CAM_Application::event( e );
3791 /*! Check data object */
3792 bool LightApp_Application::checkDataObject(LightApp_DataObject* theObj)
3796 bool isSuitable = !theObj->entry().isEmpty() &&
3797 !theObj->componentDataType().isEmpty() &&
3798 !theObj->name().isEmpty();
3805 int LightApp_Application::openChoice( const QString& aName )
3807 int choice = CAM_Application::openChoice( aName );
3809 if ( choice == OpenExist ) // The document is already open.
3811 // Do you want to reload it?
3812 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "QUE_DOC_ALREADYOPEN" ).arg( aName ),
3813 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No ) == SUIT_MessageBox::Yes )
3814 choice = OpenReload;
3820 bool LightApp_Application::openAction( const int choice, const QString& aName )
3827 STD_Application* app = 0;
3828 SUIT_Session* session = SUIT_Session::session();
3829 QList<SUIT_Application*> appList = session->applications();
3830 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !app; ++it )
3832 if ( (*it)->activeStudy() && (*it)->activeStudy()->studyName() == aName )
3833 app = ::qobject_cast<STD_Application*>( *it );
3838 app->onCloseDoc( false );
3839 appList = session->applications();
3840 STD_Application* other = 0;
3841 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !other; ++it )
3842 other = ::qobject_cast<STD_Application*>( *it );
3845 res = other->onOpenDoc( aName );
3850 res = CAM_Application::openAction( choice, aName );
3857 QStringList LightApp_Application::viewManagersTypes() const
3859 QStringList aTypesList;
3860 aTypesList += myUserWmTypes;
3861 #ifndef DISABLE_GLVIEWER
3862 aTypesList<<GLViewer_Viewer::Type();
3864 #ifndef DISABLE_PLOT2DVIEWER
3865 aTypesList<<Plot2d_Viewer::Type();
3867 #ifndef DISABLE_QXGRAPHVIEWER
3868 aTypesList<<QxScene_Viewer::Type();
3870 #ifndef DISABLE_OCCVIEWER
3871 aTypesList<<OCCViewer_Viewer::Type();
3873 #ifndef DISABLE_VTKVIEWER
3874 #ifndef DISABLE_SALOMEOBJECT
3875 aTypesList<<SVTK_Viewer::Type();
3877 aTypesList<<VTKViewer_Viewer::Type();
3883 * Removes all view managers of known types
3884 * Other view managers are ignored
3886 void LightApp_Application::clearKnownViewManagers()
3888 QStringList aTypesList = viewManagersTypes();
3889 QList<SUIT_ViewManager*> aMgrList;
3890 viewManagers( aMgrList );
3891 foreach (SUIT_ViewManager* aMgr, aMgrList) {
3892 if (aTypesList.contains(aMgr->getType()))
3893 removeViewManager(aMgr);
3898 Copy of current selection
3900 void LightApp_Application::onCopy()
3902 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
3908 Paste of current data in clipboard
3910 void LightApp_Application::onPaste()
3912 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
3918 Browse (i.e. set focus on) the published objects
3919 \param theIsApplyAndClose - flag indicating that the dialog for creating objects
3920 has been accepted by Ok (or Apply & Close) button
3921 \param theIsOptimizedBrowsing - flag switching to optimized browsing mode
3922 (to select the first published object only)
3923 \return entry of the selected object
3925 QString LightApp_Application::browseObjects( const QStringList& theEntryList,
3926 const bool theIsApplyAndClose,
3927 const bool theIsOptimizedBrowsing )
3930 if( SUIT_ResourceMgr* aResourceMgr = resourceMgr() )
3932 int aBrowsePolicy = aResourceMgr->integerValue( "ObjectBrowser", "browse_published_object", (int)BP_Never );
3933 switch( aBrowsePolicy )
3937 case BP_ApplyAndClose:
3938 if( !theIsApplyAndClose )
3946 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
3950 SUIT_DataBrowser* anOB = objectBrowser();
3954 SUIT_AbstractModel* aModel = dynamic_cast<SUIT_AbstractModel*>( anOB->model() );
3958 QStringListIterator anIter( theEntryList );
3959 if( theIsOptimizedBrowsing )
3961 // go to the last entry
3963 if( anIter.hasPrevious() )
3967 // scroll to each entry in the list
3968 // (in optimized mode - to the last entry only)
3970 LightApp_DataObject* anObject = 0;
3971 while( anIter.hasNext() )
3973 anEntry = anIter.next();
3974 if( !anEntry.isEmpty() )
3976 anObject = aStudy->findObjectByEntry( anEntry );
3979 QModelIndex anIndex = aModel->index( anObject );
3980 anOB->treeView()->scrollTo( anIndex );
3985 // always select the last object
3986 if( anObject && !anEntry.isEmpty() )
3988 QList<SUIT_Selector*> aSelectorList;
3989 selectionMgr()->selectors( "ObjectBrowser", aSelectorList );
3990 if( !aSelectorList.isEmpty() )
3992 if( LightApp_OBSelector* aSelector = dynamic_cast<LightApp_OBSelector*>( aSelectorList.first() ) )
3994 bool anIsAutoBlock = aSelector->autoBlock();
3996 // temporarily disable auto block, to emit LightApp_SelectionMgr::currentSelectionChanged() signal
3997 aSelector->setAutoBlock( false );
3999 SUIT_DataOwnerPtrList aList;
4000 #ifndef DISABLE_SALOMEOBJECT
4001 Handle(SALOME_InteractiveObject) aSObj = new SALOME_InteractiveObject
4002 ( anObject->entry().toLatin1().constData(),
4003 anObject->componentDataType().toLatin1().constData(),
4004 anObject->name().toLatin1().constData() );
4005 LightApp_DataOwner* owner = new LightApp_DataOwner( aSObj );
4007 LightApp_DataOwner* owner = new LightApp_DataOwner( anEntry );
4010 aList.append( owner );
4011 selectionMgr()->setSelected( aList );
4014 // restore auto block flag
4015 aSelector->setAutoBlock( anIsAutoBlock );
4023 SUIT_DataObject* LightApp_Application::findObject( const QString& id ) const
4025 LightApp_Study* study = dynamic_cast<LightApp_Study*>( activeStudy() );
4026 return study ? study->findObjectByEntry( id ) : 0;
4030 Checks that an object can be renamed.
4031 \param entry entry of the object
4032 \brief Return \c true if object can be renamed
4034 bool LightApp_Application::renameAllowed( const QString& /*entry*/) const {
4039 Rename object by entry.
4040 \param entry entry of the object
4041 \param name new name of the object
4042 \brief Return \c true if rename operation finished successfully, \c false otherwise.
4044 bool LightApp_Application::renameObject( const QString& entry, const QString& ) {
4048 /*! Process standard messages from desktop */
4049 void LightApp_Application::onDesktopMessage( const QString& message )
4051 const QString sectionSeparator = "/";
4053 if ( message.toLower() == "updateobjectbrowser" ||
4054 message.toLower() == "updateobjbrowser" ) {
4055 // update object browser
4056 updateObjectBrowser();
4059 QStringList data = message.split( sectionSeparator );
4060 if ( data.count() > 1 ) {
4061 QString msgType = data[0].trimmed();
4062 LightApp_Module* sMod = 0;
4063 CAM_Module* mod = module( msgType );
4065 mod = module( moduleTitle( msgType ) );
4066 if ( mod && mod->inherits( "LightApp_Module" ) )
4067 sMod = (LightApp_Module*)mod;
4069 if ( msgType.toLower() == "preferences" ) {
4070 // requested preferences change: should be given as "preferences/<section>/<name>/<value>"
4071 // for example "preferences/Study/multi_file_dump/true"
4072 if ( data.count() > 3 ) {
4073 QString section = data[1].trimmed();
4074 QString param = data[2].trimmed();
4075 QString value = QStringList( data.mid(3) ).join( sectionSeparator );
4076 resourceMgr()->setValue( section, param, value );
4080 // received message for the module
4081 QString msg = QStringList( data.mid(1) ).join( sectionSeparator );
4082 sMod->message( msg );
4090 Returns all top level toolbars.
4091 Note : Result list contains only main window toolbars, not including toolbars from viewers.
4093 QList<QToolBar*> LightApp_Application::findToolBars() {
4094 QList<QToolBar*> aResult;
4095 QList<QToolBar*> tbList = qFindChildren<QToolBar*>( desktop() );
4096 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit ) {
4097 QToolBar* tb = *tit;
4098 QObject* po = Qtx::findParent( tb, "QMainWindow" );
4099 if ( po != desktop() )
4107 Internal method to parse toolbars and dockable windows state.
4109 QByteArray LightApp_Application::processState(QByteArray& input, const bool processWin,const bool processTb, QByteArray defaultState) {
4112 bool hasDefaultState = !defaultState.isEmpty();
4113 bool isDockWinWriten = false;
4114 if(processWin && processTb) {
4116 } else if(!processWin && !processTb ) {
4118 aRes = defaultState;
4120 QDataStream aData(&aRes, QIODevice::WriteOnly);
4121 QList<QToolBar*> aToolBars = findToolBars();
4124 for ( QList<QToolBar*>::iterator tit = aToolBars.begin(); tit != aToolBars.end(); ++tit ) {
4125 QToolBar* tb = *tit;
4126 aNames.append(tb->objectName());
4129 int toolBarMarkerIndex = getToolbarMarkerIndex(input,aNames);
4130 QDataStream anInputData(&input, QIODevice::ReadOnly);
4131 if(toolBarMarkerIndex < 0)
4134 int toolBarMarkerIndexDef;
4135 if(hasDefaultState) {
4136 toolBarMarkerIndexDef = getToolbarMarkerIndex(defaultState, aNames);
4137 if(toolBarMarkerIndexDef < 0)
4140 QDataStream anInputDataDef(&defaultState, QIODevice::ReadOnly);
4142 QDataStream* aTargetData = 0;
4143 int aTargetIndex = -1;
4146 //Write date from users settings
4147 aTargetData = &anInputData;
4148 aTargetIndex = toolBarMarkerIndex;
4150 //Write date from default settings
4151 if(hasDefaultState) {
4152 aTargetData = &anInputDataDef;
4153 aTargetIndex = toolBarMarkerIndexDef;
4157 if(aTargetData && aTargetIndex >= 0 ) {
4158 aTargetData->device()->seek(0);
4159 while( aTargetData->device()->pos() < aTargetIndex ) {
4164 isDockWinWriten = true;
4171 aTargetData = &anInputData;
4172 aTargetIndex = toolBarMarkerIndex;
4174 if(hasDefaultState) {
4175 aTargetData = &anInputDataDef;
4176 aTargetIndex = toolBarMarkerIndexDef;
4180 if(aTargetData && aTargetIndex >= 0) {
4182 if(!isDockWinWriten ) {
4183 //Write version marker
4184 int marker, version;
4185 aTargetData->device()->seek(0);
4186 *aTargetData >> marker;
4187 *aTargetData >> version;
4190 aData << (uchar) QDockWidgetMarker;
4192 int shift = 4*sizeof(int) + sizeof(QSize);
4193 index = aTargetIndex - shift;
4195 index = aTargetIndex;
4198 aTargetData->device()->seek(index);
4199 while(!aTargetData->atEnd()) {
4204 } else { // Not treat toolbars
4205 aData << (uchar) QToolBarMarker;
4206 aData << (int) 0; //Nb toolbars = 0