From ca17cb3a112faecc9b0cc524892f3f0baa575d58 Mon Sep 17 00:00:00 2001 From: jfa Date: Thu, 21 Jan 2021 11:54:09 +0300 Subject: [PATCH] Update SHAPERSTUDY objects in the viewers after SHAPER objects modification --- src/LightApp/LightApp_Application.cxx | 75 ++++++++++++++++++++++----- src/LightApp/LightApp_Application.h | 9 ++-- 2 files changed, 68 insertions(+), 16 deletions(-) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 9ced671ae..f28b5b14f 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -464,7 +464,7 @@ void LightApp_Application::closeApplication() #ifndef DISABLE_QTXWEBBROWSER QProcess::startDetached( "HelpBrowser", QStringList() << QString( "--remove=%1" ).arg( QApplication::instance()->applicationPid() ) ); -#endif +#endif CAM_Application::closeApplication(); } @@ -539,7 +539,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 ); } @@ -594,7 +594,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 @@ -705,7 +705,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 @@ -719,7 +719,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() ) ); @@ -745,9 +745,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() ) ); @@ -1006,7 +1006,7 @@ void LightApp_Application::onNewDoc() //asl: fix for 0020515 saveDockWindowsState(); - + CAM_Application::onNewDoc(); } @@ -1064,7 +1064,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 ) @@ -1236,7 +1236,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 @@ -1248,7 +1248,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 ); @@ -1455,7 +1455,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 */ @@ -2345,7 +2345,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" ); @@ -5211,6 +5211,55 @@ void LightApp_Application::updateVisibilityState( DataObjectList& theList, } } +/*! + 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 ) { + if ( aDisplayer->IsDisplayed( anEntry, aView ) ) { + aDisplayer->Erase( anEntry, false, false, aView ); + aDisplayer->Display( anEntry, false, aView ); + } + } + } + } + } + } + } + } +} + /*! * Called when window activated */ diff --git a/src/LightApp/LightApp_Application.h b/src/LightApp/LightApp_Application.h index 448294867..e0ba3c495 100644 --- a/src/LightApp/LightApp_Application.h +++ b/src/LightApp/LightApp_Application.h @@ -178,7 +178,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 ); @@ -314,8 +317,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, -- 2.39.2