Back to index

salome-gui  6.5.0
LightApp_Application.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // File:      LightApp_Application.cxx
00024 // Created:   6/20/2005 18:39:45 PM
00025 // Author:    Natalia Donis
00026 
00027 #ifdef WNT
00028 // E.A. : On windows with python 2.6, there is a conflict
00029 // E.A. : between pymath.h and Standard_math.h which define
00030 // E.A. : some same symbols : acosh, asinh, ...
00031   #include <Standard_math.hxx>
00032   #ifndef DISABLE_PYCONSOLE
00033     #include <pymath.h>
00034   #endif
00035 #endif
00036 
00037 #ifndef DISABLE_PYCONSOLE
00038   #include "LightApp_PyInterp.h" // WARNING! This include must be the first!
00039   #include <PyConsole_Console.h>
00040 #endif
00041 
00042 #include "LightApp_Application.h"
00043 #include "LightApp_Module.h"
00044 #include "LightApp_DataModel.h"
00045 #include "LightApp_Study.h"
00046 #include "LightApp_Preferences.h"
00047 #include "LightApp_PreferencesDlg.h"
00048 #include "LightApp_ModuleDlg.h"
00049 #include "LightApp_AboutDlg.h"
00050 #include "LightApp_ModuleAction.h"
00051 // temporary commented
00052 //#include "LightApp_OBFilter.h"
00053 #include "LightApp_EventFilter.h"
00054 #include "LightApp_OBSelector.h"
00055 #include "LightApp_SelectionMgr.h"
00056 #include "LightApp_DataObject.h"
00057 #include "LightApp_WgViewModel.h"
00058 #include "LightApp_FullScreenHelper.h"
00059 
00060 
00061 #include <GUI_version.h>
00062 #include <Basics_OCCTVersion.hxx>
00063 
00064 #include <SALOME_Event.h>
00065 
00066 #include <Style_Salome.h>
00067 #include <Style_PrefDlg.h>
00068 
00069 #include <CAM_Module.h>
00070 #include <CAM_DataModel.h>
00071 #include <CAM_Study.h>
00072 #include <STD_TabDesktop.h>
00073 
00074 #include <SUIT_DataBrowser.h>
00075 #include <SUIT_Session.h>
00076 #include <SUIT_Study.h>
00077 #include <SUIT_FileDlg.h>
00078 #include <SUIT_ResourceMgr.h>
00079 #include <SUIT_ShortcutMgr.h>
00080 #include <SUIT_Tools.h>
00081 #include <SUIT_Accel.h>
00082 #include <SUIT_MessageBox.h>
00083 #include <SUIT_ViewWindow.h>
00084 
00085 #include <Qtx.h>
00086 #include <QtxToolBar.h>
00087 #include <QtxTreeView.h>
00088 #include <QtxMRUAction.h>
00089 #include <QtxDockAction.h>
00090 #include <QtxDockWidget.h>
00091 #include <QtxActionToolMgr.h>
00092 #include <QtxSearchTool.h>
00093 #include <QtxWorkstack.h>
00094 #include <QtxMap.h>
00095 #include <QtxWebBrowser.h>
00096 
00097 #include <LogWindow.h>
00098 
00099 #ifndef DISABLE_GLVIEWER
00100   #include <GLViewer_Viewer.h>
00101   #include <GLViewer_ViewManager.h>
00102   #include "LightApp_GLSelector.h"
00103 #endif
00104 
00105 #ifndef DISABLE_PLOT2DVIEWER
00106   #include <Plot2d_ViewManager.h>
00107   #include <Plot2d_ViewModel.h>
00108   #include <Plot2d_ViewWindow.h>
00109   #include <Plot2d_ViewFrame.h>
00110   #include "LightApp_Plot2dSelector.h"
00111 #ifndef DISABLE_SALOMEOBJECT
00112   #include <SPlot2d_ViewModel.h>
00113 #else
00114   #include <Plot2d_ViewModel.h>
00115 #endif
00116 #endif
00117 
00118 #ifndef DISABLE_OCCVIEWER
00119   #include <OCCViewer_ViewManager.h>
00120   #include <OCCViewer_ViewFrame.h>
00121 #ifndef DISABLE_SALOMEOBJECT
00122   #include <SOCC_ViewModel.h>
00123 #else
00124   #include <OCCViewer_ViewModel.h>
00125 #endif
00126   #include "LightApp_OCCSelector.h"
00127 #endif
00128 
00129 #ifndef DISABLE_VTKVIEWER
00130 #ifndef DISABLE_SALOMEOBJECT
00131   #include <SVTK_ViewModel.h>
00132   #include <SVTK_ViewManager.h>
00133   #include "LightApp_VTKSelector.h"
00134 #else
00135   #include <VTKViewer_ViewModel.h>
00136   #include <VTKViewer_ViewManager.h>
00137 #endif
00138   #include <VTKViewer_ViewModel.h>
00139 #endif
00140 
00141 //#ifndef DISABLE_SUPERVGRAPHVIEWER
00142 //  #include <SUPERVGraph_ViewModel.h>
00143 //  #include <SUPERVGraph_ViewFrame.h>
00144 //  #include <SUPERVGraph_ViewManager.h>
00145 //#endif
00146 
00147 #ifndef DISABLE_QXGRAPHVIEWER
00148 //VSR: QxGraph has been replaced by QxScene
00149 //  #include <QxGraph_ViewModel.h>
00150 //  #include <QxGraph_ViewWindow.h>
00151 //  #include <QxGraph_ViewManager.h>
00152   #include <QxScene_ViewManager.h>
00153   #include <QxScene_ViewModel.h>
00154   #include <QxScene_ViewWindow.h>
00155 #endif
00156 
00157 
00158 #define VISIBILITY_COLUMN_WIDTH 25
00159 
00160 #include <QDir>
00161 #include <QImage>
00162 #include <QString>
00163 #include <QWidget>
00164 #include <QStringList>
00165 #include <QFile>
00166 #include <QApplication>
00167 #include <QMap>
00168 #include <QStatusBar>
00169 #include <QThread>
00170 #include <QObjectList>
00171 #include <QComboBox>
00172 #include <QInputDialog>
00173 #include <QFontDatabase>
00174 #include <QIcon>
00175 #include <QByteArray>
00176 #include <QMenu>
00177 #include <QProcess>
00178 #include <QTimer>
00179 #include <QHeaderView>
00180 #include <QTreeView>
00181 #include <QMimeData>
00182 #include <QShortcut>
00183 
00184 #include <utilities.h>
00185 
00186 #define FIRST_HELP_ID 1000000
00187 
00188 #ifndef DISABLE_SALOMEOBJECT
00189   #include <SALOME_InteractiveObject.hxx>
00190   #include <SALOME_ListIO.hxx>
00191 #endif
00192 
00193 #include <Standard_Version.hxx>
00194 
00195 #define ToolBarMarker    0
00196 #define DockWidgetMarker 1
00197 
00198 static const char* imageEmptyIcon[] = {
00199 "20 20 1 1",
00200 ".      c None",
00201 "....................",
00202 "....................",
00203 "....................",
00204 "....................",
00205 "....................",
00206 "....................",
00207 "....................",
00208 "....................",
00209 "....................",
00210 "....................",
00211 "....................",
00212 "....................",
00213 "....................",
00214 "....................",
00215 "....................",
00216 "....................",
00217 "....................",
00218 "....................",
00219 "....................",
00220 "...................."};
00221 
00222 int LightApp_Application::lastStudyId = 0;
00223 
00227 int LightApp_Application::studyId()
00228 {
00229   return LightApp_Application::lastStudyId;
00230 }
00231 
00233 extern "C" LIGHTAPP_EXPORT SUIT_Application* createApplication()
00234 {
00235   return new LightApp_Application();
00236 }
00237 
00239 LightApp_Preferences* LightApp_Application::_prefs_ = 0;
00240 
00241 
00248 LightApp_Application::LightApp_Application()
00249 : CAM_Application( false ),
00250   myPrefs( 0 ),
00251   myScreenHelper(new LightApp_FullScreenHelper())
00252 {
00253   Q_INIT_RESOURCE( LightApp );
00254 
00255   STD_TabDesktop* desk = new STD_TabDesktop();
00256   desk->setFullScreenAllowed(false);
00257 
00258   setDesktop( desk );
00259 
00260   // initialize auto save timer
00261   myAutoSaveTimer = new QTimer( this );
00262   myAutoSaveTimer->setSingleShot( true );
00263   connect( myAutoSaveTimer, SIGNAL( timeout() ), this, SLOT( onSaveDoc() ) );
00264 
00265   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
00266   QPixmap aLogo = aResMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
00267 
00268   QtxWebBrowser::setData("browser:icon",          aResMgr->loadPixmap( "LightApp", tr( "BROWSER_ICON" ) ) );
00269   QtxWebBrowser::setData("browser:title",         tr( "BROWSER_TITLE" ) );
00270   QtxWebBrowser::setData("toolbar:title",         tr( "BROWSER_TOOLBAR_TITLE" ) );
00271   QtxWebBrowser::setData("menu:file:title",       tr( "BROWSER_FILEMENU" ) );
00272   QtxWebBrowser::setData("action:close:title",    tr( "BROWSER_CLOSE" ) );
00273   QtxWebBrowser::setData("action:close:icon",     aResMgr->loadPixmap( "LightApp", tr( "BROWSER_CLOSE_ICON" ) ) );
00274   QtxWebBrowser::setData("action:back:title",     tr( "BROWSER_BACK" ) );
00275   QtxWebBrowser::setData("action:forward:title",  tr( "BROWSER_FORWARD" ) );
00276   QtxWebBrowser::setData("action:find:title",     tr( "BROWSER_FIND" ) );
00277   QtxWebBrowser::setData("action:findnext:title", tr( "BROWSER_FINDNEXT" ) );
00278   QtxWebBrowser::setData("action:findprev:title", tr( "BROWSER_FINDPREV" ) );
00279 
00280   desktop()->setWindowIcon( aLogo );
00281   desktop()->setDockableMenuBar( false );
00282   desktop()->setDockableStatusBar( false );
00283 
00284   // base logo (salome itself)
00285   desktop()->logoInsert( "_app_base",  aResMgr->loadPixmap( "LightApp", tr( "APP_BASE_LOGO" ), false ) );
00286   // extra logo (salome-based application)
00287   desktop()->logoInsert( "_app_extra", aResMgr->loadPixmap( "LightApp", tr( "APP_EXTRA_LOGO" ), false ) );
00288 
00289   clearViewManagers();
00290 
00291   mySelMgr = new LightApp_SelectionMgr( this );
00292 
00293   myAccel = SUIT_Accel::getAccel();
00294 
00295 #ifndef DISABLE_OCCVIEWER
00296   myAccel->setActionKey( SUIT_Accel::PanLeft,     Qt::CTRL+Qt::Key_Left,     OCCViewer_Viewer::Type() );
00297   myAccel->setActionKey( SUIT_Accel::PanRight,    Qt::CTRL+Qt::Key_Right,    OCCViewer_Viewer::Type() );
00298   myAccel->setActionKey( SUIT_Accel::PanUp,       Qt::CTRL+Qt::Key_Up,       OCCViewer_Viewer::Type() );
00299   myAccel->setActionKey( SUIT_Accel::PanDown,     Qt::CTRL+Qt::Key_Down,     OCCViewer_Viewer::Type() );
00300   myAccel->setActionKey( SUIT_Accel::ZoomIn,      Qt::CTRL+Qt::Key_Plus,     OCCViewer_Viewer::Type() );
00301   myAccel->setActionKey( SUIT_Accel::ZoomOut,     Qt::CTRL+Qt::Key_Minus,    OCCViewer_Viewer::Type() );
00302   myAccel->setActionKey( SUIT_Accel::ZoomFit,     Qt::CTRL+Qt::Key_Asterisk, OCCViewer_Viewer::Type() );
00303   myAccel->setActionKey( SUIT_Accel::RotateLeft,  Qt::ALT+Qt::Key_Left,      OCCViewer_Viewer::Type() );
00304   myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right,     OCCViewer_Viewer::Type() );
00305   myAccel->setActionKey( SUIT_Accel::RotateUp,    Qt::ALT+Qt::Key_Up,        OCCViewer_Viewer::Type() );
00306   myAccel->setActionKey( SUIT_Accel::RotateDown,  Qt::ALT+Qt::Key_Down,      OCCViewer_Viewer::Type() );
00307 #endif
00308 #ifndef DISABLE_VTKVIEWER
00309   myAccel->setActionKey( SUIT_Accel::PanLeft,     Qt::CTRL+Qt::Key_Left,     VTKViewer_Viewer::Type() );
00310   myAccel->setActionKey( SUIT_Accel::PanRight,    Qt::CTRL+Qt::Key_Right,    VTKViewer_Viewer::Type() );
00311   myAccel->setActionKey( SUIT_Accel::PanUp,       Qt::CTRL+Qt::Key_Up,       VTKViewer_Viewer::Type() );
00312   myAccel->setActionKey( SUIT_Accel::PanDown,     Qt::CTRL+Qt::Key_Down,     VTKViewer_Viewer::Type() );
00313   myAccel->setActionKey( SUIT_Accel::ZoomIn,      Qt::CTRL+Qt::Key_Plus,     VTKViewer_Viewer::Type() );
00314   myAccel->setActionKey( SUIT_Accel::ZoomOut,     Qt::CTRL+Qt::Key_Minus,    VTKViewer_Viewer::Type() );
00315   myAccel->setActionKey( SUIT_Accel::ZoomFit,     Qt::CTRL+Qt::Key_Asterisk, VTKViewer_Viewer::Type() );
00316   myAccel->setActionKey( SUIT_Accel::RotateLeft,  Qt::ALT+Qt::Key_Left,      VTKViewer_Viewer::Type() );
00317   myAccel->setActionKey( SUIT_Accel::RotateRight, Qt::ALT+Qt::Key_Right,     VTKViewer_Viewer::Type() );
00318   myAccel->setActionKey( SUIT_Accel::RotateUp,    Qt::ALT+Qt::Key_Up,        VTKViewer_Viewer::Type() );
00319   myAccel->setActionKey( SUIT_Accel::RotateDown,  Qt::ALT+Qt::Key_Down,      VTKViewer_Viewer::Type() );
00320 #endif
00321 #ifndef DISABLE_PLOT2DVIEWER
00322   myAccel->setActionKey( SUIT_Accel::PanLeft,     Qt::CTRL+Qt::Key_Left,     Plot2d_Viewer::Type() );
00323   myAccel->setActionKey( SUIT_Accel::PanRight,    Qt::CTRL+Qt::Key_Right,    Plot2d_Viewer::Type() );
00324   myAccel->setActionKey( SUIT_Accel::PanUp,       Qt::CTRL+Qt::Key_Up,       Plot2d_Viewer::Type() );
00325   myAccel->setActionKey( SUIT_Accel::PanDown,     Qt::CTRL+Qt::Key_Down,     Plot2d_Viewer::Type() );
00326   myAccel->setActionKey( SUIT_Accel::ZoomIn,      Qt::CTRL+Qt::Key_Plus,     Plot2d_Viewer::Type() );
00327   myAccel->setActionKey( SUIT_Accel::ZoomOut,     Qt::CTRL+Qt::Key_Minus,    Plot2d_Viewer::Type() );
00328   myAccel->setActionKey( SUIT_Accel::ZoomFit,     Qt::CTRL+Qt::Key_Asterisk, Plot2d_Viewer::Type() );
00329 #endif
00330 
00331   connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) );
00332 
00333   // Set existing font for the python console in resources
00334   if( !aResMgr->hasValue( "PyConsole", "font" ) )
00335     return;
00336 
00337   QFont f = aResMgr->fontValue( "PyConsole", "font" );
00338   QFontDatabase fdb;
00339   QStringList famdb = fdb.families();
00340 
00341   if ( famdb.contains(f.family()) || !aResMgr->hasValue( "PyConsole", "additional_families" ) )
00342     return;
00343 
00344   QStringList anAddFamilies = aResMgr->stringValue( "PyConsole", "additional_families" ).split( ";", QString::SkipEmptyParts );
00345   QString aFamily;
00346   for ( QStringList::Iterator it = anAddFamilies.begin(); it != anAddFamilies.end(); ++it )
00347   {
00348     aFamily = *it;
00349     if ( famdb.contains(aFamily) )
00350     {
00351       f.setFamily( aFamily );
00352       aResMgr->setValue( "PyConsole", "font", f );
00353       break;
00354     }
00355   }
00356 }
00357 
00364 LightApp_Application::~LightApp_Application()
00365 {
00366   delete mySelMgr;
00367   delete myScreenHelper;
00368 }
00369 
00371 void LightApp_Application::start()
00372 {
00373   CAM_Application::start();
00374 
00375   updateWindows();
00376   updateViewManagers();
00377 
00378   putInfo( "" );
00379   desktop()->statusBar()->showMessage( "" );
00380 
00381   LightApp_EventFilter::Init();
00382 }
00383 
00385 QString LightApp_Application::applicationName() const
00386 {
00387   static QString _app_name;
00388   if ( _app_name.isEmpty() )
00389     _app_name = tr( "APP_NAME" );
00390   return _app_name;
00391 }
00392 
00394 QString LightApp_Application::applicationVersion() const
00395 {
00396   static QString _app_version;
00397 
00398   if ( _app_version.isEmpty() )
00399   {
00400     QString resVersion = tr( "APP_VERSION" );
00401     if ( resVersion != "APP_VERSION" )
00402     {
00403       _app_version = resVersion;
00404     }
00405     else
00406     {
00407       _app_version = GUI_VERSION_STR;
00408     }
00409   }
00410   return _app_version;
00411 }
00412 
00414 CAM_Module* LightApp_Application::loadModule( const QString& name, const bool showMsg )
00415 {
00416   CAM_Module* mod = CAM_Application::loadModule( name, showMsg );
00417   if ( mod )
00418   {
00419     connect( this, SIGNAL( studyOpened() ), mod, SLOT( onModelOpened() ) );
00420     connect( this, SIGNAL( studySaved() ),  mod, SLOT( onModelSaved() ) );
00421     connect( this, SIGNAL( studyClosed() ), mod, SLOT( onModelClosed() ) );
00422   }
00423   return mod;
00424 }
00425 
00427 bool LightApp_Application::activateModule( const QString& modName )
00428 {
00429   QString actName;
00430   CAM_Module* prevMod = activeModule();
00431 
00432   if ( prevMod )
00433     actName = prevMod->moduleName();
00434 
00435   if ( actName == modName )
00436     return true;
00437 
00438   putInfo( tr( "ACTIVATING_MODULE" ).arg( modName ) );
00439 
00440   saveDockWindowsState();
00441 
00442   bool status = CAM_Application::activateModule( modName );
00443 
00444   updateModuleActions();
00445 
00446   putInfo( "" );
00447 
00448   if ( !status )
00449     return false;
00450 
00451   updateWindows();
00452   updateViewManagers();
00453 
00454   return true;
00455 }
00456 
00458 LightApp_SelectionMgr* LightApp_Application::selectionMgr() const
00459 {
00460   return mySelMgr;
00461 }
00462 
00464 void LightApp_Application::createActionForViewer( const int id,
00465                                                   const int parentId,
00466                                                   const QString& suffix,
00467                                                   const int accel )
00468 {
00469   QString vtlt = tr( QString( "NEW_WINDOW_%1" ).arg( suffix ).toLatin1().constData() );
00470   QString tip = tr( "CREATING_NEW_WINDOW" ).arg( vtlt.remove( "&" ) );
00471   QAction* a = createAction( id,                      // menu action id
00472                           tip,                     // status tip
00473                           QIcon(),                 // icon
00474                           vtlt,                    // menu text
00475                              tip,                     // tooltip
00476                              accel,                   // shortcut
00477                           desktop(),               // parent
00478                              false,                   // toggle flag
00479                           this,                    // receiver
00480                              SLOT( onNewWindow() ) ); // slot
00481   createMenu( a, parentId, -1 );
00482 }
00483 
00486 void LightApp_Application::createActions()
00487 {
00488   STD_Application::createActions();
00489 
00490   SUIT_Desktop* desk = desktop();
00491   SUIT_ResourceMgr* resMgr = resourceMgr();
00492 
00494   createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIcon(),
00495                 tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
00496                 Qt::CTRL+Qt::Key_R, desk, false, this, SLOT( onPreferences() ) );
00497 
00499   int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
00500   createMenu( separator(), helpMenu, -1, 1 );
00501   QStringList aModuleList;
00502   modules( aModuleList, false );
00503   aModuleList.prepend( "GUI" );
00504   aModuleList.prepend( "KERNEL" );
00505 
00506   int id = LightApp_Application::UserID + FIRST_HELP_ID;
00507 
00508   // help for other existing modules
00509 
00510   QString aModule;
00511   foreach( aModule, aModuleList ) {
00512     if ( aModule.isEmpty() )                                         // module title (user name)
00513       continue;
00514     IMap <QString, QString> helpData;                                // list of help files for the module
00515     QString helpSubMenu;                                             // help submenu name (empty if not needed)
00516     QString modName = moduleName( aModule );                         // module name
00517     if ( modName.isEmpty() ) modName = aModule;                      // for KERNEL and GUI
00518     QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName );       // module root dir variable
00519     QString modDir  = getenv( rootDir.toLatin1().constData() );      // module root dir
00520     QString docSection;
00521     if (resMgr->hasValue( modName, "documentation" ) )
00522       docSection = resMgr->stringValue(modName, "documentation");
00523     else if ( resMgr->hasSection( modName + "_documentation" ) )
00524       docSection = modName + "_documentation";
00525     if ( !docSection.isEmpty() ) {
00526       helpSubMenu = resMgr->stringValue( docSection, "sub_menu", "" ).arg( aModule );
00527       QStringList listOfParam = resMgr->parameters( docSection );
00528       foreach( QString paramName, listOfParam ) {
00529         QString valueStr = resMgr->stringValue( docSection, paramName );
00530         if ( !valueStr.isEmpty() ) {
00531           QFileInfo fi( valueStr );
00532           if ( fi.isRelative() && !modDir.isEmpty() )
00533             valueStr = Qtx::addSlash( modDir ) + valueStr;
00534           if ( QFile::exists( valueStr ) )
00535             helpData.insert( paramName.arg( aModule ), valueStr );
00536         }
00537       }
00538     }
00539 
00540     if ( helpData.isEmpty() && !modDir.isEmpty() ) {
00541       QStringList idxLst = QStringList() << modDir << "share" << "doc" << "salome" << "gui" << modName << "index.html";
00542       QString indexFile = idxLst.join( QDir::separator() );          // index file
00543       if ( QFile::exists( indexFile ) )
00544         helpData.insert( tr( "%1 module Users's Guide" ).arg( aModule ), indexFile );
00545     }
00546 
00547     IMapConstIterator<QString, QString > fileIt;
00548     for ( fileIt = helpData.begin(); fileIt != helpData.end(); fileIt++ ) {
00549       QString helpFileName = fileIt.key();
00550       // remove all '//' occurances 
00551       while ( helpFileName.contains( "//" ) )
00552        helpFileName.replace( "//", "" );
00553       // obtain submenus hierarchy if given
00554       QStringList smenus = helpFileName.split( "/" );
00555       helpFileName = smenus.last();
00556       smenus.removeLast();
00557       QAction* a = createAction( id, helpFileName,
00558                                  resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
00559                                  helpFileName, helpFileName,
00560                                  0, desk, false, this, SLOT( onHelpContentsModule() ) );
00561       a->setData( fileIt.value() );
00562       if ( !helpSubMenu.isEmpty() ) {
00563        smenus.prepend( helpSubMenu );
00564       }
00565       // create sub-menus hierarchy
00566       int menuId = helpMenu;
00567       foreach ( QString subMenu, smenus ) {
00568         menuId = createMenu( subMenu, menuId, -1, 0 );
00569       }
00570       createMenu( a, menuId, -1, 0 );
00571       id++;
00572     }
00573   }
00574 
00576   static QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), 0 );
00577   connect( mru, SIGNAL( activated( const QString& ) ), this, SLOT( onMRUActivated( const QString& ) ) );
00578   registerAction( MRUId, mru );
00579 
00580   // default icon for neutral point ('SALOME' module)
00581   QPixmap defIcon = resMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
00582   if ( defIcon.isNull() )
00583     defIcon = QPixmap( imageEmptyIcon );
00584 
00586   QPixmap modIcon = resMgr->loadPixmap( "LightApp", tr( "APP_MODULE_ICO" ), false );
00587   if ( modIcon.isNull() )
00588     modIcon = QPixmap( imageEmptyIcon );
00589 
00590   QStringList modList;
00591   modules( modList, false );
00592 
00593   if ( modList.count() > 1 )
00594   {
00595     LightApp_ModuleAction* moduleAction =
00596       new LightApp_ModuleAction( tr( "APP_NAME" ), defIcon, desk );
00597 
00598     QMap<QString, QString> iconMap;
00599     moduleIconNames( iconMap );
00600 
00601     const int iconSize = 20;
00602 
00603     QStringList::Iterator it;
00604     for ( it = modList.begin(); it != modList.end(); ++it )
00605     {
00606       if ( !isLibExists( *it ) )
00607         continue;
00608 
00609       QString modName = moduleName( *it );
00610 
00611       if ( !isModuleAccessible( *it ) )
00612         continue;
00613 
00614       QString iconName;
00615       if ( iconMap.contains( *it ) )
00616         iconName = iconMap[*it];
00617 
00618       QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
00619       if ( icon.isNull() )
00620       {
00621         icon = modIcon;
00622         INFOS ( "****************************************************************" << std::endl
00623                 <<  "*    Icon for " << (*it).toLatin1().constData()
00624                 << " not found. Using the default one." << std::endl
00625                 << "****************************************************************" << std::endl );
00626       }
00627 
00628       icon = Qtx::scaleIcon( icon, iconSize );
00629 
00630       moduleAction->insertModule( *it, icon );
00631     }
00632 
00633     connect( moduleAction, SIGNAL( moduleActivated( const QString& ) ),
00634              this, SLOT( onModuleActivation( const QString& ) ) );
00635     registerAction( ModulesListId, moduleAction );
00636   }
00637 
00638   // New window
00639   int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, MenuWindowId, 100 );
00640   int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
00641 
00642   createAction( CloseId, tr( "TOT_CLOSE" ), QIcon(), tr( "MEN_DESK_CLOSE" ), tr( "PRP_CLOSE" ),
00643                 Qt::CTRL+Qt::Key_F4, desk, false, this, SLOT( onCloseWindow() ) );
00644   createAction( CloseAllId, tr( "TOT_CLOSE_ALL" ), QIcon(), tr( "MEN_DESK_CLOSE_ALL" ), tr( "PRP_CLOSE_ALL" ),
00645                 0, desk, false, this, SLOT( onCloseAllWindow() ) );
00646   createAction( GroupAllId, tr( "TOT_GROUP_ALL" ), QIcon(), tr( "MEN_DESK_GROUP_ALL" ), tr( "PRP_GROUP_ALL" ),
00647                 0, desk, false, this, SLOT( onGroupAllWindow() ) );
00648 
00649   createMenu( CloseId,     windowMenu, 0, -1 );
00650   createMenu( CloseAllId,  windowMenu, 0, -1 );
00651   createMenu( GroupAllId,  windowMenu, 0, -1 );
00652   createMenu( separator(), windowMenu, -1, 0 );
00653 
00654 #ifndef DISABLE_GLVIEWER
00655   createActionForViewer( NewGLViewId, newWinMenu, QString::number( 0 ), Qt::ALT+Qt::Key_G );
00656 #endif
00657 #ifndef DISABLE_PLOT2DVIEWER
00658   createActionForViewer( NewPlot2dId, newWinMenu, QString::number( 1 ), Qt::ALT+Qt::Key_P );
00659 #endif
00660 #ifndef DISABLE_OCCVIEWER
00661   createActionForViewer( NewOCCViewId, newWinMenu, QString::number( 2 ), Qt::ALT+Qt::Key_O );
00662 #endif
00663 #ifndef DISABLE_VTKVIEWER
00664   createActionForViewer( NewVTKViewId, newWinMenu, QString::number( 3 ), Qt::ALT+Qt::Key_K );
00665 #endif
00666 #ifndef DISABLE_QXGRAPHVIEWER
00667 //VSR: QxGraph has been replaced by QxScene
00668 //  createActionForViewer( NewQxGraphViewId, newWinMenu, QString::number( 4 ), Qt::ALT+Qt::Key_C );
00669   createActionForViewer( NewQxSceneViewId, newWinMenu, QString::number( 4 ), Qt::ALT+Qt::Key_S );
00670 #endif
00671 
00672   createAction( RenameId, tr( "TOT_RENAME" ), QIcon(), tr( "MEN_DESK_RENAME" ), tr( "PRP_RENAME" ),
00673                 Qt::ALT+Qt::SHIFT+Qt::Key_R, desk, false, this, SLOT( onRenameWindow() ) );
00674   createMenu( RenameId, windowMenu, -1 );
00675 
00676   int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
00677   createMenu( PreferencesId, fileMenu, 50, -1 );
00678   createMenu( separator(), fileMenu, -1, 50, -1 );
00679 
00680   createMenu( separator(), fileMenu, -1, 100, -1 );
00681   createMenu( MRUId, fileMenu, 100, -1 );
00682   createMenu( separator(), fileMenu, -1, 100, -1 );
00683 
00684   createAction( StyleId, tr( "TOT_THEME" ), QIcon(), tr( "MEN_DESK_THEME" ), tr( "PRP_THEME" ),
00685                 0, desk, false, this, SLOT( onStylePreferences() ) );
00686 
00687   createAction( FullScreenId, tr( "TOT_FULLSCREEN" ), QIcon(), tr( "MEN_DESK_FULLSCREEN" ), tr( "PRP_FULLSCREEN" ),
00688                 Qt::Key_F11, desk, false, this, SLOT( onFullScreen() ) );
00689 
00690 
00691   int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1 );
00692   createMenu( separator(), viewMenu, -1, 20, -1 );
00693   createMenu( StyleId, viewMenu, 20, -1 );
00694   createMenu( FullScreenId, viewMenu, 20, -1 );
00695 
00696   int modTBar = createTool( tr( "INF_TOOLBAR_MODULES" ) );
00697   createTool( ModulesListId, modTBar );
00698 }
00699 
00701 void LightApp_Application::onModuleActivation( const QString& modName )
00702 {
00703   // Force user to create/open a study before module activation
00704   QMap<QString, QString> iconMap;
00705   moduleIconNames( iconMap );
00706   QPixmap icon = resourceMgr()->loadPixmap( moduleName( modName ), iconMap[ modName ], false );
00707   if ( icon.isNull() )
00708     icon = resourceMgr()->loadPixmap( "LightApp", tr( "APP_MODULE_BIG_ICO" ), false ); // default icon for any module
00709 
00710   bool cancelled = false;
00711 
00712   while ( !modName.isEmpty() && !activeStudy() && !cancelled ){
00713     LightApp_ModuleDlg aDlg( desktop(), modName, icon );
00714     QMap<int, QString> opmap = activateModuleActions();
00715     for ( QMap<int, QString>::ConstIterator it = opmap.begin(); it != opmap.end(); ++it )
00716       aDlg.addButton( it.value(), it.key() );
00717 
00718     int res = aDlg.exec();
00719     if ( res ) {
00720       // some operation is selected
00721       moduleActionSelected( res );
00722     }
00723     else {
00724       // cancelled
00725       putInfo( tr("INF_CANCELLED") );
00726 
00727       LightApp_ModuleAction* moduleAction =
00728         qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
00729       if ( moduleAction )
00730         moduleAction->setActiveModule( QString() );
00731       cancelled = true;
00732     }
00733   }
00734 
00735   if ( !cancelled )
00736     activateModule( modName );
00737 }
00738 
00740 QString LightApp_Application::defaultModule() const
00741 {
00742   QStringList aModuleNames;
00743   modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration
00746   return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" );
00747 }
00748 
00750 void LightApp_Application::onNewWindow()
00751 {
00752   const QObject* obj = sender();
00753   if ( !obj || !obj->inherits( "QAction" ) )
00754     return;
00755 
00756   QString type;
00757   int id = actionId( (QAction*)obj );
00758   switch ( id )
00759   {
00760 #ifndef DISABLE_GLVIEWER
00761   case NewGLViewId:
00762     type = GLViewer_Viewer::Type();
00763     break;
00764 #endif
00765 #ifndef DISABLE_PLOT2DVIEWER
00766   case NewPlot2dId:
00767     type = Plot2d_Viewer::Type();
00768     break;
00769 #endif
00770 #ifndef DISABLE_OCCVIEWER
00771   case NewOCCViewId:
00772     type = OCCViewer_Viewer::Type();
00773     break;
00774 #endif
00775 #ifndef DISABLE_VTKVIEWER
00776   case NewVTKViewId:
00777     type = VTKViewer_Viewer::Type();
00778     break;
00779 #endif
00780 #ifndef DISABLE_QXGRAPHVIEWER
00781 //VSR: QxGraph has been replaced by QxScene
00782 //  case NewQxGraphViewId:
00783 //    type = QxGraph_Viewer::Type();
00784 //    break;
00785   case NewQxSceneViewId:
00786     type = QxScene_Viewer::Type();
00787     break;
00788 #endif
00789   }
00790 
00791   if ( !type.isEmpty() )
00792     createViewManager( type );
00793 }
00794 
00798 void LightApp_Application::onNewDoc()
00799 {
00800   //asl: fix for 0020515
00801   if ( activeStudy() )
00802     saveDockWindowsState();
00803 
00804   CAM_Application::onNewDoc();
00805 }
00806 
00810 void LightApp_Application::onOpenDoc()
00811 {
00812   SUIT_Study* study = activeStudy();
00813   saveDockWindowsState();
00814 
00815   CAM_Application::onOpenDoc();
00816 
00817   if ( !study ) // new study will be create in THIS application
00818   {
00819     updateWindows();
00820     updateViewManagers();
00821   }
00822 }
00823 
00828 bool LightApp_Application::onOpenDoc( const QString& aName )
00829 {
00830   // We should take mru action first because this application instance can be deleted later.
00831   QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
00832 
00833   bool res = CAM_Application::onOpenDoc( aName );
00834 
00835   if ( mru )
00836   {
00837     if ( res )
00838       mru->insert( aName );
00839     else
00840       mru->remove( aName );
00841   }
00842   return res;
00843 }
00844 
00848 void LightApp_Application::onHelpAbout()
00849 {
00850   LightApp_AboutDlg dlg( applicationName(), applicationVersion(), desktop() );
00851   dlg.exec();
00852 }
00853 
00858 void LightApp_Application::onSelection()
00859 {
00860   onSelectionChanged();
00861 
00862   if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
00863     ((LightApp_Module*)activeModule())->selectionChanged();
00864 }
00865 
00870 void LightApp_Application::setActiveStudy( SUIT_Study* study )
00871 {
00872   CAM_Application::setActiveStudy( study );
00873 }
00874 
00878 void LightApp_Application::updateCommandsStatus()
00879 {
00880   CAM_Application::updateCommandsStatus();
00881   QAction* a = 0;
00882 
00883 #ifndef DISABLE_GLVIEWER
00884   a = action( NewGLViewId );
00885   if( a )
00886     a->setEnabled( activeStudy() );
00887 #endif
00888 
00889 #ifndef DISABLE_PLOT2DVIEWER
00890   a = action( NewPlot2dId );
00891   if( a )
00892     a->setEnabled( activeStudy() );
00893 #endif
00894 
00895 #ifndef DISABLE_OCCVIEWER
00896   a = action( NewOCCViewId );
00897   if( a )
00898     a->setEnabled( activeStudy() );
00899 #endif
00900 
00901 #ifndef DISABLE_VTKVIEWER
00902   a = action( NewVTKViewId );
00903   if( a )
00904     a->setEnabled( activeStudy() );
00905 #endif
00906 
00907 #ifndef DISABLE_QXGRAPHVIEWER
00908 //VSR: QxGraph has been replaced by QxScene
00909 //  a = action( NewQxGraphViewId );
00910   a = action( NewQxSceneViewId );
00911   if( a )
00912     a->setEnabled( activeStudy() );
00913 #endif
00914 }
00915 
00920 class RunBrowser: public QThread
00921 {
00922 public:
00923   RunBrowser( LightApp_Application* app,
00924               const QString&        theApp,
00925               const QString&        theParams,
00926               const QString&        theHelpFile,
00927               const QString&        theContext = QString() )
00928     : myApp( theApp ),
00929       myParams( theParams ),
00930       myContext( theContext ),
00931       myStatus(0),
00932       myLApp( app )
00933   {
00934     //For the external browser always specify 'file://' protocol,
00935     //because some WEB browsers (for example Mozilla Firefox) can't open local file without protocol.
00936     myHelpFile = QString("file://%1").arg( QFileInfo( theHelpFile ).canonicalFilePath() );
00937   }
00938 
00939   virtual void run()
00940   {
00941     if ( !myApp.isEmpty() && !myHelpFile.isEmpty()) {
00942       QString aCommand = QString( "%1 %2 \"%3%4\"" ).arg( myApp, myParams, myHelpFile, myContext.isEmpty() ? QString("") : QString( "#%1" ).arg( myContext ) );
00943 
00944       QProcess* proc = new QProcess();
00945 
00946       proc->start( aCommand );
00947       if ( !proc->waitForStarted() ) {
00948         SALOME_CustomEvent* ce2000 = new SALOME_CustomEvent( 2000 );
00949         QString* msg = new QString( QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).arg( myApp, myHelpFile ) );
00950         ce2000->setData( msg );
00951         QApplication::postEvent( myLApp, ce2000 );
00952       }
00953     }
00954   }
00955 
00956 private:
00957   QString               myApp;
00958   QString               myParams;
00959   QString               myHelpFile;
00960   QString               myContext;
00961   int                   myStatus;
00962   LightApp_Application* myLApp;
00963 };
00964 
00968 void LightApp_Application::onHelpContentsModule()
00969 {
00970   const QAction* a = (QAction*) sender();
00971   QString helpFile = a->data().toString();
00972   if ( helpFile.isEmpty() ) return;
00973 
00974   SUIT_ResourceMgr* resMgr = resourceMgr();
00975   QString platform;
00976 #ifdef WIN32
00977   platform = "winapplication";
00978 #else
00979   platform = "application";
00980 #endif
00981   QString anApp = resMgr->stringValue("ExternalBrowser", platform);
00982 #ifdef WIN32
00983   QString quote("\"");
00984   anApp.prepend( quote );
00985   anApp.append( quote );
00986 #endif
00987   QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
00988   bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
00989 
00990   if( useExtBrowser ) {
00991     if ( !anApp.isEmpty() ) {
00992       RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile );
00993       rs->start();
00994     }
00995     else {
00996       if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
00997                                       SUIT_MessageBox::Yes | SUIT_MessageBox::No,
00998                                       SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
00999 
01000         showPreferences( tr( "PREF_APP" ) );
01001     }
01002   }
01003   else {
01004 #ifdef WIN32
01005     // On Win32 platform QWebKit of the Qt 4.6.3 hang up in case 'file://' protocol 
01006     // is defined. On Linux platform QWebKit doesn't work correctly without 'file://' protocol.
01007     QtxWebBrowser::loadUrl(helpFile);
01008 #else
01009        QtxWebBrowser::loadUrl(QString("file://%1").arg(helpFile));
01010 #endif
01011   }
01012 }
01013 
01017 void LightApp_Application::onHelpContextModule( const QString& theComponentName,
01018                                                 const QString& theFileName,
01019                                                 const QString& theContext )
01020 {
01021   QString fileName = theFileName;
01022   QString context  = theContext;
01023   if ( !QFile::exists( fileName ) && theContext.isEmpty() ) {
01024     // context might be passed within theFileName argument
01025     QStringList comps = fileName.split("#");
01026     if ( comps.count() > 1 ) {
01027       context = comps.last();
01028       comps.removeLast();
01029       fileName = comps.join("#");
01030     }
01031   }
01032 
01033   QString homeDir = "";
01034   if ( !theComponentName.isEmpty() ) {
01035     QString dir = getenv( ( theComponentName + "_ROOT_DIR" ).toLatin1().constData() );
01036     if ( !dir.isEmpty() )
01037       homeDir = Qtx::addSlash( Qtx::addSlash( dir )      +
01038                                Qtx::addSlash( "share" )  +
01039                                Qtx::addSlash( "doc" )    +
01040                                Qtx::addSlash( "salome" ) +
01041                                Qtx::addSlash( "gui" )    +
01042                                Qtx::addSlash( theComponentName ) );
01043   }
01044 
01045   QString helpFile = QFileInfo( homeDir + fileName ).absoluteFilePath();
01046   SUIT_ResourceMgr* resMgr = resourceMgr();
01047         QString platform;
01048 #ifdef WIN32
01049         platform = "winapplication";
01050 #else
01051         platform = "application";
01052 #endif
01053         QString anApp = resMgr->stringValue("ExternalBrowser", platform);
01054 #ifdef WIN32
01055         QString quote("\"");
01056         anApp.prepend( quote );
01057         anApp.append( quote );
01058 #endif
01059 
01060   bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
01061 
01062   if(useExtBrowser) {
01063     QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
01064 
01065     if ( !anApp.isEmpty() ) {
01066       RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile, context );
01067       rs->start();
01068     }
01069     else {
01070       if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
01071                                       SUIT_MessageBox::Yes | SUIT_MessageBox::No,
01072                                       SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
01073         showPreferences( tr( "PREF_APP" ) );
01074     }
01075   }
01076   else {
01077 #ifdef WIN32
01078     // On Win32 platform QWebKit of the Qt 4.6.3 hang up in case 'file://' protocol 
01079     // is defined. On Linux platform QWebKit doesn't work correctly without 'file://' protocol.
01080        QtxWebBrowser::loadUrl(helpFile, context);
01081 #else
01082        QtxWebBrowser::loadUrl(QString("file://%1").arg(helpFile),context);
01083 #endif
01084     
01085   }
01086 }
01087 
01091 void LightApp_Application::onSelectionChanged()
01092 {
01093   LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
01094   bool canCopy  = m ? m->canCopy() : false;
01095   bool canPaste = m ? m->canPaste() : false;
01096 
01097   action( EditCopyId )->setEnabled(canCopy);
01098   action( EditPasteId )->setEnabled(canPaste);
01099 }
01100 
01108 /*
01109 void LightApp_Application::addWindow( QWidget* wid, const int flag, const int studyId )
01110 {
01111   if ( !wid )
01112     return;
01113 
01114   int sId = studyId;
01115   if ( sId < 0 )
01116   {
01117     if ( !activeStudy() )
01118       return;
01119     else
01120       sId = activeStudy()->id();
01121   }
01122 
01123   if ( !myWindows.contains( flag ) )
01124   {
01125     QMap<int, int> winMap;
01126     currentWindows( winMap );
01127 
01128     LightApp_WidgetContainer* newWC = new LightApp_WidgetContainer( flag, desktop() );
01129     connect( newWC, SIGNAL(  destroyed ( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
01130     // asv: connecting a slot for storing visibility flag of a window
01131     connect( newWC, SIGNAL( visibilityChanged ( bool ) ), SLOT( onVisibilityChanged( bool ) ) );
01132     myWindows.insert( flag, newWC );
01133     if ( winMap.contains( flag ) ) {
01134       //desktop()->removeDockWidget( myWindows[flag] );
01135       desktop()->addDockWidget( (Qt::DockWidgetArea)winMap[flag], myWindows[flag] );
01136     }
01137 
01138     //myWindows[flag]->setResizeEnabled( true );
01139     myWindows[flag]->setFeatures( QDockWidget::AllDockWidgetFeatures );
01140     myWindows[flag]->setObjectName( QString( "dock_window_%1" ).arg( flag ) );
01141     //myWindows[flag]->setFixedExtentWidth( wid->width() );
01142     //myWindows[flag]->setFixedExtentHeight( wid->height() );
01143     myWindows[flag]->resize( wid->width(), wid->height() );
01144   }
01145 
01146   QFont f;
01147 #ifndef DISABLE_PYCONSOLE
01148   if( wid->inherits( "PyConsole_Console" ) )
01149   {
01150     if( resourceMgr()->hasValue( "PyConsole", "font" ) )
01151       f = resourceMgr()->fontValue( "PyConsole", "font" );
01152     else
01153       {
01154         f = ( ( PyConsole_Console* )wid )->font();
01155         resourceMgr()->setValue( "PyConsole", "font", f );
01156       }
01157   }
01158   else
01159 #endif
01160     f = wid->font();
01161 
01162   myWindows[flag]->insert( sId, wid );
01163   wid->setFont( f );
01164 
01165   setWindowShown( flag, !myWindows[flag]->isEmpty() );
01166 }
01167 */
01168 
01169 QWidget* LightApp_Application::dockWindow( const int id ) const
01170 {
01171   QWidget* wid = 0;
01172   if ( myWin.contains( id ) )
01173     wid = myWin[id];
01174   return wid;
01175 }
01176 
01177 QDockWidget* LightApp_Application::windowDock( QWidget* wid ) const
01178 {
01179   if ( !wid )
01180     return 0;
01181 
01182   QDockWidget* dock = 0;
01183   QWidget* w = wid->parentWidget();
01184   while ( w && !dock )
01185   {
01186     dock = ::qobject_cast<QDockWidget*>( w );
01187     w = w->parentWidget();
01188   }
01189   return dock;
01190 }
01191 
01192 void LightApp_Application::insertDockWindow( const int id, QWidget* wid )
01193 {
01194   if ( !wid )
01195     return;
01196 
01197   if ( wid != dockWindow( id ) )
01198     removeDockWindow( id );
01199 
01200   myWin.insert( id, wid );
01201 
01202   QtxDockWidget* dock = new QtxDockWidget( true, desktop() );
01203   connect( dock, SIGNAL(  destroyed( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
01204 
01205   dock->setFeatures( QDockWidget::AllDockWidgetFeatures );
01206   dock->setObjectName( QString( "window_%1" ).arg( id ) );
01207   dock->setWidget( wid );
01208 
01209   QKeySequence accel = wid->property( "shortcut" ).value<QKeySequence>();
01210   if ( !accel.isEmpty() )
01211     dock->toggleViewAction()->setShortcut( accel );
01212 
01213   dock->show();
01214 }
01215 
01216 void LightApp_Application::removeDockWindow( const int id )
01217 {
01218   QWidget* wid = dockWindow( id );
01219   if ( !wid )
01220     return;
01221 
01222   myWin.remove( id );
01223 
01224   QDockWidget* dock = windowDock( wid );
01225   if ( !dock )
01226     return;
01227 
01228   dock->setWidget( 0 );
01229   wid->setParent( 0 );
01230   wid->setVisible( false );
01231   delete dock;
01232 }
01233 
01234 void LightApp_Application::placeDockWindow( const int id, Qt::DockWidgetArea place )
01235 {
01236   QDockWidget* dock = windowDock( dockWindow( id ) );
01237   if ( dock && desktop() ) {
01238     desktop()->addDockWidget( place, dock );
01239     QtxDockAction* a = qobject_cast<QtxDockAction*>( action( ViewWindowsId ) );
01240     if ( a ) a->update();
01241   }
01242 }
01243 
01250 QWidget* LightApp_Application::getWindow( const int flag, const int )
01251 {
01252   QWidget* wid = dockWindow( flag );
01253   if ( !wid )
01254     insertDockWindow( flag, wid = createWindow( flag ) );
01255 
01256   QMap<int, int> winMap;
01257   currentWindows( winMap );
01258   if ( winMap.contains( flag ) )
01259     placeDockWindow( flag, (Qt::DockWidgetArea)winMap[flag] );
01260 
01261   return wid;
01262 }
01263 
01267 SUIT_DataBrowser* LightApp_Application::objectBrowser()
01268 {
01269   return qobject_cast<SUIT_DataBrowser*>( dockWindow( WT_ObjectBrowser ) );
01270 }
01271 
01275 LogWindow* LightApp_Application::logWindow()
01276 {
01277   return qobject_cast<LogWindow*>( dockWindow( WT_LogWindow ) );
01278 }
01279 
01280 #ifndef DISABLE_PYCONSOLE
01281 
01284 PyConsole_Console* LightApp_Application::pythonConsole()
01285 {
01286   return qobject_cast<PyConsole_Console*>( dockWindow( WT_PyConsole ) );
01287 }
01288 #endif
01289 
01294 void LightApp_Application::updateObjectBrowser( const bool updateModels )
01295 {
01296   // update existing data models
01297   if ( updateModels )
01298   {
01299     const bool isAutoUpdate = objectBrowser() ? objectBrowser()->autoUpdate() : true;
01300     if ( objectBrowser() )
01301       objectBrowser()->setAutoUpdate( false );
01302 
01303     LightApp_Study* study = dynamic_cast<LightApp_Study*>(activeStudy());
01304     if ( study ) {
01305       CAM_Study::ModelList dm_list;
01306       study->dataModels( dm_list );
01307       QListIterator<CAM_DataModel*> it( dm_list );
01308       while ( it.hasNext() ) {
01309         CAM_DataModel* camDM = it.next();
01310         if ( camDM && camDM->inherits( "LightApp_DataModel" ) )
01311           ((LightApp_DataModel*)camDM)->update();
01312       }
01313     }
01314 
01315     if( objectBrowser() )
01316       objectBrowser()->setAutoUpdate( isAutoUpdate );
01317   }
01318 
01319   if ( objectBrowser() ) {
01320     objectBrowser()->updateGeometry();
01321     objectBrowser()->updateTree( 0, false );
01322   }
01323 }
01324 
01328 LightApp_Preferences* LightApp_Application::preferences() const
01329 {
01330   return preferences( false );
01331 }
01332 
01338 SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, const bool create )
01339 {
01340   SUIT_ViewManager* aVM = viewManager( vmType );
01341   SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
01342 
01343   if ( anActiveVM && anActiveVM->getType() == vmType )
01344     aVM = anActiveVM;
01345 
01346   if ( aVM && create )
01347   {
01348     if ( !aVM->getActiveView() )
01349       aVM->createView();
01350     else
01351       aVM->getActiveView()->setFocus();
01352   }
01353   else if ( create )
01354     aVM = createViewManager( vmType );
01355 
01356   return aVM;
01357 }
01358 
01363 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType )
01364 {
01365   SUIT_ResourceMgr* resMgr = resourceMgr();
01366 
01367   SUIT_ViewManager* viewMgr = 0;
01368 #ifndef DISABLE_GLVIEWER
01369   if( vmType == GLViewer_Viewer::Type() )
01370   {
01371     viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() );
01372     new LightApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
01373   }
01374 #endif
01375 #ifndef DISABLE_PLOT2DVIEWER
01376   if( vmType == Plot2d_Viewer::Type() )
01377   {
01378     viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
01379     Plot2d_Viewer* vm;
01380 #ifndef DISABLE_SALOMEOBJECT
01381     SPlot2d_Viewer* v = new SPlot2d_Viewer();
01382     vm = v;
01383     new LightApp_Plot2dSelector( v, mySelMgr );
01384 #else
01385     vm = new Plot2d_Viewer();
01386 #endif
01387     viewMgr->setViewModel( vm  );// custom view model, which extends SALOME_View interface
01388     Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
01389     if( wnd )
01390     {
01391       Plot2d_ViewFrame* frame = wnd->getViewFrame();
01392       frame->setBackgroundColor( resMgr->colorValue( "Plot2d", "Background", frame->backgroundColor() ) );
01393     }
01394   }
01395 #endif
01396   //#ifndef DISABLE_SUPERVGRAPHVIEWER
01397   //  if( vmType == SUPERVGraph_Viewer::Type() )
01398   //  {
01399   //    viewMgr = new SUPERVGraph_ViewManager( activeStudy(), desktop(), new SUPERVGraph_Viewer() );
01400   //  }
01401   //#endif
01402 #ifndef DISABLE_QXGRAPHVIEWER
01403 //VSR: QxGraph has been replaced by QxScene
01404 //  if( vmType == QxGraph_Viewer::Type() )
01405 //    {
01406 //      viewMgr = new QxGraph_ViewManager( activeStudy(), desktop(), new QxGraph_Viewer() );
01407 //    }
01408   if( vmType == QxScene_Viewer::Type() )
01409   {
01410     viewMgr = new QxScene_ViewManager( activeStudy(), desktop() );
01411     QxScene_Viewer* vm = new QxScene_Viewer();
01412     viewMgr->setViewModel( vm  );
01413     //QxScene_ViewWindow* wnd = dynamic_cast<QxScene_ViewWindow*>( viewMgr->getActiveView() );
01414   }
01415 #endif
01416 #ifndef DISABLE_OCCVIEWER
01417   if( vmType == OCCViewer_Viewer::Type() )
01418   {
01419     viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
01420     OCCViewer_Viewer* vm;
01421 #ifndef DISABLE_SALOMEOBJECT
01422     vm = new SOCC_Viewer();
01423 #else
01424     vm = new OCCViewer_Viewer( true );
01425 #endif
01426     vm->setBackground( OCCViewer_ViewFrame::TOP_LEFT,
01427                      resMgr->backgroundValue( "OCCViewer", "xz_background", vm->background(OCCViewer_ViewFrame::TOP_LEFT) ) );
01428     vm->setBackground( OCCViewer_ViewFrame::TOP_RIGHT,
01429                      resMgr->backgroundValue( "OCCViewer", "yz_background", vm->background(OCCViewer_ViewFrame::TOP_RIGHT) ) );
01430     vm->setBackground( OCCViewer_ViewFrame::BOTTOM_LEFT,
01431                      resMgr->backgroundValue( "OCCViewer", "xy_background", vm->background(OCCViewer_ViewFrame::BOTTOM_LEFT) ) );
01432     vm->setBackground( OCCViewer_ViewFrame::BOTTOM_RIGHT,
01433                      resMgr->backgroundValue( "OCCViewer", "background", vm->background(OCCViewer_ViewFrame::MAIN_VIEW) ) );
01434 
01435     vm->setTrihedronSize(  resMgr->doubleValue( "OCCViewer", "trihedron_size", vm->trihedronSize() ),
01436                            resMgr->booleanValue( "OCCViewer", "relative_size", vm->trihedronRelative() ));
01437     int u( 1 ), v( 1 );
01438     vm->isos( u, v );
01439     u = resMgr->integerValue( "OCCViewer", "iso_number_u", u );
01440     v = resMgr->integerValue( "OCCViewer", "iso_number_v", v );
01441     vm->setIsos( u, v );
01442     vm->setInteractionStyle( resMgr->integerValue( "OCCViewer", "navigation_mode", vm->interactionStyle() ) );
01443     vm->setZoomingStyle( resMgr->integerValue( "OCCViewer", "zooming_mode", vm->zoomingStyle() ) );
01444     viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
01445     new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
01446   }
01447 #endif
01448 #ifndef DISABLE_VTKVIEWER
01449 #ifndef DISABLE_SALOMEOBJECT
01450   if ( vmType == SVTK_Viewer::Type() )
01451 #else
01452   if ( vmType == VTKViewer_Viewer::Type() )
01453 #endif
01454   {
01455 #ifndef DISABLE_SALOMEOBJECT
01456     viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
01457     SVTK_Viewer* vm = dynamic_cast<SVTK_Viewer*>( viewMgr->getViewModel() );
01458     if( vm )
01459     {
01460       vm->setProjectionMode( resMgr->integerValue( "VTKViewer", "projection_mode", vm->projectionMode() ) );
01461       vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
01462       vm->setTrihedronSize( resMgr->doubleValue( "VTKViewer", "trihedron_size", vm->trihedronSize() ),
01463                             resMgr->booleanValue( "VTKViewer", "relative_size", vm->trihedronRelative() ) );
01464       vm->setStaticTrihedronVisible( resMgr->booleanValue( "VTKViewer", "show_static_trihedron", vm->isStaticTrihedronVisible() ) );
01465       vm->setInteractionStyle( resMgr->integerValue( "VTKViewer", "navigation_mode", vm->interactionStyle() ) );
01466       vm->setZoomingStyle( resMgr->integerValue( "VTKViewer", "zooming_mode", vm->zoomingStyle() ) );
01467       vm->setDynamicPreSelection( resMgr->booleanValue( "VTKViewer", "dynamic_preselection", vm->dynamicPreSelection() ) );
01468       vm->setIncrementalSpeed( resMgr->integerValue( "VTKViewer", "speed_value", vm->incrementalSpeed() ),
01469                                resMgr->integerValue( "VTKViewer", "speed_mode", vm->incrementalSpeedMode() ) );
01470       vm->setSpacemouseButtons( resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", vm->spacemouseBtn(1) ),
01471                                 resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", vm->spacemouseBtn(2) ),
01472                                 resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", vm->spacemouseBtn(3) ) );
01473       new LightApp_VTKSelector( vm, mySelMgr );
01474     }
01475 #else
01476     viewMgr = new VTKViewer_ViewManager( activeStudy(), desktop() );
01477     VTKViewer_Viewer* vm = dynamic_cast<VTKViewer_Viewer*>( viewMgr->getViewModel() );
01478     if ( vm )
01479       vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) );
01480 #endif
01481   }
01482 #endif
01483 
01484   if ( !viewMgr )
01485     return 0;
01486 
01487   addViewManager( viewMgr );
01488   SUIT_ViewWindow* viewWin = viewMgr->createViewWindow();
01489 
01490   if ( viewWin && desktop() ) {
01491     viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
01492     viewWin->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
01493   }
01494 
01495   return viewMgr;
01496 }
01497 
01498 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, QWidget* w )
01499 {
01500   SUIT_ResourceMgr* resMgr = resourceMgr();
01501 
01502   SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(),
01503                                                desktop(),
01504                                                new LightApp_WgViewModel( vmType, w ) );
01505   vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) );
01506 
01507   addViewManager( vm );
01508   SUIT_ViewWindow* vw = vm->createViewWindow();
01509   if ( vw && desktop() ) {
01510     vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
01511     vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
01512   }
01513 
01514   if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) )
01515     myUserWmTypes << vmType;
01516 
01517   return vm;
01518 }
01519 
01523 void LightApp_Application::onCloseView( SUIT_ViewManager* theVM )
01524 {
01525   removeViewManager( theVM );
01526 }
01527 
01532 void LightApp_Application::onStudyCreated( SUIT_Study* theStudy )
01533 {
01534   SUIT_DataObject* aRoot = 0;
01535   if ( theStudy && theStudy->root() )
01536   {
01537     aRoot = theStudy->root();
01538     //aRoot->setName( tr( "DATA_MODELS" ) );
01539   }
01540 
01541   getWindow( WT_ObjectBrowser );
01542 
01543   loadDockWindowsState();
01544 
01545   if ( objectBrowser() )
01546     objectBrowser()->setRoot( aRoot );
01547 
01548   activateModule( defaultModule() );
01549 
01550   if ( objectBrowser() )
01551     objectBrowser()->openLevels();
01552 }
01553 
01558 void LightApp_Application::onStudyOpened( SUIT_Study* theStudy )
01559 {
01560   SUIT_DataObject* aRoot = 0;
01561   if ( theStudy && theStudy->root() )
01562   {
01563     aRoot = theStudy->root();
01564     //aRoot->dump();
01565   }
01566 
01567   getWindow( WT_ObjectBrowser );
01568 
01569   loadDockWindowsState();
01570 
01571   if ( objectBrowser() )
01572     objectBrowser()->setRoot( aRoot );
01573 
01574   activateModule( defaultModule() );
01575 
01576   if ( objectBrowser() )
01577     objectBrowser()->openLevels();
01578 
01579   emit studyOpened();
01580 }
01581 
01583 void LightApp_Application::onStudySaved( SUIT_Study* s )
01584 {
01585   QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
01586   if ( mru && s )
01587       mru->insert( s->studyName() );
01588 
01589   emit studySaved();
01590 }
01591 
01593 void LightApp_Application::onStudyClosed( SUIT_Study* s )
01594 {
01595   // stop auto-save timer
01596   myAutoSaveTimer->stop();
01597 
01598   // Bug 10396: clear selection
01599   mySelMgr->clearSelected();
01600 
01601   // Bug 12944: emit signal only after clear selection
01602   emit studyClosed();
01603 
01604   activateModule( "" );
01605 }
01606 
01608 void LightApp_Application::onDesktopActivated()
01609 {
01610   CAM_Application::onDesktopActivated();
01611   LightApp_Module* aModule = dynamic_cast<LightApp_Module*>(activeModule());
01612   if(aModule)
01613     aModule->studyActivated();
01614 }
01615 
01616 void LightApp_Application::studyOpened( SUIT_Study* s )
01617 {
01618   CAM_Application::studyOpened( s );
01619 
01620   updateWindows();
01621   updateViewManagers();
01622 }
01623 
01624 void LightApp_Application::studySaved( SUIT_Study* s )
01625 {
01626   CAM_Application::studyOpened( s );
01627   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
01628   if ( aResMgr && activeStudy() ) {
01629     int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
01630     if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
01631   }
01632 }
01633 
01634 void LightApp_Application::studyCreated( SUIT_Study* s )
01635 {
01636   CAM_Application::studyCreated( s );
01637 
01638   updateWindows();
01639   updateViewManagers();
01640 }
01641 
01645 QString LightApp_Application::getFileFilter() const
01646 {
01647   //return "(*.bin)";
01648   // HDF persistence
01649   return "(*.hdf)";
01650 }
01651 
01655 QString LightApp_Application::getFileName( bool open, const QString& initial, const QString& filters,
01656                                            const QString& caption, QWidget* parent )
01657 {
01658   if ( !parent )
01659     parent = desktop();
01660   QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
01661   return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
01662 }
01663 
01665 QString LightApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
01666 {
01667   if ( !parent )
01668     parent = desktop();
01669   return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true );
01670 }
01671 
01673 QStringList LightApp_Application::getOpenFileNames( const QString& initial, const QString& filters,
01674                                                     const QString& caption, QWidget* parent )
01675 {
01676   if ( !parent )
01677     parent = desktop();
01678   QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
01679   return SUIT_FileDlg::getOpenFileNames( parent, initial, fls, caption, true );
01680 }
01681 
01683 void LightApp_Application::onRefresh()
01684 {
01685   updateObjectBrowser( true );
01686 }
01687 
01689 void LightApp_Application::onDropped( const QList<SUIT_DataObject*>& objects, SUIT_DataObject* parent, int row, Qt::DropAction action )
01690 {
01691   LightApp_DataObject* parentObj = dynamic_cast<LightApp_DataObject*>( parent );
01692   if ( !parentObj )
01693     return;
01694 
01695   LightApp_Module* aModule = dynamic_cast<LightApp_Module*>( parentObj->module() );
01696   if ( aModule )
01697     aModule->dropObjects( objects, parentObj, row, action );
01698 }
01699 
01701 void LightApp_Application::onPreferences()
01702 {
01703   showPreferences( activeModule() ? activeModule()->moduleName() : tr( "PREF_CATEGORY_SALOME" ) );
01704 }
01705 
01707 void LightApp_Application::showPreferences( const QString& itemText )
01708 {
01709   QApplication::setOverrideCursor( Qt::WaitCursor );
01710 
01711   LightApp_PreferencesDlg* prefDlg = new LightApp_PreferencesDlg( preferences( true ), desktop());
01712 
01713   QApplication::restoreOverrideCursor();
01714 
01715   if ( !prefDlg )
01716     return;
01717 
01718   preferences()->activateItem( itemText );
01719 
01720   if ( ( prefDlg->exec() == QDialog::Accepted || prefDlg->isSaved() ) &&  resourceMgr() )
01721   {
01722     if ( desktop() )
01723       resourceMgr()->setValue( "desktop", "geometry", desktop()->storeGeometry() );
01724     resourceMgr()->save();
01725 
01726     // Update shortcuts
01727     shortcutMgr()->updateShortcuts();
01728   }
01729 
01730   delete prefDlg;
01731 }
01732 
01734 void LightApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param )
01735 {
01736   LightApp_Module* sMod = 0;
01737   CAM_Module* mod = module( modName );
01738   if ( mod && mod->inherits( "LightApp_Module" ) )
01739     sMod = (LightApp_Module*)mod;
01740 
01741   if ( sMod )
01742     sMod->preferencesChanged( section, param );
01743   else
01744     preferencesChanged( section, param );
01745   // emit signal to allow additional preferences changing processing
01746   emit preferenceChanged( modName, section, param );
01747 }
01748 
01750 void LightApp_Application::beforeCloseDoc( SUIT_Study* s )
01751 {
01752   CAM_Application::beforeCloseDoc( s );
01753 }
01754 
01756 void LightApp_Application::updateActions()
01757 {
01758   updateCommandsStatus();
01759 }
01760 
01764 SUIT_Study* LightApp_Application::createNewStudy()
01765 {
01766   LightApp_Application::lastStudyId++;
01767 
01768   LightApp_Study* aStudy = new LightApp_Study( this );
01769 
01770   // Set up processing of major study-related events
01771   connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
01772   connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
01773   connect( aStudy, SIGNAL( saved  ( SUIT_Study* ) ), this, SLOT( onStudySaved  ( SUIT_Study* ) ) );
01774   connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
01775 
01776   return aStudy;
01777 }
01778 
01783 QWidget* LightApp_Application::createWindow( const int flag )
01784 {
01785   QWidget* wid = 0;
01786 
01787   SUIT_ResourceMgr* resMgr = resourceMgr();
01788 
01789   if ( flag == WT_ObjectBrowser )
01790   {
01791     SUIT_DataBrowser* ob = new SUIT_DataBrowser( new LightApp_DataObject(), desktop() );
01792     ob->setSortMenuEnabled( true );
01793     ob->setAutoUpdate( true );
01794     if ( resMgr->hasValue( "ObjectBrowser", "auto_hide_search_tool" ) )
01795       ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
01796 
01797     //ob->setAutoOpenLevel( 1 ); // commented by ASV as a fix to bug IPAL10107
01798     ob->setWindowTitle( tr( "OBJECT_BROWSER" ) );
01799     connect( ob, SIGNAL( requestUpdate() ), this, SLOT( onRefresh() ) );
01800 
01801     QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
01802     SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
01803     treeModel->setSearcher( this );
01804     treeModel->registerColumn( 0, EntryCol, LightApp_DataObject::EntryId );
01805     treeModel->setAppropriate( EntryCol, Qtx::Toggled );
01806 
01807     // Mantis issue 0020136: Drag&Drop in OB
01808     SUIT_ProxyModel* proxyModel = dynamic_cast<SUIT_ProxyModel*>(treeModel);
01809     if ( proxyModel ) {
01810       connect( proxyModel, SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
01811               this,       SLOT( onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
01812     }
01813 
01814     // temporary commented
01815     /*
01816     OB_ListView* ob_list = dynamic_cast<OB_ListView*>( const_cast<QListView*>( ob->listView() ) );
01817     if( ob_list )
01818       ob_list->setColumnMaxWidth( 0, desktop()->width()/4 );
01819 
01820     ob->setFilter( new LightApp_OBFilter( selectionMgr() ) );
01821     */
01822 
01823     // Create OBSelector
01824     new LightApp_OBSelector( ob, mySelMgr );
01825 
01826     ob->treeView()->header()->setResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
01827     ob->treeView()->header()->moveSection(SUIT_DataObject::NameId,SUIT_DataObject::VisibilityId);
01828     ob->treeView()->setColumnWidth(SUIT_DataObject::VisibilityId, VISIBILITY_COLUMN_WIDTH);
01829     ob->setProperty( "shortcut", QKeySequence( "Alt+Shift+O" ) );
01830     wid = ob;
01831     ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
01832   }
01833 #ifndef DISABLE_PYCONSOLE
01834   else  if ( flag == WT_PyConsole )
01835   {
01836     PyConsole_Console* pyCons = new PyConsole_Console( desktop(),new LightApp_PyInterp());
01837     pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
01838     pyCons->setFont(resourceMgr()->fontValue( "PyConsole", "font" ));
01839     pyCons->setIsShowBanner(resourceMgr()->booleanValue( "PyConsole", "show_banner", true ));
01840     pyCons->setProperty( "shortcut", QKeySequence( "Alt+Shift+P" ) );
01841 
01842     wid = pyCons;
01843     pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
01844   }
01845 #endif
01846   else if ( flag == WT_LogWindow )
01847   {
01848     LogWindow* logWin = new LogWindow( desktop() );
01849     logWin->setWindowTitle( tr( "LOG_WINDOW" ) );
01850     logWin->setProperty( "shortcut", QKeySequence( "Alt+Shift+L" ) );
01851     wid = logWin;
01852     logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
01853   }
01854   return wid;
01855 }
01856 
01861 void LightApp_Application::defaultWindows( QMap<int, int>& aMap ) const
01862 {
01863   aMap.insert( WT_ObjectBrowser, Qt::LeftDockWidgetArea );
01864 #ifndef DISABLE_PYCONSOLE
01865   aMap.insert( WT_PyConsole, Qt::BottomDockWidgetArea );
01866 #endif
01867   //  aMap.insert( WT_LogWindow, Qt::DockBottom );
01868 }
01869 
01871 void LightApp_Application::defaultViewManagers( QStringList& ) const
01872 {
01874 }
01875 
01880 LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const
01881 {
01882   if ( myPrefs )
01883     return myPrefs;
01884 
01885   LightApp_Application* that = (LightApp_Application*)this;
01886 
01887   bool toCreate = !_prefs_ && crt;
01888   if ( toCreate )
01889   {
01890     _prefs_ = new LightApp_Preferences( resourceMgr() );
01891     that->createPreferences( _prefs_ );
01892   }
01893 
01894   that->myPrefs = _prefs_;
01895 
01896   connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
01897            this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ) );
01898 
01899   if ( !crt )
01900     return myPrefs;
01901 
01902   SUIT_ResourceMgr* resMgr = resourceMgr();
01903 
01904   QList<SUIT_Application*> appList = SUIT_Session::session()->applications();
01905   for ( QList<SUIT_Application*>::iterator appIt = appList.begin(); appIt != appList.end(); ++appIt )
01906   {
01907     LightApp_Application* app = ::qobject_cast<LightApp_Application*>( *appIt );
01908     if ( !app )
01909       continue;
01910 
01911     QStringList modNameList;
01912     app->modules( modNameList, false );
01913 
01914     QMap<QString, QString> iconMap;
01915     app->moduleIconNames( iconMap );
01916 
01917     for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it )
01918     {
01919       if ( !app->isLibExists( *it ) || _prefs_->hasModule( *it ) )
01920         continue;
01921 
01922       int modId = _prefs_->addPreference( *it );
01923       if ( iconMap.contains( *it ) )
01924         _prefs_->setItemIcon( modId, Qtx::scaleIcon( resMgr->loadPixmap( moduleName( *it ), iconMap[*it], false ), 20 ) );
01925     }
01926 
01927     ModuleList modList;
01928     app->modules( modList );
01929     QListIterator<CAM_Module*> itr( modList );
01930     while ( itr.hasNext() )
01931     {
01932       LightApp_Module* mod = 0;
01933 
01934       CAM_Module* anItem = itr.next();
01935       if ( anItem->inherits( "LightApp_Module" ) )
01936         mod = (LightApp_Module*)anItem;
01937 
01938       if ( mod && !_prefs_->hasModule( mod->moduleName() ) )
01939       {
01940         _prefs_->addPreference( mod->moduleName() );
01941         mod->createPreferences();
01942         that->emptyPreferences( mod->moduleName() );
01943       }
01944     }
01945   }
01946   _prefs_->setItemProperty( "info", tr( "PREFERENCES_NOT_LOADED" ) );
01947 
01948   return myPrefs;
01949 }
01950 
01954 void LightApp_Application::moduleAdded( CAM_Module* mod )
01955 {
01956   CAM_Application::moduleAdded( mod );
01957 
01958   LightApp_Module* lightMod = 0;
01959   if ( mod && mod->inherits( "LightApp_Module" ) )
01960     lightMod = (LightApp_Module*)mod;
01961 
01962   if ( myPrefs && lightMod && !myPrefs->hasModule( lightMod->moduleName() ))
01963   {
01964     myPrefs->addPreference( mod->moduleName() );
01965     lightMod->createPreferences();
01966     emptyPreferences( mod->moduleName() );
01967   }
01968 }
01969 
01970 void LightApp_Application::emptyPreferences( const QString& modName )
01971 {
01972   QtxPreferenceItem* item = myPrefs->findItem( modName, true );
01973   if ( !item || !item->isEmpty() )
01974     return;
01975 
01976   //  printf( "---------------------> Modify for empty module.\n" );
01977 
01978   QtxPagePrefFrameItem* frm = new QtxPagePrefFrameItem( item->title(), item->parentItem() );
01979   frm->setIcon( item->icon() );
01980   frm->setStretch( false );
01981   item->parentItem()->insertItem( frm, item );
01982   new QtxPagePrefLabelItem( Qt::AlignCenter, tr( "PREFERENCES_NOT_SUPPORTED" ).arg( modName ), frm );
01983   delete item;
01984 }
01985 
01989 void LightApp_Application::createPreferences( LightApp_Preferences* pref )
01990 {
01991   if ( !pref )
01992     return;
01993 
01994   QStringList     aValuesList;
01995   QList<QVariant> anIndicesList;
01996   QIntList        idList;
01997   QIntList        txtList;
01998 
01999   // . Top-level "SALOME" preferences group <<start>>
02000   int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
02001   pref->setItemIcon( salomeCat, Qtx::scaleIcon( resourceMgr()->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false ), 20 ) );
02002 
02003   // .. "General" preferences tab <<start>>
02004   int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat );
02005 
02006   // ... "Language" group <<start>>
02007   int langGroup = pref->addPreference( tr( "PREF_GROUP_LANGUAGE" ), genTab );
02008   pref->setItemProperty( "columns", 2, langGroup );
02009   // .... -> application language
02010   int curLang = pref->addPreference( tr( "PREF_CURRENT_LANGUAGE" ), langGroup,
02011                                           LightApp_Preferences::Selector, "language", "language" );
02012   QStringList aLangs = SUIT_Session::session()->resourceMgr()->stringValue( "language", "languages", "en" ).split( "," );
02013   QList<QVariant> aIcons;
02014   foreach ( QString aLang, aLangs ) {
02015     aIcons << QPixmap( QString( ":/images/%1" ).arg( aLang ) );
02016   }
02017   pref->setItemProperty( "strings", aLangs, curLang );
02018   pref->setItemProperty( "icons",   aIcons, curLang );
02019   // ... "Language" group <<end>>
02020 
02021   // ... "Look and feel" group <<start>>
02022   int lookGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), genTab );
02023   // .... -> opaque resize
02024   pref->addPreference( tr( "PREF_OPAQUE_RESIZE" ), lookGroup, LightApp_Preferences::Bool, "desktop", "opaque_resize" );
02025   // .... -> drop-down buttons 
02026   pref->addPreference( tr( "PREF_DROP_DOWN_BUTTONS" ), lookGroup, LightApp_Preferences::Bool, "viewers", "drop_down_buttons" );
02027   // ... "Look and feel" group <<end>>
02028 
02029   // ... "Study properties" group <<start>>
02030   int studyGroup = pref->addPreference( tr( "PREF_GROUP_STUDY" ), genTab );
02031   pref->setItemProperty( "columns", 2, studyGroup );
02032   // .... -> multi-file save
02033   pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "multi_file" );
02034   // .... -> ascii save mode
02035   pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" );
02036   // .... -> store windows geometry
02037   pref->addPreference( tr( "PREF_STORE_POS" ),  studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" );
02038   // .... -> auto-save
02039   int autoSaveInterval = pref->addPreference( tr( "PREF_AUTO_SAVE" ),  studyGroup,
02040                                               LightApp_Preferences::IntSpin, "Study", "auto_save_interval" );
02041   pref->setItemProperty( "min",        0, autoSaveInterval );
02042   pref->setItemProperty( "max",     1440, autoSaveInterval );
02043   pref->setItemProperty( "special", tr( "PREF_AUTO_SAVE_DISABLED" ), autoSaveInterval );
02044   // ... "Study properties" group <<end>>
02045 
02046   // ... "Help browser" group <<start>>
02047   int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab, LightApp_Preferences::Auto, "ExternalBrowser", "use_external_browser");
02048 #ifdef WIN32
02049   QString platform = "winapplication";
02050 #else
02051   QString platform = "application";
02052 #endif
02053   // .... -> browser application
02054   int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, LightApp_Preferences::File, "ExternalBrowser", platform );
02055   pref->setItemProperty( "mode", Qtx::PT_OpenFile, apppref );
02056   // .... -> browser parameters
02057   pref->addPreference( tr( "PREF_PARAM" ), extgroup, LightApp_Preferences::String, "ExternalBrowser", "parameters" );
02058   // ... "Help browser" group <<end>>
02059 
02060   // ... "Python console properties" group <<start>>
02061   int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab );
02062   // .... -> font
02063   pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, LightApp_Preferences::Font, "PyConsole", "font" );
02064   // .... -> show banner
02065   pref->addPreference( tr( "PREF_SHOW_BANNER" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "show_banner" );
02066   // ... "Python console properties" group <<end>>
02067 
02068   // ... "MRU" preferences group <<start>>
02069   int mruGroup = pref->addPreference( tr( "PREF_GROUP_MRU" ), genTab, LightApp_Preferences::Auto, "MRU", "show_mru" );
02070   pref->setItemProperty( "columns", 4, mruGroup );
02071   // number of MRU items
02072   int mruVisCount = pref->addPreference( tr( "PREF_MRU_VISIBLE_COUNT" ), mruGroup, LightApp_Preferences::IntSpin,
02073                                          "MRU", "visible_count" );
02074   pref->setItemProperty( "min", 0,   mruVisCount );
02075   pref->setItemProperty( "max", 100, mruVisCount );
02076   // MRU links type
02077   int mruLinkType = pref->addPreference( tr( "PREF_MRU_LINK_TYPE" ), mruGroup, LightApp_Preferences::Selector,
02078                                          "MRU", "link_type" );
02079   aValuesList.clear();
02080   anIndicesList.clear();
02081   aValuesList   << tr("PREF_MRU_LINK_AUTO") << tr("PREF_MRU_LINK_SHORT") << tr("PREF_MRU_LINK_FULL");
02082   anIndicesList << 0                        << 1                         << 2                       ;
02083   pref->setItemProperty( "strings", aValuesList,   mruLinkType );
02084   pref->setItemProperty( "indexes", anIndicesList, mruLinkType );
02085   // ... "MRU" preferences group <<end>>
02086   // .. "General" preferences tab <<end>>
02087 
02088   // .. "OCC viewer" group <<start>>
02089   int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), salomeCat );
02090 
02091   // ... "Trihedron" group <<start>>
02092   int occTriGroup = pref->addPreference( tr( "PREF_TRIHEDRON" ), occGroup );
02093   pref->setItemProperty( "columns", 2, occTriGroup );
02094   // .... -> trihedron size
02095   int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occTriGroup,
02096                                    LightApp_Preferences::DblSpin, "OCCViewer", "trihedron_size" );
02097   pref->setItemProperty( "min", 1.0E-06, occTS );
02098   pref->setItemProperty( "max", 1000, occTS );
02099   // .... -> relative size of trihedron
02100   pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), occTriGroup, LightApp_Preferences::Bool, "OCCViewer", "relative_size" );
02101   // .... -> show static trihedron
02102   pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), occTriGroup, LightApp_Preferences::Bool, "OCCViewer", "show_static_trihedron" );
02103   // ... "Trihedron" group <<end>>
02104 
02105   // ... "Iso-lines" group <<start>>
02106   int isoGroup = pref->addPreference( tr( "PREF_ISOS" ), occGroup );
02107   pref->setItemProperty( "columns", 2, isoGroup );
02108   // .... -> nb isos U
02109   int isoU = pref->addPreference( tr( "PREF_ISOS_U" ), isoGroup,
02110                                   LightApp_Preferences::IntSpin, "OCCViewer", "iso_number_u" );
02111   pref->setItemProperty( "min", 0, isoU );
02112   pref->setItemProperty( "max", 100000, isoU );
02113   // .... -> nb isos V
02114   int isoV = pref->addPreference( tr( "PREF_ISOS_V" ), isoGroup,
02115                                   LightApp_Preferences::IntSpin, "OCCViewer", "iso_number_v" );
02116   pref->setItemProperty( "min", 0, isoV );
02117   pref->setItemProperty( "max", 100000, isoV );
02118   // ... "Iso-lines" group <<end>>
02119 
02120   // ... "Background" group <<start>>
02121   int bgGroup = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup );
02122   //  pref->setItemProperty( "columns", 2, bgGroup );
02123   aValuesList.clear();
02124   anIndicesList.clear();
02125   txtList.clear();
02126   QString formats = OCCViewer_Viewer::backgroundData( aValuesList, idList, txtList );
02127   foreach( int gid, idList ) anIndicesList << gid;
02128   // .... -> 3D viewer background
02129   int bgId = pref->addPreference( tr( "PREF_3DVIEWER_BACKGROUND" ), bgGroup,
02130                               LightApp_Preferences::Background, "OCCViewer", "background" );
02131   pref->setItemProperty( "gradient_names", aValuesList, bgId );
02132   pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
02133   pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
02134   pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
02135   pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
02136   pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
02137   pref->setItemProperty( "custom_enabled", false, bgId );
02138   pref->setItemProperty( "image_formats", formats, bgId );
02139   // .... -> XZ viewer background
02140   bgId = pref->addPreference( tr( "PREF_XZVIEWER_BACKGROUND" ), bgGroup,
02141                            LightApp_Preferences::Background, "OCCViewer", "xz_background" );
02142   pref->setItemProperty( "gradient_names", aValuesList, bgId );
02143   pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
02144   pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
02145   pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
02146   pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
02147   pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
02148   pref->setItemProperty( "custom_enabled", false, bgId );
02149   pref->setItemProperty( "image_formats", formats, bgId );
02150   // .... -> YZ viewer background
02151   bgId = pref->addPreference( tr( "PREF_YZVIEWER_BACKGROUND" ), bgGroup,
02152                            LightApp_Preferences::Background, "OCCViewer", "yz_background" );
02153   pref->setItemProperty( "gradient_names", aValuesList, bgId );
02154   pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
02155   pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
02156   pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
02157   pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
02158   pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
02159   pref->setItemProperty( "custom_enabled", false, bgId );
02160   pref->setItemProperty( "image_formats", formats, bgId );
02161   // .... -> XY viewer background
02162   bgId = pref->addPreference( tr( "PREF_XYVIEWER_BACKGROUND" ), bgGroup,
02163                            LightApp_Preferences::Background, "OCCViewer", "xy_background" );
02164   pref->setItemProperty( "gradient_names", aValuesList, bgId );
02165   pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
02166   pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
02167   pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
02168   pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
02169   pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
02170   pref->setItemProperty( "custom_enabled", false, bgId );
02171   pref->setItemProperty( "image_formats", formats, bgId );
02172   // ... "Background" group <<end>>
02173 
02174   // ... -> empty frame (for layout) <<start>>
02175   int occGen = pref->addPreference( "", occGroup, LightApp_Preferences::Frame );
02176   pref->setItemProperty( "margin",  0, occGen );
02177   pref->setItemProperty( "columns", 2, occGen );
02178   // .... -> navigation mode
02179   int occStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), occGen,
02180                                           LightApp_Preferences::Selector, "OCCViewer", "navigation_mode" );
02181   aValuesList.clear();
02182   anIndicesList.clear();
02183   aValuesList   << tr("PREF_STANDARD_STYLE") << tr("PREF_KEYFREE_STYLE");
02184   anIndicesList << 0                         << 1;
02185   pref->setItemProperty( "strings", aValuesList,   occStyleMode );
02186   pref->setItemProperty( "indexes", anIndicesList, occStyleMode );
02187   // .... -> zooming mode
02188 #if OCC_VERSION_LARGE > 0x0603000A // available only with OCC-6.3-sp11 and higher version
02189   int occZoomingStyleMode = pref->addPreference( tr( "PREF_ZOOMING" ), occGen,
02190                                                  LightApp_Preferences::Selector, "OCCViewer", "zooming_mode" );
02191   aValuesList.clear();
02192   anIndicesList.clear();
02193   aValuesList   << tr("PREF_ZOOMING_AT_CENTER") << tr("PREF_ZOOMING_AT_CURSOR");
02194   anIndicesList << 0                            << 1;
02195   pref->setItemProperty( "strings", aValuesList,   occZoomingStyleMode );
02196   pref->setItemProperty( "indexes", anIndicesList, occZoomingStyleMode );
02197 #endif
02198   // ... -> empty frame (for layout) <<end>>
02199   // .. "OCC viewer" group <<end>>
02200 
02201   // .. "VTK viewer" group <<start>>
02202   int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), salomeCat ); //viewTab
02203 
02204   // ... -> empty frame (for layout) <<start>>
02205   int vtkGen = pref->addPreference( "", vtkGroup, LightApp_Preferences::Frame );
02206   //pref->setItemProperty( "columns", 2, vtkGen );
02207   // .... -> projection mode
02208   int vtkProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), vtkGen,
02209                                          LightApp_Preferences::Selector, "VTKViewer", "projection_mode" );
02210   aValuesList.clear();
02211   anIndicesList.clear();
02212   aValuesList   << tr("PREF_ORTHOGRAPHIC") << tr("PREF_PERSPECTIVE");
02213   anIndicesList << 0                       << 1;
02214   pref->setItemProperty( "strings", aValuesList,   vtkProjMode );
02215   pref->setItemProperty( "indexes", anIndicesList, vtkProjMode );
02216   // .... -> background
02217   aValuesList.clear();
02218   anIndicesList.clear();
02219   txtList.clear();
02220   formats = SVTK_Viewer::backgroundData( aValuesList, idList, txtList );
02221   foreach( int gid, idList ) anIndicesList << gid;
02222   bgId = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGen,
02223                            LightApp_Preferences::Background, "VTKViewer", "background" );
02224   pref->setItemProperty( "gradient_names", aValuesList, bgId );
02225   pref->setItemProperty( "gradient_ids", anIndicesList, bgId );
02226   pref->setItemProperty( "texture_enabled", !txtList.isEmpty(), bgId );
02227   pref->setItemProperty( "texture_center_enabled", (bool)txtList.contains( Qtx::CenterTexture ), bgId );
02228   pref->setItemProperty( "texture_tile_enabled", (bool)txtList.contains( Qtx::TileTexture ), bgId );
02229   pref->setItemProperty( "texture_stretch_enabled", (bool)txtList.contains( Qtx::StretchTexture ), bgId );
02230   pref->setItemProperty( "custom_enabled", false, bgId );
02231   pref->setItemProperty( "image_formats", formats, bgId );
02232   // .... -> navigation mode
02233   int vtkStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), vtkGen,
02234                                           LightApp_Preferences::Selector, "VTKViewer", "navigation_mode" );
02235   aValuesList.clear();
02236   anIndicesList.clear();
02237   aValuesList   << tr("PREF_STANDARD_STYLE") << tr("PREF_KEYFREE_STYLE");
02238   anIndicesList << 0                         << 1;
02239   pref->setItemProperty( "strings", aValuesList,   vtkStyleMode );
02240   pref->setItemProperty( "indexes", anIndicesList, vtkStyleMode );
02241   // .... -> zooming mode
02242   int vtkZoomingStyleMode = pref->addPreference( tr( "PREF_ZOOMING" ), vtkGen,
02243                                                  LightApp_Preferences::Selector, "VTKViewer", "zooming_mode" );
02244   aValuesList.clear();
02245   anIndicesList.clear();
02246   aValuesList   << tr("PREF_ZOOMING_AT_CENTER") << tr("PREF_ZOOMING_AT_CURSOR");
02247   anIndicesList << 0                            << 1;
02248   pref->setItemProperty( "strings", aValuesList,   vtkZoomingStyleMode );
02249   pref->setItemProperty( "indexes", anIndicesList, vtkZoomingStyleMode );
02250   // .... -> speed increment
02251   int vtkSpeed = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED" ), vtkGen,
02252                                       LightApp_Preferences::IntSpin, "VTKViewer", "speed_value" );
02253   pref->setItemProperty( "min", 1, vtkSpeed );
02254   pref->setItemProperty( "max", 1000, vtkSpeed );
02255   // .... -> speed mode
02256   int vtkSpeedMode = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED_MODE" ), vtkGen,
02257                                           LightApp_Preferences::Selector, "VTKViewer", "speed_mode" );
02258   aValuesList.clear();
02259   anIndicesList.clear();
02260   aValuesList   << tr("PREF_ARITHMETIC") << tr("PREF_GEOMETRICAL");
02261   anIndicesList << 0                     << 1;
02262   pref->setItemProperty( "strings", aValuesList,   vtkSpeedMode );
02263   pref->setItemProperty( "indexes", anIndicesList, vtkSpeedMode );
02264   // .... -> dynamic pre-selection
02265   pref->addPreference( tr( "PREF_DYNAMIC_PRESELECTION" ),  vtkGen, LightApp_Preferences::Bool, "VTKViewer", "dynamic_preselection" );
02266   // ... -> empty frame (for layout) <<end>>
02267 
02268   // ... "Trihedron" group <<start>>
02269   int vtkTriGroup = pref->addPreference( tr( "PREF_TRIHEDRON" ), vtkGroup );
02270   pref->setItemProperty( "columns", 2, vtkTriGroup );
02271   // .... -> trihedron size
02272   int vtkTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), vtkTriGroup,
02273                                    LightApp_Preferences::DblSpin, "VTKViewer", "trihedron_size" );
02274   pref->setItemProperty( "min", 1.0E-06, vtkTS );
02275   pref->setItemProperty( "max", 150, vtkTS );
02276   // .... -> relative size of trihedron
02277   pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), vtkTriGroup, LightApp_Preferences::Bool, "VTKViewer", "relative_size" );
02278   // .... -> static trihedron
02279   pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), vtkTriGroup, LightApp_Preferences::Bool, "VTKViewer", "show_static_trihedron" );
02280   // ... "Trihedron" group <<end>>
02281 
02282   // ... space mouse sub-group <<start>>
02283   int vtkSM = pref->addPreference( tr( "PREF_FRAME_SPACEMOUSE" ), vtkGroup, LightApp_Preferences::GroupBox );
02284   //pref->setItemProperty( "columns", 2, vtkSM );
02285   // .... -> decrease speed increment
02286   int spacemousePref1 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_1" ), vtkSM,
02287                                              LightApp_Preferences::Selector, "VTKViewer",
02288                                              "spacemouse_func1_btn" );
02289   // .... -> increase speed increment
02290   int spacemousePref2 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_2" ), vtkSM,
02291                                              LightApp_Preferences::Selector, "VTKViewer",
02292                                              "spacemouse_func2_btn" );
02293   // .... -> dominant / combined switch  
02294   int spacemousePref3 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_3" ), vtkSM,
02295                                              LightApp_Preferences::Selector, "VTKViewer",
02296                                              "spacemouse_func5_btn" ); //
02297   aValuesList.clear();
02298   anIndicesList.clear();
02299   aValuesList << tr( "PREF_SPACEMOUSE_BTN_1" )  << tr( "PREF_SPACEMOUSE_BTN_2" ) << tr( "PREF_SPACEMOUSE_BTN_3" );
02300   aValuesList << tr( "PREF_SPACEMOUSE_BTN_4" )  << tr( "PREF_SPACEMOUSE_BTN_5" ) << tr( "PREF_SPACEMOUSE_BTN_6" );
02301   aValuesList << tr( "PREF_SPACEMOUSE_BTN_7" )  << tr( "PREF_SPACEMOUSE_BTN_8" ) << tr( "PREF_SPACEMOUSE_BTN_*" );
02302   aValuesList << tr( "PREF_SPACEMOUSE_BTN_10" ) << tr( "PREF_SPACEMOUSE_BTN_11" );
02303   anIndicesList << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11;
02304   pref->setItemProperty( "strings", aValuesList,   spacemousePref1 );
02305   pref->setItemProperty( "indexes", anIndicesList, spacemousePref1 );
02306   pref->setItemProperty( "strings", aValuesList,   spacemousePref2 );
02307   pref->setItemProperty( "indexes", anIndicesList, spacemousePref2 );
02308   pref->setItemProperty( "strings", aValuesList,   spacemousePref3 );
02309   pref->setItemProperty( "indexes", anIndicesList, spacemousePref3 );
02310   // ... space mouse sub-group <<end>>
02311 
02312   // ... avi recording sub-group <<start>>
02313   int vtkRec = pref->addPreference( tr( "PREF_FRAME_RECORDING" ), vtkGroup, LightApp_Preferences::GroupBox );
02314   pref->setItemProperty( "columns", 2, vtkRec );
02315   // .... -> recording mode
02316   int modePref = pref->addPreference( tr( "PREF_RECORDING_MODE" ), vtkRec,
02317                                       LightApp_Preferences::Selector, "VTKViewer", "recorder_mode" );
02318   aValuesList.clear();
02319   anIndicesList.clear();
02320   aValuesList   << tr( "PREF_SKIPPED_FRAMES" ) << tr( "PREF_ALL_DISLPAYED_FRAMES" );
02321   anIndicesList << 0                           << 1;
02322   pref->setItemProperty( "strings", aValuesList,   modePref );
02323   pref->setItemProperty( "indexes", anIndicesList, modePref );
02324   // .... -> fps
02325   int fpsPref = pref->addPreference( tr( "PREF_FPS" ), vtkRec,
02326                                      LightApp_Preferences::DblSpin, "VTKViewer", "recorder_fps" );
02327   pref->setItemProperty( "min", 0.1, fpsPref );
02328   pref->setItemProperty( "max", 100, fpsPref );
02329   // .... -> quality
02330   int qualityPref = pref->addPreference( tr( "PREF_QUALITY" ), vtkRec,
02331                                          LightApp_Preferences::IntSpin, "VTKViewer", "recorder_quality" );
02332   pref->setItemProperty( "min", 1, qualityPref );
02333   pref->setItemProperty( "max", 100, qualityPref );
02334   // .... -> progressive mode
02335   pref->addPreference( tr( "PREF_PROGRESSIVE" ), vtkRec,
02336                        LightApp_Preferences::Bool, "VTKViewer", "recorder_progressive" );
02337   // ... avi recording sub-group <<end>>
02338 
02339   // ... group names sub-group <<start>>
02340   int vtkGN = pref->addPreference( tr( "PREF_FRAME_GROUP_NAMES" ), vtkGroup,
02341                                    LightApp_Preferences::GroupBox, "VTKViewer", "show_group_names" );
02342   pref->setItemProperty( "columns", 2, vtkGN );
02343   // .... -> text color
02344   pref->addPreference( tr(  "PREF_GROUP_NAMES_TEXT_COLOR" ), vtkGN,
02345                        LightApp_Preferences::Color, "VTKViewer", "group_names_text_color" );
02346   // .... -> transparency
02347   int transPref = pref->addPreference( tr( "PREF_GROUP_NAMES_TRANSPARENCY" ), vtkGN,
02348                                        LightApp_Preferences::DblSpin, "VTKViewer", "group_names_transparency" );
02349   pref->setItemProperty( "min", 0.0, transPref );
02350   pref->setItemProperty( "max", 1.0, transPref );
02351   pref->setItemProperty( "step", 0.1, transPref );
02352   // ... -> group names sub-group <<end>>
02353   // .. "VTK viewer" group <<end>>
02354 
02355   // .. "Plot2d viewer" group <<start>>
02356   int plot2dGroup = pref->addPreference( tr( "PREF_GROUP_PLOT2DVIEWER" ), salomeCat ); //viewTab
02357   //pref->setItemProperty( "columns", 2, plot2dGroup );
02358 
02359   // ... -> show legend
02360   pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dGroup,
02361                        LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
02362   // ... -> legend position
02363   int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dGroup,
02364                                             LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
02365   aValuesList.clear();
02366   anIndicesList.clear();
02367   aValuesList   << tr("PREF_LEFT") << tr("PREF_RIGHT") << tr("PREF_TOP") << tr("PREF_BOTTOM");
02368   anIndicesList << 0               << 1                << 2              << 3                ;
02369   pref->setItemProperty( "strings", aValuesList,   legendPosition );
02370   pref->setItemProperty( "indexes", anIndicesList, legendPosition );
02371   // ... -> legend font
02372   pref->addPreference( tr( "PREF_LEGEND_FONT" ), plot2dGroup, LightApp_Preferences::Font, "Plot2d", "LegendFont" );
02373   // ... -> curve type
02374   int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dGroup,
02375                                        LightApp_Preferences::Selector, "Plot2d", "CurveType" );
02376   aValuesList.clear();
02377   anIndicesList.clear();
02378   aValuesList   << tr("PREF_POINTS") << tr("PREF_LINES") << tr("PREF_SPLINE");
02379   anIndicesList << 0                 << 1                << 2                ;
02380   pref->setItemProperty( "strings", aValuesList,   curveType );
02381   pref->setItemProperty( "indexes", anIndicesList, curveType );
02382   // ... -> marker size
02383   int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dGroup,
02384                                         LightApp_Preferences::IntSpin, "Plot2d", "MarkerSize" );
02385   pref->setItemProperty( "min", 0, markerSize );
02386   pref->setItemProperty( "max", 100, markerSize );
02387   // ... -> horizontal scaling mode
02388   int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dGroup,
02389                                       LightApp_Preferences::Selector, "Plot2d", "HorScaleMode" );
02390   aValuesList.clear();
02391   anIndicesList.clear();
02392   aValuesList   << tr("PREF_LINEAR") << tr("PREF_LOGARITHMIC");
02393   anIndicesList << 0                 << 1                     ;
02394   pref->setItemProperty( "strings", aValuesList,   horScale );
02395   pref->setItemProperty( "indexes", anIndicesList, horScale );
02396   // ... -> vertical scaling mode
02397   int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dGroup,
02398                                       LightApp_Preferences::Selector, "Plot2d", "VerScaleMode" );
02399   pref->setItemProperty( "strings", aValuesList,   verScale );
02400   pref->setItemProperty( "indexes", anIndicesList, verScale );
02401   // ... -> background
02402   pref->addPreference( tr( "PREF_VIEWER_BACKGROUND_COLOR" ), plot2dGroup,
02403                        LightApp_Preferences::Color, "Plot2d", "Background" );
02404   // ... -> font color
02405   pref->addPreference( tr( "PREF_FONT_COLOR" ), plot2dGroup, LightApp_Preferences::Color, "Plot2d", "LegendFontColor" );
02406   // ... -> selection font color
02407   pref->addPreference( tr( "PREF_SELECTED_FONT_COLOR" ), plot2dGroup, LightApp_Preferences::Color, "Plot2d", "SelectedLegendFontColor" );
02408   // ... -> selection color
02409   pref->addPreference( tr( "PREF_VIEWER_SELECTION" ), plot2dGroup,
02410                        LightApp_Preferences::Color, "Plot2d", "SelectionColor" );
02411   // ... -> errors/deviation colot
02412   pref->addPreference( tr( "PREF_DEVIATION_COLOR" ), plot2dGroup,
02413                        LightApp_Preferences::Color, "Plot2d", "DeviationMarkerColor" );
02414   // ... -> deviation markers line size
02415   int deviationMarkerLw = pref->addPreference( tr( "PREF_DEVIATION_MARKER_LW" ), plot2dGroup,
02416                                         LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerLineWidth" );
02417   pref->setItemProperty( "min", 1, deviationMarkerLw );
02418   pref->setItemProperty( "max", 5, deviationMarkerLw );
02419   // ... -> deviation markers tick mark size
02420   int deviationMarkerTs = pref->addPreference( tr( "PREF_DEVIATION_MARKER_TS" ), plot2dGroup,
02421                                         LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerTickSize" );
02422   pref->setItemProperty( "min", 1, deviationMarkerTs );
02423   pref->setItemProperty( "max", 5, deviationMarkerTs );
02424   // .. "Plot2d viewer" group <<end>>
02425 
02426   // .. "Directories" preferences tab <<start>>
02427   int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat );
02428   // ... --> quick directories list
02429   int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab );
02430   pref->addPreference( tr( "" ), dirGroup,
02431                        LightApp_Preferences::DirList, "FileDlg", "QuickDirList" );
02432   // .. "Directories" preferences tab <<end>>
02433 
02434   // .. "Object browser" preferences tab <<start>>
02435   int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
02436 
02437   // ... "Search tool" group <<start>>
02438   int stGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SEARCH_TOOL" ), obTab );
02439   // .... --> auto-hide
02440   pref->addPreference( tr( "PREF_AUTO_HIDE_SEARCH_TOOL" ), stGroup, LightApp_Preferences::Bool,
02441                        "ObjectBrowser", "auto_hide_search_tool" );
02442   // ... "Search tool" group <<end>>
02443 
02444   // ... "Object browser settings" group <<start>>
02445   int objSetGroup = pref->addPreference( tr( "PREF_GROUP_LOOK_AND_FEEL" ), obTab );
02446   pref->setItemProperty( "columns", 2, objSetGroup );
02447   // .... -> auto size first column
02448   pref->addPreference( tr( "PREF_AUTO_SIZE_FIRST" ), objSetGroup, LightApp_Preferences::Bool,
02449                        "ObjectBrowser", "auto_size_first" );
02450   // .... -> auto size other columns
02451   pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool,
02452                        "ObjectBrowser", "auto_size" );
02453   // .... -> resize columns on expand item
02454   pref->addPreference( tr( "PREF_RESIZE_ON_EXPAND_ITEM" ), objSetGroup, LightApp_Preferences::Bool,
02455                        "ObjectBrowser", "resize_on_expand_item" );
02456   // .... -> browse to published object
02457   int browsePublished = pref->addPreference( tr( "PREF_BROWSE_TO_THE_PUBLISHED_OBJECT" ), objSetGroup, LightApp_Preferences::Selector,
02458                                              "ObjectBrowser", "browse_published_object" );
02459   aValuesList.clear();
02460   anIndicesList.clear();
02461   aValuesList << tr( "PREF_BROWSE_NEVER" ) << tr( "PREF_BROWSE_AFTER_APPLY_AND_CLOSE_ONLY" ) << tr( "PREF_BROWSE_ALWAYS" );
02462   anIndicesList << BP_Never << BP_ApplyAndClose << BP_Always;
02463   pref->setItemProperty( "strings", aValuesList,   browsePublished );
02464   pref->setItemProperty( "indexes", anIndicesList, browsePublished );
02465   // ... "Object browser settings" group <<end>>
02466   // .. "Object browser" preferences tab <<end>>
02467 
02468   // .. "Shortcuts" preferences tab <<start>>
02469   int shortcutTab = pref->addPreference( tr( "PREF_TAB_SHORTCUTS" ), salomeCat );
02470   // ... "Shortcuts settings" group <<start>>
02471   int shortcutGroup = pref->addPreference( tr( "PREF_GROUP_SHORTCUTS" ), shortcutTab );
02472   pref->addPreference( tr( "" ), shortcutGroup,
02473                        LightApp_Preferences::ShortcutTree, "shortcuts" );
02474   // ... "Shortcuts settings" group <<end>>
02475   // .. "Shortcuts" preferences tab <<end>>
02476   // . Top-level "SALOME" preferences group <<end>>
02477 
02478   pref->retrieve();
02479 }
02480 
02486 void LightApp_Application::preferencesChanged( const QString& sec, const QString& param )
02487 {
02488   SUIT_ResourceMgr* resMgr = resourceMgr();
02489   if ( !resMgr )
02490     return;
02491 
02492   if ( sec == "viewers" && param == "drop_down_buttons" )
02493   {
02494     ViewManagerList vmlist = viewManagers();
02495     foreach( SUIT_ViewManager* vm, vmlist )
02496     {
02497       QVector<SUIT_ViewWindow*> vwlist = vm->getViews();
02498       foreach( SUIT_ViewWindow* vw, vwlist )
02499         if ( vw ) vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) );
02500     }
02501   }
02502 
02503 #ifndef DISABLE_OCCVIEWER
02504   if ( sec == QString( "OCCViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )))
02505   {
02506     double sz = resMgr->doubleValue( sec, "trihedron_size", -1 );
02507     bool relative = resMgr->booleanValue( sec, "relative_size", true );
02508     QList<SUIT_ViewManager*> lst;
02509     viewManagers( OCCViewer_Viewer::Type(), lst );
02510     QListIterator<SUIT_ViewManager*> it( lst );
02511     while ( it.hasNext() && sz >= 0 )
02512     {
02513       SUIT_ViewModel* vm = it.next()->getViewModel();
02514       if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
02515         continue;
02516 
02517       OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
02518       occVM->setTrihedronSize( sz, relative );
02519       occVM->getAISContext()->UpdateCurrentViewer();
02520     }
02521   }
02522 #endif
02523 
02524 #ifndef DISABLE_OCCVIEWER
02525   if ( sec == QString( "OCCViewer" ) && param == QString( "show_static_trihedron" ) )
02526   {
02527     bool isVisible = resMgr->booleanValue( "OCCViewer", "show_static_trihedron", true );
02528     QList<SUIT_ViewManager*> lst;
02529     viewManagers( OCCViewer_Viewer::Type(), lst );
02530     QListIterator<SUIT_ViewManager*> it( lst );
02531     while ( it.hasNext() )
02532     {
02533       SUIT_ViewModel* vm = it.next()->getViewModel();
02534       if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
02535         continue;
02536 
02537       OCCViewer_Viewer* occVM = dynamic_cast<OCCViewer_Viewer*>( vm );
02538       if( occVM )
02539       {
02540         occVM->setStaticTrihedronDisplayed( isVisible );
02541       }
02542     }
02543   }
02544 #endif
02545 
02546 #ifndef DISABLE_OCCVIEWER
02547   if ( sec == QString( "OCCViewer" ) && param == QString( "navigation_mode" ) )
02548   {
02549     int mode = resMgr->integerValue( "OCCViewer", "navigation_mode", 0 );
02550     QList<SUIT_ViewManager*> lst;
02551     viewManagers( OCCViewer_Viewer::Type(), lst );
02552     QListIterator<SUIT_ViewManager*> it( lst );
02553     while ( it.hasNext() )
02554     {
02555       SUIT_ViewModel* vm = it.next()->getViewModel();
02556       if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
02557         continue;
02558 
02559       OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
02560       occVM->setInteractionStyle( mode );
02561     }
02562   }
02563 #endif
02564 
02565 #ifndef DISABLE_OCCVIEWER
02566   if ( sec == QString( "OCCViewer" ) && param == QString( "zooming_mode" ) )
02567   {
02568     int mode = resMgr->integerValue( "OCCViewer", "zooming_mode", 0 );
02569     QList<SUIT_ViewManager*> lst;
02570     viewManagers( OCCViewer_Viewer::Type(), lst );
02571     QListIterator<SUIT_ViewManager*> it( lst );
02572     while ( it.hasNext() )
02573     {
02574       SUIT_ViewModel* vm = it.next()->getViewModel();
02575       if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
02576         continue;
02577 
02578       OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
02579       occVM->setZoomingStyle( mode );
02580     }
02581   }
02582 #endif
02583 
02584 #ifndef DISABLE_VTKVIEWER
02585   if ( sec == QString( "VTKViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )) )
02586   {
02587     double sz = resMgr->doubleValue( "VTKViewer", "trihedron_size", -1 );
02588     bool isRelative = resMgr->booleanValue( "VTKViewer", "relative_size", true );
02589     QList<SUIT_ViewManager*> lst;
02590 #ifndef DISABLE_SALOMEOBJECT
02591     viewManagers( SVTK_Viewer::Type(), lst );
02592     QListIterator<SUIT_ViewManager*> it( lst );
02593     while ( it.hasNext() && sz >= 0 )
02594     {
02595       SUIT_ViewModel* vm = it.next()->getViewModel();
02596       if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
02597         continue;
02598 
02599       SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
02600       if( vtkVM )
02601       {
02602         vtkVM->setTrihedronSize( sz, isRelative );
02603         vtkVM->Repaint();
02604       }
02605     }
02606 #endif
02607   }
02608 #endif
02609 
02610 #ifndef DISABLE_VTKVIEWER
02611   if ( sec == QString( "VTKViewer" ) && (param == QString( "speed_value" ) || param == QString( "speed_mode" )) )
02612   {
02613     int speed = resMgr->integerValue( "VTKViewer", "speed_value", 10 );
02614     int mode = resMgr->integerValue( "VTKViewer", "speed_mode", 0 );
02615     QList<SUIT_ViewManager*> lst;
02616 #ifndef DISABLE_SALOMEOBJECT
02617     viewManagers( SVTK_Viewer::Type(), lst );
02618     QListIterator<SUIT_ViewManager*> it( lst );
02619     while ( it.hasNext() )
02620     {
02621       SUIT_ViewModel* vm = it.next()->getViewModel();
02622       if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
02623         continue;
02624 
02625       SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
02626       if( vtkVM ) vtkVM->setIncrementalSpeed( speed, mode );
02627     }
02628 #endif
02629   }
02630 #endif
02631 
02632 #ifndef DISABLE_VTKVIEWER
02633   if ( sec == QString( "VTKViewer" ) && param == QString( "projection_mode" ) )
02634   {
02635     int mode = resMgr->integerValue( "VTKViewer", "projection_mode", 0 );
02636     QList<SUIT_ViewManager*> lst;
02637 #ifndef DISABLE_SALOMEOBJECT
02638     viewManagers( SVTK_Viewer::Type(), lst );
02639     QListIterator<SUIT_ViewManager*> it( lst );
02640     while ( it.hasNext() )
02641     {
02642       SUIT_ViewModel* vm = it.next()->getViewModel();
02643       if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
02644         continue;
02645 
02646       SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
02647       if( vtkVM ) vtkVM->setProjectionMode( mode );
02648     }
02649 #endif
02650   }
02651 #endif
02652 
02653 #ifndef DISABLE_VTKVIEWER
02654   if ( sec == QString( "VTKViewer" ) && param == QString( "navigation_mode" ) )
02655   {
02656     int mode = resMgr->integerValue( "VTKViewer", "navigation_mode", 0 );
02657     QList<SUIT_ViewManager*> lst;
02658 #ifndef DISABLE_SALOMEOBJECT
02659     viewManagers( SVTK_Viewer::Type(), lst );
02660     QListIterator<SUIT_ViewManager*> it( lst );
02661     while ( it.hasNext() )
02662     {
02663       SUIT_ViewModel* vm = it.next()->getViewModel();
02664       if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
02665         continue;
02666 
02667       SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
02668       if( vtkVM ) vtkVM->setInteractionStyle( mode );
02669     }
02670 #endif
02671   }
02672 #endif
02673 
02674 #ifndef DISABLE_VTKVIEWER
02675   if ( sec == QString( "VTKViewer" ) && param == QString( "zooming_mode" ) )
02676   {
02677     int mode = resMgr->integerValue( "VTKViewer", "zooming_mode", 0 );
02678     QList<SUIT_ViewManager*> lst;
02679 #ifndef DISABLE_SALOMEOBJECT
02680     viewManagers( SVTK_Viewer::Type(), lst );
02681     QListIterator<SUIT_ViewManager*> it( lst );
02682     while ( it.hasNext() )
02683     {
02684       SUIT_ViewModel* vm = it.next()->getViewModel();
02685       if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
02686         continue;
02687 
02688       SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
02689       if( vtkVM ) vtkVM->setZoomingStyle( mode );
02690     }
02691 #endif
02692   }
02693 #endif
02694 
02695 #ifndef DISABLE_VTKVIEWER
02696   if ( sec == QString( "VTKViewer" ) && param == QString( "dynamic_preselection" ) )
02697   {
02698     bool mode = resMgr->booleanValue( "VTKViewer", "dynamic_preselection", true );
02699     QList<SUIT_ViewManager*> lst;
02700 #ifndef DISABLE_SALOMEOBJECT
02701     viewManagers( SVTK_Viewer::Type(), lst );
02702     QListIterator<SUIT_ViewManager*> it( lst );
02703     while ( it.hasNext() )
02704     {
02705       SUIT_ViewModel* vm = it.next()->getViewModel();
02706       if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
02707         continue;
02708 
02709       SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
02710       if( vtkVM ) vtkVM->setDynamicPreSelection( mode );
02711     }
02712 #endif
02713   }
02714 #endif
02715 
02716 #ifndef DISABLE_VTKVIEWER
02717   if ( sec == QString( "VTKViewer" ) && param == QString( "show_static_trihedron" ) )
02718   {
02719     bool isVisible = resMgr->booleanValue( "VTKViewer", "show_static_trihedron", true );
02720     QList<SUIT_ViewManager*> lst;
02721 #ifndef DISABLE_SALOMEOBJECT
02722     viewManagers( SVTK_Viewer::Type(), lst );
02723     QListIterator<SUIT_ViewManager*> it( lst );
02724     while ( it.hasNext() )
02725     {
02726       SUIT_ViewModel* vm = it.next()->getViewModel();
02727       if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
02728         continue;
02729 
02730       SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
02731       if( vtkVM )
02732       {
02733         vtkVM->setStaticTrihedronVisible( isVisible );
02734         vtkVM->Repaint();
02735       }
02736     }
02737 #endif
02738   }
02739 #endif
02740 
02741 #ifndef DISABLE_VTKVIEWER
02742   if ( sec == QString( "VTKViewer" ) && (param == QString( "spacemouse_func1_btn" ) ||
02743                                          param == QString( "spacemouse_func2_btn" ) ||
02744                                          param == QString( "spacemouse_func5_btn" ) ) )
02745   {
02746     int btn1 = resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", 1 );
02747     int btn2 = resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", 2 );
02748     int btn3 = resMgr->integerValue( "VTKViewer", "spacemouse_func5_btn", 9 );
02749     QList<SUIT_ViewManager*> lst;
02750 #ifndef DISABLE_SALOMEOBJECT
02751     viewManagers( SVTK_Viewer::Type(), lst );
02752     QListIterator<SUIT_ViewManager*> it( lst );
02753     while ( it.hasNext() )
02754     {
02755       SUIT_ViewModel* vm = it.next()->getViewModel();
02756       if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
02757         continue;
02758 
02759       SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
02760       if( vtkVM ) vtkVM->setSpacemouseButtons( btn1, btn2, btn3 );
02761     }
02762 #endif
02763   }
02764 #endif
02765 
02766 #ifndef DISABLE_OCCVIEWER
02767   if ( sec == QString( "OCCViewer" ) && ( param == QString( "iso_number_u" ) || param == QString( "iso_number_v" ) ) )
02768   {
02769     QList<SUIT_ViewManager*> lst;
02770     viewManagers( OCCViewer_Viewer::Type(), lst );
02771     int u = resMgr->integerValue( sec, "iso_number_u" );
02772     int v = resMgr->integerValue( sec, "iso_number_v" );
02773     QListIterator<SUIT_ViewManager*> it( lst );
02774     while ( it.hasNext() )
02775     {
02776       OCCViewer_ViewManager* mgr = dynamic_cast<OCCViewer_ViewManager*>( it.next() );
02777       if( mgr && mgr->getOCCViewer() )
02778         mgr->getOCCViewer()->setIsos( u, v );
02779     }
02780   }
02781 #endif
02782 
02783   if( sec=="ObjectBrowser" )
02784   {
02785     SUIT_DataBrowser* ob = objectBrowser();
02786     if ( !ob )
02787       return;
02788 
02789     if ( param=="auto_size_first" )
02790     {
02791       bool autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
02792       ob->setAutoSizeFirstColumn( autoSizeFirst );
02793       if ( autoSizeFirst )
02794         ob->adjustFirstColumnWidth();
02795     }
02796     else if ( param=="auto_size" ) {
02797       bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
02798       ob->setAutoSizeColumns(autoSize);
02799       if ( autoSize )
02800         ob->adjustColumnsWidth();
02801     }
02802     else if ( param=="resize_on_expand_item" ) {
02803       bool resizeOnExpandItem = resMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
02804       ob->setResizeOnExpandItem(resizeOnExpandItem);
02805     }
02806     else if ( param == "auto_hide_search_tool" ) {
02807       ob->searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
02808     }
02809   }
02810 
02811   if( sec=="Study" )
02812   {
02813     if( param=="store_positions" )
02814       updateWindows();
02815     if( param=="auto_save_interval" ) {
02816       myAutoSaveTimer->stop();
02817       int autoSaveInterval = resMgr->integerValue( "Study", "auto_save_interval", 0 );
02818       if ( activeStudy() && autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
02819     }
02820   }
02821 
02822 #ifndef DISABLE_PYCONSOLE
02823   if( sec=="PyConsole" && pythonConsole() )
02824   {
02825     if ( param=="font" ) {
02826       pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) );
02827     }
02828     else if ( param=="show_banner" ) {
02829       pythonConsole()->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) );
02830     }
02831   }
02832 #endif
02833 
02834   if( sec=="MRU" )
02835   {
02836     QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
02837     if ( mru ) {
02838       if ( param == "visible_count" )
02839         mru->setVisibleCount( resMgr->integerValue( "MRU", "visible_count", 5 ) );    // 5 MRU items by default
02840       else if ( param == "max_count" )
02841         mru->setHistoryCount( resMgr->integerValue( "MRU", "max_count", -1 ) );       // unlimited history by default
02842       else if ( param == "insert_mode" )
02843         mru->setInsertMode( resMgr->integerValue( "MRU", "insert_mode", 0 ) );        // QtxMRUAction::MoveFirst by default
02844       else if ( param == "link_type" )
02845         mru->setLinkType( resMgr->integerValue( "MRU", "link_type", 0 ) );            // QtxMRUAction::LinkAuto by default
02846       else if ( param == "show_clear" )
02847         mru->setClearPossible( resMgr->booleanValue( "MRU", "show_clear", false ) );  // do not show "Clear" item by default
02848       else if ( param == "show_mru" )
02849         mru->setVisible( resMgr->booleanValue( "MRU", "show_mru", false ) );          // do not show MRU menu item by default
02850     }
02851   }
02852   if ( sec == "language" && param == "language" )
02853   {
02854     SUIT_MessageBox::information( desktop(), tr( "WRN_WARNING" ), tr( "LANG_CHANGED" ) );
02855   }
02856   if ( sec == "desktop" && param == "opaque_resize" ) {
02857     bool opaqueResize = resMgr->booleanValue( "desktop", "opaque_resize", false );
02858     QMainWindow::DockOptions dopts = desktop()->dockOptions();
02859     if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
02860     else                dopts &= ~QMainWindow::AnimatedDocks;
02861     desktop()->setDockOptions( dopts );
02862     desktop()->setOpaqueResize( opaqueResize );
02863     if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
02864       dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
02865   }
02866 
02867   if ( sec == "ExternalBrowser" && param == "use_external_browser" ) {
02868     if ( resMgr->booleanValue("ExternalBrowser", "use_external_browser", false ) )
02869       {
02870         if(QtxWebBrowser::webBrowser())
02871           QtxWebBrowser::webBrowser()->close();
02872       }
02873   }
02874 
02875 #ifndef DISABLE_PLOT2DVIEWER
02876   if ( sec == "Plot2d" ) {
02877     if( param == "SelectionColor" ) {
02878       QColor c = resMgr->colorValue( sec, param );
02879       Plot2d_Object::setSelectionColor(c);
02880     }
02881     else if (param == "SelectedLegendFontColor") {
02882       QColor c = resMgr->colorValue( sec, param );      
02883       Plot2d_Object::setHighlightedLegendTextColor(c);
02884     }
02885   }
02886 #endif
02887 }
02888 
02892 void LightApp_Application::loadPreferences()
02893 {
02894   CAM_Application::loadPreferences();
02895 
02896   SUIT_ResourceMgr* aResMgr = resourceMgr();
02897 
02898   if ( !aResMgr )
02899     return;
02900 
02901   static bool mru_load = true;
02902   if ( mru_load )
02903   {
02904     QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
02905     if ( mru ) {
02906       mru->setVisible( aResMgr->booleanValue( "MRU", "show_mru", false ) );         // do not show MRU menu item by default
02907       mru->setVisibleCount( aResMgr->integerValue( "MRU", "visible_count", 5 ) );   // 5 MRU items by default
02908       mru->setHistoryCount( aResMgr->integerValue( "MRU", "max_count", -1 ) );      // unlimited history by default
02909       mru->setInsertMode( aResMgr->integerValue( "MRU", "insert_mode", 0 ) );       // QtxMRUAction::MoveFirst by default
02910       mru->setLinkType( aResMgr->integerValue( "MRU", "link_type", 0 ) );           // QtxMRUAction::LinkAuto by default
02911       mru->setClearPossible( aResMgr->booleanValue( "MRU", "show_clear", false ) ); // do not show "Clear" item by default
02912       mru->loadLinks( aResMgr, "MRU" );
02913     }
02914     mru_load = false;
02915   }
02916 
02917   myWinGeom.clear();
02918   QStringList mods = aResMgr->parameters( "windows_geometry" );
02919   for ( QStringList::const_iterator it = mods.begin(); it != mods.end(); ++it )
02920   {
02921     QByteArray arr;
02922     if ( aResMgr->value( "windows_geometry", *it, arr ) )
02923       myWinGeom.insert( *it, arr );
02924   }
02925 
02926   myWinVis.clear();
02927   mods = aResMgr->parameters( "windows_visibility" );
02928   for ( QStringList::const_iterator itr = mods.begin(); itr != mods.end(); ++itr )
02929   {
02930     QByteArray arr;
02931     if ( aResMgr->value( "windows_visibility", *itr, arr ) )
02932       myWinVis.insert( *itr, arr );
02933   }
02934 
02935   if ( desktop() ) {
02936     desktop()->retrieveGeometry( aResMgr->stringValue( "desktop", "geometry" ) );
02937     bool opaqueResize = aResMgr->booleanValue( "desktop", "opaque_resize", false );
02938     QMainWindow::DockOptions dopts = desktop()->dockOptions();
02939     if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
02940     else                dopts &= ~QMainWindow::AnimatedDocks;
02941     desktop()->setDockOptions( dopts );
02942     desktop()->setOpaqueResize( opaqueResize );
02943     if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
02944       dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
02945   }
02946 }
02947 
02951 void LightApp_Application::savePreferences()
02952 {
02953   CAM_Application::savePreferences();
02954 
02955   saveDockWindowsState();
02956 
02957   SUIT_ResourceMgr* aResMgr = resourceMgr();
02958 
02959   if ( !aResMgr )
02960     return;
02961 
02962   QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
02963   if ( mru )
02964     mru->saveLinks( aResMgr, "MRU" );
02965 
02966   for ( WinGeom::const_iterator it = myWinGeom.begin(); it != myWinGeom.end(); ++it )
02967     aResMgr->setValue( "windows_geometry", it.key(), it.value() );
02968 
02969   for ( WinVis::const_iterator itr = myWinVis.begin(); itr != myWinVis.end(); ++itr )
02970     aResMgr->setValue( "windows_visibility", itr.key(), itr.value() );
02971 
02972   if ( desktop() )
02973     aResMgr->setValue( "desktop", "geometry", desktop()->storeGeometry() );
02974 
02975   aResMgr->save();
02976 }
02977 
02981 void LightApp_Application::updateDesktopTitle()
02982 {
02983   QString aTitle = applicationName();
02984   QString aVer = applicationVersion();
02985   if ( !aVer.isEmpty() )
02986     aTitle += QString( " " ) + aVer;
02987 
02988   if ( activeStudy() ) {
02989     QString sName = SUIT_Tools::file( activeStudy()->studyName().trimmed(), false );
02990     aTitle += QString( " - [%1]" ).arg( sName );
02991   }
02992 
02993   desktop()->setWindowTitle( aTitle );
02994 }
02995 
03011 QMap<int, QString> LightApp_Application::activateModuleActions() const
03012 {
03013   QMap<int, QString> opmap;
03014   opmap.insert( NewStudyId,  tr( "ACTIVATE_MODULE_OP_NEW" ) );
03015   opmap.insert( OpenStudyId, tr( "ACTIVATE_MODULE_OP_OPEN" ) );
03016   return opmap;
03017 }
03018 
03028 void LightApp_Application::moduleActionSelected( const int id )
03029 {
03030   switch ( id ) {
03031   case NewStudyId:
03032     onNewDoc();
03033     break;
03034   case OpenStudyId:
03035     onOpenDoc();
03036     break;
03037   default:
03038     break;
03039   }
03040 }
03041 
03045 void LightApp_Application::afterCloseDoc()
03046 {
03047   updateWindows();
03048 
03049   CAM_Application::afterCloseDoc();
03050 }
03051 
03055 void LightApp_Application::updateModuleActions()
03056 {
03057   QString modName;
03058   if ( activeModule() ) {
03059     modName = activeModule()->moduleName();
03060     if ( !isModuleAccessible( modName ) ) {
03061       QList<SUIT_Application*> apps = SUIT_Session::session()->applications();
03062       foreach( SUIT_Application* app, apps ) {
03063         LightApp_Application* lapp = dynamic_cast<LightApp_Application*>( app );
03064         if ( lapp && lapp != this )
03065           lapp->removeModuleAction( modName );
03066       }
03067     }
03068   }
03069 
03070   LightApp_ModuleAction* moduleAction =
03071     qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
03072   if ( moduleAction )
03073     moduleAction->setActiveModule( modName );
03074 }
03075 
03076 void LightApp_Application::removeModuleAction( const QString& modName )
03077 {
03078   LightApp_ModuleAction* moduleAction =
03079     qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
03080   if ( moduleAction )
03081     moduleAction->removeModule( modName );
03082 }
03083 
03088 void LightApp_Application::currentWindows( QMap<int, int>& winMap ) const
03089 {
03090   winMap.clear();
03091   if ( !activeStudy() )
03092     return;
03093 
03094   if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
03095     ((LightApp_Module*)activeModule())->windows( winMap );
03096   else
03097     defaultWindows( winMap );
03098 }
03099 
03104 void LightApp_Application::currentViewManagers( QStringList& lst ) const
03105 {
03106   lst.clear();
03107   if ( !activeStudy() )
03108     return;
03109 
03110   if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
03111     ((LightApp_Module*)activeModule())->viewManagers( lst );
03112   else
03113     defaultViewManagers( lst );
03114 }
03115 
03119 void LightApp_Application::updateWindows()
03120 {
03121   QMap<int, int> winMap;
03122   currentWindows( winMap );
03123 
03124   if ( activeStudy() )
03125   {
03126     for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
03127     {
03128       if ( !dockWindow( it.key() ) )
03129         getWindow( it.key() );
03130     }
03131   }
03132 
03133   for ( WinMap::ConstIterator it = myWin.begin(); it != myWin.end(); ++it )
03134   {
03135     QWidget* wid = it.value();
03136     if ( activeStudy() )
03137       wid->setVisible( winMap.contains( it.key() ) );
03138     else
03139       delete wid;
03140   }
03141 
03142   if ( activeStudy() )
03143     loadDockWindowsState();
03144   else
03145     myWin.clear();
03146 }
03147 
03151 void LightApp_Application::updateViewManagers()
03152 {
03153   QStringList lst;
03154   currentViewManagers( lst );
03155 
03156   for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
03157     getViewManager( *it, true );
03158 }
03159 
03163 void LightApp_Application::loadDockWindowsState()
03164 {
03165   if ( !desktop() )
03166     return;
03167 
03168   bool store = resourceMgr()->booleanValue( "Study", "store_positions", true );
03169   if( !store )
03170     return;
03171 
03172   QString modName;
03173   if ( activeModule() )
03174     modName = activeModule()->name();
03175 
03176   if ( myWinGeom.contains( modName ) )
03177     desktop()->restoreState( myWinGeom[modName] );
03178 
03179   if ( !myWinVis.contains( modName ) )
03180     return;
03181 
03182   QMap<QString, bool> tbMap, dwMap;
03183   dockWindowsState( myWinVis[modName], tbMap, dwMap );
03184 
03185   QList<QToolBar*> tbList = qFindChildren<QToolBar*>( desktop() );
03186   for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit )
03187   {
03188     QToolBar* tb = *tit;
03189 
03190     QObject* po = Qtx::findParent( tb, "QMainWindow" );
03191     if ( po != desktop() )
03192       continue;
03193 
03194     if ( tbMap.contains( tb->objectName() ) )
03195       tb->setVisible( tbMap[tb->objectName()] );
03196   }
03197 
03198   QList<QDockWidget*> dwList = qFindChildren<QDockWidget*>( desktop() );
03199   for ( QList<QDockWidget*>::iterator dit = dwList.begin(); dit != dwList.end(); ++dit )
03200   {
03201     QDockWidget* dw = *dit;
03202 
03203     QObject* po = Qtx::findParent( dw, "QMainWindow" );
03204     if ( po != desktop() )
03205       continue;
03206 
03207     if ( dwMap.contains( dw->objectName() ) )
03208       dw->setVisible( dwMap[dw->objectName()] );
03209   }
03210 }
03211 
03215 void LightApp_Application::saveDockWindowsState()
03216 {
03217   if ( !desktop() )
03218     return;
03219 
03220   bool store = resourceMgr()->booleanValue( "Study", "store_positions", true );
03221   if( !store )
03222     return;
03223 
03224   QString modName;
03225   if ( activeModule() )
03226     modName = activeModule()->name();
03227 
03228   myWinGeom.insert( modName, desktop()->saveState() );
03229 
03230   QByteArray visArr;
03231   if ( myWinVis.contains( modName ) )
03232     visArr = myWinVis[modName];
03233 
03234   QMap<QString, bool> tbMap, dwMap;
03235   dockWindowsState( visArr, tbMap, dwMap );
03236 
03237   QList<QToolBar*> tbList = qFindChildren<QToolBar*>( desktop() );
03238   for ( QList<QToolBar*>::iterator it = tbList.begin(); it != tbList.end(); ++it )
03239   {
03240     QToolBar* tb = *it;
03241     tbMap.insert( tb->objectName(), tb->toggleViewAction()->isChecked() );
03242   }
03243 
03244   QList<QDockWidget*> dwList = qFindChildren<QDockWidget*>( desktop() );
03245   for ( QList<QDockWidget*>::iterator it = dwList.begin(); it != dwList.end(); ++it )
03246   {
03247     QDockWidget* wid = *it;
03248     dwMap.insert( wid->objectName(), wid->toggleViewAction()->isChecked() );
03249   }
03250 
03251   visArr = dockWindowsState( tbMap, dwMap );
03252 
03253   myWinVis.insert( modName, visArr );
03254 }
03255 
03256 QByteArray LightApp_Application::dockWindowsState( const QMap<QString, bool>& tb, const QMap<QString, bool>& dw ) const
03257 {
03258   QByteArray visArr;
03259   QDataStream stream( &visArr, QIODevice::WriteOnly );
03260 
03261   stream << (uchar)ToolBarMarker;
03262   stream << tb.size();
03263   for ( QMap<QString, bool>::const_iterator tit = tb.begin(); tit != tb.end(); ++tit )
03264   {
03265     stream << tit.key();
03266     stream << (uchar)( tit.value() ? 1 : 0 );
03267   }
03268 
03269   stream << (uchar)DockWidgetMarker;
03270   stream << dw.size();
03271   for ( QMap<QString, bool>::const_iterator wit = dw.begin(); wit != dw.end(); ++wit )
03272   {
03273     stream << wit.key();
03274     stream << (uchar)( wit.value() ? 1 : 0 );
03275   }
03276 
03277   return visArr;
03278 }
03279 
03280 void LightApp_Application::dockWindowsState( const QByteArray& arr, QMap<QString, bool>& tb, QMap<QString, bool>& dw ) const
03281 {
03282   tb.clear();
03283   dw.clear();
03284 
03285   QByteArray visArr = arr;
03286   QDataStream stream( &visArr, QIODevice::ReadOnly );
03287 
03288   uchar marker;
03289   stream >> marker;
03290   if ( marker != ToolBarMarker )
03291     return;
03292 
03293   int lines;
03294   stream >> lines;
03295   for ( int i = 0; i < lines; ++i )
03296   {
03297     QString objectName;
03298     stream >> objectName;
03299     uchar shown;
03300     stream >> shown;
03301     tb.insert( objectName, shown );
03302   }
03303 
03304   stream >> marker;
03305   if ( marker != DockWidgetMarker )
03306     return;
03307 
03308   stream >> lines;
03309   for ( int j = 0; j < lines; ++j )
03310   {
03311     QString objectName;
03312     stream >> objectName;
03313     uchar shown;
03314     stream >> shown;
03315     dw.insert( objectName, shown );
03316   }
03317 }
03318 
03322 void LightApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) const
03323 {
03324   iconMap.clear();
03325 
03326   SUIT_ResourceMgr* resMgr = resourceMgr();
03327   if ( !resMgr )
03328     return;
03329 
03330   QStringList modList;
03331   modules( modList, false );
03332 
03333   for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )
03334   {
03335     QString modName = *it;
03336     QString modIntr = moduleName( modName );
03337     QString modIcon = resMgr->stringValue( modIntr, "icon", QString() );
03338 
03339     if ( modIcon.isEmpty() )
03340       continue;
03341 
03342     if ( SUIT_Tools::extension( modIcon ).isEmpty() )
03343       modIcon += QString( ".png" );
03344 
03345     iconMap.insert( modName, modIcon );
03346   }
03347 }
03348 
03352 void LightApp_Application::contextMenuPopup( const QString& type, QMenu* thePopup, QString& title )
03353 {
03354   //Add "Rename" item
03355   LightApp_SelectionMgr* selMgr = LightApp_Application::selectionMgr();
03356   bool cacheIsOn = selMgr->isSelectionCacheEnabled();
03357   selMgr->setSelectionCacheEnabled( true );
03358 
03359   SUIT_DataBrowser* ob = objectBrowser();
03360 
03361   CAM_Application::contextMenuPopup( type, thePopup, title );
03362 
03363   if ( ob && type == ob->popupClientType() ) {
03364     thePopup->addSeparator();
03365     QAction* a = thePopup->addAction( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
03366     if ( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) )
03367       a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::UpdateShortcut) );
03368   }
03369 
03370   if ( selMgr && ob ) {
03371     SALOME_ListIO selected;
03372     selMgr->selectedObjects( selected );
03373     if(selected.Extent() == 1){
03374       Handle(SALOME_InteractiveObject) anIObject = selected.First();
03375       SUIT_DataObject* obj = findObject(anIObject->getEntry());
03376       if(obj && obj->renameAllowed()) {
03377         QAction* a = new QAction(tr("MEN_RENAME_OBJ"), thePopup);
03378         connect( a, SIGNAL( triggered(bool) ), ob, SLOT( onStartEditing() ) );
03379         if ( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) )
03380           a->setShortcut( ob->shortcutKey(SUIT_DataBrowser::RenameShortcut) );
03381 
03382         QList<QAction*> acts = thePopup->actions();
03383         QAction* firstAction = acts.count() > 0 ? acts.first() : 0;
03384         thePopup->insertAction(firstAction,a);
03385       }
03386     }
03387   }
03388 
03389   selMgr->setSelectionCacheEnabled( cacheIsOn );
03390 }
03391 
03395 void LightApp_Application::createEmptyStudy()
03396 {
03397   CAM_Application::createEmptyStudy();
03398 
03399   if ( objectBrowser() )
03400     objectBrowser()->updateTree();
03401 
03402   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
03403   if ( aResMgr && activeStudy() ) {
03404     int autoSaveInterval = aResMgr->integerValue( "Study", "auto_save_interval", 0 );
03405     if ( autoSaveInterval > 0 ) myAutoSaveTimer->start( autoSaveInterval*60000 );
03406   }
03407 }
03408 
03410 void LightApp_Application::setDesktop( SUIT_Desktop* desk )
03411 {
03412   CAM_Application::setDesktop( desk );
03413 
03414   if ( desk ) {
03415     connect( desk, SIGNAL( message( const QString& ) ),
03416              this, SLOT( onDesktopMessage( const QString& ) ), Qt::UniqueConnection );
03417   }
03418 }
03419 
03424 bool LightApp_Application::activateModule( CAM_Module* mod )
03425 {
03426   bool res = CAM_Application::activateModule( mod );
03427 
03428   if ( objectBrowser() )
03429     objectBrowser()->updateTree();
03430 
03431   return res;
03432 }
03433 
03437 SUIT_Accel* LightApp_Application::accel() const
03438 {
03439   return myAccel;
03440 }
03441 
03445 void LightApp_Application::onWCDestroyed( QObject* ob )
03446 {
03447   // remove destroyed widget container from windows map
03448   for ( WinMap::ConstIterator itr = myWin.begin(); itr != myWin.end(); ++itr )
03449   {
03450     if ( itr.value() != ob )
03451       continue;
03452 
03453     int key = itr.key();
03454     myWin.remove( key );
03455     break;
03456   }
03457 }
03458 
03459 void LightApp_Application::onMRUActivated( const QString& name )
03460 {
03461   SUIT_Session* s = SUIT_Session::session();
03462   if ( s && s->activeApplication() == this )
03463     onOpenDoc( name );
03464 }
03465 
03466 void LightApp_Application::onStylePreferences()
03467 {
03468   Style_PrefDlg dlg( desktop() );
03469   dlg.exec();
03470 
03471   resourceMgr()->setValue( "Style", "use_salome_style", Style_Salome::isActive() );
03472 }
03473 
03474 void LightApp_Application::onFullScreen(){
03475   if(myScreenHelper) {
03476     if(desktop()->isFullScreen())
03477       myScreenHelper->switchToNormalScreen();
03478     else
03479       myScreenHelper->switchToFullScreen();
03480   }
03481 }
03482 
03486 void LightApp_Application::addViewManager( SUIT_ViewManager* vm )
03487 {
03488   connect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
03489            this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
03490   STD_Application::addViewManager( vm );
03491 }
03492 
03496 void LightApp_Application::removeViewManager( SUIT_ViewManager* vm )
03497 {
03498   disconnect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
03499            this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
03500   LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
03501   if (aStudy )
03502     aStudy->removeViewMgr(vm->getGlobalId());
03503 
03504   STD_Application::removeViewManager( vm );
03505 
03506   // IPAL22894: Crash on closing OCC view
03507   //delete vm;
03508   vm->deleteLater();
03509 }
03510 
03514 void LightApp_Application::onRenameWindow()
03515 {
03516   if( !desktop() )
03517     return;
03518 
03519   QWidget* w = desktop()->activeWindow();
03520   if( !w )
03521     return;
03522 
03523   bool ok;
03524   QString name = QInputDialog::getText( w, tr( "TOT_RENAME" ), tr( "PRP_RENAME" ), QLineEdit::Normal, w->windowTitle(), &ok );
03525   if( ok && !name.isEmpty() )
03526     w->setWindowTitle( name );
03527 }
03528 
03532 void LightApp_Application::onCloseWindow()
03533 {
03534   if( !desktop() )
03535     return;
03536 
03537   QWidget* w = desktop()->activeWindow();
03538   if( !w )
03539     return;
03540 
03541   w->close();
03542 }
03543 
03547 void LightApp_Application::onCloseAllWindow()
03548 {
03549   STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
03550   if( !desk )
03551     return;
03552 
03553   QList<SUIT_ViewWindow*> wndList = desk->windows();
03554   SUIT_ViewWindow* wnd;
03555   foreach( wnd, wndList )
03556   {
03557     if ( wnd )
03558       wnd->close();
03559   }
03560 }
03561 
03565 void LightApp_Application::onGroupAllWindow()
03566 {
03567   STD_TabDesktop* desk = dynamic_cast<STD_TabDesktop*>( desktop() );
03568   if( !desk )
03569     return;
03570 
03571   QtxWorkstack* wgStack = desk->workstack();
03572   if ( wgStack )
03573     wgStack->stack();
03574 }
03575 
03580 bool LightApp_Application::isLibExists( const QString& moduleTitle ) const
03581 {
03582   if( moduleTitle.isEmpty() )
03583     return false;
03584 
03585   QString lib = moduleLibrary( moduleTitle );
03586 
03587   //abd: changed libSalomePyQtGUI to SalomePyQtGUI for WIN32
03588   bool isPythonModule = lib.contains("SalomePyQtGUI");
03589   bool isPythonLightModule = lib.contains("libSalomePyQtGUILight");
03590 
03591   QStringList paths;
03592 #ifdef WIN32
03593   paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
03594 #else
03595   paths = QString(::getenv( "LD_LIBRARY_PATH" )).split( ":", QString::SkipEmptyParts );
03596 #endif
03597 
03598   bool isLibFound = false;
03599   QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
03600   for( ; anIt!=aLast; anIt++ )
03601   {
03602     QFileInfo inf( Qtx::addSlash( *anIt ) + lib );
03603 
03604     if( inf.exists() )
03605       {
03606         isLibFound = true;
03607         break;
03608       }
03609   }
03610 
03611   if ( !isLibFound )
03612     {
03613       INFOS( "****************************************************************" << std::endl
03614           << "*    Warning: library " << lib.toLatin1().constData() << " cannot be found" << std::endl
03615           << "*    Module " << moduleTitle.toLatin1().constData() << " will not be available in GUI mode" << std::endl
03616           << "****************************************************************" << std::endl );
03617     }
03618   else if ( !isPythonModule && !isPythonLightModule)
03619     return true;
03620 
03621   if ( isPythonModule || isPythonLightModule)
03622     {
03623       QString pylib = moduleName( moduleTitle ) + QString(".py");
03624       QString pylibgui = moduleName( moduleTitle ) + QString("GUI.py");
03625 
03626       // Check the python library
03627 #ifdef WIN32
03628       paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
03629 #else
03630       paths = QString(::getenv( "PYTHONPATH" )).split( ":", QString::SkipEmptyParts );
03631 #endif
03632       bool isPyLib = false, isPyGuiLib = false;
03633       QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
03634       for( ; anIt!=aLast; anIt++ )
03635         {
03636           QFileInfo inf( Qtx::addSlash( *anIt ) + pylib );
03637           QFileInfo infgui( Qtx::addSlash( *anIt ) + pylibgui );
03638 
03639           if(!isPythonLightModule)
03640             if( !isPyLib && inf.exists() )
03641               isPyLib = true;
03642 
03643           if( !isPyGuiLib && infgui.exists() )
03644             isPyGuiLib = true;
03645 
03646           if ((isPyLib || isPythonLightModule ) && isPyGuiLib && isLibFound)
03647             return true;
03648         }
03649 
03650       printf( "****************************************************************\n" );
03651       printf( "*    Warning: python library for %s cannot be found:\n", moduleTitle.toLatin1().constData() );
03652       if (!isPyLib)
03653         printf( "*    No module named %s\n", moduleName( moduleTitle ).toLatin1().constData() );
03654       if (!isPyGuiLib)
03655         printf( "*    No module named %s\n", (moduleName( moduleTitle ) + QString("GUI")).toLatin1().constData() );
03656       printf( "****************************************************************\n" );
03657       return true;
03658   }
03659   return false;
03660 }
03661 
03665 void LightApp_Application::setDefaultStudyName( const QString& theName )
03666 {
03667   QStringList anInfoList;
03668   modules( anInfoList, false );
03669 
03670   LightApp_Study* aStudy = (LightApp_Study*)activeStudy();
03671   if( anInfoList.count() == 1 && // to avoid a conflict between different modules
03672       !aStudy->isSaved() )
03673   {
03674     aStudy->setStudyName( theName );
03675     updateDesktopTitle();
03676   }
03677 }
03678 
03682 bool LightApp_Application::event( QEvent* e )
03683 {
03684   if( e && e->type()==2000 )
03685   {
03686     SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
03687     QString* d = ( QString* )ce->data();
03688     if( SUIT_MessageBox::question(0, tr("WRN_WARNING"),
03689                                   d ? *d : "",
03690                                   SUIT_MessageBox::Yes | SUIT_MessageBox::No,
03691                                   SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
03692       showPreferences( tr( "PREF_APP" ) );
03693     if( d )
03694       delete d;
03695     return true;
03696   }
03697   return CAM_Application::event( e );
03698 }
03699 
03701 bool LightApp_Application::checkDataObject(LightApp_DataObject* theObj)
03702 {
03703   if (theObj)
03704     {
03705       bool isSuitable = !theObj->entry().isEmpty() &&
03706                         !theObj->componentDataType().isEmpty() &&
03707                         !theObj->name().isEmpty();
03708       return isSuitable;
03709     }
03710 
03711   return false;
03712 }
03713 
03714 int LightApp_Application::openChoice( const QString& aName )
03715 {
03716   int choice = CAM_Application::openChoice( aName );
03717 
03718   if ( choice == OpenExist ) // The document is already open.
03719   {
03720     // Do you want to reload it?
03721     if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "QUE_DOC_ALREADYOPEN" ).arg( aName ),
03722                                     SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No ) == SUIT_MessageBox::Yes )
03723       choice = OpenReload;
03724   }
03725 
03726   return choice;
03727 }
03728 
03729 bool LightApp_Application::openAction( const int choice, const QString& aName )
03730 {
03731   bool res = false;
03732   switch ( choice )
03733   {
03734   case OpenReload:
03735     {
03736       STD_Application* app = 0;
03737       SUIT_Session* session = SUIT_Session::session();
03738       QList<SUIT_Application*> appList = session->applications();
03739       for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !app; ++it )
03740       {
03741         if ( (*it)->activeStudy() && (*it)->activeStudy()->studyName() == aName )
03742           app = ::qobject_cast<STD_Application*>( *it );
03743       }
03744 
03745       if ( app )
03746       {
03747         app->onCloseDoc( false );
03748         appList = session->applications();
03749         STD_Application* other = 0;
03750         for ( QList<SUIT_Application*>::iterator it = appList.begin(); it != appList.end() && !other; ++it )
03751           other = ::qobject_cast<STD_Application*>( *it );
03752 
03753         if ( other )
03754           res = other->onOpenDoc( aName );
03755       }
03756     }
03757     break;
03758   default:
03759     res = CAM_Application::openAction( choice, aName );
03760     break;
03761   }
03762 
03763   return res;
03764 }
03765 
03766 QStringList LightApp_Application::viewManagersTypes() const
03767 {
03768   QStringList aTypesList;
03769   aTypesList += myUserWmTypes;
03770 #ifndef DISABLE_GLVIEWER
03771   aTypesList<<GLViewer_Viewer::Type();
03772 #endif
03773 #ifndef DISABLE_PLOT2DVIEWER
03774   aTypesList<<Plot2d_Viewer::Type();
03775 #endif
03776 #ifndef DISABLE_QXGRAPHVIEWER
03777   aTypesList<<QxScene_Viewer::Type();
03778 #endif
03779 #ifndef DISABLE_OCCVIEWER
03780   aTypesList<<OCCViewer_Viewer::Type();
03781 #endif
03782 #ifndef DISABLE_VTKVIEWER
03783  #ifndef DISABLE_SALOMEOBJECT
03784   aTypesList<<SVTK_Viewer::Type();
03785  #else
03786   aTypesList<<VTKViewer_Viewer::Type();
03787  #endif
03788 #endif
03789   return aTypesList;
03790 }
03795 void LightApp_Application::clearKnownViewManagers()
03796 {
03797   QStringList aTypesList = viewManagersTypes();
03798   QList<SUIT_ViewManager*> aMgrList;
03799   viewManagers( aMgrList );
03800   foreach (SUIT_ViewManager* aMgr, aMgrList) {
03801     if (aTypesList.contains(aMgr->getType()))
03802       removeViewManager(aMgr);
03803   }
03804 }
03805 
03809 void LightApp_Application::onCopy()
03810 {
03811   LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
03812   if( m )
03813     m->copy();
03814 }
03815 
03819 void LightApp_Application::onPaste()
03820 {
03821   LightApp_Module* m = dynamic_cast<LightApp_Module*>( activeModule() );
03822   if( m )
03823     m->paste();
03824 }
03825 
03834 QString LightApp_Application::browseObjects( const QStringList& theEntryList,
03835                                              const bool theIsApplyAndClose,
03836                                              const bool theIsOptimizedBrowsing )
03837 {
03838   QString aResult;
03839   if( SUIT_ResourceMgr* aResourceMgr = resourceMgr() )
03840   {
03841     int aBrowsePolicy = aResourceMgr->integerValue( "ObjectBrowser", "browse_published_object", (int)BP_Never );
03842     switch( aBrowsePolicy )
03843     {
03844       case BP_Never:
03845         return aResult;
03846       case BP_ApplyAndClose:
03847         if( !theIsApplyAndClose )
03848           return aResult;
03849       case BP_Always:
03850       default:
03851         break;
03852     }
03853   }
03854 
03855   LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
03856   if( !aStudy )
03857     return aResult;
03858 
03859   SUIT_DataBrowser* anOB = objectBrowser();
03860   if( !anOB )
03861     return aResult;
03862 
03863   SUIT_AbstractModel* aModel = dynamic_cast<SUIT_AbstractModel*>( anOB->model() );
03864   if( !aModel )
03865     return aResult;
03866 
03867   QStringListIterator anIter( theEntryList );
03868   if( theIsOptimizedBrowsing )
03869   {
03870     // go to the last entry
03871     anIter.toBack();
03872     if( anIter.hasPrevious() )
03873       anIter.previous();
03874   }
03875 
03876   // scroll to each entry in the list
03877   // (in optimized mode - to the last entry only)
03878   QString anEntry;
03879   LightApp_DataObject* anObject;
03880   while( anIter.hasNext() )
03881   {
03882     anEntry = anIter.next();
03883     if( !anEntry.isEmpty() )
03884     {
03885       anObject = aStudy->findObjectByEntry( anEntry );
03886       if( anObject )
03887       {
03888         QModelIndex anIndex = aModel->index( anObject );
03889         anOB->treeView()->scrollTo( anIndex );
03890       }
03891     }
03892   }
03893 
03894   // always select the last object
03895   if( anObject && !anEntry.isEmpty() )
03896   {
03897     QList<SUIT_Selector*> aSelectorList;
03898     selectionMgr()->selectors( "ObjectBrowser", aSelectorList );
03899     if( !aSelectorList.isEmpty() )
03900     {
03901       if( LightApp_OBSelector* aSelector = dynamic_cast<LightApp_OBSelector*>( aSelectorList.first() ) )
03902       {
03903         bool anIsAutoBlock = aSelector->autoBlock();
03904 
03905         // temporarily disable auto block, to emit LightApp_SelectionMgr::currentSelectionChanged() signal
03906         aSelector->setAutoBlock( false );
03907 
03908         SUIT_DataOwnerPtrList aList;
03909 #ifndef DISABLE_SALOMEOBJECT
03910         Handle(SALOME_InteractiveObject) aSObj = new SALOME_InteractiveObject
03911           ( anObject->entry().toLatin1().constData(),
03912             anObject->componentDataType().toLatin1().constData(),
03913             anObject->name().toLatin1().constData() );
03914         LightApp_DataOwner* owner = new LightApp_DataOwner( aSObj  );
03915 #else
03916         LightApp_DataOwner* owner = new LightApp_DataOwner( anEntry );
03917 #endif
03918 
03919         aList.append( owner );
03920         selectionMgr()->setSelected( aList );
03921         aResult = anEntry;
03922 
03923         // restore auto block flag
03924         aSelector->setAutoBlock( anIsAutoBlock );
03925       }
03926     }
03927   }
03928 
03929   return aResult;
03930 }
03931 
03932 SUIT_DataObject* LightApp_Application::findObject( const QString& id ) const
03933 {
03934   LightApp_Study* study = dynamic_cast<LightApp_Study*>( activeStudy() );
03935   return study ? study->findObjectByEntry( id ) : 0;
03936 }
03937 
03943 bool LightApp_Application::renameAllowed( const QString& /*entry*/) const {
03944   return false;
03945 }
03946 
03953 bool LightApp_Application::renameObject( const QString& entry, const QString& ) {
03954   return false;
03955 }
03956 
03958 void LightApp_Application::onDesktopMessage( const QString& message )
03959 {
03960   const QString sectionSeparator = "/";
03961 
03962   if ( message.toLower() == "updateobjectbrowser" ||
03963        message.toLower() == "updateobjbrowser" ) {
03964     // update object browser
03965     updateObjectBrowser();
03966   }
03967   else {
03968     QStringList data = message.split( sectionSeparator );
03969     if ( data.count() > 1 ) {
03970       QString msgType = data[0].trimmed();
03971       LightApp_Module* sMod = 0;
03972       CAM_Module* mod = module( msgType );
03973       if ( !mod )
03974        mod = module( moduleTitle( msgType ) );
03975       if ( mod && mod->inherits( "LightApp_Module" ) )
03976        sMod = (LightApp_Module*)mod;
03977 
03978       if ( msgType.toLower() == "preferences" ) {
03979        // requested preferences change: should be given as "preferences/<section>/<name>/<value>"
03980        // for example "preferences/Study/multi_file_dump/true"
03981        if ( data.count() > 3 ) {
03982          QString section = data[1].trimmed();
03983          QString param   = data[2].trimmed();
03984          QString value   = QStringList( data.mid(3) ).join( sectionSeparator );
03985          resourceMgr()->setValue( section, param, value );
03986        }
03987       }
03988       else if ( sMod ) {
03989        // received message for the module
03990        QString msg = QStringList( data.mid(1) ).join( sectionSeparator );
03991        sMod->message( msg );
03992       }
03993     }
03994   }
03995 }