Ejemplo n.º 1
0
        public override bool OnButtonPressed(ButtonEventArgs args, PlotCanvas pc)
        {
            // Only start scaling if mouse is inside plot area (excluding axes)
            Rectangle area = pc.PlotAreaBoundingBoxCache;

            if (area.Contains(args.Position))
            {
                scaling   = true;
                lastPoint = new Point(args.X, args.Y);
                if (args.Button == PointerButton.Left)
                {
                    if (Horizontal)
                    {
                        ;                        //pc.plotCursor = CursorType.LeftRight;
                    }
                    if (Vertical)
                    {
                        ;                        //pc.plotCursor = CursorType.UpDown;
                    }
                    if (Horizontal && Vertical)
                    {
                        ;                        //pc.plotCursor = CursorType.Zoom;
                    }
                }
                // evaluate focusPoint about which axis is expanded
                focusX = (double)(args.X - area.Left) / (double)area.Width;
                focusY = (double)(area.Bottom - args.Y) / (double)area.Height;
            }
            return(false);
        }
Ejemplo n.º 2
0
        public override bool OnMouseMoved(MouseMovedEventArgs args, PlotCanvas pc)
        {
            Rectangle area = pc.PlotAreaBoundingBoxCache;

            if (dragging && physicalAxis != null)
            {
                pc.CacheAxes();

                double dX = args.X - lastPoint.X;
                double dY = args.Y - lastPoint.Y;
                lastPoint = new Point(args.X, args.Y);

                double length = physicalAxis.PhysicalLength;

                if (translateX)
                {
                    double xShift = -dX / length;
                    pc.TranslateXAxes(xShift);
                }
                if (translateY)
                {
                    double yShift = +dY / length;
                    pc.TranslateYAxes(yShift);
                }
                return(true);
            }
            return(false);
        }
Ejemplo n.º 3
0
        public override bool OnMouseMoved(MouseMovedEventArgs args, PlotCanvas pc)
        {
            double X = args.X;
            double Y = args.Y;

            if (selectionActive)
            {
                // note last selection rectangle
                Rectangle lastSelection = selection;
                Rectangle bounds        = pc.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);

                pc.Canvas.QueueDraw(lastSelection);
                //Console.WriteLine ("Erase: {0} {1} {2} {3} ", lastSelection.X, lastSelection.Y, lastSelection.Width, lastSelection.Height);
                pc.Canvas.QueueDraw(selection);
            }
            return(false);
        }
Ejemplo n.º 4
0
        public override bool OnMouseMoved(MouseMovedEventArgs args, PlotCanvas pc)
        {
            Rectangle area = pc.PlotAreaBoundingBoxCache;

            if (dragging)
            {
                pc.CacheAxes();

                double dX = args.X - lastPoint.X;                               // distance mouse has moved
                double dY = args.Y - lastPoint.Y;
                lastPoint = new Point(args.X, args.Y);

                // Axis translation required
                double xShift = -dX / area.Width;
                double yShift = +dY / area.Height;

                if (Horizontal)
                {
                    pc.TranslateXAxes(xShift);
                }
                if (Vertical)
                {
                    pc.TranslateYAxes(yShift);
                }
                return(true);
            }
            return(false);
        }
Ejemplo n.º 5
0
        public override bool OnMouseMoved(MouseMovedEventArgs args, PlotCanvas pc)
        {
            Rectangle area = pc.PlotAreaBoundingBoxCache;

            if (scaling)
            {
                pc.CacheAxes();

                double dX = args.X - lastPoint.X;                               // distance mouse has moved
                double dY = args.Y - lastPoint.Y;
                lastPoint = new Point(args.X, args.Y);

                // Alt key reduces sensitivity
                double factor = Sensitivity;
                if (key == Key.AltLeft || key == Key.AltRight)
                {
                    factor *= 0.25;                        // arbitrary change
                }

                double xProportion = +dX * factor / area.Width;
                double yProportion = -dY * factor / area.Height;
                if (Horizontal)
                {
                    pc.ZoomXAxes(xProportion, focusX);
                }
                if (Vertical)
                {
                    pc.ZoomYAxes(yProportion, focusY);
                }
                return(true);
            }
            return(false);
        }
Ejemplo n.º 6
0
 public override bool OnMouseExited(EventArgs args, PlotCanvas pc)
 {
     if (selectionActive)
     {
         pc.Canvas.QueueDraw(selection);
         selectionActive = false;
     }
     return(false);
 }
Ejemplo n.º 7
0
 public override bool OnButtonReleased(ButtonEventArgs args, PlotCanvas pc)
 {
     if (scaling)
     {
         lastPoint = unset;
         scaling   = false;
         //pc.plotCursor = CursorType.LeftPointer;
     }
     return(false);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// OnButtonPressed method for AxisScale interaction
        /// </summary>
        public override bool OnButtonPressed(ButtonEventArgs args, PlotCanvas pc)
        {
            // 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 scaling
            if (pc.PlotAreaBoundingBoxCache.Contains(args.X, args.Y))
            {
                return(false);
            }

            if (args.Button == PointerButton.Left)
            {
                // see if hit with axis. NB Only one axis object will be returned
                ArrayList objects = pc.HitTest(new Point(args.X, args.Y));

                foreach (object o in objects)
                {
                    if (o is Axis)
                    {
                        dragging = true;
                        axis     = (Axis)o;
                        if (pc.PhysicalXAxis1Cache.Axis == axis)
                        {
                            physicalAxis = pc.PhysicalXAxis1Cache;
                            //pc.plotCursor = CursorType.LeftRight;
                        }
                        else if (pc.PhysicalXAxis2Cache.Axis == axis)
                        {
                            physicalAxis = pc.PhysicalXAxis2Cache;
                            //ps.plotCursor = CursorType.LeftRight;
                        }
                        else if (pc.PhysicalYAxis1Cache.Axis == axis)
                        {
                            physicalAxis = pc.PhysicalYAxis1Cache;
                            //pc.plotCursor = CursorType.UpDown;
                        }
                        else if (pc.PhysicalYAxis2Cache.Axis == axis)
                        {
                            physicalAxis = pc.PhysicalYAxis2Cache;
                            //pc.plotCursor = CursorType.UpDown;
                        }

                        startPoint = new Point(args.X, args.Y);
                        lastPoint  = startPoint;

                        // evaluate focusRatio about which axis is expanded
                        double x = startPoint.X - physicalAxis.PhysicalMin.X;
                        double y = startPoint.Y - physicalAxis.PhysicalMin.Y;
                        double r = Math.Sqrt(x * x + y * y);
                        focusRatio = r / physicalAxis.PhysicalLength;
                        return(false);
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// OnButtonReleased method for AxisDrag interaction
 /// </summary>
 public override bool OnButtonReleased(ButtonEventArgs args, PlotCanvas pc)
 {
     if (dragging)
     {
         physicalAxis = null;
         lastPoint    = unset;
         dragging     = false;
         translateX   = false;
         translateY   = false;
     }
     return(false);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// OnButtonReleased method for AxisScale interaction
 /// </summary>
 public override bool OnButtonReleased(ButtonEventArgs args, PlotCanvas pc)
 {
     if (dragging)
     {
         dragging     = false;
         axis         = null;
         physicalAxis = null;
         lastPoint    = new Point();
         //pc.plotCursor = CursorType.LeftPointer;
     }
     return(false);
 }
Ejemplo n.º 11
0
        public override bool OnButtonPressed(ButtonEventArgs args, PlotCanvas pc)
        {
            // Only start selection if mouse is inside plot area (excluding axes)
            Rectangle area = pc.PlotAreaBoundingBoxCache;

            if (args.Button == PointerButton.Left && area.Contains(args.Position))
            {
                selectionActive = true;
                startPoint.X    = args.X;
                startPoint.Y    = args.Y;
                endPoint        = startPoint;
            }
            return(false);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Handler for KeyPressed events
        /// </summary>
        /// <param name="args">the Xwt.KeyEventArgs</param>
        /// <param name="pc">the PlotCanvas</param>
        /// <returns>
        /// true if the underlying (cached) plot requires redrawing, otherwise false
        /// </returns>
        public override bool OnKeyPressed(KeyEventArgs args, PlotCanvas pc)
        {
            double factor = Sensitivity;
            Key key = args.Key;
            ModifierKeys modifiers = args.Modifiers;

            if ((modifiers & ModifierKeys.Alt) != 0) {
                factor = Sensitivity * altFactor;
            }

            if (key == Key.Home || key == Key.NumPadHome) {
                pc.SetOriginalDimensions ();
                return true;
            }
            if (key == Key.Left || key == Key.NumPadLeft) {
                pc.CacheAxes();
                pc.TranslateXAxes (factor * left);
                return true;
            }
            if (key == Key.Right || key == Key.NumPadRight) {
                pc.CacheAxes();
                pc.TranslateXAxes (factor*right);
                return true;
            }
            if (key == Key.Up || key == Key.NumPadUp) {
                pc.CacheAxes ();
                pc.TranslateYAxes (factor*up);
                return true;
            }
            if (key == Key.Down || key == Key.NumPadDown) {
                pc.CacheAxes ();
                pc.TranslateYAxes (factor*down);
                return true;
            }
            if (key == Key.Plus || key == Key.NumPadAdd) {
                pc.CacheAxes ();
                pc.ZoomXAxes (zoomIn*factor, symmetrical);
                pc.ZoomYAxes (zoomIn*factor, symmetrical);
                return true;
            }
            if (key == Key.Minus || key == Key.NumPadSubtract) {
                pc.CacheAxes ();
                pc.ZoomXAxes (zoomOut*factor, symmetrical);
                pc.ZoomYAxes (zoomOut*factor, symmetrical);
                return true;
            }
            return false;
        }
Ejemplo n.º 13
0
        /// <summary>
        /// OnButtonPressed method for AxisDrag interaction
        /// </summary>
        public override bool OnButtonPressed(ButtonEventArgs args, PlotCanvas pc)
        {
            // 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 scaling
            if (pc.PlotAreaBoundingBoxCache.Contains(args.X, args.Y))
            {
                return(false);
            }

            if (args.Button == PointerButton.Left)
            {
                // see if hit with axis. NB Only one axis object will be returned
                ArrayList objects = pc.HitTest(new Point(args.X, args.Y));
                foreach (object o in objects)
                {
                    if (o is Axis)
                    {
                        dragging = true;
                        Axis axis = (Axis)o;
                        if (pc.PhysicalXAxis1Cache.Axis == axis)
                        {
                            physicalAxis = pc.PhysicalXAxis1Cache;
                            translateX   = true;
                        }
                        else if (pc.PhysicalXAxis2Cache.Axis == axis)
                        {
                            physicalAxis = pc.PhysicalXAxis2Cache;
                            translateX   = true;
                        }
                        else if (pc.PhysicalYAxis1Cache.Axis == axis)
                        {
                            physicalAxis = pc.PhysicalYAxis1Cache;
                            translateY   = true;
                        }
                        else if (pc.PhysicalYAxis2Cache.Axis == axis)
                        {
                            physicalAxis = pc.PhysicalYAxis2Cache;
                            translateY   = true;
                        }
                        lastPoint = new Point(args.X, args.Y);
                        return(false);
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 14
0
        public override bool OnButtonPressed(ButtonEventArgs args, PlotCanvas pc)
        {
            // Only start drag if mouse is inside plot area (excluding axes)
            Rectangle area = pc.PlotAreaBoundingBoxCache;

            if (area.Contains(args.Position))
            {
                dragging  = true;
                lastPoint = new Point(args.X, args.Y);
                if (args.Button == PointerButton.Left)
                {
                    if (Horizontal || Vertical)
                    {
                        //pc.plotCursor = CursorType.Hand;
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Mouse Scroll (wheel) method for PlotZoom interaction
        /// </summary>
        public override bool OnMouseScrolled(MouseScrolledEventArgs args, PlotCanvas pc)
        {
            double proportion = 0.1 * Sensitivity;              // use initial zoom of 10%
            double focusX = 0.5, focusY = 0.5;                  // default focus point

            double direction = 1;

            if (args.Direction == ScrollDirection.Down)
            {
                direction = -1;
            }

            // Zoom direction is +1 for Up/ZoomIn, or -1 for Down/ZoomOut
            proportion *= -direction;

            // delete previous focusPoint drawing
            pc.Canvas.QueueDraw(focusRect);

            Rectangle area = pc.PlotAreaBoundingBoxCache;

            if (area.Contains(args.X, args.Y))
            {
                focus.X = args.X;
                focus.Y = args.Y;
                focusX  = (double)(args.X - area.Left) / (double)area.Width;
                focusY  = (double)(area.Bottom - args.Y) / (double)area.Height;
            }

            // Zoom in/out for all defined axes
            pc.CacheAxes();
            pc.ZoomXAxes(proportion, focusX);
            pc.ZoomYAxes(proportion, focusY);

            double x = focus.X - 32;
            double y = focus.Y - 32;

            focusRect = new Rectangle(x, y, 64, 64);
            // draw new focusRect
            pc.Canvas.QueueDraw(focusRect);

            return(true);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// OnMouseMoved method for AxisScale interaction
        /// </summary>
        public override bool OnMouseMoved(MouseMovedEventArgs args, PlotCanvas pc)
        {
            if (dragging && physicalAxis != null)
            {
                pc.CacheAxes();

                double dX = (args.X - lastPoint.X);
                double dY = (args.Y - lastPoint.Y);
                lastPoint = new Point(args.X, args.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);
        }
Ejemplo n.º 17
0
        public override bool OnButtonReleased(ButtonEventArgs args, PlotCanvas pc)
        {
            bool modified = false;

            // delete previous overlay rectangle
            pc.Canvas.QueueDraw(selection);

            if (selectionActive)
            {
                selectionActive = false;
                Rectangle bounds = pc.PlotAreaBoundingBoxCache;
                if (!bounds.Contains(endPoint))
                {
                    // MouseUp outside plotArea - cancel selection
                    modified = false;
                }
                else
                {
                    pc.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;

                    pc.DefineXAxes(xMinProp, xMaxProp);
                    pc.DefineYAxes(yMinProp, yMaxProp);
                    modified = true;
                }
            }
            return(modified);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// OnButtonPressed method for AxisDrag interaction
        /// </summary>
        public override bool OnButtonPressed(ButtonEventArgs args, PlotCanvas pc)
        {
            // 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 scaling
            if (pc.PlotAreaBoundingBoxCache.Contains(args.X, args.Y)) {
                return false;
            }

            if (args.Button == PointerButton.Left) {
                // see if hit with axis. NB Only one axis object will be returned
                ArrayList objects = pc.HitTest (new Point(args.X, args.Y));
                foreach (object o in objects) {
                    if (o is Axis) {
                        dragging = true;
                        Axis axis = (Axis)o;
                        if (pc.PhysicalXAxis1Cache.Axis == axis) {
                            physicalAxis = pc.PhysicalXAxis1Cache;
                            translateX = true;
                        }
                        else if (pc.PhysicalXAxis2Cache.Axis == axis) {
                            physicalAxis = pc.PhysicalXAxis2Cache;
                            translateX = true;
                        }
                        else if (pc.PhysicalYAxis1Cache.Axis == axis) {
                            physicalAxis = pc.PhysicalYAxis1Cache;
                            translateY = true;
                        }
                        else if (pc.PhysicalYAxis2Cache.Axis == axis) {
                            physicalAxis = pc.PhysicalYAxis2Cache;
                            translateY = true;
                        }
                        lastPoint = new Point (args.X, args.Y);
                        return false;
                    }
                }
            }
            return false;
        }
Ejemplo n.º 19
0
 /// <summary>
 /// MouseMove method for PlotScroll
 /// </summary>
 public override bool OnMouseMoved(MouseMovedEventArgs args, PlotCanvas pc)
 {
     // delete previous focusPoint drawing
     pc.Canvas.QueueDraw(focusRect);
     return(false);
 }
Ejemplo n.º 20
0
        public override bool OnMouseMoved(MouseMovedEventArgs args, PlotCanvas pc)
        {
            Rectangle area = pc.PlotAreaBoundingBoxCache;

            if (scaling) {
                pc.CacheAxes();

                double dX = args.X - lastPoint.X;		// distance mouse has moved
                double dY = args.Y - lastPoint.Y;
                lastPoint = new Point (args.X, args.Y);

                // Alt key reduces sensitivity
                double factor = Sensitivity;
                if (key == Key.AltLeft || key == Key.AltRight) {
                    factor *= 0.25;	   // arbitrary change
                }

                double xProportion = +dX*factor/area.Width;
                double yProportion = -dY*factor/area.Height;
                if (Horizontal) {
                    pc.ZoomXAxes (xProportion, focusX);
                }
                if (Vertical) {
                    pc.ZoomYAxes (yProportion, focusY);
                }
                return true;
            }
            return false;
        }
Ejemplo n.º 21
0
 public override bool OnKeyReleased(KeyEventArgs args, PlotCanvas pc)
 {
     key = args.Key;
     return false;
 }
Ejemplo n.º 22
0
 public override bool OnButtonPressed(ButtonEventArgs args, PlotCanvas pc)
 {
     // Only start scaling if mouse is inside plot area (excluding axes)
     Rectangle area = pc.PlotAreaBoundingBoxCache;
     if (area.Contains (args.Position)) {
         scaling = true;
         lastPoint = new Point (args.X, args.Y);
         if (args.Button == PointerButton.Left) {
             if (Horizontal) {
                 ;//pc.plotCursor = CursorType.LeftRight;
             }
             if (Vertical) {
                 ;//pc.plotCursor = CursorType.UpDown;
             }
             if (Horizontal && Vertical) {
                 ;//pc.plotCursor = CursorType.Zoom;
             }
         }
         // evaluate focusPoint about which axis is expanded
         focusX = (double)(args.X - area.Left)/(double)area.Width;
         focusY = (double)(area.Bottom - args.Y)/(double)area.Height;
     }
     return false;
 }
Ejemplo n.º 23
0
 public override bool OnMouseExited(EventArgs args, PlotCanvas pc)
 {
     if (selectionActive) {
         pc.Canvas.QueueDraw (selection);
         selectionActive = false;
     }
     return false;
 }
Ejemplo n.º 24
0
        public override bool OnMouseMoved(MouseMovedEventArgs args, PlotCanvas pc)
        {
            Rectangle area = pc.PlotAreaBoundingBoxCache;

            if (dragging && physicalAxis != null) {
                pc.CacheAxes();

                double dX = args.X - lastPoint.X;
                double dY = args.Y - lastPoint.Y;
                lastPoint = new Point (args.X, args.Y);

                double length = physicalAxis.PhysicalLength;

                if (translateX) {
                    double xShift = -dX / length;
                    pc.TranslateXAxes (xShift);
                }
                if (translateY) {
                    double yShift = +dY / length;
                    pc.TranslateYAxes (yShift);
                }
                return true;
            }
            return false;
        }
Ejemplo n.º 25
0
 /// <summary>
 /// MouseMove method for PlotScroll
 /// </summary>
 public override bool OnMouseMoved(MouseMovedEventArgs args, PlotCanvas pc)
 {
     // delete previous focusPoint drawing
     pc.Canvas.QueueDraw (focusRect);
     return false;
 }
Ejemplo n.º 26
0
 public override bool OnButtonPressed(ButtonEventArgs args, PlotCanvas pc)
 {
     // Only start selection if mouse is inside plot area (excluding axes)
     Rectangle area = pc.PlotAreaBoundingBoxCache;
     if (args.Button == PointerButton.Left && area.Contains (args.Position)) {
         selectionActive = true;
         startPoint.X = args.X;
         startPoint.Y = args.Y;
         endPoint = startPoint;
     }
     return false;
 }
Ejemplo n.º 27
0
 public virtual bool OnMouseScrolled(MouseScrolledEventArgs args, PlotCanvas pc)
 {
     return(false);
 }
Ejemplo n.º 28
0
 public virtual bool OnMouseExited(EventArgs args, PlotCanvas pc)
 {
     return(false);
 }
Ejemplo n.º 29
0
        public override bool OnMouseMoved(MouseMovedEventArgs args, PlotCanvas pc)
        {
            double X = args.X;
            double Y = args.Y;

            if (selectionActive) {
                // note last selection rectangle
                Rectangle lastSelection = selection;
                Rectangle bounds = pc.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);

                pc.Canvas.QueueDraw (lastSelection);
                //Console.WriteLine ("Erase: {0} {1} {2} {3} ", lastSelection.X, lastSelection.Y, lastSelection.Width, lastSelection.Height);
                pc.Canvas.QueueDraw (selection);
            }
            return false;
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Mouse Scroll (wheel) method for PlotZoom interaction
        /// </summary>
        public override bool OnMouseScrolled(MouseScrolledEventArgs args, PlotCanvas pc)
        {
            double proportion = 0.1*Sensitivity;	// use initial zoom of 10%
            double focusX = 0.5, focusY = 0.5;		// default focus point

            double direction = 1;
            if (args.Direction == ScrollDirection.Down) {
                direction = -1;
            }

            // Zoom direction is +1 for Up/ZoomIn, or -1 for Down/ZoomOut
            proportion *= -direction;

            // delete previous focusPoint drawing
            pc.Canvas.QueueDraw (focusRect);

            Rectangle area = pc.PlotAreaBoundingBoxCache;
            if (area.Contains(args.X, args.Y)) {
                focus.X = args.X;
                focus.Y = args.Y;
                focusX = (double)(args.X - area.Left)/(double)area.Width;
                focusY = (double)(area.Bottom - args.Y)/(double)area.Height;
            }

            // Zoom in/out for all defined axes
            pc.CacheAxes();
            pc.ZoomXAxes (proportion,focusX);
            pc.ZoomYAxes (proportion,focusY);

            double x = focus.X-32;
            double y = focus.Y-32;

            focusRect = new Rectangle (x, y, 64, 64);
            // draw new focusRect
            pc.Canvas.QueueDraw (focusRect);

            return (true);
        }
Ejemplo n.º 31
0
 /// <summary>
 /// Handler for KeyRelease events
 /// </summary>
 /// <param name="key">the NPlot key enumeration</param>
 /// <param name="pc">the PlotCanvas</param>
 /// <returns></returns> 
 public override bool OnKeyReleased(KeyEventArgs args, PlotCanvas pc)
 {
     return false;
 }
Ejemplo n.º 32
0
 /// <summary>
 /// OnButtonReleased method for AxisScale interaction
 /// </summary>
 public override bool OnButtonReleased(ButtonEventArgs args, PlotCanvas pc)
 {
     if (dragging) {
         dragging = false;
         axis = null;
         physicalAxis = null;
         lastPoint = new Point();
         //pc.plotCursor = CursorType.LeftPointer;
     }
     return false;
 }
Ejemplo n.º 33
0
 /// <summary>
 /// OnButtonReleased method for AxisDrag interaction
 /// </summary>
 public override bool OnButtonReleased(ButtonEventArgs args, PlotCanvas pc)
 {
     if (dragging) {
         physicalAxis = null;
         lastPoint = unset;
         dragging = false;
         translateX = false;
         translateY = false;
     }
     return false;
 }
Ejemplo n.º 34
0
        public override bool OnButtonReleased(ButtonEventArgs args, PlotCanvas pc)
        {
            bool modified = false;

            // delete previous overlay rectangle
            pc.Canvas.QueueDraw (selection);

            if (selectionActive) {
                selectionActive = false;
                Rectangle bounds = pc.PlotAreaBoundingBoxCache;
                if (!bounds.Contains(endPoint)) {
                    // MouseUp outside plotArea - cancel selection
                    modified = false;
                }
                else {
                    pc.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;

                    pc.DefineXAxes (xMinProp, xMaxProp);
                    pc.DefineYAxes (yMinProp, yMaxProp);
                    modified = true;
                }
            }
            return modified;
        }
Ejemplo n.º 35
0
        PlotCanvas plotCanvas;          // To allow access to parent PlotCanvas

        /// <summary>
        /// Creates a new DrawingSurface and saves a reference to the PlotSurface
        /// </summary>
        internal DrawingSurface(PlotCanvas pc) : base()
        {
            plotCanvas = pc;
        }
Ejemplo n.º 36
0
 public virtual bool OnButtonReleased(ButtonEventArgs args, PlotCanvas pc)
 {
     return(false);
 }
Ejemplo n.º 37
0
 public override bool OnKeyReleased(KeyEventArgs args, PlotCanvas pc)
 {
     key = args.Key;
     return(false);
 }
Ejemplo n.º 38
0
 public virtual bool OnKeyReleased(KeyEventArgs args, PlotCanvas pc)
 {
     return(false);
 }
Ejemplo n.º 39
0
        /// <summary>
        /// OnButtonPressed method for AxisScale interaction
        /// </summary>
        public override bool OnButtonPressed(ButtonEventArgs args, PlotCanvas pc)
        {
            // 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 scaling
            if (pc.PlotAreaBoundingBoxCache.Contains(args.X, args.Y)) {
                return false;
            }

            if (args.Button == PointerButton.Left) {
                // see if hit with axis. NB Only one axis object will be returned
                ArrayList objects = pc.HitTest (new Point(args.X, args.Y));

                foreach (object o in objects) {
                    if (o is Axis) {
                        dragging = true;
                        axis = (Axis)o;
                        if (pc.PhysicalXAxis1Cache.Axis == axis) {
                            physicalAxis = pc.PhysicalXAxis1Cache;
                            //pc.plotCursor = CursorType.LeftRight;
                        }
                        else if (pc.PhysicalXAxis2Cache.Axis == axis) {
                            physicalAxis = pc.PhysicalXAxis2Cache;
                            //ps.plotCursor = CursorType.LeftRight;
                        }
                        else if (pc.PhysicalYAxis1Cache.Axis == axis) {
                            physicalAxis = pc.PhysicalYAxis1Cache;
                            //pc.plotCursor = CursorType.UpDown;
                        }
                        else if (pc.PhysicalYAxis2Cache.Axis == axis) {
                            physicalAxis = pc.PhysicalYAxis2Cache;
                            //pc.plotCursor = CursorType.UpDown;
                        }

                        startPoint = new Point (args.X, args.Y);
                        lastPoint = startPoint;

                        // evaluate focusRatio about which axis is expanded
                        double  x = startPoint.X - physicalAxis.PhysicalMin.X;
                        double  y = startPoint.Y - physicalAxis.PhysicalMin.Y;
                        double r = Math.Sqrt(x*x + y*y);
                        focusRatio = r/physicalAxis.PhysicalLength;
                        return false;
                    }
                }
            }
            return false;
        }
Ejemplo n.º 40
0
        /// <summary>
        /// OnMouseMoved method for AxisScale interaction
        /// </summary>
        public override bool OnMouseMoved(MouseMovedEventArgs args, PlotCanvas pc)
        {
            if (dragging && physicalAxis != null) {
                pc.CacheAxes();

                double dX = (args.X - lastPoint.X);
                double dY = (args.Y - lastPoint.Y);
                lastPoint = new Point (args.X, args.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;
        }
Ejemplo n.º 41
0
        public override bool OnMouseMoved(MouseMovedEventArgs args, PlotCanvas pc)
        {
            Rectangle area = pc.PlotAreaBoundingBoxCache;

            if (dragging) {
                pc.CacheAxes();

                double dX = args.X - lastPoint.X;		// distance mouse has moved
                double dY = args.Y - lastPoint.Y;
                lastPoint = new Point (args.X, args.Y);

                // Axis translation required
                double xShift = -dX / area.Width;
                double yShift = +dY / area.Height;

                if (Horizontal) {
                    pc.TranslateXAxes (xShift);
                }
                if (Vertical) {
                    pc.TranslateYAxes (yShift);
                }
                return true;
            }
            return false;
        }
Ejemplo n.º 42
0
 public override bool OnButtonReleased(ButtonEventArgs args, PlotCanvas pc)
 {
     if (dragging) {
         lastPoint = unset;
         dragging = false;
         //pc.plotCursor = CursorType.LeftPointer;
     }
     return false;
 }
Ejemplo n.º 43
0
 public virtual bool OnMouseScrolled(MouseScrolledEventArgs args, PlotCanvas pc)
 {
     return false;
 }
Ejemplo n.º 44
0
 public override bool OnButtonPressed(ButtonEventArgs args, PlotCanvas pc)
 {
     // Only start drag if mouse is inside plot area (excluding axes)
     Rectangle area = pc.PlotAreaBoundingBoxCache;
     if (area.Contains (args.Position)) {
         dragging = true;
         lastPoint = new Point (args.X, args.Y);
         if (args.Button == PointerButton.Left) {
             if (Horizontal || Vertical) {
                 //pc.plotCursor = CursorType.Hand;
             }
         }
     }
     return false;
 }
Ejemplo n.º 45
0
 public virtual bool OnButtonReleased(ButtonEventArgs args, PlotCanvas pc)
 {
     return false;
 }
Ejemplo n.º 46
0
 public virtual bool OnKeyReleased(KeyEventArgs args, PlotCanvas pc)
 {
     return false;
 }
Ejemplo n.º 47
0
 public virtual bool OnMouseEntered(EventArgs args, PlotCanvas pc)
 {
     return false;
 }
Ejemplo n.º 48
0
        PlotCanvas plotCanvas; // To allow access to parent PlotCanvas

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Creates a new DrawingSurface and saves a reference to the PlotSurface
        /// </summary>
        internal DrawingSurface(PlotCanvas pc)
            : base()
        {
            plotCanvas = pc;
        }
Ejemplo n.º 49
0
        /// <summary>
        /// Handler for KeyPressed events
        /// </summary>
        /// <param name="args">the Xwt.KeyEventArgs</param>
        /// <param name="pc">the PlotCanvas</param>
        /// <returns>
        /// true if the underlying (cached) plot requires redrawing, otherwise false
        /// </returns>
        public override bool OnKeyPressed(KeyEventArgs args, PlotCanvas pc)
        {
            double factor = Sensitivity;
            Key key = args.Key;
            ModifierKeys modifiers = args.Modifiers;

            if ((modifiers & ModifierKeys.Alt) != 0) {
                factor = Sensitivity * altFactor;
            }

            if (key == Key.Home || key == Key.NumPadHome) {
                pc.SetOriginalDimensions ();
                return true;
            }
            if (key == Key.Left || key == Key.NumPadLeft) {
                pc.CacheAxes();
                pc.TranslateXAxes (factor * left);
                return true;
            }
            if (key == Key.Right || key == Key.NumPadRight) {
                pc.CacheAxes();
                pc.TranslateXAxes (factor*right);
                return true;
            }
            if (key == Key.Up || key == Key.NumPadUp) {
                pc.CacheAxes ();
                pc.TranslateYAxes (factor*up);
                return true;
            }
            if (key == Key.Down || key == Key.NumPadDown) {
                pc.CacheAxes ();
                pc.TranslateYAxes (factor*down);
                return true;
            }
            if (key == Key.Plus || key == Key.NumPadAdd) {
                pc.CacheAxes ();
                pc.ZoomXAxes (zoomIn*factor, symmetrical);
                pc.ZoomYAxes (zoomIn*factor, symmetrical);
                return true;
            }
            if (key == Key.Minus || key == Key.NumPadSubtract) {
                pc.CacheAxes ();
                pc.ZoomXAxes (zoomOut*factor, symmetrical);
                pc.ZoomYAxes (zoomOut*factor, symmetrical);
                return true;
            }
            return false;
        }