1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File: LightApp_Application.cxx
24 // Created: 6/20/2005 18:39:45 PM
25 // Author: Natalia Donis
28 // E.A. : On windows with python 2.6, there is a conflict
29 // E.A. : between pymath.h and Standard_math.h which define
30 // E.A. : some same symbols : acosh, asinh, ...
31 #include <Standard_math.hxx>
32 #ifndef DISABLE_PYCONSOLE
37 #ifndef DISABLE_PYCONSOLE
38 #include "LightApp_PyInterp.h" // WARNING! This include must be the first!
39 #include <PyConsole_Console.h>
42 #include "LightApp_Application.h"
43 #include "LightApp_Module.h"
44 #include "LightApp_DataModel.h"
45 #include "LightApp_DataOwner.h"
46 #include "LightApp_Displayer.h"
47 #include "LightApp_Study.h"
48 #include "LightApp_Preferences.h"
49 #include "LightApp_PreferencesDlg.h"
50 #include "LightApp_ModuleDlg.h"
51 #include "LightApp_AboutDlg.h"
52 #include "LightApp_ModuleAction.h"
53 // temporary commented
54 #include "LightApp_EventFilter.h"
55 #include "LightApp_OBSelector.h"
56 #include "LightApp_SelectionMgr.h"
57 #include "LightApp_DataObject.h"
58 #include "LightApp_WgViewModel.h"
59 #include "LightApp_FullScreenHelper.h"
62 #include <GUI_version.h>
63 #include <Basics_OCCTVersion.hxx>
65 #include <SALOME_Event.h>
67 #include <Style_Salome.h>
68 #include <Style_PrefDlg.h>
70 #include <CAM_Module.h>
71 #include <CAM_DataModel.h>
72 #include <CAM_Study.h>
73 #include <STD_TabDesktop.h>
75 #include <SUIT_DataBrowser.h>
76 #include <SUIT_Session.h>
77 #include <SUIT_Study.h>
78 #include <SUIT_FileDlg.h>
79 #include <SUIT_ResourceMgr.h>
80 #include <SUIT_ShortcutMgr.h>
81 #include <SUIT_Tools.h>
82 #include <SUIT_Accel.h>
83 #include <SUIT_MessageBox.h>
84 #include <SUIT_ViewWindow.h>
87 #include <QtxToolBar.h>
88 #include <QtxTreeView.h>
89 #include <QtxMRUAction.h>
90 #include <QtxDockAction.h>
91 #include <QtxDockWidget.h>
92 #include <QtxActionToolMgr.h>
93 #include <QtxSearchTool.h>
94 #include <QtxWorkstack.h>
97 #include <LogWindow.h>
99 #ifndef DISABLE_GLVIEWER
100 #include <GLViewer_Viewer.h>
101 #include <GLViewer_ViewManager.h>
102 #include "LightApp_GLSelector.h"
105 #ifndef DISABLE_PLOT2DVIEWER
106 #include <Plot2d_ViewManager.h>
107 #include <Plot2d_ViewModel.h>
108 #include <Plot2d_ViewWindow.h>
109 #include <Plot2d_ViewFrame.h>
110 #include "LightApp_Plot2dSelector.h"
111 #ifndef DISABLE_SALOMEOBJECT
112 #include <SPlot2d_ViewModel.h>
114 #include <Plot2d_ViewModel.h>
118 #ifndef DISABLE_OCCVIEWER
119 #include <OCCViewer_ViewManager.h>
120 #include <OCCViewer_ViewFrame.h>
121 #ifndef DISABLE_SALOMEOBJECT
122 #include <SOCC_ViewModel.h>
124 #include <OCCViewer_ViewModel.h>
126 #include "LightApp_OCCSelector.h"
129 #ifndef DISABLE_VTKVIEWER
130 #ifndef DISABLE_SALOMEOBJECT
131 #include <SVTK_ViewModel.h>
132 #include <SVTK_ViewManager.h>
133 #include "LightApp_VTKSelector.h"
135 #include <VTKViewer_ViewModel.h>
136 #include <VTKViewer_ViewManager.h>
138 #include <VTKViewer_ViewModel.h>
141 #ifndef DISABLE_QXGRAPHVIEWER
142 #include <QxScene_ViewManager.h>
143 #include <QxScene_ViewModel.h>
144 #include <QxScene_ViewWindow.h>
147 #ifndef DISABLE_GRAPHICSVIEW
148 #include "GraphicsView_Viewer.h"
149 #include "GraphicsView_ViewManager.h"
150 #include "LightApp_GVSelector.h"
153 #define VISIBILITY_COLUMN_WIDTH 25
159 #include <QStringList>
161 #include <QApplication>
163 #include <QStatusBar>
165 #include <QObjectList>
167 #include <QInputDialog>
168 #include <QFontDatabase>
170 #include <QByteArray>
174 #include <QHeaderView>
179 #include <utilities.h>
181 #define FIRST_HELP_ID 1000000
183 #ifndef DISABLE_SALOMEOBJECT
184 #include <SALOME_InteractiveObject.hxx>
185 #include <SALOME_ListIO.hxx>
188 #include <Standard_Version.hxx>
190 #define ToolBarMarker 0
191 #define DockWidgetMarker 1
193 static const char* imageEmptyIcon[] = {
196 "....................",
197 "....................",
198 "....................",
199 "....................",
200 "....................",
201 "....................",
202 "....................",
203 "....................",
204 "....................",
205 "....................",
206 "....................",
207 "....................",
208 "....................",
209 "....................",
210 "....................",
211 "....................",
212 "....................",
213 "....................",
214 "....................",
215 "...................."};
217 int LightApp_Application::lastStudyId = 0;
220 // Markers used to parse array with dockable windows and toolbars state.
221 // For more details please see the qdockarealayout.cpp && qtoolbararealayout.cpp
222 // in the Qt source code.
224 #define QDockWidgetMarker 0xfd // = DockWidgetStateMarker
225 #define QToolBarMarker 0xfc // = ToolBarStateMarkerEx
227 // Format of the Byte array with the windows and toolbar state is:
228 // VersionMarker|version|DockWidgetStateMarker|nbDockWidgetLines|...DocWidgetData...|ToolBarStateMarkerEx|nbToolBarLines|...ToolBarData...
230 //Find toolbar marker position in the array in the following way:
231 //since the 'toolbar marker' is not unique, find index of first occurrence of the
232 //'toolbar marker' in the array and check that next string is name of the toolbar
234 int getToolbarMarkerIndex(QByteArray input, const QStringList& aFlags) {
235 int aResult = -1,tmp = 0;
236 int inputLen = input.length();
237 QDataStream anInputData(&input, QIODevice::ReadOnly);
238 while(tmp < inputLen) {
239 tmp = input.indexOf(QToolBarMarker, tmp + 1);
242 anInputData.device()->seek(tmp);
246 anInputData >> lines;
248 if(lines == 0 && anInputData.atEnd()){
249 //Case then array doesn't contain information about toolbars,
260 if(aFlags.contains(str)) {
269 \return last global id of study
271 int LightApp_Application::studyId()
273 return LightApp_Application::lastStudyId;
276 /*!Create new instance of LightApp_Application.*/
277 extern "C" LIGHTAPP_EXPORT SUIT_Application* createApplication()
279 return new LightApp_Application();
282 /*! \var global preferences of LightApp */
283 LightApp_Preferences* LightApp_Application::_prefs_ = 0;
287 \class LightApp_Application
288 Application containing LightApp module
292 LightApp_Application::LightApp_Application()
293 : CAM_Application( false ),
295 myScreenHelper(new LightApp_FullScreenHelper())
297 Q_INIT_RESOURCE( LightApp );
299 STD_TabDesktop* desk = new STD_TabDesktop();
300 desk->setFullScreenAllowed(false);
301 desk->setMinimizeAllowed(false);
305 // initialize auto save timer
306 myAutoSaveTimer = new QTimer( this );
307 myAutoSaveTimer->setSingleShot( true );
308 connect( myAutoSaveTimer, SIGNAL( timeout() ), this, SLOT( onSaveDoc() ) );
310 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
311 QPixmap aLogo = aResMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
313 desktop()->setWindowIcon( aLogo );
314 desktop()->setDockableMenuBar( false );
315 desktop()->setDockableStatusBar( false );
317 // base logo (salome itself)
318 desktop()->logoInsert( "_app_base", aResMgr->loadPixmap( "LightApp", tr( "APP_BASE_LOGO" ), false ) );
319 // extra logo (salome-based application)
320 desktop()->logoInsert( "_app_extra", aResMgr->loadPixmap( "LightApp", tr( "APP_EXTRA_LOGO" ), false ) );
324 mySelMgr = new LightApp_SelectionMgr( this );
326 myAccel = SUIT_Accel::getAccel();
328 #ifndef DISABLE_OCCVIEWER
329 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, OCCViewer_Viewer::Type() );
330 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, OCCViewer_Viewer::Type() );
331 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, OCCViewer_Viewer::Type() );
332 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, OCCViewer_Viewer::Type() );
333 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, OCCViewer_Viewer::Type() );
334 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, OCCViewer_Viewer::Type() );
335 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, OCCViewer_Viewer::Type() );
336 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, OCCViewer_Viewer::Type() );
337 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, OCCViewer_Viewer::Type() );
338 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, OCCViewer_Viewer::Type() );
339 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, OCCViewer_Viewer::Type() );
340 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, OCCViewer_Viewer::Type() );
342 #ifndef DISABLE_VTKVIEWER
343 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, VTKViewer_Viewer::Type() );
344 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, VTKViewer_Viewer::Type() );
345 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, VTKViewer_Viewer::Type() );
346 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, VTKViewer_Viewer::Type() );
347 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, VTKViewer_Viewer::Type() );
348 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, VTKViewer_Viewer::Type() );
349 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, VTKViewer_Viewer::Type() );
350 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, VTKViewer_Viewer::Type() );
351 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, VTKViewer_Viewer::Type() );
352 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, VTKViewer_Viewer::Type() );
353 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, VTKViewer_Viewer::Type() );
354 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, VTKViewer_Viewer::Type() );
356 #ifndef DISABLE_PLOT2DVIEWER
357 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, Plot2d_Viewer::Type() );
358 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, Plot2d_Viewer::Type() );
359 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, Plot2d_Viewer::Type() );
360 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, Plot2d_Viewer::Type() );
361 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, Plot2d_Viewer::Type() );
362 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, Plot2d_Viewer::Type() );
363 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, Plot2d_Viewer::Type() );
364 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, Plot2d_Viewer::Type() );
367 connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) );
368 connect( desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
369 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
370 connect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
371 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ), Qt::UniqueConnection );
374 // Set existing font for the python console in resources
375 if( !aResMgr->hasValue( "PyConsole", "font" ) )
378 QFont f = aResMgr->fontValue( "PyConsole", "font" );
380 QStringList famdb = fdb.families();
382 if ( famdb.contains(f.family()) || !aResMgr->hasValue( "PyConsole", "additional_families" ) )
385 QStringList anAddFamilies = aResMgr->stringValue( "PyConsole", "additional_families" ).split( ";", QString::SkipEmptyParts );
387 for ( QStringList::Iterator it = anAddFamilies.begin(); it != anAddFamilies.end(); ++it )
390 if ( famdb.contains(aFamily) )
392 f.setFamily( aFamily );
393 aResMgr->setValue( "PyConsole", "font", f );
400 *\li Save window geometry.
401 *\li Save desktop geometry.
402 *\li Save resource maneger.
403 *\li Delete selection manager.
405 LightApp_Application::~LightApp_Application()
408 delete myScreenHelper;
411 /*!Start application.*/
412 void LightApp_Application::start()
414 CAM_Application::start();
417 updateViewManagers();
420 desktop()->statusBar()->showMessage( "" );
422 LightApp_EventFilter::Init();
425 /*!Gets application name.*/
426 QString LightApp_Application::applicationName() const
428 static QString _app_name;
429 if ( _app_name.isEmpty() )
430 _app_name = tr( "APP_NAME" );
434 /*!Gets application version.*/
435 QString LightApp_Application::applicationVersion() const
437 static QString _app_version;
439 if ( _app_version.isEmpty() )
441 QString resVersion = tr( "APP_VERSION" );
442 if ( resVersion != "APP_VERSION" )
444 _app_version = resVersion;
448 _app_version = GUI_VERSION_STR;
454 /*!Load module by \a name.*/
455 CAM_Module* LightApp_Application::loadModule( const QString& name, const bool showMsg )
457 CAM_Module* mod = CAM_Application::loadModule( name, showMsg );
460 connect( this, SIGNAL( studyOpened() ), mod, SLOT( onModelOpened() ) );
461 connect( this, SIGNAL( studySaved() ), mod, SLOT( onModelSaved() ) );
462 connect( this, SIGNAL( studyClosed() ), mod, SLOT( onModelClosed() ) );
467 /*!Activate module by \a modName*/
468 bool LightApp_Application::activateModule( const QString& modName )
471 CAM_Module* prevMod = activeModule();
474 actName = prevMod->moduleName();
476 if ( actName == modName )
479 putInfo( tr( "ACTIVATING_MODULE" ).arg( modName ) );
481 saveDockWindowsState();
483 bool status = CAM_Application::activateModule( modName );
485 updateModuleActions();
493 updateViewManagers();
498 /*!Gets selection manager.*/
499 LightApp_SelectionMgr* LightApp_Application::selectionMgr() const
504 /*!Creat action "New window" for certain type of viewer:*/
505 void LightApp_Application::createActionForViewer( const int id,
507 const QString& suffix,
510 QString vtlt = tr( QString( "NEW_WINDOW_%1" ).arg( suffix ).toLatin1().constData() );
511 QString tip = tr( "CREATING_NEW_WINDOW" ).arg( vtlt.remove( "&" ) );
512 QAction* a = createAction( id, // menu action id
519 false, // toggle flag
521 SLOT( onNewWindow() ) ); // slot
522 createMenu( a, parentId, -1 );
527 void LightApp_Application::createActions()
529 CAM_Application::createActions();
531 SUIT_Desktop* desk = desktop();
532 SUIT_ResourceMgr* resMgr = resourceMgr();
535 createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIcon(),
536 tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
537 Qt::CTRL+Qt::Key_R, desk, false, this, SLOT( onPreferences() ) );
541 // - Help for modules
543 int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
544 createMenu( separator(), helpMenu, -1, 10 );
545 QStringList aModuleList;
546 modules( aModuleList, false );
547 aModuleList.prepend( "GUI" );
548 aModuleList.prepend( "KERNEL" );
550 int id = LightApp_Application::UserID + FIRST_HELP_ID;
553 foreach( aModule, aModuleList ) {
554 if ( aModule.isEmpty() ) // module title (user name)
556 IMap <QString, QString> helpData; // list of help files for the module
557 QString helpSubMenu; // help submenu name (empty if not needed)
558 QString modName = moduleName( aModule ); // module name
559 if ( modName.isEmpty() ) modName = aModule; // for KERNEL and GUI
560 QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName ); // module root dir variable
561 QString modDir = getenv( rootDir.toLatin1().constData() ); // module root dir
563 if (resMgr->hasValue( modName, "documentation" ) )
564 docSection = resMgr->stringValue(modName, "documentation");
565 else if ( resMgr->hasSection( modName + "_documentation" ) )
566 docSection = modName + "_documentation";
567 if ( !docSection.isEmpty() ) {
568 helpSubMenu = resMgr->stringValue( docSection, "sub_menu", "" ).arg( aModule );
569 QStringList listOfParam = resMgr->parameters( docSection );
570 foreach( QString paramName, listOfParam ) {
571 QString valueStr = resMgr->stringValue( docSection, paramName );
572 if ( !valueStr.isEmpty() ) {
573 QFileInfo fi( valueStr );
574 if ( fi.isRelative() && !modDir.isEmpty() )
575 valueStr = Qtx::addSlash( modDir ) + valueStr;
576 if ( QFile::exists( valueStr ) )
577 helpData.insert( paramName.arg( aModule ), valueStr );
582 if ( helpData.isEmpty() && !modDir.isEmpty() ) {
583 QStringList idxLst = QStringList() << modDir << "share" << "doc" << "salome" << "gui" << modName << "index.html";
584 QString indexFile = idxLst.join( QDir::separator() ); // index file
585 if ( QFile::exists( indexFile ) )
586 helpData.insert( tr( "%1 module Users's Guide" ).arg( aModule ), indexFile );
589 IMapConstIterator<QString, QString > fileIt;
590 for ( fileIt = helpData.begin(); fileIt != helpData.end(); fileIt++ ) {
591 QString helpFileName = fileIt.key();
592 // remove all '//' occurances
593 while ( helpFileName.contains( "//" ) )
594 helpFileName.replace( "//", "" );
595 // obtain submenus hierarchy if given
596 QStringList smenus = helpFileName.split( "/" );
597 helpFileName = smenus.last();
599 QAction* a = createAction( id, helpFileName,
600 resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
601 helpFileName, helpFileName,
602 0, desk, false, this, SLOT( onHelpContentsModule() ) );
603 a->setData( fileIt.value() );
604 if ( !helpSubMenu.isEmpty() ) {
605 smenus.prepend( helpSubMenu );
607 // create sub-menus hierarchy
608 int menuId = helpMenu;
609 foreach ( QString subMenu, smenus ) {
610 menuId = createMenu( subMenu, menuId, -1, 0 );
612 createMenu( a, menuId, -1, 0 );
617 // - Additional help items
619 createMenu( separator(), helpMenu, -1, 5 );
621 QStringList addHelpItems = resMgr->parameters( "add_help" );
622 foreach ( QString addHelpItem, addHelpItems ) {
623 QString valueStr = resMgr->stringValue( "add_help", addHelpItem );
624 if ( !valueStr.isEmpty() && QFile::exists( valueStr ) ) {
625 QAction* a = createAction( id, addHelpItem,
626 resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
627 addHelpItem, addHelpItem,
628 0, desk, false, this, SLOT( onHelpContentsModule() ) );
629 a->setData( valueStr );
630 createMenu( a, helpMenu, -1, 5 );
636 static QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), 0 );
637 connect( mru, SIGNAL( activated( const QString& ) ), this, SLOT( onMRUActivated( const QString& ) ) );
638 registerAction( MRUId, mru );
640 // default icon for neutral point ('SALOME' module)
641 QPixmap defIcon = resMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
642 if ( defIcon.isNull() )
643 defIcon = QPixmap( imageEmptyIcon );
645 //! default icon for any module
646 QPixmap modIcon = resMgr->loadPixmap( "LightApp", tr( "APP_MODULE_ICO" ), false );
647 if ( modIcon.isNull() )
648 modIcon = QPixmap( imageEmptyIcon );
651 modules( modList, false );
653 if ( modList.count() > 1 )
655 LightApp_ModuleAction* moduleAction =
656 new LightApp_ModuleAction( tr( "APP_NAME" ), defIcon, desk );
658 QMap<QString, QString> iconMap;
659 moduleIconNames( iconMap );
661 const int iconSize = 20;
663 QStringList::Iterator it;
664 for ( it = modList.begin(); it != modList.end(); ++it )
666 if ( !isLibExists( *it ) )
669 QString modName = moduleName( *it );
671 if ( !isModuleAccessible( *it ) )
675 if ( iconMap.contains( *it ) )
676 iconName = iconMap[*it];
678 QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
682 INFOS ( "\n****************************************************************" << std::endl
683 << "* Icon for " << (*it).toLatin1().constData()
684 << " not found. Using the default one." << std::endl
685 << "****************************************************************" << std::endl );
688 icon = Qtx::scaleIcon( icon, iconSize );
690 moduleAction->insertModule( *it, icon );
693 connect( moduleAction, SIGNAL( moduleActivated( const QString& ) ),
694 this, SLOT( onModuleActivation( const QString& ) ) );
695 registerAction( ModulesListId, moduleAction );
699 int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, MenuWindowId, 100 );
700 int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
702 createAction( CloseId, tr( "TOT_CLOSE" ), QIcon(), tr( "MEN_DESK_CLOSE" ), tr( "PRP_CLOSE" ),
703 Qt::CTRL+Qt::Key_F4, desk, false, this, SLOT( onCloseWindow() ) );
704 createAction( CloseAllId, tr( "TOT_CLOSE_ALL" ), QIcon(), tr( "MEN_DESK_CLOSE_ALL" ), tr( "PRP_CLOSE_ALL" ),
705 0, desk, false, this, SLOT( onCloseAllWindow() ) );
706 createAction( GroupAllId, tr( "TOT_GROUP_ALL" ), QIcon(), tr( "MEN_DESK_GROUP_ALL" ), tr( "PRP_GROUP_ALL" ),
707 0, desk, false, this, SLOT( onGroupAllWindow() ) );
709 createMenu( CloseId, windowMenu, 0, -1 );
710 createMenu( CloseAllId, windowMenu, 0, -1 );
711 createMenu( GroupAllId, windowMenu, 0, -1 );
712 createMenu( separator(), windowMenu, -1, 0 );
714 #ifndef DISABLE_GLVIEWER
715 createActionForViewer( NewGLViewId, newWinMenu, QString::number( 0 ), Qt::ALT+Qt::Key_G );
717 #ifndef DISABLE_PLOT2DVIEWER
718 createActionForViewer( NewPlot2dId, newWinMenu, QString::number( 1 ), Qt::ALT+Qt::Key_P );
720 #ifndef DISABLE_OCCVIEWER
721 createActionForViewer( NewOCCViewId, newWinMenu, QString::number( 2 ), Qt::ALT+Qt::Key_O );
723 #ifndef DISABLE_VTKVIEWER
724 createActionForViewer( NewVTKViewId, newWinMenu, QString::number( 3 ), Qt::ALT+Qt::Key_K );
726 #ifndef DISABLE_QXGRAPHVIEWER
727 createActionForViewer( NewQxSceneViewId, newWinMenu, QString::number( 4 ), Qt::ALT+Qt::Key_S );
729 #ifndef DISABLE_GRAPHICSVIEW
730 createActionForViewer( NewGraphicsViewId, newWinMenu, QString::number( 5 ), Qt::ALT+Qt::Key_R );
733 createAction( RenameId, tr( "TOT_RENAME" ), QIcon(), tr( "MEN_DESK_RENAME" ), tr( "PRP_RENAME" ),
734 Qt::ALT+Qt::SHIFT+Qt::Key_R, desk, false, this, SLOT( onRenameWindow() ) );
735 createMenu( RenameId, windowMenu, -1 );
737 int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
738 createMenu( PreferencesId, fileMenu, 50, -1 );
739 createMenu( separator(), fileMenu, -1, 50, -1 );
741 createMenu( separator(), fileMenu, -1, 100, -1 );
742 createMenu( MRUId, fileMenu, 100, -1 );
743 createMenu( separator(), fileMenu, -1, 100, -1 );
745 createAction( StyleId, tr( "TOT_THEME" ), QIcon(), tr( "MEN_DESK_THEME" ), tr( "PRP_THEME" ),
746 0, desk, false, this, SLOT( onStylePreferences() ) );
748 createAction( FullScreenId, tr( "TOT_FULLSCREEN" ), QIcon(), tr( "MEN_DESK_FULLSCREEN" ), tr( "PRP_FULLSCREEN" ),
749 Qt::Key_F11, desk, false, this, SLOT( onFullScreen() ) );
752 int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1 );
753 createMenu( separator(), viewMenu, -1, 20, -1 );
754 createMenu( StyleId, viewMenu, 20, -1 );
755 createMenu( FullScreenId, viewMenu, 20, -1 );
757 int modTBar = createTool( tr( "INF_TOOLBAR_MODULES" ), // title (language-dependant)
758 QString( "SalomeModules" ) ); // name (language-independant)
759 createTool( ModulesListId, modTBar );
762 /*!On module activation action.*/
763 void LightApp_Application::onModuleActivation( const QString& modName )
765 // Force user to create/open a study before module activation
766 QMap<QString, QString> iconMap;
767 moduleIconNames( iconMap );
768 QPixmap icon = resourceMgr()->loadPixmap( moduleName( modName ), iconMap[ modName ], false );
770 icon = resourceMgr()->loadPixmap( "LightApp", tr( "APP_MODULE_BIG_ICO" ), false ); // default icon for any module
772 bool cancelled = false;
774 while ( !modName.isEmpty() && !activeStudy() && !cancelled ){
775 LightApp_ModuleDlg aDlg( desktop(), modName, icon );
776 QMap<int, QString> opmap = activateModuleActions();
777 for ( QMap<int, QString>::ConstIterator it = opmap.begin(); it != opmap.end(); ++it )
778 aDlg.addButton( it.value(), it.key() );
780 int res = aDlg.exec();
782 // some operation is selected
783 moduleActionSelected( res );
787 putInfo( tr("INF_CANCELLED") );
789 LightApp_ModuleAction* moduleAction =
790 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
792 moduleAction->setActiveModule( QString() );
798 activateModule( modName );
801 /*!Default module activation.*/
802 QString LightApp_Application::defaultModule() const
804 QStringList aModuleNames;
805 modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration
806 //! If there's the one and only module --> activate it automatically
807 //! TODO: Possible improvement - default module can be taken from preferences
808 return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" );
811 /*!On new window slot.*/
812 void LightApp_Application::onNewWindow()
814 const QObject* obj = sender();
815 if ( !obj || !obj->inherits( "QAction" ) )
819 int id = actionId( (QAction*)obj );
822 #ifndef DISABLE_GLVIEWER
824 type = GLViewer_Viewer::Type();
827 #ifndef DISABLE_PLOT2DVIEWER
829 type = Plot2d_Viewer::Type();
832 #ifndef DISABLE_OCCVIEWER
834 type = OCCViewer_Viewer::Type();
837 #ifndef DISABLE_VTKVIEWER
839 type = VTKViewer_Viewer::Type();
842 #ifndef DISABLE_QXGRAPHVIEWER
843 case NewQxSceneViewId:
844 type = QxScene_Viewer::Type();
847 #ifndef DISABLE_GRAPHICSVIEW
848 case NewGraphicsViewId:
849 type = GraphicsView_Viewer::Type();
854 if ( !type.isEmpty() )
855 createViewManager( type );
859 SLOT: Creates new document
861 void LightApp_Application::onNewDoc()
863 //asl: fix for 0020515
864 if ( activeStudy() ) {
865 saveDockWindowsState();
868 #ifdef SINGLE_DESKTOP
869 if ( !checkExistingDoc() )
873 CAM_Application::onNewDoc();
877 SLOT: Opens new document
879 void LightApp_Application::onOpenDoc()
881 SUIT_Study* study = activeStudy();
882 saveDockWindowsState();
884 #ifdef SINGLE_DESKTOP
885 if ( !checkExistingDoc() )
889 CAM_Application::onOpenDoc();
891 if ( !study ) // new study will be create in THIS application
894 updateViewManagers();
899 SLOT: Opens new document.
900 \param aName - name of file
902 bool LightApp_Application::onOpenDoc( const QString& aName )
904 #ifdef SINGLE_DESKTOP
905 if ( !checkExistingDoc() )
908 // We should take mru action first because this application instance can be deleted later.
909 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
911 bool res = CAM_Application::onOpenDoc( aName );
916 mru->insert( aName );
918 mru->remove( aName );
924 SLOT: Displays "About" message box
926 void LightApp_Application::onHelpAbout()
928 LightApp_AboutDlg dlg( applicationName(), applicationVersion(), desktop() );
933 Private SLOT: Called on selection is changed
934 Dispatchs active module that selection is changed
936 void LightApp_Application::onSelection()
938 onSelectionChanged();
940 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
941 ((LightApp_Module*)activeModule())->selectionChanged();
946 \param study - SUIT_Study.
948 void LightApp_Application::setActiveStudy( SUIT_Study* study )
950 CAM_Application::setActiveStudy( study );
954 Enables/Disables menu items and toolbar buttons. Rebuild menu
956 void LightApp_Application::updateCommandsStatus()
958 CAM_Application::updateCommandsStatus();
961 #ifndef DISABLE_GLVIEWER
962 a = action( NewGLViewId );
964 a->setEnabled( activeStudy() );
967 #ifndef DISABLE_PLOT2DVIEWER
968 a = action( NewPlot2dId );
970 a->setEnabled( activeStudy() );
973 #ifndef DISABLE_OCCVIEWER
974 a = action( NewOCCViewId );
976 a->setEnabled( activeStudy() );
979 #ifndef DISABLE_VTKVIEWER
980 a = action( NewVTKViewId );
982 a->setEnabled( activeStudy() );
985 #ifndef DISABLE_QXGRAPHVIEWER
986 a = action( NewQxSceneViewId );
988 a->setEnabled( activeStudy() );
991 #ifndef DISABLE_GRAPHICSVIEW
992 a = action( NewGraphicsViewId );
994 a->setEnabled( activeStudy() );
1000 Runs system command in separate thread
1002 class RunBrowser: public QThread
1005 RunBrowser( LightApp_Application* app,
1006 const QString& theApp,
1007 const QString& theParams,
1008 const QString& theHelpFile,
1009 const QString& theContext = QString() )
1011 myParams( theParams ),
1012 myContext( theContext ),
1016 //For the external browser always specify 'file://' protocol,
1017 //because some WEB browsers (for example Mozilla Firefox) can't open local file without protocol.
1018 myHelpFile = QString("file://%1").arg( QFileInfo( theHelpFile ).canonicalFilePath() );
1023 if ( !myApp.isEmpty() && !myHelpFile.isEmpty()) {
1024 QString aCommand = QString( "%1 %2 \"%3%4\"" ).arg( myApp, myParams, myHelpFile, myContext.isEmpty() ? QString("") : QString( "#%1" ).arg( myContext ) );
1026 QProcess* proc = new QProcess();
1028 proc->start( aCommand );
1029 if ( !proc->waitForStarted() ) {
1030 SALOME_CustomEvent* ce2000 = new SALOME_CustomEvent( 2000 );
1031 QString* msg = new QString( QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).arg( myApp, myHelpFile ) );
1032 ce2000->setData( msg );
1033 QApplication::postEvent( myLApp, ce2000 );
1044 LightApp_Application* myLApp;
1048 SLOT: Displays help contents for choosen module
1050 void LightApp_Application::onHelpContentsModule()
1052 const QAction* a = (QAction*) sender();
1053 QString helpFile = a->data().toString();
1054 if ( helpFile.isEmpty() ) return;
1056 SUIT_ResourceMgr* resMgr = resourceMgr();
1059 platform = "winapplication";
1061 platform = "application";
1063 QString anApp = resMgr->stringValue("ExternalBrowser", platform);
1065 QString quote("\"");
1066 anApp.prepend( quote );
1067 anApp.append( quote );
1069 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
1070 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1072 if( useExtBrowser ) {
1073 if ( !anApp.isEmpty() ) {
1074 RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile );
1078 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1079 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1080 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1082 showPreferences( tr( "PREF_APP" ) );
1086 QStringList parameters;
1087 parameters << QString( "--language=%1" ).arg( resMgr->stringValue( "language", "language" ) );
1088 parameters << helpFile;
1089 QProcess::startDetached( "HelpBrowser", parameters );
1094 SLOT: Displays help contents for choosen dialog
1096 void LightApp_Application::onHelpContextModule( const QString& theComponentName,
1097 const QString& theFileName,
1098 const QString& theContext )
1100 QString fileName = theFileName;
1101 QString context = theContext;
1102 if ( !QFile::exists( fileName ) && theContext.isEmpty() ) {
1103 // context might be passed within theFileName argument
1104 QStringList comps = fileName.split("#");
1105 if ( comps.count() > 1 ) {
1106 context = comps.last();
1108 fileName = comps.join("#");
1112 QString homeDir = "";
1113 if ( !theComponentName.isEmpty() ) {
1114 QString dir = getenv( ( theComponentName + "_ROOT_DIR" ).toLatin1().constData() );
1115 if ( !dir.isEmpty() )
1116 homeDir = Qtx::addSlash( Qtx::addSlash( dir ) +
1117 Qtx::addSlash( "share" ) +
1118 Qtx::addSlash( "doc" ) +
1119 Qtx::addSlash( "salome" ) +
1120 Qtx::addSlash( "gui" ) +
1121 Qtx::addSlash( theComponentName ) );
1124 QString helpFile = QFileInfo( homeDir + fileName ).absoluteFilePath();
1125 SUIT_ResourceMgr* resMgr = resourceMgr();
1128 platform = "winapplication";
1130 platform = "application";
1132 QString anApp = resMgr->stringValue("ExternalBrowser", platform);
1134 QString quote("\"");
1135 anApp.prepend( quote );
1136 anApp.append( quote );
1139 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1142 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
1144 if ( !anApp.isEmpty() ) {
1145 RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile, context );
1149 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1150 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1151 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1152 showPreferences( tr( "PREF_APP" ) );
1156 QStringList parameters;
1157 parameters << QString( "--language=%1" ).arg( resMgr->stringValue( "language", "language" ) );
1158 parameters << QString( "%1#%2" ).arg( helpFile ).arg( context );
1159 QProcess::startDetached( "HelpBrowser", parameters );
1164 Sets enable or disable some actions on selection changed.
1166 void LightApp_Application::onSelectionChanged()
1168 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
1169 bool canCopy = m ? m->canCopy() : false;
1170 bool canPaste = m ? m->canPaste() : false;
1172 action( EditCopyId )->setEnabled(canCopy);
1173 action( EditPasteId )->setEnabled(canPaste);
1176 QWidget* LightApp_Application::dockWindow( const int id ) const
1179 if ( myWin.contains( id ) )
1184 QDockWidget* LightApp_Application::windowDock( QWidget* wid ) const
1189 QDockWidget* dock = 0;
1190 QWidget* w = wid->parentWidget();
1191 while ( w && !dock )
1193 dock = ::qobject_cast<QDockWidget*>( w );
1194 w = w->parentWidget();
1199 void LightApp_Application::insertDockWindow( const int id, QWidget* wid )
1204 if ( wid != dockWindow( id ) )
1205 removeDockWindow( id );
1207 myWin.insert( id, wid );
1209 QtxDockWidget* dock = new QtxDockWidget( true, desktop() );
1210 connect( dock, SIGNAL( destroyed( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
1212 dock->setFeatures( QDockWidget::AllDockWidgetFeatures );
1213 dock->setObjectName( wid->objectName().isEmpty() ? QString( "window_%1" ).arg( id ) :
1214 QString( "%1Dock" ).arg( wid->objectName() ) );
1215 dock->setWidget( wid );
1217 QKeySequence accel = wid->property( "shortcut" ).value<QKeySequence>();
1218 if ( !accel.isEmpty() )
1219 dock->toggleViewAction()->setShortcut( accel );
1224 void LightApp_Application::removeDockWindow( const int id )
1226 QWidget* wid = dockWindow( id );
1232 QDockWidget* dock = windowDock( wid );
1236 dock->setWidget( 0 );
1237 wid->setParent( 0 );
1238 wid->setVisible( false );
1242 void LightApp_Application::placeDockWindow( const int id, Qt::DockWidgetArea place )
1244 QDockWidget* dock = windowDock( dockWindow( id ) );
1245 if ( dock && desktop() ) {
1246 desktop()->addDockWidget( place, dock );
1247 QtxDockAction* a = qobject_cast<QtxDockAction*>( action( ViewWindowsId ) );
1248 if ( a ) a->update();
1254 \param flag - key for window
1255 \param studyId - study id
1256 Flag used how identificator of window in windows list.
1258 QWidget* LightApp_Application::getWindow( const int flag, const int )
1260 QWidget* wid = dockWindow( flag );
1262 insertDockWindow( flag, wid = createWindow( flag ) );
1264 QMap<int, int> winMap;
1265 currentWindows( winMap );
1266 if ( winMap.contains( flag ) )
1267 placeDockWindow( flag, (Qt::DockWidgetArea)winMap[flag] );
1273 \return Object Browser
1275 SUIT_DataBrowser* LightApp_Application::objectBrowser()
1277 return qobject_cast<SUIT_DataBrowser*>( dockWindow( WT_ObjectBrowser ) );
1283 LogWindow* LightApp_Application::logWindow()
1285 return qobject_cast<LogWindow*>( dockWindow( WT_LogWindow ) );
1288 #ifndef DISABLE_PYCONSOLE
1290 This returns the python console integrated to the GUI. Depending
1291 when you request the python console, this function could return
1292 null. Then the optional parameter force (default to false) can be
1293 set to force the creation of the python console if it is not done
1295 \param force - if true, the pythonConsole is created if it does not exist yet
1296 \return Python Console
1298 PyConsole_Console* LightApp_Application::pythonConsole(const bool force)
1300 QWidget* wid = dockWindow( WT_PyConsole );
1301 if ( !wid && force==true) {
1302 wid = getWindow(WT_PyConsole);
1304 return qobject_cast<PyConsole_Console*>( wid );
1309 Updates object browser and maybe data models
1310 \param updateModels - if it is true, then data models are updated
1312 void LightApp_Application::updateObjectBrowser( const bool updateModels )
1314 // update existing data models
1317 const bool isAutoUpdate = objectBrowser() ? objectBrowser()->autoUpdate() : true;
1318 if ( objectBrowser() )
1319 objectBrowser()->setAutoUpdate( false );
1321 LightApp_Study* study = dynamic_cast<LightApp_Study*>(activeStudy());
1323 CAM_Study::ModelList dm_list;
1324 study->dataModels( dm_list );
1325 QListIterator<CAM_DataModel*> it( dm_list );
1326 while ( it.hasNext() ) {
1327 CAM_DataModel* camDM = it.next();
1328 if ( camDM && camDM->inherits( "LightApp_DataModel" ) )
1329 ((LightApp_DataModel*)camDM)->update();
1333 if( objectBrowser() )
1334 objectBrowser()->setAutoUpdate( isAutoUpdate );
1337 if ( objectBrowser() ) {
1338 objectBrowser()->updateGeometry();
1339 objectBrowser()->updateTree( 0, false );
1346 LightApp_Preferences* LightApp_Application::preferences() const
1348 return preferences( false );
1352 \return first view manager of some type
1353 \param vmType - type of view manager
1354 \param create - is it necessary to create view manager in case, when there is no manager of such type
1356 SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, const bool create )
1358 SUIT_ViewManager* aVM = viewManager( vmType );
1359 SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
1361 if ( anActiveVM && anActiveVM->getType() == vmType )
1364 if ( aVM && create )
1366 if ( !aVM->getActiveView() )
1369 aVM->getActiveView()->setFocus();
1372 aVM = createViewManager( vmType );
1378 Creates view manager of some type
1379 \param vmType - type of view manager
1381 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType )
1383 SUIT_ResourceMgr* resMgr = resourceMgr();
1385 SUIT_ViewManager* viewMgr = 0;
1386 #ifndef DISABLE_GLVIEWER
1387 if( vmType == GLViewer_Viewer::Type() )
1389 viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() );
1390 new LightApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
1393 #ifndef DISABLE_PLOT2DVIEWER
1394 if( vmType == Plot2d_Viewer::Type() )
1396 viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
1398 #ifndef DISABLE_SALOMEOBJECT
1399 SPlot2d_Viewer* v = new SPlot2d_Viewer();
1401 new LightApp_Plot2dSelector( v, mySelMgr );
1403 vm = new Plot2d_Viewer();
1405 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1406 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
1409 Plot2d_ViewFrame* frame = wnd->getViewFrame();
1410 frame->setBackgroundColor( resMgr->colorValue( "Plot2d", "Background", frame->backgroundColor() ) );
1414 #ifndef DISABLE_QXGRAPHVIEWER
1415 if( vmType == QxScene_Viewer::Type() )
1417 viewMgr = new QxScene_ViewManager( activeStudy(), desktop() );
1418 QxScene_Viewer* vm = new QxScene_Viewer();
1419 viewMgr->setViewModel( vm );
1420 //QxScene_ViewWindow* wnd = dynamic_cast<QxScene_ViewWindow*>( viewMgr->getActiveView() );
1423 #ifndef DISABLE_GRAPHICSVIEW
1424 if( vmType == GraphicsView_Viewer::Type() )
1426 viewMgr = new GraphicsView_ViewManager( activeStudy(), desktop() );
1427 new LightApp_GVSelector( (GraphicsView_Viewer*)viewMgr->getViewModel(), mySelMgr );
1430 #ifndef DISABLE_OCCVIEWER
1431 if( vmType == OCCViewer_Viewer::Type() )
1433 viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
1434 OCCViewer_Viewer* vm;
1435 #ifndef DISABLE_SALOMEOBJECT
1436 vm = new SOCC_Viewer();
1438 vm = new OCCViewer_Viewer( true );
1440 vm->setBackground( OCCViewer_ViewFrame::TOP_LEFT,
1441 resMgr->backgroundValue( "OCCViewer", "xz_background", vm->background(OCCViewer_ViewFrame::TOP_LEFT) ) );
1442 vm->setBackground( OCCViewer_ViewFrame::TOP_RIGHT,
1443 resMgr->backgroundValue( "OCCViewer", "yz_background", vm->background(OCCViewer_ViewFrame::TOP_RIGHT) ) );
1444 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_LEFT,
1445 resMgr->backgroundValue( "OCCViewer", "xy_background", vm->background(OCCViewer_ViewFrame::BOTTOM_LEFT) ) );
1446 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_RIGHT,
1447 resMgr->backgroundValue( "OCCViewer", "background", vm->background(OCCViewer_ViewFrame::MAIN_VIEW) ) );
1449 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1450 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ));
1451 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1452 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1453 vm->enablePreselection( resMgr->booleanValue( "OCCViewer", "enable_preselection", vm->isPreselectionEnabled() ) );
1454 vm->enableSelection( resMgr->booleanValue( "OCCViewer", "enable_selection", vm->isSelectionEnabled() ) );
1456 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1457 new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
1460 #ifndef DISABLE_VTKVIEWER
1461 #ifndef DISABLE_SALOMEOBJECT
1462 if ( vmType == SVTK_Viewer::Type() )
1464 if ( vmType == VTKViewer_Viewer::Type() )
1467 #ifndef DISABLE_SALOMEOBJECT
1468 viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
1469 SVTK_Viewer* vm = dynamic_cast<SVTK_Viewer*>( viewMgr->getViewModel() );
1472 vm->setProjectionMode( resMgr->integerValue( "VTKViewer", "projection_mode", vm->projectionMode() ) );
1473 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1474 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1475 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ) );
1476 vm->setStaticTrihedronVisible( resMgr->booleanValue( "3DViewer", "show_static_trihedron", vm->isStaticTrihedronVisible() ) );
1477 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1478 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1479 vm->setPreSelectionMode(resMgr->integerValue( "VTKViewer", "preselection", vm->preSelectionMode() ) );
1480 vm->enableSelection( resMgr->booleanValue( "VTKViewer", "enable_selection", vm->isSelectionEnabled() ) );
1481 vm->setIncrementalSpeed( resMgr->integerValue( "VTKViewer", "speed_value", vm->incrementalSpeed() ),
1482 resMgr->integerValue( "VTKViewer", "speed_mode", vm->incrementalSpeedMode() ) );
1483 vm->setSpacemouseButtons( resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", vm->spacemouseBtn(1) ),
1484 resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", vm->spacemouseBtn(2) ),
1485 resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", vm->spacemouseBtn(3) ) );
1486 new LightApp_VTKSelector( vm, mySelMgr );
1489 viewMgr = new VTKViewer_ViewManager( activeStudy(), desktop() );
1490 VTKViewer_Viewer* vm = dynamic_cast<VTKViewer_Viewer*>( viewMgr->getViewModel() );
1492 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1500 addViewManager( viewMgr );
1501 SUIT_ViewWindow* viewWin = viewMgr->createViewWindow();
1503 if ( viewWin && desktop() ) {
1504 viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1505 viewWin->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1511 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, QWidget* w )
1513 SUIT_ResourceMgr* resMgr = resourceMgr();
1515 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
1517 new LightApp_WgViewModel( vmType, w ) );
1518 vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
1520 addViewManager( vm );
1521 SUIT_ViewWindow* vw = vm->createViewWindow();
1522 if ( vw && desktop() ) {
1523 vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1524 vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1527 if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
1528 myUserWmTypes << vmType;
1533 SUIT_ViewManager* LightApp_Application::createViewManager( SUIT_ViewModel* theModel )
1535 SUIT_ResourceMgr* resMgr = resourceMgr();
1537 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
1541 QString vmType = vm->getType();
1543 vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
1545 addViewManager( vm );
1546 SUIT_ViewWindow* vw = vm->createViewWindow();
1547 if ( vw && desktop() ) {
1548 vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1549 vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1552 if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
1553 myUserWmTypes << vmType;
1559 SLOT: Removes view manager from application
1561 void LightApp_Application::onCloseView( SUIT_ViewManager* theVM )
1563 removeViewManager( theVM );
1567 Protected SLOT: On study created.
1568 \param theStudy - just created study
1570 void LightApp_Application::onStudyCreated( SUIT_Study* theStudy )
1572 SUIT_DataObject* aRoot = 0;
1573 if ( theStudy && theStudy->root() )
1575 aRoot = theStudy->root();
1576 //aRoot->setName( tr( "DATA_MODELS" ) );
1579 getWindow( WT_ObjectBrowser );
1581 loadDockWindowsState();
1583 if ( objectBrowser() )
1584 objectBrowser()->setRoot( aRoot );
1586 activateModule( defaultModule() );
1588 if ( objectBrowser() )
1589 objectBrowser()->openLevels();
1593 Protected SLOT: On study opened.
1594 \param theStudy - just opened study
1596 void LightApp_Application::onStudyOpened( SUIT_Study* theStudy )
1598 SUIT_DataObject* aRoot = 0;
1599 if ( theStudy && theStudy->root() )
1601 aRoot = theStudy->root();
1605 getWindow( WT_ObjectBrowser );
1607 loadDockWindowsState();
1609 if ( objectBrowser() )
1610 objectBrowser()->setRoot( aRoot );
1612 activateModule( defaultModule() );
1614 if ( objectBrowser() )
1615 objectBrowser()->openLevels();
1620 /*!Protected SLOT. On study saved.*/
1621 void LightApp_Application::onStudySaved( SUIT_Study* s )
1623 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
1625 mru->insert( s->studyName() );
1630 /*!Protected SLOT. On study closed.*/
1631 void LightApp_Application::onStudyClosed( SUIT_Study* s )
1634 disconnect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
1635 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
1638 // stop auto-save timer
1639 myAutoSaveTimer->stop();
1641 // Bug 10396: clear selection
1642 mySelMgr->clearSelected();
1644 // Bug 12944: emit signal only after clear selection
1647 activateModule( "" );
1650 /*!Protected SLOT.On desktop activated.*/
1651 void LightApp_Application::onDesktopActivated()
1653 CAM_Application::onDesktopActivated();
1654 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>(activeModule());
1656 aModule->studyActivated();
1659 void LightApp_Application::studyOpened( SUIT_Study* s )
1661 CAM_Application::studyOpened( s );
1664 updateViewManagers();
1667 void LightApp_Application::studySaved( SUIT_Study* s )
1669 CAM_Application::studyOpened( s );
1670 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1671 if ( aResMgr && activeStudy() ) {
1672 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
1673 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
1677 void LightApp_Application::studyCreated( SUIT_Study* s )
1679 CAM_Application::studyCreated( s );
1682 updateViewManagers();
1685 /*!Gets file filter.
1686 *\retval QString "(*.bin)"
1688 QString LightApp_Application::getFileFilter() const
1696 Shows file dialog and return user selected file name
1698 QString LightApp_Application::getFileName( bool open, const QString& initial, const QString& filters,
1699 const QString& caption, QWidget* parent )
1703 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1704 return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
1707 /*! Gets directory*/
1708 QString LightApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
1712 return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true );
1715 /*! Get open file names*/
1716 QStringList LightApp_Application::getOpenFileNames( const QString& initial, const QString& filters,
1717 const QString& caption, QWidget* parent )
1721 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1722 return SUIT_FileDlg::getOpenFileNames( parent, initial, fls, caption, true );
1725 /*!Private SLOT. Update object browser.*/
1726 void LightApp_Application::onRefresh()
1728 updateObjectBrowser( true );
1731 /*!Private SLOT. Support drag-and-drop operation.*/
1732 void LightApp_Application::onDropped( const QList<SUIT_DataObject*>& objects, SUIT_DataObject* parent, int row, Qt::DropAction action )
1734 LightApp_DataObject* parentObj = dynamic_cast<LightApp_DataObject*>( parent );
1738 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>( parentObj->module() );
1740 aModule->dropObjects( objects, parentObj, row, action );
1743 /*!Private SLOT. On preferences.*/
1744 void LightApp_Application::onPreferences()
1746 showPreferences( activeModule() ? activeModule()->moduleName() : tr( "PREF_CATEGORY_SALOME" ) );
1749 /*!Private SLOT. On preferences.*/
1750 void LightApp_Application::showPreferences( const QString& itemText )
1752 QApplication::setOverrideCursor( Qt::WaitCursor );
1754 LightApp_PreferencesDlg* prefDlg = new LightApp_PreferencesDlg( preferences( true ), desktop());
1756 QApplication::restoreOverrideCursor();
1761 preferences()->activateItem( itemText );
1763 if ( ( prefDlg->exec() == QDialog::Accepted || prefDlg->isSaved() ) && resourceMgr() )
1766 resourceMgr()->setValue( "desktop", "geometry", desktop()->storeGeometry() );
1767 resourceMgr()->save();
1770 shortcutMgr()->updateShortcuts();
1776 /*!Protected SLOT. On preferences changed.*/
1777 void LightApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param )
1779 LightApp_Module* sMod = 0;
1780 CAM_Module* mod = module( modName );
1781 if ( mod && mod->inherits( "LightApp_Module" ) )
1782 sMod = (LightApp_Module*)mod;
1785 sMod->preferencesChanged( section, param );
1787 preferencesChanged( section, param );
1788 // emit signal to allow additional preferences changing processing
1789 emit preferenceChanged( modName, section, param );
1792 /*!Remove all windows from study.*/
1793 void LightApp_Application::beforeCloseDoc( SUIT_Study* s )
1795 if ( SUIT_DataBrowser* ob = objectBrowser() )
1798 CAM_Application::beforeCloseDoc( s );
1801 /*!Update actions.*/
1802 void LightApp_Application::updateActions()
1804 updateCommandsStatus();
1810 SUIT_Study* LightApp_Application::createNewStudy()
1812 LightApp_Application::lastStudyId++;
1814 LightApp_Study* aStudy = new LightApp_Study( this );
1816 // Set up processing of major study-related events
1817 connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
1818 connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
1819 connect( aStudy, SIGNAL( saved ( SUIT_Study* ) ), this, SLOT( onStudySaved ( SUIT_Study* ) ) );
1820 connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
1826 Creates window by flag.
1827 \param flag - identificator of window type
1829 QWidget* LightApp_Application::createWindow( const int flag )
1833 SUIT_ResourceMgr* resMgr = resourceMgr();
1835 if ( flag == WT_ObjectBrowser )
1837 SUIT_DataBrowser* ob = new SUIT_DataBrowser( new LightApp_DataObject(), desktop() );
1838 ob->setObjectName( "objectBrowser" );
1839 ob->setSortMenuEnabled( true );
1840 ob->setAutoUpdate( true );
1841 if ( resMgr->hasValue( "ObjectBrowser", "auto_hide_search_tool" ) )
1842 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
1844 //ob->setAutoOpenLevel( 1 ); // commented by ASV as a fix to bug IPAL10107
1845 ob->setWindowTitle( tr( "OBJECT_BROWSER" ) );
1846 connect( ob, SIGNAL( requestUpdate() ), this, SLOT( onRefresh() ) );
1848 QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
1849 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
1850 treeModel->setSearcher( this );
1851 treeModel->registerColumn( 0, EntryCol, LightApp_DataObject::EntryId );
1852 treeModel->setAppropriate( EntryCol, Qtx::Toggled );
1854 // Mantis issue 0020136: Drag&Drop in OB
1855 SUIT_ProxyModel* proxyModel = dynamic_cast<SUIT_ProxyModel*>(treeModel);
1857 connect( proxyModel, SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
1858 this, SLOT( onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
1861 // temporary commented
1863 OB_ListView* ob_list = dynamic_cast<OB_ListView*>( const_cast<QListView*>( ob->listView() ) );
1865 ob_list->setColumnMaxWidth( 0, desktop()->width()/4 );
1868 // Create OBSelector
1869 new LightApp_OBSelector( ob, mySelMgr );
1871 ob->treeView()->header()->setResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
1872 ob->treeView()->header()->moveSection(SUIT_DataObject::NameId,SUIT_DataObject::VisibilityId);
1873 ob->treeView()->setColumnWidth(SUIT_DataObject::VisibilityId, VISIBILITY_COLUMN_WIDTH);
1874 ob->setProperty( "shortcut", QKeySequence( "Alt+Shift+O" ) );
1876 ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1878 #ifndef DISABLE_PYCONSOLE
1879 else if ( flag == WT_PyConsole )
1881 PyConsole_Console* pyCons = new PyConsole_EnhConsole( desktop(),new LightApp_PyInterp());
1882 pyCons->setObjectName( "pythonConsole" );
1883 pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
1884 pyCons->setFont(resourceMgr()->fontValue( "PyConsole", "font" ));
1885 pyCons->setIsShowBanner(resourceMgr()->booleanValue( "PyConsole", "show_banner", true ));
1886 pyCons->setProperty( "shortcut", QKeySequence( "Alt+Shift+P" ) );
1889 pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1892 else if ( flag == WT_LogWindow )
1894 LogWindow* logWin = new LogWindow( desktop() );
1895 logWin->setObjectName( "logWindow" );
1896 logWin->setWindowTitle( tr( "LOG_WINDOW" ) );
1897 logWin->setProperty( "shortcut", QKeySequence( "Alt+Shift+L" ) );
1899 logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
1905 \return default windows( Object Browser, Python Console )
1906 Adds to map \a aMap.
1908 void LightApp_Application::defaultWindows( QMap<int, int>& aMap ) const
1910 aMap.insert( WT_ObjectBrowser, Qt::LeftDockWidgetArea );
1911 #ifndef DISABLE_PYCONSOLE
1912 aMap.insert( WT_PyConsole, Qt::BottomDockWidgetArea );
1914 // aMap.insert( WT_LogWindow, Qt::DockBottom );
1917 /*!Default view managers*/
1918 void LightApp_Application::defaultViewManagers( QStringList& ) const
1924 \return preferences.
1925 Create preferences, if \a crt = true.
1927 LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const
1932 LightApp_Application* that = (LightApp_Application*)this;
1934 bool toCreate = !_prefs_ && crt;
1937 _prefs_ = new LightApp_Preferences( resourceMgr() );
1938 that->createPreferences( _prefs_ );
1941 that->myPrefs = _prefs_;
1943 connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
1944 this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ) );
1949 SUIT_ResourceMgr* resMgr = resourceMgr();
1951 QList<SUIT_Application*> appList = SUIT_Session::session()->applications();
1952 for ( QList<SUIT_Application*>::iterator appIt = appList.begin(); appIt != appList.end(); ++appIt )
1954 LightApp_Application* app = ::qobject_cast<LightApp_Application*>( *appIt );
1958 QStringList modNameList;
1959 app->modules( modNameList, false );
1961 QMap<QString, QString> iconMap;
1962 app->moduleIconNames( iconMap );
1964 for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it )
1966 if ( !app->isLibExists( *it ) || _prefs_->hasModule( *it ) )
1969 int modId = _prefs_->addPreference( *it );
1970 if ( iconMap.contains( *it ) )
1971 _prefs_->setItemIcon( modId, Qtx::scaleIcon( resMgr->loadPixmap( moduleName( *it ), iconMap[*it], false ), 20 ) );
1975 app->modules( modList );
1976 QListIterator<CAM_Module*> itr( modList );
1977 while ( itr.hasNext() )
1979 LightApp_Module* mod = 0;
1981 CAM_Module* anItem = itr.next();
1982 if ( anItem->inherits( "LightApp_Module" ) )
1983 mod = (LightApp_Module*)anItem;
1985 if ( mod && !_prefs_->hasModule( mod->moduleName() ) )
1987 _prefs_->addPreference( mod->moduleName() );
1988 mod->createPreferences();
1989 that->emptyPreferences( mod->moduleName() );
1993 _prefs_->setItemProperty( "info", tr( "PREFERENCES_NOT_LOADED" ) );
1999 Adds new module to application
2001 void LightApp_Application::moduleAdded( CAM_Module* mod )
2003 CAM_Application::moduleAdded( mod );
2005 LightApp_Module* lightMod = 0;
2006 if ( mod && mod->inherits( "LightApp_Module" ) )
2007 lightMod = (LightApp_Module*)mod;
2009 if ( myPrefs && lightMod && !myPrefs->hasModule( lightMod->moduleName() ))
2011 myPrefs->addPreference( mod->moduleName() );
2012 lightMod->createPreferences();
2013 emptyPreferences( mod->moduleName() );
2017 void LightApp_Application::emptyPreferences( const QString& modName )
2019 QtxPreferenceItem* item = myPrefs->findItem( modName, true );
2020 if ( !item || !item->isEmpty() )
2023 // printf( "---------------------> Modify for empty module.\n" );
2025 QtxPagePrefFrameItem* frm = new QtxPagePrefFrameItem( item->title(), item->parentItem() );
2026 frm->setIcon( item->icon() );
2027 frm->setStretch( false );
2028 item->parentItem()->insertItem( frm, item );
2029 new QtxPagePrefLabelItem( Qt::AlignCenter, tr( "PREFERENCES_NOT_SUPPORTED" ).arg( modName ), frm );
2036 void LightApp_Application::createPreferences( LightApp_Preferences* pref )
2041 QStringList aValuesList;
2042 QList<QVariant> anIndicesList;
2046 // . Top-level "SALOME" preferences group <<start>>
2047 int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
2048 pref->setItemIcon( salomeCat, Qtx::scaleIcon( resourceMgr()->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false ), 20 ) );
2050 // .. "General" preferences tab <<start>>
2051 int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat );
2053 // ... "Language" group <<start>>
2054 int langGroup = pref->addPreference( tr( "PREF_GROUP_LANGUAGE" ), genTab );
2055 pref->setItemProperty( "columns", 2, langGroup );
2056 // .... -> application language
2057 int curLang = pref->addPreference( tr( "PREF_CURRENT_LANGUAGE" ), langGroup,
2058 LightApp_Preferences::Selector, "language", "language" );
2059 QStringList aLangs = SUIT_Session::session()->resourceMgr()->stringValue( "language", "languages", "en" ).split( "," );
2060 QList<QVariant> aIcons;
2061 foreach ( QString aLang, aLangs ) {
2062 aIcons << QPixmap( QString( ":/images/%1" ).arg( aLang ) );
2064 pref->setItemProperty( "strings", aLangs, curLang );
2065 pref->setItemProperty( "icons", aIcons, curLang );
2067 int curLocale = pref->addPreference( tr( "PREF_CURRENT_LOCALE" ), langGroup,
2068 LightApp_Preferences::Bool, "language", "locale" );
2069 // ... "Language" group <<end>>
2071 // ... "Look and feel" group <<start>>
2072 int lookGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), genTab );
2073 pref->setItemProperty( "columns", 2, lookGroup );
2074 // .... -> show splash-screen
2075 pref->addPreference( tr( "PREF_SHOW_SPLASH" ), lookGroup, LightApp_Preferences::Bool, "launch", "splash" );
2076 // .... -> opaque resize
2077 pref->addPreference( tr( "PREF_OPAQUE_RESIZE" ), lookGroup, LightApp_Preferences::Bool, "desktop", "opaque_resize" );
2078 // .... -> drop-down buttons
2079 pref->addPreference( tr( "PREF_DROP_DOWN_BUTTONS" ), lookGroup, LightApp_Preferences::Bool, "viewers", "drop_down_buttons" );
2080 // ... "Look and feel" group <<end>>
2082 // ... "Study properties" group <<start>>
2083 int studyGroup = pref->addPreference( tr( "PREF_GROUP_STUDY" ), genTab );
2084 pref->setItemProperty( "columns", 2, studyGroup );
2085 // .... -> multi-file save
2086 pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "multi_file" );
2087 // .... -> ascii save mode
2088 pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" );
2089 // .... -> store windows geometry
2090 pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" );
2091 pref->addPreference( "", studyGroup, LightApp_Preferences::Space );
2092 pref->addPreference( tr( "PREF_STORE_TOOL_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_tool_positions" );
2093 // .... -> auto-save
2094 int autoSaveInterval = pref->addPreference( tr( "PREF_AUTO_SAVE" ), studyGroup,
2095 LightApp_Preferences::IntSpin, "Study", "auto_save_interval" );
2096 pref->setItemProperty( "min", 0, autoSaveInterval );
2097 pref->setItemProperty( "max", 1440, autoSaveInterval );
2098 pref->setItemProperty( "special", tr( "PREF_AUTO_SAVE_DISABLED" ), autoSaveInterval );
2099 // ... "Study properties" group <<end>>
2101 // ... "Help browser" group <<start>>
2102 int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab, LightApp_Preferences::Auto, "ExternalBrowser", "use_external_browser");
2104 QString platform = "winapplication";
2106 QString platform = "application";
2108 // .... -> browser application
2109 int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, LightApp_Preferences::File, "ExternalBrowser", platform );
2110 pref->setItemProperty( "mode", Qtx::PT_OpenFile, apppref );
2111 // .... -> browser parameters
2112 pref->addPreference( tr( "PREF_PARAM" ), extgroup, LightApp_Preferences::String, "ExternalBrowser", "parameters" );
2113 // ... "Help browser" group <<end>>
2115 // ... "Python console properties" group <<start>>
2116 int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab );
2118 pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, LightApp_Preferences::Font, "PyConsole", "font" );
2119 // .... -> show banner
2120 pref->addPreference( tr( "PREF_SHOW_BANNER" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "show_banner" );
2121 // ... "Python console properties" group <<end>>
2123 // ... "MRU" preferences group <<start>>
2124 int mruGroup = pref->addPreference( tr( "PREF_GROUP_MRU" ), genTab, LightApp_Preferences::Auto, "MRU", "show_mru" );
2125 pref->setItemProperty( "columns", 4, mruGroup );
2126 // number of MRU items
2127 int mruVisCount = pref->addPreference( tr( "PREF_MRU_VISIBLE_COUNT" ), mruGroup, LightApp_Preferences::IntSpin,
2128 "MRU", "visible_count" );
2129 pref->setItemProperty( "min", 0, mruVisCount );
2130 pref->setItemProperty( "max", 100, mruVisCount );
2132 int mruLinkType = pref->addPreference( tr( "PREF_MRU_LINK_TYPE" ), mruGroup, LightApp_Preferences::Selector,
2133 "MRU", "link_type" );
2134 aValuesList.clear();
2135 anIndicesList.clear();
2136 aValuesList << tr("PREF_MRU_LINK_AUTO") << tr("PREF_MRU_LINK_SHORT") << tr("PREF_MRU_LINK_FULL");
2137 anIndicesList << 0 << 1 << 2 ;
2138 pref->setItemProperty( "strings", aValuesList, mruLinkType );
2139 pref->setItemProperty( "indexes", anIndicesList, mruLinkType );
2140 // ... "MRU" preferences group <<end>>
2141 // .. "General" preferences tab <<end>>
2143 // .. "3D viewer" group <<start>>
2144 int Viewer3DGroup = pref->addPreference( tr( "PREF_GROUP_3DVIEWER" ), salomeCat );
2145 // ... -> navigation mode
2146 int vtkStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), Viewer3DGroup,
2147 LightApp_Preferences::Selector, "3DViewer", "navigation_mode" );
2148 aValuesList.clear();
2149 anIndicesList.clear();
2150 aValuesList << tr("PREF_STANDARD_STYLE") << tr("PREF_KEYFREE_STYLE");
2151 anIndicesList << 0 << 1;
2152 pref->setItemProperty( "strings", aValuesList, vtkStyleMode );
2153 pref->setItemProperty( "indexes", anIndicesList, vtkStyleMode );
2154 // ... -> zooming mode
2155 #if OCC_VERSION_LARGE > 0x0603000A // available only with OCC-6.3-sp11 and higher version
2156 int occZoomingStyleMode = pref->addPreference( tr( "PREF_ZOOMING" ), Viewer3DGroup,
2157 LightApp_Preferences::Selector, "3DViewer", "zooming_mode" );
2158 aValuesList.clear();
2159 anIndicesList.clear();
2160 aValuesList << tr("PREF_ZOOMING_AT_CENTER") << tr("PREF_ZOOMING_AT_CURSOR");
2161 anIndicesList << 0 << 1;
2162 pref->setItemProperty( "strings", aValuesList, occZoomingStyleMode );
2163 pref->setItemProperty( "indexes", anIndicesList, occZoomingStyleMode );
2165 // ... "Trihedron" group <<start>>
2166 int occTriGroup = pref->addPreference( tr( "PREF_TRIHEDRON" ), Viewer3DGroup );
2167 pref->setItemProperty( "columns", 2, occTriGroup );
2168 // .... -> trihedron size
2169 int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occTriGroup,
2170 LightApp_Preferences::DblSpin, "3DViewer", "trihedron_size" );
2171 pref->setItemProperty( "min", 1.0E-06, occTS );
2172 pref->setItemProperty( "max", 1000, occTS );
2173 // .... -> relative size of trihedron
2174 pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "relative_size" );
2175 // .... -> show static trihedron
2176 pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "show_static_trihedron" );
2177 // ... "Trihedron" group <<end>>
2178 // .. "3D viewer" group <<end>>
2182 #ifndef DISABLE_OCCVIEWER
2183 // .. "OCC viewer" group <<start>>
2184 int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), salomeCat );
2186 // ... "Background" group <<start>>
2187 int bgGroup = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup );
2188 // pref->setItemProperty( "columns", 2, bgGroup );
2189 aValuesList.clear();
2190 anIndicesList.clear();
2192 formats = OCCViewer_Viewer::backgroundData( aValuesList, idList, txtList );
2193 foreach( int gid, idList ) anIndicesList << gid;
2194 // .... -> 3D viewer background
2195 bgId = pref->addPreference( tr( "PREF_3DVIEWER_BACKGROUND" ), bgGroup,
2196 LightApp_Preferences::Background, "OCCViewer", "background" );
2197 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2198 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2199 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2200 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2201 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2202 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2203 pref->setItemProperty( "custom_enabled", false, bgId );
2204 pref->setItemProperty( "image_formats", formats, bgId );
2205 // .... -> XZ viewer background
2206 bgId = pref->addPreference( tr( "PREF_XZVIEWER_BACKGROUND" ), bgGroup,
2207 LightApp_Preferences::Background, "OCCViewer", "xz_background" );
2208 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2209 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2210 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2211 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2212 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2213 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2214 pref->setItemProperty( "custom_enabled", false, bgId );
2215 pref->setItemProperty( "image_formats", formats, bgId );
2216 // .... -> YZ viewer background
2217 bgId = pref->addPreference( tr( "PREF_YZVIEWER_BACKGROUND" ), bgGroup,
2218 LightApp_Preferences::Background, "OCCViewer", "yz_background" );
2219 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2220 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2221 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2222 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2223 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2224 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2225 pref->setItemProperty( "custom_enabled", false, bgId );
2226 pref->setItemProperty( "image_formats", formats, bgId );
2227 // .... -> XY viewer background
2228 bgId = pref->addPreference( tr( "PREF_XYVIEWER_BACKGROUND" ), bgGroup,
2229 LightApp_Preferences::Background, "OCCViewer", "xy_background" );
2230 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2231 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2232 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2233 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2234 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2235 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2236 pref->setItemProperty( "custom_enabled", false, bgId );
2237 pref->setItemProperty( "image_formats", formats, bgId );
2238 // ... "Background" group <<end>>
2241 // ... "Selection" group <<start>>
2242 int occSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), occGroup );
2243 pref->setItemProperty( "columns", 2, occSelectionGroup );
2244 // .... -> enable preselection
2245 pref->addPreference( tr( "PREF_ENABLE_PRESELECTION" ), occSelectionGroup,
2246 LightApp_Preferences::Bool, "OCCViewer", "enable_preselection" );
2247 // .... -> enable selection
2248 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), occSelectionGroup,
2249 LightApp_Preferences::Bool, "OCCViewer", "enable_selection" );
2250 // ... "Selection" group <<end>>
2252 // ... -> empty frame (for layout) <<start>>
2253 int occGen = pref->addPreference( "", occGroup, LightApp_Preferences::Frame );
2254 pref->setItemProperty( "margin", 0, occGen );
2255 pref->setItemProperty( "columns", 2, occGen );
2256 // ... -> empty frame (for layout) <<end>>
2257 // .. "OCC viewer" group <<end>>
2260 #ifndef DISABLE_VTKVIEWER
2261 // .. "VTK viewer" group <<start>>
2262 int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), salomeCat ); //viewTab
2264 // ... -> empty frame (for layout) <<start>>
2265 int vtkGen = pref->addPreference( "", vtkGroup, LightApp_Preferences::Frame );
2266 //pref->setItemProperty( "columns", 2, vtkGen );
2267 // .... -> projection mode
2268 int vtkProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), vtkGen,
2269 LightApp_Preferences::Selector, "VTKViewer", "projection_mode" );
2270 aValuesList.clear();
2271 anIndicesList.clear();
2272 aValuesList << tr("PREF_ORTHOGRAPHIC") << tr("PREF_PERSPECTIVE");
2273 anIndicesList << 0 << 1;
2274 pref->setItemProperty( "strings", aValuesList, vtkProjMode );
2275 pref->setItemProperty( "indexes", anIndicesList, vtkProjMode );
2276 // .... -> background
2277 aValuesList.clear();
2278 anIndicesList.clear();
2280 #ifndef DISABLE_SALOMEOBJECT
2281 formats = SVTK_Viewer::backgroundData( aValuesList, idList, txtList );
2283 foreach( int gid, idList ) anIndicesList << gid;
2284 bgId = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGen,
2285 LightApp_Preferences::Background, "VTKViewer", "background" );
2286 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2287 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2288 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2289 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2290 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2291 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2292 pref->setItemProperty( "custom_enabled", false, bgId );
2293 #ifndef DISABLE_SALOMEOBJECT
2294 pref->setItemProperty( "image_formats", formats, bgId );
2296 // .... -> speed increment
2297 int vtkSpeed = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED" ), vtkGen,
2298 LightApp_Preferences::IntSpin, "VTKViewer", "speed_value" );
2299 pref->setItemProperty( "min", 1, vtkSpeed );
2300 pref->setItemProperty( "max", 1000, vtkSpeed );
2301 // .... -> speed mode
2302 int vtkSpeedMode = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED_MODE" ), vtkGen,
2303 LightApp_Preferences::Selector, "VTKViewer", "speed_mode" );
2304 aValuesList.clear();
2305 anIndicesList.clear();
2306 aValuesList << tr("PREF_ARITHMETIC") << tr("PREF_GEOMETRICAL");
2307 anIndicesList << 0 << 1;
2308 pref->setItemProperty( "strings", aValuesList, vtkSpeedMode );
2309 pref->setItemProperty( "indexes", anIndicesList, vtkSpeedMode );
2311 // ... "Selection" group <<start>>
2312 int vtkSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), vtkGroup );
2313 pref->setItemProperty( "columns", 2, vtkSelectionGroup );
2314 // .... -> preselection
2315 int vtkPreselection = pref->addPreference( tr( "PREF_PRESELECTION" ), vtkSelectionGroup,
2316 LightApp_Preferences::Selector, "VTKViewer", "preselection" );
2317 aValuesList.clear();
2318 anIndicesList.clear();
2319 aValuesList << tr("PREF_PRESELECTION_STANDARD") << tr("PREF_PRESELECTION_DYNAMIC") << tr("PREF_PRESELECTION_DISABLED");
2320 anIndicesList << 0 << 1 << 2;
2321 pref->setItemProperty( "strings", aValuesList, vtkPreselection );
2322 pref->setItemProperty( "indexes", anIndicesList, vtkPreselection );
2323 // .... -> enable selection
2324 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), vtkSelectionGroup, LightApp_Preferences::Bool, "VTKViewer", "enable_selection" );
2325 // ... "Selection" group <<end>>
2327 // ... -> empty frame (for layout) <<end>>
2329 // ... space mouse sub-group <<start>>
2330 int vtkSM = pref->addPreference( tr( "PREF_FRAME_SPACEMOUSE" ), vtkGroup, LightApp_Preferences::GroupBox );
2331 //pref->setItemProperty( "columns", 2, vtkSM );
2332 // .... -> decrease speed increment
2333 int spacemousePref1 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_1" ), vtkSM,
2334 LightApp_Preferences::Selector, "VTKViewer",
2335 "spacemouse_func1_btn" );
2336 // .... -> increase speed increment
2337 int spacemousePref2 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_2" ), vtkSM,
2338 LightApp_Preferences::Selector, "VTKViewer",
2339 "spacemouse_func2_btn" );
2340 // .... -> dominant / combined switch
2341 int spacemousePref3 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_3" ), vtkSM,
2342 LightApp_Preferences::Selector, "VTKViewer",
2343 "spacemouse_func5_btn" ); //
2344 aValuesList.clear();
2345 anIndicesList.clear();
2346 aValuesList << tr( "PREF_SPACEMOUSE_BTN_1" ) << tr( "PREF_SPACEMOUSE_BTN_2" ) << tr( "PREF_SPACEMOUSE_BTN_3" );
2347 aValuesList << tr( "PREF_SPACEMOUSE_BTN_4" ) << tr( "PREF_SPACEMOUSE_BTN_5" ) << tr( "PREF_SPACEMOUSE_BTN_6" );
2348 aValuesList << tr( "PREF_SPACEMOUSE_BTN_7" ) << tr( "PREF_SPACEMOUSE_BTN_8" ) << tr( "PREF_SPACEMOUSE_BTN_*" );
2349 aValuesList << tr( "PREF_SPACEMOUSE_BTN_10" ) << tr( "PREF_SPACEMOUSE_BTN_11" );
2350 anIndicesList << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11;
2351 pref->setItemProperty( "strings", aValuesList, spacemousePref1 );
2352 pref->setItemProperty( "indexes", anIndicesList, spacemousePref1 );
2353 pref->setItemProperty( "strings", aValuesList, spacemousePref2 );
2354 pref->setItemProperty( "indexes", anIndicesList, spacemousePref2 );
2355 pref->setItemProperty( "strings", aValuesList, spacemousePref3 );
2356 pref->setItemProperty( "indexes", anIndicesList, spacemousePref3 );
2357 // ... space mouse sub-group <<end>>
2359 // ... avi recording sub-group <<start>>
2360 int vtkRec = pref->addPreference( tr( "PREF_FRAME_RECORDING" ), vtkGroup, LightApp_Preferences::GroupBox );
2361 pref->setItemProperty( "columns", 2, vtkRec );
2362 // .... -> recording mode
2363 int modePref = pref->addPreference( tr( "PREF_RECORDING_MODE" ), vtkRec,
2364 LightApp_Preferences::Selector, "VTKViewer", "recorder_mode" );
2365 aValuesList.clear();
2366 anIndicesList.clear();
2367 aValuesList << tr( "PREF_SKIPPED_FRAMES" ) << tr( "PREF_ALL_DISLPAYED_FRAMES" );
2368 anIndicesList << 0 << 1;
2369 pref->setItemProperty( "strings", aValuesList, modePref );
2370 pref->setItemProperty( "indexes", anIndicesList, modePref );
2372 int fpsPref = pref->addPreference( tr( "PREF_FPS" ), vtkRec,
2373 LightApp_Preferences::DblSpin, "VTKViewer", "recorder_fps" );
2374 pref->setItemProperty( "min", 0.1, fpsPref );
2375 pref->setItemProperty( "max", 100, fpsPref );
2377 int qualityPref = pref->addPreference( tr( "PREF_QUALITY" ), vtkRec,
2378 LightApp_Preferences::IntSpin, "VTKViewer", "recorder_quality" );
2379 pref->setItemProperty( "min", 1, qualityPref );
2380 pref->setItemProperty( "max", 100, qualityPref );
2381 // .... -> progressive mode
2382 pref->addPreference( tr( "PREF_PROGRESSIVE" ), vtkRec,
2383 LightApp_Preferences::Bool, "VTKViewer", "recorder_progressive" );
2384 // ... avi recording sub-group <<end>>
2386 // ... group names sub-group <<start>>
2387 int vtkGN = pref->addPreference( tr( "PREF_FRAME_GROUP_NAMES" ), vtkGroup,
2388 LightApp_Preferences::GroupBox, "VTKViewer", "show_group_names" );
2389 pref->setItemProperty( "columns", 2, vtkGN );
2390 // .... -> text color
2391 pref->addPreference( tr( "PREF_GROUP_NAMES_TEXT_COLOR" ), vtkGN,
2392 LightApp_Preferences::Color, "VTKViewer", "group_names_text_color" );
2393 // .... -> transparency
2394 int transPref = pref->addPreference( tr( "PREF_GROUP_NAMES_TRANSPARENCY" ), vtkGN,
2395 LightApp_Preferences::DblSpin, "VTKViewer", "group_names_transparency" );
2396 pref->setItemProperty( "min", 0.0, transPref );
2397 pref->setItemProperty( "max", 1.0, transPref );
2398 pref->setItemProperty( "step", 0.1, transPref );
2399 // ... -> group names sub-group <<end>>
2400 // .. "VTK viewer" group <<end>>
2403 // .. "Plot2d viewer" group <<start>>
2404 int plot2dGroup = pref->addPreference( tr( "PREF_GROUP_PLOT2DVIEWER" ), salomeCat ); //viewTab
2405 //pref->setItemProperty( "columns", 2, plot2dGroup );
2407 // ... -> background
2408 pref->addPreference( tr( "PREF_VIEWER_BACKGROUND_COLOR" ), plot2dGroup,
2409 LightApp_Preferences::Color, "Plot2d", "Background" );
2410 // ... -> selection color
2411 pref->addPreference( tr( "PREF_VIEWER_SELECTION" ), plot2dGroup,
2412 LightApp_Preferences::Color, "Plot2d", "SelectionColor" );
2414 // ... "Viewer" group <<start>>
2415 int plot2dViewerGroup = pref->addPreference( tr( "PREF_GROUP_VIEWER" ), plot2dGroup );
2417 // .... -> curve type
2418 int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dViewerGroup,
2419 LightApp_Preferences::Selector, "Plot2d", "CurveType" );
2420 aValuesList.clear();
2421 anIndicesList.clear();
2422 aValuesList << tr("PREF_POINTS") << tr("PREF_LINES") << tr("PREF_SPLINE");
2423 anIndicesList << 0 << 1 << 2 ;
2424 pref->setItemProperty( "strings", aValuesList, curveType );
2425 pref->setItemProperty( "indexes", anIndicesList, curveType );
2426 // .... -> marker size
2427 int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dViewerGroup,
2428 LightApp_Preferences::IntSpin, "Plot2d", "MarkerSize" );
2429 pref->setItemProperty( "min", 0, markerSize );
2430 pref->setItemProperty( "max", 100, markerSize );
2431 // .... -> horizontal scaling mode
2432 int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dViewerGroup,
2433 LightApp_Preferences::Selector, "Plot2d", "HorScaleMode" );
2434 aValuesList.clear();
2435 anIndicesList.clear();
2436 aValuesList << tr("PREF_LINEAR") << tr("PREF_LOGARITHMIC");
2437 anIndicesList << 0 << 1 ;
2438 pref->setItemProperty( "strings", aValuesList, horScale );
2439 pref->setItemProperty( "indexes", anIndicesList, horScale );
2440 // .... -> vertical scaling mode
2441 int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dViewerGroup,
2442 LightApp_Preferences::Selector, "Plot2d", "VerScaleMode" );
2443 pref->setItemProperty( "strings", aValuesList, verScale );
2444 pref->setItemProperty( "indexes", anIndicesList, verScale );
2446 // .... -> errors/deviation colot
2447 pref->addPreference( tr( "PREF_DEVIATION_COLOR" ), plot2dViewerGroup,
2448 LightApp_Preferences::Color, "Plot2d", "DeviationMarkerColor" );
2449 // .... -> deviation markers line size
2450 int deviationMarkerLw = pref->addPreference( tr( "PREF_DEVIATION_MARKER_LW" ), plot2dViewerGroup,
2451 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerLineWidth" );
2452 pref->setItemProperty( "min", 1, deviationMarkerLw );
2453 pref->setItemProperty( "max", 5, deviationMarkerLw );
2454 // .... -> deviation markers tick mark size
2455 int deviationMarkerTs = pref->addPreference( tr( "PREF_DEVIATION_MARKER_TS" ), plot2dViewerGroup,
2456 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerTickSize" );
2457 pref->setItemProperty( "min", 1, deviationMarkerTs );
2458 pref->setItemProperty( "max", 5, deviationMarkerTs );
2459 // .... "Viewer" group <<end>>
2461 // ... "Legend" group <<start>>
2462 int plot2dLegendGroup = pref->addPreference( tr( "PREF_GROUP_LEGEND" ), plot2dGroup );
2464 // .... -> show legend
2465 pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dLegendGroup,
2466 LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
2467 // .... -> legend position
2468 int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dLegendGroup,
2469 LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
2470 aValuesList.clear();
2471 anIndicesList.clear();
2472 aValuesList << tr("PREF_LEFT") << tr("PREF_RIGHT") << tr("PREF_TOP") << tr("PREF_BOTTOM");
2473 anIndicesList << 0 << 1 << 2 << 3 ;
2474 pref->setItemProperty( "strings", aValuesList, legendPosition );
2475 pref->setItemProperty( "indexes", anIndicesList, legendPosition );
2476 // .... -> Symbol type
2477 int legendSymbolType = pref->addPreference( tr( "PREF_LEGEND_SYMBOL_TYPE" ), plot2dLegendGroup,
2478 LightApp_Preferences::Selector, "Plot2d", "LegendSymbolType" );
2479 aValuesList.clear();
2480 anIndicesList.clear();
2481 aValuesList << tr("PREF_MARKER_ON_LINE") << tr("PREF_MARKER_ABOVE_LINE");
2482 anIndicesList << 0 << 1 ;
2483 pref->setItemProperty( "strings", aValuesList, legendSymbolType );
2484 pref->setItemProperty( "indexes", anIndicesList, legendSymbolType );
2485 // .... -> legend font
2486 pref->addPreference( tr( "PREF_LEGEND_FONT" ), plot2dLegendGroup, LightApp_Preferences::Font, "Plot2d", "LegendFont" );
2487 // ... -> font color
2488 pref->addPreference( tr( "PREF_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "LegendFontColor" );
2489 // ... -> selection font color
2490 pref->addPreference( tr( "PREF_SELECTED_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "SelectedLegendFontColor" );
2491 // ... "Legend" group <<end>>
2493 // .. "Plot2d viewer" group <<end>>
2495 // .. "Directories" preferences tab <<start>>
2496 int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat );
2497 // ... --> quick directories list
2498 int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab );
2499 pref->addPreference( tr( "" ), dirGroup,
2500 LightApp_Preferences::DirList, "FileDlg", "QuickDirList" );
2501 // .. "Directories" preferences tab <<end>>
2503 // .. "Object browser" preferences tab <<start>>
2504 int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
2506 // ... "Search tool" group <<start>>
2507 int stGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SEARCH_TOOL" ), obTab );
2508 // .... --> auto-hide
2509 pref->addPreference( tr( "PREF_AUTO_HIDE_SEARCH_TOOL" ), stGroup, LightApp_Preferences::Bool,
2510 "ObjectBrowser", "auto_hide_search_tool" );
2511 // ... "Search tool" group <<end>>
2513 // ... "Object browser settings" group <<start>>
2514 int objSetGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), obTab );
2515 pref->setItemProperty( "columns", 2, objSetGroup );
2516 // .... -> auto size first column
2517 pref->addPreference( tr( "PREF_AUTO_SIZE_FIRST" ), objSetGroup, LightApp_Preferences::Bool,
2518 "ObjectBrowser", "auto_size_first" );
2519 // .... -> auto size other columns
2520 pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool,
2521 "ObjectBrowser", "auto_size" );
2522 // .... -> resize columns on expand item
2523 pref->addPreference( tr( "PREF_RESIZE_ON_EXPAND_ITEM" ), objSetGroup, LightApp_Preferences::Bool,
2524 "ObjectBrowser", "resize_on_expand_item" );
2525 // .... -> browse to published object
2526 int browsePublished = pref->addPreference( tr( "PREF_BROWSE_TO_THE_PUBLISHED_OBJECT" ), objSetGroup, LightApp_Preferences::Selector,
2527 "ObjectBrowser", "browse_published_object" );
2528 aValuesList.clear();
2529 anIndicesList.clear();
2530 aValuesList << tr( "PREF_BROWSE_NEVER" ) << tr( "PREF_BROWSE_AFTER_APPLY_AND_CLOSE_ONLY" ) << tr( "PREF_BROWSE_ALWAYS" );
2531 anIndicesList << BP_Never << BP_ApplyAndClose << BP_Always;
2532 pref->setItemProperty( "strings", aValuesList, browsePublished );
2533 pref->setItemProperty( "indexes", anIndicesList, browsePublished );
2534 // ... "Object browser settings" group <<end>>
2535 // .. "Object browser" preferences tab <<end>>
2537 // .. "Shortcuts" preferences tab <<start>>
2538 int shortcutTab = pref->addPreference( tr( "PREF_TAB_SHORTCUTS" ), salomeCat );
2539 // ... "Shortcuts settings" group <<start>>
2540 int shortcutGroup = pref->addPreference( tr( "PREF_GROUP_SHORTCUTS" ), shortcutTab );
2541 pref->addPreference( tr( "" ), shortcutGroup,
2542 LightApp_Preferences::ShortcutTree, "shortcuts" );
2543 // ... "Shortcuts settings" group <<end>>
2544 // .. "Shortcuts" preferences tab <<end>>
2545 // . Top-level "SALOME" preferences group <<end>>
2551 Changes appearance of application according to changed preferences
2552 \param sec - section
2553 \param param - name of changed parameter
2555 void LightApp_Application::preferencesChanged( const QString& sec, const QString& param )
2557 SUIT_ResourceMgr* resMgr = resourceMgr();
2561 if ( sec == "viewers" && param == "drop_down_buttons" )
2563 ViewManagerList vmlist = viewManagers();
2564 foreach( SUIT_ViewManager* vm, vmlist )
2566 QVector<SUIT_ViewWindow*> vwlist = vm->getViews();
2567 foreach( SUIT_ViewWindow* vw, vwlist )
2568 if ( vw ) vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
2572 if ( sec == QString( "3DViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )))
2574 double sz = resMgr->doubleValue( sec, "trihedron_size", -1 );
2575 bool relative = resMgr->booleanValue( sec, "relative_size", true );
2576 QList<SUIT_ViewManager*> lst;
2577 #ifndef DISABLE_OCCVIEWER
2578 viewManagers( OCCViewer_Viewer::Type(), lst );
2579 QListIterator<SUIT_ViewManager*> itOCC( lst );
2580 while ( itOCC.hasNext() && sz >= 0 )
2582 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2583 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2586 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2587 occVM->setTrihedronSize( sz, relative );
2588 occVM->getAISContext()->UpdateCurrentViewer();
2591 #ifndef DISABLE_VTKVIEWER
2592 #ifndef DISABLE_SALOMEOBJECT
2593 viewManagers( SVTK_Viewer::Type(), lst );
2594 QListIterator<SUIT_ViewManager*> itVTK( lst );
2595 while ( itVTK.hasNext() && sz >= 0 )
2597 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2598 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2601 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2604 vtkVM->setTrihedronSize( sz, relative );
2612 if ( sec == QString( "3DViewer" ) && param == QString( "show_static_trihedron" ) )
2614 bool isVisible = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
2615 QList<SUIT_ViewManager*> lst;
2616 #ifndef DISABLE_OCCVIEWER
2617 viewManagers( OCCViewer_Viewer::Type(), lst );
2618 QListIterator<SUIT_ViewManager*> itOCC( lst );
2619 while ( itOCC.hasNext() )
2621 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2622 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2625 OCCViewer_Viewer* occVM = dynamic_cast<OCCViewer_Viewer*>( vm );
2628 occVM->setStaticTrihedronDisplayed( isVisible );
2632 #ifndef DISABLE_VTKVIEWER
2633 #ifndef DISABLE_SALOMEOBJECT
2634 viewManagers( SVTK_Viewer::Type(), lst );
2635 QListIterator<SUIT_ViewManager*> itVTK( lst );
2636 while ( itVTK.hasNext() )
2638 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2639 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2642 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2645 vtkVM->setStaticTrihedronVisible( isVisible );
2653 if ( sec == QString( "3DViewer" ) && param == QString( "navigation_mode" ) )
2655 int mode = resMgr->integerValue( "3DViewer", "navigation_mode", 0 );
2656 QList<SUIT_ViewManager*> lst;
2657 #ifndef DISABLE_OCCVIEWER
2658 viewManagers( OCCViewer_Viewer::Type(), lst );
2659 QListIterator<SUIT_ViewManager*> itOCC( lst );
2660 while ( itOCC.hasNext() )
2662 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2663 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2666 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2667 occVM->setInteractionStyle( mode );
2670 #ifndef DISABLE_VTKVIEWER
2671 #ifndef DISABLE_SALOMEOBJECT
2672 viewManagers( SVTK_Viewer::Type(), lst );
2673 QListIterator<SUIT_ViewManager*> itVTK( lst );
2674 while ( itVTK.hasNext() )
2676 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2677 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2680 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2681 if( vtkVM ) vtkVM->setInteractionStyle( mode );
2687 #ifndef DISABLE_OCCVIEWER
2688 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_preselection" ) )
2690 bool isToEnablePreselection = resMgr->booleanValue( "OCCViewer", "enable_preselection", true );
2691 QList<SUIT_ViewManager*> lst;
2692 viewManagers( OCCViewer_Viewer::Type(), lst );
2693 QListIterator<SUIT_ViewManager*> it( lst );
2694 while ( it.hasNext() )
2696 SUIT_ViewModel* vm = it.next()->getViewModel();
2697 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2700 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2701 occVM->enablePreselection( isToEnablePreselection );
2706 #ifndef DISABLE_OCCVIEWER
2707 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_selection" ) )
2709 bool isToEnableSelection = resMgr->booleanValue( "OCCViewer", "enable_selection", true );
2710 QList<SUIT_ViewManager*> lst;
2711 viewManagers( OCCViewer_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( "OCCViewer_Viewer" ) )
2719 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2720 occVM->enableSelection( isToEnableSelection );
2725 if ( sec == QString( "3DViewer" ) && param == QString( "zooming_mode" ) )
2727 int mode = resMgr->integerValue( "3DViewer", "zooming_mode", 0 );
2728 QList<SUIT_ViewManager*> lst;
2729 #ifndef DISABLE_OCCVIEWER
2730 viewManagers( OCCViewer_Viewer::Type(), lst );
2731 QListIterator<SUIT_ViewManager*> itOCC( lst );
2732 while ( itOCC.hasNext() )
2734 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
2735 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
2738 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
2739 occVM->setZoomingStyle( mode );
2742 #ifndef DISABLE_VTKVIEWER
2743 #ifndef DISABLE_SALOMEOBJECT
2744 viewManagers( SVTK_Viewer::Type(), lst );
2745 QListIterator<SUIT_ViewManager*> itVTK( lst );
2746 while ( itVTK.hasNext() )
2748 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
2749 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2752 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2753 if( vtkVM ) vtkVM->setZoomingStyle( mode );
2759 #ifndef DISABLE_VTKVIEWER
2760 if ( sec == QString( "VTKViewer" ) && (param == QString( "speed_value" ) || param == QString( "speed_mode" )) )
2762 int speed = resMgr->integerValue( "VTKViewer", "speed_value", 10 );
2763 int mode = resMgr->integerValue( "VTKViewer", "speed_mode", 0 );
2764 QList<SUIT_ViewManager*> lst;
2765 #ifndef DISABLE_SALOMEOBJECT
2766 viewManagers( SVTK_Viewer::Type(), lst );
2767 QListIterator<SUIT_ViewManager*> it( lst );
2768 while ( it.hasNext() )
2770 SUIT_ViewModel* vm = it.next()->getViewModel();
2771 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2774 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2775 if( vtkVM ) vtkVM->setIncrementalSpeed( speed, mode );
2781 #ifndef DISABLE_VTKVIEWER
2782 if ( sec == QString( "VTKViewer" ) && param == QString( "projection_mode" ) )
2784 int mode = resMgr->integerValue( "VTKViewer", "projection_mode", 0 );
2785 QList<SUIT_ViewManager*> lst;
2786 #ifndef DISABLE_SALOMEOBJECT
2787 viewManagers( SVTK_Viewer::Type(), lst );
2788 QListIterator<SUIT_ViewManager*> it( lst );
2789 while ( it.hasNext() )
2791 SUIT_ViewModel* vm = it.next()->getViewModel();
2792 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2795 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2796 if( vtkVM ) vtkVM->setProjectionMode( mode );
2802 #ifndef DISABLE_VTKVIEWER
2803 if ( sec == QString( "VTKViewer" ) && param == QString( "preselection" ) )
2805 int mode = resMgr->integerValue( "VTKViewer", "preselection", 0 );
2806 QList<SUIT_ViewManager*> lst;
2807 #ifndef DISABLE_SALOMEOBJECT
2808 viewManagers( SVTK_Viewer::Type(), lst );
2809 QListIterator<SUIT_ViewManager*> it( lst );
2810 while ( it.hasNext() )
2812 SUIT_ViewModel* vm = it.next()->getViewModel();
2813 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2816 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2817 if( vtkVM ) vtkVM->setPreSelectionMode( mode );
2823 #ifndef DISABLE_VTKVIEWER
2824 if ( sec == QString( "VTKViewer" ) && param == QString( "enable_selection" ) )
2826 bool isToEnableSelection = resMgr->booleanValue( "VTKViewer", "enable_selection", true );
2827 QList<SUIT_ViewManager*> lst;
2828 #ifndef DISABLE_SALOMEOBJECT
2829 viewManagers( SVTK_Viewer::Type(), lst );
2830 QListIterator<SUIT_ViewManager*> it( lst );
2831 while ( it.hasNext() )
2833 SUIT_ViewModel* vm = it.next()->getViewModel();
2834 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2837 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2838 if( vtkVM ) vtkVM->enableSelection( isToEnableSelection );
2844 #ifndef DISABLE_VTKVIEWER
2845 if ( sec == QString( "VTKViewer" ) && (param == QString( "spacemouse_func1_btn" ) ||
2846 param == QString( "spacemouse_func2_btn" ) ||
2847 param == QString( "spacemouse_func5_btn" ) ) )
2849 int btn1 = resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", 1 );
2850 int btn2 = resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", 2 );
2851 int btn3 = resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", 9 );
2852 QList<SUIT_ViewManager*> lst;
2853 #ifndef DISABLE_SALOMEOBJECT
2854 viewManagers( SVTK_Viewer::Type(), lst );
2855 QListIterator<SUIT_ViewManager*> it( lst );
2856 while ( it.hasNext() )
2858 SUIT_ViewModel* vm = it.next()->getViewModel();
2859 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
2862 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
2863 if( vtkVM ) vtkVM->setSpacemouseButtons( btn1, btn2, btn3 );
2868 if( sec=="ObjectBrowser" )
2870 SUIT_DataBrowser* ob = objectBrowser();
2874 if ( param=="auto_size_first" )
2876 bool autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
2877 ob->setAutoSizeFirstColumn( autoSizeFirst );
2878 if ( autoSizeFirst )
2879 ob->adjustFirstColumnWidth();
2881 else if ( param=="auto_size" ) {
2882 bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
2883 ob->setAutoSizeColumns(autoSize);
2885 ob->adjustColumnsWidth();
2887 else if ( param=="resize_on_expand_item" ) {
2888 bool resizeOnExpandItem = resMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
2889 ob->setResizeOnExpandItem(resizeOnExpandItem);
2891 else if ( param == "auto_hide_search_tool" ) {
2892 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
2898 if( param=="auto_save_interval" ) {
2899 myAutoSaveTimer->stop();
2900 int autoSaveInterval = resMgr->integerValue( "Study", "auto_save_interval", 0 );
2901 if ( activeStudy() && autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
2905 #ifndef DISABLE_PYCONSOLE
2906 if( sec=="PyConsole" && pythonConsole() )
2908 if ( param=="font" ) {
2909 pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) );
2911 else if ( param=="show_banner" ) {
2912 pythonConsole()->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
2919 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
2921 if ( param == "visible_count" )
2922 mru->setVisibleCount( resMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
2923 else if ( param == "max_count" )
2924 mru->setHistoryCount( resMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
2925 else if ( param == "insert_mode" )
2926 mru->setInsertMode( resMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
2927 else if ( param == "link_type" )
2928 mru->setLinkType( resMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
2929 else if ( param == "show_clear" )
2930 mru->setClearPossible( resMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
2931 else if ( param == "show_mru" )
2932 mru->setVisible( resMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
2935 if ( sec == "language" && param == "language" )
2937 SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LANG_CHANGED" ) );
2939 if ( sec == "language" && param == "locale")
2941 SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LOCALE_CHANGED" ) );
2943 if ( sec == "desktop" && param == "opaque_resize" ) {
2944 bool opaqueResize = resMgr->booleanValue( "desktop", "opaque_resize", false );
2945 QMainWindow::DockOptions dopts = desktop()->dockOptions();
2946 if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
2947 else dopts &= ~QMainWindow::AnimatedDocks;
2948 desktop()->setDockOptions( dopts );
2949 desktop()->setOpaqueResize( opaqueResize );
2950 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
2951 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
2954 #ifndef DISABLE_PLOT2DVIEWER
2955 QList<SUIT_ViewManager*> lst;
2956 viewManagers( Plot2d_Viewer::Type(), lst );
2957 QListIterator<SUIT_ViewManager*> itPlot2d( lst );
2958 while ( itPlot2d.hasNext() ) {
2959 SUIT_ViewManager* viewMgr = itPlot2d.next();
2960 SUIT_ViewModel* vm = viewMgr->getViewModel();
2961 if ( !vm || !vm->inherits( "Plot2d_Viewer" ) )
2964 Plot2d_Viewer* Plot2dVM = dynamic_cast<Plot2d_Viewer*>( vm );
2966 viewMgr->setViewModel( vm );
2967 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
2969 Plot2d_ViewFrame* frame = wnd->getViewFrame();
2970 frame->SetPreference();
2979 void LightApp_Application::loadPreferences()
2981 CAM_Application::loadPreferences();
2983 SUIT_ResourceMgr* aResMgr = resourceMgr();
2988 static bool mru_load = true;
2991 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
2993 mru->setVisible( aResMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
2994 mru->setVisibleCount( aResMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
2995 mru->setHistoryCount( aResMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
2996 mru->setInsertMode( aResMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
2997 mru->setLinkType( aResMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
2998 mru->setClearPossible( aResMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
2999 mru->loadLinks( aResMgr, "MRU" );
3005 QStringList mods = aResMgr->parameters( "windows_visibility" );
3006 for ( QStringList::const_iterator itr = mods.begin(); itr != mods.end(); ++itr )
3009 if ( aResMgr->value( "windows_visibility", *itr, arr ) )
3010 myWinVis.insert( *itr, arr );
3014 desktop()->retrieveGeometry( aResMgr->stringValue( "desktop", "geometry" ) );
3015 bool opaqueResize = aResMgr->booleanValue( "desktop", "opaque_resize", false );
3016 QMainWindow::DockOptions dopts = desktop()->dockOptions();
3017 if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
3018 else dopts &= ~QMainWindow::AnimatedDocks;
3019 desktop()->setDockOptions( dopts );
3020 desktop()->setOpaqueResize( opaqueResize );
3021 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
3022 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
3029 void LightApp_Application::savePreferences()
3031 CAM_Application::savePreferences();
3033 saveDockWindowsState();
3035 SUIT_ResourceMgr* aResMgr = resourceMgr();
3040 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3042 mru->saveLinks( aResMgr, "MRU" );
3044 for ( WinVis::const_iterator itr = myWinVis.begin(); itr != myWinVis.end(); ++itr )
3045 aResMgr->setValue( "windows_visibility", itr.key(), itr.value() );
3048 aResMgr->setValue( "desktop", "geometry", desktop()->storeGeometry() );
3050 #if GUI_DEVELOPMENT > 0
3051 aResMgr->setValue( "salome", "version", QString(GUI_VERSION_STR)+"dev" );
3053 aResMgr->setValue( "salome", "version", QString(GUI_VERSION_STR) );
3060 Updates desktop title
3062 void LightApp_Application::updateDesktopTitle()
3064 QString aTitle = applicationName();
3065 QString aVer = applicationVersion();
3066 if ( !aVer.isEmpty() )
3067 aTitle += QString( " " ) + aVer;
3069 if ( activeStudy() ) {
3070 QString sName = SUIT_Tools::file( activeStudy()->studyName().trimmed(), false );
3071 aTitle += QString( " - [%1]" ).arg( sName );
3074 desktop()->setWindowTitle( aTitle );
3078 \brief Get map of the operations which can be performed
3079 on the module activation.
3081 The method should return the map of the kind \c {<id>:<name>}
3082 where \c <id> is an integer identifier of the operation and
3083 \c <name> is a title for the button to be added to the
3084 dialog box. After user selects the required operation by the
3085 clicking the corresponding button in the dialog box, its identifier
3086 is passed to the moduleActionSelected() method to process
3089 \return map of the operations
3090 \sa moduleActionSelected()
3092 QMap<int, QString> LightApp_Application::activateModuleActions() const
3094 QMap<int, QString> opmap;
3095 opmap.insert( NewStudyId, tr( "ACTIVATE_MODULE_OP_NEW" ) );
3096 opmap.insert( OpenStudyId, tr( "ACTIVATE_MODULE_OP_OPEN" ) );
3101 \brief Called when the used selectes required operation chosen
3102 from "Activate module" dialog box.
3104 Performs the required operation according to the user choice.
3106 \param id operation identifier
3107 \sa activateModuleActions()
3109 void LightApp_Application::moduleActionSelected( const int id )
3124 Updates windows after close document
3126 void LightApp_Application::afterCloseDoc()
3130 CAM_Application::afterCloseDoc();
3134 Updates actions of active module
3136 void LightApp_Application::updateModuleActions()
3139 if ( activeModule() ) {
3140 modName = activeModule()->moduleName();
3141 if ( !isModuleAccessible( modName ) ) {
3142 QList<SUIT_Application*> apps = SUIT_Session::session()->applications();
3143 foreach( SUIT_Application* app, apps ) {
3144 LightApp_Application* lapp = dynamic_cast<LightApp_Application*>( app );
3145 if ( lapp && lapp != this )
3146 lapp->removeModuleAction( modName );
3151 LightApp_ModuleAction* moduleAction =
3152 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
3154 moduleAction->setActiveModule( modName );
3157 void LightApp_Application::removeModuleAction( const QString& modName )
3159 LightApp_ModuleAction* moduleAction =
3160 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
3162 moduleAction->removeModule( modName );
3166 Gets current windows.
3167 \param winMap - output current windows map.
3169 void LightApp_Application::currentWindows( QMap<int, int>& winMap ) const
3172 if ( !activeStudy() )
3175 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
3176 ((LightApp_Module*)activeModule())->windows( winMap );
3178 defaultWindows( winMap );
3182 Gets current view managers.
3183 \param lst - output current view managers list.
3185 void LightApp_Application::currentViewManagers( QStringList& lst ) const
3188 if ( !activeStudy() )
3191 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
3192 ((LightApp_Module*)activeModule())->viewManagers( lst );
3194 defaultViewManagers( lst );
3200 void LightApp_Application::updateWindows()
3202 QMap<int, int> winMap;
3203 currentWindows( winMap );
3205 if ( activeStudy() )
3207 for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
3209 if ( !dockWindow( it.key() ) )
3210 getWindow( it.key() );
3214 for ( WinMap::ConstIterator it = myWin.begin(); it != myWin.end(); ++it )
3216 QWidget* wid = it.value();
3217 if ( activeStudy() )
3218 wid->setVisible( winMap.contains( it.key() ) );
3223 if ( activeStudy() )
3224 loadDockWindowsState();
3230 Updates view managers
3232 void LightApp_Application::updateViewManagers()
3235 currentViewManagers( lst );
3237 for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
3238 getViewManager( *it, true );
3242 Loads windows geometry
3244 void LightApp_Application::loadDockWindowsState()
3248 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
3249 bool storeWin = aResMgr->booleanValue( "Study", "store_positions", true );
3250 bool storeTb = aResMgr->booleanValue( "Study", "store_tool_positions", true );
3251 long version = Qtx::versionToId( aResMgr->stringValue( "salome", "version", "" ) );
3254 if ( activeModule() )
3255 modName = activeModule()->name();
3257 QtxResourceMgr::WorkingMode prevMode = aResMgr->workingMode();
3258 aResMgr->setWorkingMode(QtxResourceMgr::IgnoreUserValues);
3259 QByteArray aDefaultState;
3260 aResMgr->value("windows_geometry", modName , aDefaultState );
3261 QByteArray aDefaultVisibility;
3262 aResMgr->value("windows_visibility", modName , aDefaultVisibility );
3263 bool hasDefaultVisibility = !aDefaultVisibility.isEmpty();
3264 aResMgr->setWorkingMode(prevMode);
3266 if( !storeWin && !storeTb && aDefaultState.isEmpty() && !hasDefaultVisibility)
3269 if ( aResMgr->hasValue("windows_geometry" ,modName ) ) {
3271 if ( version > Qtx::versionToId( "7.4.1" ) )
3272 aResMgr->value( "windows_geometry", modName , arr );
3274 arr = aDefaultState;
3275 QByteArray aTargetArray = processState(arr, storeWin, storeTb, true, aDefaultState);
3276 desktop()->restoreState( aTargetArray );
3279 QStringList mainToolbarsNames;
3280 mainToolbarsNames << "SalomeStandard" << "SalomeModules";
3281 QList<QToolBar*> mainToolbars = findToolBars( mainToolbarsNames );
3282 foreach( QToolBar* tb, mainToolbars ) tb->setVisible( true );
3284 if ( !myWinVis.contains( modName ) && aDefaultVisibility.isEmpty())
3287 QMap<QString, bool> *tbMap = 0;
3288 QMap<QString, bool> *dwMap = 0;
3290 QMap<QString, bool> userTbMap, userDwMap;
3291 dockWindowsState( myWinVis[modName], userTbMap, userDwMap );
3293 QMap<QString, bool> defaultTbMap, defaultDwMap;
3294 if(hasDefaultVisibility) {
3295 dockWindowsState( aDefaultVisibility, defaultTbMap, defaultDwMap);
3301 if(hasDefaultVisibility){
3302 tbMap = &defaultTbMap;
3309 if(hasDefaultVisibility){
3310 dwMap = &defaultDwMap;
3315 QList<QToolBar*> tbList = findToolBars();
3316 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit )
3318 QToolBar* tb = *tit;
3319 if ( tbMap->contains( tb->objectName() ) ) {
3320 tb->setVisible( (*tbMap)[tb->objectName()] );
3326 QList<QDockWidget*> dwList = qFindChildren<QDockWidget*>( desktop() );
3327 for ( QList<QDockWidget*>::iterator dit = dwList.begin(); dit != dwList.end(); ++dit )
3329 QDockWidget* dw = *dit;
3331 QObject* po = Qtx::findParent( dw, "QMainWindow" );
3332 if ( po != desktop() )
3335 if ( dwMap->contains( dw->objectName() ) )
3336 dw->setVisible( (*dwMap)[dw->objectName()] );
3344 Saves windows geometry
3346 void LightApp_Application::saveDockWindowsState()
3351 bool storeWin = resourceMgr()->booleanValue( "Study", "store_positions", true );
3352 bool storeTb = resourceMgr()->booleanValue( "Study", "store_tool_positions", true );
3354 if( !storeWin && !storeTb )
3358 if ( activeModule() )
3359 modName = activeModule()->name();
3361 QByteArray arr = desktop()->saveState();
3362 resourceMgr()->setValue( "windows_geometry", modName, processState(arr, storeWin, storeTb, false) );
3365 if ( myWinVis.contains( modName ) )
3366 visArr = myWinVis[modName];
3368 QMap<QString, bool> tbMap, dwMap;
3369 dockWindowsState( visArr, tbMap, dwMap );
3371 QList<QToolBar*> tbList = qFindChildren<QToolBar*>( desktop() );
3372 for ( QList<QToolBar*>::iterator it = tbList.begin(); it != tbList.end(); ++it )
3375 tbMap.insert( tb->objectName(), tb->toggleViewAction()->isChecked() );
3378 QList<QDockWidget*> dwList = qFindChildren<QDockWidget*>( desktop() );
3379 for ( QList<QDockWidget*>::iterator it = dwList.begin(); it != dwList.end(); ++it )
3381 QDockWidget* wid = *it;
3382 dwMap.insert( wid->objectName(), wid->toggleViewAction()->isChecked() );
3385 visArr = dockWindowsState( tbMap, dwMap );
3387 myWinVis.insert( modName, visArr );
3390 QByteArray LightApp_Application::dockWindowsState( const QMap<QString, bool>& tb, const QMap<QString, bool>& dw ) const
3393 QDataStream stream( &visArr, QIODevice::WriteOnly );
3395 stream << (uchar)ToolBarMarker;
3396 stream << tb.size();
3397 for ( QMap<QString, bool>::const_iterator tit = tb.begin(); tit != tb.end(); ++tit )
3399 stream << tit.key();
3400 stream << (uchar)( tit.value() ? 1 : 0 );
3403 stream << (uchar)DockWidgetMarker;
3404 stream << dw.size();
3405 for ( QMap<QString, bool>::const_iterator wit = dw.begin(); wit != dw.end(); ++wit )
3407 stream << wit.key();
3408 stream << (uchar)( wit.value() ? 1 : 0 );
3414 void LightApp_Application::dockWindowsState( const QByteArray& arr, QMap<QString, bool>& tb, QMap<QString, bool>& dw ) const
3419 QByteArray visArr = arr;
3420 QDataStream stream( &visArr, QIODevice::ReadOnly );
3424 if ( marker != ToolBarMarker )
3429 for ( int i = 0; i < lines; ++i )
3432 stream >> objectName;
3435 tb.insert( objectName, shown );
3439 if ( marker != DockWidgetMarker )
3443 for ( int j = 0; j < lines; ++j )
3446 stream >> objectName;
3449 dw.insert( objectName, shown );
3454 Adds icon names for modules
3456 void LightApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) const
3460 SUIT_ResourceMgr* resMgr = resourceMgr();
3464 QStringList modList;
3465 modules( modList, false );
3467 for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )
3469 QString modName = *it;
3470 QString modIntr = moduleName( modName );
3471 QString modIcon = resMgr->stringValue( modIntr, "icon", QString() );
3473 if ( modIcon.isEmpty() )
3476 if ( SUIT_Tools::extension( modIcon ).isEmpty() )
3477 modIcon += QString( ".png" );
3479 iconMap.insert( modName, modIcon );
3484 Inserts items in popup, which necessary for current application
3486 void LightApp_Application::contextMenuPopup( const QString& type, QMenu* thePopup, QString& title )
3489 LightApp_SelectionMgr* selMgr = LightApp_Application::selectionMgr();
3490 bool cacheIsOn = selMgr->isSelectionCacheEnabled();
3491 selMgr->setSelectionCacheEnabled( true );
3493 SUIT_DataBrowser* ob = objectBrowser();
3495 CAM_Application::contextMenuPopup( type, thePopup, title );
3497 if ( ob && type == ob->popupClientType() ) {
3498 thePopup->addSeparator();
3499 QAction* a = thePopup->addAction( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
3500 if ( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) )
3501 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) );
3504 #ifndef DISABLE_SALOMEOBJECT
3505 if ( selMgr && ob ) {
3506 SALOME_ListIO selected;
3507 selMgr->selectedObjects( selected );
3508 if(selected.Extent() == 1){
3509 Handle(SALOME_InteractiveObject) anIObject = selected.First();
3510 SUIT_DataObject* obj = findObject(anIObject->getEntry());
3511 if(obj && obj->renameAllowed()) {
3512 QAction* a = new QAction(tr("MEN_RENAME_OBJ"), thePopup);
3513 connect( a, SIGNAL( triggered(bool) ), ob, SLOT( onStartEditing() ) );
3514 if ( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) )
3515 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) );
3517 QList<QAction*> acts = thePopup->actions();
3518 QAction* firstAction = acts.count() > 0 ? acts.first() : 0;
3519 thePopup->insertAction(firstAction,a);
3525 selMgr->setSelectionCacheEnabled( cacheIsOn );
3531 void LightApp_Application::createEmptyStudy()
3533 CAM_Application::createEmptyStudy();
3535 if ( objectBrowser() )
3536 objectBrowser()->updateTree();
3538 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
3539 if ( aResMgr && activeStudy() ) {
3540 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
3541 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
3546 void LightApp_Application::setDesktop( SUIT_Desktop* desk )
3548 CAM_Application::setDesktop( desk );
3551 connect( desk, SIGNAL( message( const QString& ) ),
3552 this, SLOT( onDesktopMessage( const QString& ) ), Qt::UniqueConnection );
3553 connect( desk, SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
3554 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
3560 \param mod - module to be activated
3562 bool LightApp_Application::activateModule( CAM_Module* mod )
3564 bool res = CAM_Application::activateModule( mod );
3566 if ( objectBrowser() )
3567 objectBrowser()->updateTree();
3573 \return keyborad accelerators manager object
3575 SUIT_Accel* LightApp_Application::accel() const
3581 Removes dead widget container from map
3583 void LightApp_Application::onWCDestroyed( QObject* ob )
3585 // remove destroyed widget container from windows map
3586 for ( WinMap::ConstIterator itr = myWin.begin(); itr != myWin.end(); ++itr )
3588 if ( itr.value() != ob )
3591 int key = itr.key();
3592 myWin.remove( key );
3597 void LightApp_Application::onMRUActivated( const QString& name )
3599 SUIT_Session* s = SUIT_Session::session();
3600 if ( s && s->activeApplication() == this )
3604 void LightApp_Application::onStylePreferences()
3606 Style_PrefDlg dlg( desktop() );
3609 resourceMgr()->setValue( "Style", "use_salome_style", Style_Salome::isActive() );
3612 void LightApp_Application::onFullScreen(){
3613 if(myScreenHelper) {
3614 if(desktop()->isFullScreen())
3615 myScreenHelper->switchToNormalScreen();
3617 myScreenHelper->switchToFullScreen();
3622 Connects just added view manager
3624 void LightApp_Application::addViewManager( SUIT_ViewManager* vm )
3626 connect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
3627 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
3628 CAM_Application::addViewManager( vm );
3632 Remove view manager from memory
3634 void LightApp_Application::removeViewManager( SUIT_ViewManager* vm )
3636 disconnect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
3637 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
3638 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
3640 aStudy->removeViewMgr(vm->getGlobalId());
3642 CAM_Application::removeViewManager( vm );
3644 LightApp_SelectionMgr* selMgr = selectionMgr();
3645 QList<SUIT_Selector*> selectors;
3646 selMgr->selectors( selectors );
3647 foreach( SUIT_Selector* selector, selectors ) {
3648 if ( selector->owner() == vm->getViewModel() ) {
3653 // IPAL22894: Crash on closing OCC view
3659 Renames active window of desktop
3661 void LightApp_Application::onRenameWindow()
3666 QWidget* w = desktop()->activeWindow();
3671 QString name = QInputDialog::getText( w, tr( "TOT_RENAME" ), tr( "PRP_RENAME" ), QLineEdit::Normal, w->windowTitle(), &ok );
3672 if( ok && !name.isEmpty() )
3673 w->setWindowTitle( name );
3677 Closes active window of desktop
3679 void LightApp_Application::onCloseWindow()
3684 QWidget* w = desktop()->activeWindow();
3692 Closes all windows of desktop
3694 void LightApp_Application::onCloseAllWindow()
3696 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
3700 QList<SUIT_ViewWindow*> wndList = desk->windows();
3701 SUIT_ViewWindow* wnd;
3702 foreach( wnd, wndList )
3710 Groups all windows of desktop
3712 void LightApp_Application::onGroupAllWindow()
3714 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
3718 QtxWorkstack* wgStack = desk->workstack();
3724 \return if the library of module exists
3725 \param moduleTitle - title of module
3727 bool LightApp_Application::isLibExists( const QString& moduleTitle ) const
3729 if( moduleTitle.isEmpty() )
3732 QString lib = moduleLibrary( moduleTitle );
3734 //abd: changed libSalomePyQtGUI to SalomePyQtGUI for WIN32
3735 bool isPythonModule = lib.contains("SalomePyQtGUI");
3736 bool isPythonLightModule = lib.contains("SalomePyQtGUILight");
3740 paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
3742 paths = QString(::getenv( "LD_LIBRARY_PATH" )).split( ":", QString::SkipEmptyParts );
3745 bool isLibFound = false;
3746 QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
3747 for( ; anIt!=aLast; anIt++ )
3749 QFileInfo inf( Qtx::addSlash( *anIt ) + lib );
3760 INFOS( "\n****************************************************************" << std::endl
3761 << "* Warning: library " << lib.toLatin1().constData() << " cannot be found" << std::endl
3762 << "* Module " << moduleTitle.toLatin1().constData() << " will not be available in GUI mode" << std::endl
3763 << "****************************************************************" << std::endl );
3765 else if ( !isPythonModule && !isPythonLightModule)
3768 if ( isPythonModule || isPythonLightModule)
3770 QString pylib = moduleName( moduleTitle ) + QString(".py");
3771 QString pylibgui = moduleName( moduleTitle ) + QString("GUI.py");
3773 // Check the python library
3775 // paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
3777 paths = QString(::getenv( "PYTHONPATH" )).split( ":", QString::SkipEmptyParts );
3779 bool isPyLib = false, isPyGuiLib = false;
3780 QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
3781 for( ; anIt!=aLast; anIt++ )
3783 QFileInfo inf( Qtx::addSlash( *anIt ) + pylib );
3784 QFileInfo infgui( Qtx::addSlash( *anIt ) + pylibgui );
3786 if(!isPythonLightModule)
3787 if( !isPyLib && inf.exists() )
3790 if( !isPyGuiLib && infgui.exists() )
3793 if ((isPyLib || isPythonLightModule ) && isPyGuiLib && isLibFound)
3797 printf( "\n****************************************************************\n" );
3798 printf( "* Warning: python library for %s cannot be found:\n", moduleTitle.toLatin1().constData() );
3800 printf( "* No module named %s\n", moduleName( moduleTitle ).toLatin1().constData() );
3802 printf( "* No module named %s\n", (moduleName( moduleTitle ) + QString("GUI")).toLatin1().constData() );
3803 printf( "****************************************************************\n" );
3810 \return default name for an active study
3812 void LightApp_Application::setDefaultStudyName( const QString& theName )
3814 QStringList anInfoList;
3815 modules( anInfoList, false );
3817 LightApp_Study* aStudy = (LightApp_Study*)activeStudy();
3818 if( anInfoList.count() == 1 && // to avoid a conflict between different modules
3819 !aStudy->isSaved() )
3821 aStudy->setStudyName( theName );
3822 updateDesktopTitle();
3827 Custom event handler
3829 bool LightApp_Application::event( QEvent* e )
3831 if( e && e->type()==2000 )
3833 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
3834 QString* d = ( QString* )ce->data();
3835 if( SUIT_MessageBox::question(0, tr("WRN_WARNING"),
3837 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
3838 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
3839 showPreferences( tr( "PREF_APP" ) );
3844 return CAM_Application::event( e );
3847 /*! Check data object */
3848 bool LightApp_Application::checkDataObject(LightApp_DataObject* theObj)
3852 bool isSuitable = !theObj->entry().isEmpty() &&
3853 !theObj->componentDataType().isEmpty() &&
3854 !theObj->name().isEmpty();
3861 int LightApp_Application::openChoice( const QString& aName )
3863 int choice = CAM_Application::openChoice( aName );
3865 if ( choice == OpenExist ) // The document is already open.
3867 // Do you want to reload it?
3868 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "QUE_DOC_ALREADYOPEN" ).arg( aName ),
3869 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No ) == SUIT_MessageBox::Yes )
3870 choice = OpenReload;
3876 bool LightApp_Application::openAction( const int choice, const QString& aName )
3883 STD_Application* app = 0;
3884 SUIT_Session* session = SUIT_Session::session();
3885 QList<SUIT_Application*> appList = session->applications();
3886 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !app; ++it )
3888 if ( (*it)->activeStudy() && (*it)->activeStudy()->studyName() == aName )
3889 app = ::qobject_cast<STD_Application*>( *it );
3894 app->onCloseDoc( false );
3895 appList = session->applications();
3896 STD_Application* other = 0;
3897 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !other; ++it )
3898 other = ::qobject_cast<STD_Application*>( *it );
3901 res = other->onOpenDoc( aName );
3906 res = CAM_Application::openAction( choice, aName );
3913 QStringList LightApp_Application::viewManagersTypes() const
3915 QStringList aTypesList;
3916 aTypesList += myUserWmTypes;
3917 #ifndef DISABLE_GLVIEWER
3918 aTypesList<<GLViewer_Viewer::Type();
3920 #ifndef DISABLE_PLOT2DVIEWER
3921 aTypesList<<Plot2d_Viewer::Type();
3923 #ifndef DISABLE_QXGRAPHVIEWER
3924 aTypesList<<QxScene_Viewer::Type();
3926 #ifndef DISABLE_OCCVIEWER
3927 aTypesList<<OCCViewer_Viewer::Type();
3929 #ifndef DISABLE_VTKVIEWER
3930 #ifndef DISABLE_SALOMEOBJECT
3931 aTypesList<<SVTK_Viewer::Type();
3933 aTypesList<<VTKViewer_Viewer::Type();
3939 * Removes all view managers of known types
3940 * Other view managers are ignored
3942 void LightApp_Application::clearKnownViewManagers()
3944 QStringList aTypesList = viewManagersTypes();
3945 QList<SUIT_ViewManager*> aMgrList;
3946 viewManagers( aMgrList );
3947 foreach (SUIT_ViewManager* aMgr, aMgrList) {
3948 if (aTypesList.contains(aMgr->getType()))
3949 removeViewManager(aMgr);
3954 Copy of current selection
3956 void LightApp_Application::onCopy()
3958 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
3964 Paste of current data in clipboard
3966 void LightApp_Application::onPaste()
3968 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
3974 Browse (i.e. set focus on) the published objects
3975 \param theIsApplyAndClose - flag indicating that the dialog for creating objects
3976 has been accepted by Ok (or Apply & Close) button
3977 \param theIsOptimizedBrowsing - flag switching to optimized browsing mode
3978 (to select the first published object only)
3979 \return entry of the selected object
3981 QString LightApp_Application::browseObjects( const QStringList& theEntryList,
3982 const bool theIsApplyAndClose,
3983 const bool theIsOptimizedBrowsing )
3986 if( SUIT_ResourceMgr* aResourceMgr = resourceMgr() )
3988 int aBrowsePolicy = aResourceMgr->integerValue( "ObjectBrowser", "browse_published_object", (int)BP_Never );
3989 switch( aBrowsePolicy )
3993 case BP_ApplyAndClose:
3994 if( !theIsApplyAndClose )
4002 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
4006 SUIT_DataBrowser* anOB = objectBrowser();
4010 SUIT_AbstractModel* aModel = dynamic_cast<SUIT_AbstractModel*>( anOB->model() );
4014 QStringListIterator anIter( theEntryList );
4015 if( theIsOptimizedBrowsing )
4017 // go to the last entry
4019 if( anIter.hasPrevious() )
4023 // scroll to each entry in the list
4024 // (in optimized mode - to the last entry only)
4026 LightApp_DataObject* anObject = 0;
4027 while( anIter.hasNext() )
4029 anEntry = anIter.next();
4030 if( !anEntry.isEmpty() )
4032 anObject = aStudy->findObjectByEntry( anEntry );
4035 QModelIndex anIndex = aModel->index( anObject );
4036 anOB->treeView()->scrollTo( anIndex );
4041 // always select the last object
4042 if( anObject && !anEntry.isEmpty() )
4044 QList<SUIT_Selector*> aSelectorList;
4045 selectionMgr()->selectors( "ObjectBrowser", aSelectorList );
4046 if( !aSelectorList.isEmpty() )
4048 if( LightApp_OBSelector* aSelector = dynamic_cast<LightApp_OBSelector*>( aSelectorList.first() ) )
4050 bool anIsAutoBlock = aSelector->autoBlock();
4052 // temporarily disable auto block, to emit LightApp_SelectionMgr::currentSelectionChanged() signal
4053 aSelector->setAutoBlock( false );
4055 SUIT_DataOwnerPtrList aList;
4056 #ifndef DISABLE_SALOMEOBJECT
4057 Handle(SALOME_InteractiveObject) aSObj = new SALOME_InteractiveObject
4058 ( anObject->entry().toLatin1().constData(),
4059 anObject->componentDataType().toLatin1().constData(),
4060 anObject->name().toLatin1().constData() );
4061 LightApp_DataOwner* owner = new LightApp_DataOwner( aSObj );
4063 LightApp_DataOwner* owner = new LightApp_DataOwner( anEntry );
4066 aList.append( owner );
4067 selectionMgr()->setSelected( aList );
4070 // restore auto block flag
4071 aSelector->setAutoBlock( anIsAutoBlock );
4079 SUIT_DataObject* LightApp_Application::findObject( const QString& id ) const
4081 LightApp_Study* study = dynamic_cast<LightApp_Study*>( activeStudy() );
4082 return study ? study->findObjectByEntry( id ) : 0;
4086 Checks that an object can be renamed.
4087 \param entry entry of the object
4088 \brief Return \c true if object can be renamed
4090 bool LightApp_Application::renameAllowed( const QString& /*entry*/) const {
4095 Rename object by entry.
4096 \param entry entry of the object
4097 \param name new name of the object
4098 \brief Return \c true if rename operation finished successfully, \c false otherwise.
4100 bool LightApp_Application::renameObject( const QString& entry, const QString& ) {
4104 /*! Process standard messages from desktop */
4105 void LightApp_Application::onDesktopMessage( const QString& message )
4107 const QString sectionSeparator = "/";
4109 if ( message.toLower() == "updateobjectbrowser" ||
4110 message.toLower() == "updateobjbrowser" ) {
4111 // update object browser
4112 updateObjectBrowser();
4115 QStringList data = message.split( sectionSeparator );
4116 if ( data.count() > 1 ) {
4117 QString msgType = data[0].trimmed();
4118 LightApp_Module* sMod = 0;
4119 CAM_Module* mod = module( msgType );
4121 mod = module( moduleTitle( msgType ) );
4122 if ( mod && mod->inherits( "LightApp_Module" ) )
4123 sMod = (LightApp_Module*)mod;
4125 if ( msgType.toLower() == "preferences" ) {
4126 // requested preferences change: should be given as "preferences/<section>/<name>/<value>"
4127 // for example "preferences/Study/multi_file_dump/true"
4128 if ( data.count() > 3 ) {
4129 QString section = data[1].trimmed();
4130 QString param = data[2].trimmed();
4131 QString value = QStringList( data.mid(3) ).join( sectionSeparator );
4132 resourceMgr()->setValue( section, param, value );
4136 // received message for the module
4137 QString msg = QStringList( data.mid(1) ).join( sectionSeparator );
4138 sMod->message( msg );
4146 Returns all top level toolbars.
4147 Note : Result list contains only main window toolbars, not including toolbars from viewers.
4149 QList<QToolBar*> LightApp_Application::findToolBars( const QStringList& names )
4151 QList<QToolBar*> aResult;
4152 QList<QToolBar*> tbList = qFindChildren<QToolBar*>( desktop() );
4153 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit ) {
4154 QToolBar* tb = *tit;
4155 QObject* po = Qtx::findParent( tb, "QMainWindow" );
4156 if ( po != desktop() )
4158 if ( names.isEmpty() || names.contains( tb->objectName() ) )
4165 Internal method to parse toolbars and dockable windows state.
4167 QByteArray LightApp_Application::processState(QByteArray& input,
4168 const bool processWin,
4169 const bool processTb,
4170 const bool isRestoring,
4171 QByteArray defaultState) {
4174 bool hasDefaultState = !defaultState.isEmpty();
4175 bool isDockWinWriten = false;
4177 //Write date from users settings
4179 QDataStream tmpInputData(&input, QIODevice::ReadOnly);
4180 int marker, version;
4182 tmpInputData >> marker;
4183 tmpInputData >> version;
4184 tmpInputData >> dockmarker;
4185 tmpInputData >> nbDocWin;
4187 if(processWin && processTb && !isRestoring) {
4189 } else if(!processWin && !processTb ) {
4191 aRes = defaultState;
4193 QDataStream aData(&aRes, QIODevice::WriteOnly);
4194 QList<QToolBar*> aToolBars = findToolBars();
4197 for ( QList<QToolBar*>::iterator tit = aToolBars.begin(); tit != aToolBars.end(); ++tit ) {
4198 QToolBar* tb = *tit;
4199 aNames.append(tb->objectName());
4202 int toolBarMarkerIndex = getToolbarMarkerIndex(input,aNames);
4203 if(toolBarMarkerIndex < 0)
4205 QDataStream anInputData(&input, QIODevice::ReadOnly);
4207 int toolBarMarkerIndexDef;
4208 if(hasDefaultState) {
4209 toolBarMarkerIndexDef = getToolbarMarkerIndex(defaultState, aNames);
4210 if(toolBarMarkerIndexDef < 0)
4213 QDataStream anInputDataDef(&defaultState, QIODevice::ReadOnly);
4215 QDataStream* aTargetData = 0;
4216 int aTargetIndex = -1;
4218 QByteArray currentArr = desktop()->saveState();
4219 QDataStream anInputDataCur(¤tArr, QIODevice::ReadOnly);
4220 bool useInputData = !isRestoring || (isRestoring && nbDocWin > 0);
4221 if(processWin && useInputData) {
4222 aTargetData = &anInputData;
4223 aTargetIndex = toolBarMarkerIndex;
4225 //Write date from default settings
4226 if(hasDefaultState) {
4227 aTargetData = &anInputDataDef;
4228 aTargetIndex = toolBarMarkerIndexDef;
4230 //If no default state, write current snapshot of the dockable windows
4232 aTargetData = &anInputDataCur;
4233 int toolBarMarkerIndexCur = getToolbarMarkerIndex(currentArr, aNames);
4234 aTargetIndex = toolBarMarkerIndexCur;
4239 if(aTargetData && aTargetIndex >= 0 ) {
4240 aTargetData->device()->seek(0);
4241 while( aTargetData->device()->pos() < aTargetIndex ) {
4246 isDockWinWriten = true;
4253 aTargetData = &anInputData;
4254 aTargetIndex = toolBarMarkerIndex;
4256 if(hasDefaultState) {
4257 aTargetData = &anInputDataDef;
4258 aTargetIndex = toolBarMarkerIndexDef;
4262 if(aTargetData && aTargetIndex >= 0) {
4264 if(!isDockWinWriten ) {
4265 //Write version marker
4266 int marker, version;
4267 aTargetData->device()->seek(0);
4268 *aTargetData >> marker;
4269 *aTargetData >> version;
4272 aData << (uchar) QDockWidgetMarker;
4274 int shift = 4*sizeof(int) + sizeof(QSize);
4275 index = aTargetIndex - shift;
4277 index = aTargetIndex;
4280 aTargetData->device()->seek(index);
4281 while(!aTargetData->atEnd()) {
4286 } else { // Not treat toolbars
4287 aData << (uchar) QToolBarMarker;
4288 aData << (int) 0; //Nb toolbars = 0
4295 \brief Emits operationFinished signal.
4296 \param theModuleName the name of the module which perfomed the operation
4297 \param theOperationName the operation name
4298 \param theEntryList the list of the created objects entries
4300 void LightApp_Application::emitOperationFinished( const QString& theModuleName,
4301 const QString& theOperationName,
4302 const QStringList& theEntryList )
4304 emit operationFinished( theModuleName, theOperationName, theEntryList );
4308 Update visibility state of given objects
4310 void LightApp_Application::updateVisibilityState( DataObjectList& theList,
4311 SUIT_ViewModel* theViewModel )
4313 if ( !theViewModel || theList.isEmpty() ) return;
4315 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
4316 if ( !aStudy ) return;
4318 SALOME_View* aView = dynamic_cast<SALOME_View*>( theViewModel );
4320 for ( DataObjectList::iterator itr = theList.begin(); itr != theList.end(); ++itr ) {
4321 LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>(*itr);
4323 if ( !obj || aStudy->isComponent( obj->entry() ) )
4326 LightApp_Module* anObjModule = dynamic_cast<LightApp_Module*>(obj->module());
4327 if ( anObjModule ) {
4328 LightApp_Displayer* aDisplayer = anObjModule->displayer();
4330 Qtx::VisibilityState anObjState = Qtx::UnpresentableState;
4331 if ( aDisplayer->canBeDisplayed( obj->entry(), theViewModel->getType() ) ) {
4332 if ( aView && aDisplayer->IsDisplayed( obj->entry(), aView ) )
4333 anObjState = Qtx::ShownState;
4335 anObjState = Qtx::HiddenState;
4337 aStudy->setVisibilityState( obj->entry(), anObjState );
4344 * Called when window activated
4346 void LightApp_Application::onWindowActivated( SUIT_ViewWindow* theViewWindow )
4348 SUIT_DataBrowser* anOB = objectBrowser();
4351 SUIT_DataObject* rootObj = anOB->root();
4355 DataObjectList listObj = rootObj->children( true );
4357 SUIT_ViewModel* vmod = 0;
4358 if ( SUIT_ViewManager* vman = theViewWindow->getViewManager() )
4359 vmod = vman->getViewModel();
4360 updateVisibilityState( listObj, vmod );
4364 Called then view manager removed
4366 void LightApp_Application::onViewManagerRemoved( SUIT_ViewManager* )
4368 ViewManagerList lst;
4369 viewManagers( lst );
4370 if ( lst.count() == 1) { // in case if closed last view window
4371 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
4373 aStudy->setVisibilityStateForAll( Qtx::UnpresentableState );
4378 Check existing document.
4380 bool LightApp_Application::checkExistingDoc() {