microsoft / InteractiveDataDisplay.WPF

Interactive Data Display for WPF is a set of controls for adding interactive visualization of dynamic data to your application. It allows to create line graphs, bubble charts, heat maps and other complex 2D plots which are very common in scientific software. Interactive Data Display for WPF integrates well with Bing Maps control to show data on a geographic map in latitude/longitude coordinates. The controls can also be operated programmatically.
Other
970 stars 265 forks source link

Interactive Data display in KeyboardNavigation #39

Open 07012220 opened 4 years ago

07012220 commented 4 years ago

I read the source code KeyboardNavigation.cs in InteractiveDataDisplay.WPF . i just don't no why need

IsZoomEnable(rect)

to check before setting the zooming.

private void DoZoom(double factor) { if (masterPlot != null) { var rect = masterPlot.PlotRect;

        if (IsHorizontalNavigationEnabled)
            rect.X = rect.X.Zoom(factor);
        if (IsVerticalNavigationEnabled)
            rect.Y = rect.Y.Zoom(factor);

        if (IsZoomEnable(rect))// why need this check?
        {
            masterPlot.SetPlotRect(rect);
            masterPlot.IsAutoFitEnabled = false;
        }
    }
}

private bool IsZoomEnable(DataRect rect)
{
    bool res = true;
    if (IsHorizontalNavigationEnabled)
    {
        double e_max = Math.Log(Math.Max(Math.Abs(rect.XMax), Math.Abs(rect.XMin)), 2);
        double log = Math.Log(rect.Width, 2);
        res = log > e_max - 40;
    }
    if (IsVerticalNavigationEnabled)
    {
        double e_max = Math.Log(Math.Max(Math.Abs(rect.YMax), Math.Abs(rect.YMin)), 2);
        double log = Math.Log(rect.Height, 2);
        res = res && log > e_max - 40;
    }
    return res;
}