/// <summary>
 /// Copies the plotToCopy as a bitmap to the clipboard, and copies the
 /// chartControl to the clipboard as tab separated values.
 /// </summary>
 /// <param name="plotToCopy"></param>
 /// <param name="chartControl"></param>
 /// <param name="width">Width of the bitmap to be created</param>
 /// <param name="height">Height of the bitmap to be created</param>
 public static void CopyChartToClipboard(FrameworkElement plotToCopy, XYLineChart chartControl, double width,
                                         double height)
 {
     Bitmap bitmap = CopyFrameworkElementToBitmap(plotToCopy, width, height);
     string text = ConvertChartToSpreadsheetText(chartControl, '\t');
     var csv = new MemoryStream(Encoding.UTF8.GetBytes(ConvertChartToSpreadsheetText(chartControl, ',')));
     var dataObject = new DataObject();
     dataObject.SetData(DataFormats.Bitmap, bitmap);
     dataObject.SetData(DataFormats.Text, text);
     dataObject.SetData(DataFormats.CommaSeparatedValue, csv);
     Clipboard.SetDataObject(dataObject);
 }
Exemple #2
0
        /// <summary>
        /// Copies the plotToCopy as a bitmap to the clipboard, and copies the
        /// chartControl to the clipboard as tab separated values.
        /// </summary>
        /// <param name="plotToCopy"></param>
        /// <param name="chartControl"></param>
        /// <param name="width">Width of the bitmap to be created</param>
        /// <param name="height">Height of the bitmap to be created</param>
        public static void CopyChartToClipboard(FrameworkElement plotToCopy, XYLineChart chartControl, double width,
                                                double height)
        {
            Bitmap bitmap     = CopyFrameworkElementToBitmap(plotToCopy, width, height);
            string text       = ConvertChartToSpreadsheetText(chartControl, '\t');
            var    csv        = new MemoryStream(Encoding.UTF8.GetBytes(ConvertChartToSpreadsheetText(chartControl, ',')));
            var    dataObject = new DataObject();

            dataObject.SetData(DataFormats.Bitmap, bitmap);
            dataObject.SetData(DataFormats.Text, text);
            dataObject.SetData(DataFormats.CommaSeparatedValue, csv);
            Clipboard.SetDataObject(dataObject);
        }
Exemple #3
0
        /// <summary>
        /// Converts a chart to tab separated values
        /// </summary>
        /// <param name="xyLineChart"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public static string ConvertChartToSpreadsheetText(XYLineChart xyLineChart, char token)
        {
            int maxPrimitiveLength = 0;

            foreach (ChartPrimitive primitive in xyLineChart.Primitives)
            {
                maxPrimitiveLength = Math.Max(maxPrimitiveLength, primitive.Points.Count);
            }
            var grid = new string[maxPrimitiveLength + 1];

            foreach (ChartPrimitive primitive in xyLineChart.Primitives)
            {
                if (primitive.ShowInLegend)
                {
                    int row = 0;
                    grid[row] += primitive.Label + " X" + token + primitive.Label + " Y" + token;
                    foreach (Point point in primitive.Points)
                    {
                        ++row;
                        grid[row] += point.X.ToString() + token + point.Y + token;
                    }
                    ++row;
                    while (row < grid.Length)
                    {
                        grid[row] += token + token.ToString();
                        ++row;
                    }
                }
            }

            var sb = new StringBuilder();

            sb.AppendLine(xyLineChart.Title);
            foreach (string line in grid)
            {
                sb.AppendLine(line.Substring(0, line.Length - 1));
            }

            return(sb.ToString());
        }
        /// <summary>
        /// Converts a chart to tab separated values
        /// </summary>
        /// <param name="xyLineChart"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public static string ConvertChartToSpreadsheetText(XYLineChart xyLineChart, char token)
        {
            int maxPrimitiveLength = 0;
            foreach (ChartPrimitive primitive in xyLineChart.Primitives)
            {
                maxPrimitiveLength = Math.Max(maxPrimitiveLength, primitive.Points.Count);
            }
            var grid = new string[maxPrimitiveLength + 1];
            foreach (ChartPrimitive primitive in xyLineChart.Primitives)
            {
                if (primitive.ShowInLegend)
                {
                    int row = 0;
                    grid[row] += primitive.Label + " X" + token + primitive.Label + " Y" + token;
                    foreach (Point point in primitive.Points)
                    {
                        ++row;
                        grid[row] += point.X.ToString() + token + point.Y + token;
                    }
                    ++row;
                    while (row < grid.Length)
                    {
                        grid[row] += token + token.ToString();
                        ++row;
                    }
                }
            }

            var sb = new StringBuilder();
            sb.AppendLine(xyLineChart.Title);
            foreach (string line in grid)
            {
                sb.AppendLine(line.Substring(0, line.Length - 1));
            }

            return sb.ToString();
        }
 public ScalarTest(XYLineChart chart)
     : base(chart)
 {
 }
        /// <summary>
        /// Adds a set of lines to the chart for test purposes
        /// </summary>
        /// <param name="xyLineChart"></param>
        public static void AddTestLines(XYLineChart xyLineChart)
        {
            if (xyLineChart == null)
                return;

            // Add test Lines to demonstrate the control

            xyLineChart.Primitives.Clear();

            double limit = 5;
            double increment = .01;

            // Create 3 normal lines
            var lines = new ChartPrimitive[3];

            for (int lineNo = 0; lineNo < 3; ++lineNo)
            {
                var line = new ChartPrimitive();

                // Label the lines
                line.Filled = true;
                line.Dashed = false;
                line.ShowInLegend = false;
                line.AddPoint(0, 0);

                // Draw 3 sine curves
                for (double x = 0; x < limit + increment*.5; x += increment)
                {
                    line.AddPoint(x, Math.Cos(x*Math.PI - lineNo*Math.PI/1.5));
                }
                line.AddPoint(limit, 0);

                // Add the lines to the chart
                xyLineChart.Primitives.Add(line);
                lines[lineNo] = line;
            }

            // Set the line colors to Red, Green, and Blue
            lines[0].Color = Color.FromArgb(90, 255, 0, 0);
            lines[1].Color = Color.FromArgb(90, 0, 180, 0);
            lines[2].Color = Color.FromArgb(90, 0, 0, 255);

            for (int lineNo = 0; lineNo < 3; ++lineNo)
            {
                var line = new ChartPrimitive();

                // Label the lines
                line.Label = "Test Line " + (lineNo + 1);
                line.ShowInLegend = true;
                line.HitTest = true;

                line.LineThickness = 1.5;
                // Draw 3 sine curves
                for (double x = 0; x < limit + increment*.5; x += increment)
                {
                    line.AddPoint(x, Math.Cos(x*Math.PI - lineNo*Math.PI/1.5));
                }

                // Add the lines to the chart
                xyLineChart.Primitives.Add(line);
                lines[lineNo] = line;
            }
            // Set the line colors to Red, Green, and Blue
            lines[0].Color = Colors.Red;
            lines[1].Color = Colors.Green;
            lines[2].Color = Colors.Blue;

            xyLineChart.Title = "Test Chart Title";
            xyLineChart.XAxisLabel = "Test Chart X Axis";
            xyLineChart.YAxisLabel = "Test Chart Y Axis";

            xyLineChart.RedrawPlotLines();
        }
        public LiveFlightLogDataProvider(XYLineChart positionChart, XYLineChart accelerometerChart, XYLineChart heightChart)
        {
            _positionChart = positionChart;
            _accelerometerChart = accelerometerChart;
            _heightChart = heightChart;

            #region Position Top View setup

            _positionChart.UniformScaling = true;
            _positionChart.Title = "Position Top View";
            _positionChart.XAxisLabel = "X [m]";
            _positionChart.YAxisLabel = "Z [m]";

            _estimatedGraph = new ChartPrimitive
                                  {
                                      Filled = false,
                                      Dashed = false,
                                      ShowInLegend = true,
                                      LineThickness = 1.5,
                                      HitTest = true,
                                      Color = Colors.Navy,
                                      Label = "Estimated"
                                  };

            _blindEstimatedGraph = new ChartPrimitive
                                       {
                                           Filled = false,
                                           Dashed = false,
                                           ShowInLegend = true,
                                           LineThickness = 1.5,
                                           HitTest = true,
                                           Color = Colors.LightBlue,
                                           Label = "Blind estimated"
                                       };

            _trueGraph = new ChartPrimitive
                             {
                                 Filled = false,
                                 Dashed = false,
                                 ShowInLegend = true,
                                 LineThickness = 1.5,
                                 HitTest = true,
                                 Color = Colors.DarkRed,
                                 Label = "True"
                             };

            _observedGraph = new ChartPrimitive
                                 {
                                     Filled = false,
                                     Dashed = false,
                                     ShowInLegend = true,
                                     LineThickness = 1.5,
                                     HitTest = true,
                                     Color = Colors.Orange,
                                     Label = "GPS"
                                 };

            #endregion

            #region Height Data setup

            _heightChart.Title = "Height data";
            _heightChart.XAxisLabel = "Time [s]";
            _heightChart.YAxisLabel = "Altitude [m]";

            _helicopterHeightGraph = new ChartPrimitive
                                         {
                                             Filled = false,
                                             Dashed = false,
                                             ShowInLegend = true,
                                             LineThickness = 1.5,
                                             HitTest = true,
                                             Color = Colors.DarkRed,
                                             Label = "True"
                                         };

            _estimatedHelicopterHeightGraph = new ChartPrimitive
            {
                Filled = false,
                Dashed = false,
                ShowInLegend = true,
                LineThickness = 1.5,
                HitTest = true,
                Color = Colors.Navy,
                Label = "Estimated"
            };

            _groundHeightGraph = new ChartPrimitive
                                     {
                                         Filled = false,
                                         Dashed = false,
                                         ShowInLegend = true,
                                         LineThickness = 1.5,
                                         HitTest = true,
                                         Color = Colors.DarkGray,
                                         Label = "Ground"
                                     };

            #endregion

            #region Acceleration Data setup

            _accelerometerChart.Title = "Accelerometer data";
            _accelerometerChart.XAxisLabel = "Time [s]";
            _accelerometerChart.YAxisLabel = "Acceleration [m/s²]";

            _accelForwardGraph = new ChartPrimitive
                                     {
                                         Filled = false,
                                         Dashed = false,
                                         ShowInLegend = true,
                                         LineThickness = 1.5,
                                         HitTest = true,
                                         Color = Colors.Navy,
                                         Label = "Accel forward"
                                     };

            _accelRightGraph = new ChartPrimitive
                                   {
                                       Filled = false,
                                       Dashed = false,
                                       ShowInLegend = true,
                                       LineThickness = 1.5,
                                       HitTest = true,
                                       Color = Colors.DarkRed,
                                       Label = "Accel right"
                                   };

            _accelUpGraph = new ChartPrimitive
                                {
                                    Filled = false,
                                    Dashed = false,
                                    ShowInLegend = true,
                                    LineThickness = 1.5,
                                    HitTest = true,
                                    Color = Colors.Orange,
                                    Label = "Accel up"
                                };

            #endregion
        }
Exemple #8
0
        /// <summary>
        /// Adds a set of lines to the chart for test purposes
        /// </summary>
        /// <param name="xyLineChart"></param>
        public static void AddTestLines(XYLineChart xyLineChart)
        {
            if (xyLineChart == null)
            {
                return;
            }

            // Add test Lines to demonstrate the control

            xyLineChart.Primitives.Clear();

            double limit     = 5;
            double increment = .01;

            // Create 3 normal lines
            var lines = new ChartPrimitive[3];

            for (int lineNo = 0; lineNo < 3; ++lineNo)
            {
                var line = new ChartPrimitive();

                // Label the lines
                line.Filled       = true;
                line.Dashed       = false;
                line.ShowInLegend = false;
                line.AddPoint(0, 0);

                // Draw 3 sine curves
                for (double x = 0; x < limit + increment * .5; x += increment)
                {
                    line.AddPoint(x, Math.Cos(x * Math.PI - lineNo * Math.PI / 1.5));
                }
                line.AddPoint(limit, 0);

                // Add the lines to the chart
                xyLineChart.Primitives.Add(line);
                lines[lineNo] = line;
            }

            // Set the line colors to Red, Green, and Blue
            lines[0].Color = Color.FromArgb(90, 255, 0, 0);
            lines[1].Color = Color.FromArgb(90, 0, 180, 0);
            lines[2].Color = Color.FromArgb(90, 0, 0, 255);

            for (int lineNo = 0; lineNo < 3; ++lineNo)
            {
                var line = new ChartPrimitive();

                // Label the lines
                line.Label        = "Test Line " + (lineNo + 1);
                line.ShowInLegend = true;
                line.HitTest      = true;

                line.LineThickness = 1.5;
                // Draw 3 sine curves
                for (double x = 0; x < limit + increment * .5; x += increment)
                {
                    line.AddPoint(x, Math.Cos(x * Math.PI - lineNo * Math.PI / 1.5));
                }

                // Add the lines to the chart
                xyLineChart.Primitives.Add(line);
                lines[lineNo] = line;
            }
            // Set the line colors to Red, Green, and Blue
            lines[0].Color = Colors.Red;
            lines[1].Color = Colors.Green;
            lines[2].Color = Colors.Blue;

            xyLineChart.Title      = "Test Chart Title";
            xyLineChart.XAxisLabel = "Test Chart X Axis";
            xyLineChart.YAxisLabel = "Test Chart Y Axis";

            xyLineChart.RedrawPlotLines();
        }
 public GPS2DTest(XYLineChart chart)
     : base(chart)
 {
 }
 public GPS_INSTest(XYLineChart chart)
     : base(chart)
 {
 }
        private void setupChart()
        {
            XYLineChart chart = new XYLineChart();
            chart.Height = 126; chart.Width = 486;

            chart.RenderTransformOrigin = new Point(0.5,0.5);
            // Add test Lines to demonstrate the control

            chart.Primitives.Clear();

            // Create 3 normal lines
            ChartPrimitive[] lines = new ChartPrimitive[3];

            for (int lineNo = 0; lineNo < 3; ++lineNo)
            {
                ChartPrimitive line = new ChartPrimitive();

                // Label the lines
                //line.Label = "Test Line " + (lineNo + 1);
                line.ShowInLegend = true;
                //line.HitTest = true;

                line.LineThickness = 1.5;
                // Draw 3 sine curves
                //for (double x = 0; x < limit + increment * .5; x += increment)
                //{
                //    line.AddPoint(x, 1);
                //}
                //line.AddPoint(0, 1);
                // Add the lines to the chart
                chart.Primitives.Add(line);
                lines[lineNo] = line;
            }
            // Set the line colors to Red, Green, and Blue
            lines[0].Label = "TrainingRate";
            lines[1].Label = "AvgTrainMSE";
            lines[2].Label = "AvgTestMSE";
            lines[0].AddPoint(0, 2);
            lines[0].AddPoint(33, 2);
            lines[1].AddPoint(0, 1.5);
            lines[1].AddPoint(33, 1.5);
            lines[2].AddPoint(0, 1);
            lines[2].AddPoint(33, 1);

            lines[0].Color = Colors.Red;
            lines[1].Color = Colors.Green;
            lines[2].Color = Colors.Blue;

            chart.Title = "TrainingParameters";
            chart.XAxisLabel = "TrainingEpoch";
            chart.YAxisLabel = "Value";

            chart.RedrawPlotLines();
            lines[0].Points.Clear();
            lines[1].Points.Clear();
            lines[2].Points.Clear();
            //lines[0].AddPoint(0, 0);
            //lines[1].AddPoint(0, 0);
            //lines[2].AddPoint(0, 0);
            //_xyLineChart = chart;
            Chart = chart;
        }
 public FlightLoggerTest(XYLineChart chart)
     : base(chart)
 {
 }
 protected GraphTestBase(XYLineChart positionChart)
 {
     Chart = positionChart;
 }