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

index 88d61b8c396a5ee9e5ad7c916d7823063a25afca..ba2963891d7fd04ba01fd8d56710e09e739888ee 100644 (file)
@@ -1551,6 +1551,7 @@ void SVTK_InteractorStyle::OnTimer()
   // check if bounding box was changed
   if ( GetCurrentRenderer() )
   {
+    GetCurrentRenderer()->Render();
     double aCurrBBCenter[3];
     if ( ComputeBBCenter(GetCurrentRenderer(),aCurrBBCenter) )
     {
index 592333012fe96a25b9c059081a03090f3a9937b1..216c9f8ae207e1b2a5890d6a9f3f98dec847a8c9 100644 (file)
@@ -21,8 +21,8 @@
 //
 
 //  SALOME VTKViewer : build VTK viewer into Salome desktop
-//  File   : 
-//  Author : 
+//  File   :
+//  Author :
 
 #include "SVTK_RenderWindowInteractor.h"
 
@@ -40,8 +40,8 @@
 #endif
 #include <QMouseEvent>
 
-#include "SVTK_SpaceMouse.h" 
-#include "SVTK_Event.h" 
+#include "SVTK_SpaceMouse.h"
+#include "SVTK_Event.h"
 
 #include "VTKViewer_Algorithm.h"
 
@@ -67,7 +67,7 @@ static bool FOCUS_UNDER_MOUSE = false;
   Constructor
 */
 QVTK_RenderWindowInteractor
-::QVTK_RenderWindowInteractor(QWidget* theParent, 
+::QVTK_RenderWindowInteractor(QWidget* theParent,
                               const char* theName):
   QWidget(theParent),
   myRenderWindow(vtkRenderWindow::New())
@@ -91,7 +91,7 @@ QVTK_RenderWindowInteractor
 /*!
   To initialize by vtkGenericRenderWindowInteractor instance
 */
-void 
+void
 QVTK_RenderWindowInteractor
 ::Initialize(vtkGenericRenderWindowInteractor* theDevice)
 {
@@ -108,7 +108,7 @@ QVTK_RenderWindowInteractor
   Destructor
 */
 QVTK_RenderWindowInteractor
-::~QVTK_RenderWindowInteractor() 
+::~QVTK_RenderWindowInteractor()
 {
 #if !defined WIN32 && !defined __APPLE__
   SVTK_SpaceMouseXCB* aSpaceMouse = SVTK_SpaceMouseXCB::getInstance();
@@ -121,7 +121,7 @@ QVTK_RenderWindowInteractor
 /*!
   \return corresponding render window interactor
 */
-vtkGenericRenderWindowInteractor* 
+vtkGenericRenderWindowInteractor*
 QVTK_RenderWindowInteractor
 ::GetDevice()
 {
@@ -187,7 +187,7 @@ QVTK_RenderWindowInteractor
 */
 void
 QVTK_RenderWindowInteractor
-::resize(int w, int h) 
+::resize(int w, int h)
 {
   GetDevice()->UpdateSize(w,h);
 }
@@ -197,7 +197,7 @@ QVTK_RenderWindowInteractor
 */
 void
 QVTK_RenderWindowInteractor
-::paintEvent( QPaintEvent* theEvent ) 
+::paintEvent( QPaintEvent* theEvent )
 {
   GetDevice()->CreateTimer(VTKI_TIMER_FIRST);
 }
@@ -233,7 +233,7 @@ QVTK_RenderWindowInteractor
     }
   }
 
-  update(); 
+  update();
 }
 
 
@@ -251,9 +251,9 @@ QVTK_RenderWindowInteractor
 */
 void
 QVTK_RenderWindowInteractor
-::mouseMoveEvent( QMouseEvent* event ) 
+::mouseMoveEvent( QMouseEvent* event )
 {
-  GetDevice()->SetEventInformationFlipY(event->x(), 
+  GetDevice()->SetEventInformationFlipY(event->x(),
                                         event->y(),
                                         event->modifiers() & Qt::ControlModifier,
                                         event->modifiers() & Qt::ShiftModifier);
@@ -266,9 +266,9 @@ QVTK_RenderWindowInteractor
 */
 void
 QVTK_RenderWindowInteractor
-::mousePressEvent( QMouseEvent* event ) 
+::mousePressEvent( QMouseEvent* event )
 {
-  GetDevice()->SetEventInformationFlipY(event->x(), 
+  GetDevice()->SetEventInformationFlipY(event->x(),
                                         event->y(),
                                         event->modifiers() & Qt::ControlModifier,
                                         event->modifiers() & Qt::ShiftModifier);
@@ -288,7 +288,7 @@ void
 QVTK_RenderWindowInteractor
 ::mouseReleaseEvent( QMouseEvent *event )
 {
-  GetDevice()->SetEventInformationFlipY(event->x(), 
+  GetDevice()->SetEventInformationFlipY(event->x(),
                                         event->y(),
                                         event->modifiers() & Qt::ControlModifier,
                                         event->modifiers() & Qt::ShiftModifier);
@@ -334,7 +334,7 @@ QVTK_RenderWindowInteractor
 {
   activateWindow();
   setFocus();
-  GetDevice()->SetEventInformationFlipY(event->x(), 
+  GetDevice()->SetEventInformationFlipY(event->x(),
                                         event->y(),
                                         event->modifiers() & Qt::ControlModifier,
                                         event->modifiers() & Qt::ShiftModifier);
@@ -350,7 +350,7 @@ QVTK_RenderWindowInteractor
 */
 void
 QVTK_RenderWindowInteractor
-::keyPressEvent( QKeyEvent* event ) 
+::keyPressEvent( QKeyEvent* event )
 {
   GetDevice()->SetKeyEventInformation(event->modifiers() & Qt::ControlModifier,
                                       event->modifiers() & Qt::ShiftModifier,
@@ -364,7 +364,7 @@ QVTK_RenderWindowInteractor
 */
 void
 QVTK_RenderWindowInteractor
-::keyReleaseEvent( QKeyEvent * event ) 
+::keyReleaseEvent( QKeyEvent * event )
 {
   GetDevice()->SetKeyEventInformation(event->modifiers() & Qt::ControlModifier,
                                       event->modifiers() & Qt::ShiftModifier,
@@ -376,7 +376,7 @@ QVTK_RenderWindowInteractor
 /*!
   Custom enter event handler
 */
-void  
+void
 QVTK_RenderWindowInteractor
 ::enterEvent( QEvent* event )
 {
@@ -390,7 +390,7 @@ QVTK_RenderWindowInteractor
 /*!
   Custom leave event handler
 */
-void  
+void
 QVTK_RenderWindowInteractor
 ::leaveEvent( QEvent * )
 {
@@ -399,9 +399,9 @@ QVTK_RenderWindowInteractor
 
 /*!
   Reimplemented from QWidget in order to set window - receiver
-  of space mouse events. 
+  of space mouse events.
 */
-void  
+void
 QVTK_RenderWindowInteractor
 ::focusInEvent( QFocusEvent* event )
 {
@@ -423,9 +423,9 @@ QVTK_RenderWindowInteractor
 
 /*!
   Reimplemented from QWidget in order to set window - receiver
-  of space mouse events. 
+  of space mouse events.
 */
-void  
+void
 QVTK_RenderWindowInteractor
 ::focusOutEvent ( QFocusEvent* event )
 {
@@ -476,14 +476,14 @@ bool QVTK_RenderWindowInteractor
   Constructor
 */
 SVTK_RenderWindowInteractor
-::SVTK_RenderWindowInteractor(QWidget* theParent, 
+::SVTK_RenderWindowInteractor(QWidget* theParent,
                                const char* theName):
   QVTK_RenderWindowInteractor(theParent,theName),
   myEventCallbackCommand(vtkCallbackCommand::New())
 {
   myEventCallbackCommand->Delete();
 
-  myEventCallbackCommand->SetClientData(this); 
+  myEventCallbackCommand->SetClientData(this);
   myPriority = 0.0;
 
   myEventCallbackCommand->SetCallback(SVTK_RenderWindowInteractor::ProcessEvents);
@@ -507,11 +507,11 @@ SVTK_RenderWindowInteractor
   Destructor
 */
 SVTK_RenderWindowInteractor
-::~SVTK_RenderWindowInteractor() 
+::~SVTK_RenderWindowInteractor()
 {
   // Sequence of the destruction call are fixed and should be changed.
   // vtkRenderWindow instance should be destroyed after all vtkRenderer's
-  GetDevice()->SetInteractorStyle(NULL); 
+  GetDevice()->SetInteractorStyle(NULL);
   while(!myInteractorStyles.empty()){
     const PInteractorStyle& aStyle = myInteractorStyles.top();
     aStyle->SetInteractor(NULL);
@@ -522,7 +522,7 @@ SVTK_RenderWindowInteractor
 /*!
   To get corresponding SVTK_Renderer instance
 */
-SVTK_Renderer* 
+SVTK_Renderer*
 SVTK_RenderWindowInteractor
 ::GetRenderer()
 {
@@ -532,7 +532,7 @@ SVTK_RenderWindowInteractor
 /*!
   To get corresponding SVTK_Renderer device (just to simplify collobaration with SVTK_Renderer)
 */
-vtkRenderer* 
+vtkRenderer*
 SVTK_RenderWindowInteractor
 ::getRenderer()
 {
@@ -568,7 +568,7 @@ void
 SVTK_RenderWindowInteractor
 ::InitInteractorStyle(vtkInteractorStyle* theStyle)
 {
-  GetDevice()->SetInteractorStyle(theStyle); 
+  GetDevice()->SetInteractorStyle(theStyle);
 }
 
 /*!
@@ -591,15 +591,15 @@ SVTK_RenderWindowInteractor
 {
   if(GetInteractorStyle())
     myInteractorStyles.pop();
-  
-  if(GetInteractorStyle()) 
+
+  if(GetInteractorStyle())
     InitInteractorStyle(GetInteractorStyle());
 }
 
 /*!
   To get current interactor style
 */
-vtkInteractorStyle* 
+vtkInteractorStyle*
 SVTK_RenderWindowInteractor
 ::GetInteractorStyle()
 {
@@ -610,11 +610,11 @@ SVTK_RenderWindowInteractor
 /*!
   To get current selector
 */
-SVTK_Selector* 
+SVTK_Selector*
 SVTK_RenderWindowInteractor
-::GetSelector() 
-{ 
-  return mySelector.GetPointer(); 
+::GetSelector()
+{
+  return mySelector.GetPointer();
 }
 
 
@@ -625,26 +625,26 @@ SVTK_RenderWindowInteractor
 void
 SVTK_RenderWindowInteractor
 ::SetSelector(SVTK_Selector* theSelector)
-{ 
+{
   if(mySelector.GetPointer())
     mySelector->RemoveObserver(myEventCallbackCommand.GetPointer());
 
-  mySelector = theSelector; 
+  mySelector = theSelector;
 
   if(mySelector.GetPointer())
-    mySelector->AddObserver(vtkCommand::EndPickEvent, 
-                            myEventCallbackCommand.GetPointer(), 
+    mySelector->AddObserver(vtkCommand::EndPickEvent,
+                            myEventCallbackCommand.GetPointer(),
                             myPriority);
 }
 
 /*!
   Main process VTK event method
 */
-void 
+void
 SVTK_RenderWindowInteractor
-::ProcessEvents(vtkObject* vtkNotUsed(theObject), 
+::ProcessEvents(vtkObject* vtkNotUsed(theObject),
                 unsigned long theEvent,
-                void* theClientData, 
+                void* theClientData,
                 void* vtkNotUsed(theCallData))
 {
   SVTK_RenderWindowInteractor* self = reinterpret_cast<SVTK_RenderWindowInteractor*>(theClientData);
@@ -693,7 +693,7 @@ SVTK_RenderWindowInteractor
 */
 void
 SVTK_RenderWindowInteractor
-::mouseMoveEvent( QMouseEvent* event ) 
+::mouseMoveEvent( QMouseEvent* event )
 {
   QVTK_RenderWindowInteractor::mouseMoveEvent(event);
 
@@ -707,7 +707,7 @@ SVTK_RenderWindowInteractor
 */
 void
 SVTK_RenderWindowInteractor
-::mousePressEvent( QMouseEvent* event ) 
+::mousePressEvent( QMouseEvent* event )
 {
   QVTK_RenderWindowInteractor::mousePressEvent(event);
 
@@ -795,7 +795,7 @@ SVTK_RenderWindowInteractor
 */
 void
 SVTK_RenderWindowInteractor
-::keyPressEvent( QKeyEvent* event ) 
+::keyPressEvent( QKeyEvent* event )
 {
   QVTK_RenderWindowInteractor::keyPressEvent(event);
 
@@ -808,7 +808,7 @@ SVTK_RenderWindowInteractor
 */
 void
 SVTK_RenderWindowInteractor
-::keyReleaseEvent( QKeyEvent * event ) 
+::keyReleaseEvent( QKeyEvent * event )
 {
   QVTK_RenderWindowInteractor::keyReleaseEvent(event);
 
index cf8f11a7bd95c6cdbf94b44df0356ec4c3e36718..8d800745f1b5278c98fbb37f5420c70e4aabe821 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,8 @@ 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 +868,12 @@ void SVTK_Viewer::onActorRemoved(VTKViewer_Actor* theActor)
 {
   emit actorRemoved((SVTK_ViewWindow*)sender(), theActor);
 }
+
+void SVTK_Viewer::onViewCreated( SUIT_ViewWindow* view) {
+  if ( SVTK_ViewWindow* svw = dynamic_cast<SVTK_ViewWindow*>( view ) ){
+    QTimer *timer = new QTimer(this);
+    timer->setSingleShot(true);
+    connect(timer, &QTimer::timeout, [svw] () { svw->Repaint(); } );
+    timer->start(250);
+  }
+}
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..187fe1809b1c930f88e78c710afb25b5db07e524 100644 (file)
@@ -789,8 +789,14 @@ void SVTK_ViewWindow::Repaint(bool theUpdateTrihedron)
   GetInteractor()->update();
 
   SVTK_InteractorStyle* aStyle = (SVTK_InteractorStyle*)getInteractor()->GetInteractorStyle();
-  if ( aStyle )
+  if ( aStyle ) {
+    if ( aStyle->GetCurrentRenderer() == nullptr ) {
+      if( GetRenderer() ) {
+       aStyle->SetCurrentRenderer(GetRenderer()->GetDevice());
+      }
+    }  
     aStyle->OnTimer();
+  }
 }
 
 /*!