[vtkusers] MouseMoveEvent bug in Cocoa

Benoist Laurent laurentbenoist at hotmail.com
Thu Jul 23 05:01:03 EDT 2009


I'm going crazy since a few weeks with the MouseMoveEvent.
Originally, I wanted to display a VTK view in a Cocoa Window.
I've already posted a message on vtkusers because I hadn't a real time access to the mouse position : the OnMouseMove() function was called on a drag movement and not every time the mouse moves.
I've just found why : it seems that integration of the VTK view in the Cocoa window doesn't work as well as expected.

To perform a good integration, I call the two functions SetWindowId() and SetDisplayId(), as recommanded by VTK.
This generates 2 warning messages "invalid drawable" at the beginning of the program but the program is still running and, except the problem of mouse position,
everything run as expected.

If I don't call these functions, then the VTK view appears in a separated window.
There is no more warning message and I've a real time access to the mouse position.

Below the code of initialisation of the VTK view window, written in Objective-C++ (optimal with Cocoa).

- (id) initWithFrame:(NSRect) frame {
    self = [super initWithFrame:frame];
    if (self) {
        renderer = vtkRenderer::New();
        rendererWindow = vtkCocoaRenderWindow::New();
        renWinInt = vtkCocoaRenderWindowInteractor::New();
        vtkSmartPointer <vtkInteractorStyleSwitch> intStyle = vtkSmartPointer<vtkInteractorStyleSwitch>::New();

        intStyle -> SetCurrentStyleToTrackballCamera();
        renWinInt -> SetInteractorStyle(intStyle);
        rendererWindow -> SetWindowId([self window]);
        rendererWindow -> SetDisplayId(self);
        rendererWindow -> AddRenderer(renderer);
        renWinInt -> SetRenderWindow(rendererWindow);
        renWinInt -> CreateRepeatingTimer (1);

        [self setVTKRenderWindow:rendererWindow];
        if (!renWinInt -> GetInitialized()) renWinInt -> Initialize();
    return self;

Does someone see something wrong in this code and/or have an idea to solve this problem.

Help would be appreciated.
Thanks in advance.


Téléphonez gratuitement à tous vos proches avec Windows Live Messenger  !  Téléchargez-le maintenant !
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090723/105046c8/attachment.htm>

More information about the vtkusers mailing list