简体   繁体   English

QT中的2D vtk渲染

[英]2D vtk Renders in QT

I am unable to do 2D vtk renders in QT without having override errors: Vtk charts break in QT, "no override found for 'vtkContextDevice2D" . 我无法在QT中执行2D vtk渲染而没有覆盖错误: Vtk图表在QT中中断,“找不到'vtkContextDevice2D的覆盖”

While trying to solve this I have been reading about the vtkContextView and vtkGenericOpenGLRenderWindow classes. 在尝试解决此问题时,我一直在阅读有关vtkContextView和vtkGenericOpenGLRenderWindow类的信息。

vtkGenericOpenGLRenderWindow: vtkGenericOpenGLRenderWindow:

vtkGenericOpenGLRenderWindow provides a skeleton for implementing a render window using one's own OpenGL context and drawable. vtkGenericOpenGLRenderWindow提供了一个框架,用于使用自己的OpenGL上下文和可绘制对象来实现渲染窗口。 To be effective, one must register an observer for WindowMakeCurrentEvent, WindowIsCurrentEvent and WindowFrameEvent. 为了有效,必须注册WindowMakeCurrentEvent,WindowIsCurrentEvent和WindowFrameEvent的观察者。

vtkContextView: vtkContextView:

This class is derived from vtkRenderViewBase and provides a view of a vtkContextScene, with a default interactor style, renderer etc. It is the simplest way to create a vtkRenderWindow and display a 2D scene inside of it. 此类从vtkRenderViewBase派生并提供vtkContextScene的视图以及默认的交互器样式,渲染器等。这是创建vtkRenderWindow并在其中显示2D场景的最简单方法。

I do not understand how the vtkContextView works with OpenGL and was wondering if someone could help explain their relation to one another, and how the context view works. 我不了解vtkContextView如何与OpenGL一起使用,并且想知道是否有人可以帮助解释彼此之间的关系,以及上下文视图如何工作。

Also, is there any other way to do 2D vtk renders without the using the context view? 另外,还有其他方法可以在不使用上下文视图的情况下进行2D vtk渲染吗? I cannot find any exmaples of 2D vtk renders in QT, any advice on how to do 2D renders of vtk in QT will be greatly appreciated . 我在QT中找不到任何2D vtk渲染的典范,将不胜感激有关如何在QT中进行vtk的2D渲染的任何建议

Current Attempt to render 2D vtk chart: 当前尝试渲染2D vtk图表的方法:

view->SetRenderWindow(this->qvtkWidgetRight->GetRenderWindow());
view->SetInteractor(this->qvtkWidgetRight->GetInteractor());

Additional Code in main file: 主文件中的附加代码:

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

Additional Info: Win64 on 64bit machine, vtk8.2.0, Qt5.13.0, compiled/built in MCVS2017(Release x64) with cmake3.15.0(3D vtk renders work fine) 附加信息:64位计算机上的Win64,vtk8.2.0,Qt5.13.0,使用cmake3.15.0在MCVS2017(Release x64)中编译/内置(3D vtk可以正常工作)

Finally figured it out with the help of VTK forums. 终于在VTK论坛的帮助下找到了答案。 I simply did not have vtkRenderingContextOpenGL2 in my CMake file(updated code too, had it backwards). 我只是在我的CMake文件中没有vtkRenderingContextOpenGL2(更新的代码,也向后)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM