+// 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
// Copyright (C) CEA 2005
-#include "PythonConsole_PyInterp.h" // WARNING! This include must be the first!
+#ifndef DISABLE_PYCONSOLE
+ #include "PythonConsole_PyInterp.h" // WARNING! This include must be the first!
+ #include <PythonConsole_PyConsole.h>
+#endif
#include "LightApp_Application.h"
#include "LightApp_WidgetContainer.h"
#include "LightApp_OBFilter.h"
-#include "LightApp_GLSelector.h"
+#include "LightApp_EventFilter.h"
+
#include "LightApp_OBSelector.h"
-#include "LightApp_OCCSelector.h"
-#include "LightApp_VTKSelector.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 <PythonConsole_PyConsole.h>
-
-#include <GLViewer_Viewer.h>
-#include <GLViewer_ViewManager.h>
-
-#include <Plot2d_ViewManager.h>
-#include <Plot2d_ViewModel.h>
-#include <SPlot2d_ViewModel.h>
-
-#include <OCCViewer_ViewManager.h>
-#include <SOCC_ViewModel.h>
-
-#include <SVTK_ViewModel.h>
-#include <SVTK_ViewManager.h>
-#include <VTKViewer_ViewModel.h>
-
-#include <SUPERVGraph_ViewModel.h>
-#include <SUPERVGraph_ViewFrame.h>
-#include <SUPERVGraph_ViewManager.h>
+#include <OB_ListView.h>
+#include <OB_ObjSearch.h>
+
+#ifndef DISABLE_GLVIEWER
+ #include <GLViewer_Viewer.h>
+ #include <GLViewer_ViewManager.h>
+ #include "LightApp_GLSelector.h"
+#endif
+
+#ifndef DISABLE_PLOT2DVIEWER
+ #include <Plot2d_ViewManager.h>
+ #include <Plot2d_ViewModel.h>
+#ifndef DISABLE_SALOMEOBJECT
+ #include <SPlot2d_ViewModel.h>
+#else
+ #include <Plot2d_ViewModel.h>
+#endif
+#endif
+
+#ifndef DISABLE_OCCVIEWER
+ #include <OCCViewer_ViewManager.h>
+#ifndef DISABLE_SALOMEOBJECT
+ #include <SOCC_ViewModel.h>
+#else
+ #include <OCCViewer_ViewModel.h>
+#endif
+ #include "LightApp_OCCSelector.h"
+#endif
+
+#ifndef DISABLE_VTKVIEWER
+#ifndef DISABLE_SALOMEOBJECT
+ #include <SVTK_ViewModel.h>
+ #include <SVTK_ViewManager.h>
+ #include "LightApp_VTKSelector.h"
+#else
+ #include <VTKViewer_ViewModel.h>
+ #include <VTKViewer_ViewManager.h>
+#endif
+ #include <VTKViewer_ViewModel.h>
+#endif
+
+//#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 <qdir.h>
#include <qimage.h>
#include <qmap.h>
#include <qstatusbar.h>
#include <qthread.h>
-
-#define OBJECT_BROWSER_WIDTH 300
-#define OBJECT_COLUMN_WIDTH 150
-
-#define DEFAULT_BROWSER "mozilla"
+#include <qobjectlist.h>
+#include <qcombobox.h>
+#include <qinputdialog.h>
+#include <qmessagebox.h>
+#include <qfontdatabase.h>
#define FIRST_HELP_ID 1000000
-#include "SALOME_InteractiveObject.hxx"
-#include "SALOME_ListIO.hxx"
+#ifndef DISABLE_SALOMEOBJECT
+ #include "SALOME_InteractiveObject.hxx"
+ #include "SALOME_ListIO.hxx"
+#endif
static const char* imageEmptyIcon[] = {
"20 20 1 1",
"....................",
"...................."};
+int LightApp_Application::lastStudyId = 0;
+
+/*!
+ \return last global id of study
+*/
+int LightApp_Application::studyId()
+{
+ return LightApp_Application::lastStudyId;
+}
+
/*!Create new instance of LightApp_Application.*/
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.*/
mySelMgr = new LightApp_SelectionMgr( this );
- myAccel = new SUIT_Accel( desktop() );
+ myAccel = SUIT_Accel::getAccel();
+
+#ifndef DISABLE_OCCVIEWER
myAccel->setActionKey( SUIT_Accel::PanLeft, CTRL+Key_Left, OCCViewer_Viewer::Type() );
myAccel->setActionKey( SUIT_Accel::PanRight, CTRL+Key_Right, OCCViewer_Viewer::Type() );
myAccel->setActionKey( SUIT_Accel::PanUp, CTRL+Key_Up, OCCViewer_Viewer::Type() );
myAccel->setActionKey( SUIT_Accel::RotateRight, ALT+Key_Right, OCCViewer_Viewer::Type() );
myAccel->setActionKey( SUIT_Accel::RotateUp, ALT+Key_Up, OCCViewer_Viewer::Type() );
myAccel->setActionKey( SUIT_Accel::RotateDown, ALT+Key_Down, OCCViewer_Viewer::Type() );
+#endif
+#ifndef DISABLE_VTKVIEWER
myAccel->setActionKey( SUIT_Accel::PanLeft, CTRL+Key_Left, VTKViewer_Viewer::Type() );
myAccel->setActionKey( SUIT_Accel::PanRight, CTRL+Key_Right, VTKViewer_Viewer::Type() );
myAccel->setActionKey( SUIT_Accel::PanUp, CTRL+Key_Up, VTKViewer_Viewer::Type() );
myAccel->setActionKey( SUIT_Accel::RotateRight, ALT+Key_Right, VTKViewer_Viewer::Type() );
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.
*/
LightApp_Application::~LightApp_Application()
{
- saveWindowsGeometry();
-
- if ( resourceMgr() )
- {
- if ( desktop() )
- desktop()->saveGeometry( resourceMgr(), "desktop" );
- resourceMgr()->save();
- }
delete mySelMgr;
}
putInfo( "" );
desktop()->statusBar()->message( "" );
+
+ LightApp_EventFilter::Init();
}
/*!Gets application name.*/
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();
return mySelMgr;
}
+/*!Creat action "New window" for certain type of viewer:*/
+void LightApp_Application::createActionForViewer( const int id,
+ const int parentId,
+ const QString& suffix,
+ const int accel )
+{
+ QAction* a = createAction( id, tr( QString( "NEW_WINDOW_%1" ).arg( suffix ) ), QIconSet(),
+ tr( QString( "NEW_WINDOW_%1" ).arg( suffix ) ),
+ tr( QString( "NEW_WINDOW_%1" ).arg( suffix ) ),
+ accel, desktop(), false, this, SLOT( onNewWindow() ) );
+ createMenu( a, parentId, -1 );
+}
+
/*!Create actions:*/
void LightApp_Application::createActions()
{
//! Preferences
createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIconSet(),
tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
- CTRL+Key_P, desk, false, this, SLOT( onPreferences() ) );
+ CTRL+Key_F, desk, false, this, SLOT( onPreferences() ) );
//! Help for modules
int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
int id = LightApp_Application::UserID + FIRST_HELP_ID;
// help for KERNEL and GUI
QCString dir;
+ QString aFileName = "index.html";
+ QString root;
QAction* a;
if (dir = getenv("GUI_ROOT_DIR")) {
- a = createAction( id, tr( QString("Kernel & GUI Help") ), QIconSet(),
- tr( QString("Kernel && GUI Help") ),
- tr( QString("Kernel & GUI Help") ),
- 0, desk, false, this, SLOT( onHelpContentsModule() ) );
- a->setName( QString("GUI") );
- createMenu( a, helpModuleMenu, -1 );
- id++;
+ 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("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
- for ( QStringList::Iterator it = aModuleList.begin(); it != aModuleList.end(); ++it )
+ QStringList::Iterator it;
+ for ( it = aModuleList.begin(); it != aModuleList.end(); ++it )
{
if ( (*it).isEmpty() )
continue;
QString modName = moduleName( *it );
- if ( modName.compare("GEOM") == 0 ) { // to be removed when documentation for other modules will be done
- QAction* a = createAction( id, tr( moduleTitle(modName) + QString(" Help") ), QIconSet(),
- tr( moduleTitle(modName) + QString(" Help") ),
- tr( moduleTitle(modName) + QString(" Help") ),
- 0, desk, false, this, SLOT( onHelpContentsModule() ) );
- a->setName( modName );
- createMenu( a, helpModuleMenu, -1 );
- id++;
+
+ if (dir = getenv( modName + "_ROOT_DIR")) {
+ 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(),
+ tr( moduleTitle(modName) + QString(" Help") ),
+ tr( moduleTitle(modName) + QString(" Help") ),
+ 0, desk, false, this, SLOT( onHelpContentsModule() ) );
+ a->setName( modName );
+ createMenu( a, helpModuleMenu, -1 );
+ id++;
+ }
}
}
if ( modIcon.isNull() )
modIcon = QPixmap( imageEmptyIcon );
- QToolBar* modTBar = new QtxToolBar( true, desk );
- modTBar->setLabel( tr( "INF_TOOLBAR_MODULES" ) );
+ QStringList modList;
+ modules( modList, false );
- QActionGroup* modGroup = new QActionGroup( this );
- modGroup->setExclusive( true );
- modGroup->setUsesDropDown( true );
+ if( modList.count()>1 )
+ {
+ QToolBar* modTBar = new QtxToolBar( true, desk );
+ modTBar->setLabel( tr( "INF_TOOLBAR_MODULES" ) );
- a = createAction( -1, tr( "APP_NAME" ), defIcon, tr( "APP_NAME" ),
- tr( "PRP_APP_MODULE" ), 0, desk, true );
- modGroup->add( a );
- myActions.insert( QString(), a );
+ QActionGroup* modGroup = new QActionGroup( this );
+ modGroup->setExclusive( true );
+ modGroup->setUsesDropDown( true );
- QMap<QString, QString> iconMap;
- moduleIconNames( iconMap );
+ a = createAction( -1, tr( "APP_NAME" ), defIcon, tr( "APP_NAME" ),
+ tr( "PRP_APP_MODULE" ), 0, desk, true );
+ modGroup->add( a );
+ myActions.insert( QString(), a );
- const int iconSize = 20;
+ QMap<QString, QString> iconMap;
+ moduleIconNames( iconMap );
- modGroup->addTo( modTBar );
- modTBar->addSeparator();
+ const int iconSize = 20;
- QStringList modList;
- modules( modList, false );
+ 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;
+
+ modTBar->addSeparator();
- for ( QStringList::Iterator it = modList.begin(); it != modList.end(); ++it )
- {
- if ( (*it).isEmpty() )
- 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, 100 );
+ int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, MenuWindowId, 100 );
int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
createMenu( separator(), windowMenu, -1, 1 );
- QMap<int, int> accelMap;
- accelMap[NewGLViewId] = ALT+Key_G;
- accelMap[NewPlot2dId] = ALT+Key_P;
- accelMap[NewOCCViewId] = ALT+Key_O;
- accelMap[NewVTKViewId] = ALT+Key_K;
- for ( int id = NewGLViewId; id <= NewVTKViewId; id++ )
- {
- QAction* a = createAction( id, tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ), QIconSet(),
- tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ),
- tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ),
- accelMap.contains( id ) ? accelMap[id] : 0, desk, false, this, SLOT( onNewWindow() ) );
- createMenu( a, newWinMenu, -1 );
- }
+#ifndef DISABLE_GLVIEWER
+ createActionForViewer( NewGLViewId, newWinMenu, QString::number( 0 ), ALT+Key_G );
+#endif
+#ifndef DISABLE_PLOT2DVIEWER
+ createActionForViewer( NewPlot2dId, newWinMenu, QString::number( 1 ), ALT+Key_P );
+#endif
+#ifndef DISABLE_OCCVIEWER
+ createActionForViewer( NewOCCViewId, newWinMenu, QString::number( 2 ), ALT+Key_O );
+#endif
+#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
+
- connect( modGroup, SIGNAL( selected( QAction* ) ), this, SLOT( onModuleActivation( QAction* ) ) );
+ 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 );
int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
createMenu( PreferencesId, fileMenu, 15, -1 );
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;
int id = actionId( (QAction*)obj );
switch ( id )
{
+#ifndef DISABLE_GLVIEWER
case NewGLViewId:
type = GLViewer_Viewer::Type();
break;
+#endif
+#ifndef DISABLE_PLOT2DVIEWER
case NewPlot2dId:
type = Plot2d_Viewer::Type();
break;
+#endif
+#ifndef DISABLE_OCCVIEWER
case NewOCCViewId:
type = OCCViewer_Viewer::Type();
break;
+#endif
+#ifndef DISABLE_VTKVIEWER
case NewVTKViewId:
type = VTKViewer_Viewer::Type();
break;
+#endif
+#ifndef DISABLE_QXGRAPHVIEWER
+ case NewQxGraphViewId:
+ type = QxGraph_Viewer::Type();
+ break;
+#endif
}
if ( !type.isEmpty() )
createViewManager( type );
}
-//=======================================================================
-// name : onNewDoc
-/*! Purpose : SLOT. Create new document*/
-//=======================================================================
+/*!
+ SLOT: Creates new document
+*/
void LightApp_Application::onNewDoc()
{
SUIT_Study* study = activeStudy();
}
}
-//=======================================================================
-// name : onOpenDoc
-/*! Purpose : SLOT. Open new document*/
-//=======================================================================
+/*!
+ SLOT: Opens new document
+*/
void LightApp_Application::onOpenDoc()
{
SUIT_Study* study = activeStudy();
}
#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;
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() );
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 );
return res;
}
-/*!Private SLOT. Selection.*/
+/*!
+ Private SLOT: Called on selection is changed
+ Dispatchs active module that selection is changed
+*/
void LightApp_Application::onSelection()
{
onSelectionChanged();
((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 );
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();
-
- for ( int id = NewGLViewId; id <= NewVTKViewId; id++ )
- {
- QAction* a = action( id );
- if ( a )
- a->setEnabled( activeStudy() );
- }
-}
-
-// Helps to execute command
-class RunBrowser: public QThread {
+ QAction* a = 0;
+
+#ifndef DISABLE_GLVIEWER
+ a = action( NewGLViewId );
+ if( a )
+ a->setEnabled( activeStudy() );
+#endif
+
+#ifndef DISABLE_PLOT2DVIEWER
+ a = action( NewPlot2dId );
+ if( a )
+ a->setEnabled( activeStudy() );
+#endif
+
+#ifndef DISABLE_OCCVIEWER
+ a = action( NewOCCViewId );
+ if( a )
+ a->setEnabled( activeStudy() );
+#endif
+
+#ifndef DISABLE_VTKVIEWER
+ a = action( NewVTKViewId );
+ if( a )
+ a->setEnabled( activeStudy() );
+#endif
+
+#ifndef DISABLE_QXGRAPHVIEWER
+ a = action( NewQxGraphViewId );
+ if( a )
+ a->setEnabled( activeStudy() );
+#endif
+}
+
+/*!
+ \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), myHelpFile("file:" + theHelpFile + theContext), myStatus(0) {};
+ 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),
+ 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 (!myApp.isEmpty())
+ {
+ //aCommand.sprintf("%s %s %s",myApp.latin1(),myParams.latin1(),myHelpFile.latin1());
- if( myStatus != 0 || myApp.isEmpty())
+ //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())
{
- myParams = "";
- aCommand.sprintf("%s %s %s", QString(DEFAULT_BROWSER).latin1(),myParams.latin1(), myHelpFile.latin1());
- myStatus = system(aCommand);
- if(myStatus != 0)
- {
- QCustomEvent* ce2001 = new QCustomEvent (2001);
- postEvent (qApp, ce2001);
- }
+ 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:
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.lower() + ".htm";
+ QString aFileName = "index.html";
- QCString dir;
- QString root;
- QString homeDir;
- if (dir = getenv( aComponentName + "_ROOT_DIR")) {
- root = Qtx::addSlash( Qtx::addSlash(dir) + Qtx::addSlash("doc") + Qtx::addSlash("salome") + Qtx::addSlash(aComponentName));
- if ( QFileInfo( root + aFileName ).exists() ) {
- homeDir = root;
- } else {
- SUIT_MessageBox::warn1( desktop(), tr("WRN_WARNING"),
- QString( "%1"+ aFileName + " doesn't exist." ).arg(root), tr ("BUT_OK") );
- return;
- }
+ QCString dir = getenv( aComponentName + "_ROOT_DIR");
+ 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 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();
+ }
+}
- QString helpFile = QFileInfo( homeDir + aFileName ).absFilePath();
+/*!
+ 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 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");
- RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile);
- rs->start();
+ 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.*/
+/*!
+ 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;
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 )
QMap<int, int> winMap;
currentWindows( winMap );
- myWindows.insert( flag, new LightApp_WidgetContainer( flag, desktop() ) );
+ 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] );
myWindows[flag]->setResizeEnabled( true );
myWindows[flag]->setCloseMode( QDockWindow::Always );
myWindows[flag]->setName( QString( "dock_window_%1" ).arg( flag ) );
+ myWindows[flag]->setFixedExtentWidth( wid->width() );
+ myWindows[flag]->setFixedExtentHeight( wid->height() );
}
QFont f;
+#ifndef DISABLE_PYCONSOLE
if( wid->inherits( "PythonConsole" ) )
- f = ( ( PythonConsole* )wid )->font();
+ {
+ if( resourceMgr()->hasValue( "PyConsole", "font" ) )
+ f = resourceMgr()->fontValue( "PyConsole", "font" );
+ else
+ {
+ f = ( ( PythonConsole* )wid )->font();
+ resourceMgr()->setValue( "PyConsole", "font", f );
+ }
+ }
else
+#endif
f = wid->font();
myWindows[flag]->insert( sId, wid );
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 ) )
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 );
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;
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 ) )
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;
- QWidget* wid = getWindow( WT_ObjectBrowser );
- if ( wid->inherits( "OB_Browser" ) )
+ QWidget* wid = window( WT_ObjectBrowser );
+ if ( wid && wid->inherits( "OB_Browser" ) )
ob = (OB_Browser*)wid;
return ob;
}
-/*!Gets "LogWindow".*/
+/*!
+ \return Log Window
+*/
LogWindow* LightApp_Application::logWindow()
{
LogWindow* lw = 0;
return lw;
}
-/*!Get "PythonConsole"*/
+#ifndef DISABLE_PYCONSOLE
+/*!
+ \return Python Console
+*/
PythonConsole* LightApp_Application::pythonConsole()
{
PythonConsole* console = 0;
console = (PythonConsole*)wid;
return console;
}
+#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;
((LightApp_DataModel*)camDM)->update();
}
}
+
+ if( objectBrowser() )
+ objectBrowser()->setAutoUpdate( isAutoUpdate );
}
if ( objectBrowser() )
{
objectBrowser()->updateGeometry();
- objectBrowser()->updateTree();
+ objectBrowser()->updateTree( 0, false );
}
}
-/*!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 );
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();
SUIT_ViewManager* viewMgr = 0;
+#ifndef DISABLE_GLVIEWER
if( vmType == GLViewer_Viewer::Type() )
{
viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() );
new LightApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
}
- else if( vmType == Plot2d_Viewer::Type() )
+#endif
+#ifndef DISABLE_PLOT2DVIEWER
+ if( vmType == Plot2d_Viewer::Type() )
{
viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
- SPlot2d_Viewer* vm = new SPlot2d_Viewer();
+ Plot2d_Viewer* vm;
+#ifndef DISABLE_SALOMEOBJECT
+ vm = new SPlot2d_Viewer();
+#else
+ vm = new Plot2d_Viewer();
+#endif
viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
if( wnd )
frame->setBackgroundColor( resMgr->colorValue( "Plot2d", "Background", frame->backgroundColor() ) );
}
}
- else 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() ) );
- }
- else if( vmType == OCCViewer_Viewer::Type() )
+#endif
+ //#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() )
{
viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
- SOCC_Viewer* vm = new SOCC_Viewer();
+ OCCViewer_Viewer* vm;
+#ifndef DISABLE_SALOMEOBJECT
+ vm = new SOCC_Viewer();
+#else
+ 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 );
viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
}
- else if ( vmType == SVTK_Viewer::Type() )
+#endif
+#ifndef DISABLE_VTKVIEWER
+#ifndef DISABLE_SALOMEOBJECT
+ if ( vmType == SVTK_Viewer::Type() )
+#else
+ if ( vmType == VTKViewer_Viewer::Type() )
+#endif
{
+#ifndef DISABLE_SALOMEOBJECT
viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
SVTK_Viewer* vm = dynamic_cast<SVTK_Viewer*>( viewMgr->getViewModel() );
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 );
}
+#else
+ viewMgr = new VTKViewer_ViewManager( activeStudy(), desktop() );
+ VTKViewer_Viewer* vm = dynamic_cast<VTKViewer_Viewer*>( viewMgr->getViewModel() );
+ if ( vm )
+ vm->setBackgroundColor( resMgr->colorValue( "VTKViewer", "background", vm->backgroundColor() ) );
+#endif
}
+#endif
if ( !viewMgr )
return 0;
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;
aRoot = theStudy->root();
//aRoot->setName( tr( "DATA_MODELS" ) );
}
+ getWindow( WT_ObjectBrowser );
if ( objectBrowser() != 0 )
objectBrowser()->setRootObject( aRoot );
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;
aRoot = theStudy->root();
//aRoot->dump();
}
- if ( objectBrowser() != 0 ) {
+ getWindow( WT_ObjectBrowser );
+ if ( objectBrowser() )
objectBrowser()->setRootObject( aRoot );
- }
activateModule( defaultModule() );
+ if ( objectBrowser() )
+ objectBrowser()->openLevels();
+
activateWindows();
emit studyOpened();
}
/*!Protected SLOT. On study closed.*/
-void LightApp_Application::onStudyClosed( SUIT_Study* )
+void LightApp_Application::onStudyClosed( SUIT_Study* s )
{
+ // Bug 10396: clear selection
+ mySelMgr->clearSelected();
+
+ // Bug 12944: emit signal only after clear selection
emit studyClosed();
activateModule( "" );
- // Bug 10396: remove all selectors
- delete mySelMgr;
- mySelMgr = new LightApp_SelectionMgr( this );
-
- saveWindowsGeometry();
+ for ( WindowMap::ConstIterator itr = myWindows.begin(); s && itr != myWindows.end(); ++itr )
+ removeWindow( itr.key(), s->id() );
}
/*!Protected SLOT.On desktop activated.*/
*/
QString LightApp_Application::getFileFilter() const
{
- return "(*.bin)";
+ //return "(*.bin)";
+ // HDF persistence
+ 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 )
{
if ( !prefDlg )
return;
- prefDlg->exec();
+ if ( ( prefDlg->exec() == QDialog::Accepted || prefDlg->isSaved() ) && resourceMgr() ) {
+ if ( desktop() )
+ desktop()->saveGeometry( resourceMgr(), "desktop" );
+ resourceMgr()->save();
+ }
delete prefDlg;
}
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.*/
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.*/
updateCommandsStatus();
}
-//=======================================================================
-// name : createNewStudy
-/*! Purpose : Create new study*/
-//=======================================================================
+/*!
+ Creates new study
+*/
SUIT_Study* LightApp_Application::createNewStudy()
{
+ LightApp_Application::lastStudyId++;
+
LightApp_Study* aStudy = new LightApp_Study( this );
// Set up processing of major study-related events
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 );
+ //ob->setAutoOpenLevel( 1 ); // commented by ASV as a fix to bug IPAL10107
ob->setCaption( tr( "OBJECT_BROWSER" ) );
- ob->listView()->setColumnWidth( 0, OBJECT_COLUMN_WIDTH );
- ob->resize( OBJECT_BROWSER_WIDTH, ob->height() );
- ob->setFilter( new LightApp_OBFilter( selectionMgr() ) );
+ OB_ListView* ob_list = dynamic_cast<OB_ListView*>( const_cast<QListView*>( ob->listView() ) );
+ if( ob_list )
+ ob_list->setColumnMaxWidth( 0, desktop()->width()/4 );
+
+ ob->setFilter( new LightApp_OBFilter( selectionMgr() ) );
ob->setNameTitle( tr( "OBJ_BROWSER_NAME" ) );
// Create OBSelector
ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
}
+#ifndef DISABLE_PYCONSOLE
else if ( flag == WT_PyConsole )
{
PythonConsole* pyCons = new PythonConsole( desktop() );
wid = pyCons;
// pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
}
+#endif
else if ( flag == WT_LogWindow )
{
LogWindow* logWin = new LogWindow( desktop() );
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
{
aMap.insert( WT_ObjectBrowser, Qt::DockLeft );
+#ifndef DISABLE_PYCONSOLE
aMap.insert( WT_PyConsole, Qt::DockBottom );
+#endif
// 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 )
LightApp_Application* that = (LightApp_Application*)this;
- if ( !_prefs_ && crt )
+ bool toCreate = !_prefs_ && crt;
+ if( toCreate )
{
_prefs_ = new LightApp_Preferences( resourceMgr() );
that->createPreferences( _prefs_ );
{
int modCat = _prefs_->addPreference( mod->moduleName() );
_prefs_->setItemProperty( modCat, "info", QString::null );
- mod->createPreferences();
+ if( toCreate )
+ mod->createPreferences();
}
}
}
return myPrefs;
}
-/*!Add new module to application.*/
+/*!
+ Adds new module to application
+*/
void LightApp_Application::moduleAdded( CAM_Module* mod )
{
CAM_Application::moduleAdded( mod );
}
}
-/*!Create preferences.*/
+/*!
+ Create preferences
+*/
void LightApp_Application::createPreferences( LightApp_Preferences* pref )
{
if ( !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 );
pref->addPreference( tr( "PREF_PARAM" ), extgroup, LightApp_Preferences::String, "ExternalBrowser", "parameters" );
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" );
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,
LightApp_Preferences::Color, "SUPERVGraph", "Title" );
// pref->addPreference( tr( "PREF_SUPERV_CTRL_COLOR" ), supervGroup,
// LightApp_Preferences::Color, "SUPERVGraph", "Ctrl" );
+
+ int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
+ int objSetGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SETTINGS" ), obTab );
+ pref->addPreference( tr( "PREF_AUTO_SIZE_FIRST" ), objSetGroup, LightApp_Preferences::Bool,
+ "ObjectBrowser", "auto_size_first" );
+ pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool,
+ "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();
if ( !resMgr )
return;
+#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 )
occVM->getAISContext()->UpdateCurrentViewer();
}
}
+#endif
- if ( sec == QString( "VTKViewer" ) && param == QString( "trihedron_size" ) )
+#ifndef DISABLE_VTKVIEWER
+ if ( sec == QString( "VTKViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )) )
{
- int sz = resMgr->integerValue( sec, param, -1 );
+ double sz = resMgr->doubleValue( "VTKViewer", "trihedron_size", -1 );
+ bool isRelative = resMgr->booleanValue( "VTKViewer", "relative_size", true );
QPtrList<SUIT_ViewManager> lst;
+#ifndef DISABLE_SALOMEOBJECT
viewManagers( SVTK_Viewer::Type(), lst );
for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current() && sz >= 0; ++it )
{
SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
if( vtkVM )
{
- vtkVM->setTrihedronSize( sz );
+ vtkVM->setTrihedronSize( sz, isRelative );
vtkVM->Repaint();
}
}
+#endif
}
+#endif
+#ifndef DISABLE_OCCVIEWER
if ( sec == QString( "OCCViewer" ) && ( param == QString( "iso_number_u" ) || param == QString( "iso_number_v" ) ) )
{
QPtrList<SUIT_ViewManager> lst;
int u = resMgr->integerValue( sec, "iso_number_u" );
int v = resMgr->integerValue( sec, "iso_number_v" );
for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current(); ++it )
- ((OCCViewer_Viewer*)it.current())->setIsos( u, v );
+ {
+ OCCViewer_ViewManager* mgr = dynamic_cast<OCCViewer_ViewManager*>( it.current() );
+ if( mgr && mgr->getOCCViewer() )
+ mgr->getOCCViewer()->setIsos( u, v );
+ }
}
+#endif
if( sec=="ObjectBrowser" )
{
- if( param=="auto_size" )
+ if( param=="auto_size" || param=="auto_size_first" )
{
OB_Browser* ob = objectBrowser();
if( !ob )
return;
- bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
+ bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false ),
+ 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 );
}
}
+ if( sec=="Study" )
+ {
+ if( param=="store_positions" )
+ updateWindows();
+ }
+
+#ifndef DISABLE_PYCONSOLE
if( sec=="PyConsole" )
{
if( param=="font" )
if( pythonConsole() )
pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) );
}
+#endif
}
-/*!Update desktop title.*/
+/*!
+ Saves preferences
+*/
+void LightApp_Application::savePreferences()
+{
+ saveWindowsGeometry();
+
+ if ( resourceMgr() )
+ {
+ if ( desktop() )
+ desktop()->saveGeometry( resourceMgr(), "desktop" );
+ resourceMgr()->save();
+ }
+}
+
+/*!
+ Updates desktop title
+*/
void LightApp_Application::updateDesktopTitle() {
QString aTitle = applicationName();
QString aVer = applicationVersion();
if ( !aVer.isEmpty() )
aTitle += QString( " " ) + aVer;
+ if ( activeStudy() ) {
+ QString sName = SUIT_Tools::file( activeStudy()->studyName().stripWhiteSpace(), false );
+ aTitle += QString( " - [%1]" ).arg( sName );
+ }
+
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();
CAM_Application::afterCloseDoc();
}
-/*!Update module action.*/
+/*!
+ Updates actions of active module
+*/
void LightApp_Application::updateModuleActions()
{
QString modName;
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();
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();
defaultViewManagers( lst );
}
-/*!Update windows.*/
+/*!
+ Updates windows
+*/
void LightApp_Application::updateWindows()
{
QMap<int, int> winMap;
currentWindows( winMap );
- for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
- getWindow( it.key() );
+ if ( activeStudy() ) {
+ 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();
+ 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 ) {
+
+ if ( myWindowsVisible.contains( itr.key() ) &&
+ !myWindowsVisible[ itr.key() ] )
+ continue;
- for ( WindowMap::ConstIterator itr = myWindows.begin(); itr != myWindows.end(); ++itr )
setWindowShown( itr.key(), !itr.data()->isEmpty() && winMap.contains( itr.key() ) );
+ }
}
-/*!Update view managers.*/
+/*!
+ Updates view managers
+*/
void LightApp_Application::updateViewManagers()
{
QStringList lst;
getViewManager( *it, true );
}
-/*!Load windows geometry.*/
+/*!
+ Loads windows geometry
+*/
void LightApp_Application::loadWindowsGeometry()
{
+ bool store = resourceMgr()->booleanValue( "Study", "store_positions", true );
+ if( !store )
+ return;
+
QtxDockAction* dockMgr = 0;
QAction* a = action( ViewWindowsId );
dockMgr->restoreGeometry();
}
-/*!Save windows geometry.*/
+/*!
+ Saves windows geometry
+*/
void LightApp_Application::saveWindowsGeometry()
{
+ bool store = resourceMgr()->booleanValue( "Study", "store_positions", true );
+ if( !store )
+ return;
+
QtxDockAction* dockMgr = 0;
QAction* a = action( ViewWindowsId );
dockMgr->saveGeometry( resourceMgr(), section, false );
}
-/*!Activate windows.*/
+/*!
+ Activates windows
+*/
void LightApp_Application::activateWindows()
{
if ( activeStudy() )
}
}
-/*!Adds icon names for modules.*/
+/*!
+ Adds icon names for modules
+*/
void LightApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) const
{
iconMap.clear();
}
}
-/*!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 );
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();
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 );
return res;
}
-/*!return keyborad accelerators manager object */
+/*!
+ \return keyborad accelerators manager object
+*/
SUIT_Accel* LightApp_Application::accel() const
{
return myAccel;
}
+
+/*!
+ Removes dead widget container from map
+*/
+void LightApp_Application::onWCDestroyed( QObject* ob )
+{
+ // remove destroyed widget container from windows map
+ for ( WindowMap::ConstIterator itr = myWindows.begin(); itr != myWindows.end(); ++itr )
+ {
+ if ( itr.data() != ob )
+ continue;
+
+ int key = itr.key();
+ myWindows.remove( key );
+ break;
+ }
+}
+
+/*!
+ 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* ) ),
+ this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
+ STD_Application::removeViewManager( vm );
+ delete vm;
+}
+
+/*!
+ Renames active window of desktop
+*/
+void LightApp_Application::onRenameWindow()
+{
+ if( !desktop() )
+ return;
+
+ QWidget* w = desktop()->activeWindow();
+ if( !w )
+ return;
+
+ bool ok;
+ QString name = QInputDialog::getText( tr( "TOT_RENAME" ), tr( "PRP_RENAME" ), QLineEdit::Normal, w->caption(), &ok, w );
+ if( ok && !name.isEmpty() )
+ 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" ) );
+#else
+ 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;
+}
+
+/*!
+ \return default name for an active study
+*/
+void LightApp_Application::setDefaultStudyName( const QString& theName )
+{
+ QStringList anInfoList;
+ modules( anInfoList, false );
+
+ LightApp_Study* aStudy = (LightApp_Study*)activeStudy();
+ if( anInfoList.count() == 1 && // to avoid a conflict between different modules
+ !aStudy->isSaved() )
+ {
+ aStudy->setStudyName( 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 );
+}