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 "PyConsole_Interp.h"
39 #include "LightApp_PyEditor.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 // Markers used to parse array with dockable windows and toolbars state.
234 // For more details please see the qdockarealayout.cpp && qtoolbararealayout.cpp
235 // in the Qt source code.
237 #define QDockWidgetMarker 0xfd // = DockWidgetStateMarker
238 #define QToolBarMarker 0xfc // = ToolBarStateMarkerEx
240 // Format of the Byte array with the windows and toolbar state is:
241 // VersionMarker|version|DockWidgetStateMarker|nbDockWidgetLines|...DocWidgetData...|ToolBarStateMarkerEx|nbToolBarLines|...ToolBarData...
243 //Find toolbar marker position in the array in the following way:
244 //since the 'toolbar marker' is not unique, find index of first occurrence of the
245 //'toolbar marker' in the array and check that next string is name of the toolbar
249 int getToolbarMarkerIndex( QByteArray input, const QStringList& aFlags ) {
250 int aResult = -1,tmp = 0;
251 int inputLen = input.length();
252 QDataStream anInputData( &input, QIODevice::ReadOnly );
253 while ( tmp < inputLen ) {
254 tmp = input.indexOf( QToolBarMarker, tmp + 1 );
257 anInputData.device()->seek( tmp );
261 anInputData >> lines;
263 if ( lines == 0 && anInputData.atEnd() ) {
264 //Case then array doesn't contain information about toolbars,
275 if ( aFlags.contains( str ) ) {
283 QString langToName( const QString& lang )
285 // special processing for English language to avoid such result as "American English"
286 // as Qt cannot just say "English"
291 result = QLocale( lang ).nativeLanguageName();
296 /*!Create new instance of LightApp_Application.*/
297 extern "C" LIGHTAPP_EXPORT SUIT_Application* createApplication()
299 return new LightApp_Application();
302 /*! \var global preferences of LightApp */
303 LightApp_Preferences* LightApp_Application::_prefs_ = 0;
307 \class LightApp_Application
308 Application containing LightApp module
312 LightApp_Application::LightApp_Application()
313 : CAM_Application( false ),
315 myScreenHelper(new LightApp_FullScreenHelper())
317 Q_INIT_RESOURCE( LightApp );
319 STD_TabDesktop* desk = new STD_TabDesktop();
320 desk->setFullScreenAllowed(false);
321 desk->setMinimizeAllowed(false);
325 // initialize auto save timer
326 myAutoSaveTimer = new QTimer( this );
327 myAutoSaveTimer->setSingleShot( true );
328 connect( myAutoSaveTimer, SIGNAL( timeout() ), this, SLOT( onSaveDoc() ) );
330 //connect( this, SIGNAL( moving() ), this, SLOT( onMoved() ) );
332 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
333 QPixmap aLogo = aResMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
335 desktop()->setWindowIcon( aLogo );
336 desktop()->setDockableMenuBar( false );
337 desktop()->setDockableStatusBar( false );
339 // base logo (salome itself)
340 desktop()->logoInsert( "_app_base", aResMgr->loadPixmap( "LightApp", tr( "APP_BASE_LOGO" ), false ) );
341 // extra logo (salome-based application)
342 desktop()->logoInsert( "_app_extra", aResMgr->loadPixmap( "LightApp", tr( "APP_EXTRA_LOGO" ), false ) );
346 mySelMgr = new LightApp_SelectionMgr( this );
348 myAccel = SUIT_Accel::getAccel();
350 #ifndef DISABLE_OCCVIEWER
351 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, OCCViewer_Viewer::Type() );
352 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, OCCViewer_Viewer::Type() );
353 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, OCCViewer_Viewer::Type() );
354 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, OCCViewer_Viewer::Type() );
355 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, OCCViewer_Viewer::Type() );
356 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, OCCViewer_Viewer::Type() );
357 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, OCCViewer_Viewer::Type() );
358 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, OCCViewer_Viewer::Type() );
359 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, OCCViewer_Viewer::Type() );
360 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, OCCViewer_Viewer::Type() );
361 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, OCCViewer_Viewer::Type() );
362 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, OCCViewer_Viewer::Type() );
364 #ifndef DISABLE_VTKVIEWER
365 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, VTKViewer_Viewer::Type() );
366 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, VTKViewer_Viewer::Type() );
367 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, VTKViewer_Viewer::Type() );
368 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, VTKViewer_Viewer::Type() );
369 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, VTKViewer_Viewer::Type() );
370 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, VTKViewer_Viewer::Type() );
371 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, VTKViewer_Viewer::Type() );
372 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, VTKViewer_Viewer::Type() );
373 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, VTKViewer_Viewer::Type() );
374 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, VTKViewer_Viewer::Type() );
375 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, VTKViewer_Viewer::Type() );
376 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, VTKViewer_Viewer::Type() );
378 #ifndef DISABLE_PLOT2DVIEWER
379 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, Plot2d_Viewer::Type() );
380 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, Plot2d_Viewer::Type() );
381 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, Plot2d_Viewer::Type() );
382 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, Plot2d_Viewer::Type() );
383 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, Plot2d_Viewer::Type() );
384 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, Plot2d_Viewer::Type() );
385 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, Plot2d_Viewer::Type() );
386 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, Plot2d_Viewer::Type() );
389 connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) );
390 connect( desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
391 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
392 connect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
393 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ), Qt::UniqueConnection );
396 // Set existing font for the python console in resources
397 if( !aResMgr->hasValue( "PyConsole", "font" ) )
400 QFont f = aResMgr->fontValue( "PyConsole", "font" );
402 QStringList famdb = fdb.families();
404 if ( famdb.contains(f.family()) || !aResMgr->hasValue( "PyConsole", "additional_families" ) )
407 QStringList anAddFamilies = aResMgr->stringValue( "PyConsole", "additional_families" ).split( ";", QString::SkipEmptyParts );
409 for ( QStringList::Iterator it = anAddFamilies.begin(); it != anAddFamilies.end(); ++it )
412 if ( famdb.contains(aFamily) )
414 f.setFamily( aFamily );
415 aResMgr->setValue( "PyConsole", "font", f );
422 *\li Save window geometry.
423 *\li Save desktop geometry.
424 *\li Save resource maneger.
425 *\li Delete selection manager.
427 LightApp_Application::~LightApp_Application()
431 delete myScreenHelper;
434 /*!Start application.*/
435 void LightApp_Application::start()
437 CAM_Application::start();
440 updateViewManagers();
441 updateCommandsStatus();
444 desktop()->statusBar()->showMessage( "" );
446 LightApp_EventFilter::Init();
451 /*!Closeapplication.*/
452 void LightApp_Application::closeApplication()
454 #ifndef DISABLE_QTXWEBBROWSER
455 QProcess::startDetached( "HelpBrowser",
456 QStringList() << QString( "--remove=%1" ).arg( QApplication::instance()->applicationPid() ) );
458 CAM_Application::closeApplication();
461 /*!Gets application name.*/
462 QString LightApp_Application::applicationName() const
464 static QString _app_name;
465 if ( _app_name.isEmpty() )
466 _app_name = tr( "APP_NAME" );
470 /*!Gets application version.*/
471 QString LightApp_Application::applicationVersion() const
473 static QString _app_version;
475 if ( _app_version.isEmpty() )
477 QString resVersion = tr( "APP_VERSION" );
478 if ( resVersion != "APP_VERSION" )
480 _app_version = resVersion;
484 _app_version = GUI_VERSION_STR;
490 /*!Load module by \a name.*/
491 CAM_Module* LightApp_Application::loadModule( const QString& name, const bool showMsg )
493 CAM_Module* mod = CAM_Application::loadModule( name, showMsg );
496 connect( this, SIGNAL( studyOpened() ), mod, SLOT( onModelOpened() ) );
497 connect( this, SIGNAL( studySaved() ), mod, SLOT( onModelSaved() ) );
498 connect( this, SIGNAL( studyClosed() ), mod, SLOT( onModelClosed() ) );
503 /*!Activate module by \a modName*/
504 bool LightApp_Application::activateModule( const QString& modName )
507 CAM_Module* prevMod = activeModule();
510 actName = prevMod->moduleName();
512 if ( actName == modName )
515 putInfo( tr( "ACTIVATING_MODULE" ).arg( modName ) );
517 saveDockWindowsState();
519 bool status = CAM_Application::activateModule( modName );
521 updateModuleActions();
529 updateViewManagers();
531 if ( activeStudy() && activeStudy()->root() && objectBrowser() ) {
532 if ( objectBrowser()->root() != activeStudy()->root() )
533 objectBrowser()->setRoot( activeStudy()->root() );
534 updateObjectBrowser( true );
537 if ( activeModule() ) activeModule()->updateModuleVisibilityState();
542 /*!Gets selection manager.*/
543 LightApp_SelectionMgr* LightApp_Application::selectionMgr() const
548 /*!Creat action "New window" for certain type of viewer:*/
549 void LightApp_Application::createActionForViewer( const int id,
551 const QString& suffix,
554 QString vtlt = tr( QString( "NEW_WINDOW_%1" ).arg( suffix ).toLatin1().constData() );
555 QString tip = tr( "CREATING_NEW_WINDOW" ).arg( vtlt.remove( "&" ) );
556 QAction* a = createAction( id, // menu action id
563 false, // toggle flag
565 SLOT( onNewWindow() ) ); // slot
566 createMenu( a, parentId, -1 );
571 void LightApp_Application::createActions()
573 CAM_Application::createActions();
575 SUIT_Desktop* desk = desktop();
576 SUIT_ResourceMgr* resMgr = resourceMgr();
579 createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIcon(),
580 tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
581 Qt::CTRL+Qt::Key_P, desk, false, this, SLOT( onPreferences() ) );
585 // - Help for modules
587 int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
588 createMenu( separator(), helpMenu, -1, 10 );
589 QStringList aModuleList;
590 modules( aModuleList, false );
591 aModuleList.prepend( "GUI" );
592 aModuleList.prepend( "KERNEL" );
594 int id = LightApp_Application::UserID + FIRST_HELP_ID;
597 foreach( aModule, aModuleList ) {
598 if ( aModule.isEmpty() ) // module title (user name)
600 IMap <QString, QString> helpData; // list of help files for the module
601 QString helpSubMenu; // help submenu name (empty if not needed)
602 QString modName = moduleName( aModule ); // module name
603 if ( modName.isEmpty() ) modName = aModule; // for KERNEL and GUI
604 QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName ); // module root dir variable
605 QString modDir = getenv( rootDir.toLatin1().constData() ); // module root dir
607 if (resMgr->hasValue( modName, "documentation" ) )
608 docSection = resMgr->stringValue(modName, "documentation");
609 else if ( resMgr->hasSection( modName + "_documentation" ) )
610 docSection = modName + "_documentation";
611 if ( !docSection.isEmpty() ) {
612 helpSubMenu = resMgr->stringValue( docSection, "sub_menu", "" ).arg( aModule );
613 QStringList listOfParam = resMgr->parameters( docSection );
614 foreach( QString paramName, listOfParam ) {
615 QString valueStr = resMgr->stringValue( docSection, paramName );
616 if ( !valueStr.isEmpty() ) {
617 QFileInfo fi( valueStr );
618 if ( fi.isRelative() && !modDir.isEmpty() )
619 valueStr = Qtx::addSlash( modDir ) + valueStr;
620 if ( QFile::exists( valueStr ) )
621 helpData.insert( paramName.arg( aModule ), valueStr );
626 if ( helpData.isEmpty() && !modDir.isEmpty() ) {
627 QStringList idxLst = QStringList() << modDir << "share" << "doc" << "salome" << "gui" << modName << "index.html";
628 QString indexFile = idxLst.join( QDir::separator() ); // index file
629 if ( QFile::exists( indexFile ) )
630 helpData.insert( tr( "%1 module Users's Guide" ).arg( aModule ), indexFile );
633 IMapConstIterator<QString, QString > fileIt;
634 for ( fileIt = helpData.begin(); fileIt != helpData.end(); fileIt++ ) {
635 QString helpFileName = fileIt.key();
636 // remove all '//' occurances
637 while ( helpFileName.contains( "//" ) )
638 helpFileName.replace( "//", "" );
639 // obtain submenus hierarchy if given
640 QStringList smenus = helpFileName.split( "/" );
641 helpFileName = smenus.last();
643 QAction* a = createAction( id, helpFileName,
644 resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
645 helpFileName, helpFileName,
646 0, desk, false, this, SLOT( onHelpContentsModule() ) );
647 a->setData( fileIt.value() );
648 if ( !helpSubMenu.isEmpty() ) {
649 smenus.prepend( helpSubMenu );
651 // create sub-menus hierarchy
652 int menuId = helpMenu;
653 foreach ( QString subMenu, smenus ) {
654 menuId = createMenu( subMenu, menuId, -1, 0 );
656 createMenu( a, menuId, -1, 0 );
661 // - Additional help items
663 createMenu( separator(), helpMenu, -1, 5 );
665 QStringList addHelpItems = resMgr->parameters( "add_help" );
666 foreach ( QString addHelpItem, addHelpItems ) {
667 QString valueStr = resMgr->stringValue( "add_help", addHelpItem );
668 if ( !valueStr.isEmpty() && QFile::exists( valueStr ) ) {
669 QAction* a = createAction( id, addHelpItem,
670 resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
671 addHelpItem, addHelpItem,
672 0, desk, false, this, SLOT( onHelpContentsModule() ) );
673 a->setData( valueStr );
674 createMenu( a, helpMenu, -1, 5 );
680 static QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), 0 );
681 connect( mru, SIGNAL( activated( const QString& ) ), this, SLOT( onMRUActivated( const QString& ) ) );
682 registerAction( MRUId, mru );
684 // default icon for neutral point ('SALOME' module)
685 QPixmap defIcon = resMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
686 if ( defIcon.isNull() )
687 defIcon = QPixmap( imageEmptyIcon );
689 //! default icon for any module
690 QPixmap modIcon = resMgr->loadPixmap( "LightApp", tr( "APP_MODULE_ICO" ), false );
691 if ( modIcon.isNull() )
692 modIcon = QPixmap( imageEmptyIcon );
695 modules( modList, false );
697 if ( modList.count() > 1 )
699 LightApp_ModuleAction* moduleAction =
700 new LightApp_ModuleAction( tr( "APP_NAME" ), defIcon, desk );
702 QMap<QString, QString> iconMap;
703 moduleIconNames( iconMap );
705 const int iconSize = 20;
707 QStringList::Iterator it;
708 for ( it = modList.begin(); it != modList.end(); ++it )
710 if ( !isModuleAccessible( *it ) )
713 QString modName = moduleName( *it );
716 if ( iconMap.contains( *it ) )
717 iconName = iconMap[*it];
719 QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
724 "****************************************************************" << std::endl <<
725 " Warning: icon for " << qPrintable(*it) << " is not found!" << std::endl <<
726 " Using the default icon." << std::endl <<
727 "****************************************************************" << std::endl);
729 icon = Qtx::scaleIcon( icon, iconSize );
731 moduleAction->insertModule( *it, icon );
734 connect( moduleAction, SIGNAL( moduleActivated( const QString& ) ),
735 this, SLOT( onModuleActivation( const QString& ) ) );
736 registerAction( ModulesListId, moduleAction );
740 int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, MenuWindowId, 100 );
741 int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
743 createAction( CloseId, tr( "TOT_CLOSE" ), QIcon(), tr( "MEN_DESK_CLOSE" ), tr( "PRP_CLOSE" ),
744 Qt::CTRL+Qt::Key_F4, desk, false, this, SLOT( onCloseWindow() ) );
745 createAction( CloseAllId, tr( "TOT_CLOSE_ALL" ), QIcon(), tr( "MEN_DESK_CLOSE_ALL" ), tr( "PRP_CLOSE_ALL" ),
746 0, desk, false, this, SLOT( onCloseAllWindow() ) );
747 createAction( GroupAllId, tr( "TOT_GROUP_ALL" ), QIcon(), tr( "MEN_DESK_GROUP_ALL" ), tr( "PRP_GROUP_ALL" ),
748 0, desk, false, this, SLOT( onGroupAllWindow() ) );
750 createMenu( CloseId, windowMenu, 0, -1 );
751 createMenu( CloseAllId, windowMenu, 0, -1 );
752 createMenu( GroupAllId, windowMenu, 0, -1 );
753 createMenu( separator(), windowMenu, -1, 0 );
755 #ifndef DISABLE_GLVIEWER
756 createActionForViewer( NewGLViewId, newWinMenu, QString::number( 0 ), Qt::ALT+Qt::Key_G );
758 #ifndef DISABLE_PLOT2DVIEWER
759 createActionForViewer( NewPlot2dId, newWinMenu, QString::number( 1 ), Qt::ALT+Qt::Key_P );
761 #ifndef DISABLE_OCCVIEWER
762 createActionForViewer( NewOCCViewId, newWinMenu, QString::number( 2 ), Qt::ALT+Qt::Key_O );
764 #ifndef DISABLE_VTKVIEWER
765 createActionForViewer( NewVTKViewId, newWinMenu, QString::number( 3 ), Qt::ALT+Qt::Key_K );
767 #ifndef DISABLE_QXGRAPHVIEWER
768 createActionForViewer( NewQxSceneViewId, newWinMenu, QString::number( 4 ), Qt::ALT+Qt::Key_S );
770 #ifndef DISABLE_GRAPHICSVIEW
771 createActionForViewer( NewGraphicsViewId, newWinMenu, QString::number( 5 ), Qt::ALT+Qt::Key_C );
773 #ifndef DISABLE_PVVIEWER
774 createActionForViewer( NewPVViewId, newWinMenu, QString::number( 6 ), Qt::ALT+Qt::Key_A );
776 #ifndef DISABLE_PYVIEWER
777 createActionForViewer( NewPyViewerId, newWinMenu, QString::number( 7 ), Qt::ALT+Qt::Key_Y );
780 createAction( RenameId, tr( "TOT_RENAME" ), QIcon(), tr( "MEN_DESK_RENAME" ), tr( "PRP_RENAME" ),
781 Qt::ALT+Qt::SHIFT+Qt::Key_R, desk, false, this, SLOT( onRenameWindow() ) );
782 createMenu( RenameId, windowMenu, -1 );
784 int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
785 createMenu( PreferencesId, fileMenu, 50, -1 );
786 createMenu( separator(), fileMenu, -1, 50, -1 );
788 createMenu( separator(), fileMenu, -1, 100, -1 );
789 createMenu( MRUId, fileMenu, 100, -1 );
790 createMenu( separator(), fileMenu, -1, 100, -1 );
792 #ifdef USE_SALOME_STYLE
793 createAction( StyleId, tr( "TOT_THEME" ), QIcon(), tr( "MEN_DESK_THEME" ), tr( "PRP_THEME" ),
794 0, desk, false, this, SLOT( onStylePreferences() ) );
795 #endif // USE_SALOME_STYLE
797 createAction( FullScreenId, tr( "TOT_FULLSCREEN" ), QIcon(), tr( "MEN_DESK_FULLSCREEN" ), tr( "PRP_FULLSCREEN" ),
798 Qt::Key_F11, desk, false, this, SLOT( onFullScreen() ) );
801 int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1 );
802 createMenu( separator(), viewMenu, -1, 20, -1 );
803 #ifdef USE_SALOME_STYLE
804 createMenu( StyleId, viewMenu, 20, -1 );
805 #endif // USE_SALOME_STYLE
806 createMenu( FullScreenId, viewMenu, 20, -1 );
808 int modTBar = createTool( tr( "INF_TOOLBAR_MODULES" ), // title (language-dependant)
809 QString( "SalomeModules" ) ); // name (language-independant)
810 createTool( ModulesListId, modTBar );
813 /*!On module activation action.*/
814 void LightApp_Application::onModuleActivation( const QString& modName )
816 // Force user to create/open a study before module activation
817 QMap<QString, QString> iconMap;
818 moduleIconNames( iconMap );
819 QPixmap icon = resourceMgr()->loadPixmap( moduleName( modName ), iconMap[ modName ], false );
821 icon = resourceMgr()->loadPixmap( "LightApp", tr( "APP_MODULE_BIG_ICO" ), false ); // default icon for any module
823 bool cancelled = false;
825 while ( !modName.isEmpty() && !activeStudy() && !cancelled ){
826 LightApp_ModuleDlg aDlg( desktop(), modName, icon );
827 QMap<int, QString> opmap = activateModuleActions();
828 for ( QMap<int, QString>::ConstIterator it = opmap.begin(); it != opmap.end(); ++it )
829 aDlg.addButton( it.value(), it.key() );
831 int res = aDlg.exec();
833 // some operation is selected
834 moduleActionSelected( res );
838 putInfo( tr("INF_CANCELLED") );
840 LightApp_ModuleAction* moduleAction =
841 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
843 moduleAction->setActiveModule( QString() );
849 activateModule( modName );
852 /*!Default module activation.*/
853 QString LightApp_Application::defaultModule() const
855 QStringList aModuleNames;
856 modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration
857 //! If there's the one and only module --> activate it automatically
858 //! TODO: Possible improvement - default module can be taken from preferences
859 return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" );
862 /*!On new window slot.*/
863 void LightApp_Application::onNewWindow()
865 const QObject* obj = sender();
866 if ( !obj || !obj->inherits( "QAction" ) )
870 int id = actionId( (QAction*)obj );
873 #ifndef DISABLE_GLVIEWER
875 type = GLViewer_Viewer::Type();
878 #ifndef DISABLE_PLOT2DVIEWER
880 type = Plot2d_Viewer::Type();
883 #ifndef DISABLE_OCCVIEWER
885 type = OCCViewer_Viewer::Type();
888 #ifndef DISABLE_VTKVIEWER
890 type = VTKViewer_Viewer::Type();
893 #ifndef DISABLE_QXGRAPHVIEWER
894 case NewQxSceneViewId:
895 type = QxScene_Viewer::Type();
898 #ifndef DISABLE_GRAPHICSVIEW
899 case NewGraphicsViewId:
900 type = GraphicsView_Viewer::Type();
903 #ifndef DISABLE_PVVIEWER
905 type = PVViewer_Viewer::Type();
908 #ifndef DISABLE_PYVIEWER
910 type = PyViewer_Viewer::Type();
915 if ( !type.isEmpty() )
916 createViewManager( type );
920 SLOT: Creates new document
922 void LightApp_Application::onNewDoc()
924 if ( !checkExistingDoc() )
927 //asl: fix for 0020515
928 saveDockWindowsState();
930 CAM_Application::onNewDoc();
934 SLOT: Opens new document
936 void LightApp_Application::onOpenDoc()
938 SUIT_Study* study = activeStudy();
940 if ( !checkExistingDoc() )
943 CAM_Application::onOpenDoc();
945 if ( !study ) // new study will be create in THIS application
948 updateViewManagers();
953 SLOT: Opens new document.
954 \param aName - name of file
956 bool LightApp_Application::onOpenDoc( const QString& aName )
958 if ( !checkExistingDoc() )
961 saveDockWindowsState();
963 // We should take mru action first because this application instance can be deleted later.
964 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
966 bool res = CAM_Application::onOpenDoc( aName );
971 mru->insert( aName );
973 mru->remove( aName );
979 SLOT: Displays "About" message box
981 void LightApp_Application::onHelpAbout()
983 LightApp_AboutDlg dlg( applicationName(), applicationVersion(), desktop() );
988 Private SLOT: Called on selection is changed
989 Dispatchs active module that selection is changed
991 void LightApp_Application::onSelection()
993 //MESSAGE("onSelection")
994 onSelectionChanged();
996 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
997 ((LightApp_Module*)activeModule())->selectionChanged();
1002 \param study - SUIT_Study.
1004 void LightApp_Application::setActiveStudy( SUIT_Study* study )
1006 CAM_Application::setActiveStudy( study );
1010 Enables/Disables menu items and toolbar buttons. Rebuild menu
1012 void LightApp_Application::updateCommandsStatus()
1014 CAM_Application::updateCommandsStatus();
1017 #ifndef DISABLE_GLVIEWER
1018 a = action( NewGLViewId );
1020 a->setEnabled( activeStudy() );
1023 #ifndef DISABLE_PLOT2DVIEWER
1024 a = action( NewPlot2dId );
1026 a->setEnabled( activeStudy() );
1029 #ifndef DISABLE_OCCVIEWER
1030 a = action( NewOCCViewId );
1032 a->setEnabled( activeStudy() );
1035 #ifndef DISABLE_VTKVIEWER
1036 a = action( NewVTKViewId );
1038 a->setEnabled( activeStudy() );
1041 #ifndef DISABLE_QXGRAPHVIEWER
1042 a = action( NewQxSceneViewId );
1044 a->setEnabled( activeStudy() );
1047 #ifndef DISABLE_GRAPHICSVIEW
1048 a = action( NewGraphicsViewId );
1050 a->setEnabled( activeStudy() );
1053 #ifndef DISABLE_PVVIEWER
1054 a = action( NewPVViewId );
1056 a->setEnabled( activeStudy() );
1059 #ifndef DISABLE_PYVIEWER
1060 a = action( NewPyViewerId );
1062 a->setEnabled( activeStudy() );
1068 Runs system command in separate thread
1070 class RunBrowser: public QThread
1073 RunBrowser( LightApp_Application* app,
1074 const QString& theApp,
1075 const QString& theParams,
1076 const QString& theHelpFile,
1077 const QString& theContext = QString() )
1079 myParams( theParams ),
1080 myContext( theContext ),
1084 //For the external browser always specify 'file://' protocol,
1085 //because some WEB browsers (for example Mozilla Firefox) can't open local file without protocol.
1086 myHelpFile = QString("file://%1").arg( QFileInfo( theHelpFile ).canonicalFilePath() );
1091 if ( !myApp.isEmpty() && !myHelpFile.isEmpty()) {
1092 QString aCommand = QString( "%1 %2 \"%3%4\"" ).arg( myApp, myParams, myHelpFile, myContext.isEmpty() ? QString("") : QString( "#%1" ).arg( myContext ) );
1094 QProcess* proc = new QProcess();
1096 proc->start( aCommand );
1097 if ( !proc->waitForStarted() ) {
1098 SALOME_CustomEvent* ce2000 = new SALOME_CustomEvent( 2000 );
1099 QString* msg = new QString( QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).arg( myApp, myHelpFile ) );
1100 ce2000->setData( msg );
1101 QApplication::postEvent( myLApp, ce2000 );
1112 LightApp_Application* myLApp;
1116 SLOT: Displays help contents for choosen module
1118 void LightApp_Application::onHelpContentsModule()
1120 const QAction* a = (QAction*) sender();
1121 QString helpFile = a->data().toString();
1122 if ( helpFile.isEmpty() ) return;
1124 SUIT_ResourceMgr* resMgr = resourceMgr();
1127 platform = "winapplication";
1129 platform = "application";
1131 QString anApp = resMgr->stringValue("ExternalBrowser", platform);
1133 QString quote("\"");
1134 anApp.prepend( quote );
1135 anApp.append( quote );
1137 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
1138 #if DISABLE_QTXWEBBROWSER
1139 bool useExtBrowser = true;
1141 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1144 if( useExtBrowser ) {
1145 if ( !anApp.isEmpty() ) {
1146 RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile );
1150 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1151 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1152 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1154 showPreferences( tr( "PREF_APP" ) );
1158 QStringList parameters;
1159 parameters << QString( "--language=%1" ).arg( resMgr->stringValue( "language", "language" ) );
1160 parameters << QString( "--add=%1" ).arg( QApplication::instance()->applicationPid() );
1161 parameters << helpFile;
1162 QProcess::startDetached( "HelpBrowser", parameters );
1167 SLOT: Displays help contents for choosen dialog
1169 void LightApp_Application::onHelpContextModule( const QString& theComponentName,
1170 const QString& theFileName,
1171 const QString& theContext )
1173 QString fileName = theFileName;
1174 QString context = theContext;
1175 if ( !QFile::exists( fileName ) && theContext.isEmpty() ) {
1176 // context might be passed within theFileName argument
1177 QStringList comps = fileName.split("#");
1178 if ( comps.count() > 1 ) {
1179 context = comps.last();
1181 fileName = comps.join("#");
1185 QString homeDir = "";
1186 if ( !theComponentName.isEmpty() ) {
1187 QString dir = getenv( ( theComponentName + "_ROOT_DIR" ).toLatin1().constData() );
1188 if ( !dir.isEmpty() )
1189 homeDir = Qtx::addSlash( Qtx::addSlash( dir ) +
1190 Qtx::addSlash( "share" ) +
1191 Qtx::addSlash( "doc" ) +
1192 Qtx::addSlash( "salome" ) +
1193 Qtx::addSlash( "gui" ) +
1194 Qtx::addSlash( theComponentName ) );
1197 QString helpFile = QFileInfo( homeDir + fileName ).absoluteFilePath();
1198 SUIT_ResourceMgr* resMgr = resourceMgr();
1201 platform = "winapplication";
1203 platform = "application";
1205 QString anApp = resMgr->stringValue("ExternalBrowser", platform);
1207 QString quote("\"");
1208 anApp.prepend( quote );
1209 anApp.append( quote );
1212 #if DISABLE_QTXWEBBROWSER
1213 bool useExtBrowser = true;
1215 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1219 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
1221 if ( !anApp.isEmpty() ) {
1222 RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile, context );
1226 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1227 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1228 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1229 showPreferences( tr( "PREF_APP" ) );
1233 QStringList parameters;
1234 parameters << QString( "--language=%1" ).arg( resMgr->stringValue( "language", "language" ) );
1235 parameters << QString( "--add=%1" ).arg( QApplication::instance()->applicationPid() );
1236 parameters << QString( "%1#%2" ).arg( helpFile ).arg( context );
1237 QProcess::startDetached( "HelpBrowser", parameters );
1242 Sets enable or disable some actions on selection changed.
1244 void LightApp_Application::onSelectionChanged()
1246 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
1247 bool canCopy = m ? m->canCopy() : false;
1248 bool canPaste = m ? m->canPaste() : false;
1250 action( EditCopyId )->setEnabled(canCopy);
1251 action( EditPasteId )->setEnabled(canPaste);
1255 SLOT: Performs some actions when dockable windows are triggered
1257 void LightApp_Application::onDockWindowVisibilityChanged( bool )
1261 QWidget* LightApp_Application::dockWindow( const int id ) const
1264 if ( myWin.contains( id ) )
1269 QDockWidget* LightApp_Application::windowDock( QWidget* wid ) const
1274 QDockWidget* dock = 0;
1275 QWidget* w = wid->parentWidget();
1276 while ( w && !dock )
1278 dock = ::qobject_cast<QDockWidget*>( w );
1279 w = w->parentWidget();
1284 void LightApp_Application::insertDockWindow( const int id, QWidget* wid )
1289 if ( wid != dockWindow( id ) )
1290 removeDockWindow( id );
1292 myWin.insert( id, wid );
1294 QtxDockWidget* dock = new QtxDockWidget( true, desktop() );
1295 connect( dock, SIGNAL( destroyed( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
1297 dock->setFeatures( QDockWidget::AllDockWidgetFeatures );
1298 dock->setObjectName( wid->objectName().isEmpty() ? QString( "window_%1" ).arg( id ) :
1299 QString( "%1Dock" ).arg( wid->objectName() ) );
1300 dock->setWidget( wid );
1301 dock->toggleViewAction()->setData( QVariant( wid->objectName() ) );
1302 connect( dock->toggleViewAction(), SIGNAL( triggered( bool ) ),
1303 this, SLOT( onDockWindowVisibilityChanged( bool ) ) );
1305 QKeySequence accel = wid->property( "shortcut" ).value<QKeySequence>();
1306 if ( !accel.isEmpty() )
1307 dock->toggleViewAction()->setShortcut( accel );
1312 void LightApp_Application::removeDockWindow( const int id )
1314 QWidget* wid = dockWindow( id );
1320 QDockWidget* dock = windowDock( wid );
1324 dock->setWidget( 0 );
1325 wid->setParent( 0 );
1326 wid->setVisible( false );
1330 void LightApp_Application::placeDockWindow( const int id, Qt::DockWidgetArea place )
1332 QDockWidget* dock = windowDock( dockWindow( id ) );
1333 if ( dock && desktop() ) {
1334 desktop()->addDockWidget( place, dock );
1335 QtxDockAction* a = qobject_cast<QtxDockAction*>( action( ViewWindowsId ) );
1336 if ( a ) a->update();
1342 \param flag - key for window
1343 Flag used how identificator of window in windows list.
1345 QWidget* LightApp_Application::getWindow( const int flag)
1347 QWidget* wid = dockWindow( flag );
1349 insertDockWindow( flag, wid = createWindow( flag ) );
1351 QMap<int, int> winMap;
1352 currentWindows( winMap );
1353 if ( winMap.contains( flag ) )
1354 placeDockWindow( flag, (Qt::DockWidgetArea)winMap[flag] );
1360 \return Object Browser
1362 SUIT_DataBrowser* LightApp_Application::objectBrowser()
1364 return qobject_cast<SUIT_DataBrowser*>( dockWindow( WT_ObjectBrowser ) );
1370 LogWindow* LightApp_Application::logWindow()
1372 return qobject_cast<LogWindow*>( dockWindow( WT_LogWindow ) );
1375 #ifndef DISABLE_PYCONSOLE
1377 This returns the python console integrated to the GUI. Depending
1378 when you request the python console, this function could return
1379 null. Then the optional parameter force (default to false) can be
1380 set to force the creation of the python console if it is not done
1382 \param force - if true, the pythonConsole is created if it does not exist yet
1383 \return Python Console
1385 PyConsole_Console* LightApp_Application::pythonConsole(const bool force)
1387 QWidget* wid = dockWindow( WT_PyConsole );
1388 if ( !wid && force==true) {
1389 wid = getWindow(WT_PyConsole);
1391 return qobject_cast<PyConsole_Console*>( wid );
1396 Updates object browser and maybe data models
1397 \param updateModels - if it is true, then data models are updated
1399 void LightApp_Application::updateObjectBrowser( const bool updateModels )
1401 // update existing data models
1404 const bool isAutoUpdate = objectBrowser() ? objectBrowser()->autoUpdate() : true;
1405 if ( objectBrowser() )
1406 objectBrowser()->setAutoUpdate( false );
1408 LightApp_Study* study = dynamic_cast<LightApp_Study*>(activeStudy());
1410 CAM_Study::ModelList dm_list;
1411 study->dataModels( dm_list );
1412 QListIterator<CAM_DataModel*> it( dm_list );
1413 while ( it.hasNext() ) {
1414 CAM_DataModel* camDM = it.next();
1415 if ( camDM && camDM->inherits( "LightApp_DataModel" ) )
1416 ((LightApp_DataModel*)camDM)->update();
1420 if( objectBrowser() )
1421 objectBrowser()->setAutoUpdate( isAutoUpdate );
1424 if ( objectBrowser() ) {
1425 objectBrowser()->updateGeometry();
1426 objectBrowser()->updateTree( 0, false );
1433 LightApp_Preferences* LightApp_Application::preferences() const
1435 return preferences( false );
1439 \return first view manager of some type
1440 \param vmType - type of view manager
1441 \param create - is it necessary to create view manager in case, when there is no manager of such type
1443 SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, const bool create )
1445 SUIT_ViewManager* aVM = viewManager( vmType );
1446 SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
1447 MESSAGE("vmType: " << vmType.toStdString() << " aVM: " << aVM << " anActiveVM: " << anActiveVM );
1448 if ( anActiveVM && anActiveVM->getType() == vmType )
1450 MESSAGE("aVM = anActiveVM");
1454 if ( aVM && !aVM->getDetached() && create )
1456 if ( !aVM->getActiveView() )
1458 MESSAGE("aVM->createView()");
1463 MESSAGE("desktop()->setActiveWindow: " << aVM->getActiveView());
1464 desktop()->setActiveWindow( aVM->getActiveView() );
1469 MESSAGE("aVM = createViewManager( vmType )");
1470 aVM = createViewManager( vmType );
1477 Creates view manager of some type
1478 \param vmType - type of view manager
1480 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, bool detached )
1482 SUIT_ResourceMgr* resMgr = resourceMgr();
1484 SUIT_ViewManager* viewMgr = 0;
1485 #ifndef DISABLE_GLVIEWER
1486 if( vmType == GLViewer_Viewer::Type() )
1488 viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() );
1489 new LightApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
1492 #ifndef DISABLE_PLOT2DVIEWER
1493 if( vmType == Plot2d_Viewer::Type() )
1495 viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
1497 #ifndef DISABLE_SALOMEOBJECT
1498 SPlot2d_Viewer* v = new SPlot2d_Viewer();
1500 new LightApp_Plot2dSelector( v, mySelMgr );
1502 vm = new Plot2d_Viewer();
1504 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1505 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
1508 Plot2d_ViewFrame* frame = wnd->getViewFrame();
1509 frame->setBackgroundColor( resMgr->colorValue( "Plot2d", "Background", frame->backgroundColor() ) );
1513 #ifndef DISABLE_QXGRAPHVIEWER
1514 if( vmType == QxScene_Viewer::Type() )
1516 viewMgr = new QxScene_ViewManager( activeStudy(), desktop() );
1517 QxScene_Viewer* vm = new QxScene_Viewer();
1518 viewMgr->setViewModel( vm );
1519 //QxScene_ViewWindow* wnd = dynamic_cast<QxScene_ViewWindow*>( viewMgr->getActiveView() );
1522 #ifndef DISABLE_GRAPHICSVIEW
1523 if( vmType == GraphicsView_Viewer::Type() )
1525 viewMgr = new GraphicsView_ViewManager( activeStudy(), desktop() );
1526 new LightApp_GVSelector( (GraphicsView_Viewer*)viewMgr->getViewModel(), mySelMgr );
1529 #ifndef DISABLE_PVVIEWER
1530 if( vmType == PVViewer_Viewer::Type() )
1532 if (( viewMgr = dynamic_cast<PVViewer_ViewManager*>( getViewManager( vmType, false )))) {
1533 viewMgr->getActiveView()->setFocus();
1536 viewMgr = new PVViewer_ViewManager( activeStudy(), desktop(), logWindow() );
1540 #ifndef DISABLE_PYVIEWER
1541 if( vmType == PyViewer_Viewer::Type() )
1543 viewMgr = new PyViewer_ViewManager( activeStudy(), desktop() );
1546 #ifndef DISABLE_OCCVIEWER
1547 if( vmType == OCCViewer_Viewer::Type() )
1549 viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
1550 OCCViewer_Viewer* vm;
1551 #ifndef DISABLE_SALOMEOBJECT
1552 vm = new SOCC_Viewer();
1554 vm = new OCCViewer_Viewer( true );
1556 vm->setBackground( OCCViewer_ViewFrame::TOP_LEFT,
1557 resMgr->backgroundValue( "OCCViewer", "xz_background", vm->background(OCCViewer_ViewFrame::TOP_LEFT) ) );
1558 vm->setBackground( OCCViewer_ViewFrame::TOP_RIGHT,
1559 resMgr->backgroundValue( "OCCViewer", "yz_background", vm->background(OCCViewer_ViewFrame::TOP_RIGHT) ) );
1560 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_LEFT,
1561 resMgr->backgroundValue( "OCCViewer", "xy_background", vm->background(OCCViewer_ViewFrame::BOTTOM_LEFT) ) );
1562 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_RIGHT,
1563 resMgr->backgroundValue( "OCCViewer", "background", vm->background(OCCViewer_ViewFrame::MAIN_VIEW) ) );
1565 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1566 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ));
1567 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1568 vm->setProjectionType( resMgr->integerValue( "OCCViewer", "projection_mode", vm->projectionType() ) );
1569 #if OCC_VERSION_LARGE > 0x06090000
1570 vm->setStereoType( resMgr->integerValue( "OCCViewer", "stereo_type", vm->stereoType() ) );
1571 vm->setAnaglyphFilter( resMgr->integerValue( "OCCViewer", "anaglyph_filter", vm->anaglyphFilter() ) );
1572 vm->setStereographicFocus( resMgr->integerValue( "OCCViewer", "focus_type", vm->stereographicFocusType() ),
1573 resMgr->doubleValue( "OCCViewer", "focus_value", vm->stereographicFocusValue() ));
1574 vm->setInterocularDistance( resMgr->integerValue( "OCCViewer", "iod_type", vm->interocularDistanceType() ),
1575 resMgr->doubleValue( "OCCViewer", "iod_value", vm->interocularDistanceValue() ));
1577 vm->setReverseStereo( resMgr->booleanValue( "OCCViewer", "reverse_stereo", vm->isReverseStereo() ) );
1578 vm->setVSync( resMgr->booleanValue( "OCCViewer", "enable_vsync", vm->isVSync() ) );
1579 vm->setQuadBufferSupport( resMgr->booleanValue( "OCCViewer", "enable_quad_buffer_support", vm->isQuadBufferSupport() ) );
1581 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1582 vm->enablePreselection( resMgr->booleanValue( "OCCViewer", "enable_preselection", vm->isPreselectionEnabled() ) );
1583 vm->enableSelection( resMgr->booleanValue( "OCCViewer", "enable_selection", vm->isSelectionEnabled() ) );
1584 vm->setClippingColor( resMgr->colorValue( "OCCViewer", "clipping_color", vm->clippingColor() ) );
1585 vm->setClippingTextureParams( resMgr->booleanValue( "OCCViewer", "clipping_use_default_texture", vm->isDefaultTextureUsed() ),
1586 resMgr->stringValue( "OCCViewer", "clipping_texture", vm->clippingTexture() ),
1587 resMgr->booleanValue( "OCCViewer", "clipping_modulate", vm->isTextureModulated() ),
1588 resMgr->doubleValue( "OCCViewer", "clipping_scale", vm->clippingTextureScale() ) );
1591 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1592 new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
1595 #ifndef DISABLE_VTKVIEWER
1596 #ifndef DISABLE_SALOMEOBJECT
1597 if ( vmType == SVTK_Viewer::Type() )
1599 if ( vmType == VTKViewer_Viewer::Type() )
1602 #ifndef DISABLE_SALOMEOBJECT
1603 viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
1604 SVTK_Viewer* vm = dynamic_cast<SVTK_Viewer*>( viewMgr->getViewModel() );
1607 vm->setProjectionMode( resMgr->integerValue( "VTKViewer", "projection_mode", vm->projectionMode() ) );
1608 vm->setStereoType( resMgr->integerValue( "VTKViewer", "stereo_type", vm->stereoType() ) );
1609 vm->setAnaglyphFilter( resMgr->integerValue( "VTKViewer", "anaglyph_filter", vm->anaglyphFilter() ) );
1610 vm->setQuadBufferSupport( resMgr->booleanValue( "VTKViewer", "enable_quad_buffer_support", vm->isQuadBufferSupport() ) );
1611 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1612 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1613 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ) );
1614 vm->setStaticTrihedronVisible( resMgr->booleanValue( "3DViewer", "show_static_trihedron", vm->isStaticTrihedronVisible() ) );
1615 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1616 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1617 vm->setPreSelectionMode(resMgr->integerValue( "VTKViewer", "preselection", vm->preSelectionMode() ) );
1618 vm->enableSelection( resMgr->booleanValue( "VTKViewer", "enable_selection", vm->isSelectionEnabled() ) );
1619 vm->setIncrementalSpeed( resMgr->integerValue( "VTKViewer", "speed_value", vm->incrementalSpeed() ),
1620 resMgr->integerValue( "VTKViewer", "speed_mode", vm->incrementalSpeedMode() ) );
1621 vm->setSpacemouseButtons( resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", vm->spacemouseBtn(1) ),
1622 resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", vm->spacemouseBtn(2) ),
1623 resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", vm->spacemouseBtn(3) ) );
1624 new LightApp_VTKSelector( vm, mySelMgr );
1627 viewMgr = new VTKViewer_ViewManager( activeStudy(), desktop() );
1628 VTKViewer_Viewer* vm = dynamic_cast<VTKViewer_Viewer*>( viewMgr->getViewModel() );
1630 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1638 viewMgr->setDetached(detached);
1639 addViewManager( viewMgr );
1640 SUIT_ViewWindow* viewWin = viewMgr->createViewWindow();
1642 if ( viewWin && desktop() ) {
1643 viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1644 viewWin->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1650 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, QWidget* w )
1652 SUIT_ResourceMgr* resMgr = resourceMgr();
1654 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
1656 new LightApp_WgViewModel( vmType, w ) );
1657 vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
1659 addViewManager( vm );
1660 SUIT_ViewWindow* vw = vm->createViewWindow();
1661 if ( vw && desktop() ) {
1662 vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1663 vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1666 if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
1667 myUserWmTypes << vmType;
1672 SUIT_ViewManager* LightApp_Application::createViewManager( SUIT_ViewModel* theModel )
1674 SUIT_ResourceMgr* resMgr = resourceMgr();
1676 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
1680 QString vmType = vm->getType();
1682 vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
1684 addViewManager( vm );
1685 SUIT_ViewWindow* vw = vm->createViewWindow();
1686 if ( vw && desktop() ) {
1687 vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1688 vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1691 if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
1692 myUserWmTypes << vmType;
1698 SLOT: Removes view manager from application
1700 void LightApp_Application::onCloseView( SUIT_ViewManager* theVM )
1702 removeViewManager( theVM );
1706 Protected SLOT: On study created.
1707 \param theStudy - just created study
1709 void LightApp_Application::onStudyCreated( SUIT_Study* theStudy )
1711 SUIT_DataObject* aRoot = 0;
1712 if ( theStudy && theStudy->root() )
1714 aRoot = theStudy->root();
1715 //aRoot->setName( tr( "DATA_MODELS" ) );
1718 getWindow( WT_ObjectBrowser );
1720 loadDockWindowsState();
1722 if ( objectBrowser() )
1723 objectBrowser()->setRoot( aRoot );
1725 activateModule( defaultModule() );
1727 if ( objectBrowser() )
1728 objectBrowser()->openLevels();
1730 #ifndef DISABLE_PYCONSOLE
1731 if( pythonConsole() )
1732 getPyInterp()->initStudy();
1737 Protected SLOT: On study opened.
1738 \param theStudy - just opened study
1740 void LightApp_Application::onStudyOpened( SUIT_Study* theStudy )
1742 SUIT_DataObject* aRoot = 0;
1743 if ( theStudy && theStudy->root() )
1745 aRoot = theStudy->root();
1749 getWindow( WT_ObjectBrowser );
1751 loadDockWindowsState();
1753 if ( objectBrowser() )
1754 objectBrowser()->setRoot( aRoot );
1756 activateModule( defaultModule() );
1758 if ( objectBrowser() )
1759 objectBrowser()->openLevels();
1761 #ifndef DISABLE_PYCONSOLE
1762 if( pythonConsole() )
1763 getPyInterp()->initStudy();
1769 /*!Protected SLOT. On study saved.*/
1770 void LightApp_Application::onStudySaved( SUIT_Study* s )
1772 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
1774 mru->insert( s->studyName() );
1779 /*!Protected SLOT. On study closed.*/
1780 void LightApp_Application::onStudyClosed( SUIT_Study* s )
1783 disconnect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
1784 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
1787 // stop auto-save timer
1788 myAutoSaveTimer->stop();
1790 // Bug 10396: clear selection
1791 mySelMgr->clearSelected();
1793 // Bug 12944: emit signal only after clear selection
1796 activateModule( "" );
1799 /*!Protected SLOT.On desktop activated.*/
1800 void LightApp_Application::onDesktopActivated()
1802 CAM_Application::onDesktopActivated();
1803 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>(activeModule());
1805 aModule->studyActivated();
1808 void LightApp_Application::studyOpened( SUIT_Study* s )
1810 CAM_Application::studyOpened( s );
1813 updateViewManagers();
1816 void LightApp_Application::studySaved( SUIT_Study* s )
1818 CAM_Application::studyOpened( s );
1819 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1820 if ( aResMgr && activeStudy() ) {
1821 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
1822 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
1826 void LightApp_Application::studyCreated( SUIT_Study* s )
1828 CAM_Application::studyCreated( s );
1831 updateViewManagers();
1834 /*!Gets file filter.
1835 *\retval QString "(*.hdf)"
1837 QString LightApp_Application::getFileFilter( bool /*open*/) const
1843 Shows file dialog and return user selected file name
1845 QString LightApp_Application::getFileName( bool open, const QString& initial, const QString& filters,
1846 const QString& caption, QWidget* parent )
1850 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1851 return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
1854 /*! Gets directory*/
1855 QString LightApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
1859 return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true );
1862 /*! Get open file names*/
1863 QStringList LightApp_Application::getOpenFileNames( const QString& initial, const QString& filters,
1864 const QString& caption, QWidget* parent )
1868 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1869 return SUIT_FileDlg::getOpenFileNames( parent, initial, fls, caption, true );
1872 /*!Private SLOT. Update object browser.*/
1873 void LightApp_Application::onRefresh()
1875 updateObjectBrowser( true );
1878 /*!Private SLOT. Update actions after rename object.*/
1879 void LightApp_Application::onRenamed()
1881 activeStudy()->Modified();
1885 // IMN 08.07.2015 : issue 002556: Some stereo outputs are affected by window position.
1886 // To prevent reversion the window should be either aligned during movement and resize.
1887 /*!Private SLOT. Update actions after rename object.*/
1888 /*void LightApp_Application::onMoved()
1890 OCCViewer_ViewManager* viewMgr = 0;
1891 viewMgr = dynamic_cast<OCCViewer_ViewManager*>( getViewManager( OCCViewer_Viewer::Type(), false ) );
1893 OCCViewer_ViewWindow* view = 0;
1894 view = dynamic_cast<OCCViewer_ViewWindow*>( viewMgr->getActiveView() );
1896 view->getViewPort()->repaintViewAfterMove();
1901 /*!Private SLOT. Support drag-and-drop operation.*/
1902 void LightApp_Application::onDropped( const QList<SUIT_DataObject*>& objects, SUIT_DataObject* parent, int row, Qt::DropAction action )
1904 LightApp_DataObject* parentObj = dynamic_cast<LightApp_DataObject*>( parent );
1908 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>( parentObj->module() );
1910 aModule->dropObjects( objects, parentObj, row, action );
1913 /*!Private SLOT. On preferences.*/
1914 void LightApp_Application::onPreferences()
1916 showPreferences( activeModule() ? activeModule()->moduleName() : tr( "PREF_CATEGORY_SALOME" ) );
1919 /*!Private SLOT. On preferences.*/
1920 void LightApp_Application::showPreferences( const QString& itemText )
1922 QApplication::setOverrideCursor( Qt::WaitCursor );
1924 LightApp_PreferencesDlg* prefDlg = new LightApp_PreferencesDlg( preferences( true ), desktop());
1926 QApplication::restoreOverrideCursor();
1931 preferences()->activateItem( itemText );
1933 if ( ( prefDlg->exec() == QDialog::Accepted || prefDlg->isSaved() ) && resourceMgr() )
1936 resourceMgr()->setValue( "desktop", "geometry", desktop()->storeGeometry() );
1937 resourceMgr()->save();
1940 shortcutMgr()->updateShortcuts();
1946 /*!Protected SLOT. On preferences changed.*/
1947 void LightApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param )
1949 LightApp_Module* sMod = 0;
1950 CAM_Module* mod = module( modName );
1951 if ( mod && mod->inherits( "LightApp_Module" ) )
1952 sMod = (LightApp_Module*)mod;
1955 sMod->preferencesChanged( section, param );
1957 preferencesChanged( section, param );
1958 // emit signal to allow additional preferences changing processing
1959 emit preferenceChanged( modName, section, param );
1962 /*!Remove all windows from study.*/
1963 void LightApp_Application::beforeCloseDoc( SUIT_Study* s )
1965 saveDockWindowsState();
1967 if ( SUIT_DataBrowser* ob = objectBrowser() )
1970 CAM_Application::beforeCloseDoc( s );
1973 /*!Update actions.*/
1974 void LightApp_Application::updateActions()
1976 updateCommandsStatus();
1982 SUIT_Study* LightApp_Application::createNewStudy()
1984 LightApp_Study* aStudy = new LightApp_Study( this );
1986 // Set up processing of major study-related events
1987 connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
1988 connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
1989 connect( aStudy, SIGNAL( saved ( SUIT_Study* ) ), this, SLOT( onStudySaved ( SUIT_Study* ) ) );
1990 connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
1996 Creates window by flag.
1997 \param flag - identificator of window type
1999 QWidget* LightApp_Application::createWindow( const int flag )
2003 SUIT_ResourceMgr* resMgr = resourceMgr();
2005 if ( flag == WT_ObjectBrowser )
2007 SUIT_DataBrowser* ob = new SUIT_DataBrowser( new LightApp_DataObject(), desktop() );
2008 ob->setObjectName( "objectBrowser" );
2009 ob->setSortMenuEnabled( true );
2010 ob->setAutoUpdate( true );
2011 if ( resMgr->hasValue( "ObjectBrowser", "auto_hide_search_tool" ) )
2012 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
2014 //ob->setAutoOpenLevel( 1 ); // commented by ASV as a fix to bug IPAL10107
2015 ob->setWindowTitle( tr( "OBJECT_BROWSER" ) );
2016 connect( ob, SIGNAL( requestUpdate() ), this, SLOT( onRefresh() ) );
2018 QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
2019 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
2020 treeModel->setSearcher( this );
2021 treeModel->registerColumn( 0, EntryCol, LightApp_DataObject::EntryId );
2022 treeModel->setAppropriate( EntryCol, Qtx::Toggled );
2024 // Mantis issue 0020136: Drag&Drop in OB
2025 SUIT_ProxyModel* proxyModel = dynamic_cast<SUIT_ProxyModel*>(treeModel);
2027 connect( proxyModel, SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
2028 this, SLOT( onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
2029 connect( proxyModel, SIGNAL( renamed( SUIT_DataObject* ) ),
2030 this, SLOT( onRenamed( ) ) );
2034 // temporary commented
2036 OB_ListView* ob_list = dynamic_cast<OB_ListView*>( const_cast<QListView*>( ob->listView() ) );
2038 ob_list->setColumnMaxWidth( 0, desktop()->width()/4 );
2041 // Create OBSelector
2042 new LightApp_OBSelector( ob, mySelMgr );
2043 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
2044 ob->treeView()->header()->setResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
2046 ob->treeView()->header()->setSectionResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
2048 ob->treeView()->header()->moveSection(SUIT_DataObject::NameId,SUIT_DataObject::VisibilityId);
2049 ob->treeView()->setColumnWidth(SUIT_DataObject::VisibilityId, VISIBILITY_COLUMN_WIDTH);
2050 ob->setProperty( "shortcut", QKeySequence( "Alt+Shift+O" ) );
2052 ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
2054 #ifndef DISABLE_PYCONSOLE
2055 else if ( flag == WT_PyConsole )
2057 PyConsole_Console* pyCons = new PyConsole_Console( desktop(), new LightApp_PyEditor( getPyInterp() ) );
2058 pyCons->setObjectName( "pythonConsole" );
2059 pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
2060 pyCons->setFont( resMgr->fontValue( "PyConsole", "font" ) );
2061 pyCons->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
2062 pyCons->setAutoCompletion( resMgr->booleanValue( "PyConsole", "auto_completion", true ) );
2063 pyCons->setProperty( "shortcut", QKeySequence( "Alt+Shift+P" ) );
2067 else if ( flag == WT_LogWindow )
2069 LogWindow* logWin = new LogWindow( desktop() );
2070 logWin->setObjectName( "logWindow" );
2071 logWin->setWindowTitle( tr( "LOG_WINDOW" ) );
2072 logWin->setProperty( "shortcut", QKeySequence( "Alt+Shift+L" ) );
2074 logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
2080 \return default windows( Object Browser, Python Console )
2081 Adds to map \a aMap.
2083 void LightApp_Application::defaultWindows( QMap<int, int>& aMap ) const
2085 #ifndef DISABLE_PYCONSOLE
2086 aMap.insert( WT_PyConsole, Qt::BottomDockWidgetArea );
2088 if ( activeStudy() ) {
2089 aMap.insert( WT_ObjectBrowser, Qt::LeftDockWidgetArea );
2090 // aMap.insert( WT_LogWindow, Qt::DockBottom );
2094 /*!Default view managers*/
2095 void LightApp_Application::defaultViewManagers( QStringList& ) const
2101 \return preferences.
2102 Create preferences, if \a crt = true.
2104 LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const
2109 LightApp_Application* that = (LightApp_Application*)this;
2111 bool toCreate = !_prefs_ && crt;
2114 _prefs_ = new LightApp_Preferences( resourceMgr() );
2115 that->createPreferences( _prefs_ );
2118 that->myPrefs = _prefs_;
2120 connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
2121 this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ), Qt::UniqueConnection );
2122 connect( myPrefs, SIGNAL( resetToDefaults() ),
2123 this, SIGNAL( preferenceResetToDefaults() ), Qt::UniqueConnection );
2128 SUIT_ResourceMgr* resMgr = resourceMgr();
2130 QList<SUIT_Application*> appList = SUIT_Session::session()->applications();
2131 for ( QList<SUIT_Application*>::iterator appIt = appList.begin(); appIt != appList.end(); ++appIt )
2133 LightApp_Application* app = ::qobject_cast<LightApp_Application*>( *appIt );
2137 QStringList modNameList;
2138 app->modules( modNameList, false );
2140 QMap<QString, QString> iconMap;
2141 app->moduleIconNames( iconMap );
2143 for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it )
2145 if ( !app->isModuleAccessible( *it ) || _prefs_->hasModule( *it ) )
2148 int modId = _prefs_->addPreference( *it );
2149 if ( iconMap.contains( *it ) )
2150 _prefs_->setItemIcon( modId, Qtx::scaleIcon( resMgr->loadPixmap( moduleName( *it ), iconMap[*it], false ), 20 ) );
2154 app->modules( modList );
2155 QListIterator<CAM_Module*> itr( modList );
2156 while ( itr.hasNext() )
2158 LightApp_Module* mod = 0;
2160 CAM_Module* anItem = itr.next();
2161 if ( anItem->inherits( "LightApp_Module" ) )
2162 mod = (LightApp_Module*)anItem;
2164 if ( mod && !_prefs_->hasModule( mod->moduleName() ) )
2166 _prefs_->addPreference( mod->moduleName() );
2167 mod->createPreferences();
2168 that->emptyPreferences( mod->moduleName() );
2172 _prefs_->setItemProperty( "info", tr( "PREFERENCES_NOT_LOADED" ) );
2178 Adds new module to application
2180 void LightApp_Application::moduleAdded( CAM_Module* mod )
2182 CAM_Application::moduleAdded( mod );
2184 LightApp_Module* lightMod = 0;
2185 if ( mod && mod->inherits( "LightApp_Module" ) )
2186 lightMod = (LightApp_Module*)mod;
2188 if ( myPrefs && lightMod && !myPrefs->hasModule( lightMod->moduleName() ))
2190 myPrefs->addPreference( mod->moduleName() );
2191 lightMod->createPreferences();
2192 emptyPreferences( mod->moduleName() );
2196 void LightApp_Application::emptyPreferences( const QString& modName )
2198 QtxPreferenceItem* item = myPrefs->findItem( modName, true );
2199 if ( !item || !item->isEmpty() )
2202 // printf( "---------------------> Modify for empty module.\n" );
2204 QtxPagePrefFrameItem* frm = new QtxPagePrefFrameItem( item->title(), item->parentItem() );
2205 frm->setIcon( item->icon() );
2206 frm->setStretch( false );
2207 item->parentItem()->insertItem( frm, item );
2208 new QtxPagePrefLabelItem( Qt::AlignCenter, tr( "PREFERENCES_NOT_SUPPORTED" ).arg( modName ), frm );
2215 void LightApp_Application::createPreferences( LightApp_Preferences* pref )
2220 QStringList aValuesList;
2221 QList<QVariant> anIndicesList;
2225 // . Top-level "SALOME" preferences group <<start>>
2226 int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
2227 pref->setItemIcon( salomeCat, Qtx::scaleIcon( resourceMgr()->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false ), 20 ) );
2229 // .. "General" preferences tab <<start>>
2230 int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat );
2232 // ... "Language" group <<start>>
2233 int langGroup = pref->addPreference( tr( "PREF_GROUP_LANGUAGE" ), genTab );
2234 pref->setItemProperty( "columns", 2, langGroup );
2235 // .... -> application language
2236 int curLang = pref->addPreference( tr( "PREF_CURRENT_LANGUAGE" ), langGroup,
2237 LightApp_Preferences::Selector, "language", "language" );
2238 QStringList aLangs = SUIT_Session::session()->resourceMgr()->stringValue( "language", "languages", "en" ).split( "," );
2239 QList<QVariant> aIcons;
2240 QList<QVariant> aNumbers;
2241 QStringList aTitles;
2242 foreach ( QString aLang, aLangs ) {
2243 aIcons << QPixmap( QString( ":/images/%1" ).arg( aLang ) );
2245 aTitles << langToName( aLang );
2247 pref->setItemProperty( "strings", aTitles, curLang );
2248 pref->setItemProperty( "ids", aNumbers, curLang );
2249 pref->setItemProperty( "icons", aIcons, curLang );
2250 pref->setItemProperty( "restart", true, curLang );
2252 int curLocale = pref->addPreference( tr( "PREF_CURRENT_LOCALE" ), langGroup,
2253 LightApp_Preferences::Bool, "language", "locale" );
2254 pref->setItemProperty( "restart", true, curLocale );
2255 // ... "Language" group <<end>>
2257 // ... "Look and feel" group <<start>>
2258 int lookGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), genTab );
2259 pref->setItemProperty( "columns", 2, lookGroup );
2260 // .... -> show splash-screen
2261 pref->addPreference( tr( "PREF_SHOW_SPLASH" ), lookGroup, LightApp_Preferences::Bool, "launch", "splash" );
2262 // .... -> opaque resize
2263 pref->addPreference( tr( "PREF_OPAQUE_RESIZE" ), lookGroup, LightApp_Preferences::Bool, "desktop", "opaque_resize" );
2264 // .... -> drop-down buttons
2265 pref->addPreference( tr( "PREF_DROP_DOWN_BUTTONS" ), lookGroup, LightApp_Preferences::Bool, "viewers", "drop_down_buttons" );
2266 // ... "Look and feel" group <<end>>
2268 // ... "Study properties" group <<start>>
2269 int studyGroup = pref->addPreference( tr( "PREF_GROUP_STUDY" ), genTab );
2270 pref->setItemProperty( "columns", 2, studyGroup );
2271 // .... -> multi-file save
2272 pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "multi_file" );
2273 // .... -> ascii save mode
2274 pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" );
2275 // .... -> store windows geometry
2276 pref->addPreference( tr( "PREF_LOAD_LIGHT" ), studyGroup, LightApp_Preferences::Bool, "Study", "autoload_light_modules" );
2277 pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" );
2278 pref->addPreference( "", studyGroup, LightApp_Preferences::Space );
2279 pref->addPreference( tr( "PREF_STORE_TOOL_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_tool_positions" );
2280 // .... -> auto-save
2281 int autoSaveInterval = pref->addPreference( tr( "PREF_AUTO_SAVE" ), studyGroup,
2282 LightApp_Preferences::IntSpin, "Study", "auto_save_interval" );
2283 pref->setItemProperty( "min", 0, autoSaveInterval );
2284 pref->setItemProperty( "max", 1440, autoSaveInterval );
2285 pref->setItemProperty( "special", tr( "PREF_AUTO_SAVE_DISABLED" ), autoSaveInterval );
2286 // ... "Study properties" group <<end>>
2288 // ... "Help browser" group <<start>>
2289 #ifndef DISABLE_QTXWEBBROWSER
2290 int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab, LightApp_Preferences::Auto, "ExternalBrowser", "use_external_browser");
2292 int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab );
2296 QString platform = "winapplication";
2298 QString platform = "application";
2300 // .... -> browser application
2301 int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, LightApp_Preferences::File, "ExternalBrowser", platform );
2302 pref->setItemProperty( "mode", Qtx::PT_OpenFile, apppref );
2303 // .... -> browser parameters
2304 pref->addPreference( tr( "PREF_PARAM" ), extgroup, LightApp_Preferences::String, "ExternalBrowser", "parameters" );
2305 // ... "Help browser" group <<end>>
2307 // ... "Python console properties" group <<start>>
2308 int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab );
2309 pref->setItemProperty( "columns", 2, pythonConsoleGroup );
2311 pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, LightApp_Preferences::Font, "PyConsole", "font" );
2312 // .... -> show banner
2313 pref->addPreference( tr( "PREF_SHOW_BANNER" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "show_banner" );
2314 // .... -> auto-completion
2315 pref->addPreference( tr( "PREF_AUTO_COMPLETION" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "auto_completion" );
2316 // ... "Python console properties" group <<end>>
2318 // ... "MRU" preferences group <<start>>
2319 int mruGroup = pref->addPreference( tr( "PREF_GROUP_MRU" ), genTab, LightApp_Preferences::Auto, "MRU", "show_mru" );
2320 pref->setItemProperty( "columns", 4, mruGroup );
2321 // number of MRU items
2322 int mruVisCount = pref->addPreference( tr( "PREF_MRU_VISIBLE_COUNT" ), mruGroup, LightApp_Preferences::IntSpin,
2323 "MRU", "visible_count" );
2324 pref->setItemProperty( "min", 0, mruVisCount );
2325 pref->setItemProperty( "max", 100, mruVisCount );
2327 int mruLinkType = pref->addPreference( tr( "PREF_MRU_LINK_TYPE" ), mruGroup, LightApp_Preferences::Selector,
2328 "MRU", "link_type" );
2329 aValuesList.clear();
2330 anIndicesList.clear();
2331 aValuesList << tr("PREF_MRU_LINK_AUTO") << tr("PREF_MRU_LINK_SHORT") << tr("PREF_MRU_LINK_FULL");
2332 anIndicesList << 0 << 1 << 2 ;
2333 pref->setItemProperty( "strings", aValuesList, mruLinkType );
2334 pref->setItemProperty( "indexes", anIndicesList, mruLinkType );
2335 // ... "MRU" preferences group <<end>>
2337 // ... "Full-screen" group <<start>>
2338 int fullScreenGroup = pref->addPreference( tr( "PREF_GROUP_FULL_SCREEN" ), genTab );
2339 pref->setItemProperty( "columns", 2, fullScreenGroup );
2340 // .... -> automatic hiding toolbars
2341 pref->addPreference( tr( "PREF_FULL_SCREEN_AUTO" ), fullScreenGroup,
2342 LightApp_Preferences::Bool, "OCCViewer", "automatic_hiding" );
2343 // ... "Full-screen" group <<end>>
2345 // .. "General" preferences tab <<end>>
2347 // .. "3D viewer" group <<start>>
2348 int Viewer3DGroup = pref->addPreference( tr( "PREF_GROUP_3DVIEWER" ), salomeCat );
2349 // ... -> navigation mode
2350 int vtkStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), Viewer3DGroup,
2351 LightApp_Preferences::Selector, "3DViewer", "navigation_mode" );
2352 aValuesList.clear();
2353 anIndicesList.clear();
2354 aValuesList << tr("PREF_STANDARD_STYLE") << tr("PREF_KEYFREE_STYLE");
2355 anIndicesList << 0 << 1;
2356 pref->setItemProperty( "strings", aValuesList, vtkStyleMode );
2357 pref->setItemProperty( "indexes", anIndicesList, vtkStyleMode );
2358 // ... -> zooming mode
2359 int occZoomingStyleMode = pref->addPreference( tr( "PREF_ZOOMING" ), Viewer3DGroup,
2360 LightApp_Preferences::Selector, "3DViewer", "zooming_mode" );
2361 aValuesList.clear();
2362 anIndicesList.clear();
2363 aValuesList << tr("PREF_ZOOMING_AT_CENTER") << tr("PREF_ZOOMING_AT_CURSOR");
2364 anIndicesList << 0 << 1;
2365 pref->setItemProperty( "strings", aValuesList, occZoomingStyleMode );
2366 pref->setItemProperty( "indexes", anIndicesList, occZoomingStyleMode );
2367 // ... "Trihedron" group <<start>>
2368 int occTriGroup = pref->addPreference( tr( "PREF_TRIHEDRON" ), Viewer3DGroup );
2369 pref->setItemProperty( "columns", 2, occTriGroup );
2370 // .... -> trihedron size
2371 int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occTriGroup,
2372 LightApp_Preferences::DblSpin, "3DViewer", "trihedron_size" );
2373 pref->setItemProperty( "min", 1.0E-06, occTS );
2374 pref->setItemProperty( "max", 1000, occTS );
2375 // .... -> relative size of trihedron
2376 pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "relative_size" );
2377 // .... -> show static trihedron
2378 pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "show_static_trihedron" );
2379 // ... "Trihedron" group <<end>>
2380 // .. "3D viewer" group <<end>>
2384 #ifndef DISABLE_OCCVIEWER
2385 // .. "OCC viewer" group <<start>>
2386 int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), salomeCat );
2388 // .... -> Projection mode
2389 int occProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), occGroup,
2390 LightApp_Preferences::Selector, "OCCViewer", "projection_mode" );
2391 aValuesList.clear();
2392 anIndicesList.clear();
2393 aValuesList << tr("PREF_ORTHOGRAPHIC") << tr("PREF_PERSPECTIVE");
2394 anIndicesList << 0 << 1;
2395 pref->setItemProperty( "strings", aValuesList, occProjMode );
2396 pref->setItemProperty( "indexes", anIndicesList, occProjMode );
2397 #if OCC_VERSION_LARGE > 0x06090000
2398 // .... -> Stereo group
2399 int stereoGroup = pref->addPreference( tr( "PREF_GROUP_STEREO" ), occGroup);
2400 pref->setItemProperty( "columns", 2, stereoGroup );
2401 // .... -> Stereo type
2402 int stereoType = pref->addPreference( tr( "PREF_STEREO_TYPE" ), stereoGroup,
2403 LightApp_Preferences::Selector, "OCCViewer", "stereo_type" );
2404 aValuesList.clear();
2405 anIndicesList.clear();
2407 OCCViewer_Viewer::stereoData( aValuesList, idList);
2408 foreach( int gid, idList ) anIndicesList << gid;
2409 pref->setItemProperty( "strings", aValuesList, stereoType );
2410 pref->setItemProperty( "indexes", anIndicesList, stereoType );
2412 // .... -> Anaglyph filter
2413 int anaglyphFilter = pref->addPreference( tr( "PREF_ANAGLYPH_FILTER" ), stereoGroup,
2414 LightApp_Preferences::Selector, "OCCViewer", "anaglyph_filter" );
2415 aValuesList.clear();
2416 anIndicesList.clear();
2417 aValuesList << tr("PREF_ANAGLYPH_RED_CYAN") << tr("PREF_ANAGLYPH_YELLOW_BLUE") << tr("PREF_ANAGLYPH_GREEN_MAGENTA");
2418 anIndicesList << 0 << 1 << 2;
2420 pref->setItemProperty( "strings", aValuesList, anaglyphFilter );
2421 pref->setItemProperty( "indexes", anIndicesList, anaglyphFilter );
2423 // .... -> Convergence distance type
2424 int occFocusType = pref->addPreference( tr( "PREF_FOCUS_TYPE" ), stereoGroup,
2425 LightApp_Preferences::Selector, "OCCViewer", "focus_type" );
2426 aValuesList.clear();
2427 anIndicesList.clear();
2428 aValuesList << tr("PREF_ABSOLUTE") << tr("PREF_RELATIVE");
2429 anIndicesList << 0 << 1;
2430 pref->setItemProperty( "strings", aValuesList, occFocusType );
2431 pref->setItemProperty( "indexes", anIndicesList, occFocusType );
2433 // .... -> Stereographic focus value
2434 int focusValue = pref->addPreference( tr( "PREF_FOCUS_VALUE" ), stereoGroup,
2435 LightApp_Preferences::DblSpin, "OCCViewer", "focus_value" );
2436 pref->setItemProperty( "precision", 3, focusValue );
2437 pref->setItemProperty( "min", 1.0E-03, focusValue );
2438 pref->setItemProperty( "max", 1.0E03, focusValue );
2439 pref->setItemProperty( "step", 0.05, focusValue );
2442 int occIODType = pref->addPreference( tr( "PREF_IOD_TYPE" ), stereoGroup,
2443 LightApp_Preferences::Selector, "OCCViewer", "iod_type" );
2444 aValuesList.clear();
2445 anIndicesList.clear();
2446 aValuesList << tr("PREF_ABSOLUTE") << tr("PREF_RELATIVE");
2447 anIndicesList << 0 << 1;
2448 pref->setItemProperty( "strings", aValuesList, occIODType );
2449 pref->setItemProperty( "indexes", anIndicesList, occIODType );
2451 // .... -> Interocular distance (IOD) value
2452 int IODValue = pref->addPreference( tr( "PREF_IOD_VALUE" ), stereoGroup,
2453 LightApp_Preferences::DblSpin, "OCCViewer", "iod_value" );
2454 pref->setItemProperty( "precision", 3, IODValue );
2455 pref->setItemProperty( "min", 1.0E-03, IODValue );
2456 pref->setItemProperty( "max", 1.0E03, IODValue );
2457 pref->setItemProperty( "step", 0.05, IODValue );
2459 // .... -> Reverse stereo
2460 pref->addPreference( tr( "PREF_REVERSE_STEREO" ), stereoGroup,
2461 LightApp_Preferences::Bool, "OCCViewer", "reverse_stereo" );
2462 // .... -> Enable V-Sync
2463 pref->addPreference( tr( "PREF_ENABLE_VSYNC" ), stereoGroup,
2464 LightApp_Preferences::Bool, "OCCViewer", "enable_vsync" );
2465 // .... -> Enable quad-buffer support
2466 pref->addPreference( tr( "PREF_ENABLE_QUAD_BUFFER_SUPPORT" ), stereoGroup,
2467 LightApp_Preferences::Bool, "OCCViewer", "enable_quad_buffer_support" );
2469 // ... "Background" group <<start>>
2470 int bgGroup = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup );
2471 // pref->setItemProperty( "columns", 2, bgGroup );
2472 aValuesList.clear();
2473 anIndicesList.clear();
2476 formats = OCCViewer_Viewer::backgroundData( aValuesList, idList, txtList );
2477 foreach( int gid, idList ) anIndicesList << gid;
2478 // .... -> 3D viewer background
2479 bgId = pref->addPreference( tr( "PREF_3DVIEWER_BACKGROUND" ), bgGroup,
2480 LightApp_Preferences::Background, "OCCViewer", "background" );
2481 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2482 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2483 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2484 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2485 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2486 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2487 pref->setItemProperty( "custom_enabled", false, bgId );
2488 pref->setItemProperty( "image_formats", formats, bgId );
2489 // .... -> XZ viewer background
2490 bgId = pref->addPreference( tr( "PREF_XZVIEWER_BACKGROUND" ), bgGroup,
2491 LightApp_Preferences::Background, "OCCViewer", "xz_background" );
2492 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2493 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2494 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2495 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2496 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2497 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2498 pref->setItemProperty( "custom_enabled", false, bgId );
2499 pref->setItemProperty( "image_formats", formats, bgId );
2500 // .... -> YZ viewer background
2501 bgId = pref->addPreference( tr( "PREF_YZVIEWER_BACKGROUND" ), bgGroup,
2502 LightApp_Preferences::Background, "OCCViewer", "yz_background" );
2503 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2504 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2505 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2506 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2507 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2508 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2509 pref->setItemProperty( "custom_enabled", false, bgId );
2510 pref->setItemProperty( "image_formats", formats, bgId );
2511 // .... -> XY viewer background
2512 bgId = pref->addPreference( tr( "PREF_XYVIEWER_BACKGROUND" ), bgGroup,
2513 LightApp_Preferences::Background, "OCCViewer", "xy_background" );
2514 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2515 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2516 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2517 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2518 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2519 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2520 pref->setItemProperty( "custom_enabled", false, bgId );
2521 pref->setItemProperty( "image_formats", formats, bgId );
2522 // ... "Background" group <<end>>
2525 // ... "Selection" group <<start>>
2526 int occSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), occGroup );
2527 pref->setItemProperty( "columns", 2, occSelectionGroup );
2528 // .... -> enable preselection
2529 pref->addPreference( tr( "PREF_ENABLE_PRESELECTION" ), occSelectionGroup,
2530 LightApp_Preferences::Bool, "OCCViewer", "enable_preselection" );
2531 // .... -> enable selection
2532 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), occSelectionGroup,
2533 LightApp_Preferences::Bool, "OCCViewer", "enable_selection" );
2534 // ... "Selection" group <<end>>
2536 // ... "Clipping" group <<start>>
2537 int occClippingGroup = pref->addPreference( tr( "PREF_GROUP_CLIPPING" ), occGroup );
2538 // .... -> clipping color
2539 pref->addPreference( tr( "PREF_CLIPPING_COLOR" ), occClippingGroup,
2540 LightApp_Preferences::Color, "OCCViewer", "clipping_color" );
2541 int texturePref = pref->addPreference( "", occClippingGroup, LightApp_Preferences::Frame );
2542 pref->setItemProperty( "columns", 2, texturePref );
2543 // .... -> use default texture
2544 pref->addPreference( tr( "PREF_CLIPPING_DEFAULT_TEXTURE" ), texturePref,
2545 LightApp_Preferences::Bool, "OCCViewer", "clipping_use_default_texture" );
2546 // .... -> clipping texture
2547 int filePref = pref->addPreference( tr( "PREF_CLIPPING_TEXTURE" ), texturePref,
2548 LightApp_Preferences::File, "OCCViewer", "clipping_texture" );
2549 pref->setItemProperty( "path_filter", tr( "OCC_TEXTURE_FILES" ), filePref );
2551 pref->addPreference( tr( "PREF_CLIPPING_MODULATE" ), texturePref,
2552 LightApp_Preferences::Bool, "OCCViewer", "clipping_modulate" );
2553 // .... -> scale factor
2554 int scaleFactor = pref->addPreference( tr( "PREF_CLIPPING_SCALE" ), texturePref,
2555 LightApp_Preferences::DblSpin, "OCCViewer", "clipping_scale" );
2556 pref->setItemProperty( "precision", 3, scaleFactor );
2557 pref->setItemProperty( "min", 1.0E-03, scaleFactor );
2558 pref->setItemProperty( "max", 1.0E03, scaleFactor );
2559 pref->setItemProperty( "step", 0.1, scaleFactor );
2560 // ... "Clipping" group <<end>>
2562 // ... "Ray tracing" group <<start>>
2563 int occRayTracingGroup = pref->addPreference( tr( "PREF_GROUP_RAY_TRACING" ), occGroup );
2564 int rtPref = pref->addPreference( "", occRayTracingGroup, LightApp_Preferences::Frame );
2565 pref->setItemProperty( "columns", 2, rtPref );
2567 int rt_depth = pref->addPreference( tr( "PREF_RAY_TRACING_DEPTH" ), rtPref,
2568 LightApp_Preferences::IntSpin, "OCCViewer", "rt_depth" );
2569 pref->setItemProperty( "min", 1, rt_depth );
2570 pref->setItemProperty( "max", 10, rt_depth );
2571 pref->setItemProperty( "step", 1, rt_depth );
2572 pref->addPreference( "", rtPref, LightApp_Preferences::Frame );
2573 // .... -> specular reflections
2574 pref->addPreference( tr( "PREF_RAY_TRACING_REFLECTION" ), rtPref,
2575 LightApp_Preferences::Bool, "OCCViewer", "rt_reflection" );
2576 // .... -> adaptive anti-aliasing
2577 pref->addPreference( tr( "PREF_RAY_TRACING_ANTIALIASING" ), rtPref,
2578 LightApp_Preferences::Bool, "OCCViewer", "rt_antialiasing" );
2579 // .... -> shadows rendering
2580 pref->addPreference( tr( "PREF_RAY_TRACING_SHADOW" ), rtPref,
2581 LightApp_Preferences::Bool, "OCCViewer", "rt_shadow" );
2582 // .... -> transparent shadow
2583 pref->addPreference( tr( "PREF_RAY_TRACING_TRANS_SHADOW" ), rtPref,
2584 LightApp_Preferences::Bool, "OCCViewer", "rt_trans_shadow" );
2585 // ... "Ray tracing" group <<end>>
2587 // ... "Light source" group <<start>>
2588 int occLightGroup = pref->addPreference( tr( "PREF_GROUP_LIGHT" ), occGroup );
2589 // .... -> light color
2590 pref->addPreference( tr( "PREF_LIGHT_COLOR" ), occLightGroup,
2591 LightApp_Preferences::Color, "OCCViewer", "light_color" );
2592 int directionPref = pref->addPreference( "", occLightGroup, LightApp_Preferences::Frame );
2593 pref->setItemProperty( "columns", 3, directionPref );
2594 // .... -> light direction (dx component)
2595 int light_dx = pref->addPreference( tr( "Dx" ), directionPref,
2596 LightApp_Preferences::DblSpin, "OCCViewer", "light_dx" );
2597 pref->setItemProperty( "precision", 2, light_dx );
2598 pref->setItemProperty( "min", -1.0E03, light_dx );
2599 pref->setItemProperty( "max", 1.0E03, light_dx );
2600 pref->setItemProperty( "step", 0.1, light_dx );
2601 // .... -> light direction (dy component)
2602 int light_dy = pref->addPreference( tr( "Dy" ), directionPref,
2603 LightApp_Preferences::DblSpin, "OCCViewer", "light_dy" );
2604 pref->setItemProperty( "precision", 2, light_dy );
2605 pref->setItemProperty( "min", -1.0E03, light_dy );
2606 pref->setItemProperty( "max", 1.0E03, light_dy );
2607 pref->setItemProperty( "step", 0.1, light_dy );
2608 // .... -> light direction (dz component)
2609 int light_dz = pref->addPreference( tr( "Dz" ), directionPref,
2610 LightApp_Preferences::DblSpin, "OCCViewer", "light_dz" );
2611 pref->setItemProperty( "precision", 2, light_dz );
2612 pref->setItemProperty( "min", -1.0E03, light_dz );
2613 pref->setItemProperty( "max", 1.0E03, light_dz );
2614 pref->setItemProperty( "step", 0.1, light_dz );
2615 // ... "Light source" group <<end>>
2617 // ... -> empty frame (for layout) <<start>>
2618 int occGen = pref->addPreference( "", occGroup, LightApp_Preferences::Frame );
2619 pref->setItemProperty( "margin", 0, occGen );
2620 pref->setItemProperty( "columns", 2, occGen );
2621 // ... -> empty frame (for layout) <<end>>
2623 // .. "OCC viewer" group <<end>>
2626 #ifndef DISABLE_VTKVIEWER
2627 // .. "VTK viewer" group <<start>>
2628 int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), salomeCat ); //viewTab
2630 // ... -> empty frame (for layout) <<start>>
2631 int vtkGen = pref->addPreference( "", vtkGroup, LightApp_Preferences::Frame );
2632 //pref->setItemProperty( "columns", 2, vtkGen );
2633 // .... -> projection mode
2634 int vtkProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), vtkGen,
2635 LightApp_Preferences::Selector, "VTKViewer", "projection_mode" );
2636 aValuesList.clear();
2637 anIndicesList.clear();
2638 aValuesList << tr("PREF_ORTHOGRAPHIC") << tr("PREF_PERSPECTIVE");
2639 anIndicesList << 0 << 1;
2640 pref->setItemProperty( "strings", aValuesList, vtkProjMode );
2641 pref->setItemProperty( "indexes", anIndicesList, vtkProjMode );
2643 // .... -> Stereo group
2644 int vtkStereoGroup = pref->addPreference( tr( "PREF_GROUP_STEREO" ), vtkGroup);
2645 pref->setItemProperty( "columns", 2, vtkStereoGroup );
2646 // .... -> Stereo type
2647 int vtkStereoType = pref->addPreference( tr( "PREF_STEREO_TYPE" ), vtkStereoGroup,
2648 LightApp_Preferences::Selector, "VTKViewer", "stereo_type" );
2649 aValuesList.clear();
2650 anIndicesList.clear();
2652 SVTK_Viewer::stereoData( aValuesList, idList);
2653 foreach( int gid, idList ) anIndicesList << gid;
2654 pref->setItemProperty( "strings", aValuesList, vtkStereoType );
2655 pref->setItemProperty( "indexes", anIndicesList, vtkStereoType );
2656 // .... -> Anaglyph filter
2657 int vtkAnaglyphFilter = pref->addPreference( tr( "PREF_ANAGLYPH_FILTER" ), vtkStereoGroup,
2658 LightApp_Preferences::Selector, "VTKViewer", "anaglyph_filter" );
2659 aValuesList.clear();
2660 anIndicesList.clear();
2661 aValuesList << tr("PREF_ANAGLYPH_RED_CYAN") << tr("PREF_ANAGLYPH_YELLOW_BLUE") << tr("PREF_ANAGLYPH_GREEN_MAGENTA");
2662 anIndicesList << 0 << 1 << 2;
2664 pref->setItemProperty( "strings", aValuesList, vtkAnaglyphFilter );
2665 pref->setItemProperty( "indexes", anIndicesList, vtkAnaglyphFilter );
2667 // .... -> Enable quad-buffer support
2668 pref->addPreference( tr( "PREF_ENABLE_QUAD_BUFFER_SUPPORT" ), vtkStereoGroup,
2669 LightApp_Preferences::Bool, "VTKViewer", "enable_quad_buffer_support" );
2671 // .... -> background
2672 aValuesList.clear();
2673 anIndicesList.clear();
2676 #ifndef DISABLE_SALOMEOBJECT
2677 formats = SVTK_Viewer::backgroundData( aValuesList, idList, txtList );
2679 foreach( int gid, idList ) anIndicesList << gid;
2680 bgId = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGen,
2681 LightApp_Preferences::Background, "VTKViewer", "background" );
2682 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2683 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2684 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2685 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2686 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2687 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2688 pref->setItemProperty( "custom_enabled", false, bgId );
2689 #ifndef DISABLE_SALOMEOBJECT
2690 pref->setItemProperty( "image_formats", formats, bgId );
2692 // .... -> speed increment
2693 int vtkSpeed = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED" ), vtkGen,
2694 LightApp_Preferences::IntSpin, "VTKViewer", "speed_value" );
2695 pref->setItemProperty( "min", 1, vtkSpeed );
2696 pref->setItemProperty( "max", 1000, vtkSpeed );
2697 // .... -> speed mode
2698 int vtkSpeedMode = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED_MODE" ), vtkGen,
2699 LightApp_Preferences::Selector, "VTKViewer", "speed_mode" );
2700 aValuesList.clear();
2701 anIndicesList.clear();
2702 aValuesList << tr("PREF_ARITHMETIC") << tr("PREF_GEOMETRICAL");
2703 anIndicesList << 0 << 1;
2704 pref->setItemProperty( "strings", aValuesList, vtkSpeedMode );
2705 pref->setItemProperty( "indexes", anIndicesList, vtkSpeedMode );
2707 // ... "Selection" group <<start>>
2708 int vtkSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), vtkGroup );
2709 pref->setItemProperty( "columns", 2, vtkSelectionGroup );
2710 // .... -> preselection
2711 int vtkPreselection = pref->addPreference( tr( "PREF_PRESELECTION" ), vtkSelectionGroup,
2712 LightApp_Preferences::Selector, "VTKViewer", "preselection" );
2713 aValuesList.clear();
2714 anIndicesList.clear();
2715 aValuesList << tr("PREF_PRESELECTION_STANDARD") << tr("PREF_PRESELECTION_DYNAMIC") << tr("PREF_PRESELECTION_DISABLED");
2716 anIndicesList << 0 << 1 << 2;
2717 pref->setItemProperty( "strings", aValuesList, vtkPreselection );
2718 pref->setItemProperty( "indexes", anIndicesList, vtkPreselection );
2719 // .... -> enable selection
2720 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), vtkSelectionGroup, LightApp_Preferences::Bool, "VTKViewer", "enable_selection" );
2721 // ... "Selection" group <<end>>
2723 // ... -> empty frame (for layout) <<end>>
2725 // ... space mouse sub-group <<start>>
2726 int vtkSM = pref->addPreference( tr( "PREF_FRAME_SPACEMOUSE" ), vtkGroup, LightApp_Preferences::GroupBox );
2727 //pref->setItemProperty( "columns", 2, vtkSM );
2728 // .... -> decrease speed increment
2729 int spacemousePref1 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_1" ), vtkSM,
2730 LightApp_Preferences::Selector, "VTKViewer",
2731 "spacemouse_func1_btn" );
2732 // .... -> increase speed increment
2733 int spacemousePref2 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_2" ), vtkSM,
2734 LightApp_Preferences::Selector, "VTKViewer",
2735 "spacemouse_func2_btn" );
2736 // .... -> dominant / combined switch
2737 int spacemousePref3 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_3" ), vtkSM,
2738 LightApp_Preferences::Selector, "VTKViewer",
2739 "spacemouse_func5_btn" ); //
2740 aValuesList.clear();
2741 anIndicesList.clear();
2742 aValuesList << tr( "PREF_SPACEMOUSE_BTN_1" ) << tr( "PREF_SPACEMOUSE_BTN_2" ) << tr( "PREF_SPACEMOUSE_BTN_3" );
2743 aValuesList << tr( "PREF_SPACEMOUSE_BTN_4" ) << tr( "PREF_SPACEMOUSE_BTN_5" ) << tr( "PREF_SPACEMOUSE_BTN_6" );
2744 aValuesList << tr( "PREF_SPACEMOUSE_BTN_7" ) << tr( "PREF_SPACEMOUSE_BTN_8" ) << tr( "PREF_SPACEMOUSE_BTN_*" );
2745 aValuesList << tr( "PREF_SPACEMOUSE_BTN_10" ) << tr( "PREF_SPACEMOUSE_BTN_11" );
2746 anIndicesList << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11;
2747 pref->setItemProperty( "strings", aValuesList, spacemousePref1 );
2748 pref->setItemProperty( "indexes", anIndicesList, spacemousePref1 );
2749 pref->setItemProperty( "strings", aValuesList, spacemousePref2 );
2750 pref->setItemProperty( "indexes", anIndicesList, spacemousePref2 );
2751 pref->setItemProperty( "strings", aValuesList, spacemousePref3 );
2752 pref->setItemProperty( "indexes", anIndicesList, spacemousePref3 );
2753 // ... space mouse sub-group <<end>>
2755 // ... avi recording sub-group <<start>>
2756 int vtkRec = pref->addPreference( tr( "PREF_FRAME_RECORDING" ), vtkGroup, LightApp_Preferences::GroupBox );
2757 pref->setItemProperty( "columns", 2, vtkRec );
2758 // .... -> recording mode
2759 int modePref = pref->addPreference( tr( "PREF_RECORDING_MODE" ), vtkRec,
2760 LightApp_Preferences::Selector, "VTKViewer", "recorder_mode" );
2761 aValuesList.clear();
2762 anIndicesList.clear();
2763 aValuesList << tr( "PREF_SKIPPED_FRAMES" ) << tr( "PREF_ALL_DISLPAYED_FRAMES" );
2764 anIndicesList << 0 << 1;
2765 pref->setItemProperty( "strings", aValuesList, modePref );
2766 pref->setItemProperty( "indexes", anIndicesList, modePref );
2768 int fpsPref = pref->addPreference( tr( "PREF_FPS" ), vtkRec,
2769 LightApp_Preferences::DblSpin, "VTKViewer", "recorder_fps" );
2770 pref->setItemProperty( "min", 0.1, fpsPref );
2771 pref->setItemProperty( "max", 100, fpsPref );
2773 int qualityPref = pref->addPreference( tr( "PREF_QUALITY" ), vtkRec,
2774 LightApp_Preferences::IntSpin, "VTKViewer", "recorder_quality" );
2775 pref->setItemProperty( "min", 1, qualityPref );
2776 pref->setItemProperty( "max", 100, qualityPref );
2777 // .... -> progressive mode
2778 pref->addPreference( tr( "PREF_PROGRESSIVE" ), vtkRec,
2779 LightApp_Preferences::Bool, "VTKViewer", "recorder_progressive" );
2780 // ... avi recording sub-group <<end>>
2782 // ... group names sub-group <<start>>
2783 int vtkGN = pref->addPreference( tr( "PREF_FRAME_GROUP_NAMES" ), vtkGroup,
2784 LightApp_Preferences::GroupBox, "VTKViewer", "show_group_names" );
2785 pref->setItemProperty( "columns", 2, vtkGN );
2786 // .... -> text color
2787 pref->addPreference( tr( "PREF_GROUP_NAMES_TEXT_COLOR" ), vtkGN,
2788 LightApp_Preferences::Color, "VTKViewer", "group_names_text_color" );
2789 // .... -> transparency
2790 int transPref = pref->addPreference( tr( "PREF_GROUP_NAMES_TRANSPARENCY" ), vtkGN,
2791 LightApp_Preferences::DblSpin, "VTKViewer", "group_names_transparency" );
2792 pref->setItemProperty( "min", 0.0, transPref );
2793 pref->setItemProperty( "max", 1.0, transPref );
2794 pref->setItemProperty( "step", 0.1, transPref );
2795 // ... -> group names sub-group <<end>>
2796 // .. "VTK viewer" group <<end>>
2799 // .. "Plot2d viewer" group <<start>>
2800 int plot2dGroup = pref->addPreference( tr( "PREF_GROUP_PLOT2DVIEWER" ), salomeCat ); //viewTab
2801 //pref->setItemProperty( "columns", 2, plot2dGroup );
2803 // ... -> background
2804 pref->addPreference( tr( "PREF_VIEWER_BACKGROUND_COLOR" ), plot2dGroup,
2805 LightApp_Preferences::Color, "Plot2d", "Background" );
2806 // ... -> selection color
2807 pref->addPreference( tr( "PREF_VIEWER_SELECTION" ), plot2dGroup,
2808 LightApp_Preferences::Color, "Plot2d", "SelectionColor" );
2810 // ... "Viewer" group <<start>>
2811 int plot2dViewerGroup = pref->addPreference( tr( "PREF_GROUP_VIEWER" ), plot2dGroup );
2813 // .... -> curve type
2814 int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dViewerGroup,
2815 LightApp_Preferences::Selector, "Plot2d", "CurveType" );
2816 aValuesList.clear();
2817 anIndicesList.clear();
2818 aValuesList << tr("PREF_POINTS") << tr("PREF_LINES") << tr("PREF_SPLINE");
2819 anIndicesList << 0 << 1 << 2 ;
2820 pref->setItemProperty( "strings", aValuesList, curveType );
2821 pref->setItemProperty( "indexes", anIndicesList, curveType );
2822 // .... -> marker size
2823 int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dViewerGroup,
2824 LightApp_Preferences::IntSpin, "Plot2d", "MarkerSize" );
2825 pref->setItemProperty( "min", 0, markerSize );
2826 pref->setItemProperty( "max", 100, markerSize );
2827 // .... -> horizontal scaling mode
2828 int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dViewerGroup,
2829 LightApp_Preferences::Selector, "Plot2d", "HorScaleMode" );
2830 aValuesList.clear();
2831 anIndicesList.clear();
2832 aValuesList << tr("PREF_LINEAR") << tr("PREF_LOGARITHMIC");
2833 anIndicesList << 0 << 1 ;
2834 pref->setItemProperty( "strings", aValuesList, horScale );
2835 pref->setItemProperty( "indexes", anIndicesList, horScale );
2836 // .... -> vertical scaling mode
2837 int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dViewerGroup,
2838 LightApp_Preferences::Selector, "Plot2d", "VerScaleMode" );
2839 pref->setItemProperty( "strings", aValuesList, verScale );
2840 pref->setItemProperty( "indexes", anIndicesList, verScale );
2842 // .... -> errors/deviation colot
2843 pref->addPreference( tr( "PREF_DEVIATION_COLOR" ), plot2dViewerGroup,
2844 LightApp_Preferences::Color, "Plot2d", "DeviationMarkerColor" );
2845 // .... -> deviation markers line size
2846 int deviationMarkerLw = pref->addPreference( tr( "PREF_DEVIATION_MARKER_LW" ), plot2dViewerGroup,
2847 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerLineWidth" );
2848 pref->setItemProperty( "min", 1, deviationMarkerLw );
2849 pref->setItemProperty( "max", 5, deviationMarkerLw );
2850 // .... -> deviation markers tick mark size
2851 int deviationMarkerTs = pref->addPreference( tr( "PREF_DEVIATION_MARKER_TS" ), plot2dViewerGroup,
2852 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerTickSize" );
2853 pref->setItemProperty( "min", 1, deviationMarkerTs );
2854 pref->setItemProperty( "max", 5, deviationMarkerTs );
2855 // .... "Viewer" group <<end>>
2857 // ... "Legend" group <<start>>
2858 int plot2dLegendGroup = pref->addPreference( tr( "PREF_GROUP_LEGEND" ), plot2dGroup );
2860 // .... -> show legend
2861 pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dLegendGroup,
2862 LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
2863 // .... -> legend position
2864 int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dLegendGroup,
2865 LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
2866 aValuesList.clear();
2867 anIndicesList.clear();
2868 aValuesList << tr("PREF_LEFT") << tr("PREF_RIGHT") << tr("PREF_TOP") << tr("PREF_BOTTOM");
2869 anIndicesList << 0 << 1 << 2 << 3 ;
2870 pref->setItemProperty( "strings", aValuesList, legendPosition );
2871 pref->setItemProperty( "indexes", anIndicesList, legendPosition );
2872 // .... -> Symbol type
2873 int legendSymbolType = pref->addPreference( tr( "PREF_LEGEND_SYMBOL_TYPE" ), plot2dLegendGroup,
2874 LightApp_Preferences::Selector, "Plot2d", "LegendSymbolType" );
2875 aValuesList.clear();
2876 anIndicesList.clear();
2877 aValuesList << tr("PREF_MARKER_ON_LINE") << tr("PREF_MARKER_ABOVE_LINE");
2878 anIndicesList << 0 << 1 ;
2879 pref->setItemProperty( "strings", aValuesList, legendSymbolType );
2880 pref->setItemProperty( "indexes", anIndicesList, legendSymbolType );
2881 // .... -> legend font
2882 pref->addPreference( tr( "PREF_LEGEND_FONT" ), plot2dLegendGroup, LightApp_Preferences::Font, "Plot2d", "LegendFont" );
2883 // ... -> font color
2884 pref->addPreference( tr( "PREF_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "LegendFontColor" );
2885 // ... -> selection font color
2886 pref->addPreference( tr( "PREF_SELECTED_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "SelectedLegendFontColor" );
2887 // ... "Legend" group <<end>>
2889 // .. "Plot2d viewer" group <<end>>
2891 // .. "PyViewer" preferences tab <<start>>
2892 int pyeditTab = pref->addPreference( tr( "PREF_TAB_PYEDITOR" ), salomeCat );
2893 // ... "Font settings" group <<start>>
2894 int pyFontGroup = pref->addPreference( tr( "PREF_GROUP_PY_FONT" ), pyeditTab );
2895 int pyFont = pref->addPreference( tr( "PREF_PY_FONT" ), pyFontGroup,
2896 LightApp_Preferences::Font, "PyEditor", "Font" );
2897 pref->setItemProperty( "features", QtxFontEdit::Family | QtxFontEdit::Size | QtxFontEdit::UserSize, pyFont );
2898 // ... "Font settings" group <<end>>
2899 // ... "Display settings" group <<start>>
2900 int pyDispGroup = pref->addPreference( tr( "PREF_GROUP_PY_DISPLAY" ), pyeditTab );
2901 pref->setItemProperty( "columns", 2, pyDispGroup );
2902 // ... -> current line highlight
2903 pref->addPreference( tr( "PREF_PY_CURRLINE_HIGHLIGHT" ), pyDispGroup,
2904 LightApp_Preferences::Bool, "PyEditor", "HighlightCurrentLine" );
2905 // ... -> text wrapping
2906 pref->addPreference( tr( "PREF_PY_TEXT_WRAP" ), pyDispGroup,
2907 LightApp_Preferences::Bool, "PyEditor", "TextWrapping" );
2908 // ... -> center cursor on scroll
2909 pref->addPreference( tr( "PREF_PY_CURSON_ON_SCROLL" ), pyDispGroup,
2910 LightApp_Preferences::Bool, "PyEditor", "CenterCursorOnScroll" );
2911 // ... -> line numbers area
2912 pref->addPreference( tr( "PREF_PY_LINE_NUMBS_AREA" ), pyDispGroup,
2913 LightApp_Preferences::Bool, "PyEditor", "LineNumberArea" );
2914 // ... "Display settings" group <<end>>
2916 // ... "Editor settings" group <<start>>
2917 int pyEditGroup = pref->addPreference( tr( "PREF_GROUP_PY_EDITOR" ), pyeditTab );
2918 // ... -> navigation mode
2919 int pyCompletion = pref->addPreference( tr( "PREF_PY_COMPLETION_MODE" ), pyEditGroup,
2920 LightApp_Preferences::Selector, "PyEditor", "CompletionPolicy" );
2921 aValuesList.clear();
2922 anIndicesList.clear();
2923 aValuesList << tr("PREF_PY_NONE") << tr("PREF_PY_AUTO") << tr("PREF_PY_MANUAL") << tr("PREF_PY_ALWAYS");
2924 anIndicesList << 0 << 1 << 2 << 3 ;
2925 pref->setItemProperty( "strings", aValuesList, pyCompletion );
2926 pref->setItemProperty( "indexes", anIndicesList, pyCompletion );
2927 // ... "Editor settings" group <<end>>
2929 // ... "Tab settings" group <<start>>
2930 int pyTabGroup = pref->addPreference( tr( "PREF_GROUP_PY_TAB" ), pyeditTab );
2931 pref->setItemProperty( "columns", 2, pyTabGroup );
2932 // ... -> tab whitespaces
2933 pref->addPreference( tr( "PREF_PY_TAB_WHITESPACES" ), pyTabGroup,
2934 LightApp_Preferences::Bool, "PyEditor", "TabSpaceVisible" );
2936 pref->addPreference( tr( "PREF_PY_TAB_SIZE" ), pyTabGroup,
2937 LightApp_Preferences::IntSpin, "PyEditor", "TabSize" );
2938 // ... "Tab settings" group <<end>>
2939 // ... "Vertical edge settings" group <<start>>
2940 int pyVertEdgeGroup = pref->addPreference( tr( "PREF_GROUP_VERT_EDGE" ), pyeditTab );
2941 pref->setItemProperty( "columns", 2, pyVertEdgeGroup );
2942 // ... -> vertical edge
2943 pref->addPreference( tr( "PREF_PY_VERT_EDGE" ), pyVertEdgeGroup,
2944 LightApp_Preferences::Bool, "PyEditor", "VerticalEdge" );
2945 // ... -> number of columns
2946 pref->addPreference( tr( "PREF_PY_NUM_COLUMNS" ), pyVertEdgeGroup,
2947 LightApp_Preferences::IntSpin, "PyEditor", "NumberColumns" );
2948 // ... "Vertical edge settings" group <<end>>
2949 // .. "PyEditor" preferences tab <<end>>
2951 // .. "Directories" preferences tab <<start>>
2952 int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat );
2953 // ... --> quick directories list
2954 int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab );
2955 pref->addPreference( tr( "" ), dirGroup,
2956 LightApp_Preferences::DirList, "FileDlg", "QuickDirList" );
2957 // .. "Directories" preferences tab <<end>>
2959 // .. "Object browser" preferences tab <<start>>
2960 int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
2962 // ... "Search tool" group <<start>>
2963 int stGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SEARCH_TOOL" ), obTab );
2964 // .... --> auto-hide
2965 pref->addPreference( tr( "PREF_AUTO_HIDE_SEARCH_TOOL" ), stGroup, LightApp_Preferences::Bool,
2966 "ObjectBrowser", "auto_hide_search_tool" );
2967 // ... "Search tool" group <<end>>
2969 // ... "Object browser settings" group <<start>>
2970 int objSetGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), obTab );
2971 pref->setItemProperty( "columns", 2, objSetGroup );
2972 // .... -> auto size first column
2973 pref->addPreference( tr( "PREF_AUTO_SIZE_FIRST" ), objSetGroup, LightApp_Preferences::Bool,
2974 "ObjectBrowser", "auto_size_first" );
2975 // .... -> auto size other columns
2976 pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool,
2977 "ObjectBrowser", "auto_size" );
2978 // .... -> resize columns on expand item
2979 pref->addPreference( tr( "PREF_RESIZE_ON_EXPAND_ITEM" ), objSetGroup, LightApp_Preferences::Bool,
2980 "ObjectBrowser", "resize_on_expand_item" );
2981 // .... -> browse to published object
2982 int browsePublished = pref->addPreference( tr( "PREF_BROWSE_TO_THE_PUBLISHED_OBJECT" ), objSetGroup, LightApp_Preferences::Selector,
2983 "ObjectBrowser", "browse_published_object" );
2984 aValuesList.clear();
2985 anIndicesList.clear();
2986 aValuesList << tr( "PREF_BROWSE_NEVER" ) << tr( "PREF_BROWSE_AFTER_APPLY_AND_CLOSE_ONLY" ) << tr( "PREF_BROWSE_ALWAYS" );
2987 anIndicesList << BP_Never << BP_ApplyAndClose << BP_Always;
2988 pref->setItemProperty( "strings", aValuesList, browsePublished );
2989 pref->setItemProperty( "indexes", anIndicesList, browsePublished );
2990 // ... "Object browser settings" group <<end>>
2991 // .. "Object browser" preferences tab <<end>>
2993 // .. "Shortcuts" preferences tab <<start>>
2994 int shortcutTab = pref->addPreference( tr( "PREF_TAB_SHORTCUTS" ), salomeCat );
2995 // ... "Shortcuts settings" group <<start>>
2996 int shortcutGroup = pref->addPreference( tr( "PREF_GROUP_SHORTCUTS" ), shortcutTab );
2997 pref->addPreference( tr( "" ), shortcutGroup,
2998 LightApp_Preferences::ShortcutTree, "shortcuts" );
2999 // ... "Shortcuts settings" group <<end>>
3000 // .. "Shortcuts" preferences tab <<end>>
3001 // . Top-level "SALOME" preferences group <<end>>
3007 Changes appearance of application according to changed preferences
3008 \param sec - section
3009 \param param - name of changed parameter
3011 void LightApp_Application::preferencesChanged( const QString& sec, const QString& param )
3013 SUIT_ResourceMgr* resMgr = resourceMgr();
3017 if ( sec == "viewers" && param == "drop_down_buttons" )
3019 ViewManagerList vmlist = viewManagers();
3020 foreach( SUIT_ViewManager* vm, vmlist )
3022 QVector<SUIT_ViewWindow*> vwlist = vm->getViews();
3023 foreach( SUIT_ViewWindow* vw, vwlist )
3024 if ( vw ) vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
3028 if ( sec == QString( "3DViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )))
3030 double sz = resMgr->doubleValue( sec, "trihedron_size", -1 );
3031 bool relative = resMgr->booleanValue( sec, "relative_size", true );
3032 QList<SUIT_ViewManager*> lst;
3033 #ifndef DISABLE_OCCVIEWER
3034 viewManagers( OCCViewer_Viewer::Type(), lst );
3035 QListIterator<SUIT_ViewManager*> itOCC( lst );
3036 while ( itOCC.hasNext() && sz >= 0 )
3038 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3039 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3042 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3043 occVM->setTrihedronSize( sz, relative );
3044 occVM->getAISContext()->UpdateCurrentViewer();
3047 #ifndef DISABLE_VTKVIEWER
3048 #ifndef DISABLE_SALOMEOBJECT
3049 viewManagers( SVTK_Viewer::Type(), lst );
3050 QListIterator<SUIT_ViewManager*> itVTK( lst );
3051 while ( itVTK.hasNext() && sz >= 0 )
3053 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3054 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3057 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3060 vtkVM->setTrihedronSize( sz, relative );
3068 if ( sec == QString( "3DViewer" ) && param == QString( "show_static_trihedron" ) )
3070 bool isVisible = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
3071 QList<SUIT_ViewManager*> lst;
3072 #ifndef DISABLE_OCCVIEWER
3073 viewManagers( OCCViewer_Viewer::Type(), lst );
3074 QListIterator<SUIT_ViewManager*> itOCC( lst );
3075 while ( itOCC.hasNext() )
3077 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3078 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3081 OCCViewer_Viewer* occVM = dynamic_cast<OCCViewer_Viewer*>( vm );
3084 occVM->setStaticTrihedronDisplayed( isVisible );
3088 #ifndef DISABLE_VTKVIEWER
3089 #ifndef DISABLE_SALOMEOBJECT
3090 viewManagers( SVTK_Viewer::Type(), lst );
3091 QListIterator<SUIT_ViewManager*> itVTK( lst );
3092 while ( itVTK.hasNext() )
3094 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3095 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3098 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3101 vtkVM->setStaticTrihedronVisible( isVisible );
3109 if ( sec == QString( "3DViewer" ) && param == QString( "navigation_mode" ) )
3111 int mode = resMgr->integerValue( "3DViewer", "navigation_mode", 0 );
3112 QList<SUIT_ViewManager*> lst;
3113 #ifndef DISABLE_OCCVIEWER
3114 viewManagers( OCCViewer_Viewer::Type(), lst );
3115 QListIterator<SUIT_ViewManager*> itOCC( lst );
3116 while ( itOCC.hasNext() )
3118 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3119 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3122 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3123 occVM->setInteractionStyle( mode );
3126 #ifndef DISABLE_VTKVIEWER
3127 #ifndef DISABLE_SALOMEOBJECT
3128 viewManagers( SVTK_Viewer::Type(), lst );
3129 QListIterator<SUIT_ViewManager*> itVTK( lst );
3130 while ( itVTK.hasNext() )
3132 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3133 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3136 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3137 if( vtkVM ) vtkVM->setInteractionStyle( mode );
3143 #ifndef DISABLE_OCCVIEWER
3144 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_preselection" ) )
3146 bool isToEnablePreselection = resMgr->booleanValue( "OCCViewer", "enable_preselection", true );
3147 QList<SUIT_ViewManager*> lst;
3148 viewManagers( OCCViewer_Viewer::Type(), lst );
3149 QListIterator<SUIT_ViewManager*> it( lst );
3150 while ( it.hasNext() )
3152 SUIT_ViewModel* vm = it.next()->getViewModel();
3153 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3156 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3157 occVM->enablePreselection( isToEnablePreselection );
3162 #ifndef DISABLE_OCCVIEWER
3163 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_selection" ) )
3165 bool isToEnableSelection = resMgr->booleanValue( "OCCViewer", "enable_selection", true );
3166 QList<SUIT_ViewManager*> lst;
3167 viewManagers( OCCViewer_Viewer::Type(), lst );
3168 QListIterator<SUIT_ViewManager*> it( lst );
3169 while ( it.hasNext() )
3171 SUIT_ViewModel* vm = it.next()->getViewModel();
3172 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3175 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3176 occVM->enableSelection( isToEnableSelection );
3181 #ifndef DISABLE_OCCVIEWER
3182 if ( sec == QString( "OCCViewer" ) && param == QString( "clipping_color" ) )
3184 QColor aColor = resMgr->colorValue( "OCCViewer", "clipping_color", QColor( 50, 50, 50 ) );
3185 QList<SUIT_ViewManager*> lst;
3186 viewManagers( OCCViewer_Viewer::Type(), lst );
3187 QListIterator<SUIT_ViewManager*> it( lst );
3188 while ( it.hasNext() )
3190 SUIT_ViewModel* vm = it.next()->getViewModel();
3191 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3194 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3195 occVM->setClippingColor( aColor );
3200 #ifndef DISABLE_OCCVIEWER
3201 if ( sec == QString( "OCCViewer" ) && ( param == QString( "clipping_use_default_texture" ) ||
3202 param == QString( "clipping_texture" ) ||
3203 param == QString( "clipping_modulate" ) ||
3204 param == QString( "clipping_scale" ) ) )
3206 bool isDefaultTextureUsed = resMgr->booleanValue( "OCCViewer", "clipping_use_default_texture" );
3207 QString aTexture = resMgr->stringValue( "OCCViewer", "clipping_texture" );
3208 bool isModulated = resMgr->booleanValue( "OCCViewer", "clipping_modulate" );
3209 double aScale = resMgr->doubleValue( "OCCViewer", "clipping_scale" );
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->setClippingTextureParams( isDefaultTextureUsed, aTexture, isModulated, aScale );
3225 #ifndef DISABLE_OCCVIEWER
3226 if ( sec == QString( "OCCViewer" ) && param == QString( "projection_mode" ) )
3228 int mode = resMgr->integerValue( "OCCViewer", "projection_mode", 0 );
3229 QList<SUIT_ViewManager*> lst;
3230 viewManagers( OCCViewer_Viewer::Type(), lst );
3231 QListIterator<SUIT_ViewManager*> it( lst );
3232 while ( it.hasNext() )
3234 SUIT_ViewModel* vm = it.next()->getViewModel();
3235 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3238 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3239 occVM->setProjectionType( mode );
3243 #if OCC_VERSION_LARGE > 0x06090000
3244 #ifndef DISABLE_OCCVIEWER
3245 if ( sec == QString( "OCCViewer" ) && param == QString( "stereo_type" ) )
3247 int mode = resMgr->integerValue( "OCCViewer", "stereo_type", 0 );
3248 QList<SUIT_ViewManager*> lst;
3249 viewManagers( OCCViewer_Viewer::Type(), lst );
3250 QListIterator<SUIT_ViewManager*> it( lst );
3251 while ( it.hasNext() )
3253 SUIT_ViewModel* vm = it.next()->getViewModel();
3254 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3257 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3258 occVM->setStereoType( mode );
3263 #ifndef DISABLE_OCCVIEWER
3264 if ( sec == QString( "OCCViewer" ) && param == QString( "anaglyph_filter" ) )
3266 int mode = resMgr->integerValue( "OCCViewer", "anaglyph_filter", 0 );
3267 QList<SUIT_ViewManager*> lst;
3268 viewManagers( OCCViewer_Viewer::Type(), lst );
3269 QListIterator<SUIT_ViewManager*> it( lst );
3270 while ( it.hasNext() )
3272 SUIT_ViewModel* vm = it.next()->getViewModel();
3273 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3276 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3277 occVM->setAnaglyphFilter( mode );
3282 #ifndef DISABLE_OCCVIEWER
3283 if ( sec == QString( "OCCViewer" ) && ( param == QString( "focus_type" ) ||
3284 param == QString( "focus_value" ) ) )
3286 int aType = resMgr->integerValue( "OCCViewer", "focus_type" );
3287 double aValue = resMgr->doubleValue( "OCCViewer", "focus_value" );
3288 QList<SUIT_ViewManager*> lst;
3289 viewManagers( OCCViewer_Viewer::Type(), lst );
3290 QListIterator<SUIT_ViewManager*> it( lst );
3291 while ( it.hasNext() )
3293 SUIT_ViewModel* vm = it.next()->getViewModel();
3294 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3297 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3298 occVM->setStereographicFocus( aType, aValue );
3303 #ifndef DISABLE_OCCVIEWER
3304 if ( sec == QString( "OCCViewer" ) && ( param == QString( "iod_type" ) ||
3305 param == QString( "iod_value" ) ) )
3307 int aType = resMgr->integerValue( "OCCViewer", "iod_type" );
3308 double aValue = resMgr->doubleValue( "OCCViewer", "iod_value" );
3309 QList<SUIT_ViewManager*> lst;
3310 viewManagers( OCCViewer_Viewer::Type(), lst );
3311 QListIterator<SUIT_ViewManager*> it( lst );
3312 while ( it.hasNext() )
3314 SUIT_ViewModel* vm = it.next()->getViewModel();
3315 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3318 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3319 occVM->setInterocularDistance( aType, aValue );
3324 #ifndef DISABLE_OCCVIEWER
3325 if ( sec == QString( "OCCViewer" ) && param == QString( "reverse_stereo" ) )
3327 bool reverse = resMgr->booleanValue( "OCCViewer", "reverse_stereo", false );
3328 QList<SUIT_ViewManager*> lst;
3329 viewManagers( OCCViewer_Viewer::Type(), lst );
3330 QListIterator<SUIT_ViewManager*> it( lst );
3331 while ( it.hasNext() )
3333 SUIT_ViewModel* vm = it.next()->getViewModel();
3334 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3337 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3338 occVM->setReverseStereo( reverse );
3343 #ifndef DISABLE_OCCVIEWER
3344 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_vsync" ) )
3346 bool enable = resMgr->booleanValue( "OCCViewer", "enable_vsync", true );
3347 QList<SUIT_ViewManager*> lst;
3348 viewManagers( OCCViewer_Viewer::Type(), lst );
3349 QListIterator<SUIT_ViewManager*> it( lst );
3350 while ( it.hasNext() )
3352 SUIT_ViewModel* vm = it.next()->getViewModel();
3353 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3356 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3357 occVM->setVSync( enable );
3362 #ifndef DISABLE_OCCVIEWER
3363 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_quad_buffer_support" ) )
3365 bool enable = resMgr->booleanValue( "OCCViewer", "enable_quad_buffer_support", false );
3366 QList<SUIT_ViewManager*> lst;
3367 viewManagers( OCCViewer_Viewer::Type(), lst );
3368 QListIterator<SUIT_ViewManager*> it( lst );
3369 while ( it.hasNext() )
3371 SUIT_ViewModel* vm = it.next()->getViewModel();
3372 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3375 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3376 occVM->setQuadBufferSupport( enable );
3381 if ( sec == QString( "3DViewer" ) && param == QString( "zooming_mode" ) )
3383 int mode = resMgr->integerValue( "3DViewer", "zooming_mode", 0 );
3384 QList<SUIT_ViewManager*> lst;
3385 #ifndef DISABLE_OCCVIEWER
3386 viewManagers( OCCViewer_Viewer::Type(), lst );
3387 QListIterator<SUIT_ViewManager*> itOCC( lst );
3388 while ( itOCC.hasNext() )
3390 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3391 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3394 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3395 occVM->setZoomingStyle( mode );
3398 #ifndef DISABLE_VTKVIEWER
3399 #ifndef DISABLE_SALOMEOBJECT
3400 viewManagers( SVTK_Viewer::Type(), lst );
3401 QListIterator<SUIT_ViewManager*> itVTK( lst );
3402 while ( itVTK.hasNext() )
3404 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3405 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3408 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3409 if( vtkVM ) vtkVM->setZoomingStyle( mode );
3415 #ifndef DISABLE_VTKVIEWER
3416 if ( sec == QString( "VTKViewer" ) && (param == QString( "speed_value" ) || param == QString( "speed_mode" )) )
3418 int speed = resMgr->integerValue( "VTKViewer", "speed_value", 10 );
3419 int mode = resMgr->integerValue( "VTKViewer", "speed_mode", 0 );
3420 QList<SUIT_ViewManager*> lst;
3421 #ifndef DISABLE_SALOMEOBJECT
3422 viewManagers( SVTK_Viewer::Type(), lst );
3423 QListIterator<SUIT_ViewManager*> it( lst );
3424 while ( it.hasNext() )
3426 SUIT_ViewModel* vm = it.next()->getViewModel();
3427 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3430 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3431 if( vtkVM ) vtkVM->setIncrementalSpeed( speed, mode );
3437 #ifndef DISABLE_VTKVIEWER
3438 if ( sec == QString( "VTKViewer" ) && param == QString( "projection_mode" ) )
3440 int mode = resMgr->integerValue( "VTKViewer", "projection_mode", 0 );
3441 QList<SUIT_ViewManager*> lst;
3442 #ifndef DISABLE_SALOMEOBJECT
3443 viewManagers( SVTK_Viewer::Type(), lst );
3444 QListIterator<SUIT_ViewManager*> it( lst );
3445 while ( it.hasNext() )
3447 SUIT_ViewModel* vm = it.next()->getViewModel();
3448 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3451 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3452 if( vtkVM ) vtkVM->setProjectionMode( mode );
3458 #ifndef DISABLE_VTKVIEWER
3459 if ( sec == QString( "VTKViewer" ) && param == QString( "stereo_type" ) )
3461 int mode = resMgr->integerValue( "VTKViewer", "stereo_type", 0 );
3462 QList<SUIT_ViewManager*> lst;
3463 #ifndef DISABLE_SALOMEOBJECT
3464 viewManagers( SVTK_Viewer::Type(), lst );
3465 QListIterator<SUIT_ViewManager*> it( lst );
3466 while ( it.hasNext() )
3468 SUIT_ViewModel* vm = it.next()->getViewModel();
3469 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3472 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3473 if( vtkVM ) vtkVM->setStereoType( mode );
3479 #ifndef DISABLE_VTKVIEWER
3480 if ( sec == QString( "VTKViewer" ) && param == QString( "anaglyph_filter" ) )
3482 int mode = resMgr->integerValue( "VTKViewer", "anaglyph_filter", 0 );
3483 QList<SUIT_ViewManager*> lst;
3484 #ifndef DISABLE_SALOMEOBJECT
3485 viewManagers( SVTK_Viewer::Type(), lst );
3486 QListIterator<SUIT_ViewManager*> it( lst );
3487 while ( it.hasNext() )
3489 SUIT_ViewModel* vm = it.next()->getViewModel();
3490 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3493 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3494 if( vtkVM ) vtkVM->setAnaglyphFilter( mode );
3500 #ifndef DISABLE_VTKVIEWER
3501 if ( sec == QString( "VTKViewer" ) && param == QString( "enable_quad_buffer_support" ) )
3503 int enable = resMgr->booleanValue( "VTKViewer", "enable_quad_buffer_support", false );
3504 QList<SUIT_ViewManager*> lst;
3505 #ifndef DISABLE_SALOMEOBJECT
3506 viewManagers( SVTK_Viewer::Type(), lst );
3507 QListIterator<SUIT_ViewManager*> it( lst );
3508 while ( it.hasNext() )
3510 SUIT_ViewModel* vm = it.next()->getViewModel();
3511 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3514 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3515 if( vtkVM ) vtkVM->setQuadBufferSupport( enable );
3521 #ifndef DISABLE_VTKVIEWER
3522 if ( sec == QString( "VTKViewer" ) && param == QString( "preselection" ) )
3524 int mode = resMgr->integerValue( "VTKViewer", "preselection", 0 );
3525 QList<SUIT_ViewManager*> lst;
3526 #ifndef DISABLE_SALOMEOBJECT
3527 viewManagers( SVTK_Viewer::Type(), lst );
3528 QListIterator<SUIT_ViewManager*> it( lst );
3529 while ( it.hasNext() )
3531 SUIT_ViewModel* vm = it.next()->getViewModel();
3532 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3535 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3536 if( vtkVM ) vtkVM->setPreSelectionMode( mode );
3542 #ifndef DISABLE_VTKVIEWER
3543 if ( sec == QString( "VTKViewer" ) && param == QString( "enable_selection" ) )
3545 bool isToEnableSelection = resMgr->booleanValue( "VTKViewer", "enable_selection", true );
3546 QList<SUIT_ViewManager*> lst;
3547 #ifndef DISABLE_SALOMEOBJECT
3548 viewManagers( SVTK_Viewer::Type(), lst );
3549 QListIterator<SUIT_ViewManager*> it( lst );
3550 while ( it.hasNext() )
3552 SUIT_ViewModel* vm = it.next()->getViewModel();
3553 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3556 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3557 if( vtkVM ) vtkVM->enableSelection( isToEnableSelection );
3563 #ifndef DISABLE_VTKVIEWER
3564 if ( sec == QString( "VTKViewer" ) && (param == QString( "spacemouse_func1_btn" ) ||
3565 param == QString( "spacemouse_func2_btn" ) ||
3566 param == QString( "spacemouse_func5_btn" ) ) )
3568 int btn1 = resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", 1 );
3569 int btn2 = resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", 2 );
3570 int btn3 = resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", 9 );
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->setSpacemouseButtons( btn1, btn2, btn3 );
3587 if( sec=="ObjectBrowser" )
3589 SUIT_DataBrowser* ob = objectBrowser();
3593 if ( param=="auto_size_first" )
3595 bool autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
3596 ob->setAutoSizeFirstColumn( autoSizeFirst );
3597 if ( autoSizeFirst )
3598 ob->adjustFirstColumnWidth();
3600 else if ( param=="auto_size" ) {
3601 bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
3602 ob->setAutoSizeColumns(autoSize);
3604 ob->adjustColumnsWidth();
3606 else if ( param=="resize_on_expand_item" ) {
3607 bool resizeOnExpandItem = resMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
3608 ob->setResizeOnExpandItem(resizeOnExpandItem);
3610 else if ( param == "auto_hide_search_tool" ) {
3611 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
3617 if( param=="auto_save_interval" ) {
3618 myAutoSaveTimer->stop();
3619 int autoSaveInterval = resMgr->integerValue( "Study", "auto_save_interval", 0 );
3620 if ( activeStudy() && autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
3624 #ifndef DISABLE_PYCONSOLE
3625 if( sec=="PyConsole" && pythonConsole() )
3627 if ( param=="font" ) {
3628 pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) );
3630 else if ( param=="show_banner" ) {
3631 pythonConsole()->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
3633 else if ( param=="auto_completion" ) {
3634 pythonConsole()->setAutoCompletion( resMgr->booleanValue( "PyConsole", "auto_completion", true ) );
3641 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3643 if ( param == "visible_count" )
3644 mru->setVisibleCount( resMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
3645 else if ( param == "max_count" )
3646 mru->setHistoryCount( resMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
3647 else if ( param == "insert_mode" )
3648 mru->setInsertMode( resMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
3649 else if ( param == "link_type" )
3650 mru->setLinkType( resMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
3651 else if ( param == "show_clear" )
3652 mru->setClearPossible( resMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
3653 else if ( param == "show_mru" )
3654 mru->setVisible( resMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
3657 if ( sec == "language" && param == "language" )
3659 // VSR 18.06.2015 : commented out : single warning dialog box is now shown by the LightApp_PreferencesDlg
3660 //SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LANG_CHANGED" ) );
3662 if ( sec == "language" && param == "locale")
3664 // VSR 18.06.2015: commented out : single warning dialog box is now shown by the LightApp_PreferencesDlg
3665 //SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LOCALE_CHANGED" ) );
3667 if ( sec == "desktop" && param == "opaque_resize" ) {
3668 bool opaqueResize = resMgr->booleanValue( "desktop", "opaque_resize", false );
3669 // RNV: This code has been commented, because clearing of the QMainWindow::AnimatedDocks option
3670 // leads to strange behaviour of the dockable windows (at least at qt-5.6.1):
3671 // any dockable window can't be docked to the another area, except initial area.
3672 // It is possible to move window to another area, but it always returns to the initial area.
3674 // QMainWindow::DockOptions dopts = desktop()->dockOptions();
3675 // if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
3676 // else dopts &= ~QMainWindow::AnimatedDocks;
3677 // desktop()->setDockOptions( dopts );
3678 desktop()->setOpaqueResize( opaqueResize );
3679 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
3680 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
3683 #ifndef DISABLE_PLOT2DVIEWER
3684 QList<SUIT_ViewManager*> lst;
3685 viewManagers( Plot2d_Viewer::Type(), lst );
3686 QListIterator<SUIT_ViewManager*> itPlot2d( lst );
3687 while ( itPlot2d.hasNext() ) {
3688 SUIT_ViewManager* viewMgr = itPlot2d.next();
3689 SUIT_ViewModel* vm = viewMgr->getViewModel();
3690 if ( !vm || !vm->inherits( "Plot2d_Viewer" ) )
3693 //Plot2d_Viewer* Plot2dVM = dynamic_cast<Plot2d_Viewer*>( vm );
3695 viewMgr->setViewModel( vm );
3696 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
3698 Plot2d_ViewFrame* frame = wnd->getViewFrame();
3699 frame->SetPreference();
3708 void LightApp_Application::loadPreferences()
3710 CAM_Application::loadPreferences();
3712 SUIT_ResourceMgr* aResMgr = resourceMgr();
3717 static bool mru_load = true;
3720 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3722 mru->setVisible( aResMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
3723 mru->setVisibleCount( aResMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
3724 mru->setHistoryCount( aResMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
3725 mru->setInsertMode( aResMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
3726 mru->setLinkType( aResMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
3727 mru->setClearPossible( aResMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
3728 mru->loadLinks( aResMgr, "MRU" );
3734 QStringList mods = aResMgr->parameters( "windows_visibility" );
3735 for ( QStringList::const_iterator itr = mods.begin(); itr != mods.end(); ++itr )
3738 if ( aResMgr->value( "windows_visibility", *itr, arr ) )
3739 myWinVis.insert( *itr, arr );
3743 desktop()->retrieveGeometry( aResMgr->stringValue( "desktop", "geometry" ) );
3744 bool opaqueResize = aResMgr->booleanValue( "desktop", "opaque_resize", false );
3745 // QMainWindow::DockOptions dopts = desktop()->dockOptions();
3746 // if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
3747 // else dopts &= ~QMainWindow::AnimatedDocks;
3748 // desktop()->setDockOptions( dopts );
3749 desktop()->setOpaqueResize( opaqueResize );
3750 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
3751 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
3758 void LightApp_Application::savePreferences()
3760 CAM_Application::savePreferences();
3762 saveDockWindowsState();
3764 SUIT_ResourceMgr* aResMgr = resourceMgr();
3769 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3771 mru->saveLinks( aResMgr, "MRU" );
3773 for ( WinVis::const_iterator itr = myWinVis.begin(); itr != myWinVis.end(); ++itr )
3774 aResMgr->setValue( "windows_visibility", itr.key(), itr.value() );
3777 aResMgr->setValue( "desktop", "geometry", desktop()->storeGeometry() );
3779 #if GUI_DEVELOPMENT > 0
3780 aResMgr->setValue( "salome", "version", QString(GUI_VERSION_STR)+"dev" );
3782 aResMgr->setValue( "salome", "version", QString(GUI_VERSION_STR) );
3789 Updates desktop title
3791 void LightApp_Application::updateDesktopTitle()
3793 QString aTitle = applicationName();
3794 QString aVer = applicationVersion();
3795 if ( !aVer.isEmpty() )
3796 aTitle += QString( " " ) + aVer;
3798 if ( activeStudy() ) {
3799 QString sName = SUIT_Tools::file( activeStudy()->studyName().trimmed(), false );
3800 aTitle += QString( " - [%1]" ).arg( sName );
3803 desktop()->setWindowTitle( aTitle );
3807 \brief Get map of the operations which can be performed
3808 on the module activation.
3810 The method should return the map of the kind \c {<id>:<name>}
3811 where \c <id> is an integer identifier of the operation and
3812 \c <name> is a title for the button to be added to the
3813 dialog box. After user selects the required operation by the
3814 clicking the corresponding button in the dialog box, its identifier
3815 is passed to the moduleActionSelected() method to process
3818 \return map of the operations
3819 \sa moduleActionSelected()
3821 QMap<int, QString> LightApp_Application::activateModuleActions() const
3823 QMap<int, QString> opmap;
3824 opmap.insert( NewStudyId, tr( "ACTIVATE_MODULE_OP_NEW" ) );
3825 opmap.insert( OpenStudyId, tr( "ACTIVATE_MODULE_OP_OPEN" ) );
3830 \brief Called when the used selectes required operation chosen
3831 from "Activate module" dialog box.
3833 Performs the required operation according to the user choice.
3835 \param id operation identifier
3836 \sa activateModuleActions()
3838 void LightApp_Application::moduleActionSelected( const int id )
3853 Updates windows after close document
3855 void LightApp_Application::afterCloseDoc()
3859 CAM_Application::afterCloseDoc();
3863 Updates actions of active module
3865 void LightApp_Application::updateModuleActions()
3868 if ( activeModule() ) {
3869 modName = activeModule()->moduleName();
3870 if ( !isModuleAccessible( modName ) ) {
3871 QList<SUIT_Application*> apps = SUIT_Session::session()->applications();
3872 foreach( SUIT_Application* app, apps ) {
3873 LightApp_Application* lapp = dynamic_cast<LightApp_Application*>( app );
3874 if ( lapp && lapp != this )
3875 lapp->removeModuleAction( modName );
3880 LightApp_ModuleAction* moduleAction =
3881 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
3883 moduleAction->setActiveModule( modName );
3886 void LightApp_Application::removeModuleAction( const QString& modName )
3888 LightApp_ModuleAction* moduleAction =
3889 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
3891 moduleAction->removeModule( modName );
3894 bool LightApp_Application::checkModule( const QString& title )
3896 if ( title.isEmpty() )
3899 QString library = moduleLibrary( title, true );
3900 if ( library.isEmpty() )
3903 QString name = moduleName( title );
3905 bool isPyModule = library.contains( "SalomePyQtGUI" ) || library.contains( "SalomePyQtGUILight" );
3909 paths = QString( ::getenv( "PATH" ) ).split( ";", QString::SkipEmptyParts );
3910 #elif defined(__APPLE__)
3911 paths = QString( ::getenv( "DYLD_LIBRARY_PATH" ) ).split( ":", QString::SkipEmptyParts );
3913 paths = QString( ::getenv( "LD_LIBRARY_PATH" ) ).split( ":", QString::SkipEmptyParts );
3916 bool isFound = false;
3917 QStringList::const_iterator it;
3918 for ( it = paths.begin(); it != paths.end() && !isFound; ++it )
3920 isFound = QFileInfo( Qtx::addSlash( *it ) + library ).exists();
3926 "****************************************************************" << std::endl <<
3927 " Warning: library " << qPrintable( library ) << " is not found!" << std::endl <<
3928 " Module " << qPrintable( title ) << " will not be available in GUI mode!" << std::endl <<
3929 "****************************************************************" << std::endl);
3935 QString pyModule = QString( "%1GUI.py" ).arg( name );
3936 paths = QString( ::getenv( "PYTHONPATH" ) ).split( ":", QString::SkipEmptyParts );
3939 for ( it = paths.begin(); it != paths.end() && !isFound; ++it )
3941 isFound = QFileInfo( Qtx::addSlash( *it ) + pyModule ).exists();
3947 "****************************************************************" << std::endl <<
3948 " Warning: Python module " << qPrintable( pyModule ) << " is not found!" << std::endl <<
3949 " Module " << qPrintable( title ) << " will not be available in GUI mode!" << std::endl <<
3950 "****************************************************************" << std::endl);
3959 Gets current windows.
3960 \param winMap - output current windows map.
3962 void LightApp_Application::currentWindows( QMap<int, int>& winMap ) const
3965 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
3966 ((LightApp_Module*)activeModule())->windows( winMap );
3968 defaultWindows( winMap );
3972 Gets current view managers.
3973 \param lst - output current view managers list.
3975 void LightApp_Application::currentViewManagers( QStringList& lst ) const
3978 if ( !activeStudy() )
3981 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
3982 ((LightApp_Module*)activeModule())->viewManagers( lst );
3984 defaultViewManagers( lst );
3990 void LightApp_Application::updateWindows()
3992 QMap<int, int> winMap;
3993 currentWindows( winMap );
3995 for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
3997 if ( !dockWindow( it.key() ) )
3998 getWindow( it.key() );
4001 for ( WinMap::ConstIterator it = myWin.begin(); it != myWin.end(); ++it )
4003 QWidget* wid = it.value();
4004 if ( winMap.contains( it.key() ) )
4005 wid->setVisible( true );
4010 loadDockWindowsState();
4014 Updates view managers
4016 void LightApp_Application::updateViewManagers()
4019 currentViewManagers( lst );
4021 for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
4022 getViewManager( *it, true );
4026 Loads windows geometry
4028 void LightApp_Application::loadDockWindowsState()
4032 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
4033 bool storeWin = aResMgr->booleanValue( "Study", "store_positions", true );
4034 bool storeTb = aResMgr->booleanValue( "Study", "store_tool_positions", true );
4037 if ( activeModule() )
4038 modName = activeModule()->name();
4039 else if ( activeStudy() )
4040 modName = "nomodule";
4042 QtxResourceMgr::WorkingMode prevMode = aResMgr->setWorkingMode( QtxResourceMgr::IgnoreUserValues );
4043 QByteArray aDefaultState;
4044 aResMgr->value( "windows_geometry", modName, aDefaultState );
4045 QByteArray aDefaultVisibility;
4046 aResMgr->value( "windows_visibility", modName, aDefaultVisibility );
4047 bool hasDefaultVisibility = !aDefaultVisibility.isEmpty();
4048 aResMgr->setWorkingMode( prevMode );
4050 if( !storeWin && !storeTb && aDefaultState.isEmpty() && !hasDefaultVisibility)
4053 if ( aResMgr->hasValue("windows_geometry" ,modName ) ) {
4054 long version = Qtx::versionToId( aResMgr->stringValue( "windows_geometry_version", modName, "" ) );
4056 if ( version > Qtx::versionToId( "7.4.1" ) )
4057 aResMgr->value( "windows_geometry", modName , arr );
4059 arr = aDefaultState;
4060 QByteArray aTargetArray = processState(arr, storeWin, storeTb, true, aDefaultState);
4061 desktop()->restoreState( aTargetArray );
4064 QStringList mainToolbarsNames;
4065 mainToolbarsNames << "SalomeStandard" << "SalomeModules";
4066 QList<QToolBar*> mainToolbars = findToolBars( mainToolbarsNames );
4067 foreach( QToolBar* tb, mainToolbars ) tb->setVisible( true );
4069 if ( !myWinVis.contains( modName ) && aDefaultVisibility.isEmpty())
4072 QMap<QString, bool> *tbMap = 0;
4073 QMap<QString, bool> *dwMap = 0;
4075 QMap<QString, bool> userTbMap, userDwMap;
4076 dockWindowsState( myWinVis[modName], userTbMap, userDwMap );
4078 QMap<QString, bool> defaultTbMap, defaultDwMap;
4079 if(hasDefaultVisibility) {
4080 dockWindowsState( aDefaultVisibility, defaultTbMap, defaultDwMap);
4086 if(hasDefaultVisibility){
4087 tbMap = &defaultTbMap;
4094 if(hasDefaultVisibility){
4095 dwMap = &defaultDwMap;
4100 QList<QToolBar*> tbList = findToolBars();
4101 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit )
4103 QToolBar* tb = *tit;
4104 if ( tbMap->contains( tb->objectName() ) ) {
4105 tb->setVisible( (*tbMap)[tb->objectName()] );
4111 QList<QDockWidget*> dwList = desktop()->findChildren<QDockWidget*>();
4112 for ( QList<QDockWidget*>::iterator dit = dwList.begin(); dit != dwList.end(); ++dit )
4114 QDockWidget* dw = *dit;
4116 QObject* po = Qtx::findParent( dw, "QMainWindow" );
4117 if ( po != desktop() )
4120 if ( dwMap->contains( dw->objectName() ) )
4121 dw->setVisible( (*dwMap)[dw->objectName()] );
4129 Saves windows geometry
4131 void LightApp_Application::saveDockWindowsState()
4136 bool storeWin = resourceMgr()->booleanValue( "Study", "store_positions", true );
4137 bool storeTb = resourceMgr()->booleanValue( "Study", "store_tool_positions", true );
4139 if( !storeWin && !storeTb )
4143 if ( activeModule() )
4144 modName = activeModule()->name();
4145 else if ( activeStudy() )
4146 modName = "nomodule";
4148 QString versionId = GUI_VERSION_STR;
4149 #if GUI_DEVELOPMENT > 0
4153 QByteArray arr = desktop()->saveState();
4154 resourceMgr()->setValue( "windows_geometry", modName, processState(arr, storeWin, storeTb, false) );
4155 resourceMgr()->setValue( "windows_geometry_version", modName, versionId );
4158 if ( myWinVis.contains( modName ) )
4159 visArr = myWinVis[modName];
4161 QMap<QString, bool> tbMap, dwMap;
4162 dockWindowsState( visArr, tbMap, dwMap );
4164 QList<QToolBar*> tbList = desktop()->findChildren<QToolBar*>();
4165 for ( QList<QToolBar*>::iterator it = tbList.begin(); it != tbList.end(); ++it )
4168 tbMap.insert( tb->objectName(), tb->toggleViewAction()->isChecked() );
4171 QList<QDockWidget*> dwList = desktop()->findChildren<QDockWidget*>();
4172 for ( QList<QDockWidget*>::iterator it = dwList.begin(); it != dwList.end(); ++it )
4174 QDockWidget* wid = *it;
4175 dwMap.insert( wid->objectName(), wid->toggleViewAction()->isChecked() );
4178 visArr = dockWindowsState( tbMap, dwMap );
4180 myWinVis.insert( modName, visArr );
4183 QByteArray LightApp_Application::dockWindowsState( const QMap<QString, bool>& tb, const QMap<QString, bool>& dw ) const
4186 QDataStream stream( &visArr, QIODevice::WriteOnly );
4188 stream << (uchar)ToolBarMarker;
4189 stream << tb.size();
4190 for ( QMap<QString, bool>::const_iterator tit = tb.begin(); tit != tb.end(); ++tit )
4192 stream << tit.key();
4193 stream << (uchar)( tit.value() ? 1 : 0 );
4196 stream << (uchar)DockWidgetMarker;
4197 stream << dw.size();
4198 for ( QMap<QString, bool>::const_iterator wit = dw.begin(); wit != dw.end(); ++wit )
4200 stream << wit.key();
4201 stream << (uchar)( wit.value() ? 1 : 0 );
4207 void LightApp_Application::dockWindowsState( const QByteArray& arr, QMap<QString, bool>& tb, QMap<QString, bool>& dw ) const
4212 QByteArray visArr = arr;
4213 QDataStream stream( &visArr, QIODevice::ReadOnly );
4217 if ( marker != ToolBarMarker )
4222 for ( int i = 0; i < lines; ++i )
4225 stream >> objectName;
4228 tb.insert( objectName, shown );
4232 if ( marker != DockWidgetMarker )
4236 for ( int j = 0; j < lines; ++j )
4239 stream >> objectName;
4242 dw.insert( objectName, shown );
4247 Adds icon names for modules
4249 void LightApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) const
4253 SUIT_ResourceMgr* resMgr = resourceMgr();
4257 QStringList modList;
4258 modules( modList, false );
4260 for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )
4262 QString modName = *it;
4263 QString modIntr = moduleName( modName );
4264 QString modIcon = resMgr->stringValue( modIntr, "icon", QString() );
4266 if ( modIcon.isEmpty() )
4269 if ( SUIT_Tools::extension( modIcon ).isEmpty() )
4270 modIcon += QString( ".png" );
4272 iconMap.insert( modName, modIcon );
4277 Inserts items in popup, which necessary for current application
4279 void LightApp_Application::contextMenuPopup( const QString& type, QMenu* thePopup, QString& title )
4282 LightApp_SelectionMgr* selMgr = LightApp_Application::selectionMgr();
4283 bool cacheIsOn = selMgr->isSelectionCacheEnabled();
4284 selMgr->setSelectionCacheEnabled( true );
4286 SUIT_DataBrowser* ob = objectBrowser();
4288 CAM_Application::contextMenuPopup( type, thePopup, title );
4290 if ( ob && type == ob->popupClientType() ) {
4291 thePopup->addSeparator();
4292 QAction* a = thePopup->addAction( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
4293 if ( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) )
4294 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) );
4297 #ifndef DISABLE_SALOMEOBJECT
4298 if ( selMgr && ob ) {
4299 SALOME_ListIO selected;
4300 selMgr->selectedObjects( selected );
4301 if(selected.Extent() == 1){
4302 Handle(SALOME_InteractiveObject) anIObject = selected.First();
4303 SUIT_DataObject* obj = findObject(anIObject->getEntry());
4304 if(obj && obj->renameAllowed()) {
4305 QAction* a = new QAction(tr("MEN_RENAME_OBJ"), thePopup);
4306 connect( a, SIGNAL( triggered(bool) ), ob, SLOT( onStartEditing() ) );
4307 if ( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) )
4308 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) );
4310 QList<QAction*> acts = thePopup->actions();
4311 QAction* firstAction = acts.count() > 0 ? acts.first() : 0;
4312 thePopup->insertAction(firstAction,a);
4318 selMgr->setSelectionCacheEnabled( cacheIsOn );
4324 void LightApp_Application::createEmptyStudy()
4326 CAM_Application::createEmptyStudy();
4328 if ( objectBrowser() )
4329 objectBrowser()->updateTree();
4331 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
4332 if ( aResMgr && activeStudy() ) {
4333 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
4334 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
4339 void LightApp_Application::setDesktop( SUIT_Desktop* desk )
4341 CAM_Application::setDesktop( desk );
4344 connect( desk, SIGNAL( message( const QString& ) ),
4345 this, SLOT( onDesktopMessage( const QString& ) ), Qt::UniqueConnection );
4346 connect( desk, SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
4347 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
4348 /* connect( desk, SIGNAL( windowMoved( SUIT_ViewWindow* ) ),
4349 this, SLOT( onWindowMoved( SUIT_ViewWindow* ) ), Qt::UniqueConnection ); */
4355 \param mod - module to be activated
4357 bool LightApp_Application::activateModule( CAM_Module* mod )
4359 bool res = CAM_Application::activateModule( mod );
4361 if ( objectBrowser() )
4362 objectBrowser()->updateTree();
4368 \return keyborad accelerators manager object
4370 SUIT_Accel* LightApp_Application::accel() const
4376 Removes dead widget container from map
4378 void LightApp_Application::onWCDestroyed( QObject* ob )
4380 // remove destroyed widget container from windows map
4381 for ( WinMap::ConstIterator itr = myWin.begin(); itr != myWin.end(); ++itr )
4383 if ( itr.value() != ob )
4386 int key = itr.key();
4387 myWin.remove( key );
4392 void LightApp_Application::onMRUActivated( const QString& name )
4394 SUIT_Session* s = SUIT_Session::session();
4395 if ( s && s->activeApplication() == this )
4399 void LightApp_Application::onStylePreferences()
4401 #ifdef USE_SALOME_STYLE
4402 Style_PrefDlg dlg( desktop() );
4405 resourceMgr()->setValue( "Style", "use_salome_style", Style_Salome::isActive() );
4406 #endif // USE_SALOME_STYLE
4409 void LightApp_Application::onFullScreen(){
4410 if(myScreenHelper) {
4411 if(desktop()->isFullScreen())
4412 myScreenHelper->switchToNormalScreen();
4414 myScreenHelper->switchToFullScreen();
4419 Connects just added view manager
4421 void LightApp_Application::addViewManager( SUIT_ViewManager* vm )
4423 connect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
4424 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
4425 CAM_Application::addViewManager( vm );
4429 Remove view manager from memory
4431 void LightApp_Application::removeViewManager( SUIT_ViewManager* vm )
4433 disconnect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
4434 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
4435 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
4437 aStudy->removeObjectProperties( vm->getGlobalId() );
4439 CAM_Application::removeViewManager( vm );
4441 LightApp_SelectionMgr* selMgr = selectionMgr();
4442 QList<SUIT_Selector*> selectors;
4443 selMgr->selectors( selectors );
4444 foreach( SUIT_Selector* selector, selectors ) {
4445 if ( selector->owner() == vm->getViewModel() ) {
4450 // IPAL22894: Crash on closing OCC view
4456 Renames active window of desktop
4458 void LightApp_Application::onRenameWindow()
4463 QWidget* w = desktop()->activeWindow();
4468 QString name = QInputDialog::getText( w, tr( "TOT_RENAME" ), tr( "PRP_RENAME" ), QLineEdit::Normal, w->windowTitle(), &ok );
4469 if( ok && !name.isEmpty() )
4470 w->setWindowTitle( name );
4474 Closes active window of desktop
4476 void LightApp_Application::onCloseWindow()
4481 QWidget* w = desktop()->activeWindow();
4489 Closes all windows of desktop
4491 void LightApp_Application::onCloseAllWindow()
4493 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
4497 QList<SUIT_ViewWindow*> wndList = desk->windows();
4498 SUIT_ViewWindow* wnd;
4499 foreach( wnd, wndList )
4507 Groups all windows of desktop
4509 void LightApp_Application::onGroupAllWindow()
4511 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
4515 QtxWorkstack* wgStack = desk->workstack();
4521 \return default name for an active study
4523 void LightApp_Application::setDefaultStudyName( const QString& theName )
4525 QStringList anInfoList;
4526 modules( anInfoList, false );
4528 LightApp_Study* aStudy = (LightApp_Study*)activeStudy();
4529 if( anInfoList.count() == 1 && // to avoid a conflict between different modules
4530 !aStudy->isSaved() )
4532 aStudy->setStudyName( theName );
4533 updateDesktopTitle();
4538 Custom event handler
4540 bool LightApp_Application::event( QEvent* e )
4542 if( e && e->type()==2000 )
4544 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
4545 QString* d = ( QString* )ce->data();
4546 if( SUIT_MessageBox::question(0, tr("WRN_WARNING"),
4548 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
4549 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
4550 showPreferences( tr( "PREF_APP" ) );
4555 return CAM_Application::event( e );
4558 /*! Check data object */
4559 bool LightApp_Application::checkDataObject(LightApp_DataObject* theObj)
4563 bool isSuitable = !theObj->entry().isEmpty() &&
4564 !theObj->componentDataType().isEmpty() &&
4565 !theObj->name().isEmpty();
4572 int LightApp_Application::openChoice( const QString& aName )
4574 int choice = CAM_Application::openChoice( aName );
4576 if ( choice == OpenExist ) // The document is already open.
4578 // Do you want to reload it?
4579 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "QUE_DOC_ALREADYOPEN" ).arg( aName ),
4580 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No ) == SUIT_MessageBox::Yes )
4581 choice = OpenReload;
4587 bool LightApp_Application::openAction( const int choice, const QString& aName )
4594 STD_Application* app = 0;
4595 SUIT_Session* session = SUIT_Session::session();
4596 QList<SUIT_Application*> appList = session->applications();
4597 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !app; ++it )
4599 if ( (*it)->activeStudy() && (*it)->activeStudy()->studyName() == aName )
4600 app = ::qobject_cast<STD_Application*>( *it );
4605 app->onCloseDoc( false );
4606 appList = session->applications();
4607 STD_Application* other = 0;
4608 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !other; ++it )
4609 other = ::qobject_cast<STD_Application*>( *it );
4612 res = other->onOpenDoc( aName );
4617 res = CAM_Application::openAction( choice, aName );
4624 QStringList LightApp_Application::viewManagersTypes() const
4626 QStringList aTypesList;
4627 aTypesList += myUserWmTypes;
4628 #ifndef DISABLE_GLVIEWER
4629 aTypesList<<GLViewer_Viewer::Type();
4631 #ifndef DISABLE_PLOT2DVIEWER
4632 aTypesList<<Plot2d_Viewer::Type();
4634 #ifndef DISABLE_QXGRAPHVIEWER
4635 aTypesList<<QxScene_Viewer::Type();
4637 #ifndef DISABLE_PVVIEWER
4638 aTypesList<<PVViewer_Viewer::Type();
4640 #ifndef DISABLE_PYVIEWER
4641 aTypesList<<PyViewer_Viewer::Type();
4643 #ifndef DISABLE_OCCVIEWER
4644 aTypesList<<OCCViewer_Viewer::Type();
4646 #ifndef DISABLE_VTKVIEWER
4647 #ifndef DISABLE_SALOMEOBJECT
4648 aTypesList<<SVTK_Viewer::Type();
4650 aTypesList<<VTKViewer_Viewer::Type();
4656 * Removes all view managers of known types
4657 * Other view managers are ignored
4659 void LightApp_Application::clearKnownViewManagers()
4661 QStringList aTypesList = viewManagersTypes();
4662 QList<SUIT_ViewManager*> aMgrList;
4663 viewManagers( aMgrList );
4664 foreach (SUIT_ViewManager* aMgr, aMgrList) {
4665 if (aTypesList.contains(aMgr->getType()))
4666 removeViewManager(aMgr);
4671 Copy of current selection
4673 void LightApp_Application::onCopy()
4675 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
4681 Paste of current data in clipboard
4683 void LightApp_Application::onPaste()
4685 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
4691 Browse (i.e. set focus on) the published objects
4692 \param theIsApplyAndClose - flag indicating that the dialog for creating objects
4693 has been accepted by Ok (or Apply & Close) button
4694 \param theIsOptimizedBrowsing - flag switching to optimized browsing mode
4695 (to select the first published object only)
4696 \return entry of the selected object
4698 QString LightApp_Application::browseObjects( const QStringList& theEntryList,
4699 const bool theIsApplyAndClose,
4700 const bool theIsOptimizedBrowsing )
4703 if( SUIT_ResourceMgr* aResourceMgr = resourceMgr() )
4705 int aBrowsePolicy = aResourceMgr->integerValue( "ObjectBrowser", "browse_published_object", (int)BP_Never );
4706 switch( aBrowsePolicy )
4710 case BP_ApplyAndClose:
4711 if( !theIsApplyAndClose )
4719 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
4723 SUIT_DataBrowser* anOB = objectBrowser();
4727 SUIT_AbstractModel* aModel = dynamic_cast<SUIT_AbstractModel*>( anOB->model() );
4731 QStringListIterator anIter( theEntryList );
4732 if( theIsOptimizedBrowsing )
4734 // go to the last entry
4736 if( anIter.hasPrevious() )
4740 // scroll to each entry in the list
4741 // (in optimized mode - to the last entry only)
4743 LightApp_DataObject* anObject = 0;
4744 while( anIter.hasNext() )
4746 anEntry = anIter.next();
4747 if( !anEntry.isEmpty() )
4749 anObject = aStudy->findObjectByEntry( anEntry );
4752 QModelIndex anIndex = aModel->index( anObject );
4753 anOB->treeView()->scrollTo( anIndex );
4758 // always select the last object
4759 if( anObject && !anEntry.isEmpty() )
4761 QList<SUIT_Selector*> aSelectorList;
4762 selectionMgr()->selectors( "ObjectBrowser", aSelectorList );
4763 if( !aSelectorList.isEmpty() )
4765 if( LightApp_OBSelector* aSelector = dynamic_cast<LightApp_OBSelector*>( aSelectorList.first() ) )
4767 bool anIsAutoBlock = aSelector->autoBlock();
4769 // temporarily disable auto block, to emit LightApp_SelectionMgr::currentSelectionChanged() signal
4770 aSelector->setAutoBlock( false );
4772 SUIT_DataOwnerPtrList aList;
4773 #ifndef DISABLE_SALOMEOBJECT
4774 Handle(SALOME_InteractiveObject) aSObj = new SALOME_InteractiveObject
4775 ( anObject->entry().toLatin1().constData(),
4776 anObject->componentDataType().toLatin1().constData(),
4777 anObject->name().toLatin1().constData() );
4778 LightApp_DataOwner* owner = new LightApp_DataOwner( aSObj );
4780 LightApp_DataOwner* owner = new LightApp_DataOwner( anEntry );
4783 aList.append( owner );
4784 selectionMgr()->setSelected( aList );
4787 // restore auto block flag
4788 aSelector->setAutoBlock( anIsAutoBlock );
4796 SUIT_DataObject* LightApp_Application::findObject( const QString& id ) const
4798 LightApp_Study* study = dynamic_cast<LightApp_Study*>( activeStudy() );
4799 return study ? study->findObjectByEntry( id ) : 0;
4803 Checks that an object can be renamed.
4804 \param entry entry of the object
4805 \brief Return \c true if object can be renamed
4807 bool LightApp_Application::renameAllowed( const QString& /*entry*/) const {
4812 Rename object by entry.
4813 \param entry entry of the object
4814 \param name new name of the object
4815 \brief Return \c true if rename operation finished successfully, \c false otherwise.
4817 bool LightApp_Application::renameObject( const QString& entry, const QString& ) {
4821 /*! Process standard messages from desktop */
4822 void LightApp_Application::onDesktopMessage( const QString& message )
4824 const QString sectionSeparator = "/";
4826 if ( message.toLower() == "updateobjectbrowser" ||
4827 message.toLower() == "updateobjbrowser" ) {
4828 // update object browser
4829 updateObjectBrowser();
4831 else if ( message.toLower().startsWith( "activate_viewer" ) ) {
4832 QString vtype = message.split( sectionSeparator ).last();
4833 if ( !vtype.isEmpty() )
4834 getViewManager( vtype, true );
4837 QStringList data = message.split( sectionSeparator );
4838 if ( data.count() > 1 ) {
4839 QString msgType = data[0].trimmed();
4840 LightApp_Module* sMod = 0;
4841 CAM_Module* mod = module( msgType );
4843 mod = module( moduleTitle( msgType ) );
4844 if ( mod && mod->inherits( "LightApp_Module" ) )
4845 sMod = (LightApp_Module*)mod;
4847 if ( msgType.toLower() == "preferences" ) {
4848 // requested preferences change: should be given as "preferences/<section>/<name>/<value>"
4849 // for example "preferences/Study/multi_file_dump/true"
4850 if ( data.count() > 3 ) {
4851 QString section = data[1].trimmed();
4852 QString param = data[2].trimmed();
4853 QString value = QStringList( data.mid(3) ).join( sectionSeparator );
4854 resourceMgr()->setValue( section, param, value );
4858 // received message for the module
4859 QString msg = QStringList( data.mid(1) ).join( sectionSeparator );
4860 sMod->message( msg );
4868 Returns all top level toolbars.
4869 Note : Result list contains only main window toolbars, not including toolbars from viewers.
4871 QList<QToolBar*> LightApp_Application::findToolBars( const QStringList& names )
4873 QList<QToolBar*> aResult;
4874 QList<QToolBar*> tbList = desktop()->findChildren<QToolBar*>();
4875 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit ) {
4876 QToolBar* tb = *tit;
4877 QObject* po = Qtx::findParent( tb, "QMainWindow" );
4878 if ( po != desktop() )
4880 if ( names.isEmpty() || names.contains( tb->objectName() ) )
4887 Internal method to parse toolbars and dockable windows state.
4889 QByteArray LightApp_Application::processState(QByteArray& input,
4890 const bool processWin,
4891 const bool processTb,
4892 const bool isRestoring,
4893 QByteArray defaultState) {
4896 bool hasDefaultState = !defaultState.isEmpty();
4897 bool isDockWinWriten = false;
4899 //Write date from users settings
4901 QDataStream tmpInputData(&input, QIODevice::ReadOnly);
4902 int marker, version;
4904 tmpInputData >> marker;
4905 tmpInputData >> version;
4906 tmpInputData >> dockmarker;
4907 tmpInputData >> nbDocWin;
4909 if(processWin && processTb && !isRestoring) {
4911 } else if(!processWin && !processTb ) {
4913 aRes = defaultState;
4915 QDataStream aData(&aRes, QIODevice::WriteOnly);
4916 QList<QToolBar*> aToolBars = findToolBars();
4919 for ( QList<QToolBar*>::iterator tit = aToolBars.begin(); tit != aToolBars.end(); ++tit ) {
4920 QToolBar* tb = *tit;
4921 aNames.append(tb->objectName());
4924 int toolBarMarkerIndex = getToolbarMarkerIndex(input,aNames);
4925 if(toolBarMarkerIndex < 0)
4927 QDataStream anInputData(&input, QIODevice::ReadOnly);
4929 int toolBarMarkerIndexDef;
4930 if(hasDefaultState) {
4931 toolBarMarkerIndexDef = getToolbarMarkerIndex(defaultState, aNames);
4932 if(toolBarMarkerIndexDef < 0)
4935 QDataStream anInputDataDef(&defaultState, QIODevice::ReadOnly);
4937 QDataStream* aTargetData = 0;
4938 int aTargetIndex = -1;
4940 QByteArray currentArr = desktop()->saveState();
4941 QDataStream anInputDataCur(¤tArr, QIODevice::ReadOnly);
4942 bool useInputData = !isRestoring || (isRestoring && nbDocWin > 0);
4943 if(processWin && useInputData) {
4944 aTargetData = &anInputData;
4945 aTargetIndex = toolBarMarkerIndex;
4947 //Write date from default settings
4948 if(hasDefaultState) {
4949 aTargetData = &anInputDataDef;
4950 aTargetIndex = toolBarMarkerIndexDef;
4952 //If no default state, write current snapshot of the dockable windows
4954 aTargetData = &anInputDataCur;
4955 int toolBarMarkerIndexCur = getToolbarMarkerIndex(currentArr, aNames);
4956 aTargetIndex = toolBarMarkerIndexCur;
4961 if(aTargetData && aTargetIndex >= 0 ) {
4962 aTargetData->device()->seek(0);
4963 while( aTargetData->device()->pos() < aTargetIndex ) {
4968 isDockWinWriten = true;
4975 aTargetData = &anInputData;
4976 aTargetIndex = toolBarMarkerIndex;
4978 if(hasDefaultState) {
4979 aTargetData = &anInputDataDef;
4980 aTargetIndex = toolBarMarkerIndexDef;
4984 if(aTargetData && aTargetIndex >= 0) {
4986 if(!isDockWinWriten ) {
4987 //Write version marker
4988 int marker, version;
4989 aTargetData->device()->seek(0);
4990 *aTargetData >> marker;
4991 *aTargetData >> version;
4994 aData << (uchar) QDockWidgetMarker;
4996 int shift = 4*sizeof(int) + sizeof(QSize);
4997 index = aTargetIndex - shift;
4999 index = aTargetIndex;
5002 aTargetData->device()->seek(index);
5003 while(!aTargetData->atEnd()) {
5008 } else { // Not treat toolbars
5009 aData << (uchar) QToolBarMarker;
5010 aData << (int) 0; //Nb toolbars = 0
5017 \brief Emits operationFinished signal.
5018 \param theModuleName the name of the module which perfomed the operation
5019 \param theOperationName the operation name
5020 \param theEntryList the list of the created objects entries
5022 void LightApp_Application::emitOperationFinished( const QString& theModuleName,
5023 const QString& theOperationName,
5024 const QStringList& theEntryList )
5026 emit operationFinished( theModuleName, theOperationName, theEntryList );
5030 Update visibility state of given objects
5032 void LightApp_Application::updateVisibilityState( DataObjectList& theList,
5033 SUIT_ViewModel* theViewModel )
5035 if ( !theViewModel || theList.isEmpty() ) return;
5037 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
5038 if ( !aStudy ) return;
5040 SALOME_View* aView = dynamic_cast<SALOME_View*>( theViewModel );
5042 for ( DataObjectList::iterator itr = theList.begin(); itr != theList.end(); ++itr ) {
5043 LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>(*itr);
5045 if ( !obj || aStudy->isComponent( obj->entry() ) )
5048 LightApp_Module* anObjModule = dynamic_cast<LightApp_Module*>(obj->module());
5049 if ( anObjModule ) {
5050 LightApp_Displayer* aDisplayer = anObjModule->displayer();
5052 Qtx::VisibilityState anObjState = Qtx::UnpresentableState;
5053 if ( aDisplayer->canBeDisplayed( obj->entry(), theViewModel->getType() ) ) {
5054 if ( aView && aDisplayer->IsDisplayed( obj->entry(), aView ) )
5055 anObjState = Qtx::ShownState;
5057 anObjState = Qtx::HiddenState;
5059 aStudy->setVisibilityState( obj->entry(), anObjState );
5066 * Called when window activated
5068 void LightApp_Application::onWindowActivated( SUIT_ViewWindow* theViewWindow )
5070 SUIT_DataBrowser* anOB = objectBrowser();
5073 SUIT_DataObject* rootObj = anOB->root();
5077 DataObjectList listObj = rootObj->children( true );
5079 SUIT_ViewModel* vmod = 0;
5080 if ( SUIT_ViewManager* vman = theViewWindow->getViewManager() )
5081 vmod = vman->getViewModel();
5082 updateVisibilityState( listObj, vmod );
5086 Called then view manager removed
5088 void LightApp_Application::onViewManagerRemoved( SUIT_ViewManager* )
5090 ViewManagerList lst;
5091 viewManagers( lst );
5092 if ( lst.count() == 1) { // in case if closed last view window
5093 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
5095 aStudy->setVisibilityStateForAll( Qtx::UnpresentableState );
5100 Check existing document.
5102 bool LightApp_Application::checkExistingDoc()
5105 if( activeStudy() ) {
5106 int answer = !activeStudy()->isModified() ? 1 :
5107 SUIT_MessageBox::question( desktop(),
5108 tr( "APPCLOSE_CAPTION" ),
5109 tr( "STUDYCLOSE_DESCRIPTION" ),
5110 tr( "APPCLOSE_SAVE" ),
5111 tr( "APPCLOSE_CLOSE" ),
5112 tr( "APPCLOSE_CANCEL" ), 0 );
5114 if ( activeStudy()->isSaved() ) {
5117 } else if ( onSaveAsDoc() ) {
5118 if( !closeDoc( false ) ) {
5125 else if( answer == 1 ) {
5127 } else if( answer == 2 ) {
5134 #ifndef DISABLE_PYCONSOLE
5136 PyConsole_Interp* LightApp_Application::getPyInterp()
5138 static PyConsole_Interp* myInterp = 0;
5140 myInterp = createPyInterp();
5141 myInterp->initialize();
5146 PyConsole_Interp* LightApp_Application::createPyInterp()
5148 return new PyConsole_Interp();
5151 #endif // DISABLE_PYCONSOLE