/// <summary> /// MouseMove method for Guideline /// </summary> /// <param name="X">mouse X position</param> /// <param name="Y"> mouse Y position</param> /// <param name="keys"> mouse and keyboard modifiers</param> /// <param name="ps">the InteractivePlotSurface2D</param> public override bool DoMouseMove(int X, int Y, Modifier keys, InteractivePlotSurface2D ps) { Rectangle plotArea = ps.PlotAreaBoundingBoxCache; if (drawPending) { overRuns += 1; return(false); } // note previous guideline ready to erase it Rectangle prevExtent = lineExtent; // Only display guideline when mouse is within the plotArea if (plotArea.Contains(X, Y)) { int h = 1; int w = plotArea.Right - plotArea.Left + 1; lineExtent = new Rectangle(plotArea.X, Y, w, h); drawPending = true; } else { lineExtent = Rectangle.Empty; } ps.QueueDraw(prevExtent); ps.QueueDraw(lineExtent); return(false); }
/// <summary> /// MouseLeave method for RubberBand selection /// </summary> /// <param name="ps">the InteractivePlotSurface2D</param> public override bool DoMouseLeave(InteractivePlotSurface2D ps) { if (selectionActive) { ps.QueueDraw(selection); selectionActive = false; } return(false); }
/// <summary> /// MouseLeave method for Guideline /// </summary> /// <param name="ps">the InteractivePlotSurface2D</param> public override bool DoMouseLeave(InteractivePlotSurface2D ps) { if (lineExtent != Rectangle.Empty) { // erase previous vertical guideline ps.QueueDraw(lineExtent); } lineExtent = Rectangle.Empty; return(false); }
/// <summary> /// Mouse Scroll (wheel) method for AxisZoom interaction /// </summary> public override bool DoMouseScroll(int X, int Y, int direction, Modifier keys, InteractivePlotSurface2D ps) { // Add timeout into Gtk loop when scroll starts - Omit for now // GLib.Timeout.Add (500, new GLib.TimeoutHandler (zoomTimeout) ); zoomActive = true; surface = ps; double proportion = 0.1 * sensitivity_; // use initial zoom of 10% double focusX = 0.5, focusY = 0.5; // default focus point // Zoom direction is +1 for Up/ZoomIn, or -1 for Down/ZoomOut proportion *= -direction; // delete previous focusPoint drawing - this is all a bit 'tentative' ps.QueueDraw(focusRect); Rectangle area = ps.PlotAreaBoundingBoxCache; if (area.Contains(X, Y)) { p.X = X; p.Y = Y; focusX = (double)(X - area.Left) / (double)area.Width; focusY = (double)(area.Bottom - Y) / (double)area.Height; } // Zoom in/out for all defined axes ps.CacheAxes(); ps.ZoomXAxes(proportion, focusX); ps.ZoomYAxes(proportion, focusY); // Note: r = 16, and Focus extents range from x-2*r-1 to x+2*r+1, y-2*r-1 to y+2*r+1 int x = p.X - 31; int y = p.Y - 31; focusRect = new Rectangle(x, y, 64, 64); // draw new focusRect ps.QueueDraw(focusRect); return(true); }
/// <summary> /// Callback for zoom timeout - compiled but not active at present /// </summary> private bool zoomTimeout() { // clear zoom flag and remove last focusPoint zoomActive = false; surface.QueueDraw(focusRect); //returning true means that the timeout routine should be invoked //again after the timeout period expires. Returning false will //terminate the timeout (ie until invoked again by Scrolling) return(false); }
/// <summary> /// MouseMove method for Rubberband selection of plot area /// </summary> public override bool DoMouseMove(int X, int Y, Modifier keys, InteractivePlotSurface2D ps) { if (((keys & Modifier.Button1) != 0) && selectionActive) { // note last selection rectangle Rectangle lastSelection = selection; Rectangle bounds = ps.PlotAreaBoundingBoxCache; // clip selection rectangle to PlotArea X = Math.Max(X, bounds.Left); X = Math.Min(X, bounds.Right); Y = Math.Max(Y, bounds.Top); Y = Math.Min(Y, bounds.Bottom); endPoint.X = X; endPoint.Y = Y; selection = FromPoints(startPoint, endPoint); ps.QueueDraw(lastSelection); //Console.WriteLine ("Erase: {0} {1} {2} {3} ", lastSelection.X, lastSelection.Y, lastSelection.Width, lastSelection.Height); ps.QueueDraw(selection); } return(false); }
/// <summary> /// MouseUp method for RubberBand selection /// </summary> /// <param name="X">mouse X position</param> /// <param name="Y"> mouse Y position</param> /// <param name="keys"> mouse and keyboard modifiers</param> /// <param name="ps">the InteractivePlotSurface2D</param> public override bool DoMouseUp(int X, int Y, Modifier keys, InteractivePlotSurface2D ps) { bool modified = false; // delete previous overlay rectangle ps.QueueDraw(selection); if (selectionActive) { selectionActive = false; Rectangle bounds = ps.PlotAreaBoundingBoxCache; if (!bounds.Contains(endPoint)) { // MouseUp outside plotArea - cancel selection modified = false; } else { ps.CacheAxes(); // Redefine range based on selection. The proportions for // Min and Max do not require Min < Max, since they will // be re-ordered by Axis.DefineRange if necessary double xMin = startPoint.X - bounds.Left; double yMin = bounds.Bottom - startPoint.Y; double xMax = endPoint.X - bounds.Left; double yMax = bounds.Bottom - endPoint.Y; double xMinProp = xMin / bounds.Width; double xMaxProp = xMax / bounds.Width; double yMinProp = yMin / bounds.Height; double yMaxProp = yMax / bounds.Height; ps.DefineXAxes(xMinProp, xMaxProp); ps.DefineYAxes(yMinProp, yMaxProp); modified = true; } } return(modified); }
/// <summary> /// MouseMove method for PlotScroll /// </summary> public override bool DoMouseMove(int X, int Y, Modifier keys, InteractivePlotSurface2D ps) { zoomActive = false; ps.QueueDraw(focusRect); return(false); }
/// <summary> /// MouseMove method for Guideline /// </summary> /// <param name="X">mouse X position</param> /// <param name="Y"> mouse Y position</param> /// <param name="keys"> mouse and keyboard modifiers</param> /// <param name="ps">the InteractivePlotSurface2D</param> public override bool DoMouseMove(int X, int Y, Modifier keys, InteractivePlotSurface2D ps) { Rectangle plotArea = ps.PlotAreaBoundingBoxCache; if (drawPending) { overRuns += 1; return false; } // note previous guideline ready to erase it Rectangle prevExtent = lineExtent; // Only display guideline when mouse is within the plotArea if (plotArea.Contains(X, Y)) { int w = 1; int h = plotArea.Bottom - plotArea.Top + 1; lineExtent = new Rectangle(X, plotArea.Top, w, h); drawPending = true; } else { lineExtent = Rectangle.Empty; } ps.QueueDraw(prevExtent); ps.QueueDraw(lineExtent); return false; }
/// <summary> /// MouseLeave method for Guideline /// </summary> /// <param name="ps">the InteractivePlotSurface2D</param> public override bool DoMouseLeave(InteractivePlotSurface2D ps) { if (lineExtent != Rectangle.Empty) { // erase previous vertical guideline ps.QueueDraw(lineExtent); } lineExtent = Rectangle.Empty; return false; }
/// <summary> /// MouseUp method for RubberBand selection /// </summary> /// <param name="X">mouse X position</param> /// <param name="Y"> mouse Y position</param> /// <param name="keys"> mouse and keyboard modifiers</param> /// <param name="ps">the InteractivePlotSurface2D</param> public override bool DoMouseUp(int X, int Y, Modifier keys, InteractivePlotSurface2D ps) { bool modified = false; // delete previous overlay rectangle ps.QueueDraw(selection); if (selectionActive) { selectionActive = false; Rectangle bounds = ps.PlotAreaBoundingBoxCache; if (!bounds.Contains(endPoint)) { // MouseUp outside plotArea - cancel selection modified = false; } else { ps.CacheAxes(); // Redefine range based on selection. The proportions for // Min and Max do not require Min < Max, since they will // be re-ordered by Axis.DefineRange if necessary double xMin = startPoint.X - bounds.Left; double yMin = bounds.Bottom - startPoint.Y; double xMax = endPoint.X - bounds.Left; double yMax = bounds.Bottom - endPoint.Y; double xMinProp = xMin / bounds.Width; double xMaxProp = xMax / bounds.Width; double yMinProp = yMin / bounds.Height; double yMaxProp = yMax / bounds.Height; ps.DefineXAxes(xMinProp, xMaxProp); ps.DefineYAxes(yMinProp, yMaxProp); modified = true; } } return modified; }
/// <summary> /// MouseMove method for Rubberband selection of plot area /// </summary> public override bool DoMouseMove(int X, int Y, Modifier keys, InteractivePlotSurface2D ps) { if (((keys & Modifier.Button1) != 0) && selectionActive) { // note last selection rectangle Rectangle lastSelection = selection; Rectangle bounds = ps.PlotAreaBoundingBoxCache; // clip selection rectangle to PlotArea X = Math.Max(X, bounds.Left); X = Math.Min(X, bounds.Right); Y = Math.Max(Y, bounds.Top); Y = Math.Min(Y, bounds.Bottom); endPoint.X = X; endPoint.Y = Y; selection = FromPoints(startPoint, endPoint); ps.QueueDraw(lastSelection); //Console.WriteLine ("Erase: {0} {1} {2} {3} ", lastSelection.X, lastSelection.Y, lastSelection.Width, lastSelection.Height); ps.QueueDraw(selection); } return false; }
/// <summary> /// MouseLeave method for RubberBand selection /// </summary> /// <param name="ps">the InteractivePlotSurface2D</param> public override bool DoMouseLeave(InteractivePlotSurface2D ps) { if (selectionActive) { ps.QueueDraw(selection); selectionActive = false; } return false; }
/// <summary> /// MouseMove method for PlotScroll /// </summary> public override bool DoMouseMove(int X, int Y, Modifier keys, InteractivePlotSurface2D ps) { zoomActive = false; ps.QueueDraw(focusRect); return false; }
/// <summary> /// Mouse Scroll (wheel) method for AxisZoom interaction /// </summary> public override bool DoMouseScroll(int X, int Y, int direction, Modifier keys, InteractivePlotSurface2D ps) { // Add timeout into Gtk loop when scroll starts - Omit for now // GLib.Timeout.Add (500, new GLib.TimeoutHandler (zoomTimeout) ); zoomActive = true; surface = ps; double proportion = 0.1 * sensitivity_; // use initial zoom of 10% double focusX = 0.5, focusY = 0.5; // default focus point // Zoom direction is +1 for Up/ZoomIn, or -1 for Down/ZoomOut proportion *= -direction; // delete previous focusPoint drawing - this is all a bit 'tentative' ps.QueueDraw(focusRect); Rectangle area = ps.PlotAreaBoundingBoxCache; if (area.Contains(X, Y)) { p.X = X; p.Y = Y; focusX = (double)(X - area.Left) / (double)area.Width; focusY = (double)(area.Bottom - Y) / (double)area.Height; } // Zoom in/out for all defined axes ps.CacheAxes(); ps.ZoomXAxes(proportion, focusX); ps.ZoomYAxes(proportion, focusY); // Note: r = 16, and Focus extents range from x-2*r-1 to x+2*r+1, y-2*r-1 to y+2*r+1 int x = p.X - 31; int y = p.Y - 31; focusRect = new Rectangle(x, y, 64, 64); // draw new focusRect ps.QueueDraw(focusRect); return (true); }