1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File: LightApp_Application.cxx
24 // Created: 6/20/2005 18:39:45 PM
25 // Author: Natalia Donis
28 // E.A. : On windows with python 2.6, there is a conflict
29 // E.A. : between pymath.h and Standard_math.h which define
30 // E.A. : some same symbols : acosh, asinh, ...
31 #include <Standard_math.hxx>
32 #ifndef DISABLE_PYCONSOLE
37 #ifndef DISABLE_PYCONSOLE
38 #include "LightApp_PyInterp.h" // WARNING! This include must be the first!
39 #include <PyConsole_Console.h>
42 #include "LightApp_Application.h"
43 #include "LightApp_Module.h"
44 #include "LightApp_DataModel.h"
45 #include "LightApp_Study.h"
46 #include "LightApp_Preferences.h"
47 #include "LightApp_PreferencesDlg.h"
48 #include "LightApp_ModuleDlg.h"
49 #include "LightApp_AboutDlg.h"
50 #include "LightApp_ModuleAction.h"
51 // temporary commented
52 //#include "LightApp_OBFilter.h"
53 #include "LightApp_EventFilter.h"
54 #include "LightApp_OBSelector.h"
55 #include "LightApp_SelectionMgr.h"
56 #include "LightApp_DataObject.h"
57 #include "LightApp_WgViewModel.h"
58 #include "LightApp_FullScreenHelper.h"
61 #include <GUI_version.h>
62 #include <Basics_OCCTVersion.hxx>
64 #include <SALOME_Event.h>
66 #include <Style_Salome.h>
67 #include <Style_PrefDlg.h>
69 #include <CAM_Module.h>
70 #include <CAM_DataModel.h>
71 #include <CAM_Study.h>
72 #include <STD_TabDesktop.h>
74 #include <SUIT_DataBrowser.h>
75 #include <SUIT_Session.h>
76 #include <SUIT_Study.h>
77 #include <SUIT_FileDlg.h>
78 #include <SUIT_ResourceMgr.h>
79 #include <SUIT_ShortcutMgr.h>
80 #include <SUIT_Tools.h>
81 #include <SUIT_Accel.h>
82 #include <SUIT_MessageBox.h>
83 #include <SUIT_ViewWindow.h>
86 #include <QtxToolBar.h>
87 #include <QtxTreeView.h>
88 #include <QtxMRUAction.h>
89 #include <QtxDockAction.h>
90 #include <QtxDockWidget.h>
91 #include <QtxActionToolMgr.h>
92 #include <QtxSearchTool.h>
93 #include <QtxWorkstack.h>
95 #include <QtxWebBrowser.h>
97 #include <LogWindow.h>
99 #ifndef DISABLE_GLVIEWER
100 #include <GLViewer_Viewer.h>
101 #include <GLViewer_ViewManager.h>
102 #include "LightApp_GLSelector.h"
105 #ifndef DISABLE_PLOT2DVIEWER
106 #include <Plot2d_ViewManager.h>
107 #include <Plot2d_ViewModel.h>
108 #include <Plot2d_ViewWindow.h>
109 #include <Plot2d_ViewFrame.h>
110 #include "LightApp_Plot2dSelector.h"
111 #ifndef DISABLE_SALOMEOBJECT
112 #include <SPlot2d_ViewModel.h>
114 #include <Plot2d_ViewModel.h>
118 #ifndef DISABLE_OCCVIEWER
119 #include <OCCViewer_ViewManager.h>
120 #include <OCCViewer_ViewFrame.h>
121 #ifndef DISABLE_SALOMEOBJECT
122 #include <SOCC_ViewModel.h>
124 #include <OCCViewer_ViewModel.h>
126 #include "LightApp_OCCSelector.h"
129 #ifndef DISABLE_VTKVIEWER
130 #ifndef DISABLE_SALOMEOBJECT
131 #include <SVTK_ViewModel.h>
132 #include <SVTK_ViewManager.h>
133 #include "LightApp_VTKSelector.h"
135 #include <VTKViewer_ViewModel.h>
136 #include <VTKViewer_ViewManager.h>
138 #include <VTKViewer_ViewModel.h>
141 //#ifndef DISABLE_SUPERVGRAPHVIEWER
142 // #include <SUPERVGraph_ViewModel.h>
143 // #include <SUPERVGraph_ViewFrame.h>
144 // #include <SUPERVGraph_ViewManager.h>
147 #ifndef DISABLE_QXGRAPHVIEWER
148 //VSR: QxGraph has been replaced by QxScene
149 // #include <QxGraph_ViewModel.h>
150 // #include <QxGraph_ViewWindow.h>
151 // #include <QxGraph_ViewManager.h>
152 #include <QxScene_ViewManager.h>
153 #include <QxScene_ViewModel.h>
154 #include <QxScene_ViewWindow.h>
158 #define VISIBILITY_COLUMN_WIDTH 25
164 #include <QStringList>
166 #include <QApplication>
168 #include <QStatusBar>
170 #include <QObjectList>
172 #include <QInputDialog>
173 #include <QFontDatabase>
175 #include <QByteArray>
179 #include <QHeaderView>
184 #include <utilities.h>
186 #define FIRST_HELP_ID 1000000
188 #ifndef DISABLE_SALOMEOBJECT
189 #include <SALOME_InteractiveObject.hxx>
190 #include <SALOME_ListIO.hxx>
193 #include <Standard_Version.hxx>
195 #define ToolBarMarker 0
196 #define DockWidgetMarker 1
198 static const char* imageEmptyIcon[] = {
201 "....................",
202 "....................",
203 "....................",
204 "....................",
205 "....................",
206 "....................",
207 "....................",
208 "....................",
209 "....................",
210 "....................",
211 "....................",
212 "....................",
213 "....................",
214 "....................",
215 "....................",
216 "....................",
217 "....................",
218 "....................",
219 "....................",
220 "...................."};
222 int LightApp_Application::lastStudyId = 0;
225 \return last global id of study
227 int LightApp_Application::studyId()
229 return LightApp_Application::lastStudyId;
232 /*!Create new instance of LightApp_Application.*/
233 extern "C" LIGHTAPP_EXPORT SUIT_Application* createApplication()
235 return new LightApp_Application();
238 /*! \var global preferences of LightApp */
239 LightApp_Preferences* LightApp_Application::_prefs_ = 0;
243 \class LightApp_Application
244 Application containing LightApp module
248 LightApp_Application::LightApp_Application()
249 : CAM_Application( false ),
251 myScreenHelper(new LightApp_FullScreenHelper())
253 Q_INIT_RESOURCE( LightApp );
255 STD_TabDesktop* desk = new STD_TabDesktop();
256 desk->setFullScreenAllowed(false);
257 desk->setMinimizeAllowed(false);
261 // initialize auto save timer
262 myAutoSaveTimer = new QTimer( this );
263 myAutoSaveTimer->setSingleShot( true );
264 connect( myAutoSaveTimer, SIGNAL( timeout() ), this, SLOT( onSaveDoc() ) );
266 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
267 QPixmap aLogo = aResMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
269 QtxWebBrowser::setData("browser:icon", aResMgr->loadPixmap( "LightApp", tr( "BROWSER_ICON" ) ) );
270 QtxWebBrowser::setData("browser:title", tr( "BROWSER_TITLE" ) );
271 QtxWebBrowser::setData("toolbar:title", tr( "BROWSER_TOOLBAR_TITLE" ) );
272 QtxWebBrowser::setData("menu:file:title", tr( "BROWSER_FILEMENU" ) );
273 QtxWebBrowser::setData("action:close:title", tr( "BROWSER_CLOSE" ) );
274 QtxWebBrowser::setData("action:close:icon", aResMgr->loadPixmap( "LightApp", tr( "BROWSER_CLOSE_ICON" ) ) );
275 QtxWebBrowser::setData("action:back:title", tr( "BROWSER_BACK" ) );
276 QtxWebBrowser::setData("action:forward:title", tr( "BROWSER_FORWARD" ) );
277 QtxWebBrowser::setData("action:find:title", tr( "BROWSER_FIND" ) );
278 QtxWebBrowser::setData("action:findnext:title", tr( "BROWSER_FINDNEXT" ) );
279 QtxWebBrowser::setData("action:findprev:title", tr( "BROWSER_FINDPREV" ) );
281 desktop()->setWindowIcon( aLogo );
282 desktop()->setDockableMenuBar( false );
283 desktop()->setDockableStatusBar( false );
285 // base logo (salome itself)
286 desktop()->logoInsert( "_app_base", aResMgr->loadPixmap( "LightApp", tr( "APP_BASE_LOGO" ), false ) );
287 // extra logo (salome-based application)
288 desktop()->logoInsert( "_app_extra", aResMgr->loadPixmap( "LightApp", tr( "APP_EXTRA_LOGO" ), false ) );
292 mySelMgr = new LightApp_SelectionMgr( this );
294 myAccel = SUIT_Accel::getAccel();
296 #ifndef DISABLE_OCCVIEWER
297 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, OCCViewer_Viewer::Type() );
298 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, OCCViewer_Viewer::Type() );
299 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, OCCViewer_Viewer::Type() );
300 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, OCCViewer_Viewer::Type() );
301 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, OCCViewer_Viewer::Type() );
302 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, OCCViewer_Viewer::Type() );
303 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, OCCViewer_Viewer::Type() );
304 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, OCCViewer_Viewer::Type() );
305 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, OCCViewer_Viewer::Type() );
306 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, OCCViewer_Viewer::Type() );
307 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, OCCViewer_Viewer::Type() );
309 #ifndef DISABLE_VTKVIEWER
310 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, VTKViewer_Viewer::Type() );
311 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, VTKViewer_Viewer::Type() );
312 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, VTKViewer_Viewer::Type() );
313 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, VTKViewer_Viewer::Type() );
314 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, VTKViewer_Viewer::Type() );
315 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, VTKViewer_Viewer::Type() );
316 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, VTKViewer_Viewer::Type() );
317 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, VTKViewer_Viewer::Type() );
318 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, VTKViewer_Viewer::Type() );
319 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, VTKViewer_Viewer::Type() );
320 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, VTKViewer_Viewer::Type() );
322 #ifndef DISABLE_PLOT2DVIEWER
323 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, Plot2d_Viewer::Type() );
324 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, Plot2d_Viewer::Type() );
325 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, Plot2d_Viewer::Type() );
326 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, Plot2d_Viewer::Type() );
327 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, Plot2d_Viewer::Type() );
328 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, Plot2d_Viewer::Type() );
329 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, Plot2d_Viewer::Type() );
332 connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) );
334 // Set existing font for the python console in resources
335 if( !aResMgr->hasValue( "PyConsole", "font" ) )
338 QFont f = aResMgr->fontValue( "PyConsole", "font" );
340 QStringList famdb = fdb.families();
342 if ( famdb.contains(f.family()) || !aResMgr->hasValue( "PyConsole", "additional_families" ) )
345 QStringList anAddFamilies = aResMgr->stringValue( "PyConsole", "additional_families" ).split( ";", QString::SkipEmptyParts );
347 for ( QStringList::Iterator it = anAddFamilies.begin(); it != anAddFamilies.end(); ++it )
350 if ( famdb.contains(aFamily) )
352 f.setFamily( aFamily );
353 aResMgr->setValue( "PyConsole", "font", f );
360 *\li Save window geometry.
361 *\li Save desktop geometry.
362 *\li Save resource maneger.
363 *\li Delete selection manager.
365 LightApp_Application::~LightApp_Application()
368 delete myScreenHelper;
371 /*!Start application.*/
372 void LightApp_Application::start()
374 CAM_Application::start();
377 updateViewManagers();
380 desktop()->statusBar()->showMessage( "" );
382 LightApp_EventFilter::Init();
385 /*!Gets application name.*/
386 QString LightApp_Application::applicationName() const
388 static QString _app_name;
389 if ( _app_name.isEmpty() )
390 _app_name = tr( "APP_NAME" );
394 /*!Gets application version.*/
395 QString LightApp_Application::applicationVersion() const
397 static QString _app_version;
399 if ( _app_version.isEmpty() )
401 QString resVersion = tr( "APP_VERSION" );
402 if ( resVersion != "APP_VERSION" )
404 _app_version = resVersion;
408 _app_version = GUI_VERSION_STR;
414 /*!Load module by \a name.*/
415 CAM_Module* LightApp_Application::loadModule( const QString& name, const bool showMsg )
417 CAM_Module* mod = CAM_Application::loadModule( name, showMsg );
420 connect( this, SIGNAL( studyOpened() ), mod, SLOT( onModelOpened() ) );
421 connect( this, SIGNAL( studySaved() ), mod, SLOT( onModelSaved() ) );
422 connect( this, SIGNAL( studyClosed() ), mod, SLOT( onModelClosed() ) );
427 /*!Activate module by \a modName*/
428 bool LightApp_Application::activateModule( const QString& modName )
431 CAM_Module* prevMod = activeModule();
434 actName = prevMod->moduleName();
436 if ( actName == modName )
439 putInfo( tr( "ACTIVATING_MODULE" ).arg( modName ) );
441 saveDockWindowsState();
443 bool status = CAM_Application::activateModule( modName );
445 updateModuleActions();
453 updateViewManagers();
458 /*!Gets selection manager.*/
459 LightApp_SelectionMgr* LightApp_Application::selectionMgr() const
464 /*!Creat action "New window" for certain type of viewer:*/
465 void LightApp_Application::createActionForViewer( const int id,
467 const QString& suffix,
470 QString vtlt = tr( QString( "NEW_WINDOW_%1" ).arg( suffix ).toLatin1().constData() );
471 QString tip = tr( "CREATING_NEW_WINDOW" ).arg( vtlt.remove( "&" ) );
472 QAction* a = createAction( id, // menu action id
479 false, // toggle flag
481 SLOT( onNewWindow() ) ); // slot
482 createMenu( a, parentId, -1 );
487 void LightApp_Application::createActions()
489 CAM_Application::createActions();
491 SUIT_Desktop* desk = desktop();
492 SUIT_ResourceMgr* resMgr = resourceMgr();
495 createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIcon(),
496 tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
497 Qt::CTRL+Qt::Key_R, desk, false, this, SLOT( onPreferences() ) );
501 // - Help for modules
503 int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
504 createMenu( separator(), helpMenu, -1, 10 );
505 QStringList aModuleList;
506 modules( aModuleList, false );
507 aModuleList.prepend( "GUI" );
508 aModuleList.prepend( "KERNEL" );
510 int id = LightApp_Application::UserID + FIRST_HELP_ID;
513 foreach( aModule, aModuleList ) {
514 if ( aModule.isEmpty() ) // module title (user name)
516 IMap <QString, QString> helpData; // list of help files for the module
517 QString helpSubMenu; // help submenu name (empty if not needed)
518 QString modName = moduleName( aModule ); // module name
519 if ( modName.isEmpty() ) modName = aModule; // for KERNEL and GUI
520 QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName ); // module root dir variable
521 QString modDir = getenv( rootDir.toLatin1().constData() ); // module root dir
523 if (resMgr->hasValue( modName, "documentation" ) )
524 docSection = resMgr->stringValue(modName, "documentation");
525 else if ( resMgr->hasSection( modName + "_documentation" ) )
526 docSection = modName + "_documentation";
527 if ( !docSection.isEmpty() ) {
528 helpSubMenu = resMgr->stringValue( docSection, "sub_menu", "" ).arg( aModule );
529 QStringList listOfParam = resMgr->parameters( docSection );
530 foreach( QString paramName, listOfParam ) {
531 QString valueStr = resMgr->stringValue( docSection, paramName );
532 if ( !valueStr.isEmpty() ) {
533 QFileInfo fi( valueStr );
534 if ( fi.isRelative() && !modDir.isEmpty() )
535 valueStr = Qtx::addSlash( modDir ) + valueStr;
536 if ( QFile::exists( valueStr ) )
537 helpData.insert( paramName.arg( aModule ), valueStr );
542 if ( helpData.isEmpty() && !modDir.isEmpty() ) {
543 QStringList idxLst = QStringList() << modDir << "share" << "doc" << "salome" << "gui" << modName << "index.html";
544 QString indexFile = idxLst.join( QDir::separator() ); // index file
545 if ( QFile::exists( indexFile ) )
546 helpData.insert( tr( "%1 module Users's Guide" ).arg( aModule ), indexFile );
549 IMapConstIterator<QString, QString > fileIt;
550 for ( fileIt = helpData.begin(); fileIt != helpData.end(); fileIt++ ) {
551 QString helpFileName = fileIt.key();
552 // remove all '//' occurances
553 while ( helpFileName.contains( "//" ) )
554 helpFileName.replace( "//", "" );
555 // obtain submenus hierarchy if given
556 QStringList smenus = helpFileName.split( "/" );
557 helpFileName = smenus.last();
559 QAction* a = createAction( id, helpFileName,
560 resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
561 helpFileName, helpFileName,
562 0, desk, false, this, SLOT( onHelpContentsModule() ) );
563 a->setData( fileIt.value() );
564 if ( !helpSubMenu.isEmpty() ) {
565 smenus.prepend( helpSubMenu );
567 // create sub-menus hierarchy
568 int menuId = helpMenu;
569 foreach ( QString subMenu, smenus ) {
570 menuId = createMenu( subMenu, menuId, -1, 0 );
572 createMenu( a, menuId, -1, 0 );
577 // - Additional help items
579 QStringList addHelpItems = resMgr->parameters( "add_help" );
580 foreach ( QString addHelpItem, addHelpItems ) {
581 QString valueStr = resMgr->stringValue( "add_help", addHelpItem );
582 if ( !valueStr.isEmpty() && QFile::exists( valueStr ) ) {
583 QAction* a = createAction( id, addHelpItem,
584 resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
585 addHelpItem, addHelpItem,
586 0, desk, false, this, SLOT( onHelpContentsModule() ) );
587 a->setData( valueStr );
588 createMenu( a, helpMenu, -1, 5 );
592 createMenu( separator(), helpMenu, -1, 5 );
595 static QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), 0 );
596 connect( mru, SIGNAL( activated( const QString& ) ), this, SLOT( onMRUActivated( const QString& ) ) );
597 registerAction( MRUId, mru );
599 // default icon for neutral point ('SALOME' module)
600 QPixmap defIcon = resMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
601 if ( defIcon.isNull() )
602 defIcon = QPixmap( imageEmptyIcon );
604 //! default icon for any module
605 QPixmap modIcon = resMgr->loadPixmap( "LightApp", tr( "APP_MODULE_ICO" ), false );
606 if ( modIcon.isNull() )
607 modIcon = QPixmap( imageEmptyIcon );
610 modules( modList, false );
612 if ( modList.count() > 1 )
614 LightApp_ModuleAction* moduleAction =
615 new LightApp_ModuleAction( tr( "APP_NAME" ), defIcon, desk );
617 QMap<QString, QString> iconMap;
618 moduleIconNames( iconMap );
620 const int iconSize = 20;
622 QStringList::Iterator it;
623 for ( it = modList.begin(); it != modList.end(); ++it )
625 if ( !isLibExists( *it ) )
628 QString modName = moduleName( *it );
630 if ( !isModuleAccessible( *it ) )
634 if ( iconMap.contains( *it ) )
635 iconName = iconMap[*it];
637 QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
641 INFOS ( "****************************************************************" << std::endl
642 << "* Icon for " << (*it).toLatin1().constData()
643 << " not found. Using the default one." << std::endl
644 << "****************************************************************" << std::endl );
647 icon = Qtx::scaleIcon( icon, iconSize );
649 moduleAction->insertModule( *it, icon );
652 connect( moduleAction, SIGNAL( moduleActivated( const QString& ) ),
653 this, SLOT( onModuleActivation( const QString& ) ) );
654 registerAction( ModulesListId, moduleAction );
658 int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, MenuWindowId, 100 );
659 int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
661 createAction( CloseId, tr( "TOT_CLOSE" ), QIcon(), tr( "MEN_DESK_CLOSE" ), tr( "PRP_CLOSE" ),
662 Qt::CTRL+Qt::Key_F4, desk, false, this, SLOT( onCloseWindow() ) );
663 createAction( CloseAllId, tr( "TOT_CLOSE_ALL" ), QIcon(), tr( "MEN_DESK_CLOSE_ALL" ), tr( "PRP_CLOSE_ALL" ),
664 0, desk, false, this, SLOT( onCloseAllWindow() ) );
665 createAction( GroupAllId, tr( "TOT_GROUP_ALL" ), QIcon(), tr( "MEN_DESK_GROUP_ALL" ), tr( "PRP_GROUP_ALL" ),
666 0, desk, false, this, SLOT( onGroupAllWindow() ) );
668 createMenu( CloseId, windowMenu, 0, -1 );
669 createMenu( CloseAllId, windowMenu, 0, -1 );
670 createMenu( GroupAllId, windowMenu, 0, -1 );
671 createMenu( separator(), windowMenu, -1, 0 );
673 #ifndef DISABLE_GLVIEWER
674 createActionForViewer( NewGLViewId, newWinMenu, QString::number( 0 ), Qt::ALT+Qt::Key_G );
676 #ifndef DISABLE_PLOT2DVIEWER
677 createActionForViewer( NewPlot2dId, newWinMenu, QString::number( 1 ), Qt::ALT+Qt::Key_P );
679 #ifndef DISABLE_OCCVIEWER
680 createActionForViewer( NewOCCViewId, newWinMenu, QString::number( 2 ), Qt::ALT+Qt::Key_O );
682 #ifndef DISABLE_VTKVIEWER
683 createActionForViewer( NewVTKViewId, newWinMenu, QString::number( 3 ), Qt::ALT+Qt::Key_K );
685 #ifndef DISABLE_QXGRAPHVIEWER
686 //VSR: QxGraph has been replaced by QxScene
687 // createActionForViewer( NewQxGraphViewId, newWinMenu, QString::number( 4 ), Qt::ALT+Qt::Key_C );
688 createActionForViewer( NewQxSceneViewId, newWinMenu, QString::number( 4 ), Qt::ALT+Qt::Key_S );
691 createAction( RenameId, tr( "TOT_RENAME" ), QIcon(), tr( "MEN_DESK_RENAME" ), tr( "PRP_RENAME" ),
692 Qt::ALT+Qt::SHIFT+Qt::Key_R, desk, false, this, SLOT( onRenameWindow() ) );
693 createMenu( RenameId, windowMenu, -1 );
695 int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
696 createMenu( PreferencesId, fileMenu, 50, -1 );
697 createMenu( separator(), fileMenu, -1, 50, -1 );
699 createMenu( separator(), fileMenu, -1, 100, -1 );
700 createMenu( MRUId, fileMenu, 100, -1 );
701 createMenu( separator(), fileMenu, -1, 100, -1 );
703 createAction( StyleId, tr( "TOT_THEME" ), QIcon(), tr( "MEN_DESK_THEME" ), tr( "PRP_THEME" ),
704 0, desk, false, this, SLOT( onStylePreferences() ) );
706 createAction( FullScreenId, tr( "TOT_FULLSCREEN" ), QIcon(), tr( "MEN_DESK_FULLSCREEN" ), tr( "PRP_FULLSCREEN" ),
707 Qt::Key_F11, desk, false, this, SLOT( onFullScreen() ) );
710 int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1 );
711 createMenu( separator(), viewMenu, -1, 20, -1 );
712 createMenu( StyleId, viewMenu, 20, -1 );
713 createMenu( FullScreenId, viewMenu, 20, -1 );
715 int modTBar = createTool( tr( "INF_TOOLBAR_MODULES" ) );
716 createTool( ModulesListId, modTBar );
719 /*!On module activation action.*/
720 void LightApp_Application::onModuleActivation( const QString& modName )
722 // Force user to create/open a study before module activation
723 QMap<QString, QString> iconMap;
724 moduleIconNames( iconMap );
725 QPixmap icon = resourceMgr()->loadPixmap( moduleName( modName ), iconMap[ modName ], false );
727 icon = resourceMgr()->loadPixmap( "LightApp", tr( "APP_MODULE_BIG_ICO" ), false ); // default icon for any module
729 bool cancelled = false;
731 while ( !modName.isEmpty() && !activeStudy() && !cancelled ){
732 LightApp_ModuleDlg aDlg( desktop(), modName, icon );
733 QMap<int, QString> opmap = activateModuleActions();
734 for ( QMap<int, QString>::ConstIterator it = opmap.begin(); it != opmap.end(); ++it )
735 aDlg.addButton( it.value(), it.key() );
737 int res = aDlg.exec();
739 // some operation is selected
740 moduleActionSelected( res );
744 putInfo( tr("INF_CANCELLED") );
746 LightApp_ModuleAction* moduleAction =
747 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
749 moduleAction->setActiveModule( QString() );
755 activateModule( modName );
758 /*!Default module activation.*/
759 QString LightApp_Application::defaultModule() const
761 QStringList aModuleNames;
762 modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration
763 //! If there's the one and only module --> activate it automatically
764 //! TODO: Possible improvement - default module can be taken from preferences
765 return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" );
768 /*!On new window slot.*/
769 void LightApp_Application::onNewWindow()
771 const QObject* obj = sender();
772 if ( !obj || !obj->inherits( "QAction" ) )
776 int id = actionId( (QAction*)obj );
779 #ifndef DISABLE_GLVIEWER
781 type = GLViewer_Viewer::Type();
784 #ifndef DISABLE_PLOT2DVIEWER
786 type = Plot2d_Viewer::Type();
789 #ifndef DISABLE_OCCVIEWER
791 type = OCCViewer_Viewer::Type();
794 #ifndef DISABLE_VTKVIEWER
796 type = VTKViewer_Viewer::Type();
799 #ifndef DISABLE_QXGRAPHVIEWER
800 //VSR: QxGraph has been replaced by QxScene
801 // case NewQxGraphViewId:
802 // type = QxGraph_Viewer::Type();
804 case NewQxSceneViewId:
805 type = QxScene_Viewer::Type();
810 if ( !type.isEmpty() )
811 createViewManager( type );
815 SLOT: Creates new document
817 void LightApp_Application::onNewDoc()
819 //asl: fix for 0020515
821 saveDockWindowsState();
823 CAM_Application::onNewDoc();
827 SLOT: Opens new document
829 void LightApp_Application::onOpenDoc()
831 SUIT_Study* study = activeStudy();
832 saveDockWindowsState();
834 CAM_Application::onOpenDoc();
836 if ( !study ) // new study will be create in THIS application
839 updateViewManagers();
844 SLOT: Opens new document.
845 \param aName - name of file
847 bool LightApp_Application::onOpenDoc( const QString& aName )
849 // We should take mru action first because this application instance can be deleted later.
850 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
852 bool res = CAM_Application::onOpenDoc( aName );
857 mru->insert( aName );
859 mru->remove( aName );
865 SLOT: Displays "About" message box
867 void LightApp_Application::onHelpAbout()
869 LightApp_AboutDlg dlg( applicationName(), applicationVersion(), desktop() );
874 Private SLOT: Called on selection is changed
875 Dispatchs active module that selection is changed
877 void LightApp_Application::onSelection()
879 onSelectionChanged();
881 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
882 ((LightApp_Module*)activeModule())->selectionChanged();
887 \param study - SUIT_Study.
889 void LightApp_Application::setActiveStudy( SUIT_Study* study )
891 CAM_Application::setActiveStudy( study );
895 Enables/Disables menu items and toolbar buttons. Rebuild menu
897 void LightApp_Application::updateCommandsStatus()
899 CAM_Application::updateCommandsStatus();
902 #ifndef DISABLE_GLVIEWER
903 a = action( NewGLViewId );
905 a->setEnabled( activeStudy() );
908 #ifndef DISABLE_PLOT2DVIEWER
909 a = action( NewPlot2dId );
911 a->setEnabled( activeStudy() );
914 #ifndef DISABLE_OCCVIEWER
915 a = action( NewOCCViewId );
917 a->setEnabled( activeStudy() );
920 #ifndef DISABLE_VTKVIEWER
921 a = action( NewVTKViewId );
923 a->setEnabled( activeStudy() );
926 #ifndef DISABLE_QXGRAPHVIEWER
927 //VSR: QxGraph has been replaced by QxScene
928 // a = action( NewQxGraphViewId );
929 a = action( NewQxSceneViewId );
931 a->setEnabled( activeStudy() );
937 Runs system command in separate thread
939 class RunBrowser: public QThread
942 RunBrowser( LightApp_Application* app,
943 const QString& theApp,
944 const QString& theParams,
945 const QString& theHelpFile,
946 const QString& theContext = QString() )
948 myParams( theParams ),
949 myContext( theContext ),
953 //For the external browser always specify 'file://' protocol,
954 //because some WEB browsers (for example Mozilla Firefox) can't open local file without protocol.
955 myHelpFile = QString("file://%1").arg( QFileInfo( theHelpFile ).canonicalFilePath() );
960 if ( !myApp.isEmpty() && !myHelpFile.isEmpty()) {
961 QString aCommand = QString( "%1 %2 \"%3%4\"" ).arg( myApp, myParams, myHelpFile, myContext.isEmpty() ? QString("") : QString( "#%1" ).arg( myContext ) );
963 QProcess* proc = new QProcess();
965 proc->start( aCommand );
966 if ( !proc->waitForStarted() ) {
967 SALOME_CustomEvent* ce2000 = new SALOME_CustomEvent( 2000 );
968 QString* msg = new QString( QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).arg( myApp, myHelpFile ) );
969 ce2000->setData( msg );
970 QApplication::postEvent( myLApp, ce2000 );
981 LightApp_Application* myLApp;
985 SLOT: Displays help contents for choosen module
987 void LightApp_Application::onHelpContentsModule()
989 const QAction* a = (QAction*) sender();
990 QString helpFile = a->data().toString();
991 if ( helpFile.isEmpty() ) return;
993 SUIT_ResourceMgr* resMgr = resourceMgr();
996 platform = "winapplication";
998 platform = "application";
1000 QString anApp = resMgr->stringValue("ExternalBrowser", platform);
1002 QString quote("\"");
1003 anApp.prepend( quote );
1004 anApp.append( quote );
1006 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
1007 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1009 if( useExtBrowser ) {
1010 if ( !anApp.isEmpty() ) {
1011 RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile );
1015 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1016 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1017 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1019 showPreferences( tr( "PREF_APP" ) );
1024 // On Win32 platform QWebKit of the Qt 4.6.3 hang up in case 'file://' protocol
1025 // is defined. On Linux platform QWebKit doesn't work correctly without 'file://' protocol.
1026 QtxWebBrowser::loadUrl(helpFile);
1028 QtxWebBrowser::loadUrl(QString("file://%1").arg(helpFile));
1034 SLOT: Displays help contents for choosen dialog
1036 void LightApp_Application::onHelpContextModule( const QString& theComponentName,
1037 const QString& theFileName,
1038 const QString& theContext )
1040 QString fileName = theFileName;
1041 QString context = theContext;
1042 if ( !QFile::exists( fileName ) && theContext.isEmpty() ) {
1043 // context might be passed within theFileName argument
1044 QStringList comps = fileName.split("#");
1045 if ( comps.count() > 1 ) {
1046 context = comps.last();
1048 fileName = comps.join("#");
1052 QString homeDir = "";
1053 if ( !theComponentName.isEmpty() ) {
1054 QString dir = getenv( ( theComponentName + "_ROOT_DIR" ).toLatin1().constData() );
1055 if ( !dir.isEmpty() )
1056 homeDir = Qtx::addSlash( Qtx::addSlash( dir ) +
1057 Qtx::addSlash( "share" ) +
1058 Qtx::addSlash( "doc" ) +
1059 Qtx::addSlash( "salome" ) +
1060 Qtx::addSlash( "gui" ) +
1061 Qtx::addSlash( theComponentName ) );
1064 QString helpFile = QFileInfo( homeDir + fileName ).absoluteFilePath();
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 );
1079 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1082 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
1084 if ( !anApp.isEmpty() ) {
1085 RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile, context );
1089 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1090 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1091 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1092 showPreferences( tr( "PREF_APP" ) );
1097 // On Win32 platform QWebKit of the Qt 4.6.3 hang up in case 'file://' protocol
1098 // is defined. On Linux platform QWebKit doesn't work correctly without 'file://' protocol.
1099 QtxWebBrowser::loadUrl(helpFile, context);
1101 QtxWebBrowser::loadUrl(QString("file://%1").arg(helpFile),context);
1108 Sets enable or disable some actions on selection changed.
1110 void LightApp_Application::onSelectionChanged()
1112 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
1113 bool canCopy = m ? m->canCopy() : false;
1114 bool canPaste = m ? m->canPaste() : false;
1116 action( EditCopyId )->setEnabled(canCopy);
1117 action( EditPasteId )->setEnabled(canPaste);
1121 Adds window to application.
1122 \param wid - QWidget
1123 \param flag - key for window
1124 \param studyId - study id
1125 Flag used how identificator of window in windows list.
1128 void LightApp_Application::addWindow( QWidget* wid, const int flag, const int studyId )
1136 if ( !activeStudy() )
1139 sId = activeStudy()->id();
1142 if ( !myWindows.contains( flag ) )
1144 QMap<int, int> winMap;
1145 currentWindows( winMap );
1147 LightApp_WidgetContainer* newWC = new LightApp_WidgetContainer( flag, desktop() );
1148 connect( newWC, SIGNAL( destroyed ( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
1149 // asv: connecting a slot for storing visibility flag of a window
1150 connect( newWC, SIGNAL( visibilityChanged ( bool ) ), SLOT( onVisibilityChanged( bool ) ) );
1151 myWindows.insert( flag, newWC );
1152 if ( winMap.contains( flag ) ) {
1153 //desktop()->removeDockWidget( myWindows[flag] );
1154 desktop()->addDockWidget( (Qt::DockWidgetArea)winMap[flag], myWindows[flag] );
1157 //myWindows[flag]->setResizeEnabled( true );
1158 myWindows[flag]->setFeatures( QDockWidget::AllDockWidgetFeatures );
1159 myWindows[flag]->setObjectName( QString( "dock_window_%1" ).arg( flag ) );
1160 //myWindows[flag]->setFixedExtentWidth( wid->width() );
1161 //myWindows[flag]->setFixedExtentHeight( wid->height() );
1162 myWindows[flag]->resize( wid->width(), wid->height() );
1166 #ifndef DISABLE_PYCONSOLE
1167 if( wid->inherits( "PyConsole_Console" ) )
1169 if( resourceMgr()->hasValue( "PyConsole", "font" ) )
1170 f = resourceMgr()->fontValue( "PyConsole", "font" );
1173 f = ( ( PyConsole_Console* )wid )->font();
1174 resourceMgr()->setValue( "PyConsole", "font", f );
1181 myWindows[flag]->insert( sId, wid );
1184 setWindowShown( flag, !myWindows[flag]->isEmpty() );
1188 QWidget* LightApp_Application::dockWindow( const int id ) const
1191 if ( myWin.contains( id ) )
1196 QDockWidget* LightApp_Application::windowDock( QWidget* wid ) const
1201 QDockWidget* dock = 0;
1202 QWidget* w = wid->parentWidget();
1203 while ( w && !dock )
1205 dock = ::qobject_cast<QDockWidget*>( w );
1206 w = w->parentWidget();
1211 void LightApp_Application::insertDockWindow( const int id, QWidget* wid )
1216 if ( wid != dockWindow( id ) )
1217 removeDockWindow( id );
1219 myWin.insert( id, wid );
1221 QtxDockWidget* dock = new QtxDockWidget( true, desktop() );
1222 connect( dock, SIGNAL( destroyed( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
1224 dock->setFeatures( QDockWidget::AllDockWidgetFeatures );
1225 dock->setObjectName( QString( "window_%1" ).arg( id ) );
1226 dock->setWidget( wid );
1228 QKeySequence accel = wid->property( "shortcut" ).value<QKeySequence>();
1229 if ( !accel.isEmpty() )
1230 dock->toggleViewAction()->setShortcut( accel );
1235 void LightApp_Application::removeDockWindow( const int id )
1237 QWidget* wid = dockWindow( id );
1243 QDockWidget* dock = windowDock( wid );
1247 dock->setWidget( 0 );
1248 wid->setParent( 0 );
1249 wid->setVisible( false );
1253 void LightApp_Application::placeDockWindow( const int id, Qt::DockWidgetArea place )
1255 QDockWidget* dock = windowDock( dockWindow( id ) );
1256 if ( dock && desktop() ) {
1257 desktop()->addDockWidget( place, dock );
1258 QtxDockAction* a = qobject_cast<QtxDockAction*>( action( ViewWindowsId ) );
1259 if ( a ) a->update();
1265 \param flag - key for window
1266 \param studyId - study id
1267 Flag used how identificator of window in windows list.
1269 QWidget* LightApp_Application::getWindow( const int flag, const int )
1271 QWidget* wid = dockWindow( flag );
1273 insertDockWindow( flag, wid = createWindow( flag ) );
1275 QMap<int, int> winMap;
1276 currentWindows( winMap );
1277 if ( winMap.contains( flag ) )
1278 placeDockWindow( flag, (Qt::DockWidgetArea)winMap[flag] );
1284 \return Object Browser
1286 SUIT_DataBrowser* LightApp_Application::objectBrowser()
1288 return qobject_cast<SUIT_DataBrowser*>( dockWindow( WT_ObjectBrowser ) );
1294 LogWindow* LightApp_Application::logWindow()
1296 return qobject_cast<LogWindow*>( dockWindow( WT_LogWindow ) );
1299 #ifndef DISABLE_PYCONSOLE
1301 This returns the python console integrated to the GUI. Depending
1302 when you request the python console, this function could return
1303 null. Then the optional parameter force (default to false) can be
1304 set to force the creation of the python console if it is not done
1306 \param force - if true, the pythonConsole is created if it does not exist yet
1307 \return Python Console
1309 PyConsole_Console* LightApp_Application::pythonConsole(const bool force)
1311 QWidget* wid = dockWindow( WT_PyConsole );
1312 if ( !wid && force==true) {
1313 wid = getWindow(WT_PyConsole);
1315 return qobject_cast<PyConsole_Console*>( wid );
1320 Updates object browser and maybe data models
1321 \param updateModels - if it is true, then data models are updated
1323 void LightApp_Application::updateObjectBrowser( const bool updateModels )
1325 // update existing data models
1328 const bool isAutoUpdate = objectBrowser() ? objectBrowser()->autoUpdate() : true;
1329 if ( objectBrowser() )
1330 objectBrowser()->setAutoUpdate( false );
1332 LightApp_Study* study = dynamic_cast<LightApp_Study*>(activeStudy());
1334 CAM_Study::ModelList dm_list;
1335 study->dataModels( dm_list );
1336 QListIterator<CAM_DataModel*> it( dm_list );
1337 while ( it.hasNext() ) {
1338 CAM_DataModel* camDM = it.next();
1339 if ( camDM && camDM->inherits( "LightApp_DataModel" ) )
1340 ((LightApp_DataModel*)camDM)->update();
1344 if( objectBrowser() )
1345 objectBrowser()->setAutoUpdate( isAutoUpdate );
1348 if ( objectBrowser() ) {
1349 objectBrowser()->updateGeometry();
1350 objectBrowser()->updateTree( 0, false );
1357 LightApp_Preferences* LightApp_Application::preferences() const
1359 return preferences( false );
1363 \return first view manager of some type
1364 \param vmType - type of view manager
1365 \param create - is it necessary to create view manager in case, when there is no manager of such type
1367 SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, const bool create )
1369 SUIT_ViewManager* aVM = viewManager( vmType );
1370 SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
1372 if ( anActiveVM && anActiveVM->getType() == vmType )
1375 if ( aVM && create )
1377 if ( !aVM->getActiveView() )
1380 aVM->getActiveView()->setFocus();
1383 aVM = createViewManager( vmType );
1389 Creates view manager of some type
1390 \param vmType - type of view manager
1392 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType )
1394 SUIT_ResourceMgr* resMgr = resourceMgr();
1396 SUIT_ViewManager* viewMgr = 0;
1397 #ifndef DISABLE_GLVIEWER
1398 if( vmType == GLViewer_Viewer::Type() )
1400 viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() );
1401 new LightApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
1404 #ifndef DISABLE_PLOT2DVIEWER
1405 if( vmType == Plot2d_Viewer::Type() )
1407 viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
1409 #ifndef DISABLE_SALOMEOBJECT
1410 SPlot2d_Viewer* v = new SPlot2d_Viewer();
1412 new LightApp_Plot2dSelector( v, mySelMgr );
1414 vm = new Plot2d_Viewer();
1416 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1417 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
1420 Plot2d_ViewFrame* frame = wnd->getViewFrame();
1421 frame->setBackgroundColor( resMgr->colorValue( "Plot2d", "Background", frame->backgroundColor() ) );
1425 //#ifndef DISABLE_SUPERVGRAPHVIEWER
1426 // if( vmType == SUPERVGraph_Viewer::Type() )
1428 // viewMgr = new SUPERVGraph_ViewManager( activeStudy(), desktop(), new SUPERVGraph_Viewer() );
1431 #ifndef DISABLE_QXGRAPHVIEWER
1432 //VSR: QxGraph has been replaced by QxScene
1433 // if( vmType == QxGraph_Viewer::Type() )
1435 // viewMgr = new QxGraph_ViewManager( activeStudy(), desktop(), new QxGraph_Viewer() );
1437 if( vmType == QxScene_Viewer::Type() )
1439 viewMgr = new QxScene_ViewManager( activeStudy(), desktop() );
1440 QxScene_Viewer* vm = new QxScene_Viewer();
1441 viewMgr->setViewModel( vm );
1442 //QxScene_ViewWindow* wnd = dynamic_cast<QxScene_ViewWindow*>( viewMgr->getActiveView() );
1445 #ifndef DISABLE_OCCVIEWER
1446 if( vmType == OCCViewer_Viewer::Type() )
1448 viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
1449 OCCViewer_Viewer* vm;
1450 #ifndef DISABLE_SALOMEOBJECT
1451 vm = new SOCC_Viewer();
1453 vm = new OCCViewer_Viewer( true );
1455 vm->setBackground( OCCViewer_ViewFrame::TOP_LEFT,
1456 resMgr->backgroundValue( "OCCViewer", "xz_background", vm->background(OCCViewer_ViewFrame::TOP_LEFT) ) );
1457 vm->setBackground( OCCViewer_ViewFrame::TOP_RIGHT,
1458 resMgr->backgroundValue( "OCCViewer", "yz_background", vm->background(OCCViewer_ViewFrame::TOP_RIGHT) ) );
1459 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_LEFT,
1460 resMgr->backgroundValue( "OCCViewer", "xy_background", vm->background(OCCViewer_ViewFrame::BOTTOM_LEFT) ) );
1461 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_RIGHT,
1462 resMgr->backgroundValue( "OCCViewer", "background", vm->background(OCCViewer_ViewFrame::MAIN_VIEW) ) );
1464 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1465 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ));
1466 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1467 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1468 vm->enablePreselection( resMgr->booleanValue( "OCCViewer", "enable_preselection", vm->isPreselectionEnabled() ) );
1469 vm->enableSelection( resMgr->booleanValue( "OCCViewer", "enable_selection", vm->isSelectionEnabled() ) );
1471 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1472 new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
1475 #ifndef DISABLE_VTKVIEWER
1476 #ifndef DISABLE_SALOMEOBJECT
1477 if ( vmType == SVTK_Viewer::Type() )
1479 if ( vmType == VTKViewer_Viewer::Type() )
1482 #ifndef DISABLE_SALOMEOBJECT
1483 viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
1484 SVTK_Viewer* vm = dynamic_cast<SVTK_Viewer*>( viewMgr->getViewModel() );
1487 vm->setProjectionMode( resMgr->integerValue( "VTKViewer", "projection_mode", vm->projectionMode() ) );
1488 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1489 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1490 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ) );
1491 vm->setStaticTrihedronVisible( resMgr->booleanValue( "3DViewer", "show_static_trihedron", vm->isStaticTrihedronVisible() ) );
1492 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1493 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1494 vm->setPreSelectionMode(resMgr->integerValue( "VTKViewer", "preselection", vm->preSelectionMode() ) );
1495 vm->enableSelection( resMgr->booleanValue( "VTKViewer", "enable_selection", vm->isSelectionEnabled() ) );
1496 vm->setIncrementalSpeed( resMgr->integerValue( "VTKViewer", "speed_value", vm->incrementalSpeed() ),
1497 resMgr->integerValue( "VTKViewer", "speed_mode", vm->incrementalSpeedMode() ) );
1498 vm->setSpacemouseButtons( resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", vm->spacemouseBtn(1) ),
1499 resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", vm->spacemouseBtn(2) ),
1500 resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", vm->spacemouseBtn(3) ) );
1501 new LightApp_VTKSelector( vm, mySelMgr );
1504 viewMgr = new VTKViewer_ViewManager( activeStudy(), desktop() );
1505 VTKViewer_Viewer* vm = dynamic_cast<VTKViewer_Viewer*>( viewMgr->getViewModel() );
1507 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1515 addViewManager( viewMgr );
1516 SUIT_ViewWindow* viewWin = viewMgr->createViewWindow();
1518 if ( viewWin && desktop() ) {
1519 viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1520 viewWin->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1526 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, QWidget* w )
1528 SUIT_ResourceMgr* resMgr = resourceMgr();
1530 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
1532 new LightApp_WgViewModel( vmType, w ) );
1533 vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
1535 addViewManager( vm );
1536 SUIT_ViewWindow* vw = vm->createViewWindow();
1537 if ( vw && desktop() ) {
1538 vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1539 vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1542 if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
1543 myUserWmTypes << vmType;
1549 SLOT: Removes view manager from application
1551 void LightApp_Application::onCloseView( SUIT_ViewManager* theVM )
1553 removeViewManager( theVM );
1557 Protected SLOT: On study created.
1558 \param theStudy - just created study
1560 void LightApp_Application::onStudyCreated( SUIT_Study* theStudy )
1562 SUIT_DataObject* aRoot = 0;
1563 if ( theStudy && theStudy->root() )
1565 aRoot = theStudy->root();
1566 //aRoot->setName( tr( "DATA_MODELS" ) );
1569 getWindow( WT_ObjectBrowser );
1571 loadDockWindowsState();
1573 if ( objectBrowser() )
1574 objectBrowser()->setRoot( aRoot );
1576 activateModule( defaultModule() );
1578 if ( objectBrowser() )
1579 objectBrowser()->openLevels();
1583 Protected SLOT: On study opened.
1584 \param theStudy - just opened study
1586 void LightApp_Application::onStudyOpened( SUIT_Study* theStudy )
1588 SUIT_DataObject* aRoot = 0;
1589 if ( theStudy && theStudy->root() )
1591 aRoot = theStudy->root();
1595 getWindow( WT_ObjectBrowser );
1597 loadDockWindowsState();
1599 if ( objectBrowser() )
1600 objectBrowser()->setRoot( aRoot );
1602 activateModule( defaultModule() );
1604 if ( objectBrowser() )
1605 objectBrowser()->openLevels();
1610 /*!Protected SLOT. On study saved.*/
1611 void LightApp_Application::onStudySaved( SUIT_Study* s )
1613 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
1615 mru->insert( s->studyName() );
1620 /*!Protected SLOT. On study closed.*/
1621 void LightApp_Application::onStudyClosed( SUIT_Study* s )
1623 // stop auto-save timer
1624 myAutoSaveTimer->stop();
1626 // Bug 10396: clear selection
1627 mySelMgr->clearSelected();
1629 // Bug 12944: emit signal only after clear selection
1632 activateModule( "" );
1635 /*!Protected SLOT.On desktop activated.*/
1636 void LightApp_Application::onDesktopActivated()
1638 CAM_Application::onDesktopActivated();
1639 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>(activeModule());
1641 aModule->studyActivated();
1644 void LightApp_Application::studyOpened( SUIT_Study* s )
1646 CAM_Application::studyOpened( s );
1649 updateViewManagers();
1652 void LightApp_Application::studySaved( SUIT_Study* s )
1654 CAM_Application::studyOpened( s );
1655 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1656 if ( aResMgr && activeStudy() ) {
1657 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
1658 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
1662 void LightApp_Application::studyCreated( SUIT_Study* s )
1664 CAM_Application::studyCreated( s );
1667 updateViewManagers();
1670 /*!Gets file filter.
1671 *\retval QString "(*.bin)"
1673 QString LightApp_Application::getFileFilter() const
1681 Shows file dialog and return user selected file name
1683 QString LightApp_Application::getFileName( bool open, const QString& initial, const QString& filters,
1684 const QString& caption, QWidget* parent )
1688 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1689 return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
1692 /*! Gets directory*/
1693 QString LightApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
1697 return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true );
1700 /*! Get open file names*/
1701 QStringList LightApp_Application::getOpenFileNames( const QString& initial, const QString& filters,
1702 const QString& caption, QWidget* parent )
1706 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1707 return SUIT_FileDlg::getOpenFileNames( parent, initial, fls, caption, true );
1710 /*!Private SLOT. Update object browser.*/
1711 void LightApp_Application::onRefresh()
1713 updateObjectBrowser( true );
1716 /*!Private SLOT. Support drag-and-drop operation.*/
1717 void LightApp_Application::onDropped( const QList<SUIT_DataObject*>& objects, SUIT_DataObject* parent, int row, Qt::DropAction action )
1719 LightApp_DataObject* parentObj = dynamic_cast<LightApp_DataObject*>( parent );
1723 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>( parentObj->module() );
1725 aModule->dropObjects( objects, parentObj, row, action );
1728 /*!Private SLOT. On preferences.*/
1729 void LightApp_Application::onPreferences()
1731 showPreferences( activeModule() ? activeModule()->moduleName() : tr( "PREF_CATEGORY_SALOME" ) );
1734 /*!Private SLOT. On preferences.*/
1735 void LightApp_Application::showPreferences( const QString& itemText )
1737 QApplication::setOverrideCursor( Qt::WaitCursor );
1739 LightApp_PreferencesDlg* prefDlg = new LightApp_PreferencesDlg( preferences( true ), desktop());
1741 QApplication::restoreOverrideCursor();
1746 preferences()->activateItem( itemText );
1748 if ( ( prefDlg->exec() == QDialog::Accepted || prefDlg->isSaved() ) && resourceMgr() )
1751 resourceMgr()->setValue( "desktop", "geometry", desktop()->storeGeometry() );
1752 resourceMgr()->save();
1755 shortcutMgr()->updateShortcuts();
1761 /*!Protected SLOT. On preferences changed.*/
1762 void LightApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param )
1764 LightApp_Module* sMod = 0;
1765 CAM_Module* mod = module( modName );
1766 if ( mod && mod->inherits( "LightApp_Module" ) )
1767 sMod = (LightApp_Module*)mod;
1770 sMod->preferencesChanged( section, param );
1772 preferencesChanged( section, param );
1773 // emit signal to allow additional preferences changing processing
1774 emit preferenceChanged( modName, section, param );
1777 /*!Remove all windows from study.*/
1778 void LightApp_Application::beforeCloseDoc( SUIT_Study* s )
1780 CAM_Application::beforeCloseDoc( s );
1783 /*!Update actions.*/
1784 void LightApp_Application::updateActions()
1786 updateCommandsStatus();
1792 SUIT_Study* LightApp_Application::createNewStudy()
1794 LightApp_Application::lastStudyId++;
1796 LightApp_Study* aStudy = new LightApp_Study( this );
1798 // Set up processing of major study-related events
1799 connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
1800 connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
1801 connect( aStudy, SIGNAL( saved ( SUIT_Study* ) ), this, SLOT( onStudySaved ( SUIT_Study* ) ) );
1802 connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
1808 Creates window by flag.
1809 \param flag - identificator of window type
1811 QWidget* LightApp_Application::createWindow( const int flag )
1815 SUIT_ResourceMgr* resMgr = resourceMgr();
1817 if ( flag == WT_ObjectBrowser )
1819 SUIT_DataBrowser* ob = new SUIT_DataBrowser( new LightApp_DataObject(), desktop() );
1820 ob->setSortMenuEnabled( true );
1821 ob->setAutoUpdate( true );
1822 if ( resMgr->hasValue( "ObjectBrowser", "auto_hide_search_tool" ) )
1823 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
1825 //ob->setAutoOpenLevel( 1 ); // commented by ASV as a fix to bug IPAL10107
1826 ob->setWindowTitle( tr( "OBJECT_BROWSER" ) );
1827 connect( ob, SIGNAL( requestUpdate() ), this, SLOT( onRefresh() ) );
1829 QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
1830 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
1831 treeModel->setSearcher( this );
1832 treeModel->registerColumn( 0, EntryCol, LightApp_DataObject::EntryId );
1833 treeModel->setAppropriate( EntryCol, Qtx::Toggled );
1835 // Mantis issue 0020136: Drag&Drop in OB
1836 SUIT_ProxyModel* proxyModel = dynamic_cast<SUIT_ProxyModel*>(treeModel);
1838 connect( proxyModel, SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
1839 this, SLOT( onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
1842 // temporary commented
1844 OB_ListView* ob_list = dynamic_cast<OB_ListView*>( const_cast<QListView*>( ob->listView() ) );
1846 ob_list->setColumnMaxWidth( 0, desktop()->width()/4 );
1848 ob->setFilter( new LightApp_OBFilter( selectionMgr() ) );
1851 // Create OBSelector
1852 new LightApp_OBSelector( ob, mySelMgr );
1854 ob->treeView()->header()->setResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
1855 ob->treeView()->header()->moveSection(SUIT_DataObject::NameId,SUIT_DataObject::VisibilityId);
1856 ob->treeView()->setColumnWidth(SUIT_DataObject::VisibilityId, VISIBILITY_COLUMN_WIDTH);
1857 ob->setProperty( "shortcut", QKeySequence( "Alt+Shift+O" ) );
1859 ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1861 #ifndef DISABLE_PYCONSOLE
1862 else if ( flag == WT_PyConsole )
1864 PyConsole_Console* pyCons = new PyConsole_EnhConsole( desktop(),new LightApp_PyInterp());
1865 pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
1866 pyCons->setFont(resourceMgr()->fontValue( "PyConsole", "font" ));
1867 pyCons->setIsShowBanner(resourceMgr()->booleanValue( "PyConsole", "show_banner", true ));
1868 pyCons->setProperty( "shortcut", QKeySequence( "Alt+Shift+P" ) );
1871 pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1874 else if ( flag == WT_LogWindow )
1876 LogWindow* logWin = new LogWindow( desktop() );
1877 logWin->setWindowTitle( tr( "LOG_WINDOW" ) );
1878 logWin->setProperty( "shortcut", QKeySequence( "Alt+Shift+L" ) );
1880 logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1886 \return default windows( Object Browser, Python Console )
1887 Adds to map \a aMap.
1889 void LightApp_Application::defaultWindows( QMap<int, int>& aMap ) const
1891 aMap.insert( WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1892 #ifndef DISABLE_PYCONSOLE
1893 aMap.insert( WT_PyConsole, Qt::BottomDockWidgetArea );
1895 // aMap.insert( WT_LogWindow, Qt::DockBottom );
1898 /*!Default view managers*/
1899 void LightApp_Application::defaultViewManagers( QStringList& ) const
1905 \return preferences.
1906 Create preferences, if \a crt = true.
1908 LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const
1913 LightApp_Application* that = (LightApp_Application*)this;
1915 bool toCreate = !_prefs_ && crt;
1918 _prefs_ = new LightApp_Preferences( resourceMgr() );
1919 that->createPreferences( _prefs_ );
1922 that->myPrefs = _prefs_;
1924 connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
1925 this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ) );
1930 SUIT_ResourceMgr* resMgr = resourceMgr();
1932 QList<SUIT_Application*> appList = SUIT_Session::session()->applications();
1933 for ( QList<SUIT_Application*>::iterator appIt = appList.begin(); appIt != appList.end(); ++appIt )
1935 LightApp_Application* app = ::qobject_cast<LightApp_Application*>( *appIt );
1939 QStringList modNameList;
1940 app->modules( modNameList, false );
1942 QMap<QString, QString> iconMap;
1943 app->moduleIconNames( iconMap );
1945 for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it )
1947 if ( !app->isLibExists( *it ) || _prefs_->hasModule( *it ) )
1950 int modId = _prefs_->addPreference( *it );
1951 if ( iconMap.contains( *it ) )
1952 _prefs_->setItemIcon( modId, Qtx::scaleIcon( resMgr->loadPixmap( moduleName( *it ), iconMap[*it], false ), 20 ) );
1956 app->modules( modList );
1957 QListIterator<CAM_Module*> itr( modList );
1958 while ( itr.hasNext() )
1960 LightApp_Module* mod = 0;
1962 CAM_Module* anItem = itr.next();
1963 if ( anItem->inherits( "LightApp_Module" ) )
1964 mod = (LightApp_Module*)anItem;
1966 if ( mod && !_prefs_->hasModule( mod->moduleName() ) )
1968 _prefs_->addPreference( mod->moduleName() );
1969 mod->createPreferences();
1970 that->emptyPreferences( mod->moduleName() );
1974 _prefs_->setItemProperty( "info", tr( "PREFERENCES_NOT_LOADED" ) );
1980 Adds new module to application
1982 void LightApp_Application::moduleAdded( CAM_Module* mod )
1984 CAM_Application::moduleAdded( mod );
1986 LightApp_Module* lightMod = 0;
1987 if ( mod && mod->inherits( "LightApp_Module" ) )
1988 lightMod = (LightApp_Module*)mod;
1990 if ( myPrefs && lightMod && !myPrefs->hasModule( lightMod->moduleName() ))
1992 myPrefs->addPreference( mod->moduleName() );
1993 lightMod->createPreferences();
1994 emptyPreferences( mod->moduleName() );
1998 void LightApp_Application::emptyPreferences( const QString& modName )
2000 QtxPreferenceItem* item = myPrefs->findItem( modName, true );
2001 if ( !item || !item->isEmpty() )
2004 // printf( "---------------------> Modify for empty module.\n" );
2006 QtxPagePrefFrameItem* frm = new QtxPagePrefFrameItem( item->title(), item->parentItem() );
2007 frm->setIcon( item->icon() );
2008 frm->setStretch( false );
2009 item->parentItem()->insertItem( frm, item );
2010 new QtxPagePrefLabelItem( Qt::AlignCenter, tr( "PREFERENCES_NOT_SUPPORTED" ).arg( modName ), frm );
2017 void LightApp_Application::createPreferences( LightApp_Preferences* pref )
2022 QStringList aValuesList;
2023 QList<QVariant> anIndicesList;
2027 // . Top-level "SALOME" preferences group <<start>>
2028 int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
2029 pref->setItemIcon( salomeCat, Qtx::scaleIcon( resourceMgr()->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false ), 20 ) );
2031 // .. "General" preferences tab <<start>>
2032 int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat );
2034 // ... "Language" group <<start>>
2035 int langGroup = pref->addPreference( tr( "PREF_GROUP_LANGUAGE" ), genTab );
2036 pref->setItemProperty( "columns", 2, langGroup );
2037 // .... -> application language
2038 int curLang = pref->addPreference( tr( "PREF_CURRENT_LANGUAGE" ), langGroup,
2039 LightApp_Preferences::Selector, "language", "language" );
2040 QStringList aLangs = SUIT_Session::session()->resourceMgr()->stringValue( "language", "languages", "en" ).split( "," );
2041 QList<QVariant> aIcons;
2042 foreach ( QString aLang, aLangs ) {
2043 aIcons << QPixmap( QString( ":/images/%1" ).arg( aLang ) );
2045 pref->setItemProperty( "strings", aLangs, curLang );
2046 pref->setItemProperty( "icons", aIcons, curLang );
2047 // ... "Language" group <<end>>
2049 // ... "Look and feel" group <<start>>
2050 int lookGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), genTab );
2051 pref->setItemProperty( "columns", 2, lookGroup );
2052 // .... -> show splash-screen
2053 pref->addPreference( tr( "PREF_SHOW_SPLASH" ), lookGroup, LightApp_Preferences::Bool, "launch", "splash" );
2054 // .... -> opaque resize
2055 pref->addPreference( tr( "PREF_OPAQUE_RESIZE" ), lookGroup, LightApp_Preferences::Bool, "desktop", "opaque_resize" );
2056 // .... -> drop-down buttons
2057 pref->addPreference( tr( "PREF_DROP_DOWN_BUTTONS" ), lookGroup, LightApp_Preferences::Bool, "viewers", "drop_down_buttons" );
2058 // ... "Look and feel" group <<end>>
2060 // ... "Study properties" group <<start>>
2061 int studyGroup = pref->addPreference( tr( "PREF_GROUP_STUDY" ), genTab );
2062 pref->setItemProperty( "columns", 2, studyGroup );
2063 // .... -> multi-file save
2064 pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "multi_file" );
2065 // .... -> ascii save mode
2066 pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" );
2067 // .... -> store windows geometry
2068 pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" );
2069 // .... -> auto-save
2070 int autoSaveInterval = pref->addPreference( tr( "PREF_AUTO_SAVE" ), studyGroup,
2071 LightApp_Preferences::IntSpin, "Study", "auto_save_interval" );
2072 pref->setItemProperty( "min", 0, autoSaveInterval );
2073 pref->setItemProperty( "max", 1440, autoSaveInterval );
2074 pref->setItemProperty( "special", tr( "PREF_AUTO_SAVE_DISABLED" ), autoSaveInterval );
2075 // ... "Study properties" group <<end>>
2077 // ... "Help browser" group <<start>>
2078 int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab, LightApp_Preferences::Auto, "ExternalBrowser", "use_external_browser");
2080 QString platform = "winapplication";
2082 QString platform = "application";
2084 // .... -> browser application
2085 int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, LightApp_Preferences::File, "ExternalBrowser", platform );
2086 pref->setItemProperty( "mode", Qtx::PT_OpenFile, apppref );
2087 // .... -> browser parameters
2088 pref->addPreference( tr( "PREF_PARAM" ), extgroup, LightApp_Preferences::String, "ExternalBrowser", "parameters" );
2089 // ... "Help browser" group <<end>>
2091 // ... "Python console properties" group <<start>>
2092 int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab );
2094 pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, LightApp_Preferences::Font, "PyConsole", "font" );
2095 // .... -> show banner
2096 pref->addPreference( tr( "PREF_SHOW_BANNER" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "show_banner" );
2097 // ... "Python console properties" group <<end>>
2099 // ... "MRU" preferences group <<start>>
2100 int mruGroup = pref->addPreference( tr( "PREF_GROUP_MRU" ), genTab, LightApp_Preferences::Auto, "MRU", "show_mru" );
2101 pref->setItemProperty( "columns", 4, mruGroup );
2102 // number of MRU items
2103 int mruVisCount = pref->addPreference( tr( "PREF_MRU_VISIBLE_COUNT" ), mruGroup, LightApp_Preferences::IntSpin,
2104 "MRU", "visible_count" );
2105 pref->setItemProperty( "min", 0, mruVisCount );
2106 pref->setItemProperty( "max", 100, mruVisCount );
2108 int mruLinkType = pref->addPreference( tr( "PREF_MRU_LINK_TYPE" ), mruGroup, LightApp_Preferences::Selector,
2109 "MRU", "link_type" );
2110 aValuesList.clear();
2111 anIndicesList.clear();
2112 aValuesList << tr("PREF_MRU_LINK_AUTO") << tr("PREF_MRU_LINK_SHORT") << tr("PREF_MRU_LINK_FULL");
2113 anIndicesList << 0 << 1 << 2 ;
2114 pref->setItemProperty( "strings", aValuesList, mruLinkType );
2115 pref->setItemProperty( "indexes", anIndicesList, mruLinkType );
2116 // ... "MRU" preferences group <<end>>
2117 // .. "General" preferences tab <<end>>
2119 // .. "3D viewer" group <<start>>
2120 int Viewer3DGroup = pref->addPreference( tr( "PREF_GROUP_3DVIEWER" ), salomeCat );
2121 // ... -> navigation mode
2122 int vtkStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), Viewer3DGroup,
2123 LightApp_Preferences::Selector, "3DViewer", "navigation_mode" );
2124 aValuesList.clear();
2125 anIndicesList.clear();
2126 aValuesList << tr("PREF_STANDARD_STYLE") << tr("PREF_KEYFREE_STYLE");
2127 anIndicesList << 0 << 1;
2128 pref->setItemProperty( "strings", aValuesList, vtkStyleMode );
2129 pref->setItemProperty( "indexes", anIndicesList, vtkStyleMode );
2130 // ... -> zooming mode
2131 #if OCC_VERSION_LARGE > 0x0603000A // available only with OCC-6.3-sp11 and higher version
2132 int occZoomingStyleMode = pref->addPreference( tr( "PREF_ZOOMING" ), Viewer3DGroup,
2133 LightApp_Preferences::Selector, "3DViewer", "zooming_mode" );
2134 aValuesList.clear();
2135 anIndicesList.clear();
2136 aValuesList << tr("PREF_ZOOMING_AT_CENTER") << tr("PREF_ZOOMING_AT_CURSOR");
2137 anIndicesList << 0 << 1;
2138 pref->setItemProperty( "strings", aValuesList, occZoomingStyleMode );
2139 pref->setItemProperty( "indexes", anIndicesList, occZoomingStyleMode );
2141 // ... "Trihedron" group <<start>>
2142 int occTriGroup = pref->addPreference( tr( "PREF_TRIHEDRON" ), Viewer3DGroup );
2143 pref->setItemProperty( "columns", 2, occTriGroup );
2144 // .... -> trihedron size
2145 int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occTriGroup,
2146 LightApp_Preferences::DblSpin, "3DViewer", "trihedron_size" );
2147 pref->setItemProperty( "min", 1.0E-06, occTS );
2148 pref->setItemProperty( "max", 1000, occTS );
2149 // .... -> relative size of trihedron
2150 pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "relative_size" );
2151 // .... -> show static trihedron
2152 pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "show_static_trihedron" );
2153 // ... "Trihedron" group <<end>>
2154 // .. "3D viewer" group <<end>>
2156 // .. "OCC viewer" group <<start>>
2157 int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), salomeCat );
2159 // ... "Background" group <<start>>
2160 int bgGroup = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup );
2161 // pref->setItemProperty( "columns", 2, bgGroup );
2162 aValuesList.clear();
2163 anIndicesList.clear();
2165 QString formats = OCCViewer_Viewer::backgroundData( aValuesList, idList, txtList );
2166 foreach( int gid, idList ) anIndicesList << gid;
2167 // .... -> 3D viewer background
2168 int bgId = pref->addPreference( tr( "PREF_3DVIEWER_BACKGROUND" ), bgGroup,
2169 LightApp_Preferences::Background, "OCCViewer", "background" );
2170 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2171 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2172 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2173 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2174 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2175 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2176 pref->setItemProperty( "custom_enabled", false, bgId );
2177 pref->setItemProperty( "image_formats", formats, bgId );
2178 // .... -> XZ viewer background
2179 bgId = pref->addPreference( tr( "PREF_XZVIEWER_BACKGROUND" ), bgGroup,
2180 LightApp_Preferences::Background, "OCCViewer", "xz_background" );
2181 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2182 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2183 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2184 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2185 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2186 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2187 pref->setItemProperty( "custom_enabled", false, bgId );
2188 pref->setItemProperty( "image_formats", formats, bgId );
2189 // .... -> YZ viewer background
2190 bgId = pref->addPreference( tr( "PREF_YZVIEWER_BACKGROUND" ), bgGroup,
2191 LightApp_Preferences::Background, "OCCViewer", "yz_background" );
2192 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2193 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2194 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2195 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2196 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2197 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2198 pref->setItemProperty( "custom_enabled", false, bgId );
2199 pref->setItemProperty( "image_formats", formats, bgId );
2200 // .... -> XY viewer background
2201 bgId = pref->addPreference( tr( "PREF_XYVIEWER_BACKGROUND" ), bgGroup,
2202 LightApp_Preferences::Background, "OCCViewer", "xy_background" );
2203 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2204 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2205 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2206 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2207 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2208 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2209 pref->setItemProperty( "custom_enabled", false, bgId );
2210 pref->setItemProperty( "image_formats", formats, bgId );
2211 // ... "Background" group <<end>>
2214 // ... "Selection" group <<start>>
2215 int occSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), occGroup );
2216 pref->setItemProperty( "columns", 2, occSelectionGroup );
2217 // .... -> enable preselection
2218 pref->addPreference( tr( "PREF_ENABLE_PRESELECTION" ), occSelectionGroup,
2219 LightApp_Preferences::Bool, "OCCViewer", "enable_preselection" );
2220 // .... -> enable selection
2221 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), occSelectionGroup,
2222 LightApp_Preferences::Bool, "OCCViewer", "enable_selection" );
2223 // ... "Selection" group <<end>>
2225 // ... -> empty frame (for layout) <<start>>
2226 int occGen = pref->addPreference( "", occGroup, LightApp_Preferences::Frame );
2227 pref->setItemProperty( "margin", 0, occGen );
2228 pref->setItemProperty( "columns", 2, occGen );
2229 // ... -> empty frame (for layout) <<end>>
2230 // .. "OCC viewer" group <<end>>
2232 // .. "VTK viewer" group <<start>>
2233 int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), salomeCat ); //viewTab
2235 // ... -> empty frame (for layout) <<start>>
2236 int vtkGen = pref->addPreference( "", vtkGroup, LightApp_Preferences::Frame );
2237 //pref->setItemProperty( "columns", 2, vtkGen );
2238 // .... -> projection mode
2239 int vtkProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), vtkGen,
2240 LightApp_Preferences::Selector, "VTKViewer", "projection_mode" );
2241 aValuesList.clear();
2242 anIndicesList.clear();
2243 aValuesList << tr("PREF_ORTHOGRAPHIC") << tr("PREF_PERSPECTIVE");
2244 anIndicesList << 0 << 1;
2245 pref->setItemProperty( "strings", aValuesList, vtkProjMode );
2246 pref->setItemProperty( "indexes", anIndicesList, vtkProjMode );
2247 // .... -> background
2248 aValuesList.clear();
2249 anIndicesList.clear();
2251 formats = SVTK_Viewer::backgroundData( aValuesList, idList, txtList );
2252 foreach( int gid, idList ) anIndicesList << gid;
2253 bgId = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGen,
2254 LightApp_Preferences::Background, "VTKViewer", "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 // .... -> speed increment
2264 int vtkSpeed = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED" ), vtkGen,
2265 LightApp_Preferences::IntSpin, "VTKViewer", "speed_value" );
2266 pref->setItemProperty( "min", 1, vtkSpeed );
2267 pref->setItemProperty( "max", 1000, vtkSpeed );
2268 // .... -> speed mode
2269 int vtkSpeedMode = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED_MODE" ), vtkGen,
2270 LightApp_Preferences::Selector, "VTKViewer", "speed_mode" );
2271 aValuesList.clear();
2272 anIndicesList.clear();
2273 aValuesList << tr("PREF_ARITHMETIC") << tr("PREF_GEOMETRICAL");
2274 anIndicesList << 0 << 1;
2275 pref->setItemProperty( "strings", aValuesList, vtkSpeedMode );
2276 pref->setItemProperty( "indexes", anIndicesList, vtkSpeedMode );
2278 // ... "Selection" group <<start>>
2279 int vtkSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), vtkGroup );
2280 pref->setItemProperty( "columns", 2, vtkSelectionGroup );
2281 // .... -> preselection
2282 int vtkPreselection = pref->addPreference( tr( "PREF_PRESELECTION" ), vtkSelectionGroup,
2283 LightApp_Preferences::Selector, "VTKViewer", "preselection" );
2284 aValuesList.clear();
2285 anIndicesList.clear();
2286 aValuesList << tr("PREF_PRESELECTION_STANDARD") << tr("PREF_PRESELECTION_DYNAMIC") << tr("PREF_PRESELECTION_DISABLED");
2287 anIndicesList << 0 << 1 << 2;
2288 pref->setItemProperty( "strings", aValuesList, vtkPreselection );
2289 pref->setItemProperty( "indexes", anIndicesList, vtkPreselection );
2290 // .... -> enable selection
2291 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), vtkSelectionGroup, LightApp_Preferences::Bool, "VTKViewer", "enable_selection" );
2292 // ... "Selection" group <<end>>
2294 // ... -> empty frame (for layout) <<end>>
2296 // ... space mouse sub-group <<start>>
2297 int vtkSM = pref->addPreference( tr( "PREF_FRAME_SPACEMOUSE" ), vtkGroup, LightApp_Preferences::GroupBox );
2298 //pref->setItemProperty( "columns", 2, vtkSM );
2299 // .... -> decrease speed increment
2300 int spacemousePref1 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_1" ), vtkSM,
2301 LightApp_Preferences::Selector, "VTKViewer",
2302 "spacemouse_func1_btn" );
2303 // .... -> increase speed increment
2304 int spacemousePref2 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_2" ), vtkSM,
2305 LightApp_Preferences::Selector, "VTKViewer",
2306 "spacemouse_func2_btn" );
2307 // .... -> dominant / combined switch
2308 int spacemousePref3 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_3" ), vtkSM,
2309 LightApp_Preferences::Selector, "VTKViewer",
2310 "spacemouse_func5_btn" ); //
2311 aValuesList.clear();
2312 anIndicesList.clear();
2313 aValuesList << tr( "PREF_SPACEMOUSE_BTN_1" ) << tr( "PREF_SPACEMOUSE_BTN_2" ) << tr( "PREF_SPACEMOUSE_BTN_3" );
2314 aValuesList << tr( "PREF_SPACEMOUSE_BTN_4" ) << tr( "PREF_SPACEMOUSE_BTN_5" ) << tr( "PREF_SPACEMOUSE_BTN_6" );
2315 aValuesList << tr( "PREF_SPACEMOUSE_BTN_7" ) << tr( "PREF_SPACEMOUSE_BTN_8" ) << tr( "PREF_SPACEMOUSE_BTN_*" );
2316 aValuesList << tr( "PREF_SPACEMOUSE_BTN_10" ) << tr( "PREF_SPACEMOUSE_BTN_11" );
2317 anIndicesList << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11;
2318 pref->setItemProperty( "strings", aValuesList, spacemousePref1 );
2319 pref->setItemProperty( "indexes", anIndicesList, spacemousePref1 );
2320 pref->setItemProperty( "strings", aValuesList, spacemousePref2 );
2321 pref->setItemProperty( "indexes", anIndicesList, spacemousePref2 );
2322 pref->setItemProperty( "strings", aValuesList, spacemousePref3 );
2323 pref->setItemProperty( "indexes", anIndicesList, spacemousePref3 );
2324 // ... space mouse sub-group <<end>>
2326 // ... avi recording sub-group <<start>>
2327 int vtkRec = pref->addPreference( tr( "PREF_FRAME_RECORDING" ), vtkGroup, LightApp_Preferences::GroupBox );
2328 pref->setItemProperty( "columns", 2, vtkRec );
2329 // .... -> recording mode
2330 int modePref = pref->addPreference( tr( "PREF_RECORDING_MODE" ), vtkRec,
2331 LightApp_Preferences::Selector, "VTKViewer", "recorder_mode" );
2332 aValuesList.clear();
2333 anIndicesList.clear();
2334 aValuesList << tr( "PREF_SKIPPED_FRAMES" ) << tr( "PREF_ALL_DISLPAYED_FRAMES" );
2335 anIndicesList << 0 << 1;
2336 pref->setItemProperty( "strings", aValuesList, modePref );
2337 pref->setItemProperty( "indexes", anIndicesList, modePref );
2339 int fpsPref = pref->addPreference( tr( "PREF_FPS" ), vtkRec,
2340 LightApp_Preferences::DblSpin, "VTKViewer", "recorder_fps" );
2341 pref->setItemProperty( "min", 0.1, fpsPref );
2342 pref->setItemProperty( "max", 100, fpsPref );
2344 int qualityPref = pref->addPreference( tr( "PREF_QUALITY" ), vtkRec,
2345 LightApp_Preferences::IntSpin, "VTKViewer", "recorder_quality" );
2346 pref->setItemProperty( "min", 1, qualityPref );
2347 pref->setItemProperty( "max", 100, qualityPref );
2348 // .... -> progressive mode
2349 pref->addPreference( tr( "PREF_PROGRESSIVE" ), vtkRec,
2350 LightApp_Preferences::Bool, "VTKViewer", "recorder_progressive" );
2351 // ... avi recording sub-group <<end>>
2353 // ... group names sub-group <<start>>
2354 int vtkGN = pref->addPreference( tr( "PREF_FRAME_GROUP_NAMES" ), vtkGroup,
2355 LightApp_Preferences::GroupBox, "VTKViewer", "show_group_names" );
2356 pref->setItemProperty( "columns", 2, vtkGN );
2357 // .... -> text color
2358 pref->addPreference( tr( "PREF_GROUP_NAMES_TEXT_COLOR" ), vtkGN,
2359 LightApp_Preferences::Color, "VTKViewer", "group_names_text_color" );
2360 // .... -> transparency
2361 int transPref = pref->addPreference( tr( "PREF_GROUP_NAMES_TRANSPARENCY" ), vtkGN,
2362 LightApp_Preferences::DblSpin, "VTKViewer", "group_names_transparency" );
2363 pref->setItemProperty( "min", 0.0, transPref );
2364 pref->setItemProperty( "max", 1.0, transPref );
2365 pref->setItemProperty( "step", 0.1, transPref );
2366 // ... -> group names sub-group <<end>>
2367 // .. "VTK viewer" group <<end>>
2369 // .. "Plot2d viewer" group <<start>>
2370 int plot2dGroup = pref->addPreference( tr( "PREF_GROUP_PLOT2DVIEWER" ), salomeCat ); //viewTab
2371 //pref->setItemProperty( "columns", 2, plot2dGroup );
2373 // ... -> show legend
2374 pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dGroup,
2375 LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
2376 // ... -> legend position
2377 int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dGroup,
2378 LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
2379 aValuesList.clear();
2380 anIndicesList.clear();
2381 aValuesList << tr("PREF_LEFT") << tr("PREF_RIGHT") << tr("PREF_TOP") << tr("PREF_BOTTOM");
2382 anIndicesList << 0 << 1 << 2 << 3 ;
2383 pref->setItemProperty( "strings", aValuesList, legendPosition );
2384 pref->setItemProperty( "indexes", anIndicesList, legendPosition );
2385 // ... -> legend font
2386 pref->addPreference( tr( "PREF_LEGEND_FONT" ), plot2dGroup, LightApp_Preferences::Font, "Plot2d", "LegendFont" );
2387 // ... -> curve type
2388 int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dGroup,
2389 LightApp_Preferences::Selector, "Plot2d", "CurveType" );
2390 aValuesList.clear();
2391 anIndicesList.clear();
2392 aValuesList << tr("PREF_POINTS") << tr("PREF_LINES") << tr("PREF_SPLINE");
2393 anIndicesList << 0 << 1 << 2 ;
2394 pref->setItemProperty( "strings", aValuesList, curveType );
2395 pref->setItemProperty( "indexes", anIndicesList, curveType );
2396 // ... -> marker size
2397 int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dGroup,
2398 LightApp_Preferences::IntSpin, "Plot2d", "MarkerSize" );
2399 pref->setItemProperty( "min", 0, markerSize );
2400 pref->setItemProperty( "max", 100, markerSize );
2401 // ... -> horizontal scaling mode
2402 int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dGroup,
2403 LightApp_Preferences::Selector, "Plot2d", "HorScaleMode" );
2404 aValuesList.clear();
2405 anIndicesList.clear();
2406 aValuesList << tr("PREF_LINEAR") << tr("PREF_LOGARITHMIC");
2407 anIndicesList << 0 << 1 ;
2408 pref->setItemProperty( "strings", aValuesList, horScale );
2409 pref->setItemProperty( "indexes", anIndicesList, horScale );
2410 // ... -> vertical scaling mode
2411 int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dGroup,
2412 LightApp_Preferences::Selector, "Plot2d", "VerScaleMode" );
2413 pref->setItemProperty( "strings", aValuesList, verScale );
2414 pref->setItemProperty( "indexes", anIndicesList, verScale );
2415 // ... -> background
2416 pref->addPreference( tr( "PREF_VIEWER_BACKGROUND_COLOR" ), plot2dGroup,
2417 LightApp_Preferences::Color, "Plot2d", "Background" );
2418 // ... -> font color
2419 pref->addPreference( tr( "PREF_FONT_COLOR" ), plot2dGroup, LightApp_Preferences::Color, "Plot2d", "LegendFontColor" );
2420 // ... -> selection font color
2421 pref->addPreference( tr( "PREF_SELECTED_FONT_COLOR" ), plot2dGroup, LightApp_Preferences::Color, "Plot2d", "SelectedLegendFontColor" );
2422 // ... -> selection color
2423 pref->addPreference( tr( "PREF_VIEWER_SELECTION" ), plot2dGroup,
2424 LightApp_Preferences::Color, "Plot2d", "SelectionColor" );
2425 // ... -> errors/deviation colot
2426 pref->addPreference( tr( "PREF_DEVIATION_COLOR" ), plot2dGroup,
2427 LightApp_Preferences::Color, "Plot2d", "DeviationMarkerColor" );
2428 // ... -> deviation markers line size
2429 int deviationMarkerLw = pref->addPreference( tr( "PREF_DEVIATION_MARKER_LW" ), plot2dGroup,
2430 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerLineWidth" );
2431 pref->setItemProperty( "min", 1, deviationMarkerLw );
2432 pref->setItemProperty( "max", 5, deviationMarkerLw );
2433 // ... -> deviation markers tick mark size
2434 int deviationMarkerTs = pref->addPreference( tr( "PREF_DEVIATION_MARKER_TS" ), plot2dGroup,
2435 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerTickSize" );
2436 pref->setItemProperty( "min", 1, deviationMarkerTs );
2437 pref->setItemProperty( "max", 5, deviationMarkerTs );
2438 // .. "Plot2d viewer" group <<end>>
2440 // .. "Directories" preferences tab <<start>>
2441 int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat );
2442 // ... --> quick directories list
2443 int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab );
2444 pref->addPreference( tr( "" ), dirGroup,
2445 LightApp_Preferences::DirList, "FileDlg", "QuickDirList" );
2446 // .. "Directories" preferences tab <<end>>
2448 // .. "Object browser" preferences tab <<start>>
2449 int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
2451 // ... "Search tool" group <<start>>
2452 int stGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SEARCH_TOOL" ), obTab );
2453 // .... --> auto-hide
2454 pref->addPreference( tr( "PREF_AUTO_HIDE_SEARCH_TOOL" ), stGroup, LightApp_Preferences::Bool,
2455 "ObjectBrowser", "auto_hide_search_tool" );
2456 // ... "Search tool" group <<end>>
2458 // ... "Object browser settings" group <<start>>
2459 int objSetGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), obTab );
2460 pref->setItemProperty( "columns", 2, objSetGroup );
2461 // .... -> auto size first column
2462 pref->addPreference( tr( "PREF_AUTO_SIZE_FIRST" ), objSetGroup, LightApp_Preferences::Bool,
2463 "ObjectBrowser", "auto_size_first" );
2464 // .... -> auto size other columns
2465 pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool,
2466 "ObjectBrowser", "auto_size" );
2467 // .... -> resize columns on expand item
2468 pref->addPreference( tr( "PREF_RESIZE_ON_EXPAND_ITEM" ), objSetGroup, LightApp_Preferences::Bool,
2469 "ObjectBrowser", "resize_on_expand_item" );
2470 // .... -> browse to published object
2471 int browsePublished = pref->addPreference( tr( "PREF_BROWSE_TO_THE_PUBLISHED_OBJECT" ), objSetGroup, LightApp_Preferences::Selector,
2472 "ObjectBrowser", "browse_published_object" );
2473 aValuesList.clear();
2474 anIndicesList.clear();
2475 aValuesList << tr( "PREF_BROWSE_NEVER" ) << tr( "PREF_BROWSE_AFTER_APPLY_AND_CLOSE_ONLY" ) << tr( "PREF_BROWSE_ALWAYS" );
2476 anIndicesList << BP_Never << BP_ApplyAndClose << BP_Always;
2477 pref->setItemProperty( "strings", aValuesList, browsePublished );
2478 pref->setItemProperty( "indexes", anIndicesList, browsePublished );
2479 // ... "Object browser settings" group <<end>>
2480 // .. "Object browser" preferences tab <<end>>
2482 // .. "Shortcuts" preferences tab <<start>>
2483 int shortcutTab = pref->addPreference( tr( "PREF_TAB_SHORTCUTS" ), salomeCat );
2484 // ... "Shortcuts settings" group <<start>>
2485 int shortcutGroup = pref->addPreference( tr( "PREF_GROUP_SHORTCUTS" ), shortcutTab );
2486 pref->addPreference( tr( "" ), shortcutGroup,
2487 LightApp_Preferences::ShortcutTree, "shortcuts" );
2488 // ... "Shortcuts settings" group <<end>>
2489 // .. "Shortcuts" preferences tab <<end>>
2490 // . Top-level "SALOME" preferences group <<end>>
2496 Changes appearance of application according to changed preferences
2497 \param sec - section
2498 \param param - name of changed parameter
2500 void LightApp_Application::preferencesChanged( const QString& sec, const QString& param )
2502 SUIT_ResourceMgr* resMgr = resourceMgr();
2506 if ( sec == "viewers" && param == "drop_down_buttons" )
2508 ViewManagerList vmlist = viewManagers();
2509 foreach( SUIT_ViewManager* vm, vmlist )
2511 QVector<SUIT_ViewWindow*> vwlist = vm->getViews();
2512 foreach( SUIT_ViewWindow* vw, vwlist )
2513 if ( vw ) vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
2517 if ( sec == QString( "3DViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )))
2519 double sz = resMgr->doubleValue( sec, "trihedron_size", -1 );
2520 bool relative = resMgr->booleanValue( sec, "relative_size", true );
2521 QList<SUIT_ViewManager*> lst;
2522 #ifndef DISABLE_OCCVIEWER
2523 viewManagers( OCCViewer_Viewer::Type(), lst );
2524 QListIterator<SUIT_ViewManager*> itOCC( lst );
2525 while ( itOCC.hasNext() && sz >= 0 )
2527 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2528 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2531 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2532 occVM->setTrihedronSize( sz, relative );
2533 occVM->getAISContext()->UpdateCurrentViewer();
2536 #ifndef DISABLE_VTKVIEWER
2537 #ifndef DISABLE_SALOMEOBJECT
2538 viewManagers( SVTK_Viewer::Type(), lst );
2539 QListIterator<SUIT_ViewManager*> itVTK( lst );
2540 while ( itVTK.hasNext() && sz >= 0 )
2542 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2543 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2546 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2549 vtkVM->setTrihedronSize( sz, relative );
2557 if ( sec == QString( "3DViewer" ) && param == QString( "show_static_trihedron" ) )
2559 bool isVisible = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
2560 QList<SUIT_ViewManager*> lst;
2561 #ifndef DISABLE_OCCVIEWER
2562 viewManagers( OCCViewer_Viewer::Type(), lst );
2563 QListIterator<SUIT_ViewManager*> itOCC( lst );
2564 while ( itOCC.hasNext() )
2566 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2567 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2570 OCCViewer_Viewer* occVM = dynamic_cast<OCCViewer_Viewer*>( vm );
2573 occVM->setStaticTrihedronDisplayed( isVisible );
2577 #ifndef DISABLE_VTKVIEWER
2578 #ifndef DISABLE_SALOMEOBJECT
2579 viewManagers( SVTK_Viewer::Type(), lst );
2580 QListIterator<SUIT_ViewManager*> itVTK( lst );
2581 while ( itVTK.hasNext() )
2583 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2584 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2587 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2590 vtkVM->setStaticTrihedronVisible( isVisible );
2598 if ( sec == QString( "3DViewer" ) && param == QString( "navigation_mode" ) )
2600 int mode = resMgr->integerValue( "3DViewer", "navigation_mode", 0 );
2601 QList<SUIT_ViewManager*> lst;
2602 #ifndef DISABLE_OCCVIEWER
2603 viewManagers( OCCViewer_Viewer::Type(), lst );
2604 QListIterator<SUIT_ViewManager*> itOCC( lst );
2605 while ( itOCC.hasNext() )
2607 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2608 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2611 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2612 occVM->setInteractionStyle( mode );
2615 #ifndef DISABLE_VTKVIEWER
2616 #ifndef DISABLE_SALOMEOBJECT
2617 viewManagers( SVTK_Viewer::Type(), lst );
2618 QListIterator<SUIT_ViewManager*> itVTK( lst );
2619 while ( itVTK.hasNext() )
2621 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2622 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2625 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2626 if( vtkVM ) vtkVM->setInteractionStyle( mode );
2632 #ifndef DISABLE_OCCVIEWER
2633 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_preselection" ) )
2635 bool isToEnablePreselection = resMgr->booleanValue( "OCCViewer", "enable_preselection", true );
2636 QList<SUIT_ViewManager*> lst;
2637 viewManagers( OCCViewer_Viewer::Type(), lst );
2638 QListIterator<SUIT_ViewManager*> it( lst );
2639 while ( it.hasNext() )
2641 SUIT_ViewModel* vm = it.next()->getViewModel();
2642 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2645 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2646 occVM->enablePreselection( isToEnablePreselection );
2651 #ifndef DISABLE_OCCVIEWER
2652 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_selection" ) )
2654 bool isToEnableSelection = resMgr->booleanValue( "OCCViewer", "enable_selection", true );
2655 QList<SUIT_ViewManager*> lst;
2656 viewManagers( OCCViewer_Viewer::Type(), lst );
2657 QListIterator<SUIT_ViewManager*> it( lst );
2658 while ( it.hasNext() )
2660 SUIT_ViewModel* vm = it.next()->getViewModel();
2661 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2664 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2665 occVM->enableSelection( isToEnableSelection );
2670 if ( sec == QString( "3DViewer" ) && param == QString( "zooming_mode" ) )
2672 int mode = resMgr->integerValue( "3DViewer", "zooming_mode", 0 );
2673 QList<SUIT_ViewManager*> lst;
2674 #ifndef DISABLE_OCCVIEWER
2675 viewManagers( OCCViewer_Viewer::Type(), lst );
2676 QListIterator<SUIT_ViewManager*> itOCC( lst );
2677 while ( itOCC.hasNext() )
2679 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2680 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2683 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2684 occVM->setZoomingStyle( mode );
2687 #ifndef DISABLE_VTKVIEWER
2688 #ifndef DISABLE_SALOMEOBJECT
2689 viewManagers( SVTK_Viewer::Type(), lst );
2690 QListIterator<SUIT_ViewManager*> itVTK( lst );
2691 while ( itVTK.hasNext() )
2693 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2694 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2697 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2698 if( vtkVM ) vtkVM->setZoomingStyle( mode );
2704 #ifndef DISABLE_VTKVIEWER
2705 if ( sec == QString( "VTKViewer" ) && (param == QString( "speed_value" ) || param == QString( "speed_mode" )) )
2707 int speed = resMgr->integerValue( "VTKViewer", "speed_value", 10 );
2708 int mode = resMgr->integerValue( "VTKViewer", "speed_mode", 0 );
2709 QList<SUIT_ViewManager*> lst;
2710 #ifndef DISABLE_SALOMEOBJECT
2711 viewManagers( SVTK_Viewer::Type(), lst );
2712 QListIterator<SUIT_ViewManager*> it( lst );
2713 while ( it.hasNext() )
2715 SUIT_ViewModel* vm = it.next()->getViewModel();
2716 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2719 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2720 if( vtkVM ) vtkVM->setIncrementalSpeed( speed, mode );
2726 #ifndef DISABLE_VTKVIEWER
2727 if ( sec == QString( "VTKViewer" ) && param == QString( "projection_mode" ) )
2729 int mode = resMgr->integerValue( "VTKViewer", "projection_mode", 0 );
2730 QList<SUIT_ViewManager*> lst;
2731 #ifndef DISABLE_SALOMEOBJECT
2732 viewManagers( SVTK_Viewer::Type(), lst );
2733 QListIterator<SUIT_ViewManager*> it( lst );
2734 while ( it.hasNext() )
2736 SUIT_ViewModel* vm = it.next()->getViewModel();
2737 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2740 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2741 if( vtkVM ) vtkVM->setProjectionMode( mode );
2747 #ifndef DISABLE_VTKVIEWER
2748 if ( sec == QString( "VTKViewer" ) && param == QString( "preselection" ) )
2750 int mode = resMgr->integerValue( "VTKViewer", "preselection", 0 );
2751 QList<SUIT_ViewManager*> lst;
2752 #ifndef DISABLE_SALOMEOBJECT
2753 viewManagers( SVTK_Viewer::Type(), lst );
2754 QListIterator<SUIT_ViewManager*> it( lst );
2755 while ( it.hasNext() )
2757 SUIT_ViewModel* vm = it.next()->getViewModel();
2758 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2761 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2762 if( vtkVM ) vtkVM->setPreSelectionMode( mode );
2768 #ifndef DISABLE_VTKVIEWER
2769 if ( sec == QString( "VTKViewer" ) && param == QString( "enable_selection" ) )
2771 bool isToEnableSelection = resMgr->booleanValue( "VTKViewer", "enable_selection", true );
2772 QList<SUIT_ViewManager*> lst;
2773 #ifndef DISABLE_SALOMEOBJECT
2774 viewManagers( SVTK_Viewer::Type(), lst );
2775 QListIterator<SUIT_ViewManager*> it( lst );
2776 while ( it.hasNext() )
2778 SUIT_ViewModel* vm = it.next()->getViewModel();
2779 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2782 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2783 if( vtkVM ) vtkVM->enableSelection( isToEnableSelection );
2789 #ifndef DISABLE_VTKVIEWER
2790 if ( sec == QString( "VTKViewer" ) && (param == QString( "spacemouse_func1_btn" ) ||
2791 param == QString( "spacemouse_func2_btn" ) ||
2792 param == QString( "spacemouse_func5_btn" ) ) )
2794 int btn1 = resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", 1 );
2795 int btn2 = resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", 2 );
2796 int btn3 = resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", 9 );
2797 QList<SUIT_ViewManager*> lst;
2798 #ifndef DISABLE_SALOMEOBJECT
2799 viewManagers( SVTK_Viewer::Type(), lst );
2800 QListIterator<SUIT_ViewManager*> it( lst );
2801 while ( it.hasNext() )
2803 SUIT_ViewModel* vm = it.next()->getViewModel();
2804 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2807 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2808 if( vtkVM ) vtkVM->setSpacemouseButtons( btn1, btn2, btn3 );
2813 if( sec=="ObjectBrowser" )
2815 SUIT_DataBrowser* ob = objectBrowser();
2819 if ( param=="auto_size_first" )
2821 bool autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
2822 ob->setAutoSizeFirstColumn( autoSizeFirst );
2823 if ( autoSizeFirst )
2824 ob->adjustFirstColumnWidth();
2826 else if ( param=="auto_size" ) {
2827 bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
2828 ob->setAutoSizeColumns(autoSize);
2830 ob->adjustColumnsWidth();
2832 else if ( param=="resize_on_expand_item" ) {
2833 bool resizeOnExpandItem = resMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
2834 ob->setResizeOnExpandItem(resizeOnExpandItem);
2836 else if ( param == "auto_hide_search_tool" ) {
2837 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
2843 if( param=="store_positions" )
2845 if( param=="auto_save_interval" ) {
2846 myAutoSaveTimer->stop();
2847 int autoSaveInterval = resMgr->integerValue( "Study", "auto_save_interval", 0 );
2848 if ( activeStudy() && autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
2852 #ifndef DISABLE_PYCONSOLE
2853 if( sec=="PyConsole" && pythonConsole() )
2855 if ( param=="font" ) {
2856 pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) );
2858 else if ( param=="show_banner" ) {
2859 pythonConsole()->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
2866 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
2868 if ( param == "visible_count" )
2869 mru->setVisibleCount( resMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
2870 else if ( param == "max_count" )
2871 mru->setHistoryCount( resMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
2872 else if ( param == "insert_mode" )
2873 mru->setInsertMode( resMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
2874 else if ( param == "link_type" )
2875 mru->setLinkType( resMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
2876 else if ( param == "show_clear" )
2877 mru->setClearPossible( resMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
2878 else if ( param == "show_mru" )
2879 mru->setVisible( resMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
2882 if ( sec == "language" && param == "language" )
2884 SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LANG_CHANGED" ) );
2886 if ( sec == "desktop" && param == "opaque_resize" ) {
2887 bool opaqueResize = resMgr->booleanValue( "desktop", "opaque_resize", false );
2888 QMainWindow::DockOptions dopts = desktop()->dockOptions();
2889 if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
2890 else dopts &= ~QMainWindow::AnimatedDocks;
2891 desktop()->setDockOptions( dopts );
2892 desktop()->setOpaqueResize( opaqueResize );
2893 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
2894 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
2897 if ( sec == "ExternalBrowser" && param == "use_external_browser" ) {
2898 if ( resMgr->booleanValue("ExternalBrowser", "use_external_browser", false ) )
2900 if(QtxWebBrowser::webBrowser())
2901 QtxWebBrowser::webBrowser()->close();
2905 #ifndef DISABLE_PLOT2DVIEWER
2906 if ( sec == "Plot2d" ) {
2907 if( param == "SelectionColor" ) {
2908 QColor c = resMgr->colorValue( sec, param );
2909 Plot2d_Object::setSelectionColor(c);
2911 else if (param == "SelectedLegendFontColor") {
2912 QColor c = resMgr->colorValue( sec, param );
2913 Plot2d_Object::setHighlightedLegendTextColor(c);
2922 void LightApp_Application::loadPreferences()
2924 CAM_Application::loadPreferences();
2926 SUIT_ResourceMgr* aResMgr = resourceMgr();
2931 static bool mru_load = true;
2934 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
2936 mru->setVisible( aResMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
2937 mru->setVisibleCount( aResMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
2938 mru->setHistoryCount( aResMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
2939 mru->setInsertMode( aResMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
2940 mru->setLinkType( aResMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
2941 mru->setClearPossible( aResMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
2942 mru->loadLinks( aResMgr, "MRU" );
2948 QStringList mods = aResMgr->parameters( "windows_geometry" );
2949 for ( QStringList::const_iterator it = mods.begin(); it != mods.end(); ++it )
2952 if ( aResMgr->value( "windows_geometry", *it, arr ) )
2953 myWinGeom.insert( *it, arr );
2957 mods = aResMgr->parameters( "windows_visibility" );
2958 for ( QStringList::const_iterator itr = mods.begin(); itr != mods.end(); ++itr )
2961 if ( aResMgr->value( "windows_visibility", *itr, arr ) )
2962 myWinVis.insert( *itr, arr );
2966 desktop()->retrieveGeometry( aResMgr->stringValue( "desktop", "geometry" ) );
2967 bool opaqueResize = aResMgr->booleanValue( "desktop", "opaque_resize", false );
2968 QMainWindow::DockOptions dopts = desktop()->dockOptions();
2969 if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
2970 else dopts &= ~QMainWindow::AnimatedDocks;
2971 desktop()->setDockOptions( dopts );
2972 desktop()->setOpaqueResize( opaqueResize );
2973 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
2974 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
2981 void LightApp_Application::savePreferences()
2983 CAM_Application::savePreferences();
2985 saveDockWindowsState();
2987 SUIT_ResourceMgr* aResMgr = resourceMgr();
2992 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
2994 mru->saveLinks( aResMgr, "MRU" );
2996 for ( WinGeom::const_iterator it = myWinGeom.begin(); it != myWinGeom.end(); ++it )
2997 aResMgr->setValue( "windows_geometry", it.key(), it.value() );
2999 for ( WinVis::const_iterator itr = myWinVis.begin(); itr != myWinVis.end(); ++itr )
3000 aResMgr->setValue( "windows_visibility", itr.key(), itr.value() );
3003 aResMgr->setValue( "desktop", "geometry", desktop()->storeGeometry() );
3009 Updates desktop title
3011 void LightApp_Application::updateDesktopTitle()
3013 QString aTitle = applicationName();
3014 QString aVer = applicationVersion();
3015 if ( !aVer.isEmpty() )
3016 aTitle += QString( " " ) + aVer;
3018 if ( activeStudy() ) {
3019 QString sName = SUIT_Tools::file( activeStudy()->studyName().trimmed(), false );
3020 aTitle += QString( " - [%1]" ).arg( sName );
3023 desktop()->setWindowTitle( aTitle );
3027 \brief Get map of the operations which can be performed
3028 on the module activation.
3030 The method should return the map of the kind \c {<id>:<name>}
3031 where \c <id> is an integer identifier of the operation and
3032 \c <name> is a title for the button to be added to the
3033 dialog box. After user selects the required operation by the
3034 clicking the corresponding button in the dialog box, its identifier
3035 is passed to the moduleActionSelected() method to process
3038 \return map of the operations
3039 \sa moduleActionSelected()
3041 QMap<int, QString> LightApp_Application::activateModuleActions() const
3043 QMap<int, QString> opmap;
3044 opmap.insert( NewStudyId, tr( "ACTIVATE_MODULE_OP_NEW" ) );
3045 opmap.insert( OpenStudyId, tr( "ACTIVATE_MODULE_OP_OPEN" ) );
3050 \brief Called when the used selectes required operation chosen
3051 from "Activate module" dialog box.
3053 Performs the required operation according to the user choice.
3055 \param id operation identifier
3056 \sa activateModuleActions()
3058 void LightApp_Application::moduleActionSelected( const int id )
3073 Updates windows after close document
3075 void LightApp_Application::afterCloseDoc()
3079 CAM_Application::afterCloseDoc();
3083 Updates actions of active module
3085 void LightApp_Application::updateModuleActions()
3088 if ( activeModule() ) {
3089 modName = activeModule()->moduleName();
3090 if ( !isModuleAccessible( modName ) ) {
3091 QList<SUIT_Application*> apps = SUIT_Session::session()->applications();
3092 foreach( SUIT_Application* app, apps ) {
3093 LightApp_Application* lapp = dynamic_cast<LightApp_Application*>( app );
3094 if ( lapp && lapp != this )
3095 lapp->removeModuleAction( modName );
3100 LightApp_ModuleAction* moduleAction =
3101 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
3103 moduleAction->setActiveModule( modName );
3106 void LightApp_Application::removeModuleAction( const QString& modName )
3108 LightApp_ModuleAction* moduleAction =
3109 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
3111 moduleAction->removeModule( modName );
3115 Gets current windows.
3116 \param winMap - output current windows map.
3118 void LightApp_Application::currentWindows( QMap<int, int>& winMap ) const
3121 if ( !activeStudy() )
3124 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
3125 ((LightApp_Module*)activeModule())->windows( winMap );
3127 defaultWindows( winMap );
3131 Gets current view managers.
3132 \param lst - output current view managers list.
3134 void LightApp_Application::currentViewManagers( QStringList& lst ) const
3137 if ( !activeStudy() )
3140 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
3141 ((LightApp_Module*)activeModule())->viewManagers( lst );
3143 defaultViewManagers( lst );
3149 void LightApp_Application::updateWindows()
3151 QMap<int, int> winMap;
3152 currentWindows( winMap );
3154 if ( activeStudy() )
3156 for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
3158 if ( !dockWindow( it.key() ) )
3159 getWindow( it.key() );
3163 for ( WinMap::ConstIterator it = myWin.begin(); it != myWin.end(); ++it )
3165 QWidget* wid = it.value();
3166 if ( activeStudy() )
3167 wid->setVisible( winMap.contains( it.key() ) );
3172 if ( activeStudy() )
3173 loadDockWindowsState();
3179 Updates view managers
3181 void LightApp_Application::updateViewManagers()
3184 currentViewManagers( lst );
3186 for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
3187 getViewManager( *it, true );
3191 Loads windows geometry
3193 void LightApp_Application::loadDockWindowsState()
3198 bool store = resourceMgr()->booleanValue( "Study", "store_positions", true );
3203 if ( activeModule() )
3204 modName = activeModule()->name();
3206 if ( myWinGeom.contains( modName ) )
3207 desktop()->restoreState( myWinGeom[modName] );
3209 if ( !myWinVis.contains( modName ) )
3212 QMap<QString, bool> tbMap, dwMap;
3213 dockWindowsState( myWinVis[modName], tbMap, dwMap );
3215 QList<QToolBar*> tbList = qFindChildren<QToolBar*>( desktop() );
3216 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit )
3218 QToolBar* tb = *tit;
3220 QObject* po = Qtx::findParent( tb, "QMainWindow" );
3221 if ( po != desktop() )
3224 if ( tbMap.contains( tb->objectName() ) )
3225 tb->setVisible( tbMap[tb->objectName()] );
3228 QList<QDockWidget*> dwList = qFindChildren<QDockWidget*>( desktop() );
3229 for ( QList<QDockWidget*>::iterator dit = dwList.begin(); dit != dwList.end(); ++dit )
3231 QDockWidget* dw = *dit;
3233 QObject* po = Qtx::findParent( dw, "QMainWindow" );
3234 if ( po != desktop() )
3237 if ( dwMap.contains( dw->objectName() ) )
3238 dw->setVisible( dwMap[dw->objectName()] );
3243 Saves windows geometry
3245 void LightApp_Application::saveDockWindowsState()
3250 bool store = resourceMgr()->booleanValue( "Study", "store_positions", true );
3255 if ( activeModule() )
3256 modName = activeModule()->name();
3258 myWinGeom.insert( modName, desktop()->saveState() );
3261 if ( myWinVis.contains( modName ) )
3262 visArr = myWinVis[modName];
3264 QMap<QString, bool> tbMap, dwMap;
3265 dockWindowsState( visArr, tbMap, dwMap );
3267 QList<QToolBar*> tbList = qFindChildren<QToolBar*>( desktop() );
3268 for ( QList<QToolBar*>::iterator it = tbList.begin(); it != tbList.end(); ++it )
3271 tbMap.insert( tb->objectName(), tb->toggleViewAction()->isChecked() );
3274 QList<QDockWidget*> dwList = qFindChildren<QDockWidget*>( desktop() );
3275 for ( QList<QDockWidget*>::iterator it = dwList.begin(); it != dwList.end(); ++it )
3277 QDockWidget* wid = *it;
3278 dwMap.insert( wid->objectName(), wid->toggleViewAction()->isChecked() );
3281 visArr = dockWindowsState( tbMap, dwMap );
3283 myWinVis.insert( modName, visArr );
3286 QByteArray LightApp_Application::dockWindowsState( const QMap<QString, bool>& tb, const QMap<QString, bool>& dw ) const
3289 QDataStream stream( &visArr, QIODevice::WriteOnly );
3291 stream << (uchar)ToolBarMarker;
3292 stream << tb.size();
3293 for ( QMap<QString, bool>::const_iterator tit = tb.begin(); tit != tb.end(); ++tit )
3295 stream << tit.key();
3296 stream << (uchar)( tit.value() ? 1 : 0 );
3299 stream << (uchar)DockWidgetMarker;
3300 stream << dw.size();
3301 for ( QMap<QString, bool>::const_iterator wit = dw.begin(); wit != dw.end(); ++wit )
3303 stream << wit.key();
3304 stream << (uchar)( wit.value() ? 1 : 0 );
3310 void LightApp_Application::dockWindowsState( const QByteArray& arr, QMap<QString, bool>& tb, QMap<QString, bool>& dw ) const
3315 QByteArray visArr = arr;
3316 QDataStream stream( &visArr, QIODevice::ReadOnly );
3320 if ( marker != ToolBarMarker )
3325 for ( int i = 0; i < lines; ++i )
3328 stream >> objectName;
3331 tb.insert( objectName, shown );
3335 if ( marker != DockWidgetMarker )
3339 for ( int j = 0; j < lines; ++j )
3342 stream >> objectName;
3345 dw.insert( objectName, shown );
3350 Adds icon names for modules
3352 void LightApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) const
3356 SUIT_ResourceMgr* resMgr = resourceMgr();
3360 QStringList modList;
3361 modules( modList, false );
3363 for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )
3365 QString modName = *it;
3366 QString modIntr = moduleName( modName );
3367 QString modIcon = resMgr->stringValue( modIntr, "icon", QString() );
3369 if ( modIcon.isEmpty() )
3372 if ( SUIT_Tools::extension( modIcon ).isEmpty() )
3373 modIcon += QString( ".png" );
3375 iconMap.insert( modName, modIcon );
3380 Inserts items in popup, which necessary for current application
3382 void LightApp_Application::contextMenuPopup( const QString& type, QMenu* thePopup, QString& title )
3385 LightApp_SelectionMgr* selMgr = LightApp_Application::selectionMgr();
3386 bool cacheIsOn = selMgr->isSelectionCacheEnabled();
3387 selMgr->setSelectionCacheEnabled( true );
3389 SUIT_DataBrowser* ob = objectBrowser();
3391 CAM_Application::contextMenuPopup( type, thePopup, title );
3393 if ( ob && type == ob->popupClientType() ) {
3394 thePopup->addSeparator();
3395 QAction* a = thePopup->addAction( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
3396 if ( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) )
3397 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) );
3400 if ( selMgr && ob ) {
3401 SALOME_ListIO selected;
3402 selMgr->selectedObjects( selected );
3403 if(selected.Extent() == 1){
3404 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3405 SUIT_DataObject* obj = findObject(anIObject->getEntry());
3406 if(obj && obj->renameAllowed()) {
3407 QAction* a = new QAction(tr("MEN_RENAME_OBJ"), thePopup);
3408 connect( a, SIGNAL( triggered(bool) ), ob, SLOT( onStartEditing() ) );
3409 if ( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) )
3410 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) );
3412 QList<QAction*> acts = thePopup->actions();
3413 QAction* firstAction = acts.count() > 0 ? acts.first() : 0;
3414 thePopup->insertAction(firstAction,a);
3419 selMgr->setSelectionCacheEnabled( cacheIsOn );
3425 void LightApp_Application::createEmptyStudy()
3427 CAM_Application::createEmptyStudy();
3429 if ( objectBrowser() )
3430 objectBrowser()->updateTree();
3432 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
3433 if ( aResMgr && activeStudy() ) {
3434 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
3435 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
3440 void LightApp_Application::setDesktop( SUIT_Desktop* desk )
3442 CAM_Application::setDesktop( desk );
3445 connect( desk, SIGNAL( message( const QString& ) ),
3446 this, SLOT( onDesktopMessage( const QString& ) ), Qt::UniqueConnection );
3452 \param mod - module to be activated
3454 bool LightApp_Application::activateModule( CAM_Module* mod )
3456 bool res = CAM_Application::activateModule( mod );
3458 if ( objectBrowser() )
3459 objectBrowser()->updateTree();
3465 \return keyborad accelerators manager object
3467 SUIT_Accel* LightApp_Application::accel() const
3473 Removes dead widget container from map
3475 void LightApp_Application::onWCDestroyed( QObject* ob )
3477 // remove destroyed widget container from windows map
3478 for ( WinMap::ConstIterator itr = myWin.begin(); itr != myWin.end(); ++itr )
3480 if ( itr.value() != ob )
3483 int key = itr.key();
3484 myWin.remove( key );
3489 void LightApp_Application::onMRUActivated( const QString& name )
3491 SUIT_Session* s = SUIT_Session::session();
3492 if ( s && s->activeApplication() == this )
3496 void LightApp_Application::onStylePreferences()
3498 Style_PrefDlg dlg( desktop() );
3501 resourceMgr()->setValue( "Style", "use_salome_style", Style_Salome::isActive() );
3504 void LightApp_Application::onFullScreen(){
3505 if(myScreenHelper) {
3506 if(desktop()->isFullScreen())
3507 myScreenHelper->switchToNormalScreen();
3509 myScreenHelper->switchToFullScreen();
3514 Connects just added view manager
3516 void LightApp_Application::addViewManager( SUIT_ViewManager* vm )
3518 connect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
3519 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
3520 CAM_Application::addViewManager( vm );
3524 Remove view manager from memory
3526 void LightApp_Application::removeViewManager( SUIT_ViewManager* vm )
3528 disconnect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
3529 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
3530 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
3532 aStudy->removeViewMgr(vm->getGlobalId());
3534 CAM_Application::removeViewManager( vm );
3536 LightApp_SelectionMgr* selMgr = selectionMgr();
3537 QList<SUIT_Selector*> selectors;
3538 selMgr->selectors( selectors );
3539 foreach( SUIT_Selector* selector, selectors ) {
3540 if ( selector->owner() == vm->getViewModel() ) {
3545 // IPAL22894: Crash on closing OCC view
3551 Renames active window of desktop
3553 void LightApp_Application::onRenameWindow()
3558 QWidget* w = desktop()->activeWindow();
3563 QString name = QInputDialog::getText( w, tr( "TOT_RENAME" ), tr( "PRP_RENAME" ), QLineEdit::Normal, w->windowTitle(), &ok );
3564 if( ok && !name.isEmpty() )
3565 w->setWindowTitle( name );
3569 Closes active window of desktop
3571 void LightApp_Application::onCloseWindow()
3576 QWidget* w = desktop()->activeWindow();
3584 Closes all windows of desktop
3586 void LightApp_Application::onCloseAllWindow()
3588 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
3592 QList<SUIT_ViewWindow*> wndList = desk->windows();
3593 SUIT_ViewWindow* wnd;
3594 foreach( wnd, wndList )
3602 Groups all windows of desktop
3604 void LightApp_Application::onGroupAllWindow()
3606 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
3610 QtxWorkstack* wgStack = desk->workstack();
3616 \return if the library of module exists
3617 \param moduleTitle - title of module
3619 bool LightApp_Application::isLibExists( const QString& moduleTitle ) const
3621 if( moduleTitle.isEmpty() )
3624 QString lib = moduleLibrary( moduleTitle );
3626 //abd: changed libSalomePyQtGUI to SalomePyQtGUI for WIN32
3627 bool isPythonModule = lib.contains("SalomePyQtGUI");
3628 bool isPythonLightModule = lib.contains("SalomePyQtGUILight");
3632 paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
3634 paths = QString(::getenv( "LD_LIBRARY_PATH" )).split( ":", QString::SkipEmptyParts );
3637 bool isLibFound = false;
3638 QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
3639 for( ; anIt!=aLast; anIt++ )
3641 QFileInfo inf( Qtx::addSlash( *anIt ) + lib );
3652 INFOS( "****************************************************************" << std::endl
3653 << "* Warning: library " << lib.toLatin1().constData() << " cannot be found" << std::endl
3654 << "* Module " << moduleTitle.toLatin1().constData() << " will not be available in GUI mode" << std::endl
3655 << "****************************************************************" << std::endl );
3657 else if ( !isPythonModule && !isPythonLightModule)
3660 if ( isPythonModule || isPythonLightModule)
3662 QString pylib = moduleName( moduleTitle ) + QString(".py");
3663 QString pylibgui = moduleName( moduleTitle ) + QString("GUI.py");
3665 // Check the python library
3667 // paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
3669 paths = QString(::getenv( "PYTHONPATH" )).split( ":", QString::SkipEmptyParts );
3671 bool isPyLib = false, isPyGuiLib = false;
3672 QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
3673 for( ; anIt!=aLast; anIt++ )
3675 QFileInfo inf( Qtx::addSlash( *anIt ) + pylib );
3676 QFileInfo infgui( Qtx::addSlash( *anIt ) + pylibgui );
3678 if(!isPythonLightModule)
3679 if( !isPyLib && inf.exists() )
3682 if( !isPyGuiLib && infgui.exists() )
3685 if ((isPyLib || isPythonLightModule ) && isPyGuiLib && isLibFound)
3689 printf( "****************************************************************\n" );
3690 printf( "* Warning: python library for %s cannot be found:\n", moduleTitle.toLatin1().constData() );
3692 printf( "* No module named %s\n", moduleName( moduleTitle ).toLatin1().constData() );
3694 printf( "* No module named %s\n", (moduleName( moduleTitle ) + QString("GUI")).toLatin1().constData() );
3695 printf( "****************************************************************\n" );
3702 \return default name for an active study
3704 void LightApp_Application::setDefaultStudyName( const QString& theName )
3706 QStringList anInfoList;
3707 modules( anInfoList, false );
3709 LightApp_Study* aStudy = (LightApp_Study*)activeStudy();
3710 if( anInfoList.count() == 1 && // to avoid a conflict between different modules
3711 !aStudy->isSaved() )
3713 aStudy->setStudyName( theName );
3714 updateDesktopTitle();
3719 Custom event handler
3721 bool LightApp_Application::event( QEvent* e )
3723 if( e && e->type()==2000 )
3725 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
3726 QString* d = ( QString* )ce->data();
3727 if( SUIT_MessageBox::question(0, tr("WRN_WARNING"),
3729 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
3730 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
3731 showPreferences( tr( "PREF_APP" ) );
3736 return CAM_Application::event( e );
3739 /*! Check data object */
3740 bool LightApp_Application::checkDataObject(LightApp_DataObject* theObj)
3744 bool isSuitable = !theObj->entry().isEmpty() &&
3745 !theObj->componentDataType().isEmpty() &&
3746 !theObj->name().isEmpty();
3753 int LightApp_Application::openChoice( const QString& aName )
3755 int choice = CAM_Application::openChoice( aName );
3757 if ( choice == OpenExist ) // The document is already open.
3759 // Do you want to reload it?
3760 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "QUE_DOC_ALREADYOPEN" ).arg( aName ),
3761 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No ) == SUIT_MessageBox::Yes )
3762 choice = OpenReload;
3768 bool LightApp_Application::openAction( const int choice, const QString& aName )
3775 STD_Application* app = 0;
3776 SUIT_Session* session = SUIT_Session::session();
3777 QList<SUIT_Application*> appList = session->applications();
3778 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !app; ++it )
3780 if ( (*it)->activeStudy() && (*it)->activeStudy()->studyName() == aName )
3781 app = ::qobject_cast<STD_Application*>( *it );
3786 app->onCloseDoc( false );
3787 appList = session->applications();
3788 STD_Application* other = 0;
3789 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !other; ++it )
3790 other = ::qobject_cast<STD_Application*>( *it );
3793 res = other->onOpenDoc( aName );
3798 res = CAM_Application::openAction( choice, aName );
3805 QStringList LightApp_Application::viewManagersTypes() const
3807 QStringList aTypesList;
3808 aTypesList += myUserWmTypes;
3809 #ifndef DISABLE_GLVIEWER
3810 aTypesList<<GLViewer_Viewer::Type();
3812 #ifndef DISABLE_PLOT2DVIEWER
3813 aTypesList<<Plot2d_Viewer::Type();
3815 #ifndef DISABLE_QXGRAPHVIEWER
3816 aTypesList<<QxScene_Viewer::Type();
3818 #ifndef DISABLE_OCCVIEWER
3819 aTypesList<<OCCViewer_Viewer::Type();
3821 #ifndef DISABLE_VTKVIEWER
3822 #ifndef DISABLE_SALOMEOBJECT
3823 aTypesList<<SVTK_Viewer::Type();
3825 aTypesList<<VTKViewer_Viewer::Type();
3831 * Removes all view managers of known types
3832 * Other view managers are ignored
3834 void LightApp_Application::clearKnownViewManagers()
3836 QStringList aTypesList = viewManagersTypes();
3837 QList<SUIT_ViewManager*> aMgrList;
3838 viewManagers( aMgrList );
3839 foreach (SUIT_ViewManager* aMgr, aMgrList) {
3840 if (aTypesList.contains(aMgr->getType()))
3841 removeViewManager(aMgr);
3846 Copy of current selection
3848 void LightApp_Application::onCopy()
3850 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
3856 Paste of current data in clipboard
3858 void LightApp_Application::onPaste()
3860 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
3866 Browse (i.e. set focus on) the published objects
3867 \param theIsApplyAndClose - flag indicating that the dialog for creating objects
3868 has been accepted by Ok (or Apply & Close) button
3869 \param theIsOptimizedBrowsing - flag switching to optimized browsing mode
3870 (to select the first published object only)
3871 \return entry of the selected object
3873 QString LightApp_Application::browseObjects( const QStringList& theEntryList,
3874 const bool theIsApplyAndClose,
3875 const bool theIsOptimizedBrowsing )
3878 if( SUIT_ResourceMgr* aResourceMgr = resourceMgr() )
3880 int aBrowsePolicy = aResourceMgr->integerValue( "ObjectBrowser", "browse_published_object", (int)BP_Never );
3881 switch( aBrowsePolicy )
3885 case BP_ApplyAndClose:
3886 if( !theIsApplyAndClose )
3894 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
3898 SUIT_DataBrowser* anOB = objectBrowser();
3902 SUIT_AbstractModel* aModel = dynamic_cast<SUIT_AbstractModel*>( anOB->model() );
3906 QStringListIterator anIter( theEntryList );
3907 if( theIsOptimizedBrowsing )
3909 // go to the last entry
3911 if( anIter.hasPrevious() )
3915 // scroll to each entry in the list
3916 // (in optimized mode - to the last entry only)
3918 LightApp_DataObject* anObject = 0;
3919 while( anIter.hasNext() )
3921 anEntry = anIter.next();
3922 if( !anEntry.isEmpty() )
3924 anObject = aStudy->findObjectByEntry( anEntry );
3927 QModelIndex anIndex = aModel->index( anObject );
3928 anOB->treeView()->scrollTo( anIndex );
3933 // always select the last object
3934 if( anObject && !anEntry.isEmpty() )
3936 QList<SUIT_Selector*> aSelectorList;
3937 selectionMgr()->selectors( "ObjectBrowser", aSelectorList );
3938 if( !aSelectorList.isEmpty() )
3940 if( LightApp_OBSelector* aSelector = dynamic_cast<LightApp_OBSelector*>( aSelectorList.first() ) )
3942 bool anIsAutoBlock = aSelector->autoBlock();
3944 // temporarily disable auto block, to emit LightApp_SelectionMgr::currentSelectionChanged() signal
3945 aSelector->setAutoBlock( false );
3947 SUIT_DataOwnerPtrList aList;
3948 #ifndef DISABLE_SALOMEOBJECT
3949 Handle(SALOME_InteractiveObject) aSObj = new SALOME_InteractiveObject
3950 ( anObject->entry().toLatin1().constData(),
3951 anObject->componentDataType().toLatin1().constData(),
3952 anObject->name().toLatin1().constData() );
3953 LightApp_DataOwner* owner = new LightApp_DataOwner( aSObj );
3955 LightApp_DataOwner* owner = new LightApp_DataOwner( anEntry );
3958 aList.append( owner );
3959 selectionMgr()->setSelected( aList );
3962 // restore auto block flag
3963 aSelector->setAutoBlock( anIsAutoBlock );
3971 SUIT_DataObject* LightApp_Application::findObject( const QString& id ) const
3973 LightApp_Study* study = dynamic_cast<LightApp_Study*>( activeStudy() );
3974 return study ? study->findObjectByEntry( id ) : 0;
3978 Checks that an object can be renamed.
3979 \param entry entry of the object
3980 \brief Return \c true if object can be renamed
3982 bool LightApp_Application::renameAllowed( const QString& /*entry*/) const {
3987 Rename object by entry.
3988 \param entry entry of the object
3989 \param name new name of the object
3990 \brief Return \c true if rename operation finished successfully, \c false otherwise.
3992 bool LightApp_Application::renameObject( const QString& entry, const QString& ) {
3996 /*! Process standard messages from desktop */
3997 void LightApp_Application::onDesktopMessage( const QString& message )
3999 const QString sectionSeparator = "/";
4001 if ( message.toLower() == "updateobjectbrowser" ||
4002 message.toLower() == "updateobjbrowser" ) {
4003 // update object browser
4004 updateObjectBrowser();
4007 QStringList data = message.split( sectionSeparator );
4008 if ( data.count() > 1 ) {
4009 QString msgType = data[0].trimmed();
4010 LightApp_Module* sMod = 0;
4011 CAM_Module* mod = module( msgType );
4013 mod = module( moduleTitle( msgType ) );
4014 if ( mod && mod->inherits( "LightApp_Module" ) )
4015 sMod = (LightApp_Module*)mod;
4017 if ( msgType.toLower() == "preferences" ) {
4018 // requested preferences change: should be given as "preferences/<section>/<name>/<value>"
4019 // for example "preferences/Study/multi_file_dump/true"
4020 if ( data.count() > 3 ) {
4021 QString section = data[1].trimmed();
4022 QString param = data[2].trimmed();
4023 QString value = QStringList( data.mid(3) ).join( sectionSeparator );
4024 resourceMgr()->setValue( section, param, value );
4028 // received message for the module
4029 QString msg = QStringList( data.mid(1) ).join( sectionSeparator );
4030 sMod->message( msg );