Hi,<br><br>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. <br>
<br>Here is a the simple code!<br><br><b style="color: rgb(51, 102, 255);">import vtk<br><br>def Show3DPlanes(img_data,renWin):<br># renWin is actually a QVTKRenderWindowInteractor<br><br> # An outline is shown for context.<br>
outline = vtk.vtkOutlineFilter()<br> outline.SetInput(img_data)<br><br> outlineMapper = vtk.vtkPolyDataMapper()<br> outlineMapper.SetInputConnection(outline.GetOutputPort())<br><br> outlineActor = vtk.vtkActor()<br>
outlineActor.SetMapper(outlineMapper)<br><br> # The shared picker enables us to use 3 planes at one time<br> # and gets the picking order right<br> picker = vtk.vtkCellPicker()<br> picker.SetTolerance(0.005)<br>
<br> # The 3 image plane widgets are used to probe the dataset.<br> planeWidgetX = vtk.vtkImagePlaneWidget()<br> planeWidgetX.DisplayTextOn()<br> planeWidgetX.SetInput(img_data)<br> planeWidgetX.SetPlaneOrientationToXAxes()<br>
planeWidgetX.SetSliceIndex(200)<br> planeWidgetX.SetPicker(picker)<br> planeWidgetX.SetKeyPressActivationValue("x")<br> prop1 = planeWidgetX.GetPlaneProperty()<br> prop1.SetColor(1, 0, 0)<br><br>
planeWidgetY = vtk.vtkImagePlaneWidget()<br> planeWidgetY.DisplayTextOn()<br> planeWidgetY.SetInput(img_data)<br> planeWidgetY.SetPlaneOrientationToYAxes()<br> planeWidgetY.SetSliceIndex(255)<br> planeWidgetY.SetPicker(picker)<br>
planeWidgetY.SetKeyPressActivationValue("y")<br> prop2 = planeWidgetY.GetPlaneProperty()<br> prop2.SetColor(1, 1, 0)<br> planeWidgetY.SetLookupTable(planeWidgetX.GetLookupTable())<br><br> # for the z-slice, turn off texture interpolation:<br>
# interpolation is now nearest neighbour, to demonstrate<br> # cross-hair cursor snapping to pixel centers<br> planeWidgetZ = vtk.vtkImagePlaneWidget()<br> planeWidgetZ.DisplayTextOn()<br> planeWidgetZ.SetInput(img_data)<br>
planeWidgetZ.SetPlaneOrientationToZAxes()<br> planeWidgetZ.SetSliceIndex(15)<br> planeWidgetZ.SetPicker(picker)<br> planeWidgetZ.SetKeyPressActivationValue("z")<br> prop3 = planeWidgetZ.GetPlaneProperty()<br>
prop3.SetColor(0, 0, 1)<br> planeWidgetZ.SetLookupTable(planeWidgetX.GetLookupTable())<br><br> # Create the RenderWindow and Renderer<br> ren = vtk.vtkRenderer()<br> renWin.GetRenderWindow().AddRenderer(ren)<br>
Win=renWin.GetRenderWindow()<br><br><br> # Add the outline actor to the renderer, set the background<br> # color and size<br> ren.AddActor(outlineActor)<br> #renWin.SetSize(432,361)<br> ren.SetBackground(0, 0, 0)<br>
<br> current_widget = planeWidgetZ<br> mode_widget = planeWidgetZ<br><br> # Set the interactor for the widgets<br> iact = vtk.vtkRenderWindowInteractor()<br> iact.SetRenderWindow(Win)<br> planeWidgetX.SetInteractor(iact)<br>
planeWidgetX.On()<br> planeWidgetY.SetInteractor(iact)<br> planeWidgetY.On()<br> planeWidgetZ.SetInteractor(iact)<br> planeWidgetZ.On()<br><br> # Create an initial interesting view<br> ren.ResetCamera();<br>
cam1 = ren.GetActiveCamera()<br> cam1.Elevation(110)<br> cam1.SetViewUp(0, 0, -1)<br> cam1.Azimuth(0)<br> ren.ResetCameraClippingRange()<br><br> iact.Initialize()<br> renWin.show()<br> iact.Start()</b><br>
<br><br>Could anybody please help me?<br><br>Thanks