[vtkusers] MouseMoveEvent bug in Cocoa

Sean McBride sean at rogue-research.com
Tue Aug 4 15:53:53 EDT 2009


On 7/23/09 9:01 AM, Benoist Laurent said:

>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.

That's correct.

>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.

The "invalid drawable" message is harmless.

>If I don't call these functions, then the VTK view appears in a
>separated window.

That's expected.

>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;
>}

That looks basically right.  Do you have the same problem with different
interactor styles?

-- 
____________________________________________________________
Sean McBride, B. Eng                 sean at rogue-research.com
Rogue Research                        www.rogue-research.com 
Mac Software Developer              Montréal, Québec, Canada





More information about the vtkusers mailing list