Add and remove vtkChartXY/vtkContextView within a QVTKWidget renderer

二次信任 提交于 2019-12-12 23:50:57

问题


I currently have a Qt MainWindow, which holds a number of controls including a QVTKWidget. I can easily add a vtkChartXY object using a vtkContextView to the QVTKWidget:

vtkSmartPointer<vtkContextView> m_2Dview = vtkSmartPointer<vtkContextView>::New();
m_2Dview->SetRenderWindow(this->QVTKWidget->GetRenderWindow());

However, once I have it in the QVTKWidget, I can not find a way to return to the 3d view. I tried using the vtkContextActor, but it led to interaction issues. However, I'm willing to try out any suggestions if the vtkContextActor is the way to go.


回答1:


What I did to resolve this was to reset the vtkrenderer on the vtkrenderwindow by removing the vtkrenderer from the pointer of the vtkRenderWindow after storing the vtkRenderer pointer first, and then added the renderer I had stored back into the vtkRenderWindow.

This reset the view for me at least and below is the snippet I used.

AnalysisWindow is my pointer to the actual vtkRenderer.

if(AnalysisWindow != NULL)
{
    vtkSmartPointer<vtkRenderWindow> win;
    win = AnalysisWindow->GetRenderWindow();
    win->RemoveRenderer(AnalysisWindow);
    win->AddRenderer(AnalysisWindow);
}


来源:https://stackoverflow.com/questions/10218316/add-and-remove-vtkchartxy-vtkcontextview-within-a-qvtkwidget-renderer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!