You should set an appropriate interactor style (e.g. vtkInteractorStyleTrackballCamera).<br><br><br><div class="gmail_quote">2009/11/17 KS Jothybasu <span dir="ltr"><<a href="mailto:jothybasu@gmail.com">jothybasu@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">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<br>
<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br>