void
VisWinFrame::GetRange(double &min_x, double &max_x, double &min_y, double &max_y)
{
    VisWindow *vw = mediator;

    switch (vw->GetWindowMode())
    {
      case WINMODE_2D:
        {
        const avtView2D view2D = vw->GetView2D();
        min_x = view2D.window[0];
        max_x = view2D.window[1];
        min_y = view2D.window[2];
        max_y = view2D.window[3];
        }
        break;
      case WINMODE_CURVE:
        {
            const avtViewCurve viewCurve = vw->GetViewCurve();
            min_x = viewCurve.domain[0];
            max_x = viewCurve.domain[1];
            min_y = viewCurve.range[0];
            max_y = viewCurve.range[1];
        }
        break;
      default:
        break;
    }
}
void
VisWinFrame::UpdateView(void)
{
    double  min_x = 0., max_x = 0., min_y = 0., max_y = 0.;
    GetRange(min_x, max_x, min_y, max_y);

    //
    // We put the topBorder in reverse so that its ticks would appear on the
    // correct side of the viewport.  Must propogate kludge by sending
    // range in backwards.
    //
    leftBorder->SetRange(max_y, min_y);
    leftBorder->SetUseOrientationAngle(1);
    leftBorder->SetOrientationAngle(-1.5707963);

    rightBorder->SetRange(min_y, max_y);
    rightBorder->SetUseOrientationAngle(1);
    rightBorder->SetOrientationAngle(1.5707963);

    bottomBorder->SetRange(min_x, max_x);
    bottomBorder->SetUseOrientationAngle(1);
    bottomBorder->SetOrientationAngle(0.);

    topBorder->SetRange(max_x, min_x);
    topBorder->SetUseOrientationAngle(1);
    topBorder->SetOrientationAngle(3.1415926);

    VisWindow *vw = mediator;
    bool logScale[2] = { false, false};
    if (vw->GetWindowMode() == WINMODE_CURVE)
    {
        const avtViewCurve viewCurve = vw->GetViewCurve();
        logScale[0] = viewCurve.domainScale == LOG;
        logScale[1] = viewCurve.rangeScale == LOG;
    }
    else if (vw->GetWindowMode() == WINMODE_2D)
    {
        const avtView2D view2D = vw->GetView2D();
        logScale[0] = view2D.xScale == LOG;
        logScale[1] = view2D.yScale == LOG;
    }
    topBorder->SetLogScale((int)logScale[0]);
    bottomBorder->SetLogScale((int)logScale[0]);
    rightBorder->SetLogScale((int)logScale[1]);
    leftBorder->SetLogScale((int)logScale[1]);
}
void
Navigate2D::PanCamera(const int x, const int y)
{
    vtkRenderWindowInteractor *rwi = Interactor;

    if ((OldX != x) || (OldY != y))
    {
        //
        // Determine the size of the window.
        //
        int       size[2];

        rwi->GetSize(size);

        //
        // Get the current view information.
        //
        VisWindow *vw = proxy;

        double    viewport[4];
        double    pan[2];

        avtView2D newView2D = vw->GetView2D();

        newView2D.GetActualViewport(viewport, size[0], size[1]);
        
        pan[0] = (double)(x - OldX) /
                 ((viewport[1] - viewport[0]) * (double)(size[0])) *
                 (newView2D.window[1] - newView2D.window[0]);
        pan[1] = (double)(y - OldY) /
                 ((viewport[3] - viewport[2]) * (double)(size[1])) *
                 (newView2D.window[3] - newView2D.window[2]);

        newView2D.window[0] -= pan[0];
        newView2D.window[1] -= pan[0];
        newView2D.window[2] -= pan[1];
        newView2D.window[3] -= pan[1];

        OldX = x;
        OldY = y;

        vw->SetView2D(newView2D);
    }
}