/// <summary> /// 放大时画图函数 /// </summary> /// <param name="list"></param> /// <returns></returns> private bool Plot(List <List <Point> > list) { Paint paint = new Paint(); List <List <Point> > tempPointsList = new List <List <Point> >(); List <Visual> tempVisualList = new List <Visual>(); if (flag == 1)//这个if为根据标志位和新的序列重绘图像 { tempPointsList = CoordinateTransformDb(list); for (int i = 0; i < tempPointsList.Count; i++) { tempVisualList.Add(paint.DrawVisual(tempPointsList[i], true, false, LineType.Bezier, new Pen(color.colors[i], 1.3))); } } else if (flag == 2) { tempPointsList = CoordinateTransformRs(list); for (int i = 0; i < tempPointsList.Count; i++) { tempVisualList.Add(paint.DrawVisual(tempPointsList[i], true, false, LineType.Bezier, new Pen(color.colors[i], 1.3))); } } else if (flag == 3) { tempPointsList = CoordinateTransformError(list); for (int i = 0; i < tempPointsList.Count; i++) { tempVisualList.Add(paint.DrawVisual(tempPointsList[i], true, false, LineType.Bezier, new Pen(color.colors[i], 1.3))); } } else if (flag == 4) { tempPointsList = CoordinateTransformRs(list); for (int i = 0; i < tempPointsList.Count; i++) { tempVisualList.Add(paint.DrawVisual(tempPointsList[i], true, false, LineType.Bezier, new Pen(color.colors[i], 1.3))); } } else if (flag == 5) { tempPointsList = CoordinateTransformRs(list); for (int i = 0; i < tempPointsList.Count; i++) { tempVisualList.Add(paint.DrawVisual(tempPointsList[i], true, false, LineType.Bezier, new Pen(color.colors[i], 1.3))); } } else if (flag == 6) { tempPointsList = CoordinateTransformError(list); for (int i = 0; i < tempPointsList.Count; i++) { tempVisualList.Add(paint.DrawVisual(tempPointsList[i], true, false, LineType.Bezier, new Pen(color.colors[i / 2], 1.3))); } } //重绘图像 drawingCanvas.RemoveAll(); foreach (var visual in tempVisualList) { drawingCanvas.AddVisual(visual); } RuntimeVisualList = tempVisualList; //重新设定x坐标轴 graphicContext.LabelX_0 = xMin.ToString("f");//只保留小数点后两位 graphicContext.LabelX_1 = (xMin + gapX).ToString("f"); graphicContext.LabelX_2 = (xMin + 2 * gapX).ToString("f"); graphicContext.LabelX_3 = (xMin + 3 * gapX).ToString("f"); graphicContext.LabelX_4 = (xMin + 4 * gapX).ToString("f"); graphicContext.LabelX_5 = (xMin + 5 * gapX).ToString("f"); graphicContext.LabelX_6 = (xMin + 6 * gapX).ToString("f"); return(true); }
/// <summary> /// 程序开始直接调用画出原始图像 /// </summary> /// <param name="yLabel">要画的图的名称</param> /// <returns></returns> private bool Plot(string yLabel) { Paint paint = new Paint(); List <List <Point> > formerList = new List <List <Point> >(); foreach (var item in dictionary) { formerList.Add(item.Value); } if (yLabel.Equals("时域波形"))//这个if为将序列坐标变换后,生成visual对象,并添加显示,同时设定标志位,以保存本次所绘曲线的类型 { flag = 0; pointsList = CoordinateTransformError(formerList); for (int i = 0; i < pointsList.Count; i++) { InitialVisualList.Add(paint.DrawVisual(pointsList[i], true, false, LineType.Line, new Pen(color.colors[i], 1.3))); } graphicContext.YLabel = yLabel; graphicContext.XLabel = "时间(ns)"; } else if (yLabel.Equals("功率谱密度")) { flag = 1; pointsList = CoordinateTransformDb(formerList); for (int i = 0; i < pointsList.Count; i++) { InitialVisualList.Add(paint.DrawVisual(pointsList[i], true, false, LineType.Bezier, new Pen(color.colors[i], 1.3))); } graphicContext.YLabel = yLabel + "(dB)"; graphicContext.XLabel = "频率(MHz)"; } else if (yLabel.Equals("自相关函数")) { flag = 2; pointsList = CoordinateTransformRs(formerList); for (int i = 0; i < pointsList.Count; i++) { InitialVisualList.Add(paint.DrawVisual(pointsList[i], true, false, LineType.Bezier, new Pen(color.colors[i], 1.3))); } graphicContext.YLabel = yLabel; graphicContext.XLabel = "时延(microseconds)"; } else if (yLabel.Equals("s曲线")) { flag = 3; pointsList = CoordinateTransformError(formerList); for (int i = 0; i < pointsList.Count; i++) { InitialVisualList.Add(paint.DrawVisual(pointsList[i], true, false, LineType.Bezier, new Pen(color.colors[i], 1.3))); } graphicContext.YLabel = yLabel; graphicContext.XLabel = "时延(microseconds)"; } else if (yLabel.Equals("码跟踪精度(时延)")) { flag = 4; pointsList = CoordinateTransformRs(formerList); for (int i = 0; i < pointsList.Count; i++) { InitialVisualList.Add(paint.DrawVisual(pointsList[i], true, false, LineType.Bezier, new Pen(color.colors[i], 1.3))); } graphicContext.YLabel = yLabel; graphicContext.XLabel = "时延(microseconds)"; } else if (yLabel.Equals("码跟踪精度(信噪比)")) { flag = 5; pointsList = CoordinateTransformRs(formerList); for (int i = 0; i < pointsList.Count; i++) { InitialVisualList.Add(paint.DrawVisual(pointsList[i], true, false, LineType.Bezier, new Pen(color.colors[i], 1.3))); } graphicContext.YLabel = yLabel; graphicContext.XLabel = "信噪比(dB)"; } else if (yLabel.Equals("镜像多径引起的偏移误差")) { flag = 6; pointsList = CoordinateTransformError(formerList); for (int i = 0; i < pointsList.Count; i++) { InitialVisualList.Add(paint.DrawVisual(pointsList[i], true, false, LineType.Bezier, new Pen(color.colors[i / 2], 1.3))); } graphicContext.YLabel = yLabel; graphicContext.XLabel = "多径时延(ns)"; } //重画图像 drawingCanvas.RemoveAll(); foreach (var visual in InitialVisualList) { drawingCanvas.AddVisual(visual); } RuntimeVisualList = InitialVisualList; //设定命中判断所用的visual集合 for (int i = 0; i < dictionary.Count; i++) //添加listBox的项,以创建图例 { ListBoxItem listBoxItem = new ListBoxItem(); listBoxItem.Content = dictionary.ElementAt(i).Key; if (flag != 6) { listBoxItem.Foreground = color.colors[i]; } else { listBoxItem.Foreground = color.colors[i / 2]; } Setter setter = new Setter(FontSizeProperty, 7, "listBoxItem"); listBox.Items.Add(listBoxItem); } //设定x坐标 graphicContext.LabelX_0 = xMin.ToString("f");; graphicContext.LabelX_1 = (xMin + gapX).ToString("f"); graphicContext.LabelX_2 = (xMin + 2 * gapX).ToString("f"); graphicContext.LabelX_3 = (xMin + 3 * gapX).ToString("f"); graphicContext.LabelX_4 = (xMin + 4 * gapX).ToString("f"); graphicContext.LabelX_5 = (xMin + 5 * gapX).ToString("f"); graphicContext.LabelX_6 = (xMin + 6 * gapX).ToString("f"); return(true); }