コード例 #1
0
        private void DrawCharts()
        {
            double[] funcValues = GetFuncValues();

            ClearChartFunction();
            DrawInitialFunction(funcValues);

            Harmonic[] harmonics = dft.GetFrequencyResponse(funcValues, countOfHarmonics);

            DrawSpectrums(harmonics);

            Func <double, double> restoredFunction             = RestoreFunction.FromHarmonics(harmonics);
            Func <double, double> restoredWithoutPhaseFunction = RestoreFunction.FromHarmonicsWithoutPhase(harmonics);

            DrawFunction(restoredFunction, chartFunctions.Series[RestoredFunctionSeries]);
            DrawFunction(restoredWithoutPhaseFunction, chartFunctions.Series[RestoredWithoutPhaseFunctionSeries]);

            DrawFilteredFunction(harmonics);

            if (chkSmoothing.Checked)
            {
                double[]   filterValues    = DrawSmoothingFunction(funcValues);
                Harmonic[] filterHarmonics = dft.GetFrequencyResponse(filterValues, countOfHarmonics);

                DrawFilteredSpectrums(filterHarmonics);
            }
        }
コード例 #2
0
        private void DrawFilteredFunction(Harmonic[] harmonics)
        {
            int  start     = 0;
            int  end       = 0;
            bool noChecked = true;

            if (chkLowPassFilter.Checked)
            {
                end       = int.Parse(txtLowPassFilter.Text);
                noChecked = false;
            }

            if (chkHighPassFilter.Checked)
            {
                start     = int.Parse(txtHighPassFilter.Text);
                noChecked = false;
            }

            if (noChecked)
            {
                if (chartFunctions.Series[FilteredFunction].Points.Count > 0)
                {
                    chartFunctions.Series[FilteredFunction].Points.Clear();
                }

                return;
            }

            Func <double, double> filteredFunction = RestoreFunction.FromHarmonics(harmonics, start, end);

            DrawFunction(filteredFunction, chartFunctions.Series[FilteredFunction]);
        }