示例#1
0
文件: PlotDrag.cs 项目: parnham/NPlot
 /// <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;
 }
示例#2
0
        /// <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;
        }
示例#3
0
        /// <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);
        }
示例#4
0
文件: PlotZoom.cs 项目: parnham/NPlot
        /// <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);
        }
示例#5
0
 /// <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;
 }
示例#6
0
 /// <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);
 }
示例#7
0
 /// <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;
 }
示例#8
0
 /// <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);
 }
示例#9
0
 /// <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);
 }
示例#10
0
        /// <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);
        }
示例#11
0
 /// <summary>
 /// Mouse Down method for Rubberband selection of plot region
 /// </summary>
 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;
         endPoint = startPoint;
     }
     return false;
 }
示例#12
0
        /// <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);
        }
示例#13
0
 /// <summary>
 /// Mouse Down method for Rubberband selection of plot region
 /// </summary>
 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;
         endPoint        = startPoint;
     }
     return(false);
 }
示例#14
0
 /// <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);
 }
示例#15
0
        /// <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);
        }
示例#16
0
        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);
        }
示例#17
0
文件: AxisDrag.cs 项目: parnham/NPlot
        /// <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;
        }
示例#18
0
        /// <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);
        }
示例#19
0
 /// <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;
 }
示例#20
0
        /// <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);
        }
示例#21
0
        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);
        }
示例#22
0
        /// <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);
        }
示例#23
0
        /// <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);
        }
示例#24
0
        /// <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);
        }
示例#25
0
        /// <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);
        }
示例#26
0
        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);
        }
示例#27
0
        /// <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;
        }
示例#28
0
 /// <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);
 }
示例#29
0
文件: PlotDrag.cs 项目: sanyu1/NPlot
        /// <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;
        }
示例#30
0
 public virtual bool DoKeyRelease(Modifier keys, InteractivePlotSurface2D ps)
 {
     return(false);
 }
示例#31
0
文件: AxisDrag.cs 项目: sanyu1/NPlot
        /// <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;
        }
示例#32
0
文件: PlotZoom.cs 项目: sanyu1/NPlot
        /// <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);
        }
示例#33
0
 public virtual bool DoMouseScroll(double X, double Y, int direction, Modifier keys, InteractivePlotSurface2D ps)
 {
     return false;
 }
示例#34
0
 /// <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);
 }
示例#35
0
 public virtual bool DoMouseScroll(int X, int Y, int direction, Modifier keys, InteractivePlotSurface2D ps)
 {
     return(false);
 }
示例#36
0
 public virtual bool DoMouseLeave(InteractivePlotSurface2D ps)
 {
     return(false);
 }
示例#37
0
 /// <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;
 }
示例#38
0
 public virtual bool DoMouseLeave(InteractivePlotSurface2D ps)
 {
     return false;
 }
示例#39
0
文件: Measure.cs 项目: parnham/NPlot
        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;
        }
示例#40
0
 /// <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);
 }
示例#41
0
文件: PlotZoom.cs 项目: parnham/NPlot
 /// <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;
 }
示例#42
0
文件: PlotZoom.cs 项目: sanyu1/NPlot
 /// <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;
 }
示例#43
0
 public virtual bool DoKeyRelease(Modifier keys, InteractivePlotSurface2D ps)
 {
     return false;
 }
示例#44
0
文件: AxisDrag.cs 项目: sanyu1/NPlot
 /// <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;
 }
示例#45
0
        /// <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;
        }
示例#46
0
文件: Measure.cs 项目: parnham/NPlot
        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;
        }
示例#47
0
 public virtual bool DoMouseUp(double X, double Y, Modifier keys, InteractivePlotSurface2D ps)
 {
     return false;
 }
示例#48
0
 public virtual bool DoMouseMove(int X, int Y, Modifier keys, InteractivePlotSurface2D ps)
 {
     return(false);
 }
示例#49
0
文件: Measure.cs 项目: parnham/NPlot
        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;
        }
示例#50
0
文件: PlotDrag.cs 项目: sanyu1/NPlot
 /// <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;
 }
示例#51
0
 public virtual bool DoMouseMove(int X, int Y, Modifier keys, InteractivePlotSurface2D ps)
 {
     return false;
 }