From: vsr Date: Thu, 10 Sep 2020 07:10:35 +0000 (+0300) Subject: Use Geometry Displayer for Shaper X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=835e66324db38b92f873dc149335fc2b12f6a774;p=modules%2Fgui.git Use Geometry Displayer for Shaper --- diff --git a/src/CAM/CAM_Application.cxx b/src/CAM/CAM_Application.cxx index ae731cee5..dadb2edc9 100644 --- a/src/CAM/CAM_Application.cxx +++ b/src/CAM/CAM_Application.cxx @@ -208,7 +208,8 @@ void CAM_Application::modules( QStringList& lst, const bool loaded ) const { for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end(); ++it ) - lst.append( (*it).title ); + if ( (*it).status != stNoGui ) + lst.append( (*it).title ); } } @@ -673,6 +674,22 @@ QString CAM_Application::moduleLibrary( const QString& title, const bool full ) return res; } +/*! + \brief Get displayer proxy for given module, by its title (user name). + \param title module title (user name) + \return name of module which provides displayer for requested module + */ +QString CAM_Application::moduleDisplayer( const QString& title ) +{ + QString res; + for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end() && res.isEmpty(); ++it ) + { + if ( (*it).title == title ) + res = (*it).displayer; + } + return res.isEmpty() ? title : res; +} + /*! \brief Read modules information list @@ -756,51 +773,58 @@ void CAM_Application::readModuleList() continue; // omit KERNEL and GUI modules bool hasGui = resMgr->booleanValue( *it, "gui", true ); - if ( !hasGui ) - continue; // omit if module is explicitly declared as not having GUI - QString modTitle = resMgr->stringValue( *it, "name", QString() ); - if ( modTitle.isEmpty() ) + QString modTitle, modIcon, modLibrary; + + if ( hasGui ) { - printf( "****************************************************************\n" ); - 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; - } + // if module has GUI, check that it is present + modTitle = resMgr->stringValue( *it, "name", QString() ); + if ( modTitle.isEmpty() ) + { + printf( "****************************************************************\n" ); + 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; + } - QString modIcon = resMgr->stringValue( *it, "icon", QString() ); + QString modIcon = resMgr->stringValue( *it, "icon", QString() ); - QString modLibrary = resMgr->stringValue( *it, "library", QString() ).trimmed(); - if ( !modLibrary.isEmpty() ) - { - modLibrary = SUIT_Tools::file( modLibrary.trimmed() ); + modLibrary = resMgr->stringValue( *it, "library", QString() ).trimmed(); + if ( !modLibrary.isEmpty() ) + { + modLibrary = SUIT_Tools::file( modLibrary.trimmed() ); #if defined(WIN32) - QString libExt = QString( "dll" ); + QString libExt = QString( "dll" ); #elif defined(__APPLE__) - QString libExt = QString( "dylib" ); + QString libExt = QString( "dylib" ); #else - QString libExt = QString( "so" ); + QString libExt = QString( "so" ); #endif - if ( SUIT_Tools::extension( modLibrary ).toLower() == libExt ) - modLibrary.truncate( modLibrary.length() - libExt.length() - 1 ); + if ( SUIT_Tools::extension( modLibrary ).toLower() == libExt ) + modLibrary.truncate( modLibrary.length() - libExt.length() - 1 ); #ifndef WIN32 - QString prefix = QString( "lib" ); - if ( modLibrary.startsWith( prefix ) ) - modLibrary.remove( 0, prefix.length() ); + QString prefix = QString( "lib" ); + if ( modLibrary.startsWith( prefix ) ) + modLibrary.remove( 0, prefix.length() ); #endif + } + else + modLibrary = modName; } - else - modLibrary = modName; QString version = resMgr->stringValue( *it, "version", QString() ); + QString modDisplayer = resMgr->stringValue( *it, "displayer", QString() ); + ModuleInfo inf; inf.name = modName; inf.title = modTitle; inf.status = hasGui ? stUnknown : stNoGui; if ( hasGui ) inf.library = modLibrary; inf.icon = modIcon; + inf.displayer = modDisplayer; inf.version = version; myInfoList.append( inf ); } diff --git a/src/CAM/CAM_Application.h b/src/CAM/CAM_Application.h index b0b69d3f6..987bf49d1 100644 --- a/src/CAM/CAM_Application.h +++ b/src/CAM/CAM_Application.h @@ -75,6 +75,7 @@ public: static QString moduleTitle( const QString& ); static QString moduleIcon( const QString& ); static QString moduleLibrary( const QString&, const bool = true ); + static QString moduleDisplayer( const QString& ); virtual void createEmptyStudy(); @@ -101,6 +102,7 @@ private: enum { stUnknown = 0, stNoGui, stInaccessible, stReady }; typedef struct { QString name, title, icon, library, version; + QString displayer; int status; } ModuleInfo; typedef QList ModuleInfoList; diff --git a/src/LightApp/LightApp_Displayer.cxx b/src/LightApp/LightApp_Displayer.cxx index c369ecabd..636f72a4c 100644 --- a/src/LightApp/LightApp_Displayer.cxx +++ b/src/LightApp/LightApp_Displayer.cxx @@ -303,28 +303,29 @@ bool LightApp_Displayer::canBeDisplayed( const QString& entry ) const */ LightApp_Displayer* LightApp_Displayer::FindDisplayer( const QString& mod_name, const bool load ) { + QString mname = LightApp_Application::moduleDisplayer( mod_name ); SUIT_Session* session = SUIT_Session::session(); SUIT_Application* sapp = session ? session->activeApplication() : 0; LightApp_Application* app = dynamic_cast( sapp ); if( !app ) return 0; - LightApp_Module* m = dynamic_cast( app ? app->module( mod_name ) : 0 ); + LightApp_Module* m = dynamic_cast( app ? app->module( mname ) : 0 ); bool wasLoaded = false; if( !m && load ) { - m = dynamic_cast( app->loadModule( mod_name, false ) ); - if( m ) { + m = dynamic_cast( app->loadModule( mname, false ) ); + if( m ) { app->addModule( m ); - wasLoaded = true; - } + wasLoaded = true; + } } if( m ) { m->connectToStudy( dynamic_cast( app->activeStudy() ) ); - if( wasLoaded ) - m->updateModuleVisibilityState(); + if( wasLoaded ) + m->updateModuleVisibilityState(); } return m ? m->displayer() : 0; }