[vtk-developers] Overriding MouseButtonPressEvent in vtkChartXY
Brad Hollister
behollis at sci.utah.edu
Mon May 9 14:32:53 EDT 2016
So, I've used the AddObserver method on vtkObject to register a
callback. There is a Python example of this:
http://www.vtk.org/Wiki/VTK/Examples/Python/Interaction/MouseEventsObserver
However, I want to specifically handle a 'LeftButtonPressEvent' on a
vtkChartXY object. If I invoke an event as in:
self.chart.InvokeEvent('LeftButtonPressEvent')
this event will be caught by my handler function. However, a
'LeftButtonPressEvent' when invoked on the graphical widget doesn't
call the handler.
Some events, which are labelled 'NoEvent' or 'InteractionEvent', will
invoke a call on my callback, such as a scroll wheel event outside the
content in the vtkChartXY view.
Is there still a way to handle a 'LeftButtonPressEvent' that appears
to stop at vtkChartXY handler level? Does vtkChartXY emit a signal
after having processed an event, that can be subsequently handled by a
user-defined routine in Python?
Regards,
Brad
> Date: Thu, 5 May 2016 15:57:50 -0400
>From: "Marcus D. Hanwell" <marcus.hanwell at kitware.com>
> To: Brad Hollister <behollis at sci.utah.edu>
> Cc: VTK Developers <vtk-developers at vtk.org>
> Subject: Re: [vtk-developers] Overriding MouseButtonPressEvent in
> vtkChartXY
> Message-ID:
> <CAMkPkZVKw+VOsDbE-jKaP1n2JU=jqi4awz=KVNNMwhvP3raaJQ at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> On Wed, May 4, 2016 at 5:48 PM, Brad Hollister
><behollis at sci.utah.edu> wrote:
>> Hi,
>>
>> I'd like to override the mouse handler for vtkChartXY in Python.
>>However,
>> when I do this, the overriden function is not called. I have the
>>following:
>>
>> from vtk import vtkChartXY, vtkContextMouseEvent
>>
>> class dbsTransFuncChart(vtkChartXY):
>> def __init__(self, parent = None):
>> vtkChartXY.__init__(self)
>> self.par = parent
>>
>> def MouseButtonPressEvent(self, *args, **kwargs):
>> self.par.updateRenderQVTKWin()
>> return vtkChartXY.MouseButtonPressEvent(self, *args,
>>**kwargs)
>>
>> Is there a way to do this properly?
>>
> I am not sure on the right way to do this in Python, I don't
>remember
> seeing examples of class derivation in Python using the VTK
>wrappers.
> The equivalent should work in C++, hopefully someone who knows the
> wrapping better might comment.
>
> Marcus
More information about the vtk-developers
mailing list