1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File: LightApp_Application.cxx
24 // Created: 6/20/2005 18:39:45 PM
25 // Author: Natalia Donis
28 // E.A. : On windows with python 2.6, there is a conflict
29 // E.A. : between pymath.h and Standard_math.h which define
30 // E.A. : some same symbols : acosh, asinh, ...
31 #include <Standard_math.hxx>
32 #ifndef DISABLE_PYCONSOLE
37 #ifndef DISABLE_PYCONSOLE
38 #include "LightApp_PyInterp.h" // WARNING! This include must be the first!
39 #include <PyConsole_Console.h>
42 #include "LightApp_Application.h"
43 #include "LightApp_Module.h"
44 #include "LightApp_DataModel.h"
45 #include "LightApp_DataOwner.h"
46 #include "LightApp_Displayer.h"
47 #include "LightApp_Study.h"
48 #include "LightApp_Preferences.h"
49 #include "LightApp_PreferencesDlg.h"
50 #include "LightApp_ModuleDlg.h"
51 #include "LightApp_AboutDlg.h"
52 #include "LightApp_ModuleAction.h"
53 // temporary commented
54 #include "LightApp_EventFilter.h"
55 #include "LightApp_OBSelector.h"
56 #include "LightApp_SelectionMgr.h"
57 #include "LightApp_DataObject.h"
58 #include "LightApp_WgViewModel.h"
59 #include "LightApp_FullScreenHelper.h"
61 #include <GUI_version.h>
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>
95 #include <LogWindow.h>
97 #ifndef DISABLE_GLVIEWER
98 #include <GLViewer_Viewer.h>
99 #include <GLViewer_ViewManager.h>
100 #include "LightApp_GLSelector.h"
103 #ifndef DISABLE_PLOT2DVIEWER
104 #include <Plot2d_ViewManager.h>
105 #include <Plot2d_ViewModel.h>
106 #include <Plot2d_ViewWindow.h>
107 #include <Plot2d_ViewFrame.h>
108 #include "LightApp_Plot2dSelector.h"
109 #ifndef DISABLE_SALOMEOBJECT
110 #include <SPlot2d_ViewModel.h>
112 #include <Plot2d_ViewModel.h>
116 #ifndef DISABLE_OCCVIEWER
117 #include <OCCViewer_ViewManager.h>
118 #include <OCCViewer_ViewFrame.h>
119 #ifndef DISABLE_SALOMEOBJECT
120 #include <SOCC_ViewModel.h>
122 #include <OCCViewer_ViewModel.h>
124 #include "LightApp_OCCSelector.h"
127 #ifndef DISABLE_VTKVIEWER
128 #ifndef DISABLE_SALOMEOBJECT
129 #include <SVTK_ViewModel.h>
130 #include <SVTK_ViewManager.h>
131 #include "LightApp_VTKSelector.h"
133 #include <VTKViewer_ViewModel.h>
134 #include <VTKViewer_ViewManager.h>
136 #include <VTKViewer_ViewModel.h>
139 #ifndef DISABLE_QXGRAPHVIEWER
140 #include <QxScene_ViewManager.h>
141 #include <QxScene_ViewModel.h>
142 #include <QxScene_ViewWindow.h>
145 #ifndef DISABLE_GRAPHICSVIEW
146 #include "GraphicsView_Viewer.h"
147 #include "GraphicsView_ViewManager.h"
148 #include "LightApp_GVSelector.h"
151 #ifndef DISABLE_PVVIEWER
152 #include "PVViewer_ViewManager.h"
153 #include "PVViewer_ViewWindow.h"
154 #include "PVViewer_ViewModel.h"
158 #define VISIBILITY_COLUMN_WIDTH 25
164 #include <QStringList>
166 #include <QApplication>
168 #include <QStatusBar>
170 #include <QObjectList>
172 #include <QInputDialog>
173 #include <QFontDatabase>
175 #include <QByteArray>
179 #include <QHeaderView>
184 #include <utilities.h>
186 #define FIRST_HELP_ID 1000000
188 #ifndef DISABLE_SALOMEOBJECT
189 #include <SALOME_InteractiveObject.hxx>
190 #include <SALOME_ListIO.hxx>
193 #include <Standard_Version.hxx>
195 #define ToolBarMarker 0
196 #define DockWidgetMarker 1
198 static const char* imageEmptyIcon[] = {
201 "....................",
202 "....................",
203 "....................",
204 "....................",
205 "....................",
206 "....................",
207 "....................",
208 "....................",
209 "....................",
210 "....................",
211 "....................",
212 "....................",
213 "....................",
214 "....................",
215 "....................",
216 "....................",
217 "....................",
218 "....................",
219 "....................",
220 "...................."};
222 int LightApp_Application::lastStudyId = 0;
224 // Markers used to parse array with dockable windows and toolbars state.
225 // For more details please see the qdockarealayout.cpp && qtoolbararealayout.cpp
226 // in the Qt source code.
228 #define QDockWidgetMarker 0xfd // = DockWidgetStateMarker
229 #define QToolBarMarker 0xfc // = ToolBarStateMarkerEx
231 // Format of the Byte array with the windows and toolbar state is:
232 // VersionMarker|version|DockWidgetStateMarker|nbDockWidgetLines|...DocWidgetData...|ToolBarStateMarkerEx|nbToolBarLines|...ToolBarData...
234 //Find toolbar marker position in the array in the following way:
235 //since the 'toolbar marker' is not unique, find index of first occurrence of the
236 //'toolbar marker' in the array and check that next string is name of the toolbar
238 int getToolbarMarkerIndex(QByteArray input, const QStringList& aFlags) {
239 int aResult = -1,tmp = 0;
240 int inputLen = input.length();
241 QDataStream anInputData(&input, QIODevice::ReadOnly);
242 while(tmp < inputLen) {
243 tmp = input.indexOf(QToolBarMarker, tmp + 1);
246 anInputData.device()->seek(tmp);
250 anInputData >> lines;
252 if(lines == 0 && anInputData.atEnd()){
253 //Case then array doesn't contain information about toolbars,
264 if(aFlags.contains(str)) {
273 \return last global id of study
275 int LightApp_Application::studyId()
277 return LightApp_Application::lastStudyId;
280 /*!Create new instance of LightApp_Application.*/
281 extern "C" LIGHTAPP_EXPORT SUIT_Application* createApplication()
283 return new LightApp_Application();
286 /*! \var global preferences of LightApp */
287 LightApp_Preferences* LightApp_Application::_prefs_ = 0;
291 \class LightApp_Application
292 Application containing LightApp module
296 LightApp_Application::LightApp_Application()
297 : CAM_Application( false ),
299 myScreenHelper(new LightApp_FullScreenHelper())
301 Q_INIT_RESOURCE( LightApp );
303 STD_TabDesktop* desk = new STD_TabDesktop();
304 desk->setFullScreenAllowed(false);
305 desk->setMinimizeAllowed(false);
309 // initialize auto save timer
310 myAutoSaveTimer = new QTimer( this );
311 myAutoSaveTimer->setSingleShot( true );
312 connect( myAutoSaveTimer, SIGNAL( timeout() ), this, SLOT( onSaveDoc() ) );
314 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
315 QPixmap aLogo = aResMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
317 desktop()->setWindowIcon( aLogo );
318 desktop()->setDockableMenuBar( false );
319 desktop()->setDockableStatusBar( false );
321 // base logo (salome itself)
322 desktop()->logoInsert( "_app_base", aResMgr->loadPixmap( "LightApp", tr( "APP_BASE_LOGO" ), false ) );
323 // extra logo (salome-based application)
324 desktop()->logoInsert( "_app_extra", aResMgr->loadPixmap( "LightApp", tr( "APP_EXTRA_LOGO" ), false ) );
328 mySelMgr = new LightApp_SelectionMgr( this );
330 myAccel = SUIT_Accel::getAccel();
332 #ifndef DISABLE_OCCVIEWER
333 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, OCCViewer_Viewer::Type() );
334 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, OCCViewer_Viewer::Type() );
335 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, OCCViewer_Viewer::Type() );
336 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, OCCViewer_Viewer::Type() );
337 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, OCCViewer_Viewer::Type() );
338 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, OCCViewer_Viewer::Type() );
339 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, OCCViewer_Viewer::Type() );
340 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, OCCViewer_Viewer::Type() );
341 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, OCCViewer_Viewer::Type() );
342 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, OCCViewer_Viewer::Type() );
343 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, OCCViewer_Viewer::Type() );
344 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, OCCViewer_Viewer::Type() );
346 #ifndef DISABLE_VTKVIEWER
347 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, VTKViewer_Viewer::Type() );
348 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, VTKViewer_Viewer::Type() );
349 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, VTKViewer_Viewer::Type() );
350 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, VTKViewer_Viewer::Type() );
351 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, VTKViewer_Viewer::Type() );
352 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, VTKViewer_Viewer::Type() );
353 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, VTKViewer_Viewer::Type() );
354 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, VTKViewer_Viewer::Type() );
355 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, VTKViewer_Viewer::Type() );
356 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, VTKViewer_Viewer::Type() );
357 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, VTKViewer_Viewer::Type() );
358 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, VTKViewer_Viewer::Type() );
360 #ifndef DISABLE_PLOT2DVIEWER
361 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, Plot2d_Viewer::Type() );
362 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, Plot2d_Viewer::Type() );
363 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, Plot2d_Viewer::Type() );
364 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, Plot2d_Viewer::Type() );
365 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, Plot2d_Viewer::Type() );
366 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, Plot2d_Viewer::Type() );
367 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, Plot2d_Viewer::Type() );
368 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, Plot2d_Viewer::Type() );
371 connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) );
372 connect( desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
373 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
374 connect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
375 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ), Qt::UniqueConnection );
378 // Set existing font for the python console in resources
379 if( !aResMgr->hasValue( "PyConsole", "font" ) )
382 QFont f = aResMgr->fontValue( "PyConsole", "font" );
384 QStringList famdb = fdb.families();
386 if ( famdb.contains(f.family()) || !aResMgr->hasValue( "PyConsole", "additional_families" ) )
389 QStringList anAddFamilies = aResMgr->stringValue( "PyConsole", "additional_families" ).split( ";", QString::SkipEmptyParts );
391 for ( QStringList::Iterator it = anAddFamilies.begin(); it != anAddFamilies.end(); ++it )
394 if ( famdb.contains(aFamily) )
396 f.setFamily( aFamily );
397 aResMgr->setValue( "PyConsole", "font", f );
404 *\li Save window geometry.
405 *\li Save desktop geometry.
406 *\li Save resource maneger.
407 *\li Delete selection manager.
409 LightApp_Application::~LightApp_Application()
412 delete myScreenHelper;
415 /*!Start application.*/
416 void LightApp_Application::start()
418 CAM_Application::start();
421 updateViewManagers();
422 updateCommandsStatus();
425 desktop()->statusBar()->showMessage( "" );
427 LightApp_EventFilter::Init();
430 /*!Gets application name.*/
431 QString LightApp_Application::applicationName() const
433 static QString _app_name;
434 if ( _app_name.isEmpty() )
435 _app_name = tr( "APP_NAME" );
439 /*!Gets application version.*/
440 QString LightApp_Application::applicationVersion() const
442 static QString _app_version;
444 if ( _app_version.isEmpty() )
446 QString resVersion = tr( "APP_VERSION" );
447 if ( resVersion != "APP_VERSION" )
449 _app_version = resVersion;
453 _app_version = GUI_VERSION_STR;
459 /*!Load module by \a name.*/
460 CAM_Module* LightApp_Application::loadModule( const QString& name, const bool showMsg )
462 CAM_Module* mod = CAM_Application::loadModule( name, showMsg );
465 connect( this, SIGNAL( studyOpened() ), mod, SLOT( onModelOpened() ) );
466 connect( this, SIGNAL( studySaved() ), mod, SLOT( onModelSaved() ) );
467 connect( this, SIGNAL( studyClosed() ), mod, SLOT( onModelClosed() ) );
472 /*!Activate module by \a modName*/
473 bool LightApp_Application::activateModule( const QString& modName )
476 CAM_Module* prevMod = activeModule();
479 actName = prevMod->moduleName();
481 if ( actName == modName )
484 putInfo( tr( "ACTIVATING_MODULE" ).arg( modName ) );
486 saveDockWindowsState();
488 bool status = CAM_Application::activateModule( modName );
490 updateModuleActions();
498 updateViewManagers();
503 /*!Gets selection manager.*/
504 LightApp_SelectionMgr* LightApp_Application::selectionMgr() const
509 /*!Creat action "New window" for certain type of viewer:*/
510 void LightApp_Application::createActionForViewer( const int id,
512 const QString& suffix,
515 QString vtlt = tr( QString( "NEW_WINDOW_%1" ).arg( suffix ).toLatin1().constData() );
516 QString tip = tr( "CREATING_NEW_WINDOW" ).arg( vtlt.remove( "&" ) );
517 QAction* a = createAction( id, // menu action id
524 false, // toggle flag
526 SLOT( onNewWindow() ) ); // slot
527 createMenu( a, parentId, -1 );
532 void LightApp_Application::createActions()
534 CAM_Application::createActions();
536 SUIT_Desktop* desk = desktop();
537 SUIT_ResourceMgr* resMgr = resourceMgr();
540 createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIcon(),
541 tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
542 Qt::CTRL+Qt::Key_R, desk, false, this, SLOT( onPreferences() ) );
546 // - Help for modules
548 int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
549 createMenu( separator(), helpMenu, -1, 10 );
550 QStringList aModuleList;
551 modules( aModuleList, false );
552 aModuleList.prepend( "GUI" );
553 aModuleList.prepend( "KERNEL" );
555 int id = LightApp_Application::UserID + FIRST_HELP_ID;
558 foreach( aModule, aModuleList ) {
559 if ( aModule.isEmpty() ) // module title (user name)
561 IMap <QString, QString> helpData; // list of help files for the module
562 QString helpSubMenu; // help submenu name (empty if not needed)
563 QString modName = moduleName( aModule ); // module name
564 if ( modName.isEmpty() ) modName = aModule; // for KERNEL and GUI
565 QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName ); // module root dir variable
566 QString modDir = getenv( rootDir.toLatin1().constData() ); // module root dir
568 if (resMgr->hasValue( modName, "documentation" ) )
569 docSection = resMgr->stringValue(modName, "documentation");
570 else if ( resMgr->hasSection( modName + "_documentation" ) )
571 docSection = modName + "_documentation";
572 if ( !docSection.isEmpty() ) {
573 helpSubMenu = resMgr->stringValue( docSection, "sub_menu", "" ).arg( aModule );
574 QStringList listOfParam = resMgr->parameters( docSection );
575 foreach( QString paramName, listOfParam ) {
576 QString valueStr = resMgr->stringValue( docSection, paramName );
577 if ( !valueStr.isEmpty() ) {
578 QFileInfo fi( valueStr );
579 if ( fi.isRelative() && !modDir.isEmpty() )
580 valueStr = Qtx::addSlash( modDir ) + valueStr;
581 if ( QFile::exists( valueStr ) )
582 helpData.insert( paramName.arg( aModule ), valueStr );
587 if ( helpData.isEmpty() && !modDir.isEmpty() ) {
588 QStringList idxLst = QStringList() << modDir << "share" << "doc" << "salome" << "gui" << modName << "index.html";
589 QString indexFile = idxLst.join( QDir::separator() ); // index file
590 if ( QFile::exists( indexFile ) )
591 helpData.insert( tr( "%1 module Users's Guide" ).arg( aModule ), indexFile );
594 IMapConstIterator<QString, QString > fileIt;
595 for ( fileIt = helpData.begin(); fileIt != helpData.end(); fileIt++ ) {
596 QString helpFileName = fileIt.key();
597 // remove all '//' occurances
598 while ( helpFileName.contains( "//" ) )
599 helpFileName.replace( "//", "" );
600 // obtain submenus hierarchy if given
601 QStringList smenus = helpFileName.split( "/" );
602 helpFileName = smenus.last();
604 QAction* a = createAction( id, helpFileName,
605 resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
606 helpFileName, helpFileName,
607 0, desk, false, this, SLOT( onHelpContentsModule() ) );
608 a->setData( fileIt.value() );
609 if ( !helpSubMenu.isEmpty() ) {
610 smenus.prepend( helpSubMenu );
612 // create sub-menus hierarchy
613 int menuId = helpMenu;
614 foreach ( QString subMenu, smenus ) {
615 menuId = createMenu( subMenu, menuId, -1, 0 );
617 createMenu( a, menuId, -1, 0 );
622 // - Additional help items
624 createMenu( separator(), helpMenu, -1, 5 );
626 QStringList addHelpItems = resMgr->parameters( "add_help" );
627 foreach ( QString addHelpItem, addHelpItems ) {
628 QString valueStr = resMgr->stringValue( "add_help", addHelpItem );
629 if ( !valueStr.isEmpty() && QFile::exists( valueStr ) ) {
630 QAction* a = createAction( id, addHelpItem,
631 resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
632 addHelpItem, addHelpItem,
633 0, desk, false, this, SLOT( onHelpContentsModule() ) );
634 a->setData( valueStr );
635 createMenu( a, helpMenu, -1, 5 );
641 static QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), 0 );
642 connect( mru, SIGNAL( activated( const QString& ) ), this, SLOT( onMRUActivated( const QString& ) ) );
643 registerAction( MRUId, mru );
645 // default icon for neutral point ('SALOME' module)
646 QPixmap defIcon = resMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
647 if ( defIcon.isNull() )
648 defIcon = QPixmap( imageEmptyIcon );
650 //! default icon for any module
651 QPixmap modIcon = resMgr->loadPixmap( "LightApp", tr( "APP_MODULE_ICO" ), false );
652 if ( modIcon.isNull() )
653 modIcon = QPixmap( imageEmptyIcon );
656 modules( modList, false );
658 if ( modList.count() > 1 )
660 LightApp_ModuleAction* moduleAction =
661 new LightApp_ModuleAction( tr( "APP_NAME" ), defIcon, desk );
663 QMap<QString, QString> iconMap;
664 moduleIconNames( iconMap );
666 const int iconSize = 20;
668 QStringList::Iterator it;
669 for ( it = modList.begin(); it != modList.end(); ++it )
671 if ( !isLibExists( *it ) )
674 QString modName = moduleName( *it );
676 if ( !isModuleAccessible( *it ) )
680 if ( iconMap.contains( *it ) )
681 iconName = iconMap[*it];
683 QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
687 INFOS ( "\n****************************************************************" << std::endl
688 << "* Icon for " << (*it).toLatin1().constData()
689 << " not found. Using the default one." << std::endl
690 << "****************************************************************" << std::endl );
693 icon = Qtx::scaleIcon( icon, iconSize );
695 moduleAction->insertModule( *it, icon );
698 connect( moduleAction, SIGNAL( moduleActivated( const QString& ) ),
699 this, SLOT( onModuleActivation( const QString& ) ) );
700 registerAction( ModulesListId, moduleAction );
704 int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, MenuWindowId, 100 );
705 int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
707 createAction( CloseId, tr( "TOT_CLOSE" ), QIcon(), tr( "MEN_DESK_CLOSE" ), tr( "PRP_CLOSE" ),
708 Qt::CTRL+Qt::Key_F4, desk, false, this, SLOT( onCloseWindow() ) );
709 createAction( CloseAllId, tr( "TOT_CLOSE_ALL" ), QIcon(), tr( "MEN_DESK_CLOSE_ALL" ), tr( "PRP_CLOSE_ALL" ),
710 0, desk, false, this, SLOT( onCloseAllWindow() ) );
711 createAction( GroupAllId, tr( "TOT_GROUP_ALL" ), QIcon(), tr( "MEN_DESK_GROUP_ALL" ), tr( "PRP_GROUP_ALL" ),
712 0, desk, false, this, SLOT( onGroupAllWindow() ) );
714 createMenu( CloseId, windowMenu, 0, -1 );
715 createMenu( CloseAllId, windowMenu, 0, -1 );
716 createMenu( GroupAllId, windowMenu, 0, -1 );
717 createMenu( separator(), windowMenu, -1, 0 );
719 #ifndef DISABLE_GLVIEWER
720 createActionForViewer( NewGLViewId, newWinMenu, QString::number( 0 ), Qt::ALT+Qt::Key_G );
722 #ifndef DISABLE_PLOT2DVIEWER
723 createActionForViewer( NewPlot2dId, newWinMenu, QString::number( 1 ), Qt::ALT+Qt::Key_P );
725 #ifndef DISABLE_OCCVIEWER
726 createActionForViewer( NewOCCViewId, newWinMenu, QString::number( 2 ), Qt::ALT+Qt::Key_O );
728 #ifndef DISABLE_VTKVIEWER
729 createActionForViewer( NewVTKViewId, newWinMenu, QString::number( 3 ), Qt::ALT+Qt::Key_K );
731 #ifndef DISABLE_QXGRAPHVIEWER
732 createActionForViewer( NewQxSceneViewId, newWinMenu, QString::number( 4 ), Qt::ALT+Qt::Key_S );
734 #ifndef DISABLE_GRAPHICSVIEW
735 createActionForViewer( NewGraphicsViewId, newWinMenu, QString::number( 5 ), Qt::ALT+Qt::Key_R );
737 #ifndef DISABLE_PVVIEWER
738 createActionForViewer( NewPVViewId, newWinMenu, QString::number( 6 ), Qt::ALT+Qt::Key_W );
741 createAction( RenameId, tr( "TOT_RENAME" ), QIcon(), tr( "MEN_DESK_RENAME" ), tr( "PRP_RENAME" ),
742 Qt::ALT+Qt::SHIFT+Qt::Key_R, desk, false, this, SLOT( onRenameWindow() ) );
743 createMenu( RenameId, windowMenu, -1 );
745 int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
746 createMenu( PreferencesId, fileMenu, 50, -1 );
747 createMenu( separator(), fileMenu, -1, 50, -1 );
749 createMenu( separator(), fileMenu, -1, 100, -1 );
750 createMenu( MRUId, fileMenu, 100, -1 );
751 createMenu( separator(), fileMenu, -1, 100, -1 );
753 createAction( StyleId, tr( "TOT_THEME" ), QIcon(), tr( "MEN_DESK_THEME" ), tr( "PRP_THEME" ),
754 0, desk, false, this, SLOT( onStylePreferences() ) );
756 createAction( FullScreenId, tr( "TOT_FULLSCREEN" ), QIcon(), tr( "MEN_DESK_FULLSCREEN" ), tr( "PRP_FULLSCREEN" ),
757 Qt::Key_F11, desk, false, this, SLOT( onFullScreen() ) );
760 int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1 );
761 createMenu( separator(), viewMenu, -1, 20, -1 );
762 createMenu( StyleId, viewMenu, 20, -1 );
763 createMenu( FullScreenId, viewMenu, 20, -1 );
765 int modTBar = createTool( tr( "INF_TOOLBAR_MODULES" ), // title (language-dependant)
766 QString( "SalomeModules" ) ); // name (language-independant)
767 createTool( ModulesListId, modTBar );
770 /*!On module activation action.*/
771 void LightApp_Application::onModuleActivation( const QString& modName )
773 // Force user to create/open a study before module activation
774 QMap<QString, QString> iconMap;
775 moduleIconNames( iconMap );
776 QPixmap icon = resourceMgr()->loadPixmap( moduleName( modName ), iconMap[ modName ], false );
778 icon = resourceMgr()->loadPixmap( "LightApp", tr( "APP_MODULE_BIG_ICO" ), false ); // default icon for any module
780 bool cancelled = false;
782 while ( !modName.isEmpty() && !activeStudy() && !cancelled ){
783 LightApp_ModuleDlg aDlg( desktop(), modName, icon );
784 QMap<int, QString> opmap = activateModuleActions();
785 for ( QMap<int, QString>::ConstIterator it = opmap.begin(); it != opmap.end(); ++it )
786 aDlg.addButton( it.value(), it.key() );
788 int res = aDlg.exec();
790 // some operation is selected
791 moduleActionSelected( res );
795 putInfo( tr("INF_CANCELLED") );
797 LightApp_ModuleAction* moduleAction =
798 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
800 moduleAction->setActiveModule( QString() );
806 activateModule( modName );
809 /*!Default module activation.*/
810 QString LightApp_Application::defaultModule() const
812 QStringList aModuleNames;
813 modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration
814 //! If there's the one and only module --> activate it automatically
815 //! TODO: Possible improvement - default module can be taken from preferences
816 return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" );
819 /*!On new window slot.*/
820 void LightApp_Application::onNewWindow()
822 const QObject* obj = sender();
823 if ( !obj || !obj->inherits( "QAction" ) )
827 int id = actionId( (QAction*)obj );
830 #ifndef DISABLE_GLVIEWER
832 type = GLViewer_Viewer::Type();
835 #ifndef DISABLE_PLOT2DVIEWER
837 type = Plot2d_Viewer::Type();
840 #ifndef DISABLE_OCCVIEWER
842 type = OCCViewer_Viewer::Type();
845 #ifndef DISABLE_VTKVIEWER
847 type = VTKViewer_Viewer::Type();
850 #ifndef DISABLE_QXGRAPHVIEWER
851 case NewQxSceneViewId:
852 type = QxScene_Viewer::Type();
855 #ifndef DISABLE_GRAPHICSVIEW
856 case NewGraphicsViewId:
857 type = GraphicsView_Viewer::Type();
860 #ifndef DISABLE_PVVIEWER
862 type = PVViewer_Viewer::Type();
867 if ( !type.isEmpty() )
868 createViewManager( type );
872 SLOT: Creates new document
874 void LightApp_Application::onNewDoc()
876 #ifdef SINGLE_DESKTOP
877 if ( !checkExistingDoc() )
881 //asl: fix for 0020515
882 saveDockWindowsState();
884 CAM_Application::onNewDoc();
888 SLOT: Opens new document
890 void LightApp_Application::onOpenDoc()
892 SUIT_Study* study = activeStudy();
894 #ifdef SINGLE_DESKTOP
895 if ( !checkExistingDoc() )
899 CAM_Application::onOpenDoc();
901 if ( !study ) // new study will be create in THIS application
904 updateViewManagers();
909 SLOT: Opens new document.
910 \param aName - name of file
912 bool LightApp_Application::onOpenDoc( const QString& aName )
914 #ifdef SINGLE_DESKTOP
915 if ( !checkExistingDoc() )
919 saveDockWindowsState();
921 // We should take mru action first because this application instance can be deleted later.
922 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
924 bool res = CAM_Application::onOpenDoc( aName );
929 mru->insert( aName );
931 mru->remove( aName );
937 SLOT: Displays "About" message box
939 void LightApp_Application::onHelpAbout()
941 LightApp_AboutDlg dlg( applicationName(), applicationVersion(), desktop() );
946 Private SLOT: Called on selection is changed
947 Dispatchs active module that selection is changed
949 void LightApp_Application::onSelection()
951 onSelectionChanged();
953 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
954 ((LightApp_Module*)activeModule())->selectionChanged();
959 \param study - SUIT_Study.
961 void LightApp_Application::setActiveStudy( SUIT_Study* study )
963 CAM_Application::setActiveStudy( study );
967 Enables/Disables menu items and toolbar buttons. Rebuild menu
969 void LightApp_Application::updateCommandsStatus()
971 CAM_Application::updateCommandsStatus();
974 #ifndef DISABLE_GLVIEWER
975 a = action( NewGLViewId );
977 a->setEnabled( activeStudy() );
980 #ifndef DISABLE_PLOT2DVIEWER
981 a = action( NewPlot2dId );
983 a->setEnabled( activeStudy() );
986 #ifndef DISABLE_OCCVIEWER
987 a = action( NewOCCViewId );
989 a->setEnabled( activeStudy() );
992 #ifndef DISABLE_VTKVIEWER
993 a = action( NewVTKViewId );
995 a->setEnabled( activeStudy() );
998 #ifndef DISABLE_QXGRAPHVIEWER
999 a = action( NewQxSceneViewId );
1001 a->setEnabled( activeStudy() );
1004 #ifndef DISABLE_GRAPHICSVIEW
1005 a = action( NewGraphicsViewId );
1007 a->setEnabled( activeStudy() );
1010 #ifndef DISABLE_PVVIEWER
1011 a = action( NewPVViewId );
1013 a->setEnabled( activeStudy() );
1019 Runs system command in separate thread
1021 class RunBrowser: public QThread
1024 RunBrowser( LightApp_Application* app,
1025 const QString& theApp,
1026 const QString& theParams,
1027 const QString& theHelpFile,
1028 const QString& theContext = QString() )
1030 myParams( theParams ),
1031 myContext( theContext ),
1035 //For the external browser always specify 'file://' protocol,
1036 //because some WEB browsers (for example Mozilla Firefox) can't open local file without protocol.
1037 myHelpFile = QString("file://%1").arg( QFileInfo( theHelpFile ).canonicalFilePath() );
1042 if ( !myApp.isEmpty() && !myHelpFile.isEmpty()) {
1043 QString aCommand = QString( "%1 %2 \"%3%4\"" ).arg( myApp, myParams, myHelpFile, myContext.isEmpty() ? QString("") : QString( "#%1" ).arg( myContext ) );
1045 QProcess* proc = new QProcess();
1047 proc->start( aCommand );
1048 if ( !proc->waitForStarted() ) {
1049 SALOME_CustomEvent* ce2000 = new SALOME_CustomEvent( 2000 );
1050 QString* msg = new QString( QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).arg( myApp, myHelpFile ) );
1051 ce2000->setData( msg );
1052 QApplication::postEvent( myLApp, ce2000 );
1063 LightApp_Application* myLApp;
1067 SLOT: Displays help contents for choosen module
1069 void LightApp_Application::onHelpContentsModule()
1071 const QAction* a = (QAction*) sender();
1072 QString helpFile = a->data().toString();
1073 if ( helpFile.isEmpty() ) return;
1075 SUIT_ResourceMgr* resMgr = resourceMgr();
1078 platform = "winapplication";
1080 platform = "application";
1082 QString anApp = resMgr->stringValue("ExternalBrowser", platform);
1084 QString quote("\"");
1085 anApp.prepend( quote );
1086 anApp.append( quote );
1088 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
1089 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1091 if( useExtBrowser ) {
1092 if ( !anApp.isEmpty() ) {
1093 RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile );
1097 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1098 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1099 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1101 showPreferences( tr( "PREF_APP" ) );
1105 QStringList parameters;
1106 parameters << QString( "--language=%1" ).arg( resMgr->stringValue( "language", "language" ) );
1107 parameters << helpFile;
1108 QProcess::startDetached( "HelpBrowser", parameters );
1113 SLOT: Displays help contents for choosen dialog
1115 void LightApp_Application::onHelpContextModule( const QString& theComponentName,
1116 const QString& theFileName,
1117 const QString& theContext )
1119 QString fileName = theFileName;
1120 QString context = theContext;
1121 if ( !QFile::exists( fileName ) && theContext.isEmpty() ) {
1122 // context might be passed within theFileName argument
1123 QStringList comps = fileName.split("#");
1124 if ( comps.count() > 1 ) {
1125 context = comps.last();
1127 fileName = comps.join("#");
1131 QString homeDir = "";
1132 if ( !theComponentName.isEmpty() ) {
1133 QString dir = getenv( ( theComponentName + "_ROOT_DIR" ).toLatin1().constData() );
1134 if ( !dir.isEmpty() )
1135 homeDir = Qtx::addSlash( Qtx::addSlash( dir ) +
1136 Qtx::addSlash( "share" ) +
1137 Qtx::addSlash( "doc" ) +
1138 Qtx::addSlash( "salome" ) +
1139 Qtx::addSlash( "gui" ) +
1140 Qtx::addSlash( theComponentName ) );
1143 QString helpFile = QFileInfo( homeDir + fileName ).absoluteFilePath();
1144 SUIT_ResourceMgr* resMgr = resourceMgr();
1147 platform = "winapplication";
1149 platform = "application";
1151 QString anApp = resMgr->stringValue("ExternalBrowser", platform);
1153 QString quote("\"");
1154 anApp.prepend( quote );
1155 anApp.append( quote );
1158 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1161 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
1163 if ( !anApp.isEmpty() ) {
1164 RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile, context );
1168 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1169 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1170 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1171 showPreferences( tr( "PREF_APP" ) );
1175 QStringList parameters;
1176 parameters << QString( "--language=%1" ).arg( resMgr->stringValue( "language", "language" ) );
1177 parameters << QString( "%1#%2" ).arg( helpFile ).arg( context );
1178 QProcess::startDetached( "HelpBrowser", parameters );
1183 Sets enable or disable some actions on selection changed.
1185 void LightApp_Application::onSelectionChanged()
1187 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
1188 bool canCopy = m ? m->canCopy() : false;
1189 bool canPaste = m ? m->canPaste() : false;
1191 action( EditCopyId )->setEnabled(canCopy);
1192 action( EditPasteId )->setEnabled(canPaste);
1195 QWidget* LightApp_Application::dockWindow( const int id ) const
1198 if ( myWin.contains( id ) )
1203 QDockWidget* LightApp_Application::windowDock( QWidget* wid ) const
1208 QDockWidget* dock = 0;
1209 QWidget* w = wid->parentWidget();
1210 while ( w && !dock )
1212 dock = ::qobject_cast<QDockWidget*>( w );
1213 w = w->parentWidget();
1218 void LightApp_Application::insertDockWindow( const int id, QWidget* wid )
1223 if ( wid != dockWindow( id ) )
1224 removeDockWindow( id );
1226 myWin.insert( id, wid );
1228 QtxDockWidget* dock = new QtxDockWidget( true, desktop() );
1229 connect( dock, SIGNAL( destroyed( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
1231 dock->setFeatures( QDockWidget::AllDockWidgetFeatures );
1232 dock->setObjectName( wid->objectName().isEmpty() ? QString( "window_%1" ).arg( id ) :
1233 QString( "%1Dock" ).arg( wid->objectName() ) );
1234 dock->setWidget( wid );
1236 QKeySequence accel = wid->property( "shortcut" ).value<QKeySequence>();
1237 if ( !accel.isEmpty() )
1238 dock->toggleViewAction()->setShortcut( accel );
1243 void LightApp_Application::removeDockWindow( const int id )
1245 QWidget* wid = dockWindow( id );
1251 QDockWidget* dock = windowDock( wid );
1255 dock->setWidget( 0 );
1256 wid->setParent( 0 );
1257 wid->setVisible( false );
1261 void LightApp_Application::placeDockWindow( const int id, Qt::DockWidgetArea place )
1263 QDockWidget* dock = windowDock( dockWindow( id ) );
1264 if ( dock && desktop() ) {
1265 desktop()->addDockWidget( place, dock );
1266 QtxDockAction* a = qobject_cast<QtxDockAction*>( action( ViewWindowsId ) );
1267 if ( a ) a->update();
1273 \param flag - key for window
1274 \param studyId - study id
1275 Flag used how identificator of window in windows list.
1277 QWidget* LightApp_Application::getWindow( const int flag, const int )
1279 QWidget* wid = dockWindow( flag );
1281 insertDockWindow( flag, wid = createWindow( flag ) );
1283 QMap<int, int> winMap;
1284 currentWindows( winMap );
1285 if ( winMap.contains( flag ) )
1286 placeDockWindow( flag, (Qt::DockWidgetArea)winMap[flag] );
1292 \return Object Browser
1294 SUIT_DataBrowser* LightApp_Application::objectBrowser()
1296 return qobject_cast<SUIT_DataBrowser*>( dockWindow( WT_ObjectBrowser ) );
1302 LogWindow* LightApp_Application::logWindow()
1304 return qobject_cast<LogWindow*>( dockWindow( WT_LogWindow ) );
1307 #ifndef DISABLE_PYCONSOLE
1309 This returns the python console integrated to the GUI. Depending
1310 when you request the python console, this function could return
1311 null. Then the optional parameter force (default to false) can be
1312 set to force the creation of the python console if it is not done
1314 \param force - if true, the pythonConsole is created if it does not exist yet
1315 \return Python Console
1317 PyConsole_Console* LightApp_Application::pythonConsole(const bool force)
1319 QWidget* wid = dockWindow( WT_PyConsole );
1320 if ( !wid && force==true) {
1321 wid = getWindow(WT_PyConsole);
1323 return qobject_cast<PyConsole_Console*>( wid );
1328 Updates object browser and maybe data models
1329 \param updateModels - if it is true, then data models are updated
1331 void LightApp_Application::updateObjectBrowser( const bool updateModels )
1333 // update existing data models
1336 const bool isAutoUpdate = objectBrowser() ? objectBrowser()->autoUpdate() : true;
1337 if ( objectBrowser() )
1338 objectBrowser()->setAutoUpdate( false );
1340 LightApp_Study* study = dynamic_cast<LightApp_Study*>(activeStudy());
1342 CAM_Study::ModelList dm_list;
1343 study->dataModels( dm_list );
1344 QListIterator<CAM_DataModel*> it( dm_list );
1345 while ( it.hasNext() ) {
1346 CAM_DataModel* camDM = it.next();
1347 if ( camDM && camDM->inherits( "LightApp_DataModel" ) )
1348 ((LightApp_DataModel*)camDM)->update();
1352 if( objectBrowser() )
1353 objectBrowser()->setAutoUpdate( isAutoUpdate );
1356 if ( objectBrowser() ) {
1357 objectBrowser()->updateGeometry();
1358 objectBrowser()->updateTree( 0, false );
1365 LightApp_Preferences* LightApp_Application::preferences() const
1367 return preferences( false );
1371 \return first view manager of some type
1372 \param vmType - type of view manager
1373 \param create - is it necessary to create view manager in case, when there is no manager of such type
1375 SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, const bool create )
1377 SUIT_ViewManager* aVM = viewManager( vmType );
1378 SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
1380 if ( anActiveVM && anActiveVM->getType() == vmType )
1383 if ( aVM && create )
1385 if ( !aVM->getActiveView() )
1388 aVM->getActiveView()->setFocus();
1391 aVM = createViewManager( vmType );
1397 Creates view manager of some type
1398 \param vmType - type of view manager
1400 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType )
1402 SUIT_ResourceMgr* resMgr = resourceMgr();
1404 SUIT_ViewManager* viewMgr = 0;
1405 #ifndef DISABLE_GLVIEWER
1406 if( vmType == GLViewer_Viewer::Type() )
1408 viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() );
1409 new LightApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
1412 #ifndef DISABLE_PLOT2DVIEWER
1413 if( vmType == Plot2d_Viewer::Type() )
1415 viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
1417 #ifndef DISABLE_SALOMEOBJECT
1418 SPlot2d_Viewer* v = new SPlot2d_Viewer();
1420 new LightApp_Plot2dSelector( v, mySelMgr );
1422 vm = new Plot2d_Viewer();
1424 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1425 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
1428 Plot2d_ViewFrame* frame = wnd->getViewFrame();
1429 frame->setBackgroundColor( resMgr->colorValue( "Plot2d", "Background", frame->backgroundColor() ) );
1433 #ifndef DISABLE_QXGRAPHVIEWER
1434 if( vmType == QxScene_Viewer::Type() )
1436 viewMgr = new QxScene_ViewManager( activeStudy(), desktop() );
1437 QxScene_Viewer* vm = new QxScene_Viewer();
1438 viewMgr->setViewModel( vm );
1439 //QxScene_ViewWindow* wnd = dynamic_cast<QxScene_ViewWindow*>( viewMgr->getActiveView() );
1442 #ifndef DISABLE_GRAPHICSVIEW
1443 if( vmType == GraphicsView_Viewer::Type() )
1445 viewMgr = new GraphicsView_ViewManager( activeStudy(), desktop() );
1446 new LightApp_GVSelector( (GraphicsView_Viewer*)viewMgr->getViewModel(), mySelMgr );
1449 #ifndef DISABLE_PVVIEWER
1450 if( vmType == PVViewer_Viewer::Type() )
1452 viewMgr = new PVViewer_ViewManager( activeStudy(), desktop(), logWindow() );
1455 #ifndef DISABLE_OCCVIEWER
1456 if( vmType == OCCViewer_Viewer::Type() )
1458 viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
1459 OCCViewer_Viewer* vm;
1460 #ifndef DISABLE_SALOMEOBJECT
1461 vm = new SOCC_Viewer();
1463 vm = new OCCViewer_Viewer( true );
1465 vm->setBackground( OCCViewer_ViewFrame::TOP_LEFT,
1466 resMgr->backgroundValue( "OCCViewer", "xz_background", vm->background(OCCViewer_ViewFrame::TOP_LEFT) ) );
1467 vm->setBackground( OCCViewer_ViewFrame::TOP_RIGHT,
1468 resMgr->backgroundValue( "OCCViewer", "yz_background", vm->background(OCCViewer_ViewFrame::TOP_RIGHT) ) );
1469 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_LEFT,
1470 resMgr->backgroundValue( "OCCViewer", "xy_background", vm->background(OCCViewer_ViewFrame::BOTTOM_LEFT) ) );
1471 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_RIGHT,
1472 resMgr->backgroundValue( "OCCViewer", "background", vm->background(OCCViewer_ViewFrame::MAIN_VIEW) ) );
1474 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1475 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ));
1476 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1477 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1478 vm->enablePreselection( resMgr->booleanValue( "OCCViewer", "enable_preselection", vm->isPreselectionEnabled() ) );
1479 vm->enableSelection( resMgr->booleanValue( "OCCViewer", "enable_selection", vm->isSelectionEnabled() ) );
1481 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1482 new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
1485 #ifndef DISABLE_VTKVIEWER
1486 #ifndef DISABLE_SALOMEOBJECT
1487 if ( vmType == SVTK_Viewer::Type() )
1489 if ( vmType == VTKViewer_Viewer::Type() )
1492 #ifndef DISABLE_SALOMEOBJECT
1493 viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
1494 SVTK_Viewer* vm = dynamic_cast<SVTK_Viewer*>( viewMgr->getViewModel() );
1497 vm->setProjectionMode( resMgr->integerValue( "VTKViewer", "projection_mode", vm->projectionMode() ) );
1498 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1499 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1500 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ) );
1501 vm->setStaticTrihedronVisible( resMgr->booleanValue( "3DViewer", "show_static_trihedron", vm->isStaticTrihedronVisible() ) );
1502 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1503 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1504 vm->setPreSelectionMode(resMgr->integerValue( "VTKViewer", "preselection", vm->preSelectionMode() ) );
1505 vm->enableSelection( resMgr->booleanValue( "VTKViewer", "enable_selection", vm->isSelectionEnabled() ) );
1506 vm->setIncrementalSpeed( resMgr->integerValue( "VTKViewer", "speed_value", vm->incrementalSpeed() ),
1507 resMgr->integerValue( "VTKViewer", "speed_mode", vm->incrementalSpeedMode() ) );
1508 vm->setSpacemouseButtons( resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", vm->spacemouseBtn(1) ),
1509 resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", vm->spacemouseBtn(2) ),
1510 resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", vm->spacemouseBtn(3) ) );
1511 new LightApp_VTKSelector( vm, mySelMgr );
1514 viewMgr = new VTKViewer_ViewManager( activeStudy(), desktop() );
1515 VTKViewer_Viewer* vm = dynamic_cast<VTKViewer_Viewer*>( viewMgr->getViewModel() );
1517 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1525 addViewManager( viewMgr );
1526 SUIT_ViewWindow* viewWin = viewMgr->createViewWindow();
1528 if ( viewWin && desktop() ) {
1529 viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1530 viewWin->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1536 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, QWidget* w )
1538 SUIT_ResourceMgr* resMgr = resourceMgr();
1540 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
1542 new LightApp_WgViewModel( vmType, w ) );
1543 vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
1545 addViewManager( vm );
1546 SUIT_ViewWindow* vw = vm->createViewWindow();
1547 if ( vw && desktop() ) {
1548 vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1549 vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1552 if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
1553 myUserWmTypes << vmType;
1558 SUIT_ViewManager* LightApp_Application::createViewManager( SUIT_ViewModel* theModel )
1560 SUIT_ResourceMgr* resMgr = resourceMgr();
1562 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
1566 QString vmType = vm->getType();
1568 vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
1570 addViewManager( vm );
1571 SUIT_ViewWindow* vw = vm->createViewWindow();
1572 if ( vw && desktop() ) {
1573 vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1574 vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1577 if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
1578 myUserWmTypes << vmType;
1584 SLOT: Removes view manager from application
1586 void LightApp_Application::onCloseView( SUIT_ViewManager* theVM )
1588 removeViewManager( theVM );
1592 Protected SLOT: On study created.
1593 \param theStudy - just created study
1595 void LightApp_Application::onStudyCreated( SUIT_Study* theStudy )
1597 SUIT_DataObject* aRoot = 0;
1598 if ( theStudy && theStudy->root() )
1600 aRoot = theStudy->root();
1601 //aRoot->setName( tr( "DATA_MODELS" ) );
1604 getWindow( WT_ObjectBrowser );
1606 loadDockWindowsState();
1608 if ( objectBrowser() )
1609 objectBrowser()->setRoot( aRoot );
1611 activateModule( defaultModule() );
1613 if ( objectBrowser() )
1614 objectBrowser()->openLevels();
1616 #ifndef DISABLE_PYCONSOLE
1617 if( pythonConsole() )
1618 getPyInterp()->initStudy();
1623 Protected SLOT: On study opened.
1624 \param theStudy - just opened study
1626 void LightApp_Application::onStudyOpened( SUIT_Study* theStudy )
1628 SUIT_DataObject* aRoot = 0;
1629 if ( theStudy && theStudy->root() )
1631 aRoot = theStudy->root();
1635 getWindow( WT_ObjectBrowser );
1637 loadDockWindowsState();
1639 if ( objectBrowser() )
1640 objectBrowser()->setRoot( aRoot );
1642 activateModule( defaultModule() );
1644 if ( objectBrowser() )
1645 objectBrowser()->openLevels();
1647 #ifndef DISABLE_PYCONSOLE
1648 if( pythonConsole() )
1649 getPyInterp()->initStudy();
1655 /*!Protected SLOT. On study saved.*/
1656 void LightApp_Application::onStudySaved( SUIT_Study* s )
1658 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
1660 mru->insert( s->studyName() );
1665 /*!Protected SLOT. On study closed.*/
1666 void LightApp_Application::onStudyClosed( SUIT_Study* s )
1669 disconnect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
1670 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
1673 // stop auto-save timer
1674 myAutoSaveTimer->stop();
1676 // Bug 10396: clear selection
1677 mySelMgr->clearSelected();
1679 // Bug 12944: emit signal only after clear selection
1682 activateModule( "" );
1685 /*!Protected SLOT.On desktop activated.*/
1686 void LightApp_Application::onDesktopActivated()
1688 CAM_Application::onDesktopActivated();
1689 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>(activeModule());
1691 aModule->studyActivated();
1694 void LightApp_Application::studyOpened( SUIT_Study* s )
1696 CAM_Application::studyOpened( s );
1699 updateViewManagers();
1702 void LightApp_Application::studySaved( SUIT_Study* s )
1704 CAM_Application::studyOpened( s );
1705 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1706 if ( aResMgr && activeStudy() ) {
1707 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
1708 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
1712 void LightApp_Application::studyCreated( SUIT_Study* s )
1714 CAM_Application::studyCreated( s );
1717 updateViewManagers();
1720 /*!Gets file filter.
1721 *\retval QString "(*.bin)"
1723 QString LightApp_Application::getFileFilter() const
1731 Shows file dialog and return user selected file name
1733 QString LightApp_Application::getFileName( bool open, const QString& initial, const QString& filters,
1734 const QString& caption, QWidget* parent )
1738 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1739 return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
1742 /*! Gets directory*/
1743 QString LightApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
1747 return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true );
1750 /*! Get open file names*/
1751 QStringList LightApp_Application::getOpenFileNames( const QString& initial, const QString& filters,
1752 const QString& caption, QWidget* parent )
1756 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1757 return SUIT_FileDlg::getOpenFileNames( parent, initial, fls, caption, true );
1760 /*!Private SLOT. Update object browser.*/
1761 void LightApp_Application::onRefresh()
1763 updateObjectBrowser( true );
1766 /*!Private SLOT. Support drag-and-drop operation.*/
1767 void LightApp_Application::onDropped( const QList<SUIT_DataObject*>& objects, SUIT_DataObject* parent, int row, Qt::DropAction action )
1769 LightApp_DataObject* parentObj = dynamic_cast<LightApp_DataObject*>( parent );
1773 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>( parentObj->module() );
1775 aModule->dropObjects( objects, parentObj, row, action );
1778 /*!Private SLOT. On preferences.*/
1779 void LightApp_Application::onPreferences()
1781 showPreferences( activeModule() ? activeModule()->moduleName() : tr( "PREF_CATEGORY_SALOME" ) );
1784 /*!Private SLOT. On preferences.*/
1785 void LightApp_Application::showPreferences( const QString& itemText )
1787 QApplication::setOverrideCursor( Qt::WaitCursor );
1789 LightApp_PreferencesDlg* prefDlg = new LightApp_PreferencesDlg( preferences( true ), desktop());
1791 QApplication::restoreOverrideCursor();
1796 preferences()->activateItem( itemText );
1798 if ( ( prefDlg->exec() == QDialog::Accepted || prefDlg->isSaved() ) && resourceMgr() )
1801 resourceMgr()->setValue( "desktop", "geometry", desktop()->storeGeometry() );
1802 resourceMgr()->save();
1805 shortcutMgr()->updateShortcuts();
1811 /*!Protected SLOT. On preferences changed.*/
1812 void LightApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param )
1814 LightApp_Module* sMod = 0;
1815 CAM_Module* mod = module( modName );
1816 if ( mod && mod->inherits( "LightApp_Module" ) )
1817 sMod = (LightApp_Module*)mod;
1820 sMod->preferencesChanged( section, param );
1822 preferencesChanged( section, param );
1823 // emit signal to allow additional preferences changing processing
1824 emit preferenceChanged( modName, section, param );
1827 /*!Remove all windows from study.*/
1828 void LightApp_Application::beforeCloseDoc( SUIT_Study* s )
1830 saveDockWindowsState();
1832 if ( SUIT_DataBrowser* ob = objectBrowser() )
1835 CAM_Application::beforeCloseDoc( s );
1838 /*!Update actions.*/
1839 void LightApp_Application::updateActions()
1841 updateCommandsStatus();
1847 SUIT_Study* LightApp_Application::createNewStudy()
1849 LightApp_Application::lastStudyId++;
1851 LightApp_Study* aStudy = new LightApp_Study( this );
1853 // Set up processing of major study-related events
1854 connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
1855 connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
1856 connect( aStudy, SIGNAL( saved ( SUIT_Study* ) ), this, SLOT( onStudySaved ( SUIT_Study* ) ) );
1857 connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
1863 Creates window by flag.
1864 \param flag - identificator of window type
1866 QWidget* LightApp_Application::createWindow( const int flag )
1870 SUIT_ResourceMgr* resMgr = resourceMgr();
1872 if ( flag == WT_ObjectBrowser )
1874 SUIT_DataBrowser* ob = new SUIT_DataBrowser( new LightApp_DataObject(), desktop() );
1875 ob->setObjectName( "objectBrowser" );
1876 ob->setSortMenuEnabled( true );
1877 ob->setAutoUpdate( true );
1878 if ( resMgr->hasValue( "ObjectBrowser", "auto_hide_search_tool" ) )
1879 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
1881 //ob->setAutoOpenLevel( 1 ); // commented by ASV as a fix to bug IPAL10107
1882 ob->setWindowTitle( tr( "OBJECT_BROWSER" ) );
1883 connect( ob, SIGNAL( requestUpdate() ), this, SLOT( onRefresh() ) );
1885 QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
1886 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
1887 treeModel->setSearcher( this );
1888 treeModel->registerColumn( 0, EntryCol, LightApp_DataObject::EntryId );
1889 treeModel->setAppropriate( EntryCol, Qtx::Toggled );
1891 // Mantis issue 0020136: Drag&Drop in OB
1892 SUIT_ProxyModel* proxyModel = dynamic_cast<SUIT_ProxyModel*>(treeModel);
1894 connect( proxyModel, SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
1895 this, SLOT( onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
1898 // temporary commented
1900 OB_ListView* ob_list = dynamic_cast<OB_ListView*>( const_cast<QListView*>( ob->listView() ) );
1902 ob_list->setColumnMaxWidth( 0, desktop()->width()/4 );
1905 // Create OBSelector
1906 new LightApp_OBSelector( ob, mySelMgr );
1908 ob->treeView()->header()->setResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
1909 ob->treeView()->header()->moveSection(SUIT_DataObject::NameId,SUIT_DataObject::VisibilityId);
1910 ob->treeView()->setColumnWidth(SUIT_DataObject::VisibilityId, VISIBILITY_COLUMN_WIDTH);
1911 ob->setProperty( "shortcut", QKeySequence( "Alt+Shift+O" ) );
1913 ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1915 #ifndef DISABLE_PYCONSOLE
1916 else if ( flag == WT_PyConsole )
1918 PyConsole_Console* pyCons = new PyConsole_EnhConsole( desktop(), getPyInterp() );
1919 pyCons->setObjectName( "pythonConsole" );
1920 pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
1921 pyCons->setFont(resourceMgr()->fontValue( "PyConsole", "font" ));
1922 pyCons->setIsShowBanner(resourceMgr()->booleanValue( "PyConsole", "show_banner", true ));
1923 pyCons->setProperty( "shortcut", QKeySequence( "Alt+Shift+P" ) );
1926 pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1929 else if ( flag == WT_LogWindow )
1931 LogWindow* logWin = new LogWindow( desktop() );
1932 logWin->setObjectName( "logWindow" );
1933 logWin->setWindowTitle( tr( "LOG_WINDOW" ) );
1934 logWin->setProperty( "shortcut", QKeySequence( "Alt+Shift+L" ) );
1936 logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1942 \return default windows( Object Browser, Python Console )
1943 Adds to map \a aMap.
1945 void LightApp_Application::defaultWindows( QMap<int, int>& aMap ) const
1947 #ifndef DISABLE_PYCONSOLE
1948 aMap.insert( WT_PyConsole, Qt::BottomDockWidgetArea );
1950 if ( activeStudy() ) {
1951 aMap.insert( WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1952 // aMap.insert( WT_LogWindow, Qt::DockBottom );
1956 /*!Default view managers*/
1957 void LightApp_Application::defaultViewManagers( QStringList& ) const
1963 \return preferences.
1964 Create preferences, if \a crt = true.
1966 LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const
1971 LightApp_Application* that = (LightApp_Application*)this;
1973 bool toCreate = !_prefs_ && crt;
1976 _prefs_ = new LightApp_Preferences( resourceMgr() );
1977 that->createPreferences( _prefs_ );
1980 that->myPrefs = _prefs_;
1982 connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
1983 this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ), Qt::UniqueConnection );
1984 connect( myPrefs, SIGNAL( resetToDefaults() ),
1985 this, SIGNAL( preferenceResetToDefaults() ), Qt::UniqueConnection );
1990 SUIT_ResourceMgr* resMgr = resourceMgr();
1992 QList<SUIT_Application*> appList = SUIT_Session::session()->applications();
1993 for ( QList<SUIT_Application*>::iterator appIt = appList.begin(); appIt != appList.end(); ++appIt )
1995 LightApp_Application* app = ::qobject_cast<LightApp_Application*>( *appIt );
1999 QStringList modNameList;
2000 app->modules( modNameList, false );
2002 QMap<QString, QString> iconMap;
2003 app->moduleIconNames( iconMap );
2005 for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it )
2007 if ( !app->isLibExists( *it ) || _prefs_->hasModule( *it ) )
2010 int modId = _prefs_->addPreference( *it );
2011 if ( iconMap.contains( *it ) )
2012 _prefs_->setItemIcon( modId, Qtx::scaleIcon( resMgr->loadPixmap( moduleName( *it ), iconMap[*it], false ), 20 ) );
2016 app->modules( modList );
2017 QListIterator<CAM_Module*> itr( modList );
2018 while ( itr.hasNext() )
2020 LightApp_Module* mod = 0;
2022 CAM_Module* anItem = itr.next();
2023 if ( anItem->inherits( "LightApp_Module" ) )
2024 mod = (LightApp_Module*)anItem;
2026 if ( mod && !_prefs_->hasModule( mod->moduleName() ) )
2028 _prefs_->addPreference( mod->moduleName() );
2029 mod->createPreferences();
2030 that->emptyPreferences( mod->moduleName() );
2034 _prefs_->setItemProperty( "info", tr( "PREFERENCES_NOT_LOADED" ) );
2040 Adds new module to application
2042 void LightApp_Application::moduleAdded( CAM_Module* mod )
2044 CAM_Application::moduleAdded( mod );
2046 LightApp_Module* lightMod = 0;
2047 if ( mod && mod->inherits( "LightApp_Module" ) )
2048 lightMod = (LightApp_Module*)mod;
2050 if ( myPrefs && lightMod && !myPrefs->hasModule( lightMod->moduleName() ))
2052 myPrefs->addPreference( mod->moduleName() );
2053 lightMod->createPreferences();
2054 emptyPreferences( mod->moduleName() );
2058 void LightApp_Application::emptyPreferences( const QString& modName )
2060 QtxPreferenceItem* item = myPrefs->findItem( modName, true );
2061 if ( !item || !item->isEmpty() )
2064 // printf( "---------------------> Modify for empty module.\n" );
2066 QtxPagePrefFrameItem* frm = new QtxPagePrefFrameItem( item->title(), item->parentItem() );
2067 frm->setIcon( item->icon() );
2068 frm->setStretch( false );
2069 item->parentItem()->insertItem( frm, item );
2070 new QtxPagePrefLabelItem( Qt::AlignCenter, tr( "PREFERENCES_NOT_SUPPORTED" ).arg( modName ), frm );
2077 void LightApp_Application::createPreferences( LightApp_Preferences* pref )
2082 QStringList aValuesList;
2083 QList<QVariant> anIndicesList;
2087 // . Top-level "SALOME" preferences group <<start>>
2088 int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
2089 pref->setItemIcon( salomeCat, Qtx::scaleIcon( resourceMgr()->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false ), 20 ) );
2091 // .. "General" preferences tab <<start>>
2092 int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat );
2094 // ... "Language" group <<start>>
2095 int langGroup = pref->addPreference( tr( "PREF_GROUP_LANGUAGE" ), genTab );
2096 pref->setItemProperty( "columns", 2, langGroup );
2097 // .... -> application language
2098 int curLang = pref->addPreference( tr( "PREF_CURRENT_LANGUAGE" ), langGroup,
2099 LightApp_Preferences::Selector, "language", "language" );
2100 QStringList aLangs = SUIT_Session::session()->resourceMgr()->stringValue( "language", "languages", "en" ).split( "," );
2101 QList<QVariant> aIcons;
2102 foreach ( QString aLang, aLangs ) {
2103 aIcons << QPixmap( QString( ":/images/%1" ).arg( aLang ) );
2105 pref->setItemProperty( "strings", aLangs, curLang );
2106 pref->setItemProperty( "icons", aIcons, curLang );
2108 int curLocale = pref->addPreference( tr( "PREF_CURRENT_LOCALE" ), langGroup,
2109 LightApp_Preferences::Bool, "language", "locale" );
2110 // ... "Language" group <<end>>
2112 // ... "Look and feel" group <<start>>
2113 int lookGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), genTab );
2114 pref->setItemProperty( "columns", 2, lookGroup );
2115 // .... -> show splash-screen
2116 pref->addPreference( tr( "PREF_SHOW_SPLASH" ), lookGroup, LightApp_Preferences::Bool, "launch", "splash" );
2117 // .... -> opaque resize
2118 pref->addPreference( tr( "PREF_OPAQUE_RESIZE" ), lookGroup, LightApp_Preferences::Bool, "desktop", "opaque_resize" );
2119 // .... -> drop-down buttons
2120 pref->addPreference( tr( "PREF_DROP_DOWN_BUTTONS" ), lookGroup, LightApp_Preferences::Bool, "viewers", "drop_down_buttons" );
2121 // ... "Look and feel" group <<end>>
2123 // ... "Study properties" group <<start>>
2124 int studyGroup = pref->addPreference( tr( "PREF_GROUP_STUDY" ), genTab );
2125 pref->setItemProperty( "columns", 2, studyGroup );
2126 // .... -> multi-file save
2127 pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "multi_file" );
2128 // .... -> ascii save mode
2129 pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" );
2130 // .... -> store windows geometry
2131 pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" );
2132 pref->addPreference( "", studyGroup, LightApp_Preferences::Space );
2133 pref->addPreference( tr( "PREF_STORE_TOOL_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_tool_positions" );
2134 // .... -> auto-save
2135 int autoSaveInterval = pref->addPreference( tr( "PREF_AUTO_SAVE" ), studyGroup,
2136 LightApp_Preferences::IntSpin, "Study", "auto_save_interval" );
2137 pref->setItemProperty( "min", 0, autoSaveInterval );
2138 pref->setItemProperty( "max", 1440, autoSaveInterval );
2139 pref->setItemProperty( "special", tr( "PREF_AUTO_SAVE_DISABLED" ), autoSaveInterval );
2140 // ... "Study properties" group <<end>>
2142 // ... "Help browser" group <<start>>
2143 int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab, LightApp_Preferences::Auto, "ExternalBrowser", "use_external_browser");
2145 QString platform = "winapplication";
2147 QString platform = "application";
2149 // .... -> browser application
2150 int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, LightApp_Preferences::File, "ExternalBrowser", platform );
2151 pref->setItemProperty( "mode", Qtx::PT_OpenFile, apppref );
2152 // .... -> browser parameters
2153 pref->addPreference( tr( "PREF_PARAM" ), extgroup, LightApp_Preferences::String, "ExternalBrowser", "parameters" );
2154 // ... "Help browser" group <<end>>
2156 // ... "Python console properties" group <<start>>
2157 int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab );
2159 pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, LightApp_Preferences::Font, "PyConsole", "font" );
2160 // .... -> show banner
2161 pref->addPreference( tr( "PREF_SHOW_BANNER" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "show_banner" );
2162 // ... "Python console properties" group <<end>>
2164 // ... "MRU" preferences group <<start>>
2165 int mruGroup = pref->addPreference( tr( "PREF_GROUP_MRU" ), genTab, LightApp_Preferences::Auto, "MRU", "show_mru" );
2166 pref->setItemProperty( "columns", 4, mruGroup );
2167 // number of MRU items
2168 int mruVisCount = pref->addPreference( tr( "PREF_MRU_VISIBLE_COUNT" ), mruGroup, LightApp_Preferences::IntSpin,
2169 "MRU", "visible_count" );
2170 pref->setItemProperty( "min", 0, mruVisCount );
2171 pref->setItemProperty( "max", 100, mruVisCount );
2173 int mruLinkType = pref->addPreference( tr( "PREF_MRU_LINK_TYPE" ), mruGroup, LightApp_Preferences::Selector,
2174 "MRU", "link_type" );
2175 aValuesList.clear();
2176 anIndicesList.clear();
2177 aValuesList << tr("PREF_MRU_LINK_AUTO") << tr("PREF_MRU_LINK_SHORT") << tr("PREF_MRU_LINK_FULL");
2178 anIndicesList << 0 << 1 << 2 ;
2179 pref->setItemProperty( "strings", aValuesList, mruLinkType );
2180 pref->setItemProperty( "indexes", anIndicesList, mruLinkType );
2181 // ... "MRU" preferences group <<end>>
2182 // .. "General" preferences tab <<end>>
2184 // .. "3D viewer" group <<start>>
2185 int Viewer3DGroup = pref->addPreference( tr( "PREF_GROUP_3DVIEWER" ), salomeCat );
2186 // ... -> navigation mode
2187 int vtkStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), Viewer3DGroup,
2188 LightApp_Preferences::Selector, "3DViewer", "navigation_mode" );
2189 aValuesList.clear();
2190 anIndicesList.clear();
2191 aValuesList << tr("PREF_STANDARD_STYLE") << tr("PREF_KEYFREE_STYLE");
2192 anIndicesList << 0 << 1;
2193 pref->setItemProperty( "strings", aValuesList, vtkStyleMode );
2194 pref->setItemProperty( "indexes", anIndicesList, vtkStyleMode );
2195 // ... -> zooming mode
2196 int occZoomingStyleMode = pref->addPreference( tr( "PREF_ZOOMING" ), Viewer3DGroup,
2197 LightApp_Preferences::Selector, "3DViewer", "zooming_mode" );
2198 aValuesList.clear();
2199 anIndicesList.clear();
2200 aValuesList << tr("PREF_ZOOMING_AT_CENTER") << tr("PREF_ZOOMING_AT_CURSOR");
2201 anIndicesList << 0 << 1;
2202 pref->setItemProperty( "strings", aValuesList, occZoomingStyleMode );
2203 pref->setItemProperty( "indexes", anIndicesList, occZoomingStyleMode );
2204 // ... "Trihedron" group <<start>>
2205 int occTriGroup = pref->addPreference( tr( "PREF_TRIHEDRON" ), Viewer3DGroup );
2206 pref->setItemProperty( "columns", 2, occTriGroup );
2207 // .... -> trihedron size
2208 int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occTriGroup,
2209 LightApp_Preferences::DblSpin, "3DViewer", "trihedron_size" );
2210 pref->setItemProperty( "min", 1.0E-06, occTS );
2211 pref->setItemProperty( "max", 1000, occTS );
2212 // .... -> relative size of trihedron
2213 pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "relative_size" );
2214 // .... -> show static trihedron
2215 pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "show_static_trihedron" );
2216 // ... "Trihedron" group <<end>>
2217 // .. "3D viewer" group <<end>>
2221 #ifndef DISABLE_OCCVIEWER
2222 // .. "OCC viewer" group <<start>>
2223 int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), salomeCat );
2225 // ... "Background" group <<start>>
2226 int bgGroup = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup );
2227 // pref->setItemProperty( "columns", 2, bgGroup );
2228 aValuesList.clear();
2229 anIndicesList.clear();
2231 formats = OCCViewer_Viewer::backgroundData( aValuesList, idList, txtList );
2232 foreach( int gid, idList ) anIndicesList << gid;
2233 // .... -> 3D viewer background
2234 bgId = pref->addPreference( tr( "PREF_3DVIEWER_BACKGROUND" ), bgGroup,
2235 LightApp_Preferences::Background, "OCCViewer", "background" );
2236 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2237 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2238 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2239 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2240 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2241 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2242 pref->setItemProperty( "custom_enabled", false, bgId );
2243 pref->setItemProperty( "image_formats", formats, bgId );
2244 // .... -> XZ viewer background
2245 bgId = pref->addPreference( tr( "PREF_XZVIEWER_BACKGROUND" ), bgGroup,
2246 LightApp_Preferences::Background, "OCCViewer", "xz_background" );
2247 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2248 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2249 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2250 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2251 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2252 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2253 pref->setItemProperty( "custom_enabled", false, bgId );
2254 pref->setItemProperty( "image_formats", formats, bgId );
2255 // .... -> YZ viewer background
2256 bgId = pref->addPreference( tr( "PREF_YZVIEWER_BACKGROUND" ), bgGroup,
2257 LightApp_Preferences::Background, "OCCViewer", "yz_background" );
2258 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2259 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2260 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2261 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2262 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2263 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2264 pref->setItemProperty( "custom_enabled", false, bgId );
2265 pref->setItemProperty( "image_formats", formats, bgId );
2266 // .... -> XY viewer background
2267 bgId = pref->addPreference( tr( "PREF_XYVIEWER_BACKGROUND" ), bgGroup,
2268 LightApp_Preferences::Background, "OCCViewer", "xy_background" );
2269 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2270 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2271 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2272 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2273 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2274 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2275 pref->setItemProperty( "custom_enabled", false, bgId );
2276 pref->setItemProperty( "image_formats", formats, bgId );
2277 // ... "Background" group <<end>>
2280 // ... "Selection" group <<start>>
2281 int occSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), occGroup );
2282 pref->setItemProperty( "columns", 2, occSelectionGroup );
2283 // .... -> enable preselection
2284 pref->addPreference( tr( "PREF_ENABLE_PRESELECTION" ), occSelectionGroup,
2285 LightApp_Preferences::Bool, "OCCViewer", "enable_preselection" );
2286 // .... -> enable selection
2287 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), occSelectionGroup,
2288 LightApp_Preferences::Bool, "OCCViewer", "enable_selection" );
2289 // ... "Selection" group <<end>>
2291 // ... -> empty frame (for layout) <<start>>
2292 int occGen = pref->addPreference( "", occGroup, LightApp_Preferences::Frame );
2293 pref->setItemProperty( "margin", 0, occGen );
2294 pref->setItemProperty( "columns", 2, occGen );
2295 // ... -> empty frame (for layout) <<end>>
2296 // .. "OCC viewer" group <<end>>
2299 #ifndef DISABLE_VTKVIEWER
2300 // .. "VTK viewer" group <<start>>
2301 int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), salomeCat ); //viewTab
2303 // ... -> empty frame (for layout) <<start>>
2304 int vtkGen = pref->addPreference( "", vtkGroup, LightApp_Preferences::Frame );
2305 //pref->setItemProperty( "columns", 2, vtkGen );
2306 // .... -> projection mode
2307 int vtkProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), vtkGen,
2308 LightApp_Preferences::Selector, "VTKViewer", "projection_mode" );
2309 aValuesList.clear();
2310 anIndicesList.clear();
2311 aValuesList << tr("PREF_ORTHOGRAPHIC") << tr("PREF_PERSPECTIVE");
2312 anIndicesList << 0 << 1;
2313 pref->setItemProperty( "strings", aValuesList, vtkProjMode );
2314 pref->setItemProperty( "indexes", anIndicesList, vtkProjMode );
2315 // .... -> background
2316 aValuesList.clear();
2317 anIndicesList.clear();
2319 #ifndef DISABLE_SALOMEOBJECT
2320 formats = SVTK_Viewer::backgroundData( aValuesList, idList, txtList );
2322 foreach( int gid, idList ) anIndicesList << gid;
2323 bgId = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGen,
2324 LightApp_Preferences::Background, "VTKViewer", "background" );
2325 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2326 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2327 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2328 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2329 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2330 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2331 pref->setItemProperty( "custom_enabled", false, bgId );
2332 #ifndef DISABLE_SALOMEOBJECT
2333 pref->setItemProperty( "image_formats", formats, bgId );
2335 // .... -> speed increment
2336 int vtkSpeed = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED" ), vtkGen,
2337 LightApp_Preferences::IntSpin, "VTKViewer", "speed_value" );
2338 pref->setItemProperty( "min", 1, vtkSpeed );
2339 pref->setItemProperty( "max", 1000, vtkSpeed );
2340 // .... -> speed mode
2341 int vtkSpeedMode = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED_MODE" ), vtkGen,
2342 LightApp_Preferences::Selector, "VTKViewer", "speed_mode" );
2343 aValuesList.clear();
2344 anIndicesList.clear();
2345 aValuesList << tr("PREF_ARITHMETIC") << tr("PREF_GEOMETRICAL");
2346 anIndicesList << 0 << 1;
2347 pref->setItemProperty( "strings", aValuesList, vtkSpeedMode );
2348 pref->setItemProperty( "indexes", anIndicesList, vtkSpeedMode );
2350 // ... "Selection" group <<start>>
2351 int vtkSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), vtkGroup );
2352 pref->setItemProperty( "columns", 2, vtkSelectionGroup );
2353 // .... -> preselection
2354 int vtkPreselection = pref->addPreference( tr( "PREF_PRESELECTION" ), vtkSelectionGroup,
2355 LightApp_Preferences::Selector, "VTKViewer", "preselection" );
2356 aValuesList.clear();
2357 anIndicesList.clear();
2358 aValuesList << tr("PREF_PRESELECTION_STANDARD") << tr("PREF_PRESELECTION_DYNAMIC") << tr("PREF_PRESELECTION_DISABLED");
2359 anIndicesList << 0 << 1 << 2;
2360 pref->setItemProperty( "strings", aValuesList, vtkPreselection );
2361 pref->setItemProperty( "indexes", anIndicesList, vtkPreselection );
2362 // .... -> enable selection
2363 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), vtkSelectionGroup, LightApp_Preferences::Bool, "VTKViewer", "enable_selection" );
2364 // ... "Selection" group <<end>>
2366 // ... -> empty frame (for layout) <<end>>
2368 // ... space mouse sub-group <<start>>
2369 int vtkSM = pref->addPreference( tr( "PREF_FRAME_SPACEMOUSE" ), vtkGroup, LightApp_Preferences::GroupBox );
2370 //pref->setItemProperty( "columns", 2, vtkSM );
2371 // .... -> decrease speed increment
2372 int spacemousePref1 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_1" ), vtkSM,
2373 LightApp_Preferences::Selector, "VTKViewer",
2374 "spacemouse_func1_btn" );
2375 // .... -> increase speed increment
2376 int spacemousePref2 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_2" ), vtkSM,
2377 LightApp_Preferences::Selector, "VTKViewer",
2378 "spacemouse_func2_btn" );
2379 // .... -> dominant / combined switch
2380 int spacemousePref3 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_3" ), vtkSM,
2381 LightApp_Preferences::Selector, "VTKViewer",
2382 "spacemouse_func5_btn" ); //
2383 aValuesList.clear();
2384 anIndicesList.clear();
2385 aValuesList << tr( "PREF_SPACEMOUSE_BTN_1" ) << tr( "PREF_SPACEMOUSE_BTN_2" ) << tr( "PREF_SPACEMOUSE_BTN_3" );
2386 aValuesList << tr( "PREF_SPACEMOUSE_BTN_4" ) << tr( "PREF_SPACEMOUSE_BTN_5" ) << tr( "PREF_SPACEMOUSE_BTN_6" );
2387 aValuesList << tr( "PREF_SPACEMOUSE_BTN_7" ) << tr( "PREF_SPACEMOUSE_BTN_8" ) << tr( "PREF_SPACEMOUSE_BTN_*" );
2388 aValuesList << tr( "PREF_SPACEMOUSE_BTN_10" ) << tr( "PREF_SPACEMOUSE_BTN_11" );
2389 anIndicesList << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11;
2390 pref->setItemProperty( "strings", aValuesList, spacemousePref1 );
2391 pref->setItemProperty( "indexes", anIndicesList, spacemousePref1 );
2392 pref->setItemProperty( "strings", aValuesList, spacemousePref2 );
2393 pref->setItemProperty( "indexes", anIndicesList, spacemousePref2 );
2394 pref->setItemProperty( "strings", aValuesList, spacemousePref3 );
2395 pref->setItemProperty( "indexes", anIndicesList, spacemousePref3 );
2396 // ... space mouse sub-group <<end>>
2398 // ... avi recording sub-group <<start>>
2399 int vtkRec = pref->addPreference( tr( "PREF_FRAME_RECORDING" ), vtkGroup, LightApp_Preferences::GroupBox );
2400 pref->setItemProperty( "columns", 2, vtkRec );
2401 // .... -> recording mode
2402 int modePref = pref->addPreference( tr( "PREF_RECORDING_MODE" ), vtkRec,
2403 LightApp_Preferences::Selector, "VTKViewer", "recorder_mode" );
2404 aValuesList.clear();
2405 anIndicesList.clear();
2406 aValuesList << tr( "PREF_SKIPPED_FRAMES" ) << tr( "PREF_ALL_DISLPAYED_FRAMES" );
2407 anIndicesList << 0 << 1;
2408 pref->setItemProperty( "strings", aValuesList, modePref );
2409 pref->setItemProperty( "indexes", anIndicesList, modePref );
2411 int fpsPref = pref->addPreference( tr( "PREF_FPS" ), vtkRec,
2412 LightApp_Preferences::DblSpin, "VTKViewer", "recorder_fps" );
2413 pref->setItemProperty( "min", 0.1, fpsPref );
2414 pref->setItemProperty( "max", 100, fpsPref );
2416 int qualityPref = pref->addPreference( tr( "PREF_QUALITY" ), vtkRec,
2417 LightApp_Preferences::IntSpin, "VTKViewer", "recorder_quality" );
2418 pref->setItemProperty( "min", 1, qualityPref );
2419 pref->setItemProperty( "max", 100, qualityPref );
2420 // .... -> progressive mode
2421 pref->addPreference( tr( "PREF_PROGRESSIVE" ), vtkRec,
2422 LightApp_Preferences::Bool, "VTKViewer", "recorder_progressive" );
2423 // ... avi recording sub-group <<end>>
2425 // ... group names sub-group <<start>>
2426 int vtkGN = pref->addPreference( tr( "PREF_FRAME_GROUP_NAMES" ), vtkGroup,
2427 LightApp_Preferences::GroupBox, "VTKViewer", "show_group_names" );
2428 pref->setItemProperty( "columns", 2, vtkGN );
2429 // .... -> text color
2430 pref->addPreference( tr( "PREF_GROUP_NAMES_TEXT_COLOR" ), vtkGN,
2431 LightApp_Preferences::Color, "VTKViewer", "group_names_text_color" );
2432 // .... -> transparency
2433 int transPref = pref->addPreference( tr( "PREF_GROUP_NAMES_TRANSPARENCY" ), vtkGN,
2434 LightApp_Preferences::DblSpin, "VTKViewer", "group_names_transparency" );
2435 pref->setItemProperty( "min", 0.0, transPref );
2436 pref->setItemProperty( "max", 1.0, transPref );
2437 pref->setItemProperty( "step", 0.1, transPref );
2438 // ... -> group names sub-group <<end>>
2439 // .. "VTK viewer" group <<end>>
2442 // .. "Plot2d viewer" group <<start>>
2443 int plot2dGroup = pref->addPreference( tr( "PREF_GROUP_PLOT2DVIEWER" ), salomeCat ); //viewTab
2444 //pref->setItemProperty( "columns", 2, plot2dGroup );
2446 // ... -> background
2447 pref->addPreference( tr( "PREF_VIEWER_BACKGROUND_COLOR" ), plot2dGroup,
2448 LightApp_Preferences::Color, "Plot2d", "Background" );
2449 // ... -> selection color
2450 pref->addPreference( tr( "PREF_VIEWER_SELECTION" ), plot2dGroup,
2451 LightApp_Preferences::Color, "Plot2d", "SelectionColor" );
2453 // ... "Viewer" group <<start>>
2454 int plot2dViewerGroup = pref->addPreference( tr( "PREF_GROUP_VIEWER" ), plot2dGroup );
2456 // .... -> curve type
2457 int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dViewerGroup,
2458 LightApp_Preferences::Selector, "Plot2d", "CurveType" );
2459 aValuesList.clear();
2460 anIndicesList.clear();
2461 aValuesList << tr("PREF_POINTS") << tr("PREF_LINES") << tr("PREF_SPLINE");
2462 anIndicesList << 0 << 1 << 2 ;
2463 pref->setItemProperty( "strings", aValuesList, curveType );
2464 pref->setItemProperty( "indexes", anIndicesList, curveType );
2465 // .... -> marker size
2466 int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dViewerGroup,
2467 LightApp_Preferences::IntSpin, "Plot2d", "MarkerSize" );
2468 pref->setItemProperty( "min", 0, markerSize );
2469 pref->setItemProperty( "max", 100, markerSize );
2470 // .... -> horizontal scaling mode
2471 int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dViewerGroup,
2472 LightApp_Preferences::Selector, "Plot2d", "HorScaleMode" );
2473 aValuesList.clear();
2474 anIndicesList.clear();
2475 aValuesList << tr("PREF_LINEAR") << tr("PREF_LOGARITHMIC");
2476 anIndicesList << 0 << 1 ;
2477 pref->setItemProperty( "strings", aValuesList, horScale );
2478 pref->setItemProperty( "indexes", anIndicesList, horScale );
2479 // .... -> vertical scaling mode
2480 int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dViewerGroup,
2481 LightApp_Preferences::Selector, "Plot2d", "VerScaleMode" );
2482 pref->setItemProperty( "strings", aValuesList, verScale );
2483 pref->setItemProperty( "indexes", anIndicesList, verScale );
2485 // .... -> errors/deviation colot
2486 pref->addPreference( tr( "PREF_DEVIATION_COLOR" ), plot2dViewerGroup,
2487 LightApp_Preferences::Color, "Plot2d", "DeviationMarkerColor" );
2488 // .... -> deviation markers line size
2489 int deviationMarkerLw = pref->addPreference( tr( "PREF_DEVIATION_MARKER_LW" ), plot2dViewerGroup,
2490 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerLineWidth" );
2491 pref->setItemProperty( "min", 1, deviationMarkerLw );
2492 pref->setItemProperty( "max", 5, deviationMarkerLw );
2493 // .... -> deviation markers tick mark size
2494 int deviationMarkerTs = pref->addPreference( tr( "PREF_DEVIATION_MARKER_TS" ), plot2dViewerGroup,
2495 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerTickSize" );
2496 pref->setItemProperty( "min", 1, deviationMarkerTs );
2497 pref->setItemProperty( "max", 5, deviationMarkerTs );
2498 // .... "Viewer" group <<end>>
2500 // ... "Legend" group <<start>>
2501 int plot2dLegendGroup = pref->addPreference( tr( "PREF_GROUP_LEGEND" ), plot2dGroup );
2503 // .... -> show legend
2504 pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dLegendGroup,
2505 LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
2506 // .... -> legend position
2507 int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dLegendGroup,
2508 LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
2509 aValuesList.clear();
2510 anIndicesList.clear();
2511 aValuesList << tr("PREF_LEFT") << tr("PREF_RIGHT") << tr("PREF_TOP") << tr("PREF_BOTTOM");
2512 anIndicesList << 0 << 1 << 2 << 3 ;
2513 pref->setItemProperty( "strings", aValuesList, legendPosition );
2514 pref->setItemProperty( "indexes", anIndicesList, legendPosition );
2515 // .... -> Symbol type
2516 int legendSymbolType = pref->addPreference( tr( "PREF_LEGEND_SYMBOL_TYPE" ), plot2dLegendGroup,
2517 LightApp_Preferences::Selector, "Plot2d", "LegendSymbolType" );
2518 aValuesList.clear();
2519 anIndicesList.clear();
2520 aValuesList << tr("PREF_MARKER_ON_LINE") << tr("PREF_MARKER_ABOVE_LINE");
2521 anIndicesList << 0 << 1 ;
2522 pref->setItemProperty( "strings", aValuesList, legendSymbolType );
2523 pref->setItemProperty( "indexes", anIndicesList, legendSymbolType );
2524 // .... -> legend font
2525 pref->addPreference( tr( "PREF_LEGEND_FONT" ), plot2dLegendGroup, LightApp_Preferences::Font, "Plot2d", "LegendFont" );
2526 // ... -> font color
2527 pref->addPreference( tr( "PREF_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "LegendFontColor" );
2528 // ... -> selection font color
2529 pref->addPreference( tr( "PREF_SELECTED_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "SelectedLegendFontColor" );
2530 // ... "Legend" group <<end>>
2532 // .. "Plot2d viewer" group <<end>>
2534 // .. "Directories" preferences tab <<start>>
2535 int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat );
2536 // ... --> quick directories list
2537 int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab );
2538 pref->addPreference( tr( "" ), dirGroup,
2539 LightApp_Preferences::DirList, "FileDlg", "QuickDirList" );
2540 // .. "Directories" preferences tab <<end>>
2542 // .. "Object browser" preferences tab <<start>>
2543 int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
2545 // ... "Search tool" group <<start>>
2546 int stGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SEARCH_TOOL" ), obTab );
2547 // .... --> auto-hide
2548 pref->addPreference( tr( "PREF_AUTO_HIDE_SEARCH_TOOL" ), stGroup, LightApp_Preferences::Bool,
2549 "ObjectBrowser", "auto_hide_search_tool" );
2550 // ... "Search tool" group <<end>>
2552 // ... "Object browser settings" group <<start>>
2553 int objSetGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), obTab );
2554 pref->setItemProperty( "columns", 2, objSetGroup );
2555 // .... -> auto size first column
2556 pref->addPreference( tr( "PREF_AUTO_SIZE_FIRST" ), objSetGroup, LightApp_Preferences::Bool,
2557 "ObjectBrowser", "auto_size_first" );
2558 // .... -> auto size other columns
2559 pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool,
2560 "ObjectBrowser", "auto_size" );
2561 // .... -> resize columns on expand item
2562 pref->addPreference( tr( "PREF_RESIZE_ON_EXPAND_ITEM" ), objSetGroup, LightApp_Preferences::Bool,
2563 "ObjectBrowser", "resize_on_expand_item" );
2564 // .... -> browse to published object
2565 int browsePublished = pref->addPreference( tr( "PREF_BROWSE_TO_THE_PUBLISHED_OBJECT" ), objSetGroup, LightApp_Preferences::Selector,
2566 "ObjectBrowser", "browse_published_object" );
2567 aValuesList.clear();
2568 anIndicesList.clear();
2569 aValuesList << tr( "PREF_BROWSE_NEVER" ) << tr( "PREF_BROWSE_AFTER_APPLY_AND_CLOSE_ONLY" ) << tr( "PREF_BROWSE_ALWAYS" );
2570 anIndicesList << BP_Never << BP_ApplyAndClose << BP_Always;
2571 pref->setItemProperty( "strings", aValuesList, browsePublished );
2572 pref->setItemProperty( "indexes", anIndicesList, browsePublished );
2573 // ... "Object browser settings" group <<end>>
2574 // .. "Object browser" preferences tab <<end>>
2576 // .. "Shortcuts" preferences tab <<start>>
2577 int shortcutTab = pref->addPreference( tr( "PREF_TAB_SHORTCUTS" ), salomeCat );
2578 // ... "Shortcuts settings" group <<start>>
2579 int shortcutGroup = pref->addPreference( tr( "PREF_GROUP_SHORTCUTS" ), shortcutTab );
2580 pref->addPreference( tr( "" ), shortcutGroup,
2581 LightApp_Preferences::ShortcutTree, "shortcuts" );
2582 // ... "Shortcuts settings" group <<end>>
2583 // .. "Shortcuts" preferences tab <<end>>
2584 // . Top-level "SALOME" preferences group <<end>>
2590 Changes appearance of application according to changed preferences
2591 \param sec - section
2592 \param param - name of changed parameter
2594 void LightApp_Application::preferencesChanged( const QString& sec, const QString& param )
2596 SUIT_ResourceMgr* resMgr = resourceMgr();
2600 if ( sec == "viewers" && param == "drop_down_buttons" )
2602 ViewManagerList vmlist = viewManagers();
2603 foreach( SUIT_ViewManager* vm, vmlist )
2605 QVector<SUIT_ViewWindow*> vwlist = vm->getViews();
2606 foreach( SUIT_ViewWindow* vw, vwlist )
2607 if ( vw ) vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
2611 if ( sec == QString( "3DViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )))
2613 double sz = resMgr->doubleValue( sec, "trihedron_size", -1 );
2614 bool relative = resMgr->booleanValue( sec, "relative_size", true );
2615 QList<SUIT_ViewManager*> lst;
2616 #ifndef DISABLE_OCCVIEWER
2617 viewManagers( OCCViewer_Viewer::Type(), lst );
2618 QListIterator<SUIT_ViewManager*> itOCC( lst );
2619 while ( itOCC.hasNext() && sz >= 0 )
2621 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2622 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2625 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2626 occVM->setTrihedronSize( sz, relative );
2627 occVM->getAISContext()->UpdateCurrentViewer();
2630 #ifndef DISABLE_VTKVIEWER
2631 #ifndef DISABLE_SALOMEOBJECT
2632 viewManagers( SVTK_Viewer::Type(), lst );
2633 QListIterator<SUIT_ViewManager*> itVTK( lst );
2634 while ( itVTK.hasNext() && sz >= 0 )
2636 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2637 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2640 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2643 vtkVM->setTrihedronSize( sz, relative );
2651 if ( sec == QString( "3DViewer" ) && param == QString( "show_static_trihedron" ) )
2653 bool isVisible = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
2654 QList<SUIT_ViewManager*> lst;
2655 #ifndef DISABLE_OCCVIEWER
2656 viewManagers( OCCViewer_Viewer::Type(), lst );
2657 QListIterator<SUIT_ViewManager*> itOCC( lst );
2658 while ( itOCC.hasNext() )
2660 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2661 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2664 OCCViewer_Viewer* occVM = dynamic_cast<OCCViewer_Viewer*>( vm );
2667 occVM->setStaticTrihedronDisplayed( isVisible );
2671 #ifndef DISABLE_VTKVIEWER
2672 #ifndef DISABLE_SALOMEOBJECT
2673 viewManagers( SVTK_Viewer::Type(), lst );
2674 QListIterator<SUIT_ViewManager*> itVTK( lst );
2675 while ( itVTK.hasNext() )
2677 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2678 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2681 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2684 vtkVM->setStaticTrihedronVisible( isVisible );
2692 if ( sec == QString( "3DViewer" ) && param == QString( "navigation_mode" ) )
2694 int mode = resMgr->integerValue( "3DViewer", "navigation_mode", 0 );
2695 QList<SUIT_ViewManager*> lst;
2696 #ifndef DISABLE_OCCVIEWER
2697 viewManagers( OCCViewer_Viewer::Type(), lst );
2698 QListIterator<SUIT_ViewManager*> itOCC( lst );
2699 while ( itOCC.hasNext() )
2701 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2702 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2705 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2706 occVM->setInteractionStyle( mode );
2709 #ifndef DISABLE_VTKVIEWER
2710 #ifndef DISABLE_SALOMEOBJECT
2711 viewManagers( SVTK_Viewer::Type(), lst );
2712 QListIterator<SUIT_ViewManager*> itVTK( lst );
2713 while ( itVTK.hasNext() )
2715 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2716 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2719 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2720 if( vtkVM ) vtkVM->setInteractionStyle( mode );
2726 #ifndef DISABLE_OCCVIEWER
2727 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_preselection" ) )
2729 bool isToEnablePreselection = resMgr->booleanValue( "OCCViewer", "enable_preselection", true );
2730 QList<SUIT_ViewManager*> lst;
2731 viewManagers( OCCViewer_Viewer::Type(), lst );
2732 QListIterator<SUIT_ViewManager*> it( lst );
2733 while ( it.hasNext() )
2735 SUIT_ViewModel* vm = it.next()->getViewModel();
2736 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2739 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2740 occVM->enablePreselection( isToEnablePreselection );
2745 #ifndef DISABLE_OCCVIEWER
2746 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_selection" ) )
2748 bool isToEnableSelection = resMgr->booleanValue( "OCCViewer", "enable_selection", true );
2749 QList<SUIT_ViewManager*> lst;
2750 viewManagers( OCCViewer_Viewer::Type(), lst );
2751 QListIterator<SUIT_ViewManager*> it( lst );
2752 while ( it.hasNext() )
2754 SUIT_ViewModel* vm = it.next()->getViewModel();
2755 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2758 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2759 occVM->enableSelection( isToEnableSelection );
2764 if ( sec == QString( "3DViewer" ) && param == QString( "zooming_mode" ) )
2766 int mode = resMgr->integerValue( "3DViewer", "zooming_mode", 0 );
2767 QList<SUIT_ViewManager*> lst;
2768 #ifndef DISABLE_OCCVIEWER
2769 viewManagers( OCCViewer_Viewer::Type(), lst );
2770 QListIterator<SUIT_ViewManager*> itOCC( lst );
2771 while ( itOCC.hasNext() )
2773 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2774 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2777 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2778 occVM->setZoomingStyle( mode );
2781 #ifndef DISABLE_VTKVIEWER
2782 #ifndef DISABLE_SALOMEOBJECT
2783 viewManagers( SVTK_Viewer::Type(), lst );
2784 QListIterator<SUIT_ViewManager*> itVTK( lst );
2785 while ( itVTK.hasNext() )
2787 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2788 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2791 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2792 if( vtkVM ) vtkVM->setZoomingStyle( mode );
2798 #ifndef DISABLE_VTKVIEWER
2799 if ( sec == QString( "VTKViewer" ) && (param == QString( "speed_value" ) || param == QString( "speed_mode" )) )
2801 int speed = resMgr->integerValue( "VTKViewer", "speed_value", 10 );
2802 int mode = resMgr->integerValue( "VTKViewer", "speed_mode", 0 );
2803 QList<SUIT_ViewManager*> lst;
2804 #ifndef DISABLE_SALOMEOBJECT
2805 viewManagers( SVTK_Viewer::Type(), lst );
2806 QListIterator<SUIT_ViewManager*> it( lst );
2807 while ( it.hasNext() )
2809 SUIT_ViewModel* vm = it.next()->getViewModel();
2810 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2813 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2814 if( vtkVM ) vtkVM->setIncrementalSpeed( speed, mode );
2820 #ifndef DISABLE_VTKVIEWER
2821 if ( sec == QString( "VTKViewer" ) && param == QString( "projection_mode" ) )
2823 int mode = resMgr->integerValue( "VTKViewer", "projection_mode", 0 );
2824 QList<SUIT_ViewManager*> lst;
2825 #ifndef DISABLE_SALOMEOBJECT
2826 viewManagers( SVTK_Viewer::Type(), lst );
2827 QListIterator<SUIT_ViewManager*> it( lst );
2828 while ( it.hasNext() )
2830 SUIT_ViewModel* vm = it.next()->getViewModel();
2831 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2834 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2835 if( vtkVM ) vtkVM->setProjectionMode( mode );
2841 #ifndef DISABLE_VTKVIEWER
2842 if ( sec == QString( "VTKViewer" ) && param == QString( "preselection" ) )
2844 int mode = resMgr->integerValue( "VTKViewer", "preselection", 0 );
2845 QList<SUIT_ViewManager*> lst;
2846 #ifndef DISABLE_SALOMEOBJECT
2847 viewManagers( SVTK_Viewer::Type(), lst );
2848 QListIterator<SUIT_ViewManager*> it( lst );
2849 while ( it.hasNext() )
2851 SUIT_ViewModel* vm = it.next()->getViewModel();
2852 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2855 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2856 if( vtkVM ) vtkVM->setPreSelectionMode( mode );
2862 #ifndef DISABLE_VTKVIEWER
2863 if ( sec == QString( "VTKViewer" ) && param == QString( "enable_selection" ) )
2865 bool isToEnableSelection = resMgr->booleanValue( "VTKViewer", "enable_selection", true );
2866 QList<SUIT_ViewManager*> lst;
2867 #ifndef DISABLE_SALOMEOBJECT
2868 viewManagers( SVTK_Viewer::Type(), lst );
2869 QListIterator<SUIT_ViewManager*> it( lst );
2870 while ( it.hasNext() )
2872 SUIT_ViewModel* vm = it.next()->getViewModel();
2873 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2876 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2877 if( vtkVM ) vtkVM->enableSelection( isToEnableSelection );
2883 #ifndef DISABLE_VTKVIEWER
2884 if ( sec == QString( "VTKViewer" ) && (param == QString( "spacemouse_func1_btn" ) ||
2885 param == QString( "spacemouse_func2_btn" ) ||
2886 param == QString( "spacemouse_func5_btn" ) ) )
2888 int btn1 = resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", 1 );
2889 int btn2 = resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", 2 );
2890 int btn3 = resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", 9 );
2891 QList<SUIT_ViewManager*> lst;
2892 #ifndef DISABLE_SALOMEOBJECT
2893 viewManagers( SVTK_Viewer::Type(), lst );
2894 QListIterator<SUIT_ViewManager*> it( lst );
2895 while ( it.hasNext() )
2897 SUIT_ViewModel* vm = it.next()->getViewModel();
2898 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2901 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2902 if( vtkVM ) vtkVM->setSpacemouseButtons( btn1, btn2, btn3 );
2907 if( sec=="ObjectBrowser" )
2909 SUIT_DataBrowser* ob = objectBrowser();
2913 if ( param=="auto_size_first" )
2915 bool autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
2916 ob->setAutoSizeFirstColumn( autoSizeFirst );
2917 if ( autoSizeFirst )
2918 ob->adjustFirstColumnWidth();
2920 else if ( param=="auto_size" ) {
2921 bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
2922 ob->setAutoSizeColumns(autoSize);
2924 ob->adjustColumnsWidth();
2926 else if ( param=="resize_on_expand_item" ) {
2927 bool resizeOnExpandItem = resMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
2928 ob->setResizeOnExpandItem(resizeOnExpandItem);
2930 else if ( param == "auto_hide_search_tool" ) {
2931 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
2937 if( param=="auto_save_interval" ) {
2938 myAutoSaveTimer->stop();
2939 int autoSaveInterval = resMgr->integerValue( "Study", "auto_save_interval", 0 );
2940 if ( activeStudy() && autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
2944 #ifndef DISABLE_PYCONSOLE
2945 if( sec=="PyConsole" && pythonConsole() )
2947 if ( param=="font" ) {
2948 pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) );
2950 else if ( param=="show_banner" ) {
2951 pythonConsole()->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
2958 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
2960 if ( param == "visible_count" )
2961 mru->setVisibleCount( resMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
2962 else if ( param == "max_count" )
2963 mru->setHistoryCount( resMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
2964 else if ( param == "insert_mode" )
2965 mru->setInsertMode( resMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
2966 else if ( param == "link_type" )
2967 mru->setLinkType( resMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
2968 else if ( param == "show_clear" )
2969 mru->setClearPossible( resMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
2970 else if ( param == "show_mru" )
2971 mru->setVisible( resMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
2974 if ( sec == "language" && param == "language" )
2976 SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LANG_CHANGED" ) );
2978 if ( sec == "language" && param == "locale")
2980 SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LOCALE_CHANGED" ) );
2982 if ( sec == "desktop" && param == "opaque_resize" ) {
2983 bool opaqueResize = resMgr->booleanValue( "desktop", "opaque_resize", false );
2984 QMainWindow::DockOptions dopts = desktop()->dockOptions();
2985 if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
2986 else dopts &= ~QMainWindow::AnimatedDocks;
2987 desktop()->setDockOptions( dopts );
2988 desktop()->setOpaqueResize( opaqueResize );
2989 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
2990 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
2993 #ifndef DISABLE_PLOT2DVIEWER
2994 QList<SUIT_ViewManager*> lst;
2995 viewManagers( Plot2d_Viewer::Type(), lst );
2996 QListIterator<SUIT_ViewManager*> itPlot2d( lst );
2997 while ( itPlot2d.hasNext() ) {
2998 SUIT_ViewManager* viewMgr = itPlot2d.next();
2999 SUIT_ViewModel* vm = viewMgr->getViewModel();
3000 if ( !vm || !vm->inherits( "Plot2d_Viewer" ) )
3003 Plot2d_Viewer* Plot2dVM = dynamic_cast<Plot2d_Viewer*>( vm );
3005 viewMgr->setViewModel( vm );
3006 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
3008 Plot2d_ViewFrame* frame = wnd->getViewFrame();
3009 frame->SetPreference();
3018 void LightApp_Application::loadPreferences()
3020 CAM_Application::loadPreferences();
3022 SUIT_ResourceMgr* aResMgr = resourceMgr();
3027 static bool mru_load = true;
3030 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3032 mru->setVisible( aResMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
3033 mru->setVisibleCount( aResMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
3034 mru->setHistoryCount( aResMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
3035 mru->setInsertMode( aResMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
3036 mru->setLinkType( aResMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
3037 mru->setClearPossible( aResMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
3038 mru->loadLinks( aResMgr, "MRU" );
3044 QStringList mods = aResMgr->parameters( "windows_visibility" );
3045 for ( QStringList::const_iterator itr = mods.begin(); itr != mods.end(); ++itr )
3048 if ( aResMgr->value( "windows_visibility", *itr, arr ) )
3049 myWinVis.insert( *itr, arr );
3053 desktop()->retrieveGeometry( aResMgr->stringValue( "desktop", "geometry" ) );
3054 bool opaqueResize = aResMgr->booleanValue( "desktop", "opaque_resize", false );
3055 QMainWindow::DockOptions dopts = desktop()->dockOptions();
3056 if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
3057 else dopts &= ~QMainWindow::AnimatedDocks;
3058 desktop()->setDockOptions( dopts );
3059 desktop()->setOpaqueResize( opaqueResize );
3060 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
3061 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
3068 void LightApp_Application::savePreferences()
3070 CAM_Application::savePreferences();
3072 saveDockWindowsState();
3074 SUIT_ResourceMgr* aResMgr = resourceMgr();
3079 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3081 mru->saveLinks( aResMgr, "MRU" );
3083 for ( WinVis::const_iterator itr = myWinVis.begin(); itr != myWinVis.end(); ++itr )
3084 aResMgr->setValue( "windows_visibility", itr.key(), itr.value() );
3087 aResMgr->setValue( "desktop", "geometry", desktop()->storeGeometry() );
3089 #if GUI_DEVELOPMENT > 0
3090 aResMgr->setValue( "salome", "version", QString(GUI_VERSION_STR)+"dev" );
3092 aResMgr->setValue( "salome", "version", QString(GUI_VERSION_STR) );
3099 Updates desktop title
3101 void LightApp_Application::updateDesktopTitle()
3103 QString aTitle = applicationName();
3104 QString aVer = applicationVersion();
3105 if ( !aVer.isEmpty() )
3106 aTitle += QString( " " ) + aVer;
3108 if ( activeStudy() ) {
3109 QString sName = SUIT_Tools::file( activeStudy()->studyName().trimmed(), false );
3110 aTitle += QString( " - [%1]" ).arg( sName );
3113 desktop()->setWindowTitle( aTitle );
3117 \brief Get map of the operations which can be performed
3118 on the module activation.
3120 The method should return the map of the kind \c {<id>:<name>}
3121 where \c <id> is an integer identifier of the operation and
3122 \c <name> is a title for the button to be added to the
3123 dialog box. After user selects the required operation by the
3124 clicking the corresponding button in the dialog box, its identifier
3125 is passed to the moduleActionSelected() method to process
3128 \return map of the operations
3129 \sa moduleActionSelected()
3131 QMap<int, QString> LightApp_Application::activateModuleActions() const
3133 QMap<int, QString> opmap;
3134 opmap.insert( NewStudyId, tr( "ACTIVATE_MODULE_OP_NEW" ) );
3135 opmap.insert( OpenStudyId, tr( "ACTIVATE_MODULE_OP_OPEN" ) );
3140 \brief Called when the used selectes required operation chosen
3141 from "Activate module" dialog box.
3143 Performs the required operation according to the user choice.
3145 \param id operation identifier
3146 \sa activateModuleActions()
3148 void LightApp_Application::moduleActionSelected( const int id )
3163 Updates windows after close document
3165 void LightApp_Application::afterCloseDoc()
3169 CAM_Application::afterCloseDoc();
3173 Updates actions of active module
3175 void LightApp_Application::updateModuleActions()
3178 if ( activeModule() ) {
3179 modName = activeModule()->moduleName();
3180 if ( !isModuleAccessible( modName ) ) {
3181 QList<SUIT_Application*> apps = SUIT_Session::session()->applications();
3182 foreach( SUIT_Application* app, apps ) {
3183 LightApp_Application* lapp = dynamic_cast<LightApp_Application*>( app );
3184 if ( lapp && lapp != this )
3185 lapp->removeModuleAction( modName );
3190 LightApp_ModuleAction* moduleAction =
3191 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
3193 moduleAction->setActiveModule( modName );
3196 void LightApp_Application::removeModuleAction( const QString& modName )
3198 LightApp_ModuleAction* moduleAction =
3199 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
3201 moduleAction->removeModule( modName );
3205 Gets current windows.
3206 \param winMap - output current windows map.
3208 void LightApp_Application::currentWindows( QMap<int, int>& winMap ) const
3211 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
3212 ((LightApp_Module*)activeModule())->windows( winMap );
3214 defaultWindows( winMap );
3218 Gets current view managers.
3219 \param lst - output current view managers list.
3221 void LightApp_Application::currentViewManagers( QStringList& lst ) const
3224 if ( !activeStudy() )
3227 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
3228 ((LightApp_Module*)activeModule())->viewManagers( lst );
3230 defaultViewManagers( lst );
3236 void LightApp_Application::updateWindows()
3238 QMap<int, int> winMap;
3239 currentWindows( winMap );
3241 for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
3243 if ( !dockWindow( it.key() ) )
3244 getWindow( it.key() );
3247 for ( WinMap::ConstIterator it = myWin.begin(); it != myWin.end(); ++it )
3249 QWidget* wid = it.value();
3250 if ( winMap.contains( it.key() ) )
3251 wid->setVisible( true );
3256 loadDockWindowsState();
3260 Updates view managers
3262 void LightApp_Application::updateViewManagers()
3265 currentViewManagers( lst );
3267 for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
3268 getViewManager( *it, true );
3272 Loads windows geometry
3274 void LightApp_Application::loadDockWindowsState()
3278 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
3279 bool storeWin = aResMgr->booleanValue( "Study", "store_positions", true );
3280 bool storeTb = aResMgr->booleanValue( "Study", "store_tool_positions", true );
3283 if ( activeModule() )
3284 modName = activeModule()->name();
3285 else if ( activeStudy() )
3286 modName = "nomodule";
3288 QtxResourceMgr::WorkingMode prevMode = aResMgr->setWorkingMode( QtxResourceMgr::IgnoreUserValues );
3289 QByteArray aDefaultState;
3290 aResMgr->value( "windows_geometry", modName, aDefaultState );
3291 QByteArray aDefaultVisibility;
3292 aResMgr->value( "windows_visibility", modName, aDefaultVisibility );
3293 bool hasDefaultVisibility = !aDefaultVisibility.isEmpty();
3294 aResMgr->setWorkingMode( prevMode );
3296 if( !storeWin && !storeTb && aDefaultState.isEmpty() && !hasDefaultVisibility)
3299 if ( aResMgr->hasValue("windows_geometry" ,modName ) ) {
3300 long version = Qtx::versionToId( aResMgr->stringValue( "windows_geometry_version", modName, "" ) );
3302 if ( version > Qtx::versionToId( "7.4.1" ) )
3303 aResMgr->value( "windows_geometry", modName , arr );
3305 arr = aDefaultState;
3306 QByteArray aTargetArray = processState(arr, storeWin, storeTb, true, aDefaultState);
3307 desktop()->restoreState( aTargetArray );
3310 QStringList mainToolbarsNames;
3311 mainToolbarsNames << "SalomeStandard" << "SalomeModules";
3312 QList<QToolBar*> mainToolbars = findToolBars( mainToolbarsNames );
3313 foreach( QToolBar* tb, mainToolbars ) tb->setVisible( true );
3315 if ( !myWinVis.contains( modName ) && aDefaultVisibility.isEmpty())
3318 QMap<QString, bool> *tbMap = 0;
3319 QMap<QString, bool> *dwMap = 0;
3321 QMap<QString, bool> userTbMap, userDwMap;
3322 dockWindowsState( myWinVis[modName], userTbMap, userDwMap );
3324 QMap<QString, bool> defaultTbMap, defaultDwMap;
3325 if(hasDefaultVisibility) {
3326 dockWindowsState( aDefaultVisibility, defaultTbMap, defaultDwMap);
3332 if(hasDefaultVisibility){
3333 tbMap = &defaultTbMap;
3340 if(hasDefaultVisibility){
3341 dwMap = &defaultDwMap;
3346 QList<QToolBar*> tbList = findToolBars();
3347 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit )
3349 QToolBar* tb = *tit;
3350 if ( tbMap->contains( tb->objectName() ) ) {
3351 tb->setVisible( (*tbMap)[tb->objectName()] );
3357 QList<QDockWidget*> dwList = qFindChildren<QDockWidget*>( desktop() );
3358 for ( QList<QDockWidget*>::iterator dit = dwList.begin(); dit != dwList.end(); ++dit )
3360 QDockWidget* dw = *dit;
3362 QObject* po = Qtx::findParent( dw, "QMainWindow" );
3363 if ( po != desktop() )
3366 if ( dwMap->contains( dw->objectName() ) )
3367 dw->setVisible( (*dwMap)[dw->objectName()] );
3375 Saves windows geometry
3377 void LightApp_Application::saveDockWindowsState()
3382 bool storeWin = resourceMgr()->booleanValue( "Study", "store_positions", true );
3383 bool storeTb = resourceMgr()->booleanValue( "Study", "store_tool_positions", true );
3385 if( !storeWin && !storeTb )
3389 if ( activeModule() )
3390 modName = activeModule()->name();
3391 else if ( activeStudy() )
3392 modName = "nomodule";
3394 QString versionId = GUI_VERSION_STR;
3395 #if GUI_DEVELOPMENT > 0
3399 QByteArray arr = desktop()->saveState();
3400 resourceMgr()->setValue( "windows_geometry", modName, processState(arr, storeWin, storeTb, false) );
3401 resourceMgr()->setValue( "windows_geometry_version", modName, versionId );
3404 if ( myWinVis.contains( modName ) )
3405 visArr = myWinVis[modName];
3407 QMap<QString, bool> tbMap, dwMap;
3408 dockWindowsState( visArr, tbMap, dwMap );
3410 QList<QToolBar*> tbList = qFindChildren<QToolBar*>( desktop() );
3411 for ( QList<QToolBar*>::iterator it = tbList.begin(); it != tbList.end(); ++it )
3414 tbMap.insert( tb->objectName(), tb->toggleViewAction()->isChecked() );
3417 QList<QDockWidget*> dwList = qFindChildren<QDockWidget*>( desktop() );
3418 for ( QList<QDockWidget*>::iterator it = dwList.begin(); it != dwList.end(); ++it )
3420 QDockWidget* wid = *it;
3421 dwMap.insert( wid->objectName(), wid->toggleViewAction()->isChecked() );
3424 visArr = dockWindowsState( tbMap, dwMap );
3426 myWinVis.insert( modName, visArr );
3429 QByteArray LightApp_Application::dockWindowsState( const QMap<QString, bool>& tb, const QMap<QString, bool>& dw ) const
3432 QDataStream stream( &visArr, QIODevice::WriteOnly );
3434 stream << (uchar)ToolBarMarker;
3435 stream << tb.size();
3436 for ( QMap<QString, bool>::const_iterator tit = tb.begin(); tit != tb.end(); ++tit )
3438 stream << tit.key();
3439 stream << (uchar)( tit.value() ? 1 : 0 );
3442 stream << (uchar)DockWidgetMarker;
3443 stream << dw.size();
3444 for ( QMap<QString, bool>::const_iterator wit = dw.begin(); wit != dw.end(); ++wit )
3446 stream << wit.key();
3447 stream << (uchar)( wit.value() ? 1 : 0 );
3453 void LightApp_Application::dockWindowsState( const QByteArray& arr, QMap<QString, bool>& tb, QMap<QString, bool>& dw ) const
3458 QByteArray visArr = arr;
3459 QDataStream stream( &visArr, QIODevice::ReadOnly );
3463 if ( marker != ToolBarMarker )
3468 for ( int i = 0; i < lines; ++i )
3471 stream >> objectName;
3474 tb.insert( objectName, shown );
3478 if ( marker != DockWidgetMarker )
3482 for ( int j = 0; j < lines; ++j )
3485 stream >> objectName;
3488 dw.insert( objectName, shown );
3493 Adds icon names for modules
3495 void LightApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) const
3499 SUIT_ResourceMgr* resMgr = resourceMgr();
3503 QStringList modList;
3504 modules( modList, false );
3506 for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )
3508 QString modName = *it;
3509 QString modIntr = moduleName( modName );
3510 QString modIcon = resMgr->stringValue( modIntr, "icon", QString() );
3512 if ( modIcon.isEmpty() )
3515 if ( SUIT_Tools::extension( modIcon ).isEmpty() )
3516 modIcon += QString( ".png" );
3518 iconMap.insert( modName, modIcon );
3523 Inserts items in popup, which necessary for current application
3525 void LightApp_Application::contextMenuPopup( const QString& type, QMenu* thePopup, QString& title )
3528 LightApp_SelectionMgr* selMgr = LightApp_Application::selectionMgr();
3529 bool cacheIsOn = selMgr->isSelectionCacheEnabled();
3530 selMgr->setSelectionCacheEnabled( true );
3532 SUIT_DataBrowser* ob = objectBrowser();
3534 CAM_Application::contextMenuPopup( type, thePopup, title );
3536 if ( ob && type == ob->popupClientType() ) {
3537 thePopup->addSeparator();
3538 QAction* a = thePopup->addAction( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
3539 if ( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) )
3540 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) );
3543 #ifndef DISABLE_SALOMEOBJECT
3544 if ( selMgr && ob ) {
3545 SALOME_ListIO selected;
3546 selMgr->selectedObjects( selected );
3547 if(selected.Extent() == 1){
3548 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3549 SUIT_DataObject* obj = findObject(anIObject->getEntry());
3550 if(obj && obj->renameAllowed()) {
3551 QAction* a = new QAction(tr("MEN_RENAME_OBJ"), thePopup);
3552 connect( a, SIGNAL( triggered(bool) ), ob, SLOT( onStartEditing() ) );
3553 if ( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) )
3554 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) );
3556 QList<QAction*> acts = thePopup->actions();
3557 QAction* firstAction = acts.count() > 0 ? acts.first() : 0;
3558 thePopup->insertAction(firstAction,a);
3564 selMgr->setSelectionCacheEnabled( cacheIsOn );
3570 void LightApp_Application::createEmptyStudy()
3572 CAM_Application::createEmptyStudy();
3574 if ( objectBrowser() )
3575 objectBrowser()->updateTree();
3577 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
3578 if ( aResMgr && activeStudy() ) {
3579 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
3580 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
3585 void LightApp_Application::setDesktop( SUIT_Desktop* desk )
3587 CAM_Application::setDesktop( desk );
3590 connect( desk, SIGNAL( message( const QString& ) ),
3591 this, SLOT( onDesktopMessage( const QString& ) ), Qt::UniqueConnection );
3592 connect( desk, SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
3593 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
3599 \param mod - module to be activated
3601 bool LightApp_Application::activateModule( CAM_Module* mod )
3603 bool res = CAM_Application::activateModule( mod );
3605 if ( objectBrowser() )
3606 objectBrowser()->updateTree();
3612 \return keyborad accelerators manager object
3614 SUIT_Accel* LightApp_Application::accel() const
3620 Removes dead widget container from map
3622 void LightApp_Application::onWCDestroyed( QObject* ob )
3624 // remove destroyed widget container from windows map
3625 for ( WinMap::ConstIterator itr = myWin.begin(); itr != myWin.end(); ++itr )
3627 if ( itr.value() != ob )
3630 int key = itr.key();
3631 myWin.remove( key );
3636 void LightApp_Application::onMRUActivated( const QString& name )
3638 SUIT_Session* s = SUIT_Session::session();
3639 if ( s && s->activeApplication() == this )
3643 void LightApp_Application::onStylePreferences()
3645 Style_PrefDlg dlg( desktop() );
3648 resourceMgr()->setValue( "Style", "use_salome_style", Style_Salome::isActive() );
3651 void LightApp_Application::onFullScreen(){
3652 if(myScreenHelper) {
3653 if(desktop()->isFullScreen())
3654 myScreenHelper->switchToNormalScreen();
3656 myScreenHelper->switchToFullScreen();
3661 Connects just added view manager
3663 void LightApp_Application::addViewManager( SUIT_ViewManager* vm )
3665 connect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
3666 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
3667 CAM_Application::addViewManager( vm );
3671 Remove view manager from memory
3673 void LightApp_Application::removeViewManager( SUIT_ViewManager* vm )
3675 disconnect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
3676 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
3677 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
3679 aStudy->removeObjectProperties( vm->getGlobalId() );
3681 CAM_Application::removeViewManager( vm );
3683 LightApp_SelectionMgr* selMgr = selectionMgr();
3684 QList<SUIT_Selector*> selectors;
3685 selMgr->selectors( selectors );
3686 foreach( SUIT_Selector* selector, selectors ) {
3687 if ( selector->owner() == vm->getViewModel() ) {
3692 // IPAL22894: Crash on closing OCC view
3698 Renames active window of desktop
3700 void LightApp_Application::onRenameWindow()
3705 QWidget* w = desktop()->activeWindow();
3710 QString name = QInputDialog::getText( w, tr( "TOT_RENAME" ), tr( "PRP_RENAME" ), QLineEdit::Normal, w->windowTitle(), &ok );
3711 if( ok && !name.isEmpty() )
3712 w->setWindowTitle( name );
3716 Closes active window of desktop
3718 void LightApp_Application::onCloseWindow()
3723 QWidget* w = desktop()->activeWindow();
3731 Closes all windows of desktop
3733 void LightApp_Application::onCloseAllWindow()
3735 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
3739 QList<SUIT_ViewWindow*> wndList = desk->windows();
3740 SUIT_ViewWindow* wnd;
3741 foreach( wnd, wndList )
3749 Groups all windows of desktop
3751 void LightApp_Application::onGroupAllWindow()
3753 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
3757 QtxWorkstack* wgStack = desk->workstack();
3763 \return if the library of module exists
3764 \param moduleTitle - title of module
3766 bool LightApp_Application::isLibExists( const QString& moduleTitle ) const
3768 if( moduleTitle.isEmpty() )
3771 QString lib = moduleLibrary( moduleTitle );
3773 //abd: changed libSalomePyQtGUI to SalomePyQtGUI for WIN32
3774 bool isPythonModule = lib.contains("SalomePyQtGUI");
3775 bool isPythonLightModule = lib.contains("SalomePyQtGUILight");
3779 paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
3781 paths = QString(::getenv( "LD_LIBRARY_PATH" )).split( ":", QString::SkipEmptyParts );
3784 bool isLibFound = false;
3785 QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
3786 for( ; anIt!=aLast; anIt++ )
3788 QFileInfo inf( Qtx::addSlash( *anIt ) + lib );
3799 INFOS( "\n****************************************************************" << std::endl
3800 << "* Warning: library " << lib.toLatin1().constData() << " cannot be found" << std::endl
3801 << "* Module " << moduleTitle.toLatin1().constData() << " will not be available in GUI mode" << std::endl
3802 << "****************************************************************" << std::endl );
3804 else if ( !isPythonModule && !isPythonLightModule)
3807 if ( isPythonModule || isPythonLightModule)
3809 QString pylib = moduleName( moduleTitle ) + QString(".py");
3810 QString pylibgui = moduleName( moduleTitle ) + QString("GUI.py");
3812 // Check the python library
3814 // paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
3816 paths = QString(::getenv( "PYTHONPATH" )).split( ":", QString::SkipEmptyParts );
3818 bool isPyLib = false, isPyGuiLib = false;
3819 QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
3820 for( ; anIt!=aLast; anIt++ )
3822 QFileInfo inf( Qtx::addSlash( *anIt ) + pylib );
3823 QFileInfo infgui( Qtx::addSlash( *anIt ) + pylibgui );
3825 if(!isPythonLightModule)
3826 if( !isPyLib && inf.exists() )
3829 if( !isPyGuiLib && infgui.exists() )
3832 if ((isPyLib || isPythonLightModule ) && isPyGuiLib && isLibFound)
3836 printf( "\n****************************************************************\n" );
3837 printf( "* Warning: python library for %s cannot be found:\n", moduleTitle.toLatin1().constData() );
3839 printf( "* No module named %s\n", moduleName( moduleTitle ).toLatin1().constData() );
3841 printf( "* No module named %s\n", (moduleName( moduleTitle ) + QString("GUI")).toLatin1().constData() );
3842 printf( "****************************************************************\n" );
3849 \return default name for an active study
3851 void LightApp_Application::setDefaultStudyName( const QString& theName )
3853 QStringList anInfoList;
3854 modules( anInfoList, false );
3856 LightApp_Study* aStudy = (LightApp_Study*)activeStudy();
3857 if( anInfoList.count() == 1 && // to avoid a conflict between different modules
3858 !aStudy->isSaved() )
3860 aStudy->setStudyName( theName );
3861 updateDesktopTitle();
3866 Custom event handler
3868 bool LightApp_Application::event( QEvent* e )
3870 if( e && e->type()==2000 )
3872 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
3873 QString* d = ( QString* )ce->data();
3874 if( SUIT_MessageBox::question(0, tr("WRN_WARNING"),
3876 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
3877 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
3878 showPreferences( tr( "PREF_APP" ) );
3883 return CAM_Application::event( e );
3886 /*! Check data object */
3887 bool LightApp_Application::checkDataObject(LightApp_DataObject* theObj)
3891 bool isSuitable = !theObj->entry().isEmpty() &&
3892 !theObj->componentDataType().isEmpty() &&
3893 !theObj->name().isEmpty();
3900 int LightApp_Application::openChoice( const QString& aName )
3902 int choice = CAM_Application::openChoice( aName );
3904 if ( choice == OpenExist ) // The document is already open.
3906 // Do you want to reload it?
3907 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "QUE_DOC_ALREADYOPEN" ).arg( aName ),
3908 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No ) == SUIT_MessageBox::Yes )
3909 choice = OpenReload;
3915 bool LightApp_Application::openAction( const int choice, const QString& aName )
3922 STD_Application* app = 0;
3923 SUIT_Session* session = SUIT_Session::session();
3924 QList<SUIT_Application*> appList = session->applications();
3925 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !app; ++it )
3927 if ( (*it)->activeStudy() && (*it)->activeStudy()->studyName() == aName )
3928 app = ::qobject_cast<STD_Application*>( *it );
3933 app->onCloseDoc( false );
3934 appList = session->applications();
3935 STD_Application* other = 0;
3936 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !other; ++it )
3937 other = ::qobject_cast<STD_Application*>( *it );
3940 res = other->onOpenDoc( aName );
3945 res = CAM_Application::openAction( choice, aName );
3952 QStringList LightApp_Application::viewManagersTypes() const
3954 QStringList aTypesList;
3955 aTypesList += myUserWmTypes;
3956 #ifndef DISABLE_GLVIEWER
3957 aTypesList<<GLViewer_Viewer::Type();
3959 #ifndef DISABLE_PLOT2DVIEWER
3960 aTypesList<<Plot2d_Viewer::Type();
3962 #ifndef DISABLE_QXGRAPHVIEWER
3963 aTypesList<<QxScene_Viewer::Type();
3965 #ifndef DISABLE_PVVIEWER
3966 aTypesList<<PVViewer_Viewer::Type();
3968 #ifndef DISABLE_OCCVIEWER
3969 aTypesList<<OCCViewer_Viewer::Type();
3971 #ifndef DISABLE_VTKVIEWER
3972 #ifndef DISABLE_SALOMEOBJECT
3973 aTypesList<<SVTK_Viewer::Type();
3975 aTypesList<<VTKViewer_Viewer::Type();
3981 * Removes all view managers of known types
3982 * Other view managers are ignored
3984 void LightApp_Application::clearKnownViewManagers()
3986 QStringList aTypesList = viewManagersTypes();
3987 QList<SUIT_ViewManager*> aMgrList;
3988 viewManagers( aMgrList );
3989 foreach (SUIT_ViewManager* aMgr, aMgrList) {
3990 if (aTypesList.contains(aMgr->getType()))
3991 removeViewManager(aMgr);
3996 Copy of current selection
3998 void LightApp_Application::onCopy()
4000 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
4006 Paste of current data in clipboard
4008 void LightApp_Application::onPaste()
4010 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
4016 Browse (i.e. set focus on) the published objects
4017 \param theIsApplyAndClose - flag indicating that the dialog for creating objects
4018 has been accepted by Ok (or Apply & Close) button
4019 \param theIsOptimizedBrowsing - flag switching to optimized browsing mode
4020 (to select the first published object only)
4021 \return entry of the selected object
4023 QString LightApp_Application::browseObjects( const QStringList& theEntryList,
4024 const bool theIsApplyAndClose,
4025 const bool theIsOptimizedBrowsing )
4028 if( SUIT_ResourceMgr* aResourceMgr = resourceMgr() )
4030 int aBrowsePolicy = aResourceMgr->integerValue( "ObjectBrowser", "browse_published_object", (int)BP_Never );
4031 switch( aBrowsePolicy )
4035 case BP_ApplyAndClose:
4036 if( !theIsApplyAndClose )
4044 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
4048 SUIT_DataBrowser* anOB = objectBrowser();
4052 SUIT_AbstractModel* aModel = dynamic_cast<SUIT_AbstractModel*>( anOB->model() );
4056 QStringListIterator anIter( theEntryList );
4057 if( theIsOptimizedBrowsing )
4059 // go to the last entry
4061 if( anIter.hasPrevious() )
4065 // scroll to each entry in the list
4066 // (in optimized mode - to the last entry only)
4068 LightApp_DataObject* anObject = 0;
4069 while( anIter.hasNext() )
4071 anEntry = anIter.next();
4072 if( !anEntry.isEmpty() )
4074 anObject = aStudy->findObjectByEntry( anEntry );
4077 QModelIndex anIndex = aModel->index( anObject );
4078 anOB->treeView()->scrollTo( anIndex );
4083 // always select the last object
4084 if( anObject && !anEntry.isEmpty() )
4086 QList<SUIT_Selector*> aSelectorList;
4087 selectionMgr()->selectors( "ObjectBrowser", aSelectorList );
4088 if( !aSelectorList.isEmpty() )
4090 if( LightApp_OBSelector* aSelector = dynamic_cast<LightApp_OBSelector*>( aSelectorList.first() ) )
4092 bool anIsAutoBlock = aSelector->autoBlock();
4094 // temporarily disable auto block, to emit LightApp_SelectionMgr::currentSelectionChanged() signal
4095 aSelector->setAutoBlock( false );
4097 SUIT_DataOwnerPtrList aList;
4098 #ifndef DISABLE_SALOMEOBJECT
4099 Handle(SALOME_InteractiveObject) aSObj = new SALOME_InteractiveObject
4100 ( anObject->entry().toLatin1().constData(),
4101 anObject->componentDataType().toLatin1().constData(),
4102 anObject->name().toLatin1().constData() );
4103 LightApp_DataOwner* owner = new LightApp_DataOwner( aSObj );
4105 LightApp_DataOwner* owner = new LightApp_DataOwner( anEntry );
4108 aList.append( owner );
4109 selectionMgr()->setSelected( aList );
4112 // restore auto block flag
4113 aSelector->setAutoBlock( anIsAutoBlock );
4121 SUIT_DataObject* LightApp_Application::findObject( const QString& id ) const
4123 LightApp_Study* study = dynamic_cast<LightApp_Study*>( activeStudy() );
4124 return study ? study->findObjectByEntry( id ) : 0;
4128 Checks that an object can be renamed.
4129 \param entry entry of the object
4130 \brief Return \c true if object can be renamed
4132 bool LightApp_Application::renameAllowed( const QString& /*entry*/) const {
4137 Rename object by entry.
4138 \param entry entry of the object
4139 \param name new name of the object
4140 \brief Return \c true if rename operation finished successfully, \c false otherwise.
4142 bool LightApp_Application::renameObject( const QString& entry, const QString& ) {
4146 /*! Process standard messages from desktop */
4147 void LightApp_Application::onDesktopMessage( const QString& message )
4149 const QString sectionSeparator = "/";
4151 if ( message.toLower() == "updateobjectbrowser" ||
4152 message.toLower() == "updateobjbrowser" ) {
4153 // update object browser
4154 updateObjectBrowser();
4156 else if ( message.toLower().startsWith( "activate_viewer" ) ) {
4157 QString vtype = message.split( sectionSeparator ).last();
4158 if ( !vtype.isEmpty() )
4159 getViewManager( vtype, true );
4162 QStringList data = message.split( sectionSeparator );
4163 if ( data.count() > 1 ) {
4164 QString msgType = data[0].trimmed();
4165 LightApp_Module* sMod = 0;
4166 CAM_Module* mod = module( msgType );
4168 mod = module( moduleTitle( msgType ) );
4169 if ( mod && mod->inherits( "LightApp_Module" ) )
4170 sMod = (LightApp_Module*)mod;
4172 if ( msgType.toLower() == "preferences" ) {
4173 // requested preferences change: should be given as "preferences/<section>/<name>/<value>"
4174 // for example "preferences/Study/multi_file_dump/true"
4175 if ( data.count() > 3 ) {
4176 QString section = data[1].trimmed();
4177 QString param = data[2].trimmed();
4178 QString value = QStringList( data.mid(3) ).join( sectionSeparator );
4179 resourceMgr()->setValue( section, param, value );
4183 // received message for the module
4184 QString msg = QStringList( data.mid(1) ).join( sectionSeparator );
4185 sMod->message( msg );
4193 Returns all top level toolbars.
4194 Note : Result list contains only main window toolbars, not including toolbars from viewers.
4196 QList<QToolBar*> LightApp_Application::findToolBars( const QStringList& names )
4198 QList<QToolBar*> aResult;
4199 QList<QToolBar*> tbList = qFindChildren<QToolBar*>( desktop() );
4200 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit ) {
4201 QToolBar* tb = *tit;
4202 QObject* po = Qtx::findParent( tb, "QMainWindow" );
4203 if ( po != desktop() )
4205 if ( names.isEmpty() || names.contains( tb->objectName() ) )
4212 Internal method to parse toolbars and dockable windows state.
4214 QByteArray LightApp_Application::processState(QByteArray& input,
4215 const bool processWin,
4216 const bool processTb,
4217 const bool isRestoring,
4218 QByteArray defaultState) {
4221 bool hasDefaultState = !defaultState.isEmpty();
4222 bool isDockWinWriten = false;
4224 //Write date from users settings
4226 QDataStream tmpInputData(&input, QIODevice::ReadOnly);
4227 int marker, version;
4229 tmpInputData >> marker;
4230 tmpInputData >> version;
4231 tmpInputData >> dockmarker;
4232 tmpInputData >> nbDocWin;
4234 if(processWin && processTb && !isRestoring) {
4236 } else if(!processWin && !processTb ) {
4238 aRes = defaultState;
4240 QDataStream aData(&aRes, QIODevice::WriteOnly);
4241 QList<QToolBar*> aToolBars = findToolBars();
4244 for ( QList<QToolBar*>::iterator tit = aToolBars.begin(); tit != aToolBars.end(); ++tit ) {
4245 QToolBar* tb = *tit;
4246 aNames.append(tb->objectName());
4249 int toolBarMarkerIndex = getToolbarMarkerIndex(input,aNames);
4250 if(toolBarMarkerIndex < 0)
4252 QDataStream anInputData(&input, QIODevice::ReadOnly);
4254 int toolBarMarkerIndexDef;
4255 if(hasDefaultState) {
4256 toolBarMarkerIndexDef = getToolbarMarkerIndex(defaultState, aNames);
4257 if(toolBarMarkerIndexDef < 0)
4260 QDataStream anInputDataDef(&defaultState, QIODevice::ReadOnly);
4262 QDataStream* aTargetData = 0;
4263 int aTargetIndex = -1;
4265 QByteArray currentArr = desktop()->saveState();
4266 QDataStream anInputDataCur(¤tArr, QIODevice::ReadOnly);
4267 bool useInputData = !isRestoring || (isRestoring && nbDocWin > 0);
4268 if(processWin && useInputData) {
4269 aTargetData = &anInputData;
4270 aTargetIndex = toolBarMarkerIndex;
4272 //Write date from default settings
4273 if(hasDefaultState) {
4274 aTargetData = &anInputDataDef;
4275 aTargetIndex = toolBarMarkerIndexDef;
4277 //If no default state, write current snapshot of the dockable windows
4279 aTargetData = &anInputDataCur;
4280 int toolBarMarkerIndexCur = getToolbarMarkerIndex(currentArr, aNames);
4281 aTargetIndex = toolBarMarkerIndexCur;
4286 if(aTargetData && aTargetIndex >= 0 ) {
4287 aTargetData->device()->seek(0);
4288 while( aTargetData->device()->pos() < aTargetIndex ) {
4293 isDockWinWriten = true;
4300 aTargetData = &anInputData;
4301 aTargetIndex = toolBarMarkerIndex;
4303 if(hasDefaultState) {
4304 aTargetData = &anInputDataDef;
4305 aTargetIndex = toolBarMarkerIndexDef;
4309 if(aTargetData && aTargetIndex >= 0) {
4311 if(!isDockWinWriten ) {
4312 //Write version marker
4313 int marker, version;
4314 aTargetData->device()->seek(0);
4315 *aTargetData >> marker;
4316 *aTargetData >> version;
4319 aData << (uchar) QDockWidgetMarker;
4321 int shift = 4*sizeof(int) + sizeof(QSize);
4322 index = aTargetIndex - shift;
4324 index = aTargetIndex;
4327 aTargetData->device()->seek(index);
4328 while(!aTargetData->atEnd()) {
4333 } else { // Not treat toolbars
4334 aData << (uchar) QToolBarMarker;
4335 aData << (int) 0; //Nb toolbars = 0
4342 \brief Emits operationFinished signal.
4343 \param theModuleName the name of the module which perfomed the operation
4344 \param theOperationName the operation name
4345 \param theEntryList the list of the created objects entries
4347 void LightApp_Application::emitOperationFinished( const QString& theModuleName,
4348 const QString& theOperationName,
4349 const QStringList& theEntryList )
4351 emit operationFinished( theModuleName, theOperationName, theEntryList );
4355 Update visibility state of given objects
4357 void LightApp_Application::updateVisibilityState( DataObjectList& theList,
4358 SUIT_ViewModel* theViewModel )
4360 if ( !theViewModel || theList.isEmpty() ) return;
4362 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
4363 if ( !aStudy ) return;
4365 SALOME_View* aView = dynamic_cast<SALOME_View*>( theViewModel );
4367 for ( DataObjectList::iterator itr = theList.begin(); itr != theList.end(); ++itr ) {
4368 LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>(*itr);
4370 if ( !obj || aStudy->isComponent( obj->entry() ) )
4373 LightApp_Module* anObjModule = dynamic_cast<LightApp_Module*>(obj->module());
4374 if ( anObjModule ) {
4375 LightApp_Displayer* aDisplayer = anObjModule->displayer();
4377 Qtx::VisibilityState anObjState = Qtx::UnpresentableState;
4378 if ( aDisplayer->canBeDisplayed( obj->entry(), theViewModel->getType() ) ) {
4379 if ( aView && aDisplayer->IsDisplayed( obj->entry(), aView ) )
4380 anObjState = Qtx::ShownState;
4382 anObjState = Qtx::HiddenState;
4384 aStudy->setVisibilityState( obj->entry(), anObjState );
4391 * Called when window activated
4393 void LightApp_Application::onWindowActivated( SUIT_ViewWindow* theViewWindow )
4395 SUIT_DataBrowser* anOB = objectBrowser();
4398 SUIT_DataObject* rootObj = anOB->root();
4402 DataObjectList listObj = rootObj->children( true );
4404 SUIT_ViewModel* vmod = 0;
4405 if ( SUIT_ViewManager* vman = theViewWindow->getViewManager() )
4406 vmod = vman->getViewModel();
4407 updateVisibilityState( listObj, vmod );
4411 Called then view manager removed
4413 void LightApp_Application::onViewManagerRemoved( SUIT_ViewManager* )
4415 ViewManagerList lst;
4416 viewManagers( lst );
4417 if ( lst.count() == 1) { // in case if closed last view window
4418 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
4420 aStudy->setVisibilityStateForAll( Qtx::UnpresentableState );
4425 Check existing document.
4427 bool LightApp_Application::checkExistingDoc()
4430 if( activeStudy() ) {
4431 int answer = SUIT_MessageBox::question( desktop(),
4432 tr( "APPCLOSE_CAPTION" ),
4433 tr( "STUDYCLOSE_DESCRIPTION" ),
4434 tr( "APPCLOSE_SAVE" ),
4435 tr( "APPCLOSE_CLOSE" ),
4436 tr( "APPCLOSE_CANCEL" ), 0 );
4438 if ( activeStudy()->isSaved() ) {
4441 } else if ( onSaveAsDoc() ) {
4442 if( !closeDoc( false ) ) {
4449 else if( answer == 1 ) {
4451 } else if( answer == 2 ) {
4458 #ifndef DISABLE_PYCONSOLE
4460 PyConsole_Interp* LightApp_Application::getPyInterp()
4462 static PyConsole_Interp* myInterp = 0;
4464 myInterp = createPyInterp();
4468 PyConsole_Interp* LightApp_Application::createPyInterp()
4470 return new LightApp_PyInterp();
4473 #endif // DISABLE_PYCONSOLE