vtk 3.1: using vtkInteractorStyle

John Biddiscombe j.biddiscombe at rl.ac.uk
Wed Feb 23 05:09:43 EST 2000


Here's a piece of code from a C++Builder component
//--------------------------------------------------------------------------
-
vtkRenderWindow * __fastcall BCBvtkRenderWindow::GetRenderWindow(void) {
    if (!FRenderWindow) {
        // Stuff the renderwindow into our window
        FRenderWindow = vtkRenderWindow::New();
            FRenderWindow->SetParentId(Parent->Handle);
            FRenderWindow->SetWindowId(Handle);
            FRenderWindow->SwapBuffersOn();
            // Clean and Frame to avoid unsightly garbage during initial
            // display which may be long when a complex scene is first
rendered
            ((vtkWin32OpenGLRenderWindow*)FRenderWindow)->Clean();
            FRenderWindow->Frame();
        FInteractor = vtkWin32RenderWindowInteractor::New();
            FInteractor->SetRenderWindow(FRenderWindow);
            FInteractor->SetInstallMessageProc(false);
            FInteractor->UpdateSize(Width,Height);
            FInteractor->Initialize();
        Invalidate();
    }
    return FRenderWindow;
}

You can see that we just need to set an interactor and that's it

later on I use this code (but note that vtkInteractorStyleFlight isn't part
of the main distribution yet, so ignore it)
And note that interactorsylte trackball handles trackball and joystick
modes!

//--------------------------------------------------------------------------
-
void __fastcall BCBvtkRenderWindow::SetInteractorMode(BCBvtkInteractorMode
im) {
 if (im==IM_Trackball) {
        vtkInteractorStyleTrackball *iatb =
vtkIsTypeMacro(vtkInteractorStyleTrackball,FInteractor->GetInteractorStyle()
);
        if (!iatb) {
            iatb = vtkInteractorStyleTrackball::New();
            FInteractor->SetInteractorStyle(iatb);
            iatb->Delete();
        }
        iatb->SetTrackballModeToTrackball();
        FInteractorMode = IM_Trackball;
 }
 else if (im==IM_Joystick) {
        vtkInteractorStyleTrackball *iatb =
vtkIsTypeMacro(vtkInteractorStyleTrackball,FInteractor->GetInteractorStyle()
);
        if (!iatb) {
            iatb = vtkInteractorStyleTrackball::New();
            FInteractor->SetInteractorStyle(iatb);
            iatb->Delete();
        }
  iatb->SetTrackballModeToJoystick();
  FInteractorMode = IM_Joystick;
 }
 else if (im==IM_Flight) {
        vtkInteractorStyleFlight *iafl =
vtkIsTypeMacro(vtkInteractorStyleFlight,FInteractor->GetInteractorStyle());
        if (!iafl) {
            iafl = vtkInteractorStyleFlight::New();
            FInteractor->SetInteractorStyle(iafl);
            iafl->Delete();
        }
  FInteractorMode = IM_Flight;
 }
}


--------------------------------------------------------------------
This is the private VTK discussion list. Please keep messages on-topic.
Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at public.kitware.com>. For help, send message body containing
"info vtkusers" to the same address.
--------------------------------------------------------------------



More information about the vtkusers mailing list