Exemple #1
0
        public void Render(SKCanvas canvas, SKRect rect)
        {
            if (axes == null)
            {
                AutoAxis();
            }

            layout.Tighten(rect);
            axes.SetRect(layout.data);

            if (layout.display)
            {
                layout.RenderDebuggingGuides(canvas);
            }

            // update the scale, apply mouse adjustments, then update the scale again
            PlotSettings.Axes axesAfterMouse = new PlotSettings.Axes(axes);
            axesAfterMouse.PanPixels(mouse.leftDownDelta);
            axesAfterMouse.ZoomPixels(mouse.rightDownDelta);
            axesAfterMouse.SetRect(layout.data);

            // draw inside a clipping rectangle
            canvas.Save();
            canvas.ClipRect(layout.data);
            for (int i = 0; i < plottables.Count; i++)
            {
                plottables[i].Render(canvas, axesAfterMouse);
            }
            canvas.Restore();

            axisLabels.Render(layout, canvas);
            axisScales.Render(layout, axesAfterMouse, canvas);
        }
Exemple #2
0
        /// <summary>
        /// Return a new Axes after mouse panning and zooming
        /// </summary>
        private PlotSettings.Axes AxesAfterMouse(RectangleF?renderArea = null)
        {
            if (renderArea is null)
            {
                renderArea = mouse.lastRenderArea;
            }
            else
            {
                mouse.lastRenderArea = (RectangleF)renderArea;
            }

            var axesAfterMouse = new PlotSettings.Axes(axes);

            if (mouse.leftButtonIsDown)
            {
                axesAfterMouse.PanPixels(mouse.leftDelta);
            }
            if (mouse.rightButtonIsDown)
            {
                axesAfterMouse.ZoomPixels(mouse.rightDelta);
            }
            axesAfterMouse.SetDataRect((RectangleF)renderArea);
            return(axesAfterMouse);
        }