]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
[CEA 19033] With VirtualGL, VTK viewer is void
authorrnv <rnv@opencascade.com>
Wed, 19 Aug 2020 10:23:24 +0000 (13:23 +0300)
committerrnv <rnv@opencascade.com>
Wed, 9 Sep 2020 12:08:16 +0000 (15:08 +0300)
src/SVTK/SVTK.h
src/SVTK/SVTK_InteractorStyle.cxx
src/SVTK/SVTK_ViewModel.cxx
src/SVTK/SVTK_ViewModel.h
src/SVTK/SVTK_ViewWindow.cxx
src/SVTK/SVTK_ViewWindow.h

index 6426fda17262f6906067eb26b8d8fb9402418934..dccb7f233beb98f2ef4b26031f8b5606bcf58d50 100644 (file)
@@ -25,6 +25,8 @@
 
 #include "VTKViewer.h"
 
+#define VGL_WORKAROUND
+
 #ifdef WIN32
 #  if defined SVTK_EXPORTS
 #    define SVTK_EXPORT __declspec(dllexport)
index 88d61b8c396a5ee9e5ad7c916d7823063a25afca..a717d752ab55a05c0d4b9577fe1aac3db3963bc4 100644 (file)
@@ -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) )
     {
index cf8f11a7bd95c6cdbf94b44df0356ec4c3e36718..0e062d85cc720f4246702bd8d353aa4d3662d890 100644 (file)
@@ -23,6 +23,7 @@
 #include <QMenu>
 #include <QColorDialog>
 #include <QToolBar>
+#include <QTimer>
 
 #include <vtkCamera.h>
 #include <vtkRenderer.h>
@@ -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<SVTK_ViewWindow*>( view ) )
+    QTimer::singleShot(500, [svw] () { svw->Repaint(); } );
+#endif
+}
index e341fb736c973da9b2476c2de2fb150283f62f7c..c47219786d97469b194960ee8b0ce142bb7514f5 100644 (file)
@@ -220,6 +220,8 @@ protected slots:
   void onActorAdded(VTKViewer_Actor*);
   void onActorRemoved(VTKViewer_Actor*);
 
+  void onViewCreated( SUIT_ViewWindow* );
+
 private:
   void updateToolBars();
 
index 7e8a5aaf6b50621c4d424a485cef6661ad549620..72b366c887270ff29410523774972b94d1cd05fd 100644 (file)
@@ -34,6 +34,7 @@
 
 #include <QMenu>
 #include <QToolBar>
+#include <QTimer>
 #include <QEvent>
 #include <QFileInfo>
 #include <QSignalMapper>
@@ -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
+}
index 5e8980bb76902cc766bd5596ff58ae678271d092..0ab5d79204351fd0661ddeb782b8d2dd13f2a2ac 100644 (file)
@@ -416,6 +416,9 @@ public:
   enum AnaglyphFilter { RedCyan, YellowBlue, GreenMagenta };
 
 protected:
+  
+  virtual void resizeEvent( QResizeEvent* );
+  
   virtual void Initialize(SVTK_View* theView,
                           SVTK_ViewModelBase* theModel);