Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QVTKWidget deprecated (in VTK >= 8.2 at least) #3370

Closed
kunaltyagi opened this issue Sep 26, 2019 · 17 comments
Closed

QVTKWidget deprecated (in VTK >= 8.2 at least) #3370

kunaltyagi opened this issue Sep 26, 2019 · 17 comments

Comments

@kunaltyagi
Copy link
Member

QVTKWidget is used in apps (pcd_video_player, manual_registration, render_window, among others) and is deprecated at least on VTK v8.2

Rendering background used is OpenGL2

@lesterlo
Copy link

lesterlo commented Jul 2, 2020

I receive this warning after I change qvtkWidget to QVTKOpenGLNativeWidget on my program. This error appears on my mac and the program is not functional.

Any suggestions to solve this question?

Possible solution

Use vtkGenericOpenGLRenderWindow with QVTKOpenGLNativeWidget

and

setup the surfaceFormat QSurfaceFormat::setDefaultFormat(QVTKOpenGLWidget::defaultFormat());

Error

# Error

QVTKOpenGLNativeWidget requires a `vtkGenericOpenGLRenderWindow`. ` vtkCocoaRenderWindow ` is not supported.


ERROR: In /tmp/vtk-20200406-71083-llkp3g/VTK-8.2.0/Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx, line 754
vtkGenericOpenGLRenderWindow (0x7fa4b400d800): Unable to find a valid OpenGL 3.2 or later implementation. Please update your video card driver to the latest version. If you are using Mesa please make sure you have version 11.2 or later and make sure your driver in Mesa supports OpenGL 3.2 such as llvmpipe or openswr. If you are on windows and using Microsoft remote desktop note that it only supports OpenGL 3.2 with nvidia quadro cards. You can use other remoting software such as nomachine to avoid this issue.

@kunaltyagi
Copy link
Member Author

This error appears on my mac and the program is not functional.

Mac isn't supported because Apple has deprecated OpenGL

@lesterlo
Copy link

lesterlo commented Jul 8, 2020

@kunaltyagi

Is there has any solution to prevent this error? Or I need to write 2 sets of Qt GUI Code, One for Mac and One for Linux?

Also, Could I use dear ImGUI with PCL?

Many Thanks!

@kunaltyagi
Copy link
Member Author

We don't have enough hands on deck with experience in visualization. As a result, we haven't found a solution or a workaround.

I think using MoltenVK and GLOVE together should make it work, but I never investigated it deeply.

Regarding ImGUI, I'm sure you can use it with PCL. You can either create a new binding or use an existing one:

@larshg
Copy link
Contributor

larshg commented Feb 19, 2021

Should have been solved by #4262.

@larshg larshg closed this as completed Feb 19, 2021
Update dependencies automation moved this from To do to Done Feb 19, 2021
@themightyoarfish
Copy link
Contributor

Not solved with current master and vtk 9.0.3 on macos.

@themightyoarfish
Copy link
Contributor

Is it definitive that visualization will not work on macos with VTK > 8?

@larshg
Copy link
Contributor

larshg commented Jan 4, 2022

Is it definitive that visualization will not work on macos with VTK > 8?

Can you elaborate a bit whats not working? The CI builds with vtk 9.

@themightyoarfish
Copy link
Contributor

I mean using the render window returned by PCLVisualizer::getRenderWindow() as the target for a Qt widget that inherits from QVTKOpenGLNativeWidget. When I call setRenderWindow() with the PCL visualizer window, I get the

QVTKOpenGLNativeWidget requires a `vtkGenericOpenGLRenderWindow`. ` vtkCocoaRenderWindow ` is not supported.

warning/error and the PCL visualizer window pops up separately, instead of appearing inside the Qt widget.

@themightyoarfish
Copy link
Contributor

Something like this, which used to work with QVTKWidget from vtk 8.2

class PointCloudWidget : public QVTKOpenGLNativeWidget {
public:
  PointCloudWidget(QWidget* parent) : QVTKOpenGLNativeWidget(parent) {
	this->setRenderWindow(m_visualizer->getRenderWindow());
}
};

@themightyoarfish
Copy link
Contributor

What seems to work is to call

  QSurfaceFormat::setDefaultFormat(QVTKOpenGLNativeWidget::defaultFormat());

before the QApplication gets instantiated and then something like this to set up the widget with the viewer inside:

PointCloudWidget::PointCloudWidget(QWidget* parent) :
    QVTKOpenGLNativeWidget(parent) {
  auto renderer     = vtkSmartPointer<vtkRenderer>::New();
  auto renderWindow = vtkSmartPointer<vtkGenericOpenGLRenderWindow>::New();
  renderWindow->AddRenderer(renderer);
  m_visualizer.reset(
      new PCLVisualizer(renderer, renderWindow, "viewer", false));
  this->setRenderWindow(m_visualizer->getRenderWindow());
…
}

@themightyoarfish
Copy link
Contributor

Passing true for the last arg to PCLVisualizer makes it segfault, however.

@themightyoarfish
Copy link
Contributor

themightyoarfish commented Jan 4, 2022

Unfortunately without the interactor, the widget only displays new data when interacted with, so there must be some way to add one from the outside or fix the segmentation fault.

(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x0000000000000000
    frame #1: 0x000000010c6aaf2c libvtkRenderingOpenGL2-9.0.1.dylib`vtkOpenGLFramebufferObject::CreateFBO() + 62
    frame #2: 0x000000010c6ac659 libvtkRenderingOpenGL2-9.0.1.dylib`vtkOpenGLFramebufferObject::Bind(unsigned int) + 43
    frame #3: 0x000000010c6ae36c libvtkRenderingOpenGL2-9.0.1.dylib`vtkOpenGLFramebufferObject::PopulateFramebuffer(int, int, bool, int, int, bool, int, int, bool) + 44
    frame #4: 0x000000010c6eca55 libvtkRenderingOpenGL2-9.0.1.dylib`vtkOpenGLRenderWindow::CreateOffScreenFramebuffer(int, int) + 429
    frame #5: 0x000000010c6ec878 libvtkRenderingOpenGL2-9.0.1.dylib`vtkOpenGLRenderWindow::Start() + 110
    frame #6: 0x000000010c84b778 libvtkRenderingUI-9.0.1.dylib`vtkCocoaRenderWindowInteractor::Initialize() + 56
    frame #7: 0x0000000100fe35dd libpcl_visualization.1.12.dylib`pcl::visualization::PCLVisualizer::createInteractor(this=0x0000000110679830) at pcl_visualizer.cpp:316:16 [opt]
    frame #8: 0x0000000100fe4368 libpcl_visualization.1.12.dylib`pcl::visualization::PCLVisualizer::PCLVisualizer(this=0x0000000110679830, ren=vtkSmartPointer<vtkRenderer> @ 0x00007ffeefbfb260, wind=<unavailable>, name="viewer", create_interactor=true) at pcl_visualizer.cpp:261:5 [opt]

@themightyoarfish
Copy link
Contributor

On this page here, there is a workaround listed

#if VTK_MAJOR_VERSION > 8
  auto renderer = vtkSmartPointer<vtkRenderer>::New();
  auto renderWindow = vtkSmartPointer<vtkGenericOpenGLRenderWindow>::New();
  renderWindow->AddRenderer(renderer);
  viewer.reset(new pcl::visualization::PCLVisualizer(renderer, renderWindow, "viewer", false));
  ui->qvtkWidget->setRenderWindow(viewer->getRenderWindow());
  viewer->setupInteractor(ui->qvtkWidget->interactor(), ui->qvtkWidget->renderWindow());
#else
  viewer.reset(new pcl::visualization::PCLVisualizer("viewer", false));
  ui->qvtkWidget->SetRenderWindow(viewer->getRenderWindow());
  viewer->setupInteractor(ui->qvtkWidget->GetInteractor(), ui->qvtkWidget->GetRenderWindow());
#endif

But I have not yet tested this on macos.

@larshg
Copy link
Contributor

larshg commented Jan 5, 2022

Yes, to get it to rerender without interacting you need to call whats in refreshView of the tutorial.

Its basically calling render() og the renderwindow or the renderer. Cant remember on top of my head.

@themightyoarfish
Copy link
Contributor

Interesting, too bad the tutorial doesn't show the refreshView() code, but I'll try when I get to it.

@themightyoarfish
Copy link
Contributor

Aha, it's here: https://github.com/PointCloudLibrary/pcl/blob/master/doc/tutorials/content/sources/qt_colorize_cloud/pclviewer.cpp#L74

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging a pull request may close this issue.

4 participants