private void DrawSeparator(double x, double tolerance, CoreMargin currentMargin, AxisOrientationNew source) { SeparatorElementCore elementCore; var key = Math.Round(x / tolerance) * tolerance; if (!Cache.TryGetValue(key, out elementCore)) { elementCore = new DateSeparatorElementCore { IsNew = true }; Cache[key] = elementCore; } else { elementCore.IsNew = false; } // Determine whether this separator is a header now ((DateSeparatorElementCore)elementCore).IsHeader = SelectedWindow.IsHeader(x); View.RenderSeparator(elementCore, Chart); elementCore.Key = key; elementCore.Value = x; elementCore.GarbageCollectorIndex = GarbageCollectorIndex; var labelsMargin = elementCore.View.UpdateLabel(SelectedWindow.FormatAxisLabel(x), this, source); currentMargin.Width = labelsMargin.TakenWidth > currentMargin.Width ? labelsMargin.TakenWidth : currentMargin.Width; currentMargin.Height = labelsMargin.TakenHeight > currentMargin.Height ? labelsMargin.TakenHeight : currentMargin.Height; currentMargin.Left = labelsMargin.Left > currentMargin.Left ? labelsMargin.Left : currentMargin.Left; currentMargin.Right = labelsMargin.Right > currentMargin.Right ? labelsMargin.Right : currentMargin.Right; currentMargin.Top = labelsMargin.Top > currentMargin.Top ? labelsMargin.Top : currentMargin.Top; currentMargin.Bottom = labelsMargin.Bottom > currentMargin.Bottom ? labelsMargin.Bottom : currentMargin.Bottom; if (LastAxisMax == null) { elementCore.State = SeparationState.InitialAdd; return; } elementCore.State = SeparationState.Keep; }
public void CreateFilter() { Func <int, double, List <double> > filterFunction = null; Func <List <double>, int, List <double> > windowFunction = null; switch (SelectedFilter.Substring(1, 2)) { case "F0": filterFunction = Filter.LowPassFilter; break; case "F1": filterFunction = Filter.MidPassFilter; break; case "F2": filterFunction = Filter.HighPassFilter; break; } switch (SelectedWindow.Substring(1, 2)) { case "O0": windowFunction = Filter.RectangularWindow; break; case "O1": windowFunction = Filter.HammingWindow; break; case "O2": windowFunction = Filter.HanningWindow; break; case "O3": windowFunction = Filter.BlackmanWindow; break; } SampledSignal signal = new SampledSignal(); signal.PointsY = Filter.CreateFilterSignal(M, K, filterFunction, windowFunction); signal.Name = FilterName + " - F"; SignalCreator.AddSignal(signal); }
public void CreateFilter() { List <double> XSamples = new List <double>(); List <double> YSamples = SelectedFilter.FilterOperation(M_FilterRow, F0_CutOffFrequency, Fp_SamplingFrequency); YSamples = SelectedWindow.WindowOperation(YSamples, M_FilterRow); for (int i = 0; i < YSamples.Count; i++) { XSamples.Add(i); } SignalData signalData = new SignalData(0) { ConversionSamplesX = XSamples, ConversionSamplesY = YSamples }; SelectedTab.SignalData = signalData; SelectedTab.IsScattered = true; SelectedTab.DrawCharts(); }
private void OnTitleBarPreviewMouseDown(object sender, MouseButtonEventArgs e) { SelectedWindow?.SelectAndPopup(); }
public void Compute() { int distancePoints = 0; double distance = 0; bool radar = false; SelectedSignal1Tab.TabContent.Data.FromSamples = true; SelectedSignal2Tab.TabContent.Data.FromSamples = true; if (SelectedSignal1Tab.TabContent.Data.HasData() && SelectedSignal2Tab.TabContent.Data.HasData()) { DataHandler data = new DataHandler(); List <double> pointsY = new List <double>(); switch (SelectedOperation.Substring(1, 2)) { case "O1": if (!SelectedSignal2Tab.TabContent.Data.IsValidConvulution(SelectedSignal1Tab.TabContent.Data)) { MessageBox.Show("Given signals are not valid", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } pointsY = SignalFiltering.CalculateConvolution(SelectedSignal1Tab.TabContent.Data.Samples, SelectedSignal2Tab.TabContent.Data.Samples); break; case "O2": int windowType = int.Parse(SelectedWindow.Substring(0, 1)); int filterType = int.Parse(SelectedFilter.Substring(0, 1)); pointsY = SignalFiltering.Filter(SelectedSignal1Tab.TabContent.Data.Samples, M, K, windowType, filterType); break; case "O3": if (!SelectedSignal2Tab.TabContent.Data.IsValidConvulution(SelectedSignal1Tab.TabContent.Data)) { MessageBox.Show("Given signals are not valid", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } pointsY = SignalFiltering.CalculateCorrelation(SelectedSignal1Tab.TabContent.Data.Samples, SelectedSignal2Tab.TabContent.Data.Samples); break; case "O4": pointsY = SignalFiltering.CalculateDistance(SelectedSignal1Tab.TabContent.Data.Samples, SignalFiltering.DelaySignal(SelectedSignal1Tab.TabContent.Data.Samples, t * SelectedSignal1Tab.TabContent.Data.Frequency), out distancePoints); distance = distancePoints * v / SelectedSignal1Tab.TabContent.Data.Frequency; radar = true; break; } data.StartTime = SelectedSignal1Tab.TabContent.Data.StartTime; data.Frequency = SelectedSignal1Tab.TabContent.Data.Frequency; data.Samples = pointsY; data.FromSamples = true; SelectedResultTab.TabContent.IsScattered = true; SelectedResultTab.TabContent.LoadData(data); SelectedResultTab.TabContent.AddOriginal = false; SelectedResultTab.TabContent.AddSamples = false; SelectedResultTab.TabContent.DrawCharts(); SelectedResultTab.TabContent.CalculateSignalInfo(isDiscrete: true, fromSamples: true); if (radar) { MessageBox.Show("Odległość: " + distance.ToString() + " m", "Radar", MessageBoxButton.OK, MessageBoxImage.Information); } } }