/// <summary> /// Handler for KeyPress events /// </summary> /// <param name="key">the NPlot key enumeration</param> /// <param name="ps">the InteractivePlotSurface2D</param> /// <returns></returns> public override bool DoKeyPress(Modifier keys, InteractivePlotSurface2D ps) { double factor = Sensitivity; if (((keys & Modifier.Alt) != 0)) { factor *= altFactor; } if ((keys & Modifier.Home) != 0) { ps.SetOriginalDimensions(); return(true); } if ((keys & Modifier.Left) != 0) { ps.CacheAxes(); ps.TranslateXAxes(left * factor); return(true); } if ((keys & Modifier.Right) != 0) { ps.CacheAxes(); ps.TranslateXAxes(right * factor); return(true); } if ((keys & Modifier.Up) != 0) { ps.CacheAxes(); ps.TranslateYAxes(up * factor); return(true); } if ((keys & Modifier.Down) != 0) { ps.CacheAxes(); ps.TranslateYAxes(down * factor); return(true); } if ((keys & Modifier.Plus) != 0) { ps.CacheAxes(); ps.ZoomXAxes(zoomIn * factor, symmetrical); ps.ZoomYAxes(zoomIn * factor, symmetrical); return(true); } if ((keys & Modifier.Minus) != 0) { ps.CacheAxes(); ps.ZoomXAxes(zoomOut * factor, symmetrical); ps.ZoomYAxes(zoomOut * factor, symmetrical); return(true); } 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.ZoomXAxes(xProportion, focusX); } if (vertical_) { ps.ZoomYAxes(yProportion, focusY); } } else { // Axis translation required double xShift = -dX / area.Width; double yShift = +dY / area.Height; if (horizontal_) { ps.TranslateXAxes(xShift); } if (vertical_) { ps.TranslateYAxes(yShift); } } return(true); } return(false); }
/// <summary> /// Handler for KeyPress events /// </summary> /// <param name="key">the NPlot key enumeration</param> /// <param name="ps">the InteractivePlotSurface2D</param> /// <returns></returns> public override bool DoKeyPress(Modifier keys, InteractivePlotSurface2D ps) { double factor = Sensitivity; if (((keys & Modifier.Alt) != 0)) { factor *= altFactor; } if ((keys & Modifier.Home) != 0) { ps.SetOriginalDimensions(); return true; } if ((keys & Modifier.Left) != 0) { ps.CacheAxes(); ps.TranslateXAxes (left*factor); return true; } if ((keys & Modifier.Right) != 0) { ps.CacheAxes(); ps.TranslateXAxes (right*factor); return true; } if ((keys & Modifier.Up) != 0) { ps.CacheAxes(); ps.TranslateYAxes (up*factor); return true; } if ((keys & Modifier.Down) != 0) { ps.CacheAxes(); ps.TranslateYAxes (down*factor); return true; } if ((keys & Modifier.Plus) != 0) { ps.CacheAxes(); ps.ZoomXAxes (zoomIn*factor,symmetrical); ps.ZoomYAxes (zoomIn*factor,symmetrical); return true; } if ((keys & Modifier.Minus) != 0) { ps.CacheAxes(); ps.ZoomXAxes (zoomOut*factor,symmetrical); ps.ZoomYAxes (zoomOut*factor,symmetrical); return true; } 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.ZoomXAxes (xProportion, focusX); } if (vertical_) { ps.ZoomYAxes (yProportion, focusY); } } else { // Axis translation required double xShift = -dX / area.Width; double yShift = +dY / area.Height; if (horizontal_) { ps.TranslateXAxes (xShift); } if (vertical_) { ps.TranslateYAxes (yShift); } } return true; } return false; }