From 2161ad4dc7bc40634dd626b07cb6d0ce3c1aa3e0 Mon Sep 17 00:00:00 2001 From: rnv Date: Wed, 19 Aug 2020 13:23:24 +0300 Subject: [PATCH] [CEA 19033] With VirtualGL, VTK viewer is void --- src/SVTK/SVTK.h | 2 ++ src/SVTK/SVTK_InteractorStyle.cxx | 3 +++ src/SVTK/SVTK_ViewModel.cxx | 13 ++++++++++++- src/SVTK/SVTK_ViewModel.h | 2 ++ src/SVTK/SVTK_ViewWindow.cxx | 18 +++++++++++++++++- src/SVTK/SVTK_ViewWindow.h | 3 +++ 6 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/SVTK/SVTK.h b/src/SVTK/SVTK.h index 6426fda17..dccb7f233 100644 --- a/src/SVTK/SVTK.h +++ b/src/SVTK/SVTK.h @@ -25,6 +25,8 @@ #include "VTKViewer.h" +#define VGL_WORKAROUND + #ifdef WIN32 # if defined SVTK_EXPORTS # define SVTK_EXPORT __declspec(dllexport) diff --git a/src/SVTK/SVTK_InteractorStyle.cxx b/src/SVTK/SVTK_InteractorStyle.cxx index 88d61b8c3..a717d752a 100644 --- a/src/SVTK/SVTK_InteractorStyle.cxx +++ b/src/SVTK/SVTK_InteractorStyle.cxx @@ -1551,6 +1551,9 @@ void SVTK_InteractorStyle::OnTimer() // check if bounding box was changed if ( GetCurrentRenderer() ) { +#ifdef VGL_WORKAROUND + GetCurrentRenderer()->Render(); +#endif double aCurrBBCenter[3]; if ( ComputeBBCenter(GetCurrentRenderer(),aCurrBBCenter) ) { diff --git a/src/SVTK/SVTK_ViewModel.cxx b/src/SVTK/SVTK_ViewModel.cxx index cf8f11a7b..0e062d85c 100644 --- a/src/SVTK/SVTK_ViewModel.cxx +++ b/src/SVTK/SVTK_ViewModel.cxx @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -186,7 +187,7 @@ SUIT_ViewWindow* SVTK_Viewer::createView( SUIT_Desktop* theDesktop ) this, SLOT(onActorAdded(VTKViewer_Actor*))); connect(aViewWindow, SIGNAL( actorRemoved(VTKViewer_Actor*) ), this, SLOT(onActorRemoved(VTKViewer_Actor*))); - + return aViewWindow; } @@ -528,6 +529,9 @@ void SVTK_Viewer::setViewManager(SUIT_ViewManager* theViewManager) connect(theViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)), this, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*))); + + connect(theViewManager, SIGNAL(viewCreated(SUIT_ViewWindow*)), + this, SLOT(onViewCreated(SUIT_ViewWindow*))); } /*! @@ -865,3 +869,10 @@ void SVTK_Viewer::onActorRemoved(VTKViewer_Actor* theActor) { emit actorRemoved((SVTK_ViewWindow*)sender(), theActor); } + +void SVTK_Viewer::onViewCreated( SUIT_ViewWindow* view) { +#ifdef VGL_WORKAROUND + if ( SVTK_ViewWindow* svw = dynamic_cast( view ) ) + QTimer::singleShot(500, [svw] () { svw->Repaint(); } ); +#endif +} diff --git a/src/SVTK/SVTK_ViewModel.h b/src/SVTK/SVTK_ViewModel.h index e341fb736..c47219786 100644 --- a/src/SVTK/SVTK_ViewModel.h +++ b/src/SVTK/SVTK_ViewModel.h @@ -220,6 +220,8 @@ protected slots: void onActorAdded(VTKViewer_Actor*); void onActorRemoved(VTKViewer_Actor*); + void onViewCreated( SUIT_ViewWindow* ); + private: void updateToolBars(); diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index 7e8a5aaf6..72b366c88 100644 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -789,8 +790,16 @@ void SVTK_ViewWindow::Repaint(bool theUpdateTrihedron) GetInteractor()->update(); SVTK_InteractorStyle* aStyle = (SVTK_InteractorStyle*)getInteractor()->GetInteractorStyle(); - if ( aStyle ) + if ( aStyle ) { +#ifdef VGL_WORKAROUND + if ( aStyle->GetCurrentRenderer() == nullptr ) { + if( GetRenderer() ) { + aStyle->SetCurrentRenderer(GetRenderer()->GetDevice()); + } + } +#endif aStyle->OnTimer(); + } } /*! @@ -2828,3 +2837,10 @@ void SVTK_ViewWindow::synchronize( SUIT_ViewWindow* theView ) blockSignals( blocked ); } + +void SVTK_ViewWindow::resizeEvent( QResizeEvent* theEvent ) +{ +#ifdef VGL_WORKAROUND + Repaint(); +#endif +} diff --git a/src/SVTK/SVTK_ViewWindow.h b/src/SVTK/SVTK_ViewWindow.h index 5e8980bb7..0ab5d7920 100644 --- a/src/SVTK/SVTK_ViewWindow.h +++ b/src/SVTK/SVTK_ViewWindow.h @@ -416,6 +416,9 @@ public: enum AnaglyphFilter { RedCyan, YellowBlue, GreenMagenta }; protected: + + virtual void resizeEvent( QResizeEvent* ); + virtual void Initialize(SVTK_View* theView, SVTK_ViewModelBase* theModel); -- 2.39.2