[vtkusers] QVTKOpenGLWidget with vtkBalloonWidget bug?

Ivan Kosik ivankosik91 at gmail.com
Wed Apr 25 08:49:26 EDT 2018


Moving from the old QVTKWidget to the new QVTKOpenGLWidget, I noticed the
bug, when a vtkBalloonWidget was added to the QVTKInteractor. When
QVTKOpenGLWidget
object lose the focus, then it becomes black (when you move mouse over it,
then all is OK again).
Video is here:
https://youtu.be/aRlfiZpFFqE

The code to reproduce the bug:

#include <QApplication>

#include <QSurfaceFormat>


#include <QVTKOpenGLWidget.h>

#include <vtkRenderer.h>

#include <vtkGenericOpenGLRenderWindow.h>

#include <vtkBalloonWidget.h>

#include <vtkSphereSource.h>

#include <vtkPolyDataMapper.h>


#include <vtkAutoInit.h>

VTK_MODULE_INIT(vtkInteractionStyle)

VTK_MODULE_INIT(vtkRenderingOpenGL2)



int main(int argc, char *argv[])

{

    QSurfaceFormat::setDefaultFormat(QVTKOpenGLWidget::defaultFormat());


    QApplication a(argc, argv);


    vtkNew<vtkRenderer> mRenderer;

    mRenderer->SetBackground(.3, .6, .3);


    vtkNew<vtkGenericOpenGLRenderWindow> mRenderWindow;

    mRenderWindow->AddRenderer(mRenderer.Get());


    vtkNew<QVTKInteractor> mRenderWindowInteractor;

    mRenderWindowInteractor->SetRenderWindow(mRenderWindow.Get());


    vtkNew<vtkBalloonWidget> mBalloonWidget;

    mBalloonWidget->SetInteractor(mRenderWindowInteractor.Get());

    mBalloonWidget->EnabledOn(); // remove this line to fix the bug
(but we need it for balloons)


    // Add a sphere for beauty (but we can get the bug without any actor too)

    vtkNew<vtkSphereSource> sphere;

    sphere->SetCenter(0.0, 0.0, 0.0);

    sphere->SetRadius(5.0);

    vtkNew<vtkPolyDataMapper> mapper;

    mapper->SetInputConnection(sphere->GetOutputPort());

    vtkNew<vtkActor> actor;

    actor->SetMapper(mapper);

    mRenderer->AddActor(actor);


    QVTKOpenGLWidget vtkOpenGlWidget;

    vtkOpenGlWidget.SetRenderWindow(mRenderWindow.Get());


    vtkOpenGlWidget.show();

    mRenderWindow->Render();


    return a.exec();

}



Without this line:

mBalloonWidget->EnabledOn();

all works good.

And there are no problems with old QVTKWidget, but there is this bug with
new QVTKOpenGLWidget and balloons enabled.

Compiler is MSVC 2017 32 bit, VTK 8.1.0, Qt 5.10.1

The question is:
Is this a VTK bug or some my mistake?

-- 
Best regards,
Ivan Kosik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20180425/4a4c0ff8/attachment.html>


More information about the vtkusers mailing list