public virtual bool DoMouseLeave(InteractivePlotSurface2D ps) { return false; }
/// <summary> /// MouseMove method for Guidelines /// </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; Rectangle lineExtent = Rectangle.Empty; if (vertical_) { if (xPos_ != -1) { // set extents to erase current vertical guideline //lineExtent = new Rectangle (yStart_.X, yStart_.Y, 1, (int)Math.Abs (yEnd_.Y - yStart_.Y)); ps.DrawOverlayLine(yStart_, yEnd_, lineColor_, false); } // Only display guideline when mouse is within the plotArea if (plotArea.Contains(X,Y)) { xPos_ = X; yStart_ = new Point(X, plotArea.Top); yEnd_ = new Point(X, plotArea.Bottom); ps.DrawOverlayLine(yStart_, yEnd_, lineColor_, true); } else { xPos_ = -1; } //if (xPos_ != -1) { // // Invalidate line extents, then DoDraw will request a new line to be drawn // ps.QueueDraw (lineExtent); //} } if (horizontal_) { if (yPos_ != -1) { // set extents to erase current vertical guideline //lineExtent = new Rectangle (xStart_.X, xStart_.Y, (int)Math.Abs (xEnd_.X - xStart_.X), 1); ps.DrawOverlayLine(xStart_, xEnd_, lineColor_, false); } // Only display guideline when mouse is within the plotArea if (plotArea.Contains(X,Y)) { yPos_ = Y; xStart_ = new Point(plotArea.Left,Y); xEnd_ = new Point(plotArea.Right,Y); ps.DrawOverlayLine(xStart_, xEnd_, lineColor_, true); } else { yPos_ = -1; } //if (yPos_ != -1) { // // Invalidate line extents, then DoDraw will request a new line to be drawn // ps.QueueDraw (lineExtent); //} } return false; }
public virtual bool DoKeyRelease(Modifier keys, InteractivePlotSurface2D ps) { return false; }
/// <summary> /// MouseUp method for AxisDrag interaction /// </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 ) { if (dragging_) { dragging_ = false; axis_ = null; physicalAxis_ = null; lastPoint_ = new Point(); ps.plotCursor = CursorType.LeftPointer; } return false; }
/// <summary> /// MouseLeave method for Guidelines /// </summary> /// <param name="ps">the InteractivePlotSurface2D</param> public override bool DoMouseLeave(InteractivePlotSurface2D ps) { Rectangle lineExtent = Rectangle.Empty; if (vertical_) { if (xPos_ != -1) { // set extents to erase current vertical guideline lineExtent = new Rectangle (yStart_.X, yStart_.Y, 1, (int)Math.Abs (yEnd_.Y - yStart_.Y)); ps.DrawOverlayLine(yStart_, yEnd_, lineColor_, false); } xPos_ = -1; } if (horizontal_) { if (yPos_ != -1) { // set extents to erase current vertical guideline lineExtent = new Rectangle (xStart_.X, xStart_.Y, (int)Math.Abs (xEnd_.X - xStart_.X), 1); ps.DrawOverlayLine(xStart_, xEnd_, lineColor_, false); } yPos_ = -1; } return false; }
/// <summary> /// MouseDown method for PlotDrag interaction /// </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 DoMouseDown(int X, int Y, Modifier keys, InteractivePlotSurface2D ps) { // Only start drag if mouse is inside plot area (excluding axes) Rectangle area = ps.PlotAreaBoundingBoxCache; if (area.Contains(X,Y)) { dragInitiated_ = true; lastPoint_ = new Point(X,Y); if (((keys & Modifier.Button1) != 0)) { // Drag if (horizontal_ || vertical_) { ps.plotCursor = CursorType.Hand; } if (((keys & Modifier.Control) != 0)) { // Zoom if (horizontal_) ps.plotCursor = CursorType.LeftRight; if (vertical_) ps.plotCursor = CursorType.UpDown; if (horizontal_ && vertical_) ps.plotCursor = CursorType.Zoom; } } // evaluate focusPoint about which axis is expanded focusX = (double)(X - area.Left)/(double)area.Width; focusY = (double)(area.Bottom - Y)/(double)area.Height; } return false; }
/// <summary> /// MouseMove method for AxisDrag interaction /// </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) { if (((keys & Modifier.Button1) != 0) && dragging_&& physicalAxis_ != null ) { ps.CacheAxes(); float dX = (X - lastPoint_.X); float dY = (Y - lastPoint_.Y); lastPoint_ = new Point(X, Y); // In case the physical axis is not horizontal/vertical, combine dX and dY // in a way which preserves their sign and intuitive axis zoom sense, ie // because the physical origin is top-left, expand with +ve dX, but -ve dY double distance = dX - dY; double proportion = distance*sensitivity_ /physicalAxis_.PhysicalLength; axis_.IncreaseRange(proportion, focusRatio_); return true; } 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; if (selectionActive_) { // erase current (clipped) rectangle ps.DrawOverlayRectangle(startPoint_, endPoint_, Color.White, false); endPoint_.X = X; endPoint_.Y = Y; 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.DefineAxis(ps.XAxis1, xMinProp, xMaxProp); ps.DefineAxis(ps.XAxis2, xMinProp, xMaxProp); ps.DefineAxis(ps.YAxis1, yMinProp, yMaxProp); ps.DefineAxis(ps.YAxis2, yMinProp, yMaxProp); modified = true; } selectionActive_ = false; startPoint_ = unset_; endPoint_ = unset_; } return modified; }
/// <summary> /// Handle KeyReleased for all PlotSurface interactions /// </summary> protected bool DoKeyRelease(Modifier keys, InteractivePlotSurface2D ps) { bool modified = false; foreach (Interaction i in interactions) { modified |= i.DoKeyRelease(keys,this); } if (modified) { InteractionOccurred(this); ReDraw(); } return(modified); }
/// <summary> /// MouseLeave method for RubberBand selection /// </summary> /// <param name="ps">the InteractivePlotSurface2D</param> public override bool DoMouseLeave(InteractivePlotSurface2D ps) { if (selectionActive_) { selectionActive_ = false; if (endPoint_ != unset_) { // erase latest rectangle ps.DrawOverlayRectangle(startPoint_, endPoint_, Color.White, false); } startPoint_ = unset_; endPoint_ = unset_; } return false; }
/// <summary> /// MouseMove 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 DoMouseMove(int X, int Y, Modifier keys, InteractivePlotSurface2D ps) { if (((keys & Modifier.Button1) != 0) && selectionActive_) { // clip X and Y to PlotArea Rectangle bounds = ps.PlotAreaBoundingBoxCache; X = Math.Max(X, bounds.Left); X = Math.Min(X, bounds.Right); Y = Math.Max(Y, bounds.Top); Y = Math.Min(Y, bounds.Bottom); Point here = new Point(X,Y); // delete previous overlay rectangle if (endPoint_ != unset_) { ps.DrawOverlayRectangle(startPoint_, endPoint_, Color.White, false); } endPoint_ = here; // draw the latest rectangle ps.DrawOverlayRectangle(startPoint_, endPoint_, Color.White, true); } return false; }
private Point unset_ = new Point(-1, -1); // any unset point #endregion Fields #region Methods /// <summary> /// Mouse Down 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 DoMouseDown(int X, int Y, Modifier keys, InteractivePlotSurface2D ps) { // Only start selection if mouse is inside plot area (excluding axes) if (ps.PlotAreaBoundingBoxCache.Contains(X,Y)) { selectionActive_ = true; startPoint_.X = X; startPoint_.Y = Y; // invalidate end point endPoint_ = unset_; } return false; }
/// <summary> /// MouseUp method for PlotDrag interaction /// </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) { if (dragInitiated_) { lastPoint_ = unset_; dragInitiated_ = false; ps.plotCursor = CursorType.LeftPointer; } return false; }
/// <summary> /// MouseMove method for PlotDrag interaction /// </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 area = ps.PlotAreaBoundingBoxCache; // Mouse Left-Button gives Plot Drag, Ctrl.Left-Button Zooms if (((keys & Modifier.Button1) != 0) && dragInitiated_) { ps.CacheAxes(); double dX = X - lastPoint_.X; // distance mouse has moved double dY = Y - lastPoint_.Y; lastPoint_ = new Point(X, Y); if ((keys & Modifier.Control) != 0) { // Axis re-ranging required double factor = Sensitivity; if ((keys & Modifier.Alt) != 0) { factor *= 0.25; // arbitrary change } double xProportion = +dX*factor/area.Width; double yProportion = -dY*factor/area.Height; if (horizontal_) { ps.ZoomAxis(ps.XAxis1, xProportion, focusX); ps.ZoomAxis(ps.XAxis2, xProportion, focusX); } if (vertical_) { ps.ZoomAxis(ps.YAxis1, yProportion, focusY); ps.ZoomAxis(ps.YAxis2, yProportion, focusY); } } else { // Axis translation required double xShift = -dX / area.Width; double yShift = +dY / area.Height; if (horizontal_) { ps.TranslateAxis(ps.XAxis1, xShift); ps.TranslateAxis(ps.XAxis2, xShift); } if (vertical_) { ps.TranslateAxis(ps.YAxis1, yShift); ps.TranslateAxis(ps.YAxis2, yShift); } } return true; } return false; }
public virtual bool DoMouseScroll(int X, int Y, int direction, Modifier keys, InteractivePlotSurface2D ps) { return false; }
/// <summary> /// MouseDown method for AxisDrag interaction /// </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 DoMouseDown(int X, int Y, Modifier keys, InteractivePlotSurface2D ps) { // if the mouse is inside the plot area [the tick marks may be here, // and are counted as part of the axis], then don't invoke drag. if (ps.PlotAreaBoundingBoxCache.Contains(X,Y)) { return false; } if ((keys & Modifier.Button1) != 0) { // see if hit with axis. NB Only one axis object will be returned ArrayList objects = ps.HitTest(new Point(X, Y)); foreach (object o in objects) { if (o is NPlot.Axis) { dragging_ = true; axis_ = (Axis)o; if (ps.PhysicalXAxis1Cache.Axis == axis_) { physicalAxis_ = ps.PhysicalXAxis1Cache; ps.plotCursor = CursorType.LeftRight; } else if (ps.PhysicalXAxis2Cache.Axis == axis_) { physicalAxis_ = ps.PhysicalXAxis2Cache; ps.plotCursor = CursorType.LeftRight; } else if (ps.PhysicalYAxis1Cache.Axis == axis_) { physicalAxis_ = ps.PhysicalYAxis1Cache; ps.plotCursor = CursorType.UpDown; } else if (ps.PhysicalYAxis2Cache.Axis == axis_) { physicalAxis_ = ps.PhysicalYAxis2Cache; ps.plotCursor = CursorType.UpDown; } startPoint_ = new Point(X, Y); // don't combine these - Mono lastPoint_ = startPoint_; // bug #475205 prior to 2.4 // evaluate focusRatio about which axis is expanded float x = startPoint_.X - physicalAxis_.PhysicalMin.X; float y = startPoint_.Y - physicalAxis_.PhysicalMin.Y; double r = Math.Sqrt(x*x + y*y); focusRatio_ = r/physicalAxis_.PhysicalLength; return false; } } } return false; }
public virtual bool DoMouseUp(int X, int Y, Modifier keys, InteractivePlotSurface2D ps) { return false; }
/// <summary> /// Handler for KeyRelease events /// </summary> /// <param name="key">the NPlot key enumeration</param> /// <param name="ps">the InteractivePlotSurface2D</param> /// <returns></returns> public override bool DoKeyRelease(Modifier keys, InteractivePlotSurface2D ps) { return false; }