From 896ae22cf0c952e28dd2b455c5078df02a7f00f1 Mon Sep 17 00:00:00 2001 From: vsr Date: Thu, 10 Sep 2020 10:10:35 +0300 Subject: [PATCH] bos #19960: [CEA 19958] Show/Hide SHAPERSTUDY objects --- src/CAM/CAM_Application.cxx | 86 +++++++++++++++------- src/CAM/CAM_Application.h | 3 +- src/LightApp/LightApp_Application.cxx | 98 ++++++++++++++++++------- src/LightApp/LightApp_Application.h | 9 ++- src/LightApp/LightApp_Displayer.cxx | 19 +++-- src/LightApp/LightApp_Module.cxx | 4 +- src/LightApp/LightApp_Selection.cxx | 14 ++-- src/LightApp/LightApp_ShowHideOp.cxx | 8 +- src/SALOME_SWIG/SALOMEGUI_Swig.cxx | 12 +-- src/SalomeApp/SalomeApp_Application.cxx | 9 ++- src/SalomeApp/SalomeApp_Study.cxx | 37 +++++----- 11 files changed, 196 insertions(+), 103 deletions(-) diff --git a/src/CAM/CAM_Application.cxx b/src/CAM/CAM_Application.cxx index ac5989830..4c39298f5 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 ); } } @@ -689,6 +690,30 @@ QString CAM_Application::moduleLibrary( const QString& name, const bool full ) return res; } +/*! + \brief Get displayer proxy for given module, by its title (user name). + \param name module name or title + \return name of module which provides displayer for requested module + */ +QString CAM_Application::moduleDisplayer( const QString& name ) +{ + QString res; + + if ( !name.isEmpty() ) + { + for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end() && res.isEmpty(); ++it ) + { + if ( (*it).title == name || (*it).name == name ) { + res = (*it).displayer; + if ( res.isEmpty() ) + res = (*it).title; + } + } + } + + return res; +} + /*! \brief Read modules information list @@ -772,47 +797,53 @@ 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, modDescription; + + 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() ); + modIcon = resMgr->stringValue( *it, "icon", QString() ); - QString modDescription = resMgr->stringValue( *it, "description", QString() ); + modDescription = resMgr->stringValue( *it, "description", 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; @@ -820,6 +851,7 @@ void CAM_Application::readModuleList() if ( hasGui ) inf.library = modLibrary; inf.icon = modIcon; inf.description = modDescription; + inf.displayer = modDisplayer; inf.version = version; myInfoList.append( inf ); } diff --git a/src/CAM/CAM_Application.h b/src/CAM/CAM_Application.h index a11669897..93f7c266b 100644 --- a/src/CAM/CAM_Application.h +++ b/src/CAM/CAM_Application.h @@ -76,6 +76,7 @@ public: static QString moduleIcon( const QString& ); static QString moduleDescription( const QString& ); static QString moduleLibrary( const QString&, const bool = true ); + static QString moduleDisplayer( const QString& ); virtual void createEmptyStudy(); @@ -101,7 +102,7 @@ private: private: enum { stUnknown = 0, stNoGui, stInaccessible, stReady }; typedef struct { - QString name, title, icon, library, version, description; + QString name, title, icon, library, version, description, displayer; int status; } ModuleInfo; typedef QList ModuleInfoList; diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index b0d8f7f8f..249ce2fd1 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -465,7 +465,7 @@ void LightApp_Application::closeApplication() #ifndef DISABLE_QTXWEBBROWSER QProcess::startDetached( "HelpBrowser", QStringList() << QString( "--remove=%1" ).arg( QApplication::instance()->applicationPid() ) ); -#endif +#endif CAM_Application::closeApplication(); } @@ -543,7 +543,7 @@ bool LightApp_Application::activateModule( const QString& modName ) updateViewManagers(); if ( activeStudy() && activeStudy()->root() && objectBrowser() ) { - if ( objectBrowser()->root() != activeStudy()->root() ) + if ( objectBrowser()->root() != activeStudy()->root() ) objectBrowser()->setRoot( activeStudy()->root() ); updateObjectBrowser( true ); } @@ -598,7 +598,7 @@ void LightApp_Application::createActions() // Help menu int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 ); - + int id = LightApp_Application::UserID + FIRST_HELP_ID; // a) Link to web site @@ -719,7 +719,7 @@ void LightApp_Application::createActions() IMapConstIterator fileIt; for ( fileIt = helpData.begin(); fileIt != helpData.end(); fileIt++ ) { QString helpItemPath = fileIt.key(); - // remove all '//' occurances + // remove all '//' occurances while ( helpItemPath.contains( "//" ) ) helpItemPath.replace( "//", "" ); // obtain submenus hierarchy if given @@ -733,7 +733,7 @@ void LightApp_Application::createActions() if ( total.count() == 1 && smenus.count() > 0 ) helpItemPath = smenus.takeLast(); } - QPixmap helpIcon = fileIt.value().startsWith( "http", Qt::CaseInsensitive ) ? + QPixmap helpIcon = fileIt.value().startsWith( "http", Qt::CaseInsensitive ) ? resMgr->loadPixmap( "STD", tr( "ICON_WWW" ), false ) : resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ); QAction* a = createAction( id, helpItemPath, helpIcon, helpItemPath, helpItemPath, 0, desk, false, this, SLOT( onHelpContentsModule() ) ); @@ -759,9 +759,9 @@ void LightApp_Application::createActions() QString valueStr = resMgr->stringValue( "add_help", paramName ); if ( !valueStr.isEmpty() ) { QStringList valueItems = valueStr.split( ";;", QString::SkipEmptyParts ); - foreach( QString item, valueItems ) { + foreach( QString item, valueItems ) { if ( item.startsWith( "http", Qt::CaseInsensitive ) || QFile::exists( item ) ) { - QPixmap helpIcon = item.startsWith( "http", Qt::CaseInsensitive ) ? + QPixmap helpIcon = item.startsWith( "http", Qt::CaseInsensitive ) ? resMgr->loadPixmap( "STD", tr( "ICON_WWW" ), false ) : resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ); QAction* a = createAction( id++, paramName, helpIcon, paramName, paramName, 0, desk, false, this, SLOT( onHelpContentsModule() ) ); @@ -1020,7 +1020,7 @@ void LightApp_Application::onNewDoc() //asl: fix for 0020515 saveDockWindowsState(); - + CAM_Application::onNewDoc(); } @@ -1078,7 +1078,7 @@ bool LightApp_Application::onOpenDoc( const QString& aName ) // We should take mru action first because this application instance can be deleted later. QtxMRUAction* mru = ::qobject_cast( action( MRUId ) ); - + bool res = CAM_Application::onOpenDoc( aName ); if ( mru ) @@ -1255,7 +1255,7 @@ void LightApp_Application::showHelp( const QString& path ) #if DISABLE_QTXWEBBROWSER bool useExternalBrowser = true; -#else +#else bool useExternalBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false ); #endif @@ -1267,7 +1267,7 @@ void LightApp_Application::showHelp( const QString& path ) QString browser = resMgr->stringValue( "ExternalBrowser", "application" ); #endif QString parameters = resMgr->stringValue("ExternalBrowser", "parameters"); - + if ( !browser.isEmpty() ) { RunBrowser::execute( this, browser, parameters, path ); @@ -1488,7 +1488,7 @@ LogWindow* LightApp_Application::logWindow() when you request the python console, this function could return null. Then the optional parameter force (default to false) can be set to force the creation of the python console if it is not done - already. + already. \param force - if true, the pythonConsole is created if it does not exist yet \return Python Console */ @@ -2388,7 +2388,7 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) pref->addPreference( tr( "PREF_SHOW_SPLASH" ), lookGroup, LightApp_Preferences::Bool, "launch", "splash" ); // .... -> opaque resize pref->addPreference( tr( "PREF_OPAQUE_RESIZE" ), lookGroup, LightApp_Preferences::Bool, "desktop", "opaque_resize" ); - // .... -> drop-down buttons + // .... -> drop-down buttons pref->addPreference( tr( "PREF_DROP_DOWN_BUTTONS" ), lookGroup, LightApp_Preferences::Bool, "viewers", "drop_down_buttons" ); // .... -> Notification timeout int delay = pref->addPreference( tr( "PREF_NOTIFY_TIMEOUT" ), lookGroup, LightApp_Preferences::IntSpin, "notification", "timeout" ); @@ -5258,7 +5258,7 @@ void LightApp_Application::emitOperationFinished( const QString& theModuleName, Update visibility state of given objects */ void LightApp_Application::updateVisibilityState( DataObjectList& theList, - SUIT_ViewModel* theViewModel ) + SUIT_ViewModel* theViewModel ) { if ( !theViewModel || theList.isEmpty() ) return; @@ -5273,18 +5273,66 @@ void LightApp_Application::updateVisibilityState( DataObjectList& theList, if ( !obj || aStudy->isComponent( obj->entry() ) ) continue; - LightApp_Module* anObjModule = dynamic_cast(obj->module()); - if ( anObjModule ) { - LightApp_Displayer* aDisplayer = anObjModule->displayer(); - if ( aDisplayer ) { - Qtx::VisibilityState anObjState = Qtx::UnpresentableState; - if ( aDisplayer->canBeDisplayed( obj->entry(), theViewModel->getType() ) ) { - if ( aView && aDisplayer->IsDisplayed( obj->entry(), aView ) ) - anObjState = Qtx::ShownState; - else - anObjState = Qtx::HiddenState; + QString mname = aStudy->componentDataType(obj->entry()); + LightApp_Displayer* aDisplayer = LightApp_Displayer::FindDisplayer(mname, false); + if ( aDisplayer ) { + Qtx::VisibilityState anObjState = Qtx::UnpresentableState; + if ( aDisplayer->canBeDisplayed( obj->entry(), theViewModel->getType() ) ) { + if ( aView && aDisplayer->IsDisplayed( obj->entry(), aView ) ) + anObjState = Qtx::ShownState; + else + anObjState = Qtx::HiddenState; + } + aStudy->setVisibilityState( obj->entry(), anObjState ); + } + } +} + +/*! + Update presentations of all displayed objects of theComponent in specified viewers +*/ +void LightApp_Application::updatePresentations( const QString& theComponent, + const QStringList& theViewManagerTypes ) +{ + LightApp_Displayer* aDisplayer = LightApp_Displayer::FindDisplayer(theComponent, false); + if ( aDisplayer ) { + LightApp_Study* aStudy = dynamic_cast(activeStudy()); + DataObjectList aComps; + bool isFound = false; + aStudy->root()->children( aComps ); + DataObjectList::const_iterator aCompsIt = aComps.begin(); + for ( ; aCompsIt != aComps.end() && !isFound; aCompsIt++ ) { + LightApp_DataObject* aComp = dynamic_cast( *aCompsIt ); + if ( aComp && aComp->componentDataType() == theComponent) { + isFound = true; + DataObjectList anObjs; + aComp->children(anObjs, true); + + QList aViewMgrs; + QStringList::const_iterator itVMTypes = theViewManagerTypes.begin(); + for ( ; itVMTypes != theViewManagerTypes.end(); ++itVMTypes ) + viewManagers( *itVMTypes, aViewMgrs ); + + DataObjectList::const_iterator itObjs = anObjs.begin(); + for ( ; itObjs != anObjs.end(); itObjs++ ) { + LightApp_DataObject* anObj = dynamic_cast( *itObjs ); + QString anEntry = anObj->entry(); + + QListIterator itViewMgrs( aViewMgrs ); + while ( itViewMgrs.hasNext()) { + SUIT_ViewModel* aVM = itViewMgrs.next()->getViewModel(); + if ( aVM ) { + SALOME_View* aView = dynamic_cast(aVM); + if ( aView ) { + bool isDisp = aDisplayer->IsDisplayed( anEntry, aView ); + aDisplayer->Erase( anEntry, true, false, aView ); + if ( isDisp ) { + aDisplayer->Display( anEntry, false, aView ); + } + } + } + } } - aStudy->setVisibilityState( obj->entry(), anObjState ); } } } diff --git a/src/LightApp/LightApp_Application.h b/src/LightApp/LightApp_Application.h index da8ffc266..141f5f5c1 100644 --- a/src/LightApp/LightApp_Application.h +++ b/src/LightApp/LightApp_Application.h @@ -182,7 +182,10 @@ public: void emitOperationFinished( const QString&, const QString&, const QStringList& ); void updateVisibilityState( DataObjectList& theList, - SUIT_ViewModel* theViewModel ); + SUIT_ViewModel* theViewModel ); + + void updatePresentations( const QString& theComponent, + const QStringList& theViewManagerTypes ); virtual bool checkExistingDoc( bool = true ); @@ -320,8 +323,8 @@ protected: private: void emptyPreferences( const QString& ); QList findToolBars( const QStringList& names = QStringList() ); - - QByteArray processState(QByteArray& input, + + QByteArray processState(QByteArray& input, const bool processWin, const bool processTb, const bool isRestoring, diff --git a/src/LightApp/LightApp_Displayer.cxx b/src/LightApp/LightApp_Displayer.cxx index c369ecabd..fbc9200fd 100644 --- a/src/LightApp/LightApp_Displayer.cxx +++ b/src/LightApp/LightApp_Displayer.cxx @@ -298,33 +298,36 @@ bool LightApp_Displayer::canBeDisplayed( const QString& entry ) const /*! \return displayer, corresponding to module - \param mod_name - name of module + \param mod_name - name or title of module. + \note It is better to use name (component data type) + in any case when you are not sure the title is not empty. \param load - is module has to be forced loaded */ 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; } diff --git a/src/LightApp/LightApp_Module.cxx b/src/LightApp/LightApp_Module.cxx index ee0b2e505..ceb22eacd 100644 --- a/src/LightApp/LightApp_Module.cxx +++ b/src/LightApp/LightApp_Module.cxx @@ -463,9 +463,9 @@ QtxPopupMgr* LightApp_Module::popupMgr() myPopupMgr->insert( eraseAll, -1, 0 ); myPopupMgr->insert( separator(), -1, 0 ); - QString oneAndNotActive = "( count( $component ) = 1 ) and ( not( activeModule in $component ) )"; + QString oneAndNotActive = "( count( $component ) = 1 ) and ( not( activeModule in $component ) ) and ( not($displayer={'%3'}) )"; QString uniform = "true in $canBeDisplayed and %1 and ( activeModule = '%2' )"; - uniform = uniform.arg( oneAndNotActive ).arg( name() ); + uniform = uniform.arg( oneAndNotActive ).arg( name() ).arg( LightApp_Application::moduleDisplayer( name() ) ); myPopupMgr->setRule( disp, /*QString( "( not isVisible ) and " ) + */ uniform, QtxPopupMgr::VisibleRule ); myPopupMgr->setRule( erase, /*QString( "( isVisible ) and " ) + */ uniform, QtxPopupMgr::VisibleRule ); myPopupMgr->setRule( dispOnly, uniform, QtxPopupMgr::VisibleRule ); diff --git a/src/LightApp/LightApp_Selection.cxx b/src/LightApp/LightApp_Selection.cxx index b5b6ec743..ec2f910ba 100644 --- a/src/LightApp/LightApp_Selection.cxx +++ b/src/LightApp/LightApp_Selection.cxx @@ -215,8 +215,8 @@ QVariant LightApp_Selection::parameter( const int idx, const QString& p ) const QString e = entry( idx ); if ( !e.isEmpty() ) { if ( p == "isVisible" ) { - QString mod_name = app->moduleTitle( myStudy->componentDataType( e ) ); - LightApp_Displayer* d = LightApp_Displayer::FindDisplayer( mod_name, false ); + QString mname = myStudy->componentDataType( e ); + LightApp_Displayer* d = LightApp_Displayer::FindDisplayer( mname, false ); // false in last parameter means that now we doesn't load module, if it isn't loaded bool vis = false; @@ -226,15 +226,17 @@ QVariant LightApp_Selection::parameter( const int idx, const QString& p ) const vis = LightApp_Displayer().IsDisplayed( e ); v = vis; } - else if ( p == "component" || p == "displayer" ) - v = myStudy->componentDataType( e ); + else if ( p == "component" ) + v = myStudy->componentDataType( e ); + else if ( p == "displayer" ) + v = LightApp_Application::moduleDisplayer( myStudy->componentDataType( e ) ); else if ( p == "isComponent" ) v = myStudy->isComponent( e ); else if ( p == "isReference" ) v = isReference( idx ); else if ( p == "canBeDisplayed" ) { - QString mod_name = app->moduleTitle( myStudy->componentDataType( e ) ); - LightApp_Displayer* d = LightApp_Displayer::FindDisplayer( mod_name, false ); + QString mname = myStudy->componentDataType( e ) ; + LightApp_Displayer* d = LightApp_Displayer::FindDisplayer( mname, false ); // false in last parameter means that now we doesn't load module, if it isn't loaded if ( d ) diff --git a/src/LightApp/LightApp_ShowHideOp.cxx b/src/LightApp/LightApp_ShowHideOp.cxx index 3c313941d..a940de8fc 100644 --- a/src/LightApp/LightApp_ShowHideOp.cxx +++ b/src/LightApp/LightApp_ShowHideOp.cxx @@ -88,7 +88,7 @@ void LightApp_ShowHideOp::startOperation() QStringList::const_iterator anIt = comps.begin(), aLast = comps.end(); for( ; anIt!=aLast; anIt++ ) { - LightApp_Displayer* disp = LightApp_Displayer::FindDisplayer( app->moduleTitle( *anIt ), false ); + LightApp_Displayer* disp = LightApp_Displayer::FindDisplayer( *anIt, false ); if( disp ) disp->EraseAll( false, false, 0 ); } @@ -105,11 +105,11 @@ void LightApp_ShowHideOp::startOperation() QString mod_name; if( sel->count()>0 ) { - QString aStr = sel->parameter( 0, "displayer" ).toString(); - mod_name = app->moduleTitle( aStr ); + QString aStr = sel->parameter( 0, "displayer" ).toString(); + mod_name = aStr; } else if( app->activeModule() ) - mod_name = app->moduleTitle( app->activeModule()->name() ); + mod_name = app->activeModule()->name(); LightApp_Displayer* d = LightApp_Displayer::FindDisplayer( mod_name, true ); if( !d ) diff --git a/src/SALOME_SWIG/SALOMEGUI_Swig.cxx b/src/SALOME_SWIG/SALOMEGUI_Swig.cxx index 60f31e8f1..2109b4399 100644 --- a/src/SALOME_SWIG/SALOMEGUI_Swig.cxx +++ b/src/SALOME_SWIG/SALOMEGUI_Swig.cxx @@ -418,7 +418,7 @@ void SALOMEGUI_Swig::Display( const char* theEntry ) LightApp_Application* anApp = getApplication(); LightApp_Study* aStudy = getActiveStudy(); if ( anApp && aStudy ) { - QString mname = anApp->moduleTitle( aStudy->componentDataType( myEntry ) ); + QString mname = aStudy->componentDataType( myEntry ); LightApp_Displayer* d = LightApp_Displayer::FindDisplayer( mname, true ); if ( d ) { QStringList entries; @@ -459,11 +459,11 @@ void SALOMEGUI_Swig::DisplayOnly( const char* theEntry ) QStringList comps; aStudy->components( comps ); foreach( QString comp, comps ) { - LightApp_Displayer* d = LightApp_Displayer::FindDisplayer( anApp->moduleTitle( comp ), false ); + LightApp_Displayer* d = LightApp_Displayer::FindDisplayer( comp, false ); if ( d ) d->EraseAll( false, false, 0 ); } - QString mname = anApp->moduleTitle( aStudy->componentDataType( myEntry ) ); + QString mname = aStudy->componentDataType( myEntry ); LightApp_Displayer* d = LightApp_Displayer::FindDisplayer( mname, true ); if ( d ) { QStringList entries; @@ -500,7 +500,7 @@ void SALOMEGUI_Swig::Erase( const char* theEntry ) LightApp_Application* anApp = getApplication(); LightApp_Study* aStudy = getActiveStudy(); if ( anApp && aStudy ) { - QString mname = anApp->moduleTitle( aStudy->componentDataType( myEntry ) ); + QString mname = aStudy->componentDataType( myEntry ); LightApp_Displayer* d = LightApp_Displayer::FindDisplayer( mname, true ); if ( d ) { QStringList entries; @@ -538,7 +538,7 @@ void SALOMEGUI_Swig::DisplayAll() QStringList comps; aStudy->components( comps ); foreach( QString comp, comps ) { - LightApp_Displayer* d = LightApp_Displayer::FindDisplayer( anApp->moduleTitle( comp ), true ); + LightApp_Displayer* d = LightApp_Displayer::FindDisplayer( comp, true ); if ( d ) { QStringList entries; aStudy->children( aStudy->centry( comp ), entries ); @@ -569,7 +569,7 @@ void SALOMEGUI_Swig::EraseAll() QStringList comps; aStudy->components( comps ); foreach( QString comp, comps ) { - LightApp_Displayer* d = LightApp_Displayer::FindDisplayer( anApp->moduleTitle( comp ), false ); + LightApp_Displayer* d = LightApp_Displayer::FindDisplayer( comp, false ); if ( d ) d->EraseAll( false, false, 0 ); } } diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index bfb209efa..ec5f66cc0 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -813,6 +813,8 @@ void SalomeApp_Application::onOpenWith() Handle(SALOME_InteractiveObject) aIObj = aList.First(); QString aModuleName(aIObj->getComponentDataType()); QString aModuleTitle = moduleTitle(aModuleName); + if (aModuleTitle.isEmpty()) // no gui + aModuleTitle = moduleDisplayer(aModuleName); activateModule(aModuleTitle); QApplication::restoreOverrideCursor(); } @@ -1488,9 +1490,14 @@ void SalomeApp_Application::contextMenuPopup( const QString& type, QMenu* thePop if ( !entry.startsWith( tr( "SAVE_POINT_DEF_NAME" ) ) ) { QString aModuleName( aIObj->getComponentDataType() ); QString aModuleTitle = moduleTitle( aModuleName ); + if (aModuleTitle.isEmpty()) { + // use displayer module, if given + aModuleTitle = moduleDisplayer( aModuleName ); + } CAM_Module* currentModule = activeModule(); - if ( ( !currentModule || currentModule->moduleName() != aModuleTitle ) && !aModuleTitle.isEmpty() ) + if ( ( !currentModule || currentModule->moduleName() != aModuleTitle ) && !aModuleTitle.isEmpty() ) { thePopup->addAction( tr( "MEN_OPENWITH" ).arg( aModuleTitle ), this, SLOT( onOpenWith() ) ); + } } } diff --git a/src/SalomeApp/SalomeApp_Study.cxx b/src/SalomeApp/SalomeApp_Study.cxx index c68065232..633154329 100644 --- a/src/SalomeApp/SalomeApp_Study.cxx +++ b/src/SalomeApp/SalomeApp_Study.cxx @@ -190,17 +190,16 @@ public: /* Define visibility state */ bool isComponent = dynamic_cast( suit_obj ) != 0; if ( suit_obj && !isComponent && myStudy->visibilityState( theID.c_str() ) == Qtx::UnpresentableState ) { - QString moduleTitle = ((CAM_Application*)myStudy->application())->moduleTitle(suit_obj->componentDataType()); - if (!moduleTitle.isEmpty()) { - LightApp_Displayer* aDisplayer = LightApp_Displayer::FindDisplayer(moduleTitle,false); - if (aDisplayer) { - if(aDisplayer->canBeDisplayed(theID.c_str())) { - myStudy->setVisibilityState( theID.c_str(), Qtx::HiddenState ); //hide the just added object - //MESSAGE("Object with entry : "<< theID <<" CAN be displayed !!!"); - } - //else - //MESSAGE("Object with entry : "<< theID <<" CAN'T be displayed !!!"); + LightApp_Displayer* aDisplayer = LightApp_Displayer::FindDisplayer + (suit_obj->componentDataType(),false); + if (aDisplayer) { + if (aDisplayer->canBeDisplayed(theID.c_str())) { + //hide the just added object + myStudy->setVisibilityState( theID.c_str(), Qtx::HiddenState ); + //MESSAGE("Object with entry : "<< theID <<" CAN be displayed !!!"); } + //else + // MESSAGE("Object with entry : "<< theID <<" CAN'T be displayed !!!"); } } } // END: work with tree nodes structure @@ -323,17 +322,15 @@ public: /* Define visibility state */ bool isComponent = dynamic_cast( suit_obj ) != 0; if ( suit_obj && !isComponent ) { - QString moduleTitle = ((CAM_Application*)myStudy->application())->moduleTitle(suit_obj->componentDataType()); - if (!moduleTitle.isEmpty()) { - LightApp_Displayer* aDisplayer = LightApp_Displayer::FindDisplayer(moduleTitle,false); - if (aDisplayer) { - if(aDisplayer->canBeDisplayed(theID.c_str())) { - myStudy->setVisibilityState( theID.c_str(), Qtx::HiddenState ); - //MESSAGE("Object with entry : "<< theID <<" CAN be displayed !!!"); - } - //else - //MESSAGE("Object with entry : "<< theID <<" CAN'T be displayed !!!"); + LightApp_Displayer* aDisplayer = LightApp_Displayer::FindDisplayer + (suit_obj->componentDataType(),false); + if (aDisplayer) { + if (aDisplayer->canBeDisplayed(theID.c_str())) { + myStudy->setVisibilityState( theID.c_str(), Qtx::HiddenState ); + //MESSAGE("Object with entry : "<< theID <<" CAN be displayed !!!"); } + //else + // MESSAGE("Object with entry : "<< theID <<" CAN'T be displayed !!!"); } } break; -- 2.39.2