/// <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> /// Mouse Scroll (wheel) method for AxisZoom interaction /// </summary> public override bool DoMouseScroll(int X, int Y, int direction, Modifier keys, InteractivePlotSurface2D 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)) { pF.X = X; pF.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); int x = pF.X-10; int y = pF.Y-10; focusRect = new Rectangle (x, y, 21, 21); // draw new focusRect ps.QueueDraw (focusRect); return (true); }
public override bool DoMouseMove(int x, int y, Modifier keys, InteractivePlotSurface2D ps) { Rectangle previous = this.extent; // If the mouse is being dragged then set the end point and extent // rectangle accordingly. Otherwise simply set the start coordinates // the current cursor position. if (this.active) { this.end = new Point(x, y); this.extent = new Rectangle( Math.Min(this.start.X, this.end.X) - this.offset, Math.Min(this.start.Y, this.end.Y) - this.offset, Math.Abs(this.end.X - this.start.X) + this.offset * 2 + 1, Math.Abs(this.end.Y - this.start.Y) + this.offset * 2 + 1 ); } else { this.start = new Point(x, y); this.extent = Rectangle.Empty; } // If an event handler has been set then throw the latest world // coordinates at it. Start and end points are set the same if // the cursor is not being dragged. if (this.Measurement != null) { if (ps.PhysicalXAxis1Cache != null && ps.PhysicalYAxis1Cache != null) { var args = new MeasurementArgs(); args.Start = new PointF( (float)ps.PhysicalXAxis1Cache.PhysicalToWorld(this.start, true), (float)ps.PhysicalYAxis1Cache.PhysicalToWorld(this.start, true) ); args.End = !this.active ? args.Start : new PointF( (float)ps.PhysicalXAxis1Cache.PhysicalToWorld(this.end, true), (float)ps.PhysicalYAxis1Cache.PhysicalToWorld(this.end, true) ); this.Measurement(ps, args); } } ps.QueueDraw(previous); ps.QueueDraw(this.extent); 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> /// 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); }
public override bool DoMouseDown(int x, int y, Modifier keys, InteractivePlotSurface2D ps) { Rectangle area = ps.PlotAreaBoundingBoxCache; // Left mouse button triggers a drag. if ((keys & Modifier.Button1) > 0) { if (area.Contains(x, y)) { this.active = true; this.start = new Point(x, y); this.end = this.start; this.extent = new Rectangle(x - this.offset, y - this.offset, this.offset * 2 + 1, this.offset * 2); } } ps.QueueDraw(this.extent); 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); }
public override bool DoMouseUp(int x, int y, Modifier keys, InteractivePlotSurface2D ps) { ps.QueueDraw(this.extent); this.active = false; this.extent = Rectangle.Empty; if (this.Measurement != null) { if (ps.PhysicalXAxis1Cache != null && ps.PhysicalYAxis1Cache != null) { var args = new MeasurementArgs(); args.End = args.Start = new PointF( (float)ps.PhysicalXAxis1Cache.PhysicalToWorld(this.start, true), (float)ps.PhysicalYAxis1Cache.PhysicalToWorld(this.start, true) ); this.Measurement(ps, args); } } return(false); }
public override bool DoMouseDown(int x, int y, Modifier keys, InteractivePlotSurface2D ps) { Rectangle area = ps.PlotAreaBoundingBoxCache; // Left mouse button triggers a drag. if ((keys & Modifier.Button1) > 0) { if (area.Contains(x, y)) { this.active = true; this.start = new Point(x, y); this.end = this.start; this.extent = new Rectangle(x - this.offset, y - this.offset, this.offset * 2 + 1, this.offset * 2); } } ps.QueueDraw(this.extent); return false; }
/// <summary> /// MouseMove method for PlotScroll /// </summary> public override bool DoMouseMove(int X, int Y, Modifier keys, InteractivePlotSurface2D ps) { // delete previous focusPoint drawing ps.QueueDraw (focusRect); 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> /// 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> /// 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); }
/// <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> /// 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; }
public override bool DoMouseUp(int x, int y, Modifier keys, InteractivePlotSurface2D ps) { ps.QueueDraw(this.extent); this.active = false; this.extent = Rectangle.Empty; if (this.Measurement != null) { if (ps.PhysicalXAxis1Cache != null && ps.PhysicalYAxis1Cache != null) { var args = new MeasurementArgs(); args.End = args.Start = new PointF( (float)ps.PhysicalXAxis1Cache.PhysicalToWorld(this.start, true), (float)ps.PhysicalYAxis1Cache.PhysicalToWorld(this.start, true) ); this.Measurement(ps, args); } } return false; }
public override bool DoMouseMove(int x, int y, Modifier keys, InteractivePlotSurface2D ps) { Rectangle previous = this.extent; // If the mouse is being dragged then set the end point and extent // rectangle accordingly. Otherwise simply set the start coordinates // the current cursor position. if (this.active) { this.end = new Point(x, y); this.extent = new Rectangle( Math.Min(this.start.X, this.end.X) - this.offset, Math.Min(this.start.Y, this.end.Y) - this.offset, Math.Abs(this.end.X - this.start.X) + this.offset * 2 + 1, Math.Abs(this.end.Y - this.start.Y) + this.offset * 2 + 1 ); } else { this.start = new Point(x, y); this.extent = Rectangle.Empty; } // If an event handler has been set then throw the latest world // coordinates at it. Start and end points are set the same if // the cursor is not being dragged. if (this.Measurement != null) { if (ps.PhysicalXAxis1Cache != null && ps.PhysicalYAxis1Cache != null) { var args = new MeasurementArgs(); args.Start = new PointF( (float)ps.PhysicalXAxis1Cache.PhysicalToWorld(this.start, true), (float)ps.PhysicalYAxis1Cache.PhysicalToWorld(this.start, true) ); args.End = !this.active ? args.Start : new PointF( (float)ps.PhysicalXAxis1Cache.PhysicalToWorld(this.end, true), (float)ps.PhysicalYAxis1Cache.PhysicalToWorld(this.end, true) ); this.Measurement(ps, args); } } ps.QueueDraw(previous); ps.QueueDraw(this.extent); return false; }