[vtkusers] Mouse Wheel Event: Update

Mathieu Malaterre mathieu.malaterre at kitware.com
Thu Apr 22 16:42:08 EDT 2004


Gianni,

	My mistake there is already a default behaviour for MouseWheel event. 
So you need to remove them first:

iren.RemoveObservers("MouseWheelForwardEvent")

For instance:

import vtk
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()

reader = vtk.vtkVolume16Reader()
reader.SetDataDimensions(64, 64)
reader.SetDataByteOrderToLittleEndian()
reader.SetFilePrefix(VTK_DATA_ROOT + "/Data/headsq/quarter")
reader.SetImageRange(1, 93)
reader.SetDataSpacing(3.2, 3.2, 1.5)

slice = 0
def foo(obj, evt):
    global slice
    slice += 1
    viewer.SetZSlice( slice )
    #viewer.GetRenderer().ResetCameraClippingRange()
    #print viewer.GetRenderer().GetActiveCamera().GetParallelProjection()
    viewer.Render()

iren = vtk.vtkRenderWindowInteractor()

viewer = vtk.vtkImageViewer2()
viewer.SetInput ( reader.GetOutput() )
viewer.SetupInteractor (iren)

iren.RemoveObservers("MouseWheelForwardEvent")
iren.AddObserver("MouseWheelForwardEvent", foo)

iren.Initialize()
iren.Start()



Sorry for troubles
Mathieu

Mathieu Malaterre wrote:
> I have added two new events:
> 
> MouseWheelForwardEvent
> MouseWheelBackwardEvent
> 
> Then you just use them as any others command event.
> 
> 
> Just remove the '#' comment in this example:
> http://vtk.org/pipermail/vtkusers/2003-September/019884.html
> 
> Mathieu
> Ps: You need VTK from cvs...
> 
> 
> Dr. Gianni Lazzarato wrote:
> 
>> hi to all User,
>>  
>>                    are there some examples, in tcl or c++, regarding 
>> mouse wheel event in vtk?  If i remember rigth
>> M. Malaterre was interested in this topic, time ago.
>> Where can i found these examples? Maybe in vtkusers archive?
>>  
>> thank you very much in advance for the answers.
>>  
>> Dr. Gianni Lazzarato
> 
> 
> 






More information about the vtkusers mailing list