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_Study.h"
47 #include "LightApp_Preferences.h"
48 #include "LightApp_PreferencesDlg.h"
49 #include "LightApp_ModuleDlg.h"
50 #include "LightApp_AboutDlg.h"
51 #include "LightApp_ModuleAction.h"
52 // temporary commented
53 #include "LightApp_EventFilter.h"
54 #include "LightApp_OBSelector.h"
55 #include "LightApp_SelectionMgr.h"
56 #include "LightApp_DataObject.h"
57 #include "LightApp_WgViewModel.h"
58 #include "LightApp_FullScreenHelper.h"
61 #include <GUI_version.h>
62 #include <Basics_OCCTVersion.hxx>
64 #include <SALOME_Event.h>
66 #include <Style_Salome.h>
67 #include <Style_PrefDlg.h>
69 #include <CAM_Module.h>
70 #include <CAM_DataModel.h>
71 #include <CAM_Study.h>
72 #include <STD_TabDesktop.h>
74 #include <SUIT_DataBrowser.h>
75 #include <SUIT_Session.h>
76 #include <SUIT_Study.h>
77 #include <SUIT_FileDlg.h>
78 #include <SUIT_ResourceMgr.h>
79 #include <SUIT_ShortcutMgr.h>
80 #include <SUIT_Tools.h>
81 #include <SUIT_Accel.h>
82 #include <SUIT_MessageBox.h>
83 #include <SUIT_ViewWindow.h>
86 #include <QtxToolBar.h>
87 #include <QtxTreeView.h>
88 #include <QtxMRUAction.h>
89 #include <QtxDockAction.h>
90 #include <QtxDockWidget.h>
91 #include <QtxActionToolMgr.h>
92 #include <QtxSearchTool.h>
93 #include <QtxWorkstack.h>
95 #include <QtxWebBrowser.h>
97 #include <LogWindow.h>
99 #ifndef DISABLE_GLVIEWER
100 #include <GLViewer_Viewer.h>
101 #include <GLViewer_ViewManager.h>
102 #include "LightApp_GLSelector.h"
105 #ifndef DISABLE_PLOT2DVIEWER
106 #include <Plot2d_ViewManager.h>
107 #include <Plot2d_ViewModel.h>
108 #include <Plot2d_ViewWindow.h>
109 #include <Plot2d_ViewFrame.h>
110 #include "LightApp_Plot2dSelector.h"
111 #ifndef DISABLE_SALOMEOBJECT
112 #include <SPlot2d_ViewModel.h>
114 #include <Plot2d_ViewModel.h>
118 #ifndef DISABLE_OCCVIEWER
119 #include <OCCViewer_ViewManager.h>
120 #include <OCCViewer_ViewFrame.h>
121 #ifndef DISABLE_SALOMEOBJECT
122 #include <SOCC_ViewModel.h>
124 #include <OCCViewer_ViewModel.h>
126 #include "LightApp_OCCSelector.h"
129 #ifndef DISABLE_VTKVIEWER
130 #ifndef DISABLE_SALOMEOBJECT
131 #include <SVTK_ViewModel.h>
132 #include <SVTK_ViewManager.h>
133 #include "LightApp_VTKSelector.h"
135 #include <VTKViewer_ViewModel.h>
136 #include <VTKViewer_ViewManager.h>
138 #include <VTKViewer_ViewModel.h>
141 #ifndef DISABLE_QXGRAPHVIEWER
142 #include <QxScene_ViewManager.h>
143 #include <QxScene_ViewModel.h>
144 #include <QxScene_ViewWindow.h>
147 #ifndef DISABLE_GRAPHICSVIEW
148 #include "GraphicsView_Viewer.h"
149 #include "GraphicsView_ViewManager.h"
150 #include "LightApp_GVSelector.h"
153 #define VISIBILITY_COLUMN_WIDTH 25
159 #include <QStringList>
161 #include <QApplication>
163 #include <QStatusBar>
165 #include <QObjectList>
167 #include <QInputDialog>
168 #include <QFontDatabase>
170 #include <QByteArray>
174 #include <QHeaderView>
179 #include <utilities.h>
181 #define FIRST_HELP_ID 1000000
183 #ifndef DISABLE_SALOMEOBJECT
184 #include <SALOME_InteractiveObject.hxx>
185 #include <SALOME_ListIO.hxx>
188 #include <Standard_Version.hxx>
190 #define ToolBarMarker 0
191 #define DockWidgetMarker 1
193 static const char* imageEmptyIcon[] = {
196 "....................",
197 "....................",
198 "....................",
199 "....................",
200 "....................",
201 "....................",
202 "....................",
203 "....................",
204 "....................",
205 "....................",
206 "....................",
207 "....................",
208 "....................",
209 "....................",
210 "....................",
211 "....................",
212 "....................",
213 "....................",
214 "....................",
215 "...................."};
217 int LightApp_Application::lastStudyId = 0;
220 // Markers used to parse array with dockable windows and toolbars state.
221 // For more details please see the qdockarealayout.cpp && qtoolbararealayout.cpp
222 // in the Qt source code.
224 #define QDockWidgetMarker 0xfd // = DockWidgetStateMarker
225 #define QToolBarMarker 0xfc // = ToolBarStateMarkerEx
227 // Format of the Byte array with the windows and toolbar state is:
228 // VersionMarker|version|DockWidgetStateMarker|nbDockWidgetLines|...DocWidgetData...|ToolBarStateMarkerEx|nbToolBarLines|...ToolBarData...
230 //Find toolbar marker position in the array in the following way:
231 //since the 'toolbar marker' is not unique, find index of first occurrence of the
232 //'toolbar marker' in the array and check that next string is name of the toolbar
234 int getToolbarMarkerIndex(QByteArray input, const QStringList& aFlags) {
235 int aResult = -1,tmp = 0;
236 int inputLen = input.length();
237 QDataStream anInputData(&input, QIODevice::ReadOnly);
238 while(tmp < inputLen) {
239 tmp = input.indexOf(QToolBarMarker, tmp + 1);
242 anInputData.device()->seek(tmp);
246 anInputData >> lines;
248 if(lines == 0 && anInputData.atEnd()){
249 //Case then array doesn't contain information about toolbars,
260 if(aFlags.contains(str)) {
269 \return last global id of study
271 int LightApp_Application::studyId()
273 return LightApp_Application::lastStudyId;
276 /*!Create new instance of LightApp_Application.*/
277 extern "C" LIGHTAPP_EXPORT SUIT_Application* createApplication()
279 return new LightApp_Application();
282 /*! \var global preferences of LightApp */
283 LightApp_Preferences* LightApp_Application::_prefs_ = 0;
287 \class LightApp_Application
288 Application containing LightApp module
292 LightApp_Application::LightApp_Application()
293 : CAM_Application( false ),
295 myScreenHelper(new LightApp_FullScreenHelper())
297 Q_INIT_RESOURCE( LightApp );
299 STD_TabDesktop* desk = new STD_TabDesktop();
300 desk->setFullScreenAllowed(false);
301 desk->setMinimizeAllowed(false);
305 // initialize auto save timer
306 myAutoSaveTimer = new QTimer( this );
307 myAutoSaveTimer->setSingleShot( true );
308 connect( myAutoSaveTimer, SIGNAL( timeout() ), this, SLOT( onSaveDoc() ) );
310 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
311 QPixmap aLogo = aResMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
313 QtxWebBrowser::setResourceManager( aResMgr );
314 QtxWebBrowser::setData("browser:icon", aResMgr->loadPixmap( "LightApp", tr( "BROWSER_ICON" ) ) );
315 QtxWebBrowser::setData("browser:title", tr( "BROWSER_TITLE" ) );
316 QtxWebBrowser::setData("toolbar:title", tr( "BROWSER_TOOLBAR_TITLE" ) );
317 QtxWebBrowser::setData("menu:file:title", tr( "BROWSER_FILEMENU" ) );
318 QtxWebBrowser::setData("action:close:title", tr( "BROWSER_CLOSE" ) );
319 QtxWebBrowser::setData("action:close:icon", aResMgr->loadPixmap( "LightApp", tr( "BROWSER_CLOSE_ICON" ) ) );
320 QtxWebBrowser::setData("action:back:title", tr( "BROWSER_BACK" ) );
321 QtxWebBrowser::setData("action:forward:title", tr( "BROWSER_FORWARD" ) );
322 QtxWebBrowser::setData("action:find:title", tr( "BROWSER_FIND" ) );
323 QtxWebBrowser::setData("action:findnext:title", tr( "BROWSER_FINDNEXT" ) );
324 QtxWebBrowser::setData("action:findprev:title", tr( "BROWSER_FINDPREV" ) );
326 desktop()->setWindowIcon( aLogo );
327 desktop()->setDockableMenuBar( false );
328 desktop()->setDockableStatusBar( false );
330 // base logo (salome itself)
331 desktop()->logoInsert( "_app_base", aResMgr->loadPixmap( "LightApp", tr( "APP_BASE_LOGO" ), false ) );
332 // extra logo (salome-based application)
333 desktop()->logoInsert( "_app_extra", aResMgr->loadPixmap( "LightApp", tr( "APP_EXTRA_LOGO" ), false ) );
337 mySelMgr = new LightApp_SelectionMgr( this );
339 myAccel = SUIT_Accel::getAccel();
341 #ifndef DISABLE_OCCVIEWER
342 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, OCCViewer_Viewer::Type() );
343 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, OCCViewer_Viewer::Type() );
344 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, OCCViewer_Viewer::Type() );
345 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, OCCViewer_Viewer::Type() );
346 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, OCCViewer_Viewer::Type() );
347 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, OCCViewer_Viewer::Type() );
348 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, OCCViewer_Viewer::Type() );
349 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, OCCViewer_Viewer::Type() );
350 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, OCCViewer_Viewer::Type() );
351 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, OCCViewer_Viewer::Type() );
352 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, OCCViewer_Viewer::Type() );
353 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, OCCViewer_Viewer::Type() );
355 #ifndef DISABLE_VTKVIEWER
356 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, VTKViewer_Viewer::Type() );
357 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, VTKViewer_Viewer::Type() );
358 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, VTKViewer_Viewer::Type() );
359 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, VTKViewer_Viewer::Type() );
360 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, VTKViewer_Viewer::Type() );
361 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, VTKViewer_Viewer::Type() );
362 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, VTKViewer_Viewer::Type() );
363 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, VTKViewer_Viewer::Type() );
364 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, VTKViewer_Viewer::Type() );
365 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, VTKViewer_Viewer::Type() );
366 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, VTKViewer_Viewer::Type() );
367 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, VTKViewer_Viewer::Type() );
369 #ifndef DISABLE_PLOT2DVIEWER
370 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, Plot2d_Viewer::Type() );
371 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, Plot2d_Viewer::Type() );
372 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, Plot2d_Viewer::Type() );
373 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, Plot2d_Viewer::Type() );
374 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, Plot2d_Viewer::Type() );
375 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, Plot2d_Viewer::Type() );
376 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, Plot2d_Viewer::Type() );
377 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, Plot2d_Viewer::Type() );
380 connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) );
382 // Set existing font for the python console in resources
383 if( !aResMgr->hasValue( "PyConsole", "font" ) )
386 QFont f = aResMgr->fontValue( "PyConsole", "font" );
388 QStringList famdb = fdb.families();
390 if ( famdb.contains(f.family()) || !aResMgr->hasValue( "PyConsole", "additional_families" ) )
393 QStringList anAddFamilies = aResMgr->stringValue( "PyConsole", "additional_families" ).split( ";", QString::SkipEmptyParts );
395 for ( QStringList::Iterator it = anAddFamilies.begin(); it != anAddFamilies.end(); ++it )
398 if ( famdb.contains(aFamily) )
400 f.setFamily( aFamily );
401 aResMgr->setValue( "PyConsole", "font", f );
408 *\li Save window geometry.
409 *\li Save desktop geometry.
410 *\li Save resource maneger.
411 *\li Delete selection manager.
413 LightApp_Application::~LightApp_Application()
416 delete myScreenHelper;
419 /*!Start application.*/
420 void LightApp_Application::start()
422 CAM_Application::start();
425 updateViewManagers();
428 desktop()->statusBar()->showMessage( "" );
430 LightApp_EventFilter::Init();
433 /*!Gets application name.*/
434 QString LightApp_Application::applicationName() const
436 static QString _app_name;
437 if ( _app_name.isEmpty() )
438 _app_name = tr( "APP_NAME" );
442 /*!Gets application version.*/
443 QString LightApp_Application::applicationVersion() const
445 static QString _app_version;
447 if ( _app_version.isEmpty() )
449 QString resVersion = tr( "APP_VERSION" );
450 if ( resVersion != "APP_VERSION" )
452 _app_version = resVersion;
456 _app_version = GUI_VERSION_STR;
462 /*!Load module by \a name.*/
463 CAM_Module* LightApp_Application::loadModule( const QString& name, const bool showMsg )
465 CAM_Module* mod = CAM_Application::loadModule( name, showMsg );
468 connect( this, SIGNAL( studyOpened() ), mod, SLOT( onModelOpened() ) );
469 connect( this, SIGNAL( studySaved() ), mod, SLOT( onModelSaved() ) );
470 connect( this, SIGNAL( studyClosed() ), mod, SLOT( onModelClosed() ) );
475 /*!Activate module by \a modName*/
476 bool LightApp_Application::activateModule( const QString& modName )
479 CAM_Module* prevMod = activeModule();
482 actName = prevMod->moduleName();
484 if ( actName == modName )
487 putInfo( tr( "ACTIVATING_MODULE" ).arg( modName ) );
489 saveDockWindowsState();
491 bool status = CAM_Application::activateModule( modName );
493 updateModuleActions();
501 updateViewManagers();
506 /*!Gets selection manager.*/
507 LightApp_SelectionMgr* LightApp_Application::selectionMgr() const
512 /*!Creat action "New window" for certain type of viewer:*/
513 void LightApp_Application::createActionForViewer( const int id,
515 const QString& suffix,
518 QString vtlt = tr( QString( "NEW_WINDOW_%1" ).arg( suffix ).toLatin1().constData() );
519 QString tip = tr( "CREATING_NEW_WINDOW" ).arg( vtlt.remove( "&" ) );
520 QAction* a = createAction( id, // menu action id
527 false, // toggle flag
529 SLOT( onNewWindow() ) ); // slot
530 createMenu( a, parentId, -1 );
535 void LightApp_Application::createActions()
537 CAM_Application::createActions();
539 SUIT_Desktop* desk = desktop();
540 SUIT_ResourceMgr* resMgr = resourceMgr();
543 createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIcon(),
544 tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
545 Qt::CTRL+Qt::Key_R, desk, false, this, SLOT( onPreferences() ) );
549 // - Help for modules
551 int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
552 createMenu( separator(), helpMenu, -1, 10 );
553 QStringList aModuleList;
554 modules( aModuleList, false );
555 aModuleList.prepend( "GUI" );
556 aModuleList.prepend( "KERNEL" );
558 int id = LightApp_Application::UserID + FIRST_HELP_ID;
561 foreach( aModule, aModuleList ) {
562 if ( aModule.isEmpty() ) // module title (user name)
564 IMap <QString, QString> helpData; // list of help files for the module
565 QString helpSubMenu; // help submenu name (empty if not needed)
566 QString modName = moduleName( aModule ); // module name
567 if ( modName.isEmpty() ) modName = aModule; // for KERNEL and GUI
568 QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName ); // module root dir variable
569 QString modDir = getenv( rootDir.toLatin1().constData() ); // module root dir
571 if (resMgr->hasValue( modName, "documentation" ) )
572 docSection = resMgr->stringValue(modName, "documentation");
573 else if ( resMgr->hasSection( modName + "_documentation" ) )
574 docSection = modName + "_documentation";
575 if ( !docSection.isEmpty() ) {
576 helpSubMenu = resMgr->stringValue( docSection, "sub_menu", "" ).arg( aModule );
577 QStringList listOfParam = resMgr->parameters( docSection );
578 foreach( QString paramName, listOfParam ) {
579 QString valueStr = resMgr->stringValue( docSection, paramName );
580 if ( !valueStr.isEmpty() ) {
581 QFileInfo fi( valueStr );
582 if ( fi.isRelative() && !modDir.isEmpty() )
583 valueStr = Qtx::addSlash( modDir ) + valueStr;
584 if ( QFile::exists( valueStr ) )
585 helpData.insert( paramName.arg( aModule ), valueStr );
590 if ( helpData.isEmpty() && !modDir.isEmpty() ) {
591 QStringList idxLst = QStringList() << modDir << "share" << "doc" << "salome" << "gui" << modName << "index.html";
592 QString indexFile = idxLst.join( QDir::separator() ); // index file
593 if ( QFile::exists( indexFile ) )
594 helpData.insert( tr( "%1 module Users's Guide" ).arg( aModule ), indexFile );
597 IMapConstIterator<QString, QString > fileIt;
598 for ( fileIt = helpData.begin(); fileIt != helpData.end(); fileIt++ ) {
599 QString helpFileName = fileIt.key();
600 // remove all '//' occurances
601 while ( helpFileName.contains( "//" ) )
602 helpFileName.replace( "//", "" );
603 // obtain submenus hierarchy if given
604 QStringList smenus = helpFileName.split( "/" );
605 helpFileName = smenus.last();
607 QAction* a = createAction( id, helpFileName,
608 resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
609 helpFileName, helpFileName,
610 0, desk, false, this, SLOT( onHelpContentsModule() ) );
611 a->setData( fileIt.value() );
612 if ( !helpSubMenu.isEmpty() ) {
613 smenus.prepend( helpSubMenu );
615 // create sub-menus hierarchy
616 int menuId = helpMenu;
617 foreach ( QString subMenu, smenus ) {
618 menuId = createMenu( subMenu, menuId, -1, 0 );
620 createMenu( a, menuId, -1, 0 );
625 // - Additional help items
627 createMenu( separator(), helpMenu, -1, 5 );
629 QStringList addHelpItems = resMgr->parameters( "add_help" );
630 foreach ( QString addHelpItem, addHelpItems ) {
631 QString valueStr = resMgr->stringValue( "add_help", addHelpItem );
632 if ( !valueStr.isEmpty() && QFile::exists( valueStr ) ) {
633 QAction* a = createAction( id, addHelpItem,
634 resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
635 addHelpItem, addHelpItem,
636 0, desk, false, this, SLOT( onHelpContentsModule() ) );
637 a->setData( valueStr );
638 createMenu( a, helpMenu, -1, 5 );
644 static QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), 0 );
645 connect( mru, SIGNAL( activated( const QString& ) ), this, SLOT( onMRUActivated( const QString& ) ) );
646 registerAction( MRUId, mru );
648 // default icon for neutral point ('SALOME' module)
649 QPixmap defIcon = resMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
650 if ( defIcon.isNull() )
651 defIcon = QPixmap( imageEmptyIcon );
653 //! default icon for any module
654 QPixmap modIcon = resMgr->loadPixmap( "LightApp", tr( "APP_MODULE_ICO" ), false );
655 if ( modIcon.isNull() )
656 modIcon = QPixmap( imageEmptyIcon );
659 modules( modList, false );
661 if ( modList.count() > 1 )
663 LightApp_ModuleAction* moduleAction =
664 new LightApp_ModuleAction( tr( "APP_NAME" ), defIcon, desk );
666 QMap<QString, QString> iconMap;
667 moduleIconNames( iconMap );
669 const int iconSize = 20;
671 QStringList::Iterator it;
672 for ( it = modList.begin(); it != modList.end(); ++it )
674 if ( !isLibExists( *it ) )
677 QString modName = moduleName( *it );
679 if ( !isModuleAccessible( *it ) )
683 if ( iconMap.contains( *it ) )
684 iconName = iconMap[*it];
686 QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
690 INFOS ( "\n****************************************************************" << std::endl
691 << "* Icon for " << (*it).toLatin1().constData()
692 << " not found. Using the default one." << std::endl
693 << "****************************************************************" << std::endl );
696 icon = Qtx::scaleIcon( icon, iconSize );
698 moduleAction->insertModule( *it, icon );
701 connect( moduleAction, SIGNAL( moduleActivated( const QString& ) ),
702 this, SLOT( onModuleActivation( const QString& ) ) );
703 registerAction( ModulesListId, moduleAction );
707 int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, MenuWindowId, 100 );
708 int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
710 createAction( CloseId, tr( "TOT_CLOSE" ), QIcon(), tr( "MEN_DESK_CLOSE" ), tr( "PRP_CLOSE" ),
711 Qt::CTRL+Qt::Key_F4, desk, false, this, SLOT( onCloseWindow() ) );
712 createAction( CloseAllId, tr( "TOT_CLOSE_ALL" ), QIcon(), tr( "MEN_DESK_CLOSE_ALL" ), tr( "PRP_CLOSE_ALL" ),
713 0, desk, false, this, SLOT( onCloseAllWindow() ) );
714 createAction( GroupAllId, tr( "TOT_GROUP_ALL" ), QIcon(), tr( "MEN_DESK_GROUP_ALL" ), tr( "PRP_GROUP_ALL" ),
715 0, desk, false, this, SLOT( onGroupAllWindow() ) );
717 createMenu( CloseId, windowMenu, 0, -1 );
718 createMenu( CloseAllId, windowMenu, 0, -1 );
719 createMenu( GroupAllId, windowMenu, 0, -1 );
720 createMenu( separator(), windowMenu, -1, 0 );
722 #ifndef DISABLE_GLVIEWER
723 createActionForViewer( NewGLViewId, newWinMenu, QString::number( 0 ), Qt::ALT+Qt::Key_G );
725 #ifndef DISABLE_PLOT2DVIEWER
726 createActionForViewer( NewPlot2dId, newWinMenu, QString::number( 1 ), Qt::ALT+Qt::Key_P );
728 #ifndef DISABLE_OCCVIEWER
729 createActionForViewer( NewOCCViewId, newWinMenu, QString::number( 2 ), Qt::ALT+Qt::Key_O );
731 #ifndef DISABLE_VTKVIEWER
732 createActionForViewer( NewVTKViewId, newWinMenu, QString::number( 3 ), Qt::ALT+Qt::Key_K );
734 #ifndef DISABLE_QXGRAPHVIEWER
735 createActionForViewer( NewQxSceneViewId, newWinMenu, QString::number( 4 ), Qt::ALT+Qt::Key_S );
737 #ifndef DISABLE_GRAPHICSVIEW
738 createActionForViewer( NewGraphicsViewId, newWinMenu, QString::number( 5 ), Qt::ALT+Qt::Key_R );
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" ) );
766 createTool( ModulesListId, modTBar );
769 /*!On module activation action.*/
770 void LightApp_Application::onModuleActivation( const QString& modName )
772 // Force user to create/open a study before module activation
773 QMap<QString, QString> iconMap;
774 moduleIconNames( iconMap );
775 QPixmap icon = resourceMgr()->loadPixmap( moduleName( modName ), iconMap[ modName ], false );
777 icon = resourceMgr()->loadPixmap( "LightApp", tr( "APP_MODULE_BIG_ICO" ), false ); // default icon for any module
779 bool cancelled = false;
781 while ( !modName.isEmpty() && !activeStudy() && !cancelled ){
782 LightApp_ModuleDlg aDlg( desktop(), modName, icon );
783 QMap<int, QString> opmap = activateModuleActions();
784 for ( QMap<int, QString>::ConstIterator it = opmap.begin(); it != opmap.end(); ++it )
785 aDlg.addButton( it.value(), it.key() );
787 int res = aDlg.exec();
789 // some operation is selected
790 moduleActionSelected( res );
794 putInfo( tr("INF_CANCELLED") );
796 LightApp_ModuleAction* moduleAction =
797 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
799 moduleAction->setActiveModule( QString() );
805 activateModule( modName );
808 /*!Default module activation.*/
809 QString LightApp_Application::defaultModule() const
811 QStringList aModuleNames;
812 modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration
813 //! If there's the one and only module --> activate it automatically
814 //! TODO: Possible improvement - default module can be taken from preferences
815 return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" );
818 /*!On new window slot.*/
819 void LightApp_Application::onNewWindow()
821 const QObject* obj = sender();
822 if ( !obj || !obj->inherits( "QAction" ) )
826 int id = actionId( (QAction*)obj );
829 #ifndef DISABLE_GLVIEWER
831 type = GLViewer_Viewer::Type();
834 #ifndef DISABLE_PLOT2DVIEWER
836 type = Plot2d_Viewer::Type();
839 #ifndef DISABLE_OCCVIEWER
841 type = OCCViewer_Viewer::Type();
844 #ifndef DISABLE_VTKVIEWER
846 type = VTKViewer_Viewer::Type();
849 #ifndef DISABLE_QXGRAPHVIEWER
850 case NewQxSceneViewId:
851 type = QxScene_Viewer::Type();
854 #ifndef DISABLE_GRAPHICSVIEW
855 case NewGraphicsViewId:
856 type = GraphicsView_Viewer::Type();
861 if ( !type.isEmpty() )
862 createViewManager( type );
866 SLOT: Creates new document
868 void LightApp_Application::onNewDoc()
870 //asl: fix for 0020515
871 if ( activeStudy() ) {
872 saveDockWindowsState();
873 #ifdef SINGLE_DESKTOP
879 CAM_Application::onNewDoc();
883 SLOT: Opens new document
885 void LightApp_Application::onOpenDoc()
887 SUIT_Study* study = activeStudy();
888 saveDockWindowsState();
890 #ifdef SINGLE_DESKTOP
896 CAM_Application::onOpenDoc();
898 if ( !study ) // new study will be create in THIS application
901 updateViewManagers();
906 SLOT: Opens new document.
907 \param aName - name of file
909 bool LightApp_Application::onOpenDoc( const QString& aName )
911 if ( activeStudy() ) {
912 #ifdef SINGLE_DESKTOP
917 // We should take mru action first because this application instance can be deleted later.
918 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
920 bool res = CAM_Application::onOpenDoc( aName );
925 mru->insert( aName );
927 mru->remove( aName );
933 SLOT: Displays "About" message box
935 void LightApp_Application::onHelpAbout()
937 LightApp_AboutDlg dlg( applicationName(), applicationVersion(), desktop() );
942 Private SLOT: Called on selection is changed
943 Dispatchs active module that selection is changed
945 void LightApp_Application::onSelection()
947 onSelectionChanged();
949 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
950 ((LightApp_Module*)activeModule())->selectionChanged();
955 \param study - SUIT_Study.
957 void LightApp_Application::setActiveStudy( SUIT_Study* study )
959 CAM_Application::setActiveStudy( study );
963 Enables/Disables menu items and toolbar buttons. Rebuild menu
965 void LightApp_Application::updateCommandsStatus()
967 CAM_Application::updateCommandsStatus();
970 #ifndef DISABLE_GLVIEWER
971 a = action( NewGLViewId );
973 a->setEnabled( activeStudy() );
976 #ifndef DISABLE_PLOT2DVIEWER
977 a = action( NewPlot2dId );
979 a->setEnabled( activeStudy() );
982 #ifndef DISABLE_OCCVIEWER
983 a = action( NewOCCViewId );
985 a->setEnabled( activeStudy() );
988 #ifndef DISABLE_VTKVIEWER
989 a = action( NewVTKViewId );
991 a->setEnabled( activeStudy() );
994 #ifndef DISABLE_QXGRAPHVIEWER
995 a = action( NewQxSceneViewId );
997 a->setEnabled( activeStudy() );
1000 #ifndef DISABLE_GRAPHICSVIEW
1001 a = action( NewGraphicsViewId );
1003 a->setEnabled( activeStudy() );
1009 Runs system command in separate thread
1011 class RunBrowser: public QThread
1014 RunBrowser( LightApp_Application* app,
1015 const QString& theApp,
1016 const QString& theParams,
1017 const QString& theHelpFile,
1018 const QString& theContext = QString() )
1020 myParams( theParams ),
1021 myContext( theContext ),
1025 //For the external browser always specify 'file://' protocol,
1026 //because some WEB browsers (for example Mozilla Firefox) can't open local file without protocol.
1027 myHelpFile = QString("file://%1").arg( QFileInfo( theHelpFile ).canonicalFilePath() );
1032 if ( !myApp.isEmpty() && !myHelpFile.isEmpty()) {
1033 QString aCommand = QString( "%1 %2 \"%3%4\"" ).arg( myApp, myParams, myHelpFile, myContext.isEmpty() ? QString("") : QString( "#%1" ).arg( myContext ) );
1035 QProcess* proc = new QProcess();
1037 proc->start( aCommand );
1038 if ( !proc->waitForStarted() ) {
1039 SALOME_CustomEvent* ce2000 = new SALOME_CustomEvent( 2000 );
1040 QString* msg = new QString( QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).arg( myApp, myHelpFile ) );
1041 ce2000->setData( msg );
1042 QApplication::postEvent( myLApp, ce2000 );
1053 LightApp_Application* myLApp;
1057 SLOT: Displays help contents for choosen module
1059 void LightApp_Application::onHelpContentsModule()
1061 const QAction* a = (QAction*) sender();
1062 QString helpFile = a->data().toString();
1063 if ( helpFile.isEmpty() ) return;
1065 SUIT_ResourceMgr* resMgr = resourceMgr();
1068 platform = "winapplication";
1070 platform = "application";
1072 QString anApp = resMgr->stringValue("ExternalBrowser", platform);
1074 QString quote("\"");
1075 anApp.prepend( quote );
1076 anApp.append( quote );
1078 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
1079 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1081 if( useExtBrowser ) {
1082 if ( !anApp.isEmpty() ) {
1083 RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile );
1087 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1088 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1089 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1091 showPreferences( tr( "PREF_APP" ) );
1096 // On Win32 platform QWebKit of the Qt 4.6.3 hang up in case 'file://' protocol
1097 // is defined. On Linux platform QWebKit doesn't work correctly without 'file://' protocol.
1098 QtxWebBrowser::loadUrl(helpFile);
1100 QtxWebBrowser::loadUrl(QString("file://%1").arg(helpFile));
1106 SLOT: Displays help contents for choosen dialog
1108 void LightApp_Application::onHelpContextModule( const QString& theComponentName,
1109 const QString& theFileName,
1110 const QString& theContext )
1112 QString fileName = theFileName;
1113 QString context = theContext;
1114 if ( !QFile::exists( fileName ) && theContext.isEmpty() ) {
1115 // context might be passed within theFileName argument
1116 QStringList comps = fileName.split("#");
1117 if ( comps.count() > 1 ) {
1118 context = comps.last();
1120 fileName = comps.join("#");
1124 QString homeDir = "";
1125 if ( !theComponentName.isEmpty() ) {
1126 QString dir = getenv( ( theComponentName + "_ROOT_DIR" ).toLatin1().constData() );
1127 if ( !dir.isEmpty() )
1128 homeDir = Qtx::addSlash( Qtx::addSlash( dir ) +
1129 Qtx::addSlash( "share" ) +
1130 Qtx::addSlash( "doc" ) +
1131 Qtx::addSlash( "salome" ) +
1132 Qtx::addSlash( "gui" ) +
1133 Qtx::addSlash( theComponentName ) );
1136 QString helpFile = QFileInfo( homeDir + fileName ).absoluteFilePath();
1137 SUIT_ResourceMgr* resMgr = resourceMgr();
1140 platform = "winapplication";
1142 platform = "application";
1144 QString anApp = resMgr->stringValue("ExternalBrowser", platform);
1146 QString quote("\"");
1147 anApp.prepend( quote );
1148 anApp.append( quote );
1151 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1154 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
1156 if ( !anApp.isEmpty() ) {
1157 RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile, context );
1161 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1162 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1163 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1164 showPreferences( tr( "PREF_APP" ) );
1169 // On Win32 platform QWebKit of the Qt 4.6.3 hang up in case 'file://' protocol
1170 // is defined. On Linux platform QWebKit doesn't work correctly without 'file://' protocol.
1171 QtxWebBrowser::loadUrl(helpFile, context);
1173 QtxWebBrowser::loadUrl(QString("file://%1").arg(helpFile), context);
1180 Sets enable or disable some actions on selection changed.
1182 void LightApp_Application::onSelectionChanged()
1184 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
1185 bool canCopy = m ? m->canCopy() : false;
1186 bool canPaste = m ? m->canPaste() : false;
1188 action( EditCopyId )->setEnabled(canCopy);
1189 action( EditPasteId )->setEnabled(canPaste);
1193 Adds window to application.
1194 \param wid - QWidget
1195 \param flag - key for window
1196 \param studyId - study id
1197 Flag used how identificator of window in windows list.
1200 void LightApp_Application::addWindow( QWidget* wid, const int flag, const int studyId )
1208 if ( !activeStudy() )
1211 sId = activeStudy()->id();
1214 if ( !myWindows.contains( flag ) )
1216 QMap<int, int> winMap;
1217 currentWindows( winMap );
1219 LightApp_WidgetContainer* newWC = new LightApp_WidgetContainer( flag, desktop() );
1220 connect( newWC, SIGNAL( destroyed ( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
1221 // asv: connecting a slot for storing visibility flag of a window
1222 connect( newWC, SIGNAL( visibilityChanged ( bool ) ), SLOT( onVisibilityChanged( bool ) ) );
1223 myWindows.insert( flag, newWC );
1224 if ( winMap.contains( flag ) ) {
1225 //desktop()->removeDockWidget( myWindows[flag] );
1226 desktop()->addDockWidget( (Qt::DockWidgetArea)winMap[flag], myWindows[flag] );
1229 //myWindows[flag]->setResizeEnabled( true );
1230 myWindows[flag]->setFeatures( QDockWidget::AllDockWidgetFeatures );
1231 myWindows[flag]->setObjectName( QString( "dock_window_%1" ).arg( flag ) );
1232 //myWindows[flag]->setFixedExtentWidth( wid->width() );
1233 //myWindows[flag]->setFixedExtentHeight( wid->height() );
1234 myWindows[flag]->resize( wid->width(), wid->height() );
1238 #ifndef DISABLE_PYCONSOLE
1239 if( wid->inherits( "PyConsole_Console" ) )
1241 if( resourceMgr()->hasValue( "PyConsole", "font" ) )
1242 f = resourceMgr()->fontValue( "PyConsole", "font" );
1245 f = ( ( PyConsole_Console* )wid )->font();
1246 resourceMgr()->setValue( "PyConsole", "font", f );
1253 myWindows[flag]->insert( sId, wid );
1256 setWindowShown( flag, !myWindows[flag]->isEmpty() );
1260 QWidget* LightApp_Application::dockWindow( const int id ) const
1263 if ( myWin.contains( id ) )
1268 QDockWidget* LightApp_Application::windowDock( QWidget* wid ) const
1273 QDockWidget* dock = 0;
1274 QWidget* w = wid->parentWidget();
1275 while ( w && !dock )
1277 dock = ::qobject_cast<QDockWidget*>( w );
1278 w = w->parentWidget();
1283 void LightApp_Application::insertDockWindow( const int id, QWidget* wid )
1288 if ( wid != dockWindow( id ) )
1289 removeDockWindow( id );
1291 myWin.insert( id, wid );
1293 QtxDockWidget* dock = new QtxDockWidget( true, desktop() );
1294 connect( dock, SIGNAL( destroyed( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
1296 dock->setFeatures( QDockWidget::AllDockWidgetFeatures );
1297 dock->setObjectName( QString( "window_%1" ).arg( id ) );
1298 dock->setWidget( wid );
1300 QKeySequence accel = wid->property( "shortcut" ).value<QKeySequence>();
1301 if ( !accel.isEmpty() )
1302 dock->toggleViewAction()->setShortcut( accel );
1307 void LightApp_Application::removeDockWindow( const int id )
1309 QWidget* wid = dockWindow( id );
1315 QDockWidget* dock = windowDock( wid );
1319 dock->setWidget( 0 );
1320 wid->setParent( 0 );
1321 wid->setVisible( false );
1325 void LightApp_Application::placeDockWindow( const int id, Qt::DockWidgetArea place )
1327 QDockWidget* dock = windowDock( dockWindow( id ) );
1328 if ( dock && desktop() ) {
1329 desktop()->addDockWidget( place, dock );
1330 QtxDockAction* a = qobject_cast<QtxDockAction*>( action( ViewWindowsId ) );
1331 if ( a ) a->update();
1337 \param flag - key for window
1338 \param studyId - study id
1339 Flag used how identificator of window in windows list.
1341 QWidget* LightApp_Application::getWindow( const int flag, const int )
1343 QWidget* wid = dockWindow( flag );
1345 insertDockWindow( flag, wid = createWindow( flag ) );
1347 QMap<int, int> winMap;
1348 currentWindows( winMap );
1349 if ( winMap.contains( flag ) )
1350 placeDockWindow( flag, (Qt::DockWidgetArea)winMap[flag] );
1356 \return Object Browser
1358 SUIT_DataBrowser* LightApp_Application::objectBrowser()
1360 return qobject_cast<SUIT_DataBrowser*>( dockWindow( WT_ObjectBrowser ) );
1366 LogWindow* LightApp_Application::logWindow()
1368 return qobject_cast<LogWindow*>( dockWindow( WT_LogWindow ) );
1371 #ifndef DISABLE_PYCONSOLE
1373 This returns the python console integrated to the GUI. Depending
1374 when you request the python console, this function could return
1375 null. Then the optional parameter force (default to false) can be
1376 set to force the creation of the python console if it is not done
1378 \param force - if true, the pythonConsole is created if it does not exist yet
1379 \return Python Console
1381 PyConsole_Console* LightApp_Application::pythonConsole(const bool force)
1383 QWidget* wid = dockWindow( WT_PyConsole );
1384 if ( !wid && force==true) {
1385 wid = getWindow(WT_PyConsole);
1387 return qobject_cast<PyConsole_Console*>( wid );
1392 Updates object browser and maybe data models
1393 \param updateModels - if it is true, then data models are updated
1395 void LightApp_Application::updateObjectBrowser( const bool updateModels )
1397 // update existing data models
1400 const bool isAutoUpdate = objectBrowser() ? objectBrowser()->autoUpdate() : true;
1401 if ( objectBrowser() )
1402 objectBrowser()->setAutoUpdate( false );
1404 LightApp_Study* study = dynamic_cast<LightApp_Study*>(activeStudy());
1406 CAM_Study::ModelList dm_list;
1407 study->dataModels( dm_list );
1408 QListIterator<CAM_DataModel*> it( dm_list );
1409 while ( it.hasNext() ) {
1410 CAM_DataModel* camDM = it.next();
1411 if ( camDM && camDM->inherits( "LightApp_DataModel" ) )
1412 ((LightApp_DataModel*)camDM)->update();
1416 if( objectBrowser() )
1417 objectBrowser()->setAutoUpdate( isAutoUpdate );
1420 if ( objectBrowser() ) {
1421 objectBrowser()->updateGeometry();
1422 objectBrowser()->updateTree( 0, false );
1429 LightApp_Preferences* LightApp_Application::preferences() const
1431 return preferences( false );
1435 \return first view manager of some type
1436 \param vmType - type of view manager
1437 \param create - is it necessary to create view manager in case, when there is no manager of such type
1439 SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, const bool create )
1441 SUIT_ViewManager* aVM = viewManager( vmType );
1442 SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
1444 if ( anActiveVM && anActiveVM->getType() == vmType )
1447 if ( aVM && create )
1449 if ( !aVM->getActiveView() )
1452 aVM->getActiveView()->setFocus();
1455 aVM = createViewManager( vmType );
1461 Creates view manager of some type
1462 \param vmType - type of view manager
1464 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType )
1466 SUIT_ResourceMgr* resMgr = resourceMgr();
1468 SUIT_ViewManager* viewMgr = 0;
1469 #ifndef DISABLE_GLVIEWER
1470 if( vmType == GLViewer_Viewer::Type() )
1472 viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() );
1473 new LightApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
1476 #ifndef DISABLE_PLOT2DVIEWER
1477 if( vmType == Plot2d_Viewer::Type() )
1479 viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
1481 #ifndef DISABLE_SALOMEOBJECT
1482 SPlot2d_Viewer* v = new SPlot2d_Viewer();
1484 new LightApp_Plot2dSelector( v, mySelMgr );
1486 vm = new Plot2d_Viewer();
1488 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1489 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
1492 Plot2d_ViewFrame* frame = wnd->getViewFrame();
1493 frame->setBackgroundColor( resMgr->colorValue( "Plot2d", "Background", frame->backgroundColor() ) );
1497 #ifndef DISABLE_QXGRAPHVIEWER
1498 if( vmType == QxScene_Viewer::Type() )
1500 viewMgr = new QxScene_ViewManager( activeStudy(), desktop() );
1501 QxScene_Viewer* vm = new QxScene_Viewer();
1502 viewMgr->setViewModel( vm );
1503 //QxScene_ViewWindow* wnd = dynamic_cast<QxScene_ViewWindow*>( viewMgr->getActiveView() );
1506 #ifndef DISABLE_GRAPHICSVIEW
1507 if( vmType == GraphicsView_Viewer::Type() )
1509 viewMgr = new GraphicsView_ViewManager( activeStudy(), desktop() );
1510 new LightApp_GVSelector( (GraphicsView_Viewer*)viewMgr->getViewModel(), mySelMgr );
1513 #ifndef DISABLE_OCCVIEWER
1514 if( vmType == OCCViewer_Viewer::Type() )
1516 viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
1517 OCCViewer_Viewer* vm;
1518 #ifndef DISABLE_SALOMEOBJECT
1519 vm = new SOCC_Viewer();
1521 vm = new OCCViewer_Viewer( true );
1523 vm->setBackground( OCCViewer_ViewFrame::TOP_LEFT,
1524 resMgr->backgroundValue( "OCCViewer", "xz_background", vm->background(OCCViewer_ViewFrame::TOP_LEFT) ) );
1525 vm->setBackground( OCCViewer_ViewFrame::TOP_RIGHT,
1526 resMgr->backgroundValue( "OCCViewer", "yz_background", vm->background(OCCViewer_ViewFrame::TOP_RIGHT) ) );
1527 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_LEFT,
1528 resMgr->backgroundValue( "OCCViewer", "xy_background", vm->background(OCCViewer_ViewFrame::BOTTOM_LEFT) ) );
1529 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_RIGHT,
1530 resMgr->backgroundValue( "OCCViewer", "background", vm->background(OCCViewer_ViewFrame::MAIN_VIEW) ) );
1532 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1533 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ));
1534 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1535 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1536 vm->enablePreselection( resMgr->booleanValue( "OCCViewer", "enable_preselection", vm->isPreselectionEnabled() ) );
1537 vm->enableSelection( resMgr->booleanValue( "OCCViewer", "enable_selection", vm->isSelectionEnabled() ) );
1539 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1540 new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
1543 #ifndef DISABLE_VTKVIEWER
1544 #ifndef DISABLE_SALOMEOBJECT
1545 if ( vmType == SVTK_Viewer::Type() )
1547 if ( vmType == VTKViewer_Viewer::Type() )
1550 #ifndef DISABLE_SALOMEOBJECT
1551 viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
1552 SVTK_Viewer* vm = dynamic_cast<SVTK_Viewer*>( viewMgr->getViewModel() );
1555 vm->setProjectionMode( resMgr->integerValue( "VTKViewer", "projection_mode", vm->projectionMode() ) );
1556 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1557 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1558 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ) );
1559 vm->setStaticTrihedronVisible( resMgr->booleanValue( "3DViewer", "show_static_trihedron", vm->isStaticTrihedronVisible() ) );
1560 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1561 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1562 vm->setPreSelectionMode(resMgr->integerValue( "VTKViewer", "preselection", vm->preSelectionMode() ) );
1563 vm->enableSelection( resMgr->booleanValue( "VTKViewer", "enable_selection", vm->isSelectionEnabled() ) );
1564 vm->setIncrementalSpeed( resMgr->integerValue( "VTKViewer", "speed_value", vm->incrementalSpeed() ),
1565 resMgr->integerValue( "VTKViewer", "speed_mode", vm->incrementalSpeedMode() ) );
1566 vm->setSpacemouseButtons( resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", vm->spacemouseBtn(1) ),
1567 resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", vm->spacemouseBtn(2) ),
1568 resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", vm->spacemouseBtn(3) ) );
1569 new LightApp_VTKSelector( vm, mySelMgr );
1572 viewMgr = new VTKViewer_ViewManager( activeStudy(), desktop() );
1573 VTKViewer_Viewer* vm = dynamic_cast<VTKViewer_Viewer*>( viewMgr->getViewModel() );
1575 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1583 addViewManager( viewMgr );
1584 SUIT_ViewWindow* viewWin = viewMgr->createViewWindow();
1586 if ( viewWin && desktop() ) {
1587 viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1588 viewWin->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1594 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, QWidget* w )
1596 SUIT_ResourceMgr* resMgr = resourceMgr();
1598 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
1600 new LightApp_WgViewModel( vmType, w ) );
1601 vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
1603 addViewManager( vm );
1604 SUIT_ViewWindow* vw = vm->createViewWindow();
1605 if ( vw && desktop() ) {
1606 vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1607 vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1610 if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
1611 myUserWmTypes << vmType;
1617 SLOT: Removes view manager from application
1619 void LightApp_Application::onCloseView( SUIT_ViewManager* theVM )
1621 removeViewManager( theVM );
1625 Protected SLOT: On study created.
1626 \param theStudy - just created study
1628 void LightApp_Application::onStudyCreated( SUIT_Study* theStudy )
1630 SUIT_DataObject* aRoot = 0;
1631 if ( theStudy && theStudy->root() )
1633 aRoot = theStudy->root();
1634 //aRoot->setName( tr( "DATA_MODELS" ) );
1637 getWindow( WT_ObjectBrowser );
1639 loadDockWindowsState();
1641 if ( objectBrowser() )
1642 objectBrowser()->setRoot( aRoot );
1644 activateModule( defaultModule() );
1646 if ( objectBrowser() )
1647 objectBrowser()->openLevels();
1651 Protected SLOT: On study opened.
1652 \param theStudy - just opened study
1654 void LightApp_Application::onStudyOpened( SUIT_Study* theStudy )
1656 SUIT_DataObject* aRoot = 0;
1657 if ( theStudy && theStudy->root() )
1659 aRoot = theStudy->root();
1663 getWindow( WT_ObjectBrowser );
1665 loadDockWindowsState();
1667 if ( objectBrowser() )
1668 objectBrowser()->setRoot( aRoot );
1670 activateModule( defaultModule() );
1672 if ( objectBrowser() )
1673 objectBrowser()->openLevels();
1678 /*!Protected SLOT. On study saved.*/
1679 void LightApp_Application::onStudySaved( SUIT_Study* s )
1681 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
1683 mru->insert( s->studyName() );
1688 /*!Protected SLOT. On study closed.*/
1689 void LightApp_Application::onStudyClosed( SUIT_Study* s )
1691 // stop auto-save timer
1692 myAutoSaveTimer->stop();
1694 // Bug 10396: clear selection
1695 mySelMgr->clearSelected();
1697 // Bug 12944: emit signal only after clear selection
1700 activateModule( "" );
1703 /*!Protected SLOT.On desktop activated.*/
1704 void LightApp_Application::onDesktopActivated()
1706 CAM_Application::onDesktopActivated();
1707 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>(activeModule());
1709 aModule->studyActivated();
1712 void LightApp_Application::studyOpened( SUIT_Study* s )
1714 CAM_Application::studyOpened( s );
1717 updateViewManagers();
1720 void LightApp_Application::studySaved( SUIT_Study* s )
1722 CAM_Application::studyOpened( s );
1723 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1724 if ( aResMgr && activeStudy() ) {
1725 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
1726 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
1730 void LightApp_Application::studyCreated( SUIT_Study* s )
1732 CAM_Application::studyCreated( s );
1735 updateViewManagers();
1738 /*!Gets file filter.
1739 *\retval QString "(*.bin)"
1741 QString LightApp_Application::getFileFilter() const
1749 Shows file dialog and return user selected file name
1751 QString LightApp_Application::getFileName( bool open, const QString& initial, const QString& filters,
1752 const QString& caption, QWidget* parent )
1756 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1757 return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
1760 /*! Gets directory*/
1761 QString LightApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
1765 return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true );
1768 /*! Get open file names*/
1769 QStringList LightApp_Application::getOpenFileNames( const QString& initial, const QString& filters,
1770 const QString& caption, QWidget* parent )
1774 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1775 return SUIT_FileDlg::getOpenFileNames( parent, initial, fls, caption, true );
1778 /*!Private SLOT. Update object browser.*/
1779 void LightApp_Application::onRefresh()
1781 updateObjectBrowser( true );
1784 /*!Private SLOT. Support drag-and-drop operation.*/
1785 void LightApp_Application::onDropped( const QList<SUIT_DataObject*>& objects, SUIT_DataObject* parent, int row, Qt::DropAction action )
1787 LightApp_DataObject* parentObj = dynamic_cast<LightApp_DataObject*>( parent );
1791 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>( parentObj->module() );
1793 aModule->dropObjects( objects, parentObj, row, action );
1796 /*!Private SLOT. On preferences.*/
1797 void LightApp_Application::onPreferences()
1799 showPreferences( activeModule() ? activeModule()->moduleName() : tr( "PREF_CATEGORY_SALOME" ) );
1802 /*!Private SLOT. On preferences.*/
1803 void LightApp_Application::showPreferences( const QString& itemText )
1805 QApplication::setOverrideCursor( Qt::WaitCursor );
1807 LightApp_PreferencesDlg* prefDlg = new LightApp_PreferencesDlg( preferences( true ), desktop());
1809 QApplication::restoreOverrideCursor();
1814 preferences()->activateItem( itemText );
1816 if ( ( prefDlg->exec() == QDialog::Accepted || prefDlg->isSaved() ) && resourceMgr() )
1819 resourceMgr()->setValue( "desktop", "geometry", desktop()->storeGeometry() );
1820 resourceMgr()->save();
1823 shortcutMgr()->updateShortcuts();
1829 /*!Protected SLOT. On preferences changed.*/
1830 void LightApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param )
1832 LightApp_Module* sMod = 0;
1833 CAM_Module* mod = module( modName );
1834 if ( mod && mod->inherits( "LightApp_Module" ) )
1835 sMod = (LightApp_Module*)mod;
1838 sMod->preferencesChanged( section, param );
1840 preferencesChanged( section, param );
1841 // emit signal to allow additional preferences changing processing
1842 emit preferenceChanged( modName, section, param );
1845 /*!Remove all windows from study.*/
1846 void LightApp_Application::beforeCloseDoc( SUIT_Study* s )
1848 if ( SUIT_DataBrowser* ob = objectBrowser() )
1851 CAM_Application::beforeCloseDoc( s );
1854 /*!Update actions.*/
1855 void LightApp_Application::updateActions()
1857 updateCommandsStatus();
1863 SUIT_Study* LightApp_Application::createNewStudy()
1865 LightApp_Application::lastStudyId++;
1867 LightApp_Study* aStudy = new LightApp_Study( this );
1869 // Set up processing of major study-related events
1870 connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
1871 connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
1872 connect( aStudy, SIGNAL( saved ( SUIT_Study* ) ), this, SLOT( onStudySaved ( SUIT_Study* ) ) );
1873 connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
1879 Creates window by flag.
1880 \param flag - identificator of window type
1882 QWidget* LightApp_Application::createWindow( const int flag )
1886 SUIT_ResourceMgr* resMgr = resourceMgr();
1888 if ( flag == WT_ObjectBrowser )
1890 SUIT_DataBrowser* ob = new SUIT_DataBrowser( new LightApp_DataObject(), desktop() );
1891 ob->setSortMenuEnabled( true );
1892 ob->setAutoUpdate( true );
1893 if ( resMgr->hasValue( "ObjectBrowser", "auto_hide_search_tool" ) )
1894 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
1896 //ob->setAutoOpenLevel( 1 ); // commented by ASV as a fix to bug IPAL10107
1897 ob->setWindowTitle( tr( "OBJECT_BROWSER" ) );
1898 connect( ob, SIGNAL( requestUpdate() ), this, SLOT( onRefresh() ) );
1900 QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
1901 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
1902 treeModel->setSearcher( this );
1903 treeModel->registerColumn( 0, EntryCol, LightApp_DataObject::EntryId );
1904 treeModel->setAppropriate( EntryCol, Qtx::Toggled );
1906 // Mantis issue 0020136: Drag&Drop in OB
1907 SUIT_ProxyModel* proxyModel = dynamic_cast<SUIT_ProxyModel*>(treeModel);
1909 connect( proxyModel, SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
1910 this, SLOT( onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
1913 // temporary commented
1915 OB_ListView* ob_list = dynamic_cast<OB_ListView*>( const_cast<QListView*>( ob->listView() ) );
1917 ob_list->setColumnMaxWidth( 0, desktop()->width()/4 );
1920 // Create OBSelector
1921 new LightApp_OBSelector( ob, mySelMgr );
1923 ob->treeView()->header()->setResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
1924 ob->treeView()->header()->moveSection(SUIT_DataObject::NameId,SUIT_DataObject::VisibilityId);
1925 ob->treeView()->setColumnWidth(SUIT_DataObject::VisibilityId, VISIBILITY_COLUMN_WIDTH);
1926 ob->setProperty( "shortcut", QKeySequence( "Alt+Shift+O" ) );
1928 ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1930 #ifndef DISABLE_PYCONSOLE
1931 else if ( flag == WT_PyConsole )
1933 PyConsole_Console* pyCons = new PyConsole_EnhConsole( desktop(),new LightApp_PyInterp());
1934 pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
1935 pyCons->setFont(resourceMgr()->fontValue( "PyConsole", "font" ));
1936 pyCons->setIsShowBanner(resourceMgr()->booleanValue( "PyConsole", "show_banner", true ));
1937 pyCons->setProperty( "shortcut", QKeySequence( "Alt+Shift+P" ) );
1940 pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1943 else if ( flag == WT_LogWindow )
1945 LogWindow* logWin = new LogWindow( desktop() );
1946 logWin->setWindowTitle( tr( "LOG_WINDOW" ) );
1947 logWin->setProperty( "shortcut", QKeySequence( "Alt+Shift+L" ) );
1949 logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1955 \return default windows( Object Browser, Python Console )
1956 Adds to map \a aMap.
1958 void LightApp_Application::defaultWindows( QMap<int, int>& aMap ) const
1960 aMap.insert( WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1961 #ifndef DISABLE_PYCONSOLE
1962 aMap.insert( WT_PyConsole, Qt::BottomDockWidgetArea );
1964 // aMap.insert( WT_LogWindow, Qt::DockBottom );
1967 /*!Default view managers*/
1968 void LightApp_Application::defaultViewManagers( QStringList& ) const
1974 \return preferences.
1975 Create preferences, if \a crt = true.
1977 LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const
1982 LightApp_Application* that = (LightApp_Application*)this;
1984 bool toCreate = !_prefs_ && crt;
1987 _prefs_ = new LightApp_Preferences( resourceMgr() );
1988 that->createPreferences( _prefs_ );
1991 that->myPrefs = _prefs_;
1993 connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
1994 this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ) );
1999 SUIT_ResourceMgr* resMgr = resourceMgr();
2001 QList<SUIT_Application*> appList = SUIT_Session::session()->applications();
2002 for ( QList<SUIT_Application*>::iterator appIt = appList.begin(); appIt != appList.end(); ++appIt )
2004 LightApp_Application* app = ::qobject_cast<LightApp_Application*>( *appIt );
2008 QStringList modNameList;
2009 app->modules( modNameList, false );
2011 QMap<QString, QString> iconMap;
2012 app->moduleIconNames( iconMap );
2014 for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it )
2016 if ( !app->isLibExists( *it ) || _prefs_->hasModule( *it ) )
2019 int modId = _prefs_->addPreference( *it );
2020 if ( iconMap.contains( *it ) )
2021 _prefs_->setItemIcon( modId, Qtx::scaleIcon( resMgr->loadPixmap( moduleName( *it ), iconMap[*it], false ), 20 ) );
2025 app->modules( modList );
2026 QListIterator<CAM_Module*> itr( modList );
2027 while ( itr.hasNext() )
2029 LightApp_Module* mod = 0;
2031 CAM_Module* anItem = itr.next();
2032 if ( anItem->inherits( "LightApp_Module" ) )
2033 mod = (LightApp_Module*)anItem;
2035 if ( mod && !_prefs_->hasModule( mod->moduleName() ) )
2037 _prefs_->addPreference( mod->moduleName() );
2038 mod->createPreferences();
2039 that->emptyPreferences( mod->moduleName() );
2043 _prefs_->setItemProperty( "info", tr( "PREFERENCES_NOT_LOADED" ) );
2049 Adds new module to application
2051 void LightApp_Application::moduleAdded( CAM_Module* mod )
2053 CAM_Application::moduleAdded( mod );
2055 LightApp_Module* lightMod = 0;
2056 if ( mod && mod->inherits( "LightApp_Module" ) )
2057 lightMod = (LightApp_Module*)mod;
2059 if ( myPrefs && lightMod && !myPrefs->hasModule( lightMod->moduleName() ))
2061 myPrefs->addPreference( mod->moduleName() );
2062 lightMod->createPreferences();
2063 emptyPreferences( mod->moduleName() );
2067 void LightApp_Application::emptyPreferences( const QString& modName )
2069 QtxPreferenceItem* item = myPrefs->findItem( modName, true );
2070 if ( !item || !item->isEmpty() )
2073 // printf( "---------------------> Modify for empty module.\n" );
2075 QtxPagePrefFrameItem* frm = new QtxPagePrefFrameItem( item->title(), item->parentItem() );
2076 frm->setIcon( item->icon() );
2077 frm->setStretch( false );
2078 item->parentItem()->insertItem( frm, item );
2079 new QtxPagePrefLabelItem( Qt::AlignCenter, tr( "PREFERENCES_NOT_SUPPORTED" ).arg( modName ), frm );
2086 void LightApp_Application::createPreferences( LightApp_Preferences* pref )
2091 QStringList aValuesList;
2092 QList<QVariant> anIndicesList;
2096 // . Top-level "SALOME" preferences group <<start>>
2097 int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
2098 pref->setItemIcon( salomeCat, Qtx::scaleIcon( resourceMgr()->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false ), 20 ) );
2100 // .. "General" preferences tab <<start>>
2101 int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat );
2103 // ... "Language" group <<start>>
2104 int langGroup = pref->addPreference( tr( "PREF_GROUP_LANGUAGE" ), genTab );
2105 pref->setItemProperty( "columns", 2, langGroup );
2106 // .... -> application language
2107 int curLang = pref->addPreference( tr( "PREF_CURRENT_LANGUAGE" ), langGroup,
2108 LightApp_Preferences::Selector, "language", "language" );
2109 QStringList aLangs = SUIT_Session::session()->resourceMgr()->stringValue( "language", "languages", "en" ).split( "," );
2110 QList<QVariant> aIcons;
2111 foreach ( QString aLang, aLangs ) {
2112 aIcons << QPixmap( QString( ":/images/%1" ).arg( aLang ) );
2114 pref->setItemProperty( "strings", aLangs, curLang );
2115 pref->setItemProperty( "icons", aIcons, curLang );
2116 // ... "Language" group <<end>>
2118 // ... "Look and feel" group <<start>>
2119 int lookGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), genTab );
2120 pref->setItemProperty( "columns", 2, lookGroup );
2121 // .... -> show splash-screen
2122 pref->addPreference( tr( "PREF_SHOW_SPLASH" ), lookGroup, LightApp_Preferences::Bool, "launch", "splash" );
2123 // .... -> opaque resize
2124 pref->addPreference( tr( "PREF_OPAQUE_RESIZE" ), lookGroup, LightApp_Preferences::Bool, "desktop", "opaque_resize" );
2125 // .... -> drop-down buttons
2126 pref->addPreference( tr( "PREF_DROP_DOWN_BUTTONS" ), lookGroup, LightApp_Preferences::Bool, "viewers", "drop_down_buttons" );
2127 // ... "Look and feel" group <<end>>
2129 // ... "Study properties" group <<start>>
2130 int studyGroup = pref->addPreference( tr( "PREF_GROUP_STUDY" ), genTab );
2131 pref->setItemProperty( "columns", 2, studyGroup );
2132 // .... -> multi-file save
2133 pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "multi_file" );
2134 // .... -> ascii save mode
2135 pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" );
2136 // .... -> store windows geometry
2137 pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" );
2138 pref->addPreference( "", studyGroup, LightApp_Preferences::Space );
2139 pref->addPreference( tr( "PREF_STORE_TOOL_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_tool_positions" );
2140 // .... -> auto-save
2141 int autoSaveInterval = pref->addPreference( tr( "PREF_AUTO_SAVE" ), studyGroup,
2142 LightApp_Preferences::IntSpin, "Study", "auto_save_interval" );
2143 pref->setItemProperty( "min", 0, autoSaveInterval );
2144 pref->setItemProperty( "max", 1440, autoSaveInterval );
2145 pref->setItemProperty( "special", tr( "PREF_AUTO_SAVE_DISABLED" ), autoSaveInterval );
2146 // ... "Study properties" group <<end>>
2148 // ... "Help browser" group <<start>>
2149 int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab, LightApp_Preferences::Auto, "ExternalBrowser", "use_external_browser");
2151 QString platform = "winapplication";
2153 QString platform = "application";
2155 // .... -> browser application
2156 int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, LightApp_Preferences::File, "ExternalBrowser", platform );
2157 pref->setItemProperty( "mode", Qtx::PT_OpenFile, apppref );
2158 // .... -> browser parameters
2159 pref->addPreference( tr( "PREF_PARAM" ), extgroup, LightApp_Preferences::String, "ExternalBrowser", "parameters" );
2160 // ... "Help browser" group <<end>>
2162 // ... "Python console properties" group <<start>>
2163 int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab );
2165 pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, LightApp_Preferences::Font, "PyConsole", "font" );
2166 // .... -> show banner
2167 pref->addPreference( tr( "PREF_SHOW_BANNER" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "show_banner" );
2168 // ... "Python console properties" group <<end>>
2170 // ... "MRU" preferences group <<start>>
2171 int mruGroup = pref->addPreference( tr( "PREF_GROUP_MRU" ), genTab, LightApp_Preferences::Auto, "MRU", "show_mru" );
2172 pref->setItemProperty( "columns", 4, mruGroup );
2173 // number of MRU items
2174 int mruVisCount = pref->addPreference( tr( "PREF_MRU_VISIBLE_COUNT" ), mruGroup, LightApp_Preferences::IntSpin,
2175 "MRU", "visible_count" );
2176 pref->setItemProperty( "min", 0, mruVisCount );
2177 pref->setItemProperty( "max", 100, mruVisCount );
2179 int mruLinkType = pref->addPreference( tr( "PREF_MRU_LINK_TYPE" ), mruGroup, LightApp_Preferences::Selector,
2180 "MRU", "link_type" );
2181 aValuesList.clear();
2182 anIndicesList.clear();
2183 aValuesList << tr("PREF_MRU_LINK_AUTO") << tr("PREF_MRU_LINK_SHORT") << tr("PREF_MRU_LINK_FULL");
2184 anIndicesList << 0 << 1 << 2 ;
2185 pref->setItemProperty( "strings", aValuesList, mruLinkType );
2186 pref->setItemProperty( "indexes", anIndicesList, mruLinkType );
2187 // ... "MRU" preferences group <<end>>
2188 // .. "General" preferences tab <<end>>
2190 // .. "3D viewer" group <<start>>
2191 int Viewer3DGroup = pref->addPreference( tr( "PREF_GROUP_3DVIEWER" ), salomeCat );
2192 // ... -> navigation mode
2193 int vtkStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), Viewer3DGroup,
2194 LightApp_Preferences::Selector, "3DViewer", "navigation_mode" );
2195 aValuesList.clear();
2196 anIndicesList.clear();
2197 aValuesList << tr("PREF_STANDARD_STYLE") << tr("PREF_KEYFREE_STYLE");
2198 anIndicesList << 0 << 1;
2199 pref->setItemProperty( "strings", aValuesList, vtkStyleMode );
2200 pref->setItemProperty( "indexes", anIndicesList, vtkStyleMode );
2201 // ... -> zooming mode
2202 #if OCC_VERSION_LARGE > 0x0603000A // available only with OCC-6.3-sp11 and higher version
2203 int occZoomingStyleMode = pref->addPreference( tr( "PREF_ZOOMING" ), Viewer3DGroup,
2204 LightApp_Preferences::Selector, "3DViewer", "zooming_mode" );
2205 aValuesList.clear();
2206 anIndicesList.clear();
2207 aValuesList << tr("PREF_ZOOMING_AT_CENTER") << tr("PREF_ZOOMING_AT_CURSOR");
2208 anIndicesList << 0 << 1;
2209 pref->setItemProperty( "strings", aValuesList, occZoomingStyleMode );
2210 pref->setItemProperty( "indexes", anIndicesList, occZoomingStyleMode );
2212 // ... "Trihedron" group <<start>>
2213 int occTriGroup = pref->addPreference( tr( "PREF_TRIHEDRON" ), Viewer3DGroup );
2214 pref->setItemProperty( "columns", 2, occTriGroup );
2215 // .... -> trihedron size
2216 int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occTriGroup,
2217 LightApp_Preferences::DblSpin, "3DViewer", "trihedron_size" );
2218 pref->setItemProperty( "min", 1.0E-06, occTS );
2219 pref->setItemProperty( "max", 1000, occTS );
2220 // .... -> relative size of trihedron
2221 pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "relative_size" );
2222 // .... -> show static trihedron
2223 pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "show_static_trihedron" );
2224 // ... "Trihedron" group <<end>>
2225 // .. "3D viewer" group <<end>>
2229 #ifndef DISABLE_OCCVIEWER
2230 // .. "OCC viewer" group <<start>>
2231 int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), salomeCat );
2233 // ... "Background" group <<start>>
2234 int bgGroup = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup );
2235 // pref->setItemProperty( "columns", 2, bgGroup );
2236 aValuesList.clear();
2237 anIndicesList.clear();
2239 formats = OCCViewer_Viewer::backgroundData( aValuesList, idList, txtList );
2240 foreach( int gid, idList ) anIndicesList << gid;
2241 // .... -> 3D viewer background
2242 bgId = pref->addPreference( tr( "PREF_3DVIEWER_BACKGROUND" ), bgGroup,
2243 LightApp_Preferences::Background, "OCCViewer", "background" );
2244 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2245 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2246 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2247 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2248 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2249 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2250 pref->setItemProperty( "custom_enabled", false, bgId );
2251 pref->setItemProperty( "image_formats", formats, bgId );
2252 // .... -> XZ viewer background
2253 bgId = pref->addPreference( tr( "PREF_XZVIEWER_BACKGROUND" ), bgGroup,
2254 LightApp_Preferences::Background, "OCCViewer", "xz_background" );
2255 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2256 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2257 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2258 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2259 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2260 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2261 pref->setItemProperty( "custom_enabled", false, bgId );
2262 pref->setItemProperty( "image_formats", formats, bgId );
2263 // .... -> YZ viewer background
2264 bgId = pref->addPreference( tr( "PREF_YZVIEWER_BACKGROUND" ), bgGroup,
2265 LightApp_Preferences::Background, "OCCViewer", "yz_background" );
2266 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2267 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2268 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2269 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2270 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2271 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2272 pref->setItemProperty( "custom_enabled", false, bgId );
2273 pref->setItemProperty( "image_formats", formats, bgId );
2274 // .... -> XY viewer background
2275 bgId = pref->addPreference( tr( "PREF_XYVIEWER_BACKGROUND" ), bgGroup,
2276 LightApp_Preferences::Background, "OCCViewer", "xy_background" );
2277 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2278 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2279 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2280 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2281 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2282 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2283 pref->setItemProperty( "custom_enabled", false, bgId );
2284 pref->setItemProperty( "image_formats", formats, bgId );
2285 // ... "Background" group <<end>>
2288 // ... "Selection" group <<start>>
2289 int occSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), occGroup );
2290 pref->setItemProperty( "columns", 2, occSelectionGroup );
2291 // .... -> enable preselection
2292 pref->addPreference( tr( "PREF_ENABLE_PRESELECTION" ), occSelectionGroup,
2293 LightApp_Preferences::Bool, "OCCViewer", "enable_preselection" );
2294 // .... -> enable selection
2295 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), occSelectionGroup,
2296 LightApp_Preferences::Bool, "OCCViewer", "enable_selection" );
2297 // ... "Selection" group <<end>>
2299 // ... -> empty frame (for layout) <<start>>
2300 int occGen = pref->addPreference( "", occGroup, LightApp_Preferences::Frame );
2301 pref->setItemProperty( "margin", 0, occGen );
2302 pref->setItemProperty( "columns", 2, occGen );
2303 // ... -> empty frame (for layout) <<end>>
2304 // .. "OCC viewer" group <<end>>
2307 #ifndef DISABLE_VTKVIEWER
2308 // .. "VTK viewer" group <<start>>
2309 int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), salomeCat ); //viewTab
2311 // ... -> empty frame (for layout) <<start>>
2312 int vtkGen = pref->addPreference( "", vtkGroup, LightApp_Preferences::Frame );
2313 //pref->setItemProperty( "columns", 2, vtkGen );
2314 // .... -> projection mode
2315 int vtkProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), vtkGen,
2316 LightApp_Preferences::Selector, "VTKViewer", "projection_mode" );
2317 aValuesList.clear();
2318 anIndicesList.clear();
2319 aValuesList << tr("PREF_ORTHOGRAPHIC") << tr("PREF_PERSPECTIVE");
2320 anIndicesList << 0 << 1;
2321 pref->setItemProperty( "strings", aValuesList, vtkProjMode );
2322 pref->setItemProperty( "indexes", anIndicesList, vtkProjMode );
2323 // .... -> background
2324 aValuesList.clear();
2325 anIndicesList.clear();
2327 #ifndef DISABLE_SALOMEOBJECT
2328 formats = SVTK_Viewer::backgroundData( aValuesList, idList, txtList );
2330 foreach( int gid, idList ) anIndicesList << gid;
2331 bgId = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGen,
2332 LightApp_Preferences::Background, "VTKViewer", "background" );
2333 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2334 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2335 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2336 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2337 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2338 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2339 pref->setItemProperty( "custom_enabled", false, bgId );
2340 #ifndef DISABLE_SALOMEOBJECT
2341 pref->setItemProperty( "image_formats", formats, bgId );
2343 // .... -> speed increment
2344 int vtkSpeed = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED" ), vtkGen,
2345 LightApp_Preferences::IntSpin, "VTKViewer", "speed_value" );
2346 pref->setItemProperty( "min", 1, vtkSpeed );
2347 pref->setItemProperty( "max", 1000, vtkSpeed );
2348 // .... -> speed mode
2349 int vtkSpeedMode = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED_MODE" ), vtkGen,
2350 LightApp_Preferences::Selector, "VTKViewer", "speed_mode" );
2351 aValuesList.clear();
2352 anIndicesList.clear();
2353 aValuesList << tr("PREF_ARITHMETIC") << tr("PREF_GEOMETRICAL");
2354 anIndicesList << 0 << 1;
2355 pref->setItemProperty( "strings", aValuesList, vtkSpeedMode );
2356 pref->setItemProperty( "indexes", anIndicesList, vtkSpeedMode );
2358 // ... "Selection" group <<start>>
2359 int vtkSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), vtkGroup );
2360 pref->setItemProperty( "columns", 2, vtkSelectionGroup );
2361 // .... -> preselection
2362 int vtkPreselection = pref->addPreference( tr( "PREF_PRESELECTION" ), vtkSelectionGroup,
2363 LightApp_Preferences::Selector, "VTKViewer", "preselection" );
2364 aValuesList.clear();
2365 anIndicesList.clear();
2366 aValuesList << tr("PREF_PRESELECTION_STANDARD") << tr("PREF_PRESELECTION_DYNAMIC") << tr("PREF_PRESELECTION_DISABLED");
2367 anIndicesList << 0 << 1 << 2;
2368 pref->setItemProperty( "strings", aValuesList, vtkPreselection );
2369 pref->setItemProperty( "indexes", anIndicesList, vtkPreselection );
2370 // .... -> enable selection
2371 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), vtkSelectionGroup, LightApp_Preferences::Bool, "VTKViewer", "enable_selection" );
2372 // ... "Selection" group <<end>>
2374 // ... -> empty frame (for layout) <<end>>
2376 // ... space mouse sub-group <<start>>
2377 int vtkSM = pref->addPreference( tr( "PREF_FRAME_SPACEMOUSE" ), vtkGroup, LightApp_Preferences::GroupBox );
2378 //pref->setItemProperty( "columns", 2, vtkSM );
2379 // .... -> decrease speed increment
2380 int spacemousePref1 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_1" ), vtkSM,
2381 LightApp_Preferences::Selector, "VTKViewer",
2382 "spacemouse_func1_btn" );
2383 // .... -> increase speed increment
2384 int spacemousePref2 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_2" ), vtkSM,
2385 LightApp_Preferences::Selector, "VTKViewer",
2386 "spacemouse_func2_btn" );
2387 // .... -> dominant / combined switch
2388 int spacemousePref3 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_3" ), vtkSM,
2389 LightApp_Preferences::Selector, "VTKViewer",
2390 "spacemouse_func5_btn" ); //
2391 aValuesList.clear();
2392 anIndicesList.clear();
2393 aValuesList << tr( "PREF_SPACEMOUSE_BTN_1" ) << tr( "PREF_SPACEMOUSE_BTN_2" ) << tr( "PREF_SPACEMOUSE_BTN_3" );
2394 aValuesList << tr( "PREF_SPACEMOUSE_BTN_4" ) << tr( "PREF_SPACEMOUSE_BTN_5" ) << tr( "PREF_SPACEMOUSE_BTN_6" );
2395 aValuesList << tr( "PREF_SPACEMOUSE_BTN_7" ) << tr( "PREF_SPACEMOUSE_BTN_8" ) << tr( "PREF_SPACEMOUSE_BTN_*" );
2396 aValuesList << tr( "PREF_SPACEMOUSE_BTN_10" ) << tr( "PREF_SPACEMOUSE_BTN_11" );
2397 anIndicesList << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11;
2398 pref->setItemProperty( "strings", aValuesList, spacemousePref1 );
2399 pref->setItemProperty( "indexes", anIndicesList, spacemousePref1 );
2400 pref->setItemProperty( "strings", aValuesList, spacemousePref2 );
2401 pref->setItemProperty( "indexes", anIndicesList, spacemousePref2 );
2402 pref->setItemProperty( "strings", aValuesList, spacemousePref3 );
2403 pref->setItemProperty( "indexes", anIndicesList, spacemousePref3 );
2404 // ... space mouse sub-group <<end>>
2406 // ... avi recording sub-group <<start>>
2407 int vtkRec = pref->addPreference( tr( "PREF_FRAME_RECORDING" ), vtkGroup, LightApp_Preferences::GroupBox );
2408 pref->setItemProperty( "columns", 2, vtkRec );
2409 // .... -> recording mode
2410 int modePref = pref->addPreference( tr( "PREF_RECORDING_MODE" ), vtkRec,
2411 LightApp_Preferences::Selector, "VTKViewer", "recorder_mode" );
2412 aValuesList.clear();
2413 anIndicesList.clear();
2414 aValuesList << tr( "PREF_SKIPPED_FRAMES" ) << tr( "PREF_ALL_DISLPAYED_FRAMES" );
2415 anIndicesList << 0 << 1;
2416 pref->setItemProperty( "strings", aValuesList, modePref );
2417 pref->setItemProperty( "indexes", anIndicesList, modePref );
2419 int fpsPref = pref->addPreference( tr( "PREF_FPS" ), vtkRec,
2420 LightApp_Preferences::DblSpin, "VTKViewer", "recorder_fps" );
2421 pref->setItemProperty( "min", 0.1, fpsPref );
2422 pref->setItemProperty( "max", 100, fpsPref );
2424 int qualityPref = pref->addPreference( tr( "PREF_QUALITY" ), vtkRec,
2425 LightApp_Preferences::IntSpin, "VTKViewer", "recorder_quality" );
2426 pref->setItemProperty( "min", 1, qualityPref );
2427 pref->setItemProperty( "max", 100, qualityPref );
2428 // .... -> progressive mode
2429 pref->addPreference( tr( "PREF_PROGRESSIVE" ), vtkRec,
2430 LightApp_Preferences::Bool, "VTKViewer", "recorder_progressive" );
2431 // ... avi recording sub-group <<end>>
2433 // ... group names sub-group <<start>>
2434 int vtkGN = pref->addPreference( tr( "PREF_FRAME_GROUP_NAMES" ), vtkGroup,
2435 LightApp_Preferences::GroupBox, "VTKViewer", "show_group_names" );
2436 pref->setItemProperty( "columns", 2, vtkGN );
2437 // .... -> text color
2438 pref->addPreference( tr( "PREF_GROUP_NAMES_TEXT_COLOR" ), vtkGN,
2439 LightApp_Preferences::Color, "VTKViewer", "group_names_text_color" );
2440 // .... -> transparency
2441 int transPref = pref->addPreference( tr( "PREF_GROUP_NAMES_TRANSPARENCY" ), vtkGN,
2442 LightApp_Preferences::DblSpin, "VTKViewer", "group_names_transparency" );
2443 pref->setItemProperty( "min", 0.0, transPref );
2444 pref->setItemProperty( "max", 1.0, transPref );
2445 pref->setItemProperty( "step", 0.1, transPref );
2446 // ... -> group names sub-group <<end>>
2447 // .. "VTK viewer" group <<end>>
2450 // .. "Plot2d viewer" group <<start>>
2451 int plot2dGroup = pref->addPreference( tr( "PREF_GROUP_PLOT2DVIEWER" ), salomeCat ); //viewTab
2452 //pref->setItemProperty( "columns", 2, plot2dGroup );
2454 // ... -> background
2455 pref->addPreference( tr( "PREF_VIEWER_BACKGROUND_COLOR" ), plot2dGroup,
2456 LightApp_Preferences::Color, "Plot2d", "Background" );
2457 // ... -> selection color
2458 pref->addPreference( tr( "PREF_VIEWER_SELECTION" ), plot2dGroup,
2459 LightApp_Preferences::Color, "Plot2d", "SelectionColor" );
2461 // ... "Viewer" group <<start>>
2462 int plot2dViewerGroup = pref->addPreference( tr( "PREF_GROUP_VIEWER" ), plot2dGroup );
2464 // .... -> curve type
2465 int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dViewerGroup,
2466 LightApp_Preferences::Selector, "Plot2d", "CurveType" );
2467 aValuesList.clear();
2468 anIndicesList.clear();
2469 aValuesList << tr("PREF_POINTS") << tr("PREF_LINES") << tr("PREF_SPLINE");
2470 anIndicesList << 0 << 1 << 2 ;
2471 pref->setItemProperty( "strings", aValuesList, curveType );
2472 pref->setItemProperty( "indexes", anIndicesList, curveType );
2473 // .... -> marker size
2474 int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dViewerGroup,
2475 LightApp_Preferences::IntSpin, "Plot2d", "MarkerSize" );
2476 pref->setItemProperty( "min", 0, markerSize );
2477 pref->setItemProperty( "max", 100, markerSize );
2478 // .... -> horizontal scaling mode
2479 int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dViewerGroup,
2480 LightApp_Preferences::Selector, "Plot2d", "HorScaleMode" );
2481 aValuesList.clear();
2482 anIndicesList.clear();
2483 aValuesList << tr("PREF_LINEAR") << tr("PREF_LOGARITHMIC");
2484 anIndicesList << 0 << 1 ;
2485 pref->setItemProperty( "strings", aValuesList, horScale );
2486 pref->setItemProperty( "indexes", anIndicesList, horScale );
2487 // .... -> vertical scaling mode
2488 int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dViewerGroup,
2489 LightApp_Preferences::Selector, "Plot2d", "VerScaleMode" );
2490 pref->setItemProperty( "strings", aValuesList, verScale );
2491 pref->setItemProperty( "indexes", anIndicesList, verScale );
2493 // .... -> errors/deviation colot
2494 pref->addPreference( tr( "PREF_DEVIATION_COLOR" ), plot2dViewerGroup,
2495 LightApp_Preferences::Color, "Plot2d", "DeviationMarkerColor" );
2496 // .... -> deviation markers line size
2497 int deviationMarkerLw = pref->addPreference( tr( "PREF_DEVIATION_MARKER_LW" ), plot2dViewerGroup,
2498 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerLineWidth" );
2499 pref->setItemProperty( "min", 1, deviationMarkerLw );
2500 pref->setItemProperty( "max", 5, deviationMarkerLw );
2501 // .... -> deviation markers tick mark size
2502 int deviationMarkerTs = pref->addPreference( tr( "PREF_DEVIATION_MARKER_TS" ), plot2dViewerGroup,
2503 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerTickSize" );
2504 pref->setItemProperty( "min", 1, deviationMarkerTs );
2505 pref->setItemProperty( "max", 5, deviationMarkerTs );
2506 // .... "Viewer" group <<end>>
2508 // ... "Legend" group <<start>>
2509 int plot2dLegendGroup = pref->addPreference( tr( "PREF_GROUP_LEGEND" ), plot2dGroup );
2511 // .... -> show legend
2512 pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dLegendGroup,
2513 LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
2514 // .... -> legend position
2515 int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dLegendGroup,
2516 LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
2517 aValuesList.clear();
2518 anIndicesList.clear();
2519 aValuesList << tr("PREF_LEFT") << tr("PREF_RIGHT") << tr("PREF_TOP") << tr("PREF_BOTTOM");
2520 anIndicesList << 0 << 1 << 2 << 3 ;
2521 pref->setItemProperty( "strings", aValuesList, legendPosition );
2522 pref->setItemProperty( "indexes", anIndicesList, legendPosition );
2523 // .... -> Symbol type
2524 int legendSymbolType = pref->addPreference( tr( "PREF_LEGEND_SYMBOL_TYPE" ), plot2dLegendGroup,
2525 LightApp_Preferences::Selector, "Plot2d", "LegendSymbolType" );
2526 aValuesList.clear();
2527 anIndicesList.clear();
2528 aValuesList << tr("PREF_MARKER_ON_LINE") << tr("PREF_MARKER_ABOVE_LINE");
2529 anIndicesList << 0 << 1 ;
2530 pref->setItemProperty( "strings", aValuesList, legendSymbolType );
2531 pref->setItemProperty( "indexes", anIndicesList, legendSymbolType );
2532 // .... -> legend font
2533 pref->addPreference( tr( "PREF_LEGEND_FONT" ), plot2dLegendGroup, LightApp_Preferences::Font, "Plot2d", "LegendFont" );
2534 // ... -> font color
2535 pref->addPreference( tr( "PREF_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "LegendFontColor" );
2536 // ... -> selection font color
2537 pref->addPreference( tr( "PREF_SELECTED_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "SelectedLegendFontColor" );
2538 // ... "Legend" group <<end>>
2540 // .. "Plot2d viewer" group <<end>>
2542 // .. "Directories" preferences tab <<start>>
2543 int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat );
2544 // ... --> quick directories list
2545 int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab );
2546 pref->addPreference( tr( "" ), dirGroup,
2547 LightApp_Preferences::DirList, "FileDlg", "QuickDirList" );
2548 // .. "Directories" preferences tab <<end>>
2550 // .. "Object browser" preferences tab <<start>>
2551 int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
2553 // ... "Search tool" group <<start>>
2554 int stGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SEARCH_TOOL" ), obTab );
2555 // .... --> auto-hide
2556 pref->addPreference( tr( "PREF_AUTO_HIDE_SEARCH_TOOL" ), stGroup, LightApp_Preferences::Bool,
2557 "ObjectBrowser", "auto_hide_search_tool" );
2558 // ... "Search tool" group <<end>>
2560 // ... "Object browser settings" group <<start>>
2561 int objSetGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), obTab );
2562 pref->setItemProperty( "columns", 2, objSetGroup );
2563 // .... -> auto size first column
2564 pref->addPreference( tr( "PREF_AUTO_SIZE_FIRST" ), objSetGroup, LightApp_Preferences::Bool,
2565 "ObjectBrowser", "auto_size_first" );
2566 // .... -> auto size other columns
2567 pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool,
2568 "ObjectBrowser", "auto_size" );
2569 // .... -> resize columns on expand item
2570 pref->addPreference( tr( "PREF_RESIZE_ON_EXPAND_ITEM" ), objSetGroup, LightApp_Preferences::Bool,
2571 "ObjectBrowser", "resize_on_expand_item" );
2572 // .... -> browse to published object
2573 int browsePublished = pref->addPreference( tr( "PREF_BROWSE_TO_THE_PUBLISHED_OBJECT" ), objSetGroup, LightApp_Preferences::Selector,
2574 "ObjectBrowser", "browse_published_object" );
2575 aValuesList.clear();
2576 anIndicesList.clear();
2577 aValuesList << tr( "PREF_BROWSE_NEVER" ) << tr( "PREF_BROWSE_AFTER_APPLY_AND_CLOSE_ONLY" ) << tr( "PREF_BROWSE_ALWAYS" );
2578 anIndicesList << BP_Never << BP_ApplyAndClose << BP_Always;
2579 pref->setItemProperty( "strings", aValuesList, browsePublished );
2580 pref->setItemProperty( "indexes", anIndicesList, browsePublished );
2581 // ... "Object browser settings" group <<end>>
2582 // .. "Object browser" preferences tab <<end>>
2584 // .. "Shortcuts" preferences tab <<start>>
2585 int shortcutTab = pref->addPreference( tr( "PREF_TAB_SHORTCUTS" ), salomeCat );
2586 // ... "Shortcuts settings" group <<start>>
2587 int shortcutGroup = pref->addPreference( tr( "PREF_GROUP_SHORTCUTS" ), shortcutTab );
2588 pref->addPreference( tr( "" ), shortcutGroup,
2589 LightApp_Preferences::ShortcutTree, "shortcuts" );
2590 // ... "Shortcuts settings" group <<end>>
2591 // .. "Shortcuts" preferences tab <<end>>
2592 // . Top-level "SALOME" preferences group <<end>>
2598 Changes appearance of application according to changed preferences
2599 \param sec - section
2600 \param param - name of changed parameter
2602 void LightApp_Application::preferencesChanged( const QString& sec, const QString& param )
2604 SUIT_ResourceMgr* resMgr = resourceMgr();
2608 if ( sec == "viewers" && param == "drop_down_buttons" )
2610 ViewManagerList vmlist = viewManagers();
2611 foreach( SUIT_ViewManager* vm, vmlist )
2613 QVector<SUIT_ViewWindow*> vwlist = vm->getViews();
2614 foreach( SUIT_ViewWindow* vw, vwlist )
2615 if ( vw ) vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
2619 if ( sec == QString( "3DViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )))
2621 double sz = resMgr->doubleValue( sec, "trihedron_size", -1 );
2622 bool relative = resMgr->booleanValue( sec, "relative_size", true );
2623 QList<SUIT_ViewManager*> lst;
2624 #ifndef DISABLE_OCCVIEWER
2625 viewManagers( OCCViewer_Viewer::Type(), lst );
2626 QListIterator<SUIT_ViewManager*> itOCC( lst );
2627 while ( itOCC.hasNext() && sz >= 0 )
2629 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2630 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2633 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2634 occVM->setTrihedronSize( sz, relative );
2635 occVM->getAISContext()->UpdateCurrentViewer();
2638 #ifndef DISABLE_VTKVIEWER
2639 #ifndef DISABLE_SALOMEOBJECT
2640 viewManagers( SVTK_Viewer::Type(), lst );
2641 QListIterator<SUIT_ViewManager*> itVTK( lst );
2642 while ( itVTK.hasNext() && sz >= 0 )
2644 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2645 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2648 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2651 vtkVM->setTrihedronSize( sz, relative );
2659 if ( sec == QString( "3DViewer" ) && param == QString( "show_static_trihedron" ) )
2661 bool isVisible = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
2662 QList<SUIT_ViewManager*> lst;
2663 #ifndef DISABLE_OCCVIEWER
2664 viewManagers( OCCViewer_Viewer::Type(), lst );
2665 QListIterator<SUIT_ViewManager*> itOCC( lst );
2666 while ( itOCC.hasNext() )
2668 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2669 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2672 OCCViewer_Viewer* occVM = dynamic_cast<OCCViewer_Viewer*>( vm );
2675 occVM->setStaticTrihedronDisplayed( isVisible );
2679 #ifndef DISABLE_VTKVIEWER
2680 #ifndef DISABLE_SALOMEOBJECT
2681 viewManagers( SVTK_Viewer::Type(), lst );
2682 QListIterator<SUIT_ViewManager*> itVTK( lst );
2683 while ( itVTK.hasNext() )
2685 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2686 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2689 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2692 vtkVM->setStaticTrihedronVisible( isVisible );
2700 if ( sec == QString( "3DViewer" ) && param == QString( "navigation_mode" ) )
2702 int mode = resMgr->integerValue( "3DViewer", "navigation_mode", 0 );
2703 QList<SUIT_ViewManager*> lst;
2704 #ifndef DISABLE_OCCVIEWER
2705 viewManagers( OCCViewer_Viewer::Type(), lst );
2706 QListIterator<SUIT_ViewManager*> itOCC( lst );
2707 while ( itOCC.hasNext() )
2709 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2710 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2713 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2714 occVM->setInteractionStyle( mode );
2717 #ifndef DISABLE_VTKVIEWER
2718 #ifndef DISABLE_SALOMEOBJECT
2719 viewManagers( SVTK_Viewer::Type(), lst );
2720 QListIterator<SUIT_ViewManager*> itVTK( lst );
2721 while ( itVTK.hasNext() )
2723 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2724 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2727 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2728 if( vtkVM ) vtkVM->setInteractionStyle( mode );
2734 #ifndef DISABLE_OCCVIEWER
2735 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_preselection" ) )
2737 bool isToEnablePreselection = resMgr->booleanValue( "OCCViewer", "enable_preselection", true );
2738 QList<SUIT_ViewManager*> lst;
2739 viewManagers( OCCViewer_Viewer::Type(), lst );
2740 QListIterator<SUIT_ViewManager*> it( lst );
2741 while ( it.hasNext() )
2743 SUIT_ViewModel* vm = it.next()->getViewModel();
2744 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2747 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2748 occVM->enablePreselection( isToEnablePreselection );
2753 #ifndef DISABLE_OCCVIEWER
2754 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_selection" ) )
2756 bool isToEnableSelection = resMgr->booleanValue( "OCCViewer", "enable_selection", true );
2757 QList<SUIT_ViewManager*> lst;
2758 viewManagers( OCCViewer_Viewer::Type(), lst );
2759 QListIterator<SUIT_ViewManager*> it( lst );
2760 while ( it.hasNext() )
2762 SUIT_ViewModel* vm = it.next()->getViewModel();
2763 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2766 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2767 occVM->enableSelection( isToEnableSelection );
2772 if ( sec == QString( "3DViewer" ) && param == QString( "zooming_mode" ) )
2774 int mode = resMgr->integerValue( "3DViewer", "zooming_mode", 0 );
2775 QList<SUIT_ViewManager*> lst;
2776 #ifndef DISABLE_OCCVIEWER
2777 viewManagers( OCCViewer_Viewer::Type(), lst );
2778 QListIterator<SUIT_ViewManager*> itOCC( lst );
2779 while ( itOCC.hasNext() )
2781 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2782 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2785 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2786 occVM->setZoomingStyle( mode );
2789 #ifndef DISABLE_VTKVIEWER
2790 #ifndef DISABLE_SALOMEOBJECT
2791 viewManagers( SVTK_Viewer::Type(), lst );
2792 QListIterator<SUIT_ViewManager*> itVTK( lst );
2793 while ( itVTK.hasNext() )
2795 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2796 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2799 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2800 if( vtkVM ) vtkVM->setZoomingStyle( mode );
2806 #ifndef DISABLE_VTKVIEWER
2807 if ( sec == QString( "VTKViewer" ) && (param == QString( "speed_value" ) || param == QString( "speed_mode" )) )
2809 int speed = resMgr->integerValue( "VTKViewer", "speed_value", 10 );
2810 int mode = resMgr->integerValue( "VTKViewer", "speed_mode", 0 );
2811 QList<SUIT_ViewManager*> lst;
2812 #ifndef DISABLE_SALOMEOBJECT
2813 viewManagers( SVTK_Viewer::Type(), lst );
2814 QListIterator<SUIT_ViewManager*> it( lst );
2815 while ( it.hasNext() )
2817 SUIT_ViewModel* vm = it.next()->getViewModel();
2818 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2821 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2822 if( vtkVM ) vtkVM->setIncrementalSpeed( speed, mode );
2828 #ifndef DISABLE_VTKVIEWER
2829 if ( sec == QString( "VTKViewer" ) && param == QString( "projection_mode" ) )
2831 int mode = resMgr->integerValue( "VTKViewer", "projection_mode", 0 );
2832 QList<SUIT_ViewManager*> lst;
2833 #ifndef DISABLE_SALOMEOBJECT
2834 viewManagers( SVTK_Viewer::Type(), lst );
2835 QListIterator<SUIT_ViewManager*> it( lst );
2836 while ( it.hasNext() )
2838 SUIT_ViewModel* vm = it.next()->getViewModel();
2839 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2842 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2843 if( vtkVM ) vtkVM->setProjectionMode( mode );
2849 #ifndef DISABLE_VTKVIEWER
2850 if ( sec == QString( "VTKViewer" ) && param == QString( "preselection" ) )
2852 int mode = resMgr->integerValue( "VTKViewer", "preselection", 0 );
2853 QList<SUIT_ViewManager*> lst;
2854 #ifndef DISABLE_SALOMEOBJECT
2855 viewManagers( SVTK_Viewer::Type(), lst );
2856 QListIterator<SUIT_ViewManager*> it( lst );
2857 while ( it.hasNext() )
2859 SUIT_ViewModel* vm = it.next()->getViewModel();
2860 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2863 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2864 if( vtkVM ) vtkVM->setPreSelectionMode( mode );
2870 #ifndef DISABLE_VTKVIEWER
2871 if ( sec == QString( "VTKViewer" ) && param == QString( "enable_selection" ) )
2873 bool isToEnableSelection = resMgr->booleanValue( "VTKViewer", "enable_selection", true );
2874 QList<SUIT_ViewManager*> lst;
2875 #ifndef DISABLE_SALOMEOBJECT
2876 viewManagers( SVTK_Viewer::Type(), lst );
2877 QListIterator<SUIT_ViewManager*> it( lst );
2878 while ( it.hasNext() )
2880 SUIT_ViewModel* vm = it.next()->getViewModel();
2881 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2884 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2885 if( vtkVM ) vtkVM->enableSelection( isToEnableSelection );
2891 #ifndef DISABLE_VTKVIEWER
2892 if ( sec == QString( "VTKViewer" ) && (param == QString( "spacemouse_func1_btn" ) ||
2893 param == QString( "spacemouse_func2_btn" ) ||
2894 param == QString( "spacemouse_func5_btn" ) ) )
2896 int btn1 = resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", 1 );
2897 int btn2 = resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", 2 );
2898 int btn3 = resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", 9 );
2899 QList<SUIT_ViewManager*> lst;
2900 #ifndef DISABLE_SALOMEOBJECT
2901 viewManagers( SVTK_Viewer::Type(), lst );
2902 QListIterator<SUIT_ViewManager*> it( lst );
2903 while ( it.hasNext() )
2905 SUIT_ViewModel* vm = it.next()->getViewModel();
2906 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2909 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2910 if( vtkVM ) vtkVM->setSpacemouseButtons( btn1, btn2, btn3 );
2915 if( sec=="ObjectBrowser" )
2917 SUIT_DataBrowser* ob = objectBrowser();
2921 if ( param=="auto_size_first" )
2923 bool autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
2924 ob->setAutoSizeFirstColumn( autoSizeFirst );
2925 if ( autoSizeFirst )
2926 ob->adjustFirstColumnWidth();
2928 else if ( param=="auto_size" ) {
2929 bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
2930 ob->setAutoSizeColumns(autoSize);
2932 ob->adjustColumnsWidth();
2934 else if ( param=="resize_on_expand_item" ) {
2935 bool resizeOnExpandItem = resMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
2936 ob->setResizeOnExpandItem(resizeOnExpandItem);
2938 else if ( param == "auto_hide_search_tool" ) {
2939 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
2945 if( param=="auto_save_interval" ) {
2946 myAutoSaveTimer->stop();
2947 int autoSaveInterval = resMgr->integerValue( "Study", "auto_save_interval", 0 );
2948 if ( activeStudy() && autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
2952 #ifndef DISABLE_PYCONSOLE
2953 if( sec=="PyConsole" && pythonConsole() )
2955 if ( param=="font" ) {
2956 pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) );
2958 else if ( param=="show_banner" ) {
2959 pythonConsole()->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
2966 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
2968 if ( param == "visible_count" )
2969 mru->setVisibleCount( resMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
2970 else if ( param == "max_count" )
2971 mru->setHistoryCount( resMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
2972 else if ( param == "insert_mode" )
2973 mru->setInsertMode( resMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
2974 else if ( param == "link_type" )
2975 mru->setLinkType( resMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
2976 else if ( param == "show_clear" )
2977 mru->setClearPossible( resMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
2978 else if ( param == "show_mru" )
2979 mru->setVisible( resMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
2982 if ( sec == "language" && param == "language" )
2984 SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LANG_CHANGED" ) );
2986 if ( sec == "desktop" && param == "opaque_resize" ) {
2987 bool opaqueResize = resMgr->booleanValue( "desktop", "opaque_resize", false );
2988 QMainWindow::DockOptions dopts = desktop()->dockOptions();
2989 if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
2990 else dopts &= ~QMainWindow::AnimatedDocks;
2991 desktop()->setDockOptions( dopts );
2992 desktop()->setOpaqueResize( opaqueResize );
2993 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
2994 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
2997 if ( sec == "ExternalBrowser" && param == "use_external_browser" ) {
2998 if ( resMgr->booleanValue("ExternalBrowser", "use_external_browser", false ) )
3000 QtxWebBrowser::shutdown();
3004 #ifndef DISABLE_PLOT2DVIEWER
3005 QList<SUIT_ViewManager*> lst;
3006 viewManagers( Plot2d_Viewer::Type(), lst );
3007 QListIterator<SUIT_ViewManager*> itPlot2d( lst );
3008 while ( itPlot2d.hasNext() ) {
3009 SUIT_ViewManager* viewMgr = itPlot2d.next();
3010 SUIT_ViewModel* vm = viewMgr->getViewModel();
3011 if ( !vm || !vm->inherits( "Plot2d_Viewer" ) )
3014 Plot2d_Viewer* Plot2dVM = dynamic_cast<Plot2d_Viewer*>( vm );
3016 viewMgr->setViewModel( vm );
3017 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
3019 Plot2d_ViewFrame* frame = wnd->getViewFrame();
3020 frame->SetPreference();
3029 void LightApp_Application::loadPreferences()
3031 CAM_Application::loadPreferences();
3033 SUIT_ResourceMgr* aResMgr = resourceMgr();
3038 static bool mru_load = true;
3041 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3043 mru->setVisible( aResMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
3044 mru->setVisibleCount( aResMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
3045 mru->setHistoryCount( aResMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
3046 mru->setInsertMode( aResMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
3047 mru->setLinkType( aResMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
3048 mru->setClearPossible( aResMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
3049 mru->loadLinks( aResMgr, "MRU" );
3055 QStringList mods = aResMgr->parameters( "windows_visibility" );
3056 for ( QStringList::const_iterator itr = mods.begin(); itr != mods.end(); ++itr )
3059 if ( aResMgr->value( "windows_visibility", *itr, arr ) )
3060 myWinVis.insert( *itr, arr );
3064 desktop()->retrieveGeometry( aResMgr->stringValue( "desktop", "geometry" ) );
3065 bool opaqueResize = aResMgr->booleanValue( "desktop", "opaque_resize", false );
3066 QMainWindow::DockOptions dopts = desktop()->dockOptions();
3067 if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
3068 else dopts &= ~QMainWindow::AnimatedDocks;
3069 desktop()->setDockOptions( dopts );
3070 desktop()->setOpaqueResize( opaqueResize );
3071 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
3072 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
3079 void LightApp_Application::savePreferences()
3081 CAM_Application::savePreferences();
3083 saveDockWindowsState();
3085 SUIT_ResourceMgr* aResMgr = resourceMgr();
3090 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3092 mru->saveLinks( aResMgr, "MRU" );
3094 for ( WinVis::const_iterator itr = myWinVis.begin(); itr != myWinVis.end(); ++itr )
3095 aResMgr->setValue( "windows_visibility", itr.key(), itr.value() );
3098 aResMgr->setValue( "desktop", "geometry", desktop()->storeGeometry() );
3104 Updates desktop title
3106 void LightApp_Application::updateDesktopTitle()
3108 QString aTitle = applicationName();
3109 QString aVer = applicationVersion();
3110 if ( !aVer.isEmpty() )
3111 aTitle += QString( " " ) + aVer;
3113 if ( activeStudy() ) {
3114 QString sName = SUIT_Tools::file( activeStudy()->studyName().trimmed(), false );
3115 aTitle += QString( " - [%1]" ).arg( sName );
3118 desktop()->setWindowTitle( aTitle );
3122 \brief Get map of the operations which can be performed
3123 on the module activation.
3125 The method should return the map of the kind \c {<id>:<name>}
3126 where \c <id> is an integer identifier of the operation and
3127 \c <name> is a title for the button to be added to the
3128 dialog box. After user selects the required operation by the
3129 clicking the corresponding button in the dialog box, its identifier
3130 is passed to the moduleActionSelected() method to process
3133 \return map of the operations
3134 \sa moduleActionSelected()
3136 QMap<int, QString> LightApp_Application::activateModuleActions() const
3138 QMap<int, QString> opmap;
3139 opmap.insert( NewStudyId, tr( "ACTIVATE_MODULE_OP_NEW" ) );
3140 opmap.insert( OpenStudyId, tr( "ACTIVATE_MODULE_OP_OPEN" ) );
3145 \brief Called when the used selectes required operation chosen
3146 from "Activate module" dialog box.
3148 Performs the required operation according to the user choice.
3150 \param id operation identifier
3151 \sa activateModuleActions()
3153 void LightApp_Application::moduleActionSelected( const int id )
3168 Updates windows after close document
3170 void LightApp_Application::afterCloseDoc()
3174 CAM_Application::afterCloseDoc();
3178 Updates actions of active module
3180 void LightApp_Application::updateModuleActions()
3183 if ( activeModule() ) {
3184 modName = activeModule()->moduleName();
3185 if ( !isModuleAccessible( modName ) ) {
3186 QList<SUIT_Application*> apps = SUIT_Session::session()->applications();
3187 foreach( SUIT_Application* app, apps ) {
3188 LightApp_Application* lapp = dynamic_cast<LightApp_Application*>( app );
3189 if ( lapp && lapp != this )
3190 lapp->removeModuleAction( modName );
3195 LightApp_ModuleAction* moduleAction =
3196 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
3198 moduleAction->setActiveModule( modName );
3201 void LightApp_Application::removeModuleAction( const QString& modName )
3203 LightApp_ModuleAction* moduleAction =
3204 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
3206 moduleAction->removeModule( modName );
3210 Gets current windows.
3211 \param winMap - output current windows map.
3213 void LightApp_Application::currentWindows( QMap<int, int>& winMap ) const
3216 if ( !activeStudy() )
3219 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
3220 ((LightApp_Module*)activeModule())->windows( winMap );
3222 defaultWindows( winMap );
3226 Gets current view managers.
3227 \param lst - output current view managers list.
3229 void LightApp_Application::currentViewManagers( QStringList& lst ) const
3232 if ( !activeStudy() )
3235 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
3236 ((LightApp_Module*)activeModule())->viewManagers( lst );
3238 defaultViewManagers( lst );
3244 void LightApp_Application::updateWindows()
3246 QMap<int, int> winMap;
3247 currentWindows( winMap );
3249 if ( activeStudy() )
3251 for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
3253 if ( !dockWindow( it.key() ) )
3254 getWindow( it.key() );
3258 for ( WinMap::ConstIterator it = myWin.begin(); it != myWin.end(); ++it )
3260 QWidget* wid = it.value();
3261 if ( activeStudy() )
3262 wid->setVisible( winMap.contains( it.key() ) );
3267 if ( activeStudy() )
3268 loadDockWindowsState();
3274 Updates view managers
3276 void LightApp_Application::updateViewManagers()
3279 currentViewManagers( lst );
3281 for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
3282 getViewManager( *it, true );
3286 Loads windows geometry
3288 void LightApp_Application::loadDockWindowsState()
3292 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
3293 bool storeWin = aResMgr->booleanValue( "Study", "store_positions", true );
3294 bool storeTb = aResMgr->booleanValue( "Study", "store_tool_positions", true );
3297 if ( activeModule() )
3298 modName = activeModule()->name();
3300 QtxResourceMgr::WorkingMode prevMode = aResMgr->workingMode();
3301 aResMgr->setWorkingMode(QtxResourceMgr::IgnoreUserValues);
3302 QByteArray aDefaultState;
3303 aResMgr->value("windows_geometry", modName , aDefaultState );
3304 QByteArray aDefaultVisibility;
3305 aResMgr->value("windows_visibility", modName , aDefaultVisibility );
3306 bool hasDefaultVisibility = !aDefaultVisibility.isEmpty();
3307 aResMgr->setWorkingMode(prevMode);
3309 if( !storeWin && !storeTb && aDefaultState.isEmpty() && !hasDefaultVisibility)
3312 if ( aResMgr->hasValue("windows_geometry" ,modName ) ) {
3314 aResMgr->value("windows_geometry", modName , arr );
3315 QByteArray aTargetArray = processState(arr, storeWin, storeTb, true, aDefaultState);
3316 desktop()->restoreState( aTargetArray );
3319 if ( !myWinVis.contains( modName ) && aDefaultVisibility.isEmpty())
3322 QMap<QString, bool> *tbMap = 0;
3323 QMap<QString, bool> *dwMap = 0;
3325 QMap<QString, bool> userTbMap, userDwMap;
3326 dockWindowsState( myWinVis[modName], userTbMap, userDwMap );
3328 QMap<QString, bool> defaultTbMap, defaultDwMap;
3329 if(hasDefaultVisibility) {
3330 dockWindowsState( aDefaultVisibility, defaultTbMap, defaultDwMap);
3336 if(hasDefaultVisibility){
3337 tbMap = &defaultTbMap;
3344 if(hasDefaultVisibility){
3345 dwMap = &defaultDwMap;
3350 QList<QToolBar*> tbList = findToolBars();
3351 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit )
3353 QToolBar* tb = *tit;
3354 if ( tbMap->contains( tb->objectName() ) ) {
3355 tb->setVisible( (*tbMap)[tb->objectName()] );
3361 QList<QDockWidget*> dwList = qFindChildren<QDockWidget*>( desktop() );
3362 for ( QList<QDockWidget*>::iterator dit = dwList.begin(); dit != dwList.end(); ++dit )
3364 QDockWidget* dw = *dit;
3366 QObject* po = Qtx::findParent( dw, "QMainWindow" );
3367 if ( po != desktop() )
3370 if ( dwMap->contains( dw->objectName() ) )
3371 dw->setVisible( (*dwMap)[dw->objectName()] );
3378 Saves windows geometry
3380 void LightApp_Application::saveDockWindowsState()
3385 bool storeWin = resourceMgr()->booleanValue( "Study", "store_positions", true );
3386 bool storeTb = resourceMgr()->booleanValue( "Study", "store_tool_positions", true );
3388 if( !storeWin && !storeTb )
3392 if ( activeModule() )
3393 modName = activeModule()->name();
3395 QByteArray arr = desktop()->saveState();
3396 resourceMgr()->setValue( "windows_geometry", modName, processState(arr, storeWin, storeTb, false) );
3399 if ( myWinVis.contains( modName ) )
3400 visArr = myWinVis[modName];
3402 QMap<QString, bool> tbMap, dwMap;
3403 dockWindowsState( visArr, tbMap, dwMap );
3405 QList<QToolBar*> tbList = qFindChildren<QToolBar*>( desktop() );
3406 for ( QList<QToolBar*>::iterator it = tbList.begin(); it != tbList.end(); ++it )
3409 tbMap.insert( tb->objectName(), tb->toggleViewAction()->isChecked() );
3412 QList<QDockWidget*> dwList = qFindChildren<QDockWidget*>( desktop() );
3413 for ( QList<QDockWidget*>::iterator it = dwList.begin(); it != dwList.end(); ++it )
3415 QDockWidget* wid = *it;
3416 dwMap.insert( wid->objectName(), wid->toggleViewAction()->isChecked() );
3419 visArr = dockWindowsState( tbMap, dwMap );
3421 myWinVis.insert( modName, visArr );
3424 QByteArray LightApp_Application::dockWindowsState( const QMap<QString, bool>& tb, const QMap<QString, bool>& dw ) const
3427 QDataStream stream( &visArr, QIODevice::WriteOnly );
3429 stream << (uchar)ToolBarMarker;
3430 stream << tb.size();
3431 for ( QMap<QString, bool>::const_iterator tit = tb.begin(); tit != tb.end(); ++tit )
3433 stream << tit.key();
3434 stream << (uchar)( tit.value() ? 1 : 0 );
3437 stream << (uchar)DockWidgetMarker;
3438 stream << dw.size();
3439 for ( QMap<QString, bool>::const_iterator wit = dw.begin(); wit != dw.end(); ++wit )
3441 stream << wit.key();
3442 stream << (uchar)( wit.value() ? 1 : 0 );
3448 void LightApp_Application::dockWindowsState( const QByteArray& arr, QMap<QString, bool>& tb, QMap<QString, bool>& dw ) const
3453 QByteArray visArr = arr;
3454 QDataStream stream( &visArr, QIODevice::ReadOnly );
3458 if ( marker != ToolBarMarker )
3463 for ( int i = 0; i < lines; ++i )
3466 stream >> objectName;
3469 tb.insert( objectName, shown );
3473 if ( marker != DockWidgetMarker )
3477 for ( int j = 0; j < lines; ++j )
3480 stream >> objectName;
3483 dw.insert( objectName, shown );
3488 Adds icon names for modules
3490 void LightApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) const
3494 SUIT_ResourceMgr* resMgr = resourceMgr();
3498 QStringList modList;
3499 modules( modList, false );
3501 for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )
3503 QString modName = *it;
3504 QString modIntr = moduleName( modName );
3505 QString modIcon = resMgr->stringValue( modIntr, "icon", QString() );
3507 if ( modIcon.isEmpty() )
3510 if ( SUIT_Tools::extension( modIcon ).isEmpty() )
3511 modIcon += QString( ".png" );
3513 iconMap.insert( modName, modIcon );
3518 Inserts items in popup, which necessary for current application
3520 void LightApp_Application::contextMenuPopup( const QString& type, QMenu* thePopup, QString& title )
3523 LightApp_SelectionMgr* selMgr = LightApp_Application::selectionMgr();
3524 bool cacheIsOn = selMgr->isSelectionCacheEnabled();
3525 selMgr->setSelectionCacheEnabled( true );
3527 SUIT_DataBrowser* ob = objectBrowser();
3529 CAM_Application::contextMenuPopup( type, thePopup, title );
3531 if ( ob && type == ob->popupClientType() ) {
3532 thePopup->addSeparator();
3533 QAction* a = thePopup->addAction( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
3534 if ( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) )
3535 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) );
3538 #ifndef DISABLE_SALOMEOBJECT
3539 if ( selMgr && ob ) {
3540 SALOME_ListIO selected;
3541 selMgr->selectedObjects( selected );
3542 if(selected.Extent() == 1){
3543 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3544 SUIT_DataObject* obj = findObject(anIObject->getEntry());
3545 if(obj && obj->renameAllowed()) {
3546 QAction* a = new QAction(tr("MEN_RENAME_OBJ"), thePopup);
3547 connect( a, SIGNAL( triggered(bool) ), ob, SLOT( onStartEditing() ) );
3548 if ( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) )
3549 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) );
3551 QList<QAction*> acts = thePopup->actions();
3552 QAction* firstAction = acts.count() > 0 ? acts.first() : 0;
3553 thePopup->insertAction(firstAction,a);
3559 selMgr->setSelectionCacheEnabled( cacheIsOn );
3565 void LightApp_Application::createEmptyStudy()
3567 CAM_Application::createEmptyStudy();
3569 if ( objectBrowser() )
3570 objectBrowser()->updateTree();
3572 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
3573 if ( aResMgr && activeStudy() ) {
3574 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
3575 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
3580 void LightApp_Application::setDesktop( SUIT_Desktop* desk )
3582 CAM_Application::setDesktop( desk );
3585 connect( desk, SIGNAL( message( const QString& ) ),
3586 this, SLOT( onDesktopMessage( const QString& ) ), Qt::UniqueConnection );
3592 \param mod - module to be activated
3594 bool LightApp_Application::activateModule( CAM_Module* mod )
3596 bool res = CAM_Application::activateModule( mod );
3598 if ( objectBrowser() )
3599 objectBrowser()->updateTree();
3605 \return keyborad accelerators manager object
3607 SUIT_Accel* LightApp_Application::accel() const
3613 Removes dead widget container from map
3615 void LightApp_Application::onWCDestroyed( QObject* ob )
3617 // remove destroyed widget container from windows map
3618 for ( WinMap::ConstIterator itr = myWin.begin(); itr != myWin.end(); ++itr )
3620 if ( itr.value() != ob )
3623 int key = itr.key();
3624 myWin.remove( key );
3629 void LightApp_Application::onMRUActivated( const QString& name )
3631 SUIT_Session* s = SUIT_Session::session();
3632 if ( s && s->activeApplication() == this )
3636 void LightApp_Application::onStylePreferences()
3638 Style_PrefDlg dlg( desktop() );
3641 resourceMgr()->setValue( "Style", "use_salome_style", Style_Salome::isActive() );
3644 void LightApp_Application::onFullScreen(){
3645 if(myScreenHelper) {
3646 if(desktop()->isFullScreen())
3647 myScreenHelper->switchToNormalScreen();
3649 myScreenHelper->switchToFullScreen();
3654 Connects just added view manager
3656 void LightApp_Application::addViewManager( SUIT_ViewManager* vm )
3658 connect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
3659 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
3660 CAM_Application::addViewManager( vm );
3664 Remove view manager from memory
3666 void LightApp_Application::removeViewManager( SUIT_ViewManager* vm )
3668 disconnect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
3669 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
3670 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
3672 aStudy->removeViewMgr(vm->getGlobalId());
3674 CAM_Application::removeViewManager( vm );
3676 LightApp_SelectionMgr* selMgr = selectionMgr();
3677 QList<SUIT_Selector*> selectors;
3678 selMgr->selectors( selectors );
3679 foreach( SUIT_Selector* selector, selectors ) {
3680 if ( selector->owner() == vm->getViewModel() ) {
3685 // IPAL22894: Crash on closing OCC view
3691 Renames active window of desktop
3693 void LightApp_Application::onRenameWindow()
3698 QWidget* w = desktop()->activeWindow();
3703 QString name = QInputDialog::getText( w, tr( "TOT_RENAME" ), tr( "PRP_RENAME" ), QLineEdit::Normal, w->windowTitle(), &ok );
3704 if( ok && !name.isEmpty() )
3705 w->setWindowTitle( name );
3709 Closes active window of desktop
3711 void LightApp_Application::onCloseWindow()
3716 QWidget* w = desktop()->activeWindow();
3724 Closes all windows of desktop
3726 void LightApp_Application::onCloseAllWindow()
3728 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
3732 QList<SUIT_ViewWindow*> wndList = desk->windows();
3733 SUIT_ViewWindow* wnd;
3734 foreach( wnd, wndList )
3742 Groups all windows of desktop
3744 void LightApp_Application::onGroupAllWindow()
3746 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
3750 QtxWorkstack* wgStack = desk->workstack();
3756 \return if the library of module exists
3757 \param moduleTitle - title of module
3759 bool LightApp_Application::isLibExists( const QString& moduleTitle ) const
3761 if( moduleTitle.isEmpty() )
3764 QString lib = moduleLibrary( moduleTitle );
3766 //abd: changed libSalomePyQtGUI to SalomePyQtGUI for WIN32
3767 bool isPythonModule = lib.contains("SalomePyQtGUI");
3768 bool isPythonLightModule = lib.contains("SalomePyQtGUILight");
3772 paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
3774 paths = QString(::getenv( "LD_LIBRARY_PATH" )).split( ":", QString::SkipEmptyParts );
3777 bool isLibFound = false;
3778 QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
3779 for( ; anIt!=aLast; anIt++ )
3781 QFileInfo inf( Qtx::addSlash( *anIt ) + lib );
3792 INFOS( "\n****************************************************************" << std::endl
3793 << "* Warning: library " << lib.toLatin1().constData() << " cannot be found" << std::endl
3794 << "* Module " << moduleTitle.toLatin1().constData() << " will not be available in GUI mode" << std::endl
3795 << "****************************************************************" << std::endl );
3797 else if ( !isPythonModule && !isPythonLightModule)
3800 if ( isPythonModule || isPythonLightModule)
3802 QString pylib = moduleName( moduleTitle ) + QString(".py");
3803 QString pylibgui = moduleName( moduleTitle ) + QString("GUI.py");
3805 // Check the python library
3807 // paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
3809 paths = QString(::getenv( "PYTHONPATH" )).split( ":", QString::SkipEmptyParts );
3811 bool isPyLib = false, isPyGuiLib = false;
3812 QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
3813 for( ; anIt!=aLast; anIt++ )
3815 QFileInfo inf( Qtx::addSlash( *anIt ) + pylib );
3816 QFileInfo infgui( Qtx::addSlash( *anIt ) + pylibgui );
3818 if(!isPythonLightModule)
3819 if( !isPyLib && inf.exists() )
3822 if( !isPyGuiLib && infgui.exists() )
3825 if ((isPyLib || isPythonLightModule ) && isPyGuiLib && isLibFound)
3829 printf( "\n****************************************************************\n" );
3830 printf( "* Warning: python library for %s cannot be found:\n", moduleTitle.toLatin1().constData() );
3832 printf( "* No module named %s\n", moduleName( moduleTitle ).toLatin1().constData() );
3834 printf( "* No module named %s\n", (moduleName( moduleTitle ) + QString("GUI")).toLatin1().constData() );
3835 printf( "****************************************************************\n" );
3842 \return default name for an active study
3844 void LightApp_Application::setDefaultStudyName( const QString& theName )
3846 QStringList anInfoList;
3847 modules( anInfoList, false );
3849 LightApp_Study* aStudy = (LightApp_Study*)activeStudy();
3850 if( anInfoList.count() == 1 && // to avoid a conflict between different modules
3851 !aStudy->isSaved() )
3853 aStudy->setStudyName( theName );
3854 updateDesktopTitle();
3859 Custom event handler
3861 bool LightApp_Application::event( QEvent* e )
3863 if( e && e->type()==2000 )
3865 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
3866 QString* d = ( QString* )ce->data();
3867 if( SUIT_MessageBox::question(0, tr("WRN_WARNING"),
3869 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
3870 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
3871 showPreferences( tr( "PREF_APP" ) );
3876 return CAM_Application::event( e );
3879 /*! Check data object */
3880 bool LightApp_Application::checkDataObject(LightApp_DataObject* theObj)
3884 bool isSuitable = !theObj->entry().isEmpty() &&
3885 !theObj->componentDataType().isEmpty() &&
3886 !theObj->name().isEmpty();
3893 int LightApp_Application::openChoice( const QString& aName )
3895 int choice = CAM_Application::openChoice( aName );
3897 if ( choice == OpenExist ) // The document is already open.
3899 // Do you want to reload it?
3900 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "QUE_DOC_ALREADYOPEN" ).arg( aName ),
3901 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No ) == SUIT_MessageBox::Yes )
3902 choice = OpenReload;
3908 bool LightApp_Application::openAction( const int choice, const QString& aName )
3915 STD_Application* app = 0;
3916 SUIT_Session* session = SUIT_Session::session();
3917 QList<SUIT_Application*> appList = session->applications();
3918 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !app; ++it )
3920 if ( (*it)->activeStudy() && (*it)->activeStudy()->studyName() == aName )
3921 app = ::qobject_cast<STD_Application*>( *it );
3926 app->onCloseDoc( false );
3927 appList = session->applications();
3928 STD_Application* other = 0;
3929 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !other; ++it )
3930 other = ::qobject_cast<STD_Application*>( *it );
3933 res = other->onOpenDoc( aName );
3938 res = CAM_Application::openAction( choice, aName );
3945 QStringList LightApp_Application::viewManagersTypes() const
3947 QStringList aTypesList;
3948 aTypesList += myUserWmTypes;
3949 #ifndef DISABLE_GLVIEWER
3950 aTypesList<<GLViewer_Viewer::Type();
3952 #ifndef DISABLE_PLOT2DVIEWER
3953 aTypesList<<Plot2d_Viewer::Type();
3955 #ifndef DISABLE_QXGRAPHVIEWER
3956 aTypesList<<QxScene_Viewer::Type();
3958 #ifndef DISABLE_OCCVIEWER
3959 aTypesList<<OCCViewer_Viewer::Type();
3961 #ifndef DISABLE_VTKVIEWER
3962 #ifndef DISABLE_SALOMEOBJECT
3963 aTypesList<<SVTK_Viewer::Type();
3965 aTypesList<<VTKViewer_Viewer::Type();
3971 * Removes all view managers of known types
3972 * Other view managers are ignored
3974 void LightApp_Application::clearKnownViewManagers()
3976 QStringList aTypesList = viewManagersTypes();
3977 QList<SUIT_ViewManager*> aMgrList;
3978 viewManagers( aMgrList );
3979 foreach (SUIT_ViewManager* aMgr, aMgrList) {
3980 if (aTypesList.contains(aMgr->getType()))
3981 removeViewManager(aMgr);
3986 Copy of current selection
3988 void LightApp_Application::onCopy()
3990 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
3996 Paste of current data in clipboard
3998 void LightApp_Application::onPaste()
4000 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
4006 Browse (i.e. set focus on) the published objects
4007 \param theIsApplyAndClose - flag indicating that the dialog for creating objects
4008 has been accepted by Ok (or Apply & Close) button
4009 \param theIsOptimizedBrowsing - flag switching to optimized browsing mode
4010 (to select the first published object only)
4011 \return entry of the selected object
4013 QString LightApp_Application::browseObjects( const QStringList& theEntryList,
4014 const bool theIsApplyAndClose,
4015 const bool theIsOptimizedBrowsing )
4018 if( SUIT_ResourceMgr* aResourceMgr = resourceMgr() )
4020 int aBrowsePolicy = aResourceMgr->integerValue( "ObjectBrowser", "browse_published_object", (int)BP_Never );
4021 switch( aBrowsePolicy )
4025 case BP_ApplyAndClose:
4026 if( !theIsApplyAndClose )
4034 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
4038 SUIT_DataBrowser* anOB = objectBrowser();
4042 SUIT_AbstractModel* aModel = dynamic_cast<SUIT_AbstractModel*>( anOB->model() );
4046 QStringListIterator anIter( theEntryList );
4047 if( theIsOptimizedBrowsing )
4049 // go to the last entry
4051 if( anIter.hasPrevious() )
4055 // scroll to each entry in the list
4056 // (in optimized mode - to the last entry only)
4058 LightApp_DataObject* anObject = 0;
4059 while( anIter.hasNext() )
4061 anEntry = anIter.next();
4062 if( !anEntry.isEmpty() )
4064 anObject = aStudy->findObjectByEntry( anEntry );
4067 QModelIndex anIndex = aModel->index( anObject );
4068 anOB->treeView()->scrollTo( anIndex );
4073 // always select the last object
4074 if( anObject && !anEntry.isEmpty() )
4076 QList<SUIT_Selector*> aSelectorList;
4077 selectionMgr()->selectors( "ObjectBrowser", aSelectorList );
4078 if( !aSelectorList.isEmpty() )
4080 if( LightApp_OBSelector* aSelector = dynamic_cast<LightApp_OBSelector*>( aSelectorList.first() ) )
4082 bool anIsAutoBlock = aSelector->autoBlock();
4084 // temporarily disable auto block, to emit LightApp_SelectionMgr::currentSelectionChanged() signal
4085 aSelector->setAutoBlock( false );
4087 SUIT_DataOwnerPtrList aList;
4088 #ifndef DISABLE_SALOMEOBJECT
4089 Handle(SALOME_InteractiveObject) aSObj = new SALOME_InteractiveObject
4090 ( anObject->entry().toLatin1().constData(),
4091 anObject->componentDataType().toLatin1().constData(),
4092 anObject->name().toLatin1().constData() );
4093 LightApp_DataOwner* owner = new LightApp_DataOwner( aSObj );
4095 LightApp_DataOwner* owner = new LightApp_DataOwner( anEntry );
4098 aList.append( owner );
4099 selectionMgr()->setSelected( aList );
4102 // restore auto block flag
4103 aSelector->setAutoBlock( anIsAutoBlock );
4111 SUIT_DataObject* LightApp_Application::findObject( const QString& id ) const
4113 LightApp_Study* study = dynamic_cast<LightApp_Study*>( activeStudy() );
4114 return study ? study->findObjectByEntry( id ) : 0;
4118 Checks that an object can be renamed.
4119 \param entry entry of the object
4120 \brief Return \c true if object can be renamed
4122 bool LightApp_Application::renameAllowed( const QString& /*entry*/) const {
4127 Rename object by entry.
4128 \param entry entry of the object
4129 \param name new name of the object
4130 \brief Return \c true if rename operation finished successfully, \c false otherwise.
4132 bool LightApp_Application::renameObject( const QString& entry, const QString& ) {
4136 /*! Process standard messages from desktop */
4137 void LightApp_Application::onDesktopMessage( const QString& message )
4139 const QString sectionSeparator = "/";
4141 if ( message.toLower() == "updateobjectbrowser" ||
4142 message.toLower() == "updateobjbrowser" ) {
4143 // update object browser
4144 updateObjectBrowser();
4147 QStringList data = message.split( sectionSeparator );
4148 if ( data.count() > 1 ) {
4149 QString msgType = data[0].trimmed();
4150 LightApp_Module* sMod = 0;
4151 CAM_Module* mod = module( msgType );
4153 mod = module( moduleTitle( msgType ) );
4154 if ( mod && mod->inherits( "LightApp_Module" ) )
4155 sMod = (LightApp_Module*)mod;
4157 if ( msgType.toLower() == "preferences" ) {
4158 // requested preferences change: should be given as "preferences/<section>/<name>/<value>"
4159 // for example "preferences/Study/multi_file_dump/true"
4160 if ( data.count() > 3 ) {
4161 QString section = data[1].trimmed();
4162 QString param = data[2].trimmed();
4163 QString value = QStringList( data.mid(3) ).join( sectionSeparator );
4164 resourceMgr()->setValue( section, param, value );
4168 // received message for the module
4169 QString msg = QStringList( data.mid(1) ).join( sectionSeparator );
4170 sMod->message( msg );
4178 Returns all top level toolbars.
4179 Note : Result list contains only main window toolbars, not including toolbars from viewers.
4181 QList<QToolBar*> LightApp_Application::findToolBars() {
4182 QList<QToolBar*> aResult;
4183 QList<QToolBar*> tbList = qFindChildren<QToolBar*>( desktop() );
4184 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit ) {
4185 QToolBar* tb = *tit;
4186 QObject* po = Qtx::findParent( tb, "QMainWindow" );
4187 if ( po != desktop() )
4195 Internal method to parse toolbars and dockable windows state.
4197 QByteArray LightApp_Application::processState(QByteArray& input,
4198 const bool processWin,
4199 const bool processTb,
4200 const bool isRestoring,
4201 QByteArray defaultState) {
4204 bool hasDefaultState = !defaultState.isEmpty();
4205 bool isDockWinWriten = false;
4207 //Write date from users settings
4209 QDataStream tmpInputData(&input, QIODevice::ReadOnly);
4210 int marker, version;
4212 tmpInputData >> marker;
4213 tmpInputData >> version;
4214 tmpInputData >> dockmarker;
4215 tmpInputData >> nbDocWin;
4217 if(processWin && processTb && !isRestoring) {
4219 } else if(!processWin && !processTb ) {
4221 aRes = defaultState;
4223 QDataStream aData(&aRes, QIODevice::WriteOnly);
4224 QList<QToolBar*> aToolBars = findToolBars();
4227 for ( QList<QToolBar*>::iterator tit = aToolBars.begin(); tit != aToolBars.end(); ++tit ) {
4228 QToolBar* tb = *tit;
4229 aNames.append(tb->objectName());
4232 int toolBarMarkerIndex = getToolbarMarkerIndex(input,aNames);
4233 QDataStream anInputData(&input, QIODevice::ReadOnly);
4234 if(toolBarMarkerIndex < 0)
4237 int toolBarMarkerIndexDef;
4238 if(hasDefaultState) {
4239 toolBarMarkerIndexDef = getToolbarMarkerIndex(defaultState, aNames);
4240 if(toolBarMarkerIndexDef < 0)
4243 QDataStream anInputDataDef(&defaultState, QIODevice::ReadOnly);
4245 QDataStream* aTargetData = 0;
4246 int aTargetIndex = -1;
4248 QByteArray currentArr = desktop()->saveState();
4249 QDataStream anInputDataCur(¤tArr, QIODevice::ReadOnly);
4250 bool useInputData = !isRestoring || (isRestoring && nbDocWin > 0);
4251 if(processWin && useInputData) {
4252 aTargetData = &anInputData;
4253 aTargetIndex = toolBarMarkerIndex;
4255 //Write date from default settings
4256 if(hasDefaultState) {
4257 aTargetData = &anInputDataDef;
4258 aTargetIndex = toolBarMarkerIndexDef;
4260 //If no default state, write current snapshot of the dockable windows
4262 aTargetData = &anInputDataCur;
4263 int toolBarMarkerIndexCur = getToolbarMarkerIndex(currentArr, aNames);
4264 aTargetIndex = toolBarMarkerIndexCur;
4269 if(aTargetData && aTargetIndex >= 0 ) {
4270 aTargetData->device()->seek(0);
4271 while( aTargetData->device()->pos() < aTargetIndex ) {
4276 isDockWinWriten = true;
4283 aTargetData = &anInputData;
4284 aTargetIndex = toolBarMarkerIndex;
4286 if(hasDefaultState) {
4287 aTargetData = &anInputDataDef;
4288 aTargetIndex = toolBarMarkerIndexDef;
4292 if(aTargetData && aTargetIndex >= 0) {
4294 if(!isDockWinWriten ) {
4295 //Write version marker
4296 int marker, version;
4297 aTargetData->device()->seek(0);
4298 *aTargetData >> marker;
4299 *aTargetData >> version;
4302 aData << (uchar) QDockWidgetMarker;
4304 int shift = 4*sizeof(int) + sizeof(QSize);
4305 index = aTargetIndex - shift;
4307 index = aTargetIndex;
4310 aTargetData->device()->seek(index);
4311 while(!aTargetData->atEnd()) {
4316 } else { // Not treat toolbars
4317 aData << (uchar) QToolBarMarker;
4318 aData << (int) 0; //Nb toolbars = 0
4325 \brief Emits operationFinished signal.
4326 \param theModuleName the name of the module which perfomed the operation
4327 \param theOperationName the operation name
4328 \param theEntryList the list of the created objects entries
4330 void LightApp_Application::emitOperationFinished( const QString& theModuleName,
4331 const QString& theOperationName,
4332 const QStringList& theEntryList )
4334 emit operationFinished( theModuleName, theOperationName, theEntryList );