[vtkusers] How to "undo" GetRenderWindow()->Render()?

Jan Niklas Hasse jan-niklas.hasse at stw.de
Fri Nov 18 05:51:04 EST 2016


Hi,

I'm using VTK 6.2 with Qt. I've created a class Plot2D which inherits from QVTKWidget. I now have a lot of these plots widgets in a tabbed view and want to only render the ones that are currently visible (otherwise I get an OpenGL crash).

void Plot2D::showEvent(QShowEvent*) {
    view = vtkSmartPointer<vtkContextView>::New();
    view->GetRenderer()->SetBackground(1,1,1);
    view->SetRenderWindow(GetRenderWindow());
    view->GetRenderWindow()->SetSize(width(),height());
    view->GetScene()->AddItem(chart);
    view->GetRenderWindow()->SetMultiSamples(0);
    view->GetRenderWindow()->Render();
}

void Plot2D::hideEvent(QHideEvent*) {
    view = nullptr;
}

Unfortunately, deleting the vtkContextView isn't enough: The next time showEvent is called, I get a crash inside VTK because it seems that view->GetRenderWindow()->Render(); has set up some kind of timer in the background. How would I solve this?

Thanks in advance :)
Jan


More information about the vtkusers mailing list