[vtkusers] Trouble using VTK Widget with QVTK

andyjk andrewkeeling at hotmail.com
Sun Jul 8 06:34:48 EDT 2018


Thanks again for the advice, Todd.

Yes - I do need to delve a bit deeper re debugging.

I thought vtkNew<...>, and vtksmartPointer<...>::New() both create instances
(the former being the preferred method now?)

To check, I tried both:
vtkNew<vtkGenericOpenGLRenderWindow> renderWindow;
	

and 

vtkSmartPointer<vtkGenericOpenGLRenderWindow> renderWindow =
vtkSmartPointer<vtkGenericOpenGLRenderWindow>::New();

(then ui->widget->SetRenderWindow(renderWindow); in both instances)

Both work and produce the rendered sphere, but no contour widget. So I think
the assignment is happening identically with either method.

I also did the following, with two breakpoints (before and after the safe
down cast):

vtkSmartPointer<vtkRenderWindow> vtkrenderWindow =
		vtkSmartPointer<vtkRenderWindow>::New();
	vtkSmartPointer<vtkGenericOpenGLRenderWindow> renderWindow =
vtkGenericOpenGLRenderWindow::SafeDownCast(vtkrenderWindow);

	ui->widget->SetRenderWindow(renderWindow);

I notice that the vtkrenderwindow gets a valid pointer, and seems to be
reading from vtkRenderingOpenGL2-8.1.dll  - so is presumably already
something opengl based ?

At the subsequent break point (so after the line
vtkSmartPointer<vtkGenericOpenGLRenderWindow> renderWindow =
vtkGenericOpenGLRenderWindow::SafeDownCast(vtkrenderWindow); ) I notice that
the renderWindow pointer is still NULL.

So the SafeDownCast seems to fail -but of course I can bypass this line by
just doing 
vtkSmartPointer<vtkGenericOpenGLRenderWindow> renderWindow =
vtkSmartPointer<vtkGenericOpenGLRenderWindow>::New();
ui->widget->SetRenderWindow(renderWindow);

which seems to render fine but ignores the contour widget.

Frustrating! But thanks for your help anyway.

Andy








--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html


More information about the vtkusers mailing list