Beispiel #1
0
        public void AddPoint(GraphPoint point)
        {
            lock (_lockObject)
            {
                _samples.Add(point);

                // Updating Y range
                if (_samples.Count == 0)
                {
                    projection.UpdateAutoscrollFromMeasurement(point.Y);
                    _yMin = point.Y;
                    _yMax = point.Y;
                    return;
                }

                if (point.Y < Projection.YMin)
                {
                    _yMin = point.Y;
                    projection.UpdateAutoscrollFromMeasurement(_yMin);
                }
                else if (point.Y > Projection.YMax)
                {
                    _yMax = point.Y;
                    projection.UpdateAutoscrollFromMeasurement(_yMax);
                }
            }
        }
Beispiel #2
0
        public virtual void PaintLines(Graphics graphics)
        {
            int nCount = 0;

            if ((_isVisible == false) || (usedLength < 2)) //(_samples.Count < 2))
            {
                return;
            }

            lock (_lockObject)
            {
                _pixels = new CircularBuffer <Point>((int)usedLength); //_samples.Count);

                GraphPoint previous          = new GraphPoint();
                Point      previousProjected = new Point();
                bool       bFirst            = true;

                foreach (var sample in _samples)
                {
                    nCount++;

                    if (sample.X >= Projection.XMin && sample.X <= Projection.XMax)
                    {
                        Point p = projection.ConvertToScreenPoint(sample);
                        if (bFirst)
                        {
                            bFirst            = false;
                            previous          = sample;
                            previousProjected = p;
                        }
                        else if (sample.Y < 10000000 && sample.Y > -10000000)  // ovo je samo zbog neke greske u fazi koja uzrokuje da program ide u exception pa bude spor
                        {
                            try
                            {
                                if (!float.IsNaN(sample.Y) && !float.IsNaN(previous.Y))
                                {
                                    graphics.DrawLine(_graphPen, p.X, p.Y, previousProjected.X, previousProjected.Y);
                                }
                            }
                            catch
                            {
                                Console.WriteLine("Err. 229911: " + sample.Y + "   " + previous.Y);
                            }
                            // _pixels.Add(projection.ConvertToScreenPoint(sample));

                            previous          = sample;
                            previousProjected = p;
                        }
                        else
                        {
                            // Console.WriteLine("Err. 229912: " + sample.Y + "   " + previous.Y);
                        }
                    }
                }

                //  if (_pixels.Count > 1)
                //    graphics.DrawLines(_graphPen, _pixels.ToArray());
            }
        }
Beispiel #3
0
        public Point ConvertToScreenPoint(GraphPoint point)
        {
            Point pointResult = new Point();

            pointResult.X = (int)((point.X - XMin) * _xScalingFactor + 0.5);
            pointResult.Y = Height - (int)((point.Y - YMin) * _yScalingFactor + 0.5);

            return(pointResult);
        }
Beispiel #4
0
        public void MouseMoved(object sender, MouseEventArgs e)
        {
            if (System.Windows.Forms.Control.MouseButtons != MouseButtons.Left)
            {
                return;
            }

            int nXscreen = e.X;

            float fReal;

            paintAll(_graphicsPictureBox);
            int    x    = 0;
            String strX = "";

            for (int i = 0; i < _graphList.Count; i++)
            {
                if (_graphList[i].IsVisible())
                {
                    fReal = _graphList[i].projection.ConvertScreenXToRealValue(nXscreen);
                    strX  = "" + (int)fReal;
                    GraphPoint closest = _graphList[i].GetClosestPointTo_X(fReal);
                    if (closest != null && !float.IsNaN(closest.Y))
                    {
                        Point screenPoint = _graphList[i].projection.ConvertToScreenPoint(closest);
                        if (screenPoint.X > 0 && screenPoint.Y > 0)
                        {
                            x = screenPoint.X;
                            // strX = "" + closest.X;
                            _graphicsPictureBox.FillRectangle(new SolidBrush(Color.Yellow), screenPoint.X, screenPoint.Y, 25, 25);
                            _graphicsPictureBox.FillRectangle(new SolidBrush(Color.FromArgb(0xff, 0x00, 0x00)), screenPoint.X - 2, screenPoint.Y - 2, 4, 4);

                            _graphicsPictureBox.DrawString("" + closest.Y, new Font("Times New Roman", 10), new SolidBrush(Color.Black), screenPoint.X, screenPoint.Y);
                            this._pictureBox.Invalidate();
                        }
                    }
                }
            }

            _graphicsPictureBox.DrawString(strX, new Font("Times New Roman", 10), new SolidBrush(Color.Black), x, this.graphHeight - 20);
        }
Beispiel #5
0
        public void AddPoint(GraphPoint point, bool bUpdateAutoscroll)
        {
            lock (_lockObject)
            {
                _samples.Add(point);
                usedLength++;
                // Updating Y range
                if (_samples.Count == 1)
                {
                    if (bUpdateAutoscroll)
                    {
                        projection.UpdateAutoscrollFromMeasurement(point.Y);
                    }
                    _yMin = point.Y;
                    _yMax = point.Y;
                    return;
                }

                if (point.Y < _yMin) //Projection.YMin)
                {
                    _yMin = point.Y;

                    if (bUpdateAutoscroll)
                    {
                        projection.UpdateAutoscrollFromMeasurement(_yMin);
                    }
                }
                else if (point.Y > _yMax) //Projection.YMax)
                {
                    _yMax = point.Y;

                    if (bUpdateAutoscroll)
                    {
                        projection.UpdateAutoscrollFromMeasurement(_yMax);
                    }
                }
            }
        }
Beispiel #6
0
        public override void PaintLines(Graphics graphics)
        {
            int nCount = 0;

            if ((_isVisible == false) || (_samples.Count < 2))
            {
                return;
            }

            lock (_lockObject)
            {
                _pixels = new CircularBuffer <Point>(_samples.Count);

                GraphPoint previous = new GraphPoint();

                int nPrevPaintedX = -5;

                foreach (var sample in _samples)
                {
                    nCount++;

                    if (sample.X >= Projection.XMin && sample.X <= Projection.XMax)
                    {
                        Point p = projection.ConvertToScreenPoint(sample);

                        if (!float.IsNaN(sample.Y))
                        {
                            if (!float.IsNaN(sample.Angle))  // We have 3 coordinats
                            {
                                float fAngle = sample.Angle;
                                // TODO: Min/max of graf is from graph -constructor.
                                int nArrowLength = (int)(sample.Y * 35 / 3); // max length 35 pix. WC speed is between 0 and 5. Sow, 5 kn is shown as 35 pix
                                int f_dX         = (int)(nArrowLength * Math.Sin(fAngle * Math.PI / 180));
                                int f_dY         = (int)(nArrowLength * Math.Cos(fAngle * Math.PI / 180));
                                p.Y = nVerticalOffset;
                                Point p2 = new Point(p.X + f_dX, p.Y - f_dY);

                                if (Math.Abs(nPrevPaintedX - p.X) > 12)
                                {
                                    DrawArrow(graphics, _graphPen, new PointF(p.X, p.Y), new PointF(p2.X, p2.Y), EndpointStyle.None, EndpointStyle.ArrowHead);
                                    nPrevPaintedX = p.X;
                                }
                            }
                            else
                            {
                                float fAngle = sample.Y;
                                int   f_dX   = (int)(12 * Math.Sin(fAngle * Math.PI / 180));
                                int   f_dY   = (int)(12 * Math.Cos(fAngle * Math.PI / 180));
                                p.Y = nVerticalOffset;
                                Point p2 = new Point(p.X + f_dX, p.Y - f_dY);

                                if (Math.Abs(nPrevPaintedX - p.X) > 15)
                                {
                                    DrawArrow(graphics, _graphPen, new PointF(p.X, p.Y), new PointF(p2.X, p2.Y), EndpointStyle.None, EndpointStyle.ArrowHead);
                                    nPrevPaintedX = p.X;
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #7
0
 public void AddPoint(GraphPoint point, int nGraphIndex, bool bRecalculateVertical)
 {
     _graphList[nGraphIndex].AddPoint(point, bRecalculateVertical);
 }