void
ZoomInteractor::StartRubberBand(int x, int y)
{
    rubberBandMode = true;

    shiftKeyDown = Interactor->GetShiftKey();
    controlKeyDown = Interactor->GetControlKey();

    VisWindow *win = proxy;
    shouldClampSquare = win->GetInteractorAtts()->GetClampSquare();
    shouldDrawGuides = win->GetInteractorAtts()->GetShowGuidelines();

    // Set the actor's color.
    double fg[3];
    proxy.GetForegroundColor(fg);
    rubberBandActor->GetProperty()->SetColor(fg[0], fg[1], fg[2]);

    //
    // Add the rubber band actors to the background.  We do this since the
    // background is in the same display coordinates that the rubber band will
    // be.  From an appearance standpoint it should be in the canvas, which
    // the routine ForceCoordsToViewport ensures.
    //
    vtkRenderer *ren = proxy.GetBackground();
    ren->AddActor2D(rubberBandActor);

    //
    // The anchor of the rubber band will be where the button press was.
    //
    anchorX = x;
    anchorY = y;

    //
    // Determine what to clamp the rubber band to.
    //
    SetCanvasViewport();

    //
    // If the user has clicked outside the viewport, force the back inside.
    //
    ForceCoordsToViewport(anchorX, anchorY);

    //
    // Must update bookkeeping so that OnMouseMove works correctly.
    //
    lastX   = anchorX;
    lastY   = anchorY;

    rubberBandDrawn = false;
}
void
NavigateAxisArray::OnTimer(void)
{
    vtkRenderWindowInteractor *rwi = Interactor;

    int Pos[2];
    rwi->GetEventPosition(Pos);

    VisWindow *win = proxy;
    shouldSnap = win->GetInteractorAtts()->GetAxisArraySnap();

    switch (State)
    {
      case VTKIS_PAN:
        PanCamera(Pos[0], Pos[1], shouldSnap);

        rwi->CreateTimer(VTKI_TIMER_UPDATE);
        break;

      case VTKIS_DOLLY:
        ZoomCamera(Pos[0], Pos[1]);

        rwi->CreateTimer(VTKI_TIMER_UPDATE);
        break;

      default:
        break;
    }
}
NavigateAxisArray::NavigateAxisArray(VisWindowInteractorProxy &v) : VisitInteractor(v)
{
    shiftKeyDown = controlKeyDown = false;
    VisWindow *win = v;
    shouldSnap = win->GetInteractorAtts()->GetAxisArraySnap();
    axisOrientation = Vertical;
}
ZoomInteractor::ZoomInteractor(VisWindowInteractorProxy &vw) 
    : VisitInteractor(vw)
{
    rubberBandMode  = false;
    shiftKeyDown = controlKeyDown = false;

    VisWindow *win = vw;
    shouldClampSquare = win->GetInteractorAtts()->GetClampSquare();
    shouldDrawGuides = win->GetInteractorAtts()->GetShowGuidelines();

    //
    // Create the poly data that will map the rubber band onto the screen.
    //
    rubberBand       = vtkPolyData::New();

    vtkPoints *pts = vtkPoints::New();
#if defined(__APPLE__) || defined(_WIN32)
    pts->SetNumberOfPoints(4);
    rubberBand->SetPoints(pts);
    pts->Delete();

    vtkCellArray *lines  = vtkCellArray::New();
    vtkIdType  ids[] = { 0, 1, 2, 3, 0};
    lines->InsertNextCell(5, ids);
    rubberBand->SetLines(lines);
    lines->Delete();
#else
    pts->SetNumberOfPoints(2);
    rubberBand->SetPoints(pts);
    pts->Delete();

    vtkCellArray *lines  = vtkCellArray::New();
    vtkIdType  ids[2] = { 0, 1 };
    lines->InsertNextCell(2, ids);
    rubberBand->SetLines(lines);
    lines->Delete();
#endif

    rubberBandMapper = proxy.CreateRubberbandMapper();
    rubberBandMapper->SetInput(rubberBand);

    rubberBandActor  = vtkActor2D::New();
    rubberBandActor->SetMapper(rubberBandMapper);
    rubberBandActor->GetProperty()->SetColor(0., 0., 0.);
}
void
VisitHotPointInteractor::Start3DMode(INTERACTION_MODE mode)
{
    if(!proxy.HasPlots())
    {
        return;
    }

    VisWindow *vw = proxy;
    const InteractorAttributes *atts=vw->GetInteractorAtts();

    VisitInteractor  *newInteractor  = NULL;
    switch(mode)
    {
    case LINEOUT:  // use Navigate until a 3d lineout mode can be implemented.
    case NAVIGATE:
        if (atts->GetNavigationMode() == InteractorAttributes::Trackball)
        {
            if(navigate3D == NULL)
            {
                navigate3D = new Navigate3D(proxy);
            }
            newInteractor = navigate3D;
        }
        else if (atts->GetNavigationMode() == InteractorAttributes::Dolly)
        {
            if(dolly3D == NULL)
            {
                dolly3D = new Dolly3D(proxy);
            }
            newInteractor = dolly3D;
        }
        else
        {
            if(flyThrough == NULL)
            {
                flyThrough = new FlyThrough(proxy);
            }
            newInteractor = flyThrough;
        }
        break;
    case ZONE_PICK: // fall-through
    case NODE_PICK:
    case SPREADSHEET_PICK:
    case DDT_PICK:
        if(pick == NULL)
        {
            pick = new Pick(proxy);
        }
        newInteractor = pick;
        break;
    case ZOOM:
        if(zoom3D == NULL)
        {
            zoom3D = new Zoom3D(proxy);
        }
        newInteractor = zoom3D;
        break;
    }

    if(newInteractor == NULL)
    {
        //
        // We have an invalid navigation mode or an invalid window mode.
        //
        EXCEPTION1(BadInteractorException, mode);
    }

    //
    // No reason to set the interactor again if it is the same one.
    //
    if(newInteractor != currentInteractor)
        SetInteractor(newInteractor);
}