Esempio n. 1
0
        private void GatherData(object sender, DoWorkEventArgs e)
        {
            var readDataStream = new System.IO.StreamReader(filePath, Encoding.UTF8);

            while (true)
            {
                Thread.Sleep(100);  // can use to change the poltting rate

                //Generate a test trace: an upward spiral with square corners

                #region old test code

                //double t = stopwatch.Elapsed.TotalSeconds * 0.25;
                //double sint = Math.Sin(t);
                //double cost = Math.Cos(t);
                //double x, y, z = t * 0.5;
                //Color color;

                //if (sint > 0.0 && cost > 0.0)
                //{
                //    if (sint > cost)
                //    {
                //        x = 100.0;
                //        y = 70.71 * cost + 50.0;
                //    }
                //    else
                //    {
                //        x = 70.71 * sint + 50.0;
                //        y = 100.0;
                //    }
                //    color = Colors.Red;
                //}
                //else if (sint < 0.0 && cost < 0.0)
                //{
                //    if (sint < cost)
                //    {
                //        x = 0.0;
                //        y = 70.71 * cost + 50.0;
                //    }
                //    else
                //    {
                //        x = 70.71 * sint + 50.0;
                //        y = 0.0;
                //    }
                //    color = Colors.Red;
                //}
                //else
                //{
                //    x = 50.0 * sint + 50.0;
                //    y = 50.0 * cost + 50.0;
                //    color = Colors.Blue;
                //}

                #endregion old test code

                List <Point3DPlus> points = new List <Point3DPlus>();

                Color  color = Colors.Black;
                double x = 0, y = 0, z = 0;

                const int addPointSum = 50; //can use to change the poltting rate

                for (int i = 0; i < addPointSum; i++)
                {
                    if (readDataStream.EndOfStream)
                    {
                        break;
                    }

                    var readDataLine = readDataStream.ReadLine();

                    var readDataNumbers = readDataLine.Split(' ');

                    try
                    {
                        x = Convert.ToDouble(readDataNumbers[0]);
                        y = Convert.ToDouble(readDataNumbers[1]);

                        if (readDataNumbers.Length >= 3)
                        {
                            z = Convert.ToDouble(readDataNumbers[2]);
                        }
                        else
                        {
                            z = 0;
                        }
                    }
                    catch
                    {
                        System.Windows.MessageBox.Show("Data format is error. The format is 'x y z'.", "Error", MessageBoxButton.OK,
                                                       MessageBoxImage.Error);
                        Environment.Exit(-1);
                    }

                    var point = new Point3DPlus(new Point3D(x, y, z), color, 1.5);

                    points.Add(point);
                }

                bool invoke = false;
                if (points.Count > 0)
                {
                    pointsList.Enqueue(points);
                    invoke = true;
                }

                if (invoke)
                {
                    Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action)PlotData);
                }
            }
        }
Esempio n. 2
0
 private void AddPoint(Point3DPlus point)
 {
     plot.AddPoint(point.point, point.color, point.thickness);
 }
Esempio n. 3
0
        public void MoveTo(double x, double y, double z)
        {
            var point = new Point3DPlus(new Point3D(x, y, z), color, 0);

            AddPoint(point);
        }
Esempio n. 4
0
        public void AddPoint(double x, double y, double z)
        {
            var point = new Point3DPlus(new Point3D(x, y, z), color, 1.5);

            AddPoint(point);
        }