*/
void CAM_Application::start()
{
+ // check modules
+ for ( ModuleInfoList::iterator it = myInfoList.begin();
+ it != myInfoList.end(); ++it )
+ {
+ if ( (*it).status == stUnknown )
+ (*it).status = checkModule( (*it).title ) ? stReady : stInaccessible;
+ }
+
+ // auto-load modules
if ( myAutoLoad )
loadModules();
if ( !modName.isEmpty() )
{
CAM_Module* mod = module( modName );
- if ( !mod && !moduleLibrary( modName ).isEmpty() )
- {
+ if ( !mod )
mod = loadModule( modName );
- addModule( mod );
- }
+ addModule( mod );
if ( mod )
res = activateModule( mod );
STD_Application::setActiveStudy( study );
}
+/*!
+ \brief Check module availability.
+
+ The method can be redefined in successors. Default implementation returns \c true.
+
+ \param title module title
+ \return \c true if module is accessible; \c false otherwise
+*/
+bool CAM_Application::checkModule( const QString& )
+{
+ return true;
+}
+
/*!
\brief Callback function, called when the module is added to the application.
{
bool found = false;
bool blocked = false;
+ bool statusOK = false;
QStringList somewhereLoaded;
QList<SUIT_Application*> apps = SUIT_Session::session()->applications();
{
found = (*it).title == title;
blocked = (*it).isSingleton && somewhereLoaded.contains((*it).title);
+ statusOK = (*it).status == stReady;
}
- return found && !blocked;
+ return found && statusOK && !blocked;
}
/*!
for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end() && res.isEmpty(); ++it )
{
if ( (*it).title == title )
- res = (*it).internal;
+ res = (*it).library;
}
if ( !res.isEmpty() && full )
res = SUIT_Tools::library( res );
if ( !moduleTitle( modName ).isEmpty() )
continue; // already added
+ if ( modName == "KERNEL" || modName == "GUI" )
+ continue; // omit KERNEL and GUI modules
+
QString modTitle = resMgr->stringValue( *it, "name", QString() );
if ( modTitle.isEmpty() )
{
printf( "****************************************************************\n" );
- printf( "* Warning: %s GUI resources are not found.\n", qPrintable(*it) );
- printf( "* %s GUI will not be available.\n", qPrintable(*it) );
+ printf( " Warning: module %s is improperly configured!\n", qPrintable(*it) );
+ printf( " Module %s will not be available in GUI mode!\n", qPrintable(*it) );
printf( "****************************************************************\n" );
continue;
}
else
modLibrary = modName;
- bool aIsSingleton = resMgr->booleanValue(*it, "singleton", false);
-
- QString ver = resMgr->stringValue(*it, "version", QString());
+ bool aIsSingleton = resMgr->booleanValue( *it, "singleton", false );
+ bool hasGui = resMgr->booleanValue( *it, "gui", true );
+ QString version = resMgr->stringValue( *it, "version", QString() );
ModuleInfo inf;
inf.name = modName;
inf.title = modTitle;
- inf.internal = modLibrary;
+ inf.status = hasGui ? stUnknown : stNoGui;
+ if ( hasGui ) inf.library = modLibrary;
inf.icon = modIcon;
inf.isSingleton = aIsSingleton;
- inf.version = ver;
+ inf.version = version;
myInfoList.append( inf );
}
static QString moduleName( const QString& );
static QString moduleTitle( const QString& );
static QString moduleIcon( const QString& );
+ static QString moduleLibrary( const QString&, const bool = true );
static bool isModuleAccessible( const QString& );
virtual void createEmptyStudy();
virtual SUIT_Study* createNewStudy();
virtual void updateCommandsStatus();
+ virtual bool checkModule( const QString& );
virtual void moduleAdded( CAM_Module* );
virtual void beforeCloseDoc( SUIT_Study* );
virtual void afterCloseDoc();
virtual void setActiveStudy( SUIT_Study* );
- static QString moduleLibrary( const QString&, const bool = true );
-
virtual bool abortAllOperations();
private:
void readModuleList();
private:
- typedef struct { QString name, title, internal, icon; bool isSingleton; QString version; } ModuleInfo;
+ enum { stUnknown = 0, stNoGui, stInaccessible, stReady };
+ typedef struct {
+ QString name, title, icon, library, version;
+ bool isSingleton;
+ int status;
+ } ModuleInfo;
typedef QList<ModuleInfo> ModuleInfoList;
private:
QStringList::Iterator it;
for ( it = modList.begin(); it != modList.end(); ++it )
{
- if ( !isLibExists( *it ) )
+ if ( !isModuleAccessible( *it ) )
continue;
QString modName = moduleName( *it );
- if ( !isModuleAccessible( *it ) )
- continue;
-
QString iconName;
if ( iconMap.contains( *it ) )
iconName = iconMap[*it];
if ( icon.isNull() )
{
icon = modIcon;
- INFOS ( "\n****************************************************************" << std::endl
- << "* Icon for " << (*it).toLatin1().constData()
- << " not found. Using the default one." << std::endl
- << "****************************************************************" << std::endl );
+ INFOS( std::endl <<
+ "****************************************************************" << std::endl <<
+ " Warning: icon for " << qPrintable(*it) << " is not found!" << std::endl <<
+ " Using the default icon." << std::endl <<
+ "****************************************************************" << std::endl);
}
-
icon = Qtx::scaleIcon( icon, iconSize );
moduleAction->insertModule( *it, icon );
for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it )
{
- if ( !app->isLibExists( *it ) || _prefs_->hasModule( *it ) )
+ if ( !app->isModuleAccessible( *it ) || _prefs_->hasModule( *it ) )
continue;
int modId = _prefs_->addPreference( *it );
moduleAction->removeModule( modName );
}
+bool LightApp_Application::checkModule( const QString& title )
+{
+ if ( title.isEmpty() )
+ return false;
+
+ QString library = moduleLibrary( title, true );
+ if ( library.isEmpty() )
+ return false;
+
+ QString name = moduleName( title );
+
+ bool isPyModule = library.contains( "SalomePyQtGUI" ) || library.contains( "SalomePyQtGUILight" );
+
+ QStringList paths;
+#if defined(WIN32)
+ paths = QString( ::getenv( "PATH" ) ).split( ";", QString::SkipEmptyParts );
+#elif defined(__APPLE__)
+ paths = QString( ::getenv( "DYLD_LIBRARY_PATH" ) ).split( ":", QString::SkipEmptyParts );
+#else
+ paths = QString( ::getenv( "LD_LIBRARY_PATH" ) ).split( ":", QString::SkipEmptyParts );
+#endif
+
+ bool isFound = false;
+ QStringList::const_iterator it;
+ for ( it = paths.begin(); it != paths.end() && !isFound; ++it )
+ {
+ isFound = QFileInfo( Qtx::addSlash( *it ) + library ).exists();
+ }
+
+ if ( !isFound )
+ {
+ INFOS( std::endl <<
+ "****************************************************************" << std::endl <<
+ " Warning: library " << qPrintable( library ) << " is not found!" << std::endl <<
+ " Module " << qPrintable( title ) << " will not be available in GUI mode!" << std::endl <<
+ "****************************************************************" << std::endl);
+ return false;
+ }
+
+ if ( isPyModule )
+ {
+ QString pyModule = QString( "%1GUI.py" ).arg( name );
+ paths = QString( ::getenv( "PYTHONPATH" ) ).split( ":", QString::SkipEmptyParts );
+
+ isFound = false;
+ for ( it = paths.begin(); it != paths.end() && !isFound; ++it )
+ {
+ isFound = QFileInfo( Qtx::addSlash( *it ) + pyModule ).exists();
+ }
+
+ if ( !isFound )
+ {
+ INFOS( std::endl <<
+ "****************************************************************" << std::endl <<
+ " Warning: Python module " << qPrintable( pyModule ) << " is not found!" << std::endl <<
+ " Module " << qPrintable( title ) << " will not be available in GUI mode!" << std::endl <<
+ "****************************************************************" << std::endl);
+ return false;
+ }
+ }
+
+ return true;
+}
+
/*!
Gets current windows.
\param winMap - output current windows map.
wgStack->stack();
}
-/*!
- \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");
- bool isPythonLightModule = lib.contains("SalomePyQtGUILight");
-
- QStringList paths;
-#if defined(WIN32)
- paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
-#elif defined(__APPLE__)
- paths = QString(::getenv( "DYLD_LIBRARY_PATH" )).split( ":", QString::SkipEmptyParts );
-#else
- paths = QString(::getenv( "LD_LIBRARY_PATH" )).split( ":", QString::SkipEmptyParts );
-#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 )
- {
- INFOS( "\n****************************************************************" << std::endl
- << "* Warning: library " << lib.toLatin1().constData() << " cannot be found" << std::endl
- << "* Module " << moduleTitle.toLatin1().constData() << " will not be available in GUI mode" << std::endl
- << "****************************************************************" << std::endl );
- }
- else if ( !isPythonModule && !isPythonLightModule)
- return true;
-
- if ( isPythonModule || isPythonLightModule)
- {
- QString pylib = moduleName( moduleTitle ) + QString(".py");
- QString pylibgui = moduleName( moduleTitle ) + QString("GUI.py");
-
- // Check the python library
-// #ifdef WIN32
-// paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
-// #else
- paths = QString(::getenv( "PYTHONPATH" )).split( ":", QString::SkipEmptyParts );
-// #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(!isPythonLightModule)
- if( !isPyLib && inf.exists() )
- isPyLib = true;
-
- if( !isPyGuiLib && infgui.exists() )
- isPyGuiLib = true;
-
- if ((isPyLib || isPythonLightModule ) && isPyGuiLib && isLibFound)
- return true;
- }
-
- printf( "\n****************************************************************\n" );
- printf( "* Warning: python library for %s cannot be found:\n", moduleTitle.toLatin1().constData() );
- if (!isPyLib)
- printf( "* No module named %s\n", moduleName( moduleTitle ).toLatin1().constData() );
- if (!isPyGuiLib)
- printf( "* No module named %s\n", (moduleName( moduleTitle ) + QString("GUI")).toLatin1().constData() );
- printf( "****************************************************************\n" );
- return true;
- }
- return false;
-}
-
/*!
\return default name for an active study
*/