1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File: LightApp_Application.cxx
24 // Created: 6/20/2005 18:39:45 PM
25 // Author: Natalia Donis
28 // E.A. : On windows with python 2.6, there is a conflict
29 // E.A. : between pymath.h and Standard_math.h which define
30 // E.A. : some same symbols : acosh, asinh, ...
31 #include <Standard_math.hxx>
32 #ifndef DISABLE_PYCONSOLE
37 #ifndef DISABLE_PYCONSOLE
38 #include "LightApp_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_DataOwner.h"
46 #include "LightApp_Displayer.h"
47 #include "LightApp_Study.h"
48 #include "LightApp_Preferences.h"
49 #include "LightApp_PreferencesDlg.h"
50 #include "LightApp_ModuleDlg.h"
51 #include "LightApp_AboutDlg.h"
52 #include "LightApp_ModuleAction.h"
53 // temporary commented
54 #include "LightApp_EventFilter.h"
55 #include "LightApp_OBSelector.h"
56 #include "LightApp_SelectionMgr.h"
57 #include "LightApp_DataObject.h"
58 #include "LightApp_WgViewModel.h"
59 #include "LightApp_FullScreenHelper.h"
62 #include <GUI_version.h>
63 #include <Basics_OCCTVersion.hxx>
65 #include <SALOME_Event.h>
67 #include <Style_Salome.h>
68 #include <Style_PrefDlg.h>
70 #include <CAM_Module.h>
71 #include <CAM_DataModel.h>
72 #include <CAM_Study.h>
73 #include <STD_TabDesktop.h>
75 #include <SUIT_DataBrowser.h>
76 #include <SUIT_Session.h>
77 #include <SUIT_Study.h>
78 #include <SUIT_FileDlg.h>
79 #include <SUIT_ResourceMgr.h>
80 #include <SUIT_ShortcutMgr.h>
81 #include <SUIT_Tools.h>
82 #include <SUIT_Accel.h>
83 #include <SUIT_MessageBox.h>
84 #include <SUIT_ViewWindow.h>
87 #include <QtxToolBar.h>
88 #include <QtxTreeView.h>
89 #include <QtxMRUAction.h>
90 #include <QtxDockAction.h>
91 #include <QtxDockWidget.h>
92 #include <QtxActionToolMgr.h>
93 #include <QtxSearchTool.h>
94 #include <QtxWorkstack.h>
96 #include <QtxWebBrowser.h>
98 #include <LogWindow.h>
100 #ifndef DISABLE_GLVIEWER
101 #include <GLViewer_Viewer.h>
102 #include <GLViewer_ViewManager.h>
103 #include "LightApp_GLSelector.h"
106 #ifndef DISABLE_PLOT2DVIEWER
107 #include <Plot2d_ViewManager.h>
108 #include <Plot2d_ViewModel.h>
109 #include <Plot2d_ViewWindow.h>
110 #include <Plot2d_ViewFrame.h>
111 #include "LightApp_Plot2dSelector.h"
112 #ifndef DISABLE_SALOMEOBJECT
113 #include <SPlot2d_ViewModel.h>
115 #include <Plot2d_ViewModel.h>
119 #ifndef DISABLE_OCCVIEWER
120 #include <OCCViewer_ViewManager.h>
121 #include <OCCViewer_ViewFrame.h>
122 #ifndef DISABLE_SALOMEOBJECT
123 #include <SOCC_ViewModel.h>
125 #include <OCCViewer_ViewModel.h>
127 #include "LightApp_OCCSelector.h"
130 #ifndef DISABLE_VTKVIEWER
131 #ifndef DISABLE_SALOMEOBJECT
132 #include <SVTK_ViewModel.h>
133 #include <SVTK_ViewManager.h>
134 #include "LightApp_VTKSelector.h"
136 #include <VTKViewer_ViewModel.h>
137 #include <VTKViewer_ViewManager.h>
139 #include <VTKViewer_ViewModel.h>
142 #ifndef DISABLE_QXGRAPHVIEWER
143 #include <QxScene_ViewManager.h>
144 #include <QxScene_ViewModel.h>
145 #include <QxScene_ViewWindow.h>
148 #ifndef DISABLE_GRAPHICSVIEW
149 #include "GraphicsView_Viewer.h"
150 #include "GraphicsView_ViewManager.h"
151 #include "LightApp_GVSelector.h"
154 #define VISIBILITY_COLUMN_WIDTH 25
160 #include <QStringList>
162 #include <QApplication>
164 #include <QStatusBar>
166 #include <QObjectList>
168 #include <QInputDialog>
169 #include <QFontDatabase>
171 #include <QByteArray>
175 #include <QHeaderView>
180 #include <utilities.h>
182 #define FIRST_HELP_ID 1000000
184 #ifndef DISABLE_SALOMEOBJECT
185 #include <SALOME_InteractiveObject.hxx>
186 #include <SALOME_ListIO.hxx>
189 #include <Standard_Version.hxx>
191 #define ToolBarMarker 0
192 #define DockWidgetMarker 1
194 static const char* imageEmptyIcon[] = {
197 "....................",
198 "....................",
199 "....................",
200 "....................",
201 "....................",
202 "....................",
203 "....................",
204 "....................",
205 "....................",
206 "....................",
207 "....................",
208 "....................",
209 "....................",
210 "....................",
211 "....................",
212 "....................",
213 "....................",
214 "....................",
215 "....................",
216 "...................."};
218 int LightApp_Application::lastStudyId = 0;
221 // Markers used to parse array with dockable windows and toolbars state.
222 // For more details please see the qdockarealayout.cpp && qtoolbararealayout.cpp
223 // in the Qt source code.
225 #define QDockWidgetMarker 0xfd // = DockWidgetStateMarker
226 #define QToolBarMarker 0xfc // = ToolBarStateMarkerEx
228 // Format of the Byte array with the windows and toolbar state is:
229 // VersionMarker|version|DockWidgetStateMarker|nbDockWidgetLines|...DocWidgetData...|ToolBarStateMarkerEx|nbToolBarLines|...ToolBarData...
231 //Find toolbar marker position in the array in the following way:
232 //since the 'toolbar marker' is not unique, find index of first occurrence of the
233 //'toolbar marker' in the array and check that next string is name of the toolbar
235 int getToolbarMarkerIndex(QByteArray input, const QStringList& aFlags) {
236 int aResult = -1,tmp = 0;
237 int inputLen = input.length();
238 QDataStream anInputData(&input, QIODevice::ReadOnly);
239 while(tmp < inputLen) {
240 tmp = input.indexOf(QToolBarMarker, tmp + 1);
243 anInputData.device()->seek(tmp);
247 anInputData >> lines;
249 if(lines == 0 && anInputData.atEnd()){
250 //Case then array doesn't contain information about toolbars,
261 if(aFlags.contains(str)) {
270 \return last global id of study
272 int LightApp_Application::studyId()
274 return LightApp_Application::lastStudyId;
277 /*!Create new instance of LightApp_Application.*/
278 extern "C" LIGHTAPP_EXPORT SUIT_Application* createApplication()
280 return new LightApp_Application();
283 /*! \var global preferences of LightApp */
284 LightApp_Preferences* LightApp_Application::_prefs_ = 0;
288 \class LightApp_Application
289 Application containing LightApp module
293 LightApp_Application::LightApp_Application()
294 : CAM_Application( false ),
296 myScreenHelper(new LightApp_FullScreenHelper())
298 Q_INIT_RESOURCE( LightApp );
300 STD_TabDesktop* desk = new STD_TabDesktop();
301 desk->setFullScreenAllowed(false);
302 desk->setMinimizeAllowed(false);
306 // initialize auto save timer
307 myAutoSaveTimer = new QTimer( this );
308 myAutoSaveTimer->setSingleShot( true );
309 connect( myAutoSaveTimer, SIGNAL( timeout() ), this, SLOT( onSaveDoc() ) );
311 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
312 QPixmap aLogo = aResMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
314 QtxWebBrowser::setResourceManager( aResMgr );
315 QtxWebBrowser::setData("browser:icon", aResMgr->loadPixmap( "LightApp", tr( "BROWSER_ICON" ) ) );
316 QtxWebBrowser::setData("browser:title", tr( "BROWSER_TITLE" ) );
317 QtxWebBrowser::setData("toolbar:title", tr( "BROWSER_TOOLBAR_TITLE" ) );
318 QtxWebBrowser::setData("menu:file:title", tr( "BROWSER_FILEMENU" ) );
319 QtxWebBrowser::setData("action:close:title", tr( "BROWSER_CLOSE" ) );
320 QtxWebBrowser::setData("action:close:icon", aResMgr->loadPixmap( "LightApp", tr( "BROWSER_CLOSE_ICON" ) ) );
321 QtxWebBrowser::setData("action:back:title", tr( "BROWSER_BACK" ) );
322 QtxWebBrowser::setData("action:forward:title", tr( "BROWSER_FORWARD" ) );
323 QtxWebBrowser::setData("action:find:title", tr( "BROWSER_FIND" ) );
324 QtxWebBrowser::setData("action:findnext:title", tr( "BROWSER_FINDNEXT" ) );
325 QtxWebBrowser::setData("action:findprev:title", tr( "BROWSER_FINDPREV" ) );
327 desktop()->setWindowIcon( aLogo );
328 desktop()->setDockableMenuBar( false );
329 desktop()->setDockableStatusBar( false );
331 // base logo (salome itself)
332 desktop()->logoInsert( "_app_base", aResMgr->loadPixmap( "LightApp", tr( "APP_BASE_LOGO" ), false ) );
333 // extra logo (salome-based application)
334 desktop()->logoInsert( "_app_extra", aResMgr->loadPixmap( "LightApp", tr( "APP_EXTRA_LOGO" ), false ) );
338 mySelMgr = new LightApp_SelectionMgr( this );
340 myAccel = SUIT_Accel::getAccel();
342 #ifndef DISABLE_OCCVIEWER
343 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, OCCViewer_Viewer::Type() );
344 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, OCCViewer_Viewer::Type() );
345 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, OCCViewer_Viewer::Type() );
346 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, OCCViewer_Viewer::Type() );
347 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, OCCViewer_Viewer::Type() );
348 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, OCCViewer_Viewer::Type() );
349 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, OCCViewer_Viewer::Type() );
350 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, OCCViewer_Viewer::Type() );
351 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, OCCViewer_Viewer::Type() );
352 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, OCCViewer_Viewer::Type() );
353 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, OCCViewer_Viewer::Type() );
354 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, OCCViewer_Viewer::Type() );
356 #ifndef DISABLE_VTKVIEWER
357 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, VTKViewer_Viewer::Type() );
358 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, VTKViewer_Viewer::Type() );
359 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, VTKViewer_Viewer::Type() );
360 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, VTKViewer_Viewer::Type() );
361 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, VTKViewer_Viewer::Type() );
362 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, VTKViewer_Viewer::Type() );
363 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, VTKViewer_Viewer::Type() );
364 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, VTKViewer_Viewer::Type() );
365 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, VTKViewer_Viewer::Type() );
366 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, VTKViewer_Viewer::Type() );
367 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, VTKViewer_Viewer::Type() );
368 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, VTKViewer_Viewer::Type() );
370 #ifndef DISABLE_PLOT2DVIEWER
371 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, Plot2d_Viewer::Type() );
372 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, Plot2d_Viewer::Type() );
373 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, Plot2d_Viewer::Type() );
374 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, Plot2d_Viewer::Type() );
375 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, Plot2d_Viewer::Type() );
376 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, Plot2d_Viewer::Type() );
377 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, Plot2d_Viewer::Type() );
378 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, Plot2d_Viewer::Type() );
381 connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) );
382 connect( desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
383 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
384 connect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
385 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ), Qt::UniqueConnection );
388 // Set existing font for the python console in resources
389 if( !aResMgr->hasValue( "PyConsole", "font" ) )
392 QFont f = aResMgr->fontValue( "PyConsole", "font" );
394 QStringList famdb = fdb.families();
396 if ( famdb.contains(f.family()) || !aResMgr->hasValue( "PyConsole", "additional_families" ) )
399 QStringList anAddFamilies = aResMgr->stringValue( "PyConsole", "additional_families" ).split( ";", QString::SkipEmptyParts );
401 for ( QStringList::Iterator it = anAddFamilies.begin(); it != anAddFamilies.end(); ++it )
404 if ( famdb.contains(aFamily) )
406 f.setFamily( aFamily );
407 aResMgr->setValue( "PyConsole", "font", f );
414 *\li Save window geometry.
415 *\li Save desktop geometry.
416 *\li Save resource maneger.
417 *\li Delete selection manager.
419 LightApp_Application::~LightApp_Application()
422 delete myScreenHelper;
425 /*!Start application.*/
426 void LightApp_Application::start()
428 CAM_Application::start();
431 updateViewManagers();
434 desktop()->statusBar()->showMessage( "" );
436 LightApp_EventFilter::Init();
439 /*!Gets application name.*/
440 QString LightApp_Application::applicationName() const
442 static QString _app_name;
443 if ( _app_name.isEmpty() )
444 _app_name = tr( "APP_NAME" );
448 /*!Gets application version.*/
449 QString LightApp_Application::applicationVersion() const
451 static QString _app_version;
453 if ( _app_version.isEmpty() )
455 QString resVersion = tr( "APP_VERSION" );
456 if ( resVersion != "APP_VERSION" )
458 _app_version = resVersion;
462 _app_version = GUI_VERSION_STR;
468 /*!Load module by \a name.*/
469 CAM_Module* LightApp_Application::loadModule( const QString& name, const bool showMsg )
471 CAM_Module* mod = CAM_Application::loadModule( name, showMsg );
474 connect( this, SIGNAL( studyOpened() ), mod, SLOT( onModelOpened() ) );
475 connect( this, SIGNAL( studySaved() ), mod, SLOT( onModelSaved() ) );
476 connect( this, SIGNAL( studyClosed() ), mod, SLOT( onModelClosed() ) );
481 /*!Activate module by \a modName*/
482 bool LightApp_Application::activateModule( const QString& modName )
485 CAM_Module* prevMod = activeModule();
488 actName = prevMod->moduleName();
490 if ( actName == modName )
493 putInfo( tr( "ACTIVATING_MODULE" ).arg( modName ) );
495 saveDockWindowsState();
497 bool status = CAM_Application::activateModule( modName );
499 updateModuleActions();
507 updateViewManagers();
512 /*!Gets selection manager.*/
513 LightApp_SelectionMgr* LightApp_Application::selectionMgr() const
518 /*!Creat action "New window" for certain type of viewer:*/
519 void LightApp_Application::createActionForViewer( const int id,
521 const QString& suffix,
524 QString vtlt = tr( QString( "NEW_WINDOW_%1" ).arg( suffix ).toLatin1().constData() );
525 QString tip = tr( "CREATING_NEW_WINDOW" ).arg( vtlt.remove( "&" ) );
526 QAction* a = createAction( id, // menu action id
533 false, // toggle flag
535 SLOT( onNewWindow() ) ); // slot
536 createMenu( a, parentId, -1 );
541 void LightApp_Application::createActions()
543 CAM_Application::createActions();
545 SUIT_Desktop* desk = desktop();
546 SUIT_ResourceMgr* resMgr = resourceMgr();
549 createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIcon(),
550 tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
551 Qt::CTRL+Qt::Key_R, desk, false, this, SLOT( onPreferences() ) );
555 // - Help for modules
557 int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
558 createMenu( separator(), helpMenu, -1, 10 );
559 QStringList aModuleList;
560 modules( aModuleList, false );
561 aModuleList.prepend( "GUI" );
562 aModuleList.prepend( "KERNEL" );
564 int id = LightApp_Application::UserID + FIRST_HELP_ID;
567 foreach( aModule, aModuleList ) {
568 if ( aModule.isEmpty() ) // module title (user name)
570 IMap <QString, QString> helpData; // list of help files for the module
571 QString helpSubMenu; // help submenu name (empty if not needed)
572 QString modName = moduleName( aModule ); // module name
573 if ( modName.isEmpty() ) modName = aModule; // for KERNEL and GUI
574 QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName ); // module root dir variable
575 QString modDir = getenv( rootDir.toLatin1().constData() ); // module root dir
577 if (resMgr->hasValue( modName, "documentation" ) )
578 docSection = resMgr->stringValue(modName, "documentation");
579 else if ( resMgr->hasSection( modName + "_documentation" ) )
580 docSection = modName + "_documentation";
581 if ( !docSection.isEmpty() ) {
582 helpSubMenu = resMgr->stringValue( docSection, "sub_menu", "" ).arg( aModule );
583 QStringList listOfParam = resMgr->parameters( docSection );
584 foreach( QString paramName, listOfParam ) {
585 QString valueStr = resMgr->stringValue( docSection, paramName );
586 if ( !valueStr.isEmpty() ) {
587 QFileInfo fi( valueStr );
588 if ( fi.isRelative() && !modDir.isEmpty() )
589 valueStr = Qtx::addSlash( modDir ) + valueStr;
590 if ( QFile::exists( valueStr ) )
591 helpData.insert( paramName.arg( aModule ), valueStr );
596 if ( helpData.isEmpty() && !modDir.isEmpty() ) {
597 QStringList idxLst = QStringList() << modDir << "share" << "doc" << "salome" << "gui" << modName << "index.html";
598 QString indexFile = idxLst.join( QDir::separator() ); // index file
599 if ( QFile::exists( indexFile ) )
600 helpData.insert( tr( "%1 module Users's Guide" ).arg( aModule ), indexFile );
603 IMapConstIterator<QString, QString > fileIt;
604 for ( fileIt = helpData.begin(); fileIt != helpData.end(); fileIt++ ) {
605 QString helpFileName = fileIt.key();
606 // remove all '//' occurances
607 while ( helpFileName.contains( "//" ) )
608 helpFileName.replace( "//", "" );
609 // obtain submenus hierarchy if given
610 QStringList smenus = helpFileName.split( "/" );
611 helpFileName = smenus.last();
613 QAction* a = createAction( id, helpFileName,
614 resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
615 helpFileName, helpFileName,
616 0, desk, false, this, SLOT( onHelpContentsModule() ) );
617 a->setData( fileIt.value() );
618 if ( !helpSubMenu.isEmpty() ) {
619 smenus.prepend( helpSubMenu );
621 // create sub-menus hierarchy
622 int menuId = helpMenu;
623 foreach ( QString subMenu, smenus ) {
624 menuId = createMenu( subMenu, menuId, -1, 0 );
626 createMenu( a, menuId, -1, 0 );
631 // - Additional help items
633 createMenu( separator(), helpMenu, -1, 5 );
635 QStringList addHelpItems = resMgr->parameters( "add_help" );
636 foreach ( QString addHelpItem, addHelpItems ) {
637 QString valueStr = resMgr->stringValue( "add_help", addHelpItem );
638 if ( !valueStr.isEmpty() && QFile::exists( valueStr ) ) {
639 QAction* a = createAction( id, addHelpItem,
640 resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
641 addHelpItem, addHelpItem,
642 0, desk, false, this, SLOT( onHelpContentsModule() ) );
643 a->setData( valueStr );
644 createMenu( a, helpMenu, -1, 5 );
650 static QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), 0 );
651 connect( mru, SIGNAL( activated( const QString& ) ), this, SLOT( onMRUActivated( const QString& ) ) );
652 registerAction( MRUId, mru );
654 // default icon for neutral point ('SALOME' module)
655 QPixmap defIcon = resMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
656 if ( defIcon.isNull() )
657 defIcon = QPixmap( imageEmptyIcon );
659 //! default icon for any module
660 QPixmap modIcon = resMgr->loadPixmap( "LightApp", tr( "APP_MODULE_ICO" ), false );
661 if ( modIcon.isNull() )
662 modIcon = QPixmap( imageEmptyIcon );
665 modules( modList, false );
667 if ( modList.count() > 1 )
669 LightApp_ModuleAction* moduleAction =
670 new LightApp_ModuleAction( tr( "APP_NAME" ), defIcon, desk );
672 QMap<QString, QString> iconMap;
673 moduleIconNames( iconMap );
675 const int iconSize = 20;
677 QStringList::Iterator it;
678 for ( it = modList.begin(); it != modList.end(); ++it )
680 if ( !isLibExists( *it ) )
683 QString modName = moduleName( *it );
685 if ( !isModuleAccessible( *it ) )
689 if ( iconMap.contains( *it ) )
690 iconName = iconMap[*it];
692 QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
696 INFOS ( "\n****************************************************************" << std::endl
697 << "* Icon for " << (*it).toLatin1().constData()
698 << " not found. Using the default one." << std::endl
699 << "****************************************************************" << std::endl );
702 icon = Qtx::scaleIcon( icon, iconSize );
704 moduleAction->insertModule( *it, icon );
707 connect( moduleAction, SIGNAL( moduleActivated( const QString& ) ),
708 this, SLOT( onModuleActivation( const QString& ) ) );
709 registerAction( ModulesListId, moduleAction );
713 int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, MenuWindowId, 100 );
714 int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
716 createAction( CloseId, tr( "TOT_CLOSE" ), QIcon(), tr( "MEN_DESK_CLOSE" ), tr( "PRP_CLOSE" ),
717 Qt::CTRL+Qt::Key_F4, desk, false, this, SLOT( onCloseWindow() ) );
718 createAction( CloseAllId, tr( "TOT_CLOSE_ALL" ), QIcon(), tr( "MEN_DESK_CLOSE_ALL" ), tr( "PRP_CLOSE_ALL" ),
719 0, desk, false, this, SLOT( onCloseAllWindow() ) );
720 createAction( GroupAllId, tr( "TOT_GROUP_ALL" ), QIcon(), tr( "MEN_DESK_GROUP_ALL" ), tr( "PRP_GROUP_ALL" ),
721 0, desk, false, this, SLOT( onGroupAllWindow() ) );
723 createMenu( CloseId, windowMenu, 0, -1 );
724 createMenu( CloseAllId, windowMenu, 0, -1 );
725 createMenu( GroupAllId, windowMenu, 0, -1 );
726 createMenu( separator(), windowMenu, -1, 0 );
728 #ifndef DISABLE_GLVIEWER
729 createActionForViewer( NewGLViewId, newWinMenu, QString::number( 0 ), Qt::ALT+Qt::Key_G );
731 #ifndef DISABLE_PLOT2DVIEWER
732 createActionForViewer( NewPlot2dId, newWinMenu, QString::number( 1 ), Qt::ALT+Qt::Key_P );
734 #ifndef DISABLE_OCCVIEWER
735 createActionForViewer( NewOCCViewId, newWinMenu, QString::number( 2 ), Qt::ALT+Qt::Key_O );
737 #ifndef DISABLE_VTKVIEWER
738 createActionForViewer( NewVTKViewId, newWinMenu, QString::number( 3 ), Qt::ALT+Qt::Key_K );
740 #ifndef DISABLE_QXGRAPHVIEWER
741 createActionForViewer( NewQxSceneViewId, newWinMenu, QString::number( 4 ), Qt::ALT+Qt::Key_S );
743 #ifndef DISABLE_GRAPHICSVIEW
744 createActionForViewer( NewGraphicsViewId, newWinMenu, QString::number( 5 ), Qt::ALT+Qt::Key_R );
747 createAction( RenameId, tr( "TOT_RENAME" ), QIcon(), tr( "MEN_DESK_RENAME" ), tr( "PRP_RENAME" ),
748 Qt::ALT+Qt::SHIFT+Qt::Key_R, desk, false, this, SLOT( onRenameWindow() ) );
749 createMenu( RenameId, windowMenu, -1 );
751 int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
752 createMenu( PreferencesId, fileMenu, 50, -1 );
753 createMenu( separator(), fileMenu, -1, 50, -1 );
755 createMenu( separator(), fileMenu, -1, 100, -1 );
756 createMenu( MRUId, fileMenu, 100, -1 );
757 createMenu( separator(), fileMenu, -1, 100, -1 );
759 createAction( StyleId, tr( "TOT_THEME" ), QIcon(), tr( "MEN_DESK_THEME" ), tr( "PRP_THEME" ),
760 0, desk, false, this, SLOT( onStylePreferences() ) );
762 createAction( FullScreenId, tr( "TOT_FULLSCREEN" ), QIcon(), tr( "MEN_DESK_FULLSCREEN" ), tr( "PRP_FULLSCREEN" ),
763 Qt::Key_F11, desk, false, this, SLOT( onFullScreen() ) );
766 int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1 );
767 createMenu( separator(), viewMenu, -1, 20, -1 );
768 createMenu( StyleId, viewMenu, 20, -1 );
769 createMenu( FullScreenId, viewMenu, 20, -1 );
771 int modTBar = createTool( tr( "INF_TOOLBAR_MODULES" ) );
772 createTool( ModulesListId, modTBar );
775 /*!On module activation action.*/
776 void LightApp_Application::onModuleActivation( const QString& modName )
778 // Force user to create/open a study before module activation
779 QMap<QString, QString> iconMap;
780 moduleIconNames( iconMap );
781 QPixmap icon = resourceMgr()->loadPixmap( moduleName( modName ), iconMap[ modName ], false );
783 icon = resourceMgr()->loadPixmap( "LightApp", tr( "APP_MODULE_BIG_ICO" ), false ); // default icon for any module
785 bool cancelled = false;
787 while ( !modName.isEmpty() && !activeStudy() && !cancelled ){
788 LightApp_ModuleDlg aDlg( desktop(), modName, icon );
789 QMap<int, QString> opmap = activateModuleActions();
790 for ( QMap<int, QString>::ConstIterator it = opmap.begin(); it != opmap.end(); ++it )
791 aDlg.addButton( it.value(), it.key() );
793 int res = aDlg.exec();
795 // some operation is selected
796 moduleActionSelected( res );
800 putInfo( tr("INF_CANCELLED") );
802 LightApp_ModuleAction* moduleAction =
803 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
805 moduleAction->setActiveModule( QString() );
811 activateModule( modName );
814 /*!Default module activation.*/
815 QString LightApp_Application::defaultModule() const
817 QStringList aModuleNames;
818 modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration
819 //! If there's the one and only module --> activate it automatically
820 //! TODO: Possible improvement - default module can be taken from preferences
821 return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" );
824 /*!On new window slot.*/
825 void LightApp_Application::onNewWindow()
827 const QObject* obj = sender();
828 if ( !obj || !obj->inherits( "QAction" ) )
832 int id = actionId( (QAction*)obj );
835 #ifndef DISABLE_GLVIEWER
837 type = GLViewer_Viewer::Type();
840 #ifndef DISABLE_PLOT2DVIEWER
842 type = Plot2d_Viewer::Type();
845 #ifndef DISABLE_OCCVIEWER
847 type = OCCViewer_Viewer::Type();
850 #ifndef DISABLE_VTKVIEWER
852 type = VTKViewer_Viewer::Type();
855 #ifndef DISABLE_QXGRAPHVIEWER
856 case NewQxSceneViewId:
857 type = QxScene_Viewer::Type();
860 #ifndef DISABLE_GRAPHICSVIEW
861 case NewGraphicsViewId:
862 type = GraphicsView_Viewer::Type();
867 if ( !type.isEmpty() )
868 createViewManager( type );
872 SLOT: Creates new document
874 void LightApp_Application::onNewDoc()
876 //asl: fix for 0020515
877 if ( activeStudy() ) {
878 saveDockWindowsState();
879 #ifdef SINGLE_DESKTOP
885 CAM_Application::onNewDoc();
889 SLOT: Opens new document
891 void LightApp_Application::onOpenDoc()
893 SUIT_Study* study = activeStudy();
894 saveDockWindowsState();
896 #ifdef SINGLE_DESKTOP
902 CAM_Application::onOpenDoc();
904 if ( !study ) // new study will be create in THIS application
907 updateViewManagers();
912 SLOT: Opens new document.
913 \param aName - name of file
915 bool LightApp_Application::onOpenDoc( const QString& aName )
917 if ( activeStudy() ) {
918 #ifdef SINGLE_DESKTOP
923 // We should take mru action first because this application instance can be deleted later.
924 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
926 bool res = CAM_Application::onOpenDoc( aName );
931 mru->insert( aName );
933 mru->remove( aName );
939 SLOT: Displays "About" message box
941 void LightApp_Application::onHelpAbout()
943 LightApp_AboutDlg dlg( applicationName(), applicationVersion(), desktop() );
948 Private SLOT: Called on selection is changed
949 Dispatchs active module that selection is changed
951 void LightApp_Application::onSelection()
953 onSelectionChanged();
955 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
956 ((LightApp_Module*)activeModule())->selectionChanged();
961 \param study - SUIT_Study.
963 void LightApp_Application::setActiveStudy( SUIT_Study* study )
965 CAM_Application::setActiveStudy( study );
969 Enables/Disables menu items and toolbar buttons. Rebuild menu
971 void LightApp_Application::updateCommandsStatus()
973 CAM_Application::updateCommandsStatus();
976 #ifndef DISABLE_GLVIEWER
977 a = action( NewGLViewId );
979 a->setEnabled( activeStudy() );
982 #ifndef DISABLE_PLOT2DVIEWER
983 a = action( NewPlot2dId );
985 a->setEnabled( activeStudy() );
988 #ifndef DISABLE_OCCVIEWER
989 a = action( NewOCCViewId );
991 a->setEnabled( activeStudy() );
994 #ifndef DISABLE_VTKVIEWER
995 a = action( NewVTKViewId );
997 a->setEnabled( activeStudy() );
1000 #ifndef DISABLE_QXGRAPHVIEWER
1001 a = action( NewQxSceneViewId );
1003 a->setEnabled( activeStudy() );
1006 #ifndef DISABLE_GRAPHICSVIEW
1007 a = action( NewGraphicsViewId );
1009 a->setEnabled( activeStudy() );
1015 Runs system command in separate thread
1017 class RunBrowser: public QThread
1020 RunBrowser( LightApp_Application* app,
1021 const QString& theApp,
1022 const QString& theParams,
1023 const QString& theHelpFile,
1024 const QString& theContext = QString() )
1026 myParams( theParams ),
1027 myContext( theContext ),
1031 //For the external browser always specify 'file://' protocol,
1032 //because some WEB browsers (for example Mozilla Firefox) can't open local file without protocol.
1033 myHelpFile = QString("file://%1").arg( QFileInfo( theHelpFile ).canonicalFilePath() );
1038 if ( !myApp.isEmpty() && !myHelpFile.isEmpty()) {
1039 QString aCommand = QString( "%1 %2 \"%3%4\"" ).arg( myApp, myParams, myHelpFile, myContext.isEmpty() ? QString("") : QString( "#%1" ).arg( myContext ) );
1041 QProcess* proc = new QProcess();
1043 proc->start( aCommand );
1044 if ( !proc->waitForStarted() ) {
1045 SALOME_CustomEvent* ce2000 = new SALOME_CustomEvent( 2000 );
1046 QString* msg = new QString( QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).arg( myApp, myHelpFile ) );
1047 ce2000->setData( msg );
1048 QApplication::postEvent( myLApp, ce2000 );
1059 LightApp_Application* myLApp;
1063 SLOT: Displays help contents for choosen module
1065 void LightApp_Application::onHelpContentsModule()
1067 const QAction* a = (QAction*) sender();
1068 QString helpFile = a->data().toString();
1069 if ( helpFile.isEmpty() ) return;
1071 SUIT_ResourceMgr* resMgr = resourceMgr();
1074 platform = "winapplication";
1076 platform = "application";
1078 QString anApp = resMgr->stringValue("ExternalBrowser", platform);
1080 QString quote("\"");
1081 anApp.prepend( quote );
1082 anApp.append( quote );
1084 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
1085 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1087 if( useExtBrowser ) {
1088 if ( !anApp.isEmpty() ) {
1089 RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile );
1093 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1094 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1095 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1097 showPreferences( tr( "PREF_APP" ) );
1102 // On Win32 platform QWebKit of the Qt 4.6.3 hang up in case 'file://' protocol
1103 // is defined. On Linux platform QWebKit doesn't work correctly without 'file://' protocol.
1104 QtxWebBrowser::loadUrl(helpFile);
1106 QtxWebBrowser::loadUrl(QString("file://%1").arg(helpFile));
1112 SLOT: Displays help contents for choosen dialog
1114 void LightApp_Application::onHelpContextModule( const QString& theComponentName,
1115 const QString& theFileName,
1116 const QString& theContext )
1118 QString fileName = theFileName;
1119 QString context = theContext;
1120 if ( !QFile::exists( fileName ) && theContext.isEmpty() ) {
1121 // context might be passed within theFileName argument
1122 QStringList comps = fileName.split("#");
1123 if ( comps.count() > 1 ) {
1124 context = comps.last();
1126 fileName = comps.join("#");
1130 QString homeDir = "";
1131 if ( !theComponentName.isEmpty() ) {
1132 QString dir = getenv( ( theComponentName + "_ROOT_DIR" ).toLatin1().constData() );
1133 if ( !dir.isEmpty() )
1134 homeDir = Qtx::addSlash( Qtx::addSlash( dir ) +
1135 Qtx::addSlash( "share" ) +
1136 Qtx::addSlash( "doc" ) +
1137 Qtx::addSlash( "salome" ) +
1138 Qtx::addSlash( "gui" ) +
1139 Qtx::addSlash( theComponentName ) );
1142 QString helpFile = QFileInfo( homeDir + fileName ).absoluteFilePath();
1143 SUIT_ResourceMgr* resMgr = resourceMgr();
1146 platform = "winapplication";
1148 platform = "application";
1150 QString anApp = resMgr->stringValue("ExternalBrowser", platform);
1152 QString quote("\"");
1153 anApp.prepend( quote );
1154 anApp.append( quote );
1157 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1160 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
1162 if ( !anApp.isEmpty() ) {
1163 RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile, context );
1167 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1168 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1169 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1170 showPreferences( tr( "PREF_APP" ) );
1175 // On Win32 platform QWebKit of the Qt 4.6.3 hang up in case 'file://' protocol
1176 // is defined. On Linux platform QWebKit doesn't work correctly without 'file://' protocol.
1177 QtxWebBrowser::loadUrl(helpFile, context);
1179 QtxWebBrowser::loadUrl(QString("file://%1").arg(helpFile), context);
1186 Sets enable or disable some actions on selection changed.
1188 void LightApp_Application::onSelectionChanged()
1190 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
1191 bool canCopy = m ? m->canCopy() : false;
1192 bool canPaste = m ? m->canPaste() : false;
1194 action( EditCopyId )->setEnabled(canCopy);
1195 action( EditPasteId )->setEnabled(canPaste);
1199 Adds window to application.
1200 \param wid - QWidget
1201 \param flag - key for window
1202 \param studyId - study id
1203 Flag used how identificator of window in windows list.
1206 void LightApp_Application::addWindow( QWidget* wid, const int flag, const int studyId )
1214 if ( !activeStudy() )
1217 sId = activeStudy()->id();
1220 if ( !myWindows.contains( flag ) )
1222 QMap<int, int> winMap;
1223 currentWindows( winMap );
1225 LightApp_WidgetContainer* newWC = new LightApp_WidgetContainer( flag, desktop() );
1226 connect( newWC, SIGNAL( destroyed ( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
1227 // asv: connecting a slot for storing visibility flag of a window
1228 connect( newWC, SIGNAL( visibilityChanged ( bool ) ), SLOT( onVisibilityChanged( bool ) ) );
1229 myWindows.insert( flag, newWC );
1230 if ( winMap.contains( flag ) ) {
1231 //desktop()->removeDockWidget( myWindows[flag] );
1232 desktop()->addDockWidget( (Qt::DockWidgetArea)winMap[flag], myWindows[flag] );
1235 //myWindows[flag]->setResizeEnabled( true );
1236 myWindows[flag]->setFeatures( QDockWidget::AllDockWidgetFeatures );
1237 myWindows[flag]->setObjectName( QString( "dock_window_%1" ).arg( flag ) );
1238 //myWindows[flag]->setFixedExtentWidth( wid->width() );
1239 //myWindows[flag]->setFixedExtentHeight( wid->height() );
1240 myWindows[flag]->resize( wid->width(), wid->height() );
1244 #ifndef DISABLE_PYCONSOLE
1245 if( wid->inherits( "PyConsole_Console" ) )
1247 if( resourceMgr()->hasValue( "PyConsole", "font" ) )
1248 f = resourceMgr()->fontValue( "PyConsole", "font" );
1251 f = ( ( PyConsole_Console* )wid )->font();
1252 resourceMgr()->setValue( "PyConsole", "font", f );
1259 myWindows[flag]->insert( sId, wid );
1262 setWindowShown( flag, !myWindows[flag]->isEmpty() );
1266 QWidget* LightApp_Application::dockWindow( const int id ) const
1269 if ( myWin.contains( id ) )
1274 QDockWidget* LightApp_Application::windowDock( QWidget* wid ) const
1279 QDockWidget* dock = 0;
1280 QWidget* w = wid->parentWidget();
1281 while ( w && !dock )
1283 dock = ::qobject_cast<QDockWidget*>( w );
1284 w = w->parentWidget();
1289 void LightApp_Application::insertDockWindow( const int id, QWidget* wid )
1294 if ( wid != dockWindow( id ) )
1295 removeDockWindow( id );
1297 myWin.insert( id, wid );
1299 QtxDockWidget* dock = new QtxDockWidget( true, desktop() );
1300 connect( dock, SIGNAL( destroyed( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
1302 dock->setFeatures( QDockWidget::AllDockWidgetFeatures );
1303 dock->setObjectName( QString( "window_%1" ).arg( id ) );
1304 dock->setWidget( wid );
1306 QKeySequence accel = wid->property( "shortcut" ).value<QKeySequence>();
1307 if ( !accel.isEmpty() )
1308 dock->toggleViewAction()->setShortcut( accel );
1313 void LightApp_Application::removeDockWindow( const int id )
1315 QWidget* wid = dockWindow( id );
1321 QDockWidget* dock = windowDock( wid );
1325 dock->setWidget( 0 );
1326 wid->setParent( 0 );
1327 wid->setVisible( false );
1331 void LightApp_Application::placeDockWindow( const int id, Qt::DockWidgetArea place )
1333 QDockWidget* dock = windowDock( dockWindow( id ) );
1334 if ( dock && desktop() ) {
1335 desktop()->addDockWidget( place, dock );
1336 QtxDockAction* a = qobject_cast<QtxDockAction*>( action( ViewWindowsId ) );
1337 if ( a ) a->update();
1343 \param flag - key for window
1344 \param studyId - study id
1345 Flag used how identificator of window in windows list.
1347 QWidget* LightApp_Application::getWindow( const int flag, const int )
1349 QWidget* wid = dockWindow( flag );
1351 insertDockWindow( flag, wid = createWindow( flag ) );
1353 QMap<int, int> winMap;
1354 currentWindows( winMap );
1355 if ( winMap.contains( flag ) )
1356 placeDockWindow( flag, (Qt::DockWidgetArea)winMap[flag] );
1362 \return Object Browser
1364 SUIT_DataBrowser* LightApp_Application::objectBrowser()
1366 return qobject_cast<SUIT_DataBrowser*>( dockWindow( WT_ObjectBrowser ) );
1372 LogWindow* LightApp_Application::logWindow()
1374 return qobject_cast<LogWindow*>( dockWindow( WT_LogWindow ) );
1377 #ifndef DISABLE_PYCONSOLE
1379 This returns the python console integrated to the GUI. Depending
1380 when you request the python console, this function could return
1381 null. Then the optional parameter force (default to false) can be
1382 set to force the creation of the python console if it is not done
1384 \param force - if true, the pythonConsole is created if it does not exist yet
1385 \return Python Console
1387 PyConsole_Console* LightApp_Application::pythonConsole(const bool force)
1389 QWidget* wid = dockWindow( WT_PyConsole );
1390 if ( !wid && force==true) {
1391 wid = getWindow(WT_PyConsole);
1393 return qobject_cast<PyConsole_Console*>( wid );
1398 Updates object browser and maybe data models
1399 \param updateModels - if it is true, then data models are updated
1401 void LightApp_Application::updateObjectBrowser( const bool updateModels )
1403 // update existing data models
1406 const bool isAutoUpdate = objectBrowser() ? objectBrowser()->autoUpdate() : true;
1407 if ( objectBrowser() )
1408 objectBrowser()->setAutoUpdate( false );
1410 LightApp_Study* study = dynamic_cast<LightApp_Study*>(activeStudy());
1412 CAM_Study::ModelList dm_list;
1413 study->dataModels( dm_list );
1414 QListIterator<CAM_DataModel*> it( dm_list );
1415 while ( it.hasNext() ) {
1416 CAM_DataModel* camDM = it.next();
1417 if ( camDM && camDM->inherits( "LightApp_DataModel" ) )
1418 ((LightApp_DataModel*)camDM)->update();
1422 if( objectBrowser() )
1423 objectBrowser()->setAutoUpdate( isAutoUpdate );
1426 if ( objectBrowser() ) {
1427 objectBrowser()->updateGeometry();
1428 objectBrowser()->updateTree( 0, false );
1435 LightApp_Preferences* LightApp_Application::preferences() const
1437 return preferences( false );
1441 \return first view manager of some type
1442 \param vmType - type of view manager
1443 \param create - is it necessary to create view manager in case, when there is no manager of such type
1445 SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, const bool create )
1447 SUIT_ViewManager* aVM = viewManager( vmType );
1448 SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
1450 if ( anActiveVM && anActiveVM->getType() == vmType )
1453 if ( aVM && create )
1455 if ( !aVM->getActiveView() )
1458 aVM->getActiveView()->setFocus();
1461 aVM = createViewManager( vmType );
1467 Creates view manager of some type
1468 \param vmType - type of view manager
1470 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType )
1472 SUIT_ResourceMgr* resMgr = resourceMgr();
1474 SUIT_ViewManager* viewMgr = 0;
1475 #ifndef DISABLE_GLVIEWER
1476 if( vmType == GLViewer_Viewer::Type() )
1478 viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() );
1479 new LightApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
1482 #ifndef DISABLE_PLOT2DVIEWER
1483 if( vmType == Plot2d_Viewer::Type() )
1485 viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
1487 #ifndef DISABLE_SALOMEOBJECT
1488 SPlot2d_Viewer* v = new SPlot2d_Viewer();
1490 new LightApp_Plot2dSelector( v, mySelMgr );
1492 vm = new Plot2d_Viewer();
1494 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1495 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
1498 Plot2d_ViewFrame* frame = wnd->getViewFrame();
1499 frame->setBackgroundColor( resMgr->colorValue( "Plot2d", "Background", frame->backgroundColor() ) );
1503 #ifndef DISABLE_QXGRAPHVIEWER
1504 if( vmType == QxScene_Viewer::Type() )
1506 viewMgr = new QxScene_ViewManager( activeStudy(), desktop() );
1507 QxScene_Viewer* vm = new QxScene_Viewer();
1508 viewMgr->setViewModel( vm );
1509 //QxScene_ViewWindow* wnd = dynamic_cast<QxScene_ViewWindow*>( viewMgr->getActiveView() );
1512 #ifndef DISABLE_GRAPHICSVIEW
1513 if( vmType == GraphicsView_Viewer::Type() )
1515 viewMgr = new GraphicsView_ViewManager( activeStudy(), desktop() );
1516 new LightApp_GVSelector( (GraphicsView_Viewer*)viewMgr->getViewModel(), mySelMgr );
1519 #ifndef DISABLE_OCCVIEWER
1520 if( vmType == OCCViewer_Viewer::Type() )
1522 viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
1523 OCCViewer_Viewer* vm;
1524 #ifndef DISABLE_SALOMEOBJECT
1525 vm = new SOCC_Viewer();
1527 vm = new OCCViewer_Viewer( true );
1529 vm->setBackground( OCCViewer_ViewFrame::TOP_LEFT,
1530 resMgr->backgroundValue( "OCCViewer", "xz_background", vm->background(OCCViewer_ViewFrame::TOP_LEFT) ) );
1531 vm->setBackground( OCCViewer_ViewFrame::TOP_RIGHT,
1532 resMgr->backgroundValue( "OCCViewer", "yz_background", vm->background(OCCViewer_ViewFrame::TOP_RIGHT) ) );
1533 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_LEFT,
1534 resMgr->backgroundValue( "OCCViewer", "xy_background", vm->background(OCCViewer_ViewFrame::BOTTOM_LEFT) ) );
1535 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_RIGHT,
1536 resMgr->backgroundValue( "OCCViewer", "background", vm->background(OCCViewer_ViewFrame::MAIN_VIEW) ) );
1538 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1539 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ));
1540 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1541 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1542 vm->enablePreselection( resMgr->booleanValue( "OCCViewer", "enable_preselection", vm->isPreselectionEnabled() ) );
1543 vm->enableSelection( resMgr->booleanValue( "OCCViewer", "enable_selection", vm->isSelectionEnabled() ) );
1545 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1546 new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
1549 #ifndef DISABLE_VTKVIEWER
1550 #ifndef DISABLE_SALOMEOBJECT
1551 if ( vmType == SVTK_Viewer::Type() )
1553 if ( vmType == VTKViewer_Viewer::Type() )
1556 #ifndef DISABLE_SALOMEOBJECT
1557 viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
1558 SVTK_Viewer* vm = dynamic_cast<SVTK_Viewer*>( viewMgr->getViewModel() );
1561 vm->setProjectionMode( resMgr->integerValue( "VTKViewer", "projection_mode", vm->projectionMode() ) );
1562 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1563 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1564 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ) );
1565 vm->setStaticTrihedronVisible( resMgr->booleanValue( "3DViewer", "show_static_trihedron", vm->isStaticTrihedronVisible() ) );
1566 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1567 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1568 vm->setPreSelectionMode(resMgr->integerValue( "VTKViewer", "preselection", vm->preSelectionMode() ) );
1569 vm->enableSelection( resMgr->booleanValue( "VTKViewer", "enable_selection", vm->isSelectionEnabled() ) );
1570 vm->setIncrementalSpeed( resMgr->integerValue( "VTKViewer", "speed_value", vm->incrementalSpeed() ),
1571 resMgr->integerValue( "VTKViewer", "speed_mode", vm->incrementalSpeedMode() ) );
1572 vm->setSpacemouseButtons( resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", vm->spacemouseBtn(1) ),
1573 resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", vm->spacemouseBtn(2) ),
1574 resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", vm->spacemouseBtn(3) ) );
1575 new LightApp_VTKSelector( vm, mySelMgr );
1578 viewMgr = new VTKViewer_ViewManager( activeStudy(), desktop() );
1579 VTKViewer_Viewer* vm = dynamic_cast<VTKViewer_Viewer*>( viewMgr->getViewModel() );
1581 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1589 addViewManager( viewMgr );
1590 SUIT_ViewWindow* viewWin = viewMgr->createViewWindow();
1592 if ( viewWin && desktop() ) {
1593 viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1594 viewWin->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1600 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, QWidget* w )
1602 SUIT_ResourceMgr* resMgr = resourceMgr();
1604 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
1606 new LightApp_WgViewModel( vmType, w ) );
1607 vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
1609 addViewManager( vm );
1610 SUIT_ViewWindow* vw = vm->createViewWindow();
1611 if ( vw && desktop() ) {
1612 vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1613 vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1616 if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
1617 myUserWmTypes << vmType;
1623 SLOT: Removes view manager from application
1625 void LightApp_Application::onCloseView( SUIT_ViewManager* theVM )
1627 removeViewManager( theVM );
1631 Protected SLOT: On study created.
1632 \param theStudy - just created study
1634 void LightApp_Application::onStudyCreated( SUIT_Study* theStudy )
1636 SUIT_DataObject* aRoot = 0;
1637 if ( theStudy && theStudy->root() )
1639 aRoot = theStudy->root();
1640 //aRoot->setName( tr( "DATA_MODELS" ) );
1643 getWindow( WT_ObjectBrowser );
1645 loadDockWindowsState();
1647 if ( objectBrowser() )
1648 objectBrowser()->setRoot( aRoot );
1650 activateModule( defaultModule() );
1652 if ( objectBrowser() )
1653 objectBrowser()->openLevels();
1657 Protected SLOT: On study opened.
1658 \param theStudy - just opened study
1660 void LightApp_Application::onStudyOpened( SUIT_Study* theStudy )
1662 SUIT_DataObject* aRoot = 0;
1663 if ( theStudy && theStudy->root() )
1665 aRoot = theStudy->root();
1669 getWindow( WT_ObjectBrowser );
1671 loadDockWindowsState();
1673 if ( objectBrowser() )
1674 objectBrowser()->setRoot( aRoot );
1676 activateModule( defaultModule() );
1678 if ( objectBrowser() )
1679 objectBrowser()->openLevels();
1684 /*!Protected SLOT. On study saved.*/
1685 void LightApp_Application::onStudySaved( SUIT_Study* s )
1687 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
1689 mru->insert( s->studyName() );
1694 /*!Protected SLOT. On study closed.*/
1695 void LightApp_Application::onStudyClosed( SUIT_Study* s )
1698 disconnect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
1699 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
1702 // stop auto-save timer
1703 myAutoSaveTimer->stop();
1705 // Bug 10396: clear selection
1706 mySelMgr->clearSelected();
1708 // Bug 12944: emit signal only after clear selection
1711 activateModule( "" );
1714 /*!Protected SLOT.On desktop activated.*/
1715 void LightApp_Application::onDesktopActivated()
1717 CAM_Application::onDesktopActivated();
1718 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>(activeModule());
1720 aModule->studyActivated();
1723 void LightApp_Application::studyOpened( SUIT_Study* s )
1725 CAM_Application::studyOpened( s );
1728 updateViewManagers();
1731 void LightApp_Application::studySaved( SUIT_Study* s )
1733 CAM_Application::studyOpened( s );
1734 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1735 if ( aResMgr && activeStudy() ) {
1736 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
1737 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
1741 void LightApp_Application::studyCreated( SUIT_Study* s )
1743 CAM_Application::studyCreated( s );
1746 updateViewManagers();
1749 /*!Gets file filter.
1750 *\retval QString "(*.bin)"
1752 QString LightApp_Application::getFileFilter() const
1760 Shows file dialog and return user selected file name
1762 QString LightApp_Application::getFileName( bool open, const QString& initial, const QString& filters,
1763 const QString& caption, QWidget* parent )
1767 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1768 return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
1771 /*! Gets directory*/
1772 QString LightApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
1776 return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true );
1779 /*! Get open file names*/
1780 QStringList LightApp_Application::getOpenFileNames( const QString& initial, const QString& filters,
1781 const QString& caption, QWidget* parent )
1785 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1786 return SUIT_FileDlg::getOpenFileNames( parent, initial, fls, caption, true );
1789 /*!Private SLOT. Update object browser.*/
1790 void LightApp_Application::onRefresh()
1792 updateObjectBrowser( true );
1795 /*!Private SLOT. Support drag-and-drop operation.*/
1796 void LightApp_Application::onDropped( const QList<SUIT_DataObject*>& objects, SUIT_DataObject* parent, int row, Qt::DropAction action )
1798 LightApp_DataObject* parentObj = dynamic_cast<LightApp_DataObject*>( parent );
1802 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>( parentObj->module() );
1804 aModule->dropObjects( objects, parentObj, row, action );
1807 /*!Private SLOT. On preferences.*/
1808 void LightApp_Application::onPreferences()
1810 showPreferences( activeModule() ? activeModule()->moduleName() : tr( "PREF_CATEGORY_SALOME" ) );
1813 /*!Private SLOT. On preferences.*/
1814 void LightApp_Application::showPreferences( const QString& itemText )
1816 QApplication::setOverrideCursor( Qt::WaitCursor );
1818 LightApp_PreferencesDlg* prefDlg = new LightApp_PreferencesDlg( preferences( true ), desktop());
1820 QApplication::restoreOverrideCursor();
1825 preferences()->activateItem( itemText );
1827 if ( ( prefDlg->exec() == QDialog::Accepted || prefDlg->isSaved() ) && resourceMgr() )
1830 resourceMgr()->setValue( "desktop", "geometry", desktop()->storeGeometry() );
1831 resourceMgr()->save();
1834 shortcutMgr()->updateShortcuts();
1840 /*!Protected SLOT. On preferences changed.*/
1841 void LightApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param )
1843 LightApp_Module* sMod = 0;
1844 CAM_Module* mod = module( modName );
1845 if ( mod && mod->inherits( "LightApp_Module" ) )
1846 sMod = (LightApp_Module*)mod;
1849 sMod->preferencesChanged( section, param );
1851 preferencesChanged( section, param );
1852 // emit signal to allow additional preferences changing processing
1853 emit preferenceChanged( modName, section, param );
1856 /*!Remove all windows from study.*/
1857 void LightApp_Application::beforeCloseDoc( SUIT_Study* s )
1859 if ( SUIT_DataBrowser* ob = objectBrowser() )
1862 CAM_Application::beforeCloseDoc( s );
1865 /*!Update actions.*/
1866 void LightApp_Application::updateActions()
1868 updateCommandsStatus();
1874 SUIT_Study* LightApp_Application::createNewStudy()
1876 LightApp_Application::lastStudyId++;
1878 LightApp_Study* aStudy = new LightApp_Study( this );
1880 // Set up processing of major study-related events
1881 connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
1882 connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
1883 connect( aStudy, SIGNAL( saved ( SUIT_Study* ) ), this, SLOT( onStudySaved ( SUIT_Study* ) ) );
1884 connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
1890 Creates window by flag.
1891 \param flag - identificator of window type
1893 QWidget* LightApp_Application::createWindow( const int flag )
1897 SUIT_ResourceMgr* resMgr = resourceMgr();
1899 if ( flag == WT_ObjectBrowser )
1901 SUIT_DataBrowser* ob = new SUIT_DataBrowser( new LightApp_DataObject(), desktop() );
1902 ob->setSortMenuEnabled( true );
1903 ob->setAutoUpdate( true );
1904 if ( resMgr->hasValue( "ObjectBrowser", "auto_hide_search_tool" ) )
1905 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
1907 //ob->setAutoOpenLevel( 1 ); // commented by ASV as a fix to bug IPAL10107
1908 ob->setWindowTitle( tr( "OBJECT_BROWSER" ) );
1909 connect( ob, SIGNAL( requestUpdate() ), this, SLOT( onRefresh() ) );
1911 QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
1912 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
1913 treeModel->setSearcher( this );
1914 treeModel->registerColumn( 0, EntryCol, LightApp_DataObject::EntryId );
1915 treeModel->setAppropriate( EntryCol, Qtx::Toggled );
1917 // Mantis issue 0020136: Drag&Drop in OB
1918 SUIT_ProxyModel* proxyModel = dynamic_cast<SUIT_ProxyModel*>(treeModel);
1920 connect( proxyModel, SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
1921 this, SLOT( onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
1924 // temporary commented
1926 OB_ListView* ob_list = dynamic_cast<OB_ListView*>( const_cast<QListView*>( ob->listView() ) );
1928 ob_list->setColumnMaxWidth( 0, desktop()->width()/4 );
1931 // Create OBSelector
1932 new LightApp_OBSelector( ob, mySelMgr );
1934 ob->treeView()->header()->setResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
1935 ob->treeView()->header()->moveSection(SUIT_DataObject::NameId,SUIT_DataObject::VisibilityId);
1936 ob->treeView()->setColumnWidth(SUIT_DataObject::VisibilityId, VISIBILITY_COLUMN_WIDTH);
1937 ob->setProperty( "shortcut", QKeySequence( "Alt+Shift+O" ) );
1939 ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1941 #ifndef DISABLE_PYCONSOLE
1942 else if ( flag == WT_PyConsole )
1944 PyConsole_Console* pyCons = new PyConsole_EnhConsole( desktop(),new LightApp_PyInterp());
1945 pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
1946 pyCons->setFont(resourceMgr()->fontValue( "PyConsole", "font" ));
1947 pyCons->setIsShowBanner(resourceMgr()->booleanValue( "PyConsole", "show_banner", true ));
1948 pyCons->setProperty( "shortcut", QKeySequence( "Alt+Shift+P" ) );
1951 pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1954 else if ( flag == WT_LogWindow )
1956 LogWindow* logWin = new LogWindow( desktop() );
1957 logWin->setWindowTitle( tr( "LOG_WINDOW" ) );
1958 logWin->setProperty( "shortcut", QKeySequence( "Alt+Shift+L" ) );
1960 logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1966 \return default windows( Object Browser, Python Console )
1967 Adds to map \a aMap.
1969 void LightApp_Application::defaultWindows( QMap<int, int>& aMap ) const
1971 aMap.insert( WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1972 #ifndef DISABLE_PYCONSOLE
1973 aMap.insert( WT_PyConsole, Qt::BottomDockWidgetArea );
1975 // aMap.insert( WT_LogWindow, Qt::DockBottom );
1978 /*!Default view managers*/
1979 void LightApp_Application::defaultViewManagers( QStringList& ) const
1985 \return preferences.
1986 Create preferences, if \a crt = true.
1988 LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const
1993 LightApp_Application* that = (LightApp_Application*)this;
1995 bool toCreate = !_prefs_ && crt;
1998 _prefs_ = new LightApp_Preferences( resourceMgr() );
1999 that->createPreferences( _prefs_ );
2002 that->myPrefs = _prefs_;
2004 connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
2005 this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ) );
2010 SUIT_ResourceMgr* resMgr = resourceMgr();
2012 QList<SUIT_Application*> appList = SUIT_Session::session()->applications();
2013 for ( QList<SUIT_Application*>::iterator appIt = appList.begin(); appIt != appList.end(); ++appIt )
2015 LightApp_Application* app = ::qobject_cast<LightApp_Application*>( *appIt );
2019 QStringList modNameList;
2020 app->modules( modNameList, false );
2022 QMap<QString, QString> iconMap;
2023 app->moduleIconNames( iconMap );
2025 for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it )
2027 if ( !app->isLibExists( *it ) || _prefs_->hasModule( *it ) )
2030 int modId = _prefs_->addPreference( *it );
2031 if ( iconMap.contains( *it ) )
2032 _prefs_->setItemIcon( modId, Qtx::scaleIcon( resMgr->loadPixmap( moduleName( *it ), iconMap[*it], false ), 20 ) );
2036 app->modules( modList );
2037 QListIterator<CAM_Module*> itr( modList );
2038 while ( itr.hasNext() )
2040 LightApp_Module* mod = 0;
2042 CAM_Module* anItem = itr.next();
2043 if ( anItem->inherits( "LightApp_Module" ) )
2044 mod = (LightApp_Module*)anItem;
2046 if ( mod && !_prefs_->hasModule( mod->moduleName() ) )
2048 _prefs_->addPreference( mod->moduleName() );
2049 mod->createPreferences();
2050 that->emptyPreferences( mod->moduleName() );
2054 _prefs_->setItemProperty( "info", tr( "PREFERENCES_NOT_LOADED" ) );
2060 Adds new module to application
2062 void LightApp_Application::moduleAdded( CAM_Module* mod )
2064 CAM_Application::moduleAdded( mod );
2066 LightApp_Module* lightMod = 0;
2067 if ( mod && mod->inherits( "LightApp_Module" ) )
2068 lightMod = (LightApp_Module*)mod;
2070 if ( myPrefs && lightMod && !myPrefs->hasModule( lightMod->moduleName() ))
2072 myPrefs->addPreference( mod->moduleName() );
2073 lightMod->createPreferences();
2074 emptyPreferences( mod->moduleName() );
2078 void LightApp_Application::emptyPreferences( const QString& modName )
2080 QtxPreferenceItem* item = myPrefs->findItem( modName, true );
2081 if ( !item || !item->isEmpty() )
2084 // printf( "---------------------> Modify for empty module.\n" );
2086 QtxPagePrefFrameItem* frm = new QtxPagePrefFrameItem( item->title(), item->parentItem() );
2087 frm->setIcon( item->icon() );
2088 frm->setStretch( false );
2089 item->parentItem()->insertItem( frm, item );
2090 new QtxPagePrefLabelItem( Qt::AlignCenter, tr( "PREFERENCES_NOT_SUPPORTED" ).arg( modName ), frm );
2097 void LightApp_Application::createPreferences( LightApp_Preferences* pref )
2102 QStringList aValuesList;
2103 QList<QVariant> anIndicesList;
2107 // . Top-level "SALOME" preferences group <<start>>
2108 int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
2109 pref->setItemIcon( salomeCat, Qtx::scaleIcon( resourceMgr()->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false ), 20 ) );
2111 // .. "General" preferences tab <<start>>
2112 int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat );
2114 // ... "Language" group <<start>>
2115 int langGroup = pref->addPreference( tr( "PREF_GROUP_LANGUAGE" ), genTab );
2116 pref->setItemProperty( "columns", 2, langGroup );
2117 // .... -> application language
2118 int curLang = pref->addPreference( tr( "PREF_CURRENT_LANGUAGE" ), langGroup,
2119 LightApp_Preferences::Selector, "language", "language" );
2120 QStringList aLangs = SUIT_Session::session()->resourceMgr()->stringValue( "language", "languages", "en" ).split( "," );
2121 QList<QVariant> aIcons;
2122 foreach ( QString aLang, aLangs ) {
2123 aIcons << QPixmap( QString( ":/images/%1" ).arg( aLang ) );
2125 pref->setItemProperty( "strings", aLangs, curLang );
2126 pref->setItemProperty( "icons", aIcons, curLang );
2128 int curLocale = pref->addPreference( tr( "PREF_CURRENT_LOCALE" ), langGroup,
2129 LightApp_Preferences::Bool, "language", "locale" );
2130 // ... "Language" group <<end>>
2132 // ... "Look and feel" group <<start>>
2133 int lookGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), genTab );
2134 pref->setItemProperty( "columns", 2, lookGroup );
2135 // .... -> show splash-screen
2136 pref->addPreference( tr( "PREF_SHOW_SPLASH" ), lookGroup, LightApp_Preferences::Bool, "launch", "splash" );
2137 // .... -> opaque resize
2138 pref->addPreference( tr( "PREF_OPAQUE_RESIZE" ), lookGroup, LightApp_Preferences::Bool, "desktop", "opaque_resize" );
2139 // .... -> drop-down buttons
2140 pref->addPreference( tr( "PREF_DROP_DOWN_BUTTONS" ), lookGroup, LightApp_Preferences::Bool, "viewers", "drop_down_buttons" );
2141 // ... "Look and feel" group <<end>>
2143 // ... "Study properties" group <<start>>
2144 int studyGroup = pref->addPreference( tr( "PREF_GROUP_STUDY" ), genTab );
2145 pref->setItemProperty( "columns", 2, studyGroup );
2146 // .... -> multi-file save
2147 pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "multi_file" );
2148 // .... -> ascii save mode
2149 pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" );
2150 // .... -> store windows geometry
2151 pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" );
2152 pref->addPreference( "", studyGroup, LightApp_Preferences::Space );
2153 pref->addPreference( tr( "PREF_STORE_TOOL_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_tool_positions" );
2154 // .... -> auto-save
2155 int autoSaveInterval = pref->addPreference( tr( "PREF_AUTO_SAVE" ), studyGroup,
2156 LightApp_Preferences::IntSpin, "Study", "auto_save_interval" );
2157 pref->setItemProperty( "min", 0, autoSaveInterval );
2158 pref->setItemProperty( "max", 1440, autoSaveInterval );
2159 pref->setItemProperty( "special", tr( "PREF_AUTO_SAVE_DISABLED" ), autoSaveInterval );
2160 // ... "Study properties" group <<end>>
2162 // ... "Help browser" group <<start>>
2163 int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab, LightApp_Preferences::Auto, "ExternalBrowser", "use_external_browser");
2165 QString platform = "winapplication";
2167 QString platform = "application";
2169 // .... -> browser application
2170 int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, LightApp_Preferences::File, "ExternalBrowser", platform );
2171 pref->setItemProperty( "mode", Qtx::PT_OpenFile, apppref );
2172 // .... -> browser parameters
2173 pref->addPreference( tr( "PREF_PARAM" ), extgroup, LightApp_Preferences::String, "ExternalBrowser", "parameters" );
2174 // ... "Help browser" group <<end>>
2176 // ... "Python console properties" group <<start>>
2177 int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab );
2179 pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, LightApp_Preferences::Font, "PyConsole", "font" );
2180 // .... -> show banner
2181 pref->addPreference( tr( "PREF_SHOW_BANNER" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "show_banner" );
2182 // ... "Python console properties" group <<end>>
2184 // ... "MRU" preferences group <<start>>
2185 int mruGroup = pref->addPreference( tr( "PREF_GROUP_MRU" ), genTab, LightApp_Preferences::Auto, "MRU", "show_mru" );
2186 pref->setItemProperty( "columns", 4, mruGroup );
2187 // number of MRU items
2188 int mruVisCount = pref->addPreference( tr( "PREF_MRU_VISIBLE_COUNT" ), mruGroup, LightApp_Preferences::IntSpin,
2189 "MRU", "visible_count" );
2190 pref->setItemProperty( "min", 0, mruVisCount );
2191 pref->setItemProperty( "max", 100, mruVisCount );
2193 int mruLinkType = pref->addPreference( tr( "PREF_MRU_LINK_TYPE" ), mruGroup, LightApp_Preferences::Selector,
2194 "MRU", "link_type" );
2195 aValuesList.clear();
2196 anIndicesList.clear();
2197 aValuesList << tr("PREF_MRU_LINK_AUTO") << tr("PREF_MRU_LINK_SHORT") << tr("PREF_MRU_LINK_FULL");
2198 anIndicesList << 0 << 1 << 2 ;
2199 pref->setItemProperty( "strings", aValuesList, mruLinkType );
2200 pref->setItemProperty( "indexes", anIndicesList, mruLinkType );
2201 // ... "MRU" preferences group <<end>>
2202 // .. "General" preferences tab <<end>>
2204 // .. "3D viewer" group <<start>>
2205 int Viewer3DGroup = pref->addPreference( tr( "PREF_GROUP_3DVIEWER" ), salomeCat );
2206 // ... -> navigation mode
2207 int vtkStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), Viewer3DGroup,
2208 LightApp_Preferences::Selector, "3DViewer", "navigation_mode" );
2209 aValuesList.clear();
2210 anIndicesList.clear();
2211 aValuesList << tr("PREF_STANDARD_STYLE") << tr("PREF_KEYFREE_STYLE");
2212 anIndicesList << 0 << 1;
2213 pref->setItemProperty( "strings", aValuesList, vtkStyleMode );
2214 pref->setItemProperty( "indexes", anIndicesList, vtkStyleMode );
2215 // ... -> zooming mode
2216 #if OCC_VERSION_LARGE > 0x0603000A // available only with OCC-6.3-sp11 and higher version
2217 int occZoomingStyleMode = pref->addPreference( tr( "PREF_ZOOMING" ), Viewer3DGroup,
2218 LightApp_Preferences::Selector, "3DViewer", "zooming_mode" );
2219 aValuesList.clear();
2220 anIndicesList.clear();
2221 aValuesList << tr("PREF_ZOOMING_AT_CENTER") << tr("PREF_ZOOMING_AT_CURSOR");
2222 anIndicesList << 0 << 1;
2223 pref->setItemProperty( "strings", aValuesList, occZoomingStyleMode );
2224 pref->setItemProperty( "indexes", anIndicesList, occZoomingStyleMode );
2226 // ... "Trihedron" group <<start>>
2227 int occTriGroup = pref->addPreference( tr( "PREF_TRIHEDRON" ), Viewer3DGroup );
2228 pref->setItemProperty( "columns", 2, occTriGroup );
2229 // .... -> trihedron size
2230 int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occTriGroup,
2231 LightApp_Preferences::DblSpin, "3DViewer", "trihedron_size" );
2232 pref->setItemProperty( "min", 1.0E-06, occTS );
2233 pref->setItemProperty( "max", 1000, occTS );
2234 // .... -> relative size of trihedron
2235 pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "relative_size" );
2236 // .... -> show static trihedron
2237 pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "show_static_trihedron" );
2238 // ... "Trihedron" group <<end>>
2239 // .. "3D viewer" group <<end>>
2243 #ifndef DISABLE_OCCVIEWER
2244 // .. "OCC viewer" group <<start>>
2245 int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), salomeCat );
2247 // ... "Background" group <<start>>
2248 int bgGroup = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup );
2249 // pref->setItemProperty( "columns", 2, bgGroup );
2250 aValuesList.clear();
2251 anIndicesList.clear();
2253 formats = OCCViewer_Viewer::backgroundData( aValuesList, idList, txtList );
2254 foreach( int gid, idList ) anIndicesList << gid;
2255 // .... -> 3D viewer background
2256 bgId = pref->addPreference( tr( "PREF_3DVIEWER_BACKGROUND" ), bgGroup,
2257 LightApp_Preferences::Background, "OCCViewer", "background" );
2258 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2259 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2260 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2261 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2262 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2263 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2264 pref->setItemProperty( "custom_enabled", false, bgId );
2265 pref->setItemProperty( "image_formats", formats, bgId );
2266 // .... -> XZ viewer background
2267 bgId = pref->addPreference( tr( "PREF_XZVIEWER_BACKGROUND" ), bgGroup,
2268 LightApp_Preferences::Background, "OCCViewer", "xz_background" );
2269 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2270 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2271 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2272 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2273 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2274 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2275 pref->setItemProperty( "custom_enabled", false, bgId );
2276 pref->setItemProperty( "image_formats", formats, bgId );
2277 // .... -> YZ viewer background
2278 bgId = pref->addPreference( tr( "PREF_YZVIEWER_BACKGROUND" ), bgGroup,
2279 LightApp_Preferences::Background, "OCCViewer", "yz_background" );
2280 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2281 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2282 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2283 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2284 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2285 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2286 pref->setItemProperty( "custom_enabled", false, bgId );
2287 pref->setItemProperty( "image_formats", formats, bgId );
2288 // .... -> XY viewer background
2289 bgId = pref->addPreference( tr( "PREF_XYVIEWER_BACKGROUND" ), bgGroup,
2290 LightApp_Preferences::Background, "OCCViewer", "xy_background" );
2291 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2292 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2293 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2294 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2295 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2296 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2297 pref->setItemProperty( "custom_enabled", false, bgId );
2298 pref->setItemProperty( "image_formats", formats, bgId );
2299 // ... "Background" group <<end>>
2302 // ... "Selection" group <<start>>
2303 int occSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), occGroup );
2304 pref->setItemProperty( "columns", 2, occSelectionGroup );
2305 // .... -> enable preselection
2306 pref->addPreference( tr( "PREF_ENABLE_PRESELECTION" ), occSelectionGroup,
2307 LightApp_Preferences::Bool, "OCCViewer", "enable_preselection" );
2308 // .... -> enable selection
2309 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), occSelectionGroup,
2310 LightApp_Preferences::Bool, "OCCViewer", "enable_selection" );
2311 // ... "Selection" group <<end>>
2313 // ... -> empty frame (for layout) <<start>>
2314 int occGen = pref->addPreference( "", occGroup, LightApp_Preferences::Frame );
2315 pref->setItemProperty( "margin", 0, occGen );
2316 pref->setItemProperty( "columns", 2, occGen );
2317 // ... -> empty frame (for layout) <<end>>
2318 // .. "OCC viewer" group <<end>>
2321 #ifndef DISABLE_VTKVIEWER
2322 // .. "VTK viewer" group <<start>>
2323 int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), salomeCat ); //viewTab
2325 // ... -> empty frame (for layout) <<start>>
2326 int vtkGen = pref->addPreference( "", vtkGroup, LightApp_Preferences::Frame );
2327 //pref->setItemProperty( "columns", 2, vtkGen );
2328 // .... -> projection mode
2329 int vtkProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), vtkGen,
2330 LightApp_Preferences::Selector, "VTKViewer", "projection_mode" );
2331 aValuesList.clear();
2332 anIndicesList.clear();
2333 aValuesList << tr("PREF_ORTHOGRAPHIC") << tr("PREF_PERSPECTIVE");
2334 anIndicesList << 0 << 1;
2335 pref->setItemProperty( "strings", aValuesList, vtkProjMode );
2336 pref->setItemProperty( "indexes", anIndicesList, vtkProjMode );
2337 // .... -> background
2338 aValuesList.clear();
2339 anIndicesList.clear();
2341 #ifndef DISABLE_SALOMEOBJECT
2342 formats = SVTK_Viewer::backgroundData( aValuesList, idList, txtList );
2344 foreach( int gid, idList ) anIndicesList << gid;
2345 bgId = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGen,
2346 LightApp_Preferences::Background, "VTKViewer", "background" );
2347 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2348 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2349 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2350 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2351 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2352 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2353 pref->setItemProperty( "custom_enabled", false, bgId );
2354 #ifndef DISABLE_SALOMEOBJECT
2355 pref->setItemProperty( "image_formats", formats, bgId );
2357 // .... -> speed increment
2358 int vtkSpeed = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED" ), vtkGen,
2359 LightApp_Preferences::IntSpin, "VTKViewer", "speed_value" );
2360 pref->setItemProperty( "min", 1, vtkSpeed );
2361 pref->setItemProperty( "max", 1000, vtkSpeed );
2362 // .... -> speed mode
2363 int vtkSpeedMode = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED_MODE" ), vtkGen,
2364 LightApp_Preferences::Selector, "VTKViewer", "speed_mode" );
2365 aValuesList.clear();
2366 anIndicesList.clear();
2367 aValuesList << tr("PREF_ARITHMETIC") << tr("PREF_GEOMETRICAL");
2368 anIndicesList << 0 << 1;
2369 pref->setItemProperty( "strings", aValuesList, vtkSpeedMode );
2370 pref->setItemProperty( "indexes", anIndicesList, vtkSpeedMode );
2372 // ... "Selection" group <<start>>
2373 int vtkSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), vtkGroup );
2374 pref->setItemProperty( "columns", 2, vtkSelectionGroup );
2375 // .... -> preselection
2376 int vtkPreselection = pref->addPreference( tr( "PREF_PRESELECTION" ), vtkSelectionGroup,
2377 LightApp_Preferences::Selector, "VTKViewer", "preselection" );
2378 aValuesList.clear();
2379 anIndicesList.clear();
2380 aValuesList << tr("PREF_PRESELECTION_STANDARD") << tr("PREF_PRESELECTION_DYNAMIC") << tr("PREF_PRESELECTION_DISABLED");
2381 anIndicesList << 0 << 1 << 2;
2382 pref->setItemProperty( "strings", aValuesList, vtkPreselection );
2383 pref->setItemProperty( "indexes", anIndicesList, vtkPreselection );
2384 // .... -> enable selection
2385 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), vtkSelectionGroup, LightApp_Preferences::Bool, "VTKViewer", "enable_selection" );
2386 // ... "Selection" group <<end>>
2388 // ... -> empty frame (for layout) <<end>>
2390 // ... space mouse sub-group <<start>>
2391 int vtkSM = pref->addPreference( tr( "PREF_FRAME_SPACEMOUSE" ), vtkGroup, LightApp_Preferences::GroupBox );
2392 //pref->setItemProperty( "columns", 2, vtkSM );
2393 // .... -> decrease speed increment
2394 int spacemousePref1 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_1" ), vtkSM,
2395 LightApp_Preferences::Selector, "VTKViewer",
2396 "spacemouse_func1_btn" );
2397 // .... -> increase speed increment
2398 int spacemousePref2 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_2" ), vtkSM,
2399 LightApp_Preferences::Selector, "VTKViewer",
2400 "spacemouse_func2_btn" );
2401 // .... -> dominant / combined switch
2402 int spacemousePref3 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_3" ), vtkSM,
2403 LightApp_Preferences::Selector, "VTKViewer",
2404 "spacemouse_func5_btn" ); //
2405 aValuesList.clear();
2406 anIndicesList.clear();
2407 aValuesList << tr( "PREF_SPACEMOUSE_BTN_1" ) << tr( "PREF_SPACEMOUSE_BTN_2" ) << tr( "PREF_SPACEMOUSE_BTN_3" );
2408 aValuesList << tr( "PREF_SPACEMOUSE_BTN_4" ) << tr( "PREF_SPACEMOUSE_BTN_5" ) << tr( "PREF_SPACEMOUSE_BTN_6" );
2409 aValuesList << tr( "PREF_SPACEMOUSE_BTN_7" ) << tr( "PREF_SPACEMOUSE_BTN_8" ) << tr( "PREF_SPACEMOUSE_BTN_*" );
2410 aValuesList << tr( "PREF_SPACEMOUSE_BTN_10" ) << tr( "PREF_SPACEMOUSE_BTN_11" );
2411 anIndicesList << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11;
2412 pref->setItemProperty( "strings", aValuesList, spacemousePref1 );
2413 pref->setItemProperty( "indexes", anIndicesList, spacemousePref1 );
2414 pref->setItemProperty( "strings", aValuesList, spacemousePref2 );
2415 pref->setItemProperty( "indexes", anIndicesList, spacemousePref2 );
2416 pref->setItemProperty( "strings", aValuesList, spacemousePref3 );
2417 pref->setItemProperty( "indexes", anIndicesList, spacemousePref3 );
2418 // ... space mouse sub-group <<end>>
2420 // ... avi recording sub-group <<start>>
2421 int vtkRec = pref->addPreference( tr( "PREF_FRAME_RECORDING" ), vtkGroup, LightApp_Preferences::GroupBox );
2422 pref->setItemProperty( "columns", 2, vtkRec );
2423 // .... -> recording mode
2424 int modePref = pref->addPreference( tr( "PREF_RECORDING_MODE" ), vtkRec,
2425 LightApp_Preferences::Selector, "VTKViewer", "recorder_mode" );
2426 aValuesList.clear();
2427 anIndicesList.clear();
2428 aValuesList << tr( "PREF_SKIPPED_FRAMES" ) << tr( "PREF_ALL_DISLPAYED_FRAMES" );
2429 anIndicesList << 0 << 1;
2430 pref->setItemProperty( "strings", aValuesList, modePref );
2431 pref->setItemProperty( "indexes", anIndicesList, modePref );
2433 int fpsPref = pref->addPreference( tr( "PREF_FPS" ), vtkRec,
2434 LightApp_Preferences::DblSpin, "VTKViewer", "recorder_fps" );
2435 pref->setItemProperty( "min", 0.1, fpsPref );
2436 pref->setItemProperty( "max", 100, fpsPref );
2438 int qualityPref = pref->addPreference( tr( "PREF_QUALITY" ), vtkRec,
2439 LightApp_Preferences::IntSpin, "VTKViewer", "recorder_quality" );
2440 pref->setItemProperty( "min", 1, qualityPref );
2441 pref->setItemProperty( "max", 100, qualityPref );
2442 // .... -> progressive mode
2443 pref->addPreference( tr( "PREF_PROGRESSIVE" ), vtkRec,
2444 LightApp_Preferences::Bool, "VTKViewer", "recorder_progressive" );
2445 // ... avi recording sub-group <<end>>
2447 // ... group names sub-group <<start>>
2448 int vtkGN = pref->addPreference( tr( "PREF_FRAME_GROUP_NAMES" ), vtkGroup,
2449 LightApp_Preferences::GroupBox, "VTKViewer", "show_group_names" );
2450 pref->setItemProperty( "columns", 2, vtkGN );
2451 // .... -> text color
2452 pref->addPreference( tr( "PREF_GROUP_NAMES_TEXT_COLOR" ), vtkGN,
2453 LightApp_Preferences::Color, "VTKViewer", "group_names_text_color" );
2454 // .... -> transparency
2455 int transPref = pref->addPreference( tr( "PREF_GROUP_NAMES_TRANSPARENCY" ), vtkGN,
2456 LightApp_Preferences::DblSpin, "VTKViewer", "group_names_transparency" );
2457 pref->setItemProperty( "min", 0.0, transPref );
2458 pref->setItemProperty( "max", 1.0, transPref );
2459 pref->setItemProperty( "step", 0.1, transPref );
2460 // ... -> group names sub-group <<end>>
2461 // .. "VTK viewer" group <<end>>
2464 // .. "Plot2d viewer" group <<start>>
2465 int plot2dGroup = pref->addPreference( tr( "PREF_GROUP_PLOT2DVIEWER" ), salomeCat ); //viewTab
2466 //pref->setItemProperty( "columns", 2, plot2dGroup );
2468 // ... -> background
2469 pref->addPreference( tr( "PREF_VIEWER_BACKGROUND_COLOR" ), plot2dGroup,
2470 LightApp_Preferences::Color, "Plot2d", "Background" );
2471 // ... -> selection color
2472 pref->addPreference( tr( "PREF_VIEWER_SELECTION" ), plot2dGroup,
2473 LightApp_Preferences::Color, "Plot2d", "SelectionColor" );
2475 // ... "Viewer" group <<start>>
2476 int plot2dViewerGroup = pref->addPreference( tr( "PREF_GROUP_VIEWER" ), plot2dGroup );
2478 // .... -> curve type
2479 int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dViewerGroup,
2480 LightApp_Preferences::Selector, "Plot2d", "CurveType" );
2481 aValuesList.clear();
2482 anIndicesList.clear();
2483 aValuesList << tr("PREF_POINTS") << tr("PREF_LINES") << tr("PREF_SPLINE");
2484 anIndicesList << 0 << 1 << 2 ;
2485 pref->setItemProperty( "strings", aValuesList, curveType );
2486 pref->setItemProperty( "indexes", anIndicesList, curveType );
2487 // .... -> marker size
2488 int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dViewerGroup,
2489 LightApp_Preferences::IntSpin, "Plot2d", "MarkerSize" );
2490 pref->setItemProperty( "min", 0, markerSize );
2491 pref->setItemProperty( "max", 100, markerSize );
2492 // .... -> horizontal scaling mode
2493 int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dViewerGroup,
2494 LightApp_Preferences::Selector, "Plot2d", "HorScaleMode" );
2495 aValuesList.clear();
2496 anIndicesList.clear();
2497 aValuesList << tr("PREF_LINEAR") << tr("PREF_LOGARITHMIC");
2498 anIndicesList << 0 << 1 ;
2499 pref->setItemProperty( "strings", aValuesList, horScale );
2500 pref->setItemProperty( "indexes", anIndicesList, horScale );
2501 // .... -> vertical scaling mode
2502 int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dViewerGroup,
2503 LightApp_Preferences::Selector, "Plot2d", "VerScaleMode" );
2504 pref->setItemProperty( "strings", aValuesList, verScale );
2505 pref->setItemProperty( "indexes", anIndicesList, verScale );
2507 // .... -> errors/deviation colot
2508 pref->addPreference( tr( "PREF_DEVIATION_COLOR" ), plot2dViewerGroup,
2509 LightApp_Preferences::Color, "Plot2d", "DeviationMarkerColor" );
2510 // .... -> deviation markers line size
2511 int deviationMarkerLw = pref->addPreference( tr( "PREF_DEVIATION_MARKER_LW" ), plot2dViewerGroup,
2512 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerLineWidth" );
2513 pref->setItemProperty( "min", 1, deviationMarkerLw );
2514 pref->setItemProperty( "max", 5, deviationMarkerLw );
2515 // .... -> deviation markers tick mark size
2516 int deviationMarkerTs = pref->addPreference( tr( "PREF_DEVIATION_MARKER_TS" ), plot2dViewerGroup,
2517 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerTickSize" );
2518 pref->setItemProperty( "min", 1, deviationMarkerTs );
2519 pref->setItemProperty( "max", 5, deviationMarkerTs );
2520 // .... "Viewer" group <<end>>
2522 // ... "Legend" group <<start>>
2523 int plot2dLegendGroup = pref->addPreference( tr( "PREF_GROUP_LEGEND" ), plot2dGroup );
2525 // .... -> show legend
2526 pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dLegendGroup,
2527 LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
2528 // .... -> legend position
2529 int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dLegendGroup,
2530 LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
2531 aValuesList.clear();
2532 anIndicesList.clear();
2533 aValuesList << tr("PREF_LEFT") << tr("PREF_RIGHT") << tr("PREF_TOP") << tr("PREF_BOTTOM");
2534 anIndicesList << 0 << 1 << 2 << 3 ;
2535 pref->setItemProperty( "strings", aValuesList, legendPosition );
2536 pref->setItemProperty( "indexes", anIndicesList, legendPosition );
2537 // .... -> Symbol type
2538 int legendSymbolType = pref->addPreference( tr( "PREF_LEGEND_SYMBOL_TYPE" ), plot2dLegendGroup,
2539 LightApp_Preferences::Selector, "Plot2d", "LegendSymbolType" );
2540 aValuesList.clear();
2541 anIndicesList.clear();
2542 aValuesList << tr("PREF_MARKER_ON_LINE") << tr("PREF_MARKER_ABOVE_LINE");
2543 anIndicesList << 0 << 1 ;
2544 pref->setItemProperty( "strings", aValuesList, legendSymbolType );
2545 pref->setItemProperty( "indexes", anIndicesList, legendSymbolType );
2546 // .... -> legend font
2547 pref->addPreference( tr( "PREF_LEGEND_FONT" ), plot2dLegendGroup, LightApp_Preferences::Font, "Plot2d", "LegendFont" );
2548 // ... -> font color
2549 pref->addPreference( tr( "PREF_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "LegendFontColor" );
2550 // ... -> selection font color
2551 pref->addPreference( tr( "PREF_SELECTED_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "SelectedLegendFontColor" );
2552 // ... "Legend" group <<end>>
2554 // .. "Plot2d viewer" group <<end>>
2556 // .. "Directories" preferences tab <<start>>
2557 int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat );
2558 // ... --> quick directories list
2559 int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab );
2560 pref->addPreference( tr( "" ), dirGroup,
2561 LightApp_Preferences::DirList, "FileDlg", "QuickDirList" );
2562 // .. "Directories" preferences tab <<end>>
2564 // .. "Object browser" preferences tab <<start>>
2565 int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
2567 // ... "Search tool" group <<start>>
2568 int stGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SEARCH_TOOL" ), obTab );
2569 // .... --> auto-hide
2570 pref->addPreference( tr( "PREF_AUTO_HIDE_SEARCH_TOOL" ), stGroup, LightApp_Preferences::Bool,
2571 "ObjectBrowser", "auto_hide_search_tool" );
2572 // ... "Search tool" group <<end>>
2574 // ... "Object browser settings" group <<start>>
2575 int objSetGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), obTab );
2576 pref->setItemProperty( "columns", 2, objSetGroup );
2577 // .... -> auto size first column
2578 pref->addPreference( tr( "PREF_AUTO_SIZE_FIRST" ), objSetGroup, LightApp_Preferences::Bool,
2579 "ObjectBrowser", "auto_size_first" );
2580 // .... -> auto size other columns
2581 pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool,
2582 "ObjectBrowser", "auto_size" );
2583 // .... -> resize columns on expand item
2584 pref->addPreference( tr( "PREF_RESIZE_ON_EXPAND_ITEM" ), objSetGroup, LightApp_Preferences::Bool,
2585 "ObjectBrowser", "resize_on_expand_item" );
2586 // .... -> browse to published object
2587 int browsePublished = pref->addPreference( tr( "PREF_BROWSE_TO_THE_PUBLISHED_OBJECT" ), objSetGroup, LightApp_Preferences::Selector,
2588 "ObjectBrowser", "browse_published_object" );
2589 aValuesList.clear();
2590 anIndicesList.clear();
2591 aValuesList << tr( "PREF_BROWSE_NEVER" ) << tr( "PREF_BROWSE_AFTER_APPLY_AND_CLOSE_ONLY" ) << tr( "PREF_BROWSE_ALWAYS" );
2592 anIndicesList << BP_Never << BP_ApplyAndClose << BP_Always;
2593 pref->setItemProperty( "strings", aValuesList, browsePublished );
2594 pref->setItemProperty( "indexes", anIndicesList, browsePublished );
2595 // ... "Object browser settings" group <<end>>
2596 // .. "Object browser" preferences tab <<end>>
2598 // .. "Shortcuts" preferences tab <<start>>
2599 int shortcutTab = pref->addPreference( tr( "PREF_TAB_SHORTCUTS" ), salomeCat );
2600 // ... "Shortcuts settings" group <<start>>
2601 int shortcutGroup = pref->addPreference( tr( "PREF_GROUP_SHORTCUTS" ), shortcutTab );
2602 pref->addPreference( tr( "" ), shortcutGroup,
2603 LightApp_Preferences::ShortcutTree, "shortcuts" );
2604 // ... "Shortcuts settings" group <<end>>
2605 // .. "Shortcuts" preferences tab <<end>>
2606 // . Top-level "SALOME" preferences group <<end>>
2612 Changes appearance of application according to changed preferences
2613 \param sec - section
2614 \param param - name of changed parameter
2616 void LightApp_Application::preferencesChanged( const QString& sec, const QString& param )
2618 SUIT_ResourceMgr* resMgr = resourceMgr();
2622 if ( sec == "viewers" && param == "drop_down_buttons" )
2624 ViewManagerList vmlist = viewManagers();
2625 foreach( SUIT_ViewManager* vm, vmlist )
2627 QVector<SUIT_ViewWindow*> vwlist = vm->getViews();
2628 foreach( SUIT_ViewWindow* vw, vwlist )
2629 if ( vw ) vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
2633 if ( sec == QString( "3DViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )))
2635 double sz = resMgr->doubleValue( sec, "trihedron_size", -1 );
2636 bool relative = resMgr->booleanValue( sec, "relative_size", true );
2637 QList<SUIT_ViewManager*> lst;
2638 #ifndef DISABLE_OCCVIEWER
2639 viewManagers( OCCViewer_Viewer::Type(), lst );
2640 QListIterator<SUIT_ViewManager*> itOCC( lst );
2641 while ( itOCC.hasNext() && sz >= 0 )
2643 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2644 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2647 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2648 occVM->setTrihedronSize( sz, relative );
2649 occVM->getAISContext()->UpdateCurrentViewer();
2652 #ifndef DISABLE_VTKVIEWER
2653 #ifndef DISABLE_SALOMEOBJECT
2654 viewManagers( SVTK_Viewer::Type(), lst );
2655 QListIterator<SUIT_ViewManager*> itVTK( lst );
2656 while ( itVTK.hasNext() && sz >= 0 )
2658 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2659 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2662 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2665 vtkVM->setTrihedronSize( sz, relative );
2673 if ( sec == QString( "3DViewer" ) && param == QString( "show_static_trihedron" ) )
2675 bool isVisible = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
2676 QList<SUIT_ViewManager*> lst;
2677 #ifndef DISABLE_OCCVIEWER
2678 viewManagers( OCCViewer_Viewer::Type(), lst );
2679 QListIterator<SUIT_ViewManager*> itOCC( lst );
2680 while ( itOCC.hasNext() )
2682 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2683 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2686 OCCViewer_Viewer* occVM = dynamic_cast<OCCViewer_Viewer*>( vm );
2689 occVM->setStaticTrihedronDisplayed( isVisible );
2693 #ifndef DISABLE_VTKVIEWER
2694 #ifndef DISABLE_SALOMEOBJECT
2695 viewManagers( SVTK_Viewer::Type(), lst );
2696 QListIterator<SUIT_ViewManager*> itVTK( lst );
2697 while ( itVTK.hasNext() )
2699 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2700 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2703 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2706 vtkVM->setStaticTrihedronVisible( isVisible );
2714 if ( sec == QString( "3DViewer" ) && param == QString( "navigation_mode" ) )
2716 int mode = resMgr->integerValue( "3DViewer", "navigation_mode", 0 );
2717 QList<SUIT_ViewManager*> lst;
2718 #ifndef DISABLE_OCCVIEWER
2719 viewManagers( OCCViewer_Viewer::Type(), lst );
2720 QListIterator<SUIT_ViewManager*> itOCC( lst );
2721 while ( itOCC.hasNext() )
2723 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2724 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2727 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2728 occVM->setInteractionStyle( mode );
2731 #ifndef DISABLE_VTKVIEWER
2732 #ifndef DISABLE_SALOMEOBJECT
2733 viewManagers( SVTK_Viewer::Type(), lst );
2734 QListIterator<SUIT_ViewManager*> itVTK( lst );
2735 while ( itVTK.hasNext() )
2737 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2738 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2741 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2742 if( vtkVM ) vtkVM->setInteractionStyle( mode );
2748 #ifndef DISABLE_OCCVIEWER
2749 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_preselection" ) )
2751 bool isToEnablePreselection = resMgr->booleanValue( "OCCViewer", "enable_preselection", true );
2752 QList<SUIT_ViewManager*> lst;
2753 viewManagers( OCCViewer_Viewer::Type(), lst );
2754 QListIterator<SUIT_ViewManager*> it( lst );
2755 while ( it.hasNext() )
2757 SUIT_ViewModel* vm = it.next()->getViewModel();
2758 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2761 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2762 occVM->enablePreselection( isToEnablePreselection );
2767 #ifndef DISABLE_OCCVIEWER
2768 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_selection" ) )
2770 bool isToEnableSelection = resMgr->booleanValue( "OCCViewer", "enable_selection", true );
2771 QList<SUIT_ViewManager*> lst;
2772 viewManagers( OCCViewer_Viewer::Type(), lst );
2773 QListIterator<SUIT_ViewManager*> it( lst );
2774 while ( it.hasNext() )
2776 SUIT_ViewModel* vm = it.next()->getViewModel();
2777 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2780 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2781 occVM->enableSelection( isToEnableSelection );
2786 if ( sec == QString( "3DViewer" ) && param == QString( "zooming_mode" ) )
2788 int mode = resMgr->integerValue( "3DViewer", "zooming_mode", 0 );
2789 QList<SUIT_ViewManager*> lst;
2790 #ifndef DISABLE_OCCVIEWER
2791 viewManagers( OCCViewer_Viewer::Type(), lst );
2792 QListIterator<SUIT_ViewManager*> itOCC( lst );
2793 while ( itOCC.hasNext() )
2795 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2796 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2799 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2800 occVM->setZoomingStyle( mode );
2803 #ifndef DISABLE_VTKVIEWER
2804 #ifndef DISABLE_SALOMEOBJECT
2805 viewManagers( SVTK_Viewer::Type(), lst );
2806 QListIterator<SUIT_ViewManager*> itVTK( lst );
2807 while ( itVTK.hasNext() )
2809 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2810 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2813 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2814 if( vtkVM ) vtkVM->setZoomingStyle( mode );
2820 #ifndef DISABLE_VTKVIEWER
2821 if ( sec == QString( "VTKViewer" ) && (param == QString( "speed_value" ) || param == QString( "speed_mode" )) )
2823 int speed = resMgr->integerValue( "VTKViewer", "speed_value", 10 );
2824 int mode = resMgr->integerValue( "VTKViewer", "speed_mode", 0 );
2825 QList<SUIT_ViewManager*> lst;
2826 #ifndef DISABLE_SALOMEOBJECT
2827 viewManagers( SVTK_Viewer::Type(), lst );
2828 QListIterator<SUIT_ViewManager*> it( lst );
2829 while ( it.hasNext() )
2831 SUIT_ViewModel* vm = it.next()->getViewModel();
2832 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2835 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2836 if( vtkVM ) vtkVM->setIncrementalSpeed( speed, mode );
2842 #ifndef DISABLE_VTKVIEWER
2843 if ( sec == QString( "VTKViewer" ) && param == QString( "projection_mode" ) )
2845 int mode = resMgr->integerValue( "VTKViewer", "projection_mode", 0 );
2846 QList<SUIT_ViewManager*> lst;
2847 #ifndef DISABLE_SALOMEOBJECT
2848 viewManagers( SVTK_Viewer::Type(), lst );
2849 QListIterator<SUIT_ViewManager*> it( lst );
2850 while ( it.hasNext() )
2852 SUIT_ViewModel* vm = it.next()->getViewModel();
2853 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2856 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2857 if( vtkVM ) vtkVM->setProjectionMode( mode );
2863 #ifndef DISABLE_VTKVIEWER
2864 if ( sec == QString( "VTKViewer" ) && param == QString( "preselection" ) )
2866 int mode = resMgr->integerValue( "VTKViewer", "preselection", 0 );
2867 QList<SUIT_ViewManager*> lst;
2868 #ifndef DISABLE_SALOMEOBJECT
2869 viewManagers( SVTK_Viewer::Type(), lst );
2870 QListIterator<SUIT_ViewManager*> it( lst );
2871 while ( it.hasNext() )
2873 SUIT_ViewModel* vm = it.next()->getViewModel();
2874 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2877 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2878 if( vtkVM ) vtkVM->setPreSelectionMode( mode );
2884 #ifndef DISABLE_VTKVIEWER
2885 if ( sec == QString( "VTKViewer" ) && param == QString( "enable_selection" ) )
2887 bool isToEnableSelection = resMgr->booleanValue( "VTKViewer", "enable_selection", true );
2888 QList<SUIT_ViewManager*> lst;
2889 #ifndef DISABLE_SALOMEOBJECT
2890 viewManagers( SVTK_Viewer::Type(), lst );
2891 QListIterator<SUIT_ViewManager*> it( lst );
2892 while ( it.hasNext() )
2894 SUIT_ViewModel* vm = it.next()->getViewModel();
2895 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2898 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2899 if( vtkVM ) vtkVM->enableSelection( isToEnableSelection );
2905 #ifndef DISABLE_VTKVIEWER
2906 if ( sec == QString( "VTKViewer" ) && (param == QString( "spacemouse_func1_btn" ) ||
2907 param == QString( "spacemouse_func2_btn" ) ||
2908 param == QString( "spacemouse_func5_btn" ) ) )
2910 int btn1 = resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", 1 );
2911 int btn2 = resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", 2 );
2912 int btn3 = resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", 9 );
2913 QList<SUIT_ViewManager*> lst;
2914 #ifndef DISABLE_SALOMEOBJECT
2915 viewManagers( SVTK_Viewer::Type(), lst );
2916 QListIterator<SUIT_ViewManager*> it( lst );
2917 while ( it.hasNext() )
2919 SUIT_ViewModel* vm = it.next()->getViewModel();
2920 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2923 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2924 if( vtkVM ) vtkVM->setSpacemouseButtons( btn1, btn2, btn3 );
2929 if( sec=="ObjectBrowser" )
2931 SUIT_DataBrowser* ob = objectBrowser();
2935 if ( param=="auto_size_first" )
2937 bool autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
2938 ob->setAutoSizeFirstColumn( autoSizeFirst );
2939 if ( autoSizeFirst )
2940 ob->adjustFirstColumnWidth();
2942 else if ( param=="auto_size" ) {
2943 bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
2944 ob->setAutoSizeColumns(autoSize);
2946 ob->adjustColumnsWidth();
2948 else if ( param=="resize_on_expand_item" ) {
2949 bool resizeOnExpandItem = resMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
2950 ob->setResizeOnExpandItem(resizeOnExpandItem);
2952 else if ( param == "auto_hide_search_tool" ) {
2953 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
2959 if( param=="auto_save_interval" ) {
2960 myAutoSaveTimer->stop();
2961 int autoSaveInterval = resMgr->integerValue( "Study", "auto_save_interval", 0 );
2962 if ( activeStudy() && autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
2966 #ifndef DISABLE_PYCONSOLE
2967 if( sec=="PyConsole" && pythonConsole() )
2969 if ( param=="font" ) {
2970 pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) );
2972 else if ( param=="show_banner" ) {
2973 pythonConsole()->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
2980 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
2982 if ( param == "visible_count" )
2983 mru->setVisibleCount( resMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
2984 else if ( param == "max_count" )
2985 mru->setHistoryCount( resMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
2986 else if ( param == "insert_mode" )
2987 mru->setInsertMode( resMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
2988 else if ( param == "link_type" )
2989 mru->setLinkType( resMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
2990 else if ( param == "show_clear" )
2991 mru->setClearPossible( resMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
2992 else if ( param == "show_mru" )
2993 mru->setVisible( resMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
2996 if ( sec == "language" && param == "language" )
2998 SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LANG_CHANGED" ) );
3000 if ( sec == "language" && param == "locale")
3002 SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LOCALE_CHANGED" ) );
3004 if ( sec == "desktop" && param == "opaque_resize" ) {
3005 bool opaqueResize = resMgr->booleanValue( "desktop", "opaque_resize", false );
3006 QMainWindow::DockOptions dopts = desktop()->dockOptions();
3007 if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
3008 else dopts &= ~QMainWindow::AnimatedDocks;
3009 desktop()->setDockOptions( dopts );
3010 desktop()->setOpaqueResize( opaqueResize );
3011 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
3012 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
3015 if ( sec == "ExternalBrowser" && param == "use_external_browser" ) {
3016 if ( resMgr->booleanValue("ExternalBrowser", "use_external_browser", false ) )
3018 QtxWebBrowser::shutdown();
3022 #ifndef DISABLE_PLOT2DVIEWER
3023 QList<SUIT_ViewManager*> lst;
3024 viewManagers( Plot2d_Viewer::Type(), lst );
3025 QListIterator<SUIT_ViewManager*> itPlot2d( lst );
3026 while ( itPlot2d.hasNext() ) {
3027 SUIT_ViewManager* viewMgr = itPlot2d.next();
3028 SUIT_ViewModel* vm = viewMgr->getViewModel();
3029 if ( !vm || !vm->inherits( "Plot2d_Viewer" ) )
3032 Plot2d_Viewer* Plot2dVM = dynamic_cast<Plot2d_Viewer*>( vm );
3034 viewMgr->setViewModel( vm );
3035 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
3037 Plot2d_ViewFrame* frame = wnd->getViewFrame();
3038 frame->SetPreference();
3047 void LightApp_Application::loadPreferences()
3049 CAM_Application::loadPreferences();
3051 SUIT_ResourceMgr* aResMgr = resourceMgr();
3056 static bool mru_load = true;
3059 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3061 mru->setVisible( aResMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
3062 mru->setVisibleCount( aResMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
3063 mru->setHistoryCount( aResMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
3064 mru->setInsertMode( aResMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
3065 mru->setLinkType( aResMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
3066 mru->setClearPossible( aResMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
3067 mru->loadLinks( aResMgr, "MRU" );
3073 QStringList mods = aResMgr->parameters( "windows_visibility" );
3074 for ( QStringList::const_iterator itr = mods.begin(); itr != mods.end(); ++itr )
3077 if ( aResMgr->value( "windows_visibility", *itr, arr ) )
3078 myWinVis.insert( *itr, arr );
3082 desktop()->retrieveGeometry( aResMgr->stringValue( "desktop", "geometry" ) );
3083 bool opaqueResize = aResMgr->booleanValue( "desktop", "opaque_resize", false );
3084 QMainWindow::DockOptions dopts = desktop()->dockOptions();
3085 if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
3086 else dopts &= ~QMainWindow::AnimatedDocks;
3087 desktop()->setDockOptions( dopts );
3088 desktop()->setOpaqueResize( opaqueResize );
3089 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
3090 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
3097 void LightApp_Application::savePreferences()
3099 CAM_Application::savePreferences();
3101 saveDockWindowsState();
3103 SUIT_ResourceMgr* aResMgr = resourceMgr();
3108 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3110 mru->saveLinks( aResMgr, "MRU" );
3112 for ( WinVis::const_iterator itr = myWinVis.begin(); itr != myWinVis.end(); ++itr )
3113 aResMgr->setValue( "windows_visibility", itr.key(), itr.value() );
3116 aResMgr->setValue( "desktop", "geometry", desktop()->storeGeometry() );
3122 Updates desktop title
3124 void LightApp_Application::updateDesktopTitle()
3126 QString aTitle = applicationName();
3127 QString aVer = applicationVersion();
3128 if ( !aVer.isEmpty() )
3129 aTitle += QString( " " ) + aVer;
3131 if ( activeStudy() ) {
3132 QString sName = SUIT_Tools::file( activeStudy()->studyName().trimmed(), false );
3133 aTitle += QString( " - [%1]" ).arg( sName );
3136 desktop()->setWindowTitle( aTitle );
3140 \brief Get map of the operations which can be performed
3141 on the module activation.
3143 The method should return the map of the kind \c {<id>:<name>}
3144 where \c <id> is an integer identifier of the operation and
3145 \c <name> is a title for the button to be added to the
3146 dialog box. After user selects the required operation by the
3147 clicking the corresponding button in the dialog box, its identifier
3148 is passed to the moduleActionSelected() method to process
3151 \return map of the operations
3152 \sa moduleActionSelected()
3154 QMap<int, QString> LightApp_Application::activateModuleActions() const
3156 QMap<int, QString> opmap;
3157 opmap.insert( NewStudyId, tr( "ACTIVATE_MODULE_OP_NEW" ) );
3158 opmap.insert( OpenStudyId, tr( "ACTIVATE_MODULE_OP_OPEN" ) );
3163 \brief Called when the used selectes required operation chosen
3164 from "Activate module" dialog box.
3166 Performs the required operation according to the user choice.
3168 \param id operation identifier
3169 \sa activateModuleActions()
3171 void LightApp_Application::moduleActionSelected( const int id )
3186 Updates windows after close document
3188 void LightApp_Application::afterCloseDoc()
3192 CAM_Application::afterCloseDoc();
3196 Updates actions of active module
3198 void LightApp_Application::updateModuleActions()
3201 if ( activeModule() ) {
3202 modName = activeModule()->moduleName();
3203 if ( !isModuleAccessible( modName ) ) {
3204 QList<SUIT_Application*> apps = SUIT_Session::session()->applications();
3205 foreach( SUIT_Application* app, apps ) {
3206 LightApp_Application* lapp = dynamic_cast<LightApp_Application*>( app );
3207 if ( lapp && lapp != this )
3208 lapp->removeModuleAction( modName );
3213 LightApp_ModuleAction* moduleAction =
3214 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
3216 moduleAction->setActiveModule( modName );
3219 void LightApp_Application::removeModuleAction( const QString& modName )
3221 LightApp_ModuleAction* moduleAction =
3222 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
3224 moduleAction->removeModule( modName );
3228 Gets current windows.
3229 \param winMap - output current windows map.
3231 void LightApp_Application::currentWindows( QMap<int, int>& winMap ) const
3234 if ( !activeStudy() )
3237 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
3238 ((LightApp_Module*)activeModule())->windows( winMap );
3240 defaultWindows( winMap );
3244 Gets current view managers.
3245 \param lst - output current view managers list.
3247 void LightApp_Application::currentViewManagers( QStringList& lst ) const
3250 if ( !activeStudy() )
3253 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
3254 ((LightApp_Module*)activeModule())->viewManagers( lst );
3256 defaultViewManagers( lst );
3262 void LightApp_Application::updateWindows()
3264 QMap<int, int> winMap;
3265 currentWindows( winMap );
3267 if ( activeStudy() )
3269 for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
3271 if ( !dockWindow( it.key() ) )
3272 getWindow( it.key() );
3276 for ( WinMap::ConstIterator it = myWin.begin(); it != myWin.end(); ++it )
3278 QWidget* wid = it.value();
3279 if ( activeStudy() )
3280 wid->setVisible( winMap.contains( it.key() ) );
3285 if ( activeStudy() )
3286 loadDockWindowsState();
3292 Updates view managers
3294 void LightApp_Application::updateViewManagers()
3297 currentViewManagers( lst );
3299 for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
3300 getViewManager( *it, true );
3304 Loads windows geometry
3306 void LightApp_Application::loadDockWindowsState()
3310 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
3311 bool storeWin = aResMgr->booleanValue( "Study", "store_positions", true );
3312 bool storeTb = aResMgr->booleanValue( "Study", "store_tool_positions", true );
3315 if ( activeModule() )
3316 modName = activeModule()->name();
3318 QtxResourceMgr::WorkingMode prevMode = aResMgr->workingMode();
3319 aResMgr->setWorkingMode(QtxResourceMgr::IgnoreUserValues);
3320 QByteArray aDefaultState;
3321 aResMgr->value("windows_geometry", modName , aDefaultState );
3322 QByteArray aDefaultVisibility;
3323 aResMgr->value("windows_visibility", modName , aDefaultVisibility );
3324 bool hasDefaultVisibility = !aDefaultVisibility.isEmpty();
3325 aResMgr->setWorkingMode(prevMode);
3327 if( !storeWin && !storeTb && aDefaultState.isEmpty() && !hasDefaultVisibility)
3330 if ( aResMgr->hasValue("windows_geometry" ,modName ) ) {
3332 aResMgr->value("windows_geometry", modName , arr );
3333 QByteArray aTargetArray = processState(arr, storeWin, storeTb, true, aDefaultState);
3334 desktop()->restoreState( aTargetArray );
3338 if ( !myWinVis.contains( modName ) && aDefaultVisibility.isEmpty())
3341 QMap<QString, bool> *tbMap = 0;
3342 QMap<QString, bool> *dwMap = 0;
3344 QMap<QString, bool> userTbMap, userDwMap;
3345 dockWindowsState( myWinVis[modName], userTbMap, userDwMap );
3347 QMap<QString, bool> defaultTbMap, defaultDwMap;
3348 if(hasDefaultVisibility) {
3349 dockWindowsState( aDefaultVisibility, defaultTbMap, defaultDwMap);
3355 if(hasDefaultVisibility){
3356 tbMap = &defaultTbMap;
3363 if(hasDefaultVisibility){
3364 dwMap = &defaultDwMap;
3369 QList<QToolBar*> tbList = findToolBars();
3370 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit )
3372 QToolBar* tb = *tit;
3373 if ( tbMap->contains( tb->objectName() ) ) {
3374 tb->setVisible( (*tbMap)[tb->objectName()] );
3380 QList<QDockWidget*> dwList = qFindChildren<QDockWidget*>( desktop() );
3381 for ( QList<QDockWidget*>::iterator dit = dwList.begin(); dit != dwList.end(); ++dit )
3383 QDockWidget* dw = *dit;
3385 QObject* po = Qtx::findParent( dw, "QMainWindow" );
3386 if ( po != desktop() )
3389 if ( dwMap->contains( dw->objectName() ) )
3390 dw->setVisible( (*dwMap)[dw->objectName()] );
3398 Saves windows geometry
3400 void LightApp_Application::saveDockWindowsState()
3405 bool storeWin = resourceMgr()->booleanValue( "Study", "store_positions", true );
3406 bool storeTb = resourceMgr()->booleanValue( "Study", "store_tool_positions", true );
3408 if( !storeWin && !storeTb )
3412 if ( activeModule() )
3413 modName = activeModule()->name();
3415 QByteArray arr = desktop()->saveState();
3416 resourceMgr()->setValue( "windows_geometry", modName, processState(arr, storeWin, storeTb, false) );
3419 if ( myWinVis.contains( modName ) )
3420 visArr = myWinVis[modName];
3422 QMap<QString, bool> tbMap, dwMap;
3423 dockWindowsState( visArr, tbMap, dwMap );
3425 QList<QToolBar*> tbList = qFindChildren<QToolBar*>( desktop() );
3426 for ( QList<QToolBar*>::iterator it = tbList.begin(); it != tbList.end(); ++it )
3429 tbMap.insert( tb->objectName(), tb->toggleViewAction()->isChecked() );
3432 QList<QDockWidget*> dwList = qFindChildren<QDockWidget*>( desktop() );
3433 for ( QList<QDockWidget*>::iterator it = dwList.begin(); it != dwList.end(); ++it )
3435 QDockWidget* wid = *it;
3436 dwMap.insert( wid->objectName(), wid->toggleViewAction()->isChecked() );
3439 visArr = dockWindowsState( tbMap, dwMap );
3441 myWinVis.insert( modName, visArr );
3444 QByteArray LightApp_Application::dockWindowsState( const QMap<QString, bool>& tb, const QMap<QString, bool>& dw ) const
3447 QDataStream stream( &visArr, QIODevice::WriteOnly );
3449 stream << (uchar)ToolBarMarker;
3450 stream << tb.size();
3451 for ( QMap<QString, bool>::const_iterator tit = tb.begin(); tit != tb.end(); ++tit )
3453 stream << tit.key();
3454 stream << (uchar)( tit.value() ? 1 : 0 );
3457 stream << (uchar)DockWidgetMarker;
3458 stream << dw.size();
3459 for ( QMap<QString, bool>::const_iterator wit = dw.begin(); wit != dw.end(); ++wit )
3461 stream << wit.key();
3462 stream << (uchar)( wit.value() ? 1 : 0 );
3468 void LightApp_Application::dockWindowsState( const QByteArray& arr, QMap<QString, bool>& tb, QMap<QString, bool>& dw ) const
3473 QByteArray visArr = arr;
3474 QDataStream stream( &visArr, QIODevice::ReadOnly );
3478 if ( marker != ToolBarMarker )
3483 for ( int i = 0; i < lines; ++i )
3486 stream >> objectName;
3489 tb.insert( objectName, shown );
3493 if ( marker != DockWidgetMarker )
3497 for ( int j = 0; j < lines; ++j )
3500 stream >> objectName;
3503 dw.insert( objectName, shown );
3508 Adds icon names for modules
3510 void LightApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) const
3514 SUIT_ResourceMgr* resMgr = resourceMgr();
3518 QStringList modList;
3519 modules( modList, false );
3521 for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )
3523 QString modName = *it;
3524 QString modIntr = moduleName( modName );
3525 QString modIcon = resMgr->stringValue( modIntr, "icon", QString() );
3527 if ( modIcon.isEmpty() )
3530 if ( SUIT_Tools::extension( modIcon ).isEmpty() )
3531 modIcon += QString( ".png" );
3533 iconMap.insert( modName, modIcon );
3538 Inserts items in popup, which necessary for current application
3540 void LightApp_Application::contextMenuPopup( const QString& type, QMenu* thePopup, QString& title )
3543 LightApp_SelectionMgr* selMgr = LightApp_Application::selectionMgr();
3544 bool cacheIsOn = selMgr->isSelectionCacheEnabled();
3545 selMgr->setSelectionCacheEnabled( true );
3547 SUIT_DataBrowser* ob = objectBrowser();
3549 CAM_Application::contextMenuPopup( type, thePopup, title );
3551 if ( ob && type == ob->popupClientType() ) {
3552 thePopup->addSeparator();
3553 QAction* a = thePopup->addAction( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
3554 if ( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) )
3555 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) );
3558 #ifndef DISABLE_SALOMEOBJECT
3559 if ( selMgr && ob ) {
3560 SALOME_ListIO selected;
3561 selMgr->selectedObjects( selected );
3562 if(selected.Extent() == 1){
3563 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3564 SUIT_DataObject* obj = findObject(anIObject->getEntry());
3565 if(obj && obj->renameAllowed()) {
3566 QAction* a = new QAction(tr("MEN_RENAME_OBJ"), thePopup);
3567 connect( a, SIGNAL( triggered(bool) ), ob, SLOT( onStartEditing() ) );
3568 if ( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) )
3569 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) );
3571 QList<QAction*> acts = thePopup->actions();
3572 QAction* firstAction = acts.count() > 0 ? acts.first() : 0;
3573 thePopup->insertAction(firstAction,a);
3579 selMgr->setSelectionCacheEnabled( cacheIsOn );
3585 void LightApp_Application::createEmptyStudy()
3587 CAM_Application::createEmptyStudy();
3589 if ( objectBrowser() )
3590 objectBrowser()->updateTree();
3592 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
3593 if ( aResMgr && activeStudy() ) {
3594 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
3595 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
3600 void LightApp_Application::setDesktop( SUIT_Desktop* desk )
3602 CAM_Application::setDesktop( desk );
3605 connect( desk, SIGNAL( message( const QString& ) ),
3606 this, SLOT( onDesktopMessage( const QString& ) ), Qt::UniqueConnection );
3607 connect( desk, SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
3608 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
3614 \param mod - module to be activated
3616 bool LightApp_Application::activateModule( CAM_Module* mod )
3618 bool res = CAM_Application::activateModule( mod );
3620 if ( objectBrowser() )
3621 objectBrowser()->updateTree();
3627 \return keyborad accelerators manager object
3629 SUIT_Accel* LightApp_Application::accel() const
3635 Removes dead widget container from map
3637 void LightApp_Application::onWCDestroyed( QObject* ob )
3639 // remove destroyed widget container from windows map
3640 for ( WinMap::ConstIterator itr = myWin.begin(); itr != myWin.end(); ++itr )
3642 if ( itr.value() != ob )
3645 int key = itr.key();
3646 myWin.remove( key );
3651 void LightApp_Application::onMRUActivated( const QString& name )
3653 SUIT_Session* s = SUIT_Session::session();
3654 if ( s && s->activeApplication() == this )
3658 void LightApp_Application::onStylePreferences()
3660 Style_PrefDlg dlg( desktop() );
3663 resourceMgr()->setValue( "Style", "use_salome_style", Style_Salome::isActive() );
3666 void LightApp_Application::onFullScreen(){
3667 if(myScreenHelper) {
3668 if(desktop()->isFullScreen())
3669 myScreenHelper->switchToNormalScreen();
3671 myScreenHelper->switchToFullScreen();
3676 Connects just added view manager
3678 void LightApp_Application::addViewManager( SUIT_ViewManager* vm )
3680 connect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
3681 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
3682 CAM_Application::addViewManager( vm );
3686 Remove view manager from memory
3688 void LightApp_Application::removeViewManager( SUIT_ViewManager* vm )
3690 disconnect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
3691 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
3692 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
3694 aStudy->removeViewMgr(vm->getGlobalId());
3696 CAM_Application::removeViewManager( vm );
3698 LightApp_SelectionMgr* selMgr = selectionMgr();
3699 QList<SUIT_Selector*> selectors;
3700 selMgr->selectors( selectors );
3701 foreach( SUIT_Selector* selector, selectors ) {
3702 if ( selector->owner() == vm->getViewModel() ) {
3707 // IPAL22894: Crash on closing OCC view
3713 Renames active window of desktop
3715 void LightApp_Application::onRenameWindow()
3720 QWidget* w = desktop()->activeWindow();
3725 QString name = QInputDialog::getText( w, tr( "TOT_RENAME" ), tr( "PRP_RENAME" ), QLineEdit::Normal, w->windowTitle(), &ok );
3726 if( ok && !name.isEmpty() )
3727 w->setWindowTitle( name );
3731 Closes active window of desktop
3733 void LightApp_Application::onCloseWindow()
3738 QWidget* w = desktop()->activeWindow();
3746 Closes all windows of desktop
3748 void LightApp_Application::onCloseAllWindow()
3750 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
3754 QList<SUIT_ViewWindow*> wndList = desk->windows();
3755 SUIT_ViewWindow* wnd;
3756 foreach( wnd, wndList )
3764 Groups all windows of desktop
3766 void LightApp_Application::onGroupAllWindow()
3768 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
3772 QtxWorkstack* wgStack = desk->workstack();
3778 \return if the library of module exists
3779 \param moduleTitle - title of module
3781 bool LightApp_Application::isLibExists( const QString& moduleTitle ) const
3783 if( moduleTitle.isEmpty() )
3786 QString lib = moduleLibrary( moduleTitle );
3788 //abd: changed libSalomePyQtGUI to SalomePyQtGUI for WIN32
3789 bool isPythonModule = lib.contains("SalomePyQtGUI");
3790 bool isPythonLightModule = lib.contains("SalomePyQtGUILight");
3794 paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
3796 paths = QString(::getenv( "LD_LIBRARY_PATH" )).split( ":", QString::SkipEmptyParts );
3799 bool isLibFound = false;
3800 QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
3801 for( ; anIt!=aLast; anIt++ )
3803 QFileInfo inf( Qtx::addSlash( *anIt ) + lib );
3814 INFOS( "\n****************************************************************" << std::endl
3815 << "* Warning: library " << lib.toLatin1().constData() << " cannot be found" << std::endl
3816 << "* Module " << moduleTitle.toLatin1().constData() << " will not be available in GUI mode" << std::endl
3817 << "****************************************************************" << std::endl );
3819 else if ( !isPythonModule && !isPythonLightModule)
3822 if ( isPythonModule || isPythonLightModule)
3824 QString pylib = moduleName( moduleTitle ) + QString(".py");
3825 QString pylibgui = moduleName( moduleTitle ) + QString("GUI.py");
3827 // Check the python library
3829 // paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
3831 paths = QString(::getenv( "PYTHONPATH" )).split( ":", QString::SkipEmptyParts );
3833 bool isPyLib = false, isPyGuiLib = false;
3834 QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
3835 for( ; anIt!=aLast; anIt++ )
3837 QFileInfo inf( Qtx::addSlash( *anIt ) + pylib );
3838 QFileInfo infgui( Qtx::addSlash( *anIt ) + pylibgui );
3840 if(!isPythonLightModule)
3841 if( !isPyLib && inf.exists() )
3844 if( !isPyGuiLib && infgui.exists() )
3847 if ((isPyLib || isPythonLightModule ) && isPyGuiLib && isLibFound)
3851 printf( "\n****************************************************************\n" );
3852 printf( "* Warning: python library for %s cannot be found:\n", moduleTitle.toLatin1().constData() );
3854 printf( "* No module named %s\n", moduleName( moduleTitle ).toLatin1().constData() );
3856 printf( "* No module named %s\n", (moduleName( moduleTitle ) + QString("GUI")).toLatin1().constData() );
3857 printf( "****************************************************************\n" );
3864 \return default name for an active study
3866 void LightApp_Application::setDefaultStudyName( const QString& theName )
3868 QStringList anInfoList;
3869 modules( anInfoList, false );
3871 LightApp_Study* aStudy = (LightApp_Study*)activeStudy();
3872 if( anInfoList.count() == 1 && // to avoid a conflict between different modules
3873 !aStudy->isSaved() )
3875 aStudy->setStudyName( theName );
3876 updateDesktopTitle();
3881 Custom event handler
3883 bool LightApp_Application::event( QEvent* e )
3885 if( e && e->type()==2000 )
3887 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
3888 QString* d = ( QString* )ce->data();
3889 if( SUIT_MessageBox::question(0, tr("WRN_WARNING"),
3891 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
3892 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
3893 showPreferences( tr( "PREF_APP" ) );
3898 return CAM_Application::event( e );
3901 /*! Check data object */
3902 bool LightApp_Application::checkDataObject(LightApp_DataObject* theObj)
3906 bool isSuitable = !theObj->entry().isEmpty() &&
3907 !theObj->componentDataType().isEmpty() &&
3908 !theObj->name().isEmpty();
3915 int LightApp_Application::openChoice( const QString& aName )
3917 int choice = CAM_Application::openChoice( aName );
3919 if ( choice == OpenExist ) // The document is already open.
3921 // Do you want to reload it?
3922 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "QUE_DOC_ALREADYOPEN" ).arg( aName ),
3923 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No ) == SUIT_MessageBox::Yes )
3924 choice = OpenReload;
3930 bool LightApp_Application::openAction( const int choice, const QString& aName )
3937 STD_Application* app = 0;
3938 SUIT_Session* session = SUIT_Session::session();
3939 QList<SUIT_Application*> appList = session->applications();
3940 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !app; ++it )
3942 if ( (*it)->activeStudy() && (*it)->activeStudy()->studyName() == aName )
3943 app = ::qobject_cast<STD_Application*>( *it );
3948 app->onCloseDoc( false );
3949 appList = session->applications();
3950 STD_Application* other = 0;
3951 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !other; ++it )
3952 other = ::qobject_cast<STD_Application*>( *it );
3955 res = other->onOpenDoc( aName );
3960 res = CAM_Application::openAction( choice, aName );
3967 QStringList LightApp_Application::viewManagersTypes() const
3969 QStringList aTypesList;
3970 aTypesList += myUserWmTypes;
3971 #ifndef DISABLE_GLVIEWER
3972 aTypesList<<GLViewer_Viewer::Type();
3974 #ifndef DISABLE_PLOT2DVIEWER
3975 aTypesList<<Plot2d_Viewer::Type();
3977 #ifndef DISABLE_QXGRAPHVIEWER
3978 aTypesList<<QxScene_Viewer::Type();
3980 #ifndef DISABLE_OCCVIEWER
3981 aTypesList<<OCCViewer_Viewer::Type();
3983 #ifndef DISABLE_VTKVIEWER
3984 #ifndef DISABLE_SALOMEOBJECT
3985 aTypesList<<SVTK_Viewer::Type();
3987 aTypesList<<VTKViewer_Viewer::Type();
3993 * Removes all view managers of known types
3994 * Other view managers are ignored
3996 void LightApp_Application::clearKnownViewManagers()
3998 QStringList aTypesList = viewManagersTypes();
3999 QList<SUIT_ViewManager*> aMgrList;
4000 viewManagers( aMgrList );
4001 foreach (SUIT_ViewManager* aMgr, aMgrList) {
4002 if (aTypesList.contains(aMgr->getType()))
4003 removeViewManager(aMgr);
4008 Copy of current selection
4010 void LightApp_Application::onCopy()
4012 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
4018 Paste of current data in clipboard
4020 void LightApp_Application::onPaste()
4022 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
4028 Browse (i.e. set focus on) the published objects
4029 \param theIsApplyAndClose - flag indicating that the dialog for creating objects
4030 has been accepted by Ok (or Apply & Close) button
4031 \param theIsOptimizedBrowsing - flag switching to optimized browsing mode
4032 (to select the first published object only)
4033 \return entry of the selected object
4035 QString LightApp_Application::browseObjects( const QStringList& theEntryList,
4036 const bool theIsApplyAndClose,
4037 const bool theIsOptimizedBrowsing )
4040 if( SUIT_ResourceMgr* aResourceMgr = resourceMgr() )
4042 int aBrowsePolicy = aResourceMgr->integerValue( "ObjectBrowser", "browse_published_object", (int)BP_Never );
4043 switch( aBrowsePolicy )
4047 case BP_ApplyAndClose:
4048 if( !theIsApplyAndClose )
4056 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
4060 SUIT_DataBrowser* anOB = objectBrowser();
4064 SUIT_AbstractModel* aModel = dynamic_cast<SUIT_AbstractModel*>( anOB->model() );
4068 QStringListIterator anIter( theEntryList );
4069 if( theIsOptimizedBrowsing )
4071 // go to the last entry
4073 if( anIter.hasPrevious() )
4077 // scroll to each entry in the list
4078 // (in optimized mode - to the last entry only)
4080 LightApp_DataObject* anObject = 0;
4081 while( anIter.hasNext() )
4083 anEntry = anIter.next();
4084 if( !anEntry.isEmpty() )
4086 anObject = aStudy->findObjectByEntry( anEntry );
4089 QModelIndex anIndex = aModel->index( anObject );
4090 anOB->treeView()->scrollTo( anIndex );
4095 // always select the last object
4096 if( anObject && !anEntry.isEmpty() )
4098 QList<SUIT_Selector*> aSelectorList;
4099 selectionMgr()->selectors( "ObjectBrowser", aSelectorList );
4100 if( !aSelectorList.isEmpty() )
4102 if( LightApp_OBSelector* aSelector = dynamic_cast<LightApp_OBSelector*>( aSelectorList.first() ) )
4104 bool anIsAutoBlock = aSelector->autoBlock();
4106 // temporarily disable auto block, to emit LightApp_SelectionMgr::currentSelectionChanged() signal
4107 aSelector->setAutoBlock( false );
4109 SUIT_DataOwnerPtrList aList;
4110 #ifndef DISABLE_SALOMEOBJECT
4111 Handle(SALOME_InteractiveObject) aSObj = new SALOME_InteractiveObject
4112 ( anObject->entry().toLatin1().constData(),
4113 anObject->componentDataType().toLatin1().constData(),
4114 anObject->name().toLatin1().constData() );
4115 LightApp_DataOwner* owner = new LightApp_DataOwner( aSObj );
4117 LightApp_DataOwner* owner = new LightApp_DataOwner( anEntry );
4120 aList.append( owner );
4121 selectionMgr()->setSelected( aList );
4124 // restore auto block flag
4125 aSelector->setAutoBlock( anIsAutoBlock );
4133 SUIT_DataObject* LightApp_Application::findObject( const QString& id ) const
4135 LightApp_Study* study = dynamic_cast<LightApp_Study*>( activeStudy() );
4136 return study ? study->findObjectByEntry( id ) : 0;
4140 Checks that an object can be renamed.
4141 \param entry entry of the object
4142 \brief Return \c true if object can be renamed
4144 bool LightApp_Application::renameAllowed( const QString& /*entry*/) const {
4149 Rename object by entry.
4150 \param entry entry of the object
4151 \param name new name of the object
4152 \brief Return \c true if rename operation finished successfully, \c false otherwise.
4154 bool LightApp_Application::renameObject( const QString& entry, const QString& ) {
4158 /*! Process standard messages from desktop */
4159 void LightApp_Application::onDesktopMessage( const QString& message )
4161 const QString sectionSeparator = "/";
4163 if ( message.toLower() == "updateobjectbrowser" ||
4164 message.toLower() == "updateobjbrowser" ) {
4165 // update object browser
4166 updateObjectBrowser();
4169 QStringList data = message.split( sectionSeparator );
4170 if ( data.count() > 1 ) {
4171 QString msgType = data[0].trimmed();
4172 LightApp_Module* sMod = 0;
4173 CAM_Module* mod = module( msgType );
4175 mod = module( moduleTitle( msgType ) );
4176 if ( mod && mod->inherits( "LightApp_Module" ) )
4177 sMod = (LightApp_Module*)mod;
4179 if ( msgType.toLower() == "preferences" ) {
4180 // requested preferences change: should be given as "preferences/<section>/<name>/<value>"
4181 // for example "preferences/Study/multi_file_dump/true"
4182 if ( data.count() > 3 ) {
4183 QString section = data[1].trimmed();
4184 QString param = data[2].trimmed();
4185 QString value = QStringList( data.mid(3) ).join( sectionSeparator );
4186 resourceMgr()->setValue( section, param, value );
4190 // received message for the module
4191 QString msg = QStringList( data.mid(1) ).join( sectionSeparator );
4192 sMod->message( msg );
4200 Returns all top level toolbars.
4201 Note : Result list contains only main window toolbars, not including toolbars from viewers.
4203 QList<QToolBar*> LightApp_Application::findToolBars() {
4204 QList<QToolBar*> aResult;
4205 QList<QToolBar*> tbList = qFindChildren<QToolBar*>( desktop() );
4206 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit ) {
4207 QToolBar* tb = *tit;
4208 QObject* po = Qtx::findParent( tb, "QMainWindow" );
4209 if ( po != desktop() )
4217 Internal method to parse toolbars and dockable windows state.
4219 QByteArray LightApp_Application::processState(QByteArray& input,
4220 const bool processWin,
4221 const bool processTb,
4222 const bool isRestoring,
4223 QByteArray defaultState) {
4226 bool hasDefaultState = !defaultState.isEmpty();
4227 bool isDockWinWriten = false;
4229 //Write date from users settings
4231 QDataStream tmpInputData(&input, QIODevice::ReadOnly);
4232 int marker, version;
4234 tmpInputData >> marker;
4235 tmpInputData >> version;
4236 tmpInputData >> dockmarker;
4237 tmpInputData >> nbDocWin;
4239 if(processWin && processTb && !isRestoring) {
4241 } else if(!processWin && !processTb ) {
4243 aRes = defaultState;
4245 QDataStream aData(&aRes, QIODevice::WriteOnly);
4246 QList<QToolBar*> aToolBars = findToolBars();
4249 for ( QList<QToolBar*>::iterator tit = aToolBars.begin(); tit != aToolBars.end(); ++tit ) {
4250 QToolBar* tb = *tit;
4251 aNames.append(tb->objectName());
4254 int toolBarMarkerIndex = getToolbarMarkerIndex(input,aNames);
4255 QDataStream anInputData(&input, QIODevice::ReadOnly);
4256 if(toolBarMarkerIndex < 0)
4259 int toolBarMarkerIndexDef;
4260 if(hasDefaultState) {
4261 toolBarMarkerIndexDef = getToolbarMarkerIndex(defaultState, aNames);
4262 if(toolBarMarkerIndexDef < 0)
4265 QDataStream anInputDataDef(&defaultState, QIODevice::ReadOnly);
4267 QDataStream* aTargetData = 0;
4268 int aTargetIndex = -1;
4270 QByteArray currentArr = desktop()->saveState();
4271 QDataStream anInputDataCur(¤tArr, QIODevice::ReadOnly);
4272 bool useInputData = !isRestoring || (isRestoring && nbDocWin > 0);
4273 if(processWin && useInputData) {
4274 aTargetData = &anInputData;
4275 aTargetIndex = toolBarMarkerIndex;
4277 //Write date from default settings
4278 if(hasDefaultState) {
4279 aTargetData = &anInputDataDef;
4280 aTargetIndex = toolBarMarkerIndexDef;
4282 //If no default state, write current snapshot of the dockable windows
4284 aTargetData = &anInputDataCur;
4285 int toolBarMarkerIndexCur = getToolbarMarkerIndex(currentArr, aNames);
4286 aTargetIndex = toolBarMarkerIndexCur;
4291 if(aTargetData && aTargetIndex >= 0 ) {
4292 aTargetData->device()->seek(0);
4293 while( aTargetData->device()->pos() < aTargetIndex ) {
4298 isDockWinWriten = true;
4305 aTargetData = &anInputData;
4306 aTargetIndex = toolBarMarkerIndex;
4308 if(hasDefaultState) {
4309 aTargetData = &anInputDataDef;
4310 aTargetIndex = toolBarMarkerIndexDef;
4314 if(aTargetData && aTargetIndex >= 0) {
4316 if(!isDockWinWriten ) {
4317 //Write version marker
4318 int marker, version;
4319 aTargetData->device()->seek(0);
4320 *aTargetData >> marker;
4321 *aTargetData >> version;
4324 aData << (uchar) QDockWidgetMarker;
4326 int shift = 4*sizeof(int) + sizeof(QSize);
4327 index = aTargetIndex - shift;
4329 index = aTargetIndex;
4332 aTargetData->device()->seek(index);
4333 while(!aTargetData->atEnd()) {
4338 } else { // Not treat toolbars
4339 aData << (uchar) QToolBarMarker;
4340 aData << (int) 0; //Nb toolbars = 0
4347 \brief Emits operationFinished signal.
4348 \param theModuleName the name of the module which perfomed the operation
4349 \param theOperationName the operation name
4350 \param theEntryList the list of the created objects entries
4352 void LightApp_Application::emitOperationFinished( const QString& theModuleName,
4353 const QString& theOperationName,
4354 const QStringList& theEntryList )
4356 emit operationFinished( theModuleName, theOperationName, theEntryList );
4360 Update visibility state of given objects
4362 void LightApp_Application::updateVisibilityState( DataObjectList& theList,
4363 SUIT_ViewModel* theViewModel )
4365 if ( !theViewModel || theList.isEmpty() ) return;
4367 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
4368 if ( !aStudy ) return;
4370 SALOME_View* aView = dynamic_cast<SALOME_View*>( theViewModel );
4372 for ( DataObjectList::iterator itr = theList.begin(); itr != theList.end(); ++itr ) {
4373 LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>(*itr);
4375 if ( !obj || aStudy->isComponent( obj->entry() ) )
4378 LightApp_Module* anObjModule = dynamic_cast<LightApp_Module*>(obj->module());
4379 if ( anObjModule ) {
4380 LightApp_Displayer* aDisplayer = anObjModule->displayer();
4382 Qtx::VisibilityState anObjState = Qtx::UnpresentableState;
4383 if ( aDisplayer->canBeDisplayed( obj->entry(), theViewModel->getType() ) ) {
4384 if ( aView && aDisplayer->IsDisplayed( obj->entry(), aView ) )
4385 anObjState = Qtx::ShownState;
4387 anObjState = Qtx::HiddenState;
4389 aStudy->setVisibilityState( obj->entry(), anObjState );
4396 * Called when window activated
4398 void LightApp_Application::onWindowActivated( SUIT_ViewWindow* theViewWindow )
4400 SUIT_DataBrowser* anOB = objectBrowser();
4403 SUIT_DataObject* rootObj = anOB->root();
4407 DataObjectList listObj = rootObj->children( true );
4409 SUIT_ViewModel* vmod = 0;
4410 if ( SUIT_ViewManager* vman = theViewWindow->getViewManager() )
4411 vmod = vman->getViewModel();
4412 updateVisibilityState( listObj, vmod );
4416 Called then view manager removed
4418 void LightApp_Application::onViewManagerRemoved( SUIT_ViewManager* )
4420 ViewManagerList lst;
4421 viewManagers( lst );
4422 if ( lst.count() == 1) { // in case if closed last view window
4423 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
4425 aStudy->setVisibilityStateForAll( Qtx::UnpresentableState );