简体   繁体   中英

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" .

While trying to solve this I have been reading about the vtkContextView and vtkGenericOpenGLRenderWindow classes.

vtkGenericOpenGLRenderWindow:

vtkGenericOpenGLRenderWindow provides a skeleton for implementing a render window using one's own OpenGL context and drawable. To be effective, one must register an observer for WindowMakeCurrentEvent, WindowIsCurrentEvent and WindowFrameEvent.

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.

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.

Also, is there any other way to do 2D vtk renders without the using the context view? 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 .

Current Attempt to render 2D vtk chart:

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)

Finally figured it out with the help of VTK forums. I simply did not have vtkRenderingContextOpenGL2 in my CMake file(updated code too, had it backwards).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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