1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File: LightApp_Application.cxx
24 // Created: 6/20/2005 18:39:45 PM
25 // Author: Natalia Donis
28 // E.A. : On windows with python 2.6, there is a conflict
29 // E.A. : between pymath.h and Standard_math.h which define
30 // E.A. : some same symbols : acosh, asinh, ...
31 #include <Standard_math.hxx>
32 #ifndef DISABLE_PYCONSOLE
37 #ifndef DISABLE_PYCONSOLE
38 #include "LightApp_PyEditor.h"
39 #include "PyConsole_Interp.h"
40 #include "PyConsole_Console.h"
43 #include "LightApp_Application.h"
44 #include "LightApp_Module.h"
45 #include "LightApp_DataModel.h"
46 #include "LightApp_DataOwner.h"
47 #include "LightApp_Displayer.h"
48 #include "LightApp_Study.h"
49 #include "LightApp_Preferences.h"
50 #include "LightApp_PreferencesDlg.h"
51 #include "LightApp_ModuleDlg.h"
52 #include "LightApp_AboutDlg.h"
53 #include "LightApp_ModuleAction.h"
54 // temporary commented
55 #include "LightApp_EventFilter.h"
56 #include "LightApp_OBSelector.h"
57 #include "LightApp_SelectionMgr.h"
58 #include "LightApp_DataObject.h"
59 #include "LightApp_WgViewModel.h"
60 #include "LightApp_FullScreenHelper.h"
62 #include <GUI_version.h>
64 #include <SALOME_Event.h>
66 #ifdef USE_SALOME_STYLE
67 #include <Style_Salome.h>
68 #include <Style_PrefDlg.h>
69 #endif // USE_SALOME_STYLE
71 #include <CAM_Module.h>
72 #include <CAM_DataModel.h>
73 #include <CAM_Study.h>
74 #include <STD_TabDesktop.h>
76 #include <SUIT_DataBrowser.h>
77 #include <SUIT_Session.h>
78 #include <SUIT_Study.h>
79 #include <SUIT_FileDlg.h>
80 #include <SUIT_ResourceMgr.h>
81 #include <SUIT_ShortcutMgr.h>
82 #include <SUIT_Tools.h>
83 #include <SUIT_Accel.h>
84 #include <SUIT_MessageBox.h>
85 #include <SUIT_ViewWindow.h>
88 #include <QtxFontEdit.h>
89 #include <QtxToolBar.h>
90 #include <QtxTreeView.h>
91 #include <QtxMRUAction.h>
92 #include <QtxDockAction.h>
93 #include <QtxDockWidget.h>
94 #include <QtxActionToolMgr.h>
95 #include <QtxSearchTool.h>
96 #include <QtxWorkstack.h>
99 #include <LogWindow.h>
101 #ifndef DISABLE_GLVIEWER
102 #include <GLViewer_Viewer.h>
103 #include <GLViewer_ViewManager.h>
104 #include "LightApp_GLSelector.h"
107 #ifndef DISABLE_PLOT2DVIEWER
108 #include <Plot2d_ViewManager.h>
109 #include <Plot2d_ViewModel.h>
110 #include <Plot2d_ViewWindow.h>
111 #include <Plot2d_ViewFrame.h>
112 #include "LightApp_Plot2dSelector.h"
113 #ifndef DISABLE_SALOMEOBJECT
114 #include <SPlot2d_ViewModel.h>
116 #include <Plot2d_ViewModel.h>
120 #ifndef DISABLE_OCCVIEWER
121 #include <OCCViewer_ViewManager.h>
122 #include <OCCViewer_ViewFrame.h>
123 #include <OCCViewer_ViewPort3d.h>
124 #ifndef DISABLE_SALOMEOBJECT
125 #include <SOCC_ViewModel.h>
127 #include <OCCViewer_ViewModel.h>
129 #include "LightApp_OCCSelector.h"
132 #ifndef DISABLE_VTKVIEWER
133 #ifndef DISABLE_SALOMEOBJECT
134 #include <SVTK_ViewModel.h>
135 #include <SVTK_ViewManager.h>
136 #include "LightApp_VTKSelector.h"
138 #include <VTKViewer_ViewModel.h>
139 #include <VTKViewer_ViewManager.h>
141 #include <VTKViewer_ViewModel.h>
144 #ifndef DISABLE_QXGRAPHVIEWER
145 #include <QxScene_ViewManager.h>
146 #include <QxScene_ViewModel.h>
147 #include <QxScene_ViewWindow.h>
150 #ifndef DISABLE_GRAPHICSVIEW
151 #include "GraphicsView_Viewer.h"
152 #include "GraphicsView_ViewManager.h"
153 #include "LightApp_GVSelector.h"
156 #ifndef DISABLE_PVVIEWER
157 #include "PVViewer_ViewManager.h"
158 #include "PVViewer_ViewWindow.h"
159 #include "PVViewer_ViewModel.h"
162 #ifndef DISABLE_PYVIEWER
163 #include <PyViewer_ViewManager.h>
164 #include <PyViewer_ViewModel.h>
165 #include <PyViewer_ViewWindow.h>
169 #define VISIBILITY_COLUMN_WIDTH 25
175 #include <QStringList>
177 #include <QApplication>
179 #include <QStatusBar>
181 #include <QObjectList>
183 #include <QInputDialog>
184 #include <QFontDatabase>
186 #include <QByteArray>
190 #include <QHeaderView>
195 #include <utilities.h>
197 #define FIRST_HELP_ID 1000000
199 #ifndef DISABLE_SALOMEOBJECT
200 #include <SALOME_InteractiveObject.hxx>
201 #include <SALOME_ListIO.hxx>
204 #include <Standard_Version.hxx>
206 #define ToolBarMarker 0
207 #define DockWidgetMarker 1
209 static const char* imageEmptyIcon[] = {
212 "....................",
213 "....................",
214 "....................",
215 "....................",
216 "....................",
217 "....................",
218 "....................",
219 "....................",
220 "....................",
221 "....................",
222 "....................",
223 "....................",
224 "....................",
225 "....................",
226 "....................",
227 "....................",
228 "....................",
229 "....................",
230 "....................",
231 "...................."};
233 int LightApp_Application::lastStudyId = 0;
235 // Markers used to parse array with dockable windows and toolbars state.
236 // For more details please see the qdockarealayout.cpp && qtoolbararealayout.cpp
237 // in the Qt source code.
239 #define QDockWidgetMarker 0xfd // = DockWidgetStateMarker
240 #define QToolBarMarker 0xfc // = ToolBarStateMarkerEx
242 // Format of the Byte array with the windows and toolbar state is:
243 // VersionMarker|version|DockWidgetStateMarker|nbDockWidgetLines|...DocWidgetData...|ToolBarStateMarkerEx|nbToolBarLines|...ToolBarData...
245 //Find toolbar marker position in the array in the following way:
246 //since the 'toolbar marker' is not unique, find index of first occurrence of the
247 //'toolbar marker' in the array and check that next string is name of the toolbar
249 void LightAppCleanUpAppResources()
251 if ( LightApp_Application::_prefs_ ) {
252 delete LightApp_Application::_prefs_;
253 LightApp_Application::_prefs_ = 0;
259 int getToolbarMarkerIndex( QByteArray input, const QStringList& aFlags ) {
260 int aResult = -1,tmp = 0;
261 int inputLen = input.length();
262 QDataStream anInputData( &input, QIODevice::ReadOnly );
263 while ( tmp < inputLen ) {
264 tmp = input.indexOf( QToolBarMarker, tmp + 1 );
267 anInputData.device()->seek( tmp );
271 anInputData >> lines;
273 if ( lines == 0 && anInputData.atEnd() ) {
274 //Case then array doesn't contain information about toolbars,
285 if ( aFlags.contains( str ) ) {
293 QString langToName( const QString& lang )
295 // special processing for English language to avoid such result as "American English"
296 // as Qt cannot just say "English"
301 result = QLocale( lang ).nativeLanguageName();
307 \return last global id of study
309 int LightApp_Application::studyId()
311 return LightApp_Application::lastStudyId;
314 /*!Create new instance of LightApp_Application.*/
315 extern "C" LIGHTAPP_EXPORT SUIT_Application* createApplication()
317 return new LightApp_Application();
320 /*! \var global preferences of LightApp */
321 LightApp_Preferences* LightApp_Application::_prefs_ = 0;
325 \class LightApp_Application
326 Application containing LightApp module
330 LightApp_Application::LightApp_Application()
331 : CAM_Application( false ),
333 myScreenHelper(new LightApp_FullScreenHelper())
335 Q_INIT_RESOURCE( LightApp );
337 STD_TabDesktop* desk = new STD_TabDesktop();
338 desk->setFullScreenAllowed(false);
339 desk->setMinimizeAllowed(false);
343 // initialize auto save timer
344 myAutoSaveTimer = new QTimer( this );
345 myAutoSaveTimer->setSingleShot( true );
346 connect( myAutoSaveTimer, SIGNAL( timeout() ), this, SLOT( onSaveDoc() ) );
348 //connect( this, SIGNAL( moving() ), this, SLOT( onMoved() ) );
350 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
351 QPixmap aLogo = aResMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
353 desktop()->setWindowIcon( aLogo );
354 desktop()->setDockableMenuBar( false );
355 desktop()->setDockableStatusBar( false );
357 // base logo (salome itself)
358 desktop()->logoInsert( "_app_base", aResMgr->loadPixmap( "LightApp", tr( "APP_BASE_LOGO" ), false ) );
359 // extra logo (salome-based application)
360 desktop()->logoInsert( "_app_extra", aResMgr->loadPixmap( "LightApp", tr( "APP_EXTRA_LOGO" ), false ) );
364 mySelMgr = new LightApp_SelectionMgr( this );
366 myAccel = SUIT_Accel::getAccel();
368 #ifndef DISABLE_OCCVIEWER
369 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, OCCViewer_Viewer::Type() );
370 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, OCCViewer_Viewer::Type() );
371 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, OCCViewer_Viewer::Type() );
372 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, OCCViewer_Viewer::Type() );
373 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, OCCViewer_Viewer::Type() );
374 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, OCCViewer_Viewer::Type() );
375 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, OCCViewer_Viewer::Type() );
376 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, OCCViewer_Viewer::Type() );
377 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, OCCViewer_Viewer::Type() );
378 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, OCCViewer_Viewer::Type() );
379 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, OCCViewer_Viewer::Type() );
380 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, OCCViewer_Viewer::Type() );
382 #ifndef DISABLE_VTKVIEWER
383 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, VTKViewer_Viewer::Type() );
384 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, VTKViewer_Viewer::Type() );
385 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, VTKViewer_Viewer::Type() );
386 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, VTKViewer_Viewer::Type() );
387 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, VTKViewer_Viewer::Type() );
388 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, VTKViewer_Viewer::Type() );
389 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, VTKViewer_Viewer::Type() );
390 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, VTKViewer_Viewer::Type() );
391 myAccel->setActionKey( SUIT_Accel::RotateLeft, Qt::ALT+Qt::Key_Left, VTKViewer_Viewer::Type() );
392 myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right, VTKViewer_Viewer::Type() );
393 myAccel->setActionKey( SUIT_Accel::RotateUp, Qt::ALT+Qt::Key_Up, VTKViewer_Viewer::Type() );
394 myAccel->setActionKey( SUIT_Accel::RotateDown, Qt::ALT+Qt::Key_Down, VTKViewer_Viewer::Type() );
396 #ifndef DISABLE_PLOT2DVIEWER
397 myAccel->setActionKey( SUIT_Accel::PanLeft, Qt::CTRL+Qt::Key_Left, Plot2d_Viewer::Type() );
398 myAccel->setActionKey( SUIT_Accel::PanRight, Qt::CTRL+Qt::Key_Right, Plot2d_Viewer::Type() );
399 myAccel->setActionKey( SUIT_Accel::PanUp, Qt::CTRL+Qt::Key_Up, Plot2d_Viewer::Type() );
400 myAccel->setActionKey( SUIT_Accel::PanDown, Qt::CTRL+Qt::Key_Down, Plot2d_Viewer::Type() );
401 myAccel->setActionKey( SUIT_Accel::ZoomIn, Qt::CTRL+Qt::Key_Plus, Plot2d_Viewer::Type() );
402 myAccel->setActionKey( SUIT_Accel::ZoomOut, Qt::CTRL+Qt::Key_Minus, Plot2d_Viewer::Type() );
403 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::CTRL+Qt::Key_Asterisk, Plot2d_Viewer::Type() );
404 myAccel->setActionKey( SUIT_Accel::ZoomFit, Qt::Key_Space, Plot2d_Viewer::Type() );
407 connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) );
408 connect( desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
409 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
410 connect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
411 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ), Qt::UniqueConnection );
414 // Set existing font for the python console in resources
415 if( !aResMgr->hasValue( "PyConsole", "font" ) )
418 QFont f = aResMgr->fontValue( "PyConsole", "font" );
420 QStringList famdb = fdb.families();
422 if ( famdb.contains(f.family()) || !aResMgr->hasValue( "PyConsole", "additional_families" ) )
425 QStringList anAddFamilies = aResMgr->stringValue( "PyConsole", "additional_families" ).split( ";", QString::SkipEmptyParts );
427 for ( QStringList::Iterator it = anAddFamilies.begin(); it != anAddFamilies.end(); ++it )
430 if ( famdb.contains(aFamily) )
432 f.setFamily( aFamily );
433 aResMgr->setValue( "PyConsole", "font", f );
440 *\li Save window geometry.
441 *\li Save desktop geometry.
442 *\li Save resource maneger.
443 *\li Delete selection manager.
445 LightApp_Application::~LightApp_Application()
449 delete myScreenHelper;
453 /*!Start application.*/
454 void LightApp_Application::start()
456 CAM_Application::start();
459 updateViewManagers();
460 updateCommandsStatus();
463 desktop()->statusBar()->showMessage( "" );
465 LightApp_EventFilter::Init();
468 /*!Closeapplication.*/
469 void LightApp_Application::closeApplication()
471 #ifndef DISABLE_QTXWEBBROWSER
472 QProcess::startDetached( "HelpBrowser",
473 QStringList() << QString( "--remove=%1" ).arg( QApplication::instance()->applicationPid() ) );
475 CAM_Application::closeApplication();
478 /*!Gets application name.*/
479 QString LightApp_Application::applicationName() const
481 static QString _app_name;
482 if ( _app_name.isEmpty() )
483 _app_name = tr( "APP_NAME" );
487 /*!Gets application version.*/
488 QString LightApp_Application::applicationVersion() const
490 static QString _app_version;
492 if ( _app_version.isEmpty() )
494 QString resVersion = tr( "APP_VERSION" );
495 if ( resVersion != "APP_VERSION" )
497 _app_version = resVersion;
501 _app_version = GUI_VERSION_STR;
507 /*!Load module by \a name.*/
508 CAM_Module* LightApp_Application::loadModule( const QString& name, const bool showMsg )
510 CAM_Module* mod = CAM_Application::loadModule( name, showMsg );
513 connect( this, SIGNAL( studyOpened() ), mod, SLOT( onModelOpened() ) );
514 connect( this, SIGNAL( studySaved() ), mod, SLOT( onModelSaved() ) );
515 connect( this, SIGNAL( studyClosed() ), mod, SLOT( onModelClosed() ) );
520 /*!Activate module by \a modName*/
521 bool LightApp_Application::activateModule( const QString& modName )
524 CAM_Module* prevMod = activeModule();
527 actName = prevMod->moduleName();
529 if ( actName == modName )
532 putInfo( tr( "ACTIVATING_MODULE" ).arg( modName ) );
534 saveDockWindowsState();
536 bool status = CAM_Application::activateModule( modName );
538 updateModuleActions();
546 updateViewManagers();
548 if ( activeStudy() && activeStudy()->root() && objectBrowser() ) {
549 if ( objectBrowser()->root() != activeStudy()->root() )
550 objectBrowser()->setRoot( activeStudy()->root() );
551 updateObjectBrowser( true );
554 if ( activeModule() ) activeModule()->updateModuleVisibilityState();
559 /*!Gets selection manager.*/
560 LightApp_SelectionMgr* LightApp_Application::selectionMgr() const
565 /*!Creat action "New window" for certain type of viewer:*/
566 void LightApp_Application::createActionForViewer( const int id,
568 const QString& suffix,
571 QString vtlt = tr( QString( "NEW_WINDOW_%1" ).arg( suffix ).toLatin1().constData() );
572 QString tip = tr( "CREATING_NEW_WINDOW" ).arg( vtlt.remove( "&" ) );
573 QAction* a = createAction( id, // menu action id
580 false, // toggle flag
582 SLOT( onNewWindow() ) ); // slot
583 createMenu( a, parentId, -1 );
588 void LightApp_Application::createActions()
590 CAM_Application::createActions();
592 SUIT_Desktop* desk = desktop();
593 SUIT_ResourceMgr* resMgr = resourceMgr();
596 createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIcon(),
597 tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
598 Qt::CTRL+Qt::Key_P, desk, false, this, SLOT( onPreferences() ) );
602 // - Help for modules
604 int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
605 createMenu( separator(), helpMenu, -1, 10 );
608 int id = LightApp_Application::UserID + FIRST_HELP_ID;
610 QString site = tr ( "SALOME_SITE" );
611 QAction* as = createAction( id, site,
612 resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ),
614 0, desk, false, this, SLOT( onHelpOnline() ) );
615 as->setData( "salome-platform.org" );
616 createMenu( as, helpMenu, -1, 0 );
619 QString forum = tr ( "SALOME_FORUM" );
621 QAction* af = createAction( helpMenu, forum,
622 resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ),
624 0, desk, false, this, SLOT( onHelpOnline() ) );
625 af->setData( "salome-platform.org/forum" );
626 createMenu( af, helpMenu, -1, 0 );
629 createMenu( separator(), helpMenu, -1, 0 );
632 QString video = tr ( "SALOME_VIDEO_TUTORIALS" );
633 QAction* av = createAction( helpMenu, video,
634 resMgr->loadPixmap( "LightApp", tr( "ICON_LIFE_RIGN" ), false ),
636 0, desk, false, this, SLOT( onHelpOnline() ) );
637 av->setData( "www.youtube.com/playlist?list=PLgvBxFyGVRbZZz4wVvP36xXQL-S81RZsc" );
638 createMenu( av, helpMenu, -1, 0 );
642 QStringList aModuleList;
643 modules( aModuleList, false );
644 aModuleList.prepend( "GUI" );
645 aModuleList.prepend( "KERNEL" );
648 foreach( aModule, aModuleList ) {
649 if ( aModule.isEmpty() ) // module title (user name)
651 IMap <QString, QString> helpData; // list of help files for the module
652 QString helpSubMenu; // help submenu name (empty if not needed)
653 QString modName = moduleName( aModule ); // module name
654 if ( modName.isEmpty() ) modName = aModule; // for KERNEL and GUI
655 QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName ); // module root dir variable
656 QString modDir = getenv( rootDir.toLatin1().constData() ); // module root dir
658 if (resMgr->hasValue( modName, "documentation" ) )
659 docSection = resMgr->stringValue(modName, "documentation");
660 else if ( resMgr->hasSection( modName + "_documentation" ) )
661 docSection = modName + "_documentation";
662 if ( !docSection.isEmpty() ) {
663 helpSubMenu = resMgr->stringValue( docSection, "sub_menu", "" ).arg( aModule );
664 QStringList listOfParam = resMgr->parameters( docSection );
665 foreach( QString paramName, listOfParam ) {
666 QString valueStr = resMgr->stringValue( docSection, paramName );
667 if ( !valueStr.isEmpty() ) {
668 QFileInfo fi( valueStr );
669 if ( fi.isRelative() && !modDir.isEmpty() )
670 valueStr = Qtx::addSlash( modDir ) + valueStr;
671 if ( QFile::exists( valueStr ) )
672 helpData.insert( paramName.arg( aModule ), valueStr );
677 if ( helpData.isEmpty() && !modDir.isEmpty() ) {
678 QStringList idxLst = QStringList() << modDir << "share" << "doc" << "salome" << "gui" << modName << "index.html";
679 QString indexFile = idxLst.join( QDir::separator() ); // index file
680 if ( QFile::exists( indexFile ) )
681 helpData.insert( tr( "%1 module Users's Guide" ).arg( aModule ), indexFile );
684 IMapConstIterator<QString, QString > fileIt;
685 for ( fileIt = helpData.begin(); fileIt != helpData.end(); fileIt++ ) {
686 QString helpFileName = fileIt.key();
687 // remove all '//' occurances
688 while ( helpFileName.contains( "//" ) )
689 helpFileName.replace( "//", "" );
690 // obtain submenus hierarchy if given
691 QStringList smenus = helpFileName.split( "/" );
692 helpFileName = smenus.last();
694 QAction* a = createAction( id, helpFileName,
695 resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
696 helpFileName, helpFileName,
697 0, desk, false, this, SLOT( onHelpContentsModule() ) );
698 a->setData( fileIt.value() );
699 if ( !helpSubMenu.isEmpty() ) {
700 smenus.prepend( helpSubMenu );
702 // create sub-menus hierarchy
703 int menuId = helpMenu;
704 foreach ( QString subMenu, smenus ) {
705 menuId = createMenu( subMenu, menuId, -1, 0 );
707 createMenu( a, menuId, -1, 0 );
712 // - Additional help items
714 createMenu( separator(), helpMenu, -1, 5 );
716 QStringList addHelpItems = resMgr->parameters( "add_help" );
717 foreach ( QString addHelpItem, addHelpItems ) {
718 QString valueStr = resMgr->stringValue( "add_help", addHelpItem );
719 if ( !valueStr.isEmpty() && QFile::exists( valueStr ) ) {
720 QAction* a = createAction( id, addHelpItem,
721 resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
722 addHelpItem, addHelpItem,
723 0, desk, false, this, SLOT( onHelpContentsModule() ) );
724 a->setData( valueStr );
725 createMenu( a, helpMenu, -1, 5 );
731 static QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), 0 );
732 connect( mru, SIGNAL( activated( const QString& ) ), this, SLOT( onMRUActivated( const QString& ) ) );
733 registerAction( MRUId, mru );
735 // default icon for neutral point ('SALOME' module)
736 QPixmap defIcon = resMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
737 if ( defIcon.isNull() )
738 defIcon = QPixmap( imageEmptyIcon );
740 //! default icon for any module
741 QPixmap modIcon = resMgr->loadPixmap( "LightApp", tr( "APP_MODULE_ICO" ), false );
742 if ( modIcon.isNull() )
743 modIcon = QPixmap( imageEmptyIcon );
746 modules( modList, false );
748 if ( modList.count() > 1 )
750 LightApp_ModuleAction* moduleAction =
751 new LightApp_ModuleAction( tr( "APP_NAME" ), defIcon, desk );
753 QMap<QString, QString> iconMap;
754 moduleIconNames( iconMap );
756 const int iconSize = 20;
758 QStringList::Iterator it;
759 for ( it = modList.begin(); it != modList.end(); ++it )
761 if ( !isModuleAccessible( *it ) )
764 QString modName = moduleName( *it );
767 if ( iconMap.contains( *it ) )
768 iconName = iconMap[*it];
770 QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
775 "****************************************************************" << std::endl <<
776 " Warning: icon for " << qPrintable(*it) << " is not found!" << std::endl <<
777 " Using the default icon." << std::endl <<
778 "****************************************************************" << std::endl);
780 icon = Qtx::scaleIcon( icon, iconSize );
782 moduleAction->insertModule( *it, icon );
785 connect( moduleAction, SIGNAL( moduleActivated( const QString& ) ),
786 this, SLOT( onModuleActivation( const QString& ) ) );
787 registerAction( ModulesListId, moduleAction );
791 int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, MenuWindowId, 100 );
792 int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
794 createAction( CloseId, tr( "TOT_CLOSE" ), QIcon(), tr( "MEN_DESK_CLOSE" ), tr( "PRP_CLOSE" ),
795 Qt::CTRL+Qt::Key_F4, desk, false, this, SLOT( onCloseWindow() ) );
796 createAction( CloseAllId, tr( "TOT_CLOSE_ALL" ), QIcon(), tr( "MEN_DESK_CLOSE_ALL" ), tr( "PRP_CLOSE_ALL" ),
797 0, desk, false, this, SLOT( onCloseAllWindow() ) );
798 createAction( GroupAllId, tr( "TOT_GROUP_ALL" ), QIcon(), tr( "MEN_DESK_GROUP_ALL" ), tr( "PRP_GROUP_ALL" ),
799 0, desk, false, this, SLOT( onGroupAllWindow() ) );
801 createMenu( CloseId, windowMenu, 0, -1 );
802 createMenu( CloseAllId, windowMenu, 0, -1 );
803 createMenu( GroupAllId, windowMenu, 0, -1 );
804 createMenu( separator(), windowMenu, -1, 0 );
806 #ifndef DISABLE_GLVIEWER
807 createActionForViewer( NewGLViewId, newWinMenu, QString::number( 0 ), Qt::ALT+Qt::Key_G );
809 #ifndef DISABLE_PLOT2DVIEWER
810 createActionForViewer( NewPlot2dId, newWinMenu, QString::number( 1 ), Qt::ALT+Qt::Key_P );
812 #ifndef DISABLE_OCCVIEWER
813 createActionForViewer( NewOCCViewId, newWinMenu, QString::number( 2 ), Qt::ALT+Qt::Key_O );
815 #ifndef DISABLE_VTKVIEWER
816 createActionForViewer( NewVTKViewId, newWinMenu, QString::number( 3 ), Qt::ALT+Qt::Key_K );
818 #ifndef DISABLE_QXGRAPHVIEWER
819 createActionForViewer( NewQxSceneViewId, newWinMenu, QString::number( 4 ), Qt::ALT+Qt::Key_S );
821 #ifndef DISABLE_GRAPHICSVIEW
822 createActionForViewer( NewGraphicsViewId, newWinMenu, QString::number( 5 ), Qt::ALT+Qt::Key_C );
824 #ifndef DISABLE_PVVIEWER
825 createActionForViewer( NewPVViewId, newWinMenu, QString::number( 6 ), Qt::ALT+Qt::Key_A );
827 #ifndef DISABLE_PYVIEWER
828 createActionForViewer( NewPyViewerId, newWinMenu, QString::number( 7 ), Qt::ALT+Qt::Key_Y );
831 createAction( RenameId, tr( "TOT_RENAME" ), QIcon(), tr( "MEN_DESK_RENAME" ), tr( "PRP_RENAME" ),
832 Qt::ALT+Qt::SHIFT+Qt::Key_R, desk, false, this, SLOT( onRenameWindow() ) );
833 createMenu( RenameId, windowMenu, -1 );
835 int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
836 createMenu( PreferencesId, fileMenu, 50, -1 );
837 createMenu( separator(), fileMenu, -1, 50, -1 );
839 createMenu( separator(), fileMenu, -1, 100, -1 );
840 createMenu( MRUId, fileMenu, 100, -1 );
841 createMenu( separator(), fileMenu, -1, 100, -1 );
843 #ifdef USE_SALOME_STYLE
844 createAction( StyleId, tr( "TOT_THEME" ), QIcon(), tr( "MEN_DESK_THEME" ), tr( "PRP_THEME" ),
845 0, desk, false, this, SLOT( onStylePreferences() ) );
846 #endif // USE_SALOME_STYLE
848 createAction( FullScreenId, tr( "TOT_FULLSCREEN" ), QIcon(), tr( "MEN_DESK_FULLSCREEN" ), tr( "PRP_FULLSCREEN" ),
849 Qt::Key_F11, desk, false, this, SLOT( onFullScreen() ) );
852 int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1 );
853 createMenu( separator(), viewMenu, -1, 20, -1 );
854 #ifdef USE_SALOME_STYLE
855 createMenu( StyleId, viewMenu, 20, -1 );
856 #endif // USE_SALOME_STYLE
857 createMenu( FullScreenId, viewMenu, 20, -1 );
859 int modTBar = createTool( tr( "INF_TOOLBAR_MODULES" ), // title (language-dependant)
860 QString( "SalomeModules" ) ); // name (language-independant)
861 createTool( ModulesListId, modTBar );
864 /*!On module activation action.*/
865 void LightApp_Application::onModuleActivation( const QString& modName )
867 // Force user to create/open a study before module activation
868 QMap<QString, QString> iconMap;
869 moduleIconNames( iconMap );
870 QPixmap icon = resourceMgr()->loadPixmap( moduleName( modName ), iconMap[ modName ], false );
872 icon = resourceMgr()->loadPixmap( "LightApp", tr( "APP_MODULE_BIG_ICO" ), false ); // default icon for any module
874 bool cancelled = false;
876 while ( !modName.isEmpty() && !activeStudy() && !cancelled ){
877 LightApp_ModuleDlg aDlg( desktop(), modName, icon );
878 QMap<int, QString> opmap = activateModuleActions();
879 for ( QMap<int, QString>::ConstIterator it = opmap.begin(); it != opmap.end(); ++it )
880 aDlg.addButton( it.value(), it.key() );
882 int res = aDlg.exec();
884 // some operation is selected
885 moduleActionSelected( res );
889 putInfo( tr("INF_CANCELLED") );
891 LightApp_ModuleAction* moduleAction =
892 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
894 moduleAction->setActiveModule( QString() );
900 activateModule( modName );
903 /*!Default module activation.*/
904 QString LightApp_Application::defaultModule() const
906 QStringList aModuleNames;
907 modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration
908 //! If there's the one and only module --> activate it automatically
909 //! TODO: Possible improvement - default module can be taken from preferences
910 return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" );
913 /*!On new window slot.*/
914 void LightApp_Application::onNewWindow()
916 const QObject* obj = sender();
917 if ( !obj || !obj->inherits( "QAction" ) )
921 int id = actionId( (QAction*)obj );
924 #ifndef DISABLE_GLVIEWER
926 type = GLViewer_Viewer::Type();
929 #ifndef DISABLE_PLOT2DVIEWER
931 type = Plot2d_Viewer::Type();
934 #ifndef DISABLE_OCCVIEWER
936 type = OCCViewer_Viewer::Type();
939 #ifndef DISABLE_VTKVIEWER
941 type = VTKViewer_Viewer::Type();
944 #ifndef DISABLE_QXGRAPHVIEWER
945 case NewQxSceneViewId:
946 type = QxScene_Viewer::Type();
949 #ifndef DISABLE_GRAPHICSVIEW
950 case NewGraphicsViewId:
951 type = GraphicsView_Viewer::Type();
954 #ifndef DISABLE_PVVIEWER
956 type = PVViewer_Viewer::Type();
959 #ifndef DISABLE_PYVIEWER
961 type = PyViewer_Viewer::Type();
966 if ( !type.isEmpty() )
967 createViewManager( type );
971 SLOT: Creates new document
973 void LightApp_Application::onNewDoc()
975 #ifdef SINGLE_DESKTOP
976 if ( !checkExistingDoc() )
980 //asl: fix for 0020515
981 saveDockWindowsState();
983 CAM_Application::onNewDoc();
987 SLOT: Opens new document
989 void LightApp_Application::onOpenDoc()
991 SUIT_Study* study = activeStudy();
993 #ifdef SINGLE_DESKTOP
994 if ( !checkExistingDoc() )
998 CAM_Application::onOpenDoc();
1000 if ( !study ) // new study will be create in THIS application
1003 updateViewManagers();
1008 SLOT: Opens new document.
1009 \param aName - name of file
1011 bool LightApp_Application::onOpenDoc( const QString& aName )
1013 #ifdef SINGLE_DESKTOP
1014 if ( !checkExistingDoc() )
1018 saveDockWindowsState();
1020 // We should take mru action first because this application instance can be deleted later.
1021 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
1023 bool res = CAM_Application::onOpenDoc( aName );
1028 mru->insert( aName );
1030 mru->remove( aName );
1036 SLOT: Displays "About" message box
1038 void LightApp_Application::onHelpAbout()
1040 LightApp_AboutDlg dlg( applicationName(), applicationVersion(), desktop() );
1045 Private SLOT: Called on selection is changed
1046 Dispatchs active module that selection is changed
1048 void LightApp_Application::onSelection()
1050 //MESSAGE("onSelection")
1051 onSelectionChanged();
1053 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
1054 ((LightApp_Module*)activeModule())->selectionChanged();
1059 \param study - SUIT_Study.
1061 void LightApp_Application::setActiveStudy( SUIT_Study* study )
1063 CAM_Application::setActiveStudy( study );
1067 Enables/Disables menu items and toolbar buttons. Rebuild menu
1069 void LightApp_Application::updateCommandsStatus()
1071 CAM_Application::updateCommandsStatus();
1074 #ifndef DISABLE_GLVIEWER
1075 a = action( NewGLViewId );
1077 a->setEnabled( activeStudy() );
1080 #ifndef DISABLE_PLOT2DVIEWER
1081 a = action( NewPlot2dId );
1083 a->setEnabled( activeStudy() );
1086 #ifndef DISABLE_OCCVIEWER
1087 a = action( NewOCCViewId );
1089 a->setEnabled( activeStudy() );
1092 #ifndef DISABLE_VTKVIEWER
1093 a = action( NewVTKViewId );
1095 a->setEnabled( activeStudy() );
1098 #ifndef DISABLE_QXGRAPHVIEWER
1099 a = action( NewQxSceneViewId );
1101 a->setEnabled( activeStudy() );
1104 #ifndef DISABLE_GRAPHICSVIEW
1105 a = action( NewGraphicsViewId );
1107 a->setEnabled( activeStudy() );
1110 #ifndef DISABLE_PVVIEWER
1111 a = action( NewPVViewId );
1113 a->setEnabled( activeStudy() );
1116 #ifndef DISABLE_PYVIEWER
1117 a = action( NewPyViewerId );
1119 a->setEnabled( activeStudy() );
1125 Runs system command in separate thread
1127 class RunBrowser: public QThread
1130 RunBrowser( LightApp_Application* app,
1131 const QString& theApp,
1132 const QString& theParams,
1133 const QString& theHelpFile,
1134 const QString& theContext = QString(),
1135 //For the external browser always specify 'file://' protocol,
1136 //because some WEB browsers (for example Mozilla Firefox) can't open local file without protocol.
1137 const QString& theProtocol = QString("file://"),
1138 const bool isFile = true)
1140 myParams( theParams ),
1141 myContext( theContext ),
1145 QString path_begin = theProtocol+"%1";
1146 QString path_end = theHelpFile;
1148 path_end = QFileInfo( theHelpFile ).canonicalFilePath();
1150 myHelpFile = path_begin.arg( path_end );
1155 if ( !myApp.isEmpty() && !myHelpFile.isEmpty()) {
1156 QString aCommand = QString( "%1 %2 \"%3%4\"" ).arg( myApp, myParams, myHelpFile, myContext.isEmpty() ? QString("") : QString( "#%1" ).arg( myContext ) );
1158 QProcess* proc = new QProcess();
1160 proc->start( aCommand );
1161 if ( !proc->waitForStarted() ) {
1162 SALOME_CustomEvent* ce2000 = new SALOME_CustomEvent( 2000 );
1163 QString* msg = new QString( QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).arg( myApp, myHelpFile ) );
1164 ce2000->setData( msg );
1165 QApplication::postEvent( myLApp, ce2000 );
1176 LightApp_Application* myLApp;
1180 SLOT: Displays help contents for choosen module
1182 void LightApp_Application::onHelpContentsModule()
1184 const QAction* a = (QAction*) sender();
1185 QString helpFile = a->data().toString();
1186 if ( helpFile.isEmpty() ) return;
1188 SUIT_ResourceMgr* resMgr = resourceMgr();
1191 platform = "winapplication";
1193 platform = "application";
1195 QString anApp = resMgr->stringValue("ExternalBrowser", platform);
1197 QString quote("\"");
1198 anApp.prepend( quote );
1199 anApp.append( quote );
1201 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
1202 #if DISABLE_QTXWEBBROWSER
1203 bool useExtBrowser = true;
1205 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1208 if( useExtBrowser ) {
1209 if ( !anApp.isEmpty() ) {
1210 RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile );
1214 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1215 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1216 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1218 showPreferences( tr( "PREF_APP" ) );
1222 QStringList parameters;
1223 parameters << QString( "--language=%1" ).arg( resMgr->stringValue( "language", "language" ) );
1224 parameters << QString( "--add=%1" ).arg( QApplication::instance()->applicationPid() );
1225 parameters << helpFile;
1226 QProcess::startDetached( "HelpBrowser", parameters );
1231 SLOT: Displays help contents for choosen dialog
1233 void LightApp_Application::onHelpContextModule( const QString& theComponentName,
1234 const QString& theFileName,
1235 const QString& theContext )
1237 QString fileName = theFileName;
1238 QString context = theContext;
1239 if ( !QFile::exists( fileName ) && theContext.isEmpty() ) {
1240 // context might be passed within theFileName argument
1241 QStringList comps = fileName.split("#");
1242 if ( comps.count() > 1 ) {
1243 context = comps.last();
1245 fileName = comps.join("#");
1249 QString homeDir = "";
1250 if ( !theComponentName.isEmpty() ) {
1251 QString dir = getenv( ( theComponentName + "_ROOT_DIR" ).toLatin1().constData() );
1252 if ( !dir.isEmpty() )
1253 homeDir = Qtx::addSlash( Qtx::addSlash( dir ) +
1254 Qtx::addSlash( "share" ) +
1255 Qtx::addSlash( "doc" ) +
1256 Qtx::addSlash( "salome" ) +
1257 Qtx::addSlash( "gui" ) +
1258 Qtx::addSlash( theComponentName ) );
1261 QString helpFile = QFileInfo( homeDir + fileName ).absoluteFilePath();
1262 SUIT_ResourceMgr* resMgr = resourceMgr();
1265 platform = "winapplication";
1267 platform = "application";
1269 QString anApp = resMgr->stringValue("ExternalBrowser", platform);
1271 QString quote("\"");
1272 anApp.prepend( quote );
1273 anApp.append( quote );
1276 #if DISABLE_QTXWEBBROWSER
1277 bool useExtBrowser = true;
1279 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1283 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
1285 if ( !anApp.isEmpty() ) {
1286 RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile, context );
1290 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1291 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1292 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1293 showPreferences( tr( "PREF_APP" ) );
1297 QStringList parameters;
1298 parameters << QString( "--language=%1" ).arg( resMgr->stringValue( "language", "language" ) );
1299 parameters << QString( "--add=%1" ).arg( QApplication::instance()->applicationPid() );
1300 parameters << QString( "%1#%2" ).arg( helpFile ).arg( context );
1301 QProcess::startDetached( "HelpBrowser", parameters );
1306 SLOT: Displays help contents for choosen module
1308 void LightApp_Application::onHelpOnline()
1310 const QAction* a = (QAction*) sender();
1311 QString url = a->data().toString();
1312 if ( url.isEmpty() ) return;
1314 SUIT_ResourceMgr* resMgr = resourceMgr();
1317 platform = "winapplication";
1319 platform = "application";
1321 QString anApp = resMgr->stringValue("ExternalBrowser", platform);
1323 QString quote("\"");
1324 anApp.prepend( quote );
1325 anApp.append( quote );
1327 QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
1328 #if DISABLE_QTXWEBBROWSER
1329 bool useExtBrowser = true;
1331 bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
1334 if( useExtBrowser ) {
1335 if ( !anApp.isEmpty() ) {
1336 RunBrowser* rs = new RunBrowser( this, anApp, aParams, url, "", "http://", false );
1340 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
1341 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
1342 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
1344 showPreferences( tr( "PREF_APP" ) );
1348 QStringList parameters;
1349 parameters << QString( "--language=%1" ).arg( resMgr->stringValue( "language", "language" ) );
1350 parameters << QString( "--add=%1" ).arg( QApplication::instance()->applicationPid() );
1351 parameters << "http://" + url;
1352 QProcess::startDetached( "HelpBrowser", parameters );
1357 Sets enable or disable some actions on selection changed.
1359 void LightApp_Application::onSelectionChanged()
1361 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
1362 bool canCopy = m ? m->canCopy() : false;
1363 bool canPaste = m ? m->canPaste() : false;
1365 action( EditCopyId )->setEnabled(canCopy);
1366 action( EditPasteId )->setEnabled(canPaste);
1370 SLOT: Performs some actions when dockable windows are triggered
1372 void LightApp_Application::onDockWindowVisibilityChanged( bool )
1376 QWidget* LightApp_Application::dockWindow( const int id ) const
1379 if ( myWin.contains( id ) )
1384 QDockWidget* LightApp_Application::windowDock( QWidget* wid ) const
1389 QDockWidget* dock = 0;
1390 QWidget* w = wid->parentWidget();
1391 while ( w && !dock )
1393 dock = ::qobject_cast<QDockWidget*>( w );
1394 w = w->parentWidget();
1399 void LightApp_Application::insertDockWindow( const int id, QWidget* wid )
1404 if ( wid != dockWindow( id ) )
1405 removeDockWindow( id );
1407 myWin.insert( id, wid );
1409 QtxDockWidget* dock = new QtxDockWidget( true, desktop() );
1410 connect( dock, SIGNAL( destroyed( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
1412 dock->setFeatures( QDockWidget::AllDockWidgetFeatures );
1413 dock->setObjectName( wid->objectName().isEmpty() ? QString( "window_%1" ).arg( id ) :
1414 QString( "%1Dock" ).arg( wid->objectName() ) );
1415 dock->setWidget( wid );
1416 dock->toggleViewAction()->setData( QVariant( wid->objectName() ) );
1417 connect( dock->toggleViewAction(), SIGNAL( triggered( bool ) ),
1418 this, SLOT( onDockWindowVisibilityChanged( bool ) ) );
1420 QKeySequence accel = wid->property( "shortcut" ).value<QKeySequence>();
1421 if ( !accel.isEmpty() )
1422 dock->toggleViewAction()->setShortcut( accel );
1427 void LightApp_Application::removeDockWindow( const int id )
1429 QWidget* wid = dockWindow( id );
1435 QDockWidget* dock = windowDock( wid );
1439 dock->setWidget( 0 );
1440 wid->setParent( 0 );
1441 wid->setVisible( false );
1445 void LightApp_Application::placeDockWindow( const int id, Qt::DockWidgetArea place )
1447 QDockWidget* dock = windowDock( dockWindow( id ) );
1448 if ( dock && desktop() ) {
1449 desktop()->addDockWidget( place, dock );
1450 QtxDockAction* a = qobject_cast<QtxDockAction*>( action( ViewWindowsId ) );
1451 if ( a ) a->update();
1457 \param flag - key for window
1458 \param studyId - study id
1459 Flag used how identificator of window in windows list.
1461 QWidget* LightApp_Application::getWindow( const int flag, const int )
1463 QWidget* wid = dockWindow( flag );
1465 insertDockWindow( flag, wid = createWindow( flag ) );
1467 QMap<int, int> winMap;
1468 currentWindows( winMap );
1469 if ( winMap.contains( flag ) )
1470 placeDockWindow( flag, (Qt::DockWidgetArea)winMap[flag] );
1476 \return Object Browser
1478 SUIT_DataBrowser* LightApp_Application::objectBrowser()
1480 return qobject_cast<SUIT_DataBrowser*>( dockWindow( WT_ObjectBrowser ) );
1486 LogWindow* LightApp_Application::logWindow()
1488 return qobject_cast<LogWindow*>( dockWindow( WT_LogWindow ) );
1491 #ifndef DISABLE_PYCONSOLE
1493 This returns the python console integrated to the GUI. Depending
1494 when you request the python console, this function could return
1495 null. Then the optional parameter force (default to false) can be
1496 set to force the creation of the python console if it is not done
1498 \param force - if true, the pythonConsole is created if it does not exist yet
1499 \return Python Console
1501 PyConsole_Console* LightApp_Application::pythonConsole(const bool force)
1503 QWidget* wid = dockWindow( WT_PyConsole );
1504 if ( !wid && force==true) {
1505 wid = getWindow(WT_PyConsole);
1507 return qobject_cast<PyConsole_Console*>( wid );
1512 Updates object browser and maybe data models
1513 \param updateModels - if it is true, then data models are updated
1515 void LightApp_Application::updateObjectBrowser( const bool updateModels )
1517 // update existing data models
1520 const bool isAutoUpdate = objectBrowser() ? objectBrowser()->autoUpdate() : true;
1521 if ( objectBrowser() )
1522 objectBrowser()->setAutoUpdate( false );
1524 LightApp_Study* study = dynamic_cast<LightApp_Study*>(activeStudy());
1526 CAM_Study::ModelList dm_list;
1527 study->dataModels( dm_list );
1528 QListIterator<CAM_DataModel*> it( dm_list );
1529 while ( it.hasNext() ) {
1530 CAM_DataModel* camDM = it.next();
1531 if ( camDM && camDM->inherits( "LightApp_DataModel" ) )
1532 ((LightApp_DataModel*)camDM)->update();
1536 if( objectBrowser() )
1537 objectBrowser()->setAutoUpdate( isAutoUpdate );
1540 if ( objectBrowser() ) {
1541 objectBrowser()->updateGeometry();
1542 objectBrowser()->updateTree( 0, false );
1549 LightApp_Preferences* LightApp_Application::preferences() const
1551 return preferences( false );
1555 \return first view manager of some type
1556 \param vmType - type of view manager
1557 \param create - is it necessary to create view manager in case, when there is no manager of such type
1559 SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, const bool create )
1561 SUIT_ViewManager* aVM = viewManager( vmType );
1562 SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
1563 MESSAGE("vmType: " << vmType.toStdString() << " aVM: " << aVM << " anActiveVM: " << anActiveVM );
1564 if ( anActiveVM && anActiveVM->getType() == vmType )
1566 MESSAGE("aVM = anActiveVM");
1570 if ( aVM && !aVM->getDetached() && create )
1572 if ( !aVM->getActiveView() )
1574 MESSAGE("aVM->createView()");
1579 MESSAGE("desktop()->setActiveWindow: " << aVM->getActiveView());
1580 desktop()->setActiveWindow( aVM->getActiveView() );
1585 MESSAGE("aVM = createViewManager( vmType )");
1586 aVM = createViewManager( vmType );
1593 Creates view manager of some type
1594 \param vmType - type of view manager
1596 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, bool detached )
1598 SUIT_ResourceMgr* resMgr = resourceMgr();
1600 SUIT_ViewManager* viewMgr = 0;
1601 #ifndef DISABLE_GLVIEWER
1602 if( vmType == GLViewer_Viewer::Type() )
1604 viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() );
1605 new LightApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
1608 #ifndef DISABLE_PLOT2DVIEWER
1609 if( vmType == Plot2d_Viewer::Type() )
1611 viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
1613 #ifndef DISABLE_SALOMEOBJECT
1614 SPlot2d_Viewer* v = new SPlot2d_Viewer();
1616 new LightApp_Plot2dSelector( v, mySelMgr );
1618 vm = new Plot2d_Viewer();
1620 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1621 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
1624 Plot2d_ViewFrame* frame = wnd->getViewFrame();
1625 frame->setBackgroundColor( resMgr->colorValue( "Plot2d", "Background", frame->backgroundColor() ) );
1629 #ifndef DISABLE_QXGRAPHVIEWER
1630 if( vmType == QxScene_Viewer::Type() )
1632 viewMgr = new QxScene_ViewManager( activeStudy(), desktop() );
1633 QxScene_Viewer* vm = new QxScene_Viewer();
1634 viewMgr->setViewModel( vm );
1635 //QxScene_ViewWindow* wnd = dynamic_cast<QxScene_ViewWindow*>( viewMgr->getActiveView() );
1638 #ifndef DISABLE_GRAPHICSVIEW
1639 if( vmType == GraphicsView_Viewer::Type() )
1641 viewMgr = new GraphicsView_ViewManager( activeStudy(), desktop() );
1642 new LightApp_GVSelector( (GraphicsView_Viewer*)viewMgr->getViewModel(), mySelMgr );
1645 #ifndef DISABLE_PVVIEWER
1646 if( vmType == PVViewer_Viewer::Type() )
1648 if (( viewMgr = dynamic_cast<PVViewer_ViewManager*>( getViewManager( vmType, false )))) {
1649 viewMgr->getActiveView()->setFocus();
1652 viewMgr = new PVViewer_ViewManager( activeStudy(), desktop(), logWindow() );
1656 #ifndef DISABLE_PYVIEWER
1657 if( vmType == PyViewer_Viewer::Type() )
1659 viewMgr = new PyViewer_ViewManager( activeStudy(), desktop() );
1662 #ifndef DISABLE_OCCVIEWER
1663 if( vmType == OCCViewer_Viewer::Type() )
1665 viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
1666 OCCViewer_Viewer* vm;
1667 #ifndef DISABLE_SALOMEOBJECT
1668 vm = new SOCC_Viewer();
1670 vm = new OCCViewer_Viewer( true );
1672 vm->setBackground( OCCViewer_ViewFrame::TOP_LEFT,
1673 resMgr->backgroundValue( "OCCViewer", "xz_background", vm->background(OCCViewer_ViewFrame::TOP_LEFT) ) );
1674 vm->setBackground( OCCViewer_ViewFrame::TOP_RIGHT,
1675 resMgr->backgroundValue( "OCCViewer", "yz_background", vm->background(OCCViewer_ViewFrame::TOP_RIGHT) ) );
1676 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_LEFT,
1677 resMgr->backgroundValue( "OCCViewer", "xy_background", vm->background(OCCViewer_ViewFrame::BOTTOM_LEFT) ) );
1678 vm->setBackground( OCCViewer_ViewFrame::BOTTOM_RIGHT,
1679 resMgr->backgroundValue( "OCCViewer", "background", vm->background(OCCViewer_ViewFrame::MAIN_VIEW) ) );
1681 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1682 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ));
1683 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1684 vm->setProjectionType( resMgr->integerValue( "OCCViewer", "projection_mode", vm->projectionType() ) );
1685 vm->setStereoType( resMgr->integerValue( "OCCViewer", "stereo_type", vm->stereoType() ) );
1686 vm->setAnaglyphFilter( resMgr->integerValue( "OCCViewer", "anaglyph_filter", vm->anaglyphFilter() ) );
1687 vm->setStereographicFocus( resMgr->integerValue( "OCCViewer", "focus_type", vm->stereographicFocusType() ),
1688 resMgr->doubleValue( "OCCViewer", "focus_value", vm->stereographicFocusValue() ));
1689 vm->setInterocularDistance( resMgr->integerValue( "OCCViewer", "iod_type", vm->interocularDistanceType() ),
1690 resMgr->doubleValue( "OCCViewer", "iod_value", vm->interocularDistanceValue() ));
1692 vm->setReverseStereo( resMgr->booleanValue( "OCCViewer", "reverse_stereo", vm->isReverseStereo() ) );
1693 vm->setVSync( resMgr->booleanValue( "OCCViewer", "enable_vsync", vm->isVSync() ) );
1694 vm->setQuadBufferSupport( resMgr->booleanValue( "OCCViewer", "enable_quad_buffer_support", vm->isQuadBufferSupport() ) );
1695 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1696 vm->enablePreselection( resMgr->booleanValue( "OCCViewer", "enable_preselection", vm->isPreselectionEnabled() ) );
1697 vm->enableSelection( resMgr->booleanValue( "OCCViewer", "enable_selection", vm->isSelectionEnabled() ) );
1698 vm->setClippingColor( resMgr->colorValue( "OCCViewer", "clipping_color", vm->clippingColor() ) );
1699 vm->setClippingTextureParams( resMgr->booleanValue( "OCCViewer", "clipping_use_default_texture", vm->isDefaultTextureUsed() ),
1700 resMgr->stringValue( "OCCViewer", "clipping_texture", vm->clippingTexture() ),
1701 resMgr->booleanValue( "OCCViewer", "clipping_modulate", vm->isTextureModulated() ),
1702 resMgr->doubleValue( "OCCViewer", "clipping_scale", vm->clippingTextureScale() ) );
1705 viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
1706 new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
1709 #ifndef DISABLE_VTKVIEWER
1710 #ifndef DISABLE_SALOMEOBJECT
1711 if ( vmType == SVTK_Viewer::Type() )
1713 if ( vmType == VTKViewer_Viewer::Type() )
1716 #ifndef DISABLE_SALOMEOBJECT
1717 viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
1718 SVTK_Viewer* vm = dynamic_cast<SVTK_Viewer*>( viewMgr->getViewModel() );
1721 vm->setProjectionMode( resMgr->integerValue( "VTKViewer", "projection_mode", vm->projectionMode() ) );
1722 vm->setStereoType( resMgr->integerValue( "VTKViewer", "stereo_type", vm->stereoType() ) );
1723 vm->setAnaglyphFilter( resMgr->integerValue( "VTKViewer", "anaglyph_filter", vm->anaglyphFilter() ) );
1724 vm->setQuadBufferSupport( resMgr->booleanValue( "VTKViewer", "enable_quad_buffer_support", vm->isQuadBufferSupport() ) );
1725 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1726 vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ),
1727 resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ) );
1728 vm->setStaticTrihedronVisible( resMgr->booleanValue( "3DViewer", "show_static_trihedron", vm->isStaticTrihedronVisible() ) );
1729 vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
1730 vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
1731 vm->setPreSelectionMode(resMgr->integerValue( "VTKViewer", "preselection", vm->preSelectionMode() ) );
1732 vm->enableSelection( resMgr->booleanValue( "VTKViewer", "enable_selection", vm->isSelectionEnabled() ) );
1733 vm->setIncrementalSpeed( resMgr->integerValue( "VTKViewer", "speed_value", vm->incrementalSpeed() ),
1734 resMgr->integerValue( "VTKViewer", "speed_mode", vm->incrementalSpeedMode() ) );
1735 vm->setSpacemouseButtons( resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", vm->spacemouseBtn(1) ),
1736 resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", vm->spacemouseBtn(2) ),
1737 resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", vm->spacemouseBtn(3) ) );
1738 new LightApp_VTKSelector( vm, mySelMgr );
1741 viewMgr = new VTKViewer_ViewManager( activeStudy(), desktop() );
1742 VTKViewer_Viewer* vm = dynamic_cast<VTKViewer_Viewer*>( viewMgr->getViewModel() );
1744 vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
1752 viewMgr->setDetached(detached);
1753 addViewManager( viewMgr );
1754 SUIT_ViewWindow* viewWin = viewMgr->createViewWindow();
1756 if ( viewWin && desktop() ) {
1757 viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1758 viewWin->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1764 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, QWidget* w )
1766 SUIT_ResourceMgr* resMgr = resourceMgr();
1768 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
1770 new LightApp_WgViewModel( vmType, w ) );
1771 vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
1773 addViewManager( vm );
1774 SUIT_ViewWindow* vw = vm->createViewWindow();
1775 if ( vw && desktop() ) {
1776 vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1777 vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1780 if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
1781 myUserWmTypes << vmType;
1786 SUIT_ViewManager* LightApp_Application::createViewManager( SUIT_ViewModel* theModel )
1788 SUIT_ResourceMgr* resMgr = resourceMgr();
1790 SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
1794 QString vmType = vm->getType();
1796 vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
1798 addViewManager( vm );
1799 SUIT_ViewWindow* vw = vm->createViewWindow();
1800 if ( vw && desktop() ) {
1801 vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
1802 vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
1805 if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
1806 myUserWmTypes << vmType;
1812 SLOT: Removes view manager from application
1814 void LightApp_Application::onCloseView( SUIT_ViewManager* theVM )
1816 removeViewManager( theVM );
1820 Protected SLOT: On study created.
1821 \param theStudy - just created study
1823 void LightApp_Application::onStudyCreated( SUIT_Study* theStudy )
1825 SUIT_DataObject* aRoot = 0;
1826 if ( theStudy && theStudy->root() )
1828 aRoot = theStudy->root();
1829 //aRoot->setName( tr( "DATA_MODELS" ) );
1832 getWindow( WT_ObjectBrowser );
1834 loadDockWindowsState();
1836 if ( objectBrowser() )
1837 objectBrowser()->setRoot( aRoot );
1839 activateModule( defaultModule() );
1841 if ( objectBrowser() )
1842 objectBrowser()->openLevels();
1844 #ifndef DISABLE_PYCONSOLE
1845 if( pythonConsole() )
1846 getPyInterp()->initStudy();
1851 Protected SLOT: On study opened.
1852 \param theStudy - just opened study
1854 void LightApp_Application::onStudyOpened( SUIT_Study* theStudy )
1856 SUIT_DataObject* aRoot = 0;
1857 if ( theStudy && theStudy->root() )
1859 aRoot = theStudy->root();
1863 getWindow( WT_ObjectBrowser );
1865 loadDockWindowsState();
1867 if ( objectBrowser() )
1868 objectBrowser()->setRoot( aRoot );
1870 activateModule( defaultModule() );
1872 if ( objectBrowser() )
1873 objectBrowser()->openLevels();
1875 #ifndef DISABLE_PYCONSOLE
1876 if( pythonConsole() )
1877 getPyInterp()->initStudy();
1883 /*!Protected SLOT. On study saved.*/
1884 void LightApp_Application::onStudySaved( SUIT_Study* s )
1886 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
1888 mru->insert( s->studyName() );
1893 /*!Protected SLOT. On study closed.*/
1894 void LightApp_Application::onStudyClosed( SUIT_Study* s )
1897 disconnect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
1898 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
1901 // stop auto-save timer
1902 myAutoSaveTimer->stop();
1904 // Bug 10396: clear selection
1905 mySelMgr->clearSelected();
1907 // Bug 12944: emit signal only after clear selection
1910 activateModule( "" );
1913 /*!Protected SLOT.On desktop activated.*/
1914 void LightApp_Application::onDesktopActivated()
1916 CAM_Application::onDesktopActivated();
1917 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>(activeModule());
1919 aModule->studyActivated();
1922 void LightApp_Application::studyOpened( SUIT_Study* s )
1924 CAM_Application::studyOpened( s );
1927 updateViewManagers();
1930 void LightApp_Application::studySaved( SUIT_Study* s )
1932 CAM_Application::studyOpened( s );
1933 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
1934 if ( aResMgr && activeStudy() ) {
1935 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
1936 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
1940 void LightApp_Application::studyCreated( SUIT_Study* s )
1942 CAM_Application::studyCreated( s );
1945 updateViewManagers();
1948 /*!Gets file filter.
1949 *\retval QString "(*.hdf)"
1951 QString LightApp_Application::getFileFilter( bool /*open*/) const
1957 Shows file dialog and return user selected file name
1959 QString LightApp_Application::getFileName( bool open, const QString& initial, const QString& filters,
1960 const QString& caption, QWidget* parent )
1964 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1965 return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
1968 /*! Gets directory*/
1969 QString LightApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
1973 return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true );
1976 /*! Get open file names*/
1977 QStringList LightApp_Application::getOpenFileNames( const QString& initial, const QString& filters,
1978 const QString& caption, QWidget* parent )
1982 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
1983 return SUIT_FileDlg::getOpenFileNames( parent, initial, fls, caption, true );
1986 /*!Private SLOT. Update object browser.*/
1987 void LightApp_Application::onRefresh()
1989 updateObjectBrowser( true );
1992 /*!Private SLOT. Update actions after rename object.*/
1993 void LightApp_Application::onRenamed()
1995 activeStudy()->Modified();
1999 // IMN 08.07.2015 : issue 002556: Some stereo outputs are affected by window position.
2000 // To prevent reversion the window should be either aligned during movement and resize.
2001 /*!Private SLOT. Update actions after rename object.*/
2002 /*void LightApp_Application::onMoved()
2004 OCCViewer_ViewManager* viewMgr = 0;
2005 viewMgr = dynamic_cast<OCCViewer_ViewManager*>( getViewManager( OCCViewer_Viewer::Type(), false ) );
2007 OCCViewer_ViewWindow* view = 0;
2008 view = dynamic_cast<OCCViewer_ViewWindow*>( viewMgr->getActiveView() );
2010 view->getViewPort()->repaintViewAfterMove();
2015 /*!Private SLOT. Support drag-and-drop operation.*/
2016 void LightApp_Application::onDropped( const QList<SUIT_DataObject*>& objects, SUIT_DataObject* parent, int row, Qt::DropAction action )
2018 LightApp_DataObject* parentObj = dynamic_cast<LightApp_DataObject*>( parent );
2022 LightApp_Module* aModule = dynamic_cast<LightApp_Module*>( parentObj->module() );
2024 aModule->dropObjects( objects, parentObj, row, action );
2027 /*!Private SLOT. On preferences.*/
2028 void LightApp_Application::onPreferences()
2030 showPreferences( activeModule() ? activeModule()->moduleName() : tr( "PREF_CATEGORY_SALOME" ) );
2033 /*!Private SLOT. On preferences.*/
2034 void LightApp_Application::showPreferences( const QString& itemText )
2036 QApplication::setOverrideCursor( Qt::WaitCursor );
2038 LightApp_PreferencesDlg* prefDlg = new LightApp_PreferencesDlg( preferences( true ), desktop());
2040 QApplication::restoreOverrideCursor();
2045 preferences()->activateItem( itemText );
2047 if ( ( prefDlg->exec() == QDialog::Accepted || prefDlg->isSaved() ) && resourceMgr() )
2050 resourceMgr()->setValue( "desktop", "geometry", desktop()->storeGeometry() );
2051 resourceMgr()->save();
2054 shortcutMgr()->updateShortcuts();
2060 /*!Protected SLOT. On preferences changed.*/
2061 void LightApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param )
2063 LightApp_Module* sMod = 0;
2064 CAM_Module* mod = module( modName );
2065 if ( mod && mod->inherits( "LightApp_Module" ) )
2066 sMod = (LightApp_Module*)mod;
2069 sMod->preferencesChanged( section, param );
2071 preferencesChanged( section, param );
2072 // emit signal to allow additional preferences changing processing
2073 emit preferenceChanged( modName, section, param );
2076 /*!Remove all windows from study.*/
2077 void LightApp_Application::beforeCloseDoc( SUIT_Study* s )
2079 saveDockWindowsState();
2081 if ( SUIT_DataBrowser* ob = objectBrowser() )
2084 CAM_Application::beforeCloseDoc( s );
2087 /*!Update actions.*/
2088 void LightApp_Application::updateActions()
2090 updateCommandsStatus();
2096 SUIT_Study* LightApp_Application::createNewStudy()
2098 LightApp_Application::lastStudyId++;
2100 LightApp_Study* aStudy = new LightApp_Study( this );
2102 // Set up processing of major study-related events
2103 connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
2104 connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
2105 connect( aStudy, SIGNAL( saved ( SUIT_Study* ) ), this, SLOT( onStudySaved ( SUIT_Study* ) ) );
2106 connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
2112 Creates window by flag.
2113 \param flag - identificator of window type
2115 QWidget* LightApp_Application::createWindow( const int flag )
2119 SUIT_ResourceMgr* resMgr = resourceMgr();
2121 if ( flag == WT_ObjectBrowser )
2123 SUIT_DataBrowser* ob = new SUIT_DataBrowser( new LightApp_DataObject(), desktop() );
2124 ob->setObjectName( "objectBrowser" );
2125 ob->setSortMenuEnabled( true );
2126 ob->setAutoUpdate( true );
2127 if ( resMgr->hasValue( "ObjectBrowser", "auto_hide_search_tool" ) )
2128 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
2130 //ob->setAutoOpenLevel( 1 ); // commented by ASV as a fix to bug IPAL10107
2131 ob->setWindowTitle( tr( "OBJECT_BROWSER" ) );
2132 connect( ob, SIGNAL( requestUpdate() ), this, SLOT( onRefresh() ) );
2134 QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
2135 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
2136 treeModel->setSearcher( this );
2137 treeModel->registerColumn( 0, EntryCol, LightApp_DataObject::EntryId );
2138 treeModel->setAppropriate( EntryCol, Qtx::Toggled );
2140 // Mantis issue 0020136: Drag&Drop in OB
2141 SUIT_ProxyModel* proxyModel = dynamic_cast<SUIT_ProxyModel*>(treeModel);
2143 connect( proxyModel, SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
2144 this, SLOT( onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
2145 connect( proxyModel, SIGNAL( renamed( SUIT_DataObject* ) ),
2146 this, SLOT( onRenamed( ) ) );
2150 // temporary commented
2152 OB_ListView* ob_list = dynamic_cast<OB_ListView*>( const_cast<QListView*>( ob->listView() ) );
2154 ob_list->setColumnMaxWidth( 0, desktop()->width()/4 );
2157 // Create OBSelector
2158 new LightApp_OBSelector( ob, mySelMgr );
2159 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
2160 ob->treeView()->header()->setResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
2162 ob->treeView()->header()->setSectionResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
2164 ob->treeView()->header()->moveSection(SUIT_DataObject::NameId,SUIT_DataObject::VisibilityId);
2165 ob->treeView()->setColumnWidth(SUIT_DataObject::VisibilityId, VISIBILITY_COLUMN_WIDTH);
2166 ob->setProperty( "shortcut", QKeySequence( "Alt+Shift+O" ) );
2168 ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
2170 #ifndef DISABLE_PYCONSOLE
2171 else if ( flag == WT_PyConsole )
2173 PyConsole_Console* pyCons = new PyConsole_Console( desktop(), new LightApp_PyEditor( getPyInterp() ) );
2174 pyCons->setObjectName( "pythonConsole" );
2175 pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
2176 pyCons->setFont( resMgr->fontValue( "PyConsole", "font" ) );
2177 pyCons->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
2178 pyCons->setAutoCompletion( resMgr->booleanValue( "PyConsole", "auto_completion", true ) );
2179 pyCons->setProperty( "shortcut", QKeySequence( "Alt+Shift+P" ) );
2183 else if ( flag == WT_LogWindow )
2185 LogWindow* logWin = new LogWindow( desktop() );
2186 logWin->setObjectName( "logWindow" );
2187 logWin->setWindowTitle( tr( "LOG_WINDOW" ) );
2188 logWin->setProperty( "shortcut", QKeySequence( "Alt+Shift+L" ) );
2190 logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
2196 \return default windows( Object Browser, Python Console )
2197 Adds to map \a aMap.
2199 void LightApp_Application::defaultWindows( QMap<int, int>& aMap ) const
2201 #ifndef DISABLE_PYCONSOLE
2202 aMap.insert( WT_PyConsole, Qt::BottomDockWidgetArea );
2204 if ( activeStudy() ) {
2205 aMap.insert( WT_ObjectBrowser, Qt::LeftDockWidgetArea );
2206 // aMap.insert( WT_LogWindow, Qt::DockBottom );
2210 /*!Default view managers*/
2211 void LightApp_Application::defaultViewManagers( QStringList& ) const
2217 \return preferences.
2218 Create preferences, if \a crt = true.
2220 LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const
2225 LightApp_Application* that = (LightApp_Application*)this;
2227 bool toCreate = !_prefs_ && crt;
2230 _prefs_ = new LightApp_Preferences( resourceMgr() );
2231 that->createPreferences( _prefs_ );
2232 qAddPostRoutine( LightAppCleanUpAppResources );
2235 that->myPrefs = _prefs_;
2237 connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
2238 this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ), Qt::UniqueConnection );
2239 connect( myPrefs, SIGNAL( resetToDefaults() ),
2240 this, SIGNAL( preferenceResetToDefaults() ), Qt::UniqueConnection );
2245 SUIT_ResourceMgr* resMgr = resourceMgr();
2247 QList<SUIT_Application*> appList = SUIT_Session::session()->applications();
2248 for ( QList<SUIT_Application*>::iterator appIt = appList.begin(); appIt != appList.end(); ++appIt )
2250 LightApp_Application* app = ::qobject_cast<LightApp_Application*>( *appIt );
2254 QStringList modNameList;
2255 app->modules( modNameList, false );
2257 QMap<QString, QString> iconMap;
2258 app->moduleIconNames( iconMap );
2260 for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it )
2262 if ( !app->isModuleAccessible( *it ) || _prefs_->hasModule( *it ) )
2265 int modId = _prefs_->addPreference( *it );
2266 if ( iconMap.contains( *it ) )
2267 _prefs_->setItemIcon( modId, Qtx::scaleIcon( resMgr->loadPixmap( moduleName( *it ), iconMap[*it], false ), 20 ) );
2271 app->modules( modList );
2272 QListIterator<CAM_Module*> itr( modList );
2273 while ( itr.hasNext() )
2275 LightApp_Module* mod = 0;
2277 CAM_Module* anItem = itr.next();
2278 if ( anItem->inherits( "LightApp_Module" ) )
2279 mod = (LightApp_Module*)anItem;
2281 if ( mod && !_prefs_->hasModule( mod->moduleName() ) )
2283 _prefs_->addPreference( mod->moduleName() );
2284 mod->createPreferences();
2285 that->emptyPreferences( mod->moduleName() );
2289 _prefs_->setItemProperty( "info", tr( "PREFERENCES_NOT_LOADED" ) );
2295 Adds new module to application
2297 void LightApp_Application::moduleAdded( CAM_Module* mod )
2299 CAM_Application::moduleAdded( mod );
2301 LightApp_Module* lightMod = 0;
2302 if ( mod && mod->inherits( "LightApp_Module" ) )
2303 lightMod = (LightApp_Module*)mod;
2305 if ( myPrefs && lightMod && !myPrefs->hasModule( lightMod->moduleName() ))
2307 myPrefs->addPreference( mod->moduleName() );
2308 lightMod->createPreferences();
2309 emptyPreferences( mod->moduleName() );
2313 void LightApp_Application::emptyPreferences( const QString& modName )
2315 QtxPreferenceItem* item = myPrefs->findItem( modName, true );
2316 if ( !item || !item->isEmpty() )
2319 // printf( "---------------------> Modify for empty module.\n" );
2321 QtxPagePrefFrameItem* frm = new QtxPagePrefFrameItem( item->title(), item->parentItem() );
2322 frm->setIcon( item->icon() );
2323 frm->setStretch( false );
2324 item->parentItem()->insertItem( frm, item );
2325 new QtxPagePrefLabelItem( Qt::AlignCenter, tr( "PREFERENCES_NOT_SUPPORTED" ).arg( modName ), frm );
2332 void LightApp_Application::createPreferences( LightApp_Preferences* pref )
2337 QStringList aValuesList;
2338 QList<QVariant> anIndicesList;
2342 // . Top-level "SALOME" preferences group <<start>>
2343 int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
2344 pref->setItemIcon( salomeCat, Qtx::scaleIcon( resourceMgr()->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false ), 20 ) );
2346 // .. "General" preferences tab <<start>>
2347 int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat );
2349 // ... "Language" group <<start>>
2350 int langGroup = pref->addPreference( tr( "PREF_GROUP_LANGUAGE" ), genTab );
2351 pref->setItemProperty( "columns", 2, langGroup );
2352 // .... -> application language
2353 int curLang = pref->addPreference( tr( "PREF_CURRENT_LANGUAGE" ), langGroup,
2354 LightApp_Preferences::Selector, "language", "language" );
2355 QStringList aLangs = SUIT_Session::session()->resourceMgr()->stringValue( "language", "languages", "en" ).split( "," );
2356 QList<QVariant> aIcons;
2357 QList<QVariant> aNumbers;
2358 QStringList aTitles;
2359 foreach ( QString aLang, aLangs ) {
2360 aIcons << QPixmap( QString( ":/images/%1" ).arg( aLang ) );
2362 aTitles << langToName( aLang );
2364 pref->setItemProperty( "strings", aTitles, curLang );
2365 pref->setItemProperty( "ids", aNumbers, curLang );
2366 pref->setItemProperty( "icons", aIcons, curLang );
2367 pref->setItemProperty( "restart", true, curLang );
2369 int curLocale = pref->addPreference( tr( "PREF_CURRENT_LOCALE" ), langGroup,
2370 LightApp_Preferences::Bool, "language", "locale" );
2371 pref->setItemProperty( "restart", true, curLocale );
2372 // ... "Language" group <<end>>
2374 // ... "Look and feel" group <<start>>
2375 int lookGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), genTab );
2376 pref->setItemProperty( "columns", 2, lookGroup );
2377 // .... -> show splash-screen
2378 pref->addPreference( tr( "PREF_SHOW_SPLASH" ), lookGroup, LightApp_Preferences::Bool, "launch", "splash" );
2379 // .... -> opaque resize
2380 pref->addPreference( tr( "PREF_OPAQUE_RESIZE" ), lookGroup, LightApp_Preferences::Bool, "desktop", "opaque_resize" );
2381 // .... -> drop-down buttons
2382 pref->addPreference( tr( "PREF_DROP_DOWN_BUTTONS" ), lookGroup, LightApp_Preferences::Bool, "viewers", "drop_down_buttons" );
2383 // ... "Look and feel" group <<end>>
2385 // ... "Study properties" group <<start>>
2386 int studyGroup = pref->addPreference( tr( "PREF_GROUP_STUDY" ), genTab );
2387 pref->setItemProperty( "columns", 2, studyGroup );
2388 // .... -> multi-file save
2389 pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "multi_file" );
2390 // .... -> ascii save mode
2391 pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" );
2392 // .... -> store windows geometry
2393 pref->addPreference( tr( "PREF_LOAD_LIGHT" ), studyGroup, LightApp_Preferences::Bool, "Study", "autoload_light_modules" );
2394 pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" );
2395 pref->addPreference( "", studyGroup, LightApp_Preferences::Space );
2396 pref->addPreference( tr( "PREF_STORE_TOOL_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_tool_positions" );
2397 // .... -> auto-save
2398 int autoSaveInterval = pref->addPreference( tr( "PREF_AUTO_SAVE" ), studyGroup,
2399 LightApp_Preferences::IntSpin, "Study", "auto_save_interval" );
2400 pref->setItemProperty( "min", 0, autoSaveInterval );
2401 pref->setItemProperty( "max", 1440, autoSaveInterval );
2402 pref->setItemProperty( "special", tr( "PREF_AUTO_SAVE_DISABLED" ), autoSaveInterval );
2403 // ... "Study properties" group <<end>>
2405 // ... "Help browser" group <<start>>
2406 #ifndef DISABLE_QTXWEBBROWSER
2407 int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab, LightApp_Preferences::Auto, "ExternalBrowser", "use_external_browser");
2409 int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab );
2413 QString platform = "winapplication";
2415 QString platform = "application";
2417 // .... -> browser application
2418 int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, LightApp_Preferences::File, "ExternalBrowser", platform );
2419 pref->setItemProperty( "mode", Qtx::PT_OpenFile, apppref );
2420 // .... -> browser parameters
2421 pref->addPreference( tr( "PREF_PARAM" ), extgroup, LightApp_Preferences::String, "ExternalBrowser", "parameters" );
2422 // ... "Help browser" group <<end>>
2424 // ... "Python console properties" group <<start>>
2425 int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab );
2426 pref->setItemProperty( "columns", 2, pythonConsoleGroup );
2428 pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, LightApp_Preferences::Font, "PyConsole", "font" );
2429 // .... -> show banner
2430 pref->addPreference( tr( "PREF_SHOW_BANNER" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "show_banner" );
2431 // .... -> auto-completion
2432 pref->addPreference( tr( "PREF_AUTO_COMPLETION" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "auto_completion" );
2433 // ... "Python console properties" group <<end>>
2435 // ... "MRU" preferences group <<start>>
2436 int mruGroup = pref->addPreference( tr( "PREF_GROUP_MRU" ), genTab, LightApp_Preferences::Auto, "MRU", "show_mru" );
2437 pref->setItemProperty( "columns", 4, mruGroup );
2438 // number of MRU items
2439 int mruVisCount = pref->addPreference( tr( "PREF_MRU_VISIBLE_COUNT" ), mruGroup, LightApp_Preferences::IntSpin,
2440 "MRU", "visible_count" );
2441 pref->setItemProperty( "min", 0, mruVisCount );
2442 pref->setItemProperty( "max", 100, mruVisCount );
2444 int mruLinkType = pref->addPreference( tr( "PREF_MRU_LINK_TYPE" ), mruGroup, LightApp_Preferences::Selector,
2445 "MRU", "link_type" );
2446 aValuesList.clear();
2447 anIndicesList.clear();
2448 aValuesList << tr("PREF_MRU_LINK_AUTO") << tr("PREF_MRU_LINK_SHORT") << tr("PREF_MRU_LINK_FULL");
2449 anIndicesList << 0 << 1 << 2 ;
2450 pref->setItemProperty( "strings", aValuesList, mruLinkType );
2451 pref->setItemProperty( "indexes", anIndicesList, mruLinkType );
2452 // ... "MRU" preferences group <<end>>
2454 // ... "Full-screen" group <<start>>
2455 int fullScreenGroup = pref->addPreference( tr( "PREF_GROUP_FULL_SCREEN" ), genTab );
2456 pref->setItemProperty( "columns", 2, fullScreenGroup );
2457 // .... -> automatic hiding toolbars
2458 pref->addPreference( tr( "PREF_FULL_SCREEN_AUTO" ), fullScreenGroup,
2459 LightApp_Preferences::Bool, "OCCViewer", "automatic_hiding" );
2460 // ... "Full-screen" group <<end>>
2462 // .. "General" preferences tab <<end>>
2464 // .. "3D viewer" group <<start>>
2465 int Viewer3DGroup = pref->addPreference( tr( "PREF_GROUP_3DVIEWER" ), salomeCat );
2466 // ... -> navigation mode
2467 int vtkStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), Viewer3DGroup,
2468 LightApp_Preferences::Selector, "3DViewer", "navigation_mode" );
2469 aValuesList.clear();
2470 anIndicesList.clear();
2471 aValuesList << tr("PREF_STANDARD_STYLE") << tr("PREF_KEYFREE_STYLE");
2472 anIndicesList << 0 << 1;
2473 pref->setItemProperty( "strings", aValuesList, vtkStyleMode );
2474 pref->setItemProperty( "indexes", anIndicesList, vtkStyleMode );
2475 // ... -> zooming mode
2476 int occZoomingStyleMode = pref->addPreference( tr( "PREF_ZOOMING" ), Viewer3DGroup,
2477 LightApp_Preferences::Selector, "3DViewer", "zooming_mode" );
2478 aValuesList.clear();
2479 anIndicesList.clear();
2480 aValuesList << tr("PREF_ZOOMING_AT_CENTER") << tr("PREF_ZOOMING_AT_CURSOR");
2481 anIndicesList << 0 << 1;
2482 pref->setItemProperty( "strings", aValuesList, occZoomingStyleMode );
2483 pref->setItemProperty( "indexes", anIndicesList, occZoomingStyleMode );
2484 // ... "Trihedron" group <<start>>
2485 int occTriGroup = pref->addPreference( tr( "PREF_TRIHEDRON" ), Viewer3DGroup );
2486 pref->setItemProperty( "columns", 2, occTriGroup );
2487 // .... -> trihedron size
2488 int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occTriGroup,
2489 LightApp_Preferences::DblSpin, "3DViewer", "trihedron_size" );
2490 pref->setItemProperty( "min", 1.0E-06, occTS );
2491 pref->setItemProperty( "max", 1000, occTS );
2492 // .... -> relative size of trihedron
2493 pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "relative_size" );
2494 // .... -> show static trihedron
2495 pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "show_static_trihedron" );
2496 // ... "Trihedron" group <<end>>
2497 // .. "3D viewer" group <<end>>
2501 #ifndef DISABLE_OCCVIEWER
2502 // .. "OCC viewer" group <<start>>
2503 int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), salomeCat );
2505 // .... -> Projection mode
2506 int occProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), occGroup,
2507 LightApp_Preferences::Selector, "OCCViewer", "projection_mode" );
2508 aValuesList.clear();
2509 anIndicesList.clear();
2510 aValuesList << tr("PREF_ORTHOGRAPHIC") << tr("PREF_PERSPECTIVE");
2511 anIndicesList << 0 << 1;
2512 pref->setItemProperty( "strings", aValuesList, occProjMode );
2513 pref->setItemProperty( "indexes", anIndicesList, occProjMode );
2515 // .... -> Stereo group
2516 int stereoGroup = pref->addPreference( tr( "PREF_GROUP_STEREO" ), occGroup);
2517 pref->setItemProperty( "columns", 2, stereoGroup );
2518 // .... -> Stereo type
2519 int stereoType = pref->addPreference( tr( "PREF_STEREO_TYPE" ), stereoGroup,
2520 LightApp_Preferences::Selector, "OCCViewer", "stereo_type" );
2521 aValuesList.clear();
2522 anIndicesList.clear();
2524 OCCViewer_Viewer::stereoData( aValuesList, idList);
2525 foreach( int gid, idList ) anIndicesList << gid;
2526 pref->setItemProperty( "strings", aValuesList, stereoType );
2527 pref->setItemProperty( "indexes", anIndicesList, stereoType );
2529 // .... -> Anaglyph filter
2530 int anaglyphFilter = pref->addPreference( tr( "PREF_ANAGLYPH_FILTER" ), stereoGroup,
2531 LightApp_Preferences::Selector, "OCCViewer", "anaglyph_filter" );
2532 aValuesList.clear();
2533 anIndicesList.clear();
2534 aValuesList << tr("PREF_ANAGLYPH_RED_CYAN") << tr("PREF_ANAGLYPH_YELLOW_BLUE") << tr("PREF_ANAGLYPH_GREEN_MAGENTA");
2535 anIndicesList << 0 << 1 << 2;
2537 pref->setItemProperty( "strings", aValuesList, anaglyphFilter );
2538 pref->setItemProperty( "indexes", anIndicesList, anaglyphFilter );
2540 // .... -> Convergence distance type
2541 int occFocusType = pref->addPreference( tr( "PREF_FOCUS_TYPE" ), stereoGroup,
2542 LightApp_Preferences::Selector, "OCCViewer", "focus_type" );
2543 aValuesList.clear();
2544 anIndicesList.clear();
2545 aValuesList << tr("PREF_ABSOLUTE") << tr("PREF_RELATIVE");
2546 anIndicesList << 0 << 1;
2547 pref->setItemProperty( "strings", aValuesList, occFocusType );
2548 pref->setItemProperty( "indexes", anIndicesList, occFocusType );
2550 // .... -> Stereographic focus value
2551 int focusValue = pref->addPreference( tr( "PREF_FOCUS_VALUE" ), stereoGroup,
2552 LightApp_Preferences::DblSpin, "OCCViewer", "focus_value" );
2553 pref->setItemProperty( "precision", 3, focusValue );
2554 pref->setItemProperty( "min", 1.0E-03, focusValue );
2555 pref->setItemProperty( "max", 1.0E03, focusValue );
2556 pref->setItemProperty( "step", 0.05, focusValue );
2559 int occIODType = pref->addPreference( tr( "PREF_IOD_TYPE" ), stereoGroup,
2560 LightApp_Preferences::Selector, "OCCViewer", "iod_type" );
2561 aValuesList.clear();
2562 anIndicesList.clear();
2563 aValuesList << tr("PREF_ABSOLUTE") << tr("PREF_RELATIVE");
2564 anIndicesList << 0 << 1;
2565 pref->setItemProperty( "strings", aValuesList, occIODType );
2566 pref->setItemProperty( "indexes", anIndicesList, occIODType );
2568 // .... -> Interocular distance (IOD) value
2569 int IODValue = pref->addPreference( tr( "PREF_IOD_VALUE" ), stereoGroup,
2570 LightApp_Preferences::DblSpin, "OCCViewer", "iod_value" );
2571 pref->setItemProperty( "precision", 3, IODValue );
2572 pref->setItemProperty( "min", 1.0E-03, IODValue );
2573 pref->setItemProperty( "max", 1.0E03, IODValue );
2574 pref->setItemProperty( "step", 0.05, IODValue );
2576 // .... -> Reverse stereo
2577 pref->addPreference( tr( "PREF_REVERSE_STEREO" ), stereoGroup,
2578 LightApp_Preferences::Bool, "OCCViewer", "reverse_stereo" );
2579 // .... -> Enable V-Sync
2580 pref->addPreference( tr( "PREF_ENABLE_VSYNC" ), stereoGroup,
2581 LightApp_Preferences::Bool, "OCCViewer", "enable_vsync" );
2582 // .... -> Enable quad-buffer support
2583 pref->addPreference( tr( "PREF_ENABLE_QUAD_BUFFER_SUPPORT" ), stereoGroup,
2584 LightApp_Preferences::Bool, "OCCViewer", "enable_quad_buffer_support" );
2586 // ... "Background" group <<start>>
2587 int bgGroup = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup );
2588 // pref->setItemProperty( "columns", 2, bgGroup );
2589 aValuesList.clear();
2590 anIndicesList.clear();
2593 formats = OCCViewer_Viewer::backgroundData( aValuesList, idList, txtList );
2594 foreach( int gid, idList ) anIndicesList << gid;
2595 // .... -> 3D viewer background
2596 bgId = pref->addPreference( tr( "PREF_3DVIEWER_BACKGROUND" ), bgGroup,
2597 LightApp_Preferences::Background, "OCCViewer", "background" );
2598 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2599 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2600 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2601 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2602 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2603 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2604 pref->setItemProperty( "custom_enabled", false, bgId );
2605 pref->setItemProperty( "image_formats", formats, bgId );
2606 // .... -> XZ viewer background
2607 bgId = pref->addPreference( tr( "PREF_XZVIEWER_BACKGROUND" ), bgGroup,
2608 LightApp_Preferences::Background, "OCCViewer", "xz_background" );
2609 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2610 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2611 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2612 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2613 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2614 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2615 pref->setItemProperty( "custom_enabled", false, bgId );
2616 pref->setItemProperty( "image_formats", formats, bgId );
2617 // .... -> YZ viewer background
2618 bgId = pref->addPreference( tr( "PREF_YZVIEWER_BACKGROUND" ), bgGroup,
2619 LightApp_Preferences::Background, "OCCViewer", "yz_background" );
2620 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2621 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2622 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2623 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2624 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2625 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2626 pref->setItemProperty( "custom_enabled", false, bgId );
2627 pref->setItemProperty( "image_formats", formats, bgId );
2628 // .... -> XY viewer background
2629 bgId = pref->addPreference( tr( "PREF_XYVIEWER_BACKGROUND" ), bgGroup,
2630 LightApp_Preferences::Background, "OCCViewer", "xy_background" );
2631 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2632 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2633 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2634 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2635 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2636 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2637 pref->setItemProperty( "custom_enabled", false, bgId );
2638 pref->setItemProperty( "image_formats", formats, bgId );
2639 // ... "Background" group <<end>>
2642 // ... "Selection" group <<start>>
2643 int occSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), occGroup );
2644 pref->setItemProperty( "columns", 2, occSelectionGroup );
2645 // .... -> enable preselection
2646 pref->addPreference( tr( "PREF_ENABLE_PRESELECTION" ), occSelectionGroup,
2647 LightApp_Preferences::Bool, "OCCViewer", "enable_preselection" );
2648 // .... -> enable selection
2649 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), occSelectionGroup,
2650 LightApp_Preferences::Bool, "OCCViewer", "enable_selection" );
2651 // ... "Selection" group <<end>>
2653 // ... "Clipping" group <<start>>
2654 int occClippingGroup = pref->addPreference( tr( "PREF_GROUP_CLIPPING" ), occGroup );
2655 // .... -> clipping color
2656 pref->addPreference( tr( "PREF_CLIPPING_COLOR" ), occClippingGroup,
2657 LightApp_Preferences::Color, "OCCViewer", "clipping_color" );
2658 int texturePref = pref->addPreference( "", occClippingGroup, LightApp_Preferences::Frame );
2659 pref->setItemProperty( "columns", 2, texturePref );
2660 // .... -> use default texture
2661 pref->addPreference( tr( "PREF_CLIPPING_DEFAULT_TEXTURE" ), texturePref,
2662 LightApp_Preferences::Bool, "OCCViewer", "clipping_use_default_texture" );
2663 // .... -> clipping texture
2664 int filePref = pref->addPreference( tr( "PREF_CLIPPING_TEXTURE" ), texturePref,
2665 LightApp_Preferences::File, "OCCViewer", "clipping_texture" );
2666 pref->setItemProperty( "path_filter", tr( "OCC_TEXTURE_FILES" ), filePref );
2668 pref->addPreference( tr( "PREF_CLIPPING_MODULATE" ), texturePref,
2669 LightApp_Preferences::Bool, "OCCViewer", "clipping_modulate" );
2670 // .... -> scale factor
2671 int scaleFactor = pref->addPreference( tr( "PREF_CLIPPING_SCALE" ), texturePref,
2672 LightApp_Preferences::DblSpin, "OCCViewer", "clipping_scale" );
2673 pref->setItemProperty( "precision", 3, scaleFactor );
2674 pref->setItemProperty( "min", 1.0E-03, scaleFactor );
2675 pref->setItemProperty( "max", 1.0E03, scaleFactor );
2676 pref->setItemProperty( "step", 0.1, scaleFactor );
2677 // ... "Clipping" group <<end>>
2679 // ... "Ray tracing" group <<start>>
2680 int occRayTracingGroup = pref->addPreference( tr( "PREF_GROUP_RAY_TRACING" ), occGroup );
2681 int rtPref = pref->addPreference( "", occRayTracingGroup, LightApp_Preferences::Frame );
2682 pref->setItemProperty( "columns", 2, rtPref );
2684 int rt_depth = pref->addPreference( tr( "PREF_RAY_TRACING_DEPTH" ), rtPref,
2685 LightApp_Preferences::IntSpin, "OCCViewer", "rt_depth" );
2686 pref->setItemProperty( "min", 1, rt_depth );
2687 pref->setItemProperty( "max", 10, rt_depth );
2688 pref->setItemProperty( "step", 1, rt_depth );
2689 pref->addPreference( "", rtPref, LightApp_Preferences::Frame );
2690 // .... -> specular reflections
2691 pref->addPreference( tr( "PREF_RAY_TRACING_REFLECTION" ), rtPref,
2692 LightApp_Preferences::Bool, "OCCViewer", "rt_reflection" );
2693 // .... -> adaptive anti-aliasing
2694 pref->addPreference( tr( "PREF_RAY_TRACING_ANTIALIASING" ), rtPref,
2695 LightApp_Preferences::Bool, "OCCViewer", "rt_antialiasing" );
2696 // .... -> shadows rendering
2697 pref->addPreference( tr( "PREF_RAY_TRACING_SHADOW" ), rtPref,
2698 LightApp_Preferences::Bool, "OCCViewer", "rt_shadow" );
2699 // .... -> transparent shadow
2700 pref->addPreference( tr( "PREF_RAY_TRACING_TRANS_SHADOW" ), rtPref,
2701 LightApp_Preferences::Bool, "OCCViewer", "rt_trans_shadow" );
2702 // ... "Ray tracing" group <<end>>
2704 // ... "Light source" group <<start>>
2705 int occLightGroup = pref->addPreference( tr( "PREF_GROUP_LIGHT" ), occGroup );
2706 // .... -> light color
2707 pref->addPreference( tr( "PREF_LIGHT_COLOR" ), occLightGroup,
2708 LightApp_Preferences::Color, "OCCViewer", "light_color" );
2709 int directionPref = pref->addPreference( "", occLightGroup, LightApp_Preferences::Frame );
2710 pref->setItemProperty( "columns", 3, directionPref );
2711 // .... -> light direction (dx component)
2712 int light_dx = pref->addPreference( tr( "Dx" ), directionPref,
2713 LightApp_Preferences::DblSpin, "OCCViewer", "light_dx" );
2714 pref->setItemProperty( "precision", 2, light_dx );
2715 pref->setItemProperty( "min", -1.0E03, light_dx );
2716 pref->setItemProperty( "max", 1.0E03, light_dx );
2717 pref->setItemProperty( "step", 0.1, light_dx );
2718 // .... -> light direction (dy component)
2719 int light_dy = pref->addPreference( tr( "Dy" ), directionPref,
2720 LightApp_Preferences::DblSpin, "OCCViewer", "light_dy" );
2721 pref->setItemProperty( "precision", 2, light_dy );
2722 pref->setItemProperty( "min", -1.0E03, light_dy );
2723 pref->setItemProperty( "max", 1.0E03, light_dy );
2724 pref->setItemProperty( "step", 0.1, light_dy );
2725 // .... -> light direction (dz component)
2726 int light_dz = pref->addPreference( tr( "Dz" ), directionPref,
2727 LightApp_Preferences::DblSpin, "OCCViewer", "light_dz" );
2728 pref->setItemProperty( "precision", 2, light_dz );
2729 pref->setItemProperty( "min", -1.0E03, light_dz );
2730 pref->setItemProperty( "max", 1.0E03, light_dz );
2731 pref->setItemProperty( "step", 0.1, light_dz );
2732 // ... "Light source" group <<end>>
2734 // ... -> empty frame (for layout) <<start>>
2735 int occGen = pref->addPreference( "", occGroup, LightApp_Preferences::Frame );
2736 pref->setItemProperty( "margin", 0, occGen );
2737 pref->setItemProperty( "columns", 2, occGen );
2738 // ... -> empty frame (for layout) <<end>>
2740 // .. "OCC viewer" group <<end>>
2743 #ifndef DISABLE_VTKVIEWER
2744 // .. "VTK viewer" group <<start>>
2745 int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), salomeCat ); //viewTab
2747 // ... -> empty frame (for layout) <<start>>
2748 int vtkGen = pref->addPreference( "", vtkGroup, LightApp_Preferences::Frame );
2749 //pref->setItemProperty( "columns", 2, vtkGen );
2750 // .... -> projection mode
2751 int vtkProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), vtkGen,
2752 LightApp_Preferences::Selector, "VTKViewer", "projection_mode" );
2753 aValuesList.clear();
2754 anIndicesList.clear();
2755 aValuesList << tr("PREF_ORTHOGRAPHIC") << tr("PREF_PERSPECTIVE");
2756 anIndicesList << 0 << 1;
2757 pref->setItemProperty( "strings", aValuesList, vtkProjMode );
2758 pref->setItemProperty( "indexes", anIndicesList, vtkProjMode );
2760 // .... -> Stereo group
2761 int vtkStereoGroup = pref->addPreference( tr( "PREF_GROUP_STEREO" ), vtkGroup);
2762 pref->setItemProperty( "columns", 2, vtkStereoGroup );
2763 // .... -> Stereo type
2764 int vtkStereoType = pref->addPreference( tr( "PREF_STEREO_TYPE" ), vtkStereoGroup,
2765 LightApp_Preferences::Selector, "VTKViewer", "stereo_type" );
2766 aValuesList.clear();
2767 anIndicesList.clear();
2769 SVTK_Viewer::stereoData( aValuesList, idList);
2770 foreach( int gid, idList ) anIndicesList << gid;
2771 pref->setItemProperty( "strings", aValuesList, vtkStereoType );
2772 pref->setItemProperty( "indexes", anIndicesList, vtkStereoType );
2773 // .... -> Anaglyph filter
2774 int vtkAnaglyphFilter = pref->addPreference( tr( "PREF_ANAGLYPH_FILTER" ), vtkStereoGroup,
2775 LightApp_Preferences::Selector, "VTKViewer", "anaglyph_filter" );
2776 aValuesList.clear();
2777 anIndicesList.clear();
2778 aValuesList << tr("PREF_ANAGLYPH_RED_CYAN") << tr("PREF_ANAGLYPH_YELLOW_BLUE") << tr("PREF_ANAGLYPH_GREEN_MAGENTA");
2779 anIndicesList << 0 << 1 << 2;
2781 pref->setItemProperty( "strings", aValuesList, vtkAnaglyphFilter );
2782 pref->setItemProperty( "indexes", anIndicesList, vtkAnaglyphFilter );
2784 // .... -> Enable quad-buffer support
2785 pref->addPreference( tr( "PREF_ENABLE_QUAD_BUFFER_SUPPORT" ), vtkStereoGroup,
2786 LightApp_Preferences::Bool, "VTKViewer", "enable_quad_buffer_support" );
2788 // .... -> background
2789 aValuesList.clear();
2790 anIndicesList.clear();
2793 #ifndef DISABLE_SALOMEOBJECT
2794 formats = SVTK_Viewer::backgroundData( aValuesList, idList, txtList );
2796 foreach( int gid, idList ) anIndicesList << gid;
2797 bgId = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGen,
2798 LightApp_Preferences::Background, "VTKViewer", "background" );
2799 pref->setItemProperty( "gradient_names", aValuesList, bgId );
2800 pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
2801 pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
2802 pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
2803 pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
2804 pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
2805 pref->setItemProperty( "custom_enabled", false, bgId );
2806 #ifndef DISABLE_SALOMEOBJECT
2807 pref->setItemProperty( "image_formats", formats, bgId );
2809 // .... -> speed increment
2810 int vtkSpeed = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED" ), vtkGen,
2811 LightApp_Preferences::IntSpin, "VTKViewer", "speed_value" );
2812 pref->setItemProperty( "min", 1, vtkSpeed );
2813 pref->setItemProperty( "max", 1000, vtkSpeed );
2814 // .... -> speed mode
2815 int vtkSpeedMode = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED_MODE" ), vtkGen,
2816 LightApp_Preferences::Selector, "VTKViewer", "speed_mode" );
2817 aValuesList.clear();
2818 anIndicesList.clear();
2819 aValuesList << tr("PREF_ARITHMETIC") << tr("PREF_GEOMETRICAL");
2820 anIndicesList << 0 << 1;
2821 pref->setItemProperty( "strings", aValuesList, vtkSpeedMode );
2822 pref->setItemProperty( "indexes", anIndicesList, vtkSpeedMode );
2824 // ... "Selection" group <<start>>
2825 int vtkSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), vtkGroup );
2826 pref->setItemProperty( "columns", 2, vtkSelectionGroup );
2827 // .... -> preselection
2828 int vtkPreselection = pref->addPreference( tr( "PREF_PRESELECTION" ), vtkSelectionGroup,
2829 LightApp_Preferences::Selector, "VTKViewer", "preselection" );
2830 aValuesList.clear();
2831 anIndicesList.clear();
2832 aValuesList << tr("PREF_PRESELECTION_STANDARD") << tr("PREF_PRESELECTION_DYNAMIC") << tr("PREF_PRESELECTION_DISABLED");
2833 anIndicesList << 0 << 1 << 2;
2834 pref->setItemProperty( "strings", aValuesList, vtkPreselection );
2835 pref->setItemProperty( "indexes", anIndicesList, vtkPreselection );
2836 // .... -> enable selection
2837 pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), vtkSelectionGroup, LightApp_Preferences::Bool, "VTKViewer", "enable_selection" );
2838 // ... "Selection" group <<end>>
2840 // ... -> empty frame (for layout) <<end>>
2842 // ... space mouse sub-group <<start>>
2843 int vtkSM = pref->addPreference( tr( "PREF_FRAME_SPACEMOUSE" ), vtkGroup, LightApp_Preferences::GroupBox );
2844 //pref->setItemProperty( "columns", 2, vtkSM );
2845 // .... -> decrease speed increment
2846 int spacemousePref1 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_1" ), vtkSM,
2847 LightApp_Preferences::Selector, "VTKViewer",
2848 "spacemouse_func1_btn" );
2849 // .... -> increase speed increment
2850 int spacemousePref2 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_2" ), vtkSM,
2851 LightApp_Preferences::Selector, "VTKViewer",
2852 "spacemouse_func2_btn" );
2853 // .... -> dominant / combined switch
2854 int spacemousePref3 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_3" ), vtkSM,
2855 LightApp_Preferences::Selector, "VTKViewer",
2856 "spacemouse_func5_btn" ); //
2857 aValuesList.clear();
2858 anIndicesList.clear();
2859 aValuesList << tr( "PREF_SPACEMOUSE_BTN_1" ) << tr( "PREF_SPACEMOUSE_BTN_2" ) << tr( "PREF_SPACEMOUSE_BTN_3" );
2860 aValuesList << tr( "PREF_SPACEMOUSE_BTN_4" ) << tr( "PREF_SPACEMOUSE_BTN_5" ) << tr( "PREF_SPACEMOUSE_BTN_6" );
2861 aValuesList << tr( "PREF_SPACEMOUSE_BTN_7" ) << tr( "PREF_SPACEMOUSE_BTN_8" ) << tr( "PREF_SPACEMOUSE_BTN_*" );
2862 aValuesList << tr( "PREF_SPACEMOUSE_BTN_10" ) << tr( "PREF_SPACEMOUSE_BTN_11" );
2863 anIndicesList << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11;
2864 pref->setItemProperty( "strings", aValuesList, spacemousePref1 );
2865 pref->setItemProperty( "indexes", anIndicesList, spacemousePref1 );
2866 pref->setItemProperty( "strings", aValuesList, spacemousePref2 );
2867 pref->setItemProperty( "indexes", anIndicesList, spacemousePref2 );
2868 pref->setItemProperty( "strings", aValuesList, spacemousePref3 );
2869 pref->setItemProperty( "indexes", anIndicesList, spacemousePref3 );
2870 // ... space mouse sub-group <<end>>
2872 // ... avi recording sub-group <<start>>
2873 int vtkRec = pref->addPreference( tr( "PREF_FRAME_RECORDING" ), vtkGroup, LightApp_Preferences::GroupBox );
2874 pref->setItemProperty( "columns", 2, vtkRec );
2875 // .... -> recording mode
2876 int modePref = pref->addPreference( tr( "PREF_RECORDING_MODE" ), vtkRec,
2877 LightApp_Preferences::Selector, "VTKViewer", "recorder_mode" );
2878 aValuesList.clear();
2879 anIndicesList.clear();
2880 aValuesList << tr( "PREF_SKIPPED_FRAMES" ) << tr( "PREF_ALL_DISLPAYED_FRAMES" );
2881 anIndicesList << 0 << 1;
2882 pref->setItemProperty( "strings", aValuesList, modePref );
2883 pref->setItemProperty( "indexes", anIndicesList, modePref );
2885 int fpsPref = pref->addPreference( tr( "PREF_FPS" ), vtkRec,
2886 LightApp_Preferences::DblSpin, "VTKViewer", "recorder_fps" );
2887 pref->setItemProperty( "min", 0.1, fpsPref );
2888 pref->setItemProperty( "max", 100, fpsPref );
2890 int qualityPref = pref->addPreference( tr( "PREF_QUALITY" ), vtkRec,
2891 LightApp_Preferences::IntSpin, "VTKViewer", "recorder_quality" );
2892 pref->setItemProperty( "min", 1, qualityPref );
2893 pref->setItemProperty( "max", 100, qualityPref );
2894 // .... -> progressive mode
2895 pref->addPreference( tr( "PREF_PROGRESSIVE" ), vtkRec,
2896 LightApp_Preferences::Bool, "VTKViewer", "recorder_progressive" );
2897 // ... avi recording sub-group <<end>>
2899 // ... group names sub-group <<start>>
2900 int vtkGN = pref->addPreference( tr( "PREF_FRAME_GROUP_NAMES" ), vtkGroup,
2901 LightApp_Preferences::GroupBox, "VTKViewer", "show_group_names" );
2902 pref->setItemProperty( "columns", 2, vtkGN );
2903 // .... -> text color
2904 pref->addPreference( tr( "PREF_GROUP_NAMES_TEXT_COLOR" ), vtkGN,
2905 LightApp_Preferences::Color, "VTKViewer", "group_names_text_color" );
2906 // .... -> transparency
2907 int transPref = pref->addPreference( tr( "PREF_GROUP_NAMES_TRANSPARENCY" ), vtkGN,
2908 LightApp_Preferences::DblSpin, "VTKViewer", "group_names_transparency" );
2909 pref->setItemProperty( "min", 0.0, transPref );
2910 pref->setItemProperty( "max", 1.0, transPref );
2911 pref->setItemProperty( "step", 0.1, transPref );
2912 // ... -> group names sub-group <<end>>
2913 // .. "VTK viewer" group <<end>>
2916 // .. "Plot2d viewer" group <<start>>
2917 int plot2dGroup = pref->addPreference( tr( "PREF_GROUP_PLOT2DVIEWER" ), salomeCat ); //viewTab
2918 //pref->setItemProperty( "columns", 2, plot2dGroup );
2920 // ... -> background
2921 pref->addPreference( tr( "PREF_VIEWER_BACKGROUND_COLOR" ), plot2dGroup,
2922 LightApp_Preferences::Color, "Plot2d", "Background" );
2923 // ... -> selection color
2924 pref->addPreference( tr( "PREF_VIEWER_SELECTION" ), plot2dGroup,
2925 LightApp_Preferences::Color, "Plot2d", "SelectionColor" );
2927 // ... "Viewer" group <<start>>
2928 int plot2dViewerGroup = pref->addPreference( tr( "PREF_GROUP_VIEWER" ), plot2dGroup );
2930 // .... -> curve type
2931 int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dViewerGroup,
2932 LightApp_Preferences::Selector, "Plot2d", "CurveType" );
2933 aValuesList.clear();
2934 anIndicesList.clear();
2935 aValuesList << tr("PREF_POINTS") << tr("PREF_LINES") << tr("PREF_SPLINE");
2936 anIndicesList << 0 << 1 << 2 ;
2937 pref->setItemProperty( "strings", aValuesList, curveType );
2938 pref->setItemProperty( "indexes", anIndicesList, curveType );
2939 // .... -> marker size
2940 int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dViewerGroup,
2941 LightApp_Preferences::IntSpin, "Plot2d", "MarkerSize" );
2942 pref->setItemProperty( "min", 0, markerSize );
2943 pref->setItemProperty( "max", 100, markerSize );
2944 // .... -> horizontal scaling mode
2945 int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dViewerGroup,
2946 LightApp_Preferences::Selector, "Plot2d", "HorScaleMode" );
2947 aValuesList.clear();
2948 anIndicesList.clear();
2949 aValuesList << tr("PREF_LINEAR") << tr("PREF_LOGARITHMIC");
2950 anIndicesList << 0 << 1 ;
2951 pref->setItemProperty( "strings", aValuesList, horScale );
2952 pref->setItemProperty( "indexes", anIndicesList, horScale );
2953 // .... -> vertical scaling mode
2954 int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dViewerGroup,
2955 LightApp_Preferences::Selector, "Plot2d", "VerScaleMode" );
2956 pref->setItemProperty( "strings", aValuesList, verScale );
2957 pref->setItemProperty( "indexes", anIndicesList, verScale );
2959 // .... -> errors/deviation colot
2960 pref->addPreference( tr( "PREF_DEVIATION_COLOR" ), plot2dViewerGroup,
2961 LightApp_Preferences::Color, "Plot2d", "DeviationMarkerColor" );
2962 // .... -> deviation markers line size
2963 int deviationMarkerLw = pref->addPreference( tr( "PREF_DEVIATION_MARKER_LW" ), plot2dViewerGroup,
2964 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerLineWidth" );
2965 pref->setItemProperty( "min", 1, deviationMarkerLw );
2966 pref->setItemProperty( "max", 5, deviationMarkerLw );
2967 // .... -> deviation markers tick mark size
2968 int deviationMarkerTs = pref->addPreference( tr( "PREF_DEVIATION_MARKER_TS" ), plot2dViewerGroup,
2969 LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerTickSize" );
2970 pref->setItemProperty( "min", 1, deviationMarkerTs );
2971 pref->setItemProperty( "max", 5, deviationMarkerTs );
2972 // .... "Viewer" group <<end>>
2974 // ... "Legend" group <<start>>
2975 int plot2dLegendGroup = pref->addPreference( tr( "PREF_GROUP_LEGEND" ), plot2dGroup );
2977 // .... -> show legend
2978 pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dLegendGroup,
2979 LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
2980 // .... -> legend position
2981 int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dLegendGroup,
2982 LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
2983 aValuesList.clear();
2984 anIndicesList.clear();
2985 aValuesList << tr("PREF_LEFT") << tr("PREF_RIGHT") << tr("PREF_TOP") << tr("PREF_BOTTOM");
2986 anIndicesList << 0 << 1 << 2 << 3 ;
2987 pref->setItemProperty( "strings", aValuesList, legendPosition );
2988 pref->setItemProperty( "indexes", anIndicesList, legendPosition );
2989 // .... -> Symbol type
2990 int legendSymbolType = pref->addPreference( tr( "PREF_LEGEND_SYMBOL_TYPE" ), plot2dLegendGroup,
2991 LightApp_Preferences::Selector, "Plot2d", "LegendSymbolType" );
2992 aValuesList.clear();
2993 anIndicesList.clear();
2994 aValuesList << tr("PREF_MARKER_ON_LINE") << tr("PREF_MARKER_ABOVE_LINE");
2995 anIndicesList << 0 << 1 ;
2996 pref->setItemProperty( "strings", aValuesList, legendSymbolType );
2997 pref->setItemProperty( "indexes", anIndicesList, legendSymbolType );
2998 // .... -> legend font
2999 pref->addPreference( tr( "PREF_LEGEND_FONT" ), plot2dLegendGroup, LightApp_Preferences::Font, "Plot2d", "LegendFont" );
3000 // ... -> font color
3001 pref->addPreference( tr( "PREF_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "LegendFontColor" );
3002 // ... -> selection font color
3003 pref->addPreference( tr( "PREF_SELECTED_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "SelectedLegendFontColor" );
3004 // ... "Legend" group <<end>>
3006 // .. "Plot2d viewer" group <<end>>
3008 // .. "PyViewer" preferences tab <<start>>
3009 int pyeditTab = pref->addPreference( tr( "PREF_TAB_PYEDITOR" ), salomeCat );
3010 // ... "Font settings" group <<start>>
3011 int pyFontGroup = pref->addPreference( tr( "PREF_GROUP_PY_FONT" ), pyeditTab );
3012 int pyFont = pref->addPreference( tr( "PREF_PY_FONT" ), pyFontGroup,
3013 LightApp_Preferences::Font, "PyEditor", "Font" );
3014 pref->setItemProperty( "features", QtxFontEdit::Family | QtxFontEdit::Size | QtxFontEdit::UserSize, pyFont );
3015 // ... "Font settings" group <<end>>
3016 // ... "Display settings" group <<start>>
3017 int pyDispGroup = pref->addPreference( tr( "PREF_GROUP_PY_DISPLAY" ), pyeditTab );
3018 pref->setItemProperty( "columns", 2, pyDispGroup );
3019 // ... -> current line highlight
3020 pref->addPreference( tr( "PREF_PY_CURRLINE_HIGHLIGHT" ), pyDispGroup,
3021 LightApp_Preferences::Bool, "PyEditor", "HighlightCurrentLine" );
3022 // ... -> text wrapping
3023 pref->addPreference( tr( "PREF_PY_TEXT_WRAP" ), pyDispGroup,
3024 LightApp_Preferences::Bool, "PyEditor", "TextWrapping" );
3025 // ... -> center cursor on scroll
3026 pref->addPreference( tr( "PREF_PY_CURSON_ON_SCROLL" ), pyDispGroup,
3027 LightApp_Preferences::Bool, "PyEditor", "CenterCursorOnScroll" );
3028 // ... -> line numbers area
3029 pref->addPreference( tr( "PREF_PY_LINE_NUMBS_AREA" ), pyDispGroup,
3030 LightApp_Preferences::Bool, "PyEditor", "LineNumberArea" );
3031 // ... "Display settings" group <<end>>
3033 // ... "Editor settings" group <<start>>
3034 int pyEditGroup = pref->addPreference( tr( "PREF_GROUP_PY_EDITOR" ), pyeditTab );
3035 // ... -> navigation mode
3036 int pyCompletion = pref->addPreference( tr( "PREF_PY_COMPLETION_MODE" ), pyEditGroup,
3037 LightApp_Preferences::Selector, "PyEditor", "CompletionPolicy" );
3038 aValuesList.clear();
3039 anIndicesList.clear();
3040 aValuesList << tr("PREF_PY_NONE") << tr("PREF_PY_AUTO") << tr("PREF_PY_MANUAL") << tr("PREF_PY_ALWAYS");
3041 anIndicesList << 0 << 1 << 2 << 3 ;
3042 pref->setItemProperty( "strings", aValuesList, pyCompletion );
3043 pref->setItemProperty( "indexes", anIndicesList, pyCompletion );
3044 // ... "Editor settings" group <<end>>
3046 // ... "Tab settings" group <<start>>
3047 int pyTabGroup = pref->addPreference( tr( "PREF_GROUP_PY_TAB" ), pyeditTab );
3048 pref->setItemProperty( "columns", 2, pyTabGroup );
3049 // ... -> tab whitespaces
3050 pref->addPreference( tr( "PREF_PY_TAB_WHITESPACES" ), pyTabGroup,
3051 LightApp_Preferences::Bool, "PyEditor", "TabSpaceVisible" );
3053 pref->addPreference( tr( "PREF_PY_TAB_SIZE" ), pyTabGroup,
3054 LightApp_Preferences::IntSpin, "PyEditor", "TabSize" );
3055 // ... "Tab settings" group <<end>>
3056 // ... "Vertical edge settings" group <<start>>
3057 int pyVertEdgeGroup = pref->addPreference( tr( "PREF_GROUP_VERT_EDGE" ), pyeditTab );
3058 pref->setItemProperty( "columns", 2, pyVertEdgeGroup );
3059 // ... -> vertical edge
3060 pref->addPreference( tr( "PREF_PY_VERT_EDGE" ), pyVertEdgeGroup,
3061 LightApp_Preferences::Bool, "PyEditor", "VerticalEdge" );
3062 // ... -> number of columns
3063 pref->addPreference( tr( "PREF_PY_NUM_COLUMNS" ), pyVertEdgeGroup,
3064 LightApp_Preferences::IntSpin, "PyEditor", "NumberColumns" );
3065 // ... "Vertical edge settings" group <<end>>
3066 // .. "PyEditor" preferences tab <<end>>
3068 // .. "Directories" preferences tab <<start>>
3069 int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat );
3070 // ... --> quick directories list
3071 int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab );
3072 pref->addPreference( tr( "" ), dirGroup,
3073 LightApp_Preferences::DirList, "FileDlg", "QuickDirList" );
3074 // .. "Directories" preferences tab <<end>>
3076 // .. "Object browser" preferences tab <<start>>
3077 int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
3079 // ... "Search tool" group <<start>>
3080 int stGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SEARCH_TOOL" ), obTab );
3081 // .... --> auto-hide
3082 pref->addPreference( tr( "PREF_AUTO_HIDE_SEARCH_TOOL" ), stGroup, LightApp_Preferences::Bool,
3083 "ObjectBrowser", "auto_hide_search_tool" );
3084 // ... "Search tool" group <<end>>
3086 // ... "Object browser settings" group <<start>>
3087 int objSetGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), obTab );
3088 pref->setItemProperty( "columns", 2, objSetGroup );
3089 // .... -> auto size first column
3090 pref->addPreference( tr( "PREF_AUTO_SIZE_FIRST" ), objSetGroup, LightApp_Preferences::Bool,
3091 "ObjectBrowser", "auto_size_first" );
3092 // .... -> auto size other columns
3093 pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool,
3094 "ObjectBrowser", "auto_size" );
3095 // .... -> resize columns on expand item
3096 pref->addPreference( tr( "PREF_RESIZE_ON_EXPAND_ITEM" ), objSetGroup, LightApp_Preferences::Bool,
3097 "ObjectBrowser", "resize_on_expand_item" );
3098 // .... -> browse to published object
3099 int browsePublished = pref->addPreference( tr( "PREF_BROWSE_TO_THE_PUBLISHED_OBJECT" ), objSetGroup, LightApp_Preferences::Selector,
3100 "ObjectBrowser", "browse_published_object" );
3101 aValuesList.clear();
3102 anIndicesList.clear();
3103 aValuesList << tr( "PREF_BROWSE_NEVER" ) << tr( "PREF_BROWSE_AFTER_APPLY_AND_CLOSE_ONLY" ) << tr( "PREF_BROWSE_ALWAYS" );
3104 anIndicesList << BP_Never << BP_ApplyAndClose << BP_Always;
3105 pref->setItemProperty( "strings", aValuesList, browsePublished );
3106 pref->setItemProperty( "indexes", anIndicesList, browsePublished );
3107 // ... "Object browser settings" group <<end>>
3108 // .. "Object browser" preferences tab <<end>>
3110 // .. "Shortcuts" preferences tab <<start>>
3111 int shortcutTab = pref->addPreference( tr( "PREF_TAB_SHORTCUTS" ), salomeCat );
3112 // ... "Shortcuts settings" group <<start>>
3113 int shortcutGroup = pref->addPreference( tr( "PREF_GROUP_SHORTCUTS" ), shortcutTab );
3114 pref->addPreference( tr( "" ), shortcutGroup,
3115 LightApp_Preferences::ShortcutTree, "shortcuts" );
3116 // ... "Shortcuts settings" group <<end>>
3117 // .. "Shortcuts" preferences tab <<end>>
3118 // . Top-level "SALOME" preferences group <<end>>
3124 Changes appearance of application according to changed preferences
3125 \param sec - section
3126 \param param - name of changed parameter
3128 void LightApp_Application::preferencesChanged( const QString& sec, const QString& param )
3130 SUIT_ResourceMgr* resMgr = resourceMgr();
3134 if ( sec == "viewers" && param == "drop_down_buttons" )
3136 ViewManagerList vmlist = viewManagers();
3137 foreach( SUIT_ViewManager* vm, vmlist )
3139 QVector<SUIT_ViewWindow*> vwlist = vm->getViews();
3140 foreach( SUIT_ViewWindow* vw, vwlist )
3141 if ( vw ) vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
3145 if ( sec == QString( "3DViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )))
3147 double sz = resMgr->doubleValue( sec, "trihedron_size", -1 );
3148 bool relative = resMgr->booleanValue( sec, "relative_size", true );
3149 QList<SUIT_ViewManager*> lst;
3150 #ifndef DISABLE_OCCVIEWER
3151 viewManagers( OCCViewer_Viewer::Type(), lst );
3152 QListIterator<SUIT_ViewManager*> itOCC( lst );
3153 while ( itOCC.hasNext() && sz >= 0 )
3155 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3156 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3159 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3160 occVM->setTrihedronSize( sz, relative );
3161 occVM->getAISContext()->UpdateCurrentViewer();
3164 #ifndef DISABLE_VTKVIEWER
3165 #ifndef DISABLE_SALOMEOBJECT
3166 viewManagers( SVTK_Viewer::Type(), lst );
3167 QListIterator<SUIT_ViewManager*> itVTK( lst );
3168 while ( itVTK.hasNext() && sz >= 0 )
3170 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3171 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3174 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3177 vtkVM->setTrihedronSize( sz, relative );
3185 if ( sec == QString( "3DViewer" ) && param == QString( "show_static_trihedron" ) )
3187 bool isVisible = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
3188 QList<SUIT_ViewManager*> lst;
3189 #ifndef DISABLE_OCCVIEWER
3190 viewManagers( OCCViewer_Viewer::Type(), lst );
3191 QListIterator<SUIT_ViewManager*> itOCC( lst );
3192 while ( itOCC.hasNext() )
3194 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3195 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3198 OCCViewer_Viewer* occVM = dynamic_cast<OCCViewer_Viewer*>( vm );
3201 occVM->setStaticTrihedronDisplayed( isVisible );
3205 #ifndef DISABLE_VTKVIEWER
3206 #ifndef DISABLE_SALOMEOBJECT
3207 viewManagers( SVTK_Viewer::Type(), lst );
3208 QListIterator<SUIT_ViewManager*> itVTK( lst );
3209 while ( itVTK.hasNext() )
3211 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3212 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3215 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3218 vtkVM->setStaticTrihedronVisible( isVisible );
3226 if ( sec == QString( "3DViewer" ) && param == QString( "navigation_mode" ) )
3228 int mode = resMgr->integerValue( "3DViewer", "navigation_mode", 0 );
3229 QList<SUIT_ViewManager*> lst;
3230 #ifndef DISABLE_OCCVIEWER
3231 viewManagers( OCCViewer_Viewer::Type(), lst );
3232 QListIterator<SUIT_ViewManager*> itOCC( lst );
3233 while ( itOCC.hasNext() )
3235 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3236 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3239 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3240 occVM->setInteractionStyle( mode );
3243 #ifndef DISABLE_VTKVIEWER
3244 #ifndef DISABLE_SALOMEOBJECT
3245 viewManagers( SVTK_Viewer::Type(), lst );
3246 QListIterator<SUIT_ViewManager*> itVTK( lst );
3247 while ( itVTK.hasNext() )
3249 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3250 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3253 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3254 if( vtkVM ) vtkVM->setInteractionStyle( mode );
3260 #ifndef DISABLE_OCCVIEWER
3261 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_preselection" ) )
3263 bool isToEnablePreselection = resMgr->booleanValue( "OCCViewer", "enable_preselection", true );
3264 QList<SUIT_ViewManager*> lst;
3265 viewManagers( OCCViewer_Viewer::Type(), lst );
3266 QListIterator<SUIT_ViewManager*> it( lst );
3267 while ( it.hasNext() )
3269 SUIT_ViewModel* vm = it.next()->getViewModel();
3270 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3273 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3274 occVM->enablePreselection( isToEnablePreselection );
3279 #ifndef DISABLE_OCCVIEWER
3280 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_selection" ) )
3282 bool isToEnableSelection = resMgr->booleanValue( "OCCViewer", "enable_selection", true );
3283 QList<SUIT_ViewManager*> lst;
3284 viewManagers( OCCViewer_Viewer::Type(), lst );
3285 QListIterator<SUIT_ViewManager*> it( lst );
3286 while ( it.hasNext() )
3288 SUIT_ViewModel* vm = it.next()->getViewModel();
3289 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3292 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3293 occVM->enableSelection( isToEnableSelection );
3298 #ifndef DISABLE_OCCVIEWER
3299 if ( sec == QString( "OCCViewer" ) && param == QString( "clipping_color" ) )
3301 QColor aColor = resMgr->colorValue( "OCCViewer", "clipping_color", QColor( 50, 50, 50 ) );
3302 QList<SUIT_ViewManager*> lst;
3303 viewManagers( OCCViewer_Viewer::Type(), lst );
3304 QListIterator<SUIT_ViewManager*> it( lst );
3305 while ( it.hasNext() )
3307 SUIT_ViewModel* vm = it.next()->getViewModel();
3308 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3311 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3312 occVM->setClippingColor( aColor );
3317 #ifndef DISABLE_OCCVIEWER
3318 if ( sec == QString( "OCCViewer" ) && ( param == QString( "clipping_use_default_texture" ) ||
3319 param == QString( "clipping_texture" ) ||
3320 param == QString( "clipping_modulate" ) ||
3321 param == QString( "clipping_scale" ) ) )
3323 bool isDefaultTextureUsed = resMgr->booleanValue( "OCCViewer", "clipping_use_default_texture" );
3324 QString aTexture = resMgr->stringValue( "OCCViewer", "clipping_texture" );
3325 bool isModulated = resMgr->booleanValue( "OCCViewer", "clipping_modulate" );
3326 double aScale = resMgr->doubleValue( "OCCViewer", "clipping_scale" );
3327 QList<SUIT_ViewManager*> lst;
3328 viewManagers( OCCViewer_Viewer::Type(), lst );
3329 QListIterator<SUIT_ViewManager*> it( lst );
3330 while ( it.hasNext() )
3332 SUIT_ViewModel* vm = it.next()->getViewModel();
3333 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3336 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3337 occVM->setClippingTextureParams( isDefaultTextureUsed, aTexture, isModulated, aScale );
3342 #ifndef DISABLE_OCCVIEWER
3343 if ( sec == QString( "OCCViewer" ) && param == QString( "projection_mode" ) )
3345 int mode = resMgr->integerValue( "OCCViewer", "projection_mode", 0 );
3346 QList<SUIT_ViewManager*> lst;
3347 viewManagers( OCCViewer_Viewer::Type(), lst );
3348 QListIterator<SUIT_ViewManager*> it( lst );
3349 while ( it.hasNext() )
3351 SUIT_ViewModel* vm = it.next()->getViewModel();
3352 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3355 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3356 occVM->setProjectionType( mode );
3361 #ifndef DISABLE_OCCVIEWER
3362 if ( sec == QString( "OCCViewer" ) && param == QString( "stereo_type" ) )
3364 int mode = resMgr->integerValue( "OCCViewer", "stereo_type", 0 );
3365 QList<SUIT_ViewManager*> lst;
3366 viewManagers( OCCViewer_Viewer::Type(), lst );
3367 QListIterator<SUIT_ViewManager*> it( lst );
3368 while ( it.hasNext() )
3370 SUIT_ViewModel* vm = it.next()->getViewModel();
3371 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3374 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3375 occVM->setStereoType( mode );
3380 #ifndef DISABLE_OCCVIEWER
3381 if ( sec == QString( "OCCViewer" ) && param == QString( "anaglyph_filter" ) )
3383 int mode = resMgr->integerValue( "OCCViewer", "anaglyph_filter", 0 );
3384 QList<SUIT_ViewManager*> lst;
3385 viewManagers( OCCViewer_Viewer::Type(), lst );
3386 QListIterator<SUIT_ViewManager*> it( lst );
3387 while ( it.hasNext() )
3389 SUIT_ViewModel* vm = it.next()->getViewModel();
3390 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3393 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3394 occVM->setAnaglyphFilter( mode );
3399 #ifndef DISABLE_OCCVIEWER
3400 if ( sec == QString( "OCCViewer" ) && ( param == QString( "focus_type" ) ||
3401 param == QString( "focus_value" ) ) )
3403 int aType = resMgr->integerValue( "OCCViewer", "focus_type" );
3404 double aValue = resMgr->doubleValue( "OCCViewer", "focus_value" );
3405 QList<SUIT_ViewManager*> lst;
3406 viewManagers( OCCViewer_Viewer::Type(), lst );
3407 QListIterator<SUIT_ViewManager*> it( lst );
3408 while ( it.hasNext() )
3410 SUIT_ViewModel* vm = it.next()->getViewModel();
3411 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3414 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3415 occVM->setStereographicFocus( aType, aValue );
3420 #ifndef DISABLE_OCCVIEWER
3421 if ( sec == QString( "OCCViewer" ) && ( param == QString( "iod_type" ) ||
3422 param == QString( "iod_value" ) ) )
3424 int aType = resMgr->integerValue( "OCCViewer", "iod_type" );
3425 double aValue = resMgr->doubleValue( "OCCViewer", "iod_value" );
3426 QList<SUIT_ViewManager*> lst;
3427 viewManagers( OCCViewer_Viewer::Type(), lst );
3428 QListIterator<SUIT_ViewManager*> it( lst );
3429 while ( it.hasNext() )
3431 SUIT_ViewModel* vm = it.next()->getViewModel();
3432 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3435 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3436 occVM->setInterocularDistance( aType, aValue );
3441 #ifndef DISABLE_OCCVIEWER
3442 if ( sec == QString( "OCCViewer" ) && param == QString( "reverse_stereo" ) )
3444 bool reverse = resMgr->booleanValue( "OCCViewer", "reverse_stereo", false );
3445 QList<SUIT_ViewManager*> lst;
3446 viewManagers( OCCViewer_Viewer::Type(), lst );
3447 QListIterator<SUIT_ViewManager*> it( lst );
3448 while ( it.hasNext() )
3450 SUIT_ViewModel* vm = it.next()->getViewModel();
3451 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3454 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3455 occVM->setReverseStereo( reverse );
3460 #ifndef DISABLE_OCCVIEWER
3461 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_vsync" ) )
3463 bool enable = resMgr->booleanValue( "OCCViewer", "enable_vsync", true );
3464 QList<SUIT_ViewManager*> lst;
3465 viewManagers( OCCViewer_Viewer::Type(), lst );
3466 QListIterator<SUIT_ViewManager*> it( lst );
3467 while ( it.hasNext() )
3469 SUIT_ViewModel* vm = it.next()->getViewModel();
3470 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3473 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3474 occVM->setVSync( enable );
3479 #ifndef DISABLE_OCCVIEWER
3480 if ( sec == QString( "OCCViewer" ) && param == QString( "enable_quad_buffer_support" ) )
3482 bool enable = resMgr->booleanValue( "OCCViewer", "enable_quad_buffer_support", false );
3483 QList<SUIT_ViewManager*> lst;
3484 viewManagers( OCCViewer_Viewer::Type(), lst );
3485 QListIterator<SUIT_ViewManager*> it( lst );
3486 while ( it.hasNext() )
3488 SUIT_ViewModel* vm = it.next()->getViewModel();
3489 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3492 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3493 occVM->setQuadBufferSupport( enable );
3498 if ( sec == QString( "3DViewer" ) && param == QString( "zooming_mode" ) )
3500 int mode = resMgr->integerValue( "3DViewer", "zooming_mode", 0 );
3501 QList<SUIT_ViewManager*> lst;
3502 #ifndef DISABLE_OCCVIEWER
3503 viewManagers( OCCViewer_Viewer::Type(), lst );
3504 QListIterator<SUIT_ViewManager*> itOCC( lst );
3505 while ( itOCC.hasNext() )
3507 SUIT_ViewModel* vm = itOCC.next()->getViewModel();
3508 if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
3511 OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
3512 occVM->setZoomingStyle( mode );
3515 #ifndef DISABLE_VTKVIEWER
3516 #ifndef DISABLE_SALOMEOBJECT
3517 viewManagers( SVTK_Viewer::Type(), lst );
3518 QListIterator<SUIT_ViewManager*> itVTK( lst );
3519 while ( itVTK.hasNext() )
3521 SUIT_ViewModel* vm = itVTK.next()->getViewModel();
3522 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3525 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3526 if( vtkVM ) vtkVM->setZoomingStyle( mode );
3532 #ifndef DISABLE_VTKVIEWER
3533 if ( sec == QString( "VTKViewer" ) && (param == QString( "speed_value" ) || param == QString( "speed_mode" )) )
3535 int speed = resMgr->integerValue( "VTKViewer", "speed_value", 10 );
3536 int mode = resMgr->integerValue( "VTKViewer", "speed_mode", 0 );
3537 QList<SUIT_ViewManager*> lst;
3538 #ifndef DISABLE_SALOMEOBJECT
3539 viewManagers( SVTK_Viewer::Type(), lst );
3540 QListIterator<SUIT_ViewManager*> it( lst );
3541 while ( it.hasNext() )
3543 SUIT_ViewModel* vm = it.next()->getViewModel();
3544 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3547 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3548 if( vtkVM ) vtkVM->setIncrementalSpeed( speed, mode );
3554 #ifndef DISABLE_VTKVIEWER
3555 if ( sec == QString( "VTKViewer" ) && param == QString( "projection_mode" ) )
3557 int mode = resMgr->integerValue( "VTKViewer", "projection_mode", 0 );
3558 QList<SUIT_ViewManager*> lst;
3559 #ifndef DISABLE_SALOMEOBJECT
3560 viewManagers( SVTK_Viewer::Type(), lst );
3561 QListIterator<SUIT_ViewManager*> it( lst );
3562 while ( it.hasNext() )
3564 SUIT_ViewModel* vm = it.next()->getViewModel();
3565 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3568 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3569 if( vtkVM ) vtkVM->setProjectionMode( mode );
3575 #ifndef DISABLE_VTKVIEWER
3576 if ( sec == QString( "VTKViewer" ) && param == QString( "stereo_type" ) )
3578 int mode = resMgr->integerValue( "VTKViewer", "stereo_type", 0 );
3579 QList<SUIT_ViewManager*> lst;
3580 #ifndef DISABLE_SALOMEOBJECT
3581 viewManagers( SVTK_Viewer::Type(), lst );
3582 QListIterator<SUIT_ViewManager*> it( lst );
3583 while ( it.hasNext() )
3585 SUIT_ViewModel* vm = it.next()->getViewModel();
3586 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3589 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3590 if( vtkVM ) vtkVM->setStereoType( mode );
3596 #ifndef DISABLE_VTKVIEWER
3597 if ( sec == QString( "VTKViewer" ) && param == QString( "anaglyph_filter" ) )
3599 int mode = resMgr->integerValue( "VTKViewer", "anaglyph_filter", 0 );
3600 QList<SUIT_ViewManager*> lst;
3601 #ifndef DISABLE_SALOMEOBJECT
3602 viewManagers( SVTK_Viewer::Type(), lst );
3603 QListIterator<SUIT_ViewManager*> it( lst );
3604 while ( it.hasNext() )
3606 SUIT_ViewModel* vm = it.next()->getViewModel();
3607 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3610 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3611 if( vtkVM ) vtkVM->setAnaglyphFilter( mode );
3617 #ifndef DISABLE_VTKVIEWER
3618 if ( sec == QString( "VTKViewer" ) && param == QString( "enable_quad_buffer_support" ) )
3620 int enable = resMgr->booleanValue( "VTKViewer", "enable_quad_buffer_support", false );
3621 QList<SUIT_ViewManager*> lst;
3622 #ifndef DISABLE_SALOMEOBJECT
3623 viewManagers( SVTK_Viewer::Type(), lst );
3624 QListIterator<SUIT_ViewManager*> it( lst );
3625 while ( it.hasNext() )
3627 SUIT_ViewModel* vm = it.next()->getViewModel();
3628 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3631 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3632 if( vtkVM ) vtkVM->setQuadBufferSupport( enable );
3638 #ifndef DISABLE_VTKVIEWER
3639 if ( sec == QString( "VTKViewer" ) && param == QString( "preselection" ) )
3641 int mode = resMgr->integerValue( "VTKViewer", "preselection", 0 );
3642 QList<SUIT_ViewManager*> lst;
3643 #ifndef DISABLE_SALOMEOBJECT
3644 viewManagers( SVTK_Viewer::Type(), lst );
3645 QListIterator<SUIT_ViewManager*> it( lst );
3646 while ( it.hasNext() )
3648 SUIT_ViewModel* vm = it.next()->getViewModel();
3649 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3652 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3653 if( vtkVM ) vtkVM->setPreSelectionMode( mode );
3659 #ifndef DISABLE_VTKVIEWER
3660 if ( sec == QString( "VTKViewer" ) && param == QString( "enable_selection" ) )
3662 bool isToEnableSelection = resMgr->booleanValue( "VTKViewer", "enable_selection", true );
3663 QList<SUIT_ViewManager*> lst;
3664 #ifndef DISABLE_SALOMEOBJECT
3665 viewManagers( SVTK_Viewer::Type(), lst );
3666 QListIterator<SUIT_ViewManager*> it( lst );
3667 while ( it.hasNext() )
3669 SUIT_ViewModel* vm = it.next()->getViewModel();
3670 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3673 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3674 if( vtkVM ) vtkVM->enableSelection( isToEnableSelection );
3680 #ifndef DISABLE_VTKVIEWER
3681 if ( sec == QString( "VTKViewer" ) && (param == QString( "spacemouse_func1_btn" ) ||
3682 param == QString( "spacemouse_func2_btn" ) ||
3683 param == QString( "spacemouse_func5_btn" ) ) )
3685 int btn1 = resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", 1 );
3686 int btn2 = resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", 2 );
3687 int btn3 = resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", 9 );
3688 QList<SUIT_ViewManager*> lst;
3689 #ifndef DISABLE_SALOMEOBJECT
3690 viewManagers( SVTK_Viewer::Type(), lst );
3691 QListIterator<SUIT_ViewManager*> it( lst );
3692 while ( it.hasNext() )
3694 SUIT_ViewModel* vm = it.next()->getViewModel();
3695 if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
3698 SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
3699 if( vtkVM ) vtkVM->setSpacemouseButtons( btn1, btn2, btn3 );
3704 if( sec=="ObjectBrowser" )
3706 SUIT_DataBrowser* ob = objectBrowser();
3710 if ( param=="auto_size_first" )
3712 bool autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
3713 ob->setAutoSizeFirstColumn( autoSizeFirst );
3714 if ( autoSizeFirst )
3715 ob->adjustFirstColumnWidth();
3717 else if ( param=="auto_size" ) {
3718 bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
3719 ob->setAutoSizeColumns(autoSize);
3721 ob->adjustColumnsWidth();
3723 else if ( param=="resize_on_expand_item" ) {
3724 bool resizeOnExpandItem = resMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
3725 ob->setResizeOnExpandItem(resizeOnExpandItem);
3727 else if ( param == "auto_hide_search_tool" ) {
3728 ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
3734 if( param=="auto_save_interval" ) {
3735 myAutoSaveTimer->stop();
3736 int autoSaveInterval = resMgr->integerValue( "Study", "auto_save_interval", 0 );
3737 if ( activeStudy() && autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
3741 #ifndef DISABLE_PYCONSOLE
3742 if( sec=="PyConsole" && pythonConsole() )
3744 if ( param=="font" ) {
3745 pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) );
3747 else if ( param=="show_banner" ) {
3748 pythonConsole()->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
3750 else if ( param=="auto_completion" ) {
3751 pythonConsole()->setAutoCompletion( resMgr->booleanValue( "PyConsole", "auto_completion", true ) );
3758 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3760 if ( param == "visible_count" )
3761 mru->setVisibleCount( resMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
3762 else if ( param == "max_count" )
3763 mru->setHistoryCount( resMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
3764 else if ( param == "insert_mode" )
3765 mru->setInsertMode( resMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
3766 else if ( param == "link_type" )
3767 mru->setLinkType( resMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
3768 else if ( param == "show_clear" )
3769 mru->setClearPossible( resMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
3770 else if ( param == "show_mru" )
3771 mru->setVisible( resMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
3774 if ( sec == "language" && param == "language" )
3776 // VSR 18.06.2015 : commented out : single warning dialog box is now shown by the LightApp_PreferencesDlg
3777 //SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LANG_CHANGED" ) );
3779 if ( sec == "language" && param == "locale")
3781 // VSR 18.06.2015: commented out : single warning dialog box is now shown by the LightApp_PreferencesDlg
3782 //SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LOCALE_CHANGED" ) );
3784 if ( sec == "desktop" && param == "opaque_resize" ) {
3785 bool opaqueResize = resMgr->booleanValue( "desktop", "opaque_resize", false );
3786 // RNV: This code has been commented, because clearing of the QMainWindow::AnimatedDocks option
3787 // leads to strange behaviour of the dockable windows (at least at qt-5.6.1):
3788 // any dockable window can't be docked to the another area, except initial area.
3789 // It is possible to move window to another area, but it always returns to the initial area.
3791 // QMainWindow::DockOptions dopts = desktop()->dockOptions();
3792 // if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
3793 // else dopts &= ~QMainWindow::AnimatedDocks;
3794 // desktop()->setDockOptions( dopts );
3795 desktop()->setOpaqueResize( opaqueResize );
3796 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
3797 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
3800 #ifndef DISABLE_PLOT2DVIEWER
3801 QList<SUIT_ViewManager*> lst;
3802 viewManagers( Plot2d_Viewer::Type(), lst );
3803 QListIterator<SUIT_ViewManager*> itPlot2d( lst );
3804 while ( itPlot2d.hasNext() ) {
3805 SUIT_ViewManager* viewMgr = itPlot2d.next();
3806 SUIT_ViewModel* vm = viewMgr->getViewModel();
3807 if ( !vm || !vm->inherits( "Plot2d_Viewer" ) )
3810 //Plot2d_Viewer* Plot2dVM = dynamic_cast<Plot2d_Viewer*>( vm );
3812 viewMgr->setViewModel( vm );
3813 Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
3815 Plot2d_ViewFrame* frame = wnd->getViewFrame();
3816 frame->SetPreference();
3825 void LightApp_Application::loadPreferences()
3827 CAM_Application::loadPreferences();
3829 SUIT_ResourceMgr* aResMgr = resourceMgr();
3834 static bool mru_load = true;
3837 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3839 mru->setVisible( aResMgr->booleanValue( "MRU", "show_mru", false ) ); // do not show MRU menu item by default
3840 mru->setVisibleCount( aResMgr->integerValue( "MRU", "visible_count", 5 ) ); // 5 MRU items by default
3841 mru->setHistoryCount( aResMgr->integerValue( "MRU", "max_count", -1 ) ); // unlimited history by default
3842 mru->setInsertMode( aResMgr->integerValue( "MRU", "insert_mode", 0 ) ); // QtxMRUAction::MoveFirst by default
3843 mru->setLinkType( aResMgr->integerValue( "MRU", "link_type", 0 ) ); // QtxMRUAction::LinkAuto by default
3844 mru->setClearPossible( aResMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
3845 mru->loadLinks( aResMgr, "MRU" );
3851 QStringList mods = aResMgr->parameters( "windows_visibility" );
3852 for ( QStringList::const_iterator itr = mods.begin(); itr != mods.end(); ++itr )
3855 if ( aResMgr->value( "windows_visibility", *itr, arr ) )
3856 myWinVis.insert( *itr, arr );
3860 desktop()->retrieveGeometry( aResMgr->stringValue( "desktop", "geometry" ) );
3861 bool opaqueResize = aResMgr->booleanValue( "desktop", "opaque_resize", false );
3862 // QMainWindow::DockOptions dopts = desktop()->dockOptions();
3863 // if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
3864 // else dopts &= ~QMainWindow::AnimatedDocks;
3865 // desktop()->setDockOptions( dopts );
3866 desktop()->setOpaqueResize( opaqueResize );
3867 if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
3868 dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
3875 void LightApp_Application::savePreferences()
3877 CAM_Application::savePreferences();
3879 saveDockWindowsState();
3881 SUIT_ResourceMgr* aResMgr = resourceMgr();
3886 QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
3888 mru->saveLinks( aResMgr, "MRU" );
3890 for ( WinVis::const_iterator itr = myWinVis.begin(); itr != myWinVis.end(); ++itr )
3891 aResMgr->setValue( "windows_visibility", itr.key(), itr.value() );
3894 aResMgr->setValue( "desktop", "geometry", desktop()->storeGeometry() );
3896 #if GUI_DEVELOPMENT > 0
3897 aResMgr->setValue( "salome", "version", QString(GUI_VERSION_STR)+"dev" );
3899 aResMgr->setValue( "salome", "version", QString(GUI_VERSION_STR) );
3906 Updates desktop title
3908 void LightApp_Application::updateDesktopTitle()
3910 QString aTitle = applicationName();
3911 QString aVer = applicationVersion();
3912 if ( !aVer.isEmpty() )
3913 aTitle += QString( " " ) + aVer;
3915 if ( activeStudy() ) {
3916 QString sName = SUIT_Tools::file( activeStudy()->studyName().trimmed(), false );
3917 aTitle += QString( " - [%1]" ).arg( sName );
3920 desktop()->setWindowTitle( aTitle );
3924 \brief Get map of the operations which can be performed
3925 on the module activation.
3927 The method should return the map of the kind \c {<id>:<name>}
3928 where \c <id> is an integer identifier of the operation and
3929 \c <name> is a title for the button to be added to the
3930 dialog box. After user selects the required operation by the
3931 clicking the corresponding button in the dialog box, its identifier
3932 is passed to the moduleActionSelected() method to process
3935 \return map of the operations
3936 \sa moduleActionSelected()
3938 QMap<int, QString> LightApp_Application::activateModuleActions() const
3940 QMap<int, QString> opmap;
3941 opmap.insert( NewStudyId, tr( "ACTIVATE_MODULE_OP_NEW" ) );
3942 opmap.insert( OpenStudyId, tr( "ACTIVATE_MODULE_OP_OPEN" ) );
3947 \brief Called when the used selectes required operation chosen
3948 from "Activate module" dialog box.
3950 Performs the required operation according to the user choice.
3952 \param id operation identifier
3953 \sa activateModuleActions()
3955 void LightApp_Application::moduleActionSelected( const int id )
3970 Updates windows after close document
3972 void LightApp_Application::afterCloseDoc()
3976 CAM_Application::afterCloseDoc();
3980 Updates actions of active module
3982 void LightApp_Application::updateModuleActions()
3985 if ( activeModule() ) {
3986 modName = activeModule()->moduleName();
3987 if ( !isModuleAccessible( modName ) ) {
3988 QList<SUIT_Application*> apps = SUIT_Session::session()->applications();
3989 foreach( SUIT_Application* app, apps ) {
3990 LightApp_Application* lapp = dynamic_cast<LightApp_Application*>( app );
3991 if ( lapp && lapp != this )
3992 lapp->removeModuleAction( modName );
3997 LightApp_ModuleAction* moduleAction =
3998 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
4000 moduleAction->setActiveModule( modName );
4003 void LightApp_Application::removeModuleAction( const QString& modName )
4005 LightApp_ModuleAction* moduleAction =
4006 qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
4008 moduleAction->removeModule( modName );
4011 bool LightApp_Application::checkModule( const QString& title )
4013 if ( title.isEmpty() )
4016 QString library = moduleLibrary( title, true );
4017 if ( library.isEmpty() )
4020 QString name = moduleName( title );
4022 bool isPyModule = library.contains( "SalomePyQtGUI" ) || library.contains( "SalomePyQtGUILight" );
4026 paths = QString( ::getenv( "PATH" ) ).split( ";", QString::SkipEmptyParts );
4027 #elif defined(__APPLE__)
4028 paths = QString( ::getenv( "DYLD_LIBRARY_PATH" ) ).split( ":", QString::SkipEmptyParts );
4030 paths = QString( ::getenv( "LD_LIBRARY_PATH" ) ).split( ":", QString::SkipEmptyParts );
4033 bool isFound = false;
4034 QStringList::const_iterator it;
4035 for ( it = paths.begin(); it != paths.end() && !isFound; ++it )
4037 isFound = QFileInfo( Qtx::addSlash( *it ) + library ).exists();
4043 "****************************************************************" << std::endl <<
4044 " Warning: library " << qPrintable( library ) << " is not found!" << std::endl <<
4045 " Module " << qPrintable( title ) << " will not be available in GUI mode!" << std::endl <<
4046 "****************************************************************" << std::endl);
4052 QString pyModule = QString( "%1GUI.py" ).arg( name );
4053 paths = QString( ::getenv( "PYTHONPATH" ) ).split( ":", QString::SkipEmptyParts );
4056 for ( it = paths.begin(); it != paths.end() && !isFound; ++it )
4058 isFound = QFileInfo( Qtx::addSlash( *it ) + pyModule ).exists();
4064 "****************************************************************" << std::endl <<
4065 " Warning: Python module " << qPrintable( pyModule ) << " is not found!" << std::endl <<
4066 " Module " << qPrintable( title ) << " will not be available in GUI mode!" << std::endl <<
4067 "****************************************************************" << std::endl);
4076 Gets current windows.
4077 \param winMap - output current windows map.
4079 void LightApp_Application::currentWindows( QMap<int, int>& winMap ) const
4082 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
4083 ((LightApp_Module*)activeModule())->windows( winMap );
4085 defaultWindows( winMap );
4089 Gets current view managers.
4090 \param lst - output current view managers list.
4092 void LightApp_Application::currentViewManagers( QStringList& lst ) const
4095 if ( !activeStudy() )
4098 if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
4099 ((LightApp_Module*)activeModule())->viewManagers( lst );
4101 defaultViewManagers( lst );
4107 void LightApp_Application::updateWindows()
4109 QMap<int, int> winMap;
4110 currentWindows( winMap );
4112 for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
4114 if ( !dockWindow( it.key() ) )
4115 getWindow( it.key() );
4118 for ( WinMap::ConstIterator it = myWin.begin(); it != myWin.end(); ++it )
4120 QWidget* wid = it.value();
4121 if ( winMap.contains( it.key() ) )
4122 wid->setVisible( true );
4127 loadDockWindowsState();
4131 Updates view managers
4133 void LightApp_Application::updateViewManagers()
4136 currentViewManagers( lst );
4138 for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
4139 getViewManager( *it, true );
4143 Loads windows geometry
4145 void LightApp_Application::loadDockWindowsState()
4149 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
4150 bool storeWin = aResMgr->booleanValue( "Study", "store_positions", true );
4151 bool storeTb = aResMgr->booleanValue( "Study", "store_tool_positions", true );
4154 if ( activeModule() )
4155 modName = activeModule()->name();
4156 else if ( activeStudy() )
4157 modName = "nomodule";
4159 QtxResourceMgr::WorkingMode prevMode = aResMgr->setWorkingMode( QtxResourceMgr::IgnoreUserValues );
4160 QByteArray aDefaultState;
4161 aResMgr->value( "windows_geometry", modName, aDefaultState );
4162 QByteArray aDefaultVisibility;
4163 aResMgr->value( "windows_visibility", modName, aDefaultVisibility );
4164 bool hasDefaultVisibility = !aDefaultVisibility.isEmpty();
4165 aResMgr->setWorkingMode( prevMode );
4167 if( !storeWin && !storeTb && aDefaultState.isEmpty() && !hasDefaultVisibility)
4170 if ( aResMgr->hasValue("windows_geometry" ,modName ) ) {
4171 long version = Qtx::versionToId( aResMgr->stringValue( "windows_geometry_version", modName, "" ) );
4173 if ( version > Qtx::versionToId( "7.4.1" ) )
4174 aResMgr->value( "windows_geometry", modName , arr );
4176 arr = aDefaultState;
4177 QByteArray aTargetArray = processState(arr, storeWin, storeTb, true, aDefaultState);
4178 desktop()->restoreState( aTargetArray );
4181 QStringList mainToolbarsNames;
4182 mainToolbarsNames << "SalomeStandard" << "SalomeModules";
4183 QList<QToolBar*> mainToolbars = findToolBars( mainToolbarsNames );
4184 foreach( QToolBar* tb, mainToolbars ) tb->setVisible( true );
4186 if ( !myWinVis.contains( modName ) && aDefaultVisibility.isEmpty())
4189 QMap<QString, bool> *tbMap = 0;
4190 QMap<QString, bool> *dwMap = 0;
4192 QMap<QString, bool> userTbMap, userDwMap;
4193 dockWindowsState( myWinVis[modName], userTbMap, userDwMap );
4195 QMap<QString, bool> defaultTbMap, defaultDwMap;
4196 if(hasDefaultVisibility) {
4197 dockWindowsState( aDefaultVisibility, defaultTbMap, defaultDwMap);
4203 if(hasDefaultVisibility){
4204 tbMap = &defaultTbMap;
4211 if(hasDefaultVisibility){
4212 dwMap = &defaultDwMap;
4217 QList<QToolBar*> tbList = findToolBars();
4218 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit )
4220 QToolBar* tb = *tit;
4221 if ( tbMap->contains( tb->objectName() ) ) {
4222 tb->setVisible( (*tbMap)[tb->objectName()] );
4228 QList<QDockWidget*> dwList = desktop()->findChildren<QDockWidget*>();
4229 for ( QList<QDockWidget*>::iterator dit = dwList.begin(); dit != dwList.end(); ++dit )
4231 QDockWidget* dw = *dit;
4233 QObject* po = Qtx::findParent( dw, "QMainWindow" );
4234 if ( po != desktop() )
4237 if ( dwMap->contains( dw->objectName() ) )
4238 dw->setVisible( (*dwMap)[dw->objectName()] );
4246 Saves windows geometry
4248 void LightApp_Application::saveDockWindowsState()
4253 bool storeWin = resourceMgr()->booleanValue( "Study", "store_positions", true );
4254 bool storeTb = resourceMgr()->booleanValue( "Study", "store_tool_positions", true );
4256 if( !storeWin && !storeTb )
4260 if ( activeModule() )
4261 modName = activeModule()->name();
4262 else if ( activeStudy() )
4263 modName = "nomodule";
4265 QString versionId = GUI_VERSION_STR;
4266 #if GUI_DEVELOPMENT > 0
4270 QByteArray arr = desktop()->saveState();
4271 resourceMgr()->setValue( "windows_geometry", modName, processState(arr, storeWin, storeTb, false) );
4272 resourceMgr()->setValue( "windows_geometry_version", modName, versionId );
4275 if ( myWinVis.contains( modName ) )
4276 visArr = myWinVis[modName];
4278 QMap<QString, bool> tbMap, dwMap;
4279 dockWindowsState( visArr, tbMap, dwMap );
4281 QList<QToolBar*> tbList = desktop()->findChildren<QToolBar*>();
4282 for ( QList<QToolBar*>::iterator it = tbList.begin(); it != tbList.end(); ++it )
4285 tbMap.insert( tb->objectName(), tb->toggleViewAction()->isChecked() );
4288 QList<QDockWidget*> dwList = desktop()->findChildren<QDockWidget*>();
4289 for ( QList<QDockWidget*>::iterator it = dwList.begin(); it != dwList.end(); ++it )
4291 QDockWidget* wid = *it;
4292 dwMap.insert( wid->objectName(), wid->toggleViewAction()->isChecked() );
4295 visArr = dockWindowsState( tbMap, dwMap );
4297 myWinVis.insert( modName, visArr );
4300 QByteArray LightApp_Application::dockWindowsState( const QMap<QString, bool>& tb, const QMap<QString, bool>& dw ) const
4303 QDataStream stream( &visArr, QIODevice::WriteOnly );
4305 stream << (uchar)ToolBarMarker;
4306 stream << tb.size();
4307 for ( QMap<QString, bool>::const_iterator tit = tb.begin(); tit != tb.end(); ++tit )
4309 stream << tit.key();
4310 stream << (uchar)( tit.value() ? 1 : 0 );
4313 stream << (uchar)DockWidgetMarker;
4314 stream << dw.size();
4315 for ( QMap<QString, bool>::const_iterator wit = dw.begin(); wit != dw.end(); ++wit )
4317 stream << wit.key();
4318 stream << (uchar)( wit.value() ? 1 : 0 );
4324 void LightApp_Application::dockWindowsState( const QByteArray& arr, QMap<QString, bool>& tb, QMap<QString, bool>& dw ) const
4329 QByteArray visArr = arr;
4330 QDataStream stream( &visArr, QIODevice::ReadOnly );
4334 if ( marker != ToolBarMarker )
4339 for ( int i = 0; i < lines; ++i )
4342 stream >> objectName;
4345 tb.insert( objectName, shown );
4349 if ( marker != DockWidgetMarker )
4353 for ( int j = 0; j < lines; ++j )
4356 stream >> objectName;
4359 dw.insert( objectName, shown );
4364 Adds icon names for modules
4366 void LightApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) const
4370 SUIT_ResourceMgr* resMgr = resourceMgr();
4374 QStringList modList;
4375 modules( modList, false );
4377 for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )
4379 QString modName = *it;
4380 QString modIntr = moduleName( modName );
4381 QString modIcon = resMgr->stringValue( modIntr, "icon", QString() );
4383 if ( modIcon.isEmpty() )
4386 if ( SUIT_Tools::extension( modIcon ).isEmpty() )
4387 modIcon += QString( ".png" );
4389 iconMap.insert( modName, modIcon );
4394 Inserts items in popup, which necessary for current application
4396 void LightApp_Application::contextMenuPopup( const QString& type, QMenu* thePopup, QString& title )
4399 LightApp_SelectionMgr* selMgr = LightApp_Application::selectionMgr();
4400 bool cacheIsOn = selMgr->isSelectionCacheEnabled();
4401 selMgr->setSelectionCacheEnabled( true );
4403 SUIT_DataBrowser* ob = objectBrowser();
4405 CAM_Application::contextMenuPopup( type, thePopup, title );
4407 if ( ob && type == ob->popupClientType() ) {
4408 thePopup->addSeparator();
4409 QAction* a = thePopup->addAction( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
4410 if ( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) )
4411 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) );
4414 #ifndef DISABLE_SALOMEOBJECT
4415 if ( selMgr && ob ) {
4416 SALOME_ListIO selected;
4417 selMgr->selectedObjects( selected );
4418 if(selected.Extent() == 1){
4419 Handle(SALOME_InteractiveObject) anIObject = selected.First();
4420 SUIT_DataObject* obj = findObject(anIObject->getEntry());
4421 if(obj && obj->renameAllowed()) {
4422 QAction* a = new QAction(tr("MEN_RENAME_OBJ"), thePopup);
4423 connect( a, SIGNAL( triggered(bool) ), ob, SLOT( onStartEditing() ) );
4424 if ( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) )
4425 a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) );
4427 QList<QAction*> acts = thePopup->actions();
4428 QAction* firstAction = acts.count() > 0 ? acts.first() : 0;
4429 thePopup->insertAction(firstAction,a);
4435 selMgr->setSelectionCacheEnabled( cacheIsOn );
4441 void LightApp_Application::createEmptyStudy()
4443 CAM_Application::createEmptyStudy();
4445 if ( objectBrowser() )
4446 objectBrowser()->updateTree();
4448 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
4449 if ( aResMgr && activeStudy() ) {
4450 int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
4451 if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
4456 void LightApp_Application::setDesktop( SUIT_Desktop* desk )
4458 CAM_Application::setDesktop( desk );
4461 connect( desk, SIGNAL( message( const QString& ) ),
4462 this, SLOT( onDesktopMessage( const QString& ) ), Qt::UniqueConnection );
4463 connect( desk, SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
4464 this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
4465 /* connect( desk, SIGNAL( windowMoved( SUIT_ViewWindow* ) ),
4466 this, SLOT( onWindowMoved( SUIT_ViewWindow* ) ), Qt::UniqueConnection ); */
4472 \param mod - module to be activated
4474 bool LightApp_Application::activateModule( CAM_Module* mod )
4476 bool res = CAM_Application::activateModule( mod );
4478 if ( objectBrowser() )
4479 objectBrowser()->updateTree();
4485 \return keyborad accelerators manager object
4487 SUIT_Accel* LightApp_Application::accel() const
4493 Removes dead widget container from map
4495 void LightApp_Application::onWCDestroyed( QObject* ob )
4497 // remove destroyed widget container from windows map
4498 for ( WinMap::ConstIterator itr = myWin.begin(); itr != myWin.end(); ++itr )
4500 if ( itr.value() != ob )
4503 int key = itr.key();
4504 myWin.remove( key );
4509 void LightApp_Application::onMRUActivated( const QString& name )
4511 SUIT_Session* s = SUIT_Session::session();
4512 if ( s && s->activeApplication() == this )
4516 void LightApp_Application::onStylePreferences()
4518 #ifdef USE_SALOME_STYLE
4519 Style_PrefDlg dlg( desktop() );
4522 resourceMgr()->setValue( "Style", "use_salome_style", Style_Salome::isActive() );
4523 #endif // USE_SALOME_STYLE
4526 void LightApp_Application::onFullScreen(){
4527 if(myScreenHelper) {
4528 if(desktop()->isFullScreen())
4529 myScreenHelper->switchToNormalScreen();
4531 myScreenHelper->switchToFullScreen();
4536 Connects just added view manager
4538 void LightApp_Application::addViewManager( SUIT_ViewManager* vm )
4540 connect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
4541 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
4542 CAM_Application::addViewManager( vm );
4546 Remove view manager from memory
4548 void LightApp_Application::removeViewManager( SUIT_ViewManager* vm )
4550 disconnect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
4551 this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
4552 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
4554 aStudy->removeObjectProperties( vm->getGlobalId() );
4556 CAM_Application::removeViewManager( vm );
4558 LightApp_SelectionMgr* selMgr = selectionMgr();
4559 QList<SUIT_Selector*> selectors;
4560 selMgr->selectors( selectors );
4561 foreach( SUIT_Selector* selector, selectors ) {
4562 if ( selector->owner() == vm->getViewModel() ) {
4567 // IPAL22894: Crash on closing OCC view
4573 Renames active window of desktop
4575 void LightApp_Application::onRenameWindow()
4580 QWidget* w = desktop()->activeWindow();
4585 QString name = QInputDialog::getText( w, tr( "TOT_RENAME" ), tr( "PRP_RENAME" ), QLineEdit::Normal, w->windowTitle(), &ok );
4586 if( ok && !name.isEmpty() )
4587 w->setWindowTitle( name );
4591 Closes active window of desktop
4593 void LightApp_Application::onCloseWindow()
4598 QWidget* w = desktop()->activeWindow();
4606 Closes all windows of desktop
4608 void LightApp_Application::onCloseAllWindow()
4610 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
4614 QList<SUIT_ViewWindow*> wndList = desk->windows();
4615 SUIT_ViewWindow* wnd;
4616 foreach( wnd, wndList )
4624 Groups all windows of desktop
4626 void LightApp_Application::onGroupAllWindow()
4628 STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
4632 QtxWorkstack* wgStack = desk->workstack();
4638 \return default name for an active study
4640 void LightApp_Application::setDefaultStudyName( const QString& theName )
4642 QStringList anInfoList;
4643 modules( anInfoList, false );
4645 LightApp_Study* aStudy = (LightApp_Study*)activeStudy();
4646 if( anInfoList.count() == 1 && // to avoid a conflict between different modules
4647 !aStudy->isSaved() )
4649 aStudy->setStudyName( theName );
4650 updateDesktopTitle();
4655 Custom event handler
4657 bool LightApp_Application::event( QEvent* e )
4659 if( e && e->type()==2000 )
4661 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
4662 QString* d = ( QString* )ce->data();
4663 if( SUIT_MessageBox::question(0, tr("WRN_WARNING"),
4665 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
4666 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
4667 showPreferences( tr( "PREF_APP" ) );
4672 return CAM_Application::event( e );
4675 /*! Check data object */
4676 bool LightApp_Application::checkDataObject(LightApp_DataObject* theObj)
4680 bool isSuitable = !theObj->entry().isEmpty() &&
4681 !theObj->componentDataType().isEmpty() &&
4682 !theObj->name().isEmpty();
4689 int LightApp_Application::openChoice( const QString& aName )
4691 int choice = CAM_Application::openChoice( aName );
4693 if ( choice == OpenExist ) // The document is already open.
4695 // Do you want to reload it?
4696 if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "QUE_DOC_ALREADYOPEN" ).arg( aName ),
4697 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No ) == SUIT_MessageBox::Yes )
4698 choice = OpenReload;
4704 bool LightApp_Application::openAction( const int choice, const QString& aName )
4711 STD_Application* app = 0;
4712 SUIT_Session* session = SUIT_Session::session();
4713 QList<SUIT_Application*> appList = session->applications();
4714 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !app; ++it )
4716 if ( (*it)->activeStudy() && (*it)->activeStudy()->studyName() == aName )
4717 app = ::qobject_cast<STD_Application*>( *it );
4722 app->onCloseDoc( false );
4723 appList = session->applications();
4724 STD_Application* other = 0;
4725 for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !other; ++it )
4726 other = ::qobject_cast<STD_Application*>( *it );
4729 res = other->onOpenDoc( aName );
4734 res = CAM_Application::openAction( choice, aName );
4741 QStringList LightApp_Application::viewManagersTypes() const
4743 QStringList aTypesList;
4744 aTypesList += myUserWmTypes;
4745 #ifndef DISABLE_GLVIEWER
4746 aTypesList<<GLViewer_Viewer::Type();
4748 #ifndef DISABLE_PLOT2DVIEWER
4749 aTypesList<<Plot2d_Viewer::Type();
4751 #ifndef DISABLE_QXGRAPHVIEWER
4752 aTypesList<<QxScene_Viewer::Type();
4754 #ifndef DISABLE_PVVIEWER
4755 aTypesList<<PVViewer_Viewer::Type();
4757 #ifndef DISABLE_PYVIEWER
4758 aTypesList<<PyViewer_Viewer::Type();
4760 #ifndef DISABLE_OCCVIEWER
4761 aTypesList<<OCCViewer_Viewer::Type();
4763 #ifndef DISABLE_VTKVIEWER
4764 #ifndef DISABLE_SALOMEOBJECT
4765 aTypesList<<SVTK_Viewer::Type();
4767 aTypesList<<VTKViewer_Viewer::Type();
4773 * Removes all view managers of known types
4774 * Other view managers are ignored
4776 void LightApp_Application::clearKnownViewManagers()
4778 QStringList aTypesList = viewManagersTypes();
4779 QList<SUIT_ViewManager*> aMgrList;
4780 viewManagers( aMgrList );
4781 foreach (SUIT_ViewManager* aMgr, aMgrList) {
4782 if (aTypesList.contains(aMgr->getType()))
4783 removeViewManager(aMgr);
4788 Copy of current selection
4790 void LightApp_Application::onCopy()
4792 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
4798 Paste of current data in clipboard
4800 void LightApp_Application::onPaste()
4802 LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
4808 Browse (i.e. set focus on) the published objects
4809 \param theIsApplyAndClose - flag indicating that the dialog for creating objects
4810 has been accepted by Ok (or Apply & Close) button
4811 \param theIsOptimizedBrowsing - flag switching to optimized browsing mode
4812 (to select the first published object only)
4813 \return entry of the selected object
4815 QString LightApp_Application::browseObjects( const QStringList& theEntryList,
4816 const bool theIsApplyAndClose,
4817 const bool theIsOptimizedBrowsing )
4820 if( SUIT_ResourceMgr* aResourceMgr = resourceMgr() )
4822 int aBrowsePolicy = aResourceMgr->integerValue( "ObjectBrowser", "browse_published_object", (int)BP_Never );
4823 switch( aBrowsePolicy )
4827 case BP_ApplyAndClose:
4828 if( !theIsApplyAndClose )
4836 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
4840 SUIT_DataBrowser* anOB = objectBrowser();
4844 SUIT_AbstractModel* aModel = dynamic_cast<SUIT_AbstractModel*>( anOB->model() );
4848 QStringListIterator anIter( theEntryList );
4849 if( theIsOptimizedBrowsing )
4851 // go to the last entry
4853 if( anIter.hasPrevious() )
4857 // scroll to each entry in the list
4858 // (in optimized mode - to the last entry only)
4860 LightApp_DataObject* anObject = 0;
4861 while( anIter.hasNext() )
4863 anEntry = anIter.next();
4864 if( !anEntry.isEmpty() )
4866 anObject = aStudy->findObjectByEntry( anEntry );
4869 QModelIndex anIndex = aModel->index( anObject );
4870 anOB->treeView()->scrollTo( anIndex );
4875 // always select the last object
4876 if( anObject && !anEntry.isEmpty() )
4878 QList<SUIT_Selector*> aSelectorList;
4879 selectionMgr()->selectors( "ObjectBrowser", aSelectorList );
4880 if( !aSelectorList.isEmpty() )
4882 if( LightApp_OBSelector* aSelector = dynamic_cast<LightApp_OBSelector*>( aSelectorList.first() ) )
4884 bool anIsAutoBlock = aSelector->autoBlock();
4886 // temporarily disable auto block, to emit LightApp_SelectionMgr::currentSelectionChanged() signal
4887 aSelector->setAutoBlock( false );
4889 SUIT_DataOwnerPtrList aList;
4890 #ifndef DISABLE_SALOMEOBJECT
4891 Handle(SALOME_InteractiveObject) aSObj = new SALOME_InteractiveObject
4892 ( anObject->entry().toLatin1().constData(),
4893 anObject->componentDataType().toLatin1().constData(),
4894 anObject->name().toLatin1().constData() );
4895 LightApp_DataOwner* owner = new LightApp_DataOwner( aSObj );
4897 LightApp_DataOwner* owner = new LightApp_DataOwner( anEntry );
4900 aList.append( owner );
4901 selectionMgr()->setSelected( aList );
4904 // restore auto block flag
4905 aSelector->setAutoBlock( anIsAutoBlock );
4913 SUIT_DataObject* LightApp_Application::findObject( const QString& id ) const
4915 LightApp_Study* study = dynamic_cast<LightApp_Study*>( activeStudy() );
4916 return study ? study->findObjectByEntry( id ) : 0;
4920 Checks that an object can be renamed.
4921 \param entry entry of the object
4922 \brief Return \c true if object can be renamed
4924 bool LightApp_Application::renameAllowed( const QString& /*entry*/) const {
4929 Rename object by entry.
4930 \param entry entry of the object
4931 \param name new name of the object
4932 \brief Return \c true if rename operation finished successfully, \c false otherwise.
4934 bool LightApp_Application::renameObject( const QString& entry, const QString& ) {
4938 /*! Process standard messages from desktop */
4939 void LightApp_Application::onDesktopMessage( const QString& message )
4941 const QString sectionSeparator = "/";
4943 if ( message.toLower() == "updateobjectbrowser" ||
4944 message.toLower() == "updateobjbrowser" ) {
4945 // update object browser
4946 updateObjectBrowser();
4948 else if ( message.toLower().startsWith( "activate_viewer" ) ) {
4949 QString vtype = message.split( sectionSeparator ).last();
4950 if ( !vtype.isEmpty() )
4951 getViewManager( vtype, true );
4954 QStringList data = message.split( sectionSeparator );
4955 if ( data.count() > 1 ) {
4956 QString msgType = data[0].trimmed();
4957 LightApp_Module* sMod = 0;
4958 CAM_Module* mod = module( msgType );
4960 mod = module( moduleTitle( msgType ) );
4961 if ( mod && mod->inherits( "LightApp_Module" ) )
4962 sMod = (LightApp_Module*)mod;
4964 if ( msgType.toLower() == "preferences" ) {
4965 // requested preferences change: should be given as "preferences/<section>/<name>/<value>"
4966 // for example "preferences/Study/multi_file_dump/true"
4967 if ( data.count() > 3 ) {
4968 QString section = data[1].trimmed();
4969 QString param = data[2].trimmed();
4970 QString value = QStringList( data.mid(3) ).join( sectionSeparator );
4971 resourceMgr()->setValue( section, param, value );
4975 // received message for the module
4976 QString msg = QStringList( data.mid(1) ).join( sectionSeparator );
4977 sMod->message( msg );
4985 Returns all top level toolbars.
4986 Note : Result list contains only main window toolbars, not including toolbars from viewers.
4988 QList<QToolBar*> LightApp_Application::findToolBars( const QStringList& names )
4990 QList<QToolBar*> aResult;
4991 QList<QToolBar*> tbList = desktop()->findChildren<QToolBar*>();
4992 for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit ) {
4993 QToolBar* tb = *tit;
4994 QObject* po = Qtx::findParent( tb, "QMainWindow" );
4995 if ( po != desktop() )
4997 if ( names.isEmpty() || names.contains( tb->objectName() ) )
5004 Internal method to parse toolbars and dockable windows state.
5006 QByteArray LightApp_Application::processState(QByteArray& input,
5007 const bool processWin,
5008 const bool processTb,
5009 const bool isRestoring,
5010 QByteArray defaultState) {
5013 bool hasDefaultState = !defaultState.isEmpty();
5014 bool isDockWinWriten = false;
5016 //Write date from users settings
5018 QDataStream tmpInputData(&input, QIODevice::ReadOnly);
5019 int marker, version;
5021 tmpInputData >> marker;
5022 tmpInputData >> version;
5023 tmpInputData >> dockmarker;
5024 tmpInputData >> nbDocWin;
5026 if(processWin && processTb && !isRestoring) {
5028 } else if(!processWin && !processTb ) {
5030 aRes = defaultState;
5032 QDataStream aData(&aRes, QIODevice::WriteOnly);
5033 QList<QToolBar*> aToolBars = findToolBars();
5036 for ( QList<QToolBar*>::iterator tit = aToolBars.begin(); tit != aToolBars.end(); ++tit ) {
5037 QToolBar* tb = *tit;
5038 aNames.append(tb->objectName());
5041 int toolBarMarkerIndex = getToolbarMarkerIndex(input,aNames);
5042 if(toolBarMarkerIndex < 0)
5044 QDataStream anInputData(&input, QIODevice::ReadOnly);
5046 int toolBarMarkerIndexDef;
5047 if(hasDefaultState) {
5048 toolBarMarkerIndexDef = getToolbarMarkerIndex(defaultState, aNames);
5049 if(toolBarMarkerIndexDef < 0)
5052 QDataStream anInputDataDef(&defaultState, QIODevice::ReadOnly);
5054 QDataStream* aTargetData = 0;
5055 int aTargetIndex = -1;
5057 QByteArray currentArr = desktop()->saveState();
5058 QDataStream anInputDataCur(¤tArr, QIODevice::ReadOnly);
5059 bool useInputData = !isRestoring || (isRestoring && nbDocWin > 0);
5060 if(processWin && useInputData) {
5061 aTargetData = &anInputData;
5062 aTargetIndex = toolBarMarkerIndex;
5064 //Write date from default settings
5065 if(hasDefaultState) {
5066 aTargetData = &anInputDataDef;
5067 aTargetIndex = toolBarMarkerIndexDef;
5069 //If no default state, write current snapshot of the dockable windows
5071 aTargetData = &anInputDataCur;
5072 int toolBarMarkerIndexCur = getToolbarMarkerIndex(currentArr, aNames);
5073 aTargetIndex = toolBarMarkerIndexCur;
5078 if(aTargetData && aTargetIndex >= 0 ) {
5079 aTargetData->device()->seek(0);
5080 while( aTargetData->device()->pos() < aTargetIndex ) {
5085 isDockWinWriten = true;
5092 aTargetData = &anInputData;
5093 aTargetIndex = toolBarMarkerIndex;
5095 if(hasDefaultState) {
5096 aTargetData = &anInputDataDef;
5097 aTargetIndex = toolBarMarkerIndexDef;
5101 if(aTargetData && aTargetIndex >= 0) {
5103 if(!isDockWinWriten ) {
5104 //Write version marker
5105 int marker, version;
5106 aTargetData->device()->seek(0);
5107 *aTargetData >> marker;
5108 *aTargetData >> version;
5111 aData << (uchar) QDockWidgetMarker;
5113 int shift = 4*sizeof(int) + sizeof(QSize);
5114 index = aTargetIndex - shift;
5116 index = aTargetIndex;
5119 aTargetData->device()->seek(index);
5120 while(!aTargetData->atEnd()) {
5125 } else { // Not treat toolbars
5126 aData << (uchar) QToolBarMarker;
5127 aData << (int) 0; //Nb toolbars = 0
5134 \brief Emits operationFinished signal.
5135 \param theModuleName the name of the module which perfomed the operation
5136 \param theOperationName the operation name
5137 \param theEntryList the list of the created objects entries
5139 void LightApp_Application::emitOperationFinished( const QString& theModuleName,
5140 const QString& theOperationName,
5141 const QStringList& theEntryList )
5143 emit operationFinished( theModuleName, theOperationName, theEntryList );
5147 Update visibility state of given objects
5149 void LightApp_Application::updateVisibilityState( DataObjectList& theList,
5150 SUIT_ViewModel* theViewModel )
5152 if ( !theViewModel || theList.isEmpty() ) return;
5154 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
5155 if ( !aStudy ) return;
5157 SALOME_View* aView = dynamic_cast<SALOME_View*>( theViewModel );
5159 for ( DataObjectList::iterator itr = theList.begin(); itr != theList.end(); ++itr ) {
5160 LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>(*itr);
5162 if ( !obj || aStudy->isComponent( obj->entry() ) )
5165 LightApp_Module* anObjModule = dynamic_cast<LightApp_Module*>(obj->module());
5166 if ( anObjModule ) {
5167 LightApp_Displayer* aDisplayer = anObjModule->displayer();
5169 Qtx::VisibilityState anObjState = Qtx::UnpresentableState;
5170 if ( aDisplayer->canBeDisplayed( obj->entry(), theViewModel->getType() ) ) {
5171 if ( aView && aDisplayer->IsDisplayed( obj->entry(), aView ) )
5172 anObjState = Qtx::ShownState;
5174 anObjState = Qtx::HiddenState;
5176 aStudy->setVisibilityState( obj->entry(), anObjState );
5183 * Called when window activated
5185 void LightApp_Application::onWindowActivated( SUIT_ViewWindow* theViewWindow )
5187 SUIT_DataBrowser* anOB = objectBrowser();
5190 SUIT_DataObject* rootObj = anOB->root();
5194 DataObjectList listObj = rootObj->children( true );
5196 SUIT_ViewModel* vmod = 0;
5197 if ( SUIT_ViewManager* vman = theViewWindow->getViewManager() )
5198 vmod = vman->getViewModel();
5199 updateVisibilityState( listObj, vmod );
5203 Called then view manager removed
5205 void LightApp_Application::onViewManagerRemoved( SUIT_ViewManager* )
5207 ViewManagerList lst;
5208 viewManagers( lst );
5209 if ( lst.count() == 1) { // in case if closed last view window
5210 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
5212 aStudy->setVisibilityStateForAll( Qtx::UnpresentableState );
5217 Check existing document.
5219 bool LightApp_Application::checkExistingDoc()
5222 if( activeStudy() ) {
5223 int answer = SUIT_MessageBox::question( desktop(),
5224 tr( "APPCLOSE_CAPTION" ),
5225 tr( "STUDYCLOSE_DESCRIPTION" ),
5226 tr( "APPCLOSE_SAVE" ),
5227 tr( "APPCLOSE_CLOSE" ),
5228 tr( "APPCLOSE_CANCEL" ), 0 );
5230 if ( activeStudy()->isSaved() ) {
5233 } else if ( onSaveAsDoc() ) {
5234 if( !closeDoc( false ) ) {
5241 else if( answer == 1 ) {
5243 } else if( answer == 2 ) {
5250 #ifndef DISABLE_PYCONSOLE
5252 PyConsole_Interp* LightApp_Application::getPyInterp()
5254 static PyConsole_Interp* myInterp = 0;
5256 myInterp = createPyInterp();
5257 myInterp->initialize();
5262 PyConsole_Interp* LightApp_Application::createPyInterp()
5264 return new PyConsole_Interp();
5267 #endif // DISABLE_PYCONSOLE