1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File: LightApp_Application.cxx
24 // Created: 6/20/2005 18:39:45 PM
25 // Author: Natalia Donis
28 // E.A. : On windows with python 2.6, there is a conflict
29 // E.A. : between pymath.h and Standard_math.h which define
30 // E.A. : some same symbols : acosh, asinh, ...
31 #include <Standard_math.hxx>
32 #ifndef DISABLE_PYCONSOLE
37 #ifndef DISABLE_PYCONSOLE
38 #include "LightApp_PyInterp.h" // WARNING! This include must be the first!
39 #include <PyConsole_Console.h>
42 #include "LightApp_Application.h"
43 #include "LightApp_Module.h"
44 #include "LightApp_DataModel.h"
45 #include "LightApp_Study.h"
46 #include "LightApp_Preferences.h"
47 #include "LightApp_PreferencesDlg.h"
48 #include "LightApp_ModuleDlg.h"
49 #include "LightApp_AboutDlg.h"
50 #include "LightApp_ModuleAction.h"
51 // temporary commented
52 #include "LightApp_EventFilter.h"
53 #include "LightApp_OBSelector.h"
54 #include "LightApp_SelectionMgr.h"
55 #include "LightApp_DataObject.h"
56 #include "LightApp_WgViewModel.h"
57 #include "LightApp_FullScreenHelper.h"
60 #include <GUI_version.h>
61 #include <Basics_OCCTVersion.hxx>
63 #include <SALOME_Event.h>
65 #include <Style_Salome.h>
66 #include <Style_PrefDlg.h>
68 #include <CAM_Module.h>
69 #include <CAM_DataModel.h>
70 #include <CAM_Study.h>
71 #include <STD_TabDesktop.h>
73 #include <SUIT_DataBrowser.h>
74 #include <SUIT_Session.h>
75 #include <SUIT_Study.h>
76 #include <SUIT_FileDlg.h>
77 #include <SUIT_ResourceMgr.h>
78 #include <SUIT_ShortcutMgr.h>
79 #include <SUIT_Tools.h>
80 #include <SUIT_Accel.h>
81 #include <SUIT_MessageBox.h>
82 #include <SUIT_ViewWindow.h>
85 #include <QtxToolBar.h>
86 #include <QtxTreeView.h>
87 #include <QtxMRUAction.h>
88 #include <QtxDockAction.h>
89 #include <QtxDockWidget.h>
90 #include <QtxActionToolMgr.h>
91 #include <QtxSearchTool.h>
92 #include <QtxWorkstack.h>
94 #include <QtxWebBrowser.h>
96 #include <LogWindow.h>
98 #ifndef DISABLE_GLVIEWER
99 #include <GLViewer_Viewer.h>
100 #include <GLViewer_ViewManager.h>
101 #include "LightApp_GLSelector.h"
104 #ifndef DISABLE_PLOT2DVIEWER
105 #include <Plot2d_ViewManager.h>
106 #include <Plot2d_ViewModel.h>
107 #include <Plot2d_ViewWindow.h>
108 #include <Plot2d_ViewFrame.h>
109 #include "LightApp_Plot2dSelector.h"
110 #ifndef DISABLE_SALOMEOBJECT
111 #include <SPlot2d_ViewModel.h>
113 #include <Plot2d_ViewModel.h>
117 #ifndef DISABLE_OCCVIEWER
118 #include <OCCViewer_ViewManager.h>
119 #include <OCCViewer_ViewFrame.h>
120 #ifndef DISABLE_SALOMEOBJECT
121 #include <SOCC_ViewModel.h>
123 #include <OCCViewer_ViewModel.h>
125 #include "LightApp_OCCSelector.h"
128 #ifndef DISABLE_VTKVIEWER
129 #ifndef DISABLE_SALOMEOBJECT
130 #include <SVTK_ViewModel.h>
131 #include <SVTK_ViewManager.h>
132 #include "LightApp_VTKSelector.h"
134 #include <VTKViewer_ViewModel.h>
135 #include <VTKViewer_ViewManager.h>
137 #include <VTKViewer_ViewModel.h>
140 #ifndef DISABLE_QXGRAPHVIEWER
141 #include <QxScene_ViewManager.h>
142 #include <QxScene_ViewModel.h>
143 #include <QxScene_ViewWindow.h>
147 #define VISIBILITY_COLUMN_WIDTH 25
153 #include <QStringList>
155 #include <QApplication>
157 #include <QStatusBar>
159 #include <QObjectList>
161 #include <QInputDialog>
162 #include <QFontDatabase>
164 #include <QByteArray>
168 #include <QHeaderView>
173 #include <utilities.h>
175 #define FIRST_HELP_ID 1000000
177 #ifndef DISABLE_SALOMEOBJECT
178 #include <SALOME_InteractiveObject.hxx>
179 #include <SALOME_ListIO.hxx>
182 #include <Standard_Version.hxx>
184 #define ToolBarMarker 0
185 #define DockWidgetMarker 1
187 static const char* imageEmptyIcon[] = {
190 "....................",
191 "....................",
192 "....................",
193 "....................",
194 "....................",
195 "....................",
196 "....................",
197 "....................",
198 "....................",
199 "....................",
200 "....................",
201 "....................",
202 "....................",
203 "....................",
204 "....................",
205 "....................",
206 "....................",
207 "....................",
208 "....................",
209 "...................."};
211 int LightApp_Application::lastStudyId = 0;
214 \return last global id of study
216 int LightApp_Application::studyId()
218 return LightApp_Application::lastStudyId;
221 /*!Create new instance of LightApp_Application.*/
222 extern "C" LIGHTAPP_EXPORT SUIT_Application* createApplication()
224 return new LightApp_Application();
227 /*! \var global preferences of LightApp */
228 LightApp_Preferences* LightApp_Application::_prefs_ = 0;
232 \class LightApp_Application
233 Application containing LightApp module
237 LightApp_Application::LightApp_Application()
238 : CAM_Application( false ),
240 myScreenHelper(new LightApp_FullScreenHelper())
242 Q_INIT_RESOURCE( LightApp );
244 STD_TabDesktop* desk = new STD_TabDesktop();
245 desk->setFullScreenAllowed(false);
246 desk->setMinimizeAllowed(false);
250 // initialize auto save timer
251 myAutoSaveTimer = new QTimer( this );
252 myAutoSaveTimer->setSingleShot( true );
253 connect( myAutoSaveTimer, SIGNAL( timeout() ), this, SLOT( onSaveDoc() ) );
255 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
256 QPixmap aLogo = aResMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
258 QtxWebBrowser::setResourceManager( aResMgr );
259 QtxWebBrowser::setData("browser:icon", aResMgr->loadPixmap( "LightApp", tr( "BROWSER_ICON" ) ) );
260 QtxWebBrowser::setData("browser:title", tr( "BROWSER_TITLE" ) );
261 QtxWebBrowser::setData("toolbar:title", tr( "BROWSER_TOOLBAR_TITLE" ) );
262 QtxWebBrowser::setData("menu:file:title", tr( "BROWSER_FILEMENU" ) );
263 QtxWebBrowser::setData("action:close:title", tr( "BROWSER_CLOSE" ) );
264 QtxWebBrowser::setData("action:close:icon", aResMgr->loadPixmap( "LightApp", tr( "BROWSER_CLOSE_ICON" ) ) );
265 QtxWebBrowser::setData("action:back:title", tr( "BROWSER_BACK" ) );
266 QtxWebBrowser::setData("action:forward:title", tr( "BROWSER_FORWARD" ) );
267 QtxWebBrowser::setData("action:find:title", tr( "BROWSER_FIND" ) );
268 QtxWebBrowser::setData("action:findnext:title", tr( "BROWSER_FINDNEXT" ) );
269 QtxWebBrowser::setData("action:findprev:title", tr( "BROWSER_FINDPREV" ) );
271 desktop()->setWindowIcon( aLogo );
272 desktop()->setDockableMenuBar( false );
273 desktop()->setDockableStatusBar( false );
275 // base logo (salome itself)
276 desktop()->logoInsert( "_app_base", aResMgr->loadPixmap( "LightApp", tr( "APP_BASE_LOGO" ), false ) );
277 // extra logo (salome-based application)
278 desktop()->logoInsert( "_app_extra", aResMgr->loadPixmap( "LightApp", tr( "APP_EXTRA_LOGO" ), false ) );
282 mySelMgr = new LightApp_SelectionMgr( this );
284 myAccel = SUIT_Accel::getAccel();
286 #ifndef DISABLE_OCCVIEWER
287 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, OCCViewer_Viewer::Type() );
288 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, OCCViewer_Viewer::Type() );
289 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, OCCViewer_Viewer::Type() );
290 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, OCCViewer_Viewer::Type() );
291 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, OCCViewer_Viewer::Type() );
292 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, OCCViewer_Viewer::Type() );
293 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, OCCViewer_Viewer::Type() );
294 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, OCCViewer_Viewer::Type() );
295 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, OCCViewer_Viewer::Type() );
296 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, OCCViewer_Viewer::Type() );
297 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, OCCViewer_Viewer::Type() );
299 #ifndef DISABLE_VTKVIEWER
300 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, VTKViewer_Viewer::Type() );
301 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, VTKViewer_Viewer::Type() );
302 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, VTKViewer_Viewer::Type() );
303 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, VTKViewer_Viewer::Type() );
304 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, VTKViewer_Viewer::Type() );
305 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, VTKViewer_Viewer::Type() );
306 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, VTKViewer_Viewer::Type() );
307 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, VTKViewer_Viewer::Type() );
308 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, VTKViewer_Viewer::Type() );
309 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, VTKViewer_Viewer::Type() );
310 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, VTKViewer_Viewer::Type() );
312 #ifndef DISABLE_PLOT2DVIEWER
313 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, Plot2d_Viewer::Type() );
314 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, Plot2d_Viewer::Type() );
315 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, Plot2d_Viewer::Type() );
316 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, Plot2d_Viewer::Type() );
317 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, Plot2d_Viewer::Type() );
318 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, Plot2d_Viewer::Type() );
319 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, Plot2d_Viewer::Type() );
322 connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) );
324 // Set existing font for the python console in resources
325 if( !aResMgr->hasValue( "PyConsole", "font" ) )
328 QFont f = aResMgr->fontValue( "PyConsole", "font" );
330 QStringList famdb = fdb.families();
332 if ( famdb.contains(f.family()) || !aResMgr->hasValue( "PyConsole", "additional_families" ) )
335 QStringList anAddFamilies = aResMgr->stringValue( "PyConsole", "additional_families" ).split( ";", QString::SkipEmptyParts );
337 for ( QStringList::Iterator it = anAddFamilies.begin(); it != anAddFamilies.end(); ++it )
340 if ( famdb.contains(aFamily) )
342 f.setFamily( aFamily );
343 aResMgr->setValue( "PyConsole", "font", f );
350 *\li Save window geometry.
351 *\li Save desktop geometry.
352 *\li Save resource maneger.
353 *\li Delete selection manager.
355 LightApp_Application::~LightApp_Application()
358 delete myScreenHelper;
361 /*!Start application.*/
362 void LightApp_Application::start()
364 CAM_Application::start();
367 updateViewManagers();
370 desktop()->statusBar()->showMessage( "" );
372 LightApp_EventFilter::Init();
375 /*!Gets application name.*/
376 QString LightApp_Application::applicationName() const
378 static QString _app_name;
379 if ( _app_name.isEmpty() )
380 _app_name = tr( "APP_NAME" );
384 /*!Gets application version.*/
385 QString LightApp_Application::applicationVersion() const
387 static QString _app_version;
389 if ( _app_version.isEmpty() )
391 QString resVersion = tr( "APP_VERSION" );
392 if ( resVersion != "APP_VERSION" )
394 _app_version = resVersion;
398 _app_version = GUI_VERSION_STR;
404 /*!Load module by \a name.*/
405 CAM_Module* LightApp_Application::loadModule( const QString& name, const bool showMsg )
407 CAM_Module* mod = CAM_Application::loadModule( name, showMsg );
410 connect( this, SIGNAL( studyOpened() ), mod, SLOT( onModelOpened() ) );
411 connect( this, SIGNAL( studySaved() ), mod, SLOT( onModelSaved() ) );
412 connect( this, SIGNAL( studyClosed() ), mod, SLOT( onModelClosed() ) );
417 /*!Activate module by \a modName*/
418 bool LightApp_Application::activateModule( const QString& modName )
421 CAM_Module* prevMod = activeModule();
424 actName = prevMod->moduleName();
426 if ( actName == modName )
429 putInfo( tr( "ACTIVATING_MODULE" ).arg( modName ) );
431 saveDockWindowsState();
433 bool status = CAM_Application::activateModule( modName );
435 updateModuleActions();
443 updateViewManagers();
448 /*!Gets selection manager.*/
449 LightApp_SelectionMgr* LightApp_Application::selectionMgr() const
454 /*!Creat action "New window" for certain type of viewer:*/
455 void LightApp_Application::createActionForViewer( const int id,
457 const QString& suffix,
460 QString vtlt = tr( QString( "NEW_WINDOW_%1" ).arg( suffix ).toLatin1().constData() );
461 QString tip = tr( "CREATING_NEW_WINDOW" ).arg( vtlt.remove( "&" ) );
462 QAction* a = createAction( id, // menu action id
469 false, // toggle flag
471 SLOT( onNewWindow() ) ); // slot
472 createMenu( a, parentId, -1 );
477 void LightApp_Application::createActions()
479 CAM_Application::createActions();
481 SUIT_Desktop* desk = desktop();
482 SUIT_ResourceMgr* resMgr = resourceMgr();
485 createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIcon(),
486 tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
487 Qt::CTRL+Qt::Key_R, desk, false, this, SLOT( onPreferences() ) );
491 // - Help for modules
493 int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
494 createMenu( separator(), helpMenu, -1, 10 );
495 QStringList aModuleList;
496 modules( aModuleList, false );
497 aModuleList.prepend( "GUI" );
498 aModuleList.prepend( "KERNEL" );
500 int id = LightApp_Application::UserID + FIRST_HELP_ID;
503 foreach( aModule, aModuleList ) {
504 if ( aModule.isEmpty() ) // module title (user name)
506 IMap <QString, QString> helpData; // list of help files for the module
507 QString helpSubMenu; // help submenu name (empty if not needed)
508 QString modName = moduleName( aModule ); // module name
509 if ( modName.isEmpty() ) modName = aModule; // for KERNEL and GUI
510 QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName ); // module root dir variable
511 QString modDir = getenv( rootDir.toLatin1().constData() ); // module root dir
513 if (resMgr->hasValue( modName, "documentation" ) )
514 docSection = resMgr->stringValue(modName, "documentation");
515 else if ( resMgr->hasSection( modName + "_documentation" ) )
516 docSection = modName + "_documentation";
517 if ( !docSection.isEmpty() ) {
518 helpSubMenu = resMgr->stringValue( docSection, "sub_menu", "" ).arg( aModule );
519 QStringList listOfParam = resMgr->parameters( docSection );
520 foreach( QString paramName, listOfParam ) {
521 QString valueStr = resMgr->stringValue( docSection, paramName );
522 if ( !valueStr.isEmpty() ) {
523 QFileInfo fi( valueStr );
524 if ( fi.isRelative() && !modDir.isEmpty() )
525 valueStr = Qtx::addSlash( modDir ) + valueStr;
526 if ( QFile::exists( valueStr ) )
527 helpData.insert( paramName.arg( aModule ), valueStr );
532 if ( helpData.isEmpty() && !modDir.isEmpty() ) {
533 QStringList idxLst = QStringList() << modDir << "share" << "doc" << "salome" << "gui" << modName << "index.html";
534 QString indexFile = idxLst.join( QDir::separator() ); // index file
535 if ( QFile::exists( indexFile ) )
536 helpData.insert( tr( "%1 module Users's Guide" ).arg( aModule ), indexFile );
539 IMapConstIterator<QString, QString > fileIt;
540 for ( fileIt = helpData.begin(); fileIt != helpData.end(); fileIt++ ) {
541 QString helpFileName = fileIt.key();
542 // remove all '//' occurances
543 while ( helpFileName.contains( "//" ) )
544 helpFileName.replace( "//", "" );
545 // obtain submenus hierarchy if given
546 QStringList smenus = helpFileName.split( "/" );
547 helpFileName = smenus.last();
549 QAction* a = createAction( id, helpFileName,
550 resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
551 helpFileName, helpFileName,
552 0, desk, false, this, SLOT( onHelpContentsModule() ) );
553 a->setData( fileIt.value() );
554 if ( !helpSubMenu.isEmpty() ) {
555 smenus.prepend( helpSubMenu );
557 // create sub-menus hierarchy
558 int menuId = helpMenu;
559 foreach ( QString subMenu, smenus ) {
560 menuId = createMenu( subMenu, menuId, -1, 0 );
562 createMenu( a, menuId, -1, 0 );
567 // - Additional help items
569 createMenu( separator(), helpMenu, -1, 5 );
571 QStringList addHelpItems = resMgr->parameters( "add_help" );
572 foreach ( QString addHelpItem, addHelpItems ) {
573 QString valueStr = resMgr->stringValue( "add_help", addHelpItem );
574 if ( !valueStr.isEmpty() && QFile::exists( valueStr ) ) {
575 QAction* a = createAction( id, addHelpItem,
576 resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
577 addHelpItem, addHelpItem,
578 0, desk, false, this, SLOT( onHelpContentsModule() ) );
579 a->setData( valueStr );
580 createMenu( a, helpMenu, -1, 5 );
586 static QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), 0 );
587 connect( mru, SIGNAL( activated( const QString& ) ), this, SLOT( onMRUActivated( const QString& ) ) );
588 registerAction( MRUId, mru );
590 // default icon for neutral point ('SALOME' module)
591 QPixmap defIcon = resMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
592 if ( defIcon.isNull() )
593 defIcon = QPixmap( imageEmptyIcon );
595 //! default icon for any module
596 QPixmap modIcon = resMgr->loadPixmap( "LightApp", tr( "APP_MODULE_ICO" ), false );
597 if ( modIcon.isNull() )
598 modIcon = QPixmap( imageEmptyIcon );
601 modules( modList, false );
603 if ( modList.count() > 1 )
605 LightApp_ModuleAction* moduleAction =
606 new LightApp_ModuleAction( tr( "APP_NAME" ), defIcon, desk );
608 QMap<QString, QString> iconMap;
609 moduleIconNames( iconMap );
611 const int iconSize = 20;
613 QStringList::Iterator it;
614 for ( it = modList.begin(); it != modList.end(); ++it )
616 if ( !isLibExists( *it ) )
619 QString modName = moduleName( *it );
621 if ( !isModuleAccessible( *it ) )
625 if ( iconMap.contains( *it ) )
626 iconName = iconMap[*it];
628 QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
632 INFOS ( "****************************************************************" << std::endl
633 << "* Icon for " << (*it).toLatin1().constData()
634 << " not found. Using the default one." << std::endl
635 << "****************************************************************" << std::endl );
638 icon = Qtx::scaleIcon( icon, iconSize );
640 moduleAction->insertModule( *it, icon );
643 connect( moduleAction, SIGNAL( moduleActivated( const QString& ) ),
644 this, SLOT( onModuleActivation( const QString& ) ) );
645 registerAction( ModulesListId, moduleAction );
649 int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, MenuWindowId, 100 );
650 int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
652 createAction( CloseId, tr( "TOT_CLOSE" ), QIcon(), tr( "MEN_DESK_CLOSE" ), tr( "PRP_CLOSE" ),
653 Qt::CTRL+Qt::Key_F4, desk, false, this, SLOT( onCloseWindow() ) );
654 createAction( CloseAllId, tr( "TOT_CLOSE_ALL" ), QIcon(), tr( "MEN_DESK_CLOSE_ALL" ), tr( "PRP_CLOSE_ALL" ),
655 0, desk, false, this, SLOT( onCloseAllWindow() ) );
656 createAction( GroupAllId, tr( "TOT_GROUP_ALL" ), QIcon(), tr( "MEN_DESK_GROUP_ALL" ), tr( "PRP_GROUP_ALL" ),
657 0, desk, false, this, SLOT( onGroupAllWindow() ) );
659 createMenu( CloseId, windowMenu, 0, -1 );
660 createMenu( CloseAllId, windowMenu, 0, -1 );
661 createMenu( GroupAllId, windowMenu, 0, -1 );
662 createMenu( separator(), windowMenu, -1, 0 );
664 #ifndef DISABLE_GLVIEWER
665 createActionForViewer( NewGLViewId, newWinMenu, QString::number( 0 ), Qt::ALT+Qt::Key_G );
667 #ifndef DISABLE_PLOT2DVIEWER
668 createActionForViewer( NewPlot2dId, newWinMenu, QString::number( 1 ), Qt::ALT+Qt::Key_P );
670 #ifndef DISABLE_OCCVIEWER
671 createActionForViewer( NewOCCViewId, newWinMenu, QString::number( 2 ), Qt::ALT+Qt::Key_O );
673 #ifndef DISABLE_VTKVIEWER
674 createActionForViewer( NewVTKViewId, newWinMenu, QString::number( 3 ), Qt::ALT+Qt::Key_K );
676 #ifndef DISABLE_QXGRAPHVIEWER
677 createActionForViewer( NewQxSceneViewId, newWinMenu, QString::number( 4 ), Qt::ALT+Qt::Key_S );
680 createAction( RenameId, tr( "TOT_RENAME" ), QIcon(), tr( "MEN_DESK_RENAME" ), tr( "PRP_RENAME" ),
681 Qt::ALT+Qt::SHIFT+Qt::Key_R, desk, false, this, SLOT( onRenameWindow() ) );
682 createMenu( RenameId, windowMenu, -1 );
684 int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
685 createMenu( PreferencesId, fileMenu, 50, -1 );
686 createMenu( separator(), fileMenu, -1, 50, -1 );
688 createMenu( separator(), fileMenu, -1, 100, -1 );
689 createMenu( MRUId, fileMenu, 100, -1 );
690 createMenu( separator(), fileMenu, -1, 100, -1 );
692 createAction( StyleId, tr( "TOT_THEME" ), QIcon(), tr( "MEN_DESK_THEME" ), tr( "PRP_THEME" ),
693 0, desk, false, this, SLOT( onStylePreferences() ) );
695 createAction( FullScreenId, tr( "TOT_FULLSCREEN" ), QIcon(), tr( "MEN_DESK_FULLSCREEN" ), tr( "PRP_FULLSCREEN" ),
696 Qt::Key_F11, desk, false, this, SLOT( onFullScreen() ) );
699 int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1 );
700 createMenu( separator(), viewMenu, -1, 20, -1 );
701 createMenu( StyleId, viewMenu, 20, -1 );
702 createMenu( FullScreenId, viewMenu, 20, -1 );
704 int modTBar = createTool( tr( "INF_TOOLBAR_MODULES" ) );
705 createTool( ModulesListId, modTBar );
708 /*!On module activation action.*/
709 void LightApp_Application::onModuleActivation( const QString& modName )
711 // Force user to create/open a study before module activation
712 QMap<QString, QString> iconMap;
713 moduleIconNames( iconMap );
714 QPixmap icon = resourceMgr()->loadPixmap( moduleName( modName ), iconMap[ modName ], false );
716 icon = resourceMgr()->loadPixmap( "LightApp", tr( "APP_MODULE_BIG_ICO" ), false ); // default icon for any module
718 bool cancelled = false;
720 while ( !modName.isEmpty() && !activeStudy() && !cancelled ){
721 LightApp_ModuleDlg aDlg( desktop(), modName, icon );
722 QMap<int, QString> opmap = activateModuleActions();
723 for ( QMap<int, QString>::ConstIterator it = opmap.begin(); it != opmap.end(); ++it )
724 aDlg.addButton( it.value(), it.key() );
726 int res = aDlg.exec();
728 // some operation is selected
729 moduleActionSelected( res );
733 putInfo( tr("INF_CANCELLED") );
735 LightApp_ModuleAction* moduleAction =
736 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
738 moduleAction->setActiveModule( QString() );
744 activateModule( modName );
747 /*!Default module activation.*/
748 QString LightApp_Application::defaultModule() const
750 QStringList aModuleNames;
751 modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration
752 //! If there's the one and only module --> activate it automatically
753 //! TODO: Possible improvement - default module can be taken from preferences
754 return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" );
757 /*!On new window slot.*/
758 void LightApp_Application::onNewWindow()
760 const QObject* obj = sender();
761 if ( !obj || !obj->inherits( "QAction" ) )
765 int id = actionId( (QAction*)obj );
768 #ifndef DISABLE_GLVIEWER
770 type = GLViewer_Viewer::Type();
773 #ifndef DISABLE_PLOT2DVIEWER
775 type = Plot2d_Viewer::Type();
778 #ifndef DISABLE_OCCVIEWER
780 type = OCCViewer_Viewer::Type();
783 #ifndef DISABLE_VTKVIEWER
785 type = VTKViewer_Viewer::Type();
788 #ifndef DISABLE_QXGRAPHVIEWER
789 case NewQxSceneViewId:
790 type = QxScene_Viewer::Type();
795 if ( !type.isEmpty() )
796 createViewManager( type );
800 SLOT: Creates new document
802 void LightApp_Application::onNewDoc()
804 //asl: fix for 0020515
806 saveDockWindowsState();
808 CAM_Application::onNewDoc();
812 SLOT: Opens new document
814 void LightApp_Application::onOpenDoc()
816 SUIT_Study* study = activeStudy();
817 saveDockWindowsState();
819 CAM_Application::onOpenDoc();
821 if ( !study ) // new study will be create in THIS application
824 updateViewManagers();
829 SLOT: Opens new document.
830 \param aName - name of file
832 bool LightApp_Application::onOpenDoc( const QString& aName )
834 // We should take mru action first because this application instance can be deleted later.
835 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
837 bool res = CAM_Application::onOpenDoc( aName );
842 mru->insert( aName );
844 mru->remove( aName );
850 SLOT: Displays "About" message box
852 void LightApp_Application::onHelpAbout()
854 LightApp_AboutDlg dlg( applicationName(), applicationVersion(), desktop() );
859 Private SLOT: Called on selection is changed
860 Dispatchs active module that selection is changed
862 void LightApp_Application::onSelection()
864 onSelectionChanged();
866 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
867 ((LightApp_Module*)activeModule())->selectionChanged();
872 \param study - SUIT_Study.
874 void LightApp_Application::setActiveStudy( SUIT_Study* study )
876 CAM_Application::setActiveStudy( study );
880 Enables/Disables menu items and toolbar buttons. Rebuild menu
882 void LightApp_Application::updateCommandsStatus()
884 CAM_Application::updateCommandsStatus();
887 #ifndef DISABLE_GLVIEWER
888 a = action( NewGLViewId );
890 a->setEnabled( activeStudy() );
893 #ifndef DISABLE_PLOT2DVIEWER
894 a = action( NewPlot2dId );
896 a->setEnabled( activeStudy() );
899 #ifndef DISABLE_OCCVIEWER
900 a = action( NewOCCViewId );
902 a->setEnabled( activeStudy() );
905 #ifndef DISABLE_VTKVIEWER
906 a = action( NewVTKViewId );
908 a->setEnabled( activeStudy() );
911 #ifndef DISABLE_QXGRAPHVIEWER
912 a = action( NewQxSceneViewId );
914 a->setEnabled( activeStudy() );
920 Runs system command in separate thread
922 class RunBrowser: public QThread
925 RunBrowser( LightApp_Application* app,
926 const QString& theApp,
927 const QString& theParams,
928 const QString& theHelpFile,
929 const QString& theContext = QString() )
931 myParams( theParams ),
932 myContext( theContext ),
936 //For the external browser always specify 'file://' protocol,
937 //because some WEB browsers (for example Mozilla Firefox) can't open local file without protocol.
938 myHelpFile = QString("file://%1").arg( QFileInfo( theHelpFile ).canonicalFilePath() );
943 if ( !myApp.isEmpty() && !myHelpFile.isEmpty()) {
944 QString aCommand = QString( "%1 %2 \"%3%4\"" ).arg( myApp, myParams, myHelpFile, myContext.isEmpty() ? QString("") : QString( "#%1" ).arg( myContext ) );
946 QProcess* proc = new QProcess();
948 proc->start( aCommand );
949 if ( !proc->waitForStarted() ) {
950 SALOME_CustomEvent* ce2000 = new SALOME_CustomEvent( 2000 );
951 QString* msg = new QString( QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).arg( myApp, myHelpFile ) );
952 ce2000->setData( msg );
953 QApplication::postEvent( myLApp, ce2000 );
964 LightApp_Application* myLApp;
968 SLOT: Displays help contents for choosen module
970 void LightApp_Application::onHelpContentsModule()
972 const QAction* a = (QAction*) sender();
973 QString helpFile = a->data().toString();
974 if ( helpFile.isEmpty() ) return;
976 SUIT_ResourceMgr* resMgr = resourceMgr();
979 platform = "winapplication";
981 platform = "application";
983 QString anApp = resMgr->stringValue("ExternalBrowser", platform);
986 anApp.prepend( quote );
987 anApp.append( quote );
989 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
990 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
992 if( useExtBrowser ) {
993 if ( !anApp.isEmpty() ) {
994 RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile );
998 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
999 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1000 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1002 showPreferences( tr( "PREF_APP" ) );
1007 // On Win32 platform QWebKit of the Qt 4.6.3 hang up in case 'file://' protocol
1008 // is defined. On Linux platform QWebKit doesn't work correctly without 'file://' protocol.
1009 QtxWebBrowser::loadUrl(helpFile);
1011 QtxWebBrowser::loadUrl(QString("file://%1").arg(helpFile));
1017 SLOT: Displays help contents for choosen dialog
1019 void LightApp_Application::onHelpContextModule( const QString& theComponentName,
1020 const QString& theFileName,
1021 const QString& theContext )
1023 QString fileName = theFileName;
1024 QString context = theContext;
1025 if ( !QFile::exists( fileName ) && theContext.isEmpty() ) {
1026 // context might be passed within theFileName argument
1027 QStringList comps = fileName.split("#");
1028 if ( comps.count() > 1 ) {
1029 context = comps.last();
1031 fileName = comps.join("#");
1035 QString homeDir = "";
1036 if ( !theComponentName.isEmpty() ) {
1037 QString dir = getenv( ( theComponentName + "_ROOT_DIR" ).toLatin1().constData() );
1038 if ( !dir.isEmpty() )
1039 homeDir = Qtx::addSlash( Qtx::addSlash( dir ) +
1040 Qtx::addSlash( "share" ) +
1041 Qtx::addSlash( "doc" ) +
1042 Qtx::addSlash( "salome" ) +
1043 Qtx::addSlash( "gui" ) +
1044 Qtx::addSlash( theComponentName ) );
1047 QString helpFile = QFileInfo( homeDir + fileName ).absoluteFilePath();
1048 SUIT_ResourceMgr* resMgr = resourceMgr();
1051 platform = "winapplication";
1053 platform = "application";
1055 QString anApp = resMgr->stringValue("ExternalBrowser", platform);
1057 QString quote("\"");
1058 anApp.prepend( quote );
1059 anApp.append( quote );
1062 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1065 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
1067 if ( !anApp.isEmpty() ) {
1068 RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile, context );
1072 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1073 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1074 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1075 showPreferences( tr( "PREF_APP" ) );
1080 // On Win32 platform QWebKit of the Qt 4.6.3 hang up in case 'file://' protocol
1081 // is defined. On Linux platform QWebKit doesn't work correctly without 'file://' protocol.
1082 QtxWebBrowser::loadUrl(helpFile, context);
1084 QtxWebBrowser::loadUrl(QString("file://%1").arg(helpFile), context);
1091 Sets enable or disable some actions on selection changed.
1093 void LightApp_Application::onSelectionChanged()
1095 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
1096 bool canCopy = m ? m->canCopy() : false;
1097 bool canPaste = m ? m->canPaste() : false;
1099 action( EditCopyId )->setEnabled(canCopy);
1100 action( EditPasteId )->setEnabled(canPaste);
1104 Adds window to application.
1105 \param wid - QWidget
1106 \param flag - key for window
1107 \param studyId - study id
1108 Flag used how identificator of window in windows list.
1111 void LightApp_Application::addWindow( QWidget* wid, const int flag, const int studyId )
1119 if ( !activeStudy() )
1122 sId = activeStudy()->id();
1125 if ( !myWindows.contains( flag ) )
1127 QMap<int, int> winMap;
1128 currentWindows( winMap );
1130 LightApp_WidgetContainer* newWC = new LightApp_WidgetContainer( flag, desktop() );
1131 connect( newWC, SIGNAL( destroyed ( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
1132 // asv: connecting a slot for storing visibility flag of a window
1133 connect( newWC, SIGNAL( visibilityChanged ( bool ) ), SLOT( onVisibilityChanged( bool ) ) );
1134 myWindows.insert( flag, newWC );
1135 if ( winMap.contains( flag ) ) {
1136 //desktop()->removeDockWidget( myWindows[flag] );
1137 desktop()->addDockWidget( (Qt::DockWidgetArea)winMap[flag], myWindows[flag] );
1140 //myWindows[flag]->setResizeEnabled( true );
1141 myWindows[flag]->setFeatures( QDockWidget::AllDockWidgetFeatures );
1142 myWindows[flag]->setObjectName( QString( "dock_window_%1" ).arg( flag ) );
1143 //myWindows[flag]->setFixedExtentWidth( wid->width() );
1144 //myWindows[flag]->setFixedExtentHeight( wid->height() );
1145 myWindows[flag]->resize( wid->width(), wid->height() );
1149 #ifndef DISABLE_PYCONSOLE
1150 if( wid->inherits( "PyConsole_Console" ) )
1152 if( resourceMgr()->hasValue( "PyConsole", "font" ) )
1153 f = resourceMgr()->fontValue( "PyConsole", "font" );
1156 f = ( ( PyConsole_Console* )wid )->font();
1157 resourceMgr()->setValue( "PyConsole", "font", f );
1164 myWindows[flag]->insert( sId, wid );
1167 setWindowShown( flag, !myWindows[flag]->isEmpty() );
1171 QWidget* LightApp_Application::dockWindow( const int id ) const
1174 if ( myWin.contains( id ) )
1179 QDockWidget* LightApp_Application::windowDock( QWidget* wid ) const
1184 QDockWidget* dock = 0;
1185 QWidget* w = wid->parentWidget();
1186 while ( w && !dock )
1188 dock = ::qobject_cast<QDockWidget*>( w );
1189 w = w->parentWidget();
1194 void LightApp_Application::insertDockWindow( const int id, QWidget* wid )
1199 if ( wid != dockWindow( id ) )
1200 removeDockWindow( id );
1202 myWin.insert( id, wid );
1204 QtxDockWidget* dock = new QtxDockWidget( true, desktop() );
1205 connect( dock, SIGNAL( destroyed( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
1207 dock->setFeatures( QDockWidget::AllDockWidgetFeatures );
1208 dock->setObjectName( QString( "window_%1" ).arg( id ) );
1209 dock->setWidget( wid );
1211 QKeySequence accel = wid->property( "shortcut" ).value<QKeySequence>();
1212 if ( !accel.isEmpty() )
1213 dock->toggleViewAction()->setShortcut( accel );
1218 void LightApp_Application::removeDockWindow( const int id )
1220 QWidget* wid = dockWindow( id );
1226 QDockWidget* dock = windowDock( wid );
1230 dock->setWidget( 0 );
1231 wid->setParent( 0 );
1232 wid->setVisible( false );
1236 void LightApp_Application::placeDockWindow( const int id, Qt::DockWidgetArea place )
1238 QDockWidget* dock = windowDock( dockWindow( id ) );
1239 if ( dock && desktop() ) {
1240 desktop()->addDockWidget( place, dock );
1241 QtxDockAction* a = qobject_cast<QtxDockAction*>( action( ViewWindowsId ) );
1242 if ( a ) a->update();
1248 \param flag - key for window
1249 \param studyId - study id
1250 Flag used how identificator of window in windows list.
1252 QWidget* LightApp_Application::getWindow( const int flag, const int )
1254 QWidget* wid = dockWindow( flag );
1256 insertDockWindow( flag, wid = createWindow( flag ) );
1258 QMap<int, int> winMap;
1259 currentWindows( winMap );
1260 if ( winMap.contains( flag ) )
1261 placeDockWindow( flag, (Qt::DockWidgetArea)winMap[flag] );
1267 \return Object Browser
1269 SUIT_DataBrowser* LightApp_Application::objectBrowser()
1271 return qobject_cast<SUIT_DataBrowser*>( dockWindow( WT_ObjectBrowser ) );
1277 LogWindow* LightApp_Application::logWindow()
1279 return qobject_cast<LogWindow*>( dockWindow( WT_LogWindow ) );
1282 #ifndef DISABLE_PYCONSOLE
1284 This returns the python console integrated to the GUI. Depending
1285 when you request the python console, this function could return
1286 null. Then the optional parameter force (default to false) can be
1287 set to force the creation of the python console if it is not done
1289 \param force - if true, the pythonConsole is created if it does not exist yet
1290 \return Python Console
1292 PyConsole_Console* LightApp_Application::pythonConsole(const bool force)
1294 QWidget* wid = dockWindow( WT_PyConsole );
1295 if ( !wid && force==true) {
1296 wid = getWindow(WT_PyConsole);
1298 return qobject_cast<PyConsole_Console*>( wid );
1303 Updates object browser and maybe data models
1304 \param updateModels - if it is true, then data models are updated
1306 void LightApp_Application::updateObjectBrowser( const bool updateModels )
1308 // update existing data models
1311 const bool isAutoUpdate = objectBrowser() ? objectBrowser()->autoUpdate() : true;
1312 if ( objectBrowser() )
1313 objectBrowser()->setAutoUpdate( false );
1315 LightApp_Study* study = dynamic_cast<LightApp_Study*>(activeStudy());
1317 CAM_Study::ModelList dm_list;
1318 study->dataModels( dm_list );
1319 QListIterator<CAM_DataModel*> it( dm_list );
1320 while ( it.hasNext() ) {
1321 CAM_DataModel* camDM = it.next();
1322 if ( camDM && camDM->inherits( "LightApp_DataModel" ) )
1323 ((LightApp_DataModel*)camDM)->update();
1327 if( objectBrowser() )
1328 objectBrowser()->setAutoUpdate( isAutoUpdate );
1331 if ( objectBrowser() ) {
1332 objectBrowser()->updateGeometry();
1333 objectBrowser()->updateTree( 0, false );
1340 LightApp_Preferences* LightApp_Application::preferences() const
1342 return preferences( false );
1346 \return first view manager of some type
1347 \param vmType - type of view manager
1348 \param create - is it necessary to create view manager in case, when there is no manager of such type
1350 SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, const bool create )
1352 SUIT_ViewManager* aVM = viewManager( vmType );
1353 SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
1355 if ( anActiveVM && anActiveVM->getType() == vmType )
1358 if ( aVM && create )
1360 if ( !aVM->getActiveView() )
1363 aVM->getActiveView()->setFocus();
1366 aVM = createViewManager( vmType );
1372 Creates view manager of some type
1373 \param vmType - type of view manager
1375 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType )
1377 SUIT_ResourceMgr* resMgr = resourceMgr();
1379 SUIT_ViewManager* viewMgr = 0;
1380 #ifndef DISABLE_GLVIEWER
1381 if( vmType == GLViewer_Viewer::Type() )
1383 viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() );
1384 new LightApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
1387 #ifndef DISABLE_PLOT2DVIEWER
1388 if( vmType == Plot2d_Viewer::Type() )
1390 viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
1392 #ifndef DISABLE_SALOMEOBJECT
1393 SPlot2d_Viewer* v = new SPlot2d_Viewer();
1395 new LightApp_Plot2dSelector( v, mySelMgr );
1397 vm = new Plot2d_Viewer();
1399 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1400 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
1403 Plot2d_ViewFrame* frame = wnd->getViewFrame();
1404 frame->setBackgroundColor( resMgr->colorValue( "Plot2d", "Background", frame->backgroundColor() ) );
1408 #ifndef DISABLE_QXGRAPHVIEWER
1409 if( vmType == QxScene_Viewer::Type() )
1411 viewMgr = new QxScene_ViewManager( activeStudy(), desktop() );
1412 QxScene_Viewer* vm = new QxScene_Viewer();
1413 viewMgr->setViewModel( vm );
1414 //QxScene_ViewWindow* wnd = dynamic_cast<QxScene_ViewWindow*>( viewMgr->getActiveView() );
1417 #ifndef DISABLE_OCCVIEWER
1418 if( vmType == OCCViewer_Viewer::Type() )
1420 viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
1421 OCCViewer_Viewer* vm;
1422 #ifndef DISABLE_SALOMEOBJECT
1423 vm = new SOCC_Viewer();
1425 vm = new OCCViewer_Viewer( true );
1427 vm->setBackground( OCCViewer_ViewFrame::TOP_LEFT,
1428 resMgr->backgroundValue( "OCCViewer", "xz_background", vm->background(OCCViewer_ViewFrame::TOP_LEFT) ) );
1429 vm->setBackground( OCCViewer_ViewFrame::TOP_RIGHT,
1430 resMgr->backgroundValue( "OCCViewer", "yz_background", vm->background(OCCViewer_ViewFrame::TOP_RIGHT) ) );
1431 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_LEFT,
1432 resMgr->backgroundValue( "OCCViewer", "xy_background", vm->background(OCCViewer_ViewFrame::BOTTOM_LEFT) ) );
1433 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_RIGHT,
1434 resMgr->backgroundValue( "OCCViewer", "background", vm->background(OCCViewer_ViewFrame::MAIN_VIEW) ) );
1436 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1437 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ));
1438 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1439 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1440 vm->enablePreselection( resMgr->booleanValue( "OCCViewer", "enable_preselection", vm->isPreselectionEnabled() ) );
1441 vm->enableSelection( resMgr->booleanValue( "OCCViewer", "enable_selection", vm->isSelectionEnabled() ) );
1443 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1444 new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
1447 #ifndef DISABLE_VTKVIEWER
1448 #ifndef DISABLE_SALOMEOBJECT
1449 if ( vmType == SVTK_Viewer::Type() )
1451 if ( vmType == VTKViewer_Viewer::Type() )
1454 #ifndef DISABLE_SALOMEOBJECT
1455 viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
1456 SVTK_Viewer* vm = dynamic_cast<SVTK_Viewer*>( viewMgr->getViewModel() );
1459 vm->setProjectionMode( resMgr->integerValue( "VTKViewer", "projection_mode", vm->projectionMode() ) );
1460 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1461 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1462 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ) );
1463 vm->setStaticTrihedronVisible( resMgr->booleanValue( "3DViewer", "show_static_trihedron", vm->isStaticTrihedronVisible() ) );
1464 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1465 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1466 vm->setPreSelectionMode(resMgr->integerValue( "VTKViewer", "preselection", vm->preSelectionMode() ) );
1467 vm->enableSelection( resMgr->booleanValue( "VTKViewer", "enable_selection", vm->isSelectionEnabled() ) );
1468 vm->setIncrementalSpeed( resMgr->integerValue( "VTKViewer", "speed_value", vm->incrementalSpeed() ),
1469 resMgr->integerValue( "VTKViewer", "speed_mode", vm->incrementalSpeedMode() ) );
1470 vm->setSpacemouseButtons( resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", vm->spacemouseBtn(1) ),
1471 resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", vm->spacemouseBtn(2) ),
1472 resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", vm->spacemouseBtn(3) ) );
1473 new LightApp_VTKSelector( vm, mySelMgr );
1476 viewMgr = new VTKViewer_ViewManager( activeStudy(), desktop() );
1477 VTKViewer_Viewer* vm = dynamic_cast<VTKViewer_Viewer*>( viewMgr->getViewModel() );
1479 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1487 addViewManager( viewMgr );
1488 SUIT_ViewWindow* viewWin = viewMgr->createViewWindow();
1490 if ( viewWin && desktop() ) {
1491 viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1492 viewWin->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1498 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, QWidget* w )
1500 SUIT_ResourceMgr* resMgr = resourceMgr();
1502 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
1504 new LightApp_WgViewModel( vmType, w ) );
1505 vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
1507 addViewManager( vm );
1508 SUIT_ViewWindow* vw = vm->createViewWindow();
1509 if ( vw && desktop() ) {
1510 vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1511 vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1514 if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
1515 myUserWmTypes << vmType;
1521 SLOT: Removes view manager from application
1523 void LightApp_Application::onCloseView( SUIT_ViewManager* theVM )
1525 removeViewManager( theVM );
1529 Protected SLOT: On study created.
1530 \param theStudy - just created study
1532 void LightApp_Application::onStudyCreated( SUIT_Study* theStudy )
1534 SUIT_DataObject* aRoot = 0;
1535 if ( theStudy && theStudy->root() )
1537 aRoot = theStudy->root();
1538 //aRoot->setName( tr( "DATA_MODELS" ) );
1541 getWindow( WT_ObjectBrowser );
1543 loadDockWindowsState();
1545 if ( objectBrowser() )
1546 objectBrowser()->setRoot( aRoot );
1548 activateModule( defaultModule() );
1550 if ( objectBrowser() )
1551 objectBrowser()->openLevels();
1555 Protected SLOT: On study opened.
1556 \param theStudy - just opened study
1558 void LightApp_Application::onStudyOpened( SUIT_Study* theStudy )
1560 SUIT_DataObject* aRoot = 0;
1561 if ( theStudy && theStudy->root() )
1563 aRoot = theStudy->root();
1567 getWindow( WT_ObjectBrowser );
1569 loadDockWindowsState();
1571 if ( objectBrowser() )
1572 objectBrowser()->setRoot( aRoot );
1574 activateModule( defaultModule() );
1576 if ( objectBrowser() )
1577 objectBrowser()->openLevels();
1582 /*!Protected SLOT. On study saved.*/
1583 void LightApp_Application::onStudySaved( SUIT_Study* s )
1585 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
1587 mru->insert( s->studyName() );
1592 /*!Protected SLOT. On study closed.*/
1593 void LightApp_Application::onStudyClosed( SUIT_Study* s )
1595 // stop auto-save timer
1596 myAutoSaveTimer->stop();
1598 // Bug 10396: clear selection
1599 mySelMgr->clearSelected();
1601 // Bug 12944: emit signal only after clear selection
1604 activateModule( "" );
1607 /*!Protected SLOT.On desktop activated.*/
1608 void LightApp_Application::onDesktopActivated()
1610 CAM_Application::onDesktopActivated();
1611 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>(activeModule());
1613 aModule->studyActivated();
1616 void LightApp_Application::studyOpened( SUIT_Study* s )
1618 CAM_Application::studyOpened( s );
1621 updateViewManagers();
1624 void LightApp_Application::studySaved( SUIT_Study* s )
1626 CAM_Application::studyOpened( s );
1627 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1628 if ( aResMgr && activeStudy() ) {
1629 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
1630 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
1634 void LightApp_Application::studyCreated( SUIT_Study* s )
1636 CAM_Application::studyCreated( s );
1639 updateViewManagers();
1642 /*!Gets file filter.
1643 *\retval QString "(*.bin)"
1645 QString LightApp_Application::getFileFilter() const
1653 Shows file dialog and return user selected file name
1655 QString LightApp_Application::getFileName( bool open, const QString& initial, const QString& filters,
1656 const QString& caption, QWidget* parent )
1660 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1661 return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
1664 /*! Gets directory*/
1665 QString LightApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
1669 return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true );
1672 /*! Get open file names*/
1673 QStringList LightApp_Application::getOpenFileNames( const QString& initial, const QString& filters,
1674 const QString& caption, QWidget* parent )
1678 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1679 return SUIT_FileDlg::getOpenFileNames( parent, initial, fls, caption, true );
1682 /*!Private SLOT. Update object browser.*/
1683 void LightApp_Application::onRefresh()
1685 updateObjectBrowser( true );
1688 /*!Private SLOT. Support drag-and-drop operation.*/
1689 void LightApp_Application::onDropped( const QList<SUIT_DataObject*>& objects, SUIT_DataObject* parent, int row, Qt::DropAction action )
1691 LightApp_DataObject* parentObj = dynamic_cast<LightApp_DataObject*>( parent );
1695 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>( parentObj->module() );
1697 aModule->dropObjects( objects, parentObj, row, action );
1700 /*!Private SLOT. On preferences.*/
1701 void LightApp_Application::onPreferences()
1703 showPreferences( activeModule() ? activeModule()->moduleName() : tr( "PREF_CATEGORY_SALOME" ) );
1706 /*!Private SLOT. On preferences.*/
1707 void LightApp_Application::showPreferences( const QString& itemText )
1709 QApplication::setOverrideCursor( Qt::WaitCursor );
1711 LightApp_PreferencesDlg* prefDlg = new LightApp_PreferencesDlg( preferences( true ), desktop());
1713 QApplication::restoreOverrideCursor();
1718 preferences()->activateItem( itemText );
1720 if ( ( prefDlg->exec() == QDialog::Accepted || prefDlg->isSaved() ) && resourceMgr() )
1723 resourceMgr()->setValue( "desktop", "geometry", desktop()->storeGeometry() );
1724 resourceMgr()->save();
1727 shortcutMgr()->updateShortcuts();
1733 /*!Protected SLOT. On preferences changed.*/
1734 void LightApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param )
1736 LightApp_Module* sMod = 0;
1737 CAM_Module* mod = module( modName );
1738 if ( mod && mod->inherits( "LightApp_Module" ) )
1739 sMod = (LightApp_Module*)mod;
1742 sMod->preferencesChanged( section, param );
1744 preferencesChanged( section, param );
1745 // emit signal to allow additional preferences changing processing
1746 emit preferenceChanged( modName, section, param );
1749 /*!Remove all windows from study.*/
1750 void LightApp_Application::beforeCloseDoc( SUIT_Study* s )
1752 CAM_Application::beforeCloseDoc( s );
1755 /*!Update actions.*/
1756 void LightApp_Application::updateActions()
1758 updateCommandsStatus();
1764 SUIT_Study* LightApp_Application::createNewStudy()
1766 LightApp_Application::lastStudyId++;
1768 LightApp_Study* aStudy = new LightApp_Study( this );
1770 // Set up processing of major study-related events
1771 connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
1772 connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
1773 connect( aStudy, SIGNAL( saved ( SUIT_Study* ) ), this, SLOT( onStudySaved ( SUIT_Study* ) ) );
1774 connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
1780 Creates window by flag.
1781 \param flag - identificator of window type
1783 QWidget* LightApp_Application::createWindow( const int flag )
1787 SUIT_ResourceMgr* resMgr = resourceMgr();
1789 if ( flag == WT_ObjectBrowser )
1791 SUIT_DataBrowser* ob = new SUIT_DataBrowser( new LightApp_DataObject(), desktop() );
1792 ob->setSortMenuEnabled( true );
1793 ob->setAutoUpdate( true );
1794 if ( resMgr->hasValue( "ObjectBrowser", "auto_hide_search_tool" ) )
1795 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
1797 //ob->setAutoOpenLevel( 1 ); // commented by ASV as a fix to bug IPAL10107
1798 ob->setWindowTitle( tr( "OBJECT_BROWSER" ) );
1799 connect( ob, SIGNAL( requestUpdate() ), this, SLOT( onRefresh() ) );
1801 QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
1802 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
1803 treeModel->setSearcher( this );
1804 treeModel->registerColumn( 0, EntryCol, LightApp_DataObject::EntryId );
1805 treeModel->setAppropriate( EntryCol, Qtx::Toggled );
1807 // Mantis issue 0020136: Drag&Drop in OB
1808 SUIT_ProxyModel* proxyModel = dynamic_cast<SUIT_ProxyModel*>(treeModel);
1810 connect( proxyModel, SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
1811 this, SLOT( onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
1814 // temporary commented
1816 OB_ListView* ob_list = dynamic_cast<OB_ListView*>( const_cast<QListView*>( ob->listView() ) );
1818 ob_list->setColumnMaxWidth( 0, desktop()->width()/4 );
1821 // Create OBSelector
1822 new LightApp_OBSelector( ob, mySelMgr );
1824 ob->treeView()->header()->setResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
1825 ob->treeView()->header()->moveSection(SUIT_DataObject::NameId,SUIT_DataObject::VisibilityId);
1826 ob->treeView()->setColumnWidth(SUIT_DataObject::VisibilityId, VISIBILITY_COLUMN_WIDTH);
1827 ob->setProperty( "shortcut", QKeySequence( "Alt+Shift+O" ) );
1829 ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1831 #ifndef DISABLE_PYCONSOLE
1832 else if ( flag == WT_PyConsole )
1834 PyConsole_Console* pyCons = new PyConsole_EnhConsole( desktop(),new LightApp_PyInterp());
1835 pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
1836 pyCons->setFont(resourceMgr()->fontValue( "PyConsole", "font" ));
1837 pyCons->setIsShowBanner(resourceMgr()->booleanValue( "PyConsole", "show_banner", true ));
1838 pyCons->setProperty( "shortcut", QKeySequence( "Alt+Shift+P" ) );
1841 pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1844 else if ( flag == WT_LogWindow )
1846 LogWindow* logWin = new LogWindow( desktop() );
1847 logWin->setWindowTitle( tr( "LOG_WINDOW" ) );
1848 logWin->setProperty( "shortcut", QKeySequence( "Alt+Shift+L" ) );
1850 logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1856 \return default windows( Object Browser, Python Console )
1857 Adds to map \a aMap.
1859 void LightApp_Application::defaultWindows( QMap<int, int>& aMap ) const
1861 aMap.insert( WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1862 #ifndef DISABLE_PYCONSOLE
1863 aMap.insert( WT_PyConsole, Qt::BottomDockWidgetArea );
1865 // aMap.insert( WT_LogWindow, Qt::DockBottom );
1868 /*!Default view managers*/
1869 void LightApp_Application::defaultViewManagers( QStringList& ) const
1875 \return preferences.
1876 Create preferences, if \a crt = true.
1878 LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const
1883 LightApp_Application* that = (LightApp_Application*)this;
1885 bool toCreate = !_prefs_ && crt;
1888 _prefs_ = new LightApp_Preferences( resourceMgr() );
1889 that->createPreferences( _prefs_ );
1892 that->myPrefs = _prefs_;
1894 connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
1895 this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ) );
1900 SUIT_ResourceMgr* resMgr = resourceMgr();
1902 QList<SUIT_Application*> appList = SUIT_Session::session()->applications();
1903 for ( QList<SUIT_Application*>::iterator appIt = appList.begin(); appIt != appList.end(); ++appIt )
1905 LightApp_Application* app = ::qobject_cast<LightApp_Application*>( *appIt );
1909 QStringList modNameList;
1910 app->modules( modNameList, false );
1912 QMap<QString, QString> iconMap;
1913 app->moduleIconNames( iconMap );
1915 for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it )
1917 if ( !app->isLibExists( *it ) || _prefs_->hasModule( *it ) )
1920 int modId = _prefs_->addPreference( *it );
1921 if ( iconMap.contains( *it ) )
1922 _prefs_->setItemIcon( modId, Qtx::scaleIcon( resMgr->loadPixmap( moduleName( *it ), iconMap[*it], false ), 20 ) );
1926 app->modules( modList );
1927 QListIterator<CAM_Module*> itr( modList );
1928 while ( itr.hasNext() )
1930 LightApp_Module* mod = 0;
1932 CAM_Module* anItem = itr.next();
1933 if ( anItem->inherits( "LightApp_Module" ) )
1934 mod = (LightApp_Module*)anItem;
1936 if ( mod && !_prefs_->hasModule( mod->moduleName() ) )
1938 _prefs_->addPreference( mod->moduleName() );
1939 mod->createPreferences();
1940 that->emptyPreferences( mod->moduleName() );
1944 _prefs_->setItemProperty( "info", tr( "PREFERENCES_NOT_LOADED" ) );
1950 Adds new module to application
1952 void LightApp_Application::moduleAdded( CAM_Module* mod )
1954 CAM_Application::moduleAdded( mod );
1956 LightApp_Module* lightMod = 0;
1957 if ( mod && mod->inherits( "LightApp_Module" ) )
1958 lightMod = (LightApp_Module*)mod;
1960 if ( myPrefs && lightMod && !myPrefs->hasModule( lightMod->moduleName() ))
1962 myPrefs->addPreference( mod->moduleName() );
1963 lightMod->createPreferences();
1964 emptyPreferences( mod->moduleName() );
1968 void LightApp_Application::emptyPreferences( const QString& modName )
1970 QtxPreferenceItem* item = myPrefs->findItem( modName, true );
1971 if ( !item || !item->isEmpty() )
1974 // printf( "---------------------> Modify for empty module.\n" );
1976 QtxPagePrefFrameItem* frm = new QtxPagePrefFrameItem( item->title(), item->parentItem() );
1977 frm->setIcon( item->icon() );
1978 frm->setStretch( false );
1979 item->parentItem()->insertItem( frm, item );
1980 new QtxPagePrefLabelItem( Qt::AlignCenter, tr( "PREFERENCES_NOT_SUPPORTED" ).arg( modName ), frm );
1987 void LightApp_Application::createPreferences( LightApp_Preferences* pref )
1992 QStringList aValuesList;
1993 QList<QVariant> anIndicesList;
1997 // . Top-level "SALOME" preferences group <<start>>
1998 int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
1999 pref->setItemIcon( salomeCat, Qtx::scaleIcon( resourceMgr()->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false ), 20 ) );
2001 // .. "General" preferences tab <<start>>
2002 int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat );
2004 // ... "Language" group <<start>>
2005 int langGroup = pref->addPreference( tr( "PREF_GROUP_LANGUAGE" ), genTab );
2006 pref->setItemProperty( "columns", 2, langGroup );
2007 // .... -> application language
2008 int curLang = pref->addPreference( tr( "PREF_CURRENT_LANGUAGE" ), langGroup,
2009 LightApp_Preferences::Selector, "language", "language" );
2010 QStringList aLangs = SUIT_Session::session()->resourceMgr()->stringValue( "language", "languages", "en" ).split( "," );
2011 QList<QVariant> aIcons;
2012 foreach ( QString aLang, aLangs ) {
2013 aIcons << QPixmap( QString( ":/images/%1" ).arg( aLang ) );
2015 pref->setItemProperty( "strings", aLangs, curLang );
2016 pref->setItemProperty( "icons", aIcons, curLang );
2017 // ... "Language" group <<end>>
2019 // ... "Look and feel" group <<start>>
2020 int lookGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), genTab );
2021 pref->setItemProperty( "columns", 2, lookGroup );
2022 // .... -> show splash-screen
2023 pref->addPreference( tr( "PREF_SHOW_SPLASH" ), lookGroup, LightApp_Preferences::Bool, "launch", "splash" );
2024 // .... -> opaque resize
2025 pref->addPreference( tr( "PREF_OPAQUE_RESIZE" ), lookGroup, LightApp_Preferences::Bool, "desktop", "opaque_resize" );
2026 // .... -> drop-down buttons
2027 pref->addPreference( tr( "PREF_DROP_DOWN_BUTTONS" ), lookGroup, LightApp_Preferences::Bool, "viewers", "drop_down_buttons" );
2028 // ... "Look and feel" group <<end>>
2030 // ... "Study properties" group <<start>>
2031 int studyGroup = pref->addPreference( tr( "PREF_GROUP_STUDY" ), genTab );
2032 pref->setItemProperty( "columns", 2, studyGroup );
2033 // .... -> multi-file save
2034 pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "multi_file" );
2035 // .... -> ascii save mode
2036 pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" );
2037 // .... -> store windows geometry
2038 pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" );
2039 // .... -> auto-save
2040 int autoSaveInterval = pref->addPreference( tr( "PREF_AUTO_SAVE" ), studyGroup,
2041 LightApp_Preferences::IntSpin, "Study", "auto_save_interval" );
2042 pref->setItemProperty( "min", 0, autoSaveInterval );
2043 pref->setItemProperty( "max", 1440, autoSaveInterval );
2044 pref->setItemProperty( "special", tr( "PREF_AUTO_SAVE_DISABLED" ), autoSaveInterval );
2045 // ... "Study properties" group <<end>>
2047 // ... "Help browser" group <<start>>
2048 int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab, LightApp_Preferences::Auto, "ExternalBrowser", "use_external_browser");
2050 QString platform = "winapplication";
2052 QString platform = "application";
2054 // .... -> browser application
2055 int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, LightApp_Preferences::File, "ExternalBrowser", platform );
2056 pref->setItemProperty( "mode", Qtx::PT_OpenFile, apppref );
2057 // .... -> browser parameters
2058 pref->addPreference( tr( "PREF_PARAM" ), extgroup, LightApp_Preferences::String, "ExternalBrowser", "parameters" );
2059 // ... "Help browser" group <<end>>
2061 // ... "Python console properties" group <<start>>
2062 int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab );
2064 pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, LightApp_Preferences::Font, "PyConsole", "font" );
2065 // .... -> show banner
2066 pref->addPreference( tr( "PREF_SHOW_BANNER" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "show_banner" );
2067 // ... "Python console properties" group <<end>>
2069 // ... "MRU" preferences group <<start>>
2070 int mruGroup = pref->addPreference( tr( "PREF_GROUP_MRU" ), genTab, LightApp_Preferences::Auto, "MRU", "show_mru" );
2071 pref->setItemProperty( "columns", 4, mruGroup );
2072 // number of MRU items
2073 int mruVisCount = pref->addPreference( tr( "PREF_MRU_VISIBLE_COUNT" ), mruGroup, LightApp_Preferences::IntSpin,
2074 "MRU", "visible_count" );
2075 pref->setItemProperty( "min", 0, mruVisCount );
2076 pref->setItemProperty( "max", 100, mruVisCount );
2078 int mruLinkType = pref->addPreference( tr( "PREF_MRU_LINK_TYPE" ), mruGroup, LightApp_Preferences::Selector,
2079 "MRU", "link_type" );
2080 aValuesList.clear();
2081 anIndicesList.clear();
2082 aValuesList << tr("PREF_MRU_LINK_AUTO") << tr("PREF_MRU_LINK_SHORT") << tr("PREF_MRU_LINK_FULL");
2083 anIndicesList << 0 << 1 << 2 ;
2084 pref->setItemProperty( "strings", aValuesList, mruLinkType );
2085 pref->setItemProperty( "indexes", anIndicesList, mruLinkType );
2086 // ... "MRU" preferences group <<end>>
2087 // .. "General" preferences tab <<end>>
2089 // .. "3D viewer" group <<start>>
2090 int Viewer3DGroup = pref->addPreference( tr( "PREF_GROUP_3DVIEWER" ), salomeCat );
2091 // ... -> navigation mode
2092 int vtkStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), Viewer3DGroup,
2093 LightApp_Preferences::Selector, "3DViewer", "navigation_mode" );
2094 aValuesList.clear();
2095 anIndicesList.clear();
2096 aValuesList << tr("PREF_STANDARD_STYLE") << tr("PREF_KEYFREE_STYLE");
2097 anIndicesList << 0 << 1;
2098 pref->setItemProperty( "strings", aValuesList, vtkStyleMode );
2099 pref->setItemProperty( "indexes", anIndicesList, vtkStyleMode );
2100 // ... -> zooming mode
2101 #if OCC_VERSION_LARGE > 0x0603000A // available only with OCC-6.3-sp11 and higher version
2102 int occZoomingStyleMode = pref->addPreference( tr( "PREF_ZOOMING" ), Viewer3DGroup,
2103 LightApp_Preferences::Selector, "3DViewer", "zooming_mode" );
2104 aValuesList.clear();
2105 anIndicesList.clear();
2106 aValuesList << tr("PREF_ZOOMING_AT_CENTER") << tr("PREF_ZOOMING_AT_CURSOR");
2107 anIndicesList << 0 << 1;
2108 pref->setItemProperty( "strings", aValuesList, occZoomingStyleMode );
2109 pref->setItemProperty( "indexes", anIndicesList, occZoomingStyleMode );
2111 // ... "Trihedron" group <<start>>
2112 int occTriGroup = pref->addPreference( tr( "PREF_TRIHEDRON" ), Viewer3DGroup );
2113 pref->setItemProperty( "columns", 2, occTriGroup );
2114 // .... -> trihedron size
2115 int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occTriGroup,
2116 LightApp_Preferences::DblSpin, "3DViewer", "trihedron_size" );
2117 pref->setItemProperty( "min", 1.0E-06, occTS );
2118 pref->setItemProperty( "max", 1000, occTS );
2119 // .... -> relative size of trihedron
2120 pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "relative_size" );
2121 // .... -> show static trihedron
2122 pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "show_static_trihedron" );
2123 // ... "Trihedron" group <<end>>
2124 // .. "3D viewer" group <<end>>
2126 // .. "OCC viewer" group <<start>>
2127 int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), salomeCat );
2129 // ... "Background" group <<start>>
2130 int bgGroup = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup );
2131 // pref->setItemProperty( "columns", 2, bgGroup );
2132 aValuesList.clear();
2133 anIndicesList.clear();
2135 QString formats = OCCViewer_Viewer::backgroundData( aValuesList, idList, txtList );
2136 foreach( int gid, idList ) anIndicesList << gid;
2137 // .... -> 3D viewer background
2138 int bgId = pref->addPreference( tr( "PREF_3DVIEWER_BACKGROUND" ), bgGroup,
2139 LightApp_Preferences::Background, "OCCViewer", "background" );
2140 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2141 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2142 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2143 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2144 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2145 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2146 pref->setItemProperty( "custom_enabled", false, bgId );
2147 pref->setItemProperty( "image_formats", formats, bgId );
2148 // .... -> XZ viewer background
2149 bgId = pref->addPreference( tr( "PREF_XZVIEWER_BACKGROUND" ), bgGroup,
2150 LightApp_Preferences::Background, "OCCViewer", "xz_background" );
2151 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2152 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2153 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2154 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2155 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2156 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2157 pref->setItemProperty( "custom_enabled", false, bgId );
2158 pref->setItemProperty( "image_formats", formats, bgId );
2159 // .... -> YZ viewer background
2160 bgId = pref->addPreference( tr( "PREF_YZVIEWER_BACKGROUND" ), bgGroup,
2161 LightApp_Preferences::Background, "OCCViewer", "yz_background" );
2162 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2163 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2164 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2165 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2166 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2167 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2168 pref->setItemProperty( "custom_enabled", false, bgId );
2169 pref->setItemProperty( "image_formats", formats, bgId );
2170 // .... -> XY viewer background
2171 bgId = pref->addPreference( tr( "PREF_XYVIEWER_BACKGROUND" ), bgGroup,
2172 LightApp_Preferences::Background, "OCCViewer", "xy_background" );
2173 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2174 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2175 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2176 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2177 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2178 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2179 pref->setItemProperty( "custom_enabled", false, bgId );
2180 pref->setItemProperty( "image_formats", formats, bgId );
2181 // ... "Background" group <<end>>
2184 // ... "Selection" group <<start>>
2185 int occSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), occGroup );
2186 pref->setItemProperty( "columns", 2, occSelectionGroup );
2187 // .... -> enable preselection
2188 pref->addPreference( tr( "PREF_ENABLE_PRESELECTION" ), occSelectionGroup,
2189 LightApp_Preferences::Bool, "OCCViewer", "enable_preselection" );
2190 // .... -> enable selection
2191 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), occSelectionGroup,
2192 LightApp_Preferences::Bool, "OCCViewer", "enable_selection" );
2193 // ... "Selection" group <<end>>
2195 // ... -> empty frame (for layout) <<start>>
2196 int occGen = pref->addPreference( "", occGroup, LightApp_Preferences::Frame );
2197 pref->setItemProperty( "margin", 0, occGen );
2198 pref->setItemProperty( "columns", 2, occGen );
2199 // ... -> empty frame (for layout) <<end>>
2200 // .. "OCC viewer" group <<end>>
2202 // .. "VTK viewer" group <<start>>
2203 int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), salomeCat ); //viewTab
2205 // ... -> empty frame (for layout) <<start>>
2206 int vtkGen = pref->addPreference( "", vtkGroup, LightApp_Preferences::Frame );
2207 //pref->setItemProperty( "columns", 2, vtkGen );
2208 // .... -> projection mode
2209 int vtkProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), vtkGen,
2210 LightApp_Preferences::Selector, "VTKViewer", "projection_mode" );
2211 aValuesList.clear();
2212 anIndicesList.clear();
2213 aValuesList << tr("PREF_ORTHOGRAPHIC") << tr("PREF_PERSPECTIVE");
2214 anIndicesList << 0 << 1;
2215 pref->setItemProperty( "strings", aValuesList, vtkProjMode );
2216 pref->setItemProperty( "indexes", anIndicesList, vtkProjMode );
2217 // .... -> background
2218 aValuesList.clear();
2219 anIndicesList.clear();
2221 formats = SVTK_Viewer::backgroundData( aValuesList, idList, txtList );
2222 foreach( int gid, idList ) anIndicesList << gid;
2223 bgId = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGen,
2224 LightApp_Preferences::Background, "VTKViewer", "background" );
2225 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2226 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2227 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2228 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2229 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2230 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2231 pref->setItemProperty( "custom_enabled", false, bgId );
2232 pref->setItemProperty( "image_formats", formats, bgId );
2233 // .... -> speed increment
2234 int vtkSpeed = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED" ), vtkGen,
2235 LightApp_Preferences::IntSpin, "VTKViewer", "speed_value" );
2236 pref->setItemProperty( "min", 1, vtkSpeed );
2237 pref->setItemProperty( "max", 1000, vtkSpeed );
2238 // .... -> speed mode
2239 int vtkSpeedMode = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED_MODE" ), vtkGen,
2240 LightApp_Preferences::Selector, "VTKViewer", "speed_mode" );
2241 aValuesList.clear();
2242 anIndicesList.clear();
2243 aValuesList << tr("PREF_ARITHMETIC") << tr("PREF_GEOMETRICAL");
2244 anIndicesList << 0 << 1;
2245 pref->setItemProperty( "strings", aValuesList, vtkSpeedMode );
2246 pref->setItemProperty( "indexes", anIndicesList, vtkSpeedMode );
2248 // ... "Selection" group <<start>>
2249 int vtkSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), vtkGroup );
2250 pref->setItemProperty( "columns", 2, vtkSelectionGroup );
2251 // .... -> preselection
2252 int vtkPreselection = pref->addPreference( tr( "PREF_PRESELECTION" ), vtkSelectionGroup,
2253 LightApp_Preferences::Selector, "VTKViewer", "preselection" );
2254 aValuesList.clear();
2255 anIndicesList.clear();
2256 aValuesList << tr("PREF_PRESELECTION_STANDARD") << tr("PREF_PRESELECTION_DYNAMIC") << tr("PREF_PRESELECTION_DISABLED");
2257 anIndicesList << 0 << 1 << 2;
2258 pref->setItemProperty( "strings", aValuesList, vtkPreselection );
2259 pref->setItemProperty( "indexes", anIndicesList, vtkPreselection );
2260 // .... -> enable selection
2261 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), vtkSelectionGroup, LightApp_Preferences::Bool, "VTKViewer", "enable_selection" );
2262 // ... "Selection" group <<end>>
2264 // ... -> empty frame (for layout) <<end>>
2266 // ... space mouse sub-group <<start>>
2267 int vtkSM = pref->addPreference( tr( "PREF_FRAME_SPACEMOUSE" ), vtkGroup, LightApp_Preferences::GroupBox );
2268 //pref->setItemProperty( "columns", 2, vtkSM );
2269 // .... -> decrease speed increment
2270 int spacemousePref1 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_1" ), vtkSM,
2271 LightApp_Preferences::Selector, "VTKViewer",
2272 "spacemouse_func1_btn" );
2273 // .... -> increase speed increment
2274 int spacemousePref2 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_2" ), vtkSM,
2275 LightApp_Preferences::Selector, "VTKViewer",
2276 "spacemouse_func2_btn" );
2277 // .... -> dominant / combined switch
2278 int spacemousePref3 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_3" ), vtkSM,
2279 LightApp_Preferences::Selector, "VTKViewer",
2280 "spacemouse_func5_btn" ); //
2281 aValuesList.clear();
2282 anIndicesList.clear();
2283 aValuesList << tr( "PREF_SPACEMOUSE_BTN_1" ) << tr( "PREF_SPACEMOUSE_BTN_2" ) << tr( "PREF_SPACEMOUSE_BTN_3" );
2284 aValuesList << tr( "PREF_SPACEMOUSE_BTN_4" ) << tr( "PREF_SPACEMOUSE_BTN_5" ) << tr( "PREF_SPACEMOUSE_BTN_6" );
2285 aValuesList << tr( "PREF_SPACEMOUSE_BTN_7" ) << tr( "PREF_SPACEMOUSE_BTN_8" ) << tr( "PREF_SPACEMOUSE_BTN_*" );
2286 aValuesList << tr( "PREF_SPACEMOUSE_BTN_10" ) << tr( "PREF_SPACEMOUSE_BTN_11" );
2287 anIndicesList << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11;
2288 pref->setItemProperty( "strings", aValuesList, spacemousePref1 );
2289 pref->setItemProperty( "indexes", anIndicesList, spacemousePref1 );
2290 pref->setItemProperty( "strings", aValuesList, spacemousePref2 );
2291 pref->setItemProperty( "indexes", anIndicesList, spacemousePref2 );
2292 pref->setItemProperty( "strings", aValuesList, spacemousePref3 );
2293 pref->setItemProperty( "indexes", anIndicesList, spacemousePref3 );
2294 // ... space mouse sub-group <<end>>
2296 // ... avi recording sub-group <<start>>
2297 int vtkRec = pref->addPreference( tr( "PREF_FRAME_RECORDING" ), vtkGroup, LightApp_Preferences::GroupBox );
2298 pref->setItemProperty( "columns", 2, vtkRec );
2299 // .... -> recording mode
2300 int modePref = pref->addPreference( tr( "PREF_RECORDING_MODE" ), vtkRec,
2301 LightApp_Preferences::Selector, "VTKViewer", "recorder_mode" );
2302 aValuesList.clear();
2303 anIndicesList.clear();
2304 aValuesList << tr( "PREF_SKIPPED_FRAMES" ) << tr( "PREF_ALL_DISLPAYED_FRAMES" );
2305 anIndicesList << 0 << 1;
2306 pref->setItemProperty( "strings", aValuesList, modePref );
2307 pref->setItemProperty( "indexes", anIndicesList, modePref );
2309 int fpsPref = pref->addPreference( tr( "PREF_FPS" ), vtkRec,
2310 LightApp_Preferences::DblSpin, "VTKViewer", "recorder_fps" );
2311 pref->setItemProperty( "min", 0.1, fpsPref );
2312 pref->setItemProperty( "max", 100, fpsPref );
2314 int qualityPref = pref->addPreference( tr( "PREF_QUALITY" ), vtkRec,
2315 LightApp_Preferences::IntSpin, "VTKViewer", "recorder_quality" );
2316 pref->setItemProperty( "min", 1, qualityPref );
2317 pref->setItemProperty( "max", 100, qualityPref );
2318 // .... -> progressive mode
2319 pref->addPreference( tr( "PREF_PROGRESSIVE" ), vtkRec,
2320 LightApp_Preferences::Bool, "VTKViewer", "recorder_progressive" );
2321 // ... avi recording sub-group <<end>>
2323 // ... group names sub-group <<start>>
2324 int vtkGN = pref->addPreference( tr( "PREF_FRAME_GROUP_NAMES" ), vtkGroup,
2325 LightApp_Preferences::GroupBox, "VTKViewer", "show_group_names" );
2326 pref->setItemProperty( "columns", 2, vtkGN );
2327 // .... -> text color
2328 pref->addPreference( tr( "PREF_GROUP_NAMES_TEXT_COLOR" ), vtkGN,
2329 LightApp_Preferences::Color, "VTKViewer", "group_names_text_color" );
2330 // .... -> transparency
2331 int transPref = pref->addPreference( tr( "PREF_GROUP_NAMES_TRANSPARENCY" ), vtkGN,
2332 LightApp_Preferences::DblSpin, "VTKViewer", "group_names_transparency" );
2333 pref->setItemProperty( "min", 0.0, transPref );
2334 pref->setItemProperty( "max", 1.0, transPref );
2335 pref->setItemProperty( "step", 0.1, transPref );
2336 // ... -> group names sub-group <<end>>
2337 // .. "VTK viewer" group <<end>>
2339 // .. "Plot2d viewer" group <<start>>
2340 int plot2dGroup = pref->addPreference( tr( "PREF_GROUP_PLOT2DVIEWER" ), salomeCat ); //viewTab
2341 //pref->setItemProperty( "columns", 2, plot2dGroup );
2343 // ... -> show legend
2344 pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dGroup,
2345 LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
2346 // ... -> legend position
2347 int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dGroup,
2348 LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
2349 aValuesList.clear();
2350 anIndicesList.clear();
2351 aValuesList << tr("PREF_LEFT") << tr("PREF_RIGHT") << tr("PREF_TOP") << tr("PREF_BOTTOM");
2352 anIndicesList << 0 << 1 << 2 << 3 ;
2353 pref->setItemProperty( "strings", aValuesList, legendPosition );
2354 pref->setItemProperty( "indexes", anIndicesList, legendPosition );
2355 // ... -> legend font
2356 pref->addPreference( tr( "PREF_LEGEND_FONT" ), plot2dGroup, LightApp_Preferences::Font, "Plot2d", "LegendFont" );
2357 // ... -> curve type
2358 int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dGroup,
2359 LightApp_Preferences::Selector, "Plot2d", "CurveType" );
2360 aValuesList.clear();
2361 anIndicesList.clear();
2362 aValuesList << tr("PREF_POINTS") << tr("PREF_LINES") << tr("PREF_SPLINE");
2363 anIndicesList << 0 << 1 << 2 ;
2364 pref->setItemProperty( "strings", aValuesList, curveType );
2365 pref->setItemProperty( "indexes", anIndicesList, curveType );
2366 // ... -> marker size
2367 int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dGroup,
2368 LightApp_Preferences::IntSpin, "Plot2d", "MarkerSize" );
2369 pref->setItemProperty( "min", 0, markerSize );
2370 pref->setItemProperty( "max", 100, markerSize );
2371 // ... -> horizontal scaling mode
2372 int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dGroup,
2373 LightApp_Preferences::Selector, "Plot2d", "HorScaleMode" );
2374 aValuesList.clear();
2375 anIndicesList.clear();
2376 aValuesList << tr("PREF_LINEAR") << tr("PREF_LOGARITHMIC");
2377 anIndicesList << 0 << 1 ;
2378 pref->setItemProperty( "strings", aValuesList, horScale );
2379 pref->setItemProperty( "indexes", anIndicesList, horScale );
2380 // ... -> vertical scaling mode
2381 int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dGroup,
2382 LightApp_Preferences::Selector, "Plot2d", "VerScaleMode" );
2383 pref->setItemProperty( "strings", aValuesList, verScale );
2384 pref->setItemProperty( "indexes", anIndicesList, verScale );
2385 // ... -> background
2386 pref->addPreference( tr( "PREF_VIEWER_BACKGROUND_COLOR" ), plot2dGroup,
2387 LightApp_Preferences::Color, "Plot2d", "Background" );
2388 // ... -> font color
2389 pref->addPreference( tr( "PREF_FONT_COLOR" ), plot2dGroup, LightApp_Preferences::Color, "Plot2d", "LegendFontColor" );
2390 // ... -> selection font color
2391 pref->addPreference( tr( "PREF_SELECTED_FONT_COLOR" ), plot2dGroup, LightApp_Preferences::Color, "Plot2d", "SelectedLegendFontColor" );
2392 // ... -> selection color
2393 pref->addPreference( tr( "PREF_VIEWER_SELECTION" ), plot2dGroup,
2394 LightApp_Preferences::Color, "Plot2d", "SelectionColor" );
2395 // ... -> errors/deviation colot
2396 pref->addPreference( tr( "PREF_DEVIATION_COLOR" ), plot2dGroup,
2397 LightApp_Preferences::Color, "Plot2d", "DeviationMarkerColor" );
2398 // ... -> deviation markers line size
2399 int deviationMarkerLw = pref->addPreference( tr( "PREF_DEVIATION_MARKER_LW" ), plot2dGroup,
2400 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerLineWidth" );
2401 pref->setItemProperty( "min", 1, deviationMarkerLw );
2402 pref->setItemProperty( "max", 5, deviationMarkerLw );
2403 // ... -> deviation markers tick mark size
2404 int deviationMarkerTs = pref->addPreference( tr( "PREF_DEVIATION_MARKER_TS" ), plot2dGroup,
2405 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerTickSize" );
2406 pref->setItemProperty( "min", 1, deviationMarkerTs );
2407 pref->setItemProperty( "max", 5, deviationMarkerTs );
2408 // .. "Plot2d viewer" group <<end>>
2410 // .. "Directories" preferences tab <<start>>
2411 int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat );
2412 // ... --> quick directories list
2413 int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab );
2414 pref->addPreference( tr( "" ), dirGroup,
2415 LightApp_Preferences::DirList, "FileDlg", "QuickDirList" );
2416 // .. "Directories" preferences tab <<end>>
2418 // .. "Object browser" preferences tab <<start>>
2419 int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
2421 // ... "Search tool" group <<start>>
2422 int stGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SEARCH_TOOL" ), obTab );
2423 // .... --> auto-hide
2424 pref->addPreference( tr( "PREF_AUTO_HIDE_SEARCH_TOOL" ), stGroup, LightApp_Preferences::Bool,
2425 "ObjectBrowser", "auto_hide_search_tool" );
2426 // ... "Search tool" group <<end>>
2428 // ... "Object browser settings" group <<start>>
2429 int objSetGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), obTab );
2430 pref->setItemProperty( "columns", 2, objSetGroup );
2431 // .... -> auto size first column
2432 pref->addPreference( tr( "PREF_AUTO_SIZE_FIRST" ), objSetGroup, LightApp_Preferences::Bool,
2433 "ObjectBrowser", "auto_size_first" );
2434 // .... -> auto size other columns
2435 pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool,
2436 "ObjectBrowser", "auto_size" );
2437 // .... -> resize columns on expand item
2438 pref->addPreference( tr( "PREF_RESIZE_ON_EXPAND_ITEM" ), objSetGroup, LightApp_Preferences::Bool,
2439 "ObjectBrowser", "resize_on_expand_item" );
2440 // .... -> browse to published object
2441 int browsePublished = pref->addPreference( tr( "PREF_BROWSE_TO_THE_PUBLISHED_OBJECT" ), objSetGroup, LightApp_Preferences::Selector,
2442 "ObjectBrowser", "browse_published_object" );
2443 aValuesList.clear();
2444 anIndicesList.clear();
2445 aValuesList << tr( "PREF_BROWSE_NEVER" ) << tr( "PREF_BROWSE_AFTER_APPLY_AND_CLOSE_ONLY" ) << tr( "PREF_BROWSE_ALWAYS" );
2446 anIndicesList << BP_Never << BP_ApplyAndClose << BP_Always;
2447 pref->setItemProperty( "strings", aValuesList, browsePublished );
2448 pref->setItemProperty( "indexes", anIndicesList, browsePublished );
2449 // ... "Object browser settings" group <<end>>
2450 // .. "Object browser" preferences tab <<end>>
2452 // .. "Shortcuts" preferences tab <<start>>
2453 int shortcutTab = pref->addPreference( tr( "PREF_TAB_SHORTCUTS" ), salomeCat );
2454 // ... "Shortcuts settings" group <<start>>
2455 int shortcutGroup = pref->addPreference( tr( "PREF_GROUP_SHORTCUTS" ), shortcutTab );
2456 pref->addPreference( tr( "" ), shortcutGroup,
2457 LightApp_Preferences::ShortcutTree, "shortcuts" );
2458 // ... "Shortcuts settings" group <<end>>
2459 // .. "Shortcuts" preferences tab <<end>>
2460 // . Top-level "SALOME" preferences group <<end>>
2466 Changes appearance of application according to changed preferences
2467 \param sec - section
2468 \param param - name of changed parameter
2470 void LightApp_Application::preferencesChanged( const QString& sec, const QString& param )
2472 SUIT_ResourceMgr* resMgr = resourceMgr();
2476 if ( sec == "viewers" && param == "drop_down_buttons" )
2478 ViewManagerList vmlist = viewManagers();
2479 foreach( SUIT_ViewManager* vm, vmlist )
2481 QVector<SUIT_ViewWindow*> vwlist = vm->getViews();
2482 foreach( SUIT_ViewWindow* vw, vwlist )
2483 if ( vw ) vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
2487 if ( sec == QString( "3DViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )))
2489 double sz = resMgr->doubleValue( sec, "trihedron_size", -1 );
2490 bool relative = resMgr->booleanValue( sec, "relative_size", true );
2491 QList<SUIT_ViewManager*> lst;
2492 #ifndef DISABLE_OCCVIEWER
2493 viewManagers( OCCViewer_Viewer::Type(), lst );
2494 QListIterator<SUIT_ViewManager*> itOCC( lst );
2495 while ( itOCC.hasNext() && sz >= 0 )
2497 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2498 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2501 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2502 occVM->setTrihedronSize( sz, relative );
2503 occVM->getAISContext()->UpdateCurrentViewer();
2506 #ifndef DISABLE_VTKVIEWER
2507 #ifndef DISABLE_SALOMEOBJECT
2508 viewManagers( SVTK_Viewer::Type(), lst );
2509 QListIterator<SUIT_ViewManager*> itVTK( lst );
2510 while ( itVTK.hasNext() && sz >= 0 )
2512 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2513 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2516 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2519 vtkVM->setTrihedronSize( sz, relative );
2527 if ( sec == QString( "3DViewer" ) && param == QString( "show_static_trihedron" ) )
2529 bool isVisible = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
2530 QList<SUIT_ViewManager*> lst;
2531 #ifndef DISABLE_OCCVIEWER
2532 viewManagers( OCCViewer_Viewer::Type(), lst );
2533 QListIterator<SUIT_ViewManager*> itOCC( lst );
2534 while ( itOCC.hasNext() )
2536 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2537 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2540 OCCViewer_Viewer* occVM = dynamic_cast<OCCViewer_Viewer*>( vm );
2543 occVM->setStaticTrihedronDisplayed( isVisible );
2547 #ifndef DISABLE_VTKVIEWER
2548 #ifndef DISABLE_SALOMEOBJECT
2549 viewManagers( SVTK_Viewer::Type(), lst );
2550 QListIterator<SUIT_ViewManager*> itVTK( lst );
2551 while ( itVTK.hasNext() )
2553 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2554 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2557 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2560 vtkVM->setStaticTrihedronVisible( isVisible );
2568 if ( sec == QString( "3DViewer" ) && param == QString( "navigation_mode" ) )
2570 int mode = resMgr->integerValue( "3DViewer", "navigation_mode", 0 );
2571 QList<SUIT_ViewManager*> lst;
2572 #ifndef DISABLE_OCCVIEWER
2573 viewManagers( OCCViewer_Viewer::Type(), lst );
2574 QListIterator<SUIT_ViewManager*> itOCC( lst );
2575 while ( itOCC.hasNext() )
2577 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2578 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2581 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2582 occVM->setInteractionStyle( mode );
2585 #ifndef DISABLE_VTKVIEWER
2586 #ifndef DISABLE_SALOMEOBJECT
2587 viewManagers( SVTK_Viewer::Type(), lst );
2588 QListIterator<SUIT_ViewManager*> itVTK( lst );
2589 while ( itVTK.hasNext() )
2591 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2592 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2595 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2596 if( vtkVM ) vtkVM->setInteractionStyle( mode );
2602 #ifndef DISABLE_OCCVIEWER
2603 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_preselection" ) )
2605 bool isToEnablePreselection = resMgr->booleanValue( "OCCViewer", "enable_preselection", true );
2606 QList<SUIT_ViewManager*> lst;
2607 viewManagers( OCCViewer_Viewer::Type(), lst );
2608 QListIterator<SUIT_ViewManager*> it( lst );
2609 while ( it.hasNext() )
2611 SUIT_ViewModel* vm = it.next()->getViewModel();
2612 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2615 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2616 occVM->enablePreselection( isToEnablePreselection );
2621 #ifndef DISABLE_OCCVIEWER
2622 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_selection" ) )
2624 bool isToEnableSelection = resMgr->booleanValue( "OCCViewer", "enable_selection", true );
2625 QList<SUIT_ViewManager*> lst;
2626 viewManagers( OCCViewer_Viewer::Type(), lst );
2627 QListIterator<SUIT_ViewManager*> it( lst );
2628 while ( it.hasNext() )
2630 SUIT_ViewModel* vm = it.next()->getViewModel();
2631 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2634 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2635 occVM->enableSelection( isToEnableSelection );
2640 if ( sec == QString( "3DViewer" ) && param == QString( "zooming_mode" ) )
2642 int mode = resMgr->integerValue( "3DViewer", "zooming_mode", 0 );
2643 QList<SUIT_ViewManager*> lst;
2644 #ifndef DISABLE_OCCVIEWER
2645 viewManagers( OCCViewer_Viewer::Type(), lst );
2646 QListIterator<SUIT_ViewManager*> itOCC( lst );
2647 while ( itOCC.hasNext() )
2649 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2650 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2653 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2654 occVM->setZoomingStyle( mode );
2657 #ifndef DISABLE_VTKVIEWER
2658 #ifndef DISABLE_SALOMEOBJECT
2659 viewManagers( SVTK_Viewer::Type(), lst );
2660 QListIterator<SUIT_ViewManager*> itVTK( lst );
2661 while ( itVTK.hasNext() )
2663 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2664 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2667 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2668 if( vtkVM ) vtkVM->setZoomingStyle( mode );
2674 #ifndef DISABLE_VTKVIEWER
2675 if ( sec == QString( "VTKViewer" ) && (param == QString( "speed_value" ) || param == QString( "speed_mode" )) )
2677 int speed = resMgr->integerValue( "VTKViewer", "speed_value", 10 );
2678 int mode = resMgr->integerValue( "VTKViewer", "speed_mode", 0 );
2679 QList<SUIT_ViewManager*> lst;
2680 #ifndef DISABLE_SALOMEOBJECT
2681 viewManagers( SVTK_Viewer::Type(), lst );
2682 QListIterator<SUIT_ViewManager*> it( lst );
2683 while ( it.hasNext() )
2685 SUIT_ViewModel* vm = it.next()->getViewModel();
2686 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2689 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2690 if( vtkVM ) vtkVM->setIncrementalSpeed( speed, mode );
2696 #ifndef DISABLE_VTKVIEWER
2697 if ( sec == QString( "VTKViewer" ) && param == QString( "projection_mode" ) )
2699 int mode = resMgr->integerValue( "VTKViewer", "projection_mode", 0 );
2700 QList<SUIT_ViewManager*> lst;
2701 #ifndef DISABLE_SALOMEOBJECT
2702 viewManagers( SVTK_Viewer::Type(), lst );
2703 QListIterator<SUIT_ViewManager*> it( lst );
2704 while ( it.hasNext() )
2706 SUIT_ViewModel* vm = it.next()->getViewModel();
2707 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2710 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2711 if( vtkVM ) vtkVM->setProjectionMode( mode );
2717 #ifndef DISABLE_VTKVIEWER
2718 if ( sec == QString( "VTKViewer" ) && param == QString( "preselection" ) )
2720 int mode = resMgr->integerValue( "VTKViewer", "preselection", 0 );
2721 QList<SUIT_ViewManager*> lst;
2722 #ifndef DISABLE_SALOMEOBJECT
2723 viewManagers( SVTK_Viewer::Type(), lst );
2724 QListIterator<SUIT_ViewManager*> it( lst );
2725 while ( it.hasNext() )
2727 SUIT_ViewModel* vm = it.next()->getViewModel();
2728 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2731 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2732 if( vtkVM ) vtkVM->setPreSelectionMode( mode );
2738 #ifndef DISABLE_VTKVIEWER
2739 if ( sec == QString( "VTKViewer" ) && param == QString( "enable_selection" ) )
2741 bool isToEnableSelection = resMgr->booleanValue( "VTKViewer", "enable_selection", true );
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->enableSelection( isToEnableSelection );
2759 #ifndef DISABLE_VTKVIEWER
2760 if ( sec == QString( "VTKViewer" ) && (param == QString( "spacemouse_func1_btn" ) ||
2761 param == QString( "spacemouse_func2_btn" ) ||
2762 param == QString( "spacemouse_func5_btn" ) ) )
2764 int btn1 = resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", 1 );
2765 int btn2 = resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", 2 );
2766 int btn3 = resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", 9 );
2767 QList<SUIT_ViewManager*> lst;
2768 #ifndef DISABLE_SALOMEOBJECT
2769 viewManagers( SVTK_Viewer::Type(), lst );
2770 QListIterator<SUIT_ViewManager*> it( lst );
2771 while ( it.hasNext() )
2773 SUIT_ViewModel* vm = it.next()->getViewModel();
2774 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2777 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2778 if( vtkVM ) vtkVM->setSpacemouseButtons( btn1, btn2, btn3 );
2783 if( sec=="ObjectBrowser" )
2785 SUIT_DataBrowser* ob = objectBrowser();
2789 if ( param=="auto_size_first" )
2791 bool autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
2792 ob->setAutoSizeFirstColumn( autoSizeFirst );
2793 if ( autoSizeFirst )
2794 ob->adjustFirstColumnWidth();
2796 else if ( param=="auto_size" ) {
2797 bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
2798 ob->setAutoSizeColumns(autoSize);
2800 ob->adjustColumnsWidth();
2802 else if ( param=="resize_on_expand_item" ) {
2803 bool resizeOnExpandItem = resMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
2804 ob->setResizeOnExpandItem(resizeOnExpandItem);
2806 else if ( param == "auto_hide_search_tool" ) {
2807 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
2813 if( param=="store_positions" )
2815 if( param=="auto_save_interval" ) {
2816 myAutoSaveTimer->stop();
2817 int autoSaveInterval = resMgr->integerValue( "Study", "auto_save_interval", 0 );
2818 if ( activeStudy() && autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
2822 #ifndef DISABLE_PYCONSOLE
2823 if( sec=="PyConsole" && pythonConsole() )
2825 if ( param=="font" ) {
2826 pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) );
2828 else if ( param=="show_banner" ) {
2829 pythonConsole()->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
2836 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
2838 if ( param == "visible_count" )
2839 mru->setVisibleCount( resMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
2840 else if ( param == "max_count" )
2841 mru->setHistoryCount( resMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
2842 else if ( param == "insert_mode" )
2843 mru->setInsertMode( resMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
2844 else if ( param == "link_type" )
2845 mru->setLinkType( resMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
2846 else if ( param == "show_clear" )
2847 mru->setClearPossible( resMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
2848 else if ( param == "show_mru" )
2849 mru->setVisible( resMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
2852 if ( sec == "language" && param == "language" )
2854 SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LANG_CHANGED" ) );
2856 if ( sec == "desktop" && param == "opaque_resize" ) {
2857 bool opaqueResize = resMgr->booleanValue( "desktop", "opaque_resize", false );
2858 QMainWindow::DockOptions dopts = desktop()->dockOptions();
2859 if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
2860 else dopts &= ~QMainWindow::AnimatedDocks;
2861 desktop()->setDockOptions( dopts );
2862 desktop()->setOpaqueResize( opaqueResize );
2863 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
2864 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
2867 if ( sec == "ExternalBrowser" && param == "use_external_browser" ) {
2868 if ( resMgr->booleanValue("ExternalBrowser", "use_external_browser", false ) )
2870 QtxWebBrowser::shutdown();
2874 #ifndef DISABLE_PLOT2DVIEWER
2875 if ( sec == "Plot2d" ) {
2876 if( param == "SelectionColor" ) {
2877 QColor c = resMgr->colorValue( sec, param );
2878 Plot2d_Object::setSelectionColor(c);
2880 else if (param == "SelectedLegendFontColor") {
2881 QColor c = resMgr->colorValue( sec, param );
2882 Plot2d_Object::setHighlightedLegendTextColor(c);
2891 void LightApp_Application::loadPreferences()
2893 CAM_Application::loadPreferences();
2895 SUIT_ResourceMgr* aResMgr = resourceMgr();
2900 static bool mru_load = true;
2903 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
2905 mru->setVisible( aResMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
2906 mru->setVisibleCount( aResMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
2907 mru->setHistoryCount( aResMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
2908 mru->setInsertMode( aResMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
2909 mru->setLinkType( aResMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
2910 mru->setClearPossible( aResMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
2911 mru->loadLinks( aResMgr, "MRU" );
2917 QStringList mods = aResMgr->parameters( "windows_geometry" );
2918 for ( QStringList::const_iterator it = mods.begin(); it != mods.end(); ++it )
2921 if ( aResMgr->value( "windows_geometry", *it, arr ) )
2922 myWinGeom.insert( *it, arr );
2926 mods = aResMgr->parameters( "windows_visibility" );
2927 for ( QStringList::const_iterator itr = mods.begin(); itr != mods.end(); ++itr )
2930 if ( aResMgr->value( "windows_visibility", *itr, arr ) )
2931 myWinVis.insert( *itr, arr );
2935 desktop()->retrieveGeometry( aResMgr->stringValue( "desktop", "geometry" ) );
2936 bool opaqueResize = aResMgr->booleanValue( "desktop", "opaque_resize", false );
2937 QMainWindow::DockOptions dopts = desktop()->dockOptions();
2938 if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
2939 else dopts &= ~QMainWindow::AnimatedDocks;
2940 desktop()->setDockOptions( dopts );
2941 desktop()->setOpaqueResize( opaqueResize );
2942 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
2943 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
2950 void LightApp_Application::savePreferences()
2952 CAM_Application::savePreferences();
2954 saveDockWindowsState();
2956 SUIT_ResourceMgr* aResMgr = resourceMgr();
2961 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
2963 mru->saveLinks( aResMgr, "MRU" );
2965 for ( WinGeom::const_iterator it = myWinGeom.begin(); it != myWinGeom.end(); ++it )
2966 aResMgr->setValue( "windows_geometry", it.key(), it.value() );
2968 for ( WinVis::const_iterator itr = myWinVis.begin(); itr != myWinVis.end(); ++itr )
2969 aResMgr->setValue( "windows_visibility", itr.key(), itr.value() );
2972 aResMgr->setValue( "desktop", "geometry", desktop()->storeGeometry() );
2978 Updates desktop title
2980 void LightApp_Application::updateDesktopTitle()
2982 QString aTitle = applicationName();
2983 QString aVer = applicationVersion();
2984 if ( !aVer.isEmpty() )
2985 aTitle += QString( " " ) + aVer;
2987 if ( activeStudy() ) {
2988 QString sName = SUIT_Tools::file( activeStudy()->studyName().trimmed(), false );
2989 aTitle += QString( " - [%1]" ).arg( sName );
2992 desktop()->setWindowTitle( aTitle );
2996 \brief Get map of the operations which can be performed
2997 on the module activation.
2999 The method should return the map of the kind \c {<id>:<name>}
3000 where \c <id> is an integer identifier of the operation and
3001 \c <name> is a title for the button to be added to the
3002 dialog box. After user selects the required operation by the
3003 clicking the corresponding button in the dialog box, its identifier
3004 is passed to the moduleActionSelected() method to process
3007 \return map of the operations
3008 \sa moduleActionSelected()
3010 QMap<int, QString> LightApp_Application::activateModuleActions() const
3012 QMap<int, QString> opmap;
3013 opmap.insert( NewStudyId, tr( "ACTIVATE_MODULE_OP_NEW" ) );
3014 opmap.insert( OpenStudyId, tr( "ACTIVATE_MODULE_OP_OPEN" ) );
3019 \brief Called when the used selectes required operation chosen
3020 from "Activate module" dialog box.
3022 Performs the required operation according to the user choice.
3024 \param id operation identifier
3025 \sa activateModuleActions()
3027 void LightApp_Application::moduleActionSelected( const int id )
3042 Updates windows after close document
3044 void LightApp_Application::afterCloseDoc()
3048 CAM_Application::afterCloseDoc();
3052 Updates actions of active module
3054 void LightApp_Application::updateModuleActions()
3057 if ( activeModule() ) {
3058 modName = activeModule()->moduleName();
3059 if ( !isModuleAccessible( modName ) ) {
3060 QList<SUIT_Application*> apps = SUIT_Session::session()->applications();
3061 foreach( SUIT_Application* app, apps ) {
3062 LightApp_Application* lapp = dynamic_cast<LightApp_Application*>( app );
3063 if ( lapp && lapp != this )
3064 lapp->removeModuleAction( modName );
3069 LightApp_ModuleAction* moduleAction =
3070 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
3072 moduleAction->setActiveModule( modName );
3075 void LightApp_Application::removeModuleAction( const QString& modName )
3077 LightApp_ModuleAction* moduleAction =
3078 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
3080 moduleAction->removeModule( modName );
3084 Gets current windows.
3085 \param winMap - output current windows map.
3087 void LightApp_Application::currentWindows( QMap<int, int>& winMap ) const
3090 if ( !activeStudy() )
3093 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
3094 ((LightApp_Module*)activeModule())->windows( winMap );
3096 defaultWindows( winMap );
3100 Gets current view managers.
3101 \param lst - output current view managers list.
3103 void LightApp_Application::currentViewManagers( QStringList& lst ) const
3106 if ( !activeStudy() )
3109 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
3110 ((LightApp_Module*)activeModule())->viewManagers( lst );
3112 defaultViewManagers( lst );
3118 void LightApp_Application::updateWindows()
3120 QMap<int, int> winMap;
3121 currentWindows( winMap );
3123 if ( activeStudy() )
3125 for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
3127 if ( !dockWindow( it.key() ) )
3128 getWindow( it.key() );
3132 for ( WinMap::ConstIterator it = myWin.begin(); it != myWin.end(); ++it )
3134 QWidget* wid = it.value();
3135 if ( activeStudy() )
3136 wid->setVisible( winMap.contains( it.key() ) );
3141 if ( activeStudy() )
3142 loadDockWindowsState();
3148 Updates view managers
3150 void LightApp_Application::updateViewManagers()
3153 currentViewManagers( lst );
3155 for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
3156 getViewManager( *it, true );
3160 Loads windows geometry
3162 void LightApp_Application::loadDockWindowsState()
3167 bool store = resourceMgr()->booleanValue( "Study", "store_positions", true );
3172 if ( activeModule() )
3173 modName = activeModule()->name();
3175 if ( myWinGeom.contains( modName ) )
3176 desktop()->restoreState( myWinGeom[modName] );
3178 if ( !myWinVis.contains( modName ) )
3181 QMap<QString, bool> tbMap, dwMap;
3182 dockWindowsState( myWinVis[modName], tbMap, dwMap );
3184 QList<QToolBar*> tbList = qFindChildren<QToolBar*>( desktop() );
3185 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit )
3187 QToolBar* tb = *tit;
3189 QObject* po = Qtx::findParent( tb, "QMainWindow" );
3190 if ( po != desktop() )
3193 if ( tbMap.contains( tb->objectName() ) )
3194 tb->setVisible( tbMap[tb->objectName()] );
3197 QList<QDockWidget*> dwList = qFindChildren<QDockWidget*>( desktop() );
3198 for ( QList<QDockWidget*>::iterator dit = dwList.begin(); dit != dwList.end(); ++dit )
3200 QDockWidget* dw = *dit;
3202 QObject* po = Qtx::findParent( dw, "QMainWindow" );
3203 if ( po != desktop() )
3206 if ( dwMap.contains( dw->objectName() ) )
3207 dw->setVisible( dwMap[dw->objectName()] );
3212 Saves windows geometry
3214 void LightApp_Application::saveDockWindowsState()
3219 bool store = resourceMgr()->booleanValue( "Study", "store_positions", true );
3224 if ( activeModule() )
3225 modName = activeModule()->name();
3227 myWinGeom.insert( modName, desktop()->saveState() );
3230 if ( myWinVis.contains( modName ) )
3231 visArr = myWinVis[modName];
3233 QMap<QString, bool> tbMap, dwMap;
3234 dockWindowsState( visArr, tbMap, dwMap );
3236 QList<QToolBar*> tbList = qFindChildren<QToolBar*>( desktop() );
3237 for ( QList<QToolBar*>::iterator it = tbList.begin(); it != tbList.end(); ++it )
3240 tbMap.insert( tb->objectName(), tb->toggleViewAction()->isChecked() );
3243 QList<QDockWidget*> dwList = qFindChildren<QDockWidget*>( desktop() );
3244 for ( QList<QDockWidget*>::iterator it = dwList.begin(); it != dwList.end(); ++it )
3246 QDockWidget* wid = *it;
3247 dwMap.insert( wid->objectName(), wid->toggleViewAction()->isChecked() );
3250 visArr = dockWindowsState( tbMap, dwMap );
3252 myWinVis.insert( modName, visArr );
3255 QByteArray LightApp_Application::dockWindowsState( const QMap<QString, bool>& tb, const QMap<QString, bool>& dw ) const
3258 QDataStream stream( &visArr, QIODevice::WriteOnly );
3260 stream << (uchar)ToolBarMarker;
3261 stream << tb.size();
3262 for ( QMap<QString, bool>::const_iterator tit = tb.begin(); tit != tb.end(); ++tit )
3264 stream << tit.key();
3265 stream << (uchar)( tit.value() ? 1 : 0 );
3268 stream << (uchar)DockWidgetMarker;
3269 stream << dw.size();
3270 for ( QMap<QString, bool>::const_iterator wit = dw.begin(); wit != dw.end(); ++wit )
3272 stream << wit.key();
3273 stream << (uchar)( wit.value() ? 1 : 0 );
3279 void LightApp_Application::dockWindowsState( const QByteArray& arr, QMap<QString, bool>& tb, QMap<QString, bool>& dw ) const
3284 QByteArray visArr = arr;
3285 QDataStream stream( &visArr, QIODevice::ReadOnly );
3289 if ( marker != ToolBarMarker )
3294 for ( int i = 0; i < lines; ++i )
3297 stream >> objectName;
3300 tb.insert( objectName, shown );
3304 if ( marker != DockWidgetMarker )
3308 for ( int j = 0; j < lines; ++j )
3311 stream >> objectName;
3314 dw.insert( objectName, shown );
3319 Adds icon names for modules
3321 void LightApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) const
3325 SUIT_ResourceMgr* resMgr = resourceMgr();
3329 QStringList modList;
3330 modules( modList, false );
3332 for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )
3334 QString modName = *it;
3335 QString modIntr = moduleName( modName );
3336 QString modIcon = resMgr->stringValue( modIntr, "icon", QString() );
3338 if ( modIcon.isEmpty() )
3341 if ( SUIT_Tools::extension( modIcon ).isEmpty() )
3342 modIcon += QString( ".png" );
3344 iconMap.insert( modName, modIcon );
3349 Inserts items in popup, which necessary for current application
3351 void LightApp_Application::contextMenuPopup( const QString& type, QMenu* thePopup, QString& title )
3354 LightApp_SelectionMgr* selMgr = LightApp_Application::selectionMgr();
3355 bool cacheIsOn = selMgr->isSelectionCacheEnabled();
3356 selMgr->setSelectionCacheEnabled( true );
3358 SUIT_DataBrowser* ob = objectBrowser();
3360 CAM_Application::contextMenuPopup( type, thePopup, title );
3362 if ( ob && type == ob->popupClientType() ) {
3363 thePopup->addSeparator();
3364 QAction* a = thePopup->addAction( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
3365 if ( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) )
3366 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) );
3369 if ( selMgr && ob ) {
3370 SALOME_ListIO selected;
3371 selMgr->selectedObjects( selected );
3372 if(selected.Extent() == 1){
3373 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3374 SUIT_DataObject* obj = findObject(anIObject->getEntry());
3375 if(obj && obj->renameAllowed()) {
3376 QAction* a = new QAction(tr("MEN_RENAME_OBJ"), thePopup);
3377 connect( a, SIGNAL( triggered(bool) ), ob, SLOT( onStartEditing() ) );
3378 if ( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) )
3379 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) );
3381 QList<QAction*> acts = thePopup->actions();
3382 QAction* firstAction = acts.count() > 0 ? acts.first() : 0;
3383 thePopup->insertAction(firstAction,a);
3388 selMgr->setSelectionCacheEnabled( cacheIsOn );
3394 void LightApp_Application::createEmptyStudy()
3396 CAM_Application::createEmptyStudy();
3398 if ( objectBrowser() )
3399 objectBrowser()->updateTree();
3401 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
3402 if ( aResMgr && activeStudy() ) {
3403 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
3404 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
3409 void LightApp_Application::setDesktop( SUIT_Desktop* desk )
3411 CAM_Application::setDesktop( desk );
3414 connect( desk, SIGNAL( message( const QString& ) ),
3415 this, SLOT( onDesktopMessage( const QString& ) ), Qt::UniqueConnection );
3421 \param mod - module to be activated
3423 bool LightApp_Application::activateModule( CAM_Module* mod )
3425 bool res = CAM_Application::activateModule( mod );
3427 if ( objectBrowser() )
3428 objectBrowser()->updateTree();
3434 \return keyborad accelerators manager object
3436 SUIT_Accel* LightApp_Application::accel() const
3442 Removes dead widget container from map
3444 void LightApp_Application::onWCDestroyed( QObject* ob )
3446 // remove destroyed widget container from windows map
3447 for ( WinMap::ConstIterator itr = myWin.begin(); itr != myWin.end(); ++itr )
3449 if ( itr.value() != ob )
3452 int key = itr.key();
3453 myWin.remove( key );
3458 void LightApp_Application::onMRUActivated( const QString& name )
3460 SUIT_Session* s = SUIT_Session::session();
3461 if ( s && s->activeApplication() == this )
3465 void LightApp_Application::onStylePreferences()
3467 Style_PrefDlg dlg( desktop() );
3470 resourceMgr()->setValue( "Style", "use_salome_style", Style_Salome::isActive() );
3473 void LightApp_Application::onFullScreen(){
3474 if(myScreenHelper) {
3475 if(desktop()->isFullScreen())
3476 myScreenHelper->switchToNormalScreen();
3478 myScreenHelper->switchToFullScreen();
3483 Connects just added view manager
3485 void LightApp_Application::addViewManager( SUIT_ViewManager* vm )
3487 connect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
3488 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
3489 CAM_Application::addViewManager( vm );
3493 Remove view manager from memory
3495 void LightApp_Application::removeViewManager( SUIT_ViewManager* vm )
3497 disconnect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
3498 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
3499 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
3501 aStudy->removeViewMgr(vm->getGlobalId());
3503 CAM_Application::removeViewManager( vm );
3505 LightApp_SelectionMgr* selMgr = selectionMgr();
3506 QList<SUIT_Selector*> selectors;
3507 selMgr->selectors( selectors );
3508 foreach( SUIT_Selector* selector, selectors ) {
3509 if ( selector->owner() == vm->getViewModel() ) {
3514 // IPAL22894: Crash on closing OCC view
3520 Renames active window of desktop
3522 void LightApp_Application::onRenameWindow()
3527 QWidget* w = desktop()->activeWindow();
3532 QString name = QInputDialog::getText( w, tr( "TOT_RENAME" ), tr( "PRP_RENAME" ), QLineEdit::Normal, w->windowTitle(), &ok );
3533 if( ok && !name.isEmpty() )
3534 w->setWindowTitle( name );
3538 Closes active window of desktop
3540 void LightApp_Application::onCloseWindow()
3545 QWidget* w = desktop()->activeWindow();
3553 Closes all windows of desktop
3555 void LightApp_Application::onCloseAllWindow()
3557 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
3561 QList<SUIT_ViewWindow*> wndList = desk->windows();
3562 SUIT_ViewWindow* wnd;
3563 foreach( wnd, wndList )
3571 Groups all windows of desktop
3573 void LightApp_Application::onGroupAllWindow()
3575 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
3579 QtxWorkstack* wgStack = desk->workstack();
3585 \return if the library of module exists
3586 \param moduleTitle - title of module
3588 bool LightApp_Application::isLibExists( const QString& moduleTitle ) const
3590 if( moduleTitle.isEmpty() )
3593 QString lib = moduleLibrary( moduleTitle );
3595 //abd: changed libSalomePyQtGUI to SalomePyQtGUI for WIN32
3596 bool isPythonModule = lib.contains("SalomePyQtGUI");
3597 bool isPythonLightModule = lib.contains("SalomePyQtGUILight");
3601 paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
3603 paths = QString(::getenv( "LD_LIBRARY_PATH" )).split( ":", QString::SkipEmptyParts );
3606 bool isLibFound = false;
3607 QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
3608 for( ; anIt!=aLast; anIt++ )
3610 QFileInfo inf( Qtx::addSlash( *anIt ) + lib );
3621 INFOS( "****************************************************************" << std::endl
3622 << "* Warning: library " << lib.toLatin1().constData() << " cannot be found" << std::endl
3623 << "* Module " << moduleTitle.toLatin1().constData() << " will not be available in GUI mode" << std::endl
3624 << "****************************************************************" << std::endl );
3626 else if ( !isPythonModule && !isPythonLightModule)
3629 if ( isPythonModule || isPythonLightModule)
3631 QString pylib = moduleName( moduleTitle ) + QString(".py");
3632 QString pylibgui = moduleName( moduleTitle ) + QString("GUI.py");
3634 // Check the python library
3636 // paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
3638 paths = QString(::getenv( "PYTHONPATH" )).split( ":", QString::SkipEmptyParts );
3640 bool isPyLib = false, isPyGuiLib = false;
3641 QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
3642 for( ; anIt!=aLast; anIt++ )
3644 QFileInfo inf( Qtx::addSlash( *anIt ) + pylib );
3645 QFileInfo infgui( Qtx::addSlash( *anIt ) + pylibgui );
3647 if(!isPythonLightModule)
3648 if( !isPyLib && inf.exists() )
3651 if( !isPyGuiLib && infgui.exists() )
3654 if ((isPyLib || isPythonLightModule ) && isPyGuiLib && isLibFound)
3658 printf( "****************************************************************\n" );
3659 printf( "* Warning: python library for %s cannot be found:\n", moduleTitle.toLatin1().constData() );
3661 printf( "* No module named %s\n", moduleName( moduleTitle ).toLatin1().constData() );
3663 printf( "* No module named %s\n", (moduleName( moduleTitle ) + QString("GUI")).toLatin1().constData() );
3664 printf( "****************************************************************\n" );
3671 \return default name for an active study
3673 void LightApp_Application::setDefaultStudyName( const QString& theName )
3675 QStringList anInfoList;
3676 modules( anInfoList, false );
3678 LightApp_Study* aStudy = (LightApp_Study*)activeStudy();
3679 if( anInfoList.count() == 1 && // to avoid a conflict between different modules
3680 !aStudy->isSaved() )
3682 aStudy->setStudyName( theName );
3683 updateDesktopTitle();
3688 Custom event handler
3690 bool LightApp_Application::event( QEvent* e )
3692 if( e && e->type()==2000 )
3694 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
3695 QString* d = ( QString* )ce->data();
3696 if( SUIT_MessageBox::question(0, tr("WRN_WARNING"),
3698 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
3699 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
3700 showPreferences( tr( "PREF_APP" ) );
3705 return CAM_Application::event( e );
3708 /*! Check data object */
3709 bool LightApp_Application::checkDataObject(LightApp_DataObject* theObj)
3713 bool isSuitable = !theObj->entry().isEmpty() &&
3714 !theObj->componentDataType().isEmpty() &&
3715 !theObj->name().isEmpty();
3722 int LightApp_Application::openChoice( const QString& aName )
3724 int choice = CAM_Application::openChoice( aName );
3726 if ( choice == OpenExist ) // The document is already open.
3728 // Do you want to reload it?
3729 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "QUE_DOC_ALREADYOPEN" ).arg( aName ),
3730 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No ) == SUIT_MessageBox::Yes )
3731 choice = OpenReload;
3737 bool LightApp_Application::openAction( const int choice, const QString& aName )
3744 STD_Application* app = 0;
3745 SUIT_Session* session = SUIT_Session::session();
3746 QList<SUIT_Application*> appList = session->applications();
3747 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !app; ++it )
3749 if ( (*it)->activeStudy() && (*it)->activeStudy()->studyName() == aName )
3750 app = ::qobject_cast<STD_Application*>( *it );
3755 app->onCloseDoc( false );
3756 appList = session->applications();
3757 STD_Application* other = 0;
3758 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !other; ++it )
3759 other = ::qobject_cast<STD_Application*>( *it );
3762 res = other->onOpenDoc( aName );
3767 res = CAM_Application::openAction( choice, aName );
3774 QStringList LightApp_Application::viewManagersTypes() const
3776 QStringList aTypesList;
3777 aTypesList += myUserWmTypes;
3778 #ifndef DISABLE_GLVIEWER
3779 aTypesList<<GLViewer_Viewer::Type();
3781 #ifndef DISABLE_PLOT2DVIEWER
3782 aTypesList<<Plot2d_Viewer::Type();
3784 #ifndef DISABLE_QXGRAPHVIEWER
3785 aTypesList<<QxScene_Viewer::Type();
3787 #ifndef DISABLE_OCCVIEWER
3788 aTypesList<<OCCViewer_Viewer::Type();
3790 #ifndef DISABLE_VTKVIEWER
3791 #ifndef DISABLE_SALOMEOBJECT
3792 aTypesList<<SVTK_Viewer::Type();
3794 aTypesList<<VTKViewer_Viewer::Type();
3800 * Removes all view managers of known types
3801 * Other view managers are ignored
3803 void LightApp_Application::clearKnownViewManagers()
3805 QStringList aTypesList = viewManagersTypes();
3806 QList<SUIT_ViewManager*> aMgrList;
3807 viewManagers( aMgrList );
3808 foreach (SUIT_ViewManager* aMgr, aMgrList) {
3809 if (aTypesList.contains(aMgr->getType()))
3810 removeViewManager(aMgr);
3815 Copy of current selection
3817 void LightApp_Application::onCopy()
3819 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
3825 Paste of current data in clipboard
3827 void LightApp_Application::onPaste()
3829 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
3835 Browse (i.e. set focus on) the published objects
3836 \param theIsApplyAndClose - flag indicating that the dialog for creating objects
3837 has been accepted by Ok (or Apply & Close) button
3838 \param theIsOptimizedBrowsing - flag switching to optimized browsing mode
3839 (to select the first published object only)
3840 \return entry of the selected object
3842 QString LightApp_Application::browseObjects( const QStringList& theEntryList,
3843 const bool theIsApplyAndClose,
3844 const bool theIsOptimizedBrowsing )
3847 if( SUIT_ResourceMgr* aResourceMgr = resourceMgr() )
3849 int aBrowsePolicy = aResourceMgr->integerValue( "ObjectBrowser", "browse_published_object", (int)BP_Never );
3850 switch( aBrowsePolicy )
3854 case BP_ApplyAndClose:
3855 if( !theIsApplyAndClose )
3863 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
3867 SUIT_DataBrowser* anOB = objectBrowser();
3871 SUIT_AbstractModel* aModel = dynamic_cast<SUIT_AbstractModel*>( anOB->model() );
3875 QStringListIterator anIter( theEntryList );
3876 if( theIsOptimizedBrowsing )
3878 // go to the last entry
3880 if( anIter.hasPrevious() )
3884 // scroll to each entry in the list
3885 // (in optimized mode - to the last entry only)
3887 LightApp_DataObject* anObject = 0;
3888 while( anIter.hasNext() )
3890 anEntry = anIter.next();
3891 if( !anEntry.isEmpty() )
3893 anObject = aStudy->findObjectByEntry( anEntry );
3896 QModelIndex anIndex = aModel->index( anObject );
3897 anOB->treeView()->scrollTo( anIndex );
3902 // always select the last object
3903 if( anObject && !anEntry.isEmpty() )
3905 QList<SUIT_Selector*> aSelectorList;
3906 selectionMgr()->selectors( "ObjectBrowser", aSelectorList );
3907 if( !aSelectorList.isEmpty() )
3909 if( LightApp_OBSelector* aSelector = dynamic_cast<LightApp_OBSelector*>( aSelectorList.first() ) )
3911 bool anIsAutoBlock = aSelector->autoBlock();
3913 // temporarily disable auto block, to emit LightApp_SelectionMgr::currentSelectionChanged() signal
3914 aSelector->setAutoBlock( false );
3916 SUIT_DataOwnerPtrList aList;
3917 #ifndef DISABLE_SALOMEOBJECT
3918 Handle(SALOME_InteractiveObject) aSObj = new SALOME_InteractiveObject
3919 ( anObject->entry().toLatin1().constData(),
3920 anObject->componentDataType().toLatin1().constData(),
3921 anObject->name().toLatin1().constData() );
3922 LightApp_DataOwner* owner = new LightApp_DataOwner( aSObj );
3924 LightApp_DataOwner* owner = new LightApp_DataOwner( anEntry );
3927 aList.append( owner );
3928 selectionMgr()->setSelected( aList );
3931 // restore auto block flag
3932 aSelector->setAutoBlock( anIsAutoBlock );
3940 SUIT_DataObject* LightApp_Application::findObject( const QString& id ) const
3942 LightApp_Study* study = dynamic_cast<LightApp_Study*>( activeStudy() );
3943 return study ? study->findObjectByEntry( id ) : 0;
3947 Checks that an object can be renamed.
3948 \param entry entry of the object
3949 \brief Return \c true if object can be renamed
3951 bool LightApp_Application::renameAllowed( const QString& /*entry*/) const {
3956 Rename object by entry.
3957 \param entry entry of the object
3958 \param name new name of the object
3959 \brief Return \c true if rename operation finished successfully, \c false otherwise.
3961 bool LightApp_Application::renameObject( const QString& entry, const QString& ) {
3965 /*! Process standard messages from desktop */
3966 void LightApp_Application::onDesktopMessage( const QString& message )
3968 const QString sectionSeparator = "/";
3970 if ( message.toLower() == "updateobjectbrowser" ||
3971 message.toLower() == "updateobjbrowser" ) {
3972 // update object browser
3973 updateObjectBrowser();
3976 QStringList data = message.split( sectionSeparator );
3977 if ( data.count() > 1 ) {
3978 QString msgType = data[0].trimmed();
3979 LightApp_Module* sMod = 0;
3980 CAM_Module* mod = module( msgType );
3982 mod = module( moduleTitle( msgType ) );
3983 if ( mod && mod->inherits( "LightApp_Module" ) )
3984 sMod = (LightApp_Module*)mod;
3986 if ( msgType.toLower() == "preferences" ) {
3987 // requested preferences change: should be given as "preferences/<section>/<name>/<value>"
3988 // for example "preferences/Study/multi_file_dump/true"
3989 if ( data.count() > 3 ) {
3990 QString section = data[1].trimmed();
3991 QString param = data[2].trimmed();
3992 QString value = QStringList( data.mid(3) ).join( sectionSeparator );
3993 resourceMgr()->setValue( section, param, value );
3997 // received message for the module
3998 QString msg = QStringList( data.mid(1) ).join( sectionSeparator );
3999 sMod->message( msg );