コード例 #1
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);
        }
コード例 #2
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);
        }
コード例 #3
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);
        }
コード例 #4
0
ファイル: PlotSelection.cs プロジェクト: lijielife/Florence
        /// <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);
        }
コード例 #5
0
ファイル: AxisDrag.cs プロジェクト: lijielife/Florence
        /// <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);
        }
コード例 #6
0
ファイル: AxisDrag.cs プロジェクト: SubaruDieselCrew/Florence
        /// <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;
        }
コード例 #7
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;
 }
コード例 #8
0
ファイル: PlotDrag.cs プロジェクト: SubaruDieselCrew/Florence
        /// <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;
        }
コード例 #9
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;
        }
コード例 #10
0
ファイル: PlotZoom.cs プロジェクト: SubaruDieselCrew/Florence
        /// <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);
        }