1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File: LightApp_Application.cxx
24 // Created: 6/20/2005 18:39:45 PM
25 // Author: Natalia Donis
28 // E.A. : On windows with python 2.6, there is a conflict
29 // E.A. : between pymath.h and Standard_math.h which define
30 // E.A. : some same symbols : acosh, asinh, ...
31 #include <Standard_math.hxx>
32 #ifndef DISABLE_PYCONSOLE
37 #ifndef DISABLE_PYCONSOLE
38 #include "LightApp_PyInterp.h" // WARNING! This include must be the first!
39 #include <PyConsole_Console.h>
42 #include "LightApp_Application.h"
43 #include "LightApp_Module.h"
44 #include "LightApp_DataModel.h"
45 #include "LightApp_Study.h"
46 #include "LightApp_Preferences.h"
47 #include "LightApp_PreferencesDlg.h"
48 #include "LightApp_ModuleDlg.h"
49 #include "LightApp_AboutDlg.h"
50 #include "LightApp_ModuleAction.h"
51 // temporary commented
52 //#include "LightApp_OBFilter.h"
53 #include "LightApp_EventFilter.h"
54 #include "LightApp_OBSelector.h"
55 #include "LightApp_SelectionMgr.h"
56 #include "LightApp_DataObject.h"
57 #include "LightApp_WgViewModel.h"
58 #include "LightApp_FullScreenHelper.h"
61 #include <GUI_version.h>
62 #include <Basics_OCCTVersion.hxx>
64 #include <SALOME_Event.h>
66 #include <Style_Salome.h>
67 #include <Style_PrefDlg.h>
69 #include <CAM_Module.h>
70 #include <CAM_DataModel.h>
71 #include <CAM_Study.h>
72 #include <STD_TabDesktop.h>
74 #include <SUIT_DataBrowser.h>
75 #include <SUIT_Session.h>
76 #include <SUIT_Study.h>
77 #include <SUIT_FileDlg.h>
78 #include <SUIT_ResourceMgr.h>
79 #include <SUIT_ShortcutMgr.h>
80 #include <SUIT_Tools.h>
81 #include <SUIT_Accel.h>
82 #include <SUIT_MessageBox.h>
83 #include <SUIT_ViewWindow.h>
86 #include <QtxToolBar.h>
87 #include <QtxTreeView.h>
88 #include <QtxMRUAction.h>
89 #include <QtxDockAction.h>
90 #include <QtxDockWidget.h>
91 #include <QtxActionToolMgr.h>
92 #include <QtxSearchTool.h>
93 #include <QtxWorkstack.h>
95 #include <QtxWebBrowser.h>
97 #include <LogWindow.h>
99 #ifndef DISABLE_GLVIEWER
100 #include <GLViewer_Viewer.h>
101 #include <GLViewer_ViewManager.h>
102 #include "LightApp_GLSelector.h"
105 #ifndef DISABLE_PLOT2DVIEWER
106 #include <Plot2d_ViewManager.h>
107 #include <Plot2d_ViewModel.h>
108 #include <Plot2d_ViewWindow.h>
109 #include <Plot2d_ViewFrame.h>
110 #include "LightApp_Plot2dSelector.h"
111 #ifndef DISABLE_SALOMEOBJECT
112 #include <SPlot2d_ViewModel.h>
114 #include <Plot2d_ViewModel.h>
118 #ifndef DISABLE_OCCVIEWER
119 #include <OCCViewer_ViewManager.h>
120 #include <OCCViewer_ViewFrame.h>
121 #ifndef DISABLE_SALOMEOBJECT
122 #include <SOCC_ViewModel.h>
124 #include <OCCViewer_ViewModel.h>
126 #include "LightApp_OCCSelector.h"
129 #ifndef DISABLE_VTKVIEWER
130 #ifndef DISABLE_SALOMEOBJECT
131 #include <SVTK_ViewModel.h>
132 #include <SVTK_ViewManager.h>
133 #include "LightApp_VTKSelector.h"
135 #include <VTKViewer_ViewModel.h>
136 #include <VTKViewer_ViewManager.h>
138 #include <VTKViewer_ViewModel.h>
141 //#ifndef DISABLE_SUPERVGRAPHVIEWER
142 // #include <SUPERVGraph_ViewModel.h>
143 // #include <SUPERVGraph_ViewFrame.h>
144 // #include <SUPERVGraph_ViewManager.h>
147 #ifndef DISABLE_QXGRAPHVIEWER
148 //VSR: QxGraph has been replaced by QxScene
149 // #include <QxGraph_ViewModel.h>
150 // #include <QxGraph_ViewWindow.h>
151 // #include <QxGraph_ViewManager.h>
152 #include <QxScene_ViewManager.h>
153 #include <QxScene_ViewModel.h>
154 #include <QxScene_ViewWindow.h>
158 #define VISIBILITY_COLUMN_WIDTH 25
164 #include <QStringList>
166 #include <QApplication>
168 #include <QStatusBar>
170 #include <QObjectList>
172 #include <QInputDialog>
173 #include <QFontDatabase>
175 #include <QByteArray>
179 #include <QHeaderView>
184 #include <utilities.h>
186 #define FIRST_HELP_ID 1000000
188 #ifndef DISABLE_SALOMEOBJECT
189 #include <SALOME_InteractiveObject.hxx>
190 #include <SALOME_ListIO.hxx>
193 #include <Standard_Version.hxx>
195 #define ToolBarMarker 0
196 #define DockWidgetMarker 1
198 static const char* imageEmptyIcon[] = {
201 "....................",
202 "....................",
203 "....................",
204 "....................",
205 "....................",
206 "....................",
207 "....................",
208 "....................",
209 "....................",
210 "....................",
211 "....................",
212 "....................",
213 "....................",
214 "....................",
215 "....................",
216 "....................",
217 "....................",
218 "....................",
219 "....................",
220 "...................."};
222 int LightApp_Application::lastStudyId = 0;
225 \return last global id of study
227 int LightApp_Application::studyId()
229 return LightApp_Application::lastStudyId;
232 /*!Create new instance of LightApp_Application.*/
233 extern "C" LIGHTAPP_EXPORT SUIT_Application* createApplication()
235 return new LightApp_Application();
238 /*! \var global preferences of LightApp */
239 LightApp_Preferences* LightApp_Application::_prefs_ = 0;
243 \class LightApp_Application
244 Application containing LightApp module
248 LightApp_Application::LightApp_Application()
249 : CAM_Application( false ),
251 myScreenHelper(new LightApp_FullScreenHelper())
253 Q_INIT_RESOURCE( LightApp );
255 STD_TabDesktop* desk = new STD_TabDesktop();
256 desk->setFullScreenAllowed(false);
257 desk->setMinimizeAllowed(false);
261 // initialize auto save timer
262 myAutoSaveTimer = new QTimer( this );
263 myAutoSaveTimer->setSingleShot( true );
264 connect( myAutoSaveTimer, SIGNAL( timeout() ), this, SLOT( onSaveDoc() ) );
266 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
267 QPixmap aLogo = aResMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
269 QtxWebBrowser::setData("browser:icon", aResMgr->loadPixmap( "LightApp", tr( "BROWSER_ICON" ) ) );
270 QtxWebBrowser::setData("browser:title", tr( "BROWSER_TITLE" ) );
271 QtxWebBrowser::setData("toolbar:title", tr( "BROWSER_TOOLBAR_TITLE" ) );
272 QtxWebBrowser::setData("menu:file:title", tr( "BROWSER_FILEMENU" ) );
273 QtxWebBrowser::setData("action:close:title", tr( "BROWSER_CLOSE" ) );
274 QtxWebBrowser::setData("action:close:icon", aResMgr->loadPixmap( "LightApp", tr( "BROWSER_CLOSE_ICON" ) ) );
275 QtxWebBrowser::setData("action:back:title", tr( "BROWSER_BACK" ) );
276 QtxWebBrowser::setData("action:forward:title", tr( "BROWSER_FORWARD" ) );
277 QtxWebBrowser::setData("action:find:title", tr( "BROWSER_FIND" ) );
278 QtxWebBrowser::setData("action:findnext:title", tr( "BROWSER_FINDNEXT" ) );
279 QtxWebBrowser::setData("action:findprev:title", tr( "BROWSER_FINDPREV" ) );
281 desktop()->setWindowIcon( aLogo );
282 desktop()->setDockableMenuBar( false );
283 desktop()->setDockableStatusBar( false );
285 // base logo (salome itself)
286 desktop()->logoInsert( "_app_base", aResMgr->loadPixmap( "LightApp", tr( "APP_BASE_LOGO" ), false ) );
287 // extra logo (salome-based application)
288 desktop()->logoInsert( "_app_extra", aResMgr->loadPixmap( "LightApp", tr( "APP_EXTRA_LOGO" ), false ) );
292 mySelMgr = new LightApp_SelectionMgr( this );
294 myAccel = SUIT_Accel::getAccel();
296 #ifndef DISABLE_OCCVIEWER
297 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, OCCViewer_Viewer::Type() );
298 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, OCCViewer_Viewer::Type() );
299 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, OCCViewer_Viewer::Type() );
300 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, OCCViewer_Viewer::Type() );
301 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, OCCViewer_Viewer::Type() );
302 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, OCCViewer_Viewer::Type() );
303 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, OCCViewer_Viewer::Type() );
304 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, OCCViewer_Viewer::Type() );
305 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, OCCViewer_Viewer::Type() );
306 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, OCCViewer_Viewer::Type() );
307 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, OCCViewer_Viewer::Type() );
309 #ifndef DISABLE_VTKVIEWER
310 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, VTKViewer_Viewer::Type() );
311 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, VTKViewer_Viewer::Type() );
312 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, VTKViewer_Viewer::Type() );
313 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, VTKViewer_Viewer::Type() );
314 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, VTKViewer_Viewer::Type() );
315 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, VTKViewer_Viewer::Type() );
316 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, VTKViewer_Viewer::Type() );
317 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, VTKViewer_Viewer::Type() );
318 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, VTKViewer_Viewer::Type() );
319 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, VTKViewer_Viewer::Type() );
320 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, VTKViewer_Viewer::Type() );
322 #ifndef DISABLE_PLOT2DVIEWER
323 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, Plot2d_Viewer::Type() );
324 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, Plot2d_Viewer::Type() );
325 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, Plot2d_Viewer::Type() );
326 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, Plot2d_Viewer::Type() );
327 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, Plot2d_Viewer::Type() );
328 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, Plot2d_Viewer::Type() );
329 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, Plot2d_Viewer::Type() );
332 connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) );
334 // Set existing font for the python console in resources
335 if( !aResMgr->hasValue( "PyConsole", "font" ) )
338 QFont f = aResMgr->fontValue( "PyConsole", "font" );
340 QStringList famdb = fdb.families();
342 if ( famdb.contains(f.family()) || !aResMgr->hasValue( "PyConsole", "additional_families" ) )
345 QStringList anAddFamilies = aResMgr->stringValue( "PyConsole", "additional_families" ).split( ";", QString::SkipEmptyParts );
347 for ( QStringList::Iterator it = anAddFamilies.begin(); it != anAddFamilies.end(); ++it )
350 if ( famdb.contains(aFamily) )
352 f.setFamily( aFamily );
353 aResMgr->setValue( "PyConsole", "font", f );
360 *\li Save window geometry.
361 *\li Save desktop geometry.
362 *\li Save resource maneger.
363 *\li Delete selection manager.
365 LightApp_Application::~LightApp_Application()
368 delete myScreenHelper;
371 /*!Start application.*/
372 void LightApp_Application::start()
374 CAM_Application::start();
377 updateViewManagers();
380 desktop()->statusBar()->showMessage( "" );
382 LightApp_EventFilter::Init();
385 /*!Gets application name.*/
386 QString LightApp_Application::applicationName() const
388 static QString _app_name;
389 if ( _app_name.isEmpty() )
390 _app_name = tr( "APP_NAME" );
394 /*!Gets application version.*/
395 QString LightApp_Application::applicationVersion() const
397 static QString _app_version;
399 if ( _app_version.isEmpty() )
401 QString resVersion = tr( "APP_VERSION" );
402 if ( resVersion != "APP_VERSION" )
404 _app_version = resVersion;
408 _app_version = GUI_VERSION_STR;
414 /*!Load module by \a name.*/
415 CAM_Module* LightApp_Application::loadModule( const QString& name, const bool showMsg )
417 CAM_Module* mod = CAM_Application::loadModule( name, showMsg );
420 connect( this, SIGNAL( studyOpened() ), mod, SLOT( onModelOpened() ) );
421 connect( this, SIGNAL( studySaved() ), mod, SLOT( onModelSaved() ) );
422 connect( this, SIGNAL( studyClosed() ), mod, SLOT( onModelClosed() ) );
427 /*!Activate module by \a modName*/
428 bool LightApp_Application::activateModule( const QString& modName )
431 CAM_Module* prevMod = activeModule();
434 actName = prevMod->moduleName();
436 if ( actName == modName )
439 putInfo( tr( "ACTIVATING_MODULE" ).arg( modName ) );
441 saveDockWindowsState();
443 bool status = CAM_Application::activateModule( modName );
445 updateModuleActions();
453 updateViewManagers();
458 /*!Gets selection manager.*/
459 LightApp_SelectionMgr* LightApp_Application::selectionMgr() const
464 /*!Creat action "New window" for certain type of viewer:*/
465 void LightApp_Application::createActionForViewer( const int id,
467 const QString& suffix,
470 QString vtlt = tr( QString( "NEW_WINDOW_%1" ).arg( suffix ).toLatin1().constData() );
471 QString tip = tr( "CREATING_NEW_WINDOW" ).arg( vtlt.remove( "&" ) );
472 QAction* a = createAction( id, // menu action id
479 false, // toggle flag
481 SLOT( onNewWindow() ) ); // slot
482 createMenu( a, parentId, -1 );
487 void LightApp_Application::createActions()
489 STD_Application::createActions();
491 SUIT_Desktop* desk = desktop();
492 SUIT_ResourceMgr* resMgr = resourceMgr();
495 createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIcon(),
496 tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
497 Qt::CTRL+Qt::Key_R, desk, false, this, SLOT( onPreferences() ) );
500 int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
501 createMenu( separator(), helpMenu, -1, 1 );
502 QStringList aModuleList;
503 modules( aModuleList, false );
504 aModuleList.prepend( "GUI" );
505 aModuleList.prepend( "KERNEL" );
507 int id = LightApp_Application::UserID + FIRST_HELP_ID;
509 // help for other existing modules
512 foreach( aModule, aModuleList ) {
513 if ( aModule.isEmpty() ) // module title (user name)
515 IMap <QString, QString> helpData; // list of help files for the module
516 QString helpSubMenu; // help submenu name (empty if not needed)
517 QString modName = moduleName( aModule ); // module name
518 if ( modName.isEmpty() ) modName = aModule; // for KERNEL and GUI
519 QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName ); // module root dir variable
520 QString modDir = getenv( rootDir.toLatin1().constData() ); // module root dir
522 if (resMgr->hasValue( modName, "documentation" ) )
523 docSection = resMgr->stringValue(modName, "documentation");
524 else if ( resMgr->hasSection( modName + "_documentation" ) )
525 docSection = modName + "_documentation";
526 if ( !docSection.isEmpty() ) {
527 helpSubMenu = resMgr->stringValue( docSection, "sub_menu", "" ).arg( aModule );
528 QStringList listOfParam = resMgr->parameters( docSection );
529 foreach( QString paramName, listOfParam ) {
530 QString valueStr = resMgr->stringValue( docSection, paramName );
531 if ( !valueStr.isEmpty() ) {
532 QFileInfo fi( valueStr );
533 if ( fi.isRelative() && !modDir.isEmpty() )
534 valueStr = Qtx::addSlash( modDir ) + valueStr;
535 if ( QFile::exists( valueStr ) )
536 helpData.insert( paramName.arg( aModule ), valueStr );
541 if ( helpData.isEmpty() && !modDir.isEmpty() ) {
542 QStringList idxLst = QStringList() << modDir << "share" << "doc" << "salome" << "gui" << modName << "index.html";
543 QString indexFile = idxLst.join( QDir::separator() ); // index file
544 if ( QFile::exists( indexFile ) )
545 helpData.insert( tr( "%1 module Users's Guide" ).arg( aModule ), indexFile );
548 IMapConstIterator<QString, QString > fileIt;
549 for ( fileIt = helpData.begin(); fileIt != helpData.end(); fileIt++ ) {
550 QString helpFileName = fileIt.key();
551 // remove all '//' occurances
552 while ( helpFileName.contains( "//" ) )
553 helpFileName.replace( "//", "" );
554 // obtain submenus hierarchy if given
555 QStringList smenus = helpFileName.split( "/" );
556 helpFileName = smenus.last();
558 QAction* a = createAction( id, helpFileName,
559 resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
560 helpFileName, helpFileName,
561 0, desk, false, this, SLOT( onHelpContentsModule() ) );
562 a->setData( fileIt.value() );
563 if ( !helpSubMenu.isEmpty() ) {
564 smenus.prepend( helpSubMenu );
566 // create sub-menus hierarchy
567 int menuId = helpMenu;
568 foreach ( QString subMenu, smenus ) {
569 menuId = createMenu( subMenu, menuId, -1, 0 );
571 createMenu( a, menuId, -1, 0 );
577 static QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), 0 );
578 connect( mru, SIGNAL( activated( const QString& ) ), this, SLOT( onMRUActivated( const QString& ) ) );
579 registerAction( MRUId, mru );
581 // default icon for neutral point ('SALOME' module)
582 QPixmap defIcon = resMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
583 if ( defIcon.isNull() )
584 defIcon = QPixmap( imageEmptyIcon );
586 //! default icon for any module
587 QPixmap modIcon = resMgr->loadPixmap( "LightApp", tr( "APP_MODULE_ICO" ), false );
588 if ( modIcon.isNull() )
589 modIcon = QPixmap( imageEmptyIcon );
592 modules( modList, false );
594 if ( modList.count() > 1 )
596 LightApp_ModuleAction* moduleAction =
597 new LightApp_ModuleAction( tr( "APP_NAME" ), defIcon, desk );
599 QMap<QString, QString> iconMap;
600 moduleIconNames( iconMap );
602 const int iconSize = 20;
604 QStringList::Iterator it;
605 for ( it = modList.begin(); it != modList.end(); ++it )
607 if ( !isLibExists( *it ) )
610 QString modName = moduleName( *it );
612 if ( !isModuleAccessible( *it ) )
616 if ( iconMap.contains( *it ) )
617 iconName = iconMap[*it];
619 QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
623 INFOS ( "****************************************************************" << std::endl
624 << "* Icon for " << (*it).toLatin1().constData()
625 << " not found. Using the default one." << std::endl
626 << "****************************************************************" << std::endl );
629 icon = Qtx::scaleIcon( icon, iconSize );
631 moduleAction->insertModule( *it, icon );
634 connect( moduleAction, SIGNAL( moduleActivated( const QString& ) ),
635 this, SLOT( onModuleActivation( const QString& ) ) );
636 registerAction( ModulesListId, moduleAction );
640 int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, MenuWindowId, 100 );
641 int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
643 createAction( CloseId, tr( "TOT_CLOSE" ), QIcon(), tr( "MEN_DESK_CLOSE" ), tr( "PRP_CLOSE" ),
644 Qt::CTRL+Qt::Key_F4, desk, false, this, SLOT( onCloseWindow() ) );
645 createAction( CloseAllId, tr( "TOT_CLOSE_ALL" ), QIcon(), tr( "MEN_DESK_CLOSE_ALL" ), tr( "PRP_CLOSE_ALL" ),
646 0, desk, false, this, SLOT( onCloseAllWindow() ) );
647 createAction( GroupAllId, tr( "TOT_GROUP_ALL" ), QIcon(), tr( "MEN_DESK_GROUP_ALL" ), tr( "PRP_GROUP_ALL" ),
648 0, desk, false, this, SLOT( onGroupAllWindow() ) );
650 createMenu( CloseId, windowMenu, 0, -1 );
651 createMenu( CloseAllId, windowMenu, 0, -1 );
652 createMenu( GroupAllId, windowMenu, 0, -1 );
653 createMenu( separator(), windowMenu, -1, 0 );
655 #ifndef DISABLE_GLVIEWER
656 createActionForViewer( NewGLViewId, newWinMenu, QString::number( 0 ), Qt::ALT+Qt::Key_G );
658 #ifndef DISABLE_PLOT2DVIEWER
659 createActionForViewer( NewPlot2dId, newWinMenu, QString::number( 1 ), Qt::ALT+Qt::Key_P );
661 #ifndef DISABLE_OCCVIEWER
662 createActionForViewer( NewOCCViewId, newWinMenu, QString::number( 2 ), Qt::ALT+Qt::Key_O );
664 #ifndef DISABLE_VTKVIEWER
665 createActionForViewer( NewVTKViewId, newWinMenu, QString::number( 3 ), Qt::ALT+Qt::Key_K );
667 #ifndef DISABLE_QXGRAPHVIEWER
668 //VSR: QxGraph has been replaced by QxScene
669 // createActionForViewer( NewQxGraphViewId, newWinMenu, QString::number( 4 ), Qt::ALT+Qt::Key_C );
670 createActionForViewer( NewQxSceneViewId, newWinMenu, QString::number( 4 ), Qt::ALT+Qt::Key_S );
673 createAction( RenameId, tr( "TOT_RENAME" ), QIcon(), tr( "MEN_DESK_RENAME" ), tr( "PRP_RENAME" ),
674 Qt::ALT+Qt::SHIFT+Qt::Key_R, desk, false, this, SLOT( onRenameWindow() ) );
675 createMenu( RenameId, windowMenu, -1 );
677 int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
678 createMenu( PreferencesId, fileMenu, 50, -1 );
679 createMenu( separator(), fileMenu, -1, 50, -1 );
681 createMenu( separator(), fileMenu, -1, 100, -1 );
682 createMenu( MRUId, fileMenu, 100, -1 );
683 createMenu( separator(), fileMenu, -1, 100, -1 );
685 createAction( StyleId, tr( "TOT_THEME" ), QIcon(), tr( "MEN_DESK_THEME" ), tr( "PRP_THEME" ),
686 0, desk, false, this, SLOT( onStylePreferences() ) );
688 createAction( FullScreenId, tr( "TOT_FULLSCREEN" ), QIcon(), tr( "MEN_DESK_FULLSCREEN" ), tr( "PRP_FULLSCREEN" ),
689 Qt::Key_F11, desk, false, this, SLOT( onFullScreen() ) );
692 int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1 );
693 createMenu( separator(), viewMenu, -1, 20, -1 );
694 createMenu( StyleId, viewMenu, 20, -1 );
695 createMenu( FullScreenId, viewMenu, 20, -1 );
697 int modTBar = createTool( tr( "INF_TOOLBAR_MODULES" ) );
698 createTool( ModulesListId, modTBar );
701 /*!On module activation action.*/
702 void LightApp_Application::onModuleActivation( const QString& modName )
704 // Force user to create/open a study before module activation
705 QMap<QString, QString> iconMap;
706 moduleIconNames( iconMap );
707 QPixmap icon = resourceMgr()->loadPixmap( moduleName( modName ), iconMap[ modName ], false );
709 icon = resourceMgr()->loadPixmap( "LightApp", tr( "APP_MODULE_BIG_ICO" ), false ); // default icon for any module
711 bool cancelled = false;
713 while ( !modName.isEmpty() && !activeStudy() && !cancelled ){
714 LightApp_ModuleDlg aDlg( desktop(), modName, icon );
715 QMap<int, QString> opmap = activateModuleActions();
716 for ( QMap<int, QString>::ConstIterator it = opmap.begin(); it != opmap.end(); ++it )
717 aDlg.addButton( it.value(), it.key() );
719 int res = aDlg.exec();
721 // some operation is selected
722 moduleActionSelected( res );
726 putInfo( tr("INF_CANCELLED") );
728 LightApp_ModuleAction* moduleAction =
729 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
731 moduleAction->setActiveModule( QString() );
737 activateModule( modName );
740 /*!Default module activation.*/
741 QString LightApp_Application::defaultModule() const
743 QStringList aModuleNames;
744 modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration
745 //! If there's the one and only module --> activate it automatically
746 //! TODO: Possible improvement - default module can be taken from preferences
747 return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" );
750 /*!On new window slot.*/
751 void LightApp_Application::onNewWindow()
753 const QObject* obj = sender();
754 if ( !obj || !obj->inherits( "QAction" ) )
758 int id = actionId( (QAction*)obj );
761 #ifndef DISABLE_GLVIEWER
763 type = GLViewer_Viewer::Type();
766 #ifndef DISABLE_PLOT2DVIEWER
768 type = Plot2d_Viewer::Type();
771 #ifndef DISABLE_OCCVIEWER
773 type = OCCViewer_Viewer::Type();
776 #ifndef DISABLE_VTKVIEWER
778 type = VTKViewer_Viewer::Type();
781 #ifndef DISABLE_QXGRAPHVIEWER
782 //VSR: QxGraph has been replaced by QxScene
783 // case NewQxGraphViewId:
784 // type = QxGraph_Viewer::Type();
786 case NewQxSceneViewId:
787 type = QxScene_Viewer::Type();
792 if ( !type.isEmpty() )
793 createViewManager( type );
797 SLOT: Creates new document
799 void LightApp_Application::onNewDoc()
801 //asl: fix for 0020515
803 saveDockWindowsState();
805 CAM_Application::onNewDoc();
809 SLOT: Opens new document
811 void LightApp_Application::onOpenDoc()
813 SUIT_Study* study = activeStudy();
814 saveDockWindowsState();
816 CAM_Application::onOpenDoc();
818 if ( !study ) // new study will be create in THIS application
821 updateViewManagers();
826 SLOT: Opens new document.
827 \param aName - name of file
829 bool LightApp_Application::onOpenDoc( const QString& aName )
831 // We should take mru action first because this application instance can be deleted later.
832 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
834 bool res = CAM_Application::onOpenDoc( aName );
839 mru->insert( aName );
841 mru->remove( aName );
847 SLOT: Displays "About" message box
849 void LightApp_Application::onHelpAbout()
851 LightApp_AboutDlg dlg( applicationName(), applicationVersion(), desktop() );
856 Private SLOT: Called on selection is changed
857 Dispatchs active module that selection is changed
859 void LightApp_Application::onSelection()
861 onSelectionChanged();
863 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
864 ((LightApp_Module*)activeModule())->selectionChanged();
869 \param study - SUIT_Study.
871 void LightApp_Application::setActiveStudy( SUIT_Study* study )
873 CAM_Application::setActiveStudy( study );
877 Enables/Disables menu items and toolbar buttons. Rebuild menu
879 void LightApp_Application::updateCommandsStatus()
881 CAM_Application::updateCommandsStatus();
884 #ifndef DISABLE_GLVIEWER
885 a = action( NewGLViewId );
887 a->setEnabled( activeStudy() );
890 #ifndef DISABLE_PLOT2DVIEWER
891 a = action( NewPlot2dId );
893 a->setEnabled( activeStudy() );
896 #ifndef DISABLE_OCCVIEWER
897 a = action( NewOCCViewId );
899 a->setEnabled( activeStudy() );
902 #ifndef DISABLE_VTKVIEWER
903 a = action( NewVTKViewId );
905 a->setEnabled( activeStudy() );
908 #ifndef DISABLE_QXGRAPHVIEWER
909 //VSR: QxGraph has been replaced by QxScene
910 // a = action( NewQxGraphViewId );
911 a = action( NewQxSceneViewId );
913 a->setEnabled( activeStudy() );
919 Runs system command in separate thread
921 class RunBrowser: public QThread
924 RunBrowser( LightApp_Application* app,
925 const QString& theApp,
926 const QString& theParams,
927 const QString& theHelpFile,
928 const QString& theContext = QString() )
930 myParams( theParams ),
931 myContext( theContext ),
935 //For the external browser always specify 'file://' protocol,
936 //because some WEB browsers (for example Mozilla Firefox) can't open local file without protocol.
937 myHelpFile = QString("file://%1").arg( QFileInfo( theHelpFile ).canonicalFilePath() );
942 if ( !myApp.isEmpty() && !myHelpFile.isEmpty()) {
943 QString aCommand = QString( "%1 %2 \"%3%4\"" ).arg( myApp, myParams, myHelpFile, myContext.isEmpty() ? QString("") : QString( "#%1" ).arg( myContext ) );
945 QProcess* proc = new QProcess();
947 proc->start( aCommand );
948 if ( !proc->waitForStarted() ) {
949 SALOME_CustomEvent* ce2000 = new SALOME_CustomEvent( 2000 );
950 QString* msg = new QString( QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).arg( myApp, myHelpFile ) );
951 ce2000->setData( msg );
952 QApplication::postEvent( myLApp, ce2000 );
963 LightApp_Application* myLApp;
967 SLOT: Displays help contents for choosen module
969 void LightApp_Application::onHelpContentsModule()
971 const QAction* a = (QAction*) sender();
972 QString helpFile = a->data().toString();
973 if ( helpFile.isEmpty() ) return;
975 SUIT_ResourceMgr* resMgr = resourceMgr();
978 platform = "winapplication";
980 platform = "application";
982 QString anApp = resMgr->stringValue("ExternalBrowser", platform);
985 anApp.prepend( quote );
986 anApp.append( quote );
988 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
989 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
991 if( useExtBrowser ) {
992 if ( !anApp.isEmpty() ) {
993 RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile );
997 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
998 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
999 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1001 showPreferences( tr( "PREF_APP" ) );
1006 // On Win32 platform QWebKit of the Qt 4.6.3 hang up in case 'file://' protocol
1007 // is defined. On Linux platform QWebKit doesn't work correctly without 'file://' protocol.
1008 QtxWebBrowser::loadUrl(helpFile);
1010 QtxWebBrowser::loadUrl(QString("file://%1").arg(helpFile));
1016 SLOT: Displays help contents for choosen dialog
1018 void LightApp_Application::onHelpContextModule( const QString& theComponentName,
1019 const QString& theFileName,
1020 const QString& theContext )
1022 QString fileName = theFileName;
1023 QString context = theContext;
1024 if ( !QFile::exists( fileName ) && theContext.isEmpty() ) {
1025 // context might be passed within theFileName argument
1026 QStringList comps = fileName.split("#");
1027 if ( comps.count() > 1 ) {
1028 context = comps.last();
1030 fileName = comps.join("#");
1034 QString homeDir = "";
1035 if ( !theComponentName.isEmpty() ) {
1036 QString dir = getenv( ( theComponentName + "_ROOT_DIR" ).toLatin1().constData() );
1037 if ( !dir.isEmpty() )
1038 homeDir = Qtx::addSlash( Qtx::addSlash( dir ) +
1039 Qtx::addSlash( "share" ) +
1040 Qtx::addSlash( "doc" ) +
1041 Qtx::addSlash( "salome" ) +
1042 Qtx::addSlash( "gui" ) +
1043 Qtx::addSlash( theComponentName ) );
1046 QString helpFile = QFileInfo( homeDir + fileName ).absoluteFilePath();
1047 SUIT_ResourceMgr* resMgr = resourceMgr();
1050 platform = "winapplication";
1052 platform = "application";
1054 QString anApp = resMgr->stringValue("ExternalBrowser", platform);
1056 QString quote("\"");
1057 anApp.prepend( quote );
1058 anApp.append( quote );
1061 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1064 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
1066 if ( !anApp.isEmpty() ) {
1067 RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile, context );
1071 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1072 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1073 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1074 showPreferences( tr( "PREF_APP" ) );
1079 // On Win32 platform QWebKit of the Qt 4.6.3 hang up in case 'file://' protocol
1080 // is defined. On Linux platform QWebKit doesn't work correctly without 'file://' protocol.
1081 QtxWebBrowser::loadUrl(helpFile, context);
1083 QtxWebBrowser::loadUrl(QString("file://%1").arg(helpFile),context);
1090 Sets enable or disable some actions on selection changed.
1092 void LightApp_Application::onSelectionChanged()
1094 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
1095 bool canCopy = m ? m->canCopy() : false;
1096 bool canPaste = m ? m->canPaste() : false;
1098 action( EditCopyId )->setEnabled(canCopy);
1099 action( EditPasteId )->setEnabled(canPaste);
1103 Adds window to application.
1104 \param wid - QWidget
1105 \param flag - key for window
1106 \param studyId - study id
1107 Flag used how identificator of window in windows list.
1110 void LightApp_Application::addWindow( QWidget* wid, const int flag, const int studyId )
1118 if ( !activeStudy() )
1121 sId = activeStudy()->id();
1124 if ( !myWindows.contains( flag ) )
1126 QMap<int, int> winMap;
1127 currentWindows( winMap );
1129 LightApp_WidgetContainer* newWC = new LightApp_WidgetContainer( flag, desktop() );
1130 connect( newWC, SIGNAL( destroyed ( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
1131 // asv: connecting a slot for storing visibility flag of a window
1132 connect( newWC, SIGNAL( visibilityChanged ( bool ) ), SLOT( onVisibilityChanged( bool ) ) );
1133 myWindows.insert( flag, newWC );
1134 if ( winMap.contains( flag ) ) {
1135 //desktop()->removeDockWidget( myWindows[flag] );
1136 desktop()->addDockWidget( (Qt::DockWidgetArea)winMap[flag], myWindows[flag] );
1139 //myWindows[flag]->setResizeEnabled( true );
1140 myWindows[flag]->setFeatures( QDockWidget::AllDockWidgetFeatures );
1141 myWindows[flag]->setObjectName( QString( "dock_window_%1" ).arg( flag ) );
1142 //myWindows[flag]->setFixedExtentWidth( wid->width() );
1143 //myWindows[flag]->setFixedExtentHeight( wid->height() );
1144 myWindows[flag]->resize( wid->width(), wid->height() );
1148 #ifndef DISABLE_PYCONSOLE
1149 if( wid->inherits( "PyConsole_Console" ) )
1151 if( resourceMgr()->hasValue( "PyConsole", "font" ) )
1152 f = resourceMgr()->fontValue( "PyConsole", "font" );
1155 f = ( ( PyConsole_Console* )wid )->font();
1156 resourceMgr()->setValue( "PyConsole", "font", f );
1163 myWindows[flag]->insert( sId, wid );
1166 setWindowShown( flag, !myWindows[flag]->isEmpty() );
1170 QWidget* LightApp_Application::dockWindow( const int id ) const
1173 if ( myWin.contains( id ) )
1178 QDockWidget* LightApp_Application::windowDock( QWidget* wid ) const
1183 QDockWidget* dock = 0;
1184 QWidget* w = wid->parentWidget();
1185 while ( w && !dock )
1187 dock = ::qobject_cast<QDockWidget*>( w );
1188 w = w->parentWidget();
1193 void LightApp_Application::insertDockWindow( const int id, QWidget* wid )
1198 if ( wid != dockWindow( id ) )
1199 removeDockWindow( id );
1201 myWin.insert( id, wid );
1203 QtxDockWidget* dock = new QtxDockWidget( true, desktop() );
1204 connect( dock, SIGNAL( destroyed( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
1206 dock->setFeatures( QDockWidget::AllDockWidgetFeatures );
1207 dock->setObjectName( QString( "window_%1" ).arg( id ) );
1208 dock->setWidget( wid );
1210 QKeySequence accel = wid->property( "shortcut" ).value<QKeySequence>();
1211 if ( !accel.isEmpty() )
1212 dock->toggleViewAction()->setShortcut( accel );
1217 void LightApp_Application::removeDockWindow( const int id )
1219 QWidget* wid = dockWindow( id );
1225 QDockWidget* dock = windowDock( wid );
1229 dock->setWidget( 0 );
1230 wid->setParent( 0 );
1231 wid->setVisible( false );
1235 void LightApp_Application::placeDockWindow( const int id, Qt::DockWidgetArea place )
1237 QDockWidget* dock = windowDock( dockWindow( id ) );
1238 if ( dock && desktop() ) {
1239 desktop()->addDockWidget( place, dock );
1240 QtxDockAction* a = qobject_cast<QtxDockAction*>( action( ViewWindowsId ) );
1241 if ( a ) a->update();
1247 \param flag - key for window
1248 \param studyId - study id
1249 Flag used how identificator of window in windows list.
1251 QWidget* LightApp_Application::getWindow( const int flag, const int )
1253 QWidget* wid = dockWindow( flag );
1255 insertDockWindow( flag, wid = createWindow( flag ) );
1257 QMap<int, int> winMap;
1258 currentWindows( winMap );
1259 if ( winMap.contains( flag ) )
1260 placeDockWindow( flag, (Qt::DockWidgetArea)winMap[flag] );
1266 \return Object Browser
1268 SUIT_DataBrowser* LightApp_Application::objectBrowser()
1270 return qobject_cast<SUIT_DataBrowser*>( dockWindow( WT_ObjectBrowser ) );
1276 LogWindow* LightApp_Application::logWindow()
1278 return qobject_cast<LogWindow*>( dockWindow( WT_LogWindow ) );
1281 #ifndef DISABLE_PYCONSOLE
1283 This returns the python console integrated to the GUI. Depending
1284 when you request the python console, this function could return
1285 null. Then the optional parameter force (default to false) can be
1286 set to force the creation of the python console if it is not done
1288 \param force - if true, the pythonConsole is created if it does not exist yet
1289 \return Python Console
1291 PyConsole_Console* LightApp_Application::pythonConsole(const bool force)
1293 QWidget* wid = dockWindow( WT_PyConsole );
1294 if ( !wid && force==true) {
1295 wid = getWindow(WT_PyConsole);
1297 return qobject_cast<PyConsole_Console*>( wid );
1302 Updates object browser and maybe data models
1303 \param updateModels - if it is true, then data models are updated
1305 void LightApp_Application::updateObjectBrowser( const bool updateModels )
1307 // update existing data models
1310 const bool isAutoUpdate = objectBrowser() ? objectBrowser()->autoUpdate() : true;
1311 if ( objectBrowser() )
1312 objectBrowser()->setAutoUpdate( false );
1314 LightApp_Study* study = dynamic_cast<LightApp_Study*>(activeStudy());
1316 CAM_Study::ModelList dm_list;
1317 study->dataModels( dm_list );
1318 QListIterator<CAM_DataModel*> it( dm_list );
1319 while ( it.hasNext() ) {
1320 CAM_DataModel* camDM = it.next();
1321 if ( camDM && camDM->inherits( "LightApp_DataModel" ) )
1322 ((LightApp_DataModel*)camDM)->update();
1326 if( objectBrowser() )
1327 objectBrowser()->setAutoUpdate( isAutoUpdate );
1330 if ( objectBrowser() ) {
1331 objectBrowser()->updateGeometry();
1332 objectBrowser()->updateTree( 0, false );
1339 LightApp_Preferences* LightApp_Application::preferences() const
1341 return preferences( false );
1345 \return first view manager of some type
1346 \param vmType - type of view manager
1347 \param create - is it necessary to create view manager in case, when there is no manager of such type
1349 SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, const bool create )
1351 SUIT_ViewManager* aVM = viewManager( vmType );
1352 SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
1354 if ( anActiveVM && anActiveVM->getType() == vmType )
1357 if ( aVM && create )
1359 if ( !aVM->getActiveView() )
1362 aVM->getActiveView()->setFocus();
1365 aVM = createViewManager( vmType );
1371 Creates view manager of some type
1372 \param vmType - type of view manager
1374 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType )
1376 SUIT_ResourceMgr* resMgr = resourceMgr();
1378 SUIT_ViewManager* viewMgr = 0;
1379 #ifndef DISABLE_GLVIEWER
1380 if( vmType == GLViewer_Viewer::Type() )
1382 viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() );
1383 new LightApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
1386 #ifndef DISABLE_PLOT2DVIEWER
1387 if( vmType == Plot2d_Viewer::Type() )
1389 viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
1391 #ifndef DISABLE_SALOMEOBJECT
1392 SPlot2d_Viewer* v = new SPlot2d_Viewer();
1394 new LightApp_Plot2dSelector( v, mySelMgr );
1396 vm = new Plot2d_Viewer();
1398 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1399 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
1402 Plot2d_ViewFrame* frame = wnd->getViewFrame();
1403 frame->setBackgroundColor( resMgr->colorValue( "Plot2d", "Background", frame->backgroundColor() ) );
1407 //#ifndef DISABLE_SUPERVGRAPHVIEWER
1408 // if( vmType == SUPERVGraph_Viewer::Type() )
1410 // viewMgr = new SUPERVGraph_ViewManager( activeStudy(), desktop(), new SUPERVGraph_Viewer() );
1413 #ifndef DISABLE_QXGRAPHVIEWER
1414 //VSR: QxGraph has been replaced by QxScene
1415 // if( vmType == QxGraph_Viewer::Type() )
1417 // viewMgr = new QxGraph_ViewManager( activeStudy(), desktop(), new QxGraph_Viewer() );
1419 if( vmType == QxScene_Viewer::Type() )
1421 viewMgr = new QxScene_ViewManager( activeStudy(), desktop() );
1422 QxScene_Viewer* vm = new QxScene_Viewer();
1423 viewMgr->setViewModel( vm );
1424 //QxScene_ViewWindow* wnd = dynamic_cast<QxScene_ViewWindow*>( viewMgr->getActiveView() );
1427 #ifndef DISABLE_OCCVIEWER
1428 if( vmType == OCCViewer_Viewer::Type() )
1430 viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
1431 OCCViewer_Viewer* vm;
1432 #ifndef DISABLE_SALOMEOBJECT
1433 vm = new SOCC_Viewer();
1435 vm = new OCCViewer_Viewer( true );
1437 vm->setBackground( OCCViewer_ViewFrame::TOP_LEFT,
1438 resMgr->backgroundValue( "OCCViewer", "xz_background", vm->background(OCCViewer_ViewFrame::TOP_LEFT) ) );
1439 vm->setBackground( OCCViewer_ViewFrame::TOP_RIGHT,
1440 resMgr->backgroundValue( "OCCViewer", "yz_background", vm->background(OCCViewer_ViewFrame::TOP_RIGHT) ) );
1441 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_LEFT,
1442 resMgr->backgroundValue( "OCCViewer", "xy_background", vm->background(OCCViewer_ViewFrame::BOTTOM_LEFT) ) );
1443 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_RIGHT,
1444 resMgr->backgroundValue( "OCCViewer", "background", vm->background(OCCViewer_ViewFrame::MAIN_VIEW) ) );
1446 vm->setTrihedronSize( resMgr->doubleValue( "OCCViewer", "trihedron_size", vm->trihedronSize() ),
1447 resMgr->booleanValue( "OCCViewer", "relative_size", vm->trihedronRelative() ));
1448 vm->setInteractionStyle( resMgr->integerValue( "OCCViewer", "navigation_mode", vm->interactionStyle() ) );
1449 vm->setZoomingStyle( resMgr->integerValue( "OCCViewer", "zooming_mode", vm->zoomingStyle() ) );
1450 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1451 new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
1454 #ifndef DISABLE_VTKVIEWER
1455 #ifndef DISABLE_SALOMEOBJECT
1456 if ( vmType == SVTK_Viewer::Type() )
1458 if ( vmType == VTKViewer_Viewer::Type() )
1461 #ifndef DISABLE_SALOMEOBJECT
1462 viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
1463 SVTK_Viewer* vm = dynamic_cast<SVTK_Viewer*>( viewMgr->getViewModel() );
1466 vm->setProjectionMode( resMgr->integerValue( "VTKViewer", "projection_mode", vm->projectionMode() ) );
1467 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1468 vm->setTrihedronSize( resMgr->doubleValue( "VTKViewer", "trihedron_size", vm->trihedronSize() ),
1469 resMgr->booleanValue( "VTKViewer", "relative_size", vm->trihedronRelative() ) );
1470 vm->setStaticTrihedronVisible( resMgr->booleanValue( "VTKViewer", "show_static_trihedron", vm->isStaticTrihedronVisible() ) );
1471 vm->setInteractionStyle( resMgr->integerValue( "VTKViewer", "navigation_mode", vm->interactionStyle() ) );
1472 vm->setZoomingStyle( resMgr->integerValue( "VTKViewer", "zooming_mode", vm->zoomingStyle() ) );
1473 vm->setDynamicPreSelection( resMgr->booleanValue( "VTKViewer", "dynamic_preselection", vm->dynamicPreSelection() ) );
1474 vm->setIncrementalSpeed( resMgr->integerValue( "VTKViewer", "speed_value", vm->incrementalSpeed() ),
1475 resMgr->integerValue( "VTKViewer", "speed_mode", vm->incrementalSpeedMode() ) );
1476 vm->setSpacemouseButtons( resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", vm->spacemouseBtn(1) ),
1477 resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", vm->spacemouseBtn(2) ),
1478 resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", vm->spacemouseBtn(3) ) );
1479 new LightApp_VTKSelector( vm, mySelMgr );
1482 viewMgr = new VTKViewer_ViewManager( activeStudy(), desktop() );
1483 VTKViewer_Viewer* vm = dynamic_cast<VTKViewer_Viewer*>( viewMgr->getViewModel() );
1485 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1493 addViewManager( viewMgr );
1494 SUIT_ViewWindow* viewWin = viewMgr->createViewWindow();
1496 if ( viewWin && desktop() ) {
1497 viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1498 viewWin->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1504 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, QWidget* w )
1506 SUIT_ResourceMgr* resMgr = resourceMgr();
1508 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
1510 new LightApp_WgViewModel( vmType, w ) );
1511 vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
1513 addViewManager( vm );
1514 SUIT_ViewWindow* vw = vm->createViewWindow();
1515 if ( vw && desktop() ) {
1516 vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1517 vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1520 if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
1521 myUserWmTypes << vmType;
1527 SLOT: Removes view manager from application
1529 void LightApp_Application::onCloseView( SUIT_ViewManager* theVM )
1531 removeViewManager( theVM );
1535 Protected SLOT: On study created.
1536 \param theStudy - just created study
1538 void LightApp_Application::onStudyCreated( SUIT_Study* theStudy )
1540 SUIT_DataObject* aRoot = 0;
1541 if ( theStudy && theStudy->root() )
1543 aRoot = theStudy->root();
1544 //aRoot->setName( tr( "DATA_MODELS" ) );
1547 getWindow( WT_ObjectBrowser );
1549 loadDockWindowsState();
1551 if ( objectBrowser() )
1552 objectBrowser()->setRoot( aRoot );
1554 activateModule( defaultModule() );
1556 if ( objectBrowser() )
1557 objectBrowser()->openLevels();
1561 Protected SLOT: On study opened.
1562 \param theStudy - just opened study
1564 void LightApp_Application::onStudyOpened( SUIT_Study* theStudy )
1566 SUIT_DataObject* aRoot = 0;
1567 if ( theStudy && theStudy->root() )
1569 aRoot = theStudy->root();
1573 getWindow( WT_ObjectBrowser );
1575 loadDockWindowsState();
1577 if ( objectBrowser() )
1578 objectBrowser()->setRoot( aRoot );
1580 activateModule( defaultModule() );
1582 if ( objectBrowser() )
1583 objectBrowser()->openLevels();
1588 /*!Protected SLOT. On study saved.*/
1589 void LightApp_Application::onStudySaved( SUIT_Study* s )
1591 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
1593 mru->insert( s->studyName() );
1598 /*!Protected SLOT. On study closed.*/
1599 void LightApp_Application::onStudyClosed( SUIT_Study* s )
1601 // stop auto-save timer
1602 myAutoSaveTimer->stop();
1604 // Bug 10396: clear selection
1605 mySelMgr->clearSelected();
1607 // Bug 12944: emit signal only after clear selection
1610 activateModule( "" );
1613 /*!Protected SLOT.On desktop activated.*/
1614 void LightApp_Application::onDesktopActivated()
1616 CAM_Application::onDesktopActivated();
1617 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>(activeModule());
1619 aModule->studyActivated();
1622 void LightApp_Application::studyOpened( SUIT_Study* s )
1624 CAM_Application::studyOpened( s );
1627 updateViewManagers();
1630 void LightApp_Application::studySaved( SUIT_Study* s )
1632 CAM_Application::studyOpened( s );
1633 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1634 if ( aResMgr && activeStudy() ) {
1635 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
1636 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
1640 void LightApp_Application::studyCreated( SUIT_Study* s )
1642 CAM_Application::studyCreated( s );
1645 updateViewManagers();
1648 /*!Gets file filter.
1649 *\retval QString "(*.bin)"
1651 QString LightApp_Application::getFileFilter() const
1659 Shows file dialog and return user selected file name
1661 QString LightApp_Application::getFileName( bool open, const QString& initial, const QString& filters,
1662 const QString& caption, QWidget* parent )
1666 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1667 return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
1670 /*! Gets directory*/
1671 QString LightApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
1675 return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true );
1678 /*! Get open file names*/
1679 QStringList LightApp_Application::getOpenFileNames( const QString& initial, const QString& filters,
1680 const QString& caption, QWidget* parent )
1684 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1685 return SUIT_FileDlg::getOpenFileNames( parent, initial, fls, caption, true );
1688 /*!Private SLOT. Update object browser.*/
1689 void LightApp_Application::onRefresh()
1691 updateObjectBrowser( true );
1694 /*!Private SLOT. Support drag-and-drop operation.*/
1695 void LightApp_Application::onDropped( const QList<SUIT_DataObject*>& objects, SUIT_DataObject* parent, int row, Qt::DropAction action )
1697 LightApp_DataObject* parentObj = dynamic_cast<LightApp_DataObject*>( parent );
1701 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>( parentObj->module() );
1703 aModule->dropObjects( objects, parentObj, row, action );
1706 /*!Private SLOT. On preferences.*/
1707 void LightApp_Application::onPreferences()
1709 showPreferences( activeModule() ? activeModule()->moduleName() : tr( "PREF_CATEGORY_SALOME" ) );
1712 /*!Private SLOT. On preferences.*/
1713 void LightApp_Application::showPreferences( const QString& itemText )
1715 QApplication::setOverrideCursor( Qt::WaitCursor );
1717 LightApp_PreferencesDlg* prefDlg = new LightApp_PreferencesDlg( preferences( true ), desktop());
1719 QApplication::restoreOverrideCursor();
1724 preferences()->activateItem( itemText );
1726 if ( ( prefDlg->exec() == QDialog::Accepted || prefDlg->isSaved() ) && resourceMgr() )
1729 resourceMgr()->setValue( "desktop", "geometry", desktop()->storeGeometry() );
1730 resourceMgr()->save();
1733 shortcutMgr()->updateShortcuts();
1739 /*!Protected SLOT. On preferences changed.*/
1740 void LightApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param )
1742 LightApp_Module* sMod = 0;
1743 CAM_Module* mod = module( modName );
1744 if ( mod && mod->inherits( "LightApp_Module" ) )
1745 sMod = (LightApp_Module*)mod;
1748 sMod->preferencesChanged( section, param );
1750 preferencesChanged( section, param );
1751 // emit signal to allow additional preferences changing processing
1752 emit preferenceChanged( modName, section, param );
1755 /*!Remove all windows from study.*/
1756 void LightApp_Application::beforeCloseDoc( SUIT_Study* s )
1758 CAM_Application::beforeCloseDoc( s );
1761 /*!Update actions.*/
1762 void LightApp_Application::updateActions()
1764 updateCommandsStatus();
1770 SUIT_Study* LightApp_Application::createNewStudy()
1772 LightApp_Application::lastStudyId++;
1774 LightApp_Study* aStudy = new LightApp_Study( this );
1776 // Set up processing of major study-related events
1777 connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
1778 connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
1779 connect( aStudy, SIGNAL( saved ( SUIT_Study* ) ), this, SLOT( onStudySaved ( SUIT_Study* ) ) );
1780 connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
1786 Creates window by flag.
1787 \param flag - identificator of window type
1789 QWidget* LightApp_Application::createWindow( const int flag )
1793 SUIT_ResourceMgr* resMgr = resourceMgr();
1795 if ( flag == WT_ObjectBrowser )
1797 SUIT_DataBrowser* ob = new SUIT_DataBrowser( new LightApp_DataObject(), desktop() );
1798 ob->setSortMenuEnabled( true );
1799 ob->setAutoUpdate( true );
1800 if ( resMgr->hasValue( "ObjectBrowser", "auto_hide_search_tool" ) )
1801 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
1803 //ob->setAutoOpenLevel( 1 ); // commented by ASV as a fix to bug IPAL10107
1804 ob->setWindowTitle( tr( "OBJECT_BROWSER" ) );
1805 connect( ob, SIGNAL( requestUpdate() ), this, SLOT( onRefresh() ) );
1807 QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
1808 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
1809 treeModel->setSearcher( this );
1810 treeModel->registerColumn( 0, EntryCol, LightApp_DataObject::EntryId );
1811 treeModel->setAppropriate( EntryCol, Qtx::Toggled );
1813 // Mantis issue 0020136: Drag&Drop in OB
1814 SUIT_ProxyModel* proxyModel = dynamic_cast<SUIT_ProxyModel*>(treeModel);
1816 connect( proxyModel, SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
1817 this, SLOT( onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
1820 // temporary commented
1822 OB_ListView* ob_list = dynamic_cast<OB_ListView*>( const_cast<QListView*>( ob->listView() ) );
1824 ob_list->setColumnMaxWidth( 0, desktop()->width()/4 );
1826 ob->setFilter( new LightApp_OBFilter( selectionMgr() ) );
1829 // Create OBSelector
1830 new LightApp_OBSelector( ob, mySelMgr );
1832 ob->treeView()->header()->setResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
1833 ob->treeView()->header()->moveSection(SUIT_DataObject::NameId,SUIT_DataObject::VisibilityId);
1834 ob->treeView()->setColumnWidth(SUIT_DataObject::VisibilityId, VISIBILITY_COLUMN_WIDTH);
1835 ob->setProperty( "shortcut", QKeySequence( "Alt+Shift+O" ) );
1837 ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1839 #ifndef DISABLE_PYCONSOLE
1840 else if ( flag == WT_PyConsole )
1842 PyConsole_Console* pyCons = new PyConsole_Console( desktop(),new LightApp_PyInterp());
1843 pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
1844 pyCons->setFont(resourceMgr()->fontValue( "PyConsole", "font" ));
1845 pyCons->setIsShowBanner(resourceMgr()->booleanValue( "PyConsole", "show_banner", true ));
1846 pyCons->setProperty( "shortcut", QKeySequence( "Alt+Shift+P" ) );
1849 pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1852 else if ( flag == WT_LogWindow )
1854 LogWindow* logWin = new LogWindow( desktop() );
1855 logWin->setWindowTitle( tr( "LOG_WINDOW" ) );
1856 logWin->setProperty( "shortcut", QKeySequence( "Alt+Shift+L" ) );
1858 logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1864 \return default windows( Object Browser, Python Console )
1865 Adds to map \a aMap.
1867 void LightApp_Application::defaultWindows( QMap<int, int>& aMap ) const
1869 aMap.insert( WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1870 #ifndef DISABLE_PYCONSOLE
1871 aMap.insert( WT_PyConsole, Qt::BottomDockWidgetArea );
1873 // aMap.insert( WT_LogWindow, Qt::DockBottom );
1876 /*!Default view managers*/
1877 void LightApp_Application::defaultViewManagers( QStringList& ) const
1883 \return preferences.
1884 Create preferences, if \a crt = true.
1886 LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const
1891 LightApp_Application* that = (LightApp_Application*)this;
1893 bool toCreate = !_prefs_ && crt;
1896 _prefs_ = new LightApp_Preferences( resourceMgr() );
1897 that->createPreferences( _prefs_ );
1900 that->myPrefs = _prefs_;
1902 connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
1903 this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ) );
1908 SUIT_ResourceMgr* resMgr = resourceMgr();
1910 QList<SUIT_Application*> appList = SUIT_Session::session()->applications();
1911 for ( QList<SUIT_Application*>::iterator appIt = appList.begin(); appIt != appList.end(); ++appIt )
1913 LightApp_Application* app = ::qobject_cast<LightApp_Application*>( *appIt );
1917 QStringList modNameList;
1918 app->modules( modNameList, false );
1920 QMap<QString, QString> iconMap;
1921 app->moduleIconNames( iconMap );
1923 for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it )
1925 if ( !app->isLibExists( *it ) || _prefs_->hasModule( *it ) )
1928 int modId = _prefs_->addPreference( *it );
1929 if ( iconMap.contains( *it ) )
1930 _prefs_->setItemIcon( modId, Qtx::scaleIcon( resMgr->loadPixmap( moduleName( *it ), iconMap[*it], false ), 20 ) );
1934 app->modules( modList );
1935 QListIterator<CAM_Module*> itr( modList );
1936 while ( itr.hasNext() )
1938 LightApp_Module* mod = 0;
1940 CAM_Module* anItem = itr.next();
1941 if ( anItem->inherits( "LightApp_Module" ) )
1942 mod = (LightApp_Module*)anItem;
1944 if ( mod && !_prefs_->hasModule( mod->moduleName() ) )
1946 _prefs_->addPreference( mod->moduleName() );
1947 mod->createPreferences();
1948 that->emptyPreferences( mod->moduleName() );
1952 _prefs_->setItemProperty( "info", tr( "PREFERENCES_NOT_LOADED" ) );
1958 Adds new module to application
1960 void LightApp_Application::moduleAdded( CAM_Module* mod )
1962 CAM_Application::moduleAdded( mod );
1964 LightApp_Module* lightMod = 0;
1965 if ( mod && mod->inherits( "LightApp_Module" ) )
1966 lightMod = (LightApp_Module*)mod;
1968 if ( myPrefs && lightMod && !myPrefs->hasModule( lightMod->moduleName() ))
1970 myPrefs->addPreference( mod->moduleName() );
1971 lightMod->createPreferences();
1972 emptyPreferences( mod->moduleName() );
1976 void LightApp_Application::emptyPreferences( const QString& modName )
1978 QtxPreferenceItem* item = myPrefs->findItem( modName, true );
1979 if ( !item || !item->isEmpty() )
1982 // printf( "---------------------> Modify for empty module.\n" );
1984 QtxPagePrefFrameItem* frm = new QtxPagePrefFrameItem( item->title(), item->parentItem() );
1985 frm->setIcon( item->icon() );
1986 frm->setStretch( false );
1987 item->parentItem()->insertItem( frm, item );
1988 new QtxPagePrefLabelItem( Qt::AlignCenter, tr( "PREFERENCES_NOT_SUPPORTED" ).arg( modName ), frm );
1995 void LightApp_Application::createPreferences( LightApp_Preferences* pref )
2000 QStringList aValuesList;
2001 QList<QVariant> anIndicesList;
2005 // . Top-level "SALOME" preferences group <<start>>
2006 int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
2007 pref->setItemIcon( salomeCat, Qtx::scaleIcon( resourceMgr()->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false ), 20 ) );
2009 // .. "General" preferences tab <<start>>
2010 int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat );
2012 // ... "Language" group <<start>>
2013 int langGroup = pref->addPreference( tr( "PREF_GROUP_LANGUAGE" ), genTab );
2014 pref->setItemProperty( "columns", 2, langGroup );
2015 // .... -> application language
2016 int curLang = pref->addPreference( tr( "PREF_CURRENT_LANGUAGE" ), langGroup,
2017 LightApp_Preferences::Selector, "language", "language" );
2018 QStringList aLangs = SUIT_Session::session()->resourceMgr()->stringValue( "language", "languages", "en" ).split( "," );
2019 QList<QVariant> aIcons;
2020 foreach ( QString aLang, aLangs ) {
2021 aIcons << QPixmap( QString( ":/images/%1" ).arg( aLang ) );
2023 pref->setItemProperty( "strings", aLangs, curLang );
2024 pref->setItemProperty( "icons", aIcons, curLang );
2025 // ... "Language" group <<end>>
2027 // ... "Look and feel" group <<start>>
2028 int lookGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), genTab );
2029 pref->setItemProperty( "columns", 2, lookGroup );
2030 // .... -> show splash-screen
2031 pref->addPreference( tr( "PREF_SHOW_SPLASH" ), lookGroup, LightApp_Preferences::Bool, "launch", "splash" );
2032 // .... -> opaque resize
2033 pref->addPreference( tr( "PREF_OPAQUE_RESIZE" ), lookGroup, LightApp_Preferences::Bool, "desktop", "opaque_resize" );
2034 // .... -> drop-down buttons
2035 pref->addPreference( tr( "PREF_DROP_DOWN_BUTTONS" ), lookGroup, LightApp_Preferences::Bool, "viewers", "drop_down_buttons" );
2036 // ... "Look and feel" group <<end>>
2038 // ... "Study properties" group <<start>>
2039 int studyGroup = pref->addPreference( tr( "PREF_GROUP_STUDY" ), genTab );
2040 pref->setItemProperty( "columns", 2, studyGroup );
2041 // .... -> multi-file save
2042 pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "multi_file" );
2043 // .... -> ascii save mode
2044 pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" );
2045 // .... -> store windows geometry
2046 pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" );
2047 // .... -> auto-save
2048 int autoSaveInterval = pref->addPreference( tr( "PREF_AUTO_SAVE" ), studyGroup,
2049 LightApp_Preferences::IntSpin, "Study", "auto_save_interval" );
2050 pref->setItemProperty( "min", 0, autoSaveInterval );
2051 pref->setItemProperty( "max", 1440, autoSaveInterval );
2052 pref->setItemProperty( "special", tr( "PREF_AUTO_SAVE_DISABLED" ), autoSaveInterval );
2053 // ... "Study properties" group <<end>>
2055 // ... "Help browser" group <<start>>
2056 int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab, LightApp_Preferences::Auto, "ExternalBrowser", "use_external_browser");
2058 QString platform = "winapplication";
2060 QString platform = "application";
2062 // .... -> browser application
2063 int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, LightApp_Preferences::File, "ExternalBrowser", platform );
2064 pref->setItemProperty( "mode", Qtx::PT_OpenFile, apppref );
2065 // .... -> browser parameters
2066 pref->addPreference( tr( "PREF_PARAM" ), extgroup, LightApp_Preferences::String, "ExternalBrowser", "parameters" );
2067 // ... "Help browser" group <<end>>
2069 // ... "Python console properties" group <<start>>
2070 int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab );
2072 pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, LightApp_Preferences::Font, "PyConsole", "font" );
2073 // .... -> show banner
2074 pref->addPreference( tr( "PREF_SHOW_BANNER" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "show_banner" );
2075 // ... "Python console properties" group <<end>>
2077 // ... "MRU" preferences group <<start>>
2078 int mruGroup = pref->addPreference( tr( "PREF_GROUP_MRU" ), genTab, LightApp_Preferences::Auto, "MRU", "show_mru" );
2079 pref->setItemProperty( "columns", 4, mruGroup );
2080 // number of MRU items
2081 int mruVisCount = pref->addPreference( tr( "PREF_MRU_VISIBLE_COUNT" ), mruGroup, LightApp_Preferences::IntSpin,
2082 "MRU", "visible_count" );
2083 pref->setItemProperty( "min", 0, mruVisCount );
2084 pref->setItemProperty( "max", 100, mruVisCount );
2086 int mruLinkType = pref->addPreference( tr( "PREF_MRU_LINK_TYPE" ), mruGroup, LightApp_Preferences::Selector,
2087 "MRU", "link_type" );
2088 aValuesList.clear();
2089 anIndicesList.clear();
2090 aValuesList << tr("PREF_MRU_LINK_AUTO") << tr("PREF_MRU_LINK_SHORT") << tr("PREF_MRU_LINK_FULL");
2091 anIndicesList << 0 << 1 << 2 ;
2092 pref->setItemProperty( "strings", aValuesList, mruLinkType );
2093 pref->setItemProperty( "indexes", anIndicesList, mruLinkType );
2094 // ... "MRU" preferences group <<end>>
2095 // .. "General" preferences tab <<end>>
2097 // .. "OCC viewer" group <<start>>
2098 int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), salomeCat );
2100 // ... "Trihedron" group <<start>>
2101 int occTriGroup = pref->addPreference( tr( "PREF_TRIHEDRON" ), occGroup );
2102 pref->setItemProperty( "columns", 2, occTriGroup );
2103 // .... -> trihedron size
2104 int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occTriGroup,
2105 LightApp_Preferences::DblSpin, "OCCViewer", "trihedron_size" );
2106 pref->setItemProperty( "min", 1.0E-06, occTS );
2107 pref->setItemProperty( "max", 1000, occTS );
2108 // .... -> relative size of trihedron
2109 pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), occTriGroup, LightApp_Preferences::Bool, "OCCViewer", "relative_size" );
2110 // .... -> show static trihedron
2111 pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), occTriGroup, LightApp_Preferences::Bool, "OCCViewer", "show_static_trihedron" );
2112 // ... "Trihedron" group <<end>>
2113 // ... "Background" group <<start>>
2114 int bgGroup = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup );
2115 // pref->setItemProperty( "columns", 2, bgGroup );
2116 aValuesList.clear();
2117 anIndicesList.clear();
2119 QString formats = OCCViewer_Viewer::backgroundData( aValuesList, idList, txtList );
2120 foreach( int gid, idList ) anIndicesList << gid;
2121 // .... -> 3D viewer background
2122 int bgId = pref->addPreference( tr( "PREF_3DVIEWER_BACKGROUND" ), bgGroup,
2123 LightApp_Preferences::Background, "OCCViewer", "background" );
2124 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2125 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2126 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2127 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2128 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2129 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2130 pref->setItemProperty( "custom_enabled", false, bgId );
2131 pref->setItemProperty( "image_formats", formats, bgId );
2132 // .... -> XZ viewer background
2133 bgId = pref->addPreference( tr( "PREF_XZVIEWER_BACKGROUND" ), bgGroup,
2134 LightApp_Preferences::Background, "OCCViewer", "xz_background" );
2135 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2136 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2137 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2138 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2139 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2140 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2141 pref->setItemProperty( "custom_enabled", false, bgId );
2142 pref->setItemProperty( "image_formats", formats, bgId );
2143 // .... -> YZ viewer background
2144 bgId = pref->addPreference( tr( "PREF_YZVIEWER_BACKGROUND" ), bgGroup,
2145 LightApp_Preferences::Background, "OCCViewer", "yz_background" );
2146 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2147 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2148 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2149 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2150 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2151 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2152 pref->setItemProperty( "custom_enabled", false, bgId );
2153 pref->setItemProperty( "image_formats", formats, bgId );
2154 // .... -> XY viewer background
2155 bgId = pref->addPreference( tr( "PREF_XYVIEWER_BACKGROUND" ), bgGroup,
2156 LightApp_Preferences::Background, "OCCViewer", "xy_background" );
2157 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2158 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2159 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2160 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2161 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2162 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2163 pref->setItemProperty( "custom_enabled", false, bgId );
2164 pref->setItemProperty( "image_formats", formats, bgId );
2165 // ... "Background" group <<end>>
2167 // ... -> empty frame (for layout) <<start>>
2168 int occGen = pref->addPreference( "", occGroup, LightApp_Preferences::Frame );
2169 pref->setItemProperty( "margin", 0, occGen );
2170 pref->setItemProperty( "columns", 2, occGen );
2171 // .... -> navigation mode
2172 int occStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), occGen,
2173 LightApp_Preferences::Selector, "OCCViewer", "navigation_mode" );
2174 aValuesList.clear();
2175 anIndicesList.clear();
2176 aValuesList << tr("PREF_STANDARD_STYLE") << tr("PREF_KEYFREE_STYLE");
2177 anIndicesList << 0 << 1;
2178 pref->setItemProperty( "strings", aValuesList, occStyleMode );
2179 pref->setItemProperty( "indexes", anIndicesList, occStyleMode );
2180 // .... -> zooming mode
2181 #if OCC_VERSION_LARGE > 0x0603000A // available only with OCC-6.3-sp11 and higher version
2182 int occZoomingStyleMode = pref->addPreference( tr( "PREF_ZOOMING" ), occGen,
2183 LightApp_Preferences::Selector, "OCCViewer", "zooming_mode" );
2184 aValuesList.clear();
2185 anIndicesList.clear();
2186 aValuesList << tr("PREF_ZOOMING_AT_CENTER") << tr("PREF_ZOOMING_AT_CURSOR");
2187 anIndicesList << 0 << 1;
2188 pref->setItemProperty( "strings", aValuesList, occZoomingStyleMode );
2189 pref->setItemProperty( "indexes", anIndicesList, occZoomingStyleMode );
2191 // ... -> empty frame (for layout) <<end>>
2192 // .. "OCC viewer" group <<end>>
2194 // .. "VTK viewer" group <<start>>
2195 int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), salomeCat ); //viewTab
2197 // ... -> empty frame (for layout) <<start>>
2198 int vtkGen = pref->addPreference( "", vtkGroup, LightApp_Preferences::Frame );
2199 //pref->setItemProperty( "columns", 2, vtkGen );
2200 // .... -> projection mode
2201 int vtkProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), vtkGen,
2202 LightApp_Preferences::Selector, "VTKViewer", "projection_mode" );
2203 aValuesList.clear();
2204 anIndicesList.clear();
2205 aValuesList << tr("PREF_ORTHOGRAPHIC") << tr("PREF_PERSPECTIVE");
2206 anIndicesList << 0 << 1;
2207 pref->setItemProperty( "strings", aValuesList, vtkProjMode );
2208 pref->setItemProperty( "indexes", anIndicesList, vtkProjMode );
2209 // .... -> background
2210 aValuesList.clear();
2211 anIndicesList.clear();
2213 formats = SVTK_Viewer::backgroundData( aValuesList, idList, txtList );
2214 foreach( int gid, idList ) anIndicesList << gid;
2215 bgId = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGen,
2216 LightApp_Preferences::Background, "VTKViewer", "background" );
2217 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2218 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2219 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2220 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2221 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2222 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2223 pref->setItemProperty( "custom_enabled", false, bgId );
2224 pref->setItemProperty( "image_formats", formats, bgId );
2225 // .... -> navigation mode
2226 int vtkStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), vtkGen,
2227 LightApp_Preferences::Selector, "VTKViewer", "navigation_mode" );
2228 aValuesList.clear();
2229 anIndicesList.clear();
2230 aValuesList << tr("PREF_STANDARD_STYLE") << tr("PREF_KEYFREE_STYLE");
2231 anIndicesList << 0 << 1;
2232 pref->setItemProperty( "strings", aValuesList, vtkStyleMode );
2233 pref->setItemProperty( "indexes", anIndicesList, vtkStyleMode );
2234 // .... -> zooming mode
2235 int vtkZoomingStyleMode = pref->addPreference( tr( "PREF_ZOOMING" ), vtkGen,
2236 LightApp_Preferences::Selector, "VTKViewer", "zooming_mode" );
2237 aValuesList.clear();
2238 anIndicesList.clear();
2239 aValuesList << tr("PREF_ZOOMING_AT_CENTER") << tr("PREF_ZOOMING_AT_CURSOR");
2240 anIndicesList << 0 << 1;
2241 pref->setItemProperty( "strings", aValuesList, vtkZoomingStyleMode );
2242 pref->setItemProperty( "indexes", anIndicesList, vtkZoomingStyleMode );
2243 // .... -> speed increment
2244 int vtkSpeed = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED" ), vtkGen,
2245 LightApp_Preferences::IntSpin, "VTKViewer", "speed_value" );
2246 pref->setItemProperty( "min", 1, vtkSpeed );
2247 pref->setItemProperty( "max", 1000, vtkSpeed );
2248 // .... -> speed mode
2249 int vtkSpeedMode = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED_MODE" ), vtkGen,
2250 LightApp_Preferences::Selector, "VTKViewer", "speed_mode" );
2251 aValuesList.clear();
2252 anIndicesList.clear();
2253 aValuesList << tr("PREF_ARITHMETIC") << tr("PREF_GEOMETRICAL");
2254 anIndicesList << 0 << 1;
2255 pref->setItemProperty( "strings", aValuesList, vtkSpeedMode );
2256 pref->setItemProperty( "indexes", anIndicesList, vtkSpeedMode );
2257 // .... -> dynamic pre-selection
2258 pref->addPreference( tr( "PREF_DYNAMIC_PRESELECTION" ), vtkGen, LightApp_Preferences::Bool, "VTKViewer", "dynamic_preselection" );
2259 // ... -> empty frame (for layout) <<end>>
2261 // ... "Trihedron" group <<start>>
2262 int vtkTriGroup = pref->addPreference( tr( "PREF_TRIHEDRON" ), vtkGroup );
2263 pref->setItemProperty( "columns", 2, vtkTriGroup );
2264 // .... -> trihedron size
2265 int vtkTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), vtkTriGroup,
2266 LightApp_Preferences::DblSpin, "VTKViewer", "trihedron_size" );
2267 pref->setItemProperty( "min", 1.0E-06, vtkTS );
2268 pref->setItemProperty( "max", 150, vtkTS );
2269 // .... -> relative size of trihedron
2270 pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), vtkTriGroup, LightApp_Preferences::Bool, "VTKViewer", "relative_size" );
2271 // .... -> static trihedron
2272 pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), vtkTriGroup, LightApp_Preferences::Bool, "VTKViewer", "show_static_trihedron" );
2273 // ... "Trihedron" group <<end>>
2275 // ... space mouse sub-group <<start>>
2276 int vtkSM = pref->addPreference( tr( "PREF_FRAME_SPACEMOUSE" ), vtkGroup, LightApp_Preferences::GroupBox );
2277 //pref->setItemProperty( "columns", 2, vtkSM );
2278 // .... -> decrease speed increment
2279 int spacemousePref1 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_1" ), vtkSM,
2280 LightApp_Preferences::Selector, "VTKViewer",
2281 "spacemouse_func1_btn" );
2282 // .... -> increase speed increment
2283 int spacemousePref2 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_2" ), vtkSM,
2284 LightApp_Preferences::Selector, "VTKViewer",
2285 "spacemouse_func2_btn" );
2286 // .... -> dominant / combined switch
2287 int spacemousePref3 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_3" ), vtkSM,
2288 LightApp_Preferences::Selector, "VTKViewer",
2289 "spacemouse_func5_btn" ); //
2290 aValuesList.clear();
2291 anIndicesList.clear();
2292 aValuesList << tr( "PREF_SPACEMOUSE_BTN_1" ) << tr( "PREF_SPACEMOUSE_BTN_2" ) << tr( "PREF_SPACEMOUSE_BTN_3" );
2293 aValuesList << tr( "PREF_SPACEMOUSE_BTN_4" ) << tr( "PREF_SPACEMOUSE_BTN_5" ) << tr( "PREF_SPACEMOUSE_BTN_6" );
2294 aValuesList << tr( "PREF_SPACEMOUSE_BTN_7" ) << tr( "PREF_SPACEMOUSE_BTN_8" ) << tr( "PREF_SPACEMOUSE_BTN_*" );
2295 aValuesList << tr( "PREF_SPACEMOUSE_BTN_10" ) << tr( "PREF_SPACEMOUSE_BTN_11" );
2296 anIndicesList << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11;
2297 pref->setItemProperty( "strings", aValuesList, spacemousePref1 );
2298 pref->setItemProperty( "indexes", anIndicesList, spacemousePref1 );
2299 pref->setItemProperty( "strings", aValuesList, spacemousePref2 );
2300 pref->setItemProperty( "indexes", anIndicesList, spacemousePref2 );
2301 pref->setItemProperty( "strings", aValuesList, spacemousePref3 );
2302 pref->setItemProperty( "indexes", anIndicesList, spacemousePref3 );
2303 // ... space mouse sub-group <<end>>
2305 // ... avi recording sub-group <<start>>
2306 int vtkRec = pref->addPreference( tr( "PREF_FRAME_RECORDING" ), vtkGroup, LightApp_Preferences::GroupBox );
2307 pref->setItemProperty( "columns", 2, vtkRec );
2308 // .... -> recording mode
2309 int modePref = pref->addPreference( tr( "PREF_RECORDING_MODE" ), vtkRec,
2310 LightApp_Preferences::Selector, "VTKViewer", "recorder_mode" );
2311 aValuesList.clear();
2312 anIndicesList.clear();
2313 aValuesList << tr( "PREF_SKIPPED_FRAMES" ) << tr( "PREF_ALL_DISLPAYED_FRAMES" );
2314 anIndicesList << 0 << 1;
2315 pref->setItemProperty( "strings", aValuesList, modePref );
2316 pref->setItemProperty( "indexes", anIndicesList, modePref );
2318 int fpsPref = pref->addPreference( tr( "PREF_FPS" ), vtkRec,
2319 LightApp_Preferences::DblSpin, "VTKViewer", "recorder_fps" );
2320 pref->setItemProperty( "min", 0.1, fpsPref );
2321 pref->setItemProperty( "max", 100, fpsPref );
2323 int qualityPref = pref->addPreference( tr( "PREF_QUALITY" ), vtkRec,
2324 LightApp_Preferences::IntSpin, "VTKViewer", "recorder_quality" );
2325 pref->setItemProperty( "min", 1, qualityPref );
2326 pref->setItemProperty( "max", 100, qualityPref );
2327 // .... -> progressive mode
2328 pref->addPreference( tr( "PREF_PROGRESSIVE" ), vtkRec,
2329 LightApp_Preferences::Bool, "VTKViewer", "recorder_progressive" );
2330 // ... avi recording sub-group <<end>>
2332 // ... group names sub-group <<start>>
2333 int vtkGN = pref->addPreference( tr( "PREF_FRAME_GROUP_NAMES" ), vtkGroup,
2334 LightApp_Preferences::GroupBox, "VTKViewer", "show_group_names" );
2335 pref->setItemProperty( "columns", 2, vtkGN );
2336 // .... -> text color
2337 pref->addPreference( tr( "PREF_GROUP_NAMES_TEXT_COLOR" ), vtkGN,
2338 LightApp_Preferences::Color, "VTKViewer", "group_names_text_color" );
2339 // .... -> transparency
2340 int transPref = pref->addPreference( tr( "PREF_GROUP_NAMES_TRANSPARENCY" ), vtkGN,
2341 LightApp_Preferences::DblSpin, "VTKViewer", "group_names_transparency" );
2342 pref->setItemProperty( "min", 0.0, transPref );
2343 pref->setItemProperty( "max", 1.0, transPref );
2344 pref->setItemProperty( "step", 0.1, transPref );
2345 // ... -> group names sub-group <<end>>
2346 // .. "VTK viewer" group <<end>>
2348 // .. "Plot2d viewer" group <<start>>
2349 int plot2dGroup = pref->addPreference( tr( "PREF_GROUP_PLOT2DVIEWER" ), salomeCat ); //viewTab
2350 //pref->setItemProperty( "columns", 2, plot2dGroup );
2352 // ... -> show legend
2353 pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dGroup,
2354 LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
2355 // ... -> legend position
2356 int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dGroup,
2357 LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
2358 aValuesList.clear();
2359 anIndicesList.clear();
2360 aValuesList << tr("PREF_LEFT") << tr("PREF_RIGHT") << tr("PREF_TOP") << tr("PREF_BOTTOM");
2361 anIndicesList << 0 << 1 << 2 << 3 ;
2362 pref->setItemProperty( "strings", aValuesList, legendPosition );
2363 pref->setItemProperty( "indexes", anIndicesList, legendPosition );
2364 // ... -> legend font
2365 pref->addPreference( tr( "PREF_LEGEND_FONT" ), plot2dGroup, LightApp_Preferences::Font, "Plot2d", "LegendFont" );
2366 // ... -> curve type
2367 int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dGroup,
2368 LightApp_Preferences::Selector, "Plot2d", "CurveType" );
2369 aValuesList.clear();
2370 anIndicesList.clear();
2371 aValuesList << tr("PREF_POINTS") << tr("PREF_LINES") << tr("PREF_SPLINE");
2372 anIndicesList << 0 << 1 << 2 ;
2373 pref->setItemProperty( "strings", aValuesList, curveType );
2374 pref->setItemProperty( "indexes", anIndicesList, curveType );
2375 // ... -> marker size
2376 int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dGroup,
2377 LightApp_Preferences::IntSpin, "Plot2d", "MarkerSize" );
2378 pref->setItemProperty( "min", 0, markerSize );
2379 pref->setItemProperty( "max", 100, markerSize );
2380 // ... -> horizontal scaling mode
2381 int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dGroup,
2382 LightApp_Preferences::Selector, "Plot2d", "HorScaleMode" );
2383 aValuesList.clear();
2384 anIndicesList.clear();
2385 aValuesList << tr("PREF_LINEAR") << tr("PREF_LOGARITHMIC");
2386 anIndicesList << 0 << 1 ;
2387 pref->setItemProperty( "strings", aValuesList, horScale );
2388 pref->setItemProperty( "indexes", anIndicesList, horScale );
2389 // ... -> vertical scaling mode
2390 int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dGroup,
2391 LightApp_Preferences::Selector, "Plot2d", "VerScaleMode" );
2392 pref->setItemProperty( "strings", aValuesList, verScale );
2393 pref->setItemProperty( "indexes", anIndicesList, verScale );
2394 // ... -> background
2395 pref->addPreference( tr( "PREF_VIEWER_BACKGROUND_COLOR" ), plot2dGroup,
2396 LightApp_Preferences::Color, "Plot2d", "Background" );
2397 // ... -> font color
2398 pref->addPreference( tr( "PREF_FONT_COLOR" ), plot2dGroup, LightApp_Preferences::Color, "Plot2d", "LegendFontColor" );
2399 // ... -> selection font color
2400 pref->addPreference( tr( "PREF_SELECTED_FONT_COLOR" ), plot2dGroup, LightApp_Preferences::Color, "Plot2d", "SelectedLegendFontColor" );
2401 // ... -> selection color
2402 pref->addPreference( tr( "PREF_VIEWER_SELECTION" ), plot2dGroup,
2403 LightApp_Preferences::Color, "Plot2d", "SelectionColor" );
2404 // ... -> errors/deviation colot
2405 pref->addPreference( tr( "PREF_DEVIATION_COLOR" ), plot2dGroup,
2406 LightApp_Preferences::Color, "Plot2d", "DeviationMarkerColor" );
2407 // ... -> deviation markers line size
2408 int deviationMarkerLw = pref->addPreference( tr( "PREF_DEVIATION_MARKER_LW" ), plot2dGroup,
2409 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerLineWidth" );
2410 pref->setItemProperty( "min", 1, deviationMarkerLw );
2411 pref->setItemProperty( "max", 5, deviationMarkerLw );
2412 // ... -> deviation markers tick mark size
2413 int deviationMarkerTs = pref->addPreference( tr( "PREF_DEVIATION_MARKER_TS" ), plot2dGroup,
2414 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerTickSize" );
2415 pref->setItemProperty( "min", 1, deviationMarkerTs );
2416 pref->setItemProperty( "max", 5, deviationMarkerTs );
2417 // .. "Plot2d viewer" group <<end>>
2419 // .. "Directories" preferences tab <<start>>
2420 int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat );
2421 // ... --> quick directories list
2422 int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab );
2423 pref->addPreference( tr( "" ), dirGroup,
2424 LightApp_Preferences::DirList, "FileDlg", "QuickDirList" );
2425 // .. "Directories" preferences tab <<end>>
2427 // .. "Object browser" preferences tab <<start>>
2428 int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
2430 // ... "Search tool" group <<start>>
2431 int stGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SEARCH_TOOL" ), obTab );
2432 // .... --> auto-hide
2433 pref->addPreference( tr( "PREF_AUTO_HIDE_SEARCH_TOOL" ), stGroup, LightApp_Preferences::Bool,
2434 "ObjectBrowser", "auto_hide_search_tool" );
2435 // ... "Search tool" group <<end>>
2437 // ... "Object browser settings" group <<start>>
2438 int objSetGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), obTab );
2439 pref->setItemProperty( "columns", 2, objSetGroup );
2440 // .... -> auto size first column
2441 pref->addPreference( tr( "PREF_AUTO_SIZE_FIRST" ), objSetGroup, LightApp_Preferences::Bool,
2442 "ObjectBrowser", "auto_size_first" );
2443 // .... -> auto size other columns
2444 pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool,
2445 "ObjectBrowser", "auto_size" );
2446 // .... -> resize columns on expand item
2447 pref->addPreference( tr( "PREF_RESIZE_ON_EXPAND_ITEM" ), objSetGroup, LightApp_Preferences::Bool,
2448 "ObjectBrowser", "resize_on_expand_item" );
2449 // .... -> browse to published object
2450 int browsePublished = pref->addPreference( tr( "PREF_BROWSE_TO_THE_PUBLISHED_OBJECT" ), objSetGroup, LightApp_Preferences::Selector,
2451 "ObjectBrowser", "browse_published_object" );
2452 aValuesList.clear();
2453 anIndicesList.clear();
2454 aValuesList << tr( "PREF_BROWSE_NEVER" ) << tr( "PREF_BROWSE_AFTER_APPLY_AND_CLOSE_ONLY" ) << tr( "PREF_BROWSE_ALWAYS" );
2455 anIndicesList << BP_Never << BP_ApplyAndClose << BP_Always;
2456 pref->setItemProperty( "strings", aValuesList, browsePublished );
2457 pref->setItemProperty( "indexes", anIndicesList, browsePublished );
2458 // ... "Object browser settings" group <<end>>
2459 // .. "Object browser" preferences tab <<end>>
2461 // .. "Shortcuts" preferences tab <<start>>
2462 int shortcutTab = pref->addPreference( tr( "PREF_TAB_SHORTCUTS" ), salomeCat );
2463 // ... "Shortcuts settings" group <<start>>
2464 int shortcutGroup = pref->addPreference( tr( "PREF_GROUP_SHORTCUTS" ), shortcutTab );
2465 pref->addPreference( tr( "" ), shortcutGroup,
2466 LightApp_Preferences::ShortcutTree, "shortcuts" );
2467 // ... "Shortcuts settings" group <<end>>
2468 // .. "Shortcuts" preferences tab <<end>>
2469 // . Top-level "SALOME" preferences group <<end>>
2475 Changes appearance of application according to changed preferences
2476 \param sec - section
2477 \param param - name of changed parameter
2479 void LightApp_Application::preferencesChanged( const QString& sec, const QString& param )
2481 SUIT_ResourceMgr* resMgr = resourceMgr();
2485 if ( sec == "viewers" && param == "drop_down_buttons" )
2487 ViewManagerList vmlist = viewManagers();
2488 foreach( SUIT_ViewManager* vm, vmlist )
2490 QVector<SUIT_ViewWindow*> vwlist = vm->getViews();
2491 foreach( SUIT_ViewWindow* vw, vwlist )
2492 if ( vw ) vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
2496 #ifndef DISABLE_OCCVIEWER
2497 if ( sec == QString( "OCCViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )))
2499 double sz = resMgr->doubleValue( sec, "trihedron_size", -1 );
2500 bool relative = resMgr->booleanValue( sec, "relative_size", true );
2501 QList<SUIT_ViewManager*> lst;
2502 viewManagers( OCCViewer_Viewer::Type(), lst );
2503 QListIterator<SUIT_ViewManager*> it( lst );
2504 while ( it.hasNext() && sz >= 0 )
2506 SUIT_ViewModel* vm = it.next()->getViewModel();
2507 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2510 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2511 occVM->setTrihedronSize( sz, relative );
2512 occVM->getAISContext()->UpdateCurrentViewer();
2517 #ifndef DISABLE_OCCVIEWER
2518 if ( sec == QString( "OCCViewer" ) && param == QString( "show_static_trihedron" ) )
2520 bool isVisible = resMgr->booleanValue( "OCCViewer", "show_static_trihedron", true );
2521 QList<SUIT_ViewManager*> lst;
2522 viewManagers( OCCViewer_Viewer::Type(), lst );
2523 QListIterator<SUIT_ViewManager*> it( lst );
2524 while ( it.hasNext() )
2526 SUIT_ViewModel* vm = it.next()->getViewModel();
2527 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2530 OCCViewer_Viewer* occVM = dynamic_cast<OCCViewer_Viewer*>( vm );
2533 occVM->setStaticTrihedronDisplayed( isVisible );
2539 #ifndef DISABLE_OCCVIEWER
2540 if ( sec == QString( "OCCViewer" ) && param == QString( "navigation_mode" ) )
2542 int mode = resMgr->integerValue( "OCCViewer", "navigation_mode", 0 );
2543 QList<SUIT_ViewManager*> lst;
2544 viewManagers( OCCViewer_Viewer::Type(), lst );
2545 QListIterator<SUIT_ViewManager*> it( lst );
2546 while ( it.hasNext() )
2548 SUIT_ViewModel* vm = it.next()->getViewModel();
2549 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2552 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2553 occVM->setInteractionStyle( mode );
2558 #ifndef DISABLE_OCCVIEWER
2559 if ( sec == QString( "OCCViewer" ) && param == QString( "zooming_mode" ) )
2561 int mode = resMgr->integerValue( "OCCViewer", "zooming_mode", 0 );
2562 QList<SUIT_ViewManager*> lst;
2563 viewManagers( OCCViewer_Viewer::Type(), lst );
2564 QListIterator<SUIT_ViewManager*> it( lst );
2565 while ( it.hasNext() )
2567 SUIT_ViewModel* vm = it.next()->getViewModel();
2568 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2571 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2572 occVM->setZoomingStyle( mode );
2577 #ifndef DISABLE_VTKVIEWER
2578 if ( sec == QString( "VTKViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )) )
2580 double sz = resMgr->doubleValue( "VTKViewer", "trihedron_size", -1 );
2581 bool isRelative = resMgr->booleanValue( "VTKViewer", "relative_size", true );
2582 QList<SUIT_ViewManager*> lst;
2583 #ifndef DISABLE_SALOMEOBJECT
2584 viewManagers( SVTK_Viewer::Type(), lst );
2585 QListIterator<SUIT_ViewManager*> it( lst );
2586 while ( it.hasNext() && sz >= 0 )
2588 SUIT_ViewModel* vm = it.next()->getViewModel();
2589 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2592 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2595 vtkVM->setTrihedronSize( sz, isRelative );
2603 #ifndef DISABLE_VTKVIEWER
2604 if ( sec == QString( "VTKViewer" ) && (param == QString( "speed_value" ) || param == QString( "speed_mode" )) )
2606 int speed = resMgr->integerValue( "VTKViewer", "speed_value", 10 );
2607 int mode = resMgr->integerValue( "VTKViewer", "speed_mode", 0 );
2608 QList<SUIT_ViewManager*> lst;
2609 #ifndef DISABLE_SALOMEOBJECT
2610 viewManagers( SVTK_Viewer::Type(), lst );
2611 QListIterator<SUIT_ViewManager*> it( lst );
2612 while ( it.hasNext() )
2614 SUIT_ViewModel* vm = it.next()->getViewModel();
2615 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2618 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2619 if( vtkVM ) vtkVM->setIncrementalSpeed( speed, mode );
2625 #ifndef DISABLE_VTKVIEWER
2626 if ( sec == QString( "VTKViewer" ) && param == QString( "projection_mode" ) )
2628 int mode = resMgr->integerValue( "VTKViewer", "projection_mode", 0 );
2629 QList<SUIT_ViewManager*> lst;
2630 #ifndef DISABLE_SALOMEOBJECT
2631 viewManagers( SVTK_Viewer::Type(), lst );
2632 QListIterator<SUIT_ViewManager*> it( lst );
2633 while ( it.hasNext() )
2635 SUIT_ViewModel* vm = it.next()->getViewModel();
2636 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2639 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2640 if( vtkVM ) vtkVM->setProjectionMode( mode );
2646 #ifndef DISABLE_VTKVIEWER
2647 if ( sec == QString( "VTKViewer" ) && param == QString( "navigation_mode" ) )
2649 int mode = resMgr->integerValue( "VTKViewer", "navigation_mode", 0 );
2650 QList<SUIT_ViewManager*> lst;
2651 #ifndef DISABLE_SALOMEOBJECT
2652 viewManagers( SVTK_Viewer::Type(), lst );
2653 QListIterator<SUIT_ViewManager*> it( lst );
2654 while ( it.hasNext() )
2656 SUIT_ViewModel* vm = it.next()->getViewModel();
2657 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2660 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2661 if( vtkVM ) vtkVM->setInteractionStyle( mode );
2667 #ifndef DISABLE_VTKVIEWER
2668 if ( sec == QString( "VTKViewer" ) && param == QString( "zooming_mode" ) )
2670 int mode = resMgr->integerValue( "VTKViewer", "zooming_mode", 0 );
2671 QList<SUIT_ViewManager*> lst;
2672 #ifndef DISABLE_SALOMEOBJECT
2673 viewManagers( SVTK_Viewer::Type(), lst );
2674 QListIterator<SUIT_ViewManager*> it( lst );
2675 while ( it.hasNext() )
2677 SUIT_ViewModel* vm = it.next()->getViewModel();
2678 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2681 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2682 if( vtkVM ) vtkVM->setZoomingStyle( mode );
2688 #ifndef DISABLE_VTKVIEWER
2689 if ( sec == QString( "VTKViewer" ) && param == QString( "dynamic_preselection" ) )
2691 bool mode = resMgr->booleanValue( "VTKViewer", "dynamic_preselection", true );
2692 QList<SUIT_ViewManager*> lst;
2693 #ifndef DISABLE_SALOMEOBJECT
2694 viewManagers( SVTK_Viewer::Type(), lst );
2695 QListIterator<SUIT_ViewManager*> it( lst );
2696 while ( it.hasNext() )
2698 SUIT_ViewModel* vm = it.next()->getViewModel();
2699 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2702 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2703 if( vtkVM ) vtkVM->setDynamicPreSelection( mode );
2709 #ifndef DISABLE_VTKVIEWER
2710 if ( sec == QString( "VTKViewer" ) && param == QString( "show_static_trihedron" ) )
2712 bool isVisible = resMgr->booleanValue( "VTKViewer", "show_static_trihedron", true );
2713 QList<SUIT_ViewManager*> lst;
2714 #ifndef DISABLE_SALOMEOBJECT
2715 viewManagers( SVTK_Viewer::Type(), lst );
2716 QListIterator<SUIT_ViewManager*> it( lst );
2717 while ( it.hasNext() )
2719 SUIT_ViewModel* vm = it.next()->getViewModel();
2720 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2723 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2726 vtkVM->setStaticTrihedronVisible( isVisible );
2734 #ifndef DISABLE_VTKVIEWER
2735 if ( sec == QString( "VTKViewer" ) && (param == QString( "spacemouse_func1_btn" ) ||
2736 param == QString( "spacemouse_func2_btn" ) ||
2737 param == QString( "spacemouse_func5_btn" ) ) )
2739 int btn1 = resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", 1 );
2740 int btn2 = resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", 2 );
2741 int btn3 = resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", 9 );
2742 QList<SUIT_ViewManager*> lst;
2743 #ifndef DISABLE_SALOMEOBJECT
2744 viewManagers( SVTK_Viewer::Type(), lst );
2745 QListIterator<SUIT_ViewManager*> it( lst );
2746 while ( it.hasNext() )
2748 SUIT_ViewModel* vm = it.next()->getViewModel();
2749 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2752 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2753 if( vtkVM ) vtkVM->setSpacemouseButtons( btn1, btn2, btn3 );
2758 if( sec=="ObjectBrowser" )
2760 SUIT_DataBrowser* ob = objectBrowser();
2764 if ( param=="auto_size_first" )
2766 bool autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
2767 ob->setAutoSizeFirstColumn( autoSizeFirst );
2768 if ( autoSizeFirst )
2769 ob->adjustFirstColumnWidth();
2771 else if ( param=="auto_size" ) {
2772 bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
2773 ob->setAutoSizeColumns(autoSize);
2775 ob->adjustColumnsWidth();
2777 else if ( param=="resize_on_expand_item" ) {
2778 bool resizeOnExpandItem = resMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
2779 ob->setResizeOnExpandItem(resizeOnExpandItem);
2781 else if ( param == "auto_hide_search_tool" ) {
2782 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
2788 if( param=="store_positions" )
2790 if( param=="auto_save_interval" ) {
2791 myAutoSaveTimer->stop();
2792 int autoSaveInterval = resMgr->integerValue( "Study", "auto_save_interval", 0 );
2793 if ( activeStudy() && autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
2797 #ifndef DISABLE_PYCONSOLE
2798 if( sec=="PyConsole" && pythonConsole() )
2800 if ( param=="font" ) {
2801 pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) );
2803 else if ( param=="show_banner" ) {
2804 pythonConsole()->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
2811 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
2813 if ( param == "visible_count" )
2814 mru->setVisibleCount( resMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
2815 else if ( param == "max_count" )
2816 mru->setHistoryCount( resMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
2817 else if ( param == "insert_mode" )
2818 mru->setInsertMode( resMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
2819 else if ( param == "link_type" )
2820 mru->setLinkType( resMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
2821 else if ( param == "show_clear" )
2822 mru->setClearPossible( resMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
2823 else if ( param == "show_mru" )
2824 mru->setVisible( resMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
2827 if ( sec == "language" && param == "language" )
2829 SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LANG_CHANGED" ) );
2831 if ( sec == "desktop" && param == "opaque_resize" ) {
2832 bool opaqueResize = resMgr->booleanValue( "desktop", "opaque_resize", false );
2833 QMainWindow::DockOptions dopts = desktop()->dockOptions();
2834 if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
2835 else dopts &= ~QMainWindow::AnimatedDocks;
2836 desktop()->setDockOptions( dopts );
2837 desktop()->setOpaqueResize( opaqueResize );
2838 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
2839 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
2842 if ( sec == "ExternalBrowser" && param == "use_external_browser" ) {
2843 if ( resMgr->booleanValue("ExternalBrowser", "use_external_browser", false ) )
2845 if(QtxWebBrowser::webBrowser())
2846 QtxWebBrowser::webBrowser()->close();
2850 #ifndef DISABLE_PLOT2DVIEWER
2851 if ( sec == "Plot2d" ) {
2852 if( param == "SelectionColor" ) {
2853 QColor c = resMgr->colorValue( sec, param );
2854 Plot2d_Object::setSelectionColor(c);
2856 else if (param == "SelectedLegendFontColor") {
2857 QColor c = resMgr->colorValue( sec, param );
2858 Plot2d_Object::setHighlightedLegendTextColor(c);
2867 void LightApp_Application::loadPreferences()
2869 CAM_Application::loadPreferences();
2871 SUIT_ResourceMgr* aResMgr = resourceMgr();
2876 static bool mru_load = true;
2879 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
2881 mru->setVisible( aResMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
2882 mru->setVisibleCount( aResMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
2883 mru->setHistoryCount( aResMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
2884 mru->setInsertMode( aResMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
2885 mru->setLinkType( aResMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
2886 mru->setClearPossible( aResMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
2887 mru->loadLinks( aResMgr, "MRU" );
2893 QStringList mods = aResMgr->parameters( "windows_geometry" );
2894 for ( QStringList::const_iterator it = mods.begin(); it != mods.end(); ++it )
2897 if ( aResMgr->value( "windows_geometry", *it, arr ) )
2898 myWinGeom.insert( *it, arr );
2902 mods = aResMgr->parameters( "windows_visibility" );
2903 for ( QStringList::const_iterator itr = mods.begin(); itr != mods.end(); ++itr )
2906 if ( aResMgr->value( "windows_visibility", *itr, arr ) )
2907 myWinVis.insert( *itr, arr );
2911 desktop()->retrieveGeometry( aResMgr->stringValue( "desktop", "geometry" ) );
2912 bool opaqueResize = aResMgr->booleanValue( "desktop", "opaque_resize", false );
2913 QMainWindow::DockOptions dopts = desktop()->dockOptions();
2914 if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
2915 else dopts &= ~QMainWindow::AnimatedDocks;
2916 desktop()->setDockOptions( dopts );
2917 desktop()->setOpaqueResize( opaqueResize );
2918 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
2919 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
2926 void LightApp_Application::savePreferences()
2928 CAM_Application::savePreferences();
2930 saveDockWindowsState();
2932 SUIT_ResourceMgr* aResMgr = resourceMgr();
2937 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
2939 mru->saveLinks( aResMgr, "MRU" );
2941 for ( WinGeom::const_iterator it = myWinGeom.begin(); it != myWinGeom.end(); ++it )
2942 aResMgr->setValue( "windows_geometry", it.key(), it.value() );
2944 for ( WinVis::const_iterator itr = myWinVis.begin(); itr != myWinVis.end(); ++itr )
2945 aResMgr->setValue( "windows_visibility", itr.key(), itr.value() );
2948 aResMgr->setValue( "desktop", "geometry", desktop()->storeGeometry() );
2954 Updates desktop title
2956 void LightApp_Application::updateDesktopTitle()
2958 QString aTitle = applicationName();
2959 QString aVer = applicationVersion();
2960 if ( !aVer.isEmpty() )
2961 aTitle += QString( " " ) + aVer;
2963 if ( activeStudy() ) {
2964 QString sName = SUIT_Tools::file( activeStudy()->studyName().trimmed(), false );
2965 aTitle += QString( " - [%1]" ).arg( sName );
2968 desktop()->setWindowTitle( aTitle );
2972 \brief Get map of the operations which can be performed
2973 on the module activation.
2975 The method should return the map of the kind \c {<id>:<name>}
2976 where \c <id> is an integer identifier of the operation and
2977 \c <name> is a title for the button to be added to the
2978 dialog box. After user selects the required operation by the
2979 clicking the corresponding button in the dialog box, its identifier
2980 is passed to the moduleActionSelected() method to process
2983 \return map of the operations
2984 \sa moduleActionSelected()
2986 QMap<int, QString> LightApp_Application::activateModuleActions() const
2988 QMap<int, QString> opmap;
2989 opmap.insert( NewStudyId, tr( "ACTIVATE_MODULE_OP_NEW" ) );
2990 opmap.insert( OpenStudyId, tr( "ACTIVATE_MODULE_OP_OPEN" ) );
2995 \brief Called when the used selectes required operation chosen
2996 from "Activate module" dialog box.
2998 Performs the required operation according to the user choice.
3000 \param id operation identifier
3001 \sa activateModuleActions()
3003 void LightApp_Application::moduleActionSelected( const int id )
3018 Updates windows after close document
3020 void LightApp_Application::afterCloseDoc()
3024 CAM_Application::afterCloseDoc();
3028 Updates actions of active module
3030 void LightApp_Application::updateModuleActions()
3033 if ( activeModule() ) {
3034 modName = activeModule()->moduleName();
3035 if ( !isModuleAccessible( modName ) ) {
3036 QList<SUIT_Application*> apps = SUIT_Session::session()->applications();
3037 foreach( SUIT_Application* app, apps ) {
3038 LightApp_Application* lapp = dynamic_cast<LightApp_Application*>( app );
3039 if ( lapp && lapp != this )
3040 lapp->removeModuleAction( modName );
3045 LightApp_ModuleAction* moduleAction =
3046 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
3048 moduleAction->setActiveModule( modName );
3051 void LightApp_Application::removeModuleAction( const QString& modName )
3053 LightApp_ModuleAction* moduleAction =
3054 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
3056 moduleAction->removeModule( modName );
3060 Gets current windows.
3061 \param winMap - output current windows map.
3063 void LightApp_Application::currentWindows( QMap<int, int>& winMap ) const
3066 if ( !activeStudy() )
3069 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
3070 ((LightApp_Module*)activeModule())->windows( winMap );
3072 defaultWindows( winMap );
3076 Gets current view managers.
3077 \param lst - output current view managers list.
3079 void LightApp_Application::currentViewManagers( QStringList& lst ) const
3082 if ( !activeStudy() )
3085 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
3086 ((LightApp_Module*)activeModule())->viewManagers( lst );
3088 defaultViewManagers( lst );
3094 void LightApp_Application::updateWindows()
3096 QMap<int, int> winMap;
3097 currentWindows( winMap );
3099 if ( activeStudy() )
3101 for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
3103 if ( !dockWindow( it.key() ) )
3104 getWindow( it.key() );
3108 for ( WinMap::ConstIterator it = myWin.begin(); it != myWin.end(); ++it )
3110 QWidget* wid = it.value();
3111 if ( activeStudy() )
3112 wid->setVisible( winMap.contains( it.key() ) );
3117 if ( activeStudy() )
3118 loadDockWindowsState();
3124 Updates view managers
3126 void LightApp_Application::updateViewManagers()
3129 currentViewManagers( lst );
3131 for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
3132 getViewManager( *it, true );
3136 Loads windows geometry
3138 void LightApp_Application::loadDockWindowsState()
3143 bool store = resourceMgr()->booleanValue( "Study", "store_positions", true );
3148 if ( activeModule() )
3149 modName = activeModule()->name();
3151 if ( myWinGeom.contains( modName ) )
3152 desktop()->restoreState( myWinGeom[modName] );
3154 if ( !myWinVis.contains( modName ) )
3157 QMap<QString, bool> tbMap, dwMap;
3158 dockWindowsState( myWinVis[modName], tbMap, dwMap );
3160 QList<QToolBar*> tbList = qFindChildren<QToolBar*>( desktop() );
3161 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit )
3163 QToolBar* tb = *tit;
3165 QObject* po = Qtx::findParent( tb, "QMainWindow" );
3166 if ( po != desktop() )
3169 if ( tbMap.contains( tb->objectName() ) )
3170 tb->setVisible( tbMap[tb->objectName()] );
3173 QList<QDockWidget*> dwList = qFindChildren<QDockWidget*>( desktop() );
3174 for ( QList<QDockWidget*>::iterator dit = dwList.begin(); dit != dwList.end(); ++dit )
3176 QDockWidget* dw = *dit;
3178 QObject* po = Qtx::findParent( dw, "QMainWindow" );
3179 if ( po != desktop() )
3182 if ( dwMap.contains( dw->objectName() ) )
3183 dw->setVisible( dwMap[dw->objectName()] );
3188 Saves windows geometry
3190 void LightApp_Application::saveDockWindowsState()
3195 bool store = resourceMgr()->booleanValue( "Study", "store_positions", true );
3200 if ( activeModule() )
3201 modName = activeModule()->name();
3203 myWinGeom.insert( modName, desktop()->saveState() );
3206 if ( myWinVis.contains( modName ) )
3207 visArr = myWinVis[modName];
3209 QMap<QString, bool> tbMap, dwMap;
3210 dockWindowsState( visArr, tbMap, dwMap );
3212 QList<QToolBar*> tbList = qFindChildren<QToolBar*>( desktop() );
3213 for ( QList<QToolBar*>::iterator it = tbList.begin(); it != tbList.end(); ++it )
3216 tbMap.insert( tb->objectName(), tb->toggleViewAction()->isChecked() );
3219 QList<QDockWidget*> dwList = qFindChildren<QDockWidget*>( desktop() );
3220 for ( QList<QDockWidget*>::iterator it = dwList.begin(); it != dwList.end(); ++it )
3222 QDockWidget* wid = *it;
3223 dwMap.insert( wid->objectName(), wid->toggleViewAction()->isChecked() );
3226 visArr = dockWindowsState( tbMap, dwMap );
3228 myWinVis.insert( modName, visArr );
3231 QByteArray LightApp_Application::dockWindowsState( const QMap<QString, bool>& tb, const QMap<QString, bool>& dw ) const
3234 QDataStream stream( &visArr, QIODevice::WriteOnly );
3236 stream << (uchar)ToolBarMarker;
3237 stream << tb.size();
3238 for ( QMap<QString, bool>::const_iterator tit = tb.begin(); tit != tb.end(); ++tit )
3240 stream << tit.key();
3241 stream << (uchar)( tit.value() ? 1 : 0 );
3244 stream << (uchar)DockWidgetMarker;
3245 stream << dw.size();
3246 for ( QMap<QString, bool>::const_iterator wit = dw.begin(); wit != dw.end(); ++wit )
3248 stream << wit.key();
3249 stream << (uchar)( wit.value() ? 1 : 0 );
3255 void LightApp_Application::dockWindowsState( const QByteArray& arr, QMap<QString, bool>& tb, QMap<QString, bool>& dw ) const
3260 QByteArray visArr = arr;
3261 QDataStream stream( &visArr, QIODevice::ReadOnly );
3265 if ( marker != ToolBarMarker )
3270 for ( int i = 0; i < lines; ++i )
3273 stream >> objectName;
3276 tb.insert( objectName, shown );
3280 if ( marker != DockWidgetMarker )
3284 for ( int j = 0; j < lines; ++j )
3287 stream >> objectName;
3290 dw.insert( objectName, shown );
3295 Adds icon names for modules
3297 void LightApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) const
3301 SUIT_ResourceMgr* resMgr = resourceMgr();
3305 QStringList modList;
3306 modules( modList, false );
3308 for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )
3310 QString modName = *it;
3311 QString modIntr = moduleName( modName );
3312 QString modIcon = resMgr->stringValue( modIntr, "icon", QString() );
3314 if ( modIcon.isEmpty() )
3317 if ( SUIT_Tools::extension( modIcon ).isEmpty() )
3318 modIcon += QString( ".png" );
3320 iconMap.insert( modName, modIcon );
3325 Inserts items in popup, which necessary for current application
3327 void LightApp_Application::contextMenuPopup( const QString& type, QMenu* thePopup, QString& title )
3330 LightApp_SelectionMgr* selMgr = LightApp_Application::selectionMgr();
3331 bool cacheIsOn = selMgr->isSelectionCacheEnabled();
3332 selMgr->setSelectionCacheEnabled( true );
3334 SUIT_DataBrowser* ob = objectBrowser();
3336 CAM_Application::contextMenuPopup( type, thePopup, title );
3338 if ( ob && type == ob->popupClientType() ) {
3339 thePopup->addSeparator();
3340 QAction* a = thePopup->addAction( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
3341 if ( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) )
3342 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) );
3345 if ( selMgr && ob ) {
3346 SALOME_ListIO selected;
3347 selMgr->selectedObjects( selected );
3348 if(selected.Extent() == 1){
3349 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3350 SUIT_DataObject* obj = findObject(anIObject->getEntry());
3351 if(obj && obj->renameAllowed()) {
3352 QAction* a = new QAction(tr("MEN_RENAME_OBJ"), thePopup);
3353 connect( a, SIGNAL( triggered(bool) ), ob, SLOT( onStartEditing() ) );
3354 if ( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) )
3355 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) );
3357 QList<QAction*> acts = thePopup->actions();
3358 QAction* firstAction = acts.count() > 0 ? acts.first() : 0;
3359 thePopup->insertAction(firstAction,a);
3364 selMgr->setSelectionCacheEnabled( cacheIsOn );
3370 void LightApp_Application::createEmptyStudy()
3372 CAM_Application::createEmptyStudy();
3374 if ( objectBrowser() )
3375 objectBrowser()->updateTree();
3377 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
3378 if ( aResMgr && activeStudy() ) {
3379 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
3380 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
3385 void LightApp_Application::setDesktop( SUIT_Desktop* desk )
3387 CAM_Application::setDesktop( desk );
3390 connect( desk, SIGNAL( message( const QString& ) ),
3391 this, SLOT( onDesktopMessage( const QString& ) ), Qt::UniqueConnection );
3397 \param mod - module to be activated
3399 bool LightApp_Application::activateModule( CAM_Module* mod )
3401 bool res = CAM_Application::activateModule( mod );
3403 if ( objectBrowser() )
3404 objectBrowser()->updateTree();
3410 \return keyborad accelerators manager object
3412 SUIT_Accel* LightApp_Application::accel() const
3418 Removes dead widget container from map
3420 void LightApp_Application::onWCDestroyed( QObject* ob )
3422 // remove destroyed widget container from windows map
3423 for ( WinMap::ConstIterator itr = myWin.begin(); itr != myWin.end(); ++itr )
3425 if ( itr.value() != ob )
3428 int key = itr.key();
3429 myWin.remove( key );
3434 void LightApp_Application::onMRUActivated( const QString& name )
3436 SUIT_Session* s = SUIT_Session::session();
3437 if ( s && s->activeApplication() == this )
3441 void LightApp_Application::onStylePreferences()
3443 Style_PrefDlg dlg( desktop() );
3446 resourceMgr()->setValue( "Style", "use_salome_style", Style_Salome::isActive() );
3449 void LightApp_Application::onFullScreen(){
3450 if(myScreenHelper) {
3451 if(desktop()->isFullScreen())
3452 myScreenHelper->switchToNormalScreen();
3454 myScreenHelper->switchToFullScreen();
3459 Connects just added view manager
3461 void LightApp_Application::addViewManager( SUIT_ViewManager* vm )
3463 connect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
3464 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
3465 STD_Application::addViewManager( vm );
3469 Remove view manager from memory
3471 void LightApp_Application::removeViewManager( SUIT_ViewManager* vm )
3473 disconnect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
3474 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
3475 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
3477 aStudy->removeViewMgr(vm->getGlobalId());
3479 LightApp_SelectionMgr* selMgr = selectionMgr();
3480 QList<SUIT_Selector*> selectors;
3481 selMgr->selectors( selectors );
3482 foreach( SUIT_Selector* selector, selectors ) {
3483 if ( selector->owner() == vm->getViewModel() ) {
3488 STD_Application::removeViewManager( vm );
3490 // IPAL22894: Crash on closing OCC view
3496 Renames active window of desktop
3498 void LightApp_Application::onRenameWindow()
3503 QWidget* w = desktop()->activeWindow();
3508 QString name = QInputDialog::getText( w, tr( "TOT_RENAME" ), tr( "PRP_RENAME" ), QLineEdit::Normal, w->windowTitle(), &ok );
3509 if( ok && !name.isEmpty() )
3510 w->setWindowTitle( name );
3514 Closes active window of desktop
3516 void LightApp_Application::onCloseWindow()
3521 QWidget* w = desktop()->activeWindow();
3529 Closes all windows of desktop
3531 void LightApp_Application::onCloseAllWindow()
3533 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
3537 QList<SUIT_ViewWindow*> wndList = desk->windows();
3538 SUIT_ViewWindow* wnd;
3539 foreach( wnd, wndList )
3547 Groups all windows of desktop
3549 void LightApp_Application::onGroupAllWindow()
3551 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
3555 QtxWorkstack* wgStack = desk->workstack();
3561 \return if the library of module exists
3562 \param moduleTitle - title of module
3564 bool LightApp_Application::isLibExists( const QString& moduleTitle ) const
3566 if( moduleTitle.isEmpty() )
3569 QString lib = moduleLibrary( moduleTitle );
3571 //abd: changed libSalomePyQtGUI to SalomePyQtGUI for WIN32
3572 bool isPythonModule = lib.contains("SalomePyQtGUI");
3573 bool isPythonLightModule = lib.contains("libSalomePyQtGUILight");
3577 paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
3579 paths = QString(::getenv( "LD_LIBRARY_PATH" )).split( ":", QString::SkipEmptyParts );
3582 bool isLibFound = false;
3583 QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
3584 for( ; anIt!=aLast; anIt++ )
3586 QFileInfo inf( Qtx::addSlash( *anIt ) + lib );
3597 INFOS( "****************************************************************" << std::endl
3598 << "* Warning: library " << lib.toLatin1().constData() << " cannot be found" << std::endl
3599 << "* Module " << moduleTitle.toLatin1().constData() << " will not be available in GUI mode" << std::endl
3600 << "****************************************************************" << std::endl );
3602 else if ( !isPythonModule && !isPythonLightModule)
3605 if ( isPythonModule || isPythonLightModule)
3607 QString pylib = moduleName( moduleTitle ) + QString(".py");
3608 QString pylibgui = moduleName( moduleTitle ) + QString("GUI.py");
3610 // Check the python library
3612 paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
3614 paths = QString(::getenv( "PYTHONPATH" )).split( ":", QString::SkipEmptyParts );
3616 bool isPyLib = false, isPyGuiLib = false;
3617 QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
3618 for( ; anIt!=aLast; anIt++ )
3620 QFileInfo inf( Qtx::addSlash( *anIt ) + pylib );
3621 QFileInfo infgui( Qtx::addSlash( *anIt ) + pylibgui );
3623 if(!isPythonLightModule)
3624 if( !isPyLib && inf.exists() )
3627 if( !isPyGuiLib && infgui.exists() )
3630 if ((isPyLib || isPythonLightModule ) && isPyGuiLib && isLibFound)
3634 printf( "****************************************************************\n" );
3635 printf( "* Warning: python library for %s cannot be found:\n", moduleTitle.toLatin1().constData() );
3637 printf( "* No module named %s\n", moduleName( moduleTitle ).toLatin1().constData() );
3639 printf( "* No module named %s\n", (moduleName( moduleTitle ) + QString("GUI")).toLatin1().constData() );
3640 printf( "****************************************************************\n" );
3647 \return default name for an active study
3649 void LightApp_Application::setDefaultStudyName( const QString& theName )
3651 QStringList anInfoList;
3652 modules( anInfoList, false );
3654 LightApp_Study* aStudy = (LightApp_Study*)activeStudy();
3655 if( anInfoList.count() == 1 && // to avoid a conflict between different modules
3656 !aStudy->isSaved() )
3658 aStudy->setStudyName( theName );
3659 updateDesktopTitle();
3664 Custom event handler
3666 bool LightApp_Application::event( QEvent* e )
3668 if( e && e->type()==2000 )
3670 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
3671 QString* d = ( QString* )ce->data();
3672 if( SUIT_MessageBox::question(0, tr("WRN_WARNING"),
3674 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
3675 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
3676 showPreferences( tr( "PREF_APP" ) );
3681 return CAM_Application::event( e );
3684 /*! Check data object */
3685 bool LightApp_Application::checkDataObject(LightApp_DataObject* theObj)
3689 bool isSuitable = !theObj->entry().isEmpty() &&
3690 !theObj->componentDataType().isEmpty() &&
3691 !theObj->name().isEmpty();
3698 int LightApp_Application::openChoice( const QString& aName )
3700 int choice = CAM_Application::openChoice( aName );
3702 if ( choice == OpenExist ) // The document is already open.
3704 // Do you want to reload it?
3705 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "QUE_DOC_ALREADYOPEN" ).arg( aName ),
3706 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No ) == SUIT_MessageBox::Yes )
3707 choice = OpenReload;
3713 bool LightApp_Application::openAction( const int choice, const QString& aName )
3720 STD_Application* app = 0;
3721 SUIT_Session* session = SUIT_Session::session();
3722 QList<SUIT_Application*> appList = session->applications();
3723 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !app; ++it )
3725 if ( (*it)->activeStudy() && (*it)->activeStudy()->studyName() == aName )
3726 app = ::qobject_cast<STD_Application*>( *it );
3731 app->onCloseDoc( false );
3732 appList = session->applications();
3733 STD_Application* other = 0;
3734 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !other; ++it )
3735 other = ::qobject_cast<STD_Application*>( *it );
3738 res = other->onOpenDoc( aName );
3743 res = CAM_Application::openAction( choice, aName );
3750 QStringList LightApp_Application::viewManagersTypes() const
3752 QStringList aTypesList;
3753 aTypesList += myUserWmTypes;
3754 #ifndef DISABLE_GLVIEWER
3755 aTypesList<<GLViewer_Viewer::Type();
3757 #ifndef DISABLE_PLOT2DVIEWER
3758 aTypesList<<Plot2d_Viewer::Type();
3760 #ifndef DISABLE_QXGRAPHVIEWER
3761 aTypesList<<QxScene_Viewer::Type();
3763 #ifndef DISABLE_OCCVIEWER
3764 aTypesList<<OCCViewer_Viewer::Type();
3766 #ifndef DISABLE_VTKVIEWER
3767 #ifndef DISABLE_SALOMEOBJECT
3768 aTypesList<<SVTK_Viewer::Type();
3770 aTypesList<<VTKViewer_Viewer::Type();
3776 * Removes all view managers of known types
3777 * Other view managers are ignored
3779 void LightApp_Application::clearKnownViewManagers()
3781 QStringList aTypesList = viewManagersTypes();
3782 QList<SUIT_ViewManager*> aMgrList;
3783 viewManagers( aMgrList );
3784 foreach (SUIT_ViewManager* aMgr, aMgrList) {
3785 if (aTypesList.contains(aMgr->getType()))
3786 removeViewManager(aMgr);
3791 Copy of current selection
3793 void LightApp_Application::onCopy()
3795 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
3801 Paste of current data in clipboard
3803 void LightApp_Application::onPaste()
3805 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
3811 Browse (i.e. set focus on) the published objects
3812 \param theIsApplyAndClose - flag indicating that the dialog for creating objects
3813 has been accepted by Ok (or Apply & Close) button
3814 \param theIsOptimizedBrowsing - flag switching to optimized browsing mode
3815 (to select the first published object only)
3816 \return entry of the selected object
3818 QString LightApp_Application::browseObjects( const QStringList& theEntryList,
3819 const bool theIsApplyAndClose,
3820 const bool theIsOptimizedBrowsing )
3823 if( SUIT_ResourceMgr* aResourceMgr = resourceMgr() )
3825 int aBrowsePolicy = aResourceMgr->integerValue( "ObjectBrowser", "browse_published_object", (int)BP_Never );
3826 switch( aBrowsePolicy )
3830 case BP_ApplyAndClose:
3831 if( !theIsApplyAndClose )
3839 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
3843 SUIT_DataBrowser* anOB = objectBrowser();
3847 SUIT_AbstractModel* aModel = dynamic_cast<SUIT_AbstractModel*>( anOB->model() );
3851 QStringListIterator anIter( theEntryList );
3852 if( theIsOptimizedBrowsing )
3854 // go to the last entry
3856 if( anIter.hasPrevious() )
3860 // scroll to each entry in the list
3861 // (in optimized mode - to the last entry only)
3863 LightApp_DataObject* anObject = 0;
3864 while( anIter.hasNext() )
3866 anEntry = anIter.next();
3867 if( !anEntry.isEmpty() )
3869 anObject = aStudy->findObjectByEntry( anEntry );
3872 QModelIndex anIndex = aModel->index( anObject );
3873 anOB->treeView()->scrollTo( anIndex );
3878 // always select the last object
3879 if( anObject && !anEntry.isEmpty() )
3881 QList<SUIT_Selector*> aSelectorList;
3882 selectionMgr()->selectors( "ObjectBrowser", aSelectorList );
3883 if( !aSelectorList.isEmpty() )
3885 if( LightApp_OBSelector* aSelector = dynamic_cast<LightApp_OBSelector*>( aSelectorList.first() ) )
3887 bool anIsAutoBlock = aSelector->autoBlock();
3889 // temporarily disable auto block, to emit LightApp_SelectionMgr::currentSelectionChanged() signal
3890 aSelector->setAutoBlock( false );
3892 SUIT_DataOwnerPtrList aList;
3893 #ifndef DISABLE_SALOMEOBJECT
3894 Handle(SALOME_InteractiveObject) aSObj = new SALOME_InteractiveObject
3895 ( anObject->entry().toLatin1().constData(),
3896 anObject->componentDataType().toLatin1().constData(),
3897 anObject->name().toLatin1().constData() );
3898 LightApp_DataOwner* owner = new LightApp_DataOwner( aSObj );
3900 LightApp_DataOwner* owner = new LightApp_DataOwner( anEntry );
3903 aList.append( owner );
3904 selectionMgr()->setSelected( aList );
3907 // restore auto block flag
3908 aSelector->setAutoBlock( anIsAutoBlock );
3916 SUIT_DataObject* LightApp_Application::findObject( const QString& id ) const
3918 LightApp_Study* study = dynamic_cast<LightApp_Study*>( activeStudy() );
3919 return study ? study->findObjectByEntry( id ) : 0;
3923 Checks that an object can be renamed.
3924 \param entry entry of the object
3925 \brief Return \c true if object can be renamed
3927 bool LightApp_Application::renameAllowed( const QString& /*entry*/) const {
3932 Rename object by entry.
3933 \param entry entry of the object
3934 \param name new name of the object
3935 \brief Return \c true if rename operation finished successfully, \c false otherwise.
3937 bool LightApp_Application::renameObject( const QString& entry, const QString& ) {
3941 /*! Process standard messages from desktop */
3942 void LightApp_Application::onDesktopMessage( const QString& message )
3944 const QString sectionSeparator = "/";
3946 if ( message.toLower() == "updateobjectbrowser" ||
3947 message.toLower() == "updateobjbrowser" ) {
3948 // update object browser
3949 updateObjectBrowser();
3952 QStringList data = message.split( sectionSeparator );
3953 if ( data.count() > 1 ) {
3954 QString msgType = data[0].trimmed();
3955 LightApp_Module* sMod = 0;
3956 CAM_Module* mod = module( msgType );
3958 mod = module( moduleTitle( msgType ) );
3959 if ( mod && mod->inherits( "LightApp_Module" ) )
3960 sMod = (LightApp_Module*)mod;
3962 if ( msgType.toLower() == "preferences" ) {
3963 // requested preferences change: should be given as "preferences/<section>/<name>/<value>"
3964 // for example "preferences/Study/multi_file_dump/true"
3965 if ( data.count() > 3 ) {
3966 QString section = data[1].trimmed();
3967 QString param = data[2].trimmed();
3968 QString value = QStringList( data.mid(3) ).join( sectionSeparator );
3969 resourceMgr()->setValue( section, param, value );
3973 // received message for the module
3974 QString msg = QStringList( data.mid(1) ).join( sectionSeparator );
3975 sMod->message( msg );