Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/gui.git] / src / LightApp / LightApp_Application.cxx
index 051b1c314cd741433f6e6d7c171c1c6a7e2af588..2e59728d023febeb1f739a63ea596adcb42519fb 100644 (file)
@@ -1,3 +1,21 @@
+// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either 
+// version 2.1 of the License.
+// 
+// This library is distributed in the hope that it will be useful 
+// but WITHOUT ANY WARRANTY; without even the implied warranty of 
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public  
+// License along with this library; if not, write to the Free Software 
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 // File:      LightApp_Application.cxx
 // Created:   6/20/2005 18:39:45 PM
 // Author:    Natalia Donis
 
 #include "LightApp_OBFilter.h"
 
+#include "LightApp_EventFilter.h"
+
 #include "LightApp_OBSelector.h"
 #include "LightApp_SelectionMgr.h"
+#include "LightApp_DataObject.h"
 
 #include <CAM_Module.h>
 #include <CAM_DataModel.h>
 #include <QtxMRUAction.h>
 #include <QtxDockAction.h>
 #include <QtxToolBar.h>
+#include <qprocess.h>
 
 #include <LogWindow.h>
 #include <OB_Browser.h>
 #include <OB_ListView.h>
+#include <OB_ObjSearch.h>
 
 #ifndef DISABLE_GLVIEWER
   #include <GLViewer_Viewer.h>
   #include <VTKViewer_ViewModel.h>
 #endif
 
-#ifndef DISABLE_SUPERVGRAPHVIEWER
-  #include <SUPERVGraph_ViewModel.h>
-  #include <SUPERVGraph_ViewFrame.h>
-  #include <SUPERVGraph_ViewManager.h>
+//#ifndef DISABLE_SUPERVGRAPHVIEWER
+//  #include <SUPERVGraph_ViewModel.h>
+//  #include <SUPERVGraph_ViewFrame.h>
+//  #include <SUPERVGraph_ViewManager.h>
+//#endif
+
+#ifndef DISABLE_QXGRAPHVIEWER
+  #include <QxGraph_ViewModel.h>
+  #include <QxGraph_ViewWindow.h>
+  #include <QxGraph_ViewManager.h>
 #endif
 
 #include <QtxWorkstack.h>
 #include <qcombobox.h>
 #include <qinputdialog.h>
 #include <qmessagebox.h>
+#include <qfontdatabase.h>
 
 #define FIRST_HELP_ID 1000000
 
@@ -137,6 +167,9 @@ static const char* imageEmptyIcon[] = {
 
 int LightApp_Application::lastStudyId = 0;
 
+/*!
+  \return last global id of study
+*/
 int LightApp_Application::studyId()
 {
   return LightApp_Application::lastStudyId;
@@ -148,11 +181,12 @@ extern "C" LIGHTAPP_EXPORT SUIT_Application* createApplication()
   return new LightApp_Application();
 }
 
+/*! \var global preferences of LightApp */
 LightApp_Preferences* LightApp_Application::_prefs_ = 0;
 
-/*
-  Class       : LightApp_Application
-  Description : Application containing LightApp module
+/*!
+  \class LightApp_Application
+  Application containing LightApp module
 */
 
 /*!Constructor.*/
@@ -208,8 +242,41 @@ myPrefs( 0 )
   myAccel->setActionKey( SUIT_Accel::RotateUp,    ALT+Key_Up,        VTKViewer_Viewer::Type() );
   myAccel->setActionKey( SUIT_Accel::RotateDown,  ALT+Key_Down,      VTKViewer_Viewer::Type() );
 #endif
+#ifndef DISABLE_PLOT2DVIEWER
+  myAccel->setActionKey( SUIT_Accel::PanLeft,     CTRL+Key_Left,     Plot2d_Viewer::Type() );
+  myAccel->setActionKey( SUIT_Accel::PanRight,    CTRL+Key_Right,    Plot2d_Viewer::Type() );
+  myAccel->setActionKey( SUIT_Accel::PanUp,       CTRL+Key_Up,       Plot2d_Viewer::Type() );
+  myAccel->setActionKey( SUIT_Accel::PanDown,     CTRL+Key_Down,     Plot2d_Viewer::Type() );
+  myAccel->setActionKey( SUIT_Accel::ZoomIn,      CTRL+Key_Plus,     Plot2d_Viewer::Type() );
+  myAccel->setActionKey( SUIT_Accel::ZoomOut,     CTRL+Key_Minus,    Plot2d_Viewer::Type() );
+  myAccel->setActionKey( SUIT_Accel::ZoomFit,     CTRL+Key_Asterisk, Plot2d_Viewer::Type() );
+#endif
 
   connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) );
+
+  // Set existing font for the python console in resources
+  if( !aResMgr->hasValue( "PyConsole", "font" ) )
+    return;
+  
+  QFont f = aResMgr->fontValue( "PyConsole", "font" );
+  QFontDatabase fdb;
+  QStringList famdb = fdb.families();
+  
+  if ( famdb.contains(f.family()) || !aResMgr->hasValue( "PyConsole", "additional_families" ) )
+    return;
+  
+  QStringList anAddFamilies = QStringList::split( ";", aResMgr->stringValue( "PyConsole", "additional_families" ) );
+  QString aFamily;
+  for ( QStringList::Iterator it = anAddFamilies.begin(); it != anAddFamilies.end(); ++it )
+    {
+      aFamily = *it;
+      if ( famdb.contains(aFamily) )
+       {
+         f.setFamily( aFamily );
+         aResMgr->setValue( "PyConsole", "font", f );
+         break;
+       }
+    }
 }
 
 /*!Destructor.
@@ -240,6 +307,8 @@ void LightApp_Application::start()
 
   putInfo( "" );
   desktop()->statusBar()->message( "" );
+
+  LightApp_EventFilter::Init();
 }
 
 /*!Gets application name.*/
@@ -333,6 +402,10 @@ bool LightApp_Application::activateModule( const QString& modName )
   return true;
 }
 
+/*!
+  Opens other study into active Study. If Study is empty - creates it.
+  \param theName - name of study
+*/
 bool LightApp_Application::useStudy(const QString& theName)
 {
   createEmptyStudy();
@@ -388,22 +461,35 @@ void LightApp_Application::createActions()
   int id = LightApp_Application::UserID + FIRST_HELP_ID;
   // help for KERNEL and GUI
   QCString dir;
-  QString aFileName;
+  QString aFileName = "index.html";
   QString root;
   QAction* a;
   if (dir = getenv("GUI_ROOT_DIR")) {
-    aFileName = "GUI_index_v3.1.0.html";
-    root = Qtx::addSlash( Qtx::addSlash(dir) +  Qtx::addSlash("doc") +  Qtx::addSlash("salome") );
+    root = Qtx::addSlash( Qtx::addSlash(dir) + Qtx::addSlash("share") + Qtx::addSlash("doc") +
+                          Qtx::addSlash("salome") + Qtx::addSlash("gui") +  Qtx::addSlash("GUI") );
     if ( QFileInfo( root + aFileName ).exists() ) {
-      a = createAction( id, tr( QString("Kernel & GUI Help") ), QIconSet(),
-                       tr( QString("Kernel && GUI Help") ),
-                       tr( QString("Kernel & GUI Help") ),
+      a = createAction( id, tr( QString("GUI Help") ), QIconSet(),
+                       tr( QString("GUI Help") ),
+                       tr( QString("GUI Help") ),
                        0, desk, false, this, SLOT( onHelpContentsModule() ) );
       a->setName( QString("GUI") );
       createMenu( a, helpModuleMenu, -1 );
       id++;
     }
   }
+  if (dir = getenv("KERNEL_ROOT_DIR")) {
+    root = Qtx::addSlash( Qtx::addSlash(dir) + Qtx::addSlash("share") + Qtx::addSlash("doc") + 
+                         Qtx::addSlash("salome") );
+    if ( QFileInfo( root + aFileName ).exists() ) {
+      a = createAction( id, tr( QString("KERNEL Help") ), QIconSet(),
+                       tr( QString("KERNEL Help") ),
+                       tr( QString("KERNEL Help") ),
+                       0, desk, false, this, SLOT( onHelpContentsModule() ) );
+      a->setName( QString("KERNEL") );
+      createMenu( a, helpModuleMenu, -1 );
+      id++;
+    }
+  }
   // help for other existing modules
   QStringList::Iterator it;
   for ( it = aModuleList.begin(); it != aModuleList.end(); ++it )
@@ -412,10 +498,10 @@ void LightApp_Application::createActions()
       continue;
 
     QString modName = moduleName( *it );
-    aFileName = modName + "_index_v3.1.0.html";
     
     if (dir = getenv( modName + "_ROOT_DIR")) {
-      root = Qtx::addSlash( Qtx::addSlash(dir) +  Qtx::addSlash("doc") +  Qtx::addSlash("salome") );
+      root = Qtx::addSlash( Qtx::addSlash(dir) +  Qtx::addSlash("share") + Qtx::addSlash("doc") + 
+                            Qtx::addSlash("salome") + Qtx::addSlash("gui") +  Qtx::addSlash(modName) );
       if ( QFileInfo( root + aFileName ).exists() ) {
 
        QAction* a = createAction( id, tr( moduleTitle(modName) + QString(" Help") ), QIconSet(),
@@ -444,64 +530,73 @@ void LightApp_Application::createActions()
   if ( modIcon.isNull() )
     modIcon = QPixmap( imageEmptyIcon );
 
-  QToolBar* modTBar = new QtxToolBar( true, desk );
-  modTBar->setLabel( tr( "INF_TOOLBAR_MODULES" ) );
+  QStringList modList;
+  modules( modList, false );
+
+  if( modList.count()>1 )
+  {
+    QToolBar* modTBar = new QtxToolBar( true, desk );
+    modTBar->setLabel( tr( "INF_TOOLBAR_MODULES" ) );
 
-  QActionGroup* modGroup = new QActionGroup( this );
-  modGroup->setExclusive( true );
-  modGroup->setUsesDropDown( true );
+    QActionGroup* modGroup = new QActionGroup( this );
+    modGroup->setExclusive( true );
+    modGroup->setUsesDropDown( true );
 
-  a = createAction( -1, tr( "APP_NAME" ), defIcon, tr( "APP_NAME" ),
-                    tr( "PRP_APP_MODULE" ), 0, desk, true );
-  modGroup->add( a );
-  myActions.insert( QString(), a );
+    a = createAction( -1, tr( "APP_NAME" ), defIcon, tr( "APP_NAME" ),
+                      tr( "PRP_APP_MODULE" ), 0, desk, true );
+    modGroup->add( a );
+    myActions.insert( QString(), a );
 
-  QMap<QString, QString> iconMap;
-  moduleIconNames( iconMap );
+    QMap<QString, QString> iconMap;
+    moduleIconNames( iconMap );
 
-  const int iconSize = 20;
+    const int iconSize = 20;
 
-  modGroup->addTo( modTBar );
-  QObjectList *l = modTBar->queryList( "QComboBox" );
-  QObjectListIt oit( *l );
-  while ( QObject* obj = oit.current() ) {
-    QComboBox* cb = (QComboBox*)obj;
-    if ( cb ) cb->setFocusPolicy( QWidget::NoFocus );
+    modGroup->addTo( modTBar );
+    QObjectList *l = modTBar->queryList( "QComboBox" );
+    QObjectListIt oit( *l );
+    while ( QObject* obj = oit.current() ) {
+      QComboBox* cb = (QComboBox*)obj;
+      if ( cb ) cb->setFocusPolicy( QWidget::NoFocus );
     ++oit;
-  }
-  delete l;
+    }
+    delete l;
   
-   modTBar->addSeparator();
-
-  QStringList modList;
-  modules( modList, false );
+    modTBar->addSeparator();
 
-  for ( it = modList.begin(); it != modList.end(); ++it )
-  {
-    if ( !isLibExists( *it ) )
-      continue;
+    for ( it = modList.begin(); it != modList.end(); ++it )
+    {
+      if ( !isLibExists( *it ) )
+        continue;
+    
+      QString iconName;
+      if ( iconMap.contains( *it ) )
+        iconName = iconMap[*it];
 
-    QString iconName;
-    if ( iconMap.contains( *it ) )
-      iconName = iconMap[*it];
+      QString modName = moduleName( *it );
 
-    QString modName = moduleName( *it );
+      QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
+      if ( icon.isNull() )
+      {
+       icon = modIcon;
+       printf( "****************************************************************\n" );
+       printf( "*    Icon for %s not found. Using the default one.\n", (*it).latin1() );
+       printf( "****************************************************************\n" );
+      }
 
-    QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
-    if ( icon.isNull() )
-      icon = modIcon;
+      icon.convertFromImage( icon.convertToImage().smoothScale( iconSize, iconSize, QImage::ScaleMin ) );
 
-    icon.convertFromImage( icon.convertToImage().smoothScale( iconSize, iconSize, QImage::ScaleMin ) );
+      QAction* a = createAction( -1, *it, icon, *it, tr( "PRP_MODULE" ).arg( *it ), 0, desk, true );
+      a->addTo( modTBar );
+      modGroup->add( a );
 
-    QAction* a = createAction( -1, *it, icon, *it, tr( "PRP_MODULE" ).arg( *it ), 0, desk, true );
-    a->addTo( modTBar );
-    modGroup->add( a );
+      myActions.insert( *it, a );
+    }
 
-    myActions.insert( *it, a );
+    SUIT_Tools::simplifySeparators( modTBar );
+    connect( modGroup, SIGNAL( selected( QAction* ) ), this, SLOT( onModuleActivation( QAction* ) ) );
   }
 
-  SUIT_Tools::simplifySeparators( modTBar );
-
   // New window
   int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, MenuWindowId, 100 );
   int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
@@ -520,14 +615,15 @@ void LightApp_Application::createActions()
 #ifndef DISABLE_VTKVIEWER
   createActionForViewer( NewVTKViewId, newWinMenu, QString::number( 3 ), ALT+Key_K );
 #endif
+#ifndef DISABLE_QXGRAPHVIEWER
+  createActionForViewer( NewQxGraphViewId, newWinMenu, QString::number( 4 ), ALT+Key_C );
+#endif
 
 
   createAction( RenameId, tr( "TOT_RENAME" ), QIconSet(), tr( "MEN_DESK_RENAME" ), tr( "PRP_RENAME" ),
                SHIFT+Key_R, desk, false, this, SLOT( onRenameWindow() ) );
   createMenu( RenameId, windowMenu, -1 );
 
-  connect( modGroup, SIGNAL( selected( QAction* ) ), this, SLOT( onModuleActivation( QAction* ) ) );
-
   int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
   createMenu( PreferencesId, fileMenu, 15, -1 );
   createMenu( separator(), fileMenu, -1, 15, -1 );
@@ -559,20 +655,16 @@ void LightApp_Application::onModuleActivation( QAction* a )
   bool cancelled = false;
   while ( !modName.isEmpty() && !activeStudy() && !cancelled ){
     LightApp_ModuleDlg aDlg( desktop(), modName, icon );
-    int res = aDlg.exec();
+    QMap<int, QString> opmap = activateModuleActions();
+    for ( QMap<int, QString>::ConstIterator it = opmap.begin(); it != opmap.end(); ++it )
+      aDlg.addButton( it.data(), it.key() );
 
-    switch ( res ){
-    case 1:
-      onNewDoc();
-      break;
-    case 2:
-      onOpenDoc();
-      break;
-    case 3:
-      //onLoadStudy();
-      //break;
-    case 0:
-    default:
+    int res = aDlg.exec();
+    if ( res != QDialog::Rejected ) {
+      // some operation is selected
+      moduleActionSelected( res );
+    }
+    else {
       putInfo( tr("INF_CANCELLED") );
       myActions[QString()]->setOn( true );
       cancelled = true;
@@ -623,6 +715,11 @@ void LightApp_Application::onNewWindow()
   case NewVTKViewId:
     type = VTKViewer_Viewer::Type();
     break;
+#endif
+#ifndef DISABLE_QXGRAPHVIEWER
+  case NewQxGraphViewId:
+    type = QxGraph_Viewer::Type();
+    break;
 #endif
   }
 
@@ -630,10 +727,9 @@ void LightApp_Application::onNewWindow()
     createViewManager( type );
 }
 
-//=======================================================================
-//  name    : onNewDoc
-/*! Purpose : SLOT. Create new document*/
-//=======================================================================
+/*!
+  SLOT: Creates new document
+*/
 void LightApp_Application::onNewDoc()
 {
   SUIT_Study* study = activeStudy();
@@ -649,10 +745,9 @@ void LightApp_Application::onNewDoc()
   }
 }
 
-//=======================================================================
-// name    : onOpenDoc
-/*! Purpose : SLOT. Open new document*/
-//=======================================================================
+/*!
+  SLOT: Opens new document
+*/
 void LightApp_Application::onOpenDoc()
 {
   SUIT_Study* study = activeStudy();
@@ -668,7 +763,11 @@ void LightApp_Application::onOpenDoc()
 }
 
 #include "SUIT_MessageBox.h"
-/*! Purpose : SLOT. Open new document with \a aName.*/
+
+/*!
+  SLOT: Opens new document.
+  \param aName - name of file
+*/
 bool LightApp_Application::onOpenDoc( const QString& aName )
 {
   bool isAlreadyOpen = false;
@@ -735,10 +834,9 @@ bool LightApp_Application::onOpenDoc( const QString& aName )
   return res;
 }
 
-//=======================================================================
-// name    : onHelpAbout
-/*! Purpose : SLOT. Display "About" message box*/
-//=======================================================================
+/*!
+  SLOT: Displays "About" message box
+*/
 void LightApp_Application::onHelpAbout()
 {
   LightApp_AboutDlg* dlg = new LightApp_AboutDlg( applicationName(), applicationVersion(), desktop() );
@@ -746,7 +844,10 @@ void LightApp_Application::onHelpAbout()
   delete dlg;
 }
 
-/*!SLOT. Load document with \a aName.*/
+/*!
+  SLOT: Loads document
+  \param aName - name of document
+*/
 bool LightApp_Application::onLoadDoc( const QString& aName )
 {
   bool res = CAM_Application::onLoadDoc( aName );
@@ -763,7 +864,10 @@ bool LightApp_Application::onLoadDoc( const QString& aName )
   return res;
 }
 
-/*!Private SLOT. Selection.*/
+/*!
+  Private SLOT: Called on selection is changed
+  Dispatchs active module that selection is changed
+*/
 void LightApp_Application::onSelection()
 {
   onSelectionChanged();
@@ -772,9 +876,10 @@ void LightApp_Application::onSelection()
     ((LightApp_Module*)activeModule())->selectionChanged();
 }
 
-/*!Set active study.
- *\param study - SUIT_Study.
- */
+/*!
+  Sets active study.
+ \param study - SUIT_Study.
+*/
 void LightApp_Application::setActiveStudy( SUIT_Study* study )
 {
   CAM_Application::setActiveStudy( study );
@@ -782,10 +887,9 @@ void LightApp_Application::setActiveStudy( SUIT_Study* study )
   activateWindows();
 }
 
-//=======================================================================
-// name    : updateCommandsStatus
-/*! Purpose : Enable/Disable menu items and toolbar buttons. Rebuild menu*/
-//=======================================================================
+/*!
+  Enables/Disables menu items and toolbar buttons. Rebuild menu
+*/
 void LightApp_Application::updateCommandsStatus()
 {
   CAM_Application::updateCommandsStatus();
@@ -814,43 +918,60 @@ void LightApp_Application::updateCommandsStatus()
   if( a )
     a->setEnabled( activeStudy() );
 #endif
+
+#ifndef DISABLE_QXGRAPHVIEWER
+  a = action( NewQxGraphViewId );
+  if( a )
+    a->setEnabled( activeStudy() );
+#endif
 }
 
-// Helps to execute command
-class RunBrowser: public QThread {
+/*!
+  \class RunBrowser
+  Runs system command in separate thread
+*/
+class RunBrowser: public QThread
+{
 public:
-
-  RunBrowser(QString theApp, QString theParams, QString theHelpFile, QString theContext=NULL):
-    myApp(theApp), myParams(theParams), 
+  RunBrowser (LightApp_Application* app, QString theApp, QString theParams,
+              QString theHelpFile, QString theContext=NULL)
+    myApp(theApp), myParams(theParams), 
 #ifdef WIN32
       myHelpFile("file://" + theHelpFile + theContext), 
 #else
       myHelpFile("file:" + theHelpFile + theContext),
 #endif
-      myStatus(0) {};
+      myStatus(0),
+      myLApp( app )
+  {
+  };
 
   virtual void run()
   {
     QString aCommand;
 
-    if ( !myApp.isEmpty())
-      {
-       aCommand.sprintf("%s %s %s",myApp.latin1(),myParams.latin1(),myHelpFile.latin1());
-       myStatus = system(aCommand);
-       if(myStatus != 0)
-         {
-           QCustomEvent* ce2000 = new QCustomEvent (2000);
-           postEvent (qApp, ce2000);
-         }
-      }
-      if( myStatus != 0)
+    if (!myApp.isEmpty())
+    {
+      //aCommand.sprintf("%s %s %s",myApp.latin1(),myParams.latin1(),myHelpFile.latin1());
+
+      //QProcess* proc = new QProcess();
+      //proc->addArgument( aCommand );
+
+      QProcess* proc = new QProcess();
+      proc->addArgument( myApp );
+      if (!myParams.isEmpty()) proc->addArgument( myParams );
+      proc->addArgument( myHelpFile );
+      //myStatus = system(aCommand);
+
+      //if(myStatus != 0)
+      if(!proc->start())
       {
-        qApp->lock();
-        SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
-                               QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").arg(myApp).arg(myHelpFile),
-                               QObject::tr("BUT_OK"));
-        qApp->unlock();
+        QCustomEvent* ce2000 = new QCustomEvent( 2000 );
+        QString* msg = new QString( QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").arg(myApp).arg(myHelpFile) );
+        ce2000->setData( msg );
+        postEvent( myLApp, ce2000 );
       }
+    }
   }
 
 private:
@@ -858,49 +979,101 @@ private:
   QString myParams;
   QString myHelpFile;
   int myStatus;
-
+  LightApp_Application* myLApp;
 };
 
-//=======================================================================
-// name    : onHelpContentsModule
-/*! Purpose : SLOT. Display help contents for choosen module*/
-//=======================================================================
+/*!
+  SLOT: Displays help contents for choosen module
+*/
 void LightApp_Application::onHelpContentsModule()
 {
   const QAction* obj = (QAction*) sender();
 
   QString aComponentName = obj->name();
-  QString aFileName = aComponentName + "_index_v3.1.0.html";
+  QString aFileName = "index.html";
 
   QCString dir = getenv( aComponentName + "_ROOT_DIR");
-  QString homeDir = Qtx::addSlash( Qtx::addSlash(dir) +  Qtx::addSlash("doc") +  Qtx::addSlash("salome") );
-
+  QString homeDir = !aComponentName.compare(QString("KERNEL")) ? 
+    Qtx::addSlash( Qtx::addSlash(dir) + Qtx::addSlash("share") + Qtx::addSlash("doc") + Qtx::addSlash("salome") ) : 
+    Qtx::addSlash( Qtx::addSlash(dir) + Qtx::addSlash("share") + Qtx::addSlash("doc") + Qtx::addSlash("salome") + Qtx::addSlash("gui") +  Qtx::addSlash(aComponentName) );
+  
   QString helpFile = QFileInfo( homeDir + aFileName ).absFilePath();
   SUIT_ResourceMgr* resMgr = resourceMgr();
-  QString anApp = resMgr->stringValue("ExternalBrowser", "application");
+       QString platform;
+#ifdef WIN32
+       platform = "winapplication";
+#else
+       platform = "application";
+#endif
+       QString anApp = resMgr->stringValue("ExternalBrowser", platform);
+#ifdef WIN32
+       QString quote("\""); 
+       anApp.prepend( quote ); 
+       anApp.append( quote ); 
+#endif
   QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
 
   if (!anApp.isEmpty()) {
-    RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile);
+    RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile );
     rs->start();
   }
   else {
-    SUIT_MessageBox::warn1(desktop(), tr("WRN_WARNING"),
+    if( SUIT_MessageBox::warn2(desktop(), tr("WRN_WARNING"),
                            tr("DEFINE_EXTERNAL_BROWSER"),
-                           tr("BUT_OK"));
+                           tr("BUT_OK"),tr("BUT_CANCEL"),0,1,0 )==0 )
+      onPreferences();
   }
 }
 
-/*!Sets enable or disable some actions on selection changed.*/
+/*!
+  SLOT: Displays help contents for choosen dialog
+*/
+void LightApp_Application::onHelpContextModule(const QString& theComponentName, const QString& theFileName)
+{
+  QCString dir = getenv( theComponentName + "_ROOT_DIR");
+  QString homeDir = Qtx::addSlash(Qtx::addSlash(dir)+Qtx::addSlash("share")+Qtx::addSlash("doc")+Qtx::addSlash("salome")+Qtx::addSlash("gui")+Qtx::addSlash(theComponentName));
+
+  QString helpFile = QFileInfo( homeDir + theFileName ).absFilePath();
+  SUIT_ResourceMgr* resMgr = resourceMgr();
+       QString platform;
+#ifdef WIN32
+       platform = "winapplication";
+#else
+       platform = "application";
+#endif
+       QString anApp = resMgr->stringValue("ExternalBrowser", platform);
+#ifdef WIN32
+       QString quote("\""); 
+       anApp.prepend( quote ); 
+       anApp.append( quote ); 
+#endif
+  QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
+
+  if (!anApp.isEmpty()) {
+    RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile );
+    rs->start();
+  }
+  else {
+    if( SUIT_MessageBox::warn2(desktop(), tr("WRN_WARNING"),
+                           tr("DEFINE_EXTERNAL_BROWSER"),
+                           tr("BUT_OK"), tr("BUT_CANCEL"),0,1,0)==0 )
+      onPreferences();
+  }
+}
+
+/*!
+  Sets enable or disable some actions on selection changed.
+*/
 void LightApp_Application::onSelectionChanged()
 {
 }
 
-/*!Return window.
- *\param flag - key for window
- *\param studyId - study id
- * Flag used how identificator of window in windows list.
- */
+/*!
+  \return window by key
+  \param flag - key for window
+  \param studyId - study id
+  Flag used how identificator of window in windows list.
+*/
 QWidget* LightApp_Application::window( const int flag, const int studyId ) const
 {
   QWidget* wid = 0;
@@ -920,12 +1093,13 @@ QWidget* LightApp_Application::window( const int flag, const int studyId ) const
   return wid;
 }
 
-/*!Adds window to application.
- *\param wid - QWidget
- *\param flag - key wor window
- *\param studyId - study id
- * Flag used how identificator of window in windows list.
- */
+/*!
+  Adds window to application.
+  \param wid - QWidget
+  \param flag - key for window
+  \param studyId - study id
+  Flag used how identificator of window in windows list.
+*/
 void LightApp_Application::addWindow( QWidget* wid, const int flag, const int studyId )
 {
   if ( !wid )
@@ -947,6 +1121,8 @@ void LightApp_Application::addWindow( QWidget* wid, const int flag, const int st
 
     LightApp_WidgetContainer* newWC = new LightApp_WidgetContainer( flag, desktop() );
     connect( newWC, SIGNAL(  destroyed ( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
+    // asv: connecting a slot for storing visibility flag of a window 
+    connect( newWC, SIGNAL( visibilityChanged ( bool ) ), SLOT( onVisibilityChanged( bool ) ) );
     myWindows.insert( flag, newWC );
     if ( winMap.contains( flag ) )
       desktop()->moveDockWindow( myWindows[flag], (Dock)winMap[flag] );
@@ -965,10 +1141,10 @@ void LightApp_Application::addWindow( QWidget* wid, const int flag, const int st
     if( resourceMgr()->hasValue( "PyConsole", "font" ) )
       f = resourceMgr()->fontValue( "PyConsole", "font" );
     else
-    {
-      f = ( ( PythonConsole* )wid )->font();
-      resourceMgr()->setValue( "PyConsole", "font", f );
-    }
+      {
+       f = ( ( PythonConsole* )wid )->font();
+       resourceMgr()->setValue( "PyConsole", "font", f );
+      }
   }
   else
 #endif
@@ -980,11 +1156,12 @@ void LightApp_Application::addWindow( QWidget* wid, const int flag, const int st
   setWindowShown( flag, !myWindows[flag]->isEmpty() );
 }
 
-/*!Remove window from application.
- *\param flag - key wor window
- *\param studyId - study id
- * Flag used how identificator of window in windows list.
- */
+/*!
+  Removes window from application.
+  \param flag - key for window
+  \param studyId - study id
+  Flag used how identificator of window in windows list.
+*/
 void LightApp_Application::removeWindow( const int flag, const int studyId )
 {
   if ( !myWindows.contains( flag ) )
@@ -999,18 +1176,21 @@ void LightApp_Application::removeWindow( const int flag, const int studyId )
       sId = activeStudy()->id();
   }
 
+  bool anIsEmpty = !myWindows[flag]->isEmpty();
   QWidget* wid = myWindows[flag]->widget( sId );
   myWindows[flag]->remove( sId );
   delete wid;
 
-  setWindowShown( flag, !myWindows[flag]->isEmpty() );
+  //setWindowShown( flag, !myWindows[flag]->isEmpty() );
+  setWindowShown( flag, anIsEmpty );
 }
 
-/*!Gets window.
- *\param flag - key wor window
- *\param studyId - study id
- * Flag used how identificator of window in windows list.
- */
+/*!
+  Gets window.
+  \param flag - key for window
+  \param studyId - study id
+  Flag used how identificator of window in windows list.
+*/
 QWidget* LightApp_Application::getWindow( const int flag, const int studyId )
 {
   QWidget* wid = window( flag, studyId );
@@ -1020,7 +1200,10 @@ QWidget* LightApp_Application::getWindow( const int flag, const int studyId )
   return wid;
 }
 
-/*!Check is window visible?(with identificator \a type)*/
+/*!
+  \return is window visible
+  \param type - flag of window
+*/
 bool LightApp_Application::isWindowVisible( const int type ) const
 {
   bool res = false;
@@ -1032,10 +1215,11 @@ bool LightApp_Application::isWindowVisible( const int type ) const
   return res;
 }
 
-/*!Sets window show or hide.
- *\param type - window identificator.
- *\param on   - true/false (window show/hide)
- */
+/*!
+  Sets window show or hide.
+  \param type - window identificator.
+  \param on   - true/false (window show/hide)
+*/
 void LightApp_Application::setWindowShown( const int type, const bool on )
 {
   if ( !desktop() || !myWindows.contains( type ) )
@@ -1043,10 +1227,18 @@ void LightApp_Application::setWindowShown( const int type, const bool on )
 
   QDockWindow* dw = myWindows[type];
   desktop()->setAppropriate( dw, on );
-  on ? dw->show() : dw->hide();
+  if( on )
+    dw->show();
+  else if( dw->isShown() )
+  {
+    dw->hide();
+    myWindowsVisible[ type ] = true;
+  }
 }
 
-/*!Gets "ObjectBrowser".*/
+/*!
+  \return Object Browser
+*/
 OB_Browser* LightApp_Application::objectBrowser()
 {
   OB_Browser* ob = 0;
@@ -1056,7 +1248,9 @@ OB_Browser* LightApp_Application::objectBrowser()
   return ob;
 }
 
-/*!Gets "LogWindow".*/
+/*!
+  \return Log Window
+*/
 LogWindow* LightApp_Application::logWindow()
 {
   LogWindow* lw = 0;
@@ -1067,7 +1261,9 @@ LogWindow* LightApp_Application::logWindow()
 }
 
 #ifndef DISABLE_PYCONSOLE
-/*!Get "PythonConsole"*/
+/*!
+  \return Python Console
+*/
 PythonConsole* LightApp_Application::pythonConsole()
 {
   PythonConsole* console = 0;
@@ -1078,12 +1274,19 @@ PythonConsole* LightApp_Application::pythonConsole()
 }
 #endif
 
-/*!Update obect browser*/
+/*!
+  Updates object browser and maybe data models
+  \param updateModels - if it is true, then data models are updated
+*/
 void LightApp_Application::updateObjectBrowser( const bool updateModels )
 {
   // update existing data models
   if ( updateModels ) 
   {
+    const bool isAutoUpdate = objectBrowser() ? objectBrowser()->isAutoUpdate() : true;
+    if( objectBrowser() )
+      objectBrowser()->setAutoUpdate( false );
+
     LightApp_Study* study = dynamic_cast<LightApp_Study*>(activeStudy());
     if ( study ) {
       CAM_Study::ModelList dm_list;
@@ -1094,6 +1297,9 @@ void LightApp_Application::updateObjectBrowser( const bool updateModels )
           ((LightApp_DataModel*)camDM)->update();
       }
     }
+
+    if( objectBrowser() )
+      objectBrowser()->setAutoUpdate( isAutoUpdate );
   }
   if ( objectBrowser() )
   {
@@ -1102,13 +1308,19 @@ void LightApp_Application::updateObjectBrowser( const bool updateModels )
   }
 }
 
-/*!Gets preferences.*/
+/*!
+  \return preferences
+*/
 LightApp_Preferences* LightApp_Application::preferences() const
 {
   return preferences( false );
 }
 
-/*!Gets view manager*/
+/*!
+  \return first view manager of some type
+  \param vmType - type of view manager
+  \param create - is it necessary to create view manager in case, when there is no manager of such type
+*/
 SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, const bool create )
 {
   SUIT_ViewManager* aVM = viewManager( vmType );
@@ -1130,7 +1342,10 @@ SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, c
   return aVM;
 }
 
-/*!Create view manager.*/
+/*!
+  Creates view manager of some type
+  \param vmType - type of view manager
+*/
 SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType )
 {
   SUIT_ResourceMgr* resMgr = resourceMgr();
@@ -1162,15 +1377,17 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType
     }
   }
 #endif
-#ifndef DISABLE_SUPERVGRAPHVIEWER
-  if( vmType == SUPERVGraph_Viewer::Type() )
-  {
-    viewMgr = new SUPERVGraph_ViewManager( activeStudy(), desktop() );
-    SUPERVGraph_Viewer* vm = new SUPERVGraph_Viewer();
-    SUPERVGraph_ViewFrame* view = dynamic_cast<SUPERVGraph_ViewFrame*>( vm->getViewManager()->getActiveView() );
-    if( view )
-      view->setBackgroundColor( resMgr->colorValue( "SUPERVGraph", "Background", view->backgroundColor() ) );
-  }
+  //#ifndef DISABLE_SUPERVGRAPHVIEWER
+  //  if( vmType == SUPERVGraph_Viewer::Type() )
+  //  {
+  //    viewMgr = new SUPERVGraph_ViewManager( activeStudy(), desktop(), new SUPERVGraph_Viewer() );
+  //  }
+  //#endif
+#ifndef DISABLE_QXGRAPHVIEWER
+  if( vmType == QxGraph_Viewer::Type() )
+    {
+      viewMgr = new QxGraph_ViewManager( activeStudy(), desktop(), new QxGraph_Viewer() );
+    }
 #endif
 #ifndef DISABLE_OCCVIEWER
   if( vmType == OCCViewer_Viewer::Type() )
@@ -1183,7 +1400,7 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType
     vm = new OCCViewer_Viewer();
 #endif
     vm->setBackgroundColor( resMgr->colorValue( "OCCViewer", "background", vm->backgroundColor() ) );
-    vm->setTrihedronSize( resMgr->integerValue( "OCCViewer", "trihedron_size", vm->trihedronSize() ) );
+    vm->setTrihedronSize( resMgr->doubleValue( "OCCViewer", "trihedron_size", vm->trihedronSize() ) );
     int u( 1 ), v( 1 );
     vm->isos( u, v );
     u = resMgr->integerValue( "OCCViewer", "iso_number_u", u );
@@ -1206,7 +1423,7 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType
     if( vm )
     {
       vm->setBackgroundColor( resMgr->colorValue( "VTKViewer", "background", vm->backgroundColor() ) );
-      vm->setTrihedronSize( resMgr->integerValue( "VTKViewer", "trihedron_size", vm->trihedronSize() ),
+      vm->setTrihedronSize( resMgr->doubleValue( "VTKViewer", "trihedron_size", vm->trihedronSize() ),
                            resMgr->booleanValue( "VTKViewer", "relative_size", vm->trihedronRelative() ) );
       new LightApp_VTKSelector( vm, mySelMgr );
     }
@@ -1228,22 +1445,21 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType
   if ( viewWin && desktop() )
     viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
 
-  connect( viewMgr, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
-           this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
-
   return viewMgr;
 }
 
-//=======================================================================
-// name    : onCloseView
-/*! Purpose : SLOT. Remove view manager from application*/
-//=======================================================================
+/*!
+  SLOT: Removes view manager from application
+*/
 void LightApp_Application::onCloseView( SUIT_ViewManager* theVM )
 {
   removeViewManager( theVM );
 }
 
-/*!Protected SLOT. On study created.*/
+/*!
+  Protected SLOT: On study created.
+  \param theStudy - just created study
+*/
 void LightApp_Application::onStudyCreated( SUIT_Study* theStudy )
 {
   SUIT_DataObject* aRoot = 0;
@@ -1258,10 +1474,16 @@ void LightApp_Application::onStudyCreated( SUIT_Study* theStudy )
 
   activateModule( defaultModule() );
 
+  if ( objectBrowser() )
+    objectBrowser()->openLevels();
+
   activateWindows();
 }
 
-/*!Protected SLOT. On study opened.*/
+/*!
+  Protected SLOT: On study opened.
+  \param theStudy - just opened  study
+*/
 void LightApp_Application::onStudyOpened( SUIT_Study* theStudy )
 {
   SUIT_DataObject* aRoot = 0;
@@ -1271,12 +1493,14 @@ void LightApp_Application::onStudyOpened( SUIT_Study* theStudy )
     //aRoot->dump();
   }
   getWindow( WT_ObjectBrowser );
-  if ( objectBrowser() != 0 ) {
+  if ( objectBrowser() )
     objectBrowser()->setRootObject( aRoot );
-  }
 
   activateModule( defaultModule() );
 
+  if ( objectBrowser() )
+    objectBrowser()->openLevels();
+
   activateWindows();
 
   emit studyOpened();
@@ -1289,16 +1513,18 @@ void LightApp_Application::onStudySaved( SUIT_Study* )
 }
 
 /*!Protected SLOT. On study closed.*/
-void LightApp_Application::onStudyClosed( SUIT_Study* )
+void LightApp_Application::onStudyClosed( SUIT_Study* )
 {
-  emit studyClosed();
-
   // Bug 10396: clear selection
   mySelMgr->clearSelected();
 
+  // Bug 12944: emit signal only after clear selection
+  emit studyClosed();
+
   activateModule( "" );
 
-  saveWindowsGeometry();
+  for ( WindowMap::ConstIterator itr = myWindows.begin(); s && itr != myWindows.end(); ++itr )
+    removeWindow( itr.key(), s->id() );
 }
 
 /*!Protected SLOT.On desktop activated.*/
@@ -1320,7 +1546,9 @@ QString LightApp_Application::getFileFilter() const
   return "(*.hdf)";
 }
 
-/*! Gets file name*/
+/*!
+  Shows file dialog and return user selected file name
+*/
 QString LightApp_Application::getFileName( bool open, const QString& initial, const QString& filters, 
                                            const QString& caption, QWidget* parent )
 {
@@ -1387,6 +1615,8 @@ void LightApp_Application::onPreferenceChanged( QString& modName, QString& secti
     sMod->preferencesChanged( section, param );
   else
     preferencesChanged( section, param );
+  // emit signal to allow additional preferences changing processing
+  emit preferenceChanged( modName, section, param );
 }
 
 /*!Private SLOT. On open document with name \a aName.*/
@@ -1399,9 +1629,6 @@ void LightApp_Application::onMRUActivated( QString aName )
 void LightApp_Application::beforeCloseDoc( SUIT_Study* s )
 {
   CAM_Application::beforeCloseDoc( s );
-
-  for ( WindowMap::ConstIterator itr = myWindows.begin(); s && itr != myWindows.end(); ++itr )
-    removeWindow( itr.key(), s->id() );
 }
 
 /*!Update actions.*/
@@ -1410,10 +1637,9 @@ void LightApp_Application::updateActions()
   updateCommandsStatus();
 }
 
-//=======================================================================
-// name    : createNewStudy
-/*! Purpose : Create new study*/
-//=======================================================================
+/*!
+  Creates new study
+*/
 SUIT_Study* LightApp_Application::createNewStudy()
 {
   LightApp_Application::lastStudyId++;
@@ -1429,13 +1655,17 @@ SUIT_Study* LightApp_Application::createNewStudy()
   return aStudy;
 }
 
-/*!Create window.*/
+/*!
+  Creates window by flag.
+  \param flag - identificator of window type
+*/
 QWidget* LightApp_Application::createWindow( const int flag )
 {
   QWidget* wid = 0;
   if ( flag == WT_ObjectBrowser )
   {
     OB_Browser* ob = new OB_Browser( desktop() );
+    ob->setSearch( new OB_ObjSearch( ob ) );
     ob->setAutoUpdate( true );
     //ob->setAutoOpenLevel( 1 ); // commented by ASV as a fix to bug IPAL10107
     ob->setCaption( tr( "OBJECT_BROWSER" ) );
@@ -1473,8 +1703,9 @@ QWidget* LightApp_Application::createWindow( const int flag )
   return wid;
 }
 
-/*!Default windows(Object Browser, Python Console).
- * Adds to map \a aMap.
+/*!
+  \return default windows( Object Browser, Python Console )
+  Adds to map \a aMap.
  */
 void LightApp_Application::defaultWindows( QMap<int, int>& aMap ) const
 {  
@@ -1485,15 +1716,16 @@ void LightApp_Application::defaultWindows( QMap<int, int>& aMap ) const
   //  aMap.insert( WT_LogWindow, Qt::DockBottom );
 }
 
-/*!Default view manager.*/
+/*!Default view managers*/
 void LightApp_Application::defaultViewManagers( QStringList& ) const
 {
   /*!Do nothing.*/
 }
 
-/*!Gets preferences.
- * Create preferences, if \a crt = true.
- */
+/*!
+  \return preferences.
+  Create preferences, if \a crt = true.
+*/
 LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const
 {
   if ( myPrefs )
@@ -1550,7 +1782,9 @@ LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const
   return myPrefs;
 }
 
-/*!Add new module to application.*/
+/*!
+  Adds new module to application
+*/
 void LightApp_Application::moduleAdded( CAM_Module* mod )
 {
   CAM_Application::moduleAdded( mod );
@@ -1567,7 +1801,9 @@ void LightApp_Application::moduleAdded( CAM_Module* mod )
   }
 }
 
-/*!Create preferences.*/
+/*!
+  Create preferences
+*/
 void LightApp_Application::createPreferences( LightApp_Preferences* pref )
 {
   if ( !pref )
@@ -1581,14 +1817,17 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref )
 
   pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "multi_file" );
   pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" );
-  int undoPref = pref->addPreference( tr( "PREF_UNDO_LEVEL" ), studyGroup, LightApp_Preferences::IntSpin, "Study", "undo_level" );
-  pref->setItemProperty( undoPref, "min", 1 );
-  pref->setItemProperty( undoPref, "max", 100 );
   pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" );
 
   int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab );
   pref->setItemProperty( extgroup, "columns", 1 );
-  int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, LightApp_Preferences::File, "ExternalBrowser", "application" );
+       QString platform;
+#ifdef WIN32
+       platform = "winapplication";
+#else
+       platform = "application";
+#endif
+  int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, LightApp_Preferences::File, "ExternalBrowser", platform );
   pref->setItemProperty( apppref, "existing", true );
   pref->setItemProperty( apppref, "flags", QFileInfo::ExeUser );
   pref->setItemProperty( apppref, "readOnly", false );
@@ -1614,12 +1853,12 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref )
   pref->setItemProperty( plot2dGroup, "columns", 1 );
 
   int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occGroup,
-                                  LightApp_Preferences::IntSpin, "OCCViewer", "trihedron_size" );
+                                  LightApp_Preferences::DblSpin, "OCCViewer", "trihedron_size" );
   pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup,
                       LightApp_Preferences::Color, "OCCViewer", "background" );
 
-  pref->setItemProperty( occTS, "min", 1 );
-  pref->setItemProperty( occTS, "max", 150 );
+  pref->setItemProperty( occTS, "min", 1.0E-06 );
+  pref->setItemProperty( occTS, "max", 1000 );
 
   int isoU = pref->addPreference( tr( "PREF_ISOS_U" ), occGroup,
                                  LightApp_Preferences::IntSpin, "OCCViewer", "iso_number_u" );
@@ -1633,12 +1872,12 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref )
   pref->setItemProperty( isoV, "max", 100000 );
 
   int vtkTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), vtkGroup,
-                                  LightApp_Preferences::IntSpin, "VTKViewer", "trihedron_size" );
+                                  LightApp_Preferences::DblSpin, "VTKViewer", "trihedron_size" );
   pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), vtkGroup, LightApp_Preferences::Bool, "VTKViewer", "relative_size" );
   pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGroup,
                       LightApp_Preferences::Color, "VTKViewer", "background" );
 
-  pref->setItemProperty( vtkTS, "min", 1 );
+  pref->setItemProperty( vtkTS, "min", 1.0E-06 );
   pref->setItemProperty( vtkTS, "max", 150 );
 
   pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dGroup,
@@ -1726,7 +1965,11 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref )
                       "ObjectBrowser", "auto_size" );
 }
 
-/*!Changed preferences */
+/*!
+  Changes appearance of application according to changed preferences
+  \param sec - section
+  \param param - name of changed parameter
+*/
 void LightApp_Application::preferencesChanged( const QString& sec, const QString& param )
 {
   SUIT_ResourceMgr* resMgr = resourceMgr();
@@ -1736,7 +1979,7 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString
 #ifndef DISABLE_OCCVIEWER
   if ( sec == QString( "OCCViewer" ) && param == QString( "trihedron_size" ) )
   {
-    int sz = resMgr->integerValue( sec, param, -1 );
+    double sz = resMgr->doubleValue( sec, param, -1 );
     QPtrList<SUIT_ViewManager> lst;
     viewManagers( OCCViewer_Viewer::Type(), lst );
     for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current() && sz >= 0; ++it )
@@ -1755,7 +1998,7 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString
 #ifndef DISABLE_VTKVIEWER
   if ( sec == QString( "VTKViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )) )
   {
-    int sz = resMgr->integerValue( "VTKViewer", "trihedron_size", -1 );
+    double sz = resMgr->doubleValue( "VTKViewer", "trihedron_size", -1 );
     bool isRelative = resMgr->booleanValue( "VTKViewer", "relative_size", true );
     QPtrList<SUIT_ViewManager> lst;
 #ifndef DISABLE_SALOMEOBJECT
@@ -1805,6 +2048,10 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString
            autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
       ob->setWidthMode( autoSize ? QListView::Maximum : QListView::Manual );
       ob->listView()->setColumnWidthMode( 0, autoSizeFirst ? QListView::Maximum : QListView::Manual );
+      if( autoSize )
+       for( int i=1; i<ob->listView()->columns(); i++ )
+         if( ob->listView()->columnWidth( i )>0 )
+           ob->listView()->adjustColumn( i );
       updateObjectBrowser( false );
     }
   }
@@ -1825,7 +2072,9 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString
 #endif
 }
 
-/*!Save preferences */
+/*!
+  Saves preferences
+*/
 void LightApp_Application::savePreferences()
 {
   saveWindowsGeometry();
@@ -1838,7 +2087,9 @@ void LightApp_Application::savePreferences()
     }
 }
 
-/*!Update desktop title.*/
+/*!
+  Updates desktop title
+*/
 void LightApp_Application::updateDesktopTitle() {
   QString aTitle = applicationName();
   QString aVer = applicationVersion();
@@ -1853,7 +2104,42 @@ void LightApp_Application::updateDesktopTitle() {
   desktop()->setCaption( aTitle );
 }
 
-/*!Update windows after close document.*/
+/*!
+  \brief Get module activation actions
+  \return map <action_id><action_name> where
+  - action_id is unique non-zero action identifier
+  - action_name is action title
+  \sa moduleActionSelected()
+*/
+QMap<int, QString> LightApp_Application::activateModuleActions() const
+{
+  QMap<int, QString> opmap;
+  opmap.insert( NewStudyId,  tr( "ACTIVATE_MODULE_OP_NEW" ) );
+  opmap.insert( OpenStudyId, tr( "ACTIVATE_MODULE_OP_OPEN" ) );
+  return opmap;
+}
+
+/*!
+  \brief Process module activation action.
+  \param id action identifier
+  \sa activateModuleActions()
+*/
+void LightApp_Application::moduleActionSelected( const int id )
+{
+  switch ( id ) {
+  case NewStudyId:
+    onNewDoc();
+    break;
+  case OpenStudyId:
+    onOpenDoc();
+    break;
+  default:
+    break;
+  }
+}
+/*!
+  Updates windows after close document
+*/
 void LightApp_Application::afterCloseDoc()
 {
   updateWindows();
@@ -1861,7 +2147,9 @@ void LightApp_Application::afterCloseDoc()
   CAM_Application::afterCloseDoc();
 }
 
-/*!Update module action.*/
+/*!
+  Updates actions of active module
+*/
 void LightApp_Application::updateModuleActions()
 {
   QString modName;
@@ -1872,9 +2160,10 @@ void LightApp_Application::updateModuleActions()
     myActions[modName]->setOn( true );
 }
 
-/*!Gets current windows.
- *\param winMap - output current windows map.
- */
+/*!
+  Gets current windows.
+  \param winMap - output current windows map.
+*/
 void LightApp_Application::currentWindows( QMap<int, int>& winMap ) const
 {
   winMap.clear();
@@ -1887,9 +2176,10 @@ void LightApp_Application::currentWindows( QMap<int, int>& winMap ) const
     defaultWindows( winMap );
 }
 
-/*!Gets current view managers.
- *\param lst - output current view managers list.
- */
+/*!
+  Gets current view managers.
+  \param lst - output current view managers list.
+*/
 void LightApp_Application::currentViewManagers( QStringList& lst ) const
 {
   lst.clear();
@@ -1902,26 +2192,43 @@ void LightApp_Application::currentViewManagers( QStringList& lst ) const
     defaultViewManagers( lst );
 }
 
-/*!Update windows.*/
+/*!
+  Updates windows
+*/
 void LightApp_Application::updateWindows()
 {
   QMap<int, int> winMap;
   currentWindows( winMap );
 
   if ( activeStudy() ) {
-    for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
-      getWindow( it.key() );
+    for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it ) {
+      getWindow( it.key() ); 
+      
+      Dock dock; int index, extraOffset; bool nl;
+      if ( desktop()->getLocation( myWindows[it.key()], dock, index, nl, extraOffset )
+          &&
+          dock != (Dock)it.data() )
+       desktop()->moveDockWindow( myWindows[it.key()], (Dock)it.data() );
+    }
 
     loadWindowsGeometry();
   }
 
   // setWindowShown should be done even if no study is active (open). in this case all open windows
   // will be hidden, which is neccessary in this case.
-  for ( WindowMap::ConstIterator itr = myWindows.begin(); itr != myWindows.end(); ++itr )
+  for ( WindowMap::ConstIterator itr = myWindows.begin(); itr != myWindows.end(); ++itr ) {
+    
+    if ( myWindowsVisible.contains( itr.key() ) && 
+        !myWindowsVisible[ itr.key() ] )
+      continue;
+
     setWindowShown( itr.key(), !itr.data()->isEmpty() && winMap.contains( itr.key() ) );
+  }
 }
 
-/*!Update view managers.*/
+/*!
+  Updates view managers
+*/
 void LightApp_Application::updateViewManagers()
 {
   QStringList lst;
@@ -1931,7 +2238,9 @@ void LightApp_Application::updateViewManagers()
     getViewManager( *it, true );
 }
 
-/*!Load windows geometry.*/
+/*!
+  Loads windows geometry
+*/
 void LightApp_Application::loadWindowsGeometry()
 {
   bool store = resourceMgr()->booleanValue( "Study", "store_positions", true );
@@ -1959,7 +2268,9 @@ void LightApp_Application::loadWindowsGeometry()
   dockMgr->restoreGeometry();
 }
 
-/*!Save windows geometry.*/
+/*!
+  Saves windows geometry
+*/
 void LightApp_Application::saveWindowsGeometry()
 {
   bool store = resourceMgr()->booleanValue( "Study", "store_positions", true );
@@ -1987,7 +2298,9 @@ void LightApp_Application::saveWindowsGeometry()
   dockMgr->saveGeometry( resourceMgr(), section, false );
 }
 
-/*!Activate windows.*/
+/*!
+  Activates windows
+*/
 void LightApp_Application::activateWindows()
 {
   if ( activeStudy() )
@@ -1997,7 +2310,9 @@ void LightApp_Application::activateWindows()
   }
 }
 
-/*!Adds icon names for modules.*/
+/*!
+  Adds icon names for modules
+*/
 void LightApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) const
 {
   iconMap.clear();
@@ -2025,7 +2340,9 @@ void LightApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) co
   }
 }
 
-/*!Insert items in popup, which necessary for current application*/
+/*!
+  Inserts items in popup, which necessary for current application
+*/
 void LightApp_Application::contextMenuPopup( const QString& type, QPopupMenu* thePopup, QString& title )
 {
   CAM_Application::contextMenuPopup( type, thePopup, title );
@@ -2036,9 +2353,12 @@ void LightApp_Application::contextMenuPopup( const QString& type, QPopupMenu* th
 
   thePopup->insertSeparator();
   thePopup->insertItem( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
+  thePopup->insertItem( tr( "MEN_FIND" ), this, SLOT( onFind() ) );
 }
 
-/*!Create empty study.*/
+/*!
+  Create empty study
+*/
 void LightApp_Application::createEmptyStudy()
 {
   CAM_Application::createEmptyStudy();
@@ -2046,7 +2366,10 @@ void LightApp_Application::createEmptyStudy()
     objectBrowser()->updateTree();
 }
 
-/*!Activate module \a mod.*/
+/*!
+  Activates module
+  \param mod - module to be activated
+*/
 bool LightApp_Application::activateModule( CAM_Module* mod )
 {
   bool res = CAM_Application::activateModule( mod );
@@ -2055,13 +2378,17 @@ bool LightApp_Application::activateModule( CAM_Module* mod )
   return res;
 }
 
-/*!return keyborad accelerators manager object */
+/*!
+  \return keyborad accelerators manager object
+*/
 SUIT_Accel* LightApp_Application::accel() const
 {
   return myAccel;
 }
 
-/*! remove dead widget container from map */
+/*!
+  Removes dead widget container from map
+*/
 void LightApp_Application::onWCDestroyed( QObject* ob )
 {
   // remove destroyed widget container from windows map
@@ -2076,7 +2403,19 @@ void LightApp_Application::onWCDestroyed( QObject* ob )
   }
 }
 
-/*! redefined to remove view manager from memory */
+/*!
+  Connects just added view manager
+*/
+void LightApp_Application::addViewManager( SUIT_ViewManager* vm )
+{
+  connect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
+           this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
+  STD_Application::addViewManager( vm );
+}
+
+/*!
+  Remove view manager from memory
+*/
 void LightApp_Application::removeViewManager( SUIT_ViewManager* vm )
 {
   disconnect( vm, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
@@ -2085,7 +2424,9 @@ void LightApp_Application::removeViewManager( SUIT_ViewManager* vm )
   delete vm;
 }
 
-/*! rename active window of desktop */
+/*!
+  Renames active window of desktop
+*/
 void LightApp_Application::onRenameWindow()
 {
   if( !desktop() )
@@ -2101,12 +2442,20 @@ void LightApp_Application::onRenameWindow()
     w->setCaption( name );
 }
 
+/*!
+  \return if the library of module exists
+  \param moduleTitle - title of module
+*/
 bool LightApp_Application::isLibExists( const QString& moduleTitle ) const
 {
   if( moduleTitle.isEmpty() )
     return false;
 
   QString lib = moduleLibrary( moduleTitle );
+  
+  //abd: changed libSalomePyQtGUI to SalomePyQtGUI for WIN32
+  bool isPythonModule = lib.contains("SalomePyQtGUI");
+
   QStringList paths;
 #ifdef WIN32
   paths = QStringList::split( ";", ::getenv( "PATH" ) );
@@ -2114,17 +2463,72 @@ bool LightApp_Application::isLibExists( const QString& moduleTitle ) const
   paths = QStringList::split( ":", ::getenv( "LD_LIBRARY_PATH" ) );
 #endif
 
+  bool isLibFound = false;
   QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
   for( ; anIt!=aLast; anIt++ )
   {
     QFileInfo inf( Qtx::addSlash( *anIt ) + lib );
+    
     if( inf.exists() )
+      {
+       isLibFound = true;
+       break;
+      }
+  }
+  
+  if ( !isLibFound )
+    {
+      printf( "****************************************************************\n" );
+      printf( "*    Warning: library %s cannot be found\n", lib.latin1() );
+      printf( "*    Module %s will not be available in GUI mode\n", moduleTitle.latin1() );
+      printf( "****************************************************************\n" );
+    }
+  else if ( !isPythonModule )
+    return true;
+
+  if ( isPythonModule )
+    {
+      QString pylib = moduleName( moduleTitle ) + QString(".py");
+      QString pylibgui = moduleName( moduleTitle ) + QString("GUI.py");
+
+      // Check the python library
+#ifdef WIN32
+      paths = QStringList::split( ";", ::getenv( "PATH" ) );
+#else
+      paths = QStringList::split( ":", ::getenv( "PYTHONPATH" ) );
+#endif
+      bool isPyLib = false, isPyGuiLib = false;
+      QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
+      for( ; anIt!=aLast; anIt++ )
+       {
+         QFileInfo inf( Qtx::addSlash( *anIt ) + pylib );
+         QFileInfo infgui( Qtx::addSlash( *anIt ) + pylibgui );
+    
+         if( !isPyLib && inf.exists() )
+           isPyLib = true;
+         
+         if( !isPyGuiLib && infgui.exists() )
+           isPyGuiLib = true;
+         
+         if ( isPyLib && isPyGuiLib && isLibFound)
+           return true;
+       }
+      
+      printf( "****************************************************************\n" );
+      printf( "*    Warning: python library for %s cannot be found:\n", moduleTitle.latin1() );
+      if (!isPyLib)
+       printf( "*    No module named %s\n", moduleName( moduleTitle ).latin1() );
+      if (!isPyGuiLib)
+       printf( "*    No module named %s\n", (moduleName( moduleTitle ) + QString("GUI")).latin1() );
+      printf( "****************************************************************\n" );
       return true;
   }
   return false;
 }
 
-/*! default name for an active study */
+/*!
+  \return default name for an active study
+*/
 void LightApp_Application::setDefaultStudyName( const QString& theName )
 {
   QStringList anInfoList;
@@ -2138,3 +2542,55 @@ void LightApp_Application::setDefaultStudyName( const QString& theName )
     updateDesktopTitle();
   }
 }
+
+/*! slot, called on show/hide of a dock window */
+void LightApp_Application::onVisibilityChanged( bool visible )
+{
+  const QObject* win = sender();
+  for ( WindowMap::ConstIterator itr = myWindows.begin(); itr != myWindows.end(); ++itr )
+    if ( itr.data() == win ) 
+    {
+      myWindowsVisible[ itr.key() ] = visible;
+      return;
+    }
+}
+
+/*!
+  Custom event handler
+*/
+bool LightApp_Application::event( QEvent* e )
+{
+  if( e && e->type()==2000 )
+  {
+    QCustomEvent* ce = ( QCustomEvent* )e;
+    QString* d = ( QString* )ce->data();
+    if( SUIT_MessageBox::warn2(0, tr("WRN_WARNING"),
+                          d ? *d : "",
+                          tr("BUT_OK"), tr("BUT_CANCEL"), 0, 1, 0 )==0 )
+       onPreferences();
+    if( d )
+      delete d;
+    return true;
+  }
+  return CAM_Application::event( e );
+}
+
+/*! Check data object */
+bool LightApp_Application::checkDataObject(LightApp_DataObject* theObj)
+{
+  if (theObj)
+    {
+      bool isSuitable =        !theObj->entry().isEmpty() && 
+                       !theObj->componentDataType().isEmpty() && 
+                       !theObj->name().isEmpty();
+      return isSuitable;
+    }
+
+  return false;
+}
+
+void LightApp_Application::onFind()
+{
+  objectBrowser()->enableSearch( true );
+}