]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
[CEA 19033] With VirtualGL, VTK viewer is void : minor corrections
authorvsr <vsr@opencascade.com>
Wed, 19 Aug 2020 12:36:54 +0000 (15:36 +0300)
committervsr <vsr@opencascade.com>
Wed, 19 Aug 2020 12:36:54 +0000 (15:36 +0300)
src/SVTK/SVTK.h
src/SVTK/SVTK_InteractorStyle.cxx
src/SVTK/SVTK_RenderWindowInteractor.cxx
src/SVTK/SVTK_ViewModel.cxx
src/SVTK/SVTK_ViewWindow.cxx

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 ba2963891d7fd04ba01fd8d56710e09e739888ee..a717d752ab55a05c0d4b9577fe1aac3db3963bc4 100644 (file)
@@ -1551,7 +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 216c9f8ae207e1b2a5890d6a9f3f98dec847a8c9..592333012fe96a25b9c059081a03090f3a9937b1 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 8d800745f1b5278c98fbb37f5420c70e4aabe821..0e062d85cc720f4246702bd8d353aa4d3662d890 100644 (file)
@@ -529,8 +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* ) ) );
+
+  connect(theViewManager, SIGNAL(viewCreated(SUIT_ViewWindow*)), 
+         this, SLOT(onViewCreated(SUIT_ViewWindow*)));
 }
 
 /*!
@@ -870,10 +871,8 @@ void SVTK_Viewer::onActorRemoved(VTKViewer_Actor* 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);
-  }
+#ifdef VGL_WORKAROUND
+  if ( SVTK_ViewWindow* svw = dynamic_cast<SVTK_ViewWindow*>( view ) )
+    QTimer::singleShot(500, [svw] () { svw->Repaint(); } );
+#endif
 }
index 187fe1809b1c930f88e78c710afb25b5db07e524..59e07e88e0ed043888ba19b8170aa4a26ee4cacf 100644 (file)
@@ -790,11 +790,13 @@ void SVTK_ViewWindow::Repaint(bool theUpdateTrihedron)
 
   SVTK_InteractorStyle* aStyle = (SVTK_InteractorStyle*)getInteractor()->GetInteractorStyle();
   if ( aStyle ) {
+#ifdef VGL_WORKAROUND
     if ( aStyle->GetCurrentRenderer() == nullptr ) {
       if( GetRenderer() ) {
-       aStyle->SetCurrentRenderer(GetRenderer()->GetDevice());
+        aStyle->SetCurrentRenderer(GetRenderer()->GetDevice());
       }
     }  
+#endif
     aStyle->OnTimer();
   }
 }