public void PlotSpectrum(Detector detector, double OrderScale = 1) { if (detector == null) { return; } var bins = detector.GetHistogram(); if (bins == null) { return; } m_Spectrum.Series.Clear(); m_Spectrum.InvalidatePlot(true); var lineSeries = new OxyPlot.Wpf.LineSeries() { LineStyle = LineStyle.Solid, Color = OxyColors.OrangeRed.ToColor(), BrokenLineColor = OxyColors.RoyalBlue.ToColor(), DataFieldX = "X", DataFieldY = "Y", TrackerFormatString = "Point position: {W:0.######}" + Environment.NewLine + "Wavelenght: {X:0.######}" + Environment.NewLine + "Counts: {Y}" }; lineSeries.YAxisKey = "Counts"; lineSeries.XAxisKey = "WaveLength"; var step = (Math.Abs(detector.MeredionalMax - detector.MeredionalMin) / bins.Length); List <WavelenghtDataPoint> pointList = new List <WavelenghtDataPoint>(); for (int i = 0; i < bins.Length; ++i) { double x = detector.MeredionalMin + i * step - detector.XShift; if (detector.ZeroCurve != null) { pointList.Add(new WavelenghtDataPoint(detector.ZeroCurve.Evaluate(x) * OrderScale, bins[i], x)); } } lineSeries.ItemsSource = pointList; lineSeries.Items.Refresh(); m_Spectrum.Series.Add(lineSeries); m_Spectrum.InvalidatePlot(true); }
public void SetWaveLimits(SystemConfig.WaveLimits WaveLimits) { m_Limits = WaveLimits; m_Model.Series.Remove(m_WaveLimitBar); if (FullRange == false) { m_Model.Axes[0].Minimum = m_Limits.min.lambda * 0.95; m_Model.Axes[0].Maximum = m_Limits.max.lambda * 1.05; } else { if (m_Limits == null) { m_Limits = new SystemConfig.WaveLimits() { min = new SystemConfig.WaveLimit() { lambda = 0, position = 0 }, max = new SystemConfig.WaveLimit() { lambda = 1, position = 1 } } } ; if (m_Model.Axes[0].Minimum > m_Limits.min.lambda * 0.95 || Double.IsNaN(m_Model.Axes[0].Minimum)) { m_Model.Axes[0].Minimum = m_Limits.min.lambda * 0.95; } if (m_Model.Axes[0].Maximum < m_Limits.max.lambda * 1.05 || Double.IsNaN(m_Model.Axes[0].Maximum)) { m_Model.Axes[0].Maximum = m_Limits.max.lambda * 1.05; } } List <DataPoint> limitBar = new List <DataPoint>(); limitBar.Add(new DataPoint(m_Limits.min.lambda, 1.0)); limitBar.Add(new DataPoint(m_Limits.max.lambda, 1.0)); m_WaveLimitBar.ItemsSource = limitBar; m_Model.Series.Add(m_WaveLimitBar); m_Model.InvalidatePlot(true); }
private void PlotCircle(DrawCircle func, Vector <double> x, double R, string color, int linewidth) { LineSeries ls = new LineSeries() { Color = OxyPlot.OxyColor.Parse(color).ToColor(), StrokeThickness = linewidth }; DataPoint[] p = new DataPoint[x.Count]; for (int i = 0; i < x.Count; ++i) { var pd = func(x[i], R); p[i] = new DataPoint(pd[0], pd[1]); } ls.ItemsSource = p; m_Canvas.Series.Add(ls); m_Canvas.InvalidatePlot(true); }