[vtkusers] QVTKRenderWindowInteractor problem
Baliki baliki
balikivtk at gmail.com
Tue Nov 17 09:47:06 EST 2009
You should set an appropriate interactor style (e.g.
vtkInteractorStyleTrackballCamera).
2009/11/17 KS Jothybasu <jothybasu at gmail.com>
> Hi,
>
> I am tryinf to render a 3d Image using vtkImagePlaneWidget to show 3
> orthogonal planes, it works perfectly with vtkRenderWindowInteractor but
> when I try to embed into a PyQt application with QVTKRenderWindowInteractor
> ,the mouse interactions doesn't work properly(like window level
> change,slicing ..), it only rotates and some of the keypress events work.
>
> Here is a the simple code!
>
> *import vtk
>
> def Show3DPlanes(img_data,renWin):
> # renWin is actually a QVTKRenderWindowInteractor
>
> # An outline is shown for context.
> outline = vtk.vtkOutlineFilter()
> outline.SetInput(img_data)
>
> outlineMapper = vtk.vtkPolyDataMapper()
> outlineMapper.SetInputConnection(outline.GetOutputPort())
>
> outlineActor = vtk.vtkActor()
> outlineActor.SetMapper(outlineMapper)
>
> # The shared picker enables us to use 3 planes at one time
> # and gets the picking order right
> picker = vtk.vtkCellPicker()
> picker.SetTolerance(0.005)
>
> # The 3 image plane widgets are used to probe the dataset.
> planeWidgetX = vtk.vtkImagePlaneWidget()
> planeWidgetX.DisplayTextOn()
> planeWidgetX.SetInput(img_data)
> planeWidgetX.SetPlaneOrientationToXAxes()
> planeWidgetX.SetSliceIndex(200)
> planeWidgetX.SetPicker(picker)
> planeWidgetX.SetKeyPressActivationValue("x")
> prop1 = planeWidgetX.GetPlaneProperty()
> prop1.SetColor(1, 0, 0)
>
> planeWidgetY = vtk.vtkImagePlaneWidget()
> planeWidgetY.DisplayTextOn()
> planeWidgetY.SetInput(img_data)
> planeWidgetY.SetPlaneOrientationToYAxes()
> planeWidgetY.SetSliceIndex(255)
> planeWidgetY.SetPicker(picker)
> planeWidgetY.SetKeyPressActivationValue("y")
> prop2 = planeWidgetY.GetPlaneProperty()
> prop2.SetColor(1, 1, 0)
> planeWidgetY.SetLookupTable(planeWidgetX.GetLookupTable())
>
> # for the z-slice, turn off texture interpolation:
> # interpolation is now nearest neighbour, to demonstrate
> # cross-hair cursor snapping to pixel centers
> planeWidgetZ = vtk.vtkImagePlaneWidget()
> planeWidgetZ.DisplayTextOn()
> planeWidgetZ.SetInput(img_data)
> planeWidgetZ.SetPlaneOrientationToZAxes()
> planeWidgetZ.SetSliceIndex(15)
> planeWidgetZ.SetPicker(picker)
> planeWidgetZ.SetKeyPressActivationValue("z")
> prop3 = planeWidgetZ.GetPlaneProperty()
> prop3.SetColor(0, 0, 1)
> planeWidgetZ.SetLookupTable(planeWidgetX.GetLookupTable())
>
> # Create the RenderWindow and Renderer
> ren = vtk.vtkRenderer()
> renWin.GetRenderWindow().AddRenderer(ren)
> Win=renWin.GetRenderWindow()
>
>
> # Add the outline actor to the renderer, set the background
> # color and size
> ren.AddActor(outlineActor)
> #renWin.SetSize(432,361)
> ren.SetBackground(0, 0, 0)
>
> current_widget = planeWidgetZ
> mode_widget = planeWidgetZ
>
> # Set the interactor for the widgets
> iact = vtk.vtkRenderWindowInteractor()
> iact.SetRenderWindow(Win)
> planeWidgetX.SetInteractor(iact)
> planeWidgetX.On()
> planeWidgetY.SetInteractor(iact)
> planeWidgetY.On()
> planeWidgetZ.SetInteractor(iact)
> planeWidgetZ.On()
>
> # Create an initial interesting view
> ren.ResetCamera();
> cam1 = ren.GetActiveCamera()
> cam1.Elevation(110)
> cam1.SetViewUp(0, 0, -1)
> cam1.Azimuth(0)
> ren.ResetCameraClippingRange()
>
> iact.Initialize()
> renWin.show()
> iact.Start()*
>
>
> Could anybody please help me?
>
> Thanks
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091117/d85113d4/attachment.htm>
More information about the vtkusers
mailing list