1 // Copyright (C) 2007-2016 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_PyEditor.h"
39 #include "PyConsole_Interp.h"
40 #include "PyConsole_Console.h"
43 #include "LightApp_Application.h"
44 #include "LightApp_Module.h"
45 #include "LightApp_DataModel.h"
46 #include "LightApp_DataOwner.h"
47 #include "LightApp_Displayer.h"
48 #include "LightApp_Study.h"
49 #include "LightApp_Preferences.h"
50 #include "LightApp_PreferencesDlg.h"
51 #include "LightApp_ModuleDlg.h"
52 #include "LightApp_AboutDlg.h"
53 #include "LightApp_ModuleAction.h"
54 // temporary commented
55 #include "LightApp_EventFilter.h"
56 #include "LightApp_OBSelector.h"
57 #include "LightApp_SelectionMgr.h"
58 #include "LightApp_DataObject.h"
59 #include "LightApp_WgViewModel.h"
60 #include "LightApp_FullScreenHelper.h"
62 #include <GUI_version.h>
64 #include <SALOME_Event.h>
66 #ifdef USE_SALOME_STYLE
67 #include <Style_Salome.h>
68 #include <Style_PrefDlg.h>
69 #endif // USE_SALOME_STYLE
71 #include <CAM_Module.h>
72 #include <CAM_DataModel.h>
73 #include <CAM_Study.h>
74 #include <STD_TabDesktop.h>
76 #include <SUIT_DataBrowser.h>
77 #include <SUIT_Session.h>
78 #include <SUIT_Study.h>
79 #include <SUIT_FileDlg.h>
80 #include <SUIT_ResourceMgr.h>
81 #include <SUIT_ShortcutMgr.h>
82 #include <SUIT_Tools.h>
83 #include <SUIT_Accel.h>
84 #include <SUIT_MessageBox.h>
85 #include <SUIT_ViewWindow.h>
88 #include <QtxFontEdit.h>
89 #include <QtxToolBar.h>
90 #include <QtxTreeView.h>
91 #include <QtxMRUAction.h>
92 #include <QtxDockAction.h>
93 #include <QtxDockWidget.h>
94 #include <QtxActionToolMgr.h>
95 #include <QtxSearchTool.h>
96 #include <QtxWorkstack.h>
99 #include <LogWindow.h>
101 #ifndef DISABLE_GLVIEWER
102 #include <GLViewer_Viewer.h>
103 #include <GLViewer_ViewManager.h>
104 #include "LightApp_GLSelector.h"
107 #ifndef DISABLE_PLOT2DVIEWER
108 #include <Plot2d_ViewManager.h>
109 #include <Plot2d_ViewModel.h>
110 #include <Plot2d_ViewWindow.h>
111 #include <Plot2d_ViewFrame.h>
112 #include "LightApp_Plot2dSelector.h"
113 #ifndef DISABLE_SALOMEOBJECT
114 #include <SPlot2d_ViewModel.h>
116 #include <Plot2d_ViewModel.h>
120 #ifndef DISABLE_OCCVIEWER
121 #include <OCCViewer_ViewManager.h>
122 #include <OCCViewer_ViewFrame.h>
123 #include <OCCViewer_ViewPort3d.h>
124 #ifndef DISABLE_SALOMEOBJECT
125 #include <SOCC_ViewModel.h>
127 #include <OCCViewer_ViewModel.h>
129 #include "LightApp_OCCSelector.h"
132 #ifndef DISABLE_VTKVIEWER
133 #ifndef DISABLE_SALOMEOBJECT
134 #include <SVTK_ViewModel.h>
135 #include <SVTK_ViewManager.h>
136 #include "LightApp_VTKSelector.h"
138 #include <VTKViewer_ViewModel.h>
139 #include <VTKViewer_ViewManager.h>
141 #include <VTKViewer_ViewModel.h>
144 #ifndef DISABLE_QXGRAPHVIEWER
145 #include <QxScene_ViewManager.h>
146 #include <QxScene_ViewModel.h>
147 #include <QxScene_ViewWindow.h>
150 #ifndef DISABLE_GRAPHICSVIEW
151 #include "GraphicsView_Viewer.h"
152 #include "GraphicsView_ViewManager.h"
153 #include "LightApp_GVSelector.h"
156 #ifndef DISABLE_PVVIEWER
157 #include "PVViewer_ViewManager.h"
158 #include "PVViewer_ViewWindow.h"
159 #include "PVViewer_ViewModel.h"
162 #ifndef DISABLE_PYVIEWER
163 #include <PyViewer_ViewManager.h>
164 #include <PyViewer_ViewModel.h>
165 #include <PyViewer_ViewWindow.h>
169 #define VISIBILITY_COLUMN_WIDTH 25
175 #include <QStringList>
177 #include <QApplication>
179 #include <QStatusBar>
181 #include <QObjectList>
183 #include <QInputDialog>
184 #include <QFontDatabase>
186 #include <QByteArray>
190 #include <QHeaderView>
195 #include <utilities.h>
197 #define FIRST_HELP_ID 1000000
199 #ifndef DISABLE_SALOMEOBJECT
200 #include <SALOME_InteractiveObject.hxx>
201 #include <SALOME_ListIO.hxx>
204 #include <Standard_Version.hxx>
206 #define ToolBarMarker 0
207 #define DockWidgetMarker 1
209 static const char* imageEmptyIcon[] = {
212 "....................",
213 "....................",
214 "....................",
215 "....................",
216 "....................",
217 "....................",
218 "....................",
219 "....................",
220 "....................",
221 "....................",
222 "....................",
223 "....................",
224 "....................",
225 "....................",
226 "....................",
227 "....................",
228 "....................",
229 "....................",
230 "....................",
231 "...................."};
233 int LightApp_Application::lastStudyId = 0;
235 // Markers used to parse array with dockable windows and toolbars state.
236 // For more details please see the qdockarealayout.cpp && qtoolbararealayout.cpp
237 // in the Qt source code.
239 #define QDockWidgetMarker 0xfd // = DockWidgetStateMarker
240 #define QToolBarMarker 0xfc // = ToolBarStateMarkerEx
242 // Format of the Byte array with the windows and toolbar state is:
243 // VersionMarker|version|DockWidgetStateMarker|nbDockWidgetLines|...DocWidgetData...|ToolBarStateMarkerEx|nbToolBarLines|...ToolBarData...
245 //Find toolbar marker position in the array in the following way:
246 //since the 'toolbar marker' is not unique, find index of first occurrence of the
247 //'toolbar marker' in the array and check that next string is name of the toolbar
249 void LightAppCleanUpAppResources()
251 if ( LightApp_Application::_prefs_ ) {
252 delete LightApp_Application::_prefs_;
253 LightApp_Application::_prefs_ = 0;
259 int getToolbarMarkerIndex( QByteArray input, const QStringList& aFlags ) {
260 int aResult = -1,tmp = 0;
261 int inputLen = input.length();
262 QDataStream anInputData( &input, QIODevice::ReadOnly );
263 while ( tmp < inputLen ) {
264 tmp = input.indexOf( QToolBarMarker, tmp + 1 );
267 anInputData.device()->seek( tmp );
271 anInputData >> lines;
273 if ( lines == 0 && anInputData.atEnd() ) {
274 //Case then array doesn't contain information about toolbars,
285 if ( aFlags.contains( str ) ) {
293 QString langToName( const QString& lang )
295 // special processing for English language to avoid such result as "American English"
296 // as Qt cannot just say "English"
301 result = QLocale( lang ).nativeLanguageName();
307 \return last global id of study
309 int LightApp_Application::studyId()
311 return LightApp_Application::lastStudyId;
314 /*!Create new instance of LightApp_Application.*/
315 extern "C" LIGHTAPP_EXPORT SUIT_Application* createApplication()
317 return new LightApp_Application();
320 /*! \var global preferences of LightApp */
321 LightApp_Preferences* LightApp_Application::_prefs_ = 0;
325 \class LightApp_Application
326 Application containing LightApp module
330 LightApp_Application::LightApp_Application()
331 : CAM_Application( false ),
333 myScreenHelper(new LightApp_FullScreenHelper())
335 Q_INIT_RESOURCE( LightApp );
337 STD_TabDesktop* desk = new STD_TabDesktop();
338 desk->setFullScreenAllowed(false);
339 desk->setMinimizeAllowed(false);
343 // initialize auto save timer
344 myAutoSaveTimer = new QTimer( this );
345 myAutoSaveTimer->setSingleShot( true );
346 connect( myAutoSaveTimer, SIGNAL( timeout() ), this, SLOT( onSaveDoc() ) );
348 //connect( this, SIGNAL( moving() ), this, SLOT( onMoved() ) );
350 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
351 QPixmap aLogo = aResMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
353 desktop()->setWindowIcon( aLogo );
354 desktop()->setDockableMenuBar( false );
355 desktop()->setDockableStatusBar( false );
357 // base logo (salome itself)
358 desktop()->logoInsert( "_app_base", aResMgr->loadPixmap( "LightApp", tr( "APP_BASE_LOGO" ), false ) );
359 // extra logo (salome-based application)
360 desktop()->logoInsert( "_app_extra", aResMgr->loadPixmap( "LightApp", tr( "APP_EXTRA_LOGO" ), false ) );
364 mySelMgr = new LightApp_SelectionMgr( this );
366 myAccel = SUIT_Accel::getAccel();
368 #ifndef DISABLE_OCCVIEWER
369 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, OCCViewer_Viewer::Type() );
370 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, OCCViewer_Viewer::Type() );
371 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, OCCViewer_Viewer::Type() );
372 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, OCCViewer_Viewer::Type() );
373 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, OCCViewer_Viewer::Type() );
374 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, OCCViewer_Viewer::Type() );
375 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, OCCViewer_Viewer::Type() );
376 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, OCCViewer_Viewer::Type() );
377 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, OCCViewer_Viewer::Type() );
378 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, OCCViewer_Viewer::Type() );
379 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, OCCViewer_Viewer::Type() );
380 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, OCCViewer_Viewer::Type() );
382 #ifndef DISABLE_VTKVIEWER
383 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, VTKViewer_Viewer::Type() );
384 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, VTKViewer_Viewer::Type() );
385 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, VTKViewer_Viewer::Type() );
386 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, VTKViewer_Viewer::Type() );
387 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, VTKViewer_Viewer::Type() );
388 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, VTKViewer_Viewer::Type() );
389 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, VTKViewer_Viewer::Type() );
390 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, VTKViewer_Viewer::Type() );
391 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, VTKViewer_Viewer::Type() );
392 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, VTKViewer_Viewer::Type() );
393 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, VTKViewer_Viewer::Type() );
394 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, VTKViewer_Viewer::Type() );
396 #ifndef DISABLE_PLOT2DVIEWER
397 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, Plot2d_Viewer::Type() );
398 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, Plot2d_Viewer::Type() );
399 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, Plot2d_Viewer::Type() );
400 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, Plot2d_Viewer::Type() );
401 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, Plot2d_Viewer::Type() );
402 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, Plot2d_Viewer::Type() );
403 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, Plot2d_Viewer::Type() );
404 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, Plot2d_Viewer::Type() );
407 connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) );
408 connect( desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
409 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
410 connect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
411 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ), Qt::UniqueConnection );
414 // Set existing font for the python console in resources
415 if( !aResMgr->hasValue( "PyConsole", "font" ) )
418 QFont f = aResMgr->fontValue( "PyConsole", "font" );
420 QStringList famdb = fdb.families();
422 if ( famdb.contains(f.family()) || !aResMgr->hasValue( "PyConsole", "additional_families" ) )
425 QStringList anAddFamilies = aResMgr->stringValue( "PyConsole", "additional_families" ).split( ";", QString::SkipEmptyParts );
427 for ( QStringList::Iterator it = anAddFamilies.begin(); it != anAddFamilies.end(); ++it )
430 if ( famdb.contains(aFamily) )
432 f.setFamily( aFamily );
433 aResMgr->setValue( "PyConsole", "font", f );
440 *\li Save window geometry.
441 *\li Save desktop geometry.
442 *\li Save resource maneger.
443 *\li Delete selection manager.
445 LightApp_Application::~LightApp_Application()
449 delete myScreenHelper;
453 /*!Start application.*/
454 void LightApp_Application::start()
456 CAM_Application::start();
459 updateViewManagers();
460 updateCommandsStatus();
463 desktop()->statusBar()->showMessage( "" );
465 LightApp_EventFilter::Init();
468 /*!Closeapplication.*/
469 void LightApp_Application::closeApplication()
471 #ifndef DISABLE_QTXWEBBROWSER
472 QProcess::startDetached( "HelpBrowser",
473 QStringList() << QString( "--remove=%1" ).arg( QApplication::instance()->applicationPid() ) );
475 CAM_Application::closeApplication();
478 /*!Gets application name.*/
479 QString LightApp_Application::applicationName() const
481 static QString _app_name;
482 if ( _app_name.isEmpty() )
483 _app_name = tr( "APP_NAME" );
487 /*!Gets application version.*/
488 QString LightApp_Application::applicationVersion() const
490 static QString _app_version;
492 if ( _app_version.isEmpty() )
494 QString resVersion = tr( "APP_VERSION" );
495 if ( resVersion != "APP_VERSION" )
497 _app_version = resVersion;
501 _app_version = GUI_VERSION_STR;
507 /*!Load module by \a name.*/
508 CAM_Module* LightApp_Application::loadModule( const QString& name, const bool showMsg )
510 CAM_Module* mod = CAM_Application::loadModule( name, showMsg );
513 connect( this, SIGNAL( studyOpened() ), mod, SLOT( onModelOpened() ) );
514 connect( this, SIGNAL( studySaved() ), mod, SLOT( onModelSaved() ) );
515 connect( this, SIGNAL( studyClosed() ), mod, SLOT( onModelClosed() ) );
520 /*!Activate module by \a modName*/
521 bool LightApp_Application::activateModule( const QString& modName )
524 CAM_Module* prevMod = activeModule();
527 actName = prevMod->moduleName();
529 if ( actName == modName )
532 putInfo( tr( "ACTIVATING_MODULE" ).arg( modName ) );
534 saveDockWindowsState();
536 bool status = CAM_Application::activateModule( modName );
538 updateModuleActions();
546 updateViewManagers();
548 if ( activeStudy() && activeStudy()->root() && objectBrowser() ) {
549 if ( objectBrowser()->root() != activeStudy()->root() )
550 objectBrowser()->setRoot( activeStudy()->root() );
551 updateObjectBrowser( true );
554 if ( activeModule() ) activeModule()->updateModuleVisibilityState();
559 /*!Gets selection manager.*/
560 LightApp_SelectionMgr* LightApp_Application::selectionMgr() const
565 /*!Creat action "New window" for certain type of viewer:*/
566 void LightApp_Application::createActionForViewer( const int id,
568 const QString& suffix,
571 QString vtlt = tr( QString( "NEW_WINDOW_%1" ).arg( suffix ).toLatin1().constData() );
572 QString tip = tr( "CREATING_NEW_WINDOW" ).arg( vtlt.remove( "&" ) );
573 QAction* a = createAction( id, // menu action id
580 false, // toggle flag
582 SLOT( onNewWindow() ) ); // slot
583 createMenu( a, parentId, -1 );
588 void LightApp_Application::createActions()
590 CAM_Application::createActions();
592 SUIT_Desktop* desk = desktop();
593 SUIT_ResourceMgr* resMgr = resourceMgr();
596 createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIcon(),
597 tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
598 Qt::CTRL+Qt::Key_P, desk, false, this, SLOT( onPreferences() ) );
602 // - Help for modules
604 int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
605 createMenu( separator(), helpMenu, -1, 10 );
606 QStringList aModuleList;
607 modules( aModuleList, false );
608 aModuleList.prepend( "GUI" );
609 aModuleList.prepend( "KERNEL" );
611 int id = LightApp_Application::UserID + FIRST_HELP_ID;
614 foreach( aModule, aModuleList ) {
615 if ( aModule.isEmpty() ) // module title (user name)
617 IMap <QString, QString> helpData; // list of help files for the module
618 QString helpSubMenu; // help submenu name (empty if not needed)
619 QString modName = moduleName( aModule ); // module name
620 if ( modName.isEmpty() ) modName = aModule; // for KERNEL and GUI
621 QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName ); // module root dir variable
622 QString modDir = getenv( rootDir.toLatin1().constData() ); // module root dir
624 if (resMgr->hasValue( modName, "documentation" ) )
625 docSection = resMgr->stringValue(modName, "documentation");
626 else if ( resMgr->hasSection( modName + "_documentation" ) )
627 docSection = modName + "_documentation";
628 if ( !docSection.isEmpty() ) {
629 helpSubMenu = resMgr->stringValue( docSection, "sub_menu", "" ).arg( aModule );
630 QStringList listOfParam = resMgr->parameters( docSection );
631 foreach( QString paramName, listOfParam ) {
632 QString valueStr = resMgr->stringValue( docSection, paramName );
633 if ( !valueStr.isEmpty() ) {
634 QFileInfo fi( valueStr );
635 if ( fi.isRelative() && !modDir.isEmpty() )
636 valueStr = Qtx::addSlash( modDir ) + valueStr;
637 if ( QFile::exists( valueStr ) )
638 helpData.insert( paramName.arg( aModule ), valueStr );
643 if ( helpData.isEmpty() && !modDir.isEmpty() ) {
644 QStringList idxLst = QStringList() << modDir << "share" << "doc" << "salome" << "gui" << modName << "index.html";
645 QString indexFile = idxLst.join( QDir::separator() ); // index file
646 if ( QFile::exists( indexFile ) )
647 helpData.insert( tr( "%1 module Users's Guide" ).arg( aModule ), indexFile );
650 IMapConstIterator<QString, QString > fileIt;
651 for ( fileIt = helpData.begin(); fileIt != helpData.end(); fileIt++ ) {
652 QString helpFileName = fileIt.key();
653 // remove all '//' occurances
654 while ( helpFileName.contains( "//" ) )
655 helpFileName.replace( "//", "" );
656 // obtain submenus hierarchy if given
657 QStringList smenus = helpFileName.split( "/" );
658 helpFileName = smenus.last();
660 QAction* a = createAction( id, helpFileName,
661 resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
662 helpFileName, helpFileName,
663 0, desk, false, this, SLOT( onHelpContentsModule() ) );
664 a->setData( fileIt.value() );
665 if ( !helpSubMenu.isEmpty() ) {
666 smenus.prepend( helpSubMenu );
668 // create sub-menus hierarchy
669 int menuId = helpMenu;
670 foreach ( QString subMenu, smenus ) {
671 menuId = createMenu( subMenu, menuId, -1, 0 );
673 createMenu( a, menuId, -1, 0 );
678 // - Additional help items
680 createMenu( separator(), helpMenu, -1, 5 );
682 QStringList addHelpItems = resMgr->parameters( "add_help" );
683 foreach ( QString addHelpItem, addHelpItems ) {
684 QString valueStr = resMgr->stringValue( "add_help", addHelpItem );
685 if ( !valueStr.isEmpty() && QFile::exists( valueStr ) ) {
686 QAction* a = createAction( id, addHelpItem,
687 resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
688 addHelpItem, addHelpItem,
689 0, desk, false, this, SLOT( onHelpContentsModule() ) );
690 a->setData( valueStr );
691 createMenu( a, helpMenu, -1, 5 );
697 static QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), 0 );
698 connect( mru, SIGNAL( activated( const QString& ) ), this, SLOT( onMRUActivated( const QString& ) ) );
699 registerAction( MRUId, mru );
701 // default icon for neutral point ('SALOME' module)
702 QPixmap defIcon = resMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
703 if ( defIcon.isNull() )
704 defIcon = QPixmap( imageEmptyIcon );
706 //! default icon for any module
707 QPixmap modIcon = resMgr->loadPixmap( "LightApp", tr( "APP_MODULE_ICO" ), false );
708 if ( modIcon.isNull() )
709 modIcon = QPixmap( imageEmptyIcon );
712 modules( modList, false );
714 if ( modList.count() > 1 )
716 LightApp_ModuleAction* moduleAction =
717 new LightApp_ModuleAction( tr( "APP_NAME" ), defIcon, desk );
719 QMap<QString, QString> iconMap;
720 moduleIconNames( iconMap );
722 const int iconSize = 20;
724 QStringList::Iterator it;
725 for ( it = modList.begin(); it != modList.end(); ++it )
727 if ( !isModuleAccessible( *it ) )
730 QString modName = moduleName( *it );
733 if ( iconMap.contains( *it ) )
734 iconName = iconMap[*it];
736 QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
741 "****************************************************************" << std::endl <<
742 " Warning: icon for " << qPrintable(*it) << " is not found!" << std::endl <<
743 " Using the default icon." << std::endl <<
744 "****************************************************************" << std::endl);
746 icon = Qtx::scaleIcon( icon, iconSize );
748 moduleAction->insertModule( *it, icon );
751 connect( moduleAction, SIGNAL( moduleActivated( const QString& ) ),
752 this, SLOT( onModuleActivation( const QString& ) ) );
753 registerAction( ModulesListId, moduleAction );
757 int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, MenuWindowId, 100 );
758 int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
760 createAction( CloseId, tr( "TOT_CLOSE" ), QIcon(), tr( "MEN_DESK_CLOSE" ), tr( "PRP_CLOSE" ),
761 Qt::CTRL+Qt::Key_F4, desk, false, this, SLOT( onCloseWindow() ) );
762 createAction( CloseAllId, tr( "TOT_CLOSE_ALL" ), QIcon(), tr( "MEN_DESK_CLOSE_ALL" ), tr( "PRP_CLOSE_ALL" ),
763 0, desk, false, this, SLOT( onCloseAllWindow() ) );
764 createAction( GroupAllId, tr( "TOT_GROUP_ALL" ), QIcon(), tr( "MEN_DESK_GROUP_ALL" ), tr( "PRP_GROUP_ALL" ),
765 0, desk, false, this, SLOT( onGroupAllWindow() ) );
767 createMenu( CloseId, windowMenu, 0, -1 );
768 createMenu( CloseAllId, windowMenu, 0, -1 );
769 createMenu( GroupAllId, windowMenu, 0, -1 );
770 createMenu( separator(), windowMenu, -1, 0 );
772 #ifndef DISABLE_GLVIEWER
773 createActionForViewer( NewGLViewId, newWinMenu, QString::number( 0 ), Qt::ALT+Qt::Key_G );
775 #ifndef DISABLE_PLOT2DVIEWER
776 createActionForViewer( NewPlot2dId, newWinMenu, QString::number( 1 ), Qt::ALT+Qt::Key_P );
778 #ifndef DISABLE_OCCVIEWER
779 createActionForViewer( NewOCCViewId, newWinMenu, QString::number( 2 ), Qt::ALT+Qt::Key_O );
781 #ifndef DISABLE_VTKVIEWER
782 createActionForViewer( NewVTKViewId, newWinMenu, QString::number( 3 ), Qt::ALT+Qt::Key_K );
784 #ifndef DISABLE_QXGRAPHVIEWER
785 createActionForViewer( NewQxSceneViewId, newWinMenu, QString::number( 4 ), Qt::ALT+Qt::Key_S );
787 #ifndef DISABLE_GRAPHICSVIEW
788 createActionForViewer( NewGraphicsViewId, newWinMenu, QString::number( 5 ), Qt::ALT+Qt::Key_C );
790 #ifndef DISABLE_PVVIEWER
791 createActionForViewer( NewPVViewId, newWinMenu, QString::number( 6 ), Qt::ALT+Qt::Key_A );
793 #ifndef DISABLE_PYVIEWER
794 createActionForViewer( NewPyViewerId, newWinMenu, QString::number( 7 ), Qt::ALT+Qt::Key_Y );
797 createAction( RenameId, tr( "TOT_RENAME" ), QIcon(), tr( "MEN_DESK_RENAME" ), tr( "PRP_RENAME" ),
798 Qt::ALT+Qt::SHIFT+Qt::Key_R, desk, false, this, SLOT( onRenameWindow() ) );
799 createMenu( RenameId, windowMenu, -1 );
801 int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
802 createMenu( PreferencesId, fileMenu, 50, -1 );
803 createMenu( separator(), fileMenu, -1, 50, -1 );
805 createMenu( separator(), fileMenu, -1, 100, -1 );
806 createMenu( MRUId, fileMenu, 100, -1 );
807 createMenu( separator(), fileMenu, -1, 100, -1 );
809 #ifdef USE_SALOME_STYLE
810 createAction( StyleId, tr( "TOT_THEME" ), QIcon(), tr( "MEN_DESK_THEME" ), tr( "PRP_THEME" ),
811 0, desk, false, this, SLOT( onStylePreferences() ) );
812 #endif // USE_SALOME_STYLE
814 createAction( FullScreenId, tr( "TOT_FULLSCREEN" ), QIcon(), tr( "MEN_DESK_FULLSCREEN" ), tr( "PRP_FULLSCREEN" ),
815 Qt::Key_F11, desk, false, this, SLOT( onFullScreen() ) );
818 int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1 );
819 createMenu( separator(), viewMenu, -1, 20, -1 );
820 #ifdef USE_SALOME_STYLE
821 createMenu( StyleId, viewMenu, 20, -1 );
822 #endif // USE_SALOME_STYLE
823 createMenu( FullScreenId, viewMenu, 20, -1 );
825 int modTBar = createTool( tr( "INF_TOOLBAR_MODULES" ), // title (language-dependant)
826 QString( "SalomeModules" ) ); // name (language-independant)
827 createTool( ModulesListId, modTBar );
830 /*!On module activation action.*/
831 void LightApp_Application::onModuleActivation( const QString& modName )
833 // Force user to create/open a study before module activation
834 QMap<QString, QString> iconMap;
835 moduleIconNames( iconMap );
836 QPixmap icon = resourceMgr()->loadPixmap( moduleName( modName ), iconMap[ modName ], false );
838 icon = resourceMgr()->loadPixmap( "LightApp", tr( "APP_MODULE_BIG_ICO" ), false ); // default icon for any module
840 bool cancelled = false;
842 while ( !modName.isEmpty() && !activeStudy() && !cancelled ){
843 LightApp_ModuleDlg aDlg( desktop(), modName, icon );
844 QMap<int, QString> opmap = activateModuleActions();
845 for ( QMap<int, QString>::ConstIterator it = opmap.begin(); it != opmap.end(); ++it )
846 aDlg.addButton( it.value(), it.key() );
848 int res = aDlg.exec();
850 // some operation is selected
851 moduleActionSelected( res );
855 putInfo( tr("INF_CANCELLED") );
857 LightApp_ModuleAction* moduleAction =
858 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
860 moduleAction->setActiveModule( QString() );
866 activateModule( modName );
869 /*!Default module activation.*/
870 QString LightApp_Application::defaultModule() const
872 QStringList aModuleNames;
873 modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration
874 //! If there's the one and only module --> activate it automatically
875 //! TODO: Possible improvement - default module can be taken from preferences
876 return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" );
879 /*!On new window slot.*/
880 void LightApp_Application::onNewWindow()
882 const QObject* obj = sender();
883 if ( !obj || !obj->inherits( "QAction" ) )
887 int id = actionId( (QAction*)obj );
890 #ifndef DISABLE_GLVIEWER
892 type = GLViewer_Viewer::Type();
895 #ifndef DISABLE_PLOT2DVIEWER
897 type = Plot2d_Viewer::Type();
900 #ifndef DISABLE_OCCVIEWER
902 type = OCCViewer_Viewer::Type();
905 #ifndef DISABLE_VTKVIEWER
907 type = VTKViewer_Viewer::Type();
910 #ifndef DISABLE_QXGRAPHVIEWER
911 case NewQxSceneViewId:
912 type = QxScene_Viewer::Type();
915 #ifndef DISABLE_GRAPHICSVIEW
916 case NewGraphicsViewId:
917 type = GraphicsView_Viewer::Type();
920 #ifndef DISABLE_PVVIEWER
922 type = PVViewer_Viewer::Type();
925 #ifndef DISABLE_PYVIEWER
927 type = PyViewer_Viewer::Type();
932 if ( !type.isEmpty() )
933 createViewManager( type );
937 SLOT: Creates new document
939 void LightApp_Application::onNewDoc()
941 #ifdef SINGLE_DESKTOP
942 if ( !checkExistingDoc() )
946 //asl: fix for 0020515
947 saveDockWindowsState();
949 CAM_Application::onNewDoc();
953 SLOT: Opens new document
955 void LightApp_Application::onOpenDoc()
957 SUIT_Study* study = activeStudy();
959 #ifdef SINGLE_DESKTOP
960 if ( !checkExistingDoc() )
964 CAM_Application::onOpenDoc();
966 if ( !study ) // new study will be create in THIS application
969 updateViewManagers();
974 SLOT: Opens new document.
975 \param aName - name of file
977 bool LightApp_Application::onOpenDoc( const QString& aName )
979 #ifdef SINGLE_DESKTOP
980 if ( !checkExistingDoc() )
984 saveDockWindowsState();
986 // We should take mru action first because this application instance can be deleted later.
987 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
989 bool res = CAM_Application::onOpenDoc( aName );
994 mru->insert( aName );
996 mru->remove( aName );
1002 SLOT: Displays "About" message box
1004 void LightApp_Application::onHelpAbout()
1006 LightApp_AboutDlg dlg( applicationName(), applicationVersion(), desktop() );
1011 Private SLOT: Called on selection is changed
1012 Dispatchs active module that selection is changed
1014 void LightApp_Application::onSelection()
1016 //MESSAGE("onSelection")
1017 onSelectionChanged();
1019 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
1020 ((LightApp_Module*)activeModule())->selectionChanged();
1025 \param study - SUIT_Study.
1027 void LightApp_Application::setActiveStudy( SUIT_Study* study )
1029 CAM_Application::setActiveStudy( study );
1033 Enables/Disables menu items and toolbar buttons. Rebuild menu
1035 void LightApp_Application::updateCommandsStatus()
1037 CAM_Application::updateCommandsStatus();
1040 #ifndef DISABLE_GLVIEWER
1041 a = action( NewGLViewId );
1043 a->setEnabled( activeStudy() );
1046 #ifndef DISABLE_PLOT2DVIEWER
1047 a = action( NewPlot2dId );
1049 a->setEnabled( activeStudy() );
1052 #ifndef DISABLE_OCCVIEWER
1053 a = action( NewOCCViewId );
1055 a->setEnabled( activeStudy() );
1058 #ifndef DISABLE_VTKVIEWER
1059 a = action( NewVTKViewId );
1061 a->setEnabled( activeStudy() );
1064 #ifndef DISABLE_QXGRAPHVIEWER
1065 a = action( NewQxSceneViewId );
1067 a->setEnabled( activeStudy() );
1070 #ifndef DISABLE_GRAPHICSVIEW
1071 a = action( NewGraphicsViewId );
1073 a->setEnabled( activeStudy() );
1076 #ifndef DISABLE_PVVIEWER
1077 a = action( NewPVViewId );
1079 a->setEnabled( activeStudy() );
1082 #ifndef DISABLE_PYVIEWER
1083 a = action( NewPyViewerId );
1085 a->setEnabled( activeStudy() );
1091 Runs system command in separate thread
1093 class RunBrowser: public QThread
1096 RunBrowser( LightApp_Application* app,
1097 const QString& theApp,
1098 const QString& theParams,
1099 const QString& theHelpFile,
1100 const QString& theContext = QString() )
1102 myParams( theParams ),
1103 myContext( theContext ),
1107 //For the external browser always specify 'file://' protocol,
1108 //because some WEB browsers (for example Mozilla Firefox) can't open local file without protocol.
1109 myHelpFile = QString("file://%1").arg( QFileInfo( theHelpFile ).canonicalFilePath() );
1114 if ( !myApp.isEmpty() && !myHelpFile.isEmpty()) {
1115 QString aCommand = QString( "%1 %2 \"%3%4\"" ).arg( myApp, myParams, myHelpFile, myContext.isEmpty() ? QString("") : QString( "#%1" ).arg( myContext ) );
1117 QProcess* proc = new QProcess();
1119 proc->start( aCommand );
1120 if ( !proc->waitForStarted() ) {
1121 SALOME_CustomEvent* ce2000 = new SALOME_CustomEvent( 2000 );
1122 QString* msg = new QString( QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).arg( myApp, myHelpFile ) );
1123 ce2000->setData( msg );
1124 QApplication::postEvent( myLApp, ce2000 );
1135 LightApp_Application* myLApp;
1139 SLOT: Displays help contents for choosen module
1141 void LightApp_Application::onHelpContentsModule()
1143 const QAction* a = (QAction*) sender();
1144 QString helpFile = a->data().toString();
1145 if ( helpFile.isEmpty() ) return;
1147 SUIT_ResourceMgr* resMgr = resourceMgr();
1150 platform = "winapplication";
1152 platform = "application";
1154 QString anApp = resMgr->stringValue("ExternalBrowser", platform);
1156 QString quote("\"");
1157 anApp.prepend( quote );
1158 anApp.append( quote );
1160 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
1161 #if DISABLE_QTXWEBBROWSER
1162 bool useExtBrowser = true;
1164 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1167 if( useExtBrowser ) {
1168 if ( !anApp.isEmpty() ) {
1169 RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile );
1173 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1174 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1175 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1177 showPreferences( tr( "PREF_APP" ) );
1181 QStringList parameters;
1182 parameters << QString( "--language=%1" ).arg( resMgr->stringValue( "language", "language" ) );
1183 parameters << QString( "--add=%1" ).arg( QApplication::instance()->applicationPid() );
1184 parameters << helpFile;
1185 QProcess::startDetached( "HelpBrowser", parameters );
1190 SLOT: Displays help contents for choosen dialog
1192 void LightApp_Application::onHelpContextModule( const QString& theComponentName,
1193 const QString& theFileName,
1194 const QString& theContext )
1196 QString fileName = theFileName;
1197 QString context = theContext;
1198 if ( !QFile::exists( fileName ) && theContext.isEmpty() ) {
1199 // context might be passed within theFileName argument
1200 QStringList comps = fileName.split("#");
1201 if ( comps.count() > 1 ) {
1202 context = comps.last();
1204 fileName = comps.join("#");
1208 QString homeDir = "";
1209 if ( !theComponentName.isEmpty() ) {
1210 QString dir = getenv( ( theComponentName + "_ROOT_DIR" ).toLatin1().constData() );
1211 if ( !dir.isEmpty() )
1212 homeDir = Qtx::addSlash( Qtx::addSlash( dir ) +
1213 Qtx::addSlash( "share" ) +
1214 Qtx::addSlash( "doc" ) +
1215 Qtx::addSlash( "salome" ) +
1216 Qtx::addSlash( "gui" ) +
1217 Qtx::addSlash( theComponentName ) );
1220 QString helpFile = QFileInfo( homeDir + fileName ).absoluteFilePath();
1221 SUIT_ResourceMgr* resMgr = resourceMgr();
1224 platform = "winapplication";
1226 platform = "application";
1228 QString anApp = resMgr->stringValue("ExternalBrowser", platform);
1230 QString quote("\"");
1231 anApp.prepend( quote );
1232 anApp.append( quote );
1235 #if DISABLE_QTXWEBBROWSER
1236 bool useExtBrowser = true;
1238 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1242 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
1244 if ( !anApp.isEmpty() ) {
1245 RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile, context );
1249 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1250 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1251 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1252 showPreferences( tr( "PREF_APP" ) );
1256 QStringList parameters;
1257 parameters << QString( "--language=%1" ).arg( resMgr->stringValue( "language", "language" ) );
1258 parameters << QString( "--add=%1" ).arg( QApplication::instance()->applicationPid() );
1259 parameters << QString( "%1#%2" ).arg( helpFile ).arg( context );
1260 QProcess::startDetached( "HelpBrowser", parameters );
1265 Sets enable or disable some actions on selection changed.
1267 void LightApp_Application::onSelectionChanged()
1269 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
1270 bool canCopy = m ? m->canCopy() : false;
1271 bool canPaste = m ? m->canPaste() : false;
1273 action( EditCopyId )->setEnabled(canCopy);
1274 action( EditPasteId )->setEnabled(canPaste);
1278 SLOT: Performs some actions when dockable windows are triggered
1280 void LightApp_Application::onDockWindowVisibilityChanged( bool )
1284 QWidget* LightApp_Application::dockWindow( const int id ) const
1287 if ( myWin.contains( id ) )
1292 QDockWidget* LightApp_Application::windowDock( QWidget* wid ) const
1297 QDockWidget* dock = 0;
1298 QWidget* w = wid->parentWidget();
1299 while ( w && !dock )
1301 dock = ::qobject_cast<QDockWidget*>( w );
1302 w = w->parentWidget();
1307 void LightApp_Application::insertDockWindow( const int id, QWidget* wid )
1312 if ( wid != dockWindow( id ) )
1313 removeDockWindow( id );
1315 myWin.insert( id, wid );
1317 QtxDockWidget* dock = new QtxDockWidget( true, desktop() );
1318 connect( dock, SIGNAL( destroyed( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
1320 dock->setFeatures( QDockWidget::AllDockWidgetFeatures );
1321 dock->setObjectName( wid->objectName().isEmpty() ? QString( "window_%1" ).arg( id ) :
1322 QString( "%1Dock" ).arg( wid->objectName() ) );
1323 dock->setWidget( wid );
1324 dock->toggleViewAction()->setData( QVariant( wid->objectName() ) );
1325 connect( dock->toggleViewAction(), SIGNAL( triggered( bool ) ),
1326 this, SLOT( onDockWindowVisibilityChanged( bool ) ) );
1328 QKeySequence accel = wid->property( "shortcut" ).value<QKeySequence>();
1329 if ( !accel.isEmpty() )
1330 dock->toggleViewAction()->setShortcut( accel );
1335 void LightApp_Application::removeDockWindow( const int id )
1337 QWidget* wid = dockWindow( id );
1343 QDockWidget* dock = windowDock( wid );
1347 dock->setWidget( 0 );
1348 wid->setParent( 0 );
1349 wid->setVisible( false );
1353 void LightApp_Application::placeDockWindow( const int id, Qt::DockWidgetArea place )
1355 QDockWidget* dock = windowDock( dockWindow( id ) );
1356 if ( dock && desktop() ) {
1357 desktop()->addDockWidget( place, dock );
1358 QtxDockAction* a = qobject_cast<QtxDockAction*>( action( ViewWindowsId ) );
1359 if ( a ) a->update();
1365 \param flag - key for window
1366 \param studyId - study id
1367 Flag used how identificator of window in windows list.
1369 QWidget* LightApp_Application::getWindow( const int flag, const int )
1371 QWidget* wid = dockWindow( flag );
1373 insertDockWindow( flag, wid = createWindow( flag ) );
1375 QMap<int, int> winMap;
1376 currentWindows( winMap );
1377 if ( winMap.contains( flag ) )
1378 placeDockWindow( flag, (Qt::DockWidgetArea)winMap[flag] );
1384 \return Object Browser
1386 SUIT_DataBrowser* LightApp_Application::objectBrowser()
1388 return qobject_cast<SUIT_DataBrowser*>( dockWindow( WT_ObjectBrowser ) );
1394 LogWindow* LightApp_Application::logWindow()
1396 return qobject_cast<LogWindow*>( dockWindow( WT_LogWindow ) );
1399 #ifndef DISABLE_PYCONSOLE
1401 This returns the python console integrated to the GUI. Depending
1402 when you request the python console, this function could return
1403 null. Then the optional parameter force (default to false) can be
1404 set to force the creation of the python console if it is not done
1406 \param force - if true, the pythonConsole is created if it does not exist yet
1407 \return Python Console
1409 PyConsole_Console* LightApp_Application::pythonConsole(const bool force)
1411 QWidget* wid = dockWindow( WT_PyConsole );
1412 if ( !wid && force==true) {
1413 wid = getWindow(WT_PyConsole);
1415 return qobject_cast<PyConsole_Console*>( wid );
1420 Updates object browser and maybe data models
1421 \param updateModels - if it is true, then data models are updated
1423 void LightApp_Application::updateObjectBrowser( const bool updateModels )
1425 // update existing data models
1428 const bool isAutoUpdate = objectBrowser() ? objectBrowser()->autoUpdate() : true;
1429 if ( objectBrowser() )
1430 objectBrowser()->setAutoUpdate( false );
1432 LightApp_Study* study = dynamic_cast<LightApp_Study*>(activeStudy());
1434 CAM_Study::ModelList dm_list;
1435 study->dataModels( dm_list );
1436 QListIterator<CAM_DataModel*> it( dm_list );
1437 while ( it.hasNext() ) {
1438 CAM_DataModel* camDM = it.next();
1439 if ( camDM && camDM->inherits( "LightApp_DataModel" ) )
1440 ((LightApp_DataModel*)camDM)->update();
1444 if( objectBrowser() )
1445 objectBrowser()->setAutoUpdate( isAutoUpdate );
1448 if ( objectBrowser() ) {
1449 objectBrowser()->updateGeometry();
1450 objectBrowser()->updateTree( 0, false );
1457 LightApp_Preferences* LightApp_Application::preferences() const
1459 return preferences( false );
1463 \return first view manager of some type
1464 \param vmType - type of view manager
1465 \param create - is it necessary to create view manager in case, when there is no manager of such type
1467 SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, const bool create )
1469 SUIT_ViewManager* aVM = viewManager( vmType );
1470 SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
1471 MESSAGE("vmType: " << vmType.toStdString() << " aVM: " << aVM << " anActiveVM: " << anActiveVM );
1472 if ( anActiveVM && anActiveVM->getType() == vmType )
1474 MESSAGE("aVM = anActiveVM");
1478 if ( aVM && !aVM->getDetached() && create )
1480 if ( !aVM->getActiveView() )
1482 MESSAGE("aVM->createView()");
1487 MESSAGE("desktop()->setActiveWindow: " << aVM->getActiveView());
1488 desktop()->setActiveWindow( aVM->getActiveView() );
1493 MESSAGE("aVM = createViewManager( vmType )");
1494 aVM = createViewManager( vmType );
1501 Creates view manager of some type
1502 \param vmType - type of view manager
1504 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, bool detached )
1506 SUIT_ResourceMgr* resMgr = resourceMgr();
1508 SUIT_ViewManager* viewMgr = 0;
1509 #ifndef DISABLE_GLVIEWER
1510 if( vmType == GLViewer_Viewer::Type() )
1512 viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() );
1513 new LightApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
1516 #ifndef DISABLE_PLOT2DVIEWER
1517 if( vmType == Plot2d_Viewer::Type() )
1519 viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
1521 #ifndef DISABLE_SALOMEOBJECT
1522 SPlot2d_Viewer* v = new SPlot2d_Viewer();
1524 new LightApp_Plot2dSelector( v, mySelMgr );
1526 vm = new Plot2d_Viewer();
1528 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1529 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
1532 Plot2d_ViewFrame* frame = wnd->getViewFrame();
1533 frame->setBackgroundColor( resMgr->colorValue( "Plot2d", "Background", frame->backgroundColor() ) );
1537 #ifndef DISABLE_QXGRAPHVIEWER
1538 if( vmType == QxScene_Viewer::Type() )
1540 viewMgr = new QxScene_ViewManager( activeStudy(), desktop() );
1541 QxScene_Viewer* vm = new QxScene_Viewer();
1542 viewMgr->setViewModel( vm );
1543 //QxScene_ViewWindow* wnd = dynamic_cast<QxScene_ViewWindow*>( viewMgr->getActiveView() );
1546 #ifndef DISABLE_GRAPHICSVIEW
1547 if( vmType == GraphicsView_Viewer::Type() )
1549 viewMgr = new GraphicsView_ViewManager( activeStudy(), desktop() );
1550 new LightApp_GVSelector( (GraphicsView_Viewer*)viewMgr->getViewModel(), mySelMgr );
1553 #ifndef DISABLE_PVVIEWER
1554 if( vmType == PVViewer_Viewer::Type() )
1556 if (( viewMgr = dynamic_cast<PVViewer_ViewManager*>( getViewManager( vmType, false )))) {
1557 viewMgr->getActiveView()->setFocus();
1560 viewMgr = new PVViewer_ViewManager( activeStudy(), desktop(), logWindow() );
1564 #ifndef DISABLE_PYVIEWER
1565 if( vmType == PyViewer_Viewer::Type() )
1567 viewMgr = new PyViewer_ViewManager( activeStudy(), desktop() );
1570 #ifndef DISABLE_OCCVIEWER
1571 if( vmType == OCCViewer_Viewer::Type() )
1573 viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
1574 OCCViewer_Viewer* vm;
1575 #ifndef DISABLE_SALOMEOBJECT
1576 vm = new SOCC_Viewer();
1578 vm = new OCCViewer_Viewer( true );
1580 vm->setBackground( OCCViewer_ViewFrame::TOP_LEFT,
1581 resMgr->backgroundValue( "OCCViewer", "xz_background", vm->background(OCCViewer_ViewFrame::TOP_LEFT) ) );
1582 vm->setBackground( OCCViewer_ViewFrame::TOP_RIGHT,
1583 resMgr->backgroundValue( "OCCViewer", "yz_background", vm->background(OCCViewer_ViewFrame::TOP_RIGHT) ) );
1584 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_LEFT,
1585 resMgr->backgroundValue( "OCCViewer", "xy_background", vm->background(OCCViewer_ViewFrame::BOTTOM_LEFT) ) );
1586 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_RIGHT,
1587 resMgr->backgroundValue( "OCCViewer", "background", vm->background(OCCViewer_ViewFrame::MAIN_VIEW) ) );
1589 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1590 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ));
1591 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1592 vm->setProjectionType( resMgr->integerValue( "OCCViewer", "projection_mode", vm->projectionType() ) );
1593 vm->setStereoType( resMgr->integerValue( "OCCViewer", "stereo_type", vm->stereoType() ) );
1594 vm->setAnaglyphFilter( resMgr->integerValue( "OCCViewer", "anaglyph_filter", vm->anaglyphFilter() ) );
1595 vm->setStereographicFocus( resMgr->integerValue( "OCCViewer", "focus_type", vm->stereographicFocusType() ),
1596 resMgr->doubleValue( "OCCViewer", "focus_value", vm->stereographicFocusValue() ));
1597 vm->setInterocularDistance( resMgr->integerValue( "OCCViewer", "iod_type", vm->interocularDistanceType() ),
1598 resMgr->doubleValue( "OCCViewer", "iod_value", vm->interocularDistanceValue() ));
1600 vm->setReverseStereo( resMgr->booleanValue( "OCCViewer", "reverse_stereo", vm->isReverseStereo() ) );
1601 vm->setVSync( resMgr->booleanValue( "OCCViewer", "enable_vsync", vm->isVSync() ) );
1602 vm->setQuadBufferSupport( resMgr->booleanValue( "OCCViewer", "enable_quad_buffer_support", vm->isQuadBufferSupport() ) );
1603 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1604 vm->enablePreselection( resMgr->booleanValue( "OCCViewer", "enable_preselection", vm->isPreselectionEnabled() ) );
1605 vm->enableSelection( resMgr->booleanValue( "OCCViewer", "enable_selection", vm->isSelectionEnabled() ) );
1606 vm->setClippingColor( resMgr->colorValue( "OCCViewer", "clipping_color", vm->clippingColor() ) );
1607 vm->setClippingTextureParams( resMgr->booleanValue( "OCCViewer", "clipping_use_default_texture", vm->isDefaultTextureUsed() ),
1608 resMgr->stringValue( "OCCViewer", "clipping_texture", vm->clippingTexture() ),
1609 resMgr->booleanValue( "OCCViewer", "clipping_modulate", vm->isTextureModulated() ),
1610 resMgr->doubleValue( "OCCViewer", "clipping_scale", vm->clippingTextureScale() ) );
1613 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1614 new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
1617 #ifndef DISABLE_VTKVIEWER
1618 #ifndef DISABLE_SALOMEOBJECT
1619 if ( vmType == SVTK_Viewer::Type() )
1621 if ( vmType == VTKViewer_Viewer::Type() )
1624 #ifndef DISABLE_SALOMEOBJECT
1625 viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
1626 SVTK_Viewer* vm = dynamic_cast<SVTK_Viewer*>( viewMgr->getViewModel() );
1629 vm->setProjectionMode( resMgr->integerValue( "VTKViewer", "projection_mode", vm->projectionMode() ) );
1630 vm->setStereoType( resMgr->integerValue( "VTKViewer", "stereo_type", vm->stereoType() ) );
1631 vm->setAnaglyphFilter( resMgr->integerValue( "VTKViewer", "anaglyph_filter", vm->anaglyphFilter() ) );
1632 vm->setQuadBufferSupport( resMgr->booleanValue( "VTKViewer", "enable_quad_buffer_support", vm->isQuadBufferSupport() ) );
1633 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1634 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1635 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ) );
1636 vm->setStaticTrihedronVisible( resMgr->booleanValue( "3DViewer", "show_static_trihedron", vm->isStaticTrihedronVisible() ) );
1637 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1638 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1639 vm->setPreSelectionMode(resMgr->integerValue( "VTKViewer", "preselection", vm->preSelectionMode() ) );
1640 vm->enableSelection( resMgr->booleanValue( "VTKViewer", "enable_selection", vm->isSelectionEnabled() ) );
1641 vm->setIncrementalSpeed( resMgr->integerValue( "VTKViewer", "speed_value", vm->incrementalSpeed() ),
1642 resMgr->integerValue( "VTKViewer", "speed_mode", vm->incrementalSpeedMode() ) );
1643 vm->setSpacemouseButtons( resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", vm->spacemouseBtn(1) ),
1644 resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", vm->spacemouseBtn(2) ),
1645 resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", vm->spacemouseBtn(3) ) );
1646 new LightApp_VTKSelector( vm, mySelMgr );
1649 viewMgr = new VTKViewer_ViewManager( activeStudy(), desktop() );
1650 VTKViewer_Viewer* vm = dynamic_cast<VTKViewer_Viewer*>( viewMgr->getViewModel() );
1652 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1660 viewMgr->setDetached(detached);
1661 addViewManager( viewMgr );
1662 SUIT_ViewWindow* viewWin = viewMgr->createViewWindow();
1664 if ( viewWin && desktop() ) {
1665 viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1666 viewWin->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1672 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, QWidget* w )
1674 SUIT_ResourceMgr* resMgr = resourceMgr();
1676 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
1678 new LightApp_WgViewModel( vmType, w ) );
1679 vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
1681 addViewManager( vm );
1682 SUIT_ViewWindow* vw = vm->createViewWindow();
1683 if ( vw && desktop() ) {
1684 vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1685 vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1688 if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
1689 myUserWmTypes << vmType;
1694 SUIT_ViewManager* LightApp_Application::createViewManager( SUIT_ViewModel* theModel )
1696 SUIT_ResourceMgr* resMgr = resourceMgr();
1698 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
1702 QString vmType = vm->getType();
1704 vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
1706 addViewManager( vm );
1707 SUIT_ViewWindow* vw = vm->createViewWindow();
1708 if ( vw && desktop() ) {
1709 vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1710 vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1713 if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
1714 myUserWmTypes << vmType;
1720 SLOT: Removes view manager from application
1722 void LightApp_Application::onCloseView( SUIT_ViewManager* theVM )
1724 removeViewManager( theVM );
1728 Protected SLOT: On study created.
1729 \param theStudy - just created study
1731 void LightApp_Application::onStudyCreated( SUIT_Study* theStudy )
1733 SUIT_DataObject* aRoot = 0;
1734 if ( theStudy && theStudy->root() )
1736 aRoot = theStudy->root();
1737 //aRoot->setName( tr( "DATA_MODELS" ) );
1740 getWindow( WT_ObjectBrowser );
1742 loadDockWindowsState();
1744 if ( objectBrowser() )
1745 objectBrowser()->setRoot( aRoot );
1747 activateModule( defaultModule() );
1749 if ( objectBrowser() )
1750 objectBrowser()->openLevels();
1752 #ifndef DISABLE_PYCONSOLE
1753 if( pythonConsole() )
1754 getPyInterp()->initStudy();
1759 Protected SLOT: On study opened.
1760 \param theStudy - just opened study
1762 void LightApp_Application::onStudyOpened( SUIT_Study* theStudy )
1764 SUIT_DataObject* aRoot = 0;
1765 if ( theStudy && theStudy->root() )
1767 aRoot = theStudy->root();
1771 getWindow( WT_ObjectBrowser );
1773 loadDockWindowsState();
1775 if ( objectBrowser() )
1776 objectBrowser()->setRoot( aRoot );
1778 activateModule( defaultModule() );
1780 if ( objectBrowser() )
1781 objectBrowser()->openLevels();
1783 #ifndef DISABLE_PYCONSOLE
1784 if( pythonConsole() )
1785 getPyInterp()->initStudy();
1791 /*!Protected SLOT. On study saved.*/
1792 void LightApp_Application::onStudySaved( SUIT_Study* s )
1794 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
1796 mru->insert( s->studyName() );
1801 /*!Protected SLOT. On study closed.*/
1802 void LightApp_Application::onStudyClosed( SUIT_Study* s )
1805 disconnect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
1806 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
1809 // stop auto-save timer
1810 myAutoSaveTimer->stop();
1812 // Bug 10396: clear selection
1813 mySelMgr->clearSelected();
1815 // Bug 12944: emit signal only after clear selection
1818 activateModule( "" );
1821 /*!Protected SLOT.On desktop activated.*/
1822 void LightApp_Application::onDesktopActivated()
1824 CAM_Application::onDesktopActivated();
1825 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>(activeModule());
1827 aModule->studyActivated();
1830 void LightApp_Application::studyOpened( SUIT_Study* s )
1832 CAM_Application::studyOpened( s );
1835 updateViewManagers();
1838 void LightApp_Application::studySaved( SUIT_Study* s )
1840 CAM_Application::studyOpened( s );
1841 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1842 if ( aResMgr && activeStudy() ) {
1843 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
1844 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
1848 void LightApp_Application::studyCreated( SUIT_Study* s )
1850 CAM_Application::studyCreated( s );
1853 updateViewManagers();
1856 /*!Gets file filter.
1857 *\retval QString "(*.hdf)"
1859 QString LightApp_Application::getFileFilter( bool /*open*/) const
1865 Shows file dialog and return user selected file name
1867 QString LightApp_Application::getFileName( bool open, const QString& initial, const QString& filters,
1868 const QString& caption, QWidget* parent )
1872 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1873 return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
1876 /*! Gets directory*/
1877 QString LightApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
1881 return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true );
1884 /*! Get open file names*/
1885 QStringList LightApp_Application::getOpenFileNames( const QString& initial, const QString& filters,
1886 const QString& caption, QWidget* parent )
1890 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1891 return SUIT_FileDlg::getOpenFileNames( parent, initial, fls, caption, true );
1894 /*!Private SLOT. Update object browser.*/
1895 void LightApp_Application::onRefresh()
1897 updateObjectBrowser( true );
1900 /*!Private SLOT. Update actions after rename object.*/
1901 void LightApp_Application::onRenamed()
1903 activeStudy()->Modified();
1907 // IMN 08.07.2015 : issue 002556: Some stereo outputs are affected by window position.
1908 // To prevent reversion the window should be either aligned during movement and resize.
1909 /*!Private SLOT. Update actions after rename object.*/
1910 /*void LightApp_Application::onMoved()
1912 OCCViewer_ViewManager* viewMgr = 0;
1913 viewMgr = dynamic_cast<OCCViewer_ViewManager*>( getViewManager( OCCViewer_Viewer::Type(), false ) );
1915 OCCViewer_ViewWindow* view = 0;
1916 view = dynamic_cast<OCCViewer_ViewWindow*>( viewMgr->getActiveView() );
1918 view->getViewPort()->repaintViewAfterMove();
1923 /*!Private SLOT. Support drag-and-drop operation.*/
1924 void LightApp_Application::onDropped( const QList<SUIT_DataObject*>& objects, SUIT_DataObject* parent, int row, Qt::DropAction action )
1926 LightApp_DataObject* parentObj = dynamic_cast<LightApp_DataObject*>( parent );
1930 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>( parentObj->module() );
1932 aModule->dropObjects( objects, parentObj, row, action );
1935 /*!Private SLOT. On preferences.*/
1936 void LightApp_Application::onPreferences()
1938 showPreferences( activeModule() ? activeModule()->moduleName() : tr( "PREF_CATEGORY_SALOME" ) );
1941 /*!Private SLOT. On preferences.*/
1942 void LightApp_Application::showPreferences( const QString& itemText )
1944 QApplication::setOverrideCursor( Qt::WaitCursor );
1946 LightApp_PreferencesDlg* prefDlg = new LightApp_PreferencesDlg( preferences( true ), desktop());
1948 QApplication::restoreOverrideCursor();
1953 preferences()->activateItem( itemText );
1955 if ( ( prefDlg->exec() == QDialog::Accepted || prefDlg->isSaved() ) && resourceMgr() )
1958 resourceMgr()->setValue( "desktop", "geometry", desktop()->storeGeometry() );
1959 resourceMgr()->save();
1962 shortcutMgr()->updateShortcuts();
1968 /*!Protected SLOT. On preferences changed.*/
1969 void LightApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param )
1971 LightApp_Module* sMod = 0;
1972 CAM_Module* mod = module( modName );
1973 if ( mod && mod->inherits( "LightApp_Module" ) )
1974 sMod = (LightApp_Module*)mod;
1977 sMod->preferencesChanged( section, param );
1979 preferencesChanged( section, param );
1980 // emit signal to allow additional preferences changing processing
1981 emit preferenceChanged( modName, section, param );
1984 /*!Remove all windows from study.*/
1985 void LightApp_Application::beforeCloseDoc( SUIT_Study* s )
1987 saveDockWindowsState();
1989 if ( SUIT_DataBrowser* ob = objectBrowser() )
1992 CAM_Application::beforeCloseDoc( s );
1995 /*!Update actions.*/
1996 void LightApp_Application::updateActions()
1998 updateCommandsStatus();
2004 SUIT_Study* LightApp_Application::createNewStudy()
2006 LightApp_Application::lastStudyId++;
2008 LightApp_Study* aStudy = new LightApp_Study( this );
2010 // Set up processing of major study-related events
2011 connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
2012 connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
2013 connect( aStudy, SIGNAL( saved ( SUIT_Study* ) ), this, SLOT( onStudySaved ( SUIT_Study* ) ) );
2014 connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
2020 Creates window by flag.
2021 \param flag - identificator of window type
2023 QWidget* LightApp_Application::createWindow( const int flag )
2027 SUIT_ResourceMgr* resMgr = resourceMgr();
2029 if ( flag == WT_ObjectBrowser )
2031 SUIT_DataBrowser* ob = new SUIT_DataBrowser( new LightApp_DataObject(), desktop() );
2032 ob->setObjectName( "objectBrowser" );
2033 ob->setSortMenuEnabled( true );
2034 ob->setAutoUpdate( true );
2035 if ( resMgr->hasValue( "ObjectBrowser", "auto_hide_search_tool" ) )
2036 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
2038 //ob->setAutoOpenLevel( 1 ); // commented by ASV as a fix to bug IPAL10107
2039 ob->setWindowTitle( tr( "OBJECT_BROWSER" ) );
2040 connect( ob, SIGNAL( requestUpdate() ), this, SLOT( onRefresh() ) );
2042 QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
2043 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
2044 treeModel->setSearcher( this );
2045 treeModel->registerColumn( 0, EntryCol, LightApp_DataObject::EntryId );
2046 treeModel->setAppropriate( EntryCol, Qtx::Toggled );
2048 // Mantis issue 0020136: Drag&Drop in OB
2049 SUIT_ProxyModel* proxyModel = dynamic_cast<SUIT_ProxyModel*>(treeModel);
2051 connect( proxyModel, SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
2052 this, SLOT( onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
2053 connect( proxyModel, SIGNAL( renamed( SUIT_DataObject* ) ),
2054 this, SLOT( onRenamed( ) ) );
2058 // temporary commented
2060 OB_ListView* ob_list = dynamic_cast<OB_ListView*>( const_cast<QListView*>( ob->listView() ) );
2062 ob_list->setColumnMaxWidth( 0, desktop()->width()/4 );
2065 // Create OBSelector
2066 new LightApp_OBSelector( ob, mySelMgr );
2067 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
2068 ob->treeView()->header()->setResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
2070 ob->treeView()->header()->setSectionResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
2072 ob->treeView()->header()->moveSection(SUIT_DataObject::NameId,SUIT_DataObject::VisibilityId);
2073 ob->treeView()->setColumnWidth(SUIT_DataObject::VisibilityId, VISIBILITY_COLUMN_WIDTH);
2074 ob->setProperty( "shortcut", QKeySequence( "Alt+Shift+O" ) );
2076 ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
2078 #ifndef DISABLE_PYCONSOLE
2079 else if ( flag == WT_PyConsole )
2081 PyConsole_Console* pyCons = new PyConsole_Console( desktop(), new LightApp_PyEditor( getPyInterp() ) );
2082 pyCons->setObjectName( "pythonConsole" );
2083 pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
2084 pyCons->setFont( resMgr->fontValue( "PyConsole", "font" ) );
2085 pyCons->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
2086 pyCons->setAutoCompletion( resMgr->booleanValue( "PyConsole", "auto_completion", true ) );
2087 pyCons->setProperty( "shortcut", QKeySequence( "Alt+Shift+P" ) );
2091 else if ( flag == WT_LogWindow )
2093 LogWindow* logWin = new LogWindow( desktop() );
2094 logWin->setObjectName( "logWindow" );
2095 logWin->setWindowTitle( tr( "LOG_WINDOW" ) );
2096 logWin->setProperty( "shortcut", QKeySequence( "Alt+Shift+L" ) );
2098 logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
2104 \return default windows( Object Browser, Python Console )
2105 Adds to map \a aMap.
2107 void LightApp_Application::defaultWindows( QMap<int, int>& aMap ) const
2109 #ifndef DISABLE_PYCONSOLE
2110 aMap.insert( WT_PyConsole, Qt::BottomDockWidgetArea );
2112 if ( activeStudy() ) {
2113 aMap.insert( WT_ObjectBrowser, Qt::LeftDockWidgetArea );
2114 // aMap.insert( WT_LogWindow, Qt::DockBottom );
2118 /*!Default view managers*/
2119 void LightApp_Application::defaultViewManagers( QStringList& ) const
2125 \return preferences.
2126 Create preferences, if \a crt = true.
2128 LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const
2133 LightApp_Application* that = (LightApp_Application*)this;
2135 bool toCreate = !_prefs_ && crt;
2138 _prefs_ = new LightApp_Preferences( resourceMgr() );
2139 that->createPreferences( _prefs_ );
2140 qAddPostRoutine( LightAppCleanUpAppResources );
2143 that->myPrefs = _prefs_;
2145 connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
2146 this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ), Qt::UniqueConnection );
2147 connect( myPrefs, SIGNAL( resetToDefaults() ),
2148 this, SIGNAL( preferenceResetToDefaults() ), Qt::UniqueConnection );
2153 SUIT_ResourceMgr* resMgr = resourceMgr();
2155 QList<SUIT_Application*> appList = SUIT_Session::session()->applications();
2156 for ( QList<SUIT_Application*>::iterator appIt = appList.begin(); appIt != appList.end(); ++appIt )
2158 LightApp_Application* app = ::qobject_cast<LightApp_Application*>( *appIt );
2162 QStringList modNameList;
2163 app->modules( modNameList, false );
2165 QMap<QString, QString> iconMap;
2166 app->moduleIconNames( iconMap );
2168 for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it )
2170 if ( !app->isModuleAccessible( *it ) || _prefs_->hasModule( *it ) )
2173 int modId = _prefs_->addPreference( *it );
2174 if ( iconMap.contains( *it ) )
2175 _prefs_->setItemIcon( modId, Qtx::scaleIcon( resMgr->loadPixmap( moduleName( *it ), iconMap[*it], false ), 20 ) );
2179 app->modules( modList );
2180 QListIterator<CAM_Module*> itr( modList );
2181 while ( itr.hasNext() )
2183 LightApp_Module* mod = 0;
2185 CAM_Module* anItem = itr.next();
2186 if ( anItem->inherits( "LightApp_Module" ) )
2187 mod = (LightApp_Module*)anItem;
2189 if ( mod && !_prefs_->hasModule( mod->moduleName() ) )
2191 _prefs_->addPreference( mod->moduleName() );
2192 mod->createPreferences();
2193 that->emptyPreferences( mod->moduleName() );
2197 _prefs_->setItemProperty( "info", tr( "PREFERENCES_NOT_LOADED" ) );
2203 Adds new module to application
2205 void LightApp_Application::moduleAdded( CAM_Module* mod )
2207 CAM_Application::moduleAdded( mod );
2209 LightApp_Module* lightMod = 0;
2210 if ( mod && mod->inherits( "LightApp_Module" ) )
2211 lightMod = (LightApp_Module*)mod;
2213 if ( myPrefs && lightMod && !myPrefs->hasModule( lightMod->moduleName() ))
2215 myPrefs->addPreference( mod->moduleName() );
2216 lightMod->createPreferences();
2217 emptyPreferences( mod->moduleName() );
2221 void LightApp_Application::emptyPreferences( const QString& modName )
2223 QtxPreferenceItem* item = myPrefs->findItem( modName, true );
2224 if ( !item || !item->isEmpty() )
2227 // printf( "---------------------> Modify for empty module.\n" );
2229 QtxPagePrefFrameItem* frm = new QtxPagePrefFrameItem( item->title(), item->parentItem() );
2230 frm->setIcon( item->icon() );
2231 frm->setStretch( false );
2232 item->parentItem()->insertItem( frm, item );
2233 new QtxPagePrefLabelItem( Qt::AlignCenter, tr( "PREFERENCES_NOT_SUPPORTED" ).arg( modName ), frm );
2240 void LightApp_Application::createPreferences( LightApp_Preferences* pref )
2245 QStringList aValuesList;
2246 QList<QVariant> anIndicesList;
2250 // . Top-level "SALOME" preferences group <<start>>
2251 int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
2252 pref->setItemIcon( salomeCat, Qtx::scaleIcon( resourceMgr()->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false ), 20 ) );
2254 // .. "General" preferences tab <<start>>
2255 int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat );
2257 // ... "Language" group <<start>>
2258 int langGroup = pref->addPreference( tr( "PREF_GROUP_LANGUAGE" ), genTab );
2259 pref->setItemProperty( "columns", 2, langGroup );
2260 // .... -> application language
2261 int curLang = pref->addPreference( tr( "PREF_CURRENT_LANGUAGE" ), langGroup,
2262 LightApp_Preferences::Selector, "language", "language" );
2263 QStringList aLangs = SUIT_Session::session()->resourceMgr()->stringValue( "language", "languages", "en" ).split( "," );
2264 QList<QVariant> aIcons;
2265 QList<QVariant> aNumbers;
2266 QStringList aTitles;
2267 foreach ( QString aLang, aLangs ) {
2268 aIcons << QPixmap( QString( ":/images/%1" ).arg( aLang ) );
2270 aTitles << langToName( aLang );
2272 pref->setItemProperty( "strings", aTitles, curLang );
2273 pref->setItemProperty( "ids", aNumbers, curLang );
2274 pref->setItemProperty( "icons", aIcons, curLang );
2275 pref->setItemProperty( "restart", true, curLang );
2277 int curLocale = pref->addPreference( tr( "PREF_CURRENT_LOCALE" ), langGroup,
2278 LightApp_Preferences::Bool, "language", "locale" );
2279 pref->setItemProperty( "restart", true, curLocale );
2280 // ... "Language" group <<end>>
2282 // ... "Look and feel" group <<start>>
2283 int lookGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), genTab );
2284 pref->setItemProperty( "columns", 2, lookGroup );
2285 // .... -> show splash-screen
2286 pref->addPreference( tr( "PREF_SHOW_SPLASH" ), lookGroup, LightApp_Preferences::Bool, "launch", "splash" );
2287 // .... -> opaque resize
2288 pref->addPreference( tr( "PREF_OPAQUE_RESIZE" ), lookGroup, LightApp_Preferences::Bool, "desktop", "opaque_resize" );
2289 // .... -> drop-down buttons
2290 pref->addPreference( tr( "PREF_DROP_DOWN_BUTTONS" ), lookGroup, LightApp_Preferences::Bool, "viewers", "drop_down_buttons" );
2291 // ... "Look and feel" group <<end>>
2293 // ... "Study properties" group <<start>>
2294 int studyGroup = pref->addPreference( tr( "PREF_GROUP_STUDY" ), genTab );
2295 pref->setItemProperty( "columns", 2, studyGroup );
2296 // .... -> multi-file save
2297 pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "multi_file" );
2298 // .... -> ascii save mode
2299 pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" );
2300 // .... -> store windows geometry
2301 pref->addPreference( tr( "PREF_LOAD_LIGHT" ), studyGroup, LightApp_Preferences::Bool, "Study", "autoload_light_modules" );
2302 pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" );
2303 pref->addPreference( "", studyGroup, LightApp_Preferences::Space );
2304 pref->addPreference( tr( "PREF_STORE_TOOL_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_tool_positions" );
2305 // .... -> auto-save
2306 int autoSaveInterval = pref->addPreference( tr( "PREF_AUTO_SAVE" ), studyGroup,
2307 LightApp_Preferences::IntSpin, "Study", "auto_save_interval" );
2308 pref->setItemProperty( "min", 0, autoSaveInterval );
2309 pref->setItemProperty( "max", 1440, autoSaveInterval );
2310 pref->setItemProperty( "special", tr( "PREF_AUTO_SAVE_DISABLED" ), autoSaveInterval );
2311 // ... "Study properties" group <<end>>
2313 // ... "Help browser" group <<start>>
2314 #ifndef DISABLE_QTXWEBBROWSER
2315 int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab, LightApp_Preferences::Auto, "ExternalBrowser", "use_external_browser");
2317 int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab );
2321 QString platform = "winapplication";
2323 QString platform = "application";
2325 // .... -> browser application
2326 int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, LightApp_Preferences::File, "ExternalBrowser", platform );
2327 pref->setItemProperty( "mode", Qtx::PT_OpenFile, apppref );
2328 // .... -> browser parameters
2329 pref->addPreference( tr( "PREF_PARAM" ), extgroup, LightApp_Preferences::String, "ExternalBrowser", "parameters" );
2330 // ... "Help browser" group <<end>>
2332 // ... "Python console properties" group <<start>>
2333 int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab );
2334 pref->setItemProperty( "columns", 2, pythonConsoleGroup );
2336 pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, LightApp_Preferences::Font, "PyConsole", "font" );
2337 // .... -> show banner
2338 pref->addPreference( tr( "PREF_SHOW_BANNER" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "show_banner" );
2339 // .... -> auto-completion
2340 pref->addPreference( tr( "PREF_AUTO_COMPLETION" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "auto_completion" );
2341 // ... "Python console properties" group <<end>>
2343 // ... "MRU" preferences group <<start>>
2344 int mruGroup = pref->addPreference( tr( "PREF_GROUP_MRU" ), genTab, LightApp_Preferences::Auto, "MRU", "show_mru" );
2345 pref->setItemProperty( "columns", 4, mruGroup );
2346 // number of MRU items
2347 int mruVisCount = pref->addPreference( tr( "PREF_MRU_VISIBLE_COUNT" ), mruGroup, LightApp_Preferences::IntSpin,
2348 "MRU", "visible_count" );
2349 pref->setItemProperty( "min", 0, mruVisCount );
2350 pref->setItemProperty( "max", 100, mruVisCount );
2352 int mruLinkType = pref->addPreference( tr( "PREF_MRU_LINK_TYPE" ), mruGroup, LightApp_Preferences::Selector,
2353 "MRU", "link_type" );
2354 aValuesList.clear();
2355 anIndicesList.clear();
2356 aValuesList << tr("PREF_MRU_LINK_AUTO") << tr("PREF_MRU_LINK_SHORT") << tr("PREF_MRU_LINK_FULL");
2357 anIndicesList << 0 << 1 << 2 ;
2358 pref->setItemProperty( "strings", aValuesList, mruLinkType );
2359 pref->setItemProperty( "indexes", anIndicesList, mruLinkType );
2360 // ... "MRU" preferences group <<end>>
2362 // ... "Full-screen" group <<start>>
2363 int fullScreenGroup = pref->addPreference( tr( "PREF_GROUP_FULL_SCREEN" ), genTab );
2364 pref->setItemProperty( "columns", 2, fullScreenGroup );
2365 // .... -> automatic hiding toolbars
2366 pref->addPreference( tr( "PREF_FULL_SCREEN_AUTO" ), fullScreenGroup,
2367 LightApp_Preferences::Bool, "OCCViewer", "automatic_hiding" );
2368 // ... "Full-screen" group <<end>>
2370 // .. "General" preferences tab <<end>>
2372 // .. "3D viewer" group <<start>>
2373 int Viewer3DGroup = pref->addPreference( tr( "PREF_GROUP_3DVIEWER" ), salomeCat );
2374 // ... -> navigation mode
2375 int vtkStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), Viewer3DGroup,
2376 LightApp_Preferences::Selector, "3DViewer", "navigation_mode" );
2377 aValuesList.clear();
2378 anIndicesList.clear();
2379 aValuesList << tr("PREF_STANDARD_STYLE") << tr("PREF_KEYFREE_STYLE");
2380 anIndicesList << 0 << 1;
2381 pref->setItemProperty( "strings", aValuesList, vtkStyleMode );
2382 pref->setItemProperty( "indexes", anIndicesList, vtkStyleMode );
2383 // ... -> zooming mode
2384 int occZoomingStyleMode = pref->addPreference( tr( "PREF_ZOOMING" ), Viewer3DGroup,
2385 LightApp_Preferences::Selector, "3DViewer", "zooming_mode" );
2386 aValuesList.clear();
2387 anIndicesList.clear();
2388 aValuesList << tr("PREF_ZOOMING_AT_CENTER") << tr("PREF_ZOOMING_AT_CURSOR");
2389 anIndicesList << 0 << 1;
2390 pref->setItemProperty( "strings", aValuesList, occZoomingStyleMode );
2391 pref->setItemProperty( "indexes", anIndicesList, occZoomingStyleMode );
2392 // ... "Trihedron" group <<start>>
2393 int occTriGroup = pref->addPreference( tr( "PREF_TRIHEDRON" ), Viewer3DGroup );
2394 pref->setItemProperty( "columns", 2, occTriGroup );
2395 // .... -> trihedron size
2396 int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occTriGroup,
2397 LightApp_Preferences::DblSpin, "3DViewer", "trihedron_size" );
2398 pref->setItemProperty( "min", 1.0E-06, occTS );
2399 pref->setItemProperty( "max", 1000, occTS );
2400 // .... -> relative size of trihedron
2401 pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "relative_size" );
2402 // .... -> show static trihedron
2403 pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "show_static_trihedron" );
2404 // ... "Trihedron" group <<end>>
2405 // .. "3D viewer" group <<end>>
2409 #ifndef DISABLE_OCCVIEWER
2410 // .. "OCC viewer" group <<start>>
2411 int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), salomeCat );
2413 // .... -> Projection mode
2414 int occProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), occGroup,
2415 LightApp_Preferences::Selector, "OCCViewer", "projection_mode" );
2416 aValuesList.clear();
2417 anIndicesList.clear();
2418 aValuesList << tr("PREF_ORTHOGRAPHIC") << tr("PREF_PERSPECTIVE");
2419 anIndicesList << 0 << 1;
2420 pref->setItemProperty( "strings", aValuesList, occProjMode );
2421 pref->setItemProperty( "indexes", anIndicesList, occProjMode );
2423 // .... -> Stereo group
2424 int stereoGroup = pref->addPreference( tr( "PREF_GROUP_STEREO" ), occGroup);
2425 pref->setItemProperty( "columns", 2, stereoGroup );
2426 // .... -> Stereo type
2427 int stereoType = pref->addPreference( tr( "PREF_STEREO_TYPE" ), stereoGroup,
2428 LightApp_Preferences::Selector, "OCCViewer", "stereo_type" );
2429 aValuesList.clear();
2430 anIndicesList.clear();
2432 OCCViewer_Viewer::stereoData( aValuesList, idList);
2433 foreach( int gid, idList ) anIndicesList << gid;
2434 pref->setItemProperty( "strings", aValuesList, stereoType );
2435 pref->setItemProperty( "indexes", anIndicesList, stereoType );
2437 // .... -> Anaglyph filter
2438 int anaglyphFilter = pref->addPreference( tr( "PREF_ANAGLYPH_FILTER" ), stereoGroup,
2439 LightApp_Preferences::Selector, "OCCViewer", "anaglyph_filter" );
2440 aValuesList.clear();
2441 anIndicesList.clear();
2442 aValuesList << tr("PREF_ANAGLYPH_RED_CYAN") << tr("PREF_ANAGLYPH_YELLOW_BLUE") << tr("PREF_ANAGLYPH_GREEN_MAGENTA");
2443 anIndicesList << 0 << 1 << 2;
2445 pref->setItemProperty( "strings", aValuesList, anaglyphFilter );
2446 pref->setItemProperty( "indexes", anIndicesList, anaglyphFilter );
2448 // .... -> Convergence distance type
2449 int occFocusType = pref->addPreference( tr( "PREF_FOCUS_TYPE" ), stereoGroup,
2450 LightApp_Preferences::Selector, "OCCViewer", "focus_type" );
2451 aValuesList.clear();
2452 anIndicesList.clear();
2453 aValuesList << tr("PREF_ABSOLUTE") << tr("PREF_RELATIVE");
2454 anIndicesList << 0 << 1;
2455 pref->setItemProperty( "strings", aValuesList, occFocusType );
2456 pref->setItemProperty( "indexes", anIndicesList, occFocusType );
2458 // .... -> Stereographic focus value
2459 int focusValue = pref->addPreference( tr( "PREF_FOCUS_VALUE" ), stereoGroup,
2460 LightApp_Preferences::DblSpin, "OCCViewer", "focus_value" );
2461 pref->setItemProperty( "precision", 3, focusValue );
2462 pref->setItemProperty( "min", 1.0E-03, focusValue );
2463 pref->setItemProperty( "max", 1.0E03, focusValue );
2464 pref->setItemProperty( "step", 0.05, focusValue );
2467 int occIODType = pref->addPreference( tr( "PREF_IOD_TYPE" ), stereoGroup,
2468 LightApp_Preferences::Selector, "OCCViewer", "iod_type" );
2469 aValuesList.clear();
2470 anIndicesList.clear();
2471 aValuesList << tr("PREF_ABSOLUTE") << tr("PREF_RELATIVE");
2472 anIndicesList << 0 << 1;
2473 pref->setItemProperty( "strings", aValuesList, occIODType );
2474 pref->setItemProperty( "indexes", anIndicesList, occIODType );
2476 // .... -> Interocular distance (IOD) value
2477 int IODValue = pref->addPreference( tr( "PREF_IOD_VALUE" ), stereoGroup,
2478 LightApp_Preferences::DblSpin, "OCCViewer", "iod_value" );
2479 pref->setItemProperty( "precision", 3, IODValue );
2480 pref->setItemProperty( "min", 1.0E-03, IODValue );
2481 pref->setItemProperty( "max", 1.0E03, IODValue );
2482 pref->setItemProperty( "step", 0.05, IODValue );
2484 // .... -> Reverse stereo
2485 pref->addPreference( tr( "PREF_REVERSE_STEREO" ), stereoGroup,
2486 LightApp_Preferences::Bool, "OCCViewer", "reverse_stereo" );
2487 // .... -> Enable V-Sync
2488 pref->addPreference( tr( "PREF_ENABLE_VSYNC" ), stereoGroup,
2489 LightApp_Preferences::Bool, "OCCViewer", "enable_vsync" );
2490 // .... -> Enable quad-buffer support
2491 pref->addPreference( tr( "PREF_ENABLE_QUAD_BUFFER_SUPPORT" ), stereoGroup,
2492 LightApp_Preferences::Bool, "OCCViewer", "enable_quad_buffer_support" );
2494 // ... "Background" group <<start>>
2495 int bgGroup = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup );
2496 // pref->setItemProperty( "columns", 2, bgGroup );
2497 aValuesList.clear();
2498 anIndicesList.clear();
2501 formats = OCCViewer_Viewer::backgroundData( aValuesList, idList, txtList );
2502 foreach( int gid, idList ) anIndicesList << gid;
2503 // .... -> 3D viewer background
2504 bgId = pref->addPreference( tr( "PREF_3DVIEWER_BACKGROUND" ), bgGroup,
2505 LightApp_Preferences::Background, "OCCViewer", "background" );
2506 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2507 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2508 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2509 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2510 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2511 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2512 pref->setItemProperty( "custom_enabled", false, bgId );
2513 pref->setItemProperty( "image_formats", formats, bgId );
2514 // .... -> XZ viewer background
2515 bgId = pref->addPreference( tr( "PREF_XZVIEWER_BACKGROUND" ), bgGroup,
2516 LightApp_Preferences::Background, "OCCViewer", "xz_background" );
2517 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2518 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2519 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2520 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2521 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2522 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2523 pref->setItemProperty( "custom_enabled", false, bgId );
2524 pref->setItemProperty( "image_formats", formats, bgId );
2525 // .... -> YZ viewer background
2526 bgId = pref->addPreference( tr( "PREF_YZVIEWER_BACKGROUND" ), bgGroup,
2527 LightApp_Preferences::Background, "OCCViewer", "yz_background" );
2528 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2529 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2530 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2531 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2532 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2533 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2534 pref->setItemProperty( "custom_enabled", false, bgId );
2535 pref->setItemProperty( "image_formats", formats, bgId );
2536 // .... -> XY viewer background
2537 bgId = pref->addPreference( tr( "PREF_XYVIEWER_BACKGROUND" ), bgGroup,
2538 LightApp_Preferences::Background, "OCCViewer", "xy_background" );
2539 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2540 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2541 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2542 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2543 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2544 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2545 pref->setItemProperty( "custom_enabled", false, bgId );
2546 pref->setItemProperty( "image_formats", formats, bgId );
2547 // ... "Background" group <<end>>
2550 // ... "Selection" group <<start>>
2551 int occSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), occGroup );
2552 pref->setItemProperty( "columns", 2, occSelectionGroup );
2553 // .... -> enable preselection
2554 pref->addPreference( tr( "PREF_ENABLE_PRESELECTION" ), occSelectionGroup,
2555 LightApp_Preferences::Bool, "OCCViewer", "enable_preselection" );
2556 // .... -> enable selection
2557 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), occSelectionGroup,
2558 LightApp_Preferences::Bool, "OCCViewer", "enable_selection" );
2559 // ... "Selection" group <<end>>
2561 // ... "Clipping" group <<start>>
2562 int occClippingGroup = pref->addPreference( tr( "PREF_GROUP_CLIPPING" ), occGroup );
2563 // .... -> clipping color
2564 pref->addPreference( tr( "PREF_CLIPPING_COLOR" ), occClippingGroup,
2565 LightApp_Preferences::Color, "OCCViewer", "clipping_color" );
2566 int texturePref = pref->addPreference( "", occClippingGroup, LightApp_Preferences::Frame );
2567 pref->setItemProperty( "columns", 2, texturePref );
2568 // .... -> use default texture
2569 pref->addPreference( tr( "PREF_CLIPPING_DEFAULT_TEXTURE" ), texturePref,
2570 LightApp_Preferences::Bool, "OCCViewer", "clipping_use_default_texture" );
2571 // .... -> clipping texture
2572 int filePref = pref->addPreference( tr( "PREF_CLIPPING_TEXTURE" ), texturePref,
2573 LightApp_Preferences::File, "OCCViewer", "clipping_texture" );
2574 pref->setItemProperty( "path_filter", tr( "OCC_TEXTURE_FILES" ), filePref );
2576 pref->addPreference( tr( "PREF_CLIPPING_MODULATE" ), texturePref,
2577 LightApp_Preferences::Bool, "OCCViewer", "clipping_modulate" );
2578 // .... -> scale factor
2579 int scaleFactor = pref->addPreference( tr( "PREF_CLIPPING_SCALE" ), texturePref,
2580 LightApp_Preferences::DblSpin, "OCCViewer", "clipping_scale" );
2581 pref->setItemProperty( "precision", 3, scaleFactor );
2582 pref->setItemProperty( "min", 1.0E-03, scaleFactor );
2583 pref->setItemProperty( "max", 1.0E03, scaleFactor );
2584 pref->setItemProperty( "step", 0.1, scaleFactor );
2585 // ... "Clipping" group <<end>>
2587 // ... "Ray tracing" group <<start>>
2588 int occRayTracingGroup = pref->addPreference( tr( "PREF_GROUP_RAY_TRACING" ), occGroup );
2589 int rtPref = pref->addPreference( "", occRayTracingGroup, LightApp_Preferences::Frame );
2590 pref->setItemProperty( "columns", 2, rtPref );
2592 int rt_depth = pref->addPreference( tr( "PREF_RAY_TRACING_DEPTH" ), rtPref,
2593 LightApp_Preferences::IntSpin, "OCCViewer", "rt_depth" );
2594 pref->setItemProperty( "min", 1, rt_depth );
2595 pref->setItemProperty( "max", 10, rt_depth );
2596 pref->setItemProperty( "step", 1, rt_depth );
2597 pref->addPreference( "", rtPref, LightApp_Preferences::Frame );
2598 // .... -> specular reflections
2599 pref->addPreference( tr( "PREF_RAY_TRACING_REFLECTION" ), rtPref,
2600 LightApp_Preferences::Bool, "OCCViewer", "rt_reflection" );
2601 // .... -> adaptive anti-aliasing
2602 pref->addPreference( tr( "PREF_RAY_TRACING_ANTIALIASING" ), rtPref,
2603 LightApp_Preferences::Bool, "OCCViewer", "rt_antialiasing" );
2604 // .... -> shadows rendering
2605 pref->addPreference( tr( "PREF_RAY_TRACING_SHADOW" ), rtPref,
2606 LightApp_Preferences::Bool, "OCCViewer", "rt_shadow" );
2607 // .... -> transparent shadow
2608 pref->addPreference( tr( "PREF_RAY_TRACING_TRANS_SHADOW" ), rtPref,
2609 LightApp_Preferences::Bool, "OCCViewer", "rt_trans_shadow" );
2610 // ... "Ray tracing" group <<end>>
2612 // ... "Light source" group <<start>>
2613 int occLightGroup = pref->addPreference( tr( "PREF_GROUP_LIGHT" ), occGroup );
2614 // .... -> light color
2615 pref->addPreference( tr( "PREF_LIGHT_COLOR" ), occLightGroup,
2616 LightApp_Preferences::Color, "OCCViewer", "light_color" );
2617 int directionPref = pref->addPreference( "", occLightGroup, LightApp_Preferences::Frame );
2618 pref->setItemProperty( "columns", 3, directionPref );
2619 // .... -> light direction (dx component)
2620 int light_dx = pref->addPreference( tr( "Dx" ), directionPref,
2621 LightApp_Preferences::DblSpin, "OCCViewer", "light_dx" );
2622 pref->setItemProperty( "precision", 2, light_dx );
2623 pref->setItemProperty( "min", -1.0E03, light_dx );
2624 pref->setItemProperty( "max", 1.0E03, light_dx );
2625 pref->setItemProperty( "step", 0.1, light_dx );
2626 // .... -> light direction (dy component)
2627 int light_dy = pref->addPreference( tr( "Dy" ), directionPref,
2628 LightApp_Preferences::DblSpin, "OCCViewer", "light_dy" );
2629 pref->setItemProperty( "precision", 2, light_dy );
2630 pref->setItemProperty( "min", -1.0E03, light_dy );
2631 pref->setItemProperty( "max", 1.0E03, light_dy );
2632 pref->setItemProperty( "step", 0.1, light_dy );
2633 // .... -> light direction (dz component)
2634 int light_dz = pref->addPreference( tr( "Dz" ), directionPref,
2635 LightApp_Preferences::DblSpin, "OCCViewer", "light_dz" );
2636 pref->setItemProperty( "precision", 2, light_dz );
2637 pref->setItemProperty( "min", -1.0E03, light_dz );
2638 pref->setItemProperty( "max", 1.0E03, light_dz );
2639 pref->setItemProperty( "step", 0.1, light_dz );
2640 // ... "Light source" group <<end>>
2642 // ... -> empty frame (for layout) <<start>>
2643 int occGen = pref->addPreference( "", occGroup, LightApp_Preferences::Frame );
2644 pref->setItemProperty( "margin", 0, occGen );
2645 pref->setItemProperty( "columns", 2, occGen );
2646 // ... -> empty frame (for layout) <<end>>
2648 // .. "OCC viewer" group <<end>>
2651 #ifndef DISABLE_VTKVIEWER
2652 // .. "VTK viewer" group <<start>>
2653 int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), salomeCat ); //viewTab
2655 // ... -> empty frame (for layout) <<start>>
2656 int vtkGen = pref->addPreference( "", vtkGroup, LightApp_Preferences::Frame );
2657 //pref->setItemProperty( "columns", 2, vtkGen );
2658 // .... -> projection mode
2659 int vtkProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), vtkGen,
2660 LightApp_Preferences::Selector, "VTKViewer", "projection_mode" );
2661 aValuesList.clear();
2662 anIndicesList.clear();
2663 aValuesList << tr("PREF_ORTHOGRAPHIC") << tr("PREF_PERSPECTIVE");
2664 anIndicesList << 0 << 1;
2665 pref->setItemProperty( "strings", aValuesList, vtkProjMode );
2666 pref->setItemProperty( "indexes", anIndicesList, vtkProjMode );
2668 // .... -> Stereo group
2669 int vtkStereoGroup = pref->addPreference( tr( "PREF_GROUP_STEREO" ), vtkGroup);
2670 pref->setItemProperty( "columns", 2, vtkStereoGroup );
2671 // .... -> Stereo type
2672 int vtkStereoType = pref->addPreference( tr( "PREF_STEREO_TYPE" ), vtkStereoGroup,
2673 LightApp_Preferences::Selector, "VTKViewer", "stereo_type" );
2674 aValuesList.clear();
2675 anIndicesList.clear();
2677 SVTK_Viewer::stereoData( aValuesList, idList);
2678 foreach( int gid, idList ) anIndicesList << gid;
2679 pref->setItemProperty( "strings", aValuesList, vtkStereoType );
2680 pref->setItemProperty( "indexes", anIndicesList, vtkStereoType );
2681 // .... -> Anaglyph filter
2682 int vtkAnaglyphFilter = pref->addPreference( tr( "PREF_ANAGLYPH_FILTER" ), vtkStereoGroup,
2683 LightApp_Preferences::Selector, "VTKViewer", "anaglyph_filter" );
2684 aValuesList.clear();
2685 anIndicesList.clear();
2686 aValuesList << tr("PREF_ANAGLYPH_RED_CYAN") << tr("PREF_ANAGLYPH_YELLOW_BLUE") << tr("PREF_ANAGLYPH_GREEN_MAGENTA");
2687 anIndicesList << 0 << 1 << 2;
2689 pref->setItemProperty( "strings", aValuesList, vtkAnaglyphFilter );
2690 pref->setItemProperty( "indexes", anIndicesList, vtkAnaglyphFilter );
2692 // .... -> Enable quad-buffer support
2693 pref->addPreference( tr( "PREF_ENABLE_QUAD_BUFFER_SUPPORT" ), vtkStereoGroup,
2694 LightApp_Preferences::Bool, "VTKViewer", "enable_quad_buffer_support" );
2696 // .... -> background
2697 aValuesList.clear();
2698 anIndicesList.clear();
2701 #ifndef DISABLE_SALOMEOBJECT
2702 formats = SVTK_Viewer::backgroundData( aValuesList, idList, txtList );
2704 foreach( int gid, idList ) anIndicesList << gid;
2705 bgId = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGen,
2706 LightApp_Preferences::Background, "VTKViewer", "background" );
2707 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2708 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2709 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2710 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2711 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2712 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2713 pref->setItemProperty( "custom_enabled", false, bgId );
2714 #ifndef DISABLE_SALOMEOBJECT
2715 pref->setItemProperty( "image_formats", formats, bgId );
2717 // .... -> speed increment
2718 int vtkSpeed = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED" ), vtkGen,
2719 LightApp_Preferences::IntSpin, "VTKViewer", "speed_value" );
2720 pref->setItemProperty( "min", 1, vtkSpeed );
2721 pref->setItemProperty( "max", 1000, vtkSpeed );
2722 // .... -> speed mode
2723 int vtkSpeedMode = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED_MODE" ), vtkGen,
2724 LightApp_Preferences::Selector, "VTKViewer", "speed_mode" );
2725 aValuesList.clear();
2726 anIndicesList.clear();
2727 aValuesList << tr("PREF_ARITHMETIC") << tr("PREF_GEOMETRICAL");
2728 anIndicesList << 0 << 1;
2729 pref->setItemProperty( "strings", aValuesList, vtkSpeedMode );
2730 pref->setItemProperty( "indexes", anIndicesList, vtkSpeedMode );
2732 // ... "Selection" group <<start>>
2733 int vtkSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), vtkGroup );
2734 pref->setItemProperty( "columns", 2, vtkSelectionGroup );
2735 // .... -> preselection
2736 int vtkPreselection = pref->addPreference( tr( "PREF_PRESELECTION" ), vtkSelectionGroup,
2737 LightApp_Preferences::Selector, "VTKViewer", "preselection" );
2738 aValuesList.clear();
2739 anIndicesList.clear();
2740 aValuesList << tr("PREF_PRESELECTION_STANDARD") << tr("PREF_PRESELECTION_DYNAMIC") << tr("PREF_PRESELECTION_DISABLED");
2741 anIndicesList << 0 << 1 << 2;
2742 pref->setItemProperty( "strings", aValuesList, vtkPreselection );
2743 pref->setItemProperty( "indexes", anIndicesList, vtkPreselection );
2744 // .... -> enable selection
2745 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), vtkSelectionGroup, LightApp_Preferences::Bool, "VTKViewer", "enable_selection" );
2746 // ... "Selection" group <<end>>
2748 // ... -> empty frame (for layout) <<end>>
2750 // ... space mouse sub-group <<start>>
2751 int vtkSM = pref->addPreference( tr( "PREF_FRAME_SPACEMOUSE" ), vtkGroup, LightApp_Preferences::GroupBox );
2752 //pref->setItemProperty( "columns", 2, vtkSM );
2753 // .... -> decrease speed increment
2754 int spacemousePref1 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_1" ), vtkSM,
2755 LightApp_Preferences::Selector, "VTKViewer",
2756 "spacemouse_func1_btn" );
2757 // .... -> increase speed increment
2758 int spacemousePref2 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_2" ), vtkSM,
2759 LightApp_Preferences::Selector, "VTKViewer",
2760 "spacemouse_func2_btn" );
2761 // .... -> dominant / combined switch
2762 int spacemousePref3 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_3" ), vtkSM,
2763 LightApp_Preferences::Selector, "VTKViewer",
2764 "spacemouse_func5_btn" ); //
2765 aValuesList.clear();
2766 anIndicesList.clear();
2767 aValuesList << tr( "PREF_SPACEMOUSE_BTN_1" ) << tr( "PREF_SPACEMOUSE_BTN_2" ) << tr( "PREF_SPACEMOUSE_BTN_3" );
2768 aValuesList << tr( "PREF_SPACEMOUSE_BTN_4" ) << tr( "PREF_SPACEMOUSE_BTN_5" ) << tr( "PREF_SPACEMOUSE_BTN_6" );
2769 aValuesList << tr( "PREF_SPACEMOUSE_BTN_7" ) << tr( "PREF_SPACEMOUSE_BTN_8" ) << tr( "PREF_SPACEMOUSE_BTN_*" );
2770 aValuesList << tr( "PREF_SPACEMOUSE_BTN_10" ) << tr( "PREF_SPACEMOUSE_BTN_11" );
2771 anIndicesList << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11;
2772 pref->setItemProperty( "strings", aValuesList, spacemousePref1 );
2773 pref->setItemProperty( "indexes", anIndicesList, spacemousePref1 );
2774 pref->setItemProperty( "strings", aValuesList, spacemousePref2 );
2775 pref->setItemProperty( "indexes", anIndicesList, spacemousePref2 );
2776 pref->setItemProperty( "strings", aValuesList, spacemousePref3 );
2777 pref->setItemProperty( "indexes", anIndicesList, spacemousePref3 );
2778 // ... space mouse sub-group <<end>>
2780 // ... avi recording sub-group <<start>>
2781 int vtkRec = pref->addPreference( tr( "PREF_FRAME_RECORDING" ), vtkGroup, LightApp_Preferences::GroupBox );
2782 pref->setItemProperty( "columns", 2, vtkRec );
2783 // .... -> recording mode
2784 int modePref = pref->addPreference( tr( "PREF_RECORDING_MODE" ), vtkRec,
2785 LightApp_Preferences::Selector, "VTKViewer", "recorder_mode" );
2786 aValuesList.clear();
2787 anIndicesList.clear();
2788 aValuesList << tr( "PREF_SKIPPED_FRAMES" ) << tr( "PREF_ALL_DISLPAYED_FRAMES" );
2789 anIndicesList << 0 << 1;
2790 pref->setItemProperty( "strings", aValuesList, modePref );
2791 pref->setItemProperty( "indexes", anIndicesList, modePref );
2793 int fpsPref = pref->addPreference( tr( "PREF_FPS" ), vtkRec,
2794 LightApp_Preferences::DblSpin, "VTKViewer", "recorder_fps" );
2795 pref->setItemProperty( "min", 0.1, fpsPref );
2796 pref->setItemProperty( "max", 100, fpsPref );
2798 int qualityPref = pref->addPreference( tr( "PREF_QUALITY" ), vtkRec,
2799 LightApp_Preferences::IntSpin, "VTKViewer", "recorder_quality" );
2800 pref->setItemProperty( "min", 1, qualityPref );
2801 pref->setItemProperty( "max", 100, qualityPref );
2802 // .... -> progressive mode
2803 pref->addPreference( tr( "PREF_PROGRESSIVE" ), vtkRec,
2804 LightApp_Preferences::Bool, "VTKViewer", "recorder_progressive" );
2805 // ... avi recording sub-group <<end>>
2807 // ... group names sub-group <<start>>
2808 int vtkGN = pref->addPreference( tr( "PREF_FRAME_GROUP_NAMES" ), vtkGroup,
2809 LightApp_Preferences::GroupBox, "VTKViewer", "show_group_names" );
2810 pref->setItemProperty( "columns", 2, vtkGN );
2811 // .... -> text color
2812 pref->addPreference( tr( "PREF_GROUP_NAMES_TEXT_COLOR" ), vtkGN,
2813 LightApp_Preferences::Color, "VTKViewer", "group_names_text_color" );
2814 // .... -> transparency
2815 int transPref = pref->addPreference( tr( "PREF_GROUP_NAMES_TRANSPARENCY" ), vtkGN,
2816 LightApp_Preferences::DblSpin, "VTKViewer", "group_names_transparency" );
2817 pref->setItemProperty( "min", 0.0, transPref );
2818 pref->setItemProperty( "max", 1.0, transPref );
2819 pref->setItemProperty( "step", 0.1, transPref );
2820 // ... -> group names sub-group <<end>>
2821 // .. "VTK viewer" group <<end>>
2824 // .. "Plot2d viewer" group <<start>>
2825 int plot2dGroup = pref->addPreference( tr( "PREF_GROUP_PLOT2DVIEWER" ), salomeCat ); //viewTab
2826 //pref->setItemProperty( "columns", 2, plot2dGroup );
2828 // ... -> background
2829 pref->addPreference( tr( "PREF_VIEWER_BACKGROUND_COLOR" ), plot2dGroup,
2830 LightApp_Preferences::Color, "Plot2d", "Background" );
2831 // ... -> selection color
2832 pref->addPreference( tr( "PREF_VIEWER_SELECTION" ), plot2dGroup,
2833 LightApp_Preferences::Color, "Plot2d", "SelectionColor" );
2835 // ... "Viewer" group <<start>>
2836 int plot2dViewerGroup = pref->addPreference( tr( "PREF_GROUP_VIEWER" ), plot2dGroup );
2838 // .... -> curve type
2839 int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dViewerGroup,
2840 LightApp_Preferences::Selector, "Plot2d", "CurveType" );
2841 aValuesList.clear();
2842 anIndicesList.clear();
2843 aValuesList << tr("PREF_POINTS") << tr("PREF_LINES") << tr("PREF_SPLINE");
2844 anIndicesList << 0 << 1 << 2 ;
2845 pref->setItemProperty( "strings", aValuesList, curveType );
2846 pref->setItemProperty( "indexes", anIndicesList, curveType );
2847 // .... -> marker size
2848 int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dViewerGroup,
2849 LightApp_Preferences::IntSpin, "Plot2d", "MarkerSize" );
2850 pref->setItemProperty( "min", 0, markerSize );
2851 pref->setItemProperty( "max", 100, markerSize );
2852 // .... -> horizontal scaling mode
2853 int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dViewerGroup,
2854 LightApp_Preferences::Selector, "Plot2d", "HorScaleMode" );
2855 aValuesList.clear();
2856 anIndicesList.clear();
2857 aValuesList << tr("PREF_LINEAR") << tr("PREF_LOGARITHMIC");
2858 anIndicesList << 0 << 1 ;
2859 pref->setItemProperty( "strings", aValuesList, horScale );
2860 pref->setItemProperty( "indexes", anIndicesList, horScale );
2861 // .... -> vertical scaling mode
2862 int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dViewerGroup,
2863 LightApp_Preferences::Selector, "Plot2d", "VerScaleMode" );
2864 pref->setItemProperty( "strings", aValuesList, verScale );
2865 pref->setItemProperty( "indexes", anIndicesList, verScale );
2867 // .... -> errors/deviation colot
2868 pref->addPreference( tr( "PREF_DEVIATION_COLOR" ), plot2dViewerGroup,
2869 LightApp_Preferences::Color, "Plot2d", "DeviationMarkerColor" );
2870 // .... -> deviation markers line size
2871 int deviationMarkerLw = pref->addPreference( tr( "PREF_DEVIATION_MARKER_LW" ), plot2dViewerGroup,
2872 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerLineWidth" );
2873 pref->setItemProperty( "min", 1, deviationMarkerLw );
2874 pref->setItemProperty( "max", 5, deviationMarkerLw );
2875 // .... -> deviation markers tick mark size
2876 int deviationMarkerTs = pref->addPreference( tr( "PREF_DEVIATION_MARKER_TS" ), plot2dViewerGroup,
2877 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerTickSize" );
2878 pref->setItemProperty( "min", 1, deviationMarkerTs );
2879 pref->setItemProperty( "max", 5, deviationMarkerTs );
2880 // .... "Viewer" group <<end>>
2882 // ... "Legend" group <<start>>
2883 int plot2dLegendGroup = pref->addPreference( tr( "PREF_GROUP_LEGEND" ), plot2dGroup );
2885 // .... -> show legend
2886 pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dLegendGroup,
2887 LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
2888 // .... -> legend position
2889 int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dLegendGroup,
2890 LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
2891 aValuesList.clear();
2892 anIndicesList.clear();
2893 aValuesList << tr("PREF_LEFT") << tr("PREF_RIGHT") << tr("PREF_TOP") << tr("PREF_BOTTOM");
2894 anIndicesList << 0 << 1 << 2 << 3 ;
2895 pref->setItemProperty( "strings", aValuesList, legendPosition );
2896 pref->setItemProperty( "indexes", anIndicesList, legendPosition );
2897 // .... -> Symbol type
2898 int legendSymbolType = pref->addPreference( tr( "PREF_LEGEND_SYMBOL_TYPE" ), plot2dLegendGroup,
2899 LightApp_Preferences::Selector, "Plot2d", "LegendSymbolType" );
2900 aValuesList.clear();
2901 anIndicesList.clear();
2902 aValuesList << tr("PREF_MARKER_ON_LINE") << tr("PREF_MARKER_ABOVE_LINE");
2903 anIndicesList << 0 << 1 ;
2904 pref->setItemProperty( "strings", aValuesList, legendSymbolType );
2905 pref->setItemProperty( "indexes", anIndicesList, legendSymbolType );
2906 // .... -> legend font
2907 pref->addPreference( tr( "PREF_LEGEND_FONT" ), plot2dLegendGroup, LightApp_Preferences::Font, "Plot2d", "LegendFont" );
2908 // ... -> font color
2909 pref->addPreference( tr( "PREF_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "LegendFontColor" );
2910 // ... -> selection font color
2911 pref->addPreference( tr( "PREF_SELECTED_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "SelectedLegendFontColor" );
2912 // ... "Legend" group <<end>>
2914 // .. "Plot2d viewer" group <<end>>
2916 // .. "PyViewer" preferences tab <<start>>
2917 int pyeditTab = pref->addPreference( tr( "PREF_TAB_PYEDITOR" ), salomeCat );
2918 // ... "Font settings" group <<start>>
2919 int pyFontGroup = pref->addPreference( tr( "PREF_GROUP_PY_FONT" ), pyeditTab );
2920 int pyFont = pref->addPreference( tr( "PREF_PY_FONT" ), pyFontGroup,
2921 LightApp_Preferences::Font, "PyEditor", "Font" );
2922 pref->setItemProperty( "features", QtxFontEdit::Family | QtxFontEdit::Size | QtxFontEdit::UserSize, pyFont );
2923 // ... "Font settings" group <<end>>
2924 // ... "Display settings" group <<start>>
2925 int pyDispGroup = pref->addPreference( tr( "PREF_GROUP_PY_DISPLAY" ), pyeditTab );
2926 pref->setItemProperty( "columns", 2, pyDispGroup );
2927 // ... -> current line highlight
2928 pref->addPreference( tr( "PREF_PY_CURRLINE_HIGHLIGHT" ), pyDispGroup,
2929 LightApp_Preferences::Bool, "PyEditor", "HighlightCurrentLine" );
2930 // ... -> text wrapping
2931 pref->addPreference( tr( "PREF_PY_TEXT_WRAP" ), pyDispGroup,
2932 LightApp_Preferences::Bool, "PyEditor", "TextWrapping" );
2933 // ... -> center cursor on scroll
2934 pref->addPreference( tr( "PREF_PY_CURSON_ON_SCROLL" ), pyDispGroup,
2935 LightApp_Preferences::Bool, "PyEditor", "CenterCursorOnScroll" );
2936 // ... -> line numbers area
2937 pref->addPreference( tr( "PREF_PY_LINE_NUMBS_AREA" ), pyDispGroup,
2938 LightApp_Preferences::Bool, "PyEditor", "LineNumberArea" );
2939 // ... "Display settings" group <<end>>
2941 // ... "Editor settings" group <<start>>
2942 int pyEditGroup = pref->addPreference( tr( "PREF_GROUP_PY_EDITOR" ), pyeditTab );
2943 // ... -> navigation mode
2944 int pyCompletion = pref->addPreference( tr( "PREF_PY_COMPLETION_MODE" ), pyEditGroup,
2945 LightApp_Preferences::Selector, "PyEditor", "CompletionPolicy" );
2946 aValuesList.clear();
2947 anIndicesList.clear();
2948 aValuesList << tr("PREF_PY_NONE") << tr("PREF_PY_AUTO") << tr("PREF_PY_MANUAL") << tr("PREF_PY_ALWAYS");
2949 anIndicesList << 0 << 1 << 2 << 3 ;
2950 pref->setItemProperty( "strings", aValuesList, pyCompletion );
2951 pref->setItemProperty( "indexes", anIndicesList, pyCompletion );
2952 // ... "Editor settings" group <<end>>
2954 // ... "Tab settings" group <<start>>
2955 int pyTabGroup = pref->addPreference( tr( "PREF_GROUP_PY_TAB" ), pyeditTab );
2956 pref->setItemProperty( "columns", 2, pyTabGroup );
2957 // ... -> tab whitespaces
2958 pref->addPreference( tr( "PREF_PY_TAB_WHITESPACES" ), pyTabGroup,
2959 LightApp_Preferences::Bool, "PyEditor", "TabSpaceVisible" );
2961 pref->addPreference( tr( "PREF_PY_TAB_SIZE" ), pyTabGroup,
2962 LightApp_Preferences::IntSpin, "PyEditor", "TabSize" );
2963 // ... "Tab settings" group <<end>>
2964 // ... "Vertical edge settings" group <<start>>
2965 int pyVertEdgeGroup = pref->addPreference( tr( "PREF_GROUP_VERT_EDGE" ), pyeditTab );
2966 pref->setItemProperty( "columns", 2, pyVertEdgeGroup );
2967 // ... -> vertical edge
2968 pref->addPreference( tr( "PREF_PY_VERT_EDGE" ), pyVertEdgeGroup,
2969 LightApp_Preferences::Bool, "PyEditor", "VerticalEdge" );
2970 // ... -> number of columns
2971 pref->addPreference( tr( "PREF_PY_NUM_COLUMNS" ), pyVertEdgeGroup,
2972 LightApp_Preferences::IntSpin, "PyEditor", "NumberColumns" );
2973 // ... "Vertical edge settings" group <<end>>
2974 // .. "PyEditor" preferences tab <<end>>
2976 // .. "Directories" preferences tab <<start>>
2977 int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat );
2978 // ... --> quick directories list
2979 int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab );
2980 pref->addPreference( tr( "" ), dirGroup,
2981 LightApp_Preferences::DirList, "FileDlg", "QuickDirList" );
2982 // .. "Directories" preferences tab <<end>>
2984 // .. "Object browser" preferences tab <<start>>
2985 int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
2987 // ... "Search tool" group <<start>>
2988 int stGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SEARCH_TOOL" ), obTab );
2989 // .... --> auto-hide
2990 pref->addPreference( tr( "PREF_AUTO_HIDE_SEARCH_TOOL" ), stGroup, LightApp_Preferences::Bool,
2991 "ObjectBrowser", "auto_hide_search_tool" );
2992 // ... "Search tool" group <<end>>
2994 // ... "Object browser settings" group <<start>>
2995 int objSetGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), obTab );
2996 pref->setItemProperty( "columns", 2, objSetGroup );
2997 // .... -> auto size first column
2998 pref->addPreference( tr( "PREF_AUTO_SIZE_FIRST" ), objSetGroup, LightApp_Preferences::Bool,
2999 "ObjectBrowser", "auto_size_first" );
3000 // .... -> auto size other columns
3001 pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool,
3002 "ObjectBrowser", "auto_size" );
3003 // .... -> resize columns on expand item
3004 pref->addPreference( tr( "PREF_RESIZE_ON_EXPAND_ITEM" ), objSetGroup, LightApp_Preferences::Bool,
3005 "ObjectBrowser", "resize_on_expand_item" );
3006 // .... -> browse to published object
3007 int browsePublished = pref->addPreference( tr( "PREF_BROWSE_TO_THE_PUBLISHED_OBJECT" ), objSetGroup, LightApp_Preferences::Selector,
3008 "ObjectBrowser", "browse_published_object" );
3009 aValuesList.clear();
3010 anIndicesList.clear();
3011 aValuesList << tr( "PREF_BROWSE_NEVER" ) << tr( "PREF_BROWSE_AFTER_APPLY_AND_CLOSE_ONLY" ) << tr( "PREF_BROWSE_ALWAYS" );
3012 anIndicesList << BP_Never << BP_ApplyAndClose << BP_Always;
3013 pref->setItemProperty( "strings", aValuesList, browsePublished );
3014 pref->setItemProperty( "indexes", anIndicesList, browsePublished );
3015 // ... "Object browser settings" group <<end>>
3016 // .. "Object browser" preferences tab <<end>>
3018 // .. "Shortcuts" preferences tab <<start>>
3019 int shortcutTab = pref->addPreference( tr( "PREF_TAB_SHORTCUTS" ), salomeCat );
3020 // ... "Shortcuts settings" group <<start>>
3021 int shortcutGroup = pref->addPreference( tr( "PREF_GROUP_SHORTCUTS" ), shortcutTab );
3022 pref->addPreference( tr( "" ), shortcutGroup,
3023 LightApp_Preferences::ShortcutTree, "shortcuts" );
3024 // ... "Shortcuts settings" group <<end>>
3025 // .. "Shortcuts" preferences tab <<end>>
3026 // . Top-level "SALOME" preferences group <<end>>
3032 Changes appearance of application according to changed preferences
3033 \param sec - section
3034 \param param - name of changed parameter
3036 void LightApp_Application::preferencesChanged( const QString& sec, const QString& param )
3038 SUIT_ResourceMgr* resMgr = resourceMgr();
3042 if ( sec == "viewers" && param == "drop_down_buttons" )
3044 ViewManagerList vmlist = viewManagers();
3045 foreach( SUIT_ViewManager* vm, vmlist )
3047 QVector<SUIT_ViewWindow*> vwlist = vm->getViews();
3048 foreach( SUIT_ViewWindow* vw, vwlist )
3049 if ( vw ) vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
3053 if ( sec == QString( "3DViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )))
3055 double sz = resMgr->doubleValue( sec, "trihedron_size", -1 );
3056 bool relative = resMgr->booleanValue( sec, "relative_size", true );
3057 QList<SUIT_ViewManager*> lst;
3058 #ifndef DISABLE_OCCVIEWER
3059 viewManagers( OCCViewer_Viewer::Type(), lst );
3060 QListIterator<SUIT_ViewManager*> itOCC( lst );
3061 while ( itOCC.hasNext() && sz >= 0 )
3063 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3064 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3067 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3068 occVM->setTrihedronSize( sz, relative );
3069 occVM->getAISContext()->UpdateCurrentViewer();
3072 #ifndef DISABLE_VTKVIEWER
3073 #ifndef DISABLE_SALOMEOBJECT
3074 viewManagers( SVTK_Viewer::Type(), lst );
3075 QListIterator<SUIT_ViewManager*> itVTK( lst );
3076 while ( itVTK.hasNext() && sz >= 0 )
3078 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3079 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3082 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3085 vtkVM->setTrihedronSize( sz, relative );
3093 if ( sec == QString( "3DViewer" ) && param == QString( "show_static_trihedron" ) )
3095 bool isVisible = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
3096 QList<SUIT_ViewManager*> lst;
3097 #ifndef DISABLE_OCCVIEWER
3098 viewManagers( OCCViewer_Viewer::Type(), lst );
3099 QListIterator<SUIT_ViewManager*> itOCC( lst );
3100 while ( itOCC.hasNext() )
3102 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3103 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3106 OCCViewer_Viewer* occVM = dynamic_cast<OCCViewer_Viewer*>( vm );
3109 occVM->setStaticTrihedronDisplayed( isVisible );
3113 #ifndef DISABLE_VTKVIEWER
3114 #ifndef DISABLE_SALOMEOBJECT
3115 viewManagers( SVTK_Viewer::Type(), lst );
3116 QListIterator<SUIT_ViewManager*> itVTK( lst );
3117 while ( itVTK.hasNext() )
3119 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3120 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3123 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3126 vtkVM->setStaticTrihedronVisible( isVisible );
3134 if ( sec == QString( "3DViewer" ) && param == QString( "navigation_mode" ) )
3136 int mode = resMgr->integerValue( "3DViewer", "navigation_mode", 0 );
3137 QList<SUIT_ViewManager*> lst;
3138 #ifndef DISABLE_OCCVIEWER
3139 viewManagers( OCCViewer_Viewer::Type(), lst );
3140 QListIterator<SUIT_ViewManager*> itOCC( lst );
3141 while ( itOCC.hasNext() )
3143 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3144 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3147 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3148 occVM->setInteractionStyle( mode );
3151 #ifndef DISABLE_VTKVIEWER
3152 #ifndef DISABLE_SALOMEOBJECT
3153 viewManagers( SVTK_Viewer::Type(), lst );
3154 QListIterator<SUIT_ViewManager*> itVTK( lst );
3155 while ( itVTK.hasNext() )
3157 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3158 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3161 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3162 if( vtkVM ) vtkVM->setInteractionStyle( mode );
3168 #ifndef DISABLE_OCCVIEWER
3169 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_preselection" ) )
3171 bool isToEnablePreselection = resMgr->booleanValue( "OCCViewer", "enable_preselection", true );
3172 QList<SUIT_ViewManager*> lst;
3173 viewManagers( OCCViewer_Viewer::Type(), lst );
3174 QListIterator<SUIT_ViewManager*> it( lst );
3175 while ( it.hasNext() )
3177 SUIT_ViewModel* vm = it.next()->getViewModel();
3178 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3181 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3182 occVM->enablePreselection( isToEnablePreselection );
3187 #ifndef DISABLE_OCCVIEWER
3188 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_selection" ) )
3190 bool isToEnableSelection = resMgr->booleanValue( "OCCViewer", "enable_selection", true );
3191 QList<SUIT_ViewManager*> lst;
3192 viewManagers( OCCViewer_Viewer::Type(), lst );
3193 QListIterator<SUIT_ViewManager*> it( lst );
3194 while ( it.hasNext() )
3196 SUIT_ViewModel* vm = it.next()->getViewModel();
3197 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3200 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3201 occVM->enableSelection( isToEnableSelection );
3206 #ifndef DISABLE_OCCVIEWER
3207 if ( sec == QString( "OCCViewer" ) && param == QString( "clipping_color" ) )
3209 QColor aColor = resMgr->colorValue( "OCCViewer", "clipping_color", QColor( 50, 50, 50 ) );
3210 QList<SUIT_ViewManager*> lst;
3211 viewManagers( OCCViewer_Viewer::Type(), lst );
3212 QListIterator<SUIT_ViewManager*> it( lst );
3213 while ( it.hasNext() )
3215 SUIT_ViewModel* vm = it.next()->getViewModel();
3216 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3219 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3220 occVM->setClippingColor( aColor );
3225 #ifndef DISABLE_OCCVIEWER
3226 if ( sec == QString( "OCCViewer" ) && ( param == QString( "clipping_use_default_texture" ) ||
3227 param == QString( "clipping_texture" ) ||
3228 param == QString( "clipping_modulate" ) ||
3229 param == QString( "clipping_scale" ) ) )
3231 bool isDefaultTextureUsed = resMgr->booleanValue( "OCCViewer", "clipping_use_default_texture" );
3232 QString aTexture = resMgr->stringValue( "OCCViewer", "clipping_texture" );
3233 bool isModulated = resMgr->booleanValue( "OCCViewer", "clipping_modulate" );
3234 double aScale = resMgr->doubleValue( "OCCViewer", "clipping_scale" );
3235 QList<SUIT_ViewManager*> lst;
3236 viewManagers( OCCViewer_Viewer::Type(), lst );
3237 QListIterator<SUIT_ViewManager*> it( lst );
3238 while ( it.hasNext() )
3240 SUIT_ViewModel* vm = it.next()->getViewModel();
3241 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3244 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3245 occVM->setClippingTextureParams( isDefaultTextureUsed, aTexture, isModulated, aScale );
3250 #ifndef DISABLE_OCCVIEWER
3251 if ( sec == QString( "OCCViewer" ) && param == QString( "projection_mode" ) )
3253 int mode = resMgr->integerValue( "OCCViewer", "projection_mode", 0 );
3254 QList<SUIT_ViewManager*> lst;
3255 viewManagers( OCCViewer_Viewer::Type(), lst );
3256 QListIterator<SUIT_ViewManager*> it( lst );
3257 while ( it.hasNext() )
3259 SUIT_ViewModel* vm = it.next()->getViewModel();
3260 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3263 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3264 occVM->setProjectionType( mode );
3269 #ifndef DISABLE_OCCVIEWER
3270 if ( sec == QString( "OCCViewer" ) && param == QString( "stereo_type" ) )
3272 int mode = resMgr->integerValue( "OCCViewer", "stereo_type", 0 );
3273 QList<SUIT_ViewManager*> lst;
3274 viewManagers( OCCViewer_Viewer::Type(), lst );
3275 QListIterator<SUIT_ViewManager*> it( lst );
3276 while ( it.hasNext() )
3278 SUIT_ViewModel* vm = it.next()->getViewModel();
3279 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3282 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3283 occVM->setStereoType( mode );
3288 #ifndef DISABLE_OCCVIEWER
3289 if ( sec == QString( "OCCViewer" ) && param == QString( "anaglyph_filter" ) )
3291 int mode = resMgr->integerValue( "OCCViewer", "anaglyph_filter", 0 );
3292 QList<SUIT_ViewManager*> lst;
3293 viewManagers( OCCViewer_Viewer::Type(), lst );
3294 QListIterator<SUIT_ViewManager*> it( lst );
3295 while ( it.hasNext() )
3297 SUIT_ViewModel* vm = it.next()->getViewModel();
3298 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3301 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3302 occVM->setAnaglyphFilter( mode );
3307 #ifndef DISABLE_OCCVIEWER
3308 if ( sec == QString( "OCCViewer" ) && ( param == QString( "focus_type" ) ||
3309 param == QString( "focus_value" ) ) )
3311 int aType = resMgr->integerValue( "OCCViewer", "focus_type" );
3312 double aValue = resMgr->doubleValue( "OCCViewer", "focus_value" );
3313 QList<SUIT_ViewManager*> lst;
3314 viewManagers( OCCViewer_Viewer::Type(), lst );
3315 QListIterator<SUIT_ViewManager*> it( lst );
3316 while ( it.hasNext() )
3318 SUIT_ViewModel* vm = it.next()->getViewModel();
3319 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3322 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3323 occVM->setStereographicFocus( aType, aValue );
3328 #ifndef DISABLE_OCCVIEWER
3329 if ( sec == QString( "OCCViewer" ) && ( param == QString( "iod_type" ) ||
3330 param == QString( "iod_value" ) ) )
3332 int aType = resMgr->integerValue( "OCCViewer", "iod_type" );
3333 double aValue = resMgr->doubleValue( "OCCViewer", "iod_value" );
3334 QList<SUIT_ViewManager*> lst;
3335 viewManagers( OCCViewer_Viewer::Type(), lst );
3336 QListIterator<SUIT_ViewManager*> it( lst );
3337 while ( it.hasNext() )
3339 SUIT_ViewModel* vm = it.next()->getViewModel();
3340 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3343 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3344 occVM->setInterocularDistance( aType, aValue );
3349 #ifndef DISABLE_OCCVIEWER
3350 if ( sec == QString( "OCCViewer" ) && param == QString( "reverse_stereo" ) )
3352 bool reverse = resMgr->booleanValue( "OCCViewer", "reverse_stereo", false );
3353 QList<SUIT_ViewManager*> lst;
3354 viewManagers( OCCViewer_Viewer::Type(), lst );
3355 QListIterator<SUIT_ViewManager*> it( lst );
3356 while ( it.hasNext() )
3358 SUIT_ViewModel* vm = it.next()->getViewModel();
3359 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3362 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3363 occVM->setReverseStereo( reverse );
3368 #ifndef DISABLE_OCCVIEWER
3369 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_vsync" ) )
3371 bool enable = resMgr->booleanValue( "OCCViewer", "enable_vsync", true );
3372 QList<SUIT_ViewManager*> lst;
3373 viewManagers( OCCViewer_Viewer::Type(), lst );
3374 QListIterator<SUIT_ViewManager*> it( lst );
3375 while ( it.hasNext() )
3377 SUIT_ViewModel* vm = it.next()->getViewModel();
3378 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3381 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3382 occVM->setVSync( enable );
3387 #ifndef DISABLE_OCCVIEWER
3388 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_quad_buffer_support" ) )
3390 bool enable = resMgr->booleanValue( "OCCViewer", "enable_quad_buffer_support", false );
3391 QList<SUIT_ViewManager*> lst;
3392 viewManagers( OCCViewer_Viewer::Type(), lst );
3393 QListIterator<SUIT_ViewManager*> it( lst );
3394 while ( it.hasNext() )
3396 SUIT_ViewModel* vm = it.next()->getViewModel();
3397 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3400 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3401 occVM->setQuadBufferSupport( enable );
3406 if ( sec == QString( "3DViewer" ) && param == QString( "zooming_mode" ) )
3408 int mode = resMgr->integerValue( "3DViewer", "zooming_mode", 0 );
3409 QList<SUIT_ViewManager*> lst;
3410 #ifndef DISABLE_OCCVIEWER
3411 viewManagers( OCCViewer_Viewer::Type(), lst );
3412 QListIterator<SUIT_ViewManager*> itOCC( lst );
3413 while ( itOCC.hasNext() )
3415 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3416 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3419 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3420 occVM->setZoomingStyle( mode );
3423 #ifndef DISABLE_VTKVIEWER
3424 #ifndef DISABLE_SALOMEOBJECT
3425 viewManagers( SVTK_Viewer::Type(), lst );
3426 QListIterator<SUIT_ViewManager*> itVTK( lst );
3427 while ( itVTK.hasNext() )
3429 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3430 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3433 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3434 if( vtkVM ) vtkVM->setZoomingStyle( mode );
3440 #ifndef DISABLE_VTKVIEWER
3441 if ( sec == QString( "VTKViewer" ) && (param == QString( "speed_value" ) || param == QString( "speed_mode" )) )
3443 int speed = resMgr->integerValue( "VTKViewer", "speed_value", 10 );
3444 int mode = resMgr->integerValue( "VTKViewer", "speed_mode", 0 );
3445 QList<SUIT_ViewManager*> lst;
3446 #ifndef DISABLE_SALOMEOBJECT
3447 viewManagers( SVTK_Viewer::Type(), lst );
3448 QListIterator<SUIT_ViewManager*> it( lst );
3449 while ( it.hasNext() )
3451 SUIT_ViewModel* vm = it.next()->getViewModel();
3452 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3455 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3456 if( vtkVM ) vtkVM->setIncrementalSpeed( speed, mode );
3462 #ifndef DISABLE_VTKVIEWER
3463 if ( sec == QString( "VTKViewer" ) && param == QString( "projection_mode" ) )
3465 int mode = resMgr->integerValue( "VTKViewer", "projection_mode", 0 );
3466 QList<SUIT_ViewManager*> lst;
3467 #ifndef DISABLE_SALOMEOBJECT
3468 viewManagers( SVTK_Viewer::Type(), lst );
3469 QListIterator<SUIT_ViewManager*> it( lst );
3470 while ( it.hasNext() )
3472 SUIT_ViewModel* vm = it.next()->getViewModel();
3473 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3476 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3477 if( vtkVM ) vtkVM->setProjectionMode( mode );
3483 #ifndef DISABLE_VTKVIEWER
3484 if ( sec == QString( "VTKViewer" ) && param == QString( "stereo_type" ) )
3486 int mode = resMgr->integerValue( "VTKViewer", "stereo_type", 0 );
3487 QList<SUIT_ViewManager*> lst;
3488 #ifndef DISABLE_SALOMEOBJECT
3489 viewManagers( SVTK_Viewer::Type(), lst );
3490 QListIterator<SUIT_ViewManager*> it( lst );
3491 while ( it.hasNext() )
3493 SUIT_ViewModel* vm = it.next()->getViewModel();
3494 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3497 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3498 if( vtkVM ) vtkVM->setStereoType( mode );
3504 #ifndef DISABLE_VTKVIEWER
3505 if ( sec == QString( "VTKViewer" ) && param == QString( "anaglyph_filter" ) )
3507 int mode = resMgr->integerValue( "VTKViewer", "anaglyph_filter", 0 );
3508 QList<SUIT_ViewManager*> lst;
3509 #ifndef DISABLE_SALOMEOBJECT
3510 viewManagers( SVTK_Viewer::Type(), lst );
3511 QListIterator<SUIT_ViewManager*> it( lst );
3512 while ( it.hasNext() )
3514 SUIT_ViewModel* vm = it.next()->getViewModel();
3515 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3518 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3519 if( vtkVM ) vtkVM->setAnaglyphFilter( mode );
3525 #ifndef DISABLE_VTKVIEWER
3526 if ( sec == QString( "VTKViewer" ) && param == QString( "enable_quad_buffer_support" ) )
3528 int enable = resMgr->booleanValue( "VTKViewer", "enable_quad_buffer_support", false );
3529 QList<SUIT_ViewManager*> lst;
3530 #ifndef DISABLE_SALOMEOBJECT
3531 viewManagers( SVTK_Viewer::Type(), lst );
3532 QListIterator<SUIT_ViewManager*> it( lst );
3533 while ( it.hasNext() )
3535 SUIT_ViewModel* vm = it.next()->getViewModel();
3536 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3539 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3540 if( vtkVM ) vtkVM->setQuadBufferSupport( enable );
3546 #ifndef DISABLE_VTKVIEWER
3547 if ( sec == QString( "VTKViewer" ) && param == QString( "preselection" ) )
3549 int mode = resMgr->integerValue( "VTKViewer", "preselection", 0 );
3550 QList<SUIT_ViewManager*> lst;
3551 #ifndef DISABLE_SALOMEOBJECT
3552 viewManagers( SVTK_Viewer::Type(), lst );
3553 QListIterator<SUIT_ViewManager*> it( lst );
3554 while ( it.hasNext() )
3556 SUIT_ViewModel* vm = it.next()->getViewModel();
3557 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3560 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3561 if( vtkVM ) vtkVM->setPreSelectionMode( mode );
3567 #ifndef DISABLE_VTKVIEWER
3568 if ( sec == QString( "VTKViewer" ) && param == QString( "enable_selection" ) )
3570 bool isToEnableSelection = resMgr->booleanValue( "VTKViewer", "enable_selection", true );
3571 QList<SUIT_ViewManager*> lst;
3572 #ifndef DISABLE_SALOMEOBJECT
3573 viewManagers( SVTK_Viewer::Type(), lst );
3574 QListIterator<SUIT_ViewManager*> it( lst );
3575 while ( it.hasNext() )
3577 SUIT_ViewModel* vm = it.next()->getViewModel();
3578 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3581 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3582 if( vtkVM ) vtkVM->enableSelection( isToEnableSelection );
3588 #ifndef DISABLE_VTKVIEWER
3589 if ( sec == QString( "VTKViewer" ) && (param == QString( "spacemouse_func1_btn" ) ||
3590 param == QString( "spacemouse_func2_btn" ) ||
3591 param == QString( "spacemouse_func5_btn" ) ) )
3593 int btn1 = resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", 1 );
3594 int btn2 = resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", 2 );
3595 int btn3 = resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", 9 );
3596 QList<SUIT_ViewManager*> lst;
3597 #ifndef DISABLE_SALOMEOBJECT
3598 viewManagers( SVTK_Viewer::Type(), lst );
3599 QListIterator<SUIT_ViewManager*> it( lst );
3600 while ( it.hasNext() )
3602 SUIT_ViewModel* vm = it.next()->getViewModel();
3603 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3606 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3607 if( vtkVM ) vtkVM->setSpacemouseButtons( btn1, btn2, btn3 );
3612 if( sec=="ObjectBrowser" )
3614 SUIT_DataBrowser* ob = objectBrowser();
3618 if ( param=="auto_size_first" )
3620 bool autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
3621 ob->setAutoSizeFirstColumn( autoSizeFirst );
3622 if ( autoSizeFirst )
3623 ob->adjustFirstColumnWidth();
3625 else if ( param=="auto_size" ) {
3626 bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
3627 ob->setAutoSizeColumns(autoSize);
3629 ob->adjustColumnsWidth();
3631 else if ( param=="resize_on_expand_item" ) {
3632 bool resizeOnExpandItem = resMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
3633 ob->setResizeOnExpandItem(resizeOnExpandItem);
3635 else if ( param == "auto_hide_search_tool" ) {
3636 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
3642 if( param=="auto_save_interval" ) {
3643 myAutoSaveTimer->stop();
3644 int autoSaveInterval = resMgr->integerValue( "Study", "auto_save_interval", 0 );
3645 if ( activeStudy() && autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
3649 #ifndef DISABLE_PYCONSOLE
3650 if( sec=="PyConsole" && pythonConsole() )
3652 if ( param=="font" ) {
3653 pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) );
3655 else if ( param=="show_banner" ) {
3656 pythonConsole()->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
3658 else if ( param=="auto_completion" ) {
3659 pythonConsole()->setAutoCompletion( resMgr->booleanValue( "PyConsole", "auto_completion", true ) );
3666 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3668 if ( param == "visible_count" )
3669 mru->setVisibleCount( resMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
3670 else if ( param == "max_count" )
3671 mru->setHistoryCount( resMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
3672 else if ( param == "insert_mode" )
3673 mru->setInsertMode( resMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
3674 else if ( param == "link_type" )
3675 mru->setLinkType( resMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
3676 else if ( param == "show_clear" )
3677 mru->setClearPossible( resMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
3678 else if ( param == "show_mru" )
3679 mru->setVisible( resMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
3682 if ( sec == "language" && param == "language" )
3684 // VSR 18.06.2015 : commented out : single warning dialog box is now shown by the LightApp_PreferencesDlg
3685 //SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LANG_CHANGED" ) );
3687 if ( sec == "language" && param == "locale")
3689 // VSR 18.06.2015: commented out : single warning dialog box is now shown by the LightApp_PreferencesDlg
3690 //SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LOCALE_CHANGED" ) );
3692 if ( sec == "desktop" && param == "opaque_resize" ) {
3693 bool opaqueResize = resMgr->booleanValue( "desktop", "opaque_resize", false );
3694 // RNV: This code has been commented, because clearing of the QMainWindow::AnimatedDocks option
3695 // leads to strange behaviour of the dockable windows (at least at qt-5.6.1):
3696 // any dockable window can't be docked to the another area, except initial area.
3697 // It is possible to move window to another area, but it always returns to the initial area.
3699 // QMainWindow::DockOptions dopts = desktop()->dockOptions();
3700 // if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
3701 // else dopts &= ~QMainWindow::AnimatedDocks;
3702 // desktop()->setDockOptions( dopts );
3703 desktop()->setOpaqueResize( opaqueResize );
3704 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
3705 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
3708 #ifndef DISABLE_PLOT2DVIEWER
3709 QList<SUIT_ViewManager*> lst;
3710 viewManagers( Plot2d_Viewer::Type(), lst );
3711 QListIterator<SUIT_ViewManager*> itPlot2d( lst );
3712 while ( itPlot2d.hasNext() ) {
3713 SUIT_ViewManager* viewMgr = itPlot2d.next();
3714 SUIT_ViewModel* vm = viewMgr->getViewModel();
3715 if ( !vm || !vm->inherits( "Plot2d_Viewer" ) )
3718 //Plot2d_Viewer* Plot2dVM = dynamic_cast<Plot2d_Viewer*>( vm );
3720 viewMgr->setViewModel( vm );
3721 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
3723 Plot2d_ViewFrame* frame = wnd->getViewFrame();
3724 frame->SetPreference();
3733 void LightApp_Application::loadPreferences()
3735 CAM_Application::loadPreferences();
3737 SUIT_ResourceMgr* aResMgr = resourceMgr();
3742 static bool mru_load = true;
3745 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3747 mru->setVisible( aResMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
3748 mru->setVisibleCount( aResMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
3749 mru->setHistoryCount( aResMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
3750 mru->setInsertMode( aResMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
3751 mru->setLinkType( aResMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
3752 mru->setClearPossible( aResMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
3753 mru->loadLinks( aResMgr, "MRU" );
3759 QStringList mods = aResMgr->parameters( "windows_visibility" );
3760 for ( QStringList::const_iterator itr = mods.begin(); itr != mods.end(); ++itr )
3763 if ( aResMgr->value( "windows_visibility", *itr, arr ) )
3764 myWinVis.insert( *itr, arr );
3768 desktop()->retrieveGeometry( aResMgr->stringValue( "desktop", "geometry" ) );
3769 bool opaqueResize = aResMgr->booleanValue( "desktop", "opaque_resize", false );
3770 // QMainWindow::DockOptions dopts = desktop()->dockOptions();
3771 // if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
3772 // else dopts &= ~QMainWindow::AnimatedDocks;
3773 // desktop()->setDockOptions( dopts );
3774 desktop()->setOpaqueResize( opaqueResize );
3775 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
3776 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
3783 void LightApp_Application::savePreferences()
3785 CAM_Application::savePreferences();
3787 saveDockWindowsState();
3789 SUIT_ResourceMgr* aResMgr = resourceMgr();
3794 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3796 mru->saveLinks( aResMgr, "MRU" );
3798 for ( WinVis::const_iterator itr = myWinVis.begin(); itr != myWinVis.end(); ++itr )
3799 aResMgr->setValue( "windows_visibility", itr.key(), itr.value() );
3802 aResMgr->setValue( "desktop", "geometry", desktop()->storeGeometry() );
3804 #if GUI_DEVELOPMENT > 0
3805 aResMgr->setValue( "salome", "version", QString(GUI_VERSION_STR)+"dev" );
3807 aResMgr->setValue( "salome", "version", QString(GUI_VERSION_STR) );
3814 Updates desktop title
3816 void LightApp_Application::updateDesktopTitle()
3818 QString aTitle = applicationName();
3819 QString aVer = applicationVersion();
3820 if ( !aVer.isEmpty() )
3821 aTitle += QString( " " ) + aVer;
3823 if ( activeStudy() ) {
3824 QString sName = SUIT_Tools::file( activeStudy()->studyName().trimmed(), false );
3825 aTitle += QString( " - [%1]" ).arg( sName );
3828 desktop()->setWindowTitle( aTitle );
3832 \brief Get map of the operations which can be performed
3833 on the module activation.
3835 The method should return the map of the kind \c {<id>:<name>}
3836 where \c <id> is an integer identifier of the operation and
3837 \c <name> is a title for the button to be added to the
3838 dialog box. After user selects the required operation by the
3839 clicking the corresponding button in the dialog box, its identifier
3840 is passed to the moduleActionSelected() method to process
3843 \return map of the operations
3844 \sa moduleActionSelected()
3846 QMap<int, QString> LightApp_Application::activateModuleActions() const
3848 QMap<int, QString> opmap;
3849 opmap.insert( NewStudyId, tr( "ACTIVATE_MODULE_OP_NEW" ) );
3850 opmap.insert( OpenStudyId, tr( "ACTIVATE_MODULE_OP_OPEN" ) );
3855 \brief Called when the used selectes required operation chosen
3856 from "Activate module" dialog box.
3858 Performs the required operation according to the user choice.
3860 \param id operation identifier
3861 \sa activateModuleActions()
3863 void LightApp_Application::moduleActionSelected( const int id )
3878 Updates windows after close document
3880 void LightApp_Application::afterCloseDoc()
3884 CAM_Application::afterCloseDoc();
3888 Updates actions of active module
3890 void LightApp_Application::updateModuleActions()
3893 if ( activeModule() ) {
3894 modName = activeModule()->moduleName();
3895 if ( !isModuleAccessible( modName ) ) {
3896 QList<SUIT_Application*> apps = SUIT_Session::session()->applications();
3897 foreach( SUIT_Application* app, apps ) {
3898 LightApp_Application* lapp = dynamic_cast<LightApp_Application*>( app );
3899 if ( lapp && lapp != this )
3900 lapp->removeModuleAction( modName );
3905 LightApp_ModuleAction* moduleAction =
3906 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
3908 moduleAction->setActiveModule( modName );
3911 void LightApp_Application::removeModuleAction( const QString& modName )
3913 LightApp_ModuleAction* moduleAction =
3914 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
3916 moduleAction->removeModule( modName );
3919 bool LightApp_Application::checkModule( const QString& title )
3921 if ( title.isEmpty() )
3924 QString library = moduleLibrary( title, true );
3925 if ( library.isEmpty() )
3928 QString name = moduleName( title );
3930 bool isPyModule = library.contains( "SalomePyQtGUI" ) || library.contains( "SalomePyQtGUILight" );
3934 paths = QString( ::getenv( "PATH" ) ).split( ";", QString::SkipEmptyParts );
3935 #elif defined(__APPLE__)
3936 paths = QString( ::getenv( "DYLD_LIBRARY_PATH" ) ).split( ":", QString::SkipEmptyParts );
3938 paths = QString( ::getenv( "LD_LIBRARY_PATH" ) ).split( ":", QString::SkipEmptyParts );
3941 bool isFound = false;
3942 QStringList::const_iterator it;
3943 for ( it = paths.begin(); it != paths.end() && !isFound; ++it )
3945 isFound = QFileInfo( Qtx::addSlash( *it ) + library ).exists();
3951 "****************************************************************" << std::endl <<
3952 " Warning: library " << qPrintable( library ) << " is not found!" << std::endl <<
3953 " Module " << qPrintable( title ) << " will not be available in GUI mode!" << std::endl <<
3954 "****************************************************************" << std::endl);
3960 QString pyModule = QString( "%1GUI.py" ).arg( name );
3961 paths = QString( ::getenv( "PYTHONPATH" ) ).split( ":", QString::SkipEmptyParts );
3964 for ( it = paths.begin(); it != paths.end() && !isFound; ++it )
3966 isFound = QFileInfo( Qtx::addSlash( *it ) + pyModule ).exists();
3972 "****************************************************************" << std::endl <<
3973 " Warning: Python module " << qPrintable( pyModule ) << " is not found!" << std::endl <<
3974 " Module " << qPrintable( title ) << " will not be available in GUI mode!" << std::endl <<
3975 "****************************************************************" << std::endl);
3984 Gets current windows.
3985 \param winMap - output current windows map.
3987 void LightApp_Application::currentWindows( QMap<int, int>& winMap ) const
3990 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
3991 ((LightApp_Module*)activeModule())->windows( winMap );
3993 defaultWindows( winMap );
3997 Gets current view managers.
3998 \param lst - output current view managers list.
4000 void LightApp_Application::currentViewManagers( QStringList& lst ) const
4003 if ( !activeStudy() )
4006 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
4007 ((LightApp_Module*)activeModule())->viewManagers( lst );
4009 defaultViewManagers( lst );
4015 void LightApp_Application::updateWindows()
4017 QMap<int, int> winMap;
4018 currentWindows( winMap );
4020 for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
4022 if ( !dockWindow( it.key() ) )
4023 getWindow( it.key() );
4026 for ( WinMap::ConstIterator it = myWin.begin(); it != myWin.end(); ++it )
4028 QWidget* wid = it.value();
4029 if ( winMap.contains( it.key() ) )
4030 wid->setVisible( true );
4035 loadDockWindowsState();
4039 Updates view managers
4041 void LightApp_Application::updateViewManagers()
4044 currentViewManagers( lst );
4046 for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
4047 getViewManager( *it, true );
4051 Loads windows geometry
4053 void LightApp_Application::loadDockWindowsState()
4057 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
4058 bool storeWin = aResMgr->booleanValue( "Study", "store_positions", true );
4059 bool storeTb = aResMgr->booleanValue( "Study", "store_tool_positions", true );
4062 if ( activeModule() )
4063 modName = activeModule()->name();
4064 else if ( activeStudy() )
4065 modName = "nomodule";
4067 QtxResourceMgr::WorkingMode prevMode = aResMgr->setWorkingMode( QtxResourceMgr::IgnoreUserValues );
4068 QByteArray aDefaultState;
4069 aResMgr->value( "windows_geometry", modName, aDefaultState );
4070 QByteArray aDefaultVisibility;
4071 aResMgr->value( "windows_visibility", modName, aDefaultVisibility );
4072 bool hasDefaultVisibility = !aDefaultVisibility.isEmpty();
4073 aResMgr->setWorkingMode( prevMode );
4075 if( !storeWin && !storeTb && aDefaultState.isEmpty() && !hasDefaultVisibility)
4078 if ( aResMgr->hasValue("windows_geometry" ,modName ) ) {
4079 long version = Qtx::versionToId( aResMgr->stringValue( "windows_geometry_version", modName, "" ) );
4081 if ( version > Qtx::versionToId( "7.4.1" ) )
4082 aResMgr->value( "windows_geometry", modName , arr );
4084 arr = aDefaultState;
4085 QByteArray aTargetArray = processState(arr, storeWin, storeTb, true, aDefaultState);
4086 desktop()->restoreState( aTargetArray );
4089 QStringList mainToolbarsNames;
4090 mainToolbarsNames << "SalomeStandard" << "SalomeModules";
4091 QList<QToolBar*> mainToolbars = findToolBars( mainToolbarsNames );
4092 foreach( QToolBar* tb, mainToolbars ) tb->setVisible( true );
4094 if ( !myWinVis.contains( modName ) && aDefaultVisibility.isEmpty())
4097 QMap<QString, bool> *tbMap = 0;
4098 QMap<QString, bool> *dwMap = 0;
4100 QMap<QString, bool> userTbMap, userDwMap;
4101 dockWindowsState( myWinVis[modName], userTbMap, userDwMap );
4103 QMap<QString, bool> defaultTbMap, defaultDwMap;
4104 if(hasDefaultVisibility) {
4105 dockWindowsState( aDefaultVisibility, defaultTbMap, defaultDwMap);
4111 if(hasDefaultVisibility){
4112 tbMap = &defaultTbMap;
4119 if(hasDefaultVisibility){
4120 dwMap = &defaultDwMap;
4125 QList<QToolBar*> tbList = findToolBars();
4126 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit )
4128 QToolBar* tb = *tit;
4129 if ( tbMap->contains( tb->objectName() ) ) {
4130 tb->setVisible( (*tbMap)[tb->objectName()] );
4136 QList<QDockWidget*> dwList = desktop()->findChildren<QDockWidget*>();
4137 for ( QList<QDockWidget*>::iterator dit = dwList.begin(); dit != dwList.end(); ++dit )
4139 QDockWidget* dw = *dit;
4141 QObject* po = Qtx::findParent( dw, "QMainWindow" );
4142 if ( po != desktop() )
4145 if ( dwMap->contains( dw->objectName() ) )
4146 dw->setVisible( (*dwMap)[dw->objectName()] );
4154 Saves windows geometry
4156 void LightApp_Application::saveDockWindowsState()
4161 bool storeWin = resourceMgr()->booleanValue( "Study", "store_positions", true );
4162 bool storeTb = resourceMgr()->booleanValue( "Study", "store_tool_positions", true );
4164 if( !storeWin && !storeTb )
4168 if ( activeModule() )
4169 modName = activeModule()->name();
4170 else if ( activeStudy() )
4171 modName = "nomodule";
4173 QString versionId = GUI_VERSION_STR;
4174 #if GUI_DEVELOPMENT > 0
4178 QByteArray arr = desktop()->saveState();
4179 resourceMgr()->setValue( "windows_geometry", modName, processState(arr, storeWin, storeTb, false) );
4180 resourceMgr()->setValue( "windows_geometry_version", modName, versionId );
4183 if ( myWinVis.contains( modName ) )
4184 visArr = myWinVis[modName];
4186 QMap<QString, bool> tbMap, dwMap;
4187 dockWindowsState( visArr, tbMap, dwMap );
4189 QList<QToolBar*> tbList = desktop()->findChildren<QToolBar*>();
4190 for ( QList<QToolBar*>::iterator it = tbList.begin(); it != tbList.end(); ++it )
4193 tbMap.insert( tb->objectName(), tb->toggleViewAction()->isChecked() );
4196 QList<QDockWidget*> dwList = desktop()->findChildren<QDockWidget*>();
4197 for ( QList<QDockWidget*>::iterator it = dwList.begin(); it != dwList.end(); ++it )
4199 QDockWidget* wid = *it;
4200 dwMap.insert( wid->objectName(), wid->toggleViewAction()->isChecked() );
4203 visArr = dockWindowsState( tbMap, dwMap );
4205 myWinVis.insert( modName, visArr );
4208 QByteArray LightApp_Application::dockWindowsState( const QMap<QString, bool>& tb, const QMap<QString, bool>& dw ) const
4211 QDataStream stream( &visArr, QIODevice::WriteOnly );
4213 stream << (uchar)ToolBarMarker;
4214 stream << tb.size();
4215 for ( QMap<QString, bool>::const_iterator tit = tb.begin(); tit != tb.end(); ++tit )
4217 stream << tit.key();
4218 stream << (uchar)( tit.value() ? 1 : 0 );
4221 stream << (uchar)DockWidgetMarker;
4222 stream << dw.size();
4223 for ( QMap<QString, bool>::const_iterator wit = dw.begin(); wit != dw.end(); ++wit )
4225 stream << wit.key();
4226 stream << (uchar)( wit.value() ? 1 : 0 );
4232 void LightApp_Application::dockWindowsState( const QByteArray& arr, QMap<QString, bool>& tb, QMap<QString, bool>& dw ) const
4237 QByteArray visArr = arr;
4238 QDataStream stream( &visArr, QIODevice::ReadOnly );
4242 if ( marker != ToolBarMarker )
4247 for ( int i = 0; i < lines; ++i )
4250 stream >> objectName;
4253 tb.insert( objectName, shown );
4257 if ( marker != DockWidgetMarker )
4261 for ( int j = 0; j < lines; ++j )
4264 stream >> objectName;
4267 dw.insert( objectName, shown );
4272 Adds icon names for modules
4274 void LightApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) const
4278 SUIT_ResourceMgr* resMgr = resourceMgr();
4282 QStringList modList;
4283 modules( modList, false );
4285 for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )
4287 QString modName = *it;
4288 QString modIntr = moduleName( modName );
4289 QString modIcon = resMgr->stringValue( modIntr, "icon", QString() );
4291 if ( modIcon.isEmpty() )
4294 if ( SUIT_Tools::extension( modIcon ).isEmpty() )
4295 modIcon += QString( ".png" );
4297 iconMap.insert( modName, modIcon );
4302 Inserts items in popup, which necessary for current application
4304 void LightApp_Application::contextMenuPopup( const QString& type, QMenu* thePopup, QString& title )
4307 LightApp_SelectionMgr* selMgr = LightApp_Application::selectionMgr();
4308 bool cacheIsOn = selMgr->isSelectionCacheEnabled();
4309 selMgr->setSelectionCacheEnabled( true );
4311 SUIT_DataBrowser* ob = objectBrowser();
4313 CAM_Application::contextMenuPopup( type, thePopup, title );
4315 if ( ob && type == ob->popupClientType() ) {
4316 thePopup->addSeparator();
4317 QAction* a = thePopup->addAction( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
4318 if ( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) )
4319 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) );
4322 #ifndef DISABLE_SALOMEOBJECT
4323 if ( selMgr && ob ) {
4324 SALOME_ListIO selected;
4325 selMgr->selectedObjects( selected );
4326 if(selected.Extent() == 1){
4327 Handle(SALOME_InteractiveObject) anIObject = selected.First();
4328 SUIT_DataObject* obj = findObject(anIObject->getEntry());
4329 if(obj && obj->renameAllowed()) {
4330 QAction* a = new QAction(tr("MEN_RENAME_OBJ"), thePopup);
4331 connect( a, SIGNAL( triggered(bool) ), ob, SLOT( onStartEditing() ) );
4332 if ( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) )
4333 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) );
4335 QList<QAction*> acts = thePopup->actions();
4336 QAction* firstAction = acts.count() > 0 ? acts.first() : 0;
4337 thePopup->insertAction(firstAction,a);
4343 selMgr->setSelectionCacheEnabled( cacheIsOn );
4349 void LightApp_Application::createEmptyStudy()
4351 CAM_Application::createEmptyStudy();
4353 if ( objectBrowser() )
4354 objectBrowser()->updateTree();
4356 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
4357 if ( aResMgr && activeStudy() ) {
4358 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
4359 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
4364 void LightApp_Application::setDesktop( SUIT_Desktop* desk )
4366 CAM_Application::setDesktop( desk );
4369 connect( desk, SIGNAL( message( const QString& ) ),
4370 this, SLOT( onDesktopMessage( const QString& ) ), Qt::UniqueConnection );
4371 connect( desk, SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
4372 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
4373 /* connect( desk, SIGNAL( windowMoved( SUIT_ViewWindow* ) ),
4374 this, SLOT( onWindowMoved( SUIT_ViewWindow* ) ), Qt::UniqueConnection ); */
4380 \param mod - module to be activated
4382 bool LightApp_Application::activateModule( CAM_Module* mod )
4384 bool res = CAM_Application::activateModule( mod );
4386 if ( objectBrowser() )
4387 objectBrowser()->updateTree();
4393 \return keyborad accelerators manager object
4395 SUIT_Accel* LightApp_Application::accel() const
4401 Removes dead widget container from map
4403 void LightApp_Application::onWCDestroyed( QObject* ob )
4405 // remove destroyed widget container from windows map
4406 for ( WinMap::ConstIterator itr = myWin.begin(); itr != myWin.end(); ++itr )
4408 if ( itr.value() != ob )
4411 int key = itr.key();
4412 myWin.remove( key );
4417 void LightApp_Application::onMRUActivated( const QString& name )
4419 SUIT_Session* s = SUIT_Session::session();
4420 if ( s && s->activeApplication() == this )
4424 void LightApp_Application::onStylePreferences()
4426 #ifdef USE_SALOME_STYLE
4427 Style_PrefDlg dlg( desktop() );
4430 resourceMgr()->setValue( "Style", "use_salome_style", Style_Salome::isActive() );
4431 #endif // USE_SALOME_STYLE
4434 void LightApp_Application::onFullScreen(){
4435 if(myScreenHelper) {
4436 if(desktop()->isFullScreen())
4437 myScreenHelper->switchToNormalScreen();
4439 myScreenHelper->switchToFullScreen();
4444 Connects just added view manager
4446 void LightApp_Application::addViewManager( SUIT_ViewManager* vm )
4448 connect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
4449 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
4450 CAM_Application::addViewManager( vm );
4454 Remove view manager from memory
4456 void LightApp_Application::removeViewManager( SUIT_ViewManager* vm )
4458 disconnect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
4459 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
4460 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
4462 aStudy->removeObjectProperties( vm->getGlobalId() );
4464 CAM_Application::removeViewManager( vm );
4466 LightApp_SelectionMgr* selMgr = selectionMgr();
4467 QList<SUIT_Selector*> selectors;
4468 selMgr->selectors( selectors );
4469 foreach( SUIT_Selector* selector, selectors ) {
4470 if ( selector->owner() == vm->getViewModel() ) {
4475 // IPAL22894: Crash on closing OCC view
4481 Renames active window of desktop
4483 void LightApp_Application::onRenameWindow()
4488 QWidget* w = desktop()->activeWindow();
4493 QString name = QInputDialog::getText( w, tr( "TOT_RENAME" ), tr( "PRP_RENAME" ), QLineEdit::Normal, w->windowTitle(), &ok );
4494 if( ok && !name.isEmpty() )
4495 w->setWindowTitle( name );
4499 Closes active window of desktop
4501 void LightApp_Application::onCloseWindow()
4506 QWidget* w = desktop()->activeWindow();
4514 Closes all windows of desktop
4516 void LightApp_Application::onCloseAllWindow()
4518 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
4522 QList<SUIT_ViewWindow*> wndList = desk->windows();
4523 SUIT_ViewWindow* wnd;
4524 foreach( wnd, wndList )
4532 Groups all windows of desktop
4534 void LightApp_Application::onGroupAllWindow()
4536 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
4540 QtxWorkstack* wgStack = desk->workstack();
4546 \return default name for an active study
4548 void LightApp_Application::setDefaultStudyName( const QString& theName )
4550 QStringList anInfoList;
4551 modules( anInfoList, false );
4553 LightApp_Study* aStudy = (LightApp_Study*)activeStudy();
4554 if( anInfoList.count() == 1 && // to avoid a conflict between different modules
4555 !aStudy->isSaved() )
4557 aStudy->setStudyName( theName );
4558 updateDesktopTitle();
4563 Custom event handler
4565 bool LightApp_Application::event( QEvent* e )
4567 if( e && e->type()==2000 )
4569 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
4570 QString* d = ( QString* )ce->data();
4571 if( SUIT_MessageBox::question(0, tr("WRN_WARNING"),
4573 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
4574 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
4575 showPreferences( tr( "PREF_APP" ) );
4580 return CAM_Application::event( e );
4583 /*! Check data object */
4584 bool LightApp_Application::checkDataObject(LightApp_DataObject* theObj)
4588 bool isSuitable = !theObj->entry().isEmpty() &&
4589 !theObj->componentDataType().isEmpty() &&
4590 !theObj->name().isEmpty();
4597 int LightApp_Application::openChoice( const QString& aName )
4599 int choice = CAM_Application::openChoice( aName );
4601 if ( choice == OpenExist ) // The document is already open.
4603 // Do you want to reload it?
4604 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "QUE_DOC_ALREADYOPEN" ).arg( aName ),
4605 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No ) == SUIT_MessageBox::Yes )
4606 choice = OpenReload;
4612 bool LightApp_Application::openAction( const int choice, const QString& aName )
4619 STD_Application* app = 0;
4620 SUIT_Session* session = SUIT_Session::session();
4621 QList<SUIT_Application*> appList = session->applications();
4622 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !app; ++it )
4624 if ( (*it)->activeStudy() && (*it)->activeStudy()->studyName() == aName )
4625 app = ::qobject_cast<STD_Application*>( *it );
4630 app->onCloseDoc( false );
4631 appList = session->applications();
4632 STD_Application* other = 0;
4633 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !other; ++it )
4634 other = ::qobject_cast<STD_Application*>( *it );
4637 res = other->onOpenDoc( aName );
4642 res = CAM_Application::openAction( choice, aName );
4649 QStringList LightApp_Application::viewManagersTypes() const
4651 QStringList aTypesList;
4652 aTypesList += myUserWmTypes;
4653 #ifndef DISABLE_GLVIEWER
4654 aTypesList<<GLViewer_Viewer::Type();
4656 #ifndef DISABLE_PLOT2DVIEWER
4657 aTypesList<<Plot2d_Viewer::Type();
4659 #ifndef DISABLE_QXGRAPHVIEWER
4660 aTypesList<<QxScene_Viewer::Type();
4662 #ifndef DISABLE_PVVIEWER
4663 aTypesList<<PVViewer_Viewer::Type();
4665 #ifndef DISABLE_PYVIEWER
4666 aTypesList<<PyViewer_Viewer::Type();
4668 #ifndef DISABLE_OCCVIEWER
4669 aTypesList<<OCCViewer_Viewer::Type();
4671 #ifndef DISABLE_VTKVIEWER
4672 #ifndef DISABLE_SALOMEOBJECT
4673 aTypesList<<SVTK_Viewer::Type();
4675 aTypesList<<VTKViewer_Viewer::Type();
4681 * Removes all view managers of known types
4682 * Other view managers are ignored
4684 void LightApp_Application::clearKnownViewManagers()
4686 QStringList aTypesList = viewManagersTypes();
4687 QList<SUIT_ViewManager*> aMgrList;
4688 viewManagers( aMgrList );
4689 foreach (SUIT_ViewManager* aMgr, aMgrList) {
4690 if (aTypesList.contains(aMgr->getType()))
4691 removeViewManager(aMgr);
4696 Copy of current selection
4698 void LightApp_Application::onCopy()
4700 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
4706 Paste of current data in clipboard
4708 void LightApp_Application::onPaste()
4710 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
4716 Browse (i.e. set focus on) the published objects
4717 \param theIsApplyAndClose - flag indicating that the dialog for creating objects
4718 has been accepted by Ok (or Apply & Close) button
4719 \param theIsOptimizedBrowsing - flag switching to optimized browsing mode
4720 (to select the first published object only)
4721 \return entry of the selected object
4723 QString LightApp_Application::browseObjects( const QStringList& theEntryList,
4724 const bool theIsApplyAndClose,
4725 const bool theIsOptimizedBrowsing )
4728 if( SUIT_ResourceMgr* aResourceMgr = resourceMgr() )
4730 int aBrowsePolicy = aResourceMgr->integerValue( "ObjectBrowser", "browse_published_object", (int)BP_Never );
4731 switch( aBrowsePolicy )
4735 case BP_ApplyAndClose:
4736 if( !theIsApplyAndClose )
4744 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
4748 SUIT_DataBrowser* anOB = objectBrowser();
4752 SUIT_AbstractModel* aModel = dynamic_cast<SUIT_AbstractModel*>( anOB->model() );
4756 QStringListIterator anIter( theEntryList );
4757 if( theIsOptimizedBrowsing )
4759 // go to the last entry
4761 if( anIter.hasPrevious() )
4765 // scroll to each entry in the list
4766 // (in optimized mode - to the last entry only)
4768 LightApp_DataObject* anObject = 0;
4769 while( anIter.hasNext() )
4771 anEntry = anIter.next();
4772 if( !anEntry.isEmpty() )
4774 anObject = aStudy->findObjectByEntry( anEntry );
4777 QModelIndex anIndex = aModel->index( anObject );
4778 anOB->treeView()->scrollTo( anIndex );
4783 // always select the last object
4784 if( anObject && !anEntry.isEmpty() )
4786 QList<SUIT_Selector*> aSelectorList;
4787 selectionMgr()->selectors( "ObjectBrowser", aSelectorList );
4788 if( !aSelectorList.isEmpty() )
4790 if( LightApp_OBSelector* aSelector = dynamic_cast<LightApp_OBSelector*>( aSelectorList.first() ) )
4792 bool anIsAutoBlock = aSelector->autoBlock();
4794 // temporarily disable auto block, to emit LightApp_SelectionMgr::currentSelectionChanged() signal
4795 aSelector->setAutoBlock( false );
4797 SUIT_DataOwnerPtrList aList;
4798 #ifndef DISABLE_SALOMEOBJECT
4799 Handle(SALOME_InteractiveObject) aSObj = new SALOME_InteractiveObject
4800 ( anObject->entry().toLatin1().constData(),
4801 anObject->componentDataType().toLatin1().constData(),
4802 anObject->name().toLatin1().constData() );
4803 LightApp_DataOwner* owner = new LightApp_DataOwner( aSObj );
4805 LightApp_DataOwner* owner = new LightApp_DataOwner( anEntry );
4808 aList.append( owner );
4809 selectionMgr()->setSelected( aList );
4812 // restore auto block flag
4813 aSelector->setAutoBlock( anIsAutoBlock );
4821 SUIT_DataObject* LightApp_Application::findObject( const QString& id ) const
4823 LightApp_Study* study = dynamic_cast<LightApp_Study*>( activeStudy() );
4824 return study ? study->findObjectByEntry( id ) : 0;
4828 Checks that an object can be renamed.
4829 \param entry entry of the object
4830 \brief Return \c true if object can be renamed
4832 bool LightApp_Application::renameAllowed( const QString& /*entry*/) const {
4837 Rename object by entry.
4838 \param entry entry of the object
4839 \param name new name of the object
4840 \brief Return \c true if rename operation finished successfully, \c false otherwise.
4842 bool LightApp_Application::renameObject( const QString& entry, const QString& ) {
4846 /*! Process standard messages from desktop */
4847 void LightApp_Application::onDesktopMessage( const QString& message )
4849 const QString sectionSeparator = "/";
4851 if ( message.toLower() == "updateobjectbrowser" ||
4852 message.toLower() == "updateobjbrowser" ) {
4853 // update object browser
4854 updateObjectBrowser();
4856 else if ( message.toLower().startsWith( "activate_viewer" ) ) {
4857 QString vtype = message.split( sectionSeparator ).last();
4858 if ( !vtype.isEmpty() )
4859 getViewManager( vtype, true );
4862 QStringList data = message.split( sectionSeparator );
4863 if ( data.count() > 1 ) {
4864 QString msgType = data[0].trimmed();
4865 LightApp_Module* sMod = 0;
4866 CAM_Module* mod = module( msgType );
4868 mod = module( moduleTitle( msgType ) );
4869 if ( mod && mod->inherits( "LightApp_Module" ) )
4870 sMod = (LightApp_Module*)mod;
4872 if ( msgType.toLower() == "preferences" ) {
4873 // requested preferences change: should be given as "preferences/<section>/<name>/<value>"
4874 // for example "preferences/Study/multi_file_dump/true"
4875 if ( data.count() > 3 ) {
4876 QString section = data[1].trimmed();
4877 QString param = data[2].trimmed();
4878 QString value = QStringList( data.mid(3) ).join( sectionSeparator );
4879 resourceMgr()->setValue( section, param, value );
4883 // received message for the module
4884 QString msg = QStringList( data.mid(1) ).join( sectionSeparator );
4885 sMod->message( msg );
4893 Returns all top level toolbars.
4894 Note : Result list contains only main window toolbars, not including toolbars from viewers.
4896 QList<QToolBar*> LightApp_Application::findToolBars( const QStringList& names )
4898 QList<QToolBar*> aResult;
4899 QList<QToolBar*> tbList = desktop()->findChildren<QToolBar*>();
4900 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit ) {
4901 QToolBar* tb = *tit;
4902 QObject* po = Qtx::findParent( tb, "QMainWindow" );
4903 if ( po != desktop() )
4905 if ( names.isEmpty() || names.contains( tb->objectName() ) )
4912 Internal method to parse toolbars and dockable windows state.
4914 QByteArray LightApp_Application::processState(QByteArray& input,
4915 const bool processWin,
4916 const bool processTb,
4917 const bool isRestoring,
4918 QByteArray defaultState) {
4921 bool hasDefaultState = !defaultState.isEmpty();
4922 bool isDockWinWriten = false;
4924 //Write date from users settings
4926 QDataStream tmpInputData(&input, QIODevice::ReadOnly);
4927 int marker, version;
4929 tmpInputData >> marker;
4930 tmpInputData >> version;
4931 tmpInputData >> dockmarker;
4932 tmpInputData >> nbDocWin;
4934 if(processWin && processTb && !isRestoring) {
4936 } else if(!processWin && !processTb ) {
4938 aRes = defaultState;
4940 QDataStream aData(&aRes, QIODevice::WriteOnly);
4941 QList<QToolBar*> aToolBars = findToolBars();
4944 for ( QList<QToolBar*>::iterator tit = aToolBars.begin(); tit != aToolBars.end(); ++tit ) {
4945 QToolBar* tb = *tit;
4946 aNames.append(tb->objectName());
4949 int toolBarMarkerIndex = getToolbarMarkerIndex(input,aNames);
4950 if(toolBarMarkerIndex < 0)
4952 QDataStream anInputData(&input, QIODevice::ReadOnly);
4954 int toolBarMarkerIndexDef;
4955 if(hasDefaultState) {
4956 toolBarMarkerIndexDef = getToolbarMarkerIndex(defaultState, aNames);
4957 if(toolBarMarkerIndexDef < 0)
4960 QDataStream anInputDataDef(&defaultState, QIODevice::ReadOnly);
4962 QDataStream* aTargetData = 0;
4963 int aTargetIndex = -1;
4965 QByteArray currentArr = desktop()->saveState();
4966 QDataStream anInputDataCur(¤tArr, QIODevice::ReadOnly);
4967 bool useInputData = !isRestoring || (isRestoring && nbDocWin > 0);
4968 if(processWin && useInputData) {
4969 aTargetData = &anInputData;
4970 aTargetIndex = toolBarMarkerIndex;
4972 //Write date from default settings
4973 if(hasDefaultState) {
4974 aTargetData = &anInputDataDef;
4975 aTargetIndex = toolBarMarkerIndexDef;
4977 //If no default state, write current snapshot of the dockable windows
4979 aTargetData = &anInputDataCur;
4980 int toolBarMarkerIndexCur = getToolbarMarkerIndex(currentArr, aNames);
4981 aTargetIndex = toolBarMarkerIndexCur;
4986 if(aTargetData && aTargetIndex >= 0 ) {
4987 aTargetData->device()->seek(0);
4988 while( aTargetData->device()->pos() < aTargetIndex ) {
4993 isDockWinWriten = true;
5000 aTargetData = &anInputData;
5001 aTargetIndex = toolBarMarkerIndex;
5003 if(hasDefaultState) {
5004 aTargetData = &anInputDataDef;
5005 aTargetIndex = toolBarMarkerIndexDef;
5009 if(aTargetData && aTargetIndex >= 0) {
5011 if(!isDockWinWriten ) {
5012 //Write version marker
5013 int marker, version;
5014 aTargetData->device()->seek(0);
5015 *aTargetData >> marker;
5016 *aTargetData >> version;
5019 aData << (uchar) QDockWidgetMarker;
5021 int shift = 4*sizeof(int) + sizeof(QSize);
5022 index = aTargetIndex - shift;
5024 index = aTargetIndex;
5027 aTargetData->device()->seek(index);
5028 while(!aTargetData->atEnd()) {
5033 } else { // Not treat toolbars
5034 aData << (uchar) QToolBarMarker;
5035 aData << (int) 0; //Nb toolbars = 0
5042 \brief Emits operationFinished signal.
5043 \param theModuleName the name of the module which perfomed the operation
5044 \param theOperationName the operation name
5045 \param theEntryList the list of the created objects entries
5047 void LightApp_Application::emitOperationFinished( const QString& theModuleName,
5048 const QString& theOperationName,
5049 const QStringList& theEntryList )
5051 emit operationFinished( theModuleName, theOperationName, theEntryList );
5055 Update visibility state of given objects
5057 void LightApp_Application::updateVisibilityState( DataObjectList& theList,
5058 SUIT_ViewModel* theViewModel )
5060 if ( !theViewModel || theList.isEmpty() ) return;
5062 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
5063 if ( !aStudy ) return;
5065 SALOME_View* aView = dynamic_cast<SALOME_View*>( theViewModel );
5067 for ( DataObjectList::iterator itr = theList.begin(); itr != theList.end(); ++itr ) {
5068 LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>(*itr);
5070 if ( !obj || aStudy->isComponent( obj->entry() ) )
5073 LightApp_Module* anObjModule = dynamic_cast<LightApp_Module*>(obj->module());
5074 if ( anObjModule ) {
5075 LightApp_Displayer* aDisplayer = anObjModule->displayer();
5077 Qtx::VisibilityState anObjState = Qtx::UnpresentableState;
5078 if ( aDisplayer->canBeDisplayed( obj->entry(), theViewModel->getType() ) ) {
5079 if ( aView && aDisplayer->IsDisplayed( obj->entry(), aView ) )
5080 anObjState = Qtx::ShownState;
5082 anObjState = Qtx::HiddenState;
5084 aStudy->setVisibilityState( obj->entry(), anObjState );
5091 * Called when window activated
5093 void LightApp_Application::onWindowActivated( SUIT_ViewWindow* theViewWindow )
5095 SUIT_DataBrowser* anOB = objectBrowser();
5098 SUIT_DataObject* rootObj = anOB->root();
5102 DataObjectList listObj = rootObj->children( true );
5104 SUIT_ViewModel* vmod = 0;
5105 if ( SUIT_ViewManager* vman = theViewWindow->getViewManager() )
5106 vmod = vman->getViewModel();
5107 updateVisibilityState( listObj, vmod );
5111 Called then view manager removed
5113 void LightApp_Application::onViewManagerRemoved( SUIT_ViewManager* )
5115 ViewManagerList lst;
5116 viewManagers( lst );
5117 if ( lst.count() == 1) { // in case if closed last view window
5118 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
5120 aStudy->setVisibilityStateForAll( Qtx::UnpresentableState );
5125 Check existing document.
5127 bool LightApp_Application::checkExistingDoc()
5130 if( activeStudy() ) {
5131 int answer = SUIT_MessageBox::question( desktop(),
5132 tr( "APPCLOSE_CAPTION" ),
5133 tr( "STUDYCLOSE_DESCRIPTION" ),
5134 tr( "APPCLOSE_SAVE" ),
5135 tr( "APPCLOSE_CLOSE" ),
5136 tr( "APPCLOSE_CANCEL" ), 0 );
5138 if ( activeStudy()->isSaved() ) {
5141 } else if ( onSaveAsDoc() ) {
5142 if( !closeDoc( false ) ) {
5149 else if( answer == 1 ) {
5151 } else if( answer == 2 ) {
5158 #ifndef DISABLE_PYCONSOLE
5160 PyConsole_Interp* LightApp_Application::getPyInterp()
5162 static PyConsole_Interp* myInterp = 0;
5164 myInterp = createPyInterp();
5165 myInterp->initialize();
5170 PyConsole_Interp* LightApp_Application::createPyInterp()
5172 return new PyConsole_Interp();
5175 #endif // DISABLE_PYCONSOLE