diff --git a/uppsrc/ScatterCtrl/Properties.cpp b/uppsrc/ScatterCtrl/Properties.cpp index 4549b615d..080705db4 100644 --- a/uppsrc/ScatterCtrl/Properties.cpp +++ b/uppsrc/ScatterCtrl/Properties.cpp @@ -481,6 +481,9 @@ ProcessingTab::ProcessingTab() tab.WhenSet = THISBACK(OnSet); tabFreq.butFFT.WhenAction = THISBACK(OnFFT); + tabFreq.opXAxis = 0; + tabFreq.opXAxis.WhenAction = THISBACK(OnFFT); + tabFreq.opPhase.WhenAction = THISBACK(OnFFT); tabFit.opSeries = true; tabFit.opSeries.WhenAction = THISBACK(OnOp); @@ -727,13 +730,11 @@ void ProcessingTab::OnSet() maxdT = max(delta, maxdT); } } - if ((maxdT - mindT)/maxdT > 0.00001) { - tabFreq.comments.SetText(Format(t_("Impossible to set sampling time. It changes from %f to %f"), mindT, maxdT)); - tabFreq.samplingTime = Null; - } else { + if ((maxdT - mindT)/maxdT > 0.00001) + tabFreq.comments.SetText(Format(t_("Sampling time changes from %f to %f"), mindT, maxdT)); + else tabFreq.comments.SetText(""); - tabFreq.samplingTime = (maxdT + mindT)/2.; - } + tabFreq.samplingTime = (maxdT + mindT)/2.; } } else if (tabOpFirst && tab.Get() == 2) { tabOpFirst = false; @@ -802,51 +803,54 @@ void ProcessingTab::OnFFT() Exclamation(t_("Incorrect sampling time")); return; } + { + WaitCursor waitcursor; + + DataSource &data = tabFit.scatter.GetSeries(0); + + Vector orderedSeries; + for (int64 i = 0; i < data.GetCount(); ++i) { // Clean Nulls + if (!IsNull(data.x(i)) && !IsNull(data.y(i))) + orderedSeries << Pointf(data.x(i), data.y(i)); + } + //if (orderedSeries.GetCount() != data.GetCount()) + // errText << Format(t_("Removed %d Null points."), data.GetCount() - orderedSeries.GetCount()); + + PointfLess less; + Sort(orderedSeries, less); + + resampledSeries.Clear(); + resampledSeries << orderedSeries[0].y; + double nextSample = orderedSeries[0].x + samplingTime; + for (int i = 0; i < orderedSeries.GetCount() - 1;) { + double x0 = orderedSeries[i].x; + double x1 = orderedSeries[i + 1].x; + if (orderedSeries[i].x == nextSample) { + resampledSeries << orderedSeries[i].y; + nextSample += samplingTime; + } else if (orderedSeries[i].x < nextSample && orderedSeries[i + 1].x > nextSample) { // Linear interpolation + resampledSeries << (orderedSeries[i].y + (orderedSeries[i + 1].y - orderedSeries[i].y)* + (nextSample - orderedSeries[i].x)/(orderedSeries[i + 1].x - orderedSeries[i].x)); + nextSample += samplingTime; + } else + ++i; + } + if (orderedSeries[orderedSeries.GetCount() - 1].x == nextSample) + resampledSeries << orderedSeries[orderedSeries.GetCount() - 1].y; - DataSource &data = tabFit.scatter.GetSeries(0); - - Vector orderedSeries; - for (int64 i = 0; i < data.GetCount(); ++i) { // Clean Nulls - if (!IsNull(data.x(i)) && !IsNull(data.y(i))) - orderedSeries << Pointf(data.x(i), data.y(i)); + VectorY series(resampledSeries, 0, samplingTime); + fft = series.FFTY(samplingTime, tabFreq.opXAxis == 1, tabFreq.opPhase); } - //if (orderedSeries.GetCount() != data.GetCount()) - // errText << Format(t_("Removed %d Null points."), data.GetCount() - orderedSeries.GetCount()); - - PointfLess less; - Sort(orderedSeries, less); - - resampledSeries.Clear(); - resampledSeries << orderedSeries[0].y; - double nextSample = orderedSeries[0].x + samplingTime; - for (int i = 0; i < orderedSeries.GetCount() - 1;) { - double x0 = orderedSeries[i].x; - double x1 = orderedSeries[i + 1].x; - if (orderedSeries[i].x == nextSample) { - resampledSeries << orderedSeries[i].y; - nextSample += samplingTime; - } else if (orderedSeries[i].x < nextSample && orderedSeries[i + 1].x > nextSample) { // Linear interpolation - resampledSeries << (orderedSeries[i].y + (orderedSeries[i + 1].y - orderedSeries[i].y)* - (nextSample - orderedSeries[i].x)/(orderedSeries[i + 1].x - orderedSeries[i].x)); - nextSample += samplingTime; - } else - ++i; - } - if (orderedSeries[orderedSeries.GetCount() - 1].x == nextSample) - resampledSeries << orderedSeries[orderedSeries.GetCount() - 1].y; - - VectorY series(resampledSeries, 0, samplingTime); - fft = series.FFTY(samplingTime); if (fft.IsEmpty()) { tabFreq.comments.SetText(errText); Exclamation(t_("Error obtaining FFT")); return; } - String legend = tabFit.scatter.GetLegend(0) + String("-") + t_("FFT"); + String legend = tabFit.scatter.GetLegend(0) + String("-") + (tabFreq.opPhase ? t_("FFT-phase [rad]") : t_("FFT")); tabFreq.scatter.AddSeries(fft).Legend(legend); tabFreq.scatter.SetMouseHandling(true, true).ShowInfo().ShowContextMenu().ShowProcessDlg().ShowPropertiesDlg(); - tabFreq.scatter.SetLabelX(t_("Period [sec]")); + tabFreq.scatter.SetLabelX(tabFreq.opXAxis == 1 ? t_("Frequency [Hz]") : t_("Period [sec]")); tabFreq.scatter.SetLabelY(legend); tabFreq.scatter.ZoomToFit(true, true); tabFreq.comments.SetText(errText); diff --git a/uppsrc/ScatterCtrl/ScatterCtrl.lay b/uppsrc/ScatterCtrl/ScatterCtrl.lay index 2e3a1baca..f701db31d 100644 --- a/uppsrc/ScatterCtrl/ScatterCtrl.lay +++ b/uppsrc/ScatterCtrl/ScatterCtrl.lay @@ -154,13 +154,16 @@ LAYOUT(ProcessingTabFit, 580, 368) ITEM(LabelBox, dv___34, SetLabel(t_("Statistical data")).RightPosZ(4, 200).TopPosZ(244, 24)) END_LAYOUT -LAYOUT(ProcessingTabFrequency, 512, 276) - ITEM(ScatterCtrl, scatter, SetPlotAreaLeftMargin(60).SetPlotAreaBottomMargin(40).HSizePosZ(0, 96).VSizePosZ(0, 20)) +LAYOUT(ProcessingTabFrequency, 524, 276) + ITEM(ScatterCtrl, scatter, SetPlotAreaLeftMargin(60).SetPlotAreaBottomMargin(40).HSizePosZ(0, 100).VSizePosZ(0, 20)) ITEM(Label, dv___1, SetLabel(t_("sec")).RightPosZ(4, 28).TopPosZ(20, 19)) ITEM(EditDouble, samplingTime, RightPosZ(36, 56).TopPosZ(20, 19)) ITEM(Button, butFFT, SetLabel(t_("FFT")).RightPosZ(4, 88).TopPosZ(48, 20)) ITEM(Label, dv___4, SetLabel(t_("Sampling time:")).RightPosZ(4, 88).TopPosZ(0, 19)) ITEM(Label, comments, HSizePosZ(0, 0).BottomPosZ(1, 19)) + ITEM(Switch, opXAxis, SetLabel(t_("Time\nFrequency")).RightPosZ(12, 76).TopPosZ(92, 32)) + ITEM(LabelBox, dv___7, SetLabel(t_("X Axis")).RightPosZ(4, 92).TopPosZ(76, 52)) + ITEM(Option, opPhase, SetLabel(t_("Show phase")).RightPosZ(4, 92).TopPosZ(132, 16)) END_LAYOUT LAYOUT(ProcessingTabOp, 544, 328) diff --git a/uppsrc/ScatterCtrl/ScatterCtrl.t b/uppsrc/ScatterCtrl/ScatterCtrl.t index 2658199b2..794eefe92 100644 --- a/uppsrc/ScatterCtrl/ScatterCtrl.t +++ b/uppsrc/ScatterCtrl/ScatterCtrl.t @@ -264,9 +264,9 @@ esES("Datos insufucientes para calcular FFT") euES("") frFR("") -T_("Impossible to set sampling time. It changes from %f to %f") +T_("Sampling time changes from %f to %f") caES("") -esES("Imposible calcular tiempo de muestreo. Cambia de %f a %f") +esES("El tiempo de muestreo varia entre %f y %f") euES("") frFR("") @@ -324,12 +324,24 @@ esES("Error obteniendo FFT") euES("") frFR("") +T_("FFT-phase [rad]") +caES("") +esES("FFT-fase [rad]") +euES("") +frFR("") + T_("FFT") caES("") esES("") euES("") frFR("") +T_("Frequency [Hz]") +caES("") +esES("Frecuencia [Hz]") +euES("") +frFR("") + T_("Period [sec]") caES("") esES("Periodo [seg]") @@ -705,6 +717,24 @@ esES("Tiempo de muestreo:") euES("") frFR("") +T_("Time\nFrequency") +caES("") +esES("Tiempo\nFrecuencia") +euES("") +frFR("") + +T_("X Axis") +caES("") +esES("Eje X") +euES("") +frFR("") + +T_("Show phase") +caES("") +esES("Mostrar fase") +euES("") +frFR("") + T_("x <") caES("") esES("")