//-------------------------------------------------------------------------------------------------------
        private void RedrawChart()
        {
            ChartPrimitive chartPrimitive = this.xyLineChart.Primitives.FirstOrDefault();

            if (chartPrimitive != null)
            {
                ChartPrimitiveXY chartPrimitiveXY = chartPrimitive as ChartPrimitiveXY;
                if (chartPrimitiveXY != null)
                {
                    chartPrimitiveXY.ShowPoints = this.showPointsCheckBox.IsChecked.Value;
                    chartPrimitiveXY.PointColor = Colors.Red;

                    chartPrimitive.IsDashed = this.dashCheckBox.IsChecked.Value;

                    if (this.showLinesCheckBox.IsChecked.Value)
                    {
                        chartPrimitiveXY.LineThickness = 1;
                    }
                    else
                    {
                        chartPrimitiveXY.LineThickness = 0;
                    }

                    this.xyLineChart.RedrawPlotLines();
                }
            }
        }
 private static void AppendLine(ChartPrimitive graph, double x, float y)
 {
     graph.AddPoint(new Point(x, y));
     if (graph.Points.Count > MaxPlots)
     {
         graph.Points.RemoveAt(0);
     }
 }
		/// <summary>
		/// Gets ChartLines and ChartPolygons for the population line, and
		/// the target line.
		/// </summary>
		public static LineAndPolygon ConvertResultsToTargetLineAndPolygon(ChartPrimitive populationLine, float[] results, Color color, string label)
		{

			// Calculate Target Primitives
			ChartPrimitive targetLine = new ChartPrimitive();
			targetLine.Color = color;
			targetLine.Dashed = true;
			targetLine.Label = label + " Target";
			targetLine.ShowInLegend = false;
			targetLine.HitTest = true;

			if (populationLine.Points.Count == results.Length)
			{
				for (int monthNo = 0; monthNo < results.Length; monthNo += 2)
				{
					targetLine.AddPoint(new Point(monthNo * .5f, results[monthNo]));
					targetLine.AddPoint(new Point(monthNo * .5f + 1f, results[monthNo + 1]));
				}
			}
			else
			{

				for (int monthNo = 0; monthNo < results.Length; ++monthNo)
				{
					targetLine.AddPoint(new Point(monthNo, results[monthNo]));
					targetLine.AddPoint(new Point(monthNo + 1f, results[monthNo]));
				}
			}

			ChartPrimitive targetPolygon = ChartUtilities.LineDiffToPolygon(populationLine, targetLine);
			color.A = (byte)(alpha * color.A);
			targetPolygon.Color = color;
			targetPolygon.Dashed = true;
			targetPolygon.ShowInLegend = false;
			targetLine.HitTest = false;

			return new LineAndPolygon(targetLine, targetPolygon);
		}
		/// <summary>
		/// Converts movements to a graphical line and polygon
		/// </summary>
		/// <param name="results"></param>
		/// <param name="color"></param>
		/// <param name="label"></param>
		/// <returns></returns>
		public static LineAndPolygon ConvertResultsToMovementLineAndPolygon(float[] results, Color color, string label)
		{
			// Create the Line
			ChartPrimitive chartLine = new ChartPrimitive();
			chartLine.Color = color;
			chartLine.Label = label;
			chartLine.ShowInLegend = true;
			chartLine.HitTest = true;

			for (int monthNo = 0; monthNo < results.Length; ++monthNo)
			{
				chartLine.AddSmoothHorizontalBar(new Point(monthNo + .5f, results[monthNo]));
			}

			// Create the polygon
			ChartPrimitive polygon = ChartUtilities.ChartLineToBaseLinedPolygon(chartLine);
			color.A = (byte)(alpha * color.A);
			polygon.Color = color;
			polygon.ShowInLegend = false;
			polygon.HitTest = false;

			return new LineAndPolygon(chartLine, polygon);
		}
        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
        }
 private static void AppendLineXZ(ChartPrimitive graph, Vector3 plot)
 {
     AppendLine(graph, plot.X, plot.Z);
 }
Пример #7
0
 public LineAndPolygon(ChartPrimitive line, ChartPrimitive polygon)
 {
     Line    = line;
     Polygon = polygon;
 }
Пример #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)
		{
			// Add test Lines to demonstrate the control

			xyLineChart.Primitives.Clear();

			double limit = 5;
			double increment = 1;

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

            //for (int lineNo = 0; lineNo < 3; ++lineNo)
            //{
            //    ChartPrimitive 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)
			{
				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
                DateTime date = DateTime.Now;
			    int i = 0;
				for (double x = 0; x < limit + increment*.5; x += increment)
				{
                    line.AddPoint(date.Add(new TimeSpan(0, i++, 0)).Ticks, -2 * 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();
		}
Пример #9
0
		/// <summary>
		/// Takes two lines and creates a polyon between them
		/// </summary>
		/// <param name="baseLine"></param>
		/// <param name="topLine"></param>
		/// <returns></returns>
		public static ChartPrimitive LineDiffToPolygon(ChartPrimitive baseLine, ChartPrimitive topLine)
		{
			ChartPrimitive polygon = new ChartPrimitive();
			List<Point> baseLinePoints = baseLine.Points;
			List<Point> topLinePoints = topLine.Points;

			for (int pointNo = baseLinePoints.Count - 1; pointNo >= 0; --pointNo)
			{
				polygon.AddPoint(baseLinePoints[pointNo]);
			}
			for (int pointNo = 0; pointNo < topLinePoints.Count; ++pointNo)
			{
				polygon.AddPoint(topLinePoints[pointNo]);
			}

			polygon.Filled = true;

			return polygon;
		}
Пример #10
0
		}//GetPlotRectangle

		/// <summary>
		/// Converts a ChartLine object to a ChartPolygon object that has
		/// one edge along the bottom Horizontal base line in the plot.
		/// </summary>
		/// <param name="chartLine"></param>
		/// <returns></returns>
		public static ChartPrimitive ChartLineToBaseLinedPolygon(ChartPrimitive chartLine)
		{
			ChartPrimitive chartPolygon = chartLine.Clone();

			Point firstPoint = chartPolygon.Points[0];
			firstPoint.Y = 0;
			Point lastPoint = chartPolygon.Points[chartPolygon.Points.Count - 1];
			lastPoint.Y = 0;

			chartPolygon.InsertPoint(firstPoint, null, 0);
			chartPolygon.AddPoint(lastPoint);
			chartPolygon.Filled = true;

			return chartPolygon;
		}
Пример #11
0
		public LineAndPolygon(ChartPrimitive line, ChartPrimitive polygon)
		{
			Line = line;
			Polygon = polygon;
		}
 /// <summary>
 /// Initialize a set of markers.
 /// </summary>
 /// <param name="parentPrimitive"></param>
 public ChartMarkerSet(ChartPrimitive parentPrimitive)
 {
     _parentPrimitive = parentPrimitive;
     _geometry        = new GeometryGroup();
     _points          = new List <ChartPoint>();
 }
Пример #13
0
		/// <summary>
		/// Converts population level to a line and polygon
		/// </summary>
		/// <param name="results"></param>
		/// <param name="color"></param>
		/// <param name="label"></param>
		/// <returns></returns>
		public static LineAndPolygon ConvertResultsToPopulationLineAndPolygon(float[] results, Color color, string label)
		{
			ChartPrimitive populationLine = new ChartPrimitive();
			populationLine.Color = color;
			populationLine.Label = label;
			populationLine.ShowInLegend = true;
			populationLine.HitTest = true;

			for (int monthNo = 0; monthNo < results.Length; monthNo += 2)
			{
				populationLine.AddPoint(new Point(monthNo * .5f, results[monthNo]));
				populationLine.AddPoint(new Point(monthNo * .5f + 1f, results[monthNo + 1]));
			}

			ChartPrimitive populationPolygon = ChartUtilities.ChartLineToBaseLinedPolygon(populationLine);
			color.A = (byte)(alpha * color.A);
			populationPolygon.Color = color;
			populationPolygon.ShowInLegend = false;
			populationPolygon.HitTest = false;

			return new LineAndPolygon(populationLine, populationPolygon);
		}
 /// <summary>
 /// Initialize a set of markers.
 /// </summary>
 /// <param name="parentPrimitive"></param>
 public ChartMarkerSet(ChartPrimitive parentPrimitive)
 {
     _parentPrimitive = parentPrimitive;
     _geometry = new GeometryGroup();
     _points = new List<ChartPoint>();
 }
        public void AddToComparison(FlightLog flightLog, Color graphColor, string label, double thickness)
        {
            var posGraph = new ChartPrimitive
            {
                Filled        = false,
                Dashed        = false,
                ShowInLegend  = true,
                LineThickness = thickness,
                HitTest       = true,
                Color         = graphColor,
                Label         = label
            };

            var altitudeGraph = new ChartPrimitive
            {
                Filled        = false,
                Dashed        = false,
                ShowInLegend  = true,
                LineThickness = thickness,
                HitTest       = true,
                Color         = graphColor,
                Label         = label
            };

            _positionChart.Primitives.Add(posGraph);
            _heightChart.Primitives.Add(altitudeGraph);

            if (_comparisonIsEmpty)
            {
                _heightChart.Primitives.Add(_groundHeightGraph);
            }

//            _waypointMarkers = new ChartMarkerSet(_waypointGraph)
//            {
//                Stroke = Colors.Black,
//                Fill = Color.FromArgb(150, 255, 255, 0),
//                Size = 20,
//                StrokeWidth = 1,
//            };
//
//            _positionChart.MarkerSets.Add(_waypointMarkers);


            foreach (var snapshot in flightLog.Plots)
            {
                AppendLineXZ(posGraph, snapshot.True.Position);
                AppendLine(altitudeGraph, snapshot.Time.TotalSeconds, snapshot.True.Position.Y);

                if (_comparisonIsEmpty)
                {
                    AppendLine(_groundHeightGraph, snapshot.Time.TotalSeconds, snapshot.GroundAltitude);
                }
            }


//            foreach (Waypoint waypoint in flightLog.Waypoints)
//            {
//                _waypointMarkers.AddPoint(new ChartPoint("",
//                    new Point(waypoint.Position.X, waypoint.Position.Z)));
//            }

            RenderAndSetScale(flightLog.Plots.Last().Time);

            _comparisonIsEmpty = false;
        }